summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2020-11-13 12:41:13 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2020-11-13 18:08:01 +0000
commitf65fb2a64abaf66b4d695be7fb3e114febea6bd1 (patch)
tree44fb913004ef2c82f5d56a7a6acc4ec4af319a79 /firmware
parent8ac46f844f437a31f72d73a41a6d3852d8b96143 (diff)
downloadrockbox-f65fb2a64abaf66b4d695be7fb3e114febea6bd1.tar.gz
rockbox-f65fb2a64abaf66b4d695be7fb3e114febea6bd1.zip
h300, Others Bugfix Bootloader backlight_init()
backlight_init needs to be called after lcd_init when using lcd_enable() Change-Id: Id034835c903801fea49e2b972c110c1ec5106976
Diffstat (limited to 'firmware')
-rw-r--r--firmware/target/coldfire/iriver/h300/lcd-h300.c100
1 files changed, 40 insertions, 60 deletions
diff --git a/firmware/target/coldfire/iriver/h300/lcd-h300.c b/firmware/target/coldfire/iriver/h300/lcd-h300.c
index c415ed6c37..7e73ea3905 100644
--- a/firmware/target/coldfire/iriver/h300/lcd-h300.c
+++ b/firmware/target/coldfire/iriver/h300/lcd-h300.c
@@ -32,16 +32,23 @@
32#include "font.h" 32#include "font.h"
33#include "bidi.h" 33#include "bidi.h"
34 34
35static bool display_on = false; /* Is the display turned on? */
36static bool display_flipped = false;
37static int xoffset = 0; /* Needed for flip */
38#ifndef BOOTLOADER 35#ifndef BOOTLOADER
36#define LCD_MUTEX_INIT() mutex_init(&lcd_mtx)
37#define LCD_MUTEX_LOCK() mutex_lock(&lcd_mtx)
38#define LCD_MUTEX_UNLOCK() mutex_unlock(&lcd_mtx)
39static struct mutex lcd_mtx; /* The update functions use DMA and yield */ 39static struct mutex lcd_mtx; /* The update functions use DMA and yield */
40
41unsigned long dma_addr IBSS_ATTR; 40unsigned long dma_addr IBSS_ATTR;
42unsigned int dma_len IBSS_ATTR; 41unsigned int dma_len IBSS_ATTR;
43volatile int dma_count IBSS_ATTR; 42volatile int dma_count IBSS_ATTR;
44#endif 43#else
44#define LCD_MUTEX_INIT()
45#define LCD_MUTEX_LOCK()
46#define LCD_MUTEX_UNLOCK()
47#endif /* def BOOTLOADER */
48
49static bool display_on = false; /* Is the display turned on? */
50static bool display_flipped = false;
51static int xoffset = 0; /* Needed for flip */
45 52
46/* register defines */ 53/* register defines */
47#define R_START_OSC 0x00 54#define R_START_OSC 0x00
@@ -141,13 +148,9 @@ void lcd_set_flip(bool yesno)
141 148
142 if (display_on) 149 if (display_on)
143 { 150 {
144#ifndef BOOTLOADER 151 LCD_MUTEX_LOCK();
145 mutex_lock(&lcd_mtx);
146#endif
147 flip_lcd(yesno); 152 flip_lcd(yesno);
148#ifndef BOOTLOADER 153 LCD_MUTEX_UNLOCK();
149 mutex_unlock(&lcd_mtx);
150#endif
151 } 154 }
152} 155}
153 156
@@ -270,13 +273,12 @@ void lcd_init_device(void)
270 273
271#ifndef BOOTLOADER 274#ifndef BOOTLOADER
272 DAR3 = 0xf0000002; /* Configure DMA channel 3 */ 275 DAR3 = 0xf0000002; /* Configure DMA channel 3 */
273 DSR3 = 1; 276 DSR3 = 1; /* Clear all bits in the status register */
274 DIVR3 = 57; /* DMA3 is mapped into vector 57 in system.c */ 277 DIVR3 = 57; /* DMA3 is mapped into vector 57 in system.c */
275 ICR9 = (6 << 2); /* Enable DMA3 interrupt at level 6, priority 0 */ 278 ICR9 = (6 << 2); /* Enable DMA3 interrupt at level 6, priority 0 */
276 coldfire_imr_mod(0, 1 << 17); 279 coldfire_imr_mod(0, 1 << 17);
277
278 mutex_init(&lcd_mtx);
279#endif 280#endif
281 LCD_MUTEX_INIT();
280 _display_on(); 282 _display_on();
281} 283}
282 284
@@ -284,9 +286,7 @@ void lcd_enable(bool on)
284{ 286{
285 if (display_on != on) 287 if (display_on != on)
286 { 288 {
287#ifndef BOOTLOADER 289 LCD_MUTEX_LOCK();
288 mutex_lock(&lcd_mtx);
289#endif
290 if (on) 290 if (on)
291 { 291 {
292 _display_on(); 292 _display_on();
@@ -314,9 +314,7 @@ void lcd_enable(bool on)
314 314
315 display_on=false; 315 display_on=false;
316 } 316 }
317#ifndef BOOTLOADER 317 LCD_MUTEX_UNLOCK();
318 mutex_unlock(&lcd_mtx);
319#endif
320 } 318 }
321} 319}
322 320
@@ -352,9 +350,7 @@ void lcd_blit_yuv(unsigned char * const src[3],
352 if (!display_on) 350 if (!display_on)
353 return; 351 return;
354 352
355#ifndef BOOTLOADER 353 LCD_MUTEX_LOCK();
356 mutex_lock(&lcd_mtx);
357#endif
358 width &= ~1; /* stay on the safe side */ 354 width &= ~1; /* stay on the safe side */
359 height &= ~1; 355 height &= ~1;
360 356
@@ -385,10 +381,9 @@ void lcd_blit_yuv(unsigned char * const src[3],
385 usrc += stride >> 1; 381 usrc += stride >> 1;
386 vsrc += stride >> 1; 382 vsrc += stride >> 1;
387 } 383 }
388 while (ysrc < ysrc_max); 384 while (ysrc < ysrc_max)
389#ifndef BOOTLOADER 385 ;;
390 mutex_unlock(&lcd_mtx); 386 LCD_MUTEX_UNLOCK();
391#endif
392} 387}
393 388
394#ifndef BOOTLOADER 389#ifndef BOOTLOADER
@@ -396,7 +391,7 @@ void lcd_blit_yuv(unsigned char * const src[3],
396void DMA3(void) __attribute__ ((interrupt_handler, section(".icode"))); 391void DMA3(void) __attribute__ ((interrupt_handler, section(".icode")));
397void DMA3(void) 392void DMA3(void)
398{ 393{
399 DSR3 = 1; 394 DSR3 = 1; /* Clear all bits in the status register */
400 if (--dma_count > 0) 395 if (--dma_count > 0)
401 { 396 {
402 dma_addr += LCD_WIDTH*sizeof(fb_data); 397 dma_addr += LCD_WIDTH*sizeof(fb_data);
@@ -415,9 +410,7 @@ void lcd_update(void)
415{ 410{
416 if (display_on) 411 if (display_on)
417 { 412 {
418#ifndef BOOTLOADER 413 LCD_MUTEX_LOCK();
419 mutex_lock(&lcd_mtx);
420#endif
421 414
422 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_VERT); 415 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_VERT);
423 /* set start position window */ 416 /* set start position window */
@@ -437,25 +430,33 @@ void lcd_update(void)
437 430
438 while (dma_count > 0) 431 while (dma_count > 0)
439 yield(); 432 yield();
440
441 mutex_unlock(&lcd_mtx);
442#else 433#else
443 DAR3 = 0xf0000002; 434 DAR3 = 0xf0000002;
435 DSR3 = 1; /* Clear all bits in the status register */
444 SAR3 = (unsigned long)FBADDR(0, 0); 436 SAR3 = (unsigned long)FBADDR(0, 0);
445 BCR3 = LCD_WIDTH*LCD_HEIGHT*sizeof(fb_data); 437 BCR3 = LCD_WIDTH*LCD_HEIGHT*sizeof(fb_data);
446 DCR3 = DMA_AA | DMA_BWC(1) 438 DCR3 = DMA_AA | DMA_BWC(1)
447 | DMA_SINC | DMA_SSIZE(DMA_SIZE_LINE) 439 | DMA_SINC | DMA_SSIZE(DMA_SIZE_LINE)
448 | DMA_DSIZE(DMA_SIZE_WORD) | DMA_START; 440 | DMA_DSIZE(DMA_SIZE_WORD) | DMA_START;
449 441
450 while (!(DSR3 & 1)); 442 while (!(DSR3 & 1))
451 DSR3 = 1; 443 ;;
444 DSR3 = 1; /* Clear all bits in the status register */
452#endif 445#endif
446 LCD_MUTEX_UNLOCK();
453 } 447 }
454} 448}
455 449
456/* Update a fraction of the display. */ 450/* Update a fraction of the display. */
457void lcd_update_rect(int x, int y, int width, int height) 451void lcd_update_rect(int x, int y, int width, int height)
458{ 452{
453#ifdef BOOTLOADER
454 (void)x;
455 (void)y;
456 (void)width;
457 (void)height;
458 lcd_update(); /* in bootloader -- all or nothing */
459#else
459 if (display_on) 460 if (display_on)
460 { 461 {
461 if (x + width > LCD_WIDTH) 462 if (x + width > LCD_WIDTH)
@@ -466,9 +467,7 @@ void lcd_update_rect(int x, int y, int width, int height)
466 if (width <= 0 || height <= 0) /* nothing to do */ 467 if (width <= 0 || height <= 0) /* nothing to do */
467 return; 468 return;
468 469
469#ifndef BOOTLOADER 470 LCD_MUTEX_LOCK();
470 mutex_lock(&lcd_mtx);
471#endif
472 471
473 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_VERT); 472 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_VERT);
474 /* set update window */ 473 /* set update window */
@@ -477,8 +476,7 @@ void lcd_update_rect(int x, int y, int width, int height)
477 lcd_write_reg(R_RAM_ADDR_SET, ((x+xoffset) << 8) | y); 476 lcd_write_reg(R_RAM_ADDR_SET, ((x+xoffset) << 8) | y);
478 477
479 lcd_begin_write_gram(); 478 lcd_begin_write_gram();
480 479
481#ifndef BOOTLOADER
482 if (width == LCD_WIDTH) 480 if (width == LCD_WIDTH)
483 { 481 {
484 dma_count = 1; 482 dma_count = 1;
@@ -498,25 +496,7 @@ void lcd_update_rect(int x, int y, int width, int height)
498 while (dma_count > 0) 496 while (dma_count > 0)
499 yield(); 497 yield();
500 498
501 mutex_unlock(&lcd_mtx); 499 LCD_MUTEX_UNLOCK();
502#else
503 DAR3 = 0xf0000002;
504 unsigned long dma_addr = (unsigned long)FBADDR(x, y);
505 width *= sizeof(fb_data);
506
507 for (; height > 0; height--)
508 {
509 SAR3 = dma_addr;
510 BCR3 = width;
511 DCR3 = DMA_AA | DMA_BWC(1)
512 | DMA_SINC | DMA_SSIZE(DMA_SIZE_LINE)
513 | DMA_DSIZE(DMA_SIZE_WORD) | DMA_START;
514
515 dma_addr += LCD_WIDTH*sizeof(fb_data);
516
517 while (!(DSR3 & 1));
518 DSR3 = 1;
519 }
520#endif
521 } 500 }
501#endif /* ndef BOOTLOADER */
522} 502}