diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2022-10-13 11:03:53 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2022-10-13 11:08:06 -0400 |
commit | 418169aff8faf2cf90124cd95dba0af821cea73d (patch) | |
tree | 4fc206af57c9a07fba6cbcb3517fa946a7b84668 /firmware/target/arm/philips/sa9200/lcd-sa9200.c | |
parent | f9ea1fc79d6aaff9949a5b11ae011b4e04e0e9d9 (diff) | |
download | rockbox-418169aff8faf2cf90124cd95dba0af821cea73d.tar.gz rockbox-418169aff8faf2cf90124cd95dba0af821cea73d.zip |
Revert "Remove YUV blitting functions and LCD modes"
This reverts commit fe6aa21e9eb88f49005863efd2003d0982920048.
Change-Id: I8bb1e5d6c52ed1478002d2140ef494ec5d62b8e3
Diffstat (limited to 'firmware/target/arm/philips/sa9200/lcd-sa9200.c')
-rw-r--r-- | firmware/target/arm/philips/sa9200/lcd-sa9200.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/firmware/target/arm/philips/sa9200/lcd-sa9200.c b/firmware/target/arm/philips/sa9200/lcd-sa9200.c index c6c297e6ca..e30a298045 100644 --- a/firmware/target/arm/philips/sa9200/lcd-sa9200.c +++ b/firmware/target/arm/philips/sa9200/lcd-sa9200.c | |||
@@ -75,6 +75,9 @@ static void lcd_display_off(void); | |||
75 | #define R_GATE_OUT_PERIOD_CTRL 0x71 | 75 | #define R_GATE_OUT_PERIOD_CTRL 0x71 |
76 | #define R_SOFTWARE_RESET 0x72 | 76 | #define R_SOFTWARE_RESET 0x72 |
77 | 77 | ||
78 | /* Display status */ | ||
79 | static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; | ||
80 | |||
78 | /* wait for LCD */ | 81 | /* wait for LCD */ |
79 | static inline void lcd_wait_write(void) | 82 | static inline void lcd_wait_write(void) |
80 | { | 83 | { |
@@ -404,6 +407,85 @@ void lcd_set_flip(bool yesno) | |||
404 | lcd_write_reg(R_DRV_OUTPUT_CONTROL, flip ? 0x090c : 0x0a0c); | 407 | lcd_write_reg(R_DRV_OUTPUT_CONTROL, flip ? 0x090c : 0x0a0c); |
405 | } | 408 | } |
406 | 409 | ||
410 | void lcd_yuv_set_options(unsigned options) | ||
411 | { | ||
412 | lcd_yuv_options = options; | ||
413 | } | ||
414 | |||
415 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
416 | void lcd_write_yuv420_lines(unsigned char const * const src[3], | ||
417 | int width, | ||
418 | int stride); | ||
419 | void lcd_write_yuv420_lines_odither(unsigned char const * const src[3], | ||
420 | int width, | ||
421 | int stride, | ||
422 | int x_screen, | ||
423 | int y_screen); | ||
424 | void lcd_blit_yuv(unsigned char * const src[3], | ||
425 | int src_x, int src_y, int stride, | ||
426 | int x, int y, int width, int height) | ||
427 | { | ||
428 | const unsigned char *yuv_src[3]; | ||
429 | const unsigned char *ysrc_max; | ||
430 | int options; | ||
431 | |||
432 | if (!display_on) | ||
433 | return; | ||
434 | |||
435 | width &= ~1; | ||
436 | height &= ~1; | ||
437 | |||
438 | /* calculate the drawing region */ | ||
439 | lcd_write_reg(R_VERT_RAM_ADDR_POS, ((x + width - 1) << 8) | x); | ||
440 | |||
441 | /* convert YUV coordinates to screen coordinates */ | ||
442 | y = LCD_WIDTH - 1 - y; | ||
443 | |||
444 | /* 2px strip: cursor moves left, then down in gram */ | ||
445 | /* BGR=1, MDT1-0=00, I/D1-0=10, AM=0 */ | ||
446 | lcd_write_reg(R_ENTRY_MODE, 0x1020); | ||
447 | |||
448 | yuv_src[0] = src[0] + src_y * stride + src_x; | ||
449 | yuv_src[1] = src[1] + (src_y * stride >> 2) + (src_x >> 1); | ||
450 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | ||
451 | ysrc_max = yuv_src[0] + height * stride; | ||
452 | |||
453 | /* cache options setting */ | ||
454 | options = lcd_yuv_options; | ||
455 | |||
456 | do | ||
457 | { | ||
458 | /* max horiz << 8 | start horiz */ | ||
459 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (y << 8) | (y - 1)); | ||
460 | |||
461 | /* position cursor (set AD0-AD15) */ | ||
462 | lcd_write_reg(R_RAM_ADDR_SET, (x << 8) | y); | ||
463 | |||
464 | /* start drawing */ | ||
465 | lcd_send_command(R_WRITE_DATA_2_GRAM); | ||
466 | |||
467 | if (options & LCD_YUV_DITHER) | ||
468 | { | ||
469 | lcd_write_yuv420_lines_odither(yuv_src, width, stride, | ||
470 | y, x); | ||
471 | } | ||
472 | else | ||
473 | { | ||
474 | lcd_write_yuv420_lines(yuv_src, width, stride); | ||
475 | } | ||
476 | |||
477 | y -= 2; /* move strip by "down" 2 px */ | ||
478 | yuv_src[0] += stride << 1; | ||
479 | yuv_src[1] += stride >> 1; | ||
480 | yuv_src[2] += stride >> 1; | ||
481 | } | ||
482 | while (yuv_src[0] < ysrc_max); | ||
483 | |||
484 | /* back to normal right, then down cursor in gram */ | ||
485 | /* BGR=1, MDT1-0=00, I/D1-0=11, AM=0 */ | ||
486 | lcd_write_reg(R_ENTRY_MODE, 0x1030); | ||
487 | } | ||
488 | |||
407 | /* Update the display. | 489 | /* Update the display. |
408 | This must be called after all other LCD functions that change the display. */ | 490 | This must be called after all other LCD functions that change the display. */ |
409 | void lcd_update(void) | 491 | void lcd_update(void) |