import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / lcm / hx8369b_dsi_vdo / hx8369b_dsi_vdo.c
1 #ifdef BUILD_LK
2 #else
3 #include <linux/string.h>
4 #if defined(BUILD_UBOOT)
5 #include <asm/arch/mt6577_gpio.h>
6 #else
7 #include <mach/mt6577_gpio.h>
8 #endif
9 #endif
10 #include "lcm_drv.h"
11
12 // ---------------------------------------------------------------------------
13 // Local Constants
14 // ---------------------------------------------------------------------------
15
16 #define FRAME_WIDTH (480)
17 #define FRAME_HEIGHT (800)
18
19 #define REGFLAG_DELAY 0XAA
20 #define REGFLAG_END_OF_TABLE 0xAB // END OF REGISTERS MARKER
21
22 #define LCM_DSI_CMD_MODE 0
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 #define LCM_ID1 (0x90)
35 #define LCM_ID2 (0x69)
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 static struct LCM_setting_table {
62 unsigned cmd;
63 unsigned char count;
64 unsigned char para_list[128];
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
86 {0x39, 0xB1, 10, {0x12, 0x83, 0x77, 0x00,
87 0x8F, 0x0F, 0x1A, 0x1A,
88 0x0C, 0x0A}},
89
90 {0x39, 0xB2, 3, {0x00, 0x10, 0x02}},
91
92 {0x39, 0xB3, 4, {0x83, 0x00, 0x31, 0x03}},
93
94 {0x15, 0xB4, 1, {0x42}},
95
96 {0x39, 0xB6, 2, {0x7F, 0x7F}},
97
98 {0x39, 0xE3, 4, {0x01, 0x01, 0x01, 0x01}},
99
100 {0x39, 0xC0, 6, {0x73, 0x50, 0x00, 0x3C,
101 0xC4, 0x00}},
102
103 {0x15, 0xCC, 1, {0x00}},
104
105 #if 1
106 {0x39, 0xD5, 92, {0x00, 0x00, 0x10, 0x00,
107 0x00, 0x00, 0x00, 0x12,
108 0x30, 0x00, 0x00, 0x00,
109 0x01, 0x70, 0x33, 0x00,
110 0x00, 0x12, 0x20, 0x60,
111 0x37, 0x00, 0x00, 0x03,
112 0x00, 0x00, 0x00, 0x00,
113 0x00, 0x03, 0x00, 0x00,
114 0x03, 0x00, 0x00, 0x0B,
115 0x00, 0x00, 0x00, 0x00,
116 0x00, 0x00, 0x00, 0x00,
117 0x00, 0x88, 0x88, 0x88,
118 0x88, 0x55, 0x77, 0x11,
119 0x33, 0x32, 0x00, 0x00,
120 0x00, 0x00, 0x00, 0x00,
121 0x00, 0x00, 0x00, 0x88,
122 0x88, 0x88, 0x88, 0x44,
123 0x66, 0x00, 0x22, 0x10,
124 0x00, 0x00, 0x00, 0x01,
125 0x00, 0x00, 0x00, 0x03,
126 0xAA, 0xFF, 0xFF, 0xFF,
127 0x03, 0xAA, 0xFF, 0xFF,
128 0xFF, 0x00, 0x01, 0x5A}},
129 #else
130 {0x39, 0xD5, 59, {0x00, 0x00, 0x10, 0x00,
131 0x00, 0x00, 0x00, 0x12,
132 0x30, 0x00, 0x00, 0x00,
133 0x01, 0x70, 0x33, 0x00,
134 0x00, 0x12, 0x20, 0x60,
135 0x37, 0x00, 0x00, 0x03,
136 0x00, 0x00, 0x00, 0x00,
137 0x00, 0x03, 0x00, 0x00,
138 0x03, 0x00, 0x00, 0x0B,
139 0x00, 0x00, 0x00, 0x00,
140 0x00, 0x00, 0x00, 0x00,
141 0x00, 0x88, 0x88, 0x88,
142 0x88, 0x55, 0x77, 0x11,
143 0x33, 0x32, 0x00, 0x00,
144 0x00, 0x00, 0x00}},
145
146 {0x39, 0xFD, 34, {
147 0xAA, 0x00,
148 0x00, 0x00, 0x00, 0x88,
149 0x88, 0x88, 0x88, 0x44,
150 0x66, 0x00, 0x22, 0x10,
151 0x00, 0x00, 0x00, 0x01,
152 0x00, 0x00, 0x00, 0x03,
153 0xAA, 0xFF, 0xFF, 0xFF,
154 0x03, 0xAA, 0xFF, 0xFF,
155 0xFF, 0x00, 0x01, 0x5A}},
156 #endif
157
158 {0x39, 0xE0, 35, {0x00, 0x0C, 0x00, 0x10,
159 0x14, 0x3C, 0x27, 0x34,
160 0x0C, 0x10, 0x11, 0x15,
161 0x18, 0x16, 0x16, 0x13,
162 0x18, 0x0C, 0x00, 0x0C,
163 0x10, 0x14, 0x3C, 0x27,
164 0x34, 0x0C, 0x10, 0x11,
165 0x15, 0x18, 0x16, 0x16,
166 0x13, 0x18, 0x01}},
167
168 {0x15, 0xEA, 1, {0x62}},
169
170 {0x15, 0x3A, 1, {0x77}},
171
172 {0x39, 0xBA, 15, {0x11, 0x00, 0x16, 0xC6,
173 0x00, 0x0A, 0x00, 0x10,
174 0x24, 0x02, 0x21, 0x21,
175 0x9A, 0x17, 0x1D}}
176 };
177
178
179 static LCM_setting_table_V3 lcm_sleep_out_setting_V3[] = {
180 // Sleep Out
181 {0x15, 0x11, 1, {0x00}},
182 {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 150, {}},
183
184 // Display ON
185 {0x15, 0x29, 1, {0x00}},
186 {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}
187
188 };
189
190
191 static LCM_setting_table_V3 lcm_deep_sleep_mode_in_setting_V3[] = {
192 // Display off sequence
193 {0x15, 0x28, 1, {0x00}},
194
195 // Sleep Mode On
196 {0x15, 0x10, 1, {0x00}}
197 };
198
199
200 static LCM_setting_table_V3 lcm_compare_id_setting_V3[] = {
201 // Display off sequence
202 {0x39, 0xB9, 3, {0xFF, 0x83, 0x69}},
203 {REGFLAG_ESCAPE_ID, REGFLAG_DELAY_MS_V3, 10, {}}
204 };
205
206
207 static LCM_setting_table_V3 lcm_backlight_level_setting_V3[] = {
208 {0x15, 0x51, 1, {0xFF}}
209 };
210
211
212 #else
213
214 static struct LCM_setting_table lcm_initialization_setting[] = {
215
216 /*
217 Note :
218
219 Data ID will depends on the following rule.
220
221 count of parameters > 1 => Data ID = 0x39
222 count of parameters = 1 => Data ID = 0x15
223 count of parameters = 0 => Data ID = 0x05
224
225 Structure Format :
226
227 {DCS command, count of parameters, {parameter list}}
228 {REGFLAG_DELAY, milliseconds of time, {}},
229
230 ...
231
232 Setting ending by predefined flag
233
234 {REGFLAG_END_OF_TABLE, 0x00, {}}
235 */
236
237 {0xB9, 3, {0xFF, 0x83, 0x69}},
238
239 {0xB1, 10, {0x12, 0x83, 0x77, 0x00,
240 0x8F, 0x0F, 0x1A, 0x1A,
241 0x0C, 0x0A}},
242
243 {0xB2, 3, {0x00, 0x10, 0x02}},
244
245 {0xB3, 4, {0x83, 0x00, 0x31, 0x03}},
246
247 {0xB4, 1, {0x42}},
248
249 {0xB6, 2, {0x7F, 0x7F}},
250
251 {0xE3, 4, {0x01, 0x01, 0x01, 0x01}},
252
253 {0xC0, 6, {0x73, 0x50, 0x00, 0x3C,
254 0xC4, 0x00}},
255
256 {0xCC, 1, {0x00}},
257
258 #if 1
259 {0xD5, 92, {0x00, 0x00, 0x10, 0x00,
260 0x00, 0x00, 0x00, 0x12,
261 0x30, 0x00, 0x00, 0x00,
262 0x01, 0x70, 0x33, 0x00,
263 0x00, 0x12, 0x20, 0x60,
264 0x37, 0x00, 0x00, 0x03,
265 0x00, 0x00, 0x00, 0x00,
266 0x00, 0x03, 0x00, 0x00,
267 0x03, 0x00, 0x00, 0x0B,
268 0x00, 0x00, 0x00, 0x00,
269 0x00, 0x00, 0x00, 0x00,
270 0x00, 0x88, 0x88, 0x88,
271 0x88, 0x55, 0x77, 0x11,
272 0x33, 0x32, 0x00, 0x00,
273 0x00, 0x00, 0x00, 0x00,
274 0x00, 0x00, 0x00, 0x88,
275 0x88, 0x88, 0x88, 0x44,
276 0x66, 0x00, 0x22, 0x10,
277 0x00, 0x00, 0x00, 0x01,
278 0x00, 0x00, 0x00, 0x03,
279 0xAA, 0xFF, 0xFF, 0xFF,
280 0x03, 0xAA, 0xFF, 0xFF,
281 0xFF, 0x00, 0x01, 0x5A}},
282 #else
283 {0xD5, 59, {0x00, 0x00, 0x10, 0x00,
284 0x00, 0x00, 0x00, 0x12,
285 0x30, 0x00, 0x00, 0x00,
286 0x01, 0x70, 0x33, 0x00,
287 0x00, 0x12, 0x20, 0x60,
288 0x37, 0x00, 0x00, 0x03,
289 0x00, 0x00, 0x00, 0x00,
290 0x00, 0x03, 0x00, 0x00,
291 0x03, 0x00, 0x00, 0x0B,
292 0x00, 0x00, 0x00, 0x00,
293 0x00, 0x00, 0x00, 0x00,
294 0x00, 0x88, 0x88, 0x88,
295 0x88, 0x55, 0x77, 0x11,
296 0x33, 0x32, 0x00, 0x00,
297 0x00, 0x00, 0x00}},
298
299 {0xFD, 34, {
300 0xAA, 0x00,
301 0x00, 0x00, 0x00, 0x88,
302 0x88, 0x88, 0x88, 0x44,
303 0x66, 0x00, 0x22, 0x10,
304 0x00, 0x00, 0x00, 0x01,
305 0x00, 0x00, 0x00, 0x03,
306 0xAA, 0xFF, 0xFF, 0xFF,
307 0x03, 0xAA, 0xFF, 0xFF,
308 0xFF, 0x00, 0x01, 0x5A}},
309 #endif
310
311 #if 0
312 {0xD5, 56, {0x00, 0x00, 0x10, 0x00,
313 0x00, 0x00, 0x00, 0x12,
314 0x30, 0x00, 0x00, 0x00,
315 0x01, 0x70, 0x33, 0x00,
316 0x00, 0x12, 0x20, 0x60,
317 0x37, 0x00, 0x00, 0x03,
318 0x00, 0x00, 0x00, 0x00,
319 0x00, 0x03, 0x00, 0x00,
320 0x03, 0x00, 0x00, 0x0B,
321 0x00, 0x00, 0x00, 0x00,
322 0x00, 0x00, 0x00, 0x00,
323 0x00, 0x88, 0x88, 0x88,
324 0x88, 0x55, 0x77, 0x11,
325 0x33, 0x32, 0x00, 0x00}},
326
327 {0xFD, 38, {0xAA, 0xAA,
328 0x00, 0x00, 0x00, 0x00,
329 0x00, 0x00, 0x00, 0x88,
330 0x88, 0x88, 0x88, 0x44,
331 0x66, 0x00, 0x22, 0x10,
332 0x00, 0x00, 0x00, 0x01,
333 0x00, 0x00, 0x00, 0x03,
334 0xAA, 0xFF, 0xFF, 0xFF,
335 0x03, 0xAA, 0xFF, 0xFF,
336 0xFF, 0x00, 0x01, 0x5A}},
337 #endif
338
339 {0xE0, 35, {0x00, 0x0C, 0x00, 0x10,
340 0x14, 0x3C, 0x27, 0x34,
341 0x0C, 0x10, 0x11, 0x15,
342 0x18, 0x16, 0x16, 0x13,
343 0x18, 0x0C, 0x00, 0x0C,
344 0x10, 0x14, 0x3C, 0x27,
345 0x34, 0x0C, 0x10, 0x11,
346 0x15, 0x18, 0x16, 0x16,
347 0x13, 0x18, 0x01}},
348
349 {0xEA, 1, {0x62}},
350
351 {0x3A, 1, {0x77}},
352
353 {0xBA, 15, {0x11, 0x00, 0x16, 0xC6,
354 0x00, 0x0A, 0x00, 0x10,
355 0x24, 0x02, 0x21, 0x21,
356 0x9A, 0x17, 0x1D}},
357
358 // Note
359 // Strongly recommend not to set Sleep out / Display On here. That will cause messed frame to be shown as later the backlight is on.
360
361
362 // Setting ending by predefined flag
363 {REGFLAG_END_OF_TABLE, 0x00, {}}
364 };
365
366
367 static struct LCM_setting_table lcm_set_window[] = {
368 {0x2A, 4, {0x00, 0x00, (FRAME_WIDTH>>8), (FRAME_WIDTH&0xFF)}},
369 {0x2B, 4, {0x00, 0x00, (FRAME_HEIGHT>>8), (FRAME_HEIGHT&0xFF)}},
370 {REGFLAG_END_OF_TABLE, 0x00, {}}
371 };
372
373
374 static struct LCM_setting_table lcm_sleep_out_setting[] = {
375 // Sleep Out
376 {0x11, 1, {0x00}},
377 {REGFLAG_DELAY, 150, {}},
378
379 // Display ON
380 {0x29, 1, {0x00}},
381 {REGFLAG_DELAY, 10, {}},
382 {REGFLAG_END_OF_TABLE, 0x00, {}}
383 };
384
385
386 static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
387 // Display off sequence
388 {0x28, 1, {0x00}},
389
390 // Sleep Mode On
391 {0x10, 1, {0x00}},
392
393 {REGFLAG_END_OF_TABLE, 0x00, {}}
394 };
395
396
397 static struct LCM_setting_table lcm_compare_id_setting[] = {
398 // Display off sequence
399 {0xB9, 3, {0xFF, 0x83, 0x69}},
400 {REGFLAG_DELAY, 10, {}},
401
402 // Sleep Mode On
403 // {0xC3, 1, {0xFF}},
404
405 {REGFLAG_END_OF_TABLE, 0x00, {}}
406 };
407
408
409 static struct LCM_setting_table lcm_backlight_level_setting[] = {
410 {0x51, 1, {0xFF}},
411 {REGFLAG_END_OF_TABLE, 0x00, {}}
412 };
413
414 #endif
415
416 static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
417 {
418 unsigned int i, j, k;
419 unsigned int para_int, read_int;
420 unsigned char buffer[256];
421
422 for(i = 0; i < count; i++) {
423
424 unsigned cmd;
425 cmd = table[i].cmd;
426
427 switch (cmd) {
428
429 case REGFLAG_DELAY :
430 MDELAY(table[i].count);
431 break;
432
433 case REGFLAG_END_OF_TABLE :
434 break;
435
436 default:
437 dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
438 #if 0
439 do {
440 read_int = read_reg(cmd);
441 para_int = *((unsigned int *)table[i].para_list);
442 printf("%s, compare = {%04x, %04x} \n", __func__, read_int, para_int);
443 } while(read_int != para_int);
444 #endif
445 }
446 }
447
448 #if 0//defined(BUILD_UBOOT)
449 int remain_bytes;
450 int r_byte_count;
451 unsigned int array[16];
452
453 for(i = 0; i < count; i++) {
454 if(table[i].cmd != REGFLAG_DELAY && table[i].cmd != REGFLAG_END_OF_TABLE)
455 {
456 remain_bytes = table[i].count;
457 j = 0;
458
459 do {
460 //printf("Read 0x%02x round %d. Remain %d bytes \n", table[i].cmd, j, remain_bytes);
461 r_byte_count = (remain_bytes > 8) ? 8 : remain_bytes;
462
463 array[0] = 0x00003700 | (r_byte_count<<16);// read id return two byte,version and id
464 dsi_set_cmdq(array, 1, 1);
465
466 if(j>0)
467 read_reg_v2(0xFD, (buffer + j*8), r_byte_count);
468 else
469 read_reg_v2(table[i].cmd, buffer, r_byte_count);
470
471 j++;
472 remain_bytes-=8;
473 } while(remain_bytes>0);
474
475 printf("0x%02X[%02d] => { ", table[i].cmd, table[i].count);
476 for(k = 0; k < table[i].count; k++)
477 {
478 if((k % 4 ) == 0 && k > 0)
479 printf("\n ", buffer[k]);
480 printf("0x%02X ", buffer[k]);
481 }
482 printf("} \n");
483
484 }
485 }
486 #endif
487
488 }
489
490
491 // ---------------------------------------------------------------------------
492 // LCM Driver Implementations
493 // ---------------------------------------------------------------------------
494
495 static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
496 {
497 memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
498 }
499
500
501 static void lcm_get_params(LCM_PARAMS *params)
502 {
503 memset(params, 0, sizeof(LCM_PARAMS));
504
505 params->type = LCM_TYPE_DSI;
506
507 params->width = FRAME_WIDTH;
508 params->height = FRAME_HEIGHT;
509
510 // enable tearing-free
511 params->dbi.te_mode = LCM_DBI_TE_MODE_DISABLED;
512 params->dbi.te_edge_polarity = LCM_POLARITY_RISING;
513
514 #if (LCM_DSI_CMD_MODE)
515 params->dsi.mode = CMD_MODE;
516 #else
517 params->dsi.mode = SYNC_PULSE_VDO_MODE;
518 #endif
519
520 // DSI
521 /* Command mode setting */
522 params->dsi.LANE_NUM = LCM_TWO_LANE;
523 //The following defined the fomat for data coming from LCD engine.
524 params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
525 params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
526 params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
527 params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
528
529 // Highly depends on LCD driver capability.
530 // Not support in MT6573
531 params->dsi.packet_size=256;
532
533 // Video mode setting
534 params->dsi.intermediat_buffer_num = 2;
535
536 params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
537 params->dsi.word_count=480*3;
538 #if 0
539 params->dsi.vertical_sync_active = 10;
540 params->dsi.vertical_backporch = 10;
541 params->dsi.vertical_frontporch = 10; // 2
542 params->dsi.vertical_active_line = FRAME_HEIGHT;
543
544 params->dsi.horizontal_sync_active = 50;
545 params->dsi.horizontal_backporch = 50;
546 params->dsi.horizontal_frontporch = 50;
547 params->dsi.horizontal_active_pixel = FRAME_WIDTH;
548 #else
549 params->dsi.vertical_sync_active = 4;
550 params->dsi.vertical_backporch = 17;
551 params->dsi.vertical_frontporch = 17; // 2
552 params->dsi.vertical_active_line = FRAME_HEIGHT;
553
554 params->dsi.horizontal_sync_active = 17;
555 params->dsi.horizontal_backporch = 49;
556 params->dsi.horizontal_frontporch = 57;
557 params->dsi.horizontal_active_pixel = FRAME_WIDTH;
558 #endif
559 // Bit rate calculation
560 params->dsi.pll_div1=28; // fref=26MHz, fvco=fref*(div1+1) (div1=0~63, fvco=500MHZ~1GHz)
561 params->dsi.pll_div2=1; // div2=0~15: fout=fvo/(2*div2)
562
563 /* ESD or noise interference recovery For video mode LCM only. */
564 // Send TE packet to LCM in a period of n frames and check the response.
565 params->dsi.lcm_int_te_monitor = FALSE;
566 params->dsi.lcm_int_te_period = 1; // Unit : frames
567
568 // Need longer FP for more opportunity to do int. TE monitor applicably.
569 if(params->dsi.lcm_int_te_monitor)
570 params->dsi.vertical_frontporch *= 2;
571
572 // Monitor external TE (or named VSYNC) from LCM once per 2 sec. (LCM VSYNC must be wired to baseband TE pin.)
573 params->dsi.lcm_ext_te_monitor = FALSE;
574 // Non-continuous clock
575 params->dsi.noncont_clock = TRUE;
576 params->dsi.noncont_clock_period = 2; // Unit : frames
577
578 }
579
580
581 static void lcm_init(void)
582 {
583 unsigned char buffer[10];
584 unsigned int array[16];
585
586 SET_RESET_PIN(1);
587 SET_RESET_PIN(0);
588 MDELAY(1);
589 SET_RESET_PIN(1);
590 MDELAY(10);
591
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 }
598
599
600 static void lcm_suspend(void)
601 {
602 #if defined(LCM_TABLE_V3)
603 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);
604 #else
605 push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
606 #endif
607 SET_RESET_PIN(0);
608 MDELAY(1);
609 SET_RESET_PIN(1);
610 }
611
612
613 static void lcm_resume(void)
614 {
615 lcm_init();
616
617 #if defined(LCM_TABLE_V3)
618 dsi_set_cmdq_V3(lcm_sleep_out_setting_V3, sizeof(lcm_sleep_out_setting_V3) / sizeof(LCM_setting_table_V3), 1);
619 #else
620 push_table(lcm_sleep_out_setting, sizeof(lcm_sleep_out_setting) / sizeof(struct LCM_setting_table), 1);
621 #endif
622 }
623
624
625 static void lcm_update(unsigned int x, unsigned int y,
626 unsigned int width, unsigned int height)
627 {
628 unsigned int x0 = x;
629 unsigned int y0 = y;
630 unsigned int x1 = x0 + width - 1;
631 unsigned int y1 = y0 + height - 1;
632
633 unsigned char x0_MSB = ((x0>>8)&0xFF);
634 unsigned char x0_LSB = (x0&0xFF);
635 unsigned char x1_MSB = ((x1>>8)&0xFF);
636 unsigned char x1_LSB = (x1&0xFF);
637 unsigned char y0_MSB = ((y0>>8)&0xFF);
638 unsigned char y0_LSB = (y0&0xFF);
639 unsigned char y1_MSB = ((y1>>8)&0xFF);
640 unsigned char y1_LSB = (y1&0xFF);
641
642 unsigned int data_array[16];
643
644 data_array[0]= 0x00053902;
645 data_array[1]= (x1_MSB<<24)|(x0_LSB<<16)|(x0_MSB<<8)|0x2a;
646 data_array[2]= (x1_LSB);
647 data_array[3]= 0x00053902;
648 data_array[4]= (y1_MSB<<24)|(y0_LSB<<16)|(y0_MSB<<8)|0x2b;
649 data_array[5]= (y1_LSB);
650 data_array[6]= 0x002c3909;
651
652 dsi_set_cmdq(&data_array, 7, 0);
653
654 }
655
656 #if 0
657 static void lcm_setbacklight(unsigned int level)
658 {
659 unsigned int default_level = 145;
660 unsigned int mapped_level = 0;
661
662 //for LGE backlight IC mapping table
663 if(level > 255)
664 level = 255;
665
666 if(level >0)
667 mapped_level = default_level+(level)*(255-default_level)/(255);
668 else
669 mapped_level=0;
670
671 // Refresh value of backlight level.
672 lcm_backlight_level_setting[0].para_list[0] = mapped_level;
673
674 push_table(lcm_backlight_level_setting, sizeof(lcm_backlight_level_setting) / sizeof(struct LCM_setting_table), 1);
675 }
676 #endif
677
678 static void lcm_setpwm(unsigned int divider)
679 {
680 // TBD
681 }
682
683
684 static unsigned int lcm_getpwm(unsigned int divider)
685 {
686 // ref freq = 15MHz, B0h setting 0x80, so 80.6% * freq is pwm_clk;
687 // pwm_clk / 255 / 2(lcm_setpwm() 6th params) = pwm_duration = 23706
688 unsigned int pwm_clk = 23706 / (1<<divider);
689 return pwm_clk;
690 }
691
692 static unsigned int lcm_compare_id(void)
693 {
694 unsigned int id1, id2;
695 unsigned char buffer[2];
696 unsigned int array[16];
697
698 //push_table(lcm_compare_id_setting, sizeof(lcm_compare_id_setting) / sizeof(struct LCM_setting_table), 1);
699 lcm_init();
700
701 array[0] = 0x00013700;// read id return two byte,version and id
702 dsi_set_cmdq(array, 1, 1);
703 id1 = read_reg(0xDA);
704 id2 = read_reg(0xDB);
705
706 #if defined(BUILD_UBOOT)
707 printf("%s, id1 = 0x%02x, id2 = 0x%02x \n", __func__, id1, id2);
708 #endif
709
710 return (LCM_ID1 == id1 && LCM_ID2 == id2 ) ? 1 : 0;
711 }
712
713 LCM_DRIVER hx8369b_dsi_vdo_lcm_drv =
714 {
715 .name = "hx8369b_dsi_vdo",
716 .set_util_funcs = lcm_set_util_funcs,
717 .get_params = lcm_get_params,
718 .init = lcm_init,
719 .suspend = lcm_suspend,
720 .resume = lcm_resume,
721 .compare_id = lcm_compare_id,
722 #if (LCM_DSI_CMD_MODE)
723 .update = lcm_update,
724 #endif
725 };
726