Commit | Line | Data |
---|---|---|
6fa3eb70 S |
1 | #ifdef BUILD_LK |
2 | #include <platform/mt_gpio.h> | |
3 | #include <string.h> | |
4 | #elif defined(BUILD_UBOOT) | |
5 | #include <asm/arch/mt_gpio.h> | |
6 | #else | |
7 | #include <mach/mt_gpio.h> | |
8 | #endif | |
9 | #include "lcm_drv.h" | |
10 | ||
11 | ||
12 | // --------------------------------------------------------------------------- | |
13 | // Local Constants | |
14 | // --------------------------------------------------------------------------- | |
15 | ||
16 | #define FRAME_WIDTH (480) | |
17 | #define FRAME_HEIGHT (800) | |
18 | #define LCM_ID (0x69) | |
19 | ||
20 | #define REGFLAG_DELAY 0XFE | |
21 | #define REGFLAG_END_OF_TABLE 0xFF // END OF REGISTERS MARKER | |
22 | ||
23 | ||
24 | #ifndef TRUE | |
25 | #define TRUE 1 | |
26 | #endif | |
27 | ||
28 | #ifndef FALSE | |
29 | #define FALSE 0 | |
30 | #endif | |
31 | ||
32 | //#define LCM_TABLE_V3 | |
33 | ||
34 | static unsigned int lcm_esd_test = FALSE; ///only for ESD test | |
35 | #define LCM_DSI_CMD_MODE 1 | |
36 | ||
37 | // --------------------------------------------------------------------------- | |
38 | // Local Variables | |
39 | // --------------------------------------------------------------------------- | |
40 | ||
41 | static LCM_UTIL_FUNCS lcm_util = {0}; | |
42 | ||
43 | #define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v))) | |
44 | ||
45 | #define UDELAY(n) (lcm_util.udelay(n)) | |
46 | #define MDELAY(n) (lcm_util.mdelay(n)) | |
47 | ||
48 | ||
49 | // --------------------------------------------------------------------------- | |
50 | // Local Functions | |
51 | // --------------------------------------------------------------------------- | |
52 | ||
53 | #define dsi_set_cmdq_V3(ppara, size, force_update) lcm_util.dsi_set_cmdq_V3(ppara, size, force_update) | |
54 | #define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update) | |
55 | #define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update) | |
56 | #define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd) | |
57 | #define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums) | |
58 | #define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd) | |
59 | #define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size) | |
60 | ||
61 | struct LCM_setting_table { | |
62 | unsigned char cmd; | |
63 | unsigned char count; | |
64 | unsigned char para_list[64]; | |
65 | }; | |
66 | ||
67 | #if defined(LCM_TABLE_V3) | |
68 | ||
69 | static LCM_setting_table_V3 lcm_initialization_setting_V3[] = { | |
70 | ||
71 | /* | |
72 | Note : | |
73 | ||
74 | Structure Format : | |
75 | ||
76 | {Data_ID, DCS command, count of parameters, {parameter list}}, | |
77 | ||
78 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, milliseconds of time, {}}, | |
79 | ||
80 | ... | |
81 | ||
82 | */ | |
83 | ||
84 | {0x39, 0xB9, 3, {0xFF, 0x83, 0x69}}, | |
85 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}, | |
86 | ||
87 | ||
88 | {0x39, 0xB0, 2, {0x01, 0x0B}}, | |
89 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}, | |
90 | ||
91 | {0x39, 0xB2, 15, {0x00, 0x20, 0x05, 0x05, | |
92 | 0x70, 0x00, 0xFF, 0x00, | |
93 | 0x00, 0x00, 0x00, 0x03, | |
94 | 0x03, 0x00, 0x01}}, | |
95 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}, | |
96 | ||
97 | {0x39, 0xB4, 5, {0x00, 0x18, 0x80, 0x06, | |
98 | 0x02}}, | |
99 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}, | |
100 | ||
101 | {0x39, 0xD5, 26, {0x00, 0x04, 0x03, 0x00, | |
102 | 0x01, 0x05, 0x28, 0x70, | |
103 | 0x01, 0x03, 0x00, 0x00, | |
104 | 0x40, 0x06, 0x51, 0x07, | |
105 | 0x00, 0x00, 0x41, 0x06, | |
106 | 0x50, 0x07, 0x07, 0x0F, | |
107 | 0x04, 0x00}}, | |
108 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}, | |
109 | ||
110 | {0x39, 0xB1, 19, {0x85, 0x00, 0x34, 0x07, | |
111 | 0x00, 0x0f, 0x0f, 0x2A, | |
112 | 0x32, 0x3F, 0x3F, 0x01, | |
113 | 0x3A, 0x01, 0xE6, 0xE6, | |
114 | 0xE6, 0xE6, 0xE6}}, | |
115 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}, | |
116 | ||
117 | ||
118 | {0x15, 0x3A, 1, {0x07}}, | |
119 | {0x15, 0xCC, 1, {0x02}}, | |
120 | ||
121 | {0x39, 0xB6, 2, {0x42, 0x42}}, ///apply it as ESD indication | |
122 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}, | |
123 | ||
124 | // ENABLE FMARK | |
125 | {0x39, 0x44, 2, {((FRAME_HEIGHT/2)>>8), ((FRAME_HEIGHT/2)&0xFF)}}, | |
126 | {0x15, 0x35, 1, {0x00}}, | |
127 | ||
128 | // SET GAMMA | |
129 | {0x39, 0xE0, 34, {0x00, 0x31, 0x19, 0x38, | |
130 | 0x3D, 0x3F, 0x28, 0x46, | |
131 | 0x07, 0x0D, 0x0E, 0x12, | |
132 | 0x15, 0x12, 0x14, 0x0F, | |
133 | 0x17, 0x00, 0x13, 0x19, | |
134 | 0x38, 0x3D, 0x3F, 0x28, | |
135 | 0x46, 0x07, 0x0D, 0x0E, | |
136 | 0x12, 0x15, 0x12, 0x14, | |
137 | 0x0F, 0x17}}, | |
138 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}, | |
139 | ||
140 | {0x39, 0xBA, 13, {0x00, 0xA0, 0xC6, 0x00, | |
141 | 0x0A, 0x02, 0x10, 0x30, | |
142 | 0x6F, 0x02, 0x11, 0x18, | |
143 | 0x40}}, | |
144 | ||
145 | {0x15, 0x51, 1, {0x00}}, | |
146 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}, | |
147 | ||
148 | {0x15, 0x53, 1, {0x24}}, | |
149 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}, | |
150 | ||
151 | {0x15, 0x55, 1, {0x00}}, | |
152 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}, | |
153 | ||
154 | {0x15, 0x5E, 1, {0x70}}, | |
155 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}} | |
156 | ||
157 | }; | |
158 | ||
159 | ||
160 | static LCM_setting_table_V3 lcm_sleep_out_setting_V3[] = { | |
161 | // Sleep Out | |
162 | {0x15, 0x11, 1, {0x00}}, | |
163 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 120, {}}, | |
164 | // Display ON | |
165 | {0x15, 0x29, 1, {0x00}} | |
166 | }; | |
167 | ||
168 | ||
169 | static LCM_setting_table_V3 lcm_deep_sleep_mode_in_setting_V3[] = { | |
170 | // Display off sequence | |
171 | {0x15, 0x28, 1, {0x00}}, | |
172 | // Sleep Mode On | |
173 | {0x15, 0x10, 1, {0x00}} | |
174 | }; | |
175 | ||
176 | ||
177 | static LCM_setting_table_V3 lcm_compare_id_setting_V3[] = { | |
178 | {0x39, 0xB9, 3, {0xFF, 0x83, 0x69}}, | |
179 | {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}} | |
180 | }; | |
181 | ||
182 | ||
183 | static LCM_setting_table_V3 lcm_backlight_level_setting_V3[] = { | |
184 | {0x15, 0x51, 1, {0xFF}} | |
185 | }; | |
186 | ||
187 | #else | |
188 | ||
189 | static struct LCM_setting_table lcm_initialization_setting[] = { | |
190 | ||
191 | /* | |
192 | Note : | |
193 | ||
194 | Data ID will depends on the following rule. | |
195 | ||
196 | count of parameters > 1 => Data ID = 0x39 | |
197 | count of parameters = 1 => Data ID = 0x15 | |
198 | count of parameters = 0 => Data ID = 0x05 | |
199 | ||
200 | Structure Format : | |
201 | ||
202 | {DCS command, count of parameters, {parameter list}} | |
203 | {REGFLAG_DELAY, milliseconds of time, {}}, | |
204 | ||
205 | ... | |
206 | ||
207 | Setting ending by predefined flag | |
208 | ||
209 | {REGFLAG_END_OF_TABLE, 0x00, {}} | |
210 | */ | |
211 | ||
212 | ||
213 | {0xB9, 3, {0xFF, 0x83, 0x69}}, | |
214 | {REGFLAG_DELAY, 10, {}}, | |
215 | ||
216 | {0xB0, 2, {0x01, 0x0B}}, | |
217 | {REGFLAG_DELAY, 10, {}}, | |
218 | ||
219 | {0xB2, 15, {0x00, 0x20, 0x05, 0x05, | |
220 | 0x70, 0x00, 0xFF, 0x00, | |
221 | 0x00, 0x00, 0x00, 0x03, | |
222 | 0x03, 0x00, 0x01}}, | |
223 | {REGFLAG_DELAY, 10, {}}, | |
224 | ||
225 | {0xB4, 5, {0x00, 0x18, 0x80, 0x06, | |
226 | 0x02}}, | |
227 | {REGFLAG_DELAY, 10, {}}, | |
228 | ||
229 | {0xD5, 26, {0x00, 0x04, 0x03, 0x00, | |
230 | 0x01, 0x05, 0x28, 0x70, | |
231 | 0x01, 0x03, 0x00, 0x00, | |
232 | 0x40, 0x06, 0x51, 0x07, | |
233 | 0x00, 0x00, 0x41, 0x06, | |
234 | 0x50, 0x07, 0x07, 0x0F, | |
235 | 0x04, 0x00}}, | |
236 | {REGFLAG_DELAY, 10, {}}, | |
237 | ||
238 | {0xB1, 19, {0x85, 0x00, 0x34, 0x07, | |
239 | 0x00, 0x0f, 0x0f, 0x2A, | |
240 | 0x32, 0x3F, 0x3F, 0x01, | |
241 | 0x3A, 0x01, 0xE6, 0xE6, | |
242 | 0xE6, 0xE6, 0xE6}}, | |
243 | {REGFLAG_DELAY, 10, {}}, | |
244 | ||
245 | ||
246 | {0x3A, 1, {0x07}}, | |
247 | {0xCC, 1, {0x02}}, | |
248 | ||
249 | {0xB6, 2, {0x42, 0x42}}, ///apply it as ESD indication | |
250 | {REGFLAG_DELAY, 10, {}}, | |
251 | ||
252 | // ENABLE FMARK | |
253 | {0x44, 2, {((FRAME_HEIGHT/2)>>8), ((FRAME_HEIGHT/2)&0xFF)}}, | |
254 | {0x35, 1, {0x00}}, | |
255 | ||
256 | // SET GAMMA | |
257 | {0xE0, 34, {0x00, 0x31, 0x19, 0x38, | |
258 | 0x3D, 0x3F, 0x28, 0x46, | |
259 | 0x07, 0x0D, 0x0E, 0x12, | |
260 | 0x15, 0x12, 0x14, 0x0F, | |
261 | 0x17, 0x00, 0x13, 0x19, | |
262 | 0x38, 0x3D, 0x3F, 0x28, | |
263 | 0x46, 0x07, 0x0D, 0x0E, | |
264 | 0x12, 0x15, 0x12, 0x14, | |
265 | 0x0F, 0x17}}, | |
266 | {REGFLAG_DELAY, 10, {}}, | |
267 | ||
268 | {0xBA, 13, {0x00, 0xA0, 0xC6, 0x00, | |
269 | 0x0A, 0x02, 0x10, 0x30, | |
270 | 0x6F, 0x02, 0x11, 0x18, | |
271 | 0x40}}, | |
272 | ||
273 | {0x51, 1, {0x00}}, | |
274 | {REGFLAG_DELAY, 10, {}}, | |
275 | ||
276 | {0x53, 1, {0x24}}, | |
277 | {REGFLAG_DELAY, 10, {}}, | |
278 | ||
279 | {0x55, 1, {0x00}}, | |
280 | {REGFLAG_DELAY, 10, {}}, | |
281 | ||
282 | {0x5E, 1, {0x70}}, | |
283 | {REGFLAG_DELAY, 10, {}}, | |
284 | ||
285 | // Note | |
286 | // Strongly recommend not to set Sleep out / Display On here. That will cause messed frame to be shown as later the backlight is on. | |
287 | ||
288 | ||
289 | // Setting ending by predefined flag | |
290 | {REGFLAG_END_OF_TABLE, 0x00, {}} | |
291 | }; | |
292 | ||
293 | ||
294 | #if 0 | |
295 | static struct LCM_setting_table lcm_set_window[] = { | |
296 | {0x2A, 4, {0x00, 0x00, (FRAME_WIDTH>>8), (FRAME_WIDTH&0xFF)}}, | |
297 | {0x2B, 4, {0x00, 0x00, (FRAME_HEIGHT>>8), (FRAME_HEIGHT&0xFF)}}, | |
298 | {REGFLAG_END_OF_TABLE, 0x00, {}} | |
299 | }; | |
300 | #endif | |
301 | ||
302 | ||
303 | static struct LCM_setting_table lcm_sleep_out_setting[] = { | |
304 | // Sleep Out | |
305 | {0x11, 1, {0x00}}, | |
306 | {REGFLAG_DELAY, 120, {}}, | |
307 | ||
308 | // Display ON | |
309 | {0x29, 1, {0x00}}, | |
310 | {REGFLAG_END_OF_TABLE, 0x00, {}} | |
311 | }; | |
312 | ||
313 | ||
314 | static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = { | |
315 | // Display off sequence | |
316 | {0x28, 1, {0x00}}, | |
317 | ||
318 | // Sleep Mode On | |
319 | {0x10, 1, {0x00}}, | |
320 | ||
321 | {REGFLAG_END_OF_TABLE, 0x00, {}} | |
322 | }; | |
323 | ||
324 | static struct LCM_setting_table lcm_compare_id_setting[] = { | |
325 | // Display off sequence | |
326 | {0xB9, 3, {0xFF, 0x83, 0x69}}, | |
327 | {REGFLAG_DELAY, 10, {}}, | |
328 | ||
329 | // Sleep Mode On | |
330 | // {0xC3, 1, {0xFF}}, | |
331 | ||
332 | {REGFLAG_END_OF_TABLE, 0x00, {}} | |
333 | }; | |
334 | ||
335 | static struct LCM_setting_table lcm_backlight_level_setting[] = { | |
336 | {0x51, 1, {0xFF}}, | |
337 | {REGFLAG_END_OF_TABLE, 0x00, {}} | |
338 | }; | |
339 | ||
340 | static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update) | |
341 | { | |
342 | unsigned int i; | |
343 | ||
344 | for(i = 0; i < count; i++) { | |
345 | ||
346 | unsigned cmd; | |
347 | cmd = table[i].cmd; | |
348 | ||
349 | switch (cmd) { | |
350 | ||
351 | case REGFLAG_DELAY : | |
352 | MDELAY(table[i].count); | |
353 | break; | |
354 | ||
355 | case REGFLAG_END_OF_TABLE : | |
356 | break; | |
357 | ||
358 | default: | |
359 | dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update); | |
360 | } | |
361 | } | |
362 | ||
363 | } | |
364 | ||
365 | #endif | |
366 | ||
367 | // --------------------------------------------------------------------------- | |
368 | // LCM Driver Implementations | |
369 | // --------------------------------------------------------------------------- | |
370 | ||
371 | static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util) | |
372 | { | |
373 | memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS)); | |
374 | } | |
375 | ||
376 | ||
377 | static void lcm_get_params(LCM_PARAMS *params) | |
378 | { | |
379 | memset(params, 0, sizeof(LCM_PARAMS)); | |
380 | ||
381 | params->type = LCM_TYPE_DSI; | |
382 | ||
383 | params->width = FRAME_WIDTH; | |
384 | params->height = FRAME_HEIGHT; | |
385 | ||
386 | // enable tearing-free | |
387 | params->dbi.te_mode = LCM_DBI_TE_MODE_VSYNC_ONLY; | |
388 | params->dbi.te_edge_polarity = LCM_POLARITY_RISING; | |
389 | ||
390 | #if (LCM_DSI_CMD_MODE) | |
391 | params->dsi.mode = CMD_MODE; | |
392 | #else | |
393 | params->dsi.mode = SYNC_PULSE_VDO_MODE; | |
394 | #endif | |
395 | ||
396 | // DSI | |
397 | /* Command mode setting */ | |
398 | params->dsi.LANE_NUM = LCM_TWO_LANE; | |
399 | //The following defined the fomat for data coming from LCD engine. | |
400 | params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB; | |
401 | params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST; | |
402 | params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB; | |
403 | params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888; | |
404 | ||
405 | // Highly depends on LCD driver capability. | |
406 | // Not support in MT6573 | |
407 | params->dsi.packet_size=256; | |
408 | ||
409 | // Video mode setting | |
410 | params->dsi.intermediat_buffer_num = 2; | |
411 | ||
412 | params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888; | |
413 | params->dsi.word_count=480*3; | |
414 | ||
415 | params->dsi.vertical_sync_active=3; | |
416 | params->dsi.vertical_backporch=12; | |
417 | params->dsi.vertical_frontporch=2; | |
418 | params->dsi.vertical_active_line=800; | |
419 | ||
420 | params->dsi.line_byte=2048; // 2256 = 752*3 | |
421 | params->dsi.horizontal_sync_active_byte=26; | |
422 | params->dsi.horizontal_backporch_byte=146; | |
423 | params->dsi.horizontal_frontporch_byte=146; | |
424 | params->dsi.rgb_byte=(480*3+6); | |
425 | ||
426 | params->dsi.horizontal_sync_active_word_count=20; | |
427 | params->dsi.horizontal_backporch_word_count=140; | |
428 | params->dsi.horizontal_frontporch_word_count=140; | |
429 | ||
430 | // Bit rate calculation | |
431 | params->dsi.pll_div1=0x1; // div1=0,1,2,3;div1_real=1,2,4,4 | |
432 | params->dsi.pll_div2=0x1; // div2=0,1,2,3;div1_real=1,2,4,4 | |
433 | params->dsi.fbk_div =0x11; // fref=26MHz, fvco=fref*(fbk_div+1)*fbk_sel_real/(div1_real*div2_real) | |
434 | params->dsi.fbk_sel=0x1; // fbk_sel=0,1,2,3;fbk_select_real=1,2,4,4 | |
435 | params->dsi.rg_bir=0x5; | |
436 | params->dsi.rg_bic=0x2; | |
437 | params->dsi.rg_bp=0xC; | |
438 | ||
439 | ||
440 | } | |
441 | ||
442 | ||
443 | static void lcm_init(void) | |
444 | { | |
445 | SET_RESET_PIN(1); | |
446 | SET_RESET_PIN(0); | |
447 | MDELAY(1); | |
448 | SET_RESET_PIN(1); | |
449 | MDELAY(10); | |
450 | ||
451 | #if defined(LCM_TABLE_V3) | |
452 | dsi_set_cmdq_V3(lcm_initialization_setting_V3, sizeof(lcm_initialization_setting_V3) / sizeof(LCM_setting_table_V3), 1); | |
453 | #else | |
454 | push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1); | |
455 | #endif | |
456 | ||
457 | } | |
458 | ||
459 | ||
460 | static void lcm_suspend(void) | |
461 | { | |
462 | #if defined(LCM_TABLE_V3) | |
463 | dsi_set_cmdq_V3(lcm_deep_sleep_mode_in_setting_V3, sizeof(lcm_deep_sleep_mode_in_setting_V3) / sizeof(LCM_setting_table_V3), 1); | |
464 | #else | |
465 | push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1); | |
466 | #endif | |
467 | ||
468 | } | |
469 | ||
470 | ||
471 | static void lcm_resume(void) | |
472 | { | |
473 | #if defined(LCM_TABLE_V3) | |
474 | dsi_set_cmdq_V3(lcm_sleep_out_setting_V3, sizeof(lcm_sleep_out_setting_V3) / sizeof(LCM_setting_table_V3), 1); | |
475 | #else | |
476 | push_table(lcm_sleep_out_setting, sizeof(lcm_sleep_out_setting) / sizeof(struct LCM_setting_table), 1); | |
477 | #endif | |
478 | ||
479 | } | |
480 | ||
481 | ||
482 | static void lcm_update(unsigned int x, unsigned int y, | |
483 | unsigned int width, unsigned int height) | |
484 | { | |
485 | unsigned int x0 = x; | |
486 | unsigned int y0 = y; | |
487 | unsigned int x1 = x0 + width - 1; | |
488 | unsigned int y1 = y0 + height - 1; | |
489 | ||
490 | unsigned char x0_MSB = ((x0>>8)&0xFF); | |
491 | unsigned char x0_LSB = (x0&0xFF); | |
492 | unsigned char x1_MSB = ((x1>>8)&0xFF); | |
493 | unsigned char x1_LSB = (x1&0xFF); | |
494 | unsigned char y0_MSB = ((y0>>8)&0xFF); | |
495 | unsigned char y0_LSB = (y0&0xFF); | |
496 | unsigned char y1_MSB = ((y1>>8)&0xFF); | |
497 | unsigned char y1_LSB = (y1&0xFF); | |
498 | ||
499 | unsigned int data_array[16]; | |
500 | ||
501 | data_array[0]= 0x00053902; | |
502 | data_array[1]= (x1_MSB<<24)|(x0_LSB<<16)|(x0_MSB<<8)|0x2a; | |
503 | data_array[2]= (x1_LSB); | |
504 | dsi_set_cmdq(data_array, 3, 1); | |
505 | ||
506 | data_array[0]= 0x00053902; | |
507 | data_array[1]= (y1_MSB<<24)|(y0_LSB<<16)|(y0_MSB<<8)|0x2b; | |
508 | data_array[2]= (y1_LSB); | |
509 | dsi_set_cmdq(data_array, 3, 1); | |
510 | ||
511 | data_array[0]= 0x00290508;//HW bug, so need send one HS packet | |
512 | dsi_set_cmdq(data_array, 1, 1); | |
513 | ||
514 | data_array[0]= 0x002c3909; | |
515 | dsi_set_cmdq(data_array, 1, 0); | |
516 | ||
517 | ||
518 | ||
519 | } | |
520 | ||
521 | ||
522 | static void lcm_setbacklight(unsigned int level) | |
523 | { | |
524 | unsigned int default_level = 145; | |
525 | unsigned int mapped_level = 0; | |
526 | ||
527 | //for LGE backlight IC mapping table | |
528 | if(level > 255) | |
529 | level = 255; | |
530 | ||
531 | if(level >0) | |
532 | mapped_level = default_level+(level)*(255-default_level)/(255); | |
533 | else | |
534 | mapped_level=0; | |
535 | ||
536 | #if defined(LCM_TABLE_V3) | |
537 | // Refresh value of backlight level. | |
538 | lcm_backlight_level_setting_V3[0].para_list[0] = mapped_level; | |
539 | ||
540 | dsi_set_cmdq_V3(lcm_backlight_level_setting_V3, sizeof(lcm_backlight_level_setting_V3) / sizeof(LCM_setting_table_V3), 1); | |
541 | #else | |
542 | // Refresh value of backlight level. | |
543 | lcm_backlight_level_setting[0].para_list[0] = mapped_level; | |
544 | ||
545 | push_table(lcm_backlight_level_setting, sizeof(lcm_backlight_level_setting) / sizeof(struct LCM_setting_table), 1); | |
546 | #endif | |
547 | ||
548 | } | |
549 | ||
550 | static unsigned int lcm_esd_check(void) | |
551 | { | |
552 | #ifndef BUILD_UBOOT | |
553 | if(lcm_esd_test) | |
554 | { | |
555 | lcm_esd_test = FALSE; | |
556 | return TRUE; | |
557 | } | |
558 | ||
559 | /// please notice: the max return packet size is 1 | |
560 | /// if you want to change it, you can refer to the following marked code | |
561 | /// but read_reg currently only support read no more than 4 bytes.... | |
562 | /// if you need to read more, please let BinHan knows. | |
563 | /* | |
564 | unsigned int data_array[16]; | |
565 | unsigned int max_return_size = 1; | |
566 | ||
567 | data_array[0]= 0x00003700 | (max_return_size << 16); | |
568 | ||
569 | dsi_set_cmdq(&data_array, 1, 1); | |
570 | */ | |
571 | ||
572 | if(read_reg(0xB6) == 0x42) | |
573 | { | |
574 | return FALSE; | |
575 | } | |
576 | else | |
577 | { | |
578 | return TRUE; | |
579 | } | |
580 | #endif | |
581 | } | |
582 | ||
583 | static unsigned int lcm_esd_recover(void) | |
584 | { | |
585 | unsigned char para = 0; | |
586 | ||
587 | SET_RESET_PIN(1); | |
588 | SET_RESET_PIN(0); | |
589 | MDELAY(1); | |
590 | SET_RESET_PIN(1); | |
591 | MDELAY(120); | |
592 | #if defined(LCM_TABLE_V3) | |
593 | dsi_set_cmdq_V3(lcm_initialization_setting_V3, sizeof(lcm_initialization_setting_V3) / sizeof(LCM_setting_table_V3), 1); | |
594 | #else | |
595 | push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1); | |
596 | #endif | |
597 | MDELAY(10); | |
598 | #if defined(LCM_TABLE_V3) | |
599 | dsi_set_cmdq_V3(lcm_sleep_out_setting_V3, sizeof(lcm_sleep_out_setting_V3) / sizeof(LCM_setting_table_V3), 1); | |
600 | #else | |
601 | push_table(lcm_sleep_out_setting, sizeof(lcm_sleep_out_setting) / sizeof(struct LCM_setting_table), 1); | |
602 | #endif | |
603 | MDELAY(10); | |
604 | dsi_set_cmdq_V2(0x35, 1, ¶, 1); ///enable TE | |
605 | MDELAY(10); | |
606 | ||
607 | return TRUE; | |
608 | } | |
609 | ||
610 | static unsigned int lcm_compare_id(void) | |
611 | { | |
612 | unsigned int id = 0; | |
613 | unsigned char buffer[2]; | |
614 | unsigned int array[16]; | |
615 | SET_RESET_PIN(1); //NOTE:should reset LCM firstly | |
616 | SET_RESET_PIN(0); | |
617 | MDELAY(1); | |
618 | SET_RESET_PIN(1); | |
619 | MDELAY(10); | |
620 | ||
621 | #if defined(LCM_TABLE_V3) | |
622 | dsi_set_cmdq_V3(lcm_compare_id_setting_V3, sizeof(lcm_compare_id_setting_V3) / sizeof(LCM_setting_table_V3), 1); | |
623 | #else | |
624 | push_table(lcm_compare_id_setting, sizeof(lcm_compare_id_setting) / sizeof(struct LCM_setting_table), 1); | |
625 | #endif | |
626 | ||
627 | array[0] = 0x00023700;// read id return two byte,version and id | |
628 | dsi_set_cmdq(array, 1, 1); | |
629 | // id = read_reg(0xF4); | |
630 | read_reg_v2(0xF4, buffer, 2); | |
631 | id = buffer[0]; //we only need ID | |
632 | #if defined(BUILD_UBOOT) | |
633 | printf("%s, id1 = 0x%08x\n", __func__, id); | |
634 | #endif | |
635 | return (LCM_ID == id)?1:0; | |
636 | } | |
637 | // --------------------------------------------------------------------------- | |
638 | // Get LCM Driver Hooks | |
639 | // --------------------------------------------------------------------------- | |
640 | LCM_DRIVER hx8369_dsi_6575_lcm_drv = | |
641 | { | |
642 | .name = "hx8369_dsi_6575", | |
643 | .set_util_funcs = lcm_set_util_funcs, | |
644 | .get_params = lcm_get_params, | |
645 | .init = lcm_init, | |
646 | .suspend = lcm_suspend, | |
647 | .resume = lcm_resume, | |
648 | #if (LCM_DSI_CMD_MODE) | |
649 | .update = lcm_update, | |
650 | .set_backlight = lcm_setbacklight, | |
651 | // .set_pwm = lcm_setpwm, | |
652 | // .get_pwm = lcm_getpwm, | |
653 | .esd_check = lcm_esd_check, | |
654 | .esd_recover = lcm_esd_recover, | |
655 | .compare_id = lcm_compare_id, | |
656 | #endif | |
657 | }; |