mtk_drm_ddp_comp.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  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_DDP_COMP_H
  15. #define MTK_DRM_DDP_COMP_H
  16. #include <linux/io.h>
  17. #include <linux/kernel.h>
  18. #include "mtk_log.h"
  19. #include "mtk_rect.h"
  20. #include "mtk_disp_pmqos.h"
  21. #include "mtk_drm_ddp_addon.h"
  22. struct device;
  23. struct device_node;
  24. struct drm_crtc;
  25. struct drm_device;
  26. struct mtk_plane_state;
  27. struct drm_crtc_state;
  28. struct mm_qos_request;
  29. #define ALIGN_TO(x, n) (((x) + ((n) - 1)) & ~((n) - 1))
  30. enum mtk_ddp_comp_type {
  31. MTK_DISP_OVL,
  32. MTK_DISP_RDMA,
  33. MTK_DISP_WDMA,
  34. MTK_DISP_COLOR,
  35. MTK_DISP_DITHER,
  36. MTK_DISP_CCORR,
  37. MTK_DISP_AAL,
  38. MTK_DISP_GAMMA,
  39. MTK_DISP_UFOE,
  40. MTK_DSI,
  41. MTK_DPI,
  42. MTK_DISP_PWM,
  43. MTK_DISP_MUTEX,
  44. MTK_DISP_OD,
  45. MTK_DISP_BLS,
  46. MTK_DISP_RSZ,
  47. MTK_DISP_POSTMASK,
  48. MTK_DMDP_RDMA,
  49. MTK_DMDP_HDR,
  50. MTK_DMDP_AAL,
  51. MTK_DMDP_RSZ,
  52. MTK_DMDP_TDSHP,
  53. MTK_DISP_DSC,
  54. MTK_DP_INTF,
  55. MTK_DISP_MERGE,
  56. MTK_DISP_DPTX,
  57. MTK_DISP_VIRTUAL,
  58. MTK_DDP_COMP_TYPE_MAX,
  59. };
  60. #define DECLARE_DDP_COMP(EXPR) \
  61. EXPR(DDP_COMPONENT_AAL0) \
  62. EXPR(DDP_COMPONENT_AAL1) \
  63. EXPR(DDP_COMPONENT_BLS) \
  64. EXPR(DDP_COMPONENT_CCORR0) \
  65. EXPR(DDP_COMPONENT_CCORR1) \
  66. EXPR(DDP_COMPONENT_COLOR0) \
  67. EXPR(DDP_COMPONENT_COLOR1) \
  68. EXPR(DDP_COMPONENT_COLOR2) \
  69. EXPR(DDP_COMPONENT_DITHER0) \
  70. EXPR(DDP_COMPONENT_DITHER1) \
  71. EXPR(DDP_COMPONENT_DPI0) \
  72. EXPR(DDP_COMPONENT_DPI1) \
  73. EXPR(DDP_COMPONENT_DSI0) \
  74. EXPR(DDP_COMPONENT_DSI1) \
  75. EXPR(DDP_COMPONENT_GAMMA0) \
  76. EXPR(DDP_COMPONENT_GAMMA1) \
  77. EXPR(DDP_COMPONENT_OD) \
  78. EXPR(DDP_COMPONENT_OD1) \
  79. EXPR(DDP_COMPONENT_OVL0) \
  80. EXPR(DDP_COMPONENT_OVL1) \
  81. EXPR(DDP_COMPONENT_OVL2) \
  82. EXPR(DDP_COMPONENT_OVL0_2L) \
  83. EXPR(DDP_COMPONENT_OVL1_2L) \
  84. EXPR(DDP_COMPONENT_OVL2_2L) \
  85. EXPR(DDP_COMPONENT_OVL3_2L) \
  86. EXPR(DDP_COMPONENT_OVL0_2L_VIRTUAL0) \
  87. EXPR(DDP_COMPONENT_OVL1_2L_VIRTUAL0) \
  88. EXPR(DDP_COMPONENT_OVL0_VIRTUAL0) \
  89. EXPR(DDP_COMPONENT_OVL1_VIRTUAL0) \
  90. EXPR(DDP_COMPONENT_OVL0_OVL0_2L_VIRTUAL0) \
  91. EXPR(DDP_COMPONENT_PWM0) \
  92. EXPR(DDP_COMPONENT_PWM1) \
  93. EXPR(DDP_COMPONENT_PWM2) \
  94. EXPR(DDP_COMPONENT_RDMA0) \
  95. EXPR(DDP_COMPONENT_RDMA1) \
  96. EXPR(DDP_COMPONENT_RDMA2) \
  97. EXPR(DDP_COMPONENT_RDMA3) \
  98. EXPR(DDP_COMPONENT_RDMA4) \
  99. EXPR(DDP_COMPONENT_RDMA5) \
  100. EXPR(DDP_COMPONENT_RDMA0_VIRTUAL0) \
  101. EXPR(DDP_COMPONENT_RDMA1_VIRTUAL0) \
  102. EXPR(DDP_COMPONENT_RDMA2_VIRTUAL0) \
  103. EXPR(DDP_COMPONENT_RSZ0) \
  104. EXPR(DDP_COMPONENT_RSZ1) \
  105. EXPR(DDP_COMPONENT_UFOE) \
  106. EXPR(DDP_COMPONENT_WDMA0) \
  107. EXPR(DDP_COMPONENT_WDMA1) \
  108. EXPR(DDP_COMPONENT_UFBC_WDMA0) \
  109. EXPR(DDP_COMPONENT_WDMA_VIRTUAL0) \
  110. EXPR(DDP_COMPONENT_WDMA_VIRTUAL1) \
  111. EXPR(DDP_COMPONENT_POSTMASK0) \
  112. EXPR(DDP_COMPONENT_POSTMASK1) \
  113. EXPR(DDP_COMPONENT_DMDP_RDMA0) \
  114. EXPR(DDP_COMPONENT_DMDP_HDR0) \
  115. EXPR(DDP_COMPONENT_DMDP_AAL0) \
  116. EXPR(DDP_COMPONENT_DMDP_RSZ0) \
  117. EXPR(DDP_COMPONENT_DMDP_TDSHP0) \
  118. EXPR(DDP_COMPONENT_DSC0) \
  119. EXPR(DDP_COMPONENT_MERGE0) \
  120. EXPR(DDP_COMPONENT_DPTX) \
  121. EXPR(DDP_COMPONENT_DP_INTF0) \
  122. EXPR(DDP_COMPONENT_RDMA4_VIRTUAL0) \
  123. EXPR(DDP_COMPONENT_RDMA5_VIRTUAL0) \
  124. EXPR(DDP_COMPONENT_MERGE1) \
  125. EXPR(DDP_COMPONENT_SPR0_VIRTUAL) \
  126. EXPR(DDP_COMPONENT_CM0) \
  127. EXPR(DDP_COMPONENT_SPR0) \
  128. EXPR(DDP_COMPONENT_ID_MAX)
  129. #define DECLARE_NUM(ENUM) ENUM,
  130. #define DECLARE_STR(STR) #STR,
  131. enum mtk_ddp_comp_id { DECLARE_DDP_COMP(DECLARE_NUM) };
  132. #if 0 /* Origin enum define */
  133. enum mtk_ddp_comp_id {
  134. DDP_COMPONENT_AAL0,
  135. DDP_COMPONENT_AAL1,
  136. DDP_COMPONENT_BLS,
  137. DDP_COMPONENT_CCORR0,
  138. DDP_COMPONENT_COLOR0,
  139. DDP_COMPONENT_COLOR1,
  140. DDP_COMPONENT_COLOR2,
  141. DDP_COMPONENT_DITHER0,
  142. DDP_COMPONENT_DPI0,
  143. DDP_COMPONENT_DPI1,
  144. DDP_COMPONENT_DSI0,
  145. DDP_COMPONENT_DSI1,
  146. DDP_COMPONENT_GAMMA0,
  147. DDP_COMPONENT_OD,
  148. DDP_COMPONENT_OD1,
  149. DDP_COMPONENT_OVL0,
  150. DDP_COMPONENT_OVL1,
  151. DDP_COMPONENT_OVL2,
  152. DDP_COMPONENT_OVL0_2L,
  153. DDP_COMPONENT_OVL1_2L,
  154. DDP_COMPONENT_OVL0_2L_VIRTUAL0,
  155. DDP_COMPONENT_OVL0_VIRTUAL0,
  156. DDP_COMPONENT_PWM0,
  157. DDP_COMPONENT_PWM1,
  158. DDP_COMPONENT_PWM2,
  159. DDP_COMPONENT_RDMA0,
  160. DDP_COMPONENT_RDMA1,
  161. DDP_COMPONENT_RDMA2,
  162. DDP_COMPONENT_RDMA0_VIRTUAL0,
  163. DDP_COMPONENT_RSZ0,
  164. DDP_COMPONENT_UFOE,
  165. DDP_COMPONENT_WDMA0,
  166. DDP_COMPONENT_WDMA1,
  167. DDP_COMPONENT_POSTMASK0,
  168. DDP_COMPONENT_ID_MAX,
  169. };
  170. #endif
  171. struct mtk_ddp_comp;
  172. struct cmdq_pkt;
  173. enum mtk_ddp_comp_trigger_flag {
  174. MTK_TRIG_FLAG_TRIGGER,
  175. MTK_TRIG_FLAG_EOF,
  176. MTK_TRIG_FLAG_LAYER_REC,
  177. };
  178. enum mtk_ddp_io_cmd {
  179. REQ_PANEL_EXT,
  180. MTK_IO_CMD_RDMA_GOLDEN_SETTING,
  181. MTK_IO_CMD_OVL_GOLDEN_SETTING,
  182. DSI_START_VDO_MODE,
  183. DSI_STOP_VDO_MODE,
  184. ESD_CHECK_READ,
  185. ESD_CHECK_CMP,
  186. REQ_ESD_EINT_COMPAT,
  187. COMP_REG_START,
  188. CONNECTOR_ENABLE,
  189. CONNECTOR_DISABLE,
  190. CONNECTOR_RESET,
  191. CONNECTOR_READ_EPILOG,
  192. CONNECTOR_IS_ENABLE,
  193. CONNECTOR_PANEL_ENABLE,
  194. CONNECTOR_PANEL_DISABLE,
  195. OVL_ALL_LAYER_OFF,
  196. IRQ_LEVEL_ALL,
  197. IRQ_LEVEL_IDLE,
  198. DSI_VFP_IDLE_MODE,
  199. DSI_VFP_DEFAULT_MODE,
  200. DSI_GET_TIMING,
  201. DSI_GET_MODE_BY_MAX_VREFRESH,
  202. PMQOS_SET_BW,
  203. PMQOS_SET_HRT_BW,
  204. PMQOS_UPDATE_BW,
  205. OVL_REPLACE_BOOTUP_MVA,
  206. BACKUP_INFO_CMP,
  207. LCM_RESET,
  208. DSI_SET_BL,
  209. DSI_SET_BL_AOD,
  210. DSI_SET_BL_GRP,
  211. DSI_HBM_SET,
  212. DSI_HBM_GET_STATE,
  213. DSI_HBM_GET_WAIT_STATE,
  214. DSI_HBM_SET_WAIT_STATE,
  215. DSI_HBM_WAIT,
  216. LCM_ATA_CHECK,
  217. DSI_SET_CRTC_AVAIL_MODES,
  218. DSI_TIMING_CHANGE,
  219. GET_PANEL_NAME,
  220. DSI_CHANGE_MODE,
  221. BACKUP_OVL_STATUS,
  222. MIPI_HOPPING,
  223. PANEL_OSC_HOPPING,
  224. DYN_FPS_INDEX,
  225. SET_MMCLK_BY_DATARATE,
  226. GET_FRAME_HRT_BW_BY_DATARATE,
  227. DSI_SEND_DDIC_CMD,
  228. DSI_READ_DDIC_CMD,
  229. DSI_GET_VIRTUAL_HEIGH,
  230. DSI_GET_VIRTUAL_WIDTH,
  231. FRAME_DIRTY,
  232. DSI_LFR_SET,
  233. DSI_LFR_UPDATE,
  234. DSI_LFR_STATUS_CHECK,
  235. };
  236. struct golden_setting_context {
  237. unsigned int is_vdo_mode;
  238. unsigned int is_dc;
  239. unsigned int dst_width;
  240. unsigned int dst_height;
  241. // add for rdma default goden setting
  242. unsigned int vrefresh;
  243. };
  244. struct mtk_ddp_config {
  245. void *pa;
  246. unsigned int w;
  247. unsigned int h;
  248. unsigned int x;
  249. unsigned int y;
  250. unsigned int vrefresh;
  251. unsigned int bpc;
  252. struct golden_setting_context *p_golden_setting_context;
  253. };
  254. struct mtk_ddp_fb_info {
  255. unsigned int fb_pa;
  256. unsigned int fb_mva;
  257. unsigned int fb_size;
  258. };
  259. struct mtk_ddp_comp_funcs {
  260. void (*config)(struct mtk_ddp_comp *comp, struct mtk_ddp_config *cfg,
  261. struct cmdq_pkt *handle);
  262. void (*prepare)(struct mtk_ddp_comp *comp);
  263. void (*unprepare)(struct mtk_ddp_comp *comp);
  264. void (*start)(struct mtk_ddp_comp *comp, struct cmdq_pkt *handle);
  265. void (*stop)(struct mtk_ddp_comp *comp, struct cmdq_pkt *handle);
  266. void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc,
  267. struct cmdq_pkt *handle);
  268. void (*disable_vblank)(struct mtk_ddp_comp *comp,
  269. struct cmdq_pkt *handle);
  270. void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx,
  271. unsigned int ext_idx, struct cmdq_pkt *handle);
  272. void (*layer_off)(struct mtk_ddp_comp *comp, unsigned int idx,
  273. unsigned int ext_idx, struct cmdq_pkt *handle);
  274. void (*layer_config)(struct mtk_ddp_comp *comp, unsigned int idx,
  275. struct mtk_plane_state *state,
  276. struct cmdq_pkt *handle);
  277. void (*gamma_set)(struct mtk_ddp_comp *comp,
  278. struct drm_crtc_state *state,
  279. struct cmdq_pkt *handle);
  280. void (*first_cfg)(struct mtk_ddp_comp *comp,
  281. struct mtk_ddp_config *cfg, struct cmdq_pkt *handle);
  282. void (*bypass)(struct mtk_ddp_comp *comp, struct cmdq_pkt *handle);
  283. void (*config_trigger)(struct mtk_ddp_comp *comp,
  284. struct cmdq_pkt *handle,
  285. enum mtk_ddp_comp_trigger_flag trig_flag);
  286. void (*addon_config)(struct mtk_ddp_comp *comp,
  287. enum mtk_ddp_comp_id prev,
  288. enum mtk_ddp_comp_id next,
  289. union mtk_addon_config *addon_config,
  290. struct cmdq_pkt *handle);
  291. int (*io_cmd)(struct mtk_ddp_comp *comp, struct cmdq_pkt *handle,
  292. enum mtk_ddp_io_cmd cmd, void *params);
  293. int (*user_cmd)(struct mtk_ddp_comp *comp, struct cmdq_pkt *handle,
  294. unsigned int cmd, void *params);
  295. void (*connect)(struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id prev,
  296. enum mtk_ddp_comp_id next);
  297. int (*is_busy)(struct mtk_ddp_comp *comp);
  298. };
  299. struct mtk_ddp_comp {
  300. struct clk *clk;
  301. void __iomem *regs;
  302. resource_size_t regs_pa;
  303. int irq;
  304. struct device *larb_dev;
  305. struct device *dev;
  306. struct mtk_drm_crtc *mtk_crtc;
  307. u32 larb_id;
  308. enum mtk_ddp_comp_id id;
  309. struct drm_framebuffer *fb;
  310. const struct mtk_ddp_comp_funcs *funcs;
  311. void *comp_mode;
  312. struct cmdq_base *cmdq_base;
  313. #if 0
  314. u8 cmdq_subsys;
  315. #endif
  316. unsigned int qos_attr;
  317. struct mm_qos_request qos_req;
  318. struct mm_qos_request fbdc_qos_req;
  319. struct mm_qos_request hrt_qos_req;
  320. bool blank_mode;
  321. u32 qos_bw;
  322. u32 fbdc_bw;
  323. u32 hrt_bw;
  324. };
  325. static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp,
  326. struct mtk_ddp_config *cfg,
  327. struct cmdq_pkt *handle)
  328. {
  329. if (comp && comp->funcs && comp->funcs->config && !comp->blank_mode)
  330. comp->funcs->config(comp, cfg, handle);
  331. }
  332. static inline void mtk_ddp_comp_prepare(struct mtk_ddp_comp *comp)
  333. {
  334. if (comp && comp->funcs && comp->funcs->prepare && !comp->blank_mode)
  335. comp->funcs->prepare(comp);
  336. }
  337. static inline void mtk_ddp_comp_unprepare(struct mtk_ddp_comp *comp)
  338. {
  339. if (comp && comp->funcs && comp->funcs->unprepare && !comp->blank_mode)
  340. comp->funcs->unprepare(comp);
  341. }
  342. static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp,
  343. struct cmdq_pkt *handle)
  344. {
  345. if (comp && comp->funcs && comp->funcs->start && !comp->blank_mode)
  346. comp->funcs->start(comp, handle);
  347. }
  348. static inline void mtk_ddp_comp_stop(struct mtk_ddp_comp *comp,
  349. struct cmdq_pkt *handle)
  350. {
  351. if (comp && comp->funcs && comp->funcs->stop && !comp->blank_mode)
  352. comp->funcs->stop(comp, handle);
  353. }
  354. static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp *comp,
  355. struct drm_crtc *crtc,
  356. struct cmdq_pkt *handle)
  357. {
  358. if (comp && comp->funcs && comp->funcs->enable_vblank &&
  359. !comp->blank_mode)
  360. comp->funcs->enable_vblank(comp, crtc, handle);
  361. }
  362. static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp,
  363. struct cmdq_pkt *handle)
  364. {
  365. if (comp && comp->funcs && comp->funcs->disable_vblank &&
  366. !comp->blank_mode)
  367. comp->funcs->disable_vblank(comp, handle);
  368. }
  369. static inline void mtk_ddp_comp_layer_on(struct mtk_ddp_comp *comp,
  370. unsigned int idx, unsigned int ext_idx,
  371. struct cmdq_pkt *handle)
  372. {
  373. if (comp && comp->funcs && comp->funcs->layer_on && !comp->blank_mode)
  374. comp->funcs->layer_on(comp, idx, ext_idx, handle);
  375. }
  376. static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp *comp,
  377. unsigned int idx,
  378. unsigned int ext_idx,
  379. struct cmdq_pkt *handle)
  380. {
  381. if (comp && comp->funcs && comp->funcs->layer_off && !comp->blank_mode)
  382. comp->funcs->layer_off(comp, idx, ext_idx, handle);
  383. }
  384. static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp,
  385. unsigned int idx,
  386. struct mtk_plane_state *state,
  387. struct cmdq_pkt *handle)
  388. {
  389. if (comp && comp->funcs && comp->funcs->layer_config &&
  390. !comp->blank_mode) {
  391. DDPDBG("[DRM]func:%s, line:%d ==>\n",
  392. __func__, __LINE__);
  393. DDPDBG("comp_funcs:0x%p, layer_config:0x%p\n",
  394. comp->funcs, comp->funcs->layer_config);
  395. comp->funcs->layer_config(comp, idx, state, handle);
  396. }
  397. }
  398. static inline void mtk_ddp_gamma_set(struct mtk_ddp_comp *comp,
  399. struct drm_crtc_state *state,
  400. struct cmdq_pkt *handle)
  401. {
  402. if (comp && comp->funcs && comp->funcs->gamma_set && !comp->blank_mode)
  403. comp->funcs->gamma_set(comp, state, handle);
  404. }
  405. static inline void mtk_ddp_comp_bypass(struct mtk_ddp_comp *comp,
  406. struct cmdq_pkt *handle)
  407. {
  408. if (comp && comp->funcs && comp->funcs->bypass && !comp->blank_mode)
  409. comp->funcs->bypass(comp, handle);
  410. }
  411. static inline void mtk_ddp_comp_first_cfg(struct mtk_ddp_comp *comp,
  412. struct mtk_ddp_config *cfg,
  413. struct cmdq_pkt *handle)
  414. {
  415. if (comp && comp->funcs && comp->funcs->first_cfg && !comp->blank_mode)
  416. comp->funcs->first_cfg(comp, cfg, handle);
  417. }
  418. static inline void
  419. mtk_ddp_comp_config_trigger(struct mtk_ddp_comp *comp, struct cmdq_pkt *handle,
  420. enum mtk_ddp_comp_trigger_flag flag)
  421. {
  422. if (comp && comp->funcs && comp->funcs->config_trigger &&
  423. !comp->blank_mode)
  424. comp->funcs->config_trigger(comp, handle, flag);
  425. }
  426. static inline void
  427. mtk_ddp_comp_addon_config(struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id prev,
  428. enum mtk_ddp_comp_id next,
  429. union mtk_addon_config *addon_config,
  430. struct cmdq_pkt *handle)
  431. {
  432. if (comp && comp->funcs && comp->funcs->addon_config &&
  433. !comp->blank_mode)
  434. comp->funcs->addon_config(comp, prev, next, addon_config,
  435. handle);
  436. }
  437. static inline int mtk_ddp_comp_io_cmd(struct mtk_ddp_comp *comp,
  438. struct cmdq_pkt *handle,
  439. enum mtk_ddp_io_cmd io_cmd, void *params)
  440. {
  441. int ret = -EINVAL;
  442. if (comp && comp->funcs && comp->funcs->io_cmd && !comp->blank_mode)
  443. ret = comp->funcs->io_cmd(comp, handle, io_cmd, params);
  444. return ret;
  445. }
  446. static inline int
  447. mtk_ddp_comp_is_busy(struct mtk_ddp_comp *comp)
  448. {
  449. int ret = 0;
  450. if (comp && comp->funcs && comp->funcs->is_busy && !comp->blank_mode)
  451. ret = comp->funcs->is_busy(comp);
  452. return ret;
  453. }
  454. static inline void mtk_ddp_cpu_mask_write(struct mtk_ddp_comp *comp,
  455. unsigned int off, unsigned int val,
  456. unsigned int mask)
  457. {
  458. unsigned int v = (readl(comp->regs + off) & (~mask));
  459. v += (val & mask);
  460. writel_relaxed(v, comp->regs + off);
  461. }
  462. enum mtk_ddp_comp_id mtk_ddp_comp_get_id(struct device_node *node,
  463. enum mtk_ddp_comp_type comp_type);
  464. struct mtk_ddp_comp *mtk_ddp_comp_find_by_id(struct drm_crtc *crtc,
  465. enum mtk_ddp_comp_id comp_id);
  466. unsigned int mtk_drm_find_possible_crtc_by_comp(struct drm_device *drm,
  467. struct mtk_ddp_comp ddp_comp);
  468. int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node,
  469. struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id,
  470. const struct mtk_ddp_comp_funcs *funcs);
  471. int mtk_ddp_comp_register(struct drm_device *drm, struct mtk_ddp_comp *comp);
  472. void mtk_ddp_comp_unregister(struct drm_device *drm, struct mtk_ddp_comp *comp);
  473. int mtk_ddp_comp_get_type(enum mtk_ddp_comp_id comp_id);
  474. bool mtk_dsi_is_cmd_mode(struct mtk_ddp_comp *comp);
  475. bool mtk_ddp_comp_is_output(struct mtk_ddp_comp *comp);
  476. void mtk_ddp_comp_get_name(struct mtk_ddp_comp *comp, char *buf, int buf_len);
  477. int mtk_ovl_layer_num(struct mtk_ddp_comp *comp);
  478. void mtk_ddp_write(struct mtk_ddp_comp *comp, unsigned int value,
  479. unsigned int offset, void *handle);
  480. void mtk_ddp_write_relaxed(struct mtk_ddp_comp *comp, unsigned int value,
  481. unsigned int offset, void *handle);
  482. void mtk_ddp_write_mask(struct mtk_ddp_comp *comp, unsigned int value,
  483. unsigned int offset, unsigned int mask, void *handle);
  484. void mtk_ddp_write_mask_cpu(struct mtk_ddp_comp *comp,
  485. unsigned int value, unsigned int offset,
  486. unsigned int mask);
  487. void mtk_ddp_comp_clk_prepare(struct mtk_ddp_comp *comp);
  488. void mtk_ddp_comp_clk_unprepare(struct mtk_ddp_comp *comp);
  489. void mtk_ddp_comp_iommu_enable(struct mtk_ddp_comp *comp,
  490. struct cmdq_pkt *handle);
  491. void mt6779_mtk_sodi_config(struct drm_device *drm, enum mtk_ddp_comp_id id,
  492. struct cmdq_pkt *handle, void *data);
  493. void mt6885_mtk_sodi_config(struct drm_device *drm, enum mtk_ddp_comp_id id,
  494. struct cmdq_pkt *handle, void *data);
  495. void mt6873_mtk_sodi_config(struct drm_device *drm, enum mtk_ddp_comp_id id,
  496. struct cmdq_pkt *handle, void *data);
  497. void mt6853_mtk_sodi_config(struct drm_device *drm, enum mtk_ddp_comp_id id,
  498. struct cmdq_pkt *handle, void *data);
  499. void mt6833_mtk_sodi_config(struct drm_device *drm, enum mtk_ddp_comp_id id,
  500. struct cmdq_pkt *handle, void *data);
  501. int mtk_ddp_comp_helper_get_opt(struct mtk_ddp_comp *comp,
  502. enum MTK_DRM_HELPER_OPT option);
  503. #endif /* MTK_DRM_DDP_COMP_H */