• Imre Deak's avatar
    drm/i915: Keep the TypeC port mode fixed when the port is active · 24a7bfe0
    Imre Deak authored
    The TypeC port mode needs to stay fixed whenever the port is active. Do
    that by introducing a tc_link_refcount to account for active ports,
    avoiding changing the port mode if a reference is held.
    
    During the modeset commit phase we also have to reset the port mode and
    update the active PLL reflecting the new port mode. We can do this only
    once the port and its old PLL has been already disabled. Add the new
    encoder update_prepare/complete hooks that are called around the whole
    enabling sequence. The TypeC specific hooks of these will reset the port
    mode, update the active PLL if the port will be active and ensure that
    the port mode will stay fixed for the duration of the whole enabling
    sequence by holding a tc_link_refcount.
    
    During the port enabling, the pre_pll_enable/post_pll_disable hooks will
    take/release a tc_link_refcount to ensure the port mode stays fixed
    while the port is active.
    
    Changing the port mode should also be avoided during connector detection
    and AUX transfers if the port is active, we'll do that by checking the
    port's tc_link_refcount.
    
    When resetting the port mode we also have to take into account the
    maximum lanes provided by the FIA. It's guaranteed to be 4 in TBT-alt
    and legacy modes, but there may be less lanes available in DP-alt mode,
    in which case we have to fall back to TBT-alt mode.
    
    While at it also update icl_tc_phy_connect()'s code comment, reflecting
    the current way of switching the port mode.
    
    v2:
    - Add the update_prepare/complete hooks to the encoder instead of the
      connector. (Ville)
    - Simplify intel_connector_needs_modeset() by removing redundant if.
      (Ville)
    v3:
    - Fix sparse warning, marking static functions as such.
    v4:
    - Rebase on drm-tip.
    
    Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
    Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
    Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
    Signed-off-by: default avatarImre Deak <imre.deak@intel.com>
    Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20190628143635.22066-21-imre.deak@intel.com
    24a7bfe0
intel_tc.h 921 Bytes