mdp5_kms.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. /* dynamic offsets used by mdp5.xml.h (initialized in mdp5_kms.c) */
  23. #define MDP5_MAX_BASES 8
  24. struct mdp5_sub_block {
  25. int count;
  26. uint32_t base[MDP5_MAX_BASES];
  27. };
  28. struct mdp5_config {
  29. char *name;
  30. struct mdp5_sub_block ctl;
  31. struct mdp5_sub_block pipe_vig;
  32. struct mdp5_sub_block pipe_rgb;
  33. struct mdp5_sub_block pipe_dma;
  34. struct mdp5_sub_block lm;
  35. struct mdp5_sub_block dspp;
  36. struct mdp5_sub_block ad;
  37. struct mdp5_sub_block intf;
  38. };
  39. extern const struct mdp5_config *mdp5_cfg;
  40. #include "mdp5.xml.h"
  41. #include "mdp5_smp.h"
  42. struct mdp5_kms {
  43. struct mdp_kms base;
  44. struct drm_device *dev;
  45. int rev;
  46. const struct mdp5_config *hw_cfg;
  47. /* mapper-id used to request GEM buffer mapped for scanout: */
  48. int id;
  49. struct msm_mmu *mmu;
  50. /* for tracking smp allocation amongst pipes: */
  51. mdp5_smp_state_t smp_state;
  52. struct mdp5_client_smp_state smp_client_state[CID_MAX];
  53. int smp_blk_cnt;
  54. /* io/register spaces: */
  55. void __iomem *mmio, *vbif;
  56. struct regulator *vdd;
  57. struct clk *axi_clk;
  58. struct clk *ahb_clk;
  59. struct clk *src_clk;
  60. struct clk *core_clk;
  61. struct clk *lut_clk;
  62. struct clk *vsync_clk;
  63. struct hdmi *hdmi;
  64. struct mdp_irq error_handler;
  65. };
  66. #define to_mdp5_kms(x) container_of(x, struct mdp5_kms, base)
  67. /* platform config data (ie. from DT, or pdata) */
  68. struct mdp5_platform_config {
  69. struct iommu_domain *iommu;
  70. uint32_t max_clk;
  71. int smp_blk_cnt;
  72. };
  73. static inline void mdp5_write(struct mdp5_kms *mdp5_kms, u32 reg, u32 data)
  74. {
  75. msm_writel(data, mdp5_kms->mmio + reg);
  76. }
  77. static inline u32 mdp5_read(struct mdp5_kms *mdp5_kms, u32 reg)
  78. {
  79. return msm_readl(mdp5_kms->mmio + reg);
  80. }
  81. static inline const char *pipe2name(enum mdp5_pipe pipe)
  82. {
  83. static const char *names[] = {
  84. #define NAME(n) [SSPP_ ## n] = #n
  85. NAME(VIG0), NAME(VIG1), NAME(VIG2),
  86. NAME(RGB0), NAME(RGB1), NAME(RGB2),
  87. NAME(DMA0), NAME(DMA1),
  88. NAME(VIG3), NAME(RGB3),
  89. #undef NAME
  90. };
  91. return names[pipe];
  92. }
  93. static inline uint32_t pipe2flush(enum mdp5_pipe pipe)
  94. {
  95. switch (pipe) {
  96. case SSPP_VIG0: return MDP5_CTL_FLUSH_VIG0;
  97. case SSPP_VIG1: return MDP5_CTL_FLUSH_VIG1;
  98. case SSPP_VIG2: return MDP5_CTL_FLUSH_VIG2;
  99. case SSPP_RGB0: return MDP5_CTL_FLUSH_RGB0;
  100. case SSPP_RGB1: return MDP5_CTL_FLUSH_RGB1;
  101. case SSPP_RGB2: return MDP5_CTL_FLUSH_RGB2;
  102. case SSPP_DMA0: return MDP5_CTL_FLUSH_DMA0;
  103. case SSPP_DMA1: return MDP5_CTL_FLUSH_DMA1;
  104. case SSPP_VIG3: return MDP5_CTL_FLUSH_VIG3;
  105. case SSPP_RGB3: return MDP5_CTL_FLUSH_RGB3;
  106. default: return 0;
  107. }
  108. }
  109. static inline int pipe2nclients(enum mdp5_pipe pipe)
  110. {
  111. switch (pipe) {
  112. case SSPP_RGB0:
  113. case SSPP_RGB1:
  114. case SSPP_RGB2:
  115. case SSPP_RGB3:
  116. return 1;
  117. default:
  118. return 3;
  119. }
  120. }
  121. static inline enum mdp5_client_id pipe2client(enum mdp5_pipe pipe, int plane)
  122. {
  123. WARN_ON(plane >= pipe2nclients(pipe));
  124. switch (pipe) {
  125. case SSPP_VIG0: return CID_VIG0_Y + plane;
  126. case SSPP_VIG1: return CID_VIG1_Y + plane;
  127. case SSPP_VIG2: return CID_VIG2_Y + plane;
  128. case SSPP_RGB0: return CID_RGB0;
  129. case SSPP_RGB1: return CID_RGB1;
  130. case SSPP_RGB2: return CID_RGB2;
  131. case SSPP_DMA0: return CID_DMA0_Y + plane;
  132. case SSPP_DMA1: return CID_DMA1_Y + plane;
  133. case SSPP_VIG3: return CID_VIG3_Y + plane;
  134. case SSPP_RGB3: return CID_RGB3;
  135. default: return CID_UNUSED;
  136. }
  137. }
  138. static inline uint32_t mixer2flush(int lm)
  139. {
  140. switch (lm) {
  141. case 0: return MDP5_CTL_FLUSH_LM0;
  142. case 1: return MDP5_CTL_FLUSH_LM1;
  143. case 2: return MDP5_CTL_FLUSH_LM2;
  144. default: return 0;
  145. }
  146. }
  147. static inline uint32_t intf2err(int intf)
  148. {
  149. switch (intf) {
  150. case 0: return MDP5_IRQ_INTF0_UNDER_RUN;
  151. case 1: return MDP5_IRQ_INTF1_UNDER_RUN;
  152. case 2: return MDP5_IRQ_INTF2_UNDER_RUN;
  153. case 3: return MDP5_IRQ_INTF3_UNDER_RUN;
  154. default: return 0;
  155. }
  156. }
  157. static inline uint32_t intf2vblank(int intf)
  158. {
  159. switch (intf) {
  160. case 0: return MDP5_IRQ_INTF0_VSYNC;
  161. case 1: return MDP5_IRQ_INTF1_VSYNC;
  162. case 2: return MDP5_IRQ_INTF2_VSYNC;
  163. case 3: return MDP5_IRQ_INTF3_VSYNC;
  164. default: return 0;
  165. }
  166. }
  167. int mdp5_disable(struct mdp5_kms *mdp5_kms);
  168. int mdp5_enable(struct mdp5_kms *mdp5_kms);
  169. void mdp5_set_irqmask(struct mdp_kms *mdp_kms, uint32_t irqmask);
  170. void mdp5_irq_preinstall(struct msm_kms *kms);
  171. int mdp5_irq_postinstall(struct msm_kms *kms);
  172. void mdp5_irq_uninstall(struct msm_kms *kms);
  173. irqreturn_t mdp5_irq(struct msm_kms *kms);
  174. int mdp5_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
  175. void mdp5_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
  176. static inline
  177. uint32_t mdp5_get_formats(enum mdp5_pipe pipe, uint32_t *pixel_formats,
  178. uint32_t max_formats)
  179. {
  180. /* TODO when we have YUV, we need to filter supported formats
  181. * based on pipe id..
  182. */
  183. return mdp_get_formats(pixel_formats, max_formats);
  184. }
  185. void mdp5_plane_install_properties(struct drm_plane *plane,
  186. struct drm_mode_object *obj);
  187. void mdp5_plane_set_scanout(struct drm_plane *plane,
  188. struct drm_framebuffer *fb);
  189. int mdp5_plane_mode_set(struct drm_plane *plane,
  190. struct drm_crtc *crtc, struct drm_framebuffer *fb,
  191. int crtc_x, int crtc_y,
  192. unsigned int crtc_w, unsigned int crtc_h,
  193. uint32_t src_x, uint32_t src_y,
  194. uint32_t src_w, uint32_t src_h);
  195. void mdp5_plane_complete_flip(struct drm_plane *plane);
  196. enum mdp5_pipe mdp5_plane_pipe(struct drm_plane *plane);
  197. struct drm_plane *mdp5_plane_init(struct drm_device *dev,
  198. enum mdp5_pipe pipe, bool private_plane);
  199. uint32_t mdp5_crtc_vblank(struct drm_crtc *crtc);
  200. void mdp5_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
  201. void mdp5_crtc_set_intf(struct drm_crtc *crtc, int intf,
  202. enum mdp5_intf intf_id);
  203. void mdp5_crtc_attach(struct drm_crtc *crtc, struct drm_plane *plane);
  204. void mdp5_crtc_detach(struct drm_crtc *crtc, struct drm_plane *plane);
  205. struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
  206. struct drm_plane *plane, int id);
  207. struct drm_encoder *mdp5_encoder_init(struct drm_device *dev, int intf,
  208. enum mdp5_intf intf_id);
  209. #endif /* __MDP5_KMS_H__ */