diff options
Diffstat (limited to 'firmware/target/arm/ipod')
-rw-r--r-- | firmware/target/arm/ipod/lcd-color_nano.c | 100 | ||||
-rw-r--r-- | firmware/target/arm/ipod/lcd-gray.c | 4 |
2 files changed, 40 insertions, 64 deletions
diff --git a/firmware/target/arm/ipod/lcd-color_nano.c b/firmware/target/arm/ipod/lcd-color_nano.c index c17b99b859..f3a5819d6b 100644 --- a/firmware/target/arm/ipod/lcd-color_nano.c +++ b/firmware/target/arm/ipod/lcd-color_nano.c | |||
@@ -30,15 +30,6 @@ | |||
30 | #include "system.h" | 30 | #include "system.h" |
31 | #include "hwcompat.h" | 31 | #include "hwcompat.h" |
32 | 32 | ||
33 | /* check if number of useconds has past */ | ||
34 | static inline bool timer_check(int clock_start, int usecs) | ||
35 | { | ||
36 | return ((int)(USEC_TIMER - clock_start)) >= usecs; | ||
37 | } | ||
38 | |||
39 | #define IPOD_LCD_BASE 0x70008a0c | ||
40 | #define IPOD_LCD_BUSY_MASK 0x80000000 | ||
41 | |||
42 | /* LCD command codes for HD66789R */ | 33 | /* LCD command codes for HD66789R */ |
43 | #define LCD_CNTL_RAM_ADDR_SET 0x21 | 34 | #define LCD_CNTL_RAM_ADDR_SET 0x21 |
44 | #define LCD_CNTL_WRITE_TO_GRAM 0x22 | 35 | #define LCD_CNTL_WRITE_TO_GRAM 0x22 |
@@ -48,39 +39,25 @@ static inline bool timer_check(int clock_start, int usecs) | |||
48 | /*** globals ***/ | 39 | /*** globals ***/ |
49 | int lcd_type = 1; /* 0 = "old" Color/Photo, 1 = "new" Color & Nano */ | 40 | int lcd_type = 1; /* 0 = "old" Color/Photo, 1 = "new" Color & Nano */ |
50 | 41 | ||
51 | static void lcd_wait_write(void) | 42 | static inline void lcd_wait_write(void) |
52 | { | ||
53 | if ((inl(IPOD_LCD_BASE) & IPOD_LCD_BUSY_MASK) != 0) { | ||
54 | int start = USEC_TIMER; | ||
55 | |||
56 | do { | ||
57 | if ((inl(IPOD_LCD_BASE) & IPOD_LCD_BUSY_MASK) == 0) break; | ||
58 | } while (timer_check(start, 1000) == 0); | ||
59 | } | ||
60 | } | ||
61 | |||
62 | static void lcd_send_lo(int v) | ||
63 | { | ||
64 | lcd_wait_write(); | ||
65 | outl(v | 0x80000000, IPOD_LCD_BASE); | ||
66 | } | ||
67 | |||
68 | static void lcd_send_hi(int v) | ||
69 | { | 43 | { |
70 | lcd_wait_write(); | 44 | while (LCD2_PORT & LCD2_BUSY_MASK); |
71 | outl(v | 0x81000000, IPOD_LCD_BASE); | ||
72 | } | 45 | } |
73 | 46 | ||
74 | static void lcd_cmd_data(int cmd, int data) | 47 | static void lcd_cmd_data(unsigned cmd, unsigned data) |
75 | { | 48 | { |
76 | if (lcd_type == 0) { | 49 | if (lcd_type == 0) { /* 16 bit transfers */ |
77 | lcd_send_lo(cmd); | 50 | lcd_wait_write(); |
78 | lcd_send_lo(data); | 51 | LCD2_PORT = LCD2_CMD_MASK | cmd; |
52 | lcd_wait_write(); | ||
53 | LCD2_PORT = LCD2_CMD_MASK | data; | ||
79 | } else { | 54 | } else { |
80 | lcd_send_lo(0x0); | 55 | lcd_wait_write(); |
81 | lcd_send_lo(cmd); | 56 | LCD2_PORT = LCD2_CMD_MASK; |
82 | lcd_send_hi((data >> 8) & 0xff); | 57 | LCD2_PORT = LCD2_CMD_MASK | cmd; |
83 | lcd_send_hi(data & 0xff); | 58 | lcd_wait_write(); |
59 | LCD2_PORT = LCD2_DATA_MASK | (data >> 8); | ||
60 | LCD2_PORT = LCD2_DATA_MASK | (data & 0xff); | ||
84 | } | 61 | } |
85 | } | 62 | } |
86 | 63 | ||
@@ -229,8 +206,9 @@ void lcd_yuv_blit(unsigned char * const src[3], | |||
229 | lcd_cmd_data(LCD_CNTL_RAM_ADDR_SET, ((x0 << 8) | y0)); | 206 | lcd_cmd_data(LCD_CNTL_RAM_ADDR_SET, ((x0 << 8) | y0)); |
230 | 207 | ||
231 | /* start drawing */ | 208 | /* start drawing */ |
232 | lcd_send_lo(0x0); | 209 | lcd_wait_write(); |
233 | lcd_send_lo(LCD_CNTL_WRITE_TO_GRAM); | 210 | LCD2_PORT = LCD2_CMD_MASK; |
211 | LCD2_PORT = (LCD2_CMD_MASK|LCD_CNTL_WRITE_TO_GRAM); | ||
234 | } | 212 | } |
235 | 213 | ||
236 | const int stride_div_csub_x = stride/CSUB_X; | 214 | const int stride_div_csub_x = stride/CSUB_X; |
@@ -257,8 +235,8 @@ void lcd_yuv_blit(unsigned char * const src[3], | |||
257 | fb_data pixel1,pixel2; | 235 | fb_data pixel1,pixel2; |
258 | 236 | ||
259 | if (h==0) { | 237 | if (h==0) { |
260 | while ((inl(0x70008a20) & 0x4000000) == 0); | 238 | while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_READY)); |
261 | outl(0x0, 0x70008a24); | 239 | LCD2_BLOCK_CONFIG = 0; |
262 | 240 | ||
263 | if (height == 0) break; | 241 | if (height == 0) break; |
264 | 242 | ||
@@ -272,9 +250,9 @@ void lcd_yuv_blit(unsigned char * const src[3], | |||
272 | } | 250 | } |
273 | 251 | ||
274 | height -= h; | 252 | height -= h; |
275 | outl(0x10000080, 0x70008a20); | 253 | LCD2_BLOCK_CTRL = 0x10000080; |
276 | outl((pixels_to_write - 1) | 0xc0010000, 0x70008a24); | 254 | LCD2_BLOCK_CONFIG = 0xc0010000 | (pixels_to_write - 1); |
277 | outl(0x34000000, 0x70008a20); | 255 | LCD2_BLOCK_CTRL = 0x34000000; |
278 | } | 256 | } |
279 | 257 | ||
280 | do | 258 | do |
@@ -368,10 +346,10 @@ void lcd_yuv_blit(unsigned char * const src[3], | |||
368 | bbits = blue2 >> 16 ; | 346 | bbits = blue2 >> 16 ; |
369 | pixel2 = swap16((rbits << 11) | (gbits << 5) | bbits); | 347 | pixel2 = swap16((rbits << 11) | (gbits << 5) | bbits); |
370 | 348 | ||
371 | while ((inl(0x70008a20) & 0x1000000) == 0); | 349 | while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_TXOK)); |
372 | 350 | ||
373 | /* output 2 pixels */ | 351 | /* output 2 pixels */ |
374 | outl((pixel2<<16)|pixel1, 0x70008b00); | 352 | LCD2_BLOCK_DATA = (pixel2 << 16) | pixel1; |
375 | } | 353 | } |
376 | while (ysrc < row_end); | 354 | while (ysrc < row_end); |
377 | 355 | ||
@@ -379,8 +357,8 @@ void lcd_yuv_blit(unsigned char * const src[3], | |||
379 | h--; | 357 | h--; |
380 | } | 358 | } |
381 | 359 | ||
382 | while ((inl(0x70008a20) & 0x4000000) == 0); | 360 | while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_READY)); |
383 | outl(0x0, 0x70008a24); | 361 | LCD2_BLOCK_CONFIG = 0; |
384 | } | 362 | } |
385 | 363 | ||
386 | 364 | ||
@@ -389,8 +367,7 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
389 | { | 367 | { |
390 | int y0, x0, y1, x1; | 368 | int y0, x0, y1, x1; |
391 | int newx,newwidth; | 369 | int newx,newwidth; |
392 | 370 | unsigned long *addr; | |
393 | unsigned long *addr = (unsigned long *)lcd_framebuffer; | ||
394 | 371 | ||
395 | /* Ensure x and width are both even - so we can read 32-bit aligned | 372 | /* Ensure x and width are both even - so we can read 32-bit aligned |
396 | data from lcd_framebuffer */ | 373 | data from lcd_framebuffer */ |
@@ -449,8 +426,9 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
449 | lcd_cmd_data(LCD_CNTL_RAM_ADDR_SET, ((x0 << 8) | y0)); | 426 | lcd_cmd_data(LCD_CNTL_RAM_ADDR_SET, ((x0 << 8) | y0)); |
450 | 427 | ||
451 | /* start drawing */ | 428 | /* start drawing */ |
452 | lcd_send_lo(0x0); | 429 | lcd_wait_write(); |
453 | lcd_send_lo(LCD_CNTL_WRITE_TO_GRAM); | 430 | LCD2_PORT = LCD2_CMD_MASK; |
431 | LCD2_PORT = (LCD2_CMD_MASK|LCD_CNTL_WRITE_TO_GRAM); | ||
454 | } | 432 | } |
455 | 433 | ||
456 | addr = (unsigned long*)&lcd_framebuffer[y][x]; | 434 | addr = (unsigned long*)&lcd_framebuffer[y][x]; |
@@ -468,28 +446,26 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
468 | pixels_to_write = (width * h) * 2; | 446 | pixels_to_write = (width * h) * 2; |
469 | } | 447 | } |
470 | 448 | ||
471 | outl(0x10000080, 0x70008a20); | 449 | LCD2_BLOCK_CTRL = 0x10000080; |
472 | outl((pixels_to_write - 1) | 0xc0010000, 0x70008a24); | 450 | LCD2_BLOCK_CONFIG = 0xc0010000 | (pixels_to_write - 1); |
473 | outl(0x34000000, 0x70008a20); | 451 | LCD2_BLOCK_CTRL = 0x34000000; |
474 | 452 | ||
475 | /* for each row */ | 453 | /* for each row */ |
476 | for (r = 0; r < h; r++) { | 454 | for (r = 0; r < h; r++) { |
477 | /* for each column */ | 455 | /* for each column */ |
478 | for (c = 0; c < width; c += 2) { | 456 | for (c = 0; c < width; c += 2) { |
479 | while ((inl(0x70008a20) & 0x1000000) == 0); | 457 | while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_TXOK)); |
480 | 458 | ||
481 | /* output 2 pixels */ | 459 | /* output 2 pixels */ |
482 | outl(*(addr++), 0x70008b00); | 460 | LCD2_BLOCK_DATA = *addr++; |
483 | } | 461 | } |
484 | |||
485 | addr += (LCD_WIDTH - width)/2; | 462 | addr += (LCD_WIDTH - width)/2; |
486 | } | 463 | } |
487 | 464 | ||
488 | while ((inl(0x70008a20) & 0x4000000) == 0); | 465 | while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_READY)); |
489 | 466 | LCD2_BLOCK_CONFIG = 0; | |
490 | outl(0x0, 0x70008a24); | ||
491 | 467 | ||
492 | height = height - h; | 468 | height -= h; |
493 | } | 469 | } |
494 | } | 470 | } |
495 | 471 | ||
diff --git a/firmware/target/arm/ipod/lcd-gray.c b/firmware/target/arm/ipod/lcd-gray.c index bea1ed46ed..c375d95ea6 100644 --- a/firmware/target/arm/ipod/lcd-gray.c +++ b/firmware/target/arm/ipod/lcd-gray.c | |||
@@ -84,7 +84,7 @@ static const unsigned char dibits[16] ICONST_ATTR = { | |||
84 | /* wait for LCD with timeout */ | 84 | /* wait for LCD with timeout */ |
85 | static inline void lcd_wait_write(void) | 85 | static inline void lcd_wait_write(void) |
86 | { | 86 | { |
87 | while (LCD1_BASE & LCD1_BUSY_MASK); | 87 | while (LCD1_CONTROL & LCD1_BUSY_MASK); |
88 | } | 88 | } |
89 | 89 | ||
90 | /* send LCD data */ | 90 | /* send LCD data */ |
@@ -155,7 +155,7 @@ void lcd_init_device(void) | |||
155 | power_reg_h = 0x1100; | 155 | power_reg_h = 0x1100; |
156 | #elif defined IPOD_MINI2G | 156 | #elif defined IPOD_MINI2G |
157 | lcd_wait_write(); | 157 | lcd_wait_write(); |
158 | LCD1_BASE = (LCD1_BASE & ~0x1f00000) | 0x1700000; | 158 | LCD1_CONTROL = (LCD1_CONTROL & ~0x1f00000) | 0x1700000; |
159 | #endif | 159 | #endif |
160 | 160 | ||
161 | lcd_cmd_and_data(R_POWER_CONTROL, POWER_REG_H | 0xc); | 161 | lcd_cmd_and_data(R_POWER_CONTROL, POWER_REG_H | 0xc); |