diff options
author | Mark Arigo <markarigo@gmail.com> | 2009-02-13 04:10:57 +0000 |
---|---|---|
committer | Mark Arigo <markarigo@gmail.com> | 2009-02-13 04:10:57 +0000 |
commit | 8e5c4ce097526f7668d9ebe89b6cae40b756ed8b (patch) | |
tree | fe64f362d7f87c5cb783e2cbbc0f7db9b5b2e838 | |
parent | 802b57ccd7676a9f619e93a4d326cf6f524f2079 (diff) | |
download | rockbox-8e5c4ce097526f7668d9ebe89b6cae40b756ed8b.tar.gz rockbox-8e5c4ce097526f7668d9ebe89b6cae40b756ed8b.zip |
Philips HDD1630 - add LCD YUV functions so mpegplayer works.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19997 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/plugin.c | 2 | ||||
-rw-r--r-- | apps/plugin.h | 2 | ||||
-rw-r--r-- | apps/plugins/mpegplayer/mpeg_settings.h | 2 | ||||
-rw-r--r-- | firmware/SOURCES | 1 | ||||
-rw-r--r-- | firmware/target/arm/philips/hdd1630/lcd-as-hdd1630.S | 570 | ||||
-rwxr-xr-x | firmware/target/arm/philips/hdd1630/lcd-hdd1630.c | 91 |
6 files changed, 651 insertions, 17 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index 856dd6e1cb..115db060bf 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -126,7 +126,7 @@ static const struct plugin_api rockbox_api = { | |||
126 | lcd_bitmap_transparent, | 126 | lcd_bitmap_transparent, |
127 | lcd_blit_yuv, | 127 | lcd_blit_yuv, |
128 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \ | 128 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \ |
129 | || defined(IRIVER_H10) || defined(COWON_D2) | 129 | || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) |
130 | lcd_yuv_set_options, | 130 | lcd_yuv_set_options, |
131 | #endif | 131 | #endif |
132 | #elif (LCD_DEPTH < 4) && !defined(SIMULATOR) | 132 | #elif (LCD_DEPTH < 4) && !defined(SIMULATOR) |
diff --git a/apps/plugin.h b/apps/plugin.h index 50598d5309..84c3d25654 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -205,7 +205,7 @@ struct plugin_api { | |||
205 | int src_x, int src_y, int stride, | 205 | int src_x, int src_y, int stride, |
206 | int x, int y, int width, int height); | 206 | int x, int y, int width, int height); |
207 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \ | 207 | #if defined(TOSHIBA_GIGABEAT_F) || defined(SANSA_E200) || defined(SANSA_C200) \ |
208 | || defined(IRIVER_H10) || defined(COWON_D2) | 208 | || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) |
209 | void (*lcd_yuv_set_options)(unsigned options); | 209 | void (*lcd_yuv_set_options)(unsigned options); |
210 | #endif | 210 | #endif |
211 | #elif (LCD_DEPTH < 4) && !defined(SIMULATOR) | 211 | #elif (LCD_DEPTH < 4) && !defined(SIMULATOR) |
diff --git a/apps/plugins/mpegplayer/mpeg_settings.h b/apps/plugins/mpegplayer/mpeg_settings.h index 71c6db50b0..6de9e698b0 100644 --- a/apps/plugins/mpegplayer/mpeg_settings.h +++ b/apps/plugins/mpegplayer/mpeg_settings.h | |||
@@ -6,7 +6,7 @@ | |||
6 | #define SETTINGS_FILENAME "mpegplayer.cfg" | 6 | #define SETTINGS_FILENAME "mpegplayer.cfg" |
7 | 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) | 9 | || defined(IRIVER_H10) || defined(COWON_D2) || defined(PHILIPS_HDD1630) |
10 | #define MPEG_OPTION_DITHERING_ENABLED 1 | 10 | #define MPEG_OPTION_DITHERING_ENABLED 1 |
11 | #endif | 11 | #endif |
12 | 12 | ||
diff --git a/firmware/SOURCES b/firmware/SOURCES index 321a26721b..ae9bbc0733 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -557,6 +557,7 @@ target/arm/philips/hdd1630/backlight-hdd1630.c | |||
557 | target/arm/philips/hdd1630/button-hdd1630.c | 557 | target/arm/philips/hdd1630/button-hdd1630.c |
558 | target/arm/philips/hdd1630/fmradio_i2c-hdd1630.c | 558 | target/arm/philips/hdd1630/fmradio_i2c-hdd1630.c |
559 | target/arm/philips/hdd1630/lcd-hdd1630.c | 559 | target/arm/philips/hdd1630/lcd-hdd1630.c |
560 | target/arm/philips/hdd1630/lcd-as-hdd1630.S | ||
560 | target/arm/philips/hdd1630/power-hdd1630.c | 561 | target/arm/philips/hdd1630/power-hdd1630.c |
561 | target/arm/philips/hdd1630/powermgmt-hdd1630.c | 562 | target/arm/philips/hdd1630/powermgmt-hdd1630.c |
562 | target/arm/usb-fw-pp502x.c | 563 | target/arm/usb-fw-pp502x.c |
diff --git a/firmware/target/arm/philips/hdd1630/lcd-as-hdd1630.S b/firmware/target/arm/philips/hdd1630/lcd-as-hdd1630.S new file mode 100644 index 0000000000..8f3d12e727 --- /dev/null +++ b/firmware/target/arm/philips/hdd1630/lcd-as-hdd1630.S | |||
@@ -0,0 +1,570 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2007-2008 by Michael Sevakis | ||
11 | * | ||
12 | * H10 20GB 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 | #include "config.h" | ||
25 | #include "cpu.h" | ||
26 | |||
27 | /**************************************************************************** | ||
28 | * void lcd_write_yuv_420_lines(unsigned char const * const src[3], | ||
29 | * int width, | ||
30 | * int stride); | ||
31 | * | ||
32 | * |R| |1.000000 -0.000001 1.402000| |Y'| | ||
33 | * |G| = |1.000000 -0.334136 -0.714136| |Pb| | ||
34 | * |B| |1.000000 1.772000 0.000000| |Pr| | ||
35 | * Scaled, normalized, rounded and tweaked to yield RGB 565: | ||
36 | * |R| |74 0 101| |Y' - 16| >> 9 | ||
37 | * |G| = |74 -24 -51| |Cb - 128| >> 8 | ||
38 | * |B| |74 128 0| |Cr - 128| >> 9 | ||
39 | * | ||
40 | * Write four RGB565 pixels in the following order on each loop: | ||
41 | * 1 3 + > down | ||
42 | * 2 4 \/ left | ||
43 | */ | ||
44 | .section .icode, "ax", %progbits | ||
45 | .align 2 | ||
46 | .global lcd_write_yuv420_lines | ||
47 | .type lcd_write_yuv420_lines, %function | ||
48 | lcd_write_yuv420_lines: | ||
49 | @ r0 = yuv_src | ||
50 | @ r1 = width | ||
51 | @ r2 = stride | ||
52 | stmfd sp!, { r4-r12, lr } @ save non-scratch | ||
53 | ldmia r0, { r4, r5, r6 } @ r4 = yuv_src[0] = Y'_p | ||
54 | @ r5 = yuv_src[1] = Cb_p | ||
55 | @ r6 = yuv_src[2] = Cr_p | ||
56 | @ | ||
57 | mov r0, #0x7000000c @ r0 = &LCD2_PORT = 0x70008a0c | ||
58 | add r0, r0, #0x8a00 @ | ||
59 | mov r14, #LCD2_DATA_MASK @ | ||
60 | @ | ||
61 | sub r2, r2, #1 @ Adjust stride because of increment | ||
62 | 10: @ loop line @ | ||
63 | ldrb r7, [r4], #1 @ r7 = *Y'_p++; | ||
64 | ldrb r8, [r5], #1 @ r8 = *Cb_p++; | ||
65 | ldrb r9, [r6], #1 @ r9 = *Cr_p++; | ||
66 | @ | ||
67 | sub r7, r7, #16 @ r7 = Y = (Y' - 16)*74 | ||
68 | add r12, r7, r7, asl #2 @ actually (Y' - 16)*37 and shift right | ||
69 | add r7, r12, r7, asl #5 @ by one less when adding - same for all | ||
70 | @ | ||
71 | sub r8, r8, #128 @ Cb -= 128 | ||
72 | sub r9, r9, #128 @ Cr -= 128 | ||
73 | @ | ||
74 | add r10, r9, r9, asl #1 @ r10 = Cr*51 + Cb*24 | ||
75 | add r10, r10, r10, asl #4 @ | ||
76 | add r10, r10, r8, asl #3 @ | ||
77 | add r10, r10, r8, asl #4 @ | ||
78 | @ | ||
79 | add r11, r9, r9, asl #2 @ r9 = Cr*101 | ||
80 | add r11, r11, r9, asl #5 @ | ||
81 | add r9, r11, r9, asl #6 @ | ||
82 | @ | ||
83 | add r8, r8, #2 @ r8 = bu = (Cb*128 + 128) >> 8 | ||
84 | mov r8, r8, asr #2 @ | ||
85 | add r9, r9, #256 @ r9 = rv = (r8 + 256) >> 9 | ||
86 | mov r9, r9, asr #9 @ | ||
87 | rsb r10, r10, #128 @ r10 = guv = (-r9 + 128) >> 8 | ||
88 | mov r10, r10, asr #8 @ | ||
89 | @ compute R, G, and B | ||
90 | add r3, r8, r7, asr #8 @ r3 = b = (Y >> 9) + bu | ||
91 | add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv | ||
92 | add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv | ||
93 | @ | ||
94 | orr r12, r3, r11 @ check if clamping is needed... | ||
95 | orr r12, r12, r7, asr #1 @ ...at all | ||
96 | cmp r12, #31 @ | ||
97 | bls 15f @ no clamp @ | ||
98 | cmp r3, #31 @ clamp b | ||
99 | mvnhi r3, r3, asr #31 @ | ||
100 | andhi r3, r3, #31 @ | ||
101 | cmp r11, #31 @ clamp r | ||
102 | mvnhi r11, r11, asr #31 @ | ||
103 | andhi r11, r11, #31 @ | ||
104 | cmp r7, #63 @ clamp g | ||
105 | mvnhi r7, r7, asr #31 @ | ||
106 | andhi r7, r7, #63 @ | ||
107 | 15: @ no clamp @ | ||
108 | @ | ||
109 | ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride) | ||
110 | @ | ||
111 | orr r3, r3, r11, lsl #11 @ r3 = b | (r << 11) | ||
112 | orr r3, r3, r7, lsl #5 @ r3 |= (g << 5) | ||
113 | @ | ||
114 | orr r7, r14, r3, lsr #8 @ store pixel | ||
115 | orr r11, r14, r3 @ | ||
116 | 20: @ | ||
117 | ldr r3, [r0] @ | ||
118 | tst r3, #LCD2_BUSY_MASK @ | ||
119 | bne 20b @ | ||
120 | str r7, [r0] @ | ||
121 | 20: @ | ||
122 | ldr r3, [r0] @ | ||
123 | tst r3, #LCD2_BUSY_MASK @ | ||
124 | bne 20b @ | ||
125 | str r11, [r0] @ | ||
126 | @ | ||
127 | sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74 | ||
128 | add r12, r7, r7, asl #2 @ | ||
129 | add r7, r12, r7, asl #5 @ | ||
130 | @ compute R, G, and B | ||
131 | add r3, r8, r7, asr #8 @ r3 = b = (Y >> 9) + bu | ||
132 | add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv | ||
133 | add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv | ||
134 | @ | ||
135 | orr r12, r3, r11 @ check if clamping is needed... | ||
136 | orr r12, r12, r7, asr #1 @ ...at all | ||
137 | cmp r12, #31 @ | ||
138 | bls 15f @ no clamp @ | ||
139 | cmp r3, #31 @ clamp b | ||
140 | mvnhi r3, r3, asr #31 @ | ||
141 | andhi r3, r3, #31 @ | ||
142 | cmp r11, #31 @ clamp r | ||
143 | mvnhi r11, r11, asr #31 @ | ||
144 | andhi r11, r11, #31 @ | ||
145 | cmp r7, #63 @ clamp g | ||
146 | mvnhi r7, r7, asr #31 @ | ||
147 | andhi r7, r7, #63 @ | ||
148 | 15: @ no clamp @ | ||
149 | @ | ||
150 | ldrb r12, [r4], #1 @ r12 = Y' = *(Y'_p++) | ||
151 | @ | ||
152 | orr r3, r3, r11, lsl #11 @ r3 = b | (r << 11) | ||
153 | orr r3, r3, r7, lsl #5 @ r3 |= (g << 5) | ||
154 | @ | ||
155 | orr r7, r14, r3, lsr #8 @ store pixel | ||
156 | orr r11, r14, r3 @ | ||
157 | 20: @ | ||
158 | ldr r3, [r0] @ | ||
159 | tst r3, #LCD2_BUSY_MASK @ | ||
160 | bne 20b @ | ||
161 | str r7, [r0] @ | ||
162 | 20: @ | ||
163 | ldr r3, [r0] @ | ||
164 | tst r3, #LCD2_BUSY_MASK @ | ||
165 | bne 20b @ | ||
166 | str r11, [r0] @ | ||
167 | @ | ||
168 | sub r7, r12, #16 @ r7 = Y = (Y' - 16)*74 | ||
169 | add r12, r7, r7, asl #2 @ | ||
170 | add r7, r12, r7, asl #5 @ | ||
171 | @ compute R, G, and B | ||
172 | add r3, r8, r7, asr #8 @ r3 = b = (Y >> 9) + bu | ||
173 | add r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv | ||
174 | add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv | ||
175 | @ | ||
176 | orr r12, r3, r11 @ check if clamping is needed... | ||
177 | orr r12, r12, r7, asr #1 @ ...at all | ||
178 | cmp r12, #31 @ | ||
179 | bls 15f @ no clamp @ | ||
180 | cmp r3, #31 @ clamp b | ||
181 | mvnhi r3, r3, asr #31 @ | ||
182 | andhi r3, r3, #31 @ | ||
183 | cmp r11, #31 @ clamp r | ||
184 | mvnhi r11, r11, asr #31 @ | ||
185 | andhi r11, r11, #31 @ | ||
186 | cmp r7, #63 @ clamp g | ||
187 | mvnhi r7, r7, asr #31 @ | ||
188 | andhi r7, r7, #63 @ | ||
189 | 15: @ no clamp @ | ||
190 | @ | ||
191 | ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride) | ||
192 | @ | ||
193 | orr r3, r3, r7, lsl #5 @ r3 = b | (g << 5) | ||
194 | orr r3, r3, r11, lsl #11 @ r3 |= (r << 11) | ||
195 | @ | ||
196 | orr r7, r14, r3, lsr #8 @ store pixel | ||
197 | orr r11, r14, r3 @ | ||
198 | 20: @ | ||
199 | ldr r3, [r0] @ | ||
200 | tst r3, #LCD2_BUSY_MASK @ | ||
201 | bne 20b @ | ||
202 | str r7, [r0] @ | ||
203 | 20: @ | ||
204 | ldr r3, [r0] @ | ||
205 | tst r3, #LCD2_BUSY_MASK @ | ||
206 | bne 20b @ | ||
207 | str r11, [r0] @ | ||
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 r11, r9, r7, asr #8 @ r11 = r = (Y >> 9) + rv | ||
215 | add r7, r10, r7, asr #7 @ r7 = g = (Y >> 8) + guv | ||
216 | @ | ||
217 | orr r12, r3, r11 @ 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 r11, #31 @ clamp r | ||
225 | mvnhi r11, r11, asr #31 @ | ||
226 | andhi r11, r11, #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 r3, r3, r11, lsl #11 @ r3 = b | (r << 11) | ||
233 | orr r3, r3, r7, lsl #5 @ r3 |= (g << 5) | ||
234 | @ | ||
235 | orr r7, r14, r3, lsr #8 @ store pixel | ||
236 | orr r11, r14, r3 @ | ||
237 | 20: @ | ||
238 | ldr r3, [r0] @ | ||
239 | tst r3, #LCD2_BUSY_MASK @ | ||
240 | bne 20b @ | ||
241 | str r7, [r0] @ | ||
242 | 20: @ | ||
243 | ldr r3, [r0] @ | ||
244 | tst r3, #LCD2_BUSY_MASK @ | ||
245 | bne 20b @ | ||
246 | str r11, [r0] @ | ||
247 | @ | ||
248 | subs r1, r1, #2 @ subtract block from width | ||
249 | bgt 10b @ loop line @ | ||
250 | @ | ||
251 | ldmfd sp!, { r4-r12, pc } @ restore registers and return | ||
252 | .ltorg @ dump constant pool | ||
253 | .size lcd_write_yuv420_lines, .-lcd_write_yuv420_lines | ||
254 | |||
255 | |||
256 | /**************************************************************************** | ||
257 | * void lcd_write_yuv_420_lines_odither(unsigned char const * const src[3], | ||
258 | * int width, | ||
259 | * int stride, | ||
260 | * int x_screen, | ||
261 | * int y_screen); | ||
262 | * | ||
263 | * |R| |1.000000 -0.000001 1.402000| |Y'| | ||
264 | * |G| = |1.000000 -0.334136 -0.714136| |Pb| | ||
265 | * |B| |1.000000 1.772000 0.000000| |Pr| | ||
266 | * Red scaled at twice g & b but at same precision to place it in correct | ||
267 | * bit position after multiply and leave instruction count lower. | ||
268 | * |R| |258 0 408| |Y' - 16| | ||
269 | * |G| = |149 -49 -104| |Cb - 128| | ||
270 | * |B| |149 258 0| |Cr - 128| | ||
271 | * | ||
272 | * Write four RGB565 pixels in the following order on each loop: | ||
273 | * 1 3 + > down | ||
274 | * 2 4 \/ left | ||
275 | * | ||
276 | * Kernel pattern (raw|use order): | ||
277 | * 5 3 4 2 row0 row2 > down | ||
278 | * 1 7 0 6 | 5 1 3 7 4 0 2 6 col0 left | ||
279 | * 4 2 5 3 | 4 0 2 6 5 1 3 7 col2 \/ | ||
280 | * 0 6 1 7 | ||
281 | */ | ||
282 | .section .icode, "ax", %progbits | ||
283 | .align 2 | ||
284 | .global lcd_write_yuv420_lines_odither | ||
285 | .type lcd_write_yuv420_lines_odither, %function | ||
286 | lcd_write_yuv420_lines_odither: | ||
287 | @ r0 = yuv_src | ||
288 | @ r1 = width | ||
289 | @ r2 = stride | ||
290 | @ r3 = x_screen | ||
291 | @ [sp] = y_screen | ||
292 | stmfd sp!, { r4-r12, lr } @ save non-scratch | ||
293 | ldmia r0, { r4, r5, r6 } @ r4 = yuv_src[0] = Y'_p | ||
294 | @ r5 = yuv_src[1] = Cb_p | ||
295 | @ r6 = yuv_src[2] = Cr_p | ||
296 | @ | ||
297 | ldr r0, [sp, #40] @ Line up pattern and kernel quadrant | ||
298 | eor r14, r3, r0 @ | ||
299 | and r14, r14, #0x2 @ | ||
300 | mov r14, r14, lsl #6 @ 0x00 or 0x80 | ||
301 | @ | ||
302 | mov r0, #0x7000000c @ r0 = &LCD2_PORT = 0x70008a0c | ||
303 | add r0, r0, #0x8a00 @ | ||
304 | @ | ||
305 | sub r2, r2, #1 @ Adjust stride because of increment | ||
306 | 10: @ loop line @ | ||
307 | @ | ||
308 | ldrb r7, [r4], #1 @ r7 = *Y'_p++; | ||
309 | ldrb r8, [r5], #1 @ r8 = *Cb_p++; | ||
310 | ldrb r9, [r6], #1 @ r9 = *Cr_p++; | ||
311 | @ | ||
312 | eor r14, r14, #0x80 @ flip pattern quadrant | ||
313 | @ | ||
314 | sub r7, r7, #16 @ r7 = Y = (Y' - 16)*149 | ||
315 | add r12, r7, r7, asl #2 @ | ||
316 | add r12, r12, r12, asl #4 @ | ||
317 | add r7, r12, r7, asl #6 @ | ||
318 | @ | ||
319 | sub r8, r8, #128 @ Cb -= 128 | ||
320 | sub r9, r9, #128 @ Cr -= 128 | ||
321 | @ | ||
322 | add r10, r8, r8, asl #4 @ r10 = guv = Cr*104 + Cb*49 | ||
323 | add r10, r10, r8, asl #5 @ | ||
324 | add r10, r10, r9, asl #3 @ | ||
325 | add r10, r10, r9, asl #5 @ | ||
326 | add r10, r10, r9, asl #6 @ | ||
327 | @ | ||
328 | mov r8, r8, asl #1 @ r8 = bu = Cb*258 | ||
329 | add r8, r8, r8, asl #7 @ | ||
330 | @ | ||
331 | add r9, r9, r9, asl #1 @ r9 = rv = Cr*408 | ||
332 | add r9, r9, r9, asl #4 @ | ||
333 | mov r9, r9, asl #3 @ | ||
334 | @ | ||
335 | @ compute R, G, and B | ||
336 | add r3, r8, r7 @ r3 = b' = Y + bu | ||
337 | add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv | ||
338 | rsb r7, r10, r7 @ r7 = g' = Y + guv | ||
339 | @ | ||
340 | @ r8 = bu, r9 = rv, r10 = guv | ||
341 | @ | ||
342 | sub r12, r3, r3, lsr #5 @ r3 = 31/32*b + b/256 | ||
343 | add r3, r12, r3, lsr #8 @ | ||
344 | @ | ||
345 | sub r12, r11, r11, lsr #5 @ r11 = 31/32*r + r/256 | ||
346 | add r11, r12, r11, lsr #8 @ | ||
347 | @ | ||
348 | sub r12, r7, r7, lsr #6 @ r7 = 63/64*g + g/256 | ||
349 | add r7, r12, r7, lsr #8 @ | ||
350 | @ | ||
351 | add r12, r14, #0x200 @ | ||
352 | @ | ||
353 | add r3, r3, r12 @ b = r3 + delta | ||
354 | add r11, r11, r12, lsl #1 @ r = r11 + delta*2 | ||
355 | add r7, r7, r12, lsr #1 @ g = r7 + delta/2 | ||
356 | @ | ||
357 | orr r12, r3, r11, asr #1 @ check if clamping is needed... | ||
358 | orr r12, r12, r7 @ ...at all | ||
359 | movs r12, r12, asr #15 @ | ||
360 | beq 15f @ no clamp @ | ||
361 | movs r12, r3, asr #15 @ clamp b | ||
362 | mvnne r3, r12, lsr #15 @ | ||
363 | andne r3, r3, #0x7c00 @ mask b only if clamped | ||
364 | movs r12, r11, asr #16 @ clamp r | ||
365 | mvnne r11, r12, lsr #16 @ | ||
366 | movs r12, r7, asr #15 @ clamp g | ||
367 | mvnne r7, r12, lsr #15 @ | ||
368 | 15: @ no clamp @ | ||
369 | @ | ||
370 | ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride) | ||
371 | @ | ||
372 | and r11, r11, #0xf800 @ pack pixel | ||
373 | and r7, r7, #0x7e00 @ r3 = pixel = (r & 0xf800) | | ||
374 | orr r11, r11, r7, lsr #4 @ ((g & 0x7e00) >> 4) | | ||
375 | orr r3, r11, r3, lsr #10 @ (b >> 10) | ||
376 | @ | ||
377 | mov r11, #LCD2_DATA_MASK @ store pixel | ||
378 | orr r7, r11, r3, lsr #8 @ | ||
379 | orr r11, r11, r3 @ | ||
380 | 20: @ | ||
381 | ldr r3, [r0] @ | ||
382 | tst r3, #LCD2_BUSY_MASK @ | ||
383 | bne 20b @ | ||
384 | str r7, [r0] @ | ||
385 | 20: @ | ||
386 | ldr r3, [r0] @ | ||
387 | tst r3, #LCD2_BUSY_MASK @ | ||
388 | bne 20b @ | ||
389 | str r11, [r0] @ | ||
390 | @ | ||
391 | sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149 | ||
392 | add r12, r7, r7, asl #2 @ | ||
393 | add r12, r12, r12, asl #4 @ | ||
394 | add r7, r12, r7, asl #6 @ | ||
395 | @ compute R, G, and B | ||
396 | add r3, r8, r7 @ r3 = b' = Y + bu | ||
397 | add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv | ||
398 | rsb r7, r10, r7 @ r7 = g' = Y + guv | ||
399 | @ | ||
400 | sub r12, r3, r3, lsr #5 @ r3 = 31/32*b' + b'/256 | ||
401 | add r3, r12, r3, lsr #8 @ | ||
402 | @ | ||
403 | sub r12, r11, r11, lsr #5 @ r11 = 31/32*r' + r'/256 | ||
404 | add r11, r12, r11, lsr #8 @ | ||
405 | @ | ||
406 | sub r12, r7, r7, lsr #6 @ r7 = 63/64*g' + g'/256 | ||
407 | add r7, r12, r7, lsr #8 @ | ||
408 | @ | ||
409 | @ This element is zero - use r14 @ | ||
410 | @ | ||
411 | add r3, r3, r14 @ b = r3 + delta | ||
412 | add r11, r11, r14, lsl #1 @ r = r11 + delta*2 | ||
413 | add r7, r7, r14, lsr #1 @ g = r7 + delta/2 | ||
414 | @ | ||
415 | orr r12, r3, r11, asr #1 @ check if clamping is needed... | ||
416 | orr r12, r12, r7 @ ...at all | ||
417 | movs r12, r12, asr #15 @ | ||
418 | beq 15f @ no clamp @ | ||
419 | movs r12, r3, asr #15 @ clamp b | ||
420 | mvnne r3, r12, lsr #15 @ | ||
421 | andne r3, r3, #0x7c00 @ mask b only if clamped | ||
422 | movs r12, r11, asr #16 @ clamp r | ||
423 | mvnne r11, r12, lsr #16 @ | ||
424 | movs r12, r7, asr #15 @ clamp g | ||
425 | mvnne r7, r12, lsr #15 @ | ||
426 | 15: @ no clamp @ | ||
427 | @ | ||
428 | ldrb r12, [r4], #1 @ r12 = Y' = *(Y'_p++) | ||
429 | @ | ||
430 | and r11, r11, #0xf800 @ pack pixel | ||
431 | and r7, r7, #0x7e00 @ r3 = pixel = (r & 0xf800) | | ||
432 | orr r11, r11, r7, lsr #4 @ ((g & 0x7e00) >> 4) | | ||
433 | orr r3, r11, r3, lsr #10 @ (b >> 10) | ||
434 | @ | ||
435 | mov r11, #LCD2_DATA_MASK @ store pixel | ||
436 | orr r7, r11, r3, lsr #8 @ | ||
437 | orr r11, r11, r3 @ | ||
438 | 20: @ | ||
439 | ldr r3, [r0] @ | ||
440 | tst r3, #LCD2_BUSY_MASK @ | ||
441 | bne 20b @ | ||
442 | str r7, [r0] @ | ||
443 | 20: @ | ||
444 | ldr r3, [r0] @ | ||
445 | tst r3, #LCD2_BUSY_MASK @ | ||
446 | bne 20b @ | ||
447 | str r11, [r0] @ | ||
448 | @ | ||
449 | sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149 | ||
450 | add r12, r7, r7, asl #2 @ | ||
451 | add r12, r12, r12, asl #4 @ | ||
452 | add r7, r12, r7, asl #6 @ | ||
453 | @ compute R, G, and B | ||
454 | add r3, r8, r7 @ r3 = b' = Y + bu | ||
455 | add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv | ||
456 | rsb r7, r10, r7 @ r7 = g' = Y + guv | ||
457 | @ | ||
458 | @ r8 = bu, r9 = rv, r10 = guv | ||
459 | @ | ||
460 | sub r12, r3, r3, lsr #5 @ r3 = 31/32*b' + b'/256 | ||
461 | add r3, r12, r3, lsr #8 @ | ||
462 | @ | ||
463 | sub r12, r11, r11, lsr #5 @ r11 = 31/32*r' + r'/256 | ||
464 | add r11, r12, r11, lsr #8 @ | ||
465 | @ | ||
466 | sub r12, r7, r7, lsr #6 @ r7 = 63/64*g' + g'/256 | ||
467 | add r7, r12, r7, lsr #8 @ | ||
468 | @ | ||
469 | add r12, r14, #0x100 @ | ||
470 | @ | ||
471 | add r3, r3, r12 @ b = r3 + delta | ||
472 | add r11, r11, r12, lsl #1 @ r = r11 + delta*2 | ||
473 | add r7, r7, r12, lsr #1 @ g = r7 + delta/2 | ||
474 | @ | ||
475 | orr r12, r3, r11, asr #1 @ check if clamping is needed... | ||
476 | orr r12, r12, r7 @ ...at all | ||
477 | movs r12, r12, asr #15 @ | ||
478 | beq 15f @ no clamp @ | ||
479 | movs r12, r3, asr #15 @ clamp b | ||
480 | mvnne r3, r12, lsr #15 @ | ||
481 | andne r3, r3, #0x7c00 @ mask b only if clamped | ||
482 | movs r12, r11, asr #16 @ clamp r | ||
483 | mvnne r11, r12, lsr #16 @ | ||
484 | movs r12, r7, asr #15 @ clamp g | ||
485 | mvnne r7, r12, lsr #15 @ | ||
486 | 15: @ no clamp @ | ||
487 | @ | ||
488 | ldrb r12, [r4, r2] @ r12 = Y' = *(Y'_p + stride) | ||
489 | @ | ||
490 | and r11, r11, #0xf800 @ pack pixel | ||
491 | and r7, r7, #0x7e00 @ r3 = pixel = (r & 0xf800) | | ||
492 | orr r11, r11, r7, lsr #4 @ ((g & 0x7e00) >> 4) | | ||
493 | orr r3, r11, r3, lsr #10 @ (b >> 10) | ||
494 | @ | ||
495 | mov r11, #LCD2_DATA_MASK @ store pixel | ||
496 | orr r7, r11, r3, lsr #8 @ | ||
497 | orr r11, r11, r3 @ | ||
498 | 20: @ | ||
499 | ldr r3, [r0] @ | ||
500 | tst r3, #LCD2_BUSY_MASK @ | ||
501 | bne 20b @ | ||
502 | str r7, [r0] @ | ||
503 | 20: @ | ||
504 | ldr r3, [r0] @ | ||
505 | tst r3, #LCD2_BUSY_MASK @ | ||
506 | bne 20b @ | ||
507 | str r11, [r0] @ | ||
508 | @ | ||
509 | sub r7, r12, #16 @ r7 = Y = (Y' - 16)*149 | ||
510 | add r12, r7, r7, asl #2 @ | ||
511 | add r12, r12, r12, asl #4 @ | ||
512 | add r7, r12, r7, asl #6 @ | ||
513 | @ compute R, G, and B | ||
514 | add r3, r8, r7 @ r3 = b' = Y + bu | ||
515 | add r11, r9, r7, asl #1 @ r11 = r' = Y*2 + rv | ||
516 | rsb r7, r10, r7 @ r7 = g' = Y + guv | ||
517 | @ | ||
518 | sub r12, r3, r3, lsr #5 @ r3 = 31/32*b + b/256 | ||
519 | add r3, r12, r3, lsr #8 @ | ||
520 | @ | ||
521 | sub r12, r11, r11, lsr #5 @ r11 = 31/32*r + r/256 | ||
522 | add r11, r12, r11, lsr #8 @ | ||
523 | @ | ||
524 | sub r12, r7, r7, lsr #6 @ r7 = 63/64*g + g/256 | ||
525 | add r7, r12, r7, lsr #8 @ | ||
526 | @ | ||
527 | add r12, r14, #0x300 @ | ||
528 | @ | ||
529 | add r3, r3, r12 @ b = r3 + delta | ||
530 | add r11, r11, r12, lsl #1 @ r = r11 + delta*2 | ||
531 | add r7, r7, r12, lsr #1 @ g = r7 + delta/2 | ||
532 | @ | ||
533 | orr r12, r3, r11, asr #1 @ check if clamping is needed... | ||
534 | orr r12, r12, r7 @ ...at all | ||
535 | movs r12, r12, asr #15 @ | ||
536 | beq 15f @ no clamp @ | ||
537 | movs r12, r3, asr #15 @ clamp b | ||
538 | mvnne r3, r12, lsr #15 @ | ||
539 | andne r3, r3, #0x7c00 @ mask b only if clamped | ||
540 | movs r12, r11, asr #16 @ clamp r | ||
541 | mvnne r11, r12, lsr #16 @ | ||
542 | movs r12, r7, asr #15 @ clamp g | ||
543 | mvnne r7, r12, lsr #15 @ | ||
544 | 15: @ no clamp @ | ||
545 | @ | ||
546 | and r11, r11, #0xf800 @ pack pixel | ||
547 | and r7, r7, #0x7e00 @ r3 = pixel = (r & 0xf800) | | ||
548 | orr r11, r11, r7, lsr #4 @ ((g & 0x7e00) >> 4) | | ||
549 | orr r3, r11, r3, lsr #10 @ (b >> 10) | ||
550 | @ | ||
551 | mov r11, #LCD2_DATA_MASK @ store pixel | ||
552 | orr r7, r11, r3, lsr #8 @ | ||
553 | orr r11, r11, r3 @ | ||
554 | 20: @ | ||
555 | ldr r3, [r0] @ | ||
556 | tst r3, #LCD2_BUSY_MASK @ | ||
557 | bne 20b @ | ||
558 | str r7, [r0] @ | ||
559 | 20: @ | ||
560 | ldr r3, [r0] @ | ||
561 | tst r3, #LCD2_BUSY_MASK @ | ||
562 | bne 20b @ | ||
563 | str r11, [r0] @ | ||
564 | @ | ||
565 | subs r1, r1, #2 @ subtract block from width | ||
566 | bgt 10b @ loop line @ | ||
567 | @ | ||
568 | ldmfd sp!, { r4-r12, pc } @ restore registers and return | ||
569 | .ltorg @ dump constant pool | ||
570 | .size lcd_write_yuv420_lines_odither, .-lcd_write_yuv420_lines_odither | ||
diff --git a/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c index b58bafab13..6bb0668352 100755 --- a/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c +++ b/firmware/target/arm/philips/hdd1630/lcd-hdd1630.c | |||
@@ -77,6 +77,7 @@ | |||
77 | 77 | ||
78 | /* Display status */ | 78 | /* Display status */ |
79 | static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; | 79 | static unsigned lcd_yuv_options SHAREDBSS_ATTR = 0; |
80 | static unsigned mad_ctrl = 0; | ||
80 | 81 | ||
81 | /* wait for LCD */ | 82 | /* wait for LCD */ |
82 | static inline void lcd_wait_write(void) | 83 | static inline void lcd_wait_write(void) |
@@ -179,6 +180,7 @@ void lcd_init_device(void) | |||
179 | 180 | ||
180 | lcd_send_cmd(MADCTR); | 181 | lcd_send_cmd(MADCTR); |
181 | lcd_send_data(0); | 182 | lcd_send_data(0); |
183 | mad_ctrl = 0; | ||
182 | 184 | ||
183 | lcd_send_cmd(COLMOD); | 185 | lcd_send_cmd(COLMOD); |
184 | lcd_send_data(0x5); | 186 | lcd_send_data(0x5); |
@@ -260,12 +262,13 @@ void lcd_set_invert_display(bool yesno) | |||
260 | /* turn the display upside down (call lcd_update() afterwards) */ | 262 | /* turn the display upside down (call lcd_update() afterwards) */ |
261 | void lcd_set_flip(bool yesno) | 263 | void lcd_set_flip(bool yesno) |
262 | { | 264 | { |
263 | lcd_send_cmd(MADCTR); | 265 | if (yesno) |
264 | 266 | mad_ctrl |= ((1<<7) | (1<<6)); /* flip */ | |
265 | if (!yesno) | ||
266 | lcd_send_data(0); /* normal */ | ||
267 | else | 267 | else |
268 | lcd_send_data((1<<7) | (1<<6)); /* y-mirror, x-mirror */ | 268 | mad_ctrl &= ~((1<<7) | (1<<6)); /* normal */ |
269 | |||
270 | lcd_send_cmd(MADCTR); | ||
271 | lcd_send_data(mad_ctrl); | ||
269 | } | 272 | } |
270 | 273 | ||
271 | void lcd_yuv_set_options(unsigned options) | 274 | void lcd_yuv_set_options(unsigned options) |
@@ -273,21 +276,81 @@ void lcd_yuv_set_options(unsigned options) | |||
273 | lcd_yuv_options = options; | 276 | lcd_yuv_options = options; |
274 | } | 277 | } |
275 | 278 | ||
279 | /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ | ||
280 | extern void lcd_write_yuv420_lines(unsigned char const * const src[3], | ||
281 | int width, int stride); | ||
282 | |||
283 | extern void lcd_write_yuv420_lines_odither(unsigned char const * const src[3], | ||
284 | int width, int stride, | ||
285 | int x_screen, int y_screen); | ||
286 | |||
276 | /* Performance function to blit a YUV bitmap directly to the LCD */ | 287 | /* Performance function to blit a YUV bitmap directly to the LCD */ |
277 | void lcd_blit_yuv(unsigned char * const src[3], | 288 | void lcd_blit_yuv(unsigned char * const src[3], |
278 | int src_x, int src_y, int stride, | 289 | int src_x, int src_y, int stride, |
279 | int x, int y, int width, int height) | 290 | int x, int y, int width, int height) |
280 | { | 291 | { |
281 | (void)src; | 292 | unsigned char const * yuv_src[3]; |
282 | (void)src_x; | 293 | off_t z; |
283 | (void)src_y; | 294 | |
284 | (void)stride; | 295 | /* Sorry, but width and height must be >= 2 or else */ |
285 | (void)x; | 296 | width &= ~1; |
286 | (void)y; | 297 | height >>= 1; |
287 | (void)width; | 298 | |
288 | (void)height; | 299 | z = stride*src_y; |
300 | yuv_src[0] = src[0] + z + src_x; | ||
301 | yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); | ||
302 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | ||
303 | |||
304 | /* Set vertical address mode */ | ||
305 | lcd_send_cmd(MADCTR); | ||
306 | lcd_send_data(mad_ctrl | (1<<5)); | ||
307 | |||
308 | lcd_send_cmd(RASET); | ||
309 | lcd_send_data(x); | ||
310 | lcd_send_data(x + width - 1); | ||
311 | |||
312 | if (lcd_yuv_options & LCD_YUV_DITHER) | ||
313 | { | ||
314 | do | ||
315 | { | ||
316 | lcd_send_cmd(CASET); | ||
317 | lcd_send_data(y); | ||
318 | lcd_send_data(y + 1); | ||
319 | |||
320 | lcd_send_cmd(RAMWR); | ||
321 | |||
322 | lcd_write_yuv420_lines_odither(yuv_src, width, stride, x, y); | ||
323 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
324 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
325 | yuv_src[2] += stride >> 1; | ||
326 | y += 2; | ||
327 | } | ||
328 | while (--height > 0); | ||
329 | } | ||
330 | else | ||
331 | { | ||
332 | do | ||
333 | { | ||
334 | lcd_send_cmd(CASET); | ||
335 | lcd_send_data(y); | ||
336 | lcd_send_data(y + 1); | ||
337 | |||
338 | lcd_send_cmd(RAMWR); | ||
339 | |||
340 | lcd_write_yuv420_lines(yuv_src, width, stride); | ||
341 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
342 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
343 | yuv_src[2] += stride >> 1; | ||
344 | y += 2; | ||
345 | } | ||
346 | while (--height > 0); | ||
347 | } | ||
348 | |||
349 | /* Restore the address mode */ | ||
350 | lcd_send_cmd(MADCTR); | ||
351 | lcd_send_data(mad_ctrl); | ||
289 | } | 352 | } |
290 | 353 | ||
291 | /* Update the display. | 354 | /* Update the display. |
292 | This must be called after all other LCD functions that change the display. */ | 355 | This must be called after all other LCD functions that change the display. */ |
293 | void lcd_update(void) | 356 | void lcd_update(void) |