drm_bridge_helper.c 1.5 KB

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