1#include <drm/drmP.h> 2#include <linux/usb.h> 3#include <linux/module.h> 4 5int drm_get_usb_dev(struct usb_interface *interface, 6 const struct usb_device_id *id, 7 struct drm_driver *driver) 8{ 9 struct drm_device *dev; 10 int ret; 11 12 DRM_DEBUG("\n"); 13 14 dev = drm_dev_alloc(driver, &interface->dev); 15 if (!dev) 16 return -ENOMEM; 17 18 dev->usbdev = interface_to_usbdev(interface); 19 usb_set_intfdata(interface, dev); 20 21 ret = drm_dev_register(dev, 0); 22 if (ret) 23 goto err_free; 24 25 DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", 26 driver->name, driver->major, driver->minor, driver->patchlevel, 27 driver->date, dev->primary->index); 28 29 return 0; 30 31err_free: 32 drm_dev_free(dev); 33 return ret; 34 35} 36EXPORT_SYMBOL(drm_get_usb_dev); 37 38static int drm_usb_get_irq(struct drm_device *dev) 39{ 40 return 0; 41} 42 43static const char *drm_usb_get_name(struct drm_device *dev) 44{ 45 return "USB"; 46} 47 48static int drm_usb_set_busid(struct drm_device *dev, 49 struct drm_master *master) 50{ 51 return 0; 52} 53 54static struct drm_bus drm_usb_bus = { 55 .bus_type = DRIVER_BUS_USB, 56 .get_irq = drm_usb_get_irq, 57 .get_name = drm_usb_get_name, 58 .set_busid = drm_usb_set_busid, 59}; 60 61int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver) 62{ 63 int res; 64 DRM_DEBUG("\n"); 65 66 INIT_LIST_HEAD(&driver->device_list); 67 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); 81 82MODULE_AUTHOR("David Airlie"); 83MODULE_DESCRIPTION("USB DRM support"); 84MODULE_LICENSE("GPL and additional rights"); 85