1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2023 Intel Corporation
4  */
5 
6 #ifndef __INTEL_DP_TUNNEL_H__
7 #define __INTEL_DP_TUNNEL_H__
8 
9 #include <linux/errno.h>
10 #include <linux/types.h>
11 
12 struct drm_connector_state;
13 struct drm_modeset_acquire_ctx;
14 struct intel_atomic_state;
15 struct intel_connector;
16 struct intel_crtc;
17 struct intel_crtc_state;
18 struct intel_display;
19 struct intel_dp;
20 struct intel_encoder;
21 struct intel_link_bw_limits;
22 
23 #if defined(CONFIG_DRM_I915_DP_TUNNEL) && defined(I915)
24 
25 int intel_dp_tunnel_detect(struct intel_dp *intel_dp, struct drm_modeset_acquire_ctx *ctx);
26 void intel_dp_tunnel_disconnect(struct intel_dp *intel_dp);
27 void intel_dp_tunnel_destroy(struct intel_dp *intel_dp);
28 void intel_dp_tunnel_resume(struct intel_dp *intel_dp,
29 			    const struct intel_crtc_state *crtc_state,
30 			    bool dpcd_updated);
31 void intel_dp_tunnel_suspend(struct intel_dp *intel_dp);
32 
33 bool intel_dp_tunnel_bw_alloc_is_enabled(struct intel_dp *intel_dp);
34 
35 void
36 intel_dp_tunnel_atomic_cleanup_inherited_state(struct intel_atomic_state *state);
37 
38 int intel_dp_tunnel_atomic_compute_stream_bw(struct intel_atomic_state *state,
39 					     struct intel_dp *intel_dp,
40 					     const struct intel_connector *connector,
41 					     struct intel_crtc_state *crtc_state);
42 void intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state,
43 					    struct intel_crtc_state *crtc_state);
44 
45 int intel_dp_tunnel_atomic_add_state_for_crtc(struct intel_atomic_state *state,
46 					      struct intel_crtc *crtc);
47 int intel_dp_tunnel_atomic_check_link(struct intel_atomic_state *state,
48 				      struct intel_link_bw_limits *limits);
49 int intel_dp_tunnel_atomic_check_state(struct intel_atomic_state *state,
50 				       struct intel_dp *intel_dp,
51 				       struct intel_connector *connector);
52 
53 void intel_dp_tunnel_atomic_alloc_bw(struct intel_atomic_state *state);
54 
55 int intel_dp_tunnel_mgr_init(struct intel_display *display);
56 void intel_dp_tunnel_mgr_cleanup(struct intel_display *display);
57 
58 #else
59 
60 static inline int
intel_dp_tunnel_detect(struct intel_dp * intel_dp,struct drm_modeset_acquire_ctx * ctx)61 intel_dp_tunnel_detect(struct intel_dp *intel_dp, struct drm_modeset_acquire_ctx *ctx)
62 {
63 	return -EOPNOTSUPP;
64 }
65 
intel_dp_tunnel_disconnect(struct intel_dp * intel_dp)66 static inline void intel_dp_tunnel_disconnect(struct intel_dp *intel_dp) {}
intel_dp_tunnel_destroy(struct intel_dp * intel_dp)67 static inline void intel_dp_tunnel_destroy(struct intel_dp *intel_dp) {}
intel_dp_tunnel_resume(struct intel_dp * intel_dp,const struct intel_crtc_state * crtc_state,bool dpcd_updated)68 static inline void intel_dp_tunnel_resume(struct intel_dp *intel_dp,
69 					  const struct intel_crtc_state *crtc_state,
70 					  bool dpcd_updated) {}
intel_dp_tunnel_suspend(struct intel_dp * intel_dp)71 static inline void intel_dp_tunnel_suspend(struct intel_dp *intel_dp) {}
72 
intel_dp_tunnel_bw_alloc_is_enabled(struct intel_dp * intel_dp)73 static inline bool intel_dp_tunnel_bw_alloc_is_enabled(struct intel_dp *intel_dp)
74 {
75 	return false;
76 }
77 
78 static inline void
intel_dp_tunnel_atomic_cleanup_inherited_state(struct intel_atomic_state * state)79 intel_dp_tunnel_atomic_cleanup_inherited_state(struct intel_atomic_state *state) {}
80 
81 static inline int
intel_dp_tunnel_atomic_compute_stream_bw(struct intel_atomic_state * state,struct intel_dp * intel_dp,const struct intel_connector * connector,struct intel_crtc_state * crtc_state)82 intel_dp_tunnel_atomic_compute_stream_bw(struct intel_atomic_state *state,
83 					 struct intel_dp *intel_dp,
84 					 const struct intel_connector *connector,
85 					 struct intel_crtc_state *crtc_state)
86 {
87 	return 0;
88 }
89 
90 static inline void
intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state * state,struct intel_crtc_state * crtc_state)91 intel_dp_tunnel_atomic_clear_stream_bw(struct intel_atomic_state *state,
92 				       struct intel_crtc_state *crtc_state) {}
93 
94 static inline int
intel_dp_tunnel_atomic_add_state_for_crtc(struct intel_atomic_state * state,struct intel_crtc * crtc)95 intel_dp_tunnel_atomic_add_state_for_crtc(struct intel_atomic_state *state,
96 					  struct intel_crtc *crtc)
97 {
98 	return 0;
99 }
100 
101 static inline int
intel_dp_tunnel_atomic_check_link(struct intel_atomic_state * state,struct intel_link_bw_limits * limits)102 intel_dp_tunnel_atomic_check_link(struct intel_atomic_state *state,
103 				  struct intel_link_bw_limits *limits)
104 {
105 	return 0;
106 }
107 
108 static inline int
intel_dp_tunnel_atomic_check_state(struct intel_atomic_state * state,struct intel_dp * intel_dp,struct intel_connector * connector)109 intel_dp_tunnel_atomic_check_state(struct intel_atomic_state *state,
110 				   struct intel_dp *intel_dp,
111 				   struct intel_connector *connector)
112 {
113 	return 0;
114 }
115 
116 static inline int
intel_dp_tunnel_atomic_alloc_bw(struct intel_atomic_state * state)117 intel_dp_tunnel_atomic_alloc_bw(struct intel_atomic_state *state)
118 {
119 	return 0;
120 }
121 
122 static inline int
intel_dp_tunnel_mgr_init(struct intel_display * display)123 intel_dp_tunnel_mgr_init(struct intel_display *display)
124 {
125 	return 0;
126 }
127 
intel_dp_tunnel_mgr_cleanup(struct intel_display * display)128 static inline void intel_dp_tunnel_mgr_cleanup(struct intel_display *display) {}
129 
130 #endif /* CONFIG_DRM_I915_DP_TUNNEL */
131 
132 #endif /* __INTEL_DP_TUNNEL_H__ */
133