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_limits.h"
21 #include "intel_display_power.h"
22 #include "intel_dpll_mgr.h"
23 #include "intel_fbc.h"
24 #include "intel_global_state.h"
25 #include "intel_gmbus.h"
26 #include "intel_opregion.h"
27 #include "intel_wm_types.h"
29 struct drm_i915_private;
31 struct drm_property_blob;
32 struct i915_audio_component;
33 struct i915_hdcp_arbiter;
34 struct intel_atomic_state;
35 struct intel_audio_funcs;
36 struct intel_bios_encoder_data;
37 struct intel_cdclk_funcs;
38 struct intel_cdclk_vals;
39 struct intel_color_funcs;
41 struct intel_crtc_state;
43 struct intel_dpll_funcs;
44 struct intel_dpll_mgr;
46 struct intel_fdi_funcs;
47 struct intel_hotplug_funcs;
48 struct intel_initial_plane_config;
51 /* Amount of SAGV/QGV points, BSpec precisely defines this */
52 #define I915_NUM_QGV_POINTS 8
54 /* Amount of PSF GV points, BSpec precisely defines this */
55 #define I915_NUM_PSF_GV_POINTS 3
57 struct intel_display_funcs {
59 * Returns the active state of the crtc, and if the crtc is active,
60 * fills out the pipe-config with the hw state.
62 bool (*get_pipe_config)(struct intel_crtc *,
63 struct intel_crtc_state *);
64 void (*get_initial_plane_config)(struct intel_crtc *,
65 struct intel_initial_plane_config *);
66 void (*crtc_enable)(struct intel_atomic_state *state,
67 struct intel_crtc *crtc);
68 void (*crtc_disable)(struct intel_atomic_state *state,
69 struct intel_crtc *crtc);
70 void (*commit_modeset_enables)(struct intel_atomic_state *state);
73 /* functions used for watermark calcs for display. */
74 struct intel_wm_funcs {
75 /* update_wm is for legacy wm management */
76 void (*update_wm)(struct drm_i915_private *dev_priv);
77 int (*compute_pipe_wm)(struct intel_atomic_state *state,
78 struct intel_crtc *crtc);
79 int (*compute_intermediate_wm)(struct intel_atomic_state *state,
80 struct intel_crtc *crtc);
81 void (*initial_watermarks)(struct intel_atomic_state *state,
82 struct intel_crtc *crtc);
83 void (*atomic_update_watermarks)(struct intel_atomic_state *state,
84 struct intel_crtc *crtc);
85 void (*optimize_watermarks)(struct intel_atomic_state *state,
86 struct intel_crtc *crtc);
87 int (*compute_global_watermarks)(struct intel_atomic_state *state);
88 void (*get_hw_state)(struct drm_i915_private *i915);
91 struct intel_audio_state {
92 struct intel_encoder *encoder;
93 u8 eld[MAX_ELD_BYTES];
97 /* hda/i915 audio component */
98 struct i915_audio_component *component;
99 bool component_registered;
100 /* mutex for audio/video sync */
105 /* current audio state for the audio component hooks */
106 struct intel_audio_state state[I915_MAX_TRANSCODERS];
108 /* necessary resource sharing with HDMI LPE audio driver. */
110 struct platform_device *platdev;
116 * dpll and cdclk state is protected by connection_mutex dpll.lock serializes
117 * intel_{prepare,enable,disable}_shared_dpll. Must be global rather than per
118 * dpll, because on some platforms plls share registers.
124 struct intel_shared_dpll shared_dplls[I915_NUM_PLLS];
125 const struct intel_dpll_mgr *mgr;
133 * Bitmask of PLLs using the PCH SSC, indexed using enum intel_dpll_id.
138 struct intel_frontbuffer_tracking {
142 * Tracking bits for delayed frontbuffer flushing du to gpu activity or
149 struct intel_hotplug {
150 struct delayed_work hotplug_work;
152 const u32 *hpd, *pch_hpd;
155 unsigned long last_jiffies;
160 HPD_MARK_DISABLED = 2
162 } stats[HPD_NUM_PINS];
165 struct delayed_work reenable_work;
169 struct work_struct dig_port_work;
171 struct work_struct poll_init_work;
174 unsigned int hpd_storm_threshold;
175 /* Whether or not to count short HPD IRQs in HPD storms */
176 u8 hpd_short_storm_enabled;
179 * if we get a HPD irq from DP and a HPD irq from non-DP
180 * the non-DP HPD could block the workqueue on a mode config
181 * mutex getting, that userspace may have taken. However
182 * userspace is waiting on the DP workqueue to run which is
183 * blocked behind the non-DP one.
185 struct workqueue_struct *dp_wq;
188 * Flag to track if long HPDs need not to be processed
190 * Some panels generate long HPDs while keep connected to the port.
191 * This can cause issues with CI tests results. In CI systems we
192 * don't expect to disconnect the panels and could ignore the long
193 * HPDs generated from the faulty panels. This flag can be used as
194 * cue to ignore the long HPDs and can be set / unset using debugfs.
196 bool ignore_long_hpd;
199 struct intel_vbt_data {
204 unsigned int int_tv_support:1;
205 unsigned int int_crt_support:1;
206 unsigned int lvds_use_ssc:1;
207 unsigned int int_lvds_support:1;
208 unsigned int display_clock_mode:1;
209 unsigned int fdi_rx_polarity_inverted:1;
211 enum drm_panel_orientation orientation;
213 bool override_afc_startup;
214 u8 override_afc_startup_val;
218 struct list_head display_devices;
219 struct list_head bdb_blocks;
221 struct intel_bios_encoder_data *ports[I915_MAX_PORTS]; /* Non-NULL if port present. */
222 struct sdvo_device_mapping {
234 * Raw watermark latency values:
235 * in 0.1us units for WM0,
236 * in 0.5us units for WM1+.
245 * Raw watermark memory latency values
246 * for SKL for all 8 levels
251 /* current hardware state */
253 struct ilk_wm_values hw;
254 struct vlv_wm_values vlv;
255 struct g4x_wm_values g4x;
261 * Should be held around atomic WM register writing; also
262 * protects * intel_crtc->wm.active and
263 * crtc_state->wm.need_postvbl_update.
265 struct mutex wm_mutex;
270 struct intel_display {
271 /* Display functions */
273 /* Top level crtc-ish functions */
274 const struct intel_display_funcs *display;
276 /* Display CDCLK functions */
277 const struct intel_cdclk_funcs *cdclk;
279 /* Display pll funcs */
280 const struct intel_dpll_funcs *dpll;
282 /* irq display functions */
283 const struct intel_hotplug_funcs *hotplug;
285 /* pm display functions */
286 const struct intel_wm_funcs *wm;
288 /* fdi display functions */
289 const struct intel_fdi_funcs *fdi;
291 /* Display internal color functions */
292 const struct intel_color_funcs *color;
294 /* Display internal audio functions */
295 const struct intel_audio_funcs *audio;
298 /* Grouping using anonymous structs. Keep sorted. */
299 struct intel_atomic_helper {
300 struct llist_head free_list;
301 struct work_struct free_work;
305 /* backlight registers and fields in struct intel_panel */
310 struct intel_global_obj obj;
312 struct intel_bw_info {
313 /* for each QGV point */
314 unsigned int deratedbw[I915_NUM_QGV_POINTS];
315 /* for each PSF GV point */
316 unsigned int psf_bw[I915_NUM_PSF_GV_POINTS];
318 u8 num_psf_gv_points;
324 /* The current hardware cdclk configuration */
325 struct intel_cdclk_config hw;
327 /* cdclk, divider, and ratio table from bspec */
328 const struct intel_cdclk_vals *table;
330 struct intel_global_obj obj;
332 unsigned int max_cdclk_freq;
336 struct drm_property_blob *glk_linear_degamma_lut;
340 /* The current hardware dbuf configuration */
343 struct intel_global_obj obj;
348 * dkl.phy_lock protects against concurrent access of the
355 struct intel_dmc *dmc;
356 intel_wakeref_t wakeref;
360 /* VLV/CHV/BXT/GLK DSI MMIO register base address */
365 /* list of fbdev register on this device */
366 struct intel_fbdev *fbdev;
367 struct work_struct suspend_work;
371 unsigned int pll_freq;
376 struct list_head obj_list;
381 * Base address of where the gmbus and gpio blocks are located
382 * (either on PCH or on SoC for platforms without PCH).
387 * gmbus.mutex protects against concurrent usage of the single
388 * hw gmbus controller on different i2c buses.
392 struct intel_gmbus *bus[GMBUS_NUM_PINS];
394 wait_queue_head_t wait_queue;
398 struct i915_hdcp_arbiter *arbiter;
402 * HDCP message struct for allocation of memory which can be
403 * reused when sending message to gsc cs.
404 * this is only populated post Meteorlake
406 struct intel_hdcp_gsc_message *hdcp_message;
407 /* Mutex to protect the above hdcp related values. */
408 struct mutex hdcp_mutex;
413 * HTI (aka HDPORT) state read during initial hw readout. Most
414 * platforms don't have HTI, so this will just stay 0. Those
415 * that do will use this later to figure out which PLLs and PHYs
416 * are unavailable for driver usage.
426 struct i915_power_domains domains;
428 /* Shadow for DISPLAY_PHY_CONTROL which can't be safely read */
431 /* perform PHY state sanity checks? */
432 bool chv_phy_assert[2];
438 /* protects panel power sequencer state */
443 struct drm_property *broadcast_rgb;
444 struct drm_property *force_audio;
452 /* restore state for suspend/resume and display reset */
453 struct drm_atomic_state *modeset_state;
454 struct drm_modeset_acquire_ctx reset_ctx;
459 I915_SAGV_UNKNOWN = 0,
462 I915_SAGV_NOT_CONTROLLED
470 * DG2: Mask of PHYs that were not calibrated by the firmware
471 * and should not be used.
473 u8 phy_failed_calibration;
478 * Shadows for CHV DPLL_MD regs to keep the state
479 * checker somewhat working in the presence hardware
480 * crappiness (can't read out DPLL_MD for pipes B & C).
482 u32 chv_dpll_md[I915_MAX_PIPES];
487 /* ordered wq for modesets */
488 struct workqueue_struct *modeset;
490 /* unbound hipri wq for page flips/plane updates */
491 struct workqueue_struct *flip;
494 /* Grouping using named structs. Keep sorted. */
495 struct intel_audio audio;
496 struct intel_dpll dpll;
497 struct intel_fbc *fbc[I915_MAX_FBCS];
498 struct intel_frontbuffer_tracking fb_tracking;
499 struct intel_hotplug hotplug;
500 struct intel_opregion opregion;
501 struct intel_overlay *overlay;
502 struct intel_vbt_data vbt;
506 #endif /* __INTEL_DISPLAY_CORE_H__ */