diff options
Diffstat (limited to 'firmware/target/arm/imx31/gigabeat-s')
-rw-r--r-- | firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c | 71 |
1 files changed, 64 insertions, 7 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c b/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c index 1a41f0c53e..4df9be843c 100644 --- a/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c +++ b/firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c | |||
@@ -17,17 +17,59 @@ | |||
17 | * | 17 | * |
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "config.h" | 19 | #include "config.h" |
20 | #include "cpu.h" | ||
21 | #include "system.h" | 20 | #include "system.h" |
22 | #include "backlight-target.h" | ||
23 | #include "backlight.h" | 21 | #include "backlight.h" |
24 | #include "lcd.h" | ||
25 | #include "power.h" | ||
26 | #include "mc13783.h" | 22 | #include "mc13783.h" |
27 | #include "debug.h" | 23 | #include "backlight-target.h" |
24 | |||
25 | /* Table that uses combinations of current level and pwm fraction to get | ||
26 | * as many uniquely-visible brightness levels as possible. The lowest current | ||
27 | * level for any average current is used even though many combinations give | ||
28 | * duplicate values. Current (I) values are in mA. */ | ||
29 | static const struct | ||
30 | { | ||
31 | unsigned char md; | ||
32 | unsigned char pwm; | ||
33 | } led_md_pwm_table[] = | ||
34 | { | ||
35 | /* I-level PWM(x/15) I-Avg */ | ||
36 | { 0, 0 }, /* 0 0 0.0 */ | ||
37 | { 1, 1 }, /* 3 1 0.2 */ | ||
38 | { 1, 2 }, /* 3 2 0.4 */ | ||
39 | { 1, 3 }, /* 3 3 0.6 */ | ||
40 | { 1, 4 }, /* 3 4 0.8 */ | ||
41 | { 1, 5 }, /* 3 5 1.0 */ | ||
42 | { 1, 6 }, /* 3 6 1.2 */ | ||
43 | { 1, 7 }, /* 3 7 1.4 */ | ||
44 | { 1, 8 }, /* 3 8 1.6 */ | ||
45 | { 1, 9 }, /* 3 9 1.8 */ | ||
46 | { 1, 10 }, /* 3 10 2.0 */ | ||
47 | { 1, 11 }, /* 3 11 2.2 */ | ||
48 | { 1, 12 }, /* 3 12 2.4 */ /* default */ | ||
49 | { 1, 13 }, /* 3 13 2.6 */ | ||
50 | { 1, 14 }, /* 3 14 2.8 */ | ||
51 | { 1, 15 }, /* 3 15 3.0 */ | ||
52 | { 2, 9 }, /* 6 9 3.6 */ | ||
53 | { 2, 10 }, /* 6 10 4.0 */ | ||
54 | { 2, 11 }, /* 6 11 4.4 */ | ||
55 | { 2, 12 }, /* 6 12 4.8 */ | ||
56 | { 2, 13 }, /* 6 13 5.2 */ | ||
57 | { 2, 14 }, /* 6 14 5.6 */ | ||
58 | { 2, 15 }, /* 6 15 6.0 */ | ||
59 | { 3, 11 }, /* 9 11 6.6 */ | ||
60 | { 3, 12 }, /* 9 12 7.2 */ | ||
61 | /* Anything higher is just too much */ | ||
62 | }; | ||
28 | 63 | ||
29 | bool _backlight_init(void) | 64 | bool _backlight_init(void) |
30 | { | 65 | { |
66 | mc13783_write(MC13783_LED_CONTROL0, | ||
67 | MC13783_LEDEN | | ||
68 | MC13783_LEDMDRAMPUP | | ||
69 | MC13783_LEDMDRAMPDOWN | | ||
70 | MC13783_BOOSTEN | | ||
71 | MC13783_ABMODE_MONCH_LEDMD1234 | | ||
72 | MC13783_ABREF_400MV); | ||
31 | return true; | 73 | return true; |
32 | } | 74 | } |
33 | 75 | ||
@@ -46,6 +88,21 @@ void _backlight_off(void) | |||
46 | /* Assumes that the backlight has been initialized */ | 88 | /* Assumes that the backlight has been initialized */ |
47 | void _backlight_set_brightness(int brightness) | 89 | void _backlight_set_brightness(int brightness) |
48 | { | 90 | { |
49 | (void)brightness; | 91 | uint32_t data, md, pwm; |
50 | } | ||
51 | 92 | ||
93 | if ((unsigned)brightness >= ARRAYLEN(led_md_pwm_table)) | ||
94 | brightness = DEFAULT_BRIGHTNESS_SETTING; | ||
95 | |||
96 | data = mc13783_read(MC13783_LED_CONTROL2); | ||
97 | |||
98 | if (data == (uint32_t)-1) | ||
99 | return; | ||
100 | |||
101 | md = led_md_pwm_table[brightness].md; | ||
102 | pwm = led_md_pwm_table[brightness].pwm; | ||
103 | |||
104 | data &= ~(MC13783_LEDMD | MC13783_LEDMDDC); | ||
105 | data |= MC13783_LEDMDw(md) | MC13783_LEDMDDCw(pwm); | ||
106 | |||
107 | mc13783_write(MC13783_LED_CONTROL2, data); | ||
108 | } | ||