xref: /linux/include/drm/intel/display_parent_interface.h (revision 99676aed1fec109d62822e21a06760eb098dc5f4)
1 /* SPDX-License-Identifier: MIT */
2 /* Copyright © 2025 Intel Corporation x*/
3 
4 #ifndef __DISPLAY_PARENT_INTERFACE_H__
5 #define __DISPLAY_PARENT_INTERFACE_H__
6 
7 #include <linux/types.h>
8 
9 enum vlv_iosf_sb_unit;
10 struct dma_fence;
11 struct drm_device;
12 struct drm_file;
13 struct drm_framebuffer;
14 struct drm_gem_object;
15 struct drm_mode_fb_cmd2;
16 struct drm_plane_state;
17 struct drm_scanout_buffer;
18 struct fb_info;
19 struct i915_gtt_view;
20 struct i915_vma;
21 struct intel_dpt;
22 struct intel_dsb_buffer;
23 struct intel_frontbuffer;
24 struct intel_hdcp_gsc_context;
25 struct intel_initial_plane_config;
26 struct intel_panic;
27 struct intel_stolen_node;
28 struct iosys_map;
29 struct ref_tracker;
30 struct seq_file;
31 struct vm_area_struct;
32 
33 struct intel_fb_pin_params {
34 	const struct i915_gtt_view *view;
35 	unsigned int alignment;
36 	unsigned int phys_alignment;
37 	unsigned int vtd_guard;
38 	bool needs_cpu_lmem_access;
39 	bool needs_low_address;
40 	bool needs_physical;
41 	bool needs_fence;
42 };
43 
44 /* Keep struct definitions sorted */
45 
46 struct intel_display_bo_interface {
47 	bool (*is_tiled)(struct drm_gem_object *obj); /* Optional */
48 	bool (*is_userptr)(struct drm_gem_object *obj); /* Optional */
49 	bool (*is_shmem)(struct drm_gem_object *obj); /* Optional */
50 	bool (*is_protected)(struct drm_gem_object *obj);
51 	int (*key_check)(struct drm_gem_object *obj);
52 	int (*fb_mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
53 	int (*read_from_page)(struct drm_gem_object *obj, u64 offset, void *dst, int size);
54 	void (*describe)(struct seq_file *m, struct drm_gem_object *obj); /* Optional */
55 	int (*framebuffer_init)(struct drm_gem_object *obj, struct drm_mode_fb_cmd2 *mode_cmd);
56 	void (*framebuffer_fini)(struct drm_gem_object *obj);
57 	struct drm_gem_object *(*framebuffer_lookup)(struct drm_device *drm,
58 						     struct drm_file *filp,
59 						     const struct drm_mode_fb_cmd2 *user_mode_cmd);
60 #if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
61 	struct drm_gem_object *(*fbdev_create)(struct drm_device *drm, int size);
62 	void (*fbdev_destroy)(struct drm_gem_object *obj);
63 	int (*fbdev_fill_info)(struct drm_gem_object *obj, struct fb_info *info, struct i915_vma *vma);
64 	u32 (*fbdev_pitch_align)(u32 stride);
65 #endif
66 };
67 
68 struct intel_display_dpt_interface {
69 	struct intel_dpt *(*create)(struct drm_gem_object *obj, size_t size);
70 	void (*destroy)(struct intel_dpt *dpt);
71 	void (*suspend)(struct intel_dpt *dpt);
72 	void (*resume)(struct intel_dpt *dpt);
73 };
74 
75 struct intel_display_dsb_interface {
76 	u32 (*ggtt_offset)(struct intel_dsb_buffer *dsb_buf);
77 	void (*write)(struct intel_dsb_buffer *dsb_buf, u32 idx, u32 val);
78 	u32 (*read)(struct intel_dsb_buffer *dsb_buf, u32 idx);
79 	void (*fill)(struct intel_dsb_buffer *dsb_buf, u32 idx, u32 val, size_t size);
80 	struct intel_dsb_buffer *(*create)(struct drm_device *drm, size_t size);
81 	void (*cleanup)(struct intel_dsb_buffer *dsb_buf);
82 	void (*flush_map)(struct intel_dsb_buffer *dsb_buf);
83 };
84 
85 struct intel_display_fb_pin_interface {
86 	int (*ggtt_pin)(struct drm_gem_object *obj,
87 			const struct intel_fb_pin_params *pin_params,
88 			struct i915_vma **out_ggtt_vma,
89 			u32 *out_offset,
90 			int *out_fence_id);
91 	void (*ggtt_unpin)(struct i915_vma *ggtt_vma,
92 			   int fence_id);
93 	int (*dpt_pin)(struct drm_gem_object *obj,
94 		       struct intel_dpt *dpt,
95 		       const struct intel_fb_pin_params *pin_params,
96 		       struct i915_vma **out_dpt_vma,
97 		       struct i915_vma **out_ggtt_vma,
98 		       u32 *out_offset);
99 	void (*dpt_unpin)(struct intel_dpt *dpt,
100 			  struct i915_vma *dpt_vma,
101 			  struct i915_vma *ggtt_vma);
102 	struct i915_vma *(*reuse_vma)(struct i915_vma *old_ggtt_vma,
103 				      struct drm_gem_object *old_obj,
104 				      const struct i915_gtt_view *old_view,
105 				      struct drm_gem_object *new_obj,
106 				      const struct i915_gtt_view *new_view,
107 				      u32 *out_offset);
108 	void (*get_map)(struct i915_vma *vma, struct iosys_map *map);
109 };
110 
111 struct intel_display_frontbuffer_interface {
112 	struct intel_frontbuffer *(*get)(struct drm_gem_object *obj);
113 	void (*ref)(struct intel_frontbuffer *front);
114 	void (*put)(struct intel_frontbuffer *front);
115 	void (*flush_for_display)(struct intel_frontbuffer *front);
116 };
117 
118 struct intel_display_hdcp_interface {
119 	ssize_t (*gsc_msg_send)(struct intel_hdcp_gsc_context *gsc_context,
120 				void *msg_in, size_t msg_in_len,
121 				void *msg_out, size_t msg_out_len);
122 	bool (*gsc_check_status)(struct drm_device *drm);
123 	struct intel_hdcp_gsc_context *(*gsc_context_alloc)(struct drm_device *drm);
124 	void (*gsc_context_free)(struct intel_hdcp_gsc_context *gsc_context);
125 };
126 
127 struct intel_display_initial_plane_interface {
128 	struct drm_gem_object *(*alloc_obj)(struct drm_device *drm, struct intel_initial_plane_config *plane_config);
129 	int (*setup)(struct drm_plane_state *plane_state, struct intel_initial_plane_config *plane_config,
130 		     struct drm_framebuffer *fb, struct i915_vma *vma);
131 	void (*config_fini)(struct intel_initial_plane_config *plane_config);
132 };
133 
134 struct intel_display_irq_interface {
135 	bool (*enabled)(struct drm_device *drm);
136 	void (*synchronize)(struct drm_device *drm);
137 };
138 
139 struct intel_display_overlay_interface {
140 	bool (*is_active)(struct drm_device *drm);
141 
142 	int (*overlay_on)(struct drm_device *drm,
143 			  u32 frontbuffer_bits);
144 	int (*overlay_continue)(struct drm_device *drm,
145 				struct i915_vma *vma,
146 				bool load_polyphase_filter);
147 	int (*overlay_off)(struct drm_device *drm);
148 	int (*recover_from_interrupt)(struct drm_device *drm);
149 	int (*release_old_vid)(struct drm_device *drm);
150 
151 	void (*reset)(struct drm_device *drm);
152 
153 	struct i915_vma *(*pin_fb)(struct drm_device *drm,
154 				   struct drm_gem_object *obj,
155 				   u32 *offset);
156 	void (*unpin_fb)(struct drm_device *drm,
157 			 struct i915_vma *vma);
158 
159 	struct drm_gem_object *(*obj_lookup)(struct drm_device *drm,
160 					     struct drm_file *filp,
161 					     u32 handle);
162 
163 	void __iomem *(*setup)(struct drm_device *drm,
164 			       bool needs_physical);
165 	void (*cleanup)(struct drm_device *drm);
166 };
167 
168 struct intel_display_panic_interface {
169 	struct intel_panic *(*alloc)(void);
170 	int (*setup)(struct intel_panic *panic, struct drm_scanout_buffer *sb);
171 	void (*finish)(struct intel_panic *panic);
172 };
173 
174 struct intel_display_pc8_interface {
175 	void (*block)(struct drm_device *drm);
176 	void (*unblock)(struct drm_device *drm);
177 };
178 
179 struct intel_display_pcode_interface {
180 	int (*read)(struct drm_device *drm, u32 mbox, u32 *val, u32 *val1);
181 	int (*write)(struct drm_device *drm, u32 mbox, u32 val, int timeout_ms);
182 	int (*request)(struct drm_device *drm, u32 mbox, u32 request,
183 		       u32 reply_mask, u32 reply, int timeout_base_ms);
184 };
185 
186 struct intel_display_rpm_interface {
187 	struct ref_tracker *(*get)(const struct drm_device *drm);
188 	struct ref_tracker *(*get_raw)(const struct drm_device *drm);
189 	struct ref_tracker *(*get_if_in_use)(const struct drm_device *drm);
190 	struct ref_tracker *(*get_noresume)(const struct drm_device *drm);
191 
192 	void (*put)(const struct drm_device *drm, struct ref_tracker *wakeref);
193 	void (*put_raw)(const struct drm_device *drm, struct ref_tracker *wakeref);
194 	void (*put_unchecked)(const struct drm_device *drm);
195 
196 	bool (*suspended)(const struct drm_device *drm);
197 	void (*assert_held)(const struct drm_device *drm);
198 	void (*assert_block)(const struct drm_device *drm);
199 	void (*assert_unblock)(const struct drm_device *drm);
200 };
201 
202 struct intel_display_rps_interface {
203 	void (*boost_if_not_started)(struct dma_fence *fence);
204 	void (*mark_interactive)(struct drm_device *drm, bool interactive);
205 	void (*ilk_irq_handler)(struct drm_device *drm);
206 };
207 
208 struct intel_display_stolen_interface {
209 	int (*insert_node_in_range)(struct intel_stolen_node *node, u64 size,
210 				    unsigned int align, u64 start, u64 end);
211 	int (*insert_node)(struct intel_stolen_node *node, u64 size, unsigned int align); /* Optional */
212 	void (*remove_node)(struct intel_stolen_node *node);
213 	bool (*initialized)(struct drm_device *drm);
214 	bool (*node_allocated)(const struct intel_stolen_node *node);
215 	u64 (*node_offset)(const struct intel_stolen_node *node);
216 	u64 (*area_address)(struct drm_device *drm); /* Optional */
217 	u64 (*area_size)(struct drm_device *drm); /* Optional */
218 	u64 (*node_address)(const struct intel_stolen_node *node);
219 	u64 (*node_size)(const struct intel_stolen_node *node);
220 	struct intel_stolen_node *(*node_alloc)(struct drm_device *drm);
221 	void (*node_free)(const struct intel_stolen_node *node);
222 };
223 
224 struct intel_display_vlv_iosf_interface {
225 	void (*get)(struct drm_device *drm, unsigned long unit_mask);
226 	void (*put)(struct drm_device *drm, unsigned long unit_mask);
227 	u32 (*read)(struct drm_device *drm, enum vlv_iosf_sb_unit unit, u32 addr);
228 	int (*write)(struct drm_device *drm, enum vlv_iosf_sb_unit unit, u32 addr, u32 val);
229 };
230 
231 /**
232  * struct intel_display_parent_interface - services parent driver provides to display
233  *
234  * The parent, or core, driver provides a pointer to this structure to display
235  * driver when calling intel_display_device_probe(). The display driver uses it
236  * to access services provided by the parent driver. The structure may contain
237  * sub-struct pointers to group function pointers by functionality.
238  *
239  * All function and sub-struct pointers must be initialized and callable unless
240  * explicitly marked as "optional" below. The display driver will only NULL
241  * check the optional pointers.
242  */
243 struct intel_display_parent_interface {
244 	/** @bo: BO interface */
245 	const struct intel_display_bo_interface *bo;
246 
247 	/** @dpt: DPT interface. Optional. */
248 	const struct intel_display_dpt_interface *dpt;
249 
250 	/** @dsb: DSB buffer interface */
251 	const struct intel_display_dsb_interface *dsb;
252 
253 	/** @fb_pin: Framebuffer pin interface */
254 	const struct intel_display_fb_pin_interface *fb_pin;
255 
256 	/** @frontbuffer: Frontbuffer interface */
257 	const struct intel_display_frontbuffer_interface *frontbuffer;
258 
259 	/** @hdcp: HDCP GSC interface */
260 	const struct intel_display_hdcp_interface *hdcp;
261 
262 	/** @initial_plane: Initial plane interface */
263 	const struct intel_display_initial_plane_interface *initial_plane;
264 
265 	/** @irq: IRQ interface */
266 	const struct intel_display_irq_interface *irq;
267 
268 	/** @panic: Panic interface */
269 	const struct intel_display_panic_interface *panic;
270 
271 	/** @overlay: Overlay. Optional. */
272 	const struct intel_display_overlay_interface *overlay;
273 
274 	/** @pc8: PC8 interface. Optional. */
275 	const struct intel_display_pc8_interface *pc8;
276 
277 	/** @pcode: Pcode interface */
278 	const struct intel_display_pcode_interface *pcode;
279 
280 	/** @rpm: Runtime PM functions */
281 	const struct intel_display_rpm_interface *rpm;
282 
283 	/** @rps: RPS interface. Optional. */
284 	const struct intel_display_rps_interface *rps;
285 
286 	/** @stolen: Stolen memory. */
287 	const struct intel_display_stolen_interface *stolen;
288 
289 	/** @vlv_iosf: VLV IOSF sideband. Optional. */
290 	const struct intel_display_vlv_iosf_interface *vlv_iosf;
291 
292 	/* Generic independent functions */
293 	struct {
294 		/** @fence_priority_display: Set display priority. Optional. */
295 		void (*fence_priority_display)(struct dma_fence *fence);
296 
297 		/** @has_auxccs: Are AuxCCS formats supported by the parent. Optional. */
298 		bool (*has_auxccs)(struct drm_device *drm);
299 
300 		/** @has_fenced_regions: Support legacy fencing? Optional. */
301 		bool (*has_fenced_regions)(struct drm_device *drm);
302 
303 		/** @vgpu_active: Is vGPU active? Optional. */
304 		bool (*vgpu_active)(struct drm_device *drm);
305 	};
306 };
307 
308 #endif
309