diff options
-rw-r--r-- | drivers/gpu/drm/Makefile | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_stub.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_usb.c | 117 | ||||
-rw-r--r-- | include/drm/drmP.h | 2 | ||||
-rw-r--r-- | include/drm/drm_usb.h | 15 |
5 files changed, 136 insertions, 1 deletions
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index d9cb3e314321..89cf05a72d1c 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile | |||
@@ -12,7 +12,7 @@ drm-y := drm_auth.o drm_buffer.o drm_bufs.o drm_cache.o \ | |||
12 | drm_platform.o drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \ | 12 | drm_platform.o drm_sysfs.o drm_hashtab.o drm_sman.o drm_mm.o \ |
13 | drm_crtc.o drm_modes.o drm_edid.o \ | 13 | drm_crtc.o drm_modes.o drm_edid.o \ |
14 | drm_info.o drm_debugfs.o drm_encoder_slave.o \ | 14 | drm_info.o drm_debugfs.o drm_encoder_slave.o \ |
15 | drm_trace_points.o drm_global.o | 15 | drm_trace_points.o drm_global.o drm_usb.o |
16 | 16 | ||
17 | drm-$(CONFIG_COMPAT) += drm_ioc32.o | 17 | drm-$(CONFIG_COMPAT) += drm_ioc32.o |
18 | 18 | ||
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index 0bf2c773c6c5..001273d57f2d 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c | |||
@@ -463,6 +463,7 @@ void drm_put_dev(struct drm_device *dev) | |||
463 | 463 | ||
464 | drm_put_minor(&dev->primary); | 464 | drm_put_minor(&dev->primary); |
465 | 465 | ||
466 | list_del(&dev->driver_item); | ||
466 | if (dev->devname) { | 467 | if (dev->devname) { |
467 | kfree(dev->devname); | 468 | kfree(dev->devname); |
468 | dev->devname = NULL; | 469 | dev->devname = NULL; |
diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c new file mode 100644 index 000000000000..206d2300d873 --- /dev/null +++ b/drivers/gpu/drm/drm_usb.c | |||
@@ -0,0 +1,117 @@ | |||
1 | #include "drmP.h" | ||
2 | #include <linux/usb.h> | ||
3 | |||
4 | #ifdef CONFIG_USB | ||
5 | int 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 | struct usb_device *usbdev; | ||
11 | int ret; | ||
12 | |||
13 | DRM_DEBUG("\n"); | ||
14 | |||
15 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); | ||
16 | if (!dev) | ||
17 | return -ENOMEM; | ||
18 | |||
19 | usbdev = interface_to_usbdev(interface); | ||
20 | dev->usbdev = usbdev; | ||
21 | dev->dev = &usbdev->dev; | ||
22 | |||
23 | mutex_lock(&drm_global_mutex); | ||
24 | |||
25 | ret = drm_fill_in_dev(dev, NULL, driver); | ||
26 | if (ret) { | ||
27 | printk(KERN_ERR "DRM: Fill_in_dev failed.\n"); | ||
28 | goto err_g1; | ||
29 | } | ||
30 | |||
31 | usb_set_intfdata(interface, dev); | ||
32 | ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL); | ||
33 | if (ret) | ||
34 | goto err_g1; | ||
35 | |||
36 | ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY); | ||
37 | if (ret) | ||
38 | goto err_g2; | ||
39 | |||
40 | if (dev->driver->load) { | ||
41 | ret = dev->driver->load(dev, 0); | ||
42 | if (ret) | ||
43 | goto err_g3; | ||
44 | } | ||
45 | |||
46 | /* setup the grouping for the legacy output */ | ||
47 | ret = drm_mode_group_init_legacy_group(dev, | ||
48 | &dev->primary->mode_group); | ||
49 | if (ret) | ||
50 | goto err_g3; | ||
51 | |||
52 | list_add_tail(&dev->driver_item, &driver->device_list); | ||
53 | |||
54 | mutex_unlock(&drm_global_mutex); | ||
55 | |||
56 | DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n", | ||
57 | driver->name, driver->major, driver->minor, driver->patchlevel, | ||
58 | driver->date, dev->primary->index); | ||
59 | |||
60 | return 0; | ||
61 | |||
62 | err_g3: | ||
63 | drm_put_minor(&dev->primary); | ||
64 | err_g2: | ||
65 | drm_put_minor(&dev->control); | ||
66 | err_g1: | ||
67 | kfree(dev); | ||
68 | mutex_unlock(&drm_global_mutex); | ||
69 | return ret; | ||
70 | |||
71 | } | ||
72 | EXPORT_SYMBOL(drm_get_usb_dev); | ||
73 | |||
74 | static int drm_usb_get_irq(struct drm_device *dev) | ||
75 | { | ||
76 | return 0; | ||
77 | } | ||
78 | |||
79 | static const char *drm_usb_get_name(struct drm_device *dev) | ||
80 | { | ||
81 | return "USB"; | ||
82 | } | ||
83 | |||
84 | static int drm_usb_set_busid(struct drm_device *dev, | ||
85 | struct drm_master *master) | ||
86 | { | ||
87 | return 0; | ||
88 | } | ||
89 | |||
90 | static struct drm_bus drm_usb_bus = { | ||
91 | .bus_type = DRIVER_BUS_USB, | ||
92 | .get_irq = drm_usb_get_irq, | ||
93 | .get_name = drm_usb_get_name, | ||
94 | .set_busid = drm_usb_set_busid, | ||
95 | }; | ||
96 | |||
97 | int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver) | ||
98 | { | ||
99 | int res; | ||
100 | DRM_DEBUG("\n"); | ||
101 | |||
102 | INIT_LIST_HEAD(&driver->device_list); | ||
103 | driver->kdriver.usb = udriver; | ||
104 | driver->bus = &drm_usb_bus; | ||
105 | |||
106 | res = usb_register(udriver); | ||
107 | return res; | ||
108 | } | ||
109 | EXPORT_SYMBOL(drm_usb_init); | ||
110 | |||
111 | void drm_usb_exit(struct drm_driver *driver, | ||
112 | struct usb_driver *udriver) | ||
113 | { | ||
114 | usb_deregister(udriver); | ||
115 | } | ||
116 | EXPORT_SYMBOL(drm_usb_exit); | ||
117 | #endif | ||
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index a99aefb9537c..52a2fd2f7789 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -925,6 +925,7 @@ struct drm_driver { | |||
925 | union { | 925 | union { |
926 | struct pci_driver *pci; | 926 | struct pci_driver *pci; |
927 | struct platform_device *platform_device; | 927 | struct platform_device *platform_device; |
928 | struct usb_driver *usb; | ||
928 | } kdriver; | 929 | } kdriver; |
929 | struct drm_bus *bus; | 930 | struct drm_bus *bus; |
930 | 931 | ||
@@ -1130,6 +1131,7 @@ struct drm_device { | |||
1130 | #endif | 1131 | #endif |
1131 | 1132 | ||
1132 | struct platform_device *platformdev; /**< Platform device struture */ | 1133 | struct platform_device *platformdev; /**< Platform device struture */ |
1134 | struct usb_device *usbdev; | ||
1133 | 1135 | ||
1134 | struct drm_sg_mem *sg; /**< Scatter gather memory */ | 1136 | struct drm_sg_mem *sg; /**< Scatter gather memory */ |
1135 | int num_crtcs; /**< Number of CRTCs on this device */ | 1137 | int num_crtcs; /**< Number of CRTCs on this device */ |
diff --git a/include/drm/drm_usb.h b/include/drm/drm_usb.h new file mode 100644 index 000000000000..33506c11da8b --- /dev/null +++ b/include/drm/drm_usb.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifndef DRM_USB_H | ||
2 | #define DRM_USB_H | ||
3 | |||
4 | #include <drmP.h> | ||
5 | |||
6 | #include <linux/usb.h> | ||
7 | |||
8 | extern int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver); | ||
9 | extern void drm_usb_exit(struct drm_driver *driver, struct usb_driver *udriver); | ||
10 | |||
11 | int drm_get_usb_dev(struct usb_interface *interface, | ||
12 | const struct usb_device_id *id, | ||
13 | struct drm_driver *driver); | ||
14 | |||
15 | #endif | ||