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
35 static int num_crtc = CONFIG_DRM_OMAP_NUM_CRTCS;
52 static void omap_fb_output_poll_changed(
struct drm_device *
dev)
63 .output_poll_changed = omap_fb_output_poll_changed,
68 switch (dssdev->
type) {
82 unsigned long evt,
void *
arg)
85 case OMAP_DSS_SIZE_CHANGE:
86 case OMAP_DSS_HOTPLUG_CONNECT:
87 case OMAP_DSS_HOTPLUG_DISCONNECT: {
89 DBG(
"hotplug event: evt=%d, dev=%p", evt, dev);
101 static void dump_video_chains(
void)
105 DBG(
"dumping video chains: ");
123 static int create_encoder(
struct drm_device *dev,
130 dev_err(dev->dev,
"could not create encoder: %s\n",
143 static int create_connector(
struct drm_device *dev,
152 dev_warn(dev->dev,
"%s has no driver.. skipping it\n",
157 if (!(dssdev->
driver->get_timings ||
158 dssdev->
driver->read_edid)) {
159 dev_warn(dev->dev,
"%s driver does not support "
160 "get_timings or read_edid.. skipping it!\n",
166 get_connector_type(dssdev), dssdev);
169 dev_err(dev->dev,
"could not create connector: %s\n",
181 omap_dss_add_notify(dssdev, notifier);
203 int *j,
unsigned int connected_connectors)
211 while (*j < priv->num_connectors && !mgr) {
212 if (connected_connectors & (1 << *j)) {
231 while (*j < 2 * priv->num_connectors && !mgr) {
233 if (!(connected_connectors & (1 << idx))) {
247 dev_err(dev->dev,
"could not create CRTC: %s\n",
267 dev_err(dev->dev,
"could not create plane: %s\n",
284 static unsigned int detect_connectors(
struct drm_device *dev)
287 unsigned int connected_connectors = 0;
294 connected_connectors |= (1 <<
i);
298 return connected_connectors;
301 static int omap_modeset_init(
struct drm_device *dev)
308 unsigned int connected_connectors = 0;
318 for (i = 0; i < kms_pdata->
mgr_cnt; i++) {
322 create_encoder(dev, mgr);
325 for (i = 0; i < kms_pdata->
dev_cnt; i++) {
331 dev_warn(dev->dev,
"no such dssdev: %s\n",
335 create_connector(dev, dssdev);
338 connected_connectors = detect_connectors(dev);
341 for (i = 0; i < kms_pdata->
ovl_cnt; i++) {
344 create_crtc(dev, ovl, &j, connected_connectors);
347 for (i = 0; i < kms_pdata->
pln_cnt; i++) {
350 create_plane(dev, ovl, (1 << priv->
num_crtcs) - 1);
363 create_connector(dev, dssdev);
366 connected_connectors = detect_connectors(dev);
369 for (i = 0; i < max_overlays; i++) {
371 &j, connected_connectors);
377 create_plane(dev, ovl, (1 << priv->
num_crtcs) - 1);
389 DBG(
"%s: possible_crtcs=%08x", mgr->
name,
395 dev->mode_config.min_width = 32;
396 dev->mode_config.min_height = 32;
401 dev->mode_config.max_width = 2048;
402 dev->mode_config.max_height = 2048;
404 dev->mode_config.funcs = &omap_mode_config_funcs;
409 static void omap_modeset_free(
struct drm_device *dev)
420 struct drm_file *file_priv)
424 DBG(
"%p: param=%llu", dev, args->
param);
426 switch (args->
param) {
431 DBG(
"unknown parameter %lld", args->
param);
438 static int ioctl_set_param(
struct drm_device *dev,
void *data,
439 struct drm_file *file_priv)
443 switch (args->
param) {
445 DBG(
"unknown parameter %lld", args->
param);
452 static int ioctl_gem_new(
struct drm_device *dev,
void *data,
453 struct drm_file *file_priv)
456 DBG(
"%p:%p: size=0x%08x, flags=%08x", dev, file_priv,
462 static int ioctl_gem_cpu_prep(
struct drm_device *dev,
void *data,
463 struct drm_file *file_priv)
466 struct drm_gem_object *obj;
469 VERB(
"%p:%p: handle=%d, op=%x", dev, file_priv, args->
handle, args->
op);
482 drm_gem_object_unreference_unlocked(obj);
487 static int ioctl_gem_cpu_fini(
struct drm_device *dev,
void *data,
488 struct drm_file *file_priv)
491 struct drm_gem_object *obj;
494 VERB(
"%p:%p: handle=%d", dev, file_priv, args->
handle);
508 drm_gem_object_unreference_unlocked(obj);
513 static int ioctl_gem_info(
struct drm_device *dev,
void *data,
514 struct drm_file *file_priv)
517 struct drm_gem_object *obj;
520 DBG(
"%p:%p: handle=%d", dev, file_priv, args->
handle);
530 drm_gem_object_unreference_unlocked(obj);
536 DRM_IOCTL_DEF_DRV(OMAP_GET_PARAM, ioctl_get_param, DRM_UNLOCKED|DRM_AUTH),
537 DRM_IOCTL_DEF_DRV(OMAP_SET_PARAM, ioctl_set_param, DRM_UNLOCKED|DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
538 DRM_IOCTL_DEF_DRV(OMAP_GEM_NEW, ioctl_gem_new, DRM_UNLOCKED|DRM_AUTH),
539 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_PREP, ioctl_gem_cpu_prep, DRM_UNLOCKED|DRM_AUTH),
540 DRM_IOCTL_DEF_DRV(OMAP_GEM_CPU_FINI, ioctl_gem_cpu_fini, DRM_UNLOCKED|DRM_AUTH),
541 DRM_IOCTL_DEF_DRV(OMAP_GEM_INFO, ioctl_gem_info, DRM_UNLOCKED|DRM_AUTH),
563 DBG(
"load: dev=%p", dev);
569 dev_err(dev->dev,
"could not allocate priv\n");
573 dev->dev_private =
priv;
581 ret = omap_modeset_init(dev);
583 dev_err(dev->dev,
"omap_modeset_init failed: ret=%d\n", ret);
584 dev->dev_private =
NULL;
591 dev_warn(dev->dev,
"omap_fbdev_init failed\n");
599 dev_warn(dev->dev,
"could not init vblank\n");
609 DBG(
"unload: dev=%p", dev);
615 omap_modeset_free(dev);
621 kfree(dev->dev_private);
622 dev->dev_private =
NULL;
627 static int dev_open(
struct drm_device *dev,
struct drm_file *
file)
629 file->driver_priv =
NULL;
631 DBG(
"open: dev=%p, file=%p", dev, file);
636 static int dev_firstopen(
struct drm_device *dev)
638 DBG(
"firstopen: dev=%p", dev);
650 static void dev_lastclose(
struct drm_device *dev)
660 DBG(
"lastclose: dev=%p", dev);
679 DBG(
"failed to restore crtc mode");
682 static void dev_preclose(
struct drm_device *dev,
struct drm_file *
file)
684 DBG(
"preclose: dev=%p", dev);
687 static void dev_postclose(
struct drm_device *dev,
struct drm_file *
file)
689 DBG(
"postclose: dev=%p, file=%p", dev, file);
705 static int dev_enable_vblank(
struct drm_device *dev,
int crtc)
707 DBG(
"enable_vblank: dev=%p, crtc=%d", dev, crtc);
720 static void dev_disable_vblank(
struct drm_device *dev,
int crtc)
722 DBG(
"disable_vblank: dev=%p, crtc=%d", dev, crtc);
730 static void dev_irq_preinstall(
struct drm_device *dev)
732 DBG(
"irq_preinstall: dev=%p", dev);
735 static int dev_irq_postinstall(
struct drm_device *dev)
737 DBG(
"irq_postinstall: dev=%p", dev);
741 static void dev_irq_uninstall(
struct drm_device *dev)
743 DBG(
"irq_uninstall: dev=%p", dev);
746 static const struct vm_operations_struct omap_gem_vm_ops = {
764 static struct drm_driver omap_drm_driver = {
766 DRIVER_HAVE_IRQ | DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
768 .unload = dev_unload,
770 .firstopen = dev_firstopen,
771 .lastclose = dev_lastclose,
772 .preclose = dev_preclose,
773 .postclose = dev_postclose,
775 .enable_vblank = dev_enable_vblank,
776 .disable_vblank = dev_disable_vblank,
777 .irq_preinstall = dev_irq_preinstall,
778 .irq_postinstall = dev_irq_postinstall,
779 .irq_uninstall = dev_irq_uninstall,
780 .irq_handler = dev_irq_handler,
781 #ifdef CONFIG_DEBUG_FS
782 .debugfs_init = omap_debugfs_init,
783 .debugfs_cleanup = omap_debugfs_cleanup,
791 .gem_vm_ops = &omap_gem_vm_ops,
797 .fops = &omapdriver_fops,
844 .remove = pdev_remove,
845 .suspend = pdev_suspend,
846 .resume = pdev_resume,
847 .shutdown = pdev_shutdown,
850 static int __init omap_drm_init(
void)
860 static void __exit omap_drm_fini(
void)