linux/drivers/gpu/drm/mediatek
Maxime Ripard 253f28b623
drm: Use state helper instead of CRTC state pointer
Many drivers reference the crtc->pointer in order to get the current CRTC
state in their atomic_begin or atomic_flush hooks, which would be the new
CRTC state in the global atomic state since _swap_state happened when those
hooks are run.

Use the drm_atomic_get_new_crtc_state helper to get that state to make it
more obvious.

This was made using the coccinelle script below:

@ 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,
	...,
};
)

@@
identifier crtc_atomic_func.func;
identifier crtc, state;
symbol crtc_state;
expression e;
@@

  func(struct drm_crtc *crtc, struct drm_atomic_state *state) {
  ...
- struct tegra_dc_state *crtc_state = e;
+ struct tegra_dc_state *dc_state = e;
  <+...
-       crtc_state
+	dc_state
  ...+>
  }

@@
identifier crtc_atomic_func.func;
identifier crtc, state;
symbol crtc_state;
expression e;
@@

  func(struct drm_crtc *crtc, struct drm_atomic_state *state) {
  ...
- struct mtk_crtc_state *crtc_state = e;
+ struct mtk_crtc_state *mtk_crtc_state = e;
  <+...
-       crtc_state
+	mtk_crtc_state
  ...+>
  }

@ replaces_new_state @
identifier crtc_atomic_func.func;
identifier crtc, state, crtc_state;
@@

  func(struct drm_crtc *crtc, struct drm_atomic_state *state) {
  ...
- struct drm_crtc_state *crtc_state = crtc->state;
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
  ...
 }

@@
identifier crtc_atomic_func.func;
identifier crtc, state, crtc_state;
@@

  func(struct drm_crtc *crtc, struct drm_atomic_state *state) {
  struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
  ...
- crtc->state
+ crtc_state
  ...
 }

@ adds_new_state @
identifier crtc_atomic_func.func;
identifier crtc, state;
@@

  func(struct drm_crtc *crtc, struct drm_atomic_state *state) {
+ struct drm_crtc_state *crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
  ...
- crtc->state
+ crtc_state
  ...
 }

@ include depends on adds_new_state || replaces_new_state @
@@

 #include <drm/drm_atomic.h>

@ no_include depends on !include && (adds_new_state || replaces_new_state) @
@@

+ #include <drm/drm_atomic.h>
  #include <drm/...>

Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Acked-by: Thomas Zimmermann <tzimmermann@suse.de>
Cc: "James (Qian) Wang" <james.qian.wang@arm.com>
Cc: Liviu Dudau <liviu.dudau@arm.com>
Cc: Mihail Atanassov <mihail.atanassov@arm.com>
Cc: Brian Starkey <brian.starkey@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Paul Cercueil <paul@crapouillou.net>
Cc: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Sandy Huang <hjc@rock-chips.com>
Cc: "Heiko Stübner" <heiko@sntech.de>
Cc: Thierry Reding <thierry.reding@gmail.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20201105164518.392891-1-maxime@cerno.tech
2020-11-10 12:41:06 +01:00
..
Kconfig phy: mediatek: Move mtk_hdmi_phy driver into drivers/phy/mediatek folder 2020-09-06 07:03:21 +08:00
Makefile phy: mediatek: Move mtk_hdmi_phy driver into drivers/phy/mediatek folder 2020-09-06 07:03:21 +08:00
mtk_cec.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
mtk_cec.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
mtk_disp_color.c drm/mediatek: Omit warning on probe defers 2020-04-13 13:01:16 +02:00
mtk_disp_ovl.c drm/mediatek: Omit warning on probe defers 2020-04-13 13:01:16 +02:00
mtk_disp_rdma.c drm/mediatek: Omit warning on probe defers 2020-04-13 13:01:16 +02:00
mtk_dpi_regs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
mtk_dpi.c drm/mediatek: mtk_dpi: Convert to bridge driver 2020-09-13 09:19:24 +08:00
mtk_drm_crtc.c drm: Use state helper instead of CRTC state pointer 2020-11-10 12:41:06 +01:00
mtk_drm_crtc.h drm/mediatek: update cursors by using async atomic update 2019-12-20 16:19:11 +08:00
mtk_drm_ddp_comp.c drm next for 5.10-rc1 2020-10-15 10:46:16 -07:00
mtk_drm_ddp_comp.h drm/mediatek: dpi/dsi: Change the getting possible_crtc way 2020-08-28 07:10:05 +08:00
mtk_drm_ddp.c soc / drm: mediatek: Move routing control to mmsys device 2020-04-13 13:01:16 +02:00
mtk_drm_ddp.h soc / drm: mediatek: Move routing control to mmsys device 2020-04-13 13:01:16 +02:00
mtk_drm_drv.c drm/<drivers>: Constify struct drm_driver 2020-11-06 10:31:26 +01:00
mtk_drm_drv.h soc / drm: mediatek: Move routing control to mmsys device 2020-04-13 13:01:16 +02:00
mtk_drm_gem.c drm/mediatek: Use struct dma_buf_map in GEM vmap ops 2020-11-10 10:39:16 +01:00
mtk_drm_gem.h drm/mediatek: Use struct dma_buf_map in GEM vmap ops 2020-11-10 10:39:16 +01:00
mtk_drm_plane.c drm/mediatek: Check plane visibility in atomic_update 2020-06-27 10:08:03 +08:00
mtk_drm_plane.h drm/mediatek: update cursors by using async atomic update 2019-12-20 16:19:11 +08:00
mtk_dsi.c drm next for 5.10-rc1 2020-10-15 10:46:16 -07:00
mtk_hdmi_ddc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
mtk_hdmi_regs.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 174 2019-05-30 11:26:41 -07:00
mtk_hdmi.c drm next for 5.10-rc1 2020-10-15 10:46:16 -07:00
mtk_hdmi.h drm/mediatek: Separate mtk_hdmi_phy to an independent module 2020-09-06 07:02:54 +08:00
mtk_mipi_tx.c drm/mediatek: config mipitx impedance with calibration data 2020-04-22 07:10:36 +08:00
mtk_mipi_tx.h drm/mediatek: config mipitx impedance with calibration data 2020-04-22 07:10:36 +08:00
mtk_mt8173_mipi_tx.c drm/mediatek: separate mipi_tx to different file 2019-10-07 12:29:37 +08:00
mtk_mt8183_mipi_tx.c drm/mediatek: config mipitx impedance with calibration data 2020-04-22 07:10:36 +08:00