mtk_drm_ddp_comp.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*
  2. * Copyright (c) 2015 MediaTek Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. */
  13. #ifndef MTK_DRM_DDP_COMP_H
  14. #define MTK_DRM_DDP_COMP_H
  15. #include <linux/io.h>
  16. struct device;
  17. struct device_node;
  18. struct drm_crtc;
  19. struct drm_device;
  20. struct mtk_plane_state;
  21. enum mtk_ddp_comp_type {
  22. MTK_DISP_OVL,
  23. MTK_DISP_RDMA,
  24. MTK_DISP_WDMA,
  25. MTK_DISP_COLOR,
  26. MTK_DISP_AAL,
  27. MTK_DISP_GAMMA,
  28. MTK_DISP_UFOE,
  29. MTK_DSI,
  30. MTK_DPI,
  31. MTK_DISP_PWM,
  32. MTK_DISP_MUTEX,
  33. MTK_DISP_OD,
  34. MTK_DDP_COMP_TYPE_MAX,
  35. };
  36. enum mtk_ddp_comp_id {
  37. DDP_COMPONENT_AAL,
  38. DDP_COMPONENT_COLOR0,
  39. DDP_COMPONENT_COLOR1,
  40. DDP_COMPONENT_DPI0,
  41. DDP_COMPONENT_DSI0,
  42. DDP_COMPONENT_DSI1,
  43. DDP_COMPONENT_GAMMA,
  44. DDP_COMPONENT_OD,
  45. DDP_COMPONENT_OVL0,
  46. DDP_COMPONENT_OVL1,
  47. DDP_COMPONENT_PWM0,
  48. DDP_COMPONENT_PWM1,
  49. DDP_COMPONENT_RDMA0,
  50. DDP_COMPONENT_RDMA1,
  51. DDP_COMPONENT_RDMA2,
  52. DDP_COMPONENT_UFOE,
  53. DDP_COMPONENT_WDMA0,
  54. DDP_COMPONENT_WDMA1,
  55. DDP_COMPONENT_ID_MAX,
  56. };
  57. struct mtk_ddp_comp;
  58. struct mtk_ddp_comp_funcs {
  59. void (*config)(struct mtk_ddp_comp *comp, unsigned int w,
  60. unsigned int h, unsigned int vrefresh);
  61. void (*start)(struct mtk_ddp_comp *comp);
  62. void (*stop)(struct mtk_ddp_comp *comp);
  63. void (*enable_vblank)(struct mtk_ddp_comp *comp, struct drm_crtc *crtc);
  64. void (*disable_vblank)(struct mtk_ddp_comp *comp);
  65. void (*layer_on)(struct mtk_ddp_comp *comp, unsigned int idx);
  66. void (*layer_off)(struct mtk_ddp_comp *comp, unsigned int idx);
  67. void (*layer_config)(struct mtk_ddp_comp *comp, unsigned int idx,
  68. struct mtk_plane_state *state);
  69. };
  70. struct mtk_ddp_comp {
  71. struct clk *clk;
  72. void __iomem *regs;
  73. int irq;
  74. struct device *larb_dev;
  75. enum mtk_ddp_comp_id id;
  76. const struct mtk_ddp_comp_funcs *funcs;
  77. };
  78. static inline void mtk_ddp_comp_config(struct mtk_ddp_comp *comp,
  79. unsigned int w, unsigned int h,
  80. unsigned int vrefresh)
  81. {
  82. if (comp->funcs && comp->funcs->config)
  83. comp->funcs->config(comp, w, h, vrefresh);
  84. }
  85. static inline void mtk_ddp_comp_start(struct mtk_ddp_comp *comp)
  86. {
  87. if (comp->funcs && comp->funcs->start)
  88. comp->funcs->start(comp);
  89. }
  90. static inline void mtk_ddp_comp_stop(struct mtk_ddp_comp *comp)
  91. {
  92. if (comp->funcs && comp->funcs->stop)
  93. comp->funcs->stop(comp);
  94. }
  95. static inline void mtk_ddp_comp_enable_vblank(struct mtk_ddp_comp *comp,
  96. struct drm_crtc *crtc)
  97. {
  98. if (comp->funcs && comp->funcs->enable_vblank)
  99. comp->funcs->enable_vblank(comp, crtc);
  100. }
  101. static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp)
  102. {
  103. if (comp->funcs && comp->funcs->disable_vblank)
  104. comp->funcs->disable_vblank(comp);
  105. }
  106. static inline void mtk_ddp_comp_layer_on(struct mtk_ddp_comp *comp,
  107. unsigned int idx)
  108. {
  109. if (comp->funcs && comp->funcs->layer_on)
  110. comp->funcs->layer_on(comp, idx);
  111. }
  112. static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp *comp,
  113. unsigned int idx)
  114. {
  115. if (comp->funcs && comp->funcs->layer_off)
  116. comp->funcs->layer_off(comp, idx);
  117. }
  118. static inline void mtk_ddp_comp_layer_config(struct mtk_ddp_comp *comp,
  119. unsigned int idx,
  120. struct mtk_plane_state *state)
  121. {
  122. if (comp->funcs && comp->funcs->layer_config)
  123. comp->funcs->layer_config(comp, idx, state);
  124. }
  125. int mtk_ddp_comp_get_id(struct device_node *node,
  126. enum mtk_ddp_comp_type comp_type);
  127. int mtk_ddp_comp_init(struct device *dev, struct device_node *comp_node,
  128. struct mtk_ddp_comp *comp, enum mtk_ddp_comp_id comp_id,
  129. const struct mtk_ddp_comp_funcs *funcs);
  130. int mtk_ddp_comp_register(struct drm_device *drm, struct mtk_ddp_comp *comp);
  131. void mtk_ddp_comp_unregister(struct drm_device *drm, struct mtk_ddp_comp *comp);
  132. #endif /* MTK_DRM_DDP_COMP_H */