panel_st77916.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. /*
  2. * Copyright (c) 2020 Actions Technology Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <sys/byteorder.h>
  7. #include "panel_st77916.h"
  8. #include "panel_device.h"
  9. /*********************
  10. * DEFINES
  11. *********************/
  12. /**********************
  13. * TYPEDEFS
  14. **********************/
  15. /**********************
  16. * STATIC PROTOTYPES
  17. **********************/
  18. /**********************
  19. * STATIC VARIABLES
  20. **********************/
  21. /**********************
  22. * MACROS
  23. **********************/
  24. /**********************
  25. * FUNCTIONS
  26. **********************/
  27. static void _panel_transmit(const struct device *dev, uint32_t cmd,
  28. const uint8_t *tx_data, size_t tx_count)
  29. {
  30. struct lcd_panel_data *data = dev->data;
  31. //assert(data->transfering == 0);
  32. display_controller_write_config(data->lcdc_dev, ST77916_WR_CMD(cmd), tx_data, tx_count);
  33. }
  34. static inline void _panel_transmit_cmd(const struct device *dev, uint32_t cmd)
  35. {
  36. _panel_transmit(dev, cmd, NULL, 0);
  37. }
  38. static inline void _panel_transmit_p1(const struct device *dev, uint32_t cmd, uint8_t tx_data)
  39. {
  40. _panel_transmit(dev, cmd, &tx_data, 1);
  41. }
  42. static void _panel_transmit_p2(const struct device *dev, uint32_t cmd, uint8_t data1, uint8_t data2)
  43. {
  44. uint8_t data_array[2] = {
  45. data1,
  46. data2,
  47. };
  48. _panel_transmit(dev, cmd, data_array, 2);
  49. }
  50. static int _panel_set_brightness(const struct device *dev, uint8_t brightness)
  51. {
  52. _panel_transmit_p1(dev, DDIC_CMD_WRDISBV, brightness);
  53. return 0;
  54. }
  55. static int _panel_set_mem_area(const struct device *dev, uint16_t x, uint16_t y, uint16_t w,
  56. uint16_t h)
  57. {
  58. uint16_t cmd_data[2];
  59. x += CONFIG_PANEL_MEM_OFFSET_X; // add 12 pixel offset ?
  60. y += CONFIG_PANEL_MEM_OFFSET_Y;
  61. cmd_data[0] = sys_cpu_to_be16(x);
  62. cmd_data[1] = sys_cpu_to_be16(x + w - 1);
  63. _panel_transmit(dev, DDIC_CMD_CASET, (uint8_t *)&cmd_data[0], 4);
  64. cmd_data[0] = sys_cpu_to_be16(y);
  65. cmd_data[1] = sys_cpu_to_be16(y + h - 1);
  66. _panel_transmit(dev, DDIC_CMD_RASET, (uint8_t *)&cmd_data[0], 4);
  67. return 0;
  68. }
  69. #if 0
  70. static void _panel_exit_sleep(const struct device *dev)
  71. {
  72. struct lcd_panel_data *data = dev->data;
  73. _panel_transmit_cmd(dev, DDIC_CMD_SLPOUT);
  74. k_msleep(120);
  75. data->in_sleep = 0;
  76. // _panel_transmit_cmd(dev, 0xFE);
  77. // _panel_transmit_cmd(dev, 0xEF);
  78. // _panel_transmit_cmd(dev, 0x11);
  79. // k_msleep(120);
  80. // _panel_transmit_cmd(dev, 0x29);
  81. //printk("st77916 panel exit sleep \r\n ");
  82. }
  83. #endif
  84. static int _panel_blanking_on(const struct device *dev)
  85. {
  86. //printk("st77916 panel blanking on \r\n ");
  87. //_panel_transmit_cmd(dev, DDIC_CMD_DISPOFF);
  88. //_panel_transmit_cmd(dev, DDIC_CMD_SLPIN);
  89. return 0;
  90. }
  91. static int _panel_blanking_off(const struct device *dev)
  92. {
  93. //struct lcd_panel_data *data = dev->data;
  94. //printk("st77916 panel blanking off \r\n ");
  95. //if (data->in_sleep)
  96. // _panel_exit_sleep(dev);
  97. //_panel_transmit_cmd(dev, DDIC_CMD_DISPON);
  98. k_msleep(80);
  99. return 0;
  100. }
  101. static int _panel_lowpower_enter(const struct device *dev)
  102. {
  103. //printk("st77916 panel lowpower enter \r\n ");
  104. //_panel_transmit_p1(dev, 0xFE, 0x01);
  105. /* 0x01 60Hz, 0x41 30Hz, 0x43 15Hz, 0x4B 5Hz, 0x7B 1Hz */
  106. //_panel_transmit_p1(dev, 0x29, 0x4B);
  107. //_panel_transmit_p1(dev, 0xFE, 0x00);
  108. return 0;
  109. }
  110. static int _panel_lowpower_exit(const struct device *dev)
  111. {
  112. //printk("st77916 panel lowpower exit \r\n ");
  113. //_panel_transmit_p1(dev, 0xFE, 0x01);
  114. //_panel_transmit_p1(dev, 0x29, 0x01);
  115. //_panel_transmit_p1(dev, 0xFE, 0x00);
  116. return 0;
  117. }
  118. //static void _panel_init_te(const struct device *dev)
  119. //{
  120. // const struct lcd_panel_config *config = dev->config;
  121. // if (config->videomode.flags & (DISPLAY_FLAGS_TE_HIGH | DISPLAY_FLAGS_TE_LOW)) {
  122. // uint8_t tmp[2];
  123. // sys_put_be16(CONFIG_PANEL_TE_SCANLINE, tmp);
  124. // _panel_transmit(dev, DDIC_CMD_STESL, tmp, 2);
  125. // tmp[0] = 0x02;
  126. // _panel_transmit(dev, DDIC_CMD_TEON, tmp, 1);
  127. // } else {
  128. // _panel_transmit(dev, DDIC_CMD_TEOFF, NULL, 0);
  129. // }
  130. //}
  131. static int _panel_init(const struct device *dev)
  132. {
  133. /* Sleep Out */
  134. //_panel_exit_sleep(dev);
  135. // internal reg enable
  136. //_panel_transmit(dev, DDIC_CMD_INTERREG_EN1, NULL, 0);
  137. //_panel_transmit(dev, DDIC_CMD_INTERREG_EN2, NULL, 0);
  138. printk("st77916 panel_init \r\n ");
  139. #if 1
  140. _panel_transmit_p1(dev, 0xf0, 0x08);
  141. _panel_transmit_p1(dev, 0xF2, 0x08);
  142. _panel_transmit_p1(dev, 0x9B, 0x51);
  143. _panel_transmit_p1(dev, 0x86, 0x53);
  144. _panel_transmit_p1(dev, 0xF2, 0x80);
  145. _panel_transmit_p1(dev, 0xF0, 0x00);
  146. _panel_transmit_p1(dev, 0xF0, 0x01);
  147. _panel_transmit_p1(dev, 0xF1, 0x01);
  148. _panel_transmit_p1(dev, 0xB0, 0x54);
  149. _panel_transmit_p1(dev, 0xB1, 0x3F);
  150. _panel_transmit_p1(dev, 0xB2, 0x2A);
  151. _panel_transmit_p1(dev, 0xB4, 0x46);
  152. _panel_transmit_p1(dev, 0xB5, 0x34);
  153. _panel_transmit_p1(dev, 0xB6, 0xD5);
  154. _panel_transmit_p1(dev, 0xB7, 0x30);
  155. //_panel_transmit_p1(dev, 0xB8, 0x04);
  156. _panel_transmit_p1(dev, 0xBA, 0x00);
  157. _panel_transmit_p1(dev, 0xBB, 0x08);
  158. _panel_transmit_p1(dev, 0xBC, 0x08);
  159. _panel_transmit_p1(dev, 0xBD, 0x00);
  160. _panel_transmit_p1(dev, 0xC0, 0x80);
  161. _panel_transmit_p1(dev, 0xC1, 0x10);
  162. _panel_transmit_p1(dev, 0xC2, 0x37);
  163. _panel_transmit_p1(dev, 0xC3, 0x80);
  164. _panel_transmit_p1(dev, 0xC4, 0x10);
  165. _panel_transmit_p1(dev, 0xC5, 0x37);
  166. _panel_transmit_p1(dev, 0xC6, 0xA9);
  167. _panel_transmit_p1(dev, 0xC7, 0x41);
  168. _panel_transmit_p1(dev, 0xC8, 0x51);
  169. _panel_transmit_p1(dev, 0xC9, 0xA9);
  170. _panel_transmit_p1(dev, 0xCA, 0x41);
  171. _panel_transmit_p1(dev, 0xCB, 0x51);
  172. _panel_transmit_p1(dev, 0xD0, 0x91);
  173. _panel_transmit_p1(dev, 0xD1, 0x68);
  174. _panel_transmit_p1(dev, 0xD2, 0x69);
  175. const uint8_t data_0xf5[] = {
  176. 0x00,
  177. 0xA5,
  178. };
  179. _panel_transmit(dev, 0xF5, data_0xf5, sizeof(data_0xf5));
  180. _panel_transmit_p1(dev, 0xDD, 0x3F);
  181. _panel_transmit_p1(dev, 0xDE, 0x3F);
  182. _panel_transmit_p1(dev, 0xF1, 0x10);
  183. _panel_transmit_p1(dev, 0xF0, 0x00);
  184. _panel_transmit_p1(dev, 0xF0, 0x02);
  185. const uint8_t data_0xe0[] = {
  186. 0xF0, 0x06, 0x0B, 0x09, 0x09, 0x16, 0x32, 0x44, 0x4A, 0x37, 0x13, 0x13, 0x2E, 0x34,
  187. };
  188. _panel_transmit(dev, 0xE0, data_0xe0, sizeof(data_0xe0));
  189. const uint8_t data_0xe1[] = {
  190. 0xF0, 0x06, 0x0B, 0x09, 0x08, 0x05, 0x32, 0x33, 0x49, 0x17, 0x13, 0x13, 0x2E, 0x34,
  191. };
  192. _panel_transmit(dev, 0xE1, data_0xe1, sizeof(data_0xe1));
  193. _panel_transmit_p1(dev, 0xF0, 0x10);
  194. _panel_transmit_p1(dev, 0xF3, 0x10);
  195. _panel_transmit_p1(dev, 0xE0, 0x0A);
  196. _panel_transmit_p1(dev, 0xE1, 0x00);
  197. _panel_transmit_p1(dev, 0xE2, 0x00);
  198. _panel_transmit_p1(dev, 0xE3, 0x00);
  199. _panel_transmit_p1(dev, 0xE4, 0xE0);
  200. _panel_transmit_p1(dev, 0xE5, 0x06);
  201. _panel_transmit_p1(dev, 0xE6, 0x21);
  202. _panel_transmit_p1(dev, 0xE7, 0x00);
  203. _panel_transmit_p1(dev, 0xE8, 0x05);
  204. _panel_transmit_p1(dev, 0xE9, 0x82);
  205. _panel_transmit_p1(dev, 0xEA, 0xDF);
  206. _panel_transmit_p1(dev, 0xEB, 0x89);
  207. _panel_transmit_p1(dev, 0xEC, 0x20);
  208. _panel_transmit_p1(dev, 0xED, 0x14);
  209. _panel_transmit_p1(dev, 0xEE, 0xFF);
  210. _panel_transmit_p1(dev, 0xEF, 0x00);
  211. _panel_transmit_p1(dev, 0xF8, 0xFF);
  212. _panel_transmit_p1(dev, 0xF9, 0x00);
  213. _panel_transmit_p1(dev, 0xFA, 0x00);
  214. _panel_transmit_p1(dev, 0xFB, 0x30);
  215. _panel_transmit_p1(dev, 0xFC, 0x00);
  216. _panel_transmit_p1(dev, 0xFD, 0x00);
  217. _panel_transmit_p1(dev, 0xFE, 0x00);
  218. _panel_transmit_p1(dev, 0xFF, 0x00);
  219. _panel_transmit_p1(dev, 0x60, 0x42);
  220. _panel_transmit_p1(dev, 0x61, 0xE0);
  221. _panel_transmit_p1(dev, 0x62, 0x40);
  222. _panel_transmit_p1(dev, 0x63, 0x40);
  223. _panel_transmit_p1(dev, 0x64, 0x02);
  224. _panel_transmit_p1(dev, 0x65, 0x00);
  225. _panel_transmit_p1(dev, 0x66, 0x40);
  226. _panel_transmit_p1(dev, 0x67, 0x03);
  227. _panel_transmit_p1(dev, 0x68, 0x00);
  228. _panel_transmit_p1(dev, 0x69, 0x00);
  229. _panel_transmit_p1(dev, 0x6A, 0x00);
  230. _panel_transmit_p1(dev, 0x6B, 0x00);
  231. _panel_transmit_p1(dev, 0x70, 0x42);
  232. _panel_transmit_p1(dev, 0x71, 0xE0);
  233. _panel_transmit_p1(dev, 0x72, 0x40);
  234. _panel_transmit_p1(dev, 0x73, 0x40);
  235. _panel_transmit_p1(dev, 0x74, 0x02);
  236. _panel_transmit_p1(dev, 0x75, 0x00);
  237. _panel_transmit_p1(dev, 0x76, 0x40);
  238. _panel_transmit_p1(dev, 0x77, 0x03);
  239. _panel_transmit_p1(dev, 0x78, 0x00);
  240. _panel_transmit_p1(dev, 0x79, 0x00);
  241. _panel_transmit_p1(dev, 0x7A, 0x00);
  242. _panel_transmit_p1(dev, 0x7B, 0x00);
  243. _panel_transmit_p1(dev, 0x80, 0x48);
  244. _panel_transmit_p1(dev, 0x81, 0x00);
  245. _panel_transmit_p1(dev, 0x82, 0x05);
  246. _panel_transmit_p1(dev, 0x83, 0x02);
  247. _panel_transmit_p1(dev, 0x84, 0xDD);
  248. _panel_transmit_p1(dev, 0x85, 0x00);
  249. _panel_transmit_p1(dev, 0x86, 0x00);
  250. _panel_transmit_p1(dev, 0x87, 0x00);
  251. _panel_transmit_p1(dev, 0x88, 0x48);
  252. _panel_transmit_p1(dev, 0x89, 0x00);
  253. _panel_transmit_p1(dev, 0x8A, 0x07);
  254. _panel_transmit_p1(dev, 0x8B, 0x02);
  255. _panel_transmit_p1(dev, 0x8C, 0xDF);
  256. _panel_transmit_p1(dev, 0x8D, 0x00);
  257. _panel_transmit_p1(dev, 0x8E, 0x00);
  258. _panel_transmit_p1(dev, 0x8F, 0x00);
  259. _panel_transmit_p1(dev, 0x90, 0x48);
  260. _panel_transmit_p1(dev, 0x91, 0x00);
  261. _panel_transmit_p1(dev, 0x92, 0x09);
  262. _panel_transmit_p1(dev, 0x93, 0x02);
  263. _panel_transmit_p1(dev, 0x94, 0xE1);
  264. _panel_transmit_p1(dev, 0x95, 0x00);
  265. _panel_transmit_p1(dev, 0x96, 0x00);
  266. _panel_transmit_p1(dev, 0x97, 0x00);
  267. _panel_transmit_p1(dev, 0x98, 0x48);
  268. _panel_transmit_p1(dev, 0x99, 0x00);
  269. _panel_transmit_p1(dev, 0x9A, 0x0B);
  270. _panel_transmit_p1(dev, 0x9B, 0x02);
  271. _panel_transmit_p1(dev, 0x9C, 0xE3);
  272. _panel_transmit_p1(dev, 0x9D, 0x00);
  273. _panel_transmit_p1(dev, 0x9E, 0x00);
  274. _panel_transmit_p1(dev, 0x9F, 0x00);
  275. _panel_transmit_p1(dev, 0xA0, 0x48);
  276. _panel_transmit_p1(dev, 0xA1, 0x00);
  277. _panel_transmit_p1(dev, 0xA2, 0x04);
  278. _panel_transmit_p1(dev, 0xA3, 0x02);
  279. _panel_transmit_p1(dev, 0xA4, 0xDC);
  280. _panel_transmit_p1(dev, 0xA5, 0x00);
  281. _panel_transmit_p1(dev, 0xA6, 0x00);
  282. _panel_transmit_p1(dev, 0xA7, 0x00);
  283. _panel_transmit_p1(dev, 0xA8, 0x48);
  284. _panel_transmit_p1(dev, 0xA9, 0x00);
  285. _panel_transmit_p1(dev, 0xAA, 0x06);
  286. _panel_transmit_p1(dev, 0xAB, 0x02);
  287. _panel_transmit_p1(dev, 0xAC, 0xDE);
  288. _panel_transmit_p1(dev, 0xAD, 0x00);
  289. _panel_transmit_p1(dev, 0xAE, 0x00);
  290. _panel_transmit_p1(dev, 0xAF, 0x00);
  291. _panel_transmit_p1(dev, 0xB0, 0x48);
  292. _panel_transmit_p1(dev, 0xB1, 0x00);
  293. _panel_transmit_p1(dev, 0xB2, 0x08);
  294. _panel_transmit_p1(dev, 0xB3, 0x02);
  295. _panel_transmit_p1(dev, 0xB4, 0xE0);
  296. _panel_transmit_p1(dev, 0xB5, 0x00);
  297. _panel_transmit_p1(dev, 0xB6, 0x00);
  298. _panel_transmit_p1(dev, 0xB7, 0x00);
  299. _panel_transmit_p1(dev, 0xB8, 0x48);
  300. _panel_transmit_p1(dev, 0xB9, 0x00);
  301. _panel_transmit_p1(dev, 0xBA, 0x0A);
  302. _panel_transmit_p1(dev, 0xBB, 0x02);
  303. _panel_transmit_p1(dev, 0xBC, 0xE2);
  304. _panel_transmit_p1(dev, 0xBD, 0x00);
  305. _panel_transmit_p1(dev, 0xBE, 0x00);
  306. _panel_transmit_p1(dev, 0xBF, 0x00);
  307. _panel_transmit_p1(dev, 0xC0, 0x12);
  308. _panel_transmit_p1(dev, 0xC1, 0xAA);
  309. _panel_transmit_p1(dev, 0xC2, 0x65);
  310. _panel_transmit_p1(dev, 0xC3, 0x74);
  311. _panel_transmit_p1(dev, 0xC4, 0x47);
  312. _panel_transmit_p1(dev, 0xC5, 0x56);
  313. _panel_transmit_p1(dev, 0xC6, 0x00);
  314. _panel_transmit_p1(dev, 0xC7, 0x88);
  315. _panel_transmit_p1(dev, 0xC8, 0x99);
  316. _panel_transmit_p1(dev, 0xC9, 0x33);
  317. _panel_transmit_p1(dev, 0xD0, 0x21);
  318. _panel_transmit_p1(dev, 0xD1, 0xAA);
  319. _panel_transmit_p1(dev, 0xD2, 0x65);
  320. _panel_transmit_p1(dev, 0xD3, 0x74);
  321. _panel_transmit_p1(dev, 0xD4, 0x47);
  322. _panel_transmit_p1(dev, 0xD5, 0x56);
  323. _panel_transmit_p1(dev, 0xD6, 0x00);
  324. _panel_transmit_p1(dev, 0xD7, 0x88);
  325. _panel_transmit_p1(dev, 0xD8, 0x99);
  326. _panel_transmit_p1(dev, 0xD9, 0x33);
  327. _panel_transmit_p1(dev, 0xF3, 0x01);
  328. _panel_transmit_p1(dev, 0xF0, 0x00);
  329. _panel_transmit_p1(dev, 0xF0, 0x01);
  330. _panel_transmit_p1(dev, 0xF1, 0x01);
  331. _panel_transmit_p1(dev, 0xA0, 0x0B);
  332. _panel_transmit_p1(dev, 0xA3, 0x2A);
  333. _panel_transmit_p1(dev, 0xA5, 0xC3);
  334. k_msleep(1);
  335. _panel_transmit_p1(dev, 0xA3, 0x2B);
  336. _panel_transmit_p1(dev, 0xA5, 0xC3);
  337. k_msleep(1);
  338. _panel_transmit_p1(dev, 0xA3, 0x2C);
  339. _panel_transmit_p1(dev, 0xA5, 0xC3);
  340. k_msleep(1);
  341. _panel_transmit_p1(dev, 0xA3, 0x2D);
  342. _panel_transmit_p1(dev, 0xA5, 0xC3);
  343. k_msleep(1);
  344. _panel_transmit_p1(dev, 0xA3, 0x2E);
  345. _panel_transmit_p1(dev, 0xA5, 0xC3);
  346. k_msleep(1);
  347. _panel_transmit_p1(dev, 0xA3, 0x2F);
  348. _panel_transmit_p1(dev, 0xA5, 0xC3);
  349. k_msleep(1);
  350. _panel_transmit_p1(dev, 0xA3, 0x30);
  351. _panel_transmit_p1(dev, 0xA5, 0xC3);
  352. k_msleep(1);
  353. _panel_transmit_p1(dev, 0xA3, 0x31);
  354. _panel_transmit_p1(dev, 0xA5, 0xC3);
  355. k_msleep(1);
  356. _panel_transmit_p1(dev, 0xA3, 0x32);
  357. _panel_transmit_p1(dev, 0xA5, 0xC3);
  358. k_msleep(1);
  359. _panel_transmit_p1(dev, 0xA3, 0x33);
  360. _panel_transmit_p1(dev, 0xA5, 0xC3);
  361. k_msleep(1);
  362. _panel_transmit_p1(dev, 0xA0, 0x09);
  363. _panel_transmit_p1(dev, 0xF1, 0x10);
  364. _panel_transmit_p1(dev, 0xF0, 0x00);
  365. const uint8_t data_0x2a[] = {
  366. 0x00,
  367. 0x00,
  368. 0x01,
  369. 0x67,
  370. };
  371. _panel_transmit(dev, 0x2a, data_0x2a, sizeof(data_0x2a));
  372. const uint8_t data_0x2b[] = {
  373. 0x01,
  374. 0x68,
  375. 0x01,
  376. 0x68,
  377. };
  378. _panel_transmit(dev, 0x2b, data_0x2b, sizeof(data_0x2b));
  379. _panel_transmit_p1(dev, 0x4D, 0x00);
  380. _panel_transmit_p1(dev, 0x4E, 0x00);
  381. _panel_transmit_p1(dev, 0x4F, 0x00);
  382. _panel_transmit_p1(dev, 0x4C, 0x01);
  383. k_msleep(10);
  384. _panel_transmit_p1(dev, 0x4C, 0x00);
  385. _panel_transmit(dev, 0x2a, data_0x2a, sizeof(data_0x2a));
  386. _panel_transmit(dev, 0x2b, data_0x2a, sizeof(data_0x2a));
  387. _panel_transmit_cmd(dev, 0x21);
  388. /* TE */
  389. _panel_transmit_p2(dev, DDIC_CMD_STESL, CONFIG_PANEL_TE_SCANLINE >> 8,
  390. CONFIG_PANEL_TE_SCANLINE & 0xff);
  391. _panel_transmit_p1(dev, DDIC_CMD_TEON, 0x00);
  392. _panel_transmit_p1(dev, 0x53, 0x20);
  393. _panel_transmit_cmd(dev, 0x11); /* Sleep Out */
  394. k_msleep(120);
  395. _panel_transmit_p1(dev, 0x3a, 0x55);
  396. _panel_transmit_cmd(dev, 0x29); /* Display On */
  397. k_msleep(50);
  398. //_panel_transmit_cmd(dev, 0x1c);
  399. //k_msleep(120);
  400. #else
  401. _panel_transmit_p1(dev, 0xf0, 0x08);
  402. _panel_transmit_p1(dev, 0xF2, 0x08);
  403. _panel_transmit_p1(dev, 0x9B, 0x51);
  404. _panel_transmit_p1(dev, 0x86, 0x53);
  405. _panel_transmit_p1(dev, 0xF2, 0x08);
  406. _panel_transmit_p1(dev, 0xF0, 0x00);
  407. _panel_transmit_p1(dev, 0xF0, 0x01);
  408. _panel_transmit_p1(dev, 0xF1, 0x01);
  409. _panel_transmit_p1(dev, 0xB0, 0x54);
  410. _panel_transmit_p1(dev, 0xB1, 0x3F);
  411. _panel_transmit_p1(dev, 0xB2, 0x2A);
  412. _panel_transmit_p1(dev, 0xB4, 0x46);
  413. _panel_transmit_p1(dev, 0xB5, 0x34);
  414. _panel_transmit_p1(dev, 0xB6, 0xD5);
  415. _panel_transmit_p1(dev, 0xB7, 0x30);
  416. _panel_transmit_p1(dev, 0xB8, 0x04);
  417. _panel_transmit_p1(dev, 0xBA, 0x00);
  418. _panel_transmit_p1(dev, 0xBB, 0x08);
  419. _panel_transmit_p1(dev, 0xBC, 0x08);
  420. _panel_transmit_p1(dev, 0xBD, 0x00);
  421. _panel_transmit_p1(dev, 0xC0, 0x80);
  422. _panel_transmit_p1(dev, 0xC1, 0x10);
  423. _panel_transmit_p1(dev, 0xC2, 0x37);
  424. _panel_transmit_p1(dev, 0xC3, 0x80);
  425. _panel_transmit_p1(dev, 0xC4, 0x10);
  426. _panel_transmit_p1(dev, 0xC5, 0x37);
  427. _panel_transmit_p1(dev, 0xC6, 0xA9);
  428. _panel_transmit_p1(dev, 0xC7, 0x41);
  429. _panel_transmit_p1(dev, 0xC8, 0x51);
  430. _panel_transmit_p1(dev, 0xC9, 0xA9);
  431. _panel_transmit_p1(dev, 0xCA, 0x41);
  432. _panel_transmit_p1(dev, 0xCB, 0x51);
  433. _panel_transmit_p1(dev, 0xD0, 0x91);
  434. _panel_transmit_p1(dev, 0xD1, 0x68);
  435. _panel_transmit_p1(dev, 0xD2, 0x69);
  436. const uint8_t data_0xf5[] = {
  437. 0x00,
  438. 0xA5,
  439. };
  440. _panel_transmit(dev, 0xF5, data_0xf5, sizeof(data_0xf5));
  441. _panel_transmit_p1(dev, 0xDD, 0x35);
  442. _panel_transmit_p1(dev, 0xDE, 0x35);
  443. _panel_transmit_p1(dev, 0xF1, 0x10);
  444. _panel_transmit_p1(dev, 0xF0, 0x00);
  445. _panel_transmit_p1(dev, 0xF0, 0x02);
  446. const uint8_t data_0xe0[] = {
  447. 0x70, 0x09, 0x12, 0x0C, 0x0B, 0x27, 0x38, 0x54, 0x4E, 0x19, 0x15, 0x15, 0x2C, 0x2F,
  448. };
  449. _panel_transmit(dev, 0xE0, data_0xe0, sizeof(data_0xe0));
  450. const uint8_t data_0xe1[] = {
  451. 0x70, 0x08, 0x11, 0x0C, 0x0B, 0x27, 0x38, 0x43, 0x4C, 0x18, 0x14, 0x14, 0x2B, 0x2D,
  452. };
  453. _panel_transmit(dev, 0xE1, data_0xe1, sizeof(data_0xe1));
  454. _panel_transmit_p1(dev, 0xF0, 0x10);
  455. _panel_transmit_p1(dev, 0xF3, 0x10);
  456. _panel_transmit_p1(dev, 0xE0, 0x0A);
  457. _panel_transmit_p1(dev, 0xE1, 0x00);
  458. _panel_transmit_p1(dev, 0xE2, 0x0B);
  459. _panel_transmit_p1(dev, 0xE3, 0x00);
  460. _panel_transmit_p1(dev, 0xE4, 0xE0);
  461. _panel_transmit_p1(dev, 0xE5, 0x06);
  462. _panel_transmit_p1(dev, 0xE6, 0x21);
  463. _panel_transmit_p1(dev, 0xE7, 0x00);
  464. _panel_transmit_p1(dev, 0xE8, 0x05);
  465. _panel_transmit_p1(dev, 0xE9, 0x82);
  466. _panel_transmit_p1(dev, 0xEA, 0xDF);
  467. _panel_transmit_p1(dev, 0xEB, 0x89);
  468. _panel_transmit_p1(dev, 0xEC, 0x20);
  469. _panel_transmit_p1(dev, 0xED, 0x14);
  470. _panel_transmit_p1(dev, 0xEE, 0xFF);
  471. _panel_transmit_p1(dev, 0xEF, 0x00);
  472. _panel_transmit_p1(dev, 0xF8, 0xFF);
  473. _panel_transmit_p1(dev, 0xF9, 0x00);
  474. _panel_transmit_p1(dev, 0xFA, 0x00);
  475. _panel_transmit_p1(dev, 0xFB, 0x30);
  476. _panel_transmit_p1(dev, 0xFC, 0x00);
  477. _panel_transmit_p1(dev, 0xFD, 0x00);
  478. _panel_transmit_p1(dev, 0xFE, 0x00);
  479. _panel_transmit_p1(dev, 0xFF, 0x00);
  480. _panel_transmit_p1(dev, 0x60, 0x42);
  481. _panel_transmit_p1(dev, 0x61, 0xE0);
  482. _panel_transmit_p1(dev, 0x62, 0x40);
  483. _panel_transmit_p1(dev, 0x63, 0x40);
  484. _panel_transmit_p1(dev, 0x64, 0x02);
  485. _panel_transmit_p1(dev, 0x65, 0x00);
  486. _panel_transmit_p1(dev, 0x66, 0x40);
  487. _panel_transmit_p1(dev, 0x67, 0x03);
  488. _panel_transmit_p1(dev, 0x68, 0x00);
  489. _panel_transmit_p1(dev, 0x69, 0x00);
  490. _panel_transmit_p1(dev, 0x6A, 0x00);
  491. _panel_transmit_p1(dev, 0x6B, 0x00);
  492. _panel_transmit_p1(dev, 0x70, 0x42);
  493. _panel_transmit_p1(dev, 0x71, 0xE0);
  494. _panel_transmit_p1(dev, 0x72, 0x40);
  495. _panel_transmit_p1(dev, 0x73, 0x40);
  496. _panel_transmit_p1(dev, 0x74, 0x02);
  497. _panel_transmit_p1(dev, 0x75, 0x00);
  498. _panel_transmit_p1(dev, 0x76, 0x40);
  499. _panel_transmit_p1(dev, 0x77, 0x03);
  500. _panel_transmit_p1(dev, 0x78, 0x00);
  501. _panel_transmit_p1(dev, 0x79, 0x00);
  502. _panel_transmit_p1(dev, 0x7A, 0x00);
  503. _panel_transmit_p1(dev, 0x7B, 0x00);
  504. _panel_transmit_p1(dev, 0x80, 0x38);
  505. _panel_transmit_p1(dev, 0x81, 0x00);
  506. _panel_transmit_p1(dev, 0x82, 0x04);
  507. _panel_transmit_p1(dev, 0x83, 0x02);
  508. _panel_transmit_p1(dev, 0x84, 0xDC);
  509. _panel_transmit_p1(dev, 0x85, 0x00);
  510. _panel_transmit_p1(dev, 0x86, 0x00);
  511. _panel_transmit_p1(dev, 0x87, 0x00);
  512. _panel_transmit_p1(dev, 0x88, 0x38);
  513. _panel_transmit_p1(dev, 0x89, 0x00);
  514. _panel_transmit_p1(dev, 0x8A, 0x06);
  515. _panel_transmit_p1(dev, 0x8B, 0x02);
  516. _panel_transmit_p1(dev, 0x8C, 0xDE);
  517. _panel_transmit_p1(dev, 0x8D, 0x00);
  518. _panel_transmit_p1(dev, 0x8E, 0x00);
  519. _panel_transmit_p1(dev, 0x8F, 0x00);
  520. _panel_transmit_p1(dev, 0x90, 0x38);
  521. _panel_transmit_p1(dev, 0x91, 0x00);
  522. _panel_transmit_p1(dev, 0x92, 0x08);
  523. _panel_transmit_p1(dev, 0x93, 0x02);
  524. _panel_transmit_p1(dev, 0x94, 0xE0);
  525. _panel_transmit_p1(dev, 0x95, 0x00);
  526. _panel_transmit_p1(dev, 0x96, 0x00);
  527. _panel_transmit_p1(dev, 0x97, 0x00);
  528. _panel_transmit_p1(dev, 0x98, 0x38);
  529. _panel_transmit_p1(dev, 0x99, 0x00);
  530. _panel_transmit_p1(dev, 0x9A, 0x0A);
  531. _panel_transmit_p1(dev, 0x9B, 0x02);
  532. _panel_transmit_p1(dev, 0x9C, 0xE2);
  533. _panel_transmit_p1(dev, 0x9D, 0x00);
  534. _panel_transmit_p1(dev, 0x9E, 0x00);
  535. _panel_transmit_p1(dev, 0x9F, 0x00);
  536. _panel_transmit_p1(dev, 0xA0, 0x38);
  537. _panel_transmit_p1(dev, 0xA1, 0x00);
  538. _panel_transmit_p1(dev, 0xA2, 0x03);
  539. _panel_transmit_p1(dev, 0xA3, 0x02);
  540. _panel_transmit_p1(dev, 0xA4, 0xDB);
  541. _panel_transmit_p1(dev, 0xA5, 0x00);
  542. _panel_transmit_p1(dev, 0xA6, 0x00);
  543. _panel_transmit_p1(dev, 0xA7, 0x00);
  544. _panel_transmit_p1(dev, 0xA8, 0x38);
  545. _panel_transmit_p1(dev, 0xA9, 0x00);
  546. _panel_transmit_p1(dev, 0xAA, 0x05);
  547. _panel_transmit_p1(dev, 0xAB, 0x02);
  548. _panel_transmit_p1(dev, 0xAC, 0xDD);
  549. _panel_transmit_p1(dev, 0xAD, 0x00);
  550. _panel_transmit_p1(dev, 0xAE, 0x00);
  551. _panel_transmit_p1(dev, 0xAF, 0x00);
  552. _panel_transmit_p1(dev, 0xB0, 0x38);
  553. _panel_transmit_p1(dev, 0xB1, 0x00);
  554. _panel_transmit_p1(dev, 0xB2, 0x07);
  555. _panel_transmit_p1(dev, 0xB3, 0x02);
  556. _panel_transmit_p1(dev, 0xB4, 0xDF);
  557. _panel_transmit_p1(dev, 0xB5, 0x00);
  558. _panel_transmit_p1(dev, 0xB6, 0x00);
  559. _panel_transmit_p1(dev, 0xB7, 0x00);
  560. _panel_transmit_p1(dev, 0xB8, 0x38);
  561. _panel_transmit_p1(dev, 0xB9, 0x00);
  562. _panel_transmit_p1(dev, 0xBA, 0x09);
  563. _panel_transmit_p1(dev, 0xBB, 0x02);
  564. _panel_transmit_p1(dev, 0xBC, 0xE1);
  565. _panel_transmit_p1(dev, 0xBD, 0x00);
  566. _panel_transmit_p1(dev, 0xBE, 0x00);
  567. _panel_transmit_p1(dev, 0xBF, 0x00);
  568. _panel_transmit_p1(dev, 0xC0, 0x22);
  569. _panel_transmit_p1(dev, 0xC1, 0xAA);
  570. _panel_transmit_p1(dev, 0xC2, 0x65);
  571. _panel_transmit_p1(dev, 0xC3, 0x74);
  572. _panel_transmit_p1(dev, 0xC4, 0x47);
  573. _panel_transmit_p1(dev, 0xC5, 0x56);
  574. _panel_transmit_p1(dev, 0xC6, 0x00);
  575. _panel_transmit_p1(dev, 0xC7, 0x88);
  576. _panel_transmit_p1(dev, 0xC8, 0x99);
  577. _panel_transmit_p1(dev, 0xC9, 0x33);
  578. _panel_transmit_p1(dev, 0xD0, 0x11);
  579. _panel_transmit_p1(dev, 0xD1, 0xAA);
  580. _panel_transmit_p1(dev, 0xD2, 0x65);
  581. _panel_transmit_p1(dev, 0xD3, 0x74);
  582. _panel_transmit_p1(dev, 0xD4, 0x47);
  583. _panel_transmit_p1(dev, 0xD5, 0x56);
  584. _panel_transmit_p1(dev, 0xD6, 0x00);
  585. _panel_transmit_p1(dev, 0xD7, 0x88);
  586. _panel_transmit_p1(dev, 0xD8, 0x99);
  587. _panel_transmit_p1(dev, 0xD9, 0x33);
  588. _panel_transmit_p1(dev, 0xF3, 0x01);
  589. _panel_transmit_p1(dev, 0xF0, 0x00);
  590. _panel_transmit_p1(dev, 0xF0, 0x01);
  591. _panel_transmit_p1(dev, 0xF1, 0x01);
  592. _panel_transmit_p1(dev, 0xA0, 0x0B);
  593. _panel_transmit_p1(dev, 0xA3, 0x2A);
  594. _panel_transmit_p1(dev, 0xA5, 0xC3);
  595. k_msleep(1);
  596. _panel_transmit_p1(dev, 0xA3, 0x2B);
  597. _panel_transmit_p1(dev, 0xA5, 0xC3);
  598. k_msleep(1);
  599. _panel_transmit_p1(dev, 0xA3, 0x2C);
  600. _panel_transmit_p1(dev, 0xA5, 0xC3);
  601. k_msleep(1);
  602. _panel_transmit_p1(dev, 0xA3, 0x2D);
  603. _panel_transmit_p1(dev, 0xA5, 0xC3);
  604. k_msleep(1);
  605. _panel_transmit_p1(dev, 0xA3, 0x2E);
  606. _panel_transmit_p1(dev, 0xA5, 0xC3);
  607. k_msleep(1);
  608. _panel_transmit_p1(dev, 0xA3, 0x2F);
  609. _panel_transmit_p1(dev, 0xA5, 0xC3);
  610. k_msleep(1);
  611. _panel_transmit_p1(dev, 0xA3, 0x30);
  612. _panel_transmit_p1(dev, 0xA5, 0xC3);
  613. k_msleep(1);
  614. _panel_transmit_p1(dev, 0xA3, 0x31);
  615. _panel_transmit_p1(dev, 0xA5, 0xC3);
  616. k_msleep(1);
  617. _panel_transmit_p1(dev, 0xA3, 0x32);
  618. _panel_transmit_p1(dev, 0xA5, 0xC3);
  619. k_msleep(1);
  620. _panel_transmit_p1(dev, 0xA3, 0x33);
  621. _panel_transmit_p1(dev, 0xA5, 0xC3);
  622. k_msleep(1);
  623. _panel_transmit_p1(dev, 0xA0, 0x09);
  624. _panel_transmit_p1(dev, 0xF1, 0x10);
  625. _panel_transmit_p1(dev, 0xF0, 0x00);
  626. const uint8_t data_0x2a[] = {
  627. 0x00,
  628. 0x00,
  629. 0x01,
  630. 0x67,
  631. };
  632. _panel_transmit(dev, 0x2a, data_0x2a, sizeof(data_0x2a));
  633. const uint8_t data_0x2b[] = {
  634. 0x01,
  635. 0x68,
  636. 0x01,
  637. 0x68,
  638. };
  639. _panel_transmit(dev, 0x2b, data_0x2b, sizeof(data_0x2b));
  640. _panel_transmit_p1(dev, 0x4D, 0x00);
  641. _panel_transmit_p1(dev, 0x4E, 0x00);
  642. _panel_transmit_p1(dev, 0x4F, 0x00);
  643. _panel_transmit_p1(dev, 0x4C, 0x01);
  644. k_msleep(10);
  645. _panel_transmit_p1(dev, 0x4C, 0x00);
  646. _panel_transmit(dev, 0x2a, data_0x2a, sizeof(data_0x2a));
  647. _panel_transmit(dev, 0x2b, data_0x2a, sizeof(data_0x2a));
  648. _panel_transmit_cmd(dev, 0x21);
  649. /* TE */
  650. _panel_transmit_p2(dev, DDIC_CMD_STESL,
  651. CONFIG_PANEL_TE_SCANLINE >> 8, CONFIG_PANEL_TE_SCANLINE & 0xff);
  652. _panel_transmit_p1(dev, DDIC_CMD_TEON, 0x00);
  653. _panel_transmit_p1(dev, 0x53, 0x20);
  654. _panel_transmit_cmd(dev, 0x11); /* Sleep Out */
  655. k_msleep(120);
  656. _panel_transmit_cmd(dev, 0x29); /* Display On */
  657. k_msleep(120);
  658. _panel_transmit_cmd(dev, 0x1c);
  659. k_msleep(120);
  660. #endif
  661. // _panel_init_te(dev);
  662. printk("st77916 panel_init exit\r\n ");
  663. return 0;
  664. }
  665. static const struct lcd_panel_ops lcd_panel_ops = {
  666. .init = _panel_init,
  667. .blanking_on = _panel_blanking_on,
  668. .blanking_off = _panel_blanking_off,
  669. .lowpower_enter = _panel_lowpower_enter,
  670. .lowpower_exit = _panel_lowpower_exit,
  671. .set_brightness = _panel_set_brightness,
  672. .write_prepare = _panel_set_mem_area,
  673. };
  674. const struct lcd_panel_config lcd_panel_st77916_config = {
  675. .videoport = PANEL_VIDEO_PORT_INITIALIZER,
  676. .videomode = PANEL_VIDEO_MODE_INITIALIZER,
  677. .ops = &lcd_panel_ops,
  678. .cmd_ramwr = (0x32 << 24 | DDIC_CMD_RAMWR << 8),
  679. .cmd_ramwc = (0x32 << 24 | DDIC_CMD_RAMWRC << 8),
  680. .tw_reset = 10,
  681. .ts_reset = 120,
  682. };