sde_hw_pingpong.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022 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. struct sde_hw_merge_3d_ops {
  115. /**
  116. * setup the 3d blend mode configuration
  117. */
  118. void (*setup_blend_mode)(struct sde_hw_merge_3d *id,
  119. enum sde_3d_blend_mode cfg);
  120. /**
  121. * reset 3d blend mode configuration
  122. */
  123. void (*reset_blend_mode)(struct sde_hw_merge_3d *id);
  124. };
  125. struct sde_hw_merge_3d {
  126. struct sde_hw_blk_reg_map hw;
  127. /* merge_3d */
  128. enum sde_merge_3d idx;
  129. const struct sde_merge_3d_cfg *caps;
  130. /* ops */
  131. struct sde_hw_merge_3d_ops ops;
  132. };
  133. struct sde_hw_pingpong {
  134. struct sde_hw_blk_reg_map hw;
  135. /* pingpong */
  136. enum sde_pingpong idx;
  137. const struct sde_pingpong_cfg *caps;
  138. /* associated dcwb idx */
  139. enum sde_dcwb dcwb_idx;
  140. /* associated 3d_merge */
  141. struct sde_hw_merge_3d *merge_3d;
  142. /* ops */
  143. struct sde_hw_pingpong_ops ops;
  144. };
  145. /**
  146. * to_sde_hw_pingpong - convert base hw object to sde_hw_pingpong container
  147. * @hw: Pointer to hardware block register map object
  148. * return: Pointer to hardware block container
  149. */
  150. static inline struct sde_hw_pingpong *to_sde_hw_pingpong(struct sde_hw_blk_reg_map *hw)
  151. {
  152. return container_of(hw, struct sde_hw_pingpong, hw);
  153. }
  154. /**
  155. * sde_hw_pingpong_init - initializes the pingpong driver for the passed
  156. * pingpong idx.
  157. * @idx: Pingpong index for which driver object is required
  158. * @addr: Mapped register io address of MDP
  159. * @m: Pointer to mdss catalog data
  160. * Returns: Error code or allocated sde_hw_pingpong context
  161. */
  162. struct sde_hw_blk_reg_map *sde_hw_pingpong_init(enum sde_pingpong idx,
  163. void __iomem *addr,
  164. struct sde_mdss_cfg *m);
  165. /**
  166. * sde_hw_pingpong_destroy - destroys pingpong driver context
  167. * should be called to free the context
  168. * @hw: Pointer to hardware block register map object
  169. */
  170. void sde_hw_pingpong_destroy(struct sde_hw_blk_reg_map *hw);
  171. #endif /*_SDE_HW_PINGPONG_H */