diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c index dba54373be..2e49e4d3d0 100644 --- a/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c +++ b/firmware/target/arm/imx233/sansa-fuzeplus/lcd-fuzeplus.c | |||
@@ -18,6 +18,7 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include <sys/types.h> /* off_t */ | ||
21 | #include <string.h> | 22 | #include <string.h> |
22 | #include "cpu.h" | 23 | #include "cpu.h" |
23 | #include "system.h" | 24 | #include "system.h" |
@@ -35,6 +36,8 @@ | |||
35 | extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, | 36 | extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, |
36 | int width, int height); | 37 | int width, int height); |
37 | 38 | ||
39 | static unsigned lcd_yuv_options = 0; | ||
40 | |||
38 | #ifdef HAVE_LCD_ENABLE | 41 | #ifdef HAVE_LCD_ENABLE |
39 | static bool lcd_on = false; | 42 | static bool lcd_on = false; |
40 | #endif | 43 | #endif |
@@ -517,3 +520,74 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
517 | (void) height; | 520 | (void) height; |
518 | lcd_update(); | 521 | lcd_update(); |
519 | } | 522 | } |
523 | |||
524 | void lcd_yuv_set_options(unsigned options) | ||
525 | { | ||
526 | lcd_yuv_options = options; | ||
527 | } | ||
528 | |||
529 | /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ | ||
530 | extern void lcd_write_yuv420_lines(fb_data *dst, | ||
531 | unsigned char const * const src[3], | ||
532 | int width, | ||
533 | int stride); | ||
534 | extern void lcd_write_yuv420_lines_odither(fb_data *dst, | ||
535 | unsigned char const * const src[3], | ||
536 | int width, | ||
537 | int stride, | ||
538 | int x_screen, /* To align dither pattern */ | ||
539 | int y_screen); | ||
540 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
541 | /* So the LCD_WIDTH is now the height */ | ||
542 | void lcd_blit_yuv(unsigned char * const src[3], | ||
543 | int src_x, int src_y, int stride, | ||
544 | int x, int y, int width, int height) | ||
545 | { | ||
546 | /* Caches for chroma data so it only need be recaculated every other | ||
547 | line */ | ||
548 | unsigned char const * yuv_src[3]; | ||
549 | off_t z; | ||
550 | |||
551 | #ifdef HAVE_LCD_ENABLE | ||
552 | if (!lcd_on) | ||
553 | return; | ||
554 | #endif | ||
555 | |||
556 | /* Sorry, but width and height must be >= 2 or else */ | ||
557 | width &= ~1; | ||
558 | height >>= 1; | ||
559 | |||
560 | y = LCD_WIDTH - 1 - y; | ||
561 | fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + y; | ||
562 | |||
563 | z = stride*src_y; | ||
564 | yuv_src[0] = src[0] + z + src_x; | ||
565 | yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); | ||
566 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | ||
567 | |||
568 | if (lcd_yuv_options & LCD_YUV_DITHER) | ||
569 | { | ||
570 | do | ||
571 | { | ||
572 | lcd_write_yuv420_lines_odither(dst, yuv_src, width, stride, y, x); | ||
573 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
574 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
575 | yuv_src[2] += stride >> 1; | ||
576 | dst -= 2; | ||
577 | y -= 2; | ||
578 | } | ||
579 | while (--height > 0); | ||
580 | } | ||
581 | else | ||
582 | { | ||
583 | do | ||
584 | { | ||
585 | lcd_write_yuv420_lines(dst, yuv_src, width, stride); | ||
586 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
587 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
588 | yuv_src[2] += stride >> 1; | ||
589 | dst -= 2; | ||
590 | } | ||
591 | while (--height > 0); | ||
592 | } | ||
593 | } | ||