msm_atomic.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright (C) 2014 Red Hat
  3. * Author: Rob Clark <robdclark@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify it
  6. * under the terms of the GNU General Public License version 2 as published by
  7. * the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but WITHOUT
  10. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  12. * more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along with
  15. * this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <drm/drm_atomic_uapi.h>
  18. #include "msm_drv.h"
  19. #include "msm_gem.h"
  20. #include "msm_kms.h"
  21. static void msm_atomic_wait_for_commit_done(struct drm_device *dev,
  22. struct drm_atomic_state *old_state)
  23. {
  24. struct drm_crtc *crtc;
  25. struct drm_crtc_state *new_crtc_state;
  26. struct msm_drm_private *priv = old_state->dev->dev_private;
  27. struct msm_kms *kms = priv->kms;
  28. int i;
  29. for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i) {
  30. if (!new_crtc_state->active)
  31. continue;
  32. if (drm_crtc_vblank_get(crtc))
  33. continue;
  34. kms->funcs->wait_for_crtc_commit_done(kms, crtc);
  35. drm_crtc_vblank_put(crtc);
  36. }
  37. }
  38. int msm_atomic_prepare_fb(struct drm_plane *plane,
  39. struct drm_plane_state *new_state)
  40. {
  41. struct msm_drm_private *priv = plane->dev->dev_private;
  42. struct msm_kms *kms = priv->kms;
  43. struct drm_gem_object *obj;
  44. struct msm_gem_object *msm_obj;
  45. struct dma_fence *fence;
  46. if (!new_state->fb)
  47. return 0;
  48. obj = msm_framebuffer_bo(new_state->fb, 0);
  49. msm_obj = to_msm_bo(obj);
  50. fence = reservation_object_get_excl_rcu(msm_obj->resv);
  51. drm_atomic_set_fence_for_plane(new_state, fence);
  52. return msm_framebuffer_prepare(new_state->fb, kms->aspace);
  53. }
  54. void msm_atomic_commit_tail(struct drm_atomic_state *state)
  55. {
  56. struct drm_device *dev = state->dev;
  57. struct msm_drm_private *priv = dev->dev_private;
  58. struct msm_kms *kms = priv->kms;
  59. kms->funcs->prepare_commit(kms, state);
  60. drm_atomic_helper_commit_modeset_disables(dev, state);
  61. drm_atomic_helper_commit_planes(dev, state, 0);
  62. drm_atomic_helper_commit_modeset_enables(dev, state);
  63. if (kms->funcs->commit) {
  64. DRM_DEBUG_ATOMIC("triggering commit\n");
  65. kms->funcs->commit(kms, state);
  66. }
  67. msm_atomic_wait_for_commit_done(dev, state);
  68. kms->funcs->complete_commit(kms, state);
  69. drm_atomic_helper_commit_hw_done(state);
  70. drm_atomic_helper_cleanup_planes(dev, state);
  71. }