diff --git a/firmware/target/arm/as3525/button-e200v2-fuze.c b/firmware/target/arm/as3525/button-e200v2-fuze.c index 6a9f029..9554c61 100644 --- a/firmware/target/arm/as3525/button-e200v2-fuze.c +++ b/firmware/target/arm/as3525/button-e200v2-fuze.c @@ -246,6 +246,8 @@ static int button_gpio(void) int btn = BUTTON_NONE; if(hold_button) return btn; + DBOP_CTRL &= ~(1<<16); /* disable output (1:write enabled) */ + button_delay(); /* set afsel, so that we can read our buttons */ GPIOC_AFSEL &= ~(1<<2|1<<3|1<<4|1<<5|1<<6); /* set dir so we can read our buttons (but reset the C pins first) */ @@ -277,6 +279,7 @@ static int button_gpio(void) GPIOC_DIR |= (1<<2|1<<3|1<<4|1<<5|1<<6); GPIOC_AFSEL |= (1<<2|1<<3|1<<4|1<<5|1<<6); + DBOP_CTRL |= (1<<16); /* disable output (1:write enabled) */ return btn; } diff --git a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c index 7f02a8b..e9f6e1b 100644 --- a/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c +++ b/firmware/target/arm/as3525/sansa-e200v2/lcd-e200v2.c @@ -131,14 +131,16 @@ static void ams3525_dbop_init(void) } +#define lcd_write_single_data16(value) do {\ + DBOP_CTRL &= ~(1<<14|1<<13); \ + DBOP_DOUT16 = (fb_data)(value); \ + } while(0) + static void lcd_write_cmd(int cmd) { - /* Write register */ - DBOP_CTRL &= ~(1<<14); - DBOP_TIMPOL_23 = 0xa167006e; - - DBOP_DOUT = cmd; + /* Write register */ + lcd_write_single_data16(cmd); /* Wait for fifo to empty */ while ((DBOP_STAT & (1<<10)) == 0); @@ -152,13 +154,36 @@ static void lcd_write_cmd(int cmd) void lcd_write_data(const fb_data* p_bytes, int count) { - while (count--) + const long *data; + if ((int)p_bytes & 0x3) + { /* need to do a single 16bit write beforehand if the address is + * not word aligned*/ + lcd_write_single_data16(*p_bytes); + count--;p_bytes++; + } + /* from here, 32bit transfers are save */ + /* set it to transfer 4*(outputwidth) units at a time, + * if bit 12 is set it only does 2 halfwords though */ + DBOP_CTRL |= (1<<13|1<<14); + data = (long*)p_bytes; + while (count > 1) { - DBOP_DOUT = *p_bytes++; + DBOP_DOUT32 = *data++; + count -= 2; /* Wait for fifo to empty */ - while ((DBOP_STAT & (1<<10)) == 0); - } + /* TODO: We should normally fill the fifo until it's full + * instead of waiting after each word, + * but that causes blue lines on the display */ + /* Wait if push fifo is full */ + while ((DBOP_STAT & (1<<6)) != 0); + } + /* While push fifo is not empty */ + while ((DBOP_STAT & (1<<10)) == 0); + /* due to the 32bit alignment requirement, we possibly need to do a + * 16bit transfer at the end also */ + if (count > 0) + lcd_write_single_data16(*(fb_data*)data); } static void lcd_write_reg(int reg, int value) @@ -166,7 +191,8 @@ static void lcd_write_reg(int reg, int value) fb_data data = value; lcd_write_cmd(reg); - lcd_write_data(&data, 1); + + lcd_write_single_data16(data); } /*** hardware configuration ***/ @@ -555,6 +581,6 @@ bool lcd_button_support(void) lcd_write_cmd(R_WRITE_DATA_2_GRAM); - lcd_write_data(&data, 1); + lcd_write_single_data16(data); return true; } diff --git a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c index fc0fdaa..833cdf8 100644 --- a/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c +++ b/firmware/target/arm/as3525/sansa-fuze/lcd-fuze.c @@ -120,8 +120,11 @@ void lcd_write_data(const fb_data* p_bytes, int count) /* TODO: We should normally fill the fifo until it's full * instead of waiting after each word, * but that causes blue lines on the display */ - while ((DBOP_STAT & (1<<10)) == 0); - } + /* Wait if push fifo is full */ + while ((DBOP_STAT & (1<<6)) != 0); + } + /* While push fifo is not empty */ + while ((DBOP_STAT & (1<<10)) == 0); /* due to the 32bit alignment requirement, we possibly need to do a * 16bit transfer at the end also */ if (count > 0)