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/pm_qos.h>
32 #include <linux/pwm.h>
33 #include <linux/sched/clock.h>
35 #include <drm/dp/drm_dp_dual_mode_helper.h>
36 #include <drm/dp/drm_dp_mst_helper.h>
37 #include <drm/drm_atomic.h>
38 #include <drm/drm_crtc.h>
39 #include <drm/drm_dsc.h>
40 #include <drm/drm_encoder.h>
41 #include <drm/drm_fb_helper.h>
42 #include <drm/drm_fourcc.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_mei_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_power.h"
55 #include "intel_dpll_mgr.h"
56 #include "intel_pm_types.h"
59 struct __intel_global_objs_state;
60 struct intel_ddi_buf_trans;
62 struct intel_connector;
65 * Display related stuff
68 /* these are outputs from the chip - integrated only
69 external chips are via DVO or SDVO output */
70 enum intel_output_type {
71 INTEL_OUTPUT_UNUSED = 0,
72 INTEL_OUTPUT_ANALOG = 1,
74 INTEL_OUTPUT_SDVO = 3,
75 INTEL_OUTPUT_LVDS = 4,
76 INTEL_OUTPUT_TVOUT = 5,
77 INTEL_OUTPUT_HDMI = 6,
81 INTEL_OUTPUT_DDI = 10,
82 INTEL_OUTPUT_DP_MST = 11,
85 enum hdmi_force_audio {
86 HDMI_AUDIO_OFF_DVI = -2, /* no aux data for HDMI-DVI converter */
87 HDMI_AUDIO_OFF, /* force turn off HDMI audio */
88 HDMI_AUDIO_AUTO, /* trust EDID */
89 HDMI_AUDIO_ON, /* force turn on HDMI audio */
92 /* "Broadcast RGB" property */
93 enum intel_broadcast_rgb {
94 INTEL_BROADCAST_RGB_AUTO,
95 INTEL_BROADCAST_RGB_FULL,
96 INTEL_BROADCAST_RGB_LIMITED,
99 struct intel_fb_view {
101 * The remap information used in the remapped and rotated views to
102 * create the DMA scatter-gather list for each FB color plane. This sg
103 * list is created along with the view type (gtt.type) specific
104 * i915_vma object and contains the list of FB object pages (reordered
105 * in the rotated view) that are visible in the view.
106 * In the normal view the FB object's backing store sg list is used
107 * directly and hence the remap information here is not used.
109 struct i915_ggtt_view gtt;
112 * The GTT view (gtt.type) specific information for each FB color
113 * plane. In the normal GTT view all formats (up to 4 color planes),
114 * in the rotated and remapped GTT view all no-CCS formats (up to 2
115 * color planes) are supported.
117 * The view information shared by all FB color planes in the FB,
118 * like dst x/y and src/dst width, is stored separately in
121 struct i915_color_plane_view {
126 * bytes for 0/180 degree rotation
127 * pixels for 90/270 degree rotation
129 unsigned int mapping_stride;
130 unsigned int scanout_stride;
134 struct intel_framebuffer {
135 struct drm_framebuffer base;
136 struct intel_frontbuffer *frontbuffer;
138 /* Params to remap the FB pages and program the plane registers in each view. */
139 struct intel_fb_view normal_view;
141 struct intel_fb_view rotated_view;
142 struct intel_fb_view remapped_view;
145 struct i915_address_space *dpt_vm;
149 struct drm_fb_helper helper;
150 struct intel_framebuffer *fb;
151 struct i915_vma *vma;
152 unsigned long vma_flags;
153 async_cookie_t cookie;
156 /* Whether or not fbdev hpd processing is temporarily suspended */
157 bool hpd_suspended : 1;
158 /* Set when a hotplug was received while HPD processing was
161 bool hpd_waiting : 1;
163 /* Protects hpd_suspended */
164 struct mutex hpd_lock;
167 enum intel_hotplug_state {
168 INTEL_HOTPLUG_UNCHANGED,
169 INTEL_HOTPLUG_CHANGED,
173 struct intel_encoder {
174 struct drm_encoder base;
176 enum intel_output_type type;
180 enum intel_hotplug_state (*hotplug)(struct intel_encoder *encoder,
181 struct intel_connector *connector);
182 enum intel_output_type (*compute_output_type)(struct intel_encoder *,
183 struct intel_crtc_state *,
184 struct drm_connector_state *);
185 int (*compute_config)(struct intel_encoder *,
186 struct intel_crtc_state *,
187 struct drm_connector_state *);
188 int (*compute_config_late)(struct intel_encoder *,
189 struct intel_crtc_state *,
190 struct drm_connector_state *);
191 void (*update_prepare)(struct intel_atomic_state *,
192 struct intel_encoder *,
193 struct intel_crtc *);
194 void (*pre_pll_enable)(struct intel_atomic_state *,
195 struct intel_encoder *,
196 const struct intel_crtc_state *,
197 const struct drm_connector_state *);
198 void (*pre_enable)(struct intel_atomic_state *,
199 struct intel_encoder *,
200 const struct intel_crtc_state *,
201 const struct drm_connector_state *);
202 void (*enable)(struct intel_atomic_state *,
203 struct intel_encoder *,
204 const struct intel_crtc_state *,
205 const struct drm_connector_state *);
206 void (*update_complete)(struct intel_atomic_state *,
207 struct intel_encoder *,
208 struct intel_crtc *);
209 void (*disable)(struct intel_atomic_state *,
210 struct intel_encoder *,
211 const struct intel_crtc_state *,
212 const struct drm_connector_state *);
213 void (*post_disable)(struct intel_atomic_state *,
214 struct intel_encoder *,
215 const struct intel_crtc_state *,
216 const struct drm_connector_state *);
217 void (*post_pll_disable)(struct intel_atomic_state *,
218 struct intel_encoder *,
219 const struct intel_crtc_state *,
220 const struct drm_connector_state *);
221 void (*update_pipe)(struct intel_atomic_state *,
222 struct intel_encoder *,
223 const struct intel_crtc_state *,
224 const struct drm_connector_state *);
225 /* Read out the current hw state of this connector, returning true if
226 * the encoder is active. If the encoder is enabled it also set the pipe
227 * it is connected to in the pipe parameter. */
228 bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
229 /* Reconstructs the equivalent mode flags for the current hardware
230 * state. This must be called _after_ display->get_pipe_config has
231 * pre-filled the pipe config. Note that intel_encoder->base.crtc must
232 * be set correctly before calling this function. */
233 void (*get_config)(struct intel_encoder *,
234 struct intel_crtc_state *pipe_config);
237 * Optional hook called during init/resume to sync any state
238 * stored in the encoder (eg. DP link parameters) wrt. the HW state.
240 void (*sync_state)(struct intel_encoder *encoder,
241 const struct intel_crtc_state *crtc_state);
244 * Optional hook, returning true if this encoder allows a fastset
245 * during the initial commit, false otherwise.
247 bool (*initial_fastset_check)(struct intel_encoder *encoder,
248 struct intel_crtc_state *crtc_state);
251 * Acquires the power domains needed for an active encoder during
252 * hardware state readout.
254 void (*get_power_domains)(struct intel_encoder *encoder,
255 struct intel_crtc_state *crtc_state);
257 * Called during system suspend after all pending requests for the
258 * encoder are flushed (for example for DP AUX transactions) and
259 * device interrupts are disabled.
261 void (*suspend)(struct intel_encoder *);
263 * Called during system reboot/shutdown after all the
264 * encoders have been disabled and suspended.
266 void (*shutdown)(struct intel_encoder *encoder);
268 * Enable/disable the clock to the port.
270 void (*enable_clock)(struct intel_encoder *encoder,
271 const struct intel_crtc_state *crtc_state);
272 void (*disable_clock)(struct intel_encoder *encoder);
274 * Returns whether the port clock is enabled or not.
276 bool (*is_clock_enabled)(struct intel_encoder *encoder);
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;
285 /* for communication with audio component; protected by av_mutex */
286 const struct drm_connector *audio_connector;
288 /* VBT information for this encoder (may be NULL for older platforms) */
289 const struct intel_bios_encoder_data *devdata;
292 struct intel_panel_bl_funcs {
293 /* Connector and platform specific backlight functions */
294 int (*setup)(struct intel_connector *connector, enum pipe pipe);
295 u32 (*get)(struct intel_connector *connector, enum pipe pipe);
296 void (*set)(const struct drm_connector_state *conn_state, u32 level);
297 void (*disable)(const struct drm_connector_state *conn_state, u32 level);
298 void (*enable)(const struct intel_crtc_state *crtc_state,
299 const struct drm_connector_state *conn_state, u32 level);
300 u32 (*hz_to_pwm)(struct intel_connector *connector, u32 hz);
304 struct drm_display_mode *fixed_mode;
305 struct drm_display_mode *downclock_mode;
314 bool combination_mode; /* gen 2/4 only */
316 bool alternate_pwm_increment; /* lpt+ */
322 bool util_pin_active_low; /* bxt+ */
323 u8 controller; /* bxt+ only */
324 struct pwm_device *pwm;
325 struct pwm_state pwm_state;
330 struct drm_edp_backlight_info info;
337 struct backlight_device *device;
339 const struct intel_panel_bl_funcs *funcs;
340 const struct intel_panel_bl_funcs *pwm_funcs;
341 void (*power)(struct intel_connector *, bool enable);
345 struct intel_digital_port;
347 enum check_link_response {
348 HDCP_LINK_PROTECTED = 0,
349 HDCP_TOPOLOGY_CHANGE,
350 HDCP_LINK_INTEGRITY_FAILURE,
355 * This structure serves as a translation layer between the generic HDCP code
356 * and the bus-specific code. What that means is that HDCP over HDMI differs
357 * from HDCP over DP, so to account for these differences, we need to
358 * communicate with the receiver through this shim.
360 * For completeness, the 2 buses differ in the following ways:
362 * HDCP registers on the receiver are set via DP AUX for DP, and
363 * they are set via DDC for HDMI.
364 * - Receiver register offsets
365 * The offsets of the registers are different for DP vs. HDMI
366 * - Receiver register masks/offsets
367 * For instance, the ready bit for the KSV fifo is in a different
368 * place on DP vs HDMI
369 * - Receiver register names
370 * Seriously. In the DP spec, the 16-bit register containing
371 * downstream information is called BINFO, on HDMI it's called
372 * BSTATUS. To confuse matters further, DP has a BSTATUS register
373 * with a completely different definition.
375 * On HDMI, the ksv fifo is read all at once, whereas on DP it must
376 * be read 3 keys at a time
378 * Since Aksv is hidden in hardware, there's different procedures
379 * to send it over DP AUX vs DDC
381 struct intel_hdcp_shim {
382 /* Outputs the transmitter's An and Aksv values to the receiver. */
383 int (*write_an_aksv)(struct intel_digital_port *dig_port, u8 *an);
385 /* Reads the receiver's key selection vector */
386 int (*read_bksv)(struct intel_digital_port *dig_port, u8 *bksv);
389 * Reads BINFO from DP receivers and BSTATUS from HDMI receivers. The
390 * definitions are the same in the respective specs, but the names are
391 * different. Call it BSTATUS since that's the name the HDMI spec
392 * uses and it was there first.
394 int (*read_bstatus)(struct intel_digital_port *dig_port,
397 /* Determines whether a repeater is present downstream */
398 int (*repeater_present)(struct intel_digital_port *dig_port,
399 bool *repeater_present);
401 /* Reads the receiver's Ri' value */
402 int (*read_ri_prime)(struct intel_digital_port *dig_port, u8 *ri);
404 /* Determines if the receiver's KSV FIFO is ready for consumption */
405 int (*read_ksv_ready)(struct intel_digital_port *dig_port,
408 /* Reads the ksv fifo for num_downstream devices */
409 int (*read_ksv_fifo)(struct intel_digital_port *dig_port,
410 int num_downstream, u8 *ksv_fifo);
412 /* Reads a 32-bit part of V' from the receiver */
413 int (*read_v_prime_part)(struct intel_digital_port *dig_port,
416 /* Enables HDCP signalling on the port */
417 int (*toggle_signalling)(struct intel_digital_port *dig_port,
418 enum transcoder cpu_transcoder,
421 /* Enable/Disable stream encryption on DP MST Transport Link */
422 int (*stream_encryption)(struct intel_connector *connector,
425 /* Ensures the link is still protected */
426 bool (*check_link)(struct intel_digital_port *dig_port,
427 struct intel_connector *connector);
429 /* Detects panel's hdcp capability. This is optional for HDMI. */
430 int (*hdcp_capable)(struct intel_digital_port *dig_port,
433 /* HDCP adaptation(DP/HDMI) required on the port */
434 enum hdcp_wired_protocol protocol;
436 /* Detects whether sink is HDCP2.2 capable */
437 int (*hdcp_2_2_capable)(struct intel_digital_port *dig_port,
440 /* Write HDCP2.2 messages */
441 int (*write_2_2_msg)(struct intel_digital_port *dig_port,
442 void *buf, size_t size);
444 /* Read HDCP2.2 messages */
445 int (*read_2_2_msg)(struct intel_digital_port *dig_port,
446 u8 msg_id, void *buf, size_t size);
449 * Implementation of DP HDCP2.2 Errata for the communication of stream
450 * type to Receivers. In DP HDCP2.2 Stream type is one of the input to
451 * the HDCP2.2 Cipher for En/De-Cryption. Not applicable for HDMI.
453 int (*config_stream_type)(struct intel_digital_port *dig_port,
454 bool is_repeater, u8 type);
456 /* Enable/Disable HDCP 2.2 stream encryption on DP MST Transport Link */
457 int (*stream_2_2_encryption)(struct intel_connector *connector,
460 /* HDCP2.2 Link Integrity Check */
461 int (*check_2_2_link)(struct intel_digital_port *dig_port,
462 struct intel_connector *connector);
466 const struct intel_hdcp_shim *shim;
467 /* Mutex for hdcp state of the connector */
470 struct delayed_work check_work;
471 struct work_struct prop_work;
473 /* HDCP1.4 Encryption status */
476 /* HDCP2.2 related definitions */
477 /* Flag indicates whether this connector supports HDCP2.2 or not. */
478 bool hdcp2_supported;
480 /* HDCP2.2 Encryption status */
481 bool hdcp2_encrypted;
484 * Content Stream Type defined by content owner. TYPE0(0x0) content can
485 * flow in the link protected by HDCP2.2 or HDCP1.4, where as TYPE1(0x1)
486 * content can flow only through a link protected by HDCP2.2.
494 * Count of ReceiverID_List received. Initialized to 0 at AKE_INIT.
495 * Incremented after processing the RepeaterAuth_Send_ReceiverID_List.
496 * When it rolls over re-auth has to be triggered.
501 * Count of RepeaterAuth_Stream_Manage msg propagated.
502 * Initialized to 0 on AKE_INIT. Incremented after every successful
503 * transmission of RepeaterAuth_Stream_Manage message. When it rolls
504 * over re-Auth has to be triggered.
509 * Work queue to signal the CP_IRQ. Used for the waiters to read the
510 * available information from HDCP DP sink.
512 wait_queue_head_t cp_irq_queue;
513 atomic_t cp_irq_count;
514 int cp_irq_count_cached;
517 * HDCP register access for gen12+ need the transcoder associated.
518 * Transcoder attached to the connector could be changed at modeset.
519 * Hence caching the transcoder here.
521 enum transcoder cpu_transcoder;
522 /* Only used for DP MST stream encryption */
523 enum transcoder stream_transcoder;
526 struct intel_connector {
527 struct drm_connector base;
529 * The fixed encoder this connector is connected to.
531 struct intel_encoder *encoder;
533 /* ACPI device id for ACPI and driver cooperation */
536 /* Reads out the current hw, returning true if the connector is enabled
537 * and active (i.e. dpms ON state). */
538 bool (*get_hw_state)(struct intel_connector *);
540 /* Panel info for eDP and LVDS */
541 struct intel_panel panel;
543 /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
545 struct edid *detect_edid;
547 /* Number of times hotplug detection was tried after an HPD interrupt */
550 /* since POLL and HPD connectors may use the same HPD line keep the native
551 state of connector->polled in case hotplug storm detection changes it */
554 struct drm_dp_mst_port *port;
556 struct intel_dp *mst_port;
558 /* Work struct to schedule a uevent on link train failure */
559 struct work_struct modeset_retry_work;
561 struct intel_hdcp hdcp;
564 struct intel_digital_connector_state {
565 struct drm_connector_state base;
567 enum hdmi_force_audio force_audio;
571 #define to_intel_digital_connector_state(x) container_of(x, struct intel_digital_connector_state, base)
585 struct intel_atomic_state {
586 struct drm_atomic_state base;
588 intel_wakeref_t wakeref;
590 struct __intel_global_objs_state *global_objs;
593 bool dpll_set, modeset;
595 struct intel_shared_dpll_state shared_dpll[I915_NUM_PLLS];
598 * Current watermarks can't be trusted during hardware readout, so
599 * don't bother calculating intermediate watermarks.
601 bool skip_intermediate_wm;
603 bool rps_interactive;
605 struct i915_sw_fence commit_ready;
607 struct llist_node freed;
610 struct intel_plane_state {
611 struct drm_plane_state uapi;
614 * actual hardware state, the state we program to the hardware.
615 * The following members are used to verify the hardware state:
616 * During initial hw readout, they need to be copied from uapi.
619 struct drm_crtc *crtc;
620 struct drm_framebuffer *fb;
623 u16 pixel_blend_mode;
624 unsigned int rotation;
625 enum drm_color_encoding color_encoding;
626 enum drm_color_range color_range;
627 enum drm_scaling_filter scaling_filter;
630 struct i915_vma *ggtt_vma;
631 struct i915_vma *dpt_vma;
633 #define PLANE_HAS_FENCE BIT(0)
635 struct intel_fb_view view;
637 /* Plane pxp decryption state */
640 /* Plane state to display black pixels when pxp is borked */
643 /* plane control register */
646 /* plane color control register */
649 /* chroma upsampler control register */
654 * = -1 : not using a scaler
655 * >= 0 : using a scalers
657 * plane requiring a scaler:
658 * - During check_plane, its bit is set in
659 * crtc_state->scaler_state.scaler_users by calling helper function
660 * update_scaler_plane.
661 * - scaler_id indicates the scaler it got assigned.
663 * plane doesn't require a scaler:
664 * - this can happen when scaling is no more required or plane simply
666 * - During check_plane, corresponding bit is reset in
667 * crtc_state->scaler_state.scaler_users by calling helper function
668 * update_scaler_plane.
673 * planar_linked_plane:
675 * ICL planar formats require 2 planes that are updated as pairs.
676 * This member is used to make sure the other plane is also updated
677 * when required, and for update_slave() to find the correct
678 * plane_state to pass as argument.
680 struct intel_plane *planar_linked_plane;
684 * If set don't update use the linked plane's state for updating
685 * this plane during atomic commit with the update_slave() callback.
687 * It's also used by the watermark code to ignore wm calculations on
688 * this plane. They're calculated by the linked plane's wm code.
692 struct drm_intel_sprite_colorkey ckey;
694 struct drm_rect psr2_sel_fetch_area;
696 /* Clear Color Value */
699 const char *no_fbc_reason;
702 struct intel_initial_plane_config {
703 struct intel_framebuffer *fb;
704 struct i915_vma *vma;
711 struct intel_scaler {
716 struct intel_crtc_scaler_state {
717 #define SKL_NUM_SCALERS 2
718 struct intel_scaler scalers[SKL_NUM_SCALERS];
721 * scaler_users: keeps track of users requesting scalers on this crtc.
723 * If a bit is set, a user is using a scaler.
724 * Here user can be a plane or crtc as defined below:
725 * bits 0-30 - plane (bit position is index from drm_plane_index)
728 * Instead of creating a new index to cover planes and crtc, using
729 * existing drm_plane_index for planes which is well less than 31
730 * planes and bit 31 for crtc. This should be fine to cover all
733 * intel_atomic_setup_scalers will setup available scalers to users
734 * requesting scalers. It will gracefully fail if request exceeds
737 #define SKL_CRTC_INDEX 31
738 unsigned scaler_users;
740 /* scaler used by crtc for panel fitting purpose */
744 /* {crtc,crtc_state}->mode_flags */
745 /* Flag to get scanline using frame time stamps */
746 #define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1)
747 /* Flag to use the scanline counter instead of the pixel counter */
748 #define I915_MODE_FLAG_USE_SCANLINE_COUNTER (1<<2)
750 * TE0 or TE1 flag is set if the crtc has a DSI encoder which
751 * is operating in command mode.
752 * Flag to use TE from DSI0 instead of VBI in command mode
754 #define I915_MODE_FLAG_DSI_USE_TE0 (1<<3)
755 /* Flag to use TE from DSI1 instead of VBI in command mode */
756 #define I915_MODE_FLAG_DSI_USE_TE1 (1<<4)
757 /* Flag to indicate mipi dsi periodic command mode where we do not get TE */
758 #define I915_MODE_FLAG_DSI_PERIODIC_CMD_MODE (1<<5)
759 /* Do tricks to make vblank timestamps sane with VRR? */
760 #define I915_MODE_FLAG_VRR (1<<6)
762 struct intel_wm_level {
770 struct intel_pipe_wm {
771 struct intel_wm_level wm[5];
774 bool sprites_enabled;
778 struct skl_wm_level {
787 struct skl_plane_wm {
788 struct skl_wm_level wm[8];
789 struct skl_wm_level uv_wm[8];
790 struct skl_wm_level trans_wm;
792 struct skl_wm_level wm0;
793 struct skl_wm_level trans_wm;
799 struct skl_plane_wm planes[I915_MAX_PLANES];
806 VLV_WM_LEVEL_DDR_DVFS,
810 struct vlv_wm_state {
811 struct g4x_pipe_wm wm[NUM_VLV_WM_LEVELS];
812 struct g4x_sr_wm sr[NUM_VLV_WM_LEVELS];
817 struct vlv_fifo_state {
818 u16 plane[I915_MAX_PLANES];
828 struct g4x_wm_state {
829 struct g4x_pipe_wm wm;
831 struct g4x_sr_wm hpll;
837 struct intel_crtc_wm_state {
841 * The "raw" watermark values produced by the formula
842 * given the plane's current state. They do not consider
843 * how much FIFO is actually allocated for each plane.
846 * The "optimal" watermark values given the current
847 * state of the planes and the amount of FIFO
848 * allocated to each, ignoring any previous state
852 * The "intermediate" watermark values when transitioning
853 * between the old and new "optimal" values. Used when
854 * the watermark registers are single buffered and hence
855 * their state changes asynchronously with regards to the
856 * actual plane registers. These are essentially the
857 * worst case combination of the old and new "optimal"
858 * watermarks, which are therefore safe to use when the
859 * plane is in either its old or new state.
862 struct intel_pipe_wm intermediate;
863 struct intel_pipe_wm optimal;
867 struct skl_pipe_wm raw;
868 /* gen9+ only needs 1-step wm programming */
869 struct skl_pipe_wm optimal;
870 struct skl_ddb_entry ddb;
871 struct skl_ddb_entry plane_ddb_y[I915_MAX_PLANES];
872 struct skl_ddb_entry plane_ddb_uv[I915_MAX_PLANES];
876 struct g4x_pipe_wm raw[NUM_VLV_WM_LEVELS]; /* not inverted */
877 struct vlv_wm_state intermediate; /* inverted */
878 struct vlv_wm_state optimal; /* inverted */
879 struct vlv_fifo_state fifo_state;
883 struct g4x_pipe_wm raw[NUM_G4X_WM_LEVELS];
884 struct g4x_wm_state intermediate;
885 struct g4x_wm_state optimal;
890 * Platforms with two-step watermark programming will need to
891 * update watermark programming post-vblank to switch from the
892 * safe intermediate watermarks to the optimal final
895 bool need_postvbl_update;
898 enum intel_output_format {
899 INTEL_OUTPUT_FORMAT_RGB,
900 INTEL_OUTPUT_FORMAT_YCBCR420,
901 INTEL_OUTPUT_FORMAT_YCBCR444,
904 struct intel_mpllb_state {
905 u32 clock; /* in KHz */
916 struct intel_crtc_state {
918 * uapi (drm) state. This is the software state shown to userspace.
919 * In particular, the following members are used for bookkeeping:
927 struct drm_crtc_state uapi;
930 * actual hardware state, the state we program to the hardware.
931 * The following members are used to verify the hardware state:
934 * - mode / pipe_mode / adjusted_mode
935 * - color property blobs.
937 * During initial hw readout, they need to be copied to uapi.
939 * Bigjoiner will allow a transcoder mode that spans 2 pipes;
940 * Use the pipe_mode for calculations like watermarks, pipe
941 * scaler, and bandwidth.
943 * Use adjusted_mode for things that need to know the full
944 * mode on the transcoder, which spans all pipes.
948 struct drm_property_blob *degamma_lut, *gamma_lut, *ctm;
949 struct drm_display_mode mode, pipe_mode, adjusted_mode;
950 enum drm_scaling_filter scaling_filter;
954 * quirks - bitfield with hw state readout quirks
956 * For various reasons the hw state readout code might not be able to
957 * completely faithfully read out the current state. These cases are
958 * tracked with quirk flags so that fastboot and state checker can act
961 #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
962 unsigned long quirks;
964 unsigned fb_bits; /* framebuffers to flip */
965 bool update_pipe; /* can a fast modeset be performed? */
967 bool update_wm_pre, update_wm_post; /* watermarks are updated */
968 bool fifo_changed; /* FIFO split is changed */
970 bool inherited; /* state inherited from BIOS? */
972 /* Pipe source size (ie. panel fitter input size)
973 * All planes will be positioned inside this space,
974 * and get clipped at the edges. */
975 int pipe_src_w, pipe_src_h;
978 * Pipe pixel rate, adjusted for
979 * panel fitter/pipe scaler downscaling.
981 unsigned int pixel_rate;
983 /* Whether to set up the PCH/FDI. Note that we never allow sharing
984 * between pch encoders and cpu encoders. */
985 bool has_pch_encoder;
987 /* Are we sending infoframes on the attached port */
990 /* CPU Transcoder for the pipe. Currently this can only differ from the
991 * pipe on Haswell and later (where we have a special eDP transcoder)
992 * and Broxton (where we have special DSI transcoders). */
993 enum transcoder cpu_transcoder;
996 * Use reduced/limited/broadcast rbg range, compressing from the full
997 * range fed into the crtcs.
999 bool limited_color_range;
1001 /* Bitmask of encoder types (enum intel_output_type)
1002 * driven by the pipe.
1004 unsigned int output_types;
1006 /* Whether we should send NULL infoframes. Required for audio. */
1009 /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
1010 * has_dp_encoder is set. */
1014 * Enable dithering, used when the selected pipe bpp doesn't match the
1020 * Dither gets enabled for 18bpp which causes CRC mismatch errors for
1021 * compliance video pattern tests.
1022 * Disable dither only if it is a compliance test request for
1025 bool dither_force_disable;
1027 /* Controls for the clock computation, to override various stages. */
1030 /* SDVO TV has a bunch of special case. To make multifunction encoders
1031 * work correctly, we need to track this at runtime.*/
1035 * crtc bandwidth limit, don't increase pipe bpp or clock if not really
1036 * required. This is set in the 2nd loop of calling encoder's
1037 * ->compute_config if the first pick doesn't work out.
1039 bool bw_constrained;
1041 /* Settings for the intel dpll used on pretty much everything but
1045 /* Selected dpll when shared or NULL. */
1046 struct intel_shared_dpll *shared_dpll;
1048 /* Actual register state of the dpll, for shared dpll cross-checking. */
1050 struct intel_dpll_hw_state dpll_hw_state;
1051 struct intel_mpllb_state mpllb_state;
1055 * ICL reserved DPLLs for the CRTC/port. The active PLL is selected by
1056 * setting shared_dpll and dpll_hw_state to one of these reserved ones.
1058 struct icl_port_dpll {
1059 struct intel_shared_dpll *pll;
1060 struct intel_dpll_hw_state hw_state;
1061 } icl_port_dplls[ICL_PORT_DPLL_COUNT];
1063 /* DSI PLL registers */
1069 struct intel_link_m_n dp_m_n;
1071 /* m2_n2 for eDP downclock */
1072 struct intel_link_m_n dp_m2_n2;
1075 /* PSR is supported but might not be enabled due the lack of enabled planes */
1078 bool enable_psr2_sel_fetch;
1079 bool req_psr2_sdp_prior_scanline;
1081 u16 su_y_granularity;
1082 struct drm_dp_vsc_sdp psr_vsc;
1085 * Frequence the dpll for the port should run at. Differs from the
1086 * adjusted dotclock e.g. for DP or 10/12bpc hdmi mode. This is also
1087 * already multiplied by pixel_multiplier.
1091 /* Used by SDVO (and if we ever fix it, HDMI). */
1092 unsigned pixel_multiplier;
1094 /* I915_MODE_FLAG_* */
1100 * Used by platforms having DP/HDMI PHY with programmable lane
1101 * latency optimization.
1103 u8 lane_lat_optim_mask;
1105 /* minimum acceptable voltage level */
1106 u8 min_voltage_level;
1108 /* Panel fitter controls for gen2-gen4 + VLV */
1112 u32 lvds_border_bits;
1115 /* Panel fitter placement and size for Ironlake+ */
1117 struct drm_rect dst;
1122 /* FDI configuration, only valid if has_pch_encoder is set. */
1124 struct intel_link_m_n fdi_m_n;
1134 struct intel_crtc_scaler_state scaler_state;
1136 /* w/a for waiting 2 vblanks during crtc enable */
1137 enum pipe hsw_workaround_pipe;
1139 /* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */
1142 struct intel_crtc_wm_state wm;
1144 int min_cdclk[I915_MAX_PLANES];
1146 u32 data_rate[I915_MAX_PLANES];
1148 /* FIXME unify with data_rate[] */
1149 u64 plane_data_rate[I915_MAX_PLANES];
1150 u64 uv_plane_data_rate[I915_MAX_PLANES];
1152 /* Gamma mode programmed on the pipe */
1156 /* CSC mode programmed on the pipe */
1163 /* bitmask of logically enabled planes (enum plane_id) */
1166 /* bitmask of actually visible planes (enum plane_id) */
1171 /* bitmask of planes that will be updated during the commit */
1177 union hdmi_infoframe avi;
1178 union hdmi_infoframe spd;
1179 union hdmi_infoframe hdmi;
1180 union hdmi_infoframe drm;
1181 struct drm_dp_vsc_sdp vsc;
1184 /* HDMI scrambling status */
1185 bool hdmi_scrambling;
1187 /* HDMI High TMDS char rate ratio */
1188 bool hdmi_high_tmds_clock_ratio;
1190 /* Output format RGB/YCBCR etc */
1191 enum intel_output_format output_format;
1193 /* enable pipe gamma? */
1196 /* enable pipe csc? */
1199 /* enable pipe big joiner? */
1202 /* big joiner slave crtc? */
1203 bool bigjoiner_slave;
1205 /* linked crtc for bigjoiner, either slave or master */
1206 struct intel_crtc *bigjoiner_linked_crtc;
1208 /* Display Stream compression state */
1210 bool compression_enable;
1214 struct drm_dsc_config config;
1217 /* HSW+ linetime watermarks */
1221 /* Forward Error correction State */
1224 /* Pointer to master transcoder in case of tiled displays */
1225 enum transcoder master_transcoder;
1227 /* Bitmask to indicate slaves attached */
1228 u8 sync_mode_slaves_mask;
1230 /* Only valid on TGL+ */
1231 enum transcoder mst_master_transcoder;
1233 /* For DSB related info */
1234 struct intel_dsb *dsb;
1236 u32 psr2_man_track_ctl;
1238 /* Variable Refresh Rate state */
1242 u16 flipline, vmin, vmax, guardband;
1245 /* Stream Splitter for eDP MSO */
1252 /* for loading single buffered registers during vblank */
1253 struct drm_vblank_work vblank_work;
1256 enum intel_pipe_crc_source {
1257 INTEL_PIPE_CRC_SOURCE_NONE,
1258 INTEL_PIPE_CRC_SOURCE_PLANE1,
1259 INTEL_PIPE_CRC_SOURCE_PLANE2,
1260 INTEL_PIPE_CRC_SOURCE_PLANE3,
1261 INTEL_PIPE_CRC_SOURCE_PLANE4,
1262 INTEL_PIPE_CRC_SOURCE_PLANE5,
1263 INTEL_PIPE_CRC_SOURCE_PLANE6,
1264 INTEL_PIPE_CRC_SOURCE_PLANE7,
1265 INTEL_PIPE_CRC_SOURCE_PIPE,
1266 /* TV/DP on pre-gen5/vlv can't use the pipe source. */
1267 INTEL_PIPE_CRC_SOURCE_TV,
1268 INTEL_PIPE_CRC_SOURCE_DP_B,
1269 INTEL_PIPE_CRC_SOURCE_DP_C,
1270 INTEL_PIPE_CRC_SOURCE_DP_D,
1271 INTEL_PIPE_CRC_SOURCE_AUTO,
1272 INTEL_PIPE_CRC_SOURCE_MAX,
1275 #define INTEL_PIPE_CRC_ENTRIES_NR 128
1276 struct intel_pipe_crc {
1279 enum intel_pipe_crc_source source;
1283 struct drm_crtc base;
1286 * Whether the crtc and the connected output pipeline is active. Implies
1287 * that crtc->enabled is set, i.e. the current mode configuration has
1288 * some outputs connected to this crtc.
1293 /* I915_MODE_FLAG_* */
1296 u16 vmax_vblank_start;
1298 struct intel_display_power_domain_set enabled_power_domains;
1299 struct intel_overlay *overlay;
1301 struct intel_crtc_state *config;
1303 /* Access to these should be protected by dev_priv->irq_lock. */
1304 bool cpu_fifo_underrun_disabled;
1305 bool pch_fifo_underrun_disabled;
1307 /* per-pipe watermark state */
1309 /* watermarks currently being used */
1311 struct intel_pipe_wm ilk;
1312 struct vlv_wm_state vlv;
1313 struct g4x_wm_state g4x;
1317 int scanline_offset;
1320 unsigned start_vbl_count;
1321 ktime_t start_vbl_time;
1322 int min_vbl, max_vbl;
1324 #ifdef CONFIG_DRM_I915_DEBUG_VBLANK_EVADE
1330 unsigned int times[17]; /* [1us, 16ms] */
1335 /* scalers available on this crtc */
1338 /* for loading single buffered registers during vblank */
1339 struct pm_qos_request vblank_pm_qos;
1341 #ifdef CONFIG_DEBUG_FS
1342 struct intel_pipe_crc pipe_crc;
1346 struct intel_plane {
1347 struct drm_plane base;
1348 enum i9xx_plane_id i9xx_plane;
1351 bool need_async_flip_disable_wa;
1352 u32 frontbuffer_bit;
1355 u32 base, cntl, size;
1358 struct intel_fbc *fbc;
1361 * NOTE: Do not place new plane state fields here (e.g., when adding
1362 * new plane properties). New runtime state should now be placed in
1363 * the intel_plane_state structure and accessed via plane_state.
1366 int (*min_width)(const struct drm_framebuffer *fb,
1368 unsigned int rotation);
1369 int (*max_width)(const struct drm_framebuffer *fb,
1371 unsigned int rotation);
1372 int (*max_height)(const struct drm_framebuffer *fb,
1374 unsigned int rotation);
1375 unsigned int (*max_stride)(struct intel_plane *plane,
1376 u32 pixel_format, u64 modifier,
1377 unsigned int rotation);
1378 /* Write all non-self arming plane registers */
1379 void (*update_noarm)(struct intel_plane *plane,
1380 const struct intel_crtc_state *crtc_state,
1381 const struct intel_plane_state *plane_state);
1382 /* Write all self-arming plane registers */
1383 void (*update_arm)(struct intel_plane *plane,
1384 const struct intel_crtc_state *crtc_state,
1385 const struct intel_plane_state *plane_state);
1386 /* Disable the plane, must arm */
1387 void (*disable_arm)(struct intel_plane *plane,
1388 const struct intel_crtc_state *crtc_state);
1389 bool (*get_hw_state)(struct intel_plane *plane, enum pipe *pipe);
1390 int (*check_plane)(struct intel_crtc_state *crtc_state,
1391 struct intel_plane_state *plane_state);
1392 int (*min_cdclk)(const struct intel_crtc_state *crtc_state,
1393 const struct intel_plane_state *plane_state);
1394 void (*async_flip)(struct intel_plane *plane,
1395 const struct intel_crtc_state *crtc_state,
1396 const struct intel_plane_state *plane_state,
1398 void (*enable_flip_done)(struct intel_plane *plane);
1399 void (*disable_flip_done)(struct intel_plane *plane);
1402 struct intel_watermark_params {
1410 struct cxsr_latency {
1411 bool is_desktop : 1;
1416 u16 display_hpll_disable;
1418 u16 cursor_hpll_disable;
1421 #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base)
1422 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
1423 #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, uapi)
1424 #define to_intel_connector(x) container_of(x, struct intel_connector, base)
1425 #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
1426 #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
1427 #define to_intel_plane(x) container_of(x, struct intel_plane, base)
1428 #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, uapi)
1429 #define intel_fb_obj(x) ((x) ? to_intel_bo((x)->obj[0]) : NULL)
1432 i915_reg_t hdmi_reg;
1435 enum drm_dp_dual_mode_type type;
1440 struct intel_connector *attached_connector;
1441 struct cec_notifier *cec_notifier;
1444 struct intel_dp_mst_encoder;
1446 * enum link_m_n_set:
1447 * When platform provides two set of M_N registers for dp, we can
1448 * program them and switch between them incase of DRRS.
1449 * But When only one such register is provided, we have to program the
1450 * required divider value on that registers itself based on the DRRS state.
1452 * M1_N1 : Program dp_m_n on M1_N1 registers
1453 * dp_m2_n2 on M2_N2 registers (If supported)
1455 * M2_N2 : Program dp_m2_n2 on M1_N1 registers
1456 * M2_N2 registers are not supported
1460 /* Sets the m1_n1 and m2_n2 */
1465 struct intel_dp_compliance_data {
1468 u16 hdisplay, vdisplay;
1470 struct drm_dp_phy_test_params phytest;
1473 struct intel_dp_compliance {
1474 unsigned long test_type;
1475 struct intel_dp_compliance_data test_data;
1481 struct intel_dp_pcon_frl {
1483 int trained_rate_gbps;
1487 int panel_power_up_delay;
1488 int panel_power_down_delay;
1489 int panel_power_cycle_delay;
1490 int backlight_on_delay;
1491 int backlight_off_delay;
1492 struct delayed_work panel_vdd_work;
1493 bool want_panel_vdd;
1494 unsigned long last_power_on;
1495 unsigned long last_backlight_off;
1496 ktime_t panel_power_off_time;
1497 intel_wakeref_t vdd_wakeref;
1500 * Pipe whose power sequencer is currently locked into
1501 * this port. Only relevant on VLV/CHV.
1505 * Pipe currently driving the port. Used for preventing
1506 * the use of the PPS for any pipe currentrly driving
1507 * external DP as that will mess things up on VLV.
1509 enum pipe active_pipe;
1511 * Set if the sequencer may be reset due to a power transition,
1512 * requiring a reinitialization. Only relevant on BXT.
1515 struct edp_power_seq pps_delays;
1519 /* Mutex for PSR state of the transcoder */
1522 #define I915_PSR_DEBUG_MODE_MASK 0x0f
1523 #define I915_PSR_DEBUG_DEFAULT 0x00
1524 #define I915_PSR_DEBUG_DISABLE 0x01
1525 #define I915_PSR_DEBUG_ENABLE 0x02
1526 #define I915_PSR_DEBUG_FORCE_PSR1 0x03
1527 #define I915_PSR_DEBUG_ENABLE_SEL_FETCH 0x4
1528 #define I915_PSR_DEBUG_IRQ 0x10
1532 bool source_support;
1536 enum transcoder transcoder;
1538 struct work_struct work;
1539 unsigned int busy_frontbuffer_bits;
1540 bool sink_psr2_support;
1542 bool colorimetry_support;
1544 bool psr2_sel_fetch_enabled;
1545 bool req_psr2_sdp_prior_scanline;
1546 u8 sink_sync_latency;
1547 ktime_t last_entry_attempt;
1549 bool sink_not_reliable;
1551 u16 su_w_granularity;
1552 u16 su_y_granularity;
1554 u32 dc3co_exit_delay;
1555 struct delayed_work dc3co_work;
1559 i915_reg_t output_reg;
1567 bool reset_link_params;
1568 bool use_max_params;
1569 u8 dpcd[DP_RECEIVER_CAP_SIZE];
1570 u8 psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
1571 u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
1572 u8 edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
1573 u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE];
1574 u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE];
1575 u8 lttpr_phy_caps[DP_MAX_LTTPR_COUNT][DP_LTTPR_PHY_CAP_SIZE];
1577 u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE];
1579 int num_source_rates;
1580 const int *source_rates;
1581 /* sink rates as reported by DP_MAX_LINK_RATE/DP_SUPPORTED_LINK_RATES */
1583 int sink_rates[DP_MAX_SUPPORTED_RATES];
1584 bool use_rate_select;
1585 /* Max sink lane count as reported by DP_MAX_LANE_COUNT */
1586 int max_sink_lane_count;
1587 /* intersection of source and sink rates */
1588 int num_common_rates;
1589 int common_rates[DP_MAX_SUPPORTED_RATES];
1590 /* Max lane count for the current link */
1591 int max_link_lane_count;
1592 /* Max rate for the current link */
1595 int mso_pixel_overlap;
1596 /* sink or branch descriptor */
1597 struct drm_dp_desc desc;
1598 struct drm_dp_aux aux;
1599 u32 aux_busy_last_status;
1602 struct intel_pps pps;
1605 int active_mst_links;
1607 /* connector directly attached - won't be use for modeset in mst world */
1608 struct intel_connector *attached_connector;
1610 /* mst connector list */
1611 struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
1612 struct drm_dp_mst_topology_mgr mst_mgr;
1614 u32 (*get_aux_clock_divider)(struct intel_dp *dp, int index);
1616 * This function returns the value we have to program the AUX_CTL
1617 * register with to kick off an AUX transaction.
1619 u32 (*get_aux_send_ctl)(struct intel_dp *dp, int send_bytes,
1620 u32 aux_clock_divider);
1622 i915_reg_t (*aux_ch_ctl_reg)(struct intel_dp *dp);
1623 i915_reg_t (*aux_ch_data_reg)(struct intel_dp *dp, int index);
1625 /* This is called before a link training is starterd */
1626 void (*prepare_link_retrain)(struct intel_dp *intel_dp,
1627 const struct intel_crtc_state *crtc_state);
1628 void (*set_link_train)(struct intel_dp *intel_dp,
1629 const struct intel_crtc_state *crtc_state,
1631 void (*set_idle_link_train)(struct intel_dp *intel_dp,
1632 const struct intel_crtc_state *crtc_state);
1634 u8 (*preemph_max)(struct intel_dp *intel_dp);
1635 u8 (*voltage_max)(struct intel_dp *intel_dp,
1636 const struct intel_crtc_state *crtc_state);
1638 /* Displayport compliance testing */
1639 struct intel_dp_compliance compliance;
1641 /* Downstream facing port caps */
1643 int min_tmds_clock, max_tmds_clock;
1645 int pcon_max_frl_bw;
1647 bool ycbcr_444_to_420;
1651 /* To control wakeup latency, e.g. for irq-driven dp aux transfers. */
1652 struct pm_qos_request pm_qos;
1654 /* Display stream compression testing */
1661 struct intel_dp_pcon_frl frl;
1663 struct intel_psr psr;
1665 /* When we last wrote the OUI for eDP */
1666 unsigned long last_oui_write;
1669 enum lspcon_vendor {
1671 LSPCON_VENDOR_PARADE
1674 struct intel_lspcon {
1677 enum drm_lspcon_mode mode;
1678 enum lspcon_vendor vendor;
1681 struct intel_digital_port {
1682 struct intel_encoder base;
1683 u32 saved_port_bits;
1685 struct intel_hdmi hdmi;
1686 struct intel_lspcon lspcon;
1687 enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
1688 bool release_cl2_override;
1690 /* Used for DP and ICL+ TypeC/DP and TypeC/HDMI ports. */
1692 enum intel_display_power_domain ddi_io_power_domain;
1693 intel_wakeref_t ddi_io_wakeref;
1694 intel_wakeref_t aux_wakeref;
1696 struct mutex tc_lock; /* protects the TypeC port mode */
1697 intel_wakeref_t tc_lock_wakeref;
1698 enum intel_display_power_domain tc_lock_power_domain;
1699 struct delayed_work tc_disconnect_phy_work;
1700 int tc_link_refcount;
1701 bool tc_legacy_port:1;
1702 char tc_port_name[8];
1703 enum tc_port_mode tc_mode;
1704 enum phy_fia tc_phy_fia;
1707 /* protects num_hdcp_streams reference count, hdcp_port_data and hdcp_auth_status */
1708 struct mutex hdcp_mutex;
1709 /* the number of pipes using HDCP signalling out of this port */
1710 unsigned int num_hdcp_streams;
1711 /* port HDCP auth status */
1712 bool hdcp_auth_status;
1713 /* HDCP port data need to pass to security f/w */
1714 struct hdcp_port_data hdcp_port_data;
1715 /* Whether the MST topology supports HDCP Type 1 Content */
1716 bool hdcp_mst_type1_capable;
1718 void (*write_infoframe)(struct intel_encoder *encoder,
1719 const struct intel_crtc_state *crtc_state,
1721 const void *frame, ssize_t len);
1722 void (*read_infoframe)(struct intel_encoder *encoder,
1723 const struct intel_crtc_state *crtc_state,
1725 void *frame, ssize_t len);
1726 void (*set_infoframes)(struct intel_encoder *encoder,
1728 const struct intel_crtc_state *crtc_state,
1729 const struct drm_connector_state *conn_state);
1730 u32 (*infoframes_enabled)(struct intel_encoder *encoder,
1731 const struct intel_crtc_state *pipe_config);
1732 bool (*connected)(struct intel_encoder *encoder);
1735 struct intel_dp_mst_encoder {
1736 struct intel_encoder base;
1738 struct intel_digital_port *primary;
1739 struct intel_connector *connector;
1742 static inline enum dpio_channel
1743 vlv_dig_port_to_channel(struct intel_digital_port *dig_port)
1745 switch (dig_port->base.port) {
1756 static inline enum dpio_phy
1757 vlv_dig_port_to_phy(struct intel_digital_port *dig_port)
1759 switch (dig_port->base.port) {
1770 static inline enum dpio_channel
1771 vlv_pipe_to_channel(enum pipe pipe)
1784 struct intel_load_detect_pipe {
1785 struct drm_atomic_state *restore_state;
1788 static inline struct intel_encoder *
1789 intel_attached_encoder(struct intel_connector *connector)
1791 return connector->encoder;
1794 static inline bool intel_encoder_is_dig_port(struct intel_encoder *encoder)
1796 switch (encoder->type) {
1797 case INTEL_OUTPUT_DDI:
1798 case INTEL_OUTPUT_DP:
1799 case INTEL_OUTPUT_EDP:
1800 case INTEL_OUTPUT_HDMI:
1807 static inline bool intel_encoder_is_mst(struct intel_encoder *encoder)
1809 return encoder->type == INTEL_OUTPUT_DP_MST;
1812 static inline struct intel_dp_mst_encoder *
1813 enc_to_mst(struct intel_encoder *encoder)
1815 return container_of(&encoder->base, struct intel_dp_mst_encoder,
1819 static inline struct intel_digital_port *
1820 enc_to_dig_port(struct intel_encoder *encoder)
1822 struct intel_encoder *intel_encoder = encoder;
1824 if (intel_encoder_is_dig_port(intel_encoder))
1825 return container_of(&encoder->base, struct intel_digital_port,
1827 else if (intel_encoder_is_mst(intel_encoder))
1828 return enc_to_mst(encoder)->primary;
1833 static inline struct intel_digital_port *
1834 intel_attached_dig_port(struct intel_connector *connector)
1836 return enc_to_dig_port(intel_attached_encoder(connector));
1839 static inline struct intel_hdmi *
1840 enc_to_intel_hdmi(struct intel_encoder *encoder)
1842 return &enc_to_dig_port(encoder)->hdmi;
1845 static inline struct intel_hdmi *
1846 intel_attached_hdmi(struct intel_connector *connector)
1848 return enc_to_intel_hdmi(intel_attached_encoder(connector));
1851 static inline struct intel_dp *enc_to_intel_dp(struct intel_encoder *encoder)
1853 return &enc_to_dig_port(encoder)->dp;
1856 static inline struct intel_dp *intel_attached_dp(struct intel_connector *connector)
1858 return enc_to_intel_dp(intel_attached_encoder(connector));
1861 static inline bool intel_encoder_is_dp(struct intel_encoder *encoder)
1863 switch (encoder->type) {
1864 case INTEL_OUTPUT_DP:
1865 case INTEL_OUTPUT_EDP:
1867 case INTEL_OUTPUT_DDI:
1868 /* Skip pure HDMI/DVI DDI encoders */
1869 return i915_mmio_reg_valid(enc_to_intel_dp(encoder)->output_reg);
1875 static inline struct intel_lspcon *
1876 enc_to_intel_lspcon(struct intel_encoder *encoder)
1878 return &enc_to_dig_port(encoder)->lspcon;
1881 static inline struct intel_digital_port *
1882 dp_to_dig_port(struct intel_dp *intel_dp)
1884 return container_of(intel_dp, struct intel_digital_port, dp);
1887 static inline struct intel_lspcon *
1888 dp_to_lspcon(struct intel_dp *intel_dp)
1890 return &dp_to_dig_port(intel_dp)->lspcon;
1893 #define dp_to_i915(__intel_dp) to_i915(dp_to_dig_port(__intel_dp)->base.base.dev)
1895 #define CAN_PSR(intel_dp) ((intel_dp)->psr.sink_support && \
1896 (intel_dp)->psr.source_support)
1898 static inline bool intel_encoder_can_psr(struct intel_encoder *encoder)
1900 if (!intel_encoder_is_dp(encoder))
1903 return CAN_PSR(enc_to_intel_dp(encoder));
1906 static inline struct intel_digital_port *
1907 hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
1909 return container_of(intel_hdmi, struct intel_digital_port, hdmi);
1912 static inline struct intel_plane_state *
1913 intel_atomic_get_plane_state(struct intel_atomic_state *state,
1914 struct intel_plane *plane)
1916 struct drm_plane_state *ret =
1917 drm_atomic_get_plane_state(&state->base, &plane->base);
1920 return ERR_CAST(ret);
1922 return to_intel_plane_state(ret);
1925 static inline struct intel_plane_state *
1926 intel_atomic_get_old_plane_state(struct intel_atomic_state *state,
1927 struct intel_plane *plane)
1929 return to_intel_plane_state(drm_atomic_get_old_plane_state(&state->base,
1933 static inline struct intel_plane_state *
1934 intel_atomic_get_new_plane_state(struct intel_atomic_state *state,
1935 struct intel_plane *plane)
1937 return to_intel_plane_state(drm_atomic_get_new_plane_state(&state->base,
1941 static inline struct intel_crtc_state *
1942 intel_atomic_get_old_crtc_state(struct intel_atomic_state *state,
1943 struct intel_crtc *crtc)
1945 return to_intel_crtc_state(drm_atomic_get_old_crtc_state(&state->base,
1949 static inline struct intel_crtc_state *
1950 intel_atomic_get_new_crtc_state(struct intel_atomic_state *state,
1951 struct intel_crtc *crtc)
1953 return to_intel_crtc_state(drm_atomic_get_new_crtc_state(&state->base,
1957 static inline struct intel_digital_connector_state *
1958 intel_atomic_get_new_connector_state(struct intel_atomic_state *state,
1959 struct intel_connector *connector)
1961 return to_intel_digital_connector_state(
1962 drm_atomic_get_new_connector_state(&state->base,
1966 static inline struct intel_digital_connector_state *
1967 intel_atomic_get_old_connector_state(struct intel_atomic_state *state,
1968 struct intel_connector *connector)
1970 return to_intel_digital_connector_state(
1971 drm_atomic_get_old_connector_state(&state->base,
1975 /* intel_display.c */
1977 intel_crtc_has_type(const struct intel_crtc_state *crtc_state,
1978 enum intel_output_type type)
1980 return crtc_state->output_types & (1 << type);
1983 intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state)
1985 return crtc_state->output_types &
1986 ((1 << INTEL_OUTPUT_DP) |
1987 (1 << INTEL_OUTPUT_DP_MST) |
1988 (1 << INTEL_OUTPUT_EDP));
1992 intel_crtc_needs_modeset(const struct intel_crtc_state *crtc_state)
1994 return drm_atomic_crtc_needs_modeset(&crtc_state->uapi);
1997 static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *plane_state)
1999 return i915_ggtt_offset(plane_state->ggtt_vma);
2002 static inline struct intel_frontbuffer *
2003 to_intel_frontbuffer(struct drm_framebuffer *fb)
2005 return fb ? to_intel_framebuffer(fb)->frontbuffer : NULL;
2008 #endif /* __INTEL_DISPLAY_TYPES_H__ */