@@ -3279,6 +3279,73 @@ int drm_atomic_helper_set_config(struct drm_mode_set *set,
}
EXPORT_SYMBOL(drm_atomic_helper_set_config);
+/**
+ * drm_atomic_helper_disable_connector - disable connector
+ * @connector: connector to disable
+ * @ctx: lock acquisition context
+ *
+ * Turn off the given connector by setting its DPMS mode to off.
+ * Also deactivate the CRTC is this connector was the only one connected to the
+ * CRTC.
+ *
+ * Note that if callers haven't already acquired all modeset locks this might
+ * return -EDEADLK, which must be handled by calling drm_modeset_backoff().
+ *
+ * Returns:
+ * 0 on success or a negative error code on failure.
+ */
+int drm_atomic_helper_disable_connector(struct drm_connector *connector,
+ struct drm_modeset_acquire_ctx *ctx)
+{
+ struct drm_connector_state *connector_state;
+ struct drm_crtc_state *crtc_state;
+ struct drm_atomic_state *state;
+ struct drm_crtc *crtc;
+ int ret;
+
+ state = drm_atomic_state_alloc(connector->dev);
+ if (!state)
+ return -ENOMEM;
+
+ state->acquire_ctx = ctx;
+
+ connector_state = drm_atomic_get_connector_state(state, connector);
+ if (IS_ERR(connector_state)) {
+ ret = PTR_ERR(connector_state);
+ goto end;
+ }
+
+ crtc = connector_state->crtc;
+
+ ret = drm_atomic_set_crtc_for_connector(connector_state, NULL);
+ if (ret < 0)
+ goto end;
+
+ crtc_state = drm_atomic_get_crtc_state(state, crtc);
+ if (IS_ERR(crtc_state)) {
+ ret = PTR_ERR(crtc_state);
+ goto end;
+ }
+
+ if (!crtc_state->connector_mask) {
+ /*
+ * The only one connector from the crtc has
+ * been disabled -> Disable the CRTC too
+ */
+ ret = drm_atomic_set_mode_prop_for_crtc(crtc_state, NULL);
+ if (ret < 0)
+ goto end;
+
+ crtc_state->active = false;
+ }
+
+ ret = drm_atomic_commit(state);
+end:
+ drm_atomic_state_put(state);
+ return ret;
+}
+EXPORT_SYMBOL(drm_atomic_helper_disable_connector);
+
/**
* drm_atomic_helper_disable_all - disable all currently active outputs
* @dev: DRM device
@@ -137,6 +137,8 @@ int drm_atomic_helper_disable_plane(struct drm_plane *plane,
int drm_atomic_helper_set_config(struct drm_mode_set *set,
struct drm_modeset_acquire_ctx *ctx);
+int drm_atomic_helper_disable_connector(struct drm_connector *connector,
+ struct drm_modeset_acquire_ctx *ctx);
int drm_atomic_helper_disable_all(struct drm_device *dev,
struct drm_modeset_acquire_ctx *ctx);
void drm_atomic_helper_shutdown(struct drm_device *dev);
drm_atomic_helper_disable_connector() disables a connector taking care of disabling the CRTC as well if the disabled connector was the only one connector connected to the CRTC. Signed-off-by: Herve Codina <herve.codina@bootlin.com> --- drivers/gpu/drm/drm_atomic_helper.c | 67 +++++++++++++++++++++++++++++ include/drm/drm_atomic_helper.h | 2 + 2 files changed, 69 insertions(+)