summaryrefslogtreecommitdiff
path: root/firmware/target/arm/sandisk
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2007-10-07 17:54:49 +0000
committerJens Arnold <amiconn@rockbox.org>2007-10-07 17:54:49 +0000
commitd1e2f5240cd32fc7d77edcc089370e79a55f30b1 (patch)
treecd685228f2deb791d88de04d9bf3072d70162aa1 /firmware/target/arm/sandisk
parente3e0a3a1691c820198f7b7cea6c17e2fb063d2bb (diff)
c200: First implemention of lcd_yuv_blit(). mpegplayer works now, but speed can be optimized more and dithering is not yet implemented.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@15020 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/sandisk')
-rw-r--r--firmware/target/arm/sandisk/sansa-c200/lcd-as-c200.S243
-rw-r--r--firmware/target/arm/sandisk/sansa-c200/lcd-c200.c49
2 files changed, 284 insertions, 8 deletions
diff --git a/firmware/target/arm/sandisk/sansa-c200/lcd-as-c200.S b/firmware/target/arm/sandisk/sansa-c200/lcd-as-c200.S
new file mode 100644
index 0000000000..9b0cd75bae
--- /dev/null
+++ b/firmware/target/arm/sandisk/sansa-c200/lcd-as-c200.S
@@ -0,0 +1,243 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 by Jens Arnold
+ * Heavily based on lcd-as-memframe.c by Michael Sevakis
+ *
+ * All files in this archive are subject to the GNU General Public License.
+ * See the file COPYING in the source tree root for full license agreement.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ****************************************************************************/
+
+#include "config.h"
+#include "cpu.h"
+
+/****************************************************************************
+ * void lcd_write_yuv_420_lines(unsigned char const * const src[3],
+ * int width,
+ * int stride);
+ *
+ * |R| |1.000000 -0.000001 1.402000| |Y'|
+ * |G| = |1.000000 -0.334136 -0.714136| |Pb|
+ * |B| |1.000000 1.772000 0.000000| |Pr|
+ * Scaled, normalized, rounded and tweaked to yield RGB 565:
+ * |R| |74 0 101| |Y' - 16| >> 9
+ * |G| = |74 -24 -51| |Cb - 128| >> 8
+ * |B| |74 128 0| |Cr - 128| >> 9
+ *
+ * Write four RGB565 pixels in the following order on each loop:
+ * 1 3 + > down
+ * 2 4 \/ left
+ */
+ .section .icode, "ax", %progbits
+ .align 2
+ .global lcd_write_yuv420_lines
+ .type lcd_write_yuv420_lines, %function
+lcd_write_yuv420_lines:
+ @ r0 = yuv_src
+ @ r1 = width
+ @ r2 = stride
+ stmfd sp!, { r4-r12 } @ save non-scratch
+ ldmia r0, { r4, r5, r6 } @ r4 = yuv_src[0] = Y'_p
+ @ r5 = yuv_src[1] = Cb_p
+ @ r6 = yuv_src[2] = Cr_p
+ @ r0 = scratch
+ sub r2, r2, #1 @
+ mov r3, #0x70000000 @
+ orr r3, r3, #0x3000 @ r3 = LCD1_BASE
+10: @ loop line @
+ ldrb r7, [r4], #1 @ r7 = *Y'_p++;
+ ldrb r8, [r5], #1 @ r8 = *Cb_p++;
+ ldrb r9, [r6], #1 @ r9 = *Cr_p++;
+ @
+ sub r7, r7, #16 @ r7 = Y = (Y' - 16)*74
+ add r12, r7, r7, asl #2 @ actually (Y' - 16)*37 and shift right
+ add r7, r12, r7, asl #5 @ by one less when adding - same for all
+ @
+ sub r8, r8, #128 @ Cb -= 128
+ sub r9, r9, #128 @ Cr -= 128
+ @
+ add r10, r9, r9, asl #1 @ r10 = Cr*51 + Cb*24
+ add r10, r10, r10, asl #4 @
+ add r10, r10, r8, asl #3 @
+ add r10, r10, r8, asl #4 @
+ @
+ add r11, r9, r9, asl #2 @ r9 = Cr*101
+ add r11, r11, r9, asl #5 @
+ add r9, r11, r9, asl #6 @
+ @
+ add r8, r8, #2 @ r8 = bu = (Cb*128 + 128) >> 8
+ mov r8, r8, asr #2 @
+ add r9, r9, #256 @ r9 = rv = (r9 + 256) >> 9
+ mov r9, r9, asr #9 @
+ rsb r10, r10, #128 @ r10 = guv = (-r10 + 128) >> 8
+ mov r10, r10, asr #8 @
+ @ compute R, G, and B
+ add r0, r8, r7, asr #8 @ r0 = b = (Y >> 9) + bu
+ add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
+ add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
+ @
+ orr r12, r0, r11 @ check if clamping is needed...
+ orr r12, r12, r7, asr #1 @ ...at all
+ cmp r12, #31 @
+ bls 15f @ no clamp @
+ cmp r0, #31 @ clamp b
+ mvnhi r0, r0, asr #31 @
+ andhi r0, r0, #31 @
+ cmp r11, #31 @ clamp r
+ mvnhi r11, r11, asr #31 @
+ andhi r11, r11, #31 @
+ cmp r7, #63 @ clamp g
+ mvnhi r7, r7, asr #31 @
+ andhi r7, r7, #63 @
+15: @ no clamp @
+ @
+ ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride)
+ @
+ mov r11, r11, lsl #3 @
+ orr r11, r11, r7, lsr #3 @ r11 = (r << 3) | (g >> 3)
+ orr r0, r0, r7, lsl #5 @ r0 = (g << 5) | b
+1: @ busy @
+ ldr r7, [r3] @ r7 = LCD1_BASE
+ tst r7, #LCD1_BUSY_MASK @ bridge busy?
+ bne 1b @
+ str r11, [r3, #0x10] @ send MSB
+1: @busy @
+ ldr r7, [r3] @ r7 = LCD1_BASE
+ tst r7, #LCD1_BUSY_MASK @ bridge busy?
+ bne 1b @
+ str r0, [r3, #0x10] @ send LSB
+ @
+ sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74
+ add r12, r7, r7, asl #2 @
+ add r7, r12, r7, asl #5 @
+ @ compute R, G, and B
+ add r0, r8, r7, asr #8 @ r0 = b = (Y >> 9) + bu
+ add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
+ add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
+ @
+ orr r12, r0, r11 @ check if clamping is needed...
+ orr r12, r12, r7, asr #1 @ ...at all
+ cmp r12, #31 @
+ bls 15f @ no clamp @
+ cmp r0, #31 @ clamp b
+ mvnhi r0, r0, asr #31 @
+ andhi r0, r0, #31 @
+ cmp r11, #31 @ clamp r
+ mvnhi r11, r11, asr #31 @
+ andhi r11, r11, #31 @
+ cmp r7, #63 @ clamp g
+ mvnhi r7, r7, asr #31 @
+ andhi r7, r7, #63 @
+15: @ no clamp @
+ @
+ ldrb r12, [r4], #1 @ r12 = Y' = *(Y'_p++)
+ @
+ mov r11, r11, lsl #3 @
+ orr r11, r11, r7, lsr #3 @ r11 = (r << 3) | (g >> 3)
+ orr r0, r0, r7, lsl #5 @ r0 = (g << 5) | b
+1: @ busy @
+ ldr r7, [r3] @ r7 = LCD1_BASE
+ tst r7, #LCD1_BUSY_MASK @ bridge busy?
+ bne 1b @
+ str r11, [r3, #0x10] @ send MSB
+1: @ busy @
+ ldr r7, [r3] @ r7 = LCD1_BASE
+ tst r7, #LCD1_BUSY_MASK @ bridge busy?
+ bne 1b @
+ str r0, [r3, #0x10] @ send LSB
+ @
+ sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74
+ add r12, r7, r7, asl #2 @
+ add r7, r12, r7, asl #5 @
+ @ compute R, G, and B
+ add r0, r8, r7, asr #8 @ r0 = b = (Y >> 9) + bu
+ add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
+ add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
+ @
+ orr r12, r0, r11 @ check if clamping is needed...
+ orr r12, r12, r7, asr #1 @ ...at all
+ cmp r12, #31 @
+ bls 15f @ no clamp @
+ cmp r0, #31 @ clamp b
+ mvnhi r0, r0, asr #31 @
+ andhi r0, r0, #31 @
+ cmp r11, #31 @ clamp r
+ mvnhi r11, r11, asr #31 @
+ andhi r11, r11, #31 @
+ cmp r7, #63 @ clamp g
+ mvnhi r7, r7, asr #31 @
+ andhi r7, r7, #63 @
+15: @ no clamp @
+ @
+ ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride)
+ @
+ @
+ mov r11, r11, lsl #3 @
+ orr r11, r11, r7, lsr #3 @ r11 = (r << 3) | (g >> 3)
+ orr r0, r0, r7, lsl #5 @ r0 = (g << 5) | b
+1: @ busy @
+ ldr r7, [r3] @ r7 = LCD1_BASE
+ tst r7, #LCD1_BUSY_MASK @ bridge busy?
+ bne 1b @
+ str r11, [r3, #0x10] @ send MSB
+1: @ busy @
+ ldr r7, [r3] @ r7 = LCD1_BASE
+ tst r7, #LCD1_BUSY_MASK @ bridge busy?
+ bne 1b @
+ str r0, [r3, #0x10] @ send LSB
+ @
+ sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74
+ add r12, r7, r7, asl #2 @
+ add r7, r12, r7, asl #5 @
+ @ compute R, G, and B
+ add r0, r8, r7, asr #8 @ r0 = b = (Y >> 9) + bu
+ add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv
+ add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv
+ @
+ orr r12, r0, r11 @ check if clamping is needed...
+ orr r12, r12, r7, asr #1 @ ...at all
+ cmp r12, #31 @
+ bls 15f @ no clamp @
+ cmp r0, #31 @ clamp b
+ mvnhi r0, r0, asr #31 @
+ andhi r0, r0, #31 @
+ cmp r11, #31 @ clamp r
+ mvnhi r11, r11, asr #31 @
+ andhi r11, r11, #31 @
+ cmp r7, #63 @ clamp g
+ mvnhi r7, r7, asr #31 @
+ andhi r7, r7, #63 @
+15: @ no clamp @
+ @
+ mov r11, r11, lsl #3 @
+ orr r11, r11, r7, lsr #3 @ r11 = (r << 3) | (g >> 3)
+ orr r0, r0, r7, lsl #5 @ r0 = (g << 5) | b
+1: @ busy @
+ ldr r7, [r3] @ r7 = LCD1_BASE
+ tst r7, #LCD1_BUSY_MASK @ bridge busy?
+ bne 1b @
+ str r11, [r3, #0x10] @ send MSB
+1: @ busy @
+ ldr r7, [r3] @ r7 = LCD1_BASE
+ tst r7, #LCD1_BUSY_MASK @ bridge busy?
+ bne 1b @
+ str r0, [r3, #0x10] @ send LSB
+ @
+ subs r1, r1, #2 @ subtract block from width
+ bgt 10b @ loop line @
+ @
+ ldmfd sp!, { r4-r12 } @ restore registers and return
+ bx lr @
+ .ltorg @ dump constant pool
+ .size lcd_write_yuv420_lines, .-lcd_write_yuv420_lines
+
diff --git a/firmware/target/arm/sandisk/sansa-c200/lcd-c200.c b/firmware/target/arm/sandisk/sansa-c200/lcd-c200.c
index ef336b46c0..d503fd2c9b 100644
--- a/firmware/target/arm/sandisk/sansa-c200/lcd-c200.c
+++ b/firmware/target/arm/sandisk/sansa-c200/lcd-c200.c
@@ -206,19 +206,49 @@ void lcd_blit(const fb_data* data, int x, int by, int width,
(void)stride;
}
+/* 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);
/* 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)
{
- (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;
+
+ y += 0x1a;
+
+ 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]);
+
+ lcd_send_command(R_ENTRY_MODE);
+ lcd_send_command(0x80);
+
+ lcd_send_command(R_X_ADDR_AREA);
+ lcd_send_command(x);
+ lcd_send_command(x + width - 1);
+
+ do
+ {
+ lcd_send_command(R_Y_ADDR_AREA);
+ lcd_send_command(y);
+ lcd_send_command(y + 1);
+
+ 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);
}
/* Update the display.
@@ -239,6 +269,9 @@ void lcd_update_rect(int x0, int y0, int width, int height)
if ((x1 <= 0) || (y1 <= 0))
return;
+ lcd_send_command(R_ENTRY_MODE);
+ lcd_send_command(0x82);
+
if(y1 >= LCD_HEIGHT)
y1 = LCD_HEIGHT - 1;