mtk_drm_crtc.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790
  1. /*
  2. * Copyright (c) 2015 MediaTek Inc.
  3. * Copyright (C) 2021 XiaoMi, Inc.
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef MTK_DRM_CRTC_H
  15. #define MTK_DRM_CRTC_H
  16. #include <linux/types.h>
  17. #include <linux/workqueue.h>
  18. #include <linux/wait.h>
  19. #include <linux/soc/mediatek/mtk-cmdq.h>
  20. #include <drm/drm_crtc.h>
  21. #include "mtk_drm_ddp_comp.h"
  22. #include "mtk_drm_plane.h"
  23. #include <drm/drm_writeback.h>
  24. #include "mtk_debug.h"
  25. #include "mtk_log.h"
  26. #include "mtk_panel_ext.h"
  27. #include "mtk_drm_lowpower.h"
  28. #include "mtk_disp_recovery.h"
  29. #include "mtk_drm_ddp_addon.h"
  30. #include <linux/pm_wakeup.h>
  31. #include "mtk_disp_pmqos.h"
  32. #define MAX_CRTC 3
  33. #define OVL_LAYER_NR 12L
  34. #define OVL_PHY_LAYER_NR 4L
  35. #define RDMA_LAYER_NR 1UL
  36. #define EXTERNAL_INPUT_LAYER_NR 2UL
  37. #define MEMORY_INPUT_LAYER_NR 2UL
  38. #define MAX_PLANE_NR \
  39. ((OVL_LAYER_NR) + (EXTERNAL_INPUT_LAYER_NR) + (MEMORY_INPUT_LAYER_NR))
  40. #define MTK_PLANE_INPUT_LAYER_COUNT (OVL_LAYER_NR)
  41. #define MTK_LUT_SIZE 512
  42. #define MTK_MAX_BPC 10
  43. #define MTK_MIN_BPC 3
  44. #define BW_MODULE 17
  45. #define COLOR_MATRIX_PARAMS 17
  46. #define PRIMARY_OVL_PHY_LAYER_NR 6L
  47. #define PRIMARY_OVL_EXT_LAYER_NR 6L
  48. #define pgc _get_context()
  49. /* TODO: BW report module should not hardcode */
  50. enum DISP_PMQOS_SLOT {
  51. DISP_PMQOS_OVL0_BW = 0,
  52. DISP_PMQOS_OVL0_FBDC_BW,
  53. DISP_PMQOS_OVL1_BW,
  54. DISP_PMQOS_OVL1_FBDC_BW,
  55. DISP_PMQOS_OVL0_2L_BW,
  56. DISP_PMQOS_OVL0_2L_FBDC_BW,
  57. DISP_PMQOS_OVL1_2L_BW,
  58. DISP_PMQOS_OVL1_2L_FBDC_BW,
  59. DISP_PMQOS_OVL2_2L_BW,
  60. DISP_PMQOS_OVL2_2L_FBDC_BW,
  61. DISP_PMQOS_OVL3_2L_BW,
  62. DISP_PMQOS_OVL3_2L_FBDC_BW,
  63. DISP_PMQOS_RDMA0_BW,
  64. DISP_PMQOS_RDMA1_BW,
  65. DISP_PMQOS_RDMA2_BW,
  66. DISP_PMQOS_WDMA0_BW,
  67. DISP_PMQOS_WDMA1_BW
  68. };
  69. #define IGNORE_MODULE_IRQ
  70. #define DISP_SLOT_CUR_CONFIG_FENCE_BASE 0x0000
  71. #define DISP_SLOT_CUR_CONFIG_FENCE(n) \
  72. (DISP_SLOT_CUR_CONFIG_FENCE_BASE + (0x4 * (n)))
  73. #define DISP_SLOT_PRESENT_FENCE(n) \
  74. (DISP_SLOT_CUR_CONFIG_FENCE(OVL_LAYER_NR) + (0x4 * (n)))
  75. #define DISP_SLOT_SUBTRACTOR_WHEN_FREE_BASE \
  76. (DISP_SLOT_PRESENT_FENCE(MAX_CRTC) + 0x4)
  77. #define DISP_SLOT_SUBTRACTOR_WHEN_FREE(n) \
  78. (DISP_SLOT_SUBTRACTOR_WHEN_FREE_BASE + (0x4 * (n)))
  79. #define DISP_SLOT_ESD_READ_BASE DISP_SLOT_SUBTRACTOR_WHEN_FREE(OVL_LAYER_NR)
  80. #define DISP_SLOT_PMQOS_BW_BASE \
  81. (DISP_SLOT_ESD_READ_BASE + (ESD_CHECK_NUM * 2 * 0x4))
  82. #define DISP_SLOT_PMQOS_BW(n) (DISP_SLOT_PMQOS_BW_BASE + ((n)*0x4))
  83. #define DISP_SLOT_RDMA_FB_IDX_BASE (DISP_SLOT_PMQOS_BW(BW_MODULE))
  84. #define DISP_SLOT_RDMA_FB_IDX (DISP_SLOT_RDMA_FB_IDX_BASE + 0x4)
  85. #define DISP_SLOT_RDMA_FB_ID (DISP_SLOT_RDMA_FB_IDX + 0x4)
  86. #define DISP_SLOT_CUR_HRT_IDX (DISP_SLOT_RDMA_FB_ID + 0x4)
  87. #define DISP_SLOT_CUR_HRT_LEVEL (DISP_SLOT_CUR_HRT_IDX + 0x4)
  88. #define DISP_SLOT_CUR_OUTPUT_FENCE (DISP_SLOT_CUR_HRT_LEVEL + 0x4)
  89. #define DISP_SLOT_CUR_INTERFACE_FENCE (DISP_SLOT_CUR_OUTPUT_FENCE + 0x4)
  90. #define DISP_SLOT_COLOR_MATRIX_PARAMS(n) \
  91. ((DISP_SLOT_CUR_INTERFACE_FENCE + 0x4) + (n) * 0x4)
  92. #define DISP_SLOT_OVL_STATUS \
  93. (DISP_SLOT_COLOR_MATRIX_PARAMS(COLOR_MATRIX_PARAMS))
  94. #define DISP_SLOT_LAYER_REC_BASE (DISP_SLOT_OVL_STATUS + 0x4)
  95. #define DISP_SLOT_LAYER_REC_OVL0_2L (DISP_SLOT_LAYER_REC_BASE)
  96. #define DISP_SLOT_LAYER_REC_OVL0 (DISP_SLOT_LAYER_REC_OVL0_2L + 0x4 * 14)
  97. #define DISP_SLOT_LAYER_REC_END (DISP_SLOT_LAYER_REC_OVL0 + 0x4 * 18)
  98. #define DISP_SLOT_TRIG_CNT (DISP_SLOT_LAYER_REC_END)
  99. #define DISP_SLOT_READ_DDIC_BASE (DISP_SLOT_TRIG_CNT + 0x4)
  100. #define DISP_SLOT_READ_DDIC_BASE_END \
  101. (DISP_SLOT_READ_DDIC_BASE + READ_DDIC_SLOT_NUM * 0x4)
  102. #define DISP_SLOT_CUR_USER_CMD_IDX (DISP_SLOT_READ_DDIC_BASE_END + 0x4)
  103. #define DISP_SLOT_CUR_BL_IDX (DISP_SLOT_CUR_USER_CMD_IDX + 0x4)
  104. /* For Dynamic OVL feature */
  105. #define DISP_OVL_ROI_SIZE 0x20
  106. #define DISP_OVL_DATAPATH_CON 0x24
  107. /* TODO: figure out Display pipe which need report PMQOS BW */
  108. #define DISP_SLOT_SIZE (DISP_SLOT_CUR_BL_IDX + 0x4)
  109. #if DISP_SLOT_SIZE > CMDQ_BUF_ALLOC_SIZE
  110. #error "DISP_SLOT_SIZE exceed CMDQ_BUF_ALLOC_SIZE"
  111. #endif
  112. #define to_mtk_crtc(x) container_of(x, struct mtk_drm_crtc, base)
  113. #define to_mtk_crtc_state(x) container_of(x, struct mtk_crtc_state, base)
  114. #define _MTK_CRTC_COLOR_FMT_ID_SHIFT 0
  115. #define _MTK_CRTC_COLOR_FMT_ID_WIDTH 8
  116. #define _MTK_CRTC_COLOR_FMT_RGBSWAP_SHIFT \
  117. (_MTK_CRTC_COLOR_FMT_ID_SHIFT + _MTK_CRTC_COLOR_FMT_ID_WIDTH)
  118. #define _MTK_CRTC_COLOR_FMT_RGBSWAP_WIDTH 1
  119. #define _MTK_CRTC_COLOR_FMT_BYTESWAP_SHIFT \
  120. (_MTK_CRTC_COLOR_FMT_RGBSWAP_SHIFT + _MTK_CRTC_COLOR_FMT_RGBSWAP_WIDTH)
  121. #define _MTK_CRTC_COLOR_FMT_BYTESWAP_WIDTH 1
  122. #define _MTK_CRTC_COLOR_FMT_FORMAT_SHIFT \
  123. (_MTK_CRTC_COLOR_FMT_BYTESWAP_SHIFT + \
  124. _MTK_CRTC_COLOR_FMT_BYTESWAP_WIDTH)
  125. #define _MTK_CRTC_COLOR_FMT_FORMAT_WIDTH 5
  126. #define _MTK_CRTC_COLOR_FMT_VDO_SHIFT \
  127. (_MTK_CRTC_COLOR_FMT_FORMAT_SHIFT + _MTK_CRTC_COLOR_FMT_FORMAT_WIDTH)
  128. #define _MTK_CRTC_COLOR_FMT_VDO_WIDTH 1
  129. #define _MTK_CRTC_COLOR_FMT_BLOCK_SHIT \
  130. (_MTK_CRTC_COLOR_FMT_VDO_SHIFT + _MTK_CRTC_COLOR_FMT_VDO_WIDTH)
  131. #define _MTK_CRTC_COLOR_FMT_BLOCK_WIDTH 1
  132. #define _MTK_CRTC_COLOR_FMT_bpp_SHIFT \
  133. (_MTK_CRTC_COLOR_FMT_BLOCK_SHIT + _MTK_CRTC_COLOR_FMT_BLOCK_WIDTH)
  134. #define _MTK_CRTC_COLOR_FMT_bpp_WIDTH 6
  135. #define _MTK_CRTC_COLOR_FMT_RGB_SHIFT \
  136. (_MTK_CRTC_COLOR_FMT_bpp_SHIFT + _MTK_CRTC_COLOR_FMT_bpp_WIDTH)
  137. #define _MTK_CRTC_COLOR_FMT_RGB_WIDTH 1
  138. #if defined(CONFIG_MACH_MT6873) || defined(CONFIG_MACH_MT6853) \
  139. || defined(CONFIG_MACH_MT6833)
  140. #define GCE_BASE_ADDR 0x10228000
  141. #define GCE_GCTL_VALUE 0x48
  142. #define GCE_DEBUG_START_ADDR 0x1104
  143. #define GCE_DDR_EN BIT(16)
  144. #endif
  145. #define _MASK_SHIFT(val, width, shift) \
  146. (((val) >> (shift)) & ((1 << (width)) - 1))
  147. #define REG_FLD(width, shift) \
  148. ((unsigned int)((((width)&0xFF) << 16) | ((shift)&0xFF)))
  149. #define REG_FLD_MSB_LSB(msb, lsb) REG_FLD((msb) - (lsb) + 1, (lsb))
  150. #define REG_FLD_WIDTH(field) ((unsigned int)(((field) >> 16) & 0xFF))
  151. #define REG_FLD_SHIFT(field) ((unsigned int)((field)&0xFF))
  152. #define REG_FLD_MASK(field) \
  153. ((unsigned int)((1ULL << REG_FLD_WIDTH(field)) - 1) \
  154. << REG_FLD_SHIFT(field))
  155. #define REG_FLD_VAL(field, val) \
  156. (((val) << REG_FLD_SHIFT(field)) & REG_FLD_MASK(field))
  157. #define REG_FLD_VAL_GET(field, regval) \
  158. (((regval)&REG_FLD_MASK(field)) >> REG_FLD_SHIFT(field))
  159. #define DISP_REG_GET_FIELD(field, reg32) \
  160. REG_FLD_VAL_GET(field, __raw_readl((unsigned long *)(reg32)))
  161. #define SET_VAL_MASK(o_val, o_mask, i_val, i_fld) \
  162. do { \
  163. o_val |= (i_val << REG_FLD_SHIFT(i_fld)); \
  164. o_mask |= (REG_FLD_MASK(i_fld)); \
  165. } while (0)
  166. #define MAKE_CRTC_COLOR_FMT(rgb, bpp, block, vdo, format, byteswap, rgbswap, \
  167. id) \
  168. (((rgb) << _MTK_CRTC_COLOR_FMT_RGB_SHIFT) | \
  169. ((bpp) << _MTK_CRTC_COLOR_FMT_bpp_SHIFT) | \
  170. ((block) << _MTK_CRTC_COLOR_FMT_BLOCK_SHIT) | \
  171. ((vdo) << _MTK_CRTC_COLOR_FMT_VDO_SHIFT) | \
  172. ((format) << _MTK_CRTC_COLOR_FMT_FORMAT_SHIFT) | \
  173. ((byteswap) << _MTK_CRTC_COLOR_FMT_BYTESWAP_SHIFT) | \
  174. ((rgbswap) << _MTK_CRTC_COLOR_FMT_RGBSWAP_SHIFT) | \
  175. ((id) << _MTK_CRTC_COLOR_FMT_ID_SHIFT))
  176. #define MTK_CRTC_COLOR_FMT_GET_RGB(fmt) \
  177. _MASK_SHIFT(fmt, _MTK_CRTC_COLOR_FMT_RGB_WIDTH, \
  178. _MTK_CRTC_COLOR_FMT_RGB_SHIFT)
  179. #define MTK_CRTC_COLOR_FMT_GET_bpp(fmt) \
  180. _MASK_SHIFT(fmt, _MTK_CRTC_COLOR_FMT_bpp_WIDTH, \
  181. _MTK_CRTC_COLOR_FMT_bpp_SHIFT)
  182. #define MTK_CRTC_COLOR_FMT_GET_BLOCK(fmt) \
  183. _MASK_SHIFT(fmt, _MTK_CRTC_COLOR_FMT_BLOCK_WIDTH, \
  184. _MTK_CRTC_COLOR_FMT_BLOCK_SHIT)
  185. #define MTK_CRTC_COLOR_FMT_GET_VDO(fmt) \
  186. _MASK_SHIFT(fmt, _MTK_CRTC_COLOR_FMT_VDO_WIDTH, \
  187. _MTK_CRTC_COLOR_FMT_VDO_SHIFT)
  188. #define MTK_CRTC_COLOR_FMT_GET_FORMAT(fmt) \
  189. _MASK_SHIFT(fmt, _MTK_CRTC_COLOR_FMT_FORMAT_WIDTH, \
  190. _MTK_CRTC_COLOR_FMT_FORMAT_SHIFT)
  191. #define MTK_CRTC_COLOR_FMT_GET_BYTESWAP(fmt) \
  192. _MASK_SHIFT(fmt, _MTK_CRTC_COLOR_FMT_BYTESWAP_WIDTH, \
  193. _MTK_CRTC_COLOR_FMT_BYTESWAP_SHIFT)
  194. #define MTK_CRTC_COLOR_FMT_GET_RGBSWAP(fmt) \
  195. _MASK_SHIFT(fmt, _MTK_CRTC_COLOR_FMT_RGBSWAP_WIDTH, \
  196. _MTK_CRTC_COLOR_FMT_RGBSWAP_SHIFT)
  197. #define MTK_CRTC_COLOR_FMT_GET_ID(fmt) \
  198. _MASK_SHIFT(fmt, _MTK_CRTC_COLOR_FMT_ID_WIDTH, \
  199. _MTK_CRTC_COLOR_FMT_ID_SHIFT)
  200. #define MTK_CRTC_COLOR_FMT_GET_Bpp(fmt) (MTK_CRTC_COLOR_FMT_GET_bpp(fmt) / 8)
  201. #define MAX_CRTC_DC_FB 3
  202. #define for_each_comp_in_target_ddp_mode_bound(comp, mtk_crtc, __i, __j, \
  203. ddp_mode, offset) \
  204. for ((__i) = 0; (__i) < DDP_PATH_NR; (__i)++) \
  205. for ((__j) = 0; \
  206. (offset) < \
  207. (mtk_crtc)->ddp_ctx[ddp_mode].ddp_comp_nr[__i] && \
  208. (__j) < \
  209. (mtk_crtc)->ddp_ctx[ddp_mode].ddp_comp_nr[__i] - \
  210. offset && \
  211. ((comp) = (mtk_crtc)->ddp_ctx[ddp_mode].ddp_comp[__i] \
  212. [__j], \
  213. 1); \
  214. (__j)++) \
  215. for_each_if(comp)
  216. #define for_each_comp_in_target_ddp_mode(comp, mtk_crtc, __i, __j, ddp_mode) \
  217. for_each_comp_in_target_ddp_mode_bound(comp, mtk_crtc, __i, __j, \
  218. ddp_mode, 0)
  219. #define for_each_comp_in_crtc_path_bound(comp, mtk_crtc, __i, __j, offset) \
  220. for_each_comp_in_target_ddp_mode_bound(comp, mtk_crtc, __i, __j, \
  221. mtk_crtc->ddp_mode, offset)
  222. #define for_each_comp_in_cur_crtc_path(comp, mtk_crtc, __i, __j) \
  223. for_each_comp_in_crtc_path_bound(comp, mtk_crtc, __i, __j, 0)
  224. #define for_each_comp_in_crtc_target_path(comp, mtk_crtc, __i, ddp_path) \
  225. for ((__i) = 0; \
  226. (__i) < \
  227. (mtk_crtc)->ddp_ctx[mtk_crtc->ddp_mode] \
  228. .ddp_comp_nr[(ddp_path)] && \
  229. ((comp) = (mtk_crtc) \
  230. ->ddp_ctx[mtk_crtc->ddp_mode] \
  231. .ddp_comp[(ddp_path)][__i], \
  232. 1); \
  233. (__i)++) \
  234. for_each_if(comp)
  235. #define for_each_comp_in_crtc_target_mode(comp, mtk_crtc, __i, __j, ddp_mode) \
  236. for ((__i) = 0; (__i) < DDP_PATH_NR; (__i)++) \
  237. for ((__j) = 0; \
  238. (__j) < \
  239. (mtk_crtc)->ddp_ctx[ddp_mode].ddp_comp_nr[__i] && \
  240. ((comp) = (mtk_crtc)->ddp_ctx[ddp_mode].ddp_comp[__i] \
  241. [__j], \
  242. 1); \
  243. (__j)++) \
  244. for_each_if(comp)
  245. #define for_each_comp_in_crtc_path_reverse(comp, mtk_crtc, __i, __j) \
  246. for ((__i) = DDP_PATH_NR - 1; (__i) >= 0; (__i)--) \
  247. for ((__j) = \
  248. (mtk_crtc)->ddp_ctx[mtk_crtc->ddp_mode] \
  249. .ddp_comp_nr[__i] - \
  250. 1; \
  251. (__j) >= 0 && \
  252. ((comp) = (mtk_crtc) \
  253. ->ddp_ctx[mtk_crtc->ddp_mode] \
  254. .ddp_comp[__i][__j], \
  255. 1); \
  256. (__j)--) \
  257. for_each_if(comp)
  258. #define for_each_comp_in_all_crtc_mode(comp, mtk_crtc, __i, __j, p_mode) \
  259. for ((p_mode) = 0; (p_mode) < DDP_MODE_NR; (p_mode)++) \
  260. for ((__i) = 0; (__i) < DDP_PATH_NR; (__i)++) \
  261. for ((__j) = 0; (__j) < \
  262. (mtk_crtc)->ddp_ctx[p_mode] \
  263. .ddp_comp_nr[__i] && \
  264. ((comp) = (mtk_crtc) \
  265. ->ddp_ctx[p_mode] \
  266. .ddp_comp[__i][__j], \
  267. 1); \
  268. (__j)++) \
  269. for_each_if(comp)
  270. #define for_each_comp_id_in_path_data(comp_id, path_data, __i, __j, p_mode) \
  271. for ((p_mode) = 0; (p_mode) < DDP_MODE_NR; (p_mode)++) \
  272. for ((__i) = 0; (__i) < DDP_PATH_NR; (__i)++) \
  273. for ((__j) = 0; \
  274. (__j) < \
  275. (path_data)->path_len[p_mode][__i] && \
  276. ((comp_id) = (path_data) \
  277. ->path[p_mode][__i][__j], \
  278. 1); \
  279. (__j)++)
  280. #define for_each_comp_id_in_dual_pipe(comp_id, path_data, __i, __j) \
  281. for ((__i) = 0; (__i) < DDP_SECOND_PATH; (__i)++) \
  282. for ((__j) = 0; \
  283. (__j) < \
  284. (path_data)->dual_path_len[__i] && \
  285. ((comp_id) = (path_data) \
  286. ->dual_path[__i][__j], \
  287. 1); \
  288. (__j)++)
  289. #define for_each_comp_in_dual_pipe(comp, mtk_crtc, __i, __j) \
  290. for ((__i) = 0; (__i) < DDP_SECOND_PATH; (__i)++) \
  291. for ((__j) = 0; (__j) < \
  292. (mtk_crtc)->dual_pipe_ddp_ctx \
  293. .ddp_comp_nr[__i] && \
  294. ((comp) = (mtk_crtc) \
  295. ->dual_pipe_ddp_ctx \
  296. .ddp_comp[__i][__j], \
  297. 1); \
  298. (__j)++) \
  299. for_each_if(comp)
  300. #define for_each_wb_comp_id_in_path_data(comp_id, path_data, __i, p_mode) \
  301. for ((p_mode) = 0; (p_mode) < DDP_MODE_NR; (p_mode)++) \
  302. for ((__i) = 0; \
  303. (__i) < (path_data)->wb_path_len[p_mode] && \
  304. ((comp_id) = (path_data) \
  305. ->wb_path[p_mode][__i], 1); \
  306. (__i)++)
  307. enum MTK_CRTC_PROP {
  308. CRTC_PROP_OVERLAP_LAYER_NUM,
  309. CRTC_PROP_LYE_IDX,
  310. CRTC_PROP_PRES_FENCE_IDX,
  311. CRTC_PROP_DOZE_ACTIVE,
  312. CRTC_PROP_OUTPUT_ENABLE,
  313. CRTC_PROP_OUTPUT_FENCE_IDX,
  314. CRTC_PROP_OUTPUT_X,
  315. CRTC_PROP_OUTPUT_Y,
  316. CRTC_PROP_OUTPUT_WIDTH,
  317. CRTC_PROP_OUTPUT_HEIGHT,
  318. CRTC_PROP_OUTPUT_FB_ID,
  319. CRTC_PROP_INTF_FENCE_IDX,
  320. CRTC_PROP_DISP_MODE_IDX,
  321. CRTC_PROP_HBM_ENABLE,
  322. CRTC_PROP_COLOR_TRANSFORM,
  323. CRTC_PROP_USER_SCEN,
  324. CRTC_PROP_HDR_ENABLE,
  325. CRTC_PROP_MAX,
  326. };
  327. #define USER_SCEN_BLANK (BIT(0))
  328. enum MTK_CRTC_COLOR_FMT {
  329. CRTC_COLOR_FMT_UNKNOWN = 0,
  330. CRTC_COLOR_FMT_Y8 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 7, 0, 0, 1),
  331. CRTC_COLOR_FMT_RGBA4444 = MAKE_CRTC_COLOR_FMT(1, 16, 0, 0, 4, 0, 0, 2),
  332. CRTC_COLOR_FMT_RGBA5551 = MAKE_CRTC_COLOR_FMT(1, 16, 0, 0, 0, 0, 0, 3),
  333. CRTC_COLOR_FMT_RGB565 = MAKE_CRTC_COLOR_FMT(1, 16, 0, 0, 0, 0, 0, 4),
  334. CRTC_COLOR_FMT_BGR565 = MAKE_CRTC_COLOR_FMT(1, 16, 0, 0, 0, 1, 0, 5),
  335. CRTC_COLOR_FMT_RGB888 = MAKE_CRTC_COLOR_FMT(1, 24, 0, 0, 1, 1, 0, 6),
  336. CRTC_COLOR_FMT_BGR888 = MAKE_CRTC_COLOR_FMT(1, 24, 0, 0, 1, 0, 0, 7),
  337. CRTC_COLOR_FMT_RGBA8888 = MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 2, 1, 0, 8),
  338. CRTC_COLOR_FMT_BGRA8888 = MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 2, 0, 0, 9),
  339. CRTC_COLOR_FMT_ARGB8888 = MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 3, 1, 0, 10),
  340. CRTC_COLOR_FMT_ABGR8888 = MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 3, 0, 0, 11),
  341. CRTC_COLOR_FMT_RGBX8888 = MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 0, 0, 0, 12),
  342. CRTC_COLOR_FMT_BGRX8888 = MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 0, 0, 0, 13),
  343. CRTC_COLOR_FMT_XRGB8888 = MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 0, 0, 0, 14),
  344. CRTC_COLOR_FMT_XBGR8888 = MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 0, 0, 0, 15),
  345. CRTC_COLOR_FMT_AYUV = MAKE_CRTC_COLOR_FMT(0, 0, 0, 0, 0, 0, 0, 16),
  346. CRTC_COLOR_FMT_YUV = MAKE_CRTC_COLOR_FMT(0, 0, 0, 0, 0, 0, 0, 17),
  347. CRTC_COLOR_FMT_UYVY = MAKE_CRTC_COLOR_FMT(0, 16, 0, 0, 4, 0, 0, 18),
  348. CRTC_COLOR_FMT_VYUY = MAKE_CRTC_COLOR_FMT(0, 16, 0, 0, 4, 1, 0, 19),
  349. CRTC_COLOR_FMT_YUYV = MAKE_CRTC_COLOR_FMT(0, 16, 0, 0, 5, 0, 0, 20),
  350. CRTC_COLOR_FMT_YVYU = MAKE_CRTC_COLOR_FMT(0, 16, 0, 0, 5, 1, 0, 21),
  351. CRTC_COLOR_FMT_UYVY_BLK = MAKE_CRTC_COLOR_FMT(0, 16, 1, 0, 4, 0, 0, 22),
  352. CRTC_COLOR_FMT_VYUY_BLK = MAKE_CRTC_COLOR_FMT(0, 16, 1, 0, 4, 1, 0, 23),
  353. CRTC_COLOR_FMT_YUY2_BLK = MAKE_CRTC_COLOR_FMT(0, 16, 1, 0, 5, 0, 0, 24),
  354. CRTC_COLOR_FMT_YVYU_BLK = MAKE_CRTC_COLOR_FMT(0, 16, 1, 0, 5, 1, 0, 25),
  355. CRTC_COLOR_FMT_YV12 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 8, 1, 0, 26),
  356. CRTC_COLOR_FMT_I420 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 8, 0, 0, 27),
  357. CRTC_COLOR_FMT_YV16 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 9, 1, 0, 28),
  358. CRTC_COLOR_FMT_I422 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 9, 0, 0, 29),
  359. CRTC_COLOR_FMT_YV24 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 10, 1, 0, 30),
  360. CRTC_COLOR_FMT_I444 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 10, 0, 0, 31),
  361. CRTC_COLOR_FMT_NV12 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 12, 0, 0, 32),
  362. CRTC_COLOR_FMT_NV21 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 12, 1, 0, 33),
  363. CRTC_COLOR_FMT_NV12_BLK = MAKE_CRTC_COLOR_FMT(0, 8, 1, 0, 12, 0, 0, 34),
  364. CRTC_COLOR_FMT_NV21_BLK = MAKE_CRTC_COLOR_FMT(0, 8, 1, 0, 12, 1, 0, 35),
  365. CRTC_COLOR_FMT_NV12_BLK_FLD =
  366. MAKE_CRTC_COLOR_FMT(0, 8, 1, 1, 12, 0, 0, 36),
  367. CRTC_COLOR_FMT_NV21_BLK_FLD =
  368. MAKE_CRTC_COLOR_FMT(0, 8, 1, 1, 12, 1, 0, 37),
  369. CRTC_COLOR_FMT_NV16 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 13, 0, 0, 38),
  370. CRTC_COLOR_FMT_NV61 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 13, 1, 0, 39),
  371. CRTC_COLOR_FMT_NV24 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 14, 0, 0, 40),
  372. CRTC_COLOR_FMT_NV42 = MAKE_CRTC_COLOR_FMT(0, 8, 0, 0, 14, 1, 0, 41),
  373. CRTC_COLOR_FMT_PARGB8888 =
  374. MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 3, 1, 0, 42),
  375. CRTC_COLOR_FMT_PABGR8888 =
  376. MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 3, 1, 1, 43),
  377. CRTC_COLOR_FMT_PRGBA8888 =
  378. MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 3, 0, 1, 44),
  379. CRTC_COLOR_FMT_PBGRA8888 =
  380. MAKE_CRTC_COLOR_FMT(1, 32, 0, 0, 3, 0, 0, 45),
  381. };
  382. /* CLIENT_SODI_LOOP for sw workaround to fix gce hw bug */
  383. #define DECLARE_GCE_CLIENT(EXPR) \
  384. EXPR(CLIENT_CFG) \
  385. EXPR(CLIENT_TRIG_LOOP) \
  386. EXPR(CLIENT_SODI_LOOP) \
  387. EXPR(CLIENT_SUB_CFG) \
  388. EXPR(CLIENT_DSI_CFG) \
  389. EXPR(CLIENT_SEC_CFG) \
  390. EXPR(CLIENT_TYPE_MAX)
  391. enum CRTC_GCE_CLIENT_TYPE { DECLARE_GCE_CLIENT(DECLARE_NUM) };
  392. enum CRTC_GCE_EVENT_TYPE {
  393. EVENT_CMD_EOF,
  394. EVENT_VDO_EOF,
  395. EVENT_STREAM_EOF,
  396. EVENT_STREAM_DIRTY,
  397. #if defined(CONFIG_MACH_MT6873) || defined(CONFIG_MACH_MT6853) \
  398. || defined(CONFIG_MACH_MT6833)
  399. EVENT_SYNC_TOKEN_SODI,
  400. #endif
  401. EVENT_TE,
  402. EVENT_ESD_EOF,
  403. EVENT_RDMA0_EOF,
  404. EVENT_WDMA0_EOF,
  405. EVENT_WDMA1_EOF,
  406. EVENT_STREAM_BLOCK,
  407. EVENT_CABC_EOF,
  408. EVENT_DSI0_SOF,
  409. EVENT_TYPE_MAX,
  410. };
  411. enum CRTC_DDP_MODE {
  412. DDP_MAJOR,
  413. DDP_MINOR,
  414. DDP_MODE_NR,
  415. DDP_NO_USE,
  416. };
  417. enum CRTC_DDP_PATH {
  418. DDP_FIRST_PATH,
  419. DDP_SECOND_PATH,
  420. DDP_PATH_NR,
  421. };
  422. struct mtk_crtc_path_data {
  423. const enum mtk_ddp_comp_id *path[DDP_MODE_NR][DDP_PATH_NR];
  424. unsigned int path_len[DDP_MODE_NR][DDP_PATH_NR];
  425. bool path_req_hrt[DDP_MODE_NR][DDP_PATH_NR];
  426. const enum mtk_ddp_comp_id *wb_path[DDP_MODE_NR];
  427. unsigned int wb_path_len[DDP_MODE_NR];
  428. const struct mtk_addon_scenario_data *addon_data;
  429. //for dual path
  430. const enum mtk_ddp_comp_id *dual_path[DDP_PATH_NR];
  431. unsigned int dual_path_len[DDP_PATH_NR];
  432. };
  433. struct mtk_crtc_gce_obj {
  434. struct cmdq_client *client[CLIENT_TYPE_MAX];
  435. struct cmdq_pkt_buffer buf;
  436. struct cmdq_base *base;
  437. int event[EVENT_TYPE_MAX];
  438. };
  439. /**
  440. * struct mtk_crtc_ddp_ctx - MediaTek specific ddp structure for crtc path
  441. * control.
  442. * @mutex: handle to one of the ten disp_mutex streams
  443. * @ddp_comp_nr: number of components in ddp_comp
  444. * @ddp_comp: array of pointers the mtk_ddp_comp structures used by this crtc
  445. * @wb_comp_nr: number of components in 1to2 path
  446. * @wb_comp: array of pointers the mtk_ddp_comp structures used for 1to2 path
  447. * @wb_fb: temp wdma output buffer in 1to2 path
  448. * @dc_fb: frame buffer for decouple mode
  449. * @dc_fb_idx: the index of latest used fb
  450. */
  451. struct mtk_crtc_ddp_ctx {
  452. struct mtk_disp_mutex *mutex;
  453. unsigned int ddp_comp_nr[DDP_PATH_NR];
  454. struct mtk_ddp_comp **ddp_comp[DDP_PATH_NR];
  455. bool req_hrt[DDP_PATH_NR];
  456. unsigned int wb_comp_nr;
  457. struct mtk_ddp_comp **wb_comp;
  458. struct drm_framebuffer *wb_fb;
  459. struct drm_framebuffer *dc_fb;
  460. unsigned int dc_fb_idx;
  461. };
  462. struct mtk_drm_fake_vsync {
  463. struct task_struct *fvsync_task;
  464. wait_queue_head_t fvsync_wq;
  465. atomic_t fvsync_active;
  466. };
  467. struct mtk_drm_fake_layer {
  468. unsigned int fake_layer_mask;
  469. struct drm_framebuffer *fake_layer_buf[PRIMARY_OVL_PHY_LAYER_NR];
  470. bool init;
  471. bool first_dis;
  472. };
  473. struct disp_ccorr_config {
  474. int mode;
  475. int color_matrix[16];
  476. bool featureFlag;
  477. };
  478. /**
  479. * struct mtk_drm_crtc - MediaTek specific crtc structure.
  480. * @base: crtc object.
  481. * @enabled: records whether crtc_enable succeeded
  482. * @bpc: Maximum bits per color channel.
  483. * @lock: Mutex lock for critical section in crtc
  484. * @gce_obj: the elements for controlling GCE engine.
  485. * @planes: array of 4 drm_plane structures, one for each overlay plane
  486. * @pending_planes: whether any plane has pending changes to be applied
  487. * @config_regs: memory mapped mmsys configuration register space
  488. * @ddp_ctx: contain path components and mutex
  489. * @mutex: handle to one of the ten disp_mutex streams
  490. * @ddp_mode: the currently selected ddp path
  491. * @panel_ext: contain extended panel extended information and callback function
  492. * @esd_ctx: ESD check task context
  493. * @qos_ctx: BW Qos task context
  494. */
  495. struct mtk_drm_crtc {
  496. struct drm_crtc base;
  497. bool enabled;
  498. unsigned int bpc;
  499. bool pending_needs_vblank;
  500. struct mutex lock;
  501. struct drm_pending_vblank_event *event;
  502. struct mtk_crtc_gce_obj gce_obj;
  503. struct cmdq_pkt *trig_loop_cmdq_handle;
  504. #if defined(CONFIG_MACH_MT6873) || defined(CONFIG_MACH_MT6853) \
  505. || defined(CONFIG_MACH_MT6833)
  506. struct cmdq_pkt *sodi_loop_cmdq_handle;
  507. #endif
  508. struct mtk_drm_plane *planes;
  509. unsigned int layer_nr;
  510. bool pending_planes;
  511. void __iomem *config_regs;
  512. resource_size_t config_regs_pa;
  513. const struct mtk_mmsys_reg_data *mmsys_reg_data;
  514. struct mtk_crtc_ddp_ctx ddp_ctx[DDP_MODE_NR];
  515. struct mtk_disp_mutex *mutex[DDP_PATH_NR];
  516. unsigned int ddp_mode;
  517. unsigned int cur_config_fence[OVL_LAYER_NR];
  518. struct drm_writeback_connector wb_connector;
  519. bool wb_enable;
  520. bool wb_hw_enable;
  521. const struct mtk_crtc_path_data *path_data;
  522. struct mtk_crtc_ddp_ctx dual_pipe_ddp_ctx;
  523. bool is_dual_pipe;
  524. struct mtk_drm_idlemgr *idlemgr;
  525. wait_queue_head_t crtc_status_wq;
  526. struct mtk_panel_ext *panel_ext;
  527. struct mtk_drm_esd_ctx *esd_ctx;
  528. #ifdef CONFIG_MTK_ROUND_CORNER_SUPPORT
  529. struct mtk_drm_gem_obj *round_corner_gem;
  530. #endif
  531. struct mtk_drm_qos_ctx *qos_ctx;
  532. bool sec_on;
  533. struct task_struct *vblank_enable_task;
  534. wait_queue_head_t vblank_enable_wq;
  535. atomic_t vblank_enable_task_active;
  536. char *wk_lock_name;
  537. struct wakeup_source wk_lock;
  538. struct mtk_drm_fake_vsync *fake_vsync;
  539. struct mtk_drm_fake_layer fake_layer;
  540. /* DC mode - RDMA config thread*/
  541. struct task_struct *dc_main_path_commit_task;
  542. wait_queue_head_t dc_main_path_commit_wq;
  543. atomic_t dc_main_path_commit_event;
  544. struct task_struct *trigger_event_task;
  545. struct task_struct *trigger_delay_task;
  546. atomic_t trig_event_act;
  547. atomic_t trig_delay_act;
  548. atomic_t delayed_trig;
  549. wait_queue_head_t trigger_delay;
  550. wait_queue_head_t trigger_event;
  551. unsigned int avail_modes_num;
  552. struct drm_display_mode *avail_modes;
  553. struct timeval vblank_time;
  554. bool mipi_hopping_sta;
  555. bool panel_osc_hopping_sta;
  556. bool vblank_en;
  557. atomic_t already_config;
  558. bool layer_rec_en;
  559. unsigned int fps_change_index;
  560. wait_queue_head_t state_wait_queue;
  561. bool crtc_blank;
  562. struct mutex blank_lock;
  563. };
  564. struct mtk_crtc_state {
  565. struct drm_crtc_state base;
  566. struct cmdq_pkt *cmdq_handle;
  567. bool pending_config;
  568. unsigned int pending_width;
  569. unsigned int pending_height;
  570. unsigned int pending_vrefresh;
  571. struct mtk_lye_ddp_state lye_state;
  572. struct mtk_rect rsz_src_roi;
  573. struct mtk_rect rsz_dst_roi;
  574. atomic_t plane_enabled_num;
  575. /* property */
  576. unsigned int prop_val[CRTC_PROP_MAX];
  577. bool doze_changed;
  578. };
  579. struct mtk_cmdq_cb_data {
  580. struct drm_crtc_state *state;
  581. struct cmdq_pkt *cmdq_handle;
  582. struct drm_crtc *crtc;
  583. unsigned int misc;
  584. };
  585. int mtk_drm_crtc_enable_vblank(struct drm_device *drm, unsigned int pipe);
  586. void mtk_drm_crtc_disable_vblank(struct drm_device *drm, unsigned int pipe);
  587. bool mtk_crtc_get_vblank_timestamp(struct drm_device *dev, unsigned int pipe,
  588. int *max_error,
  589. struct timeval *vblank_time,
  590. bool in_vblank_irq);
  591. void mtk_drm_crtc_commit(struct drm_crtc *crtc);
  592. void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *comp);
  593. void mtk_crtc_vblank_irq(struct drm_crtc *crtc);
  594. int mtk_drm_crtc_create(struct drm_device *drm_dev,
  595. const struct mtk_crtc_path_data *path_data);
  596. void mtk_drm_crtc_plane_update(struct drm_crtc *crtc, struct drm_plane *plane,
  597. struct mtk_plane_state *state);
  598. void mtk_drm_crtc_dump(struct drm_crtc *crtc);
  599. void mtk_drm_crtc_analysis(struct drm_crtc *crtc);
  600. bool mtk_crtc_is_frame_trigger_mode(struct drm_crtc *crtc);
  601. void mtk_crtc_wait_frame_done(struct mtk_drm_crtc *mtk_crtc,
  602. struct cmdq_pkt *cmdq_handle,
  603. enum CRTC_DDP_PATH ddp_path,
  604. int clear_event);
  605. struct mtk_ddp_comp *mtk_ddp_comp_request_output(struct mtk_drm_crtc *mtk_crtc);
  606. /* get fence */
  607. int mtk_drm_crtc_getfence_ioctl(struct drm_device *dev, void *data,
  608. struct drm_file *file_priv);
  609. long mtk_crtc_wait_status(struct drm_crtc *crtc, bool status, long timeout);
  610. int mtk_crtc_path_switch(struct drm_crtc *crtc, unsigned int path_sel,
  611. int need_lock);
  612. void mtk_need_vds_path_switch(struct drm_crtc *crtc);
  613. void mtk_drm_crtc_first_enable(struct drm_crtc *crtc);
  614. void mtk_drm_crtc_enable(struct drm_crtc *crtc);
  615. void mtk_drm_crtc_disable(struct drm_crtc *crtc, bool need_wait);
  616. bool mtk_crtc_with_sub_path(struct drm_crtc *crtc, unsigned int ddp_mode);
  617. void mtk_crtc_ddp_prepare(struct mtk_drm_crtc *mtk_crtc);
  618. void mtk_crtc_ddp_unprepare(struct mtk_drm_crtc *mtk_crtc);
  619. void mtk_crtc_stop(struct mtk_drm_crtc *mtk_crtc, bool need_wait);
  620. void mtk_crtc_connect_default_path(struct mtk_drm_crtc *mtk_crtc);
  621. void mtk_crtc_disconnect_default_path(struct mtk_drm_crtc *mtk_crtc);
  622. void mtk_crtc_config_default_path(struct mtk_drm_crtc *mtk_crtc);
  623. void mtk_crtc_restore_plane_setting(struct mtk_drm_crtc *mtk_crtc);
  624. bool mtk_crtc_set_status(struct drm_crtc *crtc, bool status);
  625. void mtk_crtc_connect_addon_module(struct drm_crtc *crtc);
  626. void mtk_crtc_disconnect_addon_module(struct drm_crtc *crtc);
  627. int mtk_crtc_gce_flush(struct drm_crtc *crtc, void *gce_cb, void *cb_data,
  628. struct cmdq_pkt *cmdq_handle);
  629. struct cmdq_pkt *mtk_crtc_gce_commit_begin(struct drm_crtc *crtc);
  630. void mtk_crtc_pkt_create(struct cmdq_pkt **cmdq_handle,
  631. struct drm_crtc *crtc, struct cmdq_client *cl);
  632. int mtk_crtc_get_mutex_id(struct drm_crtc *crtc, unsigned int ddp_mode,
  633. enum mtk_ddp_comp_id find_comp);
  634. void mtk_crtc_disconnect_path_between_component(struct drm_crtc *crtc,
  635. unsigned int ddp_mode,
  636. enum mtk_ddp_comp_id prev,
  637. enum mtk_ddp_comp_id next,
  638. struct cmdq_pkt *cmdq_handle);
  639. void mtk_crtc_connect_path_between_component(struct drm_crtc *crtc,
  640. unsigned int ddp_mode,
  641. enum mtk_ddp_comp_id prev,
  642. enum mtk_ddp_comp_id next,
  643. struct cmdq_pkt *cmdq_handle);
  644. int mtk_crtc_find_comp(struct drm_crtc *crtc, unsigned int ddp_mode,
  645. enum mtk_ddp_comp_id comp_id);
  646. int mtk_crtc_find_next_comp(struct drm_crtc *crtc, unsigned int ddp_mode,
  647. enum mtk_ddp_comp_id comp_id);
  648. int mtk_crtc_find_prev_comp(struct drm_crtc *crtc, unsigned int ddp_mode,
  649. enum mtk_ddp_comp_id comp_id);
  650. void mtk_drm_fake_vsync_switch(struct drm_crtc *crtc, bool enable);
  651. void mtk_crtc_check_trigger(struct mtk_drm_crtc *mtk_crtc, bool delay,
  652. bool need_lock);
  653. bool mtk_crtc_is_dc_mode(struct drm_crtc *crtc);
  654. void mtk_crtc_clear_wait_event(struct drm_crtc *crtc);
  655. void mtk_crtc_hw_block_ready(struct drm_crtc *crtc);
  656. int mtk_crtc_lcm_ATA(struct drm_crtc *crtc);
  657. int mtk_crtc_mipi_freq_switch(struct drm_crtc *crtc, unsigned int en,
  658. unsigned int userdata);
  659. int mtk_crtc_osc_freq_switch(struct drm_crtc *crtc, unsigned int en,
  660. unsigned int userdata);
  661. int mtk_crtc_enter_tui(struct drm_crtc *crtc);
  662. int mtk_crtc_exit_tui(struct drm_crtc *crtc);
  663. struct drm_display_mode *mtk_drm_crtc_avail_disp_mode(struct drm_crtc *crtc,
  664. unsigned int idx);
  665. unsigned int mtk_drm_primary_frame_bw(struct drm_crtc *crtc);
  666. unsigned int mtk_drm_primary_display_get_debug_state(
  667. struct mtk_drm_private *priv, char *stringbuf, int buf_len);
  668. bool mtk_crtc_with_trigger_loop(struct drm_crtc *crtc);
  669. void mtk_crtc_stop_trig_loop(struct drm_crtc *crtc);
  670. void mtk_crtc_start_trig_loop(struct drm_crtc *crtc);
  671. #if defined(CONFIG_MACH_MT6873) || defined(CONFIG_MACH_MT6853) \
  672. || defined(CONFIG_MACH_MT6833)
  673. bool mtk_crtc_with_sodi_loop(struct drm_crtc *crtc);
  674. void mtk_crtc_stop_sodi_loop(struct drm_crtc *crtc);
  675. void mtk_crtc_start_sodi_loop(struct drm_crtc *crtc);
  676. #endif
  677. void mtk_crtc_change_output_mode(struct drm_crtc *crtc, int aod_en);
  678. int mtk_crtc_user_cmd(struct drm_crtc *crtc, struct mtk_ddp_comp *comp,
  679. unsigned int cmd, void *params);
  680. unsigned int mtk_drm_dump_wk_lock(struct mtk_drm_private *priv,
  681. char *stringbuf, int buf_len);
  682. char *mtk_crtc_index_spy(int crtc_index);
  683. bool mtk_drm_get_hdr_property(void);
  684. int mtk_drm_aod_setbacklight(struct drm_crtc *crtc, unsigned int level);
  685. int mtk_drm_crtc_wait_blank(struct mtk_drm_crtc *mtk_crtc);
  686. /* ********************* Legacy DISP API *************************** */
  687. unsigned int DISP_GetScreenWidth(void);
  688. unsigned int DISP_GetScreenHeight(void);
  689. void mtk_crtc_disable_secure_state(struct drm_crtc *crtc);
  690. int mtk_crtc_check_out_sec(struct drm_crtc *crtc);
  691. struct golden_setting_context *
  692. __get_golden_setting_context(struct mtk_drm_crtc *mtk_crtc);
  693. /*********************** PanelMaster ********************************/
  694. void mtk_crtc_start_for_pm(struct drm_crtc *crtc);
  695. void mtk_crtc_stop_for_pm(struct mtk_drm_crtc *mtk_crtc, bool need_wait);
  696. bool mtk_crtc_frame_buffer_existed(void);
  697. #endif /* MTK_DRM_CRTC_H */