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/mutex.h>
10 #include <linux/types.h>
11 #include <linux/wait.h>
12 #include <linux/workqueue.h>
14 #include "intel_cdclk.h"
15 #include "intel_display.h"
16 #include "intel_dmc.h"
17 #include "intel_dpll_mgr.h"
18 #include "intel_global_state.h"
19 #include "intel_gmbus.h"
20 #include "intel_opregion.h"
21 #include "intel_pm_types.h"
23 struct drm_i915_private;
24 struct i915_audio_component;
25 struct i915_hdcp_comp_master;
26 struct intel_atomic_state;
27 struct intel_audio_funcs;
28 struct intel_cdclk_funcs;
29 struct intel_cdclk_vals;
30 struct intel_color_funcs;
32 struct intel_crtc_state;
33 struct intel_dpll_funcs;
34 struct intel_dpll_mgr;
36 struct intel_fdi_funcs;
37 struct intel_hotplug_funcs;
38 struct intel_initial_plane_config;
41 /* Amount of SAGV/QGV points, BSpec precisely defines this */
42 #define I915_NUM_QGV_POINTS 8
44 /* Amount of PSF GV points, BSpec precisely defines this */
45 #define I915_NUM_PSF_GV_POINTS 3
47 struct intel_display_funcs {
49 * Returns the active state of the crtc, and if the crtc is active,
50 * fills out the pipe-config with the hw state.
52 bool (*get_pipe_config)(struct intel_crtc *,
53 struct intel_crtc_state *);
54 void (*get_initial_plane_config)(struct intel_crtc *,
55 struct intel_initial_plane_config *);
56 void (*crtc_enable)(struct intel_atomic_state *state,
57 struct intel_crtc *crtc);
58 void (*crtc_disable)(struct intel_atomic_state *state,
59 struct intel_crtc *crtc);
60 void (*commit_modeset_enables)(struct intel_atomic_state *state);
63 /* functions used for watermark calcs for display. */
64 struct intel_wm_funcs {
65 /* update_wm is for legacy wm management */
66 void (*update_wm)(struct drm_i915_private *dev_priv);
67 int (*compute_pipe_wm)(struct intel_atomic_state *state,
68 struct intel_crtc *crtc);
69 int (*compute_intermediate_wm)(struct intel_atomic_state *state,
70 struct intel_crtc *crtc);
71 void (*initial_watermarks)(struct intel_atomic_state *state,
72 struct intel_crtc *crtc);
73 void (*atomic_update_watermarks)(struct intel_atomic_state *state,
74 struct intel_crtc *crtc);
75 void (*optimize_watermarks)(struct intel_atomic_state *state,
76 struct intel_crtc *crtc);
77 int (*compute_global_watermarks)(struct intel_atomic_state *state);
81 /* hda/i915 audio component */
82 struct i915_audio_component *component;
83 bool component_registered;
84 /* mutex for audio/video sync */
89 /* Used to save the pipe-to-encoder mapping for audio */
90 struct intel_encoder *encoder_map[I915_MAX_PIPES];
92 /* necessary resource sharing with HDMI LPE audio driver. */
94 struct platform_device *platdev;
100 * dpll and cdclk state is protected by connection_mutex dpll.lock serializes
101 * intel_{prepare,enable,disable}_shared_dpll. Must be global rather than per
102 * dpll, because on some platforms plls share registers.
108 struct intel_shared_dpll shared_dplls[I915_NUM_PLLS];
109 const struct intel_dpll_mgr *mgr;
117 struct intel_hotplug {
118 struct delayed_work hotplug_work;
120 const u32 *hpd, *pch_hpd;
123 unsigned long last_jiffies;
128 HPD_MARK_DISABLED = 2
130 } stats[HPD_NUM_PINS];
133 struct delayed_work reenable_work;
137 struct work_struct dig_port_work;
139 struct work_struct poll_init_work;
142 unsigned int hpd_storm_threshold;
143 /* Whether or not to count short HPD IRQs in HPD storms */
144 u8 hpd_short_storm_enabled;
147 * if we get a HPD irq from DP and a HPD irq from non-DP
148 * the non-DP HPD could block the workqueue on a mode config
149 * mutex getting, that userspace may have taken. However
150 * userspace is waiting on the DP workqueue to run which is
151 * blocked behind the non-DP one.
153 struct workqueue_struct *dp_wq;
158 * Raw watermark latency values:
159 * in 0.1us units for WM0,
160 * in 0.5us units for WM1+.
169 * Raw watermark memory latency values
170 * for SKL for all 8 levels
175 /* current hardware state */
177 struct ilk_wm_values hw;
178 struct vlv_wm_values vlv;
179 struct g4x_wm_values g4x;
185 * Should be held around atomic WM register writing; also
186 * protects * intel_crtc->wm.active and
187 * crtc_state->wm.need_postvbl_update.
189 struct mutex wm_mutex;
192 struct intel_display {
193 /* Display functions */
195 /* Top level crtc-ish functions */
196 const struct intel_display_funcs *display;
198 /* Display CDCLK functions */
199 const struct intel_cdclk_funcs *cdclk;
201 /* Display pll funcs */
202 const struct intel_dpll_funcs *dpll;
204 /* irq display functions */
205 const struct intel_hotplug_funcs *hotplug;
207 /* pm display functions */
208 const struct intel_wm_funcs *wm;
210 /* fdi display functions */
211 const struct intel_fdi_funcs *fdi;
213 /* Display internal color functions */
214 const struct intel_color_funcs *color;
216 /* Display internal audio functions */
217 const struct intel_audio_funcs *audio;
220 /* Grouping using anonymous structs. Keep sorted. */
222 /* backlight registers and fields in struct intel_panel */
227 struct intel_global_obj obj;
229 struct intel_bw_info {
230 /* for each QGV point */
231 unsigned int deratedbw[I915_NUM_QGV_POINTS];
232 /* for each PSF GV point */
233 unsigned int psf_bw[I915_NUM_PSF_GV_POINTS];
235 u8 num_psf_gv_points;
241 /* The current hardware cdclk configuration */
242 struct intel_cdclk_config hw;
244 /* cdclk, divider, and ratio table from bspec */
245 const struct intel_cdclk_vals *table;
247 struct intel_global_obj obj;
249 unsigned int max_cdclk_freq;
253 /* VLV/CHV/BXT/GLK DSI MMIO register base address */
258 /* list of fbdev register on this device */
259 struct intel_fbdev *fbdev;
260 struct work_struct suspend_work;
265 * Base address of where the gmbus and gpio blocks are located
266 * (either on PCH or on SoC for platforms without PCH).
271 * gmbus.mutex protects against concurrent usage of the single
272 * hw gmbus controller on different i2c buses.
276 struct intel_gmbus *bus[GMBUS_NUM_PINS];
278 wait_queue_head_t wait_queue;
282 struct i915_hdcp_comp_master *master;
285 /* Mutex to protect the above hdcp component related values. */
286 struct mutex comp_mutex;
292 /* protects panel power sequencer state */
298 I915_SAGV_UNKNOWN = 0,
301 I915_SAGV_NOT_CONTROLLED
307 /* Grouping using named structs. Keep sorted. */
308 struct intel_audio audio;
309 struct intel_dmc dmc;
310 struct intel_dpll dpll;
311 struct intel_hotplug hotplug;
312 struct intel_opregion opregion;
313 struct intel_overlay *overlay;
317 #endif /* __INTEL_DISPLAY_CORE_H__ */