From 715d8c63d9a051b2ab7ab6ac27639d090a1823f1 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Thu, 16 Jul 2009 18:03:09 +0000 Subject: 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 --- .../target/arm/s5l8700/ipodnano2g/lcd-nano2g.c | 95 +++++++++++++++------- 1 file changed, 66 insertions(+), 29 deletions(-) (limited to 'firmware/target/arm/s5l8700') diff --git a/firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c b/firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c index 74f2fca383..ad2e356b5e 100644 --- a/firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c +++ b/firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c @@ -40,9 +40,9 @@ static void s5l_lcd_write_data(int data) while (LCD_STATUS&0x10); } - /** globals **/ +static int lcd_type; static int xoffset; /* needed for flip */ /*** hardware configuration ***/ @@ -89,6 +89,15 @@ void lcd_on(void) /* LCD init */ 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) { int x,y; - fb_data* p; + fb_data* p = &lcd_framebuffer[0][0]; fb_data pixel; - s5l_lcd_write_cmd(0x3a); - s5l_lcd_write_data(0x65); - - s5l_lcd_write_cmd(0x2a); - s5l_lcd_write_data(0); - s5l_lcd_write_data(0); - s5l_lcd_write_data(0); - s5l_lcd_write_data(LCD_WIDTH-1); - - s5l_lcd_write_cmd(0x2b); - s5l_lcd_write_data(0); - s5l_lcd_write_data(0); - s5l_lcd_write_data(0); - s5l_lcd_write_data(LCD_HEIGHT-1); - - s5l_lcd_write_cmd(0x2c); - - /* Copy display bitmap to hardware */ - - p = &lcd_framebuffer[0][0]; - 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; + if (lcd_type==0) { + 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(0x20); + s5l_lcd_write_data(0); + s5l_lcd_write_cmd(0x21); + s5l_lcd_write_data(0); + s5l_lcd_write_cmd(0x22); + + /* 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 & 0xff; + LCD_WDATA = (pixel & 0xff00) >> 8; + } + } + } else { + s5l_lcd_write_cmd(0x3a); + s5l_lcd_write_data(0x65); + + s5l_lcd_write_cmd(0x2a); + s5l_lcd_write_data(0); /* Start column, high byte */ + s5l_lcd_write_data(0); /* Start column. low byte */ + s5l_lcd_write_data(0); /* End column, high byte */ + s5l_lcd_write_data(LCD_WIDTH-1); /* End column, low byte */ + + s5l_lcd_write_cmd(0x2b); + s5l_lcd_write_data(0); /* Start row, high byte */ + 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; + } } } -- cgit v1.2.3