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