drm_dp_tunnel.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /* SPDX-License-Identifier: MIT */
  2. /*
  3. * Copyright © 2023 Intel Corporation
  4. */
  5. #ifndef __DRM_DP_TUNNEL_H__
  6. #define __DRM_DP_TUNNEL_H__
  7. #include <linux/err.h>
  8. #include <linux/errno.h>
  9. #include <linux/types.h>
  10. struct drm_dp_aux;
  11. struct drm_device;
  12. struct drm_atomic_state;
  13. struct drm_dp_tunnel_mgr;
  14. struct drm_dp_tunnel_state;
  15. struct ref_tracker;
  16. struct drm_dp_tunnel_ref {
  17. struct drm_dp_tunnel *tunnel;
  18. struct ref_tracker *tracker;
  19. };
  20. #ifdef CONFIG_DRM_DISPLAY_DP_TUNNEL
  21. struct drm_dp_tunnel *
  22. drm_dp_tunnel_get(struct drm_dp_tunnel *tunnel, struct ref_tracker **tracker);
  23. void
  24. drm_dp_tunnel_put(struct drm_dp_tunnel *tunnel, struct ref_tracker **tracker);
  25. static inline void drm_dp_tunnel_ref_get(struct drm_dp_tunnel *tunnel,
  26. struct drm_dp_tunnel_ref *tunnel_ref)
  27. {
  28. tunnel_ref->tunnel = drm_dp_tunnel_get(tunnel, &tunnel_ref->tracker);
  29. }
  30. static inline void drm_dp_tunnel_ref_put(struct drm_dp_tunnel_ref *tunnel_ref)
  31. {
  32. drm_dp_tunnel_put(tunnel_ref->tunnel, &tunnel_ref->tracker);
  33. tunnel_ref->tunnel = NULL;
  34. }
  35. struct drm_dp_tunnel *
  36. drm_dp_tunnel_detect(struct drm_dp_tunnel_mgr *mgr,
  37. struct drm_dp_aux *aux);
  38. int drm_dp_tunnel_destroy(struct drm_dp_tunnel *tunnel);
  39. int drm_dp_tunnel_enable_bw_alloc(struct drm_dp_tunnel *tunnel);
  40. int drm_dp_tunnel_disable_bw_alloc(struct drm_dp_tunnel *tunnel);
  41. bool drm_dp_tunnel_bw_alloc_is_enabled(const struct drm_dp_tunnel *tunnel);
  42. int drm_dp_tunnel_alloc_bw(struct drm_dp_tunnel *tunnel, int bw);
  43. int drm_dp_tunnel_get_allocated_bw(struct drm_dp_tunnel *tunnel);
  44. int drm_dp_tunnel_update_state(struct drm_dp_tunnel *tunnel);
  45. void drm_dp_tunnel_set_io_error(struct drm_dp_tunnel *tunnel);
  46. int drm_dp_tunnel_handle_irq(struct drm_dp_tunnel_mgr *mgr,
  47. struct drm_dp_aux *aux);
  48. int drm_dp_tunnel_max_dprx_rate(const struct drm_dp_tunnel *tunnel);
  49. int drm_dp_tunnel_max_dprx_lane_count(const struct drm_dp_tunnel *tunnel);
  50. int drm_dp_tunnel_available_bw(const struct drm_dp_tunnel *tunnel);
  51. const char *drm_dp_tunnel_name(const struct drm_dp_tunnel *tunnel);
  52. struct drm_dp_tunnel_state *
  53. drm_dp_tunnel_atomic_get_state(struct drm_atomic_state *state,
  54. struct drm_dp_tunnel *tunnel);
  55. struct drm_dp_tunnel_state *
  56. drm_dp_tunnel_atomic_get_old_state(struct drm_atomic_state *state,
  57. const struct drm_dp_tunnel *tunnel);
  58. struct drm_dp_tunnel_state *
  59. drm_dp_tunnel_atomic_get_new_state(struct drm_atomic_state *state,
  60. const struct drm_dp_tunnel *tunnel);
  61. int drm_dp_tunnel_atomic_set_stream_bw(struct drm_atomic_state *state,
  62. struct drm_dp_tunnel *tunnel,
  63. u8 stream_id, int bw);
  64. int drm_dp_tunnel_atomic_get_group_streams_in_state(struct drm_atomic_state *state,
  65. const struct drm_dp_tunnel *tunnel,
  66. u32 *stream_mask);
  67. int drm_dp_tunnel_atomic_check_stream_bws(struct drm_atomic_state *state,
  68. u32 *failed_stream_mask);
  69. int drm_dp_tunnel_atomic_get_required_bw(const struct drm_dp_tunnel_state *tunnel_state);
  70. struct drm_dp_tunnel_mgr *
  71. drm_dp_tunnel_mgr_create(struct drm_device *dev, int max_group_count);
  72. void drm_dp_tunnel_mgr_destroy(struct drm_dp_tunnel_mgr *mgr);
  73. #else
  74. static inline struct drm_dp_tunnel *
  75. drm_dp_tunnel_get(struct drm_dp_tunnel *tunnel, struct ref_tracker **tracker)
  76. {
  77. return NULL;
  78. }
  79. static inline void
  80. drm_dp_tunnel_put(struct drm_dp_tunnel *tunnel, struct ref_tracker **tracker) {}
  81. static inline void drm_dp_tunnel_ref_get(struct drm_dp_tunnel *tunnel,
  82. struct drm_dp_tunnel_ref *tunnel_ref) {}
  83. static inline void drm_dp_tunnel_ref_put(struct drm_dp_tunnel_ref *tunnel_ref) {}
  84. static inline struct drm_dp_tunnel *
  85. drm_dp_tunnel_detect(struct drm_dp_tunnel_mgr *mgr,
  86. struct drm_dp_aux *aux)
  87. {
  88. return ERR_PTR(-EOPNOTSUPP);
  89. }
  90. static inline int
  91. drm_dp_tunnel_destroy(struct drm_dp_tunnel *tunnel)
  92. {
  93. return 0;
  94. }
  95. static inline int drm_dp_tunnel_enable_bw_alloc(struct drm_dp_tunnel *tunnel)
  96. {
  97. return -EOPNOTSUPP;
  98. }
  99. static inline int drm_dp_tunnel_disable_bw_alloc(struct drm_dp_tunnel *tunnel)
  100. {
  101. return -EOPNOTSUPP;
  102. }
  103. static inline bool drm_dp_tunnel_bw_alloc_is_enabled(const struct drm_dp_tunnel *tunnel)
  104. {
  105. return false;
  106. }
  107. static inline int
  108. drm_dp_tunnel_alloc_bw(struct drm_dp_tunnel *tunnel, int bw)
  109. {
  110. return -EOPNOTSUPP;
  111. }
  112. static inline int
  113. drm_dp_tunnel_get_allocated_bw(struct drm_dp_tunnel *tunnel)
  114. {
  115. return -1;
  116. }
  117. static inline int
  118. drm_dp_tunnel_update_state(struct drm_dp_tunnel *tunnel)
  119. {
  120. return -EOPNOTSUPP;
  121. }
  122. static inline void drm_dp_tunnel_set_io_error(struct drm_dp_tunnel *tunnel) {}
  123. static inline int
  124. drm_dp_tunnel_handle_irq(struct drm_dp_tunnel_mgr *mgr,
  125. struct drm_dp_aux *aux)
  126. {
  127. return -EOPNOTSUPP;
  128. }
  129. static inline int
  130. drm_dp_tunnel_max_dprx_rate(const struct drm_dp_tunnel *tunnel)
  131. {
  132. return 0;
  133. }
  134. static inline int
  135. drm_dp_tunnel_max_dprx_lane_count(const struct drm_dp_tunnel *tunnel)
  136. {
  137. return 0;
  138. }
  139. static inline int
  140. drm_dp_tunnel_available_bw(const struct drm_dp_tunnel *tunnel)
  141. {
  142. return -1;
  143. }
  144. static inline const char *
  145. drm_dp_tunnel_name(const struct drm_dp_tunnel *tunnel)
  146. {
  147. return NULL;
  148. }
  149. static inline struct drm_dp_tunnel_state *
  150. drm_dp_tunnel_atomic_get_state(struct drm_atomic_state *state,
  151. struct drm_dp_tunnel *tunnel)
  152. {
  153. return ERR_PTR(-EOPNOTSUPP);
  154. }
  155. static inline struct drm_dp_tunnel_state *
  156. drm_dp_tunnel_atomic_get_new_state(struct drm_atomic_state *state,
  157. const struct drm_dp_tunnel *tunnel)
  158. {
  159. return ERR_PTR(-EOPNOTSUPP);
  160. }
  161. static inline int
  162. drm_dp_tunnel_atomic_set_stream_bw(struct drm_atomic_state *state,
  163. struct drm_dp_tunnel *tunnel,
  164. u8 stream_id, int bw)
  165. {
  166. return -EOPNOTSUPP;
  167. }
  168. static inline int
  169. drm_dp_tunnel_atomic_get_group_streams_in_state(struct drm_atomic_state *state,
  170. const struct drm_dp_tunnel *tunnel,
  171. u32 *stream_mask)
  172. {
  173. return -EOPNOTSUPP;
  174. }
  175. static inline int
  176. drm_dp_tunnel_atomic_check_stream_bws(struct drm_atomic_state *state,
  177. u32 *failed_stream_mask)
  178. {
  179. return -EOPNOTSUPP;
  180. }
  181. static inline int
  182. drm_dp_tunnel_atomic_get_required_bw(const struct drm_dp_tunnel_state *tunnel_state)
  183. {
  184. return 0;
  185. }
  186. static inline struct drm_dp_tunnel_mgr *
  187. drm_dp_tunnel_mgr_create(struct drm_device *dev, int max_group_count)
  188. {
  189. return ERR_PTR(-EOPNOTSUPP);
  190. }
  191. static inline
  192. void drm_dp_tunnel_mgr_destroy(struct drm_dp_tunnel_mgr *mgr) {}
  193. #endif /* CONFIG_DRM_DISPLAY_DP_TUNNEL */
  194. #endif /* __DRM_DP_TUNNEL_H__ */