ili9881d_hdplus_vdo_haifei.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748
  1. #ifndef BUILD_LK
  2. #include <linux/string.h>
  3. #include <linux/wait.h>
  4. #endif
  5. #include "lcm_drv.h"
  6. #ifdef MTK_ROUND_CORNER_SUPPORT
  7. #include "data_rgba4444_roundedpattern.h"
  8. #endif
  9. // ---------------------------------------------------------------------------
  10. // Local Constantsq
  11. // ---------------------------------------------------------------------------
  12. #define FRAME_WIDTH (720)
  13. #define FRAME_HEIGHT (1560)
  14. #define LCM_DSI_CMD_MODE 0
  15. #ifndef TRUE
  16. #define TRUE 1
  17. #endif
  18. #ifndef FALSE
  19. #define FALSE 0
  20. #endif
  21. #define REGFLAG_DELAY 0XFE
  22. #define REGFLAG_END_OF_TABLE 0xFFF // END OF REGISTERS MARKER
  23. // static unsigned int lcm_esd_test = FALSE; ///only for ESD test
  24. // ---------------------------------------------------------------------------
  25. // Local Variables
  26. // ---------------------------------------------------------------------------
  27. static LCM_UTIL_FUNCS lcm_util = {0};
  28. #define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
  29. #define UDELAY(n) (lcm_util.udelay(n))
  30. #define MDELAY(n) (lcm_util.mdelay(n))
  31. // ---------------------------------------------------------------------------
  32. // Local Functions
  33. // ---------------------------------------------------------------------------
  34. #define dsi_set_cmdq_V3(para_tbl,size,force_update) lcm_util.dsi_set_cmdq_V3(para_tbl,size,force_update)
  35. #define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
  36. #define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
  37. #define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
  38. #define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
  39. #define read_reg(cmd) lcm_util.dsi_dcs_read_lcm_reg(cmd)
  40. #define read_reg_v2(cmd, buffer, buffer_size) lcm_util.dsi_dcs_read_lcm_reg_v2(cmd, buffer, buffer_size)
  41. struct LCM_setting_table {
  42. unsigned char cmd;
  43. unsigned char count;
  44. unsigned char para_list[100];
  45. };
  46. static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
  47. {
  48. unsigned int i;
  49. for(i = 0; i < count; i++)
  50. {
  51. unsigned cmd;
  52. cmd = table[i].cmd;
  53. switch (cmd)
  54. {
  55. case REGFLAG_DELAY :
  56. MDELAY(table[i].count);
  57. break;
  58. case REGFLAG_END_OF_TABLE :
  59. break;
  60. default:
  61. dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
  62. }
  63. }
  64. }
  65. static struct LCM_setting_table lcm_initialization_setting[] = {
  66. #if 1
  67. {0xFF,3,{0x98,0x81,0x03}},
  68. {0x01,1,{0x00}},
  69. {0x02,1,{0x00}},
  70. {0x03,1,{0x73}},
  71. {0x04,1,{0x00}},
  72. {0x05,1,{0x00}},
  73. {0x06,1,{0x08}},
  74. {0x07,1,{0x00}},
  75. {0x08,1,{0x00}},
  76. {0x09,1,{0x00}},
  77. {0x0a,1,{0x00}},
  78. {0x0b,1,{0x00}},
  79. {0x0c,1,{0x00}},
  80. {0x0d,1,{0x00}},
  81. {0x0e,1,{0x00}},
  82. {0x0f,1,{0x15}},
  83. {0x10,1,{0x15}},
  84. {0x11,1,{0x00}},
  85. {0x12,1,{0x00}},
  86. {0x13,1,{0x00}},
  87. {0x14,1,{0x00}},
  88. {0x15,1,{0x04}},
  89. {0x16,1,{0x00}},
  90. {0x17,1,{0x00}},
  91. {0x18,1,{0x04}},
  92. {0x19,1,{0x00}},
  93. {0x1a,1,{0x00}},
  94. {0x1b,1,{0x00}},
  95. {0x1c,1,{0x00}},
  96. {0x1d,1,{0x00}},
  97. {0x1e,1,{0x48}},
  98. {0x1f,1,{0x40}},
  99. {0x20,1,{0x06}},
  100. {0x21,1,{0x01}},
  101. {0x22,1,{0x06}},
  102. {0x23,1,{0x01}},
  103. {0x24,1,{0x00}},
  104. {0x25,1,{0x00}},
  105. {0x26,1,{0x00}},
  106. {0x27,1,{0x00}},
  107. {0x28,1,{0x73}},
  108. {0x29,1,{0x33}},
  109. {0x2a,1,{0x00}},
  110. {0x2b,1,{0x00}},
  111. {0x2c,1,{0x08}},
  112. {0x2d,1,{0x00}},
  113. {0x2e,1,{0x02}},
  114. {0x2f,1,{0x00}},
  115. {0x30,1,{0x00}},
  116. {0x31,1,{0x00}},
  117. {0x32,1,{0x12}},
  118. {0x33,1,{0x00}},
  119. {0x34,1,{0x04}},
  120. {0x35,1,{0x0a}},
  121. {0x36,1,{0x03}},
  122. {0x37,1,{0x08}},
  123. {0x38,1,{0x00}},
  124. {0x39,1,{0x31}},
  125. {0x3a,1,{0x01}},
  126. {0x3b,1,{0x40}},
  127. {0x3c,1,{0x00}},
  128. {0x3d,1,{0x01}},
  129. {0x3e,1,{0x00}},
  130. {0x3f,1,{0x00}},
  131. {0x40,1,{0x00}},
  132. {0x41,1,{0x88}},
  133. {0x42,1,{0x00}},
  134. {0x43,1,{0x40}},
  135. {0x44,1,{0x3F}},
  136. {0x45,1,{0x20}},
  137. {0x50,1,{0x01}},
  138. {0x51,1,{0x23}},
  139. {0x52,1,{0x45}},
  140. {0x53,1,{0x67}},
  141. {0x54,1,{0x89}},
  142. {0x55,1,{0xab}},
  143. {0x56,1,{0x01}},
  144. {0x57,1,{0x23}},
  145. {0x58,1,{0x45}},
  146. {0x59,1,{0x67}},
  147. {0x5a,1,{0x89}},
  148. {0x5b,1,{0xab}},
  149. {0x5c,1,{0xcd}},
  150. {0x5d,1,{0xef}},
  151. {0x5e,1,{0x00}},
  152. {0x5f,1,{0x06}},
  153. {0x60,1,{0x02}},
  154. {0x61,1,{0x02}},
  155. {0x62,1,{0x02}},
  156. {0x63,1,{0x0c}},
  157. {0x64,1,{0x0d}},
  158. {0x65,1,{0x0e}},
  159. {0x66,1,{0x0f}},
  160. {0x67,1,{0x00}},
  161. {0x68,1,{0x17}},
  162. {0x69,1,{0x07}},
  163. {0x6a,1,{0x02}},
  164. {0x6b,1,{0x02}},
  165. {0x6c,1,{0x02}},
  166. {0x6d,1,{0x02}},
  167. {0x6e,1,{0x02}},
  168. {0x6f,1,{0x02}},
  169. {0x70,1,{0x02}},
  170. {0x71,1,{0x02}},
  171. {0x72,1,{0x02}},
  172. {0x73,1,{0x16}},
  173. {0x74,1,{0x01}},
  174. {0x75,1,{0x06}},
  175. {0x76,1,{0x02}},
  176. {0x77,1,{0x02}},
  177. {0x78,1,{0x02}},
  178. {0x79,1,{0x0c}},
  179. {0x7a,1,{0x0d}},
  180. {0x7b,1,{0x0e}},
  181. {0x7c,1,{0x0f}},
  182. {0x7d,1,{0x00}},
  183. {0x7e,1,{0x17}},
  184. {0x7f,1,{0x07}},
  185. {0x80,1,{0x02}},
  186. {0x81,1,{0x02}},
  187. {0x82,1,{0x02}},
  188. {0x83,1,{0x02}},
  189. {0x84,1,{0x02}},
  190. {0x85,1,{0x02}},
  191. {0x86,1,{0x02}},
  192. {0x87,1,{0x02}},
  193. {0x88,1,{0x02}},
  194. {0x89,1,{0x16}},
  195. {0x8A,1,{0x01}},
  196. {0xFF,3,{0x98,0x81,0x04}},
  197. {0x68,1,{0xDB}},
  198. {0x70,1,{0x00}},
  199. {0x71,1,{0x00}},
  200. {0x66,1,{0x1E}},
  201. {0x82,1,{0x0A}},
  202. {0x84,1,{0x0A}},
  203. {0x85,1,{0x1D}},
  204. {0x32,1,{0xAC}},
  205. {0x8C,1,{0x80}},
  206. {0x3C,1,{0xF5}},
  207. {0x3A,1,{0x24}},
  208. {0xB5,1,{0x02}},
  209. {0x31,1,{0x25}},
  210. {0x88,1,{0x33}},
  211. {0xFF,3,{0x98,0x81,0x01}},
  212. {0x22,1,{0x0A}},
  213. {0x31,1,{0x00}},
  214. {0x50,1,{0x85}},
  215. {0x51,1,{0x85}},
  216. {0x53,1,{0x85}},
  217. {0x55,1,{0x77}},
  218. {0x60,1,{0x2B}},
  219. {0x61,1,{0x00}},
  220. {0x62,1,{0x19}},
  221. {0x63,1,{0x00}},
  222. {0x2E,1,{0x0E}},
  223. {0xF6,1,{0x01}},
  224. {0x2F,1,{0x00}},
  225. {0xA0,1,{0x08}},
  226. {0xA1,1,{0x17}},
  227. {0xA2,1,{0x23}},
  228. {0xA3,1,{0x12}},
  229. {0xA4,1,{0x14}},
  230. {0xA5,1,{0x27}},
  231. {0xA6,1,{0x1B}},
  232. {0xA7,1,{0x1D}},
  233. {0xA8,1,{0x82}},
  234. {0xA9,1,{0x1A}},
  235. {0xAA,1,{0x26}},
  236. {0xAB,1,{0x81}},
  237. {0xAC,1,{0x1F}},
  238. {0xAD,1,{0x22}},
  239. {0xAE,1,{0x56}},
  240. {0xAF,1,{0x29}},
  241. {0xB0,1,{0x2C}},
  242. {0xB1,1,{0x5D}},
  243. {0xB2,1,{0x6A}},
  244. {0xB3,1,{0x39}},
  245. {0xC0,1,{0x08}},
  246. {0xC1,1,{0x17}},
  247. {0xC2,1,{0x23}},
  248. {0xC3,1,{0x12}},
  249. {0xC4,1,{0x14}},
  250. {0xC5,1,{0x27}},
  251. {0xC6,1,{0x1B}},
  252. {0xC7,1,{0x1D}},
  253. {0xC8,1,{0x82}},
  254. {0xC9,1,{0x1A}},
  255. {0xCA,1,{0x26}},
  256. {0xCB,1,{0x81}},
  257. {0xCC,1,{0x1E}},
  258. {0xCD,1,{0x22}},
  259. {0xCE,1,{0x56}},
  260. {0xCF,1,{0x29}},
  261. {0xD0,1,{0x2C}},
  262. {0xD1,1,{0x5D}},
  263. {0xD2,1,{0x6A}},
  264. {0xD3,1,{0x39}},
  265. {0xFF,3,{0x98,0x81,0x00}},
  266. {0x35,1,{0x00}},
  267. #else
  268. {0xFF,1,{0x98,0x81,0x01}},
  269. {0x91,1,{0x00}},
  270. {0x92,1,{0x00}},
  271. {0x93,1,{0x73}},
  272. {0x94,1,{0x00}},
  273. {0x95,1,{0x00}},
  274. {0x96,1,{0x08}},
  275. {0x97,1,{0x00}},
  276. {0x98,1,{0x00}},
  277. {0x09,1,{0x00}},
  278. {0x0a,1,{0x00}},
  279. {0x0b,1,{0x00}},
  280. {0x0c,1,{0x00}},
  281. {0x0d,1,{0x00}},
  282. {0x0e,1,{0x00}},
  283. {0x0f,1,{0x20}},
  284. {0x10,1,{0x20}},
  285. {0x11,1,{0x00}},
  286. {0x12,1,{0x00}},
  287. {0x13,1,{0x02}},
  288. {0x14,1,{0x00}},
  289. {0x15,1,{0x08}},
  290. {0x16,1,{0x10}},
  291. {0x17,1,{0x00}},
  292. {0x18,1,{0x00}},
  293. {0x19,1,{0x00}},
  294. {0x1a,1,{0x00}},
  295. {0x1b,1,{0x00}},
  296. {0x1c,1,{0x00}},
  297. {0x1d,1,{0x00}},
  298. {0x1e,1,{0xC0}},
  299. {0x1f,1,{0x00}},
  300. {0x20,1,{0x06}},
  301. {0x21,1,{0x01}},
  302. {0x22,1,{0x00}},
  303. {0x23,1,{0x00}},
  304. {0x24,1,{0x00}},
  305. {0x25,1,{0x00}},
  306. {0x26,1,{0x00}},
  307. {0x27,1,{0x00}},
  308. {0x28,1,{0x33}},
  309. {0x29,1,{0x33}},
  310. {0x2a,1,{0x00}},
  311. {0x2b,1,{0x00}},
  312. {0x2c,1,{0x09}},
  313. {0x2d,1,{0x09}},
  314. {0x2e,1,{0x09}},
  315. {0x2f,1,{0x09}},
  316. {0x30,1,{0x00}},
  317. {0x31,1,{0x00}},
  318. {0x32,1,{0x02}},
  319. {0x33,1,{0x00}},
  320. {0x34,1,{0x00}},
  321. {0x35,1,{0x0A}},
  322. {0x36,1,{0x00}},
  323. {0x37,1,{0x08}},
  324. {0x38,1,{0x00}},
  325. {0x39,1,{0x07}},
  326. {0x3a,1,{0x00}},
  327. {0x3b,1,{0x00}},
  328. {0x3c,1,{0x00}},
  329. {0x40,1,{0x03}},
  330. {0x41,1,{0x20}},
  331. {0x42,1,{0x00}},
  332. {0x43,1,{0x40}},
  333. {0x44,1,{0x03}},
  334. {0x45,1,{0x00}},
  335. {0x46,1,{0x01}},
  336. {0x47,1,{0x08}},
  337. {0x48,1,{0x00}},
  338. {0x49,1,{0x00}},
  339. {0x4a,1,{0x00}},
  340. {0x4b,1,{0x00}},
  341. {0x4c,1,{0x28}},
  342. {0x4d,1,{0x22}},
  343. {0x4e,1,{0x8A}},
  344. {0x4f,1,{0x46}},
  345. {0x50,1,{0x70}},
  346. {0x51,1,{0x26}},
  347. {0x52,1,{0x22}},
  348. {0x53,1,{0x22}},
  349. {0x54,1,{0x22}},
  350. {0x55,1,{0x22}},
  351. {0x56,1,{0x16}},
  352. {0x57,1,{0x29}},
  353. {0x58,1,{0x22}},
  354. {0x59,1,{0x9B}},
  355. {0x5a,1,{0x57}},
  356. {0x5b,1,{0x70}},
  357. {0x5c,1,{0x27}},
  358. {0x5d,1,{0x22}},
  359. {0x5e,1,{0x22}},
  360. {0x5f,1,{0x22}},
  361. {0x60,1,{0x22}},
  362. {0x61,1,{0x16}},
  363. {0x62,1,{0x06}},
  364. {0x63,1,{0x07}},
  365. {0x64,1,{0x02}},
  366. {0x65,1,{0x02}},
  367. {0x66,1,{0x02}},
  368. {0x67,1,{0x55}},
  369. {0x68,1,{0x57}},
  370. {0x69,1,{0x59}},
  371. {0x6a,1,{0x5B}},
  372. {0x6b,1,{0x00}},
  373. {0x6c,1,{0xA7}},
  374. {0x6d,1,{0x09}},
  375. {0x6e,1,{0x02}},
  376. {0x6f,1,{0x02}},
  377. {0x70,1,{0x02}},
  378. {0x71,1,{0x02}},
  379. {0x72,1,{0x02}},
  380. {0x73,1,{0x02}},
  381. {0x74,1,{0x02}},
  382. {0x75,1,{0x02}},
  383. {0x76,1,{0x02}},
  384. {0x77,1,{0xA6}},
  385. {0x78,1,{0x01}},
  386. {0x79,1,{0x06}},
  387. {0x7a,1,{0x02}},
  388. {0x7b,1,{0x02}},
  389. {0x7c,1,{0x02}},
  390. {0x7d,1,{0x54}},
  391. {0x7e,1,{0x56}},
  392. {0x7f,1,{0x58}},
  393. {0x80,1,{0x5A}},
  394. {0x81,1,{0x00}},
  395. {0x82,1,{0xA7}},
  396. {0x83,1,{0x08}},
  397. {0x84,1,{0x02}},
  398. {0x85,1,{0x02}},
  399. {0x86,1,{0x02}},
  400. {0x87,1,{0x02}},
  401. {0x88,1,{0x02}},
  402. {0x89,1,{0x02}},
  403. {0x8a,1,{0x02}},
  404. {0x8b,1,{0x02}},
  405. {0x8c,1,{0x02}},
  406. {0x8d,1,{0xA6}},
  407. {0x8e,1,{0x01}},
  408. {0xa0,1,{0x35}},
  409. {0xa1,1,{0x00}},
  410. {0xa2,1,{0x00}},
  411. {0xa3,1,{0x00}},
  412. {0xa4,1,{0x00}},
  413. {0xa5,1,{0x10}},
  414. {0xa6,1,{0x08}},
  415. {0xa7,1,{0x00}},
  416. {0xa8,1,{0x00}},
  417. {0xa9,1,{0x00}},
  418. {0xaa,1,{0x00}},
  419. {0xab,1,{0x00}},
  420. {0xac,1,{0x00}},
  421. {0xad,1,{0x00}},
  422. {0xae,1,{0xff}},
  423. {0xaf,1,{0x00}},
  424. {0xb0,1,{0x00}},
  425. {0xFF,3,{0x98,0x81,0x02}},
  426. {0x42,1,{0x29}},
  427. {0xA0,20,{0x00,0x0A,0x13,0x10,0x10,0x22,0x16,0x19,0x53,0x1A,0x26,0x54,0x1F,0x1F,0x53,0x26,0x29,0x4D,0x5D,0x3F}},
  428. {0xC0,20,{0x00,0x0A,0x13,0x10,0x10,0x22,0x16,0x19,0x53,0x1A,0x26,0x54,0x1F,0x1F,0x53,0x26,0x29,0x4D,0x5D,0x3F}},
  429. {0x18,1,{0xF4}},
  430. {0xFF,3,{0x98,0x81,0x04}},
  431. {0x5D,1,{0x6B}},
  432. {0x5E,1,{0x6B}},
  433. {0x60,1,{0x88}},
  434. {0x62,1,{0x88}},
  435. {0x82,1,{0x20}},
  436. {0x84,1,{0x20}},
  437. {0x86,1,{0x38}},
  438. {0x66,1,{0x04}},
  439. {0xC1,1,{0x70}},
  440. {0x70,1,{0x60}},
  441. {0x71,1,{0x00}},
  442. {0x5B,1,{0x33}},
  443. {0x6C,1,{0x10}},
  444. {0x77,1,{0x03}},
  445. {0x7B,1,{0x02}},
  446. {0xFF,3,{0x98,0x81,0x01}},
  447. {0xF0,1,{0x01}},
  448. {0xF1,1,{0x0E}},
  449. {0xFF,3,{0x98,0x81,0x05}},
  450. {0x22,1,{0x3A}},
  451. {0xFF,3,{0x98,0x81,0x00}},
  452. {0x35,1,{0x00}},
  453. #endif
  454. {0x11, 1, {0x00}},
  455. {REGFLAG_DELAY, 100, {}},
  456. // Display ON
  457. {0x29, 1, {0x00}},
  458. {REGFLAG_DELAY, 100, {}},
  459. };
  460. static void init_lcm_registers(void)
  461. {
  462. #if 1
  463. push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
  464. #else
  465. #endif
  466. }
  467. /*
  468. static struct LCM_setting_table lcm_sleep_out_setting[] = {
  469. // Sleep Out
  470. {0x11, 0, {0x00}},
  471. {REGFLAG_DELAY, 120, {}},
  472. // Display ON
  473. {0x29, 0, {0x00}},
  474. {REGFLAG_DELAY, 100, {}},
  475. {REGFLAG_END_OF_TABLE, 0x00, {}}
  476. };
  477. static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
  478. // Display off sequence
  479. {0x28, 0, {0x00}},
  480. // Sleep Mode On
  481. {0x10, 0, {0x00}},
  482. {REGFLAG_END_OF_TABLE, 0x00, {}}
  483. };
  484. */
  485. // ---------------------------------------------------------------------------
  486. // LCM Driver Implementations
  487. // ---------------------------------------------------------------------------
  488. static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
  489. {
  490. memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
  491. }
  492. static void lcm_get_params(LCM_PARAMS *params)
  493. {
  494. memset(params, 0, sizeof(LCM_PARAMS));
  495. params->type = LCM_TYPE_DSI;
  496. params->physical_width = 64;
  497. params->physical_height = 139;
  498. params->width = FRAME_WIDTH;
  499. params->height = FRAME_HEIGHT;
  500. //params->physical_width = 71;
  501. //params->physical_height = 129;
  502. #if (LCM_DSI_CMD_MODE)
  503. params->dsi.mode = CMD_MODE;
  504. #else
  505. params->dsi.mode = SYNC_PULSE_VDO_MODE; //SYNC_PULSE_VDO_MODE;//BURST_VDO_MODE;
  506. #endif
  507. // DSI
  508. /* Command mode setting */
  509. //1 Three lane or Four lane
  510. params->dsi.LANE_NUM = LCM_FOUR_LANE;
  511. //The following defined the fomat for data coming from LCD engine.
  512. params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
  513. params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
  514. params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
  515. params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
  516. // Highly depends on LCD driver capability.
  517. // Not support in MT6573
  518. params->dsi.packet_size=256;
  519. // Video mode setting
  520. params->dsi.intermediat_buffer_num = 0;//because DSI/DPI HW design change, this parameters should be 0 when video mode in MT658X; or memory leakage
  521. params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
  522. //params->dsi.word_count=720*3;
  523. params->dsi.vertical_sync_active = 16;
  524. params->dsi.vertical_backporch = 40;
  525. params->dsi.vertical_frontporch = 30;
  526. params->dsi.vertical_active_line = FRAME_HEIGHT;
  527. params->dsi.horizontal_sync_active = 30;
  528. params->dsi.horizontal_backporch = 30;
  529. params->dsi.horizontal_frontporch = 50;
  530. params->dsi.horizontal_active_pixel = FRAME_WIDTH;
  531. // params->dsi.compatibility_for_nvk = 0;
  532. params->dsi.ssc_disable = 1;
  533. params->dsi.esd_check_enable = 1;
  534. params->dsi.customization_esd_check_enable = 1;
  535. params->dsi.lcm_esd_check_table[0].cmd = 0x0a;
  536. params->dsi.lcm_esd_check_table[0].count = 1;
  537. params->dsi.lcm_esd_check_table[0].para_list[0] = 0x9C;
  538. params->dsi.HS_TRAIL=20;
  539. params->dsi.PLL_CLOCK = 220;//185;//183 212 195 200 205 180 230
  540. #ifdef MTK_ROUND_CORNER_SUPPORT
  541. params->round_corner_params.round_corner_en = 1;
  542. params->round_corner_params.full_content = 0;
  543. params->round_corner_params.w = ROUND_CORNER_W;
  544. params->round_corner_params.h = ROUND_CORNER_H;
  545. params->round_corner_params.lt_addr = left_top;
  546. params->round_corner_params.lb_addr = left_bottom;
  547. params->round_corner_params.rt_addr = right_top;
  548. params->round_corner_params.rb_addr = right_bottom;
  549. #endif
  550. }
  551. static unsigned int lcm_compare_id(void);
  552. static void lcm_suspend(void)
  553. {
  554. unsigned int data_array[16];
  555. data_array[0] = 0x00280500;
  556. dsi_set_cmdq(data_array, 1, 1);
  557. MDELAY(50);
  558. data_array[0]= 0x00100500;
  559. dsi_set_cmdq(data_array, 1, 1);
  560. MDELAY(120);
  561. // push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
  562. }
  563. #if (LCM_DSI_CMD_MODE)
  564. static void lcm_update(unsigned int x, unsigned int y,
  565. unsigned int width, unsigned int height)
  566. {
  567. unsigned int x0 = x;
  568. unsigned int y0 = y;
  569. unsigned int x1 = x0 + width - 1;
  570. unsigned int y1 = y0 + height - 1;
  571. unsigned char x0_MSB = ((x0>>8)&0xFF);
  572. unsigned char x0_LSB = (x0&0xFF);
  573. unsigned char x1_MSB = ((x1>>8)&0xFF);
  574. unsigned char x1_LSB = (x1&0xFF);
  575. unsigned char y0_MSB = ((y0>>8)&0xFF);
  576. unsigned char y0_LSB = (y0&0xFF);
  577. unsigned char y1_MSB = ((y1>>8)&0xFF);
  578. unsigned char y1_LSB = (y1&0xFF);
  579. unsigned int data_array[16];
  580. data_array[0]= 0x00053902;
  581. data_array[1]= (x1_MSB<<24)|(x0_LSB<<16)|(x0_MSB<<8)|0x2a;
  582. data_array[2]= (x1_LSB);
  583. dsi_set_cmdq(data_array, 3, 1);
  584. data_array[0]= 0x00053902;
  585. data_array[1]= (y1_MSB<<24)|(y0_LSB<<16)|(y0_MSB<<8)|0x2b;
  586. data_array[2]= (y1_LSB);
  587. dsi_set_cmdq(data_array, 3, 1);
  588. data_array[0]= 0x002c3909;
  589. dsi_set_cmdq(data_array, 1, 0);
  590. }
  591. #endif
  592. static unsigned int lcm_compare_id(void)
  593. {
  594. int array[4];
  595. char buffer[5];
  596. char id_high=0;
  597. char id_low=0;
  598. int id=0;
  599. SET_RESET_PIN(1);
  600. MDELAY(20);
  601. SET_RESET_PIN(0);
  602. MDELAY(20);
  603. SET_RESET_PIN(1);
  604. MDELAY(120);
  605. array[0]=0x00043902;
  606. array[1]=0x068198FF;
  607. dsi_set_cmdq(array, 2, 1);
  608. MDELAY(10);
  609. array[0]=0x00023700;
  610. dsi_set_cmdq(array, 1, 1);
  611. read_reg_v2(0xF0, buffer,1);
  612. id_high = buffer[0]; //0x98
  613. array[0]=0x00023700;
  614. dsi_set_cmdq(array, 1, 1);
  615. read_reg_v2(0xF1, buffer,1);
  616. id_low = buffer[0]; //0x81
  617. id =(id_high << 8) | id_low;
  618. #ifdef BUILD_LK
  619. printf("zrl_lk -- ili9881 0x%x , 0x%x, 0x%x \n", id_high, id_low, id);
  620. #else
  621. printk("zrl_lk -- ili9881 0x%x , 0x%x, 0x%x \n", id_high, id_low, id);
  622. #endif
  623. return (id ==0x9881)?1:0;
  624. }
  625. static void lcm_init(void)
  626. {
  627. SET_RESET_PIN(1);
  628. MDELAY(10); //20130924 add
  629. SET_RESET_PIN(0);
  630. MDELAY(50);//Must > 5ms //6 20130924 changed
  631. SET_RESET_PIN(1);
  632. MDELAY(100);//Must > 50ms //50 20130924 changed
  633. init_lcm_registers();
  634. // lcm_compare_id();
  635. }
  636. static void lcm_resume(void)
  637. {
  638. lcm_init();
  639. // push_table(lcm_sleep_out_setting, sizeof(lcm_sleep_out_setting) / sizeof(struct LCM_setting_table), 1);
  640. }
  641. LCM_DRIVER ili9881d_hdplus_vdo_haifei_lcm_drv =
  642. {
  643. .name = "ili9881d_hdplus_vdo_haifei",
  644. .set_util_funcs = lcm_set_util_funcs,
  645. .get_params = lcm_get_params,
  646. .init = lcm_init,
  647. .suspend = lcm_suspend,
  648. .resume = lcm_resume,
  649. .compare_id = lcm_compare_id,
  650. #if (LCM_DSI_CMD_MODE)
  651. .update = lcm_update,
  652. #endif
  653. };