summaryrefslogtreecommitdiff
path: root/firmware/target/arm/lcd-c200_c200v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/lcd-c200_c200v2.c')
-rw-r--r--firmware/target/arm/lcd-c200_c200v2.c50
1 files changed, 37 insertions, 13 deletions
diff --git a/firmware/target/arm/lcd-c200_c200v2.c b/firmware/target/arm/lcd-c200_c200v2.c
index 06cb475d9d..3ba1bf0f07 100644
--- a/firmware/target/arm/lcd-c200_c200v2.c
+++ b/firmware/target/arm/lcd-c200_c200v2.c
@@ -29,6 +29,7 @@
29#ifdef SANSA_C200V2 29#ifdef SANSA_C200V2
30/* button driver needs to know if a lcd operation is in progress */ 30/* button driver needs to know if a lcd operation is in progress */
31static bool lcd_busy = false; 31static bool lcd_busy = false;
32static unsigned short dbop_input = 0xFFFF;
32#endif 33#endif
33 34
34/* Display status */ 35/* Display status */
@@ -182,24 +183,45 @@ static inline void as3525_dbop_init(void)
182 lcd_delay(20); 183 lcd_delay(20);
183} 184}
184 185
185/* we need to set the DBOP_DOUT pins high, for correct dbop reads */ 186static unsigned short lcd_dbop_read(void)
186bool lcd_button_support(void)
187{ 187{
188 const fb_data data = 0xffff; 188 unsigned int dbop_ctrl_old = DBOP_CTRL;
189 189 unsigned int dbop_timpol23_old = DBOP_TIMPOL_23;
190 if (lcd_busy) /* we can't use dbop for reading if we are in the */ 190 unsigned int value;
191 return false; /* middle of a write operation */ 191
192 /* make sure that the DBOP FIFO is empty */
193 while ((DBOP_STAT & (1<<10)) == 0);
192 194
193 /* use out of screen coordinates */ 195 /* write DBOP_DOUT to pre-charge DBOP data lines with a high level */
194 lcd_send_command(R_X_ADDR_AREA, 0); 196 DBOP_TIMPOL_23 = 0xe167e167; /* no strobe towards lcd */
195 lcd_send_command(1, 0); 197 DBOP_CTRL = (1 << 16) | /* enw=1 (enable write) */
196 lcd_send_command(R_Y_ADDR_AREA, 0); 198 (1 << 12); /* ow=1 (16-bit data width) */
197 lcd_send_command(1, 0); 199 DBOP_DOUT = 0xFFFF; /* all pins high */
200 while ((DBOP_STAT & (1<<10)) == 0);
198 201
199 lcd_write_data(&data, 1); 202 /* perform a DBOP read */
203 DBOP_CTRL = (1 << 15) | /* strd=1 (start read) */
204 (1 << 12) | /* ow=1 (16-bit data width) */
205 (31 << 0); /* rs_t=31 (read DBOP at end of cycle) */
206 while ((DBOP_STAT & (1<<16)) == 0);
207 value = DBOP_DIN;
208
209 /* restore previous values */
210 DBOP_TIMPOL_23 = dbop_timpol23_old;
211 DBOP_CTRL = dbop_ctrl_old;
212
213 return value;
214}
200 215
201 return true; 216/* get the DBOP input value, either directly or cached if DBOP is busy */
217unsigned short int lcd_dbop_input(void)
218{
219 if (!lcd_busy) {
220 dbop_input = lcd_dbop_read();
221 }
222 return dbop_input;
202} 223}
224
203#endif 225#endif
204 226
205/* LCD init */ 227/* LCD init */
@@ -430,6 +452,8 @@ void lcd_update_rect(int x, int y, int width, int height)
430 452
431#ifdef SANSA_C200V2 453#ifdef SANSA_C200V2
432 lcd_busy = true; 454 lcd_busy = true;
455 /* perform a dbop read before doing a potentially lengthy lcd update */
456 dbop_input = lcd_dbop_read();
433#endif 457#endif
434 458
435 if (width <= 1) { 459 if (width <= 1) {