| 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
|---|---|
| 2 | |
| 3 | #include <linux/export.h> |
| 4 | |
| 5 | #include <drm/drm_atomic.h> |
| 6 | #include <drm/drm_atomic_helper.h> |
| 7 | #include <drm/drm_bridge.h> |
| 8 | #include <drm/drm_bridge_helper.h> |
| 9 | #include <drm/drm_modeset_lock.h> |
| 10 | |
| 11 | /** |
| 12 | * drm_bridge_helper_reset_crtc - Reset the pipeline feeding a bridge |
| 13 | * @bridge: DRM bridge to reset |
| 14 | * @ctx: lock acquisition context |
| 15 | * |
| 16 | * Reset a @bridge pipeline. It will power-cycle all active components |
| 17 | * between the CRTC and connector that bridge is connected to. |
| 18 | * |
| 19 | * As it relies on drm_atomic_helper_reset_crtc(), the same limitations |
| 20 | * apply. |
| 21 | * |
| 22 | * Returns: |
| 23 | * |
| 24 | * 0 on success or a negative error code on failure. If the error |
| 25 | * returned is EDEADLK, the whole atomic sequence must be restarted. |
| 26 | */ |
| 27 | int drm_bridge_helper_reset_crtc(struct drm_bridge *bridge, |
| 28 | struct drm_modeset_acquire_ctx *ctx) |
| 29 | { |
| 30 | struct drm_connector *connector; |
| 31 | struct drm_encoder *encoder = bridge->encoder; |
| 32 | struct drm_device *dev = encoder->dev; |
| 33 | struct drm_crtc *crtc; |
| 34 | int ret; |
| 35 | |
| 36 | ret = drm_modeset_lock(lock: &dev->mode_config.connection_mutex, ctx); |
| 37 | if (ret) |
| 38 | return ret; |
| 39 | |
| 40 | connector = drm_atomic_get_connector_for_encoder(encoder, ctx); |
| 41 | if (IS_ERR(ptr: connector)) { |
| 42 | ret = PTR_ERR(ptr: connector); |
| 43 | goto out; |
| 44 | } |
| 45 | |
| 46 | if (!connector->state) { |
| 47 | ret = -EINVAL; |
| 48 | goto out; |
| 49 | } |
| 50 | |
| 51 | crtc = connector->state->crtc; |
| 52 | ret = drm_atomic_helper_reset_crtc(crtc, ctx); |
| 53 | if (ret) |
| 54 | goto out; |
| 55 | |
| 56 | out: |
| 57 | drm_modeset_unlock(lock: &dev->mode_config.connection_mutex); |
| 58 | return ret; |
| 59 | } |
| 60 | EXPORT_SYMBOL(drm_bridge_helper_reset_crtc); |
| 61 |
