mdp5_kms.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * Copyright (C) 2013 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __MDP5_KMS_H__
  18. #define __MDP5_KMS_H__
  19. #include "msm_drv.h"
  20. #include "msm_kms.h"
  21. #include "mdp/mdp_kms.h"
  22. #include "mdp5.xml.h"
  23. #include "mdp5_smp.h"
  24. struct mdp5_kms {
  25. struct mdp_kms base;
  26. struct drm_device *dev;
  27. int rev;
  28. /* mapper-id used to request GEM buffer mapped for scanout: */
  29. int id;
  30. struct msm_mmu *mmu;
  31. /* for tracking smp allocation amongst pipes: */
  32. mdp5_smp_state_t smp_state;
  33. struct mdp5_client_smp_state smp_client_state[CID_MAX];
  34. int smp_blk_cnt;
  35. /* io/register spaces: */
  36. void __iomem *mmio, *vbif;
  37. struct regulator *vdd;
  38. struct clk *axi_clk;
  39. struct clk *ahb_clk;
  40. struct clk *src_clk;
  41. struct clk *core_clk;
  42. struct clk *lut_clk;
  43. struct clk *vsync_clk;
  44. struct hdmi *hdmi;
  45. struct mdp_irq error_handler;
  46. };
  47. #define to_mdp5_kms(x) container_of(x, struct mdp5_kms, base)
  48. /* platform config data (ie. from DT, or pdata) */
  49. struct mdp5_platform_config {
  50. struct iommu_domain *iommu;
  51. uint32_t max_clk;
  52. int smp_blk_cnt;
  53. };
  54. static inline void mdp5_write(struct mdp5_kms *mdp5_kms, u32 reg, u32 data)
  55. {
  56. msm_writel(data, mdp5_kms->mmio + reg);
  57. }
  58. static inline u32 mdp5_read(struct mdp5_kms *mdp5_kms, u32 reg)
  59. {
  60. return msm_readl(mdp5_kms->mmio + reg);
  61. }
  62. static inline const char *pipe2name(enum mdp5_pipe pipe)
  63. {
  64. static const char *names[] = {
  65. #define NAME(n) [SSPP_ ## n] = #n
  66. NAME(VIG0), NAME(VIG1), NAME(VIG2),
  67. NAME(RGB0), NAME(RGB1), NAME(RGB2),
  68. NAME(DMA0), NAME(DMA1),
  69. #undef NAME
  70. };
  71. return names[pipe];
  72. }
  73. static inline uint32_t pipe2flush(enum mdp5_pipe pipe)
  74. {
  75. switch (pipe) {
  76. case SSPP_VIG0: return MDP5_CTL_FLUSH_VIG0;
  77. case SSPP_VIG1: return MDP5_CTL_FLUSH_VIG1;
  78. case SSPP_VIG2: return MDP5_CTL_FLUSH_VIG2;
  79. case SSPP_RGB0: return MDP5_CTL_FLUSH_RGB0;
  80. case SSPP_RGB1: return MDP5_CTL_FLUSH_RGB1;
  81. case SSPP_RGB2: return MDP5_CTL_FLUSH_RGB2;
  82. case SSPP_DMA0: return MDP5_CTL_FLUSH_DMA0;
  83. case SSPP_DMA1: return MDP5_CTL_FLUSH_DMA1;
  84. default: return 0;
  85. }
  86. }
  87. static inline int pipe2nclients(enum mdp5_pipe pipe)
  88. {
  89. switch (pipe) {
  90. case SSPP_RGB0:
  91. case SSPP_RGB1:
  92. case SSPP_RGB2:
  93. return 1;
  94. default:
  95. return 3;
  96. }
  97. }
  98. static inline enum mdp5_client_id pipe2client(enum mdp5_pipe pipe, int plane)
  99. {
  100. WARN_ON(plane >= pipe2nclients(pipe));
  101. switch (pipe) {
  102. case SSPP_VIG0: return CID_VIG0_Y + plane;
  103. case SSPP_VIG1: return CID_VIG1_Y + plane;
  104. case SSPP_VIG2: return CID_VIG2_Y + plane;
  105. case SSPP_RGB0: return CID_RGB0;
  106. case SSPP_RGB1: return CID_RGB1;
  107. case SSPP_RGB2: return CID_RGB2;
  108. case SSPP_DMA0: return CID_DMA0_Y + plane;
  109. case SSPP_DMA1: return CID_DMA1_Y + plane;
  110. default: return CID_UNUSED;
  111. }
  112. }
  113. static inline uint32_t mixer2flush(int lm)
  114. {
  115. switch (lm) {
  116. case 0: return MDP5_CTL_FLUSH_LM0;
  117. case 1: return MDP5_CTL_FLUSH_LM1;
  118. case 2: return MDP5_CTL_FLUSH_LM2;
  119. default: return 0;
  120. }
  121. }
  122. static inline uint32_t intf2err(int intf)
  123. {
  124. switch (intf) {
  125. case 0: return MDP5_IRQ_INTF0_UNDER_RUN;
  126. case 1: return MDP5_IRQ_INTF1_UNDER_RUN;
  127. case 2: return MDP5_IRQ_INTF2_UNDER_RUN;
  128. case 3: return MDP5_IRQ_INTF3_UNDER_RUN;
  129. default: return 0;
  130. }
  131. }
  132. static inline uint32_t intf2vblank(int intf)
  133. {
  134. switch (intf) {
  135. case 0: return MDP5_IRQ_INTF0_VSYNC;
  136. case 1: return MDP5_IRQ_INTF1_VSYNC;
  137. case 2: return MDP5_IRQ_INTF2_VSYNC;
  138. case 3: return MDP5_IRQ_INTF3_VSYNC;
  139. default: return 0;
  140. }
  141. }
  142. int mdp5_disable(struct mdp5_kms *mdp5_kms);
  143. int mdp5_enable(struct mdp5_kms *mdp5_kms);
  144. void mdp5_set_irqmask(struct mdp_kms *mdp_kms, uint32_t irqmask);
  145. void mdp5_irq_preinstall(struct msm_kms *kms);
  146. int mdp5_irq_postinstall(struct msm_kms *kms);
  147. void mdp5_irq_uninstall(struct msm_kms *kms);
  148. irqreturn_t mdp5_irq(struct msm_kms *kms);
  149. int mdp5_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
  150. void mdp5_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
  151. static inline
  152. uint32_t mdp5_get_formats(enum mdp5_pipe pipe, uint32_t *pixel_formats,
  153. uint32_t max_formats)
  154. {
  155. /* TODO when we have YUV, we need to filter supported formats
  156. * based on pipe id..
  157. */
  158. return mdp_get_formats(pixel_formats, max_formats);
  159. }
  160. void mdp5_plane_install_properties(struct drm_plane *plane,
  161. struct drm_mode_object *obj);
  162. void mdp5_plane_set_scanout(struct drm_plane *plane,
  163. struct drm_framebuffer *fb);
  164. int mdp5_plane_mode_set(struct drm_plane *plane,
  165. struct drm_crtc *crtc, struct drm_framebuffer *fb,
  166. int crtc_x, int crtc_y,
  167. unsigned int crtc_w, unsigned int crtc_h,
  168. uint32_t src_x, uint32_t src_y,
  169. uint32_t src_w, uint32_t src_h);
  170. void mdp5_plane_complete_flip(struct drm_plane *plane);
  171. enum mdp5_pipe mdp5_plane_pipe(struct drm_plane *plane);
  172. struct drm_plane *mdp5_plane_init(struct drm_device *dev,
  173. enum mdp5_pipe pipe, bool private_plane);
  174. uint32_t mdp5_crtc_vblank(struct drm_crtc *crtc);
  175. void mdp5_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
  176. void mdp5_crtc_set_intf(struct drm_crtc *crtc, int intf,
  177. enum mdp5_intf intf_id);
  178. void mdp5_crtc_attach(struct drm_crtc *crtc, struct drm_plane *plane);
  179. void mdp5_crtc_detach(struct drm_crtc *crtc, struct drm_plane *plane);
  180. struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
  181. struct drm_plane *plane, int id);
  182. struct drm_encoder *mdp5_encoder_init(struct drm_device *dev, int intf,
  183. enum mdp5_intf intf_id);
  184. #endif /* __MDP5_KMS_H__ */