import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / lcm / otm1282a_hd720_dsi_vdo_60hz / otm1282a_hd720_dsi_vdo_60hz.c
CommitLineData
6fa3eb70
S
1#ifndef BUILD_LK
2#include <linux/string.h>
3#endif
4
5#include "lcm_drv.h"
6
7#ifdef BUILD_LK
8 #include <platform/mt_gpio.h>
9 #include <string.h>
10#elif defined(BUILD_UBOOT)
11 #include <asm/arch/mt_gpio.h>
12#else
13 #include <mach/mt_gpio.h>
14#endif
15// ---------------------------------------------------------------------------
16// Local Constants
17// ---------------------------------------------------------------------------
18
19#define LCM_ID (0x69)
20#define REGFLAG_DELAY 0XFE
21#define REGFLAG_END_OF_TABLE 0XFD // END OF REGISTERS MARKER
22
23#define LCM_ID_OTM1282A (0x90)
24
25
26#if 0
27#ifndef TRUE
28 #define TRUE 1
29#endif
30
31#ifndef FALSE
32 #define FALSE 0
33#endif
34
35static unsigned int lcm_esd_test = FALSE; ///only for ESD test
36#endif
37
38#define LCM_DSI_CMD_MODE 0
39
40#define FRAME_WIDTH (720)
41#define FRAME_HEIGHT (1280)
42
43// ---------------------------------------------------------------------------
44// Local Variables
45// ---------------------------------------------------------------------------
46
47static LCM_UTIL_FUNCS lcm_util;
48
49#define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
50
51#define UDELAY(n) (lcm_util.udelay(n))
52#define MDELAY(n) (lcm_util.mdelay(n))
53
54
55// ---------------------------------------------------------------------------
56// Local Functions
57// ---------------------------------------------------------------------------
58
59#define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
60#define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
61#define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
62#define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
63#define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
64#define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
65
66static unsigned int need_set_lcm_addr = 1;
67struct LCM_setting_table {
68 unsigned char cmd;
69 unsigned char count;
70 unsigned char para_list[64];
71};
72
73static struct LCM_setting_table lcm_vdo_initialization_setting[] = {
74 {0xff, 3, {0x12,0x82,0x01}},
75 {0x00, 1, {0x80}},
76 {0xff, 2, {0x12,0x82}},
77 {0x00, 1, {0x00}},
78 {0x1C, 1, {0x02}},
79/*
80 {0x00, 1, {0x80}},
81 {0xa4, 1, {0xa8}},
82 {0x00, 1, {0x80}},
83 {0xc0, 14, {0x00, 0x60, 0x00, 0x02, 0x04, 0x00, 0x60, 0x02, 0x04, 0x00, 0x60, 0x00, 0x02, 0x04}},
84 {0x00, 1, {0xc0}},
85 {0xc5, 2, {0x12, 0xfa}},
86 {0x00, 1, {0x80}},
87 {0xa5, 3, {0x0c, 0x44, 0x12}},
88*/
89
90 {0x00, 1, {0xa0}},
91 {0xc1, 3, {0xe0, 0xe0, 0x10}},
92
93 // Sleep Out
94 {0x11, 1, {0x00}},
95 {REGFLAG_DELAY, 120, {}},
96
97 // Display ON
98 {0x29, 1, {0x00}},
99 {REGFLAG_END_OF_TABLE, 0x00, {}}
100};
101
102static struct LCM_setting_table lcm_sleep_out_setting[] = {
103 // Sleep Out
104 {0x11, 1, {0x00}},
105 {REGFLAG_DELAY, 120, {}},
106
107 // Display ON
108 {0x29, 1, {0x00}},
109 {REGFLAG_END_OF_TABLE, 0x00, {}}
110};
111
112
113static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
114 // Display off sequence
115 {0x28, 1, {0x00}},
116
117 // Sleep Mode On
118 {0x10, 1, {0x00}},
119
120
121 {REGFLAG_END_OF_TABLE, 0x00, {}}
122};
123
124/*
125static struct LCM_setting_table lcm_compare_id_setting[] = {
126 // Display off sequence
127 {0xB9, 3, {0xFF, 0x83, 0x69}},
128 {REGFLAG_DELAY, 10, {}},
129
130 // Sleep Mode On
131// {0xC3, 1, {0xFF}},
132
133 {REGFLAG_END_OF_TABLE, 0x00, {}}
134};
135*/
136#if 0
137static struct LCM_setting_table lcm_backlight_level_setting[] = {
138 {0x51, 1, {0xFF}},
139 {REGFLAG_END_OF_TABLE, 0x00, {}}
140};
141#endif
142
143#if 0
144// 120 hz
145static unsigned char od_table_33x33[] =
146{
1470,11,21,31,44,57,71,86,99,111,122,132,141,151,160,168,175,183,190,197,203,209,216,222,228,234,239,245,251,255,255,255,255,
1480,8,18,28,41,54,68,81,95,107,118,128,139,148,156,164,173,181,188,194,202,208,214,221,227,233,238,244,250,255,255,255,255,
1490,5,16,25,38,50,65,77,90,103,115,125,136,145,153,162,171,178,186,192,200,206,213,219,226,232,237,243,249,255,255,255,255,
1500,2,13,24,35,47,61,73,86,100,111,122,133,142,151,159,168,176,184,190,198,205,211,218,224,231,237,243,249,255,255,255,255,
1510,0,10,21,32,44,56,69,83,96,107,119,130,139,148,157,166,174,182,190,196,203,210,217,223,229,236,242,248,254,255,255,255,
1520,0,7,18,29,40,52,65,78,91,103,115,125,135,145,154,162,171,179,187,193,201,208,215,221,228,235,241,247,254,255,255,255,
1530,0,4,15,25,36,48,60,73,86,98,110,120,131,142,151,159,168,176,185,191,199,206,213,219,227,234,240,246,253,255,255,255,
1540,0,1,12,22,33,44,56,68,81,93,105,116,128,138,148,156,166,174,182,189,197,205,212,218,226,232,239,246,252,255,255,255,
1550,0,0,9,19,29,41,52,64,76,88,101,113,125,135,144,154,163,171,179,188,195,203,210,217,224,231,238,245,252,255,255,255,
1560,0,0,7,16,26,38,48,60,72,84,96,108,120,130,141,151,159,169,177,186,193,201,209,216,223,230,237,244,251,255,255,255,
1570,0,0,4,14,24,35,45,56,67,80,92,104,116,126,138,148,156,166,175,184,191,200,207,214,221,229,236,243,250,255,255,255,
1580,0,0,2,12,21,32,41,52,63,76,88,100,112,123,134,144,153,164,173,182,189,198,206,213,220,228,235,242,249,255,255,255,
1590,0,0,0,9,18,28,38,49,59,71,84,96,108,119,130,141,151,161,170,179,188,196,204,212,219,227,234,241,249,255,255,255,
1600,0,0,0,7,16,25,36,45,56,68,79,92,104,116,127,138,148,157,168,177,186,194,203,211,219,226,234,241,248,255,255,255,
1610,0,0,0,4,13,23,33,42,52,64,75,87,100,112,124,135,145,155,166,175,184,192,202,210,218,226,233,240,247,254,255,255,
1620,0,0,0,1,11,20,30,39,49,60,70,83,95,108,120,131,142,152,163,173,182,190,200,209,218,226,233,240,247,254,255,255,
1630,0,0,0,0,8,18,27,37,46,55,66,78,91,103,116,128,139,150,161,171,180,190,199,208,217,226,232,239,246,253,255,255,
1640,0,0,0,0,6,15,24,34,43,52,63,75,86,99,111,124,136,147,158,168,178,188,197,207,216,225,232,239,246,253,255,255,
1650,0,0,0,0,4,12,21,31,39,49,60,71,82,95,107,119,132,144,156,166,176,186,196,205,215,224,231,238,245,252,255,255,
1660,0,0,0,0,2,10,18,28,36,46,56,67,78,90,103,115,128,140,152,163,173,184,194,204,214,224,231,238,245,252,255,255,
1670,0,0,0,0,0,8,16,24,33,42,52,62,74,86,98,111,123,136,148,160,171,181,192,202,212,222,230,237,244,251,255,255,
1680,0,0,0,0,0,5,13,21,31,40,48,58,70,82,94,106,119,131,144,156,168,179,189,200,210,219,229,236,243,251,255,255,
1690,0,0,0,0,0,3,11,19,28,36,45,54,66,77,89,102,115,127,140,152,165,176,187,197,208,216,227,235,242,250,255,255,
1700,0,0,0,0,0,1,8,16,25,33,41,51,61,72,85,98,111,124,136,149,161,172,184,195,205,214,225,233,241,249,255,255,
1710,0,0,0,0,0,0,6,13,21,28,37,47,56,68,80,94,107,120,132,145,157,169,180,192,203,213,224,232,240,248,255,255,
1720,0,0,0,0,0,0,3,11,18,25,35,44,52,64,76,88,101,115,127,141,153,165,176,187,200,211,222,230,238,246,255,255,
1730,0,0,0,0,0,0,1,8,15,22,32,40,48,59,71,83,96,110,122,136,149,161,172,183,193,208,220,228,236,245,253,255,
1740,0,0,0,0,0,0,0,5,12,19,28,35,44,55,65,77,90,104,118,132,145,157,169,179,189,202,216,226,235,243,252,255,
1750,0,0,0,0,0,0,0,2,9,16,23,30,40,50,59,72,85,99,113,127,140,154,165,175,185,196,210,224,233,242,250,255,
1760,0,0,0,0,0,0,0,0,5,12,19,26,36,45,54,66,78,91,105,120,134,148,159,169,183,194,208,221,232,241,250,255,
1770,0,0,0,0,0,0,0,0,1,8,15,22,31,39,48,60,71,84,98,112,127,142,153,165,180,192,205,218,230,240,249,255,
1780,0,0,0,0,0,0,0,0,0,4,11,18,26,34,42,53,64,77,91,105,120,135,148,161,177,190,203,216,227,238,248,255,
1790,0,0,0,0,0,0,0,0,0,1,8,15,21,28,37,48,58,70,84,99,114,130,144,158,173,188,201,213,225,235,246,255,
180};
181#else
182// 60 hz
183static unsigned char od_table_33x33[] =
184{
1850,9,18,26,36,46,56,66,76,86,95,105,114,123,132,140,148,155,163,170,177,185,192,200,208,216,223,230,236,242,248,254,255,
1860,8,17,26,35,45,55,65,75,84,94,104,113,122,131,139,147,155,162,169,177,184,192,199,207,215,222,229,236,242,248,254,255,
1870,8,16,25,34,44,53,63,73,83,92,103,112,121,129,137,146,154,161,169,176,183,191,198,207,215,220,229,235,241,248,254,255,
1880,7,16,24,33,42,52,61,71,82,91,101,110,119,128,136,144,153,161,168,175,182,190,198,206,214,220,229,235,241,247,254,255,
1890,7,15,24,32,41,50,59,69,80,91,100,109,118,127,135,143,152,160,167,174,182,189,197,205,213,221,228,234,241,247,253,255,
1900,7,15,23,31,40,49,58,68,78,89,98,107,116,125,134,142,150,158,166,173,181,188,196,204,212,221,228,234,240,247,253,255,
1910,6,14,22,29,39,48,57,67,77,87,96,106,115,123,132,140,149,156,165,172,180,187,195,203,212,220,227,234,240,247,253,255,
1920,6,13,21,28,37,47,56,65,75,85,95,104,113,122,131,139,147,155,164,171,179,186,194,202,211,219,227,233,240,246,253,255,
1930,5,13,20,27,36,45,55,64,74,84,94,103,111,120,129,138,146,155,163,170,178,185,193,202,210,219,226,233,239,246,253,255,
1940,4,11,19,26,35,44,53,63,72,82,92,101,110,119,127,136,145,154,162,169,177,185,193,201,209,218,226,232,239,246,252,255,
1950,3,10,18,25,33,43,52,61,71,80,90,99,108,117,126,135,144,152,161,169,176,184,192,200,209,217,225,232,239,246,252,255,
1960,1,9,17,24,32,42,51,60,69,79,88,98,107,116,125,134,143,151,160,168,176,184,191,200,208,216,224,231,238,245,252,255,
1970,0,8,16,24,32,40,49,58,68,77,86,96,105,115,124,133,142,150,159,167,175,183,191,199,207,216,224,231,238,245,252,255,
1980,0,7,15,23,32,40,49,57,67,76,85,94,104,113,123,132,140,149,157,166,174,182,190,199,207,215,222,230,238,245,252,255,
1990,0,6,15,23,31,39,48,56,66,74,83,93,102,112,121,130,139,148,156,165,174,182,190,198,206,214,222,230,237,245,252,255,
2000,0,6,14,22,31,39,47,55,64,73,82,91,100,110,120,129,138,147,155,164,173,181,189,198,206,214,221,229,237,244,252,255,
2010,0,5,13,22,30,38,46,54,62,71,80,89,99,108,118,128,137,146,155,164,172,180,189,197,205,213,221,229,236,244,251,255,
2020,0,4,13,21,29,37,45,53,61,69,79,88,97,107,117,126,136,145,154,163,171,180,188,196,204,213,221,229,236,244,251,255,
2030,0,4,12,20,27,35,43,51,59,68,77,86,96,105,115,125,135,144,153,162,170,179,187,196,204,212,220,228,236,243,251,255,
2040,0,3,11,19,26,34,42,50,58,66,75,85,94,104,114,123,133,143,152,161,169,178,186,195,203,211,220,228,235,243,250,255,
2050,0,3,10,18,25,33,41,48,56,64,73,83,92,102,112,122,132,141,151,160,169,177,186,194,202,211,219,227,235,243,250,255,
2060,0,2,9,17,24,32,39,47,55,64,72,81,91,101,111,120,130,140,149,159,168,177,185,194,202,210,219,227,235,242,250,255,
2070,0,1,8,16,23,31,38,46,53,63,70,80,89,99,109,119,129,138,148,157,167,176,185,193,202,210,218,227,234,242,250,255,
2080,0,0,7,15,22,30,37,45,52,61,69,78,88,98,108,118,127,137,147,156,165,175,184,193,201,210,218,226,234,242,250,255,
2090,0,0,6,13,21,28,36,43,51,59,67,77,86,96,106,116,126,136,145,155,164,173,183,192,201,209,218,226,234,242,250,255,
2100,0,0,5,12,20,27,35,42,50,57,67,75,85,95,105,115,125,134,144,154,163,172,181,191,200,209,217,225,233,241,249,255,
2110,0,0,4,11,19,26,34,41,49,56,66,74,83,93,103,113,123,133,143,152,162,171,180,189,199,208,217,225,233,241,249,255,
2120,0,0,3,10,18,25,33,40,48,55,64,72,82,92,101,111,121,131,141,151,161,170,179,188,197,207,216,224,232,240,248,255,
2130,0,0,2,9,17,24,32,39,47,54,61,71,80,90,100,110,120,130,140,150,160,169,178,187,196,205,215,224,232,240,248,255,
2140,0,0,0,8,15,23,30,37,45,52,60,70,78,88,98,108,118,128,138,148,158,167,176,185,195,204,213,223,232,240,248,255,
2150,0,0,0,7,14,21,29,36,43,50,58,68,76,86,96,106,116,126,137,147,156,166,175,184,193,202,212,222,231,240,248,255,
2160,0,0,0,5,12,20,27,34,41,49,56,65,74,84,94,104,115,125,135,145,154,164,173,182,191,201,211,220,230,239,248,255,
2170,0,0,0,4,11,18,25,32,40,47,54,62,71,82,92,103,113,123,133,143,153,163,172,181,189,199,209,219,229,238,247,255,
218};
219#endif
220
221
222static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
223{
224 unsigned int i;
225
226 for(i = 0; i < count; i++) {
227
228 unsigned cmd;
229 cmd = table[i].cmd;
230
231 switch (cmd) {
232
233 case REGFLAG_DELAY :
234 MDELAY(table[i].count);
235 break;
236
237 case REGFLAG_END_OF_TABLE :
238 break;
239
240 default:
241 dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
242 }
243
244 }
245
246}
247
248
249// ---------------------------------------------------------------------------
250// LCM Driver Implementations
251// ---------------------------------------------------------------------------
252
253static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
254{
255 memcpy((void*)&lcm_util, (void*)util, sizeof(LCM_UTIL_FUNCS));
256}
257
258
259static void lcm_get_params(LCM_PARAMS *params)
260{
261 memset((void*)params, 0, sizeof(LCM_PARAMS));
262
263 params->type = LCM_TYPE_DSI;
264
265 params->width = FRAME_WIDTH;
266 params->height = FRAME_HEIGHT;
267
268#if (LCM_DSI_CMD_MODE)
269 params->dsi.mode = CMD_MODE;
270#else
271 params->dsi.mode = BURST_VDO_MODE;
272#endif
273 // DSI
274 /* Command mode setting */
275 params->dsi.LANE_NUM = LCM_FOUR_LANE;
276
277 //The following defined the fomat for data coming from LCD engine.
278 params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
279 params->dsi.vertical_sync_active = 10;// 3 2
280 params->dsi.vertical_backporch = 10;// 20 1
281 params->dsi.vertical_frontporch = 10; // 1 12
282 params->dsi.vertical_active_line = FRAME_HEIGHT;
283
284 params->dsi.horizontal_sync_active = 2;// 50 2
285 params->dsi.horizontal_backporch = 30;
286 params->dsi.horizontal_frontporch = 30;
287 params->dsi.horizontal_active_pixel = FRAME_WIDTH;
288
289 params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
290 params->dsi.CLK_HS_POST=26;
291#ifndef CONFIG_MTK_FPGA
292 params->dsi.PLL_CLOCK = 200; //390 for 120fps//320;//dsi clock customization: should config clock value directly
293 params->dsi.ssc_disable = 1;
294#else
295 params->dsi.fbk_div = 0x10;
296 params->dsi.pll_div1 = 0x2;
297 params->dsi.pll_div2 = 0x2;
298#endif
299
300 params->od_table_size = 33 * 33;
301 params->od_table = (void*)&od_table_33x33;
302}
303
304static void lcm_init(void)
305{
306 SET_RESET_PIN(1);
307 SET_RESET_PIN(0);
308 MDELAY(10);
309 SET_RESET_PIN(1);
310 MDELAY(10);
311 push_table(lcm_vdo_initialization_setting, sizeof(lcm_vdo_initialization_setting) / sizeof(struct LCM_setting_table), 1);
312 need_set_lcm_addr = 1;
313}
314
315static void lcm_suspend(void)
316{
317 push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
318}
319
320
321static void lcm_resume(void)
322{
323
324 lcm_init();
325 push_table(lcm_sleep_out_setting, sizeof(lcm_sleep_out_setting) / sizeof(struct LCM_setting_table), 1);
326 need_set_lcm_addr = 1;
327}
328
329
330static void lcm_update(unsigned int x, unsigned int y,
331 unsigned int width, unsigned int height)
332{
333 unsigned int x0 = x;
334 unsigned int y0 = y;
335 unsigned int x1 = x0 + width - 1;
336 unsigned int y1 = y0 + height - 1;
337
338 unsigned char x0_MSB = ((x0>>8)&0xFF);
339 unsigned char x0_LSB = (x0&0xFF);
340 unsigned char x1_MSB = ((x1>>8)&0xFF);
341 unsigned char x1_LSB = (x1&0xFF);
342 unsigned char y0_MSB = ((y0>>8)&0xFF);
343 unsigned char y0_LSB = (y0&0xFF);
344 unsigned char y1_MSB = ((y1>>8)&0xFF);
345 unsigned char y1_LSB = (y1&0xFF);
346
347 unsigned int data_array[16];
348
349 // need update at the first time
350 if(need_set_lcm_addr)
351 {
352 data_array[0]= 0x00053902;
353 data_array[1]= (x1_MSB<<24)|(x0_LSB<<16)|(x0_MSB<<8)|0x2a;
354 data_array[2]= (x1_LSB);
355 dsi_set_cmdq(data_array, 3, 1);
356
357 data_array[0]= 0x00053902;
358 data_array[1]= (y1_MSB<<24)|(y0_LSB<<16)|(y0_MSB<<8)|0x2b;
359 data_array[2]= (y1_LSB);
360 dsi_set_cmdq(data_array, 3, 1);
361
362 need_set_lcm_addr = 0;
363 }
364
365 data_array[0]= 0x002c3909;
366 dsi_set_cmdq(data_array, 1, 0);
367
368}
369
370#if 0
371static unsigned int lcm_esd_check(void)
372{
373 #ifndef BUILD_LK
374 char buffer[3];
375 int array[4];
376
377 if(lcm_esd_test)
378 {
379 lcm_esd_test = FALSE;
380 return TRUE;
381 }
382
383 array[0] = 0x00013700;
384 dsi_set_cmdq(array, 1, 1);
385
386 read_reg_v2(0x36, buffer, 1);
387 printk("%s, xxh esd check, read 0xBA = 0x%08x\n", __func__, buffer[0]);
388
389 if(buffer[0]==0x90)
390 {
391 return FALSE;
392 }
393 else
394 {
395 return TRUE;
396 }
397 #endif
398
399}
400
401static unsigned int lcm_esd_recover(void)
402{
403 lcm_init();
404
405 return TRUE;
406}
407
408#endif
409
410static unsigned int lcm_compare_id(void)
411{
412 unsigned int id=0;
413 unsigned char buffer[2];
414 unsigned int array[16];
415
416 SET_RESET_PIN(1);
417 SET_RESET_PIN(0);
418 MDELAY(1);
419
420 SET_RESET_PIN(1);
421 MDELAY(20);
422
423 array[0] = 0x00023700;// read id return two byte,version and id
424 dsi_set_cmdq(array, 1, 1);
425
426 read_reg_v2(0xF4, buffer, 2);
427 id = buffer[0]; //we only need ID
428 #ifdef BUILD_LK
429 printf("%s, LK otm1282a debug: nt35590 id = 0x%08x\n", __func__, id);
430 #else
431 printk("%s, kernel otm1282a horse debug: otm1282a id = 0x%08x\n", __func__, id);
432 #endif
433
434 if(id == LCM_ID_OTM1282A)
435 return 1;
436 else
437 return 0;
438
439}
440
441#ifndef BUILD_LK
442static unsigned int lcm_esd_test = FALSE; ///only for ESD test
443#endif
444
445static unsigned int lcm_esd_check(void)
446{
447 #ifndef BUILD_LK
448 char buffer[3];
449 int array[4];
450 int ret = 0;
451
452 if(lcm_esd_test)
453 {
454 lcm_esd_test = FALSE;
455 return TRUE;
456 }
457
458 array[0] = 0x00013700;
459 dsi_set_cmdq(array, 1, 1);
460
461 read_reg_v2(0x0F, buffer, 1);
462 if(buffer[0] != 0xc0)
463 {
464 printk("[LCM ERROR] [0x0F]=0x%02x\n", buffer[0]);
465 ret++;
466 }
467
468 read_reg_v2(0x05, buffer, 1);
469 if(buffer[0] != 0x00)
470 {
471 printk("[LCM ERROR] [0x05]=0x%02x\n", buffer[0]);
472 ret++;
473 }
474
475 read_reg_v2(0x0A, buffer, 1);
476 if((buffer[0]&0xf)!=0x0C)
477 {
478 printk("[LCM ERROR] [0x0A]=0x%02x\n", buffer[0]);
479 ret++;
480 }
481
482 // return TRUE: need recovery
483 // return FALSE: No need recovery
484 if(ret)
485 {
486 return TRUE;
487 }
488 else
489 {
490 return FALSE;
491 }
492#else
493 return FALSE;
494 #endif
495}
496
497static unsigned int lcm_esd_recover(void)
498{
499 lcm_init();
500 lcm_resume();
501
502 return TRUE;
503}
504
505static unsigned int lcm_ata_check(unsigned char *buffer)
506{
507#ifndef BUILD_LK
508 unsigned int ret = 0;
509 unsigned int x0 = FRAME_WIDTH/4;
510 unsigned int x1 = FRAME_WIDTH*3/4;
511
512 unsigned char x0_MSB = ((x0>>8)&0xFF);
513 unsigned char x0_LSB = (x0&0xFF);
514 unsigned char x1_MSB = ((x1>>8)&0xFF);
515 unsigned char x1_LSB = (x1&0xFF);
516
517 unsigned int data_array[3];
518 unsigned char read_buf[4];
519 printk("ATA check size = 0x%x,0x%x,0x%x,0x%x\n",x0_MSB,x0_LSB,x1_MSB,x1_LSB);
520 data_array[0]= 0x0005390A;//HS packet
521 data_array[1]= (x1_MSB<<24)|(x0_LSB<<16)|(x0_MSB<<8)|0x2a;
522 data_array[2]= (x1_LSB);
523 dsi_set_cmdq(data_array, 3, 1);
524
525 data_array[0] = 0x00043700;// read id return two byte,version and id
526 dsi_set_cmdq(data_array, 1, 1);
527
528 read_reg_v2(0x2A, read_buf, 4);
529
530 if((read_buf[0] == x0_MSB) && (read_buf[1] == x0_LSB)
531 && (read_buf[2] == x1_MSB) && (read_buf[3] == x1_LSB))
532 ret = 1;
533 else
534 ret = 0;
535
536 x0 = 0;
537 x1 = FRAME_WIDTH - 1;
538
539 x0_MSB = ((x0>>8)&0xFF);
540 x0_LSB = (x0&0xFF);
541 x1_MSB = ((x1>>8)&0xFF);
542 x1_LSB = (x1&0xFF);
543
544 data_array[0]= 0x0005390A;//HS packet
545 data_array[1]= (x1_MSB<<24)|(x0_LSB<<16)|(x0_MSB<<8)|0x2a;
546 data_array[2]= (x1_LSB);
547 dsi_set_cmdq(data_array, 3, 1);
548 need_set_lcm_addr = 1;
549 return ret;
550#else
551 return 0;
552#endif
553}
554// ---------------------------------------------------------------------------
555// Get LCM Driver Hooks
556// ---------------------------------------------------------------------------
557LCM_DRIVER otm1282a_hd720_dsi_vdo_60hz_lcm_drv =
558{
559 .name = "otm1282a_hd720_dsi_vdo",
560 .set_util_funcs = lcm_set_util_funcs,
561 .get_params = lcm_get_params,
562 .init = lcm_init,
563 .suspend = lcm_suspend,
564 .resume = lcm_resume,
565 .compare_id = lcm_compare_id,
566 .ata_check = lcm_ata_check,
567 //.esd_check = lcm_esd_check,
568 //.esd_recover = lcm_esd_recover,
569#if (LCM_DSI_CMD_MODE)
570 .update = lcm_update,
571 //.set_backlight = lcm_setbacklight,
572// .set_pwm = lcm_setpwm,
573// .get_pwm = lcm_getpwm,
574#endif
575};