diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2011-12-16 23:40:39 +0000 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2011-12-16 23:40:39 +0000 |
commit | 95e6043d5e256df72c20db39c3be59a3ba977b19 (patch) | |
tree | 20a86cd626c43e92436459b6a408c4a13f4c21ef /firmware/target/arm/tms320dm320 | |
parent | 13b2f5381310bc4e58d34f8dac0c8b9bdbd736d2 (diff) | |
download | rockbox-95e6043d5e256df72c20db39c3be59a3ba977b19.tar.gz rockbox-95e6043d5e256df72c20db39c3be59a3ba977b19.zip |
Convert remaining memframe LCDs that can be convert to common code.
Massage the way it interfaces a bit to make things more flexible.
The chroma_buf scheme on Sansa Connect and Creative ZVx calling the
lcd_write_yuv420_lines implementation in lcd-as-memframe.S with five params
with a chroma buffer that the function can't use wouldn't work anyway so just
have them use the stock implementation (really, how was that working?).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31335 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/tms320dm320')
4 files changed, 29 insertions, 176 deletions
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c index c92920337b..e6d9e034ed 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c | |||
@@ -33,7 +33,7 @@ | |||
33 | #include "ltv350qv.h" | 33 | #include "ltv350qv.h" |
34 | 34 | ||
35 | /* Power and display status */ | 35 | /* Power and display status */ |
36 | static bool display_on = false; /* Is the display turned on? */ | 36 | extern bool lcd_on; /* lcd-memframe.c */ |
37 | static bool direct_fb_access = false; /* Does the DM320 has direct access to the FB? */ | 37 | static bool direct_fb_access = false; /* Does the DM320 has direct access to the FB? */ |
38 | 38 | ||
39 | /* Copies a rectangle from one framebuffer to another. Can be used in | 39 | /* Copies a rectangle from one framebuffer to another. Can be used in |
@@ -189,7 +189,7 @@ static void lcd_display_on(bool reset) | |||
189 | IO_VID_ENC_VMOD |= VENC_VMOD_VENC; | 189 | IO_VID_ENC_VMOD |= VENC_VMOD_VENC; |
190 | } | 190 | } |
191 | /* tell that we're on now */ | 191 | /* tell that we're on now */ |
192 | display_on = true; | 192 | lcd_on = true; |
193 | } | 193 | } |
194 | 194 | ||
195 | #ifdef HAVE_LCD_ENABLE | 195 | #ifdef HAVE_LCD_ENABLE |
@@ -224,14 +224,14 @@ static void lcd_display_off(void) | |||
224 | 224 | ||
225 | enable_venc(false); | 225 | enable_venc(false); |
226 | 226 | ||
227 | display_on = false; | 227 | lcd_on = false; |
228 | } | 228 | } |
229 | 229 | ||
230 | void lcd_enable(bool on) | 230 | void lcd_enable(bool on) |
231 | { | 231 | { |
232 | /* Disabled until properly working */ | 232 | /* Disabled until properly working */ |
233 | return; | 233 | return; |
234 | if (on == display_on) | 234 | if (on == lcd_on) |
235 | return; | 235 | return; |
236 | 236 | ||
237 | if (on) | 237 | if (on) |
@@ -247,13 +247,6 @@ return; | |||
247 | } | 247 | } |
248 | #endif | 248 | #endif |
249 | 249 | ||
250 | #if defined(HAVE_LCD_ENABLE) || defined(HAVE_LCD_SLEEP) | ||
251 | bool lcd_active(void) | ||
252 | { | ||
253 | return display_on; | ||
254 | } | ||
255 | #endif | ||
256 | |||
257 | void lcd_set_direct_fb(bool yes) | 250 | void lcd_set_direct_fb(bool yes) |
258 | { | 251 | { |
259 | unsigned int addr; | 252 | unsigned int addr; |
@@ -323,7 +316,7 @@ void lcd_init_device(void) | |||
323 | DM320_REG(0x0864) = 0; /* ???? */ | 316 | DM320_REG(0x0864) = 0; /* ???? */ |
324 | } | 317 | } |
325 | else | 318 | else |
326 | display_on = true; | 319 | lcd_on = true; |
327 | 320 | ||
328 | /* Based on lcd-mr500.c from Catalin Patulea */ | 321 | /* Based on lcd-mr500.c from Catalin Patulea */ |
329 | /* Clear the Frame */ | 322 | /* Clear the Frame */ |
@@ -369,7 +362,7 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
369 | { | 362 | { |
370 | register fb_data *dst, *src; | 363 | register fb_data *dst, *src; |
371 | 364 | ||
372 | if (!display_on || direct_fb_access) | 365 | if (!lcd_on || direct_fb_access) |
373 | return; | 366 | return; |
374 | 367 | ||
375 | if (x + width > LCD_WIDTH) | 368 | if (x + width > LCD_WIDTH) |
@@ -424,7 +417,7 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
424 | This must be called after all other LCD functions that change the display. */ | 417 | This must be called after all other LCD functions that change the display. */ |
425 | void lcd_update(void) | 418 | void lcd_update(void) |
426 | { | 419 | { |
427 | if (!display_on || direct_fb_access) | 420 | if (!lcd_on || direct_fb_access) |
428 | return; | 421 | return; |
429 | #if CONFIG_ORIENTATION == SCREEN_PORTRAIT | 422 | #if CONFIG_ORIENTATION == SCREEN_PORTRAIT |
430 | lcd_copy_buffer_rect((fb_data *)FRAME, &lcd_framebuffer[0][0], | 423 | lcd_copy_buffer_rect((fb_data *)FRAME, &lcd_framebuffer[0][0], |
@@ -433,50 +426,3 @@ void lcd_update(void) | |||
433 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | 426 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); |
434 | #endif | 427 | #endif |
435 | } | 428 | } |
436 | |||
437 | /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ | ||
438 | extern void lcd_write_yuv420_lines(fb_data *dst, | ||
439 | unsigned char chroma_buf[LCD_HEIGHT/2*3], | ||
440 | unsigned char const * const src[3], | ||
441 | int width, | ||
442 | int stride); | ||
443 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
444 | /* For the Gigabeat - show it rotated */ | ||
445 | /* So the LCD_WIDTH is now the height */ | ||
446 | void lcd_blit_yuv(unsigned char * const src[3], | ||
447 | int src_x, int src_y, int stride, | ||
448 | int x, int y, int width, int height) | ||
449 | { | ||
450 | /* Caches for chroma data so it only need be recalculated every other | ||
451 | line */ | ||
452 | unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */ | ||
453 | unsigned char const * yuv_src[3]; | ||
454 | off_t z; | ||
455 | |||
456 | if (!display_on || direct_fb_access) | ||
457 | return; | ||
458 | |||
459 | /* Sorry, but width and height must be >= 2 or else */ | ||
460 | width &= ~1; | ||
461 | height >>= 1; | ||
462 | |||
463 | fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + (LCD_WIDTH - y) - 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 | do | ||
471 | { | ||
472 | lcd_write_yuv420_lines(dst, chroma_buf, yuv_src, width, | ||
473 | stride); | ||
474 | |||
475 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
476 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
477 | yuv_src[2] += stride >> 1; | ||
478 | dst -= 2; | ||
479 | } | ||
480 | while (--height > 0); | ||
481 | } | ||
482 | |||
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h b/firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h index 720aa0cf19..456f0e3cfe 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h +++ b/firmware/target/arm/tms320dm320/creative-zvm/lcd-target.h | |||
@@ -19,12 +19,20 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #ifndef _LCD_TARGET_H_ | 22 | #ifndef LCD_TARGET_H |
23 | #define _LCD_TARGET_H_ | 23 | #define LCD_TARGET_H |
24 | |||
25 | extern void lcd_enable(bool state); | ||
26 | 24 | ||
27 | void lcd_set_direct_fb(bool yes); | 25 | void lcd_set_direct_fb(bool yes); |
28 | bool lcd_get_direct_fb(void); | 26 | bool lcd_get_direct_fb(void); |
29 | 27 | ||
30 | #endif | 28 | /* Direct FB access disables regular updates */ |
29 | #define lcd_write_enabled() \ | ||
30 | ({ lcd_on && !lcd_get_direct_fb(); }) | ||
31 | |||
32 | /* Very strange functions */ | ||
33 | #define LCD_OPTIMIZED_UPDATE | ||
34 | #define LCD_OPTIMIZED_UPDATE_RECT | ||
35 | |||
36 | #define LCD_FRAMEBUF_ADDR(col, row) ((fb_data *)FRAME + (row)*LCD_WIDTH + (col)) | ||
37 | |||
38 | #endif /* LCD_TARGET_H */ | ||
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c b/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c index 308b4297c2..ad417663fe 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c +++ b/firmware/target/arm/tms320dm320/sansa-connect/lcd-sansaconnect.c | |||
@@ -30,18 +30,7 @@ | |||
30 | #include "lcd-target.h" | 30 | #include "lcd-target.h" |
31 | #include "avr-sansaconnect.h" | 31 | #include "avr-sansaconnect.h" |
32 | 32 | ||
33 | /* Copies a rectangle from one framebuffer to another. Can be used in | 33 | extern bool lcd_on; /* lcd-memframe.c */ |
34 | single transfer mode with width = num pixels, and height = 1 which | ||
35 | allows a full-width rectangle to be copied more efficiently. */ | ||
36 | extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, | ||
37 | int width, int height); | ||
38 | |||
39 | static bool lcd_on = true; | ||
40 | |||
41 | bool lcd_active(void) | ||
42 | { | ||
43 | return lcd_on; | ||
44 | } | ||
45 | 34 | ||
46 | #if defined(HAVE_LCD_SLEEP) | 35 | #if defined(HAVE_LCD_SLEEP) |
47 | void lcd_sleep(void) | 36 | void lcd_sleep(void) |
@@ -49,6 +38,7 @@ void lcd_sleep(void) | |||
49 | if (lcd_on) | 38 | if (lcd_on) |
50 | { | 39 | { |
51 | lcd_on = false; | 40 | lcd_on = false; |
41 | |||
52 | avr_hid_lcm_sleep(); | 42 | avr_hid_lcm_sleep(); |
53 | sleep(HZ/20); | 43 | sleep(HZ/20); |
54 | 44 | ||
@@ -67,6 +57,7 @@ void lcd_awake(void) | |||
67 | if (!lcd_on) | 57 | if (!lcd_on) |
68 | { | 58 | { |
69 | lcd_on = true; | 59 | lcd_on = true; |
60 | |||
70 | /* enable video encoder clock */ | 61 | /* enable video encoder clock */ |
71 | bitset16(&IO_CLK_MOD1, CLK_MOD1_VENC); | 62 | bitset16(&IO_CLK_MOD1, CLK_MOD1_VENC); |
72 | 63 | ||
@@ -159,56 +150,7 @@ void lcd_init_device(void) | |||
159 | /* Enable Video Encoder - RGB666, custom timing */ | 150 | /* Enable Video Encoder - RGB666, custom timing */ |
160 | IO_VID_ENC_VMOD = 0x2011; | 151 | IO_VID_ENC_VMOD = 0x2011; |
161 | avr_hid_lcm_wake(); | 152 | avr_hid_lcm_wake(); |
162 | } | 153 | lcd_on = true; |
163 | |||
164 | /* Update a fraction of the display. */ | ||
165 | void lcd_update_rect(int x, int y, int width, int height) | ||
166 | __attribute__ ((section(".icode"))); | ||
167 | void lcd_update_rect(int x, int y, int width, int height) | ||
168 | { | ||
169 | register fb_data *dst, *src; | ||
170 | |||
171 | if (!lcd_on) | ||
172 | return; | ||
173 | |||
174 | if ((width | height) < 0) | ||
175 | return; /* Nothing left to do */ | ||
176 | |||
177 | if (x + width > LCD_WIDTH) | ||
178 | width = LCD_WIDTH - x; /* Clip right */ | ||
179 | if (x < 0) | ||
180 | width += x, x = 0; /* Clip left */ | ||
181 | |||
182 | if (y + height > LCD_HEIGHT) | ||
183 | height = LCD_HEIGHT - y; /* Clip bottom */ | ||
184 | if (y < 0) | ||
185 | height += y, y = 0; /* Clip top */ | ||
186 | |||
187 | dst = FRAME + LCD_WIDTH*y + x; | ||
188 | src = &lcd_framebuffer[y][x]; | ||
189 | |||
190 | /* Copy part of the Rockbox framebuffer to the second framebuffer */ | ||
191 | if (width < LCD_WIDTH) | ||
192 | { | ||
193 | /* Not full width - do line-by-line */ | ||
194 | lcd_copy_buffer_rect(dst, src, width, height); | ||
195 | } | ||
196 | else | ||
197 | { | ||
198 | /* Full width - copy as one line */ | ||
199 | lcd_copy_buffer_rect(dst, src, LCD_WIDTH*height, 1); | ||
200 | } | ||
201 | } | ||
202 | |||
203 | /* Update the display. | ||
204 | This must be called after all other LCD functions that change the display. */ | ||
205 | void lcd_update(void) __attribute__ ((section(".icode"))); | ||
206 | void lcd_update(void) | ||
207 | { | ||
208 | if (!lcd_on) | ||
209 | return; | ||
210 | |||
211 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
212 | } | 154 | } |
213 | 155 | ||
214 | void lcd_set_contrast(int val) { | 156 | void lcd_set_contrast(int val) { |
@@ -225,48 +167,3 @@ void lcd_set_flip(bool yesno) { | |||
225 | (void) yesno; | 167 | (void) yesno; |
226 | // TODO: | 168 | // TODO: |
227 | } | 169 | } |
228 | |||
229 | /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ | ||
230 | extern void lcd_write_yuv420_lines(fb_data *dst, | ||
231 | unsigned char chroma_buf[LCD_HEIGHT/2*3], | ||
232 | unsigned char const * const src[3], | ||
233 | int width, int stride); | ||
234 | |||
235 | /* Performance function to blit a YUV bitmap directly to the LCD */ | ||
236 | void lcd_blit_yuv(unsigned char * const src[3], | ||
237 | int src_x, int src_y, int stride, | ||
238 | int x, int y, int width, int height) | ||
239 | { | ||
240 | /* Caches for chroma data so it only need be recalculated every other | ||
241 | line */ | ||
242 | unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */ | ||
243 | unsigned char const * yuv_src[3]; | ||
244 | off_t z; | ||
245 | |||
246 | if (!lcd_on) | ||
247 | return; | ||
248 | |||
249 | /* Sorry, but width and height must be >= 2 or else */ | ||
250 | width &= ~1; | ||
251 | height >>= 1; | ||
252 | |||
253 | fb_data *dst = (fb_data*)FRAME + x * LCD_WIDTH + (LCD_WIDTH - y) - 1; | ||
254 | |||
255 | z = stride*src_y; | ||
256 | yuv_src[0] = src[0] + z + src_x; | ||
257 | yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); | ||
258 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | ||
259 | |||
260 | do | ||
261 | { | ||
262 | lcd_write_yuv420_lines(dst, chroma_buf, yuv_src, width, | ||
263 | stride); | ||
264 | |||
265 | yuv_src[0] += stride << 1; /* Skip down two luma lines */ | ||
266 | yuv_src[1] += stride >> 1; /* Skip down one chroma line */ | ||
267 | yuv_src[2] += stride >> 1; | ||
268 | dst -= 2; | ||
269 | } | ||
270 | while (--height > 0); | ||
271 | } | ||
272 | |||
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/lcd-target.h b/firmware/target/arm/tms320dm320/sansa-connect/lcd-target.h index da82c8fe7d..60d5df69c8 100644 --- a/firmware/target/arm/tms320dm320/sansa-connect/lcd-target.h +++ b/firmware/target/arm/tms320dm320/sansa-connect/lcd-target.h | |||
@@ -19,9 +19,11 @@ | |||
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | 21 | ||
22 | #ifndef _LCD_TARGET_H_ | 22 | #ifndef LCD_TARGET_H |
23 | #define _LCD_TARGET_H_ | 23 | #define LCD_TARGET_H |
24 | |||
25 | #define LCD_FRAMEBUF_ADDR(col, row) ((fb_data *)FRAME + (row)*LCD_WIDTH + (col)) | ||
24 | 26 | ||
25 | void lcd_awake(void); | 27 | void lcd_awake(void); |
26 | 28 | ||
27 | #endif | 29 | #endif /* LCD_TARGET_H */ |