From patchwork Mon Aug 29 13:11:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12957935 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 3B503ECAAD5 for ; Mon, 29 Aug 2022 13:35:26 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KIikQmARY4rzZ316kdf5XnXIlQIK2PBgU+0IbOY2Jxw=; b=Bbv2E5krzBzLIP Qfd6T+BdaY0oool+XDfIwCmOuOAnxill+SkgL1jsQSU/b3k7AjFmsoLBgPSwr2t7JQoufxza3UidK 4133KAPpJYs0vxcnWSYPINm+pi3niP8QlicWd1aZTWNYVDy/FxU11x1pO6qflOuqcjm8nMjRN05pX ovJmh5oOd0iO45jpExmiAlSS/UY301z5rKg24h1QaTHIROG8xCYrTY/uAIt5FCFhSZL/+5HpYzXtx nDJSlQeC0tgsD6xNZ3GORoSRvTZe+g4xb3fDGC2Px7CWwm05+BIYuEaYaS9C2vqttnjO11/fIfEhY Fhn0KFvay0LK1FuHUZ5w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oSetc-00AktI-HM; Mon, 29 Aug 2022 13:33:45 +0000 Received: from wnew2-smtp.messagingengine.com ([64.147.123.27]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oSeb8-00AatI-6X for linux-arm-kernel@lists.infradead.org; Mon, 29 Aug 2022 13:14:40 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id B22912B0606D; Mon, 29 Aug 2022 09:14:34 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 29 Aug 2022 09:14:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1661778874; x= 1661786074; bh=O2K8vY3bz7CqbtV7SDqiw++49YhOhYlXnJRYT6GaHo0=; b=G mx2HOjqpy8Vuvh7ofDmXwVGjdnqoscgUXD45ef0jj/VIxTBVoLcBrYJQs8sYRiqR Dij9Fq0CPWGv02esfBUo/xKVSg/Fo7C2x3FlueiZz7fLApbwaeIKaOM0fdg9ke0W DBXrqN68/DR7zgEZdlvOH4mqOiO0beAxYVgaEdg49TGwj3wzAMnBWlOwInQ+GBN6 eH3njcImHLuDrVVQHLNPiYowCAxj8+wf99sFfnRmPP1e6xXYKphDVf/H0mkQDdsX Ox13UDxzdwWzileclBwOVNjIbxg6xrz1Zt1vpV1kVzAzoOxoMwdIBlQ0jKeadwNb mqlg437OYD4VLtsWNm0/A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1661778874; x= 1661786074; bh=O2K8vY3bz7CqbtV7SDqiw++49YhOhYlXnJRYT6GaHo0=; b=K 0hspOg0VCsB6jyOqPWfY4/sDjtqkAc0SYamNpCVVcVpTPSf9aLgwmKhvlwddAdhU Fcl3UIJijcevRdfTS6wlnaFFsa7dBe9DCaR626pTcZUM4c3nu8UMBSQffXzDDo6r nok/uuCfq+LUGqYK6ewj3PPuftAqO1UlwEV914t1B2aVCHfbOUUBPWF9J/wjSn9n jvX9xq7g3fpZw4zx2+1Rvu3XkhjKbXTKAnOSRcJPw1/1WdA5gitVV6z9P2+2Kh2X z53AGiXB49TRNB8zs3lby1yb8fluGTn2Rw8PZGL6YdVlAWG6Hk37cycmFliP5es/ FoOlNdNLdqGzfuJxcrybQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdekuddgieefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfogfesthhqredtredtjeenucfhrhhomhepofgr gihimhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtf frrghtthgvrhhnpeefiedvfefggffgffehveejieffuddtgffhjefggeetieduvdeileet lefgveegtdenucevlhhushhtvghrufhiiigvpeefnecurfgrrhgrmhepmhgrihhlfhhroh hmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 Aug 2022 09:14:33 -0400 (EDT) From: Maxime Ripard To: Maxime Ripard , Ben Skeggs , David Airlie , Chen-Yu Tsai , Thomas Zimmermann , Jani Nikula , Lyude Paul , Philipp Zabel , Maarten Lankhorst , Rodrigo Vivi , Tvrtko Ursulin , Jernej Skrabec , Samuel Holland , Karol Herbst , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Emma Anholt , Daniel Vetter , Joonas Lahtinen Cc: Maxime Ripard , Hans de Goede , linux-arm-kernel@lists.infradead.org, Phil Elwell , intel-gfx@lists.freedesktop.org, Dave Stevenson , dri-devel@lists.freedesktop.org, Dom Cobley , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, linux-sunxi@lists.linux.dev, Mateusz Kwiatkowski , Geert Uytterhoeven Subject: [PATCH v2 23/41] drm/atomic-helper: Add an analog TV atomic_check implementation Date: Mon, 29 Aug 2022 15:11:37 +0200 Message-Id: <20220728-rpi-analog-tv-properties-v2-23-459522d653a7@cerno.tech> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-459522d653a7@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-459522d653a7@cerno.tech> MIME-Version: 1.0 X-Mailer: b4 0.10.0-dev-65ba7 X-Developer-Signature: v=1; a=openpgp-sha256; l=2877; i=maxime@cerno.tech; h=from:subject:message-id; bh=tMMQ9LmYriVsBj4/ucBagVoAOsUAypD775BhY4mJj98=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk8uxSEEpcYRiVtnm5f0vzng0aRVHzokRLm5M9q+ydZcLkv t6zvKGVhEONikBVTZIkRNl8Sd2rW6042vnkwc1iZQIYwcHEKwEQ0tjD804uellbiNPGm/pk/Ua662V WPORQ/TUjzm+Ske/nLFOVzBxj+yr66VvabxS7y8fzzXlP2/43Wf+RRuDV0oay9+4SlaW8m8QEA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220829_061438_981382_F934FC6F X-CRM114-Status: UNSURE ( 9.65 ) X-CRM114-Notice: Please train this message. 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 analog TV connector drivers share some atomic_check logic, and the new TV standard property have created a bunch of new constraints that needs to be shared across drivers too. Let's create an atomic_check helper for those use cases. Signed-off-by: Maxime Ripard Reviewed-by: Noralf Trønnes diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c index 0373c3dc824b..d64733c6aae3 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -556,6 +556,42 @@ void drm_atomic_helper_connector_tv_reset(struct drm_connector *connector) } EXPORT_SYMBOL(drm_atomic_helper_connector_tv_reset); +/** + * @drm_atomic_helper_connector_tv_check: Validate an analog TV connector state + * @connector: DRM Connector + * @state: the DRM State object + * + * Checks the state object to see if the requested state is valid for an + * analog TV connector. + * + * Returns: + * Zero for success, a negative error code on error. + */ +int drm_atomic_helper_connector_tv_check(struct drm_connector *connector, + struct drm_atomic_state *state) +{ + struct drm_connector_state *old_conn_state = + drm_atomic_get_old_connector_state(state, connector); + struct drm_connector_state *new_conn_state = + drm_atomic_get_new_connector_state(state, connector); + struct drm_crtc_state *crtc_state; + struct drm_crtc *crtc; + + crtc = new_conn_state->crtc; + if (!crtc) + return 0; + + crtc_state = drm_atomic_get_new_crtc_state(state, crtc); + if (!crtc_state) + return -EINVAL; + + if (old_conn_state->tv.mode != new_conn_state->tv.mode) + crtc_state->mode_changed = true; + + return 0; +} +EXPORT_SYMBOL(drm_atomic_helper_connector_tv_check); + /** * __drm_atomic_helper_connector_duplicate_state - copy atomic connector state * @connector: connector object diff --git a/include/drm/drm_atomic_state_helper.h b/include/drm/drm_atomic_state_helper.h index c8fbce795ee7..b9740edb2658 100644 --- a/include/drm/drm_atomic_state_helper.h +++ b/include/drm/drm_atomic_state_helper.h @@ -26,6 +26,7 @@ #include +struct drm_atomic_state; struct drm_bridge; struct drm_bridge_state; struct drm_crtc; @@ -71,6 +72,8 @@ void __drm_atomic_helper_connector_reset(struct drm_connector *connector, struct drm_connector_state *conn_state); void drm_atomic_helper_connector_reset(struct drm_connector *connector); void drm_atomic_helper_connector_tv_reset(struct drm_connector *connector); +int drm_atomic_helper_connector_tv_check(struct drm_connector *connector, + struct drm_atomic_state *state); void drm_atomic_helper_connector_tv_margins_reset(struct drm_connector *connector); void __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,