diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c')
-rw-r--r-- | firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c | 169 |
1 files changed, 43 insertions, 126 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c index ff62949dcd..36006beffb 100644 --- a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c +++ b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c | |||
@@ -25,6 +25,16 @@ | |||
25 | #include "cpu.h" | 25 | #include "cpu.h" |
26 | #include "lcd.h" | 26 | #include "lcd.h" |
27 | 27 | ||
28 | /* The controller is unknown, but some registers appear to be the same as the | ||
29 | HD66789R */ | ||
30 | |||
31 | #define R_ENTRY_MODE 0x03 | ||
32 | #define R_RAM_ADDR_SET 0x21 | ||
33 | #define R_WRITE_DATA_2_GRAM 0x22 | ||
34 | |||
35 | #define R_ENTRY_MODE_HORZ 0x7030 | ||
36 | |||
37 | |||
28 | static bool display_on = false; /* is the display turned on? */ | 38 | static bool display_on = false; /* is the display turned on? */ |
29 | static bool display_flipped = false; | 39 | static bool display_flipped = false; |
30 | static int xoffset = 20; /* needed for flip */ | 40 | static int xoffset = 20; /* needed for flip */ |
@@ -154,7 +164,7 @@ static void _display_on(void) | |||
154 | 164 | ||
155 | lcd_write_reg(0x01, 277); | 165 | lcd_write_reg(0x01, 277); |
156 | lcd_write_reg(0x02, (7<<8)); | 166 | lcd_write_reg(0x02, (7<<8)); |
157 | lcd_write_reg(0x03, 0x30); | 167 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); |
158 | lcd_write_reg(0x08, 0x01); | 168 | lcd_write_reg(0x08, 0x01); |
159 | lcd_write_reg(0x0b, (1<<10)); | 169 | lcd_write_reg(0x0b, (1<<10)); |
160 | lcd_write_reg(0x0c, 0); | 170 | lcd_write_reg(0x0c, 0); |
@@ -188,120 +198,6 @@ static void _display_on(void) | |||
188 | lcd_update(); | 198 | lcd_update(); |
189 | } | 199 | } |
190 | 200 | ||
191 | /* (e.g. 0, 219) */ | ||
192 | static void lcd_window_x(int r0, int r1) | ||
193 | { | ||
194 | int r2, r3, r4; | ||
195 | |||
196 | r3 = (LCD_WIDTH - 1); | ||
197 | r2 = (LCD_WIDTH - 1); | ||
198 | |||
199 | if (r0 < LCD_WIDTH) | ||
200 | r2 = r0; | ||
201 | |||
202 | if (r1 < LCD_WIDTH) | ||
203 | r3 = r1; | ||
204 | |||
205 | #if 0 | ||
206 | r1 = 0x1db12; | ||
207 | |||
208 | [r1] = 1; /* byte */ | ||
209 | #endif | ||
210 | |||
211 | r3 += xoffset; | ||
212 | |||
213 | r4 = r2; | ||
214 | |||
215 | r4 += xoffset; | ||
216 | |||
217 | r0 = (r3 << 8); | ||
218 | |||
219 | r0 |= r4; | ||
220 | |||
221 | r1 = (r0 << 16) >> 16; | ||
222 | |||
223 | lcd_write_reg(0x46, r1); | ||
224 | |||
225 | r1 = (r4 << 16) >> 16; | ||
226 | |||
227 | lcd_write_reg(0x20, r1); | ||
228 | |||
229 | lcd_write_reg(0x03, 0x30); | ||
230 | |||
231 | #if 0 | ||
232 | r0 := 0x1e0c4 | ||
233 | r1 := 0x216a8 | ||
234 | |||
235 | r0 := [r0] | ||
236 | r2 := [r1] | ||
237 | |||
238 | r0 := (r0 >> 2) << 2; | ||
239 | |||
240 | if (r0 != r2) { | ||
241 | #endif | ||
242 | lcd_write_reg(0x00, 0x0001); | ||
243 | lcd_write_reg(0x11, 0x3704); | ||
244 | lcd_write_reg(0x14, 0x1a1b); | ||
245 | lcd_write_reg(0x10, 0x3860); | ||
246 | lcd_write_reg(0x13, 0x0070); | ||
247 | lcd_write_reg(0x07, 0x0017); | ||
248 | lcd_write_reg(0x01, 277); | ||
249 | lcd_write_reg(0x02, (7<<8)); | ||
250 | lcd_write_reg(0x08, 0x0001); | ||
251 | lcd_write_reg(0x0b, (1<<10)); | ||
252 | lcd_write_reg(0x0c, 0x0000); | ||
253 | lcd_write_reg(0x30, 0x0040); | ||
254 | lcd_write_reg(0x31, 0x0687); | ||
255 | lcd_write_reg(0x32, 0x0306); | ||
256 | lcd_write_reg(0x33, 260); | ||
257 | lcd_write_reg(0x34, 0x0585); | ||
258 | lcd_write_reg(0x35, 255+66); | ||
259 | lcd_write_reg(0x36, 0x687+128); | ||
260 | lcd_write_reg(0x37, 259); | ||
261 | lcd_write_reg(0x38, 0); | ||
262 | lcd_write_reg(0x39, 0); | ||
263 | lcd_write_reg(0x40, 0); | ||
264 | lcd_write_reg(0x41, 0); | ||
265 | lcd_write_reg(0x42, (LCD_WIDTH - 1)); | ||
266 | lcd_write_reg(0x43, 0); | ||
267 | lcd_write_reg(0x44, (LCD_WIDTH - 1)); | ||
268 | lcd_write_reg(0x45, 0); | ||
269 | lcd_write_reg(0x15, 0); | ||
270 | lcd_write_reg(0x73, 0); | ||
271 | #if 0 | ||
272 | } | ||
273 | #endif | ||
274 | } | ||
275 | |||
276 | /* - e.g. 0, 175 */ | ||
277 | static void lcd_window_y(int r0, int r1) | ||
278 | { | ||
279 | int r2, r4; | ||
280 | |||
281 | r2 = (LCD_HEIGHT - 1); | ||
282 | r4 = (LCD_HEIGHT - 1); | ||
283 | |||
284 | if (r0 < LCD_HEIGHT) | ||
285 | r4 = r0; | ||
286 | |||
287 | if (r1 < LCD_HEIGHT) | ||
288 | r2 = r1; | ||
289 | |||
290 | r1 = (r2 << 16) >> 16; | ||
291 | |||
292 | lcd_write_reg(0x47, r1); | ||
293 | |||
294 | r1 = (r4 << 16) >> 16; | ||
295 | |||
296 | lcd_write_reg(0x48, r1); | ||
297 | |||
298 | /* ??Start address - (x<<8) | y0 */ | ||
299 | lcd_write_reg(0x21, r1); | ||
300 | |||
301 | /* Start write to GRAM */ | ||
302 | lcd_write_cmd(0x22); | ||
303 | } | ||
304 | |||
305 | /* I'm guessing this function is lcd_enable, but it may not be... */ | 201 | /* I'm guessing this function is lcd_enable, but it may not be... */ |
306 | void lcd_enable(int r0) | 202 | void lcd_enable(int r0) |
307 | { | 203 | { |
@@ -376,13 +272,6 @@ void lcd_init_device() | |||
376 | 272 | ||
377 | GPIOD_DIR |= (1<<7); | 273 | GPIOD_DIR |= (1<<7); |
378 | 274 | ||
379 | #if 0 | ||
380 | if (byte[0x21b24] == 0) { | ||
381 | GPIOD_PIN(7) = (1<<7); | ||
382 | GPIOD_DIR |= (1<<7); | ||
383 | } | ||
384 | #endif | ||
385 | |||
386 | lcd_delay(1); | 275 | lcd_delay(1); |
387 | 276 | ||
388 | GPIOA_PIN(5) = (1<<5); | 277 | GPIOA_PIN(5) = (1<<5); |
@@ -392,6 +281,24 @@ void lcd_init_device() | |||
392 | _display_on(); | 281 | _display_on(); |
393 | } | 282 | } |
394 | 283 | ||
284 | /* Set horizontal window addresses */ | ||
285 | static void lcd_window_x(int xmin, int xmax) | ||
286 | { | ||
287 | xmin += xoffset; | ||
288 | xmax += xoffset; | ||
289 | |||
290 | lcd_write_reg(0x46, (xmax << 8) | xmin); | ||
291 | lcd_write_reg(0x20, xmin); | ||
292 | } | ||
293 | |||
294 | /* Set vertical window addresses */ | ||
295 | static void lcd_window_y(int ymin, int ymax) | ||
296 | { | ||
297 | lcd_write_reg(0x47, ymax); | ||
298 | lcd_write_reg(0x48, ymin); | ||
299 | lcd_write_reg(0x21, ymin); | ||
300 | } | ||
301 | |||
395 | /* Update the display. | 302 | /* Update the display. |
396 | This must be called after all other LCD functions that change the display. */ | 303 | This must be called after all other LCD functions that change the display. */ |
397 | void lcd_update(void) | 304 | void lcd_update(void) |
@@ -399,12 +306,16 @@ void lcd_update(void) | |||
399 | if (!display_on) | 306 | if (!display_on) |
400 | return; | 307 | return; |
401 | 308 | ||
402 | lcd_window_x(0, (LCD_WIDTH - 1)); | 309 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); |
403 | 310 | ||
404 | lcd_window_y(0, (LCD_HEIGHT - 1)); | 311 | lcd_window_x(0, LCD_WIDTH - 1); |
312 | lcd_window_y(0, LCD_HEIGHT - 1); | ||
405 | 313 | ||
406 | lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT); | 314 | /* Start write to GRAM */ |
315 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
407 | 316 | ||
317 | /* Write data */ | ||
318 | lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT); | ||
408 | } | 319 | } |
409 | 320 | ||
410 | /* Update a fraction of the display. */ | 321 | /* Update a fraction of the display. */ |
@@ -424,7 +335,9 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
424 | if (x >= xmax) | 335 | if (x >= xmax) |
425 | return; /* nothing left to do */ | 336 | return; /* nothing left to do */ |
426 | 337 | ||
427 | ymax = y + height; | 338 | width = xmax - x + 1; /* Fix width */ |
339 | |||
340 | ymax = y + height - 1; | ||
428 | if (ymax > LCD_HEIGHT) | 341 | if (ymax > LCD_HEIGHT) |
429 | ymax = LCD_HEIGHT - 1; /* Clip bottom */ | 342 | ymax = LCD_HEIGHT - 1; /* Clip bottom */ |
430 | if (y < 0) | 343 | if (y < 0) |
@@ -432,10 +345,14 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
432 | if (y >= ymax) | 345 | if (y >= ymax) |
433 | return; /* nothing left to do */ | 346 | return; /* nothing left to do */ |
434 | 347 | ||
348 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); | ||
435 | 349 | ||
436 | lcd_window_x(x, xmax); | 350 | lcd_window_x(x, xmax); |
437 | lcd_window_y(y, ymax); | 351 | lcd_window_y(y, ymax); |
438 | 352 | ||
353 | /* Start write to GRAM */ | ||
354 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | ||
355 | |||
439 | ptr = (unsigned short *)&lcd_framebuffer[y][x]; | 356 | ptr = (unsigned short *)&lcd_framebuffer[y][x]; |
440 | 357 | ||
441 | do | 358 | do |