1
0
Fork 0
alistair23-linux/drivers/gpu/drm/meson
Maxime Ripard 351f950db4
drm/atomic: Pass the full state to CRTC atomic enable/disable
If the CRTC driver ever needs to access the full DRM state, it can't do so
at atomic_enable / atomic_disable time since drm_atomic_helper_swap_state
will have cleared the pointer from the struct drm_crtc_state to the struct
drm_atomic_state before calling those hooks.

In order to allow that, let's pass the full DRM state to atomic_enable and
atomic_disable. 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 dev, state;
identifier crtc, crtc_state;
@@

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

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

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

@@
identifier crtc, old_state;
@@

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

@ crtc_atomic_func @
identifier helpers;
identifier func;
@@

(
static struct drm_crtc_helper_funcs helpers = {
	...,
	.atomic_enable = func,
	...,
};
|
static struct drm_crtc_helper_funcs helpers = {
	...,
	.atomic_disable = 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
	...+>

}

@ 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>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/845aa10ef171fc0ea060495efef142a0c13f7870.1602161031.git-series.maxime@cerno.tech
2020-10-09 09:55:59 +02:00
..
Kconfig Merge remote-tracking branch 'drm/drm-next' into drm-misc-next 2019-05-28 09:39:08 +02:00
Makefile drm/meson: Add AFBCD module driver 2019-12-10 10:09:01 +01:00
meson_crtc.c drm/atomic: Pass the full state to CRTC atomic enable/disable 2020-10-09 09:55:59 +02:00
meson_crtc.h
meson_drv.c drm-misc-next for v5.9: 2020-06-24 15:45:51 +10:00
meson_drv.h drm/meson: overlay: setup overlay for Amlogic FBC 2020-07-03 10:12:29 +02:00
meson_dw_hdmi.c Backmerge remote-tracking branch 'drm/drm-next' into drm-misc-next 2020-06-29 12:16:26 +02:00
meson_dw_hdmi.h drm: meson: global clean-up 2019-08-09 12:06:14 +02:00
meson_osd_afbcd.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
meson_osd_afbcd.h drm/meson: Add AFBCD module driver 2019-12-10 10:09:01 +01:00
meson_overlay.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
meson_overlay.h
meson_plane.c drm/meson: Remove unneeded semicolon 2020-04-28 11:17:27 +02:00
meson_plane.h
meson_rdma.c drm: meson: fix address type confusion 2020-01-08 13:51:56 +01:00
meson_rdma.h drm/meson: add RDMA module driver 2019-12-10 10:08:45 +01:00
meson_registers.h Linux 5.8-rc6 2020-07-24 08:48:05 +10:00
meson_vclk.c drm/meson: add mode selection limits against specific SoC revisions 2020-05-05 10:19:33 +02:00
meson_vclk.h drm/meson: add mode selection limits against specific SoC revisions 2020-05-05 10:19:33 +02:00
meson_venc.c drm/meson: venc: add support for YUV420 setup 2020-03-10 10:51:24 +01:00
meson_venc.h drm/meson: venc: add support for YUV420 setup 2020-03-10 10:51:24 +01:00
meson_venc_cvbs.c drm: Nuke mode->vrefresh 2020-05-27 14:31:42 +03:00
meson_venc_cvbs.h
meson_viu.c drm/meson: viu: fix setting the OSD burst length in VIU_OSD1_FIFO_CTRL_STAT 2020-07-02 10:36:56 +02:00
meson_viu.h drm/meson: viu: add AFBC modules routing functions 2019-12-10 10:09:38 +01:00
meson_vpp.c drm: meson: use match data to detect vpu compatibility 2019-08-22 17:54:05 +02:00
meson_vpp.h drm/meson: drop use of drmP.h 2019-07-17 12:47:57 +02:00