Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2066628lqb; Mon, 27 May 2024 06:59:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUIjTaTovHWXSe/9n/QySik8DdJy6Lgjt4q68MTsbscRanh1d62kf7DPO0qMM5ENkAfQ/rE55VX5CwQRNot5J75VglwFXGhYYEitY5aSw== X-Google-Smtp-Source: AGHT+IFcXUmKRh2lLQt05JX+fWcNhOw/KgIO7oqHcLd5C5myTxeeHSmVV79WaUM7Caq7Lrbai7+k X-Received: by 2002:a17:906:90d:b0:a59:9da0:cc1 with SMTP id a640c23a62f3a-a626511b172mr979038266b.58.1716818342356; Mon, 27 May 2024 06:59:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716818342; cv=pass; d=google.com; s=arc-20160816; b=uwq1WMo0u2xOlGWGWWJYUQ7iENwAJNmin0iuegRq4mcaw5g9HUUc9r7Vul6w2QFq+Q eBa1VTSCIZyL1erQLClXBajWy+L4Q0tUJbvtbucRUhF408DnulscGHvkaOUfMFZ2liI9 G+SKerQO6jg5AQA22AE0Spg7vfZwi5SPq0Hk2177K3r95yClKK4qtC0bBDalnc9Gd++8 NiQBBE5J9L+RVfMvhjuiQ9rNf1t7VeU5LycXzt2AC1NSdVSZ1USWY1aAWTOjnCtYJsqE QdeLSGWmQMmJGOfC2idZo1XDBcjCtOGeWsGx8dUd6Jv2CjGfCcjh9kLEcW8boq5PFq9C Ojmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=3Z9iXe4/g2dfUXuzrC/SYHDyYBCloRFDchZfVclniZ4=; fh=Rmvm45DLBttDXPZ7ZQBINOOM6/ese2BHFaa7wD2L3jc=; b=GKTL81BkNwBlgCansgvxusQSXndll51cpoqXiSdrQBzhkWNAltIO5IiRw2j+ZU++Tb cJrzEoCtoOQjLi/V8ZkIWRLuHokKHSFoH6yZA6L00XO3+ZgQ1wMf42PpUuBX5xtZJ8Da mNs+e8gNuXfmyd8MMvSkdluG26nl/dM8ip9Pq1NmQ+ZY//1rMkg9nGGbLVlCcYs58h8w KKhsClq8sPjFvkT7+48s+NzHVZAG3Y/xO3/6F09Q/3Rkol90cDcUo8RNTpBygsSFbkmw IrWO987+pPVvN93xvm0EihcSDsWbzLG0K1ui1+yRbsf7iisFJ6yu/wUI9QUoozqO+soS GfmQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t1pKMVRn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190764-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a626cdd5054si378359266b.1041.2024.05.27.06.59.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 06:59:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=t1pKMVRn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190764-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190764-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id D02C91F21D60 for ; Mon, 27 May 2024 13:59:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 35F9D15EFAA; Mon, 27 May 2024 13:58:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t1pKMVRn" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 23E4A15F309; Mon, 27 May 2024 13:58:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716818294; cv=none; b=jC8L/4+PwNDUOQxIOfLjJlw1/hIpr2tziysac0ABij0SmX3f3Y361fwgI4yRrVFD1PR0l+RhXphn1zWUXRi5oQ7FvzksdixRkyxlRX9WlKlN2PnwdmjM6RTsIeMTukCV/M9WMbJQIF+yoXer60yHqIGCUHHipTa5koEdIsWhEfo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716818294; c=relaxed/simple; bh=Jd5Xo/csjHcnm5bNUzfT8E3FJ0NlCfRfDDxu197YBKE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VXFDMk5uCcnpZIvcuO/S5L728Fo/hnNQdRQY1hAU9PaW4N25EMuEel7SoW7Vr8hNi6EePqlL1nFyVDrHX+CRw+Y1DqS0thO2sNfTY6mip10IPThlFWHx1KMOZHd5Ixix0a3Q/A4dsHJy2ArULF2uKFvcMeCsmGf6H5UWIGZOORo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t1pKMVRn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5E2DC4AF0A; Mon, 27 May 2024 13:58:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716818294; bh=Jd5Xo/csjHcnm5bNUzfT8E3FJ0NlCfRfDDxu197YBKE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=t1pKMVRnF/dibuWfNeZg5gHE47p0XOqiYYca3Qi2U4sIpoQwxkF6HWs/NNLmv9t+2 tKsaFtPXBg2/nl2PYyyWA6joFw3sfTLFvishPelujJsd/LuMeDjXb1PdSpGdUOXLag E6YJc5PaSF6dxfFJKopGV5xlPIny1L4e+JxfD42hB1flU1Oo3zQMYiwgH93O8kSHn9 m2pkuBXlV+sttYkVWo2IA/rvS9awRsqZJJz5mwfgMGOJ/7nOvfswSHSRbQw4qQ3+o+ Tq1A6wgZ82Msn+RD2L4PHNJeDISkQHVmCR7wX/roMgGPdVJW4dKM7bFCnyLjdu9pW7 VnwduZBgjMgfg== From: Maxime Ripard Date: Mon, 27 May 2024 15:57:51 +0200 Subject: [PATCH v15 02/29] drm/tests: connector: Add tests for drmm_connector_hdmi_init Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240527-kms-hdmi-connector-state-v15-2-c5af16c3aae2@kernel.org> References: <20240527-kms-hdmi-connector-state-v15-0-c5af16c3aae2@kernel.org> In-Reply-To: <20240527-kms-hdmi-connector-state-v15-0-c5af16c3aae2@kernel.org> To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Jonathan Corbet , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Andy Yan Cc: Hans Verkuil , Sebastian Wick , =?utf-8?q?Ville_Syrj=C3=A4l=C3=A4?= , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-sunxi@lists.linux.dev, Maxime Ripard , Dave Stevenson , Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5181; i=mripard@kernel.org; h=from:subject:message-id; bh=Jd5Xo/csjHcnm5bNUzfT8E3FJ0NlCfRfDDxu197YBKE=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGkhExM+2HrN+nNoYfF+LtMPeSsmflLZaMAT88HO6N4Lc 75YKYb+jqksDMKcDLJiiixPZMJOL29fXOVgv/IHzBxWJpAhDFycAjAR9jTGOtWFU48qLRPblKdr lHCNef6e53w6en2yIuVvQi9rKKkxJEvNNJe9G3Zd6xzb46fX875WMdaZVa4zPLiz53PF6Zmz+AW vM19qYXJfXZW5NeLDsvsF7rpuPoGdGX0FjsorviaqXTn0hAMA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D We just introduced a new initialization function for our connectors, so let's build a kunit test suite for it as well. Reviewed-by: Dave Stevenson Reviewed-by: Dmitry Baryshkov Signed-off-by: Maxime Ripard --- drivers/gpu/drm/tests/drm_connector_test.c | 123 +++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c index 44f82ed2a958..261d4109946d 100644 --- a/drivers/gpu/drm/tests/drm_connector_test.c +++ b/drivers/gpu/drm/tests/drm_connector_test.c @@ -170,10 +170,132 @@ static struct kunit_suite drmm_connector_init_test_suite = { .name = "drmm_connector_init", .init = drm_test_connector_init, .test_cases = drmm_connector_init_tests, }; +/* + * Test that the registration of a bog standard connector works as + * expected and doesn't report any error. + */ +static void drm_test_connector_hdmi_init_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, + DRM_MODE_CONNECTOR_HDMIA, + &priv->ddc); + KUNIT_EXPECT_EQ(test, ret, 0); +} + +/* + * Test that the registration of a connector without a DDC adapter + * doesn't report any error. + */ +static void drm_test_connector_hdmi_init_null_ddc(struct kunit *test) +{ + struct drm_connector_init_priv *priv = test->priv; + int ret; + + ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, + &dummy_funcs, + DRM_MODE_CONNECTOR_HDMIA, + NULL); + KUNIT_EXPECT_EQ(test, ret, 0); +} + +/* + * Test that the registration of an HDMI connector with an HDMI + * connector type succeeds. + */ +static void drm_test_connector_hdmi_init_type_valid(struct kunit *test) +{ + struct drm_connector_init_priv *priv = test->priv; + unsigned int connector_type = *(unsigned int *)test->param_value; + int ret; + + ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, + &dummy_funcs, + connector_type, + &priv->ddc); + KUNIT_EXPECT_EQ(test, ret, 0); +} + +static const unsigned int drm_connector_hdmi_init_type_valid_tests[] = { + DRM_MODE_CONNECTOR_HDMIA, + DRM_MODE_CONNECTOR_HDMIB, +}; + +static void drm_connector_hdmi_init_type_desc(const unsigned int *type, char *desc) +{ + sprintf(desc, "%s", drm_get_connector_type_name(*type)); +} + +KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_type_valid, + drm_connector_hdmi_init_type_valid_tests, + drm_connector_hdmi_init_type_desc); + +/* + * Test that the registration of an HDMI connector with an !HDMI + * connector type fails. + */ +static void drm_test_connector_hdmi_init_type_invalid(struct kunit *test) +{ + struct drm_connector_init_priv *priv = test->priv; + unsigned int connector_type = *(unsigned int *)test->param_value; + int ret; + + ret = drmm_connector_hdmi_init(&priv->drm, &priv->connector, + &dummy_funcs, + connector_type, + &priv->ddc); + KUNIT_EXPECT_LT(test, ret, 0); +} + +static const unsigned int drm_connector_hdmi_init_type_invalid_tests[] = { + DRM_MODE_CONNECTOR_Unknown, + DRM_MODE_CONNECTOR_VGA, + DRM_MODE_CONNECTOR_DVII, + DRM_MODE_CONNECTOR_DVID, + DRM_MODE_CONNECTOR_DVIA, + DRM_MODE_CONNECTOR_Composite, + DRM_MODE_CONNECTOR_SVIDEO, + DRM_MODE_CONNECTOR_LVDS, + DRM_MODE_CONNECTOR_Component, + DRM_MODE_CONNECTOR_9PinDIN, + DRM_MODE_CONNECTOR_DisplayPort, + DRM_MODE_CONNECTOR_TV, + DRM_MODE_CONNECTOR_eDP, + DRM_MODE_CONNECTOR_VIRTUAL, + DRM_MODE_CONNECTOR_DSI, + DRM_MODE_CONNECTOR_DPI, + DRM_MODE_CONNECTOR_WRITEBACK, + DRM_MODE_CONNECTOR_SPI, + DRM_MODE_CONNECTOR_USB, +}; + +KUNIT_ARRAY_PARAM(drm_connector_hdmi_init_type_invalid, + drm_connector_hdmi_init_type_invalid_tests, + drm_connector_hdmi_init_type_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_null_ddc), + KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_type_valid, + 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), + { } +}; + +static struct kunit_suite drmm_connector_hdmi_init_test_suite = { + .name = "drmm_connector_hdmi_init", + .init = drm_test_connector_init, + .test_cases = drmm_connector_hdmi_init_tests, +}; + struct drm_get_tv_mode_from_name_test { const char *name; enum drm_connector_tv_mode expected_mode; }; @@ -234,10 +356,11 @@ static struct kunit_suite drm_get_tv_mode_from_name_test_suite = { .name = "drm_get_tv_mode_from_name", .test_cases = drm_get_tv_mode_from_name_tests, }; kunit_test_suites( + &drmm_connector_hdmi_init_test_suite, &drmm_connector_init_test_suite, &drm_get_tv_mode_from_name_test_suite ); MODULE_AUTHOR("Maxime Ripard "); -- 2.45.0