diff options
author | Thomas Zimmermann <tzimmermann@suse.de> | 2022-09-05 16:16:45 +0200 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2022-09-12 09:13:25 +0200 |
commit | d25654b3fad9906ca80912701fd4bd6e2419f54d (patch) | |
tree | 652aaf51c461aa1629c3440cacaf2b2a86dad334 /drivers/gpu/drm/drm_probe_helper.c | |
parent | drm/vkms: fix variable dereferenced before check warning (diff) | |
download | linux-dev-d25654b3fad9906ca80912701fd4bd6e2419f54d.tar.xz linux-dev-d25654b3fad9906ca80912701fd4bd6e2419f54d.zip |
drm/probe-helper: Add drm_connector_helper_get_modes_fixed()
Add drm_connector_helper_get_modes_fixed(), which duplicates a single
display mode for a connector. Convert drivers.
v2:
* rename 'static' and 'hw' to 'fixed' everywhere
* fix typo 'there' to 'their' (Sam)
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20220905141648.22013-2-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm/drm_probe_helper.c')
-rw-r--r-- | drivers/gpu/drm/drm_probe_helper.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index bb427c5a4f1f..818150a1b3b0 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -1051,6 +1051,46 @@ int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector) EXPORT_SYMBOL(drm_connector_helper_get_modes_from_ddc); /** + * drm_connector_helper_get_modes_fixed - Duplicates a display mode for a connector + * @connector: the connector + * @fixed_mode: the display hardware's mode + * + * This function duplicates a display modes for a connector. Drivers for hardware + * that only supports a single fixed mode can use this function in their connector's + * get_modes helper. + * + * Returns: + * The number of created modes. + */ +int drm_connector_helper_get_modes_fixed(struct drm_connector *connector, + const struct drm_display_mode *fixed_mode) +{ + struct drm_device *dev = connector->dev; + struct drm_display_mode *mode; + + mode = drm_mode_duplicate(dev, fixed_mode); + if (!mode) { + drm_err(dev, "Failed to duplicate mode " DRM_MODE_FMT "\n", + DRM_MODE_ARG(fixed_mode)); + return 0; + } + + if (mode->name[0] == '\0') + drm_mode_set_name(mode); + + mode->type |= DRM_MODE_TYPE_PREFERRED; + drm_mode_probed_add(connector, mode); + + if (mode->width_mm) + connector->display_info.width_mm = mode->width_mm; + if (mode->height_mm) + connector->display_info.height_mm = mode->height_mm; + + return 1; +} +EXPORT_SYMBOL(drm_connector_helper_get_modes_fixed); + +/** * drm_connector_helper_get_modes - Read EDID and update connector. * @connector: The connector * |