From ecb0485dbab37fd7898906b902b4ff288cd381a4 Mon Sep 17 00:00:00 2001 From: Brian Zhu Date: Sat, 9 Nov 2019 02:03:16 +0800 Subject: [PATCH] dv: add dv target output mode [1/1] PD#SWPL-16861 Problem: HDR core get the wrong dv output state when vd1/vd switching. It caused the HDR core setting incorret. Solution: Add the new interface to update the correct state. Verify: Verified on AC213 Change-Id: I3df18b967257ccfcb57c110b4dbc79100d290a80 Signed-off-by: Brian Zhu (cherry picked from commit 9d31efae4a55eadf0beb62c404adb427fdd7d4ea) --- .../amdolby_vision/amdolby_vision.c | 35 +++++-- .../amlogic/media/enhancement/amvecm/amcsc.c | 2 +- .../media/enhancement/amvecm/amcsc_pip.c | 2 +- .../media/enhancement/amvecm/set_hdr2_v0.c | 9 +- .../media/amdolbyvision/dolby_vision.h | 98 +++++++++---------- 5 files changed, 84 insertions(+), 62 deletions(-) diff --git a/drivers/amlogic/media/enhancement/amdolby_vision/amdolby_vision.c b/drivers/amlogic/media/enhancement/amdolby_vision/amdolby_vision.c index 7123712fb83b..562d7b890cdb 100644 --- a/drivers/amlogic/media/enhancement/amdolby_vision/amdolby_vision.c +++ b/drivers/amlogic/media/enhancement/amdolby_vision/amdolby_vision.c @@ -82,6 +82,10 @@ static unsigned int dolby_vision_mode = DOLBY_VISION_OUTPUT_MODE_BYPASS; module_param(dolby_vision_mode, uint, 0664); MODULE_PARM_DESC(dolby_vision_mode, "\n dolby_vision_mode\n"); +static unsigned int dolby_vision_target_mode = DOLBY_VISION_OUTPUT_MODE_BYPASS; +module_param(dolby_vision_target_mode, uint, 0444); +MODULE_PARM_DESC(dolby_vision_target_mode, "\n dolby_vision_target_mode\n"); + static unsigned int dolby_vision_profile = 0xff; module_param(dolby_vision_profile, uint, 0664); MODULE_PARM_DESC(dolby_vision_profile, "\n dolby_vision_profile\n"); @@ -3900,6 +3904,7 @@ void enable_dolby_vision(int enable) dolby_vision_wait_init = false; dolby_vision_wait_count = 0; dolby_vision_status = BYPASS_PROCESS; + dolby_vision_target_mode = DOLBY_VISION_OUTPUT_MODE_BYPASS; dolby_vision_mode = DOLBY_VISION_OUTPUT_MODE_BYPASS; dolby_vision_src_format = 0; dolby_vision_on_count = 0; @@ -4868,10 +4873,11 @@ int dolby_vision_check_mvc(struct vframe_s *vf) mode = dolby_vision_mode; if (dolby_vision_policy_process( &mode, FORMAT_MVC)) { - if ((mode == DOLBY_VISION_OUTPUT_MODE_BYPASS) && - (dolby_vision_mode != + if ((mode != DOLBY_VISION_OUTPUT_MODE_BYPASS) && + (dolby_vision_mode == DOLBY_VISION_OUTPUT_MODE_BYPASS)) dolby_vision_wait_on = true; + dolby_vision_target_mode = mode; return 1; } } @@ -4892,6 +4898,7 @@ int dolby_vision_check_hlg(struct vframe_s *vf) && (dolby_vision_mode == DOLBY_VISION_OUTPUT_MODE_BYPASS)) dolby_vision_wait_on = true; + dolby_vision_target_mode = mode; return 1; } } @@ -4912,6 +4919,7 @@ int dolby_vision_check_hdr10plus(struct vframe_s *vf) && (dolby_vision_mode == DOLBY_VISION_OUTPUT_MODE_BYPASS)) dolby_vision_wait_on = true; + dolby_vision_target_mode = mode; return 1; } } @@ -4932,6 +4940,7 @@ int dolby_vision_check_hdr10(struct vframe_s *vf) && (dolby_vision_mode == DOLBY_VISION_OUTPUT_MODE_BYPASS)) dolby_vision_wait_on = true; + dolby_vision_target_mode = mode; return 1; } } @@ -6348,6 +6357,7 @@ int dolby_vision_parse_metadata( dolby_vision_set_toggle_flag(1); pr_info("[dolby_vision_parse_metadata] output change from %d to %d\n", dolby_vision_mode, current_mode); + dolby_vision_target_mode = current_mode; dolby_vision_mode = current_mode; if (is_dolby_vision_stb_mode()) new_dovi_setting.mode_changed = 1; @@ -7010,6 +7020,7 @@ int dolby_vision_wait_metadata(struct vframe_s *vf) dolby_vision_wait_init = true; dolby_vision_wait_count = dolby_vision_wait_delay; + dolby_vision_target_mode = mode; dolby_vision_wait_on = true; pr_dolby_dbg("dolby_vision_need_wait src=%d mode=%d\n", check_format, mode); @@ -7122,6 +7133,7 @@ int dolby_vision_process( int graphic_status = 0; int policy_changed = 0; int sink_changed = 0; + int format_changed = 0; if (!is_meson_box() && !is_meson_txlx() && !is_meson_tm2()) return -1; @@ -7249,14 +7261,14 @@ int dolby_vision_process( /* rpt_vf = NULL; */ } + if (dolby_vision_mode != dolby_vision_target_mode) + format_changed = 1; + graphic_status = is_graphic_changed(); /* monitor policy changes */ policy_changed = is_policy_changed(); - if (policy_changed) - dolby_vision_set_toggle_flag(1); - - if (graphic_status & 2) + if (policy_changed || format_changed || (graphic_status & 2)) dolby_vision_set_toggle_flag(1); if (!is_dolby_vision_on()) @@ -7264,7 +7276,7 @@ int dolby_vision_process( sink_changed = (is_sink_cap_changed(vinfo, ¤t_hdr_cap, ¤t_sink_available) & 2) ? 1 : 0; - if (sink_changed || policy_changed || + if (sink_changed || policy_changed || format_changed || (video_status == 1) || (graphic_status & 2) || (dolby_vision_flags & FLAG_FORCE_HDMI_PKT)) { u8 toggle_mode; @@ -7296,6 +7308,8 @@ int dolby_vision_process( pr_dolby_dbg("Fake SDR, mode->%d\n", mode); if (dolby_vision_policy == DOLBY_VISION_FOLLOW_SOURCE && mode == DOLBY_VISION_OUTPUT_MODE_BYPASS) { + dolby_vision_target_mode = + DOLBY_VISION_OUTPUT_MODE_BYPASS; dolby_vision_mode = DOLBY_VISION_OUTPUT_MODE_BYPASS; dolby_vision_set_toggle_flag(0); @@ -7682,6 +7696,7 @@ void set_dolby_vision_mode(int mode) dolby_vision_wait_on = true; pr_info("DOVI output change from %d to %d\n", dolby_vision_mode, mode); + dolby_vision_target_mode = mode; dolby_vision_mode = mode; } } @@ -7694,6 +7709,12 @@ int get_dolby_vision_mode(void) } EXPORT_SYMBOL(get_dolby_vision_mode); +int get_dolby_vision_target_mode(void) +{ + return dolby_vision_target_mode; +} +EXPORT_SYMBOL(get_dolby_vision_target_mode); + bool is_dolby_vision_enable(void) { return dolby_vision_enable; diff --git a/drivers/amlogic/media/enhancement/amvecm/amcsc.c b/drivers/amlogic/media/enhancement/amvecm/amcsc.c index 384839ff11d3..eba35e575dd8 100644 --- a/drivers/amlogic/media/enhancement/amvecm/amcsc.c +++ b/drivers/amlogic/media/enhancement/amvecm/amcsc.c @@ -377,7 +377,7 @@ int get_hdr_policy(void) /* sync hdr_policy with dolby_vision_policy */ /* get current dolby_vision_mode */ dv_policy = get_dolby_vision_policy(); - dv_mode = get_dolby_vision_mode(); + dv_mode = get_dolby_vision_target_mode(); if ((dv_policy != DOLBY_VISION_FORCE_OUTPUT_MODE) || (dv_mode != DOLBY_VISION_OUTPUT_MODE_BYPASS)) { /* use dv policy when not force bypass */ diff --git a/drivers/amlogic/media/enhancement/amvecm/amcsc_pip.c b/drivers/amlogic/media/enhancement/amvecm/amcsc_pip.c index 3402fe0c901c..e5da2319fef5 100644 --- a/drivers/amlogic/media/enhancement/amvecm/amcsc_pip.c +++ b/drivers/amlogic/media/enhancement/amvecm/amcsc_pip.c @@ -137,7 +137,7 @@ int hdr_policy_process( /* sync hdr_policy with dolby_vision_policy */ /* get current dolby_vision_mode */ dv_policy = get_dolby_vision_policy(); - dv_mode = get_dolby_vision_mode(); + dv_mode = get_dolby_vision_target_mode(); dv_format = get_dolby_vision_src_format(); } diff --git a/drivers/amlogic/media/enhancement/amvecm/set_hdr2_v0.c b/drivers/amlogic/media/enhancement/amvecm/set_hdr2_v0.c index 946abb3d9ca8..4c33306429b7 100644 --- a/drivers/amlogic/media/enhancement/amvecm/set_hdr2_v0.c +++ b/drivers/amlogic/media/enhancement/amvecm/set_hdr2_v0.c @@ -2504,11 +2504,12 @@ enum hdr_process_sel hdr_func(enum hdr_module_sel module_sel, } else if (hdr_process_select == SDR_IPT) { for (i = 0; i < HDR2_OETF_LUT_SIZE; i++) { hdr_lut_param.oetf_lut[i] = oe_y_lut_hdr[i]; - output_mode = get_dolby_vision_mode(); + output_mode = get_dolby_vision_target_mode(); if (output_mode == DOLBY_VISION_OUTPUT_MODE_SDR10 || output_mode == DOLBY_VISION_OUTPUT_MODE_SDR8) hdr_lut_param.ogain_lut[i] = - oo_y_lut_sdr_hdr_250[i]; + 512 * 80 / 10000; + /* oo_y_lut_sdr_hdr_250[i]; */ else if (output_mode == DOLBY_VISION_OUTPUT_MODE_HDR10) hdr_lut_param.ogain_lut[i] = oo_y_lut_sdr_hdr_250[i]; @@ -2532,7 +2533,7 @@ enum hdr_process_sel hdr_func(enum hdr_module_sel module_sel, for (i = 0; i < HDR2_OETF_LUT_SIZE; i++) { hdr_lut_param.oetf_lut[i] = oe_y_lut_hdr[i]; // hdr_lut_param.ogain_lut[i] = oo_y_lut_bypass[i]; - output_mode = get_dolby_vision_mode(); + output_mode = get_dolby_vision_target_mode(); if (output_mode == DOLBY_VISION_OUTPUT_MODE_SDR10 || output_mode == DOLBY_VISION_OUTPUT_MODE_SDR8) hdr_lut_param.ogain_lut[i] = @@ -2560,7 +2561,7 @@ enum hdr_process_sel hdr_func(enum hdr_module_sel module_sel, } else if (hdr_process_select == HDR_IPT) { for (i = 0; i < HDR2_OETF_LUT_SIZE; i++) { hdr_lut_param.oetf_lut[i] = oe_y_lut_hdr[i]; - output_mode = get_dolby_vision_mode(); + output_mode = get_dolby_vision_target_mode(); if (output_mode == DOLBY_VISION_OUTPUT_MODE_SDR10 || output_mode == DOLBY_VISION_OUTPUT_MODE_SDR8) hdr_lut_param.ogain_lut[i] = diff --git a/include/linux/amlogic/media/amdolbyvision/dolby_vision.h b/include/linux/amlogic/media/amdolbyvision/dolby_vision.h index f00fac0a6e5c..4202d2e9934a 100644 --- a/include/linux/amlogic/media/amdolbyvision/dolby_vision.h +++ b/include/linux/amlogic/media/amdolbyvision/dolby_vision.h @@ -53,68 +53,68 @@ #define MUTE_TYPE_RGB 2 #define MUTE_TYPE_IPT 3 -extern void enable_dolby_vision(int enable); -extern bool is_dolby_vision_enable(void); -extern bool is_dolby_vision_on(void); -extern bool is_dolby_vision_video_on(void); -extern bool for_dolby_vision_certification(void); -extern void set_dolby_vision_mode(int mode); -extern int get_dolby_vision_mode(void); -extern void dolby_vision_set_toggle_flag(int flag); -extern int dolby_vision_wait_metadata(struct vframe_s *vf); -extern int dolby_vision_pop_metadata(void); +void enable_dolby_vision(int enable); +bool is_dolby_vision_enable(void); +bool is_dolby_vision_on(void); +bool is_dolby_vision_video_on(void); +bool for_dolby_vision_certification(void); +void set_dolby_vision_mode(int mode); +int get_dolby_vision_mode(void); +int get_dolby_vision_target_mode(void); +void dolby_vision_set_toggle_flag(int flag); +int dolby_vision_wait_metadata(struct vframe_s *vf); +int dolby_vision_pop_metadata(void); int dolby_vision_update_metadata(struct vframe_s *vf, bool drop_flag); int dolby_vision_process( struct vframe_s *rpt_vf, struct vframe_s *vf, u32 display_size, u8 pps_state); -extern void dolby_vision_init_receiver(void *pdev); -extern void dolby_vision_vf_put(struct vframe_s *vf); -extern struct vframe_s *dolby_vision_vf_peek_el(struct vframe_s *vf); -extern void dolby_vision_dump_setting(int debug_flag); -extern void dolby_vision_dump_struct(void); -extern void enable_osd_path(int on, int shadow_mode); -extern void tv_dolby_vision_config(int config); -extern void dolby_vision_update_pq_config( +void dolby_vision_init_receiver(void *pdev); +void dolby_vision_vf_put(struct vframe_s *vf); +struct vframe_s *dolby_vision_vf_peek_el(struct vframe_s *vf); +void dolby_vision_dump_setting(int debug_flag); +void dolby_vision_dump_struct(void); +void enable_osd_path(int on, int shadow_mode); +void tv_dolby_vision_config(int config); +void dolby_vision_update_pq_config( char *pq_config_buf); -extern int dolby_vision_update_setting(void); -extern bool is_dolby_vision_stb_mode(void); -extern bool is_meson_g12(void); -extern bool is_meson_gxm(void); -extern bool is_meson_box(void); -extern bool is_meson_txlx(void); -extern bool is_meson_txlx_tvmode(void); -extern bool is_meson_txlx_stbmode(void); -extern bool is_meson_tm2(void); -extern bool is_meson_tm2_tvmode(void); -extern bool is_meson_tm2_stbmode(void); -extern bool is_meson_tvmode(void); -extern void tv_dolby_vision_crc_clear(int flag); -extern char *tv_dolby_vision_get_crc(u32 *len); -extern void tv_dolby_vision_insert_crc(bool print); -extern int dolby_vision_check_hdr10(struct vframe_s *vf); -extern int dolby_vision_check_hlg(struct vframe_s *vf); -extern int dolby_vision_check_hdr10plus(struct vframe_s *vf); -extern void tv_dolby_vision_dma_table_modify( +int dolby_vision_update_setting(void); +bool is_dolby_vision_stb_mode(void); +bool is_meson_g12(void); +bool is_meson_gxm(void); +bool is_meson_box(void); +bool is_meson_txlx(void); +bool is_meson_txlx_tvmode(void); +bool is_meson_txlx_stbmode(void); +bool is_meson_tm2(void); +bool is_meson_tm2_tvmode(void); +bool is_meson_tm2_stbmode(void); +bool is_meson_tvmode(void); +void tv_dolby_vision_crc_clear(int flag); +char *tv_dolby_vision_get_crc(u32 *len); +void tv_dolby_vision_insert_crc(bool print); +int dolby_vision_check_hdr10(struct vframe_s *vf); +int dolby_vision_check_hlg(struct vframe_s *vf); +int dolby_vision_check_hdr10plus(struct vframe_s *vf); +void tv_dolby_vision_dma_table_modify( u32 tbl_id, uint64_t value); -extern void tv_dolby_vision_efuse_info(void); -extern int dolby_vision_parse_metadata( +void tv_dolby_vision_efuse_info(void); +int dolby_vision_parse_metadata( struct vframe_s *vf, u8 toggle_mode, bool bypass_release, bool drop_flag); -extern void dolby_vision_update_vsvdb_config( +void dolby_vision_update_vsvdb_config( char *vsvdb_buf, u32 tbl_size); -extern void tv_dolby_vision_el_info(void); +void tv_dolby_vision_el_info(void); -extern int enable_rgb_to_yuv_matrix_for_dvll( +int enable_rgb_to_yuv_matrix_for_dvll( int32_t on, uint32_t *coeff_orig, uint32_t bits); -extern bool is_dovi_frame(struct vframe_s *vf); -extern void update_graphic_width_height(unsigned int width, - unsigned int height); -extern int get_dolby_vision_policy(void); +bool is_dovi_frame(struct vframe_s *vf); +void update_graphic_width_height(unsigned int width, unsigned int height); +int get_dolby_vision_policy(void); void set_dolby_vision_policy(int policy); -extern int get_dolby_vision_src_format(void); -extern bool is_dolby_vision_el_disable(void); -extern bool is_dovi_dual_layer_frame(struct vframe_s *vf); +int get_dolby_vision_src_format(void); +bool is_dolby_vision_el_disable(void); +bool is_dovi_dual_layer_frame(struct vframe_s *vf); void dolby_vision_set_provider(char *prov_name); int dolby_vision_check_mvc(struct vframe_s *vf); #endif -- 2.20.1