hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/gpu/drm/omapdrm/omap_drv.c
....@@ -1,26 +1,26 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
34 * Author: Rob Clark <rob@ti.com>
4
- *
5
- * This program is free software; you can redistribute it and/or modify it
6
- * under the terms of the GNU General Public License version 2 as published by
7
- * the Free Software Foundation.
8
- *
9
- * This program is distributed in the hope that it will be useful, but WITHOUT
10
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
- * more details.
13
- *
14
- * You should have received a copy of the GNU General Public License along with
15
- * this program. If not, see <http://www.gnu.org/licenses/>.
165 */
176
7
+#include <linux/dma-mapping.h>
8
+#include <linux/platform_device.h>
9
+#include <linux/sort.h>
1810 #include <linux/sys_soc.h>
1911
2012 #include <drm/drm_atomic.h>
2113 #include <drm/drm_atomic_helper.h>
22
-#include <drm/drm_crtc_helper.h>
14
+#include <drm/drm_bridge.h>
15
+#include <drm/drm_bridge_connector.h>
16
+#include <drm/drm_drv.h>
2317 #include <drm/drm_fb_helper.h>
18
+#include <drm/drm_file.h>
19
+#include <drm/drm_ioctl.h>
20
+#include <drm/drm_panel.h>
21
+#include <drm/drm_prime.h>
22
+#include <drm/drm_probe_helper.h>
23
+#include <drm/drm_vblank.h>
2424
2525 #include "omap_dmm_tiler.h"
2626 #include "omap_drv.h"
....@@ -127,65 +127,66 @@
127127 .atomic_commit = drm_atomic_helper_commit,
128128 };
129129
130
-static int get_connector_type(struct omap_dss_device *dssdev)
130
+static void omap_disconnect_pipelines(struct drm_device *ddev)
131131 {
132
- switch (dssdev->type) {
133
- case OMAP_DISPLAY_TYPE_HDMI:
134
- return DRM_MODE_CONNECTOR_HDMIA;
135
- case OMAP_DISPLAY_TYPE_DVI:
136
- return DRM_MODE_CONNECTOR_DVID;
137
- case OMAP_DISPLAY_TYPE_DSI:
138
- return DRM_MODE_CONNECTOR_DSI;
139
- case OMAP_DISPLAY_TYPE_DPI:
140
- case OMAP_DISPLAY_TYPE_DBI:
141
- return DRM_MODE_CONNECTOR_DPI;
142
- case OMAP_DISPLAY_TYPE_VENC:
143
- /* TODO: This could also be composite */
144
- return DRM_MODE_CONNECTOR_SVIDEO;
145
- case OMAP_DISPLAY_TYPE_SDI:
146
- return DRM_MODE_CONNECTOR_LVDS;
147
- default:
148
- return DRM_MODE_CONNECTOR_Unknown;
132
+ struct omap_drm_private *priv = ddev->dev_private;
133
+ unsigned int i;
134
+
135
+ for (i = 0; i < priv->num_pipes; i++) {
136
+ struct omap_drm_pipeline *pipe = &priv->pipes[i];
137
+
138
+ omapdss_device_disconnect(NULL, pipe->output);
139
+
140
+ omapdss_device_put(pipe->output);
141
+ pipe->output = NULL;
149142 }
143
+
144
+ memset(&priv->channels, 0, sizeof(priv->channels));
145
+
146
+ priv->num_pipes = 0;
150147 }
151148
152
-static void omap_disconnect_dssdevs(void)
149
+static int omap_connect_pipelines(struct drm_device *ddev)
153150 {
154
- struct omap_dss_device *dssdev = NULL;
155
-
156
- for_each_dss_dev(dssdev)
157
- dssdev->driver->disconnect(dssdev);
158
-}
159
-
160
-static int omap_connect_dssdevs(void)
161
-{
151
+ struct omap_drm_private *priv = ddev->dev_private;
152
+ struct omap_dss_device *output = NULL;
162153 int r;
163
- struct omap_dss_device *dssdev = NULL;
164154
165
- if (!omapdss_stack_is_ready())
166
- return -EPROBE_DEFER;
167
-
168
- for_each_dss_dev(dssdev) {
169
- r = dssdev->driver->connect(dssdev);
155
+ for_each_dss_output(output) {
156
+ r = omapdss_device_connect(priv->dss, NULL, output);
170157 if (r == -EPROBE_DEFER) {
171
- omap_dss_put_device(dssdev);
172
- goto cleanup;
158
+ omapdss_device_put(output);
159
+ return r;
173160 } else if (r) {
174
- dev_warn(dssdev->dev, "could not connect display: %s\n",
175
- dssdev->name);
161
+ dev_warn(output->dev, "could not connect output %s\n",
162
+ output->name);
163
+ } else {
164
+ struct omap_drm_pipeline *pipe;
165
+
166
+ pipe = &priv->pipes[priv->num_pipes++];
167
+ pipe->output = omapdss_device_get(output);
168
+
169
+ if (priv->num_pipes == ARRAY_SIZE(priv->pipes)) {
170
+ /* To balance the 'for_each_dss_output' loop */
171
+ omapdss_device_put(output);
172
+ break;
173
+ }
176174 }
177175 }
178176
179177 return 0;
178
+}
180179
181
-cleanup:
182
- /*
183
- * if we are deferring probe, we disconnect the devices we previously
184
- * connected
185
- */
186
- omap_disconnect_dssdevs();
180
+static int omap_compare_pipelines(const void *a, const void *b)
181
+{
182
+ const struct omap_drm_pipeline *pipe1 = a;
183
+ const struct omap_drm_pipeline *pipe2 = b;
187184
188
- return r;
185
+ if (pipe1->alias_id > pipe2->alias_id)
186
+ return 1;
187
+ else if (pipe1->alias_id < pipe2->alias_id)
188
+ return -1;
189
+ return 0;
189190 }
190191
191192 static int omap_modeset_init_properties(struct drm_device *dev)
....@@ -201,15 +202,40 @@
201202 return 0;
202203 }
203204
205
+static int omap_display_id(struct omap_dss_device *output)
206
+{
207
+ struct device_node *node = NULL;
208
+
209
+ if (output->next) {
210
+ struct omap_dss_device *display = output;
211
+
212
+ while (display->next)
213
+ display = display->next;
214
+
215
+ node = display->dev->of_node;
216
+ } else if (output->bridge) {
217
+ struct drm_bridge *bridge = output->bridge;
218
+
219
+ while (drm_bridge_get_next_bridge(bridge))
220
+ bridge = drm_bridge_get_next_bridge(bridge);
221
+
222
+ node = bridge->of_node;
223
+ }
224
+
225
+ return node ? of_alias_get_id(node, "display") : -ENODEV;
226
+}
227
+
204228 static int omap_modeset_init(struct drm_device *dev)
205229 {
206230 struct omap_drm_private *priv = dev->dev_private;
207
- struct omap_dss_device *dssdev = NULL;
208231 int num_ovls = priv->dispc_ops->get_num_ovls(priv->dispc);
209232 int num_mgrs = priv->dispc_ops->get_num_mgrs(priv->dispc);
210
- int num_crtcs, crtc_idx, plane_idx;
233
+ unsigned int i;
211234 int ret;
212235 u32 plane_crtc_mask;
236
+
237
+ if (!omapdss_stack_is_ready())
238
+ return -EPROBE_DEFER;
213239
214240 drm_mode_config_init(dev);
215241
....@@ -225,87 +251,114 @@
225251 * configuration does not match the expectations or exceeds
226252 * the available resources, the configuration is rejected.
227253 */
228
- num_crtcs = 0;
229
- for_each_dss_dev(dssdev)
230
- if (omapdss_device_is_connected(dssdev))
231
- num_crtcs++;
254
+ ret = omap_connect_pipelines(dev);
255
+ if (ret < 0)
256
+ return ret;
232257
233
- if (num_crtcs > num_mgrs || num_crtcs > num_ovls ||
234
- num_crtcs > ARRAY_SIZE(priv->crtcs) ||
235
- num_crtcs > ARRAY_SIZE(priv->planes) ||
236
- num_crtcs > ARRAY_SIZE(priv->encoders) ||
237
- num_crtcs > ARRAY_SIZE(priv->connectors)) {
258
+ if (priv->num_pipes > num_mgrs || priv->num_pipes > num_ovls) {
238259 dev_err(dev->dev, "%s(): Too many connected displays\n",
239260 __func__);
240261 return -EINVAL;
241262 }
242263
243
- /* All planes can be put to any CRTC */
244
- plane_crtc_mask = (1 << num_crtcs) - 1;
264
+ /* Create all planes first. They can all be put to any CRTC. */
265
+ plane_crtc_mask = (1 << priv->num_pipes) - 1;
245266
246
- dssdev = NULL;
247
-
248
- crtc_idx = 0;
249
- plane_idx = 0;
250
- for_each_dss_dev(dssdev) {
251
- struct drm_connector *connector;
252
- struct drm_encoder *encoder;
253
- struct drm_plane *plane;
254
- struct drm_crtc *crtc;
255
-
256
- if (!omapdss_device_is_connected(dssdev))
257
- continue;
258
-
259
- encoder = omap_encoder_init(dev, dssdev);
260
- if (!encoder)
261
- return -ENOMEM;
262
-
263
- connector = omap_connector_init(dev,
264
- get_connector_type(dssdev), dssdev, encoder);
265
- if (!connector)
266
- return -ENOMEM;
267
-
268
- plane = omap_plane_init(dev, plane_idx, DRM_PLANE_TYPE_PRIMARY,
269
- plane_crtc_mask);
270
- if (IS_ERR(plane))
271
- return PTR_ERR(plane);
272
-
273
- crtc = omap_crtc_init(dev, plane, dssdev);
274
- if (IS_ERR(crtc))
275
- return PTR_ERR(crtc);
276
-
277
- drm_connector_attach_encoder(connector, encoder);
278
- encoder->possible_crtcs = (1 << crtc_idx);
279
-
280
- priv->crtcs[priv->num_crtcs++] = crtc;
281
- priv->planes[priv->num_planes++] = plane;
282
- priv->encoders[priv->num_encoders++] = encoder;
283
- priv->connectors[priv->num_connectors++] = connector;
284
-
285
- plane_idx++;
286
- crtc_idx++;
287
- }
288
-
289
- /*
290
- * Create normal planes for the remaining overlays:
291
- */
292
- for (; plane_idx < num_ovls; plane_idx++) {
267
+ for (i = 0; i < num_ovls; i++) {
268
+ enum drm_plane_type type = i < priv->num_pipes
269
+ ? DRM_PLANE_TYPE_PRIMARY
270
+ : DRM_PLANE_TYPE_OVERLAY;
293271 struct drm_plane *plane;
294272
295273 if (WARN_ON(priv->num_planes >= ARRAY_SIZE(priv->planes)))
296274 return -EINVAL;
297275
298
- plane = omap_plane_init(dev, plane_idx, DRM_PLANE_TYPE_OVERLAY,
299
- plane_crtc_mask);
276
+ plane = omap_plane_init(dev, i, type, plane_crtc_mask);
300277 if (IS_ERR(plane))
301278 return PTR_ERR(plane);
302279
303280 priv->planes[priv->num_planes++] = plane;
304281 }
305282
306
- DBG("registered %d planes, %d crtcs, %d encoders and %d connectors\n",
307
- priv->num_planes, priv->num_crtcs, priv->num_encoders,
308
- priv->num_connectors);
283
+ /*
284
+ * Create the encoders, attach the bridges and get the pipeline alias
285
+ * IDs.
286
+ */
287
+ for (i = 0; i < priv->num_pipes; i++) {
288
+ struct omap_drm_pipeline *pipe = &priv->pipes[i];
289
+ int id;
290
+
291
+ pipe->encoder = omap_encoder_init(dev, pipe->output);
292
+ if (!pipe->encoder)
293
+ return -ENOMEM;
294
+
295
+ if (pipe->output->bridge) {
296
+ ret = drm_bridge_attach(pipe->encoder,
297
+ pipe->output->bridge, NULL,
298
+ DRM_BRIDGE_ATTACH_NO_CONNECTOR);
299
+ if (ret < 0) {
300
+ dev_err(priv->dev,
301
+ "unable to attach bridge %pOF\n",
302
+ pipe->output->bridge->of_node);
303
+ return ret;
304
+ }
305
+ }
306
+
307
+ id = omap_display_id(pipe->output);
308
+ pipe->alias_id = id >= 0 ? id : i;
309
+ }
310
+
311
+ /* Sort the pipelines by DT aliases. */
312
+ sort(priv->pipes, priv->num_pipes, sizeof(priv->pipes[0]),
313
+ omap_compare_pipelines, NULL);
314
+
315
+ /*
316
+ * Populate the pipeline lookup table by DISPC channel. Only one display
317
+ * is allowed per channel.
318
+ */
319
+ for (i = 0; i < priv->num_pipes; ++i) {
320
+ struct omap_drm_pipeline *pipe = &priv->pipes[i];
321
+ enum omap_channel channel = pipe->output->dispc_channel;
322
+
323
+ if (WARN_ON(priv->channels[channel] != NULL))
324
+ return -EINVAL;
325
+
326
+ priv->channels[channel] = pipe;
327
+ }
328
+
329
+ /* Create the connectors and CRTCs. */
330
+ for (i = 0; i < priv->num_pipes; i++) {
331
+ struct omap_drm_pipeline *pipe = &priv->pipes[i];
332
+ struct drm_encoder *encoder = pipe->encoder;
333
+ struct drm_crtc *crtc;
334
+
335
+ if (pipe->output->next) {
336
+ pipe->connector = omap_connector_init(dev, pipe->output,
337
+ encoder);
338
+ if (!pipe->connector)
339
+ return -ENOMEM;
340
+ } else {
341
+ pipe->connector = drm_bridge_connector_init(dev, encoder);
342
+ if (IS_ERR(pipe->connector)) {
343
+ dev_err(priv->dev,
344
+ "unable to create bridge connector for %s\n",
345
+ pipe->output->name);
346
+ return PTR_ERR(pipe->connector);
347
+ }
348
+ }
349
+
350
+ drm_connector_attach_encoder(pipe->connector, encoder);
351
+
352
+ crtc = omap_crtc_init(dev, pipe, priv->planes[i]);
353
+ if (IS_ERR(crtc))
354
+ return PTR_ERR(crtc);
355
+
356
+ encoder->possible_crtcs = 1 << i;
357
+ pipe->crtc = crtc;
358
+ }
359
+
360
+ DBG("registered %u planes, %u crtcs/encoders/connectors\n",
361
+ priv->num_planes, priv->num_pipes);
309362
310363 dev->mode_config.min_width = 8;
311364 dev->mode_config.min_height = 2;
....@@ -332,29 +385,48 @@
332385 return 0;
333386 }
334387
388
+static void omap_modeset_fini(struct drm_device *ddev)
389
+{
390
+ omap_drm_irq_uninstall(ddev);
391
+
392
+ drm_mode_config_cleanup(ddev);
393
+}
394
+
335395 /*
336396 * Enable the HPD in external components if supported
337397 */
338
-static void omap_modeset_enable_external_hpd(void)
398
+static void omap_modeset_enable_external_hpd(struct drm_device *ddev)
339399 {
340
- struct omap_dss_device *dssdev = NULL;
400
+ struct omap_drm_private *priv = ddev->dev_private;
401
+ unsigned int i;
341402
342
- for_each_dss_dev(dssdev) {
343
- if (dssdev->driver->enable_hpd)
344
- dssdev->driver->enable_hpd(dssdev);
403
+ for (i = 0; i < priv->num_pipes; i++) {
404
+ struct drm_connector *connector = priv->pipes[i].connector;
405
+
406
+ if (!connector)
407
+ continue;
408
+
409
+ if (priv->pipes[i].output->bridge)
410
+ drm_bridge_connector_enable_hpd(connector);
345411 }
346412 }
347413
348414 /*
349415 * Disable the HPD in external components if supported
350416 */
351
-static void omap_modeset_disable_external_hpd(void)
417
+static void omap_modeset_disable_external_hpd(struct drm_device *ddev)
352418 {
353
- struct omap_dss_device *dssdev = NULL;
419
+ struct omap_drm_private *priv = ddev->dev_private;
420
+ unsigned int i;
354421
355
- for_each_dss_dev(dssdev) {
356
- if (dssdev->driver->disable_hpd)
357
- dssdev->driver->disable_hpd(dssdev);
422
+ for (i = 0; i < priv->num_pipes; i++) {
423
+ struct drm_connector *connector = priv->pipes[i].connector;
424
+
425
+ if (!connector)
426
+ continue;
427
+
428
+ if (priv->pipes[i].output->bridge)
429
+ drm_bridge_connector_disable_hpd(connector);
358430 }
359431 }
360432
....@@ -375,20 +447,6 @@
375447 case OMAP_PARAM_CHIPSET_ID:
376448 args->value = priv->omaprev;
377449 break;
378
- default:
379
- DBG("unknown parameter %lld", args->param);
380
- return -EINVAL;
381
- }
382
-
383
- return 0;
384
-}
385
-
386
-static int ioctl_set_param(struct drm_device *dev, void *data,
387
- struct drm_file *file_priv)
388
-{
389
- struct drm_omap_param *args = data;
390
-
391
- switch (args->param) {
392450 default:
393451 DBG("unknown parameter %lld", args->param);
394452 return -EINVAL;
....@@ -428,26 +486,26 @@
428486 args->size = omap_gem_mmap_size(obj);
429487 args->offset = omap_gem_mmap_offset(obj);
430488
431
- drm_gem_object_unreference_unlocked(obj);
489
+ drm_gem_object_put(obj);
432490
433491 return ret;
434492 }
435493
436494 static const struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] = {
437495 DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param,
438
- DRM_AUTH | DRM_RENDER_ALLOW),
439
- DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param,
496
+ DRM_RENDER_ALLOW),
497
+ DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, drm_invalid_op,
440498 DRM_AUTH | DRM_MASTER | DRM_ROOT_ONLY),
441499 DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new,
442
- DRM_AUTH | DRM_RENDER_ALLOW),
500
+ DRM_RENDER_ALLOW),
443501 /* Deprecated, to be removed. */
444502 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, drm_noop,
445
- DRM_AUTH | DRM_RENDER_ALLOW),
503
+ DRM_RENDER_ALLOW),
446504 /* Deprecated, to be removed. */
447505 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, drm_noop,
448
- DRM_AUTH | DRM_RENDER_ALLOW),
506
+ DRM_RENDER_ALLOW),
449507 DRM_IOCTL_DEF_DRV(OMAP_GEM_INFO, ioctl_gem_info,
450
- DRM_AUTH | DRM_RENDER_ALLOW),
508
+ DRM_RENDER_ALLOW),
451509 };
452510
453511 /*
....@@ -482,7 +540,7 @@
482540 };
483541
484542 static struct drm_driver omap_drm_driver = {
485
- .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME |
543
+ .driver_features = DRIVER_MODESET | DRIVER_GEM |
486544 DRIVER_ATOMIC | DRIVER_RENDER,
487545 .open = dev_open,
488546 .lastclose = drm_fb_helper_lastclose,
....@@ -520,10 +578,17 @@
520578 {
521579 const struct soc_device_attribute *soc;
522580 struct drm_device *ddev;
523
- unsigned int i;
524581 int ret;
525582
526583 DBG("%s", dev_name(dev));
584
+
585
+ /* Allocate and initialize the DRM device. */
586
+ ddev = drm_dev_alloc(&omap_drm_driver, dev);
587
+ if (IS_ERR(ddev))
588
+ return PTR_ERR(ddev);
589
+
590
+ priv->ddev = ddev;
591
+ ddev->dev_private = priv;
527592
528593 priv->dev = dev;
529594 priv->dss = omapdss_get_dss();
....@@ -532,26 +597,12 @@
532597
533598 omap_crtc_pre_init(priv);
534599
535
- ret = omap_connect_dssdevs();
536
- if (ret)
537
- goto err_crtc_uninit;
538
-
539600 soc = soc_device_match(omapdrm_soc_devices);
540601 priv->omaprev = soc ? (unsigned int)soc->data : 0;
541602 priv->wq = alloc_ordered_workqueue("omapdrm", 0);
542603
543604 mutex_init(&priv->list_lock);
544605 INIT_LIST_HEAD(&priv->obj_list);
545
-
546
- /* Allocate and initialize the DRM device. */
547
- ddev = drm_dev_alloc(&omap_drm_driver, priv->dev);
548
- if (IS_ERR(ddev)) {
549
- ret = PTR_ERR(ddev);
550
- goto err_destroy_wq;
551
- }
552
-
553
- priv->ddev = ddev;
554
- ddev->dev_private = priv;
555606
556607 /* Get memory bandwidth limits */
557608 if (priv->dispc_ops->get_memory_bandwidth_limit)
....@@ -563,23 +614,20 @@
563614 ret = omap_modeset_init(ddev);
564615 if (ret) {
565616 dev_err(priv->dev, "omap_modeset_init failed: ret=%d\n", ret);
566
- goto err_free_drm_dev;
617
+ goto err_gem_deinit;
567618 }
568619
569620 /* Initialize vblank handling, start with all CRTCs disabled. */
570
- ret = drm_vblank_init(ddev, priv->num_crtcs);
621
+ ret = drm_vblank_init(ddev, priv->num_pipes);
571622 if (ret) {
572623 dev_err(priv->dev, "could not init vblank\n");
573624 goto err_cleanup_modeset;
574625 }
575626
576
- for (i = 0; i < priv->num_crtcs; i++)
577
- drm_crtc_vblank_off(priv->crtcs[i]);
578
-
579627 omap_fbdev_init(ddev);
580628
581629 drm_kms_helper_poll_init(ddev);
582
- omap_modeset_enable_external_hpd();
630
+ omap_modeset_enable_external_hpd(ddev);
583631
584632 /*
585633 * Register the DRM device with the core and the connectors with
....@@ -592,21 +640,18 @@
592640 return 0;
593641
594642 err_cleanup_helpers:
595
- omap_modeset_disable_external_hpd();
643
+ omap_modeset_disable_external_hpd(ddev);
596644 drm_kms_helper_poll_fini(ddev);
597645
598646 omap_fbdev_fini(ddev);
599647 err_cleanup_modeset:
600
- drm_mode_config_cleanup(ddev);
601
- omap_drm_irq_uninstall(ddev);
602
-err_free_drm_dev:
648
+ omap_modeset_fini(ddev);
649
+err_gem_deinit:
603650 omap_gem_deinit(ddev);
604
- drm_dev_unref(ddev);
605
-err_destroy_wq:
606651 destroy_workqueue(priv->wq);
607
- omap_disconnect_dssdevs();
608
-err_crtc_uninit:
609
- omap_crtc_pre_uninit();
652
+ omap_disconnect_pipelines(ddev);
653
+ omap_crtc_pre_uninit(priv);
654
+ drm_dev_put(ddev);
610655 return ret;
611656 }
612657
....@@ -618,24 +663,22 @@
618663
619664 drm_dev_unregister(ddev);
620665
621
- omap_modeset_disable_external_hpd();
666
+ omap_modeset_disable_external_hpd(ddev);
622667 drm_kms_helper_poll_fini(ddev);
623668
624669 omap_fbdev_fini(ddev);
625670
626671 drm_atomic_helper_shutdown(ddev);
627672
628
- drm_mode_config_cleanup(ddev);
629
-
630
- omap_drm_irq_uninstall(ddev);
673
+ omap_modeset_fini(ddev);
631674 omap_gem_deinit(ddev);
632
-
633
- drm_dev_unref(ddev);
634675
635676 destroy_workqueue(priv->wq);
636677
637
- omap_disconnect_dssdevs();
638
- omap_crtc_pre_uninit();
678
+ omap_disconnect_pipelines(ddev);
679
+ omap_crtc_pre_uninit(priv);
680
+
681
+ drm_dev_put(ddev);
639682 }
640683
641684 static int pdev_probe(struct platform_device *pdev)
....@@ -646,7 +689,7 @@
646689 if (omapdss_is_initialized() == false)
647690 return -EPROBE_DEFER;
648691
649
- ret = dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(32));
692
+ ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
650693 if (ret) {
651694 dev_err(&pdev->dev, "Failed to set the DMA mask\n");
652695 return ret;
....@@ -677,54 +720,12 @@
677720 }
678721
679722 #ifdef CONFIG_PM_SLEEP
680
-static int omap_drm_suspend_all_displays(void)
681
-{
682
- struct omap_dss_device *dssdev = NULL;
683
-
684
- for_each_dss_dev(dssdev) {
685
- if (!dssdev->driver)
686
- continue;
687
-
688
- if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) {
689
- dssdev->driver->disable(dssdev);
690
- dssdev->activate_after_resume = true;
691
- } else {
692
- dssdev->activate_after_resume = false;
693
- }
694
- }
695
-
696
- return 0;
697
-}
698
-
699
-static int omap_drm_resume_all_displays(void)
700
-{
701
- struct omap_dss_device *dssdev = NULL;
702
-
703
- for_each_dss_dev(dssdev) {
704
- if (!dssdev->driver)
705
- continue;
706
-
707
- if (dssdev->activate_after_resume) {
708
- dssdev->driver->enable(dssdev);
709
- dssdev->activate_after_resume = false;
710
- }
711
- }
712
-
713
- return 0;
714
-}
715
-
716723 static int omap_drm_suspend(struct device *dev)
717724 {
718725 struct omap_drm_private *priv = dev_get_drvdata(dev);
719726 struct drm_device *drm_dev = priv->ddev;
720727
721
- drm_kms_helper_poll_disable(drm_dev);
722
-
723
- drm_modeset_lock_all(drm_dev);
724
- omap_drm_suspend_all_displays();
725
- drm_modeset_unlock_all(drm_dev);
726
-
727
- return 0;
728
+ return drm_mode_config_helper_suspend(drm_dev);
728729 }
729730
730731 static int omap_drm_resume(struct device *dev)
....@@ -732,11 +733,7 @@
732733 struct omap_drm_private *priv = dev_get_drvdata(dev);
733734 struct drm_device *drm_dev = priv->ddev;
734735
735
- drm_modeset_lock_all(drm_dev);
736
- omap_drm_resume_all_displays();
737
- drm_modeset_unlock_all(drm_dev);
738
-
739
- drm_kms_helper_poll_enable(drm_dev);
736
+ drm_mode_config_helper_resume(drm_dev);
740737
741738 return omap_gem_resume(drm_dev);
742739 }