summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2009-02-19 20:40:00 +0000
committerThomas Martitz <kugel@rockbox.org>2009-02-19 20:40:00 +0000
commit1ad58f9757de11248e74ca52c3288e177ac2760b (patch)
tree93f632c26f23ca60840ac012e976ad279f8765b9
parent807fd0d36362ebcd785ae82fbd98493d4b68f29b (diff)
downloadrockbox-1ad58f9757de11248e74ca52c3288e177ac2760b.tar.gz
rockbox-1ad58f9757de11248e74ca52c3288e177ac2760b.zip
Sansa e200v2: Some LCD driver changes (none with functional changes):
1) put window addressing in a seperate function like on the fuze 2) use fb_data instead of unsigned short 3) change clipping a bit git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20051 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c65
1 files changed, 32 insertions, 33 deletions
diff --git a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
index 379869f2b4..a9bbc1b41b 100644
--- a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
+++ b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
@@ -145,7 +145,7 @@ void lcd_write_data(const fb_data* p_bytes, int count)
145 145
146static void lcd_write_reg(int reg, int value) 146static void lcd_write_reg(int reg, int value)
147{ 147{
148 unsigned short data = value; 148 fb_data data = value;
149 149
150 lcd_write_cmd(reg); 150 lcd_write_cmd(reg);
151 lcd_write_data(&data, 1); 151 lcd_write_data(&data, 1);
@@ -363,6 +363,18 @@ void lcd_blit_yuv(unsigned char * const src[3],
363 (void)height; 363 (void)height;
364} 364}
365 365
366static void lcd_window_x(int xmin, int xmax)
367{
368 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin);
369}
370
371static void lcd_window_y(int ymin, int ymax)
372{
373 ymin += y_offset;
374 ymax += y_offset;
375 lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin);
376 lcd_write_reg(R_RAM_ADDR_SET, ymin << 8);
377}
366/* Update the display. 378/* Update the display.
367 This must be called after all other LCD functions that change the display. */ 379 This must be called after all other LCD functions that change the display. */
368void lcd_update(void) 380void lcd_update(void)
@@ -374,14 +386,12 @@ void lcd_update(void)
374 386
375 lcd_busy = true; 387 lcd_busy = true;
376 /* Set start position and window */ 388 /* Set start position and window */
377 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (LCD_WIDTH-1) << 8); 389 lcd_window_x(0, LCD_WIDTH-1);
378 lcd_write_reg(R_VERT_RAM_ADDR_POS, 390 lcd_window_x(0, LCD_HEIGHT-1);
379 ((y_offset + LCD_HEIGHT-1) << 8) | y_offset);
380 lcd_write_reg(R_RAM_ADDR_SET, (y_offset) << 8);
381 391
382 lcd_write_cmd(R_WRITE_DATA_2_GRAM); 392 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
383 393
384 lcd_write_data((unsigned short *)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT); 394 lcd_write_data((fb_data*)lcd_framebuffer, LCD_WIDTH*LCD_HEIGHT);
385 395
386 lcd_busy = false; 396 lcd_busy = false;
387} /* lcd_update */ 397} /* lcd_update */
@@ -390,46 +400,42 @@ void lcd_update(void)
390/* Update a fraction of the display. */ 400/* Update a fraction of the display. */
391void lcd_update_rect(int x, int y, int width, int height) 401void lcd_update_rect(int x, int y, int width, int height)
392{ 402{
403 const fb_data *ptr;
393 int ymax; 404 int ymax;
394 const unsigned short *ptr;
395 405
396 if (!display_on) 406 if (!display_on)
397 return; 407 return;
398 408
399 if (x + width > LCD_WIDTH) 409 if (x + width >= LCD_WIDTH)
400 width = LCD_WIDTH - x; /* Clip right */ 410 width = LCD_WIDTH - x -1; /* Clip right */
401 if (x < 0) 411 if (x < 0)
402 width += x, x = 0; /* Clip left */ 412 width += x, x = 0; /* Clip left */
403 if (width <= 0) 413 if (width <= 0)
404 return; /* nothing left to do */ 414 return; /* nothing left to do */
405 415
406 ymax = y + height; 416 if (y + height >= LCD_HEIGHT)
407 if (ymax > LCD_HEIGHT) 417 height = LCD_HEIGHT - y - 1; /* Clip bottom */
408 ymax = LCD_HEIGHT; /* Clip bottom */
409 if (y < 0) 418 if (y < 0)
410 y = 0; /* Clip top */ 419 height += y; y = 0; /* Clip top */
411 if (y >= ymax) 420 if (height <= 0)
412 return; /* nothing left to do */ 421 return; /* nothing left to do */
413 422
423 ymax = y+height;
414 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); 424 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
415 lcd_busy = true; 425 lcd_busy = true;
416 /* Set start position and window */
417 lcd_write_reg(R_HORIZ_RAM_ADDR_POS,
418 ((x + width-1) << 8) | x);
419 lcd_write_reg(R_VERT_RAM_ADDR_POS,
420 ((y_offset + y + height - 1) << 8) | (y_offset + y));
421 lcd_write_reg(R_RAM_ADDR_SET, ((y + y_offset) << 8) | x);
422 426
423 lcd_write_cmd(R_WRITE_DATA_2_GRAM); 427 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
428 lcd_window_x(x, x + width);
429 lcd_window_y(y, ymax);
424 430
425 ptr = (unsigned short *)&lcd_framebuffer[y][x]; 431 ptr = &lcd_framebuffer[y][x];
426 432
427 do 433 do
428 { 434 {
429 lcd_write_data(ptr, width); 435 lcd_write_data(ptr, width);
430 ptr += LCD_WIDTH; 436 ptr += LCD_WIDTH;
431 } 437 }
432 while (++y < ymax); 438 while (++y <= ymax);
433 439
434 lcd_busy = false; 440 lcd_busy = false;
435} /* lcd_update_rect */ 441} /* lcd_update_rect */
@@ -437,25 +443,18 @@ void lcd_update_rect(int x, int y, int width, int height)
437/* writes one read pixel outside the visible area, needed for correct dbop reads */ 443/* writes one read pixel outside the visible area, needed for correct dbop reads */
438bool lcd_button_support(void) 444bool lcd_button_support(void)
439{ 445{
440 int x=LCD_HEIGHT+1; 446 fb_data data = (0xf<<12);
441 int y=LCD_WIDTH+1;
442 int width=1;
443 int height=1;
444 unsigned short data = (0xf<<12);
445 447
446 if (lcd_busy) 448 if (lcd_busy)
447 return false; 449 return false;
448 450
449 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); 451 lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ);
450 /* Set start position and window */ 452 /* Set start position and window */
451 lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 453 lcd_window_x(LCD_WIDTH+1, 1);
452 ((x + width-1) << 8) | x); 454 lcd_window_y(LCD_HEIGHT+1, 1);
453 lcd_write_reg(R_VERT_RAM_ADDR_POS,
454 ((y_offset + y + height - 1) << 8) | (y_offset + y));
455 lcd_write_reg(R_RAM_ADDR_SET, ((y + y_offset) << 8) | x);
456 455
457 lcd_write_cmd(R_WRITE_DATA_2_GRAM); 456 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
458 457
459 lcd_write_data(&data, width); 458 lcd_write_data(&data, 1);
460 return true; 459 return true;
461} 460}