sde_hw_pingpong.h 5.2 KB

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