summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-01-22 22:48:43 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-01-22 22:48:43 +0000
commit6546cd12828d108c4c84ea128a21a102d55a7bd6 (patch)
treeb60d50fdd1d3432a5fd93bbcee9a1820bff32e39
parent90aafeae6702c84b3b577b3e2d991d6bece801e9 (diff)
downloadrockbox-6546cd12828d108c4c84ea128a21a102d55a7bd6.tar.gz
rockbox-6546cd12828d108c4c84ea128a21a102d55a7bd6.zip
Gigabeat S: Keep LCD options in sync even when display is turned off.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29118 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c54
1 files changed, 37 insertions, 17 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c
index cd583ecd6b..6a0c889851 100644
--- a/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c
@@ -44,6 +44,16 @@ extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src,
44static bool lcd_on = true; 44static bool lcd_on = true;
45static bool lcd_powered = true; 45static bool lcd_powered = true;
46static unsigned lcd_yuv_options = 0; 46static unsigned lcd_yuv_options = 0;
47/* Settings shadow regs */
48#ifdef HAVE_LCD_CONTRAST
49static uint8_t reg0x0b = 0x2f;
50#endif
51#ifdef HAVE_LCD_INVERT
52static uint8_t reg0x27 = 0x00;
53#endif
54#ifdef HAVE_LCD_FLIP
55static uint8_t reg0x06 = 0x04;
56#endif
47 57
48#if 0 58#if 0
49/* Initialization data from OF bootloader. Identical to Gigabeat F/X. */ 59/* Initialization data from OF bootloader. Identical to Gigabeat F/X. */
@@ -64,12 +74,12 @@ static const unsigned char lcd_init_data[50] =
64 0x00, 0x03, 74 0x00, 0x03,
65 0x01, 0x10, 75 0x01, 0x10,
66 0x02, 0x0a, 76 0x02, 0x0a,
67 0x06, 0x04, /* Set the orientation 2=upside down, 4=normal */ 77 0x06, 0x04, /* Set the orientation 0x02=upside down, 0x04=normal */
68 0x08, 0x2e, 78 0x08, 0x2e,
69 0x24, 0x12, 79 0x24, 0x12,
70 0x25, 0x3f, 80 0x25, 0x3f,
71 0x26, 0x0b, 81 0x26, 0x0b,
72 0x27, 0x00, 82 0x27, 0x00, /* Invert display 0x00=normal, 0x10=inverted */
73 0x28, 0x00, 83 0x28, 0x00,
74 0x29, 0xf6, 84 0x29, 0xf6,
75 0x2a, 0x03, 85 0x2a, 0x03,
@@ -80,7 +90,7 @@ static const unsigned char lcd_init_data[50] =
80 90
81static const struct spi_node lcd_spi_node = 91static const struct spi_node lcd_spi_node =
82{ 92{
83 /* Original firmware settings for LCD panel commication */ 93 /* Original firmware settings for LCD panel communication */
84 CSPI3_NUM, /* CSPI module 3 */ 94 CSPI3_NUM, /* CSPI module 3 */
85 CSPI_CONREG_CHIP_SELECT_SS1 | /* Chip select 1 */ 95 CSPI_CONREG_CHIP_SELECT_SS1 | /* Chip select 1 */
86 CSPI_CONREG_DRCTL_DONT_CARE | /* Don't care about CSPI_RDY */ 96 CSPI_CONREG_DRCTL_DONT_CARE | /* Don't care about CSPI_RDY */
@@ -146,6 +156,19 @@ static void lcd_set_power(bool powered)
146 } 156 }
147} 157}
148 158
159static void lcd_sync_settings(void)
160{
161#ifdef HAVE_LCD_CONTRAST
162 lcd_write_reg(0x0b, reg0x0b);
163#endif
164#ifdef HAVE_LCD_INVERT
165 lcd_write_reg(0x27, reg0x27);
166#endif
167#ifdef HAVE_LCD_FLIP
168 lcd_write_reg(0x06, reg0x06);
169#endif
170}
171
149/* LCD init */ 172/* LCD init */
150void INIT_ATTR lcd_init_device(void) 173void INIT_ATTR lcd_init_device(void)
151{ 174{
@@ -158,15 +181,7 @@ void INIT_ATTR lcd_init_device(void)
158 IPU_IPU_IMA_DATA = FRAME_PHYS_ADDR; 181 IPU_IPU_IMA_DATA = FRAME_PHYS_ADDR;
159 182
160 lcd_enable_interface(true); 183 lcd_enable_interface(true);
161#ifdef HAVE_LCD_CONTRAST 184 lcd_sync_settings();
162 lcd_set_contrast(DEFAULT_CONTRAST_SETTING);
163#endif
164#ifdef HAVE_LCD_INVERT
165 lcd_set_invert_display(false);
166#endif
167#ifdef HAVE_LCD_FLIP
168 lcd_set_flip(false);
169#endif
170} 185}
171 186
172/* Update a fraction of the display. */ 187/* Update a fraction of the display. */
@@ -191,8 +206,6 @@ void lcd_update_rect(int x, int y, int width, int height)
191 if (height <= 0) 206 if (height <= 0)
192 return; /* nothing left to do */ 207 return; /* nothing left to do */
193 208
194 /* TODO: It may be faster to swap the addresses of lcd_driver_framebuffer
195 * and lcd_framebuffer */
196 dst = (fb_data *)FRAME + LCD_WIDTH*y + x; 209 dst = (fb_data *)FRAME + LCD_WIDTH*y + x;
197 src = &lcd_framebuffer[y][x]; 210 src = &lcd_framebuffer[y][x];
198 211
@@ -230,6 +243,7 @@ void lcd_enable(bool state)
230 if (!lcd_powered) 243 if (!lcd_powered)
231 lcd_set_power(true); 244 lcd_set_power(true);
232 IPU_IDMAC_CHA_EN |= 1ul << MAIN_LCD_IDMAC_CHANNEL; 245 IPU_IDMAC_CHA_EN |= 1ul << MAIN_LCD_IDMAC_CHANNEL;
246 lcd_sync_settings();
233 sleep(HZ/50); 247 sleep(HZ/50);
234 lcd_on = true; 248 lcd_on = true;
235 lcd_update(); 249 lcd_update();
@@ -330,10 +344,12 @@ void lcd_blit_yuv(unsigned char * const src[3],
330#ifdef HAVE_LCD_CONTRAST 344#ifdef HAVE_LCD_CONTRAST
331void lcd_set_contrast(int val) 345void lcd_set_contrast(int val)
332{ 346{
347 reg0x0b = val & 0x3f;
348
333 if (!lcd_on) 349 if (!lcd_on)
334 return; 350 return;
335 351
336 lcd_write_reg(0x0b, val); 352 lcd_write_reg(0x0b, reg0x0b);
337} 353}
338 354
339int lcd_default_contrast(void) 355int lcd_default_contrast(void)
@@ -345,19 +361,23 @@ int lcd_default_contrast(void)
345#ifdef HAVE_LCD_INVERT 361#ifdef HAVE_LCD_INVERT
346void lcd_set_invert_display(bool yesno) 362void lcd_set_invert_display(bool yesno)
347{ 363{
364 reg0x27 = yesno ? 0x10 : 0x00;
365
348 if (!lcd_on) 366 if (!lcd_on)
349 return; 367 return;
350 368
351 lcd_write_reg(0x27, yesno ? 0x10 : 00); 369 lcd_write_reg(0x27, reg0x27);
352} 370}
353#endif /* HAVE_LCD_INVERT */ 371#endif /* HAVE_LCD_INVERT */
354 372
355#ifdef HAVE_LCD_FLIP 373#ifdef HAVE_LCD_FLIP
356void lcd_set_flip(bool yesno) 374void lcd_set_flip(bool yesno)
357{ 375{
376 reg0x06 = yesno ? 0x02 : 0x04;
377
358 if (!lcd_on) 378 if (!lcd_on)
359 return; 379 return;
360 380
361 lcd_write_reg(0x06, yesno ? 0x02 : 0x04); 381 lcd_write_reg(0x06, reg0x06);
362} 382}
363#endif /* HAVE_LCD_FLIP */ 383#endif /* HAVE_LCD_FLIP */