Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp563915lqi; Thu, 7 Mar 2024 05:44:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUU+lwMd4SdDyP6dNvpu6Ynso5zBp9iWW98LHR11DZQoRDV01aDOwLzqjvS6YZBTX9t/6sU1o2TS5+xPu0xuwKPUt14U6DeRUE4c5x9yA== X-Google-Smtp-Source: AGHT+IFtZKDATBKDSyQXis+1SZGDuJGOYDyyVmtjZf2yAmxZx6PpaXQE3ScycXOqrQzmMikWy1rv X-Received: by 2002:a17:902:e746:b0:1db:7052:2f45 with SMTP id p6-20020a170902e74600b001db70522f45mr10043560plf.61.1709819084067; Thu, 07 Mar 2024 05:44:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709819084; cv=pass; d=google.com; s=arc-20160816; b=Z3FuH1ByX9RN5l9sa4K8ATwgHu3pi0u61F9xYW2MPYec3ePYzyopyNHS1vzsgg5vTn HT6eFkrVdMpFzl7ku64PsFdWPNXCQVjJl68cekF3ACLD37VdfF7SAousRs0RYg7BGsyB 5WjXf5nE6XQipnJTD5qb3GzuK+Giisko2iBymLzdcPIBCPNc1yKd2mIpukksXZ651L27 Za5IOAJzDNm7Q9j3I+0xsO9r0OOXEQDtfE1tjC0PRw2P0gCcFQnd+hlRSKczjHW/nWCk xMOZnu3vNWd7Aw8R8ZWY48CuySL9Z/fzuhssW/wcYVydqjFhmw4H/GMyLcFlbCSA/odR rirA== 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=wsAmgFhchod3E8j7cwsydYsPwjHd0toBCaTsGQOveRU=; fh=8wcoxKk21hICD+6obVirG13fsSSMhKa/pufykSf87d0=; b=hbEQQcUd5U1DeCj+S3D+pzmdzP105jQYWfI0LdqjYJByD2Dv9tQlTOLImTvzceUCm/ aJCugpIub87wdMjiFVbICdpzhSXLMSwL7F4h06NVr7vXckyC5cTqBGeL5E7OvW6wrLPg z+qvtxIjKg5sjJ3jPgClLfXIcsoNPUuJCV6NQXGl7Sgjd6k7Xsxmmh37+mdnBSK3iIwG V5r3+lOCC7InmfE7r6vFWXiu0hGxElXAQjd05No/+a8vay1RY6fEQIty9o4Jx0cU8+G/ 3FrLjpqzGuRRREWkykrdZ6FSjuPpC10Fm+qcWt3a+DmmokPVUEDKBjXG8gEaaZ8pdWA+ ljBA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=b4GcARRe; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-95636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95636-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 s18-20020a170902ea1200b001dc96c65edesi14359291plg.469.2024.03.07.05.44.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 05:44:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95636-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=b4GcARRe; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-95636-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95636-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 4C33A284D6C for ; Thu, 7 Mar 2024 13:44:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2ED4413666A; Thu, 7 Mar 2024 13:39:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="b4GcARRe" 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 348FE135A7E; Thu, 7 Mar 2024 13:39:32 +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=1709818773; cv=none; b=WpF7zABNt3O8k0qKE1u7Ver63ml+35m8P25CLF3RyQ1QgLVlzpaq0lJn/tAUdcF6Obm8nXU8gNc+EC6DTyNJ17fWOrDHElE92RwBJzSLuIW6Za7YME7RQWvwk7K6Gb9gw4ag4BTdi+bT4vwOs2yovGX48utIWz8bkaxs4DY0cio= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709818773; c=relaxed/simple; bh=FYtMepddDx3HCIUl7lef+T8X++8b141JfngL4arDBvg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PEeYjAshKY62gsf2nbLNP41PYTekWCyavLvAld0aQD9tKr50Pt5vseC4mtVxbQoUKxsjdkPrtalVI36+jJWI2MI8pxAjPOUYDdPIS0eaoEAMkcHcR68Cua/RcnRBzKnpIDWuKQi2qfx3LkidnqFu6mPwRWnoDiL9LUkPliLV6/I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=b4GcARRe; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6734FC433C7; Thu, 7 Mar 2024 13:39:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709818772; bh=FYtMepddDx3HCIUl7lef+T8X++8b141JfngL4arDBvg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=b4GcARReK4wCXWkOtDpq/OEcHnccAuBiuqFFplgYV9OecrS4F6ErMm7LoLrDrxBQm oyi5RlRFwwDmA2wVqZdxtsQxGOx8KOjrPHLrOWYREhtOOkiV2MExFeNH3bYsBzn9bj EyfrcCD3nDz5ymk0pdI58TloiocDsrEJcT96fPziJZP7nGXuiDbGI8eudrTkTSQMZj ILg1PIYa1A8naER0hCXsbX45SoFsY41Fl+kvb9IwgLBpj52TaNJeUQ7EtA1YWlDio6 IeZXHixTK7+KbXT9v6tC/Bb7oLSi0QAgVgC05cixjptCN6Al9+06VPCc08vcN5r/oz lK42qLpn7z7Tg== From: Maxime Ripard Date: Thu, 07 Mar 2024 14:38:40 +0100 Subject: [PATCH v8 13/27] 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: <20240307-kms-hdmi-connector-state-v8-13-ef6a6f31964b@kernel.org> References: <20240307-kms-hdmi-connector-state-v8-0-ef6a6f31964b@kernel.org> In-Reply-To: <20240307-kms-hdmi-connector-state-v8-0-ef6a6f31964b@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=3906; i=mripard@kernel.org; h=from:subject:message-id; bh=FYtMepddDx3HCIUl7lef+T8X++8b141JfngL4arDBvg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKkvDyfr/IlJn+Ga+3Ct1dqGXzeul/zRfPH95UvFP2eve 0brmoTadZSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAiq5wYGS5wp/FsXiMY71Yf umP3njWHJJkPVzu/MTFP+71LZfnC1TsYGQ793h42ffZbLz+tPcnf3mzwvR82Ufpc3Tq9PWuT3JZ fXMsPAA== 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 --- .../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), -- 2.43.2