summaryrefslogtreecommitdiffstats
path: root/firmware/target/arm/as3525/sansa-clip
diff options
context:
space:
mode:
authorRafaël Carré <rafael.carre@gmail.com>2008-10-31 22:02:41 +0000
committerRafaël Carré <rafael.carre@gmail.com>2008-10-31 22:02:41 +0000
commit603a9c7c7ded195de7af15a35d10f5961f2e88f1 (patch)
treeff215c32de10e82172bf953ae7e043ddc5d353bb /firmware/target/arm/as3525/sansa-clip
parentee593c95e22b0361431f97dcc8a91c0264a5485a (diff)
downloadrockbox-603a9c7c7ded195de7af15a35d10f5961f2e88f1.tar.gz
rockbox-603a9c7c7ded195de7af15a35d10f5961f2e88f1.zip
Clip: add backlight and buttonlight code
Revive lcd_enable() as well, and use it in _backlight_on/off() Don't update the lcd framebuffer if the display is off git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18952 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/as3525/sansa-clip')
-rw-r--r--firmware/target/arm/as3525/sansa-clip/backlight-clip.c58
-rw-r--r--firmware/target/arm/as3525/sansa-clip/backlight-target.h16
-rw-r--r--firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c19
3 files changed, 88 insertions, 5 deletions
diff --git a/firmware/target/arm/as3525/sansa-clip/backlight-clip.c b/firmware/target/arm/as3525/sansa-clip/backlight-clip.c
new file mode 100644
index 0000000000..2064f0992f
--- /dev/null
+++ b/firmware/target/arm/as3525/sansa-clip/backlight-clip.c
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright © 2008 Rafaël Carré
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "backlight-target.h"
+#include "as3525.h"
+
+/* TODO : backlight brightness */
+
+/* XXX : xpd is used for SD/MCI interface
+ * If interrupts are used to access this interface, they should be
+ * disabled in _buttonlight_on/off ()
+ */
+
+void _buttonlight_on(void)
+{
+ int saved_ccu_io;
+
+ saved_ccu_io = CCU_IO; /* save XPD setting */
+
+ CCU_IO &= ~(3<<2); /* setup xpd as GPIO */
+
+ GPIOD_DIR |= (1<<7);
+ GPIOD_PIN(7) = (1<<7); /* set pin d7 high */
+
+ CCU_IO = saved_ccu_io; /* restore the previous XPD setting */
+}
+
+void _buttonlight_off(void)
+{
+ int saved_ccu_io;
+
+ saved_ccu_io = CCU_IO; /* save XPD setting */
+
+ CCU_IO &= ~(3<<2); /* setup xpd as GPIO */
+
+ GPIOD_DIR |= (1<<7);
+ GPIOD_PIN(7) = 0; /* set pin d7 low */
+
+ CCU_IO = saved_ccu_io; /* restore the previous XPD setting */
+}
diff --git a/firmware/target/arm/as3525/sansa-clip/backlight-target.h b/firmware/target/arm/as3525/sansa-clip/backlight-target.h
index 9533d0a6b5..5a6ae34728 100644
--- a/firmware/target/arm/as3525/sansa-clip/backlight-target.h
+++ b/firmware/target/arm/as3525/sansa-clip/backlight-target.h
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2008 ??
+ * Copyright © 2008 Rafaël Carré
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -21,17 +21,23 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-static inline bool _backlight_init(void)
-{
- return true;
-}
+#include "stdbool.h"
+#include "lcd.h"
+#include "backlight.h"
+
+#define _backlight_init() true
static inline void _backlight_on(void)
{
+ lcd_enable(true);
}
static inline void _backlight_off(void)
{
+ lcd_enable(false);
}
+void _buttonlight_on(void);
+void _buttonlight_off(void);
+
#endif
diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c
index ed4bcc7be9..a794589647 100644
--- a/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c
+++ b/firmware/target/arm/as3525/sansa-clip/lcd-ssd1303.c
@@ -149,6 +149,9 @@ void lcd_set_flip(bool yesno)
void lcd_enable(bool enable)
{
+ if(display_on == enable)
+ return;
+
if( (display_on = enable) ) /* simple '=' is not a typo ! */
lcd_write_command(LCD_SET_DISPLAY_ON);
else
@@ -240,6 +243,9 @@ void lcd_init_device(void)
void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
int bheight, int stride)
{
+ if(!display_on)
+ return;
+
/* Copy display bitmap to hardware */
while (bheight--)
{
@@ -258,6 +264,13 @@ void lcd_blit_mono(const unsigned char *data, int x, int by, int width,
void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases,
int x, int by, int width, int bheight, int stride)
{
+ /* TODO */
+
+#if 0
+ if(!display_on)
+ return;
+#endif
+
(void)values;
(void)phases;
(void)x;
@@ -274,6 +287,9 @@ void lcd_update(void)
{
int y;
+ if(!display_on)
+ return;
+
/* Copy display bitmap to hardware */
for (y = 0; y < LCD_FBHEIGHT; y++)
{
@@ -291,6 +307,9 @@ void lcd_update_rect(int x, int y, int width, int height)
{
int ymax;
+ if(!display_on)
+ return;
+
/* The Y coordinates have to work on even 8 pixel rows */
ymax = (y + height-1) >> 3;
y >>= 3;