forked from Minki/linux
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
This commit is contained in:
parent
aaa6552028
commit
d25654b3fa
@ -415,26 +415,8 @@ EXPORT_SYMBOL(mipi_dbi_pipe_disable);
|
||||
static int mipi_dbi_connector_get_modes(struct drm_connector *connector)
|
||||
{
|
||||
struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(connector->dev);
|
||||
struct drm_display_mode *mode;
|
||||
|
||||
mode = drm_mode_duplicate(connector->dev, &dbidev->mode);
|
||||
if (!mode) {
|
||||
DRM_ERROR("Failed to duplicate mode\n");
|
||||
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;
|
||||
connector->display_info.height_mm = mode->height_mm;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return drm_connector_helper_get_modes_fixed(connector, &dbidev->mode);
|
||||
}
|
||||
|
||||
static const struct drm_connector_helper_funcs mipi_dbi_connector_hfuncs = {
|
||||
|
@ -1050,6 +1050,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
|
||||
|
@ -839,22 +839,8 @@ static const struct drm_simple_display_pipe_funcs repaper_pipe_funcs = {
|
||||
static int repaper_connector_get_modes(struct drm_connector *connector)
|
||||
{
|
||||
struct repaper_epd *epd = drm_to_epd(connector->dev);
|
||||
struct drm_display_mode *mode;
|
||||
|
||||
mode = drm_mode_duplicate(connector->dev, epd->mode);
|
||||
if (!mode) {
|
||||
DRM_ERROR("Failed to duplicate mode\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
drm_mode_set_name(mode);
|
||||
mode->type |= DRM_MODE_TYPE_PREFERRED;
|
||||
drm_mode_probed_add(connector, mode);
|
||||
|
||||
connector->display_info.width_mm = mode->width_mm;
|
||||
connector->display_info.height_mm = mode->height_mm;
|
||||
|
||||
return 1;
|
||||
return drm_connector_helper_get_modes_fixed(connector, epd->mode);
|
||||
}
|
||||
|
||||
static const struct drm_connector_helper_funcs repaper_connector_hfuncs = {
|
||||
|
@ -620,24 +620,8 @@ static const struct drm_encoder_funcs simpledrm_encoder_funcs = {
|
||||
static int simpledrm_connector_helper_get_modes(struct drm_connector *connector)
|
||||
{
|
||||
struct simpledrm_device *sdev = simpledrm_device_of_dev(connector->dev);
|
||||
struct drm_display_mode *mode;
|
||||
|
||||
mode = drm_mode_duplicate(connector->dev, &sdev->mode);
|
||||
if (!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;
|
||||
return drm_connector_helper_get_modes_fixed(connector, &sdev->mode);
|
||||
}
|
||||
|
||||
static const struct drm_connector_helper_funcs simpledrm_connector_helper_funcs = {
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
struct drm_connector;
|
||||
struct drm_device;
|
||||
struct drm_display_mode;
|
||||
struct drm_modeset_acquire_ctx;
|
||||
|
||||
int drm_helper_probe_single_connector_modes(struct drm_connector
|
||||
@ -27,6 +28,8 @@ void drm_kms_helper_poll_enable(struct drm_device *dev);
|
||||
bool drm_kms_helper_is_poll_worker(void);
|
||||
|
||||
int drm_connector_helper_get_modes_from_ddc(struct drm_connector *connector);
|
||||
int drm_connector_helper_get_modes_fixed(struct drm_connector *connector,
|
||||
const struct drm_display_mode *fixed_mode);
|
||||
int drm_connector_helper_get_modes(struct drm_connector *connector);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user