summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iaudio/x5/lcd-x5.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/iaudio/x5/lcd-x5.c')
-rwxr-xr-xfirmware/target/coldfire/iaudio/x5/lcd-x5.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/firmware/target/coldfire/iaudio/x5/lcd-x5.c b/firmware/target/coldfire/iaudio/x5/lcd-x5.c
index c00dc74b0c..e1fac1e2ac 100755
--- a/firmware/target/coldfire/iaudio/x5/lcd-x5.c
+++ b/firmware/target/coldfire/iaudio/x5/lcd-x5.c
@@ -44,6 +44,9 @@ static unsigned short disp_control_rev;
44/* Contrast setting << 8 */ 44/* Contrast setting << 8 */
45static int lcd_contrast; 45static int lcd_contrast;
46 46
47/* Hardware dither bit */
48static unsigned short hw_dit = 0x0000;
49
47/* Forward declarations */ 50/* Forward declarations */
48static void lcd_display_off(void); 51static void lcd_display_off(void);
49 52
@@ -102,6 +105,13 @@ static inline void lcd_begin_write_gram(void)
102 LCD_CMD = R_WRITE_DATA_2_GRAM << 1; 105 LCD_CMD = R_WRITE_DATA_2_GRAM << 1;
103} 106}
104 107
108static void hw_dither(bool on)
109{
110 /* DIT=x, BGR=1, HWM=0, I/D1-0=11, AM=1, LG2-0=000 */
111 hw_dit = on ? 0x8000 : 0x0000;
112 lcd_write_reg(R_ENTRY_MODE, 0x1038 | hw_dit);
113}
114
105/*** hardware configuration ***/ 115/*** hardware configuration ***/
106 116
107int lcd_default_contrast(void) 117int lcd_default_contrast(void)
@@ -224,8 +234,8 @@ static void lcd_power_on(void)
224 lcd_write_reg(R_DRV_OUTPUT_CONTROL, y_offset ? 0x0013 : 0x0313); 234 lcd_write_reg(R_DRV_OUTPUT_CONTROL, y_offset ? 0x0013 : 0x0313);
225 /* FLD1-0=01 (1 field), B/C=1, EOR=1 (C-pat), NW5-0=000000 (1 row) */ 235 /* FLD1-0=01 (1 field), B/C=1, EOR=1 (C-pat), NW5-0=000000 (1 row) */
226 lcd_write_reg(R_DRV_AC_CONTROL, 0x0700); 236 lcd_write_reg(R_DRV_AC_CONTROL, 0x0700);
227 /* DIT=1, BGR=1, HWM=0, I/D1-0=11, AM=1, LG2-0=000 */ 237 /* DIT=x, BGR=1, HWM=0, I/D1-0=11, AM=1, LG2-0=000 */
228 lcd_write_reg(R_ENTRY_MODE, 0x9038); 238 lcd_write_reg(R_ENTRY_MODE, 0x1038 | hw_dit);
229 /* CP15-0=0000000000000000 */ 239 /* CP15-0=0000000000000000 */
230 lcd_write_reg(R_COMPARE_REG, 0x0000); 240 lcd_write_reg(R_COMPARE_REG, 0x0000);
231 /* NO1-0=01, SDT1-0=00, EQ1-0=00, DIV1-0=00, RTN3-00000 */ 241 /* NO1-0=01, SDT1-0=00, EQ1-0=00, DIV1-0=00, RTN3-00000 */
@@ -379,6 +389,7 @@ void lcd_init_device(void)
379 lcd_roll(0); 389 lcd_roll(0);
380 lcd_set_invert_display(false); 390 lcd_set_invert_display(false);
381 lcd_set_contrast(DEFAULT_CONTRAST_SETTING); 391 lcd_set_contrast(DEFAULT_CONTRAST_SETTING);
392 hw_dither(false); /* do this or all bootloaders will need reflashing */
382#endif 393#endif
383} 394}
384 395
@@ -455,6 +466,9 @@ void lcd_yuv_blit(unsigned char * const src[3],
455 if (!display_on) 466 if (!display_on)
456 return; 467 return;
457 468
469 if (hw_dit == 0x0000)
470 hw_dither(true);
471
458 width = (width + 1) & ~1; 472 width = (width + 1) & ~1;
459 height = (height + 1) & ~1; 473 height = (height + 1) & ~1;
460 474
@@ -493,6 +507,9 @@ void lcd_update(void)
493 if (!display_on) 507 if (!display_on)
494 return; 508 return;
495 509
510 if (hw_dit != 0x0000)
511 hw_dither(false);
512
496 /* Set start position and window */ 513 /* Set start position and window */
497 /* Just add roll offset to start address. CP will roll back around. */ 514 /* Just add roll offset to start address. CP will roll back around. */
498 lcd_write_reg(R_RAM_ADDR_SET, y_offset + roll_offset); /* X == 0 */ 515 lcd_write_reg(R_RAM_ADDR_SET, y_offset + roll_offset); /* X == 0 */
@@ -513,6 +530,9 @@ void lcd_update_rect(int x, int y, int width, int height)
513 if (!display_on) 530 if (!display_on)
514 return; 531 return;
515 532
533 if (hw_dit != 0x0000)
534 hw_dither(false);
535
516 if (x + width > LCD_WIDTH) 536 if (x + width > LCD_WIDTH)
517 width = LCD_WIDTH - x; /* Clip right */ 537 width = LCD_WIDTH - x; /* Clip right */
518 if (x < 0) 538 if (x < 0)