Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp462437rwb; Thu, 10 Nov 2022 03:22:43 -0800 (PST) X-Google-Smtp-Source: AMsMyM56vpiV8b0Ug7OTaIg/sjLZx6D8V8GNuiRBzL4A2fsFkXEB6IKMVYlt5AppodRu8IsBCM+3 X-Received: by 2002:aa7:c746:0:b0:460:d969:1371 with SMTP id c6-20020aa7c746000000b00460d9691371mr2025153eds.270.1668079362978; Thu, 10 Nov 2022 03:22:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668079362; cv=none; d=google.com; s=arc-20160816; b=c0s/wx3laR9sQO9FR468TbCU6+I3SN+pkJqwUU46eTuhfqlBR42/oO6FHk/zC7CH5i IvbGS1ObGmeWD1tY8v+hXA3vE8OM8arhPNQyCosRryVDFooZ3c3M1k3iGGfs86UbY3Iv Rf3G/G1GZ6zHj+13G2MhWlk6YipyKYJ+Sro03Ln69Nsr/F/hfNcJDIUSn7lZSo3jn5eC kwQrFbi5z7HO4wCIH1ckbZoQxnvxM50oimSoW4BcXF1ImIlmepgcSkOq7Axa2supP4IB PB99IH+6YFKsN/HVkVcUKoJON93oN6PbprtTlQUMpdDx6xRwAJ5tyk4URppTCZ87RDGx IA0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature:dkim-signature; bh=nBoJDFkJJqzsBQfR1N/+xj7J+//0xyFLrenyQ7PXUlg=; b=E2L/tueurHMPSO7s6EqVkKblnXrvrPvT852dAU9HmK2yFtoBHzvQSPDtfvPK19+byB D0E8pbsRUGec9qMWYz/gyBYy8BiC82W4GcaH5ZFg1oNnFj9hksBahE+uwg2aDz46AhYO ZLTwRfibdA8qVijLVfZ/qbslvHJ3KllR2wLP2XLBBKgTULNU14jAlFzfoTkSubQ7E0Ph lZz3eVYuAXqIXx7tLyLsou5MaWlKt7kA1+jRLvul34rIJ4HbHdHbqFKTTOK+9e8sJVXD rdIjzBresAYz/rap60+eRF1tOSKK33cnX3ZMwUjUZGmrgG1UVWjOY3p3jl77c8kSJJIG a4EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=oS3gBOWS; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=HApQSeuY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a056402510a00b00462ab8923ccsi17422570edd.600.2022.11.10.03.22.07; Thu, 10 Nov 2022 03:22:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm2 header.b=oS3gBOWS; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=HApQSeuY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=cerno.tech Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229593AbiKJKgs (ORCPT + 92 others); Thu, 10 Nov 2022 05:36:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiKJKgr (ORCPT ); Thu, 10 Nov 2022 05:36:47 -0500 Received: from new4-smtp.messagingengine.com (new4-smtp.messagingengine.com [66.111.4.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 382FF317D2 for ; Thu, 10 Nov 2022 02:36:44 -0800 (PST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 825145801D6; Thu, 10 Nov 2022 05:36:41 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 10 Nov 2022 05:36:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc: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=1668076601; x=1668083801; bh=nBoJDFkJJq zsBQfR1N/+xj7J+//0xyFLrenyQ7PXUlg=; b=oS3gBOWS2Jkxc08ZKEglsrYDk5 cKoSW3lOwR6hOscSLcWtdwQdkOlP/wOOKMY+spb9ZfuuQxsfXbQ1HhSN79htTXhd gS97dwGs07oLsfaMhUFMz7aVgBhFe1+uifQi5lXcJcJPFGnTO5J/JoKOqR87PvLo 50emMP6yDTes462ANMJ+jEROiS06NdWYY+3+70hms29SUSidQ+ppw5e8MmI8K7bH MyTi3ywT0GYM7EdM5ErS2y5ME132kO3OiU22dmLY6kKpcO2BUxuO0PcnMw8gehxJ h3MTY+oFW4kFlpGpP0EIGlJL/o4pUFMmGjTBJElA2g2gdpclJ9IYHyWZZCUQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1668076601; x=1668083801; bh=nBoJDFkJJqzsBQfR1N/+xj7J+//0 xyFLrenyQ7PXUlg=; b=HApQSeuYUcYuSJ5s8TN27XYvDD3b8GZIL/aFBgp9/frU PLhgMsdr02IUSU519noG8jNCnvfSoaM7OMQcFD2X83pKnQtCYz16GdWF1BGCVtow JIdleYVFscWIjOad1aPMUUC84Nq0z+lIqehuim76Nz6g6c0xtbDPF5DDVfSpZ9x1 PZ2751Lz+PxzSln/cqRQjQ40TZAbfqLiwGDKYcYesmDuVX6OTzmtZsqbv3qT6vTt NrGTvMQ9cvL3maIfr/HQpL3ArYL2ULFi00QfSr2oIb979KPqXWDTNgTpbDgwPBtL 5haKOaiVhWZM2LfUzJ8VvtpjM2Dkdn9AFU6GIh99qw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvgedrfeeggddujecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehgtderredttddunecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepjeevfeehfeekieffgeevleevtefgffefkedtfeeuhfettdegjeehgfegudff ffdunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepmh grgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 10 Nov 2022 05:36:40 -0500 (EST) Date: Thu, 10 Nov 2022 11:36:38 +0100 From: Maxime Ripard To: Noralf =?utf-8?Q?Tr=C3=B8nnes?= Cc: Jani Nikula , Joonas Lahtinen , Tvrtko Ursulin , Ben Skeggs , Rodrigo Vivi , Samuel Holland , Jernej Skrabec , Maarten Lankhorst , Emma Anholt , Karol Herbst , Daniel Vetter , Chen-Yu Tsai , Lyude Paul , Thomas Zimmermann , David Airlie , Phil Elwell , Hans de Goede , linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Geert Uytterhoeven , Dave Stevenson , linux-arm-kernel@lists.infradead.org, Dom Cobley , Mateusz Kwiatkowski , dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org Subject: Re: [PATCH v7 14/23] drm/modes: Properly generate a drm_display_mode from a named mode Message-ID: <20221110103638.o3bomslhvb2sj43d@houat> References: <20220728-rpi-analog-tv-properties-v7-0-7072a478c6b3@cerno.tech> <20220728-rpi-analog-tv-properties-v7-14-7072a478c6b3@cerno.tech> <9e9a8a48-89f2-35d4-b26f-afa7cc44f2f6@tronnes.org> <85a607b4-2645-68c7-0898-08f7c6d064b9@tronnes.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="5srbqddj7e3dz2xw" Content-Disposition: inline In-Reply-To: <85a607b4-2645-68c7-0898-08f7c6d064b9@tronnes.org> X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --5srbqddj7e3dz2xw Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 08, 2022 at 10:40:07AM +0100, Noralf Tr=F8nnes wrote: >=20 >=20 > Den 07.11.2022 18.49, skrev Noralf Tr=F8nnes: > >=20 > >=20 > > Den 07.11.2022 15.16, skrev Maxime Ripard: > >> 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_cmdlin= e_mode() > >> function. > >> > >> In the case of the named modes though, there's no real code to make th= at > >> translation and we rely on the drivers to guess which actual display m= ode > >> 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 v7: > >> - Use tv_mode_specified in drm_mode_parse_command_line_for_connector > >> > >> 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..49441cabdd9d 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); > >> =20 > >> +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 =3D 0; i < ARRAY_SIZE(drm_named_modes); i++) { > >> + const struct drm_named_mode *named_mode =3D &drm_named_modes[i]; > >> + > >> + if (strcmp(cmd->name, named_mode->name)) > >> + continue; > >> + > >> + if (!cmd->tv_mode_specified) > >> + continue; > >=20 > > Only a named mode will set cmd->name, so is this check necessary? > >=20 > >> + > >> + mode =3D 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; > >=20 > > You can just return the result from drm_analog_tv_mode() directly. > >=20 > > With those considered: > >=20 > > Reviewed-by: Noralf Tr=F8nnes > >=20 >=20 > I forgot one thing, shouldn't the named mode test in > drm_connector_pick_cmdline_mode() be removed now that we have proper mode= s? Good catch, I've fixed it Thanks! Maxime --5srbqddj7e3dz2xw Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCY2zUNgAKCRDj7w1vZxhR xc5tAQDufFWQT96Lb6iVY5J8Lt2HGBq1P51c1tAQgPlz+FoRAQD+K3ZwbAaLO5em tFADsUq+cdoZA5xWmbM0RCAIK2hDkg4= =cS0b -----END PGP SIGNATURE----- --5srbqddj7e3dz2xw--