[v9,54/61] drm/tests: connector: Add HDMI source-side scrambler coverage

Message ID 20260723-dw-hdmi-qp-scramb-v9-54-4fb12ea22ac9@collabora.com (mailing list archive)
State New
Headers
Series Add HDMI 2.0 support to DW HDMI QP TX |

Commit Message

Cristian Ciocaltea July 23, 2026, 1:35 a.m. UTC
Add KUnit tests for the HDMI source-side scrambling validation done by
the new drmm_connector_hdmi_init() helper.

Connector initialization derives scrambler support from the
driver-provided supported_hdmi_ver capability.  The scrambler callbacks
are only valid for connectors advertising HDMI 2.0 or later, as
drm_connector_hdmi_scrambler_supported() uses their presence to report
source-side scrambling support.

Therefore, connectors that advertise source-side scrambling support must
provide both .scrambler_enable and .scrambler_disable.  Registration is
rejected if either callback is missing.  Conversely, connectors that do
not advertise source-side scrambling support must not provide these
callbacks, and registration is rejected if they are present.

Test the valid and invalid callback combinations for both supported and
unsupported scrambling configurations.

Signed-off-by: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>
---
 drivers/gpu/drm/tests/drm_connector_test.c | 87 ++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)
  

Comments

sashiko-bot@kernel.org July 23, 2026, 2 a.m. UTC | #1
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Masked test failures in TMDS character rate validation tests.
--

--- Patch [54]: [PATCH v9 54/61] drm/tests: connector: Add HDMI source-side scrambler coverage ---
commit 51e9e33a81edd8b52502410a5e171c4a8d0bf3c5
Author: Cristian Ciocaltea <cristian.ciocaltea@collabora.com>

drm/tests: connector: Add HDMI source-side scrambler coverage

This commit adds KUnit tests to validate the HDMI source-side scrambler checking
in drmm_connector_hdmi_init(). It verifies that scrambler callbacks are
correctly required for HDMI 2.0 and later, and rejected if provided for earlier
HDMI versions.

> diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c
> index f14cd741b05e4..3d050ac5e5f6d 100644
> --- a/drivers/gpu/drm/tests/drm_connector_test.c
> +++ b/drivers/gpu/drm/tests/drm_connector_test.c
> @@ -1412,6 +1412,89 @@ static void drm_test_connector_hdmi_init_max_tmds_rate_no_version(struct kunit *
>  	KUNIT_EXPECT_LT(test, ret, 0);
>  }
>  

[Severity: Medium]
Will the scrambler validation tested by this patch mask the TMDS rate limit
tests located just above this hunk?

In drm_test_connector_hdmi_init_max_tmds_rate_exceeds() and
drm_test_connector_hdmi_init_max_tmds_rate_no_version(), the tests use
dummy_hdmi_funcs_scrambler but set supported_hdmi_ver to HDMI_VERSION_1_4 or
HDMI_VERSION_UNKNOWN:

	struct drm_connector_hdmi_funcs hdmi_funcs = dummy_hdmi_funcs_scrambler;
	...
	hdmi_funcs.supported_hdmi_ver = HDMI_VERSION_1_4;

Since drmm_connector_hdmi_init() rejects scrambler callbacks for HDMI
versions < 2.0 by returning -EINVAL early, will these TMDS rate tests now fail
during the scrambler check rather than actually validating the TMDS character
rate logic?

Should they be updated to use a dummy struct without scrambler callbacks to
ensure the max_tmds_char_rate limit is what actually causes the test to pass?

> +/*
> + * Test that the registration of an HDMI connector advertising source-side
> + * scrambling support succeeds when the .scrambler_{enable,disable} callbacks
> + * are provided.
> + */

[ ... ]
  

Patch

diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c
index f14cd741b05e..3d050ac5e5f6 100644
--- a/drivers/gpu/drm/tests/drm_connector_test.c
+++ b/drivers/gpu/drm/tests/drm_connector_test.c
@@ -1412,6 +1412,89 @@  static void drm_test_connector_hdmi_init_max_tmds_rate_no_version(struct kunit *
 	KUNIT_EXPECT_LT(test, ret, 0);
 }
 
