From e7f25b093b6024255484ff6086ded117ecb38afe Mon Sep 17 00:00:00 2001 From: Yong Qin Date: Thu, 4 Jul 2019 19:02:06 +0800 Subject: [PATCH] vdin: hdr mode force 10bit mode [1/1] 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 --- .../amlogic/media/vin/tvin/vdin/vdin_ctl.c | 44 +++++++++++++++++-- .../amlogic/media/vin/tvin/vdin/vdin_debug.c | 3 +- .../amlogic/media/vin/tvin/vdin/vdin_drv.c | 8 +++- .../amlogic/media/vin/tvin/vdin/vdin_drv.h | 10 ++++- 4 files changed, 58 insertions(+), 7 deletions(-) diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c index 0e2aec3483fe..5d5f8b540926 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_ctl.c @@ -3500,13 +3500,13 @@ 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); @@ -4292,6 +4292,44 @@ void vdin_set_drm_data(struct vdin_dev_s *devp, } } +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; diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c index f3d4a04bda86..62a148d28382 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_debug.c @@ -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); @@ -1967,7 +1968,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); } diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c index 9007a9989c35..7b55e86749d9 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.c @@ -540,8 +540,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); @@ -3217,7 +3221,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) diff --git a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h index 80a498c767e7..a95ffe8b31a0 100644 --- a/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h +++ b/drivers/amlogic/media/vin/tvin/vdin/vdin_drv.h @@ -117,6 +117,14 @@ #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) { @@ -322,7 +330,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