xref: /linux/include/drm/intel/display_parent_interface.h (revision 13c072b8e91a5ccb5855ca1ba6fe3ea467dbf94d)
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 struct dma_fence;
10 struct drm_crtc;
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 i915_vma;
19 struct intel_dpt;
20 struct intel_dsb_buffer;
21 struct intel_frontbuffer;
22 struct intel_hdcp_gsc_context;
23 struct intel_initial_plane_config;
24 struct intel_panic;
25 struct intel_stolen_node;
26 struct ref_tracker;
27 struct seq_file;
28 struct vm_area_struct;
29 
30 /* Keep struct definitions sorted */
31 
32 struct intel_display_bo_interface {
33 	bool (*is_tiled)(struct drm_gem_object *obj); /* Optional */
34 	bool (*is_userptr)(struct drm_gem_object *obj); /* Optional */
35 	bool (*is_shmem)(struct drm_gem_object *obj); /* Optional */
36 	bool (*is_protected)(struct drm_gem_object *obj);
37 	int (*key_check)(struct drm_gem_object *obj);
38 	int (*fb_mmap)(struct drm_gem_object *obj, struct vm_area_struct *vma);
39 	int (*read_from_page)(struct drm_gem_object *obj, u64 offset, void *dst, int size);
40 	void (*describe)(struct seq_file *m, struct drm_gem_object *obj); /* Optional */
41 	int (*framebuffer_init)(struct drm_gem_object *obj, struct drm_mode_fb_cmd2 *mode_cmd);
42 	void (*framebuffer_fini)(struct drm_gem_object *obj);
43 	struct drm_gem_object *(*framebuffer_lookup)(struct drm_device *drm,
44 						     struct drm_file *filp,
45 						     const struct drm_mode_fb_cmd2 *user_mode_cmd);
46 };
47 
48 struct intel_display_dpt_interface {
49 	struct intel_dpt *(*create)(struct drm_gem_object *obj, size_t size);
50 	void (*destroy)(struct intel_dpt *dpt);
51 	void (*suspend)(struct intel_dpt *dpt);
52 	void (*resume)(struct intel_dpt *dpt);
53 };
54 
55 struct intel_display_dsb_interface {
56 	u32 (*ggtt_offset)(struct intel_dsb_buffer *dsb_buf);
57 	void (*write)(struct intel_dsb_buffer *dsb_buf, u32 idx, u32 val);
58 	u32 (*read)(struct intel_dsb_buffer *dsb_buf, u32 idx);
59 	void (*fill)(struct intel_dsb_buffer *dsb_buf, u32 idx, u32 val, size_t size);
60 	struct intel_dsb_buffer *(*create)(struct drm_device *drm, size_t size);
61 	void (*cleanup)(struct intel_dsb_buffer *dsb_buf);
62 	void (*flush_map)(struct intel_dsb_buffer *dsb_buf);
63 };
64 
65 struct intel_display_frontbuffer_interface {
66 	struct intel_frontbuffer *(*get)(struct drm_gem_object *obj);
67 	void (*ref)(struct intel_frontbuffer *front);
68 	void (*put)(struct intel_frontbuffer *front);
69 	void (*flush_for_display)(struct intel_frontbuffer *front);
70 };
71 
72 struct intel_display_hdcp_interface {
73 	ssize_t (*gsc_msg_send)(struct intel_hdcp_gsc_context *gsc_context,
74 				void *msg_in, size_t msg_in_len,
75 				void *msg_out, size_t msg_out_len);
76 	bool (*gsc_check_status)(struct drm_device *drm);
77 	struct intel_hdcp_gsc_context *(*gsc_context_alloc)(struct drm_device *drm);
78 	void (*gsc_context_free)(struct intel_hdcp_gsc_context *gsc_context);
79 };
80 
81 struct intel_display_initial_plane_interface {
82 	void (*vblank_wait)(struct drm_crtc *crtc);
83 	struct drm_gem_object *(*alloc_obj)(struct drm_device *drm, struct intel_initial_plane_config *plane_config);
84 	int (*setup)(struct drm_plane_state *plane_state, struct intel_initial_plane_config *plane_config,
85 		     struct drm_framebuffer *fb, struct i915_vma *vma);
86 	void (*config_fini)(struct intel_initial_plane_config *plane_configs);
87 };
88 
89 struct intel_display_irq_interface {
90 	bool (*enabled)(struct drm_device *drm);
91 	void (*synchronize)(struct drm_device *drm);
92 };
93 
94 struct intel_display_overlay_interface {
95 	bool (*is_active)(struct drm_device *drm);
96 
97 	int (*overlay_on)(struct drm_device *drm,
98 			  u32 frontbuffer_bits);
99 	int (*overlay_continue)(struct drm_device *drm,
100 				struct i915_vma *vma,
101 				bool load_polyphase_filter);
102 	int (*overlay_off)(struct drm_device *drm);
103 	int (*recover_from_interrupt)(struct drm_device *drm);
104 	int (*release_old_vid)(struct drm_device *drm);
105 
106 	void (*reset)(struct drm_device *drm);
107 
108 	struct i915_vma *(*pin_fb)(struct drm_device *drm,
109 				   struct drm_gem_object *obj,
110 				   u32 *offset);
111 	void (*unpin_fb)(struct drm_device *drm,
112 			 struct i915_vma *vma);
113 
114 	struct drm_gem_object *(*obj_lookup)(struct drm_device *drm,
115 					     struct drm_file *filp,
116 					     u32 handle);
117 
118 	void __iomem *(*setup)(struct drm_device *drm,
119 			       bool needs_physical);
120 	void (*cleanup)(struct drm_device *drm);
121 };
122 
123 struct intel_display_panic_interface {
124 	struct intel_panic *(*alloc)(void);
125 	int (*setup)(struct intel_panic *panic, struct drm_scanout_buffer *sb);
126 	void (*finish)(struct intel_panic *panic);
127 };
128 
129 struct intel_display_pc8_interface {
130 	void (*block)(struct drm_device *drm);
131 	void (*unblock)(struct drm_device *drm);
132 };
133 
134 struct intel_display_pcode_interface {
135 	int (*read)(struct drm_device *drm, u32 mbox, u32 *val, u32 *val1);
136 	int (*write)(struct drm_device *drm, u32 mbox, u32 val, int timeout_ms);
137 	int (*request)(struct drm_device *drm, u32 mbox, u32 request,
138 		       u32 reply_mask, u32 reply, int timeout_base_ms);
139 };
140 
141 struct intel_display_rpm_interface {
142 	struct ref_tracker *(*get)(const struct drm_device *drm);
143 	struct ref_tracker *(*get_raw)(const struct drm_device *drm);
144 	struct ref_tracker *(*get_if_in_use)(const struct drm_device *drm);
145 	struct ref_tracker *(*get_noresume)(const struct drm_device *drm);
146 
147 	void (*put)(const struct drm_device *drm, struct ref_tracker *wakeref);
148 	void (*put_raw)(const struct drm_device *drm, struct ref_tracker *wakeref);
149 	void (*put_unchecked)(const struct drm_device *drm);
150 
151 	bool (*suspended)(const struct drm_device *drm);
152 	void (*assert_held)(const struct drm_device *drm);
153 	void (*assert_block)(const struct drm_device *drm);
154 	void (*assert_unblock)(const struct drm_device *drm);
155 };
156 
157 struct intel_display_rps_interface {
158 	void (*boost_if_not_started)(struct dma_fence *fence);
159 	void (*mark_interactive)(struct drm_device *drm, bool interactive);
160 	void (*ilk_irq_handler)(struct drm_device *drm);
161 };
162 
163 struct intel_display_stolen_interface {
164 	int (*insert_node_in_range)(struct intel_stolen_node *node, u64 size,
165 				    unsigned int align, u64 start, u64 end);
166 	int (*insert_node)(struct intel_stolen_node *node, u64 size, unsigned int align); /* Optional */
167 	void (*remove_node)(struct intel_stolen_node *node);
168 	bool (*initialized)(struct drm_device *drm);
169 	bool (*node_allocated)(const struct intel_stolen_node *node);
170 	u64 (*node_offset)(const struct intel_stolen_node *node);
171 	u64 (*area_address)(struct drm_device *drm); /* Optional */
172 	u64 (*area_size)(struct drm_device *drm); /* Optional */
173 	u64 (*node_address)(const struct intel_stolen_node *node);
174 	u64 (*node_size)(const struct intel_stolen_node *node);
175 	struct intel_stolen_node *(*node_alloc)(struct drm_device *drm);
176 	void (*node_free)(const struct intel_stolen_node *node);
177 };
178 
179 struct intel_display_vma_interface {
180 	int (*fence_id)(const struct i915_vma *vma);
181 };
182 
183 /**
184  * struct intel_display_parent_interface - services parent driver provides to display
185  *
186  * The parent, or core, driver provides a pointer to this structure to display
187  * driver when calling intel_display_device_probe(). The display driver uses it
188  * to access services provided by the parent driver. The structure may contain
189  * sub-struct pointers to group function pointers by functionality.
190  *
191  * All function and sub-struct pointers must be initialized and callable unless
192  * explicitly marked as "optional" below. The display driver will only NULL
193  * check the optional pointers.
194  */
195 struct intel_display_parent_interface {
196 	/** @bo: BO interface */
197 	const struct intel_display_bo_interface *bo;
198 
199 	/** @dpt: DPT interface. Optional. */
200 	const struct intel_display_dpt_interface *dpt;
201 
202 	/** @dsb: DSB buffer interface */
203 	const struct intel_display_dsb_interface *dsb;
204 
205 	/** @frontbuffer: Frontbuffer interface */
206 	const struct intel_display_frontbuffer_interface *frontbuffer;
207 
208 	/** @hdcp: HDCP GSC interface */
209 	const struct intel_display_hdcp_interface *hdcp;
210 
211 	/** @initial_plane: Initial plane interface */
212 	const struct intel_display_initial_plane_interface *initial_plane;
213 
214 	/** @irq: IRQ interface */
215 	const struct intel_display_irq_interface *irq;
216 
217 	/** @panic: Panic interface */
218 	const struct intel_display_panic_interface *panic;
219 
220 	/** @overlay: Overlay. Optional. */
221 	const struct intel_display_overlay_interface *overlay;
222 
223 	/** @pc8: PC8 interface. Optional. */
224 	const struct intel_display_pc8_interface *pc8;
225 
226 	/** @pcode: Pcode interface */
227 	const struct intel_display_pcode_interface *pcode;
228 
229 	/** @rpm: Runtime PM functions */
230 	const struct intel_display_rpm_interface *rpm;
231 
232 	/** @rps: RPS interface. Optional. */
233 	const struct intel_display_rps_interface *rps;
234 
235 	/** @stolen: Stolen memory. */
236 	const struct intel_display_stolen_interface *stolen;
237 
238 	/** @vma: VMA interface. Optional. */
239 	const struct intel_display_vma_interface *vma;
240 
241 	/* Generic independent functions */
242 	struct {
243 		/** @fence_priority_display: Set display priority. Optional. */
244 		void (*fence_priority_display)(struct dma_fence *fence);
245 
246 		/** @has_auxccs: Are AuxCCS formats supported by the parent. Optional. */
247 		bool (*has_auxccs)(struct drm_device *drm);
248 
249 		/** @has_fenced_regions: Support legacy fencing? Optional. */
250 		bool (*has_fenced_regions)(struct drm_device *drm);
251 
252 		/** @vgpu_active: Is vGPU active? Optional. */
253 		bool (*vgpu_active)(struct drm_device *drm);
254 	};
255 };
256 
257 #endif
258