Index: firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c =================================================================== --- firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c (revision 28794) +++ firmware/target/arm/s5l8700/ipodnano2g/lcd-nano2g.c (working copy) @@ -67,149 +67,82 @@ #ifdef HAVE_LCD_SLEEP #define SLEEP 0 -#define CMD8 1 -#define CMD16 2 -#define DATA8 3 -#define DATA16 4 +#define CMD16 1 +#define DATA16 2 unsigned short lcd_init_sequence_0[] = { - CMD16, 0x00a4, - DATA16, 0x0001, + CMD16, 0x00a4, DATA16, 0x0001, SLEEP, 0x0000, - CMD16, 0x0001, - DATA16, 0x0100, - CMD16, 0x0002, - DATA16, 0x0300, - CMD16, 0x0003, - DATA16, 0x1230, - CMD16, 0x0008, - DATA16, 0x0404, - CMD16, 0x0008, - DATA16, 0x0404, - CMD16, 0x000e, - DATA16, 0x0010, - CMD16, 0x0070, - DATA16, 0x1000, - CMD16, 0x0071, - DATA16, 0x0001, - CMD16, 0x0030, - DATA16, 0x0002, - CMD16, 0x0031, - DATA16, 0x0400, - CMD16, 0x0032, - DATA16, 0x0007, - CMD16, 0x0033, - DATA16, 0x0500, - CMD16, 0x0034, - DATA16, 0x0007, - CMD16, 0x0035, - DATA16, 0x0703, - CMD16, 0x0036, - DATA16, 0x0507, - CMD16, 0x0037, - DATA16, 0x0005, - CMD16, 0x0038, - DATA16, 0x0407, - CMD16, 0x0039, - DATA16, 0x000e, - CMD16, 0x0040, - DATA16, 0x0202, - CMD16, 0x0041, - DATA16, 0x0003, - CMD16, 0x0042, - DATA16, 0x0000, - CMD16, 0x0043, - DATA16, 0x0200, - CMD16, 0x0044, - DATA16, 0x0707, - CMD16, 0x0045, - DATA16, 0x0407, - CMD16, 0x0046, - DATA16, 0x0505, - CMD16, 0x0047, - DATA16, 0x0002, - CMD16, 0x0048, - DATA16, 0x0004, - CMD16, 0x0049, - DATA16, 0x0004, - CMD16, 0x0060, - DATA16, 0x0202, - CMD16, 0x0061, - DATA16, 0x0003, - CMD16, 0x0062, - DATA16, 0x0000, - CMD16, 0x0063, - DATA16, 0x0200, - CMD16, 0x0064, - DATA16, 0x0707, - CMD16, 0x0065, - DATA16, 0x0407, - CMD16, 0x0066, - DATA16, 0x0505, - CMD16, 0x0068, - DATA16, 0x0004, - CMD16, 0x0069, - DATA16, 0x0004, - CMD16, 0x0007, - DATA16, 0x0001, - CMD16, 0x0018, - DATA16, 0x0001, - CMD16, 0x0010, - DATA16, 0x1690, - CMD16, 0x0011, - DATA16, 0x0100, - CMD16, 0x0012, - DATA16, 0x0117, - CMD16, 0x0013, - DATA16, 0x0f80, - CMD16, 0x0012, - DATA16, 0x0137, - CMD16, 0x0020, - DATA16, 0x0000, - CMD16, 0x0021, - DATA16, 0x0000, - CMD16, 0x0050, - DATA16, 0x0000, - CMD16, 0x0051, - DATA16, 0x00af, - CMD16, 0x0052, - DATA16, 0x0000, - CMD16, 0x0053, - DATA16, 0x0083, - CMD16, 0x0090, - DATA16, 0x0003, - CMD16, 0x0091, - DATA16, 0x0000, - CMD16, 0x0092, - DATA16, 0x0101, - CMD16, 0x0098, - DATA16, 0x0400, - CMD16, 0x0099, - DATA16, 0x1302, - CMD16, 0x009a, - DATA16, 0x0202, - CMD16, 0x009b, - DATA16, 0x0200, + CMD16, 0x0001, DATA16, 0x0100, + CMD16, 0x0002, DATA16, 0x0300, + CMD16, 0x0003, DATA16, 0x1230, + CMD16, 0x0008, DATA16, 0x0404, + CMD16, 0x0008, DATA16, 0x0404, + CMD16, 0x000e, DATA16, 0x0010, + CMD16, 0x0070, DATA16, 0x1000, + CMD16, 0x0071, DATA16, 0x0001, + CMD16, 0x0030, DATA16, 0x0002, + CMD16, 0x0031, DATA16, 0x0400, + CMD16, 0x0032, DATA16, 0x0007, + CMD16, 0x0033, DATA16, 0x0500, + CMD16, 0x0034, DATA16, 0x0007, + CMD16, 0x0035, DATA16, 0x0703, + CMD16, 0x0036, DATA16, 0x0507, + CMD16, 0x0037, DATA16, 0x0005, + CMD16, 0x0038, DATA16, 0x0407, + CMD16, 0x0039, DATA16, 0x000e, + CMD16, 0x0040, DATA16, 0x0202, + CMD16, 0x0041, DATA16, 0x0003, + CMD16, 0x0042, DATA16, 0x0000, + CMD16, 0x0043, DATA16, 0x0200, + CMD16, 0x0044, DATA16, 0x0707, + CMD16, 0x0045, DATA16, 0x0407, + CMD16, 0x0046, DATA16, 0x0505, + CMD16, 0x0047, DATA16, 0x0002, + CMD16, 0x0048, DATA16, 0x0004, + CMD16, 0x0049, DATA16, 0x0004, + CMD16, 0x0060, DATA16, 0x0202, + CMD16, 0x0061, DATA16, 0x0003, + CMD16, 0x0062, DATA16, 0x0000, + CMD16, 0x0063, DATA16, 0x0200, + CMD16, 0x0064, DATA16, 0x0707, + CMD16, 0x0065, DATA16, 0x0407, + CMD16, 0x0066, DATA16, 0x0505, + CMD16, 0x0068, DATA16, 0x0004, + CMD16, 0x0069, DATA16, 0x0004, + CMD16, 0x0007, DATA16, 0x0001, + CMD16, 0x0018, DATA16, 0x0001, + CMD16, 0x0010, DATA16, 0x1690, + CMD16, 0x0011, DATA16, 0x0100, + CMD16, 0x0012, DATA16, 0x0117, + CMD16, 0x0013, DATA16, 0x0f80, + CMD16, 0x0012, DATA16, 0x0137, + CMD16, 0x0020, DATA16, 0x0000, + CMD16, 0x0021, DATA16, 0x0000, + CMD16, 0x0050, DATA16, 0x0000, + CMD16, 0x0051, DATA16, 0x00af, + CMD16, 0x0052, DATA16, 0x0000, + CMD16, 0x0053, DATA16, 0x0083, + CMD16, 0x0090, DATA16, 0x0003, + CMD16, 0x0091, DATA16, 0x0000, + CMD16, 0x0092, DATA16, 0x0101, + CMD16, 0x0098, DATA16, 0x0400, + CMD16, 0x0099, DATA16, 0x1302, + CMD16, 0x009a, DATA16, 0x0202, + CMD16, 0x009b, DATA16, 0x0200, SLEEP, 0x0000, - CMD16, 0x0007, - DATA16, 0x0021, - CMD16, 0x0012, - DATA16, 0x0137, + CMD16, 0x0007, DATA16, 0x0021, + CMD16, 0x0012, DATA16, 0x0137, SLEEP, 0x0000, - CMD16, 0x0007, - DATA16, 0x0021, - CMD16, 0x0012, - DATA16, 0x1137, + CMD16, 0x0007, DATA16, 0x0021, + CMD16, 0x0012, DATA16, 0x1137, SLEEP, 0x0000, - CMD16, 0x0007, - DATA16, 0x0233, + CMD16, 0x0007, DATA16, 0x0233, }; unsigned short lcd_init_sequence_1[] = { - CMD8, 0x11, - DATA16, 0x00, - CMD8, 0x29, - DATA16, 0x00, + CMD16, 0x0011, DATA16, 0x0000, + CMD16, 0x0029, DATA16, 0x0000, }; @@ -219,14 +152,10 @@ static inline void s5l_lcd_write_cmd_data(int cmd, int data) { while (LCD_STATUS & 0x10); - LCD_WCMD = cmd >> 8; - while (LCD_STATUS & 0x10); - LCD_WCMD = cmd & 0xff; + LCD_WCMD = cmd; while (LCD_STATUS & 0x10); - LCD_WDATA = data >> 8; - while (LCD_STATUS & 0x10); - LCD_WDATA = data & 0xff; + LCD_WDATA = data; } static inline void s5l_lcd_write_cmd(unsigned short cmd) @@ -235,28 +164,12 @@ LCD_WCMD = cmd; } -static inline void s5l_lcd_write_wcmd(unsigned short cmd) -{ - while (LCD_STATUS & 0x10); - LCD_WCMD = cmd >> 8; - while (LCD_STATUS & 0x10); - LCD_WCMD = cmd & 0xff; -} - static inline void s5l_lcd_write_data(unsigned short data) { while (LCD_STATUS & 0x10); - LCD_WDATA = data & 0xff; + LCD_WDATA = data; } -static inline void s5l_lcd_write_wdata(unsigned short data) -{ - while (LCD_STATUS & 0x10); - LCD_WDATA = data >> 8; - while (LCD_STATUS & 0x10); - LCD_WDATA = data & 0xff; -} - /*** hardware configuration ***/ int lcd_default_contrast(void) @@ -331,18 +244,12 @@ { switch(lcd_init_sequence[i]) { - case CMD8: + case CMD16: s5l_lcd_write_cmd(lcd_init_sequence[i+1]); break; - case DATA8: + case DATA16: s5l_lcd_write_data(lcd_init_sequence[i+1]); break; - case CMD16: - s5l_lcd_write_wcmd(lcd_init_sequence[i+1]); - break; - case DATA16: - s5l_lcd_write_wdata(lcd_init_sequence[i+1]); - break; case SLEEP: sleep(lcd_init_sequence[i+1]); break; @@ -367,24 +274,24 @@ if (lcd_type == 0) { - s5l_lcd_write_cmd_data(R_DISPLAY_CONTROL_1, 0x232); - s5l_lcd_write_cmd_data(R_POWER_CONTROL_3, 0x1137); - s5l_lcd_write_cmd_data(R_DISPLAY_CONTROL_1, 0x201); - s5l_lcd_write_cmd_data(R_POWER_CONTROL_3, 0x137); - s5l_lcd_write_cmd_data(R_DISPLAY_CONTROL_1, 0x200); - s5l_lcd_write_cmd_data(R_POWER_CONTROL_1, 0x680); - s5l_lcd_write_cmd_data(R_POWER_CONTROL_2, 0x160); - s5l_lcd_write_cmd_data(R_POWER_CONTROL_3, 0x127); - s5l_lcd_write_cmd_data(R_POWER_CONTROL_1, 0x600); + s5l_lcd_write_cmd_data(R_DISPLAY_CONTROL_1, 0x0232); + s5l_lcd_write_cmd_data(R_POWER_CONTROL_3 , 0x1137); + s5l_lcd_write_cmd_data(R_DISPLAY_CONTROL_1, 0x0201); + s5l_lcd_write_cmd_data(R_POWER_CONTROL_3 , 0x0137); + s5l_lcd_write_cmd_data(R_DISPLAY_CONTROL_1, 0x0200); + s5l_lcd_write_cmd_data(R_POWER_CONTROL_1 , 0x0680); + s5l_lcd_write_cmd_data(R_POWER_CONTROL_2 , 0x0160); + s5l_lcd_write_cmd_data(R_POWER_CONTROL_3 , 0x0127); + s5l_lcd_write_cmd_data(R_POWER_CONTROL_1 , 0x0600); } else { s5l_lcd_write_cmd(R_DISPLAY_OFF); - s5l_lcd_write_wdata(0); - s5l_lcd_write_wdata(0); + s5l_lcd_write_data(0); + s5l_lcd_write_data(0); s5l_lcd_write_cmd(R_SLEEP_IN); - s5l_lcd_write_wdata(0); - s5l_lcd_write_wdata(0); + s5l_lcd_write_data(0); + s5l_lcd_write_data(0); } PWRCONEXT |= 0x80; @@ -409,6 +316,8 @@ lcd_type = 0; /* Similar to ILI9320 - aka "type 2" */ else lcd_type = 1; /* Similar to LDS176 - aka "type 7" */ + + LCD_CON |= 0x100; /* use 16 bit bus width, little endian */ lcd_ispowered = true; } @@ -417,10 +326,7 @@ static inline void lcd_write_pixel(fb_data pixel) { - while (LCD_STATUS & 0x10); - LCD_WDATA = (pixel & 0xff00) >> 8; - while (LCD_STATUS & 0x10); - LCD_WDATA = pixel & 0xff; + LCD_WDATA = pixel; } /* Update the display. @@ -435,9 +341,10 @@ void lcd_update_rect(int, int, int, int) ICODE_ATTR; void lcd_update_rect(int x, int y, int width, int height) { - int xx,yy; int y0, x0, y1, x1; fb_data* p; + + width = (width + 1) & ~1; /* ensure width is even */ x0 = x; /* start horiz */ y0 = y; /* start vert */ @@ -457,25 +364,39 @@ s5l_lcd_write_cmd(R_WRITE_DATA_TO_GRAM); } else { s5l_lcd_write_cmd(R_COLUMN_ADDR_SET); - s5l_lcd_write_wdata(x0); /* Start column */ - s5l_lcd_write_wdata(x1); /* End column */ + s5l_lcd_write_data(x0); /* Start column */ + s5l_lcd_write_data(x1); /* End column */ s5l_lcd_write_cmd(R_ROW_ADDR_SET); - s5l_lcd_write_wdata(y0); /* Start row */ - s5l_lcd_write_wdata(y1); /* End row */ + s5l_lcd_write_data(y0); /* Start row */ + s5l_lcd_write_data(y1); /* End row */ s5l_lcd_write_cmd(R_MEMORY_WRITE); } - /* Copy display bitmap to hardware */ p = &lcd_framebuffer[y0][x0]; - yy = height; - for (yy = y0; yy <= y1; yy++) { - for (xx = x0; xx <= x1; xx++) { + if (LCD_WIDTH == width) + { + x1 = height*LCD_WIDTH/4; + do { + while (LCD_STATUS & 0x08); /* wait while FIFO is half full */ lcd_write_pixel(*(p++)); - } - p += LCD_WIDTH - width; + lcd_write_pixel(*(p++)); + lcd_write_pixel(*(p++)); + lcd_write_pixel(*(p++)); + } while (--x1 > 0); + } else { + y1 = height; + do { + x1 = width/2; /* width is forced to even to allow speed up */ + do { + while (LCD_STATUS & 0x08); /* wait while FIFO is half full */ + lcd_write_pixel(*(p++)); + lcd_write_pixel(*(p++)); + } while (--x1 > 0 ); + p += LCD_WIDTH - width; + } while (--y1 > 0 ); } } @@ -540,12 +461,12 @@ s5l_lcd_write_cmd(R_WRITE_DATA_TO_GRAM); } else { s5l_lcd_write_cmd(R_COLUMN_ADDR_SET); - s5l_lcd_write_wdata(x0); /* Start column */ - s5l_lcd_write_wdata(x1); /* End column */ + s5l_lcd_write_data(x0); /* Start column */ + s5l_lcd_write_data(x1); /* End column */ s5l_lcd_write_cmd(R_ROW_ADDR_SET); - s5l_lcd_write_wdata(y0); /* Start row */ - s5l_lcd_write_wdata(y1); /* End row */ + s5l_lcd_write_data(y0); /* Start row */ + s5l_lcd_write_data(y1); /* End row */ s5l_lcd_write_cmd(R_MEMORY_WRITE); } @@ -616,6 +537,7 @@ } /* output 2 pixels */ + while (LCD_STATUS & 0x08); /* wait while FIFO is half full */ lcd_write_pixel((red1 << 11) | (green1 << 5) | blue1); lcd_write_pixel((red2 << 11) | (green2 << 5) | blue2); }