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