]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - drivers/gpu/drm/display/drm_dp_helper.c
Merge tag 'drm-intel-next-2024-02-27-1' of git://anongit.freedesktop.org/drm/drm...
[thirdparty/linux.git] / drivers / gpu / drm / display / drm_dp_helper.c
index d72b6f9a352c10c13d6a66509d29372962dc4cef..d046dfa79504f9c5368aaf2a0bd87c2e1d84f4b7 100644 (file)
@@ -2102,7 +2102,6 @@ int drm_dp_aux_register(struct drm_dp_aux *aux)
        if (!aux->ddc.algo)
                drm_dp_aux_init(aux);
 
-       aux->ddc.class = I2C_CLASS_DDC;
        aux->ddc.owner = THIS_MODULE;
        aux->ddc.dev.parent = aux->dev;
 
@@ -2898,22 +2897,19 @@ static const char *dp_content_type_get_name(enum dp_content_type content_type)
        }
 }
 
-void drm_dp_vsc_sdp_log(const char *level, struct device *dev,
-                       const struct drm_dp_vsc_sdp *vsc)
+void drm_dp_vsc_sdp_log(struct drm_printer *p, const struct drm_dp_vsc_sdp *vsc)
 {
-#define DP_SDP_LOG(fmt, ...) dev_printk(level, dev, fmt, ##__VA_ARGS__)
-       DP_SDP_LOG("DP SDP: %s, revision %u, length %u\n", "VSC",
+       drm_printf(p, "DP SDP: VSC, revision %u, length %u\n",
                   vsc->revision, vsc->length);
-       DP_SDP_LOG("    pixelformat: %s\n",
+       drm_printf(p, "    pixelformat: %s\n",
                   dp_pixelformat_get_name(vsc->pixelformat));
-       DP_SDP_LOG("    colorimetry: %s\n",
+       drm_printf(p, "    colorimetry: %s\n",
                   dp_colorimetry_get_name(vsc->pixelformat, vsc->colorimetry));
-       DP_SDP_LOG("    bpc: %u\n", vsc->bpc);
-       DP_SDP_LOG("    dynamic range: %s\n",
+       drm_printf(p, "    bpc: %u\n", vsc->bpc);
+       drm_printf(p, "    dynamic range: %s\n",
                   dp_dynamic_range_get_name(vsc->dynamic_range));
-       DP_SDP_LOG("    content type: %s\n",
+       drm_printf(p, "    content type: %s\n",
                   dp_content_type_get_name(vsc->content_type));
-#undef DP_SDP_LOG
 }
 EXPORT_SYMBOL(drm_dp_vsc_sdp_log);
 
@@ -4059,3 +4055,33 @@ int drm_dp_bw_channel_coding_efficiency(bool is_uhbr)
                return 800000;
 }
 EXPORT_SYMBOL(drm_dp_bw_channel_coding_efficiency);
+
+/**
+ * drm_dp_max_dprx_data_rate - Get the max data bandwidth of a DPRX sink
+ * @max_link_rate: max DPRX link rate in 10kbps units
+ * @max_lanes: max DPRX lane count
+ *
+ * Given a link rate and lanes, get the data bandwidth.
+ *
+ * Data bandwidth is the actual payload rate, which depends on the data
+ * bandwidth efficiency and the link rate.
+ *
+ * Note that protocol layers above the DPRX link level considered here can
+ * further limit the maximum data rate. Such layers are the MST topology (with
+ * limits on the link between the source and first branch device as well as on
+ * the whole MST path until the DPRX link) and (Thunderbolt) DP tunnels -
+ * which in turn can encapsulate an MST link with its own limit - with each
+ * SST or MST encapsulated tunnel sharing the BW of a tunnel group.
+ *
+ * Returns the maximum data rate in kBps units.
+ */
+int drm_dp_max_dprx_data_rate(int max_link_rate, int max_lanes)
+{
+       int ch_coding_efficiency =
+               drm_dp_bw_channel_coding_efficiency(drm_dp_is_uhbr_rate(max_link_rate));
+
+       return DIV_ROUND_DOWN_ULL(mul_u32_u32(max_link_rate * 10 * max_lanes,
+                                             ch_coding_efficiency),
+                                 1000000 * 8);
+}
+EXPORT_SYMBOL(drm_dp_max_dprx_data_rate);