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/pm_qos.h> 30 #include <linux/pwm.h> 31 32 #include <drm/display/drm_dp_dual_mode_helper.h> 33 #include <drm/display/drm_dp_mst_helper.h> 34 #include <drm/display/drm_dp_tunnel.h> 35 #include <drm/display/drm_dsc.h> 36 #include <drm/drm_atomic.h> 37 #include <drm/drm_colorop.h> 38 #include <drm/drm_crtc.h> 39 #include <drm/drm_encoder.h> 40 #include <drm/drm_framebuffer.h> 41 #include <drm/drm_panel.h> 42 #include <drm/drm_rect.h> 43 #include <drm/drm_vblank_work.h> 44 #include <drm/intel/i915_hdcp_interface.h> 45 #include <uapi/drm/i915_drm.h> 46 47 #include "i915_gtt_view_types.h" 48 #include "intel_bios.h" 49 #include "intel_display.h" 50 #include "intel_display_conversion.h" 51 #include "intel_display_limits.h" 52 #include "intel_display_power.h" 53 #include "intel_dpll_mgr.h" 54 #include "intel_dsi_vbt_defs.h" 55 #include "intel_wm_types.h" 56 57 struct cec_notifier; 58 struct drm_printer; 59 struct intel_connector; 60 struct intel_ddi_buf_trans; 61 struct intel_fbc; 62 struct intel_global_objs_state; 63 struct intel_hdcp_shim; 64 struct intel_panic; 65 struct intel_tc_port; 66 67 /* 68 * Display related stuff 69 */ 70 71 /* these are outputs from the chip - integrated only 72 external chips are via DVO or SDVO output */ 73 enum intel_output_type { 74 INTEL_OUTPUT_UNUSED = 0, 75 INTEL_OUTPUT_ANALOG = 1, 76 INTEL_OUTPUT_DVO = 2, 77 INTEL_OUTPUT_SDVO = 3, 78 INTEL_OUTPUT_LVDS = 4, 79 INTEL_OUTPUT_TVOUT = 5, 80 INTEL_OUTPUT_HDMI = 6, 81 INTEL_OUTPUT_DP = 7, 82 INTEL_OUTPUT_EDP = 8, 83 INTEL_OUTPUT_DSI = 9, 84 INTEL_OUTPUT_DDI = 10, 85 INTEL_OUTPUT_DP_MST = 11, 86 }; 87 88 enum hdmi_force_audio { 89 HDMI_AUDIO_OFF_DVI = -2, /* no aux data for HDMI-DVI converter */ 90 HDMI_AUDIO_OFF, /* force turn off HDMI audio */ 91 HDMI_AUDIO_AUTO, /* trust EDID */ 92 HDMI_AUDIO_ON, /* force turn on HDMI audio */ 93 }; 94 95 /* "Broadcast RGB" property */ 96 enum intel_broadcast_rgb { 97 INTEL_BROADCAST_RGB_AUTO, 98 INTEL_BROADCAST_RGB_FULL, 99 INTEL_BROADCAST_RGB_LIMITED, 100 }; 101 102 struct intel_fb_view { 103 /* 104 * The remap information used in the remapped and rotated views to 105 * create the DMA scatter-gather list for each FB color plane. This sg 106 * list is created along with the view type (gtt.type) specific 107 * i915_vma object and contains the list of FB object pages (reordered 108 * in the rotated view) that are visible in the view. 109 * In the normal view the FB object's backing store sg list is used 110 * directly and hence the remap information here is not used. 111 */ 112 struct i915_gtt_view gtt; 113 114 /* 115 * The GTT view (gtt.type) specific information for each FB color 116 * plane. In the normal GTT view all formats (up to 4 color planes), 117 * in the rotated and remapped GTT view all no-CCS formats (up to 2 118 * color planes) are supported. 119 * 120 * The view information shared by all FB color planes in the FB, 121 * like dst x/y and src/dst width, is stored separately in 122 * intel_plane_state. 123 */ 124 struct i915_color_plane_view { 125 u32 offset; 126 unsigned int x, y; 127 /* 128 * Plane stride in: 129 * bytes for 0/180 degree rotation 130 * pixels for 90/270 degree rotation 131 */ 132 unsigned int mapping_stride; 133 unsigned int scanout_stride; 134 } color_plane[4]; 135 }; 136 137 struct intel_framebuffer { 138 struct drm_framebuffer base; 139 struct intel_frontbuffer *frontbuffer; 140 141 /* Params to remap the FB pages and program the plane registers in each view. */ 142 struct intel_fb_view normal_view; 143 union { 144 struct intel_fb_view rotated_view; 145 struct intel_fb_view remapped_view; 146 }; 147 148 struct intel_dpt *dpt; 149 150 unsigned int min_alignment; 151 unsigned int vtd_guard; 152 153 unsigned int (*panic_tiling)(unsigned int x, unsigned int y, unsigned int width); 154 struct intel_panic *panic; 155 }; 156 157 enum intel_hotplug_state { 158 INTEL_HOTPLUG_UNCHANGED, 159 INTEL_HOTPLUG_CHANGED, 160 INTEL_HOTPLUG_RETRY, 161 }; 162 163 struct intel_encoder { 164 struct drm_encoder base; 165 166 enum intel_output_type type; 167 enum port port; 168 u16 cloneable; 169 u8 pipe_mask; 170 171 /* Check and recover a bad link state. */ 172 struct delayed_work link_check_work; 173 void (*link_check)(struct intel_encoder *encoder); 174 175 enum intel_hotplug_state (*hotplug)(struct intel_encoder *encoder, 176 struct intel_connector *connector); 177 enum intel_output_type (*compute_output_type)(struct intel_encoder *, 178 struct intel_crtc_state *, 179 struct drm_connector_state *); 180 int (*compute_config)(struct intel_encoder *, 181 struct intel_crtc_state *, 182 struct drm_connector_state *); 183 int (*compute_config_late)(struct intel_encoder *, 184 struct intel_crtc_state *, 185 struct drm_connector_state *); 186 void (*pre_pll_enable)(struct intel_atomic_state *, 187 struct intel_encoder *, 188 const struct intel_crtc_state *, 189 const struct drm_connector_state *); 190 void (*pre_enable)(struct intel_atomic_state *, 191 struct intel_encoder *, 192 const struct intel_crtc_state *, 193 const struct drm_connector_state *); 194 void (*enable)(struct intel_atomic_state *, 195 struct intel_encoder *, 196 const struct intel_crtc_state *, 197 const struct drm_connector_state *); 198 void (*disable)(struct intel_atomic_state *, 199 struct intel_encoder *, 200 const struct intel_crtc_state *, 201 const struct drm_connector_state *); 202 void (*post_disable)(struct intel_atomic_state *, 203 struct intel_encoder *, 204 const struct intel_crtc_state *, 205 const struct drm_connector_state *); 206 void (*post_pll_disable)(struct intel_atomic_state *, 207 struct intel_encoder *, 208 const struct intel_crtc_state *, 209 const struct drm_connector_state *); 210 void (*update_pipe)(struct intel_atomic_state *, 211 struct intel_encoder *, 212 const struct intel_crtc_state *, 213 const struct drm_connector_state *); 214 void (*audio_enable)(struct intel_encoder *encoder, 215 const struct intel_crtc_state *crtc_state, 216 const struct drm_connector_state *conn_state); 217 void (*audio_disable)(struct intel_encoder *encoder, 218 const struct intel_crtc_state *old_crtc_state, 219 const struct drm_connector_state *old_conn_state); 220 /* Read out the current hw state of this connector, returning true if 221 * the encoder is active. If the encoder is enabled it also set the pipe 222 * it is connected to in the pipe parameter. */ 223 bool (*get_hw_state)(struct intel_encoder *, enum pipe *pipe); 224 /* Reconstructs the equivalent mode flags for the current hardware 225 * state. This must be called _after_ display->get_pipe_config has 226 * pre-filled the pipe config. Note that intel_encoder->base.crtc must 227 * be set correctly before calling this function. */ 228 void (*get_config)(struct intel_encoder *, 229 struct intel_crtc_state *pipe_config); 230 231 /* 232 * Optional hook called during init/resume to sync any state 233 * stored in the encoder (eg. DP link parameters) wrt. the HW state. 234 */ 235 void (*sync_state)(struct intel_encoder *encoder, 236 const struct intel_crtc_state *crtc_state); 237 238 /* 239 * Optional hook, returning true if this encoder allows a fastset 240 * during the initial commit, false otherwise. 241 */ 242 bool (*initial_fastset_check)(struct intel_encoder *encoder, 243 struct intel_crtc_state *crtc_state); 244 245 /* 246 * Acquires the power domains needed for an active encoder during 247 * hardware state readout. 248 */ 249 void (*get_power_domains)(struct intel_encoder *encoder, 250 struct intel_crtc_state *crtc_state); 251 /* 252 * Called during system suspend after all pending requests for the 253 * encoder are flushed (for example for DP AUX transactions) and 254 * device interrupts are disabled. 255 * All modeset locks are held while the hook is called. 256 */ 257 void (*suspend)(struct intel_encoder *); 258 /* 259 * Called without the modeset locks held after the suspend() hook for 260 * all encoders have been called. 261 */ 262 void (*suspend_complete)(struct intel_encoder *encoder); 263 /* 264 * Called during system reboot/shutdown after all the 265 * encoders have been disabled and suspended. 266 * All modeset locks are held while the hook is called. 267 */ 268 void (*shutdown)(struct intel_encoder *encoder); 269 /* 270 * Called without the modeset locks held after the shutdown() hook for 271 * all encoders have been called. 272 */ 273 void (*shutdown_complete)(struct intel_encoder *encoder); 274 /* 275 * Enable/disable the clock to the port. 276 */ 277 void (*enable_clock)(struct intel_encoder *encoder, 278 const struct intel_crtc_state *crtc_state); 279 void (*disable_clock)(struct intel_encoder *encoder); 280 /* 281 * Returns whether the port clock is enabled or not. 282 */ 283 bool (*is_clock_enabled)(struct intel_encoder *encoder); 284 /* 285 * Returns the PLL type the port uses. 286 */ 287 enum icl_port_dpll_id (*port_pll_type)(struct intel_encoder *encoder, 288 const struct intel_crtc_state *crtc_state); 289 const struct intel_ddi_buf_trans *(*get_buf_trans)(struct intel_encoder *encoder, 290 const struct intel_crtc_state *crtc_state, 291 int *n_entries); 292 void (*set_signal_levels)(struct intel_encoder *encoder, 293 const struct intel_crtc_state *crtc_state); 294 295 enum hpd_pin hpd_pin; 296 enum intel_display_power_domain power_domain; 297 298 /* VBT information for this encoder (may be NULL for older platforms) */ 299 const struct intel_bios_encoder_data *devdata; 300 }; 301 302 struct intel_panel_bl_funcs { 303 /* Connector and platform specific backlight functions */ 304 int (*setup)(struct intel_connector *connector, enum pipe pipe); 305 u32 (*get)(struct intel_connector *connector, enum pipe pipe); 306 void (*set)(const struct drm_connector_state *conn_state, u32 level); 307 void (*disable)(const struct drm_connector_state *conn_state, u32 level); 308 void (*enable)(const struct intel_crtc_state *crtc_state, 309 const struct drm_connector_state *conn_state, u32 level); 310 u32 (*hz_to_pwm)(struct intel_connector *connector, u32 hz); 311 }; 312 313 /* in 100us units */ 314 struct intel_pps_delays { 315 u16 power_up; /* eDP: T1+T3, LVDS: T1+T2 */ 316 u16 backlight_on; /* eDP: T8, LVDS: T5 */ 317 u16 backlight_off; /* eDP: T9, LVDS: T6/TX */ 318 u16 power_down; /* eDP: T10, LVDS: T3 */ 319 u16 power_cycle; /* eDP: T11+T12, LVDS: T7+T4 */ 320 }; 321 322 enum drrs_type { 323 DRRS_TYPE_NONE, 324 DRRS_TYPE_STATIC, 325 DRRS_TYPE_SEAMLESS, 326 }; 327 328 struct intel_vbt_panel_data { 329 struct drm_display_mode *lfp_vbt_mode; /* if any */ 330 struct drm_display_mode *sdvo_lvds_vbt_mode; /* if any */ 331 332 /* Feature bits */ 333 int panel_type; 334 unsigned int lvds_dither:1; 335 unsigned int bios_lvds_val; /* initial [PCH_]LVDS reg val in VBIOS */ 336 337 bool vrr; 338 339 u8 seamless_drrs_min_refresh_rate; 340 enum drrs_type drrs_type; 341 342 struct { 343 int max_link_rate; 344 int rate; 345 int lanes; 346 int preemphasis; 347 int vswing; 348 int bpp; 349 struct intel_pps_delays pps; 350 u8 drrs_msa_timing_delay; 351 bool low_vswing; 352 bool hobl; 353 bool dsc_disable; 354 bool pipe_joiner_enable; 355 } edp; 356 357 struct { 358 bool enable; 359 bool full_link; 360 bool require_aux_wakeup; 361 int idle_frames; 362 int tp1_wakeup_time_us; 363 int tp2_tp3_wakeup_time_us; 364 int psr2_tp2_tp3_wakeup_time_us; 365 } psr; 366 367 struct { 368 u16 pwm_freq_hz; 369 u16 brightness_precision_bits; 370 u16 hdr_dpcd_refresh_timeout; 371 bool present; 372 bool active_low_pwm; 373 u8 min_brightness; /* min_brightness/255 of max */ 374 s8 controller; /* brightness controller number */ 375 enum intel_backlight_type type; 376 } backlight; 377 378 /* MIPI DSI */ 379 struct { 380 u16 panel_id; 381 struct mipi_config *config; 382 struct mipi_pps_data *pps; 383 u16 bl_ports; 384 u16 cabc_ports; 385 u8 seq_version; 386 u32 size; 387 u8 *data; 388 const u8 *sequence[MIPI_SEQ_MAX]; 389 u8 *deassert_seq; /* Used by fixup_mipi_sequences() */ 390 enum drm_panel_orientation orientation; 391 } dsi; 392 }; 393 394 struct intel_panel { 395 /* Simple drm_panel */ 396 struct drm_panel *base; 397 398 /* Fixed EDID for eDP and LVDS. May hold ERR_PTR for invalid EDID. */ 399 const struct drm_edid *fixed_edid; 400 401 struct list_head fixed_modes; 402 403 /* backlight */ 404 struct { 405 bool present; 406 u32 level; 407 u32 min; 408 u32 max; 409 bool enabled; 410 bool combination_mode; /* gen 2/4 only */ 411 bool active_low_pwm; 412 bool alternate_pwm_increment; /* lpt+ */ 413 414 /* PWM chip */ 415 u32 pwm_level_min; 416 u32 pwm_level_max; 417 bool pwm_enabled; 418 bool util_pin_active_low; /* bxt+ */ 419 u8 controller; /* bxt+ only */ 420 struct pwm_device *pwm; 421 struct pwm_state pwm_state; 422 423 /* DPCD backlight */ 424 union { 425 struct { 426 struct drm_edp_backlight_info info; 427 bool luminance_control_support; 428 } vesa; 429 struct { 430 bool sdr_uses_aux; 431 bool supports_2084_decode; 432 bool supports_2020_gamut; 433 bool supports_segmented_backlight; 434 bool supports_sdp_colorimetry; 435 bool supports_tone_mapping; 436 } intel_cap; 437 } edp; 438 439 struct backlight_device *device; 440 441 const struct intel_panel_bl_funcs *funcs; 442 const struct intel_panel_bl_funcs *pwm_funcs; 443 void (*power)(struct intel_connector *, bool enable); 444 } backlight; 445 446 struct intel_vbt_panel_data vbt; 447 }; 448 449 struct intel_digital_port; 450 451 struct intel_hdcp { 452 const struct intel_hdcp_shim *shim; 453 /* Mutex for hdcp state of the connector */ 454 struct mutex mutex; 455 u64 value; 456 struct delayed_work check_work; 457 struct work_struct prop_work; 458 459 /* HDCP1.4 Encryption status */ 460 bool hdcp_encrypted; 461 462 /* HDCP2.2 related definitions */ 463 /* Flag indicates whether this connector supports HDCP2.2 or not. */ 464 bool hdcp2_supported; 465 466 /* HDCP2.2 Encryption status */ 467 bool hdcp2_encrypted; 468 469 /* 470 * Content Stream Type defined by content owner. TYPE0(0x0) content can 471 * flow in the link protected by HDCP2.2 or HDCP1.4, where as TYPE1(0x1) 472 * content can flow only through a link protected by HDCP2.2. 473 */ 474 u8 content_type; 475 476 bool is_paired; 477 bool is_repeater; 478 479 /* 480 * Count of ReceiverID_List received. Initialized to 0 at AKE_INIT. 481 * Incremented after processing the RepeaterAuth_Send_ReceiverID_List. 482 * When it rolls over re-auth has to be triggered. 483 */ 484 u32 seq_num_v; 485 486 /* 487 * Count of RepeaterAuth_Stream_Manage msg propagated. 488 * Initialized to 0 on AKE_INIT. Incremented after every successful 489 * transmission of RepeaterAuth_Stream_Manage message. When it rolls 490 * over re-Auth has to be triggered. 491 */ 492 u32 seq_num_m; 493 494 /* 495 * Work queue to signal the CP_IRQ. Used for the waiters to read the 496 * available information from HDCP DP sink. 497 */ 498 wait_queue_head_t cp_irq_queue; 499 atomic_t cp_irq_count; 500 int cp_irq_count_cached; 501 502 /* 503 * HDCP register access for gen12+ need the transcoder associated. 504 * Transcoder attached to the connector could be changed at modeset. 505 * Hence caching the transcoder here. 506 */ 507 enum transcoder cpu_transcoder; 508 /* Only used for DP MST stream encryption */ 509 enum transcoder stream_transcoder; 510 /* Used to force HDCP 1.4 bypassing HDCP 2.x */ 511 bool force_hdcp14; 512 }; 513 514 enum intel_panel_replay_dsc_support { 515 INTEL_DP_PANEL_REPLAY_DSC_NOT_SUPPORTED, 516 INTEL_DP_PANEL_REPLAY_DSC_FULL_FRAME_ONLY, 517 INTEL_DP_PANEL_REPLAY_DSC_SELECTIVE_UPDATE, 518 }; 519 520 struct intel_connector { 521 struct drm_connector base; 522 /* 523 * The fixed encoder this connector is connected to. 524 */ 525 struct intel_encoder *encoder; 526 527 /* ACPI device id for ACPI and driver cooperation */ 528 u32 acpi_device_id; 529 530 /* Reads out the current hw, returning true if the connector is enabled 531 * and active (i.e. dpms ON state). */ 532 bool (*get_hw_state)(struct intel_connector *); 533 534 /* 535 * Optional hook called during init/resume to sync any state 536 * stored in the connector (eg. DSC state) wrt. the HW state. 537 */ 538 void (*sync_state)(struct intel_connector *connector, 539 const struct intel_crtc_state *crtc_state); 540 541 /* Panel info for eDP and LVDS */ 542 struct intel_panel panel; 543 544 /* Cached EDID for detect. */ 545 const struct drm_edid *detect_edid; 546 547 /* Number of times hotplug detection was tried after an HPD interrupt */ 548 int hotplug_retries; 549 550 /* since POLL and HPD connectors may use the same HPD line keep the native 551 state of connector->polled in case hotplug storm detection changes it */ 552 u8 polled; 553 554 int force_joined_pipes; 555 556 struct { 557 struct drm_dp_aux *dsc_decompression_aux; 558 u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE]; 559 u8 fec_capability; 560 561 u8 dsc_hblank_expansion_quirk:1; 562 u8 dsc_throughput_quirk:1; 563 u8 dsc_decompression_enabled:1; 564 565 struct { 566 struct { 567 int rgb_yuv444; 568 int yuv422_420; 569 } overall_throughput; 570 int max_line_width; 571 } dsc_branch_caps; 572 573 struct { 574 u8 dpcd[DP_PANEL_REPLAY_CAP_SIZE]; 575 #define INTEL_PR_DPCD_INDEX(pr_dpcd_register) ((pr_dpcd_register) - DP_PANEL_REPLAY_CAP_SUPPORT) 576 577 bool support; 578 bool su_support; 579 enum intel_panel_replay_dsc_support dsc_support; 580 581 u16 su_w_granularity; 582 u16 su_y_granularity; 583 } panel_replay_caps; 584 585 struct { 586 u8 dpcd[EDP_PSR_RECEIVER_CAP_SIZE]; 587 u8 intel_wa_dpcd; 588 589 bool support; 590 bool su_support; 591 592 u16 su_w_granularity; 593 u16 su_y_granularity; 594 595 u8 sync_latency; 596 } psr_caps; 597 } dp; 598 599 struct { 600 struct drm_dp_mst_port *port; 601 struct intel_dp *dp; 602 } mst; 603 604 struct { 605 int force_bpp_x16; 606 } link; 607 608 /* Work struct to schedule a uevent on link train failure */ 609 struct work_struct modeset_retry_work; 610 611 struct intel_hdcp hdcp; 612 }; 613 614 struct intel_digital_connector_state { 615 struct drm_connector_state base; 616 617 enum hdmi_force_audio force_audio; 618 int broadcast_rgb; 619 }; 620 621 #define to_intel_digital_connector_state(conn_state) \ 622 container_of_const((conn_state), struct intel_digital_connector_state, base) 623 624 struct dpll { 625 /* given values */ 626 int n; 627 int m1, m2; 628 int p1, p2; 629 /* derived values */ 630 int dot; 631 int vco; 632 int m; 633 int p; 634 }; 635 636 struct intel_atomic_state { 637 struct drm_atomic_state base; 638 639 struct ref_tracker *wakeref; 640 641 struct intel_global_objs_state *global_objs; 642 int num_global_objs; 643 644 /* Internal commit, as opposed to userspace/client initiated one */ 645 bool internal; 646 647 bool dpll_set, modeset; 648 649 struct intel_dpll_state dpll_state[I915_NUM_PLLS]; 650 651 struct intel_dp_tunnel_inherited_state *inherited_dp_tunnels; 652 653 /* 654 * Current watermarks can't be trusted during hardware readout, so 655 * don't bother calculating intermediate watermarks. 656 */ 657 bool skip_intermediate_wm; 658 659 bool rps_interactive; 660 661 struct work_struct cleanup_work; 662 }; 663 664 struct intel_plane_state { 665 struct drm_plane_state uapi; 666 667 /* 668 * actual hardware state, the state we program to the hardware. 669 * The following members are used to verify the hardware state: 670 * During initial hw readout, they need to be copied from uapi. 671 */ 672 struct { 673 struct drm_crtc *crtc; 674 struct drm_framebuffer *fb; 675 676 u16 alpha; 677 u16 pixel_blend_mode; 678 unsigned int rotation; 679 enum drm_color_encoding color_encoding; 680 enum drm_color_range color_range; 681 enum drm_scaling_filter scaling_filter; 682 struct drm_property_blob *ctm, *degamma_lut, *gamma_lut, *lut_3d; 683 } hw; 684 685 struct i915_vma *ggtt_vma; 686 struct i915_vma *dpt_vma; 687 unsigned long flags; 688 #define PLANE_HAS_FENCE BIT(0) 689 690 struct intel_fb_view view; 691 692 /* for legacy cursor fb unpin */ 693 struct drm_vblank_work unpin_work; 694 695 /* Plane pxp decryption state */ 696 bool decrypt; 697 698 /* Plane state to display black pixels when pxp is borked */ 699 bool force_black; 700 701 /* Acting as Y plane for another UV plane? */ 702 bool is_y_plane; 703 704 /* plane control register */ 705 u32 ctl; 706 707 /* plane color control register */ 708 u32 color_ctl; 709 710 /* chroma upsampler control register */ 711 u32 cus_ctl; 712 713 /* surface address register */ 714 u32 surf; 715 716 /* 717 * scaler_id 718 * = -1 : not using a scaler 719 * >= 0 : using a scalers 720 * 721 * plane requiring a scaler: 722 * - During check_plane, its bit is set in 723 * crtc_state->scaler_state.scaler_users by calling helper function 724 * update_scaler_plane. 725 * - scaler_id indicates the scaler it got assigned. 726 * 727 * plane doesn't require a scaler: 728 * - this can happen when scaling is no more required or plane simply 729 * got disabled. 730 * - During check_plane, corresponding bit is reset in 731 * crtc_state->scaler_state.scaler_users by calling helper function 732 * update_scaler_plane. 733 */ 734 int scaler_id; 735 736 /* 737 * planar_linked_plane: 738 * 739 * ICL planar formats require 2 planes that are updated as pairs. 740 * This member is used to make sure the other plane is also updated 741 * when required, and for update_slave() to find the correct 742 * plane_state to pass as argument. 743 */ 744 struct intel_plane *planar_linked_plane; 745 746 struct drm_intel_sprite_colorkey ckey; 747 748 struct drm_rect psr2_sel_fetch_area; 749 750 /* Clear Color Value */ 751 u64 ccval; 752 753 const char *no_fbc_reason; 754 755 struct drm_rect damage; 756 }; 757 758 struct intel_initial_plane_config { 759 struct intel_framebuffer *fb; 760 struct intel_memory_region *mem; 761 resource_size_t phys_base; 762 struct i915_vma *vma; 763 int size; 764 u32 base; 765 u8 rotation; 766 }; 767 768 struct intel_scaler { 769 u32 mode; 770 bool in_use; 771 int hscale; 772 int vscale; 773 }; 774 775 struct intel_crtc_scaler_state { 776 #define SKL_NUM_SCALERS 2 777 struct intel_scaler scalers[SKL_NUM_SCALERS]; 778 779 /* 780 * scaler_users: keeps track of users requesting scalers on this crtc. 781 * 782 * If a bit is set, a user is using a scaler. 783 * Here user can be a plane or crtc as defined below: 784 * bits 0-30 - plane (bit position is index from drm_plane_index) 785 * bit 31 - crtc 786 * 787 * Instead of creating a new index to cover planes and crtc, using 788 * existing drm_plane_index for planes which is well less than 31 789 * planes and bit 31 for crtc. This should be fine to cover all 790 * our platforms. 791 * 792 * intel_atomic_setup_scalers will setup available scalers to users 793 * requesting scalers. It will gracefully fail if request exceeds 794 * availability. 795 */ 796 #define SKL_CRTC_INDEX 31 797 unsigned scaler_users; 798 799 /* scaler used by crtc for panel fitting purpose */ 800 int scaler_id; 801 }; 802 803 /* {crtc,crtc_state}->mode_flags */ 804 /* Flag to get scanline using frame time stamps */ 805 #define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1) 806 /* Flag to use the scanline counter instead of the pixel counter */ 807 #define I915_MODE_FLAG_USE_SCANLINE_COUNTER (1<<2) 808 /* 809 * TE0 or TE1 flag is set if the crtc has a DSI encoder which 810 * is operating in command mode. 811 * Flag to use TE from DSI0 instead of VBI in command mode 812 */ 813 #define I915_MODE_FLAG_DSI_USE_TE0 (1<<3) 814 /* Flag to use TE from DSI1 instead of VBI in command mode */ 815 #define I915_MODE_FLAG_DSI_USE_TE1 (1<<4) 816 /* Flag to indicate mipi dsi periodic command mode where we do not get TE */ 817 #define I915_MODE_FLAG_DSI_PERIODIC_CMD_MODE (1<<5) 818 /* Do tricks to make vblank timestamps sane with VRR? */ 819 #define I915_MODE_FLAG_VRR (1<<6) 820 821 struct intel_wm_level { 822 bool enable; 823 u32 pri_val; 824 u32 spr_val; 825 u32 cur_val; 826 u32 fbc_val; 827 }; 828 829 struct intel_pipe_wm { 830 struct intel_wm_level wm[5]; 831 bool fbc_wm_enabled; 832 bool pipe_enabled; 833 bool sprites_enabled; 834 bool sprites_scaled; 835 }; 836 837 struct skl_wm_level { 838 u16 min_ddb_alloc; 839 u16 min_ddb_alloc_uv; /* for pre-icl */ 840 u16 blocks; 841 u8 lines; 842 bool enable; 843 bool ignore_lines; 844 bool auto_min_alloc_wm_enable; 845 bool can_sagv; 846 }; 847 848 struct skl_plane_wm { 849 struct skl_wm_level wm[8]; 850 struct skl_wm_level trans_wm; 851 struct { 852 struct skl_wm_level wm0; 853 struct skl_wm_level trans_wm; 854 } sagv; 855 }; 856 857 struct skl_pipe_wm { 858 struct skl_plane_wm planes[I915_MAX_PLANES]; 859 bool use_sagv_wm; 860 }; 861 862 enum vlv_wm_level { 863 VLV_WM_LEVEL_PM2, 864 VLV_WM_LEVEL_PM5, 865 VLV_WM_LEVEL_DDR_DVFS, 866 NUM_VLV_WM_LEVELS, 867 }; 868 869 struct vlv_wm_state { 870 struct g4x_pipe_wm wm[NUM_VLV_WM_LEVELS]; 871 struct g4x_sr_wm sr[NUM_VLV_WM_LEVELS]; 872 u8 num_levels; 873 bool cxsr; 874 }; 875 876 struct vlv_fifo_state { 877 u16 plane[I915_MAX_PLANES]; 878 }; 879 880 enum g4x_wm_level { 881 G4X_WM_LEVEL_NORMAL, 882 G4X_WM_LEVEL_SR, 883 G4X_WM_LEVEL_HPLL, 884 NUM_G4X_WM_LEVELS, 885 }; 886 887 struct g4x_wm_state { 888 struct g4x_pipe_wm wm; 889 struct g4x_sr_wm sr; 890 struct g4x_sr_wm hpll; 891 bool cxsr; 892 bool hpll_en; 893 bool fbc_en; 894 }; 895 896 struct intel_crtc_wm_state { 897 union { 898 /* 899 * raw: 900 * The "raw" watermark values produced by the formula 901 * given the plane's current state. They do not consider 902 * how much FIFO is actually allocated for each plane. 903 * 904 * optimal: 905 * The "optimal" watermark values given the current 906 * state of the planes and the amount of FIFO 907 * allocated to each, ignoring any previous state 908 * of the planes. 909 * 910 * intermediate: 911 * The "intermediate" watermark values when transitioning 912 * between the old and new "optimal" values. Used when 913 * the watermark registers are single buffered and hence 914 * their state changes asynchronously with regards to the 915 * actual plane registers. These are essentially the 916 * worst case combination of the old and new "optimal" 917 * watermarks, which are therefore safe to use when the 918 * plane is in either its old or new state. 919 */ 920 struct { 921 struct intel_pipe_wm intermediate; 922 struct intel_pipe_wm optimal; 923 } ilk; 924 925 struct { 926 struct skl_pipe_wm raw; 927 /* gen9+ only needs 1-step wm programming */ 928 struct skl_pipe_wm optimal; 929 struct skl_ddb_entry ddb; 930 /* 931 * pre-icl: for packed/planar CbCr 932 * icl+: for everything 933 */ 934 struct skl_ddb_entry plane_ddb[I915_MAX_PLANES]; 935 /* pre-icl: for planar Y */ 936 struct skl_ddb_entry plane_ddb_y[I915_MAX_PLANES]; 937 938 /* 939 * xe3: Minimum amount of display blocks and minimum 940 * sagv allocation required for async flip 941 */ 942 u16 plane_min_ddb[I915_MAX_PLANES]; 943 u16 plane_interim_ddb[I915_MAX_PLANES]; 944 } skl; 945 946 struct { 947 struct g4x_pipe_wm raw[NUM_VLV_WM_LEVELS]; /* not inverted */ 948 struct vlv_wm_state intermediate; /* inverted */ 949 struct vlv_wm_state optimal; /* inverted */ 950 struct vlv_fifo_state fifo_state; 951 } vlv; 952 953 struct { 954 struct g4x_pipe_wm raw[NUM_G4X_WM_LEVELS]; 955 struct g4x_wm_state intermediate; 956 struct g4x_wm_state optimal; 957 } g4x; 958 }; 959 960 /* 961 * Platforms with two-step watermark programming will need to 962 * update watermark programming post-vblank to switch from the 963 * safe intermediate watermarks to the optimal final 964 * watermarks. 965 */ 966 bool need_postvbl_update; 967 }; 968 969 enum intel_output_format { 970 INTEL_OUTPUT_FORMAT_RGB, 971 INTEL_OUTPUT_FORMAT_YCBCR420, 972 INTEL_OUTPUT_FORMAT_YCBCR444, 973 }; 974 975 /* Used by dp and fdi links */ 976 struct intel_link_m_n { 977 u32 tu; 978 u32 data_m; 979 u32 data_n; 980 u32 link_m; 981 u32 link_n; 982 }; 983 984 struct intel_csc_matrix { 985 u16 coeff[9]; 986 u16 preoff[3]; 987 u16 postoff[3]; 988 }; 989 990 struct scaler_filter_coeff { 991 u16 sign; 992 u16 exp; 993 u16 mantissa; 994 }; 995 996 struct intel_casf { 997 #define SCALER_FILTER_NUM_TAPS 7 998 struct scaler_filter_coeff coeff[SCALER_FILTER_NUM_TAPS]; 999 u8 strength; 1000 u8 win_size; 1001 bool casf_enable; 1002 }; 1003 1004 struct intel_crtc_state { 1005 /* 1006 * uapi (drm) state. This is the software state shown to userspace. 1007 * In particular, the following members are used for bookkeeping: 1008 * - crtc 1009 * - state 1010 * - *_changed 1011 * - event 1012 * - commit 1013 * - mode_blob 1014 */ 1015 struct drm_crtc_state uapi; 1016 1017 /* 1018 * actual hardware state, the state we program to the hardware. 1019 * The following members are used to verify the hardware state: 1020 * - enable 1021 * - active 1022 * - mode / pipe_mode / adjusted_mode 1023 * - color property blobs. 1024 * 1025 * During initial hw readout, they need to be copied to uapi. 1026 * 1027 * Joiner will allow a transcoder mode that spans 2 pipes; 1028 * Use the pipe_mode for calculations like watermarks, pipe 1029 * scaler, and bandwidth. 1030 * 1031 * Use adjusted_mode for things that need to know the full 1032 * mode on the transcoder, which spans all pipes. 1033 */ 1034 struct { 1035 bool active, enable; 1036 /* logical state of LUTs */ 1037 struct drm_property_blob *degamma_lut, *gamma_lut, *ctm; 1038 struct drm_display_mode mode, pipe_mode, adjusted_mode; 1039 enum drm_scaling_filter scaling_filter; 1040 struct intel_casf casf_params; 1041 } hw; 1042 1043 /* actual state of LUTs */ 1044 struct drm_property_blob *pre_csc_lut, *post_csc_lut; 1045 1046 struct intel_csc_matrix csc, output_csc; 1047 1048 /** 1049 * quirks - bitfield with hw state readout quirks 1050 * 1051 * For various reasons the hw state readout code might not be able to 1052 * completely faithfully read out the current state. These cases are 1053 * tracked with quirk flags so that fastboot and state checker can act 1054 * accordingly. 1055 */ 1056 #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS (1<<0) /* unreliable sync mode.flags */ 1057 unsigned long quirks; 1058 1059 unsigned fb_bits; /* framebuffers to flip */ 1060 bool update_pipe; /* can a fast modeset be performed? */ 1061 bool update_m_n; /* update M/N seamlessly during fastset? */ 1062 bool update_lrr; /* update TRANS_VTOTAL/etc. during fastset? */ 1063 bool disable_cxsr; 1064 bool update_wm_pre, update_wm_post; /* watermarks are updated */ 1065 bool fifo_changed; /* FIFO split is changed */ 1066 bool preload_luts; 1067 bool inherited; /* state inherited from BIOS? */ 1068 1069 /* Ask the hardware to actually async flip? */ 1070 bool do_async_flip; 1071 1072 /* Pipe source size (ie. panel fitter input size) 1073 * All planes will be positioned inside this space, 1074 * and get clipped at the edges. */ 1075 struct drm_rect pipe_src; 1076 1077 /* 1078 * Pipe pixel rate, adjusted for 1079 * panel fitter/pipe scaler downscaling. 1080 */ 1081 unsigned int pixel_rate; 1082 1083 /* Whether to set up the PCH/FDI. Note that we never allow sharing 1084 * between pch encoders and cpu encoders. */ 1085 bool has_pch_encoder; 1086 1087 /* Are we sending infoframes on the attached port */ 1088 bool has_infoframe; 1089 1090 /* CPU Transcoder for the pipe. Currently this can only differ from the 1091 * pipe on Haswell and later (where we have a special eDP transcoder) 1092 * and Broxton (where we have special DSI transcoders). */ 1093 enum transcoder cpu_transcoder; 1094 1095 /* 1096 * Use reduced/limited/broadcast rbg range, compressing from the full 1097 * range fed into the crtcs. 1098 */ 1099 bool limited_color_range; 1100 1101 /* Bitmask of encoder types (enum intel_output_type) 1102 * driven by the pipe. 1103 */ 1104 unsigned int output_types; 1105 1106 /* Whether we should send NULL infoframes. Required for audio. */ 1107 bool has_hdmi_sink; 1108 1109 /* Audio enabled on this pipe. Only valid if either has_hdmi_sink or 1110 * has_dp_encoder is set. */ 1111 bool has_audio; 1112 1113 /* 1114 * Enable dithering, used when the selected pipe bpp doesn't match the 1115 * plane bpp. 1116 */ 1117 bool dither; 1118 1119 /* 1120 * Dither gets enabled for 18bpp which causes CRC mismatch errors for 1121 * compliance video pattern tests. 1122 * Disable dither only if it is a compliance test request for 1123 * 18bpp. 1124 */ 1125 bool dither_force_disable; 1126 1127 /* Controls for the clock computation, to override various stages. */ 1128 bool clock_set; 1129 1130 /* SDVO TV has a bunch of special case. To make multifunction encoders 1131 * work correctly, we need to track this at runtime.*/ 1132 bool sdvo_tv_clock; 1133 1134 /* 1135 * crtc bandwidth limit, don't increase pipe bpp or clock if not really 1136 * required. This is set in the 2nd loop of calling encoder's 1137 * ->compute_config if the first pick doesn't work out. 1138 */ 1139 bool bw_constrained; 1140 1141 /* Settings for the intel dpll used on pretty much everything but 1142 * haswell. */ 1143 struct dpll dpll; 1144 1145 /* Selected dpll or NULL. */ 1146 struct intel_dpll *intel_dpll; 1147 1148 /* Actual register state of the dpll, for shared dpll cross-checking. */ 1149 struct intel_dpll_hw_state dpll_hw_state; 1150 1151 /* 1152 * ICL reserved DPLLs for the CRTC/port. The active PLL is selected by 1153 * setting shared_dpll and dpll_hw_state to one of these reserved ones. 1154 */ 1155 struct icl_port_dpll { 1156 struct intel_dpll *pll; 1157 struct intel_dpll_hw_state hw_state; 1158 } icl_port_dplls[ICL_PORT_DPLL_COUNT]; 1159 1160 /* DSI PLL registers */ 1161 struct { 1162 u32 ctrl, div; 1163 } dsi_pll; 1164 1165 int max_link_bpp_x16; /* in 1/16 bpp units */ 1166 int max_pipe_bpp; /* in 1 bpp units */ 1167 int pipe_bpp; /* in 1 bpp units */ 1168 int min_hblank; 1169 struct intel_link_m_n dp_m_n; 1170 1171 /* m2_n2 for eDP downclock */ 1172 struct intel_link_m_n dp_m2_n2; 1173 bool has_drrs; 1174 1175 /* PSR is supported but might not be enabled due the lack of enabled planes */ 1176 bool has_psr; 1177 bool has_sel_update; 1178 bool enable_psr2_sel_fetch; 1179 bool enable_psr2_su_region_et; 1180 bool req_psr2_sdp_prior_scanline; 1181 bool has_panel_replay; 1182 bool link_off_after_as_sdp_when_pr_active; 1183 bool disable_as_sdp_when_pr_active; 1184 bool wm_level_disabled; 1185 bool pkg_c_latency_used; 1186 /* Only used for state verification. */ 1187 enum intel_panel_replay_dsc_support panel_replay_dsc_support; 1188 u32 dc3co_exitline; 1189 u16 su_y_granularity; 1190 u8 active_non_psr_pipes; 1191 u8 entry_setup_frames; 1192 const char *no_psr_reason; 1193 1194 /* 1195 * Frequency the dpll for the port should run at. Differs from the 1196 * adjusted dotclock e.g. for DP or 10/12bpc hdmi mode. This is also 1197 * already multiplied by pixel_multiplier. 1198 */ 1199 int port_clock; 1200 1201 /* Used by SDVO (and if we ever fix it, HDMI). */ 1202 unsigned pixel_multiplier; 1203 1204 /* I915_MODE_FLAG_* */ 1205 u8 mode_flags; 1206 1207 u8 lane_count; 1208 1209 /* 1210 * Used by platforms having DP/HDMI PHY with programmable lane 1211 * latency optimization. 1212 */ 1213 u8 lane_lat_optim_mask; 1214 1215 /* minimum acceptable voltage level */ 1216 u8 min_voltage_level; 1217 1218 /* Panel fitter controls for gen2-gen4 + VLV */ 1219 struct { 1220 u32 control; 1221 u32 pgm_ratios; 1222 u32 lvds_border_bits; 1223 } gmch_pfit; 1224 1225 /* Panel fitter placement and size for Ironlake+ */ 1226 struct { 1227 struct drm_rect dst; 1228 bool enabled; 1229 bool force_thru; 1230 } pch_pfit; 1231 1232 /* FDI configuration, only valid if has_pch_encoder is set. */ 1233 int fdi_lanes; 1234 struct intel_link_m_n fdi_m_n; 1235 1236 bool ips_enabled; 1237 1238 bool crc_enabled; 1239 1240 bool double_wide; 1241 1242 struct intel_crtc_scaler_state scaler_state; 1243 1244 /* w/a for waiting 2 vblanks during crtc enable */ 1245 enum pipe hsw_workaround_pipe; 1246 1247 struct intel_crtc_wm_state wm; 1248 1249 int min_cdclk; 1250 1251 int plane_min_cdclk[I915_MAX_PLANES]; 1252 1253 /* for packed/planar CbCr */ 1254 u32 data_rate[I915_MAX_PLANES]; 1255 /* for planar Y */ 1256 u32 data_rate_y[I915_MAX_PLANES]; 1257 1258 /* FIXME unify with data_rate[]? */ 1259 u64 rel_data_rate[I915_MAX_PLANES]; 1260 u64 rel_data_rate_y[I915_MAX_PLANES]; 1261 1262 /* Gamma mode programmed on the pipe */ 1263 u32 gamma_mode; 1264 1265 union { 1266 /* CSC mode programmed on the pipe */ 1267 u32 csc_mode; 1268 1269 /* CHV CGM mode */ 1270 u32 cgm_mode; 1271 }; 1272 1273 /* bitmask of logically enabled planes (enum plane_id) */ 1274 u8 enabled_planes; 1275 1276 /* bitmask of actually visible planes (enum plane_id) */ 1277 u8 active_planes; 1278 u8 scaled_planes; 1279 u8 nv12_planes; 1280 u8 c8_planes; 1281 1282 /* bitmask of planes that will be updated during the commit */ 1283 u8 update_planes; 1284 1285 /* bitmask of planes with async flip active */ 1286 u8 async_flip_planes; 1287 1288 u8 framestart_delay; /* 1-4 */ 1289 u8 msa_timing_delay; /* 0-3 */ 1290 1291 struct { 1292 u32 enable; 1293 u32 gcp; 1294 union hdmi_infoframe avi; 1295 union hdmi_infoframe spd; 1296 union hdmi_infoframe hdmi; 1297 union hdmi_infoframe drm; 1298 struct drm_dp_vsc_sdp vsc; 1299 struct drm_dp_as_sdp as_sdp; 1300 } infoframes; 1301 1302 u8 eld[MAX_ELD_BYTES]; 1303 1304 /* HDMI scrambling status */ 1305 bool hdmi_scrambling; 1306 1307 /* HDMI High TMDS char rate ratio */ 1308 bool hdmi_high_tmds_clock_ratio; 1309 1310 /* 1311 * Output format RGB/YCBCR etc., that is coming out 1312 * at the end of the pipe. 1313 */ 1314 enum intel_output_format output_format; 1315 1316 /* 1317 * Sink output format RGB/YCBCR etc., that is going 1318 * into the sink. 1319 */ 1320 enum intel_output_format sink_format; 1321 1322 /* enable pipe gamma? */ 1323 bool gamma_enable; 1324 1325 /* enable pipe csc? */ 1326 bool csc_enable; 1327 1328 /* enable vlv/chv wgc csc? */ 1329 bool wgc_enable; 1330 1331 /* joiner pipe bitmask */ 1332 u8 joiner_pipes; 1333 1334 /* Display Stream compression state */ 1335 struct { 1336 /* Only used for state computation, not read out from the HW. */ 1337 bool compression_enabled_on_link; 1338 bool compression_enable; 1339 struct intel_dsc_slice_config { 1340 int pipes_per_line; 1341 int streams_per_pipe; 1342 int slices_per_stream; 1343 } slice_config; 1344 /* Compressed Bpp in U6.4 format (first 4 bits for fractional part) */ 1345 u16 compressed_bpp_x16; 1346 struct drm_dsc_config config; 1347 } dsc; 1348 1349 /* DP tunnel used for BW allocation. */ 1350 struct drm_dp_tunnel_ref dp_tunnel_ref; 1351 1352 /* HSW+ linetime watermarks */ 1353 u16 linetime; 1354 u16 ips_linetime; 1355 1356 bool enhanced_framing; 1357 1358 /* 1359 * Forward Error Correction. 1360 * 1361 * Note: This will be false for 128b/132b, which will always have FEC 1362 * enabled automatically. 1363 */ 1364 bool fec_enable; 1365 1366 bool sdp_split_enable; 1367 1368 /* Pointer to master transcoder in case of tiled displays */ 1369 enum transcoder master_transcoder; 1370 1371 /* Bitmask to indicate slaves attached */ 1372 u8 sync_mode_slaves_mask; 1373 1374 /* Only valid on TGL+ */ 1375 enum transcoder mst_master_transcoder; 1376 1377 /* For DSB based pipe updates */ 1378 struct intel_dsb *dsb_color, *dsb_commit; 1379 bool use_dsb; 1380 bool use_flipq; 1381 1382 u32 psr2_man_track_ctl; 1383 1384 u32 pipe_srcsz_early_tpt; 1385 1386 struct drm_rect psr2_su_area; 1387 1388 /* Variable Refresh Rate state */ 1389 struct { 1390 bool enable, in_range; 1391 u8 pipeline_full; 1392 u16 flipline, vmin, vmax, guardband; 1393 u32 vsync_end, vsync_start; 1394 struct { 1395 bool enable; 1396 u16 vmin, vmax; 1397 u16 guardband, slope; 1398 u16 max_increase, max_decrease; 1399 u16 vblank_target; 1400 } dc_balance; 1401 } vrr; 1402 1403 /* Content Match Refresh Rate state */ 1404 struct { 1405 bool enable; 1406 u64 cmrr_n, cmrr_m; 1407 } cmrr; 1408 1409 /* Stream Splitter for eDP MSO */ 1410 struct { 1411 bool enable; 1412 u8 link_count; 1413 u8 pixel_overlap; 1414 } splitter; 1415 1416 /* for loading single buffered registers during vblank */ 1417 struct drm_vblank_work vblank_work; 1418 1419 /* LOBF flag */ 1420 bool has_lobf; 1421 1422 /* W2 window or 'set context latency' lines */ 1423 u16 set_context_latency; 1424 1425 struct { 1426 u8 io_wake_lines; 1427 u8 fast_wake_lines; 1428 1429 /* LNL and beyond */ 1430 u8 check_entry_lines; 1431 u8 aux_less_wake_lines; 1432 u8 silence_period_sym_clocks; 1433 u8 lfps_half_cycle_num_of_syms; 1434 } alpm_state; 1435 1436 /* to track changes in plane color blocks */ 1437 bool plane_color_changed; 1438 }; 1439 1440 enum intel_pipe_crc_source { 1441 INTEL_PIPE_CRC_SOURCE_NONE, 1442 INTEL_PIPE_CRC_SOURCE_PLANE1, 1443 INTEL_PIPE_CRC_SOURCE_PLANE2, 1444 INTEL_PIPE_CRC_SOURCE_PLANE3, 1445 INTEL_PIPE_CRC_SOURCE_PLANE4, 1446 INTEL_PIPE_CRC_SOURCE_PLANE5, 1447 INTEL_PIPE_CRC_SOURCE_PLANE6, 1448 INTEL_PIPE_CRC_SOURCE_PLANE7, 1449 INTEL_PIPE_CRC_SOURCE_PIPE, 1450 /* TV/DP on pre-gen5/vlv can't use the pipe source. */ 1451 INTEL_PIPE_CRC_SOURCE_TV, 1452 INTEL_PIPE_CRC_SOURCE_DP_B, 1453 INTEL_PIPE_CRC_SOURCE_DP_C, 1454 INTEL_PIPE_CRC_SOURCE_DP_D, 1455 INTEL_PIPE_CRC_SOURCE_AUTO, 1456 INTEL_PIPE_CRC_SOURCE_MAX, 1457 }; 1458 1459 enum drrs_refresh_rate { 1460 DRRS_REFRESH_RATE_HIGH, 1461 DRRS_REFRESH_RATE_LOW, 1462 }; 1463 1464 #define INTEL_PIPE_CRC_ENTRIES_NR 128 1465 struct intel_pipe_crc { 1466 spinlock_t lock; 1467 int skipped; 1468 enum intel_pipe_crc_source source; 1469 }; 1470 1471 enum intel_flipq_id { 1472 INTEL_FLIPQ_PLANE_1, 1473 INTEL_FLIPQ_PLANE_2, 1474 INTEL_FLIPQ_PLANE_3, 1475 INTEL_FLIPQ_GENERAL, 1476 INTEL_FLIPQ_FAST, 1477 MAX_INTEL_FLIPQ, 1478 }; 1479 1480 struct intel_flipq { 1481 u32 start_mmioaddr; 1482 enum intel_flipq_id flipq_id; 1483 u8 tail; 1484 }; 1485 1486 struct intel_crtc { 1487 struct drm_crtc base; 1488 struct list_head pipe_head; 1489 enum pipe pipe; 1490 /* 1491 * Whether the crtc and the connected output pipeline is active. Implies 1492 * that crtc->enabled is set, i.e. the current mode configuration has 1493 * some outputs connected to this crtc. 1494 */ 1495 bool active; 1496 u8 plane_ids_mask; 1497 1498 /* I915_MODE_FLAG_* */ 1499 u8 mode_flags; 1500 1501 u16 vmax_vblank_start; 1502 1503 struct intel_display_power_domain_set enabled_power_domains; 1504 struct intel_display_power_domain_set hw_readout_power_domains; 1505 struct intel_overlay *overlay; 1506 1507 struct intel_crtc_state *config; 1508 1509 /* armed event for async flip */ 1510 struct drm_pending_vblank_event *flip_done_event; 1511 /* armed event for DSB based updates */ 1512 struct drm_pending_vblank_event *dsb_event; 1513 /* armed event for flip queue based updates */ 1514 struct drm_pending_vblank_event *flipq_event; 1515 1516 /* Access to these should be protected by display->irq.lock. */ 1517 bool cpu_fifo_underrun_disabled; 1518 bool pch_fifo_underrun_disabled; 1519 1520 struct intel_flipq flipq[MAX_INTEL_FLIPQ]; 1521 1522 /* per-pipe watermark state */ 1523 struct { 1524 /* watermarks currently being used */ 1525 union { 1526 struct intel_pipe_wm ilk; 1527 struct vlv_wm_state vlv; 1528 struct g4x_wm_state g4x; 1529 } active; 1530 } wm; 1531 1532 struct { 1533 struct mutex mutex; 1534 struct delayed_work work; 1535 enum drrs_refresh_rate refresh_rate; 1536 unsigned int frontbuffer_bits; 1537 unsigned int busy_frontbuffer_bits; 1538 enum transcoder cpu_transcoder; 1539 struct intel_link_m_n m_n, m2_n2; 1540 } drrs; 1541 1542 struct { 1543 u64 flip_count; 1544 } dc_balance; 1545 1546 int scanline_offset; 1547 1548 struct { 1549 unsigned start_vbl_count; 1550 ktime_t start_vbl_time; 1551 int min_vbl, max_vbl; 1552 int scanline_start; 1553 #ifdef CONFIG_DRM_I915_DEBUG_VBLANK_EVADE 1554 struct { 1555 u64 min; 1556 u64 max; 1557 u64 sum; 1558 unsigned int over; 1559 unsigned int times[17]; /* [1us, 16ms] */ 1560 } vbl; 1561 #endif 1562 } debug; 1563 1564 /* scalers available on this crtc */ 1565 int num_scalers; 1566 1567 /* for loading single buffered registers during vblank */ 1568 struct pm_qos_request vblank_pm_qos; 1569 1570 #ifdef CONFIG_DEBUG_FS 1571 struct intel_pipe_crc pipe_crc; 1572 #endif 1573 1574 bool vblank_psr_notify; 1575 }; 1576 1577 struct intel_plane_error { 1578 u32 ctl, surf, surflive; 1579 }; 1580 1581 struct intel_plane { 1582 struct drm_plane base; 1583 enum i9xx_plane_id i9xx_plane; 1584 enum plane_id id; 1585 enum pipe pipe; 1586 bool need_async_flip_toggle_wa; 1587 u8 vtd_guard; 1588 u32 frontbuffer_bit; 1589 1590 struct { 1591 u32 base, cntl, size; 1592 } cursor; 1593 1594 struct intel_fbc *fbc; 1595 1596 /* 1597 * NOTE: Do not place new plane state fields here (e.g., when adding 1598 * new plane properties). New runtime state should now be placed in 1599 * the intel_plane_state structure and accessed via plane_state. 1600 */ 1601 1602 int (*min_width)(const struct drm_framebuffer *fb, 1603 int color_plane, 1604 unsigned int rotation); 1605 int (*max_width)(const struct drm_framebuffer *fb, 1606 int color_plane, 1607 unsigned int rotation); 1608 int (*max_height)(const struct drm_framebuffer *fb, 1609 int color_plane, 1610 unsigned int rotation); 1611 unsigned int (*min_alignment)(struct intel_plane *plane, 1612 const struct drm_framebuffer *fb, 1613 int color_plane); 1614 unsigned int (*max_stride)(struct intel_plane *plane, 1615 const struct drm_format_info *info, 1616 u64 modifier, unsigned int rotation); 1617 bool (*can_async_flip)(u64 modifier); 1618 /* Write all non-self arming plane registers */ 1619 void (*update_noarm)(struct intel_dsb *dsb, 1620 struct intel_plane *plane, 1621 const struct intel_crtc_state *crtc_state, 1622 const struct intel_plane_state *plane_state); 1623 /* Write all self-arming plane registers */ 1624 void (*update_arm)(struct intel_dsb *dsb, 1625 struct intel_plane *plane, 1626 const struct intel_crtc_state *crtc_state, 1627 const struct intel_plane_state *plane_state); 1628 /* Disable the plane, must arm */ 1629 void (*disable_arm)(struct intel_dsb *dsb, 1630 struct intel_plane *plane, 1631 const struct intel_crtc_state *crtc_state); 1632 void (*capture_error)(struct intel_crtc *crtc, 1633 struct intel_plane *plane, 1634 struct intel_plane_error *error); 1635 bool (*get_hw_state)(struct intel_plane *plane, enum pipe *pipe); 1636 int (*check_plane)(struct intel_crtc_state *crtc_state, 1637 struct intel_plane_state *plane_state); 1638 u32 (*surf_offset)(const struct intel_plane_state *plane_state); 1639 int (*min_cdclk)(const struct intel_crtc_state *crtc_state, 1640 const struct intel_plane_state *plane_state); 1641 void (*async_flip)(struct intel_dsb *dsb, 1642 struct intel_plane *plane, 1643 const struct intel_crtc_state *crtc_state, 1644 const struct intel_plane_state *plane_state, 1645 bool async_flip); 1646 void (*enable_flip_done)(struct intel_plane *plane); 1647 void (*disable_flip_done)(struct intel_plane *plane); 1648 /* For drm_panic */ 1649 void (*disable_tiling)(struct intel_plane *plane); 1650 }; 1651 1652 #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base) 1653 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base) 1654 #define to_intel_connector(x) container_of(x, struct intel_connector, base) 1655 #define to_intel_encoder(x) container_of(x, struct intel_encoder, base) 1656 #define to_intel_plane(x) container_of(x, struct intel_plane, base) 1657 1658 #define to_intel_crtc_state(crtc_state) \ 1659 container_of_const((crtc_state), struct intel_crtc_state, uapi) 1660 #define to_intel_plane_state(plane_state) \ 1661 container_of_const((plane_state), struct intel_plane_state, uapi) 1662 #define to_intel_framebuffer(fb) \ 1663 container_of_const((fb), struct intel_framebuffer, base) 1664 1665 struct intel_hdmi { 1666 i915_reg_t hdmi_reg; 1667 struct { 1668 enum drm_dp_dual_mode_type type; 1669 int max_tmds_clock; 1670 } dp_dual_mode; 1671 struct intel_connector *attached_connector; 1672 struct cec_notifier *cec_notifier; 1673 }; 1674 1675 struct intel_dp_mst_encoder; 1676 1677 struct intel_dp_compliance_data { 1678 unsigned long edid; 1679 u8 video_pattern; 1680 u16 hdisplay, vdisplay; 1681 u8 bpc; 1682 struct drm_dp_phy_test_params phytest; 1683 }; 1684 1685 struct intel_dp_compliance { 1686 unsigned long test_type; 1687 struct intel_dp_compliance_data test_data; 1688 bool test_active; 1689 int test_link_rate; 1690 u8 test_lane_count; 1691 }; 1692 1693 struct intel_dp_pcon_frl { 1694 bool is_trained; 1695 int trained_rate_gbps; 1696 }; 1697 1698 struct intel_pps { 1699 int panel_power_up_delay; 1700 int panel_power_down_delay; 1701 int panel_power_cycle_delay; 1702 int backlight_on_delay; 1703 int backlight_off_delay; 1704 struct delayed_work panel_vdd_work; 1705 bool want_panel_vdd; 1706 bool initializing; 1707 unsigned long last_power_on; 1708 unsigned long last_backlight_off; 1709 ktime_t panel_power_off_time; 1710 struct ref_tracker *vdd_wakeref; 1711 1712 union { 1713 /* 1714 * Pipe whose power sequencer is currently locked into 1715 * this port. Only relevant on VLV/CHV. 1716 */ 1717 enum pipe vlv_pps_pipe; 1718 1719 /* 1720 * Power sequencer index. Only relevant on BXT+. 1721 */ 1722 int pps_idx; 1723 }; 1724 1725 /* 1726 * Pipe currently driving the port. Used for preventing 1727 * the use of the PPS for any pipe currentrly driving 1728 * external DP as that will mess things up on VLV. 1729 */ 1730 enum pipe vlv_active_pipe; 1731 /* 1732 * Set if the sequencer may be reset due to a power transition, 1733 * requiring a reinitialization. Only relevant on BXT+. 1734 */ 1735 bool bxt_pps_reset; 1736 struct intel_pps_delays pps_delays; 1737 struct intel_pps_delays bios_pps_delays; 1738 }; 1739 1740 struct intel_psr { 1741 /* Mutex for PSR state of the transcoder */ 1742 struct mutex lock; 1743 1744 #define I915_PSR_DEBUG_MODE_MASK 0x0f 1745 #define I915_PSR_DEBUG_DEFAULT 0x00 1746 #define I915_PSR_DEBUG_DISABLE 0x01 1747 #define I915_PSR_DEBUG_ENABLE 0x02 1748 #define I915_PSR_DEBUG_FORCE_PSR1 0x03 1749 #define I915_PSR_DEBUG_ENABLE_SEL_FETCH 0x4 1750 #define I915_PSR_DEBUG_IRQ 0x10 1751 #define I915_PSR_DEBUG_SU_REGION_ET_DISABLE 0x20 1752 #define I915_PSR_DEBUG_PANEL_REPLAY_DISABLE 0x40 1753 1754 u32 debug; 1755 bool sink_support; 1756 bool source_support; 1757 bool enabled; 1758 int pause_counter; 1759 enum pipe pipe; 1760 enum transcoder transcoder; 1761 bool active; 1762 struct work_struct work; 1763 unsigned int busy_frontbuffer_bits; 1764 bool link_standby; 1765 bool sel_update_enabled; 1766 bool psr2_sel_fetch_enabled; 1767 bool psr2_sel_fetch_cff_enabled; 1768 bool su_region_et_enabled; 1769 bool req_psr2_sdp_prior_scanline; 1770 ktime_t last_entry_attempt; 1771 ktime_t last_exit; 1772 bool sink_not_reliable; 1773 bool irq_aux_error; 1774 u16 su_w_granularity; 1775 u16 su_y_granularity; 1776 bool source_panel_replay_support; 1777 bool sink_panel_replay_support; 1778 bool panel_replay_enabled; 1779 u32 dc3co_exitline; 1780 u32 dc3co_exit_delay; 1781 struct delayed_work dc3co_work; 1782 u8 entry_setup_frames; 1783 1784 u8 io_wake_lines; 1785 u8 fast_wake_lines; 1786 1787 bool link_ok; 1788 bool pkg_c_latency_used; 1789 1790 u8 active_non_psr_pipes; 1791 1792 const char *no_psr_reason; 1793 1794 struct ref_tracker *vblank_wakeref; 1795 }; 1796 1797 struct intel_dp { 1798 i915_reg_t output_reg; 1799 u32 DP; 1800 int link_rate; 1801 u8 lane_count; 1802 u8 sink_count; 1803 bool downstream_port_changed; 1804 bool needs_modeset_retry; 1805 bool use_max_params; 1806 u8 dpcd[DP_RECEIVER_CAP_SIZE]; 1807 1808 u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS]; 1809 u8 edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE]; 1810 u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE]; 1811 u8 lttpr_phy_caps[DP_MAX_LTTPR_COUNT][DP_LTTPR_PHY_CAP_SIZE]; 1812 u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE]; 1813 /* source rates */ 1814 int num_source_rates; 1815 const int *source_rates; 1816 /* sink rates as reported by DP_MAX_LINK_RATE/DP_SUPPORTED_LINK_RATES */ 1817 int num_sink_rates; 1818 int sink_rates[DP_MAX_SUPPORTED_RATES]; 1819 bool use_rate_select; 1820 /* Max sink lane count as reported by DP_MAX_LANE_COUNT */ 1821 int max_sink_lane_count; 1822 /* intersection of source and sink rates */ 1823 int num_common_rates; 1824 int common_rates[DP_MAX_SUPPORTED_RATES]; 1825 struct { 1826 /* TODO: move the rest of link specific fields to here */ 1827 bool active; 1828 /* common rate,lane_count configs in bw order */ 1829 int num_configs; 1830 #define INTEL_DP_MAX_LANE_COUNT 4 1831 #define INTEL_DP_MAX_SUPPORTED_LANE_CONFIGS (ilog2(INTEL_DP_MAX_LANE_COUNT) + 1) 1832 #define INTEL_DP_LANE_COUNT_EXP_BITS order_base_2(INTEL_DP_MAX_SUPPORTED_LANE_CONFIGS) 1833 #define INTEL_DP_LINK_RATE_IDX_BITS (BITS_PER_TYPE(u8) - INTEL_DP_LANE_COUNT_EXP_BITS) 1834 #define INTEL_DP_MAX_LINK_CONFIGS (DP_MAX_SUPPORTED_RATES * \ 1835 INTEL_DP_MAX_SUPPORTED_LANE_CONFIGS) 1836 struct intel_dp_link_config { 1837 u8 link_rate_idx:INTEL_DP_LINK_RATE_IDX_BITS; 1838 u8 lane_count_exp:INTEL_DP_LANE_COUNT_EXP_BITS; 1839 } configs[INTEL_DP_MAX_LINK_CONFIGS]; 1840 /* Max lane count for the current link */ 1841 int max_lane_count; 1842 /* Max rate for the current link */ 1843 int max_rate; 1844 /* 1845 * Link parameters for which the MST topology was probed. 1846 * Tracking these ensures that the MST path resources are 1847 * re-enumerated whenever the link is retrained with new link 1848 * parameters, as required by the DP standard. 1849 */ 1850 int mst_probed_lane_count; 1851 int mst_probed_rate; 1852 int force_lane_count; 1853 int force_rate; 1854 bool retrain_disabled; 1855 /* Sequential link training failures after a passing LT */ 1856 int seq_train_failures; 1857 int force_train_failure; 1858 bool force_retrain; 1859 } link; 1860 bool reset_link_params; 1861 int mso_link_count; 1862 int mso_pixel_overlap; 1863 /* sink or branch descriptor */ 1864 struct drm_dp_desc desc; 1865 struct drm_dp_aux aux; 1866 u32 aux_busy_last_status; 1867 u8 train_set[4]; 1868 1869 struct intel_pps pps; 1870 1871 bool is_mst; 1872 enum drm_dp_mst_mode mst_detect; 1873 1874 /* connector directly attached - won't be use for modeset in mst world */ 1875 struct intel_connector *attached_connector; 1876 bool as_sdp_supported; 1877 1878 struct drm_dp_tunnel *tunnel; 1879 bool tunnel_suspended:1; 1880 1881 struct { 1882 struct intel_dp_mst_encoder *stream_encoders[I915_MAX_PIPES]; 1883 struct drm_dp_mst_topology_mgr mgr; 1884 int active_streams; 1885 } mst; 1886 1887 u32 (*get_aux_clock_divider)(struct intel_dp *dp, int index); 1888 /* 1889 * This function returns the value we have to program the AUX_CTL 1890 * register with to kick off an AUX transaction. 1891 */ 1892 u32 (*get_aux_send_ctl)(struct intel_dp *dp, int send_bytes, 1893 u32 aux_clock_divider); 1894 1895 i915_reg_t (*aux_ch_ctl_reg)(struct intel_dp *dp); 1896 i915_reg_t (*aux_ch_data_reg)(struct intel_dp *dp, int index); 1897 1898 /* This is called before a link training is starterd */ 1899 void (*prepare_link_retrain)(struct intel_dp *intel_dp, 1900 const struct intel_crtc_state *crtc_state); 1901 void (*set_link_train)(struct intel_dp *intel_dp, 1902 const struct intel_crtc_state *crtc_state, 1903 u8 dp_train_pat); 1904 void (*set_idle_link_train)(struct intel_dp *intel_dp, 1905 const struct intel_crtc_state *crtc_state); 1906 1907 u8 (*preemph_max)(struct intel_dp *intel_dp); 1908 u8 (*voltage_max)(struct intel_dp *intel_dp, 1909 const struct intel_crtc_state *crtc_state); 1910 1911 /* Displayport compliance testing */ 1912 struct intel_dp_compliance compliance; 1913 1914 /* Downstream facing port caps */ 1915 struct { 1916 int min_tmds_clock, max_tmds_clock; 1917 int max_dotclock; 1918 int pcon_max_frl_bw; 1919 u8 max_bpc; 1920 bool ycbcr_444_to_420; 1921 bool ycbcr420_passthrough; 1922 bool rgb_to_ycbcr; 1923 } dfp; 1924 1925 /* To control wakeup latency, e.g. for irq-driven dp aux transfers. */ 1926 struct pm_qos_request pm_qos; 1927 1928 /* Display stream compression testing */ 1929 bool force_dsc_en; 1930 int force_dsc_output_format; 1931 bool force_dsc_fractional_bpp_en; 1932 int force_dsc_bpc; 1933 1934 bool hobl_failed; 1935 bool hobl_active; 1936 1937 struct intel_dp_pcon_frl frl; 1938 1939 struct intel_psr psr; 1940 1941 /* When we last wrote the OUI for eDP */ 1942 unsigned long last_oui_write; 1943 bool oui_valid; 1944 1945 bool colorimetry_support; 1946 1947 struct { 1948 enum transcoder transcoder; 1949 struct mutex lock; 1950 1951 bool lobf_disable_debug; 1952 bool sink_alpm_error; 1953 } alpm; 1954 1955 u8 alpm_dpcd; 1956 1957 struct { 1958 unsigned long mask; 1959 } quirks; 1960 }; 1961 1962 enum lspcon_vendor { 1963 LSPCON_VENDOR_MCA, 1964 LSPCON_VENDOR_PARADE 1965 }; 1966 1967 struct intel_lspcon { 1968 bool active; 1969 bool hdr_supported; 1970 enum drm_lspcon_mode mode; 1971 enum lspcon_vendor vendor; 1972 }; 1973 1974 struct intel_digital_port { 1975 struct intel_encoder base; 1976 struct intel_dp dp; 1977 struct intel_hdmi hdmi; 1978 struct intel_lspcon lspcon; 1979 enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool); 1980 1981 bool lane_reversal; 1982 bool ddi_a_4_lanes; 1983 bool release_cl2_override; 1984 bool dedicated_external; 1985 u8 max_lanes; 1986 /* Used for DP and ICL+ TypeC/DP and TypeC/HDMI ports. */ 1987 enum aux_ch aux_ch; 1988 enum intel_display_power_domain ddi_io_power_domain; 1989 struct ref_tracker *ddi_io_wakeref; 1990 struct ref_tracker *aux_wakeref; 1991 1992 struct intel_tc_port *tc; 1993 1994 struct { 1995 /* protects num_streams reference count, port_data and auth_status */ 1996 struct mutex mutex; 1997 /* the number of pipes using HDCP signalling out of this port */ 1998 unsigned int num_streams; 1999 /* port HDCP auth status */ 2000 bool auth_status; 2001 /* HDCP port data need to pass to security f/w */ 2002 struct hdcp_port_data port_data; 2003 /* Whether the MST topology supports HDCP Type 1 Content */ 2004 bool mst_type1_capable; 2005 } hdcp; 2006 2007 void (*write_infoframe)(struct intel_encoder *encoder, 2008 const struct intel_crtc_state *crtc_state, 2009 unsigned int type, 2010 const void *frame, ssize_t len); 2011 void (*read_infoframe)(struct intel_encoder *encoder, 2012 const struct intel_crtc_state *crtc_state, 2013 unsigned int type, 2014 void *frame, ssize_t len); 2015 void (*set_infoframes)(struct intel_encoder *encoder, 2016 bool enable, 2017 const struct intel_crtc_state *crtc_state, 2018 const struct drm_connector_state *conn_state); 2019 u32 (*infoframes_enabled)(struct intel_encoder *encoder, 2020 const struct intel_crtc_state *pipe_config); 2021 bool (*connected)(struct intel_encoder *encoder); 2022 2023 void (*lock)(struct intel_digital_port *dig_port); 2024 void (*unlock)(struct intel_digital_port *dig_port); 2025 }; 2026 2027 struct intel_dp_mst_encoder { 2028 struct intel_encoder base; 2029 enum pipe pipe; 2030 struct intel_digital_port *primary; 2031 struct intel_connector *connector; 2032 }; 2033 2034 struct intel_colorop { 2035 struct drm_colorop base; 2036 enum intel_color_block id; 2037 }; 2038 2039 static inline struct intel_encoder * 2040 intel_attached_encoder(struct intel_connector *connector) 2041 { 2042 return connector->encoder; 2043 } 2044 2045 static inline bool intel_encoder_is_dig_port(struct intel_encoder *encoder) 2046 { 2047 switch (encoder->type) { 2048 case INTEL_OUTPUT_DDI: 2049 case INTEL_OUTPUT_DP: 2050 case INTEL_OUTPUT_EDP: 2051 case INTEL_OUTPUT_HDMI: 2052 return true; 2053 default: 2054 return false; 2055 } 2056 } 2057 2058 static inline bool intel_encoder_is_mst(struct intel_encoder *encoder) 2059 { 2060 return encoder->type == INTEL_OUTPUT_DP_MST; 2061 } 2062 2063 static inline struct intel_dp_mst_encoder * 2064 enc_to_mst(struct intel_encoder *encoder) 2065 { 2066 return container_of(&encoder->base, struct intel_dp_mst_encoder, 2067 base.base); 2068 } 2069 2070 static inline struct intel_digital_port * 2071 enc_to_dig_port(struct intel_encoder *encoder) 2072 { 2073 struct intel_encoder *intel_encoder = encoder; 2074 2075 if (intel_encoder_is_dig_port(intel_encoder)) 2076 return container_of(&encoder->base, struct intel_digital_port, 2077 base.base); 2078 else if (intel_encoder_is_mst(intel_encoder)) 2079 return enc_to_mst(encoder)->primary; 2080 else 2081 return NULL; 2082 } 2083 2084 static inline struct intel_digital_port * 2085 intel_attached_dig_port(struct intel_connector *connector) 2086 { 2087 return enc_to_dig_port(intel_attached_encoder(connector)); 2088 } 2089 2090 static inline struct intel_hdmi * 2091 enc_to_intel_hdmi(struct intel_encoder *encoder) 2092 { 2093 return &enc_to_dig_port(encoder)->hdmi; 2094 } 2095 2096 static inline struct intel_hdmi * 2097 intel_attached_hdmi(struct intel_connector *connector) 2098 { 2099 return enc_to_intel_hdmi(intel_attached_encoder(connector)); 2100 } 2101 2102 static inline struct intel_dp *enc_to_intel_dp(struct intel_encoder *encoder) 2103 { 2104 return &enc_to_dig_port(encoder)->dp; 2105 } 2106 2107 static inline struct intel_dp *intel_attached_dp(struct intel_connector *connector) 2108 { 2109 if (connector->mst.dp) 2110 return connector->mst.dp; 2111 else 2112 return enc_to_intel_dp(intel_attached_encoder(connector)); 2113 } 2114 2115 static inline bool intel_encoder_is_dp(struct intel_encoder *encoder) 2116 { 2117 switch (encoder->type) { 2118 case INTEL_OUTPUT_DP: 2119 case INTEL_OUTPUT_EDP: 2120 return true; 2121 case INTEL_OUTPUT_DDI: 2122 /* Skip pure HDMI/DVI DDI encoders */ 2123 return i915_mmio_reg_valid(enc_to_intel_dp(encoder)->output_reg); 2124 default: 2125 return false; 2126 } 2127 } 2128 2129 static inline bool intel_encoder_is_hdmi(struct intel_encoder *encoder) 2130 { 2131 switch (encoder->type) { 2132 case INTEL_OUTPUT_HDMI: 2133 return true; 2134 case INTEL_OUTPUT_DDI: 2135 /* See if the HDMI encoder is valid. */ 2136 return i915_mmio_reg_valid(enc_to_intel_hdmi(encoder)->hdmi_reg); 2137 default: 2138 return false; 2139 } 2140 } 2141 2142 static inline struct intel_digital_port * 2143 dp_to_dig_port(struct intel_dp *intel_dp) 2144 { 2145 return container_of(intel_dp, struct intel_digital_port, dp); 2146 } 2147 2148 static inline struct intel_digital_port * 2149 hdmi_to_dig_port(struct intel_hdmi *intel_hdmi) 2150 { 2151 return container_of(intel_hdmi, struct intel_digital_port, hdmi); 2152 } 2153 2154 static inline struct intel_plane_state * 2155 intel_atomic_get_plane_state(struct intel_atomic_state *state, 2156 struct intel_plane *plane) 2157 { 2158 struct drm_plane_state *ret = 2159 drm_atomic_get_plane_state(&state->base, &plane->base); 2160 2161 if (IS_ERR(ret)) 2162 return ERR_CAST(ret); 2163 2164 return to_intel_plane_state(ret); 2165 } 2166 2167 static inline struct intel_plane_state * 2168 intel_atomic_get_old_plane_state(struct intel_atomic_state *state, 2169 struct intel_plane *plane) 2170 { 2171 return to_intel_plane_state(drm_atomic_get_old_plane_state(&state->base, 2172 &plane->base)); 2173 } 2174 2175 static inline struct intel_plane_state * 2176 intel_atomic_get_new_plane_state(struct intel_atomic_state *state, 2177 struct intel_plane *plane) 2178 { 2179 return to_intel_plane_state(drm_atomic_get_new_plane_state(&state->base, 2180 &plane->base)); 2181 } 2182 2183 static inline struct intel_crtc_state * 2184 intel_atomic_get_old_crtc_state(struct intel_atomic_state *state, 2185 struct intel_crtc *crtc) 2186 { 2187 return to_intel_crtc_state(drm_atomic_get_old_crtc_state(&state->base, 2188 &crtc->base)); 2189 } 2190 2191 static inline struct intel_crtc_state * 2192 intel_atomic_get_new_crtc_state(struct intel_atomic_state *state, 2193 struct intel_crtc *crtc) 2194 { 2195 return to_intel_crtc_state(drm_atomic_get_new_crtc_state(&state->base, 2196 &crtc->base)); 2197 } 2198 2199 static inline struct intel_digital_connector_state * 2200 intel_atomic_get_new_connector_state(struct intel_atomic_state *state, 2201 struct intel_connector *connector) 2202 { 2203 return to_intel_digital_connector_state( 2204 drm_atomic_get_new_connector_state(&state->base, 2205 &connector->base)); 2206 } 2207 2208 static inline struct intel_digital_connector_state * 2209 intel_atomic_get_old_connector_state(struct intel_atomic_state *state, 2210 struct intel_connector *connector) 2211 { 2212 return to_intel_digital_connector_state( 2213 drm_atomic_get_old_connector_state(&state->base, 2214 &connector->base)); 2215 } 2216 2217 /* intel_display.c */ 2218 static inline bool 2219 intel_crtc_has_type(const struct intel_crtc_state *crtc_state, 2220 enum intel_output_type type) 2221 { 2222 return crtc_state->output_types & BIT(type); 2223 } 2224 2225 static inline bool 2226 intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state) 2227 { 2228 return crtc_state->output_types & 2229 (BIT(INTEL_OUTPUT_DP) | 2230 BIT(INTEL_OUTPUT_DP_MST) | 2231 BIT(INTEL_OUTPUT_EDP)); 2232 } 2233 2234 static inline bool 2235 intel_crtc_needs_modeset(const struct intel_crtc_state *crtc_state) 2236 { 2237 return drm_atomic_crtc_needs_modeset(&crtc_state->uapi); 2238 } 2239 2240 static inline bool 2241 intel_crtc_needs_fastset(const struct intel_crtc_state *crtc_state) 2242 { 2243 return crtc_state->update_pipe; 2244 } 2245 2246 static inline bool 2247 intel_crtc_needs_color_update(const struct intel_crtc_state *crtc_state) 2248 { 2249 return crtc_state->uapi.color_mgmt_changed || 2250 intel_crtc_needs_fastset(crtc_state) || 2251 intel_crtc_needs_modeset(crtc_state); 2252 } 2253 2254 static inline struct intel_frontbuffer * 2255 to_intel_frontbuffer(struct drm_framebuffer *fb) 2256 { 2257 return fb ? to_intel_framebuffer(fb)->frontbuffer : NULL; 2258 } 2259 2260 /* 2261 * Conversion functions/macros from various pointer types to struct 2262 * intel_display pointer. 2263 */ 2264 #define __drm_device_to_intel_display(p) \ 2265 ((p) ? __drm_to_display(p) : NULL) 2266 #define __device_to_intel_display(p) \ 2267 __drm_device_to_intel_display(dev_get_drvdata(p)) 2268 #define __pci_dev_to_intel_display(p) \ 2269 __drm_device_to_intel_display(pci_get_drvdata(p)) 2270 #define __intel_atomic_state_to_intel_display(p) \ 2271 __drm_device_to_intel_display((p)->base.dev) 2272 #define __intel_connector_to_intel_display(p) \ 2273 __drm_device_to_intel_display((p)->base.dev) 2274 #define __intel_crtc_to_intel_display(p) \ 2275 __drm_device_to_intel_display((p)->base.dev) 2276 #define __intel_crtc_state_to_intel_display(p) \ 2277 __drm_device_to_intel_display((p)->uapi.crtc->dev) 2278 #define __intel_digital_port_to_intel_display(p) \ 2279 __drm_device_to_intel_display((p)->base.base.dev) 2280 #define __intel_dp_to_intel_display(p) \ 2281 __drm_device_to_intel_display(dp_to_dig_port(p)->base.base.dev) 2282 #define __intel_encoder_to_intel_display(p) \ 2283 __drm_device_to_intel_display((p)->base.dev) 2284 #define __intel_hdmi_to_intel_display(p) \ 2285 __drm_device_to_intel_display(hdmi_to_dig_port(p)->base.base.dev) 2286 #define __intel_plane_to_intel_display(p) \ 2287 __drm_device_to_intel_display((p)->base.dev) 2288 #define __intel_plane_state_to_intel_display(p) \ 2289 __drm_device_to_intel_display((p)->uapi.plane->dev) 2290 2291 /* Helper for generic association. Map types to conversion functions/macros. */ 2292 #define __assoc(type, p) \ 2293 struct type: __##type##_to_intel_display((struct type *)(p)) 2294 2295 /* Convert various pointer types to struct intel_display pointer. */ 2296 #define to_intel_display(p) \ 2297 _Generic(*p, \ 2298 __assoc(drm_device, p), \ 2299 __assoc(device, p), \ 2300 __assoc(pci_dev, p), \ 2301 __assoc(intel_atomic_state, p), \ 2302 __assoc(intel_connector, p), \ 2303 __assoc(intel_crtc, p), \ 2304 __assoc(intel_crtc_state, p), \ 2305 __assoc(intel_digital_port, p), \ 2306 __assoc(intel_dp, p), \ 2307 __assoc(intel_encoder, p), \ 2308 __assoc(intel_hdmi, p), \ 2309 __assoc(intel_plane, p), \ 2310 __assoc(intel_plane_state, p)) 2311 2312 #endif /* __INTEL_DISPLAY_TYPES_H__ */ 2313