aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-08-29 06:12:45 -0400
committerDave Airlie <airlied@redhat.com>2014-09-10 03:43:27 -0400
commitd4f68a7506e924e28a9153933076628002ba8bbc (patch)
tree339bb74dceb7476fd1ace6a18e499a440a045cb4 /drivers/gpu
parentc5786fe5f1c50941dbe27fc8b4aa1afee46ae893 (diff)
drm: merge drm_usb into udl
This merges all the remains of drm_usb into its only user, udl. We can then drop all the drm_usb stuff, including dev->usbdev. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/Kconfig6
-rw-r--r--drivers/gpu/drm/Makefile3
-rw-r--r--drivers/gpu/drm/drm_usb.c76
-rw-r--r--drivers/gpu/drm/udl/Kconfig3
-rw-r--r--drivers/gpu/drm/udl/udl_connector.c4
-rw-r--r--drivers/gpu/drm/udl/udl_drv.c102
-rw-r--r--drivers/gpu/drm/udl/udl_drv.h1
-rw-r--r--drivers/gpu/drm/udl/udl_main.c8
8 files changed, 69 insertions, 134 deletions
diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index e3500f9584ec..e3b4b0f02b3d 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -25,12 +25,6 @@ config DRM_MIPI_DSI
25 bool 25 bool
26 depends on DRM 26 depends on DRM
27 27
28config DRM_USB
29 tristate
30 depends on DRM
31 depends on USB_SUPPORT && USB_ARCH_HAS_HCD
32 select USB
33
34config DRM_KMS_HELPER 28config DRM_KMS_HELPER
35 tristate 29 tristate
36 depends on DRM 30 depends on DRM
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 9b7cb3f76f01..9292a761ea6d 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -22,8 +22,6 @@ drm-$(CONFIG_PCI) += ati_pcigart.o
22drm-$(CONFIG_DRM_PANEL) += drm_panel.o 22drm-$(CONFIG_DRM_PANEL) += drm_panel.o
23drm-$(CONFIG_OF) += drm_of.o 23drm-$(CONFIG_OF) += drm_of.o
24 24
25drm-usb-y := drm_usb.o
26
27drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \ 25drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
28 drm_plane_helper.o drm_dp_mst_topology.o 26 drm_plane_helper.o drm_dp_mst_topology.o
29drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o 27drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
@@ -36,7 +34,6 @@ CFLAGS_drm_trace_points.o := -I$(src)
36 34
37obj-$(CONFIG_DRM) += drm.o 35obj-$(CONFIG_DRM) += drm.o
38obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o 36obj-$(CONFIG_DRM_MIPI_DSI) += drm_mipi_dsi.o
39obj-$(CONFIG_DRM_USB) += drm_usb.o
40obj-$(CONFIG_DRM_TTM) += ttm/ 37obj-$(CONFIG_DRM_TTM) += ttm/
41obj-$(CONFIG_DRM_TDFX) += tdfx/ 38obj-$(CONFIG_DRM_TDFX) += tdfx/
42obj-$(CONFIG_DRM_R128) += r128/ 39obj-$(CONFIG_DRM_R128) += r128/
diff --git a/drivers/gpu/drm/drm_usb.c b/drivers/gpu/drm/drm_usb.c
deleted file mode 100644
index 9c434905d37f..000000000000
--- a/drivers/gpu/drm/drm_usb.c
+++ /dev/null
@@ -1,76 +0,0 @@
1#include <drm/drmP.h>
2#include <drm/drm_usb.h>
3#include <linux/usb.h>
4#include <linux/module.h>
5
6int 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;
11 int ret;
12
13 DRM_DEBUG("\n");
14
15 dev = drm_dev_alloc(driver, &interface->dev);
16 if (!dev)
17 return -ENOMEM;
18
19 dev->usbdev = interface_to_usbdev(interface);
20 usb_set_intfdata(interface, dev);
21
22 ret = drm_dev_register(dev, 0);
23 if (ret)
24 goto err_free;
25
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
32err_free:
33 drm_dev_unref(dev);
34 return ret;
35
36}
37EXPORT_SYMBOL(drm_get_usb_dev);
38
39/**
40 * drm_usb_init - Register matching USB devices with the DRM subsystem
41 * @driver: DRM device driver
42 * @udriver: USB device driver
43 *
44 * Registers one or more devices matched by a USB driver with the DRM
45 * subsystem.
46 *
47 * Return: 0 on success or a negative error code on failure.
48 */
49int drm_usb_init(struct drm_driver *driver, struct usb_driver *udriver)
50{
51 int res;
52 DRM_DEBUG("\n");
53
54 res = usb_register(udriver);
55 return res;
56}
57EXPORT_SYMBOL(drm_usb_init);
58
59/**
60 * drm_usb_exit - Unregister matching USB devices from the DRM subsystem
61 * @driver: DRM device driver
62 * @udriver: USB device driver
63 *
64 * Unregisters one or more devices matched by a USB driver from the DRM
65 * subsystem.
66 */
67void drm_usb_exit(struct drm_driver *driver,
68 struct usb_driver *udriver)
69{
70 usb_deregister(udriver);
71}
72EXPORT_SYMBOL(drm_usb_exit);
73
74MODULE_AUTHOR("David Airlie");
75MODULE_DESCRIPTION("USB DRM support");
76MODULE_LICENSE("GPL and additional rights");
diff --git a/drivers/gpu/drm/udl/Kconfig b/drivers/gpu/drm/udl/Kconfig
index f02528686cd5..613ab0622d6e 100644
--- a/drivers/gpu/drm/udl/Kconfig
+++ b/drivers/gpu/drm/udl/Kconfig
@@ -1,8 +1,9 @@
1config DRM_UDL 1config DRM_UDL
2 tristate "DisplayLink" 2 tristate "DisplayLink"
3 depends on DRM 3 depends on DRM
4 depends on USB_SUPPORT
4 depends on USB_ARCH_HAS_HCD 5 depends on USB_ARCH_HAS_HCD
5 select DRM_USB 6 select USB
6 select FB_SYS_FILLRECT 7 select FB_SYS_FILLRECT
7 select FB_SYS_COPYAREA 8 select FB_SYS_COPYAREA
8 select FB_SYS_IMAGEBLIT 9 select FB_SYS_IMAGEBLIT
diff --git a/drivers/gpu/drm/udl/udl_connector.c b/drivers/gpu/drm/udl/udl_connector.c
index e026a9e2942a..0110d95522f3 100644
--- a/drivers/gpu/drm/udl/udl_connector.c
+++ b/drivers/gpu/drm/udl/udl_connector.c
@@ -34,8 +34,8 @@ static u8 *udl_get_edid(struct udl_device *udl)
34 goto error; 34 goto error;
35 35
36 for (i = 0; i < EDID_LENGTH; i++) { 36 for (i = 0; i < EDID_LENGTH; i++) {
37 ret = usb_control_msg(udl->ddev->usbdev, 37 ret = usb_control_msg(udl->udev,
38 usb_rcvctrlpipe(udl->ddev->usbdev, 0), (0x02), 38 usb_rcvctrlpipe(udl->udev, 0), (0x02),
39 (0x80 | (0x02 << 5)), i << 8, 0xA1, rbuf, 2, 39 (0x80 | (0x02 << 5)), i << 8, 0xA1, rbuf, 2,
40 HZ); 40 HZ);
41 if (ret < 1) { 41 if (ret < 1) {
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c
index 06675e5d4342..8607e9e513db 100644
--- a/drivers/gpu/drm/udl/udl_drv.c
+++ b/drivers/gpu/drm/udl/udl_drv.c
@@ -7,55 +7,15 @@
7 */ 7 */
8 8
9#include <linux/module.h> 9#include <linux/module.h>
10#include <drm/drm_usb.h> 10#include <drm/drmP.h>
11#include <drm/drm_crtc_helper.h> 11#include <drm/drm_crtc_helper.h>
12#include "udl_drv.h" 12#include "udl_drv.h"
13 13
14static struct drm_driver driver;
15
16/*
17 * There are many DisplayLink-based graphics products, all with unique PIDs.
18 * So we match on DisplayLink's VID + Vendor-Defined Interface Class (0xff)
19 * We also require a match on SubClass (0x00) and Protocol (0x00),
20 * which is compatible with all known USB 2.0 era graphics chips and firmware,
21 * but allows DisplayLink to increment those for any future incompatible chips
22 */
23static struct usb_device_id id_table[] = {
24 {.idVendor = 0x17e9, .bInterfaceClass = 0xff,
25 .bInterfaceSubClass = 0x00,
26 .bInterfaceProtocol = 0x00,
27 .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
28 USB_DEVICE_ID_MATCH_INT_CLASS |
29 USB_DEVICE_ID_MATCH_INT_SUBCLASS |
30 USB_DEVICE_ID_MATCH_INT_PROTOCOL,},
31 {},
32};
33MODULE_DEVICE_TABLE(usb, id_table);
34
35MODULE_LICENSE("GPL");
36
37static int udl_driver_set_busid(struct drm_device *d, struct drm_master *m) 14static int udl_driver_set_busid(struct drm_device *d, struct drm_master *m)
38{ 15{
39 return 0; 16 return 0;
40} 17}
41 18
42static int udl_usb_probe(struct usb_interface *interface,
43 const struct usb_device_id *id)
44{
45 return drm_get_usb_dev(interface, id, &driver);
46}
47
48static void udl_usb_disconnect(struct usb_interface *interface)
49{
50 struct drm_device *dev = usb_get_intfdata(interface);
51
52 drm_kms_helper_poll_disable(dev);
53 drm_connector_unplug_all(dev);
54 udl_fbdev_unplug(dev);
55 udl_drop_usb(dev);
56 drm_unplug_dev(dev);
57}
58
59static const struct vm_operations_struct udl_gem_vm_ops = { 19static const struct vm_operations_struct udl_gem_vm_ops = {
60 .fault = udl_gem_fault, 20 .fault = udl_gem_fault,
61 .open = drm_gem_vm_open, 21 .open = drm_gem_vm_open,
@@ -102,6 +62,61 @@ static struct drm_driver driver = {
102 .patchlevel = DRIVER_PATCHLEVEL, 62 .patchlevel = DRIVER_PATCHLEVEL,
103}; 63};
104 64
65static int udl_usb_probe(struct usb_interface *interface,
66 const struct usb_device_id *id)
67{
68 struct usb_device *udev = interface_to_usbdev(interface);
69 struct drm_device *dev;
70 int r;
71
72 dev = drm_dev_alloc(&driver, &interface->dev);
73 if (!dev)
74 return -ENOMEM;
75
76 r = drm_dev_register(dev, (unsigned long)udev);
77 if (r)
78 goto err_free;
79
80 usb_set_intfdata(interface, dev);
81 DRM_INFO("Initialized udl on minor %d\n", dev->primary->index);
82
83 return 0;
84
85err_free:
86 drm_dev_unref(dev);
87 return r;
88}
89
90static void udl_usb_disconnect(struct usb_interface *interface)
91{
92 struct drm_device *dev = usb_get_intfdata(interface);
93
94 drm_kms_helper_poll_disable(dev);
95 drm_connector_unplug_all(dev);
96 udl_fbdev_unplug(dev);
97 udl_drop_usb(dev);
98 drm_unplug_dev(dev);
99}
100
101/*
102 * There are many DisplayLink-based graphics products, all with unique PIDs.
103 * So we match on DisplayLink's VID + Vendor-Defined Interface Class (0xff)
104 * We also require a match on SubClass (0x00) and Protocol (0x00),
105 * which is compatible with all known USB 2.0 era graphics chips and firmware,
106 * but allows DisplayLink to increment those for any future incompatible chips
107 */
108static struct usb_device_id id_table[] = {
109 {.idVendor = 0x17e9, .bInterfaceClass = 0xff,
110 .bInterfaceSubClass = 0x00,
111 .bInterfaceProtocol = 0x00,
112 .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
113 USB_DEVICE_ID_MATCH_INT_CLASS |
114 USB_DEVICE_ID_MATCH_INT_SUBCLASS |
115 USB_DEVICE_ID_MATCH_INT_PROTOCOL,},
116 {},
117};
118MODULE_DEVICE_TABLE(usb, id_table);
119
105static struct usb_driver udl_driver = { 120static struct usb_driver udl_driver = {
106 .name = "udl", 121 .name = "udl",
107 .probe = udl_usb_probe, 122 .probe = udl_usb_probe,
@@ -111,13 +126,14 @@ static struct usb_driver udl_driver = {
111 126
112static int __init udl_init(void) 127static int __init udl_init(void)
113{ 128{
114 return drm_usb_init(&driver, &udl_driver); 129 return usb_register(&udl_driver);
115} 130}
116 131
117static void __exit udl_exit(void) 132static void __exit udl_exit(void)
118{ 133{
119 drm_usb_exit(&driver, &udl_driver); 134 usb_deregister(&udl_driver);
120} 135}
121 136
122module_init(udl_init); 137module_init(udl_init);
123module_exit(udl_exit); 138module_exit(udl_exit);
139MODULE_LICENSE("GPL");
diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h
index 1fbf7b357f16..51e10ee77f39 100644
--- a/drivers/gpu/drm/udl/udl_drv.h
+++ b/drivers/gpu/drm/udl/udl_drv.h
@@ -47,6 +47,7 @@ struct udl_fbdev;
47struct udl_device { 47struct udl_device {
48 struct device *dev; 48 struct device *dev;
49 struct drm_device *ddev; 49 struct drm_device *ddev;
50 struct usb_device *udev;
50 51
51 int sku_pixel_limit; 52 int sku_pixel_limit;
52 53
diff --git a/drivers/gpu/drm/udl/udl_main.c b/drivers/gpu/drm/udl/udl_main.c
index 42795674bc07..33dbfb2c4748 100644
--- a/drivers/gpu/drm/udl/udl_main.c
+++ b/drivers/gpu/drm/udl/udl_main.c
@@ -202,7 +202,7 @@ static int udl_alloc_urb_list(struct drm_device *dev, int count, size_t size)
202 } 202 }
203 unode->urb = urb; 203 unode->urb = urb;
204 204
205 buf = usb_alloc_coherent(udl->ddev->usbdev, MAX_TRANSFER, GFP_KERNEL, 205 buf = usb_alloc_coherent(udl->udev, MAX_TRANSFER, GFP_KERNEL,
206 &urb->transfer_dma); 206 &urb->transfer_dma);
207 if (!buf) { 207 if (!buf) {
208 kfree(unode); 208 kfree(unode);
@@ -211,7 +211,7 @@ static int udl_alloc_urb_list(struct drm_device *dev, int count, size_t size)
211 } 211 }
212 212
213 /* urb->transfer_buffer_length set to actual before submit */ 213 /* urb->transfer_buffer_length set to actual before submit */
214 usb_fill_bulk_urb(urb, udl->ddev->usbdev, usb_sndbulkpipe(udl->ddev->usbdev, 1), 214 usb_fill_bulk_urb(urb, udl->udev, usb_sndbulkpipe(udl->udev, 1),
215 buf, size, udl_urb_completion, unode); 215 buf, size, udl_urb_completion, unode);
216 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 216 urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
217 217
@@ -282,6 +282,7 @@ int udl_submit_urb(struct drm_device *dev, struct urb *urb, size_t len)
282 282
283int udl_driver_load(struct drm_device *dev, unsigned long flags) 283int udl_driver_load(struct drm_device *dev, unsigned long flags)
284{ 284{
285 struct usb_device *udev = (void*)flags;
285 struct udl_device *udl; 286 struct udl_device *udl;
286 int ret = -ENOMEM; 287 int ret = -ENOMEM;
287 288
@@ -290,10 +291,11 @@ int udl_driver_load(struct drm_device *dev, unsigned long flags)
290 if (!udl) 291 if (!udl)
291 return -ENOMEM; 292 return -ENOMEM;
292 293
294 udl->udev = udev;
293 udl->ddev = dev; 295 udl->ddev = dev;
294 dev->dev_private = udl; 296 dev->dev_private = udl;
295 297
296 if (!udl_parse_vendor_descriptor(dev, dev->usbdev)) { 298 if (!udl_parse_vendor_descriptor(dev, udl->udev)) {
297 ret = -ENODEV; 299 ret = -ENODEV;
298 DRM_ERROR("firmware not recognized. Assume incompatible device\n"); 300 DRM_ERROR("firmware not recognized. Assume incompatible device\n");
299 goto err; 301 goto err;