Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp561497lqi; Thu, 7 Mar 2024 05:40:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXMTwjZ3YHErRVQc9eZMVu/Q8pipoQEl/L7CRdS4QClpZaav+XggCkEAbivPqko3LHaq86sSn3bxTvA6P1DJPP3kSj4nBZhRqvmv/AiXw== X-Google-Smtp-Source: AGHT+IENRaeAd88+/D1PGmX2XKnuhRemC3b9yFymdEVP2QWW29vaf+wH/UgeYGo/Dihik+an1HZ/ X-Received: by 2002:a05:6a00:2d95:b0:6e6:5551:f926 with SMTP id fb21-20020a056a002d9500b006e65551f926mr3921767pfb.29.1709818818008; Thu, 07 Mar 2024 05:40:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709818817; cv=pass; d=google.com; s=arc-20160816; b=ZKuN3orr7g6PfcVkv06+NlAP8nTFZDu4/bfVbLJjVdmlVQE+jWeSypvacJCFt37PXP 59e7QA4HdSkqM3qO97ETeEse0r8kyGm/esv/LF5PFOhi5tI5lPonn1j6vpKYq8j5fJC2 MdsEPdlBXN+bwvVKvaNtZM9DLriVxuJKiX6ShjKfWBCVAgcDcPmXEr/aPGwifjXHVhtQ Z3on2/vaC/6YfRYbc7ugHZ5fqj3K2JZlPvxOjE0M0EKUEFEckJFs1e2ohZe0NPCyVF20 duLNB1dK3HqdtXYURpeB1bcLEeS1dULK8GvVfDjRBAXmxZzid/YPG3PlriydP3OYEunz U1Jw== 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=c6rj8fYFEnjIJv5FFlM3xN4+FkDrv2q2ZcK/bisnIdY=; fh=8wcoxKk21hICD+6obVirG13fsSSMhKa/pufykSf87d0=; b=xuTIRnqA399KtPYsbLpLvtcbaIYT6nL9quR9+082tPw2dEwRz37DkptN5TJbZh/2wW KEIU8Boi4NpSIFuSdoWNeFKZOi6fIhyAihyFKO+ccBeOabTHHbdCgdSZSMj2QVkJOtV8 j+6rE6wPonyghopeOpHrA+0lCGxyuIPWPh3bwbfAJyp5gF1H6ppKQmNHu/8otf3F2Cy5 avCR7/8dZDj6zgXHpKRUVGW5a5CBRtAok5efhZ32ilvL3ETNEJ0kfj3S3ElfcpcMBAJd if9exaQysP9PLgbcQfF9pHyZ7AhQzBsp00A3ECu21d8ssijzQrdTq2GD2sOVqFOaz0C8 RU0g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FDjdQTKM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-95621-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95621-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id ay25-20020a056a00301900b006e5b55d7cd9si12492960pfb.217.2024.03.07.05.40.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 05:40:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95621-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=FDjdQTKM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-95621-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95621-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id A7DD4281B57 for ; Thu, 7 Mar 2024 13:40:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01DD112D77F; Thu, 7 Mar 2024 13:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FDjdQTKM" 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 042DF12EBE1; Thu, 7 Mar 2024 13:39: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=1709818742; cv=none; b=h2X0V2Ko+m9UZmh7LUlg3ZWDIv0yjvW0Qi8v/eZJFvfiSy9V9Sl1sBiA9c4vz8jnjyqxb922I/orMTxplDqEl2zMBQ67MQdHueht4HWGGCUnZiOZKdKGiYYEJ6mfWYiVPEgRuIZ7kmWID7OvakJbM0b4HCylf16F6mpaPHXO2Ms= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709818742; c=relaxed/simple; bh=CjIGYTbMXVCqb3XcBIX9A123T+vivJfkGlKpICpmC2k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EshYlzv7kHP0n47CogFs8TR07CczalORRSKLVOl6Z8kI5jLLx6eODSmBdRIHkHgU+GbSLvb79ps1MDt2wHJSwVAJJZRjuC3QrsHoHV0DweFsPx95vbORkJ02OByejej/e7y6tdNFqTlBy9SiSHixJSqgPDw39aDWRW/wDFpGA7s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FDjdQTKM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35BD4C43394; Thu, 7 Mar 2024 13:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709818741; bh=CjIGYTbMXVCqb3XcBIX9A123T+vivJfkGlKpICpmC2k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FDjdQTKMqAV/3AujzNU0jRIlkzmEFnvS3e9S4PJP4cu/dCQYKpQGZFEx5fFRJpDHL oAUuXymBOpQz4zBwpt1L5p48udNYDWRDiwCul//qBAQit1x3++qgOt+mxIq4atYojo 8WPX9V811iaHJQhOV34l1wXqyky0DJSi43dqE7b8ZZecy8blH/+35AUs7u6ejz0YQx ZZ7uvtvgUaUfXFQ2Au/x0JuOGT+FATTfvwrr1vzr/v2JACM9TpOoSrPINWigY+a/8o N9w85QQa1HX6AdcTygiXlMnwQby62WDuTtoDVCIyBKafPHHZPwOTUZpftEEj2JuqNV Vq45WIs5G96zg== From: Maxime Ripard Date: Thu, 07 Mar 2024 14:38:29 +0100 Subject: [PATCH v8 02/27] 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: <20240307-kms-hdmi-connector-state-v8-2-ef6a6f31964b@kernel.org> References: <20240307-kms-hdmi-connector-state-v8-0-ef6a6f31964b@kernel.org> In-Reply-To: <20240307-kms-hdmi-connector-state-v8-0-ef6a6f31964b@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 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.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=5120; i=mripard@kernel.org; h=from:subject:message-id; bh=CjIGYTbMXVCqb3XcBIX9A123T+vivJfkGlKpICpmC2k=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKkvD8dUHpr2IGVl2pScIyHSEWp3d7k/eJ6adXpSt+rax oV2bfMqOkpZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRyHRGhqcpy9ovu7K/O/D3 oV+Bk8b7/oC3gt8Krhy4pHLi2QtLHTeGv0KOr5ks13/hcNGbeMT6xVv/j4uDjAvZ2DUsCydNnVC yjA0A 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.43.2