1 /* SPDX-License-Identifier: MIT */
3 * Copyright © 2022 Intel Corporation
6 #ifndef __INTEL_DISPLAY_CORE_H__
7 #define __INTEL_DISPLAY_CORE_H__
9 #include <linux/list.h>
10 #include <linux/llist.h>
11 #include <linux/mutex.h>
12 #include <linux/types.h>
13 #include <linux/wait.h>
14 #include <linux/workqueue.h>
16 #include <drm/drm_connector.h>
17 #include <drm/drm_modeset_lock.h>
19 #include "intel_cdclk.h"
20 #include "intel_display_device.h"
21 #include "intel_display_limits.h"
22 #include "intel_display_params.h"
23 #include "intel_display_power.h"
24 #include "intel_dpll_mgr.h"
25 #include "intel_fbc.h"
26 #include "intel_global_state.h"
27 #include "intel_gmbus.h"
28 #include "intel_opregion.h"
29 #include "intel_dmc_wl.h"
30 #include "intel_wm_types.h"
34 struct drm_i915_private;
36 struct drm_property_blob;
37 struct i915_audio_component;
38 struct i915_hdcp_arbiter;
39 struct intel_atomic_state;
40 struct intel_audio_funcs;
41 struct intel_cdclk_funcs;
42 struct intel_cdclk_vals;
43 struct intel_color_funcs;
45 struct intel_crtc_state;
47 struct intel_dpll_funcs;
48 struct intel_dpll_mgr;
50 struct intel_fdi_funcs;
51 struct intel_hotplug_funcs;
52 struct intel_initial_plane_config;
53 struct intel_opregion;
56 /* Amount of SAGV/QGV points, BSpec precisely defines this */
57 #define I915_NUM_QGV_POINTS 8
59 /* Amount of PSF GV points, BSpec precisely defines this */
60 #define I915_NUM_PSF_GV_POINTS 3
62 struct intel_display_funcs {
64 * Returns the active state of the crtc, and if the crtc is active,
65 * fills out the pipe-config with the hw state.
67 bool (*get_pipe_config)(struct intel_crtc *,
68 struct intel_crtc_state *);
69 void (*get_initial_plane_config)(struct intel_crtc *,
70 struct intel_initial_plane_config *);
71 bool (*fixup_initial_plane_config)(struct intel_crtc *crtc,
72 const struct intel_initial_plane_config *plane_config);
73 void (*crtc_enable)(struct intel_atomic_state *state,
74 struct intel_crtc *crtc);
75 void (*crtc_disable)(struct intel_atomic_state *state,
76 struct intel_crtc *crtc);
77 void (*commit_modeset_enables)(struct intel_atomic_state *state);
80 /* functions used for watermark calcs for display. */
81 struct intel_wm_funcs {
82 /* update_wm is for legacy wm management */
83 void (*update_wm)(struct drm_i915_private *dev_priv);
84 int (*compute_watermarks)(struct intel_atomic_state *state,
85 struct intel_crtc *crtc);
86 void (*initial_watermarks)(struct intel_atomic_state *state,
87 struct intel_crtc *crtc);
88 void (*atomic_update_watermarks)(struct intel_atomic_state *state,
89 struct intel_crtc *crtc);
90 void (*optimize_watermarks)(struct intel_atomic_state *state,
91 struct intel_crtc *crtc);
92 int (*compute_global_watermarks)(struct intel_atomic_state *state);
93 void (*get_hw_state)(struct drm_i915_private *i915);
96 struct intel_audio_state {
97 struct intel_encoder *encoder;
98 u8 eld[MAX_ELD_BYTES];
102 /* hda/i915 audio component */
103 struct i915_audio_component *component;
104 bool component_registered;
105 /* mutex for audio/video sync */
110 /* current audio state for the audio component hooks */
111 struct intel_audio_state state[I915_MAX_TRANSCODERS];
113 /* necessary resource sharing with HDMI LPE audio driver. */
115 struct platform_device *platdev;
121 * dpll and cdclk state is protected by connection_mutex dpll.lock serializes
122 * intel_{prepare,enable,disable}_shared_dpll. Must be global rather than per
123 * dpll, because on some platforms plls share registers.
129 struct intel_shared_dpll shared_dplls[I915_NUM_PLLS];
130 const struct intel_dpll_mgr *mgr;
138 * Bitmask of PLLs using the PCH SSC, indexed using enum intel_dpll_id.
143 struct intel_frontbuffer_tracking {
147 * Tracking bits for delayed frontbuffer flushing du to gpu activity or
154 struct intel_hotplug {
155 struct delayed_work hotplug_work;
157 const u32 *hpd, *pch_hpd;
160 unsigned long last_jiffies;
165 HPD_MARK_DISABLED = 2
167 } stats[HPD_NUM_PINS];
170 struct delayed_work reenable_work;
174 struct work_struct dig_port_work;
176 struct work_struct poll_init_work;
180 * Queuing of hotplug_work, reenable_work and poll_init_work is
181 * enabled. Protected by drm_i915_private::irq_lock.
183 bool detection_work_enabled;
185 unsigned int hpd_storm_threshold;
186 /* Whether or not to count short HPD IRQs in HPD storms */
187 u8 hpd_short_storm_enabled;
189 /* Last state reported by oob_hotplug_event for each encoder */
190 unsigned long oob_hotplug_last_state;
193 * if we get a HPD irq from DP and a HPD irq from non-DP
194 * the non-DP HPD could block the workqueue on a mode config
195 * mutex getting, that userspace may have taken. However
196 * userspace is waiting on the DP workqueue to run which is
197 * blocked behind the non-DP one.
199 struct workqueue_struct *dp_wq;
202 * Flag to track if long HPDs need not to be processed
204 * Some panels generate long HPDs while keep connected to the port.
205 * This can cause issues with CI tests results. In CI systems we
206 * don't expect to disconnect the panels and could ignore the long
207 * HPDs generated from the faulty panels. This flag can be used as
208 * cue to ignore the long HPDs and can be set / unset using debugfs.
210 bool ignore_long_hpd;
213 struct intel_vbt_data {
218 unsigned int int_tv_support:1;
219 unsigned int int_crt_support:1;
220 unsigned int lvds_use_ssc:1;
221 unsigned int int_lvds_support:1;
222 unsigned int display_clock_mode:1;
223 unsigned int fdi_rx_polarity_inverted:1;
225 enum drm_panel_orientation orientation;
227 bool override_afc_startup;
228 u8 override_afc_startup_val;
232 struct list_head display_devices;
233 struct list_head bdb_blocks;
235 struct sdvo_device_mapping {
247 * Raw watermark latency values:
248 * in 0.1us units for WM0,
249 * in 0.5us units for WM1+.
258 * Raw watermark memory latency values
259 * for SKL for all 8 levels
264 /* current hardware state */
266 struct ilk_wm_values hw;
267 struct vlv_wm_values vlv;
268 struct g4x_wm_values g4x;
274 * Should be held around atomic WM register writing; also
275 * protects * intel_crtc->wm.active and
276 * crtc_state->wm.need_postvbl_update.
278 struct mutex wm_mutex;
283 struct intel_display {
284 /* drm device backpointer */
285 struct drm_device *drm;
287 /* Platform (and subplatform, if any) identification */
288 struct intel_display_platforms platform;
290 /* Display functions */
292 /* Top level crtc-ish functions */
293 const struct intel_display_funcs *display;
295 /* Display CDCLK functions */
296 const struct intel_cdclk_funcs *cdclk;
298 /* Display pll funcs */
299 const struct intel_dpll_funcs *dpll;
301 /* irq display functions */
302 const struct intel_hotplug_funcs *hotplug;
304 /* pm display functions */
305 const struct intel_wm_funcs *wm;
307 /* fdi display functions */
308 const struct intel_fdi_funcs *fdi;
310 /* Display internal color functions */
311 const struct intel_color_funcs *color;
313 /* Display internal audio functions */
314 const struct intel_audio_funcs *audio;
318 bool any_task_allowed;
319 struct task_struct *allowed_task;
323 /* backlight registers and fields in struct intel_panel */
328 struct intel_global_obj obj;
330 struct intel_bw_info {
331 /* for each QGV point */
332 unsigned int deratedbw[I915_NUM_QGV_POINTS];
333 /* for each PSF GV point */
334 unsigned int psf_bw[I915_NUM_PSF_GV_POINTS];
335 /* Peak BW for each QGV point */
336 unsigned int peakbw[I915_NUM_QGV_POINTS];
338 u8 num_psf_gv_points;
344 /* The current hardware cdclk configuration */
345 struct intel_cdclk_config hw;
347 /* cdclk, divider, and ratio table from bspec */
348 const struct intel_cdclk_vals *table;
350 struct intel_global_obj obj;
352 unsigned int max_cdclk_freq;
353 unsigned int max_dotclk_freq;
354 unsigned int skl_preferred_vco_freq;
358 struct drm_property_blob *glk_linear_degamma_lut;
362 /* The current hardware dbuf configuration */
365 struct intel_global_obj obj;
370 * dkl.phy_lock protects against concurrent access of the
377 struct intel_dmc *dmc;
378 intel_wakeref_t wakeref;
382 /* VLV/CHV/BXT/GLK DSI MMIO register base address */
387 /* list of fbdev register on this device */
388 struct intel_fbdev *fbdev;
389 struct work_struct suspend_work;
393 unsigned int pll_freq;
398 struct list_head obj_list;
403 * Base address of where the gmbus and gpio blocks are located
404 * (either on PCH or on SoC for platforms without PCH).
409 * gmbus.mutex protects against concurrent usage of the single
410 * hw gmbus controller on different i2c buses.
414 struct intel_gmbus *bus[GMBUS_NUM_PINS];
416 wait_queue_head_t wait_queue;
420 struct i915_hdcp_arbiter *arbiter;
424 * HDCP message struct for allocation of memory which can be
425 * reused when sending message to gsc cs.
426 * this is only populated post Meteorlake
428 struct intel_hdcp_gsc_message *hdcp_message;
429 /* Mutex to protect the above hdcp related values. */
430 struct mutex hdcp_mutex;
435 * HTI (aka HDPORT) state read during initial hw readout. Most
436 * platforms don't have HTI, so this will just stay 0. Those
437 * that do will use this later to figure out which PLLs and PHYs
438 * are unavailable for driver usage.
444 /* Access with DISPLAY_INFO() */
445 const struct intel_display_device_info *__device_info;
447 /* Access with DISPLAY_RUNTIME_INFO() */
448 struct intel_display_runtime_info __runtime_info;
457 * Most platforms treat the display irq block as an always-on
458 * power domain. vlv/chv can disable it at runtime and need
459 * special care to avoid writing any of the display block
460 * registers outside of the power domain. We defer setting up
461 * the display irqs in this case to the runtime pm.
463 bool vlv_display_irqs_enabled;
465 /* For i915gm/i945gm vblank irq workaround */
468 int vblank_wa_num_pipes;
470 struct work_struct vblank_dc_work;
472 u32 de_irq_mask[I915_MAX_PIPES];
473 u32 pipestat_irq_mask[I915_MAX_PIPES];
477 wait_queue_head_t waitqueue;
479 /* mutex to protect pmdemand programming sequence */
482 struct intel_global_obj obj;
486 struct i915_power_domains domains;
488 /* Shadow for DISPLAY_PHY_CONTROL which can't be safely read */
491 /* perform PHY state sanity checks? */
492 bool chv_phy_assert[2];
498 /* protects panel power sequencer state */
503 struct drm_property *broadcast_rgb;
504 struct drm_property *force_audio;
512 /* restore state for suspend/resume and display reset */
513 struct drm_atomic_state *modeset_state;
514 struct drm_modeset_acquire_ctx reset_ctx;
524 I915_SAGV_UNKNOWN = 0,
527 I915_SAGV_NOT_CONTROLLED
535 * DG2: Mask of PHYs that were not calibrated by the firmware
536 * and should not be used.
538 u8 phy_failed_calibration;
543 * Shadows for CHV DPLL_MD regs to keep the state
544 * checker somewhat working in the presence hardware
545 * crappiness (can't read out DPLL_MD for pipes B & C).
547 u32 chv_dpll_md[I915_MAX_PIPES];
552 /* ordered wq for modesets */
553 struct workqueue_struct *modeset;
555 /* unbound hipri wq for page flips/plane updates */
556 struct workqueue_struct *flip;
558 /* hipri wq for commit cleanups */
559 struct workqueue_struct *cleanup;
562 /* Grouping using named structs. Keep sorted. */
563 struct drm_dp_tunnel_mgr *dp_tunnel_mgr;
564 struct intel_audio audio;
565 struct intel_dpll dpll;
566 struct intel_fbc *fbc[I915_MAX_FBCS];
567 struct intel_frontbuffer_tracking fb_tracking;
568 struct intel_hotplug hotplug;
569 struct intel_opregion *opregion;
570 struct intel_overlay *overlay;
571 struct intel_display_params params;
572 struct intel_vbt_data vbt;
573 struct intel_dmc_wl wl;
577 #endif /* __INTEL_DISPLAY_CORE_H__ */