OpenCloudOS-Kernel/drivers/gpu/drm/sun4i
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
..
Kconfig drm/sun4i: Fix Kconfig indentation 2019-11-25 10:04:41 +01:00
Makefile
sun4i_backend.c dma-mapping updates for 5.10 2020-10-15 14:43:29 -07:00
sun4i_backend.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun4i_crtc.c drm/atomic: Pass the full state to CRTC atomic begin and flush 2020-11-02 12:37:49 +01:00
sun4i_crtc.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun4i_dotclock.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun4i_dotclock.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun4i_drv.c drm/cma-helper: Rework DRM_GEM_CMA_VMAP_DRIVER_OPS macro 2020-06-10 09:01:41 +02:00
sun4i_drv.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun4i_framebuffer.c drm/sun4i: Constify static structs 2020-08-18 10:49:13 +02:00
sun4i_framebuffer.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun4i_frontend.c drm/sun4i: frontend: Fix the scaler phase on A33 2020-10-26 11:43:30 +01:00
sun4i_frontend.h drm/sun4i: frontend: Rework a bit the phase data 2020-10-26 11:43:30 +01:00
sun4i_hdmi.h drm/sun4i: hdmi ddc clk: Fix size of m divider 2020-06-10 09:11:49 +02:00
sun4i_hdmi_ddc_clk.c drm/sun4i: hdmi ddc clk: Fix size of m divider 2020-06-10 09:11:49 +02:00
sun4i_hdmi_enc.c drm: sun4i: hdmi: Fix inverted HPD result 2020-07-17 14:03:59 +02:00
sun4i_hdmi_i2c.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun4i_hdmi_tmds_clk.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun4i_layer.c drm/sun4i: Remove unneeded semicolon in sun4i_layer.c 2019-12-14 18:48:15 +01:00
sun4i_layer.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun4i_lvds.c drm/sun4i: Constify static structs 2020-08-18 10:49:13 +02:00
sun4i_lvds.h
sun4i_rgb.c drm/sun4i: Constify static structs 2020-08-18 10:49:13 +02:00
sun4i_rgb.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun4i_tcon.c Linux 5.9-rc5 2020-09-14 17:19:11 +02:00
sun4i_tcon.h drm/sun4i: tcon: Support LVDS output on Allwinner A20 2020-02-20 18:25:36 +01:00
sun4i_tv.c drm/sun4i: Constify static structs 2020-08-18 10:49:13 +02:00
sun6i_drc.c drm/sun4i: drc: Make sure we enforce the clock rate 2020-01-08 09:14:08 +01:00
sun6i_mipi_dsi.c Linux 5.9-rc5 2020-09-14 17:19:11 +02:00
sun6i_mipi_dsi.h drm/sun4i: dsi: Allow binding the host without a panel 2020-02-14 16:20:27 +01:00
sun8i_csc.c drm/sun4i: sun8i-csc: Add support for color encoding and range 2019-07-20 07:38:09 +02:00
sun8i_csc.h drm/sun4i: sun8i-csc: Secondary CSC register correction 2020-09-10 13:08:43 +02:00
sun8i_dw_hdmi.c drm: bridge: dw-hdmi: Pass drm_display_info to .mode_valid() 2020-06-23 19:56:02 +02:00
sun8i_dw_hdmi.h drm: bridge: dw-hdmi: Pass drm_display_info to .mode_valid() 2020-06-23 19:56:02 +02:00
sun8i_hdmi_phy.c drm/sun4i: Constify static structs 2020-08-18 10:49:13 +02:00
sun8i_hdmi_phy_clk.c
sun8i_mixer.c drm next for 5.10-rc1 2020-10-15 10:46:16 -07:00
sun8i_mixer.h drm/sun4i: de2: Don't return de2_fmt_info struct 2020-03-24 21:13:24 +01:00
sun8i_tcon_top.c drm/sun4i: drop use of drmP.h 2019-07-17 12:52:45 +02:00
sun8i_tcon_top.h
sun8i_ui_layer.c drm/sun4i: Constify static structs 2020-08-18 10:49:13 +02:00
sun8i_ui_layer.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun8i_ui_scaler.c
sun8i_ui_scaler.h
sun8i_vi_layer.c Linux 5.9-rc5 2020-09-14 17:19:11 +02:00
sun8i_vi_layer.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00
sun8i_vi_scaler.c
sun8i_vi_scaler.h
sunxi_engine.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152 2019-05-30 11:26:32 -07:00