summaryrefslogtreecommitdiff
path: root/firmware/target/arm/sandisk
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2007-06-07 06:11:03 +0000
committerMichael Sevakis <jethead71@rockbox.org>2007-06-07 06:11:03 +0000
commit7a16069507a290a1aab84165aa0fb6f8ee4f1b59 (patch)
tree8258e42933fac463e9b6eba54d6a8203ca6e6df4 /firmware/target/arm/sandisk
parent66f42ac12dbfdaa70f5440c16567c53205aed059 (diff)
downloadrockbox-7a16069507a290a1aab84165aa0fb6f8ee4f1b59.tar.gz
rockbox-7a16069507a290a1aab84165aa0fb6f8ee4f1b59.zip
e200: Better sync of display enabling and display update. The display would be remain stale after being turned back on with no screen activity. Block out the fiddling with DMA when writing to driver framebuffer. Melts seem too rare to catch now. There seems to be no significant advantage from an appearance point of view to be meddling around with the transfer anyway.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13582 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/sandisk')
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/backlight-e200.c15
-rw-r--r--firmware/target/arm/sandisk/sansa-e200/lcd-e200.c79
2 files changed, 51 insertions, 43 deletions
diff --git a/firmware/target/arm/sandisk/sansa-e200/backlight-e200.c b/firmware/target/arm/sandisk/sansa-e200/backlight-e200.c
index b608c1b9e6..29c6ab4b45 100644
--- a/firmware/target/arm/sandisk/sansa-e200/backlight-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/backlight-e200.c
@@ -23,32 +23,27 @@
23#include "i2c-pp.h" 23#include "i2c-pp.h"
24 24
25static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING; 25static unsigned short backlight_brightness = DEFAULT_BRIGHTNESS_SETTING;
26static bool backlight_is_on = true;
27
28int __backlight_is_on(void)
29{
30 return (int)backlight_is_on;
31}
32 26
33void __backlight_set_brightness(int brightness) 27void __backlight_set_brightness(int brightness)
34{ 28{
35 backlight_brightness = brightness; 29 backlight_brightness = brightness;
36 pp_i2c_send( 0x46, 0x23, backlight_brightness); 30
37 backlight_is_on = true; 31 if (brightness > 0)
32 __backlight_on();
33 else
34 __backlight_off();
38} 35}
39 36
40void __backlight_on(void) 37void __backlight_on(void)
41{ 38{
42 lcd_enable(true); /* power on lcd */ 39 lcd_enable(true); /* power on lcd */
43 pp_i2c_send( 0x46, 0x23, backlight_brightness); 40 pp_i2c_send( 0x46, 0x23, backlight_brightness);
44 backlight_is_on = true;
45} 41}
46 42
47void __backlight_off(void) 43void __backlight_off(void)
48{ 44{
49 pp_i2c_send( 0x46, 0x23, 0x0); 45 pp_i2c_send( 0x46, 0x23, 0x0);
50 lcd_enable(false); /* power off lcd */ 46 lcd_enable(false); /* power off lcd */
51 backlight_is_on = false;
52} 47}
53 48
54 49
diff --git a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
index 8dc8ad95e9..86f12567b4 100644
--- a/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
+++ b/firmware/target/arm/sandisk/sansa-e200/lcd-e200.c
@@ -294,14 +294,20 @@ inline void lcd_init_device(void)
294 lcd_write_reg(R_DISP_CONTROL1, 0x0077); 294 lcd_write_reg(R_DISP_CONTROL1, 0x0077);
295 295
296 lcd_send_msg(0x70, R_RAM_WRITE_DATA); 296 lcd_send_msg(0x70, R_RAM_WRITE_DATA);
297
298 LCD_REG_6 |= 1; /* Start DMA */
297} 299}
298 300
299void lcd_enable(bool on) 301void lcd_enable(bool on)
300{ 302{
301 if(on) 303 if(on)
302 { 304 {
303 DEV_EN |= DEV_LCD; /* Enable LCD controller */ 305 if(!(DEV_EN & DEV_LCD))
304 LCD_REG_6 |= 1; /* Enable DMA */ 306 {
307 DEV_EN |= DEV_LCD; /* Enable LCD controller */
308 lcd_update(); /* Resync display */
309 LCD_REG_6 |= 1; /* Restart DMA */
310 }
305 } 311 }
306 else 312 else
307 { 313 {
@@ -314,47 +320,51 @@ void lcd_enable(bool on)
314 } 320 }
315} 321}
316 322
317inline void lcd_update_rect(int x, int y, int width, int height) 323void lcd_update_rect(int x, int y, int width, int height)
318{ 324{
319 (void)x; 325 (void)x;
320 (void)width; 326 (void)width;
321 327
322 if(__backlight_is_on()) 328 if(DEV_EN & DEV_LCD)
323 { 329 {
330#if 0
324 /* Turn off DMA and wait for the transfer to complete */ 331 /* Turn off DMA and wait for the transfer to complete */
325 /* TODO: Work out the proper delay */ 332 /* TODO: Work out the proper delay */
326 LCD_REG_6 &= ~1; 333 LCD_REG_6 &= ~1;
327 udelay(1000); 334 udelay(1000);
328 335#endif
329 /* Copy the Rockbox framebuffer to the second framebuffer */ 336 /* Copy the Rockbox framebuffer to the second framebuffer */
330 /* TODO: Move the second framebuffer into uncached SDRAM */ 337 /* TODO: Move the second framebuffer into uncached SDRAM */
331 memcpy(((char*)&lcd_driver_framebuffer)+(y * sizeof(fb_data) * LCD_WIDTH), 338 memcpy(((char*)&lcd_driver_framebuffer)+(y * sizeof(fb_data) * LCD_WIDTH),
332 ((char *)&lcd_framebuffer)+(y * sizeof(fb_data) * LCD_WIDTH), 339 ((char *)&lcd_framebuffer)+(y * sizeof(fb_data) * LCD_WIDTH),
333 ((height * sizeof(fb_data) * LCD_WIDTH))); 340 ((height * sizeof(fb_data) * LCD_WIDTH)));
334 flush_icache(); 341 flush_icache();
335 342#if 0
336 /* Restart DMA */ 343 /* Restart DMA */
337 LCD_REG_6 |= 1; 344 LCD_REG_6 |= 1;
345#endif
338 } 346 }
339} 347}
340 348
341inline void lcd_update(void) 349void lcd_update(void)
342{ 350{
343 if(__backlight_is_on()) 351 if(DEV_EN & DEV_LCD)
344 { 352 {
345 /* TODO: It may be faster to swap the addresses of lcd_driver_framebuffer 353 /* TODO: It may be faster to swap the addresses of lcd_driver_framebuffer
346 * and lcd_framebuffer */ 354 * and lcd_framebuffer */
355#if 0
347 /* Turn off DMA and wait for the transfer to complete */ 356 /* Turn off DMA and wait for the transfer to complete */
348 LCD_REG_6 &= ~1; 357 LCD_REG_6 &= ~1;
349 udelay(1000); 358 udelay(1000);
350 359#endif
351 /* Copy the Rockbox framebuffer to the second framebuffer */ 360 /* Copy the Rockbox framebuffer to the second framebuffer */
352 memcpy(lcd_driver_framebuffer, lcd_framebuffer, 361 memcpy(lcd_driver_framebuffer, lcd_framebuffer,
353 sizeof(fb_data) * LCD_WIDTH * LCD_HEIGHT); 362 sizeof(fb_data) * LCD_WIDTH * LCD_HEIGHT);
354 flush_icache(); 363 flush_icache();
355 364#if 0
356 /* Restart DMA */ 365 /* Restart DMA */
357 LCD_REG_6 |= 1; 366 LCD_REG_6 |= 1;
367#endif
358 } 368 }
359} 369}
360 370
@@ -407,32 +417,35 @@ void lcd_yuv_blit(unsigned char * const src[3],
407 int src_x, int src_y, int stride, 417 int src_x, int src_y, int stride,
408 int x, int y, int width, int height) 418 int x, int y, int width, int height)
409{ 419{
410 /* Caches for chroma data so it only need be recaculated every other 420 if(DEV_EN & DEV_LCD)
411 line */ 421 {
412 static unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 330 bytes */ 422 /* Caches for chroma data so it only need be recaculated every other
413 unsigned char const * yuv_src[3]; 423 line */
414 off_t z; 424 static unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 330 bytes */
425 unsigned char const * yuv_src[3];
426 off_t z;
415 427
416 /* Sorry, but width and height must be >= 2 or else */ 428 /* Sorry, but width and height must be >= 2 or else */
417 width &= ~1; 429 width &= ~1;
418 height >>= 1; 430 height >>= 1;
419 431
420 fb_data *dst = (fb_data*)lcd_driver_framebuffer + 432 fb_data *dst = (fb_data*)lcd_driver_framebuffer +
421 x * LCD_WIDTH + (LCD_WIDTH - y) - 1; 433 x * LCD_WIDTH + (LCD_WIDTH - y) - 1;
422 434
423 z = stride*src_y; 435 z = stride*src_y;
424 yuv_src[0] = src[0] + z + src_x; 436 yuv_src[0] = src[0] + z + src_x;
425 yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); 437 yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
426 yuv_src[2] = src[2] + (yuv_src[1] - src[1]); 438 yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
427 439
428 do 440 do
429 { 441 {
430 lcd_write_yuv420_lines(dst, chroma_buf, yuv_src, width, 442 lcd_write_yuv420_lines(dst, chroma_buf, yuv_src, width,
431 stride); 443 stride);
432 yuv_src[0] += stride << 1; /* Skip down two luma lines */ 444 yuv_src[0] += stride << 1; /* Skip down two luma lines */
433 yuv_src[1] += stride >> 1; /* Skip down one chroma line */ 445 yuv_src[1] += stride >> 1; /* Skip down one chroma line */
434 yuv_src[2] += stride >> 1; 446 yuv_src[2] += stride >> 1;
435 dst -= 2; 447 dst -= 2;
448 }
449 while (--height > 0);
436 } 450 }
437 while (--height > 0);
438} 451}