OMAPDSS: add OMAP_DISPLAY_TYPE_DVI
[deliverable/linux.git] / drivers / gpu / drm / omapdrm / omap_drv.c
CommitLineData
cd5351f4 1/*
8bb0daff 2 * drivers/gpu/drm/omapdrm/omap_drv.c
cd5351f4
RC
3 *
4 * Copyright (C) 2011 Texas Instruments
5 * Author: Rob Clark <rob@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published by
9 * the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 * more details.
15 *
16 * You should have received a copy of the GNU General Public License along with
17 * this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include "omap_drv.h"
21
22#include "drm_crtc_helper.h"
23#include "drm_fb_helper.h"
5c137797 24#include "omap_dmm_tiler.h"
cd5351f4
RC
25
26#define DRIVER_NAME MODULE_NAME
27#define DRIVER_DESC "OMAP DRM"
28#define DRIVER_DATE "20110917"
29#define DRIVER_MAJOR 1
30#define DRIVER_MINOR 0
31#define DRIVER_PATCHLEVEL 0
32
cd5351f4
RC
33static int num_crtc = CONFIG_DRM_OMAP_NUM_CRTCS;
34
35MODULE_PARM_DESC(num_crtc, "Number of overlays to use as CRTCs");
36module_param(num_crtc, int, 0600);
37
38/*
39 * mode config funcs
40 */
41
42/* Notes about mapping DSS and DRM entities:
43 * CRTC: overlay
44 * encoder: manager.. with some extension to allow one primary CRTC
45 * and zero or more video CRTC's to be mapped to one encoder?
46 * connector: dssdev.. manager can be attached/detached from different
47 * devices
48 */
49
50static void omap_fb_output_poll_changed(struct drm_device *dev)
51{
52 struct omap_drm_private *priv = dev->dev_private;
53 DBG("dev=%p", dev);
c7f904b3 54 if (priv->fbdev)
cd5351f4 55 drm_fb_helper_hotplug_event(priv->fbdev);
cd5351f4
RC
56}
57
e6ecefaa 58static const struct drm_mode_config_funcs omap_mode_config_funcs = {
cd5351f4
RC
59 .fb_create = omap_framebuffer_create,
60 .output_poll_changed = omap_fb_output_poll_changed,
61};
62
63static int get_connector_type(struct omap_dss_device *dssdev)
64{
65 switch (dssdev->type) {
66 case OMAP_DISPLAY_TYPE_HDMI:
67 return DRM_MODE_CONNECTOR_HDMIA;
68 case OMAP_DISPLAY_TYPE_DPI:
69 if (!strcmp(dssdev->name, "dvi"))
70 return DRM_MODE_CONNECTOR_DVID;
71 /* fallthrough */
72 default:
73 return DRM_MODE_CONNECTOR_Unknown;
74 }
75}
76
0d8f371f
AT
77static bool channel_used(struct drm_device *dev, enum omap_channel channel)
78{
79 struct omap_drm_private *priv = dev->dev_private;
80 int i;
81
82 for (i = 0; i < priv->num_crtcs; i++) {
83 struct drm_crtc *crtc = priv->crtcs[i];
84
85 if (omap_crtc_channel(crtc) == channel)
86 return true;
87 }
88
89 return false;
90}
91
f5f9454c 92static int omap_modeset_init(struct drm_device *dev)
cd5351f4
RC
93{
94 struct omap_drm_private *priv = dev->dev_private;
f5f9454c
RC
95 struct omap_dss_device *dssdev = NULL;
96 int num_ovls = dss_feat_get_num_ovls();
0d8f371f
AT
97 int num_mgrs = dss_feat_get_num_mgrs();
98 int num_crtcs;
99 int i, id = 0;
a7e71e7f 100 int r;
cd5351f4 101
04b1fc02
TV
102 omap_crtc_pre_init();
103
f5f9454c 104 drm_mode_config_init(dev);
cd5351f4 105
f5f9454c 106 omap_drm_irq_install(dev);
cd5351f4 107
f5f9454c 108 /*
0d8f371f
AT
109 * We usually don't want to create a CRTC for each manager, at least
110 * not until we have a way to expose private planes to userspace.
111 * Otherwise there would not be enough video pipes left for drm planes.
112 * We use the num_crtc argument to limit the number of crtcs we create.
f5f9454c 113 */
0d8f371f 114 num_crtcs = min3(num_crtc, num_mgrs, num_ovls);
cd5351f4 115
0d8f371f 116 dssdev = NULL;
cd5351f4 117
f5f9454c
RC
118 for_each_dss_dev(dssdev) {
119 struct drm_connector *connector;
120 struct drm_encoder *encoder;
0d8f371f 121 enum omap_channel channel;
a7e71e7f 122 struct omap_overlay_manager *mgr;
c7f904b3 123
f5f9454c
RC
124 if (!dssdev->driver) {
125 dev_warn(dev->dev, "%s has no driver.. skipping it\n",
126 dssdev->name);
581382e3 127 continue;
cd5351f4 128 }
cd5351f4 129
f5f9454c
RC
130 if (!(dssdev->driver->get_timings ||
131 dssdev->driver->read_edid)) {
132 dev_warn(dev->dev, "%s driver does not support "
133 "get_timings or read_edid.. skipping it!\n",
134 dssdev->name);
581382e3 135 continue;
cd5351f4 136 }
cd5351f4 137
a7e71e7f
TV
138 r = dssdev->driver->connect(dssdev);
139 if (r) {
140 dev_err(dev->dev, "could not connect display: %s\n",
141 dssdev->name);
142 continue;
143 }
144
f5f9454c 145 encoder = omap_encoder_init(dev, dssdev);
cd5351f4 146
f5f9454c
RC
147 if (!encoder) {
148 dev_err(dev->dev, "could not create encoder: %s\n",
149 dssdev->name);
150 return -ENOMEM;
cd5351f4
RC
151 }
152
f5f9454c
RC
153 connector = omap_connector_init(dev,
154 get_connector_type(dssdev), dssdev, encoder);
cd5351f4 155
f5f9454c
RC
156 if (!connector) {
157 dev_err(dev->dev, "could not create connector: %s\n",
158 dssdev->name);
159 return -ENOMEM;
cd5351f4 160 }
bb5c2d9a 161
f5f9454c
RC
162 BUG_ON(priv->num_encoders >= ARRAY_SIZE(priv->encoders));
163 BUG_ON(priv->num_connectors >= ARRAY_SIZE(priv->connectors));
cd5351f4 164
f5f9454c
RC
165 priv->encoders[priv->num_encoders++] = encoder;
166 priv->connectors[priv->num_connectors++] = connector;
cd5351f4 167
f5f9454c 168 drm_mode_connector_attach_encoder(connector, encoder);
cd5351f4 169
0d8f371f
AT
170 /*
171 * if we have reached the limit of the crtcs we are allowed to
172 * create, let's not try to look for a crtc for this
173 * panel/encoder and onwards, we will, of course, populate the
174 * the possible_crtcs field for all the encoders with the final
175 * set of crtcs we create
176 */
177 if (id == num_crtcs)
178 continue;
179
180 /*
181 * get the recommended DISPC channel for this encoder. For now,
182 * we only try to get create a crtc out of the recommended, the
183 * other possible channels to which the encoder can connect are
184 * not considered.
185 */
0d8f371f 186
a7e71e7f
TV
187 mgr = omapdss_find_mgr_from_display(dssdev);
188 channel = mgr->id;
0d8f371f
AT
189 /*
190 * if this channel hasn't already been taken by a previously
191 * allocated crtc, we create a new crtc for it
192 */
193 if (!channel_used(dev, channel)) {
194 struct drm_plane *plane;
195 struct drm_crtc *crtc;
196
197 plane = omap_plane_init(dev, id, true);
198 crtc = omap_crtc_init(dev, plane, channel, id);
199
200 BUG_ON(priv->num_crtcs >= ARRAY_SIZE(priv->crtcs));
201 priv->crtcs[id] = crtc;
202 priv->num_crtcs++;
203
204 priv->planes[id] = plane;
205 priv->num_planes++;
206
207 id++;
208 }
209 }
210
211 /*
212 * we have allocated crtcs according to the need of the panels/encoders,
213 * adding more crtcs here if needed
214 */
215 for (; id < num_crtcs; id++) {
216
217 /* find a free manager for this crtc */
218 for (i = 0; i < num_mgrs; i++) {
219 if (!channel_used(dev, i)) {
220 struct drm_plane *plane;
221 struct drm_crtc *crtc;
222
223 plane = omap_plane_init(dev, id, true);
224 crtc = omap_crtc_init(dev, plane, i, id);
225
226 BUG_ON(priv->num_crtcs >=
227 ARRAY_SIZE(priv->crtcs));
228
229 priv->crtcs[id] = crtc;
230 priv->num_crtcs++;
231
232 priv->planes[id] = plane;
233 priv->num_planes++;
234
235 break;
236 } else {
237 continue;
238 }
239 }
240
241 if (i == num_mgrs) {
242 /* this shouldn't really happen */
243 dev_err(dev->dev, "no managers left for crtc\n");
244 return -ENOMEM;
245 }
246 }
247
248 /*
249 * Create normal planes for the remaining overlays:
250 */
251 for (; id < num_ovls; id++) {
252 struct drm_plane *plane = omap_plane_init(dev, id, false);
253
254 BUG_ON(priv->num_planes >= ARRAY_SIZE(priv->planes));
255 priv->planes[priv->num_planes++] = plane;
256 }
257
258 for (i = 0; i < priv->num_encoders; i++) {
259 struct drm_encoder *encoder = priv->encoders[i];
260 struct omap_dss_device *dssdev =
261 omap_encoder_get_dssdev(encoder);
1f68d9c4 262 struct omap_dss_device *output;
be8e8e1c
TV
263
264 output = omapdss_find_output_from_display(dssdev);
0d8f371f 265
f5f9454c
RC
266 /* figure out which crtc's we can connect the encoder to: */
267 encoder->possible_crtcs = 0;
268 for (id = 0; id < priv->num_crtcs; id++) {
0d8f371f
AT
269 struct drm_crtc *crtc = priv->crtcs[id];
270 enum omap_channel crtc_channel;
271 enum omap_dss_output_id supported_outputs;
272
273 crtc_channel = omap_crtc_channel(crtc);
274 supported_outputs =
275 dss_feat_get_supported_outputs(crtc_channel);
276
be8e8e1c 277 if (supported_outputs & output->id)
f5f9454c 278 encoder->possible_crtcs |= (1 << id);
bb5c2d9a 279 }
820caabf
TV
280
281 omap_dss_put_device(output);
cd5351f4
RC
282 }
283
0d8f371f
AT
284 DBG("registered %d planes, %d crtcs, %d encoders and %d connectors\n",
285 priv->num_planes, priv->num_crtcs, priv->num_encoders,
286 priv->num_connectors);
287
6b8ca4cf
RC
288 dev->mode_config.min_width = 32;
289 dev->mode_config.min_height = 32;
cd5351f4
RC
290
291 /* note: eventually will need some cpu_is_omapXYZ() type stuff here
292 * to fill in these limits properly on different OMAP generations..
293 */
294 dev->mode_config.max_width = 2048;
295 dev->mode_config.max_height = 2048;
296
297 dev->mode_config.funcs = &omap_mode_config_funcs;
298
299 return 0;
300}
301
302static void omap_modeset_free(struct drm_device *dev)
303{
304 drm_mode_config_cleanup(dev);
305}
306
307/*
308 * drm ioctl funcs
309 */
310
311
312static int ioctl_get_param(struct drm_device *dev, void *data,
313 struct drm_file *file_priv)
314{
5e3b0874 315 struct omap_drm_private *priv = dev->dev_private;
cd5351f4
RC
316 struct drm_omap_param *args = data;
317
318 DBG("%p: param=%llu", dev, args->param);
319
320 switch (args->param) {
321 case OMAP_PARAM_CHIPSET_ID:
5e3b0874 322 args->value = priv->omaprev;
cd5351f4
RC
323 break;
324 default:
325 DBG("unknown parameter %lld", args->param);
326 return -EINVAL;
327 }
328
329 return 0;
330}
331
332static int ioctl_set_param(struct drm_device *dev, void *data,
333 struct drm_file *file_priv)
334{
335 struct drm_omap_param *args = data;
336
337 switch (args->param) {
338 default:
339 DBG("unknown parameter %lld", args->param);
340 return -EINVAL;
341 }
342
343 return 0;
344}
345
346static int ioctl_gem_new(struct drm_device *dev, void *data,
347 struct drm_file *file_priv)
348{
349 struct drm_omap_gem_new *args = data;
f5f9454c 350 VERB("%p:%p: size=0x%08x, flags=%08x", dev, file_priv,
cd5351f4
RC
351 args->size.bytes, args->flags);
352 return omap_gem_new_handle(dev, file_priv, args->size,
353 args->flags, &args->handle);
354}
355
356static int ioctl_gem_cpu_prep(struct drm_device *dev, void *data,
357 struct drm_file *file_priv)
358{
359 struct drm_omap_gem_cpu_prep *args = data;
360 struct drm_gem_object *obj;
361 int ret;
362
363 VERB("%p:%p: handle=%d, op=%x", dev, file_priv, args->handle, args->op);
364
365 obj = drm_gem_object_lookup(dev, file_priv, args->handle);
c7f904b3 366 if (!obj)
cd5351f4 367 return -ENOENT;
cd5351f4
RC
368
369 ret = omap_gem_op_sync(obj, args->op);
370
c7f904b3 371 if (!ret)
cd5351f4 372 ret = omap_gem_op_start(obj, args->op);
cd5351f4
RC
373
374 drm_gem_object_unreference_unlocked(obj);
375
376 return ret;
377}
378
379static int ioctl_gem_cpu_fini(struct drm_device *dev, void *data,
380 struct drm_file *file_priv)
381{
382 struct drm_omap_gem_cpu_fini *args = data;
383 struct drm_gem_object *obj;
384 int ret;
385
386 VERB("%p:%p: handle=%d", dev, file_priv, args->handle);
387
388 obj = drm_gem_object_lookup(dev, file_priv, args->handle);
c7f904b3 389 if (!obj)
cd5351f4 390 return -ENOENT;
cd5351f4
RC
391
392 /* XXX flushy, flushy */
393 ret = 0;
394
c7f904b3 395 if (!ret)
cd5351f4 396 ret = omap_gem_op_finish(obj, args->op);
cd5351f4
RC
397
398 drm_gem_object_unreference_unlocked(obj);
399
400 return ret;
401}
402
403static int ioctl_gem_info(struct drm_device *dev, void *data,
404 struct drm_file *file_priv)
405{
406 struct drm_omap_gem_info *args = data;
407 struct drm_gem_object *obj;
408 int ret = 0;
409
f5f9454c 410 VERB("%p:%p: handle=%d", dev, file_priv, args->handle);
cd5351f4
RC
411
412 obj = drm_gem_object_lookup(dev, file_priv, args->handle);
c7f904b3 413 if (!obj)
cd5351f4 414 return -ENOENT;
cd5351f4 415
f7f9f453 416 args->size = omap_gem_mmap_size(obj);
cd5351f4
RC
417 args->offset = omap_gem_mmap_offset(obj);
418
419 drm_gem_object_unreference_unlocked(obj);
420
421 return ret;
422}
423
6717cd29 424static struct drm_ioctl_desc ioctls[DRM_COMMAND_END - DRM_COMMAND_BASE] = {
cd5351f4
RC
425 DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param, DRM_UNLOCKED|DRM_AUTH),
426 DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param, DRM_UNLOCKED|DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
427 DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new, DRM_UNLOCKED|DRM_AUTH),
428 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, ioctl_gem_cpu_prep, DRM_UNLOCKED|DRM_AUTH),
429 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, ioctl_gem_cpu_fini, DRM_UNLOCKED|DRM_AUTH),
430 DRM_IOCTL_DEF_DRV(OMAP_GEM_INFO, ioctl_gem_info, DRM_UNLOCKED|DRM_AUTH),
431};
432
433/*
434 * drm driver funcs
435 */
436
437/**
438 * load - setup chip and create an initial config
439 * @dev: DRM device
440 * @flags: startup flags
441 *
442 * The driver load routine has to do several things:
443 * - initialize the memory manager
444 * - allocate initial config memory
445 * - setup the DRM framebuffer with the allocated memory
446 */
447static int dev_load(struct drm_device *dev, unsigned long flags)
448{
5e3b0874 449 struct omap_drm_platform_data *pdata = dev->dev->platform_data;
cd5351f4
RC
450 struct omap_drm_private *priv;
451 int ret;
452
453 DBG("load: dev=%p", dev);
454
cd5351f4 455 priv = kzalloc(sizeof(*priv), GFP_KERNEL);
78110bb8 456 if (!priv)
cd5351f4 457 return -ENOMEM;
cd5351f4 458
5e3b0874
RC
459 priv->omaprev = pdata->omaprev;
460
cd5351f4
RC
461 dev->dev_private = priv;
462
4619cdbc 463 priv->wq = alloc_ordered_workqueue("omapdrm", 0);
5609f7fe 464
f6b6036e
RC
465 INIT_LIST_HEAD(&priv->obj_list);
466
f7f9f453
RC
467 omap_gem_init(dev);
468
cd5351f4
RC
469 ret = omap_modeset_init(dev);
470 if (ret) {
471 dev_err(dev->dev, "omap_modeset_init failed: ret=%d\n", ret);
472 dev->dev_private = NULL;
473 kfree(priv);
474 return ret;
475 }
476
f5f9454c
RC
477 ret = drm_vblank_init(dev, priv->num_crtcs);
478 if (ret)
479 dev_warn(dev->dev, "could not init vblank\n");
480
cd5351f4
RC
481 priv->fbdev = omap_fbdev_init(dev);
482 if (!priv->fbdev) {
483 dev_warn(dev->dev, "omap_fbdev_init failed\n");
484 /* well, limp along without an fbdev.. maybe X11 will work? */
485 }
486
e78edba1
AG
487 /* store off drm_device for use in pm ops */
488 dev_set_drvdata(dev->dev, dev);
489
cd5351f4
RC
490 drm_kms_helper_poll_init(dev);
491
cd5351f4
RC
492 return 0;
493}
494
495static int dev_unload(struct drm_device *dev)
496{
5609f7fe
RC
497 struct omap_drm_private *priv = dev->dev_private;
498
cd5351f4
RC
499 DBG("unload: dev=%p", dev);
500
cd5351f4 501 drm_kms_helper_poll_fini(dev);
f5f9454c
RC
502 drm_vblank_cleanup(dev);
503 omap_drm_irq_uninstall(dev);
cd5351f4
RC
504
505 omap_fbdev_free(dev);
cd5351f4 506 omap_modeset_free(dev);
f7f9f453 507 omap_gem_deinit(dev);
cd5351f4 508
5609f7fe
RC
509 flush_workqueue(priv->wq);
510 destroy_workqueue(priv->wq);
511
cd5351f4
RC
512 kfree(dev->dev_private);
513 dev->dev_private = NULL;
514
e78edba1
AG
515 dev_set_drvdata(dev->dev, NULL);
516
cd5351f4
RC
517 return 0;
518}
519
520static int dev_open(struct drm_device *dev, struct drm_file *file)
521{
522 file->driver_priv = NULL;
523
524 DBG("open: dev=%p, file=%p", dev, file);
525
526 return 0;
527}
528
529static int dev_firstopen(struct drm_device *dev)
530{
531 DBG("firstopen: dev=%p", dev);
532 return 0;
533}
534
535/**
536 * lastclose - clean up after all DRM clients have exited
537 * @dev: DRM device
538 *
539 * Take care of cleaning up after all DRM clients have exited. In the
540 * mode setting case, we want to restore the kernel's initial mode (just
541 * in case the last client left us in a bad state).
542 */
543static void dev_lastclose(struct drm_device *dev)
544{
3c810c61
RC
545 int i;
546
cd5351f4
RC
547 /* we don't support vga-switcheroo.. so just make sure the fbdev
548 * mode is active
549 */
550 struct omap_drm_private *priv = dev->dev_private;
551 int ret;
552
553 DBG("lastclose: dev=%p", dev);
554
c2a6a552
RC
555 if (priv->rotation_prop) {
556 /* need to restore default rotation state.. not sure
557 * if there is a cleaner way to restore properties to
558 * default state? Maybe a flag that properties should
559 * automatically be restored to default state on
560 * lastclose?
561 */
562 for (i = 0; i < priv->num_crtcs; i++) {
563 drm_object_property_set_value(&priv->crtcs[i]->base,
564 priv->rotation_prop, 0);
565 }
3c810c61 566
c2a6a552
RC
567 for (i = 0; i < priv->num_planes; i++) {
568 drm_object_property_set_value(&priv->planes[i]->base,
569 priv->rotation_prop, 0);
570 }
3c810c61
RC
571 }
572
d5d2636e 573 drm_modeset_lock_all(dev);
cd5351f4 574 ret = drm_fb_helper_restore_fbdev_mode(priv->fbdev);
d5d2636e 575 drm_modeset_unlock_all(dev);
cd5351f4
RC
576 if (ret)
577 DBG("failed to restore crtc mode");
578}
579
580static void dev_preclose(struct drm_device *dev, struct drm_file *file)
581{
582 DBG("preclose: dev=%p", dev);
583}
584
585static void dev_postclose(struct drm_device *dev, struct drm_file *file)
586{
587 DBG("postclose: dev=%p, file=%p", dev, file);
588}
589
78b68556 590static const struct vm_operations_struct omap_gem_vm_ops = {
cd5351f4
RC
591 .fault = omap_gem_fault,
592 .open = drm_gem_vm_open,
593 .close = drm_gem_vm_close,
594};
595
ff4f3876
RC
596static const struct file_operations omapdriver_fops = {
597 .owner = THIS_MODULE,
598 .open = drm_open,
599 .unlocked_ioctl = drm_ioctl,
600 .release = drm_release,
601 .mmap = omap_gem_mmap,
602 .poll = drm_poll,
603 .fasync = drm_fasync,
604 .read = drm_read,
605 .llseek = noop_llseek,
606};
607
cd5351f4
RC
608static struct drm_driver omap_drm_driver = {
609 .driver_features =
6ad11bc3 610 DRIVER_HAVE_IRQ | DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
cd5351f4
RC
611 .load = dev_load,
612 .unload = dev_unload,
613 .open = dev_open,
614 .firstopen = dev_firstopen,
615 .lastclose = dev_lastclose,
616 .preclose = dev_preclose,
617 .postclose = dev_postclose,
618 .get_vblank_counter = drm_vblank_count,
f5f9454c
RC
619 .enable_vblank = omap_irq_enable_vblank,
620 .disable_vblank = omap_irq_disable_vblank,
621 .irq_preinstall = omap_irq_preinstall,
622 .irq_postinstall = omap_irq_postinstall,
623 .irq_uninstall = omap_irq_uninstall,
624 .irq_handler = omap_irq_handler,
6169a148
AG
625#ifdef CONFIG_DEBUG_FS
626 .debugfs_init = omap_debugfs_init,
627 .debugfs_cleanup = omap_debugfs_cleanup,
628#endif
6ad11bc3 629 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
3080b838 630 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
6ad11bc3 631 .gem_prime_export = omap_gem_prime_export,
3080b838 632 .gem_prime_import = omap_gem_prime_import,
cd5351f4
RC
633 .gem_init_object = omap_gem_init_object,
634 .gem_free_object = omap_gem_free_object,
635 .gem_vm_ops = &omap_gem_vm_ops,
636 .dumb_create = omap_gem_dumb_create,
637 .dumb_map_offset = omap_gem_dumb_map_offset,
638 .dumb_destroy = omap_gem_dumb_destroy,
639 .ioctls = ioctls,
640 .num_ioctls = DRM_OMAP_NUM_IOCTLS,
ff4f3876 641 .fops = &omapdriver_fops,
cd5351f4
RC
642 .name = DRIVER_NAME,
643 .desc = DRIVER_DESC,
644 .date = DRIVER_DATE,
645 .major = DRIVER_MAJOR,
646 .minor = DRIVER_MINOR,
647 .patchlevel = DRIVER_PATCHLEVEL,
648};
649
650static int pdev_suspend(struct platform_device *pDevice, pm_message_t state)
651{
652 DBG("");
653 return 0;
654}
655
656static int pdev_resume(struct platform_device *device)
657{
658 DBG("");
659 return 0;
660}
661
662static void pdev_shutdown(struct platform_device *device)
663{
664 DBG("");
665}
666
667static int pdev_probe(struct platform_device *device)
668{
591a0ac7
TV
669 if (omapdss_is_initialized() == false)
670 return -EPROBE_DEFER;
671
cd5351f4
RC
672 DBG("%s", device->name);
673 return drm_platform_init(&omap_drm_driver, device);
674}
675
676static int pdev_remove(struct platform_device *device)
677{
678 DBG("");
679 drm_platform_exit(&omap_drm_driver, device);
5c137797
AG
680
681 platform_driver_unregister(&omap_dmm_driver);
cd5351f4
RC
682 return 0;
683}
684
e78edba1
AG
685#ifdef CONFIG_PM
686static const struct dev_pm_ops omapdrm_pm_ops = {
687 .resume = omap_gem_resume,
688};
689#endif
690
6717cd29 691static struct platform_driver pdev = {
cd5351f4
RC
692 .driver = {
693 .name = DRIVER_NAME,
694 .owner = THIS_MODULE,
e78edba1
AG
695#ifdef CONFIG_PM
696 .pm = &omapdrm_pm_ops,
697#endif
cd5351f4
RC
698 },
699 .probe = pdev_probe,
700 .remove = pdev_remove,
701 .suspend = pdev_suspend,
702 .resume = pdev_resume,
703 .shutdown = pdev_shutdown,
704};
705
706static int __init omap_drm_init(void)
707{
708 DBG("init");
be0775ac
RC
709 if (platform_driver_register(&omap_dmm_driver)) {
710 /* we can continue on without DMM.. so not fatal */
711 dev_err(NULL, "DMM registration failed\n");
712 }
cd5351f4
RC
713 return platform_driver_register(&pdev);
714}
715
716static void __exit omap_drm_fini(void)
717{
718 DBG("fini");
719 platform_driver_unregister(&pdev);
720}
721
722/* need late_initcall() so we load after dss_driver's are loaded */
723late_initcall(omap_drm_init);
724module_exit(omap_drm_fini);
725
726MODULE_AUTHOR("Rob Clark <rob@ti.com>");
727MODULE_DESCRIPTION("OMAP DRM Display Driver");
728MODULE_ALIAS("platform:" DRIVER_NAME);
729MODULE_LICENSE("GPL v2");
This page took 0.204477 seconds and 5 git commands to generate.