panel_common.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. /*
  2. * Copyright (c) 2020 Actions Technology Co., Ltd
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #ifndef DRIVER_PANEL_COMMON_H__
  7. #define DRIVER_PANEL_COMMON_H__
  8. /*********************
  9. * INCLUDES
  10. *********************/
  11. #include <soc.h>
  12. #include <board.h>
  13. #include <drivers/display/display_controller.h>
  14. #include <drivers/display/display_engine.h>
  15. #include <drivers/gpio.h>
  16. #include <drivers/pwm.h>
  17. #include <assert.h>
  18. #ifndef CONFIG_MERGE_WORK_Q
  19. /* lcd used ldc work queue default */
  20. # define CONFIG_LCD_WORK_QUEUE (1)
  21. # define CONFIG_LCD_WORK_Q_STACK_SIZE (1024)
  22. #endif
  23. #if defined(CONFIG_PANEL_BACKLIGHT_PWM) || defined(CONFIG_PANEL_BACKLIGHT_GPIO)
  24. # define CONFIG_PANEL_BACKLIGHT_CTRL 1
  25. #endif
  26. /* Horizontal fixed (hardware) offset from the active area by write() */
  27. #ifndef CONFIG_PANEL_FIX_OFFSET_X
  28. # define CONFIG_PANEL_FIX_OFFSET_X (0)
  29. #endif
  30. /* Vertical fixed (hardware) offset from the active area by write() */
  31. #ifndef CONFIG_PANEL_FIX_OFFSET_Y
  32. # define CONFIG_PANEL_FIX_OFFSET_Y (0)
  33. #endif
  34. /* Horizontal-Resolution reported by get_capabilities() */
  35. #ifndef CONFIG_PANEL_HOR_RES
  36. # define CONFIG_PANEL_HOR_RES CONFIG_PANEL_TIMING_HACTIVE
  37. #elif CONFIG_PANEL_HOR_RES > CONFIG_PANEL_TIMING_HACTIVE
  38. # error "CONFIG_PANEL_HOR_RES must not exceed CONFIG_PANEL_TIMING_HACTIVE"
  39. #endif
  40. /* Vertical-Resolution reported by get_capabilities() */
  41. #ifndef CONFIG_PANEL_VER_RES
  42. # define CONFIG_PANEL_VER_RES CONFIG_PANEL_TIMING_VACTIVE
  43. #elif CONFIG_PANEL_VER_RES > CONFIG_PANEL_TIMING_VACTIVE
  44. # error "CONFIG_PANEL_VER_RES must not exceed CONFIG_PANEL_TIMING_VACTIVE"
  45. #endif
  46. /* Horizontal logical offset from the active area by write() */
  47. #ifndef CONFIG_PANEL_OFFSET_X
  48. # define CONFIG_PANEL_OFFSET_X (0)
  49. #elif CONFIG_PANEL_OFFSET_X + CONFIG_PANEL_HOR_RES > CONFIG_PANEL_TIMING_HACTIVE
  50. # error "CONFIG_PANEL_OFFSET_X + CONFIG_PANEL_HOR_RES must not exceed CONFIG_PANEL_TIMING_HACTIVE"
  51. #endif
  52. /* Vertical logical offset from the active area by write() */
  53. #ifndef CONFIG_PANEL_OFFSET_Y
  54. # define CONFIG_PANEL_OFFSET_Y (0)
  55. #elif CONFIG_PANEL_OFFSET_Y + CONFIG_PANEL_VER_RES > CONFIG_PANEL_TIMING_VACTIVE
  56. # error "CONFIG_PANEL_OFFSET_Y + CONFIG_PANEL_VER_RES must not exceed CONFIG_PANEL_TIMING_VACTIVE"
  57. #endif
  58. /* Horizontal total offset from the active area by write() */
  59. #define CONFIG_PANEL_MEM_OFFSET_X (CONFIG_PANEL_FIX_OFFSET_X + CONFIG_PANEL_OFFSET_X)
  60. /* Vertical total offset from the active area by write() */
  61. #define CONFIG_PANEL_MEM_OFFSET_Y (CONFIG_PANEL_FIX_OFFSET_Y + CONFIG_PANEL_OFFSET_Y)
  62. /* Screen shape: round or square ? */
  63. #ifndef CONFIG_PANEL_ROUND_SHAPE
  64. # define CONFIG_PANEL_ROUND_SHAPE (0)
  65. #endif
  66. /* Orientatioin: rotation angle [0|90|180|270] */
  67. #ifndef CONFIG_PANEL_ORIENTATION
  68. # define CONFIG_PANEL_ORIENTATION (0)
  69. #endif
  70. /* Brightness in normal mode, range [0, 255] */
  71. #ifndef CONFIG_PANEL_BRIGHTNESS
  72. # define CONFIG_PANEL_BRIGHTNESS (255)
  73. #endif
  74. /* Brightness in AOD mode, range [0, 255] */
  75. #ifndef CONFIG_PANEL_AOD_BRIGHTNESS
  76. # define CONFIG_PANEL_AOD_BRIGHTNESS CONFIG_PANEL_BRIGHTNESS
  77. #endif
  78. /* Delay some TE/vsync periods to apply the brightness after blanking off, range [0, 255] */
  79. #ifndef CONFIG_PANEL_BRIGHTNESS_DELAY_PERIODS
  80. # define CONFIG_PANEL_BRIGHTNESS_DELAY_PERIODS (0)
  81. #endif
  82. /* ESD check perion in milliseconds */
  83. #ifndef CONFIG_PANEL_ESD_CHECK_PERIOD
  84. # define CONFIG_PANEL_ESD_CHECK_PERIOD (0)
  85. #endif
  86. /********************************************
  87. * Configuration of display videoport
  88. ********************************************/
  89. /* define variable of struct display_videoport */
  90. #ifndef CONFIG_PANEL_PORT_CS
  91. # define CONFIG_PANEL_PORT_CS (0)
  92. #endif
  93. #ifndef CONFIG_PANEL_PORT_LSB_FIRST
  94. # define CONFIG_PANEL_PORT_LSB_FIRST (0)
  95. #endif
  96. #ifndef CONFIG_PANEL_PORT_SPI_CPOL
  97. # define CONFIG_PANEL_PORT_SPI_CPOL (1)
  98. #endif
  99. #ifndef CONFIG_PANEL_PORT_SPI_CPHA
  100. # define CONFIG_PANEL_PORT_SPI_CPHA (1)
  101. #endif
  102. #ifndef CONFIG_PANEL_PORT_SPI_DCP_MODE
  103. # define CONFIG_PANEL_PORT_SPI_DCP_MODE (0)
  104. #endif
  105. #ifndef CONFIG_PANEL_PORT_SPI_DUAL_LANE
  106. # define CONFIG_PANEL_PORT_SPI_DUAL_LANE (1)
  107. #endif
  108. /* read data lane select for QSPI (if exist) */
  109. #ifndef CONFIG_PANEL_PORT_SPI_RD_DATA_LANE
  110. # define CONFIG_PANEL_PORT_SPI_RD_DATA_LANE (0)
  111. #endif
  112. /* dummy cycles between read command and the following data (if exist) */
  113. #ifndef CONFIG_PANEL_PORT_SPI_RD_DUMMY_CYCLES
  114. # define CONFIG_PANEL_PORT_SPI_RD_DUMMY_CYCLES (0)
  115. #endif
  116. #ifndef CONFIG_PANEL_PORT_SPI_RD_DELAY_NS
  117. # define CONFIG_PANEL_PORT_SPI_RD_DELAY_NS (0)
  118. #endif
  119. #ifndef CONFIG_PANEL_PORT_SPI_CSX_DELAY_NS
  120. # define CONFIG_PANEL_PORT_SPI_CSX_DELAY_NS (0)
  121. #endif
  122. #ifndef CONFIG_PANEL_PORT_SPI_SCL_DELAY_NS
  123. # define CONFIG_PANEL_PORT_SPI_SCL_DELAY_NS (0)
  124. #endif
  125. #ifndef CONFIG_PANEL_PORT_SPI_WR_D0_DELAY_NS
  126. # define CONFIG_PANEL_PORT_SPI_WR_D0_DELAY_NS (0)
  127. #endif
  128. #ifndef CONFIG_PANEL_PORT_SPI_WR_D1_DELAY_NS
  129. # define CONFIG_PANEL_PORT_SPI_WR_D1_DELAY_NS (0)
  130. #endif
  131. #ifndef CONFIG_PANEL_PORT_SPI_WR_D2_DELAY_NS
  132. # define CONFIG_PANEL_PORT_SPI_WR_D2_DELAY_NS (0)
  133. #endif
  134. #ifndef CONFIG_PANEL_PORT_SPI_WR_D3_DELAY_NS
  135. # define CONFIG_PANEL_PORT_SPI_WR_D3_DELAY_NS (0)
  136. #endif
  137. /* Possible values: 1, 2, 4, 8 */
  138. #ifndef CONFIG_PANEL_PORT_SPI_AHB_CLK_DIVISION
  139. # define CONFIG_PANEL_PORT_SPI_AHB_CLK_DIVISION (1)
  140. #endif
  141. #ifndef CONFIG_PANEL_PORT_MCU_CLK_HIGH_DURATION
  142. # define CONFIG_PANEL_PORT_MCU_CLK_HIGH_DURATION (1)
  143. #endif
  144. #ifndef CONFIG_PANEL_PORT_MCU_CLK_LOW_DURATION
  145. # define CONFIG_PANEL_PORT_MCU_CLK_LOW_DURATION (1)
  146. #endif
  147. #ifndef CONFIG_PANEL_PORT_BUS_WIDTH
  148. # define CONFIG_PANEL_PORT_BUS_WIDTH (8)
  149. #endif
  150. /**********************************
  151. * TR-LCD
  152. **********************************/
  153. #ifndef CONFIG_PANEL_PORT_TR_LOW_BIT
  154. # define CONFIG_PANEL_PORT_TR_LOW_BIT (3)
  155. #endif
  156. #ifndef CONFIG_PANEL_PORT_TR_HCK_TAIL
  157. # define CONFIG_PANEL_PORT_TR_HCK_TAIL (1)
  158. #endif
  159. #ifndef CONFIG_PANEL_PORT_TR_VCK_ON_XRST_LOW
  160. # define CONFIG_PANEL_PORT_TR_VCK_ON_XRST_LOW (0)
  161. #endif
  162. #ifndef CONFIG_PANEL_PORT_TR_VCK_ON_IDLE
  163. # define CONFIG_PANEL_PORT_TR_VCK_ON_IDLE (0)
  164. #endif
  165. #ifndef CONFIG_PANEL_PORT_TR_HCK_ON_IDLE
  166. # define CONFIG_PANEL_PORT_TR_HCK_ON_IDLE (0)
  167. #endif
  168. #ifndef CONFIG_PANEL_PORT_TR_PARTIAL_UPDATE
  169. # define CONFIG_PANEL_PORT_TR_PARTIAL_UPDATE (0)
  170. #endif
  171. #ifndef CONFIG_PANEL_PORT_TR_FRP
  172. # define CONFIG_PANEL_PORT_TR_FRP (0)
  173. #endif
  174. #ifndef CONFIG_PANEL_PORT_TR_VCOM_INVERSE
  175. # define CONFIG_PANEL_PORT_TR_VCOM_INVERSE (0)
  176. #endif
  177. #ifndef CONFIG_PANEL_PORT_TR_FRP_INVERSE
  178. # define CONFIG_PANEL_PORT_TR_FRP_INVERSE (0)
  179. #endif
  180. #ifndef CONFIG_PANEL_PORT_TR_XFRP_INVERSE
  181. # define CONFIG_PANEL_PORT_TR_XFRP_INVERSE (0)
  182. #endif
  183. #ifndef CONFIG_PANEL_PORT_TR_XRST_INVERSE
  184. # define CONFIG_PANEL_PORT_TR_XRST_INVERSE (0)
  185. #endif
  186. #ifndef CONFIG_PANEL_PORT_TR_VST_INVERSE
  187. # define CONFIG_PANEL_PORT_TR_VST_INVERSE (0)
  188. #endif
  189. #ifndef CONFIG_PANEL_PORT_TR_HST_INVERSE
  190. # define CONFIG_PANEL_PORT_TR_HST_INVERSE (0)
  191. #endif
  192. #ifndef CONFIG_PANEL_PORT_TR_VCK_INVERSE
  193. # define CONFIG_PANEL_PORT_TR_VCK_INVERSE (0)
  194. #endif
  195. #ifndef CONFIG_PANEL_PORT_TR_HCK_INVERSE
  196. # define CONFIG_PANEL_PORT_TR_HCK_INVERSE (0)
  197. #endif
  198. #ifndef CONFIG_PANEL_PORT_TR_ENB_INVERSE
  199. # define CONFIG_PANEL_PORT_TR_ENB_INVERSE (0)
  200. #endif
  201. #ifndef CONFIG_PANEL_PORT_TR_TW_XRST
  202. # define CONFIG_PANEL_PORT_TR_TW_XRST (0)
  203. #endif
  204. #ifndef CONFIG_PANEL_PORT_TR_TW_VCOM
  205. # define CONFIG_PANEL_PORT_TR_TW_VCOM (0)
  206. #endif
  207. #ifndef CONFIG_PANEL_PORT_TR_TD_VST
  208. # define CONFIG_PANEL_PORT_TR_TD_VST (0)
  209. #endif
  210. #ifndef CONFIG_PANEL_PORT_TR_TW_VST
  211. # define CONFIG_PANEL_PORT_TR_TW_VST (0)
  212. #endif
  213. #ifndef CONFIG_PANEL_PORT_TR_TD_HST
  214. # define CONFIG_PANEL_PORT_TR_TD_HST (0)
  215. #endif
  216. #ifndef CONFIG_PANEL_PORT_TR_TW_HST
  217. # define CONFIG_PANEL_PORT_TR_TW_HST (0)
  218. #endif
  219. #ifndef CONFIG_PANEL_PORT_TR_TD_VCK
  220. # define CONFIG_PANEL_PORT_TR_TD_VCK (0)
  221. #endif
  222. #ifndef CONFIG_PANEL_PORT_TR_TW_VCK
  223. # define CONFIG_PANEL_PORT_TR_TW_VCK (0)
  224. #endif
  225. #ifndef CONFIG_PANEL_PORT_TR_TP_HCK
  226. # define CONFIG_PANEL_PORT_TR_TP_HCK (2)
  227. #endif
  228. #ifndef CONFIG_PANEL_PORT_TR_TD_HCK
  229. # define CONFIG_PANEL_PORT_TR_TD_HCK (4)
  230. #endif
  231. #ifndef CONFIG_PANEL_PORT_TR_TS_ENB
  232. # define CONFIG_PANEL_PORT_TR_TS_ENB (0)
  233. #endif
  234. #ifndef CONFIG_PANEL_PORT_TR_TH_ENB
  235. # define CONFIG_PANEL_PORT_TR_TH_ENB (0)
  236. #endif
  237. #ifndef CONFIG_PANEL_PORT_TR_TD_DATA
  238. # define CONFIG_PANEL_PORT_TR_TD_DATA (0)
  239. #endif
  240. #ifndef CONFIG_PANEL_PORT_TR_TD_ENB
  241. # define CONFIG_PANEL_PORT_TR_TD_ENB (0)
  242. #endif
  243. #ifndef CONFIG_PANEL_PORT_TR_TW_ENB
  244. # define CONFIG_PANEL_PORT_TR_TW_ENB (0)
  245. #endif
  246. #ifndef CONFIG_PANEL_PORT_TR_TSM_ENB
  247. # define CONFIG_PANEL_PORT_TR_TSM_ENB (3)
  248. #endif
  249. #ifndef CONFIG_PANEL_PORT_TR_THM_ENB
  250. # define CONFIG_PANEL_PORT_TR_THM_ENB (0)
  251. #endif
  252. #ifndef CONFIG_PANEL_PORT_TR_TWM_VCK
  253. # define CONFIG_PANEL_PORT_TR_TWM_VCK (1)
  254. #endif
  255. /********************************************
  256. * structure display_videoport initializer
  257. ********************************************/
  258. #define IS_MCU_PANEL (DISPLAY_PORT_TYPE_MAJOR(CONFIG_PANEL_PORT_TYPE) == DISPLAY_PORT_MCU)
  259. #define IS_SPI_PANEL (DISPLAY_PORT_TYPE_MAJOR(CONFIG_PANEL_PORT_TYPE) == DISPLAY_PORT_SPI)
  260. #define IS_QSPI_SYNC_PANEL (CONFIG_PANEL_PORT_TYPE == DISPLAY_PORT_QSPI_SYNC)
  261. #define IS_TR_PANEL (DISPLAY_PORT_TYPE_MAJOR(CONFIG_PANEL_PORT_TYPE) == DISPLAY_PORT_TR)
  262. #if IS_MCU_PANEL
  263. #define PANEL_VIDEO_PORT_INITIALIZER \
  264. { \
  265. .type = CONFIG_PANEL_PORT_TYPE, \
  266. .mcu_mode = { \
  267. .cs = CONFIG_PANEL_PORT_CS, \
  268. .lsb_first = CONFIG_PANEL_PORT_LSB_FIRST, \
  269. .bus_width = CONFIG_PANEL_PORT_BUS_WIDTH, \
  270. .clk_high_duration = CONFIG_PANEL_PORT_MCU_CLK_HIGH_DURATION, \
  271. .clk_low_duration = CONFIG_PANEL_PORT_MCU_CLK_LOW_DURATION, \
  272. }, \
  273. }
  274. #elif IS_SPI_PANEL
  275. #define PANEL_VIDEO_PORT_INITIALIZER \
  276. { \
  277. .type = CONFIG_PANEL_PORT_TYPE, \
  278. .spi_mode = { \
  279. .cs = CONFIG_PANEL_PORT_CS, \
  280. .lsb_first = CONFIG_PANEL_PORT_LSB_FIRST, \
  281. .cpol = CONFIG_PANEL_PORT_SPI_CPOL, \
  282. .cpha = CONFIG_PANEL_PORT_SPI_CPHA, \
  283. .dual_lane = CONFIG_PANEL_PORT_SPI_DUAL_LANE, \
  284. .dcp_mode = CONFIG_PANEL_PORT_SPI_DCP_MODE, \
  285. .rd_lane = CONFIG_PANEL_PORT_SPI_RD_DATA_LANE, \
  286. .rd_dummy_cycles = CONFIG_PANEL_PORT_SPI_RD_DUMMY_CYCLES, \
  287. .rd_delay_ns = CONFIG_PANEL_PORT_SPI_RD_DELAY_NS, \
  288. .wr_delay_d0_ns = CONFIG_PANEL_PORT_SPI_WR_D0_DELAY_NS, \
  289. .wr_delay_d1_ns = CONFIG_PANEL_PORT_SPI_WR_D1_DELAY_NS, \
  290. .wr_delay_d2_ns = CONFIG_PANEL_PORT_SPI_WR_D2_DELAY_NS, \
  291. .wr_delay_d3_ns = CONFIG_PANEL_PORT_SPI_WR_D3_DELAY_NS, \
  292. .delay_csx_ns = CONFIG_PANEL_PORT_SPI_CSX_DELAY_NS, \
  293. .delay_scl_ns = CONFIG_PANEL_PORT_SPI_SCL_DELAY_NS, \
  294. .ahb_clk_div = CONFIG_PANEL_PORT_SPI_AHB_CLK_DIVISION, \
  295. }, \
  296. }
  297. #elif IS_TR_PANEL
  298. #define PANEL_VIDEO_PORT_INITIALIZER \
  299. { \
  300. .type = CONFIG_PANEL_PORT_TYPE, \
  301. .tr_mode = { \
  302. .low_bit = CONFIG_PANEL_PORT_TR_LOW_BIT, \
  303. .hck_tail_on = CONFIG_PANEL_PORT_TR_HCK_TAIL, \
  304. .vck_on_xrstl = CONFIG_PANEL_PORT_TR_VCK_ON_XRST_LOW, \
  305. .vck_on_idle = CONFIG_PANEL_PORT_TR_VCK_ON_IDLE, \
  306. .hck_on_idle = CONFIG_PANEL_PORT_TR_HCK_ON_IDLE, \
  307. .ptl_on = CONFIG_PANEL_PORT_TR_PARTIAL_UPDATE, \
  308. .frp_on = CONFIG_PANEL_PORT_TR_FRP, \
  309. .vcom_inv = CONFIG_PANEL_PORT_TR_VCOM_INVERSE, \
  310. .frp_inv = CONFIG_PANEL_PORT_TR_FRP_INVERSE, \
  311. .xfrp_inv = CONFIG_PANEL_PORT_TR_XFRP_INVERSE, \
  312. .xrst_inv = CONFIG_PANEL_PORT_TR_XRST_INVERSE, \
  313. .vst_inv = CONFIG_PANEL_PORT_TR_VST_INVERSE, \
  314. .hst_inv = CONFIG_PANEL_PORT_TR_HST_INVERSE, \
  315. .vck_inv = CONFIG_PANEL_PORT_TR_VCK_INVERSE, \
  316. .hck_inv = CONFIG_PANEL_PORT_TR_HCK_INVERSE, \
  317. .enb_inv = CONFIG_PANEL_PORT_TR_ENB_INVERSE, \
  318. .tw_xrst = CONFIG_PANEL_PORT_TR_TW_XRST, \
  319. .tw_vcom = CONFIG_PANEL_PORT_TR_TW_VCOM, \
  320. .td_vst = CONFIG_PANEL_PORT_TR_TD_VST, \
  321. .tw_vst = CONFIG_PANEL_PORT_TR_TW_VST, \
  322. .td_hst = CONFIG_PANEL_PORT_TR_TD_HST, \
  323. .tw_hst = CONFIG_PANEL_PORT_TR_TW_HST, \
  324. .td_vck = CONFIG_PANEL_PORT_TR_TD_VCK, \
  325. .tw_vck = CONFIG_PANEL_PORT_TR_TW_VCK, \
  326. .tp_hck = CONFIG_PANEL_PORT_TR_TP_HCK, \
  327. .td_hck = CONFIG_PANEL_PORT_TR_TD_HCK, \
  328. .ts_enb = CONFIG_PANEL_PORT_TR_TS_ENB, \
  329. .th_enb = CONFIG_PANEL_PORT_TR_TH_ENB, \
  330. .td_data = CONFIG_PANEL_PORT_TR_TD_DATA, \
  331. .td_enb = CONFIG_PANEL_PORT_TR_TD_ENB, \
  332. .tw_enb = CONFIG_PANEL_PORT_TR_TW_ENB, \
  333. .tsm_enb = CONFIG_PANEL_PORT_TR_TSM_ENB, \
  334. .thm_enb = CONFIG_PANEL_PORT_TR_THM_ENB, \
  335. .twm_vck = CONFIG_PANEL_PORT_TR_TWM_VCK, \
  336. }, \
  337. }
  338. #else
  339. #error "invalid port type."
  340. #endif
  341. #define PANEL_VIDEO_PORT_DEFINE(name) \
  342. struct display_videoport name = PANEL_VIDEO_PORT_INITIALIZER
  343. /********************************************
  344. * Configuration of display videomode
  345. ********************************************/
  346. #ifndef CONFIG_PANEL_COLOR_DEPTH
  347. # define CONFIG_PANEL_COLOR_DEPTH 16
  348. #endif
  349. #if CONFIG_PANEL_COLOR_DEPTH == 32
  350. # define CONFIG_PANEL_PIXEL_FORMAT PIXEL_FORMAT_ARGB_8888
  351. #elif CONFIG_PANEL_COLOR_DEPTH == 24
  352. # define CONFIG_PANEL_PIXEL_FORMAT PIXEL_FORMAT_RGB_888
  353. #else
  354. # define CONFIG_PANEL_PIXEL_FORMAT PIXEL_FORMAT_BGR_565
  355. #endif
  356. #ifndef CONFIG_PANEL_TIMING_REFRESH_RATE_HZ
  357. # define CONFIG_PANEL_TIMING_REFRESH_RATE_HZ (60)
  358. #endif
  359. #define CONFIG_PANEL_VSYNC_PERIOD_US \
  360. ((1000000 + CONFIG_PANEL_TIMING_REFRESH_RATE_HZ - 1) / CONFIG_PANEL_TIMING_REFRESH_RATE_HZ)
  361. #define CONFIG_PANEL_VSYNC_PERIOD_MS \
  362. ((1000 + CONFIG_PANEL_TIMING_REFRESH_RATE_HZ - 1) / CONFIG_PANEL_TIMING_REFRESH_RATE_HZ)
  363. #ifndef CONFIG_PANEL_TIMING_PIXEL_CLK_KHZ
  364. # define CONFIG_PANEL_TIMING_PIXEL_CLK_KHZ (50000)
  365. #endif
  366. /* measured in pixels */
  367. #ifndef CONFIG_PANEL_TIMING_HACTIVE
  368. # define CONFIG_PANEL_TIMING_HACTIVE (1)
  369. #endif
  370. /* measured in clock cycles */
  371. #ifndef CONFIG_PANEL_TIMING_HFRONT_PORCH
  372. # define CONFIG_PANEL_TIMING_HFRONT_PORCH (0)
  373. #endif
  374. /* measured in clock cycles */
  375. #ifndef CONFIG_PANEL_TIMING_HBACK_PORCH
  376. # define CONFIG_PANEL_TIMING_HBACK_PORCH (0)
  377. #endif
  378. /* measured in clock cycles */
  379. #ifndef CONFIG_PANEL_TIMING_HSYNC_LEN
  380. # define CONFIG_PANEL_TIMING_HSYNC_LEN (0)
  381. #endif
  382. /* measured in lines */
  383. #ifndef CONFIG_PANEL_TIMING_VACTIVE
  384. # define CONFIG_PANEL_TIMING_VACTIVE (1)
  385. #endif
  386. /* measured in lines */
  387. #ifndef CONFIG_PANEL_TIMING_VFRONT_PORCH
  388. # define CONFIG_PANEL_TIMING_VFRONT_PORCH (0)
  389. #endif
  390. /* measured in lines */
  391. #ifndef CONFIG_PANEL_TIMING_VBACK_PORCH
  392. # define CONFIG_PANEL_TIMING_VBACK_PORCH (0)
  393. #endif
  394. /* measured in lines */
  395. #ifndef CONFIG_PANEL_TIMING_VSYNC_LEN
  396. # define CONFIG_PANEL_TIMING_VSYNC_LEN (0)
  397. #endif
  398. #ifdef CONFIG_PANEL_TIMING_TE_ACTIVE
  399. # define PANEL_VIDEO_MODE_TE_FLAGS ((CONFIG_PANEL_TIMING_TE_ACTIVE) ? DISPLAY_FLAGS_TE_HIGH : DISPLAY_FLAGS_TE_LOW)
  400. #else
  401. # define PANEL_VIDEO_MODE_TE_FLAGS (0)
  402. #endif
  403. #ifdef CONFIG_PANEL_TIMING_HSYNC_ACTIVE
  404. # define PANEL_VIDEO_MODE_HSYNC_FLAGS ((CONFIG_PANEL_TIMING_HSYNC_ACTIVE) ? DISPLAY_FLAGS_HSYNC_HIGH : DISPLAY_FLAGS_HSYNC_LOW)
  405. #else
  406. # define PANEL_VIDEO_MODE_HSYNC_FLAGS (0)
  407. #endif
  408. #ifdef CONFIG_PANEL_TIMING_VSYNC_ACTIVE
  409. # define PANEL_VIDEO_MODE_VSYNC_FLAGS ((CONFIG_PANEL_TIMING_VSYNC_ACTIVE) ? DISPLAY_FLAGS_VSYNC_HIGH : DISPLAY_FLAGS_VSYNC_LOW)
  410. #else
  411. # define PANEL_VIDEO_MODE_VSYNC_FLAGS (0)
  412. #endif
  413. #ifdef CONFIG_PANEL_TIMING_DE_ACTIVE
  414. # define PANEL_VIDEO_MODE_DE_FLAGS ((CONFIG_PANEL_TIMING_DE_ACTIVE) ? DISPLAY_FLAGS_DE_HIGH : DISPLAY_FLAGS_DE_LOW)
  415. #else
  416. # define PANEL_VIDEO_MODE_DE_FLAGS (0)
  417. #endif
  418. #ifdef CONFIG_PANEL_TIMING_PIXELCLK_ACTIVE
  419. # define PANEL_VIDEO_MODE_PIXELCLK_FLAGS ((CONFIG_PANEL_TIMING_PIXELCLK_ACTIVE) ? DISPLAY_FLAGS_PIXDATA_NEGEDGE : DISPLAY_FLAGS_PIXDATA_POSEDGE)
  420. #else
  421. # define PANEL_VIDEO_MODE_PIXELCLK_FLAGS (0)
  422. #endif
  423. #ifdef CONFIG_PANEL_TIMING_SYNCCLK_ACTIVE
  424. # define PANEL_VIDEO_MODE_SYNCCLK_FLAGS ((CONFIG_PANEL_TIMING_SYNCCLK_ACTIVE) ? DISPLAY_FLAGS_SYNC_NEGEDGE : DISPLAY_FLAGS_SYNC_POSEDGE)
  425. #else
  426. # define PANEL_VIDEO_MODE_SYNCCLK_FLAGS (0)
  427. #endif
  428. /********************************************
  429. * structure display_videomode initializer
  430. ********************************************/
  431. #define PANEL_VIDEO_MODE_INITIALIZER \
  432. { \
  433. .pixel_format = CONFIG_PANEL_PIXEL_FORMAT, \
  434. .pixel_clk = CONFIG_PANEL_TIMING_PIXEL_CLK_KHZ, \
  435. .refresh_rate = CONFIG_PANEL_TIMING_REFRESH_RATE_HZ, \
  436. .hactive = CONFIG_PANEL_TIMING_HACTIVE, \
  437. .hfront_porch = CONFIG_PANEL_TIMING_HFRONT_PORCH, \
  438. .hback_porch = CONFIG_PANEL_TIMING_HBACK_PORCH, \
  439. .hsync_len = CONFIG_PANEL_TIMING_HSYNC_LEN, \
  440. .vactive = CONFIG_PANEL_TIMING_VACTIVE, \
  441. .vfront_porch = CONFIG_PANEL_TIMING_VFRONT_PORCH, \
  442. .vback_porch = CONFIG_PANEL_TIMING_VBACK_PORCH, \
  443. .vsync_len = CONFIG_PANEL_TIMING_VSYNC_LEN, \
  444. .flags = PANEL_VIDEO_MODE_TE_FLAGS | \
  445. PANEL_VIDEO_MODE_HSYNC_FLAGS | \
  446. PANEL_VIDEO_MODE_VSYNC_FLAGS | \
  447. PANEL_VIDEO_MODE_DE_FLAGS | \
  448. PANEL_VIDEO_MODE_PIXELCLK_FLAGS | \
  449. PANEL_VIDEO_MODE_SYNCCLK_FLAGS, \
  450. }
  451. #define PANEL_VIDEO_MODE_DEFINE(name) \
  452. struct display_videomode name = PANEL_VIDEO_MODE_INITIALIZER
  453. #endif /* DRIVER_PANEL_COMMON_H__ */