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_commit 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 688 struct intel_fb_view view; 689 690 /* for legacy cursor fb unpin */ 691 struct drm_vblank_work unpin_work; 692 693 /* fenced region ID (-1 if none) */ 694 s8 fence_id; 695 696 /* Plane pxp decryption state */ 697 bool decrypt; 698 699 /* Plane state to display black pixels when pxp is borked */ 700 bool force_black; 701 702 /* Acting as Y plane for another UV plane? */ 703 bool is_y_plane; 704 705 /* plane control register */ 706 u32 ctl; 707 708 /* plane color control register */ 709 u32 color_ctl; 710 711 /* chroma upsampler control register */ 712 u32 cus_ctl; 713 714 /* surface address register */ 715 u32 surf; 716 717 /* 718 * scaler_id 719 * = -1 : not using a scaler 720 * >= 0 : using a scalers 721 * 722 * plane requiring a scaler: 723 * - During check_plane, its bit is set in 724 * crtc_state->scaler_state.scaler_users by calling helper function 725 * update_scaler_plane. 726 * - scaler_id indicates the scaler it got assigned. 727 * 728 * plane doesn't require a scaler: 729 * - this can happen when scaling is no more required or plane simply 730 * got disabled. 731 * - During check_plane, corresponding bit is reset in 732 * crtc_state->scaler_state.scaler_users by calling helper function 733 * update_scaler_plane. 734 */ 735 int scaler_id; 736 737 /* 738 * planar_linked_plane: 739 * 740 * ICL planar formats require 2 planes that are updated as pairs. 741 * This member is used to make sure the other plane is also updated 742 * when required, and for update_slave() to find the correct 743 * plane_state to pass as argument. 744 */ 745 struct intel_plane *planar_linked_plane; 746 747 struct drm_intel_sprite_colorkey ckey; 748 749 struct drm_rect psr2_sel_fetch_area; 750 751 /* Clear Color Value */ 752 u64 ccval; 753 754 const char *no_fbc_reason; 755 756 struct drm_rect damage; 757 }; 758 759 struct intel_initial_plane_config { 760 struct drm_framebuffer *fb; 761 struct i915_vma *vma; 762 int size; 763 u32 base; 764 u8 rotation; 765 }; 766 767 struct intel_scaler { 768 u32 mode; 769 bool in_use; 770 int hscale; 771 int vscale; 772 }; 773 774 struct intel_crtc_scaler_state { 775 #define SKL_NUM_SCALERS 2 776 struct intel_scaler scalers[SKL_NUM_SCALERS]; 777 778 /* 779 * scaler_users: keeps track of users requesting scalers on this crtc. 780 * 781 * If a bit is set, a user is using a scaler. 782 * Here user can be a plane or crtc as defined below: 783 * bits 0-30 - plane (bit position is index from drm_plane_index) 784 * bit 31 - crtc 785 * 786 * Instead of creating a new index to cover planes and crtc, using 787 * existing drm_plane_index for planes which is well less than 31 788 * planes and bit 31 for crtc. This should be fine to cover all 789 * our platforms. 790 * 791 * intel_atomic_setup_scalers will setup available scalers to users 792 * requesting scalers. It will gracefully fail if request exceeds 793 * availability. 794 */ 795 #define SKL_CRTC_INDEX 31 796 unsigned scaler_users; 797 798 /* scaler used by crtc for panel fitting purpose */ 799 int scaler_id; 800 }; 801 802 /* {crtc,crtc_state}->mode_flags */ 803 /* Flag to get scanline using frame time stamps */ 804 #define I915_MODE_FLAG_GET_SCANLINE_FROM_TIMESTAMP (1<<1) 805 /* Flag to use the scanline counter instead of the pixel counter */ 806 #define I915_MODE_FLAG_USE_SCANLINE_COUNTER (1<<2) 807 /* 808 * TE0 or TE1 flag is set if the crtc has a DSI encoder which 809 * is operating in command mode. 810 * Flag to use TE from DSI0 instead of VBI in command mode 811 */ 812 #define I915_MODE_FLAG_DSI_USE_TE0 (1<<3) 813 /* Flag to use TE from DSI1 instead of VBI in command mode */ 814 #define I915_MODE_FLAG_DSI_USE_TE1 (1<<4) 815 /* Flag to indicate mipi dsi periodic command mode where we do not get TE */ 816 #define I915_MODE_FLAG_DSI_PERIODIC_CMD_MODE (1<<5) 817 /* Do tricks to make vblank timestamps sane with VRR? */ 818 #define I915_MODE_FLAG_VRR (1<<6) 819 820 struct intel_wm_level { 821 bool enable; 822 u32 pri_val; 823 u32 spr_val; 824 u32 cur_val; 825 u32 fbc_val; 826 }; 827 828 struct intel_pipe_wm { 829 struct intel_wm_level wm[5]; 830 bool fbc_wm_enabled; 831 bool pipe_enabled; 832 bool sprites_enabled; 833 bool sprites_scaled; 834 }; 835 836 struct skl_wm_level { 837 u16 min_ddb_alloc; 838 u16 min_ddb_alloc_uv; /* for pre-icl */ 839 u16 blocks; 840 u8 lines; 841 bool enable; 842 bool ignore_lines; 843 bool auto_min_alloc_wm_enable; 844 bool can_sagv; 845 }; 846 847 struct skl_plane_wm { 848 struct skl_wm_level wm[8]; 849 struct skl_wm_level trans_wm; 850 struct { 851 struct skl_wm_level wm0; 852 struct skl_wm_level trans_wm; 853 } sagv; 854 }; 855 856 struct skl_pipe_wm { 857 struct skl_plane_wm planes[I915_MAX_PLANES]; 858 bool use_sagv_wm; 859 }; 860 861 enum vlv_wm_level { 862 VLV_WM_LEVEL_PM2, 863 VLV_WM_LEVEL_PM5, 864 VLV_WM_LEVEL_DDR_DVFS, 865 NUM_VLV_WM_LEVELS, 866 }; 867 868 struct vlv_wm_state { 869 struct g4x_pipe_wm wm[NUM_VLV_WM_LEVELS]; 870 struct g4x_sr_wm sr[NUM_VLV_WM_LEVELS]; 871 u8 num_levels; 872 bool cxsr; 873 }; 874 875 struct vlv_fifo_state { 876 u16 plane[I915_MAX_PLANES]; 877 }; 878 879 enum g4x_wm_level { 880 G4X_WM_LEVEL_NORMAL, 881 G4X_WM_LEVEL_SR, 882 G4X_WM_LEVEL_HPLL, 883 NUM_G4X_WM_LEVELS, 884 }; 885 886 struct g4x_wm_state { 887 struct g4x_pipe_wm wm; 888 struct g4x_sr_wm sr; 889 struct g4x_sr_wm hpll; 890 bool cxsr; 891 bool hpll_en; 892 bool fbc_en; 893 }; 894 895 struct intel_crtc_wm_state { 896 union { 897 /* 898 * raw: 899 * The "raw" watermark values produced by the formula 900 * given the plane's current state. They do not consider 901 * how much FIFO is actually allocated for each plane. 902 * 903 * optimal: 904 * The "optimal" watermark values given the current 905 * state of the planes and the amount of FIFO 906 * allocated to each, ignoring any previous state 907 * of the planes. 908 * 909 * intermediate: 910 * The "intermediate" watermark values when transitioning 911 * between the old and new "optimal" values. Used when 912 * the watermark registers are single buffered and hence 913 * their state changes asynchronously with regards to the 914 * actual plane registers. These are essentially the 915 * worst case combination of the old and new "optimal" 916 * watermarks, which are therefore safe to use when the 917 * plane is in either its old or new state. 918 */ 919 struct { 920 struct intel_pipe_wm intermediate; 921 struct intel_pipe_wm optimal; 922 } ilk; 923 924 struct { 925 struct skl_pipe_wm raw; 926 /* gen9+ only needs 1-step wm programming */ 927 struct skl_pipe_wm optimal; 928 struct skl_ddb_entry ddb; 929 /* 930 * pre-icl: for packed/planar CbCr 931 * icl+: for everything 932 */ 933 struct skl_ddb_entry plane_ddb[I915_MAX_PLANES]; 934 /* pre-icl: for planar Y */ 935 struct skl_ddb_entry plane_ddb_y[I915_MAX_PLANES]; 936 937 /* 938 * xe3: Minimum amount of display blocks and minimum 939 * sagv allocation required for async flip 940 */ 941 u16 plane_min_ddb[I915_MAX_PLANES]; 942 u16 plane_interim_ddb[I915_MAX_PLANES]; 943 } skl; 944 945 struct { 946 struct g4x_pipe_wm raw[NUM_VLV_WM_LEVELS]; /* not inverted */ 947 struct vlv_wm_state intermediate; /* inverted */ 948 struct vlv_wm_state optimal; /* inverted */ 949 struct vlv_fifo_state fifo_state; 950 } vlv; 951 952 struct { 953 struct g4x_pipe_wm raw[NUM_G4X_WM_LEVELS]; 954 struct g4x_wm_state intermediate; 955 struct g4x_wm_state optimal; 956 } g4x; 957 }; 958 959 /* 960 * Platforms with two-step watermark programming will need to 961 * update watermark programming post-vblank to switch from the 962 * safe intermediate watermarks to the optimal final 963 * watermarks. 964 */ 965 bool need_postvbl_update; 966 }; 967 968 enum intel_output_format { 969 INTEL_OUTPUT_FORMAT_RGB, 970 INTEL_OUTPUT_FORMAT_YCBCR420, 971 INTEL_OUTPUT_FORMAT_YCBCR444, 972 }; 973 974 /* Used by dp and fdi links */ 975 struct intel_link_m_n { 976 u32 tu; 977 u32 data_m; 978 u32 data_n; 979 u32 link_m; 980 u32 link_n; 981 }; 982 983 struct intel_csc_matrix { 984 u16 coeff[9]; 985 u16 preoff[3]; 986 u16 postoff[3]; 987 }; 988 989 struct scaler_filter_coeff { 990 u16 sign; 991 u16 exp; 992 u16 mantissa; 993 }; 994 995 struct intel_casf { 996 #define SCALER_FILTER_NUM_TAPS 7 997 struct scaler_filter_coeff coeff[SCALER_FILTER_NUM_TAPS]; 998 u8 strength; 999 u8 win_size; 1000 bool enable; 1001 }; 1002 1003 struct intel_crtc_state { 1004 /* 1005 * uapi (drm) state. This is the software state shown to userspace. 1006 * In particular, the following members are used for bookkeeping: 1007 * - crtc 1008 * - state 1009 * - *_changed 1010 * - event 1011 * - commit 1012 * - mode_blob 1013 */ 1014 struct drm_crtc_state uapi; 1015 1016 /* 1017 * actual hardware state, the state we program to the hardware. 1018 * The following members are used to verify the hardware state: 1019 * - enable 1020 * - active 1021 * - mode / pipe_mode / adjusted_mode 1022 * - color property blobs. 1023 * 1024 * During initial hw readout, they need to be copied to uapi. 1025 * 1026 * Joiner will allow a transcoder mode that spans 2 pipes; 1027 * Use the pipe_mode for calculations like watermarks, pipe 1028 * scaler, and bandwidth. 1029 * 1030 * Use adjusted_mode for things that need to know the full 1031 * mode on the transcoder, which spans all pipes. 1032 */ 1033 struct { 1034 bool active, enable; 1035 /* logical state of LUTs */ 1036 struct drm_property_blob *degamma_lut, *gamma_lut, *ctm; 1037 struct drm_display_mode mode, pipe_mode, adjusted_mode; 1038 u32 background_color; 1039 enum drm_scaling_filter scaling_filter; 1040 u8 sharpness_strength; 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 intel_casf casf; 1228 struct drm_rect dst; 1229 bool enabled; 1230 bool force_thru; 1231 } pch_pfit; 1232 1233 /* FDI configuration, only valid if has_pch_encoder is set. */ 1234 int fdi_lanes; 1235 struct intel_link_m_n fdi_m_n; 1236 1237 bool ips_enabled; 1238 1239 bool crc_enabled; 1240 1241 bool double_wide; 1242 1243 struct intel_crtc_scaler_state scaler_state; 1244 1245 /* w/a for waiting 2 vblanks during crtc enable */ 1246 enum pipe hsw_workaround_pipe; 1247 1248 struct intel_crtc_wm_state wm; 1249 1250 int min_cdclk; 1251 1252 int plane_min_cdclk[I915_MAX_PLANES]; 1253 1254 /* for packed/planar CbCr */ 1255 u32 data_rate[I915_MAX_PLANES]; 1256 /* for planar Y */ 1257 u32 data_rate_y[I915_MAX_PLANES]; 1258 1259 /* FIXME unify with data_rate[]? */ 1260 u64 rel_data_rate[I915_MAX_PLANES]; 1261 u64 rel_data_rate_y[I915_MAX_PLANES]; 1262 1263 /* Gamma mode programmed on the pipe */ 1264 u32 gamma_mode; 1265 1266 union { 1267 /* CSC mode programmed on the pipe */ 1268 u32 csc_mode; 1269 1270 /* CHV CGM mode */ 1271 u32 cgm_mode; 1272 }; 1273 1274 /* bitmask of logically enabled planes (enum plane_id) */ 1275 u8 enabled_planes; 1276 1277 /* bitmask of actually visible planes (enum plane_id) */ 1278 u8 active_planes; 1279 u8 scaled_planes; 1280 u8 nv12_planes; 1281 u8 c8_planes; 1282 1283 /* bitmask of planes that will be updated during the commit */ 1284 u8 update_planes; 1285 1286 /* bitmask of planes with async flip active */ 1287 u8 async_flip_planes; 1288 1289 u8 framestart_delay; /* 1-4 */ 1290 u8 msa_timing_delay; /* 0-3 */ 1291 1292 struct { 1293 u32 enable; 1294 u32 gcp; 1295 union hdmi_infoframe avi; 1296 union hdmi_infoframe spd; 1297 union hdmi_infoframe hdmi; 1298 union hdmi_infoframe drm; 1299 struct drm_dp_vsc_sdp vsc; 1300 struct drm_dp_as_sdp as_sdp; 1301 } infoframes; 1302 1303 u8 eld[MAX_ELD_BYTES]; 1304 1305 /* HDMI scrambling status */ 1306 bool hdmi_scrambling; 1307 1308 /* HDMI High TMDS char rate ratio */ 1309 bool hdmi_high_tmds_clock_ratio; 1310 1311 /* 1312 * Output format RGB/YCBCR etc., that is coming out 1313 * at the end of the pipe. 1314 */ 1315 enum intel_output_format output_format; 1316 1317 /* 1318 * Sink output format RGB/YCBCR etc., that is going 1319 * into the sink. 1320 */ 1321 enum intel_output_format sink_format; 1322 1323 /* enable pipe gamma? */ 1324 bool gamma_enable; 1325 1326 /* enable pipe csc? */ 1327 bool csc_enable; 1328 1329 /* enable vlv/chv wgc csc? */ 1330 bool wgc_enable; 1331 1332 /* joiner pipe bitmask */ 1333 u8 joiner_pipes; 1334 1335 /* Display Stream compression state */ 1336 struct { 1337 /* Only used for state computation, not read out from the HW. */ 1338 bool compression_enabled_on_link; 1339 bool compression_enable; 1340 struct intel_dsc_slice_config { 1341 int pipes_per_line; 1342 int streams_per_pipe; 1343 int slices_per_stream; 1344 } slice_config; 1345 /* Compressed Bpp in U6.4 format (first 4 bits for fractional part) */ 1346 u16 compressed_bpp_x16; 1347 struct drm_dsc_config config; 1348 } dsc; 1349 1350 /* DP tunnel used for BW allocation. */ 1351 struct drm_dp_tunnel_ref dp_tunnel_ref; 1352 1353 /* HSW+ linetime watermarks */ 1354 u16 linetime; 1355 u16 ips_linetime; 1356 1357 bool enhanced_framing; 1358 1359 /* 1360 * Forward Error Correction. 1361 * 1362 * Note: This will be false for 128b/132b, which will always have FEC 1363 * enabled automatically. 1364 */ 1365 bool fec_enable; 1366 1367 bool sdp_split_enable; 1368 1369 /* Pointer to master transcoder in case of tiled displays */ 1370 enum transcoder master_transcoder; 1371 1372 /* Bitmask to indicate slaves attached */ 1373 u8 sync_mode_slaves_mask; 1374 1375 /* Only valid on TGL+ */ 1376 enum transcoder mst_master_transcoder; 1377 1378 /* For DSB based pipe updates */ 1379 struct intel_dsb *dsb_color, *dsb_commit; 1380 bool use_dsb; 1381 bool use_flipq; 1382 1383 u32 psr2_man_track_ctl; 1384 1385 u32 pipe_srcsz_early_tpt; 1386 1387 struct drm_rect psr2_su_area; 1388 1389 /* Variable Refresh Rate state */ 1390 struct { 1391 bool enable, in_range; 1392 u8 pipeline_full; 1393 u16 flipline, vmin, vmax, guardband; 1394 u32 vsync_end, vsync_start; 1395 struct { 1396 bool enable; 1397 u16 vmin, vmax; 1398 u16 guardband, slope; 1399 u16 max_increase, max_decrease; 1400 u16 vblank_target; 1401 } dc_balance; 1402 } vrr; 1403 1404 /* Content Match Refresh Rate state */ 1405 struct { 1406 bool enable; 1407 u64 cmrr_n, cmrr_m; 1408 } cmrr; 1409 1410 /* Stream Splitter for eDP MSO */ 1411 struct { 1412 bool enable; 1413 u8 link_count; 1414 u8 pixel_overlap; 1415 } splitter; 1416 1417 /* for loading single buffered registers during vblank */ 1418 struct drm_vblank_work vblank_work; 1419 1420 /* LOBF flag */ 1421 bool has_lobf; 1422 1423 /* W2 window or 'set context latency' lines */ 1424 u16 set_context_latency; 1425 1426 struct { 1427 u8 io_wake_lines; 1428 u8 fast_wake_lines; 1429 1430 /* LNL and beyond */ 1431 u8 check_entry_lines; 1432 u8 aux_less_wake_lines; 1433 u8 silence_period_sym_clocks; 1434 u8 lfps_half_cycle_num_of_syms; 1435 } alpm_state; 1436 1437 /* to track changes in plane color blocks */ 1438 bool plane_color_changed; 1439 }; 1440 1441 enum intel_pipe_crc_source { 1442 INTEL_PIPE_CRC_SOURCE_NONE, 1443 INTEL_PIPE_CRC_SOURCE_PLANE1, 1444 INTEL_PIPE_CRC_SOURCE_PLANE2, 1445 INTEL_PIPE_CRC_SOURCE_PLANE3, 1446 INTEL_PIPE_CRC_SOURCE_PLANE4, 1447 INTEL_PIPE_CRC_SOURCE_PLANE5, 1448 INTEL_PIPE_CRC_SOURCE_PLANE6, 1449 INTEL_PIPE_CRC_SOURCE_PLANE7, 1450 INTEL_PIPE_CRC_SOURCE_PIPE, 1451 /* TV/DP on pre-gen5/vlv can't use the pipe source. */ 1452 INTEL_PIPE_CRC_SOURCE_TV, 1453 INTEL_PIPE_CRC_SOURCE_DP_B, 1454 INTEL_PIPE_CRC_SOURCE_DP_C, 1455 INTEL_PIPE_CRC_SOURCE_DP_D, 1456 INTEL_PIPE_CRC_SOURCE_AUTO, 1457 INTEL_PIPE_CRC_SOURCE_MAX, 1458 }; 1459 1460 enum drrs_refresh_rate { 1461 DRRS_REFRESH_RATE_HIGH, 1462 DRRS_REFRESH_RATE_LOW, 1463 }; 1464 1465 #define INTEL_PIPE_CRC_ENTRIES_NR 128 1466 struct intel_pipe_crc { 1467 spinlock_t lock; 1468 int skipped; 1469 enum intel_pipe_crc_source source; 1470 }; 1471 1472 enum intel_flipq_id { 1473 INTEL_FLIPQ_PLANE_1, 1474 INTEL_FLIPQ_PLANE_2, 1475 INTEL_FLIPQ_PLANE_3, 1476 INTEL_FLIPQ_GENERAL, 1477 INTEL_FLIPQ_FAST, 1478 MAX_INTEL_FLIPQ, 1479 }; 1480 1481 struct intel_flipq { 1482 u32 start_mmioaddr; 1483 enum intel_flipq_id flipq_id; 1484 u8 tail; 1485 }; 1486 1487 struct intel_crtc { 1488 struct drm_crtc base; 1489 struct list_head pipe_head; 1490 enum pipe pipe; 1491 /* 1492 * Whether the crtc and the connected output pipeline is active. Implies 1493 * that crtc->enabled is set, i.e. the current mode configuration has 1494 * some outputs connected to this crtc. 1495 */ 1496 bool active; 1497 u8 plane_ids_mask; 1498 1499 /* I915_MODE_FLAG_* */ 1500 u8 mode_flags; 1501 1502 u16 vmax_vblank_start; 1503 1504 struct intel_display_power_domain_set enabled_power_domains; 1505 struct intel_display_power_domain_set hw_readout_power_domains; 1506 struct intel_overlay *overlay; 1507 1508 struct intel_crtc_state *config; 1509 1510 /* armed event for async flip */ 1511 struct drm_pending_vblank_event *flip_done_event; 1512 /* armed event for DSB based updates */ 1513 struct drm_pending_vblank_event *dsb_event; 1514 /* armed event for flip queue based updates */ 1515 struct drm_pending_vblank_event *flipq_event; 1516 1517 /* Access to these should be protected by display->irq.lock. */ 1518 bool cpu_fifo_underrun_disabled; 1519 bool pch_fifo_underrun_disabled; 1520 1521 struct intel_flipq flipq[MAX_INTEL_FLIPQ]; 1522 1523 /* per-pipe watermark state */ 1524 struct { 1525 /* watermarks currently being used */ 1526 union { 1527 struct intel_pipe_wm ilk; 1528 struct vlv_wm_state vlv; 1529 struct g4x_wm_state g4x; 1530 } active; 1531 } wm; 1532 1533 struct { 1534 struct mutex mutex; 1535 struct delayed_work work; 1536 enum drrs_refresh_rate refresh_rate; 1537 unsigned int frontbuffer_bits; 1538 unsigned int busy_frontbuffer_bits; 1539 enum transcoder cpu_transcoder; 1540 struct intel_link_m_n m_n, m2_n2; 1541 } drrs; 1542 1543 struct { 1544 u64 flip_count; 1545 } dc_balance; 1546 1547 int scanline_offset; 1548 1549 struct { 1550 unsigned start_vbl_count; 1551 ktime_t start_vbl_time; 1552 int min_vbl, max_vbl; 1553 int scanline_start; 1554 #ifdef CONFIG_DRM_I915_DEBUG_VBLANK_EVADE 1555 struct { 1556 u64 min; 1557 u64 max; 1558 u64 sum; 1559 unsigned int over; 1560 unsigned int times[17]; /* [1us, 16ms] */ 1561 } vbl; 1562 #endif 1563 } debug; 1564 1565 /* scalers available on this crtc */ 1566 int num_scalers; 1567 1568 /* for loading single buffered registers during vblank */ 1569 struct pm_qos_request vblank_pm_qos; 1570 1571 #ifdef CONFIG_DEBUG_FS 1572 struct intel_pipe_crc pipe_crc; 1573 #endif 1574 1575 bool vblank_psr_notify; 1576 }; 1577 1578 struct intel_plane_error { 1579 u32 ctl, surf, surflive; 1580 }; 1581 1582 struct intel_plane { 1583 struct drm_plane base; 1584 enum i9xx_plane_id i9xx_plane; 1585 enum plane_id id; 1586 enum pipe pipe; 1587 bool need_async_flip_toggle_wa; 1588 u8 vtd_guard; 1589 u32 frontbuffer_bit; 1590 1591 struct { 1592 u32 base, cntl, size; 1593 } cursor; 1594 1595 struct intel_fbc *fbc; 1596 1597 /* 1598 * NOTE: Do not place new plane state fields here (e.g., when adding 1599 * new plane properties). New runtime state should now be placed in 1600 * the intel_plane_state structure and accessed via plane_state. 1601 */ 1602 1603 int (*min_width)(const struct drm_framebuffer *fb, 1604 int color_plane, 1605 unsigned int rotation); 1606 int (*max_width)(const struct drm_framebuffer *fb, 1607 int color_plane, 1608 unsigned int rotation); 1609 int (*max_height)(const struct drm_framebuffer *fb, 1610 int color_plane, 1611 unsigned int rotation); 1612 unsigned int (*min_alignment)(struct intel_plane *plane, 1613 const struct drm_framebuffer *fb, 1614 int color_plane); 1615 unsigned int (*max_stride)(struct intel_plane *plane, 1616 const struct drm_format_info *info, 1617 u64 modifier, unsigned int rotation); 1618 bool (*can_async_flip)(u64 modifier); 1619 /* Write all non-self arming plane registers */ 1620 void (*update_noarm)(struct intel_dsb *dsb, 1621 struct intel_plane *plane, 1622 const struct intel_crtc_state *crtc_state, 1623 const struct intel_plane_state *plane_state); 1624 /* Write all self-arming plane registers */ 1625 void (*update_arm)(struct intel_dsb *dsb, 1626 struct intel_plane *plane, 1627 const struct intel_crtc_state *crtc_state, 1628 const struct intel_plane_state *plane_state); 1629 /* Disable the plane, must arm */ 1630 void (*disable_arm)(struct intel_dsb *dsb, 1631 struct intel_plane *plane, 1632 const struct intel_crtc_state *crtc_state); 1633 void (*capture_error)(struct intel_crtc *crtc, 1634 struct intel_plane *plane, 1635 struct intel_plane_error *error); 1636 bool (*get_hw_state)(struct intel_plane *plane, enum pipe *pipe); 1637 int (*check_plane)(struct intel_crtc_state *crtc_state, 1638 struct intel_plane_state *plane_state); 1639 u32 (*surf_offset)(const struct intel_plane_state *plane_state); 1640 int (*min_cdclk)(const struct intel_crtc_state *crtc_state, 1641 const struct intel_plane_state *plane_state); 1642 void (*async_flip)(struct intel_dsb *dsb, 1643 struct intel_plane *plane, 1644 const struct intel_crtc_state *crtc_state, 1645 const struct intel_plane_state *plane_state, 1646 bool async_flip); 1647 void (*enable_flip_done)(struct intel_plane *plane); 1648 void (*disable_flip_done)(struct intel_plane *plane); 1649 /* For drm_panic */ 1650 void (*disable_tiling)(struct intel_plane *plane); 1651 }; 1652 1653 #define to_intel_atomic_state(x) container_of(x, struct intel_atomic_state, base) 1654 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base) 1655 #define to_intel_connector(x) container_of(x, struct intel_connector, base) 1656 #define to_intel_encoder(x) container_of(x, struct intel_encoder, base) 1657 #define to_intel_plane(x) container_of(x, struct intel_plane, base) 1658 1659 #define to_intel_crtc_state(crtc_state) \ 1660 container_of_const((crtc_state), struct intel_crtc_state, uapi) 1661 #define to_intel_plane_state(plane_state) \ 1662 container_of_const((plane_state), struct intel_plane_state, uapi) 1663 #define to_intel_framebuffer(fb) \ 1664 container_of_const((fb), struct intel_framebuffer, base) 1665 1666 struct intel_hdmi { 1667 intel_reg_t hdmi_reg; 1668 struct { 1669 enum drm_dp_dual_mode_type type; 1670 int max_tmds_clock; 1671 } dp_dual_mode; 1672 struct intel_connector *attached_connector; 1673 struct cec_notifier *cec_notifier; 1674 }; 1675 1676 struct intel_dp_mst_encoder; 1677 1678 struct intel_dp_compliance_data { 1679 unsigned long edid; 1680 u8 video_pattern; 1681 u16 hdisplay, vdisplay; 1682 u8 bpc; 1683 struct drm_dp_phy_test_params phytest; 1684 }; 1685 1686 struct intel_dp_compliance { 1687 unsigned long test_type; 1688 struct intel_dp_compliance_data test_data; 1689 bool test_active; 1690 int test_link_rate; 1691 u8 test_lane_count; 1692 }; 1693 1694 struct intel_dp_pcon_frl { 1695 bool is_trained; 1696 int trained_rate_gbps; 1697 }; 1698 1699 struct intel_pps { 1700 int panel_power_up_delay; 1701 int panel_power_down_delay; 1702 int panel_power_cycle_delay; 1703 int backlight_on_delay; 1704 int backlight_off_delay; 1705 struct delayed_work panel_vdd_work; 1706 bool want_panel_vdd; 1707 bool initializing; 1708 unsigned long last_power_on; 1709 unsigned long last_backlight_off; 1710 ktime_t panel_power_off_time; 1711 struct ref_tracker *vdd_wakeref; 1712 1713 union { 1714 /* 1715 * Pipe whose power sequencer is currently locked into 1716 * this port. Only relevant on VLV/CHV. 1717 */ 1718 enum pipe vlv_pps_pipe; 1719 1720 /* 1721 * Power sequencer index. Only relevant on BXT+. 1722 */ 1723 int pps_idx; 1724 }; 1725 1726 /* 1727 * Pipe currently driving the port. Used for preventing 1728 * the use of the PPS for any pipe currentrly driving 1729 * external DP as that will mess things up on VLV. 1730 */ 1731 enum pipe vlv_active_pipe; 1732 /* 1733 * Set if the sequencer may be reset due to a power transition, 1734 * requiring a reinitialization. Only relevant on BXT+. 1735 */ 1736 bool bxt_pps_reset; 1737 struct intel_pps_delays pps_delays; 1738 struct intel_pps_delays bios_pps_delays; 1739 }; 1740 1741 struct intel_psr { 1742 /* Mutex for PSR state of the transcoder */ 1743 struct mutex lock; 1744 1745 #define I915_PSR_DEBUG_MODE_MASK 0x0f 1746 #define I915_PSR_DEBUG_DEFAULT 0x00 1747 #define I915_PSR_DEBUG_DISABLE 0x01 1748 #define I915_PSR_DEBUG_ENABLE 0x02 1749 #define I915_PSR_DEBUG_FORCE_PSR1 0x03 1750 #define I915_PSR_DEBUG_ENABLE_SEL_FETCH 0x4 1751 #define I915_PSR_DEBUG_IRQ 0x10 1752 #define I915_PSR_DEBUG_SU_REGION_ET_DISABLE 0x20 1753 #define I915_PSR_DEBUG_PANEL_REPLAY_DISABLE 0x40 1754 1755 u32 debug; 1756 bool sink_support; 1757 bool source_support; 1758 bool enabled; 1759 int pause_counter; 1760 enum pipe pipe; 1761 enum transcoder transcoder; 1762 bool active; 1763 struct work_struct work; 1764 unsigned int busy_frontbuffer_bits; 1765 bool link_standby; 1766 bool sel_update_enabled; 1767 bool psr2_sel_fetch_enabled; 1768 bool psr2_sel_fetch_cff_enabled; 1769 bool su_region_et_enabled; 1770 bool req_psr2_sdp_prior_scanline; 1771 ktime_t last_entry_attempt; 1772 ktime_t last_exit; 1773 bool sink_not_reliable; 1774 bool irq_aux_error; 1775 u16 su_w_granularity; 1776 u16 su_y_granularity; 1777 bool source_panel_replay_support; 1778 bool sink_panel_replay_support; 1779 bool panel_replay_enabled; 1780 u32 dc3co_exitline; 1781 u32 dc3co_exit_delay; 1782 struct delayed_work dc3co_work; 1783 u8 entry_setup_frames; 1784 1785 u8 io_wake_lines; 1786 u8 fast_wake_lines; 1787 1788 bool link_ok; 1789 bool pkg_c_latency_used; 1790 1791 u8 active_non_psr_pipes; 1792 1793 const char *no_psr_reason; 1794 1795 struct ref_tracker *vblank_wakeref; 1796 }; 1797 1798 struct intel_dp { 1799 intel_reg_t output_reg; 1800 u32 DP; 1801 int link_rate; 1802 u8 lane_count; 1803 u8 sink_count; 1804 bool downstream_port_changed; 1805 bool needs_modeset_retry; 1806 bool use_max_params; 1807 u8 dpcd[DP_RECEIVER_CAP_SIZE]; 1808 1809 u8 downstream_ports[DP_MAX_DOWNSTREAM_PORTS]; 1810 u8 edp_dpcd[EDP_DISPLAY_CTL_CAP_SIZE]; 1811 u8 lttpr_common_caps[DP_LTTPR_COMMON_CAP_SIZE]; 1812 u8 lttpr_phy_caps[DP_MAX_LTTPR_COUNT][DP_LTTPR_PHY_CAP_SIZE]; 1813 u8 pcon_dsc_dpcd[DP_PCON_DSC_ENCODER_CAP_SIZE]; 1814 /* source rates */ 1815 int num_source_rates; 1816 const int *source_rates; 1817 /* sink rates as reported by DP_MAX_LINK_RATE/DP_SUPPORTED_LINK_RATES */ 1818 int num_sink_rates; 1819 int sink_rates[DP_MAX_SUPPORTED_RATES]; 1820 bool use_rate_select; 1821 /* Max sink lane count as reported by DP_MAX_LANE_COUNT */ 1822 int max_sink_lane_count; 1823 /* intersection of source and sink rates */ 1824 int num_common_rates; 1825 int common_rates[DP_MAX_SUPPORTED_RATES]; 1826 int max_common_lane_count; 1827 struct { 1828 /* TODO: move the rest of link specific fields to here */ 1829 bool active; 1830 /* common rate,lane_count configs in bw order */ 1831 int num_configs; 1832 #define INTEL_DP_MAX_LANE_COUNT 4 1833 #define INTEL_DP_MAX_SUPPORTED_LANE_CONFIGS (ilog2(INTEL_DP_MAX_LANE_COUNT) + 1) 1834 #define INTEL_DP_LANE_COUNT_EXP_BITS order_base_2(INTEL_DP_MAX_SUPPORTED_LANE_CONFIGS) 1835 #define INTEL_DP_LINK_RATE_IDX_BITS (BITS_PER_TYPE(u8) - INTEL_DP_LANE_COUNT_EXP_BITS) 1836 #define INTEL_DP_MAX_LINK_CONFIGS (DP_MAX_SUPPORTED_RATES * \ 1837 INTEL_DP_MAX_SUPPORTED_LANE_CONFIGS) 1838 struct intel_dp_link_config { 1839 u8 link_rate_idx:INTEL_DP_LINK_RATE_IDX_BITS; 1840 u8 lane_count_exp:INTEL_DP_LANE_COUNT_EXP_BITS; 1841 } configs[INTEL_DP_MAX_LINK_CONFIGS]; 1842 /* Max lane count for the current link */ 1843 int max_lane_count; 1844 /* Max rate for the current link */ 1845 int max_rate; 1846 /* 1847 * Link parameters for which the MST topology was probed. 1848 * Tracking these ensures that the MST path resources are 1849 * re-enumerated whenever the link is retrained with new link 1850 * parameters, as required by the DP standard. 1851 */ 1852 int mst_probed_lane_count; 1853 int mst_probed_rate; 1854 int force_lane_count; 1855 int force_rate; 1856 bool retrain_disabled; 1857 /* Sequential link training failures after a passing LT */ 1858 int seq_train_failures; 1859 int force_train_failure; 1860 bool force_retrain; 1861 } link; 1862 bool reset_link_params; 1863 int mso_link_count; 1864 int mso_pixel_overlap; 1865 /* sink or branch descriptor */ 1866 struct drm_dp_desc desc; 1867 struct drm_dp_aux aux; 1868 u32 aux_busy_last_status; 1869 u8 train_set[4]; 1870 1871 struct intel_pps pps; 1872 1873 bool is_mst; 1874 enum drm_dp_mst_mode mst_detect; 1875 1876 /* connector directly attached - won't be use for modeset in mst world */ 1877 struct intel_connector *attached_connector; 1878 bool as_sdp_supported; 1879 bool as_sdp_v2_supported; 1880 1881 struct drm_dp_tunnel *tunnel; 1882 bool tunnel_suspended:1; 1883 1884 struct { 1885 struct intel_dp_mst_encoder *stream_encoders[I915_MAX_PIPES]; 1886 struct drm_dp_mst_topology_mgr mgr; 1887 int active_streams; 1888 } mst; 1889 1890 u32 (*get_aux_clock_divider)(struct intel_dp *dp, int index); 1891 /* 1892 * This function returns the value we have to program the AUX_CTL 1893 * register with to kick off an AUX transaction. 1894 */ 1895 u32 (*get_aux_send_ctl)(struct intel_dp *dp, int send_bytes, 1896 u32 aux_clock_divider); 1897 1898 intel_reg_t (*aux_ch_ctl_reg)(struct intel_dp *dp); 1899 intel_reg_t (*aux_ch_data_reg)(struct intel_dp *dp, int index); 1900 1901 /* This is called before a link training is starterd */ 1902 void (*prepare_link_retrain)(struct intel_dp *intel_dp, 1903 const struct intel_crtc_state *crtc_state); 1904 void (*set_link_train)(struct intel_dp *intel_dp, 1905 const struct intel_crtc_state *crtc_state, 1906 u8 dp_train_pat); 1907 void (*set_idle_link_train)(struct intel_dp *intel_dp, 1908 const struct intel_crtc_state *crtc_state); 1909 1910 u8 (*preemph_max)(struct intel_dp *intel_dp); 1911 u8 (*voltage_max)(struct intel_dp *intel_dp, 1912 const struct intel_crtc_state *crtc_state); 1913 1914 /* Displayport compliance testing */ 1915 struct intel_dp_compliance compliance; 1916 1917 /* Downstream facing port caps */ 1918 struct { 1919 int min_tmds_clock, max_tmds_clock; 1920 int max_dotclock; 1921 int pcon_max_frl_bw; 1922 u8 max_bpc; 1923 bool ycbcr_444_to_420; 1924 bool ycbcr420_passthrough; 1925 bool rgb_to_ycbcr; 1926 } dfp; 1927 1928 /* To control wakeup latency, e.g. for irq-driven dp aux transfers. */ 1929 struct pm_qos_request pm_qos; 1930 1931 /* Display stream compression testing */ 1932 bool force_dsc_en; 1933 int force_dsc_output_format; 1934 bool force_dsc_fractional_bpp_en; 1935 int force_dsc_bpc; 1936 1937 bool hobl_failed; 1938 bool hobl_active; 1939 1940 struct intel_dp_pcon_frl frl; 1941 1942 struct intel_psr psr; 1943 1944 /* When we last wrote the OUI for eDP */ 1945 unsigned long last_oui_write; 1946 bool oui_valid; 1947 1948 bool colorimetry_support; 1949 1950 struct { 1951 enum transcoder transcoder; 1952 struct mutex lock; 1953 1954 bool lobf_disable_debug; 1955 bool sink_alpm_error; 1956 } alpm; 1957 1958 u8 alpm_dpcd; 1959 1960 struct { 1961 unsigned long mask; 1962 } quirks; 1963 }; 1964 1965 enum lspcon_vendor { 1966 LSPCON_VENDOR_MCA, 1967 LSPCON_VENDOR_PARADE 1968 }; 1969 1970 struct intel_lspcon { 1971 bool active; 1972 bool hdr_supported; 1973 enum drm_lspcon_mode mode; 1974 enum lspcon_vendor vendor; 1975 }; 1976 1977 struct intel_digital_port { 1978 struct intel_encoder base; 1979 struct intel_dp dp; 1980 struct intel_hdmi hdmi; 1981 struct intel_lspcon lspcon; 1982 enum irqreturn (*hpd_pulse)(struct intel_digital_port *, bool); 1983 1984 bool lane_reversal; 1985 bool ddi_a_4_lanes; 1986 bool release_cl2_override; 1987 bool dedicated_external; 1988 u8 max_lanes; 1989 /* Used for DP and ICL+ TypeC/DP and TypeC/HDMI ports. */ 1990 enum aux_ch aux_ch; 1991 enum intel_display_power_domain ddi_io_power_domain; 1992 struct ref_tracker *ddi_io_wakeref; 1993 struct ref_tracker *aux_wakeref; 1994 1995 struct intel_tc_port *tc; 1996 1997 struct { 1998 /* protects num_streams reference count, port_data and auth_status */ 1999 struct mutex mutex; 2000 /* the number of pipes using HDCP signalling out of this port */ 2001 unsigned int num_streams; 2002 /* port HDCP auth status */ 2003 bool auth_status; 2004 /* HDCP port data need to pass to security f/w */ 2005 struct hdcp_port_data port_data; 2006 /* Whether the MST topology supports HDCP Type 1 Content */ 2007 bool mst_type1_capable; 2008 } hdcp; 2009 2010 void (*write_infoframe)(struct intel_encoder *encoder, 2011 const struct intel_crtc_state *crtc_state, 2012 unsigned int type, 2013 const void *frame, ssize_t len); 2014 void (*read_infoframe)(struct intel_encoder *encoder, 2015 const struct intel_crtc_state *crtc_state, 2016 unsigned int type, 2017 void *frame, ssize_t len); 2018 void (*set_infoframes)(struct intel_encoder *encoder, 2019 bool enable, 2020 const struct intel_crtc_state *crtc_state, 2021 const struct drm_connector_state *conn_state); 2022 u32 (*infoframes_enabled)(struct intel_encoder *encoder, 2023 const struct intel_crtc_state *pipe_config); 2024 bool (*connected)(struct intel_encoder *encoder); 2025 2026 void (*lock)(struct intel_digital_port *dig_port); 2027 void (*unlock)(struct intel_digital_port *dig_port); 2028 }; 2029 2030 struct intel_dp_mst_encoder { 2031 struct intel_encoder base; 2032 enum pipe pipe; 2033 struct intel_digital_port *primary; 2034 struct intel_connector *connector; 2035 }; 2036 2037 struct intel_colorop { 2038 struct drm_colorop base; 2039 enum intel_color_block id; 2040 }; 2041 2042 static inline struct intel_encoder * 2043 intel_attached_encoder(struct intel_connector *connector) 2044 { 2045 return connector->encoder; 2046 } 2047 2048 static inline bool intel_encoder_is_dig_port(struct intel_encoder *encoder) 2049 { 2050 switch (encoder->type) { 2051 case INTEL_OUTPUT_DDI: 2052 case INTEL_OUTPUT_DP: 2053 case INTEL_OUTPUT_EDP: 2054 case INTEL_OUTPUT_HDMI: 2055 return true; 2056 default: 2057 return false; 2058 } 2059 } 2060 2061 static inline bool intel_encoder_is_mst(struct intel_encoder *encoder) 2062 { 2063 return encoder->type == INTEL_OUTPUT_DP_MST; 2064 } 2065 2066 static inline struct intel_dp_mst_encoder * 2067 enc_to_mst(struct intel_encoder *encoder) 2068 { 2069 return container_of(&encoder->base, struct intel_dp_mst_encoder, 2070 base.base); 2071 } 2072 2073 static inline struct intel_digital_port * 2074 enc_to_dig_port(struct intel_encoder *encoder) 2075 { 2076 struct intel_encoder *intel_encoder = encoder; 2077 2078 if (intel_encoder_is_dig_port(intel_encoder)) 2079 return container_of(&encoder->base, struct intel_digital_port, 2080 base.base); 2081 else if (intel_encoder_is_mst(intel_encoder)) 2082 return enc_to_mst(encoder)->primary; 2083 else 2084 return NULL; 2085 } 2086 2087 static inline struct intel_digital_port * 2088 intel_attached_dig_port(struct intel_connector *connector) 2089 { 2090 return enc_to_dig_port(intel_attached_encoder(connector)); 2091 } 2092 2093 static inline struct intel_hdmi * 2094 enc_to_intel_hdmi(struct intel_encoder *encoder) 2095 { 2096 return &enc_to_dig_port(encoder)->hdmi; 2097 } 2098 2099 static inline struct intel_hdmi * 2100 intel_attached_hdmi(struct intel_connector *connector) 2101 { 2102 return enc_to_intel_hdmi(intel_attached_encoder(connector)); 2103 } 2104 2105 static inline struct intel_dp *enc_to_intel_dp(struct intel_encoder *encoder) 2106 { 2107 return &enc_to_dig_port(encoder)->dp; 2108 } 2109 2110 static inline struct intel_dp *intel_attached_dp(struct intel_connector *connector) 2111 { 2112 if (connector->mst.dp) 2113 return connector->mst.dp; 2114 else 2115 return enc_to_intel_dp(intel_attached_encoder(connector)); 2116 } 2117 2118 static inline bool intel_encoder_is_dp(struct intel_encoder *encoder) 2119 { 2120 switch (encoder->type) { 2121 case INTEL_OUTPUT_DP: 2122 case INTEL_OUTPUT_EDP: 2123 return true; 2124 case INTEL_OUTPUT_DDI: 2125 /* Skip pure HDMI/DVI DDI encoders */ 2126 return intel_reg_valid(enc_to_intel_dp(encoder)->output_reg); 2127 default: 2128 return false; 2129 } 2130 } 2131 2132 static inline bool intel_encoder_is_hdmi(struct intel_encoder *encoder) 2133 { 2134 switch (encoder->type) { 2135 case INTEL_OUTPUT_HDMI: 2136 return true; 2137 case INTEL_OUTPUT_DDI: 2138 /* See if the HDMI encoder is valid. */ 2139 return intel_reg_valid(enc_to_intel_hdmi(encoder)->hdmi_reg); 2140 default: 2141 return false; 2142 } 2143 } 2144 2145 static inline struct intel_digital_port * 2146 dp_to_dig_port(struct intel_dp *intel_dp) 2147 { 2148 return container_of(intel_dp, struct intel_digital_port, dp); 2149 } 2150 2151 static inline struct intel_digital_port * 2152 hdmi_to_dig_port(struct intel_hdmi *intel_hdmi) 2153 { 2154 return container_of(intel_hdmi, struct intel_digital_port, hdmi); 2155 } 2156 2157 static inline struct intel_plane_state * 2158 intel_atomic_get_plane_state(struct intel_atomic_state *state, 2159 struct intel_plane *plane) 2160 { 2161 struct drm_plane_state *ret = 2162 drm_atomic_get_plane_state(&state->base, &plane->base); 2163 2164 if (IS_ERR(ret)) 2165 return ERR_CAST(ret); 2166 2167 return to_intel_plane_state(ret); 2168 } 2169 2170 static inline struct intel_plane_state * 2171 intel_atomic_get_old_plane_state(struct intel_atomic_state *state, 2172 struct intel_plane *plane) 2173 { 2174 return to_intel_plane_state(drm_atomic_get_old_plane_state(&state->base, 2175 &plane->base)); 2176 } 2177 2178 static inline struct intel_plane_state * 2179 intel_atomic_get_new_plane_state(struct intel_atomic_state *state, 2180 struct intel_plane *plane) 2181 { 2182 return to_intel_plane_state(drm_atomic_get_new_plane_state(&state->base, 2183 &plane->base)); 2184 } 2185 2186 static inline struct intel_crtc_state * 2187 intel_atomic_get_old_crtc_state(struct intel_atomic_state *state, 2188 struct intel_crtc *crtc) 2189 { 2190 return to_intel_crtc_state(drm_atomic_get_old_crtc_state(&state->base, 2191 &crtc->base)); 2192 } 2193 2194 static inline struct intel_crtc_state * 2195 intel_atomic_get_new_crtc_state(struct intel_atomic_state *state, 2196 struct intel_crtc *crtc) 2197 { 2198 return to_intel_crtc_state(drm_atomic_get_new_crtc_state(&state->base, 2199 &crtc->base)); 2200 } 2201 2202 static inline struct intel_digital_connector_state * 2203 intel_atomic_get_new_connector_state(struct intel_atomic_state *state, 2204 struct intel_connector *connector) 2205 { 2206 return to_intel_digital_connector_state( 2207 drm_atomic_get_new_connector_state(&state->base, 2208 &connector->base)); 2209 } 2210 2211 static inline struct intel_digital_connector_state * 2212 intel_atomic_get_old_connector_state(struct intel_atomic_state *state, 2213 struct intel_connector *connector) 2214 { 2215 return to_intel_digital_connector_state( 2216 drm_atomic_get_old_connector_state(&state->base, 2217 &connector->base)); 2218 } 2219 2220 /* intel_display.c */ 2221 static inline bool 2222 intel_crtc_has_type(const struct intel_crtc_state *crtc_state, 2223 enum intel_output_type type) 2224 { 2225 return crtc_state->output_types & BIT(type); 2226 } 2227 2228 static inline bool 2229 intel_crtc_has_dp_encoder(const struct intel_crtc_state *crtc_state) 2230 { 2231 return crtc_state->output_types & 2232 (BIT(INTEL_OUTPUT_DP) | 2233 BIT(INTEL_OUTPUT_DP_MST) | 2234 BIT(INTEL_OUTPUT_EDP)); 2235 } 2236 2237 static inline bool 2238 intel_crtc_needs_modeset(const struct intel_crtc_state *crtc_state) 2239 { 2240 return drm_atomic_crtc_needs_modeset(&crtc_state->uapi); 2241 } 2242 2243 static inline bool 2244 intel_crtc_needs_fastset(const struct intel_crtc_state *crtc_state) 2245 { 2246 return crtc_state->update_pipe; 2247 } 2248 2249 static inline bool 2250 intel_crtc_needs_color_update(const struct intel_crtc_state *crtc_state) 2251 { 2252 return crtc_state->uapi.color_mgmt_changed || 2253 intel_crtc_needs_fastset(crtc_state) || 2254 intel_crtc_needs_modeset(crtc_state); 2255 } 2256 2257 static inline struct intel_frontbuffer * 2258 to_intel_frontbuffer(struct drm_framebuffer *fb) 2259 { 2260 return fb ? to_intel_framebuffer(fb)->frontbuffer : NULL; 2261 } 2262 2263 /* 2264 * Conversion functions/macros from various pointer types to struct 2265 * intel_display pointer. 2266 */ 2267 #define __drm_device_to_intel_display(p) \ 2268 ((p) ? __drm_to_display(p) : NULL) 2269 #define __device_to_intel_display(p) \ 2270 __drm_device_to_intel_display(dev_get_drvdata(p)) 2271 #define __pci_dev_to_intel_display(p) \ 2272 __drm_device_to_intel_display(pci_get_drvdata(p)) 2273 #define __intel_atomic_state_to_intel_display(p) \ 2274 __drm_device_to_intel_display((p)->base.dev) 2275 #define __intel_connector_to_intel_display(p) \ 2276 __drm_device_to_intel_display((p)->base.dev) 2277 #define __intel_crtc_to_intel_display(p) \ 2278 __drm_device_to_intel_display((p)->base.dev) 2279 #define __intel_crtc_state_to_intel_display(p) \ 2280 __drm_device_to_intel_display((p)->uapi.crtc->dev) 2281 #define __intel_digital_port_to_intel_display(p) \ 2282 __drm_device_to_intel_display((p)->base.base.dev) 2283 #define __intel_dp_to_intel_display(p) \ 2284 __drm_device_to_intel_display(dp_to_dig_port(p)->base.base.dev) 2285 #define __intel_encoder_to_intel_display(p) \ 2286 __drm_device_to_intel_display((p)->base.dev) 2287 #define __intel_hdmi_to_intel_display(p) \ 2288 __drm_device_to_intel_display(hdmi_to_dig_port(p)->base.base.dev) 2289 #define __intel_plane_to_intel_display(p) \ 2290 __drm_device_to_intel_display((p)->base.dev) 2291 #define __intel_plane_state_to_intel_display(p) \ 2292 __drm_device_to_intel_display((p)->uapi.plane->dev) 2293 2294 /* Helper for generic association. Map types to conversion functions/macros. */ 2295 #define __assoc(type, p) \ 2296 struct type: __##type##_to_intel_display((struct type *)(p)) 2297 2298 /* Convert various pointer types to struct intel_display pointer. */ 2299 #define to_intel_display(p) \ 2300 _Generic(*p, \ 2301 __assoc(drm_device, p), \ 2302 __assoc(device, p), \ 2303 __assoc(pci_dev, p), \ 2304 __assoc(intel_atomic_state, p), \ 2305 __assoc(intel_connector, p), \ 2306 __assoc(intel_crtc, p), \ 2307 __assoc(intel_crtc_state, p), \ 2308 __assoc(intel_digital_port, p), \ 2309 __assoc(intel_dp, p), \ 2310 __assoc(intel_encoder, p), \ 2311 __assoc(intel_hdmi, p), \ 2312 __assoc(intel_plane, p), \ 2313 __assoc(intel_plane_state, p)) 2314 2315 #endif /* __INTEL_DISPLAY_TYPES_H__ */ 2316