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 | 0dc8fe5 | 2013-10-02 11:23:37 +0200 | [diff] [blame] | 33 | drm_dev_free(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 | |
| 39 | static int drm_usb_get_irq(struct drm_device *dev) |
| 40 | { |
| 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | static const char *drm_usb_get_name(struct drm_device *dev) |
| 45 | { |
| 46 | return "USB"; |
| 47 | } |
| 48 | |
| 49 | static int drm_usb_set_busid(struct drm_device *dev, |
| 50 | struct drm_master *master) |
| 51 | { |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | static struct drm_bus drm_usb_bus = { |
| 56 | .bus_type = DRIVER_BUS_USB, |
| 57 | .get_irq = drm_usb_get_irq, |
| 58 | .get_name = drm_usb_get_name, |
| 59 | .set_busid = drm_usb_set_busid, |
| 60 | }; |
| 61 | |
| 62 | int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver) |
| 63 | { |
| 64 | int res; |
| 65 | DRM_DEBUG("\n"); |
| 66 | |
Dave Airlie | a250b9f | 2010-12-15 07:13:55 +1000 | [diff] [blame] | 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"); |