Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cris-mirror.git] / drivers / gpu / drm / udl / udl_drv.c
blob3c45a306472655a2ea30e8576754862351cdb259
1 /*
2 * Copyright (C) 2012 Red Hat
4 * This file is subject to the terms and conditions of the GNU General Public
5 * License v2. See the file COPYING in the main directory of this archive for
6 * more details.
7 */
9 #include <linux/module.h>
10 #include <drm/drmP.h>
11 #include <drm/drm_crtc_helper.h>
12 #include "udl_drv.h"
14 static int udl_usb_suspend(struct usb_interface *interface,
15 pm_message_t message)
17 struct drm_device *dev = usb_get_intfdata(interface);
19 drm_kms_helper_poll_disable(dev);
20 return 0;
23 static int udl_usb_resume(struct usb_interface *interface)
25 struct drm_device *dev = usb_get_intfdata(interface);
27 drm_kms_helper_poll_enable(dev);
28 udl_modeset_restore(dev);
29 return 0;
32 static const struct vm_operations_struct udl_gem_vm_ops = {
33 .fault = udl_gem_fault,
34 .open = drm_gem_vm_open,
35 .close = drm_gem_vm_close,
38 static const struct file_operations udl_driver_fops = {
39 .owner = THIS_MODULE,
40 .open = drm_open,
41 .mmap = udl_drm_gem_mmap,
42 .poll = drm_poll,
43 .read = drm_read,
44 .unlocked_ioctl = drm_ioctl,
45 .release = drm_release,
46 .compat_ioctl = drm_compat_ioctl,
47 .llseek = noop_llseek,
50 static struct drm_driver driver = {
51 .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_PRIME,
52 .load = udl_driver_load,
53 .unload = udl_driver_unload,
55 /* gem hooks */
56 .gem_free_object = udl_gem_free_object,
57 .gem_vm_ops = &udl_gem_vm_ops,
59 .dumb_create = udl_dumb_create,
60 .dumb_map_offset = udl_gem_mmap,
61 .fops = &udl_driver_fops,
63 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
64 .prime_fd_to_handle = drm_gem_prime_fd_to_handle,
65 .gem_prime_export = udl_gem_prime_export,
66 .gem_prime_import = udl_gem_prime_import,
68 .name = DRIVER_NAME,
69 .desc = DRIVER_DESC,
70 .date = DRIVER_DATE,
71 .major = DRIVER_MAJOR,
72 .minor = DRIVER_MINOR,
73 .patchlevel = DRIVER_PATCHLEVEL,
76 static int udl_usb_probe(struct usb_interface *interface,
77 const struct usb_device_id *id)
79 struct usb_device *udev = interface_to_usbdev(interface);
80 struct drm_device *dev;
81 int r;
83 dev = drm_dev_alloc(&driver, &interface->dev);
84 if (IS_ERR(dev))
85 return PTR_ERR(dev);
87 r = drm_dev_register(dev, (unsigned long)udev);
88 if (r)
89 goto err_free;
91 usb_set_intfdata(interface, dev);
92 DRM_INFO("Initialized udl on minor %d\n", dev->primary->index);
94 return 0;
96 err_free:
97 drm_dev_unref(dev);
98 return r;
101 static void udl_usb_disconnect(struct usb_interface *interface)
103 struct drm_device *dev = usb_get_intfdata(interface);
105 drm_kms_helper_poll_disable(dev);
106 udl_fbdev_unplug(dev);
107 udl_drop_usb(dev);
108 drm_dev_unplug(dev);
112 * There are many DisplayLink-based graphics products, all with unique PIDs.
113 * So we match on DisplayLink's VID + Vendor-Defined Interface Class (0xff)
114 * We also require a match on SubClass (0x00) and Protocol (0x00),
115 * which is compatible with all known USB 2.0 era graphics chips and firmware,
116 * but allows DisplayLink to increment those for any future incompatible chips
118 static const struct usb_device_id id_table[] = {
119 {.idVendor = 0x17e9, .bInterfaceClass = 0xff,
120 .bInterfaceSubClass = 0x00,
121 .bInterfaceProtocol = 0x00,
122 .match_flags = USB_DEVICE_ID_MATCH_VENDOR |
123 USB_DEVICE_ID_MATCH_INT_CLASS |
124 USB_DEVICE_ID_MATCH_INT_SUBCLASS |
125 USB_DEVICE_ID_MATCH_INT_PROTOCOL,},
128 MODULE_DEVICE_TABLE(usb, id_table);
130 static struct usb_driver udl_driver = {
131 .name = "udl",
132 .probe = udl_usb_probe,
133 .disconnect = udl_usb_disconnect,
134 .suspend = udl_usb_suspend,
135 .resume = udl_usb_resume,
136 .id_table = id_table,
138 module_usb_driver(udl_driver);
139 MODULE_LICENSE("GPL");