summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-06-24 13:48:42 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-06-24 13:48:42 +0000
commit2a4de23b5f78f076551a9a2ac52d83a64646a94f (patch)
tree0132b9b079b9c8e3906b145422d63d07e00725cd /firmware
parent740eb36c10dd43b2307767f6101833d960399438 (diff)
downloadrockbox-2a4de23b5f78f076551a9a2ac52d83a64646a94f.tar.gz
rockbox-2a4de23b5f78f076551a9a2ac52d83a64646a94f.zip
First version
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1152 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/backlight.c96
-rw-r--r--firmware/backlight.h27
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
32static void backlight_thread(void);
33static char backlight_stack[0x100];
34static struct event_queue backlight_queue;
35
36static int backlight_timer;
37
38void 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
69void backlight_on(void)
70{
71 queue_post(&backlight_queue, BACKLIGHT_ON, NULL);
72}
73
74void backlight_off(void)
75{
76 queue_post(&backlight_queue, BACKLIGHT_OFF, NULL);
77}
78
79void 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
91void 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
22void backlight_init(void);
23void backlight_on(void);
24void backlight_off(void);
25void backlight_tick(void);
26
27#endif