xref: /linux/drivers/gpu/drm/i915/display/intel_parent.c (revision aec2f682d47c54ef434b2d440992626d80b1ebdc)
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 
23 #include "intel_display_core.h"
24 #include "intel_parent.h"
25 
26 /* dpt */
27 struct intel_dpt *intel_parent_dpt_create(struct intel_display *display,
28 					  struct drm_gem_object *obj, size_t size)
29 {
30 	if (display->parent->dpt)
31 		return display->parent->dpt->create(obj, size);
32 
33 	return NULL;
34 }
35 
36 void intel_parent_dpt_destroy(struct intel_display *display, struct intel_dpt *dpt)
37 {
38 	if (display->parent->dpt)
39 		display->parent->dpt->destroy(dpt);
40 }
41 
42 void intel_parent_dpt_suspend(struct intel_display *display, struct intel_dpt *dpt)
43 {
44 	if (display->parent->dpt)
45 		display->parent->dpt->suspend(dpt);
46 }
47 
48 void intel_parent_dpt_resume(struct intel_display *display, struct intel_dpt *dpt)
49 {
50 	if (display->parent->dpt)
51 		display->parent->dpt->resume(dpt);
52 }
53 
54 /* frontbuffer */
55 struct intel_frontbuffer *intel_parent_frontbuffer_get(struct intel_display *display, struct drm_gem_object *obj)
56 {
57 	return display->parent->frontbuffer->get(obj);
58 }
59 
60 void intel_parent_frontbuffer_ref(struct intel_display *display, struct intel_frontbuffer *front)
61 {
62 	display->parent->frontbuffer->ref(front);
63 }
64 
65 void intel_parent_frontbuffer_put(struct intel_display *display, struct intel_frontbuffer *front)
66 {
67 	display->parent->frontbuffer->put(front);
68 }
69 
70 void intel_parent_frontbuffer_flush_for_display(struct intel_display *display, struct intel_frontbuffer *front)
71 {
72 	display->parent->frontbuffer->flush_for_display(front);
73 }
74 
75 /* hdcp */
76 ssize_t intel_parent_hdcp_gsc_msg_send(struct intel_display *display,
77 				       struct intel_hdcp_gsc_context *gsc_context,
78 				       void *msg_in, size_t msg_in_len,
79 				       void *msg_out, size_t msg_out_len)
80 {
81 	return display->parent->hdcp->gsc_msg_send(gsc_context, msg_in, msg_in_len, msg_out, msg_out_len);
82 }
83 
84 bool intel_parent_hdcp_gsc_check_status(struct intel_display *display)
85 {
86 	return display->parent->hdcp->gsc_check_status(display->drm);
87 }
88 
89 struct intel_hdcp_gsc_context *intel_parent_hdcp_gsc_context_alloc(struct intel_display *display)
90 {
91 	return display->parent->hdcp->gsc_context_alloc(display->drm);
92 }
93 
94 void intel_parent_hdcp_gsc_context_free(struct intel_display *display,
95 					struct intel_hdcp_gsc_context *gsc_context)
96 {
97 	display->parent->hdcp->gsc_context_free(gsc_context);
98 }
99 
100 /* irq */
101 bool intel_parent_irq_enabled(struct intel_display *display)
102 {
103 	return display->parent->irq->enabled(display->drm);
104 }
105 
106 void intel_parent_irq_synchronize(struct intel_display *display)
107 {
108 	display->parent->irq->synchronize(display->drm);
109 }
110 
111 /* overlay */
112 bool intel_parent_overlay_is_active(struct intel_display *display)
113 {
114 	return display->parent->overlay->is_active(display->drm);
115 }
116 
117 int intel_parent_overlay_on(struct intel_display *display,
118 			    u32 frontbuffer_bits)
119 {
120 	return display->parent->overlay->overlay_on(display->drm,
121 						    frontbuffer_bits);
122 }
123 
124 int intel_parent_overlay_continue(struct intel_display *display,
125 				  struct i915_vma *vma,
126 				  bool load_polyphase_filter)
127 {
128 	return display->parent->overlay->overlay_continue(display->drm, vma,
129 							  load_polyphase_filter);
130 }
131 
132 int intel_parent_overlay_off(struct intel_display *display)
133 {
134 	return display->parent->overlay->overlay_off(display->drm);
135 }
136 
137 int intel_parent_overlay_recover_from_interrupt(struct intel_display *display)
138 {
139 	return display->parent->overlay->recover_from_interrupt(display->drm);
140 }
141 
142 int intel_parent_overlay_release_old_vid(struct intel_display *display)
143 {
144 	return display->parent->overlay->release_old_vid(display->drm);
145 }
146 
147 void intel_parent_overlay_reset(struct intel_display *display)
148 {
149 	display->parent->overlay->reset(display->drm);
150 }
151 
152 struct i915_vma *intel_parent_overlay_pin_fb(struct intel_display *display,
153 					     struct drm_gem_object *obj,
154 					     u32 *offset)
155 {
156 	return display->parent->overlay->pin_fb(display->drm, obj, offset);
157 }
158 
159 void intel_parent_overlay_unpin_fb(struct intel_display *display,
160 				   struct i915_vma *vma)
161 {
162 	return display->parent->overlay->unpin_fb(display->drm, vma);
163 }
164 
165 struct drm_gem_object *intel_parent_overlay_obj_lookup(struct intel_display *display,
166 						       struct drm_file *filp,
167 						       u32 handle)
168 {
169 	return display->parent->overlay->obj_lookup(display->drm,
170 						    filp, handle);
171 }
172 
173 void __iomem *intel_parent_overlay_setup(struct intel_display *display,
174 					 bool needs_physical)
175 {
176 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->overlay))
177 		return ERR_PTR(-ENODEV);
178 
179 	return display->parent->overlay->setup(display->drm, needs_physical);
180 }
181 
182 void intel_parent_overlay_cleanup(struct intel_display *display)
183 {
184 	display->parent->overlay->cleanup(display->drm);
185 }
186 
187 /* panic */
188 struct intel_panic *intel_parent_panic_alloc(struct intel_display *display)
189 {
190 	return display->parent->panic->alloc();
191 }
192 
193 int intel_parent_panic_setup(struct intel_display *display, struct intel_panic *panic, struct drm_scanout_buffer *sb)
194 {
195 	return display->parent->panic->setup(panic, sb);
196 }
197 
198 void intel_parent_panic_finish(struct intel_display *display, struct intel_panic *panic)
199 {
200 	display->parent->panic->finish(panic);
201 }
202 
203 /* pc8 */
204 void intel_parent_pc8_block(struct intel_display *display)
205 {
206 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->pc8))
207 		return;
208 
209 	display->parent->pc8->block(display->drm);
210 }
211 
212 void intel_parent_pc8_unblock(struct intel_display *display)
213 {
214 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->pc8))
215 		return;
216 
217 	display->parent->pc8->unblock(display->drm);
218 }
219 
220 /* pcode */
221 int intel_parent_pcode_read(struct intel_display *display, u32 mbox, u32 *val, u32 *val1)
222 {
223 	return display->parent->pcode->read(display->drm, mbox, val, val1);
224 }
225 
226 int intel_parent_pcode_write_timeout(struct intel_display *display, u32 mbox, u32 val, int timeout_ms)
227 {
228 	return display->parent->pcode->write(display->drm, mbox, val, timeout_ms);
229 }
230 
231 int intel_parent_pcode_write(struct intel_display *display, u32 mbox, u32 val)
232 {
233 	return intel_parent_pcode_write_timeout(display, mbox, val, 1);
234 }
235 
236 int intel_parent_pcode_request(struct intel_display *display, u32 mbox, u32 request,
237 			       u32 reply_mask, u32 reply, int timeout_base_ms)
238 {
239 	return display->parent->pcode->request(display->drm, mbox, request, reply_mask, reply, timeout_base_ms);
240 }
241 
242 /* rps */
243 bool intel_parent_rps_available(struct intel_display *display)
244 {
245 	return display->parent->rps;
246 }
247 
248 void intel_parent_rps_boost_if_not_started(struct intel_display *display, struct dma_fence *fence)
249 {
250 	if (display->parent->rps)
251 		display->parent->rps->boost_if_not_started(fence);
252 }
253 
254 void intel_parent_rps_mark_interactive(struct intel_display *display, bool interactive)
255 {
256 	if (display->parent->rps)
257 		display->parent->rps->mark_interactive(display->drm, interactive);
258 }
259 
260 void intel_parent_rps_ilk_irq_handler(struct intel_display *display)
261 {
262 	if (display->parent->rps)
263 		display->parent->rps->ilk_irq_handler(display->drm);
264 }
265 
266 /* stolen */
267 int intel_parent_stolen_insert_node_in_range(struct intel_display *display,
268 					     struct intel_stolen_node *node, u64 size,
269 					     unsigned int align, u64 start, u64 end)
270 {
271 	return display->parent->stolen->insert_node_in_range(node, size, align, start, end);
272 }
273 
274 int intel_parent_stolen_insert_node(struct intel_display *display, struct intel_stolen_node *node, u64 size,
275 				    unsigned int align)
276 {
277 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->stolen->insert_node))
278 		return -ENODEV;
279 
280 	return display->parent->stolen->insert_node(node, size, align);
281 }
282 
283 void intel_parent_stolen_remove_node(struct intel_display *display,
284 				     struct intel_stolen_node *node)
285 {
286 	display->parent->stolen->remove_node(node);
287 }
288 
289 bool intel_parent_stolen_initialized(struct intel_display *display)
290 {
291 	return display->parent->stolen->initialized(display->drm);
292 }
293 
294 bool intel_parent_stolen_node_allocated(struct intel_display *display,
295 					const struct intel_stolen_node *node)
296 {
297 	return display->parent->stolen->node_allocated(node);
298 }
299 
300 u32 intel_parent_stolen_node_offset(struct intel_display *display, struct intel_stolen_node *node)
301 {
302 	return display->parent->stolen->node_offset(node);
303 }
304 
305 u64 intel_parent_stolen_area_address(struct intel_display *display)
306 {
307 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->stolen->area_address))
308 		return 0;
309 
310 	return display->parent->stolen->area_address(display->drm);
311 }
312 
313 u64 intel_parent_stolen_area_size(struct intel_display *display)
314 {
315 	if (drm_WARN_ON_ONCE(display->drm, !display->parent->stolen->area_size))
316 		return 0;
317 
318 	return display->parent->stolen->area_size(display->drm);
319 }
320 
321 u64 intel_parent_stolen_node_address(struct intel_display *display, struct intel_stolen_node *node)
322 {
323 	return display->parent->stolen->node_address(node);
324 }
325 
326 u64 intel_parent_stolen_node_size(struct intel_display *display, const struct intel_stolen_node *node)
327 {
328 	return display->parent->stolen->node_size(node);
329 }
330 
331 struct intel_stolen_node *intel_parent_stolen_node_alloc(struct intel_display *display)
332 {
333 	return display->parent->stolen->node_alloc(display->drm);
334 }
335 
336 void intel_parent_stolen_node_free(struct intel_display *display, const struct intel_stolen_node *node)
337 {
338 	display->parent->stolen->node_free(node);
339 }
340 
341 /* vma */
342 int intel_parent_vma_fence_id(struct intel_display *display, const struct i915_vma *vma)
343 {
344 	if (!display->parent->vma)
345 		return -1;
346 
347 	return display->parent->vma->fence_id(vma);
348 }
349 
350 /* generic */
351 void intel_parent_fence_priority_display(struct intel_display *display, struct dma_fence *fence)
352 {
353 	if (display->parent->fence_priority_display)
354 		display->parent->fence_priority_display(fence);
355 }
356 
357 bool intel_parent_has_auxccs(struct intel_display *display)
358 {
359 	return display->parent->has_auxccs && display->parent->has_auxccs(display->drm);
360 }
361 
362 bool intel_parent_has_fenced_regions(struct intel_display *display)
363 {
364 	return display->parent->has_fenced_regions && display->parent->has_fenced_regions(display->drm);
365 }
366 
367 bool intel_parent_vgpu_active(struct intel_display *display)
368 {
369 	return display->parent->vgpu_active && display->parent->vgpu_active(display->drm);
370 }
371