Received: by 2002:a89:d88:0:b0:1fa:5c73:8e2d with SMTP id eb8csp2070032lqb; Mon, 27 May 2024 07:03:34 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXQnzlsyrJCneiobAkt0r7UXhOnKxq9/uS2L/AnKvIEZQ2Nb05JVvlkY1wS4Un4CxoY/snH3+u6ntoS73GmnvybrXd3I7iaGqVpJqctAw== X-Google-Smtp-Source: AGHT+IFUQCLkJaGFVbRtWUK7I68Dkt97sxfMbtuJd+J0EeY4iGuagbAz8nfXK6lftQztAB1dFkNg X-Received: by 2002:a05:6358:432a:b0:192:2717:4ed4 with SMTP id e5c5f4694b2df-197e531ad69mr1321444355d.19.1716818613493; Mon, 27 May 2024 07:03:33 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716818613; cv=pass; d=google.com; s=arc-20160816; b=zyIsKF0ypiEek/d61SZ0odHcB6PhyAHRjt8OVdsMj1NQyVaAwwam4yemznfEsPA57s daHzBeT8GCvtyslWtakF1sFWrHfB5Jlr0v7IiSK5n6QU7AjItrxr1lmI6eIuxpKufcER l4hP+zFAPXHH3rbnVFjlbYTPCVi+twlpILbWKxs2nDxfJ6CXT9aCjq/awpwxKNZKmoId cAliqQ4H/0uTvKRkfRQ7tYdUVuC0baGkuF0mtLhSDltWdGgm7rKRRP/BseKvXFg2kan3 hXUtW99OQlFIPHvpa7eMXXaQPciLLYLX8MIdEfSUtW7OsF4UUa7qJG4thn3xN/uA8V3p rt4g== 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=cECpIkqnoXGQ6RBrYeVFFTWX0EZFe3JZojsWwOIF9i8=; fh=Rmvm45DLBttDXPZ7ZQBINOOM6/ese2BHFaa7wD2L3jc=; b=JHXqxzkoNdFEHig5NlGJ47xi8r4a3d6+xQPoYeNGRfYOucVmgzBuv/nRmaMmQbblyW FdRE0sl5sHcE/iub/nqSdhz01g1gOPAejKLk9JCLQun8s8AJB+j3F0Znlrf8GtrVtW5B uBG80GsDXkQGYSCnRKGODuGXf4yebUdbp7OU97fWswpGgV/7Cc8RLlqUAYx+o4c/9H2x yAaJEousupEWUjKDC7A8pnzbT0otTyHS+yKc5OmQBUxXLCrgM7boMIoV1fxDZTzC+a7Q Qc3b0IuA//Qho+G34U0KWfylCREzKLxFKx6w68FeV2U8wO3LpMR896iWUti7a1eqJ2bg +YbQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=am3wbWT0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190777-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190777-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-794abcc61basi783423685a.178.2024.05.27.07.03.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 May 2024 07:03:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-190777-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=am3wbWT0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-190777-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-190777-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F2B081C236DD for ; Mon, 27 May 2024 14:03:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B26A416C866; Mon, 27 May 2024 13:58:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="am3wbWT0" 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 A972A16C84E; Mon, 27 May 2024 13:58:47 +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=1716818327; cv=none; b=fO/GEf6OjM9RL4gueepeSqM7XfTDtZ0O8y5oXb4O2EuUxmAgGbyQqk9RkK13SD1ohBuFqJOENdYvJayV1xnIplcW7JDcQEXrqVDcJTz5XnOMXK06YlozRdhMp9HaNN5QySgCIwJPJIjpsMgLArKNo8WK+ofvcoLF39WzKwin2Tc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716818327; c=relaxed/simple; bh=evdMziBD604xhpsHQgfDxIbpzA2cQVm7nC6u+fBPbFE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hwUx3y7ojAZuAX1/BJ7zbh7Um+yFwIsCfx3sUBnsrM2jrXIdXLF59Ziv8WPkktL/ylaO+65xcoosqsJz69VEK6LXkCROaATQGNW1FSx5b72cLlFm+mb1UTtSjA0IKSTF/cjIlSLO7NId8CbVyuR7w2WOgkvmOEWHS8a8VTlwz5U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=am3wbWT0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3610FC2BBFC; Mon, 27 May 2024 13:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716818327; bh=evdMziBD604xhpsHQgfDxIbpzA2cQVm7nC6u+fBPbFE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=am3wbWT0VXs4fDL64MAoGiOWOL7SvD8wJtVXB2ShrW5bTL/2vkFMbi3nHoIqtm1g1 DOAtuEmRYpkKBY61zpjy/lEHTBDezE8RGGuR35y9uaWO4SI7Q6vcLtjF7+Qk2n4umZ 5g8yGeTw+dY0cEL7fyhEBuaPyzBEWK/fbdjcz71ssuoEWYT8UrnpPe0+dBJmKwnQON m2T3NirLWR/vetYVVUxdV0KkVBQTO7jrtLgUegavSH4wuVX6Ud8VvY75DfressUdzt VIV2AcbZaQDche6inIjEz7hwXmPEdGXRJDwtCoO0e+nJ10oCC8uRiiqrebhGGhUksD 6vC2WUfVqqBvg== From: Maxime Ripard Date: Mon, 27 May 2024 15:58:03 +0200 Subject: [PATCH v15 14/29] 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: <20240527-kms-hdmi-connector-state-v15-14-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=3959; i=mripard@kernel.org; h=from:subject:message-id; bh=evdMziBD604xhpsHQgfDxIbpzA2cQVm7nC6u+fBPbFE=; b=owGbwMvMwCmsHn9OcpHtvjLG02pJDGkhE9OEGI1mNfYnFul8FNJNfvW0a5lk6/SneZ+WCG8Rv 36BNVapYyoLgzAng6yYIssTmbDTy9sXVznYr/wBM4eVCWQIAxenAEzkXjxjvVv1hczmsxwpTAvW BIf2+NmLGNjwBoW+YGNLvaS4O05E3/508YJIlkvMCpFupnVe+5MYG95UbjNeZb32+eQnGSGL3tx uYCos+h1y/3TJ2xUsgWtLlITf2fZm1xxI8ZtVtNPr83Z/MQA= 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 Reviewed-by: Dmitry Baryshkov 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.45.0