.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
---|
1 | 2 | /* |
---|
2 | 3 | * Freescale i.MX drm driver |
---|
3 | 4 | * |
---|
4 | 5 | * 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 | | - * |
---|
15 | 6 | */ |
---|
| 7 | + |
---|
16 | 8 | #include <linux/component.h> |
---|
17 | 9 | #include <linux/device.h> |
---|
18 | 10 | #include <linux/dma-buf.h> |
---|
19 | 11 | #include <linux/module.h> |
---|
20 | 12 | #include <linux/platform_device.h> |
---|
21 | | -#include <drm/drmP.h> |
---|
| 13 | + |
---|
| 14 | +#include <video/imx-ipu-v3.h> |
---|
| 15 | + |
---|
22 | 16 | #include <drm/drm_atomic.h> |
---|
23 | 17 | #include <drm/drm_atomic_helper.h> |
---|
| 18 | +#include <drm/drm_drv.h> |
---|
| 19 | +#include <drm/drm_fb_cma_helper.h> |
---|
24 | 20 | #include <drm/drm_fb_helper.h> |
---|
25 | | -#include <drm/drm_crtc_helper.h> |
---|
26 | 21 | #include <drm/drm_gem_cma_helper.h> |
---|
27 | 22 | #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> |
---|
30 | 24 | #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> |
---|
32 | 28 | |
---|
33 | 29 | #include "imx-drm.h" |
---|
34 | 30 | #include "ipuv3-plane.h" |
---|
35 | 31 | |
---|
36 | 32 | #define MAX_CRTC 4 |
---|
37 | 33 | |
---|
38 | | -#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) |
---|
39 | 34 | static int legacyfb_depth = 16; |
---|
40 | 35 | module_param(legacyfb_depth, int, 0444); |
---|
41 | | -#endif |
---|
42 | 36 | |
---|
43 | 37 | DEFINE_DRM_GEM_CMA_FOPS(imx_drm_driver_fops); |
---|
44 | 38 | |
---|
.. | .. |
---|
49 | 43 | } |
---|
50 | 44 | EXPORT_SYMBOL_GPL(imx_drm_connector_destroy); |
---|
51 | 45 | |
---|
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 | | - |
---|
58 | 46 | static int imx_drm_atomic_check(struct drm_device *dev, |
---|
59 | 47 | struct drm_atomic_state *state) |
---|
60 | 48 | { |
---|
61 | 49 | int ret; |
---|
62 | 50 | |
---|
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); |
---|
68 | 52 | if (ret) |
---|
69 | 53 | return ret; |
---|
70 | 54 | |
---|
.. | .. |
---|
86 | 70 | |
---|
87 | 71 | static const struct drm_mode_config_funcs imx_drm_mode_config_funcs = { |
---|
88 | 72 | .fb_create = drm_gem_fb_create, |
---|
89 | | - .output_poll_changed = drm_fb_helper_output_poll_changed, |
---|
90 | 73 | .atomic_check = imx_drm_atomic_check, |
---|
91 | 74 | .atomic_commit = drm_atomic_helper_commit, |
---|
92 | 75 | }; |
---|
.. | .. |
---|
151 | 134 | |
---|
152 | 135 | encoder->possible_crtcs = crtc_mask; |
---|
153 | 136 | |
---|
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; |
---|
156 | 139 | |
---|
157 | 140 | return 0; |
---|
158 | 141 | } |
---|
.. | .. |
---|
163 | 146 | }; |
---|
164 | 147 | |
---|
165 | 148 | 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, |
---|
182 | 151 | .ioctls = imx_drm_ioctls, |
---|
183 | 152 | .num_ioctls = ARRAY_SIZE(imx_drm_ioctls), |
---|
184 | 153 | .fops = &imx_drm_driver_fops, |
---|
.. | .. |
---|
202 | 171 | } |
---|
203 | 172 | |
---|
204 | 173 | /* 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")) { |
---|
206 | 175 | np = of_get_parent(np); |
---|
207 | 176 | of_node_put(np); |
---|
208 | 177 | } |
---|
.. | .. |
---|
242 | 211 | drm->mode_config.funcs = &imx_drm_mode_config_funcs; |
---|
243 | 212 | drm->mode_config.helper_private = &imx_drm_mode_config_helpers; |
---|
244 | 213 | drm->mode_config.allow_fb_modifiers = true; |
---|
| 214 | + drm->mode_config.normalize_zpos = true; |
---|
245 | 215 | |
---|
246 | | - drm_mode_config_init(drm); |
---|
| 216 | + ret = drmm_mode_config_init(drm); |
---|
| 217 | + if (ret) |
---|
| 218 | + goto err_kms; |
---|
247 | 219 | |
---|
248 | 220 | ret = drm_vblank_init(drm, MAX_CRTC); |
---|
249 | 221 | if (ret) |
---|
.. | .. |
---|
263 | 235 | * The fb helper takes copies of key hardware information, so the |
---|
264 | 236 | * crtcs/connectors/encoders must not change after this point. |
---|
265 | 237 | */ |
---|
266 | | -#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) |
---|
267 | 238 | if (legacyfb_depth != 16 && legacyfb_depth != 32) { |
---|
268 | 239 | dev_warn(dev, "Invalid legacyfb_depth. Defaulting to 16bpp\n"); |
---|
269 | 240 | legacyfb_depth = 16; |
---|
270 | 241 | } |
---|
271 | | - ret = drm_fb_cma_fbdev_init(drm, legacyfb_depth, MAX_CRTC); |
---|
272 | | - if (ret) |
---|
273 | | - goto err_unbind; |
---|
274 | | -#endif |
---|
275 | 242 | |
---|
276 | 243 | drm_kms_helper_poll_init(drm); |
---|
277 | 244 | |
---|
278 | 245 | ret = drm_dev_register(drm, 0); |
---|
279 | 246 | if (ret) |
---|
280 | | - goto err_fbhelper; |
---|
| 247 | + goto err_poll_fini; |
---|
| 248 | + |
---|
| 249 | + drm_fbdev_generic_setup(drm, legacyfb_depth); |
---|
281 | 250 | |
---|
282 | 251 | return 0; |
---|
283 | 252 | |
---|
284 | | -err_fbhelper: |
---|
| 253 | +err_poll_fini: |
---|
285 | 254 | 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 |
---|
290 | 255 | component_unbind_all(drm->dev, drm); |
---|
291 | 256 | err_kms: |
---|
292 | | - drm_mode_config_cleanup(drm); |
---|
293 | 257 | drm_dev_put(drm); |
---|
294 | 258 | |
---|
295 | 259 | return ret; |
---|
.. | .. |
---|
303 | 267 | |
---|
304 | 268 | drm_kms_helper_poll_fini(drm); |
---|
305 | 269 | |
---|
306 | | - drm_fb_cma_fbdev_fini(drm); |
---|
307 | | - |
---|
308 | | - drm_mode_config_cleanup(drm); |
---|
309 | | - |
---|
310 | 270 | component_unbind_all(drm->dev, drm); |
---|
311 | | - dev_set_drvdata(dev, NULL); |
---|
312 | 271 | |
---|
313 | 272 | drm_dev_put(drm); |
---|
| 273 | + |
---|
| 274 | + dev_set_drvdata(dev, NULL); |
---|
314 | 275 | } |
---|
315 | 276 | |
---|
316 | 277 | static const struct component_master_ops imx_drm_ops = { |
---|