David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 1 | #include <drm/drmP.h> |
Dave Airlie | a250b9f | 2010-12-15 07:13:55 +1000 | [diff] [blame] | 2 | #include <linux/usb.h> |
Dave Airlie | b10c6d4 | 2012-04-19 09:33:32 +0100 | [diff] [blame] | 3 | #include <linux/module.h> |
Dave Airlie | a250b9f | 2010-12-15 07:13:55 +1000 | [diff] [blame] | 4 | |
Dave Airlie | a250b9f | 2010-12-15 07:13:55 +1000 | [diff] [blame] | 5 | int drm_get_usb_dev(struct usb_interface *interface, |
| 6 | const struct usb_device_id *id, |
| 7 | struct drm_driver *driver) |
| 8 | { |
| 9 | struct drm_device *dev; |
Dave Airlie | a250b9f | 2010-12-15 07:13:55 +1000 | [diff] [blame] | 10 | int ret; |
| 11 | |
| 12 | DRM_DEBUG("\n"); |
| 13 | |
David Herrmann | 1bb7253 | 2013-10-02 11:23:34 +0200 | [diff] [blame] | 14 | dev = drm_dev_alloc(driver, &interface->dev); |
Dave Airlie | a250b9f | 2010-12-15 07:13:55 +1000 | [diff] [blame] | 15 | if (!dev) |
| 16 | return -ENOMEM; |
| 17 | |
David Herrmann | 1bb7253 | 2013-10-02 11:23:34 +0200 | [diff] [blame] | 18 | dev->usbdev = interface_to_usbdev(interface); |
Dave Airlie | a250b9f | 2010-12-15 07:13:55 +1000 | [diff] [blame] | 19 | usb_set_intfdata(interface, dev); |
David Herrmann | c22f0ac | 2013-10-02 11:23:35 +0200 | [diff] [blame] | 20 | |
| 21 | ret = drm_dev_register(dev, 0); |
Dave Airlie | a250b9f | 2010-12-15 07:13:55 +1000 | [diff] [blame] | 22 | if (ret) |
David Herrmann | c22f0ac | 2013-10-02 11:23:35 +0200 | [diff] [blame] | 23 | goto err_free; |
Dave Airlie | a250b9f | 2010-12-15 07:13:55 +1000 | [diff] [blame] | 24 | |
| 25 | DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", |
| 26 | driver->name, driver->major, driver->minor, driver->patchlevel, |
| 27 | driver->date, dev->primary->index); |
| 28 | |
| 29 | return 0; |
| 30 | |
David Herrmann | c22f0ac | 2013-10-02 11:23:35 +0200 | [diff] [blame] | 31 | err_free: |
David Herrmann | 0dc8fe5 | 2013-10-02 11:23:37 +0200 | [diff] [blame^] | 32 | drm_dev_free(dev); |
Dave Airlie | a250b9f | 2010-12-15 07:13:55 +1000 | [diff] [blame] | 33 | return ret; |
| 34 | |
| 35 | } |
| 36 | EXPORT_SYMBOL(drm_get_usb_dev); |
| 37 | |
| 38 | static int drm_usb_get_irq(struct drm_device *dev) |
| 39 | { |
| 40 | return 0; |
| 41 | } |
| 42 | |
| 43 | static const char *drm_usb_get_name(struct drm_device *dev) |
| 44 | { |
| 45 | return "USB"; |
| 46 | } |
| 47 | |
| 48 | static int drm_usb_set_busid(struct drm_device *dev, |
| 49 | struct drm_master *master) |
| 50 | { |
| 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | static struct drm_bus drm_usb_bus = { |
| 55 | .bus_type = DRIVER_BUS_USB, |
| 56 | .get_irq = drm_usb_get_irq, |
| 57 | .get_name = drm_usb_get_name, |
| 58 | .set_busid = drm_usb_set_busid, |
| 59 | }; |
| 60 | |
| 61 | int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver) |
| 62 | { |
| 63 | int res; |
| 64 | DRM_DEBUG("\n"); |
| 65 | |
| 66 | INIT_LIST_HEAD(&driver->device_list); |
| 67 | driver->kdriver.usb = udriver; |
| 68 | driver->bus = &drm_usb_bus; |
| 69 | |
| 70 | res = usb_register(udriver); |
| 71 | return res; |
| 72 | } |
| 73 | EXPORT_SYMBOL(drm_usb_init); |
| 74 | |
| 75 | void drm_usb_exit(struct drm_driver *driver, |
| 76 | struct usb_driver *udriver) |
| 77 | { |
| 78 | usb_deregister(udriver); |
| 79 | } |
| 80 | EXPORT_SYMBOL(drm_usb_exit); |
Dave Airlie | b10c6d4 | 2012-04-19 09:33:32 +0100 | [diff] [blame] | 81 | |
| 82 | MODULE_AUTHOR("David Airlie"); |
| 83 | MODULE_DESCRIPTION("USB DRM support"); |
| 84 | MODULE_LICENSE("GPL and additional rights"); |