lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <dab9899b-b3e5-b99f-7219-9b5efa3a3591@tronnes.org>
Date:   Wed, 31 Aug 2022 21:14:36 +0200
From:   Noralf Trønnes <noralf@...nnes.org>
To:     Maxime Ripard <maxime@...no.tech>,
        Maxime Ripard <mripard@...nel.org>,
        Ben Skeggs <bskeggs@...hat.com>,
        David Airlie <airlied@...ux.ie>, Chen-Yu Tsai <wens@...e.org>,
        Thomas Zimmermann <tzimmermann@...e.de>,
        Jani Nikula <jani.nikula@...ux.intel.com>,
        Lyude Paul <lyude@...hat.com>,
        Philipp Zabel <p.zabel@...gutronix.de>,
        Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
        Rodrigo Vivi <rodrigo.vivi@...el.com>,
        Tvrtko Ursulin <tvrtko.ursulin@...ux.intel.com>,
        Jernej Skrabec <jernej.skrabec@...il.com>,
        Samuel Holland <samuel@...lland.org>,
        Karol Herbst <kherbst@...hat.com>,
        Emma Anholt <emma@...olt.net>, Daniel Vetter <daniel@...ll.ch>,
        Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>
Cc:     Hans de Goede <hdegoede@...hat.com>,
        linux-arm-kernel@...ts.infradead.org,
        Phil Elwell <phil@...pberrypi.com>,
        intel-gfx@...ts.freedesktop.org,
        Dave Stevenson <dave.stevenson@...pberrypi.com>,
        dri-devel@...ts.freedesktop.org, Dom Cobley <dom@...pberrypi.com>,
        linux-kernel@...r.kernel.org, nouveau@...ts.freedesktop.org,
        linux-sunxi@...ts.linux.dev,
        Mateusz Kwiatkowski <kfyatek+publicgit@...il.com>,
        Geert Uytterhoeven <geert@...ux-m68k.org>,
        Noralf Trønnes <noralf@...nnes.org>
Subject: Re: [PATCH v2 18/41] drm/connector: Add a function to lookup a TV
 mode by its name



Den 29.08.2022 15.11, 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.
> 
> 
> 
> 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 <maxime@...no.tech>
> 
> 
> 
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> 
> index b1fcacd150e8..0fe01a1c20ad 100644
> 
> --- a/drivers/gpu/drm/drm_connector.c
> 
> +++ b/drivers/gpu/drm/drm_connector.c
> 
> @@ -1003,6 +1003,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)

Missing semicolon.

Noralf.

> 
> +
> 
>  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 bb39d2bb806e..49d261977d4e 100644
> 
> --- a/include/drm/drm_connector.h
> 
> +++ b/include/drm/drm_connector.h
> 
> @@ -1943,6 +1943,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);
> 
>  
> 
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