diff options
Diffstat (limited to 'firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c')
-rw-r--r-- | firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c | 70 |
1 files changed, 42 insertions, 28 deletions
diff --git a/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c index dec20ad72f..a96f9c4f5f 100644 --- a/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c +++ b/firmware/target/arm/tms320dm320/creative-zvm/lcd-creativezvm.c | |||
@@ -30,7 +30,14 @@ | |||
30 | 30 | ||
31 | /* Power and display status */ | 31 | /* Power and display status */ |
32 | static bool display_on = true; /* Is the display turned on? */ | 32 | static bool display_on = true; /* Is the display turned on? */ |
33 | static bool direct_fb_access = false; /* Does the DM320 has direct access to the FB? */ | 33 | static bool direct_fb_access = false; /* Does the DM320 has direct access to |
34 | the FB? */ | ||
35 | |||
36 | /* Copies a rectangle from one framebuffer to another. Can be used in | ||
37 | single transfer mode with width = num pixels, and height = 1 which | ||
38 | allows a full-width rectangle to be copied more efficiently. */ | ||
39 | extern void lcd_copy_buffer_rect(fb_data *dst, const fb_data *src, | ||
40 | int width, int height); | ||
34 | 41 | ||
35 | int lcd_default_contrast(void) | 42 | int lcd_default_contrast(void) |
36 | { | 43 | { |
@@ -46,17 +53,17 @@ void lcd_set_contrast(int val) | |||
46 | 53 | ||
47 | void lcd_set_invert_display(bool yesno) { | 54 | void lcd_set_invert_display(bool yesno) { |
48 | (void) yesno; | 55 | (void) yesno; |
49 | // TODO: | 56 | /* TODO: */ |
50 | } | 57 | } |
51 | 58 | ||
52 | void lcd_set_flip(bool yesno) { | 59 | void lcd_set_flip(bool yesno) { |
53 | (void) yesno; | 60 | (void) yesno; |
54 | // TODO: | 61 | /* TODO: */ |
55 | } | 62 | } |
56 | 63 | ||
57 | 64 | ||
58 | /* LTV250QV panel functions */ | 65 | /* LTV250QV panel functions */ |
59 | 66 | #ifdef ENABLE_DISPLAY_FUNCS | |
60 | static void lcd_write_reg(unsigned char reg, unsigned short val) | 67 | static void lcd_write_reg(unsigned char reg, unsigned short val) |
61 | { | 68 | { |
62 | unsigned char block[3]; | 69 | unsigned char block[3]; |
@@ -88,7 +95,7 @@ static void lcd_display_on(void) | |||
88 | IO_GIO_BITSET2 = (1 << 8); | 95 | IO_GIO_BITSET2 = (1 << 8); |
89 | sleep_ms(1); | 96 | sleep_ms(1); |
90 | 97 | ||
91 | //Init SPI here... | 98 | /*Init SPI here... */ |
92 | sleep_ms(32); | 99 | sleep_ms(32); |
93 | 100 | ||
94 | IO_GIO_BITSET2 = (1 << 0); | 101 | IO_GIO_BITSET2 = (1 << 0); |
@@ -98,7 +105,7 @@ static void lcd_display_on(void) | |||
98 | IO_GIO_BITSET2 = (1 << 4); | 105 | IO_GIO_BITSET2 = (1 << 4); |
99 | sleep_ms(5); | 106 | sleep_ms(5); |
100 | IO_GIO_BITCLR2 = (1 << 8); | 107 | IO_GIO_BITCLR2 = (1 << 8); |
101 | //TODO: figure out what OF does after this... | 108 | /*TODO: figure out what OF does after this... */ |
102 | IO_GIO_BITSET2 = (1 << 8); | 109 | IO_GIO_BITSET2 = (1 << 8); |
103 | sleep_ms(1); | 110 | sleep_ms(1); |
104 | 111 | ||
@@ -155,7 +162,7 @@ static void lcd_display_on(void) | |||
155 | lcd_write_reg(10, 0x111A); | 162 | lcd_write_reg(10, 0x111A); |
156 | sleep_ms(10); | 163 | sleep_ms(10); |
157 | 164 | ||
158 | //TODO: other stuff! | 165 | /*TODO: other stuff! */ |
159 | 166 | ||
160 | /* tell that we're on now */ | 167 | /* tell that we're on now */ |
161 | display_on = true; | 168 | display_on = true; |
@@ -193,6 +200,7 @@ static void lcd_display_off(void) | |||
193 | IO_GIO_BITCLR2 |= (1 << 3); | 200 | IO_GIO_BITCLR2 |= (1 << 3); |
194 | } | 201 | } |
195 | 202 | ||
203 | #endif /* ENABLE_DISPLAY_FUNCS */ | ||
196 | 204 | ||
197 | 205 | ||
198 | void lcd_enable(bool on) | 206 | void lcd_enable(bool on) |
@@ -202,13 +210,13 @@ void lcd_enable(bool on) | |||
202 | 210 | ||
203 | if (on) | 211 | if (on) |
204 | { | 212 | { |
205 | display_on = true; //TODO: remove me! | 213 | display_on = true; /*TODO: remove me! */ |
206 | //lcd_display_on(); /* Turn on display */ | 214 | //lcd_display_on(); /* Turn on display */ |
207 | lcd_update(); /* Resync display */ | 215 | lcd_update(); /* Resync display */ |
208 | } | 216 | } |
209 | else | 217 | else |
210 | { | 218 | { |
211 | display_on = false; //TODO: remove me! | 219 | display_on = false; /*TODO: remove me! */ |
212 | //lcd_display_off(); /* Turn off display */ | 220 | //lcd_display_off(); /* Turn off display */ |
213 | } | 221 | } |
214 | } | 222 | } |
@@ -268,17 +276,23 @@ void lcd_init_device(void) | |||
268 | IO_OSD_OSDWIN0XL = LCD_WIDTH; | 276 | IO_OSD_OSDWIN0XL = LCD_WIDTH; |
269 | IO_OSD_OSDWIN0YL = LCD_HEIGHT; | 277 | IO_OSD_OSDWIN0YL = LCD_HEIGHT; |
270 | #if 0 | 278 | #if 0 |
271 | //TODO: set LCD clock! | 279 | /*TODO: set LCD clock! */ |
272 | IO_CLK_MOD1 &= ~0x18; // disable OSD clock and VENC clock | 280 | IO_CLK_MOD1 &= ~0x18; /* disable OSD clock and VENC clock */ |
273 | IO_CLK_02DIV = 3; | 281 | IO_CLK_02DIV = 3; |
274 | IO_CLK_OSEL = (IO_CLK_OSEL & ~0xF00) | 0x400; // reset 'General purpose clock output (GIO26, GIO34)' and set to 'PLLIN clock' | 282 | |
275 | IO_CLK_SEL1 = (IO_CLK_SEL1 | 7) | 0x1000; // set to 'GP clock output 2 (GIO26, GIO34)' and turn on 'VENC clock' | 283 | /* reset 'General purpose clock output (GIO26, GIO34)' and set to 'PLLIN |
276 | IO_CLK_MOD1 |= 0x18; // enable OSD clock and VENC clock | 284 | clock' */ |
285 | IO_CLK_OSEL = (IO_CLK_OSEL & ~0xF00) | 0x400; | ||
286 | |||
287 | /* set to 'GP clock output 2 (GIO26, GIO34)' and turn on 'VENC clock' */ | ||
288 | IO_CLK_SEL1 = (IO_CLK_SEL1 | 7) | 0x1000; | ||
289 | IO_CLK_MOD1 |= 0x18; /* enable OSD clock and VENC clock */ | ||
277 | 290 | ||
278 | /* Set LCD values in OSD */ | 291 | /* Set LCD values in OSD */ |
279 | IO_VID_ENC_VMOD = ( ( (IO_VID_ENC_VMOD & 0xFFFF8C00) | 0x14) | 0x2400 ); // disable NTSC/PAL encoder & set mode to RGB666 parallel 18 bit | 292 | /* disable NTSC/PAL encoder & set mode to RGB666 parallel 18 bit */ |
293 | IO_VID_ENC_VMOD = ( ( (IO_VID_ENC_VMOD & 0xFFFF8C00) | 0x14) | 0x2400 ); | ||
280 | IO_VID_ENC_VDCTL = ( ( (IO_VID_ENC_VDCTL & 0xFFFFCFE8) | 0x20) | 0x4000 ); | 294 | IO_VID_ENC_VDCTL = ( ( (IO_VID_ENC_VDCTL & 0xFFFFCFE8) | 0x20) | 0x4000 ); |
281 | //TODO: finish this... | 295 | /* TODO: finish this... */ |
282 | #endif | 296 | #endif |
283 | } | 297 | } |
284 | 298 | ||
@@ -293,21 +307,21 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
293 | register fb_data *dst, *src; | 307 | register fb_data *dst, *src; |
294 | 308 | ||
295 | if (!display_on || direct_fb_access) | 309 | if (!display_on || direct_fb_access) |
296 | return; | 310 | return; |
297 | 311 | ||
298 | if (x + width > LCD_WIDTH) | 312 | if (x + width > LCD_WIDTH) |
299 | width = LCD_WIDTH - x; /* Clip right */ | 313 | width = LCD_WIDTH - x; /* Clip right */ |
300 | if (x < 0) | 314 | if (x < 0) |
301 | width += x, x = 0; /* Clip left */ | 315 | width += x, x = 0; /* Clip left */ |
302 | if (width <= 0) | 316 | if (width <= 0) |
303 | return; /* nothing left to do */ | 317 | return; /* nothing left to do */ |
304 | 318 | ||
305 | if (y + height > LCD_HEIGHT) | 319 | if (y + height > LCD_HEIGHT) |
306 | height = LCD_HEIGHT - y; /* Clip bottom */ | 320 | height = LCD_HEIGHT - y; /* Clip bottom */ |
307 | if (y < 0) | 321 | if (y < 0) |
308 | height += y, y = 0; /* Clip top */ | 322 | height += y, y = 0; /* Clip top */ |
309 | if (height <= 0) | 323 | if (height <= 0) |
310 | return; /* nothing left to do */ | 324 | return; /* nothing left to do */ |
311 | 325 | ||
312 | #if CONFIG_ORIENTATION == SCREEN_PORTAIT | 326 | #if CONFIG_ORIENTATION == SCREEN_PORTAIT |
313 | dst = (fb_data *)FRAME + LCD_WIDTH*y + x; | 327 | dst = (fb_data *)FRAME + LCD_WIDTH*y + x; |
@@ -348,10 +362,10 @@ This must be called after all other LCD functions that change the display. */ | |||
348 | void lcd_update(void) | 362 | void lcd_update(void) |
349 | { | 363 | { |
350 | if (!display_on || direct_fb_access) | 364 | if (!display_on || direct_fb_access) |
351 | return; | 365 | return; |
352 | #if CONFIG_ORIENTATION == SCREEN_PORTAIT | 366 | #if CONFIG_ORIENTATION == SCREEN_PORTAIT |
353 | lcd_copy_buffer_rect((fb_data *)FRAME, &lcd_framebuffer[0][0], | 367 | lcd_copy_buffer_rect((fb_data *)FRAME, &lcd_framebuffer[0][0], |
354 | LCD_WIDTH*LCD_HEIGHT, 1); | 368 | LCD_WIDTH*LCD_HEIGHT, 1); |
355 | #else | 369 | #else |
356 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | 370 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); |
357 | #endif | 371 | #endif |
@@ -367,17 +381,17 @@ int stride); | |||
367 | /* For the Gigabeat - show it rotated */ | 381 | /* For the Gigabeat - show it rotated */ |
368 | /* So the LCD_WIDTH is now the height */ | 382 | /* So the LCD_WIDTH is now the height */ |
369 | void lcd_blit_yuv(unsigned char * const src[3], | 383 | void lcd_blit_yuv(unsigned char * const src[3], |
370 | int src_x, int src_y, int stride, | 384 | int src_x, int src_y, int stride, |
371 | int x, int y, int width, int height) | 385 | int x, int y, int width, int height) |
372 | { | 386 | { |
373 | /* Caches for chroma data so it only need be recalculated every other | 387 | /* Caches for chroma data so it only need be recalculated every other |
374 | line */ | 388 | line */ |
375 | unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */ | 389 | unsigned char chroma_buf[LCD_HEIGHT/2*3]; /* 480 bytes */ |
376 | unsigned char const * yuv_src[3]; | 390 | unsigned char const * yuv_src[3]; |
377 | off_t z; | 391 | off_t z; |
378 | 392 | ||
379 | if (!display_on || direct_fb_access) | 393 | if (!display_on || direct_fb_access) |
380 | return; | 394 | return; |
381 | 395 | ||
382 | /* Sorry, but width and height must be >= 2 or else */ | 396 | /* Sorry, but width and height must be >= 2 or else */ |
383 | width &= ~1; | 397 | width &= ~1; |