summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c')
-rw-r--r--firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c59
1 files changed, 48 insertions, 11 deletions
diff --git a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
index 5a4c58f5b3..089a5da24c 100644
--- a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
+++ b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c
@@ -75,9 +75,15 @@ static bool display_on = false; /* is the display turned on? */
#define R_HORIZ_RAM_ADDR_POS 0x44
#define R_VERT_RAM_ADDR_POS 0x45
+/* Flip Flag */
#define R_ENTRY_MODE_HORZ_NORMAL 0x7030
+#define R_ENTRY_MODE_HORZ_FLIPPED 0x7000
+static unsigned short r_entry_mode = R_ENTRY_MODE_HORZ_NORMAL;
#define R_ENTRY_MODE_VERT 0x7038
#define R_ENTRY_MODE_SOLID_VERT 0x1038
+#define R_ENTRY_MODE_VIDEO_NORMAL 0x7020
+#define R_ENTRY_MODE_VIDEO_FLIPPED 0x7010
+
/* Reverse Flag */
#define R_DISP_CONTROL_NORMAL 0x0004
@@ -158,17 +164,34 @@ void lcd_set_invert_display(bool yesno)
}
+static bool display_flipped = false;
+
/* turn the display upside down */
void lcd_set_flip(bool yesno)
{
- lcd_write_reg(R_DRV_OUTPUT_CONTROL, yesno ? 0x21b : 0x11b);
+ display_flipped = yesno;
+
+ r_entry_mode = yesno ? R_ENTRY_MODE_HORZ_FLIPPED :
+ R_ENTRY_MODE_HORZ_NORMAL;
}
static void lcd_window(int xmin, int ymin, int xmax, int ymax)
{
- lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin);
- lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin);
- lcd_write_reg(R_RAM_ADDR_SET, (ymin << 8) | xmin);
+ if (!display_flipped)
+ {
+ lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin);
+ lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin);
+ lcd_write_reg(R_RAM_ADDR_SET, (ymin << 8) | xmin);
+ }
+ else
+ {
+ lcd_write_reg(R_HORIZ_RAM_ADDR_POS,
+ ((LCD_WIDTH-1 - xmin) << 8) | (LCD_WIDTH-1 - xmax));
+ lcd_write_reg(R_VERT_RAM_ADDR_POS,
+ ((LCD_HEIGHT-1 - ymin) << 8) | (LCD_HEIGHT-1 - ymax));
+ lcd_write_reg(R_RAM_ADDR_SET,
+ ((LCD_HEIGHT-1 - ymin) << 8) | (LCD_WIDTH-1 - xmin));
+ }
}
static void _display_on(void)
@@ -188,7 +211,7 @@ static void _display_on(void)
/* Address counter updated in horizontal direction; left to right;
* vertical increment horizontal increment.
* data format for 8bit transfer or spi = 65k (5,6,5) */
- lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ_NORMAL);
+ lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
/* Replace data on writing to GRAM */
lcd_write_reg(R_COMPARE_REG1, 0);
@@ -329,10 +352,20 @@ void lcd_yuv_set_options(unsigned options)
#ifndef BOOTLOADER
static void lcd_window_blit(int xmin, int ymin, int xmax, int ymax)
{
- lcd_write_reg(R_HORIZ_RAM_ADDR_POS,
- ((LCD_WIDTH-1 - xmin) << 8) | (LCD_WIDTH-1 - xmax));
- lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin);
- lcd_write_reg(R_RAM_ADDR_SET, (ymin << 8) | (LCD_WIDTH-1 - xmin));
+ if (!display_flipped)
+ {
+ lcd_write_reg(R_HORIZ_RAM_ADDR_POS,
+ ((LCD_WIDTH-1 - xmin) << 8) | (LCD_WIDTH-1 - xmax));
+ lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin);
+ lcd_write_reg(R_RAM_ADDR_SET,
+ (ymin << 8) | (LCD_WIDTH-1 - xmin));
+ }
+ else
+ {
+ lcd_write_reg(R_HORIZ_RAM_ADDR_POS, (xmax << 8) | xmin);
+ lcd_write_reg(R_VERT_RAM_ADDR_POS, (ymax << 8) | ymin);
+ lcd_write_reg(R_RAM_ADDR_SET, (ymax << 8) | xmin);
+ }
}
/* Line write helper function for lcd_yuv_blit. Write two lines of yuv420. */
@@ -365,6 +398,10 @@ void lcd_blit_yuv(unsigned char * const src[3],
yuv_src[1] = src[1] + (z >> 2) + (src_x >> 1);
yuv_src[2] = src[2] + (yuv_src[1] - src[1]);
+ lcd_write_reg(R_ENTRY_MODE,
+ display_flipped ? R_ENTRY_MODE_VIDEO_FLIPPED : R_ENTRY_MODE_VIDEO_NORMAL
+ );
+
if (lcd_yuv_options & LCD_YUV_DITHER)
{
do
@@ -409,7 +446,7 @@ void lcd_update(void)
if (!display_on)
return;
- lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ_NORMAL);
+ lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
/* Set start position and window */
lcd_window(0, 0, LCD_WIDTH-1, LCD_HEIGHT-1);
@@ -447,7 +484,7 @@ void lcd_update_rect(int x, int y, int width, int height)
if (y + height > LCD_HEIGHT)
height = LCD_HEIGHT - y; /* clip bottom */
- lcd_write_reg(R_ENTRY_MODE, R_ENTRY_MODE_HORZ_NORMAL);
+ lcd_write_reg(R_ENTRY_MODE, r_entry_mode);
/* we need to make x and width even to enable 32bit transfers */
width = (width + (x & 1) + 1) & ~1;