Skip to content

Commit

Permalink
drm/atomic: Pass the full state to planes atomic disable and update
Browse files Browse the repository at this point in the history
The current atomic helpers have either their object state being passed as
an argument or the full atomic state.

The former is the pattern that was done at first, before switching to the
latter for new hooks or when it was needed.

Let's convert the remaining helpers to provide a consistent interface,
this time with the planes atomic_update and atomic_disable.

The conversion was done using the coccinelle script below, built tested on
all the drivers.

@@
identifier plane, plane_state;
symbol state;
@@

 struct drm_plane_helper_funcs {
 	...
	void (*atomic_update)(struct drm_plane *plane,
-			      struct drm_plane_state *plane_state);
+			      struct drm_atomic_state *state);
 	...
 }

@@
identifier plane, plane_state;
symbol state;
@@

 struct drm_plane_helper_funcs {
	...
	void (*atomic_disable)(struct drm_plane *plane,
-			       struct drm_plane_state *plane_state);
+			       struct drm_atomic_state *state);
	...
 }

@ plane_atomic_func @
identifier helpers;
identifier func;
@@

(
 static const struct drm_plane_helper_funcs helpers = {
 	...,
 	.atomic_update = func,
	...,
 };
|
 static const struct drm_plane_helper_funcs helpers = {
 	...,
 	.atomic_disable = func,
	...,
 };
)

@@
struct drm_plane_helper_funcs *FUNCS;
identifier f;
identifier crtc_state;
identifier plane, plane_state, state;
expression e;
@@

 f(struct drm_crtc_state *crtc_state)
 {
 	...
 	struct drm_atomic_state *state = e;
 	<+...
(
-	FUNCS->atomic_disable(plane, plane_state)
+	FUNCS->atomic_disable(plane, state)
|
-	FUNCS->atomic_update(plane, plane_state)
+	FUNCS->atomic_update(plane, state)
)
 	...+>
 }

@@
identifier plane_atomic_func.func;
identifier plane;
symbol state;
@@

 func(struct drm_plane *plane,
-    struct drm_plane_state *state)
+    struct drm_plane_state *old_plane_state)
 {
	<...
-	state
+	old_plane_state
	...>
 }

@ ignores_old_state @
identifier plane_atomic_func.func;
identifier plane, old_state;
@@

 func(struct drm_plane *plane, struct drm_plane_state *old_state)
 {
	... when != old_state
 }

@ adds_old_state depends on plane_atomic_func && !ignores_old_state @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@

 func(struct drm_plane *plane, struct drm_plane_state *plane_state)
 {
+	struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
 	...
 }

@ depends on plane_atomic_func @
identifier plane_atomic_func.func;
identifier plane, plane_state;
@@

 func(struct drm_plane *plane,
-     struct drm_plane_state *plane_state
+     struct drm_atomic_state *state
     )
 { ... }

@ include depends on adds_old_state @
@@

 #include <drm/drm_atomic.h>

@ no_include depends on !include && adds_old_state @
@@

+ #include <drm/drm_atomic.h>
  #include <drm/...>

@@
identifier plane_atomic_func.func;
identifier plane, state;
identifier plane_state;
@@

 func(struct drm_plane *plane, struct drm_atomic_state *state) {
 	...
 	struct drm_plane_state *plane_state = drm_atomic_get_old_plane_state(state, plane);
 	<+...
-	plane_state->state
+	state
 	...+>
 }

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://patchwork.freedesktop.org/patch/msgid/20210219120032.260676-9-maxime@cerno.tech
  • Loading branch information
Maxime Ripard committed Feb 25, 2021
1 parent 41016fe commit 977697e
Show file tree
Hide file tree
Showing 58 changed files with 207 additions and 123 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/arc/arcpgu_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static const struct drm_crtc_helper_funcs arc_pgu_crtc_helper_funcs = {
};

