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/i2c.h>
30 #include <linux/pm_qos.h>
31 #include <linux/pwm.h>
32 #include <linux/sched/clock.h>
34 #include <drm/display/drm_dp_dual_mode_helper.h>
35 #include <drm/display/drm_dp_mst_helper.h>
36 #include <drm/display/drm_dp_tunnel.h>
37 #include <drm/display/drm_dsc.h>
38 #include <drm/drm_atomic.h>
39 #include <drm/drm_crtc.h>
40 #include <drm/drm_encoder.h>
41 #include <drm/drm_fourcc.h>
42 #include <drm/drm_framebuffer.h>
43 #include <drm/drm_probe_helper.h>
44 #include <drm/drm_rect.h>
45 #include <drm/drm_vblank.h>
46 #include <drm/drm_vblank_work.h>
47 #include <drm/i915_hdcp_interface.h>
48 #include <media/cec-notifier.h>
51 #include "i915_vma_types.h"
52 #include "intel_bios.h"
53 #include "intel_display.h"
54 #include "intel_display_limits.h"
55 #include "intel_display_power.h"
56 #include "intel_dpll_mgr.h"
57 #include "intel_wm_types.h"
60 struct __intel_global_objs_state;
61 struct intel_ddi_buf_trans;
63 struct intel_connector;
67 * Display related stuff
70 /* these are outputs from the chip - integrated only
71 external chips are via DVO or SDVO output */
72 enum intel_output_type {
73 INTEL_OUTPUT_UNUSED = 0,
74 INTEL_OUTPUT_ANALOG = 1,
76 INTEL_OUTPUT_SDVO = 3,
77 INTEL_OUTPUT_LVDS = 4,
78 INTEL_OUTPUT_TVOUT = 5,
79 INTEL_OUTPUT_HDMI = 6,
83 INTEL_OUTPUT_DDI = 10,
84 INTEL_OUTPUT_DP_MST = 11,
87 enum hdmi_force_audio {
88 HDMI_AUDIO_OFF_DVI = -2, /* no aux data for HDMI-DVI converter */
89 HDMI_AUDIO_OFF, /* force turn off HDMI audio */
90 HDMI_AUDIO_AUTO, /* trust EDID */
91 HDMI_AUDIO_ON, /* force turn on HDMI audio */
94 /* "Broadcast RGB" property */
95 enum intel_broadcast_rgb {
96 INTEL_BROADCAST_RGB_AUTO,
97 INTEL_BROADCAST_RGB_FULL,
98 INTEL_BROADCAST_RGB_LIMITED,
101 struct intel_fb_view {
103 * The remap information used in the remapped and rotated views to
104 * create the DMA scatter-gather list for each FB color plane. This sg
105 * list is created along with the view type (gtt.type) specific
106 * i915_vma object and contains the list of FB object pages (reordered
107 * in the rotated view) that are visible in the view.
108 * In the normal view the FB object's backing store sg list is used
109 * directly and hence the remap information here is not used.
111 struct i915_gtt_view gtt;
114 * The GTT view (gtt.type) specific information for each FB color
115 * plane. In the normal GTT view all formats (up to 4 color planes),
116 * in the rotated and remapped GTT view all no-CCS formats (up to 2
117 * color planes) are supported.
119 * The view information shared by all FB color planes in the FB,
120 * like dst x/y and src/dst width, is stored separately in
123 struct i915_color_plane_view {
128 * bytes for 0/180 degree rotation
129 * pixels for 90/270 degree rotation
131 unsigned int mapping_stride;
132 unsigned int scanout_stride;
136 struct intel_framebuffer {
137 struct drm_framebuffer base;
138 struct intel_frontbuffer *frontbuffer;
140 /* Params to remap the FB pages and program the plane registers in each view. */
141 struct intel_fb_view normal_view;
143 struct intel_fb_view rotated_view;
144 struct intel_fb_view remapped_view;
147 struct i915_address_space *dpt_vm;
150 enum intel_hotplug_state {
151 INTEL_HOTPLUG_UNCHANGED,
152 INTEL_HOTPLUG_CHANGED,
156 struct intel_encoder {
157 struct drm_encoder base;
159 enum intel_output_type type;
163 enum intel_hotplug_state (*hotplug)(struct intel_encoder *encoder,
164 struct intel_connector *connector);
165 enum intel_output_type (*compute_output_type)(struct intel_encoder *,
166 struct intel_crtc_state *,
167 struct drm_connector_state *);
168 int (*compute_config)(struct intel_encoder *,
169 struct intel_crtc_state *,
170 struct drm_connector_state *);
171 int (*compute_config_late)(struct intel_encoder *,
172 struct intel_crtc_state *,
173 struct drm_connector_state *);
174 void (*pre_pll_enable)(struct intel_atomic_state *,
175 struct intel_encoder *,
176 const struct intel_crtc_state *,
177 const struct drm_connector_state *);
178 void (*pre_enable)(struct intel_atomic_state *,
179 struct intel_encoder *,
180 const struct intel_crtc_state *,
181 const struct drm_connector_state *);
182 void (*enable)(struct intel_atomic_state *,
183 struct intel_encoder *,
184 const struct intel_crtc_state *,
185 const struct drm_connector_state *);
186 void (*disable)(struct intel_atomic_state *,
187 struct intel_encoder *,
188 const struct intel_crtc_state *,
189 const struct drm_connector_state *);
190 void (*post_disable)(struct intel_atomic_state *,
191 struct intel_encoder *,
192 const struct intel_crtc_state *,
193 const struct drm_connector_state *);
194 void (*post_pll_disable)(struct intel_atomic_state *,
195 struct intel_encoder *,
196 const struct intel_crtc_state *,
197 const struct drm_connector_state *);
198 void (*update_pipe)(struct intel_atomic_state *,
199 struct intel_encoder *,
200 const struct intel_crtc_state *,
201 const struct drm_connector_state *);
202 void (*audio_enable)(struct intel_encoder *encoder,
203 const struct intel_crtc_state *crtc_state,
204 const struct drm_connector_state *conn_state);
205 void (*audio_disable)(struct intel_encoder *encoder,
206 const struct intel_crtc_state *old_crtc_state,
207 const struct drm_connector_state *old_conn_state);
208 /* Read out the current hw state of this connector, returning true if
209 * the encoder is active. If the encoder is enabled it also set the pipe
210 * it is connected to in the pipe parameter. */
211 bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
212 /* Reconstructs the equivalent mode flags for the current hardware
213 * state. This must be called _after_ display->get_pipe_config has
214 * pre-filled the pipe config. Note that intel_encoder->base.crtc must
215 * be set correctly before calling this function. */
216 void (*get_config)(struct intel_encoder *,
217 struct intel_crtc_state *pipe_config);
220 * Optional hook called during init/resume to sync any state
221 * stored in the encoder (eg. DP link parameters) wrt. the HW state.
223 void (*sync_state)(struct intel_encoder *encoder,
224 const struct intel_crtc_state *crtc_state);
227 * Optional hook, returning true if this encoder allows a fastset
228 * during the initial commit, false otherwise.
230 bool (*initial_fastset_check)(struct intel_encoder *encoder,
231 struct intel_crtc_state *crtc_state);
234 * Acquires the power domains needed for an active encoder during
235 * hardware state readout.
237 void (*get_power_domains)(struct intel_encoder *encoder,
238 struct intel_crtc_state *crtc_state);
240 * Called during system suspend after all pending requests for the
241 * encoder are flushed (for example for DP AUX transactions) and
242 * device interrupts are disabled.
243 * All modeset locks are held while the hook is called.
245 void (*suspend)(struct intel_encoder *);
247 * Called without the modeset locks held after the suspend() hook for
248 * all encoders have been called.
250 void (*suspend_complete)(struct intel_encoder *encoder);
252 * Called during system reboot/shutdown after all the
253 * encoders have been disabled and suspended.
254 * All modeset locks are held while the hook is called.
256 void (*shutdown)(struct intel_encoder *encoder);
258 * Called without the modeset locks held after the shutdown() hook for
259 * all encoders have been called.
261 void (*shutdown_complete)(struct intel_encoder *encoder);
263 * Enable/disable the clock to the port.
265 void (*enable_clock)(struct intel_encoder *encoder,
266 const struct intel_crtc_state *crtc_state);
267 void (*disable_clock)(struct intel_encoder *encoder);
269 * Returns whether the port clock is enabled or not.
271 bool (*is_clock_enabled)(struct intel_encoder *encoder);
273 * Returns the PLL type the port uses.
275 enum icl_port_dpll_id (*port_pll_type)(struct intel_encoder *encoder,
276 const struct intel_crtc_state *crtc_state);
277 const struct intel_ddi_buf_trans *(*get_buf_trans)(struct intel_encoder *encoder,
278 const struct intel_crtc_state *crtc_state,
280 void (*set_signal_levels)(struct intel_encoder *encoder,
281 const struct intel_crtc_state *crtc_state);
283 enum hpd_pin hpd_pin;
284 enum intel_display_power_domain power_domain;
286 /* VBT information for this encoder (may be NULL for older platforms) */
287 const struct intel_bios_encoder_data *devdata;
290 struct intel_panel_bl_funcs {
291 /* Connector and platform specific backlight functions */
292 int (*setup)(struct intel_connector *connector, enum pipe pipe);
293 u32 (*get)(struct intel_connector *connector, enum pipe pipe);
294 void (*set)(const struct drm_connector_state *conn_state, u32 level);
295 void (*disable)(const struct drm_connector_state *conn_state, u32 level);
296 void (*enable)(const struct intel_crtc_state *crtc_state,
297 const struct drm_connector_state *conn_state, u32 level);
298 u32 (*hz_to_pwm)(struct intel_connector *connector, u32 hz);
307 struct intel_vbt_panel_data {
308 struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */
309 struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */
313 unsigned int lvds_dither:1;
314 unsigned int bios_lvds_val; /* initial [PCH_]LVDS reg val in VBIOS */
318 u8 seamless_drrs_min_refresh_rate;
319 enum drrs_type drrs_type;
328 struct edp_power_seq pps;
329 u8 drrs_msa_timing_delay;
337 bool require_aux_wakeup;
339 int tp1_wakeup_time_us;
340 int tp2_tp3_wakeup_time_us;
341 int psr2_tp2_tp3_wakeup_time_us;
346 u16 brightness_precision_bits;
347 u16 hdr_dpcd_refresh_timeout;
350 u8 min_brightness; /* min_brightness/255 of max */
351 s8 controller; /* brightness controller number */
352 enum intel_backlight_type type;
358 struct mipi_config *config;
359 struct mipi_pps_data *pps;
365 const u8 *sequence[MIPI_SEQ_MAX];
366 u8 *deassert_seq; /* Used by fixup_mipi_sequences() */
367 enum drm_panel_orientation orientation;
372 /* Fixed EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
373 const struct drm_edid *fixed_edid;
375 struct list_head fixed_modes;
384 bool combination_mode; /* gen 2/4 only */
386 bool alternate_pwm_increment; /* lpt+ */
392 bool util_pin_active_low; /* bxt+ */
393 u8 controller; /* bxt+ only */
394 struct pwm_device *pwm;
395 struct pwm_state pwm_state;
400 struct drm_edp_backlight_info info;
407 struct backlight_device *device;
409 const struct intel_panel_bl_funcs *funcs;
410 const struct intel_panel_bl_funcs *pwm_funcs;
411 void (*power)(struct intel_connector *, bool enable);
414 struct intel_vbt_panel_data vbt;
417 struct intel_digital_port;
419 enum check_link_response {
420 HDCP_LINK_PROTECTED = 0,
421 HDCP_TOPOLOGY_CHANGE,
422 HDCP_LINK_INTEGRITY_FAILURE,
427 * This structure serves as a translation layer between the generic HDCP code
428 * and the bus-specific code. What that means is that HDCP over HDMI differs
429 * from HDCP over DP, so to account for these differences, we need to
430 * communicate with the receiver through this shim.
432 * For completeness, the 2 buses differ in the following ways:
434 * HDCP registers on the receiver are set via DP AUX for DP, and
435 * they are set via DDC for HDMI.
436 * - Receiver register offsets
437 * The offsets of the registers are different for DP vs. HDMI
438 * - Receiver register masks/offsets
439 * For instance, the ready bit for the KSV fifo is in a different
440 * place on DP vs HDMI
441 * - Receiver register names
442 * Seriously. In the DP spec, the 16-bit register containing
443 * downstream information is called BINFO, on HDMI it's called
444 * BSTATUS. To confuse matters further, DP has a BSTATUS register
445 * with a completely different definition.
447 * On HDMI, the ksv fifo is read all at once, whereas on DP it must
448 * be read 3 keys at a time
450 * Since Aksv is hidden in hardware, there's different procedures
451 * to send it over DP AUX vs DDC
453 struct intel_hdcp_shim {
454 /* Outputs the transmitter's An and Aksv values to the receiver. */
455 int (*write_an_aksv)(struct intel_digital_port *dig_port, u8 *an);
457 /* Reads the receiver's key selection vector */
458 int (*read_bksv)(struct intel_digital_port *dig_port, u8 *bksv);
461 * Reads BINFO from DP receivers and BSTATUS from HDMI receivers. The
462 * definitions are the same in the respective specs, but the names are
463 * different. Call it BSTATUS since that's the name the HDMI spec
464 * uses and it was there first.
466 int (*read_bstatus)(struct intel_digital_port *dig_port,
469 /* Determines whether a repeater is present downstream */
470 int (*repeater_present)(struct intel_digital_port *dig_port,
471 bool *repeater_present);
473 /* Reads the receiver's Ri' value */
474 int (*read_ri_prime)(struct intel_digital_port *dig_port, u8 *ri);
476 /* Determines if the receiver's KSV FIFO is ready for consumption */
477 int (*read_ksv_ready)(struct intel_digital_port *dig_port,
480 /* Reads the ksv fifo for num_downstream devices */
481 int (*read_ksv_fifo)(struct intel_digital_port *dig_port,
482 int num_downstream, u8 *ksv_fifo);
484 /* Reads a 32-bit part of V' from the receiver */
485 int (*read_v_prime_part)(struct intel_digital_port *dig_port,
488 /* Enables HDCP signalling on the port */
489 int (*toggle_signalling)(struct intel_digital_port *dig_port,
490 enum transcoder cpu_transcoder,
493 /* Enable/Disable stream encryption on DP MST Transport Link */
494 int (*stream_encryption)(struct intel_connector *connector,
497 /* Ensures the link is still protected */
498 bool (*check_link)(struct intel_digital_port *dig_port,
499 struct intel_connector *connector);
501 /* Detects panel's hdcp capability. This is optional for HDMI. */
502 int (*hdcp_get_capability)(struct intel_digital_port *dig_port,
505 /* HDCP adaptation(DP/HDMI) required on the port */
506 enum hdcp_wired_protocol protocol;
508 /* Detects whether sink is HDCP2.2 capable */
509 int (*hdcp_2_2_get_capability)(struct intel_connector *connector,
512 /* Write HDCP2.2 messages */
513 int (*write_2_2_msg)(struct intel_connector *connector,
514 void *buf, size_t size);
516 /* Read HDCP2.2 messages */
517 int (*read_2_2_msg)(struct intel_connector *connector,
518 u8 msg_id, void *buf, size_t size);
521 * Implementation of DP HDCP2.2 Errata for the communication of stream
522 * type to Receivers. In DP HDCP2.2 Stream type is one of the input to
523 * the HDCP2.2 Cipher for En/De-Cryption. Not applicable for HDMI.
525 int (*config_stream_type)(struct intel_connector *connector,
526 bool is_repeater, u8 type);
528 /* Enable/Disable HDCP 2.2 stream encryption on DP MST Transport Link */
529 int (*stream_2_2_encryption)(struct intel_connector *connector,
532 /* HDCP2.2 Link Integrity Check */
533 int (*check_2_2_link)(struct intel_digital_port *dig_port,
534 struct intel_connector *connector);
536 /* HDCP remote sink cap */
537 int (*get_remote_hdcp_capability)(struct intel_connector *connector,
538 bool *hdcp_capable, bool *hdcp2_capable);
542 const struct intel_hdcp_shim *shim;
543 /* Mutex for hdcp state of the connector */
546 struct delayed_work check_work;
547 struct work_struct prop_work;
549 /* HDCP1.4 Encryption status */
552 /* HDCP2.2 related definitions */
553 /* Flag indicates whether this connector supports HDCP2.2 or not. */
554 bool hdcp2_supported;
556 /* HDCP2.2 Encryption status */
557 bool hdcp2_encrypted;
560 * Content Stream Type defined by content owner. TYPE0(0x0) content can
561 * flow in the link protected by HDCP2.2 or HDCP1.4, where as TYPE1(0x1)
562 * content can flow only through a link protected by HDCP2.2.
570 * Count of ReceiverID_List received. Initialized to 0 at AKE_INIT.
571 * Incremented after processing the RepeaterAuth_Send_ReceiverID_List.
572 * When it rolls over re-auth has to be triggered.
577 * Count of RepeaterAuth_Stream_Manage msg propagated.
578 * Initialized to 0 on AKE_INIT. Incremented after every successful
579 * transmission of RepeaterAuth_Stream_Manage message. When it rolls
580 * over re-Auth has to be triggered.
585 * Work queue to signal the CP_IRQ. Used for the waiters to read the
586 * available information from HDCP DP sink.
588 wait_queue_head_t cp_irq_queue;
589 atomic_t cp_irq_count;
590 int cp_irq_count_cached;
593 * HDCP register access for gen12+ need the transcoder associated.
594 * Transcoder attached to the connector could be changed at modeset.
595 * Hence caching the transcoder here.
597 enum transcoder cpu_transcoder;
598 /* Only used for DP MST stream encryption */
599 enum transcoder stream_transcoder;
602 struct intel_connector {
603 struct drm_connector base;
605 * The fixed encoder this connector is connected to.
607 struct intel_encoder *encoder;
609 /* ACPI device id for ACPI and driver cooperation */
612 /* Reads out the current hw, returning true if the connector is enabled
613 * and active (i.e. dpms ON state). */
614 bool (*get_hw_state)(struct intel_connector *);
617 * Optional hook called during init/resume to sync any state
618 * stored in the connector (eg. DSC state) wrt. the HW state.
620 void (*sync_state)(struct intel_connector *connector,
621 const struct intel_crtc_state *crtc_state);
623 /* Panel info for eDP and LVDS */
624 struct intel_panel panel;
626 /* Cached EDID for detect. */
627 const struct drm_edid *detect_edid;
629 /* Number of times hotplug detection was tried after an HPD interrupt */
632 /* since POLL and HPD connectors may use the same HPD line keep the native
633 state of connector->polled in case hotplug storm detection changes it */
636 struct drm_dp_mst_port *port;
638 struct intel_dp *mst_port;
640 bool force_bigjoiner_enable;
643 struct drm_dp_aux *dsc_decompression_aux;
644 u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE];
647 u8 dsc_hblank_expansion_quirk:1;
648 u8 dsc_decompression_enabled:1;
651 /* Work struct to schedule a uevent on link train failure */
652 struct work_struct modeset_retry_work;
654 struct intel_hdcp hdcp;
657 struct intel_digital_connector_state {
658 struct drm_connector_state base;
660 enum hdmi_force_audio force_audio;
664 #define to_intel_digital_connector_state(x) container_of(x, struct intel_digital_connector_state, base)
678 struct intel_atomic_state {
679 struct drm_atomic_state base;
681 intel_wakeref_t wakeref;
683 struct __intel_global_objs_state *global_objs;
686 /* Internal commit, as opposed to userspace/client initiated one */
689 bool dpll_set, modeset;
691 struct intel_shared_dpll_state shared_dpll[I915_NUM_PLLS];
693 struct intel_dp_tunnel_inherited_state *inherited_dp_tunnels;
696 * Current watermarks can't be trusted during hardware readout, so
697 * don't bother calculating intermediate watermarks.
699 bool skip_intermediate_wm;
701 bool rps_interactive;
704 struct intel_plane_state {
705 struct drm_plane_state uapi;
708 * actual hardware state, the state we program to the hardware.
709 * The following members are used to verify the hardware state:
710 * During initial hw readout, they need to be copied from uapi.
713 struct drm_crtc *crtc;
714 struct drm_framebuffer *fb;
717 u16 pixel_blend_mode;
718 unsigned int rotation;
719 enum drm_color_encoding color_encoding;
720 enum drm_color_range color_range;
721 enum drm_scaling_filter scaling_filter;
724 struct i915_vma *ggtt_vma;
725 struct i915_vma *dpt_vma;
727 #define PLANE_HAS_FENCE BIT(0)
729 struct intel_fb_view view;
731 /* Plane pxp decryption state */
734 /* Plane state to display black pixels when pxp is borked */
737 /* plane control register */
740 /* plane color control register */
743 /* chroma upsampler control register */
748 * = -1 : not using a scaler
749 * >= 0 : using a scalers
751 * plane requiring a scaler:
752 * - During check_plane, its bit is set in
753 * crtc_state->scaler_state.scaler_users by calling helper function
754 * update_scaler_plane.
755 * - scaler_id indicates the scaler it got assigned.
757 * plane doesn't require a scaler:
758 * - this can happen when scaling is no more required or plane simply
760 * - During check_plane, corresponding bit is reset in
761 * crtc_state->scaler_state.scaler_users by calling helper function
762 * update_scaler_plane.
767 * planar_linked_plane:
769 * ICL planar formats require 2 planes that are updated as pairs.
770 * This member is used to make sure the other plane is also updated
771 * when required, and for update_slave() to find the correct
772 * plane_state to pass as argument.
774 struct intel_plane *planar_linked_plane;
778 * If set don't update use the linked plane's state for updating
779 * this plane during atomic commit with the update_slave() callback.
781 * It's also used by the watermark code to ignore wm calculations on
782 * this plane. They're calculated by the linked plane's wm code.
786 struct drm_intel_sprite_colorkey ckey;
788 struct drm_rect psr2_sel_fetch_area;
790 /* Clear Color Value */
793 const char *no_fbc_reason;
796 struct intel_initial_plane_config {
797 struct intel_framebuffer *fb;
798 struct intel_memory_region *mem;
799 resource_size_t phys_base;
800 struct i915_vma *vma;
807 struct intel_scaler {
812 struct intel_crtc_scaler_state {
813 #define SKL_NUM_SCALERS 2
814 struct intel_scaler scalers[SKL_NUM_SCALERS];
817 * scaler_users: keeps track of users requesting scalers on this crtc.
819 * If a bit is set, a user is using a scaler.
820 * Here user can be a plane or crtc as defined below:
821 * bits 0-30 - plane (bit position is index from drm_plane_index)
824 * Instead of creating a new index to cover planes and crtc, using
825 * existing drm_plane_index for planes which is well less than 31
826 * planes and bit 31 for crtc. This should be fine to cover all
829 * intel_atomic_setup_scalers will setup available scalers to users
830 * requesting scalers. It will gracefully fail if request exceeds
833 #define SKL_CRTC_INDEX 31
834 unsigned scaler_users;
836 /* scaler used by crtc for panel fitting purpose */
840 /* {crtc,crtc_state}->mode_flags */
841 /* Flag to get scanline using frame time stamps */
842 #define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1)
843 /* Flag to use the scanline counter instead of the pixel counter */
844 #define I915_MODE_FLAG_USE_SCANLINE_COUNTER (1<<2)
846 * TE0 or TE1 flag is set if the crtc has a DSI encoder which
847 * is operating in command mode.
848 * Flag to use TE from DSI0 instead of VBI in command mode
850 #define I915_MODE_FLAG_DSI_USE_TE0 (1<<3)
851 /* Flag to use TE from DSI1 instead of VBI in command mode */
852 #define I915_MODE_FLAG_DSI_USE_TE1 (1<<4)
853 /* Flag to indicate mipi dsi periodic command mode where we do not get TE */
854 #define I915_MODE_FLAG_DSI_PERIODIC_CMD_MODE (1<<5)
855 /* Do tricks to make vblank timestamps sane with VRR? */
856 #define I915_MODE_FLAG_VRR (1<<6)
858 struct intel_wm_level {
866 struct intel_pipe_wm {
867 struct intel_wm_level wm[5];
870 bool sprites_enabled;
874 struct skl_wm_level {
883 struct skl_plane_wm {
884 struct skl_wm_level wm[8];
885 struct skl_wm_level uv_wm[8];
886 struct skl_wm_level trans_wm;
888 struct skl_wm_level wm0;
889 struct skl_wm_level trans_wm;
895 struct skl_plane_wm planes[I915_MAX_PLANES];
902 VLV_WM_LEVEL_DDR_DVFS,
906 struct vlv_wm_state {
907 struct g4x_pipe_wm wm[NUM_VLV_WM_LEVELS];
908 struct g4x_sr_wm sr[NUM_VLV_WM_LEVELS];
913 struct vlv_fifo_state {
914 u16 plane[I915_MAX_PLANES];
924 struct g4x_wm_state {
925 struct g4x_pipe_wm wm;
927 struct g4x_sr_wm hpll;
933 struct intel_crtc_wm_state {
937 * The "raw" watermark values produced by the formula
938 * given the plane's current state. They do not consider
939 * how much FIFO is actually allocated for each plane.
942 * The "optimal" watermark values given the current
943 * state of the planes and the amount of FIFO
944 * allocated to each, ignoring any previous state
948 * The "intermediate" watermark values when transitioning
949 * between the old and new "optimal" values. Used when
950 * the watermark registers are single buffered and hence
951 * their state changes asynchronously with regards to the
952 * actual plane registers. These are essentially the
953 * worst case combination of the old and new "optimal"
954 * watermarks, which are therefore safe to use when the
955 * plane is in either its old or new state.
958 struct intel_pipe_wm intermediate;
959 struct intel_pipe_wm optimal;
963 struct skl_pipe_wm raw;
964 /* gen9+ only needs 1-step wm programming */
965 struct skl_pipe_wm optimal;
966 struct skl_ddb_entry ddb;
968 * pre-icl: for packed/planar CbCr
969 * icl+: for everything
971 struct skl_ddb_entry plane_ddb[I915_MAX_PLANES];
972 /* pre-icl: for planar Y */
973 struct skl_ddb_entry plane_ddb_y[I915_MAX_PLANES];
977 struct g4x_pipe_wm raw[NUM_VLV_WM_LEVELS]; /* not inverted */
978 struct vlv_wm_state intermediate; /* inverted */
979 struct vlv_wm_state optimal; /* inverted */
980 struct vlv_fifo_state fifo_state;
984 struct g4x_pipe_wm raw[NUM_G4X_WM_LEVELS];
985 struct g4x_wm_state intermediate;
986 struct g4x_wm_state optimal;
991 * Platforms with two-step watermark programming will need to
992 * update watermark programming post-vblank to switch from the
993 * safe intermediate watermarks to the optimal final
996 bool need_postvbl_update;
999 enum intel_output_format {
1000 INTEL_OUTPUT_FORMAT_RGB,
1001 INTEL_OUTPUT_FORMAT_YCBCR420,
1002 INTEL_OUTPUT_FORMAT_YCBCR444,
1005 struct intel_mpllb_state {
1006 u32 clock; /* in KHz */
1017 /* Used by dp and fdi links */
1018 struct intel_link_m_n {
1026 struct intel_csc_matrix {
1032 struct intel_c10pll_state {
1033 u32 clock; /* in KHz */
1039 struct intel_c20pll_state {
1040 u32 clock; /* in kHz */
1049 struct intel_cx0pll_state {
1051 struct intel_c10pll_state c10;
1052 struct intel_c20pll_state c20;
1057 struct intel_crtc_state {
1059 * uapi (drm) state. This is the software state shown to userspace.
1060 * In particular, the following members are used for bookkeeping:
1068 struct drm_crtc_state uapi;
1071 * actual hardware state, the state we program to the hardware.
1072 * The following members are used to verify the hardware state:
1075 * - mode / pipe_mode / adjusted_mode
1076 * - color property blobs.
1078 * During initial hw readout, they need to be copied to uapi.
1080 * Bigjoiner will allow a transcoder mode that spans 2 pipes;
1081 * Use the pipe_mode for calculations like watermarks, pipe
1082 * scaler, and bandwidth.
1084 * Use adjusted_mode for things that need to know the full
1085 * mode on the transcoder, which spans all pipes.
1088 bool active, enable;
1089 /* logical state of LUTs */
1090 struct drm_property_blob *degamma_lut, *gamma_lut, *ctm;
1091 struct drm_display_mode mode, pipe_mode, adjusted_mode;
1092 enum drm_scaling_filter scaling_filter;
1095 /* actual state of LUTs */
1096 struct drm_property_blob *pre_csc_lut, *post_csc_lut;
1098 struct intel_csc_matrix csc, output_csc;
1101 * quirks - bitfield with hw state readout quirks
1103 * For various reasons the hw state readout code might not be able to
1104 * completely faithfully read out the current state. These cases are
1105 * tracked with quirk flags so that fastboot and state checker can act
1108 #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
1109 unsigned long quirks;
1111 unsigned fb_bits; /* framebuffers to flip */
1112 bool update_pipe; /* can a fast modeset be performed? */
1113 bool update_m_n; /* update M/N seamlessly during fastset? */
1114 bool update_lrr; /* update TRANS_VTOTAL/etc. during fastset? */
1116 bool update_wm_pre, update_wm_post; /* watermarks are updated */
1117 bool fifo_changed; /* FIFO split is changed */
1119 bool inherited; /* state inherited from BIOS? */
1121 /* Ask the hardware to actually async flip? */
1124 /* Pipe source size (ie. panel fitter input size)
1125 * All planes will be positioned inside this space,
1126 * and get clipped at the edges. */
1127 struct drm_rect pipe_src;
1130 * Pipe pixel rate, adjusted for
1131 * panel fitter/pipe scaler downscaling.
1133 unsigned int pixel_rate;
1135 /* Whether to set up the PCH/FDI. Note that we never allow sharing
1136 * between pch encoders and cpu encoders. */
1137 bool has_pch_encoder;
1139 /* Are we sending infoframes on the attached port */
1142 /* CPU Transcoder for the pipe. Currently this can only differ from the
1143 * pipe on Haswell and later (where we have a special eDP transcoder)
1144 * and Broxton (where we have special DSI transcoders). */
1145 enum transcoder cpu_transcoder;
1148 * Use reduced/limited/broadcast rbg range, compressing from the full
1149 * range fed into the crtcs.
1151 bool limited_color_range;
1153 /* Bitmask of encoder types (enum intel_output_type)
1154 * driven by the pipe.
1156 unsigned int output_types;
1158 /* Whether we should send NULL infoframes. Required for audio. */
1161 /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
1162 * has_dp_encoder is set. */
1166 * Enable dithering, used when the selected pipe bpp doesn't match the
1172 * Dither gets enabled for 18bpp which causes CRC mismatch errors for
1173 * compliance video pattern tests.
1174 * Disable dither only if it is a compliance test request for
1177 bool dither_force_disable;
1179 /* Controls for the clock computation, to override various stages. */
1182 /* SDVO TV has a bunch of special case. To make multifunction encoders
1183 * work correctly, we need to track this at runtime.*/
1187 * crtc bandwidth limit, don't increase pipe bpp or clock if not really
1188 * required. This is set in the 2nd loop of calling encoder's
1189 * ->compute_config if the first pick doesn't work out.
1191 bool bw_constrained;
1193 /* Settings for the intel dpll used on pretty much everything but
1197 /* Selected dpll when shared or NULL. */
1198 struct intel_shared_dpll *shared_dpll;
1200 /* Actual register state of the dpll, for shared dpll cross-checking. */
1202 struct intel_dpll_hw_state dpll_hw_state;
1203 struct intel_mpllb_state mpllb_state;
1204 struct intel_cx0pll_state cx0pll_state;
1208 * ICL reserved DPLLs for the CRTC/port. The active PLL is selected by
1209 * setting shared_dpll and dpll_hw_state to one of these reserved ones.
1211 struct icl_port_dpll {
1212 struct intel_shared_dpll *pll;
1213 struct intel_dpll_hw_state hw_state;
1214 } icl_port_dplls[ICL_PORT_DPLL_COUNT];
1216 /* DSI PLL registers */
1221 int max_link_bpp_x16; /* in 1/16 bpp units */
1222 int pipe_bpp; /* in 1 bpp units */
1223 struct intel_link_m_n dp_m_n;
1225 /* m2_n2 for eDP downclock */
1226 struct intel_link_m_n dp_m2_n2;
1229 /* PSR is supported but might not be enabled due the lack of enabled planes */
1232 bool enable_psr2_sel_fetch;
1233 bool enable_psr2_su_region_et;
1234 bool req_psr2_sdp_prior_scanline;
1235 bool has_panel_replay;
1236 bool wm_level_disabled;
1238 u16 su_y_granularity;
1241 * Frequence the dpll for the port should run at. Differs from the
1242 * adjusted dotclock e.g. for DP or 10/12bpc hdmi mode. This is also
1243 * already multiplied by pixel_multiplier.
1247 /* Used by SDVO (and if we ever fix it, HDMI). */
1248 unsigned pixel_multiplier;
1250 /* I915_MODE_FLAG_* */
1256 * Used by platforms having DP/HDMI PHY with programmable lane
1257 * latency optimization.
1259 u8 lane_lat_optim_mask;
1261 /* minimum acceptable voltage level */
1262 u8 min_voltage_level;
1264 /* Panel fitter controls for gen2-gen4 + VLV */
1268 u32 lvds_border_bits;
1271 /* Panel fitter placement and size for Ironlake+ */
1273 struct drm_rect dst;
1278 /* FDI configuration, only valid if has_pch_encoder is set. */
1280 struct intel_link_m_n fdi_m_n;
1290 struct intel_crtc_scaler_state scaler_state;
1292 /* w/a for waiting 2 vblanks during crtc enable */
1293 enum pipe hsw_workaround_pipe;
1295 /* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */
1298 struct intel_crtc_wm_state wm;
1300 int min_cdclk[I915_MAX_PLANES];
1302 /* for packed/planar CbCr */
1303 u32 data_rate[I915_MAX_PLANES];
1305 u32 data_rate_y[I915_MAX_PLANES];
1307 /* FIXME unify with data_rate[]? */
1308 u64 rel_data_rate[I915_MAX_PLANES];
1309 u64 rel_data_rate_y[I915_MAX_PLANES];
1311 /* Gamma mode programmed on the pipe */
1315 /* CSC mode programmed on the pipe */
1322 /* bitmask of logically enabled planes (enum plane_id) */
1325 /* bitmask of actually visible planes (enum plane_id) */
1331 /* bitmask of planes that will be updated during the commit */
1334 /* bitmask of planes with async flip active */
1335 u8 async_flip_planes;
1337 u8 framestart_delay; /* 1-4 */
1338 u8 msa_timing_delay; /* 0-3 */
1343 union hdmi_infoframe avi;
1344 union hdmi_infoframe spd;
1345 union hdmi_infoframe hdmi;
1346 union hdmi_infoframe drm;
1347 struct drm_dp_vsc_sdp vsc;
1350 u8 eld[MAX_ELD_BYTES];
1352 /* HDMI scrambling status */
1353 bool hdmi_scrambling;
1355 /* HDMI High TMDS char rate ratio */
1356 bool hdmi_high_tmds_clock_ratio;
1359 * Output format RGB/YCBCR etc., that is coming out
1360 * at the end of the pipe.
1362 enum intel_output_format output_format;
1365 * Sink output format RGB/YCBCR etc., that is going
1368 enum intel_output_format sink_format;
1370 /* enable pipe gamma? */
1373 /* enable pipe csc? */
1376 /* enable vlv/chv wgc csc? */
1379 /* big joiner pipe bitmask */
1382 /* Display Stream compression state */
1384 bool compression_enable;
1386 /* Compressed Bpp in U6.4 format (first 4 bits for fractional part) */
1387 u16 compressed_bpp_x16;
1389 struct drm_dsc_config config;
1392 /* DP tunnel used for BW allocation. */
1393 struct drm_dp_tunnel_ref dp_tunnel_ref;
1395 /* HSW+ linetime watermarks */
1399 bool enhanced_framing;
1402 * Forward Error Correction.
1404 * Note: This will be false for 128b/132b, which will always have FEC
1405 * enabled automatically.
1409 bool sdp_split_enable;
1411 /* Pointer to master transcoder in case of tiled displays */
1412 enum transcoder master_transcoder;
1414 /* Bitmask to indicate slaves attached */
1415 u8 sync_mode_slaves_mask;
1417 /* Only valid on TGL+ */
1418 enum transcoder mst_master_transcoder;
1420 /* For DSB related info */
1421 struct intel_dsb *dsb;
1423 u32 psr2_man_track_ctl;
1425 struct drm_rect psr2_su_area;
1427 /* Variable Refresh Rate state */
1429 bool enable, in_range;
1431 u16 flipline, vmin, vmax, guardband;
1434 /* Stream Splitter for eDP MSO */
1441 /* for loading single buffered registers during vblank */
1442 struct drm_vblank_work vblank_work;
1445 enum intel_pipe_crc_source {
1446 INTEL_PIPE_CRC_SOURCE_NONE,
1447 INTEL_PIPE_CRC_SOURCE_PLANE1,
1448 INTEL_PIPE_CRC_SOURCE_PLANE2,
1449 INTEL_PIPE_CRC_SOURCE_PLANE3,
1450 INTEL_PIPE_CRC_SOURCE_PLANE4,
1451 INTEL_PIPE_CRC_SOURCE_PLANE5,
1452 INTEL_PIPE_CRC_SOURCE_PLANE6,
1453 INTEL_PIPE_CRC_SOURCE_PLANE7,
1454 INTEL_PIPE_CRC_SOURCE_PIPE,
1455 /* TV/DP on pre-gen5/vlv can't use the pipe source. */
1456 INTEL_PIPE_CRC_SOURCE_TV,
1457 INTEL_PIPE_CRC_SOURCE_DP_B,
1458 INTEL_PIPE_CRC_SOURCE_DP_C,
1459 INTEL_PIPE_CRC_SOURCE_DP_D,
1460 INTEL_PIPE_CRC_SOURCE_AUTO,
1461 INTEL_PIPE_CRC_SOURCE_MAX,
1464 enum drrs_refresh_rate {
1465 DRRS_REFRESH_RATE_HIGH,
1466 DRRS_REFRESH_RATE_LOW,
1469 #define INTEL_PIPE_CRC_ENTRIES_NR 128
1470 struct intel_pipe_crc {
1473 enum intel_pipe_crc_source source;
1477 struct drm_crtc base;
1480 * Whether the crtc and the connected output pipeline is active. Implies
1481 * that crtc->enabled is set, i.e. the current mode configuration has
1482 * some outputs connected to this crtc.
1487 /* I915_MODE_FLAG_* */
1490 u16 vmax_vblank_start;
1492 struct intel_display_power_domain_set enabled_power_domains;
1493 struct intel_display_power_domain_set hw_readout_power_domains;
1494 struct intel_overlay *overlay;
1496 struct intel_crtc_state *config;
1498 /* armed event for async flip */
1499 struct drm_pending_vblank_event *flip_done_event;
1501 /* Access to these should be protected by dev_priv->irq_lock. */
1502 bool cpu_fifo_underrun_disabled;
1503 bool pch_fifo_underrun_disabled;
1505 /* per-pipe watermark state */
1507 /* watermarks currently being used */
1509 struct intel_pipe_wm ilk;
1510 struct vlv_wm_state vlv;
1511 struct g4x_wm_state g4x;
1517 struct delayed_work work;
1518 enum drrs_refresh_rate refresh_rate;
1519 unsigned int frontbuffer_bits;
1520 unsigned int busy_frontbuffer_bits;
1521 enum transcoder cpu_transcoder;
1522 struct intel_link_m_n m_n, m2_n2;
1525 int scanline_offset;
1528 unsigned start_vbl_count;
1529 ktime_t start_vbl_time;
1530 int min_vbl, max_vbl;
1532 #ifdef CONFIG_DRM_I915_DEBUG_VBLANK_EVADE
1538 unsigned int times[17]; /* [1us, 16ms] */
1543 /* scalers available on this crtc */
1546 /* for loading single buffered registers during vblank */
1547 struct pm_qos_request vblank_pm_qos;
1549 #ifdef CONFIG_DEBUG_FS
1550 struct intel_pipe_crc pipe_crc;
1554 struct intel_plane {
1555 struct drm_plane base;
1556 enum i9xx_plane_id i9xx_plane;
1559 bool need_async_flip_disable_wa;
1560 u32 frontbuffer_bit;
1563 u32 base, cntl, size;
1566 struct intel_fbc *fbc;
1569 * NOTE: Do not place new plane state fields here (e.g., when adding
1570 * new plane properties). New runtime state should now be placed in
1571 * the intel_plane_state structure and accessed via plane_state.
1574 int (*min_width)(const struct drm_framebuffer *fb,
1576 unsigned int rotation);
1577 int (*max_width)(const struct drm_framebuffer *fb,
1579 unsigned int rotation);
1580 int (*max_height)(const struct drm_framebuffer *fb,
1582 unsigned int rotation);
1583 unsigned int (*max_stride)(struct intel_plane *plane,
1584 u32 pixel_format, u64 modifier,
1585 unsigned int rotation);
1586 /* Write all non-self arming plane registers */
1587 void (*update_noarm)(struct intel_plane *plane,
1588 const struct intel_crtc_state *crtc_state,
1589 const struct intel_plane_state *plane_state);
1590 /* Write all self-arming plane registers */
1591 void (*update_arm)(struct intel_plane *plane,
1592 const struct intel_crtc_state *crtc_state,
1593 const struct intel_plane_state *plane_state);
1594 /* Disable the plane, must arm */
1595 void (*disable_arm)(struct intel_plane *plane,
1596 const struct intel_crtc_state *crtc_state);
1597 bool (*get_hw_state)(struct intel_plane *plane, enum pipe *pipe);
1598 int (*check_plane)(struct intel_crtc_state *crtc_state,
1599 struct intel_plane_state *plane_state);
1600 int (*min_cdclk)(const struct intel_crtc_state *crtc_state,
1601 const struct intel_plane_state *plane_state);
1602 void (*async_flip)(struct intel_plane *plane,
1603 const struct intel_crtc_state *crtc_state,
1604 const struct intel_plane_state *plane_state,
1606 void (*enable_flip_done)(struct intel_plane *plane);
1607 void (*disable_flip_done)(struct intel_plane *plane);
1610 struct intel_watermark_params {
1618 #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base)
1619 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
1620 #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, uapi)
1621 #define to_intel_connector(x) container_of(x, struct intel_connector, base)
1622 #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
1623 #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
1624 #define to_intel_plane(x) container_of(x, struct intel_plane, base)
1625 #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, uapi)
1626 #define intel_fb_obj(x) ((x) ? to_intel_bo((x)->obj[0]) : NULL)
1629 i915_reg_t hdmi_reg;
1631 enum drm_dp_dual_mode_type type;
1634 struct intel_connector *attached_connector;
1635 struct cec_notifier *cec_notifier;
1638 struct intel_dp_mst_encoder;
1640 struct intel_dp_compliance_data {
1643 u16 hdisplay, vdisplay;
1645 struct drm_dp_phy_test_params phytest;
1648 struct intel_dp_compliance {
1649 unsigned long test_type;
1650 struct intel_dp_compliance_data test_data;
1656 struct intel_dp_pcon_frl {
1658 int trained_rate_gbps;
1662 int panel_power_up_delay;
1663 int panel_power_down_delay;
1664 int panel_power_cycle_delay;
1665 int backlight_on_delay;
1666 int backlight_off_delay;
1667 struct delayed_work panel_vdd_work;
1668 bool want_panel_vdd;
1670 unsigned long last_power_on;
1671 unsigned long last_backlight_off;
1672 ktime_t panel_power_off_time;
1673 intel_wakeref_t vdd_wakeref;
1677 * Pipe whose power sequencer is currently locked into
1678 * this port. Only relevant on VLV/CHV.
1683 * Power sequencer index. Only relevant on BXT+.
1689 * Pipe currently driving the port. Used for preventing
1690 * the use of the PPS for any pipe currentrly driving
1691 * external DP as that will mess things up on VLV.
1693 enum pipe active_pipe;
1695 * Set if the sequencer may be reset due to a power transition,
1696 * requiring a reinitialization. Only relevant on BXT+.
1699 struct edp_power_seq pps_delays;
1700 struct edp_power_seq bios_pps_delays;
1704 /* Mutex for PSR state of the transcoder */
1707 #define I915_PSR_DEBUG_MODE_MASK 0x0f
1708 #define I915_PSR_DEBUG_DEFAULT 0x00
1709 #define I915_PSR_DEBUG_DISABLE 0x01
1710 #define I915_PSR_DEBUG_ENABLE 0x02
1711 #define I915_PSR_DEBUG_FORCE_PSR1 0x03
1712 #define I915_PSR_DEBUG_ENABLE_SEL_FETCH 0x4
1713 #define I915_PSR_DEBUG_IRQ 0x10
1714 #define I915_PSR_DEBUG_SU_REGION_ET_DISABLE 0x20
1718 bool source_support;
1722 enum transcoder transcoder;
1724 struct work_struct work;
1725 unsigned int busy_frontbuffer_bits;
1726 bool sink_psr2_support;
1729 bool psr2_sel_fetch_enabled;
1730 bool psr2_sel_fetch_cff_enabled;
1731 bool req_psr2_sdp_prior_scanline;
1732 u8 sink_sync_latency;
1738 /* LNL and beyond */
1739 u8 check_entry_lines;
1742 ktime_t last_entry_attempt;
1744 bool sink_not_reliable;
1746 u16 su_w_granularity;
1747 u16 su_y_granularity;
1748 bool source_panel_replay_support;
1749 bool sink_panel_replay_support;
1750 bool panel_replay_enabled;
1752 u32 dc3co_exit_delay;
1753 struct delayed_work dc3co_work;
1754 u8 entry_setup_frames;
1758 i915_reg_t output_reg;
1764 bool reset_link_params;
1765 bool use_max_params;
1766 u8 dpcd[DP_RECEIVER_CAP_SIZE];
1767 u8 psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
1768 u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
1769 u8 edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
1770 u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE];
1771 u8 lttpr_phy_caps[DP_MAX_LTTPR_COUNT][DP_LTTPR_PHY_CAP_SIZE];
1772 u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE];
1774 int num_source_rates;
1775 const int *source_rates;
1776 /* sink rates as reported by DP_MAX_LINK_RATE/DP_SUPPORTED_LINK_RATES */
1778 int sink_rates[DP_MAX_SUPPORTED_RATES];
1779 bool use_rate_select;
1780 /* Max sink lane count as reported by DP_MAX_LANE_COUNT */
1781 int max_sink_lane_count;
1782 /* intersection of source and sink rates */
1783 int num_common_rates;
1784 int common_rates[DP_MAX_SUPPORTED_RATES];
1785 /* Max lane count for the current link */
1786 int max_link_lane_count;
1787 /* Max rate for the current link */
1790 int mso_pixel_overlap;
1791 /* sink or branch descriptor */
1792 struct drm_dp_desc desc;
1793 struct drm_dp_aux aux;
1794 u32 aux_busy_last_status;
1797 struct intel_pps pps;
1800 int active_mst_links;
1802 /* connector directly attached - won't be use for modeset in mst world */
1803 struct intel_connector *attached_connector;
1805 struct drm_dp_tunnel *tunnel;
1806 bool tunnel_suspended:1;
1808 /* mst connector list */
1809 struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
1810 struct drm_dp_mst_topology_mgr mst_mgr;
1812 u32 (*get_aux_clock_divider)(struct intel_dp *dp, int index);
1814 * This function returns the value we have to program the AUX_CTL
1815 * register with to kick off an AUX transaction.
1817 u32 (*get_aux_send_ctl)(struct intel_dp *dp, int send_bytes,
1818 u32 aux_clock_divider);
1820 i915_reg_t (*aux_ch_ctl_reg)(struct intel_dp *dp);
1821 i915_reg_t (*aux_ch_data_reg)(struct intel_dp *dp, int index);
1823 /* This is called before a link training is starterd */
1824 void (*prepare_link_retrain)(struct intel_dp *intel_dp,
1825 const struct intel_crtc_state *crtc_state);
1826 void (*set_link_train)(struct intel_dp *intel_dp,
1827 const struct intel_crtc_state *crtc_state,
1829 void (*set_idle_link_train)(struct intel_dp *intel_dp,
1830 const struct intel_crtc_state *crtc_state);
1832 u8 (*preemph_max)(struct intel_dp *intel_dp);
1833 u8 (*voltage_max)(struct intel_dp *intel_dp,
1834 const struct intel_crtc_state *crtc_state);
1836 /* Displayport compliance testing */
1837 struct intel_dp_compliance compliance;
1839 /* Downstream facing port caps */
1841 int min_tmds_clock, max_tmds_clock;
1843 int pcon_max_frl_bw;
1845 bool ycbcr_444_to_420;
1846 bool ycbcr420_passthrough;
1850 /* To control wakeup latency, e.g. for irq-driven dp aux transfers. */
1851 struct pm_qos_request pm_qos;
1853 /* Display stream compression testing */
1855 int force_dsc_output_format;
1856 bool force_dsc_fractional_bpp_en;
1862 struct intel_dp_pcon_frl frl;
1864 struct intel_psr psr;
1866 /* When we last wrote the OUI for eDP */
1867 unsigned long last_oui_write;
1869 bool colorimetry_support;
1872 enum lspcon_vendor {
1874 LSPCON_VENDOR_PARADE
1877 struct intel_lspcon {
1880 enum drm_lspcon_mode mode;
1881 enum lspcon_vendor vendor;
1884 struct intel_digital_port {
1885 struct intel_encoder base;
1886 u32 saved_port_bits;
1888 struct intel_hdmi hdmi;
1889 struct intel_lspcon lspcon;
1890 enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
1891 bool release_cl2_override;
1893 /* Used for DP and ICL+ TypeC/DP and TypeC/HDMI ports. */
1895 enum intel_display_power_domain ddi_io_power_domain;
1896 intel_wakeref_t ddi_io_wakeref;
1897 intel_wakeref_t aux_wakeref;
1899 struct intel_tc_port *tc;
1901 /* protects num_hdcp_streams reference count, hdcp_port_data and hdcp_auth_status */
1902 struct mutex hdcp_mutex;
1903 /* the number of pipes using HDCP signalling out of this port */
1904 unsigned int num_hdcp_streams;
1905 /* port HDCP auth status */
1906 bool hdcp_auth_status;
1907 /* HDCP port data need to pass to security f/w */
1908 struct hdcp_port_data hdcp_port_data;
1909 /* Whether the MST topology supports HDCP Type 1 Content */
1910 bool hdcp_mst_type1_capable;
1912 void (*write_infoframe)(struct intel_encoder *encoder,
1913 const struct intel_crtc_state *crtc_state,
1915 const void *frame, ssize_t len);
1916 void (*read_infoframe)(struct intel_encoder *encoder,
1917 const struct intel_crtc_state *crtc_state,
1919 void *frame, ssize_t len);
1920 void (*set_infoframes)(struct intel_encoder *encoder,
1922 const struct intel_crtc_state *crtc_state,
1923 const struct drm_connector_state *conn_state);
1924 u32 (*infoframes_enabled)(struct intel_encoder *encoder,
1925 const struct intel_crtc_state *pipe_config);
1926 bool (*connected)(struct intel_encoder *encoder);
1928 void (*lock)(struct intel_digital_port *dig_port);
1929 void (*unlock)(struct intel_digital_port *dig_port);
1932 struct intel_dp_mst_encoder {
1933 struct intel_encoder base;
1935 struct intel_digital_port *primary;
1936 struct intel_connector *connector;
1939 static inline struct intel_encoder *
1940 intel_attached_encoder(struct intel_connector *connector)
1942 return connector->encoder;
1945 static inline bool intel_encoder_is_dig_port(struct intel_encoder *encoder)
1947 switch (encoder->type) {
1948 case INTEL_OUTPUT_DDI:
1949 case INTEL_OUTPUT_DP:
1950 case INTEL_OUTPUT_EDP:
1951 case INTEL_OUTPUT_HDMI:
1958 static inline bool intel_encoder_is_mst(struct intel_encoder *encoder)
1960 return encoder->type == INTEL_OUTPUT_DP_MST;
1963 static inline struct intel_dp_mst_encoder *
1964 enc_to_mst(struct intel_encoder *encoder)
1966 return container_of(&encoder->base, struct intel_dp_mst_encoder,
1970 static inline struct intel_digital_port *
1971 enc_to_dig_port(struct intel_encoder *encoder)
1973 struct intel_encoder *intel_encoder = encoder;
1975 if (intel_encoder_is_dig_port(intel_encoder))
1976 return container_of(&encoder->base, struct intel_digital_port,
1978 else if (intel_encoder_is_mst(intel_encoder))
1979 return enc_to_mst(encoder)->primary;
1984 static inline struct intel_digital_port *
1985 intel_attached_dig_port(struct intel_connector *connector)
1987 return enc_to_dig_port(intel_attached_encoder(connector));
1990 static inline struct intel_hdmi *
1991 enc_to_intel_hdmi(struct intel_encoder *encoder)
1993 return &enc_to_dig_port(encoder)->hdmi;
1996 static inline struct intel_hdmi *
1997 intel_attached_hdmi(struct intel_connector *connector)
1999 return enc_to_intel_hdmi(intel_attached_encoder(connector));
2002 static inline struct intel_dp *enc_to_intel_dp(struct intel_encoder *encoder)
2004 return &enc_to_dig_port(encoder)->dp;
2007 static inline struct intel_dp *intel_attached_dp(struct intel_connector *connector)
2009 return enc_to_intel_dp(intel_attached_encoder(connector));
2012 static inline bool intel_encoder_is_dp(struct intel_encoder *encoder)
2014 switch (encoder->type) {
2015 case INTEL_OUTPUT_DP:
2016 case INTEL_OUTPUT_EDP:
2018 case INTEL_OUTPUT_DDI:
2019 /* Skip pure HDMI/DVI DDI encoders */
2020 return i915_mmio_reg_valid(enc_to_intel_dp(encoder)->output_reg);
2026 static inline struct intel_lspcon *
2027 enc_to_intel_lspcon(struct intel_encoder *encoder)
2029 return &enc_to_dig_port(encoder)->lspcon;
2032 static inline struct intel_digital_port *
2033 dp_to_dig_port(struct intel_dp *intel_dp)
2035 return container_of(intel_dp, struct intel_digital_port, dp);
2038 static inline struct intel_lspcon *
2039 dp_to_lspcon(struct intel_dp *intel_dp)
2041 return &dp_to_dig_port(intel_dp)->lspcon;
2044 #define dp_to_i915(__intel_dp) to_i915(dp_to_dig_port(__intel_dp)->base.base.dev)
2046 static inline struct intel_digital_port *
2047 hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
2049 return container_of(intel_hdmi, struct intel_digital_port, hdmi);
2052 static inline struct intel_plane_state *
2053 intel_atomic_get_plane_state(struct intel_atomic_state *state,
2054 struct intel_plane *plane)
2056 struct drm_plane_state *ret =
2057 drm_atomic_get_plane_state(&state->base, &plane->base);
2060 return ERR_CAST(ret);
2062 return to_intel_plane_state(ret);
2065 static inline struct intel_plane_state *
2066 intel_atomic_get_old_plane_state(struct intel_atomic_state *state,
2067 struct intel_plane *plane)
2069 return to_intel_plane_state(drm_atomic_get_old_plane_state(&state->base,
2073 static inline struct intel_plane_state *
2074 intel_atomic_get_new_plane_state(struct intel_atomic_state *state,
2075 struct intel_plane *plane)
2077 return to_intel_plane_state(drm_atomic_get_new_plane_state(&state->base,
2081 static inline struct intel_crtc_state *
2082 intel_atomic_get_old_crtc_state(struct intel_atomic_state *state,
2083 struct intel_crtc *crtc)
2085 return to_intel_crtc_state(drm_atomic_get_old_crtc_state(&state->base,
2089 static inline struct intel_crtc_state *
2090 intel_atomic_get_new_crtc_state(struct intel_atomic_state *state,
2091 struct intel_crtc *crtc)
2093 return to_intel_crtc_state(drm_atomic_get_new_crtc_state(&state->base,
2097 static inline struct intel_digital_connector_state *
2098 intel_atomic_get_new_connector_state(struct intel_atomic_state *state,
2099 struct intel_connector *connector)
2101 return to_intel_digital_connector_state(
2102 drm_atomic_get_new_connector_state(&state->base,
2106 static inline struct intel_digital_connector_state *
2107 intel_atomic_get_old_connector_state(struct intel_atomic_state *state,
2108 struct intel_connector *connector)
2110 return to_intel_digital_connector_state(
2111 drm_atomic_get_old_connector_state(&state->base,
2115 /* intel_display.c */
2117 intel_crtc_has_type(const struct intel_crtc_state *crtc_state,
2118 enum intel_output_type type)
2120 return crtc_state->output_types & BIT(type);
2124 intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state)
2126 return crtc_state->output_types &
2127 (BIT(INTEL_OUTPUT_DP) |
2128 BIT(INTEL_OUTPUT_DP_MST) |
2129 BIT(INTEL_OUTPUT_EDP));
2133 intel_crtc_needs_modeset(const struct intel_crtc_state *crtc_state)
2135 return drm_atomic_crtc_needs_modeset(&crtc_state->uapi);
2139 intel_crtc_needs_fastset(const struct intel_crtc_state *crtc_state)
2141 return crtc_state->update_pipe;
2145 intel_crtc_needs_color_update(const struct intel_crtc_state *crtc_state)
2147 return crtc_state->uapi.color_mgmt_changed ||
2148 intel_crtc_needs_fastset(crtc_state) ||
2149 intel_crtc_needs_modeset(crtc_state);
2152 static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *plane_state)
2154 return i915_ggtt_offset(plane_state->ggtt_vma);
2157 static inline struct intel_frontbuffer *
2158 to_intel_frontbuffer(struct drm_framebuffer *fb)
2160 return fb ? to_intel_framebuffer(fb)->frontbuffer : NULL;
2163 static inline int to_bpp_int(int bpp_x16)
2165 return bpp_x16 >> 4;
2168 static inline int to_bpp_frac(int bpp_x16)
2170 return bpp_x16 & 0xf;
2173 #define BPP_X16_FMT "%d.%04d"
2174 #define BPP_X16_ARGS(bpp_x16) to_bpp_int(bpp_x16), (to_bpp_frac(bpp_x16) * 625)
2176 static inline int to_bpp_int_roundup(int bpp_x16)
2178 return (bpp_x16 + 0xf) >> 4;
2181 static inline int to_bpp_x16(int bpp)
2186 #endif /* __INTEL_DISPLAY_TYPES_H__ */