1 /*
2 * Copyright (c) 2006 Dave Airlie <airlied@linux.ie>
3 * Copyright (c) 2007-2008 Intel Corporation
4 * Jesse Barnes <jesse.barnes@intel.com>
5 *
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:
12 *
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
15 * Software.
16 *
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
23 * IN THE SOFTWARE.
24 */
25
26 #ifndef __INTEL_DISPLAY_TYPES_H__
27 #define __INTEL_DISPLAY_TYPES_H__
28
29 #include <linux/i2c.h>
30 #include <linux/pm_qos.h>
31 #include <linux/pwm.h>
32 #include <linux/sched/clock.h>
33
34 #include <drm/display/drm_dp_dual_mode_helper.h>
35 #include <drm/display/drm_dp_mst_helper.h>
36 #include <drm/display/drm_dsc.h>
37 #include <drm/drm_atomic.h>
38 #include <drm/drm_crtc.h>
39 #include <drm/drm_encoder.h>
40 #include <drm/drm_fourcc.h>
41 #include <drm/drm_framebuffer.h>
42 #include <drm/drm_probe_helper.h>
43 #include <drm/drm_rect.h>
44 #include <drm/drm_vblank.h>
45 #include <drm/drm_vblank_work.h>
46 #include <drm/i915_mei_hdcp_interface.h>
47 #include <media/cec-notifier.h>
48
49 #include "i915_vma.h"
50 #include "i915_vma_types.h"
51 #include "intel_bios.h"
52 #include "intel_display.h"
53 #include "intel_display_limits.h"
54 #include "intel_display_power.h"
55 #include "intel_dpll_mgr.h"
56 #include "intel_pm_types.h"
57
58 struct drm_printer;
59 struct __intel_global_objs_state;
60 struct intel_ddi_buf_trans;
61 struct intel_fbc;
62 struct intel_connector;
63
64 /*
65 * Display related stuff
66 */
67
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,
73 INTEL_OUTPUT_DVO = 2,
74 INTEL_OUTPUT_SDVO = 3,
75 INTEL_OUTPUT_LVDS = 4,
76 INTEL_OUTPUT_TVOUT = 5,
77 INTEL_OUTPUT_HDMI = 6,
78 INTEL_OUTPUT_DP = 7,
79 INTEL_OUTPUT_EDP = 8,
80 INTEL_OUTPUT_DSI = 9,
81 INTEL_OUTPUT_DDI = 10,
82 INTEL_OUTPUT_DP_MST = 11,
83 };
84
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 */
90 };
91
92 /* "Broadcast RGB" property */
93 enum intel_broadcast_rgb {
94 INTEL_BROADCAST_RGB_AUTO,
95 INTEL_BROADCAST_RGB_FULL,
96 INTEL_BROADCAST_RGB_LIMITED,
97 };
98
99 struct intel_fb_view {
100 /*
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.
108 */
109 struct i915_gtt_view gtt;
110
111 /*
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.
116 *
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
119 * intel_plane_state.
120 */
121 struct i915_color_plane_view {
122 u32 offset;
123 unsigned int x, y;
124 /*
125 * Plane stride in:
126 * bytes for 0/180 degree rotation
127 * pixels for 90/270 degree rotation
128 */
129 unsigned int mapping_stride;
130 unsigned int scanout_stride;
131 } color_plane[4];
132 };
133
134 struct intel_framebuffer {
135 struct drm_framebuffer base;
136 struct intel_frontbuffer *frontbuffer;
137
138 /* Params to remap the FB pages and program the plane registers in each view. */
139 struct intel_fb_view normal_view;
140 union {
141 struct intel_fb_view rotated_view;
142 struct intel_fb_view remapped_view;
143 };
144
145 struct i915_address_space *dpt_vm;
146 };
147
148 enum intel_hotplug_state {
149 INTEL_HOTPLUG_UNCHANGED,
150 INTEL_HOTPLUG_CHANGED,
151 INTEL_HOTPLUG_RETRY,
152 };
153
154 struct intel_encoder {
155 struct drm_encoder base;
156
157 enum intel_output_type type;
158 enum port port;
159 u16 cloneable;
160 u8 pipe_mask;
161 enum intel_hotplug_state (*hotplug)(struct intel_encoder *encoder,
162 struct intel_connector *connector);
163 enum intel_output_type (*compute_output_type)(struct intel_encoder *,
164 struct intel_crtc_state *,
165 struct drm_connector_state *);
166 int (*compute_config)(struct intel_encoder *,
167 struct intel_crtc_state *,
168 struct drm_connector_state *);
169 int (*compute_config_late)(struct intel_encoder *,
170 struct intel_crtc_state *,
171 struct drm_connector_state *);
172 void (*update_prepare)(struct intel_atomic_state *,
173 struct intel_encoder *,
174 struct intel_crtc *);
175 void (*pre_pll_enable)(struct intel_atomic_state *,
176 struct intel_encoder *,
177 const struct intel_crtc_state *,
178 const struct drm_connector_state *);
179 void (*pre_enable)(struct intel_atomic_state *,
180 struct intel_encoder *,
181 const struct intel_crtc_state *,
182 const struct drm_connector_state *);
183 void (*enable)(struct intel_atomic_state *,
184 struct intel_encoder *,
185 const struct intel_crtc_state *,
186 const struct drm_connector_state *);
187 void (*update_complete)(struct intel_atomic_state *,
188 struct intel_encoder *,
189 struct intel_crtc *);
190 void (*disable)(struct intel_atomic_state *,
191 struct intel_encoder *,
192 const struct intel_crtc_state *,
193 const struct drm_connector_state *);
194 void (*post_disable)(struct intel_atomic_state *,
195 struct intel_encoder *,
196 const struct intel_crtc_state *,
197 const struct drm_connector_state *);
198 void (*post_pll_disable)(struct intel_atomic_state *,
199 struct intel_encoder *,
200 const struct intel_crtc_state *,
201 const struct drm_connector_state *);
202 void (*update_pipe)(struct intel_atomic_state *,
203 struct intel_encoder *,
204 const struct intel_crtc_state *,
205 const struct drm_connector_state *);
206 /* Read out the current hw state of this connector, returning true if
207 * the encoder is active. If the encoder is enabled it also set the pipe
208 * it is connected to in the pipe parameter. */
209 bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe);
210 /* Reconstructs the equivalent mode flags for the current hardware
211 * state. This must be called _after_ display->get_pipe_config has
212 * pre-filled the pipe config. Note that intel_encoder->base.crtc must
213 * be set correctly before calling this function. */
214 void (*get_config)(struct intel_encoder *,
215 struct intel_crtc_state *pipe_config);
216
217 /*
218 * Optional hook called during init/resume to sync any state
219 * stored in the encoder (eg. DP link parameters) wrt. the HW state.
220 */
221 void (*sync_state)(struct intel_encoder *encoder,
222 const struct intel_crtc_state *crtc_state);
223
224 /*
225 * Optional hook, returning true if this encoder allows a fastset
226 * during the initial commit, false otherwise.
227 */
228 bool (*initial_fastset_check)(struct intel_encoder *encoder,
229 struct intel_crtc_state *crtc_state);
230
231 /*
232 * Acquires the power domains needed for an active encoder during
233 * hardware state readout.
234 */
235 void (*get_power_domains)(struct intel_encoder *encoder,
236 struct intel_crtc_state *crtc_state);
237 /*
238 * Called during system suspend after all pending requests for the
239 * encoder are flushed (for example for DP AUX transactions) and
240 * device interrupts are disabled.
241 */
242 void (*suspend)(struct intel_encoder *);
243 /*
244 * Called during system reboot/shutdown after all the
245 * encoders have been disabled and suspended.
246 */
247 void (*shutdown)(struct intel_encoder *encoder);
248 /*
249 * Enable/disable the clock to the port.
250 */
251 void (*enable_clock)(struct intel_encoder *encoder,
252 const struct intel_crtc_state *crtc_state);
253 void (*disable_clock)(struct intel_encoder *encoder);
254 /*
255 * Returns whether the port clock is enabled or not.
256 */
257 bool (*is_clock_enabled)(struct intel_encoder *encoder);
258 const struct intel_ddi_buf_trans *(*get_buf_trans)(struct intel_encoder *encoder,
259 const struct intel_crtc_state *crtc_state,
260 int *n_entries);
261 void (*set_signal_levels)(struct intel_encoder *encoder,
262 const struct intel_crtc_state *crtc_state);
263
264 enum hpd_pin hpd_pin;
265 enum intel_display_power_domain power_domain;
266
267 /* VBT information for this encoder (may be NULL for older platforms) */
268 const struct intel_bios_encoder_data *devdata;
269 };
270
271 struct intel_panel_bl_funcs {
272 /* Connector and platform specific backlight functions */
273 int (*setup)(struct intel_connector *connector, enum pipe pipe);
274 u32 (*get)(struct intel_connector *connector, enum pipe pipe);
275 void (*set)(const struct drm_connector_state *conn_state, u32 level);
276 void (*disable)(const struct drm_connector_state *conn_state, u32 level);
277 void (*enable)(const struct intel_crtc_state *crtc_state,
278 const struct drm_connector_state *conn_state, u32 level);
279 u32 (*hz_to_pwm)(struct intel_connector *connector, u32 hz);
280 };
281
282 enum drrs_type {
283 DRRS_TYPE_NONE,
284 DRRS_TYPE_STATIC,
285 DRRS_TYPE_SEAMLESS,
286 };
287
288 struct intel_vbt_panel_data {
289 struct drm_display_mode *lfp_lvds_vbt_mode; /* if any */
290 struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */
291
292 /* Feature bits */
293 int panel_type;
294 unsigned int lvds_dither:1;
295 unsigned int bios_lvds_val; /* initial [PCH_]LVDS reg val in VBIOS */
296
297 bool vrr;
298
299 u8 seamless_drrs_min_refresh_rate;
300 enum drrs_type drrs_type;
301
302 struct {
303 int max_link_rate;
304 int rate;
305 int lanes;
306 int preemphasis;
307 int vswing;
308 int bpp;
309 struct edp_power_seq pps;
310 u8 drrs_msa_timing_delay;
311 bool low_vswing;
312 bool initialized;
313 bool hobl;
314 } edp;
315
316 struct {
317 bool enable;
318 bool full_link;
319 bool require_aux_wakeup;
320 int idle_frames;
321 int tp1_wakeup_time_us;
322 int tp2_tp3_wakeup_time_us;
323 int psr2_tp2_tp3_wakeup_time_us;
324 } psr;
325
326 struct {
327 u16 pwm_freq_hz;
328 u16 brightness_precision_bits;
329 bool present;
330 bool active_low_pwm;
331 u8 min_brightness; /* min_brightness/255 of max */
332 s8 controller; /* brightness controller number */
333 enum intel_backlight_type type;
334 } backlight;
335
336 /* MIPI DSI */
337 struct {
338 u16 panel_id;
339 struct mipi_config *config;
340 struct mipi_pps_data *pps;
341 u16 bl_ports;
342 u16 cabc_ports;
343 u8 seq_version;
344 u32 size;
345 u8 *data;
346 const u8 *sequence[MIPI_SEQ_MAX];
347 u8 *deassert_seq; /* Used by fixup_mipi_sequences() */
348 enum drm_panel_orientation orientation;
349 } dsi;
350 };
351
352 struct intel_panel {
353 /* Fixed EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */
354 const struct drm_edid *fixed_edid;
355
356 struct list_head fixed_modes;
357
358 /* backlight */
359 struct {
360 bool present;
361 u32 level;
362 u32 min;
363 u32 max;
364 bool enabled;
365 bool combination_mode; /* gen 2/4 only */
366 bool active_low_pwm;
367 bool alternate_pwm_increment; /* lpt+ */
368
369 /* PWM chip */
370 u32 pwm_level_min;
371 u32 pwm_level_max;
372 bool pwm_enabled;
373 bool util_pin_active_low; /* bxt+ */
374 u8 controller; /* bxt+ only */
375 struct pwm_device *pwm;
376 struct pwm_state pwm_state;
377
378 /* DPCD backlight */
379 union {
380 struct {
381 struct drm_edp_backlight_info info;
382 } vesa;
383 struct {
384 bool sdr_uses_aux;
385 } intel;
386 } edp;
387
388 struct backlight_device *device;
389
390 const struct intel_panel_bl_funcs *funcs;
391 const struct intel_panel_bl_funcs *pwm_funcs;
392 void (*power)(struct intel_connector *, bool enable);
393 } backlight;
394
395 struct intel_vbt_panel_data vbt;
396 };
397
398 struct intel_digital_port;
399
400 enum check_link_response {
401 HDCP_LINK_PROTECTED = 0,
402 HDCP_TOPOLOGY_CHANGE,
403 HDCP_LINK_INTEGRITY_FAILURE,
404 HDCP_REAUTH_REQUEST
405 };
406
407 /*
408 * This structure serves as a translation layer between the generic HDCP code
409 * and the bus-specific code. What that means is that HDCP over HDMI differs
410 * from HDCP over DP, so to account for these differences, we need to
411 * communicate with the receiver through this shim.
412 *
413 * For completeness, the 2 buses differ in the following ways:
414 * - DP AUX vs. DDC
415 * HDCP registers on the receiver are set via DP AUX for DP, and
416 * they are set via DDC for HDMI.
417 * - Receiver register offsets
418 * The offsets of the registers are different for DP vs. HDMI
419 * - Receiver register masks/offsets
420 * For instance, the ready bit for the KSV fifo is in a different
421 * place on DP vs HDMI
422 * - Receiver register names
423 * Seriously. In the DP spec, the 16-bit register containing
424 * downstream information is called BINFO, on HDMI it's called
425 * BSTATUS. To confuse matters further, DP has a BSTATUS register
426 * with a completely different definition.
427 * - KSV FIFO
428 * On HDMI, the ksv fifo is read all at once, whereas on DP it must
429 * be read 3 keys at a time
430 * - Aksv output
431 * Since Aksv is hidden in hardware, there's different procedures
432 * to send it over DP AUX vs DDC
433 */
434 struct intel_hdcp_shim {
435 /* Outputs the transmitter's An and Aksv values to the receiver. */
436 int (*write_an_aksv)(struct intel_digital_port *dig_port, u8 *an);
437
438 /* Reads the receiver's key selection vector */
439 int (*read_bksv)(struct intel_digital_port *dig_port, u8 *bksv);
440
441 /*
442 * Reads BINFO from DP receivers and BSTATUS from HDMI receivers. The
443 * definitions are the same in the respective specs, but the names are
444 * different. Call it BSTATUS since that's the name the HDMI spec
445 * uses and it was there first.
446 */
447 int (*read_bstatus)(struct intel_digital_port *dig_port,
448 u8 *bstatus);
449
450 /* Determines whether a repeater is present downstream */
451 int (*repeater_present)(struct intel_digital_port *dig_port,
452 bool *repeater_present);
453
454 /* Reads the receiver's Ri' value */
455 int (*read_ri_prime)(struct intel_digital_port *dig_port, u8 *ri);
456
457 /* Determines if the receiver's KSV FIFO is ready for consumption */
458 int (*read_ksv_ready)(struct intel_digital_port *dig_port,
459 bool *ksv_ready);
460
461 /* Reads the ksv fifo for num_downstream devices */
462 int (*read_ksv_fifo)(struct intel_digital_port *dig_port,
463 int num_downstream, u8 *ksv_fifo);
464
465 /* Reads a 32-bit part of V' from the receiver */
466 int (*read_v_prime_part)(struct intel_digital_port *dig_port,
467 int i, u32 *part);
468
469 /* Enables HDCP signalling on the port */
470 int (*toggle_signalling)(struct intel_digital_port *dig_port,
471 enum transcoder cpu_transcoder,
472 bool enable);
473
474 /* Enable/Disable stream encryption on DP MST Transport Link */
475 int (*stream_encryption)(struct intel_connector *connector,
476 bool enable);
477
478 /* Ensures the link is still protected */
479 bool (*check_link)(struct intel_digital_port *dig_port,
480 struct intel_connector *connector);
481
482 /* Detects panel's hdcp capability. This is optional for HDMI. */
483 int (*hdcp_capable)(struct intel_digital_port *dig_port,
484 bool *hdcp_capable);
485
486 /* HDCP adaptation(DP/HDMI) required on the port */
487 enum hdcp_wired_protocol protocol;
488
489 /* Detects whether sink is HDCP2.2 capable */
490 int (*hdcp_2_2_capable)(struct intel_digital_port *dig_port,
491 bool *capable);
492
493 /* Write HDCP2.2 messages */
494 int (*write_2_2_msg)(struct intel_digital_port *dig_port,
495 void *buf, size_t size);
496
497 /* Read HDCP2.2 messages */
498 int (*read_2_2_msg)(struct intel_digital_port *dig_port,
499 u8 msg_id, void *buf, size_t size);
500
501 /*
502 * Implementation of DP HDCP2.2 Errata for the communication of stream
503 * type to Receivers. In DP HDCP2.2 Stream type is one of the input to
504 * the HDCP2.2 Cipher for En/De-Cryption. Not applicable for HDMI.
505 */
506 int (*config_stream_type)(struct intel_digital_port *dig_port,
507 bool is_repeater, u8 type);
508
509 /* Enable/Disable HDCP 2.2 stream encryption on DP MST Transport Link */
510 int (*stream_2_2_encryption)(struct intel_connector *connector,
511 bool enable);
512
513 /* HDCP2.2 Link Integrity Check */
514 int (*check_2_2_link)(struct intel_digital_port *dig_port,
515 struct intel_connector *connector);
516 };
517
518 struct intel_hdcp {
519 const struct intel_hdcp_shim *shim;
520 /* Mutex for hdcp state of the connector */
521 struct mutex mutex;
522 u64 value;
523 struct delayed_work check_work;
524 struct work_struct prop_work;
525
526 /* HDCP1.4 Encryption status */
527 bool hdcp_encrypted;
528
529 /* HDCP2.2 related definitions */
530 /* Flag indicates whether this connector supports HDCP2.2 or not. */
531 bool hdcp2_supported;
532
533 /* HDCP2.2 Encryption status */
534 bool hdcp2_encrypted;
535
536 /*
537 * Content Stream Type defined by content owner. TYPE0(0x0) content can
538 * flow in the link protected by HDCP2.2 or HDCP1.4, where as TYPE1(0x1)
539 * content can flow only through a link protected by HDCP2.2.
540 */
541 u8 content_type;
542
543 bool is_paired;
544 bool is_repeater;
545
546 /*
547 * Count of ReceiverID_List received. Initialized to 0 at AKE_INIT.
548 * Incremented after processing the RepeaterAuth_Send_ReceiverID_List.
549 * When it rolls over re-auth has to be triggered.
550 */
551 u32 seq_num_v;
552
553 /*
554 * Count of RepeaterAuth_Stream_Manage msg propagated.
555 * Initialized to 0 on AKE_INIT. Incremented after every successful
556 * transmission of RepeaterAuth_Stream_Manage message. When it rolls
557 * over re-Auth has to be triggered.
558 */
559 u32 seq_num_m;
560
561 /*
562 * Work queue to signal the CP_IRQ. Used for the waiters to read the
563 * available information from HDCP DP sink.
564 */
565 wait_queue_head_t cp_irq_queue;
566 atomic_t cp_irq_count;
567 int cp_irq_count_cached;
568
569 /*
570 * HDCP register access for gen12+ need the transcoder associated.
571 * Transcoder attached to the connector could be changed at modeset.
572 * Hence caching the transcoder here.
573 */
574 enum transcoder cpu_transcoder;
575 /* Only used for DP MST stream encryption */
576 enum transcoder stream_transcoder;
577 };
578
579 struct intel_connector {
580 struct drm_connector base;
581 /*
582 * The fixed encoder this connector is connected to.
583 */
584 struct intel_encoder *encoder;
585
586 /* ACPI device id for ACPI and driver cooperation */
587 u32 acpi_device_id;
588
589 /* Reads out the current hw, returning true if the connector is enabled
590 * and active (i.e. dpms ON state). */
591 bool (*get_hw_state)(struct intel_connector *);
592
593 /* Panel info for eDP and LVDS */
594 struct intel_panel panel;
595
596 /* Cached EDID for detect. */
597 const struct drm_edid *detect_edid;
598
599 /* Number of times hotplug detection was tried after an HPD interrupt */
600 int hotplug_retries;
601
602 /* since POLL and HPD connectors may use the same HPD line keep the native
603 state of connector->polled in case hotplug storm detection changes it */
604 u8 polled;
605
606 struct drm_dp_mst_port *port;
607
608 struct intel_dp *mst_port;
609
610 /* Work struct to schedule a uevent on link train failure */
611 struct work_struct modeset_retry_work;
612
613 struct intel_hdcp hdcp;
614 };
615
616 struct intel_digital_connector_state {
617 struct drm_connector_state base;
618
619 enum hdmi_force_audio force_audio;
620 int broadcast_rgb;
621 };
622
623 #define to_intel_digital_connector_state(x) container_of(x, struct intel_digital_connector_state, base)
624
625 struct dpll {
626 /* given values */
627 int n;
628 int m1, m2;
629 int p1, p2;
630 /* derived values */
631 int dot;
632 int vco;
633 int m;
634 int p;
635 };
636
637 struct intel_atomic_state {
638 struct drm_atomic_state base;
639
640 intel_wakeref_t wakeref;
641
642 struct __intel_global_objs_state *global_objs;
643 int num_global_objs;
644
645 bool dpll_set, modeset;
646
647 struct intel_shared_dpll_state shared_dpll[I915_NUM_PLLS];
648
649 /*
650 * Current watermarks can't be trusted during hardware readout, so
651 * don't bother calculating intermediate watermarks.
652 */
653 bool skip_intermediate_wm;
654
655 bool rps_interactive;
656
657 struct i915_sw_fence commit_ready;
658
659 struct llist_node freed;
660 };
661
662 struct intel_plane_state {
663 struct drm_plane_state uapi;
664
665 /*
666 * actual hardware state, the state we program to the hardware.
667 * The following members are used to verify the hardware state:
668 * During initial hw readout, they need to be copied from uapi.
669 */
670 struct {
671 struct drm_crtc *crtc;
672 struct drm_framebuffer *fb;
673
674 u16 alpha;
675 u16 pixel_blend_mode;
676 unsigned int rotation;
677 enum drm_color_encoding color_encoding;
678 enum drm_color_range color_range;
679 enum drm_scaling_filter scaling_filter;
680 } hw;
681
682 struct i915_vma *ggtt_vma;
683 struct i915_vma *dpt_vma;
684 unsigned long flags;
685 #define PLANE_HAS_FENCE BIT(0)
686
687 struct intel_fb_view view;
688
689 /* Plane pxp decryption state */
690 bool decrypt;
691
692 /* Plane state to display black pixels when pxp is borked */
693 bool force_black;
694
695 /* plane control register */
696 u32 ctl;
697
698 /* plane color control register */
699 u32 color_ctl;
700
701 /* chroma upsampler control register */
702 u32 cus_ctl;
703
704 /*
705 * scaler_id
706 * = -1 : not using a scaler
707 * >= 0 : using a scalers
708 *
709 * plane requiring a scaler:
710 * - During check_plane, its bit is set in
711 * crtc_state->scaler_state.scaler_users by calling helper function
712 * update_scaler_plane.
713 * - scaler_id indicates the scaler it got assigned.
714 *
715 * plane doesn't require a scaler:
716 * - this can happen when scaling is no more required or plane simply
717 * got disabled.
718 * - During check_plane, corresponding bit is reset in
719 * crtc_state->scaler_state.scaler_users by calling helper function
720 * update_scaler_plane.
721 */
722 int scaler_id;
723
724 /*
725 * planar_linked_plane:
726 *
727 * ICL planar formats require 2 planes that are updated as pairs.
728 * This member is used to make sure the other plane is also updated
729 * when required, and for update_slave() to find the correct
730 * plane_state to pass as argument.
731 */
732 struct intel_plane *planar_linked_plane;
733
734 /*
735 * planar_slave:
736 * If set don't update use the linked plane's state for updating
737 * this plane during atomic commit with the update_slave() callback.
738 *
739 * It's also used by the watermark code to ignore wm calculations on
740 * this plane. They're calculated by the linked plane's wm code.
741 */
742 u32 planar_slave;
743
744 struct drm_intel_sprite_colorkey ckey;
745
746 struct drm_rect psr2_sel_fetch_area;
747
748 /* Clear Color Value */
749 u64 ccval;
750
751 const char *no_fbc_reason;
752 };
753
754 struct intel_initial_plane_config {
755 struct intel_framebuffer *fb;
756 struct i915_vma *vma;
757 unsigned int tiling;
758 int size;
759 u32 base;
760 u8 rotation;
761 };
762
763 struct intel_scaler {
764 int in_use;
765 u32 mode;
766 };
767
768 struct intel_crtc_scaler_state {
769 #define SKL_NUM_SCALERS 2
770 struct intel_scaler scalers[SKL_NUM_SCALERS];
771
772 /*
773 * scaler_users: keeps track of users requesting scalers on this crtc.
774 *
775 * If a bit is set, a user is using a scaler.
776 * Here user can be a plane or crtc as defined below:
777 * bits 0-30 - plane (bit position is index from drm_plane_index)
778 * bit 31 - crtc
779 *
780 * Instead of creating a new index to cover planes and crtc, using
781 * existing drm_plane_index for planes which is well less than 31
782 * planes and bit 31 for crtc. This should be fine to cover all
783 * our platforms.
784 *
785 * intel_atomic_setup_scalers will setup available scalers to users
786 * requesting scalers. It will gracefully fail if request exceeds
787 * avilability.
788 */
789 #define SKL_CRTC_INDEX 31
790 unsigned scaler_users;
791
792 /* scaler used by crtc for panel fitting purpose */
793 int scaler_id;
794 };
795
796 /* {crtc,crtc_state}->mode_flags */
797 /* Flag to get scanline using frame time stamps */
798 #define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1)
799 /* Flag to use the scanline counter instead of the pixel counter */
800 #define I915_MODE_FLAG_USE_SCANLINE_COUNTER (1<<2)
801 /*
802 * TE0 or TE1 flag is set if the crtc has a DSI encoder which
803 * is operating in command mode.
804 * Flag to use TE from DSI0 instead of VBI in command mode
805 */
806 #define I915_MODE_FLAG_DSI_USE_TE0 (1<<3)
807 /* Flag to use TE from DSI1 instead of VBI in command mode */
808 #define I915_MODE_FLAG_DSI_USE_TE1 (1<<4)
809 /* Flag to indicate mipi dsi periodic command mode where we do not get TE */
810 #define I915_MODE_FLAG_DSI_PERIODIC_CMD_MODE (1<<5)
811 /* Do tricks to make vblank timestamps sane with VRR? */
812 #define I915_MODE_FLAG_VRR (1<<6)
813
814 struct intel_wm_level {
815 bool enable;
816 u32 pri_val;
817 u32 spr_val;
818 u32 cur_val;
819 u32 fbc_val;
820 };
821
822 struct intel_pipe_wm {
823 struct intel_wm_level wm[5];
824 bool fbc_wm_enabled;
825 bool pipe_enabled;
826 bool sprites_enabled;
827 bool sprites_scaled;
828 };
829
830 struct skl_wm_level {
831 u16 min_ddb_alloc;
832 u16 blocks;
833 u8 lines;
834 bool enable;
835 bool ignore_lines;
836 bool can_sagv;
837 };
838
839 struct skl_plane_wm {
840 struct skl_wm_level wm[8];
841 struct skl_wm_level uv_wm[8];
842 struct skl_wm_level trans_wm;
843 struct {
844 struct skl_wm_level wm0;
845 struct skl_wm_level trans_wm;
846 } sagv;
847 bool is_planar;
848 };
849
850 struct skl_pipe_wm {
851 struct skl_plane_wm planes[I915_MAX_PLANES];
852 bool use_sagv_wm;
853 };
854
855 enum vlv_wm_level {
856 VLV_WM_LEVEL_PM2,
857 VLV_WM_LEVEL_PM5,
858 VLV_WM_LEVEL_DDR_DVFS,
859 NUM_VLV_WM_LEVELS,
860 };
861
862 struct vlv_wm_state {
863 struct g4x_pipe_wm wm[NUM_VLV_WM_LEVELS];
864 struct g4x_sr_wm sr[NUM_VLV_WM_LEVELS];
865 u8 num_levels;
866 bool cxsr;
867 };
868
869 struct vlv_fifo_state {
870 u16 plane[I915_MAX_PLANES];
871 };
872
873 enum g4x_wm_level {
874 G4X_WM_LEVEL_NORMAL,
875 G4X_WM_LEVEL_SR,
876 G4X_WM_LEVEL_HPLL,
877 NUM_G4X_WM_LEVELS,
878 };
879
880 struct g4x_wm_state {
881 struct g4x_pipe_wm wm;
882 struct g4x_sr_wm sr;
883 struct g4x_sr_wm hpll;
884 bool cxsr;
885 bool hpll_en;
886 bool fbc_en;
887 };
888
889 struct intel_crtc_wm_state {
890 union {
891 /*
892 * raw:
893 * The "raw" watermark values produced by the formula
894 * given the plane's current state. They do not consider
895 * how much FIFO is actually allocated for each plane.
896 *
897 * optimal:
898 * The "optimal" watermark values given the current
899 * state of the planes and the amount of FIFO
900 * allocated to each, ignoring any previous state
901 * of the planes.
902 *
903 * intermediate:
904 * The "intermediate" watermark values when transitioning
905 * between the old and new "optimal" values. Used when
906 * the watermark registers are single buffered and hence
907 * their state changes asynchronously with regards to the
908 * actual plane registers. These are essentially the
909 * worst case combination of the old and new "optimal"
910 * watermarks, which are therefore safe to use when the
911 * plane is in either its old or new state.
912 */
913 struct {
914 struct intel_pipe_wm intermediate;
915 struct intel_pipe_wm optimal;
916 } ilk;
917
918 struct {
919 struct skl_pipe_wm raw;
920 /* gen9+ only needs 1-step wm programming */
921 struct skl_pipe_wm optimal;
922 struct skl_ddb_entry ddb;
923 /*
924 * pre-icl: for packed/planar CbCr
925 * icl+: for everything
926 */
927 struct skl_ddb_entry plane_ddb[I915_MAX_PLANES];
928 /* pre-icl: for planar Y */
929 struct skl_ddb_entry plane_ddb_y[I915_MAX_PLANES];
930 } skl;
931
932 struct {
933 struct g4x_pipe_wm raw[NUM_VLV_WM_LEVELS]; /* not inverted */
934 struct vlv_wm_state intermediate; /* inverted */
935 struct vlv_wm_state optimal; /* inverted */
936 struct vlv_fifo_state fifo_state;
937 } vlv;
938
939 struct {
940 struct g4x_pipe_wm raw[NUM_G4X_WM_LEVELS];
941 struct g4x_wm_state intermediate;
942 struct g4x_wm_state optimal;
943 } g4x;
944 };
945
946 /*
947 * Platforms with two-step watermark programming will need to
948 * update watermark programming post-vblank to switch from the
949 * safe intermediate watermarks to the optimal final
950 * watermarks.
951 */
952 bool need_postvbl_update;
953 };
954
955 enum intel_output_format {
956 INTEL_OUTPUT_FORMAT_RGB,
957 INTEL_OUTPUT_FORMAT_YCBCR420,
958 INTEL_OUTPUT_FORMAT_YCBCR444,
959 };
960
961 struct intel_mpllb_state {
962 u32 clock; /* in KHz */
963 u32 ref_control;
964 u32 mpllb_cp;
965 u32 mpllb_div;
966 u32 mpllb_div2;
967 u32 mpllb_fracn1;
968 u32 mpllb_fracn2;
969 u32 mpllb_sscen;
970 u32 mpllb_sscstep;
971 };
972
973 /* Used by dp and fdi links */
974 struct intel_link_m_n {
975 u32 tu;
976 u32 data_m;
977 u32 data_n;
978 u32 link_m;
979 u32 link_n;
980 };
981
982 struct intel_crtc_state {
983 /*
984 * uapi (drm) state. This is the software state shown to userspace.
985 * In particular, the following members are used for bookkeeping:
986 * - crtc
987 * - state
988 * - *_changed
989 * - event
990 * - commit
991 * - mode_blob
992 */
993 struct drm_crtc_state uapi;
994
995 /*
996 * actual hardware state, the state we program to the hardware.
997 * The following members are used to verify the hardware state:
998 * - enable
999 * - active
1000 * - mode / pipe_mode / adjusted_mode
1001 * - color property blobs.
1002 *
1003 * During initial hw readout, they need to be copied to uapi.
1004 *
1005 * Bigjoiner will allow a transcoder mode that spans 2 pipes;
1006 * Use the pipe_mode for calculations like watermarks, pipe
1007 * scaler, and bandwidth.
1008 *
1009 * Use adjusted_mode for things that need to know the full
1010 * mode on the transcoder, which spans all pipes.
1011 */
1012 struct {
1013 bool active, enable;
1014 /* logical state of LUTs */
1015 struct drm_property_blob *degamma_lut, *gamma_lut, *ctm;
1016 struct drm_display_mode mode, pipe_mode, adjusted_mode;
1017 enum drm_scaling_filter scaling_filter;
1018 } hw;
1019
1020 /* actual state of LUTs */
1021 struct drm_property_blob *pre_csc_lut, *post_csc_lut;
1022
1023 /**
1024 * quirks - bitfield with hw state readout quirks
1025 *
1026 * For various reasons the hw state readout code might not be able to
1027 * completely faithfully read out the current state. These cases are
1028 * tracked with quirk flags so that fastboot and state checker can act
1029 * accordingly.
1030 */
1031 #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */
1032 unsigned long quirks;
1033
1034 unsigned fb_bits; /* framebuffers to flip */
1035 bool update_pipe; /* can a fast modeset be performed? */
1036 bool disable_cxsr;
1037 bool update_wm_pre, update_wm_post; /* watermarks are updated */
1038 bool fifo_changed; /* FIFO split is changed */
1039 bool preload_luts;
1040 bool inherited; /* state inherited from BIOS? */
1041
1042 /* Ask the hardware to actually async flip? */
1043 bool do_async_flip;
1044
1045 /* Pipe source size (ie. panel fitter input size)
1046 * All planes will be positioned inside this space,
1047 * and get clipped at the edges. */
1048 struct drm_rect pipe_src;
1049
1050 /*
1051 * Pipe pixel rate, adjusted for
1052 * panel fitter/pipe scaler downscaling.
1053 */
1054 unsigned int pixel_rate;
1055
1056 /* Whether to set up the PCH/FDI. Note that we never allow sharing
1057 * between pch encoders and cpu encoders. */
1058 bool has_pch_encoder;
1059
1060 /* Are we sending infoframes on the attached port */
1061 bool has_infoframe;
1062
1063 /* CPU Transcoder for the pipe. Currently this can only differ from the
1064 * pipe on Haswell and later (where we have a special eDP transcoder)
1065 * and Broxton (where we have special DSI transcoders). */
1066 enum transcoder cpu_transcoder;
1067
1068 /*
1069 * Use reduced/limited/broadcast rbg range, compressing from the full
1070 * range fed into the crtcs.
1071 */
1072 bool limited_color_range;
1073
1074 /* Bitmask of encoder types (enum intel_output_type)
1075 * driven by the pipe.
1076 */
1077 unsigned int output_types;
1078
1079 /* Whether we should send NULL infoframes. Required for audio. */
1080 bool has_hdmi_sink;
1081
1082 /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or
1083 * has_dp_encoder is set. */
1084 bool has_audio;
1085
1086 /*
1087 * Enable dithering, used when the selected pipe bpp doesn't match the
1088 * plane bpp.
1089 */
1090 bool dither;
1091
1092 /*
1093 * Dither gets enabled for 18bpp which causes CRC mismatch errors for
1094 * compliance video pattern tests.
1095 * Disable dither only if it is a compliance test request for
1096 * 18bpp.
1097 */
1098 bool dither_force_disable;
1099
1100 /* Controls for the clock computation, to override various stages. */
1101 bool clock_set;
1102
1103 /* SDVO TV has a bunch of special case. To make multifunction encoders
1104 * work correctly, we need to track this at runtime.*/
1105 bool sdvo_tv_clock;
1106
1107 /*
1108 * crtc bandwidth limit, don't increase pipe bpp or clock if not really
1109 * required. This is set in the 2nd loop of calling encoder's
1110 * ->compute_config if the first pick doesn't work out.
1111 */
1112 bool bw_constrained;
1113
1114 /* Settings for the intel dpll used on pretty much everything but
1115 * haswell. */
1116 struct dpll dpll;
1117
1118 /* Selected dpll when shared or NULL. */
1119 struct intel_shared_dpll *shared_dpll;
1120
1121 /* Actual register state of the dpll, for shared dpll cross-checking. */
1122 union {
1123 struct intel_dpll_hw_state dpll_hw_state;
1124 struct intel_mpllb_state mpllb_state;
1125 };
1126
1127 /*
1128 * ICL reserved DPLLs for the CRTC/port. The active PLL is selected by
1129 * setting shared_dpll and dpll_hw_state to one of these reserved ones.
1130 */
1131 struct icl_port_dpll {
1132 struct intel_shared_dpll *pll;
1133 struct intel_dpll_hw_state hw_state;
1134 } icl_port_dplls[ICL_PORT_DPLL_COUNT];
1135
1136 /* DSI PLL registers */
1137 struct {
1138 u32 ctrl, div;
1139 } dsi_pll;
1140
1141 int pipe_bpp;
1142 struct intel_link_m_n dp_m_n;
1143
1144 /* m2_n2 for eDP downclock */
1145 struct intel_link_m_n dp_m2_n2;
1146 bool has_drrs;
1147 bool seamless_m_n;
1148
1149 /* PSR is supported but might not be enabled due the lack of enabled planes */
1150 bool has_psr;
1151 bool has_psr2;
1152 bool enable_psr2_sel_fetch;
1153 bool req_psr2_sdp_prior_scanline;
1154 u32 dc3co_exitline;
1155 u16 su_y_granularity;
1156 struct drm_dp_vsc_sdp psr_vsc;
1157
1158 /*
1159 * Frequence the dpll for the port should run at. Differs from the
1160 * adjusted dotclock e.g. for DP or 10/12bpc hdmi mode. This is also
1161 * already multiplied by pixel_multiplier.
1162 */
1163 int port_clock;
1164
1165 /* Used by SDVO (and if we ever fix it, HDMI). */
1166 unsigned pixel_multiplier;
1167
1168 /* I915_MODE_FLAG_* */
1169 u8 mode_flags;
1170
1171 u8 lane_count;
1172
1173 /*
1174 * Used by platforms having DP/HDMI PHY with programmable lane
1175 * latency optimization.
1176 */
1177 u8 lane_lat_optim_mask;
1178
1179 /* minimum acceptable voltage level */
1180 u8 min_voltage_level;
1181
1182 /* Panel fitter controls for gen2-gen4 + VLV */
1183 struct {
1184 u32 control;
1185 u32 pgm_ratios;
1186 u32 lvds_border_bits;
1187 } gmch_pfit;
1188
1189 /* Panel fitter placement and size for Ironlake+ */
1190 struct {
1191 struct drm_rect dst;
1192 bool enabled;
1193 bool force_thru;
1194 } pch_pfit;
1195
1196 /* FDI configuration, only valid if has_pch_encoder is set. */
1197 int fdi_lanes;
1198 struct intel_link_m_n fdi_m_n;
1199
1200 bool ips_enabled;
1201
1202 bool crc_enabled;
1203
1204 bool double_wide;
1205
1206 int pbn;
1207
1208 struct intel_crtc_scaler_state scaler_state;
1209
1210 /* w/a for waiting 2 vblanks during crtc enable */
1211 enum pipe hsw_workaround_pipe;
1212
1213 /* IVB sprite scaling w/a (WaCxSRDisabledForSpriteScaling:ivb) */
1214 bool disable_lp_wm;
1215
1216 struct intel_crtc_wm_state wm;
1217
1218 int min_cdclk[I915_MAX_PLANES];
1219
1220 /* for packed/planar CbCr */
1221 u32 data_rate[I915_MAX_PLANES];
1222 /* for planar Y */
1223 u32 data_rate_y[I915_MAX_PLANES];
1224
1225 /* FIXME unify with data_rate[]? */
1226 u64 rel_data_rate[I915_MAX_PLANES];
1227 u64 rel_data_rate_y[I915_MAX_PLANES];
1228
1229 /* Gamma mode programmed on the pipe */
1230 u32 gamma_mode;
1231
1232 union {
1233 /* CSC mode programmed on the pipe */
1234 u32 csc_mode;
1235
1236 /* CHV CGM mode */
1237 u32 cgm_mode;
1238 };
1239
1240 /* bitmask of logically enabled planes (enum plane_id) */
1241 u8 enabled_planes;
1242
1243 /* bitmask of actually visible planes (enum plane_id) */
1244 u8 active_planes;
1245 u8 scaled_planes;
1246 u8 nv12_planes;
1247 u8 c8_planes;
1248
1249 /* bitmask of planes that will be updated during the commit */
1250 u8 update_planes;
1251
1252 u8 framestart_delay; /* 1-4 */
1253 u8 msa_timing_delay; /* 0-3 */
1254
1255 struct {
1256 u32 enable;
1257 u32 gcp;
1258 union hdmi_infoframe avi;
1259 union hdmi_infoframe spd;
1260 union hdmi_infoframe hdmi;
1261 union hdmi_infoframe drm;
1262 struct drm_dp_vsc_sdp vsc;
1263 } infoframes;
1264
1265 u8 eld[MAX_ELD_BYTES];
1266
1267 /* HDMI scrambling status */
1268 bool hdmi_scrambling;
1269
1270 /* HDMI High TMDS char rate ratio */
1271 bool hdmi_high_tmds_clock_ratio;
1272
1273 /* Output format RGB/YCBCR etc */
1274 enum intel_output_format output_format;
1275
1276 /* enable pipe gamma? */
1277 bool gamma_enable;
1278
1279 /* enable pipe csc? */
1280 bool csc_enable;
1281
1282 /* big joiner pipe bitmask */
1283 u8 bigjoiner_pipes;
1284
1285 /* Display Stream compression state */
1286 struct {
1287 bool compression_enable;
1288 bool dsc_split;
1289 u16 compressed_bpp;
1290 u8 slice_count;
1291 struct drm_dsc_config config;
1292 } dsc;
1293
1294 /* HSW+ linetime watermarks */
1295 u16 linetime;
1296 u16 ips_linetime;
1297
1298 /* Forward Error correction State */
1299 bool fec_enable;
1300
1301 bool sdp_split_enable;
1302
1303 /* Pointer to master transcoder in case of tiled displays */
1304 enum transcoder master_transcoder;
1305
1306 /* Bitmask to indicate slaves attached */
1307 u8 sync_mode_slaves_mask;
1308
1309 /* Only valid on TGL+ */
1310 enum transcoder mst_master_transcoder;
1311
1312 /* For DSB related info */
1313 struct intel_dsb *dsb;
1314
1315 u32 psr2_man_track_ctl;
1316
1317 /* Variable Refresh Rate state */
1318 struct {
1319 bool enable;
1320 u8 pipeline_full;
1321 u16 flipline, vmin, vmax, guardband;
1322 } vrr;
1323
1324 /* Stream Splitter for eDP MSO */
1325 struct {
1326 bool enable;
1327 u8 link_count;
1328 u8 pixel_overlap;
1329 } splitter;
1330
1331 /* for loading single buffered registers during vblank */
1332 struct drm_vblank_work vblank_work;
1333 };
1334
1335 enum intel_pipe_crc_source {
1336 INTEL_PIPE_CRC_SOURCE_NONE,
1337 INTEL_PIPE_CRC_SOURCE_PLANE1,
1338 INTEL_PIPE_CRC_SOURCE_PLANE2,
1339 INTEL_PIPE_CRC_SOURCE_PLANE3,
1340 INTEL_PIPE_CRC_SOURCE_PLANE4,
1341 INTEL_PIPE_CRC_SOURCE_PLANE5,
1342 INTEL_PIPE_CRC_SOURCE_PLANE6,
1343 INTEL_PIPE_CRC_SOURCE_PLANE7,
1344 INTEL_PIPE_CRC_SOURCE_PIPE,
1345 /* TV/DP on pre-gen5/vlv can't use the pipe source. */
1346 INTEL_PIPE_CRC_SOURCE_TV,
1347 INTEL_PIPE_CRC_SOURCE_DP_B,
1348 INTEL_PIPE_CRC_SOURCE_DP_C,
1349 INTEL_PIPE_CRC_SOURCE_DP_D,
1350 INTEL_PIPE_CRC_SOURCE_AUTO,
1351 INTEL_PIPE_CRC_SOURCE_MAX,
1352 };
1353
1354 enum drrs_refresh_rate {
1355 DRRS_REFRESH_RATE_HIGH,
1356 DRRS_REFRESH_RATE_LOW,
1357 };
1358
1359 #define INTEL_PIPE_CRC_ENTRIES_NR 128
1360 struct intel_pipe_crc {
1361 spinlock_t lock;
1362 int skipped;
1363 enum intel_pipe_crc_source source;
1364 };
1365
1366 struct intel_crtc {
1367 struct drm_crtc base;
1368 enum pipe pipe;
1369 /*
1370 * Whether the crtc and the connected output pipeline is active. Implies
1371 * that crtc->enabled is set, i.e. the current mode configuration has
1372 * some outputs connected to this crtc.
1373 */
1374 bool active;
1375 u8 plane_ids_mask;
1376
1377 /* I915_MODE_FLAG_* */
1378 u8 mode_flags;
1379
1380 u16 vmax_vblank_start;
1381
1382 struct intel_display_power_domain_set enabled_power_domains;
1383 struct intel_display_power_domain_set hw_readout_power_domains;
1384 struct intel_overlay *overlay;
1385
1386 struct intel_crtc_state *config;
1387
1388 /* Access to these should be protected by dev_priv->irq_lock. */
1389 bool cpu_fifo_underrun_disabled;
1390 bool pch_fifo_underrun_disabled;
1391
1392 /* per-pipe watermark state */
1393 struct {
1394 /* watermarks currently being used */
1395 union {
1396 struct intel_pipe_wm ilk;
1397 struct vlv_wm_state vlv;
1398 struct g4x_wm_state g4x;
1399 } active;
1400 } wm;
1401
1402 struct {
1403 struct mutex mutex;
1404 struct delayed_work work;
1405 enum drrs_refresh_rate refresh_rate;
1406 unsigned int frontbuffer_bits;
1407 unsigned int busy_frontbuffer_bits;
1408 enum transcoder cpu_transcoder;
1409 struct intel_link_m_n m_n, m2_n2;
1410 } drrs;
1411
1412 int scanline_offset;
1413
1414 struct {
1415 unsigned start_vbl_count;
1416 ktime_t start_vbl_time;
1417 int min_vbl, max_vbl;
1418 int scanline_start;
1419 #ifdef CONFIG_DRM_I915_DEBUG_VBLANK_EVADE
1420 struct {
1421 u64 min;
1422 u64 max;
1423 u64 sum;
1424 unsigned int over;
1425 unsigned int times[17]; /* [1us, 16ms] */
1426 } vbl;
1427 #endif
1428 } debug;
1429
1430 /* scalers available on this crtc */
1431 int num_scalers;
1432
1433 /* for loading single buffered registers during vblank */
1434 struct pm_qos_request vblank_pm_qos;
1435
1436 #ifdef CONFIG_DEBUG_FS
1437 struct intel_pipe_crc pipe_crc;
1438 #endif
1439 };
1440
1441 struct intel_plane {
1442 struct drm_plane base;
1443 enum i9xx_plane_id i9xx_plane;
1444 enum plane_id id;
1445 enum pipe pipe;
1446 bool need_async_flip_disable_wa;
1447 u32 frontbuffer_bit;
1448
1449 struct {
1450 u32 base, cntl, size;
1451 } cursor;
1452
1453 struct intel_fbc *fbc;
1454
1455 /*
1456 * NOTE: Do not place new plane state fields here (e.g., when adding
1457 * new plane properties). New runtime state should now be placed in
1458 * the intel_plane_state structure and accessed via plane_state.
1459 */
1460
1461 int (*min_width)(const struct drm_framebuffer *fb,
1462 int color_plane,
1463 unsigned int rotation);
1464 int (*max_width)(const struct drm_framebuffer *fb,
1465 int color_plane,
1466 unsigned int rotation);
1467 int (*max_height)(const struct drm_framebuffer *fb,
1468 int color_plane,
1469 unsigned int rotation);
1470 unsigned int (*max_stride)(struct intel_plane *plane,
1471 u32 pixel_format, u64 modifier,
1472 unsigned int rotation);
1473 /* Write all non-self arming plane registers */
1474 void (*update_noarm)(struct intel_plane *plane,
1475 const struct intel_crtc_state *crtc_state,
1476 const struct intel_plane_state *plane_state);
1477 /* Write all self-arming plane registers */
1478 void (*update_arm)(struct intel_plane *plane,
1479 const struct intel_crtc_state *crtc_state,
1480 const struct intel_plane_state *plane_state);
1481 /* Disable the plane, must arm */
1482 void (*disable_arm)(struct intel_plane *plane,
1483 const struct intel_crtc_state *crtc_state);
1484 bool (*get_hw_state)(struct intel_plane *plane, enum pipe *pipe);
1485 int (*check_plane)(struct intel_crtc_state *crtc_state,
1486 struct intel_plane_state *plane_state);
1487 int (*min_cdclk)(const struct intel_crtc_state *crtc_state,
1488 const struct intel_plane_state *plane_state);
1489 void (*async_flip)(struct intel_plane *plane,
1490 const struct intel_crtc_state *crtc_state,
1491 const struct intel_plane_state *plane_state,
1492 bool async_flip);
1493 void (*enable_flip_done)(struct intel_plane *plane);
1494 void (*disable_flip_done)(struct intel_plane *plane);
1495 };
1496
1497 struct intel_watermark_params {
1498 u16 fifo_size;
1499 u16 max_wm;
1500 u8 default_wm;
1501 u8 guard_size;
1502 u8 cacheline_size;
1503 };
1504
1505 struct cxsr_latency {
1506 bool is_desktop : 1;
1507 bool is_ddr3 : 1;
1508 u16 fsb_freq;
1509 u16 mem_freq;
1510 u16 display_sr;
1511 u16 display_hpll_disable;
1512 u16 cursor_sr;
1513 u16 cursor_hpll_disable;
1514 };
1515
1516 #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base)
1517 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
1518 #define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, uapi)
1519 #define to_intel_connector(x) container_of(x, struct intel_connector, base)
1520 #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
1521 #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
1522 #define to_intel_plane(x) container_of(x, struct intel_plane, base)
1523 #define to_intel_plane_state(x) container_of(x, struct intel_plane_state, uapi)
1524 #define intel_fb_obj(x) ((x) ? to_intel_bo((x)->obj[0]) : NULL)
1525
1526 struct intel_hdmi {
1527 i915_reg_t hdmi_reg;
1528 int ddc_bus;
1529 struct {
1530 enum drm_dp_dual_mode_type type;
1531 int max_tmds_clock;
1532 } dp_dual_mode;
1533 bool has_hdmi_sink;
1534 bool has_audio;
1535 struct intel_connector *attached_connector;
1536 struct cec_notifier *cec_notifier;
1537 };
1538
1539 struct intel_dp_mst_encoder;
1540
1541 struct intel_dp_compliance_data {
1542 unsigned long edid;
1543 u8 video_pattern;
1544 u16 hdisplay, vdisplay;
1545 u8 bpc;
1546 struct drm_dp_phy_test_params phytest;
1547 };
1548
1549 struct intel_dp_compliance {
1550 unsigned long test_type;
1551 struct intel_dp_compliance_data test_data;
1552 bool test_active;
1553 int test_link_rate;
1554 u8 test_lane_count;
1555 };
1556
1557 struct intel_dp_pcon_frl {
1558 bool is_trained;
1559 int trained_rate_gbps;
1560 };
1561
1562 struct intel_pps {
1563 int panel_power_up_delay;
1564 int panel_power_down_delay;
1565 int panel_power_cycle_delay;
1566 int backlight_on_delay;
1567 int backlight_off_delay;
1568 struct delayed_work panel_vdd_work;
1569 bool want_panel_vdd;
1570 bool initializing;
1571 unsigned long last_power_on;
1572 unsigned long last_backlight_off;
1573 ktime_t panel_power_off_time;
1574 intel_wakeref_t vdd_wakeref;
1575
1576 union {
1577 /*
1578 * Pipe whose power sequencer is currently locked into
1579 * this port. Only relevant on VLV/CHV.
1580 */
1581 enum pipe pps_pipe;
1582
1583 /*
1584 * Power sequencer index. Only relevant on BXT+.
1585 */
1586 int pps_idx;
1587 };
1588
1589 /*
1590 * Pipe currently driving the port. Used for preventing
1591 * the use of the PPS for any pipe currentrly driving
1592 * external DP as that will mess things up on VLV.
1593 */
1594 enum pipe active_pipe;
1595 /*
1596 * Set if the sequencer may be reset due to a power transition,
1597 * requiring a reinitialization. Only relevant on BXT+.
1598 */
1599 bool pps_reset;
1600 struct edp_power_seq pps_delays;
1601 struct edp_power_seq bios_pps_delays;
1602 };
1603
1604 struct intel_psr {
1605 /* Mutex for PSR state of the transcoder */
1606 struct mutex lock;
1607
1608 #define I915_PSR_DEBUG_MODE_MASK 0x0f
1609 #define I915_PSR_DEBUG_DEFAULT 0x00
1610 #define I915_PSR_DEBUG_DISABLE 0x01
1611 #define I915_PSR_DEBUG_ENABLE 0x02
1612 #define I915_PSR_DEBUG_FORCE_PSR1 0x03
1613 #define I915_PSR_DEBUG_ENABLE_SEL_FETCH 0x4
1614 #define I915_PSR_DEBUG_IRQ 0x10
1615
1616 u32 debug;
1617 bool sink_support;
1618 bool source_support;
1619 bool enabled;
1620 bool paused;
1621 enum pipe pipe;
1622 enum transcoder transcoder;
1623 bool active;
1624 struct work_struct work;
1625 unsigned int busy_frontbuffer_bits;
1626 bool sink_psr2_support;
1627 bool link_standby;
1628 bool colorimetry_support;
1629 bool psr2_enabled;
1630 bool psr2_sel_fetch_enabled;
1631 bool psr2_sel_fetch_cff_enabled;
1632 bool req_psr2_sdp_prior_scanline;
1633 u8 sink_sync_latency;
1634 ktime_t last_entry_attempt;
1635 ktime_t last_exit;
1636 bool sink_not_reliable;
1637 bool irq_aux_error;
1638 u16 su_w_granularity;
1639 u16 su_y_granularity;
1640 u32 dc3co_exitline;
1641 u32 dc3co_exit_delay;
1642 struct delayed_work dc3co_work;
1643 };
1644
1645 struct intel_dp {
1646 i915_reg_t output_reg;
1647 u32 DP;
1648 int link_rate;
1649 u8 lane_count;
1650 u8 sink_count;
1651 bool link_trained;
1652 bool has_hdmi_sink;
1653 bool has_audio;
1654 bool reset_link_params;
1655 bool use_max_params;
1656 u8 dpcd[DP_RECEIVER_CAP_SIZE];
1657 u8 psr_dpcd[EDP_PSR_RECEIVER_CAP_SIZE];
1658 u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS];
1659 u8 edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE];
1660 u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE];
1661 u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE];
1662 u8 lttpr_phy_caps[DP_MAX_LTTPR_COUNT][DP_LTTPR_PHY_CAP_SIZE];
1663 u8 fec_capable;
1664 u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE];
1665 /* source rates */
1666 int num_source_rates;
1667 const int *source_rates;
1668 /* sink rates as reported by DP_MAX_LINK_RATE/DP_SUPPORTED_LINK_RATES */
1669 int num_sink_rates;
1670 int sink_rates[DP_MAX_SUPPORTED_RATES];
1671 bool use_rate_select;
1672 /* Max sink lane count as reported by DP_MAX_LANE_COUNT */
1673 int max_sink_lane_count;
1674 /* intersection of source and sink rates */
1675 int num_common_rates;
1676 int common_rates[DP_MAX_SUPPORTED_RATES];
1677 /* Max lane count for the current link */
1678 int max_link_lane_count;
1679 /* Max rate for the current link */
1680 int max_link_rate;
1681 int mso_link_count;
1682 int mso_pixel_overlap;
1683 /* sink or branch descriptor */
1684 struct drm_dp_desc desc;
1685 struct drm_dp_aux aux;
1686 u32 aux_busy_last_status;
1687 u8 train_set[4];
1688
1689 struct intel_pps pps;
1690
1691 bool is_mst;
1692 int active_mst_links;
1693
1694 /* connector directly attached - won't be use for modeset in mst world */
1695 struct intel_connector *attached_connector;
1696
1697 /* mst connector list */
1698 struct intel_dp_mst_encoder *mst_encoders[I915_MAX_PIPES];
1699 struct drm_dp_mst_topology_mgr mst_mgr;
1700
1701 u32 (*get_aux_clock_divider)(struct intel_dp *dp, int index);
1702 /*
1703 * This function returns the value we have to program the AUX_CTL
1704 * register with to kick off an AUX transaction.
1705 */
1706 u32 (*get_aux_send_ctl)(struct intel_dp *dp, int send_bytes,
1707 u32 aux_clock_divider);
1708
1709 i915_reg_t (*aux_ch_ctl_reg)(struct intel_dp *dp);
1710 i915_reg_t (*aux_ch_data_reg)(struct intel_dp *dp, int index);
1711
1712 /* This is called before a link training is starterd */
1713 void (*prepare_link_retrain)(struct intel_dp *intel_dp,
1714 const struct intel_crtc_state *crtc_state);
1715 void (*set_link_train)(struct intel_dp *intel_dp,
1716 const struct intel_crtc_state *crtc_state,
1717 u8 dp_train_pat);
1718 void (*set_idle_link_train)(struct intel_dp *intel_dp,
1719 const struct intel_crtc_state *crtc_state);
1720
1721 u8 (*preemph_max)(struct intel_dp *intel_dp);
1722 u8 (*voltage_max)(struct intel_dp *intel_dp,
1723 const struct intel_crtc_state *crtc_state);
1724
1725 /* Displayport compliance testing */
1726 struct intel_dp_compliance compliance;
1727
1728 /* Downstream facing port caps */
1729 struct {
1730 int min_tmds_clock, max_tmds_clock;
1731 int max_dotclock;
1732 int pcon_max_frl_bw;
1733 u8 max_bpc;
1734 bool ycbcr_444_to_420;
1735 bool rgb_to_ycbcr;
1736 } dfp;
1737
1738 /* To control wakeup latency, e.g. for irq-driven dp aux transfers. */
1739 struct pm_qos_request pm_qos;
1740
1741 /* Display stream compression testing */
1742 bool force_dsc_en;
1743 int force_dsc_bpc;
1744
1745 bool hobl_failed;
1746 bool hobl_active;
1747
1748 struct intel_dp_pcon_frl frl;
1749
1750 struct intel_psr psr;
1751
1752 /* When we last wrote the OUI for eDP */
1753 unsigned long last_oui_write;
1754 };
1755
1756 enum lspcon_vendor {
1757 LSPCON_VENDOR_MCA,
1758 LSPCON_VENDOR_PARADE
1759 };
1760
1761 struct intel_lspcon {
1762 bool active;
1763 bool hdr_supported;
1764 enum drm_lspcon_mode mode;
1765 enum lspcon_vendor vendor;
1766 };
1767
1768 struct intel_digital_port {
1769 struct intel_encoder base;
1770 u32 saved_port_bits;
1771 struct intel_dp dp;
1772 struct intel_hdmi hdmi;
1773 struct intel_lspcon lspcon;
1774 enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool);
1775 bool release_cl2_override;
1776 u8 max_lanes;
1777 /* Used for DP and ICL+ TypeC/DP and TypeC/HDMI ports. */
1778 enum aux_ch aux_ch;
1779 enum intel_display_power_domain ddi_io_power_domain;
1780 intel_wakeref_t ddi_io_wakeref;
1781 intel_wakeref_t aux_wakeref;
1782
1783 struct mutex tc_lock; /* protects the TypeC port mode */
1784 intel_wakeref_t tc_lock_wakeref;
1785 enum intel_display_power_domain tc_lock_power_domain;
1786 struct delayed_work tc_disconnect_phy_work;
1787 int tc_link_refcount;
1788 bool tc_legacy_port:1;
1789 char tc_port_name[8];
1790 enum tc_port_mode tc_mode;
1791 enum phy_fia tc_phy_fia;
1792 u8 tc_phy_fia_idx;
1793
1794 /* protects num_hdcp_streams reference count, hdcp_port_data and hdcp_auth_status */
1795 struct mutex hdcp_mutex;
1796 /* the number of pipes using HDCP signalling out of this port */
1797 unsigned int num_hdcp_streams;
1798 /* port HDCP auth status */
1799 bool hdcp_auth_status;
1800 /* HDCP port data need to pass to security f/w */
1801 struct hdcp_port_data hdcp_port_data;
1802 /* Whether the MST topology supports HDCP Type 1 Content */
1803 bool hdcp_mst_type1_capable;
1804
1805 void (*write_infoframe)(struct intel_encoder *encoder,
1806 const struct intel_crtc_state *crtc_state,
1807 unsigned int type,
1808 const void *frame, ssize_t len);
1809 void (*read_infoframe)(struct intel_encoder *encoder,
1810 const struct intel_crtc_state *crtc_state,
1811 unsigned int type,
1812 void *frame, ssize_t len);
1813 void (*set_infoframes)(struct intel_encoder *encoder,
1814 bool enable,
1815 const struct intel_crtc_state *crtc_state,
1816 const struct drm_connector_state *conn_state);
1817 u32 (*infoframes_enabled)(struct intel_encoder *encoder,
1818 const struct intel_crtc_state *pipe_config);
1819 bool (*connected)(struct intel_encoder *encoder);
1820 };
1821
1822 struct intel_dp_mst_encoder {
1823 struct intel_encoder base;
1824 enum pipe pipe;
1825 struct intel_digital_port *primary;
1826 struct intel_connector *connector;
1827 };
1828
1829 struct intel_load_detect_pipe {
1830 struct drm_atomic_state *restore_state;
1831 };
1832
1833 static inline struct intel_encoder *
intel_attached_encoder(struct intel_connector * connector)1834 intel_attached_encoder(struct intel_connector *connector)
1835 {
1836 return connector->encoder;
1837 }
1838
intel_encoder_is_dig_port(struct intel_encoder * encoder)1839 static inline bool intel_encoder_is_dig_port(struct intel_encoder *encoder)
1840 {
1841 switch (encoder->type) {
1842 case INTEL_OUTPUT_DDI:
1843 case INTEL_OUTPUT_DP:
1844 case INTEL_OUTPUT_EDP:
1845 case INTEL_OUTPUT_HDMI:
1846 return true;
1847 default:
1848 return false;
1849 }
1850 }
1851
intel_encoder_is_mst(struct intel_encoder * encoder)1852 static inline bool intel_encoder_is_mst(struct intel_encoder *encoder)
1853 {
1854 return encoder->type == INTEL_OUTPUT_DP_MST;
1855 }
1856
1857 static inline struct intel_dp_mst_encoder *
enc_to_mst(struct intel_encoder * encoder)1858 enc_to_mst(struct intel_encoder *encoder)
1859 {
1860 return container_of(&encoder->base, struct intel_dp_mst_encoder,
1861 base.base);
1862 }
1863
1864 static inline struct intel_digital_port *
enc_to_dig_port(struct intel_encoder * encoder)1865 enc_to_dig_port(struct intel_encoder *encoder)
1866 {
1867 struct intel_encoder *intel_encoder = encoder;
1868
1869 if (intel_encoder_is_dig_port(intel_encoder))
1870 return container_of(&encoder->base, struct intel_digital_port,
1871 base.base);
1872 else if (intel_encoder_is_mst(intel_encoder))
1873 return enc_to_mst(encoder)->primary;
1874 else
1875 return NULL;
1876 }
1877
1878 static inline struct intel_digital_port *
intel_attached_dig_port(struct intel_connector * connector)1879 intel_attached_dig_port(struct intel_connector *connector)
1880 {
1881 return enc_to_dig_port(intel_attached_encoder(connector));
1882 }
1883
1884 static inline struct intel_hdmi *
enc_to_intel_hdmi(struct intel_encoder * encoder)1885 enc_to_intel_hdmi(struct intel_encoder *encoder)
1886 {
1887 return &enc_to_dig_port(encoder)->hdmi;
1888 }
1889
1890 static inline struct intel_hdmi *
intel_attached_hdmi(struct intel_connector * connector)1891 intel_attached_hdmi(struct intel_connector *connector)
1892 {
1893 return enc_to_intel_hdmi(intel_attached_encoder(connector));
1894 }
1895
enc_to_intel_dp(struct intel_encoder * encoder)1896 static inline struct intel_dp *enc_to_intel_dp(struct intel_encoder *encoder)
1897 {
1898 return &enc_to_dig_port(encoder)->dp;
1899 }
1900
intel_attached_dp(struct intel_connector * connector)1901 static inline struct intel_dp *intel_attached_dp(struct intel_connector *connector)
1902 {
1903 return enc_to_intel_dp(intel_attached_encoder(connector));
1904 }
1905
intel_encoder_is_dp(struct intel_encoder * encoder)1906 static inline bool intel_encoder_is_dp(struct intel_encoder *encoder)
1907 {
1908 switch (encoder->type) {
1909 case INTEL_OUTPUT_DP:
1910 case INTEL_OUTPUT_EDP:
1911 return true;
1912 case INTEL_OUTPUT_DDI:
1913 /* Skip pure HDMI/DVI DDI encoders */
1914 return i915_mmio_reg_valid(enc_to_intel_dp(encoder)->output_reg);
1915 default:
1916 return false;
1917 }
1918 }
1919
1920 static inline struct intel_lspcon *
enc_to_intel_lspcon(struct intel_encoder * encoder)1921 enc_to_intel_lspcon(struct intel_encoder *encoder)
1922 {
1923 return &enc_to_dig_port(encoder)->lspcon;
1924 }
1925
1926 static inline struct intel_digital_port *
dp_to_dig_port(struct intel_dp * intel_dp)1927 dp_to_dig_port(struct intel_dp *intel_dp)
1928 {
1929 return container_of(intel_dp, struct intel_digital_port, dp);
1930 }
1931
1932 static inline struct intel_lspcon *
dp_to_lspcon(struct intel_dp * intel_dp)1933 dp_to_lspcon(struct intel_dp *intel_dp)
1934 {
1935 return &dp_to_dig_port(intel_dp)->lspcon;
1936 }
1937
1938 #define dp_to_i915(__intel_dp) to_i915(dp_to_dig_port(__intel_dp)->base.base.dev)
1939
1940 #define CAN_PSR(intel_dp) ((intel_dp)->psr.sink_support && \
1941 (intel_dp)->psr.source_support)
1942
intel_encoder_can_psr(struct intel_encoder * encoder)1943 static inline bool intel_encoder_can_psr(struct intel_encoder *encoder)
1944 {
1945 if (!intel_encoder_is_dp(encoder))
1946 return false;
1947
1948 return CAN_PSR(enc_to_intel_dp(encoder));
1949 }
1950
1951 static inline struct intel_digital_port *
hdmi_to_dig_port(struct intel_hdmi * intel_hdmi)1952 hdmi_to_dig_port(struct intel_hdmi *intel_hdmi)
1953 {
1954 return container_of(intel_hdmi, struct intel_digital_port, hdmi);
1955 }
1956
1957 static inline struct intel_plane_state *
intel_atomic_get_plane_state(struct intel_atomic_state * state,struct intel_plane * plane)1958 intel_atomic_get_plane_state(struct intel_atomic_state *state,
1959 struct intel_plane *plane)
1960 {
1961 struct drm_plane_state *ret =
1962 drm_atomic_get_plane_state(&state->base, &plane->base);
1963
1964 if (IS_ERR(ret))
1965 return ERR_CAST(ret);
1966
1967 return to_intel_plane_state(ret);
1968 }
1969
1970 static inline struct intel_plane_state *
intel_atomic_get_old_plane_state(struct intel_atomic_state * state,struct intel_plane * plane)1971 intel_atomic_get_old_plane_state(struct intel_atomic_state *state,
1972 struct intel_plane *plane)
1973 {
1974 return to_intel_plane_state(drm_atomic_get_old_plane_state(&state->base,
1975 &plane->base));
1976 }
1977
1978 static inline struct intel_plane_state *
intel_atomic_get_new_plane_state(struct intel_atomic_state * state,struct intel_plane * plane)1979 intel_atomic_get_new_plane_state(struct intel_atomic_state *state,
1980 struct intel_plane *plane)
1981 {
1982 return to_intel_plane_state(drm_atomic_get_new_plane_state(&state->base,
1983 &plane->base));
1984 }
1985
1986 static inline struct intel_crtc_state *
intel_atomic_get_old_crtc_state(struct intel_atomic_state * state,struct intel_crtc * crtc)1987 intel_atomic_get_old_crtc_state(struct intel_atomic_state *state,
1988 struct intel_crtc *crtc)
1989 {
1990 return to_intel_crtc_state(drm_atomic_get_old_crtc_state(&state->base,
1991 &crtc->base));
1992 }
1993
1994 static inline struct intel_crtc_state *
intel_atomic_get_new_crtc_state(struct intel_atomic_state * state,struct intel_crtc * crtc)1995 intel_atomic_get_new_crtc_state(struct intel_atomic_state *state,
1996 struct intel_crtc *crtc)
1997 {
1998 return to_intel_crtc_state(drm_atomic_get_new_crtc_state(&state->base,
1999 &crtc->base));
2000 }
2001
2002 static inline struct intel_digital_connector_state *
intel_atomic_get_new_connector_state(struct intel_atomic_state * state,struct intel_connector * connector)2003 intel_atomic_get_new_connector_state(struct intel_atomic_state *state,
2004 struct intel_connector *connector)
2005 {
2006 return to_intel_digital_connector_state(
2007 drm_atomic_get_new_connector_state(&state->base,
2008 &connector->base));
2009 }
2010
2011 static inline struct intel_digital_connector_state *
intel_atomic_get_old_connector_state(struct intel_atomic_state * state,struct intel_connector * connector)2012 intel_atomic_get_old_connector_state(struct intel_atomic_state *state,
2013 struct intel_connector *connector)
2014 {
2015 return to_intel_digital_connector_state(
2016 drm_atomic_get_old_connector_state(&state->base,
2017 &connector->base));
2018 }
2019
2020 /* intel_display.c */
2021 static inline bool
intel_crtc_has_type(const struct intel_crtc_state * crtc_state,enum intel_output_type type)2022 intel_crtc_has_type(const struct intel_crtc_state *crtc_state,
2023 enum intel_output_type type)
2024 {
2025 return crtc_state->output_types & BIT(type);
2026 }
2027
2028 static inline bool
intel_crtc_has_dp_encoder(const struct intel_crtc_state * crtc_state)2029 intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state)
2030 {
2031 return crtc_state->output_types &
2032 (BIT(INTEL_OUTPUT_DP) |
2033 BIT(INTEL_OUTPUT_DP_MST) |
2034 BIT(INTEL_OUTPUT_EDP));
2035 }
2036
2037 static inline bool
intel_crtc_needs_modeset(const struct intel_crtc_state * crtc_state)2038 intel_crtc_needs_modeset(const struct intel_crtc_state *crtc_state)
2039 {
2040 return drm_atomic_crtc_needs_modeset(&crtc_state->uapi);
2041 }
2042
2043 static inline bool
intel_crtc_needs_fastset(const struct intel_crtc_state * crtc_state)2044 intel_crtc_needs_fastset(const struct intel_crtc_state *crtc_state)
2045 {
2046 return crtc_state->update_pipe;
2047 }
2048
2049 static inline bool
intel_crtc_needs_color_update(const struct intel_crtc_state * crtc_state)2050 intel_crtc_needs_color_update(const struct intel_crtc_state *crtc_state)
2051 {
2052 return crtc_state->uapi.color_mgmt_changed ||
2053 intel_crtc_needs_fastset(crtc_state) ||
2054 intel_crtc_needs_modeset(crtc_state);
2055 }
2056
intel_plane_ggtt_offset(const struct intel_plane_state * plane_state)2057 static inline u32 intel_plane_ggtt_offset(const struct intel_plane_state *plane_state)
2058 {
2059 return i915_ggtt_offset(plane_state->ggtt_vma);
2060 }
2061
2062 static inline struct intel_frontbuffer *
to_intel_frontbuffer(struct drm_framebuffer * fb)2063 to_intel_frontbuffer(struct drm_framebuffer *fb)
2064 {
2065 return fb ? to_intel_framebuffer(fb)->frontbuffer : NULL;
2066 }
2067
2068 #endif /* __INTEL_DISPLAY_TYPES_H__ */
2069