static void arc_pgu_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *state)
struct drm_atomic_state *state)
{
struct drm_plane_state *new_plane_state = plane->state;
struct arcpgu_drm_private *arcpgu;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/arm/display/komeda/komeda_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ komeda_plane_atomic_check(struct drm_plane *plane,
*/
static void
komeda_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/arm/hdlcd_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ static int hdlcd_plane_atomic_check(struct drm_plane *plane,
}

static void hdlcd_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *state)
struct drm_atomic_state *state)
{
struct drm_plane_state *new_plane_state = plane->state;
struct drm_framebuffer *fb = new_plane_state->fb;
Expand Down
6 changes: 4 additions & 2 deletions drivers/gpu/drm/arm/malidp_planes.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,10 @@ static void malidp_de_set_plane_afbc(struct drm_plane *plane)
}

static void malidp_de_plane_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane);
struct malidp_plane *mp;
struct malidp_plane_state *ms = to_malidp_plane_state(plane->state);
struct drm_plane_state *new_state = plane->state;
Expand Down Expand Up @@ -909,7 +911,7 @@ static void malidp_de_plane_update(struct drm_plane *plane,
}

static void malidp_de_plane_disable(struct drm_plane *plane,
struct drm_plane_state *state)
struct drm_atomic_state *state)
{
struct malidp_plane *mp = to_malidp_plane(plane);

Expand Down
8 changes: 6 additions & 2 deletions drivers/gpu/drm/armada/armada_overlay.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ static inline u32 armada_csc(struct drm_plane_state *state)

/* === Plane support === */
static void armada_drm_overlay_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane);
struct drm_plane_state *new_state = plane->state;
struct armada_crtc *dcrtc;
struct armada_regs *regs;
Expand Down Expand Up @@ -214,8 +216,10 @@ static void armada_drm_overlay_plane_atomic_update(struct drm_plane *plane,
}

static void armada_drm_overlay_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane);
struct armada_crtc *dcrtc;
struct armada_regs *regs;
unsigned int idx = 0;
Expand Down
8 changes: 6 additions & 2 deletions drivers/gpu/drm/armada/armada_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ int armada_drm_plane_atomic_check(struct drm_plane *plane,
}

static void armada_drm_primary_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane);
struct drm_plane_state *new_state = plane->state;
struct armada_crtc *dcrtc;
struct armada_regs *regs;
Expand Down Expand Up @@ -248,8 +250,10 @@ static void armada_drm_primary_plane_atomic_update(struct drm_plane *plane,
}

static void armada_drm_primary_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane);
struct armada_crtc *dcrtc;
struct armada_regs *regs;
unsigned int idx = 0;
Expand Down
12 changes: 8 additions & 4 deletions drivers/gpu/drm/ast/ast_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,10 @@ static int ast_primary_plane_helper_atomic_check(struct drm_plane *plane,

static void
ast_primary_plane_helper_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane);
struct drm_device *dev = plane->dev;
struct ast_private *ast = to_ast_private(dev);
struct drm_plane_state *new_state = plane->state;
Expand Down Expand Up @@ -601,7 +603,7 @@ ast_primary_plane_helper_atomic_update(struct drm_plane *plane,

static void
ast_primary_plane_helper_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct ast_private *ast = to_ast_private(plane->dev);

Expand Down Expand Up @@ -790,9 +792,11 @@ static int ast_cursor_plane_helper_atomic_check(struct drm_plane *plane,

static void
ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct ast_cursor_plane *ast_cursor_plane = to_ast_cursor_plane(plane);
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane);
struct drm_plane_state *new_state = plane->state;
struct drm_shadow_plane_state *shadow_plane_state = to_drm_shadow_plane_state(new_state);
struct drm_framebuffer *fb = new_state->fb;
Expand Down Expand Up @@ -860,7 +864,7 @@ ast_cursor_plane_helper_atomic_update(struct drm_plane *plane,

static void
ast_cursor_plane_helper_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct ast_private *ast = to_ast_private(plane->dev);

Expand Down
6 changes: 3 additions & 3 deletions drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
}

static void atmel_hlcdc_plane_atomic_disable(struct drm_plane *p,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct atmel_hlcdc_plane *plane = drm_plane_to_atmel_hlcdc_plane(p);

Expand All @@ -731,7 +731,7 @@ static void atmel_hlcdc_plane_atomic_disable(struct drm_plane *p,
}

static void atmel_hlcdc_plane_atomic_update(struct drm_plane *p,
struct drm_plane_state *old_s)
struct drm_atomic_state *state)
{
struct drm_plane_state *new_s = p->state;
struct atmel_hlcdc_plane *plane = drm_plane_to_atmel_hlcdc_plane(p);
Expand All @@ -743,7 +743,7 @@ static void atmel_hlcdc_plane_atomic_update(struct drm_plane *p,
return;

if (!hstate->base.visible) {
atmel_hlcdc_plane_atomic_disable(p, old_s);
atmel_hlcdc_plane_atomic_disable(p, state);
return;
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/gpu/drm/drm_atomic_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -2528,9 +2528,9 @@ void drm_atomic_helper_commit_planes(struct drm_device *dev,
no_disable)
continue;

funcs->atomic_disable(plane, old_plane_state);
funcs->atomic_disable(plane, old_state);
} else if (new_plane_state->crtc || disabling) {
funcs->atomic_update(plane, old_plane_state);
funcs->atomic_update(plane, old_state);
}
}

Expand Down Expand Up @@ -2602,10 +2602,10 @@ drm_atomic_helper_commit_planes_on_crtc(struct drm_crtc_state *old_crtc_state)

if (drm_atomic_plane_disabling(old_plane_state, new_plane_state) &&
plane_funcs->atomic_disable)
plane_funcs->atomic_disable(plane, old_plane_state);
plane_funcs->atomic_disable(plane, old_state);
else if (new_plane_state->crtc ||
drm_atomic_plane_disabling(old_plane_state, new_plane_state))
plane_funcs->atomic_update(plane, old_plane_state);
plane_funcs->atomic_update(plane, old_state);
}

if (crtc_funcs && crtc_funcs->atomic_flush)
Expand Down
4 changes: 3 additions & 1 deletion drivers/gpu/drm/drm_simple_kms_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,10 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane,
}

