Merge tag 'libnvdimm-fixes-5.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-block.git] / drivers / gpu / drm / msm / msm_atomic.c
CommitLineData
cf3a7e4c
RC
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
72fdb40c
DV
18#include <drm/drm_atomic_uapi.h>
19
cf3a7e4c 20#include "msm_drv.h"
db8f4d5d 21#include "msm_gem.h"
cf3a7e4c 22#include "msm_kms.h"
cf3a7e4c 23
0a5c9aad
HL
24static void msm_atomic_wait_for_commit_done(struct drm_device *dev,
25 struct drm_atomic_state *old_state)
26{
27 struct drm_crtc *crtc;
d7429669 28 struct drm_crtc_state *new_crtc_state;
0a5c9aad
HL
29 struct msm_drm_private *priv = old_state->dev->dev_private;
30 struct msm_kms *kms = priv->kms;
0a5c9aad
HL
31 int i;
32
d7429669
ML
33 for_each_new_crtc_in_state(old_state, crtc, new_crtc_state, i) {
34 if (!new_crtc_state->active)
0a5c9aad
HL
35 continue;
36
3b712e43
SP
37 if (drm_crtc_vblank_get(crtc))
38 continue;
39
0a5c9aad 40 kms->funcs->wait_for_crtc_commit_done(kms, crtc);
3b712e43
SP
41
42 drm_crtc_vblank_put(crtc);
0a5c9aad
HL
43 }
44}
45
db8f4d5d
SP
46int msm_atomic_prepare_fb(struct drm_plane *plane,
47 struct drm_plane_state *new_state)
48{
49 struct msm_drm_private *priv = plane->dev->dev_private;
50 struct msm_kms *kms = priv->kms;
51 struct drm_gem_object *obj;
52 struct msm_gem_object *msm_obj;
53 struct dma_fence *fence;
54
55 if (!new_state->fb)
56 return 0;
57
58 obj = msm_framebuffer_bo(new_state->fb, 0);
59 msm_obj = to_msm_bo(obj);
60 fence = reservation_object_get_excl_rcu(msm_obj->resv);
61
62 drm_atomic_set_fence_for_plane(new_state, fence);
63
64 return msm_framebuffer_prepare(new_state->fb, kms->aspace);
65}
66
d14659f5 67void msm_atomic_commit_tail(struct drm_atomic_state *state)
cf3a7e4c 68{
cf3a7e4c 69 struct drm_device *dev = state->dev;
0b776d45
RC
70 struct msm_drm_private *priv = dev->dev_private;
71 struct msm_kms *kms = priv->kms;
72
73 kms->funcs->prepare_commit(kms, state);
cf3a7e4c 74
1af434a9 75 drm_atomic_helper_commit_modeset_disables(dev, state);
cf3a7e4c 76
2b58e98d 77 drm_atomic_helper_commit_planes(dev, state, 0);
cf3a7e4c 78
1af434a9 79 drm_atomic_helper_commit_modeset_enables(dev, state);
cf3a7e4c 80
2b7ac1a8
JS
81 if (kms->funcs->commit) {
82 DRM_DEBUG_ATOMIC("triggering commit\n");
83 kms->funcs->commit(kms, state);
84 }
85
50bcc689
SP
86 if (!state->legacy_cursor_update)
87 msm_atomic_wait_for_commit_done(dev, state);
cf3a7e4c 88
0b776d45 89 kms->funcs->complete_commit(kms, state);
70db18dc 90
70db18dc
SP
91 drm_atomic_helper_commit_hw_done(state);
92
93 drm_atomic_helper_cleanup_planes(dev, state);
347b90b4 94}