video: msm_fb: Ensure backlight is scaled atomically.

Ensure that when backlight scaling ratio or backlight level is being
changed that the operation execute atomically. This prevents a backlight
level change from being overwritten when it interrupts a backlight scale
update.

CRs-Fixed: 404017
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit ce328861aa1f4fa489e9abfc9d1e02b13af2ba47)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
(cherry picked from commit 0584596f75f8f2b184b8be1a0479ee61e449acba)

Change-Id: Ifb4bd5e823815b51dae38f1b8647b80d21b8ee45
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
This commit is contained in:
Carl Vanderlip
2012-09-25 18:52:00 -07:00
committed by Stephen Boyd
parent c094187019
commit 9bca4ef76a
2 changed files with 12 additions and 12 deletions

View File

@@ -198,7 +198,9 @@ static void msm_fb_set_bl_brightness(struct led_classdev *led_cdev,
MAX_BACKLIGHT_BRIGHTNESS - 1) /
(MAX_BACKLIGHT_BRIGHTNESS - 1) / 2;
down(&mfd->sem);
msm_fb_set_backlight(mfd, bl_lvl);
up(&mfd->sem);
}
static struct led_classdev backlight_led = {
@@ -845,7 +847,9 @@ static int mdp_bl_scale_config(struct msm_fb_data_type *mfd,
struct mdp_bl_scale_data *data)
{
int ret = 0;
int curr_bl = mfd->bl_level;
int curr_bl;
down(&mfd->sem);
curr_bl = mfd->bl_level;
bl_scale = data->scale;
bl_min_lvl = data->min_lvl;
pr_debug("%s: update scale = %d, min_lvl = %d\n", __func__, bl_scale,
@@ -853,6 +857,7 @@ static int mdp_bl_scale_config(struct msm_fb_data_type *mfd,
/* update current backlight to use new scaling*/
msm_fb_set_backlight(mfd, curr_bl);
up(&mfd->sem);
return ret;
}
@@ -860,6 +865,7 @@ static int mdp_bl_scale_config(struct msm_fb_data_type *mfd,
static void msm_fb_scale_bl(__u32 *bl_lvl)
{
__u32 temp = *bl_lvl;
pr_debug("%s: input = %d, scale = %d", __func__, temp, bl_scale);
if (temp >= bl_min_lvl) {
/* bl_scale is the numerator of scaling fraction (x/1024)*/
temp = ((*bl_lvl) * bl_scale) / 1024;
@@ -868,10 +874,12 @@ static void msm_fb_scale_bl(__u32 *bl_lvl)
if (temp < bl_min_lvl)
temp = bl_min_lvl;
}
pr_debug("%s: output = %d", __func__, temp);
(*bl_lvl) = temp;
}
/*must call this function from within mfd->sem*/
void msm_fb_set_backlight(struct msm_fb_data_type *mfd, __u32 bkl_lvl)
{
struct msm_fb_panel_data *pdata;
@@ -884,27 +892,17 @@ void msm_fb_set_backlight(struct msm_fb_data_type *mfd, __u32 bkl_lvl)
unset_bl_level = 0;
}
if (!mfd->panel_power_on || !bl_updated) {
unset_bl_level = bkl_lvl;
return;
} else {
unset_bl_level = 0;
}
msm_fb_scale_bl(&temp);
pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data;
if ((pdata) && (pdata->set_backlight)) {
down(&mfd->sem);
msm_fb_scale_bl(&temp);
if (bl_level_old == temp) {
up(&mfd->sem);
return;
}
mfd->bl_level = temp;
pdata->set_backlight(mfd);
mfd->bl_level = bkl_lvl;
bl_level_old = temp;
up(&mfd->sem);
}
}

View File

@@ -34,7 +34,9 @@ static int msm_fb_bl_update_status(struct backlight_device *pbd)
bl_lvl = pbd->props.brightness;
bl_lvl = mfd->fbi->bl_curve[bl_lvl];
down(&mfd->sem);
msm_fb_set_backlight(mfd, bl_lvl);
up(&mfd->sem);
return 0;
}