blob: c6c7c29ad46f43577ade9b7e7c1a238d46bad425 [file] [log] [blame]
David Howells760285e2012-10-02 18:01:07 +01001#include <drm/drmP.h>
Rashika8eed55b2014-01-06 19:58:28 +05302#include <drm/drm_usb.h>
Dave Airliea250b9f2010-12-15 07:13:55 +10003#include <linux/usb.h>
Dave Airlieb10c6d42012-04-19 09:33:32 +01004#include <linux/module.h>
Dave Airliea250b9f2010-12-15 07:13:55 +10005
Dave Airliea250b9f2010-12-15 07:13:55 +10006int 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 Airliea250b9f2010-12-15 07:13:55 +100011 int ret;
12
13 DRM_DEBUG("\n");
14
David Herrmann1bb72532013-10-02 11:23:34 +020015 dev = drm_dev_alloc(driver, &interface->dev);
Dave Airliea250b9f2010-12-15 07:13:55 +100016 if (!dev)
17 return -ENOMEM;
18
David Herrmann1bb72532013-10-02 11:23:34 +020019 dev->usbdev = interface_to_usbdev(interface);
Dave Airliea250b9f2010-12-15 07:13:55 +100020 usb_set_intfdata(interface, dev);
David Herrmannc22f0ac2013-10-02 11:23:35 +020021
22 ret = drm_dev_register(dev, 0);
Dave Airliea250b9f2010-12-15 07:13:55 +100023 if (ret)
David Herrmannc22f0ac2013-10-02 11:23:35 +020024 goto err_free;
Dave Airliea250b9f2010-12-15 07:13:55 +100025
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 Herrmannc22f0ac2013-10-02 11:23:35 +020032err_free:
David Herrmann099d1c22014-01-29 10:21:36 +010033 drm_dev_unref(dev);
Dave Airliea250b9f2010-12-15 07:13:55 +100034 return ret;
35
36}
37EXPORT_SYMBOL(drm_get_usb_dev);
38
Dave Airliea250b9f2010-12-15 07:13:55 +100039static int drm_usb_set_busid(struct drm_device *dev,
40 struct drm_master *master)
41{
42 return 0;
43}
44
45static struct drm_bus drm_usb_bus = {
Dave Airliea250b9f2010-12-15 07:13:55 +100046 .set_busid = drm_usb_set_busid,
47};
48
49int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
50{
51 int res;
52 DRM_DEBUG("\n");
53
Dave Airliea250b9f2010-12-15 07:13:55 +100054 driver->bus = &drm_usb_bus;
55
56 res = usb_register(udriver);
57 return res;
58}
59EXPORT_SYMBOL(drm_usb_init);
60
61void drm_usb_exit(struct drm_driver *driver,
62 struct usb_driver *udriver)
63{
64 usb_deregister(udriver);
65}
66EXPORT_SYMBOL(drm_usb_exit);
Dave Airlieb10c6d42012-04-19 09:33:32 +010067
68MODULE_AUTHOR("David Airlie");
69MODULE_DESCRIPTION("USB DRM support");
70MODULE_LICENSE("GPL and additional rights");