summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/backlight.c197
-rw-r--r--firmware/export/backlight.h2
-rw-r--r--firmware/export/config-h100.h3
-rw-r--r--firmware/export/config-h120.h3
-rw-r--r--firmware/export/config-ipodnano.h3
-rw-r--r--firmware/export/config-ipodvideo.h3
6 files changed, 125 insertions, 86 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 9d48f0d660..9aace01b2e 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -41,6 +41,88 @@
41#include "lcd-remote.h" 41#include "lcd-remote.h"
42#endif 42#endif
43 43
44/* Basic low-level code that simply switches backlight on or off. Probably
45 * a nice candidate for inclusion in the target/ dir. */
46static inline void __backlight_on(void)
47{
48#ifdef SIMULATOR
49 sim_backlight(100);
50#elif CONFIG_BACKLIGHT == BL_IRIVER_H100
51 and_l(~0x00020000, &GPIO1_OUT);
52#elif CONFIG_BACKLIGHT == BL_IRIVER_H300
53 lcd_enable(true);
54 or_l(0x00020000, &GPIO1_OUT);
55#elif CONFIG_BACKLIGHT == BL_RTC
56 /* Enable square wave */
57 rtc_write(0x0a, rtc_read(0x0a) | 0x40);
58#elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */
59 and_b(~0x40, &PADRH); /* drive and set low */
60 or_b(0x40, &PAIORH);
61#elif CONFIG_BACKLIGHT == BL_PA14_HI /* Ondio */
62 or_b(0x40, &PADRH); /* drive it high */
63#elif CONFIG_BACKLIGHT == BL_GMINI
64 P1 |= 0x10;
65#elif CONFIG_BACKLIGHT == BL_IPOD4G
66 /* brightness full */
67 outl(0x80000000 | (0xff << 16), 0x7000a010);
68
69 /* set port b bit 3 on */
70 outl(((0x100 | 1) << 3), 0x6000d824);
71#elif CONFIG_BACKLIGHT==BL_IPODMINI
72 /* set port B03 on */
73 outl(((0x100 | 1) << 3), 0x6000d824);
74#elif CONFIG_BACKLIGHT==BL_IPODNANO
75 /* set port B03 on */
76 outl(((0x100 | 1) << 3), 0x6000d824);
77
78 /* set port L07 on */
79 outl(((0x100 | 1) << 7), 0x6000d12c);
80#elif CONFIG_BACKLIGHT==BL_IPOD3G
81 lcd_enable(true);
82#elif CONFIG_BACKLIGHT==BL_IRIVER_IFP7XX
83 GPIO3_SET = 1;
84#endif
85}
86
87static inline void __backlight_off(void)
88{
89#ifdef SIMULATOR
90 sim_backlight(0);
91#elif CONFIG_BACKLIGHT == BL_IRIVER_H100
92 or_l(0x00020000, &GPIO1_OUT);
93#elif CONFIG_BACKLIGHT == BL_IRIVER_H300
94 and_l(~0x00020000, &GPIO1_OUT);
95 lcd_enable(false);
96#elif CONFIG_BACKLIGHT == BL_RTC
97 /* Disable square wave */
98 rtc_write(0x0a, rtc_read(0x0a) & ~0x40);
99#elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */
100 and_b(~0x40, &PAIORH); /* let it float (up) */
101#elif CONFIG_BACKLIGHT == BL_PA14_HI /* Ondio */
102 and_b(~0x40, &PADRH); /* drive it low */
103#elif CONFIG_BACKLIGHT == BL_GMINI
104 P1 &= ~0x10;
105#elif CONFIG_BACKLIGHT == BL_IPOD4G
106 /* fades backlight off on 4g */
107 outl(inl(0x70000084) & ~0x2000000, 0x70000084);
108 outl(0x80000000, 0x7000a010);
109#elif CONFIG_BACKLIGHT==BL_IPODNANO
110 /* set port B03 off */
111 outl(((0x100 | 0) << 3), 0x6000d824);
112
113 /* set port L07 off */
114 outl(((0x100 | 0) << 7), 0x6000d12c);
115#elif CONFIG_BACKLIGHT==BL_IRIVER_IFP7XX
116 GPIO3_CLR = 1;
117#elif CONFIG_BACKLIGHT==BL_IPOD3G
118 lcd_enable(false);
119#elif CONFIG_BACKLIGHT==BL_IPODMINI
120 /* set port B03 off */
121 outl(((0x100 | 0) << 3), 0x6000d824);
122#endif
123}
124
125
44#if defined(CONFIG_BACKLIGHT) && !defined(BOOTLOADER) 126#if defined(CONFIG_BACKLIGHT) && !defined(BOOTLOADER)
45 127
46const char backlight_timeout_value[19] = 128const char backlight_timeout_value[19] =
@@ -73,7 +155,7 @@ static int remote_backlight_timeout_plugged = 5*HZ;
73#endif 155#endif
74#endif 156#endif
75 157
76#if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR) 158#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
77/* backlight fading */ 159/* backlight fading */
78#define BL_PWM_INTERVAL 5000 /* Cycle interval in µs */ 160#define BL_PWM_INTERVAL 5000 /* Cycle interval in µs */
79#define BL_PWM_COUNT 100 161#define BL_PWM_COUNT 100
@@ -93,7 +175,7 @@ static void backlight_isr(void)
93 int timer_period; 175 int timer_period;
94 bool idle = false; 176 bool idle = false;
95 177
96 timer_period = CPU_FREQ / 1000 * BL_PWM_INTERVAL / 1000; 178 timer_period = TIMER_FREQ / 1000 * BL_PWM_INTERVAL / 1000;
97 switch (bl_dim_state) 179 switch (bl_dim_state)
98 { 180 {
99 /* New cycle */ 181 /* New cycle */
@@ -103,7 +185,7 @@ static void backlight_isr(void)
103 185
104 if (bl_dim_current > 0 && bl_dim_current < BL_PWM_COUNT) 186 if (bl_dim_current > 0 && bl_dim_current < BL_PWM_COUNT)
105 { 187 {
106 and_l(~0x00020000, &GPIO1_OUT); 188 __backlight_on();
107 bl_pwm_counter = bl_dim_current; 189 bl_pwm_counter = bl_dim_current;
108 timer_period = timer_period * bl_pwm_counter / BL_PWM_COUNT; 190 timer_period = timer_period * bl_pwm_counter / BL_PWM_COUNT;
109 bl_dim_state = DIM_STATE_MAIN; 191 bl_dim_state = DIM_STATE_MAIN;
@@ -111,10 +193,9 @@ static void backlight_isr(void)
111 else 193 else
112 { 194 {
113 if (bl_dim_current) 195 if (bl_dim_current)
114 and_l(~0x00020000, &GPIO1_OUT); 196 __backlight_on();
115 else 197 else
116 or_l(0x00020000, &GPIO1_OUT); 198 __backlight_off();
117
118 if (bl_dim_current == bl_dim_target) 199 if (bl_dim_current == bl_dim_target)
119 idle = true; 200 idle = true;
120 } 201 }
@@ -123,7 +204,7 @@ static void backlight_isr(void)
123 204
124 /* Dim main screen */ 205 /* Dim main screen */
125 case DIM_STATE_MAIN: 206 case DIM_STATE_MAIN:
126 or_l(0x00020000, &GPIO1_OUT); 207 __backlight_off();
127 bl_dim_state = DIM_STATE_START; 208 bl_dim_state = DIM_STATE_START;
128 timer_period = timer_period * (BL_PWM_COUNT - bl_pwm_counter) / BL_PWM_COUNT; 209 timer_period = timer_period * (BL_PWM_COUNT - bl_pwm_counter) / BL_PWM_COUNT;
129 break ; 210 break ;
@@ -143,7 +224,9 @@ static void backlight_isr(void)
143 224
144 if (idle) 225 if (idle)
145 { 226 {
227#ifdef CPU_COLDFIRE
146 queue_post(&backlight_queue, BACKLIGHT_UNBOOST_CPU, NULL); 228 queue_post(&backlight_queue, BACKLIGHT_UNBOOST_CPU, NULL);
229#endif
147 timer_unregister(); 230 timer_unregister();
148 bl_timer_active = false; 231 bl_timer_active = false;
149 } 232 }
@@ -155,19 +238,21 @@ static void backlight_switch(void)
155{ 238{
156 if (bl_dim_target > (BL_PWM_COUNT/2)) 239 if (bl_dim_target > (BL_PWM_COUNT/2))
157 { 240 {
158 and_l(~0x00020000, &GPIO1_OUT); 241 __backlight_on();
159 bl_dim_current = BL_PWM_COUNT; 242 bl_dim_current = BL_PWM_COUNT;
160 } 243 }
161 else 244 else
162 { 245 {
163 or_l(0x00020000, &GPIO1_OUT); 246 __backlight_off();
164 bl_dim_current = 0; 247 bl_dim_current = 0;
165 } 248 }
166} 249}
167 250
168static void backlight_release_timer(void) 251static void backlight_release_timer(void)
169{ 252{
253#ifdef CPU_COLDFIRE
170 cpu_boost(false); 254 cpu_boost(false);
255#endif
171 timer_unregister(); 256 timer_unregister();
172 bl_timer_active = false; 257 bl_timer_active = false;
173 backlight_switch(); 258 backlight_switch();
@@ -186,8 +271,10 @@ static void backlight_dim(int value)
186 271
187 if (timer_register(0, backlight_release_timer, 1, 0, backlight_isr)) 272 if (timer_register(0, backlight_release_timer, 1, 0, backlight_isr))
188 { 273 {
274#ifdef CPU_COLDFIRE
189 /* Prevent cpu frequency changes while dimming. */ 275 /* Prevent cpu frequency changes while dimming. */
190 cpu_boost(true); 276 cpu_boost(true);
277#endif
191 bl_timer_active = true; 278 bl_timer_active = true;
192 } 279 }
193 else 280 else
@@ -203,96 +290,35 @@ void backlight_set_fade_out(int index)
203{ 290{
204 fade_out_count = backlight_fade_value[index]; 291 fade_out_count = backlight_fade_value[index];
205} 292}
206#endif /* (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR) */ 293#endif /* defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR) */
207 294
208static void __backlight_on(void) 295static void _backlight_on(void)
209{ 296{
210#ifdef SIMULATOR 297#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
211 sim_backlight(100);
212#elif CONFIG_BACKLIGHT == BL_IRIVER_H100
213 if (fade_in_count > 0) 298 if (fade_in_count > 0)
214 backlight_dim(BL_PWM_COUNT); 299 backlight_dim(BL_PWM_COUNT);
215 else 300 else
216 { 301 {
217 bl_dim_target = bl_dim_current = BL_PWM_COUNT; 302 bl_dim_target = bl_dim_current = BL_PWM_COUNT;
218 and_l(~0x00020000, &GPIO1_OUT); 303 __backlight_on();
219 } 304 }
220#elif CONFIG_BACKLIGHT == BL_IRIVER_H300 305#else
221 lcd_enable(true); 306 __backlight_on();
222 or_l(0x00020000, &GPIO1_OUT);
223#elif CONFIG_BACKLIGHT == BL_RTC
224 /* Enable square wave */
225 rtc_write(0x0a, rtc_read(0x0a) | 0x40);
226#elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */
227 and_b(~0x40, &PADRH); /* drive and set low */
228 or_b(0x40, &PAIORH);
229#elif CONFIG_BACKLIGHT == BL_PA14_HI /* Ondio */
230 or_b(0x40, &PADRH); /* drive it high */
231#elif CONFIG_BACKLIGHT == BL_GMINI
232 P1 |= 0x10;
233#elif CONFIG_BACKLIGHT == BL_IPOD4G
234 /* brightness full */
235 outl(0x80000000 | (0xff << 16), 0x7000a010);
236
237 /* set port b bit 3 on */
238 outl(((0x100 | 1) << 3), 0x6000d824);
239#elif CONFIG_BACKLIGHT==BL_IPODMINI
240 /* set port B03 on */
241 outl(((0x100 | 1) << 3), 0x6000d824);
242#elif CONFIG_BACKLIGHT==BL_IPODNANO
243 /* set port B03 on */
244 outl(((0x100 | 1) << 3), 0x6000d824);
245
246 /* set port L07 on */
247 outl(((0x100 | 1) << 7), 0x6000d12c);
248#elif CONFIG_BACKLIGHT==BL_IPOD3G
249 lcd_enable(true);
250#elif CONFIG_BACKLIGHT==BL_IRIVER_IFP7XX
251 GPIO3_SET = 1;
252#endif 307#endif
253} 308}
254 309
255static void __backlight_off(void) 310static void _backlight_off(void)
256{ 311{
257#ifdef SIMULATOR 312#if defined(HAVE_BACKLIGHT_PWM_FADING) && !defined(SIMULATOR)
258 sim_backlight(0);
259#elif CONFIG_BACKLIGHT == BL_IRIVER_H100
260 if (fade_out_count > 0) 313 if (fade_out_count > 0)
261 backlight_dim(0); 314 backlight_dim(0);
262 else 315 else
263 { 316 {
264 bl_dim_target = bl_dim_current = 0; 317 bl_dim_target = bl_dim_current = 0;
265 or_l(0x00020000, &GPIO1_OUT); 318 __backlight_off();
266 } 319 }
267#elif CONFIG_BACKLIGHT == BL_IRIVER_H300 320#else
268 and_l(~0x00020000, &GPIO1_OUT); 321 __backlight_off();
269 lcd_enable(false);
270#elif CONFIG_BACKLIGHT == BL_RTC
271 /* Disable square wave */
272 rtc_write(0x0a, rtc_read(0x0a) & ~0x40);
273#elif CONFIG_BACKLIGHT == BL_PA14_LO /* Player */
274 and_b(~0x40, &PAIORH); /* let it float (up) */
275#elif CONFIG_BACKLIGHT == BL_PA14_HI /* Ondio */
276 and_b(~0x40, &PADRH); /* drive it low */
277#elif CONFIG_BACKLIGHT == BL_GMINI
278 P1 &= ~0x10;
279#elif CONFIG_BACKLIGHT == BL_IPOD4G
280 /* fades backlight off on 4g */
281 outl(inl(0x70000084) & ~0x2000000, 0x70000084);
282 outl(0x80000000, 0x7000a010);
283#elif CONFIG_BACKLIGHT==BL_IPODNANO
284 /* set port B03 off */
285 outl(((0x100 | 0) << 3), 0x6000d824);
286
287 /* set port L07 off */
288 outl(((0x100 | 0) << 7), 0x6000d12c);
289#elif CONFIG_BACKLIGHT==BL_IRIVER_IFP7XX
290 GPIO3_CLR = 1;
291#elif CONFIG_BACKLIGHT==BL_IPOD3G
292 lcd_enable(false);
293#elif CONFIG_BACKLIGHT==BL_IPODMINI
294 /* set port B03 off */
295 outl(((0x100 | 0) << 3), 0x6000d824);
296#endif 322#endif
297} 323}
298 324
@@ -374,19 +400,20 @@ void backlight_thread(void)
374 if (backlight_timer < 0) /* Backlight == OFF in the setting? */ 400 if (backlight_timer < 0) /* Backlight == OFF in the setting? */
375 { 401 {
376 backlight_timer = 0; /* Disable the timeout */ 402 backlight_timer = 0; /* Disable the timeout */
377 __backlight_off(); 403 _backlight_off();
378 } 404 }
379 else 405 else
380 { 406 {
381 __backlight_on(); 407 _backlight_on();
382 } 408 }
383 break; 409 break;
384 410
385 case BACKLIGHT_OFF: 411 case BACKLIGHT_OFF:
386 __backlight_off(); 412 _backlight_off();
387 break; 413 break;
388 414
389#if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR) 415#if defined(HAVE_BACKLIGHT_PWM_FADING) && defined(CPU_COLDFIRE) \
416 && !defined(SIMULATOR)
390 case BACKLIGHT_UNBOOST_CPU: 417 case BACKLIGHT_UNBOOST_CPU:
391 cpu_boost(false); 418 cpu_boost(false);
392 break; 419 break;
diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h
index 05d395f4a6..e182803898 100644
--- a/firmware/export/backlight.h
+++ b/firmware/export/backlight.h
@@ -27,7 +27,7 @@ void backlight_set_timeout(int index);
27#ifdef CONFIG_BACKLIGHT 27#ifdef CONFIG_BACKLIGHT
28void backlight_init(void); 28void backlight_init(void);
29int backlight_get_current_timeout(void); 29int backlight_get_current_timeout(void);
30#if CONFIG_BACKLIGHT == BL_IRIVER_H100 30#ifdef HAVE_BACKLIGHT_PWM_FADING
31void backlight_set_fade_in(int index); 31void backlight_set_fade_in(int index);
32void backlight_set_fade_out(int index); 32void backlight_set_fade_out(int index);
33#endif 33#endif
diff --git a/firmware/export/config-h100.h b/firmware/export/config-h100.h
index bdbcce71a4..bc8968902d 100644
--- a/firmware/export/config-h100.h
+++ b/firmware/export/config-h100.h
@@ -40,6 +40,9 @@
40/* Define this for LCD backlight available */ 40/* Define this for LCD backlight available */
41#define CONFIG_BACKLIGHT BL_IRIVER_H100 /* port controlled */ 41#define CONFIG_BACKLIGHT BL_IRIVER_H100 /* port controlled */
42 42
43/* We can fade the backlight by using PWM */
44#define HAVE_BACKLIGHT_PWM_FADING
45
43/* Define this if you have a software controlled poweroff */ 46/* Define this if you have a software controlled poweroff */
44#define HAVE_SW_POWEROFF 47#define HAVE_SW_POWEROFF
45 48
diff --git a/firmware/export/config-h120.h b/firmware/export/config-h120.h
index aea6011e63..bbfa942ee7 100644
--- a/firmware/export/config-h120.h
+++ b/firmware/export/config-h120.h
@@ -36,6 +36,9 @@
36/* Define this for LCD backlight available */ 36/* Define this for LCD backlight available */
37#define CONFIG_BACKLIGHT BL_IRIVER_H100 /* port controlled */ 37#define CONFIG_BACKLIGHT BL_IRIVER_H100 /* port controlled */
38 38
39/* We can fade the backlight by using PWM */
40#define HAVE_BACKLIGHT_PWM_FADING
41
39/* Define this if you have a software controlled poweroff */ 42/* Define this if you have a software controlled poweroff */
40#define HAVE_SW_POWEROFF 43#define HAVE_SW_POWEROFF
41 44
diff --git a/firmware/export/config-ipodnano.h b/firmware/export/config-ipodnano.h
index 6bcbffb3b2..142fb272f9 100644
--- a/firmware/export/config-ipodnano.h
+++ b/firmware/export/config-ipodnano.h
@@ -48,6 +48,9 @@
48/* Define this for LCD backlight available */ 48/* Define this for LCD backlight available */
49#define CONFIG_BACKLIGHT BL_IPODNANO /* port controlled */ 49#define CONFIG_BACKLIGHT BL_IPODNANO /* port controlled */
50 50
51/* We can fade the backlight by using PWM */
52#define HAVE_BACKLIGHT_PWM_FADING
53
51#ifndef SIMULATOR 54#ifndef SIMULATOR
52 55
53/* The Nano actually has a PP5021 - but it's register compatible with 56/* The Nano actually has a PP5021 - but it's register compatible with
diff --git a/firmware/export/config-ipodvideo.h b/firmware/export/config-ipodvideo.h
index 6ea9fcebb8..9536cc8b8f 100644
--- a/firmware/export/config-ipodvideo.h
+++ b/firmware/export/config-ipodvideo.h
@@ -48,6 +48,9 @@
48/* Define this for LCD backlight available */ 48/* Define this for LCD backlight available */
49#define CONFIG_BACKLIGHT BL_IPODNANO /* port controlled */ 49#define CONFIG_BACKLIGHT BL_IPODNANO /* port controlled */
50 50
51/* We can fade the backlight by using PWM */
52#define HAVE_BACKLIGHT_PWM_FADING
53
51#ifndef SIMULATOR 54#ifndef SIMULATOR
52 55
53/* The Nano actually has a PP5021 - but it's register compatible with 56/* The Nano actually has a PP5021 - but it's register compatible with