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