Commit 4e936b65 authored by Imre Deak's avatar Imre Deak

drm/i915/tc: Factor out helpers converting HPD mask to TC mode

Factor out helpers used later in the patchset to convert an HPD
status mask to TC mode or target TC mode.

No functional changes.
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/20230316131724.359612-7-imre.deak@intel.com
parent b25f551a
......@@ -591,11 +591,28 @@ static void tc_phy_wait_for_ready(struct intel_digital_port *dig_port)
dig_port->tc_port_name);
}
static enum tc_port_mode
hpd_mask_to_tc_mode(u32 live_status_mask)
{
if (live_status_mask)
return fls(live_status_mask) - 1;
return TC_PORT_DISCONNECTED;
}
static enum tc_port_mode
tc_phy_hpd_live_mode(struct intel_digital_port *dig_port)
{
u32 live_status_mask = tc_port_live_status_mask(dig_port);
return hpd_mask_to_tc_mode(live_status_mask);
}
static enum tc_port_mode
intel_tc_port_get_current_mode(struct intel_digital_port *dig_port)
{
struct drm_i915_private *i915 = to_i915(dig_port->base.base.dev);
u32 live_status_mask = tc_port_live_status_mask(dig_port);
enum tc_port_mode live_mode = tc_phy_hpd_live_mode(dig_port);
enum tc_port_mode mode;
/*
......@@ -611,27 +628,32 @@ intel_tc_port_get_current_mode(struct intel_digital_port *dig_port)
return TC_PORT_TBT_ALT;
mode = dig_port->tc_legacy_port ? TC_PORT_LEGACY : TC_PORT_DP_ALT;
if (live_status_mask) {
enum tc_port_mode live_mode = fls(live_status_mask) - 1;
if (!drm_WARN_ON(&i915->drm, live_mode == TC_PORT_TBT_ALT))
if (live_mode != TC_PORT_DISCONNECTED &&
!drm_WARN_ON(&i915->drm, live_mode == TC_PORT_TBT_ALT))
mode = live_mode;
}
return mode;
}
static enum tc_port_mode
intel_tc_port_get_target_mode(struct intel_digital_port *dig_port)
hpd_mask_to_target_mode(u32 live_status_mask)
{
u32 live_status_mask = tc_port_live_status_mask(dig_port);
enum tc_port_mode mode = hpd_mask_to_tc_mode(live_status_mask);
if (live_status_mask)
return fls(live_status_mask) - 1;
if (mode != TC_PORT_DISCONNECTED)
return mode;
return TC_PORT_TBT_ALT;
}
static enum tc_port_mode
intel_tc_port_get_target_mode(struct intel_digital_port *dig_port)
{
u32 live_status_mask = tc_port_live_status_mask(dig_port);
return hpd_mask_to_target_mode(live_status_mask);
}
static void intel_tc_port_reset_mode(struct intel_digital_port *dig_port,
int required_lanes, bool force_disconnect)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment