summaryrefslogtreecommitdiff
path: root/firmware/target/arm/ipod/lcd-as-color-nano.S
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/ipod/lcd-as-color-nano.S')
-rwxr-xr-xfirmware/target/arm/ipod/lcd-as-color-nano.S152
1 files changed, 152 insertions, 0 deletions
diff --git a/firmware/target/arm/ipod/lcd-as-color-nano.S b/firmware/target/arm/ipod/lcd-as-color-nano.S
new file mode 100755
index 0000000000..d4df4d496a
--- /dev/null
+++ b/firmware/target/arm/ipod/lcd-as-color-nano.S
@@ -0,0 +1,152 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id:$
9 *
10 * Copyright (C) 2010 by Andree Buschmann
11 *
12 * Generic asm helper function used by YUV blitting.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
18 *
19 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 * KIND, either express or implied.
21 *
22 ****************************************************************************/
23
24#include "config.h"
25#include "cpu.h"
26
27 .section .icode, "ax", %progbits
28
29/****************************************************************************
30* void lcd_yuv_write_inner_loop(unsigned char const * const ysrc,
31* unsigned char const * const usrc,
32* unsigned char const * const vsrc,
33* int width);
34*
35* YUV- > RGB565 conversion
36* |R| |1.000000 -0.000001 1.402000| |Y'|
37* |G| = |1.000000 -0.334136 -0.714136| |Pb|
38* |B| |1.000000 1.772000 0.000000| |Pr|
39* Scaled, normalized, rounded and tweaked to yield RGB 565:
40* |R| |74 0 101| |Y' - 16| >> 9
41* |G| = |74 -24 -51| |Cb - 128| >> 8
42* |B| |74 128 0| |Cr - 128| >> 9
43*
44*/
45 .align 2
46 .global lcd_yuv_write_inner_loop
47 .type lcd_yuv_write_inner_loop, %function
48
49lcd_yuv_write_inner_loop:
50 @ r0 = ysrc
51 @ r1 = usrc
52 @ r2 = vsrc
53 @ r3 = width
54 stmfd sp!, { r4-r11, lr } @ save regs
55 mov r4, #0x70000000 @ r4 = LCD2_BLOCK_CTRL - 0x20
56 add r4, r4, #0x8a00 @
57 add r5, r4, #0x100 @ r5 = LCD2_BLOCK_DATA
5810: @ loop
59
60 ldrb r7, [r1], #1 @ *usrc++
61 ldrb r8, [r2], #1 @ *vsrc++
62
63 sub r7, r7, #128 @ Cb -= 128
64 sub r8, r8, #128 @ Cr -= 128
65
66 add r10, r8, r8, asl #2 @ Cr*101
67 add r10, r10, r8, asl #5
68 add r10, r10, r8, asl #6
69
70 add r11, r8, r8, asl #1 @ Cr*51 + Cb*24
71 add r11, r11, r11, asl #4
72 add r11, r11, r7, asl #3
73 add r11, r11, r7, asl #4
74
75 add r12, r7, #2 @ r12 = bu = (Cb*128 + 256) >> 9
76 mov r12, r12, asr #2
77 add r10, r10, #256 @ r10 = rv = (Cr*101 + 256) >> 9
78 mov r10, r10, asr #9
79 rsb r11, r11, #128 @ r11 = guv = (-r11 + 128) >> 8
80 mov r11, r11, asr #8
81
82@ pixel_1
83 ldrb r7, [r0], #1 @ *ysrc++
84 sub r7, r7, #16 @ Y = (Y' - 16) * 37
85 add r8, r7, r7, asl #2
86 add r7, r8, r7, asl #5
87
88 add r9, r10, r7, asr #8 @ R = (Y >> 8) + rv
89 add r8, r11, r7, asr #7 @ G = (Y >> 7) + guv
90 add r7, r12, r7, asr #8 @ B = (Y >> 8) + bu
91
92 cmp r9, #31 @ clamp R
93 mvnhi r9, r9, asr #31
94 andhi r9, r9, #31
95
96 cmp r8, #63 @ clamp G
97 mvnhi r8, r8, asr #31
98 andhi r8, r8, #63
99
100 cmp r7, #31 @ clamp B
101 mvnhi r7, r7, asr #31
102 andhi r7, r7, #31
103
104 orr r6, r7, r8, lsl #5 @ pack pixel
105 orr r6, r6, r9, lsl #11
106
107 mov r7, r6, lsl #8 @ swap bytes
108 and r7, r7, #0xff00
109 add r6, r7, r6, lsr #8
110
111@ pixel_2
112 ldrb r7, [r0], #1 @ *ysrc++
113 sub r7, r7, #16 @ Y = (Y' - 16) * 37
114 add r8, r7, r7, asl #2
115 add r7, r8, r7, asl #5
116
117 add r9, r10, r7, asr #8 @ R = (Y >> 8) + rv
118 add r8, r11, r7, asr #7 @ G = (Y >> 7) + guv
119 add r7, r12, r7, asr #8 @ B = (Y >> 8) + bu
120
121 cmp r9, #31 @ clamp R
122 mvnhi r9, r9, asr #31
123 andhi r9, r9, #31
124
125 cmp r8, #63 @ clamp G
126 mvnhi r8, r8, asr #31
127 andhi r8, r8, #63
128
129 cmp r7, #31 @ clamp B
130 mvnhi r7, r7, asr #31
131 andhi r7, r7, #31
132
133 orr r7, r7, r8, lsl #5 @ pack pixel
134 orr r7, r7, r9, lsl #11
135
136 orr r6, r6, r7, lsl #24 @ swap bytes and add pixels simultaneously
137 mov r7, r7, lsr #8
138 orr r6, r6, r7, lsl #16
139#if 1
14011: @ while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_TXOK));
141 ldr r11, [r4, #0x20] @
142 tst r11, #0x1000000 @
143 beq 11b @
144#endif
145 str r6, [r5] @ send two pixels
146
147 subs r3, r3, #2 @ decrease width
148 bgt 10b @ loop
149
150 ldmpc regs=r4-r11 @ restore regs
151 .ltorg @ dump constant pool
152 .size lcd_yuv_write_inner_loop, .-lcd_yuv_write_inner_loop