diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2022-10-13 11:03:53 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2022-10-13 11:08:06 -0400 |
commit | 418169aff8faf2cf90124cd95dba0af821cea73d (patch) | |
tree | 4fc206af57c9a07fba6cbcb3517fa946a7b84668 /firmware/target/arm/philips/sa9200 | |
parent | f9ea1fc79d6aaff9949a5b11ae011b4e04e0e9d9 (diff) | |
download | rockbox-418169aff8faf2cf90124cd95dba0af821cea73d.tar.gz rockbox-418169aff8faf2cf90124cd95dba0af821cea73d.zip |
Revert "Remove YUV blitting functions and LCD modes"
This reverts commit fe6aa21e9eb88f49005863efd2003d0982920048.
Change-Id: I8bb1e5d6c52ed1478002d2140ef494ec5d62b8e3
Diffstat (limited to 'firmware/target/arm/philips/sa9200')
-rw-r--r-- | firmware/target/arm/philips/sa9200/lcd-as-sa9200.S | 590 | ||||
-rw-r--r-- | firmware/target/arm/philips/sa9200/lcd-sa9200.c | 82 |
2 files changed, 672 insertions, 0 deletions
diff --git a/firmware/target/arm/philips/sa9200/lcd-as-sa9200.S b/firmware/target/arm/philips/sa9200/lcd-as-sa9200.S new file mode 100644 index 0000000000..d99222b9df --- /dev/null +++ b/firmware/target/arm/philips/sa9200/lcd-as-sa9200.S | |||
@@ -0,0 +1,590 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007-2011 by Michael Sevakis | ||
11 | * | ||
12 | * Philips GoGear SA9200 LCD assembly routines | ||
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 | /* This code should work in general for a Renesas type LCD interface | ||
25 | * connected to the "mono" bridge. TODO: Share it where possible. | ||
26 | * | ||
27 | * Dither is already prepared to be built for upright and rotated | ||
28 | * orientations. */ | ||
29 | |||
30 | #include "config.h" | ||
31 | #include "cpu.h" | ||
32 | |||
33 | /**************************************************************************** | ||
34 | * void lcd_write_yuv420_lines(unsigned char const * const src[3], | ||
35 | * int width, | ||
36 | * int stride); | ||
37 | * | ||
38 | * |R| |1.000000 -0.000001 1.402000| |Y'| | ||
39 | * |G| = |1.000000 -0.334136 -0.714136| |Pb| | ||
40 | * |B| |1.000000 1.772000 0.000000| |Pr| | ||
41 | * Scaled, normalized, rounded and tweaked to yield RGB 565: | ||
42 | * |R| |74 0 101| |Y' - 16| >> 9 | ||
43 | * |G| = |74 -24 -51| |Cb - 128| >> 8 | ||
44 | * |B| |74 128 0| |Cr - 128| >> 9 | ||
45 | * | ||
46 | * Write four RGB565 pixels in the following order on each loop: | ||
47 | * 1 3 + > down | ||
48 | * 2 4 \/ left | ||
49 | */ | ||
50 | .section .icode, "ax", %progbits | ||
51 | .align 2 | ||
52 | .global lcd_write_yuv420_lines | ||
53 | .type lcd_write_yuv420_lines, %function | ||
54 | lcd_write_yuv420_lines: | ||
55 | @ r0 = yuv_src | ||
56 | @ r1 = width | ||
57 | @ r2 = stride | ||
58 | stmfd sp!, { r4-r10, lr } @ save non-scratch | ||
59 | ldmia r0, { r4, r5, r6 } @ r4 = yuv_src[0] = Y'_p | ||
60 | @ r5 = yuv_src[1] = Cb_p | ||
61 | @ r6 = yuv_src[2] = Cr_p | ||
62 | @ | ||
63 | mov r0, #0x70000000 @ r0 = LCD1_BASE_ADDR = 0x70003000 | ||
64 | orr r0, r0, #0x3000 @ | ||
65 | @ | ||
66 | sub r2, r2, #1 @ Adjust stride because of increment | ||
67 | 10: @ loop line @ | ||
68 | ldrb r7, [r4], #1 @ r7 = *Y'_p++; | ||
69 | ldrb r8, [r5], #1 @ r8 = *Cb_p++; | ||
70 | ldrb r9, [r6], #1 @ r9 = *Cr_p++; | ||
71 | @ | ||
72 | sub r7, r7, #16 @ r7 = Y = (Y' - 16)*74 | ||
73 | add r12, r7, r7, asl #2 @ actually (Y' - 16)*37 and shift right | ||
74 | add r7, r12, r7, asl #5 @ by one less when adding - same for all | ||
75 | @ | ||
76 | sub r8, r8, #128 @ Cb -= 128 | ||
77 | sub r9, r9, #128 @ Cr -= 128 | ||
78 | @ | ||
79 | add r10, r9, r9, asl #1 @ r10 = Cr*51 + Cb*24 | ||
80 | add r10, r10, r10, asl #4 @ | ||
81 | add r10, r10, r8, asl #3 @ | ||
82 | add r10, r10, r8, asl #4 @ | ||
83 | @ | ||
84 | add r14, r9, r9, asl #2 @ r9 = Cr*101 | ||
85 | add r14, r14, r9, asl #5 @ | ||
86 | add r9, r14, r9, asl #6 @ | ||
87 | @ | ||
88 | add r8, r8, #2 @ r8 = bu = (Cb*128 + 128) >> 8 | ||
89 | mov r8, r8, asr #2 @ | ||
90 | add r9, r9, #256 @ r9 = rv = (r8 + 256) >> 9 | ||
91 | mov r9, r9, asr #9 @ | ||
92 | rsb r10, r10, #128 @ r10 = guv = (-r9 + 128) >> 8 | ||
93 | mov r10, r10, asr #8 @ | ||
94 | @ compute R, G, and B | ||
95 | add r3, r8, r7, asr #8 @ r3 = b = (Y >> 9) + bu | ||
96 | add r14, r9, r7, asr #8 @ r14 = r = (Y >> 9) + rv | ||
97 | add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv | ||
98 | @ | ||
99 | orr r12, r3, r14 @ check if clamping is needed... | ||
100 | orr r12, r12, r7, asr #1 @ ...at all | ||
101 | cmp r12, #31 @ | ||
102 | bls 15f @ no clamp @ | ||
103 | cmp r3, #31 @ clamp b | ||
104 | mvnhi r3, r3, asr #31 @ | ||
105 | andhi r3, r3, #31 @ | ||
106 | cmp r14, #31 @ clamp r | ||
107 | mvnhi r14, r14, asr #31 @ | ||
108 | andhi r14, r14, #31 @ | ||
109 | cmp r7, #63 @ clamp g | ||
110 | mvnhi r7, r7, asr #31 @ | ||
111 | andhi r7, r7, #63 @ | ||
112 | 15: @ no clamp @ | ||
113 | @ | ||
114 | ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride) | ||
115 | @ | ||
116 | orr r7, r3, r7, lsl #5 @ r7 = |00000000|00000000|00000ggg|gggbbbbb| | ||
117 | orr r7, r7, r14, lsl #11 @ r7 = |00000000|00000000|rrrrrggg|gggbbbbb| | ||
118 | mov r14, r7, lsr #8 @ r14 = |00000000|00000000|00000000|rrrrrggg| | ||
119 | @ | ||
120 | 20: @ | ||
121 | ldr r3, [r0] @ | ||
122 | tst r3, #LCD1_BUSY_MASK @ | ||
123 | bne 20b @ | ||
124 | strb r14, [r0, #0x10] @ | ||
125 | 20: @ | ||
126 | ldr r3, [r0] @ | ||
127 | tst r3, #LCD1_BUSY_MASK @ | ||
128 | bne 20b @ | ||
129 | strb r7, [r0, #0x10] @ | ||
130 | @ | ||
131 | sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74 | ||
132 | add r12, r7, r7, asl #2 @ | ||
133 | add r7, r12, r7, asl #5 @ | ||
134 | @ compute R, G, and B | ||
135 | add r3, r8, r7, asr #8 @ r3 = b = (Y >> 9) + bu | ||
136 | add r14, r9, r7, asr #8 @ r14 = r = (Y >> 9) + rv | ||
137 | add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv | ||
138 | @ | ||
139 | orr r12, r3, r14 @ check if clamping is needed... | ||
140 | orr r12, r12, r7, asr #1 @ ...at all | ||
141 | cmp r12, #31 @ | ||
142 | bls 15f @ no clamp @ | ||
143 | cmp r3, #31 @ clamp b | ||
144 | mvnhi r3, r3, asr #31 @ | ||
145 | andhi r3, r3, #31 @ | ||
146 | cmp r14, #31 @ clamp r | ||
147 | mvnhi r14, r14, asr #31 @ | ||
148 | andhi r14, r14, #31 @ | ||
149 | cmp r7, #63 @ clamp g | ||
150 | mvnhi r7, r7, asr #31 @ | ||
151 | andhi r7, r7, #63 @ | ||
152 | 15: @ no clamp @ | ||
153 | @ | ||
154 | ldrb r12, [r4], #1 @ r12 = Y' = *(Y'_p++) | ||
155 | @ | ||
156 | orr r7, r3, r7, lsl #5 @ r7 = |00000000|00000000|00000ggg|gggbbbbb| | ||
157 | orr r7, r7, r14, lsl #11 @ r7 = |00000000|00000000|rrrrrggg|gggbbbbb| | ||
158 | mov r14, r7, lsr #8 @ r14 = |00000000|00000000|00000000|rrrrrggg| | ||
159 | 20: @ | ||
160 | ldr r3, [r0] @ | ||
161 | tst r3, #LCD1_BUSY_MASK @ | ||
162 | bne 20b @ | ||
163 | strb r14, [r0, #0x10] @ | ||
164 | 20: @ | ||
165 | ldr r3, [r0] @ | ||
166 | tst r3, #LCD1_BUSY_MASK @ | ||
167 | bne 20b @ | ||
168 | strb r7, [r0, #0x10] @ | ||
169 | @ | ||
170 | sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74 | ||
171 | add r12, r7, r7, asl #2 @ | ||
172 | add r7, r12, r7, asl #5 @ | ||
173 | @ compute R, G, and B | ||
174 | add r3, r8, r7, asr #8 @ r3 = b = (Y >> 9) + bu | ||
175 | add r14, r9, r7, asr #8 @ r14 = r = (Y >> 9) + rv | ||
176 | add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv | ||
177 | @ | ||
178 | orr r12, r3, r14 @ check if clamping is needed... | ||
179 | orr r12, r12, r7, asr #1 @ ...at all | ||
180 | cmp r12, #31 @ | ||
181 | bls 15f @ no clamp @ | ||
182 | cmp r3, #31 @ clamp b | ||
183 | mvnhi r3, r3, asr #31 @ | ||
184 | andhi r3, r3, #31 @ | ||
185 | cmp r14, #31 @ clamp r | ||
186 | mvnhi r14, r14, asr #31 @ | ||
187 | andhi r14, r14, #31 @ | ||
188 | cmp r7, #63 @ clamp g | ||
189 | mvnhi r7, r7, asr #31 @ | ||
190 | andhi r7, r7, #63 @ | ||
191 | 15: @ no clamp @ | ||
192 | @ | ||
193 | ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride) | ||
194 | @ | ||
195 | orr r7, r3, r7, lsl #5 @ r7 = |00000000|00000000|00000ggg|gggbbbbb| | ||
196 | orr r7, r7, r14, lsl #11 @ r7 = |00000000|00000000|rrrrrggg|gggbbbbb| | ||
197 | mov r14, r7, lsr #8 @ r14 = |00000000|00000000|00000000|rrrrrggg| | ||
198 | 20: @ | ||
199 | ldr r3, [r0] @ | ||
200 | tst r3, #LCD1_BUSY_MASK @ | ||
201 | bne 20b @ | ||
202 | strb r14, [r0, #0x10] @ | ||
203 | 20: @ | ||
204 | ldr r3, [r0] @ | ||
205 | tst r3, #LCD1_BUSY_MASK @ | ||
206 | bne 20b @ | ||
207 | strb r7, [r0, #0x10] @ | ||
208 | @ | ||
209 | sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74 | ||
210 | add r12, r7, r7, asl #2 @ | ||
211 | add r7, r12, r7, asl #5 @ | ||
212 | @ compute R, G, and B | ||
213 | add r3, r8, r7, asr #8 @ r3 = b = (Y >> 9) + bu | ||
214 | add r14, r9, r7, asr #8 @ r14 = r = (Y >> 9) + rv | ||
215 | add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv | ||
216 | @ | ||
217 | orr r12, r3, r14 @ check if clamping is needed... | ||
218 | orr r12, r12, r7, asr #1 @ ...at all | ||
219 | cmp r12, #31 @ | ||
220 | bls 15f @ no clamp @ | ||
221 | cmp r3, #31 @ clamp b | ||
222 | mvnhi r3, r3, asr #31 @ | ||
223 | andhi r3, r3, #31 @ | ||
224 | cmp r14, #31 @ clamp r | ||
225 | mvnhi r14, r14, asr #31 @ | ||
226 | andhi r14, r14, #31 @ | ||
227 | cmp r7, #63 @ clamp g | ||
228 | mvnhi r7, r7, asr #31 @ | ||
229 | andhi r7, r7, #63 @ | ||
230 | 15: @ no clamp @ | ||
231 | @ | ||
232 | orr r7, r3, r7, lsl #5 @ r7 = |00000000|00000000|00000ggg|gggbbbbb| | ||
233 | orr r7, r7, r14, lsl #11 @ r7 = |00000000|00000000|rrrrrggg|gggbbbbb| | ||
234 | mov r14, r7, lsr #8 @ r14 = |00000000|00000000|00000000|rrrrrggg| | ||
235 | 20: @ | ||
236 | ldr r3, [r0] @ | ||
237 | tst r3, #LCD1_BUSY_MASK @ | ||
238 | bne 20b @ | ||
239 | strb r14, [r0, #0x10] @ | ||
240 | 20: @ | ||
241 | ldr r3, [r0] @ | ||
242 | tst r3, #LCD1_BUSY_MASK @ | ||
243 | bne 20b @ | ||
244 | strb r7, [r0, #0x10] @ | ||
245 | @ | ||
246 | subs r1, r1, #2 @ subtract block from width | ||
247 | bgt 10b @ loop line @ | ||
248 | @ | ||
249 | ldmpc regs=r4-r10 @ restore registers and return | ||
250 | .ltorg @ dump constant pool | ||
251 | .size lcd_write_yuv420_lines, .-lcd_write_yuv420_lines | ||
252 | |||
253 | |||
254 | /**************************************************************************** | ||
255 | * void lcd_write_yuv420_lines_odither(unsigned char const * const src[3], | ||
256 | * int width, | ||
257 | * int stride, | ||
258 | * int x_screen, | ||
259 | * int y_screen); | ||
260 | * | ||
261 | * |R| |1.000000 -0.000001 1.402000| |Y'| | ||
262 | * |G| = |1.000000 -0.334136 -0.714136| |Pb| | ||
263 | * |B| |1.000000 1.772000 0.000000| |Pr| | ||
264 | * Red scaled at twice g & b but at same precision to place it in correct | ||
265 | * bit position after multiply and leave instruction count lower. | ||
266 | * |R| |258 0 408| |Y' - 16| | ||
267 | * |G| = |149 -49 -104| |Cb - 128| | ||
268 | * |B| |149 258 0| |Cr - 128| | ||
269 | * | ||
270 | * Write four RGB565 pixels in the following order on each loop: | ||
271 | * 1 3 + > right/down | ||
272 | * 2 4 \/ down/left | ||
273 | * | ||
274 | * Kernel pattern for upright display: | ||
275 | * 5 3 4 2 +-> right | ||
276 | * 1 7 0 6 | down | ||
277 | * 4 2 5 3 \/ | ||
278 | * 0 6 1 7 | ||
279 | * | ||
280 | * Kernel pattern for clockwise rotated display: | ||
281 | * 2 6 3 7 +-> down | ||
282 | * 4 0 5 1 | left | ||
283 | * 3 7 2 6 \/ | ||
284 | * 5 1 4 0 | ||
285 | */ | ||
286 | .section .icode, "ax", %progbits | ||
287 | .align 2 | ||
288 | .global lcd_write_yuv420_lines_odither | ||
289 | .type lcd_write_yuv420_lines_odither, %function | ||
290 | lcd_write_yuv420_lines_odither: | ||
291 | @ r0 = yuv_src | ||
292 | @ r1 = width | ||
293 | @ r2 = strideS | ||
294 | @ r3 = x_screen | ||
295 | @ [sp] = y_screen | ||
296 | stmfd sp!, { r4-r11, lr } @ save non-scratch | ||
297 | ldmia r0, { r4, r5, r6 } @ r4 = yuv_src[0] = Y'_p | ||
298 | @ r5 = yuv_src[1] = Cb_p | ||
299 | @ r6 = yuv_src[2] = Cr_p | ||
300 | @ | ||
301 | ldr r0, [sp, #36] @ Line up pattern and kernel quadrant | ||
302 | eor r14, r3, r0 @ | ||
303 | and r14, r14, #0x2 @ | ||
304 | mov r14, r14, lsl #6 @ 0x00 or 0x80 | ||
305 | @ | ||
306 | mov r0, #0x70000000 @ r0 = LCD1_BASE_ADDR = 0x70003000 | ||
307 | orr r0, r0, #0x3000 @ | ||
308 | @ | ||
309 | sub r2, r2, #1 @ Adjust stride because of increment | ||
310 | 10: @ loop line @ | ||
311 | @ | ||
312 | ldrb r7, [r4], #1 @ r7 = *Y'_p++; | ||
313 | ldrb r8, [r5], #1 @ r8 = *Cb_p++; | ||
314 | ldrb r9, [r6], #1 @ r9 = *Cr_p++; | ||
315 | @ | ||
316 | eor r14, r14, #0x80 @ flip pattern quadrant | ||
317 | @ | ||
318 | sub r7, r7, #16 @ r7 = Y = (Y' - 16)*149 | ||
319 | add r12, r7, r7, asl #2 @ | ||
320 | add r12, r12, r12, asl #4 @ | ||
321 | add r7, r12, r7, asl #6 @ | ||
322 | @ | ||
323 | sub r8, r8, #128 @ Cb -= 128 | ||
324 | sub r9, r9, #128 @ Cr -= 128 | ||
325 | @ | ||
326 | add r10, r8, r8, asl #4 @ r10 = guv = Cr*104 + Cb*49 | ||
327 | add r10, r10, r8, asl #5 @ | ||
328 | add r10, r10, r9, asl #3 @ | ||
329 | add r10, r10, r9, asl #5 @ | ||
330 | add r10, r10, r9, asl #6 @ | ||
331 | @ | ||
332 | mov r8, r8, asl #1 @ r8 = bu = Cb*258 | ||
333 | add r8, r8, r8, asl #7 @ | ||
334 | @ | ||
335 | add r9, r9, r9, asl #1 @ r9 = rv = Cr*408 | ||
336 | add r9, r9, r9, asl #4 @ | ||
337 | mov r9, r9, asl #3 @ | ||
338 | @ | ||
339 | @ compute R, G, and B | ||
340 | add r3, r8, r7 @ r3 = b' = Y + bu | ||
341 | add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv | ||
342 | rsb r7, r10, r7 @ r7 = g' = Y + guv | ||
343 | @ | ||
344 | @ r8 = bu, r9 = rv, r10 = guv | ||
345 | @ | ||
346 | sub r12, r3, r3, lsr #5 @ r3 = 31/32*b + b/256 | ||
347 | add r3, r12, r3, lsr #8 @ | ||
348 | @ | ||
349 | sub r12, r11, r11, lsr #5 @ r11 = 31/32*r + r/256 | ||
350 | add r11, r12, r11, lsr #8 @ | ||
351 | @ | ||
352 | sub r12, r7, r7, lsr #6 @ r7 = 63/64*g + g/256 | ||
353 | add r7, r12, r7, lsr #8 @ | ||
354 | @ | ||
355 | #if LCD_WIDTH >= LCD_HEIGHT | ||
356 | add r12, r14, #0x200 @ | ||
357 | #else | ||
358 | add r12, r14, #0x100 @ | ||
359 | #endif | ||
360 | @ | ||
361 | add r3, r3, r12 @ b = r3 + delta | ||
362 | add r11, r11, r12, lsl #1 @ r = r11 + delta*2 | ||
363 | add r7, r7, r12, lsr #1 @ g = r7 + delta/2 | ||
364 | @ | ||
365 | orr r12, r3, r11, asr #1 @ check if clamping is needed... | ||
366 | orr r12, r12, r7 @ ...at all | ||
367 | movs r12, r12, asr #15 @ | ||
368 | beq 15f @ no clamp @ | ||
369 | movs r12, r3, asr #15 @ clamp b | ||
370 | mvnne r3, r12, lsr #15 @ | ||
371 | andne r3, r3, #0x7c00 @ mask b only if clamped | ||
372 | movs r12, r11, asr #16 @ clamp r | ||
373 | mvnne r11, r12, lsr #16 @ | ||
374 | movs r12, r7, asr #15 @ clamp g | ||
375 | mvnne r7, r12, lsr #15 @ | ||
376 | 15: @ no clamp @ | ||
377 | @ | ||
378 | ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride) | ||
379 | @ | ||
380 | and r11, r11, #0xf800 @ r11 = |00000000|00000000|rrrrrggg|gggbbbbb| | ||
381 | and r7, r7, #0x7e00 @ | ||
382 | orr r11, r11, r7, lsr #4 @ | ||
383 | orr r11, r11, r3, lsr #10 @ | ||
384 | mov r7, r11, lsr #8 @ r7 = |00000000|00000000|00000000|rrrrrggg| | ||
385 | @ | ||
386 | 20: @ | ||
387 | ldr r3, [r0] @ | ||
388 | tst r3, #LCD1_BUSY_MASK @ | ||
389 | bne 20b @ | ||
390 | strb r7, [r0, #0x10] @ | ||
391 | 20: @ | ||
392 | ldr r3, [r0] @ | ||
393 | tst r3, #LCD1_BUSY_MASK @ | ||
394 | bne 20b @ | ||
395 | strb r11, [r0, #0x10] @ | ||
396 | @ | ||
397 | sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149 | ||
398 | add r12, r7, r7, asl #2 @ | ||
399 | add r12, r12, r12, asl #4 @ | ||
400 | add r7, r12, r7, asl #6 @ | ||
401 | @ compute R, G, and B | ||
402 | add r3, r8, r7 @ r3 = b' = Y + bu | ||
403 | add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv | ||
404 | rsb r7, r10, r7 @ r7 = g' = Y + guv | ||
405 | @ | ||
406 | sub r12, r3, r3, lsr #5 @ r3 = 31/32*b' + b'/256 | ||
407 | add r3, r12, r3, lsr #8 @ | ||
408 | @ | ||
409 | sub r12, r11, r11, lsr #5 @ r11 = 31/32*r' + r'/256 | ||
410 | add r11, r12, r11, lsr #8 @ | ||
411 | @ | ||
412 | sub r12, r7, r7, lsr #6 @ r7 = 63/64*g' + g'/256 | ||
413 | add r7, r12, r7, lsr #8 @ | ||
414 | @ | ||
415 | #if LCD_WIDTH >= LCD_HEIGHT | ||
416 | @ This element is zero - use r14 @ | ||
417 | @ | ||
418 | add r3, r3, r14 @ b = r3 + delta | ||
419 | add r11, r11, r14, lsl #1 @ r = r11 + delta*2 | ||
420 | add r7, r7, r14, lsr #1 @ g = r7 + delta/2 | ||
421 | #else | ||
422 | add r12, r14, #0x200 @ | ||
423 | @ | ||
424 | add r3, r3, r12 @ b = r3 + delta | ||
425 | add r11, r11, r12, lsl #1 @ r = r11 + delta*2 | ||
426 | add r7, r7, r12, lsr #1 @ g = r7 + delta/2 | ||
427 | #endif | ||
428 | @ | ||
429 | orr r12, r3, r11, asr #1 @ check if clamping is needed... | ||
430 | orr r12, r12, r7 @ ...at all | ||
431 | movs r12, r12, asr #15 @ | ||
432 | beq 15f @ no clamp @ | ||
433 | movs r12, r3, asr #15 @ clamp b | ||
434 | mvnne r3, r12, lsr #15 @ | ||
435 | andne r3, r3, #0x7c00 @ mask b only if clamped | ||
436 | movs r12, r11, asr #16 @ clamp r | ||
437 | mvnne r11, r12, lsr #16 @ | ||
438 | movs r12, r7, asr #15 @ clamp g | ||
439 | mvnne r7, r12, lsr #15 @ | ||
440 | 15: @ no clamp @ | ||
441 | @ | ||
442 | ldrb r12, [r4], #1 @ r12 = Y' = *(Y'_p++) | ||
443 | @ | ||
444 | and r11, r11, #0xf800 @ r11 = |00000000|00000000|rrrrrggg|gggbbbbb| | ||
445 | and r7, r7, #0x7e00 @ | ||
446 | orr r11, r11, r7, lsr #4 @ | ||
447 | orr r11, r11, r3, lsr #10 @ | ||
448 | mov r7, r11, lsr #8 @ r7 = |00000000|00000000|00000000|rrrrrggg| | ||
449 | @ | ||
450 | 20: @ | ||
451 | ldr r3, [r0] @ | ||
452 | tst r3, #LCD1_BUSY_MASK @ | ||
453 | bne 20b @ | ||
454 | strb r7, [r0, #0x10] @ | ||
455 | 20: @ | ||
456 | ldr r3, [r0] @ | ||
457 | tst r3, #LCD1_BUSY_MASK @ | ||
458 | bne 20b @ | ||
459 | strb r11, [r0, #0x10] @ | ||
460 | @ | ||
461 | sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149 | ||
462 | add r12, r7, r7, asl #2 @ | ||
463 | add r12, r12, r12, asl #4 @ | ||
464 | add r7, r12, r7, asl #6 @ | ||
465 | @ compute R, G, and B | ||
466 | add r3, r8, r7 @ r3 = b' = Y + bu | ||
467 | add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv | ||
468 | rsb r7, r10, r7 @ r7 = g' = Y + guv | ||
469 | @ | ||
470 | @ r8 = bu, r9 = rv, r10 = guv | ||
471 | @ | ||
472 | sub r12, r3, r3, lsr #5 @ r3 = 31/32*b' + b'/256 | ||
473 | add r3, r12, r3, lsr #8 @ | ||
474 | @ | ||
475 | sub r12, r11, r11, lsr #5 @ r11 = 31/32*r' + r'/256 | ||
476 | add r11, r12, r11, lsr #8 @ | ||
477 | @ | ||
478 | sub r12, r7, r7, lsr #6 @ r7 = 63/64*g' + g'/256 | ||
479 | add r7, r12, r7, lsr #8 @ | ||
480 | @ | ||
481 | #if LCD_WIDTH >= LCD_HEIGHT | ||
482 | add r12, r14, #0x100 @ | ||
483 | #else | ||
484 | add r12, r14, #0x300 @ | ||
485 | #endif | ||
486 | @ | ||
487 | add r3, r3, r12 @ b = r3 + delta | ||
488 | add r11, r11, r12, lsl #1 @ r = r11 + delta*2 | ||
489 | add r7, r7, r12, lsr #1 @ g = r7 + delta/2 | ||
490 | @ | ||
491 | orr r12, r3, r11, asr #1 @ check if clamping is needed... | ||
492 | orr r12, r12, r7 @ ...at all | ||
493 | movs r12, r12, asr #15 @ | ||
494 | beq 15f @ no clamp @ | ||
495 | movs r12, r3, asr #15 @ clamp b | ||
496 | mvnne r3, r12, lsr #15 @ | ||
497 | andne r3, r3, #0x7c00 @ mask b only if clamped | ||
498 | movs r12, r11, asr #16 @ clamp r | ||
499 | mvnne r11, r12, lsr #16 @ | ||
500 | movs r12, r7, asr #15 @ clamp g | ||
501 | mvnne r7, r12, lsr #15 @ | ||
502 | 15: @ no clamp @ | ||
503 | @ | ||
504 | ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride) | ||
505 | @ | ||
506 | and r11, r11, #0xf800 @ r11 = |00000000|00000000|rrrrrggg|gggbbbbb| | ||
507 | and r7, r7, #0x7e00 @ | ||
508 | orr r11, r11, r7, lsr #4 @ | ||
509 | orr r11, r11, r3, lsr #10 @ | ||
510 | mov r7, r11, lsr #8 @ r7 = |00000000|00000000|00000000|rrrrrggg| | ||
511 | @ | ||
512 | 20: @ | ||
513 | ldr r3, [r0] @ | ||
514 | tst r3, #LCD1_BUSY_MASK @ | ||
515 | bne 20b @ | ||
516 | strb r7, [r0, #0x10] @ | ||
517 | 20: @ | ||
518 | ldr r3, [r0] @ | ||
519 | tst r3, #LCD1_BUSY_MASK @ | ||
520 | bne 20b @ | ||
521 | strb r11, [r0, #0x10] @ | ||
522 | @ | ||
523 | sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149 | ||
524 | add r12, r7, r7, asl #2 @ | ||
525 | add r12, r12, r12, asl #4 @ | ||
526 | add r7, r12, r7, asl #6 @ | ||
527 | @ compute R, G, and B | ||
528 | add r3, r8, r7 @ r3 = b' = Y + bu | ||
529 | add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv | ||
530 | rsb r7, r10, r7 @ r7 = g' = Y + guv | ||
531 | @ | ||
532 | sub r12, r3, r3, lsr #5 @ r3 = 31/32*b + b/256 | ||
533 | add r3, r12, r3, lsr #8 @ | ||
534 | @ | ||
535 | sub r12, r11, r11, lsr #5 @ r11 = 31/32*r + r/256 | ||
536 | add r11, r12, r11, lsr #8 @ | ||
537 | @ | ||
538 | sub r12, r7, r7, lsr #6 @ r7 = 63/64*g + g/256 | ||
539 | add r7, r12, r7, lsr #8 @ | ||
540 | @ | ||
541 | #if LCD_WIDTH >= LCD_HEIGHT | ||
542 | add r12, r14, #0x300 @ | ||
543 | @ | ||
544 | add r3, r3, r12 @ b = r3 + delta | ||
545 | add r11, r11, r12, lsl #1 @ r = r11 + delta*2 | ||
546 | add r7, r7, r12, lsr #1 @ g = r7 + delta/2 | ||
547 | #else | ||
548 | @ This element is zero - use r14 @ | ||
549 | @ | ||
550 | add r3, r3, r14 @ b = r3 + delta | ||
551 | add r11, r11, r14, lsl #1 @ r = r11 + delta*2 | ||
552 | add r7, r7, r14, lsr #1 @ g = r7 + delta/2 | ||
553 | #endif | ||
554 | @ | ||
555 | orr r12, r3, r11, asr #1 @ check if clamping is needed... | ||
556 | orr r12, r12, r7 @ ...at all | ||
557 | movs r12, r12, asr #15 @ | ||
558 | beq 15f @ no clamp @ | ||
559 | movs r12, r3, asr #15 @ clamp b | ||
560 | mvnne r3, r12, lsr #15 @ | ||
561 | andne r3, r3, #0x7c00 @ mask b only if clamped | ||
562 | movs r12, r11, asr #16 @ clamp r | ||
563 | mvnne r11, r12, lsr #16 @ | ||
564 | movs r12, r7, asr #15 @ clamp g | ||
565 | mvnne r7, r12, lsr #15 @ | ||
566 | 15: @ no clamp @ | ||
567 | @ | ||
568 | and r11, r11, #0xf800 @ r11 = |00000000|00000000|rrrrrggg|gggbbbbb| | ||
569 | and r7, r7, #0x7e00 @ | ||
570 | orr r11, r11, r7, lsr #4 @ | ||
571 | orr r11, r11, r3, lsr #10 @ | ||
572 | mov r7, r11, lsr #8 @ r7 = |00000000|00000000|00000000|rrrrrggg| | ||
573 | @ | ||
574 | 20: @ | ||
575 | ldr r3, [r0] @ | ||
576 | tst r3, #LCD1_BUSY_MASK @ | ||
577 | bne 20b @ | ||
578 | strb r7, [r0, #0x10] @ | ||
579 | 20: @ | ||
580 | ldr r3, [r0] @ | ||
581 | tst r3, #LCD1_BUSY_MASK @ | ||
582 | bne 20b @ | ||
583 | strb r11, [r0, #0x10] @ | ||
584 | @ | ||
585 | subs r1, r1, #2 @ subtract block from width | ||
586 | bgt 10b @ loop line @ | ||
587 | @ | ||
588 | ldmpc regs=r4-r11 @ restore registers and return | ||
589 | .ltorg @ dump constant pool | ||
590 | .size lcd_write_yuv420_lines_odither, .-lcd_write_yuv420_lines_odither | ||
diff --git a/firmware/target/arm/philips/sa9200/lcd-sa9200.c b/firmware/target/arm/philips/sa9200/lcd-sa9200.c index c6c297e6ca..e30a298045 100644 --- a/firmware/target/arm/philips/sa9200/lcd-sa9200.c +++ b/firmware/target/arm/philips/sa9200/lcd-sa9200.c | |||
@@ -75,6 +75,9 @@ static void lcd_display_off(void); | |||
75 | #define R_GATE_OUT_PERIOD_CTRL 0x71 | 75 | #define R_GATE_OUT_PERIOD_CTRL 0x71 |
76 | #define R_SOFTWARE_RESET 0x72 | 76 | #define R_SOFTWARE_RESET 0x72 |
77 | 77 | ||
78 | /* Display status */ | ||
79 | static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; | ||
80 | |||
78 | /* wait for LCD */ | 81 | /* wait for LCD */ |
79 | static inline void lcd_wait_write(void) | 82 | static inline void lcd_wait_write(void) |
80 | { | 83 | { |
@@ -404,6 +407,85 @@ void lcd_set_flip(bool yesno) | |||
404 | lcd_write_reg(R_DRV_OUTPUT_CONTROL, flip ? 0x090c : 0x0a0c); | 407 | lcd_write_reg(R_DRV_OUTPUT_CONTROL, flip ? 0x090c : 0x0a0c); |
405 | } | 408 | } |
406 | 409 | ||
410 | void lcd_yuv_set_options(unsigned options) | ||
411 | { | ||
412 | lcd_yuv_options = options; | ||
413 | } | ||
414 | |||
415 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
416 | void lcd_write_yuv420_lines(unsigned char const * const src[3], | ||
417 | int width, | ||
418 | int stride); | ||
419 | void lcd_write_yuv420_lines_odither(unsigned char const * const src[3], | ||
420 | int width, | ||
421 | int stride, | ||
422 | int x_screen, | ||
423 | int y_screen); | ||
424 | void lcd_blit_yuv(unsigned char * const src[3], | ||
425 | int src_x, int src_y, int stride, | ||
426 | int x, int y, int width, int height) | ||
427 | { | ||
428 | const unsigned char *yuv_src[3]; | ||
429 | const unsigned char *ysrc_max; | ||
430 | int options; | ||
431 | |||
432 | if (!display_on) | ||
433 | return; | ||
434 | |||
435 | width &= ~1; | ||
436 | height &= ~1; | ||
437 | |||
438 | /* calculate the drawing region */ | ||
439 | lcd_write_reg(R_VERT_RAM_ADDR_POS, ((x + width - 1) << 8) | x); | ||
440 | |||
441 | /* convert YUV coordinates to screen coordinates */ | ||
442 | y = LCD_WIDTH - 1 - y; | ||
443 | |||
444 | /* 2px strip: cursor moves left, then down in gram */ | ||
445 | /* BGR=1, MDT1-0=00, I/D1-0=10, AM=0 */ | ||
446 | lcd_write_reg(R_ENTRY_MODE, 0x1020); | ||
447 | |||
448 | yuv_src[0] = src[0] + src_y * stride + src_x; | ||
449 | yuv_src[1] = src[1] + (src_y * stride >> 2) + (src_x >> 1); | ||
450 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | ||
451 | ysrc_max = yuv_src[0] + height * stride; | ||
452 | |||
453 | /* cache options setting */ | ||
454 | options = lcd_yuv_options; | ||
455 | |||
456 | do | ||
457 | { | ||
458 | /* max horiz << 8 | start horiz */ | ||
459 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (y << 8) | (y - 1)); | ||
460 | |||
461 | /* position cursor (set AD0-AD15) */ | ||
462 | lcd_write_reg(R_RAM_ADDR_SET, (x << 8) | y); | ||
463 | |||
464 | /* start drawing */ | ||
465 | lcd_send_command(R_WRITE_DATA_2_GRAM); | ||
466 | |||
467 | if (options & LCD_YUV_DITHER) | ||
468 | { | ||
469 | lcd_write_yuv420_lines_odither(yuv_src, width, stride, | ||
470 | y, x); | ||
471 | } | ||
472 | else | ||
473 | { | ||
474 | lcd_write_yuv420_lines(yuv_src, width, stride); | ||
475 | } | ||
476 | |||
477 | y -= 2; /* move strip by "down" 2 px */ | ||
478 | yuv_src[0] += stride << 1; | ||
479 | yuv_src[1] += stride >> 1; | ||
480 | yuv_src[2] += stride >> 1; | ||
481 | } | ||
482 | while (yuv_src[0] < ysrc_max); | ||
483 | |||
484 | /* back to normal right, then down cursor in gram */ | ||
485 | /* BGR=1, MDT1-0=00, I/D1-0=11, AM=0 */ | ||
486 | lcd_write_reg(R_ENTRY_MODE, 0x1030); | ||
487 | } | ||
488 | |||
407 | /* Update the display. | 489 | /* Update the display. |
408 | This must be called after all other LCD functions that change the display. */ | 490 | This must be called after all other LCD functions that change the display. */ |
409 | void lcd_update(void) | 491 | void lcd_update(void) |