Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3161559rwe; Mon, 29 Aug 2022 06:55:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR5nBmuOZdei5ipGBNKYiUu/xV3JA30fBIDcT4zOETkrSm5b/CTQ1zHSWU5ci/9C0FkHrz0H X-Received: by 2002:a05:6402:34cb:b0:448:9fac:20a0 with SMTP id w11-20020a05640234cb00b004489fac20a0mr1617416edc.160.1661781345346; Mon, 29 Aug 2022 06:55:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661781345; cv=none; d=google.com; s=arc-20160816; b=WHZSL/6C2RqqRX7AmGgjEjj7asqUgtV7Tkq8eIUSOMMCa4jxgpwF1DABA7UD4zrfVp e6pcGqyaEtToG58bkdVJvzckhRkyvs5DVbwn+Vn3pWnQBnhRNL2cOUrACkLw2GeJy5nZ EbGdcUVYRdziQBueE7wtVDujtMm4AgcUSwvXf76UZNr9eJwnNPEmHERdlU8ikEFXz9iY t04MtKUNXWYOUUMOregMXAvudO8MOOMcdXTDdoZvM7bSCR9vNfp/J+8e1zK2+RdUaKEG NHHMFYT2DAWwJ0ehcXbmAOK66NAdSGh0TJoA6fNF/DEa5Z7h+CR4gzOeJEXcOAYlECaI aCYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :feedback-id:dkim-signature:dkim-signature; bh=yoaENtujWDk2YoyUfMlWzPbfHesL4mBWigqPk9djZvs=; b=rsKeZyk9LR7Dk2eFNy7pCUxla6KtNni5ymWeCtWgER48Iw4NZgDG18801u3HBJQ5HJ iLPUyar+61nXqPR/ai/IjGoh4scTofA0u13FuKFJcQzuihrVlNjRBwt6181TV2s28HXM rHb3aWeiyHkbd3htrpAPc+qowXmKECIljdpMDGtccuEuV5+UrMSTv6qhNsBl+JprNWmD WjE7ZCilYHE6SNYxNV4TcghOLqYf5r7+BV+ohetAfutPjtIL11QwUYiF3YlJs+KC5BLx aLC95/hFMLiwQd9x1HRFk73iem8e29Mmm+AHBWB5L1/PlTn8NyjYpm5VtanWPzd0kjhK ii4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cerno.tech header.s=fm3 header.b=fd9mQL3X; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=dZk9nwZm; 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 s12-20020a1709064d8c00b0074164ff47bfsi3336559eju.697.2022.08.29.06.55.17; Mon, 29 Aug 2022 06:55:45 -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=fd9mQL3X; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=dZk9nwZm; 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 S229530AbiH2NPm (ORCPT + 99 others); Mon, 29 Aug 2022 09:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbiH2NPH (ORCPT ); Mon, 29 Aug 2022 09:15:07 -0400 Received: from wnew2-smtp.messagingengine.com (wnew2-smtp.messagingengine.com [64.147.123.27]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE8857960D for ; Mon, 29 Aug 2022 06:14:20 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailnew.west.internal (Postfix) with ESMTP id 0476E2B06062; Mon, 29 Aug 2022 09:14:01 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 29 Aug 2022 09:14:05 -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=1661778841; x= 1661786041; bh=yoaENtujWDk2YoyUfMlWzPbfHesL4mBWigqPk9djZvs=; b=f d9mQL3XqdfvxkmnIOAr4zeHb8+fyR98wQCL6yRhZGsZL9hiDIpvmv0HpX8Txvql7 Q9bWee+eLxH+EEYGTgo8BQYBI4j7bQj301VJI0O7r/aJkvkb8BcyJStBMYEiidYm txaVLVN5SVmtC20Y7sQBbZJRB3iuQNY7pVbUDLifp73Wzqr6u2kHsDhNubXQcqEl vHI15lEijNN1+rlj2tEKQtinuk5QKUw+CN2JoHBEGhC0rbiWKA7u4G4enTH4udVa hbNqiM7x+6F/u0vaZSfW1VfFmqQB66uefjwPJoPFVUGl0jFcGKnbjDa2wNoI9F1N uw6FSQ0vZ/jYKqLZOLB6Q== 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=fm1; t=1661778841; x= 1661786041; bh=yoaENtujWDk2YoyUfMlWzPbfHesL4mBWigqPk9djZvs=; b=d Zk9nwZmUpnx+HmXyKpkJCVr7ucshcCzqh0RWAW2vVqikaUE2XhsiK7xDEofNcCxb 9Y5RET5Qfpp5DZ+6+cqHcrH+4/nJf44AYd5SEYfmuMVD13Nc2ZjszQNFRxdz7g0W +zBpYpFxVQmo7o3jwrROWksR2nyR9PPjEnSdu7ASowlbkh7NaErSymJdsT6lPi6m 118EvdFCzeVvycRHKD4pmzh3yP9QBIzJ9+2p4oQ88cDwCX8B7lq1g8Rp86SVd63G ORYTQSzlsNiwTeLRbI4zyVxa1WBoHojra06jN5Lh++GMVM80DOc8ik4FqpGuPH6J CFLeI1nT+Z/NIz77Z1yfw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdekuddgieefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhggtgfogfesthhqredtredtjeenucfhrhhomhepofgr gihimhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtf frrghtthgvrhhnpeefiedvfefggffgffehveejieffuddtgffhjefggeetieduvdeileet lefgveegtdenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhroh hmpehmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 29 Aug 2022 09:13:59 -0400 (EDT) From: Maxime Ripard To: Maxime Ripard , Ben Skeggs , David Airlie , Chen-Yu Tsai , Thomas Zimmermann , Jani Nikula , Lyude Paul , Philipp Zabel , Maarten Lankhorst , Rodrigo Vivi , Tvrtko Ursulin , Jernej Skrabec , Samuel Holland , Karol Herbst , =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , Emma Anholt , Daniel Vetter , Joonas Lahtinen Cc: Maxime Ripard , Hans de Goede , linux-arm-kernel@lists.infradead.org, Phil Elwell , intel-gfx@lists.freedesktop.org, Dave Stevenson , dri-devel@lists.freedesktop.org, Dom Cobley , linux-kernel@vger.kernel.org, nouveau@lists.freedesktop.org, linux-sunxi@lists.linux.dev, Mateusz Kwiatkowski , Geert Uytterhoeven Subject: [PATCH v2 18/41] drm/connector: Add a function to lookup a TV mode by its name Date: Mon, 29 Aug 2022 15:11:32 +0200 Message-Id: <20220728-rpi-analog-tv-properties-v2-18-459522d653a7@cerno.tech> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220728-rpi-analog-tv-properties-v2-0-459522d653a7@cerno.tech> References: <20220728-rpi-analog-tv-properties-v2-0-459522d653a7@cerno.tech> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Mailer: b4 0.10.0-dev-65ba7 X-Developer-Signature: v=1; a=openpgp-sha256; l=2253; i=maxime@cerno.tech; h=from:subject:message-id; bh=aZsDW2fSgZ75fEDwwGs+4i//mN9OlBrWjoxn+bTDlQ8=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMk8uxQ0Od59aMvJeOlf+r7704+U5q/Xu9L2p4hudt7KdeN/ 3luBjlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAEyEK5yRocE8o/WP67Zfy0uWT3M43j 7bX/L3IbvtpSs1/CPaTl3bvYbhf16R29Onf/1nFLmkX1/6/Of5hpmyDR03D3me3PUwKfsqExcA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D Content-Transfer-Encoding: quoted-printable 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,T_SCC_BODY_TEXT_LINE 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 As part of the command line parsing rework coming in the next patches,=0D we'll need to lookup drm_connector_tv_mode values by their name, already=0D defined in drm_tv_mode_enum_list.=0D =0D In order to avoid any code duplication, let's do a function that will=0D perform a lookup of a TV mode name and return its value.=0D =0D Signed-off-by: Maxime Ripard =0D =0D diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connecto= r.c=0D index b1fcacd150e8..0fe01a1c20ad 100644=0D --- a/drivers/gpu/drm/drm_connector.c=0D +++ b/drivers/gpu/drm/drm_connector.c=0D @@ -1003,6 +1003,30 @@ static const struct drm_prop_enum_list drm_tv_mode_e= num_list[] =3D {=0D };=0D DRM_ENUM_NAME_FN(drm_get_tv_mode_name, drm_tv_mode_enum_list)=0D =0D +/**=0D + * drm_get_tv_mode_from_name - Translates a TV mode name into its enum val= ue=0D + * @name: TV Mode name we want to convert=0D + * @len: Length of @name=0D + *=0D + * Translates @name into an enum drm_connector_tv_mode.=0D + *=0D + * Returns: the enum value on success, a negative errno otherwise.=0D + */=0D +int drm_get_tv_mode_from_name(const char *name, size_t len)=0D +{=0D + unsigned int i;=0D +=0D + for (i =3D 0; i < ARRAY_SIZE(drm_tv_mode_enum_list); i++) {=0D + const struct drm_prop_enum_list *item =3D &drm_tv_mode_enum_list[i];=0D +=0D + if (strlen(item->name) =3D=3D len && !strncmp(item->name, name, len))=0D + return item->type;=0D + }=0D +=0D + return -EINVAL;=0D +}=0D +EXPORT_SYMBOL(drm_get_tv_mode_from_name)=0D +=0D static const struct drm_prop_enum_list drm_tv_select_enum_list[] =3D {=0D { DRM_MODE_SUBCONNECTOR_Automatic, "Automatic" }, /* DVI-I and TV-out */= =0D { DRM_MODE_SUBCONNECTOR_Composite, "Composite" }, /* TV-out */=0D diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h=0D index bb39d2bb806e..49d261977d4e 100644=0D --- a/include/drm/drm_connector.h=0D +++ b/include/drm/drm_connector.h=0D @@ -1943,6 +1943,8 @@ const char *drm_get_dp_subconnector_name(int val);=0D const char *drm_get_content_protection_name(int val);=0D const char *drm_get_hdcp_content_type_name(int val);=0D =0D +int drm_get_tv_mode_from_name(const char *name, size_t len);=0D +=0D int drm_mode_create_dvi_i_properties(struct drm_device *dev);=0D void drm_connector_attach_dp_subconnector_property(struct drm_connector *c= onnector);=0D =0D =0D -- =0D b4 0.10.0-dev-65ba7=0D