From 9f2ef4bf49aedbe25d3d176be7f612b6e9435237 Mon Sep 17 00:00:00 2001 From: Huang Jiachai Date: Wed, 14 Oct 2015 10:41:00 +0800 Subject: [PATCH] video: rockchip: fb: distinguish between RGB YUV and FBDC data format Change-Id: Ia351340cf05e5264d798348178b488917ada4482 Signed-off-by: Huang Jiachai --- drivers/video/rockchip/rk_fb.c | 13 +++++-------- include/linux/rk_fb.h | 22 +++++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/video/rockchip/rk_fb.c b/drivers/video/rockchip/rk_fb.c index 5a30657a10ce..855c28441bb3 100755 --- a/drivers/video/rockchip/rk_fb.c +++ b/drivers/video/rockchip/rk_fb.c @@ -2152,7 +2152,7 @@ static int rk_fb_set_win_buffer(struct fb_info *info, 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) { + if (IS_FBDC_FMT(fb_data_fmt)) { reg_win_data->reg_area_data[i].fbdc_en = 1; reg_win_data->reg_area_data[i].fbdc_cor_en = 1; } else { @@ -2172,7 +2172,8 @@ static int rk_fb_set_win_buffer(struct fb_info *info, } /* buf offset should be 2 pix align*/ - if (win_par->area_par[i].x_offset % 2 == 1) { + if ((win_par->area_par[i].x_offset % 2 == 1) && + IS_YUV_FMT(fb_data_fmt)) { win_par->area_par[i].x_offset += 1; win_par->area_par[i].xact -= 1; } @@ -2235,11 +2236,7 @@ static int rk_fb_set_win_buffer(struct fb_info *info, xoffset * pixel_width / 8; } } - if ((fb_data_fmt != YUV420) && - (fb_data_fmt != YUV420_NV21) && - (fb_data_fmt != YUV422) && - (fb_data_fmt != YUV444) && - dev_drv->iommu_enabled) { + if (IS_RGB_FMT(fb_data_fmt) && dev_drv->iommu_enabled) { buff_len = reg_win_data->reg_area_data[i].y_offset + reg_win_data->reg_area_data[i].xvir * reg_win_data->reg_area_data[i].yact * @@ -3097,7 +3094,7 @@ static int rk_fb_set_par(struct fb_info *info) 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) { + if (IS_FBDC_FMT(fb_data_fmt)) { win->area[0].fbdc_en = 1; win->area[0].fbdc_cor_en = 1; } else { diff --git a/include/linux/rk_fb.h b/include/linux/rk_fb.h index 850683afa2f6..ba551e58b8cb 100755 --- a/include/linux/rk_fb.h +++ b/include/linux/rk_fb.h @@ -245,24 +245,28 @@ enum { //display data format enum data_format { - ARGB888 = 0, + ARGB888, RGB888, RGB565, - YUV420 = 4, - YUV422, - YUV444, XRGB888, XBGR888, ABGR888, - YUV420_A = 10, - YUV422_A, - YUV444_A, - YUV420_NV21, - FBDC_RGB_565 = 0x26, + FBDC_RGB_565, FBDC_ARGB_888, FBDC_RGBX_888, FBDC_ABGR_888, + YUV420, + YUV422, + YUV444, + YUV420_A, + YUV422_A, + YUV444_A, + YUV420_NV21, }; +#define IS_YUV_FMT(fmt) ((fmt >= YUV420) ? 1 : 0) +#define IS_RGB_FMT(fmt) ((fmt < YUV420) ? 1 : 0) +#define IS_FBDC_FMT(fmt) \ + (((fmt >= FBDC_RGB_565) && (fmt <= FBDC_ABGR_888)) ? 1 : 0) enum { -- 2.34.1