drm_usb.c 1.7 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
	return ret;

}
EXPORT_SYMBOL(drm_get_usb_dev);

39 40 41 42 43 44 45 46 47 48
/**
 * drm_usb_init - Register matching USB devices with the DRM subsystem
 * @driver: DRM device driver
 * @udriver: USB device driver
 *
 * Registers one or more devices matched by a USB driver with the DRM
 * subsystem.
 *
 * Return: 0 on success or a negative error code on failure.
 */
D
Dave Airlie 已提交
49 50 51 52 53 54 55 56 57 58
int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
{
	int res;
	DRM_DEBUG("\n");

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

59 60 61 62 63 64 65 66
/**
 * drm_usb_exit - Unregister matching USB devices from the DRM subsystem
 * @driver: DRM device driver
 * @udriver: USB device driver
 *
 * Unregisters one or more devices matched by a USB driver from the DRM
 * subsystem.
 */
D
Dave Airlie 已提交
67 68 69 70 71 72
void drm_usb_exit(struct drm_driver *driver,
		  struct usb_driver *udriver)
{
	usb_deregister(udriver);
}
EXPORT_SYMBOL(drm_usb_exit);
73 74 75 76

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