vdin: hdmi 422 mode vdin set 10bit [1/1]
authorYong Qin <yong.qin@amlogic.com>
Fri, 2 Aug 2019 09:24:43 +0000 (17:24 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Mon, 5 Aug 2019 08:13:24 +0000 (01:13 -0700)
PD#SWPL-12219

Problem:
HDMI 422 mode, 8 or 10 bit valid is unknown.
when 10bit valid, there will cause PQ problem

Solution:
HDMI 422 mode vdin set 10bit

Verify:
tl1

Change-Id: Iaee6545dfe3ebbb92a23d23515509c8e8a053a91
Signed-off-by: Yong Qin <yong.qin@amlogic.com>
drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c
drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c
drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h

index db45261..bb52b90 100644 (file)
@@ -1968,11 +1968,11 @@ static inline void vdin_set_wr_ctrl(struct vdin_dev_s *devp,
                (format_convert == VDIN_FORMAT_CONVERT_RGB_YUV422) ||
                (format_convert == VDIN_FORMAT_CONVERT_GBR_YUV422) ||
                (format_convert == VDIN_FORMAT_CONVERT_BRG_YUV422)) &&
-               color_depth_mode && (source_bitdeth > 8))
+               color_depth_mode && (source_bitdeth > VDIN_COLOR_DEEPS_8BIT))
                write_format444 = 3;
 
        /* win_he */
