summaryrefslogtreecommitdiff
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
parent740eb36c10dd43b2307767f6101833d960399438 (diff)
downloadrockbox-2a4de23b5f78f076551a9a2ac52d83a64646a94f.zip
rockbox-2a4de23b5f78f076551a9a2ac52d83a64646a94f.tar.gz
rockbox-2a4de23b5f78f076551a9a2ac52d83a64646a94f.tar.bz2
rockbox-2a4de23b5f78f076551a9a2ac52d83a64646a94f.tar.xz
First version
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1152 a1c6a512-1295-4272-9138-f99709370657
-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 0000000..c597b23
--- /dev/null
+++ b/firmware/backlight.c
@@ -0,0 +1,96 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Linus Nielsen Feltzing
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#include "config.h"
+#include <stdlib.h>
+#include "sh7034.h"
+#include "kernel.h"
+#include "thread.h"
+#include "i2c.h"
+#include "debug.h"
+#include "rtc.h"
+#include "settings.h"
+
+#define BACKLIGHT_ON 1
+#define BACKLIGHT_OFF 2
+
+static void backlight_thread(void);
+static char backlight_stack[0x100];
+static struct event_queue backlight_queue;
+
+static int backlight_timer;
+
+void backlight_thread(void)
+{
+ struct event ev;
+
+ while(1)
+ {
+ queue_wait(&backlight_queue, &ev);
+ switch(ev.id)
+ {
+ case BACKLIGHT_ON:
+ backlight_timer = HZ*global_settings.backlight;
+ if(backlight_timer)
+ {
+#ifdef HAVE_RTC
+ rtc_write(0x13, 0x10);
+#else
+ PAIOR |= 0x40;
+#endif
+ }
+ break;
+ case BACKLIGHT_OFF:
+#ifdef HAVE_RTC
+ rtc_write(0x13, 0x00);
+#else
+ PAIOR &= 0xbf;
+#endif
+ break;
+ }
+ }
+}
+
+void backlight_on(void)
+{
+ queue_post(&backlight_queue, BACKLIGHT_ON, NULL);
+}
+
+void backlight_off(void)
+{
+ queue_post(&backlight_queue, BACKLIGHT_OFF, NULL);
+}
+
+void backlight_tick(void)
+{
+ if(backlight_timer)
+ {
+ backlight_timer--;
+ if(backlight_timer == 0)
+ {
+ backlight_off();
+ }
+ }
+}
+
+void backlight_init(void)
+{
+ queue_init(&backlight_queue);
+ create_thread(backlight_thread, backlight_stack, sizeof(backlight_stack));
+ backlight_on();
+}
diff --git a/firmware/backlight.h b/firmware/backlight.h
new file mode 100644
index 0000000..2a59800
--- /dev/null
+++ b/firmware/backlight.h
@@ -0,0 +1,27 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2002 by Daniel Stenberg
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+#ifndef BACKLIGHT_H
+#define BACKLIGHT_H
+
+void backlight_init(void);
+void backlight_on(void);
+void backlight_off(void);
+void backlight_tick(void);
+
+#endif