10 #include <asm/ptrace.h>
11 #include <linux/adb.h>
12 #include <linux/pmu.h>
16 #define MAX_PMU_LEVEL 0xFF
21 static u8 bl_curve[FB_BACKLIGHT_LEVELS];
23 static void pmu_backlight_init_curve(
u8 off,
u8 min,
u8 max)
29 for (flat = 1; flat < (FB_BACKLIGHT_LEVELS / 16); ++flat)
32 count = FB_BACKLIGHT_LEVELS * 15 / 16;
33 for (i = 0; i <
count; ++
i)
34 bl_curve[flat + i] = min + (range * (i + 1) /
count);
37 static int pmu_backlight_curve_lookup(
int value)
39 int level = (FB_BACKLIGHT_LEVELS - 1);
43 for (i = 0; i < FB_BACKLIGHT_LEVELS; i++)
44 max =
max((
int)bl_curve[
i],
max);
47 for (i = 0; i < FB_BACKLIGHT_LEVELS; i++) {
48 int diff =
abs(bl_curve[i] - value);
57 static int pmu_backlight_get_level_brightness(
int level)
74 int level = bd->
props.brightness;
82 int pmulevel = pmu_backlight_get_level_brightness(level);
107 rc = __pmu_backlight_update_status(bd);
108 spin_unlock_irqrestore(&pmu_backlight_lock, flags);
115 return bd->
props.brightness;
119 .get_brightness = pmu_backlight_get_brightness,
120 .update_status = pmu_backlight_update_status,
141 spin_unlock_irqrestore(&pmu_backlight_lock, flags);
163 snprintf(name,
sizeof(name),
"pmubl");
175 pmu_backlight_init_curve(0x7F, 0x46, 0x0E);
177 level = bd->
props.max_brightness;
185 level = pmu_backlight_curve_lookup(
186 (req.
reply[0] >> 4) *
187 bd->
props.max_brightness / 15);
192 backlight_update_status(bd);