summaryrefslogtreecommitdiff
path: root/firmware/target/coldfire/iriver/h300/lcd-as-h300.S
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/coldfire/iriver/h300/lcd-as-h300.S')
-rw-r--r--firmware/target/coldfire/iriver/h300/lcd-as-h300.S246
1 files changed, 0 insertions, 246 deletions
diff --git a/firmware/target/coldfire/iriver/h300/lcd-as-h300.S b/firmware/target/coldfire/iriver/h300/lcd-as-h300.S
deleted file mode 100644
index 223c183860..0000000000
--- a/firmware/target/coldfire/iriver/h300/lcd-as-h300.S
+++ /dev/null
@@ -1,246 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Jens Arnold
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "cpu.h"
24
25 .section .icode, "ax", @progbits
26
27/* lcd_write_yuv420_lines()
28 *
29 * See http://en.wikipedia.org/wiki/YCbCr
30 * ITU-R BT.601 (formerly CCIR 601):
31 * |Y'| | 0.299000 0.587000 0.114000| |R|
32 * |Pb| = |-0.168736 -0.331264 0.500000| |G| or 0.564334*(B - Y')
33 * |Pr| | 0.500000 -0.418688 0.081312| |B| or 0.713267*(R - Y')
34 * Scaled, normalized and rounded:
35 * |Y'| | 65 129 25| |R| + 16 : 16->235
36 * |Cb| = |-38 -74 112| |G| + 128 : 16->240
37 * |Cr| |112 -94 -18| |B| + 128 : 16->240
38 *
39 * The inverse:
40 * |R| |1.000000 0.000000 1.402000| |Y'|
41 * |G| = |1.000000 -0.334136 -0.714136| |Pb|
42 * |B| |1.000000 1.772000 0.000000| |Pr|
43 * Scaled, normalized, rounded and tweaked to yield RGB565:
44 * |R| |19611723 0 26881894| |Y' - 16| >> 27
45 * |G| = |19611723 -6406711 -13692816| |Cb - 128| >> 26
46 * |B| |19611723 33976259 0| |Cr - 128| >> 27
47 *
48 * Needs EMAC set to saturated, signed integer mode.
49 *
50 * register usage:
51 * %a0 - LCD data port
52 * %a1 - Y pointer
53 * %a2 - C pointer
54 * %a3 - C width
55 * %a4 - Y end address
56 * %a5 - Y factor
57 * %a6 - BU factor
58 * %d0 - scratch
59 * %d1 - B, previous Y \ alternating
60 * %d2 - U / B, previous Y /
61 * %d3 - V / G
62 * %d4 - R / output pixel
63 * %d5 - GU factor
64 * %d6 - GV factor
65 * %d7 - RGB signed -> unsigned conversion mask
66 */
67 .align 2
68 .global lcd_write_yuv420_lines
69 .type lcd_write_yuv420_lines, @function
70
71lcd_write_yuv420_lines:
72 lea.l (-44, %sp), %sp /* free up some registers */
73 movem.l %d2-%d7/%a2-%a6, (%sp)
74
75 lea.l 0xf0000002, %a0 /* LCD data port */
76 movem.l (44+4, %sp), %a1-%a3 /* Y data, C data, C width */
77 lea.l (%a1, %a3*2), %a4 /* Y end address */
78
79 move.l #19611723, %a5 /* y factor */
80 move.l #33976259, %a6 /* bu factor */
81 move.l #-6406711, %d5 /* gu factor */
82 move.l #-13692816, %d6 /* gv factor */
83 move.l #0x8410, %d7 /* bitmask for signed->unsigned conversion
84 * of R, G and B within RGB565 at once */
85
86 /* chroma for first 2x2 pixel block */
87 clr.l %d3 /* load v component */
88 move.b (%a2, %a3), %d3
89 clr.l %d2 /* load u component */
90 move.b (%a2)+, %d2
91 moveq.l #-128, %d0
92 add.l %d0, %d2
93 add.l %d0, %d3
94
95 mac.l %a6, %d2, %acc0 /* bu */
96 mac.l %d5, %d2, %acc1 /* gu */
97 mac.l %d6, %d3, %acc1 /* gv */
98 move.l #26881894, %d0 /* rv factor */
99 mac.l %d0, %d3, %acc2 /* rv */
100
101 /* luma for very first pixel (top left) */
102 clr.l %d1
103 move.b (%a1, %a3*2), %d1
104 moveq.l #-126, %d0
105 add.l %d1, %d0 /* y' (-0.5 ... +0.5) */
106 mac.l %a5, %d0, %acc0
107 mac.l %a5, %d0, %acc1
108 mac.l %a5, %d0, %acc2
109
110 bra.b .yuv_line_entry
111
112.yuv_line_loop:
113 /* chroma for 2x2 pixel block */
114 clr.l %d3 /* load v component */
115 move.b (%a2, %a3), %d3
116 clr.l %d2 /* load u component */
117 move.b (%a2)+, %d2
118 moveq.l #-128, %d0
119 add.l %d0, %d2
120 add.l %d0, %d3
121
122 mac.l %a6, %d2, %acc0 /* bu */
123 mac.l %d5, %d2, %acc1 /* gu */
124 mac.l %d6, %d3, %acc1 /* gv */
125 move.l #26881894, %d0 /* rv factor */
126 mac.l %d0, %d3, %acc2 /* rv */
127
128 /* luma for first pixel (top left) */
129 clr.l %d1
130 move.b (%a1, %a3*2), %d1
131 moveq.l #-126, %d0
132 add.l %d1, %d0 /* y' (-0.5 ... +0.5) */
133 mac.l %a5, %d0, %acc0
134 mac.l %a5, %d0, %acc1
135 mac.l %a5, %d0, %acc2
136
137 move.w %d4, (%a0)
138 /* LCD write is delayed one pixel to use it for filling the EMAC latency */
139
140 /* convert to RGB565, pack and output */
141.yuv_line_entry:
142 moveq.l #27, %d0
143 move.l %acc0, %d2
144 move.l %acc1, %d3
145 move.l %acc2, %d4
146 lsr.l %d0, %d2
147 lsr.l %d0, %d4
148 moveq.l #26, %d0
149 lsr.l %d0, %d3
150 lsl.l #6, %d4
151 or.l %d3, %d4
152 lsl.l #5, %d4
153 or.l %d2, %d4
154 eor.l %d7, %d4
155
156 /* luma for second pixel (bottom left) as delta from the first */
157 clr.l %d2
158 move.b (%a1)+, %d2
159 move.l %d2, %d0
160 sub.l %d1, %d0
161 mac.l %a5, %d0, %acc0
162 mac.l %a5, %d0, %acc1
163 mac.l %a5, %d0, %acc2
164
165 move.w %d4, (%a0)
166 /* LCD write is delayed one pixel to use it for filling the EMAC latency */
167
168 /* convert to RGB565, pack and output */
169 moveq.l #27, %d0
170 move.l %acc0, %d1
171 move.l %acc1, %d3
172 move.l %acc2, %d4
173 lsr.l %d0, %d1
174 lsr.l %d0, %d4
175 moveq.l #26, %d0
176 lsr.l %d0, %d3
177 lsl.l #6, %d4
178 or.l %d3, %d4
179 lsl.l #5, %d4
180 or.l %d1, %d4
181 eor.l %d7, %d4
182
183 /* luma for third pixel (top right) as delta from the second */
184 clr.l %d1
185 move.b (%a1, %a3*2), %d1
186 move.l %d1, %d0
187 sub.l %d2, %d0
188 mac.l %a5, %d0, %acc0
189 mac.l %a5, %d0, %acc1
190 mac.l %a5, %d0, %acc2
191
192 move.w %d4, (%a0)
193 /* LCD write is delayed one pixel to use it for filling the EMAC latency */
194
195 /* convert to RGB565, pack and output */
196 moveq.l #27, %d0
197 move.l %acc0, %d2
198 move.l %acc1, %d3
199 move.l %acc2, %d4
200 lsr.l %d0, %d2
201 lsr.l %d0, %d4
202 moveq.l #26, %d0
203 lsr.l %d0, %d3
204 lsl.l #6, %d4
205 or.l %d3, %d4
206 lsl.l #5, %d4
207 or.l %d2, %d4
208 eor.l %d7, %d4
209
210 /* luma for fourth pixel (bottom right) as delta from the third */
211 clr.l %d2
212 move.b (%a1)+, %d2
213 move.l %d2, %d0
214 sub.l %d1, %d0
215 mac.l %a5, %d0, %acc0
216 mac.l %a5, %d0, %acc1
217 mac.l %a5, %d0, %acc2
218
219 move.w %d4, (%a0)
220 /* LCD write is delayed one pixel to use it for filling the EMAC latency */
221
222 /* convert to RGB565, pack and output */
223 moveq.l #27, %d0
224 movclr.l %acc0, %d1
225 movclr.l %acc1, %d3
226 movclr.l %acc2, %d4
227 lsr.l %d0, %d1
228 lsr.l %d0, %d4
229 moveq.l #26, %d0
230 lsr.l %d0, %d3
231 lsl.l #6, %d4
232 or.l %d3, %d4
233 lsl.l #5, %d4
234 or.l %d1, %d4
235 eor.l %d7, %d4
236
237 cmp.l %a1, %a4 /* run %a1 up to end of line */
238 bhi.w .yuv_line_loop
239
240 move.w %d4, (%a0) /* write (very) last pixel */
241
242 movem.l (%sp), %d2-%d7/%a2-%a6
243 lea.l (44, %sp), %sp /* restore registers */
244 rts
245.yuv_end:
246 .size lcd_write_yuv420_lines, .yuv_end - lcd_write_yuv420_lines