]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/dp: add drm_dp_phy_name() for getting DP PHY name
authorJani Nikula <jani.nikula@intel.com>
Mon, 15 Aug 2022 08:58:34 +0000 (11:58 +0300)
committerJani Nikula <jani.nikula@intel.com>
Tue, 30 Aug 2022 08:02:42 +0000 (11:02 +0300)
Add a helper for getting the DP PHY name. In the interest of caller
simplicity and to avoid allocations and passing in of buffers, duplicate
the const strings to return. It's a minor penalty to pay for simplicity
in all the call sites.

v2: Rebase, add kernel-doc, ensure non-NULL always

Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/b08dc12a7e621a48ec35546d6cd1ed4b1434810d.1660553850.git.jani.nikula@intel.com
drivers/gpu/drm/display/drm_dp_helper.c
include/drm/display/drm_dp_helper.h

index 32b295003f49ae5660380f54f494c4313d84ebf7..92990a3d577ad4ad8ebfe3d4948138255432e0ee 100644 (file)
@@ -390,6 +390,38 @@ void drm_dp_link_train_channel_eq_delay(const struct drm_dp_aux *aux,
 }
 EXPORT_SYMBOL(drm_dp_link_train_channel_eq_delay);
 
+/**
+ * drm_dp_phy_name() - Get the name of the given DP PHY
+ * @dp_phy: The DP PHY identifier
+ *
+ * Given the @dp_phy, get a user friendly name of the DP PHY, either "DPRX" or
+ * "LTTPR <N>", or "<INVALID DP PHY>" on errors. The returned string is always
+ * non-NULL and valid.
+ *
+ * Returns: Name of the DP PHY.
+ */
+const char *drm_dp_phy_name(enum drm_dp_phy dp_phy)
+{
+       static const char * const phy_names[] = {
+               [DP_PHY_DPRX] = "DPRX",
+               [DP_PHY_LTTPR1] = "LTTPR 1",
+               [DP_PHY_LTTPR2] = "LTTPR 2",
+               [DP_PHY_LTTPR3] = "LTTPR 3",
+               [DP_PHY_LTTPR4] = "LTTPR 4",
+               [DP_PHY_LTTPR5] = "LTTPR 5",
+               [DP_PHY_LTTPR6] = "LTTPR 6",
+               [DP_PHY_LTTPR7] = "LTTPR 7",
+               [DP_PHY_LTTPR8] = "LTTPR 8",
+       };
+
+       if (dp_phy < 0 || dp_phy >= ARRAY_SIZE(phy_names) ||
+           WARN_ON(!phy_names[dp_phy]))
+               return "<INVALID DP PHY>";
+
+       return phy_names[dp_phy];
+}
+EXPORT_SYMBOL(drm_dp_phy_name);
+
 void drm_dp_lttpr_link_train_clock_recovery_delay(void)
 {
        usleep_range(100, 200);
index db0fe9f8a6128b899523b8845c5c2a40967496c7..ab55453f2d2cd35442664070b437a748db528a1d 100644 (file)
@@ -69,6 +69,8 @@ bool drm_dp_128b132b_link_training_failed(const u8 link_status[DP_LINK_STATUS_SI
 u8 drm_dp_link_rate_to_bw_code(int link_rate);
 int drm_dp_bw_code_to_link_rate(u8 link_bw);
 
+const char *drm_dp_phy_name(enum drm_dp_phy dp_phy);
+
 /**
  * struct drm_dp_vsc_sdp - drm DP VSC SDP
  *