From a3cb6c089a6056d98308eed2084b73ee11905b74 Mon Sep 17 00:00:00 2001 From: Ping Li Date: Thu, 7 Jul 2016 10:22:15 -0700 Subject: [PATCH 1/2] msm: mdss: Fix deadlock in AD code AD calc_worker vsync thread acquires the AD lock inside the function, so the call to cancel the AD calc_worker vsync thread cannot be within the AD lock. Change-Id: Ice78f43721916110f52c3393f78c3a1868976821 Signed-off-by: Ping Li --- drivers/video/fbdev/msm/mdss_mdp_pp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/msm/mdss_mdp_pp.c b/drivers/video/fbdev/msm/mdss_mdp_pp.c index 437e01535924..63d7bf45200b 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_pp.c +++ b/drivers/video/fbdev/msm/mdss_mdp_pp.c @@ -7401,8 +7401,8 @@ static int pp_mfd_ad_release_all(struct msm_fb_data_type *mfd) ad->mfd = NULL; ad->bl_mfd = NULL; ad->state = 0; - cancel_work_sync(&ad->calc_work); mutex_unlock(&ad->lock); + cancel_work_sync(&ad->calc_work); ctl = mfd_to_ctl(mfd); if (ctl && ctl->ops.remove_vsync_handler) From 570f2550be444d93e1c3666f43f084b5075b91c0 Mon Sep 17 00:00:00 2001 From: Ping Li Date: Fri, 8 Jul 2016 14:42:11 -0700 Subject: [PATCH 2/2] msm: mdss: Fix AD backlight configuration When AD backlight attenuation feature is not enabled, the backlight send to panel doesn't need to go through the backlight linearization and inverse linearization. Also set ad_bl_level to the current panel backlight level when AD is enabled the first time and reset the ad_bl_level to 0 when AD is disabled. Change-Id: If96eccd817ecee6eae5fcc56fda29197b8b9f50d Signed-off-by: Ping Li --- drivers/video/fbdev/msm/mdss_mdp_pp.c | 40 ++++++++++++++++----------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/drivers/video/fbdev/msm/mdss_mdp_pp.c b/drivers/video/fbdev/msm/mdss_mdp_pp.c index 63d7bf45200b..dfc3e44c7aaa 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_pp.c +++ b/drivers/video/fbdev/msm/mdss_mdp_pp.c @@ -3099,8 +3099,8 @@ static int pp_ad_calc_bl(struct msm_fb_data_type *mfd, int bl_in, int *bl_out, mutex_lock(&ad->lock); if (!mfd->ad_bl_level) mfd->ad_bl_level = bl_in; - if (!(ad->state & PP_AD_STATE_RUN)) { - pr_debug("AD is not running.\n"); + if (!(ad->sts & PP_STS_ENABLE)) { + pr_debug("AD is not enabled.\n"); mutex_unlock(&ad->lock); return -EPERM; } @@ -3123,22 +3123,27 @@ static int pp_ad_calc_bl(struct msm_fb_data_type *mfd, int bl_in, int *bl_out, return ret; } - ret = pp_ad_attenuate_bl(ad, temp, &temp); - if (ret) { - pr_err("Failed to attenuate BL: %d\n", ret); - mutex_unlock(&ad->lock); - return ret; - } - ad_bl_out = temp; + if (ad->init.alpha > 0) { + ret = pp_ad_attenuate_bl(ad, temp, &temp); + if (ret) { + pr_err("Failed to attenuate BL: %d\n", ret); + mutex_unlock(&ad->lock); + return ret; + } + ad_bl_out = temp; - ret = pp_ad_linearize_bl(ad, temp, &temp, MDP_PP_AD_BL_LINEAR_INV); - if (ret) { - pr_err("Failed to inverse linearize BL: %d\n", ret); - mutex_unlock(&ad->lock); - return ret; + ret = pp_ad_linearize_bl(ad, temp, &temp, + MDP_PP_AD_BL_LINEAR_INV); + if (ret) { + pr_err("Failed to inverse linearize BL: %d\n", ret); + mutex_unlock(&ad->lock); + return ret; + } + *bl_out = temp; + } else { + ad_bl_out = temp; } - *bl_out = temp; if (pp_ad_bl_threshold_check(ad->init.al_thresh, ad->init.alpha_base, ad->last_bl, ad_bl_out)) { mfd->ad_bl_level = ad_bl_out; @@ -6193,6 +6198,8 @@ static int mdss_mdp_ad_setup(struct msm_fb_data_type *mfd) ad->sts &= ~PP_AD_STS_DIRTY_DATA; ad->state |= PP_AD_STATE_DATA; pr_debug("dirty data, last_bl = %d\n", ad->last_bl); + if (!bl_mfd->ad_bl_level) + bl_mfd->ad_bl_level = bl_mfd->bl_level; bl = bl_mfd->ad_bl_level; if (ad->last_bl != bl) { @@ -6280,6 +6287,7 @@ static int mdss_mdp_ad_setup(struct msm_fb_data_type *mfd) memset(&ad->cfg, 0, sizeof(struct mdss_ad_cfg)); bl_mfd->ext_bl_ctrl = 0; bl_mfd->ext_ad_ctrl = -1; + bl_mfd->ad_bl_level = 0; } ad->state &= ~PP_AD_STATE_RUN; } @@ -6384,7 +6392,7 @@ static void pp_ad_cfg_lut(char __iomem *addr, u32 *data) } /* must call this function from within ad->lock */ -static int pp_ad_attenuate_bl(struct mdss_ad_info *ad, u32 bl, u32 *bl_out) +static int pp_ad_attenuate_bl(struct mdss_ad_info *ad, u32 bl, u32 *bl_out) { u32 shift = 0, ratio_temp = 0; u32 n, lut_interval, bl_att;