diff options
-rw-r--r-- | firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c index a9bbc1b41b..57d5649570 100644 --- a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c +++ b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c | |||
@@ -179,6 +179,15 @@ void lcd_set_flip(bool yesno) | |||
179 | flip_lcd(yesno); | 179 | flip_lcd(yesno); |
180 | } | 180 | } |
181 | 181 | ||
182 | static void lcd_window(int xmin, int ymin, int xmax, int ymax) | ||
183 | { | ||
184 | ymin += y_offset; | ||
185 | ymax += y_offset; | ||
186 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin); | ||
187 | lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin); | ||
188 | lcd_write_reg(R_RAM_ADDR_SET, (ymin << 8) | xmin); | ||
189 | } | ||
190 | |||
182 | static void _display_on(void) | 191 | static void _display_on(void) |
183 | { | 192 | { |
184 | /* Initialisation the display the same way as the original firmware */ | 193 | /* Initialisation the display the same way as the original firmware */ |
@@ -269,16 +278,12 @@ static void _display_on(void) | |||
269 | lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x0f08); | 278 | lcd_write_reg(R_GAMMA_AMP_AVG_ADJ_RES_NEG, 0x0f08); |
270 | 279 | ||
271 | 280 | ||
272 | lcd_write_reg(R_RAM_ADDR_SET, 0); | ||
273 | lcd_write_reg(R_GATE_SCAN_POS, 0); | 281 | lcd_write_reg(R_GATE_SCAN_POS, 0); |
274 | lcd_write_reg(R_VERT_SCROLL_CONTROL, 0); | 282 | lcd_write_reg(R_VERT_SCROLL_CONTROL, 0); |
275 | |||
276 | lcd_write_reg(R_1ST_SCR_DRV_POS, 219 << 8); | ||
277 | lcd_write_reg(R_2ND_SCR_DRV_POS, 219 << 8); | ||
278 | |||
279 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, 175 << 8); | ||
280 | lcd_write_reg(R_VERT_RAM_ADDR_POS, 219 << 8); | ||
281 | 283 | ||
284 | lcd_window(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1); | ||
285 | lcd_write_reg(R_1ST_SCR_DRV_POS, (LCD_HEIGHT-1) << 8); | ||
286 | lcd_write_reg(R_2ND_SCR_DRV_POS, (LCD_HEIGHT-1) << 8); | ||
282 | 287 | ||
283 | lcd_write_reg(R_DISP_CONTROL1, 0x0037); | 288 | lcd_write_reg(R_DISP_CONTROL1, 0x0037); |
284 | 289 | ||
@@ -363,18 +368,6 @@ void lcd_blit_yuv(unsigned char * const src[3], | |||
363 | (void)height; | 368 | (void)height; |
364 | } | 369 | } |
365 | 370 | ||
366 | static void lcd_window_x(int xmin, int xmax) | ||
367 | { | ||
368 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin); | ||
369 | } | ||
370 | |||
371 | static 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 | } | ||
378 | /* Update the display. | 371 | /* Update the display. |
379 | This must be called after all other LCD functions that change the display. */ | 372 | This must be called after all other LCD functions that change the display. */ |
380 | void lcd_update(void) | 373 | void lcd_update(void) |
@@ -386,8 +379,7 @@ void lcd_update(void) | |||
386 | 379 | ||
387 | lcd_busy = true; | 380 | lcd_busy = true; |
388 | /* Set start position and window */ | 381 | /* Set start position and window */ |
389 | lcd_window_x(0, LCD_WIDTH-1); | 382 | lcd_window(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1); |
390 | lcd_window_x(0, LCD_HEIGHT-1); | ||
391 | 383 | ||
392 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | 384 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); |
393 | 385 | ||
@@ -401,34 +393,36 @@ void lcd_update(void) | |||
401 | void lcd_update_rect(int x, int y, int width, int height) | 393 | void lcd_update_rect(int x, int y, int width, int height) |
402 | { | 394 | { |
403 | const fb_data *ptr; | 395 | const fb_data *ptr; |
404 | int ymax; | 396 | int ymax, xmax; |
397 | |||
405 | 398 | ||
406 | if (!display_on) | 399 | if (!display_on) |
407 | return; | 400 | return; |
408 | 401 | ||
409 | if (x + width >= LCD_WIDTH) | 402 | xmax = x + width; |
410 | width = LCD_WIDTH - x -1; /* Clip right */ | 403 | if (xmax >= LCD_WIDTH) |
404 | xmax = LCD_WIDTH - 1; /* Clip right */ | ||
411 | if (x < 0) | 405 | if (x < 0) |
412 | width += x, x = 0; /* Clip left */ | 406 | x = 0; /* Clip left */ |
413 | if (width <= 0) | 407 | if (x >= xmax) |
414 | return; /* nothing left to do */ | 408 | return; /* nothing left to do */ |
415 | 409 | ||
416 | if (y + height >= LCD_HEIGHT) | 410 | width = xmax - x + 1; /* Fix width */ |
417 | height = LCD_HEIGHT - y - 1; /* Clip bottom */ | 411 | |
412 | ymax = y + height; | ||
413 | if (ymax >= LCD_HEIGHT) | ||
414 | ymax = LCD_HEIGHT - 1; /* Clip bottom */ | ||
418 | if (y < 0) | 415 | if (y < 0) |
419 | height += y; y = 0; /* Clip top */ | 416 | y = 0; /* Clip top */ |
420 | if (height <= 0) | 417 | if (y >= ymax) |
421 | return; /* nothing left to do */ | 418 | return; /* nothing left to do */ |
422 | 419 | ||
423 | ymax = y+height; | ||
424 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); | 420 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); |
425 | lcd_busy = true; | 421 | lcd_busy = true; |
426 | 422 | lcd_window(x, y, xmax, ymax); | |
427 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | 423 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); |
428 | lcd_window_x(x, x + width); | ||
429 | lcd_window_y(y, ymax); | ||
430 | 424 | ||
431 | ptr = &lcd_framebuffer[y][x]; | 425 | ptr = (fb_data*)&lcd_framebuffer[y][x]; |
432 | 426 | ||
433 | do | 427 | do |
434 | { | 428 | { |
@@ -450,8 +444,7 @@ bool lcd_button_support(void) | |||
450 | 444 | ||
451 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); | 445 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ); |
452 | /* Set start position and window */ | 446 | /* Set start position and window */ |
453 | lcd_window_x(LCD_WIDTH+1, 1); | 447 | lcd_window(LCD_WIDTH+1, LCD_HEIGHT+1, LCD_WIDTH+2, LCD_HEIGHT+2); |
454 | lcd_window_y(LCD_HEIGHT+1, 1); | ||
455 | 448 | ||
456 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); | 449 | lcd_write_cmd(R_WRITE_DATA_2_GRAM); |
457 | 450 | ||