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
25 #ifndef __INTEL_DRV_H__
26 #define __INTEL_DRV_H__
28 #include <linux/async.h>
29 #include <linux/i2c.h>
30 #include <linux/sched/clock.h>
31 #include <linux/stackdepot.h>
33 #include <drm/drm_atomic.h>
34 #include <drm/drm_crtc.h>
35 #include <drm/drm_dp_dual_mode_helper.h>
36 #include <drm/drm_dp_mst_helper.h>
37 #include <drm/drm_encoder.h>
38 #include <drm/drm_fb_helper.h>
39 #include <drm/drm_probe_helper.h>
40 #include <drm/drm_rect.h>
41 #include <drm/drm_vblank.h>
42 #include <drm/i915_drm.h>
43 #include <drm/i915_mei_hdcp_interface.h>
44 #include <media/cec-notifier.h>
51 * __wait_for - magic wait macro
53 * Macro to help avoid open coding check/wait/timeout patterns. Note that it's
54 * important that we check the condition again after having timed out, since the
55 * timeout could be due to preemption or similar and we've never had a chance to
56 * check the condition before the timeout.
58 #define __wait_for(OP, COND, US, Wmin, Wmax) ({ \
59 const ktime_t end__ = ktime_add_ns(ktime_get_raw(), 1000ll * (US)); \
60 long wait__ = (Wmin); /* recommended min for usleep is 10 us */ \
64 const bool expired__ = ktime_after(ktime_get_raw(), end__); \
66 /* Guarantee COND check prior to timeout */ \
76 usleep_range(wait__, wait__ * 2); \
77 if (wait__ < (Wmax)) \
83 #define _wait_for(COND, US, Wmin, Wmax) __wait_for(, (COND), (US), (Wmin), \
85 #define wait_for(COND, MS) _wait_for((COND), (MS) * 1000, 10, 1000)
87 /* If CONFIG_PREEMPT_COUNT is disabled, in_atomic() always reports false. */
88 #if defined(CONFIG_DRM_I915_DEBUG) && defined(CONFIG_PREEMPT_COUNT)
89 # define _WAIT_FOR_ATOMIC_CHECK(ATOMIC) WARN_ON_ONCE((ATOMIC) && !in_atomic())
91 # define _WAIT_FOR_ATOMIC_CHECK(ATOMIC) do { } while (0)
94 #define _wait_for_atomic(COND, US, ATOMIC) \
96 int cpu, ret, timeout = (US) * 1000; \
98 _WAIT_FOR_ATOMIC_CHECK(ATOMIC); \
101 cpu = smp_processor_id(); \
103 base = local_clock(); \
105 u64 now = local_clock(); \
108 /* Guarantee COND check prior to timeout */ \
114 if (now - base >= timeout) { \
121 if (unlikely(cpu != smp_processor_id())) { \
122 timeout -= now - base; \
123 cpu = smp_processor_id(); \
124 base = local_clock(); \
131 #define wait_for_us(COND, US) \
134 BUILD_BUG_ON(!__builtin_constant_p(US)); \
136 ret__ = _wait_for((COND), (US), 10, 10); \
138 ret__ = _wait_for_atomic((COND), (US), 0); \
142 #define wait_for_atomic_us(COND, US) \
144 BUILD_BUG_ON(!__builtin_constant_p(US)); \
145 BUILD_BUG_ON((US) > 50000); \
146 _wait_for_atomic((COND), (US), 1); \
149 #define wait_for_atomic(COND, MS) wait_for_atomic_us((COND), (MS) * 1000)
151 #define KHz(x) (1000 * (x))
152 #define MHz(x) KHz(1000 * (x))
154 #define KBps(x) (1000 * (x))
155 #define MBps(x) KBps(1000 * (x))
156 #define GBps(x) ((u64)1000 * MBps((x)))
159 * Display related stuff
162 /* store information about an Ixxx DVO */
163 /* The i830->i865 use multiple DVOs with multiple i2cs */
164 /* the i915, i945 have a single sDVO i2c bus - which is different */
165 #define MAX_OUTPUTS 6
166 /* maximum connectors per crtcs in the mode set */
168 #define INTEL_I2C_BUS_DVO 1
169 #define INTEL_I2C_BUS_SDVO 2
171 /* these are outputs from the chip - integrated only
172 external chips are via DVO or SDVO output */
173 enum intel_output_type
{
174 INTEL_OUTPUT_UNUSED
= 0,
175 INTEL_OUTPUT_ANALOG
= 1,
176 INTEL_OUTPUT_DVO
= 2,
177 INTEL_OUTPUT_SDVO
= 3,
178 INTEL_OUTPUT_LVDS
= 4,
179 INTEL_OUTPUT_TVOUT
= 5,
180 INTEL_OUTPUT_HDMI
= 6,
182 INTEL_OUTPUT_EDP
= 8,
183 INTEL_OUTPUT_DSI
= 9,
184 INTEL_OUTPUT_DDI
= 10,
185 INTEL_OUTPUT_DP_MST
= 11,
188 #define INTEL_DVO_CHIP_NONE 0
189 #define INTEL_DVO_CHIP_LVDS 1
190 #define INTEL_DVO_CHIP_TMDS 2
191 #define INTEL_DVO_CHIP_TVOUT 4
193 #define INTEL_DSI_VIDEO_MODE 0
194 #define INTEL_DSI_COMMAND_MODE 1
196 struct intel_framebuffer
{
197 struct drm_framebuffer base
;
198 struct intel_rotation_info rot_info
;
200 /* for each plane in the normal GTT view */
204 /* for each plane in the rotated GTT view */
207 unsigned int pitch
; /* pixels */
212 struct drm_fb_helper helper
;
213 struct intel_framebuffer
*fb
;
214 struct i915_vma
*vma
;
215 unsigned long vma_flags
;
216 async_cookie_t cookie
;
219 /* Whether or not fbdev hpd processing is temporarily suspended */
220 bool hpd_suspended
: 1;
221 /* Set when a hotplug was received while HPD processing was
224 bool hpd_waiting
: 1;
226 /* Protects hpd_suspended */
227 struct mutex hpd_lock
;
230 struct intel_encoder
{
231 struct drm_encoder base
;
233 enum intel_output_type type
;
235 unsigned int cloneable
;
236 bool (*hotplug
)(struct intel_encoder
*encoder
,
237 struct intel_connector
*connector
);
238 enum intel_output_type (*compute_output_type
)(struct intel_encoder
*,
239 struct intel_crtc_state
*,
240 struct drm_connector_state
*);
241 int (*compute_config
)(struct intel_encoder
*,
242 struct intel_crtc_state
*,
243 struct drm_connector_state
*);
244 void (*pre_pll_enable
)(struct intel_encoder
*,
245 const struct intel_crtc_state
*,
246 const struct drm_connector_state
*);
247 void (*pre_enable
)(struct intel_encoder
*,
248 const struct intel_crtc_state
*,
249 const struct drm_connector_state
*);
250 void (*enable
)(struct intel_encoder
*,
251 const struct intel_crtc_state
*,
252 const struct drm_connector_state
*);
253 void (*disable
)(struct intel_encoder
*,
254 const struct intel_crtc_state
*,
255 const struct drm_connector_state
*);
256 void (*post_disable
)(struct intel_encoder
*,
257 const struct intel_crtc_state
*,
258 const struct drm_connector_state
*);
259 void (*post_pll_disable
)(struct intel_encoder
*,
260 const struct intel_crtc_state
*,
261 const struct drm_connector_state
*);
262 void (*update_pipe
)(struct intel_encoder
*,
263 const struct intel_crtc_state
*,
264 const struct drm_connector_state
*);
265 /* Read out the current hw state of this connector, returning true if
266 * the encoder is active. If the encoder is enabled it also set the pipe
267 * it is connected to in the pipe parameter. */
268 bool (*get_hw_state
)(struct intel_encoder
*, enum pipe
*pipe
);
269 /* Reconstructs the equivalent mode flags for the current hardware
270 * state. This must be called _after_ display->get_pipe_config has
271 * pre-filled the pipe config. Note that intel_encoder->base.crtc must
272 * be set correctly before calling this function. */
273 void (*get_config
)(struct intel_encoder
*,
274 struct intel_crtc_state
*pipe_config
);
276 * Acquires the power domains needed for an active encoder during
277 * hardware state readout.
279 void (*get_power_domains
)(struct intel_encoder
*encoder
,
280 struct intel_crtc_state
*crtc_state
);
282 * Called during system suspend after all pending requests for the
283 * encoder are flushed (for example for DP AUX transactions) and
284 * device interrupts are disabled.
286 void (*suspend
)(struct intel_encoder
*);
288 enum hpd_pin hpd_pin
;
289 enum intel_display_power_domain power_domain
;
290 /* for communication with audio component; protected by av_mutex */
291 const struct drm_connector
*audio_connector
;
295 struct drm_display_mode
*fixed_mode
;
296 struct drm_display_mode
*downclock_mode
;
305 bool combination_mode
; /* gen 2/4 only */
307 bool alternate_pwm_increment
; /* lpt+ */
310 bool util_pin_active_low
; /* bxt+ */
311 u8 controller
; /* bxt+ only */
312 struct pwm_device
*pwm
;
314 struct backlight_device
*device
;
316 /* Connector and platform specific backlight functions */
317 int (*setup
)(struct intel_connector
*connector
, enum pipe pipe
);
318 u32 (*get
)(struct intel_connector
*connector
);
319 void (*set
)(const struct drm_connector_state
*conn_state
, u32 level
);
320 void (*disable
)(const struct drm_connector_state
*conn_state
);
321 void (*enable
)(const struct intel_crtc_state
*crtc_state
,
322 const struct drm_connector_state
*conn_state
);
323 u32 (*hz_to_pwm
)(struct intel_connector
*connector
, u32 hz
);
324 void (*power
)(struct intel_connector
*, bool enable
);
328 struct intel_digital_port
;
330 enum check_link_response
{
331 HDCP_LINK_PROTECTED
= 0,
332 HDCP_TOPOLOGY_CHANGE
,
333 HDCP_LINK_INTEGRITY_FAILURE
,
338 * This structure serves as a translation layer between the generic HDCP code
339 * and the bus-specific code. What that means is that HDCP over HDMI differs
340 * from HDCP over DP, so to account for these differences, we need to
341 * communicate with the receiver through this shim.
343 * For completeness, the 2 buses differ in the following ways:
345 * HDCP registers on the receiver are set via DP AUX for DP, and
346 * they are set via DDC for HDMI.
347 * - Receiver register offsets
348 * The offsets of the registers are different for DP vs. HDMI
349 * - Receiver register masks/offsets
350 * For instance, the ready bit for the KSV fifo is in a different
351 * place on DP vs HDMI
352 * - Receiver register names
353 * Seriously. In the DP spec, the 16-bit register containing
354 * downstream information is called BINFO, on HDMI it's called
355 * BSTATUS. To confuse matters further, DP has a BSTATUS register
356 * with a completely different definition.
358 * On HDMI, the ksv fifo is read all at once, whereas on DP it must
359 * be read 3 keys at a time
361 * Since Aksv is hidden in hardware, there's different procedures
362 * to send it over DP AUX vs DDC
364 struct intel_hdcp_shim
{
365 /* Outputs the transmitter's An and Aksv values to the receiver. */
366 int (*write_an_aksv
)(struct intel_digital_port
*intel_dig_port
, u8
*an
);
368 /* Reads the receiver's key selection vector */
369 int (*read_bksv
)(struct intel_digital_port
*intel_dig_port
, u8
*bksv
);
372 * Reads BINFO from DP receivers and BSTATUS from HDMI receivers. The
373 * definitions are the same in the respective specs, but the names are
374 * different. Call it BSTATUS since that's the name the HDMI spec
375 * uses and it was there first.
377 int (*read_bstatus
)(struct intel_digital_port
*intel_dig_port
,
380 /* Determines whether a repeater is present downstream */
381 int (*repeater_present
)(struct intel_digital_port
*intel_dig_port
,
382 bool *repeater_present
);
384 /* Reads the receiver's Ri' value */
385 int (*read_ri_prime
)(struct intel_digital_port
*intel_dig_port
, u8
*ri
);
387 /* Determines if the receiver's KSV FIFO is ready for consumption */
388 int (*read_ksv_ready
)(struct intel_digital_port
*intel_dig_port
,
391 /* Reads the ksv fifo for num_downstream devices */
392 int (*read_ksv_fifo
)(struct intel_digital_port
*intel_dig_port
,
393 int num_downstream
, u8
*ksv_fifo
);
395 /* Reads a 32-bit part of V' from the receiver */
396 int (*read_v_prime_part
)(struct intel_digital_port
*intel_dig_port
,
399 /* Enables HDCP signalling on the port */
400 int (*toggle_signalling
)(struct intel_digital_port
*intel_dig_port
,
403 /* Ensures the link is still protected */
404 bool (*check_link
)(struct intel_digital_port
*intel_dig_port
);
406 /* Detects panel's hdcp capability. This is optional for HDMI. */
407 int (*hdcp_capable
)(struct intel_digital_port
*intel_dig_port
,
410 /* HDCP adaptation(DP/HDMI) required on the port */
411 enum hdcp_wired_protocol protocol
;
413 /* Detects whether sink is HDCP2.2 capable */
414 int (*hdcp_2_2_capable
)(struct intel_digital_port
*intel_dig_port
,
417 /* Write HDCP2.2 messages */
418 int (*write_2_2_msg
)(struct intel_digital_port
*intel_dig_port
,
419 void *buf
, size_t size
);
421 /* Read HDCP2.2 messages */
422 int (*read_2_2_msg
)(struct intel_digital_port
*intel_dig_port
,
423 u8 msg_id
, void *buf
, size_t size
);
426 * Implementation of DP HDCP2.2 Errata for the communication of stream
427 * type to Receivers. In DP HDCP2.2 Stream type is one of the input to
428 * the HDCP2.2 Cipher for En/De-Cryption. Not applicable for HDMI.
430 int (*config_stream_type
)(struct intel_digital_port
*intel_dig_port
,
431 bool is_repeater
, u8 type
);
433 /* HDCP2.2 Link Integrity Check */
434 int (*check_2_2_link
)(struct intel_digital_port
*intel_dig_port
);
438 const struct intel_hdcp_shim
*shim
;
439 /* Mutex for hdcp state of the connector */
442 struct delayed_work check_work
;
443 struct work_struct prop_work
;
445 /* HDCP1.4 Encryption status */
448 /* HDCP2.2 related definitions */
449 /* Flag indicates whether this connector supports HDCP2.2 or not. */
450 bool hdcp2_supported
;
452 /* HDCP2.2 Encryption status */
453 bool hdcp2_encrypted
;
456 * Content Stream Type defined by content owner. TYPE0(0x0) content can
457 * flow in the link protected by HDCP2.2 or HDCP1.4, where as TYPE1(0x1)
458 * content can flow only through a link protected by HDCP2.2.
461 struct hdcp_port_data port_data
;
467 * Count of ReceiverID_List received. Initialized to 0 at AKE_INIT.
468 * Incremented after processing the RepeaterAuth_Send_ReceiverID_List.
469 * When it rolls over re-auth has to be triggered.
474 * Count of RepeaterAuth_Stream_Manage msg propagated.
475 * Initialized to 0 on AKE_INIT. Incremented after every successful
476 * transmission of RepeaterAuth_Stream_Manage message. When it rolls
477 * over re-Auth has to be triggered.
482 * Work queue to signal the CP_IRQ. Used for the waiters to read the
483 * available information from HDCP DP sink.
485 wait_queue_head_t cp_irq_queue
;
486 atomic_t cp_irq_count
;
487 int cp_irq_count_cached
;
490 struct intel_connector
{
491 struct drm_connector base
;
493 * The fixed encoder this connector is connected to.
495 struct intel_encoder
*encoder
;
497 /* ACPI device id for ACPI and driver cooperation */
500 /* Reads out the current hw, returning true if the connector is enabled
501 * and active (i.e. dpms ON state). */
502 bool (*get_hw_state
)(struct intel_connector
*);
504 /* Panel info for eDP and LVDS */
505 struct intel_panel panel
;
507 /* Cached EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
509 struct edid
*detect_edid
;
511 /* since POLL and HPD connectors may use the same HPD line keep the native
512 state of connector->polled in case hotplug storm detection changes it */
515 void *port
; /* store this opaque as its illegal to dereference it */
517 struct intel_dp
*mst_port
;
519 /* Work struct to schedule a uevent on link train failure */
520 struct work_struct modeset_retry_work
;
522 struct intel_hdcp hdcp
;
525 struct intel_digital_connector_state
{
526 struct drm_connector_state base
;
528 enum hdmi_force_audio force_audio
;
532 #define to_intel_digital_connector_state(x) container_of(x, struct intel_digital_connector_state, base)
546 struct intel_atomic_state
{
547 struct drm_atomic_state base
;
551 * Logical state of cdclk (used for all scaling, watermark,
552 * etc. calculations and checks). This is computed as if all
553 * enabled crtcs were active.
555 struct intel_cdclk_state logical
;
558 * Actual state of cdclk, can be different from the logical
559 * state only when all crtc's are DPMS off.
561 struct intel_cdclk_state actual
;
564 bool force_min_cdclk_changed
;
565 /* pipe to which cd2x update is synchronized */
569 bool dpll_set
, modeset
;
572 * Does this transaction change the pipes that are active? This mask
573 * tracks which CRTC's have changed their active state at the end of
574 * the transaction (not counting the temporary disable during modesets).
575 * This mask should only be non-zero when intel_state->modeset is true,
576 * but the converse is not necessarily true; simply changing a mode may
577 * not flip the final active status of any CRTC's
579 unsigned int active_pipe_changes
;
581 unsigned int active_crtcs
;
582 /* minimum acceptable cdclk for each pipe */
583 int min_cdclk
[I915_MAX_PIPES
];
584 /* minimum acceptable voltage level for each pipe */
585 u8 min_voltage_level
[I915_MAX_PIPES
];
587 struct intel_shared_dpll_state shared_dpll
[I915_NUM_PLLS
];
590 * Current watermarks can't be trusted during hardware readout, so
591 * don't bother calculating intermediate watermarks.
593 bool skip_intermediate_wm
;
595 bool rps_interactive
;
598 struct skl_ddb_values wm_results
;
600 struct i915_sw_fence commit_ready
;
602 struct llist_node freed
;
605 struct intel_plane_state
{
606 struct drm_plane_state base
;
607 struct i915_ggtt_view view
;
608 struct i915_vma
*vma
;
610 #define PLANE_HAS_FENCE BIT(0)
616 * bytes for 0/180 degree rotation
617 * pixels for 90/270 degree rotation
623 /* plane control register */
626 /* plane color control register */
631 * = -1 : not using a scaler
632 * >= 0 : using a scalers
634 * plane requiring a scaler:
635 * - During check_plane, its bit is set in
636 * crtc_state->scaler_state.scaler_users by calling helper function
637 * update_scaler_plane.
638 * - scaler_id indicates the scaler it got assigned.
640 * plane doesn't require a scaler:
641 * - this can happen when scaling is no more required or plane simply
643 * - During check_plane, corresponding bit is reset in
644 * crtc_state->scaler_state.scaler_users by calling helper function
645 * update_scaler_plane.
652 * ICL planar formats require 2 planes that are updated as pairs.
653 * This member is used to make sure the other plane is also updated
654 * when required, and for update_slave() to find the correct
655 * plane_state to pass as argument.
657 struct intel_plane
*linked_plane
;
661 * If set don't update use the linked plane's state for updating
662 * this plane during atomic commit with the update_slave() callback.
664 * It's also used by the watermark code to ignore wm calculations on
665 * this plane. They're calculated by the linked plane's wm code.
669 struct drm_intel_sprite_colorkey ckey
;
672 struct intel_initial_plane_config
{
673 struct intel_framebuffer
*fb
;
680 #define SKL_MIN_SRC_W 8
681 #define SKL_MAX_SRC_W 4096
682 #define SKL_MIN_SRC_H 8
683 #define SKL_MAX_SRC_H 4096
684 #define SKL_MIN_DST_W 8
685 #define SKL_MAX_DST_W 4096
686 #define SKL_MIN_DST_H 8
687 #define SKL_MAX_DST_H 4096
688 #define ICL_MAX_SRC_W 5120
689 #define ICL_MAX_SRC_H 4096
690 #define ICL_MAX_DST_W 5120
691 #define ICL_MAX_DST_H 4096
692 #define SKL_MIN_YUV_420_SRC_W 16
693 #define SKL_MIN_YUV_420_SRC_H 16
695 struct intel_scaler
{
700 struct intel_crtc_scaler_state
{
701 #define SKL_NUM_SCALERS 2
702 struct intel_scaler scalers
[SKL_NUM_SCALERS
];
705 * scaler_users: keeps track of users requesting scalers on this crtc.
707 * If a bit is set, a user is using a scaler.
708 * Here user can be a plane or crtc as defined below:
709 * bits 0-30 - plane (bit position is index from drm_plane_index)
712 * Instead of creating a new index to cover planes and crtc, using
713 * existing drm_plane_index for planes which is well less than 31
714 * planes and bit 31 for crtc. This should be fine to cover all
717 * intel_atomic_setup_scalers will setup available scalers to users
718 * requesting scalers. It will gracefully fail if request exceeds
721 #define SKL_CRTC_INDEX 31
722 unsigned scaler_users
;
724 /* scaler used by crtc for panel fitting purpose */
728 /* drm_mode->private_flags */
729 #define I915_MODE_FLAG_INHERITED (1<<0)
730 /* Flag to get scanline using frame time stamps */
731 #define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1)
732 /* Flag to use the scanline counter instead of the pixel counter */
733 #define I915_MODE_FLAG_USE_SCANLINE_COUNTER (1<<2)
735 struct intel_pipe_wm
{
736 struct intel_wm_level wm
[5];
740 bool sprites_enabled
;
744 struct skl_plane_wm
{
745 struct skl_wm_level wm
[8];
746 struct skl_wm_level uv_wm
[8];
747 struct skl_wm_level trans_wm
;
752 struct skl_plane_wm planes
[I915_MAX_PLANES
];
759 VLV_WM_LEVEL_DDR_DVFS
,
763 struct vlv_wm_state
{
764 struct g4x_pipe_wm wm
[NUM_VLV_WM_LEVELS
];
765 struct g4x_sr_wm sr
[NUM_VLV_WM_LEVELS
];
770 struct vlv_fifo_state
{
771 u16 plane
[I915_MAX_PLANES
];
781 struct g4x_wm_state
{
782 struct g4x_pipe_wm wm
;
784 struct g4x_sr_wm hpll
;
790 struct intel_crtc_wm_state
{
794 * Intermediate watermarks; these can be
795 * programmed immediately since they satisfy
796 * both the current configuration we're
797 * switching away from and the new
798 * configuration we're switching to.
800 struct intel_pipe_wm intermediate
;
803 * Optimal watermarks, programmed post-vblank
804 * when this state is committed.
806 struct intel_pipe_wm optimal
;
810 /* gen9+ only needs 1-step wm programming */
811 struct skl_pipe_wm optimal
;
812 struct skl_ddb_entry ddb
;
813 struct skl_ddb_entry plane_ddb_y
[I915_MAX_PLANES
];
814 struct skl_ddb_entry plane_ddb_uv
[I915_MAX_PLANES
];
818 /* "raw" watermarks (not inverted) */
819 struct g4x_pipe_wm raw
[NUM_VLV_WM_LEVELS
];
820 /* intermediate watermarks (inverted) */
821 struct vlv_wm_state intermediate
;
822 /* optimal watermarks (inverted) */
823 struct vlv_wm_state optimal
;
824 /* display FIFO split */
825 struct vlv_fifo_state fifo_state
;
829 /* "raw" watermarks */
830 struct g4x_pipe_wm raw
[NUM_G4X_WM_LEVELS
];
831 /* intermediate watermarks */
832 struct g4x_wm_state intermediate
;
833 /* optimal watermarks */
834 struct g4x_wm_state optimal
;
839 * Platforms with two-step watermark programming will need to
840 * update watermark programming post-vblank to switch from the
841 * safe intermediate watermarks to the optimal final
844 bool need_postvbl_update
;
847 enum intel_output_format
{
848 INTEL_OUTPUT_FORMAT_INVALID
,
849 INTEL_OUTPUT_FORMAT_RGB
,
850 INTEL_OUTPUT_FORMAT_YCBCR420
,
851 INTEL_OUTPUT_FORMAT_YCBCR444
,
854 struct intel_crtc_state
{
855 struct drm_crtc_state base
;
858 * quirks - bitfield with hw state readout quirks
860 * For various reasons the hw state readout code might not be able to
861 * completely faithfully read out the current state. These cases are
862 * tracked with quirk flags so that fastboot and state checker can act
865 #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
866 unsigned long quirks
;
868 unsigned fb_bits
; /* framebuffers to flip */
869 bool update_pipe
; /* can a fast modeset be performed? */
871 bool update_wm_pre
, update_wm_post
; /* watermarks are updated */
872 bool fb_changed
; /* fb on any of the planes is changed */
873 bool fifo_changed
; /* FIFO split is changed */
875 /* Pipe source size (ie. panel fitter input size)
876 * All planes will be positioned inside this space,
877 * and get clipped at the edges. */
878 int pipe_src_w
, pipe_src_h
;
881 * Pipe pixel rate, adjusted for
882 * panel fitter/pipe scaler downscaling.
884 unsigned int pixel_rate
;
886 /* Whether to set up the PCH/FDI. Note that we never allow sharing
887 * between pch encoders and cpu encoders. */
888 bool has_pch_encoder
;
890 /* Are we sending infoframes on the attached port */
893 /* CPU Transcoder for the pipe. Currently this can only differ from the
894 * pipe on Haswell and later (where we have a special eDP transcoder)
895 * and Broxton (where we have special DSI transcoders). */
896 enum transcoder cpu_transcoder
;
899 * Use reduced/limited/broadcast rbg range, compressing from the full
900 * range fed into the crtcs.
902 bool limited_color_range
;
904 /* Bitmask of encoder types (enum intel_output_type)
905 * driven by the pipe.
907 unsigned int output_types
;
909 /* Whether we should send NULL infoframes. Required for audio. */
912 /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
913 * has_dp_encoder is set. */
917 * Enable dithering, used when the selected pipe bpp doesn't match the
923 * Dither gets enabled for 18bpp which causes CRC mismatch errors for
924 * compliance video pattern tests.
925 * Disable dither only if it is a compliance test request for
928 bool dither_force_disable
;
930 /* Controls for the clock computation, to override various stages. */
933 /* SDVO TV has a bunch of special case. To make multifunction encoders
934 * work correctly, we need to track this at runtime.*/
938 * crtc bandwidth limit, don't increase pipe bpp or clock if not really
939 * required. This is set in the 2nd loop of calling encoder's
940 * ->compute_config if the first pick doesn't work out.
944 /* Settings for the intel dpll used on pretty much everything but
948 /* Selected dpll when shared or NULL. */
949 struct intel_shared_dpll
*shared_dpll
;
951 /* Actual register state of the dpll, for shared dpll cross-checking. */
952 struct intel_dpll_hw_state dpll_hw_state
;
954 /* DSI PLL registers */
960 struct intel_link_m_n dp_m_n
;
962 /* m2_n2 for eDP downclock */
963 struct intel_link_m_n dp_m2_n2
;
970 * Frequence the dpll for the port should run at. Differs from the
971 * adjusted dotclock e.g. for DP or 12bpc hdmi mode. This is also
972 * already multiplied by pixel_multiplier.
976 /* Used by SDVO (and if we ever fix it, HDMI). */
977 unsigned pixel_multiplier
;
982 * Used by platforms having DP/HDMI PHY with programmable lane
983 * latency optimization.
985 u8 lane_lat_optim_mask
;
987 /* minimum acceptable voltage level */
988 u8 min_voltage_level
;
990 /* Panel fitter controls for gen2-gen4 + VLV */
994 u32 lvds_border_bits
;
997 /* Panel fitter placement and size for Ironlake+ */
1005 /* FDI configuration, only valid if has_pch_encoder is set. */
1007 struct intel_link_m_n fdi_m_n
;
1019 struct intel_crtc_scaler_state scaler_state
;
1021 /* w/a for waiting 2 vblanks during crtc enable */
1022 enum pipe hsw_workaround_pipe
;
1024 /* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */
1027 struct intel_crtc_wm_state wm
;
1029 /* Gamma mode programmed on the pipe */
1033 /* CSC mode programmed on the pipe */
1040 /* bitmask of visible planes (enum plane_id) */
1045 /* bitmask of planes that will be updated during the commit */
1051 union hdmi_infoframe avi
;
1052 union hdmi_infoframe spd
;
1053 union hdmi_infoframe hdmi
;
1056 /* HDMI scrambling status */
1057 bool hdmi_scrambling
;
1059 /* HDMI High TMDS char rate ratio */
1060 bool hdmi_high_tmds_clock_ratio
;
1062 /* Output format RGB/YCBCR etc */
1063 enum intel_output_format output_format
;
1065 /* Output down scaling is done in LSPCON device */
1066 bool lspcon_downsampling
;
1068 /* enable pipe gamma? */
1071 /* enable pipe csc? */
1074 /* Display Stream compression state */
1076 bool compression_enable
;
1081 struct drm_dsc_config dp_dsc_cfg
;
1083 /* Forward Error correction State */
1088 struct drm_crtc base
;
1091 * Whether the crtc and the connected output pipeline is active. Implies
1092 * that crtc->enabled is set, i.e. the current mode configuration has
1093 * some outputs connected to this crtc.
1097 unsigned long long enabled_power_domains
;
1098 struct intel_overlay
*overlay
;
1100 struct intel_crtc_state
*config
;
1102 /* Access to these should be protected by dev_priv->irq_lock. */
1103 bool cpu_fifo_underrun_disabled
;
1104 bool pch_fifo_underrun_disabled
;
1106 /* per-pipe watermark state */
1108 /* watermarks currently being used */
1110 struct intel_pipe_wm ilk
;
1111 struct vlv_wm_state vlv
;
1112 struct g4x_wm_state g4x
;
1116 int scanline_offset
;
1119 unsigned start_vbl_count
;
1120 ktime_t start_vbl_time
;
1121 int min_vbl
, max_vbl
;
1125 /* scalers available on this crtc */
1129 struct intel_plane
{
1130 struct drm_plane base
;
1131 enum i9xx_plane_id i9xx_plane
;
1136 u32 frontbuffer_bit
;
1139 u32 base
, cntl
, size
;
1143 * NOTE: Do not place new plane state fields here (e.g., when adding
1144 * new plane properties). New runtime state should now be placed in
1145 * the intel_plane_state structure and accessed via plane_state.
1148 unsigned int (*max_stride
)(struct intel_plane
*plane
,
1149 u32 pixel_format
, u64 modifier
,
1150 unsigned int rotation
);
1151 void (*update_plane
)(struct intel_plane
*plane
,
1152 const struct intel_crtc_state
*crtc_state
,
1153 const struct intel_plane_state
*plane_state
);
1154 void (*update_slave
)(struct intel_plane
*plane
,
1155 const struct intel_crtc_state
*crtc_state
,
1156 const struct intel_plane_state
*plane_state
);
1157 void (*disable_plane
)(struct intel_plane
*plane
,
1158 const struct intel_crtc_state
*crtc_state
);
1159 bool (*get_hw_state
)(struct intel_plane
*plane
, enum pipe
*pipe
);
1160 int (*check_plane
)(struct intel_crtc_state
*crtc_state
,
1161 struct intel_plane_state
*plane_state
);
1164 struct intel_watermark_params
{
1172 struct cxsr_latency
{
1173 bool is_desktop
: 1;
1178 u16 display_hpll_disable
;
1180 u16 cursor_hpll_disable
;
1183 #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base)
1184 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
1185 #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, base)
1186 #define to_intel_connector(x) container_of(x, struct intel_connector, base)
1187 #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
1188 #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
1189 #define to_intel_plane(x) container_of(x, struct intel_plane, base)
1190 #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, base)
1191 #define intel_fb_obj(x) ((x) ? to_intel_bo((x)->obj[0]) : NULL)
1194 i915_reg_t hdmi_reg
;
1197 enum drm_dp_dual_mode_type type
;
1202 struct intel_connector
*attached_connector
;
1203 struct cec_notifier
*cec_notifier
;
1206 struct intel_dp_mst_encoder
;
1207 #define DP_MAX_DOWNSTREAM_PORTS 0x10
1210 * enum link_m_n_set:
1211 * When platform provides two set of M_N registers for dp, we can
1212 * program them and switch between them incase of DRRS.
1213 * But When only one such register is provided, we have to program the
1214 * required divider value on that registers itself based on the DRRS state.
1216 * M1_N1 : Program dp_m_n on M1_N1 registers
1217 * dp_m2_n2 on M2_N2 registers (If supported)
1219 * M2_N2 : Program dp_m2_n2 on M1_N1 registers
1220 * M2_N2 registers are not supported
1224 /* Sets the m1_n1 and m2_n2 */
1229 struct intel_dp_compliance_data
{
1232 u16 hdisplay
, vdisplay
;
1236 struct intel_dp_compliance
{
1237 unsigned long test_type
;
1238 struct intel_dp_compliance_data test_data
;
1245 i915_reg_t output_reg
;
1253 bool reset_link_params
;
1254 u8 dpcd
[DP_RECEIVER_CAP_SIZE
];
1255 u8 psr_dpcd
[EDP_PSR_RECEIVER_CAP_SIZE
];
1256 u8 downstream_ports
[DP_MAX_DOWNSTREAM_PORTS
];
1257 u8 edp_dpcd
[EDP_DISPLAY_CTL_CAP_SIZE
];
1258 u8 dsc_dpcd
[DP_DSC_RECEIVER_CAP_SIZE
];
1261 int num_source_rates
;
1262 const int *source_rates
;
1263 /* sink rates as reported by DP_MAX_LINK_RATE/DP_SUPPORTED_LINK_RATES */
1265 int sink_rates
[DP_MAX_SUPPORTED_RATES
];
1266 bool use_rate_select
;
1267 /* intersection of source and sink rates */
1268 int num_common_rates
;
1269 int common_rates
[DP_MAX_SUPPORTED_RATES
];
1270 /* Max lane count for the current link */
1271 int max_link_lane_count
;
1272 /* Max rate for the current link */
1274 /* sink or branch descriptor */
1275 struct drm_dp_desc desc
;
1276 struct drm_dp_aux aux
;
1278 int panel_power_up_delay
;
1279 int panel_power_down_delay
;
1280 int panel_power_cycle_delay
;
1281 int backlight_on_delay
;
1282 int backlight_off_delay
;
1283 struct delayed_work panel_vdd_work
;
1284 bool want_panel_vdd
;
1285 unsigned long last_power_on
;
1286 unsigned long last_backlight_off
;
1287 ktime_t panel_power_off_time
;
1289 struct notifier_block edp_notifier
;
1292 * Pipe whose power sequencer is currently locked into
1293 * this port. Only relevant on VLV/CHV.
1297 * Pipe currently driving the port. Used for preventing
1298 * the use of the PPS for any pipe currentrly driving
1299 * external DP as that will mess things up on VLV.
1301 enum pipe active_pipe
;
1303 * Set if the sequencer may be reset due to a power transition,
1304 * requiring a reinitialization. Only relevant on BXT.
1307 struct edp_power_seq pps_delays
;
1309 bool can_mst
; /* this port supports mst */
1311 int active_mst_links
;
1312 /* connector directly attached - won't be use for modeset in mst world */
1313 struct intel_connector
*attached_connector
;
1315 /* mst connector list */
1316 struct intel_dp_mst_encoder
*mst_encoders
[I915_MAX_PIPES
];
1317 struct drm_dp_mst_topology_mgr mst_mgr
;
1319 u32 (*get_aux_clock_divider
)(struct intel_dp
*dp
, int index
);
1321 * This function returns the value we have to program the AUX_CTL
1322 * register with to kick off an AUX transaction.
1324 u32 (*get_aux_send_ctl
)(struct intel_dp
*dp
, int send_bytes
,
1325 u32 aux_clock_divider
);
1327 i915_reg_t (*aux_ch_ctl_reg
)(struct intel_dp
*dp
);
1328 i915_reg_t (*aux_ch_data_reg
)(struct intel_dp
*dp
, int index
);
1330 /* This is called before a link training is starterd */
1331 void (*prepare_link_retrain
)(struct intel_dp
*intel_dp
);
1333 /* Displayport compliance testing */
1334 struct intel_dp_compliance compliance
;
1336 /* Display stream compression testing */
1340 enum lspcon_vendor
{
1342 LSPCON_VENDOR_PARADE
1345 struct intel_lspcon
{
1347 enum drm_lspcon_mode mode
;
1348 enum lspcon_vendor vendor
;
1351 struct intel_digital_port
{
1352 struct intel_encoder base
;
1353 u32 saved_port_bits
;
1355 struct intel_hdmi hdmi
;
1356 struct intel_lspcon lspcon
;
1357 enum irqreturn (*hpd_pulse
)(struct intel_digital_port
*, bool);
1358 bool release_cl2_override
;
1360 /* Used for DP and ICL+ TypeC/DP and TypeC/HDMI ports. */
1362 enum intel_display_power_domain ddi_io_power_domain
;
1363 bool tc_legacy_port
:1;
1364 enum tc_port_type tc_type
;
1366 void (*write_infoframe
)(struct intel_encoder
*encoder
,
1367 const struct intel_crtc_state
*crtc_state
,
1369 const void *frame
, ssize_t len
);
1370 void (*read_infoframe
)(struct intel_encoder
*encoder
,
1371 const struct intel_crtc_state
*crtc_state
,
1373 void *frame
, ssize_t len
);
1374 void (*set_infoframes
)(struct intel_encoder
*encoder
,
1376 const struct intel_crtc_state
*crtc_state
,
1377 const struct drm_connector_state
*conn_state
);
1378 u32 (*infoframes_enabled
)(struct intel_encoder
*encoder
,
1379 const struct intel_crtc_state
*pipe_config
);
1382 struct intel_dp_mst_encoder
{
1383 struct intel_encoder base
;
1385 struct intel_digital_port
*primary
;
1386 struct intel_connector
*connector
;
1389 static inline enum dpio_channel
1390 vlv_dport_to_channel(struct intel_digital_port
*dport
)
1392 switch (dport
->base
.port
) {
1403 static inline enum dpio_phy
1404 vlv_dport_to_phy(struct intel_digital_port
*dport
)
1406 switch (dport
->base
.port
) {
1417 static inline enum dpio_channel
1418 vlv_pipe_to_channel(enum pipe pipe
)
1431 static inline struct intel_crtc
*
1432 intel_get_crtc_for_pipe(struct drm_i915_private
*dev_priv
, enum pipe pipe
)
1434 return dev_priv
->pipe_to_crtc_mapping
[pipe
];
1437 static inline struct intel_crtc
*
1438 intel_get_crtc_for_plane(struct drm_i915_private
*dev_priv
, enum i9xx_plane_id plane
)
1440 return dev_priv
->plane_to_crtc_mapping
[plane
];
1443 struct intel_load_detect_pipe
{
1444 struct drm_atomic_state
*restore_state
;
1447 static inline struct intel_encoder
*
1448 intel_attached_encoder(struct drm_connector
*connector
)
1450 return to_intel_connector(connector
)->encoder
;
1453 static inline bool intel_encoder_is_dig_port(struct intel_encoder
*encoder
)
1455 switch (encoder
->type
) {
1456 case INTEL_OUTPUT_DDI
:
1457 case INTEL_OUTPUT_DP
:
1458 case INTEL_OUTPUT_EDP
:
1459 case INTEL_OUTPUT_HDMI
:
1466 static inline struct intel_digital_port
*
1467 enc_to_dig_port(struct drm_encoder
*encoder
)
1469 struct intel_encoder
*intel_encoder
= to_intel_encoder(encoder
);
1471 if (intel_encoder_is_dig_port(intel_encoder
))
1472 return container_of(encoder
, struct intel_digital_port
,
1478 static inline struct intel_digital_port
*
1479 conn_to_dig_port(struct intel_connector
*connector
)
1481 return enc_to_dig_port(&intel_attached_encoder(&connector
->base
)->base
);
1484 static inline struct intel_dp_mst_encoder
*
1485 enc_to_mst(struct drm_encoder
*encoder
)
1487 return container_of(encoder
, struct intel_dp_mst_encoder
, base
.base
);
1490 static inline struct intel_dp
*enc_to_intel_dp(struct drm_encoder
*encoder
)
1492 return &enc_to_dig_port(encoder
)->dp
;
1495 static inline bool intel_encoder_is_dp(struct intel_encoder
*encoder
)
1497 switch (encoder
->type
) {
1498 case INTEL_OUTPUT_DP
:
1499 case INTEL_OUTPUT_EDP
:
1501 case INTEL_OUTPUT_DDI
:
1502 /* Skip pure HDMI/DVI DDI encoders */
1503 return i915_mmio_reg_valid(enc_to_intel_dp(&encoder
->base
)->output_reg
);
1509 static inline struct intel_lspcon
*
1510 enc_to_intel_lspcon(struct drm_encoder
*encoder
)
1512 return &enc_to_dig_port(encoder
)->lspcon
;
1515 static inline struct intel_digital_port
*
1516 dp_to_dig_port(struct intel_dp
*intel_dp
)
1518 return container_of(intel_dp
, struct intel_digital_port
, dp
);
1521 static inline struct intel_lspcon
*
1522 dp_to_lspcon(struct intel_dp
*intel_dp
)
1524 return &dp_to_dig_port(intel_dp
)->lspcon
;
1527 static inline struct drm_i915_private
*
1528 dp_to_i915(struct intel_dp
*intel_dp
)
1530 return to_i915(dp_to_dig_port(intel_dp
)->base
.base
.dev
);
1533 static inline struct intel_digital_port
*
1534 hdmi_to_dig_port(struct intel_hdmi
*intel_hdmi
)
1536 return container_of(intel_hdmi
, struct intel_digital_port
, hdmi
);
1539 static inline struct intel_plane_state
*
1540 intel_atomic_get_plane_state(struct intel_atomic_state
*state
,
1541 struct intel_plane
*plane
)
1543 struct drm_plane_state
*ret
=
1544 drm_atomic_get_plane_state(&state
->base
, &plane
->base
);
1547 return ERR_CAST(ret
);
1549 return to_intel_plane_state(ret
);
1552 static inline struct intel_plane_state
*
1553 intel_atomic_get_old_plane_state(struct intel_atomic_state
*state
,
1554 struct intel_plane
*plane
)
1556 return to_intel_plane_state(drm_atomic_get_old_plane_state(&state
->base
,
1560 static inline struct intel_plane_state
*
1561 intel_atomic_get_new_plane_state(struct intel_atomic_state
*state
,
1562 struct intel_plane
*plane
)
1564 return to_intel_plane_state(drm_atomic_get_new_plane_state(&state
->base
,
1568 static inline struct intel_crtc_state
*
1569 intel_atomic_get_old_crtc_state(struct intel_atomic_state
*state
,
1570 struct intel_crtc
*crtc
)
1572 return to_intel_crtc_state(drm_atomic_get_old_crtc_state(&state
->base
,
1576 static inline struct intel_crtc_state
*
1577 intel_atomic_get_new_crtc_state(struct intel_atomic_state
*state
,
1578 struct intel_crtc
*crtc
)
1580 return to_intel_crtc_state(drm_atomic_get_new_crtc_state(&state
->base
,
1584 /* intel_fifo_underrun.c */
1585 bool intel_set_cpu_fifo_underrun_reporting(struct drm_i915_private
*dev_priv
,
1586 enum pipe pipe
, bool enable
);
1587 bool intel_set_pch_fifo_underrun_reporting(struct drm_i915_private
*dev_priv
,
1588 enum pipe pch_transcoder
,
1590 void intel_cpu_fifo_underrun_irq_handler(struct drm_i915_private
*dev_priv
,
1592 void intel_pch_fifo_underrun_irq_handler(struct drm_i915_private
*dev_priv
,
1593 enum pipe pch_transcoder
);
1594 void intel_check_cpu_fifo_underruns(struct drm_i915_private
*dev_priv
);
1595 void intel_check_pch_fifo_underruns(struct drm_i915_private
*dev_priv
);
1598 void gen5_enable_gt_irq(struct drm_i915_private
*dev_priv
, u32 mask
);
1599 void gen5_disable_gt_irq(struct drm_i915_private
*dev_priv
, u32 mask
);
1600 void gen6_mask_pm_irq(struct drm_i915_private
*dev_priv
, u32 mask
);
1601 void gen6_unmask_pm_irq(struct drm_i915_private
*dev_priv
, u32 mask
);
1602 void gen11_reset_rps_interrupts(struct drm_i915_private
*dev_priv
);
1603 void gen6_reset_rps_interrupts(struct drm_i915_private
*dev_priv
);
1604 void gen6_enable_rps_interrupts(struct drm_i915_private
*dev_priv
);
1605 void gen6_disable_rps_interrupts(struct drm_i915_private
*dev_priv
);
1606 void gen6_rps_reset_ei(struct drm_i915_private
*dev_priv
);
1608 static inline u32
gen6_sanitize_rps_pm_mask(const struct drm_i915_private
*i915
,
1611 return mask
& ~i915
->gt_pm
.rps
.pm_intrmsk_mbz
;
1614 void intel_runtime_pm_disable_interrupts(struct drm_i915_private
*dev_priv
);
1615 void intel_runtime_pm_enable_interrupts(struct drm_i915_private
*dev_priv
);
1616 static inline bool intel_irqs_enabled(struct drm_i915_private
*dev_priv
)
1619 * We only use drm_irq_uninstall() at unload and VT switch, so
1620 * this is the only thing we need to check.
1622 return dev_priv
->runtime_pm
.irqs_enabled
;
1625 int intel_get_crtc_scanline(struct intel_crtc
*crtc
);
1626 void gen8_irq_power_well_post_enable(struct drm_i915_private
*dev_priv
,
1628 void gen8_irq_power_well_pre_disable(struct drm_i915_private
*dev_priv
,
1630 void gen9_reset_guc_interrupts(struct drm_i915_private
*dev_priv
);
1631 void gen9_enable_guc_interrupts(struct drm_i915_private
*dev_priv
);
1632 void gen9_disable_guc_interrupts(struct drm_i915_private
*dev_priv
);
1634 /* intel_display.c */
1635 void intel_plane_destroy(struct drm_plane
*plane
);
1636 void i830_enable_pipe(struct drm_i915_private
*dev_priv
, enum pipe pipe
);
1637 void i830_disable_pipe(struct drm_i915_private
*dev_priv
, enum pipe pipe
);
1638 enum pipe
intel_crtc_pch_transcoder(struct intel_crtc
*crtc
);
1639 int vlv_get_hpll_vco(struct drm_i915_private
*dev_priv
);
1640 int vlv_get_cck_clock(struct drm_i915_private
*dev_priv
,
1641 const char *name
, u32 reg
, int ref_freq
);
1642 int vlv_get_cck_clock_hpll(struct drm_i915_private
*dev_priv
,
1643 const char *name
, u32 reg
);
1644 void lpt_disable_pch_transcoder(struct drm_i915_private
*dev_priv
);
1645 void lpt_disable_iclkip(struct drm_i915_private
*dev_priv
);
1646 void intel_init_display_hooks(struct drm_i915_private
*dev_priv
);
1647 unsigned int intel_fb_xy_to_linear(int x
, int y
,
1648 const struct intel_plane_state
*state
,
1650 unsigned int intel_fb_align_height(const struct drm_framebuffer
*fb
,
1651 int color_plane
, unsigned int height
);
1652 void intel_add_fb_offsets(int *x
, int *y
,
1653 const struct intel_plane_state
*state
, int plane
);
1654 unsigned int intel_rotation_info_size(const struct intel_rotation_info
*rot_info
);
1655 bool intel_has_pending_fb_unpin(struct drm_i915_private
*dev_priv
);
1656 void intel_mark_busy(struct drm_i915_private
*dev_priv
);
1657 void intel_mark_idle(struct drm_i915_private
*dev_priv
);
1658 int intel_display_suspend(struct drm_device
*dev
);
1659 void intel_pps_unlock_regs_wa(struct drm_i915_private
*dev_priv
);
1660 void intel_encoder_destroy(struct drm_encoder
*encoder
);
1661 struct drm_display_mode
*
1662 intel_encoder_current_mode(struct intel_encoder
*encoder
);
1663 bool intel_port_is_combophy(struct drm_i915_private
*dev_priv
, enum port port
);
1664 bool intel_port_is_tc(struct drm_i915_private
*dev_priv
, enum port port
);
1665 enum tc_port
intel_port_to_tc(struct drm_i915_private
*dev_priv
,
1667 int intel_get_pipe_from_crtc_id_ioctl(struct drm_device
*dev
, void *data
,
1668 struct drm_file
*file_priv
);
1669 enum transcoder
intel_pipe_to_cpu_transcoder(struct drm_i915_private
*dev_priv
,
1672 intel_crtc_has_type(const struct intel_crtc_state
*crtc_state
,
1673 enum intel_output_type type
)
1675 return crtc_state
->output_types
& (1 << type
);
1678 intel_crtc_has_dp_encoder(const struct intel_crtc_state
*crtc_state
)
1680 return crtc_state
->output_types
&
1681 ((1 << INTEL_OUTPUT_DP
) |
1682 (1 << INTEL_OUTPUT_DP_MST
) |
1683 (1 << INTEL_OUTPUT_EDP
));
1686 intel_wait_for_vblank(struct drm_i915_private
*dev_priv
, enum pipe pipe
)
1688 drm_wait_one_vblank(&dev_priv
->drm
, pipe
);
1691 intel_wait_for_vblank_if_active(struct drm_i915_private
*dev_priv
, int pipe
)
1693 const struct intel_crtc
*crtc
= intel_get_crtc_for_pipe(dev_priv
, pipe
);
1696 intel_wait_for_vblank(dev_priv
, pipe
);
1699 u32
intel_crtc_get_vblank_counter(struct intel_crtc
*crtc
);
1701 int ironlake_get_lanes_required(int target_clock
, int link_bw
, int bpp
);
1702 void vlv_wait_port_ready(struct drm_i915_private
*dev_priv
,
1703 struct intel_digital_port
*dport
,
1704 unsigned int expected_mask
);
1705 int intel_get_load_detect_pipe(struct drm_connector
*connector
,
1706 const struct drm_display_mode
*mode
,
1707 struct intel_load_detect_pipe
*old
,
1708 struct drm_modeset_acquire_ctx
*ctx
);
1709 void intel_release_load_detect_pipe(struct drm_connector
*connector
,
1710 struct intel_load_detect_pipe
*old
,
1711 struct drm_modeset_acquire_ctx
*ctx
);
1713 intel_pin_and_fence_fb_obj(struct drm_framebuffer
*fb
,
1714 const struct i915_ggtt_view
*view
,
1716 unsigned long *out_flags
);
1717 void intel_unpin_fb_vma(struct i915_vma
*vma
, unsigned long flags
);
1718 struct drm_framebuffer
*
1719 intel_framebuffer_create(struct drm_i915_gem_object
*obj
,
1720 struct drm_mode_fb_cmd2
*mode_cmd
);
1721 int intel_prepare_plane_fb(struct drm_plane
*plane
,
1722 struct drm_plane_state
*new_state
);
1723 void intel_cleanup_plane_fb(struct drm_plane
*plane
,
1724 struct drm_plane_state
*old_state
);
1725 int intel_plane_atomic_get_property(struct drm_plane
*plane
,
1726 const struct drm_plane_state
*state
,
1727 struct drm_property
*property
,
1729 int intel_plane_atomic_set_property(struct drm_plane
*plane
,
1730 struct drm_plane_state
*state
,
1731 struct drm_property
*property
,
1733 int intel_plane_atomic_calc_changes(const struct intel_crtc_state
*old_crtc_state
,
1734 struct drm_crtc_state
*crtc_state
,
1735 const struct intel_plane_state
*old_plane_state
,
1736 struct drm_plane_state
*plane_state
);
1738 void assert_pch_transcoder_disabled(struct drm_i915_private
*dev_priv
,
1741 int vlv_force_pll_on(struct drm_i915_private
*dev_priv
, enum pipe pipe
,
1742 const struct dpll
*dpll
);
1743 void vlv_force_pll_off(struct drm_i915_private
*dev_priv
, enum pipe pipe
);
1744 int lpt_get_iclkip(struct drm_i915_private
*dev_priv
);
1746 /* modesetting asserts */
1747 void assert_panel_unlocked(struct drm_i915_private
*dev_priv
,
1749 void assert_pll(struct drm_i915_private
*dev_priv
,
1750 enum pipe pipe
, bool state
);
1751 #define assert_pll_enabled(d, p) assert_pll(d, p, true)
1752 #define assert_pll_disabled(d, p) assert_pll(d, p, false)
1753 void assert_dsi_pll(struct drm_i915_private
*dev_priv
, bool state
);
1754 #define assert_dsi_pll_enabled(d) assert_dsi_pll(d, true)
1755 #define assert_dsi_pll_disabled(d) assert_dsi_pll(d, false)
1756 void assert_fdi_rx_pll(struct drm_i915_private
*dev_priv
,
1757 enum pipe pipe
, bool state
);
1758 #define assert_fdi_rx_pll_enabled(d, p) assert_fdi_rx_pll(d, p, true)
1759 #define assert_fdi_rx_pll_disabled(d, p) assert_fdi_rx_pll(d, p, false)
1760 void assert_pipe(struct drm_i915_private
*dev_priv
, enum pipe pipe
, bool state
);
1761 #define assert_pipe_enabled(d, p) assert_pipe(d, p, true)
1762 #define assert_pipe_disabled(d, p) assert_pipe(d, p, false)
1763 void intel_prepare_reset(struct drm_i915_private
*dev_priv
);
1764 void intel_finish_reset(struct drm_i915_private
*dev_priv
);
1765 void hsw_enable_pc8(struct drm_i915_private
*dev_priv
);
1766 void hsw_disable_pc8(struct drm_i915_private
*dev_priv
);
1767 void gen9_sanitize_dc_state(struct drm_i915_private
*dev_priv
);
1768 void bxt_enable_dc9(struct drm_i915_private
*dev_priv
);
1769 void bxt_disable_dc9(struct drm_i915_private
*dev_priv
);
1770 void gen9_enable_dc5(struct drm_i915_private
*dev_priv
);
1771 unsigned int skl_cdclk_get_vco(unsigned int freq
);
1772 void skl_enable_dc6(struct drm_i915_private
*dev_priv
);
1773 void intel_dp_get_m_n(struct intel_crtc
*crtc
,
1774 struct intel_crtc_state
*pipe_config
);
1775 void intel_dp_set_m_n(const struct intel_crtc_state
*crtc_state
,
1776 enum link_m_n_set m_n
);
1777 int intel_dotclock_calculate(int link_freq
, const struct intel_link_m_n
*m_n
);
1778 bool bxt_find_best_dpll(struct intel_crtc_state
*crtc_state
,
1779 struct dpll
*best_clock
);
1780 int chv_calc_dpll_params(int refclk
, struct dpll
*pll_clock
);
1782 bool intel_crtc_active(struct intel_crtc
*crtc
);
1783 bool hsw_crtc_state_ips_capable(const struct intel_crtc_state
*crtc_state
);
1784 void hsw_enable_ips(const struct intel_crtc_state
*crtc_state
);
1785 void hsw_disable_ips(const struct intel_crtc_state
*crtc_state
);
1786 enum intel_display_power_domain
intel_port_to_power_domain(enum port port
);
1787 enum intel_display_power_domain
1788 intel_aux_power_domain(struct intel_digital_port
*dig_port
);
1789 void intel_mode_from_pipe_config(struct drm_display_mode
*mode
,
1790 struct intel_crtc_state
*pipe_config
);
1791 void intel_crtc_arm_fifo_underrun(struct intel_crtc
*crtc
,
1792 struct intel_crtc_state
*crtc_state
);
1794 u16
skl_scaler_calc_phase(int sub
, int scale
, bool chroma_center
);
1795 int skl_update_scaler_crtc(struct intel_crtc_state
*crtc_state
);
1796 int skl_max_scale(const struct intel_crtc_state
*crtc_state
,
1799 static inline u32
intel_plane_ggtt_offset(const struct intel_plane_state
*state
)
1801 return i915_ggtt_offset(state
->vma
);
1804 u32
glk_plane_color_ctl(const struct intel_crtc_state
*crtc_state
,
1805 const struct intel_plane_state
*plane_state
);
1806 u32
glk_plane_color_ctl_crtc(const struct intel_crtc_state
*crtc_state
);
1807 u32
skl_plane_ctl(const struct intel_crtc_state
*crtc_state
,
1808 const struct intel_plane_state
*plane_state
);
1809 u32
skl_plane_ctl_crtc(const struct intel_crtc_state
*crtc_state
);
1810 u32
skl_plane_stride(const struct intel_plane_state
*plane_state
,
1812 int skl_check_plane_surface(struct intel_plane_state
*plane_state
);
1813 int i9xx_check_plane_surface(struct intel_plane_state
*plane_state
);
1814 int skl_format_to_fourcc(int format
, bool rgb_order
, bool alpha
);
1815 unsigned int i9xx_plane_max_stride(struct intel_plane
*plane
,
1816 u32 pixel_format
, u64 modifier
,
1817 unsigned int rotation
);
1819 /* intel_dp_link_training.c */
1820 void intel_dp_start_link_train(struct intel_dp
*intel_dp
);
1821 void intel_dp_stop_link_train(struct intel_dp
*intel_dp
);
1824 int intel_dp_compute_dsc_params(struct intel_dp
*intel_dp
,
1825 struct intel_crtc_state
*pipe_config
);
1826 enum intel_display_power_domain
1827 intel_dsc_power_domain(const struct intel_crtc_state
*crtc_state
);
1829 /* intel_dp_aux_backlight.c */
1830 int intel_dp_aux_init_backlight_funcs(struct intel_connector
*intel_connector
);
1832 /* intel_dp_mst.c */
1833 int intel_dp_mst_encoder_init(struct intel_digital_port
*intel_dig_port
, int conn_id
);
1834 void intel_dp_mst_encoder_cleanup(struct intel_digital_port
*intel_dig_port
);
1836 void vlv_dsi_init(struct drm_i915_private
*dev_priv
);
1839 void icl_dsi_init(struct drm_i915_private
*dev_priv
);
1841 /* intel_dsi_dcs_backlight.c */
1842 int intel_dsi_dcs_init_backlight_funcs(struct intel_connector
*intel_connector
);
1844 /* intel_hotplug.c */
1845 void intel_hpd_poll_init(struct drm_i915_private
*dev_priv
);
1846 bool intel_encoder_hotplug(struct intel_encoder
*encoder
,
1847 struct intel_connector
*connector
);
1849 /* intel_overlay.c */
1850 void intel_overlay_setup(struct drm_i915_private
*dev_priv
);
1851 void intel_overlay_cleanup(struct drm_i915_private
*dev_priv
);
1852 int intel_overlay_switch_off(struct intel_overlay
*overlay
);
1853 int intel_overlay_put_image_ioctl(struct drm_device
*dev
, void *data
,
1854 struct drm_file
*file_priv
);
1855 int intel_overlay_attrs_ioctl(struct drm_device
*dev
, void *data
,
1856 struct drm_file
*file_priv
);
1857 void intel_overlay_reset(struct drm_i915_private
*dev_priv
);
1859 /* intel_quirks.c */
1860 void intel_init_quirks(struct drm_i915_private
*dev_priv
);
1862 /* intel_runtime_pm.c */
1863 void intel_runtime_pm_init_early(struct drm_i915_private
*dev_priv
);
1864 int intel_power_domains_init(struct drm_i915_private
*);
1865 void intel_power_domains_cleanup(struct drm_i915_private
*dev_priv
);
1866 void intel_power_domains_init_hw(struct drm_i915_private
*dev_priv
, bool resume
);
1867 void intel_power_domains_fini_hw(struct drm_i915_private
*dev_priv
);
1868 void icl_display_core_init(struct drm_i915_private
*dev_priv
, bool resume
);
1869 void icl_display_core_uninit(struct drm_i915_private
*dev_priv
);
1870 void intel_power_domains_enable(struct drm_i915_private
*dev_priv
);
1871 void intel_power_domains_disable(struct drm_i915_private
*dev_priv
);
1873 enum i915_drm_suspend_mode
{
1874 I915_DRM_SUSPEND_IDLE
,
1875 I915_DRM_SUSPEND_MEM
,
1876 I915_DRM_SUSPEND_HIBERNATE
,
1879 void intel_power_domains_suspend(struct drm_i915_private
*dev_priv
,
1880 enum i915_drm_suspend_mode
);
1881 void intel_power_domains_resume(struct drm_i915_private
*dev_priv
);
1882 void bxt_display_core_init(struct drm_i915_private
*dev_priv
, bool resume
);
1883 void bxt_display_core_uninit(struct drm_i915_private
*dev_priv
);
1884 void intel_runtime_pm_enable(struct drm_i915_private
*dev_priv
);
1885 void intel_runtime_pm_disable(struct drm_i915_private
*dev_priv
);
1886 void intel_runtime_pm_cleanup(struct drm_i915_private
*dev_priv
);
1888 intel_display_power_domain_str(enum intel_display_power_domain domain
);
1890 bool intel_display_power_is_enabled(struct drm_i915_private
*dev_priv
,
1891 enum intel_display_power_domain domain
);
1892 bool __intel_display_power_is_enabled(struct drm_i915_private
*dev_priv
,
1893 enum intel_display_power_domain domain
);
1894 intel_wakeref_t
intel_display_power_get(struct drm_i915_private
*dev_priv
,
1895 enum intel_display_power_domain domain
);
1897 intel_display_power_get_if_enabled(struct drm_i915_private
*dev_priv
,
1898 enum intel_display_power_domain domain
);
1899 void intel_display_power_put_unchecked(struct drm_i915_private
*dev_priv
,
1900 enum intel_display_power_domain domain
);
1901 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
1902 void intel_display_power_put(struct drm_i915_private
*dev_priv
,
1903 enum intel_display_power_domain domain
,
1904 intel_wakeref_t wakeref
);
1906 #define intel_display_power_put(i915, domain, wakeref) \
1907 intel_display_power_put_unchecked(i915, domain)
1909 void icl_dbuf_slices_update(struct drm_i915_private
*dev_priv
,
1913 assert_rpm_device_not_suspended(struct i915_runtime_pm
*rpm
)
1915 WARN_ONCE(rpm
->suspended
,
1916 "Device suspended during HW access\n");
1920 __assert_rpm_wakelock_held(struct i915_runtime_pm
*rpm
)
1922 assert_rpm_device_not_suspended(rpm
);
1923 WARN_ONCE(!atomic_read(&rpm
->wakeref_count
),
1924 "RPM wakelock ref not held during HW access");
1928 assert_rpm_wakelock_held(struct drm_i915_private
*i915
)
1930 __assert_rpm_wakelock_held(&i915
->runtime_pm
);
1934 * disable_rpm_wakeref_asserts - disable the RPM assert checks
1935 * @i915: i915 device instance
1937 * This function disable asserts that check if we hold an RPM wakelock
1938 * reference, while keeping the device-not-suspended checks still enabled.
1939 * It's meant to be used only in special circumstances where our rule about
1940 * the wakelock refcount wrt. the device power state doesn't hold. According
1941 * to this rule at any point where we access the HW or want to keep the HW in
1942 * an active state we must hold an RPM wakelock reference acquired via one of
1943 * the intel_runtime_pm_get() helpers. Currently there are a few special spots
1944 * where this rule doesn't hold: the IRQ and suspend/resume handlers, the
1945 * forcewake release timer, and the GPU RPS and hangcheck works. All other
1946 * users should avoid using this function.
1948 * Any calls to this function must have a symmetric call to
1949 * enable_rpm_wakeref_asserts().
1952 disable_rpm_wakeref_asserts(struct drm_i915_private
*i915
)
1954 atomic_inc(&i915
->runtime_pm
.wakeref_count
);
1958 * enable_rpm_wakeref_asserts - re-enable the RPM assert checks
1959 * @i915: i915 device instance
1961 * This function re-enables the RPM assert checks after disabling them with
1962 * disable_rpm_wakeref_asserts. It's meant to be used only in special
1963 * circumstances otherwise its use should be avoided.
1965 * Any calls to this function must have a symmetric call to
1966 * disable_rpm_wakeref_asserts().
1969 enable_rpm_wakeref_asserts(struct drm_i915_private
*i915
)
1971 atomic_dec(&i915
->runtime_pm
.wakeref_count
);
1974 intel_wakeref_t
intel_runtime_pm_get(struct drm_i915_private
*i915
);
1975 intel_wakeref_t
intel_runtime_pm_get_if_in_use(struct drm_i915_private
*i915
);
1976 intel_wakeref_t
intel_runtime_pm_get_noresume(struct drm_i915_private
*i915
);
1978 #define with_intel_runtime_pm(i915, wf) \
1979 for ((wf) = intel_runtime_pm_get(i915); (wf); \
1980 intel_runtime_pm_put((i915), (wf)), (wf) = 0)
1982 #define with_intel_runtime_pm_if_in_use(i915, wf) \
1983 for ((wf) = intel_runtime_pm_get_if_in_use(i915); (wf); \
1984 intel_runtime_pm_put((i915), (wf)), (wf) = 0)
1986 void intel_runtime_pm_put_unchecked(struct drm_i915_private
*i915
);
1987 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
1988 void intel_runtime_pm_put(struct drm_i915_private
*i915
, intel_wakeref_t wref
);
1990 #define intel_runtime_pm_put(i915, wref) intel_runtime_pm_put_unchecked(i915)
1993 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM)
1994 void print_intel_runtime_pm_wakeref(struct drm_i915_private
*i915
,
1995 struct drm_printer
*p
);
1997 static inline void print_intel_runtime_pm_wakeref(struct drm_i915_private
*i915
,
1998 struct drm_printer
*p
)
2003 void chv_phy_powergate_lanes(struct intel_encoder
*encoder
,
2004 bool override
, unsigned int mask
);
2005 bool chv_phy_powergate_ch(struct drm_i915_private
*dev_priv
, enum dpio_phy phy
,
2006 enum dpio_channel ch
, bool override
);
2008 /* intel_atomic.c */
2009 int intel_digital_connector_atomic_get_property(struct drm_connector
*connector
,
2010 const struct drm_connector_state
*state
,
2011 struct drm_property
*property
,
2013 int intel_digital_connector_atomic_set_property(struct drm_connector
*connector
,
2014 struct drm_connector_state
*state
,
2015 struct drm_property
*property
,
2017 int intel_digital_connector_atomic_check(struct drm_connector
*conn
,
2018 struct drm_connector_state
*new_state
);
2019 struct drm_connector_state
*
2020 intel_digital_connector_duplicate_state(struct drm_connector
*connector
);
2022 struct drm_crtc_state
*intel_crtc_duplicate_state(struct drm_crtc
*crtc
);
2023 void intel_crtc_destroy_state(struct drm_crtc
*crtc
,
2024 struct drm_crtc_state
*state
);
2025 struct drm_atomic_state
*intel_atomic_state_alloc(struct drm_device
*dev
);
2026 void intel_atomic_state_clear(struct drm_atomic_state
*);
2028 static inline struct intel_crtc_state
*
2029 intel_atomic_get_crtc_state(struct drm_atomic_state
*state
,
2030 struct intel_crtc
*crtc
)
2032 struct drm_crtc_state
*crtc_state
;
2033 crtc_state
= drm_atomic_get_crtc_state(state
, &crtc
->base
);
2034 if (IS_ERR(crtc_state
))
2035 return ERR_CAST(crtc_state
);
2037 return to_intel_crtc_state(crtc_state
);
2040 int intel_atomic_setup_scalers(struct drm_i915_private
*dev_priv
,
2041 struct intel_crtc
*intel_crtc
,
2042 struct intel_crtc_state
*crtc_state
);
2044 #endif /* __INTEL_DRV_H__ */