diff options
Diffstat (limited to 'firmware/target/arm/as3525/sansa-e200v2')
-rw-r--r-- | firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c | 59 |
1 files changed, 11 insertions, 48 deletions
diff --git a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c index 089a5da24c..5a4c58f5b3 100644 --- a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c +++ b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c | |||
@@ -75,15 +75,9 @@ static bool display_on = false; /* is the display turned on? */ | |||
75 | #define R_HORIZ_RAM_ADDR_POS 0x44 | 75 | #define R_HORIZ_RAM_ADDR_POS 0x44 |
76 | #define R_VERT_RAM_ADDR_POS 0x45 | 76 | #define R_VERT_RAM_ADDR_POS 0x45 |
77 | 77 | ||
78 | /* Flip Flag */ | ||
79 | #define R_ENTRY_MODE_HORZ_NORMAL 0x7030 | 78 | #define R_ENTRY_MODE_HORZ_NORMAL 0x7030 |
80 | #define R_ENTRY_MODE_HORZ_FLIPPED 0x7000 | ||
81 | static unsigned short r_entry_mode = R_ENTRY_MODE_HORZ_NORMAL; | ||
82 | #define R_ENTRY_MODE_VERT 0x7038 | 79 | #define R_ENTRY_MODE_VERT 0x7038 |
83 | #define R_ENTRY_MODE_SOLID_VERT 0x1038 | 80 | #define R_ENTRY_MODE_SOLID_VERT 0x1038 |
84 | #define R_ENTRY_MODE_VIDEO_NORMAL 0x7020 | ||
85 | #define R_ENTRY_MODE_VIDEO_FLIPPED 0x7010 | ||
86 | |||
87 | 81 | ||
88 | /* Reverse Flag */ | 82 | /* Reverse Flag */ |
89 | #define R_DISP_CONTROL_NORMAL 0x0004 | 83 | #define R_DISP_CONTROL_NORMAL 0x0004 |
@@ -164,34 +158,17 @@ void lcd_set_invert_display(bool yesno) | |||
164 | 158 | ||
165 | } | 159 | } |
166 | 160 | ||
167 | static bool display_flipped = false; | ||
168 | |||
169 | /* turn the display upside down */ | 161 | /* turn the display upside down */ |
170 | void lcd_set_flip(bool yesno) | 162 | void lcd_set_flip(bool yesno) |
171 | { | 163 | { |
172 | display_flipped = yesno; | 164 | lcd_write_reg(R_DRV_OUTPUT_CONTROL, yesno ? 0x21b : 0x11b); |
173 | |||
174 | r_entry_mode = yesno ? R_ENTRY_MODE_HORZ_FLIPPED : | ||
175 | R_ENTRY_MODE_HORZ_NORMAL; | ||
176 | } | 165 | } |
177 | 166 | ||
178 | static void lcd_window(int xmin, int ymin, int xmax, int ymax) | 167 | static void lcd_window(int xmin, int ymin, int xmax, int ymax) |
179 | { | 168 | { |
180 | if (!display_flipped) | 169 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin); |
181 | { | 170 | lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin); |
182 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin); | 171 | lcd_write_reg(R_RAM_ADDR_SET, (ymin << 8) | xmin); |
183 | lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin); | ||
184 | lcd_write_reg(R_RAM_ADDR_SET, (ymin << 8) | xmin); | ||
185 | } | ||
186 | else | ||
187 | { | ||
188 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, | ||
189 | ((LCD_WIDTH-1 - xmin) << 8) | (LCD_WIDTH-1 - xmax)); | ||
190 | lcd_write_reg(R_VERT_RAM_ADDR_POS, | ||
191 | ((LCD_HEIGHT-1 - ymin) << 8) | (LCD_HEIGHT-1 - ymax)); | ||
192 | lcd_write_reg(R_RAM_ADDR_SET, | ||
193 | ((LCD_HEIGHT-1 - ymin) << 8) | (LCD_WIDTH-1 - xmin)); | ||
194 | } | ||
195 | } | 172 | } |
196 | 173 | ||
197 | static void _display_on(void) | 174 | static void _display_on(void) |
@@ -211,7 +188,7 @@ static void _display_on(void) | |||
211 | /* Address counter updated in horizontal direction; left to right; | 188 | /* Address counter updated in horizontal direction; left to right; |
212 | * vertical increment horizontal increment. | 189 | * vertical increment horizontal increment. |
213 | * data format for 8bit transfer or spi = 65k (5,6,5) */ | 190 | * data format for 8bit transfer or spi = 65k (5,6,5) */ |
214 | lcd_write_reg(R_ENTRY_MODE, r_entry_mode); | 191 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ_NORMAL); |
215 | 192 | ||
216 | /* Replace data on writing to GRAM */ | 193 | /* Replace data on writing to GRAM */ |
217 | lcd_write_reg(R_COMPARE_REG1, 0); | 194 | lcd_write_reg(R_COMPARE_REG1, 0); |
@@ -352,20 +329,10 @@ void lcd_yuv_set_options(unsigned options) | |||
352 | #ifndef BOOTLOADER | 329 | #ifndef BOOTLOADER |
353 | static void lcd_window_blit(int xmin, int ymin, int xmax, int ymax) | 330 | static void lcd_window_blit(int xmin, int ymin, int xmax, int ymax) |
354 | { | 331 | { |
355 | if (!display_flipped) | 332 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, |
356 | { | 333 | ((LCD_WIDTH-1 - xmin) << 8) | (LCD_WIDTH-1 - xmax)); |
357 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, | 334 | lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin); |
358 | ((LCD_WIDTH-1 - xmin) << 8) | (LCD_WIDTH-1 - xmax)); | 335 | lcd_write_reg(R_RAM_ADDR_SET, (ymin << 8) | (LCD_WIDTH-1 - xmin)); |
359 | lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin); | ||
360 | lcd_write_reg(R_RAM_ADDR_SET, | ||
361 | (ymin << 8) | (LCD_WIDTH-1 - xmin)); | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin); | ||
366 | lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin); | ||
367 | lcd_write_reg(R_RAM_ADDR_SET, (ymax << 8) | xmin); | ||
368 | } | ||
369 | } | 336 | } |
370 | 337 | ||
371 | /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ | 338 | /* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */ |
@@ -398,10 +365,6 @@ void lcd_blit_yuv(unsigned char * const src[3], | |||
398 | yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); | 365 | yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1); |
399 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); | 366 | yuv_src[2] = src[2] + (yuv_src[1] - src[1]); |
400 | 367 | ||
401 | lcd_write_reg(R_ENTRY_MODE, | ||
402 | display_flipped ? R_ENTRY_MODE_VIDEO_FLIPPED : R_ENTRY_MODE_VIDEO_NORMAL | ||
403 | ); | ||
404 | |||
405 | if (lcd_yuv_options & LCD_YUV_DITHER) | 368 | if (lcd_yuv_options & LCD_YUV_DITHER) |
406 | { | 369 | { |
407 | do | 370 | do |
@@ -446,7 +409,7 @@ void lcd_update(void) | |||
446 | if (!display_on) | 409 | if (!display_on) |
447 | return; | 410 | return; |
448 | 411 | ||
449 | lcd_write_reg(R_ENTRY_MODE, r_entry_mode); | 412 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ_NORMAL); |
450 | 413 | ||
451 | /* Set start position and window */ | 414 | /* Set start position and window */ |
452 | lcd_window(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1); | 415 | lcd_window(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1); |
@@ -484,7 +447,7 @@ void lcd_update_rect(int x, int y, int width, int height) | |||
484 | if (y + height > LCD_HEIGHT) | 447 | if (y + height > LCD_HEIGHT) |
485 | height = LCD_HEIGHT - y; /* clip bottom */ | 448 | height = LCD_HEIGHT - y; /* clip bottom */ |
486 | 449 | ||
487 | lcd_write_reg(R_ENTRY_MODE, r_entry_mode); | 450 | lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ_NORMAL); |
488 | 451 | ||
489 | /* we need to make x and width even to enable 32bit transfers */ | 452 | /* we need to make x and width even to enable 32bit transfers */ |
490 | width = (width + (x & 1) + 1) & ~1; | 453 | width = (width + (x & 1) + 1) & ~1; |