diff options
author | Keith Packard <keithp@keithp.com> | 2011-07-25 22:50:10 -0400 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2011-07-28 18:47:20 -0400 |
commit | 92fd8fd13b7570f6a8ba519c4e8ec98f10a86ce9 (patch) | |
tree | 26a26be50952a5ba7c40d2a770f914f93d597cde | |
parent | 40ee3381dd1010432acc13e907329029096c5bfc (diff) |
drm/i915: Use dp_detect_common in hotplug helper function
This uses the common dpcd reading routine, i915_dp_detect_common,
instead of open-coding a call to intel_dp_aux_native_read. Besides
reducing duplicated code, this also gains the read retries which
may be necessary when a cable is first plugged back in and the link
needs to be retrained.
Signed-off-by: Keith Packard <keithp@keithp.com>
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Reviewed-by: Adam Jackson <ajax@redhat.com>
-rw-r--r-- | drivers/gpu/drm/i915/intel_dp.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index dcc7ae6d4141..45db8106ab12 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c | |||
@@ -1567,6 +1567,20 @@ intel_dp_link_down(struct intel_dp *intel_dp) | |||
1567 | POSTING_READ(intel_dp->output_reg); | 1567 | POSTING_READ(intel_dp->output_reg); |
1568 | } | 1568 | } |
1569 | 1569 | ||
1570 | static enum drm_connector_status | ||
1571 | i915_dp_detect_common(struct intel_dp *intel_dp) | ||
1572 | { | ||
1573 | enum drm_connector_status status = connector_status_disconnected; | ||
1574 | |||
1575 | if (intel_dp_aux_native_read_retry(intel_dp, 0x000, intel_dp->dpcd, | ||
1576 | sizeof (intel_dp->dpcd)) && | ||
1577 | (intel_dp->dpcd[DP_DPCD_REV] != 0)) { | ||
1578 | status = connector_status_connected; | ||
1579 | } | ||
1580 | |||
1581 | return status; | ||
1582 | } | ||
1583 | |||
1570 | /* | 1584 | /* |
1571 | * According to DP spec | 1585 | * According to DP spec |
1572 | * 5.1.2: | 1586 | * 5.1.2: |
@@ -1579,45 +1593,30 @@ intel_dp_link_down(struct intel_dp *intel_dp) | |||
1579 | static void | 1593 | static void |
1580 | intel_dp_check_link_status(struct intel_dp *intel_dp) | 1594 | intel_dp_check_link_status(struct intel_dp *intel_dp) |
1581 | { | 1595 | { |
1582 | int ret; | ||
1583 | |||
1584 | if (!intel_dp->base.base.crtc) | 1596 | if (!intel_dp->base.base.crtc) |
1585 | return; | 1597 | return; |
1586 | 1598 | ||
1599 | /* Try to read receiver status if the link appears to be up */ | ||
1587 | if (!intel_dp_get_link_status(intel_dp)) { | 1600 | if (!intel_dp_get_link_status(intel_dp)) { |
1588 | intel_dp_link_down(intel_dp); | 1601 | intel_dp_link_down(intel_dp); |
1589 | return; | 1602 | return; |
1590 | } | 1603 | } |
1591 | 1604 | ||
1592 | /* Try to read receiver status if the link appears to be up */ | 1605 | /* Now read the DPCD to see if it's actually running */ |
1593 | ret = intel_dp_aux_native_read(intel_dp, | 1606 | if (i915_dp_detect_common(intel_dp) != connector_status_connected) { |
1594 | 0x000, intel_dp->dpcd, | ||
1595 | sizeof (intel_dp->dpcd)); | ||
1596 | if (ret != sizeof(intel_dp->dpcd)) { | ||
1597 | intel_dp_link_down(intel_dp); | 1607 | intel_dp_link_down(intel_dp); |
1598 | return; | 1608 | return; |
1599 | } | 1609 | } |
1600 | 1610 | ||
1601 | if (!intel_channel_eq_ok(intel_dp)) { | 1611 | if (!intel_channel_eq_ok(intel_dp)) { |
1612 | DRM_DEBUG_KMS("%s: channel EQ not ok, retraining\n", | ||
1613 | drm_get_encoder_name(&intel_dp->base.base)); | ||
1602 | intel_dp_start_link_train(intel_dp); | 1614 | intel_dp_start_link_train(intel_dp); |
1603 | intel_dp_complete_link_train(intel_dp); | 1615 | intel_dp_complete_link_train(intel_dp); |
1604 | } | 1616 | } |
1605 | } | 1617 | } |
1606 | 1618 | ||
1607 | static enum drm_connector_status | 1619 | static enum drm_connector_status |
1608 | i915_dp_detect_common(struct intel_dp *intel_dp) | ||
1609 | { | ||
1610 | enum drm_connector_status status = connector_status_disconnected; | ||
1611 | |||
1612 | if (intel_dp_aux_native_read_retry(intel_dp, 0x000, intel_dp->dpcd, | ||
1613 | sizeof (intel_dp->dpcd)) && | ||
1614 | (intel_dp->dpcd[DP_DPCD_REV] != 0)) | ||
1615 | status = connector_status_connected; | ||
1616 | |||
1617 | return status; | ||
1618 | } | ||
1619 | |||
1620 | static enum drm_connector_status | ||
1621 | ironlake_dp_detect(struct intel_dp *intel_dp) | 1620 | ironlake_dp_detect(struct intel_dp *intel_dp) |
1622 | { | 1621 | { |
1623 | enum drm_connector_status status; | 1622 | enum drm_connector_status status; |