1 From 81c14f160cd4129057f3fec5ff5a0f897f91db54 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Wed, 23 Nov 2022 16:25:59 +0100
4 Subject: [PATCH] drm/vc4: crtc: Pass the device and data in
7 Both users of vc4_crtc_init need the same extra initialization to set
8 the pointer to the platform_device and the CRTC data. Since it's
9 mandatory, let's make them both arguments of vc4_crtc_init().
11 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
12 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
13 Link: https://patchwork.freedesktop.org/patch/msgid/20221123-rpi-kunit-tests-v1-17-051a0bb60a16@cerno.tech
15 drivers/gpu/drm/vc4/vc4_crtc.c | 17 +++++++++++------
16 drivers/gpu/drm/vc4/vc4_drv.h | 6 ++++--
17 drivers/gpu/drm/vc4/vc4_txp.c | 7 ++-----
18 3 files changed, 17 insertions(+), 13 deletions(-)
20 --- a/drivers/gpu/drm/vc4/vc4_crtc.c
21 +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
22 @@ -1318,9 +1318,12 @@ static void vc4_set_crtc_possible_masks(
26 -int vc4_crtc_init(struct drm_device *drm, struct vc4_crtc *vc4_crtc,
27 +int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
28 + struct vc4_crtc *vc4_crtc,
29 + const struct vc4_crtc_data *data,
30 const struct drm_crtc_funcs *crtc_funcs,
31 - const struct drm_crtc_helper_funcs *crtc_helper_funcs)
32 + const struct drm_crtc_helper_funcs *crtc_helper_funcs,
35 struct vc4_dev *vc4 = to_vc4_dev(drm);
36 struct drm_crtc *crtc = &vc4_crtc->base;
37 @@ -1340,6 +1343,9 @@ int vc4_crtc_init(struct drm_device *drm
38 return PTR_ERR(primary_plane);
41 + vc4_crtc->data = data;
42 + vc4_crtc->pdev = pdev;
43 + vc4_crtc->feeds_txp = feeds_txp;
44 spin_lock_init(&vc4_crtc->irq_lock);
45 ret = drmm_crtc_init_with_planes(drm, crtc, primary_plane, NULL,
47 @@ -1402,8 +1408,6 @@ static int vc4_crtc_bind(struct device *
48 pv_data = of_device_get_match_data(dev);
51 - vc4_crtc->data = &pv_data->base;
52 - vc4_crtc->pdev = pdev;
54 vc4_crtc->regs = vc4_ioremap_regs(pdev, 0);
55 if (IS_ERR(vc4_crtc->regs))
56 @@ -1413,8 +1417,9 @@ static int vc4_crtc_bind(struct device *
57 vc4_crtc->regset.regs = crtc_regs;
58 vc4_crtc->regset.nregs = ARRAY_SIZE(crtc_regs);
60 - ret = vc4_crtc_init(drm, vc4_crtc,
61 - &vc4_crtc_funcs, &vc4_crtc_helper_funcs);
62 + ret = vc4_crtc_init(drm, pdev, vc4_crtc, &pv_data->base,
63 + &vc4_crtc_funcs, &vc4_crtc_helper_funcs,
67 vc4_set_crtc_possible_masks(drm, crtc);
68 --- a/drivers/gpu/drm/vc4/vc4_drv.h
69 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
70 @@ -887,9 +887,11 @@ int vc4_bo_debugfs_init(struct drm_minor
72 extern struct platform_driver vc4_crtc_driver;
73 int vc4_crtc_disable_at_boot(struct drm_crtc *crtc);
74 -int vc4_crtc_init(struct drm_device *drm, struct vc4_crtc *vc4_crtc,
75 +int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
76 + struct vc4_crtc *vc4_crtc, const struct vc4_crtc_data *data,
77 const struct drm_crtc_funcs *crtc_funcs,
78 - const struct drm_crtc_helper_funcs *crtc_helper_funcs);
79 + const struct drm_crtc_helper_funcs *crtc_helper_funcs,
81 int vc4_page_flip(struct drm_crtc *crtc,
82 struct drm_framebuffer *fb,
83 struct drm_pending_vblank_event *event,
84 --- a/drivers/gpu/drm/vc4/vc4_txp.c
85 +++ b/drivers/gpu/drm/vc4/vc4_txp.c
86 @@ -509,15 +509,12 @@ static int vc4_txp_bind(struct device *d
87 return PTR_ERR(txp->regs);
89 vc4_crtc = &txp->base;
90 - vc4_crtc->pdev = pdev;
91 - vc4_crtc->data = &vc4_txp_crtc_data;
92 - vc4_crtc->feeds_txp = true;
93 vc4_crtc->regset.base = txp->regs;
94 vc4_crtc->regset.regs = txp_regs;
95 vc4_crtc->regset.nregs = ARRAY_SIZE(txp_regs);
97 - ret = vc4_crtc_init(drm, vc4_crtc,
98 - &vc4_txp_crtc_funcs, &vc4_txp_crtc_helper_funcs);
99 + ret = vc4_crtc_init(drm, pdev, vc4_crtc, &vc4_txp_crtc_data,
100 + &vc4_txp_crtc_funcs, &vc4_txp_crtc_helper_funcs, true);