From 460c14a88fc0d12bef7e439d9d4d9a53b29a34cc Mon Sep 17 00:00:00 2001 From: yao liu Date: Thu, 1 Aug 2019 02:52:53 -0400 Subject: [PATCH] dolby: TM2 black screen on 4k60hz [1/1] PD#SWPL-11431 Problem: black screen on 4k60hz display abnormal on 1080p24hz/1080i/576p/480p Solution: 1.Adjust potch according to resolution 2.Add tm2 in is_graphics_output_off 3.Move osd sc to the back of core2 Verify: Verified on TM2 Change-Id: Ida1b4a67b3a7233d3a03b0536d246a0bd677e90c Signed-off-by: yao liu --- .../amdolby_vision/amdolby_vision.c | 142 +++++++++++------- drivers/amlogic/media/osd/osd_fb.c | 2 +- 2 files changed, 85 insertions(+), 59 deletions(-) diff --git a/drivers/amlogic/media/enhancement/amdolby_vision/amdolby_vision.c b/drivers/amlogic/media/enhancement/amdolby_vision/amdolby_vision.c index 72ff32d8f5d1..b93c4261f0d3 100644 --- a/drivers/amlogic/media/enhancement/amdolby_vision/amdolby_vision.c +++ b/drivers/amlogic/media/enhancement/amdolby_vision/amdolby_vision.c @@ -278,8 +278,12 @@ MODULE_PARM_DESC(vtotal_add, "\n vtotal_add\n"); module_param(vpotch, uint, 0664); MODULE_PARM_DESC(vpotch, "\n vpotch\n"); -module_param(g_vpotch, uint, 0664); -MODULE_PARM_DESC(g_vpotch, "\n vpotch\n"); +/* for core2 timing setup tuning */ +/* g_vtotal_add << 24 | g_vsize_add << 16 */ +/* | g_vwidth << 8 | g_vpotch */ +static unsigned int g_vtiming; +module_param(g_vtiming, uint, 0664); +MODULE_PARM_DESC(g_vtiming, "\n vpotch\n"); static unsigned int dolby_vision_target_min = 50; /* 0.0001 */ #ifdef V2_4 @@ -1024,7 +1028,7 @@ MODULE_PARM_DESC(debug_dolby_frame, "\n debug_dolby_frame\n"); (debug_dolby_frame + 1 == frame_count)) static int is_graphics_output_off(void) { - if (is_meson_g12()) + if (is_meson_g12() || is_meson_tm2_stbmode()) return !(READ_VPP_REG(OSD1_BLEND_SRC_CTRL) & (0xf<<8)) && !(READ_VPP_REG(OSD2_BLEND_SRC_CTRL) & (0xf<<8)); else @@ -1148,6 +1152,7 @@ bool is_meson_tm2(void) else return false; } + bool is_meson_tm2_tvmode(void) { if ((is_meson_tm2()) && (tv_mode == 1)) @@ -2241,18 +2246,25 @@ static int dolby_core2_set( VSYNC_WR_DV_REG(DOLBY_CORE2A_SWAP_CTRL0, 0); if (is_meson_box() || is_meson_tm2_stbmode() || reset) { VSYNC_WR_DV_REG(DOLBY_CORE2A_SWAP_CTRL1, - ((hsize + g_htotal_add) << 16) - | (vsize + g_vtotal_add + g_vsize_add)); + ((hsize + g_htotal_add) << 16) | (vsize + + ((g_vtiming & 0xff000000) ? + ((g_vtiming >> 24) & 0xff) : g_vtotal_add) + + ((g_vtiming & 0xff0000) ? + ((g_vtiming >> 16) & 0xff) : g_vsize_add))); VSYNC_WR_DV_REG(DOLBY_CORE2A_SWAP_CTRL2, - (hsize << 16) | (vsize + g_vsize_add)); + (hsize << 16) | (vsize + + ((g_vtiming & 0xff0000) ? + ((g_vtiming >> 16) & 0xff) : g_vsize_add))); } if (debug_dolby & 2) pr_dolby_dbg("g_hpotch %x, g_vpotch %x\n", g_hpotch, g_vpotch); VSYNC_WR_DV_REG(DOLBY_CORE2A_SWAP_CTRL3, - (g_hwidth << 16) | g_vwidth); + (g_hwidth << 16) | ((g_vtiming & 0xff00) ? + ((g_vtiming >> 8) & 0xff) : g_vwidth)); VSYNC_WR_DV_REG(DOLBY_CORE2A_SWAP_CTRL4, - (g_hpotch << 16) | g_vpotch); + (g_hpotch << 16) | ((g_vtiming & 0xff) ? + (g_vtiming & 0xff) : g_vpotch)); if (is_meson_txlx_stbmode() || force_stb_mode) VSYNC_WR_DV_REG(DOLBY_CORE2A_SWAP_CTRL5, 0xf8000000); else if (is_meson_g12() || is_meson_tm2_stbmode()) @@ -2585,6 +2597,63 @@ static int is_graphic_changed(void) } return ret; } +static void adjust_vpotch(void) +{ + const struct vinfo_s *vinfo = get_current_vinfo(); + + if (is_meson_txlx_stbmode() + || force_stb_mode) { + if ((vinfo->width >= 1920) && + (vinfo->height >= 1080) && + (vinfo->field_height >= 1080)) + dma_start_line = 0x400; + else + dma_start_line = 0x180; + /* adjust core2 setting to work around*/ + /* fixing with 1080p24hz and 480p60hz */ + if ((vinfo->width < 1280) && + (vinfo->height < 720) && + (vinfo->field_height < 720)) + g_vpotch = 0x60; + else + g_vpotch = 0x20; + } else if (is_meson_g12()) { + if (vinfo) { + if (debug_dolby & 2) + pr_dolby_dbg("vinfo %d %d %d\n", + vinfo->width, + vinfo->height, + vinfo->field_height); + if ((vinfo->width < 1280) && + (vinfo->height < 720) && + (vinfo->field_height < 720)) + g_vpotch = 0x60; + else + g_vpotch = 0x20; + } else + g_vpotch = 0x20; + } else if (is_meson_tm2_stbmode()) { + if (vinfo) { + if (debug_dolby & 2) + pr_dolby_dbg("vinfo %d %d %d\n", + vinfo->width, + vinfo->height, + vinfo->field_height); + if ((vinfo->width < 1280) && + (vinfo->height < 720) && + (vinfo->field_height < 720)) + g_vpotch = 0x60; + else if ((vinfo->width <= 1920) && + (vinfo->height <= 1080) && + (vinfo->field_height <= 1080)) + g_vpotch = 0x50; + else + g_vpotch = 0x20; + } else + g_vpotch = 0x20; + } + +} static void apply_stb_core_settings( int enable, unsigned int mask, @@ -2606,39 +2675,7 @@ static void apply_stb_core_settings( graphics_w = dv_cert_graphic_width; graphics_h = dv_cert_graphic_height; } - if (is_meson_txlx_stbmode() - || force_stb_mode) { - if ((vinfo->width >= 1920) && - (vinfo->height >= 1080) && - (vinfo->field_height >= 1080)) - dma_start_line = 0x400; - else - dma_start_line = 0x180; - /* adjust core2 setting to work around*/ - /* fixing with 1080p24hz and 480p60hz */ - if ((vinfo->width < 1280) && - (vinfo->height < 720) && - (vinfo->field_height < 720)) - g_vpotch = 0x60; - else - g_vpotch = 0x20; - } else if (is_meson_g12() || is_meson_tm2_stbmode()) { - if (vinfo) { - if (debug_dolby & 2) - pr_dolby_dbg("vinfo %d %d %d\n", - vinfo->width, - vinfo->height, - vinfo->field_height); - if ((vinfo->width < 1280) && - (vinfo->height < 720) && - (vinfo->field_height < 720)) - g_vpotch = 0x60; - else - g_vpotch = 0x20; - } else - g_vpotch = 0x20; - } - + adjust_vpotch(); if (mask & 1) { if (is_meson_txlx_stbmode() || force_stb_mode) { @@ -3979,11 +4016,15 @@ static int sink_support_dolby_vision(const struct vinfo_s *vinfo) return 0; if (dolby_vision_flags & FLAG_DISABLE_DOVI_OUT) return 0; + /* for sink not support 60 dovi */ if ((strstr(vinfo->name, "2160p60hz") != NULL) || (strstr(vinfo->name, "2160p50hz") != NULL)) { if (!vinfo->vout_device->dv_info->sup_2160p60hz) return 0; } + /* for interlace output */ + if (vinfo->height != vinfo->field_height) + return 0; return 1; } @@ -7102,8 +7143,7 @@ int register_dv_functions(const struct dolby_vision_func_s *func) int ret = -1; unsigned int reg_clk; unsigned int reg_value; - struct pq_config_s *pq_config; - const struct vinfo_s *vinfo = get_current_vinfo(); + struct pq_config_s *pq_config; if ((!p_funcs_stb || !p_funcs_tv) && func) { if (func->control_path && !p_funcs_stb) { @@ -7156,21 +7196,7 @@ int register_dv_functions(const struct dolby_vision_func_s *func) if (!tv_dovi_setting) return -ENOMEM; } - /* adjust core2 setting to work around fixing with 1080p24hz */ - if (is_meson_txlx()) - g_vpotch = 0x20; - else if (is_meson_g12() || is_meson_tm2_stbmode()) { - if (vinfo) { - if ((vinfo->width < 1280) && - (vinfo->height < 720) && - (vinfo->field_height < 720)) - g_vpotch = 0x60; - else - g_vpotch = 0x20; - } else - g_vpotch = 0x20; - } else - g_vpotch = 0x8; + adjust_vpotch(); } return ret; } diff --git a/drivers/amlogic/media/osd/osd_fb.c b/drivers/amlogic/media/osd/osd_fb.c index 45f1ba6a1c06..a3deb76a4fa4 100644 --- a/drivers/amlogic/media/osd/osd_fb.c +++ b/drivers/amlogic/media/osd/osd_fb.c @@ -4055,7 +4055,7 @@ static struct osd_device_data_s osd_tm2 = { .vpp_fifo_len = 0xfff,/* 2048 */ .dummy_data = 0x00808000, .has_viu2 = 1, - .osd0_sc_independ = 1, + .osd0_sc_independ = 0, }; static struct osd_device_data_s osd_a1 = {