1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2011 Andrew Ryabinin
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
29 #include "lcdif-rk27xx.h"
31 static bool display_on
= false;
33 static void reset_lcd(void)
42 void lcd_v1_display_init(void)
46 /* Driving ability setting */
47 lcd_write_reg(0x60, 0x00);
48 lcd_write_reg(0x61, 0x06);
49 lcd_write_reg(0x62, 0x00);
50 lcd_write_reg(0x63, 0xC8);
52 /* Gamma 2.2 Setting */
53 lcd_write_reg(0x40, 0x00);
54 lcd_write_reg(0x41, 0x40);
55 lcd_write_reg(0x42, 0x45);
56 lcd_write_reg(0x43, 0x01);
57 lcd_write_reg(0x44, 0x60);
58 lcd_write_reg(0x45, 0x05);
59 lcd_write_reg(0x46, 0x0C);
60 lcd_write_reg(0x47, 0xD1);
61 lcd_write_reg(0x48, 0x05);
63 lcd_write_reg(0x50, 0x75);
64 lcd_write_reg(0x51, 0x01);
65 lcd_write_reg(0x52, 0x67);
66 lcd_write_reg(0x53, 0x14);
67 lcd_write_reg(0x54, 0xF2);
68 lcd_write_reg(0x55, 0x07);
69 lcd_write_reg(0x56, 0x03);
70 lcd_write_reg(0x57, 0x49);
72 /* Power voltage setting */
73 lcd_write_reg(0x1F, 0x03);
74 lcd_write_reg(0x20, 0x00);
75 lcd_write_reg(0x24, 0x28);
76 lcd_write_reg(0x25, 0x45);
78 lcd_write_reg(0x23, 0x2F);
80 /* Power on setting */
81 lcd_write_reg(0x18, 0x44);
82 lcd_write_reg(0x21, 0x01);
83 lcd_write_reg(0x01, 0x00);
84 lcd_write_reg(0x1C, 0x03);
85 lcd_write_reg(0x19, 0x06);
88 /* Display on setting */
89 lcd_write_reg(0x26, 0x84);
91 lcd_write_reg(0x26, 0xB8);
93 lcd_write_reg(0x26, 0xBC);
96 /* Memmory access setting */
97 lcd_write_reg(0x16, 0x68);
98 /* Setup 16bit mode */
99 lcd_write_reg(0x17, 0x05);
102 lcd_write_reg(0x02, 0x00);
103 lcd_write_reg(0x03, 0x00);
104 lcd_write_reg(0x04, 0x00);
105 lcd_write_reg(0x05, LCD_WIDTH
- 1);
106 lcd_write_reg(0x06, 0x00);
107 lcd_write_reg(0x07, 0x00);
108 lcd_write_reg(0x08, 0x00);
109 lcd_write_reg(0x09, LCD_HEIGHT
- 1);
111 /* Start GRAM write */
114 for (x
=0; x
<LCD_WIDTH
; x
++)
115 for(y
=0; y
<LCD_HEIGHT
; y
++)
121 static void lcd_v1_enable (bool on
)
123 if (on
== display_on
)
131 lcd_write_reg(0x18, 0x44);
132 lcd_write_reg(0x21, 0x01);
133 lcd_write_reg(0x01, 0x00);
134 lcd_write_reg(0x1C, 0x03);
135 lcd_write_reg(0x19, 0x06);
137 lcd_write_reg(0x26, 0x84);
139 lcd_write_reg(0x26, 0xB8);
141 lcd_write_reg(0x26, 0xBC);
145 lcd_write_reg(0x26, 0xB8);
147 lcd_write_reg(0x19, 0x01);
149 lcd_write_reg(0x26, 0xA4);
151 lcd_write_reg(0x26, 0x84);
153 lcd_write_reg(0x1C, 0x00);
154 lcd_write_reg(0x01, 0x02);
155 lcd_write_reg(0x21, 0x00);
159 LCDC_CTRL
&= ~RGB24B
;
161 static void lcd_v1_set_gram_area(int x
, int y
, int width
, int height
)
166 lcd_write_reg(0x03, x
);
167 lcd_write_reg(0x05, width
-1);
168 lcd_write_reg(0x07, y
);
169 lcd_write_reg(0x09, height
-1);
172 LCDC_CTRL
&= ~RGB24B
;
175 static void lcd_v1_update_rect(int x
, int y
, int width
, int height
)
178 int pxmax
= x
+ width
, pymax
= y
+ height
;
180 lcd_v1_set_gram_area(x
, y
, pxmax
, pymax
);
182 for (py
=y
; py
<pymax
; py
++)
183 for (px
=x
; px
<pxmax
; px
++)
184 LCD_DATA
= (*FBADDR(px
, py
));
196 static void identify_lcd(void)
198 SCU_IOMUXB_CON
&= ~(1<<2);
200 if (GPIO_PCDR
& (1<<4))
210 static void lcd_v2_display_init(void)
214 lcd_write_reg(0xD0, 0x0003);
215 lcd_write_reg(0xEB, 0x0B00);
216 lcd_write_reg(0xEC, 0x00CF);
217 lcd_write_reg(0xC7, 0x030F);
219 lcd_write_reg(0x01, 0x001C);
220 lcd_write_reg(0x02, 0x0100);
221 lcd_write_reg(0x03, 0x1038);
222 lcd_write_reg(0x07, 0x0000);
223 lcd_write_reg(0x08, 0x0808);
224 lcd_write_reg(0x0F, 0x0901);
225 lcd_write_reg(0x10, 0x0000);
226 lcd_write_reg(0x11, 0x1B41);
227 lcd_write_reg(0x12, 0x2010);
228 lcd_write_reg(0x13, 0x0009);
229 lcd_write_reg(0x14, 0x4C65);
231 lcd_write_reg(0x30, 0x0000);
232 lcd_write_reg(0x31, 0x00DB);
233 lcd_write_reg(0x32, 0x0000);
234 lcd_write_reg(0x33, 0x0000);
235 lcd_write_reg(0x34, 0x00DB);
236 lcd_write_reg(0x35, 0x0000);
237 lcd_write_reg(0x36, 0x00AF);
238 lcd_write_reg(0x37, 0x0000);
239 lcd_write_reg(0x38, 0x00DB);
240 lcd_write_reg(0x39, 0x0000);
242 lcd_write_reg(0x50, 0x0000);
243 lcd_write_reg(0x51, 0x0705);
244 lcd_write_reg(0x52, 0x0C0A);
245 lcd_write_reg(0x53, 0x0401);
246 lcd_write_reg(0x54, 0x040C);
247 lcd_write_reg(0x55, 0x0608);
248 lcd_write_reg(0x56, 0x0000);
249 lcd_write_reg(0x57, 0x0104);
250 lcd_write_reg(0x58, 0x0E06);
251 lcd_write_reg(0x59, 0x060E);
253 lcd_write_reg(0x20, 0x0000);
254 lcd_write_reg(0x21, 0x0000);
256 lcd_write_reg(0x07, 0x1017);
258 lcd_write_reg(0x20, 0x00AF);
259 lcd_write_reg(0x21, 0x0000);
263 for (x
=0; x
<LCD_WIDTH
; x
++)
264 for(y
=0; y
<LCD_HEIGHT
; y
++)
270 static void lcd_v2_enable (bool on
)
275 static void lcd_v2_set_gram_area(int x
, int y
, int width
, int height
)
284 LCDC_CTRL
&= ~RGB24B
;
287 static void lcd_v2_update_rect(int x
, int y
, int width
, int height
)
296 void lcd_display_init(void)
300 if (lcd_type
== LCD_V1
)
301 lcd_v1_display_init();
303 lcd_v2_display_init();
306 void lcd_enable (bool on
)
308 if (lcd_type
== LCD_V1
)
314 void lcd_set_gram_area(int x
, int y
, int width
, int height
)
316 if (lcd_type
== LCD_V1
)
317 lcd_v1_set_gram_area(x
, y
, width
, height
);
319 lcd_v2_set_gram_area(x
, y
, width
, height
);
322 void lcd_update_rect(int x
, int y
, int width
, int height
)
324 if (lcd_type
== LCD_V1
)
325 lcd_v1_update_rect(x
, y
, width
, height
);
327 lcd_v2_update_rect(x
, y
, width
, height
);
334 void lcd_display_init(void)
337 lcd_v1_display_init();
340 void lcd_enable (bool on
)
345 void lcd_set_gram_area(int x
, int y
, int width
, int height
)
347 lcd_v1_set_gram_area(x
, y
, width
, height
);
350 void lcd_update_rect(int x
, int y
, int width
, int height
)
352 lcd_v1_update_rect(x
, y
, width
, height
);
364 /* Blit a YUV bitmap directly to the LCD
365 * provided by generic fallback in lcd-16bit-common.c
368 void lcd_blit_yuv(unsigned char * const src
[3],
369 int src_x
, int src_y
, int stride
,
370 int x
, int y
, int width
, int height
)