Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2853998lqt; Tue, 23 Apr 2024 03:51:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUHFhepJRb9DBl3yj+oVjJuyIWQStw+dxhI+dxzYDpQDkmEQHK3m3Fm7F58S9WZflQs9nsroBfsQDpLguwut6dLF4pE8cXH76NAqyFLkg== X-Google-Smtp-Source: AGHT+IE0E6zq+hmFx8/Z2xCB7VCMAz0az4pxn79fKcyc48BPgKEsVqSYKrHIBUr8CEM/z4d2awAN X-Received: by 2002:a05:6870:e99:b0:222:1353:ad0f with SMTP id mm25-20020a0568700e9900b002221353ad0fmr16915695oab.24.1713869508470; Tue, 23 Apr 2024 03:51:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713869508; cv=pass; d=google.com; s=arc-20160816; b=H6M+af+i1fTWIoV4JuuQvobjdf8jB0pb2Wo5Ytd3PfAngSXLr8HugnyRw/vUPazLxc 5JtmhaHKS+C8JhRCvVFKEyaH14iu17v40JWUaii/my74m8/5qgvbJr6r8SVDZR6bX3NK KDMi9S3tXDN5sQ5cwucv/kcGPT534IfI4B7bNTyqIqc5Cm1qle6m6bjjlAw49u1/8iky phBgZKjBevHXx1nQkTWgJE9MN3H7qUaaoNFQEYfF3ckKVtAOnfBcrTGWaZ/ruFZlY5zc 09YgkHnZud7XNr6gLiesZvoK3ZeM7qtzfqDu6VU/9koiTiiQ6a9Ima+SD7sKpHjcOeUd /mmA== 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=+jR72HXZCt59nXicEfvdfY9LNS3f9VWTzv+U7LRePgw=; fh=ufmwd8Wo0DI+kdMOJWC7ZXqsyLxoMBbO0En/E/GApYU=; b=mp2ZLNyMTPEBXI7MAoi/YZ5Ovm6N/etE9Wr75f9YoJuGirXrzRJN/flw2FgQ3c1EnL rAY9g3gSH/7I2cMbaxqYCLex1rgZLIDJglytDc7GUG35XTlapwbhLNEzty3mL1IWuAkt iMD3/RkIBXkoiHTpWUkT7CyYShi0PXqaW+DaywD4JNRl3JORkrcKR3RbgSschB28JpNT uxuVKB5Zk1216sTp4NsPwbqcaMLZN+8YrBbXPIrDQiwDLUBRfKbBhS4hK7LZ5vECal4q EUxu9W4CvmULbJaw+NYOrZrjlCzkL1MaaS0VyJ975g6JI0fkOhI28Gkch9irJZpLLmFa 5a/Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="XdE6M/Kn"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-154906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154906-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i5-20020a654845000000b005e2b1c99876si9824839pgs.336.2024.04.23.03.51.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 03:51:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-154906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="XdE6M/Kn"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-154906-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-154906-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 68EC4B233C9 for ; Tue, 23 Apr 2024 10:49:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 64AA71350E3; Tue, 23 Apr 2024 10:46:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XdE6M/Kn" 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 6401F7E578; Tue, 23 Apr 2024 10:46:25 +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=1713869185; cv=none; b=HmWokVpxjfdrZ+t8ermxCZ8tyLx9U5MZ18TxnXhbzJmrfAtMMD1nicWEztl4k5aghKbt8J0NTbBDlp7H0HKbooYlWlWw5u1cqVxzLv/koRnPqlK6mI4NFa3wZ+4xVCbS4I0C12Sv+gD5jrORvLwLzvEcrBbswC+5QAPTMXpuGtU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713869185; c=relaxed/simple; bh=4FqKEC1+UI2XcGJzlV1QQTKmPBIXGNh44kXEkVbDjO4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IIY6uytQfa9NHIPlkGBo3UZvDgyNNuciIBwNckm9JyBbwEvMYwr+45Dez4AP8/398FOtXFfheQXR5aKR0VvVjcECldrt2oZ3TAsfiHVcNEOR3kTJSSod4hZNjsfOkXnH6gEd/X+h3DLb9bOwKbEVf49n7Mbr2EE97HxYsiU3SRc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XdE6M/Kn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E74FCC3277B; Tue, 23 Apr 2024 10:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713869185; bh=4FqKEC1+UI2XcGJzlV1QQTKmPBIXGNh44kXEkVbDjO4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XdE6M/Kn+CV+h3RcNHZq/R/Wpzyz5ltmjpp/9V1rT+DoxiqPW+wS7jQj0GRHWNApX gJiPB0OTWWSHWWNW62XDlwNXVJ5tY9j+UHzd8NChhzWVDoqQhJsP7HUcCG0TrbvST5 bFfkN3nO+WZ+eshnw/F/pCEcKZq6UM0OEReTz5xZzoG1NIH6NRwXUiB0hiPDebFYiQ 3AxZgj0xwdQ1ZuKas/qyMu8MhRnyNILH68If26qv20oQuYpzHywCD/cUW0+ixmHImQ ob0H6R/v2LSAuqJ75gvlzQRYqaQ3RXzu3hu92QP+dirUzJwkH7vdsWQesHNC1xpzLv a6HcEiLOeGYTQ== From: Maxime Ripard Date: Tue, 23 Apr 2024 12:45:43 +0200 Subject: [PATCH v12 14/28] drm/tests: Add HDMI connector rate filter hook 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: <20240423-kms-hdmi-connector-state-v12-14-3338e4c0b189@kernel.org> References: <20240423-kms-hdmi-connector-state-v12-0-3338e4c0b189@kernel.org> In-Reply-To: <20240423-kms-hdmi-connector-state-v12-0-3338e4c0b189@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 X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3898; i=mripard@kernel.org; h=from:subject:message-id; bh=4FqKEC1+UI2XcGJzlV1QQTKmPBIXGNh44kXEkVbDjO4=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGnqEwNqetXNUqyaWeOT7loaLvJ/97paWr3wyaZHi7cWF SVcKZnRMZWFQZiTQVZMkeWJTNjp5e2LqxzsV/6AmcPKBDKEgYtTACZygJWx4Vclr3Xndg3V1ZZP z/YkS3Yd6D+QcKpZ7/NauZSSf5PDeJvWfDY15lpkuzSV9WCeLsshxvrc5k2fl1xWXrEoYm6WkMC lDY4BM3Ytrsz7bFPhWcbWIXZt8Q6lkMs6JkIPzunNkTa8qgsA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D The previous patch adds a new hook for HDMI connectors to filter out configurations based on the TMDS character rate. Let's add some tests to make sure it works as expected. Reviewed-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) 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 7f9a48902db4..ead998a691e7 100644 --- a/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c +++ b/drivers/gpu/drm/tests/drm_hdmi_state_helper_test.c @@ -113,10 +113,22 @@ static int set_connector_edid(struct kunit *test, struct drm_connector *connecto } static const struct drm_connector_hdmi_funcs dummy_connector_hdmi_funcs = { }; +static enum drm_mode_status +reject_connector_tmds_char_rate_valid(const struct drm_connector *connector, + const struct drm_display_mode *mode, + unsigned long long tmds_rate) +{ + return MODE_BAD; +} + +static const struct drm_connector_hdmi_funcs reject_connector_hdmi_funcs = { + .tmds_char_rate_valid = reject_connector_tmds_char_rate_valid, +}; + static int dummy_connector_get_modes(struct drm_connector *connector) { struct drm_atomic_helper_connector_hdmi_priv *priv = connector_to_priv(connector); const struct drm_edid *edid; @@ -491,11 +503,64 @@ static void drm_test_check_tmds_char_rate_rgb_12bpc(struct kunit *test) KUNIT_ASSERT_EQ(test, conn_state->hdmi.output_bpc, 12); KUNIT_ASSERT_EQ(test, conn_state->hdmi.output_format, HDMI_COLORSPACE_RGB); KUNIT_EXPECT_EQ(test, conn_state->hdmi.tmds_char_rate, preferred->clock * 1500); } +/* + * Test that if we filter a rate through our hook, it's indeed rejected + * by the whole atomic_check logic. + * + * We do so by first doing a commit on the pipeline to make sure that it + * works, change the HDMI helpers pointer, and then try the same commit + * again to see if it fails as it should. + */ +static void drm_test_check_hdmi_funcs_reject_rate(struct kunit *test) +{ + struct drm_atomic_helper_connector_hdmi_priv *priv; + struct drm_modeset_acquire_ctx *ctx; + struct drm_atomic_state *state; + struct drm_display_mode *preferred; + struct drm_crtc_state *crtc_state; + struct drm_connector *conn; + struct drm_device *drm; + struct drm_crtc *crtc; + int ret; + + priv = drm_atomic_helper_connector_hdmi_init(test, + BIT(HDMI_COLORSPACE_RGB), + 8); + KUNIT_ASSERT_NOT_NULL(test, priv); + + ctx = drm_kunit_helper_acquire_ctx_alloc(test); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, ctx); + + conn = &priv->connector; + preferred = find_preferred_mode(conn); + KUNIT_ASSERT_NOT_NULL(test, preferred); + + drm = &priv->drm; + crtc = priv->crtc; + ret = light_up_connector(test, drm, crtc, conn, preferred, ctx); + KUNIT_ASSERT_EQ(test, ret, 0); + + /* You shouldn't be doing that at home. */ + conn->hdmi.funcs = &reject_connector_hdmi_funcs; + + state = drm_kunit_helper_atomic_state_alloc(test, drm, ctx); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, state); + + crtc_state = drm_atomic_get_crtc_state(state, crtc); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, crtc_state); + + crtc_state->connectors_changed = true; + + ret = drm_atomic_check_only(state); + KUNIT_EXPECT_LT(test, ret, 0); +} + static struct kunit_case drm_atomic_helper_connector_hdmi_check_tests[] = { + KUNIT_CASE(drm_test_check_hdmi_funcs_reject_rate), KUNIT_CASE(drm_test_check_output_bpc_crtc_mode_changed), KUNIT_CASE(drm_test_check_output_bpc_crtc_mode_not_changed), KUNIT_CASE(drm_test_check_tmds_char_rate_rgb_8bpc), KUNIT_CASE(drm_test_check_tmds_char_rate_rgb_10bpc), KUNIT_CASE(drm_test_check_tmds_char_rate_rgb_12bpc), -- 2.44.0