xref: /linux/drivers/gpu/drm/i915/display/intel_parent.c (revision 570f7e331f5febb30f1384817463c7e42b65ca7d)
1 // SPDX-License-Identifier: MIT
2 /* Copyright © 2025 Intel Corporation */
3 
4 /*
5  * Convenience wrapper functions to call the parent interface functions:
6  *
7  * - display->parent->SUBSTRUCT->FUNCTION()
8  * - display->parent->FUNCTION()
9  *
10  * All functions here should be named accordingly:
11  *
12  * - intel_parent_SUBSTRUCT_FUNCTION()
13  * - intel_parent_FUNCTION()
14  *
15  * These functions may use display driver specific types for parameters and
16  * return values, translating them to and from the generic types used in the
17  * function pointer interface.
18  */
19 
20 #include <drm/drm_print.h>
21 #include <drm/intel/display_parent_interface.h>
22 #include <drm/intel/vlv_iosf_sb_regs.h>
23 
24 #include "intel_display_core.h"
25 #include "intel_parent.h"
26 
27 /* dpt */
28 struct intel_dpt *intel_parent_dpt_create(struct intel_display *display,
29 					  struct drm_gem_object *obj, size_t size)
30 {
31 	if (display->parent->dpt)
32 		return display->parent->dpt->create(obj, size);
33 
34 	return NULL;
35 }
36 
37 void intel_parent_dpt_destroy(struct intel_display *display, struct intel_dpt *dpt)
38 {
39 	if (display->parent->dpt)
40 		display->parent->dpt->destroy(dpt);
41 }
42 
43 void intel_parent_dpt_suspend(struct intel_display *display, struct intel_dpt *dpt)
44 {
45 	if (display->parent->dpt)
46 		display->parent->dpt->suspend(dpt);
47 }
48 
49 void intel_parent_dpt_resume(struct intel_display *display, struct intel_dpt *dpt)
50 {
51 	if (display->parent->dpt)
52 		display->parent->dpt->resume(dpt);
53 }
54 
55 /* fb_pin */
56 int intel_parent_fb_pin_ggtt_pin(struct intel_display *display,
57 				 struct drm_gem_object *obj,
58 				 const struct intel_fb_pin_params *pin_params,
59 				 struct i915_vma **out_ggtt_vma,
60 				 u32 *out_offset,
61 				 int *out_fence_id)
62 {
63 	return display->parent->fb_pin->ggtt_pin(obj, pin_params,
64 						 out_ggtt_vma, out_offset, out_fence_id);
65 }
66 
67 void intel_parent_fb_pin_ggtt_unpin(struct intel_display *display,
68 				    struct i915_vma *ggtt_vma,
69 				    int fence_id)
70 {
71 	return display->parent->fb_pin->ggtt_unpin(ggtt_vma, fence_id);
72 }
73 
74 int intel_parent_fb_pin_dpt_pin(struct intel_display *display,
75 				struct drm_gem_object *obj,
76 				struct intel_dpt *dpt,
77 				const struct intel_fb_pin_params *pin_params,
78 				struct i915_vma **out_dpt_vma,
79 				struct i915_vma **out_ggtt_vma,
80 				u32 *out_offset)
81 {
82 	return display->parent->fb_pin->dpt_pin(obj, dpt, pin_params,
83 						out_dpt_vma, out_ggtt_vma, out_offset);
84 }
85 
86 void intel_parent_fb_pin_dpt_unpin(struct intel_display *display,
87 				   struct intel_dpt *dpt,
88 				   struct i915_vma *dpt_vma,
89 				   struct i915_vma *ggtt_vma)
90 {
91 	return display->parent->fb_pin->dpt_unpin(dpt, dpt_vma, ggtt_vma);
92 }
93 
94 struct i915_vma *intel_parent_fb_pin_reuse_vma(struct intel_display *display,
95 					       struct i915_vma *old_ggtt_vma,
96 					       struct drm_gem_object *old_obj,
97 					       const struct i915_gtt_view *old_view,
98 					       struct drm_gem_object *new_obj,
99 					       const struct i915_gtt_view *new_view,
100 					       u32 *out_offset)
101 {
102 	if (!display->parent->fb_pin->reuse_vma)
103 		return NULL;
104 
105 	return display->parent->fb_pin->reuse_vma(old_ggtt_vma, old_obj, old_view,
106 						  new_obj, new_view, out_offset);
107 }
108 
109 void intel_parent_fb_pin_get_map(struct intel_display *display,
110 				 struct i915_vma *vma, struct iosys_map *map)
111 {
112 	return display->parent->fb_pin->get_map(vma, map);
113 }
114 
115 /* frontbuffer */
116 struct intel_frontbuffer *intel_parent_frontbuffer_get(struct intel_display *display, struct drm_gem_object *obj)
117 {
118 	return display->parent->frontbuffer->get(obj);
119 }
120 
121 void intel_parent_frontbuffer_ref(struct intel_display *display, struct intel_frontbuffer *front)
122 {
123 	display->parent->frontbuffer->ref(front);
124 }
125 
126 void intel_parent_frontbuffer_put(struct intel_display *display, struct intel_frontbuffer *front)
127 {
128 	display->parent->frontbuffer->put(front);
129 }
130 
131 void intel_parent_frontbuffer_flush_for_display(struct intel_display *display, struct intel_frontbuffer *front)
132 {
133 	display->parent->frontbuffer->flush_for_display(front);
134 }
135 
136 /* hdcp */
137 ssize_t intel_parent_hdcp_gsc_msg_send(struct intel_display *display,
138 				       struct intel_hdcp_gsc_context *gsc_context,
139 				       void *msg_in, size_t msg_in_len,
140 				       void *msg_out, size_t msg_out_len)
141 {
142 	return display->parent->hdcp->gsc_msg_send(gsc_context, msg_in, msg_in_len, msg_out, msg_out_len);
143 }
144 
145 bool intel_parent_hdcp_gsc_check_status(struct intel_display *display)
146 {
147 	return display->parent->hdcp->gsc_check_status(display->drm);
148 }
149 
150 struct intel_hdcp_gsc_context *intel_parent_hdcp_gsc_context_alloc(struct intel_display *display)
151 {
152 	return display->parent->hdcp->gsc_context_alloc(display->drm);
153 }
154 
155 void intel_parent_hdcp_gsc_context_free(struct intel_display *display,
156 					struct intel_hdcp_gsc_context *gsc_context)
157 {
158 	display->parent->hdcp->gsc_context_free(gsc_context);
159 }
160 
161 /* irq */
162 bool intel_parent_irq_enabled(struct intel_display *display)
163 {
164 	return display->parent->irq->enabled(display->drm);
165 }
166 
167 void intel_parent_irq_synchronize(struct intel_display *display)
168 {
169 	display->parent->irq->synchronize(display->drm);
170 }
171 
172 /* overlay */
173 bool intel_parent_overlay_is_active(struct intel_display *display)
174 {
175 	return display->parent->overlay->is_active(display->drm);
176 }
177 
178 int intel_parent_overlay_on(struct intel_display *display,
179 			    u32 frontbuffer_bits)
180 {
181 	return display->parent->overlay->overlay_on(display->drm,
182 						    frontbuffer_bits);
183 }
184 
185 int intel_parent_overlay_continue(struct intel_display *display,
186 				  struct i915_vma *vma,
187 				  bool load_polyphase_filter)
188 {
189 	return display->parent->overlay->overlay_continue(display->drm, vma,
190 							  load_polyphase_filter);
191 }
192 
193 int intel_parent_overlay_off(struct intel_display *display)
194 {
195 	return display->parent->overlay->overlay_off(display->drm);
196 }
197 
198 int intel_parent_overlay_recover_from_interrupt(struct intel_display *display)
199 {
200 	return display->parent->overlay->recover_from_interrupt(display->drm);
201 }
202 
203 int intel_parent_overlay_release_old_vid(struct intel_display *display)
204 {
205 	return display->parent->overlay->release_old_vid(display->drm);
206 }
207 
208 void intel_parent_overlay_reset(struct intel_display *display)
209 {
210 	display->parent->overlay->reset(display->drm);
211 }
212 
213 struct i915_vma *intel_parent_overlay_pin_fb(struct intel_display *display,
214 					     struct drm_gem_object *obj,
215 					     u32 *offset)
216 {
217 	return display->parent->overlay->pin_fb(display->drm, obj, offset);
218 }
219 
220 void intel_parent_overlay_unpin_fb(struct intel_display *display,
221 				   struct i915_vma *vma)
222 {
223 	return display->parent->overlay->unpin_fb(display->drm, vma);
224 }
225 
226 struct drm_gem_object *intel_parent_overlay_obj_lookup(struct intel_display *display,
227 						       struct drm_file *filp,
228 						       u32 handle)
229 {
230 	return display->parent->overlay->obj_lookup(display->drm,
231 						    filp, handle);
232 }
233 
234 void __iomem *intel_parent_overlay_setup(struct intel_display *display,
235 					 bool needs_physical)
236 {
237 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->overlay))
238 		return ERR_PTR(-ENODEV);
239 
240 	return display->parent->overlay->setup(display->drm, needs_physical);
241 }
242 
243 void intel_parent_overlay_cleanup(struct intel_display *display)
244 {
245 	display->parent->overlay->cleanup(display->drm);
246 }
247 
248 /* panic */
249 struct intel_panic *intel_parent_panic_alloc(struct intel_display *display)
250 {
251 	return display->parent->panic->alloc();
252 }
253 
254 int intel_parent_panic_setup(struct intel_display *display, struct intel_panic *panic,
255 			     struct drm_scanout_buffer *sb, struct drm_gem_object *obj,
256 			     unsigned int (*tiling)(unsigned int x, unsigned int y, unsigned int width))
257 {
258 	return display->parent->panic->setup(panic, sb, obj, tiling);
259 }
260 
261 void intel_parent_panic_finish(struct intel_display *display, struct intel_panic *panic)
262 {
263 	display->parent->panic->finish(panic);
264 }
265 
266 /* pc8 */
267 void intel_parent_pc8_block(struct intel_display *display)
268 {
269 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->pc8))
270 		return;
271 
272 	display->parent->pc8->block(display->drm);
273 }
274 
275 void intel_parent_pc8_unblock(struct intel_display *display)
276 {
277 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->pc8))
278 		return;
279 
280 	display->parent->pc8->unblock(display->drm);
281 }
282 
283 /* pcode */
284 int intel_parent_pcode_read(struct intel_display *display, u32 mbox, u32 *val, u32 *val1)
285 {
286 	return display->parent->pcode->read(display->drm, mbox, val, val1);
287 }
288 
289 int intel_parent_pcode_write_timeout(struct intel_display *display, u32 mbox, u32 val, int timeout_ms)
290 {
291 	return display->parent->pcode->write(display->drm, mbox, val, timeout_ms);
292 }
293 
294 int intel_parent_pcode_write(struct intel_display *display, u32 mbox, u32 val)
295 {
296 	return intel_parent_pcode_write_timeout(display, mbox, val, 1);
297 }
298 
299 int intel_parent_pcode_request(struct intel_display *display, u32 mbox, u32 request,
300 			       u32 reply_mask, u32 reply, int timeout_base_ms)
301 {
302 	return display->parent->pcode->request(display->drm, mbox, request, reply_mask, reply, timeout_base_ms);
303 }
304 
305 /* rps */
306 bool intel_parent_rps_available(struct intel_display *display)
307 {
308 	return display->parent->rps;
309 }
310 
311 void intel_parent_rps_boost_if_not_started(struct intel_display *display, struct dma_fence *fence)
312 {
313 	if (display->parent->rps)
314 		display->parent->rps->boost_if_not_started(fence);
315 }
316 
317 void intel_parent_rps_mark_interactive(struct intel_display *display, bool interactive)
318 {
319 	if (display->parent->rps)
320 		display->parent->rps->mark_interactive(display->drm, interactive);
321 }
322 
323 void intel_parent_rps_ilk_irq_handler(struct intel_display *display)
324 {
325 	if (display->parent->rps)
326 		display->parent->rps->ilk_irq_handler(display->drm);
327 }
328 
329 /* stolen */
330 int intel_parent_stolen_insert_node_in_range(struct intel_display *display,
331 					     struct intel_stolen_node *node, u64 size,
332 					     unsigned int align, u64 start, u64 end)
333 {
334 	return display->parent->stolen->insert_node_in_range(node, size, align, start, end);
335 }
336 
337 int intel_parent_stolen_insert_node(struct intel_display *display, struct intel_stolen_node *node, u64 size,
338 				    unsigned int align)
339 {
340 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->stolen->insert_node))
341 		return -ENODEV;
342 
343 	return display->parent->stolen->insert_node(node, size, align);
344 }
345 
346 void intel_parent_stolen_remove_node(struct intel_display *display,
347 				     struct intel_stolen_node *node)
348 {
349 	display->parent->stolen->remove_node(node);
350 }
351 
352 bool intel_parent_stolen_initialized(struct intel_display *display)
353 {
354 	return display->parent->stolen->initialized(display->drm);
355 }
356 
357 bool intel_parent_stolen_node_allocated(struct intel_display *display,
358 					const struct intel_stolen_node *node)
359 {
360 	return display->parent->stolen->node_allocated(node);
361 }
362 
363 u32 intel_parent_stolen_node_offset(struct intel_display *display, struct intel_stolen_node *node)
364 {
365 	return display->parent->stolen->node_offset(node);
366 }
367 
368 u64 intel_parent_stolen_area_address(struct intel_display *display)
369 {
370 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->stolen->area_address))
371 		return 0;
372 
373 	return display->parent->stolen->area_address(display->drm);
374 }
375 
376 u64 intel_parent_stolen_area_size(struct intel_display *display)
377 {
378 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->stolen->area_size))
379 		return 0;
380 
381 	return display->parent->stolen->area_size(display->drm);
382 }
383 
384 u64 intel_parent_stolen_node_address(struct intel_display *display, struct intel_stolen_node *node)
385 {
386 	return display->parent->stolen->node_address(node);
387 }
388 
389 u64 intel_parent_stolen_node_size(struct intel_display *display, const struct intel_stolen_node *node)
390 {
391 	return display->parent->stolen->node_size(node);
392 }
393 
394 struct intel_stolen_node *intel_parent_stolen_node_alloc(struct intel_display *display)
395 {
396 	return display->parent->stolen->node_alloc(display->drm);
397 }
398 
399 void intel_parent_stolen_node_free(struct intel_display *display, const struct intel_stolen_node *node)
400 {
401 	display->parent->stolen->node_free(node);
402 }
403 
404 /* vlv iosf */
405 void intel_parent_vlv_iosf_get(struct intel_display *display, unsigned long unit_mask)
406 {
407 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->vlv_iosf))
408 		return;
409 
410 	display->parent->vlv_iosf->get(display->drm, unit_mask);
411 }
412 
413 void intel_parent_vlv_iosf_put(struct intel_display *display, unsigned long unit_mask)
414 {
415 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->vlv_iosf))
416 		return;
417 
418 	display->parent->vlv_iosf->put(display->drm, unit_mask);
419 }
420 
421 u32 intel_parent_vlv_iosf_read(struct intel_display *display, enum vlv_iosf_sb_unit unit, u32 addr)
422 {
423 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->vlv_iosf))
424 		return 0;
425 
426 	return display->parent->vlv_iosf->read(display->drm, unit, addr);
427 }
428 
429 int intel_parent_vlv_iosf_write(struct intel_display *display, enum vlv_iosf_sb_unit unit, u32 addr, u32 val)
430 {
431 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->vlv_iosf))
432 		return -EINVAL;
433 
434 	return display->parent->vlv_iosf->write(display->drm, unit, addr, val);
435 }
436 
437 /* generic */
438 void intel_parent_fence_priority_display(struct intel_display *display, struct dma_fence *fence)
439 {
440 	if (display->parent->fence_priority_display)
441 		display->parent->fence_priority_display(fence);
442 }
443 
444 bool intel_parent_has_auxccs(struct intel_display *display)
445 {
446 	return display->parent->has_auxccs && display->parent->has_auxccs(display->drm);
447 }
448 
449 bool intel_parent_has_fenced_regions(struct intel_display *display)
450 {
451 	return display->parent->has_fenced_regions && display->parent->has_fenced_regions(display->drm);
452 }
453 
454 bool intel_parent_vgpu_active(struct intel_display *display)
455 {
456 	return display->parent->vgpu_active && display->parent->vgpu_active(display->drm);
457 }
458