summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-01-11 01:21:31 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-01-11 01:21:31 +0000
commit0dd74ca7224d8cb141fd924727bd65be1bda9ec6 (patch)
tree2988b0745f88ede6d6c06a46e732f5d5f72a9021
parent2e686eca633a329d99daf5a6a45b41ccb9dc5563 (diff)
downloadrockbox-0dd74ca7224d8cb141fd924727bd65be1bda9ec6.tar.gz
rockbox-0dd74ca7224d8cb141fd924727bd65be1bda9ec6.zip
SA9200: Add YUV blitting, do full-screen updates more efficiently and properly clip partial updates. Plugin struct becomes incompatible for this target but leave version alone since it's still dev-only.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@29028 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugin.c2
-rw-r--r--apps/plugin.h2
-rw-r--r--apps/plugins/mpegplayer/mpeg_settings.h2
-rw-r--r--firmware/SOURCES1
-rw-r--r--firmware/target/arm/philips/sa9200/lcd-as-sa9200.S590
-rw-r--r--firmware/target/arm/philips/sa9200/lcd-sa9200.c111
6 files changed, 690 insertions, 18 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index 16d7a76e27..1cac280e64 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -201,7 +201,7 @@ static const struct plugin_api rockbox_api = {
201#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \ 201#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \
202 || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) \ 202 || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) \
203 || defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_FUZEV2) \ 203 || defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_FUZEV2) \
204 || defined(TOSHIBA_GIGABEAT_S) 204 || defined(TOSHIBA_GIGABEAT_S) || defined(PHILIPS_SA9200)
205 lcd_yuv_set_options, 205 lcd_yuv_set_options,
206#endif 206#endif
207#endif /* MEMORYSIZE > 2 */ 207#endif /* MEMORYSIZE > 2 */
diff --git a/apps/plugin.h b/apps/plugin.h
index 84ba4e5092..e9e93d00bd 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -240,7 +240,7 @@ struct plugin_api {
240#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \ 240#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \
241 || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) \ 241 || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) \
242 || defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_FUZEV2) \ 242 || defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_FUZEV2) \
243 || defined(TOSHIBA_GIGABEAT_S) 243 || defined(TOSHIBA_GIGABEAT_S) || defined(PHILIPS_SA9200)
244 void (*lcd_yuv_set_options)(unsigned options); 244 void (*lcd_yuv_set_options)(unsigned options);
245#endif 245#endif
246#endif /* MEMORYSIZE > 2 */ 246#endif /* MEMORYSIZE > 2 */
diff --git a/apps/plugins/mpegplayer/mpeg_settings.h b/apps/plugins/mpegplayer/mpeg_settings.h
index 6287f664d3..b1704ef707 100644
--- a/apps/plugins/mpegplayer/mpeg_settings.h
+++ b/apps/plugins/mpegplayer/mpeg_settings.h
@@ -8,7 +8,7 @@
8#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \ 8#if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \
9 || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) \ 9 || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) \
10 || defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_FUZEV2) \ 10 || defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_FUZEV2) \
11 || defined(TOSHIBA_GIGABEAT_S) 11 || defined(TOSHIBA_GIGABEAT_S) || defined(PHILIPS_SA9200)
12#define MPEG_OPTION_DITHERING_ENABLED 1 12#define MPEG_OPTION_DITHERING_ENABLED 1
13#endif 13#endif
14 14
diff --git a/firmware/SOURCES b/firmware/SOURCES
index 2750b975ae..06dbf9d6e8 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -700,6 +700,7 @@ target/arm/usb-fw-pp502x.c
700target/arm/philips/sa9200/backlight-sa9200.c 700target/arm/philips/sa9200/backlight-sa9200.c
701target/arm/philips/sa9200/button-sa9200.c 701target/arm/philips/sa9200/button-sa9200.c
702target/arm/philips/sa9200/lcd-sa9200.c 702target/arm/philips/sa9200/lcd-sa9200.c
703target/arm/philips/sa9200/lcd-as-sa9200.S
703target/arm/philips/sa9200/power-sa9200.c 704target/arm/philips/sa9200/power-sa9200.c
704target/arm/philips/sa9200/powermgmt-sa9200.c 705target/arm/philips/sa9200/powermgmt-sa9200.c
705#endif /* SIMULATOR */ 706#endif /* SIMULATOR */
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
54lcd_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
6710: @ 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 @
11215: @ 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 @
12020: @
121 ldr r3, [r0] @
122 tst r3, #LCD1_BUSY_MASK @
123 bne 20b @
124 strb r14, [r0, #0x10] @
12520: @
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 @
15215: @ 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|
15920: @
160 ldr r3, [r0] @
161 tst r3, #LCD1_BUSY_MASK @
162 bne 20b @
163 strb r14, [r0, #0x10] @
16420: @
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 @
19115: @ 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|
19820: @
199 ldr r3, [r0] @
200 tst r3, #LCD1_BUSY_MASK @
201 bne 20b @
202 strb r14, [r0, #0x10] @
20320: @
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 @
23015: @ 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|
23520: @
236 ldr r3, [r0] @
237 tst r3, #LCD1_BUSY_MASK @
238 bne 20b @
239 strb r14, [r0, #0x10] @
24020: @
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
290lcd_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
31010: @ 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 @
37615: @ 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 @
38620: @
387 ldr r3, [r0] @
388 tst r3, #LCD1_BUSY_MASK @
389 bne 20b @
390 strb r7, [r0, #0x10] @
39120: @
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 @
44015: @ 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 @
45020: @
451 ldr r3, [r0] @
452 tst r3, #LCD1_BUSY_MASK @
453 bne 20b @
454 strb r7, [r0, #0x10] @
45520: @
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 @
50215: @ 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 @
51220: @
513 ldr r3, [r0] @
514 tst r3, #LCD1_BUSY_MASK @
515 bne 20b @
516 strb r7, [r0, #0x10] @
51720: @
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 @
56615: @ 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 @
57420: @
575 ldr r3, [r0] @
576 tst r3, #LCD1_BUSY_MASK @
577 bne 20b @
578 strb r7, [r0, #0x10] @
57920: @
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 51a3cf0f71..47fbfa3843 100644
--- a/firmware/target/arm/philips/sa9200/lcd-sa9200.c
+++ b/firmware/target/arm/philips/sa9200/lcd-sa9200.c
@@ -97,9 +97,9 @@ static void lcd_send_data(unsigned data)
97static void lcd_send_command(unsigned cmd) 97static void lcd_send_command(unsigned cmd)
98{ 98{
99 lcd_wait_write(); 99 lcd_wait_write();
100 LCD1_CMD = cmd >> 8; 100 LCD1_CMD = 0;
101 lcd_wait_write(); 101 lcd_wait_write();
102 LCD1_CMD = cmd & 0xff; 102 LCD1_CMD = cmd;
103} 103}
104 104
105static void lcd_write_reg(unsigned reg, unsigned data) 105static void lcd_write_reg(unsigned reg, unsigned data)
@@ -401,25 +401,101 @@ void lcd_yuv_set_options(unsigned options)
401} 401}
402 402
403/* Performance function to blit a YUV bitmap directly to the LCD */ 403/* Performance function to blit a YUV bitmap directly to the LCD */
404void lcd_write_yuv420_lines(unsigned char const * const src[3],
405 int width,
406 int stride);
407void lcd_write_yuv420_lines_odither(unsigned char const * const src[3],
408 int width,
409 int stride,
410 int x_screen,
411 int y_screen);
404void lcd_blit_yuv(unsigned char * const src[3], 412void lcd_blit_yuv(unsigned char * const src[3],
405 int src_x, int src_y, int stride, 413 int src_x, int src_y, int stride,
406 int x, int y, int width, int height) 414 int x, int y, int width, int height)
407{ 415{
408 (void)src; 416 const unsigned char *yuv_src[3];
409 (void)src_x; 417 const unsigned char *ysrc_max;
410 (void)src_y; 418 int options;
411 (void)stride; 419
412 (void)x; 420 if (!display_on)
413 (void)y; 421 return;
414 (void)width; 422
415 (void)height; 423 width &= ~1;
424 height &= ~1;
425
426 /* calculate the drawing region */
427 lcd_write_reg(R_VERT_RAM_ADDR_POS, ((x + width - 1) << 8) | x);
428
429 /* convert YUV coordinates to screen coordinates */
430 y = LCD_WIDTH - 1 - y;
431
432 /* 2px strip: cursor moves left, then down in gram */
433 /* BGR=1, MDT1-0=00, I/D1-0=10, AM=0 */
434 lcd_write_reg(R_ENTRY_MODE, 0x1020);
435
436 yuv_src[0] = src[0] + src_y * stride + src_x;
437 yuv_src[1] = src[1] + (src_y * stride >> 2) + (src_x >> 1);
438 yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
439 ysrc_max = yuv_src[0] + height * stride;
440
441 /* cache options setting */
442 options = lcd_yuv_options;
443
444 do
445 {
446 /* max horiz << 8 | start horiz */
447 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (y << 8) | (y - 1));
448
449 /* position cursor (set AD0-AD15) */
450 lcd_write_reg(R_RAM_ADDR_SET, (x << 8) | y);
451
452 /* start drawing */
453 lcd_send_command(R_WRITE_DATA_2_GRAM);
454
455 if (options & LCD_YUV_DITHER)
456 {
457 lcd_write_yuv420_lines_odither(yuv_src, width, stride,
458 y, x);
459 }
460 else
461 {
462 lcd_write_yuv420_lines(yuv_src, width, stride);
463 }
464
465 y -= 2; /* move strip by "down" 2 px */
466 yuv_src[0] += stride << 1;
467 yuv_src[1] += stride >> 1;
468 yuv_src[2] += stride >> 1;
469 }
470 while (yuv_src[0] < ysrc_max);
471
472 /* back to normal right, then down cursor in gram */
473 /* BGR=1, MDT1-0=00, I/D1-0=11, AM=0 */
474 lcd_write_reg(R_ENTRY_MODE, 0x1030);
416} 475}
417 476
418/* Update the display. 477/* Update the display.
419 This must be called after all other LCD functions that change the display. */ 478 This must be called after all other LCD functions that change the display. */
420void lcd_update(void) 479void lcd_update(void)
421{ 480{
422 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); 481 const fb_data *addr, *end;
482
483 if (!display_on)
484 return;
485
486 addr = &lcd_framebuffer[0][0];
487 end = &lcd_framebuffer[LCD_HEIGHT - 1][LCD_WIDTH];
488
489 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_WIDTH - 1) << 8);
490 lcd_write_reg(R_VERT_RAM_ADDR_POS, (LCD_HEIGHT - 1) << 8);
491 lcd_write_reg(R_RAM_ADDR_SET, 0);
492 lcd_send_command(R_WRITE_DATA_2_GRAM);
493
494 do
495 {
496 lcd_send_data(*addr++);
497 }
498 while (addr < end);
423} 499}
424 500
425/* Update a fraction of the display. */ 501/* Update a fraction of the display. */
@@ -432,18 +508,23 @@ void lcd_update_rect(int x, int y, int width, int height)
432 508
433 if (x + width > LCD_WIDTH) 509 if (x + width > LCD_WIDTH)
434 width = LCD_WIDTH - x; 510 width = LCD_WIDTH - x;
511 if (x < 0)
512 width += x, x = 0;
513 if (width <= 0)
514 return; /* Nothing left to do. */
435 515
436 if (y + height > LCD_HEIGHT) 516 if (y + height > LCD_HEIGHT)
437 height = LCD_HEIGHT - y; 517 height = LCD_HEIGHT - y;
438 518 if (y < 0)
439 if ((width <= 0) || (height <= 0)) 519 height += y, y = 0;
520 if (height <= 0)
440 return; /* Nothing left to do. */ 521 return; /* Nothing left to do. */
441 522
442 addr = &lcd_framebuffer[y][x]; 523 addr = &lcd_framebuffer[y][x];
443 524
444 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, ((x + width - 1) << 8) | x); 525 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, ((x + width - 1) << 8) | x);
445 lcd_write_reg(R_VERT_RAM_ADDR_POS, ((y + height -1) << 8) | y); 526 lcd_write_reg(R_VERT_RAM_ADDR_POS, ((y + height - 1) << 8) | y);
446 lcd_write_reg(R_RAM_ADDR_SET, ((y & 0xff) << 8) | (x & 0xff)); 527 lcd_write_reg(R_RAM_ADDR_SET, (y << 8) | x);
447 lcd_send_command(R_WRITE_DATA_2_GRAM); 528 lcd_send_command(R_WRITE_DATA_2_GRAM);
448 529
449 do { 530 do {