OpenCloudOS-Kernel/drivers/gpu/drm/tegra
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/tegra: Unconditionally select IOMMU_IOVA 2019-11-01 10:49:29 +01:00
Makefile drm/tegra: Move drm_dp_link helpers to Tegra DRM 2019-10-23 18:22:10 +02:00
dc.c drm/atomic: Pass the full state to CRTC atomic begin and flush 2020-11-02 12:37:49 +01:00
dc.h drm/tegra: plane: Support horizontal reflection 2020-07-17 16:06:17 +02:00
dp.c drm/tegra: sor: Add DisplayPort support 2019-10-28 11:18:54 +01:00
dp.h drm/tegra: dp: Add DisplayPort link training helper 2019-10-28 11:18:53 +01:00
dpaux.c drm/tegra: Clean up GPIO includes 2020-04-17 17:16:22 +02:00
dpaux.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
drm.c drm/tegra: Introduce GEM object functions 2020-09-25 09:21:23 +02:00
drm.h drm/tegra: output: Support DRM bridges 2020-09-17 12:30:11 +02:00
dsi.c drm next for 5.10-rc1 2020-10-15 10:46:16 -07:00
dsi.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
falcon.c drm/tegra: falcon: Clarify address usage 2019-10-29 15:04:36 +01:00
falcon.h drm/tegra: falcon: Clarify address usage 2019-10-29 15:04:36 +01:00
fb.c drm/tegra: remove _unlocked suffix in drm_gem_object_put_unlocked 2020-05-19 22:31:35 +01:00
gem.c Merge drm/drm-next into drm-misc-next 2020-11-02 11:17:54 +01:00
gem.h drm/tegra: gem: Rename paddr -> iova 2019-10-28 11:18:38 +01:00
gr2d.c drm/tegra: gr2d: Add tiled PATBASE address register 2020-07-17 16:06:16 +02:00
gr2d.h drm/tegra: gr2d: Add tiled PATBASE address register 2020-07-17 16:06:16 +02:00
gr3d.c drm/tegra: gr3d: Assert reset before power-gating 2020-07-17 16:06:15 +02:00
gr3d.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
hda.c drm/tegra: hda: Extract HDA format parsing code 2019-01-16 13:10:20 +01:00
hda.h drm/tegra: hda: Extract HDA format parsing code 2019-01-16 13:10:20 +01:00
hdmi.c drm/tegra: Clean up GPIO includes 2020-04-17 17:16:22 +02:00
hdmi.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
hub.c drm/tegra: hub: Register child devices 2020-06-16 13:46:19 +02:00
hub.h drm/tegra: Do not implement runtime PM 2020-01-10 16:37:43 +01:00
mipi-phy.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
mipi-phy.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
output.c drm/tegra: Changes for v5.10-rc1 2020-09-23 08:37:12 +10:00
plane.c drm: tegra: fix common struct sg_table related issues 2020-09-10 08:18:35 +02:00
plane.h drm/tegra: plane: Support horizontal reflection 2020-07-17 16:06:17 +02:00
rgb.c drm/tegra: output: rgb: Wrap directly-connected panel into DRM bridge 2020-09-17 12:31:18 +02:00
sor.c drm/tegra: Properly reference count the DDC I2C adapter 2020-09-17 12:27:11 +02:00
sor.h drm/tegra: sor: Add DisplayPort support 2019-10-28 11:18:54 +01:00
trace.c
trace.h
vic.c gpu: host1x: Rename "parent" to "host" 2020-01-10 16:37:38 +01:00
vic.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00