From: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
To: Helge Deller <deller@gmx.de>,
Thomas Zimmermann <tzimmermann@suse.de>,
Sam Ravnborg <sam@ravnborg.org>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
David Airlie <airlied@gmail.com>,
Simona Vetter <simona@ffwll.ch>
Cc: kernel@collabora.com, linux-fbdev@vger.kernel.org,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2 16/25] drm/tests: connector: Add HDMI max_tmds_char_rate init coverage
Date: Wed, 02 Dec 2026 04:20:10 +0200 [thread overview]
Message-ID: <20261202-drm-conn-hdmi-cleanup-v2-16-ba7d32550ea4@collabora.com> (raw)
In-Reply-To: <20261202-drm-conn-hdmi-cleanup-v2-0-ba7d32550ea4@collabora.com>
Add KUnit tests for the new drmm_connector_hdmi_init() extension, which
infers the connector's max_tmds_char_rate from the HDMI specification
version advertised by the driver, for every known version. Also
validate a driver-capped max_tmds_char_rate against the version-inferred
limit: override below, accept at, reject above, reject when no version
is advertised. Additionally, make sure an HDMI 2.0 connector capped at
the HDMI 1.3 limit is still reported as scrambling capable.
Since HDMI_VERSION_2_0 requires scrambler callbacks to be provided, add
a dummy_hdmi_funcs_scrambler instance for tests that initialize HDMI 2.0
connectors.
Acked-by: Maxime Ripard <mripard@kernel.org>
Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
drivers/gpu/drm/tests/drm_connector_test.c | 207 +++++++++++++++++++++++++++++
1 file changed, 207 insertions(+)
diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c
index 591557c4a8bb..698706fca5db 100644
--- a/drivers/gpu/drm/tests/drm_connector_test.c
+++ b/drivers/gpu/drm/tests/drm_connector_test.c
@@ -54,6 +54,34 @@ static const struct drm_connector_hdmi_funcs dummy_hdmi_funcs = {
},
};
+static int accept_scrambler_enable(struct drm_connector *connector)
+{
+ return 0;
+}
+
+static int accept_scrambler_disable(struct drm_connector *connector)
+{
+ return 0;
+}
+
+static const struct drm_connector_hdmi_funcs dummy_hdmi_funcs_scrambler = {
+ .vendor = "Vendor",
+ .product = "Product",
+ .supported_hdmi_ver = HDMI_VERSION_2_0,
+ .supported_formats = BIT(DRM_OUTPUT_COLOR_FORMAT_RGB444),
+ .max_bpc = 8,
+ .scrambler_enable = accept_scrambler_enable,
+ .scrambler_disable = accept_scrambler_disable,
+ .avi = {
+ .clear_infoframe = accept_infoframe_clear_infoframe,
+ .write_infoframe = accept_infoframe_write_infoframe,
+ },
+ .hdmi = {
+ .clear_infoframe = accept_infoframe_clear_infoframe,
+ .write_infoframe = accept_infoframe_write_infoframe,
+ },
+};
+
static const struct drm_connector_funcs dummy_funcs = {
.atomic_create_state = drm_atomic_helper_connector_create_state,
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
@@ -1229,6 +1257,178 @@ KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_type_invalid,
drm_connector_hdmi_init_type_invalid_tests,
drm_connector_hdmi_init_type_desc);
+/*
+ * Test that the registration of an HDMI connector without an explicit max TMDS
+ * character rate being provided succeeds, and the connector limit is inferred
+ * from the advertised HDMI specification version.
+ */
+struct drm_connector_hdmi_init_max_tmds_rate_inferred_case {
+ const char *desc;
+ enum hdmi_version ver;
+ unsigned long long expected;
+};
+
+static void drm_test_connector_hdmi_init_max_tmds_rate_inferred(struct kunit *test)
+{
+ struct drm_connector_init_priv *priv = test->priv;
+ const struct drm_connector_hdmi_init_max_tmds_rate_inferred_case *params =
+ test->param_value;
+ int ret;
+
+ priv->hdmi_funcs = params->ver < HDMI_VERSION_2_0 ?
+ dummy_hdmi_funcs : dummy_hdmi_funcs_scrambler;
+ priv->hdmi_funcs.supported_hdmi_ver = params->ver;
+
+ ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
+ &dummy_funcs,
+ &priv->hdmi_funcs,
+ DRM_MODE_CONNECTOR_HDMIA,
+ &priv->ddc);
+ KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, priv->connector.hdmi.max_tmds_char_rate,
+ params->expected);
+}
+
+static const struct drm_connector_hdmi_init_max_tmds_rate_inferred_case
+drm_connector_hdmi_init_max_tmds_rate_inferred_tests[] = {
+ { "unknown", HDMI_VERSION_UNKNOWN, 0 },
+ { "1.0", HDMI_VERSION_1_0, HDMI_1_0_TMDS_CHAR_RATE_MAX_HZ },
+ { "1.1", HDMI_VERSION_1_1, HDMI_1_0_TMDS_CHAR_RATE_MAX_HZ },
+ { "1.2", HDMI_VERSION_1_2, HDMI_1_0_TMDS_CHAR_RATE_MAX_HZ },
+ { "1.3", HDMI_VERSION_1_3, HDMI_1_3_TMDS_CHAR_RATE_MAX_HZ },
+ { "1.4", HDMI_VERSION_1_4, HDMI_1_3_TMDS_CHAR_RATE_MAX_HZ },
+ { "2.0", HDMI_VERSION_2_0, HDMI_2_0_TMDS_CHAR_RATE_MAX_HZ },
+ { "2.1", HDMI_VERSION_2_1, HDMI_2_0_TMDS_CHAR_RATE_MAX_HZ },
+ { "2.2", HDMI_VERSION_2_2, HDMI_2_0_TMDS_CHAR_RATE_MAX_HZ },
+};
+
+static void drm_connector_hdmi_init_max_tmds_rate_inferred_desc(
+ const struct drm_connector_hdmi_init_max_tmds_rate_inferred_case *t,
+ char *desc)
+{
+ strscpy(desc, t->desc, KUNIT_PARAM_DESC_SIZE);
+}
+
+KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_max_tmds_rate_inferred,
+ drm_connector_hdmi_init_max_tmds_rate_inferred_tests,
+ drm_connector_hdmi_init_max_tmds_rate_inferred_desc);
+
+/*
+ * Test that the registration of an HDMI connector providing a max TMDS
+ * character rate strictly below the version-inferred limit succeeds, and
+ * the connector limit is overridden.
+ */
+static void drm_test_connector_hdmi_init_max_tmds_rate_override(struct kunit *test)
+{
+ struct drm_connector_init_priv *priv = test->priv;
+ int ret;
+
+ priv->hdmi_funcs = dummy_hdmi_funcs;
+ priv->hdmi_funcs.supported_hdmi_ver = HDMI_VERSION_1_4;
+ priv->hdmi_funcs.supported_tmds_char_rate = HDMI_1_0_TMDS_CHAR_RATE_MAX_HZ;
+
+ ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
+ &dummy_funcs,
+ &priv->hdmi_funcs,
+ DRM_MODE_CONNECTOR_HDMIA,
+ &priv->ddc);
+ KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, priv->connector.hdmi.max_tmds_char_rate,
+ HDMI_1_0_TMDS_CHAR_RATE_MAX_HZ);
+}
+
+/*
+ * Test that the registration of an HDMI 2.0 connector capping its max TMDS
+ * character rate at the HDMI 1.3 limit succeeds, and the connector limit is
+ * overridden while the scrambling capability is still reported.
+ */
+static void drm_test_connector_hdmi_init_max_tmds_rate_override_hdmi20(struct kunit *test)
+{
+ struct drm_connector_init_priv *priv = test->priv;
+ int ret;
+
+ priv->hdmi_funcs = dummy_hdmi_funcs_scrambler;
+ priv->hdmi_funcs.supported_tmds_char_rate = HDMI_1_3_TMDS_CHAR_RATE_MAX_HZ;
+
+ ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
+ &dummy_funcs,
+ &priv->hdmi_funcs,
+ DRM_MODE_CONNECTOR_HDMIA,
+ &priv->ddc);
+ KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, priv->connector.hdmi.max_tmds_char_rate,
+ HDMI_1_3_TMDS_CHAR_RATE_MAX_HZ);
+ KUNIT_EXPECT_TRUE(test, drm_connector_hdmi_scrambler_supported(&priv->connector));
+}
+
+/*
+ * Test that the registration of an HDMI connector providing a max TMDS
+ * character rate equal to the version-inferred limit succeeds.
+ */
+static void drm_test_connector_hdmi_init_max_tmds_rate_at_limit(struct kunit *test)
+{
+ struct drm_connector_init_priv *priv = test->priv;
+ int ret;
+
+ priv->hdmi_funcs = dummy_hdmi_funcs;
+ priv->hdmi_funcs.supported_hdmi_ver = HDMI_VERSION_1_2;
+ priv->hdmi_funcs.supported_tmds_char_rate = HDMI_1_0_TMDS_CHAR_RATE_MAX_HZ;
+
+ ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
+ &dummy_funcs,
+ &priv->hdmi_funcs,
+ DRM_MODE_CONNECTOR_HDMIA,
+ &priv->ddc);
+ KUNIT_EXPECT_EQ(test, ret, 0);
+ KUNIT_EXPECT_EQ(test, priv->connector.hdmi.max_tmds_char_rate,
+ HDMI_1_0_TMDS_CHAR_RATE_MAX_HZ);
+}
+
+/*
+ * Test that the registration of an HDMI connector providing a max TMDS
+ * character rate that exceeds the limit inferred from the advertised HDMI
+ * specification version fails.
+ */
+static void drm_test_connector_hdmi_init_max_tmds_rate_off_limit(struct kunit *test)
+{
+ struct drm_connector_init_priv *priv = test->priv;
+ int ret;
+
+ priv->hdmi_funcs = dummy_hdmi_funcs;
+ priv->hdmi_funcs.supported_hdmi_ver = HDMI_VERSION_1_2;
+ priv->hdmi_funcs.supported_tmds_char_rate = HDMI_1_3_TMDS_CHAR_RATE_MAX_HZ;
+
+ ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
+ &dummy_funcs,
+ &priv->hdmi_funcs,
+ DRM_MODE_CONNECTOR_HDMIA,
+ &priv->ddc);
+ KUNIT_EXPECT_LT(test, ret, 0);
+}
+
+/*
+ * Test that the registration of an HDMI connector providing a non-zero max
+ * TMDS character rate without an HDMI specification version fails, as the
+ * version-inferred limit defaults to zero and any positive override would
+ * exceed it.
+ */
+static void drm_test_connector_hdmi_init_max_tmds_rate_no_version(struct kunit *test)
+{
+ struct drm_connector_init_priv *priv = test->priv;
+ int ret;
+
+ priv->hdmi_funcs = dummy_hdmi_funcs;
+ priv->hdmi_funcs.supported_hdmi_ver = HDMI_VERSION_UNKNOWN;
+ priv->hdmi_funcs.supported_tmds_char_rate = HDMI_1_0_TMDS_CHAR_RATE_MAX_HZ;
+
+ ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
+ &dummy_funcs,
+ &priv->hdmi_funcs,
+ DRM_MODE_CONNECTOR_HDMIA,
+ &priv->ddc);
+ KUNIT_EXPECT_LT(test, ret, 0);
+}
+
static struct kunit_case drmm_connector_hdmi_init_tests[] = {
KUNIT_CASE(drm_test_connector_hdmi_init_valid),
KUNIT_CASE(drm_test_connector_hdmi_init_bpc_8),
@@ -1254,6 +1454,13 @@ static struct kunit_case drmm_connector_hdmi_init_tests[] = {
drm_connector_hdmi_init_type_valid_gen_params),
KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_type_invalid,
drm_connector_hdmi_init_type_invalid_gen_params),
+ KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_max_tmds_rate_inferred,
+ drm_connector_hdmi_init_max_tmds_rate_inferred_gen_params),
+ KUNIT_CASE(drm_test_connector_hdmi_init_max_tmds_rate_override),
+ KUNIT_CASE(drm_test_connector_hdmi_init_max_tmds_rate_override_hdmi20),
+ KUNIT_CASE(drm_test_connector_hdmi_init_max_tmds_rate_at_limit),
+ KUNIT_CASE(drm_test_connector_hdmi_init_max_tmds_rate_off_limit),
+ KUNIT_CASE(drm_test_connector_hdmi_init_max_tmds_rate_no_version),
{ }
};
--
2.56.0
next prev parent reply other threads:[~2026-12-02 2:20 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 2:19 [PATCH v2 00/25] drm: HDMI connector API cleanup and HDMI 2.0 test coverage Cristian Ciocaltea
2026-12-02 2:19 ` [PATCH v2 01/25] video/hdmi: Copy SPD vendor/product with strtomem_pad() Cristian Ciocaltea
2026-12-02 2:19 ` [PATCH v2 02/25] video/hdmi: Define SPD InfoFrame vendor/product field lengths Cristian Ciocaltea
2026-12-02 2:19 ` [PATCH v2 03/25] drm/display: hdmi-state-helper: Drop drm_atomic_helper_connector_hdmi_force() Cristian Ciocaltea
2026-12-02 2:19 ` [PATCH v2 04/25] drm/display: hdmi-state-helper: Reject connectors lacking HDMI funcs Cristian Ciocaltea
2026-12-02 2:19 ` [PATCH v2 05/25] drm/tests: connector: Convert to drmm_connector_hdmi_init() Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 06/25] drm/tests: hdmi: " Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 07/25] drm/connector: Remove drmm_connector_hdmi_ini2() Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 08/25] drm/connector: Drop redundant hdmi vendor/product fields Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 09/25] drm/connector: Drop redundant hdmi supported_formats field Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 10/25] drm/connector: Drop redundant max_bpc field Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 11/25] drm/connector: Use the SPD InfoFrame field length defines Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 12/25] drm/connector: Fix comment in drmm_connector_hdmi_init() Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 13/25] drm/tests: edid: Fix conformity for 1080p+4K YUV420 200MHz EDID Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 14/25] drm/tests: edid: Fix conformity for 4K RGB/YUV 340MHz EDID Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 15/25] drm/tests: edid: Add 4K@60Hz EDID with 600MHz TMDS Cristian Ciocaltea
2026-12-02 2:20 ` Cristian Ciocaltea [this message]
2026-12-02 2:20 ` [PATCH v2 17/25] drm/tests: connector: Add HDMI source-side scrambler coverage Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 18/25] drm/tests: hdmi: Cover mode validation against connector max_tmds_char_rate Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 19/25] drm/tests: hdmi: Verify scrambler_needed computation Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 20/25] drm/tests: hdmi: Add SPD InfoFrame vendor/product coverage Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 21/25] drm/tests: hdmi: Add HDMI 2.0 scrambling helpers coverage Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 22/25] drm/tests: hdmi: Verify SCDC resync on hotplug Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 23/25] drm/tests: bridge: Set supported HDMI version Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 24/25] drm/tests: bridge: Add HDMI 2.0 bridge connector coverage Cristian Ciocaltea
2026-12-02 2:20 ` [PATCH v2 25/25] drm/tests: probe-helper: Add .force_ctx() callback coverage Cristian Ciocaltea
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202-drm-conn-hdmi-cleanup-v2-16-ba7d32550ea4@collabora.com \
--to=cristian.ciocaltea@collabora.com \
--cc=airlied@gmail.com \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=kernel@collabora.com \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=sam@ravnborg.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®