summaryrefslogtreecommitdiffstats
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 @@
#define HAVE_LCD_ENABLE
-//#define HAVE_BACKLIGHT_BRIGHTNESS
+#define HAVE_BACKLIGHT_BRIGHTNESS
/* Main LCD backlight brightness range and defaults */
-#define MIN_BRIGHTNESS_SETTING 0 /* 0.5 mA */
-#define MAX_BRIGHTNESS_SETTING 63 /* 32 mA */
-#define DEFAULT_BRIGHTNESS_SETTING 39 /* 20 mA */
+#define MIN_BRIGHTNESS_SETTING 0
+#define MAX_BRIGHTNESS_SETTING 24
+#define DEFAULT_BRIGHTNESS_SETTING 12
/* Define this if you have a software controlled poweroff */
#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
/* CHARGER_USB1 */
/* LED_CONTROL0 */
-#define MC13783_LEDEN (1 << 0)
+#define MC13783_LEDEN (0x1 << 0)
+#define MC13783_LEDMDRAMPUP (0x1 << 1)
+#define MC13783_LEDADRAMPUP (0x1 << 2)
+#define MC13783_LEDKDRAMPUP (0x1 << 3)
+#define MC13783_LEDMDRAMPDOWN (0x1 << 4)
+#define MC13783_LEDADRAMPDOWN (0x1 << 5)
+#define MC13783_LEDKDRAMPDOWN (0x1 << 6)
+#define MC13783_TRIODEMD (0x1 << 7)
+#define MC13783_TRIODEAD (0x1 << 8)
+#define MC13783_TRIODEKD (0x1 << 9)
+#define MC13783_BOOSTEN (0x1 << 10)
+#define MC13783_ABMODE (0x7 << 11)
+ #define MC13783_ABMODE_ADAPTIVE_BOOST_DISABLED (0x0 << 11)
+ #define MC13783_ABMODE_MONCH_LEDMD1 (0x1 << 11)
+ #define MC13783_ABMODE_MONCH_LEDMD12 (0x2 << 11)
+ #define MC13783_ABMODE_MONCH_LEDMD123 (0x3 << 11)
+ #define MC13783_ABMODE_MONCH_LEDMD1234 (0x4 << 11)
+ #define MC13783_ABMODE_MONCH_LEDMD1234_LEADAD1 (0x5 << 11)
+ #define MC13783_ABMODE_MONCH_LEDMD1234_LEADAD12 (0x6 << 11)
+ #define MC13783_ABMODE_MONCH_LEDMD1_LEDAD_ACT (0x7 << 11)
+#define MC13783_ABREF (0x3 << 14)
+ #define MC13783_ABREF_200MV (0x0 << 14)
+ #define MC13783_ABREF_400MV (0x1 << 14)
+ #define MC13783_ABREF_600MV (0x2 << 14)
+ #define MC13783_ABREF_800MV (0x3 << 14)
+#define MC13783_FLPATTRN (0xf << 17)
+ #define MC13783_FLPATTRNw(x) (((x) << 17) & MC13783_FLPATTRN)
+ #define MC13783_FLPATTRNr(x) (((x) & MC13783_FLPATTRN) >> 17)
+#define MC13783_FLBANK1 (0x1 << 21)
+#define MC13783_FLBANK2 (0x1 << 22)
+#define MC13783_FLBANK3 (0x1 << 23)
/* LED_CONTROL1 */
+#define MC13783_LEDR1RAMPUP (0x1 << 0)
+#define MC13783_LEDG1RAMPUP (0x1 << 1)
+#define MC13783_LEDB1RAMPUP (0x1 << 2)
+#define MC13783_LEDR1RAMPDOWN (0x1 << 3)
+#define MC13783_LEDG1RAMPDOWN (0x1 << 4)
+#define MC13783_LEDB1RAMPDOWN (0x1 << 5)
+#define MC13783_LEDR2RAMPUP (0x1 << 6)
+#define MC13783_LEDG2RAMPUP (0x1 << 7)
+#define MC13783_LEDB2RAMPUP (0x1 << 8)
+#define MC13783_LEDR2RAMPDOWN (0x1 << 9)
+#define MC13783_LEDG2RAMPDOWN (0x1 << 10)
+#define MC13783_LEDB2RAMPDOWN (0x1 << 11)
+#define MC13783_LEDR3RAMPUP (0x1 << 12)
+#define MC13783_LEDG3RAMPUP (0x1 << 13)
+#define MC13783_LEDB3RAMPUP (0x1 << 14)
+#define MC13783_LEDR3RAMPDOWN (0x1 << 15)
+#define MC13783_LEDG3RAMPDOWN (0x1 << 16)
+#define MC13783_LEDB3RAMPDOWN (0x1 << 17)
+#define MC13783_TC1HALF (0x1 << 18)
+#define MC13783_SLEWLIMTC (0x1 << 23)
+
/* LED_CONTROL2 */
+#define MC13783_LEDMD (0x7 << 0)
+ #define MC13783_LEDMDw(x) (((x) << 0) & MC13783_LEDMD)
+ #define MC13783_LEDMDr(x) (((x) & MC13783_LEDMD) >> 0)
+#define MC13783_LEDAD (0x7 << 3)
+ #define MC13783_LEDADw(x) (((x) << 3) & MC13783_LEDAD)
+ #define MC13783_LEDADr(x) (((x) & MC13783_LEDAD) >> 3)
+#define MC13783_LEDKP (0x7 << 6)
+ #define MC13783_LEDKPw(x) (((x) << 6) & MC13783_LEDKP)
+ #define MC13783_LEDKPr(x) (((x) & MC13783_LEDKP) >> 6)
+#define MC13783_LEDMDDC (0xf << 9)
+ #define MC13783_LEDMDDCw(x) (((x) << 9) & MC13783_LEDMDDC)
+ #define MC13783_LEDMDDCr(x) (((x) & MC13783_LEDMDDC) >> 9)
+#define MC13783_LEDADDC (0xf << 13)
+ #define MC13783_LEDADDCw(x) (((x) << 13) & MC13783_LEDADDC)
+ #define MC13783_LEDADDCr(x) (((x) & MC13783_LEDADDC) >> 13)
+#define MC13783_LEDKPDC (0xf << 17)
+ #define MC13783_LEDKPDCw(x) (((x) << 17) & MC13783_LEDKPDC)
+ #define MC13783_LEDKPDCr(x) (((x) & MC13783_LEDKPDC) >> 17)
+#define MC13783_BLPERIOD (0x1 << 21)
+ #define MC13783_BLPERIODw(x) (((x) << 21) & MC13783_BLPERIOD)
+ #define MC13783_BLPERIODr(x) (((x) & MC13783_BLPERIOD) >> 21)
+#define MC13783_SLEWLIMBL (0x1 << 23)
+
/* LED_CONTROL3 */
+#define MC13783_LEDR1 (0x3 << 0)
+ #define MC13783_LEDR1w(x) (((x) << 0) & MC13783_LEDR1)
+ #define MC13783_LEDR1r(x) (((x) & MC13783_LEDR1) >> 0)
+#define MC13783_LEDG1 (0x3 << 2)
+ #define MC13783_LEDG1w(x) (((x) << 2) & MC13783_LEDG1)
+ #define MC13783_LEDG1r(x) (((x) & MC13783_LEDG1) >> 2)
+#define MC13783_LEDB1 (0x3 << 4)
+ #define MC13783_LEDB1w(x) (((x) << 4) & MC13783_LEDB1)
+ #define MC13783_LEDB1r(x) (((x) & MC13783_LEDB1) >> 4)
+#define MC13783_LEDR1DC (0x1f << 6)
+ #define MC13783_LEDR1DCw(x) (((x) << 6) & MC13783_LEDR1DC)
+ #define MC13783_LEDR1DCr(x) (((x) & MC13783_LEDR1DC) >> 6)
+#define MC13783_LEDG1DC (0x1f << 11)
+ #define MC13783_LEDG1DCw(x) (((x) << 11) & MC13783_LEDG1DC)
+ #define MC13783_LEDG1DCr(x) (((x) & MC13783_LEDG1DC) >> 11)
+#define MC13783_LEDB1DC (0x1f << 16)
+ #define MC13783_LEDB1DCw(x) (((x) << 16) & MC13783_LEDB1DC)
+ #define MC13783_LEDB1DCr(x) (((x) & MC13783_LEDB1DC) >> 16)
+#define MC13783_TC1PERIOD (0x3 << 21)
+ #define MC13783_TC1PERIODw(x) (((x) << 21) & MC13783_TC1PERIOD)
+ #define MC13783_TC1PERIODr(x) (((x) & MC13783_TC1PERIOD) >> 21)
+#define MC13783_TC1TRIODE (0x1 << 23)
+
/* LED_CONTROL4 */
+#define MC13783_LEDR2 (0x3 << 0)
+ #define MC13783_LEDR2w(x) (((x) << 0) & MC13783_LEDR2)
+ #define MC13783_LEDR2r(x) (((x) & MC13783_LEDR2) >> 0)
+#define MC13783_LEDG2 (0x3 << 2)
+ #define MC13783_LEDG2w(x) (((x) << 2) & MC13783_LEDG2)
+ #define MC13783_LEDG2r(x) (((x) & MC13783_LEDG2) >> 2)
+#define MC13783_LEDB2 (0x3 << 4)
+ #define MC13783_LEDB2w(x) (((x) << 4) & MC13783_LEDB2)
+ #define MC13783_LEDB2r(x) (((x) & MC13783_LEDB2) >> 4)
+#define MC13783_LEDR2DC (0x1f << 6)
+ #define MC13783_LEDR2DCw(x) (((x) << 6) & MC13783_LEDR2DC)
+ #define MC13783_LEDR2DCr(x) (((x) & MC13783_LEDR2DC) >> 6)
+#define MC13783_LEDG2DC (0x1f << 11)
+ #define MC13783_LEDG2DCw(x) (((x) << 11) & MC13783_LEDG2DC)
+ #define MC13783_LEDG2DCr(x) (((x) & MC13783_LEDG2DC) >> 11)
+#define MC13783_LEDB2DC (0x1f << 16)
+ #define MC13783_LEDB2DCw(x) (((x) << 16) & MC13783_LEDB2DC)
+ #define MC13783_LEDB2DCr(x) (((x) & MC13783_LEDB2DC) >> 16)
+#define MC13783_TC2PERIOD (0x3 << 21)
+ #define MC13783_TC2PERIODw(x) (((x) << 21) & MC13783_TC2PERIOD)
+ #define MC13783_TC2PERIODr(x) (((x) & MC13783_TC2PERIOD) >> 21)
+#define MC13783_TC2TRIODE (0x1 << 23)
+
/* LED_CONTROL5 */
+#define MC13783_LEDR3 (0x3 << 0)
+ #define MC13783_LEDR3w(x) (((x) << 0) & MC13783_LEDR3)
+ #define MC13783_LEDR3r(x) (((x) & MC13783_LEDR3) >> 0)
+#define MC13783_LEDG3 (0x3 << 2)
+ #define MC13783_LEDG3w(x) (((x) << 2) & MC13783_LEDG3)
+ #define MC13783_LEDG3r(x) (((x) & MC13783_LEDG3) >> 2)
+#define MC13783_LEDB3 (0x3 << 4)
+ #define MC13783_LEDB3w(x) (((x) << 4) & MC13783_LEDB3)
+ #define MC13783_LEDB3r(x) (((x) & MC13783_LEDB3) >> 4)
+#define MC13783_LEDR3DC (0x1f << 6)
+ #define MC13783_LEDR3DCw(x) (((x) << 6) & MC13783_LEDR3DC)
+ #define MC13783_LEDR3DCr(x) (((x) & MC13783_LEDR3DC) >> 6)
+#define MC13783_LEDG3DC (0x1f << 11)
+ #define MC13783_LEDG3DCw(x) (((x) << 11) & MC13783_LEDG3DC)
+ #define MC13783_LEDG3DCr(x) (((x) & MC13783_LEDG3DC) >> 11)
+#define MC13783_LEDB3DC (0x1f << 16)
+ #define MC13783_LEDB3DCw(x) (((x) << 16) & MC13783_LEDB3DC)
+ #define MC13783_LEDB3DCr(x) (((x) & MC13783_LEDB3DC) >> 16)
+#define MC13783_TC3PERIOD (0x3 << 21)
+ #define MC13783_TC3PERIODw(x) (((x) << 21) & MC13783_TC3PERIOD)
+ #define MC13783_TC3PERIODr(x) (((x) & MC13783_TC3PERIOD) >> 21)
+#define MC13783_TC3TRIODE (0x1 << 23)
+
/* TRIM0 */
/* TRIM1 */
/* TEST0 */
@@ -272,6 +415,7 @@ void mc13783_init(void);
uint32_t mc13783_set(unsigned address, uint32_t bits);
uint32_t mc13783_clear(unsigned address, uint32_t bits);
int mc13783_write(unsigned address, uint32_t data);
+uint32_t mc13783_write_masked(unsigned address, uint32_t data, uint32_t mask);
int mc13783_write_multiple(unsigned start, const uint32_t *buffer, int count);
int mc13783_write_regset(const unsigned char *regs, const uint32_t *data, int count);
uint32_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 @@
*
****************************************************************************/
#include "config.h"
-#include "cpu.h"
#include "system.h"
-#include "backlight-target.h"
#include "backlight.h"
-#include "lcd.h"
-#include "power.h"
#include "mc13783.h"
-#include "debug.h"
+#include "backlight-target.h"
+
+/* Table that uses combinations of current level and pwm fraction to get
+ * as many uniquely-visible brightness levels as possible. The lowest current
+ * level for any average current is used even though many combinations give
+ * duplicate values. Current (I) values are in mA. */
+static const struct
+{
+ unsigned char md;
+ unsigned char pwm;
+} led_md_pwm_table[] =
+{
+ /* I-level PWM(x/15) I-Avg */
+ { 0, 0 }, /* 0 0 0.0 */
+ { 1, 1 }, /* 3 1 0.2 */
+ { 1, 2 }, /* 3 2 0.4 */
+ { 1, 3 }, /* 3 3 0.6 */
+ { 1, 4 }, /* 3 4 0.8 */
+ { 1, 5 }, /* 3 5 1.0 */
+ { 1, 6 }, /* 3 6 1.2 */
+ { 1, 7 }, /* 3 7 1.4 */
+ { 1, 8 }, /* 3 8 1.6 */
+ { 1, 9 }, /* 3 9 1.8 */
+ { 1, 10 }, /* 3 10 2.0 */
+ { 1, 11 }, /* 3 11 2.2 */
+ { 1, 12 }, /* 3 12 2.4 */ /* default */
+ { 1, 13 }, /* 3 13 2.6 */
+ { 1, 14 }, /* 3 14 2.8 */
+ { 1, 15 }, /* 3 15 3.0 */
+ { 2, 9 }, /* 6 9 3.6 */
+ { 2, 10 }, /* 6 10 4.0 */
+ { 2, 11 }, /* 6 11 4.4 */
+ { 2, 12 }, /* 6 12 4.8 */
+ { 2, 13 }, /* 6 13 5.2 */
+ { 2, 14 }, /* 6 14 5.6 */
+ { 2, 15 }, /* 6 15 6.0 */
+ { 3, 11 }, /* 9 11 6.6 */
+ { 3, 12 }, /* 9 12 7.2 */
+ /* Anything higher is just too much */
+};
bool _backlight_init(void)
{
+ mc13783_write(MC13783_LED_CONTROL0,
+ MC13783_LEDEN |
+ MC13783_LEDMDRAMPUP |
+ MC13783_LEDMDRAMPDOWN |
+ MC13783_BOOSTEN |
+ MC13783_ABMODE_MONCH_LEDMD1234 |
+ MC13783_ABREF_400MV);
return true;
}
@@ -46,6 +88,21 @@ void _backlight_off(void)
/* Assumes that the backlight has been initialized */
void _backlight_set_brightness(int brightness)
{
- (void)brightness;
-}
+ uint32_t data, md, pwm;
+ if ((unsigned)brightness >= ARRAYLEN(led_md_pwm_table))
+ brightness = DEFAULT_BRIGHTNESS_SETTING;
+
+ data = mc13783_read(MC13783_LED_CONTROL2);
+
+ if (data == (uint32_t)-1)
+ return;
+
+ md = led_md_pwm_table[brightness].md;
+ pwm = led_md_pwm_table[brightness].pwm;
+
+ data &= ~(MC13783_LEDMD | MC13783_LEDMDDC);
+ data |= MC13783_LEDMDw(md) | MC13783_LEDMDDCw(pwm);
+
+ mc13783_write(MC13783_LED_CONTROL2, data);
+}