summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2008-05-08 22:03:49 +0000
committerMichael Sevakis <jethead71@rockbox.org>2008-05-08 22:03:49 +0000
commit25583656d9e4f99c73ee41cf37055bed5aafa938 (patch)
tree8232027235ee8d16377ef8b57416dd73f46bbad1
parent2d6aa41141bfd0f6327ea2eb16b8853ae8caf31f (diff)
downloadrockbox-25583656d9e4f99c73ee41cf37055bed5aafa938.tar.gz
rockbox-25583656d9e4f99c73ee41cf37055bed5aafa938.zip
Backlight brightness setting for Gigabeat S. Cleanup headers in target backlight file too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17428 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/config-gigabeat-s.h8
-rw-r--r--firmware/export/mc13783.h146
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/backlight-imx31.c71
3 files changed, 213 insertions, 12 deletions
diff --git a/firmware/export/config-gigabeat-s.h b/firmware/export/config-gigabeat-s.h
index e290952ce7..d74f05ce9c 100644
--- a/firmware/export/config-gigabeat-s.h
+++ b/firmware/export/config-gigabeat-s.h
@@ -56,12 +56,12 @@
56 56
57#define HAVE_LCD_ENABLE 57#define HAVE_LCD_ENABLE
58 58
59//#define HAVE_BACKLIGHT_BRIGHTNESS 59#define HAVE_BACKLIGHT_BRIGHTNESS
60 60
61/* Main LCD backlight brightness range and defaults */ 61/* Main LCD backlight brightness range and defaults */
62#define MIN_BRIGHTNESS_SETTING 0 /* 0.5 mA */ 62#define MIN_BRIGHTNESS_SETTING 0
63#define MAX_BRIGHTNESS_SETTING 63 /* 32 mA */ 63#define MAX_BRIGHTNESS_SETTING 24
64#define DEFAULT_BRIGHTNESS_SETTING 39 /* 20 mA */ 64#define DEFAULT_BRIGHTNESS_SETTING 12
65 65
66/* Define this if you have a software controlled poweroff */ 66/* Define this if you have a software controlled poweroff */
67#define HAVE_SW_POWEROFF 67#define HAVE_SW_POWEROFF
diff --git a/firmware/export/mc13783.h b/firmware/export/mc13783.h
index c941100d1e..bb8787a9ec 100644
--- a/firmware/export/mc13783.h
+++ b/firmware/export/mc13783.h
@@ -254,13 +254,156 @@ enum mc13783_regs_enum
254/* CHARGER_USB1 */ 254/* CHARGER_USB1 */
255 255
256/* LED_CONTROL0 */ 256/* LED_CONTROL0 */
257#define MC13783_LEDEN (1 << 0) 257#define MC13783_LEDEN (0x1 << 0)
258#define MC13783_LEDMDRAMPUP (0x1 << 1)
259#define MC13783_LEDADRAMPUP (0x1 << 2)
260#define MC13783_LEDKDRAMPUP (0x1 << 3)
261#define MC13783_LEDMDRAMPDOWN (0x1 << 4)
262#define MC13783_LEDADRAMPDOWN (0x1 << 5)
263#define MC13783_LEDKDRAMPDOWN (0x1 << 6)
264#define MC13783_TRIODEMD (0x1 << 7)
265#define MC13783_TRIODEAD (0x1 << 8)
266#define MC13783_TRIODEKD (0x1 << 9)
267#define MC13783_BOOSTEN (0x1 << 10)
268#define MC13783_ABMODE (0x7 << 11)
269 #define MC13783_ABMODE_ADAPTIVE_BOOST_DISABLED (0x0 << 11)
270 #define MC13783_ABMODE_MONCH_LEDMD1 (0x1 << 11)
271 #define MC13783_ABMODE_MONCH_LEDMD12 (0x2 << 11)
272 #define MC13783_ABMODE_MONCH_LEDMD123 (0x3 << 11)
273 #define MC13783_ABMODE_MONCH_LEDMD1234 (0x4 << 11)
274 #define MC13783_ABMODE_MONCH_LEDMD1234_LEADAD1 (0x5 << 11)
275 #define MC13783_ABMODE_MONCH_LEDMD1234_LEADAD12 (0x6 << 11)
276 #define MC13783_ABMODE_MONCH_LEDMD1_LEDAD_ACT (0x7 << 11)
277#define MC13783_ABREF (0x3 << 14)
278 #define MC13783_ABREF_200MV (0x0 << 14)
279 #define MC13783_ABREF_400MV (0x1 << 14)
280 #define MC13783_ABREF_600MV (0x2 << 14)
281 #define MC13783_ABREF_800MV (0x3 << 14)
282#define MC13783_FLPATTRN (0xf << 17)
283 #define MC13783_FLPATTRNw(x) (((x) << 17) & MC13783_FLPATTRN)
284 #define MC13783_FLPATTRNr(x) (((x) & MC13783_FLPATTRN) >> 17)
285#define MC13783_FLBANK1 (0x1 << 21)
286#define MC13783_FLBANK2 (0x1 << 22)
287#define MC13783_FLBANK3 (0x1 << 23)
258 288
259/* LED_CONTROL1 */ 289/* LED_CONTROL1 */
290#define MC13783_LEDR1RAMPUP (0x1 << 0)
291#define MC13783_LEDG1RAMPUP (0x1 << 1)
292#define MC13783_LEDB1RAMPUP (0x1 << 2)
293#define MC13783_LEDR1RAMPDOWN (0x1 << 3)
294#define MC13783_LEDG1RAMPDOWN (0x1 << 4)
295#define MC13783_LEDB1RAMPDOWN (0x1 << 5)
296#define MC13783_LEDR2RAMPUP (0x1 << 6)
297#define MC13783_LEDG2RAMPUP (0x1 << 7)
298#define MC13783_LEDB2RAMPUP (0x1 << 8)
299#define MC13783_LEDR2RAMPDOWN (0x1 << 9)
300#define MC13783_LEDG2RAMPDOWN (0x1 << 10)
301#define MC13783_LEDB2RAMPDOWN (0x1 << 11)
302#define MC13783_LEDR3RAMPUP (0x1 << 12)
303#define MC13783_LEDG3RAMPUP (0x1 << 13)
304#define MC13783_LEDB3RAMPUP (0x1 << 14)
305#define MC13783_LEDR3RAMPDOWN (0x1 << 15)
306#define MC13783_LEDG3RAMPDOWN (0x1 << 16)
307#define MC13783_LEDB3RAMPDOWN (0x1 << 17)
308#define MC13783_TC1HALF (0x1 << 18)
309#define MC13783_SLEWLIMTC (0x1 << 23)
310
260/* LED_CONTROL2 */ 311/* LED_CONTROL2 */
312#define MC13783_LEDMD (0x7 << 0)
313 #define MC13783_LEDMDw(x) (((x) << 0) & MC13783_LEDMD)
314 #define MC13783_LEDMDr(x) (((x) & MC13783_LEDMD) >> 0)
315#define MC13783_LEDAD (0x7 << 3)
316 #define MC13783_LEDADw(x) (((x) << 3) & MC13783_LEDAD)
317 #define MC13783_LEDADr(x) (((x) & MC13783_LEDAD) >> 3)
318#define MC13783_LEDKP (0x7 << 6)
319 #define MC13783_LEDKPw(x) (((x) << 6) & MC13783_LEDKP)
320 #define MC13783_LEDKPr(x) (((x) & MC13783_LEDKP) >> 6)
321#define MC13783_LEDMDDC (0xf << 9)
322 #define MC13783_LEDMDDCw(x) (((x) << 9) & MC13783_LEDMDDC)
323 #define MC13783_LEDMDDCr(x) (((x) & MC13783_LEDMDDC) >> 9)
324#define MC13783_LEDADDC (0xf << 13)
325 #define MC13783_LEDADDCw(x) (((x) << 13) & MC13783_LEDADDC)
326 #define MC13783_LEDADDCr(x) (((x) & MC13783_LEDADDC) >> 13)
327#define MC13783_LEDKPDC (0xf << 17)
328 #define MC13783_LEDKPDCw(x) (((x) << 17) & MC13783_LEDKPDC)
329 #define MC13783_LEDKPDCr(x) (((x) & MC13783_LEDKPDC) >> 17)
330#define MC13783_BLPERIOD (0x1 << 21)
331 #define MC13783_BLPERIODw(x) (((x) << 21) & MC13783_BLPERIOD)
332 #define MC13783_BLPERIODr(x) (((x) & MC13783_BLPERIOD) >> 21)
333#define MC13783_SLEWLIMBL (0x1 << 23)
334
261/* LED_CONTROL3 */ 335/* LED_CONTROL3 */
336#define MC13783_LEDR1 (0x3 << 0)
337 #define MC13783_LEDR1w(x) (((x) << 0) & MC13783_LEDR1)
338 #define MC13783_LEDR1r(x) (((x) & MC13783_LEDR1) >> 0)
339#define MC13783_LEDG1 (0x3 << 2)
340 #define MC13783_LEDG1w(x) (((x) << 2) & MC13783_LEDG1)
341 #define MC13783_LEDG1r(x) (((x) & MC13783_LEDG1) >> 2)
342#define MC13783_LEDB1 (0x3 << 4)
343 #define MC13783_LEDB1w(x) (((x) << 4) & MC13783_LEDB1)
344 #define MC13783_LEDB1r(x) (((x) & MC13783_LEDB1) >> 4)
345#define MC13783_LEDR1DC (0x1f << 6)
346 #define MC13783_LEDR1DCw(x) (((x) << 6) & MC13783_LEDR1DC)
347 #define MC13783_LEDR1DCr(x) (((x) & MC13783_LEDR1DC) >> 6)
348#define MC13783_LEDG1DC (0x1f << 11)
349 #define MC13783_LEDG1DCw(x) (((x) << 11) & MC13783_LEDG1DC)
350 #define MC13783_LEDG1DCr(x) (((x) & MC13783_LEDG1DC) >> 11)
351#define MC13783_LEDB1DC (0x1f << 16)
352 #define MC13783_LEDB1DCw(x) (((x) << 16) & MC13783_LEDB1DC)
353 #define MC13783_LEDB1DCr(x) (((x) & MC13783_LEDB1DC) >> 16)
354#define MC13783_TC1PERIOD (0x3 << 21)
355 #define MC13783_TC1PERIODw(x) (((x) << 21) & MC13783_TC1PERIOD)
356 #define MC13783_TC1PERIODr(x) (((x) & MC13783_TC1PERIOD) >> 21)
357#define MC13783_TC1TRIODE (0x1 << 23)
358
262/* LED_CONTROL4 */ 359/* LED_CONTROL4 */
360#define MC13783_LEDR2 (0x3 << 0)
361 #define MC13783_LEDR2w(x) (((x) << 0) & MC13783_LEDR2)
362 #define MC13783_LEDR2r(x) (((x) & MC13783_LEDR2) >> 0)
363#define MC13783_LEDG2 (0x3 << 2)
364 #define MC13783_LEDG2w(x) (((x) << 2) & MC13783_LEDG2)
365 #define MC13783_LEDG2r(x) (((x) & MC13783_LEDG2) >> 2)
366#define MC13783_LEDB2 (0x3 << 4)
367 #define MC13783_LEDB2w(x) (((x) << 4) & MC13783_LEDB2)
368 #define MC13783_LEDB2r(x) (((x) & MC13783_LEDB2) >> 4)
369#define MC13783_LEDR2DC (0x1f << 6)
370 #define MC13783_LEDR2DCw(x) (((x) << 6) & MC13783_LEDR2DC)
371 #define MC13783_LEDR2DCr(x) (((x) & MC13783_LEDR2DC) >> 6)
372#define MC13783_LEDG2DC (0x1f << 11)
373 #define MC13783_LEDG2DCw(x) (((x) << 11) & MC13783_LEDG2DC)
374 #define MC13783_LEDG2DCr(x) (((x) & MC13783_LEDG2DC) >> 11)
375#define MC13783_LEDB2DC (0x1f << 16)
376 #define MC13783_LEDB2DCw(x) (((x) << 16) & MC13783_LEDB2DC)
377 #define MC13783_LEDB2DCr(x) (((x) & MC13783_LEDB2DC) >> 16)
378#define MC13783_TC2PERIOD (0x3 << 21)
379 #define MC13783_TC2PERIODw(x) (((x) << 21) & MC13783_TC2PERIOD)
380 #define MC13783_TC2PERIODr(x) (((x) & MC13783_TC2PERIOD) >> 21)
381#define MC13783_TC2TRIODE (0x1 << 23)
382
263/* LED_CONTROL5 */ 383/* LED_CONTROL5 */
384#define MC13783_LEDR3 (0x3 << 0)
385 #define MC13783_LEDR3w(x) (((x) << 0) & MC13783_LEDR3)
386 #define MC13783_LEDR3r(x) (((x) & MC13783_LEDR3) >> 0)
387#define MC13783_LEDG3 (0x3 << 2)
388 #define MC13783_LEDG3w(x) (((x) << 2) & MC13783_LEDG3)
389 #define MC13783_LEDG3r(x) (((x) & MC13783_LEDG3) >> 2)
390#define MC13783_LEDB3 (0x3 << 4)
391 #define MC13783_LEDB3w(x) (((x) << 4) & MC13783_LEDB3)
392 #define MC13783_LEDB3r(x) (((x) & MC13783_LEDB3) >> 4)
393#define MC13783_LEDR3DC (0x1f << 6)
394 #define MC13783_LEDR3DCw(x) (((x) << 6) & MC13783_LEDR3DC)
395 #define MC13783_LEDR3DCr(x) (((x) & MC13783_LEDR3DC) >> 6)
396#define MC13783_LEDG3DC (0x1f << 11)
397 #define MC13783_LEDG3DCw(x) (((x) << 11) & MC13783_LEDG3DC)
398 #define MC13783_LEDG3DCr(x) (((x) & MC13783_LEDG3DC) >> 11)
399#define MC13783_LEDB3DC (0x1f << 16)
400 #define MC13783_LEDB3DCw(x) (((x) << 16) & MC13783_LEDB3DC)
401 #define MC13783_LEDB3DCr(x) (((x) & MC13783_LEDB3DC) >> 16)
402#define MC13783_TC3PERIOD (0x3 << 21)
403 #define MC13783_TC3PERIODw(x) (((x) << 21) & MC13783_TC3PERIOD)
404 #define MC13783_TC3PERIODr(x) (((x) & MC13783_TC3PERIOD) >> 21)
405#define MC13783_TC3TRIODE (0x1 << 23)
406
264/* TRIM0 */ 407/* TRIM0 */
265/* TRIM1 */ 408/* TRIM1 */
266/* TEST0 */ 409/* TEST0 */
@@ -272,6 +415,7 @@ void mc13783_init(void);
272uint32_t mc13783_set(unsigned address, uint32_t bits); 415uint32_t mc13783_set(unsigned address, uint32_t bits);
273uint32_t mc13783_clear(unsigned address, uint32_t bits); 416uint32_t mc13783_clear(unsigned address, uint32_t bits);
274int mc13783_write(unsigned address, uint32_t data); 417int mc13783_write(unsigned address, uint32_t data);
418uint32_t mc13783_write_masked(unsigned address, uint32_t data, uint32_t mask);
275int mc13783_write_multiple(unsigned start, const uint32_t *buffer, int count); 419int mc13783_write_multiple(unsigned start, const uint32_t *buffer, int count);
276int mc13783_write_regset(const unsigned char *regs, const uint32_t *data, int count); 420int mc13783_write_regset(const unsigned char *regs, const uint32_t *data, int count);
277uint32_t mc13783_read(unsigned address); 421uint32_t mc13783_read(unsigned address);
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. */
29static 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
29bool _backlight_init(void) 64bool _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 */
47void _backlight_set_brightness(int brightness) 89void _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}