linux-stable/drivers/gpu/drm/rockchip
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
..
analogix_dp-rockchip.c Merge drm/drm-next into drm-misc-next 2020-04-17 08:12:22 +02:00
cdn-dp-core.c ASoC: hdmi-codec: merge .digital_mute() into .mute_stream() 2020-07-16 23:06:06 +01:00
cdn-dp-core.h drm/rockchip: fix integer type used for storing dp data rate 2020-01-13 14:31:59 +01:00
cdn-dp-reg.c drm/rockchip: Remove unneeded semicolon 2020-04-27 21:15:55 +02:00
cdn-dp-reg.h
dw-mipi-dsi-rockchip.c treewide: Remove uninitialized_var() usage 2020-07-16 12:35:15 -07:00
dw_hdmi-rockchip.c drm: bridge: dw-hdmi: Pass drm_display_info to dw_hdmi_support_scdc() 2020-06-23 19:57:06 +02:00
inno_hdmi.c drm/rockchip: Use simple encoder 2020-04-02 14:16:45 +02:00
inno_hdmi.h
Kconfig drm/bridge/synopsys: dsi: driver-specific configuration of phy timings 2019-12-16 12:01:58 +01:00
Makefile drm/rockchip: Use the helpers for PSR 2019-07-26 14:48:03 -04:00
rk3066_hdmi.c drm/rockchip: Use simple encoder 2020-04-02 14:16:45 +02:00
rk3066_hdmi.h
rockchip_drm_drv.c drm/rockchip: Convert to drm_gem_object_funcs 2020-09-25 09:21:20 +02:00
rockchip_drm_drv.h drm/rockchip: Add support for afbc 2020-03-23 12:45:26 +01:00
rockchip_drm_fb.c drm/rockchip: remove _unlocked suffix in drm_gem_object_put_unlocked 2020-05-19 22:31:35 +01:00
rockchip_drm_fb.h
rockchip_drm_fbdev.c drm: Remove drm_fb_helper add, add all and remove connector calls 2020-03-06 14:19:58 +01:00
rockchip_drm_fbdev.h
rockchip_drm_gem.c Merge drm/drm-next into drm-misc-next 2020-11-02 11:17:54 +01:00
rockchip_drm_gem.h
rockchip_drm_vop.c drm/atomic: Pass the full state to CRTC atomic begin and flush 2020-11-02 12:37:49 +01:00
rockchip_drm_vop.h drm/rockchip: Add per-pixel alpha support for the PX30 VOP 2020-06-17 12:04:46 +02:00
rockchip_lvds.c drm: Remove unnecessary drm_panel_attach and drm_panel_detach 2020-08-08 09:06:33 +02:00
rockchip_lvds.h drm/rockchip: lvds: Add PX30 support 2020-01-06 11:56:02 +01:00
rockchip_rgb.c drm/rockchip: Use simple encoder 2020-04-02 14:16:45 +02:00
rockchip_rgb.h
rockchip_vop_reg.c drm/rockchip: Add per-pixel alpha support for the PX30 VOP 2020-06-17 12:04:46 +02:00
rockchip_vop_reg.h