summaryrefslogtreecommitdiffstats
path: root/firmware/target
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 /firmware/target
parent8598a2c82168ca60937b4a7ec370b56ecfc2a57f (diff)
downloadrockbox-57dcfe0eee31364771d71fe32395058de3af3fa6.tar.gz
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
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/arm/ipod/backlight-4g_color.c39
-rw-r--r--firmware/target/arm/ipod/backlight-target.h1
2 files changed, 30 insertions, 10 deletions
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)