sde_hw_pingpong.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2019, 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 <uapi/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. */
  31. struct sde_hw_pingpong_ops {
  32. /**
  33. * enables vysnc generation and sets up init value of
  34. * read pointer and programs the tear check cofiguration
  35. */
  36. int (*setup_tearcheck)(struct sde_hw_pingpong *pp,
  37. struct sde_hw_tear_check *cfg);
  38. /**
  39. * enables tear check block
  40. */
  41. int (*enable_tearcheck)(struct sde_hw_pingpong *pp,
  42. bool enable);
  43. /**
  44. * updates tearcheck configuration
  45. */
  46. void (*update_tearcheck)(struct sde_hw_pingpong *pp,
  47. struct sde_hw_tear_check *cfg);
  48. /**
  49. * read, modify, write to either set or clear listening to external TE
  50. * @Return: 1 if TE was originally connected, 0 if not, or -ERROR
  51. */
  52. int (*connect_external_te)(struct sde_hw_pingpong *pp,
  53. bool enable_external_te);
  54. /**
  55. * provides the programmed and current
  56. * line_count
  57. */
  58. int (*get_vsync_info)(struct sde_hw_pingpong *pp,
  59. struct sde_hw_pp_vsync_info *info);
  60. /**
  61. * configure and enable the autorefresh config
  62. */
  63. int (*setup_autorefresh)(struct sde_hw_pingpong *pp,
  64. struct sde_hw_autorefresh *cfg);
  65. /**
  66. * retrieve autorefresh config from hardware
  67. */
  68. int (*get_autorefresh)(struct sde_hw_pingpong *pp,
  69. struct sde_hw_autorefresh *cfg);
  70. /**
  71. * poll until write pointer transmission starts
  72. * @Return: 0 on success, -ETIMEDOUT on timeout
  73. */
  74. int (*poll_timeout_wr_ptr)(struct sde_hw_pingpong *pp, u32 timeout_us);
  75. /**
  76. * Program the dsc compression block
  77. */
  78. int (*setup_dsc)(struct sde_hw_pingpong *pp);
  79. /**
  80. * Enables DSC encoder
  81. */
  82. void (*enable_dsc)(struct sde_hw_pingpong *pp);
  83. /**
  84. * Disables DSC encoder
  85. */
  86. void (*disable_dsc)(struct sde_hw_pingpong *pp);
  87. /**
  88. * Get DSC status
  89. * @Return: register value of DSC config
  90. */
  91. u32 (*get_dsc_status)(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. struct sde_hw_merge_3d_ops {
  111. /**
  112. * setup the 3d blend mode configuration
  113. */
  114. void (*setup_blend_mode)(struct sde_hw_merge_3d *id,
  115. enum sde_3d_blend_mode cfg);
  116. /**
  117. * reset 3d blend mode configuration
  118. */
  119. void (*reset_blend_mode)(struct sde_hw_merge_3d *id);
  120. };
  121. struct sde_hw_merge_3d {
  122. struct sde_hw_blk base;
  123. struct sde_hw_blk_reg_map hw;
  124. /* merge_3d */
  125. enum sde_merge_3d idx;
  126. const struct sde_merge_3d_cfg *caps;
  127. /* ops */
  128. struct sde_hw_merge_3d_ops ops;
  129. };
  130. struct sde_hw_pingpong {
  131. struct sde_hw_blk base;
  132. struct sde_hw_blk_reg_map hw;
  133. /* pingpong */
  134. enum sde_pingpong idx;
  135. const struct sde_pingpong_cfg *caps;
  136. /* associated 3d_merge */
  137. struct sde_hw_merge_3d *merge_3d;
  138. /* ops */
  139. struct sde_hw_pingpong_ops ops;
  140. };
  141. /**
  142. * sde_hw_pingpong - convert base object sde_hw_base to container
  143. * @hw: Pointer to base hardware block
  144. * return: Pointer to hardware block container
  145. */
  146. static inline struct sde_hw_pingpong *to_sde_hw_pingpong(struct sde_hw_blk *hw)
  147. {
  148. return container_of(hw, struct sde_hw_pingpong, base);
  149. }
  150. /**
  151. * sde_hw_pingpong_init - initializes the pingpong driver for the passed
  152. * pingpong idx.
  153. * @idx: Pingpong index for which driver object is required
  154. * @addr: Mapped register io address of MDP
  155. * @m: Pointer to mdss catalog data
  156. * Returns: Error code or allocated sde_hw_pingpong context
  157. */
  158. struct sde_hw_pingpong *sde_hw_pingpong_init(enum sde_pingpong idx,
  159. void __iomem *addr,
  160. struct sde_mdss_cfg *m);
  161. /**
  162. * sde_hw_pingpong_destroy - destroys pingpong driver context
  163. * should be called to free the context
  164. * @pp: Pointer to PP driver context returned by sde_hw_pingpong_init
  165. */
  166. void sde_hw_pingpong_destroy(struct sde_hw_pingpong *pp);
  167. #endif /*_SDE_HW_PINGPONG_H */