drm/dp: Factor out helper to distinguish between branch and sink devices
authorImre Deak <imre.deak@intel.com>
Mon, 24 Oct 2016 16:33:24 +0000 (19:33 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 25 Oct 2016 06:53:44 +0000 (08:53 +0200)
This check is open-coded in a few places, so it makes sense to simplify
things by having a helper for it similar to the rest of DPCD feature
helpers.

v2: (Jani)
- Move the helper to drm_dp_helper.h.
- Split out this change to a separate patch.

Cc: Jani Nikula <jani.nikula@intel.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Imre Deak <imre.deak@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1477326811-30431-2-git-send-email-imre.deak@intel.com
drivers/gpu/drm/i915/intel_dp.c
include/drm/drm_dp_helper.h

index acd0c51f74d5e2621e62903c1329a44cfec8d648..01bc67194dba6335e16f26639afaec7efc3852d0 100644 (file)
@@ -1452,8 +1452,7 @@ static void intel_dp_print_hw_revision(struct intel_dp *intel_dp)
        if ((drm_debug & DRM_UT_KMS) == 0)
                return;
 
-       if (!(intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] &
-             DP_DWN_STRM_PORT_PRESENT))
+       if (!drm_dp_is_branch(intel_dp->dpcd))
                return;
 
        len = drm_dp_dpcd_read(&intel_dp->aux, DP_BRANCH_HW_REV, &rev, 1);
@@ -1471,8 +1470,7 @@ static void intel_dp_print_sw_revision(struct intel_dp *intel_dp)
        if ((drm_debug & DRM_UT_KMS) == 0)
                return;
 
-       if (!(intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] &
-             DP_DWN_STRM_PORT_PRESENT))
+       if (!drm_dp_is_branch(intel_dp->dpcd))
                return;
 
        len = drm_dp_dpcd_read(&intel_dp->aux, DP_BRANCH_SW_REV, &rev, 2);
@@ -3607,8 +3605,7 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp)
        if (!is_edp(intel_dp) && !intel_dp->sink_count)
                return false;
 
-       if (!(intel_dp->dpcd[DP_DOWNSTREAMPORT_PRESENT] &
-             DP_DWN_STRM_PORT_PRESENT))
+       if (!drm_dp_is_branch(intel_dp->dpcd))
                return true; /* native DP sink */
 
        if (intel_dp->dpcd[DP_DPCD_REV] == 0x10)
@@ -4096,7 +4093,7 @@ intel_dp_detect_dpcd(struct intel_dp *intel_dp)
                return connector_status_connected;
 
        /* if there's no downstream port, we're done */
-       if (!(dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT))
+       if (!drm_dp_is_branch(dpcd))
                return connector_status_connected;
 
        /* If we're HPD-aware, SINK_COUNT changes dynamically */
index 2a79882cb68e8551d3719a599b482787a018fdbb..55bbeb0ff594581a2448adcf7fb26b7eb883243a 100644 (file)
@@ -690,6 +690,12 @@ drm_dp_tps3_supported(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
                dpcd[DP_MAX_LANE_COUNT] & DP_TPS3_SUPPORTED;
 }
 
+static inline bool
+drm_dp_is_branch(const u8 dpcd[DP_RECEIVER_CAP_SIZE])
+{
+       return dpcd[DP_DOWNSTREAMPORT_PRESENT] & DP_DWN_STRM_PORT_PRESENT;
+}
+
 /*
  * DisplayPort AUX channel
  */