hc
2024-05-10 9999e48639b3cecb08ffb37358bcba3b48161b29
kernel/drivers/gpu/drm/imx/imx-drm-core.c
....@@ -1,44 +1,38 @@
1
+// SPDX-License-Identifier: GPL-2.0+
12 /*
23 * Freescale i.MX drm driver
34 *
45 * Copyright (C) 2011 Sascha Hauer, Pengutronix
5
- *
6
- * This program is free software; you can redistribute it and/or
7
- * modify it under the terms of the GNU General Public License
8
- * as published by the Free Software Foundation; either version 2
9
- * of the License, or (at your option) any later version.
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
156 */
7
+
168 #include <linux/component.h>
179 #include <linux/device.h>
1810 #include <linux/dma-buf.h>
1911 #include <linux/module.h>
2012 #include <linux/platform_device.h>
21
-#include <drm/drmP.h>
13
+
14
+#include <video/imx-ipu-v3.h>
15
+
2216 #include <drm/drm_atomic.h>
2317 #include <drm/drm_atomic_helper.h>
18
+#include <drm/drm_drv.h>
19
+#include <drm/drm_fb_cma_helper.h>
2420 #include <drm/drm_fb_helper.h>
25
-#include <drm/drm_crtc_helper.h>
2621 #include <drm/drm_gem_cma_helper.h>
2722 #include <drm/drm_gem_framebuffer_helper.h>
28
-#include <drm/drm_fb_cma_helper.h>
29
-#include <drm/drm_plane_helper.h>
23
+#include <drm/drm_managed.h>
3024 #include <drm/drm_of.h>
31
-#include <video/imx-ipu-v3.h>
25
+#include <drm/drm_plane_helper.h>
26
+#include <drm/drm_probe_helper.h>
27
+#include <drm/drm_vblank.h>
3228
3329 #include "imx-drm.h"
3430 #include "ipuv3-plane.h"
3531
3632 #define MAX_CRTC 4
3733
38
-#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
3934 static int legacyfb_depth = 16;
4035 module_param(legacyfb_depth, int, 0444);
41
-#endif
4236
4337 DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops);
4438
....@@ -49,22 +43,12 @@
4943 }
5044 EXPORT_SYMBOL_GPL(imx_drm_connector_destroy);
5145
52
-void imx_drm_encoder_destroy(struct drm_encoder *encoder)
53
-{
54
- drm_encoder_cleanup(encoder);
55
-}
56
-EXPORT_SYMBOL_GPL(imx_drm_encoder_destroy);
57
-
5846 static int imx_drm_atomic_check(struct drm_device *dev,
5947 struct drm_atomic_state *state)
6048 {
6149 int ret;
6250
63
- ret = drm_atomic_helper_check_modeset(dev, state);
64
- if (ret)
65
- return ret;
66
-
67
- ret = drm_atomic_helper_check_planes(dev, state);
51
+ ret = drm_atomic_helper_check(dev, state);
6852 if (ret)
6953 return ret;
7054
....@@ -86,7 +70,6 @@
8670
8771 static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = {
8872 .fb_create = drm_gem_fb_create,
89
- .output_poll_changed = drm_fb_helper_output_poll_changed,
9073 .atomic_check = imx_drm_atomic_check,
9174 .atomic_commit = drm_atomic_helper_commit,
9275 };
....@@ -151,8 +134,8 @@
151134
152135 encoder->possible_crtcs = crtc_mask;
153136
154
- /* FIXME: this is the mask of outputs which can clone this output. */
155
- encoder->possible_clones = ~0;
137
+ /* FIXME: cloning support not clear, disable it all for now */
138
+ encoder->possible_clones = 0;
156139
157140 return 0;
158141 }
....@@ -163,22 +146,8 @@
163146 };
164147
165148 static struct drm_driver imx_drm_driver = {
166
- .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
167
- DRIVER_ATOMIC,
168
- .lastclose = drm_fb_helper_lastclose,
169
- .gem_free_object_unlocked = drm_gem_cma_free_object,
170
- .gem_vm_ops = &drm_gem_cma_vm_ops,
171
- .dumb_create = drm_gem_cma_dumb_create,
172
-
173
- .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
174
- .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
175
- .gem_prime_import = drm_gem_prime_import,
176
- .gem_prime_export = drm_gem_prime_export,
177
- .gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
178
- .gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
179
- .gem_prime_vmap = drm_gem_cma_prime_vmap,
180
- .gem_prime_vunmap = drm_gem_cma_prime_vunmap,
181
- .gem_prime_mmap = drm_gem_cma_prime_mmap,
149
+ .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_ATOMIC,
150
+ DRM_GEM_CMA_DRIVER_OPS,
182151 .ioctls = imx_drm_ioctls,
183152 .num_ioctls = ARRAY_SIZE(imx_drm_ioctls),
184153 .fops = &imx_drm_driver_fops,
....@@ -202,7 +171,7 @@
202171 }
203172
204173 /* Special case for LDB, one device for two channels */
205
- if (of_node_cmp(np->name, "lvds-channel") == 0) {
174
+ if (of_node_name_eq(np, "lvds-channel")) {
206175 np = of_get_parent(np);
207176 of_node_put(np);
208177 }
....@@ -242,8 +211,11 @@
242211 drm->mode_config.funcs = &imx_drm_mode_config_funcs;
243212 drm->mode_config.helper_private = &imx_drm_mode_config_helpers;
244213 drm->mode_config.allow_fb_modifiers = true;
214
+ drm->mode_config.normalize_zpos = true;
245215
246
- drm_mode_config_init(drm);
216
+ ret = drmm_mode_config_init(drm);
217
+ if (ret)
218
+ goto err_kms;
247219
248220 ret = drm_vblank_init(drm, MAX_CRTC);
249221 if (ret)
....@@ -263,33 +235,25 @@
263235 * The fb helper takes copies of key hardware information, so the
264236 * crtcs/connectors/encoders must not change after this point.
265237 */
266
-#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
267238 if (legacyfb_depth != 16 && legacyfb_depth != 32) {
268239 dev_warn(dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n");
269240 legacyfb_depth = 16;
270241 }
271
- ret = drm_fb_cma_fbdev_init(drm, legacyfb_depth, MAX_CRTC);
272
- if (ret)
273
- goto err_unbind;
274
-#endif
275242
276243 drm_kms_helper_poll_init(drm);
277244
278245 ret = drm_dev_register(drm, 0);
279246 if (ret)
280
- goto err_fbhelper;
247
+ goto err_poll_fini;
248
+
249
+ drm_fbdev_generic_setup(drm, legacyfb_depth);
281250
282251 return 0;
283252
284
-err_fbhelper:
253
+err_poll_fini:
285254 drm_kms_helper_poll_fini(drm);
286
-#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
287
- drm_fb_cma_fbdev_fini(drm);
288
-err_unbind:
289
-#endif
290255 component_unbind_all(drm->dev, drm);
291256 err_kms:
292
- drm_mode_config_cleanup(drm);
293257 drm_dev_put(drm);
294258
295259 return ret;
....@@ -303,14 +267,11 @@
303267
304268 drm_kms_helper_poll_fini(drm);
305269
306
- drm_fb_cma_fbdev_fini(drm);
307
-
308
- drm_mode_config_cleanup(drm);
309
-
310270 component_unbind_all(drm->dev, drm);
311
- dev_set_drvdata(dev, NULL);
312271
313272 drm_dev_put(drm);
273
+
274
+ dev_set_drvdata(dev, NULL);
314275 }
315276
316277 static const struct component_master_ops imx_drm_ops = {