From patchwork Thu Oct 13 13:19:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13006071 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 31437C433FE for ; Thu, 13 Oct 2022 13:40:49 +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:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=140YEvJe7UULEk0U3Eu4AxTyfxUruAK9ugk7L05H2Pw=; b=zxvfX78MmZhBmK va1anBwUIynQxh3UIuBeeecoi5hCVbSiiRQHe+rFS6yLh2nQVIDGcKi4SRAL3vJ6/jNdzzKNHfqqj uBs/4SrbzHwXAbR4l8mFmqmgG3nH9g/WxNepzzZvLZXXFgS8Xa1BeEkqA7+z2N4ze44cxDTLQZkdX 4r+RdTD8CEyllY7DWdtPohhr/E3Bo986TVRjJBDOkPkIEZdQ+Qo62q331pt2FQJGobBm+llE9ZQCJ t77VTIQNJvIKb+rbX3/El+VTr1phkZCBeEcNraTYdyBZIKFajc6hFjNSMMd9/9NXS0Iyqx5mt21SO ZsBqTJ0Li9JNkeGqW8tw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiyQn-00BvX1-8Z; Thu, 13 Oct 2022 13:39:25 +0000 Received: from new3-smtp.messagingengine.com ([66.111.4.229]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oiy7k-00BoeV-Bt for linux-arm-kernel@lists.infradead.org; Thu, 13 Oct 2022 13:19:46 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.nyi.internal (Postfix) with ESMTP id BE43B580367; Thu, 13 Oct 2022 09:19:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 13 Oct 2022 09:19:43 -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=1665667183; x= 1665674383; bh=NJLYeh8h9dc7+t2bHRaWvasJAEeZPBsFSyor/QzBR7I=; b=A rmHp52JTR+SDjrE9NePMCb8aeKn34iOE9eASN+ygLMCJCO/4z2fNRzeQIr2ZMqRi 5s2VADfW/b+FzuW9IRGJBX9oKxu0VZZv2KEUDlUvhrDjzaW/u16UVL1lFHojrUt7 1Zx/Fsd2GfLirjpYPDhQbyokEA3B0RgnjQn3ovj/bNNfukIdJQvj2dNSF5SCXX8s MbuXivWnplvYxsWKxtR5QyHHiUtDuc7hJPGm9BqDOypxhNF1Rzg+J6YZXxjoV3Vg oC+OGIsnBtmeS2cqPXrWLANGaHoxZHpD1psJprLwMGzfxxaBOM8/Q5fp1qeat22g +gvdTUtTDTyIWRjTnA4GQ== 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=1665667183; x= 1665674383; bh=NJLYeh8h9dc7+t2bHRaWvasJAEeZPBsFSyor/QzBR7I=; b=B J/s1GWHbj0v11Q80+wjmQ/R8G4wMZ7akSke1SyfHFZfThJuhhhOnlgt90OdXftH4 7rzFyV25Tq032TrdvkXi7m4feeIg1dp6qCCCn193cxI+aCCjV5lBB6nYZV5/SzaF BEUEOcD4U1hxb6mkvaZXA6DKUfV6zIVwlww1cp+0VLQUBp/SWIMNoRVcW3l4tNNZ ZaO/8OLN4UHYzSaexUXImMW3v5fbSWhmqEZem1k67MpyzWFCzDX9Zv/kBQYlLIQh rjYShyJRzgD3Dk+O3y2UzkzsktQ35Z5j14ivdYjvzpGGO24OX6KVHupVJsN0NoJl 6TbeH0VwXzbFZUNVqxvYA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeektddgieeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufgggfgtkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvdfgveejhfdtteevvefhleeiueeutefgvdegveekgedujeffgeffgfet tdellefhnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Oct 2022 09:19:43 -0400 (EDT) From: Maxime Ripard Date: Thu, 13 Oct 2022 15:19:03 +0200 Subject: [PATCH v5 19/22] drm/vc4: vec: Check for VEC output constraints MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v5-19-d841cc64fe4b@cerno.tech> References: <20220728-rpi-analog-tv-properties-v5-0-d841cc64fe4b@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v5-0-d841cc64fe4b@cerno.tech> To: Karol Herbst , Jani Nikula , Tvrtko Ursulin , Daniel Vetter , Maarten Lankhorst , David Airlie , Joonas Lahtinen , Lyude Paul , Maxime Ripard , Emma Anholt , Chen-Yu Tsai , Samuel Holland , Ben Skeggs , Thomas Zimmermann , Rodrigo Vivi , Jernej Skrabec Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Maxime_Ripa?= =?unknown-8bit?q?rd_=3Cmaxime=40cerno=2Etech=3E=2C_linux-sunxi=40lists=2Eli?= =?unknown-8bit?q?nux=2Edev=2C?= =?unknown-8bit?q?_Dave_Stevenson_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E?= =?unknown-8bit?q?=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eorg=3E=2C_in?= =?unknown-8bit?q?tel-gfx=40lists=2Efreedesktop=2Eorg=2C?= =?unknown-8bit?q?_linux-kernel=40vger=2Ekernel=2Eorg=2C_nouveau=40lists=2Efr?= =?unknown-8bit?q?eedesktop=2Eorg=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68?= =?unknown-8bit?q?k=2Eorg=3E=2C?= =?unknown-8bit?q?_linux-arm-kernel=40lists=2Einfradead=2Eorg=2C_Mateusz_Kwia?= =?unknown-8bit?q?tkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C?= =?unknown-8bit?q?_dri-devel=40lists=2Efreedesktop=2Eorg=2C_Hans_de_Goede_=3C?= =?unknown-8bit?q?hdegoede=40redhat=2Ecom=3E=2C_Phil_Elwell_=3Cphil=40raspbe?= =?unknown-8bit?q?rrypi=2Ecom=3E?= X-Mailer: b4 0.11.0-dev-7da52 X-Developer-Signature: v=1; a=openpgp-sha256; l=2335; i=maxime@cerno.tech; h=from:subject:message-id; bh=DlnHi+W0WvgRXYhcJg7Lq5XC1pI5v5EPE6rzTR9Z0BQ=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkeAu6nbc8ypey3XleoarlwmcfV+CertAIruiLSVDqOais1 p3V0lLIwiHExyIopssQImy+JOzXrdScb3zyYOaxMIEMYuDgFYCK1bYwMd03fOnmv8JTaEn4ystL/m2 CHhF/SBEf18Jf5Ca/ieFKjGf7HSjxdvTlQzdGx+6/AxU3HY46lWYe8P3giKL9mlUpK9SM2AA== 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-20221013_061944_528174_51977070 X-CRM114-Status: GOOD ( 10.21 ) 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 From: Mateusz Kwiatkowski The VEC can accept pretty much any relatively reasonable mode, but still has a bunch of constraints to meet. Let's create an atomic_check() implementation that will make sure we don't end up accepting a non-functional mode. Acked-by: Noralf Trønnes Signed-off-by: Mateusz Kwiatkowski Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_vec.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index 90e375a8a8f9..1fcb7baf874e 100644 --- a/drivers/gpu/drm/vc4/vc4_vec.c +++ b/drivers/gpu/drm/vc4/vc4_vec.c @@ -453,6 +453,7 @@ static int vc4_vec_encoder_atomic_check(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state, struct drm_connector_state *conn_state) { + const struct drm_display_mode *mode = &crtc_state->adjusted_mode; const struct vc4_vec_tv_mode *vec_mode; vec_mode = &vc4_vec_tv_modes[conn_state->tv.legacy_mode]; @@ -461,6 +462,53 @@ static int vc4_vec_encoder_atomic_check(struct drm_encoder *encoder, !drm_mode_equal(vec_mode->mode, &crtc_state->adjusted_mode)) return -EINVAL; + if (mode->crtc_hdisplay % 4) + return -EINVAL; + + if (!(mode->crtc_hsync_end - mode->crtc_hsync_start)) + return -EINVAL; + + switch (mode->vtotal) { + case 525: + if (mode->crtc_vtotal > 262) + return -EINVAL; + + if (mode->crtc_vdisplay < 1 || mode->crtc_vdisplay > 253) + return -EINVAL; + + if (!(mode->crtc_vsync_start - mode->crtc_vdisplay)) + return -EINVAL; + + if ((mode->crtc_vsync_end - mode->crtc_vsync_start) != 3) + return -EINVAL; + + if ((mode->crtc_vtotal - mode->crtc_vsync_end) < 4) + return -EINVAL; + + break; + + case 625: + if (mode->crtc_vtotal > 312) + return -EINVAL; + + if (mode->crtc_vdisplay < 1 || mode->crtc_vdisplay > 305) + return -EINVAL; + + if (!(mode->crtc_vsync_start - mode->crtc_vdisplay)) + return -EINVAL; + + if ((mode->crtc_vsync_end - mode->crtc_vsync_start) != 3) + return -EINVAL; + + if ((mode->crtc_vtotal - mode->crtc_vsync_end) < 2) + return -EINVAL; + + break; + + default: + return -EINVAL; + } + return 0; }