summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/backlight.c62
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;
49static int backlight_timer; 49static int backlight_timer;
50static unsigned int backlight_timeout = 5; 50static unsigned int backlight_timeout = 5;
51 51
52static 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
66static 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
52void backlight_thread(void) 81void 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