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