summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/mediatek
diff options
context:
space:
mode:
authorMaxime Ripard <maxime@cerno.tech>2021-02-19 13:00:27 +0100
committerMaxime Ripard <maxime@cerno.tech>2021-02-24 20:27:09 +0100
commite05162c017e2e14b94dfd4e55d2f006a9a642c6d (patch)
tree40a4cfeefd35fc313faeb5e9218456d7ab145099 /drivers/gpu/drm/mediatek
parent0b6aaf9d76f0420be015b97724ff764844d7c46d (diff)
downloadlwn-e05162c017e2e14b94dfd4e55d2f006a9a642c6d.tar.gz
lwn-e05162c017e2e14b94dfd4e55d2f006a9a642c6d.zip
drm: Store new plane state in a variable for atomic_update and disable
In order to store the new plane state in a subsequent helper, let's move the plane->state dereferences into a variable. This was done using the following coccinelle script, plus some hand changes for vmwgfx: @ plane_atomic_func @ identifier helpers; identifier func; @@ ( static const struct drm_plane_helper_funcs helpers = { ..., .atomic_disable = func, ..., }; | static const struct drm_plane_helper_funcs helpers = { ..., .atomic_update = func, ..., }; ) @ has_new_state_old_state @ identifier plane_atomic_func.func; identifier plane; identifier new_state; symbol old_state; @@ func(struct drm_plane *plane, struct drm_plane_state *old_state) { ... struct drm_plane_state *new_state = plane->state; ... } @ depends on !has_new_state_old_state @ identifier plane_atomic_func.func; identifier plane; symbol old_state; @@ func(struct drm_plane *plane, struct drm_plane_state *old_state) { + struct drm_plane_state *new_state = plane->state; <+... - plane->state + new_state ...+> } @ has_new_state_state @ identifier plane_atomic_func.func; identifier plane; identifier new_state; symbol state; @@ func(struct drm_plane *plane, struct drm_plane_state *state) { ... struct drm_plane_state *new_state = plane->state; ... } @ depends on !has_new_state_state @ identifier plane_atomic_func.func; identifier plane; symbol state; @@ func(struct drm_plane *plane, struct drm_plane_state *state) { + struct drm_plane_state *new_plane_state = plane->state; <+... - plane->state + new_plane_state ...+> } @ has_new_state_old_s @ identifier plane_atomic_func.func; identifier plane; identifier new_state; symbol old_s; @@ func(struct drm_plane *plane, struct drm_plane_state *old_s) { ... struct drm_plane_state *new_state = plane->state; ... } @ depends on !has_new_state_old_s @ identifier plane_atomic_func.func; identifier plane; symbol old_s; @@ func(struct drm_plane *plane, struct drm_plane_state *old_s) { + struct drm_plane_state *new_s = plane->state; <+... - plane->state + new_s ...+> } Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Acked-by: Thomas Zimmermann <tzimmermann@suse.de> Link: https://lore.kernel.org/r/20210219120032.260676-1-maxime@cerno.tech
Diffstat (limited to 'drivers/gpu/drm/mediatek')
-rw-r--r--drivers/gpu/drm/mediatek/mtk_drm_plane.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
index 1cfd85a991ed..9d82ea6f4f8c 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
@@ -175,7 +175,8 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
static void mtk_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
{
- struct mtk_plane_state *state = to_mtk_plane_state(plane->state);
+ struct drm_plane_state *new_state = plane->state;
+ struct mtk_plane_state *state = to_mtk_plane_state(new_state);
state->pending.enable = false;
wmb(); /* Make sure the above parameter is set before update */
@@ -185,9 +186,10 @@ static void mtk_plane_atomic_disable(struct drm_plane *plane,
static void mtk_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
{
- struct mtk_plane_state *state = to_mtk_plane_state(plane->state);
- struct drm_crtc *crtc = plane->state->crtc;
- struct drm_framebuffer *fb = plane->state->fb;
+ struct drm_plane_state *new_state = plane->state;
+ struct mtk_plane_state *state = to_mtk_plane_state(new_state);
+ struct drm_crtc *crtc = new_state->crtc;
+ struct drm_framebuffer *fb = new_state->fb;
struct drm_gem_object *gem;
struct mtk_drm_gem_obj *mtk_gem;
unsigned int pitch, format;
@@ -196,7 +198,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
if (!crtc || WARN_ON(!fb))
return;
- if (!plane->state->visible) {
+ if (!new_state->visible) {
mtk_plane_atomic_disable(plane, old_state);
return;
}
@@ -207,18 +209,18 @@ static void mtk_plane_atomic_update(struct drm_plane *plane,
pitch = fb->pitches[0];
format = fb->format->format;
- addr += (plane->state->src.x1 >> 16) * fb->format->cpp[0];
- addr += (plane->state->src.y1 >> 16) * pitch;
+ addr += (new_state->src.x1 >> 16) * fb->format->cpp[0];
+ addr += (new_state->src.y1 >> 16) * pitch;
state->pending.enable = true;
state->pending.pitch = pitch;
state->pending.format = format;
state->pending.addr = addr;
- state->pending.x = plane->state->dst.x1;
- state->pending.y = plane->state->dst.y1;
- state->pending.width = drm_rect_width(&plane->state->dst);
- state->pending.height = drm_rect_height(&plane->state->dst);
- state->pending.rotation = plane->state->rotation;
+ state->pending.x = new_state->dst.x1;
+ state->pending.y = new_state->dst.y1;
+ state->pending.width = drm_rect_width(&new_state->dst);
+ state->pending.height = drm_rect_height(&new_state->dst);
+ state->pending.rotation = new_state->rotation;
wmb(); /* Make sure the above parameters are set before update */
state->pending.dirty = true;
}