linux-stable/drivers/gpu/drm/exynos
Maxime Ripard f6ebe9f9c9
drm/atomic: Pass the full state to CRTC atomic begin and flush
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 start convert all the remaining helpers to provide a consistent
interface, starting with the CRTC's atomic_begin and atomic_flush.

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

virtual report

@@
struct drm_crtc_helper_funcs *FUNCS;
identifier old_crtc_state, old_state;
identifier crtc;
identifier f;
@@

 f(struct drm_crtc_state *old_crtc_state)
 {
	...
 	struct drm_atomic_state *old_state = old_crtc_state->state;
	<...
-	FUNCS->atomic_begin(crtc, old_crtc_state);
+	FUNCS->atomic_begin(crtc, old_state);
	...>
 }

@@
struct drm_crtc_helper_funcs *FUNCS;
identifier old_crtc_state, old_state;
identifier crtc;
identifier f;
@@

 f(struct drm_crtc_state *old_crtc_state)
 {
	...
 	struct drm_atomic_state *old_state = old_crtc_state->state;
	<...
-	FUNCS->atomic_flush(crtc, old_crtc_state);
+	FUNCS->atomic_flush(crtc, old_state);
	...>
 }

@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier f;
@@

 f(struct drm_device *dev, struct drm_atomic_state *state, ...)
 {
	<...
-	FUNCS->atomic_begin(crtc, crtc_state);
+	FUNCS->atomic_begin(crtc, state);
	...>
 }

@@
struct drm_crtc_helper_funcs *FUNCS;
struct drm_crtc *crtc;
struct drm_crtc_state *crtc_state;
identifier dev, state;
identifier f;
@@

 f(struct drm_device *dev, struct drm_atomic_state *state, ...)
 {
	<...
-	FUNCS->atomic_flush(crtc, crtc_state);
+	FUNCS->atomic_flush(crtc, state);
	...>
 }

@@
identifier crtc, old_state;
@@

 struct drm_crtc_helper_funcs {
	...
-	void (*atomic_begin)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+	void (*atomic_begin)(struct drm_crtc *crtc, struct drm_atomic_state *state);
	...
-	void (*atomic_flush)(struct drm_crtc *crtc, struct drm_crtc_state *old_state);
+	void (*atomic_flush)(struct drm_crtc *crtc, struct drm_atomic_state *state);
	...
}

@ crtc_atomic_func @
identifier helpers;
identifier func;
@@

(
static struct drm_crtc_helper_funcs helpers = {
	...,
	.atomic_begin = func,
	...,
};
|
static struct drm_crtc_helper_funcs helpers = {
	...,
	.atomic_flush = func,
	...,
};
)

@ ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@

void func(struct drm_crtc *crtc,
		struct drm_crtc_state *old_state)
{
	... when != old_state
}

@ adds_old_state depends on crtc_atomic_func && !ignores_old_state @
identifier crtc_atomic_func.func;
identifier crtc, old_state;
@@

void func(struct drm_crtc *crtc, struct drm_crtc_state *old_state)
{
+	struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
	...
}

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
expression E;
type T;
@@

void func(...)
{
	...
-	T state = E;
+	T crtc_state = E;
	<+...
-	state
+	crtc_state
	...+>

}

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
type T;
@@

void func(...)
{
	...
-	T state;
+	T crtc_state;
	<+...
-	state
+	crtc_state
	...+>

}

@@
identifier old_state;
identifier crtc;
@@

 void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
-			   struct drm_crtc_state *old_state
+			   struct drm_atomic_state *state
			   )
{
+	struct drm_crtc_state *old_state = drm_atomic_get_old_crtc_state(state, crtc);
	...
}

@@
identifier old_state;
identifier crtc;
@@

 void vc4_hvs_atomic_flush(struct drm_crtc *crtc,
-			   struct drm_crtc_state *old_state
+			   struct drm_atomic_state *state
			   );

@@
identifier old_state;
identifier crtc;
@@

 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
-			   struct drm_crtc_state *old_state
+			   struct drm_atomic_state *state
			   )
{
	...
}

@@
identifier old_state;
identifier crtc;
@@

 void vmw_du_crtc_atomic_begin(struct drm_crtc *crtc,
-			   struct drm_crtc_state *old_state
+			   struct drm_atomic_state *state
			   );