static void drm_simple_kms_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_pstate)
struct drm_atomic_state *state)
{
struct drm_plane_state *old_pstate = drm_atomic_get_old_plane_state(state,
plane);
struct drm_simple_display_pipe *pipe;

pipe = container_of(plane, struct drm_simple_display_pipe, plane);
Expand Down
5 changes: 3 additions & 2 deletions drivers/gpu/drm/exynos/exynos_drm_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static int exynos_plane_atomic_check(struct drm_plane *plane,
}

static void exynos_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *new_state = plane->state;
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(new_state->crtc);
Expand All @@ -266,8 +266,9 @@ static void exynos_plane_atomic_update(struct drm_plane *plane,
}

static void exynos_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state, plane);
struct exynos_drm_plane *exynos_plane = to_exynos_plane(plane);
struct exynos_drm_crtc *exynos_crtc = to_exynos_crtc(old_state->crtc);

Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static int fsl_dcu_drm_plane_atomic_check(struct drm_plane *plane,
}

static void fsl_dcu_drm_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
unsigned int value;
Expand All @@ -76,7 +76,7 @@ static void fsl_dcu_drm_plane_atomic_disable(struct drm_plane *plane,
}

static void fsl_dcu_drm_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)

{
struct fsl_dcu_drm_device *fsl_dev = plane->dev->dev_private;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static int hibmc_plane_atomic_check(struct drm_plane *plane,
}

static void hibmc_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *new_state = plane->state;
u32 reg;
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ static int ade_plane_atomic_check(struct drm_plane *plane,
}

static void ade_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *new_state = plane->state;
struct kirin_plane *kplane = to_kirin_plane(plane);
Expand All @@ -817,7 +817,7 @@ static void ade_plane_atomic_update(struct drm_plane *plane,
}

static void ade_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct kirin_plane *kplane = to_kirin_plane(plane);

Expand Down
6 changes: 4 additions & 2 deletions drivers/gpu/drm/imx/dcss/dcss-plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,10 @@ static bool dcss_plane_needs_setup(struct drm_plane_state *state,
}

static void dcss_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane);
struct drm_plane_state *new_state = plane->state;
struct dcss_plane *dcss_plane = to_dcss_plane(plane);
struct dcss_dev *dcss = plane->dev->dev_private;
Expand Down Expand Up @@ -346,7 +348,7 @@ static void dcss_plane_atomic_update(struct drm_plane *plane,
}

