Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.14-rc7 165 lines 4.1 kB view raw
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Copyright (C) 2012 Red Hat 4 */ 5 6#include <linux/module.h> 7 8#include <drm/clients/drm_client_setup.h> 9#include <drm/drm_drv.h> 10#include <drm/drm_fbdev_shmem.h> 11#include <drm/drm_file.h> 12#include <drm/drm_gem_shmem_helper.h> 13#include <drm/drm_managed.h> 14#include <drm/drm_modeset_helper.h> 15#include <drm/drm_ioctl.h> 16#include <drm/drm_probe_helper.h> 17#include <drm/drm_print.h> 18 19#include "udl_drv.h" 20 21static int udl_usb_suspend(struct usb_interface *interface, 22 pm_message_t message) 23{ 24 struct drm_device *dev = usb_get_intfdata(interface); 25 int ret; 26 27 ret = drm_mode_config_helper_suspend(dev); 28 if (ret) 29 return ret; 30 31 udl_sync_pending_urbs(dev); 32 return 0; 33} 34 35static int udl_usb_resume(struct usb_interface *interface) 36{ 37 struct drm_device *dev = usb_get_intfdata(interface); 38 39 return drm_mode_config_helper_resume(dev); 40} 41 42static int udl_usb_reset_resume(struct usb_interface *interface) 43{ 44 struct drm_device *dev = usb_get_intfdata(interface); 45 struct udl_device *udl = to_udl(dev); 46 47 udl_select_std_channel(udl); 48 49 return drm_mode_config_helper_resume(dev); 50} 51 52/* 53 * FIXME: Dma-buf sharing requires DMA support by the importing device. 54 * This function is a workaround to make USB devices work as well. 55 * See todo.rst for how to fix the issue in the dma-buf framework. 56 */ 57static struct drm_gem_object *udl_driver_gem_prime_import(struct drm_device *dev, 58 struct dma_buf *dma_buf) 59{ 60 struct udl_device *udl = to_udl(dev); 61 62 if (!udl->dmadev) 63 return ERR_PTR(-ENODEV); 64 65 return drm_gem_prime_import_dev(dev, dma_buf, udl->dmadev); 66} 67 68DEFINE_DRM_GEM_FOPS(udl_driver_fops); 69 70static const struct drm_driver driver = { 71 .driver_features = DRIVER_ATOMIC | DRIVER_GEM | DRIVER_MODESET, 72 73 /* GEM hooks */ 74 .fops = &udl_driver_fops, 75 DRM_GEM_SHMEM_DRIVER_OPS, 76 .gem_prime_import = udl_driver_gem_prime_import, 77 DRM_FBDEV_SHMEM_DRIVER_OPS, 78 79 .name = DRIVER_NAME, 80 .desc = DRIVER_DESC, 81 .major = DRIVER_MAJOR, 82 .minor = DRIVER_MINOR, 83 .patchlevel = DRIVER_PATCHLEVEL, 84}; 85 86static struct udl_device *udl_driver_create(struct usb_interface *interface) 87{ 88 struct udl_device *udl; 89 int r; 90 91 udl = devm_drm_dev_alloc(&interface->dev, &driver, 92 struct udl_device, drm); 93 if (IS_ERR(udl)) 94 return udl; 95 96 r = udl_init(udl); 97 if (r) 98 return ERR_PTR(r); 99 100 usb_set_intfdata(interface, udl); 101 102 return udl; 103} 104 105static int udl_usb_probe(struct usb_interface *interface, 106 const struct usb_device_id *id) 107{ 108 int r; 109 struct udl_device *udl; 110 111 udl = udl_driver_create(interface); 112 if (IS_ERR(udl)) 113 return PTR_ERR(udl); 114 115 r = drm_dev_register(&udl->drm, 0); 116 if (r) 117 return r; 118 119 DRM_INFO("Initialized udl on minor %d\n", udl->drm.primary->index); 120 121 drm_client_setup(&udl->drm, NULL); 122 123 return 0; 124} 125 126static void udl_usb_disconnect(struct usb_interface *interface) 127{ 128 struct drm_device *dev = usb_get_intfdata(interface); 129 130 drm_kms_helper_poll_fini(dev); 131 udl_drop_usb(dev); 132 drm_dev_unplug(dev); 133} 134 135/* 136 * There are many DisplayLink-based graphics products, all with unique PIDs. 137 * So we match on DisplayLink's VID + Vendor-Defined Interface Class (0xff) 138 * We also require a match on SubClass (0x00) and Protocol (0x00), 139 * which is compatible with all known USB 2.0 era graphics chips and firmware, 140 * but allows DisplayLink to increment those for any future incompatible chips 141 */ 142static const struct usb_device_id id_table[] = { 143 {.idVendor = 0x17e9, .bInterfaceClass = 0xff, 144 .bInterfaceSubClass = 0x00, 145 .bInterfaceProtocol = 0x00, 146 .match_flags = USB_DEVICE_ID_MATCH_VENDOR | 147 USB_DEVICE_ID_MATCH_INT_CLASS | 148 USB_DEVICE_ID_MATCH_INT_SUBCLASS | 149 USB_DEVICE_ID_MATCH_INT_PROTOCOL,}, 150 {}, 151}; 152MODULE_DEVICE_TABLE(usb, id_table); 153 154static struct usb_driver udl_driver = { 155 .name = "udl", 156 .probe = udl_usb_probe, 157 .disconnect = udl_usb_disconnect, 158 .suspend = udl_usb_suspend, 159 .resume = udl_usb_resume, 160 .reset_resume = udl_usb_reset_resume, 161 .id_table = id_table, 162}; 163module_usb_driver(udl_driver); 164MODULE_DESCRIPTION("KMS driver for the USB displaylink video adapters"); 165MODULE_LICENSE("GPL");