[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <0a748a39-a387-5bdb-ffc8-6cc6593b56e7@tronnes.org>
Date: Sat, 5 Nov 2022 18:50:30 +0100
From: Noralf Trønnes <noralf@...nnes.org>
To: maxime@...no.tech, Karol Herbst <kherbst@...hat.com>,
Emma Anholt <emma@...olt.net>, Ben Skeggs <bskeggs@...hat.com>,
Chen-Yu Tsai <wens@...e.org>,
Rodrigo Vivi <rodrigo.vivi@...el.com>,
Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Daniel Vetter <daniel@...ll.ch>,
Thomas Zimmermann <tzimmermann@...e.de>,
Tvrtko Ursulin <tvrtko.ursulin@...ux.intel.com>,
Samuel Holland <samuel@...lland.org>,
Jernej Skrabec <jernej.skrabec@...il.com>,
David Airlie <airlied@...ux.ie>,
Maxime Ripard <mripard@...nel.org>,
Joonas Lahtinen <joonas.lahtinen@...ux.intel.com>,
Lyude Paul <lyude@...hat.com>
Cc: linux-sunxi@...ts.linux.dev, intel-gfx@...ts.freedesktop.org,
Phil Elwell <phil@...pberrypi.com>,
linux-arm-kernel@...ts.infradead.org,
nouveau@...ts.freedesktop.org, Hans de Goede <hdegoede@...hat.com>,
Dom Cobley <dom@...pberrypi.com>,
Mateusz Kwiatkowski <kfyatek+publicgit@...il.com>,
dri-devel@...ts.freedesktop.org,
Dave Stevenson <dave.stevenson@...pberrypi.com>,
linux-kernel@...r.kernel.org,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Noralf Trønnes <noralf@...nnes.org>
Subject: Re: [PATCH v6 14/23] drm/modes: Properly generate a drm_display_mode
from a named mode
Den 26.10.2022 17.33, skrev maxime@...no.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 <maxime@...no.tech>
>
> ---
> 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,
Powered by blists - more mailing lists