2 * Copyright (c) 2006 Dave Airlie <airlied@linux.ie>
3 * Copyright (c) 2007-2008 Intel Corporation
4 * Jesse Barnes <jesse.barnes@intel.com>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 #ifndef __INTEL_DISPLAY_TYPES_H__
27 #define __INTEL_DISPLAY_TYPES_H__
29 #include <linux/async.h>
30 #include <linux/i2c.h>
31 #include <linux/pwm.h>
32 #include <linux/sched/clock.h>
34 #include <drm/drm_atomic.h>
35 #include <drm/drm_crtc.h>
36 #include <drm/drm_dp_dual_mode_helper.h>
37 #include <drm/drm_dp_mst_helper.h>
38 #include <drm/drm_encoder.h>
39 #include <drm/drm_fb_helper.h>
40 #include <drm/drm_fourcc.h>
41 #include <drm/drm_probe_helper.h>
42 #include <drm/drm_rect.h>
43 #include <drm/drm_vblank.h>
44 #include <drm/i915_mei_hdcp_interface.h>
45 #include <media/cec-notifier.h>
50 struct __intel_global_objs_state;
51 struct intel_ddi_buf_trans;
54 * Display related stuff
57 /* these are outputs from the chip - integrated only
58 external chips are via DVO or SDVO output */
59 enum intel_output_type {
60 INTEL_OUTPUT_UNUSED = 0,
61 INTEL_OUTPUT_ANALOG = 1,
63 INTEL_OUTPUT_SDVO = 3,
64 INTEL_OUTPUT_LVDS = 4,
65 INTEL_OUTPUT_TVOUT = 5,
66 INTEL_OUTPUT_HDMI = 6,
70 INTEL_OUTPUT_DDI = 10,
71 INTEL_OUTPUT_DP_MST = 11,
74 enum hdmi_force_audio {
75 HDMI_AUDIO_OFF_DVI = -2, /* no aux data for HDMI-DVI converter */
76 HDMI_AUDIO_OFF, /* force turn off HDMI audio */
77 HDMI_AUDIO_AUTO, /* trust EDID */
78 HDMI_AUDIO_ON, /* force turn on HDMI audio */
81 /* "Broadcast RGB" property */
82 enum intel_broadcast_rgb {
83 INTEL_BROADCAST_RGB_AUTO,
84 INTEL_BROADCAST_RGB_FULL,
85 INTEL_BROADCAST_RGB_LIMITED,
88 struct intel_fb_view {
90 * The remap information used in the remapped and rotated views to
91 * create the DMA scatter-gather list for each FB color plane. This sg
92 * list is created along with the view type (gtt.type) specific
93 * i915_vma object and contains the list of FB object pages (reordered
94 * in the rotated view) that are visible in the view.
95 * In the normal view the FB object's backing store sg list is used
96 * directly and hence the remap information here is not used.
98 struct i915_ggtt_view gtt;
101 * The GTT view (gtt.type) specific information for each FB color
102 * plane. In the normal GTT view all formats (up to 4 color planes),
103 * in the rotated and remapped GTT view all no-CCS formats (up to 2
104 * color planes) are supported.
106 * TODO: add support for CCS formats in the remapped GTT view.
108 * The view information shared by all FB color planes in the FB,
109 * like dst x/y and src/dst width, is stored separately in
112 struct i915_color_plane_view {
117 * bytes for 0/180 degree rotation
118 * pixels for 90/270 degree rotation
124 struct intel_framebuffer {
125 struct drm_framebuffer base;
126 struct intel_frontbuffer *frontbuffer;
128 /* Params to remap the FB pages and program the plane registers in each view. */
129 struct intel_fb_view normal_view;
131 struct intel_fb_view rotated_view;
132 struct intel_fb_view remapped_view;
135 struct i915_address_space *dpt_vm;
139 struct drm_fb_helper helper;
140 struct intel_framebuffer *fb;
141 struct i915_vma *vma;
142 unsigned long vma_flags;
143 async_cookie_t cookie;
146 /* Whether or not fbdev hpd processing is temporarily suspended */
147 bool hpd_suspended : 1;
148 /* Set when a hotplug was received while HPD processing was
151 bool hpd_waiting : 1;
153 /* Protects hpd_suspended */
154 struct mutex hpd_lock;
157 enum intel_hotplug_state {
158 INTEL_HOTPLUG_UNCHANGED,
159 INTEL_HOTPLUG_CHANGED,
163 struct intel_encoder {
164 struct drm_encoder base;
166 enum intel_output_type type;
170 enum intel_hotplug_state (*hotplug)(struct intel_encoder *encoder,
171 struct intel_connector *connector);
172 enum intel_output_type (*compute_output_type)(struct intel_encoder *,
173 struct intel_crtc_state *,
174 struct drm_connector_state *);
175 int (*compute_config)(struct intel_encoder *,
176 struct intel_crtc_state *,
177 struct drm_connector_state *);
178 int (*compute_config_late)(struct intel_encoder *,
179 struct intel_crtc_state *,
180 struct drm_connector_state *);
181 void (*update_prepare)(struct intel_atomic_state *,
182 struct intel_encoder *,
183 struct intel_crtc *);
184 void (*pre_pll_enable)(struct intel_atomic_state *,
185 struct intel_encoder *,
186 const struct intel_crtc_state *,
187 const struct drm_connector_state *);
188 void (*pre_enable)(struct intel_atomic_state *,
189 struct intel_encoder *,
190 const struct intel_crtc_state *,
191 const struct drm_connector_state *);
192 void (*enable)(struct intel_atomic_state *,
193 struct intel_encoder *,
194 const struct intel_crtc_state *,
195 const struct drm_connector_state *);
196 void (*update_complete)(struct intel_atomic_state *,
197 struct intel_encoder *,
198 struct intel_crtc *);
199 void (*disable)(struct intel_atomic_state *,
200 struct intel_encoder *,
201 const struct intel_crtc_state *,
202 const struct drm_connector_state *);
203 void (*post_disable)(struct intel_atomic_state *,
204 struct intel_encoder *,
205 const struct intel_crtc_state *,
206 const struct drm_connector_state *);
207 void (*post_pll_disable)(struct intel_atomic_state *,
208 struct intel_encoder *,
209 const struct intel_crtc_state *,
210 const struct drm_connector_state *);
211 void (*update_pipe)(struct intel_atomic_state *,
212 struct intel_encoder *,
213 const struct intel_crtc_state *,
214 const struct drm_connector_state *);
215 /* Read out the current hw state of this connector, returning true if
216 * the encoder is active. If the encoder is enabled it also set the pipe
217 * it is connected to in the pipe parameter. */
218 bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
219 /* Reconstructs the equivalent mode flags for the current hardware
220 * state. This must be called _after_ display->get_pipe_config has
221 * pre-filled the pipe config. Note that intel_encoder->base.crtc must
222 * be set correctly before calling this function. */
223 void (*get_config)(struct intel_encoder *,
224 struct intel_crtc_state *pipe_config);
227 * Optional hook called during init/resume to sync any state
228 * stored in the encoder (eg. DP link parameters) wrt. the HW state.
230 void (*sync_state)(struct intel_encoder *encoder,
231 const struct intel_crtc_state *crtc_state);
234 * Optional hook, returning true if this encoder allows a fastset
235 * during the initial commit, false otherwise.
237 bool (*initial_fastset_check)(struct intel_encoder *encoder,
238 struct intel_crtc_state *crtc_state);
241 * Acquires the power domains needed for an active encoder during
242 * hardware state readout.
244 void (*get_power_domains)(struct intel_encoder *encoder,
245 struct intel_crtc_state *crtc_state);
247 * Called during system suspend after all pending requests for the
248 * encoder are flushed (for example for DP AUX transactions) and
249 * device interrupts are disabled.
251 void (*suspend)(struct intel_encoder *);
253 * Called during system reboot/shutdown after all the
254 * encoders have been disabled and suspended.
256 void (*shutdown)(struct intel_encoder *encoder);
258 * Enable/disable the clock to the port.
260 void (*enable_clock)(struct intel_encoder *encoder,
261 const struct intel_crtc_state *crtc_state);
262 void (*disable_clock)(struct intel_encoder *encoder);
264 * Returns whether the port clock is enabled or not.
266 bool (*is_clock_enabled)(struct intel_encoder *encoder);
267 const struct intel_ddi_buf_trans *(*get_buf_trans)(struct intel_encoder *encoder,
268 const struct intel_crtc_state *crtc_state,
270 enum hpd_pin hpd_pin;
271 enum intel_display_power_domain power_domain;
272 /* for communication with audio component; protected by av_mutex */
273 const struct drm_connector *audio_connector;
275 /* VBT information for this encoder (may be NULL for older platforms) */
276 const struct intel_bios_encoder_data *devdata;
279 struct intel_panel_bl_funcs {
280 /* Connector and platform specific backlight functions */
281 int (*setup)(struct intel_connector *connector, enum pipe pipe);
282 u32 (*get)(struct intel_connector *connector, enum pipe pipe);
283 void (*set)(const struct drm_connector_state *conn_state, u32 level);
284 void (*disable)(const struct drm_connector_state *conn_state, u32 level);
285 void (*enable)(const struct intel_crtc_state *crtc_state,
286 const struct drm_connector_state *conn_state, u32 level);
287 u32 (*hz_to_pwm)(struct intel_connector *connector, u32 hz);
291 struct drm_display_mode *fixed_mode;
292 struct drm_display_mode *downclock_mode;
301 bool combination_mode; /* gen 2/4 only */
303 bool alternate_pwm_increment; /* lpt+ */
309 bool util_pin_active_low; /* bxt+ */
310 u8 controller; /* bxt+ only */
311 struct pwm_device *pwm;
312 struct pwm_state pwm_state;
317 struct drm_edp_backlight_info info;
324 struct backlight_device *device;
326 const struct intel_panel_bl_funcs *funcs;
327 const struct intel_panel_bl_funcs *pwm_funcs;
328 void (*power)(struct intel_connector *, bool enable);
332 struct intel_digital_port;
334 enum check_link_response {
335 HDCP_LINK_PROTECTED = 0,
336 HDCP_TOPOLOGY_CHANGE,
337 HDCP_LINK_INTEGRITY_FAILURE,
342 * This structure serves as a translation layer between the generic HDCP code
343 * and the bus-specific code. What that means is that HDCP over HDMI differs
344 * from HDCP over DP, so to account for these differences, we need to
345 * communicate with the receiver through this shim.
347 * For completeness, the 2 buses differ in the following ways:
349 * HDCP registers on the receiver are set via DP AUX for DP, and
350 * they are set via DDC for HDMI.
351 * - Receiver register offsets
352 * The offsets of the registers are different for DP vs. HDMI
353 * - Receiver register masks/offsets
354 * For instance, the ready bit for the KSV fifo is in a different
355 * place on DP vs HDMI
356 * - Receiver register names
357 * Seriously. In the DP spec, the 16-bit register containing
358 * downstream information is called BINFO, on HDMI it's called
359 * BSTATUS. To confuse matters further, DP has a BSTATUS register
360 * with a completely different definition.
362 * On HDMI, the ksv fifo is read all at once, whereas on DP it must
363 * be read 3 keys at a time
365 * Since Aksv is hidden in hardware, there's different procedures
366 * to send it over DP AUX vs DDC
368 struct intel_hdcp_shim {
369 /* Outputs the transmitter's An and Aksv values to the receiver. */
370 int (*write_an_aksv)(struct intel_digital_port *dig_port, u8 *an);
372 /* Reads the receiver's key selection vector */
373 int (*read_bksv)(struct intel_digital_port *dig_port, u8 *bksv);
376 * Reads BINFO from DP receivers and BSTATUS from HDMI receivers. The
377 * definitions are the same in the respective specs, but the names are
378 * different. Call it BSTATUS since that's the name the HDMI spec
379 * uses and it was there first.
381 int (*read_bstatus)(struct intel_digital_port *dig_port,
384 /* Determines whether a repeater is present downstream */
385 int (*repeater_present)(struct intel_digital_port *dig_port,
386 bool *repeater_present);
388 /* Reads the receiver's Ri' value */
389 int (*read_ri_prime)(struct intel_digital_port *dig_port, u8 *ri);
391 /* Determines if the receiver's KSV FIFO is ready for consumption */
392 int (*read_ksv_ready)(struct intel_digital_port *dig_port,
395 /* Reads the ksv fifo for num_downstream devices */
396 int (*read_ksv_fifo)(struct intel_digital_port *dig_port,
397 int num_downstream, u8 *ksv_fifo);
399 /* Reads a 32-bit part of V' from the receiver */
400 int (*read_v_prime_part)(struct intel_digital_port *dig_port,
403 /* Enables HDCP signalling on the port */
404 int (*toggle_signalling)(struct intel_digital_port *dig_port,
405 enum transcoder cpu_transcoder,
408 /* Enable/Disable stream encryption on DP MST Transport Link */
409 int (*stream_encryption)(struct intel_connector *connector,
412 /* Ensures the link is still protected */
413 bool (*check_link)(struct intel_digital_port *dig_port,
414 struct intel_connector *connector);
416 /* Detects panel's hdcp capability. This is optional for HDMI. */
417 int (*hdcp_capable)(struct intel_digital_port *dig_port,
420 /* HDCP adaptation(DP/HDMI) required on the port */
421 enum hdcp_wired_protocol protocol;
423 /* Detects whether sink is HDCP2.2 capable */
424 int (*hdcp_2_2_capable)(struct intel_digital_port *dig_port,
427 /* Detects whether a HDCP 1.4 sink connected in MST topology */
428 int (*streams_type1_capable)(struct intel_connector *connector,
431 /* Write HDCP2.2 messages */
432 int (*write_2_2_msg)(struct intel_digital_port *dig_port,
433 void *buf, size_t size);
435 /* Read HDCP2.2 messages */
436 int (*read_2_2_msg)(struct intel_digital_port *dig_port,
437 u8 msg_id, void *buf, size_t size);
440 * Implementation of DP HDCP2.2 Errata for the communication of stream
441 * type to Receivers. In DP HDCP2.2 Stream type is one of the input to
442 * the HDCP2.2 Cipher for En/De-Cryption. Not applicable for HDMI.
444 int (*config_stream_type)(struct intel_digital_port *dig_port,
445 bool is_repeater, u8 type);
447 /* Enable/Disable HDCP 2.2 stream encryption on DP MST Transport Link */
448 int (*stream_2_2_encryption)(struct intel_connector *connector,
451 /* HDCP2.2 Link Integrity Check */
452 int (*check_2_2_link)(struct intel_digital_port *dig_port,
453 struct intel_connector *connector);
457 const struct intel_hdcp_shim *shim;
458 /* Mutex for hdcp state of the connector */
461 struct delayed_work check_work;
462 struct work_struct prop_work;
464 /* HDCP1.4 Encryption status */
467 /* HDCP2.2 related definitions */
468 /* Flag indicates whether this connector supports HDCP2.2 or not. */
469 bool hdcp2_supported;
471 /* HDCP2.2 Encryption status */
472 bool hdcp2_encrypted;
475 * Content Stream Type defined by content owner. TYPE0(0x0) content can
476 * flow in the link protected by HDCP2.2 or HDCP1.4, where as TYPE1(0x1)
477 * content can flow only through a link protected by HDCP2.2.
485 * Count of ReceiverID_List received. Initialized to 0 at AKE_INIT.
486 * Incremented after processing the RepeaterAuth_Send_ReceiverID_List.
487 * When it rolls over re-auth has to be triggered.
492 * Count of RepeaterAuth_Stream_Manage msg propagated.
493 * Initialized to 0 on AKE_INIT. Incremented after every successful
494 * transmission of RepeaterAuth_Stream_Manage message. When it rolls
495 * over re-Auth has to be triggered.
500 * Work queue to signal the CP_IRQ. Used for the waiters to read the
501 * available information from HDCP DP sink.
503 wait_queue_head_t cp_irq_queue;
504 atomic_t cp_irq_count;
505 int cp_irq_count_cached;
508 * HDCP register access for gen12+ need the transcoder associated.
509 * Transcoder attached to the connector could be changed at modeset.
510 * Hence caching the transcoder here.
512 enum transcoder cpu_transcoder;
513 /* Only used for DP MST stream encryption */
514 enum transcoder stream_transcoder;
517 struct intel_connector {
518 struct drm_connector base;
520 * The fixed encoder this connector is connected to.
522 struct intel_encoder *encoder;
524 /* ACPI device id for ACPI and driver cooperation */
527 /* Reads out the current hw, returning true if the connector is enabled
528 * and active (i.e. dpms ON state). */
529 bool (*get_hw_state)(struct intel_connector *);
531 /* Panel info for eDP and LVDS */
532 struct intel_panel panel;
534 /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
536 struct edid *detect_edid;
538 /* Number of times hotplug detection was tried after an HPD interrupt */
541 /* since POLL and HPD connectors may use the same HPD line keep the native
542 state of connector->polled in case hotplug storm detection changes it */
545 struct drm_dp_mst_port *port;
547 struct intel_dp *mst_port;
549 /* Work struct to schedule a uevent on link train failure */
550 struct work_struct modeset_retry_work;
552 struct intel_hdcp hdcp;
555 struct intel_digital_connector_state {
556 struct drm_connector_state base;
558 enum hdmi_force_audio force_audio;
562 #define to_intel_digital_connector_state(x) container_of(x, struct intel_digital_connector_state, base)
576 struct intel_atomic_state {
577 struct drm_atomic_state base;
579 intel_wakeref_t wakeref;
581 struct __intel_global_objs_state *global_objs;
584 bool dpll_set, modeset;
586 struct intel_shared_dpll_state shared_dpll[I915_NUM_PLLS];
589 * Current watermarks can't be trusted during hardware readout, so
590 * don't bother calculating intermediate watermarks.
592 bool skip_intermediate_wm;
594 bool rps_interactive;
596 struct i915_sw_fence commit_ready;
598 struct llist_node freed;
601 struct intel_plane_state {
602 struct drm_plane_state uapi;
605 * actual hardware state, the state we program to the hardware.
606 * The following members are used to verify the hardware state:
607 * During initial hw readout, they need to be copied from uapi.
610 struct drm_crtc *crtc;
611 struct drm_framebuffer *fb;
614 u16 pixel_blend_mode;
615 unsigned int rotation;
616 enum drm_color_encoding color_encoding;
617 enum drm_color_range color_range;
618 enum drm_scaling_filter scaling_filter;
621 struct i915_vma *ggtt_vma;
622 struct i915_vma *dpt_vma;
624 #define PLANE_HAS_FENCE BIT(0)
626 struct intel_fb_view view;
628 /* plane control register */
631 /* plane color control register */
634 /* chroma upsampler control register */
639 * = -1 : not using a scaler
640 * >= 0 : using a scalers
642 * plane requiring a scaler:
643 * - During check_plane, its bit is set in
644 * crtc_state->scaler_state.scaler_users by calling helper function
645 * update_scaler_plane.
646 * - scaler_id indicates the scaler it got assigned.
648 * plane doesn't require a scaler:
649 * - this can happen when scaling is no more required or plane simply
651 * - During check_plane, corresponding bit is reset in
652 * crtc_state->scaler_state.scaler_users by calling helper function
653 * update_scaler_plane.
658 * planar_linked_plane:
660 * ICL planar formats require 2 planes that are updated as pairs.
661 * This member is used to make sure the other plane is also updated
662 * when required, and for update_slave() to find the correct
663 * plane_state to pass as argument.
665 struct intel_plane *planar_linked_plane;
669 * If set don't update use the linked plane's state for updating
670 * this plane during atomic commit with the update_slave() callback.
672 * It's also used by the watermark code to ignore wm calculations on
673 * this plane. They're calculated by the linked plane's wm code.
677 struct drm_intel_sprite_colorkey ckey;
679 struct drm_rect psr2_sel_fetch_area;
681 /* Clear Color Value */
685 struct intel_initial_plane_config {
686 struct intel_framebuffer *fb;
687 struct i915_vma *vma;
694 struct intel_scaler {
699 struct intel_crtc_scaler_state {
700 #define SKL_NUM_SCALERS 2
701 struct intel_scaler scalers[SKL_NUM_SCALERS];
704 * scaler_users: keeps track of users requesting scalers on this crtc.
706 * If a bit is set, a user is using a scaler.
707 * Here user can be a plane or crtc as defined below:
708 * bits 0-30 - plane (bit position is index from drm_plane_index)
711 * Instead of creating a new index to cover planes and crtc, using
712 * existing drm_plane_index for planes which is well less than 31
713 * planes and bit 31 for crtc. This should be fine to cover all
716 * intel_atomic_setup_scalers will setup available scalers to users
717 * requesting scalers. It will gracefully fail if request exceeds
720 #define SKL_CRTC_INDEX 31
721 unsigned scaler_users;
723 /* scaler used by crtc for panel fitting purpose */
727 /* {crtc,crtc_state}->mode_flags */
728 /* Flag to get scanline using frame time stamps */
729 #define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1)
730 /* Flag to use the scanline counter instead of the pixel counter */
731 #define I915_MODE_FLAG_USE_SCANLINE_COUNTER (1<<2)
733 * TE0 or TE1 flag is set if the crtc has a DSI encoder which
734 * is operating in command mode.
735 * Flag to use TE from DSI0 instead of VBI in command mode
737 #define I915_MODE_FLAG_DSI_USE_TE0 (1<<3)
738 /* Flag to use TE from DSI1 instead of VBI in command mode */
739 #define I915_MODE_FLAG_DSI_USE_TE1 (1<<4)
740 /* Flag to indicate mipi dsi periodic command mode where we do not get TE */
741 #define I915_MODE_FLAG_DSI_PERIODIC_CMD_MODE (1<<5)
742 /* Do tricks to make vblank timestamps sane with VRR? */
743 #define I915_MODE_FLAG_VRR (1<<6)
745 struct intel_wm_level {
753 struct intel_pipe_wm {
754 struct intel_wm_level wm[5];
757 bool sprites_enabled;
761 struct skl_wm_level {
770 struct skl_plane_wm {
771 struct skl_wm_level wm[8];
772 struct skl_wm_level uv_wm[8];
773 struct skl_wm_level trans_wm;
775 struct skl_wm_level wm0;
776 struct skl_wm_level trans_wm;
782 struct skl_plane_wm planes[I915_MAX_PLANES];
789 VLV_WM_LEVEL_DDR_DVFS,
793 struct vlv_wm_state {
794 struct g4x_pipe_wm wm[NUM_VLV_WM_LEVELS];
795 struct g4x_sr_wm sr[NUM_VLV_WM_LEVELS];
800 struct vlv_fifo_state {
801 u16 plane[I915_MAX_PLANES];
811 struct g4x_wm_state {
812 struct g4x_pipe_wm wm;
814 struct g4x_sr_wm hpll;
820 struct intel_crtc_wm_state {
824 * The "raw" watermark values produced by the formula
825 * given the plane's current state. They do not consider
826 * how much FIFO is actually allocated for each plane.
829 * The "optimal" watermark values given the current
830 * state of the planes and the amount of FIFO
831 * allocated to each, ignoring any previous state
835 * The "intermediate" watermark values when transitioning
836 * between the old and new "optimal" values. Used when
837 * the watermark registers are single buffered and hence
838 * their state changes asynchronously with regards to the
839 * actual plane registers. These are essentially the
840 * worst case combination of the old and new "optimal"
841 * watermarks, which are therefore safe to use when the
842 * plane is in either its old or new state.
845 struct intel_pipe_wm intermediate;
846 struct intel_pipe_wm optimal;
850 struct skl_pipe_wm raw;
851 /* gen9+ only needs 1-step wm programming */
852 struct skl_pipe_wm optimal;
853 struct skl_ddb_entry ddb;
854 struct skl_ddb_entry plane_ddb_y[I915_MAX_PLANES];
855 struct skl_ddb_entry plane_ddb_uv[I915_MAX_PLANES];
859 struct g4x_pipe_wm raw[NUM_VLV_WM_LEVELS]; /* not inverted */
860 struct vlv_wm_state intermediate; /* inverted */
861 struct vlv_wm_state optimal; /* inverted */
862 struct vlv_fifo_state fifo_state;
866 struct g4x_pipe_wm raw[NUM_G4X_WM_LEVELS];
867 struct g4x_wm_state intermediate;
868 struct g4x_wm_state optimal;
873 * Platforms with two-step watermark programming will need to
874 * update watermark programming post-vblank to switch from the
875 * safe intermediate watermarks to the optimal final
878 bool need_postvbl_update;
881 enum intel_output_format {
882 INTEL_OUTPUT_FORMAT_RGB,
883 INTEL_OUTPUT_FORMAT_YCBCR420,
884 INTEL_OUTPUT_FORMAT_YCBCR444,
887 struct intel_crtc_state {
889 * uapi (drm) state. This is the software state shown to userspace.
890 * In particular, the following members are used for bookkeeping:
898 struct drm_crtc_state uapi;
901 * actual hardware state, the state we program to the hardware.
902 * The following members are used to verify the hardware state:
905 * - mode / pipe_mode / adjusted_mode
906 * - color property blobs.
908 * During initial hw readout, they need to be copied to uapi.
910 * Bigjoiner will allow a transcoder mode that spans 2 pipes;
911 * Use the pipe_mode for calculations like watermarks, pipe
912 * scaler, and bandwidth.
914 * Use adjusted_mode for things that need to know the full
915 * mode on the transcoder, which spans all pipes.
919 struct drm_property_blob *degamma_lut, *gamma_lut, *ctm;
920 struct drm_display_mode mode, pipe_mode, adjusted_mode;
921 enum drm_scaling_filter scaling_filter;
925 * quirks - bitfield with hw state readout quirks
927 * For various reasons the hw state readout code might not be able to
928 * completely faithfully read out the current state. These cases are
929 * tracked with quirk flags so that fastboot and state checker can act
932 #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
933 #define PIPE_CONFIG_QUIRK_BIGJOINER_SLAVE (1<<1) /* bigjoiner slave, partial readout */
934 unsigned long quirks;
936 unsigned fb_bits; /* framebuffers to flip */
937 bool update_pipe; /* can a fast modeset be performed? */
939 bool update_wm_pre, update_wm_post; /* watermarks are updated */
940 bool fifo_changed; /* FIFO split is changed */
942 bool inherited; /* state inherited from BIOS? */
944 /* Pipe source size (ie. panel fitter input size)
945 * All planes will be positioned inside this space,
946 * and get clipped at the edges. */
947 int pipe_src_w, pipe_src_h;
950 * Pipe pixel rate, adjusted for
951 * panel fitter/pipe scaler downscaling.
953 unsigned int pixel_rate;
955 /* Whether to set up the PCH/FDI. Note that we never allow sharing
956 * between pch encoders and cpu encoders. */
957 bool has_pch_encoder;
959 /* Are we sending infoframes on the attached port */
962 /* CPU Transcoder for the pipe. Currently this can only differ from the
963 * pipe on Haswell and later (where we have a special eDP transcoder)
964 * and Broxton (where we have special DSI transcoders). */
965 enum transcoder cpu_transcoder;
968 * Use reduced/limited/broadcast rbg range, compressing from the full
969 * range fed into the crtcs.
971 bool limited_color_range;
973 /* Bitmask of encoder types (enum intel_output_type)
974 * driven by the pipe.
976 unsigned int output_types;
978 /* Whether we should send NULL infoframes. Required for audio. */
981 /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
982 * has_dp_encoder is set. */
986 * Enable dithering, used when the selected pipe bpp doesn't match the
992 * Dither gets enabled for 18bpp which causes CRC mismatch errors for
993 * compliance video pattern tests.
994 * Disable dither only if it is a compliance test request for
997 bool dither_force_disable;
999 /* Controls for the clock computation, to override various stages. */
1002 /* SDVO TV has a bunch of special case. To make multifunction encoders
1003 * work correctly, we need to track this at runtime.*/
1007 * crtc bandwidth limit, don't increase pipe bpp or clock if not really
1008 * required. This is set in the 2nd loop of calling encoder's
1009 * ->compute_config if the first pick doesn't work out.
1011 bool bw_constrained;
1013 /* Settings for the intel dpll used on pretty much everything but
1017 /* Selected dpll when shared or NULL. */
1018 struct intel_shared_dpll *shared_dpll;
1020 /* Actual register state of the dpll, for shared dpll cross-checking. */
1021 struct intel_dpll_hw_state dpll_hw_state;
1024 * ICL reserved DPLLs for the CRTC/port. The active PLL is selected by
1025 * setting shared_dpll and dpll_hw_state to one of these reserved ones.
1027 struct icl_port_dpll {
1028 struct intel_shared_dpll *pll;
1029 struct intel_dpll_hw_state hw_state;
1030 } icl_port_dplls[ICL_PORT_DPLL_COUNT];
1032 /* DSI PLL registers */
1038 struct intel_link_m_n dp_m_n;
1040 /* m2_n2 for eDP downclock */
1041 struct intel_link_m_n dp_m2_n2;
1046 bool enable_psr2_sel_fetch;
1047 bool req_psr2_sdp_prior_scanline;
1049 u16 su_y_granularity;
1052 * Frequence the dpll for the port should run at. Differs from the
1053 * adjusted dotclock e.g. for DP or 10/12bpc hdmi mode. This is also
1054 * already multiplied by pixel_multiplier.
1058 /* Used by SDVO (and if we ever fix it, HDMI). */
1059 unsigned pixel_multiplier;
1061 /* I915_MODE_FLAG_* */
1067 * Used by platforms having DP/HDMI PHY with programmable lane
1068 * latency optimization.
1070 u8 lane_lat_optim_mask;
1072 /* minimum acceptable voltage level */
1073 u8 min_voltage_level;
1075 /* Panel fitter controls for gen2-gen4 + VLV */
1079 u32 lvds_border_bits;
1082 /* Panel fitter placement and size for Ironlake+ */
1084 struct drm_rect dst;
1089 /* FDI configuration, only valid if has_pch_encoder is set. */
1091 struct intel_link_m_n fdi_m_n;
1103 struct intel_crtc_scaler_state scaler_state;
1105 /* w/a for waiting 2 vblanks during crtc enable */
1106 enum pipe hsw_workaround_pipe;
1108 /* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */
1111 struct intel_crtc_wm_state wm;
1113 int min_cdclk[I915_MAX_PLANES];
1115 u32 data_rate[I915_MAX_PLANES];
1117 /* FIXME unify with data_rate[] */
1118 u64 plane_data_rate[I915_MAX_PLANES];
1119 u64 uv_plane_data_rate[I915_MAX_PLANES];
1121 /* Gamma mode programmed on the pipe */
1125 /* CSC mode programmed on the pipe */
1132 /* bitmask of logically enabled planes (enum plane_id) */
1135 /* bitmask of actually visible planes (enum plane_id) */
1140 /* bitmask of planes that will be updated during the commit */
1146 union hdmi_infoframe avi;
1147 union hdmi_infoframe spd;
1148 union hdmi_infoframe hdmi;
1149 union hdmi_infoframe drm;
1150 struct drm_dp_vsc_sdp vsc;
1153 /* HDMI scrambling status */
1154 bool hdmi_scrambling;
1156 /* HDMI High TMDS char rate ratio */
1157 bool hdmi_high_tmds_clock_ratio;
1159 /* Output format RGB/YCBCR etc */
1160 enum intel_output_format output_format;
1162 /* enable pipe gamma? */
1165 /* enable pipe csc? */
1168 /* enable pipe big joiner? */
1171 /* big joiner slave crtc? */
1172 bool bigjoiner_slave;
1174 /* linked crtc for bigjoiner, either slave or master */
1175 struct intel_crtc *bigjoiner_linked_crtc;
1177 /* Display Stream compression state */
1179 bool compression_enable;
1183 struct drm_dsc_config config;
1186 /* HSW+ linetime watermarks */
1190 /* Forward Error correction State */
1193 /* Pointer to master transcoder in case of tiled displays */
1194 enum transcoder master_transcoder;
1196 /* Bitmask to indicate slaves attached */
1197 u8 sync_mode_slaves_mask;
1199 /* Only valid on TGL+ */
1200 enum transcoder mst_master_transcoder;
1202 /* For DSB related info */
1203 struct intel_dsb *dsb;
1205 u32 psr2_man_track_ctl;
1207 /* Variable Refresh Rate state */
1211 u16 flipline, vmin, vmax, guardband;
1214 /* Stream Splitter for eDP MSO */
1222 enum intel_pipe_crc_source {
1223 INTEL_PIPE_CRC_SOURCE_NONE,
1224 INTEL_PIPE_CRC_SOURCE_PLANE1,
1225 INTEL_PIPE_CRC_SOURCE_PLANE2,
1226 INTEL_PIPE_CRC_SOURCE_PLANE3,
1227 INTEL_PIPE_CRC_SOURCE_PLANE4,
1228 INTEL_PIPE_CRC_SOURCE_PLANE5,
1229 INTEL_PIPE_CRC_SOURCE_PLANE6,
1230 INTEL_PIPE_CRC_SOURCE_PLANE7,
1231 INTEL_PIPE_CRC_SOURCE_PIPE,
1232 /* TV/DP on pre-gen5/vlv can't use the pipe source. */
1233 INTEL_PIPE_CRC_SOURCE_TV,
1234 INTEL_PIPE_CRC_SOURCE_DP_B,
1235 INTEL_PIPE_CRC_SOURCE_DP_C,
1236 INTEL_PIPE_CRC_SOURCE_DP_D,
1237 INTEL_PIPE_CRC_SOURCE_AUTO,
1238 INTEL_PIPE_CRC_SOURCE_MAX,
1241 #define INTEL_PIPE_CRC_ENTRIES_NR 128
1242 struct intel_pipe_crc {
1245 enum intel_pipe_crc_source source;
1249 struct drm_crtc base;
1252 * Whether the crtc and the connected output pipeline is active. Implies
1253 * that crtc->enabled is set, i.e. the current mode configuration has
1254 * some outputs connected to this crtc.
1259 /* I915_MODE_FLAG_* */
1262 u16 vmax_vblank_start;
1264 struct intel_display_power_domain_set enabled_power_domains;
1265 struct intel_overlay *overlay;
1267 struct intel_crtc_state *config;
1269 /* Access to these should be protected by dev_priv->irq_lock. */
1270 bool cpu_fifo_underrun_disabled;
1271 bool pch_fifo_underrun_disabled;
1273 /* per-pipe watermark state */
1275 /* watermarks currently being used */
1277 struct intel_pipe_wm ilk;
1278 struct vlv_wm_state vlv;
1279 struct g4x_wm_state g4x;
1283 int scanline_offset;
1286 unsigned start_vbl_count;
1287 ktime_t start_vbl_time;
1288 int min_vbl, max_vbl;
1290 #ifdef CONFIG_DRM_I915_DEBUG_VBLANK_EVADE
1296 unsigned int times[17]; /* [1us, 16ms] */
1301 /* scalers available on this crtc */
1304 #ifdef CONFIG_DEBUG_FS
1305 struct intel_pipe_crc pipe_crc;
1309 struct intel_plane {
1310 struct drm_plane base;
1311 enum i9xx_plane_id i9xx_plane;
1316 bool need_async_flip_disable_wa;
1317 u32 frontbuffer_bit;
1320 u32 base, cntl, size;
1324 * NOTE: Do not place new plane state fields here (e.g., when adding
1325 * new plane properties). New runtime state should now be placed in
1326 * the intel_plane_state structure and accessed via plane_state.
1329 int (*min_width)(const struct drm_framebuffer *fb,
1331 unsigned int rotation);
1332 int (*max_width)(const struct drm_framebuffer *fb,
1334 unsigned int rotation);
1335 int (*max_height)(const struct drm_framebuffer *fb,
1337 unsigned int rotation);
1338 unsigned int (*max_stride)(struct intel_plane *plane,
1339 u32 pixel_format, u64 modifier,
1340 unsigned int rotation);
1341 void (*update_plane)(struct intel_plane *plane,
1342 const struct intel_crtc_state *crtc_state,
1343 const struct intel_plane_state *plane_state);
1344 void (*disable_plane)(struct intel_plane *plane,
1345 const struct intel_crtc_state *crtc_state);
1346 bool (*get_hw_state)(struct intel_plane *plane, enum pipe *pipe);
1347 int (*check_plane)(struct intel_crtc_state *crtc_state,
1348 struct intel_plane_state *plane_state);
1349 int (*min_cdclk)(const struct intel_crtc_state *crtc_state,
1350 const struct intel_plane_state *plane_state);
1351 void (*async_flip)(struct intel_plane *plane,
1352 const struct intel_crtc_state *crtc_state,
1353 const struct intel_plane_state *plane_state,
1355 void (*enable_flip_done)(struct intel_plane *plane);
1356 void (*disable_flip_done)(struct intel_plane *plane);
1359 struct intel_watermark_params {
1367 struct cxsr_latency {
1368 bool is_desktop : 1;
1373 u16 display_hpll_disable;
1375 u16 cursor_hpll_disable;
1378 #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base)
1379 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
1380 #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, uapi)
1381 #define to_intel_connector(x) container_of(x, struct intel_connector, base)
1382 #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
1383 #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
1384 #define to_intel_plane(x) container_of(x, struct intel_plane, base)
1385 #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, uapi)
1386 #define intel_fb_obj(x) ((x) ? to_intel_bo((x)->obj[0]) : NULL)
1389 i915_reg_t hdmi_reg;
1392 enum drm_dp_dual_mode_type type;
1397 struct intel_connector *attached_connector;
1398 struct cec_notifier *cec_notifier;
1401 struct intel_dp_mst_encoder;
1403 * enum link_m_n_set:
1404 * When platform provides two set of M_N registers for dp, we can
1405 * program them and switch between them incase of DRRS.
1406 * But When only one such register is provided, we have to program the
1407 * required divider value on that registers itself based on the DRRS state.
1409 * M1_N1 : Program dp_m_n on M1_N1 registers
1410 * dp_m2_n2 on M2_N2 registers (If supported)
1412 * M2_N2 : Program dp_m2_n2 on M1_N1 registers
1413 * M2_N2 registers are not supported
1417 /* Sets the m1_n1 and m2_n2 */
1422 struct intel_dp_compliance_data {
1425 u16 hdisplay, vdisplay;
1427 struct drm_dp_phy_test_params phytest;
1430 struct intel_dp_compliance {
1431 unsigned long test_type;
1432 struct intel_dp_compliance_data test_data;
1438 struct intel_dp_pcon_frl {
1440 int trained_rate_gbps;
1444 int panel_power_up_delay;
1445 int panel_power_down_delay;
1446 int panel_power_cycle_delay;
1447 int backlight_on_delay;
1448 int backlight_off_delay;
1449 struct delayed_work panel_vdd_work;
1450 bool want_panel_vdd;
1451 unsigned long last_power_on;
1452 unsigned long last_backlight_off;
1453 ktime_t panel_power_off_time;
1454 intel_wakeref_t vdd_wakeref;
1457 * Pipe whose power sequencer is currently locked into
1458 * this port. Only relevant on VLV/CHV.
1462 * Pipe currently driving the port. Used for preventing
1463 * the use of the PPS for any pipe currentrly driving
1464 * external DP as that will mess things up on VLV.
1466 enum pipe active_pipe;
1468 * Set if the sequencer may be reset due to a power transition,
1469 * requiring a reinitialization. Only relevant on BXT.
1472 struct edp_power_seq pps_delays;
1476 /* Mutex for PSR state of the transcoder */
1479 #define I915_PSR_DEBUG_MODE_MASK 0x0f
1480 #define I915_PSR_DEBUG_DEFAULT 0x00
1481 #define I915_PSR_DEBUG_DISABLE 0x01
1482 #define I915_PSR_DEBUG_ENABLE 0x02
1483 #define I915_PSR_DEBUG_FORCE_PSR1 0x03
1484 #define I915_PSR_DEBUG_ENABLE_SEL_FETCH 0x4
1485 #define I915_PSR_DEBUG_IRQ 0x10
1489 bool source_support;
1493 enum transcoder transcoder;
1495 struct work_struct work;
1496 unsigned int busy_frontbuffer_bits;
1497 bool sink_psr2_support;
1499 bool colorimetry_support;
1501 bool psr2_sel_fetch_enabled;
1502 bool req_psr2_sdp_prior_scanline;
1503 u8 sink_sync_latency;
1504 ktime_t last_entry_attempt;
1506 bool sink_not_reliable;
1508 u16 su_w_granularity;
1509 u16 su_y_granularity;
1511 u32 dc3co_exit_delay;
1512 struct delayed_work dc3co_work;
1513 struct drm_dp_vsc_sdp vsc;
1517 i915_reg_t output_reg;
1525 bool reset_link_params;
1526 bool use_max_params;
1527 u8 dpcd[DP_RECEIVER_CAP_SIZE];
1528 u8 psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
1529 u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
1530 u8 edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
1531 u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE];
1532 u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE];
1533 u8 lttpr_phy_caps[DP_MAX_LTTPR_COUNT][DP_LTTPR_PHY_CAP_SIZE];
1535 u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE];
1537 int num_source_rates;
1538 const int *source_rates;
1539 /* sink rates as reported by DP_MAX_LINK_RATE/DP_SUPPORTED_LINK_RATES */
1541 int sink_rates[DP_MAX_SUPPORTED_RATES];
1542 bool use_rate_select;
1543 /* intersection of source and sink rates */
1544 int num_common_rates;
1545 int common_rates[DP_MAX_SUPPORTED_RATES];
1546 /* Max lane count for the current link */
1547 int max_link_lane_count;
1548 /* Max rate for the current link */
1551 int mso_pixel_overlap;
1552 /* sink or branch descriptor */
1553 struct drm_dp_desc desc;
1554 struct drm_dp_aux aux;
1555 u32 aux_busy_last_status;
1558 struct intel_pps pps;
1560 bool can_mst; /* this port supports mst */
1562 int active_mst_links;
1564 /* connector directly attached - won't be use for modeset in mst world */
1565 struct intel_connector *attached_connector;
1567 /* mst connector list */
1568 struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
1569 struct drm_dp_mst_topology_mgr mst_mgr;
1571 u32 (*get_aux_clock_divider)(struct intel_dp *dp, int index);
1573 * This function returns the value we have to program the AUX_CTL
1574 * register with to kick off an AUX transaction.
1576 u32 (*get_aux_send_ctl)(struct intel_dp *dp, int send_bytes,
1577 u32 aux_clock_divider);
1579 i915_reg_t (*aux_ch_ctl_reg)(struct intel_dp *dp);
1580 i915_reg_t (*aux_ch_data_reg)(struct intel_dp *dp, int index);
1582 /* This is called before a link training is starterd */
1583 void (*prepare_link_retrain)(struct intel_dp *intel_dp,
1584 const struct intel_crtc_state *crtc_state);
1585 void (*set_link_train)(struct intel_dp *intel_dp,
1586 const struct intel_crtc_state *crtc_state,
1588 void (*set_idle_link_train)(struct intel_dp *intel_dp,
1589 const struct intel_crtc_state *crtc_state);
1590 void (*set_signal_levels)(struct intel_dp *intel_dp,
1591 const struct intel_crtc_state *crtc_state);
1593 u8 (*preemph_max)(struct intel_dp *intel_dp);
1594 u8 (*voltage_max)(struct intel_dp *intel_dp,
1595 const struct intel_crtc_state *crtc_state);
1597 /* Displayport compliance testing */
1598 struct intel_dp_compliance compliance;
1600 /* Downstream facing port caps */
1602 int min_tmds_clock, max_tmds_clock;
1604 int pcon_max_frl_bw;
1606 bool ycbcr_444_to_420;
1610 /* To control wakeup latency, e.g. for irq-driven dp aux transfers. */
1611 struct pm_qos_request pm_qos;
1613 /* Display stream compression testing */
1619 struct intel_dp_pcon_frl frl;
1621 struct intel_psr psr;
1624 enum lspcon_vendor {
1626 LSPCON_VENDOR_PARADE
1629 struct intel_lspcon {
1632 enum drm_lspcon_mode mode;
1633 enum lspcon_vendor vendor;
1636 struct intel_digital_port {
1637 struct intel_encoder base;
1638 u32 saved_port_bits;
1640 struct intel_hdmi hdmi;
1641 struct intel_lspcon lspcon;
1642 enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
1643 bool release_cl2_override;
1645 /* Used for DP and ICL+ TypeC/DP and TypeC/HDMI ports. */
1647 enum intel_display_power_domain ddi_io_power_domain;
1648 intel_wakeref_t ddi_io_wakeref;
1649 intel_wakeref_t aux_wakeref;
1650 struct mutex tc_lock; /* protects the TypeC port mode */
1651 intel_wakeref_t tc_lock_wakeref;
1652 int tc_link_refcount;
1653 bool tc_legacy_port:1;
1654 char tc_port_name[8];
1655 enum tc_port_mode tc_mode;
1656 enum phy_fia tc_phy_fia;
1659 /* protects num_hdcp_streams reference count, hdcp_port_data and hdcp_auth_status */
1660 struct mutex hdcp_mutex;
1661 /* the number of pipes using HDCP signalling out of this port */
1662 unsigned int num_hdcp_streams;
1663 /* port HDCP auth status */
1664 bool hdcp_auth_status;
1665 /* HDCP port data need to pass to security f/w */
1666 struct hdcp_port_data hdcp_port_data;
1668 void (*write_infoframe)(struct intel_encoder *encoder,
1669 const struct intel_crtc_state *crtc_state,
1671 const void *frame, ssize_t len);
1672 void (*read_infoframe)(struct intel_encoder *encoder,
1673 const struct intel_crtc_state *crtc_state,
1675 void *frame, ssize_t len);
1676 void (*set_infoframes)(struct intel_encoder *encoder,
1678 const struct intel_crtc_state *crtc_state,
1679 const struct drm_connector_state *conn_state);
1680 u32 (*infoframes_enabled)(struct intel_encoder *encoder,
1681 const struct intel_crtc_state *pipe_config);
1682 bool (*connected)(struct intel_encoder *encoder);
1685 struct intel_dp_mst_encoder {
1686 struct intel_encoder base;
1688 struct intel_digital_port *primary;
1689 struct intel_connector *connector;
1692 static inline enum dpio_channel
1693 vlv_dig_port_to_channel(struct intel_digital_port *dig_port)
1695 switch (dig_port->base.port) {
1706 static inline enum dpio_phy
1707 vlv_dig_port_to_phy(struct intel_digital_port *dig_port)
1709 switch (dig_port->base.port) {
1720 static inline enum dpio_channel
1721 vlv_pipe_to_channel(enum pipe pipe)
1734 static inline bool intel_pipe_valid(struct drm_i915_private *i915, enum pipe pipe)
1736 return (pipe >= 0 &&
1737 pipe < ARRAY_SIZE(i915->pipe_to_crtc_mapping) &&
1738 INTEL_INFO(i915)->pipe_mask & BIT(pipe) &&
1739 i915->pipe_to_crtc_mapping[pipe]);
1742 static inline struct intel_crtc *
1743 intel_get_first_crtc(struct drm_i915_private *dev_priv)
1745 return to_intel_crtc(drm_crtc_from_index(&dev_priv->drm, 0));
1748 static inline struct intel_crtc *
1749 intel_get_crtc_for_pipe(struct drm_i915_private *dev_priv, enum pipe pipe)
1751 /* pipe_to_crtc_mapping may have hole on any of 3 display pipe system */
1752 drm_WARN_ON(&dev_priv->drm,
1753 !(INTEL_INFO(dev_priv)->pipe_mask & BIT(pipe)));
1754 return dev_priv->pipe_to_crtc_mapping[pipe];
1757 static inline struct intel_crtc *
1758 intel_get_crtc_for_plane(struct drm_i915_private *dev_priv, enum i9xx_plane_id plane)
1760 return dev_priv->plane_to_crtc_mapping[plane];
1763 struct intel_load_detect_pipe {
1764 struct drm_atomic_state *restore_state;
1767 static inline struct intel_encoder *
1768 intel_attached_encoder(struct intel_connector *connector)
1770 return connector->encoder;
1773 static inline bool intel_encoder_is_dig_port(struct intel_encoder *encoder)
1775 switch (encoder->type) {
1776 case INTEL_OUTPUT_DDI:
1777 case INTEL_OUTPUT_DP:
1778 case INTEL_OUTPUT_EDP:
1779 case INTEL_OUTPUT_HDMI:
1786 static inline bool intel_encoder_is_mst(struct intel_encoder *encoder)
1788 return encoder->type == INTEL_OUTPUT_DP_MST;
1791 static inline struct intel_dp_mst_encoder *
1792 enc_to_mst(struct intel_encoder *encoder)
1794 return container_of(&encoder->base, struct intel_dp_mst_encoder,
1798 static inline struct intel_digital_port *
1799 enc_to_dig_port(struct intel_encoder *encoder)
1801 struct intel_encoder *intel_encoder = encoder;
1803 if (intel_encoder_is_dig_port(intel_encoder))
1804 return container_of(&encoder->base, struct intel_digital_port,
1806 else if (intel_encoder_is_mst(intel_encoder))
1807 return enc_to_mst(encoder)->primary;
1812 static inline struct intel_digital_port *
1813 intel_attached_dig_port(struct intel_connector *connector)
1815 return enc_to_dig_port(intel_attached_encoder(connector));
1818 static inline struct intel_hdmi *
1819 enc_to_intel_hdmi(struct intel_encoder *encoder)
1821 return &enc_to_dig_port(encoder)->hdmi;
1824 static inline struct intel_hdmi *
1825 intel_attached_hdmi(struct intel_connector *connector)
1827 return enc_to_intel_hdmi(intel_attached_encoder(connector));
1830 static inline struct intel_dp *enc_to_intel_dp(struct intel_encoder *encoder)
1832 return &enc_to_dig_port(encoder)->dp;
1835 static inline struct intel_dp *intel_attached_dp(struct intel_connector *connector)
1837 return enc_to_intel_dp(intel_attached_encoder(connector));
1840 static inline bool intel_encoder_is_dp(struct intel_encoder *encoder)
1842 switch (encoder->type) {
1843 case INTEL_OUTPUT_DP:
1844 case INTEL_OUTPUT_EDP:
1846 case INTEL_OUTPUT_DDI:
1847 /* Skip pure HDMI/DVI DDI encoders */
1848 return i915_mmio_reg_valid(enc_to_intel_dp(encoder)->output_reg);
1854 static inline struct intel_lspcon *
1855 enc_to_intel_lspcon(struct intel_encoder *encoder)
1857 return &enc_to_dig_port(encoder)->lspcon;
1860 static inline struct intel_digital_port *
1861 dp_to_dig_port(struct intel_dp *intel_dp)
1863 return container_of(intel_dp, struct intel_digital_port, dp);
1866 static inline struct intel_lspcon *
1867 dp_to_lspcon(struct intel_dp *intel_dp)
1869 return &dp_to_dig_port(intel_dp)->lspcon;
1872 static inline struct drm_i915_private *
1873 dp_to_i915(struct intel_dp *intel_dp)
1875 return to_i915(dp_to_dig_port(intel_dp)->base.base.dev);
1878 #define CAN_PSR(intel_dp) ((intel_dp)->psr.sink_support && \
1879 (intel_dp)->psr.source_support)
1881 static inline bool intel_encoder_can_psr(struct intel_encoder *encoder)
1883 if (!intel_encoder_is_dp(encoder))
1886 return CAN_PSR(enc_to_intel_dp(encoder));
1889 static inline struct intel_digital_port *
1890 hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
1892 return container_of(intel_hdmi, struct intel_digital_port, hdmi);
1895 static inline struct intel_plane_state *
1896 intel_atomic_get_plane_state(struct intel_atomic_state *state,
1897 struct intel_plane *plane)
1899 struct drm_plane_state *ret =
1900 drm_atomic_get_plane_state(&state->base, &plane->base);
1903 return ERR_CAST(ret);
1905 return to_intel_plane_state(ret);
1908 static inline struct intel_plane_state *
1909 intel_atomic_get_old_plane_state(struct intel_atomic_state *state,
1910 struct intel_plane *plane)
1912 return to_intel_plane_state(drm_atomic_get_old_plane_state(&state->base,
1916 static inline struct intel_plane_state *
1917 intel_atomic_get_new_plane_state(struct intel_atomic_state *state,
1918 struct intel_plane *plane)
1920 return to_intel_plane_state(drm_atomic_get_new_plane_state(&state->base,
1924 static inline struct intel_crtc_state *
1925 intel_atomic_get_old_crtc_state(struct intel_atomic_state *state,
1926 struct intel_crtc *crtc)
1928 return to_intel_crtc_state(drm_atomic_get_old_crtc_state(&state->base,
1932 static inline struct intel_crtc_state *
1933 intel_atomic_get_new_crtc_state(struct intel_atomic_state *state,
1934 struct intel_crtc *crtc)
1936 return to_intel_crtc_state(drm_atomic_get_new_crtc_state(&state->base,
1940 static inline struct intel_digital_connector_state *
1941 intel_atomic_get_new_connector_state(struct intel_atomic_state *state,
1942 struct intel_connector *connector)
1944 return to_intel_digital_connector_state(
1945 drm_atomic_get_new_connector_state(&state->base,
1949 static inline struct intel_digital_connector_state *
1950 intel_atomic_get_old_connector_state(struct intel_atomic_state *state,
1951 struct intel_connector *connector)
1953 return to_intel_digital_connector_state(
1954 drm_atomic_get_old_connector_state(&state->base,
1958 /* intel_display.c */
1960 intel_crtc_has_type(const struct intel_crtc_state *crtc_state,
1961 enum intel_output_type type)
1963 return crtc_state->output_types & (1 << type);
1966 intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state)
1968 return crtc_state->output_types &
1969 ((1 << INTEL_OUTPUT_DP) |
1970 (1 << INTEL_OUTPUT_DP_MST) |
1971 (1 << INTEL_OUTPUT_EDP));
1975 intel_crtc_needs_modeset(const struct intel_crtc_state *crtc_state)
1977 return drm_atomic_crtc_needs_modeset(&crtc_state->uapi);
1981 intel_wait_for_vblank(struct drm_i915_private *dev_priv, enum pipe pipe)
1983 struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
1985 drm_crtc_wait_one_vblank(&crtc->base);
1989 intel_wait_for_vblank_if_active(struct drm_i915_private *dev_priv, enum pipe pipe)
1991 const struct intel_crtc *crtc = intel_get_crtc_for_pipe(dev_priv, pipe);
1994 intel_wait_for_vblank(dev_priv, pipe);
1997 static inline bool intel_modifier_uses_dpt(struct drm_i915_private *i915, u64 modifier)
1999 return DISPLAY_VER(i915) >= 13 && modifier != DRM_FORMAT_MOD_LINEAR;
2002 static inline bool intel_fb_uses_dpt(const struct drm_framebuffer *fb)
2004 return fb && intel_modifier_uses_dpt(to_i915(fb->dev), fb->modifier);
2007 static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *plane_state)
2009 return i915_ggtt_offset(plane_state->ggtt_vma);
2012 static inline struct intel_frontbuffer *
2013 to_intel_frontbuffer(struct drm_framebuffer *fb)
2015 return fb ? to_intel_framebuffer(fb)->frontbuffer : NULL;
2018 static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv)
2020 if (dev_priv->params.panel_use_ssc >= 0)
2021 return dev_priv->params.panel_use_ssc != 0;
2022 return dev_priv->vbt.lvds_use_ssc
2023 && !(dev_priv->quirks & QUIRK_LVDS_SSC_DISABLE);
2026 static inline u32 i9xx_dpll_compute_fp(struct dpll *dpll)
2028 return dpll->n << 16 | dpll->m1 << 8 | dpll->m2;
2031 static inline u32 intel_fdi_link_freq(struct drm_i915_private *dev_priv,
2032 const struct intel_crtc_state *pipe_config)
2034 if (HAS_DDI(dev_priv))
2035 return pipe_config->port_clock; /* SPLL */
2037 return dev_priv->fdi_pll_freq;
2040 static inline bool is_ccs_modifier(u64 modifier)
2042 return modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS ||
2043 modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC ||
2044 modifier == I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS ||
2045 modifier == I915_FORMAT_MOD_Y_TILED_CCS ||
2046 modifier == I915_FORMAT_MOD_Yf_TILED_CCS;
2049 static inline bool is_gen12_ccs_modifier(u64 modifier)
2051 return modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS ||
2052 modifier == I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC ||
2053 modifier == I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS;
2056 #endif /* __INTEL_DISPLAY_TYPES_H__ */