video/sprdfb: add dispc_is_yuv_format() on dispc. 24/103324/2
authorJin-young Jeon <jy0.jeon@samsung.com>
Mon, 28 Mar 2016 04:29:36 +0000 (13:29 +0900)
committerJoonyoung Shim <jy0922.shim@samsung.com>
Fri, 9 Dec 2016 00:49:14 +0000 (16:49 -0800)
This adds dispc_is_yuv_format() function to be easy to check whether
image format is YUV or not, and can cleanup related codes.

This commit comes from product kernel.

Change-Id: I934756c355b533bdbadbeb10b5555ab597a43fce
Signed-off-by: Jin-young Jeon <jy0.jeon@samsung.com>
[jy0922.shim: remove unfit changes and write commit messages]
Signed-off-by: Joonyoung Shim <jy0922.shim@samsung.com>
drivers/video/sprdfb/sprdfb_dispc.c

index ae45768..8b6b63a 100644 (file)
@@ -416,6 +416,24 @@ static irqreturn_t dispc_isr(int irq, void *data)
        return IRQ_HANDLED;
 }
 
+static bool dispc_is_yuv_format(int type)
+{
+       bool ret = false;
+
+       switch(type) {
+       case SPRD_DATA_FORMAT_YUV422:
+       case SPRD_DATA_FORMAT_YUV420:
+       case SPRD_DATA_FORMAT_YUV400:
+       case SPRD_DATA_FORMAT_YUV422_3P:
+       case SPRD_DATA_FORMAT_YUV420_3P:
+               ret = true;
+               break;
+       default:
+               break;
+       }
+
+       return ret;
+}
 
 /* dispc soft reset */
 static void dispc_reset(void)
@@ -1822,7 +1840,7 @@ static int overlay_img_configure(struct sprdfb_device *dev, int type, overlay_si
        reg_value = (rect->y << 16) | (rect->x);
        dispc_write(reg_value, DISPC_IMG_DISP_XY);
 
-       if(type < SPRD_DATA_FORMAT_RGB888) {
+       if(dispc_is_yuv_format(type)) {
                dispc_write(1, DISPC_Y2R_CTRL);
 #ifndef CONFIG_FB_SCX35
                dispc_write(SPRDFB_BRIGHTNESS|SPRDFB_CONTRAST, DISPC_Y2R_Y_PARAM);
@@ -2157,19 +2175,18 @@ static int32_t sprdfb_dispc_display_overlay(struct sprdfb_device *dev, struct ov
        if ((setting->layer_index & SPRD_LAYER_IMG) && img_buffer) {
                dispc_write((uint32_t)img_buffer,
                                        DISPC_IMG_Y_BASE_ADDR);
-               if (dispc_ctx.overlay_img_info.data_type <
-                                       SPRD_DATA_FORMAT_RGB888) {
-                       uint32_t size = rect->w * rect->h;
-                       dispc_write((uint32_t)(img_buffer + size),
-                                       DISPC_IMG_UV_BASE_ADDR);
-               } else if (dispc_ctx.overlay_img_info.data_type == SPRD_DATA_FORMAT_YUV422_3P) {
-                       uint32_t size = rect->w * rect->h;
-                       dispc_write((uint32_t)(img_buffer + size), DISPC_IMG_UV_BASE_ADDR);
-                       dispc_write((uint32_t)(img_buffer + size*3/2), DISPC_IMG_V_BASE_ADDR);
-               } else if (dispc_ctx.overlay_img_info.data_type == SPRD_DATA_FORMAT_YUV420_3P) {
+
+               if (dispc_is_yuv_format(dispc_ctx.overlay_img_info.data_type)) {
                        uint32_t size = rect->w * rect->h;
+
                        dispc_write((uint32_t)(img_buffer + size), DISPC_IMG_UV_BASE_ADDR);
-                       dispc_write((uint32_t)(img_buffer + size*5/4), DISPC_IMG_V_BASE_ADDR);
+
+                       if (dispc_ctx.overlay_img_info.data_type == SPRD_DATA_FORMAT_YUV422_3P)
+                               dispc_write((uint32_t)(img_buffer + size * 3 / 2),
+                                               DISPC_IMG_V_BASE_ADDR);
+                       else if (dispc_ctx.overlay_img_info.data_type == SPRD_DATA_FORMAT_YUV420_3P)
+                               dispc_write((uint32_t)(img_buffer + size * 5 / 4),
+                                               DISPC_IMG_V_BASE_ADDR);
                }
        }