]> Git Repo - linux.git/blob - drivers/gpu/drm/i915/display/intel_display_core.h
net: wan: Add framer framework support
[linux.git] / drivers / gpu / drm / i915 / display / intel_display_core.h
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2022 Intel Corporation
4  */
5
6 #ifndef __INTEL_DISPLAY_CORE_H__
7 #define __INTEL_DISPLAY_CORE_H__
8
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>
15
16 #include <drm/drm_connector.h>
17 #include <drm/drm_modeset_lock.h>
18
19 #include "intel_cdclk.h"
20 #include "intel_display_device.h"
21 #include "intel_display_limits.h"
22 #include "intel_display_power.h"
23 #include "intel_dpll_mgr.h"
24 #include "intel_fbc.h"
25 #include "intel_global_state.h"
26 #include "intel_gmbus.h"
27 #include "intel_opregion.h"
28 #include "intel_wm_types.h"
29
30 struct drm_i915_private;
31 struct drm_property;
32 struct drm_property_blob;
33 struct i915_audio_component;
34 struct i915_hdcp_arbiter;
35 struct intel_atomic_state;
36 struct intel_audio_funcs;
37 struct intel_cdclk_funcs;
38 struct intel_cdclk_vals;
39 struct intel_color_funcs;
40 struct intel_crtc;
41 struct intel_crtc_state;
42 struct intel_dmc;
43 struct intel_dpll_funcs;
44 struct intel_dpll_mgr;
45 struct intel_fbdev;
46 struct intel_fdi_funcs;
47 struct intel_hotplug_funcs;
48 struct intel_initial_plane_config;
49 struct intel_overlay;
50
51 /* Amount of SAGV/QGV points, BSpec precisely defines this */
52 #define I915_NUM_QGV_POINTS 8
53
54 /* Amount of PSF GV points, BSpec precisely defines this */
55 #define I915_NUM_PSF_GV_POINTS 3
56
57 struct intel_display_funcs {
58         /*
59          * Returns the active state of the crtc, and if the crtc is active,
60          * fills out the pipe-config with the hw state.
61          */
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);
71 };
72
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);
89 };
90
91 struct intel_audio_state {
92         struct intel_encoder *encoder;
93         u8 eld[MAX_ELD_BYTES];
94 };
95
96 struct intel_audio {
97         /* hda/i915 audio component */
98         struct i915_audio_component *component;
99         bool component_registered;
100         /* mutex for audio/video sync */
101         struct mutex mutex;
102         int power_refcount;
103         u32 freq_cntrl;
104
105         /* current audio state for the audio component hooks */
106         struct intel_audio_state state[I915_MAX_TRANSCODERS];
107
108         /* necessary resource sharing with HDMI LPE audio driver. */
109         struct {
110                 struct platform_device *platdev;
111                 int irq;
112         } lpe;
113 };
114
115 /*
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.
119  */
120 struct intel_dpll {
121         struct mutex lock;
122
123         int num_shared_dpll;
124         struct intel_shared_dpll shared_dplls[I915_NUM_PLLS];
125         const struct intel_dpll_mgr *mgr;
126
127         struct {
128                 int nssc;
129                 int ssc;
130         } ref_clks;
131
132         /*
133          * Bitmask of PLLs using the PCH SSC, indexed using enum intel_dpll_id.
134          */
135         u8 pch_ssc_use;
136 };
137
138 struct intel_frontbuffer_tracking {
139         spinlock_t lock;
140
141         /*
142          * Tracking bits for delayed frontbuffer flushing du to gpu activity or
143          * scheduled flips.
144          */
145         unsigned busy_bits;
146         unsigned flip_bits;
147 };
148
149 struct intel_hotplug {
150         struct delayed_work hotplug_work;
151
152         const u32 *hpd, *pch_hpd;
153
154         struct {
155                 unsigned long last_jiffies;
156                 int count;
157                 enum {
158                         HPD_ENABLED = 0,
159                         HPD_DISABLED = 1,
160                         HPD_MARK_DISABLED = 2
161                 } state;
162         } stats[HPD_NUM_PINS];
163         u32 event_bits;
164         u32 retry_bits;
165         struct delayed_work reenable_work;
166
167         u32 long_port_mask;
168         u32 short_port_mask;
169         struct work_struct dig_port_work;
170
171         struct work_struct poll_init_work;
172         bool poll_enabled;
173
174         unsigned int hpd_storm_threshold;
175         /* Whether or not to count short HPD IRQs in HPD storms */
176         u8 hpd_short_storm_enabled;
177
178         /* Last state reported by oob_hotplug_event for each encoder */
179         unsigned long oob_hotplug_last_state;
180
181         /*
182          * if we get a HPD irq from DP and a HPD irq from non-DP
183          * the non-DP HPD could block the workqueue on a mode config
184          * mutex getting, that userspace may have taken. However
185          * userspace is waiting on the DP workqueue to run which is
186          * blocked behind the non-DP one.
187          */
188         struct workqueue_struct *dp_wq;
189
190         /*
191          * Flag to track if long HPDs need not to be processed
192          *
193          * Some panels generate long HPDs while keep connected to the port.
194          * This can cause issues with CI tests results. In CI systems we
195          * don't expect to disconnect the panels and could ignore the long
196          * HPDs generated from the faulty panels. This flag can be used as
197          * cue to ignore the long HPDs and can be set / unset using debugfs.
198          */
199         bool ignore_long_hpd;
200 };
201
202 struct intel_vbt_data {
203         /* bdb version */
204         u16 version;
205
206         /* Feature bits */
207         unsigned int int_tv_support:1;
208         unsigned int int_crt_support:1;
209         unsigned int lvds_use_ssc:1;
210         unsigned int int_lvds_support:1;
211         unsigned int display_clock_mode:1;
212         unsigned int fdi_rx_polarity_inverted:1;
213         int lvds_ssc_freq;
214         enum drm_panel_orientation orientation;
215
216         bool override_afc_startup;
217         u8 override_afc_startup_val;
218
219         int crt_ddc_pin;
220
221         struct list_head display_devices;
222         struct list_head bdb_blocks;
223
224         struct sdvo_device_mapping {
225                 u8 initialized;
226                 u8 dvo_port;
227                 u8 slave_addr;
228                 u8 dvo_wiring;
229                 u8 i2c_pin;
230                 u8 ddc_pin;
231         } sdvo_mappings[2];
232 };
233
234 struct intel_wm {
235         /*
236          * Raw watermark latency values:
237          * in 0.1us units for WM0,
238          * in 0.5us units for WM1+.
239          */
240         /* primary */
241         u16 pri_latency[5];
242         /* sprite */
243         u16 spr_latency[5];
244         /* cursor */
245         u16 cur_latency[5];
246         /*
247          * Raw watermark memory latency values
248          * for SKL for all 8 levels
249          * in 1us units.
250          */
251         u16 skl_latency[8];
252
253         /* current hardware state */
254         union {
255                 struct ilk_wm_values hw;
256                 struct vlv_wm_values vlv;
257                 struct g4x_wm_values g4x;
258         };
259
260         u8 num_levels;
261
262         /*
263          * Should be held around atomic WM register writing; also
264          * protects * intel_crtc->wm.active and
265          * crtc_state->wm.need_postvbl_update.
266          */
267         struct mutex wm_mutex;
268
269         bool ipc_enabled;
270 };
271
272 struct intel_display {
273         /* Display functions */
274         struct {
275                 /* Top level crtc-ish functions */
276                 const struct intel_display_funcs *display;
277
278                 /* Display CDCLK functions */
279                 const struct intel_cdclk_funcs *cdclk;
280
281                 /* Display pll funcs */
282                 const struct intel_dpll_funcs *dpll;
283
284                 /* irq display functions */
285                 const struct intel_hotplug_funcs *hotplug;
286
287                 /* pm display functions */
288                 const struct intel_wm_funcs *wm;
289
290                 /* fdi display functions */
291                 const struct intel_fdi_funcs *fdi;
292
293                 /* Display internal color functions */
294                 const struct intel_color_funcs *color;
295
296                 /* Display internal audio functions */
297                 const struct intel_audio_funcs *audio;
298         } funcs;
299
300         /* Grouping using anonymous structs. Keep sorted. */
301         struct intel_atomic_helper {
302                 struct llist_head free_list;
303                 struct work_struct free_work;
304         } atomic_helper;
305
306         struct {
307                 /* backlight registers and fields in struct intel_panel */
308                 struct mutex lock;
309         } backlight;
310
311         struct {
312                 struct intel_global_obj obj;
313
314                 struct intel_bw_info {
315                         /* for each QGV point */
316                         unsigned int deratedbw[I915_NUM_QGV_POINTS];
317                         /* for each PSF GV point */
318                         unsigned int psf_bw[I915_NUM_PSF_GV_POINTS];
319                         /* Peak BW for each QGV point */
320                         unsigned int peakbw[I915_NUM_QGV_POINTS];
321                         u8 num_qgv_points;
322                         u8 num_psf_gv_points;
323                         u8 num_planes;
324                 } max[6];
325         } bw;
326
327         struct {
328                 /* The current hardware cdclk configuration */
329                 struct intel_cdclk_config hw;
330
331                 /* cdclk, divider, and ratio table from bspec */
332                 const struct intel_cdclk_vals *table;
333
334                 struct intel_global_obj obj;
335
336                 unsigned int max_cdclk_freq;
337         } cdclk;
338
339         struct {
340                 struct drm_property_blob *glk_linear_degamma_lut;
341         } color;
342
343         struct {
344                 /* The current hardware dbuf configuration */
345                 u8 enabled_slices;
346
347                 struct intel_global_obj obj;
348         } dbuf;
349
350         struct {
351                 wait_queue_head_t waitqueue;
352
353                 /* mutex to protect pmdemand programming sequence */
354                 struct mutex lock;
355
356                 struct intel_global_obj obj;
357         } pmdemand;
358
359         struct {
360                 /*
361                  * dkl.phy_lock protects against concurrent access of the
362                  * Dekel TypeC PHYs.
363                  */
364                 spinlock_t phy_lock;
365         } dkl;
366
367         struct {
368                 struct intel_dmc *dmc;
369                 intel_wakeref_t wakeref;
370         } dmc;
371
372         struct {
373                 /* VLV/CHV/BXT/GLK DSI MMIO register base address */
374                 u32 mmio_base;
375         } dsi;
376
377         struct {
378                 /* list of fbdev register on this device */
379                 struct intel_fbdev *fbdev;
380                 struct work_struct suspend_work;
381         } fbdev;
382
383         struct {
384                 unsigned int pll_freq;
385                 u32 rx_config;
386         } fdi;
387
388         struct {
389                 struct list_head obj_list;
390         } global;
391
392         struct {
393                 /*
394                  * Base address of where the gmbus and gpio blocks are located
395                  * (either on PCH or on SoC for platforms without PCH).
396                  */
397                 u32 mmio_base;
398
399                 /*
400                  * gmbus.mutex protects against concurrent usage of the single
401                  * hw gmbus controller on different i2c buses.
402                  */
403                 struct mutex mutex;
404
405                 struct intel_gmbus *bus[GMBUS_NUM_PINS];
406
407                 wait_queue_head_t wait_queue;
408         } gmbus;
409
410         struct {
411                 struct i915_hdcp_arbiter *arbiter;
412                 bool comp_added;
413
414                 /*
415                  * HDCP message struct for allocation of memory which can be
416                  * reused when sending message to gsc cs.
417                  * this is only populated post Meteorlake
418                  */
419                 struct intel_hdcp_gsc_message *hdcp_message;
420                 /* Mutex to protect the above hdcp related values. */
421                 struct mutex hdcp_mutex;
422         } hdcp;
423
424         struct {
425                 /*
426                  * HTI (aka HDPORT) state read during initial hw readout. Most
427                  * platforms don't have HTI, so this will just stay 0. Those
428                  * that do will use this later to figure out which PLLs and PHYs
429                  * are unavailable for driver usage.
430                  */
431                 u32 state;
432         } hti;
433
434         struct {
435                 /* Access with DISPLAY_INFO() */
436                 const struct intel_display_device_info *__device_info;
437
438                 /* Access with DISPLAY_RUNTIME_INFO() */
439                 struct intel_display_runtime_info __runtime_info;
440         } info;
441
442         struct {
443                 bool false_color;
444         } ips;
445
446         struct {
447                 struct i915_power_domains domains;
448
449                 /* Shadow for DISPLAY_PHY_CONTROL which can't be safely read */
450                 u32 chv_phy_control;
451
452                 /* perform PHY state sanity checks? */
453                 bool chv_phy_assert[2];
454         } power;
455
456         struct {
457                 u32 mmio_base;
458
459                 /* protects panel power sequencer state */
460                 struct mutex mutex;
461         } pps;
462
463         struct {
464                 struct drm_property *broadcast_rgb;
465                 struct drm_property *force_audio;
466         } properties;
467
468         struct {
469                 unsigned long mask;
470         } quirks;
471
472         struct {
473                 /* restore state for suspend/resume and display reset */
474                 struct drm_atomic_state *modeset_state;
475                 struct drm_modeset_acquire_ctx reset_ctx;
476         } restore;
477
478         struct {
479                 enum {
480                         I915_SAGV_UNKNOWN = 0,
481                         I915_SAGV_DISABLED,
482                         I915_SAGV_ENABLED,
483                         I915_SAGV_NOT_CONTROLLED
484                 } status;
485
486                 u32 block_time_us;
487         } sagv;
488
489         struct {
490                 /*
491                  * DG2: Mask of PHYs that were not calibrated by the firmware
492                  * and should not be used.
493                  */
494                 u8 phy_failed_calibration;
495         } snps;
496
497         struct {
498                 /*
499                  * Shadows for CHV DPLL_MD regs to keep the state
500                  * checker somewhat working in the presence hardware
501                  * crappiness (can't read out DPLL_MD for pipes B & C).
502                  */
503                 u32 chv_dpll_md[I915_MAX_PIPES];
504                 u32 bxt_phy_grc;
505         } state;
506
507         struct {
508                 /* ordered wq for modesets */
509                 struct workqueue_struct *modeset;
510
511                 /* unbound hipri wq for page flips/plane updates */
512                 struct workqueue_struct *flip;
513         } wq;
514
515         /* Grouping using named structs. Keep sorted. */
516         struct intel_audio audio;
517         struct intel_dpll dpll;
518         struct intel_fbc *fbc[I915_MAX_FBCS];
519         struct intel_frontbuffer_tracking fb_tracking;
520         struct intel_hotplug hotplug;
521         struct intel_opregion opregion;
522         struct intel_overlay *overlay;
523         struct intel_vbt_data vbt;
524         struct intel_wm wm;
525 };
526
527 #endif /* __INTEL_DISPLAY_CORE_H__ */
This page took 0.065653 seconds and 4 git commands to generate.