aaec147cd1d785c4ab2d8f1b30ef8464f5234c56
[openwrt/staging/ansuel.git] /
1 From 4e2742244ff3084dfcd465180d7b7b843af13854 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Mon, 14 Nov 2022 14:11:41 +0100
4 Subject: [PATCH] drm/vc4: crtc: Introduce a lower-level crtc init
5 helper
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 The current vc4_crtc_init() helper assumes that we will be using
11 hardware planes and calls vc4_plane_init().
12
13 While it's a reasonable assumption, we'll want to mock the plane and
14 thus provide our own. Let's create a helper that will take the plane as
15 an argument.
16
17 Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
18 Reviewed-by: MaĆ­ra Canal <mcanal@igalia.com>
19 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
20 ---
21 drivers/gpu/drm/vc4/vc4_crtc.c | 70 +++++++++++++++++++++++++---------
22 drivers/gpu/drm/vc4/vc4_drv.h | 6 +++
23 2 files changed, 57 insertions(+), 19 deletions(-)
24
25 --- a/drivers/gpu/drm/vc4/vc4_crtc.c
26 +++ b/drivers/gpu/drm/vc4/vc4_crtc.c
27 @@ -1326,31 +1326,38 @@ static void vc4_set_crtc_possible_masks(
28 }
29 }
30
31 -int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
32 - struct vc4_crtc *vc4_crtc,
33 - const struct vc4_crtc_data *data,
34 - const struct drm_crtc_funcs *crtc_funcs,
35 - const struct drm_crtc_helper_funcs *crtc_helper_funcs,
36 - bool feeds_txp)
37 +/**
38 + * __vc4_crtc_init - Initializes a CRTC
39 + * @drm: DRM Device
40 + * @pdev: CRTC Platform Device
41 + * @vc4_crtc: CRTC Object to Initialize
42 + * @data: Configuration data associated with this CRTC
43 + * @primary_plane: Primary plane for CRTC
44 + * @crtc_funcs: Callbacks for the new CRTC
45 + * @crtc_helper_funcs: Helper Callbacks for the new CRTC
46 + * @feeds_txp: Is this CRTC connected to the TXP?
47 + *
48 + * Initializes our private CRTC structure. This function is mostly
49 + * relevant for KUnit testing, all other users should use
50 + * vc4_crtc_init() instead.
51 + *
52 + * Returns:
53 + * 0 on success, a negative error code on failure.
54 + */
55 +int __vc4_crtc_init(struct drm_device *drm,
56 + struct platform_device *pdev,
57 + struct vc4_crtc *vc4_crtc,
58 + const struct vc4_crtc_data *data,
59 + struct drm_plane *primary_plane,
60 + const struct drm_crtc_funcs *crtc_funcs,
61 + const struct drm_crtc_helper_funcs *crtc_helper_funcs,
62 + bool feeds_txp)
63 {
64 struct vc4_dev *vc4 = to_vc4_dev(drm);
65 struct drm_crtc *crtc = &vc4_crtc->base;
66 - struct drm_plane *primary_plane;
67 unsigned int i;
68 int ret;
69
70 - /* For now, we create just the primary and the legacy cursor
71 - * planes. We should be able to stack more planes on easily,
72 - * but to do that we would need to compute the bandwidth
73 - * requirement of the plane configuration, and reject ones
74 - * that will take too much.
75 - */
76 - primary_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_PRIMARY, 0);
77 - if (IS_ERR(primary_plane)) {
78 - dev_err(drm->dev, "failed to construct primary plane\n");
79 - return PTR_ERR(primary_plane);
80 - }
81 -
82 vc4_crtc->data = data;
83 vc4_crtc->pdev = pdev;
84 vc4_crtc->feeds_txp = feeds_txp;
85 @@ -1399,6 +1406,31 @@ int vc4_crtc_init(struct drm_device *drm
86 return 0;
87 }
88
89 +int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
90 + struct vc4_crtc *vc4_crtc,
91 + const struct vc4_crtc_data *data,
92 + const struct drm_crtc_funcs *crtc_funcs,
93 + const struct drm_crtc_helper_funcs *crtc_helper_funcs,
94 + bool feeds_txp)
95 +{
96 + struct drm_plane *primary_plane;
97 +
98 + /* For now, we create just the primary and the legacy cursor
99 + * planes. We should be able to stack more planes on easily,
100 + * but to do that we would need to compute the bandwidth
101 + * requirement of the plane configuration, and reject ones
102 + * that will take too much.
103 + */
104 + primary_plane = vc4_plane_init(drm, DRM_PLANE_TYPE_PRIMARY, 0);
105 + if (IS_ERR(primary_plane)) {
106 + dev_err(drm->dev, "failed to construct primary plane\n");
107 + return PTR_ERR(primary_plane);
108 + }
109 +
110 + return __vc4_crtc_init(drm, pdev, vc4_crtc, data, primary_plane,
111 + crtc_funcs, crtc_helper_funcs, feeds_txp);
112 +}
113 +
114 static int vc4_crtc_bind(struct device *dev, struct device *master, void *data)
115 {
116 struct platform_device *pdev = to_platform_device(dev);
117 --- a/drivers/gpu/drm/vc4/vc4_drv.h
118 +++ b/drivers/gpu/drm/vc4/vc4_drv.h
119 @@ -912,6 +912,12 @@ int vc4_bo_debugfs_init(struct drm_minor
120 /* vc4_crtc.c */
121 extern struct platform_driver vc4_crtc_driver;
122 int vc4_crtc_disable_at_boot(struct drm_crtc *crtc);
123 +int __vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
124 + struct vc4_crtc *vc4_crtc, const struct vc4_crtc_data *data,
125 + struct drm_plane *primary_plane,
126 + const struct drm_crtc_funcs *crtc_funcs,
127 + const struct drm_crtc_helper_funcs *crtc_helper_funcs,
128 + bool feeds_txp);
129 int vc4_crtc_init(struct drm_device *drm, struct platform_device *pdev,
130 struct vc4_crtc *vc4_crtc, const struct vc4_crtc_data *data,
131 const struct drm_crtc_funcs *crtc_funcs,