mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
msm: msm_fb: validating backlight level and scale value
Validating the value of backlight to be not more than the max value and also ensuring that the backlight scale value is not more than 1024, thereby ensuring that backlight scaling factor is not more than 1 Change-Id: I6a6f4f0f0a8c272edcac5078276fb406ddee3e90 Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org> [zhaoweiliew: Add bl_lvl argument for msm_fb_scale_bl in bl_workqueue_handler] Signed-off-by: Zhao Wei Liew <zhaoweiliew@gmail.com>
This commit is contained in:
parent
5fab4dda1c
commit
7c6ed19d8f
1 changed files with 15 additions and 5 deletions
|
@ -123,7 +123,7 @@ static int msm_fb_ioctl(struct fb_info *info, unsigned int cmd,
|
|||
static int msm_fb_mmap(struct fb_info *info, struct vm_area_struct * vma);
|
||||
static int mdp_bl_scale_config(struct msm_fb_data_type *mfd,
|
||||
struct mdp_bl_scale_data *data);
|
||||
static void msm_fb_scale_bl(__u32 *bl_lvl);
|
||||
static void msm_fb_scale_bl(__u32 bl_max, __u32 *bl_lvl);
|
||||
static int msm_fb_commit_thread(void *data);
|
||||
static int msm_fb_pan_idle(struct msm_fb_data_type *mfd);
|
||||
|
||||
|
@ -1041,13 +1041,23 @@ static int mdp_bl_scale_config(struct msm_fb_data_type *mfd,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void msm_fb_scale_bl(__u32 *bl_lvl)
|
||||
static void msm_fb_scale_bl(__u32 bl_max, __u32 *bl_lvl)
|
||||
{
|
||||
__u32 temp = *bl_lvl;
|
||||
pr_debug("%s: input = %d, scale = %d", __func__, temp, bl_scale);
|
||||
if (temp >= bl_min_lvl) {
|
||||
/* checking if temp is below bl_max else capping */
|
||||
if (temp > bl_max) {
|
||||
pr_warn("%s: invalid bl level\n", __func__);
|
||||
temp = bl_max;
|
||||
}
|
||||
/* checking if bl_scale is below 1024 else capping */
|
||||
if (bl_scale > 1024) {
|
||||
pr_warn("%s: invalid bl scale\n", __func__);
|
||||
bl_scale = 1024;
|
||||
}
|
||||
/* bl_scale is the numerator of scaling fraction (x/1024)*/
|
||||
temp = ((*bl_lvl) * bl_scale) / 1024;
|
||||
temp = (temp * bl_scale) / 1024;
|
||||
|
||||
/*if less than minimum level, use min level*/
|
||||
if (temp < bl_min_lvl)
|
||||
|
@ -1072,7 +1082,7 @@ void msm_fb_set_backlight(struct msm_fb_data_type *mfd, __u32 bkl_lvl)
|
|||
pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data;
|
||||
|
||||
if ((pdata) && (pdata->set_backlight)) {
|
||||
msm_fb_scale_bl(&temp);
|
||||
msm_fb_scale_bl(mfd->panel_info.bl_max, &temp);
|
||||
if (bl_level_old == temp) {
|
||||
return;
|
||||
}
|
||||
|
@ -2115,7 +2125,7 @@ static void bl_workqueue_handler(struct work_struct *work)
|
|||
down(&mfd->sem);
|
||||
if ((pdata) && (pdata->set_backlight) && (!bl_updated)
|
||||
&& (mfd->panel_power_on)) {
|
||||
msm_fb_scale_bl(&temp);
|
||||
msm_fb_scale_bl(mfd->panel_info.bl_max, &temp);
|
||||
mfd->bl_level = temp;
|
||||
pdata->set_backlight(mfd);
|
||||
bl_level_old = unset_bl_level;
|
||||
|
|
Loading…
Reference in a new issue