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
,
17 struct drm_device
*dev
= usb_get_intfdata(interface
);
19 drm_kms_helper_poll_disable(dev
);
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
);
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
= {
41 .mmap
= udl_drm_gem_mmap
,
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
,
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
,
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
;
83 dev
= drm_dev_alloc(&driver
, &interface
->dev
);
87 r
= drm_dev_register(dev
, (unsigned long)udev
);
91 usb_set_intfdata(interface
, dev
);
92 DRM_INFO("Initialized udl on minor %d\n", dev
->primary
->index
);
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
);
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
= {
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");