+/*
+ * Test that the registration of an HDMI connector advertising source-side
+ * scrambling support succeeds when the .scrambler_{enable,disable} callbacks
+ * are provided.
+ */
+static void drm_test_connector_hdmi_init_scrambler_valid(struct kunit *test)
+{
+	struct drm_connector_init_priv *priv = test->priv;
+	int ret;
+
+	ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
+				       &dummy_funcs,
+				       &dummy_hdmi_funcs_scrambler,
+				       DRM_MODE_CONNECTOR_HDMIA,
+				       &priv->ddc);
+	KUNIT_EXPECT_EQ(test, ret, 0);
+	KUNIT_EXPECT_TRUE(test, drm_connector_hdmi_scrambler_supported(&priv->connector));
+}
+
+/*
+ * Test that the registration of an HDMI connector advertising source-side
+ * scrambling support fails when the .scrambler_{enable,disable} callbacks
+ * are not provided.
+ */
+static void drm_test_connector_hdmi_init_scrambler_no_callbacks(struct kunit *test)
+{
+	struct drm_connector_init_priv *priv = test->priv;
+	struct drm_connector_hdmi_funcs hdmi_funcs = dummy_hdmi_funcs_scrambler;
+	int ret;
+
+	hdmi_funcs.scrambler_enable = NULL;
+	hdmi_funcs.scrambler_disable = NULL;
+
+	ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
+				       &dummy_funcs,
+				       &hdmi_funcs,
+				       DRM_MODE_CONNECTOR_HDMIA,
+				       &priv->ddc);
+	KUNIT_EXPECT_LT(test, ret, 0);
+}
+
+/*
+ * Test that the registration of an HDMI connector advertising source-side
+ * scrambling support fails when only one of the .scrambler_{enable,disable}
+ * callbacks are provided.
+ */
+static void drm_test_connector_hdmi_init_scrambler_partial_callbacks(struct kunit *test)
+{
+	struct drm_connector_init_priv *priv = test->priv;
+	struct drm_connector_hdmi_funcs hdmi_funcs = dummy_hdmi_funcs_scrambler;
+	int ret;
+
+	hdmi_funcs.scrambler_disable = NULL;
+
+	ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
+				       &dummy_funcs,
+				       &hdmi_funcs,
+				       DRM_MODE_CONNECTOR_HDMIA,
+				       &priv->ddc);
+	KUNIT_EXPECT_LT(test, ret, 0);
+}
+
+/*
+ * Test that the registration of an HDMI connector not advertising source-side
+ * scrambling support fails when .scrambler_{enable,disable} callbacks are
+ * provided.
+ */
+static void drm_test_connector_hdmi_init_scrambler_unexpected_callbacks(struct kunit *test)
+{
+	struct drm_connector_init_priv *priv = test->priv;
+	struct drm_connector_hdmi_funcs hdmi_funcs = dummy_hdmi_funcs_scrambler;
+	int ret;
+
+	hdmi_funcs.supported_hdmi_ver = HDMI_VERSION_1_4;
+
+	ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector,
+				       &dummy_funcs,
+				       &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),
@@ -1442,6 +1525,10 @@  static struct kunit_case drmm_connector_hdmi_init_tests[] = {
 	KUNIT_CASE(drm_test_connector_hdmi_init_max_tmds_rate_at_limit),
 	KUNIT_CASE(drm_test_connector_hdmi_init_max_tmds_rate_exceeds),
 	KUNIT_CASE(drm_test_connector_hdmi_init_max_tmds_rate_no_version),
+	KUNIT_CASE(drm_test_connector_hdmi_init_scrambler_valid),
+	KUNIT_CASE(drm_test_connector_hdmi_init_scrambler_no_callbacks),
+	KUNIT_CASE(drm_test_connector_hdmi_init_scrambler_partial_callbacks),
+	KUNIT_CASE(drm_test_connector_hdmi_init_scrambler_unexpected_callbacks),
 	{ }
 };