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/backlight.c | |
parent | 74c445c0fdb5c94700353aa665a44ac4ee302fd0 (diff) | |
download | rockbox-eb5463d158620e84a7ed0f5f9e47d1f88a6bd80c.tar.gz rockbox-eb5463d158620e84a7ed0f5f9e47d1f88a6bd80c.zip |
Ported to iRiver H100
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@5209 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/backlight.c')
-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 @@ | |||
18 | ****************************************************************************/ | 18 | ****************************************************************************/ |
19 | #include "config.h" | 19 | #include "config.h" |
20 | #include <stdlib.h> | 20 | #include <stdlib.h> |
21 | #include "sh7034.h" | 21 | #include "cpu.h" |
22 | #include "kernel.h" | 22 | #include "kernel.h" |
23 | #include "thread.h" | 23 | #include "thread.h" |
24 | #include "i2c.h" | 24 | #include "i2c.h" |
@@ -49,6 +49,35 @@ static bool backlight_on_when_charging = 0; | |||
49 | static int backlight_timer; | 49 | static int backlight_timer; |
50 | static unsigned int backlight_timeout = 5; | 50 | static unsigned int backlight_timeout = 5; |
51 | 51 | ||
52 | static void __backlight_off(void) | ||
53 | { | ||
54 | #ifdef IRIVER_H100 | ||
55 | GPIO1_OUT &= ~0x00020000; | ||
56 | #else | ||
57 | #ifdef HAVE_RTC | ||
58 | /* Disable square wave */ | ||
59 | rtc_write(0x0a, rtc_read(0x0a) & ~0x40); | ||
60 | #else | ||
61 | and_b(~0x40, &PAIORH); | ||
62 | #endif | ||
63 | #endif | ||
64 | } | ||
65 | |||
66 | static void __backlight_on(void) | ||
67 | { | ||
68 | #ifdef IRIVER_H100 | ||
69 | GPIO1_OUT |= 0x00020000; | ||
70 | #else | ||
71 | #ifdef HAVE_RTC | ||
72 | /* Enable square wave */ | ||
73 | rtc_write(0x0a, rtc_read(0x0a) | 0x40); | ||
74 | #else | ||
75 | and_b(~0x40, &PADRH); | ||
76 | or_b(0x40, &PAIORH); | ||
77 | #endif | ||
78 | #endif | ||
79 | } | ||
80 | |||
52 | void backlight_thread(void) | 81 | void backlight_thread(void) |
53 | { | 82 | { |
54 | struct event ev; | 83 | struct event ev; |
@@ -69,36 +98,19 @@ void backlight_thread(void) | |||
69 | backlight_timer = HZ*backlight_timeout_value[backlight_timeout]; | 98 | backlight_timer = HZ*backlight_timeout_value[backlight_timeout]; |
70 | } | 99 | } |
71 | 100 | ||
72 | if(backlight_timer < 0) | 101 | if(backlight_timer < 0) /* Backlight == OFF in the setting? */ |
73 | { | 102 | { |
74 | backlight_timer = 0; /* timer value 0 will not get ticked */ | 103 | backlight_timer = 0; /* Disable the timeout */ |
75 | #ifdef HAVE_RTC | 104 | __backlight_off(); |
76 | /* Disable square wave */ | ||
77 | rtc_write(0x0a, rtc_read(0x0a) & ~0x40); | ||
78 | #else | ||
79 | and_b(~0x40, &PAIORH); | ||
80 | #endif | ||
81 | } | 105 | } |
82 | /* else if(backlight_timer) */ | ||
83 | else | 106 | else |
84 | { | 107 | { |
85 | #ifdef HAVE_RTC | 108 | __backlight_on(); |
86 | /* Enable square wave */ | ||
87 | rtc_write(0x0a, rtc_read(0x0a) | 0x40); | ||
88 | #else | ||
89 | and_b(~0x40, &PADRH); | ||
90 | or_b(0x40, &PAIORH); | ||
91 | #endif | ||
92 | } | 109 | } |
93 | break; | 110 | break; |
94 | 111 | ||
95 | case BACKLIGHT_OFF: | 112 | case BACKLIGHT_OFF: |
96 | #ifdef HAVE_RTC | 113 | __backlight_off(); |
97 | /* Disable square wave */ | ||
98 | rtc_write(0x0a, rtc_read(0x0a) & ~0x40); | ||
99 | #else | ||
100 | and_b(~0x40, &PAIORH); | ||
101 | #endif | ||
102 | break; | 114 | break; |
103 | 115 | ||
104 | case SYS_USB_CONNECTED: | 116 | case SYS_USB_CONNECTED: |
@@ -175,6 +187,10 @@ void backlight_init(void) | |||
175 | create_thread(backlight_thread, backlight_stack, | 187 | create_thread(backlight_thread, backlight_stack, |
176 | sizeof(backlight_stack), backlight_thread_name); | 188 | sizeof(backlight_stack), backlight_thread_name); |
177 | 189 | ||
190 | #ifdef IRIVER_H100 | ||
191 | GPIO1_ENABLE |= 0x00020000; | ||
192 | GPIO1_FUNCTION |= 0x00020000; | ||
193 | #endif | ||
178 | backlight_on(); | 194 | backlight_on(); |
179 | } | 195 | } |
180 | 196 | ||