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_driver_set_busid(struct drm_device
*d
, struct drm_master
*m
)
19 static const struct vm_operations_struct udl_gem_vm_ops
= {
20 .fault
= udl_gem_fault
,
21 .open
= drm_gem_vm_open
,
22 .close
= drm_gem_vm_close
,
25 static const struct file_operations udl_driver_fops
= {
28 .mmap
= udl_drm_gem_mmap
,
31 .unlocked_ioctl
= drm_ioctl
,
32 .release
= drm_release
,
34 .compat_ioctl
= drm_compat_ioctl
,
36 .llseek
= noop_llseek
,
39 static struct drm_driver driver
= {
40 .driver_features
= DRIVER_MODESET
| DRIVER_GEM
| DRIVER_PRIME
,
41 .load
= udl_driver_load
,
42 .unload
= udl_driver_unload
,
43 .set_busid
= udl_driver_set_busid
,
46 .gem_free_object
= udl_gem_free_object
,
47 .gem_vm_ops
= &udl_gem_vm_ops
,
49 .dumb_create
= udl_dumb_create
,
50 .dumb_map_offset
= udl_gem_mmap
,
51 .dumb_destroy
= drm_gem_dumb_destroy
,
52 .fops
= &udl_driver_fops
,
54 .prime_handle_to_fd
= drm_gem_prime_handle_to_fd
,
55 .prime_fd_to_handle
= drm_gem_prime_fd_to_handle
,
56 .gem_prime_export
= udl_gem_prime_export
,
57 .gem_prime_import
= udl_gem_prime_import
,
62 .major
= DRIVER_MAJOR
,
63 .minor
= DRIVER_MINOR
,
64 .patchlevel
= DRIVER_PATCHLEVEL
,
67 static int udl_usb_probe(struct usb_interface
*interface
,
68 const struct usb_device_id
*id
)
70 struct usb_device
*udev
= interface_to_usbdev(interface
);
71 struct drm_device
*dev
;
74 dev
= drm_dev_alloc(&driver
, &interface
->dev
);
78 r
= drm_dev_register(dev
, (unsigned long)udev
);
82 usb_set_intfdata(interface
, dev
);
83 DRM_INFO("Initialized udl on minor %d\n", dev
->primary
->index
);
92 static void udl_usb_disconnect(struct usb_interface
*interface
)
94 struct drm_device
*dev
= usb_get_intfdata(interface
);
96 drm_kms_helper_poll_disable(dev
);
97 drm_connector_unplug_all(dev
);
98 udl_fbdev_unplug(dev
);
104 * There are many DisplayLink-based graphics products, all with unique PIDs.
105 * So we match on DisplayLink's VID + Vendor-Defined Interface Class (0xff)
106 * We also require a match on SubClass (0x00) and Protocol (0x00),
107 * which is compatible with all known USB 2.0 era graphics chips and firmware,
108 * but allows DisplayLink to increment those for any future incompatible chips
110 static struct usb_device_id id_table
[] = {
111 {.idVendor
= 0x17e9, .bInterfaceClass
= 0xff,
112 .bInterfaceSubClass
= 0x00,
113 .bInterfaceProtocol
= 0x00,
114 .match_flags
= USB_DEVICE_ID_MATCH_VENDOR
|
115 USB_DEVICE_ID_MATCH_INT_CLASS
|
116 USB_DEVICE_ID_MATCH_INT_SUBCLASS
|
117 USB_DEVICE_ID_MATCH_INT_PROTOCOL
,},
120 MODULE_DEVICE_TABLE(usb
, id_table
);
122 static struct usb_driver udl_driver
= {
124 .probe
= udl_usb_probe
,
125 .disconnect
= udl_usb_disconnect
,
126 .id_table
= id_table
,
129 static int __init
udl_init(void)
131 return usb_register(&udl_driver
);
134 static void __exit
udl_exit(void)
136 usb_deregister(&udl_driver
);
139 module_init(udl_init
);
140 module_exit(udl_exit
);
141 MODULE_LICENSE("GPL");