sde_hw_pingpong.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _SDE_HW_PINGPONG_H
  6. #define _SDE_HW_PINGPONG_H
  7. #include "sde_hw_catalog.h"
  8. #include "sde_hw_mdss.h"
  9. #include "sde_hw_util.h"
  10. #include "sde_hw_blk.h"
  11. #include <drm/msm_drm_pp.h>
  12. struct sde_hw_pingpong;
  13. struct sde_hw_merge_3d;
  14. struct sde_hw_dsc_cfg {
  15. u8 enable;
  16. };
  17. /**
  18. *
  19. * struct sde_hw_pingpong_ops : Interface to the pingpong Hw driver functions
  20. * Assumption is these functions will be called after clocks are enabled
  21. * @setup_tearcheck : program tear check values
  22. * @enable_tearcheck : enables tear check
  23. * @get_vsync_info : retries timing info of the panel
  24. * @setup_autorefresh : program auto refresh
  25. * @setup_dsc : program DSC block with encoding details
  26. * @enable_dsc : enables DSC encoder
  27. * @disable_dsc : disables DSC encoder
  28. * @setup_dither : function to program the dither hw block
  29. * @get_line_count: obtain current vertical line counter
  30. * @get_hw_caps: returns features supported by this pp block
  31. */
  32. struct sde_hw_pingpong_ops {
  33. /**
  34. * enables vysnc generation and sets up init value of
  35. * read pointer and programs the tear check cofiguration
  36. */
  37. int (*setup_tearcheck)(struct sde_hw_pingpong *pp,
  38. struct sde_hw_tear_check *cfg);
  39. /**
  40. * enables tear check block
  41. */
  42. int (*enable_tearcheck)(struct sde_hw_pingpong *pp,
  43. bool enable);
  44. /**
  45. * updates tearcheck configuration
  46. */
  47. void (*update_tearcheck)(struct sde_hw_pingpong *pp,
  48. struct sde_hw_tear_check *cfg);
  49. /**
  50. * read, modify, write to either set or clear listening to external TE
  51. * @Return: 1 if TE was originally connected, 0 if not, or -ERROR
  52. */
  53. int (*connect_external_te)(struct sde_hw_pingpong *pp,
  54. bool enable_external_te);
  55. /**
  56. * provides the programmed and current
  57. * line_count
  58. */
  59. int (*get_vsync_info)(struct sde_hw_pingpong *pp,
  60. struct sde_hw_pp_vsync_info *info);
  61. /**
  62. * configure and enable the autorefresh config
  63. */
  64. int (*setup_autorefresh)(struct sde_hw_pingpong *pp,
  65. struct sde_hw_autorefresh *cfg);
  66. /**
  67. * retrieve autorefresh config from hardware
  68. */
  69. int (*get_autorefresh)(struct sde_hw_pingpong *pp,
  70. struct sde_hw_autorefresh *cfg);
  71. /**
  72. * poll until write pointer transmission starts
  73. * @Return: 0 on success, -ETIMEDOUT on timeout
  74. */
  75. int (*poll_timeout_wr_ptr)(struct sde_hw_pingpong *pp, u32 timeout_us);
  76. /**
  77. * Program the dsc compression block
  78. */
  79. int (*setup_dsc)(struct sde_hw_pingpong *pp);
  80. /**
  81. * Enables DSC encoder
  82. */
  83. void (*enable_dsc)(struct sde_hw_pingpong *pp);
  84. /**
  85. * Disables DSC encoder
  86. */
  87. void (*disable_dsc)(struct sde_hw_pingpong *pp);
  88. /**
  89. * Get DSC status
  90. * @Return: register value of DSC config
  91. */
  92. u32 (*get_dsc_status)(struct sde_hw_pingpong *pp);
  93. /**
  94. * Program the dither hw block
  95. */
  96. int (*setup_dither)(struct sde_hw_pingpong *pp, void *cfg, size_t len);
  97. /**
  98. * Obtain current vertical line counter
  99. */
  100. u32 (*get_line_count)(struct sde_hw_pingpong *pp);
  101. /**
  102. * Programs the 3d blend configuration
  103. */
  104. void (*setup_3d_mode)(struct sde_hw_pingpong *pp,
  105. enum sde_3d_blend_mode cfg);
  106. /**
  107. * reset 3d blend configuration
  108. */
  109. void (*reset_3d_mode)(struct sde_hw_pingpong *pp);
  110. /**
  111. * get PP features supported by this instance
  112. */
  113. unsigned long (*get_hw_caps)(struct sde_hw_pingpong *pp);
  114. };
  115. struct sde_hw_merge_3d_ops {
  116. /**
  117. * setup the 3d blend mode configuration
  118. */
  119. void (*setup_blend_mode)(struct sde_hw_merge_3d *id,
  120. enum sde_3d_blend_mode cfg);
  121. /**
  122. * reset 3d blend mode configuration
  123. */
  124. void (*reset_blend_mode)(struct sde_hw_merge_3d *id);
  125. };
  126. struct sde_hw_merge_3d {
  127. struct sde_hw_blk base;
  128. struct sde_hw_blk_reg_map hw;
  129. /* merge_3d */
  130. enum sde_merge_3d idx;
  131. const struct sde_merge_3d_cfg *caps;
  132. /* ops */
  133. struct sde_hw_merge_3d_ops ops;
  134. };
  135. struct sde_hw_pingpong {
  136. struct sde_hw_blk base;
  137. struct sde_hw_blk_reg_map hw;
  138. /* pingpong */
  139. enum sde_pingpong idx;
  140. const struct sde_pingpong_cfg *caps;
  141. /* associated 3d_merge */
  142. struct sde_hw_merge_3d *merge_3d;
  143. /* ops */
  144. struct sde_hw_pingpong_ops ops;
  145. };
  146. /**
  147. * sde_hw_pingpong - convert base object sde_hw_base to container
  148. * @hw: Pointer to base hardware block
  149. * return: Pointer to hardware block container
  150. */
  151. static inline struct sde_hw_pingpong *to_sde_hw_pingpong(struct sde_hw_blk *hw)
  152. {
  153. return container_of(hw, struct sde_hw_pingpong, base);
  154. }
  155. /**
  156. * sde_hw_pingpong_init - initializes the pingpong driver for the passed
  157. * pingpong idx.
  158. * @idx: Pingpong index for which driver object is required
  159. * @addr: Mapped register io address of MDP
  160. * @m: Pointer to mdss catalog data
  161. * Returns: Error code or allocated sde_hw_pingpong context
  162. */
  163. struct sde_hw_pingpong *sde_hw_pingpong_init(enum sde_pingpong idx,
  164. void __iomem *addr,
  165. struct sde_mdss_cfg *m);
  166. /**
  167. * sde_hw_pingpong_destroy - destroys pingpong driver context
  168. * should be called to free the context
  169. * @pp: Pointer to PP driver context returned by sde_hw_pingpong_init
  170. */
  171. void sde_hw_pingpong_destroy(struct sde_hw_pingpong *pp);
  172. #endif /*_SDE_HW_PINGPONG_H */