summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2010-06-05 11:48:12 +0000
committerJens Arnold <amiconn@rockbox.org>2010-06-05 11:48:12 +0000
commit57dcfe0eee31364771d71fe32395058de3af3fa6 (patch)
tree3240263d08ffce6f7596ab2f1c029007cee30454
parent8598a2c82168ca60937b4a7ec370b56ecfc2a57f (diff)
downloadrockbox-57dcfe0eee31364771d71fe32395058de3af3fa6.tar.gz
rockbox-57dcfe0eee31364771d71fe32395058de3af3fa6.tar.bz2
rockbox-57dcfe0eee31364771d71fe32395058de3af3fa6.zip
Implement backlight brightness for iPod G4 greyscale and iPod Color/Photo.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26573 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/config/ipod4g.h6
-rw-r--r--firmware/export/config/ipodcolor.h6
-rw-r--r--firmware/target/arm/ipod/backlight-4g_color.c39
-rw-r--r--firmware/target/arm/ipod/backlight-target.h1
4 files changed, 42 insertions, 10 deletions
diff --git a/firmware/export/config/ipod4g.h b/firmware/export/config/ipod4g.h
index 61f12389d8..b9251e72fe 100644
--- a/firmware/export/config/ipod4g.h
+++ b/firmware/export/config/ipod4g.h
@@ -115,6 +115,12 @@
/* Define this for LCD backlight available */
#define HAVE_BACKLIGHT
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
+/* Main LCD backlight brightness range and defaults */
+#define MIN_BRIGHTNESS_SETTING 1
+#define MAX_BRIGHTNESS_SETTING 31
+#define DEFAULT_BRIGHTNESS_SETTING 20
/* define this if the unit uses a scrollwheel for navigation */
#define HAVE_SCROLLWHEEL
diff --git a/firmware/export/config/ipodcolor.h b/firmware/export/config/ipodcolor.h
index ba546e85cb..5448cb76b7 100644
--- a/firmware/export/config/ipodcolor.h
+++ b/firmware/export/config/ipodcolor.h
@@ -99,6 +99,12 @@
/* Define this for LCD backlight available */
#define HAVE_BACKLIGHT
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
+/* Main LCD backlight brightness range and defaults */
+#define MIN_BRIGHTNESS_SETTING 1
+#define MAX_BRIGHTNESS_SETTING 31
+#define DEFAULT_BRIGHTNESS_SETTING 20
/* define this if the unit uses a scrollwheel for navigation */
#define HAVE_SCROLLWHEEL
diff --git a/firmware/target/arm/ipod/backlight-4g_color.c b/firmware/target/arm/ipod/backlight-4g_color.c
index 656bef0e17..a0e14c99e3 100644
--- a/firmware/target/arm/ipod/backlight-4g_color.c
+++ b/firmware/target/arm/ipod/backlight-4g_color.c
@@ -34,28 +34,47 @@
#include "backlight.h"
#include "backlight-target.h"
+/* Index 0 is a dummy, 1..31 are used */
+static unsigned char log_brightness[32] = {
+ 0, 1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 36,
+ 42, 49, 56, 64, 72, 81, 90, 100, 110, 121, 132, 144,
+ 156, 169, 182, 196, 210, 225, 240, 255
+};
+
+static unsigned brightness = 100; /* 1 to 255 */
+static bool enabled = false;
+
+/* Handling B03 in _backlight_on() and _backlight_off() makes backlight go off
+ * without delay. Not doing that does a short (fixed) fade out. Opt for the
+ * latter. */
+
void _backlight_on(void)
{
/* brightness full */
- outl(0x80000000 | (0xff << 16), 0x7000a010);
-
- /* set port b bit 3 on */
- GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08);
+ outl(0x80000000 | (brightness << 16), 0x7000a010);
+ /* GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08); */
+ enabled = true;
}
void _backlight_off(void)
{
- /* fades backlight off on 4g */
- GPO32_ENABLE &= ~0x2000000;
outl(0x80000000, 0x7000a010);
+ /* GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x08); */
+ enabled = false;
+}
+
+void _backlight_set_brightness(int val)
+{
+ brightness = log_brightness[val];
+ if (enabled)
+ outl(0x80000000 | (brightness << 16), 0x7000a010);
}
bool _backlight_init(void)
{
- GPIOB_ENABLE |= 0x4; /* B02 enable */
- GPIOB_ENABLE |= 0x8; /* B03 enable */
- GPO32_ENABLE |= 0x2000000; /* D01 enable */
- GPO32_VAL |= 0x2000000; /* D01 =1 */
+ GPIO_SET_BITWISE(GPIOB_ENABLE, 0x0c); /* B02 and B03 enable */
+ GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08); /* B03 = 1 */
+ GPO32_ENABLE &= ~0x2000000; /* D01 disable, so pwm takes over */
DEV_EN |= DEV_PWM; /* PWM enable */
_backlight_on();
diff --git a/firmware/target/arm/ipod/backlight-target.h b/firmware/target/arm/ipod/backlight-target.h
index 28c519e4c0..9b6a96b3cb 100644
--- a/firmware/target/arm/ipod/backlight-target.h
+++ b/firmware/target/arm/ipod/backlight-target.h
@@ -53,6 +53,7 @@ void lcd_awake(void);
bool _backlight_init(void);
void _backlight_on(void);
void _backlight_off(void);
+void _backlight_set_brightness(int val);
#elif defined(IPOD_MINI) || defined(IPOD_MINI2G)