summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/target/arm/rk27xx/lcd-hifiman.c187
1 files changed, 167 insertions, 20 deletions
diff --git a/firmware/target/arm/rk27xx/lcd-hifiman.c b/firmware/target/arm/rk27xx/lcd-hifiman.c
index d98ed5a1c3..b97766c840 100644
--- a/firmware/target/arm/rk27xx/lcd-hifiman.c
+++ b/firmware/target/arm/rk27xx/lcd-hifiman.c
@@ -29,7 +29,7 @@
29 29
30static bool display_on = false; 30static bool display_on = false;
31 31
32static void lcd_display_init(void) 32static void lcd_v1_display_init(void)
33{ 33{
34 unsigned int x, y; 34 unsigned int x, y;
35 35
@@ -108,13 +108,7 @@ static void lcd_display_init(void)
108 display_on = true; 108 display_on = true;
109} 109}
110 110
111void lcd_init_device(void) 111static void lcd_v1_enable (bool on)
112{
113 lcdif_init(LCDIF_16BIT);
114 lcd_display_init();
115}
116
117void lcd_enable (bool on)
118{ 112{
119 if (on) 113 if (on)
120 { 114 {
@@ -145,32 +139,185 @@ void lcd_enable (bool on)
145 lcd_write_reg(0x21, 0x00); 139 lcd_write_reg(0x21, 0x00);
146 } 140 }
147 display_on = on; 141 display_on = on;
148
149} 142}
150 143
151bool lcd_active() 144static void lcd_v1_update_rect(int x, int y, int width, int height)
152{ 145{
153 return display_on; 146 int px = x, py = y;
147 int pxmax = x + width, pymax = y + height;
148
149 lcd_write_reg(0x03, y);
150 lcd_write_reg(0x05, pymax-1);
151 lcd_write_reg(0x07, x);
152 lcd_write_reg(0x09, pxmax-1);
153
154 lcd_cmd(0x22);
155
156 for (px=x; px<pxmax; px++)
157 for (py=y; py<pymax; py++)
158 lcd_data(*FBADDR(px, py));
154} 159}
155 160
156 161
157void lcd_update_rect(int x, int y, int width, int height) 162#ifdef HM60X
163
164enum lcd_type_t
158{ 165{
159 int px = x, py = y; 166 LCD_V1,
160 int pxmax = x + width, pymax = y + height; 167 LCD_v2
168} lcd_type;
169
170static void identify_lcd(void)
171{
172 SCU_IOMUXB_CON &= ~(1<<2);
173 GPIO_PCCON |= (1<<4);
174 if (GPIO_PCDR & (1<<4))
175 {
176 lcd_type = LCD_V1;
177 }
178 else
179 {
180 lcd_type = LCD_v2;
181 }
182}
183
184static void lcd_v2_display_init(void)
185{
186 unsigned int x, y;
161 187
162 lcd_write_reg(0x03, y); 188 lcd_write_reg(0xD0, 0x0003);
163 lcd_write_reg(0x05, pymax-1); 189 lcd_write_reg(0xEB, 0x0B00);
164 lcd_write_reg(0x07, x); 190 lcd_write_reg(0xEC, 0x00CF);
165 lcd_write_reg(0x09, pxmax-1); 191 lcd_write_reg(0xC7, 0x030F);
192
193 lcd_write_reg(0x01, 0x001C);
194 lcd_write_reg(0x02, 0x0100);
195 lcd_write_reg(0x03, 0x1038);
196 lcd_write_reg(0x07, 0x0000);
197 lcd_write_reg(0x08, 0x0808);
198 lcd_write_reg(0x0F, 0x0901);
199 lcd_write_reg(0x10, 0x0000);
200 lcd_write_reg(0x11, 0x1B41);
201 lcd_write_reg(0x12, 0x2010);
202 lcd_write_reg(0x13, 0x0009);
203 lcd_write_reg(0x14, 0x4C65);
204
205 lcd_write_reg(0x30, 0x0000);
206 lcd_write_reg(0x31, 0x00DB);
207 lcd_write_reg(0x32, 0x0000);
208 lcd_write_reg(0x33, 0x0000);
209 lcd_write_reg(0x34, 0x00DB);
210 lcd_write_reg(0x35, 0x0000);
211 lcd_write_reg(0x36, 0x00AF);
212 lcd_write_reg(0x37, 0x0000);
213 lcd_write_reg(0x38, 0x00DB);
214 lcd_write_reg(0x39, 0x0000);
215
216 lcd_write_reg(0x50, 0x0000);
217 lcd_write_reg(0x51, 0x0705);
218 lcd_write_reg(0x52, 0x0C0A);
219 lcd_write_reg(0x53, 0x0401);
220 lcd_write_reg(0x54, 0x040C);
221 lcd_write_reg(0x55, 0x0608);
222 lcd_write_reg(0x56, 0x0000);
223 lcd_write_reg(0x57, 0x0104);
224 lcd_write_reg(0x58, 0x0E06);
225 lcd_write_reg(0x59, 0x060E);
226
227 lcd_write_reg(0x20, 0x0000);
228 lcd_write_reg(0x21, 0x0000);
229
230 lcd_write_reg(0x07, 0x1017);
231
232 lcd_write_reg(0x20, 0x00AF);
233 lcd_write_reg(0x21, 0x0000);
166 234
167 lcd_cmd(0x22); 235 lcd_cmd(0x22);
168 236
169 for (px=x; px<pxmax; px++) 237 for (x=0; x<LCD_WIDTH; x++)
170 for (py=y; py<pymax; py++) 238 for(y=0; y<LCD_HEIGHT; y++)
239 lcd_data(0x00);
240
241 display_on = true;
242}
243
244static void lcd_v2_enable (bool on)
245{
246 display_on = on;
247}
248
249static void lcd_v2_update_rect(int x, int y, int width, int height)
250{
251 int px, py;
252 (void) x;
253 (void) y;
254 (void) width;
255 (void)height;
256
257 lcd_cmd(0x22);
258
259 for (py=0; py<LCD_HEIGHT; py++)
260 for (px=0; px<LCD_WIDTH; px++)
171 lcd_data(*FBADDR(px, py)); 261 lcd_data(*FBADDR(px, py));
172} 262}
173 263
264void lcd_init_device(void)
265{
266 lcdif_init(LCDIF_16BIT);
267
268 identify_lcd();
269 if (lcd_type == LCD_V1)
270 lcd_v1_display_init();
271 else
272 lcd_v2_display_init();
273
274}
275
276void lcd_enable (bool on)
277{
278 if (lcd_type == LCD_V1)
279 lcd_v1_enable(on);
280 else
281 lcd_v2_enable(on);
282}
283
284void lcd_update_rect(int x, int y, int width, int height)
285{
286 if (lcd_type == LCD_V1)
287 lcd_v1_update_rect(x, y, width, height);
288 else
289 lcd_v2_update_rect(x, y, width, height);
290}
291
292
293
294#else /* HM801 */
295
296void lcd_init_device(void)
297{
298 lcdif_init(LCDIF_16BIT);
299 lcd_v1_display_init();
300}
301
302void lcd_enable (bool on)
303{
304 lcd_v1_enable(on);
305}
306
307void lcd_update_rect(int x, int y, int width, int height)
308{
309 lcd_v1_update_rect(x, y, width, height);
310}
311
312#endif
313
314
315
316bool lcd_active()
317{
318 return display_on;
319}
320
174/* Blit a YUV bitmap directly to the LCD */ 321/* Blit a YUV bitmap directly to the LCD */
175void lcd_blit_yuv(unsigned char * const src[3], 322void lcd_blit_yuv(unsigned char * const src[3],
176 int src_x, int src_y, int stride, 323 int src_x, int src_y, int stride,