diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/backlight.c | 96 | ||||
-rw-r--r-- | firmware/backlight.h | 27 |
2 files changed, 123 insertions, 0 deletions
diff --git a/firmware/backlight.c b/firmware/backlight.c new file mode 100644 index 0000000000..c597b23c0b --- /dev/null +++ b/firmware/backlight.c | |||
@@ -0,0 +1,96 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include <stdlib.h> | ||
21 | #include "sh7034.h" | ||
22 | #include "kernel.h" | ||
23 | #include "thread.h" | ||
24 | #include "i2c.h" | ||
25 | #include "debug.h" | ||
26 | #include "rtc.h" | ||
27 | #include "settings.h" | ||
28 | |||
29 | #define BACKLIGHT_ON 1 | ||
30 | #define BACKLIGHT_OFF 2 | ||
31 | |||
32 | static void backlight_thread(void); | ||
33 | static char backlight_stack[0x100]; | ||
34 | static struct event_queue backlight_queue; | ||
35 | |||
36 | static int backlight_timer; | ||
37 | |||
38 | void backlight_thread(void) | ||
39 | { | ||
40 | struct event ev; | ||
41 | |||
42 | while(1) | ||
43 | { | ||
44 | queue_wait(&backlight_queue, &ev); | ||
45 | switch(ev.id) | ||
46 | { | ||
47 | case BACKLIGHT_ON: | ||
48 | backlight_timer = HZ*global_settings.backlight; | ||
49 | if(backlight_timer) | ||
50 | { | ||
51 | #ifdef HAVE_RTC | ||
52 | rtc_write(0x13, 0x10); | ||
53 | #else | ||
54 | PAIOR |= 0x40; | ||
55 | #endif | ||
56 | } | ||
57 | break; | ||
58 | case BACKLIGHT_OFF: | ||
59 | #ifdef HAVE_RTC | ||
60 | rtc_write(0x13, 0x00); | ||
61 | #else | ||
62 | PAIOR &= 0xbf; | ||
63 | #endif | ||
64 | break; | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | |||
69 | void backlight_on(void) | ||
70 | { | ||
71 | queue_post(&backlight_queue, BACKLIGHT_ON, NULL); | ||
72 | } | ||
73 | |||
74 | void backlight_off(void) | ||
75 | { | ||
76 | queue_post(&backlight_queue, BACKLIGHT_OFF, NULL); | ||
77 | } | ||
78 | |||
79 | void backlight_tick(void) | ||
80 | { | ||
81 | if(backlight_timer) | ||
82 | { | ||
83 | backlight_timer--; | ||
84 | if(backlight_timer == 0) | ||
85 | { | ||
86 | backlight_off(); | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | |||
91 | void backlight_init(void) | ||
92 | { | ||
93 | queue_init(&backlight_queue); | ||
94 | create_thread(backlight_thread, backlight_stack, sizeof(backlight_stack)); | ||
95 | backlight_on(); | ||
96 | } | ||
diff --git a/firmware/backlight.h b/firmware/backlight.h new file mode 100644 index 0000000000..2a59800918 --- /dev/null +++ b/firmware/backlight.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Daniel Stenberg | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef BACKLIGHT_H | ||
20 | #define BACKLIGHT_H | ||
21 | |||
22 | void backlight_init(void); | ||
23 | void backlight_on(void); | ||
24 | void backlight_off(void); | ||
25 | void backlight_tick(void); | ||
26 | |||
27 | #endif | ||