msm_atomic.c 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 "msm_drv.h"
  18. #include "msm_gem.h"
  19. #include "msm_kms.h"
  20. static void msm_atomic_wait_for_commit_done(struct drm_device *dev,
  21. struct drm_atomic_state *old_state)
  22. {
  23. struct drm_crtc *crtc;
  24. struct drm_crtc_state *new_crtc_state;
  25. struct msm_drm_private *priv = old_state->dev->dev_private;
  26. struct msm_kms *kms = priv->kms;
  27. int i;
  28. for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i) {
  29. if (!new_crtc_state->active)
  30. continue;
  31. if (drm_crtc_vblank_get(crtc))
  32. continue;
  33. kms->funcs->wait_for_crtc_commit_done(kms, crtc);
  34. drm_crtc_vblank_put(crtc);
  35. }
  36. }
  37. int msm_atomic_prepare_fb(struct drm_plane *plane,
  38. struct drm_plane_state *new_state)
  39. {
  40. struct msm_drm_private *priv = plane->dev->dev_private;
  41. struct msm_kms *kms = priv->kms;
  42. struct drm_gem_object *obj;
  43. struct msm_gem_object *msm_obj;
  44. struct dma_fence *fence;
  45. if (!new_state->fb)
  46. return 0;
  47. obj = msm_framebuffer_bo(new_state->fb, 0);
  48. msm_obj = to_msm_bo(obj);
  49. fence = reservation_object_get_excl_rcu(msm_obj->resv);
  50. drm_atomic_set_fence_for_plane(new_state, fence);
  51. return msm_framebuffer_prepare(new_state->fb, kms->aspace);
  52. }
  53. void msm_atomic_commit_tail(struct drm_atomic_state *state)
  54. {
  55. struct drm_device *dev = state->dev;
  56. struct msm_drm_private *priv = dev->dev_private;
  57. struct msm_kms *kms = priv->kms;
  58. kms->funcs->prepare_commit(kms, state);
  59. drm_atomic_helper_commit_modeset_disables(dev, state);
  60. drm_atomic_helper_commit_planes(dev, state, 0);
  61. drm_atomic_helper_commit_modeset_enables(dev, state);
  62. if (kms->funcs->commit) {
  63. DRM_DEBUG_ATOMIC("triggering commit\n");
  64. kms->funcs->commit(kms, state);
  65. }
  66. msm_atomic_wait_for_commit_done(dev, state);
  67. kms->funcs->complete_commit(kms, state);
  68. drm_atomic_helper_commit_hw_done(state);
  69. drm_atomic_helper_cleanup_planes(dev, state);
  70. }