Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2071626lqb; Mon, 27 May 2024 07:05:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVAjoqkfMjq4FNIzaWo81FwM8R+oSTXWm59Vbayhud9CeakEwR0H0VAFR6CpWv88V2NlVg9RQ66Th1IrJL/rRUSHQe/U1RVN8n8b2sDbw== X-Google-Smtp-Source: AGHT+IECkHgel2jwFEc1LBIHh8W+0vt17sTw6jqAMucZYqAE80/xpkgpGhzl1hYPqRfYHVs2+wRP X-Received: by 2002:a05:6a00:f90:b0:6ed:60a4:6d9c with SMTP id d2e1a72fcca58-6f8f2c6147emr10397929b3a.4.1716818720371; Mon, 27 May 2024 07:05:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716818720; cv=pass; d=google.com; s=arc-20160816; b=trjXcgSAnOecJ4+DgfNSSOHjkaVEKFgKUkS3NC7I+r5LBYGMEkgKXTpsY1XWqmOAHL TV+SktlCkPxhOrEIwEhS3+/+EGBlJogs2f4Y57wnlrkTCwMKkl6pmX27Lcw87VqTvoYX Ta3ya8iH/oQF7vtoSyPNTnk/YSkdL3JSwhdxKTByDJ29e+IhFum+guZr59WhLHCzmCTB ndTgbOUHH864zf37K3q4nYnY+w6Se1ssPu60ZQRfmLDBVqCbZhTyoADqm3A5h4xrNvFL 1jA/gRsBgLCE6/aQHZE4U3P7YhEuX5IdtRa/1oA5sl4kMpNydUHenV+IzQPeXY0Mdqay 21AQ== 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=5FJT/eRTxX6loLnEQ/0Y1VXnm7zvCAiCNNiDzvwtuMo=; fh=Rmvm45DLBttDXPZ7ZQBINOOM6/ese2BHFaa7wD2L3jc=; b=ucjl6w3+nrfq7Alia46qz1qDr4NWr+IpexXd6uC9Tb2ryMYFenFBiAbffWP/jWgPUy HMbA5rrueW54hgiHIAyv4LhvkZsK3stdJN8G+Tj4zlTXQAxG2nvzn0Kev+l07dr1b7VO OnfmIddhfoOHTPThY81pRdzqWeL5t1yjtb7n8S3RWQNHoTvUXQ7oR6g4ZNLFq5FoQAfX rRJjbX/vKT2zjvQx/ezENPV2Sin0rLKOuTv2Cxn8ReMXlG37OI8d+N+98eupiN+6IURy sCXDwb5nRtqc0/4l3320g5yZK5gUkMFBs640Ekd15WzVGafp1nO28VqPx9Wh/4Gf9kGQ 1dzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=A5t1oU+F; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190771-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190771-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 d2e1a72fcca58-6f8fcfd8ac3si6090509b3a.195.2024.05.27.07.05.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:05:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190771-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=A5t1oU+F; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190771-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190771-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 08159284318 for ; Mon, 27 May 2024 14:01:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6645A16190C; Mon, 27 May 2024 13:58:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="A5t1oU+F" 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 33E89161325; Mon, 27 May 2024 13:58:31 +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=1716818311; cv=none; b=DwbglhG1f3vi+uiUtd+mB4JWYQhojMseTKxiFkwdeJxKvXOFJVSZDFcjrlEXfb73WUXCjNlJbc/GTz9Q+JbyQld6BRrfGHDLU4Z6MON97TGEMtoma2gEczw2kgbZMemPyNw60x7ILRuGq67juvv+HhqnH042XXYGa8WWCjj7rnY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716818311; c=relaxed/simple; bh=SOQPfNrUwyqfTmtStDudqnm+AIbryO28dU1DQhlSVNA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fvHtiTPPGQiB38GD/HbMBzL0xZb0m+2lBiv0WuX1WRN+rKB8OLjNDn3Vr6HUBH5yFHdLXTUey+DZyoD+QDr9VJWVFi2nCTbP7PPCQxlyNKg926dwzKH+fQmRQ7HqWqeaWKsMoixuk0ckp5ozWXGsxcVi6+TJj8y/fYVZ2tz+EEE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=A5t1oU+F; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91C48C4AF08; Mon, 27 May 2024 13:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716818311; bh=SOQPfNrUwyqfTmtStDudqnm+AIbryO28dU1DQhlSVNA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=A5t1oU+Fa3Jeawwrep/wT9yuKMMZ2wZoE965Z9B4b2FiXwC3x3QQxH2KQs9jXizyZ gnfpnzuN81RwA4EmaEZ3R/PGpHizbAwh+yv12DrWlmfC0EOBsWD56qsM4SReyzgpfZ ARxmx88hFYkrCP6YfmmTHh+aGeZtilz6Nt0ASGbyFdY02fmGrfo9QAoTJH0AVVTQVL imY7fZSpcshW3gbZdhrYx5C+B4+HmutroOgftsjRsH6bUGCT3HfQOd9fdsJPSSxreN hIwZBYfsmzVjKe+T5pmClCemDwccLYwKU2CLOS0iy6GUueD7Yia2dAevq1ywVv891R +58pnbUYiHRGg== From: Maxime Ripard Date: Mon, 27 May 2024 15:57:57 +0200 Subject: [PATCH v15 08/29] 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: <20240527-kms-hdmi-connector-state-v15-8-c5af16c3aae2@kernel.org> References: <20240527-kms-hdmi-connector-state-v15-0-c5af16c3aae2@kernel.org> In-Reply-To: <20240527-kms-hdmi-connector-state-v15-0-c5af16c3aae2@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 , Dmitry Baryshkov X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8085; i=mripard@kernel.org; h=from:subject:message-id; bh=SOQPfNrUwyqfTmtStDudqnm+AIbryO28dU1DQhlSVNA=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGkhE5Mn371k9kp7FdMnvqUOf9Y4p+7J6Ty+pz/y+NRty 6viDx3e0zGVhUGYk0FWTJHliUzY6eXti6sc7Ff+gJnDygQyhIGLUwAmMmkqY30OW7+EXrrz9p7t m5OVVOInP94uo7U0btrKk8mH5gWwJ5Xzr530IYBr+fSH8ZwVJ5qf/mJs2LS/7LvNrZrP23tWMwh +tl7jqeh9vaJx6rukgI6Zpq+OXDpq90r+v+O27ueNR7rPF6beAAA= 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 Reviewed-by: Dmitry Baryshkov Signed-off-by: Maxime Ripard --- drivers/gpu/drm/tests/drm_connector_test.c | 99 +++++++++++++++++++++- drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c | 32 +++++++ 2 files changed, 130 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tests/drm_connector_test.c b/drivers/gpu/drm/tests/drm_connector_test.c index 37e6efd46d7e..250348ddfa70 100644 --- a/drivers/gpu/drm/tests/drm_connector_test.c +++ b/drivers/gpu/drm/tests/drm_connector_test.c @@ -361,10 +361,46 @@ static void drm_test_connector_hdmi_init_bpc_12(struct kunit *test) prop = priv->drm.mode_config.hdr_output_metadata_property; KUNIT_ASSERT_NOT_NULL(test, prop); 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. */ static void drm_test_connector_hdmi_init_type_valid(struct kunit *test) @@ -446,10 +482,12 @@ static struct kunit_case drmm_connector_hdmi_init_tests[] = { KUNIT_CASE(drm_test_connector_hdmi_init_bpc_8), KUNIT_CASE(drm_test_connector_hdmi_init_bpc_10), 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), KUNIT_CASE_PARAM(drm_test_connector_hdmi_init_type_invalid, drm_connector_hdmi_init_type_invalid_gen_params), @@ -523,13 +561,72 @@ static struct kunit_case drm_get_tv_mode_from_name_tests[] = { 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, }; +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 "); MODULE_LICENSE("GPL"); diff --git a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c index 333c81b8cf4f..8bc1f9b0b12b 100644 --- a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c +++ b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c @@ -347,10 +347,19 @@ 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. + */ { } }; static struct kunit_suite drm_atomic_helper_connector_hdmi_check_test_suite = { .name = "drm_atomic_helper_connector_hdmi_check", @@ -427,14 +436,37 @@ static void drm_test_check_bpc_12_value(struct kunit *test) KUNIT_EXPECT_EQ(test, conn_state->max_bpc, 12); KUNIT_EXPECT_EQ(test, conn_state->max_requested_bpc, 12); 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), { } }; static struct kunit_suite drm_atomic_helper_connector_hdmi_reset_test_suite = { .name = "drm_atomic_helper_connector_hdmi_reset", -- 2.45.0