[PATCH i-g-t v7 46/48] lib/unigraf: Add helpers to set maximum link rate

Louis Chauvet
2026-02-23T12:09:41Z

As link rate can vary on a display port link, add a way
to change advertised link rate from unigraf.

Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>
Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
---
lib/unigraf/unigraf.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++
lib/unigraf/unigraf.h | 14 ++++++++++++++
2 files changed, 67 insertions(+)

diff --git a/lib/unigraf/unigraf.c b/lib/unigraf/unigraf.c
index 038188182bc5..a18a90caad56 100644
--- a/lib/unigraf/unigraf.c
+++ b/lib/unigraf/unigraf.c
@@ -544,6 +544,7 @@ void unigraf_reset(void)
unigraf_load_default_edid();
unigraf_hpd_assert();
unigraf_set_max_lane_count(4);
+ unigraf_set_max_link_rate(UNIGRAF_RATE_8_10_GHZ);
}

/**
@@ -832,3 +833,55 @@ int unigraf_get_max_lane_count(void)
&max_lanes, sizeof(max_lanes)));
return max_lanes;
}
+
+/**
+ * unigraf_set_max_link_rate() - Set the maximum link rate advertised to the DUT
+ * @rate: The maximum link rate to configure on the device. Actual value is
+ * @rate * 270000 kHz. Common values can be found in enum unigraf_rate
+ *
+ * This function sets the maximum link rate that the device will advertise on the DP link.
+ * The actual link rate used may be less than the requested value if the DUT does not
+ * support/use it.
+ */
+void unigraf_set_max_link_rate(int bandwidth)
+{
+ unigraf_write_u32(TSI_DPRX_MAX_LINK_RATE, bandwidth);
+}
+
+/**
+ * unigraf_get_max_link_rate() - Get the maximum link rate supported by the device
+ *
+ * Returns: The maximum link rate supported by the device. The value returned must be multiplied by
+ * 270000 to get the value in kHz.
+ */
+int unigraf_get_max_link_rate(void)
+{
+ return unigraf_read_u32(TSI_DPRX_MAX_LINK_RATE);
+}
+
+/**
+ * unigraf_rate_to_kbs - Convert a rate value to kilobits per second
+ * @rate: The rate value to convert
+ *
+ * This function converts a rate value to kilobits per second (kbps).
+ *
+ * Returns: The converted rate in kilobits per second
+ */
+int unigraf_rate_to_kbs(enum unigraf_rate rate)
+{
+ switch (rate) {
+ case UNIGRAF_RATE_1_62_GHZ:
+ return 1620000;
+ case UNIGRAF_RATE_2_7_GHZ:
+ return 2700000;
+ case UNIGRAF_RATE_5_4_GHZ:
+ return 5400000;
+ case UNIGRAF_RATE_6_75_GHZ:
+ return 6750000;
+ case UNIGRAF_RATE_8_10_GHZ:
+ return 8100000;
+ default:
+ igt_assert_f(0, "Unknown rate %d\n", rate);
+ return 0;
+ }
+}
diff --git a/lib/unigraf/unigraf.h b/lib/unigraf/unigraf.h
index e926855dd059..3cba15732daa 100644
--- a/lib/unigraf/unigraf.h
+++ b/lib/unigraf/unigraf.h
@@ -84,4 +84,18 @@ int unigraf_get_max_lane_count(void);

void unigraf_set_max_lane_count(uint32_t count);

+enum unigraf_rate {
+ UNIGRAF_RATE_1_62_GHZ = 6,
+ UNIGRAF_RATE_2_7_GHZ = 10,
+ UNIGRAF_RATE_5_4_GHZ = 20,
+ UNIGRAF_RATE_6_75_GHZ = 25,
+ UNIGRAF_RATE_8_10_GHZ = 30,
+};
+
+void unigraf_set_max_link_rate(int rate);
+
+int unigraf_get_max_link_rate(void);
+
+int unigraf_rate_to_kbs(enum unigraf_rate rate);
+
#endif // UNIGRAF_H

--
2.52.0