From patchwork Fri Jul 29 16:34:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12932669 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 C6F02C19F2C for ; Fri, 29 Jul 2022 16:47:41 +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=GhsB4J1PXNyFinRvEP7dqC64PnyfsWaTepJZJ2pC5Y0=; b=vBXZM/vPK5hnTu wfYNdo4AMcHKFLCcQMC/z/9lphuFivbNQV7nLPhSBsg1D6bfi/iuVtMEK61UWR0eOcWVnLRWKV7/J sQ6DKH0r4wAPcKFPShZ1y7qd4Kz+5i2cr4PP1IJnMavWhtM9RmNCKbMT3dWAQqPJtu/jSJY8u+Qng VttL7or/2OWAQsPy/EMap678UkdgVIPVE5pJnnNI99xKUECKGMwyPlcpA/HZTi7JHhfoGH+iQpt3L aZ29wMcO9haW73mHeLT+R8kY+xyaTyyNYJZ89mh2+xhrX9dnEqaqRiHXPYLxYLAY6rsUBk2J90H0+ /rktXxccWbondQWNFB+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHT7q-006YjA-Ry; Fri, 29 Jul 2022 16:46:12 +0000 Received: from new4-smtp.messagingengine.com ([66.111.4.230]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oHSyG-006SI9-Ts; Fri, 29 Jul 2022 16:36:18 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id 3B6D7580949; Fri, 29 Jul 2022 12:36:16 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Fri, 29 Jul 2022 12:36:16 -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=fm2; t=1659112576; x= 1659119776; bh=WMi8XIOWER3wpbQVpH8wVwWCJ4/RYaQCGvT7XxQHSyU=; b=B 4ax9evUCqBTSCfQ8ar7yIeQHl3UM16fH/2o6nETKuuy2NmyD6v3Wrpph5P1ZZaeb MtbuVsTcUNG6rcxG30bubxvvx72kc7K49DiiMtlux2ntypCfzwhxfuRvtFta+yuN rYTRSj76sCU34Q43lrFjvnki0FYA0Y6EqCf1C7vYbWE3PATjLn2gnKZvl8qibdwk nwE45B22ZyG/Wbc0SYVXBq/19F6XlH4xibfy7US3WUlsp17UlpHXgo2igPDWf4Dp +Mh6GrrFuDPLliK8xDSYMmomHWntA2hDMFC4mSNO/qhdwCFYve1PjXXr8fOoEZ9t 4WguQ8bMboufRrGCanvvw== 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=fm3; t=1659112576; x= 1659119776; bh=WMi8XIOWER3wpbQVpH8wVwWCJ4/RYaQCGvT7XxQHSyU=; b=p yPkT9S1MUihXebCXbRkPEvGjTAm8sR4/ddY/iDVvmnOxzIECrYeHuy1BF94le/+i ZO7BUdL2XKnabBofH1/H8LU9YJfnFJAFrOGjgsQYQfrl23qwTFt7v36Q5CvjTilL 5j18dDTKcc2AdrV3TYOByblmnuW4B+rnWH9qxcCkZVOMxPdp3z5/p3yoL1s9uplf kjrrFYhf9cPnqK7JvS22pVPdkSNO6dRGZV4q3SjAB9PSvbqbgf5HP0BZtFSVZY6f bp7zx1qfEcCIMDGoTWMRfyw2/PlJe5HDa0tDGOpE/EV2nX9hAgud0xRPcADTl2Um hiB1oVIG+mxJjUMYCnL5Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvddujedguddtgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvfevufffkffojghfgggtoffgsehtkeertdertdejnecuhfhrohhmpefo rgigihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecugg ftrfgrthhtvghrnhepgfffgfetffduudelhfevieffffduleevgfegkeeutefgffejheel leekjeefhfejnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrh homhepmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 29 Jul 2022 12:36:15 -0400 (EDT) From: Maxime Ripard To: Jernej Skrabec , Martin Blumenstingl , Chen-Yu Tsai , Philipp Zabel , Jerome Brunet , Samuel Holland , Thomas Zimmermann , Daniel Vetter , Emma Anholt , David Airlie , Maarten Lankhorst , =?utf-8?q?Noralf_Tr?= =?utf-8?q?=C3=B8nnes?= , Kevin Hilman , Neil Armstrong , Maxime Ripard Cc: Maxime Ripard , linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Phil Elwell , Mateusz Kwiatkowski , linux-arm-kernel@lists.infradead.org, Geert Uytterhoeven , Dave Stevenson , linux-amlogic@lists.infradead.org, dri-devel@lists.freedesktop.org, Dom Cobley Subject: [PATCH v1 14/35] drm/atomic-helper: Add an analog TV atomic_check implementation Date: Fri, 29 Jul 2022 18:34:57 +0200 Message-Id: <20220728-rpi-analog-tv-properties-v1-14-3d53ae722097@cerno.tech> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech> References: <20220728-rpi-analog-tv-properties-v1-0-3d53ae722097@cerno.tech> MIME-Version: 1.0 X-Mailer: b4 0.10.0-dev-49460 X-Developer-Signature: v=1; a=openpgp-sha256; l=4069; i=maxime@cerno.tech; h=from:subject:message-id; bh=mddk/xQKK35DXd7zEHlpZoAU4iNlEj6U3dcQfuJB3RU=; b=owGbwMvMwCHc4XzqmfnC7acZT6slMSQ94VG6v/WYqwCDxI1bU1PN5rbfZLfvjkkO/f6U6XJLl8vr d9lMHaUsDMIcDLJiiizXBd/a8YVFuUXwfNgMM4eVCWQIAxenAEzEchLDP6uu70V5Ag/e7xSon+sfZ2 Ud6rkpOuPgnymT73NmqLxQY2X4w1O++uWVZOX93Mfnl4sxyP95ZbKjtpFhrkjyytA3BlNikwE= 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-20220729_093617_090439_6CC4F841 X-CRM114-Status: GOOD ( 11.44 ) 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 diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c index 6d14cb0c64b1..fce5569bd66a 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -552,6 +552,93 @@ 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); + const struct drm_display_mode *mode; + 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; + + switch (new_conn_state->tv.norm) { + case DRM_MODE_TV_NORM_NTSC_443: + fallthrough; + case DRM_MODE_TV_NORM_NTSC_J: + fallthrough; + case DRM_MODE_TV_NORM_NTSC_M: + fallthrough; + case DRM_MODE_TV_NORM_PAL_M: + mode = &drm_mode_480i; + break; + + case DRM_MODE_TV_NORM_PAL_60: + fallthrough; + case DRM_MODE_TV_NORM_PAL_B: + fallthrough; + case DRM_MODE_TV_NORM_PAL_D: + fallthrough; + case DRM_MODE_TV_NORM_PAL_G: + fallthrough; + case DRM_MODE_TV_NORM_PAL_H: + fallthrough; + case DRM_MODE_TV_NORM_PAL_I: + fallthrough; + case DRM_MODE_TV_NORM_PAL_N: + fallthrough; + case DRM_MODE_TV_NORM_PAL_NC: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_60: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_B: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_D: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_G: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_K: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_K1: + fallthrough; + case DRM_MODE_TV_NORM_SECAM_L: + mode = &drm_mode_576i; + break; + + default: + return -EINVAL; + } + + if (!drm_mode_equal(mode, &crtc_state->mode)) + return -EINVAL; + + if (old_conn_state->tv.norm != new_conn_state->tv.norm) + 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,