Commit 216b9bba authored by Thomas Zimmermann's avatar Thomas Zimmermann
Browse files

drm/probe-helper: Add drm_crtc_helper_mode_valid_fixed()



Add drm_crtc_helper_mode_valid_fixed(), which validates a given mode
against a display hardware's mode. Convert simpledrm and use it in a
few other drivers with static modes.

v4:
	* remove empty line after opening brace
v2:
	* rename 'static' and 'hw' to 'fixed' everywhere

Signed-off-by: default avatarThomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20220905141648.22013-3-tzimmermann@suse.de
parent d25654b3
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -309,6 +309,24 @@ static void mipi_dbi_fb_dirty(struct drm_framebuffer *fb, struct drm_rect *rect)
	drm_dev_exit(idx);
}

/**
 * mipi_dbi_pipe_mode_valid - MIPI DBI mode-valid helper
 * @pipe: Simple display pipe
 * @mode: The mode to test
 *
 * This function validates a given display mode against the MIPI DBI's hardware
 * display. Drivers can use this as their &drm_simple_display_pipe_funcs->mode_valid
 * callback.
 */
enum drm_mode_status mipi_dbi_pipe_mode_valid(struct drm_simple_display_pipe *pipe,
					      const struct drm_display_mode *mode)
{
	struct mipi_dbi_dev *dbidev = drm_to_mipi_dbi_dev(pipe->crtc.dev);

	return drm_crtc_helper_mode_valid_fixed(&pipe->crtc, mode, &dbidev->mode);
}
EXPORT_SYMBOL(mipi_dbi_pipe_mode_valid);

/**
 * mipi_dbi_pipe_update - Display pipe update helper
 * @pipe: Simple display pipe
+24 −0
Original line number Diff line number Diff line
@@ -1014,6 +1014,30 @@ bool drm_helper_hpd_irq_event(struct drm_device *dev)
}
EXPORT_SYMBOL(drm_helper_hpd_irq_event);

/**
 * drm_crtc_helper_mode_valid_fixed - Validates a display mode
 * @crtc: the crtc
 * @mode: the mode to validate
 * @fixed_mode: the display hardware's mode
 *
 * Returns:
 * MODE_OK on success, or another mode-status code otherwise.
 */
enum drm_mode_status drm_crtc_helper_mode_valid_fixed(struct drm_crtc *crtc,
						      const struct drm_display_mode *mode,
						      const struct drm_display_mode *fixed_mode)
{
	if (mode->hdisplay != fixed_mode->hdisplay && mode->vdisplay != fixed_mode->vdisplay)
		return MODE_ONE_SIZE;
	else if (mode->hdisplay != fixed_mode->hdisplay)
		return MODE_ONE_WIDTH;
	else if (mode->vdisplay != fixed_mode->vdisplay)
		return MODE_ONE_HEIGHT;

	return MODE_OK;
}
EXPORT_SYMBOL(drm_crtc_helper_mode_valid_fixed);

/**
 * drm_connector_helper_get_modes_from_ddc - Updates the connector's EDID
 *                                           property from the connector's
+1 −0
Original line number Diff line number Diff line
@@ -576,6 +576,7 @@ static void ili9341_dbi_enable(struct drm_simple_display_pipe *pipe,
}

static const struct drm_simple_display_pipe_funcs ili9341_dbi_funcs = {
	.mode_valid = mipi_dbi_pipe_mode_valid,
	.enable = ili9341_dbi_enable,
	.disable = mipi_dbi_pipe_disable,
	.update = mipi_dbi_pipe_update,
+1 −0
Original line number Diff line number Diff line
@@ -181,6 +181,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe,
}

static const struct drm_simple_display_pipe_funcs hx8357d_pipe_funcs = {
	.mode_valid = mipi_dbi_pipe_mode_valid,
	.enable = yx240qv29_enable,
	.disable = mipi_dbi_pipe_disable,
	.update = mipi_dbi_pipe_update,
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ static void yx240qv29_enable(struct drm_simple_display_pipe *pipe,
}

static const struct drm_simple_display_pipe_funcs ili9163_pipe_funcs = {
	.mode_valid = mipi_dbi_pipe_mode_valid,
	.enable = yx240qv29_enable,
	.disable = mipi_dbi_pipe_disable,
	.update = mipi_dbi_pipe_update,
Loading