summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2006-10-20 23:57:48 +0000
committerMichael Sevakis <jethead71@rockbox.org>2006-10-20 23:57:48 +0000
commit10363b3a8178b791960fb7f048215ee8621fa074 (patch)
treee7ffcc45d7749d24f13668b826df0e9d2f42c38c
parentdb0cc98aad95004c1cbced791d63d6254df57bd2 (diff)
downloadrockbox-10363b3a8178b791960fb7f048215ee8621fa074.tar.gz
rockbox-10363b3a8178b791960fb7f048215ee8621fa074.zip
Get rid of some OR-ing and conditional expressions in lcd driver when register values can just be saved in shorts. Touch-up to comment in asm part.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11281 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/coldfire/iaudio/x5/lcd-as-x5.S32
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/lcd-x5.c125
2 files changed, 84 insertions, 73 deletions
diff --git a/firmware/target/coldfire/iaudio/x5/lcd-as-x5.S b/firmware/target/coldfire/iaudio/x5/lcd-as-x5.S
index 54c1110d2a..6d5d324ebf 100644
--- a/firmware/target/coldfire/iaudio/x5/lcd-as-x5.S
+++ b/firmware/target/coldfire/iaudio/x5/lcd-as-x5.S
@@ -316,10 +316,10 @@ lcd_write_data:
316 /* transfer initial word */ 316 /* transfer initial word */
317 move.w (%a0)+,%d2 /* |????????|????????|rrrrrggg|gggbbbbb| */ 317 move.w (%a0)+,%d2 /* |????????|????????|rrrrrggg|gggbbbbb| */
318 move.l %d2,%d1 318 move.l %d2,%d1
319 lsr.l #7,%d1 /* |0000000?|????????|???????r|rrrrgggg| */ 319 lsr.l #7,%d1 /* |0000000?|????????|???????r|rrrrgggg| */
320 move.w %d1,(%a1) /* ^ ^^^^^^^ */ 320 move.w %d1,(%a1) /* ^ ^^^^^^^ */
321 lsl.l #1,%d2 /* |????????|???????r|rrrrgggg|ggbbbbb0| */ 321 lsl.l #1,%d2 /* |????????|???????r|rrrrgggg|ggbbbbb0| */
322 move.w %d2,(%a1) /* ^ ^^^^^^^ */ 322 move.w %d2,(%a1) /* ^ ^^^^^^^ */
323 323
324.wd_wordl_end: /* now longword aligned */ 324.wd_wordl_end: /* now longword aligned */
325 moveq.l #28,%d1 325 moveq.l #28,%d1
@@ -335,14 +335,14 @@ lcd_write_data:
335 bls.b .wd_long1_end /* no: skip leading long loop */ 335 bls.b .wd_long1_end /* no: skip leading long loop */
336 336
337.wd_long1_loop: 337.wd_long1_loop:
338 move.l (%a0)+,%d2 /* read longword */ 338 move.l (%a0)+,%d2 /* read longword */
339 swap %d2 /* |rrrrrggg|gggbbbbb|RRRRRGGG|GGGBBBBB| */ 339 swap %d2 /* |rrrrrggg|gggbbbbb|RRRRRGGG|GGGBBBBB| */
340 move.l %d2,%d5 340 move.l %d2,%d5
341 lsr.l #7,%d5 /* |0000000r|rrrrgggg|ggbbbbbR|RRRRGGGG| */ 341 lsr.l #7,%d5 /* |0000000r|rrrrgggg|ggbbbbbR|RRRRGGGG| */
342 move.w %d5,(%a1) /* ^ ^^^^^^^ */ 342 move.w %d5,(%a1) /* ^ ^^^^^^^ */
343 lsl.l #1,%d2 /* |rrrrgggg|ggbbbbbR|RRRRBGGG|GGBBBBB0| */ 343 lsl.l #1,%d2 /* |rrrrgggg|ggbbbbbR|RRRRGGGG|GGBBBBB0| */
344 move.w %d2,(%a1) /* ^ ^^^^^^^ */ 344 move.w %d2,(%a1) /* ^ ^^^^^^^ */
345 swap %d5 /* |ggbbbbbR|RRRRGGGG|0000000r|rrrrgggg| */ 345 swap %d5 /* |ggbbbbbR|RRRRGGGG|0000000r|rrrrgggg| */
346 move.w %d5,(%a1) /* ^ ^^^^^^^ */ 346 move.w %d5,(%a1) /* ^ ^^^^^^^ */
347 swap %d2 /* |RRRRBGGG|GGBBBBB0|rrrrgggg|ggbbbbbR| */ 347 swap %d2 /* |RRRRBGGG|GGBBBBB0|rrrrgggg|ggbbbbbR| */
348 move.w %d2,(%a1) /* ^ ^^^^^^^ */ 348 move.w %d2,(%a1) /* ^ ^^^^^^^ */
@@ -369,7 +369,7 @@ lcd_write_data:
369 swap %d1 369 swap %d1
370 move.w %d1,(%a1) 370 move.w %d1,(%a1)
371 371
372 swap %d2 372 swap %d2
373 move.l %d2,%d5 373 move.l %d2,%d5
374 lsr.l #7,%d5 374 lsr.l #7,%d5
375 move.w %d5,(%a1) 375 move.w %d5,(%a1)
@@ -380,7 +380,7 @@ lcd_write_data:
380 swap %d2 380 swap %d2
381 move.w %d2,(%a1) 381 move.w %d2,(%a1)
382 382
383 swap %d3 383 swap %d3
384 move.l %d3,%d5 384 move.l %d3,%d5
385 lsr.l #7,%d5 385 lsr.l #7,%d5
386 move.w %d5,(%a1) 386 move.w %d5,(%a1)
@@ -391,7 +391,7 @@ lcd_write_data:
391 swap %d3 391 swap %d3
392 move.w %d3,(%a1) 392 move.w %d3,(%a1)
393 393
394 swap %d4 394 swap %d4
395 move.l %d4,%d5 395 move.l %d4,%d5
396 lsr.l #7,%d5 396 lsr.l #7,%d5
397 move.w %d5,(%a1) 397 move.w %d5,(%a1)
@@ -411,8 +411,8 @@ lcd_write_data:
411 bls.b .wd_long2_end /* no: skip trailing longword loop */ 411 bls.b .wd_long2_end /* no: skip trailing longword loop */
412 412
413.wd_long2_loop: 413.wd_long2_loop:
414 move.l (%a0)+,%d2 /* read longword */ 414 move.l (%a0)+,%d2 /* read longword */
415 swap %d2 415 swap %d2
416 move.l %d2,%d5 416 move.l %d2,%d5
417 lsr.l #7,%d5 417 lsr.l #7,%d5
418 move.w %d5,(%a1) 418 move.w %d5,(%a1)
@@ -430,10 +430,10 @@ lcd_write_data:
430 430
431 move.w (%a0)+,%d2 /* transfer final word */ 431 move.w (%a0)+,%d2 /* transfer final word */
432 move.l %d2,%d1 432 move.l %d2,%d1
433 lsr.l #7,%d1 433 lsr.l #7,%d1
434 move.w %d1,(%a1) 434 move.w %d1,(%a1)
435 lsl.l #1,%d2 435 lsl.l #1,%d2
436 move.w %d2,(%a1) 436 move.w %d2,(%a1)
437 437
438.wd_word2_end: 438.wd_word2_end:
439 movem.l (%sp),%d2-%d5/%a2 439 movem.l (%sp),%d2-%d5/%a2
diff --git a/firmware/target/coldfire/iaudio/x5/lcd-x5.c b/firmware/target/coldfire/iaudio/x5/lcd-x5.c
index e1fac1e2ac..fc16c80a73 100755
--- a/firmware/target/coldfire/iaudio/x5/lcd-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/lcd-x5.c
@@ -30,22 +30,33 @@
30#include "font.h" 30#include "font.h"
31#include "bidi.h" 31#include "bidi.h"
32 32
33/** Initialized in lcd_init_device() **/ 33/* Power and display status */
34/* Is the power turned on? */ 34static bool power_on = false; /* Is the power turned on? */
35static bool power_on; 35static bool display_on = false; /* Is the display turned on? */
36/* Is the display turned on? */ 36
37static bool display_on; 37/* Contrast */
38/* Amount of vertical offset. Used for flip offset correction/detection. */ 38static int lcd_contrast = DEFAULT_CONTRAST_SETTING << 8;
39static int y_offset; 39
40/* Amount of roll offset (0-127). */ 40/* Reverse Flag */
41static int roll_offset; 41#define R_DISP_CONTROL_NORMAL 0x0004
42/* Reverse flag. Must be remembered when display is turned off. */ 42#define R_DISP_CONTROL_REV 0x0000
43static unsigned short disp_control_rev; 43static unsigned short r_disp_control_rev = R_DISP_CONTROL_NORMAL;
44/* Contrast setting << 8 */ 44
45static int lcd_contrast; 45/* Flipping */
46 46#define Y_OFFSET_NORMAL 0
47/* Hardware dither bit */ 47#define Y_OFFSET_FLIPPED 4
48static unsigned short hw_dit = 0x0000; 48static int y_offset = 0; /* y correction for flip */
49static unsigned short r_gate_scan_start_pos = 0x0002;
50static unsigned short r_drv_output_control = 0x0313;
51static unsigned short r_horiz_ram_addr_pos = 0x7f00;
52
53/* Rolling */
54static int roll_offset = 0; /* Amount of roll offset (0-127). */
55
56/* Dithering */
57#define R_ENTRY_MODE_SOLID 0x1038
58#define R_ENTRY_MODE_DIT 0x9038
59static unsigned short r_entry_mode = R_ENTRY_MODE_SOLID;
49 60
50/* Forward declarations */ 61/* Forward declarations */
51static void lcd_display_off(void); 62static void lcd_display_off(void);
@@ -105,11 +116,12 @@ static inline void lcd_begin_write_gram(void)
105 LCD_CMD = R_WRITE_DATA_2_GRAM << 1; 116 LCD_CMD = R_WRITE_DATA_2_GRAM << 1;
106} 117}
107 118
119/* set hard dither mode on/off */
108static void hw_dither(bool on) 120static void hw_dither(bool on)
109{ 121{
110 /* DIT=x, BGR=1, HWM=0, I/D1-0=11, AM=1, LG2-0=000 */ 122 /* DIT=x, BGR=1, HWM=0, I/D1-0=11, AM=1, LG2-0=000 */
111 hw_dit = on ? 0x8000 : 0x0000; 123 r_entry_mode = on ? R_ENTRY_MODE_DIT : R_ENTRY_MODE_SOLID;
112 lcd_write_reg(R_ENTRY_MODE, 0x1038 | hw_dit); 124 lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
113} 125}
114 126
115/*** hardware configuration ***/ 127/*** hardware configuration ***/
@@ -140,35 +152,43 @@ void lcd_set_contrast(int val)
140 152
141void lcd_set_invert_display(bool yesno) 153void lcd_set_invert_display(bool yesno)
142{ 154{
143 if (yesno == (disp_control_rev == 0x0000)) 155 r_disp_control_rev = yesno ? R_DISP_CONTROL_REV :
144 return; 156 R_DISP_CONTROL_NORMAL;
145
146 disp_control_rev = yesno ? 0x0000 : 0x0004;
147 157
148 if (!display_on) 158 if (!display_on)
149 return; 159 return;
150 160
151 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=11 */ 161 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=11 */
152 lcd_write_reg(R_DISP_CONTROL, 0x0033 | disp_control_rev); 162 lcd_write_reg(R_DISP_CONTROL, 0x0033 | r_disp_control_rev);
153} 163}
154 164
155/* turn the display upside down (call lcd_update() afterwards) */ 165/* turn the display upside down (call lcd_update() afterwards) */
156void lcd_set_flip(bool yesno) 166void lcd_set_flip(bool yesno)
157{ 167{
158 if (yesno == (y_offset != 0)) 168 if (yesno)
159 return; 169 {
160 170 y_offset = Y_OFFSET_FLIPPED;
161 y_offset = yesno ? 4 : 0; 171 r_gate_scan_start_pos = 0x0000;
172 r_drv_output_control = 0x0013;
173 r_horiz_ram_addr_pos = 0x8304;
174 }
175 else
176 {
177 y_offset = Y_OFFSET_NORMAL;
178 r_gate_scan_start_pos = 0x0002;
179 r_drv_output_control = 0x0313;
180 r_horiz_ram_addr_pos = 0x7f00;
181 }
162 182
163 if (!power_on) 183 if (!power_on)
164 return; 184 return;
165 185
166 /* SCN4-0=000x0 (G1/G160) */ 186 /* SCN4-0=000x0 (G1/G160) */
167 lcd_write_reg(R_GATE_SCAN_START_POS, yesno ? 0x0000 : 0x0002); 187 lcd_write_reg(R_GATE_SCAN_START_POS, r_gate_scan_start_pos);
168 /* SM=0, GS=x, SS=x, NL4-0=10011 (G1-G160)*/ 188 /* SM=0, GS=x, SS=x, NL4-0=10011 (G1-G160)*/
169 lcd_write_reg(R_DRV_OUTPUT_CONTROL, yesno ? 0x0013 : 0x0313); 189 lcd_write_reg(R_DRV_OUTPUT_CONTROL, r_drv_output_control);
170 /* HEA7-0=0xxx, HSA7-0=0xxx */ 190 /* HEA7-0=0xxx, HSA7-0=0xxx */
171 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, yesno ? 0x8304 : 0x7f00); 191 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, r_horiz_ram_addr_pos);
172} 192}
173 193
174/* Rolls up the lcd display by the specified amount of lines. 194/* Rolls up the lcd display by the specified amount of lines.
@@ -231,17 +251,17 @@ static void lcd_power_on(void)
231 251
232 /* Instructions for other mode settings (in register order). */ 252 /* Instructions for other mode settings (in register order). */
233 /* SM=0, GS=x, SS=x, NL4-0=10011 (G1-G160)*/ 253 /* SM=0, GS=x, SS=x, NL4-0=10011 (G1-G160)*/
234 lcd_write_reg(R_DRV_OUTPUT_CONTROL, y_offset ? 0x0013 : 0x0313); 254 lcd_write_reg(R_DRV_OUTPUT_CONTROL, r_drv_output_control);
235 /* FLD1-0=01 (1 field), B/C=1, EOR=1 (C-pat), NW5-0=000000 (1 row) */ 255 /* FLD1-0=01 (1 field), B/C=1, EOR=1 (C-pat), NW5-0=000000 (1 row) */
236 lcd_write_reg(R_DRV_AC_CONTROL, 0x0700); 256 lcd_write_reg(R_DRV_AC_CONTROL, 0x0700);
237 /* DIT=x, BGR=1, HWM=0, I/D1-0=11, AM=1, LG2-0=000 */ 257 /* DIT=x, BGR=1, HWM=0, I/D1-0=11, AM=1, LG2-0=000 */
238 lcd_write_reg(R_ENTRY_MODE, 0x1038 | hw_dit); 258 lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
239 /* CP15-0=0000000000000000 */ 259 /* CP15-0=0000000000000000 */
240 lcd_write_reg(R_COMPARE_REG, 0x0000); 260 lcd_write_reg(R_COMPARE_REG, 0x0000);
241 /* NO1-0=01, SDT1-0=00, EQ1-0=00, DIV1-0=00, RTN3-00000 */ 261 /* NO1-0=01, SDT1-0=00, EQ1-0=00, DIV1-0=00, RTN3-00000 */
242 lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x4000); 262 lcd_write_reg(R_FRAME_CYCLE_CONTROL, 0x4000);
243 /* SCN4-0=000x0 (G1/G160) */ 263 /* SCN4-0=000x0 (G1/G160) */
244 lcd_write_reg(R_GATE_SCAN_START_POS, y_offset ? 0x0000 : 0x0002); 264 lcd_write_reg(R_GATE_SCAN_START_POS, r_gate_scan_start_pos);
245 /* VL7-0=0x00 */ 265 /* VL7-0=0x00 */
246 lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000); 266 lcd_write_reg(R_VERT_SCROLL_CONTROL, 0x0000);
247 /* SE17-10(End)=0x9f (159), SS17-10(Start)=0x00 */ 267 /* SE17-10(End)=0x9f (159), SS17-10(Start)=0x00 */
@@ -249,7 +269,7 @@ static void lcd_power_on(void)
249 /* SE27-20(End)=0x5c (92), SS27-20(Start)=0x00 */ 269 /* SE27-20(End)=0x5c (92), SS27-20(Start)=0x00 */
250 lcd_write_reg(R_2ND_SCR_DRV_POS, 0x5c00); 270 lcd_write_reg(R_2ND_SCR_DRV_POS, 0x5c00);
251 /* HEA7-0=0xxx, HSA7-0=0xxx */ 271 /* HEA7-0=0xxx, HSA7-0=0xxx */
252 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, y_offset ? 0x8304 : 0x7f00); 272 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, r_horiz_ram_addr_pos);
253 /* PKP12-10=0x0, PKP02-00=0x0 */ 273 /* PKP12-10=0x0, PKP02-00=0x0 */
254 lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0003); 274 lcd_write_reg(R_GAMMA_FINE_ADJ_POS1, 0x0003);
255 /* PKP32-30=0x4, PKP22-20=0x0 */ 275 /* PKP32-30=0x4, PKP22-20=0x0 */
@@ -320,14 +340,14 @@ static void lcd_display_on(void)
320 sleep(HZ/25); /* Wait 2 frames or more */ 340 sleep(HZ/25); /* Wait 2 frames or more */
321 341
322 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=01 */ 342 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=01 */
323 lcd_write_reg(R_DISP_CONTROL, 0x0021 | disp_control_rev); 343 lcd_write_reg(R_DISP_CONTROL, 0x0021 | r_disp_control_rev);
324 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=11 */ 344 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=11 */
325 lcd_write_reg(R_DISP_CONTROL, 0x0023 | disp_control_rev); 345 lcd_write_reg(R_DISP_CONTROL, 0x0023 | r_disp_control_rev);
326 346
327 sleep(HZ/25); /* Wait 2 frames or more */ 347 sleep(HZ/25); /* Wait 2 frames or more */
328 348
329 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=11 */ 349 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=11 */
330 lcd_write_reg(R_DISP_CONTROL, 0x0033 | disp_control_rev); 350 lcd_write_reg(R_DISP_CONTROL, 0x0033 | r_disp_control_rev);
331 351
332 display_on = true; 352 display_on = true;
333} 353}
@@ -342,12 +362,12 @@ static void lcd_display_off(void)
342 /* EQ1-0=00 already */ 362 /* EQ1-0=00 already */
343 363
344 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=10 */ 364 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=1, REV=x, D1-0=10 */
345 lcd_write_reg(R_DISP_CONTROL, 0x0032 | disp_control_rev); 365 lcd_write_reg(R_DISP_CONTROL, 0x0032 | r_disp_control_rev);
346 366
347 sleep(HZ/25); /* Wait 2 frames or more */ 367 sleep(HZ/25); /* Wait 2 frames or more */
348 368
349 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=10 */ 369 /* PT1-0=00, VLE2-1=00, SPT=0, GON=1, DTE=0, REV=x, D1-0=10 */
350 lcd_write_reg(R_DISP_CONTROL, 0x0022 | disp_control_rev); 370 lcd_write_reg(R_DISP_CONTROL, 0x0022 | r_disp_control_rev);
351 371
352 sleep(HZ/25); /* Wait 2 frames or more */ 372 sleep(HZ/25); /* Wait 2 frames or more */
353 373
@@ -358,18 +378,9 @@ static void lcd_display_off(void)
358/* LCD init */ 378/* LCD init */
359void lcd_init_device(void) 379void lcd_init_device(void)
360{ 380{
361 /* Reset settings */
362
363#ifdef BOOTLOADER 381#ifdef BOOTLOADER
364 /* Initial boot requires setting up chip registers but a full reset is 382 /* Initial boot requires power on reset and setting up chip
365 not needed again. */ 383 registers but a full reset is not needed again. */
366 y_offset = 0;
367 roll_offset = 0;
368 disp_control_rev = 0x0004;
369 lcd_contrast = DEFAULT_CONTRAST_SETTING << 8;
370
371 power_on = false;
372 display_on = false;
373 384
374 /* LCD Reset */ 385 /* LCD Reset */
375 and_l(~0x00000010, &GPIO1_OUT); 386 and_l(~0x00000010, &GPIO1_OUT);
@@ -382,13 +393,13 @@ void lcd_init_device(void)
382 393
383 lcd_display_on(); 394 lcd_display_on();
384#else 395#else
385 /* Power and display already ON */ 396 /* Power and display already ON - reset settings */
386 power_on = true; 397 power_on = true;
387 display_on = true; 398 display_on = true;
399 lcd_set_contrast(DEFAULT_CONTRAST_SETTING);
400 lcd_set_invert_display(false);
388 lcd_set_flip(false); 401 lcd_set_flip(false);
389 lcd_roll(0); 402 lcd_roll(0);
390 lcd_set_invert_display(false);
391 lcd_set_contrast(DEFAULT_CONTRAST_SETTING);
392 hw_dither(false); /* do this or all bootloaders will need reflashing */ 403 hw_dither(false); /* do this or all bootloaders will need reflashing */
393#endif 404#endif
394} 405}
@@ -466,7 +477,7 @@ void lcd_yuv_blit(unsigned char * const src[3],
466 if (!display_on) 477 if (!display_on)
467 return; 478 return;
468 479
469 if (hw_dit == 0x0000) 480 if (r_entry_mode == R_ENTRY_MODE_SOLID)
470 hw_dither(true); 481 hw_dither(true);
471 482
472 width = (width + 1) & ~1; 483 width = (width + 1) & ~1;
@@ -507,7 +518,7 @@ void lcd_update(void)
507 if (!display_on) 518 if (!display_on)
508 return; 519 return;
509 520
510 if (hw_dit != 0x0000) 521 if (r_entry_mode == R_ENTRY_MODE_DIT)
511 hw_dither(false); 522 hw_dither(false);
512 523
513 /* Set start position and window */ 524 /* Set start position and window */
@@ -530,7 +541,7 @@ void lcd_update_rect(int x, int y, int width, int height)
530 if (!display_on) 541 if (!display_on)
531 return; 542 return;
532 543
533 if (hw_dit != 0x0000) 544 if (r_entry_mode == R_ENTRY_MODE_DIT)
534 hw_dither(false); 545 hw_dither(false);
535 546
536 if (x + width > LCD_WIDTH) 547 if (x + width > LCD_WIDTH)