summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2006-08-08 21:28:08 +0000
committerDave Chapman <dave@dchapman.com>2006-08-08 21:28:08 +0000
commit13b23fbcdb38dc2865d550ae5cc5bdaa8e444264 (patch)
tree460022828d88e5c60335b0e06ecc4ec339cd7c4c
parentc4c56a3da7a3ef868b853fb8f434198d6b9f9ee9 (diff)
downloadrockbox-13b23fbcdb38dc2865d550ae5cc5bdaa8e444264.zip
rockbox-13b23fbcdb38dc2865d550ae5cc5bdaa8e444264.tar.gz
rockbox-13b23fbcdb38dc2865d550ae5cc5bdaa8e444264.tar.bz2
rockbox-13b23fbcdb38dc2865d550ae5cc5bdaa8e444264.tar.xz
Implementation of lcd_yuv_blit() for the ipod 5g.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10487 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.c3
-rw-r--r--apps/plugin.h3
-rw-r--r--apps/plugins/mpegplayer/video_out_rockbox.c3
-rw-r--r--firmware/drivers/lcd-ipodvideo.c164
-rw-r--r--firmware/export/lcd.h2
5 files changed, 169 insertions, 6 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index bbc5d7d..6641fe2 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -464,7 +464,8 @@ static const struct plugin_api rockbox_api = {
#endif
#if (CONFIG_LCD == LCD_IPODCOLOR || CONFIG_LCD == LCD_IPODNANO \
- || CONFIG_LCD == LCD_H300) && !defined(SIMULATOR)
+ || CONFIG_LCD == LCD_H300 || CONFIG_LCD == LCD_IPODVIDEO) && \
+ !defined(SIMULATOR)
lcd_yuv_blit,
#endif
diff --git a/apps/plugin.h b/apps/plugin.h
index f43e0ae..9f17fa6 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -540,7 +540,8 @@ struct plugin_api {
int height);
#endif
#if (CONFIG_LCD == LCD_IPODCOLOR || CONFIG_LCD == LCD_IPODNANO \
- || CONFIG_LCD == LCD_H300) && !defined(SIMULATOR)
+ || CONFIG_LCD == LCD_H300 || CONFIG_LCD == LCD_IPODVIDEO) && \
+ !defined(SIMULATOR)
void (*lcd_yuv_blit)(unsigned char * const src[3],
int src_x, int src_y, int stride,
int x, int y, int width, int height);
diff --git a/apps/plugins/mpegplayer/video_out_rockbox.c b/apps/plugins/mpegplayer/video_out_rockbox.c
index c77c433..174921e 100644
--- a/apps/plugins/mpegplayer/video_out_rockbox.c
+++ b/apps/plugins/mpegplayer/video_out_rockbox.c
@@ -201,7 +201,8 @@ static void rockbox_draw_frame (vo_instance_t * instance,
(void)instance;
#if (CONFIG_LCD == LCD_IPODCOLOR || CONFIG_LCD == LCD_IPODNANO \
- || CONFIG_LCD == LCD_H300) && !defined(SIMULATOR)
+ || CONFIG_LCD == LCD_H300 || CONFIG_LCD == LCD_IPODVIDEO) \
+ && !defined(SIMULATOR)
rb->lcd_yuv_blit(buf,
0,0,image_width,
output_x,output_y,output_width,output_height);
diff --git a/firmware/drivers/lcd-ipodvideo.c b/firmware/drivers/lcd-ipodvideo.c
index b94ab0b..25ae235 100644
--- a/firmware/drivers/lcd-ipodvideo.c
+++ b/firmware/drivers/lcd-ipodvideo.c
@@ -118,12 +118,12 @@ static unsigned lcd_bcm_read32(unsigned address) {
return inw(0x30000000) | inw(0x30000000) << 16;
}
+static int finishup_needed = 0;
+
/* Update a fraction of the display. */
void lcd_update_rect(int x, int y, int width, int height) ICODE_ATTR;
void lcd_update_rect(int x, int y, int width, int height)
{
- static int finishup_needed = 0;
-
{
int endy = x + width;
/* Ensure x and width are both even - so we can read 32-bit aligned
@@ -204,3 +204,163 @@ void lcd_update(void)
{
lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
}
+
+#define CSUB_X 2
+#define CSUB_Y 2
+
+#define RYFAC (31*257)
+#define GYFAC (63*257)
+#define BYFAC (31*257)
+#define RVFAC 11170 /* 31 * 257 * 1.402 */
+#define GVFAC (-11563) /* 63 * 257 * -0.714136 */
+#define GUFAC (-5572) /* 63 * 257 * -0.344136 */
+#define BUFAC 14118 /* 31 * 257 * 1.772 */
+
+#define ROUNDOFFS (127*257)
+
+/* Performance function to blit a YUV bitmap directly to the LCD */
+void lcd_yuv_blit(unsigned char * const src[3],
+ int src_x, int src_y, int stride,
+ int x, int y, int width, int height)
+{
+ int ymax;
+
+ width = (width + 1) & ~1;
+
+ if (finishup_needed) {
+ unsigned int data;
+ /* Bottom-half of original lcd_bcm_finishup() function */
+ do {
+ /* This function takes about 14ms to execute - so we yield() */
+ yield();
+ data = lcd_bcm_read32(0x1F8);
+ } while (data == 0xFFFA0005 || data == 0xFFFF);
+ }
+
+ lcd_bcm_read32(0x1FC);
+
+ {
+ int rect1, rect2, rect3, rect4;
+ int count = (width * height) << 1;
+ /* calculate the drawing region */
+ rect1 = x; /* start horiz */
+ rect2 = y; /* start vert */
+ rect3 = (x + width) - 1; /* max horiz */
+ rect4 = (y + height) - 1; /* max vert */
+
+ /* setup the drawing region */
+ lcd_bcm_setup_rect(0x34, rect1, rect2, rect3, rect4, count);
+ }
+
+ /* write out destination address as two 16bit values */
+ outw((0xE0020 & 0xffff), 0x30010000);
+ outw((0xE0020 >> 16), 0x30010000);
+
+ /* wait for it to be write ready */
+ while ((inw(0x30030000) & 0x2) == 0);
+
+ ymax = y + height - 1 ;
+
+ for (; y <= ymax ; y++)
+ {
+ /* upsampling, YUV->RGB conversion and reduction to RGB565 in one go */
+ const unsigned char *ysrc = src[0] + stride * src_y + src_x;
+ const unsigned char *usrc = src[1] + (stride/CSUB_X) * (src_y/CSUB_Y)
+ + (src_x/CSUB_X);
+ const unsigned char *vsrc = src[2] + (stride/CSUB_X) * (src_y/CSUB_Y)
+ + (src_x/CSUB_X);
+ const unsigned char *row_end = ysrc + width;
+
+ int y, u, v;
+ int red, green, blue;
+ unsigned rbits, gbits, bbits;
+ unsigned short pixel;
+
+ int rc, gc, bc;
+
+ do
+ {
+ u = *usrc++ - 128;
+ v = *vsrc++ - 128;
+ rc = RVFAC * v + ROUNDOFFS;
+ gc = GVFAC * v + GUFAC * u + ROUNDOFFS;
+ bc = BUFAC * u + ROUNDOFFS;
+
+ /* Pixel 1 */
+ y = *ysrc++;
+ red = RYFAC * y + rc;
+ green = GYFAC * y + gc;
+ blue = BYFAC * y + bc;
+
+ if ((unsigned)red > (RYFAC*255+ROUNDOFFS))
+ {
+ if (red < 0)
+ red = 0;
+ else
+ red = (RYFAC*255+ROUNDOFFS);
+ }
+ if ((unsigned)green > (GYFAC*255+ROUNDOFFS))
+ {
+ if (green < 0)
+ green = 0;
+ else
+ green = (GYFAC*255+ROUNDOFFS);
+ }
+ if ((unsigned)blue > (BYFAC*255+ROUNDOFFS))
+ {
+ if (blue < 0)
+ blue = 0;
+ else
+ blue = (BYFAC*255+ROUNDOFFS);
+ }
+ rbits = ((unsigned)red) >> 16 ;
+ gbits = ((unsigned)green) >> 16 ;
+ bbits = ((unsigned)blue) >> 16 ;
+
+ outw((rbits << 11) | (gbits << 5) | bbits, 0x30000000);
+
+ /* Pixel 2 */
+ y = *ysrc++;
+ red = RYFAC * y + rc;
+ green = GYFAC * y + gc;
+ blue = BYFAC * y + bc;
+
+ if ((unsigned)red > (RYFAC*255+ROUNDOFFS))
+ {
+ if (red < 0)
+ red = 0;
+ else
+ red = (RYFAC*255+ROUNDOFFS);
+ }
+ if ((unsigned)green > (GYFAC*255+ROUNDOFFS))
+ {
+ if (green < 0)
+ green = 0;
+ else
+ green = (GYFAC*255+ROUNDOFFS);
+ }
+ if ((unsigned)blue > (BYFAC*255+ROUNDOFFS))
+ {
+ if (blue < 0)
+ blue = 0;
+ else
+ blue = (BYFAC*255+ROUNDOFFS);
+ }
+ rbits = ((unsigned)red) >> 16 ;
+ gbits = ((unsigned)green) >> 16 ;
+ bbits = ((unsigned)blue) >> 16 ;
+
+ outw((rbits << 11) | (gbits << 5) | bbits, 0x30000000);
+ }
+ while (ysrc < row_end);
+
+ src_y++;
+ }
+
+ /* Top-half of original lcd_bcm_finishup() function */
+ outw(0x31, 0x30030000);
+
+ lcd_bcm_read32(0x1FC);
+
+ finishup_needed = 1;
+}
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index 7551a1a..c3ad4f9 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -72,7 +72,7 @@ extern void lcd_puts_scroll_style(int x, int y, const unsigned char* string,
extern void lcd_icon(int icon, bool enable);
#if CONFIG_LCD == LCD_IPODCOLOR || CONFIG_LCD == LCD_IPODNANO \
- || CONFIG_LCD == LCD_H300
+ || CONFIG_LCD == LCD_H300 || CONFIG_LCD == LCD_IPODVIDEO
void lcd_yuv_blit(unsigned char * const src[3],
int src_x, int src_y, int stride,
int x, int y, int width, int height);