From patchwork Tue Sep 1 18:51:27 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 3082 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id DDF711C002D for ; Tue, 1 Sep 2026 20:59:46 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=collabora.com; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-25454-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-25454-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sto.lore.kernel.org (Postfix) with ESMTP id D2F506118DA for ; Tue, 1 Sep 2026 18:58:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B9D924AA000; Tue, 1 Sep 2026 18:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="F6VFv0Ym" X-Original-To: linux-sunxi@lists.linux.dev Received: from bali.collaboradmins.com (bali.collaboradmins.com [148.251.105.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B2054A8A27 for ; Tue, 1 Sep 2026 18:51:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.251.105.195 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788288694; cv=none; b=PRtcd2NyrvELqC4r72DoMjoFwaT2XnajqNYLlxhd5XJ5F9Y8ZDvIJPCXotv0KUfkmYMnLzz0rO+kyg5m2rOXABbjEz1KsdaYjLCGO/5N8xbceIvGQ1DG2JSOe0eFyJ1Hsk79dlOu/GE0P6KmMUby3c8BiPyS2/jJtHQLEFvm2UQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788288694; c=relaxed/simple; bh=wy7odb4Bzb//d8gJuSExcEjuuO+HCRVariqZb2J3yPk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fyUrijuL/3jCrgUwi11BNHxPKIRP+fTcUsFuSlyb8eJCCSvP85wyAwD4ysKXQ9NeKTpKQV6eehuX3AdKe2yhRgV8UjbHNxmpj9xmfRsqySv9ZQpIXLxY7FC254QXUhjbfGz8vJGfhs2WzJi6rG1BZtVLuVdWe5L2+WclKZotoys= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=F6VFv0Ym; arc=none smtp.client-ip=148.251.105.195 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1788288687; bh=wy7odb4Bzb//d8gJuSExcEjuuO+HCRVariqZb2J3yPk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=F6VFv0YmuePKkcY3481GeflZG7GBxty8bPfGbnzRU7USpkJuPzSCybDWCnlxQQKQR 3LCiXJwDwnUas7sfby6XfSawNTmF1UOHospBfUHFRJSJ4FhFRKn+5yP5LRbdYbmaOs GfUYobJ+rYpPqdpHcmLDzVaW4nBg4hwoR3vu3gzgi/PoK0ytM0V6seztFGmyUSTag9 wc8kBmLLmq62Un5Y3w9XeV8pdzwn+577m9j2CH+q7Vujkc6WlTgJpotBa/cojkX7Yu j9L3Mf3ywqkfE2zwuavxQmKVIZmVeIOq7me88Az7oyCmYIPA7kq35r6TGNhITM7GGg BDmm7v9EC9LjQ== Received: from localhost (unknown [100.64.0.241]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange secp256r1 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: cristicc) by bali.collaboradmins.com (Postfix) with ESMTPSA id 62B3817E3C93; Tue, 01 Sep 2026 20:51:27 +0200 (CEST) From: Cristian Ciocaltea Date: Tue, 01 Sep 2026 21:51:27 +0300 Subject: [PATCH v11 63/74] drm/tests: connector: Add HDMI max_tmds_char_rate init coverage Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260901-dw-hdmi-qp-scramb-v11-63-bc12954a0688@collabora.com> References: <20260901-dw-hdmi-qp-scramb-v11-0-bc12954a0688@collabora.com> In-Reply-To: <20260901-dw-hdmi-qp-scramb-v11-0-bc12954a0688@collabora.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , Dave Stevenson , Dmitry Baryshkov , Andrzej Hajda , Neil Armstrong , Robert Foss , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Luca Ceresoli , Chen-Yu Tsai , Samuel Holland , =?utf-8?q?Ma=C3=ADra_Canal?= , Raspberry Pi Kernel Maintenance , Raphael Gallais-Pou , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Andy Yan , Algea Cao , Daniel Stone , Liu Ying , Phong LE , Helge Deller Cc: kernel@collabora.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-rockchip@lists.infradead.org, linux-fbdev@vger.kernel.org X-Mailer: b4 0.15.2 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= 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. 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. 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. Signed-off-by: Cristian Ciocaltea --- drivers/gpu/drm/tests/drm_connector_test.c | 179 +++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c index c53ccce21a42..17242d1c1b16 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_destroy_state = drm_atomic_helper_connector_destroy_state, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, @@ -1244,6 +1272,151 @@ 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.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 }, +}; + +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 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), @@ -1268,6 +1441,12 @@ 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_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), { } };