diff options
Diffstat (limited to 'firmware/target/arm/iriver')
-rw-r--r-- | firmware/target/arm/iriver/h10/lcd-h10_20gb.c | 48 | ||||
-rw-r--r-- | firmware/target/arm/iriver/h10/lcd-h10_5gb.c | 117 |
2 files changed, 70 insertions, 95 deletions
diff --git a/firmware/target/arm/iriver/h10/lcd-h10_20gb.c b/firmware/target/arm/iriver/h10/lcd-h10_20gb.c index f6ea87c1d0..a52e98f364 100644 --- a/firmware/target/arm/iriver/h10/lcd-h10_20gb.c +++ b/firmware/target/arm/iriver/h10/lcd-h10_20gb.c | |||
@@ -22,12 +22,6 @@ | |||
22 | #include "kernel.h" | 22 | #include "kernel.h" |
23 | #include "system.h" | 23 | #include "system.h" |
24 | 24 | ||
25 | /* check if number of useconds has past */ | ||
26 | static inline bool timer_check(int clock_start, int usecs) | ||
27 | { | ||
28 | return ((int)(USEC_TIMER - clock_start)) >= usecs; | ||
29 | } | ||
30 | |||
31 | /** Initialized in lcd_init_device() **/ | 25 | /** Initialized in lcd_init_device() **/ |
32 | /* Is the power turned on? */ | 26 | /* Is the power turned on? */ |
33 | static bool power_on; | 27 | static bool power_on; |
@@ -43,17 +37,6 @@ static int lcd_contrast; | |||
43 | /* Forward declarations */ | 37 | /* Forward declarations */ |
44 | static void lcd_display_off(void); | 38 | static void lcd_display_off(void); |
45 | 39 | ||
46 | /* Hardware address of LCD. Bits are: | ||
47 | * 31 - set to write, poll for completion. | ||
48 | * 24 - 0 for command, 1 for data | ||
49 | * 7..0 - command/data to send | ||
50 | * Commands/Data are always sent in 16-bits, msb first. | ||
51 | */ | ||
52 | #define LCD_BASE *(volatile unsigned int *)0x70008a0c | ||
53 | #define LCD_BUSY_MASK 0x80000000 | ||
54 | #define LCD_CMD 0x80000000 | ||
55 | #define LCD_DATA 0x81000000 | ||
56 | |||
57 | /* register defines for the Renesas HD66773R */ | 40 | /* register defines for the Renesas HD66773R */ |
58 | #define R_START_OSC 0x00 | 41 | #define R_START_OSC 0x00 |
59 | #define R_DEVICE_CODE_READ 0x00 | 42 | #define R_DEVICE_CODE_READ 0x00 |
@@ -91,31 +74,34 @@ static void lcd_display_off(void); | |||
91 | 74 | ||
92 | static inline void lcd_wait_write(void) | 75 | static inline void lcd_wait_write(void) |
93 | { | 76 | { |
94 | if ((LCD_BASE & LCD_BUSY_MASK) != 0) { | 77 | while (LCD2_PORT & LCD2_BUSY_MASK); |
95 | int start = USEC_TIMER; | ||
96 | |||
97 | do { | ||
98 | if ((LCD_BASE & LCD_BUSY_MASK) == 0) break; | ||
99 | } while (timer_check(start, 1000) == 0); | ||
100 | } | ||
101 | } | 78 | } |
102 | 79 | ||
103 | /* Send command */ | 80 | /* Send command */ |
104 | static inline void lcd_send_cmd(int v) | 81 | static inline void lcd_send_cmd(unsigned v) |
105 | { | 82 | { |
106 | lcd_wait_write(); | 83 | lcd_wait_write(); |
107 | LCD_BASE = 0x00000000 | LCD_CMD; | 84 | LCD2_PORT = LCD2_CMD_MASK; |
108 | LCD_BASE = v | LCD_CMD; | 85 | LCD2_PORT = LCD2_CMD_MASK | v; |
109 | } | 86 | } |
110 | 87 | ||
111 | /* Send 16-bit data */ | 88 | /* Send 16-bit data */ |
112 | static inline void lcd_send_data(int v) | 89 | static inline void lcd_send_data(unsigned v) |
113 | { | 90 | { |
114 | lcd_wait_write(); | 91 | lcd_wait_write(); |
115 | LCD_BASE = ((v>>8) & 0xff) | LCD_DATA; /* Send MSB first */ | 92 | LCD2_PORT = LCD2_DATA_MASK | (v >> 8); /* Send MSB first */ |
116 | LCD_BASE = ( v & 0xff) | LCD_DATA; | 93 | LCD2_PORT = LCD2_DATA_MASK | (v & 0xff); |
117 | } | 94 | } |
118 | 95 | ||
96 | /* Send 16-bit data byte-swapped. Only needed until we can use block transfer. */ | ||
97 | static inline void lcd_send_data_swapped(unsigned v) | ||
98 | { | ||
99 | lcd_wait_write(); | ||
100 | LCD2_PORT = LCD2_DATA_MASK | (v & 0xff); /* Send LSB first */ | ||
101 | LCD2_PORT = LCD2_DATA_MASK | (v >> 8); | ||
102 | } | ||
103 | |||
104 | |||
119 | /* Write value to register */ | 105 | /* Write value to register */ |
120 | static inline void lcd_write_reg(int reg, int val) | 106 | static inline void lcd_write_reg(int reg, int val) |
121 | { | 107 | { |
@@ -635,7 +621,7 @@ void lcd_update_rect(int x0, int y0, int width, int height) | |||
635 | /* for each column */ | 621 | /* for each column */ |
636 | for (c = 0; c < width; c++) { | 622 | for (c = 0; c < width; c++) { |
637 | /* output 1 pixel */ | 623 | /* output 1 pixel */ |
638 | lcd_send_data(*(addr++)); | 624 | lcd_send_data_swapped(*addr++); |
639 | } | 625 | } |
640 | 626 | ||
641 | addr += LCD_WIDTH - width; | 627 | addr += LCD_WIDTH - width; |
diff --git a/firmware/target/arm/iriver/h10/lcd-h10_5gb.c b/firmware/target/arm/iriver/h10/lcd-h10_5gb.c index c1f447a80c..7555c566f0 100644 --- a/firmware/target/arm/iriver/h10/lcd-h10_5gb.c +++ b/firmware/target/arm/iriver/h10/lcd-h10_5gb.c | |||
@@ -22,23 +22,6 @@ | |||
22 | #include "kernel.h" | 22 | #include "kernel.h" |
23 | #include "system.h" | 23 | #include "system.h" |
24 | 24 | ||
25 | /* check if number of useconds has past */ | ||
26 | static inline bool timer_check(int clock_start, int usecs) | ||
27 | { | ||
28 | return ((int)(USEC_TIMER - clock_start)) >= usecs; | ||
29 | } | ||
30 | |||
31 | /* Hardware address of LCD. Bits are: | ||
32 | * 31 - set to write, poll for completion. | ||
33 | * 24 - 0 for command, 1 for data | ||
34 | * 7..0 - command/data to send | ||
35 | * Commands/Data are always sent in 16-bits, msb first. | ||
36 | */ | ||
37 | #define LCD_BASE *(volatile unsigned int *)0x70008a0c | ||
38 | #define LCD_BUSY_MASK 0x80000000 | ||
39 | #define LCD_CMD 0x80000000 | ||
40 | #define LCD_DATA 0x81000000 | ||
41 | |||
42 | /* register defines for TL1771 */ | 25 | /* register defines for TL1771 */ |
43 | #define R_START_OSC 0x00 | 26 | #define R_START_OSC 0x00 |
44 | #define R_DEVICE_CODE_READ 0x00 | 27 | #define R_DEVICE_CODE_READ 0x00 |
@@ -72,38 +55,23 @@ static inline bool timer_check(int clock_start, int usecs) | |||
72 | 55 | ||
73 | static inline void lcd_wait_write(void) | 56 | static inline void lcd_wait_write(void) |
74 | { | 57 | { |
75 | if ((LCD_BASE & LCD_BUSY_MASK) != 0) { | 58 | while (LCD2_PORT & LCD2_BUSY_MASK); |
76 | int start = USEC_TIMER; | ||
77 | |||
78 | do { | ||
79 | if ((LCD_BASE & LCD_BUSY_MASK) == 0) break; | ||
80 | } while (timer_check(start, 1000) == 0); | ||
81 | } | ||
82 | } | 59 | } |
83 | 60 | ||
84 | /* Send command */ | 61 | /* Send command */ |
85 | static inline void lcd_send_cmd(int v) | 62 | static inline void lcd_send_cmd(unsigned v) |
86 | { | 63 | { |
87 | lcd_wait_write(); | 64 | lcd_wait_write(); |
88 | LCD_BASE = 0x00000000 | LCD_CMD; | 65 | LCD2_PORT = LCD2_CMD_MASK; |
89 | LCD_BASE = v | LCD_CMD; | 66 | LCD2_PORT = LCD2_CMD_MASK | v; |
90 | } | 67 | } |
91 | 68 | ||
92 | /* Send 16-bit data */ | 69 | /* Send 16-bit data */ |
93 | static inline void lcd_send_data(int v) | 70 | static inline void lcd_send_data(unsigned v) |
94 | { | 71 | { |
95 | lcd_wait_write(); | 72 | lcd_wait_write(); |
96 | LCD_BASE = ( v & 0xff) | LCD_DATA; /* Send MSB first */ | 73 | LCD2_PORT = LCD2_DATA_MASK | (v >> 8); /* Send MSB first */ |
97 | LCD_BASE = ((v>>8) & 0xff) | LCD_DATA; | 74 | LCD2_PORT = LCD2_DATA_MASK | (v & 0xff); |
98 | } | ||
99 | |||
100 | /* Send two 16-bit data */ | ||
101 | static inline void lcd_send_data2(int v) | ||
102 | { | ||
103 | unsigned int vsr = v; | ||
104 | lcd_send_data(vsr); | ||
105 | vsr = v >> 16; | ||
106 | lcd_send_data(vsr); | ||
107 | } | 75 | } |
108 | 76 | ||
109 | 77 | ||
@@ -181,17 +149,17 @@ void lcd_yuv_blit(unsigned char * const src[3], | |||
181 | y0 = y; | 149 | y0 = y; |
182 | y1 = y + height - 1; | 150 | y1 = y + height - 1; |
183 | 151 | ||
184 | /* start horiz << 8 | max horiz */ | 152 | /* max horiz << 8 | start horiz */ |
185 | lcd_send_cmd(R_HORIZ_RAM_ADDR_POS); | 153 | lcd_send_cmd(R_HORIZ_RAM_ADDR_POS); |
186 | lcd_send_data((x0 << 8) | x1); | 154 | lcd_send_data((x1 << 8) | x0); |
187 | 155 | ||
188 | /* start vert << 8 | max vert */ | 156 | /* max vert << 8 | start vert */ |
189 | lcd_send_cmd(R_VERT_RAM_ADDR_POS); | 157 | lcd_send_cmd(R_VERT_RAM_ADDR_POS); |
190 | lcd_send_data((y0 << 8) | y1); | 158 | lcd_send_data((y1 << 8) | y0); |
191 | 159 | ||
192 | /* start horiz << 8 | start vert */ | 160 | /* start vert << 8 | start horiz */ |
193 | lcd_send_cmd(R_RAM_ADDR_SET); | 161 | lcd_send_cmd(R_RAM_ADDR_SET); |
194 | lcd_send_data(((x0 << 8) | y0)); | 162 | lcd_send_data((y0 << 8) | x0); |
195 | 163 | ||
196 | /* start drawing */ | 164 | /* start drawing */ |
197 | lcd_send_cmd(R_WRITE_DATA_2_GRAM); | 165 | lcd_send_cmd(R_WRITE_DATA_2_GRAM); |
@@ -302,12 +270,12 @@ void lcd_yuv_blit(unsigned char * const src[3], | |||
302 | rbits = red1 >> 16 ; | 270 | rbits = red1 >> 16 ; |
303 | gbits = green1 >> 15 ; | 271 | gbits = green1 >> 15 ; |
304 | bbits = blue1 >> 16 ; | 272 | bbits = blue1 >> 16 ; |
305 | lcd_send_data(swap16((rbits << 11) | (gbits << 5) | bbits)); | 273 | lcd_send_data((rbits << 11) | (gbits << 5) | bbits); |
306 | 274 | ||
307 | rbits = red2 >> 16 ; | 275 | rbits = red2 >> 16 ; |
308 | gbits = green2 >> 15 ; | 276 | gbits = green2 >> 15 ; |
309 | bbits = blue2 >> 16 ; | 277 | bbits = blue2 >> 16 ; |
310 | lcd_send_data(swap16((rbits << 11) | (gbits << 5) | bbits)); | 278 | lcd_send_data((rbits << 11) | (gbits << 5) | bbits); |
311 | } | 279 | } |
312 | while (ysrc < row_end); | 280 | while (ysrc < row_end); |
313 | 281 | ||
@@ -321,8 +289,7 @@ void lcd_update_rect(int x0, int y0, int width, int height) | |||
321 | { | 289 | { |
322 | int x1, y1; | 290 | int x1, y1; |
323 | int newx,newwidth; | 291 | int newx,newwidth; |
324 | 292 | unsigned long *addr; | |
325 | unsigned long *addr = (unsigned long *)lcd_framebuffer; | ||
326 | 293 | ||
327 | /* Ensure x and width are both even - so we can read 32-bit aligned | 294 | /* Ensure x and width are both even - so we can read 32-bit aligned |
328 | data from lcd_framebuffer */ | 295 | data from lcd_framebuffer */ |
@@ -352,34 +319,56 @@ void lcd_update_rect(int x0, int y0, int width, int height) | |||
352 | x1 = t; | 319 | x1 = t; |
353 | } | 320 | } |
354 | 321 | ||
355 | /* start horiz << 8 | max horiz */ | 322 | /* max horiz << 8 | start horiz */ |
356 | lcd_send_cmd(R_HORIZ_RAM_ADDR_POS); | 323 | lcd_send_cmd(R_HORIZ_RAM_ADDR_POS); |
357 | lcd_send_data((x0 << 8) | x1); | 324 | lcd_send_data((x1 << 8) | x0); |
358 | 325 | ||
359 | /* start vert << 8 | max vert */ | 326 | /* max vert << 8 | start vert */ |
360 | lcd_send_cmd(R_VERT_RAM_ADDR_POS); | 327 | lcd_send_cmd(R_VERT_RAM_ADDR_POS); |
361 | lcd_send_data((y0 << 8) | y1); | 328 | lcd_send_data((y1 << 8) | y0); |
362 | 329 | ||
363 | /* start horiz << 8 | start vert */ | 330 | /* start vert << 8 | start horiz */ |
364 | lcd_send_cmd(R_RAM_ADDR_SET); | 331 | lcd_send_cmd(R_RAM_ADDR_SET); |
365 | lcd_send_data(((x0 << 8) | y0)); | 332 | lcd_send_data((y0 << 8) | x0); |
366 | 333 | ||
367 | /* start drawing */ | 334 | /* start drawing */ |
368 | lcd_send_cmd(R_WRITE_DATA_2_GRAM); | 335 | lcd_send_cmd(R_WRITE_DATA_2_GRAM); |
369 | 336 | ||
370 | addr = (unsigned long*)&lcd_framebuffer[y0][x0]; | 337 | addr = (unsigned long*)&lcd_framebuffer[y0][x0]; |
371 | 338 | ||
372 | int c, r; | 339 | while (height > 0) { |
340 | int c, r; | ||
341 | int h, pixels_to_write; | ||
342 | |||
343 | pixels_to_write = (width * height) * 2; | ||
344 | h = height; | ||
373 | 345 | ||
374 | /* for each row */ | 346 | /* calculate how much we can do in one go */ |
375 | for (r = 0; r < height; r++) { | 347 | if (pixels_to_write > 0x10000) { |
376 | /* for each column */ | 348 | h = (0x10000/2) / width; |
377 | for (c = 0; c < width; c += 2) { | 349 | pixels_to_write = (width * h) * 2; |
378 | /* output 2 pixels */ | ||
379 | lcd_send_data2(*(addr++)); | ||
380 | } | 350 | } |
381 | 351 | ||
382 | addr += (LCD_WIDTH - width)/2; | 352 | LCD2_BLOCK_CTRL = 0x10000080; |
353 | LCD2_BLOCK_CONFIG = 0xc0010000 | (pixels_to_write - 1); | ||
354 | LCD2_BLOCK_CTRL = 0x34000000; | ||
355 | |||
356 | /* for each row */ | ||
357 | for (r = 0; r < h; r++) { | ||
358 | /* for each column */ | ||
359 | for (c = 0; c < width; c += 2) { | ||
360 | while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_TXOK)); | ||
361 | |||
362 | /* output 2 pixels */ | ||
363 | LCD2_BLOCK_DATA = *addr++; | ||
364 | } | ||
365 | addr += (LCD_WIDTH - width)/2; | ||
366 | } | ||
367 | |||
368 | while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_READY)); | ||
369 | LCD2_BLOCK_CONFIG = 0; | ||
370 | |||
371 | height -= h; | ||
383 | } | 372 | } |
384 | } | 373 | } |
385 | 374 | ||