diff options
author | Linus Nielsen Feltzing <linus@haxx.se> | 2004-10-07 08:38:51 +0000 |
---|---|---|
committer | Linus Nielsen Feltzing <linus@haxx.se> | 2004-10-07 08:38:51 +0000 |
commit | eb5463d158620e84a7ed0f5f9e47d1f88a6bd80c (patch) | |
tree | ed554b7ea6730c59e0be0aa723b765324e9b9763 /firmware | |
parent | 74c445c0fdb5c94700353aa665a44ac4ee302fd0 (diff) |
Ported to iRiver H100
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5209 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/backlight.c | 62 |
1 files changed, 39 insertions, 23 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c index 2a726b65a4..10e4a2fdfb 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c @@ -18,7 +18,7 @@ ****************************************************************************/ #include "config.h" #include <stdlib.h> -#include "sh7034.h" +#include "cpu.h" #include "kernel.h" #include "thread.h" #include "i2c.h" @@ -49,6 +49,35 @@ static bool backlight_on_when_charging = 0; static int backlight_timer; static unsigned int backlight_timeout = 5; +static void __backlight_off(void) +{ +#ifdef IRIVER_H100 + GPIO1_OUT &= ~0x00020000; +#else +#ifdef HAVE_RTC + /* Disable square wave */ + rtc_write(0x0a, rtc_read(0x0a) & ~0x40); +#else + and_b(~0x40, &PAIORH); +#endif +#endif +} + +static void __backlight_on(void) +{ +#ifdef IRIVER_H100 + GPIO1_OUT |= 0x00020000; +#else +#ifdef HAVE_RTC + /* Enable square wave */ + rtc_write(0x0a, rtc_read(0x0a) | 0x40); +#else + and_b(~0x40, &PADRH); + or_b(0x40, &PAIORH); +#endif +#endif +} + void backlight_thread(void) { struct event ev; @@ -69,36 +98,19 @@ void backlight_thread(void) backlight_timer = HZ*backlight_timeout_value[backlight_timeout]; } - if(backlight_timer < 0) + if(backlight_timer < 0) /* Backlight == OFF in the setting? */ { - backlight_timer = 0; /* timer value 0 will not get ticked */ -#ifdef HAVE_RTC - /* Disable square wave */ - rtc_write(0x0a, rtc_read(0x0a) & ~0x40); -#else - and_b(~0x40, &PAIORH); -#endif + backlight_timer = 0; /* Disable the timeout */ + __backlight_off(); } - /* else if(backlight_timer) */ else { -#ifdef HAVE_RTC - /* Enable square wave */ - rtc_write(0x0a, rtc_read(0x0a) | 0x40); -#else - and_b(~0x40, &PADRH); - or_b(0x40, &PAIORH); -#endif + __backlight_on(); } break; case BACKLIGHT_OFF: -#ifdef HAVE_RTC - /* Disable square wave */ - rtc_write(0x0a, rtc_read(0x0a) & ~0x40); -#else - and_b(~0x40, &PAIORH); -#endif + __backlight_off(); break; case SYS_USB_CONNECTED: @@ -175,6 +187,10 @@ void backlight_init(void) create_thread(backlight_thread, backlight_stack, sizeof(backlight_stack), backlight_thread_name); +#ifdef IRIVER_H100 + GPIO1_ENABLE |= 0x00020000; + GPIO1_FUNCTION |= 0x00020000; +#endif backlight_on(); } |