From 5524124f211b436a096d06d52fdb1d4d184b6e0e Mon Sep 17 00:00:00 2001 From: Mark Yao Date: Wed, 23 Sep 2015 16:28:12 +0800 Subject: [PATCH] rk_fb: add bt2020/bt709/bt601 colorspace support Change-Id: I55177d4e40bb8111787efe654f18e3e21c016491 Signed-off-by: Mark Yao --- drivers/video/rockchip/rk_fb.c | 9 +++++-- include/linux/rk_fb.h | 43 +++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 3 deletions(-) diff --git a/drivers/video/rockchip/rk_fb.c b/drivers/video/rockchip/rk_fb.c index 0207f79f0957..5425f7505d2d 100755 --- a/drivers/video/rockchip/rk_fb.c +++ b/drivers/video/rockchip/rk_fb.c @@ -1569,6 +1569,7 @@ static void rk_fb_update_win(struct rk_lcdc_driver *dev_drv, win->alpha_mode = reg_win_data->alpha_mode; win->g_alpha_val = reg_win_data->g_alpha_val; win->mirror_en = reg_win_data->mirror_en; + win->colorspace = reg_win_data->colorspace; win->area[0].fbdc_en = reg_win_data->reg_area_data[0].fbdc_en; win->area[0].fbdc_cor_en = @@ -2163,9 +2164,11 @@ static int rk_fb_set_win_buffer(struct fb_info *info, reg_win_data->mirror_en = win_par->mirror_en; for (i = 0; i < reg_win_data->area_num; i++) { + u8 data_format = win_par->area_par[i].data_format; /*rk_fb_check_config_var(&win_par->area_par[i], screen);*/ - - fb_data_fmt = rk_fb_data_fmt(win_par->area_par[i].data_format, 0); + reg_win_data->colorspace = CSC_FORMAT(data_format); + data_format &= ~CSC_MASK; + fb_data_fmt = rk_fb_data_fmt(data_format, 0); reg_win_data->reg_area_data[i].data_format = fb_data_fmt; if (fb_data_fmt >= FBDC_RGB_565) { reg_win_data->reg_area_data[i].fbdc_en = 1; @@ -3110,6 +3113,8 @@ static int rk_fb_set_par(struct fb_info *info) ysize = screen->mode.yres; } + win->colorspace = CSC_FORMAT(data_format); + data_format &= ~CSC_MASK; fb_data_fmt = rk_fb_data_fmt(data_format, var->bits_per_pixel); if (fb_data_fmt >= FBDC_RGB_565) { win->area[0].fbdc_en = 1; diff --git a/include/linux/rk_fb.h b/include/linux/rk_fb.h index bce8db99acd9..850683afa2f6 100755 --- a/include/linux/rk_fb.h +++ b/include/linux/rk_fb.h @@ -135,10 +135,22 @@ extern bool rk_fb_poll_wait_frame_complete(void); #define OUT_D888_P666 0x21 //18bit screen,connect to lcdc D2~D7, D10~D15, D18~D23 #define OUT_D888_P565 0x22 +enum { + CSC_BT601, + CSC_BT709, + CSC_BT2020, +}; +#define CSC_SHIFT 6 +#define CSC_MASK (0x3 << CSC_SHIFT) +#define CSC_FORMAT(x) (((x) & CSC_MASK) >> CSC_SHIFT) + +#define BT601(x) ((CSC_BT601 << CSC_SHIFT) | ((x) & ~CSC_MASK)) +#define BT709(x) ((CSC_BT709 << CSC_SHIFT) | ((x) & ~CSC_MASK)) +#define BT2020(x) ((CSC_BT2020 << CSC_SHIFT) | ((x) & ~CSC_MASK)) + /** * pixel format definitions,this is copy from android/system/core/include/system/graphics.h */ - enum { HAL_PIXEL_FORMAT_RGBA_8888 = 1, HAL_PIXEL_FORMAT_RGBX_8888 = 2, @@ -187,6 +199,10 @@ enum { HAL_PIXEL_FORMAT_YV12 = 0x32315659, // YCrCb 4:2:0 Planar /* Legacy formats (deprecated), used by ImageFormat.java */ + + /* + * YCbCr format default is BT601. + */ HAL_PIXEL_FORMAT_YCbCr_422_SP = 0x10, // NV16 HAL_PIXEL_FORMAT_YCrCb_420_SP = 0x11, // NV21 HAL_PIXEL_FORMAT_YCbCr_422_I = 0x14, // YUY2 @@ -202,6 +218,29 @@ enum { HAL_PIXEL_FORMAT_FBDC_U8U8U8U8 = 0x27, /*ARGB888*/ HAL_PIXEL_FORMAT_FBDC_U8U8U8 = 0x28, /*RGBP888*/ HAL_PIXEL_FORMAT_FBDC_RGBA888 = 0x29, /*ABGR888*/ + + HAL_PIXEL_FORMAT_YCrCb_NV12_BT709 = + BT709(HAL_PIXEL_FORMAT_YCrCb_NV12), + HAL_PIXEL_FORMAT_YCrCb_NV12_VIDEO_BT709 = + BT709(HAL_PIXEL_FORMAT_YCrCb_NV12_VIDEO), + HAL_PIXEL_FORMAT_YCbCr_422_SP_BT709 = + BT709(HAL_PIXEL_FORMAT_YCbCr_422_SP), + HAL_PIXEL_FORMAT_YCrCb_444_BT709 = + BT709(HAL_PIXEL_FORMAT_YCrCb_444), + + HAL_PIXEL_FORMAT_YCrCb_NV12_10_BT709 = + BT709(HAL_PIXEL_FORMAT_YCrCb_NV12_10), + HAL_PIXEL_FORMAT_YCbCr_422_SP_10_BT709 = + BT709(HAL_PIXEL_FORMAT_YCbCr_422_SP_10), + HAL_PIXEL_FORMAT_YCrCb_420_SP_10_BT709 = + BT709(HAL_PIXEL_FORMAT_YCrCb_444_SP_10), + + HAL_PIXEL_FORMAT_YCrCb_NV12_10_BT2020 = + BT2020(HAL_PIXEL_FORMAT_YCrCb_NV12_10), + HAL_PIXEL_FORMAT_YCbCr_422_SP_10_BT2020 = + BT2020(HAL_PIXEL_FORMAT_YCbCr_422_SP_10), + HAL_PIXEL_FORMAT_YCrCb_420_SP_10_BT2020 = + BT2020(HAL_PIXEL_FORMAT_YCrCb_444_SP_10), }; //display data format @@ -381,6 +420,7 @@ struct rk_lcdc_win { u32 pseudo_pal[16]; int z_order; /*win sel layer*/ u8 fmt_10; + u8 colorspace; u32 reserved; u32 area_num; u32 scale_yrgb_x; @@ -571,6 +611,7 @@ struct rk_fb_reg_win_data { u8 alpha_mode; u16 g_alpha_val; u8 mirror_en; + u8 colorspace; struct rk_fb_reg_area_data reg_area_data[RK_WIN_MAX_AREA]; }; -- 2.34.1