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