Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp512153rdb; Thu, 22 Feb 2024 10:19:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVph8Ma0U2JyGvKtY+wLWlzHJKhIZN4au53ZcaCJpxrJ3LZcJs6iBHUmR6JJqe31GKUWd1hyOKXKkUFcOjJyW1Uww16n2sxf+zVTOFkAw== X-Google-Smtp-Source: AGHT+IE1cSUXg3XXb+Fbndh36BLJh+87sMsM8dxYtzqtxbm8/IR150cAwyIf6KryvY1IrZKw8j1W X-Received: by 2002:a05:6a20:ce4a:b0:19e:b6da:da1b with SMTP id id10-20020a056a20ce4a00b0019eb6dada1bmr4508835pzb.4.1708625984347; Thu, 22 Feb 2024 10:19:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708625984; cv=pass; d=google.com; s=arc-20160816; b=EiHYes31byWj4kR4SXDjSADNrF8rV2JwRdyyjHQJdj2tq/YWprHg2QvSAMnU6soh5R 8Hqq+L+/T2XwsSLvXXGo490ycokIkwot5YtGw8c7qx3h00ggUkkm4PwK5Iu/JH5WI8mi Q/4RMDa32Q/14qidq/tuQVh/rcFtUHkEYr8E3Yi7X8LcvGaNHTqZ5p2WlIhDuRYbUVvP c1ArOtwZjhIlUjo1Jn/6QiLIX7fxCVnBlJZpUBzDJCS0bB5HnbdzOgSOWmCaaVtE0y0q 2D08E7zrg+vhpa9iQYuadjzzTESbwAFXgH/3mKNCo3rIhx1Ev+MaQ0ZHsAFnylei3OKj iJuQ== 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=/g0uBO0LG+TGLa9P6ILFpKyw+iTt81TCRIuyctMLaMg=; fh=8wcoxKk21hICD+6obVirG13fsSSMhKa/pufykSf87d0=; b=FHO2NFzOJwgIZq7CcuKswp2r9c6C2fbKRxvNsHpyMwMSJ++TyDdlmznYknnD4Dv/OC BiMsF+BB5S3ozpu2EKps/42n/8HGE9N+XPk321+CT/mkIJ3xmHFTmAZyVDtN8m/fRJkz rLiAm12NZTYS+DFuI/kF6e+4e5OUAUlCuUvifVVNqQaY6fHZvLSHcehn3YtQRqziF5bH kEOjiM1ntjKCUMy2a+G1wQ20LfLhMXewhBPk6ctOU7CEq58YLuzMeQNEYOtKNLljSmAH a3qiQTK5XAut+TAaecdL8jUj0KuTie4BOSdsMDcFDPy+V8oD1PKAf7b/GEC+FeK5Yn3r ozcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="ZsBjIOY/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-77076-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77076-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 m125-20020a633f83000000b005dc48253292si10551744pga.268.2024.02.22.10.19.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:19:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77076-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="ZsBjIOY/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-77076-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77076-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 0C3C6281A38 for ; Thu, 22 Feb 2024 18:19:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D5D2815F320; Thu, 22 Feb 2024 18:14:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZsBjIOY/" 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 C77EE15E5D0; Thu, 22 Feb 2024 18:14:48 +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=1708625688; cv=none; b=lskR57LtLHufl8A/CYXt5v2IzxysP8VZdZ8gB4gcJ3skZTQqLt9fEDZp3ZNGsteUW9Fk73a2oqMl7KxArF25GSLIEm/YfT1wUGKcJewxoFVpjFI87Yx/kwb5La4oQRMMyZMsDrjkssvAuGGQyvtNcslYD1psMQv1NHijSLolTMc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708625688; c=relaxed/simple; bh=aMMsGSd3iTeiTa5R3x1EcUbWFB61oRzNzaAaKePtu+0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tiF8UfFvCWp/xsSzGTyqpX8/Zpbk/StW8EKUHlJ2qJ3H3c7m/vIK3ga+pTsTXPcG/W0DridFWpteTAnpHY6F6EInCs4msJHtI6Z9jPew0CM3j1y+5cmrcYyByN6TWU/oeKf31fcl+mUcOpOYkIkHhaW/oz9P4jsyZfq2AWJFEtk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZsBjIOY/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBE5AC43399; Thu, 22 Feb 2024 18:14:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708625688; bh=aMMsGSd3iTeiTa5R3x1EcUbWFB61oRzNzaAaKePtu+0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ZsBjIOY/uJP7kxAZQ6u7lhEhsV0Xt6R0OdKFwHcru2XK0hGXZxupuxo2jmRd9rHMb 5KzeNNmy0pX/XWKuPQkvqa90l7bu3xUruGKqWRMKDmrArG736LXsw/TSFI0q0hN/8D iNoLNA9X2P7f9K5CvAchb8T+kxUoWoND9tBuUN8zHui17Sc6uhKYeWUbeeSGWn/JsX qZNHnx/1hxCoRMKowH8VbvZfQyEVVHKy0FPm7zktJYKgmZVqMMMEADP0pWzsq8cvBB sfD0q+fbNlaAMxr2+hEQz+ItZvhhv070Y2Z1QwshkFpYWOvt9de9kKKegFRlYPJrxk qhtgYOZ52yDLw== From: Maxime Ripard Date: Thu, 22 Feb 2024 19:13:53 +0100 Subject: [PATCH v7 07/36] 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: <20240222-kms-hdmi-connector-state-v7-7-8f4af575fce2@kernel.org> References: <20240222-kms-hdmi-connector-state-v7-0-8f4af575fce2@kernel.org> In-Reply-To: <20240222-kms-hdmi-connector-state-v7-0-8f4af575fce2@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=4892; i=mripard@kernel.org; h=from:subject:message-id; bh=aMMsGSd3iTeiTa5R3x1EcUbWFB61oRzNzaAaKePtu+0=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKnX+97GSvXVP1eaYbtU+85vvdV15+3aToe+Of9I6MLyL y/slFN4OkpZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRU8IM/4umBEf4RChuLeRm WyMceeLJlCuWQToLN3IKcn4v93+mlM/w36NsaqZYWZ7+IvY3bYLLH7THlpwsVT9wv9GFV8/kxpo 8PgA= 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 a268847be8d1..8f070cacab3b 100644 --- a/drivers/gpu/drm/tests/drm_connector_test.c +++ b/drivers/gpu/drm/tests/drm_connector_test.c @@ -172,6 +172,128 @@ static struct kunit_suite drmm_connector_init_test_suite = { .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; @@ -236,6 +358,7 @@ static struct kunit_suite drm_get_tv_mode_from_name_test_suite = { }; kunit_test_suites( + &drmm_connector_hdmi_init_test_suite, &drmm_connector_init_test_suite, &drm_get_tv_mode_from_name_test_suite ); -- 2.43.2