panel_rm69090.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  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_rm69090.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, (0x02 << 24) | (cmd << 8), 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_p4(const struct device *dev, uint32_t cmd,
  43. uint8_t data1, uint8_t data2, uint8_t data3, uint8_t data4)
  44. {
  45. uint8_t data_array[4] = { data1, data2, data3, data4 };
  46. _panel_transmit(dev, cmd, data_array, 4);
  47. }
  48. static void _panel_exit_sleep(const struct device *dev)
  49. {
  50. struct lcd_panel_data *data = dev->data;
  51. _panel_transmit_cmd(dev, DDIC_CMD_SLPOUT);
  52. k_msleep(150);
  53. data->in_sleep = 0;
  54. }
  55. static void _panel_init_te(const struct device *dev)
  56. {
  57. const struct lcd_panel_config *config = dev->config;
  58. if (config->videomode.flags & (DISPLAY_FLAGS_TE_HIGH | DISPLAY_FLAGS_TE_LOW)) {
  59. uint8_t tmp[2];
  60. sys_put_be16(CONFIG_PANEL_TE_SCANLINE, tmp);
  61. _panel_transmit(dev, DDIC_CMD_STESL, tmp, 2);
  62. tmp[0] = 0x02; /* only output vsync */
  63. _panel_transmit(dev, DDIC_CMD_TEON, tmp, 1);
  64. } else {
  65. _panel_transmit(dev, DDIC_CMD_TEOFF, NULL, 0);
  66. }
  67. }
  68. static int _panel_init(const struct device *dev)
  69. {
  70. const struct lcd_panel_config *config = dev->config;
  71. struct lcd_panel_data *data = dev->data;
  72. _panel_transmit_p1(dev, 0xFE, 0x01);
  73. _panel_transmit_p1(dev, 0x05, 0x00);
  74. _panel_transmit_p1(dev, 0x06, 0x72);
  75. _panel_transmit_p1(dev, 0x0D, 0x00);
  76. _panel_transmit_p1(dev, 0x0E, 0x81);//AVDD=6V
  77. _panel_transmit_p1(dev, 0x0F, 0x81);
  78. _panel_transmit_p1(dev, 0x10, 0x11);//AVDD=3VCI
  79. _panel_transmit_p1(dev, 0x11, 0x81);//VCL=-VCI
  80. _panel_transmit_p1(dev, 0x12, 0x81);
  81. _panel_transmit_p1(dev, 0x13, 0x80);//VGH=AVDD
  82. _panel_transmit_p1(dev, 0x14, 0x80);
  83. _panel_transmit_p1(dev, 0x15, 0x81);//VGL=
  84. _panel_transmit_p1(dev, 0x16, 0x81);
  85. _panel_transmit_p1(dev, 0x18, 0x66);//VGHR=6V
  86. _panel_transmit_p1(dev, 0x19, 0x88);//VGLR=-6V
  87. _panel_transmit_p1(dev, 0x5B, 0x10);//VREFPN5 Regulator Enable
  88. _panel_transmit_p1(dev, 0x5C, 0x55);
  89. _panel_transmit_p1(dev, 0x62, 0x19);//Normal VREFN
  90. _panel_transmit_p1(dev, 0x63, 0x19);//Idle VREFN
  91. _panel_transmit_p1(dev, 0x70, 0x54);
  92. _panel_transmit_p1(dev, 0x74, 0x0C);
  93. _panel_transmit_p1(dev, 0xC5, 0x10);// NOR=IDLE=GAM1 // HBM=GAM2
  94. _panel_transmit_p1(dev, 0xFE, 0x01);
  95. _panel_transmit_p1(dev, 0x25, 0x03);
  96. _panel_transmit_p1(dev, 0x26, 0x32);
  97. _panel_transmit_p1(dev, 0x27, 0x0A);
  98. _panel_transmit_p1(dev, 0x28, 0x08);
  99. _panel_transmit_p1(dev, 0x2A, 0x03);
  100. _panel_transmit_p1(dev, 0x2B, 0x32);
  101. _panel_transmit_p1(dev, 0x2D, 0x0A);
  102. _panel_transmit_p1(dev, 0x2F, 0x08);
  103. _panel_transmit_p1(dev, 0x30, 0x43);//43: 15Hz
  104. _panel_transmit_p1(dev, 0x66, 0x90);
  105. _panel_transmit_p1(dev, 0x72, 0x1A);//OVDD 4.6V
  106. _panel_transmit_p1(dev, 0x73, 0x13);//OVSS -2.2V
  107. _panel_transmit_p1(dev, 0xFE, 0x01);
  108. _panel_transmit_p1(dev, 0x6A, 0x17);//RT4723 daz20013 0x17=-2.2
  109. _panel_transmit_p1(dev, 0x1B, 0x00);
  110. //VSR power saving
  111. _panel_transmit_p1(dev, 0x1D, 0x03);
  112. _panel_transmit_p1(dev, 0x1E, 0x03);
  113. _panel_transmit_p1(dev, 0x1F, 0x03);
  114. _panel_transmit_p1(dev, 0x20, 0x03);
  115. _panel_transmit_p1(dev, 0xFE, 0x01);
  116. _panel_transmit_p1(dev, 0x36, 0x00);
  117. _panel_transmit_p1(dev, 0x6C, 0x80);
  118. _panel_transmit_p1(dev, 0x6D, 0x19);//VGMP VGSP turn off at idle mode
  119. _panel_transmit_p1(dev, 0xFE, 0x04);
  120. _panel_transmit_p1(dev, 0x63, 0x00);
  121. _panel_transmit_p1(dev, 0x64, 0x0E);
  122. //Gamma1 - AOD/Normal
  123. _panel_transmit_p1(dev, 0xFE, 0x02);
  124. _panel_transmit_p1(dev, 0xA9, 0x30);//5.8V VGMPS
  125. _panel_transmit_p1(dev, 0xAA, 0xB9);//2.5V VGSP
  126. _panel_transmit_p1(dev, 0xAB, 0x01);
  127. //Gamma2 - HBM
  128. _panel_transmit_p1(dev, 0xFE, 0x03);//page2
  129. _panel_transmit_p1(dev, 0xA9, 0x30);//5.8V VGMP
  130. _panel_transmit_p1(dev, 0xAA, 0x90);//2V VGSP
  131. _panel_transmit_p1(dev, 0xAB, 0x01);
  132. //SW MAPPING
  133. _panel_transmit_p1(dev, 0xFE, 0x0C);
  134. _panel_transmit_p1(dev, 0x07, 0x1F);
  135. _panel_transmit_p1(dev, 0x08, 0x2F);
  136. _panel_transmit_p1(dev, 0x09, 0x3F);
  137. _panel_transmit_p1(dev, 0x0A, 0x4F);
  138. _panel_transmit_p1(dev, 0x0B, 0x5F);
  139. _panel_transmit_p1(dev, 0x0C, 0x6F);
  140. _panel_transmit_p1(dev, 0x0D, 0xFF);
  141. _panel_transmit_p1(dev, 0x0E, 0xFF);
  142. _panel_transmit_p1(dev, 0x0F, 0xFF);
  143. _panel_transmit_p1(dev, 0x10, 0xFF);
  144. _panel_transmit_p1(dev, 0xFE, 0x01);
  145. _panel_transmit_p1(dev, 0x42, 0x14);
  146. _panel_transmit_p1(dev, 0x43, 0x41);
  147. _panel_transmit_p1(dev, 0x44, 0x25);
  148. _panel_transmit_p1(dev, 0x45, 0x52);
  149. _panel_transmit_p1(dev, 0x46, 0x36);
  150. _panel_transmit_p1(dev, 0x47, 0x63);
  151. _panel_transmit_p1(dev, 0x48, 0x41);
  152. _panel_transmit_p1(dev, 0x49, 0x14);
  153. _panel_transmit_p1(dev, 0x4A, 0x52);
  154. _panel_transmit_p1(dev, 0x4B, 0x25);
  155. _panel_transmit_p1(dev, 0x4C, 0x63);
  156. _panel_transmit_p1(dev, 0x4D, 0x36);
  157. _panel_transmit_p1(dev, 0x4E, 0x16);
  158. _panel_transmit_p1(dev, 0x4F, 0x61);
  159. _panel_transmit_p1(dev, 0x50, 0x25);
  160. _panel_transmit_p1(dev, 0x51, 0x52);
  161. _panel_transmit_p1(dev, 0x52, 0x34);
  162. _panel_transmit_p1(dev, 0x53, 0x43);
  163. _panel_transmit_p1(dev, 0x54, 0x61);
  164. _panel_transmit_p1(dev, 0x55, 0x16);
  165. _panel_transmit_p1(dev, 0x56, 0x52);
  166. _panel_transmit_p1(dev, 0x57, 0x25);
  167. _panel_transmit_p1(dev, 0x58, 0x43);
  168. _panel_transmit_p1(dev, 0x59, 0x34);
  169. //Switch Timing Control
  170. _panel_transmit_p1(dev, 0xFE, 0x01);
  171. _panel_transmit_p1(dev, 0x3A, 0x00);
  172. _panel_transmit_p1(dev, 0x3B, 0x00);
  173. _panel_transmit_p1(dev, 0x3D, 0x12);
  174. _panel_transmit_p1(dev, 0x3F, 0x37);
  175. _panel_transmit_p1(dev, 0x40, 0x12);
  176. _panel_transmit_p1(dev, 0x41, 0x0F);
  177. _panel_transmit_p1(dev, 0x37, 0x0C);
  178. _panel_transmit_p1(dev, 0xFE, 0x04);
  179. _panel_transmit_p1(dev, 0x5D, 0x01);
  180. _panel_transmit_p1(dev, 0x75, 0x08);
  181. //VSR Marping command---L
  182. _panel_transmit_p1(dev, 0xFE, 0x04);
  183. _panel_transmit_p1(dev, 0x5E, 0x0F);
  184. _panel_transmit_p1(dev, 0x5F, 0x12);
  185. _panel_transmit_p1(dev, 0x60, 0xFF);
  186. _panel_transmit_p1(dev, 0x61, 0xFF);
  187. _panel_transmit_p1(dev, 0x62, 0xFF);
  188. //VSR Marping command---R
  189. _panel_transmit_p1(dev, 0xFE, 0x04);
  190. _panel_transmit_p1(dev, 0x76, 0xFF);
  191. _panel_transmit_p1(dev, 0x77, 0xFF);
  192. _panel_transmit_p1(dev, 0x78, 0x49);
  193. _panel_transmit_p1(dev, 0x79, 0xF3);
  194. _panel_transmit_p1(dev, 0x7A, 0xFF);
  195. //VSR1-STV
  196. _panel_transmit_p1(dev, 0xFE, 0x04);
  197. _panel_transmit_p1(dev, 0x00, 0x9D);
  198. _panel_transmit_p1(dev, 0x01, 0x00);
  199. _panel_transmit_p1(dev, 0x02, 0x00);
  200. _panel_transmit_p1(dev, 0x03, 0x00);
  201. _panel_transmit_p1(dev, 0x04, 0x00);
  202. _panel_transmit_p1(dev, 0x05, 0x01);
  203. _panel_transmit_p1(dev, 0x06, 0x01);
  204. _panel_transmit_p1(dev, 0x07, 0x01);
  205. _panel_transmit_p1(dev, 0x08, 0x00);
  206. //VSR2-SCK1
  207. _panel_transmit_p1(dev, 0xFE, 0x04);
  208. _panel_transmit_p1(dev, 0x09, 0xDC);
  209. _panel_transmit_p1(dev, 0x0A, 0x00);
  210. _panel_transmit_p1(dev, 0x0B, 0x02);
  211. _panel_transmit_p1(dev, 0x0C, 0x00);
  212. _panel_transmit_p1(dev, 0x0D, 0x08);
  213. _panel_transmit_p1(dev, 0x0E, 0x01);
  214. _panel_transmit_p1(dev, 0x0F, 0xCE);
  215. _panel_transmit_p1(dev, 0x10, 0x16);
  216. _panel_transmit_p1(dev, 0x11, 0x00);
  217. //VSR3-SCK2
  218. _panel_transmit_p1(dev, 0xFE, 0x04);
  219. _panel_transmit_p1(dev, 0x12, 0xDC);
  220. _panel_transmit_p1(dev, 0x13, 0x00);
  221. _panel_transmit_p1(dev, 0x14, 0x02);
  222. _panel_transmit_p1(dev, 0x15, 0x00);
  223. _panel_transmit_p1(dev, 0x16, 0x08);
  224. _panel_transmit_p1(dev, 0x17, 0x02);
  225. _panel_transmit_p1(dev, 0x18, 0xCE);
  226. _panel_transmit_p1(dev, 0x19, 0x16);
  227. _panel_transmit_p1(dev, 0x1A, 0x00);
  228. //VSR4-ECK1
  229. _panel_transmit_p1(dev, 0xFE, 0x04);
  230. _panel_transmit_p1(dev, 0x1B, 0xDC);
  231. _panel_transmit_p1(dev, 0x1C, 0x00);
  232. _panel_transmit_p1(dev, 0x1D, 0x02);
  233. _panel_transmit_p1(dev, 0x1E, 0x00);
  234. _panel_transmit_p1(dev, 0x1F, 0x08);
  235. _panel_transmit_p1(dev, 0x20, 0x01);
  236. _panel_transmit_p1(dev, 0x21, 0xCE);
  237. _panel_transmit_p1(dev, 0x22, 0x16);
  238. _panel_transmit_p1(dev, 0x23, 0x00);
  239. //VSR5-ECK2
  240. _panel_transmit_p1(dev, 0xFE, 0x04);
  241. _panel_transmit_p1(dev, 0x24, 0xDC);
  242. _panel_transmit_p1(dev, 0x25, 0x00);
  243. _panel_transmit_p1(dev, 0x26, 0x02);
  244. _panel_transmit_p1(dev, 0x27, 0x00);
  245. _panel_transmit_p1(dev, 0x28, 0x08);
  246. _panel_transmit_p1(dev, 0x29, 0x02);
  247. _panel_transmit_p1(dev, 0x2A, 0xCE);
  248. _panel_transmit_p1(dev, 0x2B, 0x16);
  249. _panel_transmit_p1(dev, 0x2D, 0x00);
  250. //VEN EM-STV
  251. _panel_transmit_p1(dev, 0xFE, 0x04);
  252. _panel_transmit_p1(dev, 0x53, 0x8A);
  253. _panel_transmit_p1(dev, 0x54, 0x00);
  254. _panel_transmit_p1(dev, 0x55, 0x03);
  255. _panel_transmit_p1(dev, 0x56, 0x01);
  256. _panel_transmit_p1(dev, 0x58, 0x01);
  257. _panel_transmit_p1(dev, 0x59, 0x00);
  258. _panel_transmit_p1(dev, 0x65, 0x76);
  259. _panel_transmit_p1(dev, 0x66, 0x19);
  260. _panel_transmit_p1(dev, 0x67, 0x00);
  261. _panel_transmit_p1(dev, 0xFE, 0x07);
  262. _panel_transmit_p1(dev, 0x15, 0x04);
  263. _panel_transmit_p1(dev, 0xFE, 0x05);
  264. _panel_transmit_p1(dev, 0x4C, 0x01);
  265. _panel_transmit_p1(dev, 0x4D, 0x82);
  266. _panel_transmit_p1(dev, 0x4E, 0x04);
  267. _panel_transmit_p1(dev, 0x4F, 0x00);
  268. _panel_transmit_p1(dev, 0x50, 0x20);
  269. _panel_transmit_p1(dev, 0x51, 0x10);
  270. _panel_transmit_p1(dev, 0x52, 0x04);
  271. _panel_transmit_p1(dev, 0x53, 0x41);
  272. _panel_transmit_p1(dev, 0x54, 0x0A);
  273. _panel_transmit_p1(dev, 0x55, 0x08);
  274. _panel_transmit_p1(dev, 0x56, 0x00);
  275. _panel_transmit_p1(dev, 0x57, 0x28);
  276. _panel_transmit_p1(dev, 0x58, 0x00);
  277. _panel_transmit_p1(dev, 0x59, 0x80);
  278. _panel_transmit_p1(dev, 0x5A, 0x04);
  279. _panel_transmit_p1(dev, 0x5B, 0x10);
  280. _panel_transmit_p1(dev, 0x5C, 0x20);
  281. _panel_transmit_p1(dev, 0x5D, 0x00);
  282. _panel_transmit_p1(dev, 0x5E, 0x04);
  283. _panel_transmit_p1(dev, 0x5F, 0x0A);
  284. _panel_transmit_p1(dev, 0x60, 0x01);
  285. _panel_transmit_p1(dev, 0x61, 0x08);
  286. _panel_transmit_p1(dev, 0x62, 0x00);
  287. _panel_transmit_p1(dev, 0x63, 0x20);
  288. _panel_transmit_p1(dev, 0x64, 0x40);
  289. _panel_transmit_p1(dev, 0x65, 0x04);
  290. _panel_transmit_p1(dev, 0x66, 0x02);
  291. _panel_transmit_p1(dev, 0x67, 0x48);
  292. _panel_transmit_p1(dev, 0x68, 0x4C);
  293. _panel_transmit_p1(dev, 0x69, 0x02);
  294. _panel_transmit_p1(dev, 0x6A, 0x12);
  295. _panel_transmit_p1(dev, 0x6B, 0x00);
  296. _panel_transmit_p1(dev, 0x6C, 0x48);
  297. _panel_transmit_p1(dev, 0x6D, 0xA0);
  298. _panel_transmit_p1(dev, 0x6E, 0x08);
  299. _panel_transmit_p1(dev, 0x6F, 0x04);
  300. _panel_transmit_p1(dev, 0x70, 0x05);
  301. _panel_transmit_p1(dev, 0x71, 0x92);
  302. _panel_transmit_p1(dev, 0x72, 0x00);
  303. _panel_transmit_p1(dev, 0x73, 0x18);
  304. _panel_transmit_p1(dev, 0x74, 0xA0);
  305. _panel_transmit_p1(dev, 0x75, 0x00);
  306. _panel_transmit_p1(dev, 0x76, 0x00);
  307. _panel_transmit_p1(dev, 0x77, 0xE4);
  308. _panel_transmit_p1(dev, 0x78, 0x00);
  309. _panel_transmit_p1(dev, 0x79, 0x04);
  310. _panel_transmit_p1(dev, 0x7A, 0x02);
  311. _panel_transmit_p1(dev, 0x7B, 0x01);
  312. _panel_transmit_p1(dev, 0x7C, 0x00);
  313. _panel_transmit_p1(dev, 0x7D, 0x00);
  314. _panel_transmit_p1(dev, 0x7E, 0x24);
  315. _panel_transmit_p1(dev, 0x7F, 0x4C);
  316. _panel_transmit_p1(dev, 0x80, 0x04);
  317. _panel_transmit_p1(dev, 0x81, 0x0A);
  318. _panel_transmit_p1(dev, 0x82, 0x02);
  319. _panel_transmit_p1(dev, 0x83, 0xC1);
  320. _panel_transmit_p1(dev, 0x84, 0x02);
  321. _panel_transmit_p1(dev, 0x85, 0x18);
  322. _panel_transmit_p1(dev, 0x86, 0x90);
  323. _panel_transmit_p1(dev, 0x87, 0x60);
  324. _panel_transmit_p1(dev, 0x88, 0x88);
  325. _panel_transmit_p1(dev, 0x89, 0x02);
  326. _panel_transmit_p1(dev, 0x8A, 0x09);
  327. _panel_transmit_p1(dev, 0x8B, 0x0C);
  328. _panel_transmit_p1(dev, 0x8C, 0x18);
  329. _panel_transmit_p1(dev, 0x8D, 0x90);
  330. _panel_transmit_p1(dev, 0x8E, 0x10);
  331. _panel_transmit_p1(dev, 0x8F, 0x08);
  332. _panel_transmit_p1(dev, 0x90, 0x00);
  333. _panel_transmit_p1(dev, 0x91, 0x10);
  334. _panel_transmit_p1(dev, 0x92, 0xA8);
  335. _panel_transmit_p1(dev, 0x93, 0x00);
  336. _panel_transmit_p1(dev, 0x94, 0x04);
  337. _panel_transmit_p1(dev, 0x95, 0x0A);
  338. _panel_transmit_p1(dev, 0x96, 0x00);
  339. _panel_transmit_p1(dev, 0x97, 0x08);
  340. _panel_transmit_p1(dev, 0x98, 0x10);
  341. _panel_transmit_p1(dev, 0x99, 0x28);
  342. _panel_transmit_p1(dev, 0x9A, 0x08);
  343. _panel_transmit_p1(dev, 0x9B, 0x04);
  344. _panel_transmit_p1(dev, 0x9C, 0x02);
  345. _panel_transmit_p1(dev, 0x9D, 0x03);
  346. _panel_transmit_p1(dev, 0xFE, 0x0C);
  347. _panel_transmit_p1(dev, 0x25, 0x00);
  348. _panel_transmit_p1(dev, 0x31, 0xEF);
  349. _panel_transmit_p1(dev, 0x32, 0xE3);
  350. _panel_transmit_p1(dev, 0x33, 0x00);
  351. _panel_transmit_p1(dev, 0x34, 0xE3);
  352. _panel_transmit_p1(dev, 0x35, 0xE3);
  353. _panel_transmit_p1(dev, 0x36, 0x80);
  354. _panel_transmit_p1(dev, 0x37, 0x00);
  355. _panel_transmit_p1(dev, 0x38, 0x79);
  356. _panel_transmit_p1(dev, 0x39, 0x00);
  357. _panel_transmit_p1(dev, 0x3A, 0x00);
  358. _panel_transmit_p1(dev, 0x3B, 0x00);
  359. _panel_transmit_p1(dev, 0x3D, 0x00);
  360. _panel_transmit_p1(dev, 0x3F, 0x00);
  361. _panel_transmit_p1(dev, 0x40, 0x00);
  362. _panel_transmit_p1(dev, 0x41, 0x00);
  363. _panel_transmit_p1(dev, 0x42, 0x00);
  364. _panel_transmit_p1(dev, 0x43, 0x01);
  365. if (config->videomode.refresh_rate == 50) {
  366. _panel_transmit_p1(dev, 0xFE, 0x01);
  367. _panel_transmit_p1(dev, 0x28, 0x64);
  368. } else if (config->videomode.refresh_rate == 30) {
  369. _panel_transmit_p1(dev, 0xFE, 0x01);
  370. _panel_transmit_p1(dev, 0x25, 0x07);
  371. }
  372. //_panel_transmit_p1(dev, 0xFE,0x04);
  373. //_panel_transmit_p1(dev, 0x05,0x08);
  374. _panel_transmit_p1(dev, 0xFE, 0x01);
  375. _panel_transmit_p1(dev, 0x6e, 0x0a); // 这两句把灭屏功耗降低一倍 (灭屏电流,LCD部分为110uA左右)
  376. _panel_transmit_p1(dev, 0xFE, 0x00);
  377. _panel_transmit_p1(dev, 0x36, 0x00); // 切记 RM69090 不能设置翻转 否则 撕裂
  378. _panel_transmit_p1(dev, 0x35, 0x00);
  379. _panel_transmit_p1(dev, 0xC4, 0x80);
  380. _panel_transmit_p1(dev, 0x51, data->brightness); //_panel_transmit_p1(dev, 0x51,0xFF);
  381. _panel_transmit_p4(dev, 0x2A, 0x00, 0x0C, 0x01, 0xD1);
  382. _panel_transmit_p4(dev, 0x2B, 0x00, 0x00, 0x01, 0xC5);
  383. if (config->videomode.pixel_format == PIXEL_FORMAT_BGR_565) {
  384. _panel_transmit_p1(dev, 0x3A, 0x55);//0x55:RGB565 0x77:RGB888
  385. } else {
  386. _panel_transmit_p1(dev, 0x3A, 0x77);//0x55:RGB565 0x77:RGB888
  387. }
  388. /* Sleep Out */
  389. _panel_exit_sleep(dev);
  390. _panel_init_te(dev);
  391. return 0;
  392. }
  393. static int _panel_set_brightness(const struct device *dev, uint8_t brightness)
  394. {
  395. _panel_transmit_p1(dev, DDIC_CMD_WRDISBV, brightness);
  396. return 0;
  397. }
  398. static int _panel_set_mem_area(const struct device *dev, uint16_t x,
  399. uint16_t y, uint16_t w, uint16_t h)
  400. {
  401. uint16_t cmd_data[2];
  402. x += CONFIG_PANEL_MEM_OFFSET_X; // add 12 pixel offset ?
  403. y += CONFIG_PANEL_MEM_OFFSET_Y;
  404. cmd_data[0] = sys_cpu_to_be16(x);
  405. cmd_data[1] = sys_cpu_to_be16(x + w - 1);
  406. _panel_transmit(dev, DDIC_CMD_CASET, (uint8_t *)&cmd_data[0], 4);
  407. cmd_data[0] = sys_cpu_to_be16(y);
  408. cmd_data[1] = sys_cpu_to_be16(y + h - 1);
  409. _panel_transmit(dev, DDIC_CMD_RASET, (uint8_t *)&cmd_data[0], 4);
  410. return 0;
  411. }
  412. static int _panel_blanking_on(const struct device *dev)
  413. {
  414. _panel_transmit_cmd(dev, DDIC_CMD_DISPOFF);
  415. _panel_transmit_cmd(dev, DDIC_CMD_SLPIN);
  416. return 0;
  417. }
  418. static int _panel_blanking_off(const struct device *dev)
  419. {
  420. struct lcd_panel_data *data = dev->data;
  421. if (data->in_sleep)
  422. _panel_exit_sleep(dev);
  423. _panel_transmit_cmd(dev, DDIC_CMD_DISPON);
  424. k_msleep(80);
  425. return 0;
  426. }
  427. static int _panel_lowpower_enter(const struct device *dev)
  428. {
  429. _panel_transmit_p1(dev, 0xFE, 0x01);
  430. /* 0x01 60Hz, 0x41 30Hz, 0x43 15Hz, 0x4B 5Hz, 0x7B 1Hz */
  431. _panel_transmit_p1(dev, 0x29, 0x4B);
  432. _panel_transmit_p1(dev, 0xFE, 0x00);
  433. return 0;
  434. }
  435. static int _panel_lowpower_exit(const struct device *dev)
  436. {
  437. _panel_transmit_p1(dev, 0xFE, 0x01);
  438. _panel_transmit_p1(dev, 0x29, 0x01);
  439. _panel_transmit_p1(dev, 0xFE, 0x00);
  440. return 0;
  441. }
  442. static const struct lcd_panel_ops lcd_panel_ops = {
  443. .init = _panel_init,
  444. .blanking_on = _panel_blanking_on,
  445. .blanking_off = _panel_blanking_off,
  446. .lowpower_enter = _panel_lowpower_enter,
  447. .lowpower_exit = _panel_lowpower_exit,
  448. .set_brightness = _panel_set_brightness,
  449. .write_prepare = _panel_set_mem_area,
  450. };
  451. const struct lcd_panel_config lcd_panel_rm69090_config = {
  452. .videoport = PANEL_VIDEO_PORT_INITIALIZER,
  453. .videomode = PANEL_VIDEO_MODE_INITIALIZER,
  454. .ops = &lcd_panel_ops,
  455. .cmd_ramwr = (0x32 << 24 | DDIC_CMD_RAMWR << 8),
  456. .cmd_ramwc = (0x32 << 24 | DDIC_CMD_RAMWRC << 8),
  457. .tw_reset = 10,
  458. .ts_reset = 120,
  459. };