android_kernel_google_msm/drivers/video/msm/msm_fb_bl.c
Carl Vanderlip 9bca4ef76a 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>
2013-03-07 15:19:21 -08:00

77 lines
2.1 KiB
C

/* Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
* only version 2 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/fb.h>
#include <linux/string.h>
#include <linux/version.h>
#include <linux/backlight.h>
#include "msm_fb.h"
static int msm_fb_bl_get_brightness(struct backlight_device *pbd)
{
return pbd->props.brightness;
}
static int msm_fb_bl_update_status(struct backlight_device *pbd)
{
struct msm_fb_data_type *mfd = bl_get_data(pbd);
__u32 bl_lvl;
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;
}
static struct backlight_ops msm_fb_bl_ops = {
.get_brightness = msm_fb_bl_get_brightness,
.update_status = msm_fb_bl_update_status,
};
void msm_fb_config_backlight(struct msm_fb_data_type *mfd)
{
struct msm_fb_panel_data *pdata;
struct backlight_device *pbd;
struct fb_info *fbi;
char name[16];
struct backlight_properties props;
fbi = mfd->fbi;
pdata = (struct msm_fb_panel_data *)mfd->pdev->dev.platform_data;
if ((pdata) && (pdata->set_backlight)) {
snprintf(name, sizeof(name), "msmfb_bl%d", mfd->index);
props.max_brightness = FB_BACKLIGHT_LEVELS - 1;
props.brightness = FB_BACKLIGHT_LEVELS - 1;
pbd =
backlight_device_register(name, fbi->dev, mfd,
&msm_fb_bl_ops, &props);
if (!IS_ERR(pbd)) {
fbi->bl_dev = pbd;
fb_bl_default_curve(fbi,
0,
mfd->panel_info.bl_min,
mfd->panel_info.bl_max);
} else {
fbi->bl_dev = NULL;
printk(KERN_ERR "msm_fb: backlight_device_register failed!\n");
}
}
}