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