drm_usb.c 1.4 KB
Newer Older
1
#include <drm/drmP.h>
2
#include <drm/drm_usb.h>
D
Dave Airlie 已提交
3
#include <linux/usb.h>
4
#include <linux/module.h>
D
Dave Airlie 已提交
5 6 7 8 9 10 11 12 13 14

int drm_get_usb_dev(struct usb_interface *interface,
		    const struct usb_device_id *id,
		    struct drm_driver *driver)
{
	struct drm_device *dev;
	int ret;

	DRM_DEBUG("\n");

D
David Herrmann 已提交
15
	dev = drm_dev_alloc(driver, &interface->dev);
D
Dave Airlie 已提交
16 17 18
	if (!dev)
		return -ENOMEM;

D
David Herrmann 已提交
19
	dev->usbdev = interface_to_usbdev(interface);
D
Dave Airlie 已提交
20
	usb_set_intfdata(interface, dev);
21

22
	ret = drm_dev_register(dev, 0);
D
Dave Airlie 已提交
23
	if (ret)
24
		goto err_free;
D
Dave Airlie 已提交
25 26 27 28 29 30 31

	DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
		 driver->name, driver->major, driver->minor, driver->patchlevel,
		 driver->date, dev->primary->index);

	return 0;

32
err_free:
D
David Herrmann 已提交
33
	drm_dev_unref(dev);
D
Dave Airlie 已提交
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
	return ret;

}
EXPORT_SYMBOL(drm_get_usb_dev);

static int drm_usb_set_busid(struct drm_device *dev,
			       struct drm_master *master)
{
	return 0;
}

static struct drm_bus drm_usb_bus = {
	.set_busid = drm_usb_set_busid,
};
    
int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
{
	int res;
	DRM_DEBUG("\n");

	driver->bus = &drm_usb_bus;

	res = usb_register(udriver);
	return res;
}
EXPORT_SYMBOL(drm_usb_init);

void drm_usb_exit(struct drm_driver *driver,
		  struct usb_driver *udriver)
{
	usb_deregister(udriver);
}
EXPORT_SYMBOL(drm_usb_exit);
67 68 69 70

MODULE_AUTHOR("David Airlie");
MODULE_DESCRIPTION("USB DRM support");
MODULE_LICENSE("GPL and additional rights");