-       if ((h%2) && (devp->source_bitdepth > 8) &&
+       if ((h%2) && (devp->source_bitdepth > VDIN_COLOR_DEEPS_8BIT) &&
                (devp->color_depth_mode == 1) &&
                ((devp->format_convert == VDIN_FORMAT_CONVERT_YUV_YUV422) ||
                (devp->format_convert == VDIN_FORMAT_CONVERT_RGB_YUV422) ||
@@ -3507,24 +3507,25 @@ void vdin_set_bitdepth(struct vdin_dev_s *devp)
 {
        unsigned int offset = devp->addr_offset;
        unsigned int set_width = 0;
+       unsigned int port;
 
        if ((devp->output_color_depth) &&
                ((devp->prop.fps == 50) || (devp->prop.fps == 60)) &&
                ((devp->parm.info.fmt == TVIN_SIG_FMT_HDMI_3840_2160_00HZ) ||
                (devp->parm.info.fmt == TVIN_SIG_FMT_HDMI_4096_2160_00HZ)) &&
-               (devp->prop.colordepth == 10)) {
+               (devp->prop.colordepth == VDIN_COLOR_DEEPS_10BIT)) {
                set_width = devp->output_color_depth;
                pr_info("set output color depth %d bit from dts\n", set_width);
        }
 
        switch (devp->color_depth_config & 0xff) {
        case COLOR_DEEPS_8BIT:
-               devp->source_bitdepth = 8;
+               devp->source_bitdepth = VDIN_COLOR_DEEPS_8BIT;
                wr_bits(offset, VDIN_WR_CTRL2, 0,
                        VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
                break;
        case COLOR_DEEPS_10BIT:
-               devp->source_bitdepth = 10;
+               devp->source_bitdepth = VDIN_COLOR_DEEPS_10BIT;
                wr_bits(offset, VDIN_WR_CTRL2, 1,
                        VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
                break;
@@ -3533,7 +3534,7 @@ void vdin_set_bitdepth(struct vdin_dev_s *devp)
         *      vdin config it as 10bit , 12 to 10
         */
        case COLOR_DEEPS_12BIT:
-               devp->source_bitdepth = 10;
+               devp->source_bitdepth = VDIN_COLOR_DEEPS_10BIT;
                wr_bits(offset, VDIN_WR_CTRL2, 1,
                        VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
                break;
@@ -3548,35 +3549,53 @@ void vdin_set_bitdepth(struct vdin_dev_s *devp)
                        (devp->prop.color_format == TVIN_RGGB) ||
                        (devp->prop.color_format == TVIN_GBRG) ||
                        (devp->prop.color_format == TVIN_GRBG)) {
-                       devp->source_bitdepth = 8;
-                       wr_bits(offset, VDIN_WR_CTRL2, 0,
-                               VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
-               } else if (devp->prop.colordepth == 8) {
-                       devp->source_bitdepth = 8;
+                       devp->source_bitdepth = VDIN_COLOR_DEEPS_8BIT;
                        wr_bits(offset, VDIN_WR_CTRL2, 0,
                                VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
+               } else if (devp->prop.colordepth == VDIN_COLOR_DEEPS_8BIT) {
+                       /* hdmi YUV422, 8 or 10 bit valid is unknown*/
+                       /* so need vdin 10bit to frame buffer*/
+                       port = devp->parm.port;
+                       if (((port >= TVIN_PORT_HDMI0) &&
+                               (port <= TVIN_PORT_HDMI7)) &&
+                               (devp->prop.color_format == TVIN_YUV422) &&
+                               (devp->color_depth_support &
+                               VDIN_WR_COLOR_DEPTH_10BIT)) {
+                               /*10 bit mode*/
+                               devp->source_bitdepth = VDIN_COLOR_DEEPS_10BIT;
+                               wr_bits(offset, VDIN_WR_CTRL2, 1,
+                                       VDIN_WR_10BIT_MODE_BIT,
+                                       VDIN_WR_10BIT_MODE_WID);
+                       } else {
+                               /*8bit mode*/
+                               devp->source_bitdepth = VDIN_COLOR_DEEPS_8BIT;
+                               wr_bits(offset, VDIN_WR_CTRL2, 0,
+                                       VDIN_WR_10BIT_MODE_BIT,
+                                       VDIN_WR_10BIT_MODE_WID);
+                       }
                } else if ((devp->color_depth_support &
-                       VDIN_WR_COLOR_DEPTH_10BIT) &&
-                       (devp->prop.colordepth == 10)) {
-                       if (set_width == 8) {
-                               devp->source_bitdepth = 8;
+                       VDIN_WR_COLOR_DEPTH_10BIT)
+                       && ((devp->prop.colordepth == VDIN_COLOR_DEEPS_10BIT) ||
+                       (devp->prop.colordepth == VDIN_COLOR_DEEPS_12BIT))) {
+                       if (set_width == VDIN_COLOR_DEEPS_8BIT) {
+                               devp->source_bitdepth = VDIN_COLOR_DEEPS_8BIT;
                                wr_bits(offset, VDIN_WR_CTRL2, 0,
                                        VDIN_WR_10BIT_MODE_BIT,
                                        VDIN_WR_10BIT_MODE_WID);
                        } else {
-                               devp->source_bitdepth = 10;
+                               devp->source_bitdepth = VDIN_COLOR_DEEPS_10BIT;
                                wr_bits(offset, VDIN_WR_CTRL2, 1,
                                        VDIN_WR_10BIT_MODE_BIT,
                                        VDIN_WR_10BIT_MODE_WID);
                        }
                } else {
-                       devp->source_bitdepth = 8;
+                       devp->source_bitdepth = VDIN_COLOR_DEEPS_8BIT;
                        wr_bits(offset, VDIN_WR_CTRL2, 0,
                                VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
                }
                break;
        default:
-               devp->source_bitdepth = 8;
+               devp->source_bitdepth = VDIN_COLOR_DEEPS_8BIT;
                wr_bits(offset, VDIN_WR_CTRL2, 0,
                        VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
                break;
@@ -4689,13 +4708,13 @@ inline void vdin_set_source_bitdepth(struct vdin_dev_s *devp,
                struct vframe_s *vf)
 {
        switch (devp->source_bitdepth) {
-       case 10:
+       case VDIN_COLOR_DEEPS_10BIT:
                vf->bitdepth = BITDEPTH_Y10 | BITDEPTH_U10 | BITDEPTH_V10;
                break;
-       case 9:
+       case VDIN_COLOR_DEEPS_9BIT:
                vf->bitdepth = BITDEPTH_Y9 | BITDEPTH_U9 | BITDEPTH_V9;
                break;
-       case 8:
+       case VDIN_COLOR_DEEPS_8BIT:
                vf->bitdepth = BITDEPTH_Y8 | BITDEPTH_U8 | BITDEPTH_V8;
                break;
        default:
index 1a2db4a..260ff6a 100644 (file)
@@ -3166,13 +3166,15 @@ static int vdin_drv_probe(struct platform_device *pdev)
        vdevp->color_depth_support = bit_mode & 0xff;
        vdevp->color_depth_config = COLOR_DEEPS_AUTO;
 
+       /* bit8:use 8bit  at 4k_50/60hz_10bit*/
+       /* bit9:use 10bit at 4k_50/60hz_10bit*/
        ret = (bit_mode >> 8) & 0xff;
        if (ret == 0)
                vdevp->output_color_depth = 0;
-       else if (ret == 1)
-               vdevp->output_color_depth = 8;
-       else if (ret == 2)
-               vdevp->output_color_depth = 10;
+       else if (ret == 1)/*4k 10bit 8bit to video buffer*/
+               vdevp->output_color_depth = VDIN_COLOR_DEEPS_8BIT;
+       else if (ret == 2)/*4k 10bit 10bit to video buffer*/
+               vdevp->output_color_depth = VDIN_COLOR_DEEPS_10BIT;
 
        if (vdevp->color_depth_support&VDIN_WR_COLOR_DEPTH_10BIT_FULL_PCAK_MODE)
                vdevp->color_depth_mode = VDIN_422_FULL_PK_EN;
index cbeebfc..d699694 100644 (file)
@@ -48,7 +48,7 @@
 /* Ref.2019/04/25: tl1 vdin0 afbce dynamically switch support,
  *                 vpp also should support this function
  */
-#define VDIN_VER "Ref.2019/07/30:444 10bit mode buffer size not right"
+#define VDIN_VER "Ref.2019/08/2:hdmi yuv422 vdin set 10 bit mode"
 
 /*the counter of vdin*/
 #define VDIN_MAX_DEVS                  2
 /* #define VDIN_DEBUG */
 
 /*vdin write mem color-depth support*/
-#define VDIN_WR_COLOR_DEPTH_8BIT       1
-#define VDIN_WR_COLOR_DEPTH_9BIT       (1 << 1)
-#define VDIN_WR_COLOR_DEPTH_10BIT      (1 << 2)
-#define VDIN_WR_COLOR_DEPTH_12BIT      (1 << 3)
-/*TXL new add*/
-#define VDIN_WR_COLOR_DEPTH_10BIT_FULL_PCAK_MODE       (1 << 4)
-
+enum VDIN_WR_COLOR_DEPTHe {
+       VDIN_WR_COLOR_DEPTH_8BIT = 0x01,
+       VDIN_WR_COLOR_DEPTH_9BIT = 0x02,
+       VDIN_WR_COLOR_DEPTH_10BIT = 0x04,
+       VDIN_WR_COLOR_DEPTH_12BIT = 0x08,
+       /*TXL new add*/
+       VDIN_WR_COLOR_DEPTH_10BIT_FULL_PCAK_MODE = 0x10,
+};
 
 #define VDIN_422_FULL_PK_EN                    1
 #define VDIN_422_FULL_PK_DIS                   0
@@ -133,6 +134,13 @@ enum COLOR_DEEPS_CFGe {
        COLOR_DEEPS_MANUAL = 0x100,
 };
 
+enum vdin_color_deeps_e {
+       VDIN_COLOR_DEEPS_8BIT = 8,
+       VDIN_COLOR_DEEPS_9BIT = 9,
+       VDIN_COLOR_DEEPS_10BIT = 10,
+       VDIN_COLOR_DEEPS_12BIT = 12,
+};
+
 static inline const char *vdin_fmt_convert_str(
                enum vdin_format_convert_e fmt_cvt)
 {
@@ -256,7 +264,7 @@ struct vdin_dev_s {
 
        struct vdin_debug_s debug;
        enum vdin_format_convert_e format_convert;
-       unsigned int source_bitdepth;
+       enum vdin_color_deeps_e source_bitdepth;
 
        struct vf_entry *curr_wr_vfe;
        struct vf_entry *last_wr_vfe;
@@ -331,7 +339,7 @@ struct vdin_dev_s {
         *bit3:support 12bit
         *bit4:support yuv422 10bit full pack mode (from txl new add)
         */
-       unsigned int color_depth_support;
+       enum VDIN_WR_COLOR_DEPTHe color_depth_support;
        /*color depth config
         *0:auto config as frontend
         *8:force config as 8bit