Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2979540lqo; Tue, 21 May 2024 03:14:57 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUV9xhDtPcfKprN+ZtsH/U+omjy7WvI+g4u0cQ7xxobGE8V2LRJwk3+ks+s4DmmCG6N3yQNKVqADE3wf4vpVkTbPzIwrT9kx++pV/T42g== X-Google-Smtp-Source: AGHT+IF9inAPotv8mOAxwOte5B15sSV/VbO0fcWHwFLmz+5clLd/q0zYs8Ggs4deKMQNQvBk2DDH X-Received: by 2002:a05:6122:169c:b0:4d8:7ae2:107 with SMTP id 71dfb90a1353d-4df8834b241mr27620890e0c.10.1716286497001; Tue, 21 May 2024 03:14:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716286496; cv=pass; d=google.com; s=arc-20160816; b=FGfJJptMC0vPUG2RDnWEcQhDxateKXf++BZfw9Spy+EhTGah70RU4BvKz4kGOj/W6P GZe5Ug2dsafwDn/jfgYAaCNJdWsneB7EamO14osQ/W4THubwDntZS24d7+a3dYxk/oDG wfvo3ZmHvrpIhx/9euQcAUJI9C5Qn3QxNyxg3HR9QMPdOVOb3sr6ypxTJj6GVZ4sksbo ypBL9mT1rhaaFkelDCdy8UhZaH6sGS881WQllMCQWhpX81LbMlC/roU+PUd3zkAWWeay jQCnVLqfkidcKLoJ5GMfE4avZRVEp9w/49H6o6rXWeY7Q2EKzkU8yeWHAhI98NZPdrBY AdXA== 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=B4js7nLIIhDTsDgigNIOp0WBy0JYgGrQaAV7jrpj1dc=; fh=ufmwd8Wo0DI+kdMOJWC7ZXqsyLxoMBbO0En/E/GApYU=; b=iuU/n9EhgsSHMI0OI2/HIqt4D4QNJAB1YI1BRDTD0QRcUD6uM1kjBGX+1NcvkWni/d 8L+6I+PDgSbTXhYfdfVia2Wmyv4nK72bZpAUlhNPSL1ZvnxFDa6yALI489eVfPy2uvZt gYgESNsrnTWDa96atECR6pKvC1n3mYPYymOeRDIXNUTtVPLxNTl4CXEffx193MjROu8/ ldeQePfPliW3BJeCcK6I5aqDTMcd8qQfXrIv6Zt3EpvNRXbfMbonLCYCCLWhdJTseJ09 hxneW31X9MSCwtpLEuiFGFCsILplMlOYFa3qzfZADiubXKE+0M9sPuY+1foqtml8DGTW vUxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pKI1xk2C; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-184763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184763-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-792bf27738esi653065385a.72.2024.05.21.03.14.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 03:14:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pKI1xk2C; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-184763-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184763-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 2634F1C21604 for ; Tue, 21 May 2024 10:14:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A1F174BF0; Tue, 21 May 2024 10:14:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pKI1xk2C" 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 53C0074418; Tue, 21 May 2024 10:14:01 +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=1716286441; cv=none; b=L05+i0pGZDR7x+NlGHF/417mp3Navz61dxgw3zvLIMRCLR+3RztHoTByWztjYZ3grWsMxgdvVwxsYr++30wOhYlAYHfZx716retZ5XVOj8ZRzzOSxAqA8pSq35nwI1Xhseja1bVmBo0kxkIOLbXSPU115cjXR1iBBn8mFaqRT2w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716286441; c=relaxed/simple; bh=kpugqRRTtI2zqYUkrRQOUtStRse4zcye8LofRM1/4QM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FCt1m6wQgHLQNIFCH1JNS5hA3+uOTCP2KAMRHoWzOkuh4tWNHjQMbjFhyeTuGSH8xKjFz6Cn0Psms9geyy8OISmNUeZGW7w1owCiRkdARdhIOOkzusNGdVJmMJe5I34JDIF9sSTA10F2o9xS0Aph+E4t9Kp79cXIjPa4sJpICbM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pKI1xk2C; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9472DC2BD11; Tue, 21 May 2024 10:14:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716286440; bh=kpugqRRTtI2zqYUkrRQOUtStRse4zcye8LofRM1/4QM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pKI1xk2CxMLwVCPyuX6FA9SH+8YDSEPHnYik23K1NX90FDp6XlxFzS+RK/x+dANS0 yQwtiM+J1/kaoPa1mgsAx0/q5xcHJWKzQJpoqEHxCJkV1RvSnsmzoA8YQLmSOYxshD 35PxTX0bDzRWba9NlikfbhGQX4uqhV/R6bguHBFvifZnNDhzYdvcVJYLV5AHveU+xz FH44W8DL5nuytxSyaoqRP0CxbdLvuYS6LSxySVGulbXpDW2HzAbehECQYZCogUwLSe IiODO0XAf3TlAz77uY8Jarh8ckV7NagYbXMAZ7r3u/8VZ8VE4FJMKD3/5Bi1A9kTbw J0i6II+5haYPw== From: Maxime Ripard Date: Tue, 21 May 2024 12:13:36 +0200 Subject: [PATCH v14 03/28] 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: <20240521-kms-hdmi-connector-state-v14-3-51950db4fedb@kernel.org> References: <20240521-kms-hdmi-connector-state-v14-0-51950db4fedb@kernel.org> In-Reply-To: <20240521-kms-hdmi-connector-state-v14-0-51950db4fedb@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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5120; i=mripard@kernel.org; h=from:subject:message-id; bh=kpugqRRTtI2zqYUkrRQOUtStRse4zcye8LofRM1/4QM=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGk+xRd9grv1J0m9zlfadPToswtBR3P3VG2ZcEVhyav0I NtFGUcnd0xlYRDmZJAVU2R5IhN2enn74ioH+5U/YOawMoEMYeDiFICJHNZjrDNtPz4zxPKo+ir7 lgUd55nCjho+yA5euCZS+1JXUjxLg4SK4+J0l+TmY6ynrTxE+p7vYWy4eODM2dl7Zp/VVVXbuuL BWa3Cv4o6ByqrX325raKx7eHWMoujnCz3Z8oLPEj0k9nDlCANAA== 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 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