summaryrefslogtreecommitdiff
path: root/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c')
-rw-r--r--firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c65
1 files changed, 4 insertions, 61 deletions
diff --git a/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c b/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c
index 5fa26c0eaf..d17149ee95 100644
--- a/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c
+++ b/firmware/target/arm/as3525/sansa-fuzev2/lcd-fuzev2.c
@@ -29,6 +29,7 @@
29#include "debug.h" 29#include "debug.h"
30#include "system.h" 30#include "system.h"
31#include "clock-target.h" 31#include "clock-target.h"
32#include "dbop-as3525.h"
32 33
33/* The controller is unknown, but some registers appear to be the same as the 34/* The controller is unknown, but some registers appear to be the same as the
34 HD66789R */ 35 HD66789R */
@@ -113,67 +114,13 @@ static void as3525_dbop_init(void)
113 DBOP_TIMPOL_23 = 0xA12FE037; 114 DBOP_TIMPOL_23 = 0xA12FE037;
114} 115}
115 116
116static inline void dbop_set_mode(int mode)
117{
118 unsigned long ctrl = DBOP_CTRL;
119 int words = (ctrl >> 13) & 3; // bits 14:13
120 if (mode == 32 && words != 2)
121 DBOP_CTRL = (ctrl & ~(1<<13)) | (1<<14); // 4 serial words
122 else if (mode == 16 && words != 1)
123 DBOP_CTRL = (ctrl & ~(1<<14)) | (1<<13); // 2 serial words
124 else
125 return;
126 lcd_delay(10);
127}
128
129static void dbop_write_data(const int16_t* p_bytes, int count)
130{
131 const int32_t *data;
132 if ((intptr_t)p_bytes & 0x3 || count == 1)
133 { /* need to do a single 16bit write beforehand if the address is
134 * not word aligned or count is 1, switch to 16bit mode if needed */
135 dbop_set_mode(16);
136 DBOP_DOUT16 = *p_bytes++;
137 if (!(--count))
138 return;
139 }
140 /* from here, 32bit transfers are save
141 * set it to transfer 4*(outputwidth) units at a time,
142 * if bit 12 is set it only does 2 halfwords though (we never set it)
143 * switch to 32bit output if needed */
144 dbop_set_mode(32);
145 data = (int32_t*)p_bytes;
146
147 while (count > 1)
148 {
149 DBOP_DOUT32 = *data++;
150 count -= 2;
151
152 /* Wait if push fifo is full */
153 while ((DBOP_STAT & (1<<6)) != 0);
154 }
155 /* While push fifo is not empty */
156 while ((DBOP_STAT & (1<<10)) == 0);
157
158 /* due to the 32bit alignment requirement or uneven count,
159 * we possibly need to do a 16bit transfer at the end also */
160 if (count > 0)
161 dbop_write_data((int16_t*)data, 1);
162}
163 117
164static void lcd_write_cmd(unsigned short cmd) 118static void lcd_write_cmd(unsigned short cmd)
165{ 119{
166 volatile int i; 120 unsigned short data = swap16(cmd);
167 lcd_delay(0x20);
168
169 DBOP_CTRL |= 1<<13;
170 DBOP_CTRL &= ~(1<<14); // 2 serial words
171 DBOP_CTRL &= ~(1<<12); // 8 bit data width
172 DBOP_TIMPOL_23 = 0xA12F0036; 121 DBOP_TIMPOL_23 = 0xA12F0036;
173 DBOP_DOUT = swap16(cmd); 122 dbop_write_data(&data, 1);
174 123 lcd_delay(32);
175 while ((DBOP_STAT & (1<<10)) == 0);
176 for(i=0;i<0x20;i++) asm volatile ("nop\n");
177 DBOP_TIMPOL_23 = 0xA12FE037; 124 DBOP_TIMPOL_23 = 0xA12FE037;
178} 125}
179 126
@@ -403,8 +350,6 @@ void lcd_blit_yuv(unsigned char * const src[3],
403 lcd_window_y(y, y + 1); 350 lcd_window_y(y, y + 1);
404 351
405 lcd_write_cmd(R_WRITE_DATA_2_GRAM); 352 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
406
407 dbop_set_mode(32);
408 lcd_write_yuv420_lines_odither(yuv_src, width, stride, x, y); 353 lcd_write_yuv420_lines_odither(yuv_src, width, stride, x, y);
409 yuv_src[0] += stride << 1; /* Skip down two luma lines */ 354 yuv_src[0] += stride << 1; /* Skip down two luma lines */
410 yuv_src[1] += stride >> 1; /* Skip down one chroma line */ 355 yuv_src[1] += stride >> 1; /* Skip down one chroma line */
@@ -420,8 +365,6 @@ void lcd_blit_yuv(unsigned char * const src[3],
420 lcd_window_y(y, y + 1); 365 lcd_window_y(y, y + 1);
421 366
422 lcd_write_cmd(R_WRITE_DATA_2_GRAM); 367 lcd_write_cmd(R_WRITE_DATA_2_GRAM);
423
424 dbop_set_mode(32);
425 lcd_write_yuv420_lines(yuv_src, width, stride); 368 lcd_write_yuv420_lines(yuv_src, width, stride);
426 yuv_src[0] += stride << 1; /* Skip down two luma lines */ 369 yuv_src[0] += stride << 1; /* Skip down two luma lines */
427 yuv_src[1] += stride >> 1; /* Skip down one chroma line */ 370 yuv_src[1] += stride >> 1; /* Skip down one chroma line */