diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuze')
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c | 96 |
1 files changed, 23 insertions, 73 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c index 76b74b7c3e..b8feeb103e 100644 --- a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c +++ b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c | |||
@@ -24,6 +24,9 @@ | |||
24 | 24 | ||
25 | #include "cpu.h" | 25 | #include "cpu.h" |
26 | #include "lcd.h" | 26 | #include "lcd.h" |
27 | #include "file.h" | ||
28 | #include "debug.h" | ||
29 | #include "system.h" | ||
27 | #include "clock-target.h" | 30 | #include "clock-target.h" |
28 | 31 | ||
29 | /* The controller is unknown, but some registers appear to be the same as the | 32 | /* The controller is unknown, but some registers appear to be the same as the |
@@ -35,19 +38,10 @@ | |||
35 | 38 | ||
36 | #define R_ENTRY_MODE_HORZ 0x7030 | 39 | #define R_ENTRY_MODE_HORZ 0x7030 |
37 | 40 | ||
38 | |||
39 | static bool display_on = false; /* is the display turned on? */ | 41 | static bool display_on = false; /* is the display turned on? */ |
40 | static bool display_flipped = false; | 42 | static bool display_flipped = false; |
41 | static int xoffset = 20; /* needed for flip */ | 43 | static int xoffset = 20; /* needed for flip */ |
42 | 44 | ||
43 | /* TODO: Implement this function */ | ||
44 | static void lcd_delay(int x) | ||
45 | { | ||
46 | /* This is just arbitrary - the OF does something more complex */ | ||
47 | x *= 1024; | ||
48 | while (x--); | ||
49 | } | ||
50 | |||
51 | static void as3525_dbop_init(void) | 45 | static void as3525_dbop_init(void) |
52 | { | 46 | { |
53 | CGU_DBOP = (1<<3) | CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ); | 47 | CGU_DBOP = (1<<3) | CLK_DIV(AS3525_PCLK_FREQ, AS3525_DBOP_FREQ); |
@@ -146,23 +140,14 @@ static void _display_on(void) | |||
146 | lcd_write_reg(0x07, 0); | 140 | lcd_write_reg(0x07, 0); |
147 | lcd_write_reg(0x13, 0); | 141 | lcd_write_reg(0x13, 0); |
148 | 142 | ||
149 | lcd_delay(10); | ||
150 | |||
151 | lcd_write_reg(0x11, 0x3704); | 143 | lcd_write_reg(0x11, 0x3704); |
152 | lcd_write_reg(0x14, 0x1a1b); | 144 | lcd_write_reg(0x14, 0x1a1b); |
153 | lcd_write_reg(0x10, 0x3860); | 145 | lcd_write_reg(0x10, 0x3860); |
154 | lcd_write_reg(0x13, 0x40); | 146 | lcd_write_reg(0x13, 0x40); |
155 | 147 | ||
156 | lcd_delay(10); | ||
157 | |||
158 | lcd_write_reg(0x13, 0x60); | 148 | lcd_write_reg(0x13, 0x60); |
159 | 149 | ||
160 | lcd_delay(50); | ||
161 | |||
162 | lcd_write_reg(0x13, 0x70); | 150 | lcd_write_reg(0x13, 0x70); |
163 | |||
164 | lcd_delay(40); | ||
165 | |||
166 | lcd_write_reg(0x01, 277); | 151 | lcd_write_reg(0x01, 277); |
167 | lcd_write_reg(0x02, (7<<8)); | 152 | lcd_write_reg(0x02, (7<<8)); |
168 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); | 153 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); |
@@ -190,65 +175,42 @@ static void _display_on(void) | |||
190 | lcd_write_reg(0x48, 0x0); | 175 | lcd_write_reg(0x48, 0x0); |
191 | 176 | ||
192 | lcd_write_reg(0x07, 0x11); | 177 | lcd_write_reg(0x07, 0x11); |
193 | |||
194 | lcd_delay(40); | ||
195 | |||
196 | lcd_write_reg(0x07, 0x17); | 178 | lcd_write_reg(0x07, 0x17); |
197 | 179 | ||
198 | display_on = true; /* must be done before calling lcd_update() */ | 180 | display_on = true; /* must be done before calling lcd_update() */ |
199 | lcd_update(); | 181 | lcd_update(); |
200 | } | 182 | } |
201 | 183 | ||
202 | /* I'm guessing this function is lcd_enable, but it may not be... */ | ||
203 | void lcd_enable(bool on) | 184 | void lcd_enable(bool on) |
204 | { | 185 | { |
205 | int r0 = on; | 186 | if (display_on == on) |
206 | #if 0 | 187 | return; /* nothing to do */ |
207 | r4 = 0x1db12; | 188 | if(on) |
208 | [r4] = 1; | 189 | { |
209 | #endif | 190 | int delay = 0x200000; |
210 | |||
211 | if (r0 != 0) { | ||
212 | lcd_write_reg(0, 1); | 191 | lcd_write_reg(0, 1); |
213 | |||
214 | lcd_delay(10); | ||
215 | |||
216 | lcd_write_reg(0x10, 0); | 192 | lcd_write_reg(0x10, 0); |
217 | lcd_write_reg(0x11, 0x3704); | 193 | lcd_write_reg(0x11, 0x3704); |
218 | lcd_write_reg(0x14, 0x1a1b); | 194 | lcd_write_reg(0x14, 0x1a1b); |
219 | lcd_write_reg(0x10, 0x3860); | 195 | lcd_write_reg(0x10, 0x3860); |
220 | lcd_write_reg(0x13, 0x40); | 196 | lcd_write_reg(0x13, 0x40); |
221 | |||
222 | lcd_delay(10); | ||
223 | |||
224 | lcd_write_reg(0x13, 0x60); | 197 | lcd_write_reg(0x13, 0x60); |
225 | |||
226 | lcd_delay(50); | ||
227 | |||
228 | lcd_write_reg(0x13, 112); | 198 | lcd_write_reg(0x13, 112); |
229 | |||
230 | lcd_delay(40); | ||
231 | |||
232 | lcd_write_reg(0x07, 0x11); | 199 | lcd_write_reg(0x07, 0x11); |
233 | |||
234 | lcd_delay(40); | ||
235 | |||
236 | lcd_write_reg(0x07, 0x17); | 200 | lcd_write_reg(0x07, 0x17); |
237 | } else { | 201 | display_on = true; |
202 | /* a bit of delay before returning to | ||
203 | * avoid irritating flash on backlight on */ | ||
204 | while(delay--); | ||
205 | |||
206 | } | ||
207 | else | ||
208 | { | ||
238 | lcd_write_reg(0x07, 0x22); | 209 | lcd_write_reg(0x07, 0x22); |
239 | |||
240 | lcd_delay(40); | ||
241 | |||
242 | lcd_write_reg(0x07, 0); | 210 | lcd_write_reg(0x07, 0); |
243 | |||
244 | lcd_delay(40); | ||
245 | |||
246 | lcd_write_reg(0x10, 1); | 211 | lcd_write_reg(0x10, 1); |
212 | display_on = false; | ||
247 | } | 213 | } |
248 | |||
249 | #if 0 | ||
250 | [r4] = 0; | ||
251 | #endif | ||
252 | } | 214 | } |
253 | 215 | ||
254 | bool lcd_enabled(void) | 216 | bool lcd_enabled(void) |
@@ -285,26 +247,13 @@ void lcd_init_device() | |||
285 | { | 247 | { |
286 | as3525_dbop_init(); | 248 | as3525_dbop_init(); |
287 | 249 | ||
288 | GPIOA_DIR |= (1<<5); | 250 | GPIOA_DIR |= (1<<7|1<<5|1<<4|1<<3); |
289 | GPIOA_PIN(5) = 0; | 251 | GPIOA_PIN(5) = 0; |
290 | |||
291 | GPIOA_PIN(3) = (1<<3); | 252 | GPIOA_PIN(3) = (1<<3); |
292 | |||
293 | GPIOA_DIR |= (1<<4) | (1<<3); | ||
294 | |||
295 | GPIOA_PIN(3) = (1<<3); | ||
296 | |||
297 | GPIOA_PIN(4) = 0; | 253 | GPIOA_PIN(4) = 0; |
298 | |||
299 | GPIOA_DIR |= (1<<7); | ||
300 | GPIOA_PIN(7) = 0; | 254 | GPIOA_PIN(7) = 0; |
301 | |||
302 | lcd_delay(1); | ||
303 | |||
304 | GPIOA_PIN(5) = (1<<5); | 255 | GPIOA_PIN(5) = (1<<5); |
305 | 256 | ||
306 | lcd_delay(1); | ||
307 | |||
308 | _display_on(); | 257 | _display_on(); |
309 | } | 258 | } |
310 | 259 | ||
@@ -324,6 +273,7 @@ static void lcd_window_y(int ymin, int ymax) | |||
324 | lcd_write_reg(0x47, ymax); | 273 | lcd_write_reg(0x47, ymax); |
325 | lcd_write_reg(0x48, ymin); | 274 | lcd_write_reg(0x48, ymin); |
326 | lcd_write_reg(0x21, ymin); | 275 | lcd_write_reg(0x21, ymin); |
276 | lcd_write_cmd(0x22); | ||
327 | } | 277 | } |
328 | 278 | ||
329 | /* Update the display. | 279 | /* Update the display. |
@@ -354,7 +304,7 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
354 | if (!display_on) | 304 | if (!display_on) |
355 | return; | 305 | return; |
356 | 306 | ||
357 | xmax = x + width - 1; | 307 | xmax = x + width; |
358 | if (xmax >= LCD_WIDTH) | 308 | if (xmax >= LCD_WIDTH) |
359 | xmax = LCD_WIDTH - 1; /* Clip right */ | 309 | xmax = LCD_WIDTH - 1; /* Clip right */ |
360 | if (x < 0) | 310 | if (x < 0) |
@@ -364,8 +314,8 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
364 | 314 | ||
365 | width = xmax - x + 1; /* Fix width */ | 315 | width = xmax - x + 1; /* Fix width */ |
366 | 316 | ||
367 | ymax = y + height - 1; | 317 | ymax = y + height; |
368 | if (ymax > LCD_HEIGHT) | 318 | if (ymax >= LCD_HEIGHT) |
369 | ymax = LCD_HEIGHT - 1; /* Clip bottom */ | 319 | ymax = LCD_HEIGHT - 1; /* Clip bottom */ |
370 | if (y < 0) | 320 | if (y < 0) |
371 | y = 0; /* Clip top */ | 321 | y = 0; /* Clip top */ |
@@ -387,5 +337,5 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
387 | lcd_write_data(ptr, width); | 337 | lcd_write_data(ptr, width); |
388 | ptr += LCD_WIDTH; | 338 | ptr += LCD_WIDTH; |
389 | } | 339 | } |
390 | while (++y < ymax); | 340 | while (++y <= ymax); |
391 | } | 341 | } |