summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c137
1 files changed, 65 insertions, 72 deletions
diff --git a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
index 838efa4cd3..88b6539d66 100644
--- a/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
+++ b/firmware/target/arm/tms320dm320/mrobe-500/lcd-mr500.c
@@ -27,6 +27,7 @@
27#include "cpu.h" 27#include "cpu.h"
28#include "string.h" 28#include "string.h"
29#include "kernel.h" 29#include "kernel.h"
30#include "system.h"
30#include "string-extra.h" /* memset16() */ 31#include "string-extra.h" /* memset16() */
31#include "mmu-arm.h" 32#include "mmu-arm.h"
32#include "system-target.h" 33#include "system-target.h"
@@ -73,8 +74,8 @@ void lcd_sleep()
73 memset16(FRAME, 0xFFFF, LCD_WIDTH*LCD_HEIGHT); 74 memset16(FRAME, 0xFFFF, LCD_WIDTH*LCD_HEIGHT);
74 sleep(HZ/5); 75 sleep(HZ/5);
75 /* Disabling these saves another ~15mA */ 76 /* Disabling these saves another ~15mA */
76 IO_OSD_OSDWINMD0 &= ~(0x01); 77 bitclr16(&IO_OSD_OSDWINMD0, 0x01);
77 IO_VID_ENC_VMOD &= ~(0x01); 78 bitclr16(&IO_VID_ENC_VMOD, 0x01);
78 79
79 /* Disabling the LCD saves ~50mA */ 80 /* Disabling the LCD saves ~50mA */
80 IO_GIO_BITCLR2=1<<4; /* pin 36 */ 81 IO_GIO_BITCLR2=1<<4; /* pin 36 */
@@ -87,8 +88,8 @@ void lcd_awake(void)
87 if (!lcd_on) 88 if (!lcd_on)
88 { 89 {
89 lcd_on=true; 90 lcd_on=true;
90 IO_OSD_OSDWINMD0 |= 0x01; 91 bitset16(&IO_OSD_OSDWINMD0, 0x01);
91 IO_VID_ENC_VMOD |= 0x01; 92 bitset16(&IO_VID_ENC_VMOD, 0x01);
92 93
93 sleep(2); 94 sleep(2);
94 IO_GIO_BITSET2 = 1<<4; 95 IO_GIO_BITSET2 = 1<<4;
@@ -97,8 +98,7 @@ void lcd_awake(void)
97 98
98 /* Wait long enough for a frame to be written */ 99 /* Wait long enough for a frame to be written */
99 sleep(HZ/10); 100 sleep(HZ/10);
100 101
101
102 send_event(LCD_EVENT_ACTIVATION, NULL); 102 send_event(LCD_EVENT_ACTIVATION, NULL);
103 } 103 }
104} 104}
@@ -107,8 +107,6 @@ void lcd_awake(void)
107void lcd_enable_composite(bool enable) 107void lcd_enable_composite(bool enable)
108{ 108{
109 /* Pin 39 appears to be related to the composite output */ 109 /* Pin 39 appears to be related to the composite output */
110 /* 39: output, non-inverted, no-irq, falling edge, no-chat, normal */
111 dm320_set_io(39, false, false, false, false, false, 0x00);
112 110
113 short vidtemp = (IO_VID_ENC_VMOD & 0x7E8); 111 short vidtemp = (IO_VID_ENC_VMOD & 0x7E8);
114 112
@@ -140,56 +138,33 @@ void lcd_init_device(void)
140{ 138{
141 unsigned int addr; 139 unsigned int addr;
142 140
143 /* LCD related pins: 141 IO_GIO_BITCLR2 = 0x10; /* LCD off */
144 * 32 - LED above LCD 142
145 * 34 - R2 for 18 bit output
146 * 35 - Resolution (MO?)
147 * 36 - LCD power (INI?)
148 * 37 - Backlight and LCD power
149 * 38 - B2 for 18 bit output
150 */
151
152 /* Setup main LCD pins */
153 /* 32: output, non-inverted, no-irq, falling edge, no-chat, normal */
154 dm320_set_io(32, false, false, false, false, false, 0x00);
155 IO_GIO_BITCLR2 = 1; /* Turn the LED off */
156
157 /* 34: output, non-inverted, no-irq, falling edge, no-chat, R2 */
158 dm320_set_io(34, false, false, false, false, false, 0x02);
159
160 /* 35: output, non-inverted, no-irq, falling edge, no-chat, normal */
161 dm320_set_io(35, false, false, false, false, false, 0x00);
162#if LCD_NATIVE_HEIGHT > 320 143#if LCD_NATIVE_HEIGHT > 320
163 IO_GIO_BITSET2 = 1<<3; /* Set LCD resolution to VGA */ 144 IO_GIO_BITSET2 = 1<<3; /* Set LCD resolution to VGA */
164#else 145#else
165 IO_GIO_BITCLR2 = 1<<3; /* Set LCD resolution to QVGA */ 146 IO_GIO_BITCLR2 = 1<<3; /* Set LCD resolution to QVGA */
166#endif 147#endif
167
168 /* 36: output, non-inverted, no-irq, falling edge, no-chat, normal */
169 dm320_set_io(36, false, false, false, false, false, 0x00);
170 IO_GIO_BITSET2 = 0x10; /* LCD on */
171
172 /* 37: output, non-inverted, no-irq, falling edge, no-chat, normal */
173 dm320_set_io(37, false, false, false, false, false, 0x00);
174 IO_GIO_BITCLR2 = (1 << 5); /* output low (backlight/lcd on) */
175
176 /* 38: output, non-inverted, no-irq, falling edge, no-chat, B2 */
177 dm320_set_io(38, false, false, false, false, false, 0x02);
178 148
179 /* Enable clocks for display */ 149 /* Enable clocks for display */
180 IO_CLK_MOD1 |= (CLK_MOD1_VENC | CLK_MOD1_OSD); 150 bitset16(&IO_CLK_MOD1, (CLK_MOD1_VENC | CLK_MOD1_OSD));
181 151
182 /* Clear the Frame */ 152 /* Clear the Frame */
183 memset16(FRAME, 0x0000, LCD_WIDTH*LCD_HEIGHT); 153 memset16(FRAME, 0x0000, LCD_WIDTH*LCD_HEIGHT);
184 154
155 IO_VID_ENC_VDCTL = 0x0;
156 IO_VID_ENC_SYNCTL = 0x0;
157 IO_VID_ENC_LCDOUT = 0x0;
158
159 IO_VID_ENC_VMOD = 0x4;
160
161 IO_VID_ENC_DCLKCTL = 0x0800;
162 IO_VID_ENC_DCLKPTN0 = 0x0001;
163
185 IO_OSD_OSDWINMD0 &= ~(0x0001); 164 IO_OSD_OSDWINMD0 &= ~(0x0001);
186 IO_OSD_VIDWINMD &= ~(0x0001); 165 IO_OSD_VIDWINMD &= ~(0x0001);
187 166
188 /* Setup the LCD controller */ 167 /* Setup the LCD controller */
189 IO_VID_ENC_VMOD = 0x2014;
190 IO_VID_ENC_VDCTL = 0x2000;
191 IO_VID_ENC_VDPRO = 0x0000;
192 IO_VID_ENC_SYNCTL = 0x100E;
193 IO_VID_ENC_HSPLS = 1; /* HSYNC pulse width */ 168 IO_VID_ENC_HSPLS = 1; /* HSYNC pulse width */
194 IO_VID_ENC_VSPLS = 1; /* VSYNC pulse width */ 169 IO_VID_ENC_VSPLS = 1; /* VSYNC pulse width */
195 170
@@ -200,6 +175,11 @@ void lcd_init_device(void)
200 IO_VID_ENC_VINT = LCD_NATIVE_HEIGHT+8; 175 IO_VID_ENC_VINT = LCD_NATIVE_HEIGHT+8;
201 IO_VID_ENC_VSTART = 2; 176 IO_VID_ENC_VSTART = 2;
202 IO_VID_ENC_VVALID = LCD_NATIVE_HEIGHT; 177 IO_VID_ENC_VVALID = LCD_NATIVE_HEIGHT;
178
179 IO_VID_ENC_VMOD = 0x2015;
180 IO_VID_ENC_VDCTL = 0x2000;
181 IO_VID_ENC_VDPRO = 0x0000;
182 IO_VID_ENC_SYNCTL = 0x100E;
203 183
204 IO_VID_ENC_HSDLY = 0x0000; 184 IO_VID_ENC_HSDLY = 0x0000;
205 IO_VID_ENC_VSDLY = 0x0000; 185 IO_VID_ENC_VSDLY = 0x0000;
@@ -229,7 +209,7 @@ void lcd_init_device(void)
229 /* Setup the OSD windows */ 209 /* Setup the OSD windows */
230 210
231 /* Used for 565 RGB */ 211 /* Used for 565 RGB */
232 IO_OSD_OSDWINMD0 = 0x30C0; 212 IO_OSD_OSDWINMD0 = 0x30C1;
233 213
234 IO_OSD_OSDWIN0OFST = LCD_NATIVE_WIDTH *2 / 32; 214 IO_OSD_OSDWIN0OFST = LCD_NATIVE_WIDTH *2 / 32;
235 215
@@ -286,7 +266,8 @@ void lcd_init_device(void)
286 266
287 IO_OSD_OSDWINMD0 |= 0x01; 267 IO_OSD_OSDWINMD0 |= 0x01;
288 268
289 lcd_enable_composite(false); 269 IO_GIO_BITSET2 = 0x10; /* LCD on */
270// lcd_enable_composite(false);
290} 271}
291 272
292#if defined(HAVE_LCD_MODES) 273#if defined(HAVE_LCD_MODES)
@@ -344,8 +325,8 @@ static void dma_start_transfer16( char *src, int src_x, int src_y, int stride,
344 dst -= CONFIG_SDRAM_START; 325 dst -= CONFIG_SDRAM_START;
345 326
346 /* Enable Clocks */ 327 /* Enable Clocks */
347 IO_CLK_MOD1 |= 1<<8; 328 bitset16(&IO_CLK_MOD1, CLK_MOD1_IMGBUF);
348 COP_CP_CLKC |= 0x0001; 329 bitset16(&COP_CP_CLKC, 0x0001);
349 330
350 /* ... */ 331 /* ... */
351 COP_BUF_MUX1 = 0x0005; 332 COP_BUF_MUX1 = 0x0005;
@@ -399,6 +380,10 @@ static void dma_start_transfer16( char *src, int src_x, int src_y, int stride,
399 dst += (stride*pix_width); 380 dst += (stride*pix_width);
400 height--; 381 height--;
401 } while(height>0); 382 } while(height>0);
383
384 /* Disable image buffer clock */
385 bitclr16(&IO_CLK_MOD1, CLK_MOD1_IMGBUF);
386 bitclr16(&COP_CP_CLKC, 0x0001);
402} 387}
403#else 388#else
404static void dma_start_transfer16( char *src, int src_x, int src_y, int stride, 389static void dma_start_transfer16( char *src, int src_x, int src_y, int stride,
@@ -412,15 +397,17 @@ static void dma_start_transfer16( char *src, int src_x, int src_y, int stride,
412 * pix_width; 397 * pix_width;
413 398
414 /* Flush the area that is being copied from. */ 399 /* Flush the area that is being copied from. */
415 clean_dcache_range(src, (stride*pix_width*width)); 400 clean_dcache();
401
402// clean_dcache_range(src, (stride*pix_width*width));
416 403
417 /* Addresses are relative to start of SDRAM */ 404 /* Addresses are relative to start of SDRAM */
418 src -= CONFIG_SDRAM_START; 405 src -= CONFIG_SDRAM_START;
419 dst -= CONFIG_SDRAM_START; 406 dst -= CONFIG_SDRAM_START;
420 407
421 /* Enable Clocks */ 408 /* Enable Clocks */
422 IO_CLK_MOD1 |= 1<<8; 409 bitset16(&IO_CLK_MOD1, CLK_MOD1_IMGBUF);
423 COP_CP_CLKC |= 0x0001; 410 bitset16(&COP_CP_CLKC, 0x0001);
424 411
425 /* ... */ 412 /* ... */
426 COP_BUF_MUX1 = 0x0005; 413 COP_BUF_MUX1 = 0x0005;
@@ -474,6 +461,10 @@ static void dma_start_transfer16( char *src, int src_x, int src_y, int stride,
474 dst -= (stride*pix_width); 461 dst -= (stride*pix_width);
475 width--; 462 width--;
476 } while(width>0); 463 } while(width>0);
464
465 /* Disable image buffer clock */
466 bitclr16(&IO_CLK_MOD1, CLK_MOD1_IMGBUF);
467 bitclr16(&COP_CP_CLKC, 0x0001);
477} 468}
478#endif 469#endif
479#endif 470#endif
@@ -604,42 +595,46 @@ void lcd_blit_pal256(unsigned char *src, int src_x, int src_y, int x, int y,
604 } 595 }
605#endif 596#endif
606#else 597#else
598 if(width <= 0 || height <= 0)
599 return;
600
607 char *dst=(char *)FRAME 601 char *dst=(char *)FRAME
608 + (LCD_NATIVE_WIDTH+LCD_FUDGE)*(LCD_NATIVE_HEIGHT-1) 602 + (LCD_NATIVE_WIDTH+LCD_FUDGE)*(LCD_NATIVE_HEIGHT-1)
609 - (LCD_NATIVE_WIDTH+LCD_FUDGE)*x + y; 603 - (LCD_NATIVE_WIDTH+LCD_FUDGE)*x + y;
610 604
611 src=src+src_x+src_y*width; 605 src=src+src_x+src_y*width;
612 606
613 while(height--) 607 do
614 { 608 {
615 register char *c_src=src; 609 register char *c_dst = dst;
616 register char *c_dst=dst; 610 register unsigned int c_width = width;
617 register int c_width=width;
618 611
619 while (c_width--) 612 do
620 { 613 {
621 *c_dst = *c_src++; 614 *c_dst = *src++;
622 c_dst -= (LCD_NATIVE_WIDTH+LCD_FUDGE); 615 c_dst -= (LCD_NATIVE_WIDTH+LCD_FUDGE);
623 } 616 } while (--c_width);
624 617
625 dst++; 618 dst++;
626 src+=width; 619 } while(--height);
627 }
628#endif 620#endif
629} 621}
630 622
631void lcd_pal256_update_pal(fb_data *palette) 623void lcd_pal256_update_pal(fb_data *palette)
632{ 624{
633 unsigned char i; 625 unsigned int index = 255;
634 for(i=0; i< 255; i++) 626
627 do
635 { 628 {
636 int y, cb, cr; 629 int y, cb, cr;
637 unsigned char r=RGB_UNPACK_RED_LCD(palette[i])<<3; 630 fb_data index_value = palette[index];
638 unsigned char g=RGB_UNPACK_GREEN_LCD(palette[i])<<2; 631 unsigned char r = RGB_UNPACK_RED_LCD (index_value)<<3;
639 unsigned char b=RGB_UNPACK_BLUE_LCD(palette[i])<<3; 632 unsigned char g = RGB_UNPACK_GREEN_LCD (index_value)<<2;
633 unsigned char b = RGB_UNPACK_BLUE_LCD (index_value)<<3;
640 634
641 y = ((77 * r + 150 * g + 29 * b) >> 8); cb = ((-43 * r - 85 * g + 128 * b) >> 8) + 128; 635 y = (( 77 * r + 150 * g + 29 * b) >> 8);
642 cr = ((128 * r - 107 * g - 21 * b) >> 8) + 128; 636 cb = ((-43 * r - 85 * g + 128 * b) >> 8) + 128;
637 cr = ((128 * r - 107 * g - 21 * b) >> 8) + 128;
643 638
644 while(IO_OSD_MISCCTL&0x08) 639 while(IO_OSD_MISCCTL&0x08)
645 {}; 640 {};
@@ -648,8 +643,8 @@ void lcd_pal256_update_pal(fb_data *palette)
648 IO_OSD_CLUTRAMYCB= ((unsigned char)y << 8) | (unsigned char)cb; 643 IO_OSD_CLUTRAMYCB= ((unsigned char)y << 8) | (unsigned char)cb;
649 644
650 /* Write in the index and cr */ 645 /* Write in the index and cr */
651 IO_OSD_CLUTRAMCR=((unsigned char)cr << 8) | i; 646 IO_OSD_CLUTRAMCR=((unsigned char)cr << 8) | (unsigned char)index;
652 } 647 } while (index--); /* Write 256 values in */
653} 648}
654#endif 649#endif
655 650
@@ -719,16 +714,14 @@ void lcd_blit_yuv(unsigned char * const src[3],
719 c_dst -= (LCD_NATIVE_WIDTH+LCD_FUDGE); 714 c_dst -= (LCD_NATIVE_WIDTH+LCD_FUDGE);
720 715
721 c_width -= 2; 716 c_width -= 2;
722 } 717 } while (c_width);
723 while (c_width > 0);
724 718
725 yuv_src[0] += y_remain; /* Skip down two luma lines-width */ 719 yuv_src[0] += y_remain; /* Skip down two luma lines-width */
726 yuv_src[1] += cbcr_remain; /* Skip down one chroma line-width/2 */ 720 yuv_src[1] += cbcr_remain; /* Skip down one chroma line-width/2 */
727 yuv_src[2] += cbcr_remain; 721 yuv_src[2] += cbcr_remain;
728 722
729 dst+=2; 723 dst+=2;
730 } 724 } while (--height);
731 while (--height > 0);
732} 725}
733 726
734void lcd_set_contrast(int val) { 727void lcd_set_contrast(int val) {