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