From patchwork Thu Sep 22 14:25:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985238 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 4F3F6C6FA91 for ; Thu, 22 Sep 2022 14:25:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A1EC10EB51; Thu, 22 Sep 2022 14:25:46 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id E551410EB4A; Thu, 22 Sep 2022 14:25:40 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id 9FC1E2B05B0E; Thu, 22 Sep 2022 10:25:37 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 22 Sep 2022 10:25:40 -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=1663856737; x= 1663863937; bh=GzvrS3y9EoBmuMQfDZjRp2mrXQsq7hD4pDiqsO5bxJo=; b=z O0lkzAQc8d5bSz1zw6fUw0PxrjRPt1GIQaGr19PmvLipmuPoNYRU7I7rE4TaPmRb /lkeJqqcocFSpqhMgVXvIlYptObRfV9hO7kdmnTzS/0PceojLPMnnXnFcBTIY0QR hf3oseV5OsT8vYCsC1zDXdaKeTIS83RyFHbC9eacBKWWPJi3EqOrmNYIrpTXF1LK qx+Xzir4XfgOeaCe7Y6S0qLcZBwnmfVNXbs2vGXbuml3+Em9Z2O50YugOhQmOJkj VvcQkFxabvS6MxZD+uikr29x4Zqi6mjITODqu7wwMLUHvI+RLlcypIdFcfCWCUy0 QKzk+BbKDZIU9lG5/UFgQ== 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=fm2; t=1663856737; x= 1663863937; bh=GzvrS3y9EoBmuMQfDZjRp2mrXQsq7hD4pDiqsO5bxJo=; b=O kFjFF/VQVd2CVPjVql7OMaTlXjh5zjueL0A/6lOIUiGgEtgZ98qhgVr5V9IIpUWN ReJbSAITabaaFWPnP+3RDHru23Ubh7nkS7P81gNKbq0L17j3C6bKr8OuIzrPAxVt 1yf7ES7kXpmRsjG7LhiVeSB3rGVAsgvTwd0VuzrgiXtQLWCknVzOnIcKz8ECeUCA TqMNpX7IOZN59P/3ypFDhjAw2GH1FBs4ea/7bvUyrOU5y3XAu8BHMR12KeahVb6R buQjdVMH2/1CtHDAixazQJhqi7i8Lf9ol0kZs5uUKo/3QGdkaLez/Vopu+2Uh5G6 RdnbtUlK1gQBlzEd6FtsA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:25:35 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:18 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-1-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1028; i=maxime@cerno.tech; h=from:subject:message-id; bh=xwgXAUzZ4rFgjLxuyhsyeBgnQ3zrH13dR0coPbfjvig=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQG1R5OsNh04f/vsHlnF7aet/yqntn1lYg48/19Ui114 U4NlRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACbicIyR4dVXvxyZDMEc06CKLr/btp HG+30X2zzT61noflyrxvSeBSPDMuHNZ5Nvxq+S8VY7FaB/lfm6ztvdXp11RzUktsRLLzNiBwA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 01/33] drm/tests: Order Kunit tests in Makefile X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Since we've recently added a ton of tests, the list starts to be a bit of a mess and creates unneeded conflicts. Let's order it alphabetically. Signed-off-by: Maxime Ripard Acked-by: Thomas Zimmermann Reviewed-by: Noralf Trønnes diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile index 91b70f7d2769..2d9f49b62ecb 100644 --- a/drivers/gpu/drm/tests/Makefile +++ b/drivers/gpu/drm/tests/Makefile @@ -1,5 +1,13 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_DRM_KUNIT_TEST) += drm_format_helper_test.o drm_damage_helper_test.o \ - drm_cmdline_parser_test.o drm_rect_test.o drm_format_test.o drm_plane_helper_test.o \ - drm_dp_mst_helper_test.o drm_framebuffer_test.o drm_buddy_test.o drm_mm_test.o +obj-$(CONFIG_DRM_KUNIT_TEST) += \ + drm_buddy_test.o \ + drm_cmdline_parser_test.o \ + drm_damage_helper_test.o \ + drm_dp_mst_helper_test.o \ + drm_format_helper_test.o \ + drm_format_test.o \ + drm_framebuffer_test.o \ + drm_mm_test.o \ + drm_plane_helper_test.o \ + drm_rect_test.o From patchwork Thu Sep 22 14:25:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985239 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 425C7C6FA82 for ; Thu, 22 Sep 2022 14:25:59 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C82B10EB5C; Thu, 22 Sep 2022 14:25:54 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1CCF810EB5B; Thu, 22 Sep 2022 14:25:48 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id D1EA42B05B1B; Thu, 22 Sep 2022 10:25:44 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 22 Sep 2022 10:25:47 -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=1663856744; x= 1663863944; bh=FyLoEv/XRYcWy/imcns01ka5K5oR639zUreSPFU77k0=; b=s ytIySoCg+vUAW43gND0wm72QLZJzNT9SXfmDVGWkvEc6G6GKpbv/griOgcZ8iK4+ uftxGMieFFyASvv3gVQb6UWynNxTmvEYC9RRDq7KxNKjMHlmHwrFkj06Y63yJGfc 5oV0Y4+m9/4Rh/X/yX3tXeb0kWfqS5RqqWLWawf+pLRcY5PnSP4/5hYPF3DHvRH7 3cPJA/aHRlw+eJLhmdgbdj+0SisgHPxjlXfNdytmkYVXGXGOwxxFhpgABvnGmqn3 vXDza5StLgMnAoowvm+0ZJftVLXNE1guePY7tGK6y8xwyi3fOy6IIcFkSfHSnSRz Ab5wda2roO+vCgF1MZ5cw== 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=fm2; t=1663856744; x= 1663863944; bh=FyLoEv/XRYcWy/imcns01ka5K5oR639zUreSPFU77k0=; b=o KE628BQV1TnTJZ6SqF8fVd3UbMLyPpuY34UqlA6kPMZQPFDCmYOm3GCEpTjqQRpL Gk+2NYXYX7dHV71odxVjrGhEgyxfUOQquSs/0tWDNWTovrD5Kp1znbloA7C99yGS sA12DhuBYwQD60N/JjXHarPVgwoq7358RLa4+rnY1hfGSMryd0ZOzB5GGrBgTaWs 7QST2O/Sh9EbTzhSy22KMFjaLZ8tI3W8cTcqEWBLzZTsDsd+rn3JaCvxmUPVsi6n tcUy7XL7y63xEMHnXGr7NgkFR8UMz4lZDCf+zCK12firV7Btznzpu2blz5NPh0BV +qiY47TPKu8sLD/m3doBA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:25:43 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:19 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-2-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2632; i=maxime@cerno.tech; h=from:subject:message-id; bh=Jkj0bmR2zQZJoCYiHexMb/PSdpWvmRh+mC/KTK8yntA=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQExhlI5ecZ9h9K69RyPF0U9PfgsMePk741NSsuY1md7 bljUUcrCIMbFICumyBIjbL4k7tSs151sfPNg5rAygQxh4OIUgIlIT2dk2Dzpi/Q79gNbTDxaK6KSzR 0rL6YcrogVqfgznWXjbdG8Lob/qVOqOKdGb+E5ucEh4knovXnxle96ju0PMJZ+uTHkgGkHHwA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 02/33] drm/tests: Add Kunit Helpers X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" As the number of kunit tests in KMS grows further, we start to have multiple test suites that, for example, need to register a mock DRM driver to interact with the KMS function they are supposed to test. Let's add a file meant to provide those kind of helpers to avoid duplication. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile index 2d9f49b62ecb..b29ef1085cad 100644 --- a/drivers/gpu/drm/tests/Makefile +++ b/drivers/gpu/drm/tests/Makefile @@ -8,6 +8,7 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \ drm_format_helper_test.o \ drm_format_test.o \ drm_framebuffer_test.o \ + drm_kunit_helpers.o \ drm_mm_test.o \ drm_plane_helper_test.o \ drm_rect_test.o diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.c b/drivers/gpu/drm/tests/drm_kunit_helpers.c new file mode 100644 index 000000000000..7ebd620481c1 --- /dev/null +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.c @@ -0,0 +1,54 @@ +#include +#include + +#include + +static const struct drm_mode_config_funcs drm_mode_config_funcs = { +}; + +static const struct drm_driver drm_mode_driver = { +}; + +static void drm_kunit_free_device(struct drm_device *drm, void *ptr) +{ + struct device *dev = ptr; + + root_device_unregister(dev); +} + +struct drm_device *drm_kunit_device_init(const char *name) +{ + struct drm_device *drm; + struct device *dev; + int ret; + + dev = root_device_register(name); + if (IS_ERR(dev)) + return ERR_CAST(dev); + + drm = drm_dev_alloc(&drm_mode_driver, dev); + if (IS_ERR(drm)) { + root_device_unregister(dev); + return ERR_CAST(drm); + } + drm->mode_config.funcs = &drm_mode_config_funcs; + + ret = drmm_add_action_or_reset(drm, drm_kunit_free_device, dev); + if (ret) + goto err_put_device; + + ret = drmm_mode_config_init(drm); + if (ret) + return ERR_PTR(ret); + + return drm; + +err_put_device: + drm_dev_put(drm); + return ERR_PTR(ret); +} + +void drm_kunit_device_exit(struct drm_device *drm) +{ + drm_dev_put(drm); +} diff --git a/drivers/gpu/drm/tests/drm_kunit_helpers.h b/drivers/gpu/drm/tests/drm_kunit_helpers.h new file mode 100644 index 000000000000..5015a327a8c1 --- /dev/null +++ b/drivers/gpu/drm/tests/drm_kunit_helpers.h @@ -0,0 +1,9 @@ +#ifndef DRM_KUNIT_HELPERS_H_ +#define DRM_KUNIT_HELPERS_H_ + +struct drm_device; + +struct drm_device *drm_kunit_device_init(const char *name); +void drm_kunit_device_exit(struct drm_device *drm); + +#endif // DRM_KUNIT_HELPERS_H_ From patchwork Thu Sep 22 14:25:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985241 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 43699C54EE9 for ; Thu, 22 Sep 2022 14:26:16 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E9B210EB52; Thu, 22 Sep 2022 14:26:08 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2F50F10EB6D; Thu, 22 Sep 2022 14:25:56 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id E1B6C2B05B0E; Thu, 22 Sep 2022 10:25:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 22 Sep 2022 10:25:55 -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=1663856752; x= 1663863952; bh=i9unItsm3a3vM09vyHvrM0LwqCiC5ydn42Al/bALvVY=; b=X MWc9DTbRxORF6Hy+zZ08Kejuch4Cx/i3W7Xc09w0ajgnOcVCta2V254R5MjbR5T0 un3rKTEWfcnNfVtHyVCM6pZiaHUCfMZlt1Hup0Pz5wq9xOdraVGSS0FqZApkTKXD wgu7uhICR4XRdla35k6AwKRjxBQD18FKLGNDU8tZ9Z4Gd/0BDOaoDeu8x5gmmr6i Ls81SK/MTM7v+CXINLJcxl9RXzVP1hDTioU20uknkIdqikrNfaTCsvWKw/AUoF3K EkMeWCay8S45Tmf77qwmR94TmK3dtkPNH7z2tsBmjexRlrFGt44r+hmQQEPnJph5 sze22f/37pkEHos8i0HQA== 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=fm2; t=1663856752; x= 1663863952; bh=i9unItsm3a3vM09vyHvrM0LwqCiC5ydn42Al/bALvVY=; b=Y hZ6JXoTCqlNoLZw+88MU/fxYUVJ8ck/5g3ijOxYBPPOmITTCY3wMxig0tNoCUog6 9WLRDRVjSrYtZ5J6zNyhy05xM0C/VW5EWsvIQkdwVSQOL/b9YOmol07GznE2FDG2 jq+ZlfYfpFuIrBH56sK/F4jdTV52xcJ54TRUS8jUbdRT0JaczGuGXwnFk2edA3tu vMY/6yqGadXnUlpIz6adABcna6qIcXg8yk01DT2fnoBIu1dwMIwML35gcF3QouxL 3wl9FgEcalIKI1lqrp8RSIv/taGzodv9uhqH17fCi8sNeC6zsUM1VK8ygBY5hCyn KQYbMxyMt9jYSIMBNSRFg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufgggfgtkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepveejudekteevveefhffhudefkedtgfettefgieejtdffieffheeuhedt heeikeeunecuffhomhgrihhnpehmrghrghhinhhsrdhtohhpnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordht vggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:25:49 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:20 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-3-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4923; i=maxime@cerno.tech; h=from:subject:message-id; bh=p2LpArUJ8YB0hNgt7hVrVP+WwQ+3bZgbszS3vXAQO7Q=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQFc8xSuSP5f/3/ygvLW2lwDZ9uupK4o7p9nlt0XnLLp qE9GRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACZy7TAjw6vWGNn5k2NnyCYXXveb8H Pazbr9ll7SBntiJD7tFlPoyWJkmN3AmX08SSV+wuOjK9LlVexNVyhXbNylZnD80a9tfx2T+AE= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 03/33] drm/atomic-helper: Rename drm_atomic_helper_connector_tv_reset to avoid ambiguity X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We currently have two sets of TV properties. The first one is there to deal with analog TV properties, creating properties such as the TV mode, subconnectors, saturation, hue and so on. It's created by calling the drm_mode_create_tv_properties() function. The second one is there to deal with properties that might be useful on a TV, creating the overscan margins for example. It's created by calling the drm_mode_create_tv_margin_properties(). However, we also have a drm_atomic_helper_connector_tv_reset() function that will reset the TV margin properties to their default values, and thus is supposed to be called for the latter set. This creates an ambiguity due to the inconsistent naming. We can thus rename the drm_atomic_helper_connector_tv_reset() function to drm_atomic_helper_connector_tv_margins_reset() to remove that ambiguity and hopefully make it more obvious. Reviewed-by: Noralf Trønnes Signed-off-by: Maxime Ripard Acked-by: Thomas Zimmermann diff --git a/drivers/gpu/drm/drm_atomic_state_helper.c b/drivers/gpu/drm/drm_atomic_state_helper.c index bf31b9d92094..dfb57217253b 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -464,12 +464,12 @@ void drm_atomic_helper_connector_reset(struct drm_connector *connector) EXPORT_SYMBOL(drm_atomic_helper_connector_reset); /** - * drm_atomic_helper_connector_tv_reset - Resets TV connector properties + * drm_atomic_helper_connector_tv_margins_reset - Resets TV connector properties * @connector: DRM connector * * Resets the TV-related properties attached to a connector. */ -void drm_atomic_helper_connector_tv_reset(struct drm_connector *connector) +void drm_atomic_helper_connector_tv_margins_reset(struct drm_connector *connector) { struct drm_cmdline_mode *cmdline = &connector->cmdline_mode; struct drm_connector_state *state = connector->state; @@ -479,7 +479,7 @@ void drm_atomic_helper_connector_tv_reset(struct drm_connector *connector) state->tv.margins.top = cmdline->tv_margins.top; state->tv.margins.bottom = cmdline->tv_margins.bottom; } -EXPORT_SYMBOL(drm_atomic_helper_connector_tv_reset); +EXPORT_SYMBOL(drm_atomic_helper_connector_tv_margins_reset); /** * __drm_atomic_helper_connector_duplicate_state - copy atomic connector state diff --git a/drivers/gpu/drm/gud/gud_connector.c b/drivers/gpu/drm/gud/gud_connector.c index d0addd478815..fa636206f232 100644 --- a/drivers/gpu/drm/gud/gud_connector.c +++ b/drivers/gpu/drm/gud/gud_connector.c @@ -355,7 +355,7 @@ static void gud_connector_reset(struct drm_connector *connector) drm_atomic_helper_connector_reset(connector); connector->state->tv = gconn->initial_tv_state; /* Set margins from command line */ - drm_atomic_helper_connector_tv_reset(connector); + drm_atomic_helper_connector_tv_margins_reset(connector); if (gconn->initial_brightness >= 0) connector->state->tv.brightness = gconn->initial_brightness; } diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c index 4d3ff51ad2a8..fe01ca5a07d3 100644 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c @@ -396,7 +396,7 @@ static void vc4_hdmi_connector_reset(struct drm_connector *connector) new_state->base.max_bpc = 8; new_state->base.max_requested_bpc = 8; new_state->output_format = VC4_HDMI_OUTPUT_RGB; - drm_atomic_helper_connector_tv_reset(connector); + drm_atomic_helper_connector_tv_margins_reset(connector); } static struct drm_connector_state * diff --git a/include/drm/drm_atomic_state_helper.h b/include/drm/drm_atomic_state_helper.h index 3f8f1d627f7c..192766656b88 100644 --- a/include/drm/drm_atomic_state_helper.h +++ b/include/drm/drm_atomic_state_helper.h @@ -70,7 +70,7 @@ void __drm_atomic_helper_connector_state_reset(struct drm_connector_state *conn_ 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); +void drm_atomic_helper_connector_tv_margins_reset(struct drm_connector *connector); void __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector, struct drm_connector_state *state); diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 248206bbd975..23112f0c11cf 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -692,7 +692,7 @@ struct drm_connector_tv_margins { /** * struct drm_tv_connector_state - TV connector related states - * @subconnector: selected subconnector + * @select_subconnector: selected subconnector * @margins: TV margins * @mode: TV mode * @brightness: brightness in percent From patchwork Thu Sep 22 14:25:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985240 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 05FA1C6FA82 for ; Thu, 22 Sep 2022 14:26:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6004B10EB50; Thu, 22 Sep 2022 14:26:08 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 861A110EB53; Thu, 22 Sep 2022 14:26:02 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id 4018A2B05B1D; Thu, 22 Sep 2022 10:25:59 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 22 Sep 2022 10:26:01 -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=1663856758; x= 1663863958; bh=nul9kf+nsMkA73YYqXmZqsBmb7KKOwrv3IixGzHTnrI=; b=z cJ41D1wcu9jDkb3YA6v5AMNmOUSg+beGL/22S7FuoA2FCrBDF3vR/v1HLpvD7hCs rkFDKR1OtDHCZ2iYWvTET+aSPnex7ycvCJ3Xowa73koy+MsCLIvwqYDjxFh7kKx3 Mu/VO5BnZadiiXMrHevCzJUCCEeFWM+vXyeQejwvPhItxtiqXfcdCpVVGfyNBwG0 /EaRMt569uJcpm3mFTfVDGlIZEWmezkdkVSZwtN4fclYR7NoKrZXJBBtUX9vIJTn 5uWcAwWbs2tFxRAPX7LvKLhlv1LqZiEGZsvxw+Y2WuO3/UV6gZA4He4ErtWJeMl0 YRMb2pwPkm2Tj5BqIpKuA== 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=fm2; t=1663856758; x= 1663863958; bh=nul9kf+nsMkA73YYqXmZqsBmb7KKOwrv3IixGzHTnrI=; b=V WXCNtqFjj9afjyMLVqdgehrflK5nsUCBCMAsEx8sdgoRxXmJdHg+KV2D+tUJsdI2 jDDUaansTrxFhHEnO1x0Ad7OcwWAuMd4tA7nTdnKhpy1X0MbuBgWTa8DlaYZqBnb Aa+8NyYGRcaBEkguE5/62jde5nxJwdRVVKZamwZ7XAyP+OpGp6nyxLK8anKE2GXJ /BKwl6Mi9BYd+l+rKM8tcHVuQq1E6GohcZbn7DwP7ONQQk09oKn+AzPYgLsQ9DAz R2UQ4G32eU9HRGEtIn+fVvjVtej/M+v+PaR5/4m99FdchxourRqYqPjgTSbGKwY+ ryy3EDMJkVhGEVNcriC2g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufgggfgtkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvdfgveejhfdtteevvefhleeiueeutefgvdegveekgedujeffgeffgfet tdellefhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:25:57 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:21 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-4-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2234; i=maxime@cerno.tech; h=from:subject:message-id; bh=k9cAlnoIw4NgF/43YMLUlzcaGpJunDmXDutQHu2BS6w=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQEmm/K2JumnxEjeN/v2r2jXRMlg00nNIk+uhr6R+Mq1 9cnajlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAEzkbyHDH97DzzJ2pByX/9b40afX68 r843d3rVGI/77iRHbVjaJpiysZGR61yqyKi9Pq77bh/7exdLaCEeO9pbz/qzmFM9007tqd4AIA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 04/33] drm/connector: Rename subconnector state variable X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" There is two TV subconnector related properties registered by drm_mode_create_tv_properties(): subconnector and select subconnector. While the select subconnector property is stored in the kernel by the drm_tv_connector_state structure, the subconnector property isn't stored anywhere. Worse, the select subconnector property is stored in a field called subconnector, creating some ambiguity about which property content we're accessing. Let's rename that field to one called select_subconnector to make it move obvious what it's about. Reviewed-by: Noralf Trønnes Signed-off-by: Maxime Ripard Acked-by: Thomas Zimmermann diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 79730fa1dd8e..c74c78a28171 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -687,7 +687,7 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, */ return -EINVAL; } else if (property == config->tv_select_subconnector_property) { - state->tv.subconnector = val; + state->tv.select_subconnector = val; } else if (property == config->tv_left_margin_property) { state->tv.margins.left = val; } else if (property == config->tv_right_margin_property) { @@ -795,7 +795,7 @@ drm_atomic_connector_get_property(struct drm_connector *connector, else *val = connector->dpms; } else if (property == config->tv_select_subconnector_property) { - *val = state->tv.subconnector; + *val = state->tv.select_subconnector; } else if (property == config->tv_left_margin_property) { *val = state->tv.margins.left; } else if (property == config->tv_right_margin_property) { diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 23112f0c11cf..60b5662dec7c 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -703,7 +703,7 @@ struct drm_connector_tv_margins { * @hue: hue in percent */ struct drm_tv_connector_state { - enum drm_mode_subconnector subconnector; + enum drm_mode_subconnector select_subconnector; struct drm_connector_tv_margins margins; unsigned int mode; unsigned int brightness; From patchwork Thu Sep 22 14:25:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985242 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 26FA0C6FA82 for ; Thu, 22 Sep 2022 14:26:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4DDFF10EB59; Thu, 22 Sep 2022 14:26:16 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id B9E9810EB58; Thu, 22 Sep 2022 14:26:10 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id 7C2FB2B05B17; Thu, 22 Sep 2022 10:26:06 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 22 Sep 2022 10:26:10 -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=1663856766; x= 1663863966; bh=rvMfktgHy5FhCaD+KHa3yzMfq+yFQMkfoAap0/0FluY=; b=O FaiSKEhRINEVsGsTUwjEfoFmSO7lPr3iFSHKlUPUf9u/kOQkY/0cJ8U0vxK+W2HU E7kSoygrS2qCOCMuUzbC6OB2zHukP+rqQv1VOPOXDGptTFtelDiAXy8PI+tCKbZr Q1s8rG+lHqhFTq2QE5BDAAlMPfk81rau9ybmqTKEEezNvY44TiymESXwjB+32H7U EUB9h7ietgBVsbtyEDgIoCroZmp9EnusNo18DFvvWDNitLN1Pi9oMZp6jgTBxqY2 xraHnqiEwOqPZVlBCOfojiBJL+Qn0AbQzXm+FTTxgA1Hsb9w3cVl++GU2CV7lUlP fbEF8jVKMMtThD8Zbp/Kg== 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=fm2; t=1663856766; x= 1663863966; bh=rvMfktgHy5FhCaD+KHa3yzMfq+yFQMkfoAap0/0FluY=; b=v R3hAs7aZ7pw1v0EfIpiMXRV9SDLJ56RA69Ge19CtZVq5vf3/8MCMVvU+7kNtO2X1 xhQo0BBjFJtshZ2FcTOlhZl6sj+v6CcD4sHYX1YN9Uq0rhTo6ITSKHBjvLZlfSCe DZKnYYeMCT5ZSbsPYngkAov9Q/DmDnCnKViLKCRYmjL2bo+of1zLQJZaZzfwth+G hceZgWh8R8dsX8LIETElUDKEDYNrJMuGjwJfYG9DJvM5GCXArABtr3/KAxTXeIRp ymgHsIudnaM00BR2D1d/uWL4CST/yr4fyJQSb2r6GSrmiKoAAUwcwVymueTDj10W m64Q4RfRQUyOToyiztauw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufgggfgtkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvdfgveejhfdtteevvefhleeiueeutefgvdegveekgedujeffgeffgfet tdellefhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:26:04 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:22 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-5-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2310; i=maxime@cerno.tech; h=from:subject:message-id; bh=qDYM7aQiVENXoG6IHQvxJCBCpTNzU5wd8MrHn657838=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQEJzp2ye1L/+Ekt4lj9prDhf0QHr+D2fdv3dkiG8C1g 0lDsKGVhEONikBVTZIkRNl8Sd2rW6042vnkwc1iZQIYwcHEKwERS8hgZ5j7fV1RYlsfcWP/huorE1c Tv+WrnjUS0jGPDfZqjQy4XMvzTvpWzU5SZ97wBX1HPUuXrP850n/uUoKiW97XLaEr6PkEGAA== X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 05/33] drm/atomic: Add TV subconnector property to get/set_property X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The subconnector property was created by drm_mode_create_tv_properties(), but wasn't exposed to the userspace through the generic atomic_get/set_property implementation, and wasn't stored in any generic state structure. Let's solve this. Reviewed-by: Noralf Trønnes Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index c74c78a28171..c06d0639d552 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -688,6 +688,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, return -EINVAL; } else if (property == config->tv_select_subconnector_property) { state->tv.select_subconnector = val; + } else if (property == config->tv_subconnector_property) { + state->tv.subconnector = val; } else if (property == config->tv_left_margin_property) { state->tv.margins.left = val; } else if (property == config->tv_right_margin_property) { @@ -796,6 +798,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = connector->dpms; } else if (property == config->tv_select_subconnector_property) { *val = state->tv.select_subconnector; + } else if (property == config->tv_subconnector_property) { + *val = state->tv.subconnector; } else if (property == config->tv_left_margin_property) { *val = state->tv.margins.left; } else if (property == config->tv_right_margin_property) { diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 60b5662dec7c..1d5e3cccb9e3 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -693,6 +693,7 @@ struct drm_connector_tv_margins { /** * struct drm_tv_connector_state - TV connector related states * @select_subconnector: selected subconnector + * @subconnector: detected subconnector * @margins: TV margins * @mode: TV mode * @brightness: brightness in percent @@ -704,6 +705,7 @@ struct drm_connector_tv_margins { */ struct drm_tv_connector_state { enum drm_mode_subconnector select_subconnector; + enum drm_mode_subconnector subconnector; struct drm_connector_tv_margins margins; unsigned int mode; unsigned int brightness; From patchwork Thu Sep 22 14:25:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985243 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 CB9B9C6FA86 for ; Thu, 22 Sep 2022 14:26:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8596110EB53; Thu, 22 Sep 2022 14:26:22 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 18EB610EB5D; Thu, 22 Sep 2022 14:26:17 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id CCED62B05B1C; Thu, 22 Sep 2022 10:26:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 22 Sep 2022 10:26: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=1663856773; x= 1663863973; bh=sA9EhaZI6M2r1hnuJVGduEFvajBQuaCA071tF6Bkn1o=; b=p c95+qgh/O772hYGo/pBqfjAOjPSMyka6iTdfXbwJg3FyxEcHvcv4dUV+yNx0xkXi 81rnkMPBVsAD8luvCDoIyHZfCv3iKxPa/dDNhMtdExX6Di0gDXVEy17XlNr/mpmY abUj5AJ08t72Wb3F9COLCyLOnj3FdSR2MaIArRq0yMHqntSEteixeeBa1r/dXTAY 6GW0iq9VOT7ppxPQ2Pgxz07LQTxm/PBMqsWgtxhgzoUdKfdwbr9dRM6YpJayDbHr wWgivjIZmVwJVFPpN9Qf51cYxoq1ocvQ2kvHrV3RGz78fkko8JruOzjnspjzTlo/ eWR7VWrxa0jfWfDWuuqIw== 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=fm2; t=1663856773; x= 1663863973; bh=sA9EhaZI6M2r1hnuJVGduEFvajBQuaCA071tF6Bkn1o=; b=D N5g/KFNGc7xBCfHVRIOK72zkGIWgYyUyMEYno1C9vjyiBm3/4gczTXgzNO0TJLUw LSyI2TFp6tGdwg6knkI+IepPafEPepV2Eh0VKtccH1U4ovivoe2BkMPFLi96m8LC Otol5xGWHlAIEJJRguD5QA33gN4ZoAat6GLnroUN5a6dU6rb8EwghTCAt/4zX9YR moPBTWobRGyE/sfnLeqUApt5WB6YhrABT87R3CYVqq+J41YzOVCiMtPrKi7Lf+FS /Q7IG+o/Auv8m7OyoRf1pWWTZBSMaVNSCypapp2yNNpliXLXndTcmo8VtI2dnFNf 3s655uMKGygW0961oRIvA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepfeejteejhfdvhfeukeekudevjedvheelteeigffgudetfeduuddvvddv keeklefgnecuffhomhgrihhnpehmrghrghhinhhsrdhtohhpnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordht vggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:26:12 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:23 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-6-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9818; i=maxime@cerno.tech; h=from:subject:message-id; bh=3UvOfa1TpUUqsOT3A3Tgkj+cYjZVTP+CUe9TUNwG1Vk=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQGlPzNMHYP39d82YOF5Y8u9r/gif86LqinGD18y3VGa 0feoo5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABNJX8XwP0d06r9peTel4vsSZJjezt y7X5KrOnVmy7mOJeflrjNOP83wT1U0ZV9srMTHovcP2EW0sp2TQ9xzQgyi3FUireaaLrnCDgA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 06/33] drm/connector: Rename legacy TV property X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The current tv_mode has driver-specific values that don't allow to easily share code using it, either at the userspace or kernel level. Since we're going to introduce a new, generic, property that fit the same purpose, let's rename this one to legacy_tv_mode to make it obvious we should move away from it. Signed-off-by: Maxime Ripard Reviewed-by: Lyude Paul Acked-by: Thomas Zimmermann Reviewed-by: Noralf Trønnes diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index c06d0639d552..7f2b9a07fbdf 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -698,8 +698,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, state->tv.margins.top = val; } else if (property == config->tv_bottom_margin_property) { state->tv.margins.bottom = val; - } else if (property == config->tv_mode_property) { - state->tv.mode = val; + } else if (property == config->legacy_tv_mode_property) { + state->tv.legacy_mode = val; } else if (property == config->tv_brightness_property) { state->tv.brightness = val; } else if (property == config->tv_contrast_property) { @@ -808,8 +808,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = state->tv.margins.top; } else if (property == config->tv_bottom_margin_property) { *val = state->tv.margins.bottom; - } else if (property == config->tv_mode_property) { - *val = state->tv.mode; + } else if (property == config->legacy_tv_mode_property) { + *val = state->tv.legacy_mode; } else if (property == config->tv_brightness_property) { *val = state->tv.brightness; } else if (property == config->tv_contrast_property) { diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index e3142c8142b3..ede6025638d7 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -1686,14 +1686,14 @@ int drm_mode_create_tv_properties(struct drm_device *dev, if (drm_mode_create_tv_margin_properties(dev)) goto nomem; - dev->mode_config.tv_mode_property = + dev->mode_config.legacy_tv_mode_property = drm_property_create(dev, DRM_MODE_PROP_ENUM, "mode", num_modes); - if (!dev->mode_config.tv_mode_property) + if (!dev->mode_config.legacy_tv_mode_property) goto nomem; for (i = 0; i < num_modes; i++) - drm_property_add_enum(dev->mode_config.tv_mode_property, + drm_property_add_enum(dev->mode_config.legacy_tv_mode_property, i, modes[i]); dev->mode_config.tv_brightness_property = diff --git a/drivers/gpu/drm/gud/gud_connector.c b/drivers/gpu/drm/gud/gud_connector.c index fa636206f232..86e992b2108b 100644 --- a/drivers/gpu/drm/gud/gud_connector.c +++ b/drivers/gpu/drm/gud/gud_connector.c @@ -303,7 +303,7 @@ static int gud_connector_atomic_check(struct drm_connector *connector, old_state->tv.margins.right != new_state->tv.margins.right || old_state->tv.margins.top != new_state->tv.margins.top || old_state->tv.margins.bottom != new_state->tv.margins.bottom || - old_state->tv.mode != new_state->tv.mode || + old_state->tv.legacy_mode != new_state->tv.legacy_mode || old_state->tv.brightness != new_state->tv.brightness || old_state->tv.contrast != new_state->tv.contrast || old_state->tv.flicker_reduction != new_state->tv.flicker_reduction || @@ -424,7 +424,7 @@ gud_connector_property_lookup(struct drm_connector *connector, u16 prop) case GUD_PROPERTY_TV_BOTTOM_MARGIN: return config->tv_bottom_margin_property; case GUD_PROPERTY_TV_MODE: - return config->tv_mode_property; + return config->legacy_tv_mode_property; case GUD_PROPERTY_TV_BRIGHTNESS: return config->tv_brightness_property; case GUD_PROPERTY_TV_CONTRAST: @@ -454,7 +454,7 @@ static unsigned int *gud_connector_tv_state_val(u16 prop, struct drm_tv_connecto case GUD_PROPERTY_TV_BOTTOM_MARGIN: return &state->margins.bottom; case GUD_PROPERTY_TV_MODE: - return &state->mode; + return &state->legacy_mode; case GUD_PROPERTY_TV_BRIGHTNESS: return &state->brightness; case GUD_PROPERTY_TV_CONTRAST: diff --git a/drivers/gpu/drm/i2c/ch7006_drv.c b/drivers/gpu/drm/i2c/ch7006_drv.c index b91e48d2190d..d29b63fd6178 100644 --- a/drivers/gpu/drm/i2c/ch7006_drv.c +++ b/drivers/gpu/drm/i2c/ch7006_drv.c @@ -264,7 +264,7 @@ static int ch7006_encoder_create_resources(struct drm_encoder *encoder, priv->hmargin); drm_object_attach_property(&connector->base, conf->tv_bottom_margin_property, priv->vmargin); - drm_object_attach_property(&connector->base, conf->tv_mode_property, + drm_object_attach_property(&connector->base, conf->legacy_tv_mode_property, priv->norm); drm_object_attach_property(&connector->base, conf->tv_brightness_property, priv->brightness); @@ -315,7 +315,7 @@ static int ch7006_encoder_set_property(struct drm_encoder *encoder, ch7006_load_reg(client, state, CH7006_POV); ch7006_load_reg(client, state, CH7006_VPOS); - } else if (property == conf->tv_mode_property) { + } else if (property == conf->legacy_tv_mode_property) { if (connector->dpms != DRM_MODE_DPMS_OFF) return -EINVAL; diff --git a/drivers/gpu/drm/i915/display/intel_tv.c b/drivers/gpu/drm/i915/display/intel_tv.c index 9379f3463344..abaf9ded942d 100644 --- a/drivers/gpu/drm/i915/display/intel_tv.c +++ b/drivers/gpu/drm/i915/display/intel_tv.c @@ -1986,7 +1986,8 @@ intel_tv_init(struct drm_i915_private *dev_priv) } drm_mode_create_tv_properties(dev, i, tv_format_names); - drm_object_attach_property(&connector->base, dev->mode_config.tv_mode_property, + drm_object_attach_property(&connector->base, + dev->mode_config.legacy_tv_mode_property, state->tv.mode); drm_object_attach_property(&connector->base, dev->mode_config.tv_left_margin_property, diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c index be28e7bd7490..1a15534adc60 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c +++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c @@ -662,7 +662,7 @@ static int nv17_tv_create_resources(struct drm_encoder *encoder, conf->tv_subconnector_property, tv_enc->subconnector); drm_object_attach_property(&connector->base, - conf->tv_mode_property, + conf->legacy_tv_mode_property, tv_enc->tv_norm); drm_object_attach_property(&connector->base, conf->tv_flicker_reduction_property, @@ -722,7 +722,7 @@ static int nv17_tv_set_property(struct drm_encoder *encoder, if (encoder->crtc) nv17_tv_update_rescaler(encoder); - } else if (property == conf->tv_mode_property) { + } else if (property == conf->legacy_tv_mode_property) { if (connector->dpms != DRM_MODE_DPMS_OFF) return -EINVAL; diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index 0b3333865702..77c50ecb0309 100644 --- a/drivers/gpu/drm/vc4/vc4_vec.c +++ b/drivers/gpu/drm/vc4/vc4_vec.c @@ -274,7 +274,7 @@ static int vc4_vec_connector_get_modes(struct drm_connector *connector) struct drm_display_mode *mode; mode = drm_mode_duplicate(connector->dev, - vc4_vec_tv_modes[state->tv.mode].mode); + vc4_vec_tv_modes[state->tv.legacy_mode].mode); if (!mode) { DRM_ERROR("Failed to create a new display mode\n"); return -ENOMEM; @@ -312,7 +312,7 @@ static int vc4_vec_connector_init(struct drm_device *dev, struct vc4_vec *vec) drm_connector_helper_add(connector, &vc4_vec_connector_helper_funcs); drm_object_attach_property(&connector->base, - dev->mode_config.tv_mode_property, + dev->mode_config.legacy_tv_mode_property, VC4_VEC_TV_MODE_NTSC); drm_connector_attach_encoder(connector, &vec->encoder.base); @@ -449,7 +449,7 @@ static int vc4_vec_encoder_atomic_check(struct drm_encoder *encoder, { const struct vc4_vec_tv_mode *vec_mode; - vec_mode = &vc4_vec_tv_modes[conn_state->tv.mode]; + vec_mode = &vc4_vec_tv_modes[conn_state->tv.legacy_mode]; if (conn_state->crtc && !drm_mode_equal(vec_mode->mode, &crtc_state->adjusted_mode)) diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 1d5e3cccb9e3..5cfad8b6ad83 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -695,7 +695,7 @@ struct drm_connector_tv_margins { * @select_subconnector: selected subconnector * @subconnector: detected subconnector * @margins: TV margins - * @mode: TV mode + * @legacy_mode: Legacy TV mode, driver specific value * @brightness: brightness in percent * @contrast: contrast in percent * @flicker_reduction: flicker reduction in percent @@ -707,7 +707,7 @@ struct drm_tv_connector_state { enum drm_mode_subconnector select_subconnector; enum drm_mode_subconnector subconnector; struct drm_connector_tv_margins margins; - unsigned int mode; + unsigned int legacy_mode; unsigned int brightness; unsigned int contrast; unsigned int flicker_reduction; diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 6b5e01295348..35a827175c24 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -714,11 +714,13 @@ struct drm_mode_config { * between different TV connector types. */ struct drm_property *tv_select_subconnector_property; + /** - * @tv_mode_property: Optional TV property to select + * @legacy_tv_mode_property: Optional TV property to select * the output TV mode. */ - struct drm_property *tv_mode_property; + struct drm_property *legacy_tv_mode_property; + /** * @tv_left_margin_property: Optional TV property to set the left * margin (expressed in pixels). From patchwork Thu Sep 22 14:25:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985245 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 5808DC6FA92 for ; Thu, 22 Sep 2022 14:26:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BA18110EB70; Thu, 22 Sep 2022 14:26:51 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id A4E2710EB5F; Thu, 22 Sep 2022 14:26:24 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id C85CC2B05B0E; Thu, 22 Sep 2022 10:26:20 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 22 Sep 2022 10:26:24 -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=1663856780; x= 1663863980; bh=oRoGbxOixjA/FGsVjJsObmY8HyU8mXROxlcsJBjmCK4=; b=r M3n8JdbjXgjr1O+Sd2xCag4oK48llGSo95yC5YhEPiJNB+gmI95Lutqb8SDmSmyK z7gox+zX+aX0v8f0B628j0qib1SjWpunpL+eAa+I8Ssf7FmlI9eYa3Km5mI2+YA3 tFca70ZedPkKAhcyUfH+Y/PmwMQDMPS3xNON0ZZ+IT1JSnevuRaYb0jvnw7tNhe4 ezKMb7zTqFHqwdALxgMD4zW5o77cBstuOSyFV8pFxcvcFTZUU4izcly8je8cN69o plfKcylx1E3WMcBf/W9ZdHYCbIzBA1FW+55ttTF8IrbEHTmFFf/bW5un6M5cNMU0 /uEWH0h075JnHr+1Or4Rg== 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=fm2; t=1663856780; x= 1663863980; bh=oRoGbxOixjA/FGsVjJsObmY8HyU8mXROxlcsJBjmCK4=; b=l kf+8ecgyih+WUXsMd9xEYY+7n10huLj3KcQ3Jr8dYUGtdC1b5cGt3gmnOYWhh18D TnI55k14GO2G0HFX0UlkYKI4ggXZTEot1ewEip7qWgxzFBh807TPIQUM+L97Vo54 Lq7T7Jcur/ubUfxa9aV3tctHJcGm4mPMAGVH06ebeXQcWB/JLNaMBDMVbces+SNj u3jn1AUifvrQPEu5TAmXrQlfuY3vS8OxLxiDqfgFKkXMvNUHdv4TIjP8Bn9G/Wak WTpRlswUvUhN6KTGjdymxrclThyebtPnNX84WAsOaPwlQwl3z2hN/Zwn9KI+yWYg 06DVbB3505ZAhDZRxb+YA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufgggfgtkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvdfgveejhfdtteevvefhleeiueeutefgvdegveekgedujeffgeffgfet tdellefhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:26:19 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:24 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-7-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1493; i=maxime@cerno.tech; h=from:subject:message-id; bh=K1P8wOW1lXc6QlwFPGKbGqRYBhsEzf9zE4LsFjXniIg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQGHXmol/OEJXP7GaMGVrX9Yml1eSD/OnnxTudbj0coD aw/O7ShlYRDjYpAVU2SJETZfEndq1utONr55MHNYmUCGMHBxCsBEHn9i+O/vJTt15rsJa66FruW9VB O5dZ5wj+aetVqXLQVE5y6ScxJj+MOZp5C668wsQf4z5848NOlLm7fzFuO8g/8fNurqLXwiXM4JAA== X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 07/33] drm/connector: Only register TV mode property if present X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The drm_create_tv_properties() will create the TV mode property unconditionally. However, since we'll gradually phase it out, let's register it only if we have a list passed as an argument. This will make the transition easier. Acked-by: Noralf Trønnes Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index ede6025638d7..17a5913cefe3 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -1686,15 +1686,18 @@ int drm_mode_create_tv_properties(struct drm_device *dev, if (drm_mode_create_tv_margin_properties(dev)) goto nomem; - dev->mode_config.legacy_tv_mode_property = - drm_property_create(dev, DRM_MODE_PROP_ENUM, - "mode", num_modes); - if (!dev->mode_config.legacy_tv_mode_property) - goto nomem; - for (i = 0; i < num_modes; i++) - drm_property_add_enum(dev->mode_config.legacy_tv_mode_property, - i, modes[i]); + if (num_modes) { + dev->mode_config.legacy_tv_mode_property = + drm_property_create(dev, DRM_MODE_PROP_ENUM, + "mode", num_modes); + if (!dev->mode_config.legacy_tv_mode_property) + goto nomem; + + for (i = 0; i < num_modes; i++) + drm_property_add_enum(dev->mode_config.legacy_tv_mode_property, + i, modes[i]); + } dev->mode_config.tv_brightness_property = drm_property_create_range(dev, 0, "brightness", 0, 100); From patchwork Thu Sep 22 14:25:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985246 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 97CA1C54EE9 for ; Thu, 22 Sep 2022 14:26:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 308C510EB68; Thu, 22 Sep 2022 14:26:51 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 08BAF10EB66; Thu, 22 Sep 2022 14:26:32 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id BD3272B05B1B; Thu, 22 Sep 2022 10:26:28 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 22 Sep 2022 10:26:31 -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=1663856788; x= 1663863988; bh=xCOQtVW6tJaOXeb7kZe07M5hPdvjo9hC/bd/4Xqxv5M=; b=F ycq+AaaskJrUTBwrP+7umu2Da9bWrZ27O2mhJkQZGaZDyV4ww625Rb/kT4CKfi36 /IVzz1qi67oHU3128IpzbwJx3GRNoZIo/0FtztvTHcPh9vEYSYyJjAWk/Ouv5aeb dASLPPMnCmuX/Avb0HtGqWf/lvI/f7Mt4aHdJcXgJ9ts2OOPFuDEIjRrmV/q0d/K pri69IGg7K9pi2ib+vff/i+f1vEqraVkr/UTa+egrtCGav+ilvLdFwFEhXmVY/LW 3YaONJcn+fgOrzTnMlUbYnIMFcBAYnaSvyhW4mC5F2iIY3u0JnSpcv+sNh3XjlLr Rsn+284sazz6XCaCW13Wg== 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=fm2; t=1663856788; x= 1663863988; bh=xCOQtVW6tJaOXeb7kZe07M5hPdvjo9hC/bd/4Xqxv5M=; b=R w4Cgf8F52EUuWNkjZRh4MkAJg4WVniHDTTY6IVXlAxJ7GMTLZCumhVi9DVd7kfTo YzsYMEX7VILwckHOmcpbfm3bu5fBi+stYxTpxiyFNBCOvx9zSr5jmWV6zEc32UFo Y0VJuUMH5CfbewNBEJHIBQCZtH6uXPOTBVAfqinhrihOca5tFy+3eb6TX9XTavFb uGihDOR4dpB3J5w5rtKtTiQLWMvWz30y9egNab1VcebUGKq0uP0fZKAxrzBsczn2 Vpwh8ihzQhJQm62EyoKffp4yNzcjlXqr3SSAz+XqwS2AGrmLQBkqLCBAW24nWO0K iCfLmTHmwFvuTxonuxXtg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:26:27 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:25 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-8-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6669; i=maxime@cerno.tech; h=from:subject:message-id; bh=sbhktNdaVKnHJ3MQxkK/mjJ+RzYyXsAOcMURsaQVMOs=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQEcTN1xvgEzVrDqKkn+n6n+4O3R3U9z7NesDblte2Wu /DGVjlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAEzkSQojw8Kp/nz/1Z2uci04k908I9 WgTuCivKTLw0d5rgazYhd1FTD8L0g0nrLuSfyd9dyyclOVI9QlH3YmnfBa/LBEzzLZ/bI2DwA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 08/33] drm/connector: Rename drm_mode_create_tv_properties X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" drm_mode_create_tv_properties(), among other things, will create the "mode" property that stores the analog TV mode that connector is supposed to output. However, that property is getting deprecated, so let's rename that function to mention it's deprecated. We'll introduce a new variant of that function creating the property superseeding it in a later patch. Signed-off-by: Maxime Ripard Reviewed-by: Lyude Paul Reviewed-by: Noralf Trønnes diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 17a5913cefe3..4e4fbc9e0049 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -1600,7 +1600,7 @@ EXPORT_SYMBOL(drm_connector_attach_tv_margin_properties); * Called by a driver's HDMI connector initialization routine, this function * creates the TV margin properties for a given device. No need to call this * function for an SDTV connector, it's already called from - * drm_mode_create_tv_properties(). + * drm_mode_create_tv_properties_legacy(). * * Returns: * 0 on success or a negative error code on failure. @@ -1635,7 +1635,7 @@ int drm_mode_create_tv_margin_properties(struct drm_device *dev) EXPORT_SYMBOL(drm_mode_create_tv_margin_properties); /** - * drm_mode_create_tv_properties - create TV specific connector properties + * drm_mode_create_tv_properties_legacy - create TV specific connector properties * @dev: DRM device * @num_modes: number of different TV formats (modes) supported * @modes: array of pointers to strings containing name of each format @@ -1648,9 +1648,9 @@ EXPORT_SYMBOL(drm_mode_create_tv_margin_properties); * Returns: * 0 on success or a negative error code on failure. */ -int drm_mode_create_tv_properties(struct drm_device *dev, - unsigned int num_modes, - const char * const modes[]) +int drm_mode_create_tv_properties_legacy(struct drm_device *dev, + unsigned int num_modes, + const char * const modes[]) { struct drm_property *tv_selector; struct drm_property *tv_subconnector; @@ -1733,7 +1733,7 @@ int drm_mode_create_tv_properties(struct drm_device *dev, nomem: return -ENOMEM; } -EXPORT_SYMBOL(drm_mode_create_tv_properties); +EXPORT_SYMBOL(drm_mode_create_tv_properties_legacy); /** * drm_mode_create_scaling_mode_property - create scaling mode property diff --git a/drivers/gpu/drm/gud/gud_connector.c b/drivers/gpu/drm/gud/gud_connector.c index 86e992b2108b..034e78360d4f 100644 --- a/drivers/gpu/drm/gud/gud_connector.c +++ b/drivers/gpu/drm/gud/gud_connector.c @@ -400,7 +400,7 @@ static int gud_connector_add_tv_mode(struct gud_device *gdrm, struct drm_connect for (i = 0; i < num_modes; i++) modes[i] = &buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN]; - ret = drm_mode_create_tv_properties(connector->dev, num_modes, modes); + ret = drm_mode_create_tv_properties_legacy(connector->dev, num_modes, modes); free: kfree(buf); if (ret < 0) @@ -539,7 +539,7 @@ static int gud_connector_add_properties(struct gud_device *gdrm, struct gud_conn fallthrough; case GUD_PROPERTY_TV_HUE: /* This is a no-op if already added. */ - ret = drm_mode_create_tv_properties(drm, 0, NULL); + ret = drm_mode_create_tv_properties_legacy(drm, 0, NULL); if (ret) goto out; break; diff --git a/drivers/gpu/drm/i2c/ch7006_drv.c b/drivers/gpu/drm/i2c/ch7006_drv.c index d29b63fd6178..506f6f932518 100644 --- a/drivers/gpu/drm/i2c/ch7006_drv.c +++ b/drivers/gpu/drm/i2c/ch7006_drv.c @@ -250,7 +250,7 @@ static int ch7006_encoder_create_resources(struct drm_encoder *encoder, struct drm_device *dev = encoder->dev; struct drm_mode_config *conf = &dev->mode_config; - drm_mode_create_tv_properties(dev, NUM_TV_NORMS, ch7006_tv_norm_names); + drm_mode_create_tv_properties_legacy(dev, NUM_TV_NORMS, ch7006_tv_norm_names); priv->scale_property = drm_property_create_range(dev, 0, "scale", 0, 2); if (!priv->scale_property) diff --git a/drivers/gpu/drm/i915/display/intel_tv.c b/drivers/gpu/drm/i915/display/intel_tv.c index abaf9ded942d..5e88da8185ee 100644 --- a/drivers/gpu/drm/i915/display/intel_tv.c +++ b/drivers/gpu/drm/i915/display/intel_tv.c @@ -1984,7 +1984,7 @@ intel_tv_init(struct drm_i915_private *dev_priv) tv_format_names[i] = tv_modes[i].name; } - drm_mode_create_tv_properties(dev, i, tv_format_names); + drm_mode_create_tv_properties_legacy(dev, i, tv_format_names); drm_object_attach_property(&connector->base, dev->mode_config.legacy_tv_mode_property, diff --git a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c index 1a15534adc60..e5480dab55e3 100644 --- a/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c +++ b/drivers/gpu/drm/nouveau/dispnv04/tvnv17.c @@ -653,7 +653,7 @@ static int nv17_tv_create_resources(struct drm_encoder *encoder, tv_enc->tv_norm = i; } - drm_mode_create_tv_properties(dev, num_tv_norms, nv17_tv_norm_names); + drm_mode_create_tv_properties_legacy(dev, num_tv_norms, nv17_tv_norm_names); drm_object_attach_property(&connector->base, conf->tv_select_subconnector_property, diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index 77c50ecb0309..f31fef938f11 100644 --- a/drivers/gpu/drm/vc4/vc4_vec.c +++ b/drivers/gpu/drm/vc4/vc4_vec.c @@ -514,8 +514,9 @@ static int vc4_vec_bind(struct device *dev, struct device *master, void *data) struct vc4_vec *vec; int ret; - ret = drm_mode_create_tv_properties(drm, ARRAY_SIZE(tv_mode_names), - tv_mode_names); + ret = drm_mode_create_tv_properties_legacy(drm, + ARRAY_SIZE(tv_mode_names), + tv_mode_names); if (ret) return ret; diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 5cfad8b6ad83..d566b4a4709c 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1799,9 +1799,9 @@ int drm_mode_create_dvi_i_properties(struct drm_device *dev); void drm_connector_attach_dp_subconnector_property(struct drm_connector *connector); int drm_mode_create_tv_margin_properties(struct drm_device *dev); -int drm_mode_create_tv_properties(struct drm_device *dev, - unsigned int num_modes, - const char * const modes[]); +int drm_mode_create_tv_properties_legacy(struct drm_device *dev, + unsigned int num_modes, + const char * const modes[]); void drm_connector_attach_tv_margin_properties(struct drm_connector *conn); int drm_mode_create_scaling_mode_property(struct drm_device *dev); int drm_connector_attach_content_type_property(struct drm_connector *dev); From patchwork Thu Sep 22 14:25:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985244 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 1E6AFC6FA86 for ; Thu, 22 Sep 2022 14:26:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 10A7710EB72; Thu, 22 Sep 2022 14:26:52 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 58F6010EB67; Thu, 22 Sep 2022 14:26:39 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 17D1D2B05B1D; Thu, 22 Sep 2022 10:26:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 22 Sep 2022 10:26:38 -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=1663856795; x= 1663863995; bh=tV2yc3EZpFToTHAc3rLpWp8kLQb5xK+ucBkyIPLx9qA=; b=D TiuzyJvvDv8dQcJ9DKgArXAvkmuwTzY6AcqIeX1uYacTThNB9Yp5pBk1vB1AyMy+ GDaDiXXZfpQA8+Mqfo+eEVb3L89HZHZmAQKbbcO47hbEsxzs5ui35FwDcpxCMCWJ vRJE3QkGBVA0Y0JYcfC9dL5FiXcpdXwm1eH8VVeQXWoG3Nz1J+xsyWtD5B/ymJEm F80zRj57/PrWPBVEbXo6U8qKlvmFOkKxPlmOfMRDLWMpqqND5QetqlW9GaUmH2hX XGlmOevb8Ionm6msYO0kk3Ob+R3S5wme4av4LKKsP8AfcP1EI3h1mKROyfeTrCHH 5tSCH0nA1N5ocYUFo86UA== 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=fm2; t=1663856795; x= 1663863995; bh=tV2yc3EZpFToTHAc3rLpWp8kLQb5xK+ucBkyIPLx9qA=; b=O hqgutTZKYjnyllquwVmGFBlAmgE1PYmgdmo6tYp8b/UeHgcqX3eZYiJ9assYCX92 PMdR0OdHOMqPNci3JUQ+6TaY5IfEgcEXVYLNkc0CcaYGVxX1ERo22x1tCDljHeYD pHKYR4nsiFLIKl9ZMKCZrCGJqPu0ZbidP8UwWZrMHhJ0w7fKB1xbGWtwJAkX2myq jmcshg8zwgBQN10XlmGwcMMHV6V0gbQnI6pHDEFcDUn367KUBRDEYzGHW2e7QVk1 LRMCPYJzUnXwtKUaxhk8o8flioi6jHGirEY3OBwwF5UgX8JIKT9iqC99/Fw6l0zJ ffpyOrEowYWk8pSAnaIHQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:26:34 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:26 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-9-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9548; i=maxime@cerno.tech; h=from:subject:message-id; bh=BIsPokfQPt+am42KHiiQMKtBHhDUgZqrU7zUZAs1ZU0=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQFyB9vyIySTP5+4E3x2buRvf7FXv263+xl7PU54fXKW 9NE3HaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZiI7UFGhs5DTNaXZ6ruL3ubG6HdFh n8bp62tnanlbxtyC7dZ1fvTGJkmNXZe8Rg3YrmGNcfLx0bNZhfOq+YvnD5lBkWDmff71bsZgUA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 09/33] drm/connector: Add TV standard property X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The TV mode property has been around for a while now to select and get the current TV mode output on an analog TV connector. Despite that property name being generic, its content isn't and has been driver-specific which makes it hard to build any generic behaviour on top of it, both in kernel and user-space. Let's create a new enum tv norm property, that can contain any of the analog TV standards currently supported by kernel drivers. Each driver can then pass in a bitmask of the modes it supports, and the property creation function will filter out the modes not supported. We'll then be able to phase out the older tv mode property. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_atomic_uapi.c b/drivers/gpu/drm/drm_atomic_uapi.c index 7f2b9a07fbdf..d867e7f9f2cd 100644 --- a/drivers/gpu/drm/drm_atomic_uapi.c +++ b/drivers/gpu/drm/drm_atomic_uapi.c @@ -700,6 +700,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, state->tv.margins.bottom = val; } else if (property == config->legacy_tv_mode_property) { state->tv.legacy_mode = val; + } else if (property == config->tv_mode_property) { + state->tv.mode = val; } else if (property == config->tv_brightness_property) { state->tv.brightness = val; } else if (property == config->tv_contrast_property) { @@ -810,6 +812,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = state->tv.margins.bottom; } else if (property == config->legacy_tv_mode_property) { *val = state->tv.legacy_mode; + } else if (property == config->tv_mode_property) { + *val = state->tv.mode; } else if (property == config->tv_brightness_property) { *val = state->tv.brightness; } else if (property == config->tv_contrast_property) { diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 4e4fbc9e0049..e7aa8de08f5b 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -980,6 +980,18 @@ static const struct drm_prop_enum_list drm_dvi_i_subconnector_enum_list[] = { DRM_ENUM_NAME_FN(drm_get_dvi_i_subconnector_name, drm_dvi_i_subconnector_enum_list) +static const struct drm_prop_enum_list drm_tv_mode_enum_list[] = { + { DRM_MODE_TV_MODE_NONE, "None" }, + { DRM_MODE_TV_MODE_NTSC, "NTSC" }, + { DRM_MODE_TV_MODE_NTSC_443, "NTSC-443" }, + { DRM_MODE_TV_MODE_NTSC_J, "NTSC-J" }, + { DRM_MODE_TV_MODE_PAL, "PAL" }, + { DRM_MODE_TV_MODE_PAL_M, "PAL-M" }, + { DRM_MODE_TV_MODE_PAL_N, "PAL-N" }, + { DRM_MODE_TV_MODE_SECAM, "SECAM" }, +}; +DRM_ENUM_NAME_FN(drm_get_tv_mode_name, drm_tv_mode_enum_list) + static const struct drm_prop_enum_list drm_tv_select_enum_list[] = { { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */ { DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */ @@ -1645,6 +1657,10 @@ EXPORT_SYMBOL(drm_mode_create_tv_margin_properties); * responsible for allocating a list of format names and passing them to * this routine. * + * NOTE: This functions registers the deprecated "mode" connector + * property to select the analog TV mode (ie, NTSC, PAL, etc.). New + * drivers must use drm_mode_create_tv_properties() instead. + * * Returns: * 0 on success or a negative error code on failure. */ @@ -1686,7 +1702,6 @@ int drm_mode_create_tv_properties_legacy(struct drm_device *dev, if (drm_mode_create_tv_margin_properties(dev)) goto nomem; - if (num_modes) { dev->mode_config.legacy_tv_mode_property = drm_property_create(dev, DRM_MODE_PROP_ENUM, @@ -1735,6 +1750,49 @@ int drm_mode_create_tv_properties_legacy(struct drm_device *dev, } EXPORT_SYMBOL(drm_mode_create_tv_properties_legacy); +/** + * drm_mode_create_tv_properties - create TV specific connector properties + * @dev: DRM device + * @supported_tv_modes: Bitmask of TV modes supported (See DRM_MODE_TV_MODE_*) + + * Called by a driver's TV initialization routine, this function creates + * the TV specific connector properties for a given device. Caller is + * responsible for allocating a list of format names and passing them to + * this routine. + * + * Returns: + * 0 on success or a negative error code on failure. + */ +int drm_mode_create_tv_properties(struct drm_device *dev, + unsigned int supported_tv_modes) +{ + struct drm_prop_enum_list tv_mode_list[DRM_MODE_TV_MODE_MAX]; + struct drm_property *tv_mode; + unsigned int i, len = 0; + + if (dev->mode_config.tv_mode_property) + return 0; + + for (i = 0; i < DRM_MODE_TV_MODE_MAX; i++) { + if (!(supported_tv_modes & BIT(i))) + continue; + + tv_mode_list[len].type = i; + tv_mode_list[len].name = drm_get_tv_mode_name(i); + len++; + } + + tv_mode = drm_property_create_enum(dev, 0, "TV mode", + tv_mode_list, len); + if (!tv_mode) + return -ENOMEM; + + dev->mode_config.tv_mode_property = tv_mode; + + return drm_mode_create_tv_properties_legacy(dev, 0, NULL); +} +EXPORT_SYMBOL(drm_mode_create_tv_properties); + /** * drm_mode_create_scaling_mode_property - create scaling mode property * @dev: DRM device diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index d566b4a4709c..fffacbfd0a45 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -143,6 +143,71 @@ enum subpixel_order { }; +/** + * enum drm_connector_tv_mode - Analog TV output mode + * + * This enum is used to indicate the TV output mode used on an analog TV + * connector. + * + * WARNING: The values of this enum is uABI since they're exposed in the + * "TV mode" connector property. + */ +enum drm_connector_tv_mode { + /** + * @DRM_MODE_TV_MODE_NONE: Placeholder to not default on one + * variant or the other when nothing is set. + */ + DRM_MODE_TV_MODE_NONE = 0, + + /** + * @DRM_MODE_TV_MODE_NTSC: CCIR System M (aka 525-lines) + * together with the NTSC Color Encoding. + */ + DRM_MODE_TV_MODE_NTSC, + + /** + * @DRM_MODE_TV_MODE_NTSC_443: Variant of + * @DRM_MODE_TV_MODE_NTSC. Uses a color subcarrier frequency + * of 4.43 MHz. + */ + DRM_MODE_TV_MODE_NTSC_443, + + /** + * @DRM_MODE_TV_MODE_NTSC_J: Variant of @DRM_MODE_TV_MODE_NTSC + * used in Japan. Uses a black level equals to the blanking + * level. + */ + DRM_MODE_TV_MODE_NTSC_J, + + /** + * @DRM_MODE_TV_MODE_PAL: CCIR System B together with the PAL + * color system. + */ + DRM_MODE_TV_MODE_PAL, + + /** + * @DRM_MODE_TV_MODE_PAL_M: CCIR System M (aka 525-lines) + * together with the PAL color encoding + */ + DRM_MODE_TV_MODE_PAL_M, + + /** + * @DRM_MODE_TV_MODE_PAL_N: CCIR System N together with the PAL + * color encoding. It uses 625 lines, but has a color subcarrier + * frequency of 3.58MHz, the SECAM color space, and narrower + * channels compared to most of the other PAL variants. + */ + DRM_MODE_TV_MODE_PAL_N, + + /** + * @DRM_MODE_TV_MODE_SECAM: CCIR System B together with the + * SECAM color system. + */ + DRM_MODE_TV_MODE_SECAM, + + DRM_MODE_TV_MODE_MAX, +}; + /** * struct drm_scrambling: sink's scrambling support. */ @@ -696,6 +761,7 @@ struct drm_connector_tv_margins { * @subconnector: detected subconnector * @margins: TV margins * @legacy_mode: Legacy TV mode, driver specific value + * @mode: TV mode * @brightness: brightness in percent * @contrast: contrast in percent * @flicker_reduction: flicker reduction in percent @@ -708,6 +774,7 @@ struct drm_tv_connector_state { enum drm_mode_subconnector subconnector; struct drm_connector_tv_margins margins; unsigned int legacy_mode; + unsigned int mode; unsigned int brightness; unsigned int contrast; unsigned int flicker_reduction; @@ -1789,6 +1856,7 @@ const char *drm_get_subpixel_order_name(enum subpixel_order order); const char *drm_get_dpms_name(int val); const char *drm_get_dvi_i_subconnector_name(int val); const char *drm_get_dvi_i_select_name(int val); +const char *drm_get_tv_mode_name(int val); const char *drm_get_tv_subconnector_name(int val); const char *drm_get_tv_select_name(int val); const char *drm_get_dp_subconnector_name(int val); @@ -1802,6 +1870,8 @@ int drm_mode_create_tv_margin_properties(struct drm_device *dev); int drm_mode_create_tv_properties_legacy(struct drm_device *dev, unsigned int num_modes, const char * const modes[]); +int drm_mode_create_tv_properties(struct drm_device *dev, + unsigned int supported_tv_modes); void drm_connector_attach_tv_margin_properties(struct drm_connector *conn); int drm_mode_create_scaling_mode_property(struct drm_device *dev); int drm_connector_attach_content_type_property(struct drm_connector *dev); diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 35a827175c24..10a6f7d1df0d 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -718,9 +718,17 @@ struct drm_mode_config { /** * @legacy_tv_mode_property: Optional TV property to select * the output TV mode. + * + * Superseeded by @tv_mode_property */ struct drm_property *legacy_tv_mode_property; + /** + * @tv_mode_property: Optional TV property to select the TV + * standard output on the connector. + */ + struct drm_property *tv_mode_property; + /** * @tv_left_margin_property: Optional TV property to set the left * margin (expressed in pixels). From patchwork Thu Sep 22 14:25:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985266 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 7E070C6FA86 for ; Thu, 22 Sep 2022 14:27:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F14E10EB71; Thu, 22 Sep 2022 14:27:03 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B26E10EB68; Thu, 22 Sep 2022 14:26:46 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id 3B3042B05B1B; Thu, 22 Sep 2022 10:26:43 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 22 Sep 2022 10:26:45 -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=1663856802; x= 1663864002; bh=A/3zngWu6cCkoVlG+ecaDdhnQDgJ09cIUraKQUgT8/M=; b=b zi8teDFGu2+OauM6LRAQHO8jzygx9xk7k2vzAWDYOTnqU+J74LQ+WS8uFz+m1IF4 a4AN9fKk/spe0ZXo7z7WBHk07OTjFftDzs36cBbaHT4bwZ2cicaHxlNEyJ/Nrwtu 2giEctM1TPtMoIcNpgQ278J3IVEHI+J/DnHuPDtYutR93m9MO4SuOI2tt08Cxm3C xilfogjnk8qOpEaORYY/H/G7gW3mUIsASd/69rXBRnehn3QfrpDe2cmuvpD63Odv W9OkVyaz+d4bW7NJw1KPIof39DJfbi697c33tYFOta28MUNRObvPyvb7L1nUZoeg MTZ5qj+6VDQpiwsbP3s2g== 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=fm2; t=1663856802; x= 1663864002; bh=A/3zngWu6cCkoVlG+ecaDdhnQDgJ09cIUraKQUgT8/M=; b=x JLynd4L4Qs7dCVTqflPyMliObQhMv5fUL9FLpVSJIcdGnDAKYIMVcqEh7sUt/GKM c9t3AVg8XoFw7O7W3PmoQnEPxTKaR3qA+LorH9zGxsZKoiSLekdp/29tE/RLXEYX 1LhwQ8Z1k9HgagVJJKj4k1I/tw00dFSvbpEv/E/TUXQ54x6Y0wJLNSv+VplioWky OHkVZYbZeBnLhKfFgqUEkKRKMHAVlNhHrPVdByPNyzrjW5W6iXn9ANceH84Akmj2 ZljNSixONbJgPiPUoY+BlFMhRerV2k7YBHcvHzAR/uh7XOArhhsLBCVJJFm03hhn GY3uVVWLJr6IAD/+qp/2g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepheetheetueevueejfeekjeejkeeffeekvdfgudelffduheffvefggeek feduledunecuffhomhgrihhnpegrrhgthhhivhgvrdhorhhgpdhkohhluhhmsghushdrfh hipdhhihhnnhgvrhdrihhnfhhopdgsrghtshhotghkshdrtghordhukhenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvgestggvrh hnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:26:41 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:27 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-10-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=22437; i=maxime@cerno.tech; h=from:subject:message-id; bh=WSuRUEf18VvfvkNYlxjlTqECotKyharw0PcclOtFgtk=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQEZDWtKfrbMPONmPvtt7OwXyZVvv/5W6J1zn8mH5wH3 1/OZHaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZhIei0jw0O1fq0rsSF/0xvadWJYDT mtDZ7vfxo1+dZOhtehvfw2kxn+KW1V/dH2QyRBL2/Ok9KuKX8C75jk9y6t2Hz6me7jEvN9HAA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 10/33] drm/modes: Add a function to generate analog display modes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Multiple drivers (meson, vc4, sun4i) define analog TV 525-lines and 625-lines modes in their drivers. Since those modes are fairly standard, and that we'll need to use them in more places in the future, it makes sense to move their definition into the core framework. However, analog display usually have fairly loose timings requirements, the only discrete parameters being the total number of lines and pixel clock frequency. Thus, we created a function that will create a display mode from the standard, the pixel frequency and the active area. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 304004fb80aa..76ab700f56ff 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -116,6 +116,480 @@ void drm_mode_probed_add(struct drm_connector *connector, } EXPORT_SYMBOL(drm_mode_probed_add); +enum drm_mode_analog { + DRM_MODE_ANALOG_NTSC, /* 525 lines, 60Hz */ + DRM_MODE_ANALOG_PAL, /* 625 lines, 50Hz */ +}; + +/* + * The timings come from: + * - https://web.archive.org/web/20220406232708/http://www.kolumbus.fi/pami1/video/pal_ntsc.html + * - https://web.archive.org/web/20220406124914/http://martin.hinner.info/vga/pal.html + * - https://web.archive.org/web/20220609202433/http://www.batsocks.co.uk/readme/video_timing.htm + */ +#define NTSC_LINE_DURATION_NS 63556U +#define NTSC_LINES_NUMBER 525 + +#define NTSC_HBLK_DURATION_TYP_NS 10900U +#define NTSC_HBLK_DURATION_MIN_NS (NTSC_HBLK_DURATION_TYP_NS - 200) +#define NTSC_HBLK_DURATION_MAX_NS (NTSC_HBLK_DURATION_TYP_NS + 200) + +#define NTSC_HACT_DURATION_TYP_NS (NTSC_LINE_DURATION_NS - NTSC_HBLK_DURATION_TYP_NS) +#define NTSC_HACT_DURATION_MIN_NS (NTSC_LINE_DURATION_NS - NTSC_HBLK_DURATION_MAX_NS) +#define NTSC_HACT_DURATION_MAX_NS (NTSC_LINE_DURATION_NS - NTSC_HBLK_DURATION_MIN_NS) + +#define NTSC_HFP_DURATION_TYP_NS 1500 +#define NTSC_HFP_DURATION_MIN_NS 1270 +#define NTSC_HFP_DURATION_MAX_NS 2220 + +#define NTSC_HSLEN_DURATION_TYP_NS 4700 +#define NTSC_HSLEN_DURATION_MIN_NS (NTSC_HSLEN_DURATION_TYP_NS - 100) +#define NTSC_HSLEN_DURATION_MAX_NS (NTSC_HSLEN_DURATION_TYP_NS + 100) + +#define NTSC_HBP_DURATION_TYP_NS 4700 + +/* + * I couldn't find the actual tolerance for the back porch, so let's + * just reuse the sync length ones. + */ +#define NTSC_HBP_DURATION_MIN_NS (NTSC_HBP_DURATION_TYP_NS - 100) +#define NTSC_HBP_DURATION_MAX_NS (NTSC_HBP_DURATION_TYP_NS + 100) + +#define PAL_LINE_DURATION_NS 64000U +#define PAL_LINES_NUMBER 625 + +#define PAL_HACT_DURATION_TYP_NS 51950U +#define PAL_HACT_DURATION_MIN_NS (PAL_HACT_DURATION_TYP_NS - 100) +#define PAL_HACT_DURATION_MAX_NS (PAL_HACT_DURATION_TYP_NS + 400) + +#define PAL_HBLK_DURATION_TYP_NS (PAL_LINE_DURATION_NS - PAL_HACT_DURATION_TYP_NS) +#define PAL_HBLK_DURATION_MIN_NS (PAL_LINE_DURATION_NS - PAL_HACT_DURATION_MAX_NS) +#define PAL_HBLK_DURATION_MAX_NS (PAL_LINE_DURATION_NS - PAL_HACT_DURATION_MIN_NS) + +#define PAL_HFP_DURATION_TYP_NS 1650 +#define PAL_HFP_DURATION_MIN_NS (PAL_HFP_DURATION_TYP_NS - 100) +#define PAL_HFP_DURATION_MAX_NS (PAL_HFP_DURATION_TYP_NS + 400) + +#define PAL_HSLEN_DURATION_TYP_NS 4700 +#define PAL_HSLEN_DURATION_MIN_NS (PAL_HSLEN_DURATION_TYP_NS - 200) +#define PAL_HSLEN_DURATION_MAX_NS (PAL_HSLEN_DURATION_TYP_NS + 200) + +#define PAL_HBP_DURATION_TYP_NS 5700 +#define PAL_HBP_DURATION_MIN_NS (PAL_HBP_DURATION_TYP_NS - 200) +#define PAL_HBP_DURATION_MAX_NS (PAL_HBP_DURATION_TYP_NS + 200) + +struct analog_param_field { + unsigned int even, odd; +}; + +#define PARAM_FIELD(_odd, _even) \ + { .even = _even, .odd = _odd } + +struct analog_param_range { + unsigned int min, typ, max; +}; + +#define PARAM_RANGE(_min, _typ, _max) \ + { .min = _min, .typ = _typ, .max = _max } + +struct analog_parameters { + unsigned int num_lines; + unsigned int line_duration_ns; + + struct analog_param_range hact_ns; + struct analog_param_range hfp_ns; + struct analog_param_range hslen_ns; + struct analog_param_range hbp_ns; + struct analog_param_range hblk_ns; + + unsigned int bt601_hfp; + + struct analog_param_field vfp_lines; + struct analog_param_field vslen_lines; + struct analog_param_field vbp_lines; +}; + +#define TV_MODE_PARAMETER(_mode, _lines, _line_dur, _hact, _hfp, _hslen, _hbp, _hblk, _bt601_hfp, _vfp, _vslen, _vbp) \ + [_mode] = { \ + .num_lines = _lines, \ + .line_duration_ns = _line_dur, \ + .hact_ns = _hact, \ + .hfp_ns = _hfp, \ + .hslen_ns = _hslen, \ + .hbp_ns = _hbp, \ + .hblk_ns = _hblk, \ + .bt601_hfp = _bt601_hfp, \ + .vfp_lines = _vfp, \ + .vslen_lines = _vslen, \ + .vbp_lines = _vbp, \ + } + +const static struct analog_parameters tv_modes_parameters[] = { + TV_MODE_PARAMETER(DRM_MODE_ANALOG_NTSC, + NTSC_LINES_NUMBER, + NTSC_LINE_DURATION_NS, + PARAM_RANGE(NTSC_HACT_DURATION_MIN_NS, + NTSC_HACT_DURATION_TYP_NS, + NTSC_HACT_DURATION_MAX_NS), + PARAM_RANGE(NTSC_HFP_DURATION_MIN_NS, + NTSC_HFP_DURATION_TYP_NS, + NTSC_HFP_DURATION_MAX_NS), + PARAM_RANGE(NTSC_HSLEN_DURATION_MIN_NS, + NTSC_HSLEN_DURATION_TYP_NS, + NTSC_HSLEN_DURATION_MAX_NS), + PARAM_RANGE(NTSC_HBP_DURATION_MIN_NS, + NTSC_HBP_DURATION_TYP_NS, + NTSC_HBP_DURATION_MAX_NS), + PARAM_RANGE(NTSC_HBLK_DURATION_MIN_NS, + NTSC_HBLK_DURATION_TYP_NS, + NTSC_HBLK_DURATION_MAX_NS), + 16, + PARAM_FIELD(3, 3), + PARAM_FIELD(3, 3), + PARAM_FIELD(16, 17)), + TV_MODE_PARAMETER(DRM_MODE_ANALOG_PAL, + PAL_LINES_NUMBER, + PAL_LINE_DURATION_NS, + PARAM_RANGE(PAL_HACT_DURATION_MIN_NS, + PAL_HACT_DURATION_TYP_NS, + PAL_HACT_DURATION_MAX_NS), + PARAM_RANGE(PAL_HFP_DURATION_MIN_NS, + PAL_HFP_DURATION_TYP_NS, + PAL_HFP_DURATION_MAX_NS), + PARAM_RANGE(PAL_HSLEN_DURATION_MIN_NS, + PAL_HSLEN_DURATION_TYP_NS, + PAL_HSLEN_DURATION_MAX_NS), + PARAM_RANGE(PAL_HBP_DURATION_MIN_NS, + PAL_HBP_DURATION_TYP_NS, + PAL_HBP_DURATION_MAX_NS), + PARAM_RANGE(PAL_HBLK_DURATION_MIN_NS, + PAL_HBLK_DURATION_TYP_NS, + PAL_HBLK_DURATION_MAX_NS), + 12, + + /* + * The front porch is actually 6 short sync + * pulses for the even field, and 5 for the + * odd field. Each sync takes half a life so + * the odd field front porch is shorter by + * half a line. + * + * In progressive, we're supposed to use 6 + * pulses, so we're fine there + */ + PARAM_FIELD(3, 2), + + /* + * The vsync length is 5 long sync pulses, + * each field taking half a line. We're + * shorter for both fields by half a line. + * + * In progressive, we're supposed to use 5 + * pulses, so we're off by half + * a line. + * + * In interlace, we're now off by half a line + * for the even field and one line for the odd + * field. + */ + PARAM_FIELD(3, 3), + + /* + * The back porch starts with post-equalizing + * pulses, consisting in 5 short sync pulses + * for the even field, 4 for the odd field. In + * progressive, it's 5 short syncs. + * + * In progressive, we thus have 2.5 lines, + * plus the 0.5 line we were missing + * previously, so we should use 3 lines. + * + * In interlace, the even field is in the + * exact same case than progressive. For the + * odd field, we should be using 2 lines but + * we're one line short, so we'll make up for + * it here by using 3. + * + * The entire blanking area is supposed to + * take 25 lines, so we also need to account + * for the rest of the blanking area that + * can't be in either the front porch or sync + * period. + */ + PARAM_FIELD(19, 20)), +}; + +static int fill_analog_mode(struct drm_device *dev, + struct drm_display_mode *mode, + const struct analog_parameters *params, + unsigned long pixel_clock_hz, + unsigned int hactive, + unsigned int vactive, + bool interlace) +{ + unsigned long pixel_duration_ns = NSEC_PER_SEC / pixel_clock_hz; + unsigned int htotal, vtotal; + unsigned int max_hact, hact_duration_ns; + unsigned int hblk, hblk_duration_ns; + unsigned int hfp, hfp_duration_ns; + unsigned int hslen, hslen_duration_ns; + unsigned int hbp, hbp_duration_ns; + unsigned int porches, porches_duration_ns; + unsigned int vfp, vfp_min; + unsigned int vbp, vbp_min; + unsigned int vslen; + bool bt601 = false; + int porches_rem; + u64 result; + + drm_dbg_kms(dev, + "Generating a %ux%u%c, %u-line mode with a %lu kHz clock\n", + hactive, vactive, + interlace ? 'i' : 'p', + params->num_lines, + pixel_clock_hz / 1000); + + max_hact = params->hact_ns.max / pixel_duration_ns; + if (pixel_clock_hz == 13500000 && hactive > max_hact && hactive <= 720) { + drm_dbg_kms(dev, "Trying to generate a BT.601 mode. Disabling checks.\n"); + bt601 = true; + } + + /* + * Our pixel duration is going to be round down by the division, + * so rounding up is probably going to introduce even more + * deviation. + */ + result = (u64)params->line_duration_ns * pixel_clock_hz; + do_div(result, NSEC_PER_SEC); + htotal = result; + + drm_dbg_kms(dev, "Total Horizontal Number of Pixels: %u\n", htotal); + + hact_duration_ns = hactive * pixel_duration_ns; + if (!bt601 && + (hact_duration_ns < params->hact_ns.min || + hact_duration_ns > params->hact_ns.max)) { + DRM_ERROR("Invalid horizontal active area duration: %uns (min: %u, max %u)\n", + hact_duration_ns, params->hact_ns.min, params->hact_ns.max); + return -EINVAL; + } + + hblk = htotal - hactive; + drm_dbg_kms(dev, "Horizontal Blanking Period: %u\n", hblk); + + hblk_duration_ns = hblk * pixel_duration_ns; + if (!bt601 && + (hblk_duration_ns < params->hblk_ns.min || + hblk_duration_ns > params->hblk_ns.max)) { + DRM_ERROR("Invalid horizontal blanking duration: %uns (min: %u, max %u)\n", + hblk_duration_ns, params->hblk_ns.min, params->hblk_ns.max); + return -EINVAL; + } + + hslen = DIV_ROUND_UP(params->hslen_ns.typ, pixel_duration_ns); + drm_dbg_kms(dev, "Horizontal Sync Period: %u\n", hslen); + + hslen_duration_ns = hslen * pixel_duration_ns; + if (!bt601 && + (hslen_duration_ns < params->hslen_ns.min || + hslen_duration_ns > params->hslen_ns.max)) { + DRM_ERROR("Invalid horizontal sync duration: %uns (min: %u, max %u)\n", + hslen_duration_ns, params->hslen_ns.min, params->hslen_ns.max); + return -EINVAL; + } + + porches = hblk - hslen; + drm_dbg_kms(dev, "Remaining horizontal pixels for both porches: %u\n", porches); + + porches_duration_ns = porches * pixel_duration_ns; + if (!bt601 && + (porches_duration_ns > (params->hfp_ns.max + params->hbp_ns.max) || + porches_duration_ns < (params->hfp_ns.min + params->hbp_ns.min))) { + DRM_ERROR("Invalid horizontal porches duration: %uns\n", porches_duration_ns); + return -EINVAL; + } + + if (bt601) { + hfp = params->bt601_hfp; + } else { + unsigned int hfp_min = DIV_ROUND_UP(params->hfp_ns.min, + pixel_duration_ns); + unsigned int hbp_min = DIV_ROUND_UP(params->hbp_ns.min, + pixel_duration_ns); + int porches_rem = porches - hfp_min - hbp_min; + + hfp = hfp_min + DIV_ROUND_UP(porches_rem, 2); + } + + drm_dbg_kms(dev, "Horizontal Front Porch: %u\n", hfp); + + hfp_duration_ns = hfp * pixel_duration_ns; + if (!bt601 && + (hfp_duration_ns < params->hfp_ns.min || + hfp_duration_ns > params->hfp_ns.max)) { + DRM_ERROR("Invalid horizontal front porch duration: %uns (min: %u, max %u)\n", + hfp_duration_ns, params->hfp_ns.min, params->hfp_ns.max); + return -EINVAL; + } + + hbp = porches - hfp; + drm_dbg_kms(dev, "Horizontal Back Porch: %u\n", hbp); + + hbp_duration_ns = hbp * pixel_duration_ns; + if (!bt601 && + (hbp_duration_ns < params->hbp_ns.min || + hbp_duration_ns > params->hbp_ns.max)) { + DRM_ERROR("Invalid horizontal back porch duration: %uns (min: %u, max %u)\n", + hbp_duration_ns, params->hbp_ns.min, params->hbp_ns.max); + return -EINVAL; + } + + if (htotal != (hactive + hfp + hslen + hbp)) + return -EINVAL; + + mode->clock = pixel_clock_hz / 1000; + mode->hdisplay = hactive; + mode->hsync_start = hactive + hfp; + mode->hsync_end = hactive + hfp + hslen; + mode->htotal = hactive + hfp + hslen + hbp; + + if (interlace) { + vfp_min = params->vfp_lines.even + params->vfp_lines.odd; + vbp_min = params->vbp_lines.even + params->vbp_lines.odd; + vslen = params->vslen_lines.even + params->vslen_lines.odd; + } else { + /* + * By convention, NSTC (aka 525/60) systems start with + * the even field, but PAL (aka 625/50) systems start + * with the odd one. + * + * PAL systems also have asymetric timings between the + * even and odd field, while NTSC is symetric. + * + * Moreover, if we want to create a progressive mode for + * PAL, we need to use the odd field timings. + * + * Since odd == even for NTSC, we can just use the odd + * one all the time to simplify the code a bit. + */ + vfp_min = params->vfp_lines.odd; + vbp_min = params->vbp_lines.odd; + vslen = params->vslen_lines.odd; + } + + drm_dbg_kms(dev, "Vertical Sync Period: %u\n", vslen); + + porches = params->num_lines - vactive - vslen; + drm_dbg_kms(dev, "Remaining vertical pixels for both porches: %u\n", porches); + + porches_rem = porches - vfp_min - vbp_min; + vfp = vfp_min + (porches_rem / 2); + drm_dbg_kms(dev, "Vertical Front Porch: %u\n", vfp); + + vbp = porches - vfp; + drm_dbg_kms(dev, "Vertical Back Porch: %u\n", vbp); + + vtotal = vactive + vfp + vslen + vbp; + if (params->num_lines != vtotal) { + DRM_ERROR("Invalid vertical total: %upx (expected %upx)\n", + vtotal, params->num_lines); + return -EINVAL; + } + + mode->vdisplay = vactive; + mode->vsync_start = vactive + vfp; + mode->vsync_end = vactive + vfp + vslen; + mode->vtotal = vactive + vfp + vslen + vbp; + + mode->type = DRM_MODE_TYPE_DRIVER; + mode->flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC; + if (interlace) + mode->flags |= DRM_MODE_FLAG_INTERLACE; + + drm_mode_set_name(mode); + + if (mode->vtotal != params->num_lines) + return -EINVAL; + + drm_dbg_kms(dev, "Generated mode " DRM_MODE_FMT "\n", DRM_MODE_ARG(mode)); + + return 0; +} + +/** + * drm_analog_tv_mode - create a display mode for an analog TV + * @dev: drm device + * @tv_mode: TV Mode standard to create a mode for. See DRM_MODE_TV_MODE_*. + * @pixel_clock_hz: Pixel Clock Frequency, in Hertz + * @hdisplay: hdisplay size + * @vdisplay: vdisplay size + * @interlace: whether to compute an interlaced mode + * + * This function creates a struct drm_display_mode instance suited for + * an analog TV output, for one of the usual analog TV mode. + * + * Note that @hdisplay is larger than the usual constraints for the PAL + * and NTSC timings, and we'll choose to ignore most timings constraints + * to reach those resolutions. + * + * Returns: + * + * A pointer to the mode, allocated with drm_mode_create(). Returns NULL + * on error. + */ +struct drm_display_mode *drm_analog_tv_mode(struct drm_device *dev, + enum drm_connector_tv_mode tv_mode, + unsigned long pixel_clock_hz, + unsigned int hdisplay, + unsigned int vdisplay, + bool interlace) +{ + struct drm_display_mode *mode; + enum drm_mode_analog analog; + int ret; + + switch (tv_mode) { + case DRM_MODE_TV_MODE_NTSC: + fallthrough; + case DRM_MODE_TV_MODE_NTSC_443: + fallthrough; + case DRM_MODE_TV_MODE_NTSC_J: + fallthrough; + case DRM_MODE_TV_MODE_PAL_M: + analog = DRM_MODE_ANALOG_NTSC; + break; + + case DRM_MODE_TV_MODE_PAL: + fallthrough; + case DRM_MODE_TV_MODE_PAL_N: + fallthrough; + case DRM_MODE_TV_MODE_SECAM: + analog = DRM_MODE_ANALOG_PAL; + break; + + default: + return NULL; + } + + mode = drm_mode_create(dev); + if (!mode) + return NULL; + + ret = fill_analog_mode(dev, mode, + &tv_modes_parameters[analog], + pixel_clock_hz, hdisplay, vdisplay, interlace); + if (ret) + goto err_free_mode; + + return mode; + +err_free_mode: + drm_mode_destroy(dev, mode); + return NULL; +} +EXPORT_SYMBOL(drm_analog_tv_mode); + /** * drm_cvt_mode -create a modeline based on the CVT algorithm * @dev: drm device diff --git a/drivers/gpu/drm/tests/Makefile b/drivers/gpu/drm/tests/Makefile index b29ef1085cad..b22ac96fdd65 100644 --- a/drivers/gpu/drm/tests/Makefile +++ b/drivers/gpu/drm/tests/Makefile @@ -10,5 +10,6 @@ obj-$(CONFIG_DRM_KUNIT_TEST) += \ drm_framebuffer_test.o \ drm_kunit_helpers.o \ drm_mm_test.o \ + drm_modes_test.o \ drm_plane_helper_test.o \ drm_rect_test.o diff --git a/drivers/gpu/drm/tests/drm_modes_test.c b/drivers/gpu/drm/tests/drm_modes_test.c new file mode 100644 index 000000000000..be1ff0e21022 --- /dev/null +++ b/drivers/gpu/drm/tests/drm_modes_test.c @@ -0,0 +1,136 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Kunit test for drm_modes functions + */ + +#include + +#include + +#include "drm_kunit_helpers.h" + +struct drm_modes_test_priv { + struct drm_device *drm; +}; + +static int drm_modes_test_init(struct kunit *test) +{ + struct drm_modes_test_priv *priv; + + priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, priv); + + priv->drm = drm_kunit_device_init("drm-modes-test"); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, priv->drm); + + test->priv = priv; + + return 0; +} + +static void drm_modes_test_exit(struct kunit *test) +{ + struct drm_modes_test_priv *priv = test->priv; + + drm_kunit_device_exit(priv->drm); +} + +static void drm_modes_analog_tv_ntsc_480i(struct kunit *test) +{ + struct drm_modes_test_priv *priv = test->priv; + struct drm_display_mode *mode; + + mode = drm_analog_tv_mode(priv->drm, + DRM_MODE_TV_MODE_NTSC, + 13500 * 1000, 720, 480, + true); + KUNIT_ASSERT_NOT_NULL(test, mode); + + KUNIT_EXPECT_EQ(test, drm_mode_vrefresh(mode), 60); + KUNIT_EXPECT_EQ(test, mode->hdisplay, 720); + + /* BT.601 defines hsync_start at 736 for 480i */ + KUNIT_EXPECT_EQ(test, mode->hsync_start, 736); + + /* 63.556us * 13.5MHz = 858 pixels */ + KUNIT_EXPECT_EQ(test, mode->htotal, 858); + KUNIT_EXPECT_EQ(test, mode->vdisplay, 480); + KUNIT_EXPECT_EQ(test, mode->vtotal, 525); +} + +static void drm_modes_analog_tv_ntsc_480i_inlined(struct kunit *test) +{ + struct drm_modes_test_priv *priv = test->priv; + struct drm_display_mode *expected, *mode; + + expected = drm_analog_tv_mode(priv->drm, + DRM_MODE_TV_MODE_NTSC, + 13500 * 1000, 720, 480, + true); + KUNIT_ASSERT_NOT_NULL(test, expected); + + mode = drm_mode_analog_ntsc_480i(priv->drm); + KUNIT_ASSERT_NOT_NULL(test, mode); + + KUNIT_EXPECT_TRUE(test, drm_mode_equal(expected, mode)); +} + +static void drm_modes_analog_tv_pal_576i(struct kunit *test) +{ + struct drm_modes_test_priv *priv = test->priv; + struct drm_display_mode *mode; + + mode = drm_analog_tv_mode(priv->drm, + DRM_MODE_TV_MODE_PAL, + 13500 * 1000, 720, 576, + true); + KUNIT_ASSERT_NOT_NULL(test, mode); + + KUNIT_EXPECT_EQ(test, drm_mode_vrefresh(mode), 50); + KUNIT_EXPECT_EQ(test, mode->hdisplay, 720); + + /* BT.601 defines hsync_start at 732 for 576i */ + KUNIT_EXPECT_EQ(test, mode->hsync_start, 732); + + /* 64us * 13.5MHz = 864 pixels */ + KUNIT_EXPECT_EQ(test, mode->htotal, 864); + KUNIT_EXPECT_EQ(test, mode->vdisplay, 576); + KUNIT_EXPECT_EQ(test, mode->vtotal, 625); +} + +static void drm_modes_analog_tv_pal_576i_inlined(struct kunit *test) +{ + struct drm_modes_test_priv *priv = test->priv; + struct drm_display_mode *expected, *mode; + + expected = drm_analog_tv_mode(priv->drm, + DRM_MODE_TV_MODE_PAL, + 13500 * 1000, 720, 576, + true); + KUNIT_ASSERT_NOT_NULL(test, expected); + + mode = drm_mode_analog_pal_576i(priv->drm); + KUNIT_ASSERT_NOT_NULL(test, mode); + + KUNIT_EXPECT_TRUE(test, drm_mode_equal(expected, mode)); +} + +static struct kunit_case drm_modes_analog_tv_tests[] = { + KUNIT_CASE(drm_modes_analog_tv_ntsc_480i), + KUNIT_CASE(drm_modes_analog_tv_ntsc_480i_inlined), + KUNIT_CASE(drm_modes_analog_tv_pal_576i), + KUNIT_CASE(drm_modes_analog_tv_pal_576i_inlined), + { } +}; + +static struct kunit_suite drm_modes_analog_tv_test_suite = { + .name = "drm_modes_analog_tv", + .init = drm_modes_test_init, + .exit = drm_modes_test_exit, + .test_cases = drm_modes_analog_tv_tests, +}; + +kunit_test_suites( + &drm_modes_analog_tv_test_suite +); +MODULE_LICENSE("GPL v2"); diff --git a/include/drm/drm_modes.h b/include/drm/drm_modes.h index a80ae9639e96..dc03ce03e229 100644 --- a/include/drm/drm_modes.h +++ b/include/drm/drm_modes.h @@ -443,6 +443,23 @@ bool drm_mode_is_420_also(const struct drm_display_info *display, bool drm_mode_is_420(const struct drm_display_info *display, const struct drm_display_mode *mode); +struct drm_display_mode *drm_analog_tv_mode(struct drm_device *dev, + enum drm_connector_tv_mode mode, + unsigned long pixel_clock_hz, + unsigned int hdisplay, + unsigned int vdisplay, + bool interlace); + +static inline struct drm_display_mode *drm_mode_analog_ntsc_480i(struct drm_device *dev) +{ + return drm_analog_tv_mode(dev, DRM_MODE_TV_MODE_NTSC, 13500000, 720, 480, true); +} + +static inline struct drm_display_mode *drm_mode_analog_pal_576i(struct drm_device *dev) +{ + return drm_analog_tv_mode(dev, DRM_MODE_TV_MODE_PAL, 13500000, 720, 576, true); +} + struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay, int vdisplay, int vrefresh, bool reduced, bool interlaced, From patchwork Thu Sep 22 14:25:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985247 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D4FFEC54EE9 for ; Thu, 22 Sep 2022 14:27:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 60BF710EB6F; Thu, 22 Sep 2022 14:26:59 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id C3CE910EB6C; Thu, 22 Sep 2022 14:26:52 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 7F6242B05B1F; Thu, 22 Sep 2022 10:26:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 22 Sep 2022 10:26:52 -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=1663856809; x= 1663864009; bh=2NnjqCO4NMItXEoc0zbBHgLZ+xECh6BN8zUKWTW55Ys=; b=O Fur9YXofY21mq8/gyq5m9k34T3BnkOm/lebs2fS/9lQTv9OZ7qJtpPiqUG/i5qSW q2UPOYfEr2wAcKPH5kxFHiyvywyaS38jogfrFu/Yzr7fZlwJ/39soTMEVGEsaCd6 6pThEloiLC9+9fTlOK08KvQsqgT68CW0uhJKWue45pkGAnq+HPnBlCZlpj6Z1gDz kTww85DYX9CrT6JnACTDL0d3ExE2QaFHKsnknm2UIXQgL/HamkG9E2nedNBdHbGY fEbtp9vprjVk65lSRw0gWRN0+e0AfEJl+Zu9otf56xlmnzOIaArAKeCY+NXdbAL7 59BrLEON2azateYkI/tNw== 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=fm2; t=1663856809; x= 1663864009; bh=2NnjqCO4NMItXEoc0zbBHgLZ+xECh6BN8zUKWTW55Ys=; b=m q59E+H7i2lBNJMivDIRlLGh3hl9lsuqkFmc2YXlPPNy6wgNkQ3IUC+ijgUOkEfXD SOlC4HnisJ3BE62GnoH021mV8S6k73OsV6Vg2YXxFIJGHfUO0X5stLjJjfVMHzb1 WCjLniWIf2BNdZoPeISf4i0JB3zt4qj+DVgepXHI+iWt+fdiUTw0ZKBKa6Hk67JQ NUY5NCjWsPkKusIY0fLROVbnxwW2ipm8lUd/n00z8tG0bTcm/ZL6HnC7ah11UIaf QvyuoplKNyigAVeqX6hB6Hkp0sIjGYm/2RzGaGmlTsusp3nq7ic5bZl67WIeZiwe QUN0Xnl415RGVmqjRv3Jw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:26:48 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:28 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-11-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1592; i=maxime@cerno.tech; h=from:subject:message-id; bh=ehH+i59Vs/OowDE5NFRENhDEDWKHnp2mavFJ4/wcEk8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQEdq/PX9K6y2R4w8bddEENn17rOqilr9H5FnZWSzXwW l1TfUcrCIMbFICumyBIjbL4k7tSs151sfPNg5rAygQxh4OIUgIlMa2Jk2HqaR3mjKMvhis2sDY5Ktv HPj959KqvW2PH0yBePOpbgJQz/y1xTmidsqzKZWla2cOPyjNP3Vp+rXOH7TsZEPPXbo+3reQA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 11/33] drm/modes: Only consider bpp and refresh before options X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Some video= options might have a value that contains a dash. However, the command line parsing mode considers all dashes as the separator between the mode and the bpp count. Let's rework the parsing code a bit to only consider a dash as the bpp separator if it before a comma, the options separator. A follow-up patch will add a unit-test for this once such an option is introduced. Reviewed-by: Geert Uytterhoeven Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 76ab700f56ff..8742ee078fe6 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2275,20 +2275,22 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option, name = mode_option; + /* Locate the start of named options */ + options_ptr = strchr(name, ','); + if (options_ptr) + options_off = options_ptr - name; + else + options_off = strlen(name); + /* Try to locate the bpp and refresh specifiers, if any */ - bpp_ptr = strchr(name, '-'); + bpp_ptr = strnchr(name, options_off, '-'); if (bpp_ptr) bpp_off = bpp_ptr - name; - refresh_ptr = strchr(name, '@'); + refresh_ptr = strnchr(name, options_off, '@'); if (refresh_ptr) refresh_off = refresh_ptr - name; - /* Locate the start of named options */ - options_ptr = strchr(name, ','); - if (options_ptr) - options_off = options_ptr - name; - /* Locate the end of the name / resolution, and parse it */ if (bpp_ptr) { mode_end = bpp_off; From patchwork Thu Sep 22 14:25:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985267 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 A55FEC6FA82 for ; Thu, 22 Sep 2022 14:27:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B3F7610EB76; Thu, 22 Sep 2022 14:27:04 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 12FAA10EB71; Thu, 22 Sep 2022 14:27:00 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id C6B0C2B05B1D; Thu, 22 Sep 2022 10:26:56 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 22 Sep 2022 10:26:59 -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=1663856816; x= 1663864016; bh=jwz+ufkNT4RwFC1qE/qYHHRxmTxaMQhMtKio8e8RCO4=; b=k WthkSxJGwTqg7B8UZr2QYekK9lNpVbE4mlgOABGJ2KwdF9xlPZ0Nn2sdcmqj1Y1J gxzr401RJvXFiyFySZZge17mhnsAc3vdADTj/F1hcQwcxum20fmcuPWsGNeHR++X 800ftB6re853EZw4l1RNFKfq565umhMN2Vxi5DhzRcjJXVyYIax6/cdt4FikybDJ Zp76t6li/eiwvheS68Qh8TfORgTHE6S/oKtTb0vNkC3FP9vUtE6D+f7S7bD7PLqT h0JTQ/lhOONIWD8hnVBhwSyYRl4k5sAkNgKpv3lSprOW8IbQMFKM8zH997mQAmwB b3HmWuRApnr8DIc2gW1VQ== 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=fm2; t=1663856816; x= 1663864016; bh=jwz+ufkNT4RwFC1qE/qYHHRxmTxaMQhMtKio8e8RCO4=; b=H z9aJWg7FxXEUG6ai7wCGhXtcH2Xfenpj8of/aSOzT9uxVt0gJrmGxxNCaqIecfJ4 fd+isDf1c8v+WL9NrcuGGyfzE3RMAUQr9c1Wq5zAlRoW05X+JKIlji6m0FcF0EB9 AxdWk+0fOrpfo7reDffuWCUcAbR0Tkhf/P9HKMmoMO+FJv8T2ZRkBuaLI/Pit365 mlaFG/D+WKcuUsockm1EjqJXpaVbm2yqXtaFhZSH2J3fZkZlzd3+GQgIT1/CnT0P OkZeMGU2xzIjavmvdyhlvbEA7AmsXXG0/QQIR8Zm/z3d7P4gYJ5lYBKKsWuVak6i mdYWptg0BNWzcjsyU410Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:26:55 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:29 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-12-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1059; i=maxime@cerno.tech; h=from:subject:message-id; bh=Ce7gNsshIO6NX55u/tgmO2tT97mlvVnxqv2Q70Rq8gA=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQGR2f6vTLfOce1Tf/c2YcfK1KDF6yLux0os9nn2V3yN W2NkRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACYSm83wV5z//6Yip8nV7kuKeARWyx dpiOeXHrWP3smlt+da1oxPUowMz8z2PunkvRDE0H7h2rdLvJNlP72a8fxHrNJWm4Wff//UYQEA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 12/33] drm/modes: parse_cmdline: Add support for named modes containing dashes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Geert Uytterhoeven It is fairly common for named video modes to contain dashes (e.g. "tt-mid" on Atari, "dblntsc-ff" on Amiga). Currently such mode names are not recognized, as the dash is considered to be a separator between mode name and bpp. Fix this by skipping any dashes that are not followed immediately by a digit when looking for the separator. Signed-off-by: Geert Uytterhoeven Reviewed-by: Hans de Goede Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 8742ee078fe6..a1964e08c38f 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2284,6 +2284,8 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option, /* Try to locate the bpp and refresh specifiers, if any */ bpp_ptr = strnchr(name, options_off, '-'); + while (bpp_ptr && !isdigit(bpp_ptr[1])) + bpp_ptr = strnchr(bpp_ptr + 1, options_off, '-'); if (bpp_ptr) bpp_off = bpp_ptr - name; From patchwork Thu Sep 22 14:25:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985269 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D7FCBC54EE9 for ; Thu, 22 Sep 2022 14:27:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2255610EB86; Thu, 22 Sep 2022 14:27:20 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 251E310EB74; Thu, 22 Sep 2022 14:27:07 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id DAEC12B05B1B; Thu, 22 Sep 2022 10:27:03 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 22 Sep 2022 10:27:06 -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=1663856823; x= 1663864023; bh=IzHO9bnVwVVidyu/w4YB1rUhZuaEvXCFUHl4AC7n+Fo=; b=B C3i3Oq5XHh6sGTmFTLZuVJ0InQMtiiEaENaGeI0PKm6HVvpTL2r6Nbh8V8w6JpQB LIlRnLiYdAua6q07d5icbIrjeYh34LHe3iQ3L1pKk2fD0OC6Vt1Ehfxe1BZju7lC NObBlS3rTY2dO2zmu8v5/6bkK+smw5HAs/FnuSDK5LzcF7q1VHi/O/xJEPiv/AtU sJe2mpqzmAAbkGB8d4WYXPltm4Ik9M15vtXL6bUqM9S1Tbllm694/svXy/rXWbVF 6qDHGCFnEtEEgwhtDluFXsKr+kTg59IkmOXaTevtvoYQbKL0i0m+Os4IodB8jU8F P4bMOCRaztcCwJ/ofCstQ== 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=fm2; t=1663856823; x= 1663864023; bh=IzHO9bnVwVVidyu/w4YB1rUhZuaEvXCFUHl4AC7n+Fo=; b=C pZg4fXbDq7iQa8CuZ/MkSzXtrjbLYB2HX6b7hg8NQ1hKCs8IRblF6b5JNB/3mVrG ahhLUF4xkhiduhSAwuNP7gQWeE1S5hk3H/siylIIixzQq4GSj+z3x9jCi+NOIW6S PBdCSBijuUiSTjHrVbNDBig1roaNqveIOjNeylYtur5/9yIsWtuzWshr+8Z6/hiZ syN8VMq8huTjQKfyBkyEiN0PblQDuMIQXkAjitvG161QoKG/UTXJG5W1Gc2FeZks 6hFehuN/LbyVPi5dM+eg4IlS2S2q2Lq9N6m6Jtu6yNFLTpv+V1BN+Cz2y9W5Fv52 hjx94BlS77feYi+xIUSdw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:27:02 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:30 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-13-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4323; i=maxime@cerno.tech; h=from:subject:message-id; bh=jnFnz1dwyHOx+hA46erbRs5OOfPWWCBQIxlrOjFTajE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQHd31ebmdUeuvKP/1Ci0sa5la/XlApcs2wzPXXjemDv nb9qHaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZiIci0jQ//CpDm86XqH5zjlnTx+1v rqmkq//OxA5Q239kdsyd+/bgrD/1IWnk9CnQ3fpjbUF1yqnrdiUfGa7hfq3zjcvlzSeKTrwQ8A X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 13/33] drm/client: Add some tests for drm_connector_pick_cmdline_mode() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" drm_connector_pick_cmdline_mode() is in charge of finding a proper drm_display_mode from the definition we got in the video= command line argument. Let's add some unit tests to make sure we're not getting any regressions there. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c index bbc535cc50dd..d553e793e673 100644 --- a/drivers/gpu/drm/drm_client_modeset.c +++ b/drivers/gpu/drm/drm_client_modeset.c @@ -1237,3 +1237,7 @@ int drm_client_modeset_dpms(struct drm_client_dev *client, int mode) return ret; } EXPORT_SYMBOL(drm_client_modeset_dpms); + +#ifdef CONFIG_DRM_KUNIT_TEST +#include "tests/drm_client_modeset_test.c" +#endif diff --git a/drivers/gpu/drm/tests/drm_client_modeset_test.c b/drivers/gpu/drm/tests/drm_client_modeset_test.c new file mode 100644 index 000000000000..46335de7bc6b --- /dev/null +++ b/drivers/gpu/drm/tests/drm_client_modeset_test.c @@ -0,0 +1,114 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2022 Maxime Ripard + */ + +#include + +#include +#include +#include +#include +#include +#include + +#include "drm_kunit_helpers.h" + +struct drm_client_modeset_test_priv { + struct drm_device *drm; + struct drm_connector connector; +}; + +static int drm_client_modeset_connector_get_modes(struct drm_connector *connector) +{ + struct drm_display_mode *mode; + int count; + + count = drm_add_modes_noedid(connector, 1920, 1200); + + return count; +} + +static const struct drm_connector_helper_funcs drm_client_modeset_connector_helper_funcs = { + .get_modes = drm_client_modeset_connector_get_modes, +}; + +static const struct drm_connector_funcs drm_client_modeset_connector_funcs = { +}; + +static int drm_client_modeset_test_init(struct kunit *test) +{ + struct drm_client_modeset_test_priv *priv; + int ret; + + priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + test->priv = priv; + + priv->drm = drm_kunit_device_init("drm-client-modeset-test"); + if (IS_ERR(priv->drm)) + return PTR_ERR(priv->drm); + + ret = drmm_connector_init(priv->drm, &priv->connector, + &drm_client_modeset_connector_funcs, + DRM_MODE_CONNECTOR_Unknown, + NULL); + if (ret) + return ret; + drm_connector_helper_add(&priv->connector, &drm_client_modeset_connector_helper_funcs); + + return 0; +} + +static void drm_client_modeset_test_exit(struct kunit *test) +{ + struct drm_client_modeset_test_priv *priv = test->priv; + + drm_kunit_device_exit(priv->drm); +} + +static void drm_pick_cmdline_res_1920_1080_60(struct kunit *test) +{ + struct drm_client_modeset_test_priv *priv = test->priv; + struct drm_device *drm = priv->drm; + struct drm_connector *connector = &priv->connector; + struct drm_cmdline_mode *cmdline_mode = &connector->cmdline_mode; + struct drm_display_mode *expected_mode, *mode; + const char *cmdline = "1920x1080@60"; + int ret; + + expected_mode = drm_mode_find_dmt(priv->drm, 1920, 1080, 60, false); + KUNIT_ASSERT_PTR_NE(test, expected_mode, NULL); + + KUNIT_ASSERT_TRUE(test, + drm_mode_parse_command_line_for_connector(cmdline, + connector, + cmdline_mode)); + + mutex_lock(&drm->mode_config.mutex); + ret = drm_helper_probe_single_connector_modes(connector, 1920, 1080); + mutex_unlock(&drm->mode_config.mutex); + KUNIT_ASSERT_GT(test, ret, 0); + + mode = drm_connector_pick_cmdline_mode(connector); + KUNIT_ASSERT_PTR_NE(test, mode, NULL); + + KUNIT_EXPECT_TRUE(test, drm_mode_equal(expected_mode, mode)); +} + +static struct kunit_case drm_pick_cmdline_tests[] = { + KUNIT_CASE(drm_pick_cmdline_res_1920_1080_60), + {} +}; + +static struct kunit_suite drm_pick_cmdline_test_suite = { + .name = "drm_pick_cmdline", + .init = drm_client_modeset_test_init, + .exit = drm_client_modeset_test_exit, + .test_cases = drm_pick_cmdline_tests +}; + +kunit_test_suite(drm_pick_cmdline_test_suite); +MODULE_AUTHOR("Maxime Ripard "); +MODULE_LICENSE("GPL"); From patchwork Thu Sep 22 14:25:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985268 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D6DFEC6FA82 for ; Thu, 22 Sep 2022 14:27:23 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A5D3910EB77; Thu, 22 Sep 2022 14:27:20 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5F60A10EB7D; Thu, 22 Sep 2022 14:27:14 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id CF9842B05B1F; Thu, 22 Sep 2022 10:27:10 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 22 Sep 2022 10:27:13 -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=1663856830; x= 1663864030; bh=B1g5+PQrjPEH8uZqDM8R+Nwa9E9ZBZ5LKu7vSOSADwE=; b=P oUQghVxf8iEO4Pnvztuw+92pyAzV/avpag/lagK/fQhEojRwZSvcDov1ZjNth72d Fntjnqo/GbwiKOtUE8iTDjuc+uT4wTO+LOlus18b+zpGUx35rIuLBEXjC9FBZVmc gnWZeNmUggWtPyPOIHs3AfP5SATUGFzG3jz9FMPPB/VZa7Y+90ZBZupGRzlnaFbm Qfp/5YIWy5tEK/SkZSmGLhlUBkx99IkqQtVMf7O1eKnU2Adu4XXub5AlOgy5y9+w V3O6kYvDrMtK2Vnx4xR6wvDfVX+/Njk9eQBDPtXpzqbgzxCtgiwLtUPNAsCA+tVv wU8hfzV6qmTlhoctnmmWA== 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=fm2; t=1663856830; x= 1663864030; bh=B1g5+PQrjPEH8uZqDM8R+Nwa9E9ZBZ5LKu7vSOSADwE=; b=X c3fH45kjqTiIPx29b4R6VbXjmBmPDzOFxBr+UZNTIWJVgC0E/seJh6pwQepQP/k3 nZVSXL8avvn4nZu/fAO1Ov5aeysBi24EjKrOtitQb+7lMKM93cZYqOXtcUFrKBC1 v8MEDH80f1nQmEOt4XfTRJ9VCGn9hb+ybj55v3bD9PkGAwaitxxfi3lUTEUa9gfy fXEcvihhs5V1LSg09yEbN9dsQLsSZtd5QjRoEDEK5oIzHDfZONw/ZpNofMDk1cNR zvQlF+ZRlXd5kfzKkNJm2V26vzdDNAG4fZv5a9kwk18a+bUyibgTjWP64ygqeqfs C9bqH+Hr2Ydaai1eFhZIw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:27:09 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:31 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-14-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2608; i=maxime@cerno.tech; h=from:subject:message-id; bh=u2O3q2buX2U/Iv2bkD92AxW39Mh2ouzixRSVhxjJb+I=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQEHGj6dM/sj4PojP2vjtjP6zTmlcpWuE00uS6t+lU+U WXKho5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABNZ1M3w37P8CftnntdcUV6PLL1mvm 9ftMzD+mm+1N2U1uUxZaG3JBkZtnB/CV9osDAsKfSVzsP8L4F9GsIbq2dvi/5h+WfL/r50NgA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 14/33] drm/modes: Move named modes parsing to a separate function X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The current construction of the named mode parsing doesn't allow to extend it easily. Let's move it to a separate function so we can add more parameters and modes. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index a1964e08c38f..b1e800e4ed60 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2229,6 +2229,32 @@ static const char * const drm_named_modes_whitelist[] = { "PAL", }; +static int drm_mode_parse_cmdline_named_mode(const char *name, + unsigned int name_end, + struct drm_cmdline_mode *cmdline_mode) +{ + unsigned int i; + + /* + * We're sure we're a named mode at that point, iterate over the + * list of modes we're aware of. + */ + for (i = 0; i < ARRAY_SIZE(drm_named_modes_whitelist); i++) { + int ret; + + ret = str_has_prefix(name, drm_named_modes_whitelist[i]); + if (ret != name_end) + continue; + + strcpy(cmdline_mode->name, drm_named_modes_whitelist[i]); + cmdline_mode->specified = true; + + return 1; + } + + return -EINVAL; +} + /** * drm_mode_parse_command_line_for_connector - parse command line modeline for connector * @mode_option: optional per connector mode option @@ -2265,7 +2291,7 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option, const char *bpp_ptr = NULL, *refresh_ptr = NULL, *extra_ptr = NULL; const char *options_ptr = NULL; char *bpp_end_ptr = NULL, *refresh_end_ptr = NULL; - int i, len, ret; + int len, ret; memset(mode, 0, sizeof(*mode)); mode->panel_orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN; @@ -2306,17 +2332,19 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option, parse_extras = true; } - /* First check for a named mode */ - for (i = 0; i < ARRAY_SIZE(drm_named_modes_whitelist); i++) { - ret = str_has_prefix(name, drm_named_modes_whitelist[i]); - if (ret == mode_end) { - if (refresh_ptr) - return false; /* named + refresh is invalid */ - strcpy(mode->name, drm_named_modes_whitelist[i]); - mode->specified = true; - break; - } + if (mode_end) { + ret = drm_mode_parse_cmdline_named_mode(name, mode_end, mode); + if (ret < 0) + return false; + + /* + * Having a mode that starts by a letter (and thus is named) + * and an at-sign (used to specify a refresh rate) is + * disallowed. + */ + if (ret && refresh_ptr) + return false; } /* No named mode? Check for a normal mode argument, e.g. 1024x768 */ From patchwork Thu Sep 22 14:25:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985270 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 08925C6FA86 for ; Thu, 22 Sep 2022 14:27:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D33310EB87; Thu, 22 Sep 2022 14:27:26 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5872510EB87; Thu, 22 Sep 2022 14:27:21 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 1A2BD2B05B27; Thu, 22 Sep 2022 10:27:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 22 Sep 2022 10:27:20 -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=1663856837; x= 1663864037; bh=53LrYaV2mhomt8gRf9sphcJoUtcRBSDR3JTPJr8moaA=; b=A RfK4qb1MbOftPljiajcc1DgnXc2Gbe3U2NFvXlECK7XzZ44M4e5LvcGYLvzWUIeu 2e2GllkQc0O+UwbAUOXMPjfhQ4w0AlzMyKGuKZbzwsmz8gHhahQfBt/+1KnS278d dv2MFn2udCgjq1tWrY3POLRPPwVkcZG262jfAWfvx1koAMawwwBhSy1HugslD3D2 ScBeN5EzPHdrA1YdPEeOYttU4AblPe44x915+dYbflSVmYUjzuTDrGRoUltFdcZL joBVxdI5M81oAS3o26N0NMyeDKYzNhOhDmQIQPjvxmtedHaLN1Rn7CmdZ52aMQ3j Oz3nQlrZ5vFeH3JEFiRDw== 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=fm2; t=1663856837; x= 1663864037; bh=53LrYaV2mhomt8gRf9sphcJoUtcRBSDR3JTPJr8moaA=; b=M /3o+KIhg/f0A5/9Ekdl9jajH+LZLDS7nQXhvz9zqZpW3Ln68K7tGy5i0gCpFjf0l IOc0Z6Ptp8T28GQlG6boNtZOo88/vjdCOtoLtrwzdSTLmf9rx5cHjhAFhtL4Orc9 EmdOnfN7YK2YBExJTbAf3Qy5xEMP8xd4iQm0X9PHLmfAraolnUXx2FW6WpzWk1cD mPW/oh62fg5qf+a2GTulRKXnp6x0FD8n2YRKYUupNw2nmTC0Ugfg45bAkTIK3WHE Axuyp3Ag81L6tn+BBJpQ0wUHVOPd868jtExtvnR7BYIfwDes10aAZESt6ar1ByFe drGMOfZvbPI/GnWLaSpTQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:27:16 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:32 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-15-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=672; i=maxime@cerno.tech; h=from:subject:message-id; bh=LKwTlWbGSe8b9P99h7leZiXJ3B6Avu2KKY+GOK8gNk0=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQGqpWo/719bl6wawfHuyaMrYf8mvLlTp17f8Mz13rPn 0+Yc6ChlYRDjYpAVU2SJETZfEndq1utONr55MHNYmUCGMHBxCsBEDt5k+GcQJHfBb7Z8itrPYLmjqz Kvu78x5z8iJdEvetmxZObUplOMDGftxN/+b7eSs2hS1S2Onnn3afbhZf8NjW6rTb6akyc6jQ8A X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 15/33] drm/modes: Bail out of named mode parsing if empty X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" If the name we want to parse has a length of zero, there's no need to compare it to the list of all the named modes we support, we can return straight away. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index b1e800e4ed60..8d629fbb1047 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2235,6 +2235,9 @@ static int drm_mode_parse_cmdline_named_mode(const char *name, { unsigned int i; + if (!name_end) + return 0; + /* * We're sure we're a named mode at that point, iterate over the * list of modes we're aware of. From patchwork Thu Sep 22 14:25:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985272 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D626EC6FA86 for ; Thu, 22 Sep 2022 14:27:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8FD4C10EB8E; Thu, 22 Sep 2022 14:27:44 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0ED4810EB8B; Thu, 22 Sep 2022 14:27:29 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id C17B02B05B28; Thu, 22 Sep 2022 10:27:25 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 22 Sep 2022 10:27:28 -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=1663856845; x= 1663864045; bh=xSm1H/SvLOO84UTCPZaxyASkQdYRdGizK9EhDQqVUIE=; b=f 7nQe8WpUbPbNHBxZyNsg4pvSmHXiHjCjDwBQfCbCldC2ndc6an6c+8+Hzh2JI7Yk l4FTAlNgzoq2PY0y6hORuVzojPbJH+dBVlC0OCc6fTuBUofhd1XabwKOisKL6kDg xvbcoJgwrPbtEcgWkuYbkRH8fz/rcSBNqNm2ZQIyzjqwp/RFNS4EGsdxNNUYw6Li O+FFH24AQeebjKV2/GZKm/Xu+OqOBUroRpp/Lca6CIFvDk24OPUqlVjyWkGg6oE1 sc5Nwld+5wnjOvhgahCrgipInV3ltbx0sdj095yQQuT75TVHyavqkqOXi5nsn3ai w6c8l1KThDV6H4da2jy1w== 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=fm2; t=1663856845; x= 1663864045; bh=xSm1H/SvLOO84UTCPZaxyASkQdYRdGizK9EhDQqVUIE=; b=L KE0hx6dOosf71MT1/AFhqd2FZNyhM7GcIOL+JGmgJiuqRQwruhfh/IuDEzyHdWFW U0oFdscqLRXqpbWEqaVm504KW/oYl5qVAGuWUi4mHtugfFQrlYFLKaqpRZbGAcoh tJrVDryw7Tq+e/KFjj+pJHXxAxbWOtzhRnlRuEx1ECtDb15wqnbUiocy+tuF1kJ+ bm0+ArCKAxIvvVXL/6BrNGJzqHx8iE7oU38m0yrYbRjYnvwcj0Ydkv5H8eCkiREh X7rM/ZLRQfIejPphdBaAN0ve7Bgq8+PQYC/itosMvjSTQgv1ZRxi6lsrWSTySYGu po/eujcsWZe1Yqd6hNdkg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:27:23 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:33 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-16-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=781; i=maxime@cerno.tech; h=from:subject:message-id; bh=shGH9ck7c+L41qD2WH9TMF8BbPwoWC/90AbR/JV60RA=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BQGFs9Nu79OYOVE4ojXPs7nd9zlbaO6p+tCY2StWbXlx 8GldRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACZSvZ/hn6HFxvfrjBIl1jK2H3B+5a DbGrfj0aYefr7rurp/g03Xf2b4w5nxeKvCDm3bc2mnbvuUMjUWnIjVuSV4r6vF9K3BkwtH+QE= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 16/33] drm/modes: Bail out of named mode parsing early if it's a number X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" If the name we want to parse starts with a digit, it's not a named mode. Thus, there's no need to compare it to the list of all the named modes we support, we can return straight away. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 8d629fbb1047..ede5b094da4c 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2238,6 +2238,10 @@ static int drm_mode_parse_cmdline_named_mode(const char *name, if (!name_end) return 0; + /* If the name starts with a digit, it's not a named mode */ + if (isdigit(name[0])) + return 0; + /* * We're sure we're a named mode at that point, iterate over the * list of modes we're aware of. From patchwork Thu Sep 22 14:25:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985271 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 9FB1DC54EE9 for ; Thu, 22 Sep 2022 14:27:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E9D3510EB90; Thu, 22 Sep 2022 14:27:44 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id BA6C010EB8C; Thu, 22 Sep 2022 14:27:36 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 7459D2B05B2B; Thu, 22 Sep 2022 10:27:33 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 22 Sep 2022 10:27:36 -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=1663856852; x= 1663864052; bh=2J8ePPZWtgHL+Hggk4tVDJx1sG6hl+uFivM/ERtqGsg=; b=3 mDNWZNIe3DDqHKKg9XVsm47n7p8liMzAERITZAhAD7Jtv66VpdBtwazK/jqjmrjP Ab+FQLr0JB8CuHEhaMrD+73mSYZ+t2Qf3HM7eNaM2xpnWQEuqq3yAVDm19GFDdh+ WIU+Sys7mUeYoscOsdgvU826AaBhj6tk2jexZSRCf8owvzPCqcodoOiuDMT4dhyr xpeF7G3b90I0IyjnwqvEhQehpHmpj7IZv+19frAVFx5yBUCTf2Yd+dKrNTF83OVR qpYIwXRNJWS8p8XlB9e4oRCjYA85XUr0JIOLZmdqertSp4oUmTvZBdSMf6CquSMy ZX7PawU65R36uriF/rmwg== 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=fm2; t=1663856852; x= 1663864052; bh=2J8ePPZWtgHL+Hggk4tVDJx1sG6hl+uFivM/ERtqGsg=; b=I xCAkikURCXPNtPe/OFLT/L8HOGuOt9N7gxlGwiYeQ5Pe4Zo5nVpiemzlw29eCoMx rcIulxLP8ndPULBs00x2T7ZvJykYH/k22PY7CGbVMSYbxvDdQX3aPChv3+l70lSH M5u6erWvTI50ND20z1m++SJGV4j2fI/YSWk5MMGNI56DCP1MBVch3D2u5Obi+3eW hLg/JpqqLFhV5TzCfM9KQG8a+JGdKfunrY5qKrlirdVPOSKrO1zxKm9qb+JzkXqx Ubg1dPT4A9Y5vY+BM1fdOy7PUjapsRlIj2HyoWfUeBThJ+tH61/sPtUZplwSitrA HrAQSFho2nKAvNsLpInJA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:27:31 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:34 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-17-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1102; i=maxime@cerno.tech; h=from:subject:message-id; bh=hUcbhwJ9DBy9NDrshDAAcggJzHGewykANY8cYFaxCfU=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYGvwz9JBsU1OMkff7fXYf3G8Omz2y6rsMtblO7ZEiBz ckVNRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACYSO4WRoe/GFdmGNA2FT4KPznq/0D ljVLZy3fz/L9NymZU+hs9aIs3wT+X5IkPpRWF/n0Ss2m/+6Lg622/jlxEzXv6pUJnD/nztTRYA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 17/33] drm/modes: Bail out of named mode parsing early if it's an option X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The name we are given is the first part of the command line split at a comma. We can thus be called in two cases, either we are parsing a (named?) mode, before the optional part separated by a comma, or we never had a mode specified but only options. Options use the equal sign as separator between the name and its value, so if we ever find an equal sign in our string, we can bail early since we never had a mode to parse. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index ede5b094da4c..dc5d5bdbea7a 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2242,6 +2242,13 @@ static int drm_mode_parse_cmdline_named_mode(const char *name, if (isdigit(name[0])) return 0; + /* + * If there's an equal sign in the name, the command-line + * contains only an option and no mode. + */ + if (strnchr(name, name_end, '=')) + return 0; + /* * We're sure we're a named mode at that point, iterate over the * list of modes we're aware of. From patchwork Thu Sep 22 14:25:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985273 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 E4A72C6FA82 for ; Thu, 22 Sep 2022 14:27:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 17C0110EB89; Thu, 22 Sep 2022 14:27:49 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id CDB8D10EB89; Thu, 22 Sep 2022 14:27:43 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id E95022B05B2C; Thu, 22 Sep 2022 10:27:39 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 22 Sep 2022 10:27: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=fm2; t=1663856859; x= 1663864059; bh=XzPimO3TGCZN1s10n/IWLqdGw90v+7NTrKZn456FDUw=; b=3 cDVSrU93OpIfH3kSzBnshRADcY253ne+mFqS5xlLS9Iln5kIr4Daeufz49Ee+Baf BDEUev0tMmCFqaxQBN8uG6rp/ifCMK266Yj82znPhgKnMgoaOWvyEf6CFGWsayfn wpemtKYY00Yn0oWlP7op2F8lM2RqX9Ck0X8RNQBlqPK8uDAczxC3+7qbw+UZwdM3 YfoENghlJ+NKrhRP3Pdo4TH68dYJicNcCLWp7VGYR9gI6FyQwbDETyr+eWZrZkKQ WWmXlHoEjN+vtlCa0QGdbnAajJiF+uSiplafJ54/bt2zCJb8GRRP7fID1r1+i6bm BbutW4VhRONAS8/Am8q1w== 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=fm2; t=1663856859; x= 1663864059; bh=XzPimO3TGCZN1s10n/IWLqdGw90v+7NTrKZn456FDUw=; b=S 0E3nnYBHeJ7HHbhQHJFNN83I+j48ocCpiFyYTUCkY0xaYfu/JkJ1vUQeEmBH2Xzp BaDQyyck6bzsl+W8IXK2pp3sjiGoPJ0Zs64p4DfzsuXECyHWD8mCGTz7yFarvV/h 69M91NzDxx6AniRNdDz2tuJZjxXYXIsGOuWnH5XEigY8w8m//U8JCBgNkQQueL8d zKrd9/oQEM6DbOpBvlt9ghN+EPYylt+w8d5od6Yux56Aw99M6HyWvUKfXGYT6fE7 KTR/VwdiQun/C/yE1knz/O16Qy4lFBgHNCS0umBjAIx5KJLkC5iKDaHdjM5U70JC 62fXW14X/4GGSzTIILCig== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:27:38 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:35 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-18-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1396; i=maxime@cerno.tech; h=from:subject:message-id; bh=EPj2DquHuorBdZ9jZRn1PEir7mTLC2HDypL7NDzcn00=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYGlD+/tOLf39jmWaV5rMqdOm+HVrZ58y8IqufGommqN 8KpdHaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZjIv7eMDE/MlS097fyr+nQay1nXng pim/wtzemW2MHtJW9/L/zk3sHIsOP5ZY9Daw/blnkmbOXvO9GgYaoVcHR5ift98aYHs94mMgIA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 18/33] drm/modes: Bail out of named mode parsing early if it's a status X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The name we are given is the first part of the command line, the part before any option. The most trivial case is thus that we're parsing a mode. However, the connection status uses a single character to encode what status we want to force on a connector. It's thus fairly easy to confuse that character with a named mode, and our current code works because the list of the named modes we consider doesn't start with any of those characters. However, it's not very obvious and quite fragile, so let's add an explicit test for this, with some comment to explain what's going on. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index dc5d5bdbea7a..9cee0ad806b8 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2249,6 +2249,15 @@ static int drm_mode_parse_cmdline_named_mode(const char *name, if (strnchr(name, name_end, '=')) return 0; +#define STR_STRICT_EQ(str, len, cmp) \ + (str_has_prefix(str, cmp) == len) + + /* The connection status extras can be set without a mode. */ + if (STR_STRICT_EQ(name, name_end, "d") || + STR_STRICT_EQ(name, name_end, "D") || + STR_STRICT_EQ(name, name_end, "e")) + return 0; + /* * We're sure we're a named mode at that point, iterate over the * list of modes we're aware of. From patchwork Thu Sep 22 14:25:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985274 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 87120C54EE9 for ; Thu, 22 Sep 2022 14:27:56 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 99B3510EB95; Thu, 22 Sep 2022 14:27:55 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5880410EB91; Thu, 22 Sep 2022 14:27:51 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id 0C72E2B05B31; Thu, 22 Sep 2022 10:27:47 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 22 Sep 2022 10:27:50 -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=1663856867; x= 1663864067; bh=6jzwlHXRKIyndP+lXIzt3Yajs+mMskqMIyYzuX3/ETo=; b=3 rc9Y6M4VcaUa9oTKUDa98p2Tz57bk6UXGVPlSW9oNm9SOsde3XnA2r7T9qwa/ryb K+UJEOAzPS8W99+oFUDBwlHJQOfXcJJQ3CoxUMp4M5n/21g9EGjgAxHxZg6ivCMW p+1ZQNXoqrzqnlkIhPtzzseew4RybzT0r5y6doReHQYJPKbo39hXfEOfOpcegA7B fW+tZE7vHLssUDxcYVvn+YKhuw+wL49vIdk8HhI86S4eMPrdjJJxKjrvKQHM1ttm CTkdnWWTGp81f2c741J8Ya5hnFrbc+yl9UrNJD9qC6nH9fYfkv3HuNiTIdWgFsRA clj5wDEE3zotEqfjbLYUA== 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=fm2; t=1663856867; x= 1663864067; bh=6jzwlHXRKIyndP+lXIzt3Yajs+mMskqMIyYzuX3/ETo=; b=f ypF9vRSDT+YVhSsnOwVtIBWKhwUs4s8TBuV6SUJ0tvd6CF5TE8QGqFN9rr63iCFJ 6rpgLofGUBi39e/+xoeBAMpi1OPByGEXn4U3lrxawLmlMisOJktDZ81DgifUTXVW NRvDrCZsiGHSXUGqPheMCQwKZ8DloWHFMx8AcXE2Lri4b1N9YhyUvM9l4Ys3WEBE jxKs04OIrxj6/AphSWpM+pq/EuV5TWP8Fcnjo94/JDQBidauBlUvyeMHwxBmj7gU aFrEjUkwW+34NzCZFLdKhNrJm6FCsotYFBMcx5VmxVWXriorqNa1nGwgwPr2AvbQ /xZy/YERpU3OK+HvaQGFA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:27:46 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:36 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-19-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1610; i=maxime@cerno.tech; h=from:subject:message-id; bh=ak4bdagFeC60CdYLI9q4vEZkdpDO1FK48fEhtSFByyY=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYGbFz1iPeo843W50lt+pagbitN0ctwkExet7RLXakh7 7fOro5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABNRXszI8JzLoq3P9v5POUG18/FNL6 +/Sda7VPL0vpBtwdRaVnfjBIb/TknZa/ZLd3dx333Ff4pF4Ynbsn2vKqK2KxhGPd6yQoifCQA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 19/33] drm/modes: Switch to named mode descriptors X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The current named mode parsing relies only the mode name, and doesn't allow to specify any other parameter. Let's convert that string list to an array of a custom structure that will hold the name and some additional parameters in the future. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 9cee0ad806b8..8c8b37ba37dc 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2224,9 +2224,13 @@ static int drm_mode_parse_cmdline_options(const char *str, return 0; } -static const char * const drm_named_modes_whitelist[] = { - "NTSC", - "PAL", +struct drm_named_mode { + const char *name; +}; + +static const struct drm_named_mode drm_named_modes[] = { + { "NTSC", }, + { "PAL", }, }; static int drm_mode_parse_cmdline_named_mode(const char *name, @@ -2262,14 +2266,15 @@ static int drm_mode_parse_cmdline_named_mode(const char *name, * We're sure we're a named mode at that point, iterate over the * list of modes we're aware of. */ - for (i = 0; i < ARRAY_SIZE(drm_named_modes_whitelist); i++) { + for (i = 0; i < ARRAY_SIZE(drm_named_modes); i++) { + const struct drm_named_mode *mode = &drm_named_modes[i]; int ret; - ret = str_has_prefix(name, drm_named_modes_whitelist[i]); + ret = str_has_prefix(name, mode->name); if (ret != name_end) continue; - strcpy(cmdline_mode->name, drm_named_modes_whitelist[i]); + strcpy(cmdline_mode->name, mode->name); cmdline_mode->specified = true; return 1; From patchwork Thu Sep 22 14:25:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985275 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 3C319C6FA86 for ; Thu, 22 Sep 2022 14:28:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2508410EBA0; Thu, 22 Sep 2022 14:28:06 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1921E10EB9D; Thu, 22 Sep 2022 14:27:59 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id CCC942B05B34; Thu, 22 Sep 2022 10:27:55 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 22 Sep 2022 10:27:58 -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=1663856875; x= 1663864075; bh=LNibWIZ1W4oFh1EO7hNOkEOkBr+JL3i1WQh0c1QOIds=; b=E qjXHEhfsFJxGnXzlHxs8AGJ/IGlCJ4Je9Vkaw37k4eA97mPZkneMuA8RWDB3HH+i MZwBj14i91lWLB07WX/zewgpoAslc0LPsYk4z3vY/zdYB4zhW+MkVl9k/bUIvwnN yrCyQYCggzoQ3BVV835DLVI7j3GsW70l7i+5Yi38mQNTXhZ6PokB80LLNyMyUl3P 0ialxYVCoDahe0/hZ0OSP/LB3t4SEp4jc0eic58DKQZzcxahSenn2ozbI5vJqcxx bHiUgi9eyZHLmlQOrxrh+vu8M13V5qpObxyoUO3kOfbgjwNLFbteJQvFYzZEmovd CAJHzGPBCpaW/yjMjUz5Q== 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=fm2; t=1663856875; x= 1663864075; bh=LNibWIZ1W4oFh1EO7hNOkEOkBr+JL3i1WQh0c1QOIds=; b=F sWV473P8NYYQexGGABI/U0cKKIraWEr2rHvc+4mg4mpibxWI9MR7dEVOoyx9RmQV lqaONiY4JsGgOGv0YMEuhBWmK0HUWAXOZnv7X+QpgOp0ZG/kQqbDD3jCOQ/SjATz mcgkukz3WBbtMKaPXGHVIFiidpDXSH7UIkQWQA8Q4RgRE7r+g6T5kxsjdQw8ttSn i7ODyW2dbuXMZ2srWgYmwO9Q0VrLmOkfroLAaw2tyKKc7gQ5rWd5gyWu9kYtXpJh A4BYfEhRlP7rcCxurB1KUP3Cr5HszCE9q/Fk0F16WxVwIYO2VXwCeWx8/cHX+6Mn hObr4pofH2E+uI6dpPaxQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:27:53 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:37 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-20-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1635; i=maxime@cerno.tech; h=from:subject:message-id; bh=Vry5+OU4UmtPLlNtlWmlVT8AGNp67JVCIbgY1gO14o0=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYGTBLVVDtizMWVdeij876WFp+gKK09OnYcs/uxpJWEx 4TUdpSwMYlwMsmKKLDHC5kviTs163cnGNw9mDisTyBAGLk4BmMiTEob/iX8nJmuELX3kvey/LfPp0D VTCh/6MXwXn293TJxrq91kN0aGBo0SUYm+rXEuJ4v47hucixC2K5kcGCIf1CT7u/DFfxc2AA== X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 20/33] drm/modes: Fill drm_cmdline mode from named modes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The current code to deal with named modes will only set the mode name, and then it's up to drivers to try to match that name to whatever mode or configuration they see fit. The plan is to remove that need and move the named mode handling out of drivers and into the core, and only rely on modes and properties. Let's start by properly filling drm_cmdline_mode from a named mode. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 8c8b37ba37dc..5d8b6a0d96f3 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2226,11 +2226,22 @@ static int drm_mode_parse_cmdline_options(const char *str, struct drm_named_mode { const char *name; + unsigned int xres; + unsigned int yres; + unsigned int flags; }; +#define NAMED_MODE(_name, _x, _y, _flags) \ + { \ + .name = _name, \ + .xres = _x, \ + .yres = _y, \ + .flags = _flags, \ + } + static const struct drm_named_mode drm_named_modes[] = { - { "NTSC", }, - { "PAL", }, + NAMED_MODE("NTSC", 720, 480, DRM_MODE_FLAG_INTERLACE), + NAMED_MODE("PAL", 720, 576, DRM_MODE_FLAG_INTERLACE), }; static int drm_mode_parse_cmdline_named_mode(const char *name, @@ -2275,6 +2286,9 @@ static int drm_mode_parse_cmdline_named_mode(const char *name, continue; strcpy(cmdline_mode->name, mode->name); + cmdline_mode->xres = mode->xres; + cmdline_mode->yres = mode->yres; + cmdline_mode->interlace = !!(mode->flags & DRM_MODE_FLAG_INTERLACE); cmdline_mode->specified = true; return 1; From patchwork Thu Sep 22 14:25:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985276 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 6D5E2C6FA82 for ; Thu, 22 Sep 2022 14:28:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 69BDE10EBA1; Thu, 22 Sep 2022 14:28:13 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id F12DF10EBA4; Thu, 22 Sep 2022 14:28:06 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id AD6282B05B32; Thu, 22 Sep 2022 10:28:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 22 Sep 2022 10:28:06 -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=1663856883; x= 1663864083; bh=0h+j4Ml235vzzhk4vbz+WoFhzY0sO9zK12Ov1UnPsu4=; b=S FZ2SNztZYY3YCcMvY9vU8Fgp9KqOhqXb15Yv+rP4F20N2IB+r2FOGUnaVfvxeCA5 Qs5T0iq8Qxt2gaJWx3dfD4AromirYmJfeztL91DVw0sJWUvsSkS6PoZAy3d7RdLB WET8r3vliStt9LpAeIU6whif9xRrEcO25hMQ30gKvXzfGYL9NV3US+3sHyggkzyw uNDkyOvOPE4e0nsw31ZUMw1vTahmLowaMOjBSS+BZ02wZc/h3X9hOei9vP3iCkuD j9kPeUqWYihzmL6GS2MRi3Uiw+22Yb6eQmTWweqObpWviMxHa1qTBCykhKuU7AWF tMr5v0zeBVpgxZGZ0lOaQ== 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=fm2; t=1663856883; x= 1663864083; bh=0h+j4Ml235vzzhk4vbz+WoFhzY0sO9zK12Ov1UnPsu4=; b=C xObU6mMlJxh0xcyUVe0lAfXA03pbupq3cG9zYOXnX8OmH7td8dTes8keWJdOrvKv m79YxYTwu3fVFyRbYX6Anz9qIn3yLBOs5z0+OFExR7/oTYK+lnAjYGN/DuHquIpA gbYZpy33igVSGf8kLtcDpRSJ8bDFxNh/WmtD9j5kPNOgXZKk0zm7Eo9phve1T/7S fnvVfPEI7sFDGYKE/5RkNnM+9gNnEPxQTO08iIlIR9P7yczHq1wnDb9uN098qMQy Al0x05A/rxQHzEHWVjASfPZEdm33gxu/auFNblF4f1HJABD1dzDq73TstZxlY6Cb +XGRVoX2PwW0YVpkaKwjA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:28:01 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:38 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-21-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2051; i=maxime@cerno.tech; h=from:subject:message-id; bh=rxoD3Af1weJFe2uj/nLNvKWNvmy0Jf/ctDPA3MS5OG0=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYFzp3Yzxmc6Vy27uMBAa8rKkPJUx0sl609r/w9vkb/y +uf5jlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAEzknBTDHz57x5nmH9UKKsN+5azbaq 7L+bzp3VUV7drL85fUhPy+c5mRYfKaG15zJp5WUFz0eeMD/o3Ns/JXBj1xsfm4QEVfQuiLMxMA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 21/33] drm/connector: Add pixel clock to cmdline mode X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" We'll need to get the pixel clock to generate proper display modes for all the current named modes. Let's add it to struct drm_cmdline_mode and fill it when parsing the named mode. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 5d8b6a0d96f3..eb3c4e596c67 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2226,22 +2226,24 @@ static int drm_mode_parse_cmdline_options(const char *str, struct drm_named_mode { const char *name; + unsigned int pixel_clock_khz; unsigned int xres; unsigned int yres; unsigned int flags; }; -#define NAMED_MODE(_name, _x, _y, _flags) \ +#define NAMED_MODE(_name, _pclk, _x, _y, _flags) \ { \ .name = _name, \ + .pixel_clock_khz = _pclk, \ .xres = _x, \ .yres = _y, \ .flags = _flags, \ } static const struct drm_named_mode drm_named_modes[] = { - NAMED_MODE("NTSC", 720, 480, DRM_MODE_FLAG_INTERLACE), - NAMED_MODE("PAL", 720, 576, DRM_MODE_FLAG_INTERLACE), + NAMED_MODE("NTSC", 13500, 720, 480, DRM_MODE_FLAG_INTERLACE), + NAMED_MODE("PAL", 13500, 720, 576, DRM_MODE_FLAG_INTERLACE), }; static int drm_mode_parse_cmdline_named_mode(const char *name, @@ -2286,6 +2288,7 @@ static int drm_mode_parse_cmdline_named_mode(const char *name, continue; strcpy(cmdline_mode->name, mode->name); + cmdline_mode->pixel_clock = mode->pixel_clock_khz; cmdline_mode->xres = mode->xres; cmdline_mode->yres = mode->yres; cmdline_mode->interlace = !!(mode->flags & DRM_MODE_FLAG_INTERLACE); diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index fffacbfd0a45..80e19efb3f42 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1279,6 +1279,13 @@ struct drm_cmdline_mode { */ bool bpp_specified; + /** + * @pixel_clock: + * + * Pixel Clock in kHz. Optional. + */ + unsigned int pixel_clock; + /** * @xres: * From patchwork Thu Sep 22 14:25:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985278 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 5292EC6FA82 for ; Thu, 22 Sep 2022 14:28:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C1C1E10EBA7; Thu, 22 Sep 2022 14:28:39 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3EC5C10EB93; Thu, 22 Sep 2022 14:28:14 +0000 (UTC) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id F3B272B05B36; Thu, 22 Sep 2022 10:28:10 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 22 Sep 2022 10:28:13 -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=1663856890; x= 1663864090; bh=dfVq7BXQ9B4uAsI1a5x7OI32Ta0Cs2gU9rZUbwMpsfU=; b=r fTs6skAYSFL/b/LcYdjoOgK3dfLrbBkNKkH9FpEXI8spPzKeRD+0c9fzeEyuI1i3 QPxUxKc0ZVHmmZTpr3Oqgw/gd2s5uJD08KJy0VLsQSorgU5TSFa5pTwK0PzKd/IY oX1VDM44hyYcDZTCUrtkuXS6vUTOUpAfZ66D40ZgMMVtgWlcdewUaJdXvvb1SfP5 EA7uA36N0nSEUECo8mDDZiVXSGCegv1dkhGF4U1WYuJBQXr9SCVb6/EXIL9DUQYa ZW6leNtsEBfG0hwbSsEq/FlPa2/OswWBWpg0WP4zdcDK7uOAoP/idepmyopU2IeU ffA7/E1tyTX++GsPOxBvg== 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=fm2; t=1663856890; x= 1663864090; bh=dfVq7BXQ9B4uAsI1a5x7OI32Ta0Cs2gU9rZUbwMpsfU=; b=C Pv1sHgjrwaYJmsnrq4QCbS04NI1Gzd3smzXf2fEOzvh6Kt5XuvCwhVxO1winuc2c QDoOi7ZeujMAqWNtrcVzZqU9qyiPA3T6scnZKKG6xwv57RjlktTROoMTJz9RqfBB OKnll4la2I+nDGt3XqOuy2yqpP31Bo2F9YgL5kzqN3LQ8U3SSiq7GsFtukjUgage 3GuO0BO5AZyXr/UqA+nUhlrXLVi7bfW04lZXY5hLcg9+7knidGYvHQ/glDtJOtTo lQdFHxcGDSDW29z9f2m5P8i8cA4fJYbePfHlmLRRaOUxPc0CDrWjEAbuN7nrIKYx wr6521mas84lR2fmkXMWA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:28:09 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:39 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-22-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2242; i=maxime@cerno.tech; h=from:subject:message-id; bh=SAjtmTJcJObMxS7pu9nZu7kJ4+czqVT9o2Td3HmdMSc=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYEzdTm7Y2tLlmx+b8Z69rSx55wmVlVZ0xOzdrocmd+r HbK/o5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABOZdI/hv+9Ea5fLFj9SG2L2Slm/zY izfe7i9/z1mvS/t/1Ohh6ZepmR4ZzynG0bwnWzZz06JfA8n+dJyPFrPG2br5xwPZNgzN+mywAA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 22/33] drm/connector: Add a function to lookup a TV mode by its name X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" As part of the command line parsing rework coming in the next patches, we'll need to lookup drm_connector_tv_mode values by their name, already defined in drm_tv_mode_enum_list. In order to avoid any code duplication, let's do a function that will perform a lookup of a TV mode name and return its value. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index e7aa8de08f5b..7acf294aba5f 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -992,6 +992,30 @@ static const struct drm_prop_enum_list drm_tv_mode_enum_list[] = { }; DRM_ENUM_NAME_FN(drm_get_tv_mode_name, drm_tv_mode_enum_list) +/** + * drm_get_tv_mode_from_name - Translates a TV mode name into its enum value + * @name: TV Mode name we want to convert + * @len: Length of @name + * + * Translates @name into an enum drm_connector_tv_mode. + * + * Returns: the enum value on success, a negative errno otherwise. + */ +int drm_get_tv_mode_from_name(const char *name, size_t len) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(drm_tv_mode_enum_list); i++) { + const struct drm_prop_enum_list *item = &drm_tv_mode_enum_list[i]; + + if (strlen(item->name) == len && !strncmp(item->name, name, len)) + return item->type; + } + + return -EINVAL; +} +EXPORT_SYMBOL(drm_get_tv_mode_from_name); + static const struct drm_prop_enum_list drm_tv_select_enum_list[] = { { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */ { DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */ diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 80e19efb3f42..0dcd08e036b6 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1870,6 +1870,8 @@ const char *drm_get_dp_subconnector_name(int val); const char *drm_get_content_protection_name(int val); const char *drm_get_hdcp_content_type_name(int val); +int drm_get_tv_mode_from_name(const char *name, size_t len); + int drm_mode_create_dvi_i_properties(struct drm_device *dev); void drm_connector_attach_dp_subconnector_property(struct drm_connector *connector); From patchwork Thu Sep 22 14:25:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985279 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 7D7C2C6FA91 for ; Thu, 22 Sep 2022 14:28:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 43A4110EBAB; Thu, 22 Sep 2022 14:28:40 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 194F210EB96; Thu, 22 Sep 2022 14:28:22 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id CB80C2B05B37; Thu, 22 Sep 2022 10:28:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 22 Sep 2022 10:28:21 -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=1663856898; x= 1663864098; bh=18gGBbn5BOA5LtOZVTB7pksmz1dlucmzGzMKFLykfNY=; b=m dDwxrUVmy1qPPR8/Ec5o8wopfS0vNZuiXp5HxIzj981pK1TueM9evez3QJhN5eNG QltS9YiMBJwbWJIoBZMbU1HDYdsIF6zqVWPtidV/e+jpFDqWnAZVzPXzuTO98wmo BbcOJJi4Ux42c5Ro2DZc3QU51KIlAj0atPUcXAkInXD8rlgQ6/Sw9dvDn7PWTW+Q EgI/VIyHm3fM0dnHpxFll9T4P+kOODL1vlkBCQBbaVZQYk4lV3EfIEVvuTVsP5lg ssj47XhtayuLs1v4gAltjWVuCwHLWkeCqynAK/VFcmBT+B9bffOXYEFY5D9VyU7e bz65ClbwVQMcFNaPWMR8Q== 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=fm2; t=1663856898; x= 1663864098; bh=18gGBbn5BOA5LtOZVTB7pksmz1dlucmzGzMKFLykfNY=; b=x Worno52buMMgTJwhK8M+2xtavVQnGm/L1/zFnlb3nqJKttuUJVC0l4ml2NLX92DJ Bi+xIctCLB20J9z2Asz1lNM7BsVxt9aqPwHssnwAWE89Eeio960IR1bMh33cOsYf 5TtHCHXNVDj7MenIn4JZXqKhJZghkq6tIIv6jAbEqFCctPmHxFCn2Oca90dzDUfi s04zHoe+60wEww3Ug/xCqo+DxGFQDXCvDd8183EtoY7wnIs5MQXWQEl7Jhd+GXRk TXIwWzV+BZoOK1HPdZcWGjwzqXGpnqQtZnv1m3ZrhZEsQ5oq6pmw/04zo/3FwRzz iMJ5L4xXciIcNkmhsjT5g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepfeenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:28:16 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:40 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-23-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6975; i=maxime@cerno.tech; h=from:subject:message-id; bh=lBqGDXH5voEp6jsLlR06bJCOipI8OO2ew6AJhUSWlXg=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYEHZrDaLA/RjAj8++5/bfzXn/PsbA67hq/b7rMkZ8+7 GQZTOkpZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRmfkMf4WmSJ3a0feNIbTi+MoWi7 ur24+z6jdw+d1e+Oa6p4JAEScjw8S9MuIPZQ49cjn1yq9UZPWJT3uEZDtFpzGenHe4OL94KQcA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 23/33] drm/modes: Introduce the tv_mode property as a command-line option X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Our new tv mode option allows to specify the TV mode from a property. However, it can still be useful, for example to avoid any boot time artifact, to set that property directly from the kernel command line. Let's add some code to allow it, and some unit tests to exercise that code. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index eb3c4e596c67..23e665fd808e 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2133,6 +2133,29 @@ static int drm_mode_parse_panel_orientation(const char *delim, return 0; } +static int drm_mode_parse_tv_mode(const char *delim, + struct drm_cmdline_mode *mode) +{ + const char *value; + int ret; + + if (*delim != '=') + return -EINVAL; + + value = delim + 1; + delim = strchr(value, ','); + if (!delim) + delim = value + strlen(value); + + ret = drm_get_tv_mode_from_name(value, delim - value); + if (ret < 0) + return ret; + + mode->tv_mode = ret; + + return 0; +} + static int drm_mode_parse_cmdline_options(const char *str, bool freestanding, const struct drm_connector *connector, @@ -2202,6 +2225,9 @@ static int drm_mode_parse_cmdline_options(const char *str, } else if (!strncmp(option, "panel_orientation", delim - option)) { if (drm_mode_parse_panel_orientation(delim, mode)) return -EINVAL; + } else if (!strncmp(option, "tv_mode", delim - option)) { + if (drm_mode_parse_tv_mode(delim, mode)) + return -EINVAL; } else { return -EINVAL; } @@ -2230,20 +2256,22 @@ struct drm_named_mode { unsigned int xres; unsigned int yres; unsigned int flags; + unsigned int tv_mode; }; -#define NAMED_MODE(_name, _pclk, _x, _y, _flags) \ +#define NAMED_MODE(_name, _pclk, _x, _y, _flags, _mode) \ { \ .name = _name, \ .pixel_clock_khz = _pclk, \ .xres = _x, \ .yres = _y, \ .flags = _flags, \ + .tv_mode = _mode, \ } static const struct drm_named_mode drm_named_modes[] = { - NAMED_MODE("NTSC", 13500, 720, 480, DRM_MODE_FLAG_INTERLACE), - NAMED_MODE("PAL", 13500, 720, 576, DRM_MODE_FLAG_INTERLACE), + NAMED_MODE("NTSC", 13500, 720, 480, DRM_MODE_FLAG_INTERLACE, DRM_MODE_TV_MODE_NTSC), + NAMED_MODE("PAL", 13500, 720, 576, DRM_MODE_FLAG_INTERLACE, DRM_MODE_TV_MODE_PAL), }; static int drm_mode_parse_cmdline_named_mode(const char *name, @@ -2292,6 +2320,7 @@ static int drm_mode_parse_cmdline_named_mode(const char *name, cmdline_mode->xres = mode->xres; cmdline_mode->yres = mode->yres; cmdline_mode->interlace = !!(mode->flags & DRM_MODE_FLAG_INTERLACE); + cmdline_mode->tv_mode = mode->tv_mode; cmdline_mode->specified = true; return 1; diff --git a/drivers/gpu/drm/tests/drm_cmdline_parser_test.c b/drivers/gpu/drm/tests/drm_cmdline_parser_test.c index 09b806e27506..019ff5aa4f8d 100644 --- a/drivers/gpu/drm/tests/drm_cmdline_parser_test.c +++ b/drivers/gpu/drm/tests/drm_cmdline_parser_test.c @@ -927,6 +927,14 @@ static const struct drm_cmdline_invalid_test drm_cmdline_invalid_tests[] = { .name = "invalid_option", .cmdline = "720x480,test=42", }, + { + .name = "invalid_tv_option", + .cmdline = "720x480i,tv_mode=invalid", + }, + { + .name = "truncated_tv_option", + .cmdline = "720x480i,tv_mode=NTS", + }, }; static void drm_cmdline_invalid_desc(const struct drm_cmdline_invalid_test *t, @@ -937,6 +945,64 @@ static void drm_cmdline_invalid_desc(const struct drm_cmdline_invalid_test *t, KUNIT_ARRAY_PARAM(drm_cmdline_invalid, drm_cmdline_invalid_tests, drm_cmdline_invalid_desc); +struct drm_cmdline_tv_option_test { + const char *name; + const char *cmdline; + struct drm_display_mode *(*mode_fn)(struct drm_device *dev); + enum drm_connector_tv_mode tv_mode; +}; + +static void drm_cmdline_test_tv_options(struct kunit *test) +{ + const struct drm_cmdline_tv_option_test *params = test->param_value; + const struct drm_display_mode *expected_mode = params->mode_fn(NULL); + struct drm_cmdline_mode mode = { }; + + KUNIT_EXPECT_TRUE(test, drm_mode_parse_command_line_for_connector(params->cmdline, + &no_connector, &mode)); + KUNIT_EXPECT_TRUE(test, mode.specified); + KUNIT_EXPECT_EQ(test, mode.xres, expected_mode->hdisplay); + KUNIT_EXPECT_EQ(test, mode.yres, expected_mode->vdisplay); + KUNIT_EXPECT_EQ(test, mode.tv_mode, params->tv_mode); + + KUNIT_EXPECT_FALSE(test, mode.refresh_specified); + + KUNIT_EXPECT_FALSE(test, mode.bpp_specified); + + KUNIT_EXPECT_FALSE(test, mode.rb); + KUNIT_EXPECT_FALSE(test, mode.cvt); + KUNIT_EXPECT_EQ(test, mode.interlace, !!(expected_mode->flags & DRM_MODE_FLAG_INTERLACE)); + KUNIT_EXPECT_FALSE(test, mode.margins); + KUNIT_EXPECT_EQ(test, mode.force, DRM_FORCE_UNSPECIFIED); +} + +#define TV_OPT_TEST(_opt, _cmdline, _mode_fn) \ + { \ + .name = #_opt, \ + .cmdline = _cmdline, \ + .mode_fn = _mode_fn, \ + .tv_mode = DRM_MODE_TV_MODE_ ## _opt, \ + } + +static const struct drm_cmdline_tv_option_test drm_cmdline_tv_option_tests[] = { + TV_OPT_TEST(NTSC, "720x480i,tv_mode=NTSC", drm_mode_analog_ntsc_480i), + TV_OPT_TEST(NTSC_443, "720x480i,tv_mode=NTSC-443", drm_mode_analog_ntsc_480i), + TV_OPT_TEST(NTSC_J, "720x480i,tv_mode=NTSC-J", drm_mode_analog_ntsc_480i), + TV_OPT_TEST(PAL, "720x576i,tv_mode=PAL", drm_mode_analog_pal_576i), + TV_OPT_TEST(PAL_M, "720x480i,tv_mode=PAL-M", drm_mode_analog_ntsc_480i), + TV_OPT_TEST(PAL_N, "720x576i,tv_mode=PAL-N", drm_mode_analog_pal_576i), + TV_OPT_TEST(SECAM, "720x576i,tv_mode=SECAM", drm_mode_analog_pal_576i), +}; + +static void drm_cmdline_tv_option_desc(const struct drm_cmdline_tv_option_test *t, + char *desc) +{ + sprintf(desc, "%s", t->name); +} +KUNIT_ARRAY_PARAM(drm_cmdline_tv_option, + drm_cmdline_tv_option_tests, + drm_cmdline_tv_option_desc); + static struct kunit_case drm_cmdline_parser_tests[] = { KUNIT_CASE(drm_cmdline_test_force_d_only), KUNIT_CASE(drm_cmdline_test_force_D_only_dvi), @@ -977,6 +1043,7 @@ static struct kunit_case drm_cmdline_parser_tests[] = { KUNIT_CASE(drm_cmdline_test_freestanding_force_e_and_options), KUNIT_CASE(drm_cmdline_test_panel_orientation), KUNIT_CASE_PARAM(drm_cmdline_test_invalid, drm_cmdline_invalid_gen_params), + KUNIT_CASE_PARAM(drm_cmdline_test_tv_options, drm_cmdline_tv_option_gen_params), {} }; diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index 0dcd08e036b6..a8f7b2fdde87 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -1374,6 +1374,11 @@ struct drm_cmdline_mode { * @tv_margins: TV margins to apply to the mode. */ struct drm_connector_tv_margins tv_margins; + + /** + * @tv_mode: TV mode standard. See DRM_MODE_TV_MODE_*. + */ + enum drm_connector_tv_mode tv_mode; }; /** From patchwork Thu Sep 22 14:25:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985277 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 0A695C54EE9 for ; Thu, 22 Sep 2022 14:28:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8677610EB9D; Thu, 22 Sep 2022 14:28:39 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 757E510EB9D; Thu, 22 Sep 2022 14:28:29 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 377482B05B3B; Thu, 22 Sep 2022 10:28:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 22 Sep 2022 10:28:28 -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=1663856905; x= 1663864105; bh=nFUBBQXflU8J6ixItCmaiRTWQEmTpTCoJHkDAXVsBYk=; b=P 8s0g/yl4Ftd/fdWYnFJu5vcjkwDba2tGeDdWpqt389adiz9Pd3IAi3z6JKCViBT5 jStPZSv98OydxV5g4I7rxzUqXhFQ1ZETJ9u0vD566cYO8qKXcP/pAMdFB+hZf4uU ZwF0FosqxnChKNwhn5J0DJAKHE/jy1vISDCIuTeTlQjGG/UUZ4uz0OUCw9CfAn37 OkyxlDIZcnqcRQB54g4iccysIiyYQxik8keKUJJJlmcmb4AGXkyv8Fh3YvaObmqR P0abgj5pCSiyXDfe26S0/cUyQN30xVRfsPz7J7WKhX/1LOeMUjBB9vUQ2q7Wr0cb sL9ZPwz0GrBTfIW8uniDg== 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=fm2; t=1663856905; x= 1663864105; bh=nFUBBQXflU8J6ixItCmaiRTWQEmTpTCoJHkDAXVsBYk=; b=L 3XWW4gVj9HUJuZurwoaHXERsAuSfyJjMdTlmXafk81kjB0fZDnrbyFU5wY7JTcZg BtIpYAsbdI8g8cWqrP3IC+PNnI+nAR7uLZvJ1cehRSCEitSRoeE6TSQ1GTswV3AM yffZe+hyPJKizKx5LZ8cEMES1hQyirD3L7Q32OacFmzR6Dz6Nbl7iDzeZEjFP/YL NnJmCYKTkPthpQ/iNqY8M5Rrom+RZZ88tl6MVDfI4XGIAQrH/eomXQUIL54qLVHO 3kPPEstNfwnb1GAtz78hFh7WpcLFQf121ytdNu0IR+6FrD/26EnL40/OxO1tCWWn q5DO9ALmQISSW7eUz17/g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:28:24 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:41 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-24-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5398; i=maxime@cerno.tech; h=from:subject:message-id; bh=yrTJCblgIpfboz4+orB0xCTcSSAc3mD9ot6I29tGSEQ=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYGfJrtnJ4jfktHqixVzZ1a4U5Yq3XgvTYFT5iGnV8ky xTsdpSwMYlwMsmKKLDHC5kviTs163cnGNw9mDisTyBAGLk4BmMjUpwz/9EyFD3kLFaVfPBlZ+FXjYc 1Z58mSSV/ahFmjAj0uzpA8yfCb5fVryf8/HD7faZeQXnQkcMXrh4duWWYqa2m7622rMbvOCgA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 24/33] drm/modes: Properly generate a drm_display_mode from a named mode X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The framework will get the drm_display_mode from the drm_cmdline_mode it got by parsing the video command line argument by calling drm_connector_pick_cmdline_mode(). The heavy lifting will then be done by the drm_mode_create_from_cmdline_mode() function. In the case of the named modes though, there's no real code to make that translation and we rely on the drivers to guess which actual display mode we meant. Let's modify drm_mode_create_from_cmdline_mode() to properly generate the drm_display_mode we mean when passing a named mode. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 23e665fd808e..1ca1f82dfd12 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2500,6 +2500,36 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option, } EXPORT_SYMBOL(drm_mode_parse_command_line_for_connector); +static struct drm_display_mode *drm_named_mode(struct drm_device *dev, + struct drm_cmdline_mode *cmd) +{ + struct drm_display_mode *mode; + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(drm_named_modes); i++) { + const struct drm_named_mode *named_mode = &drm_named_modes[i]; + + if (strcmp(cmd->name, named_mode->name)) + continue; + + if (!named_mode->tv_mode) + continue; + + mode = drm_analog_tv_mode(dev, + named_mode->tv_mode, + named_mode->pixel_clock_khz * 1000, + named_mode->xres, + named_mode->yres, + named_mode->flags & DRM_MODE_FLAG_INTERLACE); + if (!mode) + return NULL; + + return mode; + } + + return NULL; +} + /** * drm_mode_create_from_cmdline_mode - convert a command line modeline into a DRM display mode * @dev: DRM device to create the new mode for @@ -2517,7 +2547,9 @@ drm_mode_create_from_cmdline_mode(struct drm_device *dev, if (cmd->xres == 0 || cmd->yres == 0) return NULL; - if (cmd->cvt) + if (strlen(cmd->name)) + mode = drm_named_mode(dev, cmd); + else if (cmd->cvt) mode = drm_cvt_mode(dev, cmd->xres, cmd->yres, cmd->refresh_specified ? cmd->refresh : 60, diff --git a/drivers/gpu/drm/tests/drm_client_modeset_test.c b/drivers/gpu/drm/tests/drm_client_modeset_test.c index 46335de7bc6b..4380cf670fb4 100644 --- a/drivers/gpu/drm/tests/drm_client_modeset_test.c +++ b/drivers/gpu/drm/tests/drm_client_modeset_test.c @@ -26,6 +26,20 @@ static int drm_client_modeset_connector_get_modes(struct drm_connector *connecto count = drm_add_modes_noedid(connector, 1920, 1200); + mode = drm_mode_analog_ntsc_480i(connector->dev); + if (!mode) + return -ENOMEM; + + drm_mode_probed_add(connector, mode); + count += 1; + + mode = drm_mode_analog_pal_576i(connector->dev); + if (!mode) + return -ENOMEM; + + drm_mode_probed_add(connector, mode); + count += 1; + return count; } @@ -58,6 +72,9 @@ static int drm_client_modeset_test_init(struct kunit *test) return ret; drm_connector_helper_add(&priv->connector, &drm_client_modeset_connector_helper_funcs); + priv->connector.interlace_allowed = true; + priv->connector.doublescan_allowed = true; + return 0; } @@ -97,8 +114,62 @@ static void drm_pick_cmdline_res_1920_1080_60(struct kunit *test) KUNIT_EXPECT_TRUE(test, drm_mode_equal(expected_mode, mode)); } +static void drm_pick_cmdline_named_ntsc(struct kunit *test) +{ + struct drm_client_modeset_test_priv *priv = test->priv; + struct drm_device *drm = priv->drm; + struct drm_connector *connector = &priv->connector; + struct drm_cmdline_mode *cmdline_mode = &connector->cmdline_mode; + struct drm_display_mode *mode; + const char *cmdline = "NTSC"; + int ret; + + KUNIT_ASSERT_TRUE(test, + drm_mode_parse_command_line_for_connector(cmdline, + connector, + cmdline_mode)); + + mutex_lock(&drm->mode_config.mutex); + ret = drm_helper_probe_single_connector_modes(connector, 1920, 1080); + mutex_unlock(&drm->mode_config.mutex); + KUNIT_ASSERT_GT(test, ret, 0); + + mode = drm_connector_pick_cmdline_mode(connector); + KUNIT_ASSERT_PTR_NE(test, mode, NULL); + + KUNIT_EXPECT_TRUE(test, drm_mode_equal(drm_mode_analog_ntsc_480i(drm), mode)); +} + +static void drm_pick_cmdline_named_pal(struct kunit *test) +{ + struct drm_client_modeset_test_priv *priv = test->priv; + struct drm_device *drm = priv->drm; + struct drm_connector *connector = &priv->connector; + struct drm_cmdline_mode *cmdline_mode = &connector->cmdline_mode; + struct drm_display_mode *mode; + const char *cmdline = "PAL"; + int ret; + + KUNIT_ASSERT_TRUE(test, + drm_mode_parse_command_line_for_connector(cmdline, + connector, + cmdline_mode)); + + mutex_lock(&drm->mode_config.mutex); + ret = drm_helper_probe_single_connector_modes(connector, 1920, 1080); + mutex_unlock(&drm->mode_config.mutex); + KUNIT_ASSERT_GT(test, ret, 0); + + mode = drm_connector_pick_cmdline_mode(connector); + KUNIT_ASSERT_PTR_NE(test, mode, NULL); + + KUNIT_EXPECT_TRUE(test, drm_mode_equal(drm_mode_analog_pal_576i(drm), mode)); +} + static struct kunit_case drm_pick_cmdline_tests[] = { KUNIT_CASE(drm_pick_cmdline_res_1920_1080_60), + KUNIT_CASE(drm_pick_cmdline_named_ntsc), + KUNIT_CASE(drm_pick_cmdline_named_pal), {} }; From patchwork Thu Sep 22 14:25:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985280 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 898E8C54EE9 for ; Thu, 22 Sep 2022 14:28:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 91D5210EBA6; Thu, 22 Sep 2022 14:28:45 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id A9AAE10EBA5; Thu, 22 Sep 2022 14:28:36 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.west.internal (Postfix) with ESMTP id 6A2312B05B39; Thu, 22 Sep 2022 10:28:33 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 22 Sep 2022 10:28:36 -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=1663856912; x= 1663864112; bh=VGkHjiQhMRMCyVL2ijEh5S+Moy8bI1ArbHDDZMqvbZY=; b=3 HZfX0k4mXhlZJWQoKk7Bw1VeMc3Enk8nYjuICm6K0p0REO5t03A3VAr8Src+rkhp xmafeBya43sbbPqA3hCR6zw000FmK13d3KS1ujAgAwSlNG5Gsozd4UQoPJ4gBNTl WyC23mZCKua9rM5najnrq0fRj1skavyvDZXx4gvXTsslJZUxWx8jSgXlCqzPC+Hy 4tFqaFB8CBKUfhrFnJ/MBHhMvG3EsOBQelVxpg4jo+ZttJfaWnhO0knyEQKuSDuF U4kfWL3f/lwNnarOAPOJBZLpMjQRqmzSOS90L9vcKmENacmGvtDUYcGKeraeuFKQ 0YXth2NyMEogF5DyQcQdw== 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=fm2; t=1663856912; x= 1663864112; bh=VGkHjiQhMRMCyVL2ijEh5S+Moy8bI1ArbHDDZMqvbZY=; b=k mq4h+C1uVj0SWnT+1QEIb11wpQnn1KA8Mal96p/kZJx3vu93wdai7XnhFFIchg2e CcZpkQRniLD8V84/+McZ/f3LXFXIRMEnWtrA4L5ZCWCuH4vAc3uRc9xhW4Kuxn7O 88YUi+3XuZ4iXBFFfBAYkYMr4AvLEJ7H54DVO6XSFVPRRURbYHsZtsB4m3XZSCFN 3NE8eBfym/1zM1gEreP9hz9j70/I2WmXk3i1htOM1zLduMAvlsEbgst06rhVe9+B YvcJzE8+7hLtZqdvVURajUptjKrNRS9rLdepQvYHmT3Qs6DnX59Tguu8PP6xo2bW aUAYJaMZYN8zMWWwDpoXg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:28:31 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:42 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-25-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3786; i=maxime@cerno.tech; h=from:subject:message-id; bh=NRfar4ttIL47tq1ByN+4ob7iKyuG0IhiwfgL1fWLpPE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYH50T99F6+68zFn6YmTH2a2GGhH6BacnVd/WJTJwk1D +oh/RykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACZSVcbwT3+S9LdX758evpaXk9X/hi XgTbSKbPqOkOlFh2OWn75gycTI8OZpWr3KCVOZJoezf/Tn3V+9rGHfHbmuox9UPvxJOrvsJgcA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 25/33] drm/modes: Introduce more named modes X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Now that we can easily extend the named modes list, let's add a few more analog TV modes that were used in the wild, and some unit tests to make sure it works as intended. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c index 1ca1f82dfd12..6f315385bd02 100644 --- a/drivers/gpu/drm/drm_modes.c +++ b/drivers/gpu/drm/drm_modes.c @@ -2271,7 +2271,9 @@ struct drm_named_mode { static const struct drm_named_mode drm_named_modes[] = { NAMED_MODE("NTSC", 13500, 720, 480, DRM_MODE_FLAG_INTERLACE, DRM_MODE_TV_MODE_NTSC), + NAMED_MODE("NTSC-J", 13500, 720, 480, DRM_MODE_FLAG_INTERLACE, DRM_MODE_TV_MODE_NTSC_J), NAMED_MODE("PAL", 13500, 720, 576, DRM_MODE_FLAG_INTERLACE, DRM_MODE_TV_MODE_PAL), + NAMED_MODE("PAL-M", 13500, 720, 480, DRM_MODE_FLAG_INTERLACE, DRM_MODE_TV_MODE_PAL_M), }; static int drm_mode_parse_cmdline_named_mode(const char *name, diff --git a/drivers/gpu/drm/tests/drm_client_modeset_test.c b/drivers/gpu/drm/tests/drm_client_modeset_test.c index 4380cf670fb4..521505753af9 100644 --- a/drivers/gpu/drm/tests/drm_client_modeset_test.c +++ b/drivers/gpu/drm/tests/drm_client_modeset_test.c @@ -140,6 +140,32 @@ static void drm_pick_cmdline_named_ntsc(struct kunit *test) KUNIT_EXPECT_TRUE(test, drm_mode_equal(drm_mode_analog_ntsc_480i(drm), mode)); } +static void drm_pick_cmdline_named_ntsc_j(struct kunit *test) +{ + struct drm_client_modeset_test_priv *priv = test->priv; + struct drm_device *drm = priv->drm; + struct drm_connector *connector = &priv->connector; + struct drm_cmdline_mode *cmdline_mode = &connector->cmdline_mode; + struct drm_display_mode *mode; + const char *cmdline = "NTSC-J"; + int ret; + + KUNIT_ASSERT_TRUE(test, + drm_mode_parse_command_line_for_connector(cmdline, + connector, + cmdline_mode)); + + mutex_lock(&drm->mode_config.mutex); + ret = drm_helper_probe_single_connector_modes(connector, 1920, 1080); + mutex_unlock(&drm->mode_config.mutex); + KUNIT_ASSERT_GT(test, ret, 0); + + mode = drm_connector_pick_cmdline_mode(connector); + KUNIT_ASSERT_PTR_NE(test, mode, NULL); + + KUNIT_EXPECT_TRUE(test, drm_mode_equal(drm_mode_analog_ntsc_480i(drm), mode)); +} + static void drm_pick_cmdline_named_pal(struct kunit *test) { struct drm_client_modeset_test_priv *priv = test->priv; @@ -166,10 +192,38 @@ static void drm_pick_cmdline_named_pal(struct kunit *test) KUNIT_EXPECT_TRUE(test, drm_mode_equal(drm_mode_analog_pal_576i(drm), mode)); } +static void drm_pick_cmdline_named_pal_m(struct kunit *test) +{ + struct drm_client_modeset_test_priv *priv = test->priv; + struct drm_device *drm = priv->drm; + struct drm_connector *connector = &priv->connector; + struct drm_cmdline_mode *cmdline_mode = &connector->cmdline_mode; + struct drm_display_mode *mode; + const char *cmdline = "PAL-M"; + int ret; + + KUNIT_ASSERT_TRUE(test, + drm_mode_parse_command_line_for_connector(cmdline, + connector, + cmdline_mode)); + + mutex_lock(&drm->mode_config.mutex); + ret = drm_helper_probe_single_connector_modes(connector, 1920, 1080); + mutex_unlock(&drm->mode_config.mutex); + KUNIT_ASSERT_GT(test, ret, 0); + + mode = drm_connector_pick_cmdline_mode(connector); + KUNIT_ASSERT_PTR_NE(test, mode, NULL); + + KUNIT_EXPECT_TRUE(test, drm_mode_equal(drm_mode_analog_ntsc_480i(drm), mode)); +} + static struct kunit_case drm_pick_cmdline_tests[] = { KUNIT_CASE(drm_pick_cmdline_res_1920_1080_60), KUNIT_CASE(drm_pick_cmdline_named_ntsc), + KUNIT_CASE(drm_pick_cmdline_named_ntsc_j), KUNIT_CASE(drm_pick_cmdline_named_pal), + KUNIT_CASE(drm_pick_cmdline_named_pal_m), {} }; From patchwork Thu Sep 22 14:25:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985281 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 14190C6FA91 for ; Thu, 22 Sep 2022 14:28:51 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8BBEC10EB7A; Thu, 22 Sep 2022 14:28:49 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 37C2B10EBA9; Thu, 22 Sep 2022 14:28:45 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id 571492B05B3C; Thu, 22 Sep 2022 10:28:41 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 22 Sep 2022 10:28:44 -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=1663856920; x= 1663864120; bh=U+kzfhAo//WtOXcUfFEucxsRHnjvV7GaIvI1DudP6HQ=; b=D 4iEtEue+ybuQ8vogDqY21P9SfgTk8a4yk2hbgMqnA42/McL33aPoHLrjQTjnJS7h DXwobMUz9TiWPJIIbqA6oWMTAAhpKt26MFDYDJIlDgL+Fpr/VlN/nAZq80+dZMF3 K0IzYmBoIscI2WlMsZnog0LZScHMV2D/1siOlfL+5Re1gVQVCB7IvT8I5bjlWv0X BC69g+Hmatf9Gfjbz6q0HQDuOYbl9L8eAMGrWZSf9vINBvOwhjurtOC82579fQbW blCmAQahiFBPsqbeHzhG++V511DiDRbJHst89MDR9HIi64xcaoxQDJJKiZ5cz9K4 /a87zoQpGnI23Q8Lq+oYg== 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=fm2; t=1663856920; x= 1663864120; bh=U+kzfhAo//WtOXcUfFEucxsRHnjvV7GaIvI1DudP6HQ=; b=J Oo1wqE/ZugoKyeE6j81uZ0jH+LS3Pa6XDkOmS96s8USWDJ/w7rmi8zBJqJsAxarX 4myndEpqT9kee+jvvhxy5p+Lvl1telGy1L02luGhErNvQ/4wo0PPfH0TJkUrRt6P JwQrArMB/fLtW0snIavz8mBklhxCnn2AH//5/U2F/RPOAAg14ia1Cj5q+258y5pb gMygqdKhLdieWm6uYHG4r83bU2ZrSsP3l/3U9VfytiRXxdydwomhDjIwhHn10nw7 /hQaRMz3F2f1ISFbU9k5g2fY28PCTP5xmTC4Fm3m2Goqe+RecimxWar+NycPxUp1 tBHXxZvEGQaGZHd5kOK2w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufgggfgtkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvdfgveejhfdtteevvefhleeiueeutefgvdegveekgedujeffgeffgfet tdellefhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:28:39 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:43 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-26-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4090; i=maxime@cerno.tech; h=from:subject:message-id; bh=Qn9tXXejtzVlILpWn1CiUIZt886SF4nFCM9aMutkhW4=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYFbLF7W2S08Lb16nf6R7U7lDlMvTJzAJeBwZ2qrVMD/ LH/ZjlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAEzE+Rsjw6fXbaJmb5u7N2cZn7i3Xm mn6Sd+i1WfYiTFyqr/fHvwvYXhn6najmozt8c6CddEF+Xeq5zMaqyi9eLDPfl7PmlrI7zi2AE= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 26/33] drm/atomic-helper: Add a TV properties reset helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The drm_tv_create_properties() function will create a bunch of properties, but it's up to each and every driver using that function to properly reset the state of these properties leading to inconsistent behaviours. Let's create a helper that will take care of it. Reviewed-by: Noralf Trønnes 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 dfb57217253b..0373c3dc824b 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -481,6 +481,81 @@ void drm_atomic_helper_connector_tv_margins_reset(struct drm_connector *connecto } EXPORT_SYMBOL(drm_atomic_helper_connector_tv_margins_reset); +/** + * drm_atomic_helper_connector_tv_reset - Resets Analog TV connector properties + * @connector: DRM connector + * + * Resets the analog TV properties attached to a connector + */ +void drm_atomic_helper_connector_tv_reset(struct drm_connector *connector) +{ + struct drm_device *dev = connector->dev; + struct drm_cmdline_mode *cmdline = &connector->cmdline_mode; + struct drm_connector_state *state = connector->state; + struct drm_property *prop; + uint64_t val; + + prop = dev->mode_config.tv_mode_property; + if (prop) + if (!drm_object_property_get_default_value(&connector->base, + prop, &val)) + state->tv.mode = val; + + if (cmdline->tv_mode) + state->tv.mode = cmdline->tv_mode; + + prop = dev->mode_config.tv_select_subconnector_property; + if (prop) + if (!drm_object_property_get_default_value(&connector->base, + prop, &val)) + state->tv.select_subconnector = val; + + prop = dev->mode_config.tv_subconnector_property; + if (prop) + if (!drm_object_property_get_default_value(&connector->base, + prop, &val)) + state->tv.subconnector = val; + + prop = dev->mode_config.tv_brightness_property; + if (prop) + if (!drm_object_property_get_default_value(&connector->base, + prop, &val)) + state->tv.brightness = val; + + prop = dev->mode_config.tv_contrast_property; + if (prop) + if (!drm_object_property_get_default_value(&connector->base, + prop, &val)) + state->tv.contrast = val; + + prop = dev->mode_config.tv_flicker_reduction_property; + if (prop) + if (!drm_object_property_get_default_value(&connector->base, + prop, &val)) + state->tv.flicker_reduction = val; + + prop = dev->mode_config.tv_overscan_property; + if (prop) + if (!drm_object_property_get_default_value(&connector->base, + prop, &val)) + state->tv.overscan = val; + + prop = dev->mode_config.tv_saturation_property; + if (prop) + if (!drm_object_property_get_default_value(&connector->base, + prop, &val)) + state->tv.saturation = val; + + prop = dev->mode_config.tv_hue_property; + if (prop) + if (!drm_object_property_get_default_value(&connector->base, + prop, &val)) + state->tv.hue = val; + + drm_atomic_helper_connector_tv_margins_reset(connector); +} +EXPORT_SYMBOL(drm_atomic_helper_connector_tv_reset); + /** * __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 192766656b88..c8fbce795ee7 100644 --- a/include/drm/drm_atomic_state_helper.h +++ b/include/drm/drm_atomic_state_helper.h @@ -70,6 +70,7 @@ void __drm_atomic_helper_connector_state_reset(struct drm_connector_state *conn_ 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); void drm_atomic_helper_connector_tv_margins_reset(struct drm_connector *connector); void __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector, From patchwork Thu Sep 22 14:25:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985282 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 DC710C54EE9 for ; Thu, 22 Sep 2022 14:29:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7C6B210EBB5; Thu, 22 Sep 2022 14:29:00 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B6A010EBA9; Thu, 22 Sep 2022 14:28:52 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id D77C82B05B3E; Thu, 22 Sep 2022 10:28:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Thu, 22 Sep 2022 10:28:51 -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=1663856928; x= 1663864128; bh=ogjeYUFL0YoRp6V9VOpBbN1JAiQ0qMitMDmrK3iZ98s=; b=F BcLS4oONe8Yh5bh1TMZZhEo/U31pDjH1KgFIimNE0E44ZpN5ycqdvVbEaWWiAm9F 9OIZy9h4RC3v1lKF6XwdBL2VMjc5xfi11jmkCLznU76SpTEXfZb/E6+Z1P0JMgur B9SrYLlToTru5a/M2DIWD5YTP9iF6+T904Dc/CF1w0+myVFMjQeWNfpc+IfPoFCK Hs6YJuuWTyYTEw7oYMF+SAgXdyBqlv9gNdJIR5uGSrBzuTrxu5WPFQYZdOfzgqF5 3Hf+IXdRGtyWVPbHp3VCb/b+rbCxkAtdlsUUNBrebdU6U3Z0pJ+JnerdNsQqY9UI drEvhHNq83THPMxMpuX5w== 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=fm2; t=1663856928; x= 1663864128; bh=ogjeYUFL0YoRp6V9VOpBbN1JAiQ0qMitMDmrK3iZ98s=; b=Q 9/8AtBHBs+JJp1UztMCf47Vt3F5Ky24yoV/KPZVrwoGvGZotBXSBEKPwc1EXEmiF WPw7yOJqFI/sbii/FZAbS0k3wPDJZe24U1RxwrtTrWVRPu5ujuIRQonxiLoKjGvS MK2f2IO2UjyJY0qK5ydJgj2+rwTXzUdAl8TAu8GXUymPfep0riuC719kb2hJD2Rm 9+TP/kOSGAL8Y4mjt2TWZrdseuNeAdj/3FfIuHau1vMg3b7f43hLjZ3718glQcAj 8ftUHnjNd/Z28IeDx3ie0rlUO1DcA5Rum44pkOTXMuG8PJZstQFeR9IgP4YdYHdw Iia4zaRcVddl9+m14kvhw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufgggfgtkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepveejudekteevveefhffhudefkedtgfettefgieejtdffieffheeuhedt heeikeeunecuffhomhgrihhnpehmrghrghhinhhsrdhtohhpnecuvehluhhsthgvrhfuih iivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmhgrgihimhgvsegtvghrnhhordht vggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:28:47 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:44 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-27-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3787; i=maxime@cerno.tech; h=from:subject:message-id; bh=9B5kZ9Vae724vHkCgt1Nv7aYWLsRgxrNi0AjSiKs5Ys=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYFNfbe//NzD8yJ5Wt6z9TPLVirvmhO3/VNr0KUwjh6X RaYGHaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZiI/AVGhn+zHbxYE3dfy+j39VweY8 sxL6A6XC/WJzOvfuIybuWvYQz/LIRCQy/8tHmdVXTCbkXQEz2l/h2zNsWEzwqVrbV5VnWAEwA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 27/33] drm/atomic-helper: Add an analog TV atomic_check implementation X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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. Reviewed-by: Noralf Trønnes 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 0373c3dc824b..e88c57a4f7be 100644 --- a/drivers/gpu/drm/drm_atomic_state_helper.c +++ b/drivers/gpu/drm/drm_atomic_state_helper.c @@ -556,6 +556,55 @@ 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; + + if ((old_conn_state->tv.margins.left != new_conn_state->tv.margins.left) || + (old_conn_state->tv.margins.right != new_conn_state->tv.margins.right) || + (old_conn_state->tv.margins.top != new_conn_state->tv.margins.top) || + (old_conn_state->tv.margins.bottom != new_conn_state->tv.margins.bottom) || + (old_conn_state->tv.mode != new_conn_state->tv.mode) || + (old_conn_state->tv.brightness != new_conn_state->tv.brightness) || + (old_conn_state->tv.contrast != new_conn_state->tv.contrast) || + (old_conn_state->tv.flicker_reduction != new_conn_state->tv.flicker_reduction) || + (old_conn_state->tv.overscan != new_conn_state->tv.overscan) || + (old_conn_state->tv.saturation != new_conn_state->tv.saturation) || + (old_conn_state->tv.hue != new_conn_state->tv.hue)) + crtc_state->connectors_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, From patchwork Thu Sep 22 14:25:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985285 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 68D5AC54EE9 for ; Thu, 22 Sep 2022 14:29:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3B86B10EBB9; Thu, 22 Sep 2022 14:29:28 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0757310EBB3; Thu, 22 Sep 2022 14:29:00 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id B68412B05B3D; Thu, 22 Sep 2022 10:28:56 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 22 Sep 2022 10:28:59 -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=1663856936; x= 1663864136; bh=7r0O9WFHJ9KQW1LRwe1RDVRyeEourmjpwkBZsM8ZBBU=; b=E vsd6BIVLFkzyZONidpAGSbu/i2yx1JG8lzZV34I3XuQR+xJVqIn4TEFOKM8XFg4C YfttrRnKCWqCytZHENgy+0Ecg9L9Sw27BZmj4gxlVPYE/f0iYXagqPv/YtPWwcvG gndJoHvSebyOfUIz9aliqSb1Jv+KH0s6SFg03hZ3NE++TKSMGgcQ2qvYP+M0aSZ9 P2w3EYYpkoW921IWqp4OENdEd5YckZr4INj4iFDAIe2GiyJCikQGIAI4OeD0xPPv pvq97AO3efnpxwfWAAshlAdodvVG9lbzxctacc8/sBK911FQdOh8t1VfLuYYmqs1 IdbJ7HyVC3ey61jX3qhQQ== 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=fm2; t=1663856936; x= 1663864136; bh=7r0O9WFHJ9KQW1LRwe1RDVRyeEourmjpwkBZsM8ZBBU=; b=E uSar2PBuxpMaada8bJj2qq3I5BRMK//Z911iFmEEQqIGk3PmCubRxSQozK9qqQMV My9VDuZ5ZpTOSQS0C7EMW8EE0a96igY2B0udidH+AIa4EVP4HlK4Mw+8qegBg2DL jMNJ+MMClDsjtEB3vBhJl57PGSeUN6eclnzktDnEiuOoPQF8O0Jsf7YQRd9tJfWG qvhN797j3tjonluTVX0JiTyc/TqyxHZ/REeX/nhKWdRjj7nCYJu/eY9GipRbU5TC GGecKyMkp8T+sMsZ4kNFMmjHQCQS55ni5840QUo5/qUxYH6QaGmtNE6G7Q5Deft+ pRafKtLVCwhtOb0uQy5OQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:28:54 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:45 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-28-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1277; i=maxime@cerno.tech; h=from:subject:message-id; bh=KhLuPV03zkkjEr/AzfTwW/zS/7K13ZQtaRxwyBOIOHw=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYETjrQZqVeeu8DLONFkwZ9netqGi172vGtpn7bF77Xj yRfyHaUsDGJcDLJiiiwxwuZL4k7Net3JxjcPZg4rE8gQBi5OAZhI/GZGhnUmMovNL09dcIjvWqGh9/ LPmmeuXLp+5uzCvcqMrzeVRu9lZPh51HPJ6kPnuSM26+4Nzp38ql7TbvaZl4t2H6yRe/ozsJQZAA== X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 28/33] drm/vc4: vec: Fix definition of PAL-M mode X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Mateusz Kwiatkowski PAL-M is a Brazilian analog TV standard that uses a PAL-style chroma subcarrier at 3.575611[888111] MHz on top of 525-line (480i60) timings. This commit makes the driver actually use the proper VEC preset for this mode instead of just changing PAL subcarrier frequency. Signed-off-by: Mateusz Kwiatkowski Signed-off-by: Maxime Ripard Acked-by: Noralf Trønnes diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index f31fef938f11..5ec3a12359b1 100644 --- a/drivers/gpu/drm/vc4/vc4_vec.c +++ b/drivers/gpu/drm/vc4/vc4_vec.c @@ -69,6 +69,7 @@ #define VEC_CONFIG0_STD_MASK GENMASK(1, 0) #define VEC_CONFIG0_NTSC_STD 0 #define VEC_CONFIG0_PAL_BDGHI_STD 1 +#define VEC_CONFIG0_PAL_M_STD 2 #define VEC_CONFIG0_PAL_N_STD 3 #define VEC_SCHPH 0x108 @@ -255,10 +256,9 @@ static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = { .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, [VC4_VEC_TV_MODE_PAL_M] = { - .mode = &pal_mode, - .config0 = VEC_CONFIG0_PAL_BDGHI_STD, - .config1 = VEC_CONFIG1_C_CVBS_CVBS | VEC_CONFIG1_CUSTOM_FREQ, - .custom_freq = 0x223b61d1, + .mode = &ntsc_mode, + .config0 = VEC_CONFIG0_PAL_M_STD, + .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, }; From patchwork Thu Sep 22 14:25:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985284 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 EB7A1C6FA82 for ; Thu, 22 Sep 2022 14:29:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5365510EBBB; Thu, 22 Sep 2022 14:29:25 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 82F7710EBB4; Thu, 22 Sep 2022 14:29:07 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id ECF1E2B05B41; Thu, 22 Sep 2022 10:29:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 22 Sep 2022 10:29:06 -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=1663856943; x= 1663864143; bh=bqaynxS1Oq35hJTEKdYTdlLLZ2nj+HwILv/fqb4eFcY=; b=E Xm4TD96uPEjvzbl9Bgo3jchOSzniLjv6WvVeKzNq+KrHSj0x7Fb4Rfu4R5jp+rBZ FUCp6mwTIfBHtfzXoNBoVL70QwViadGBaYY1BxbbmpOZSzcLYUAYkWNQF9gVQ2nO 0AWQmES9MybuTGvLxvsIX0PYdJiKEhIHUb2i0XehbOg2WwYYdNJLuSLjaDULzi6Z wQpcJvTUyxZ98V7lL5s6Dj+G08wVszEpkJv9k7cBhJjroNccdhwQgF2FtyvMG62B XZrkeMKImhq1QF+44Ra4xUbdvokScPEv8Q/gcdLWQNOGaUdpdGQPNIZAalhd9/xA +nGFpwGiQqvRkTpQjUl9g== 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=fm2; t=1663856943; x= 1663864143; bh=bqaynxS1Oq35hJTEKdYTdlLLZ2nj+HwILv/fqb4eFcY=; b=0 0mgSIZbPbgSgkmov/dQnkPbwt6QNMOnLlMNUPzoO/cXpvidbl1vmtnMt2E7lKEFM gsbooqz/C+HmsaXeG9DshL+GHSGFQ3Spa2N02rAqb2qVE9qws5Mp+aowiBtIB+Ei mTRc0+sWxsR2wFon6gGSKfnXqmZPcEcHqwQaMUvVxTJI1uKbC88KF8fGcBFn36Xv aYdb+qkmYYXy1KpBPuMuNiDHFeUXWjYI9nNwFIBqIVP2SpsexIqrxQaM8QY6xsHt E838+OF3obmFoh0Np3drZJeOpL4Bvy4w2tJhb5jcIsyJZ3Sm2SkaYLWR9qo6XAwq 5678YXV37iBaV6ul2qCKw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufgggfgtkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepvdfgveejhfdtteevvefhleeiueeutefgvdegveekgedujeffgeffgfet tdellefhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:29:01 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:46 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-29-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1454; i=maxime@cerno.tech; h=from:subject:message-id; bh=B5ugvjxaRYF46qAXVJXIzpYiW47aK3hZcW0sYJuF1G8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYFHVy4w1tki+Sy67+cb0RrLWX9UhVW/l7s+O3UhOksk L/dKRykLgxgXg6yYIkuMsPmSuFOzXney8c2DmcPKBDKEgYtTACZyvYXhf/JvF6s4Eb4drya/nTvl7B PrBn25bYdq1GrTn7lzBTFtmsPwT5Fvupb942dP2pn1Rb97Mb5s7Q6NrQ6LV58XHarx9VMPDwA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 29/33] drm/vc4: vec: Use TV Reset implementation X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The analog TV properties created by the drm_mode_create_tv_properties() are not properly initialised at reset. Let's switch our implementation to call drm_atomic_helper_connector_tv_reset(). Reviewed-by: Noralf Trønnes Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index 5ec3a12359b1..baa29067a1ff 100644 --- a/drivers/gpu/drm/vc4/vc4_vec.c +++ b/drivers/gpu/drm/vc4/vc4_vec.c @@ -268,6 +268,12 @@ vc4_vec_connector_detect(struct drm_connector *connector, bool force) return connector_status_unknown; } +static void vc4_vec_connector_reset(struct drm_connector *connector) +{ + drm_atomic_helper_connector_reset(connector); + drm_atomic_helper_connector_tv_reset(connector); +} + static int vc4_vec_connector_get_modes(struct drm_connector *connector) { struct drm_connector_state *state = connector->state; @@ -288,7 +294,7 @@ static int vc4_vec_connector_get_modes(struct drm_connector *connector) static const struct drm_connector_funcs vc4_vec_connector_funcs = { .detect = vc4_vec_connector_detect, .fill_modes = drm_helper_probe_single_connector_modes, - .reset = drm_atomic_helper_connector_reset, + .reset = vc4_vec_connector_reset, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; From patchwork Thu Sep 22 14:25:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985283 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 D3CDCC54EE9 for ; Thu, 22 Sep 2022 14:29:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ECB3410EBB7; Thu, 22 Sep 2022 14:29:24 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9FC1D10EBB7; Thu, 22 Sep 2022 14:29:15 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id 60AD92B05B42; Thu, 22 Sep 2022 10:29:11 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 22 Sep 2022 10:29:15 -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=1663856951; x= 1663864151; bh=a0B4b9odzBRPdDXC/syLESeWmwxTaesfuTcxlPyeaA8=; b=H NNzoj7vbwIrsMBcGQ0ZQohcqX0m7r97HkxhS1vOYTk/LBCwo3zh743FTDT1HaP5n yIETIMw0x6XLUMy+HwKuH0hXugA3mxCZEXU4piZt418UsQsyBJyjj1wAkEuzRpc9 vAvoqEJHhYjbwWq1HCOXQQXf0Hn+UaHAhQXz3eC+CPLyKDBII6Fkwuqeel1lBuQQ vEpYsr9LwkrVtxU5zKcEUztjzzdhKucUUvHKnPBktmyXHZjzWl+mFsrdV8e1/fdb 9XBkuytVMUNwHQe7K0xYF73YMn6hzWdrxHPnB9xGGmryWWaLYiMkZZU6XA3x07jd syRKfITbibn7tmkUyMUyA== 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=fm2; t=1663856951; x= 1663864151; bh=a0B4b9odzBRPdDXC/syLESeWmwxTaesfuTcxlPyeaA8=; b=N Uk/pIXQJQu0ZaZiqlSTOcp/OvjRwP6BPO0TlamPPOCY6VTS79tzeuWJHuzjcqhGC +rL96q5Unn6UYKIhpANUsNQFAGd6H7aKsYuFbwo/M3+LTP4ZJicjfQwFIBGh2QRy WOUBIyn7qA+gLwv6j/330k6yM/ypLB4jSuaC8bj5MPB5MC2Sm6RPxZbSmpJS7KuL IaXDsH9Om35pmfgXWSmNcLpATDvs8wld+QfBUGQhgrn0/otwM2EHqN2TIR2A0F0e FTdiPJgPe5NhFsd+VNBS4hWDL0kyLFvwRzJWUHat1+sUO6a5bzRjGNg4Vm1nIOLH ECRYw22eSi0Pp/x6KRYMQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepgeenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:29:10 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:47 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-30-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2156; i=maxime@cerno.tech; h=from:subject:message-id; bh=rft+zeCfJDk1ujED/+8Q5b6Ac7Wf2ehimxyM529KH5c=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYFMYa4LTEJ3BC4VXaP+ib+E07lOTvnrfaU8hahDfvud eK07SlkYxLgYZMUUWWKEzZfEnZr1upONbx7MHFYmkCEMXJwCMBGv+YwMszo3cubUf3//d2rWG5vCLs 2JSmy/bxYffNnw9GqSt6hUH8P/LAU5rzdGT+tathge3b/JsdXGKsb9cuAV+XelnwI2TTnGAAA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 30/33] drm/vc4: vec: Check for VEC output constraints X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" 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. Signed-off-by: Mateusz Kwiatkowski Signed-off-by: Maxime Ripard Acked-by: Noralf Trønnes diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index baa29067a1ff..6828b79a1001 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; } From patchwork Thu Sep 22 14:25:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985286 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 7953FC54EE9 for ; Thu, 22 Sep 2022 14:29:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 65BE510EBC1; Thu, 22 Sep 2022 14:29:35 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 48A9810EBB7; Thu, 22 Sep 2022 14:29:22 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id 047472B05B44; Thu, 22 Sep 2022 10:29:18 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 22 Sep 2022 10:29:21 -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=1663856958; x= 1663864158; bh=CiolBBEbAgAOB0yuauLxIchGO7qhcQ+kNL6bxBM12tk=; b=I V3YmQQxGIcXLhz8ltASLrTI76UklmK4w42jJPp+MBmlJFvZXQELAQRsQhgvBoCJa V5IImTrNMqRslWOPDPBwYBq6qZHENXw/sXqcDF4fgUrKcPqt8VKixwQE5TnG0pB4 MSQfq9rCWJLxGvthBJsMDZPG5urVoL+LKTZ5EBh1KBATww53uGzIQEX/TPTwEKs1 ObAIn90XCN0AiNrmyZX/mShjffgUwI9faUesUHQWVxs+uut0y1zER2/Uy0u/VGAh /SQX9h7glpZ6YwfnEZZBUA7hFzSXi+l1YEMk0VVqN5IRJ8IPmM+0T3ScZ93moI/r 1SxMsTfeaOX04+PytMerg== 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=fm2; t=1663856958; x= 1663864158; bh=CiolBBEbAgAOB0yuauLxIchGO7qhcQ+kNL6bxBM12tk=; b=j FtDkz7O7FatJnnVkc/UOfWjsza4O4N0x+7M3vWU4i3c/BOAvTBDsfzwesJpdBid+ L2wC8XrfFzF9g2Mh+NGUhF3p75xNuJAV35g4cHFVeMKVzMfDR7G73GhHhQlfF+n7 eDqAOUJZg388n9Z7tbqZV91rMAWUziQtS1mZJAj0FimETcgnfNXZDsnq3HazBQZx t4eaEvfnhTSWymiSaQ3ZEhr3GJ2c4Gg4zCaxsI2VCNiZXzxfazBzRNd3DJAdeycd bmVJtP5uOzD1POSVjjkJh+Xi2hXu9YOlVOH5aycR/MKSJ+S07XICi4oXqBj9i0qo VdCsmT1FWRqW+BbKVRInA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepheenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:29:17 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:48 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-31-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=9407; i=maxime@cerno.tech; h=from:subject:message-id; bh=njHT+B8aOMhNdBC4NTIx/Zg2IqYDJ2icfYnoChX93p0=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BYHqIYv9km7sq5RgZZRhKD25znz+tt2pdd3n274XlGjl XLnbUcrCIMbFICumyBIjbL4k7tSs151sfPNg5rAygQxh4OIUgInIbGH4X7TGJ/y6Aru5NcejFcyH5K 7sP7f73sOQma5ffER/lJ+zLGBkWBzZwa27c+dMt09XivebfXLYo3Ff8MXkW67vppivX6X5mhkA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 31/33] drm/vc4: vec: Convert to the new TV mode property X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Now that the core can deal fine with analog TV modes, let's convert the vc4 VEC driver to leverage those new features. We've added some backward compatibility to support the old TV mode property and translate it into the new TV norm property. Signed-off-by: Maxime Ripard Acked-by: Noralf Trønnes diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index 6828b79a1001..a9463364015b 100644 --- a/drivers/gpu/drm/vc4/vc4_vec.c +++ b/drivers/gpu/drm/vc4/vc4_vec.c @@ -172,6 +172,8 @@ struct vc4_vec { struct clk *clock; + struct drm_property *legacy_tv_mode_property; + struct debugfs_regset32 regset; }; @@ -184,6 +186,12 @@ encoder_to_vc4_vec(struct drm_encoder *encoder) return container_of(encoder, struct vc4_vec, encoder.base); } +static inline struct vc4_vec * +connector_to_vc4_vec(struct drm_connector *connector) +{ + return container_of(connector, struct vc4_vec, connector); +} + enum vc4_vec_tv_mode_id { VC4_VEC_TV_MODE_NTSC, VC4_VEC_TV_MODE_NTSC_J, @@ -192,7 +200,7 @@ enum vc4_vec_tv_mode_id { }; struct vc4_vec_tv_mode { - const struct drm_display_mode *mode; + unsigned int mode; u32 config0; u32 config1; u32 custom_freq; @@ -225,43 +233,51 @@ static const struct debugfs_reg32 vec_regs[] = { VC4_REG32(VEC_DAC_MISC), }; -static const struct drm_display_mode ntsc_mode = { - DRM_MODE("720x480", DRM_MODE_TYPE_DRIVER, 13500, - 720, 720 + 14, 720 + 14 + 64, 720 + 14 + 64 + 60, 0, - 480, 480 + 7, 480 + 7 + 6, 525, 0, - DRM_MODE_FLAG_INTERLACE) -}; - -static const struct drm_display_mode pal_mode = { - DRM_MODE("720x576", DRM_MODE_TYPE_DRIVER, 13500, - 720, 720 + 20, 720 + 20 + 64, 720 + 20 + 64 + 60, 0, - 576, 576 + 4, 576 + 4 + 6, 625, 0, - DRM_MODE_FLAG_INTERLACE) -}; - static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = { - [VC4_VEC_TV_MODE_NTSC] = { - .mode = &ntsc_mode, + { + .mode = DRM_MODE_TV_MODE_NTSC, .config0 = VEC_CONFIG0_NTSC_STD | VEC_CONFIG0_PDEN, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, - [VC4_VEC_TV_MODE_NTSC_J] = { - .mode = &ntsc_mode, + { + .mode = DRM_MODE_TV_MODE_NTSC_J, .config0 = VEC_CONFIG0_NTSC_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, - [VC4_VEC_TV_MODE_PAL] = { - .mode = &pal_mode, + { + .mode = DRM_MODE_TV_MODE_PAL, .config0 = VEC_CONFIG0_PAL_BDGHI_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, - [VC4_VEC_TV_MODE_PAL_M] = { - .mode = &ntsc_mode, + { + .mode = DRM_MODE_TV_MODE_PAL_M, .config0 = VEC_CONFIG0_PAL_M_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, }; +static inline const struct vc4_vec_tv_mode * +vc4_vec_tv_mode_lookup(unsigned int mode) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(vc4_vec_tv_modes); i++) { + const struct vc4_vec_tv_mode *tv_mode = &vc4_vec_tv_modes[i]; + + if (tv_mode->mode == mode) + return tv_mode; + } + + return NULL; +} + +static const struct drm_prop_enum_list tv_mode_names[] = { + { VC4_VEC_TV_MODE_NTSC, "NTSC", }, + { VC4_VEC_TV_MODE_NTSC_J, "NTSC-J", }, + { VC4_VEC_TV_MODE_PAL, "PAL", }, + { VC4_VEC_TV_MODE_PAL_M, "PAL-M", }, +}; + static enum drm_connector_status vc4_vec_connector_detect(struct drm_connector *connector, bool force) { @@ -276,19 +292,99 @@ static void vc4_vec_connector_reset(struct drm_connector *connector) static int vc4_vec_connector_get_modes(struct drm_connector *connector) { - struct drm_connector_state *state = connector->state; struct drm_display_mode *mode; + int count = 0; - mode = drm_mode_duplicate(connector->dev, - vc4_vec_tv_modes[state->tv.legacy_mode].mode); + mode = drm_mode_analog_ntsc_480i(connector->dev); if (!mode) { DRM_ERROR("Failed to create a new display mode\n"); return -ENOMEM; } + mode->type |= DRM_MODE_TYPE_PREFERRED; drm_mode_probed_add(connector, mode); + count += 1; - return 1; + mode = drm_mode_analog_pal_576i(connector->dev); + if (!mode) { + DRM_ERROR("Failed to create a new display mode\n"); + return -ENOMEM; + } + + drm_mode_probed_add(connector, mode); + count += 1; + + return count; +} + +static int +vc4_vec_connector_set_property(struct drm_connector *connector, + struct drm_connector_state *state, + struct drm_property *property, + uint64_t val) +{ + struct vc4_vec *vec = connector_to_vc4_vec(connector); + + if (property != vec->legacy_tv_mode_property) + return -EINVAL; + + switch (val) { + case VC4_VEC_TV_MODE_NTSC: + state->tv.mode = DRM_MODE_TV_MODE_NTSC; + break; + + case VC4_VEC_TV_MODE_NTSC_J: + state->tv.mode = DRM_MODE_TV_MODE_NTSC_J; + break; + + case VC4_VEC_TV_MODE_PAL: + state->tv.mode = DRM_MODE_TV_MODE_PAL; + break; + + case VC4_VEC_TV_MODE_PAL_M: + state->tv.mode = DRM_MODE_TV_MODE_PAL_M; + break; + + default: + return -EINVAL; + } + + return 0; +} + +static int +vc4_vec_connector_get_property(struct drm_connector *connector, + const struct drm_connector_state *state, + struct drm_property *property, + uint64_t *val) +{ + struct vc4_vec *vec = connector_to_vc4_vec(connector); + + if (property != vec->legacy_tv_mode_property) + return -EINVAL; + + switch (state->tv.mode) { + case DRM_MODE_TV_MODE_NTSC: + *val = VC4_VEC_TV_MODE_NTSC; + break; + + case DRM_MODE_TV_MODE_NTSC_J: + *val = VC4_VEC_TV_MODE_NTSC_J; + break; + + case DRM_MODE_TV_MODE_PAL: + *val = VC4_VEC_TV_MODE_PAL; + break; + + case DRM_MODE_TV_MODE_PAL_M: + *val = VC4_VEC_TV_MODE_PAL_M; + break; + + default: + return -EINVAL; + } + + return 0; } static const struct drm_connector_funcs vc4_vec_connector_funcs = { @@ -297,15 +393,19 @@ static const struct drm_connector_funcs vc4_vec_connector_funcs = { .reset = vc4_vec_connector_reset, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, + .atomic_get_property = vc4_vec_connector_get_property, + .atomic_set_property = vc4_vec_connector_set_property, }; static const struct drm_connector_helper_funcs vc4_vec_connector_helper_funcs = { + .atomic_check = drm_atomic_helper_connector_tv_check, .get_modes = vc4_vec_connector_get_modes, }; static int vc4_vec_connector_init(struct drm_device *dev, struct vc4_vec *vec) { struct drm_connector *connector = &vec->connector; + struct drm_property *prop; int ret; connector->interlace_allowed = true; @@ -318,8 +418,16 @@ static int vc4_vec_connector_init(struct drm_device *dev, struct vc4_vec *vec) drm_connector_helper_add(connector, &vc4_vec_connector_helper_funcs); drm_object_attach_property(&connector->base, - dev->mode_config.legacy_tv_mode_property, - VC4_VEC_TV_MODE_NTSC); + dev->mode_config.tv_mode_property, + DRM_MODE_TV_MODE_NTSC); + + prop = drm_property_create_enum(dev, 0, "mode", + tv_mode_names, ARRAY_SIZE(tv_mode_names)); + if (!prop) + return -ENOMEM; + vec->legacy_tv_mode_property = prop; + + drm_object_attach_property(&connector->base, prop, VC4_VEC_TV_MODE_NTSC); drm_connector_attach_encoder(connector, &vec->encoder.base); @@ -366,13 +474,16 @@ static void vc4_vec_encoder_enable(struct drm_encoder *encoder, struct drm_connector *connector = &vec->connector; struct drm_connector_state *conn_state = drm_atomic_get_new_connector_state(state, connector); - const struct vc4_vec_tv_mode *tv_mode = - &vc4_vec_tv_modes[conn_state->tv.mode]; + const struct vc4_vec_tv_mode *tv_mode; int idx, ret; if (!drm_dev_enter(drm, &idx)) return; + tv_mode = vc4_vec_tv_mode_lookup(conn_state->tv.mode); + if (!tv_mode) + goto err_dev_exit; + ret = pm_runtime_get_sync(&vec->pdev->dev); if (ret < 0) { DRM_ERROR("Failed to retain power domain: %d\n", ret); @@ -454,13 +565,6 @@ static int vc4_vec_encoder_atomic_check(struct drm_encoder *encoder, 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]; - - if (conn_state->crtc && - !drm_mode_equal(vec_mode->mode, &crtc_state->adjusted_mode)) - return -EINVAL; if (mode->crtc_hdisplay % 4) return -EINVAL; @@ -554,13 +658,6 @@ static const struct of_device_id vc4_vec_dt_match[] = { { /* sentinel */ }, }; -static const char * const tv_mode_names[] = { - [VC4_VEC_TV_MODE_NTSC] = "NTSC", - [VC4_VEC_TV_MODE_NTSC_J] = "NTSC-J", - [VC4_VEC_TV_MODE_PAL] = "PAL", - [VC4_VEC_TV_MODE_PAL_M] = "PAL-M", -}; - static int vc4_vec_bind(struct device *dev, struct device *master, void *data) { struct platform_device *pdev = to_platform_device(dev); @@ -568,9 +665,11 @@ static int vc4_vec_bind(struct device *dev, struct device *master, void *data) struct vc4_vec *vec; int ret; - ret = drm_mode_create_tv_properties_legacy(drm, - ARRAY_SIZE(tv_mode_names), - tv_mode_names); + ret = drm_mode_create_tv_properties(drm, + BIT(DRM_MODE_TV_MODE_NTSC) | + BIT(DRM_MODE_TV_MODE_NTSC_J) | + BIT(DRM_MODE_TV_MODE_PAL) | + BIT(DRM_MODE_TV_MODE_PAL_M)); if (ret) return ret; From patchwork Thu Sep 22 14:25:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985288 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 DA422C54EE9 for ; Thu, 22 Sep 2022 14:29:46 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2742810EBC4; Thu, 22 Sep 2022 14:29:46 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 57C9B10EBC7; Thu, 22 Sep 2022 14:29:29 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailnew.west.internal (Postfix) with ESMTP id 1AEC02B05B4A; Thu, 22 Sep 2022 10:29:26 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 22 Sep 2022 10:29:28 -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=1663856965; x= 1663864165; bh=oDjaofL94i8g8M1QB7L4+qraxJGhG+O3nCmHho8B0JU=; b=A yShVECO/u0SKCfF1pW/h+ruzWWxRFcyDkhHEI+qwbdKG60NMrejxlMGNgEbZ9SRs nPFiIpaNLVa6cn+B8KlWEa37H5rmk/wv2L6kQS2RxsKLHIHc7I4nnKBN9ypjG4Dr 8zXLMTC6zivZjh99dTIh39DMrofblX/nFMeqtnWvgaYbtxaV9KD2KXAqai3JNRDE utivThpMixJKtfIokXMpXGbwFAc52EKLZHFXZ50TtS5qsdLUbL6A1E8mbuEEEooP bhRHAXcc+XocyDstT29GrntLkH/B/PCgs+AOv6UnvvxZSIcf5V1Ji2d031aHmn/T 77NGqvJW3UHwY868oL3ww== 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=fm2; t=1663856965; x= 1663864165; bh=oDjaofL94i8g8M1QB7L4+qraxJGhG+O3nCmHho8B0JU=; b=L 8npyZeu7Yy4xeajl2LCJvNosUIBIPO+qVBsdrb4F1UxYey036NJMmwl2Lg1K5LrG uFPI14RtH/Esjmfx8iZ9gkyajv2Xwws/3oN4pUR6o7Zf+TA4VdpZ2hmPduu3qO42 RS05rKk0/Uy4bdvc4Desh5o5F5xqvRjQOkbcKvRgoIDc3nH0AbSIgddUiqfk3yVo 3bzehy60rBr/pppmcDDWUgZgcOCM6TaU5F5MnQPUxF9QNTlUjscDHrDjCJXMrbTu qrVaJzm1ePwhjS9HMG/SAUiVSjQxB/+3gePtchBY6haJwPDshJQb//A3WI2pA/GF 8ZRMX7H7aN4FY4nyMzXSA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepieenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:29:24 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:49 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-32-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=6722; i=maxime@cerno.tech; h=from:subject:message-id; bh=p/8ZEc2hToewfWpbizBsuyavKEakKIkKnI2WdrETWBI=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BUH/2ppc+nTOOp2aFeQgHu85g4lP9UHPg7qbqQ9furem S8/pKGVhEONikBVTZIkRNl8Sd2rW6042vnkwc1iZQIYwcHEKwET8pzP8zxVSWDnvwGce5qvWj3m0+B yFdgr7Fq+wrea6wJ0TrGU+kZHhl0F+cfGx5wlz1iiqTpj8pka79UXrfYuQo5e6VosvcHfkAAA= X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 32/33] drm/vc4: vec: Add support for more analog TV standards X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" From: Mateusz Kwiatkowski Add support for the following composite output modes (all of them are somewhat more obscure than the previously defined ones): - NTSC_443 - NTSC-style signal with the chroma subcarrier shifted to 4.43361875 MHz (the PAL subcarrier frequency). Never used for broadcasting, but sometimes used as a hack to play NTSC content in PAL regions (e.g. on VCRs). - PAL_N - PAL with alternative chroma subcarrier frequency, 3.58205625 MHz. Used as a broadcast standard in Argentina, Paraguay and Uruguay to fit 576i50 with colour in 6 MHz channel raster. - PAL60 - 480i60 signal with PAL-style color at normal European PAL frequency. Another non-standard, non-broadcast mode, used in similar contexts as NTSC_443. Some displays support one but not the other. - SECAM - French frequency-modulated analog color standard; also have been broadcast in Eastern Europe and various parts of Africa and Asia. Uses the same 576i50 timings as PAL. Also added some comments explaining color subcarrier frequency registers. Signed-off-by: Mateusz Kwiatkowski Signed-off-by: Maxime Ripard Acked-by: Noralf Trønnes diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index a9463364015b..0862462aa9e3 100644 --- a/drivers/gpu/drm/vc4/vc4_vec.c +++ b/drivers/gpu/drm/vc4/vc4_vec.c @@ -46,6 +46,7 @@ #define VEC_CONFIG0_YDEL(x) ((x) << 26) #define VEC_CONFIG0_CDEL_MASK GENMASK(25, 24) #define VEC_CONFIG0_CDEL(x) ((x) << 24) +#define VEC_CONFIG0_SECAM_STD BIT(21) #define VEC_CONFIG0_PBPR_FIL BIT(18) #define VEC_CONFIG0_CHROMA_GAIN_MASK GENMASK(17, 16) #define VEC_CONFIG0_CHROMA_GAIN_UNITY (0 << 16) @@ -76,6 +77,27 @@ #define VEC_SOFT_RESET 0x10c #define VEC_CLMP0_START 0x144 #define VEC_CLMP0_END 0x148 + +/* + * These set the color subcarrier frequency + * if VEC_CONFIG1_CUSTOM_FREQ is enabled. + * + * VEC_FREQ1_0 contains the most significant 16-bit half-word, + * VEC_FREQ3_2 contains the least significant 16-bit half-word. + * 0x80000000 seems to be equivalent to the pixel clock + * (which itself is the VEC clock divided by 8). + * + * Reference values (with the default pixel clock of 13.5 MHz): + * + * NTSC (3579545.[45] Hz) - 0x21F07C1F + * PAL (4433618.75 Hz) - 0x2A098ACB + * PAL-M (3575611.[888111] Hz) - 0x21E6EFE3 + * PAL-N (3582056.25 Hz) - 0x21F69446 + * + * NOTE: For SECAM, it is used as the Dr center frequency, + * regardless of whether VEC_CONFIG1_CUSTOM_FREQ is enabled or not; + * that is specified as 4406250 Hz, which corresponds to 0x29C71C72. + */ #define VEC_FREQ3_2 0x180 #define VEC_FREQ1_0 0x184 @@ -118,6 +140,14 @@ #define VEC_INTERRUPT_CONTROL 0x190 #define VEC_INTERRUPT_STATUS 0x194 + +/* + * Db center frequency for SECAM; the clock for this is the same as for + * VEC_FREQ3_2/VEC_FREQ1_0, which is used for Dr center frequency. + * + * This is specified as 4250000 Hz, which corresponds to 0x284BDA13. + * That is also the default value, so no need to set it explicitly. + */ #define VEC_FCW_SECAM_B 0x198 #define VEC_SECAM_GAIN_VAL 0x19c @@ -197,6 +227,10 @@ enum vc4_vec_tv_mode_id { VC4_VEC_TV_MODE_NTSC_J, VC4_VEC_TV_MODE_PAL, VC4_VEC_TV_MODE_PAL_M, + VC4_VEC_TV_MODE_NTSC_443, + VC4_VEC_TV_MODE_PAL_60, + VC4_VEC_TV_MODE_PAL_N, + VC4_VEC_TV_MODE_SECAM, }; struct vc4_vec_tv_mode { @@ -239,6 +273,12 @@ static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = { .config0 = VEC_CONFIG0_NTSC_STD | VEC_CONFIG0_PDEN, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, + { + .mode = DRM_MODE_TV_MODE_NTSC_443, + .config0 = VEC_CONFIG0_NTSC_STD, + .config1 = VEC_CONFIG1_C_CVBS_CVBS | VEC_CONFIG1_CUSTOM_FREQ, + .custom_freq = 0x2a098acb, + }, { .mode = DRM_MODE_TV_MODE_NTSC_J, .config0 = VEC_CONFIG0_NTSC_STD, @@ -254,6 +294,17 @@ static const struct vc4_vec_tv_mode vc4_vec_tv_modes[] = { .config0 = VEC_CONFIG0_PAL_M_STD, .config1 = VEC_CONFIG1_C_CVBS_CVBS, }, + { + .mode = DRM_MODE_TV_MODE_PAL_N, + .config0 = VEC_CONFIG0_PAL_N_STD, + .config1 = VEC_CONFIG1_C_CVBS_CVBS, + }, + { + .mode = DRM_MODE_TV_MODE_SECAM, + .config0 = VEC_CONFIG0_SECAM_STD, + .config1 = VEC_CONFIG1_C_CVBS_CVBS, + .custom_freq = 0x29c71c72, + }, }; static inline const struct vc4_vec_tv_mode * @@ -273,9 +324,13 @@ vc4_vec_tv_mode_lookup(unsigned int mode) static const struct drm_prop_enum_list tv_mode_names[] = { { VC4_VEC_TV_MODE_NTSC, "NTSC", }, + { VC4_VEC_TV_MODE_NTSC_443, "NTSC-443", }, { VC4_VEC_TV_MODE_NTSC_J, "NTSC-J", }, { VC4_VEC_TV_MODE_PAL, "PAL", }, + { VC4_VEC_TV_MODE_PAL_60, "PAL-60", }, { VC4_VEC_TV_MODE_PAL_M, "PAL-M", }, + { VC4_VEC_TV_MODE_PAL_N, "PAL-N", }, + { VC4_VEC_TV_MODE_SECAM, "SECAM", }, }; static enum drm_connector_status @@ -333,6 +388,10 @@ vc4_vec_connector_set_property(struct drm_connector *connector, state->tv.mode = DRM_MODE_TV_MODE_NTSC; break; + case VC4_VEC_TV_MODE_NTSC_443: + state->tv.mode = DRM_MODE_TV_MODE_NTSC_443; + break; + case VC4_VEC_TV_MODE_NTSC_J: state->tv.mode = DRM_MODE_TV_MODE_NTSC_J; break; @@ -345,6 +404,14 @@ vc4_vec_connector_set_property(struct drm_connector *connector, state->tv.mode = DRM_MODE_TV_MODE_PAL_M; break; + case VC4_VEC_TV_MODE_PAL_N: + state->tv.mode = DRM_MODE_TV_MODE_PAL_N; + break; + + case VC4_VEC_TV_MODE_SECAM: + state->tv.mode = DRM_MODE_TV_MODE_SECAM; + break; + default: return -EINVAL; } @@ -368,6 +435,10 @@ vc4_vec_connector_get_property(struct drm_connector *connector, *val = VC4_VEC_TV_MODE_NTSC; break; + case DRM_MODE_TV_MODE_NTSC_443: + *val = VC4_VEC_TV_MODE_NTSC_443; + break; + case DRM_MODE_TV_MODE_NTSC_J: *val = VC4_VEC_TV_MODE_NTSC_J; break; @@ -380,6 +451,14 @@ vc4_vec_connector_get_property(struct drm_connector *connector, *val = VC4_VEC_TV_MODE_PAL_M; break; + case DRM_MODE_TV_MODE_PAL_N: + *val = VC4_VEC_TV_MODE_PAL_N; + break; + + case DRM_MODE_TV_MODE_SECAM: + *val = VC4_VEC_TV_MODE_SECAM; + break; + default: return -EINVAL; } @@ -667,9 +746,12 @@ static int vc4_vec_bind(struct device *dev, struct device *master, void *data) ret = drm_mode_create_tv_properties(drm, BIT(DRM_MODE_TV_MODE_NTSC) | + BIT(DRM_MODE_TV_MODE_NTSC_443) | BIT(DRM_MODE_TV_MODE_NTSC_J) | BIT(DRM_MODE_TV_MODE_PAL) | - BIT(DRM_MODE_TV_MODE_PAL_M)); + BIT(DRM_MODE_TV_MODE_PAL_M) | + BIT(DRM_MODE_TV_MODE_PAL_N) | + BIT(DRM_MODE_TV_MODE_SECAM)); if (ret) return ret; From patchwork Thu Sep 22 14:25:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 12985287 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 438BDC54EE9 for ; Thu, 22 Sep 2022 14:29:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5E24D10EBC2; Thu, 22 Sep 2022 14:29:41 +0000 (UTC) Received: from wnew4-smtp.messagingengine.com (wnew4-smtp.messagingengine.com [64.147.123.18]) by gabe.freedesktop.org (Postfix) with ESMTPS id 73F0E10EBC4; Thu, 22 Sep 2022 14:29:36 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailnew.west.internal (Postfix) with ESMTP id 322DB2B05B40; Thu, 22 Sep 2022 10:29:33 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Thu, 22 Sep 2022 10:29:35 -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=1663856972; x= 1663864172; bh=YFRn0O6fdeTj6hsCk5Z7dc6Lkrxw4LhpsyxdMerwZXg=; b=L WQNfRdCEBX9MKVUErJgto0hC+hCYuq2o37GIUzysepfZ5wTuGI6uDaPsEo4hA/u5 EDmSsHIcB0+03x6+InXdYKMnuzr5mWrkj6PgkyWRf2lieKlpAx/tzoelwQy5kILy U7m+jCC9gFVaQ4cqrE7BDOFC9zgRrwimSvrGe0Aj6LCFkallEuWa1ckjzFk1Taca HXVoeBxauPMj+SEA2SrhO1MobST2mO2/VoiWxnql0xkSda56mi7UCIiFyMyw08I+ wBLL91ZEM9zLF9EVSs/zU6GZK12s4zGTkBrnmhe65TX0jvYzJFq4ZLQ2CZHtkHsm yMHwD7QCt0RBHCj8KjYTw== 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=fm2; t=1663856972; x= 1663864172; bh=YFRn0O6fdeTj6hsCk5Z7dc6Lkrxw4LhpsyxdMerwZXg=; b=e QdzQhjo7hp3ANFOsXE+dly/+ZxxC108Dv0cwA0qfWj4SGSsh16Xd1oXHzTnYmj03 MCIKNdJJhlU9NdVnALHxUXrunQp9g8XjbWB3Q7ZVn1U5E+fPavzlUqQEGHLOcI27 eE+QJSK67qH/mJ1ZP6/TPFkNN5rkFgRyK/Bv4RDBNRRduptJ3gJ3TFporXVcwu4V PNSSU3Hbl0bp8b4s95Bp/WnJOet4CMwWIdqG1gwMoQo0cn0eBOHSIRpmD+sa+zmS 9fyXAvr/HvWEdQ/oHSQGgf7Y/igT17P2688fQT2fnRB8r0bVJDWIVRTe6TU0IaPh c4huaoOJZwoUsGDncnAeA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeefgedgudekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtkeertdertdejnecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepudduudfhveejteefgedvffdvvedvjedugedukeejhedtlefhffevtefh jeeltdevnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 22 Sep 2022 10:29:31 -0400 (EDT) From: Maxime Ripard Date: Thu, 22 Sep 2022 16:25:50 +0200 MIME-Version: 1.0 Message-Id: <20220728-rpi-analog-tv-properties-v2-33-f733a0ed9f90@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-f733a0ed9f90@cerno.tech> To: Jernej Skrabec , Rodrigo Vivi , Ben Skeggs , David Airlie , Maxime Ripard , Joonas Lahtinen , Emma Anholt , Karol Herbst , Samuel Holland , Jani Nikula , Thomas Zimmermann , Daniel Vetter , Lyude Paul , Maarten Lankhorst , Tvrtko Ursulin , Chen-Yu Tsai X-Mailer: b4 0.10.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=8558; i=maxime@cerno.tech; h=from:subject:message-id; bh=Mfq/57nRwG95ttN/MIZw6AtSRZdBflD/eUn6vPpPiGE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk6BUGb2s5c2luxfYHtdjlJkRvbRVltGkQqF8pteO+p862F bdW1jlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAExk9TdGhtV3rE64axpPMWXyPtdQ43 v7bbFte8q/ToMdr5cUcJ3vLGD4X73HcsWvBe79v8x1m/78q83uitQ7NTP8z3sD/gnr9ogJcQEA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Subject: [Intel-gfx] [PATCH v2 33/33] drm/sun4i: tv: Convert to the new TV mode property X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?unknown-8bit?q?Dom_Cobley_=3Cdom=40raspberrypi=2Ecom=3E=2C_Dave_Steven?= =?unknown-8bit?q?son_=3Cdave=2Estevenson=40raspberrypi=2Ecom=3E=2C_nouveau?= =?unknown-8bit?q?=40lists=2Efreedesktop=2Eorg=2C_intel-gfx=40lists=2Efreede?= =?unknown-8bit?q?sktop=2Eorg=2C_linux-kernel=40vger=2Ekernel=2Eorg=2C_dri-d?= =?unknown-8bit?q?evel=40lists=2Efreedesktop=2Eorg=2C_linux-sunxi=40lists=2E?= =?unknown-8bit?q?linux=2Edev=2C_Noralf_Tr=C3=B8nnes_=3Cnoralf=40tronnes=2Eo?= =?unknown-8bit?q?rg=3E=2C_Geert_Uytterhoeven_=3Cgeert=40linux-m68k=2Eorg=3E?= =?unknown-8bit?q?=2C_Maxime_Ripard_=3Cmaxime=40cerno=2Etech=3E=2C_Mateusz_K?= =?unknown-8bit?q?wiatkowski_=3Ckfyatek+publicgit=40gmail=2Ecom=3E=2C_Phil_E?= =?unknown-8bit?q?lwell_=3Cphil=40raspberrypi=2Ecom=3E=2C_linux-arm-kernel?= =?unknown-8bit?q?=40lists=2Einfradead=2Eorg?= Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" Now that the core can deal fine with analog TV modes, let's convert the sun4i TV driver to leverage those new features. Signed-off-by: Maxime Ripard diff --git a/drivers/gpu/drm/sun4i/sun4i_tv.c b/drivers/gpu/drm/sun4i/sun4i_tv.c index 74ff5ad6a8b9..833742cee745 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tv.c +++ b/drivers/gpu/drm/sun4i/sun4i_tv.c @@ -140,23 +140,14 @@ struct resync_parameters { struct tv_mode { char *name; + unsigned int tv_mode; + u32 mode; u32 chroma_freq; u16 back_porch; u16 front_porch; - u16 line_number; u16 vblank_level; - u32 hdisplay; - u16 hfront_porch; - u16 hsync_len; - u16 hback_porch; - - u32 vdisplay; - u16 vfront_porch; - u16 vsync_len; - u16 vback_porch; - bool yc_en; bool dac3_en; bool dac_bit25_en; @@ -212,7 +203,7 @@ static const struct resync_parameters pal_resync_parameters = { static const struct tv_mode tv_modes[] = { { - .name = "NTSC", + .tv_mode = DRM_MODE_TV_MODE_NTSC, .mode = SUN4I_TVE_CFG0_RES_480i, .chroma_freq = 0x21f07c1f, .yc_en = true, @@ -221,17 +212,6 @@ static const struct tv_mode tv_modes[] = { .back_porch = 118, .front_porch = 32, - .line_number = 525, - - .hdisplay = 720, - .hfront_porch = 18, - .hsync_len = 2, - .hback_porch = 118, - - .vdisplay = 480, - .vfront_porch = 26, - .vsync_len = 2, - .vback_porch = 17, .vblank_level = 240, @@ -241,23 +221,12 @@ static const struct tv_mode tv_modes[] = { .resync_params = &ntsc_resync_parameters, }, { - .name = "PAL", + .tv_mode = DRM_MODE_TV_MODE_PAL, .mode = SUN4I_TVE_CFG0_RES_576i, .chroma_freq = 0x2a098acb, .back_porch = 138, .front_porch = 24, - .line_number = 625, - - .hdisplay = 720, - .hfront_porch = 3, - .hsync_len = 2, - .hback_porch = 139, - - .vdisplay = 576, - .vfront_porch = 28, - .vsync_len = 2, - .vback_porch = 19, .vblank_level = 252, @@ -275,63 +244,21 @@ drm_encoder_to_sun4i_tv(struct drm_encoder *encoder) encoder); } -/* - * FIXME: If only the drm_display_mode private field was usable, this - * could go away... - * - * So far, it doesn't seem to be preserved when the mode is passed by - * to mode_set for some reason. - */ -static const struct tv_mode *sun4i_tv_find_tv_by_mode(const struct drm_display_mode *mode) +static const struct tv_mode * +sun4i_tv_find_tv_by_mode(unsigned int mode) { int i; - /* First try to identify the mode by name */ for (i = 0; i < ARRAY_SIZE(tv_modes); i++) { const struct tv_mode *tv_mode = &tv_modes[i]; - DRM_DEBUG_DRIVER("Comparing mode %s vs %s", - mode->name, tv_mode->name); - - if (!strcmp(mode->name, tv_mode->name)) - return tv_mode; - } - - /* Then by number of lines */ - for (i = 0; i < ARRAY_SIZE(tv_modes); i++) { - const struct tv_mode *tv_mode = &tv_modes[i]; - - DRM_DEBUG_DRIVER("Comparing mode %s vs %s (X: %d vs %d)", - mode->name, tv_mode->name, - mode->vdisplay, tv_mode->vdisplay); - - if (mode->vdisplay == tv_mode->vdisplay) + if (tv_mode->tv_mode == mode) return tv_mode; } return NULL; } -static void sun4i_tv_mode_to_drm_mode(const struct tv_mode *tv_mode, - struct drm_display_mode *mode) -{ - DRM_DEBUG_DRIVER("Creating mode %s\n", mode->name); - - mode->type = DRM_MODE_TYPE_DRIVER; - mode->clock = 13500; - mode->flags = DRM_MODE_FLAG_INTERLACE; - - mode->hdisplay = tv_mode->hdisplay; - mode->hsync_start = mode->hdisplay + tv_mode->hfront_porch; - mode->hsync_end = mode->hsync_start + tv_mode->hsync_len; - mode->htotal = mode->hsync_end + tv_mode->hback_porch; - - mode->vdisplay = tv_mode->vdisplay; - mode->vsync_start = mode->vdisplay + tv_mode->vfront_porch; - mode->vsync_end = mode->vsync_start + tv_mode->vsync_len; - mode->vtotal = mode->vsync_end + tv_mode->vback_porch; -} - static void sun4i_tv_disable(struct drm_encoder *encoder, struct drm_atomic_state *state) { @@ -355,7 +282,11 @@ static void sun4i_tv_enable(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, encoder->crtc); struct drm_display_mode *mode = &crtc_state->mode; - const struct tv_mode *tv_mode = sun4i_tv_find_tv_by_mode(mode); + struct drm_connector *connector = &tv->connector; + struct drm_connector_state *conn_state = + drm_atomic_get_new_connector_state(state, connector); + const struct tv_mode *tv_mode = + sun4i_tv_find_tv_by_mode(conn_state->tv.mode); DRM_DEBUG_DRIVER("Enabling the TV Output\n"); @@ -403,7 +334,7 @@ static void sun4i_tv_enable(struct drm_encoder *encoder, /* Set the lines setup */ regmap_write(tv->regs, SUN4I_TVE_LINE_REG, SUN4I_TVE_LINE_FIRST(22) | - SUN4I_TVE_LINE_NUMBER(tv_mode->line_number)); + SUN4I_TVE_LINE_NUMBER(mode->vtotal)); regmap_write(tv->regs, SUN4I_TVE_LEVEL_REG, SUN4I_TVE_LEVEL_BLANK(tv_mode->video_levels->blank) | @@ -466,35 +397,46 @@ static const struct drm_encoder_helper_funcs sun4i_tv_helper_funcs = { static int sun4i_tv_comp_get_modes(struct drm_connector *connector) { - int i; + struct drm_display_mode *mode; + int count = 0; - for (i = 0; i < ARRAY_SIZE(tv_modes); i++) { - struct drm_display_mode *mode; - const struct tv_mode *tv_mode = &tv_modes[i]; - - mode = drm_mode_create(connector->dev); - if (!mode) { - DRM_ERROR("Failed to create a new display mode\n"); - return 0; - } + mode = drm_mode_analog_ntsc_480i(connector->dev); + if (!mode) { + DRM_ERROR("Failed to create a new display mode\n"); + return -ENOMEM; + } - strcpy(mode->name, tv_mode->name); + mode->type |= DRM_MODE_TYPE_PREFERRED; + drm_mode_probed_add(connector, mode); + count += 1; - sun4i_tv_mode_to_drm_mode(tv_mode, mode); - drm_mode_probed_add(connector, mode); + mode = drm_mode_analog_pal_576i(connector->dev); + if (!mode) { + DRM_ERROR("Failed to create a new display mode\n"); + return -ENOMEM; } - return i; + drm_mode_probed_add(connector, mode); + count += 1; + + return count; } static const struct drm_connector_helper_funcs sun4i_tv_comp_connector_helper_funcs = { + .atomic_check = drm_atomic_helper_connector_tv_check, .get_modes = sun4i_tv_comp_get_modes, }; +static void sun4i_tv_connector_reset(struct drm_connector *connector) +{ + drm_atomic_helper_connector_reset(connector); + drm_atomic_helper_connector_tv_reset(connector); +} + static const struct drm_connector_funcs sun4i_tv_comp_connector_funcs = { .fill_modes = drm_helper_probe_single_connector_modes, .destroy = drm_connector_cleanup, - .reset = drm_atomic_helper_connector_reset, + .reset = sun4i_tv_connector_reset, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, }; @@ -586,8 +528,20 @@ static int sun4i_tv_bind(struct device *dev, struct device *master, drm_connector_attach_encoder(&tv->connector, &tv->encoder); + ret = drm_mode_create_tv_properties(drm, + BIT(DRM_MODE_TV_MODE_NTSC) | + BIT(DRM_MODE_TV_MODE_PAL)); + if (ret) + goto err_cleanup_connector; + + drm_object_attach_property(&tv->connector.base, + drm->mode_config.tv_mode_property, + DRM_MODE_TV_MODE_NTSC); + return 0; +err_cleanup_connector: + drm_connector_cleanup(&tv->connector); err_cleanup_encoder: drm_encoder_cleanup(&tv->encoder); err_disable_clk: diff --git a/drivers/gpu/drm/vc4/vc4_vec.c b/drivers/gpu/drm/vc4/vc4_vec.c index 0862462aa9e3..b9f7bd7b8b7a 100644 --- a/drivers/gpu/drm/vc4/vc4_vec.c +++ b/drivers/gpu/drm/vc4/vc4_vec.c @@ -322,7 +322,7 @@ vc4_vec_tv_mode_lookup(unsigned int mode) return NULL; } -static const struct drm_prop_enum_list tv_mode_names[] = { +static const struct drm_prop_enum_list legacy_tv_mode_names[] = { { VC4_VEC_TV_MODE_NTSC, "NTSC", }, { VC4_VEC_TV_MODE_NTSC_443, "NTSC-443", }, { VC4_VEC_TV_MODE_NTSC_J, "NTSC-J", }, @@ -501,7 +501,8 @@ static int vc4_vec_connector_init(struct drm_device *dev, struct vc4_vec *vec) DRM_MODE_TV_MODE_NTSC); prop = drm_property_create_enum(dev, 0, "mode", - tv_mode_names, ARRAY_SIZE(tv_mode_names)); + legacy_tv_mode_names, + ARRAY_SIZE(legacy_tv_mode_names)); if (!prop) return -ENOMEM; vec->legacy_tv_mode_property = prop;