diff options
Diffstat (limited to 'firmware/target/arm/philips/hdd1630/lcd-hdd1630.c')
-rwxr-xr-x | firmware/target/arm/philips/hdd1630/lcd-hdd1630.c | 91 |
1 files changed, 77 insertions, 14 deletions
diff --git a/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c index b58bafab13..6bb0668352 100755 --- a/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c @@ -77,6 +77,7 @@ /* Display status */ static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; +static unsigned mad_ctrl = 0; /* wait for LCD */ static inline void lcd_wait_write(void) @@ -179,6 +180,7 @@ void lcd_init_device(void) lcd_send_cmd(MADCTR); lcd_send_data(0); + mad_ctrl = 0; lcd_send_cmd(COLMOD); lcd_send_data(0x5); @@ -260,12 +262,13 @@ void lcd_set_invert_display(bool yesno) /* turn the display upside down (call lcd_update() afterwards) */ void lcd_set_flip(bool yesno) { - lcd_send_cmd(MADCTR); - - if (!yesno) - lcd_send_data(0); /* normal */ + if (yesno) + mad_ctrl |= ((1<<7) | (1<<6)); /* flip */ else - lcd_send_data((1<<7) | (1<<6)); /* y-mirror, x-mirror */ + mad_ctrl &= ~((1<<7) | (1<<6)); /* normal */ + + lcd_send_cmd(MADCTR); + lcd_send_data(mad_ctrl); } void lcd_yuv_set_options(unsigned options) @@ -273,21 +276,81 @@ void lcd_yuv_set_options(unsigned options) lcd_yuv_options = options; } +/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ +extern void lcd_write_yuv420_lines(unsigned char const * const src[3], + int width, int stride); + +extern void lcd_write_yuv420_lines_odither(unsigned char const * const src[3], + int width, int stride, + int x_screen, int y_screen); + /* Performance function to blit a YUV bitmap directly to the LCD */ void lcd_blit_yuv(unsigned char * const src[3], int src_x, int src_y, int stride, int x, int y, int width, int height) { - (void)src; - (void)src_x; - (void)src_y; - (void)stride; - (void)x; - (void)y; - (void)width; - (void)height; + unsigned char const * yuv_src[3]; + off_t z; + + /* Sorry, but width and height must be >= 2 or else */ + width &= ~1; + height >>= 1; + + z = stride*src_y; + yuv_src[0] = src[0] + z + src_x; + yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); + yuv_src[2] = src[2] + (yuv_src[1] - src[1]); + + /* Set vertical address mode */ + lcd_send_cmd(MADCTR); + lcd_send_data(mad_ctrl | (1<<5)); + + lcd_send_cmd(RASET); + lcd_send_data(x); + lcd_send_data(x + width - 1); + + if (lcd_yuv_options & LCD_YUV_DITHER) + { + do + { + lcd_send_cmd(CASET); + lcd_send_data(y); + lcd_send_data(y + 1); + + lcd_send_cmd(RAMWR); + + lcd_write_yuv420_lines_odither(yuv_src, width, stride, x, y); + yuv_src[0] += stride << 1; /* Skip down two luma lines */ + yuv_src[1] += stride >> 1; /* Skip down one chroma line */ + yuv_src[2] += stride >> 1; + y += 2; + } + while (--height > 0); + } + else + { + do + { + lcd_send_cmd(CASET); + lcd_send_data(y); + lcd_send_data(y + 1); + + lcd_send_cmd(RAMWR); + + lcd_write_yuv420_lines(yuv_src, width, stride); + yuv_src[0] += stride << 1; /* Skip down two luma lines */ + yuv_src[1] += stride >> 1; /* Skip down one chroma line */ + yuv_src[2] += stride >> 1; + y += 2; + } + while (--height > 0); + } + + /* Restore the address mode */ + lcd_send_cmd(MADCTR); + lcd_send_data(mad_ctrl); } - + /* Update the display. This must be called after all other LCD functions that change the display. */ void lcd_update(void) |