static void dcss_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct dcss_plane *dcss_plane = to_dcss_plane(plane);
struct dcss_dev *dcss = plane->dev->dev_private;
Expand Down
6 changes: 4 additions & 2 deletions drivers/gpu/drm/imx/ipuv3-plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ static int ipu_plane_atomic_check(struct drm_plane *plane,
}

static void ipu_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct ipu_plane *ipu_plane = to_ipu_plane(plane);

Expand Down Expand Up @@ -539,8 +539,10 @@ static void ipu_calculate_bursts(u32 width, u32 cpp, u32 stride,
}

static void ipu_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct drm_plane_state *old_state = drm_atomic_get_old_plane_state(state,
plane);
struct ipu_plane *ipu_plane = to_ipu_plane(plane);
struct drm_plane_state *new_state = plane->state;
struct ipu_plane_state *ipu_state = to_ipu_plane_state(new_state);
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/ingenic/ingenic-drm-drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ void ingenic_drm_plane_disable(struct device *dev, struct drm_plane *plane)
}

static void ingenic_drm_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct ingenic_drm *priv = drm_device_get_priv(plane->dev);

Expand Down Expand Up @@ -542,7 +542,7 @@ static void ingenic_drm_update_palette(struct ingenic_drm *priv,
}

static void ingenic_drm_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *oldstate)
struct drm_atomic_state *state)
{
struct ingenic_drm *priv = drm_device_get_priv(plane->dev);
struct drm_plane_state *newstate = plane->state;
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/ingenic/ingenic-ipu.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ static inline bool osd_changed(struct drm_plane_state *state,
}

static void ingenic_ipu_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *oldstate)
struct drm_atomic_state *state)
{
struct ingenic_ipu *ipu = plane_to_ingenic_ipu(plane);
struct drm_plane_state *newstate = plane->state;
Expand Down Expand Up @@ -595,7 +595,7 @@ static int ingenic_ipu_plane_atomic_check(struct drm_plane *plane,
}

static void ingenic_ipu_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *old_state)
struct drm_atomic_state *state)
{
struct ingenic_ipu *ipu = plane_to_ingenic_ipu(plane);

Expand Down
8 changes: 5 additions & 3 deletions drivers/gpu/drm/kmb/kmb_plane.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ static int kmb_plane_atomic_check(struct drm_plane *plane,
}

static void kmb_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *state)
struct drm_atomic_state *state)
{
struct kmb_plane *kmb_plane = to_kmb_plane(plane);
int plane_id = kmb_plane->id;
Expand Down Expand Up @@ -278,8 +278,10 @@ static void config_csc(struct kmb_drm_private *kmb, int plane_id)
}

static void kmb_plane_atomic_update(struct drm_plane *plane,
struct drm_plane_state *state)
struct drm_atomic_state *state)
{
struct drm_plane_state *old_plane_state = drm_atomic_get_old_plane_state(state,
plane);
struct drm_plane_state *new_plane_state = plane->state;
struct drm_framebuffer *fb;
struct kmb_drm_private *kmb;
Expand All @@ -294,7 +296,7 @@ static void kmb_plane_atomic_update(struct drm_plane *plane,
int num_planes;
static dma_addr_t addr[MAX_SUB_PLANES];

if (!plane || !new_plane_state || !state)
if (!plane || !new_plane_state || !old_plane_state)
return;

fb = new_plane_state->fb;
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/mediatek/mtk_drm_crtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ int mtk_drm_crtc_plane_check(struct drm_crtc *crtc, struct drm_plane *plane,
}

void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
struct drm_plane_state *new_state)
struct drm_atomic_state *state)
{
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
const struct drm_plane_helper_funcs *plane_helper_funcs =
Expand All @@ -515,7 +515,7 @@ void mtk_drm_crtc_async_update(struct drm_crtc *crtc, struct drm_plane *plane,
if (!mtk_crtc->enabled)
return;

plane_helper_funcs->atomic_update(plane, new_state);
plane_helper_funcs->atomic_update(plane, state);
mtk_drm_crtc_hw_config(mtk_crtc);
}

Expand Down
Loading

0 comments on commit 977697e

Please sign in to comment.