From patchwork Mon Mar 11 14:49:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13588896 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5DF79C5475B for ; Mon, 11 Mar 2024 14:53:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=F7CKB2V45cguF3f1/t33X11SudxkcNGMDT3UMOYsZSs=; b=kZe4BMPB+stm03 QsNgLIax8JtTyk+dIFTRX743FXX39PwMl4Nt+Utl4jaGpF1IXNicU2g8Ycu4Oc5WAkKjSOFOZbxYf exS5DpZM4/N7P7YiKBvX3TRfidTrWlt349MpXNZDBn6zs6oiyQIRHBwsQurDtmW/qqL66TbcY1ooL V7dLnwayUwhNkLr3s9cqpv4PUU0wZAFZYxMFYbh+fx6AkyfEgW7H+Gk9fvWvLd1SsQEOuiEDVH2y4 7ce0Xtw7PNerea2ykM/WXQXmCpNPNc5y+OjQEBYSypcBHmhQhtAjKUaS81HTMdWl7ORx+WQFCwasU V874+ZkUbIFH6We++7fw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjh1C-00000001u0W-1Fhz; Mon, 11 Mar 2024 14:52:46 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjgzG-00000001sXD-2Kh2; Mon, 11 Mar 2024 14:50:46 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=wsAmgFhchod3E8j7cwsydYsPwjHd0toBCaTsGQOveRU=; b=Hsd/Q31MfTxMcAQV7GbH2+M4BP 0umC6n5ACLJVNNO3cQ1qg8KhsJ8g5qzZ0SvvxU8tgHuk/K+m70CV3yEtSdfpxM25uy0NCwJZtjntq wjJJXpqXTSa8vcUOy17Sfk7sapT7dlYOHfeMTKdHYu+rWdc/4h4t+z/X530eQIzJiFqRTra8N0y6T wV8C8lqDRLiBunqs7wL6J5c/JStz6OzVozaD9+avqdHsrPVDmaBwRSTCu4BliHEEIAsY3hrTbQEW1 ahROLSz2/7zdbAkWS68SkXq1cSbMHEaUgXjQdcz9vo3YG9OkTe7y5jxjB2CTmMXxHC5M7oaCMICcz FbjZegYg==; Received: from sin.source.kernel.org ([145.40.73.55]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rjgzC-000000090iO-3D6y; Mon, 11 Mar 2024 14:50:45 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 20C78CE1102; Mon, 11 Mar 2024 14:50:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFBA5C433F1; Mon, 11 Mar 2024 14:50:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710168638; bh=FYtMepddDx3HCIUl7lef+T8X++8b141JfngL4arDBvg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=hy6ynmx8940Oh31udQVQIzWpHC1P8RVpjL1gSSCt2gFRtxppGXQ1k6pvnXxphTfB+ 3pDeRibqVaH54cbIj3Bjy3km2B8EnbI3tMDCSDrWLxPRmXLlfetFzMypB3I2AoNrpT Ak9GIWMi6pjrk/Ru4vBsLKPIBH1HY2A5lksCGJFVRkEuzisLdxr4atG6Ve7UHfGbCZ U5AckXr0cJFwLhkex78wDl/bTmcH/5YYdUwSpwsRdxV5w8efKdzA6INIB1uCl3hp5D y26iZTJn1nYCKiZxDvv4fzxkjjLKaMzCPRbZtjnQNAqjB0k0/oCHHeEOoAgivIjdNY 2MRPkdhrZ9hzw== From: Maxime Ripard Date: Mon, 11 Mar 2024 15:49:41 +0100 Subject: [PATCH v9 13/27] drm/tests: Add HDMI connector rate filter hook tests MIME-Version: 1.0 Message-Id: <20240311-kms-hdmi-connector-state-v9-13-d45890323344@kernel.org> References: <20240311-kms-hdmi-connector-state-v9-0-d45890323344@kernel.org> In-Reply-To: <20240311-kms-hdmi-connector-state-v9-0-d45890323344@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=3906; i=mripard@kernel.org; h=from:subject:message-id; bh=FYtMepddDx3HCIUl7lef+T8X++8b141JfngL4arDBvg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKnvpXhOzQ88r6Gq/HXbtMty+1fnl37MPnLrzdllcaveZ LZ/rNs9vaOUhUGMi0FWTJElRth8SdypWa872fjmwcxhZQIZwsDFKQATWdLH8D/se+USMZ7nD2fo z6k7bbmIaVbL1u9WG8LZFvpMmVTc2LmDkeGNftSzeG2lm+InG65cdLuyVJf54n+ZQK0zL3f+COj ezssAAA== X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240311_145043_557924_A9CE8883 X-CRM114-Status: GOOD ( 15.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- .../gpu/drm/tests/drm_atomic_state_helper_test.c | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) 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 989661ad3aee..5a8750153510 100644 --- a/drivers/gpu/drm/tests/drm_atomic_state_helper_test.c +++ b/drivers/gpu/drm/tests/drm_atomic_state_helper_test.c @@ -111,10 +111,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; @@ -489,11 +501,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),