diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c index ea06551d24..60a32b510b 100644 --- a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c +++ b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c | |||
@@ -36,6 +36,10 @@ | |||
36 | static bool display_on = false; /* is the display turned on? */ | 36 | static bool display_on = false; /* is the display turned on? */ |
37 | static bool display_flipped = false; | 37 | static bool display_flipped = false; |
38 | static int y_offset = 0; /* needed for flip */ | 38 | static int y_offset = 0; /* needed for flip */ |
39 | /* we need to write a red pixel for correct button reads | ||
40 | * (see lcd_button_support()), but that must not happen while the lcd is updating | ||
41 | * so block lcd_button_support the during updates */ | ||
42 | static volatile bool lcd_busy = false; | ||
39 | 43 | ||
40 | /* register defines */ | 44 | /* register defines */ |
41 | #define R_START_OSC 0x00 | 45 | #define R_START_OSC 0x00 |
@@ -365,12 +369,10 @@ void lcd_update(void) | |||
365 | { | 369 | { |
366 | if (!display_on) | 370 | if (!display_on) |
367 | return; | 371 | return; |
368 | 372 | ||
369 | /* we must disable interrupts because buttondriver also writes to lcd */ | ||
370 | disable_irq(); | ||
371 | |||
372 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); | 373 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); |
373 | 374 | ||
375 | lcd_busy = true; | ||
374 | /* Set start position and window */ | 376 | /* Set start position and window */ |
375 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_WIDTH-1) << 8); | 377 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_WIDTH-1) << 8); |
376 | lcd_write_reg(R_VERT_RAM_ADDR_POS, | 378 | lcd_write_reg(R_VERT_RAM_ADDR_POS, |
@@ -381,7 +383,7 @@ void lcd_update(void) | |||
381 | 383 | ||
382 | lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT); | 384 | lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT); |
383 | 385 | ||
384 | enable_irq(); | 386 | lcd_busy = false; |
385 | } /* lcd_update */ | 387 | } /* lcd_update */ |
386 | 388 | ||
387 | 389 | ||
@@ -393,7 +395,7 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
393 | 395 | ||
394 | if (!display_on) | 396 | if (!display_on) |
395 | return; | 397 | return; |
396 | 398 | ||
397 | if (x + width > LCD_WIDTH) | 399 | if (x + width > LCD_WIDTH) |
398 | width = LCD_WIDTH - x; /* Clip right */ | 400 | width = LCD_WIDTH - x; /* Clip right */ |
399 | if (x < 0) | 401 | if (x < 0) |
@@ -409,10 +411,8 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
409 | if (y >= ymax) | 411 | if (y >= ymax) |
410 | return; /* nothing left to do */ | 412 | return; /* nothing left to do */ |
411 | 413 | ||
412 | /* we must disable interrupts because buttondriver also writes to lcd */ | ||
413 | disable_irq(); | ||
414 | |||
415 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); | 414 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); |
415 | lcd_busy = true; | ||
416 | /* Set start position and window */ | 416 | /* Set start position and window */ |
417 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, | 417 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, |
418 | ((x + width-1) << 8) | x); | 418 | ((x + width-1) << 8) | x); |
@@ -430,8 +430,8 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
430 | ptr += LCD_WIDTH; | 430 | ptr += LCD_WIDTH; |
431 | } | 431 | } |
432 | while (++y < ymax); | 432 | while (++y < ymax); |
433 | 433 | ||
434 | enable_irq(); | 434 | lcd_busy = false; |
435 | } /* lcd_update_rect */ | 435 | } /* lcd_update_rect */ |
436 | 436 | ||
437 | /* writes one read pixel outside the visible area, needed for correct dbop reads */ | 437 | /* writes one read pixel outside the visible area, needed for correct dbop reads */ |
@@ -440,9 +440,12 @@ void lcd_button_support(void) | |||
440 | int x=LCD_HEIGHT+1; | 440 | int x=LCD_HEIGHT+1; |
441 | int y=LCD_WIDTH+1; | 441 | int y=LCD_WIDTH+1; |
442 | int width=1; | 442 | int width=1; |
443 | int height=1; | 443 | int height=1; |
444 | unsigned short data = (0xf<<12); | 444 | unsigned short data = (0xf<<12); |
445 | 445 | ||
446 | if (lcd_busy) | ||
447 | return; | ||
448 | |||
446 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); | 449 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); |
447 | /* Set start position and window */ | 450 | /* Set start position and window */ |
448 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, | 451 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, |