diff options
author | Karl Kurbjun <kkurbjun@gmail.com> | 2007-06-04 14:07:26 +0000 |
---|---|---|
committer | Karl Kurbjun <kkurbjun@gmail.com> | 2007-06-04 14:07:26 +0000 |
commit | f863ba671e2f58c6118e9c00e15631ead31c1c4b (patch) | |
tree | 7b9af523912f55aec87fa6b986c802c4cb35b336 /firmware | |
parent | 63c85110d0d7cf6ea33b37cd7923fb65523ac749 (diff) | |
download | rockbox-f863ba671e2f58c6118e9c00e15631ead31c1c4b.tar.gz rockbox-f863ba671e2f58c6118e9c00e15631ead31c1c4b.zip |
Commit part of FS7113: This adds proper LCD initialization to the gigabeat thanks to Alex Gerchanovsky
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13552 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c | 76 |
1 files changed, 61 insertions, 15 deletions
diff --git a/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c b/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c index 17b0a6966e..c96e0d6d25 100644 --- a/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c +++ b/firmware/target/arm/s3c2440/gigabeat-fx/lcd-meg-fx.c | |||
@@ -1,16 +1,9 @@ | |||
1 | #include "config.h" | 1 | #include "config.h" |
2 | #include <string.h> | ||
3 | #include "cpu.h" | 2 | #include "cpu.h" |
3 | #include "string.h" | ||
4 | #include "lcd.h" | 4 | #include "lcd.h" |
5 | #include "kernel.h" | 5 | #include "kernel.h" |
6 | #include "system.h" | ||
7 | #include "mmu-meg-fx.h" | ||
8 | #include <stdlib.h> | ||
9 | #include "memory.h" | ||
10 | #include "lcd-target.h" | 6 | #include "lcd-target.h" |
11 | #include "font.h" | ||
12 | #include "rbunicode.h" | ||
13 | #include "bidi.h" | ||
14 | 7 | ||
15 | #define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)]) | 8 | #define LCDADDR(x, y) (&lcd_framebuffer[(y)][(x)]) |
16 | 9 | ||
@@ -47,11 +40,11 @@ unsigned int LCDBASEL(unsigned int address) | |||
47 | /* LCD init */ | 40 | /* LCD init */ |
48 | void lcd_init_device(void) | 41 | void lcd_init_device(void) |
49 | { | 42 | { |
43 | int i; | ||
50 | #ifdef BOOTLOADER | 44 | #ifdef BOOTLOADER |
51 | /* When the Rockbox bootloader starts, we are changing framebuffer address, | 45 | /* When the Rockbox bootloader starts, we are changing framebuffer address, |
52 | but we don't want what's shown on the LCD to change until we do an | 46 | but we don't want what's shown on the LCD to change until we do an |
53 | lcd_update(), so copy the data from the old framebuffer to the new one */ | 47 | lcd_update(), so copy the data from the old framebuffer to the new one */ |
54 | int i; | ||
55 | unsigned short *buf = (unsigned short*)FRAME; | 48 | unsigned short *buf = (unsigned short*)FRAME; |
56 | 49 | ||
57 | memcpy(FRAME, (short *)((LCDSADDR1)<<1), 320*240*2); | 50 | memcpy(FRAME, (short *)((LCDSADDR1)<<1), 320*240*2); |
@@ -68,11 +61,62 @@ void lcd_init_device(void) | |||
68 | LCDSADDR2 = LCDBASEL((unsigned)FRAME); | 61 | LCDSADDR2 = LCDBASEL((unsigned)FRAME); |
69 | LCDSADDR3 = 0x000000F0; | 62 | LCDSADDR3 = 0x000000F0; |
70 | 63 | ||
71 | LCDCON5 |= 1 << 11; /* Switch from 555I mode to 565 mode */ | ||
72 | |||
73 | #if !defined(BOOTLOADER) | 64 | #if !defined(BOOTLOADER) |
74 | lcd_poweroff = false; | 65 | lcd_poweroff = false; |
75 | #endif | 66 | #endif |
67 | |||
68 | /* ENVID = 1, BPPMODE = 16 bpp, PNRMODE = TFT, MMODE = Each Frame, CLKVAL = 8 */ | ||
69 | LCDCON1 = 0x879; | ||
70 | |||
71 | /* VCPW = 1, VFPD = 5, LINEVAL = 319, VBPD = 7 */ | ||
72 | LCDCON2 = 0x74FC141; | ||
73 | |||
74 | /* HFPD = 9, HOZVAL = 239, HBPD = 7 */ | ||
75 | LCDCON3 = 0x38EF09; | ||
76 | |||
77 | /* HSPW = 7 */ | ||
78 | LCDCON4 = 7; | ||
79 | |||
80 | /* HWSWP = 1, INVVFRAM = 1, INVVLINE = 1, FRM565 = 1, All others = 0 */ | ||
81 | LCDCON5 = 0xB01; | ||
82 | |||
83 | /* LCD controller reset */ | ||
84 | GPBCON = (GPBCON & ~((1<<15)|(1<<17))) | (1<<16)|(1<<14); /* GPB7=OUT, GPB8=OUT */ | ||
85 | GPBDAT |= (1<<7); /* LCD reset */ | ||
86 | GPBUP |= (1<<8) | (1<<7) | 1; /* pullup GPB8, GPB7, GPB0(?) */ | ||
87 | CLKCON |= (1<<5); /* enable LCD clock */ | ||
88 | |||
89 | /* SPI bus transfer */ | ||
90 | GPBDAT &= ~(1<<8); /* LCD CS off */ | ||
91 | |||
92 | /* Start the SPI interface */ | ||
93 | CLKCON |= 1<<18; /* enable SPI clock */ | ||
94 | SPCON0 = 0x3E; /* enable iterrupt mode, master,active low,format B */ | ||
95 | SPPRE0 = 0x18; /* Baud rate = PCLK(50MHz) / 2 / (Prescaler value + 1) */ | ||
96 | |||
97 | /* SPI data - Right now we are not sure what each of these SPI writes is actually | ||
98 | * telling the lcd. Many thanks to Alex Gerchanovsky for discovering them. | ||
99 | */ | ||
100 | const unsigned char initbuf[] = { | ||
101 | 0,0x0F,1,0x01, 0,0x09,1,0x06, 0,0x16,1,0xA6, 0,0x1E,1,0x49, 0,0x1F,1,0x26, | ||
102 | 0,0x0B,1,0x2F, 0,0x0C,1,0x2B, 0,0x19,1,0x5E, 0,0x1A,1,0x15, 0,0x1B,1,0x15, | ||
103 | 0,0x1D,1,0x01, 0,0x00,1,0x03, 0,0x01,1,0x10, 0,0x02,1,0x0A, 0,0x06,1,0x04, | ||
104 | 0,0x08,1,0x2E, 0,0x24,1,0x12, 0,0x25,1,0x3F, 0,0x26,1,0x0B, 0,0x27,1,0x00, | ||
105 | 0,0x28,1,0x00, 0,0x29,1,0xF6, 0,0x2A,1,0x03, 0,0x2B,1,0x0A, 0,0x04,1,0x01}; | ||
106 | |||
107 | /* Send the SPI data */ | ||
108 | for (i=0;i<(int)sizeof(initbuf);i++) | ||
109 | { | ||
110 | while ((SPSTA0&1)==0); | ||
111 | SPRDAT0 = initbuf[i]; | ||
112 | do{int x;for(x=1000*51/2;x;x--);} while (0); | ||
113 | } | ||
114 | |||
115 | /* Stop the SPI interface */ | ||
116 | SPPRE0 = 0; | ||
117 | SPCON0 = 0; | ||
118 | CLKCON &= ~(1<<18); /* disable SPI clock */ | ||
119 | GPBDAT |= (1<<8); /* LCD CS on */ | ||
76 | } | 120 | } |
77 | 121 | ||
78 | /* Update a fraction of the display. */ | 122 | /* Update a fraction of the display. */ |
@@ -91,19 +135,21 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
91 | memcpy(((char*)FRAME) + (y * sizeof(fb_data) * LCD_WIDTH), ((char *)&lcd_framebuffer) + (y * sizeof(fb_data) * LCD_WIDTH), ((height * sizeof(fb_data) * LCD_WIDTH))); | 135 | memcpy(((char*)FRAME) + (y * sizeof(fb_data) * LCD_WIDTH), ((char *)&lcd_framebuffer) + (y * sizeof(fb_data) * LCD_WIDTH), ((height * sizeof(fb_data) * LCD_WIDTH))); |
92 | } | 136 | } |
93 | 137 | ||
94 | |||
95 | void lcd_enable(bool state) | 138 | void lcd_enable(bool state) |
96 | { | 139 | { |
97 | if(!lcd_poweroff) | 140 | if(!lcd_poweroff) |
98 | return; | 141 | return; |
99 | if(state) { | 142 | if(state) |
100 | if(!lcd_on) { | 143 | { |
144 | if(!lcd_on) | ||
145 | { | ||
101 | lcd_on = true; | 146 | lcd_on = true; |
102 | memcpy(FRAME, lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT*2); | 147 | memcpy(FRAME, lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT*2); |
103 | LCDCON1 |= 1; | 148 | LCDCON1 |= 1; |
104 | } | 149 | } |
105 | } | 150 | } |
106 | else { | 151 | else |
152 | { | ||
107 | if(lcd_on) { | 153 | if(lcd_on) { |
108 | lcd_on = false; | 154 | lcd_on = false; |
109 | LCDCON1 &= ~1; | 155 | LCDCON1 &= ~1; |