From 9a471e603ebe77a3aae4692d80ceb32da50c88eb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Sat, 3 Jul 2010 18:50:07 +0000 Subject: [PATCH] Clip+ LCD: support devices with a different controller The new controller framebuffer (different from what is in clipv1/clipv2 and some clip+) has 128 columns, the old has 132 columns and is centered on the screen. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27257 a1c6a512-1295-4272-9138-f99709370657 --- firmware/target/arm/as3525/lcd-ssd1303.c | 25 +++++++++++----------- firmware/target/arm/as3525/sansa-clip/lcd-clip.c | 4 +++- firmware/target/arm/as3525/sansa-clip/lcd-clip.h | 2 +- .../arm/as3525/sansa-clipplus/lcd-clip-plus.c | 5 ++++- .../target/arm/as3525/sansa-clipplus/lcd-clip.h | 2 +- firmware/target/arm/as3525/sansa-clipv2/lcd-clip.h | 2 +- .../target/arm/as3525/sansa-clipv2/lcd-clipv2.c | 4 +++- 7 files changed, 25 insertions(+), 19 deletions(-) diff --git a/firmware/target/arm/as3525/lcd-ssd1303.c b/firmware/target/arm/as3525/lcd-ssd1303.c index 09f2638ff7..e0e0715311 100644 --- a/firmware/target/arm/as3525/lcd-ssd1303.c +++ b/firmware/target/arm/as3525/lcd-ssd1303.c @@ -68,6 +68,7 @@ /** globals **/ static bool display_on; /* used by lcd_enable */ +static int offset; /* column offset */ /*** hardware configuration ***/ @@ -135,10 +136,8 @@ bool lcd_active(void) void lcd_init_device(void) { int i; -#define LCD_FULLSCREEN (128+4) - fb_data p_bytes[LCD_FULLSCREEN]; /* framebuffer used to clear the screen */ - lcd_hw_init(); + lcd_hw_init(&offset); /* Set display clock (divide ratio = 1) and oscillator frequency (1) */ lcd_write_command(LCD_SET_DISPLAY_CLOCK_AND_OSC_FREQ); @@ -181,12 +180,12 @@ void lcd_init_device(void) lcd_write_command (LCD_SET_HIGHER_COLUMN_ADDRESS /*| 0*/); lcd_write_command (LCD_SET_LOWER_COLUMN_ADDRESS /*| 0*/); + fb_data p_bytes[LCD_WIDTH + 2 * offset]; memset(p_bytes, 0, sizeof(p_bytes)); /* fills with 0 : pixel off */ - for(i = 0; i < 8; i++) { lcd_write_command (LCD_SET_PAGE_ADDRESS | (i /*& 0xf*/)); - lcd_write_data(p_bytes, LCD_FULLSCREEN /* overscan */); + lcd_write_data(p_bytes, LCD_WIDTH + 2 * offset); } lcd_enable(true); @@ -208,8 +207,8 @@ void lcd_blit_mono(const unsigned char *data, int x, int by, int width, while (bheight--) { lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); - lcd_write_command (LCD_CNTL_HIGHCOL | (((x+2)>>4) & 0xf)); - lcd_write_command (LCD_CNTL_LOWCOL | ((x+2) & 0xf)); + lcd_write_command (LCD_CNTL_HIGHCOL | (((x+offset)>>4) & 0xf)); + lcd_write_command (LCD_CNTL_LOWCOL | ((x+offset) & 0xf)); lcd_write_data(data, width); data += stride; @@ -234,8 +233,8 @@ void lcd_blit_grey_phase(unsigned char *values, unsigned char *phases, while (bheight--) { lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); - lcd_write_command (LCD_CNTL_HIGHCOL | (((x+2)>>4) & 0xf)); - lcd_write_command (LCD_CNTL_LOWCOL | ((x+2) & 0xf)); + lcd_write_command (LCD_CNTL_HIGHCOL | (((x+offset)>>4) & 0xf)); + lcd_write_command (LCD_CNTL_LOWCOL | ((x+offset) & 0xf)); lcd_grey_data(values, phases, width); @@ -261,8 +260,8 @@ void lcd_update(void) for (y = 0; y < LCD_FBHEIGHT; y++) { lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); - lcd_write_command (LCD_CNTL_HIGHCOL | ((2 >> 4) & 0xf)); - lcd_write_command (LCD_CNTL_LOWCOL | (2 & 0xf)); + lcd_write_command (LCD_CNTL_HIGHCOL | ((offset >> 4) & 0xf)); + lcd_write_command (LCD_CNTL_LOWCOL | (offset & 0xf)); lcd_write_data (lcd_framebuffer[y], LCD_WIDTH); } @@ -292,8 +291,8 @@ void lcd_update_rect(int x, int y, int width, int height) for (; y <= ymax; y++) { lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); - lcd_write_command (LCD_CNTL_HIGHCOL | (((x+2) >> 4) & 0xf)); - lcd_write_command (LCD_CNTL_LOWCOL | ((x+2) & 0xf)); + lcd_write_command (LCD_CNTL_HIGHCOL | (((x+offset) >> 4) & 0xf)); + lcd_write_command (LCD_CNTL_LOWCOL | ((x+offset) & 0xf)); lcd_write_data (&lcd_framebuffer[y][x], width); } diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-clip.c b/firmware/target/arm/as3525/sansa-clip/lcd-clip.c index 29d9259b52..775988cc0e 100644 --- a/firmware/target/arm/as3525/sansa-clip/lcd-clip.c +++ b/firmware/target/arm/as3525/sansa-clip/lcd-clip.c @@ -26,7 +26,7 @@ #include "system.h" #include "cpu.h" -void lcd_hw_init(void) +void lcd_hw_init(int *offset) { /* DBOP initialisation, do what OF does */ CGU_DBOP = (1<<3) | AS3525_DBOP_DIV; @@ -45,6 +45,8 @@ void lcd_hw_init(void) GPIOA_PIN(0) = (1<<0); GPIOA_PIN(4) = 0; GPIOB_PIN(6) = (1<<6); + + *offset = 2; } #define LCD_DELAY 1 diff --git a/firmware/target/arm/as3525/sansa-clip/lcd-clip.h b/firmware/target/arm/as3525/sansa-clip/lcd-clip.h index 7863b853d5..3d4fe60311 100644 --- a/firmware/target/arm/as3525/sansa-clip/lcd-clip.h +++ b/firmware/target/arm/as3525/sansa-clip/lcd-clip.h @@ -22,7 +22,7 @@ #include "config.h" #include "ascodec.h" -void lcd_hw_init(void) INIT_ATTR; +void lcd_hw_init(int *offset) INIT_ATTR; static inline 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 7be0199df1..3faa92da31 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(void) +void lcd_hw_init(int *offset) { bitset32(&CGU_PERI, CGU_SSP_CLOCK_ENABLE); @@ -37,8 +37,11 @@ void lcd_hw_init(void) GPIOA_DIR |= (1<<5); GPIOB_DIR |= (1<<2) | (1<<7); + GPIOB_DIR &= ~(1<<3); GPIOB_PIN(7) = 0; GPIOA_PIN(5) = (1<<5); + + *offset = GPIOB_PIN(3) ? 0 : 2; } void lcd_write_command(int byte) diff --git a/firmware/target/arm/as3525/sansa-clipplus/lcd-clip.h b/firmware/target/arm/as3525/sansa-clipplus/lcd-clip.h index ae0309a949..70bafe4212 100644 --- a/firmware/target/arm/as3525/sansa-clipplus/lcd-clip.h +++ b/firmware/target/arm/as3525/sansa-clipplus/lcd-clip.h @@ -21,7 +21,7 @@ #include "config.h" -void lcd_hw_init(void) INIT_ATTR; +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 index ae0309a949..70bafe4212 100644 --- a/firmware/target/arm/as3525/sansa-clipv2/lcd-clip.h +++ b/firmware/target/arm/as3525/sansa-clipv2/lcd-clip.h @@ -21,7 +21,7 @@ #include "config.h" -void lcd_hw_init(void) INIT_ATTR; +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 f8cfb0b1cf..015eebfd87 100644 --- a/firmware/target/arm/as3525/sansa-clipv2/lcd-clipv2.c +++ b/firmware/target/arm/as3525/sansa-clipv2/lcd-clipv2.c @@ -26,7 +26,7 @@ #include "system.h" #include "cpu.h" -void lcd_hw_init(void) +void lcd_hw_init(int *offset) { /* DBOP initialisation, do what OF does */ CCU_IO |= (1<<12); /* ?? */ @@ -38,6 +38,8 @@ void lcd_hw_init(void) GPIOB_DIR |= (1<<2)|(1<<5); GPIOB_PIN(5) = (1<<5); + + *offset = 2; } #define LCD_DELAY 10 -- 2.11.4.GIT