1 /* Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved.
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 #include <linux/module.h>
19 #include <linux/moduleparam.h>
20 #include <linux/kernel.h>
21 #include <linux/slab.h>
23 #include <linux/string.h>
24 #include <linux/version.h>
25 #include <linux/backlight.h>
29 static int msm_fb_bl_get_brightness(struct backlight_device
*pbd
)
31 return pbd
->props
.brightness
;
34 static int msm_fb_bl_update_status(struct backlight_device
*pbd
)
36 struct msm_fb_data_type
*mfd
= bl_get_data(pbd
);
39 bl_lvl
= pbd
->props
.brightness
;
40 bl_lvl
= mfd
->fbi
->bl_curve
[bl_lvl
];
41 msm_fb_set_backlight(mfd
, bl_lvl
, 1);
45 static struct backlight_ops msm_fb_bl_ops
= {
46 .get_brightness
= msm_fb_bl_get_brightness
,
47 .update_status
= msm_fb_bl_update_status
,
50 void msm_fb_config_backlight(struct msm_fb_data_type
*mfd
)
52 struct msm_fb_panel_data
*pdata
;
53 struct backlight_device
*pbd
;
58 pdata
= (struct msm_fb_panel_data
*)mfd
->pdev
->dev
.platform_data
;
60 if ((pdata
) && (pdata
->set_backlight
)) {
61 snprintf(name
, sizeof(name
), "msmfb_bl%d", mfd
->index
);
63 backlight_device_register(name
, fbi
->dev
, mfd
,
67 fb_bl_default_curve(fbi
,
69 mfd
->panel_info
.bl_min
,
70 mfd
->panel_info
.bl_max
);
71 pbd
->props
.max_brightness
= FB_BACKLIGHT_LEVELS
- 1;
72 pbd
->props
.brightness
= FB_BACKLIGHT_LEVELS
- 1;
73 backlight_update_status(pbd
);
76 printk(KERN_ERR
"msm_fb: backlight_device_register failed!\n");