@@
identifier old_state;
identifier crtc;
@@

 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
-			   struct drm_crtc_state *old_state
+			   struct drm_atomic_state *state
			   )
{
	...
}

@@
identifier old_state;
identifier crtc;
@@

 void vmw_du_crtc_atomic_flush(struct drm_crtc *crtc,
-			   struct drm_crtc_state *old_state
+			   struct drm_atomic_state *state
			   );

@ depends on crtc_atomic_func @
identifier crtc_atomic_func.func;
identifier old_state;
identifier crtc;
@@

void func(struct drm_crtc *crtc,
-	       struct drm_crtc_state *old_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/...>

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20201028123222.1732139-2-maxime@cerno.tech
2020-11-02 12:37:49 +01:00
..
exynos7_drm_decon.c Linux 5.6 2020-03-31 15:15:47 +10:00
exynos5433_drm_decon.c drm/exynos: Fix cleanup of IOMMU related objects 2020-03-10 13:25:18 +09:00
exynos_dp.c drm-misc-next for 5.8: 2020-04-22 10:41:35 +10:00
exynos_drm_crtc.c drm/atomic: Pass the full state to CRTC atomic begin and flush 2020-11-02 12:37:49 +01:00
exynos_drm_crtc.h
exynos_drm_dma.c dma-mapping updates for 5.10 2020-10-15 14:43:29 -07:00
exynos_drm_dpi.c drm: Remove unnecessary drm_panel_attach and drm_panel_detach 2020-08-08 09:06:33 +02:00
exynos_drm_drv.c drm/exynos: Introduce GEM object functions 2020-09-25 09:20:26 +02:00
exynos_drm_drv.h drm/exynos: Fix cleanup of IOMMU related objects 2020-03-10 13:25:18 +09:00
exynos_drm_dsi.c drm/exynos: dsi: Simplify with dev_err_probe() 2020-09-21 10:58:48 +09:00
exynos_drm_fb.c
exynos_drm_fb.h
exynos_drm_fbdev.c drm/exynos: gem: Fix sparse warning 2020-08-26 16:03:05 +09:00
exynos_drm_fbdev.h
exynos_drm_fimc.c drm/exynos: Fix cleanup of IOMMU related objects 2020-03-10 13:25:18 +09:00
exynos_drm_fimd.c drm/exynos: Fix cleanup of IOMMU related objects 2020-03-10 13:25:18 +09:00
exynos_drm_g2d.c drm: exynos: fix common struct sg_table related issues 2020-09-10 08:18:35 +02:00
exynos_drm_g2d.h
exynos_drm_gem.c Merge drm/drm-next into drm-misc-next 2020-11-02 11:17:54 +01:00
exynos_drm_gem.h drm/exynos: gem: Fix sparse warning 2020-08-26 16:03:05 +09:00
exynos_drm_gsc.c drm/exynos: Fix cleanup of IOMMU related objects 2020-03-10 13:25:18 +09:00
exynos_drm_ipp.c
exynos_drm_ipp.h
exynos_drm_mic.c drm/exynos: fix ref count leak in mic_pre_enable 2020-06-29 09:38:41 +09:00
exynos_drm_plane.c
exynos_drm_plane.h
exynos_drm_rotator.c drm/exynos: Delete an error message in three functions 2020-05-18 11:36:00 +09:00
exynos_drm_scaler.c drm/exynos: Delete an error message in three functions 2020-05-18 11:36:00 +09:00
exynos_drm_vidi.c drm/exynos-vidi: convert platform driver to use dev_groups 2020-05-18 13:19:18 +09:00
exynos_drm_vidi.h
exynos_hdmi.c drm/exynos: hdmi: Simplify with dev_err_probe() 2020-09-21 10:58:48 +09:00
exynos_mixer.c drm-misc-next for v5.9: 2020-06-24 15:45:51 +10:00
Kconfig drm/exynos: Rename Exynos to lowercase 2020-01-21 09:09:42 +09:00
Makefile
regs-decon7.h
regs-decon5433.h
regs-fimc.h
regs-gsc.h
regs-hdmi.h
regs-mixer.h
regs-rotator.h
regs-scaler.h
regs-vp.h