hx8392a_dsi_vdo_2lane.c 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  1. /* Copyright Statement:
  2. *
  3. * This software/firmware and related documentation ("MediaTek Software") are
  4. * protected under relevant copyright laws. The information contained herein
  5. * is confidential and proprietary to MediaTek Inc. and/or its licensors.
  6. * Without the prior written permission of MediaTek inc. and/or its licensors,
  7. * any reproduction, modification, use or disclosure of MediaTek Software,
  8. * and information contained herein, in whole or in part, shall be strictly prohibited.
  9. */
  10. /* MediaTek Inc. (C) 2015. All rights reserved.
  11. *
  12. * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  13. * THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  14. * RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER ON
  15. * AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  16. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  17. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  18. * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  19. * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  20. * SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
  21. * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
  22. * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
  23. * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
  24. * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
  25. * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
  26. * CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  27. * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  28. * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
  29. * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  30. *
  31. * The following software/firmware and/or related documentation ("MediaTek Software")
  32. * have been modified by MediaTek Inc. All revisions are subject to any receiver\'s
  33. * applicable license agreements with MediaTek Inc.
  34. */
  35. #include "lcm_drv.h"
  36. // ---------------------------------------------------------------------------
  37. // Local Constants
  38. // ---------------------------------------------------------------------------
  39. #define FRAME_WIDTH (720)
  40. #define FRAME_HEIGHT (1280)
  41. #define REGFLAG_DELAY 0xFE
  42. #define REGFLAG_END_OF_TABLE 0xFF // END OF REGISTERS MARKER
  43. // ---------------------------------------------------------------------------
  44. // Local Variables
  45. // ---------------------------------------------------------------------------
  46. static LCM_UTIL_FUNCS lcm_util = {0};
  47. #define SET_RESET_PIN(v) (lcm_util.set_reset_pin((v)))
  48. #define UDELAY(n) (lcm_util.udelay(n))
  49. #define MDELAY(n) (lcm_util.mdelay(n))
  50. // ---------------------------------------------------------------------------
  51. // Local Functions
  52. // ---------------------------------------------------------------------------
  53. #define dsi_set_cmdq_V2(cmd, count, ppara, force_update) lcm_util.dsi_set_cmdq_V2(cmd, count, ppara, force_update)
  54. #define dsi_set_cmdq(pdata, queue_size, force_update) lcm_util.dsi_set_cmdq(pdata, queue_size, force_update)
  55. #define wrtie_cmd(cmd) lcm_util.dsi_write_cmd(cmd)
  56. #define write_regs(addr, pdata, byte_nums) lcm_util.dsi_write_regs(addr, pdata, byte_nums)
  57. #define read_reg lcm_util.dsi_read_reg()
  58. struct LCM_setting_table {
  59. unsigned cmd;
  60. unsigned char count;
  61. unsigned char para_list[64];
  62. };
  63. static struct LCM_setting_table lcm_initialization_setting[] = {
  64. /*
  65. Note :
  66. Data ID will depends on the following rule.
  67. count of parameters > 1 => Data ID = 0x39
  68. count of parameters = 1 => Data ID = 0x15
  69. count of parameters = 0 => Data ID = 0x05
  70. Structure Format :
  71. {DCS command, count of parameters, {parameter list}}
  72. {REGFLAG_DELAY, milliseconds of time, {}},
  73. ...
  74. Setting ending by predefined flag
  75. {REGFLAG_END_OF_TABLE, 0x00, {}}
  76. */
  77. //sleep out
  78. {0x11, 0, {}},
  79. {REGFLAG_DELAY, 120, {}},
  80. //SET PASSWORD
  81. {0xB9, 3, {0xFF,0x83,0x92}},
  82. {REGFLAG_DELAY, 10, {}},
  83. //set mipi 4 lane
  84. {
  85. 0xBA, 17, {
  86. 0x11, 0x83, 0x00, 0xD6,
  87. 0xC5, 0x00, 0x09, 0xFF,
  88. 0x0F, 0x27, 0x03, 0x21,
  89. 0x27, 0x25, 0x20, 0x00,
  90. 0x10
  91. }
  92. },
  93. //SET POWER
  94. {
  95. 0xB1, 13, {
  96. 0x7C, 0x00, 0x43, 0xBB,
  97. 0x00, 0x1A, 0x1A, 0x2F,
  98. 0x36, 0x3F, 0x3F, 0x42,
  99. 0x7A
  100. }
  101. },
  102. //SET DISPLAY RELATED REGISTER
  103. {
  104. 0xB2, 12, {
  105. 0x08,0xC8,0x06,0x06,
  106. 0x04,0x84,0x00,0xFF,
  107. 0x06,0x06,0x04,0x20
  108. }
  109. },
  110. //SET CYC
  111. {
  112. 0xB4, 23, {
  113. 0x00, 0x00, 0x05, 0x0A,
  114. 0x8F, 0x06, 0x0A, 0x95,
  115. 0x01, 0x07, 0x06, 0x0C,
  116. 0x02, 0x08, 0x08, 0x21,
  117. 0x04, 0x02, 0x08, 0x01,
  118. 0x04, 0x1A, 0x95
  119. }
  120. },
  121. // set TE on
  122. {0x35, 1, {0x00}},
  123. {0xBF, 4, {0x05, 0x60, 0x02, 0x00}},
  124. // VCOM//64
  125. {0xB6, 1, {0x6A}},
  126. //SET RGB OR BGR
  127. {0x36, 1, {0x08}},
  128. //SET RGB OR BGR
  129. {0xC0, 2, {0x03, 0x94}},
  130. //SET DSI VIDEO MODE
  131. {0xC2, 1, {0x03}},
  132. {0xC6, 4, {0x35, 0x00, 0x20, 0x04}},
  133. //SET PANEL
  134. {0xCC, 1, {0x09}},
  135. {0xD4, 1, {0x00}},
  136. {
  137. 0xD5, 23, {
  138. 0x00, 0x01, 0x04, 0x00,
  139. 0x01, 0x67, 0x89, 0xAB,
  140. 0x45, 0xCC, 0xCC, 0xCC,
  141. 0x00, 0x10, 0x54, 0xBA,
  142. 0x98, 0x76, 0xCC, 0xCC,
  143. 0xCC, 0x00, 0x00
  144. }
  145. },
  146. {
  147. 0xD8, 23, {
  148. 0x00, 0x00, 0x05, 0x00,
  149. 0x9A, 0x00, 0x02, 0x95,
  150. 0x01, 0x07, 0x06, 0x00,
  151. 0x08, 0x08, 0x00, 0x1D,
  152. 0x08, 0x08, 0x08, 0x00,
  153. 0x00, 0x00, 0x77
  154. }
  155. },
  156. {
  157. 0xE0, 34, {
  158. 0x00, 0x12, 0x19, 0x33,
  159. 0x36, 0x3F, 0x28, 0x47,
  160. 0x06, 0x0C, 0x0E, 0x12,
  161. 0x14, 0x12, 0x14, 0x12,
  162. 0x1A, 0x00, 0x12, 0x19,
  163. 0x33, 0x36, 0x3F, 0x28,
  164. 0x47, 0x06, 0x0C, 0x0E,
  165. 0x12, 0x14, 0x12, 0x14,
  166. 0x12, 0x1A
  167. }
  168. },
  169. {
  170. 0xE1, 34, {
  171. 0x00, 0x12, 0x19, 0x33,
  172. 0x36, 0x3F, 0x28, 0x47,
  173. 0x06, 0x0C, 0x0E, 0x12,
  174. 0x14, 0x12, 0x14, 0x12,
  175. 0x1A, 0x00, 0x12, 0x19,
  176. 0x33, 0x36, 0x3F, 0x28,
  177. 0x47, 0x06, 0x0C, 0x0E,
  178. 0x12, 0x14, 0x12, 0x14,
  179. 0x12, 0x1A
  180. }
  181. },
  182. {
  183. 0xE2, 34, {
  184. 0x00, 0x12, 0x19, 0x33,
  185. 0x36, 0x3F, 0x28, 0x47,
  186. 0x06, 0x0C, 0x0E, 0x12,
  187. 0x14, 0x12, 0x14, 0x12,
  188. 0x1A, 0x00, 0x12, 0x19,
  189. 0x33, 0x36, 0x3F, 0x28,
  190. 0x47, 0x06, 0x0C, 0x0E,
  191. 0x12, 0x14, 0x12, 0x14,
  192. 0x12, 0x1A
  193. }
  194. },
  195. //SET PIXEL FORMAT
  196. {0x3A, 1, {0x77}},
  197. //sleep out
  198. {0x29, 0, {}},
  199. };
  200. static struct LCM_setting_table lcm_deep_sleep_mode_in_setting[] = {
  201. // Display off sequence
  202. {0x28, 0, {}},
  203. // Sleep Mode On
  204. {0x10, 0, {}},
  205. {REGFLAG_DELAY, 120, {}},
  206. {REGFLAG_END_OF_TABLE, 0x00, {}}
  207. };
  208. static void push_table(struct LCM_setting_table *table, unsigned int count, unsigned char force_update)
  209. {
  210. unsigned int i;
  211. for (i = 0; i < count; i++) {
  212. unsigned cmd;
  213. cmd = table[i].cmd;
  214. switch (cmd) {
  215. case REGFLAG_DELAY :
  216. MDELAY(table[i].count);
  217. break;
  218. case REGFLAG_END_OF_TABLE :
  219. break;
  220. default:
  221. dsi_set_cmdq_V2(cmd, table[i].count, table[i].para_list, force_update);
  222. }
  223. }
  224. }
  225. // ---------------------------------------------------------------------------
  226. // LCM Driver Implementations
  227. // ---------------------------------------------------------------------------
  228. static void lcm_set_util_funcs(const LCM_UTIL_FUNCS *util)
  229. {
  230. memcpy(&lcm_util, util, sizeof(LCM_UTIL_FUNCS));
  231. }
  232. static void lcm_get_params(LCM_PARAMS *params)
  233. {
  234. memset(params, 0, sizeof(LCM_PARAMS));
  235. params->type = LCM_TYPE_DSI;
  236. params->width = FRAME_WIDTH;
  237. params->height = FRAME_HEIGHT;
  238. // enable tearing-free
  239. params->dbi.te_mode = LCM_DBI_TE_MODE_VSYNC_ONLY;
  240. params->dbi.te_edge_polarity = LCM_POLARITY_RISING;
  241. params->dsi.mode = SYNC_PULSE_VDO_MODE;
  242. // DSI
  243. /* Command mode setting */
  244. params->dsi.LANE_NUM = LCM_TWO_LANE;
  245. //The following defined the fomat for data coming from LCD engine.
  246. params->dsi.data_format.color_order = LCM_COLOR_ORDER_RGB;
  247. params->dsi.data_format.trans_seq = LCM_DSI_TRANS_SEQ_MSB_FIRST;
  248. params->dsi.data_format.padding = LCM_DSI_PADDING_ON_LSB;
  249. params->dsi.data_format.format = LCM_DSI_FORMAT_RGB888;
  250. // Highly depends on LCD driver capability.
  251. // Not support in MT6573
  252. params->dsi.packet_size=256;
  253. params->dsi.PS=LCM_PACKED_PS_24BIT_RGB888;
  254. params->dsi.vertical_sync_active = 2;
  255. params->dsi.vertical_backporch = 8;
  256. params->dsi.vertical_frontporch = 15;
  257. params->dsi.vertical_active_line = FRAME_HEIGHT;
  258. params->dsi.horizontal_sync_active = 76;
  259. params->dsi.horizontal_backporch = 76;
  260. params->dsi.horizontal_frontporch = 76;
  261. params->dsi.horizontal_active_pixel = FRAME_WIDTH;
  262. #ifndef CONFIG_FPGA_EARLY_PORTING
  263. params->dsi.PLL_CLOCK = 475;
  264. #else
  265. params->dsi.pll_div1 = 0;
  266. params->dsi.pll_div2 = 0;
  267. params->dsi.fbk_div = 0x1;
  268. #endif
  269. params->dsi.cont_clock=1;
  270. /*
  271. params->dsi.clk_lp_per_line_enable = 0;
  272. params->dsi.esd_check_enable = 0;
  273. params->dsi.customization_esd_check_enable = 0;
  274. params->dsi.lcm_esd_check_table[0].cmd = 0x53;
  275. params->dsi.lcm_esd_check_table[0].count = 1;
  276. params->dsi.lcm_esd_check_table[0].para_list[0] = 0x24;
  277. */
  278. }
  279. static void lcm_init(void)
  280. {
  281. /* enable backlight */
  282. upmu_set_rg_vgp1_vosel(0x7);
  283. upmu_set_rg_vgp1_en(0x1);
  284. SET_RESET_PIN(1);
  285. SET_RESET_PIN(0);
  286. MDELAY(10);
  287. SET_RESET_PIN(1);
  288. MDELAY(20);
  289. push_table(lcm_initialization_setting, sizeof(lcm_initialization_setting) / sizeof(struct LCM_setting_table), 1);
  290. }
  291. static void lcm_suspend(void)
  292. {
  293. push_table(lcm_deep_sleep_mode_in_setting, sizeof(lcm_deep_sleep_mode_in_setting) / sizeof(struct LCM_setting_table), 1);
  294. }
  295. static void lcm_resume(void)
  296. {
  297. lcm_init();
  298. }
  299. LCM_DRIVER hx8392a_dsi_vdo_2lane_lcm_drv = {
  300. .name = "hx8392a_vdo_2lane",
  301. .set_util_funcs = lcm_set_util_funcs,
  302. .get_params = lcm_get_params,
  303. .init = lcm_init,
  304. .suspend = lcm_suspend,
  305. .resume = lcm_resume,
  306. };