1
0
Fork 0
forked from len0rd/rockbox

Add auto-detection of Nano 2G LCD type, and an initial attempt at lcd_update() for the second lcd type. This lcd_update works, but not reliably.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@21905 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Dave Chapman 2009-07-16 18:03:09 +00:00
parent f8ec7e4ad4
commit 715d8c63d9
2 changed files with 64 additions and 23 deletions

View file

@ -459,6 +459,10 @@
#define PDAT7 (*(REG32_PTR_T)(0x3CF00074)) /* The data register for port 7 */ #define PDAT7 (*(REG32_PTR_T)(0x3CF00074)) /* The data register for port 7 */
#define PCON10 (*(REG32_PTR_T)(0x3CF000A0)) /* Configures the pins of port 10 */ #define PCON10 (*(REG32_PTR_T)(0x3CF000A0)) /* Configures the pins of port 10 */
#define PDAT10 (*(REG32_PTR_T)(0x3CF000A4)) /* The data register for port 10 */ #define PDAT10 (*(REG32_PTR_T)(0x3CF000A4)) /* The data register for port 10 */
#define PCON13 (*(REG32_PTR_T)(0x3CF000D0)) /* Configures the pins of port 13 */
#define PDAT13 (*(REG32_PTR_T)(0x3CF000D4)) /* The data register for port 13 */
#define PCON14 (*(REG32_PTR_T)(0x3CF000E0)) /* Configures the pins of port 14 */
#define PDAT14 (*(REG32_PTR_T)(0x3CF000E4)) /* The data register for port 14 */
#define PCON_ASRAM (*(REG32_PTR_T)(0x3CF000F0)) /* Configures the pins of port nor flash */ #define PCON_ASRAM (*(REG32_PTR_T)(0x3CF000F0)) /* Configures the pins of port nor flash */
#define PCON_SDRAM (*(REG32_PTR_T)(0x3CF000F4)) /* Configures the pins of port sdram */ #define PCON_SDRAM (*(REG32_PTR_T)(0x3CF000F4)) /* Configures the pins of port sdram */
#define PCON11 (*(REG32_PTR_T)(0x3CF000F8)) /* Configures the pins of port 11 */ #define PCON11 (*(REG32_PTR_T)(0x3CF000F8)) /* Configures the pins of port 11 */

View file

@ -40,9 +40,9 @@ static void s5l_lcd_write_data(int data)
while (LCD_STATUS&0x10); while (LCD_STATUS&0x10);
} }
/** globals **/ /** globals **/
static int lcd_type;
static int xoffset; /* needed for flip */ static int xoffset; /* needed for flip */
/*** hardware configuration ***/ /*** hardware configuration ***/
@ -89,6 +89,15 @@ void lcd_on(void)
/* LCD init */ /* LCD init */
void lcd_init_device(void) void lcd_init_device(void)
{ {
/* Detect lcd type */
PCON13 &= ~0xf; /* Set pin 0 to input */
PCON14 &= ~0xf0; /* Set pin 1 to input */
if (((PDAT13 & 1) == 0) && ((PDAT14 & 2) == 2))
lcd_type = 0;
else
lcd_type = 1;
} }
@ -127,36 +136,64 @@ void lcd_update(void) ICODE_ATTR;
void lcd_update(void) void lcd_update(void)
{ {
int x,y; int x,y;
fb_data* p; fb_data* p = &lcd_framebuffer[0][0];
fb_data pixel; fb_data pixel;
s5l_lcd_write_cmd(0x3a); if (lcd_type==0) {
s5l_lcd_write_data(0x65); s5l_lcd_write_cmd(0x50);
s5l_lcd_write_data(0); /* Start column */
s5l_lcd_write_cmd(0x51);
s5l_lcd_write_data(LCD_WIDTH-1); /* End column */
s5l_lcd_write_cmd(0x52);
s5l_lcd_write_data(0); /* Start row */
s5l_lcd_write_cmd(0x53);
s5l_lcd_write_data(LCD_HEIGHT-1); /* End row */
s5l_lcd_write_cmd(0x2a); s5l_lcd_write_cmd(0x20);
s5l_lcd_write_data(0); s5l_lcd_write_data(0);
s5l_lcd_write_data(0); s5l_lcd_write_cmd(0x21);
s5l_lcd_write_data(0); s5l_lcd_write_data(0);
s5l_lcd_write_data(LCD_WIDTH-1); s5l_lcd_write_cmd(0x22);
s5l_lcd_write_cmd(0x2b); /* Copy display bitmap to hardware */
s5l_lcd_write_data(0); for (y = 0; y < LCD_HEIGHT; y++) {
s5l_lcd_write_data(0); for (x = 0; x < LCD_WIDTH; x++) {
s5l_lcd_write_data(0); pixel = *(p++);
s5l_lcd_write_data(LCD_HEIGHT-1);
s5l_lcd_write_cmd(0x2c); while (LCD_STATUS&0x10);
/* Copy display bitmap to hardware */ LCD_WDATA = pixel & 0xff;
LCD_WDATA = (pixel & 0xff00) >> 8;
}
}
} else {
s5l_lcd_write_cmd(0x3a);
s5l_lcd_write_data(0x65);
p = &lcd_framebuffer[0][0]; s5l_lcd_write_cmd(0x2a);
for (y = 0; y < LCD_HEIGHT; y++) { s5l_lcd_write_data(0); /* Start column, high byte */
for (x = 0; x < LCD_WIDTH; x++) { s5l_lcd_write_data(0); /* Start column. low byte */
pixel = *(p++); s5l_lcd_write_data(0); /* End column, high byte */
s5l_lcd_write_data(LCD_WIDTH-1); /* End column, low byte */
while (LCD_STATUS&0x10); s5l_lcd_write_cmd(0x2b);
LCD_WDATA = (pixel & 0xff00) >> 8; s5l_lcd_write_data(0); /* Start row, high byte */
LCD_WDATA = pixel & 0xff; s5l_lcd_write_data(0); /* Start row, low byte */
s5l_lcd_write_data(0); /* End row, high byte */
s5l_lcd_write_data(LCD_HEIGHT-1); /* End row, low byte */
s5l_lcd_write_cmd(0x2c);
/* Copy display bitmap to hardware */
for (y = 0; y < LCD_HEIGHT; y++) {
for (x = 0; x < LCD_WIDTH; x++) {
pixel = *(p++);
while (LCD_STATUS&0x10);
LCD_WDATA = (pixel & 0xff00) >> 8;
LCD_WDATA = pixel & 0xff;
}
} }
} }