diff options
Diffstat (limited to 'firmware/target/arm/ipod')
-rw-r--r-- | firmware/target/arm/ipod/lcd-as-color-nano.S | 287 | ||||
-rw-r--r-- | firmware/target/arm/ipod/lcd-color_nano.c | 56 | ||||
-rw-r--r-- | firmware/target/arm/ipod/video/lcd-as-video.S | 237 | ||||
-rw-r--r-- | firmware/target/arm/ipod/video/lcd-video.c | 47 |
4 files changed, 0 insertions, 627 deletions
diff --git a/firmware/target/arm/ipod/lcd-as-color-nano.S b/firmware/target/arm/ipod/lcd-as-color-nano.S deleted file mode 100644 index f6f9cc5be3..0000000000 --- a/firmware/target/arm/ipod/lcd-as-color-nano.S +++ /dev/null | |||
@@ -1,287 +0,0 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id:$ | ||
9 | * | ||
10 | * Copyright (C) 2010-2011 by Andree Buschmann | ||
11 | * | ||
12 | * Generic asm helper function used by YUV blitting. | ||
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 | * #define FORCE_FIFO_WAIT | ||
29 | * | ||
30 | * This is not needed in YUV blitting when the LCD IF is fast enough. In this | ||
31 | * case YUV-to-RGB conversion per pixel needs longer than the transfer of a | ||
32 | * pixel via the LCD IF. | ||
33 | ****************************************************************************/ | ||
34 | |||
35 | #include "config.h" | ||
36 | |||
37 | /* Set FIFO wait for both iPod Color and iPod nano1G until we know for which | ||
38 | * devices we can switch this off. */ | ||
39 | #define FORCE_FIFO_WAIT | ||
40 | |||
41 | .section .icode, "ax", %progbits | ||
42 | |||
43 | /**************************************************************************** | ||
44 | * extern void lcd_write_yuv420_lines(unsigned char const * const src[3], | ||
45 | * const unsigned LCD_BASE, | ||
46 | * int width, | ||
47 | * int stride); | ||
48 | * | ||
49 | * Conversion from Motion JPEG and MPEG Y'PbPr to RGB is: | ||
50 | * |R| |1.164 0.000 1.596| |Y' - 16| | ||
51 | * |G| = |1.164 -0.391 -0.813| |Pb - 128| | ||
52 | * |B| |1.164 2.018 0.000| |Pr - 128| | ||
53 | * | ||
54 | * Scaled, normalized, rounded and tweaked to yield RGB 565: | ||
55 | * |R| |74 0 101| |Y' - 16| >> 9 | ||
56 | * |G| = |74 -24 -51| |Cb - 128| >> 8 | ||
57 | * |B| |74 128 0| |Cr - 128| >> 9 | ||
58 | * | ||
59 | * Converts two lines from YUV to RGB565 and writes to LCD at once. First loop | ||
60 | * loads Cb/Cr, calculates the chroma offset and saves them to buffer. Within | ||
61 | * the second loop these chroma offset are reloaded from buffer. Within each | ||
62 | * loop two pixels are calculated and written to LCD. | ||
63 | */ | ||
64 | .align 2 | ||
65 | .global lcd_write_yuv420_lines | ||
66 | .type lcd_write_yuv420_lines, %function | ||
67 | lcd_write_yuv420_lines: | ||
68 | /* r0 = src = yuv_src */ | ||
69 | /* r1 = dst = LCD_BASE */ | ||
70 | /* r2 = width */ | ||
71 | /* r3 = stride */ | ||
72 | stmfd sp!, { r4-r10, lr } /* save non-scratch */ | ||
73 | ldmia r0, { r9, r10, r12 } /* r9 = yuv_src[0] = Y'_p */ | ||
74 | /* r10 = yuv_src[1] = Cb_p */ | ||
75 | /* r12 = yuv_src[2] = Cr_p */ | ||
76 | add r3, r9, r3 /* r3 = &ysrc[stride] */ | ||
77 | add r4, r2, r2, asr #1 /* chroma buffer lenght = width/2 *3 */ | ||
78 | mov r4, r4, asl #2 /* use words for str/ldm possibility */ | ||
79 | add r4, r4, #19 /* plus room for 4 additional words, */ | ||
80 | bic r4, r4, #3 /* rounded up to multiples of 4 byte */ | ||
81 | sub sp, sp, r4 /* and allocate on stack */ | ||
82 | stmia sp, {r1-r4} /* LCD_BASE, width, &ysrc[stride], stack_alloc */ | ||
83 | |||
84 | mov r7, r2 /* r7 = loop count */ | ||
85 | add r8, sp, #16 /* chroma buffer */ | ||
86 | add lr, r1, #0x100 /* LCD data port = LCD2_BASE + 0x100 */ | ||
87 | |||
88 | /* 1st loop start */ | ||
89 | 10: /* loop start */ | ||
90 | |||
91 | ldrb r0, [r10], #1 /* r0 = *usrc++ = *Cb_p++ */ | ||
92 | ldrb r1, [r12], #1 /* r1 = *vsrc++ = *Cr_p++ */ | ||
93 | |||
94 | sub r0, r0, #128 /* r0 = Cb-128 */ | ||
95 | sub r1, r1, #128 /* r1 = Cr-128 */ | ||
96 | |||
97 | add r2, r1, r1, asl #1 /* r2 = Cr*51 + Cb*24 */ | ||
98 | add r2, r2, r2, asl #4 | ||
99 | add r2, r2, r0, asl #3 | ||
100 | add r2, r2, r0, asl #4 | ||
101 | |||
102 | add r4, r1, r1, asl #2 /* r1 = Cr*101 */ | ||
103 | add r4, r4, r1, asl #5 | ||
104 | add r1, r4, r1, asl #6 | ||
105 | |||
106 | add r1, r1, #256 /* r1 = rv = (r1 + 256) >> 9 */ | ||
107 | mov r1, r1, asr #9 | ||
108 | rsb r2, r2, #128 /* r2 = guv = (-r2 + 128) >> 8 */ | ||
109 | mov r2, r2, asr #8 | ||
110 | add r0, r0, #2 /* r0 = bu = (Cb*128 + 256) >> 9 */ | ||
111 | mov r0, r0, asr #2 | ||
112 | stmia r8!, {r0-r2} /* store r0, r1 and r2 to chroma buffer */ | ||
113 | |||
114 | /* 1st loop, first pixel */ | ||
115 | ldrb r5, [r9], #1 /* r5 = *ysrc++ = *Y'_p++ */ | ||
116 | sub r5, r5, #16 /* r5 = (Y'-16) * 74 */ | ||
117 | add r3, r5, r5, asl #2 | ||
118 | add r5, r3, r5, asl #5 | ||
119 | |||
120 | add r6, r1, r5, asr #8 /* r6 = r = (Y >> 9) + rv */ | ||
121 | add r3, r2, r5, asr #7 /* r3 = g = (Y >> 8) + guv */ | ||
122 | add r4, r0, r5, asr #8 /* r4 = b = (Y >> 9) + bu */ | ||
123 | |||
124 | orr r5, r6, r4 /* check if clamping is needed... */ | ||
125 | orr r5, r5, r3, asr #1 /* ...at all */ | ||
126 | cmp r5, #31 | ||
127 | bls 15f /* -> no clamp */ | ||
128 | cmp r6, #31 /* clamp r */ | ||
129 | mvnhi r6, r6, asr #31 | ||
130 | andhi r6, r6, #31 | ||
131 | cmp r3, #63 /* clamp g */ | ||
132 | mvnhi r3, r3, asr #31 | ||
133 | andhi r3, r3, #63 | ||
134 | cmp r4, #31 /* clamp b */ | ||
135 | mvnhi r4, r4, asr #31 | ||
136 | andhi r4, r4, #31 | ||
137 | 15: /* no clamp */ | ||
138 | |||
139 | /* calculate pixel_1 and save to r4 for later pixel packing */ | ||
140 | orr r4, r4, r3, lsl #5 /* pixel_1 = r<<11 | g<<5 | b */ | ||
141 | orr r4, r4, r6, lsl #11 /* r4 = pixel_1 */ | ||
142 | |||
143 | /* 1st loop, second pixel */ | ||
144 | ldrb r5, [r9], #1 /* r5 = *ysrc++ = *Y'_p++ */ | ||
145 | sub r5, r5, #16 /* r5 = (Y'-16) * 74 */ | ||
146 | add r3, r5, r5, asl #2 | ||
147 | add r5, r3, r5, asl #5 | ||
148 | |||
149 | add r6, r1, r5, asr #8 /* r6 = r = (Y >> 9) + rv */ | ||
150 | add r3, r2, r5, asr #7 /* r3 = g = (Y >> 8) + guv */ | ||
151 | add r5, r0, r5, asr #8 /* r5 = b = (Y >> 9) + bu */ | ||
152 | |||
153 | orr r0, r6, r5 /* check if clamping is needed... */ | ||
154 | orr r0, r0, r3, asr #1 /* ...at all */ | ||
155 | cmp r0, #31 | ||
156 | bls 15f /* -> no clamp */ | ||
157 | cmp r6, #31 /* clamp r */ | ||
158 | mvnhi r6, r6, asr #31 | ||
159 | andhi r6, r6, #31 | ||
160 | cmp r3, #63 /* clamp g */ | ||
161 | mvnhi r3, r3, asr #31 | ||
162 | andhi r3, r3, #63 | ||
163 | cmp r5, #31 /* clamp b */ | ||
164 | mvnhi r5, r5, asr #31 | ||
165 | andhi r5, r5, #31 | ||
166 | 15: /* no clamp */ | ||
167 | |||
168 | /* calculate pixel_2 and pack with pixel_1 before writing */ | ||
169 | orr r5, r5, r3, lsl #5 /* pixel_2 = r<<11 | g<<5 | b */ | ||
170 | orr r5, r5, r6, lsl #11 /* r5 = pixel_2 */ | ||
171 | #ifdef FORCE_FIFO_WAIT | ||
172 | /* wait for FIFO half full */ | ||
173 | .fifo_wait1: | ||
174 | ldr r3, [lr, #-0xE0] /* while !(LCD2_BLOCK_CTRL & 0x1000000); */ | ||
175 | tst r3, #0x1000000 | ||
176 | beq .fifo_wait1 | ||
177 | #endif | ||
178 | |||
179 | mov r3, r4, lsl #8 /* swap pixel_1 */ | ||
180 | and r3, r3, #0xff00 | ||
181 | add r4, r3, r4, lsr #8 | ||
182 | |||
183 | orr r4, r4, r5, lsl #24 /* swap pixel_2 and pack with pixel_1 */ | ||
184 | mov r5, r5, lsr #8 | ||
185 | orr r4, r4, r5, lsl #16 | ||
186 | |||
187 | str r4, [lr] /* write pixel_1 and pixel_2 */ | ||
188 | |||
189 | subs r7, r7, #2 /* check for loop end */ | ||
190 | bgt 10b /* back to beginning */ | ||
191 | /* 1st loop end */ | ||
192 | |||
193 | /* Reload several registers for pointer rewinding for next loop */ | ||
194 | add r8, sp, #16 /* chroma buffer */ | ||
195 | ldmia sp, { r1, r7, r9} /* r1 = LCD_BASE */ | ||
196 | /* r7 = loop count */ | ||
197 | /* r9 = &ysrc[stride] */ | ||
198 | |||
199 | /* 2nd loop start */ | ||
200 | 20: /* loop start */ | ||
201 | /* restore r0 (bu), r1 (rv) and r2 (guv) from chroma buffer */ | ||
202 | ldmia r8!, {r0-r2} | ||
203 | |||
204 | /* 2nd loop, first pixel */ | ||
205 | ldrb r5, [r9], #1 /* r5 = *ysrc++ = *Y'_p++ */ | ||
206 | sub r5, r5, #16 /* r5 = (Y'-16) * 74 */ | ||
207 | add r3, r5, r5, asl #2 | ||
208 | add r5, r3, r5, asl #5 | ||
209 | |||
210 | add r6, r1, r5, asr #8 /* r6 = r = (Y >> 9) + rv */ | ||
211 | add r3, r2, r5, asr #7 /* r3 = g = (Y >> 8) + guv */ | ||
212 | add r4, r0, r5, asr #8 /* r4 = b = (Y >> 9) + bu */ | ||
213 | |||
214 | orr r5, r6, r4 /* check if clamping is needed... */ | ||
215 | orr r5, r5, r3, asr #1 /* ...at all */ | ||
216 | cmp r5, #31 | ||
217 | bls 15f /* -> no clamp */ | ||
218 | cmp r6, #31 /* clamp r */ | ||
219 | mvnhi r6, r6, asr #31 | ||
220 | andhi r6, r6, #31 | ||
221 | cmp r3, #63 /* clamp g */ | ||
222 | mvnhi r3, r3, asr #31 | ||
223 | andhi r3, r3, #63 | ||
224 | cmp r4, #31 /* clamp b */ | ||
225 | mvnhi r4, r4, asr #31 | ||
226 | andhi r4, r4, #31 | ||
227 | 15: /* no clamp */ | ||
228 | /* calculate pixel_1 and save to r4 for later pixel packing */ | ||
229 | orr r4, r4, r3, lsl #5 /* pixel_1 = r<<11 | g<<5 | b */ | ||
230 | orr r4, r4, r6, lsl #11 /* r4 = pixel_1 */ | ||
231 | |||
232 | /* 2nd loop, second pixel */ | ||
233 | ldrb r5, [r9], #1 /* r5 = *ysrc++ = *Y'_p++ */ | ||
234 | sub r5, r5, #16 /* r5 = (Y'-16) * 74 */ | ||
235 | add r3, r5, r5, asl #2 | ||
236 | add r5, r3, r5, asl #5 | ||
237 | |||
238 | add r6, r1, r5, asr #8 /* r6 = r = (Y >> 9) + rv */ | ||
239 | add r3, r2, r5, asr #7 /* r3 = g = (Y >> 8) + guv */ | ||
240 | add r5, r0, r5, asr #8 /* r5 = b = (Y >> 9) + bu */ | ||
241 | |||
242 | orr r0, r6, r5 /* check if clamping is needed... */ | ||
243 | orr r0, r0, r3, asr #1 /* ...at all */ | ||
244 | cmp r0, #31 | ||
245 | bls 15f /* -> no clamp */ | ||
246 | cmp r6, #31 /* clamp r */ | ||
247 | mvnhi r6, r6, asr #31 | ||
248 | andhi r6, r6, #31 | ||
249 | cmp r3, #63 /* clamp g */ | ||
250 | mvnhi r3, r3, asr #31 | ||
251 | andhi r3, r3, #63 | ||
252 | cmp r5, #31 /* clamp b */ | ||
253 | mvnhi r5, r5, asr #31 | ||
254 | andhi r5, r5, #31 | ||
255 | 15: /* no clamp */ | ||
256 | |||
257 | /* calculate pixel_2 and pack with pixel_1 before writing */ | ||
258 | orr r5, r5, r3, lsl #5 /* pixel_2 = r<<11 | g<<5 | b */ | ||
259 | orr r5, r5, r6, lsl #11 /* r5 = pixel_2 */ | ||
260 | #ifdef FORCE_FIFO_WAIT | ||
261 | /* wait for FIFO half full */ | ||
262 | .fifo_wait2: | ||
263 | ldr r3, [lr, #-0xE0] /* while !(LCD2_BLOCK_CTRL & 0x1000000); */ | ||
264 | tst r3, #0x1000000 | ||
265 | beq .fifo_wait2 | ||
266 | #endif | ||
267 | |||
268 | mov r3, r4, lsl #8 /* swap pixel_1 */ | ||
269 | and r3, r3, #0xff00 | ||
270 | add r4, r3, r4, lsr #8 | ||
271 | |||
272 | orr r4, r4, r5, lsl #24 /* swap pixel_2 and pack with pixel_1 */ | ||
273 | mov r5, r5, lsr #8 | ||
274 | orr r4, r4, r5, lsl #16 | ||
275 | |||
276 | str r4, [lr] /* write pixel_1 and pixel_2 */ | ||
277 | |||
278 | subs r7, r7, #2 /* check for loop end */ | ||
279 | bgt 20b /* back to beginning */ | ||
280 | /* 2nd loop end */ | ||
281 | |||
282 | ldr r3, [sp, #12] | ||
283 | add sp, sp, r3 /* deallocate buffer */ | ||
284 | ldmpc regs=r4-r10 /* restore registers */ | ||
285 | |||
286 | .ltorg | ||
287 | .size lcd_write_yuv420_lines, .-lcd_write_yuv420_lines | ||
diff --git a/firmware/target/arm/ipod/lcd-color_nano.c b/firmware/target/arm/ipod/lcd-color_nano.c index 67d26aa862..71ae22cb23 100644 --- a/firmware/target/arm/ipod/lcd-color_nano.c +++ b/firmware/target/arm/ipod/lcd-color_nano.c | |||
@@ -202,62 +202,6 @@ static void lcd_setup_drawing_region(int x, int y, int width, int height) | |||
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | /* Line write helper function for lcd_yuv_blit. Writes two lines of yuv420. */ | ||
206 | extern void lcd_write_yuv420_lines(unsigned char const * const src[3], | ||
207 | const unsigned int lcd_baseadress, | ||
208 | int width, | ||
209 | int stride); | ||
210 | |||
211 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
212 | void lcd_blit_yuv(unsigned char * const src[3], | ||
213 | int src_x, int src_y, int stride, | ||
214 | int x, int y, int width, int height) | ||
215 | { | ||
216 | int z; | ||
217 | unsigned char const * yuv_src[3]; | ||
218 | |||
219 | width = (width + 1) & ~1; /* ensure width is even */ | ||
220 | height = (height + 1) & ~1; /* ensure height is even */ | ||
221 | |||
222 | lcd_setup_drawing_region(x, y, width, height); | ||
223 | |||
224 | z = stride * src_y; | ||
225 | yuv_src[0] = src[0] + z + src_x; | ||
226 | yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); | ||
227 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | ||
228 | |||
229 | while (height > 0) { | ||
230 | int r, h, pixels_to_write; | ||
231 | |||
232 | pixels_to_write = (width * height) * 2; | ||
233 | h = height; | ||
234 | |||
235 | /* calculate how much we can do in one go */ | ||
236 | if (pixels_to_write > 0x10000) { | ||
237 | h = ((0x10000/2) / width) & ~1; /* ensure h is even */ | ||
238 | pixels_to_write = (width * h) * 2; | ||
239 | } | ||
240 | |||
241 | LCD2_BLOCK_CTRL = 0x10000080; | ||
242 | LCD2_BLOCK_CONFIG = 0xc0010000 | (pixels_to_write - 1); | ||
243 | LCD2_BLOCK_CTRL = 0x34000000; | ||
244 | |||
245 | r = h>>1; /* lcd_write_yuv420_lines writes two lines at once */ | ||
246 | do { | ||
247 | lcd_write_yuv420_lines(yuv_src, LCD2_BASE, width, stride); | ||
248 | yuv_src[0] += stride << 1; | ||
249 | yuv_src[1] += stride >> 1; | ||
250 | yuv_src[2] += stride >> 1; | ||
251 | } while (--r > 0); | ||
252 | |||
253 | /* transfer of pixels_to_write bytes finished */ | ||
254 | while (!(LCD2_BLOCK_CTRL & LCD2_BLOCK_READY)); | ||
255 | LCD2_BLOCK_CONFIG = 0; | ||
256 | |||
257 | height -= h; | ||
258 | } | ||
259 | } | ||
260 | |||
261 | /* Helper function writes 'count' consecutive pixels from src to LCD IF */ | 205 | /* Helper function writes 'count' consecutive pixels from src to LCD IF */ |
262 | static void lcd_write_line(int count, unsigned long *src) | 206 | static void lcd_write_line(int count, unsigned long *src) |
263 | { | 207 | { |
diff --git a/firmware/target/arm/ipod/video/lcd-as-video.S b/firmware/target/arm/ipod/video/lcd-as-video.S index 47155b8c75..1b982c75ce 100644 --- a/firmware/target/arm/ipod/video/lcd-as-video.S +++ b/firmware/target/arm/ipod/video/lcd-as-video.S | |||
@@ -63,240 +63,3 @@ lcd_write_data: /* r1 = pixel count, must be even */ | |||
63 | strne r3, [lr] | 63 | strne r3, [lr] |
64 | 64 | ||
65 | ldmpc regs=r4 | 65 | ldmpc regs=r4 |
66 | |||
67 | /**************************************************************************** | ||
68 | * extern void lcd_write_yuv420_lines(unsigned char const * const src[3], | ||
69 | * unsigned bcmaddr | ||
70 | * int width, | ||
71 | * int stride); | ||
72 | * | ||
73 | * Conversion from Motion JPEG and MPEG Y'PbPr to RGB is: | ||
74 | * |R| |1.164 0.000 1.596| |Y' - 16| | ||
75 | * |G| = |1.164 -0.391 -0.813| |Pb - 128| | ||
76 | * |B| |1.164 2.018 0.000| |Pr - 128| | ||
77 | * | ||
78 | * Scaled, normalized, rounded and tweaked to yield RGB 565: | ||
79 | * |R| |74 0 101| |Y' - 16| >> 9 | ||
80 | * |G| = |74 -24 -51| |Cb - 128| >> 8 | ||
81 | * |B| |74 128 0| |Cr - 128| >> 9 | ||
82 | * | ||
83 | * Converts two lines from YUV to RGB565 and writes to BCM at once. First loop | ||
84 | * loads Cb/Cr, calculates the chroma offset and saves them to buffer. Within | ||
85 | * the second loop these chroma offset are reloaded from buffer. | ||
86 | * Within each loop two pixels are calculated and written to BCM. Before each | ||
87 | * loop the desired destination address is transmitted to BCM. | ||
88 | */ | ||
89 | .align 2 | ||
90 | .global lcd_write_yuv420_lines | ||
91 | .type lcd_write_yuv420_lines, %function | ||
92 | lcd_write_yuv420_lines: | ||
93 | /* r0 = src = yuv_src */ | ||
94 | /* r1 = dst = bcmaddr */ | ||
95 | /* r2 = width */ | ||
96 | /* r3 = stride */ | ||
97 | stmfd sp!, { r4-r10, lr } /* save non-scratch */ | ||
98 | ldmia r0, { r9, r10, r12 } /* r9 = yuv_src[0] = Y'_p */ | ||
99 | /* r10 = yuv_src[1] = Cb_p */ | ||
100 | /* r12 = yuv_src[2] = Cr_p */ | ||
101 | add r3, r9, r3 /* r3 = &ysrc[stride] */ | ||
102 | add r4, r2, r2, asr #1 /* chroma buffer lenght = width/2 *3 */ | ||
103 | mov r4, r4, asl #2 /* use words for str/ldm possibility */ | ||
104 | add r4, r4, #19 /* plus room for 4 additional words, */ | ||
105 | bic r4, r4, #3 /* rounded up to multiples of 4 byte */ | ||
106 | sub sp, sp, r4 /* and allocate on stack */ | ||
107 | stmia sp, {r1-r4} /* bcmaddr, width, &ysrc[stride], stack_alloc */ | ||
108 | |||
109 | mov r7, r2 /* r7 = loop count */ | ||
110 | add r8, sp, #16 /* chroma buffer */ | ||
111 | mov lr, #0x30000000 /* LCD data port */ | ||
112 | |||
113 | /* The following writes dest address to BCM and waits for write ready */ | ||
114 | orr r2, lr, #0x00010000 /* r2 = BCM_WR_ADDR32 */ | ||
115 | orr r6, lr, #0x00030000 /* r6 = BCM_CONTROL */ | ||
116 | str r1, [r2] /* BCM_WR_ADDR32 = bcmaddr */ | ||
117 | .busy_1: | ||
118 | ldrh r1, [r6] /* while (!(BCM_CONTROL & 0x2)) */ | ||
119 | tst r1, #0x2 | ||
120 | beq .busy_1 | ||
121 | |||
122 | /* 1st loop start */ | ||
123 | 10: /* loop start */ | ||
124 | |||
125 | ldrb r0, [r10], #1 /* r0 = *usrc++ = *Cb_p++ */ | ||
126 | ldrb r1, [r12], #1 /* r1 = *vsrc++ = *Cr_p++ */ | ||
127 | |||
128 | sub r0, r0, #128 /* r0 = Cb-128 */ | ||
129 | sub r1, r1, #128 /* r1 = Cr-128 */ | ||
130 | |||
131 | add r2, r1, r1, asl #1 /* r2 = Cr*51 + Cb*24 */ | ||
132 | add r2, r2, r2, asl #4 | ||
133 | add r2, r2, r0, asl #3 | ||
134 | add r2, r2, r0, asl #4 | ||
135 | |||
136 | add r4, r1, r1, asl #2 /* r1 = Cr*101 */ | ||
137 | add r4, r4, r1, asl #5 | ||
138 | add r1, r4, r1, asl #6 | ||
139 | |||
140 | add r1, r1, #256 /* r1 = rv = (r1 + 256) >> 9 */ | ||
141 | mov r1, r1, asr #9 | ||
142 | rsb r2, r2, #128 /* r2 = guv = (-r2 + 128) >> 8 */ | ||
143 | mov r2, r2, asr #8 | ||
144 | add r0, r0, #2 /* r0 = bu = (Cb*128 + 256) >> 9 */ | ||
145 | mov r0, r0, asr #2 | ||
146 | stmia r8!, {r0-r2} /* store r0, r1 and r2 to chroma buffer */ | ||
147 | |||
148 | /* 1st loop, first pixel */ | ||
149 | ldrb r5, [r9], #1 /* r5 = *ysrc++ = *Y'_p++ */ | ||
150 | sub r5, r5, #16 /* r5 = (Y'-16) * 74 */ | ||
151 | add r3, r5, r5, asl #2 | ||
152 | add r5, r3, r5, asl #5 | ||
153 | |||
154 | add r6, r1, r5, asr #8 /* r6 = r = (Y >> 9) + rv */ | ||
155 | add r3, r2, r5, asr #7 /* r3 = g = (Y >> 8) + guv */ | ||
156 | add r4, r0, r5, asr #8 /* r4 = b = (Y >> 9) + bu */ | ||
157 | |||
158 | orr r5, r6, r4 /* check if clamping is needed... */ | ||
159 | orr r5, r5, r3, asr #1 /* ...at all */ | ||
160 | cmp r5, #31 | ||
161 | bls 15f /* -> no clamp */ | ||
162 | cmp r6, #31 /* clamp r */ | ||
163 | mvnhi r6, r6, asr #31 | ||
164 | andhi r6, r6, #31 | ||
165 | cmp r3, #63 /* clamp g */ | ||
166 | mvnhi r3, r3, asr #31 | ||
167 | andhi r3, r3, #63 | ||
168 | cmp r4, #31 /* clamp b */ | ||
169 | mvnhi r4, r4, asr #31 | ||
170 | andhi r4, r4, #31 | ||
171 | 15: /* no clamp */ | ||
172 | |||
173 | /* calculate pixel_1 and save to r5 for later pixel packing */ | ||
174 | orr r4, r4, r3, lsl #5 /* pixel_1 = r<<11 | g<<5 | b */ | ||
175 | orr r5, r4, r6, lsl #11 /* r5 = pixel_1 */ | ||
176 | |||
177 | /* 1st loop, second pixel */ | ||
178 | ldrb r4, [r9], #1 /* r4 = *ysrc++ = *Y'_p++ */ | ||
179 | sub r4, r4, #16 /* r4 = (Y'-16) * 74 */ | ||
180 | add r3, r4, r4, asl #2 | ||
181 | add r4, r3, r4, asl #5 | ||
182 | |||
183 | add r6, r1, r4, asr #8 /* r6 = r = (Y >> 9) + rv */ | ||
184 | add r3, r2, r4, asr #7 /* r3 = g = (Y >> 8) + guv */ | ||
185 | add r4, r0, r4, asr #8 /* r4 = b = (Y >> 9) + bu */ | ||
186 | |||
187 | orr r0, r6, r4 /* check if clamping is needed... */ | ||
188 | orr r0, r0, r3, asr #1 /* ...at all */ | ||
189 | cmp r0, #31 | ||
190 | bls 15f /* -> no clamp */ | ||
191 | cmp r6, #31 /* clamp r */ | ||
192 | mvnhi r6, r6, asr #31 | ||
193 | andhi r6, r6, #31 | ||
194 | cmp r3, #63 /* clamp g */ | ||
195 | mvnhi r3, r3, asr #31 | ||
196 | andhi r3, r3, #63 | ||
197 | cmp r4, #31 /* clamp b */ | ||
198 | mvnhi r4, r4, asr #31 | ||
199 | andhi r4, r4, #31 | ||
200 | 15: /* no clamp */ | ||
201 | |||
202 | /* calculate pixel_2 and pack with pixel_1 before writing */ | ||
203 | orr r4, r4, r3, lsl #5 /* pixel_2 = r<<11 | g<<5 | b */ | ||
204 | orr r4, r4, r6, lsl #11 /* r4 = pixel_2 */ | ||
205 | orr r4, r5, r4, lsl #16 /* r4 = pixel_2<<16 | pixel_1 */ | ||
206 | str r4, [lr] /* write packed pixels */ | ||
207 | |||
208 | subs r7, r7, #2 /* check for loop end */ | ||
209 | bgt 10b /* back to beginning */ | ||
210 | /* 1st loop end */ | ||
211 | |||
212 | /* Reload several registers for pointer rewinding for next loop */ | ||
213 | add r8, sp, #16 /* chroma buffer */ | ||
214 | ldmia sp, { r1, r7, r9} /* r1 = bcmaddr */ | ||
215 | /* r7 = loop count */ | ||
216 | /* r9 = &ysrc[stride] */ | ||
217 | |||
218 | /* The following writes dest address to BCM and waits for write ready */ | ||
219 | orr r2, lr, #0x00010000 /* r2 = BCM_WR_ADDR32 */ | ||
220 | orr r6, lr, #0x00030000 /* r6 = BCM_CONTROL */ | ||
221 | add r1, r1, #640 /* dst += (LCD_WIDTH*2) */ | ||
222 | str r1, [r2] /* BCM_WR_ADDR32 = dst */ | ||
223 | .busy_2: | ||
224 | ldrh r1, [r6] /* while (!(BCM_CONTROL & 0x2)) */ | ||
225 | tst r1, #0x2 | ||
226 | beq .busy_2 | ||
227 | |||
228 | |||
229 | /* 2nd loop start */ | ||
230 | 20: /* loop start */ | ||
231 | /* restore r0 (bu), r1 (rv) and r2 (guv) from chroma buffer */ | ||
232 | ldmia r8!, {r0-r2} | ||
233 | |||
234 | /* 2nd loop, first pixel */ | ||
235 | ldrb r5, [r9], #1 /* r5 = *ysrc++ = *Y'_p++ */ | ||
236 | sub r5, r5, #16 /* r5 = (Y'-16) * 74 */ | ||
237 | add r3, r5, r5, asl #2 | ||
238 | add r5, r3, r5, asl #5 | ||
239 | |||
240 | add r6, r1, r5, asr #8 /* r6 = r = (Y >> 9) + rv */ | ||
241 | add r3, r2, r5, asr #7 /* r3 = g = (Y >> 8) + guv */ | ||
242 | add r4, r0, r5, asr #8 /* r4 = b = (Y >> 9) + bu */ | ||
243 | |||
244 | orr r5, r6, r4 /* check if clamping is needed... */ | ||
245 | orr r5, r5, r3, asr #1 /* ...at all */ | ||
246 | cmp r5, #31 | ||
247 | bls 15f /* -> no clamp */ | ||
248 | cmp r6, #31 /* clamp r */ | ||
249 | mvnhi r6, r6, asr #31 | ||
250 | andhi r6, r6, #31 | ||
251 | cmp r3, #63 /* clamp g */ | ||
252 | mvnhi r3, r3, asr #31 | ||
253 | andhi r3, r3, #63 | ||
254 | cmp r4, #31 /* clamp b */ | ||
255 | mvnhi r4, r4, asr #31 | ||
256 | andhi r4, r4, #31 | ||
257 | 15: /* no clamp */ | ||
258 | /* calculate pixel_1 and save to r5 for later pixel packing */ | ||
259 | orr r4, r4, r3, lsl #5 /* pixel_1 = r<<11 | g<<5 | b */ | ||
260 | orr r5, r4, r6, lsl #11 /* r5 = pixel_1 */ | ||
261 | |||
262 | /* 2nd loop, second pixel */ | ||
263 | ldrb r4, [r9], #1 /* r4 = *ysrc++ = *Y'_p++ */ | ||
264 | sub r4, r4, #16 /* r4 = (Y'-16) * 74 */ | ||
265 | add r3, r4, r4, asl #2 | ||
266 | add r4, r3, r4, asl #5 | ||
267 | |||
268 | add r6, r1, r4, asr #8 /* r6 = r = (Y >> 9) + rv */ | ||
269 | add r3, r2, r4, asr #7 /* r3 = g = (Y >> 8) + guv */ | ||
270 | add r4, r0, r4, asr #8 /* r4 = b = (Y >> 9) + bu */ | ||
271 | |||
272 | orr r0, r6, r4 /* check if clamping is needed... */ | ||
273 | orr r0, r0, r3, asr #1 /* ...at all */ | ||
274 | cmp r0, #31 | ||
275 | bls 15f /* -> no clamp */ | ||
276 | cmp r6, #31 /* clamp r */ | ||
277 | mvnhi r6, r6, asr #31 | ||
278 | andhi r6, r6, #31 | ||
279 | cmp r3, #63 /* clamp g */ | ||
280 | mvnhi r3, r3, asr #31 | ||
281 | andhi r3, r3, #63 | ||
282 | cmp r4, #31 /* clamp b */ | ||
283 | mvnhi r4, r4, asr #31 | ||
284 | andhi r4, r4, #31 | ||
285 | 15: /* no clamp */ | ||
286 | |||
287 | /* calculate pixel_2 and pack with pixel_1 before writing */ | ||
288 | orr r4, r4, r3, lsl #5 /* pixel_2 = r<<11 | g<<5 | b */ | ||
289 | orr r4, r4, r6, lsl #11 /* r4 = pixel_2 */ | ||
290 | orr r4, r5, r4, lsl #16 /* r4 = pixel_2<<16 | pixel_1 */ | ||
291 | str r4, [lr] /* write packed pixels */ | ||
292 | |||
293 | subs r7, r7, #2 /* check for loop end */ | ||
294 | bgt 20b /* back to beginning */ | ||
295 | /* 2nd loop end */ | ||
296 | |||
297 | ldr r3, [sp, #12] | ||
298 | add sp, sp, r3 /* deallocate buffer */ | ||
299 | ldmpc regs=r4-r10 /* restore registers */ | ||
300 | |||
301 | .ltorg | ||
302 | .size lcd_write_yuv420_lines, .-lcd_write_yuv420_lines | ||
diff --git a/firmware/target/arm/ipod/video/lcd-video.c b/firmware/target/arm/ipod/video/lcd-video.c index 27d889aafa..494bec8429 100644 --- a/firmware/target/arm/ipod/video/lcd-video.c +++ b/firmware/target/arm/ipod/video/lcd-video.c | |||
@@ -439,53 +439,6 @@ void lcd_update(void) | |||
439 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | 439 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); |
440 | } | 440 | } |
441 | 441 | ||
442 | /* Line write helper function for lcd_yuv_blit. Writes two lines of yuv420. */ | ||
443 | extern void lcd_write_yuv420_lines(unsigned char const * const src[3], | ||
444 | unsigned bcmaddr, | ||
445 | int width, | ||
446 | int stride); | ||
447 | |||
448 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
449 | void lcd_blit_yuv(unsigned char * const src[3], | ||
450 | int src_x, int src_y, int stride, | ||
451 | int x, int y, int width, int height) | ||
452 | { | ||
453 | unsigned bcmaddr; | ||
454 | off_t z; | ||
455 | unsigned char const * yuv_src[3]; | ||
456 | |||
457 | #ifdef HAVE_LCD_SLEEP | ||
458 | if (!lcd_state.display_on) | ||
459 | return; | ||
460 | #endif | ||
461 | |||
462 | /* Sorry, but width and height must be >= 2 or else */ | ||
463 | width &= ~1; | ||
464 | |||
465 | z = stride * src_y; | ||
466 | yuv_src[0] = src[0] + z + src_x; | ||
467 | yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); | ||
468 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | ||
469 | |||
470 | /* Prevent the tick from triggering BCM updates while we're writing. */ | ||
471 | lcd_block_tick(); | ||
472 | |||
473 | bcmaddr = BCMA_CMDPARAM + (LCD_WIDTH*2) * y + (x << 1); | ||
474 | height >>= 1; | ||
475 | |||
476 | do | ||
477 | { | ||
478 | lcd_write_yuv420_lines(yuv_src, bcmaddr, width, stride); | ||
479 | bcmaddr += (LCD_WIDTH*4); /* Skip up two lines */ | ||
480 | yuv_src[0] += stride << 1; | ||
481 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
482 | yuv_src[2] += stride >> 1; | ||
483 | } | ||
484 | while (--height > 0); | ||
485 | |||
486 | lcd_unblock_and_update(); | ||
487 | } | ||
488 | |||
489 | #ifdef HAVE_LCD_SLEEP | 442 | #ifdef HAVE_LCD_SLEEP |
490 | /* Executes a BCM command immediately and waits for it to complete. | 443 | /* Executes a BCM command immediately and waits for it to complete. |
491 | Other BCM commands (eg. LCD updates or lcd_tick) must not interfere. | 444 | Other BCM commands (eg. LCD updates or lcd_tick) must not interfere. |