xref: /linux/drivers/gpu/drm/i915/display/intel_parent.c (revision bba2c3615bd6cfee7456d1130f2e6b01b3f4e9ba)
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, struct drm_scanout_buffer *sb)
255 {
256 	return display->parent->panic->setup(panic, sb);
257 }
258 
259 void intel_parent_panic_finish(struct intel_display *display, struct intel_panic *panic)
260 {
261 	display->parent->panic->finish(panic);
262 }
263 
264 /* pc8 */
265 void intel_parent_pc8_block(struct intel_display *display)
266 {
267 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->pc8))
268 		return;
269 
270 	display->parent->pc8->block(display->drm);
271 }
272 
273 void intel_parent_pc8_unblock(struct intel_display *display)
274 {
275 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->pc8))
276 		return;
277 
278 	display->parent->pc8->unblock(display->drm);
279 }
280 
281 /* pcode */
282 int intel_parent_pcode_read(struct intel_display *display, u32 mbox, u32 *val, u32 *val1)
283 {
284 	return display->parent->pcode->read(display->drm, mbox, val, val1);
285 }
286 
287 int intel_parent_pcode_write_timeout(struct intel_display *display, u32 mbox, u32 val, int timeout_ms)
288 {
289 	return display->parent->pcode->write(display->drm, mbox, val, timeout_ms);
290 }
291 
292 int intel_parent_pcode_write(struct intel_display *display, u32 mbox, u32 val)
293 {
294 	return intel_parent_pcode_write_timeout(display, mbox, val, 1);
295 }
296 
297 int intel_parent_pcode_request(struct intel_display *display, u32 mbox, u32 request,
298 			       u32 reply_mask, u32 reply, int timeout_base_ms)
299 {
300 	return display->parent->pcode->request(display->drm, mbox, request, reply_mask, reply, timeout_base_ms);
301 }
302 
303 /* rps */
304 bool intel_parent_rps_available(struct intel_display *display)
305 {
306 	return display->parent->rps;
307 }
308 
309 void intel_parent_rps_boost_if_not_started(struct intel_display *display, struct dma_fence *fence)
310 {
311 	if (display->parent->rps)
312 		display->parent->rps->boost_if_not_started(fence);
313 }
314 
315 void intel_parent_rps_mark_interactive(struct intel_display *display, bool interactive)
316 {
317 	if (display->parent->rps)
318 		display->parent->rps->mark_interactive(display->drm, interactive);
319 }
320 
321 void intel_parent_rps_ilk_irq_handler(struct intel_display *display)
322 {
323 	if (display->parent->rps)
324 		display->parent->rps->ilk_irq_handler(display->drm);
325 }
326 
327 /* stolen */
328 int intel_parent_stolen_insert_node_in_range(struct intel_display *display,
329 					     struct intel_stolen_node *node, u64 size,
330 					     unsigned int align, u64 start, u64 end)
331 {
332 	return display->parent->stolen->insert_node_in_range(node, size, align, start, end);
333 }
334 
335 int intel_parent_stolen_insert_node(struct intel_display *display, struct intel_stolen_node *node, u64 size,
336 				    unsigned int align)
337 {
338 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->stolen->insert_node))
339 		return -ENODEV;
340 
341 	return display->parent->stolen->insert_node(node, size, align);
342 }
343 
344 void intel_parent_stolen_remove_node(struct intel_display *display,
345 				     struct intel_stolen_node *node)
346 {
347 	display->parent->stolen->remove_node(node);
348 }
349 
350 bool intel_parent_stolen_initialized(struct intel_display *display)
351 {
352 	return display->parent->stolen->initialized(display->drm);
353 }
354 
355 bool intel_parent_stolen_node_allocated(struct intel_display *display,
356 					const struct intel_stolen_node *node)
357 {
358 	return display->parent->stolen->node_allocated(node);
359 }
360 
361 u32 intel_parent_stolen_node_offset(struct intel_display *display, struct intel_stolen_node *node)
362 {
363 	return display->parent->stolen->node_offset(node);
364 }
365 
366 u64 intel_parent_stolen_area_address(struct intel_display *display)
367 {
368 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->stolen->area_address))
369 		return 0;
370 
371 	return display->parent->stolen->area_address(display->drm);
372 }
373 
374 u64 intel_parent_stolen_area_size(struct intel_display *display)
375 {
376 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->stolen->area_size))
377 		return 0;
378 
379 	return display->parent->stolen->area_size(display->drm);
380 }
381 
382 u64 intel_parent_stolen_node_address(struct intel_display *display, struct intel_stolen_node *node)
383 {
384 	return display->parent->stolen->node_address(node);
385 }
386 
387 u64 intel_parent_stolen_node_size(struct intel_display *display, const struct intel_stolen_node *node)
388 {
389 	return display->parent->stolen->node_size(node);
390 }
391 
392 struct intel_stolen_node *intel_parent_stolen_node_alloc(struct intel_display *display)
393 {
394 	return display->parent->stolen->node_alloc(display->drm);
395 }
396 
397 void intel_parent_stolen_node_free(struct intel_display *display, const struct intel_stolen_node *node)
398 {
399 	display->parent->stolen->node_free(node);
400 }
401 
402 /* vlv iosf */
403 void intel_parent_vlv_iosf_get(struct intel_display *display, unsigned long unit_mask)
404 {
405 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->vlv_iosf))
406 		return;
407 
408 	display->parent->vlv_iosf->get(display->drm, unit_mask);
409 }
410 
411 void intel_parent_vlv_iosf_put(struct intel_display *display, unsigned long unit_mask)
412 {
413 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->vlv_iosf))
414 		return;
415 
416 	display->parent->vlv_iosf->put(display->drm, unit_mask);
417 }
418 
419 u32 intel_parent_vlv_iosf_read(struct intel_display *display, enum vlv_iosf_sb_unit unit, u32 addr)
420 {
421 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->vlv_iosf))
422 		return 0;
423 
424 	return display->parent->vlv_iosf->read(display->drm, unit, addr);
425 }
426 
427 int intel_parent_vlv_iosf_write(struct intel_display *display, enum vlv_iosf_sb_unit unit, u32 addr, u32 val)
428 {
429 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->vlv_iosf))
430 		return -EINVAL;
431 
432 	return display->parent->vlv_iosf->write(display->drm, unit, addr, val);
433 }
434 
435 /* generic */
436 void intel_parent_fence_priority_display(struct intel_display *display, struct dma_fence *fence)
437 {
438 	if (display->parent->fence_priority_display)
439 		display->parent->fence_priority_display(fence);
440 }
441 
442 bool intel_parent_has_auxccs(struct intel_display *display)
443 {
444 	return display->parent->has_auxccs && display->parent->has_auxccs(display->drm);
445 }
446 
447 bool intel_parent_has_fenced_regions(struct intel_display *display)
448 {
449 	return display->parent->has_fenced_regions && display->parent->has_fenced_regions(display->drm);
450 }
451 
452 bool intel_parent_vgpu_active(struct intel_display *display)
453 {
454 	return display->parent->vgpu_active && display->parent->vgpu_active(display->drm);
455 }
456