Dave Airlie | 5320918 | 2010-12-15 07:14:24 +1000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 Red Hat |
| 3 | * |
| 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 | */ |
| 8 | |
| 9 | #include <linux/module.h> |
| 10 | #include "drm_usb.h" |
| 11 | #include "drm_crtc_helper.h" |
| 12 | #include "udl_drv.h" |
| 13 | |
| 14 | static struct drm_driver driver; |
| 15 | |
| 16 | static struct usb_device_id id_table[] = { |
| 17 | {.idVendor = 0x17e9, .match_flags = USB_DEVICE_ID_MATCH_VENDOR,}, |
| 18 | {}, |
| 19 | }; |
| 20 | MODULE_DEVICE_TABLE(usb, id_table); |
| 21 | |
| 22 | MODULE_LICENSE("GPL"); |
| 23 | |
| 24 | static int udl_usb_probe(struct usb_interface *interface, |
| 25 | const struct usb_device_id *id) |
| 26 | { |
| 27 | return drm_get_usb_dev(interface, id, &driver); |
| 28 | } |
| 29 | |
| 30 | static void udl_usb_disconnect(struct usb_interface *interface) |
| 31 | { |
| 32 | struct drm_device *dev = usb_get_intfdata(interface); |
| 33 | |
| 34 | drm_kms_helper_poll_disable(dev); |
| 35 | drm_connector_unplug_all(dev); |
| 36 | udl_fbdev_unplug(dev); |
| 37 | udl_drop_usb(dev); |
| 38 | drm_unplug_dev(dev); |
| 39 | } |
| 40 | |
Laurent Pinchart | 78b6855 | 2012-05-17 13:27:22 +0200 | [diff] [blame^] | 41 | static const struct vm_operations_struct udl_gem_vm_ops = { |
Dave Airlie | 5320918 | 2010-12-15 07:14:24 +1000 | [diff] [blame] | 42 | .fault = udl_gem_fault, |
| 43 | .open = drm_gem_vm_open, |
| 44 | .close = drm_gem_vm_close, |
| 45 | }; |
| 46 | |
| 47 | static const struct file_operations udl_driver_fops = { |
| 48 | .owner = THIS_MODULE, |
| 49 | .open = drm_open, |
Konstantin Khlebnikov | fa9e855 | 2012-03-31 13:29:25 +0400 | [diff] [blame] | 50 | .mmap = udl_drm_gem_mmap, |
Dave Airlie | 5320918 | 2010-12-15 07:14:24 +1000 | [diff] [blame] | 51 | .poll = drm_poll, |
| 52 | .read = drm_read, |
| 53 | .unlocked_ioctl = drm_ioctl, |
| 54 | .release = drm_release, |
| 55 | .fasync = drm_fasync, |
| 56 | .llseek = noop_llseek, |
| 57 | }; |
| 58 | |
| 59 | static struct drm_driver driver = { |
| 60 | .driver_features = DRIVER_MODESET | DRIVER_GEM, |
| 61 | .load = udl_driver_load, |
| 62 | .unload = udl_driver_unload, |
| 63 | |
| 64 | /* gem hooks */ |
| 65 | .gem_init_object = udl_gem_init_object, |
| 66 | .gem_free_object = udl_gem_free_object, |
| 67 | .gem_vm_ops = &udl_gem_vm_ops, |
| 68 | |
| 69 | .dumb_create = udl_dumb_create, |
| 70 | .dumb_map_offset = udl_gem_mmap, |
| 71 | .dumb_destroy = udl_dumb_destroy, |
| 72 | .fops = &udl_driver_fops, |
| 73 | .name = DRIVER_NAME, |
| 74 | .desc = DRIVER_DESC, |
| 75 | .date = DRIVER_DATE, |
| 76 | .major = DRIVER_MAJOR, |
| 77 | .minor = DRIVER_MINOR, |
| 78 | .patchlevel = DRIVER_PATCHLEVEL, |
| 79 | }; |
| 80 | |
| 81 | static struct usb_driver udl_driver = { |
| 82 | .name = "udl", |
| 83 | .probe = udl_usb_probe, |
| 84 | .disconnect = udl_usb_disconnect, |
| 85 | .id_table = id_table, |
| 86 | }; |
| 87 | |
| 88 | static int __init udl_init(void) |
| 89 | { |
| 90 | return drm_usb_init(&driver, &udl_driver); |
| 91 | } |
| 92 | |
| 93 | static void __exit udl_exit(void) |
| 94 | { |
| 95 | drm_usb_exit(&driver, &udl_driver); |
| 96 | } |
| 97 | |
| 98 | module_init(udl_init); |
| 99 | module_exit(udl_exit); |