Received: by 2002:a05:7412:798b:b0:fc:a2b0:25d7 with SMTP id fb11csp513753rdb; Thu, 22 Feb 2024 10:22:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVNhyzA/4ANyFOCgKV/j7Mykyv9OSyBH7sJQBH/SBIg2e+86KeMLp+OXS3D9b1zdb5ge+3nDfeSQMe9OT97bDZ/rdGQV4kT63DA4QOfLg== X-Google-Smtp-Source: AGHT+IGF25U510sVxA2zHFEJJyjaeirxNSRvRVoUFitHwA6WuuumKjSWC4ZatOTkggXmAtI/q+KL X-Received: by 2002:a17:903:110c:b0:1d9:a2b1:8693 with SMTP id n12-20020a170903110c00b001d9a2b18693mr26617650plh.23.1708626168340; Thu, 22 Feb 2024 10:22:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708626168; cv=pass; d=google.com; s=arc-20160816; b=Mj9niHTXMGfFCX+V6gOYtT765gVnwyJ6UiLNuH4ED3cEAyEKO+dgiDP2/NBoADKoql 8crwC1NS04M0eYLUBnJLjKyGq20dOdgnkim3dhv5Pgbfg8DTgtuCJYPxb9sYsiWumC6Y hZXOAanaHWCrWkmbS7aPIxBsV5dSd4LOEml4amSlJMy2Kx54KBAii/rLdfiQJi36Sd0F JgLHZv/LUsAuHrYNM7YvjVZAnddLvfP71i0GsKu17y3Qv8LZYNEGvfHU0kC92JlS8P1B BGli2G08ceZFO4ddSuy9F2S6/i+QKX9nQ73N05eBYfxG6ZeNXO0919KkEN6lxQFu1fPK us7g== 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=gujZOU2pwvxo+dyJ8DOtVEZvw7pjQXhi2g7E92ndXhw=; fh=8wcoxKk21hICD+6obVirG13fsSSMhKa/pufykSf87d0=; b=v+kIUMXs4EOYiaMCkab4oiv/MTzZ5zX6qHDmnoBx8CIRt9p8Hu+MAHu/ThUJMhoOen KanRoXzvgW80cnS0YtvD5LHMZi2MJHLzcTi2RdZjXRemoSXRd0vPRA5emwc36ANWJxY0 3lG+2IX68mjQqk8B7T/r1RRSKeorxjhuHQAANs9csF1Br5SjwkbV+yp4vokt1fhuwddV Zgt24FjtTSfDgIvrdnnfwV1lFXjT9ARoZw41dIKyssGY+QLbhE66UGugD0M+cOGaDYcJ TsXb8I1AHOeqQNyrbPk3Mwf4vTniMN1A4wTALZ4jT3eZo+2ogUZQ6iNnwuPMO1cDQHbx 9Yjg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=o3rLDusK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-77089-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77089-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. [139.178.88.99]) by mx.google.com with ESMTPS id p7-20020a170903248700b001d92086fe43si10485908plw.436.2024.02.22.10.22.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:22:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77089-linux.lists.archive=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=o3rLDusK; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-77089-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77089-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 0A356284CF1 for ; Thu, 22 Feb 2024 18:22:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 183F312D1E8; Thu, 22 Feb 2024 18:15:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="o3rLDusK" 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 94E7B73F1C; Thu, 22 Feb 2024 18:15:02 +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=1708625702; cv=none; b=uOr+oQhASNwiOMrgmrzc/XzTH3J3NDcHx1m1Si0EUO+IVR94I3QVAogChsP5XK6+zEAhKL9mzNl0dY2ac6a91sEuDLfCP5dqMlO0BpaDisZszrL5BJ7oxQ5ROlWJL6b8ypreAZj1MSPrdGxisQAFeFgtIynr2IeVrQlD6E1ZDNE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708625702; c=relaxed/simple; bh=35dEQopjUt6A2W23PQkFev/rOQ1owYxpUGVppcAXPW8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=S31slbDrtuqPvPwpnvS+8x5zD/CoWFVczkdZX1GT8+Y+mv6ltXr3U6CMxsa+xFABQgElK8ZTQHk3Mgrk2AOGNfAh3Tz2/jgU48mt/daN9jCRlnPwWhh5699TRYukFuKFC3pi6ycz/NT1QcchJhN5PiMzpIugl2HSkDgGbYBnKNo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=o3rLDusK; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 179C3C433F1; Thu, 22 Feb 2024 18:15:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708625702; bh=35dEQopjUt6A2W23PQkFev/rOQ1owYxpUGVppcAXPW8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=o3rLDusK1Vw0bjrO7qrIF4iJhbGDg6FozAm37wlI3AQmiuDM+fhZG/H0OLsrCBKpf tZA618Fds6vgfNxYnNBDhULGM98xbvKCbsrEoiHHPH4Psu2/yuFiGyHfKGYW9l0+Xi pqnFHKUjnMpSXxjmJvoQH2VebiaDN14iL0B+WFogkGHkJakkD+6/r/w3UNok18r3fH UeFsZN6/NVvbJQmK85+UspdD4daU35QqqkxLOhi6EvVgW6xPTXi+KM0A1ysI0QOcyK XJfXQFHlOZkgW30Oh0xK6oUZIEAEedT8hknOjurXc/f37ynF3QnJx5HK0yvz9DTqiP 4AL66vAYjgGlQ== From: Maxime Ripard Date: Thu, 22 Feb 2024 19:13:58 +0100 Subject: [PATCH v7 12/36] drm/tests: Add output formats tests 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-12-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=7105; i=mripard@kernel.org; h=from:subject:message-id; bh=35dEQopjUt6A2W23PQkFev/rOQ1owYxpUGVppcAXPW8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKnX+z7oCuXVxn849X/rxa/77958NnPOD/nqxveX/rdzT JhzlP/D7Y5SFgYxLgZZMUWWGGHzJXGnZr3uZOObBzOHlQlkCAMXpwBMxN6A4Q+HQc3NaV4KAbWT w5Vk1c73LdwVVnXsfX6T3oxXzj3FTGUM//NzLl42vJhwqpdTTsq1kHF/cxnbKhPtwu5LCpF8Iq/ kGQE= X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Now that we track the HDMI output format as part of the connector state, let's add a few tests to make sure it works as expected. Reviewed-by: Dave Stevenson Signed-off-by: Maxime Ripard --- .../gpu/drm/tests/drm_atomic_state_helper_test.c | 32 +++++++ drivers/gpu/drm/tests/drm_connector_test.c | 99 +++++++++++++++++++++- 2 files changed, 130 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tests/drm_atomic_state_helper_test.c b/drivers/gpu/drm/tests/drm_atomic_state_helper_test.c index a129ea5f014c..1c3dd8a98fb0 100644 --- a/drivers/gpu/drm/tests/drm_atomic_state_helper_test.c +++ b/drivers/gpu/drm/tests/drm_atomic_state_helper_test.c @@ -347,6 +347,15 @@ static void drm_test_check_output_bpc_crtc_mode_not_changed(struct kunit *test) static struct kunit_case drm_atomic_helper_connector_hdmi_check_tests[] = { KUNIT_CASE(drm_test_check_output_bpc_crtc_mode_changed), KUNIT_CASE(drm_test_check_output_bpc_crtc_mode_not_changed), + /* + * TODO: We should have tests to check that a change in the + * format triggers a CRTC mode change just like we do for the + * RGB Quantization and BPC. + * + * However, we don't have any way to control which format gets + * picked up aside from changing the BPC or mode which would + * already trigger a mode change. + */ { } }; @@ -427,10 +436,33 @@ static void drm_test_check_bpc_12_value(struct kunit *test) KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_bpc, 0); } +/* + * Test that the value of the output format property out of reset is set + * to RGB, even if the driver supports more than that. + */ +static void drm_test_check_format_value(struct kunit *test) +{ + struct drm_atomic_helper_connector_hdmi_priv *priv; + struct drm_connector_state *conn_state; + struct drm_connector *conn; + + priv = drm_atomic_helper_connector_hdmi_init(test, + BIT(HDMI_COLORSPACE_RGB) | + BIT(HDMI_COLORSPACE_YUV422) | + BIT(HDMI_COLORSPACE_YUV444), + 8); + KUNIT_ASSERT_NOT_NULL(test, priv); + + conn = &priv->connector; + conn_state = conn->state; + KUNIT_EXPECT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); +} + static struct kunit_case drm_atomic_helper_connector_hdmi_reset_tests[] = { KUNIT_CASE(drm_test_check_bpc_8_value), KUNIT_CASE(drm_test_check_bpc_10_value), KUNIT_CASE(drm_test_check_bpc_12_value), + KUNIT_CASE(drm_test_check_format_value), { } }; diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c index a9a57cb23235..5bff67fbed87 100644 --- a/drivers/gpu/drm/tests/drm_connector_test.c +++ b/drivers/gpu/drm/tests/drm_connector_test.c @@ -348,6 +348,42 @@ static void drm_test_connector_hdmi_init_bpc_12(struct kunit *test) KUNIT_EXPECT_NOT_NULL(test, drm_mode_obj_find_prop_id(&connector->base, prop->base.id)); } +/* + * Test that the registration of an HDMI connector with no supported + * format fails. + */ +static void drm_test_connector_hdmi_init_formats_empty(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, + 0, + 8); + KUNIT_EXPECT_LT(test, ret, 0); +} + +/* + * Test that the registration of an HDMI connector not listing RGB as a + * supported format fails. + */ +static void drm_test_connector_hdmi_init_formats_no_rgb(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, + BIT(HDMI_COLORSPACE_YUV422), + 8); + KUNIT_EXPECT_LT(test, ret, 0); +} + /* * Test that the registration of an HDMI connector with an HDMI * connector type succeeds. @@ -433,6 +469,8 @@ static struct kunit_case drmm_connector_hdmi_init_tests[] = { KUNIT_CASE(drm_test_connector_hdmi_init_bpc_12), KUNIT_CASE(drm_test_connector_hdmi_init_bpc_invalid), KUNIT_CASE(drm_test_connector_hdmi_init_bpc_null), + KUNIT_CASE(drm_test_connector_hdmi_init_formats_empty), + KUNIT_CASE(drm_test_connector_hdmi_init_formats_no_rgb), 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), @@ -510,10 +548,69 @@ static struct kunit_suite drm_get_tv_mode_from_name_test_suite = { .test_cases = drm_get_tv_mode_from_name_tests, }; +struct drm_hdmi_connector_get_output_format_name_test { + unsigned int kind; + const char *expected_name; +}; + +#define OUTPUT_FORMAT_TEST(_kind, _name) \ + { \ + .kind = _kind, \ + .expected_name = _name, \ + } + +static void drm_test_drm_hdmi_connector_get_output_format_name(struct kunit *test) +{ + const struct drm_hdmi_connector_get_output_format_name_test *params = + test->param_value; + + KUNIT_EXPECT_STREQ(test, + drm_hdmi_connector_get_output_format_name(params->kind), + params->expected_name); +} + +static const +struct drm_hdmi_connector_get_output_format_name_test +drm_hdmi_connector_get_output_format_name_valid_tests[] = { + OUTPUT_FORMAT_TEST(HDMI_COLORSPACE_RGB, "RGB"), + OUTPUT_FORMAT_TEST(HDMI_COLORSPACE_YUV420, "YUV 4:2:0"), + OUTPUT_FORMAT_TEST(HDMI_COLORSPACE_YUV422, "YUV 4:2:2"), + OUTPUT_FORMAT_TEST(HDMI_COLORSPACE_YUV444, "YUV 4:4:4"), +}; + +static void +drm_hdmi_connector_get_output_format_name_valid_desc(const struct drm_hdmi_connector_get_output_format_name_test *t, + char *desc) +{ + sprintf(desc, "%s", t->expected_name); +} + +KUNIT_ARRAY_PARAM(drm_hdmi_connector_get_output_format_name_valid, + drm_hdmi_connector_get_output_format_name_valid_tests, + drm_hdmi_connector_get_output_format_name_valid_desc); + +static void drm_test_drm_hdmi_connector_get_output_format_name_invalid(struct kunit *test) +{ + KUNIT_EXPECT_NULL(test, drm_hdmi_connector_get_output_format_name(4)); +}; + +static struct kunit_case drm_hdmi_connector_get_output_format_name_tests[] = { + KUNIT_CASE_PARAM(drm_test_drm_hdmi_connector_get_output_format_name, + drm_hdmi_connector_get_output_format_name_valid_gen_params), + KUNIT_CASE(drm_test_drm_hdmi_connector_get_output_format_name_invalid), + { } +}; + +static struct kunit_suite drm_hdmi_connector_get_output_format_name_test_suite = { + .name = "drm_hdmi_connector_get_output_format_name", + .test_cases = drm_hdmi_connector_get_output_format_name_tests, +}; + kunit_test_suites( &drmm_connector_hdmi_init_test_suite, &drmm_connector_init_test_suite, - &drm_get_tv_mode_from_name_test_suite + &drm_get_tv_mode_from_name_test_suite, + &drm_hdmi_connector_get_output_format_name_test_suite ); MODULE_AUTHOR("Maxime Ripard "); -- 2.43.2