From 0d07e6ac1bf9017cb4929e4ef19c6851497d3ac0 Mon Sep 17 00:00:00 2001 From: Hui Zhang Date: Thu, 3 May 2018 20:47:49 +0800 Subject: [PATCH] video_keeper: fixed greenscreen bug PD#155455: fixed green screen bug Change-Id: Idbb2ae30b1bd88d1782ff47b485e0cbf476641d0 Signed-off-by: Hui Zhang --- drivers/amlogic/media/video_sink/video.c | 20 ++++++++++++++----- .../amlogic/media/video_sink/video_keeper.c | 13 ++++++++---- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/amlogic/media/video_sink/video.c b/drivers/amlogic/media/video_sink/video.c index 2496f15a7b1a..aac682980fdb 100644 --- a/drivers/amlogic/media/video_sink/video.c +++ b/drivers/amlogic/media/video_sink/video.c @@ -343,6 +343,7 @@ static u32 hdmiin_frame_check_cnt; CLEAR_VCBUS_REG_MASK(VPP_MISC + cur_dev->vpp_off, \ VPP_VD1_PREBLEND | VPP_VD2_PREBLEND|\ VPP_VD2_POSTBLEND | VPP_VD1_POSTBLEND); \ + WRITE_VCBUS_REG(AFBC_ENABLE, 0);\ VIDEO_LAYER_OFF(); \ VD1_MEM_POWER_OFF(); \ video_prot.video_started = 0; \ @@ -357,6 +358,7 @@ static u32 hdmiin_frame_check_cnt; CLEAR_VCBUS_REG_MASK(VPP_MISC + cur_dev->vpp_off, \ VPP_VD1_PREBLEND | VPP_VD2_PREBLEND|\ VPP_VD2_POSTBLEND | VPP_VD1_POSTBLEND); \ + WRITE_VCBUS_REG(AFBC_ENABLE, 0);\ if (debug_flag & DEBUG_FLAG_BLACKOUT) { \ pr_info("DisableVideoLayer_NoDelay()\n"); \ } \ @@ -370,6 +372,7 @@ static u32 hdmiin_frame_check_cnt; CLEAR_VCBUS_REG_MASK(VPP_MISC + cur_dev->vpp_off, \ VPP_VD2_PREBLEND | VPP_PREBLEND_EN | \ (0x1ff << VPP_VD2_ALPHA_BIT)); \ + WRITE_VCBUS_REG(VD2_AFBC_ENABLE, 0); \ VD2_MEM_POWER_OFF(); \ } while (0) #else @@ -385,6 +388,7 @@ static u32 hdmiin_frame_check_cnt; #define DisableVideoLayer_PREBELEND() \ do { CLEAR_VCBUS_REG_MASK(VPP_MISC + cur_dev->vpp_off, \ VPP_VD1_PREBLEND | VPP_VD2_PREBLEND); \ + WRITE_VCBUS_REG(AFBC_ENABLE, 0);\ if (debug_flag & DEBUG_FLAG_BLACKOUT) { \ pr_info("DisableVideoLayer_PREBELEND()\n"); \ } \ @@ -3277,8 +3281,8 @@ static void vd2_set_dcu(struct vpp_frame_par_s *frame_par, struct vframe_s *vf) VD2_IF0_GEN_REG3 + cur_dev->viu_off, (bit_mode&0x3), 8, 2); } - - VSYNC_WR_MPEG_REG(VD2_AFBC_ENABLE, 0); + if (!(VSYNC_RD_MPEG_REG(VIU_MISC_CTRL1) & 0x1)) + VSYNC_WR_MPEG_REG(VD2_AFBC_ENABLE, 0); if (type & VIDTYPE_VIU_NV21) VSYNC_WR_MPEG_REG_BITS( VD2_IF0_GEN_REG2 + @@ -5979,7 +5983,7 @@ static void video_vf_unreg_provider(void) { ulong flags; struct vframe_s *el_vf = NULL; - + int keeped = 0; new_frame_count = 0; first_frame_toggled = 0; @@ -6033,7 +6037,7 @@ static void video_vf_unreg_provider(void) if (cur_dispbuf) { /* TODO: mod gate */ /* switch_mod_gate_by_name("ge2d", 1); */ - vf_keep_current(cur_dispbuf, el_vf); + keeped = vf_keep_current(cur_dispbuf, el_vf); /* TODO: mod gate */ /* switch_mod_gate_by_name("ge2d", 0); */ } @@ -6042,11 +6046,17 @@ static void video_vf_unreg_provider(void) #else /* if (!trickmode_fffb) */ if (cur_dispbuf) - vf_keep_current(cur_dispbuf, el_vf); + keeped = vf_keep_current(cur_dispbuf, el_vf); if (hdmi_in_onvideo == 0) tsync_avevent(VIDEO_STOP, 0); #endif + if (keeped < 0) {/*keep failed.*/ + pr_info("video keep failed, disable video now!\n"); + safe_disble_videolayer(); + try_free_keep_video(1); + } atomic_set(&video_unreg_flag, 0); + pr_info("VD1 AFBC 0x%x.\n", READ_VCBUS_REG(AFBC_ENABLE)); enable_video_discontinue_report = 1; show_first_picture = false; show_first_frame_nosync = false; diff --git a/drivers/amlogic/media/video_sink/video_keeper.c b/drivers/amlogic/media/video_sink/video_keeper.c index cdbcbc3bb8aa..1eaf894710f3 100644 --- a/drivers/amlogic/media/video_sink/video_keeper.c +++ b/drivers/amlogic/media/video_sink/video_keeper.c @@ -731,7 +731,7 @@ static void video_keeper_update_keeper_mem( *id = ret; } } -static void video_keeper_frame_keep_locked( +static int video_keeper_frame_keep_locked( struct vframe_s *cur_dispbuf, struct vframe_s *cur_dispbuf_el) { @@ -761,6 +761,7 @@ static void video_keeper_frame_keep_locked( MEM_TYPE_CODEC_MM, &keep_el_head_id); } + return (keep_id + keep_head_id) > 0; } /* @@ -802,6 +803,7 @@ static unsigned int vf_keep_current_locked( u32 cur_index; u32 y_index, u_index, v_index; struct canvas_s cs0, cs1, cs2, cd; + int ret; if (!cur_dispbuf) { pr_info("keep exit without cur_dispbuf\n"); @@ -829,9 +831,12 @@ static unsigned int vf_keep_current_locked( return 0; } - video_keeper_frame_keep_locked(cur_dispbuf, + ret = video_keeper_frame_keep_locked(cur_dispbuf, cur_dispbuf_el); - + if (ret) { + /*keeped ok with codec keeper!*/ + return 1; + } #ifdef CONFIG_AMLOGIC_MEDIA_MULTI_DEC if (codec_mm_video_tvp_enabled()) { pr_info("keep exit is TVP\n"); @@ -1020,7 +1025,7 @@ static unsigned int vf_keep_current_locked( } keep_video_on = 1; pr_info("%s: keep video on with keep\n", __func__); - return 0; + return 1; } unsigned int vf_keep_current(