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 | |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 38 | static void radeon_irq_set_state(struct drm_device *dev, u32 mask, int state) |
Dave Airlie | 6921e33 | 2005-06-26 21:05:59 +1000 | [diff] [blame] | 39 | { |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 40 | drm_radeon_private_t *dev_priv = dev->dev_private; |
| 41 | |
| 42 | if (state) |
| 43 | dev_priv->irq_enable_reg |= mask; |
| 44 | else |
| 45 | dev_priv->irq_enable_reg &= ~mask; |
| 46 | |
| 47 | RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg); |
| 48 | } |
| 49 | |
| 50 | int radeon_enable_vblank(struct drm_device *dev, int crtc) |
| 51 | { |
| 52 | switch (crtc) { |
| 53 | case 0: |
| 54 | radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 1); |
| 55 | break; |
| 56 | case 1: |
| 57 | radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 1); |
| 58 | break; |
| 59 | default: |
| 60 | DRM_ERROR("tried to enable vblank on non-existent crtc %d\n", |
| 61 | crtc); |
| 62 | return EINVAL; |
| 63 | } |
| 64 | |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | void radeon_disable_vblank(struct drm_device *dev, int crtc) |
| 69 | { |
| 70 | switch (crtc) { |
| 71 | case 0: |
| 72 | radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 0); |
| 73 | break; |
| 74 | case 1: |
| 75 | radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 0); |
| 76 | break; |
| 77 | default: |
| 78 | DRM_ERROR("tried to enable vblank on non-existent crtc %d\n", |
| 79 | crtc); |
| 80 | break; |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | static __inline__ u32 radeon_acknowledge_irqs(drm_radeon_private_t * dev_priv) |
| 85 | { |
| 86 | u32 irqs = RADEON_READ(RADEON_GEN_INT_STATUS) & |
| 87 | (RADEON_SW_INT_TEST | RADEON_CRTC_VBLANK_STAT | |
| 88 | RADEON_CRTC2_VBLANK_STAT); |
| 89 | |
Dave Airlie | 6921e33 | 2005-06-26 21:05:59 +1000 | [diff] [blame] | 90 | if (irqs) |
| 91 | RADEON_WRITE(RADEON_GEN_INT_STATUS, irqs); |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 92 | |
Dave Airlie | 6921e33 | 2005-06-26 21:05:59 +1000 | [diff] [blame] | 93 | return irqs; |
| 94 | } |
| 95 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | /* Interrupts - Used for device synchronization and flushing in the |
| 97 | * following circumstances: |
| 98 | * |
| 99 | * - Exclusive FB access with hw idle: |
| 100 | * - Wait for GUI Idle (?) interrupt, then do normal flush. |
| 101 | * |
| 102 | * - Frame throttling, NV_fence: |
| 103 | * - Drop marker irq's into command stream ahead of time. |
| 104 | * - Wait on irq's with lock *not held* |
| 105 | * - Check each for termination condition |
| 106 | * |
| 107 | * - Internally in cp_getbuffer, etc: |
| 108 | * - as above, but wait with lock held??? |
| 109 | * |
| 110 | * NOTE: These functions are misleadingly named -- the irq's aren't |
| 111 | * tied to dma at all, this is just a hangover from dri prehistory. |
| 112 | */ |
| 113 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 114 | irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | { |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 116 | struct drm_device *dev = (struct drm_device *) arg; |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 117 | drm_radeon_private_t *dev_priv = |
| 118 | (drm_radeon_private_t *) dev->dev_private; |
| 119 | u32 stat; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | |
| 121 | /* Only consider the bits we're interested in - others could be used |
| 122 | * outside the DRM |
| 123 | */ |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 124 | stat = radeon_acknowledge_irqs(dev_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | if (!stat) |
| 126 | return IRQ_NONE; |
| 127 | |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 128 | stat &= dev_priv->irq_enable_reg; |
| 129 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | /* SW interrupt */ |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 131 | if (stat & RADEON_SW_INT_TEST) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 132 | DRM_WAKEUP(&dev_priv->swi_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
| 134 | /* VBLANK interrupt */ |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 135 | if (stat & RADEON_CRTC_VBLANK_STAT) |
| 136 | drm_handle_vblank(dev, 0); |
| 137 | if (stat & RADEON_CRTC2_VBLANK_STAT) |
| 138 | drm_handle_vblank(dev, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | return IRQ_HANDLED; |
| 141 | } |
| 142 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 143 | static int radeon_emit_irq(struct drm_device * dev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | { |
| 145 | drm_radeon_private_t *dev_priv = dev->dev_private; |
| 146 | unsigned int ret; |
| 147 | RING_LOCALS; |
| 148 | |
| 149 | atomic_inc(&dev_priv->swi_emitted); |
| 150 | ret = atomic_read(&dev_priv->swi_emitted); |
| 151 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 152 | BEGIN_RING(4); |
| 153 | OUT_RING_REG(RADEON_LAST_SWI_REG, ret); |
| 154 | OUT_RING_REG(RADEON_GEN_INT_STATUS, RADEON_SW_INT_FIRE); |
| 155 | ADVANCE_RING(); |
| 156 | COMMIT_RING(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | |
| 158 | return ret; |
| 159 | } |
| 160 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 161 | static int radeon_wait_irq(struct drm_device * dev, int swi_nr) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 163 | drm_radeon_private_t *dev_priv = |
| 164 | (drm_radeon_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | int ret = 0; |
| 166 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 167 | if (RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr) |
| 168 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | |
| 170 | dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE; |
| 171 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 172 | DRM_WAIT_ON(ret, dev_priv->swi_queue, 3 * DRM_HZ, |
| 173 | RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | |
| 175 | return ret; |
| 176 | } |
| 177 | |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 178 | u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 179 | { |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 180 | drm_radeon_private_t *dev_priv = dev->dev_private; |
| 181 | u32 crtc_cnt_reg, crtc_status_reg; |
| 182 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 183 | if (!dev_priv) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 184 | DRM_ERROR("called with no initialization\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 185 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | } |
| 187 | |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 188 | if (crtc == 0) { |
| 189 | crtc_cnt_reg = RADEON_CRTC_CRNT_FRAME; |
| 190 | crtc_status_reg = RADEON_CRTC_STATUS; |
| 191 | } else if (crtc == 1) { |
| 192 | crtc_cnt_reg = RADEON_CRTC2_CRNT_FRAME; |
| 193 | crtc_status_reg = RADEON_CRTC2_STATUS; |
| 194 | } else { |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 195 | return -EINVAL; |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 196 | } |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 197 | |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 198 | return RADEON_READ(crtc_cnt_reg) + (RADEON_READ(crtc_status_reg) & 1); |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 199 | } |
| 200 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | /* Needs the lock as it touches the ring. |
| 202 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 203 | 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] | 204 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | drm_radeon_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 206 | drm_radeon_irq_emit_t *emit = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | int result; |
| 208 | |
Eric Anholt | 6c340ea | 2007-08-25 20:23:09 +1000 | [diff] [blame] | 209 | LOCK_TEST_WITH_RETURN(dev, file_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 211 | if (!dev_priv) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 212 | DRM_ERROR("called with no initialization\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 213 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | } |
| 215 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 216 | result = radeon_emit_irq(dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 218 | if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) { |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 219 | DRM_ERROR("copy_to_user\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 220 | return -EFAULT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | return 0; |
| 224 | } |
| 225 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | /* Doesn't need the hardware lock. |
| 227 | */ |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 228 | 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] | 229 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | drm_radeon_private_t *dev_priv = dev->dev_private; |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 231 | drm_radeon_irq_wait_t *irqwait = data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 233 | if (!dev_priv) { |
Márton Németh | 3e684ea | 2008-01-24 15:58:57 +1000 | [diff] [blame] | 234 | DRM_ERROR("called with no initialization\n"); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 235 | return -EINVAL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | } |
| 237 | |
Eric Anholt | c153f45 | 2007-09-03 12:06:45 +1000 | [diff] [blame] | 238 | return radeon_wait_irq(dev, irqwait->irq_seq); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | } |
| 240 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | /* drm_dma.h hooks |
| 242 | */ |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 243 | void radeon_driver_irq_preinstall(struct drm_device * dev) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 244 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | drm_radeon_private_t *dev_priv = |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 246 | (drm_radeon_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 247 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 248 | /* Disable *all* interrupts */ |
| 249 | RADEON_WRITE(RADEON_GEN_INT_CNTL, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
| 251 | /* Clear bits if they're already high */ |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 252 | radeon_acknowledge_irqs(dev_priv); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 255 | int radeon_driver_irq_postinstall(struct drm_device * dev) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 256 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | drm_radeon_private_t *dev_priv = |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 258 | (drm_radeon_private_t *) dev->dev_private; |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 259 | int ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 261 | atomic_set(&dev_priv->swi_emitted, 0); |
| 262 | DRM_INIT_WAITQUEUE(&dev_priv->swi_queue); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 263 | |
Jesse Barnes | ac741ab | 2008-04-22 16:03:07 +1000 | [diff] [blame^] | 264 | ret = drm_vblank_init(dev, 2); |
| 265 | if (ret) |
| 266 | return ret; |
| 267 | |
| 268 | dev->max_vblank_count = 0x001fffff; |
| 269 | |
| 270 | radeon_irq_set_state(dev, RADEON_SW_INT_ENABLE, 1); |
| 271 | |
| 272 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 275 | void radeon_driver_irq_uninstall(struct drm_device * dev) |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 276 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | drm_radeon_private_t *dev_priv = |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 278 | (drm_radeon_private_t *) dev->dev_private; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | if (!dev_priv) |
| 280 | return; |
| 281 | |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 282 | dev_priv->irq_enabled = 0; |
| 283 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | /* Disable *all* interrupts */ |
Dave Airlie | b5e89ed | 2005-09-25 14:28:13 +1000 | [diff] [blame] | 285 | RADEON_WRITE(RADEON_GEN_INT_CNTL, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | } |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 287 | |
| 288 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 289 | int radeon_vblank_crtc_get(struct drm_device *dev) |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 290 | { |
| 291 | drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; |
| 292 | u32 flag; |
| 293 | u32 value; |
| 294 | |
| 295 | flag = RADEON_READ(RADEON_GEN_INT_CNTL); |
| 296 | value = 0; |
| 297 | |
| 298 | if (flag & RADEON_CRTC_VBLANK_MASK) |
| 299 | value |= DRM_RADEON_VBLANK_CRTC1; |
| 300 | |
| 301 | if (flag & RADEON_CRTC2_VBLANK_MASK) |
| 302 | value |= DRM_RADEON_VBLANK_CRTC2; |
| 303 | return value; |
| 304 | } |
| 305 | |
Dave Airlie | 84b1fd1 | 2007-07-11 15:53:27 +1000 | [diff] [blame] | 306 | int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value) |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 307 | { |
| 308 | drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private; |
| 309 | if (value & ~(DRM_RADEON_VBLANK_CRTC1 | DRM_RADEON_VBLANK_CRTC2)) { |
| 310 | DRM_ERROR("called with invalid crtc 0x%x\n", (unsigned int)value); |
Eric Anholt | 20caafa | 2007-08-25 19:22:43 +1000 | [diff] [blame] | 311 | return -EINVAL; |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 312 | } |
| 313 | dev_priv->vblank_crtc = (unsigned int)value; |
Dave Airlie | ddbee33 | 2007-07-11 12:16:01 +1000 | [diff] [blame] | 314 | return 0; |
| 315 | } |