Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp5687150rwi; Tue, 18 Oct 2022 02:42:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GmA56nBVfDF9Kuq+2vCJUWrO09W9pPOzEcCqBSokqKM3YuVAkr6kKABlrhr1D5LDMerCK X-Received: by 2002:a17:90a:6c22:b0:20d:3147:e9b9 with SMTP id x31-20020a17090a6c2200b0020d3147e9b9mr2649689pjj.52.1666086129631; Tue, 18 Oct 2022 02:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666086129; cv=none; d=google.com; s=arc-20160816; b=QsgM5hN1Sy4Z37x6o7bhgs8LM7zIBk+F3rVSIQq9PGXXzfJZL7yw4AI1e6F72vwCNm EiDBDwz1SFarLHnRc9lurF/kCbDQ3qRr++atmR1KJUKYE11AnW1vJwqMwjWLZu0IBCI4 mPViz132A/zTIXoxu31J+ogqmIiDWB/hScjJn1JdnTPlKNPD+dr3397vl4v/DJ5E0iaz s8BggMZR53Rb7CbhDaQSpNmNK3vX7WuD+FeJqLhASQVJkSE3u6MNUVQXkaGdjxBGOUfX MJj496k9K/jEiacTOkPfD+tDmjaJFnDJgLbET6LF57msLzbb9Oxu9/P/8fV3OZj1wLO7 D6Yg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:feedback-id:dkim-signature:dkim-signature; bh=m28wxnmpSj23GfJ8mguF+RJIPvACWR84C4m9tbBSs2o=; b=jyjdKdDb9p8BDKnVGKWWyAJ5zY07HiiZJ2G9XLv+glrYXxaysm6mGBoBmjkOQQGCXY fKtZbud33CviinF5Cvt++Bp4Ra5MtFDjDuErGL0sRaybf7Wkvf1bNO764e4JWMAYgCFj zhiLnFepJxba7n1YEEN/AH/C5c9ybIzF9ODaYDEjteOZFdIWiPuPu1+M2nbQxR/x+6b9 AGmZL/rjf0wvkHuwsxFNMoWX/aKiVJ17dEua84/TmtuaMB8V6UaeBoYg4u0Zpw+aZfTu d3SrIX+LbIDpdZzvpBKwZDYnpnQu+pCn7DOGnWW4faLUoSVwUQ7+fDXx0SmJASlhc/Gn zSXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=hTJ3XFHJ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=C5vPZsR4; 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 w8-20020a17090a780800b0020a695678e5si13989984pjk.146.2022.10.18.02.41.56; Tue, 18 Oct 2022 02:42:09 -0700 (PDT) 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=fm3 header.b=hTJ3XFHJ; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=C5vPZsR4; 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 S229977AbiJRJeH (ORCPT + 99 others); Tue, 18 Oct 2022 05:34:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230133AbiJRJeE (ORCPT ); Tue, 18 Oct 2022 05:34:04 -0400 Received: from wnew2-smtp.messagingengine.com (wnew2-smtp.messagingengine.com [64.147.123.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64CA2AE846 for ; Tue, 18 Oct 2022 02:34:03 -0700 (PDT) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailnew.west.internal (Postfix) with ESMTP id EAE112B06818; Tue, 18 Oct 2022 05:33:56 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Tue, 18 Oct 2022 05:34: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=fm3; t=1666085636; x= 1666092836; bh=m28wxnmpSj23GfJ8mguF+RJIPvACWR84C4m9tbBSs2o=; b=h TJ3XFHJn+A8AI/ROPkt+sIqGY3kA4wSIJQT4tHkHl+eM5Yfcjt6X7MYAIUr7Abas QlFe4tD6eLZR/VbYzPHxfb+mmQH0VGNqwYSwV55YB9bcLtz9qxFOwi+BOde3q9ZL WdyVIaCLx1fnmBze8W9xAi0Xv9M2vR2QswXYasftU70eL5G8ZfZ8+hpqiwgPBj3H zWNl5CCgBqV4/lI9o9tIFZT1qgjc8Pd+gffFcHNDISfRVCglOWOLAfXGbTEbRPHa Yz24wplENATRxJGBJBtfQnc7xW25Q8+KWoVVjAMvG2CUhQpR0EOOqAfh4FLpp1cX 5yqaqwrN0S2MK9P/SNs2A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1666085636; x= 1666092836; bh=m28wxnmpSj23GfJ8mguF+RJIPvACWR84C4m9tbBSs2o=; b=C 5vPZsR4g/v/XssSsF5UxPaTyZ5O744YcQyhklPLOetbH0yOlm0PCjh/iY9EZAJ7V uV1SXQOu4CUug0AgTmJ/2n1SCC+FiOjwNU3KptPZNHLSFmFP+8iV5lLytvRIUGet rm3PKGYW8OeqKYNn1TEkhD/N2isE6ds71ZBkQxifTbeGuWIRkEVk9UXVoR30F2Oj /sS8v3YS+KgU4lbjlS5aVXX6eC3gIVIM5iMgDzUe9o/irGu1tn9AAF/Rb3EzIPMM KRBA13tpcwrQwVfkPIv8up+9rplog66fg2VIZD8/j785WDx8QoZg38fgIKAMaVCE j3Kt7kvbfUNsxFzFQk3RA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrfeeluddgudejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggugfgjsehtqhertddttddunecuhfhrohhmpeforgig ihhmvgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrf grthhtvghrnhepleelfeeileelteetfedvieekfeefffevhfdtvefgheevudevheejvddv ieeltdeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epmhgrgihimhgvsegtvghrnhhordhtvggthh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 18 Oct 2022 05:33:55 -0400 (EDT) Date: Tue, 18 Oct 2022 11:33:53 +0200 From: Maxime Ripard To: Noralf =?utf-8?Q?Tr=C3=B8nnes?= Cc: Karol Herbst , Jani Nikula , Tvrtko Ursulin , Daniel Vetter , Maarten Lankhorst , David Airlie , Joonas Lahtinen , Lyude Paul , Emma Anholt , Chen-Yu Tsai , Samuel Holland , Ben Skeggs , Thomas Zimmermann , Rodrigo Vivi , Jernej Skrabec , Dom Cobley , linux-sunxi@lists.linux.dev, Dave Stevenson , intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, Geert Uytterhoeven , linux-arm-kernel@lists.infradead.org, Mateusz Kwiatkowski , dri-devel@lists.freedesktop.org, Hans de Goede , Phil Elwell Subject: Re: [PATCH v5 12/22] drm/connector: Add a function to lookup a TV mode by its name Message-ID: <20221018093353.pt4vset6o2ldxrbs@houat> References: <20220728-rpi-analog-tv-properties-v5-0-d841cc64fe4b@cerno.tech> <20220728-rpi-analog-tv-properties-v5-12-d841cc64fe4b@cerno.tech> <7dcf479c-8ac7-ed47-8587-30268684373c@tronnes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <7dcf479c-8ac7-ed47-8587-30268684373c@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 On Mon, Oct 17, 2022 at 12:44:45PM +0200, Noralf Tr=F8nnes wrote: > Den 13.10.2022 15.18, skrev Maxime Ripard: > > 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. > >=20 > > 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. > >=20 > > Signed-off-by: Maxime Ripard > > --- > > drivers/gpu/drm/drm_connector.c | 24 ++++++++++++++++++++++++ > > include/drm/drm_connector.h | 2 ++ > > 2 files changed, 26 insertions(+) > >=20 > > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_conn= ector.c > > index 820f4c730b38..30611c616435 100644 > > --- a/drivers/gpu/drm/drm_connector.c > > +++ b/drivers/gpu/drm/drm_connector.c > > @@ -991,6 +991,30 @@ static const struct drm_prop_enum_list drm_tv_mode= _enum_list[] =3D { > > }; > > DRM_ENUM_NAME_FN(drm_get_tv_mode_name, drm_tv_mode_enum_list) > > =20 > > +/** > > + * 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) >=20 > Do we really need to pass in length here? item->name has to always be > NUL terminated otherwise things would break elsewhere, so it shouldn't > be necessary AFAICS. The only user so far is the command-line parsing code, and we might very well have an option after the tv_mode, something like 720x480i,tv_mode=3DNTSC,rotate=3D180 In this case, we won't get a NULL-terminated name. Maxime