From 418169aff8faf2cf90124cd95dba0af821cea73d Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Thu, 13 Oct 2022 11:03:53 -0400 Subject: Revert "Remove YUV blitting functions and LCD modes" This reverts commit fe6aa21e9eb88f49005863efd2003d0982920048. Change-Id: I8bb1e5d6c52ed1478002d2140ef494ec5d62b8e3 --- firmware/target/arm/pbell/vibe500/lcd-vibe500.c | 75 +++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'firmware/target/arm/pbell/vibe500/lcd-vibe500.c') diff --git a/firmware/target/arm/pbell/vibe500/lcd-vibe500.c b/firmware/target/arm/pbell/vibe500/lcd-vibe500.c index 2daa5def74..047ef2bf53 100644 --- a/firmware/target/arm/pbell/vibe500/lcd-vibe500.c +++ b/firmware/target/arm/pbell/vibe500/lcd-vibe500.c @@ -35,6 +35,8 @@ static unsigned short disp_control_rev; /* Contrast setting << 8 */ static int lcd_contrast; +static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; + /* Forward declarations */ #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) static void lcd_display_off(void); @@ -375,6 +377,79 @@ bool lcd_active(void) /*** update functions ***/ +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, /* To align dither pattern */ + 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) +{ + const unsigned char *yuv_src[3]; + const unsigned char *ysrc_max; + int y0; + int options; + + if (!display_on) + return; + + width &= ~1; + height &= ~1; + + lcd_write_reg(R_VERT_RAM_ADDR_POS, ((LCD_WIDTH - 1 - x) << 8) | + ((LCD_WIDTH-1) - (x + width - 1))); + + y0 = LCD_HEIGHT - 1 - y; + + lcd_write_reg(R_ENTRY_MODE,0x1000); + + yuv_src[0] = src[0] + src_y * stride + src_x; + yuv_src[1] = src[1] + (src_y * stride >> 2) + (src_x >> 1); + yuv_src[2] = src[2] + (yuv_src[1] - src[1]); + ysrc_max = yuv_src[0] + height * stride; + + options = lcd_yuv_options; + + do + { + lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (y0 << 8) | (y0 - 1)); + lcd_write_reg(R_RAM_ADDR_SET, ((LCD_WIDTH - 1 - x) << 8) | y0); + + /* start drawing */ + lcd_send_cmd(R_WRITE_DATA_2_GRAM); + + if (options & LCD_YUV_DITHER) + { + lcd_write_yuv420_lines_odither(yuv_src, width, stride,x, y); + y -= 2; + } + else + { + lcd_write_yuv420_lines(yuv_src, width, stride); + } + + y0 -= 2; + yuv_src[0] += stride << 1; + yuv_src[1] += stride >> 1; + yuv_src[2] += stride >> 1; + } + while (yuv_src[0] < ysrc_max); + lcd_write_reg(R_ENTRY_MODE,0x1008); +} + /* Update a fraction of the display. */ void lcd_update_rect(int x0, int y0, int width, int height) { -- cgit v1.2.3