Move the drm_dprx_supports_128b132b() helper from the i915 driver into
the generic DRM helpers. It reports whether the DPRX supports 128b/132b
channel coding, either from the DP tunnel capabilities when bandwidth
allocation is enabled or from the DPCD receiver capabilities.

Signed-off-by: Kory Maincent <[email protected]>
---
 drivers/gpu/drm/display/drm_dp_helper.c | 10 ++++++++++
 drivers/gpu/drm/i915/display/intel_dp.c | 10 +---------
 include/drm/display/drm_dp_helper.h     |  2 ++
 3 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/display/drm_dp_helper.c 
b/drivers/gpu/drm/display/drm_dp_helper.c
index 86260ffd57cdc..c92d89ecf96e4 100644
--- a/drivers/gpu/drm/display/drm_dp_helper.c
+++ b/drivers/gpu/drm/display/drm_dp_helper.c
@@ -4939,3 +4939,13 @@ u8 drm_dprx_128b132b_link_rates(const struct 
drm_dp_tunnel *tunnel,
        return drm_dp_tunnel_128b132b_dprx_rates(tunnel);
 }
 EXPORT_SYMBOL_GPL(drm_dprx_128b132b_link_rates);
+
+bool drm_dprx_supports_128b132b(const struct drm_dp_tunnel *tunnel,
+                               const u8 dpcd[DP_RECEIVER_CAP_SIZE])
+{
+       if (tunnel && drm_dp_tunnel_bw_alloc_is_enabled(tunnel))
+               return drm_dp_tunnel_128b132b_supported(tunnel);
+       else
+               return drm_dp_128b132b_supported(dpcd);
+}
+EXPORT_SYMBOL_GPL(drm_dprx_supports_128b132b);
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c 
b/drivers/gpu/drm/i915/display/intel_dp.c
index e124e7dced178..2ba89fee097d6 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -173,14 +173,6 @@ static void intel_dp_set_default_sink_rates(struct 
intel_dp *intel_dp)
        intel_dp->num_sink_rates = 1;
 }
 
-static bool dprx_supports_128b132b(struct intel_dp *intel_dp)
-{
-       if (intel_dp_tunnel_bw_alloc_is_enabled(intel_dp))
-               return drm_dp_tunnel_128b132b_supported(intel_dp->tunnel);
-       else
-               return drm_dp_128b132b_supported(intel_dp->dpcd);
-}
-
 /* update sink rates from dpcd */
 static void intel_dp_set_dpcd_sink_rates(struct intel_dp *intel_dp)
 {
@@ -236,7 +228,7 @@ static void intel_dp_set_dpcd_sink_rates(struct intel_dp 
*intel_dp)
         * Sink rates for 128b/132b. If set, sink should support all 8b/10b
         * rates and 10 Gbps.
         */
-       if (dprx_supports_128b132b(intel_dp)) {
+       if (drm_dprx_supports_128b132b(intel_dp->tunnel, intel_dp->dpcd)) {
                BUILD_BUG_ON(ARRAY_SIZE(intel_dp->sink_rates) < 
ARRAY_SIZE(dp_rates) + 3);
 
                uhbr_rates = drm_dprx_128b132b_link_rates(intel_dp->tunnel, 
uhbr_rates);
diff --git a/include/drm/display/drm_dp_helper.h 
b/include/drm/display/drm_dp_helper.h
index 7985bb269fdf2..b67bb06f6e07e 100644
--- a/include/drm/display/drm_dp_helper.h
+++ b/include/drm/display/drm_dp_helper.h
@@ -706,6 +706,8 @@ int drm_dprx_max_rate(const struct drm_dp_tunnel *tunnel,
                      const u8 dpcd[DP_RECEIVER_CAP_SIZE]);
 u8 drm_dprx_128b132b_link_rates(const struct drm_dp_tunnel *tunnel,
                                u8 uhbr_rates);
+bool drm_dprx_supports_128b132b(const struct drm_dp_tunnel *tunnel,
+                               const u8 dpcd[DP_RECEIVER_CAP_SIZE]);
 
 int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,
                                 u8 status[DP_LINK_STATUS_SIZE]);

-- 
2.43.0

Reply via email to