blob: 0f8cb1ae76074d2bf21d75d678585222019f2cdd [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 Herrmann0dc8fe52013-10-02 11:23:37 +020033 drm_dev_free(dev);
Dave Airliea250b9f2010-12-15 07:13:55 +100034 return ret;
35
36}
37EXPORT_SYMBOL(drm_get_usb_dev);
38
39static int drm_usb_get_irq(struct drm_device *dev)
40{
41 return 0;
42}
43
44static const char *drm_usb_get_name(struct drm_device *dev)
45{
46 return "USB";
47}
48
49static int drm_usb_set_busid(struct drm_device *dev,
50 struct drm_master *master)
51{
52 return 0;
53}
54
55static 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
62int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
63{
64 int res;
65 DRM_DEBUG("\n");
66
Dave Airliea250b9f2010-12-15 07:13:55 +100067 driver->kdriver.usb = udriver;
68 driver->bus = &drm_usb_bus;
69
70 res = usb_register(udriver);
71 return res;
72}
73EXPORT_SYMBOL(drm_usb_init);
74
75void drm_usb_exit(struct drm_driver *driver,
76 struct usb_driver *udriver)
77{
78 usb_deregister(udriver);
79}
80EXPORT_SYMBOL(drm_usb_exit);
Dave Airlieb10c6d42012-04-19 09:33:32 +010081
82MODULE_AUTHOR("David Airlie");
83MODULE_DESCRIPTION("USB DRM support");
84MODULE_LICENSE("GPL and additional rights");