3 #include <linux/module.h>
5 int drm_get_usb_dev(struct usb_interface
*interface
,
6 const struct usb_device_id
*id
,
7 struct drm_driver
*driver
)
9 struct drm_device
*dev
;
10 struct usb_device
*usbdev
;
15 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
19 usbdev
= interface_to_usbdev(interface
);
21 dev
->dev
= &interface
->dev
;
23 mutex_lock(&drm_global_mutex
);
25 ret
= drm_fill_in_dev(dev
, NULL
, driver
);
27 printk(KERN_ERR
"DRM: Fill_in_dev failed.\n");
31 usb_set_intfdata(interface
, dev
);
32 ret
= drm_get_minor(dev
, &dev
->control
, DRM_MINOR_CONTROL
);
36 if (drm_core_check_feature(dev
, DRIVER_RENDER
) && drm_rnodes
) {
37 ret
= drm_get_minor(dev
, &dev
->render
, DRM_MINOR_RENDER
);
42 ret
= drm_get_minor(dev
, &dev
->primary
, DRM_MINOR_LEGACY
);
46 if (dev
->driver
->load
) {
47 ret
= dev
->driver
->load(dev
, 0);
52 /* setup the grouping for the legacy output */
53 ret
= drm_mode_group_init_legacy_group(dev
,
54 &dev
->primary
->mode_group
);
58 list_add_tail(&dev
->driver_item
, &driver
->device_list
);
60 mutex_unlock(&drm_global_mutex
);
62 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
63 driver
->name
, driver
->major
, driver
->minor
, driver
->patchlevel
,
64 driver
->date
, dev
->primary
->index
);
69 drm_put_minor(&dev
->primary
);
72 drm_put_minor(&dev
->render
);
74 drm_put_minor(&dev
->control
);
77 mutex_unlock(&drm_global_mutex
);
81 EXPORT_SYMBOL(drm_get_usb_dev
);
83 static int drm_usb_get_irq(struct drm_device
*dev
)
88 static const char *drm_usb_get_name(struct drm_device
*dev
)
93 static int drm_usb_set_busid(struct drm_device
*dev
,
94 struct drm_master
*master
)
99 static struct drm_bus drm_usb_bus
= {
100 .bus_type
= DRIVER_BUS_USB
,
101 .get_irq
= drm_usb_get_irq
,
102 .get_name
= drm_usb_get_name
,
103 .set_busid
= drm_usb_set_busid
,
106 int drm_usb_init(struct drm_driver
*driver
, struct usb_driver
*udriver
)
111 INIT_LIST_HEAD(&driver
->device_list
);
112 driver
->kdriver
.usb
= udriver
;
113 driver
->bus
= &drm_usb_bus
;
115 res
= usb_register(udriver
);
118 EXPORT_SYMBOL(drm_usb_init
);
120 void drm_usb_exit(struct drm_driver
*driver
,
121 struct usb_driver
*udriver
)
123 usb_deregister(udriver
);
125 EXPORT_SYMBOL(drm_usb_exit
);
127 MODULE_AUTHOR("David Airlie");
128 MODULE_DESCRIPTION("USB DRM support");
129 MODULE_LICENSE("GPL and additional rights");