summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorRob Purchase <shotofadds@rockbox.org>2008-04-04 20:55:58 +0000
committerRob Purchase <shotofadds@rockbox.org>2008-04-04 20:55:58 +0000
commit91202e180497bc15cfb77d528fb04efe91dd15bf (patch)
treed8ce4c3ce2ca0028fa1cc93f59579923f530bcb0 /firmware
parent9b691d335ae4bf3d666d7991fedf56731d8f533e (diff)
downloadrockbox-91202e180497bc15cfb77d528fb04efe91dd15bf.tar.gz
rockbox-91202e180497bc15cfb77d528fb04efe91dd15bf.tar.bz2
rockbox-91202e180497bc15cfb77d528fb04efe91dd15bf.zip
D2: Adjustable backlight brightness (sometimes fails when boosted, suggests I2C timing needs adjustment). Tweak lcd_enable() to behave more like other targets.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16967 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/export/config-cowond2.h10
-rw-r--r--firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c56
-rw-r--r--firmware/target/arm/tcc780x/cowond2/backlight-target.h21
-rw-r--r--firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c26
5 files changed, 69 insertions, 45 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES
index fa2222e7d0..3864a3478b 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -911,6 +911,7 @@ target/arm/tcc780x/cowond2/lcd-cowond2.c
target/arm/tcc780x/cowond2/power-cowond2.c
target/arm/tcc780x/cowond2/powermgmt-cowond2.c
target/arm/tcc780x/cowond2/usb-cowond2.c
+target/arm/tcc780x/cowond2/backlight-cowond2.c
#ifndef BOOTLOADER
target/arm/tcc780x/kernel-tcc780x.c
target/arm/tcc780x/timer-tcc780x.c
diff --git a/firmware/export/config-cowond2.h b/firmware/export/config-cowond2.h
index a2a1775500..1eef8f8ee5 100644
--- a/firmware/export/config-cowond2.h
+++ b/firmware/export/config-cowond2.h
@@ -89,13 +89,13 @@
/* Define this for LCD backlight available */
#define HAVE_BACKLIGHT
-/* TODO: Enable LCD brightness control */
-//#define HAVE_BACKLIGHT_BRIGHTNESS
+/* Enable LCD brightness control */
+#define HAVE_BACKLIGHT_BRIGHTNESS
/* Main LCD backlight brightness range and defaults */
-//#define MIN_BRIGHTNESS_SETTING 1
-//#define MAX_BRIGHTNESS_SETTING 10
-//#define DEFAULT_BRIGHTNESS_SETTING 8
+#define MIN_BRIGHTNESS_SETTING 1
+#define MAX_BRIGHTNESS_SETTING 14
+#define DEFAULT_BRIGHTNESS_SETTING 8
#define CONFIG_I2C I2C_TCC780X
diff --git a/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c b/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c
new file mode 100644
index 0000000000..07286bdd09
--- /dev/null
+++ b/firmware/target/arm/tcc780x/cowond2/backlight-cowond2.c
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2008 by Rob Purchase
+ *
+ * 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 "backlight-target.h"
+#include "system.h"
+#include "backlight.h"
+#include "pcf50606.h"
+#include "tcc780x.h"
+
+static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
+
+int _backlight_init(void)
+{
+ _backlight_set_brightness(DEFAULT_BRIGHTNESS_SETTING);
+ return true;
+}
+
+void _backlight_set_brightness(int brightness)
+{
+ backlight_brightness = brightness;
+
+ int level = disable_irq_save();
+ pcf50606_write(PCF5060X_PWMC1, 0xe1 | (14-backlight_brightness)<<1);
+ pcf50606_write(PCF5060X_GPOC1, 0x3);
+ restore_irq(level);
+
+ if (brightness > 0)
+ _backlight_on();
+ else
+ _backlight_off();
+}
+
+void _backlight_on(void)
+{
+ GPIOA_SET = (1<<6);
+}
+
+void _backlight_off(void)
+{
+ GPIOA_CLEAR = (1<<6);
+}
diff --git a/firmware/target/arm/tcc780x/cowond2/backlight-target.h b/firmware/target/arm/tcc780x/cowond2/backlight-target.h
index 0563fc20f5..0ddff85544 100644
--- a/firmware/target/arm/tcc780x/cowond2/backlight-target.h
+++ b/firmware/target/arm/tcc780x/cowond2/backlight-target.h
@@ -19,22 +19,9 @@
#ifndef BACKLIGHT_TARGET_H
#define BACKLIGHT_TARGET_H
-#include "tcc780x.h"
-
-#define _backlight_init() true
-
-/* nb: we can set the backlight intensity using PCF50606 register 0x35 */
-
-static inline void _backlight_on(void)
-{
- /* Enable backlight */
- GPIOA_SET = (1<<6);
-}
-
-static inline void _backlight_off(void)
-{
- /* Disable backlight */
- GPIOA_CLEAR = (1<<6);
-}
+int _backlight_init(void);
+void _backlight_on(void);
+void _backlight_off(void);
+void _backlight_set_brightness(int brightness);
#endif
diff --git a/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c b/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c
index 54466f428b..8a268db4cc 100644
--- a/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c
+++ b/firmware/target/arm/tcc780x/cowond2/lcd-cowond2.c
@@ -23,7 +23,6 @@
#include "lcd.h"
#include "system.h"
#include "cpu.h"
-#include "i2c.h"
/* GPIO A pins for LCD panel SDI interface */
@@ -100,16 +99,6 @@ static void lcd_write_reg(unsigned char reg, unsigned short val)
}
-/* TODO: The existing pcf50606 drivers are target-specific, so the following
- lonely function exists until a D2 driver exists. */
-
-void pcf50606_write_reg(unsigned char reg, unsigned char val)
-{
- unsigned char data[] = { reg, val };
- i2c_write(0x10, data, 2);
-}
-
-
/*
TEMP: Rough millisecond delay routine used by the LCD panel init sequence.
PCK_TCT must first have been initialised to 2Mhz by calling clock_init().
@@ -190,9 +179,6 @@ static void lcd_display_on(void)
lcd_write_reg(10, 0x111F);
sleep_ms(10);
- pcf50606_write_reg(0x35, 0xe9); /* PWMC1 - backlight power (intensity) */
- pcf50606_write_reg(0x38, 0x3); /* GPOC1 - ? */
-
/* tell that we're on now */
display_on = true;
}
@@ -213,9 +199,6 @@ static void lcd_display_off(void)
/* kill power to LCD panel (unconfirmed) */
GPIOA_CLEAR = (1<<16);
-
- /* also kill the backlight, otherwise LCD fade is visible on screen */
- GPIOA_CLEAR = (1<<6);
}
@@ -226,14 +209,14 @@ void lcd_enable(bool on)
if (on)
{
+ lcd_display_on();
LCDC_CTRL |= 1; /* controller enable */
- GPIOA_SET = (1<<6); /* backlight enable - not visible otherwise */
lcd_update(); /* Resync display */
}
else
{
- LCDC_CTRL &= ~1; /* controller disable */
- GPIOA_CLEAR = (1<<6); /* backlight off */
+ LCDC_CTRL &= ~1; /* controller disable */
+ lcd_display_off();
}
}
@@ -290,9 +273,6 @@ void lcd_init_device(void)
/* enable LTV250QV panel */
lcd_display_on();
-
- /* turn on the backlight, without it the LCD is not visible at all */
- GPIOA_SET = (1<<6);
}