Daniel Vetter | f5752b3 | 2014-05-08 16:41:51 +0200 | [diff] [blame] | 1 | /* |
| 2 | * drm_irq.c IRQ and vblank support |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * \author Rickard E. (Rik) Faith <faith@valinux.com> |
| 5 | * \author Gareth Hughes <gareth@valinux.com> |
Daniel Vetter | 3ed4351 | 2017-05-31 11:21:46 +0200 | [diff] [blame] | 6 | * |
| 7 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 8 | * copy of this software and associated documentation files (the "Software"), |
| 9 | * to deal in the Software without restriction, including without limitation |
| 10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 11 | * and/or sell copies of the Software, and to permit persons to whom the |
| 12 | * Software is furnished to do so, subject to the following conditions: |
| 13 | * |
| 14 | * The above copyright notice and this permission notice (including the next |
| 15 | * paragraph) shall be included in all copies or substantial portions of the |
| 16 | * Software. |
| 17 | * |
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 21 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 22 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 23 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 24 | * OTHER DEALINGS IN THE SOFTWARE. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 25 | */ |
| 26 | |
| 27 | /* |
| 28 | * Created: Fri Mar 19 14:30:16 1999 by faith@valinux.com |
| 29 | * |
| 30 | * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas. |
| 31 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
| 32 | * All Rights Reserved. |
| 33 | * |
| 34 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 35 | * copy of this software and associated documentation files (the "Software"), |
| 36 | * to deal in the Software without restriction, including without limitation |
| 37 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 38 | * and/or sell copies of the Software, and to permit persons to whom the |
| 39 | * Software is furnished to do so, subject to the following conditions: |
| 40 | * |
| 41 | * The above copyright notice and this permission notice (including the next |
| 42 | * paragraph) shall be included in all copies or substantial portions of the |
| 43 | * Software. |
| 44 | * |
| 45 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 46 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 47 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 48 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 49 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 50 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 51 | * OTHER DEALINGS IN THE SOFTWARE. |
| 52 | */ |
| 53 | |
Daniel Vetter | 3ed4351 | 2017-05-31 11:21:46 +0200 | [diff] [blame] | 54 | #include <drm/drm_irq.h> |
David Howells | 760285e | 2012-10-02 18:01:07 +0100 | [diff] [blame] | 55 | #include <drm/drmP.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
| 57 | #include <linux/interrupt.h> /* For task queue support */ |
| 58 | |
Dave Airlie | 28d5204 | 2009-09-21 14:33:58 +1000 | [diff] [blame] | 59 | #include <linux/vgaarb.h> |
Paul Gortmaker | 2d1a8a4 | 2011-08-30 18:16:33 -0400 | [diff] [blame] | 60 | #include <linux/export.h> |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 61 | |
Daniel Vetter | 3ed4351 | 2017-05-31 11:21:46 +0200 | [diff] [blame] | 62 | #include "drm_internal.h" |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 63 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | /** |
Daniel Vetter | 16584b2 | 2017-05-31 11:22:53 +0200 | [diff] [blame] | 65 | * DOC: irq helpers |
| 66 | * |
| 67 | * The DRM core provides very simple support helpers to enable IRQ handling on a |
| 68 | * device through the drm_irq_install() and drm_irq_uninstall() functions. This |
| 69 | * only supports devices with a single interrupt on the main device stored in |
| 70 | * &drm_device.dev and set as the device paramter in drm_dev_alloc(). |
| 71 | * |
| 72 | * These IRQ helpers are strictly optional. Drivers which roll their own only |
| 73 | * need to set &drm_device.irq_enabled to signal the DRM core that vblank |
| 74 | * interrupts are working. Since these helpers don't automatically clean up the |
| 75 | * requested interrupt like e.g. devm_request_irq() they're not really |
| 76 | * recommended. |
| 77 | */ |
| 78 | |
| 79 | /** |
Daniel Vetter | f5752b3 | 2014-05-08 16:41:51 +0200 | [diff] [blame] | 80 | * drm_irq_install - install IRQ handler |
| 81 | * @dev: DRM device |
| 82 | * @irq: IRQ number to install the handler for |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | * |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 84 | * Initializes the IRQ related data. Installs the handler, calling the driver |
Daniel Vetter | 16584b2 | 2017-05-31 11:22:53 +0200 | [diff] [blame] | 85 | * &drm_driver.irq_preinstall and &drm_driver.irq_postinstall functions before |
| 86 | * and after the installation. |
Daniel Vetter | f5752b3 | 2014-05-08 16:41:51 +0200 | [diff] [blame] | 87 | * |
| 88 | * This is the simplified helper interface provided for drivers with no special |
| 89 | * needs. Drivers which need to install interrupt handlers for multiple |
Daniel Vetter | ef40cbf9 | 2017-01-25 07:26:47 +0100 | [diff] [blame] | 90 | * interrupts must instead set &drm_device.irq_enabled to signal the DRM core |
Daniel Vetter | f5752b3 | 2014-05-08 16:41:51 +0200 | [diff] [blame] | 91 | * that vblank interrupts are available. |
| 92 | * |
Daniel Vetter | 16584b2 | 2017-05-31 11:22:53 +0200 | [diff] [blame] | 93 | * @irq must match the interrupt number that would be passed to request_irq(), |
| 94 | * if called directly instead of using this helper function. |
| 95 | * |
| 96 | * &drm_driver.irq_handler is called to handle the registered interrupt. |
| 97 | * |
Daniel Vetter | f5752b3 | 2014-05-08 16:41:51 +0200 | [diff] [blame] | 98 | * Returns: |
| 99 | * Zero on success or a negative error code on failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | */ |
Daniel Vetter | bb0f1b5 | 2013-11-03 21:09:27 +0100 | [diff] [blame] | 101 | int drm_irq_install(struct drm_device *dev, int irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | { |
Laurent Pinchart | 4a1b071 | 2012-05-17 13:27:21 +0200 | [diff] [blame] | 103 | int ret; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 104 | unsigned long sh_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | |
| 106 | if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) |
| 107 | return -EINVAL; |
| 108 | |
Daniel Vetter | 7c1a38e | 2013-12-16 11:21:15 +0100 | [diff] [blame] | 109 | if (irq == 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | return -EINVAL; |
| 111 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | /* Driver must have been initialized */ |
Daniel Vetter | e090c53 | 2013-11-03 20:27:05 +0100 | [diff] [blame] | 113 | if (!dev->dev_private) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | |
Daniel Vetter | e090c53 | 2013-11-03 20:27:05 +0100 | [diff] [blame] | 116 | if (dev->irq_enabled) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | return -EBUSY; |
Ville Syrjälä | 4423843 | 2013-10-04 14:53:37 +0300 | [diff] [blame] | 118 | dev->irq_enabled = true; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
Daniel Vetter | 7c1a38e | 2013-12-16 11:21:15 +0100 | [diff] [blame] | 120 | DRM_DEBUG("irq=%d\n", irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 122 | /* Before installing handler */ |
Joonyoung Shim | 5037f8a | 2011-08-04 05:41:01 +0000 | [diff] [blame] | 123 | if (dev->driver->irq_preinstall) |
| 124 | dev->driver->irq_preinstall(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 126 | /* Install handler */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED)) |
Thomas Gleixner | 935f6e3 | 2006-07-01 19:29:34 -0700 | [diff] [blame] | 128 | sh_flags = IRQF_SHARED; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 129 | |
Daniel Vetter | 7c1a38e | 2013-12-16 11:21:15 +0100 | [diff] [blame] | 130 | ret = request_irq(irq, dev->driver->irq_handler, |
Daniel Vetter | 5829d18 | 2013-11-03 21:48:48 +0100 | [diff] [blame] | 131 | sh_flags, dev->driver->name, dev); |
Jesse Barnes | 9bfbd5c | 2008-09-15 15:00:33 -0700 | [diff] [blame] | 132 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 133 | if (ret < 0) { |
Ville Syrjälä | 4423843 | 2013-10-04 14:53:37 +0300 | [diff] [blame] | 134 | dev->irq_enabled = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | return ret; |
| 136 | } |
| 137 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 138 | /* After installing handler */ |
Joonyoung Shim | 5037f8a | 2011-08-04 05:41:01 +0000 | [diff] [blame] | 139 | if (dev->driver->irq_postinstall) |
| 140 | ret = dev->driver->irq_postinstall(dev); |
| 141 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 142 | if (ret < 0) { |
Ville Syrjälä | 4423843 | 2013-10-04 14:53:37 +0300 | [diff] [blame] | 143 | dev->irq_enabled = false; |
Daniel Vetter | fa53864 | 2016-08-03 21:11:10 +0200 | [diff] [blame] | 144 | if (drm_core_check_feature(dev, DRIVER_LEGACY)) |
Joonyoung Shim | e1c44ac | 2011-08-04 05:41:00 +0000 | [diff] [blame] | 145 | vga_client_register(dev->pdev, NULL, NULL, NULL); |
Daniel Vetter | 7c1a38e | 2013-12-16 11:21:15 +0100 | [diff] [blame] | 146 | free_irq(irq, dev); |
| 147 | } else { |
| 148 | dev->irq = irq; |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 149 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 151 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | } |
Jesse Barnes | 0a3e67a | 2008-09-30 12:14:26 -0700 | [diff] [blame] | 153 | EXPORT_SYMBOL(drm_irq_install); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | |
| 155 | /** |
Daniel Vetter | f5752b3 | 2014-05-08 16:41:51 +0200 | [diff] [blame] | 156 | * drm_irq_uninstall - uninstall the IRQ handler |
| 157 | * @dev: DRM device |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | * |
Daniel Vetter | 16584b2 | 2017-05-31 11:22:53 +0200 | [diff] [blame] | 159 | * Calls the driver's &drm_driver.irq_uninstall function and unregisters the IRQ |
| 160 | * handler. This should only be called by drivers which used drm_irq_install() |
| 161 | * to set up their interrupt handler. Other drivers must only reset |
Daniel Vetter | ef40cbf9 | 2017-01-25 07:26:47 +0100 | [diff] [blame] | 162 | * &drm_device.irq_enabled to false. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | * |
Daniel Vetter | f5752b3 | 2014-05-08 16:41:51 +0200 | [diff] [blame] | 164 | * Note that for kernel modesetting drivers it is a bug if this function fails. |
| 165 | * The sanity checks are only to catch buggy user modesetting drivers which call |
| 166 | * the same function through an ioctl. |
| 167 | * |
| 168 | * Returns: |
| 169 | * Zero on success or a negative error code on failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | */ |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 171 | int drm_irq_uninstall(struct drm_device *dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | { |
Jesse Barnes | dc1336f | 2009-01-06 10:21:24 -0800 | [diff] [blame] | 173 | unsigned long irqflags; |
Ville Syrjälä | 4423843 | 2013-10-04 14:53:37 +0300 | [diff] [blame] | 174 | bool irq_enabled; |
| 175 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
| 177 | if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) |
| 178 | return -EINVAL; |
| 179 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | irq_enabled = dev->irq_enabled; |
Ville Syrjälä | 4423843 | 2013-10-04 14:53:37 +0300 | [diff] [blame] | 181 | dev->irq_enabled = false; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Jesse Barnes | dc1336f | 2009-01-06 10:21:24 -0800 | [diff] [blame] | 183 | /* |
Daniel Vetter | 3bff93d | 2015-02-22 15:11:19 +0100 | [diff] [blame] | 184 | * Wake up any waiters so they don't hang. This is just to paper over |
Frank Binns | c78d1ca | 2016-06-24 11:15:37 +0100 | [diff] [blame] | 185 | * issues for UMS drivers which aren't in full control of their |
Daniel Vetter | 3bff93d | 2015-02-22 15:11:19 +0100 | [diff] [blame] | 186 | * vblank/irq handling. KMS drivers must ensure that vblanks are all |
| 187 | * disabled when uninstalling the irq handler. |
Jesse Barnes | dc1336f | 2009-01-06 10:21:24 -0800 | [diff] [blame] | 188 | */ |
Ben Skeggs | bde4889 | 2011-07-04 12:52:27 +1000 | [diff] [blame] | 189 | if (dev->num_crtcs) { |
| 190 | spin_lock_irqsave(&dev->vbl_lock, irqflags); |
| 191 | for (i = 0; i < dev->num_crtcs; i++) { |
Ville Syrjälä | 8a51d5b | 2014-08-06 14:49:50 +0300 | [diff] [blame] | 192 | struct drm_vblank_crtc *vblank = &dev->vblank[i]; |
| 193 | |
Daniel Vetter | 3bff93d | 2015-02-22 15:11:19 +0100 | [diff] [blame] | 194 | if (!vblank->enabled) |
| 195 | continue; |
| 196 | |
| 197 | WARN_ON(drm_core_check_feature(dev, DRIVER_MODESET)); |
| 198 | |
Daniel Vetter | 3ed4351 | 2017-05-31 11:21:46 +0200 | [diff] [blame] | 199 | drm_vblank_disable_and_save(dev, i); |
Ville Syrjälä | 8a51d5b | 2014-08-06 14:49:50 +0300 | [diff] [blame] | 200 | wake_up(&vblank->queue); |
Ben Skeggs | bde4889 | 2011-07-04 12:52:27 +1000 | [diff] [blame] | 201 | } |
| 202 | spin_unlock_irqrestore(&dev->vbl_lock, irqflags); |
Jesse Barnes | dc1336f | 2009-01-06 10:21:24 -0800 | [diff] [blame] | 203 | } |
Jesse Barnes | dc1336f | 2009-01-06 10:21:24 -0800 | [diff] [blame] | 204 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 205 | if (!irq_enabled) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | return -EINVAL; |
| 207 | |
Daniel Vetter | 7c1a38e | 2013-12-16 11:21:15 +0100 | [diff] [blame] | 208 | DRM_DEBUG("irq=%d\n", dev->irq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Daniel Vetter | fa53864 | 2016-08-03 21:11:10 +0200 | [diff] [blame] | 210 | if (drm_core_check_feature(dev, DRIVER_LEGACY)) |
Dave Airlie | 28d5204 | 2009-09-21 14:33:58 +1000 | [diff] [blame] | 211 | vga_client_register(dev->pdev, NULL, NULL, NULL); |
| 212 | |
Joonyoung Shim | 5037f8a | 2011-08-04 05:41:01 +0000 | [diff] [blame] | 213 | if (dev->driver->irq_uninstall) |
| 214 | dev->driver->irq_uninstall(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 215 | |
Daniel Vetter | 7c1a38e | 2013-12-16 11:21:15 +0100 | [diff] [blame] | 216 | free_irq(dev->irq, dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
| 218 | return 0; |
| 219 | } |
| 220 | EXPORT_SYMBOL(drm_irq_uninstall); |
| 221 | |
Daniel Vetter | 25a9939 | 2016-12-14 00:08:02 +0100 | [diff] [blame] | 222 | int drm_legacy_irq_control(struct drm_device *dev, void *data, |
| 223 | struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 224 | { |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 225 | struct drm_control *ctl = data; |
Daniel Vetter | a319c1a | 2013-11-03 21:09:15 +0100 | [diff] [blame] | 226 | int ret = 0, irq; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 227 | |
Mario Kleiner | 27641c3 | 2010-10-23 04:20:23 +0200 | [diff] [blame] | 228 | /* if we haven't irq we fallback for compatibility reasons - |
| 229 | * this used to be a separate function in drm_dma.h |
| 230 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | |
Daniel Vetter | 22471cf | 2013-11-03 20:02:50 +0100 | [diff] [blame] | 232 | if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) |
| 233 | return 0; |
Daniel Vetter | fa53864 | 2016-08-03 21:11:10 +0200 | [diff] [blame] | 234 | if (!drm_core_check_feature(dev, DRIVER_LEGACY)) |
Daniel Vetter | 22471cf | 2013-11-03 20:02:50 +0100 | [diff] [blame] | 235 | return 0; |
Frank Binns | c78d1ca | 2016-06-24 11:15:37 +0100 | [diff] [blame] | 236 | /* UMS was only ever supported on pci devices. */ |
Daniel Vetter | 22471cf | 2013-11-03 20:02:50 +0100 | [diff] [blame] | 237 | if (WARN_ON(!dev->pdev)) |
| 238 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 240 | switch (ctl->func) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | case DRM_INST_HANDLER: |
Daniel Vetter | a319c1a | 2013-11-03 21:09:15 +0100 | [diff] [blame] | 242 | irq = dev->pdev->irq; |
| 243 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 | if (dev->if_version < DRM_IF_VERSION(1, 2) && |
Daniel Vetter | a319c1a | 2013-11-03 21:09:15 +0100 | [diff] [blame] | 245 | ctl->irq != irq) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 246 | return -EINVAL; |
Daniel Vetter | e090c53 | 2013-11-03 20:27:05 +0100 | [diff] [blame] | 247 | mutex_lock(&dev->struct_mutex); |
Daniel Vetter | bb0f1b5 | 2013-11-03 21:09:27 +0100 | [diff] [blame] | 248 | ret = drm_irq_install(dev, irq); |
Daniel Vetter | e090c53 | 2013-11-03 20:27:05 +0100 | [diff] [blame] | 249 | mutex_unlock(&dev->struct_mutex); |
| 250 | |
| 251 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | case DRM_UNINST_HANDLER: |
Daniel Vetter | e090c53 | 2013-11-03 20:27:05 +0100 | [diff] [blame] | 253 | mutex_lock(&dev->struct_mutex); |
| 254 | ret = drm_irq_uninstall(dev); |
| 255 | mutex_unlock(&dev->struct_mutex); |
| 256 | |
| 257 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | default: |
| 259 | return -EINVAL; |
| 260 | } |
| 261 | } |