summaryrefslogtreecommitdiff
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.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 @@
115 115
116/* Define this for LCD backlight available */ 116/* Define this for LCD backlight available */
117#define HAVE_BACKLIGHT 117#define HAVE_BACKLIGHT
118#define HAVE_BACKLIGHT_BRIGHTNESS
119
120/* Main LCD backlight brightness range and defaults */
121#define MIN_BRIGHTNESS_SETTING 1
122#define MAX_BRIGHTNESS_SETTING 31
123#define DEFAULT_BRIGHTNESS_SETTING 20
118 124
119/* define this if the unit uses a scrollwheel for navigation */ 125/* define this if the unit uses a scrollwheel for navigation */
120#define HAVE_SCROLLWHEEL 126#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 @@
99 99
100/* Define this for LCD backlight available */ 100/* Define this for LCD backlight available */
101#define HAVE_BACKLIGHT 101#define HAVE_BACKLIGHT
102#define HAVE_BACKLIGHT_BRIGHTNESS
103
104/* Main LCD backlight brightness range and defaults */
105#define MIN_BRIGHTNESS_SETTING 1
106#define MAX_BRIGHTNESS_SETTING 31
107#define DEFAULT_BRIGHTNESS_SETTING 20
102 108
103/* define this if the unit uses a scrollwheel for navigation */ 109/* define this if the unit uses a scrollwheel for navigation */
104#define HAVE_SCROLLWHEEL 110#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 @@
34#include "backlight.h" 34#include "backlight.h"
35#include "backlight-target.h" 35#include "backlight-target.h"
36 36
37/* Index 0 is a dummy, 1..31 are used */
38static unsigned char log_brightness[32] = {
39 0, 1, 2, 4, 6, 9, 12, 16, 20, 25, 30, 36,
40 42, 49, 56, 64, 72, 81, 90, 100, 110, 121, 132, 144,
41 156, 169, 182, 196, 210, 225, 240, 255
42};
43
44static unsigned brightness = 100; /* 1 to 255 */
45static bool enabled = false;
46
47/* Handling B03 in _backlight_on() and _backlight_off() makes backlight go off
48 * without delay. Not doing that does a short (fixed) fade out. Opt for the
49 * latter. */
50
37void _backlight_on(void) 51void _backlight_on(void)
38{ 52{
39 /* brightness full */ 53 /* brightness full */
40 outl(0x80000000 | (0xff << 16), 0x7000a010); 54 outl(0x80000000 | (brightness << 16), 0x7000a010);
41 55 /* GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08); */
42 /* set port b bit 3 on */ 56 enabled = true;
43 GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08);
44} 57}
45 58
46void _backlight_off(void) 59void _backlight_off(void)
47{ 60{
48 /* fades backlight off on 4g */
49 GPO32_ENABLE &= ~0x2000000;
50 outl(0x80000000, 0x7000a010); 61 outl(0x80000000, 0x7000a010);
62 /* GPIO_CLEAR_BITWISE(GPIOB_OUTPUT_VAL, 0x08); */
63 enabled = false;
64}
65
66void _backlight_set_brightness(int val)
67{
68 brightness = log_brightness[val];
69 if (enabled)
70 outl(0x80000000 | (brightness << 16), 0x7000a010);
51} 71}
52 72
53bool _backlight_init(void) 73bool _backlight_init(void)
54{ 74{
55 GPIOB_ENABLE |= 0x4; /* B02 enable */ 75 GPIO_SET_BITWISE(GPIOB_ENABLE, 0x0c); /* B02 and B03 enable */
56 GPIOB_ENABLE |= 0x8; /* B03 enable */ 76 GPIO_SET_BITWISE(GPIOB_OUTPUT_VAL, 0x08); /* B03 = 1 */
57 GPO32_ENABLE |= 0x2000000; /* D01 enable */ 77 GPO32_ENABLE &= ~0x2000000; /* D01 disable, so pwm takes over */
58 GPO32_VAL |= 0x2000000; /* D01 =1 */
59 DEV_EN |= DEV_PWM; /* PWM enable */ 78 DEV_EN |= DEV_PWM; /* PWM enable */
60 79
61 _backlight_on(); 80 _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);
53bool _backlight_init(void); 53bool _backlight_init(void);
54void _backlight_on(void); 54void _backlight_on(void);
55void _backlight_off(void); 55void _backlight_off(void);
56void _backlight_set_brightness(int val);
56 57
57#elif defined(IPOD_MINI) || defined(IPOD_MINI2G) 58#elif defined(IPOD_MINI) || defined(IPOD_MINI2G)
58 59