From patchwork Tue Sep 1 18:51:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Ciocaltea X-Patchwork-Id: 3101 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mxe881.netcup.net (Postfix) with ESMTPS id D8A011C3C0F for ; Tue, 1 Sep 2026 21:09:35 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=collabora.com; spf=pass (sender IP is 172.105.105.114) smtp.mailfrom=linux-sunxi+bounces-25453-noreply=patchwork.local@lists.linux.dev smtp.helo=tor.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.105.105.114 as permitted sender) client-ip=172.105.105.114; envelope-from=linux-sunxi+bounces-25453-noreply=patchwork.local@lists.linux.dev; helo=tor.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id D322F679E2 for ; Tue, 1 Sep 2026 18:58:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 506034A9D74; 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="NGix7IFy" 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 DBE804A8A34 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=GdNvDZ37T1W1Je8vdkJaqSsYHYKsA+Z4STAZTZJl2R1DOaZTJJET0/Zk8wuOwnZs5Tez7MQjtvqgkcvyNGpCZwTZgxLeX4nGoNOSDyrZUs4BC25zwFUxS29X4e1eG7Xktu03QjKuFRYVbP58qMxQNg9zNoMG9ADRhVcRaAHaBHw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788288694; c=relaxed/simple; bh=FrhjuUNCO81qN+N5ecDEgIGCe7yPo+Baimk/ZGvUvTY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SupUD+kI9cJkS0a6M2b/2FJzuu/FsAXL9roksW9Hn0fgNxecubtS/ydja6fULrwrlxnjmwzi3Lxt5vd+r9lgiCT2n3C7kG9mdtE7UBqLx3epysOLw8OTuldv8XvQK0mrKwZXT5jfa73ZMVKNacc8MGxbqbrUNIDTMKikHoSmdKg= 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=NGix7IFy; 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=1788288688; bh=FrhjuUNCO81qN+N5ecDEgIGCe7yPo+Baimk/ZGvUvTY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NGix7IFylzprYXGkOGaW2G0REydz1DhDuNPTsROIM8iHaD6S5HP7xPb3YOAVt2IGB czFOlP4OH0a5gDtVx7Oh6Q0F4+u7AzVJ/B4DELlNOO0lQdrf7n/ElldA/uoQHwIFk9 Yg81mcHRMGcbPIdUZunIZBh+LqF02dhuwJNvDCmWyicjoabp5RvsRaVH5jbianOYaT pQZcuxgvtP7Z2sG66QeyJivfxJRm5lQ4asVGZL0HATixyH2QrHtkENn5jOnMVQx/Ly uq07ejBWG5qkp9F8Zq5ZnMsoPL+c+SwACoI6OXG4uLU4aq681yf8Yv/Fso1mGJ2YAO hSdwpI28Zui4w== 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 223CA17E3C95; Tue, 01 Sep 2026 20:51:28 +0200 (CEST) From: Cristian Ciocaltea Date: Tue, 01 Sep 2026 21:51:28 +0300 Subject: [PATCH v11 64/74] drm/tests: connector: Add HDMI source-side scrambler 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-64-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 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. Therefore, connectors that advertise HDMI 2.0 or later must provide both .scrambler_enable() and .scrambler_disable() callbacks. Registration is rejected if either callback is missing. Signed-off-by: Cristian Ciocaltea --- drivers/gpu/drm/tests/drm_connector_test.c | 102 +++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c index 17242d1c1b16..0613568ef5b7 100644 --- a/drivers/gpu/drm/tests/drm_connector_test.c +++ b/drivers/gpu/drm/tests/drm_connector_test.c @@ -1417,6 +1417,104 @@ 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 HDMI 2.0 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 not advertising HDMI 2.0 + * support succeeds, and the connector is not reported as scrambling capable. + */ +static void drm_test_connector_hdmi_init_scrambler_unsupported(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, + DRM_MODE_CONNECTOR_HDMIA, + &priv->ddc); + KUNIT_EXPECT_EQ(test, ret, 0); + KUNIT_EXPECT_FALSE(test, drm_connector_hdmi_scrambler_supported(&priv->connector)); +} + +enum drm_connector_hdmi_scrambler_cb { + SCRAMBLER_CALLBACK_ENABLE, + SCRAMBLER_CALLBACK_DISABLE, + SCRAMBLER_CALLBACK_ALL, +}; + +struct drm_connector_hdmi_init_scrambler_missing_cb_case { + const char *desc; + enum drm_connector_hdmi_scrambler_cb cb; +}; + +/* + * Test that the registration of an HDMI connector advertising HDMI 2.0 support + * fails when any single .scrambler_* callback is missing. + */ +static void drm_test_connector_hdmi_init_scrambler_missing_cb(struct kunit *test) +{ + const struct drm_connector_hdmi_init_scrambler_missing_cb_case *params = test->param_value; + struct drm_connector_init_priv *priv = test->priv; + int ret; + + priv->hdmi_funcs = dummy_hdmi_funcs_scrambler; + + switch (params->cb) { + case SCRAMBLER_CALLBACK_ENABLE: + priv->hdmi_funcs.scrambler_enable = NULL; + break; + case SCRAMBLER_CALLBACK_DISABLE: + priv->hdmi_funcs.scrambler_disable = NULL; + break; + case SCRAMBLER_CALLBACK_ALL: + priv->hdmi_funcs.scrambler_enable = NULL; + priv->hdmi_funcs.scrambler_disable = NULL; + break; + } + + 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 const struct drm_connector_hdmi_init_scrambler_missing_cb_case +drm_connector_hdmi_init_scrambler_missing_cb_tests[] = { + { "scrambler_enable", SCRAMBLER_CALLBACK_ENABLE }, + { "scrambler_disable", SCRAMBLER_CALLBACK_DISABLE }, + { "scrambler_*", SCRAMBLER_CALLBACK_ALL }, +}; + +static void +drm_connector_hdmi_init_scrambler_missing_cb_desc(const struct drm_connector_hdmi_init_scrambler_missing_cb_case *t, + char *desc) +{ + strscpy(desc, t->desc, KUNIT_PARAM_DESC_SIZE); +} + +KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_scrambler_missing_cb, + drm_connector_hdmi_init_scrambler_missing_cb_tests, + drm_connector_hdmi_init_scrambler_missing_cb_desc); + 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), @@ -1447,6 +1545,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_off_limit), 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_unsupported), + KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_scrambler_missing_cb, + drm_connector_hdmi_init_scrambler_missing_cb_gen_params), { } };