mdp5_kms.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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_cfg.h" /* must be included before mdp5.xml.h */
  23. #include "mdp5.xml.h"
  24. #include "mdp5_ctl.h"
  25. #include "mdp5_smp.h"
  26. struct mdp5_kms {
  27. struct mdp_kms base;
  28. struct drm_device *dev;
  29. struct mdp5_cfg_handler *cfg;
  30. /* mapper-id used to request GEM buffer mapped for scanout: */
  31. int id;
  32. struct msm_mmu *mmu;
  33. struct mdp5_smp *smp;
  34. struct mdp5_ctl_manager *ctlm;
  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. /*
  45. * lock to protect access to global resources: ie., following register:
  46. * - REG_MDP5_DISP_INTF_SEL
  47. */
  48. spinlock_t resource_lock;
  49. struct mdp_irq error_handler;
  50. struct {
  51. volatile unsigned long enabled_mask;
  52. struct irq_domain *domain;
  53. } irqcontroller;
  54. };
  55. #define to_mdp5_kms(x) container_of(x, struct mdp5_kms, base)
  56. struct mdp5_plane_state {
  57. struct drm_plane_state base;
  58. /* "virtual" zpos.. we calculate actual mixer-stage at runtime
  59. * by sorting the attached planes by zpos and then assigning
  60. * mixer stage lowest to highest. Private planes get default
  61. * zpos of zero, and public planes a unique value that is
  62. * greater than zero. This way, things work out if a naive
  63. * userspace assigns planes to a crtc without setting zpos.
  64. */
  65. int zpos;
  66. /* the actual mixer stage, calculated in crtc->atomic_check()
  67. * NOTE: this should move to mdp5_crtc_state, when that exists
  68. */
  69. enum mdp_mixer_stage_id stage;
  70. /* some additional transactional status to help us know in the
  71. * apply path whether we need to update SMP allocation, and
  72. * whether current update is still pending:
  73. */
  74. bool mode_changed : 1;
  75. bool pending : 1;
  76. };
  77. #define to_mdp5_plane_state(x) \
  78. container_of(x, struct mdp5_plane_state, base)
  79. static inline void mdp5_write(struct mdp5_kms *mdp5_kms, u32 reg, u32 data)
  80. {
  81. msm_writel(data, mdp5_kms->mmio + reg);
  82. }
  83. static inline u32 mdp5_read(struct mdp5_kms *mdp5_kms, u32 reg)
  84. {
  85. return msm_readl(mdp5_kms->mmio + reg);
  86. }
  87. static inline const char *pipe2name(enum mdp5_pipe pipe)
  88. {
  89. static const char *names[] = {
  90. #define NAME(n) [SSPP_ ## n] = #n
  91. NAME(VIG0), NAME(VIG1), NAME(VIG2),
  92. NAME(RGB0), NAME(RGB1), NAME(RGB2),
  93. NAME(DMA0), NAME(DMA1),
  94. NAME(VIG3), NAME(RGB3),
  95. #undef NAME
  96. };
  97. return names[pipe];
  98. }
  99. static inline int pipe2nclients(enum mdp5_pipe pipe)
  100. {
  101. switch (pipe) {
  102. case SSPP_RGB0:
  103. case SSPP_RGB1:
  104. case SSPP_RGB2:
  105. case SSPP_RGB3:
  106. return 1;
  107. default:
  108. return 3;
  109. }
  110. }
  111. static inline uint32_t intf2err(int intf)
  112. {
  113. switch (intf) {
  114. case 0: return MDP5_IRQ_INTF0_UNDER_RUN;
  115. case 1: return MDP5_IRQ_INTF1_UNDER_RUN;
  116. case 2: return MDP5_IRQ_INTF2_UNDER_RUN;
  117. case 3: return MDP5_IRQ_INTF3_UNDER_RUN;
  118. default: return 0;
  119. }
  120. }
  121. static inline uint32_t intf2vblank(int intf)
  122. {
  123. switch (intf) {
  124. case 0: return MDP5_IRQ_INTF0_VSYNC;
  125. case 1: return MDP5_IRQ_INTF1_VSYNC;
  126. case 2: return MDP5_IRQ_INTF2_VSYNC;
  127. case 3: return MDP5_IRQ_INTF3_VSYNC;
  128. default: return 0;
  129. }
  130. }
  131. int mdp5_disable(struct mdp5_kms *mdp5_kms);
  132. int mdp5_enable(struct mdp5_kms *mdp5_kms);
  133. void mdp5_set_irqmask(struct mdp_kms *mdp_kms, uint32_t irqmask);
  134. void mdp5_irq_preinstall(struct msm_kms *kms);
  135. int mdp5_irq_postinstall(struct msm_kms *kms);
  136. void mdp5_irq_uninstall(struct msm_kms *kms);
  137. irqreturn_t mdp5_irq(struct msm_kms *kms);
  138. int mdp5_enable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
  139. void mdp5_disable_vblank(struct msm_kms *kms, struct drm_crtc *crtc);
  140. int mdp5_irq_domain_init(struct mdp5_kms *mdp5_kms);
  141. void mdp5_irq_domain_fini(struct mdp5_kms *mdp5_kms);
  142. static inline
  143. uint32_t mdp5_get_formats(enum mdp5_pipe pipe, uint32_t *pixel_formats,
  144. uint32_t max_formats)
  145. {
  146. /* TODO when we have YUV, we need to filter supported formats
  147. * based on pipe id..
  148. */
  149. return mdp_get_formats(pixel_formats, max_formats);
  150. }
  151. void mdp5_plane_install_properties(struct drm_plane *plane,
  152. struct drm_mode_object *obj);
  153. uint32_t mdp5_plane_get_flush(struct drm_plane *plane);
  154. void mdp5_plane_complete_flip(struct drm_plane *plane);
  155. enum mdp5_pipe mdp5_plane_pipe(struct drm_plane *plane);
  156. struct drm_plane *mdp5_plane_init(struct drm_device *dev,
  157. enum mdp5_pipe pipe, bool private_plane, uint32_t reg_offset);
  158. uint32_t mdp5_crtc_vblank(struct drm_crtc *crtc);
  159. int mdp5_crtc_get_lm(struct drm_crtc *crtc);
  160. void mdp5_crtc_cancel_pending_flip(struct drm_crtc *crtc, struct drm_file *file);
  161. void mdp5_crtc_set_intf(struct drm_crtc *crtc, int intf,
  162. enum mdp5_intf intf_id);
  163. struct drm_crtc *mdp5_crtc_init(struct drm_device *dev,
  164. struct drm_plane *plane, int id);
  165. struct drm_encoder *mdp5_encoder_init(struct drm_device *dev, int intf,
  166. enum mdp5_intf intf_id);
  167. #endif /* __MDP5_KMS_H__ */