2019-06-03 05:44:50 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2014-11-08 18:21:06 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Red Hat
|
|
|
|
* Author: Rob Clark <robdclark@gmail.com>
|
|
|
|
*/
|
|
|
|
|
2018-09-05 13:57:11 +00:00
|
|
|
#include <drm/drm_atomic_uapi.h>
|
2019-06-25 20:42:03 +00:00
|
|
|
#include <drm/drm_gem_framebuffer_helper.h>
|
2019-08-04 06:55:51 +00:00
|
|
|
#include <drm/drm_vblank.h>
|
2018-09-05 13:57:11 +00:00
|
|
|
|
2014-11-08 18:21:06 +00:00
|
|
|
#include "msm_drv.h"
|
2018-04-03 14:42:23 +00:00
|
|
|
#include "msm_gem.h"
|
2014-11-08 18:21:06 +00:00
|
|
|
#include "msm_kms.h"
|
|
|
|
|
2018-04-03 14:42:23 +00:00
|
|
|
int msm_atomic_prepare_fb(struct drm_plane *plane,
|
|
|
|
struct drm_plane_state *new_state)
|
|
|
|
{
|
|
|
|
struct msm_drm_private *priv = plane->dev->dev_private;
|
|
|
|
struct msm_kms *kms = priv->kms;
|
|
|
|
|
|
|
|
if (!new_state->fb)
|
|
|
|
return 0;
|
|
|
|
|
2019-06-25 20:42:03 +00:00
|
|
|
drm_gem_fb_prepare_fb(plane, new_state);
|
2018-04-03 14:42:23 +00:00
|
|
|
|
|
|
|
return msm_framebuffer_prepare(new_state->fb, kms->aspace);
|
|
|
|
}
|
|
|
|
|
2019-08-29 16:45:12 +00:00
|
|
|
/* Get bitmask of crtcs that will need to be flushed. The bitmask
|
|
|
|
* can be used with for_each_crtc_mask() iterator, to iterate
|
|
|
|
* effected crtcs without needing to preserve the atomic state.
|
|
|
|
*/
|
|
|
|
static unsigned get_crtc_mask(struct drm_atomic_state *state)
|
|
|
|
{
|
|
|
|
struct drm_crtc_state *crtc_state;
|
|
|
|
struct drm_crtc *crtc;
|
|
|
|
unsigned i, mask = 0;
|
|
|
|
|
|
|
|
for_each_new_crtc_in_state(state, crtc, crtc_state, i)
|
|
|
|
mask |= drm_crtc_mask(crtc);
|
|
|
|
|
|
|
|
return mask;
|
|
|
|
}
|
|
|
|
|
2018-02-28 19:19:05 +00:00
|
|
|
void msm_atomic_commit_tail(struct drm_atomic_state *state)
|
2014-11-08 18:21:06 +00:00
|
|
|
{
|
|
|
|
struct drm_device *dev = state->dev;
|
2015-01-30 22:04:45 +00:00
|
|
|
struct msm_drm_private *priv = dev->dev_private;
|
|
|
|
struct msm_kms *kms = priv->kms;
|
2019-08-29 16:45:12 +00:00
|
|
|
unsigned crtc_mask = get_crtc_mask(state);
|
2015-01-30 22:04:45 +00:00
|
|
|
|
|
|
|
kms->funcs->prepare_commit(kms, state);
|
2014-11-08 18:21:06 +00:00
|
|
|
|
2015-02-22 11:24:19 +00:00
|
|
|
drm_atomic_helper_commit_modeset_disables(dev, state);
|
2014-11-08 18:21:06 +00:00
|
|
|
|
2016-08-29 09:12:03 +00:00
|
|
|
drm_atomic_helper_commit_planes(dev, state, 0);
|
2014-11-08 18:21:06 +00:00
|
|
|
|
2015-02-22 11:24:19 +00:00
|
|
|
drm_atomic_helper_commit_modeset_enables(dev, state);
|
2014-11-08 18:21:06 +00:00
|
|
|
|
2018-06-27 17:49:23 +00:00
|
|
|
if (kms->funcs->commit) {
|
|
|
|
DRM_DEBUG_ATOMIC("triggering commit\n");
|
|
|
|
kms->funcs->commit(kms, state);
|
|
|
|
}
|
|
|
|
|
2019-08-29 16:45:12 +00:00
|
|
|
kms->funcs->wait_flush(kms, crtc_mask);
|
2015-01-30 22:04:45 +00:00
|
|
|
kms->funcs->complete_commit(kms, state);
|
2018-02-28 19:19:01 +00:00
|
|
|
|
|
|
|
drm_atomic_helper_commit_hw_done(state);
|
|
|
|
|
|
|
|
drm_atomic_helper_cleanup_planes(dev, state);
|
2018-02-28 19:18:58 +00:00
|
|
|
}
|