From patchwork Thu Feb 22 18:13:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 204948 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp124481dyb; Thu, 22 Feb 2024 10:20:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXzQR/ALmWdeNsAA7jkGKlOxyyfuc5fgKc1Fy1Uots66k+dEsZ7PGsds3w0hUs2MOO/s5V0Fyc0qFipVS2WsVfq0ZqFfA== X-Google-Smtp-Source: AGHT+IGNsYZiEawnlLnK6Ho+/zJHf24Vrgr3wNT+AXxZLS+P/43Wsbq+zgL/qVzyLevIJmkT6df2 X-Received: by 2002:a05:6a21:1788:b0:1a0:ddbb:75f with SMTP id nx8-20020a056a21178800b001a0ddbb075fmr815704pzb.2.1708626023831; Thu, 22 Feb 2024 10:20:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708626023; cv=pass; d=google.com; s=arc-20160816; b=vZ112oBw1fbxRcnuly4PvAVTC3Cf98KsChYWF0EGkkhCbRQ5kiWzEBxxeDWWZPUa1P DE8a7RUckSdKtciPPoDQW75SwoS95UTgIpxZuxq5Q/YDTFrAL5Wfb9svVOQI5CFoYfLW Pxh97Y+juWgvKtEEEmRU41QfqqSTztdewvOsnBNiHS6jE1eKxowAA46+7+BTNNc2GkvZ tMcVNS3Ar9AtYT1bKd0cLqPFqIpZxIlrlcqgN9aVz9VNcB89llLR3/YKEavItlKjj97R KX7Y7i7KdEsSz8xNRTDLrovkYijCXrdQSH1cUvQ1/QGabn5GI+CKna/EyWkojB2gBs+4 pSgg== 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77076-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s28-20020a63925c000000b005dc855c40a4si10784020pgn.645.2024.02.22.10.20.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:20:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77076-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77076-ouuuleilei=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 95DE1283CC1 for ; Thu, 22 Feb 2024 18:20:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 06443163A89; Thu, 22 Feb 2024 18:14:52 +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 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?b?VmlsbGUgU3lyasOkbMOk?= , 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791624241386497078 X-GMAIL-MSGID: 1791624241386497078 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 );