Dave Airlie | 94bb598 | 2006-12-19 17:49:08 +1100 | [diff] [blame] | 1 | /* radeon_irq.c -- IRQ handling for radeon -*- linux-c -*- */ |
| 2 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved. |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 4 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | * The Weather Channel (TM) funded Tungsten Graphics to develop the |
| 6 | * initial release of the Radeon 8500 driver under the XFree86 license. |
| 7 | * This notice must be preserved. |
| 8 | * |
| 9 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 10 | * copy of this software and associated documentation files (the "Software"), |
| 11 | * to deal in the Software without restriction, including without limitation |
| 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 13 | * and/or sell copies of the Software, and to permit persons to whom the |
| 14 | * Software is furnished to do so, subject to the following conditions: |
| 15 | * |
| 16 | * The above copyright notice and this permission notice (including the next |
| 17 | * paragraph) shall be included in all copies or substantial portions of the |
| 18 | * Software. |
| 19 | * |
| 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 23 | * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 24 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 25 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 26 | * DEALINGS IN THE SOFTWARE. |
| 27 | * |
| 28 | * Authors: |
| 29 | * Keith Whitwell <keith@tungstengraphics.com> |
Jan Engelhardt | 96de0e2 | 2007-10-19 23:21:04 +0200 | [diff] [blame] | 30 | * Michel Dänzer <michel@daenzer.net> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | */ |
| 32 | |
| 33 | #include "drmP.h" |
| 34 | #include "drm.h" |
| 35 | #include "radeon_drm.h" |
| 36 | #include "radeon_drv.h" |
| 37 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 38 | static __inline__ u32 radeon_acknowledge_irqs(drm_radeon_private_t * dev_priv, |
| 39 | u32 mask) |
Dave Airlie | 6921e33 | 2005-06-26 21:05:59 +1000 | [diff] [blame] | 40 | { |
| 41 | u32 irqs = RADEON_READ(RADEON_GEN_INT_STATUS) & mask; |
| 42 | if (irqs) |
| 43 | RADEON_WRITE(RADEON_GEN_INT_STATUS, irqs); |
| 44 | return irqs; |
| 45 | } |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | /* Interrupts - Used for device synchronization and flushing in the |
| 48 | * following circumstances: |
| 49 | * |
| 50 | * - Exclusive FB access with hw idle: |
| 51 | * - Wait for GUI Idle (?) interrupt, then do normal flush. |
| 52 | * |
| 53 | * - Frame throttling, NV_fence: |
| 54 | * - Drop marker irq's into command stream ahead of time. |
| 55 | * - Wait on irq's with lock *not held* |
| 56 | * - Check each for termination condition |
| 57 | * |
| 58 | * - Internally in cp_getbuffer, etc: |
| 59 | * - as above, but wait with lock held??? |
| 60 | * |
| 61 | * NOTE: These functions are misleadingly named -- the irq's aren't |
| 62 | * tied to dma at all, this is just a hangover from dri prehistory. |
| 63 | */ |
| 64 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 65 | irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | { |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 67 | struct drm_device *dev = (struct drm_device *) arg; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 68 | drm_radeon_private_t *dev_priv = |
| 69 | (drm_radeon_private_t *) dev->dev_private; |
| 70 | u32 stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
| 72 | /* Only consider the bits we're interested in - others could be used |
| 73 | * outside the DRM |
| 74 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 75 | stat = radeon_acknowledge_irqs(dev_priv, (RADEON_SW_INT_TEST_ACK | |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 76 | RADEON_CRTC_VBLANK_STAT | |
| 77 | RADEON_CRTC2_VBLANK_STAT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | if (!stat) |
| 79 | return IRQ_NONE; |
| 80 | |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 81 | stat &= dev_priv->irq_enable_reg; |
| 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | /* SW interrupt */ |
| 84 | if (stat & RADEON_SW_INT_TEST) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 85 | DRM_WAKEUP(&dev_priv->swi_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | /* VBLANK interrupt */ |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 89 | if (stat & (RADEON_CRTC_VBLANK_STAT|RADEON_CRTC2_VBLANK_STAT)) { |
| 90 | int vblank_crtc = dev_priv->vblank_crtc; |
| 91 | |
| 92 | if ((vblank_crtc & |
| 93 | (DRM_RADEON_VBLANK_CRTC1 | DRM_RADEON_VBLANK_CRTC2)) == |
| 94 | (DRM_RADEON_VBLANK_CRTC1 | DRM_RADEON_VBLANK_CRTC2)) { |
| 95 | if (stat & RADEON_CRTC_VBLANK_STAT) |
| 96 | atomic_inc(&dev->vbl_received); |
| 97 | if (stat & RADEON_CRTC2_VBLANK_STAT) |
| 98 | atomic_inc(&dev->vbl_received2); |
| 99 | } else if (((stat & RADEON_CRTC_VBLANK_STAT) && |
| 100 | (vblank_crtc & DRM_RADEON_VBLANK_CRTC1)) || |
| 101 | ((stat & RADEON_CRTC2_VBLANK_STAT) && |
| 102 | (vblank_crtc & DRM_RADEON_VBLANK_CRTC2))) |
| 103 | atomic_inc(&dev->vbl_received); |
| 104 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | DRM_WAKEUP(&dev->vbl_queue); |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 106 | drm_vbl_send_signals(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | } |
| 108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | return IRQ_HANDLED; |
| 110 | } |
| 111 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 112 | static int radeon_emit_irq(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | { |
| 114 | drm_radeon_private_t *dev_priv = dev->dev_private; |
| 115 | unsigned int ret; |
| 116 | RING_LOCALS; |
| 117 | |
| 118 | atomic_inc(&dev_priv->swi_emitted); |
| 119 | ret = atomic_read(&dev_priv->swi_emitted); |
| 120 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 121 | BEGIN_RING(4); |
| 122 | OUT_RING_REG(RADEON_LAST_SWI_REG, ret); |
| 123 | OUT_RING_REG(RADEON_GEN_INT_STATUS, RADEON_SW_INT_FIRE); |
| 124 | ADVANCE_RING(); |
| 125 | COMMIT_RING(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
| 127 | return ret; |
| 128 | } |
| 129 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 130 | static int radeon_wait_irq(struct drm_device * dev, int swi_nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 131 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 132 | drm_radeon_private_t *dev_priv = |
| 133 | (drm_radeon_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | int ret = 0; |
| 135 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 136 | if (RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr) |
| 137 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 138 | |
| 139 | dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; |
| 140 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 141 | DRM_WAIT_ON(ret, dev_priv->swi_queue, 3 * DRM_HZ, |
| 142 | RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | |
| 144 | return ret; |
| 145 | } |
| 146 | |
Adrian Bunk | f75a71f | 2007-10-16 01:28:46 -0700 | [diff] [blame] | 147 | static int radeon_driver_vblank_do_wait(struct drm_device * dev, |
| 148 | unsigned int *sequence, int crtc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 149 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 150 | drm_radeon_private_t *dev_priv = |
| 151 | (drm_radeon_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | unsigned int cur_vblank; |
| 153 | int ret = 0; |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 154 | int ack = 0; |
| 155 | atomic_t *counter; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 156 | if (!dev_priv) { |
| 157 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 158 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | } |
| 160 | |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 161 | if (crtc == DRM_RADEON_VBLANK_CRTC1) { |
| 162 | counter = &dev->vbl_received; |
| 163 | ack |= RADEON_CRTC_VBLANK_STAT; |
| 164 | } else if (crtc == DRM_RADEON_VBLANK_CRTC2) { |
| 165 | counter = &dev->vbl_received2; |
| 166 | ack |= RADEON_CRTC2_VBLANK_STAT; |
| 167 | } else |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 168 | return -EINVAL; |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 169 | |
| 170 | radeon_acknowledge_irqs(dev_priv, ack); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
| 172 | dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; |
| 173 | |
| 174 | /* Assume that the user has missed the current sequence number |
| 175 | * by about a day rather than she wants to wait for years |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 176 | * using vertical blanks... |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 178 | DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ, |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 179 | (((cur_vblank = atomic_read(counter)) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 180 | - *sequence) <= (1 << 23))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
| 182 | *sequence = cur_vblank; |
| 183 | |
| 184 | return ret; |
| 185 | } |
| 186 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 187 | int radeon_driver_vblank_wait(struct drm_device *dev, unsigned int *sequence) |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 188 | { |
| 189 | return radeon_driver_vblank_do_wait(dev, sequence, DRM_RADEON_VBLANK_CRTC1); |
| 190 | } |
| 191 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 192 | int radeon_driver_vblank_wait2(struct drm_device *dev, unsigned int *sequence) |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 193 | { |
| 194 | return radeon_driver_vblank_do_wait(dev, sequence, DRM_RADEON_VBLANK_CRTC2); |
| 195 | } |
| 196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | /* Needs the lock as it touches the ring. |
| 198 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 199 | int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | drm_radeon_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 202 | drm_radeon_irq_emit_t *emit = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 203 | int result; |
| 204 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 205 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 207 | if (!dev_priv) { |
| 208 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 209 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 212 | result = radeon_emit_irq(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 213 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 214 | if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 215 | DRM_ERROR("copy_to_user\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 216 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | } |
| 218 | |
| 219 | return 0; |
| 220 | } |
| 221 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | /* Doesn't need the hardware lock. |
| 223 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 224 | int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | drm_radeon_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 227 | drm_radeon_irq_wait_t *irqwait = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 229 | if (!dev_priv) { |
| 230 | DRM_ERROR("%s called with no initialization\n", __FUNCTION__); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 231 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 234 | return radeon_wait_irq(dev, irqwait->irq_seq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 237 | static void radeon_enable_interrupt(struct drm_device *dev) |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 238 | { |
| 239 | drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; |
| 240 | |
| 241 | dev_priv->irq_enable_reg = RADEON_SW_INT_ENABLE; |
| 242 | if (dev_priv->vblank_crtc & DRM_RADEON_VBLANK_CRTC1) |
| 243 | dev_priv->irq_enable_reg |= RADEON_CRTC_VBLANK_MASK; |
| 244 | |
| 245 | if (dev_priv->vblank_crtc & DRM_RADEON_VBLANK_CRTC2) |
| 246 | dev_priv->irq_enable_reg |= RADEON_CRTC2_VBLANK_MASK; |
| 247 | |
| 248 | RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg); |
| 249 | dev_priv->irq_enabled = 1; |
| 250 | } |
| 251 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | /* drm_dma.h hooks |
| 253 | */ |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 254 | void radeon_driver_irq_preinstall(struct drm_device * dev) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 255 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | drm_radeon_private_t *dev_priv = |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 257 | (drm_radeon_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 259 | /* Disable *all* interrupts */ |
| 260 | RADEON_WRITE(RADEON_GEN_INT_CNTL, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | |
| 262 | /* Clear bits if they're already high */ |
Dave Airlie | 6921e33 | 2005-06-26 21:05:59 +1000 | [diff] [blame] | 263 | radeon_acknowledge_irqs(dev_priv, (RADEON_SW_INT_TEST_ACK | |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 264 | RADEON_CRTC_VBLANK_STAT | |
| 265 | RADEON_CRTC2_VBLANK_STAT)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 266 | } |
| 267 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 268 | void radeon_driver_irq_postinstall(struct drm_device * dev) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 269 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 270 | drm_radeon_private_t *dev_priv = |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 271 | (drm_radeon_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 273 | atomic_set(&dev_priv->swi_emitted, 0); |
| 274 | DRM_INIT_WAITQUEUE(&dev_priv->swi_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 276 | radeon_enable_interrupt(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | } |
| 278 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 279 | void radeon_driver_irq_uninstall(struct drm_device * dev) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 280 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | drm_radeon_private_t *dev_priv = |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 282 | (drm_radeon_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | if (!dev_priv) |
| 284 | return; |
| 285 | |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 286 | dev_priv->irq_enabled = 0; |
| 287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | /* Disable *all* interrupts */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 289 | RADEON_WRITE(RADEON_GEN_INT_CNTL, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | } |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 291 | |
| 292 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 293 | int radeon_vblank_crtc_get(struct drm_device *dev) |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 294 | { |
| 295 | drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; |
| 296 | u32 flag; |
| 297 | u32 value; |
| 298 | |
| 299 | flag = RADEON_READ(RADEON_GEN_INT_CNTL); |
| 300 | value = 0; |
| 301 | |
| 302 | if (flag & RADEON_CRTC_VBLANK_MASK) |
| 303 | value |= DRM_RADEON_VBLANK_CRTC1; |
| 304 | |
| 305 | if (flag & RADEON_CRTC2_VBLANK_MASK) |
| 306 | value |= DRM_RADEON_VBLANK_CRTC2; |
| 307 | return value; |
| 308 | } |
| 309 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 310 | int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value) |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 311 | { |
| 312 | drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; |
| 313 | if (value & ~(DRM_RADEON_VBLANK_CRTC1 | DRM_RADEON_VBLANK_CRTC2)) { |
| 314 | DRM_ERROR("called with invalid crtc 0x%x\n", (unsigned int)value); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 315 | return -EINVAL; |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 316 | } |
| 317 | dev_priv->vblank_crtc = (unsigned int)value; |
| 318 | radeon_enable_interrupt(dev); |
| 319 | return 0; |
| 320 | } |