From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C0218C433FE for ; Sat, 5 Nov 2022 17:52:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=7NVOk+EenisNXLnDtiZcqfh/wDU4UxSguHFJksNJkBo=; b=XFg5wR6WpOvBc3 Hl0DscKKm042F4GBVK6PJfO2GcsgtJ2Pk5L6AFrLcAunoENF4qUYreXL3O5ghBVXbtfg7vOJPmaWI RLGKIebTltc6TITPlKyoR9HILHWisXDEQBXiS/bWYFhAUuyuRAWZDoB2EAVklNfXWFu86Q6dVbcFJ ZX7Nvh7w6QsLBpFP54YkKp7dw/t0MVBgW/1lD6sSYxmCQMa/GeGniRwe4JRfJjr7FUOyHDuVx1zDe lXyfXK64nPQcN2ZP0f102A/i0IMHzMJSOhfH1HW+CYnEmP8orbXb0gbQIqXsLNvBS3rNjdF/vzR2A CRUs6Q1cF9Y9MlzI6Yzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1orNJj-006zJ3-7V; Sat, 05 Nov 2022 17:50:51 +0000 Received: from smtp.domeneshop.no ([2a01:5b40:0:3005::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1orNJe-006zI4-Gz for linux-arm-kernel@lists.infradead.org; Sat, 05 Nov 2022 17:50:47 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tronnes.org ; s=ds202112; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From: References:Cc:To:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=RWDifwBbG878DIYtQ6aTZneSyeLBzoR7LRcwuOd+5Ww=; b=FWsFtfq9WvhTbfg5xv6opUGWJP TpdfVFbgQbUnOuhkMxKu02lanIGkkuJHwejkyfTvZ9vXmef6GD29nMl00Z5kjteh6g5YHxYR0wJXV RhBcOWn0fsq+qfZB5+SM5gxMXlFWBiAbeHEa9khBdsibTyvX7JDI1lDMJcFIsnQpAYE/IRs2CDWhF Wpuh0IpixW85CIELAnJMKjZ4oe6j72x533EAtzjkeuYRKT74/CKmcO6dU2VI7EBdPFlFgjs+S6nqA ibTXHuv1WPrsHerD7XSZyKfCT/K3Y0rjY7WhCGdsdbJLjTxvSOkzuH9FPE9BNVEhz7NF06MYP3f9F jmmHuJ3Q==; Received: from [2a01:799:95a:cb00:a93e:4a2b:2c13:303] (port=57583) by smtp.domeneshop.no with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1orNJW-0004KI-U5; Sat, 05 Nov 2022 18:50:38 +0100 Message-ID: <0a748a39-a387-5bdb-ffc8-6cc6593b56e7@tronnes.org> Date: Sat, 5 Nov 2022 18:50:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Subject: Re: [PATCH v6 14/23] drm/modes: Properly generate a drm_display_mode from a named mode To: maxime@cerno.tech, Karol Herbst , Emma Anholt , Ben Skeggs , Chen-Yu Tsai , Rodrigo Vivi , Maarten Lankhorst , Jani Nikula , Daniel Vetter , Thomas Zimmermann , Tvrtko Ursulin , Samuel Holland , Jernej Skrabec , David Airlie , Maxime Ripard , Joonas Lahtinen , Lyude Paul Cc: linux-sunxi@lists.linux.dev, intel-gfx@lists.freedesktop.org, Phil Elwell , linux-arm-kernel@lists.infradead.org, nouveau@lists.freedesktop.org, Hans de Goede , Dom Cobley , Mateusz Kwiatkowski , dri-devel@lists.freedesktop.org, Dave Stevenson , linux-kernel@vger.kernel.org, Geert Uytterhoeven , =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= References: <20220728-rpi-analog-tv-properties-v6-0-e7792734108f@cerno.tech> <20220728-rpi-analog-tv-properties-v6-14-e7792734108f@cerno.tech> From: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= In-Reply-To: <20220728-rpi-analog-tv-properties-v6-14-e7792734108f@cerno.tech> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221105_105046_613987_BBA58933 X-CRM114-Status: GOOD ( 33.56 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Den 26.10.2022 17.33, skrev maxime@cerno.tech: > 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 > > --- > Changes in v6: > - Fix get_modes to return 0 instead of an error code > - Rename the tests to follow the DRM test naming convention > > Changes in v5: > - Switched to KUNIT_ASSERT_NOT_NULL > --- > drivers/gpu/drm/drm_modes.c | 34 ++++++++++- > drivers/gpu/drm/tests/drm_client_modeset_test.c | 77 ++++++++++++++++++++++++- > 2 files changed, 109 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c > index dc037f7ceb37..85aa9898c229 100644 > --- a/drivers/gpu/drm/drm_modes.c > +++ b/drivers/gpu/drm/drm_modes.c > @@ -2497,6 +2497,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 > @@ -2514,7 +2544,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); I'm trying to track how this generated mode fits into to it all and AFAICS if the connector already supports a mode with the same xres/yres as the named mode, the named mode will never be created because of the check at the beginning of drm_helper_probe_add_cmdline_mode(). It will just mark the existing mode with USERDEF and return. If the connector doesn't already support a mode with such a resolution it will be created, but should we do that? If the driver supported such a mode it would certainly already have added it to the mode list, wouldn't it? After all it's just 2 variants NTSC and PAL. We have this in drm_client_modeset.c:drm_connector_pick_cmdline_mode(): list_for_each_entry(mode, &connector->modes, head) { /* Check (optional) mode name first */ if (!strcmp(mode->name, cmdline_mode->name)) return mode; Here it looks like the named mode thing is a way to choose a mode, not to add one. I couldn't find any documentation on how named modes is supposed to work, have you seen any? Noralf. > + else if (cmd->cvt) > mode = drm_cvt_mode(dev, > cmd->xres, cmd->yres, > cmd->refresh_specified ? cmd->refresh : 60, _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel