vdin: hdr mode force 10bit mode [1/1]
authorYong Qin <yong.qin@amlogic.com>
Thu, 4 Jul 2019 11:02:06 +0000 (19:02 +0800)
committerTao Zeng <tao.zeng@amlogic.com>
Mon, 8 Jul 2019 04:11:45 +0000 (21:11 -0700)
PD#TV-7517

Problem:
hdmi hdr color deepth mode is auto, if input
is 8bit mode, output is 8bit mode

Solution:
when is hdr mode, force set 10bit mode to frame
buffer.

Verify:
tl1

Change-Id: If958f687e3923389277880e19d47f933421a8292
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_ctl.h
drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c
drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c
drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h

index c8dec90..1abefc5 100644 (file)
@@ -3461,18 +3461,18 @@ void vdin_set_bitdepth(struct vdin_dev_s *devp)
                pr_info("set output color depth %d bit from dts\n", set_width);
        }
 
-       switch (devp->color_depth_config) {
-       case 8:
+       switch (devp->color_depth_config & 0xff) {
+       case COLOR_DEEPS_8BIT:
                devp->source_bitdepth = 8;
                wr_bits(offset, VDIN_WR_CTRL2, 0,
                        VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
                break;
-       case 10:
+       case COLOR_DEEPS_10BIT:
                devp->source_bitdepth = 10;
                wr_bits(offset, VDIN_WR_CTRL2, 1,
                        VDIN_WR_10BIT_MODE_BIT, VDIN_WR_10BIT_MODE_WID);
                break;
-       case 0:
+       case COLOR_DEEPS_AUTO:
                /* vdin_bit_depth is set to 0 by defaut, in this case,
                devp->source_bitdepth is controlled by colordepth
                change default to 10bit for 8in8out detail maybe lost
@@ -4220,6 +4220,44 @@ void vdin_set_drm_data(struct vdin_dev_s *devp,
        devp->parm.info.signal_type = vf->signal_type;
 }
 
+void vdin_check_hdmi_hdr(struct vdin_dev_s *devp)
+{
+       struct tvin_state_machine_ops_s *sm_ops;
+       enum tvin_port_e port = TVIN_PORT_NULL;
+       struct tvin_sig_property_s *prop;
+
+       if (!devp)
+               return;
+
+       if (devp->color_depth_config & COLOR_DEEPS_MANUAL)
+               return;
+
+       devp->color_depth_config = COLOR_DEEPS_AUTO;
+       port = devp->parm.port;
+       if ((port < TVIN_PORT_HDMI0) || (port > TVIN_PORT_HDMI7))
+               return;
+
+       prop = &devp->prop;
+       sm_ops = devp->frontend->sm_ops;
+       if (sm_ops->get_sig_property) {
+               sm_ops->get_sig_property(devp->frontend, prop);
+               pr_info("vdin hdmi hdr eotf:0x%x\n",
+                               devp->prop.hdr_info.hdr_data.eotf);
+               if (devp->prop.hdr_info.hdr_state == HDR_STATE_GET) {
+                       if ((devp->prop.hdr_info.hdr_data.eotf ==
+                                       EOTF_HDR) ||
+                               (devp->prop.hdr_info.hdr_data.eotf ==
+                                       EOTF_SMPTE_ST_2048) ||
+                               (devp->prop.hdr_info.hdr_data.eotf ==
+                                       EOTF_HLG)) {
+                               pr_info("vdin is hdr mode,force 10bit\n");
+                               devp->color_depth_config = COLOR_DEEPS_10BIT;
+                       }
+               }
+               devp->prop.hdr_info.hdr_data.eotf = 0;
+       }
+}
+
 u32 vdin_get_curr_field_type(struct vdin_dev_s *devp)
 {
        u32 field_status;
index 93ff0b3..4393f7f 100644 (file)
@@ -220,6 +220,7 @@ extern enum tvin_force_color_range_e color_range_force;
 extern void vdin_vlock_input_sel(unsigned int type,
        enum vframe_source_type_e source_type);
 
+extern void vdin_check_hdmi_hdr(struct vdin_dev_s *devp);
 
 #endif
 
index 7e19fa4..c085962 100644 (file)
@@ -767,6 +767,7 @@ static void vdin_dump_state(struct vdin_dev_s *devp)
        pr_info("cma_mem_size:0x%x\n", devp->cma_mem_size);
        pr_info("cma_mem_mode:%d\n", devp->cma_mem_mode);
        pr_info("force_yuv444_malloc:%d\n", devp->force_yuv444_malloc);
+       vdin_check_hdmi_hdr(devp);
        vdin_dump_vf_state(devp->vfp);
        if (vf) {
                pr_info("current vframe index(%u):\n", vf->index);
@@ -1935,7 +1936,7 @@ start_chk:
                if (!parm[1])
                        pr_err("miss parameters .\n");
                else if (kstrtoul(parm[1], 10, &val) == 0) {
-                       devp->color_depth_config = val;
+                       devp->color_depth_config = val | COLOR_DEEPS_MANUAL;
                        pr_info("color_depth(%d):%d\n\n", devp->index,
                                devp->color_depth_config);
                }
index 68dbf5c..ec0a900 100644 (file)
@@ -586,8 +586,12 @@ void vdin_start_dec(struct vdin_dev_s *devp)
        }
        vdin_set_cutwin(devp);
        vdin_set_hvscale(devp);
-       if (cpu_after_eq(MESON_CPU_MAJOR_ID_GXTVBB))
+
+       if (cpu_after_eq(MESON_CPU_MAJOR_ID_GXTVBB)) {
+               vdin_check_hdmi_hdr(devp);
                vdin_set_bitdepth(devp);
+       }
+
        /* txl new add fix for hdmi switch resolution cause cpu holding */
        if (get_cpu_type() >= MESON_CPU_MAJOR_ID_TXL)
                vdin_fix_nonstd_vsync(devp);
@@ -3219,7 +3223,7 @@ static int vdin_drv_probe(struct platform_device *pdev)
                pr_info("no bit mode found, set 8bit as default\n");
 
        vdevp->color_depth_support = bit_mode & 0xff;
-       vdevp->color_depth_config = 0;
+       vdevp->color_depth_config = COLOR_DEEPS_AUTO;
 
        ret = (bit_mode >> 8) & 0xff;
        if (ret == 0)
index 556dd87..a39b473 100644 (file)
 #define VDIN_AFBCE_EN_720P              (1 << 6)
 #define VDIN_AFBCE_EN_SMALL             (1 << 7)
 
+enum COLOR_DEEPS_CFGe {
+       COLOR_DEEPS_AUTO = 0,
+       COLOR_DEEPS_8BIT = 8,
+       COLOR_DEEPS_10BIT = 10,
+       COLOR_DEEPS_12BIT = 12,
+       COLOR_DEEPS_MANUAL = 0x100,
+};
+
 static inline const char *vdin_fmt_convert_str(
                enum vdin_format_convert_e fmt_cvt)
 {
@@ -324,7 +332,7 @@ struct vdin_dev_s {
         *10:force config as 10bit
         *12:force config as 12bit
         */
-       unsigned int color_depth_config;
+       enum COLOR_DEEPS_CFGe color_depth_config;
        /* new add from txl:color depth mode for 10bit
         *1: full pack mode;config 10bit as 10bit
         *0: config 10bit as 12bit