diff options
author | Jens Arnold <amiconn@rockbox.org> | 2006-08-23 17:30:51 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2006-08-23 17:30:51 +0000 |
commit | 9af13c327e3a086f8015aec8135e01018a7ffb2b (patch) | |
tree | 65a91acf8b9e5dc4b8765c8949859f8961e3c4a0 /firmware/target/coldfire/iriver/h300/lcd-as-h300.S | |
parent | d5fe8030baccc17d22c3ecdf2d4af77b71e41c82 (diff) | |
download | rockbox-9af13c327e3a086f8015aec8135e01018a7ffb2b.tar.gz rockbox-9af13c327e3a086f8015aec8135e01018a7ffb2b.zip |
H300: * Assembler optimised lcd_yuv_blit(), based on the X5 version. 23..31% speedup in tests depending on video size. * Don't set HORIZ_RAM_ADDR_POS for LCD updates, it's unnecessary. * Started the target tree move for H300 with this.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10724 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/coldfire/iriver/h300/lcd-as-h300.S')
-rwxr-xr-x | firmware/target/coldfire/iriver/h300/lcd-as-h300.S | 385 |
1 files changed, 385 insertions, 0 deletions
diff --git a/firmware/target/coldfire/iriver/h300/lcd-as-h300.S b/firmware/target/coldfire/iriver/h300/lcd-as-h300.S new file mode 100755 index 0000000000..c6c1c76136 --- /dev/null +++ b/firmware/target/coldfire/iriver/h300/lcd-as-h300.S | |||
@@ -0,0 +1,385 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Jens Arnold | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include "config.h" | ||
21 | #include "cpu.h" | ||
22 | |||
23 | .section .icode, "ax", @progbits | ||
24 | |||
25 | .align 2 | ||
26 | .global lcd_write_data | ||
27 | .type lcd_write_data, @function | ||
28 | |||
29 | lcd_write_data: | ||
30 | move.l (4, %sp), %a0 /* data pointer */ | ||
31 | move.l (8, %sp), %d0 /* length in words */ | ||
32 | add.l %d0, %d0 /* words -> bytes */ | ||
33 | add.l %a0, %d0 /* -> end address */ | ||
34 | lea.l 0xf0000002, %a1 /* LCD data port */ | ||
35 | |||
36 | move.l %a0, %d1 | ||
37 | btst.l #1, %d1 /* already longword aligned? */ | ||
38 | beq.s .word1_end /* yes: skip initial word copy */ | ||
39 | |||
40 | move.w (%a0)+, (%a1) /* transfer initial word */ | ||
41 | |||
42 | .word1_end: /* now longword aligned */ | ||
43 | moveq.l #28, %d1 | ||
44 | add.l %a0, %d1 | ||
45 | and.l #0xFFFFFFF0,%d1 /* %d1 = first line bound + 16 */ | ||
46 | cmp.l %d1, %d0 /* at least one full line to send? */ | ||
47 | blo.s .long2_start /* no: skip to trailing longword handling */ | ||
48 | |||
49 | lea.l (-16, %sp), %sp /* free up some registers */ | ||
50 | movem.l %d2-%d4/%a2, (%sp) | ||
51 | |||
52 | subq.l #8, %d1 | ||
53 | subq.l #8, %d1 /* %d1 = first line bound */ | ||
54 | |||
55 | cmp.l %a0, %d1 /* any leading longwords? */ | ||
56 | bls.s .long1_end /* no: skip leading long loop */ | ||
57 | |||
58 | .long1_loop: | ||
59 | move.l (%a0)+, %d2 /* read longword */ | ||
60 | swap %d2 /* send data to LCD in correct order...*/ | ||
61 | move.w %d2, (%a1) | ||
62 | swap %d2 | ||
63 | move.w %d2, (%a1) | ||
64 | cmp.l %a0, %d1 /* run %a0 up to first line bound */ | ||
65 | bhi.s .long1_loop | ||
66 | |||
67 | .long1_end: | ||
68 | move.l %d0, %a2 | ||
69 | lea.l (-14, %a2), %a2 /* %a2 = end address - 14 (one line/pass) */ | ||
70 | |||
71 | /* burst-optimised line transfers */ | ||
72 | .line_loop: | ||
73 | movem.l (%a0), %d1-%d4 /* burst-read line */ | ||
74 | lea.l (16, %a0), %a0 /* increment address */ | ||
75 | swap %d1 /* send data to LCD in correct order... */ | ||
76 | move.w %d1, (%a1) | ||
77 | swap %d1 | ||
78 | move.w %d1, (%a1) | ||
79 | swap %d2 | ||
80 | move.w %d2, (%a1) | ||
81 | swap %d2 | ||
82 | move.w %d2, (%a1) | ||
83 | swap %d3 | ||
84 | move.w %d3, (%a1) | ||
85 | swap %d3 | ||
86 | move.w %d3, (%a1) | ||
87 | swap %d4 | ||
88 | move.w %d4, (%a1) | ||
89 | swap %d4 | ||
90 | move.w %d4, (%a1) | ||
91 | cmp.l %a0, %a2 /* run %a0 up to last line bound */ | ||
92 | bhi.s .line_loop | ||
93 | |||
94 | movem.l (%sp), %d2-%d4/%a2 | ||
95 | lea.l (16, %sp), %sp /* restore registers */ | ||
96 | |||
97 | .long2_start: | ||
98 | subq.l #2, %d0 /* account for handling 2 words per loop */ | ||
99 | cmp.l %a0, %d0 /* any (trailing longwords? */ | ||
100 | bls.s .long2_end /* no: skip trailing longword loop */ | ||
101 | |||
102 | .long2_loop: | ||
103 | move.l (%a0)+, %d1 /* read longword */ | ||
104 | swap %d1 /* send data to LCD in correct order */ | ||
105 | move.w %d1, (%a1) | ||
106 | swap %d1 | ||
107 | move.w %d1, (%a1) | ||
108 | cmp.l %a0, %d0 /* run %a0 up to last long bound */ | ||
109 | bhi.s .long2_loop | ||
110 | |||
111 | .long2_end: | ||
112 | blo.s .word2_end /* no final word: skip */ | ||
113 | move.w (%a0)+, (%a1) /* transfer final word */ | ||
114 | |||
115 | .word2_end: | ||
116 | rts | ||
117 | .lcd_write_data_end: | ||
118 | .size lcd_write_data, .lcd_write_data_end - lcd_write_data | ||
119 | |||
120 | |||
121 | /* lcd_write_yuv420_lines(), based on lcd-as-x5.S | ||
122 | * | ||
123 | * See http://en.wikipedia.org/wiki/YCbCr | ||
124 | * ITU-R BT.601 (formerly CCIR 601): | ||
125 | * |Y'| | 0.299000 0.587000 0.114000| |R| | ||
126 | * |Pb| = |-0.168736 -0.331264 0.500000| |G| or 0.564334*(B - Y') | ||
127 | * |Pr| | 0.500000 -0.418688 0.081312| |B| or 0.713267*(R - Y') | ||
128 | * Scaled, normalized and rounded: | ||
129 | * |Y'| | 65 129 25| |R| + 16 : 16->235 | ||
130 | * |Cb| = |-38 -74 112| |G| + 128 : 16->240 | ||
131 | * |Cr| |112 -94 -18| |B| + 128 : 16->240 | ||
132 | * | ||
133 | * The inverse: | ||
134 | * |R| |1.000000 0.000000 1.402000| |Y'| | ||
135 | * |G| = |1.000000 -0.334136 -0.714136| |Pb| | ||
136 | * |B| |1.000000 1.772000 0.000000| |Pr| | ||
137 | * Scaled, normalized, rounded and tweaked to yield RGB666, as converting | ||
138 | * directly to RGB565 gives too much roundoff error: | ||
139 | * |R| |74 0 101| |Y' - 16| / 256 | ||
140 | * |G| = |74 -24 -51| |Cb - 128| / 256 | ||
141 | * |B| |74 128 0| |Cr - 128| / 256 | ||
142 | */ | ||
143 | |||
144 | .align 2 | ||
145 | .global lcd_write_yuv420_lines | ||
146 | .type lcd_write_yuv420_lines, @function | ||
147 | |||
148 | lcd_write_yuv420_lines: | ||
149 | lea.l (-36, %sp), %sp /* free up some registers */ | ||
150 | movem.l %d2-%d6/%a2-%a5, (%sp) | ||
151 | |||
152 | lea.l 0xf0000002, %a0 /* LCD data port */ | ||
153 | movem.l (36+4, %sp), %a1-%a5 /* Y data, Cb data, guv storage, Cr data, width */ | ||
154 | lea.l (%a1, %a5), %a5 /* end address */ | ||
155 | |||
156 | .yuv_line_loop1: | ||
157 | /* chroma for first & second pixel */ | ||
158 | clr.l %d1 /* load bu component */ | ||
159 | move.b (%a2), %d1 | ||
160 | clr.l %d3 /* load rv component */ | ||
161 | move.b (%a4), %d3 | ||
162 | moveq.l #-128, %d0 | ||
163 | add.l %d0, %d1 | ||
164 | add.l %d0, %d3 | ||
165 | |||
166 | move.l %d1, %d2 /* %d2 = cb component for guv */ | ||
167 | asr.l #1, %d1 /* %d1 = 128 * (Cb - 128) / 256 */ | ||
168 | move.b %d1, (%a2)+ /* save bu for next line */ | ||
169 | moveq.l #-24, %d0 | ||
170 | muls.w %d0, %d2 /* %d2 = -24 * (Cb - 128)*/ | ||
171 | moveq.l #-51, %d0 | ||
172 | muls.w %d3, %d0 | ||
173 | add.l %d0, %d2 /* %d2 = -24 * (Cb - 128) - 51 * (Cr - 128) */ | ||
174 | asr.l #8, %d2 | ||
175 | move.b %d2, (%a3)+ /* save guv for next line */ | ||
176 | moveq.l #101, %d0 | ||
177 | muls.w %d0, %d3 /* %d3 = 101 * (Cr - 128) */ | ||
178 | asr.l #8, %d3 | ||
179 | move.b %d3, (%a4)+ /* save rv for next line */ | ||
180 | |||
181 | /* luma for first pixel */ | ||
182 | clr.l %d4 /* load y component */ | ||
183 | move.b (%a1)+, %d4 | ||
184 | moveq.l #74, %d0 | ||
185 | muls.w %d0, %d4 /* %d4 = 36 * Y */ | ||
186 | asr.l #8, %d4 | ||
187 | subq.l #4, %d4 /* correction for (Y - 16) and rounding */ | ||
188 | move.l %d4, %d5 | ||
189 | move.l %d4, %d6 | ||
190 | |||
191 | /* combine & write first pixel */ | ||
192 | add.l %d1, %d4 /* %d4 = blue */ | ||
193 | add.l %d2, %d5 /* %d5 = green */ | ||
194 | add.l %d3, %d6 /* %d6 = red */ | ||
195 | |||
196 | move.l %d4, %d0 /* clamping */ | ||
197 | or.l %d5, %d0 | ||
198 | or.l %d6, %d0 | ||
199 | asr.l #6, %d0 | ||
200 | beq.s .yuv_all_ok1 | ||
201 | moveq.l #63, %d0 | ||
202 | cmp.l %d0, %d4 | ||
203 | bls.s .yuv_blue_ok1 | ||
204 | spl.b %d4 | ||
205 | and.l %d0, %d4 | ||
206 | .yuv_blue_ok1: | ||
207 | cmp.l %d0, %d5 | ||
208 | bls.s .yuv_green_ok1 | ||
209 | spl.b %d5 | ||
210 | and.l %d0, %d5 | ||
211 | .yuv_green_ok1: | ||
212 | cmp.l %d0, %d6 | ||
213 | bls.s .yuv_red_ok1 | ||
214 | spl.b %d6 | ||
215 | and.l %d0, %d6 | ||
216 | .yuv_red_ok1: | ||
217 | .yuv_all_ok1: | ||
218 | |||
219 | lsr.l #1, %d6 /* pack, convert to RGB565 and output */ | ||
220 | lsr.l #1, %d4 | ||
221 | lsl.l #6, %d6 | ||
222 | or.l %d6, %d5 | ||
223 | lsl.l #5, %d5 | ||
224 | or.l %d5, %d4 | ||
225 | move.w %d4, (%a0) | ||
226 | |||
227 | /* luma for second pixel */ | ||
228 | clr.l %d4 /* load y component */ | ||
229 | move.b (%a1)+, %d4 | ||
230 | moveq.l #74, %d0 | ||
231 | muls.w %d0, %d4 /* %d4 = 36 * Y */ | ||
232 | asr.l #8, %d4 | ||
233 | subq.l #4, %d4 /* correction for (Y - 16) and rounding */ | ||
234 | |||
235 | /* combine & write second pixel */ | ||
236 | add.l %d4, %d1 /* %d1 = blue */ | ||
237 | add.l %d4, %d2 /* %d2 = green */ | ||
238 | add.l %d4, %d3 /* %d3 = red */ | ||
239 | |||
240 | move.l %d1, %d0 /* clamping */ | ||
241 | or.l %d2, %d0 | ||
242 | or.l %d3, %d0 | ||
243 | asr.l #6, %d0 | ||
244 | beq.s .yuv_all_ok2 | ||
245 | moveq.l #63, %d0 | ||
246 | cmp.l %d0, %d1 | ||
247 | bls.s .yuv_blue_ok2 | ||
248 | spl.b %d1 | ||
249 | and.l %d0, %d1 | ||
250 | .yuv_blue_ok2: | ||
251 | cmp.l %d0, %d2 | ||
252 | bls.s .yuv_green_ok2 | ||
253 | spl.b %d2 | ||
254 | and.l %d0, %d2 | ||
255 | .yuv_green_ok2: | ||
256 | cmp.l %d0, %d3 | ||
257 | bls.s .yuv_red_ok2 | ||
258 | spl.b %d3 | ||
259 | and.l %d0, %d3 | ||
260 | .yuv_red_ok2: | ||
261 | .yuv_all_ok2: | ||
262 | |||
263 | lsr.l #1, %d3 /* pack, convert to RGB565 and output */ | ||
264 | lsr.l #1, %d1 | ||
265 | lsl.l #6, %d3 | ||
266 | or.l %d3, %d2 | ||
267 | lsl.l #5, %d2 | ||
268 | or.l %d2, %d1 | ||
269 | move.w %d1, (%a0) | ||
270 | |||
271 | cmp.l %a1,%a5 /* run %a1 up to end of line */ | ||
272 | bhi.w .yuv_line_loop1 | ||
273 | |||
274 | /* Rewind chroma pointers */ | ||
275 | movem.l (36+8, %sp), %a2-%a5 /* bu data, guv data, rv data, width */ | ||
276 | lea.l (%a1, %a5), %a5 /* next end address */ | ||
277 | |||
278 | .yuv_line_loop2: | ||
279 | /* read saved chromas and sign extend */ | ||
280 | move.b (%a2)+, %d1 | ||
281 | extb.l %d1 | ||
282 | move.b (%a3)+, %d2 | ||
283 | extb.l %d2 | ||
284 | move.b (%a4)+, %d3 | ||
285 | extb.l %d3 | ||
286 | |||
287 | /* luma for first pixel */ | ||
288 | clr.l %d4 /* load y component */ | ||
289 | move.b (%a1)+, %d4 | ||
290 | moveq.l #74, %d0 | ||
291 | muls.w %d0, %d4 /* %d4 = 36 * Y */ | ||
292 | asr.l #8, %d4 | ||
293 | subq.l #4, %d4 /* correction for (Y - 16) and rounding */ | ||
294 | move.l %d4, %d5 | ||
295 | move.l %d4, %d6 | ||
296 | |||
297 | /* combine & write first pixel */ | ||
298 | add.l %d1, %d4 /* %d4 = blue */ | ||
299 | add.l %d2, %d5 /* %d5 = green */ | ||
300 | add.l %d3, %d6 /* %d6 = red */ | ||
301 | |||
302 | move.l %d4, %d0 /* clamping */ | ||
303 | or.l %d5, %d0 | ||
304 | or.l %d6, %d0 | ||
305 | asr.l #6, %d0 | ||
306 | beq.s .yuv_all_ok3 | ||
307 | moveq.l #63, %d0 | ||
308 | cmp.l %d0, %d4 | ||
309 | bls.s .yuv_blue_ok3 | ||
310 | spl.b %d4 | ||
311 | and.l %d0, %d4 | ||
312 | .yuv_blue_ok3: | ||
313 | cmp.l %d0, %d5 | ||
314 | bls.s .yuv_green_ok3 | ||
315 | spl.b %d5 | ||
316 | and.l %d0, %d5 | ||
317 | .yuv_green_ok3: | ||
318 | cmp.l %d0, %d6 | ||
319 | bls.s .yuv_red_ok3 | ||
320 | spl.b %d6 | ||
321 | and.l %d0, %d6 | ||
322 | .yuv_red_ok3: | ||
323 | .yuv_all_ok3: | ||
324 | |||
325 | lsr.l #1, %d6 /* pack, convert to RGB565 and output */ | ||
326 | lsr.l #1, %d4 | ||
327 | lsl.l #6, %d6 | ||
328 | or.l %d6, %d5 | ||
329 | lsl.l #5, %d5 | ||
330 | or.l %d5, %d4 | ||
331 | move.w %d4, (%a0) | ||
332 | |||
333 | /* luma for second pixel */ | ||
334 | clr.l %d4 /* load y component */ | ||
335 | move.b (%a1)+, %d4 | ||
336 | moveq.l #74, %d0 | ||
337 | muls.w %d0, %d4 /* %d4 = 36 * Y */ | ||
338 | asr.l #8, %d4 | ||
339 | subq.l #4, %d4 /* correction for (Y - 16) and rounding */ | ||
340 | |||
341 | /* combine & write second pixel */ | ||
342 | add.l %d4, %d1 /* %d1 = blue */ | ||
343 | add.l %d4, %d2 /* %d2 = green */ | ||
344 | add.l %d4, %d3 /* %d3 = red */ | ||
345 | |||
346 | move.l %d1, %d0 /* clamping */ | ||
347 | or.l %d2, %d0 | ||
348 | or.l %d3, %d0 | ||
349 | asr.l #6, %d0 | ||
350 | beq.s .yuv_all_ok4 | ||
351 | moveq.l #63, %d0 | ||
352 | cmp.l %d0, %d1 | ||
353 | bls.s .yuv_blue_ok4 | ||
354 | spl.b %d1 | ||
355 | and.l %d0, %d1 | ||
356 | .yuv_blue_ok4: | ||
357 | cmp.l %d0, %d2 | ||
358 | bls.s .yuv_green_ok4 | ||
359 | spl.b %d2 | ||
360 | and.l %d0, %d2 | ||
361 | .yuv_green_ok4: | ||
362 | cmp.l %d0, %d3 | ||
363 | bls.s .yuv_red_ok4 | ||
364 | spl.b %d3 | ||
365 | and.l %d0, %d3 | ||
366 | .yuv_red_ok4: | ||
367 | .yuv_all_ok4: | ||
368 | |||
369 | lsr.l #1, %d3 /* pack, convert to RGB565 and output */ | ||
370 | lsr.l #1, %d1 | ||
371 | lsl.l #6, %d3 | ||
372 | or.l %d3, %d2 | ||
373 | lsl.l #5, %d2 | ||
374 | or.l %d2, %d1 | ||
375 | move.w %d1, (%a0) | ||
376 | |||
377 | cmp.l %a1, %a5 /* run %a1 up to end of line */ | ||
378 | bhi.w .yuv_line_loop2 | ||
379 | |||
380 | movem.l (%sp), %d2-%d6/%a2-%a5 | ||
381 | lea.l (36, %sp), %sp /* restore registers */ | ||
382 | |||
383 | rts | ||
384 | .lcd_write_yuv420_lines_end: | ||
385 | .size lcd_write_yuv420_lines, .lcd_write_yuv420_lines_end - lcd_write_yuv420_lines | ||