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
9 #include <linux/module.h>
11 #include <drm/drm_crtc_helper.h>
14 static int udl_usb_suspend(struct usb_interface
*interface
,
20 static int udl_usb_resume(struct usb_interface
*interface
)
22 struct drm_device
*dev
= usb_get_intfdata(interface
);
24 udl_modeset_restore(dev
);
28 static const struct vm_operations_struct udl_gem_vm_ops
= {
29 .fault
= udl_gem_fault
,
30 .open
= drm_gem_vm_open
,
31 .close
= drm_gem_vm_close
,
34 static const struct file_operations udl_driver_fops
= {
37 .mmap
= udl_drm_gem_mmap
,
40 .unlocked_ioctl
= drm_ioctl
,
41 .release
= drm_release
,
42 .compat_ioctl
= drm_compat_ioctl
,
43 .llseek
= noop_llseek
,
46 static struct drm_driver driver
= {
47 .driver_features
= DRIVER_MODESET
| DRIVER_GEM
| DRIVER_PRIME
,
48 .load
= udl_driver_load
,
49 .unload
= udl_driver_unload
,
52 .gem_free_object
= udl_gem_free_object
,
53 .gem_vm_ops
= &udl_gem_vm_ops
,
55 .dumb_create
= udl_dumb_create
,
56 .dumb_map_offset
= udl_gem_mmap
,
57 .fops
= &udl_driver_fops
,
59 .prime_handle_to_fd
= drm_gem_prime_handle_to_fd
,
60 .prime_fd_to_handle
= drm_gem_prime_fd_to_handle
,
61 .gem_prime_export
= udl_gem_prime_export
,
62 .gem_prime_import
= udl_gem_prime_import
,
67 .major
= DRIVER_MAJOR
,
68 .minor
= DRIVER_MINOR
,
69 .patchlevel
= DRIVER_PATCHLEVEL
,
72 static int udl_usb_probe(struct usb_interface
*interface
,
73 const struct usb_device_id
*id
)
75 struct usb_device
*udev
= interface_to_usbdev(interface
);
76 struct drm_device
*dev
;
79 dev
= drm_dev_alloc(&driver
, &interface
->dev
);
83 r
= drm_dev_register(dev
, (unsigned long)udev
);
87 usb_set_intfdata(interface
, dev
);
88 DRM_INFO("Initialized udl on minor %d\n", dev
->primary
->index
);
97 static void udl_usb_disconnect(struct usb_interface
*interface
)
99 struct drm_device
*dev
= usb_get_intfdata(interface
);
101 drm_kms_helper_poll_disable(dev
);
102 udl_fbdev_unplug(dev
);
108 * There are many DisplayLink-based graphics products, all with unique PIDs.
109 * So we match on DisplayLink's VID + Vendor-Defined Interface Class (0xff)
110 * We also require a match on SubClass (0x00) and Protocol (0x00),
111 * which is compatible with all known USB 2.0 era graphics chips and firmware,
112 * but allows DisplayLink to increment those for any future incompatible chips
114 static const struct usb_device_id id_table
[] = {
115 {.idVendor
= 0x17e9, .bInterfaceClass
= 0xff,
116 .bInterfaceSubClass
= 0x00,
117 .bInterfaceProtocol
= 0x00,
118 .match_flags
= USB_DEVICE_ID_MATCH_VENDOR
|
119 USB_DEVICE_ID_MATCH_INT_CLASS
|
120 USB_DEVICE_ID_MATCH_INT_SUBCLASS
|
121 USB_DEVICE_ID_MATCH_INT_PROTOCOL
,},
124 MODULE_DEVICE_TABLE(usb
, id_table
);
126 static struct usb_driver udl_driver
= {
128 .probe
= udl_usb_probe
,
129 .disconnect
= udl_usb_disconnect
,
130 .suspend
= udl_usb_suspend
,
131 .resume
= udl_usb_resume
,
132 .id_table
= id_table
,
134 module_usb_driver(udl_driver
);
135 MODULE_LICENSE("GPL");