OpenCloudOS-Kernel/drivers/gpu/drm/msm
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
..
adreno drm/msm: fix 32b build warns 2020-09-29 10:20:51 +10:00
disp drm/atomic: Pass the full state to CRTC atomic begin and flush 2020-11-02 12:37:49 +01:00
dp drm/msm/dp: fix incorrect function prototype of dp_debug_get() 2020-09-25 20:31:06 -07:00
dsi drm/msm: fix 32b build warns 2020-09-29 10:20:51 +10:00
edp drm/msm: sync generated headers 2020-07-31 06:46:16 -07:00
hdmi drm/msm: sync generated headers 2020-07-31 06:46:16 -07:00
Kconfig drm/msm: Remove depends on interconnect 2020-09-20 10:48:18 -07:00
Makefile drm/msm/dp: Use qmp phy for DP PLL and PHY 2020-09-15 10:54:35 -07:00
NOTES
msm_atomic.c drm/msm: enable vblank during atomic commits 2020-08-21 22:30:17 -07:00
msm_atomic_trace.h drm/msm: add atomic traces 2019-09-03 16:17:02 -07:00
msm_atomic_tracepoints.c drm/msm: add atomic traces 2019-09-03 16:17:02 -07:00
msm_debugfs.c drm: convert .debugfs_init() hook to return void. 2020-03-18 17:53:28 +01:00
msm_debugfs.h drm: convert .debugfs_init() hook to return void. 2020-03-18 17:53:28 +01:00
msm_drv.c Merge drm/drm-next into drm-misc-next 2020-11-02 11:17:54 +01:00
msm_drv.h Merge drm/drm-next into drm-misc-next 2020-11-02 11:17:54 +01:00
msm_fb.c drm/msm: remove _unlocked suffix in drm_gem_object_put_unlocked 2020-05-19 22:31:33 +01:00
msm_fbdev.c drm: Remove drm_fb_helper add, add all and remove connector calls 2020-03-06 14:19:58 +01:00
msm_fence.c
msm_fence.h
msm_gem.c Merge drm/drm-next into drm-misc-next 2020-11-02 11:17:54 +01:00
msm_gem.h drm/msm: Fix premature purging of BO 2020-09-22 08:28:15 -07:00
msm_gem_prime.c drm: allow limiting the scatter list size. 2020-09-09 07:58:56 +02:00
msm_gem_shrinker.c drm/msm: Convert shrinker msgs to tracepoints 2020-09-09 15:25:54 -07:00
msm_gem_submit.c drm/msm: Drop context arg to gpu->submit() 2020-09-12 10:45:56 -07:00
msm_gem_vma.c drm/msm: Leave inuse count intact on map failure 2020-09-22 08:28:15 -07:00
msm_gpu.c drm/msm: Fix premature purging of BO 2020-09-22 08:28:15 -07:00
msm_gpu.h drm/msm: Allow a5xx to mark the RPTR shadow as privileged 2020-09-15 10:47:44 -07:00
msm_gpu_trace.h drm/msm/gpu: Add suspend/resume tracepoints 2020-09-12 09:59:58 -07:00
msm_gpu_tracepoints.c
msm_gpummu.c Merge tag 'drm-msm-next-2020-09-27' of https://gitlab.freedesktop.org/drm/msm into drm-next 2020-09-29 10:18:49 +10:00
msm_iommu.c drm next for 5.10-rc1 2020-10-15 10:46:16 -07:00
msm_kms.h drm/msm/dpu: async commit support 2019-09-03 16:17:01 -07:00
msm_mmu.h drm/msm: Add support to create a local pagetable 2020-09-12 10:48:32 -07:00
msm_perf.c drm/msm: drop use of drmP.h 2019-09-03 16:16:57 -07:00
msm_rd.c drm/msm: Fix undefined "rd_full" link error 2020-05-18 09:26:32 -07:00
msm_ringbuffer.c drm/msm: Enable expanded apriv support for a650 2020-09-04 12:14:07 -07:00
msm_ringbuffer.h drm/msm/a6xx: Add support for per-instance pagetables 2020-09-12 10:48:32 -07:00
msm_submitqueue.c drm/msm: Add a context pointer to the submitqueue 2020-09-12 10:45:56 -07:00