summaryrefslogtreecommitdiffstats
path: root/firmware
diff options
context:
space:
mode:
authorBertrik Sikken <bertrik@sikken.nl>2010-07-22 15:31:24 +0000
committerBertrik Sikken <bertrik@sikken.nl>2010-07-22 15:31:24 +0000
commit55a4520f076ffa5190aac1f24f584e759ffc62cf (patch)
treea7a78f2192dfd05082d8909608be6c029e6627a4 /firmware
parent10e79de27c6c71360bfe4e740098cb7e6ff64c2a (diff)
downloadrockbox-55a4520f076ffa5190aac1f24f584e759ffc62cf.tar.gz
rockbox-55a4520f076ffa5190aac1f24f584e759ffc62cf.tar.bz2
rockbox-55a4520f076ffa5190aac1f24f584e759ffc62cf.zip
Sansa clip+: fix display brightness for players with newer OLED controller type (and reorganise the variant detection a bit in the process)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27522 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/arm/as3525/lcd-clip.h (renamed from firmware/target/arm/as3525/sansa-clip/lcd-clip.h)12
-rw-r--r--firmware/target/arm/as3525/lcd-ssd1303.c18
-rw-r--r--firmware/target/arm/as3525/sansa-clip/lcd-clip.c15
-rw-r--r--firmware/target/arm/as3525/sansa-clipplus/lcd-clip-plus.c10
-rw-r--r--firmware/target/arm/as3525/sansa-clipplus/lcd-clip.h28
-rw-r--r--firmware/target/arm/as3525/sansa-clipv2/lcd-clip.h28
-rw-r--r--firmware/target/arm/as3525/sansa-clipv2/lcd-clipv2.c14
7 files changed, 49 insertions, 76 deletions
diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-clip.h b/firmware/target/arm/as3525/lcd-clip.h
index 3d4fe60311..ab31f688db 100644
--- a/firmware/target/arm/as3525/sansa-clip/lcd-clip.h
+++ b/firmware/target/arm/as3525/lcd-clip.h
@@ -20,10 +20,10 @@
****************************************************************************/
#include "config.h"
-#include "ascodec.h"
-void lcd_hw_init(int *offset) INIT_ATTR;
-static inline void lcd_enable_power(bool onoff)
-{
- ascodec_write(AS3514_DCDC15, onoff ? 1 : 0);
-}
+/* return variant number: 0 = clipv1, old clip+, 1 = newer clip+ */
+int lcd_hw_init(void) INIT_ATTR;
+
+/* target-specific power enable */
+void lcd_enable_power(bool onoff);
+
diff --git a/firmware/target/arm/as3525/lcd-ssd1303.c b/firmware/target/arm/as3525/lcd-ssd1303.c
index e0e0715311..213f12a424 100644
--- a/firmware/target/arm/as3525/lcd-ssd1303.c
+++ b/firmware/target/arm/as3525/lcd-ssd1303.c
@@ -44,7 +44,6 @@
#define LCD_SET_REVERSE_DISPLAY ((char)0xA7)
#define LCD_SET_MULTIPLEX_RATIO ((char)0xA8)
#define LCD_SET_DC_DC ((char)0xAD)
-#define LCD_SET_DC_DC_PART2 ((char)0x8A)
#define LCD_SET_DISPLAY_OFF ((char)0xAE)
#define LCD_SET_DISPLAY_ON ((char)0xAF)
#define LCD_SET_PAGE_ADDRESS ((char)0xB0)
@@ -68,6 +67,13 @@
/** globals **/
static bool display_on; /* used by lcd_enable */
+
+/* Display variant, always 0 in clipv1, clipv2, can be 0 or 1 in clip+
+ * variant 0: has 132 pixel wide framebuffer, max brightness about 50
+ * variant 1: has 128 pixel wide framebuffer, max brightness about 128
+ */
+static int variant;
+
static int offset; /* column offset */
/*** hardware configuration ***/
@@ -80,6 +86,9 @@ int lcd_default_contrast(void)
void lcd_set_contrast(int val)
{
lcd_write_command(LCD_CNTL_CONTRAST);
+ if (variant == 1) {
+ val = val * 5 / 2;
+ }
lcd_write_command(val);
}
@@ -137,7 +146,8 @@ void lcd_init_device(void)
{
int i;
- lcd_hw_init(&offset);
+ variant = lcd_hw_init();
+ offset = (variant == 0) ? 2 : 0;
/* Set display clock (divide ratio = 1) and oscillator frequency (1) */
lcd_write_command(LCD_SET_DISPLAY_CLOCK_AND_OSC_FREQ);
@@ -154,9 +164,9 @@ void lcd_init_device(void)
/* Set contrast register to 12% */
lcd_set_contrast(lcd_default_contrast());
- /* Disable DC-DC */
+ /* Configure DC-DC */
lcd_write_command(LCD_SET_DC_DC);
- lcd_write_command(LCD_SET_DC_DC_PART2/*|0*/);
+ lcd_write_command((variant == 0) ? 0x8A : 0x10);
/* Set starting line as 0 */
lcd_write_command(LCD_SET_DISPLAY_START_LINE /*|(0 & 0x3f)*/);
diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-clip.c b/firmware/target/arm/as3525/sansa-clip/lcd-clip.c
index 775988cc0e..21d8902739 100644
--- a/firmware/target/arm/as3525/sansa-clip/lcd-clip.c
+++ b/firmware/target/arm/as3525/sansa-clip/lcd-clip.c
@@ -25,8 +25,11 @@
#include "lcd-clip.h"
#include "system.h"
#include "cpu.h"
+#include "ascodec.h"
-void lcd_hw_init(int *offset)
+#define LCD_DELAY 1
+
+int lcd_hw_init(void)
{
/* DBOP initialisation, do what OF does */
CGU_DBOP = (1<<3) | AS3525_DBOP_DIV;
@@ -46,11 +49,9 @@ void lcd_hw_init(int *offset)
GPIOA_PIN(4) = 0;
GPIOB_PIN(6) = (1<<6);
- *offset = 2;
+ return 0;
}
-#define LCD_DELAY 1
-
void lcd_write_command(int byte)
{
volatile int i = 0;
@@ -90,3 +91,9 @@ void lcd_write_data(const fb_data* p_bytes, int count)
/* While push fifo is not empty */
while ((DBOP_STAT & (1<<10)) == 0);
}
+
+void lcd_enable_power(bool onoff)
+{
+ ascodec_write(AS3514_DCDC15, onoff ? 1 : 0);
+}
+
diff --git a/firmware/target/arm/as3525/sansa-clipplus/lcd-clip-plus.c b/firmware/target/arm/as3525/sansa-clipplus/lcd-clip-plus.c
index 3faa92da31..ac7b77d772 100644
--- a/firmware/target/arm/as3525/sansa-clipplus/lcd-clip-plus.c
+++ b/firmware/target/arm/as3525/sansa-clipplus/lcd-clip-plus.c
@@ -26,7 +26,7 @@
#include "system.h"
#include "cpu.h"
-void lcd_hw_init(int *offset)
+int lcd_hw_init(void)
{
bitset32(&CGU_PERI, CGU_SSP_CLOCK_ENABLE);
@@ -41,7 +41,7 @@ void lcd_hw_init(int *offset)
GPIOB_PIN(7) = 0;
GPIOA_PIN(5) = (1<<5);
- *offset = GPIOB_PIN(3) ? 0 : 2;
+ return GPIOB_PIN(3) ? 1 : 0;
}
void lcd_write_command(int byte)
@@ -68,3 +68,9 @@ void lcd_write_data(const fb_data* p_bytes, int count)
SSP_DATA = *p_bytes++;
}
}
+
+void lcd_enable_power(bool onoff)
+{
+ (void) onoff;
+}
+
diff --git a/firmware/target/arm/as3525/sansa-clipplus/lcd-clip.h b/firmware/target/arm/as3525/sansa-clipplus/lcd-clip.h
deleted file mode 100644
index 70bafe4212..0000000000
--- a/firmware/target/arm/as3525/sansa-clipplus/lcd-clip.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2008-2009 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 "config.h"
-
-void lcd_hw_init(int *offset) INIT_ATTR;
-static inline void lcd_enable_power(bool onoff)
-{
- (void) onoff;
-}
diff --git a/firmware/target/arm/as3525/sansa-clipv2/lcd-clip.h b/firmware/target/arm/as3525/sansa-clipv2/lcd-clip.h
deleted file mode 100644
index 70bafe4212..0000000000
--- a/firmware/target/arm/as3525/sansa-clipv2/lcd-clip.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/***************************************************************************
- * __________ __ ___.
- * Open \______ \ ____ ____ | | _\_ |__ _______ ___
- * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
- * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
- * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
- * \/ \/ \/ \/ \/
- * $Id$
- *
- * Copyright (C) 2008-2009 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 "config.h"
-
-void lcd_hw_init(int *offset) INIT_ATTR;
-static inline void lcd_enable_power(bool onoff)
-{
- (void) onoff;
-}
diff --git a/firmware/target/arm/as3525/sansa-clipv2/lcd-clipv2.c b/firmware/target/arm/as3525/sansa-clipv2/lcd-clipv2.c
index 14c8b77aec..d7266f72a0 100644
--- a/firmware/target/arm/as3525/sansa-clipv2/lcd-clipv2.c
+++ b/firmware/target/arm/as3525/sansa-clipv2/lcd-clipv2.c
@@ -26,7 +26,9 @@
#include "system.h"
#include "cpu.h"
-void lcd_hw_init(int *offset)
+#define LCD_DELAY 10
+
+int lcd_hw_init(void)
{
/* DBOP initialisation, do what OF does */
bitset32(&CCU_IO, 1<<12); /* ?? */
@@ -39,11 +41,9 @@ void lcd_hw_init(int *offset)
GPIOB_DIR |= (1<<2)|(1<<5);
GPIOB_PIN(5) = (1<<5);
- *offset = 2;
+ return 0;
}
-#define LCD_DELAY 10
-
void lcd_write_command(int byte)
{
volatile int i = 0;
@@ -84,3 +84,9 @@ void lcd_write_data(const fb_data* p_bytes, int count)
/* While push fifo is not empty */
while ((DBOP_STAT & (1<<10)) == 0);
}
+
+void lcd_enable_power(bool onoff)
+{
+ (void) onoff;
+}
+