Commit 64593f2a authored by Noralf Trønnes's avatar Noralf Trønnes

drm/client: Add drm_client_modeset_check()

Add a way for client to check the configuration before comitting.

v2:
- Fix docs (Sam)
Reviewed-by: default avatarSam Ravnborg <sam@ravnborg.org>
Signed-off-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200509141619.32970-5-noralf@tronnes.org
parent c9c03e3c
...@@ -969,7 +969,7 @@ bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation) ...@@ -969,7 +969,7 @@ bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation)
} }
EXPORT_SYMBOL(drm_client_rotation); EXPORT_SYMBOL(drm_client_rotation);
static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool active) static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool active, bool check)
{ {
struct drm_device *dev = client->dev; struct drm_device *dev = client->dev;
struct drm_plane *plane; struct drm_plane *plane;
...@@ -1036,6 +1036,9 @@ static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool ...@@ -1036,6 +1036,9 @@ static int drm_client_modeset_commit_atomic(struct drm_client_dev *client, bool
} }
} }
if (check)
ret = drm_atomic_check_only(state);
else
ret = drm_atomic_commit(state); ret = drm_atomic_commit(state);
out_state: out_state:
...@@ -1097,6 +1100,30 @@ static int drm_client_modeset_commit_legacy(struct drm_client_dev *client) ...@@ -1097,6 +1100,30 @@ static int drm_client_modeset_commit_legacy(struct drm_client_dev *client)
return ret; return ret;
} }
/**
* drm_client_modeset_check() - Check modeset configuration
* @client: DRM client
*
* Check modeset configuration.
*
* Returns:
* Zero on success or negative error code on failure.
*/
int drm_client_modeset_check(struct drm_client_dev *client)
{
int ret;
if (!drm_drv_uses_atomic_modeset(client->dev))
return 0;
mutex_lock(&client->modeset_mutex);
ret = drm_client_modeset_commit_atomic(client, true, true);
mutex_unlock(&client->modeset_mutex);
return ret;
}
EXPORT_SYMBOL(drm_client_modeset_check);
/** /**
* drm_client_modeset_commit_locked() - Force commit CRTC configuration * drm_client_modeset_commit_locked() - Force commit CRTC configuration
* @client: DRM client * @client: DRM client
...@@ -1115,7 +1142,7 @@ int drm_client_modeset_commit_locked(struct drm_client_dev *client) ...@@ -1115,7 +1142,7 @@ int drm_client_modeset_commit_locked(struct drm_client_dev *client)
mutex_lock(&client->modeset_mutex); mutex_lock(&client->modeset_mutex);
if (drm_drv_uses_atomic_modeset(dev)) if (drm_drv_uses_atomic_modeset(dev))
ret = drm_client_modeset_commit_atomic(client, true); ret = drm_client_modeset_commit_atomic(client, true, false);
else else
ret = drm_client_modeset_commit_legacy(client); ret = drm_client_modeset_commit_legacy(client);
mutex_unlock(&client->modeset_mutex); mutex_unlock(&client->modeset_mutex);
...@@ -1191,7 +1218,7 @@ int drm_client_modeset_dpms(struct drm_client_dev *client, int mode) ...@@ -1191,7 +1218,7 @@ int drm_client_modeset_dpms(struct drm_client_dev *client, int mode)
mutex_lock(&client->modeset_mutex); mutex_lock(&client->modeset_mutex);
if (drm_drv_uses_atomic_modeset(dev)) if (drm_drv_uses_atomic_modeset(dev))
ret = drm_client_modeset_commit_atomic(client, mode == DRM_MODE_DPMS_ON); ret = drm_client_modeset_commit_atomic(client, mode == DRM_MODE_DPMS_ON, false);
else else
drm_client_modeset_dpms_legacy(client, mode); drm_client_modeset_dpms_legacy(client, mode);
mutex_unlock(&client->modeset_mutex); mutex_unlock(&client->modeset_mutex);
......
...@@ -162,6 +162,7 @@ int drm_client_modeset_create(struct drm_client_dev *client); ...@@ -162,6 +162,7 @@ int drm_client_modeset_create(struct drm_client_dev *client);
void drm_client_modeset_free(struct drm_client_dev *client); void drm_client_modeset_free(struct drm_client_dev *client);
int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, unsigned int height); int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width, unsigned int height);
bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation); bool drm_client_rotation(struct drm_mode_set *modeset, unsigned int *rotation);
int drm_client_modeset_check(struct drm_client_dev *client);
int drm_client_modeset_commit_locked(struct drm_client_dev *client); int drm_client_modeset_commit_locked(struct drm_client_dev *client);
int drm_client_modeset_commit(struct drm_client_dev *client); int drm_client_modeset_commit(struct drm_client_dev *client);
int drm_client_modeset_dpms(struct drm_client_dev *client, int mode); int drm_client_modeset_dpms(struct drm_client_dev *client, int mode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment