1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18#include "msm_drv.h"
19#include "msm_gem.h"
20#include "msm_kms.h"
21
22static void msm_atomic_wait_for_commit_done(struct drm_device *dev,
23 struct drm_atomic_state *old_state)
24{
25 struct drm_crtc *crtc;
26 struct drm_crtc_state *new_crtc_state;
27 struct msm_drm_private *priv = old_state->dev->dev_private;
28 struct msm_kms *kms = priv->kms;
29 int i;
30
31 for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i) {
32 if (!new_crtc_state->active)
33 continue;
34
35 kms->funcs->wait_for_crtc_commit_done(kms, crtc);
36 }
37}
38
39int msm_atomic_prepare_fb(struct drm_plane *plane,
40 struct drm_plane_state *new_state)
41{
42 struct msm_drm_private *priv = plane->dev->dev_private;
43 struct msm_kms *kms = priv->kms;
44 struct drm_gem_object *obj;
45 struct msm_gem_object *msm_obj;
46 struct dma_fence *fence;
47
48 if (!new_state->fb)
49 return 0;
50
51 obj = msm_framebuffer_bo(new_state->fb, 0);
52 msm_obj = to_msm_bo(obj);
53 fence = reservation_object_get_excl_rcu(msm_obj->resv);
54
55 drm_atomic_set_fence_for_plane(new_state, fence);
56
57 return msm_framebuffer_prepare(new_state->fb, kms->aspace);
58}
59
60void msm_atomic_commit_tail(struct drm_atomic_state *state)
61{
62 struct drm_device *dev = state->dev;
63 struct msm_drm_private *priv = dev->dev_private;
64 struct msm_kms *kms = priv->kms;
65
66 kms->funcs->prepare_commit(kms, state);
67
68 drm_atomic_helper_commit_modeset_disables(dev, state);
69
70 drm_atomic_helper_commit_planes(dev, state, 0);
71
72 drm_atomic_helper_commit_modeset_enables(dev, state);
73
74 msm_atomic_wait_for_commit_done(dev, state);
75
76 kms->funcs->complete_commit(kms, state);
77
78 drm_atomic_helper_wait_for_vblanks(dev, state);
79
80 drm_atomic_helper_commit_hw_done(state);
81
82 drm_atomic_helper_cleanup_planes(dev, state);
83}
84