From patchwork Mon Feb 12 13:13:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 199767 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2423011dyd; Mon, 12 Feb 2024 05:23:13 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWp7f1SQOiqMroyYOyShIq1kRG6wReb5v4aE73kocqokX/aAFAQ9zjLm00+dMJ6TavWV0zpj/WsuW1b+yl0r1gQ5x/wig== X-Google-Smtp-Source: AGHT+IHdhKQYtf5VbfEQmdEiVvcuboW2ILQqlejc2vHmLdzlbZPolnpVTRxUD+xkhQlDcEX84lUM X-Received: by 2002:a17:906:24ce:b0:a38:98ee:698c with SMTP id f14-20020a17090624ce00b00a3898ee698cmr4549605ejb.63.1707744193433; Mon, 12 Feb 2024 05:23:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707744193; cv=pass; d=google.com; s=arc-20160816; b=uc12jt9ZBmGoF6GBVb6b6U2POnMR5Gy5FAmWadYfKQ7iH6E+z+iBTsxWXqFZEcRL4+ Da2NnsudNGBYRT69aaRTo/Ew79F3RFpDvh7xI+Rw4teJArvGGop/9g5jNU41Hla0GttX 7UygBDTZFRDKWUSA3Psyssnmq1sjIcOrxG11Q5vKRI50LOBc3nbLSvLUgLT55T6c95gJ AcSYvEPLIr0/0azFkmadr1ejbEL1OVhOQ8ddu9653bHaMnZHlRk4iQUjWjkiw6D/pdyF IGnD3trLF0dS/3uSGBq1Blc5UhKUPufZiWW3whZR44CFYDfMd02SlL1mmGwgonsyt+Ph LdBQ== 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=9v4Ts6NdSbTCWSlTuguSaZ9/dF98VqvHfymIrNsXEOo=; fh=VXBu33X14jQoA64E4z7OcSrMfSTsOl6sygQ0CcnSZCs=; b=hzukglueN0874IvXWSnooMl3v+hTzUy8pdBIEKVBb0OsIHDNLZ2PCpXa0lQkeIMJF6 XqL+kyTtKEl95j1oTTt1Og0ilCgbt1YgY3McAltQEOLkfLaCtSJp+ngFJzzcjaFahoFf h2O52H5F47ppKgBz+CrH8pmAd5UNYObQ0i+PxLk0KrykgtF+BjdX9eiClt0/vnNtk+bR wYBS9fy5Z2GeWuJcDMrPdvMXW3wAuznzolyBkH2jz7GiO9eYN0p2qNMCoMoq5nkNyyfE B60a4ZsfHK0DXtIxiGPF0meSf5sVMmsvD3SwFkgUKtCfXVifCvgJHWo1sCiO2r5mEdL6 HGDA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rt0dQRF3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-61641-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61641-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=2; AJvYcCXfXYeZxsSW2DzFj2E4A2CvTZt/3jFsZjsXrODhNtBUCo0IFx4gawwfPnUb/n/9vRS5MiWay8N9miCiVCBp1acaMvZ7yQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id lv25-20020a170906bc9900b00a3c15b989f3si173564ejb.802.2024.02.12.05.23.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:23:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61641-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rt0dQRF3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-61641-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61641-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id DC1DA1F215B5 for ; Mon, 12 Feb 2024 13:23:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1C624CB20; Mon, 12 Feb 2024 13:14:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rt0dQRF3" 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 AD17A47A57; Mon, 12 Feb 2024 13:14:30 +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=1707743671; cv=none; b=rJBqTXuBvlJd6rmi3M5jZ027fmRcas9LpRmj2PL6ViS7Q2bvHwvYyHTYOHdmtR7fMKMmhaUdAQbl/0pWXNAUwgCZg35dUkJ8FxfXYQB0K188xpimJc/oJ0Xna5DIiFwa1B9edGbWluzunwkV6QVKse1cpotcPISY9y0eTUpFx4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707743671; c=relaxed/simple; bh=qjCUh+MOUGaoHfnBp8m5jk+g0FV9Vj8vmvysXWvLAuQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lp7B8m0uPUHAVpIz2wwI9CL6NAtfik2lTlb9FMXfas5rr2Vftn02T3k3OTsfXs1ZfdLHLtxsCFCIJQnLX29M/3U3+g3vdeyysYXnwks9jII4CJWRHKbDxrbxgUzVMq+GC+obh1aAU20+myUKz/idKGXh0kJCV8pXwKRxnF0joX0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rt0dQRF3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4ADDBC3277A; Mon, 12 Feb 2024 13:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1707743670; bh=qjCUh+MOUGaoHfnBp8m5jk+g0FV9Vj8vmvysXWvLAuQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rt0dQRF3MEGHjZ6GyqelsvJ6Lplv8YjXD+dViULXEzR9MA6D/cKMBfcPZjOoo5p4g E0lf2h0N1h4RlX5oHsaS0KAGUX4JURpHn7Ha7C/e9TVf8dYAXqspm+vBPX4SG1wvqj nF30sMDzUwDo4TS1gcS2zbPYLck+4n0fIkXCsJp+34NGWCYD0OHFm/E0gDgoklJnHS iKR7LHWPHkEh9eUBkzNZrpM2bqX2mu3eAjkFF3GZERuM0VQNY/T5C8HxNDUS8jS6zu hE00WupkFsbyfMuozkH05W05iUaGLM2vhrUvPyWcJXJnt0DLg2SMhSK8dYoY6sNbIn vtshyAadq8L8A== From: Maxime Ripard Date: Mon, 12 Feb 2024 14:13:05 +0100 Subject: [PATCH v6 22/36] 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 Message-Id: <20240212-kms-hdmi-connector-state-v6-22-f4bcdc979e6f@kernel.org> References: <20240212-kms-hdmi-connector-state-v6-0-f4bcdc979e6f@kernel.org> In-Reply-To: <20240212-kms-hdmi-connector-state-v6-0-f4bcdc979e6f@kernel.org> To: Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Emma Anholt , Jonathan Corbet , Sandy Huang , =?utf-8?q?Heiko_St=C3=BCbner?= , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: Hans Verkuil , 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=4001; i=mripard@kernel.org; h=from:subject:message-id; bh=qjCUh+MOUGaoHfnBp8m5jk+g0FV9Vj8vmvysXWvLAuQ=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDKmnJHOWBSdMXbnm0bKYlNPiuhcX+m6NSs791tnvxnXVJ ufAizKHjlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAEzkeRgjQzuLXoiGJtPzI9Ff Q0O/G/i2htw9tm+q1+E/h4+cT3RxdWT47zTl2qe27yvF2U1evDxrcvpWxnnt91lvdNaLx21Z7cl /lhMA X-Developer-Key: i=mripard@kernel.org; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790699575003847306 X-GMAIL-MSGID: 1790699575003847306 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 a43bbfc2c2d0..e7dbdd4a4e7f 100644 --- a/drivers/gpu/drm/tests/drm_atomic_state_helper_test.c +++ b/drivers/gpu/drm/tests/drm_atomic_state_helper_test.c @@ -113,6 +113,18 @@ 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 = @@ -960,6 +972,58 @@ static void drm_test_check_tmds_char_rate_rgb_12bpc(struct kunit *test) 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_broadcast_rgb_auto_cea_mode), KUNIT_CASE(drm_test_check_broadcast_rgb_auto_cea_mode_vic_1), @@ -969,6 +1033,7 @@ static struct kunit_case drm_atomic_helper_connector_hdmi_check_tests[] = { KUNIT_CASE(drm_test_check_broadcast_rgb_limited_cea_mode_vic_1), KUNIT_CASE(drm_test_check_broadcast_rgb_crtc_mode_changed), KUNIT_CASE(drm_test_check_broadcast_rgb_crtc_mode_not_changed), + 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),