blob: e7710339a6a70fbe4360e6ce8f16b294a145d86c [file] [log] [blame]
Dave Airlie94bb5982006-12-19 17:49:08 +11001/* radeon_irq.c -- IRQ handling for radeon -*- linux-c -*- */
2/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
Dave Airlieb5e89ed2005-09-25 14:28:13 +10004 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 * 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>
Jesse Barnes0a3e67a2008-09-30 12:14:26 -070030 * Michel D�zer <michel@daenzer.net>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031 */
32
David Howells760285e2012-10-02 18:01:07 +010033#include <drm/drmP.h>
34#include <drm/radeon_drm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include "radeon_drv.h"
36
Jesse Barnes0a3e67a2008-09-30 12:14:26 -070037void radeon_irq_set_state(struct drm_device *dev, u32 mask, int state)
Dave Airlie6921e332005-06-26 21:05:59 +100038{
Jesse Barnes0a3e67a2008-09-30 12:14:26 -070039 drm_radeon_private_t *dev_priv = dev->dev_private;
40
41 if (state)
42 dev_priv->irq_enable_reg |= mask;
43 else
44 dev_priv->irq_enable_reg &= ~mask;
45
Dave Airlie077ebed2008-12-22 17:11:02 +100046 if (dev->irq_enabled)
Dave Airliefae70432008-12-09 15:30:50 +100047 RADEON_WRITE(RADEON_GEN_INT_CNTL, dev_priv->irq_enable_reg);
Jesse Barnes0a3e67a2008-09-30 12:14:26 -070048}
49
50static void r500_vbl_irq_set_state(struct drm_device *dev, u32 mask, int state)
51{
52 drm_radeon_private_t *dev_priv = dev->dev_private;
53
54 if (state)
55 dev_priv->r500_disp_irq_reg |= mask;
56 else
57 dev_priv->r500_disp_irq_reg &= ~mask;
58
Dave Airlie077ebed2008-12-22 17:11:02 +100059 if (dev->irq_enabled)
Dave Airliefae70432008-12-09 15:30:50 +100060 RADEON_WRITE(R500_DxMODE_INT_MASK, dev_priv->r500_disp_irq_reg);
Jesse Barnes0a3e67a2008-09-30 12:14:26 -070061}
62
63int radeon_enable_vblank(struct drm_device *dev, int crtc)
64{
65 drm_radeon_private_t *dev_priv = dev->dev_private;
66
Alex Deucher800b6992009-03-06 11:47:54 -050067 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
Jesse Barnes0a3e67a2008-09-30 12:14:26 -070068 switch (crtc) {
69 case 0:
70 r500_vbl_irq_set_state(dev, R500_D1MODE_INT_MASK, 1);
71 break;
72 case 1:
73 r500_vbl_irq_set_state(dev, R500_D2MODE_INT_MASK, 1);
74 break;
75 default:
76 DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
77 crtc);
Vasiliy Kulikov21e2eae2010-11-14 23:08:27 +030078 return -EINVAL;
Jesse Barnes0a3e67a2008-09-30 12:14:26 -070079 }
80 } else {
81 switch (crtc) {
82 case 0:
83 radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 1);
84 break;
85 case 1:
86 radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 1);
87 break;
88 default:
89 DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
90 crtc);
Vasiliy Kulikov21e2eae2010-11-14 23:08:27 +030091 return -EINVAL;
Jesse Barnes0a3e67a2008-09-30 12:14:26 -070092 }
93 }
94
95 return 0;
96}
97
98void radeon_disable_vblank(struct drm_device *dev, int crtc)
99{
100 drm_radeon_private_t *dev_priv = dev->dev_private;
101
Alex Deucher800b6992009-03-06 11:47:54 -0500102 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700103 switch (crtc) {
104 case 0:
105 r500_vbl_irq_set_state(dev, R500_D1MODE_INT_MASK, 0);
106 break;
107 case 1:
108 r500_vbl_irq_set_state(dev, R500_D2MODE_INT_MASK, 0);
109 break;
110 default:
111 DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
112 crtc);
113 break;
114 }
115 } else {
116 switch (crtc) {
117 case 0:
118 radeon_irq_set_state(dev, RADEON_CRTC_VBLANK_MASK, 0);
119 break;
120 case 1:
121 radeon_irq_set_state(dev, RADEON_CRTC2_VBLANK_MASK, 0);
122 break;
123 default:
124 DRM_ERROR("tried to enable vblank on non-existent crtc %d\n",
125 crtc);
126 break;
127 }
128 }
129}
130
Andi Kleence580fa2011-10-13 16:08:47 -0700131static u32 radeon_acknowledge_irqs(drm_radeon_private_t *dev_priv, u32 *r500_disp_int)
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700132{
133 u32 irqs = RADEON_READ(RADEON_GEN_INT_STATUS);
134 u32 irq_mask = RADEON_SW_INT_TEST;
135
136 *r500_disp_int = 0;
Alex Deucher800b6992009-03-06 11:47:54 -0500137 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700138 /* vbl interrupts in a different place */
139
140 if (irqs & R500_DISPLAY_INT_STATUS) {
141 /* if a display interrupt */
142 u32 disp_irq;
143
144 disp_irq = RADEON_READ(R500_DISP_INTERRUPT_STATUS);
145
146 *r500_disp_int = disp_irq;
147 if (disp_irq & R500_D1_VBLANK_INTERRUPT)
148 RADEON_WRITE(R500_D1MODE_VBLANK_STATUS, R500_VBLANK_ACK);
149 if (disp_irq & R500_D2_VBLANK_INTERRUPT)
150 RADEON_WRITE(R500_D2MODE_VBLANK_STATUS, R500_VBLANK_ACK);
151 }
152 irq_mask |= R500_DISPLAY_INT_STATUS;
153 } else
154 irq_mask |= RADEON_CRTC_VBLANK_STAT | RADEON_CRTC2_VBLANK_STAT;
155
156 irqs &= irq_mask;
157
Dave Airlie6921e332005-06-26 21:05:59 +1000158 if (irqs)
159 RADEON_WRITE(RADEON_GEN_INT_STATUS, irqs);
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700160
Dave Airlie6921e332005-06-26 21:05:59 +1000161 return irqs;
162}
163
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164/* Interrupts - Used for device synchronization and flushing in the
165 * following circumstances:
166 *
167 * - Exclusive FB access with hw idle:
168 * - Wait for GUI Idle (?) interrupt, then do normal flush.
169 *
170 * - Frame throttling, NV_fence:
171 * - Drop marker irq's into command stream ahead of time.
172 * - Wait on irq's with lock *not held*
173 * - Check each for termination condition
174 *
175 * - Internally in cp_getbuffer, etc:
176 * - as above, but wait with lock held???
177 *
178 * NOTE: These functions are misleadingly named -- the irq's aren't
179 * tied to dma at all, this is just a hangover from dri prehistory.
180 */
181
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000182irqreturn_t radeon_driver_irq_handler(DRM_IRQ_ARGS)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183{
Dave Airlie84b1fd12007-07-11 15:53:27 +1000184 struct drm_device *dev = (struct drm_device *) arg;
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000185 drm_radeon_private_t *dev_priv =
186 (drm_radeon_private_t *) dev->dev_private;
187 u32 stat;
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700188 u32 r500_disp_int;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
Alex Deucherb15591f2009-09-17 14:25:12 -0400190 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
191 return IRQ_NONE;
192
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 /* Only consider the bits we're interested in - others could be used
194 * outside the DRM
195 */
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700196 stat = radeon_acknowledge_irqs(dev_priv, &r500_disp_int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 if (!stat)
198 return IRQ_NONE;
199
Dave Airlieddbee332007-07-11 12:16:01 +1000200 stat &= dev_priv->irq_enable_reg;
201
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 /* SW interrupt */
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700203 if (stat & RADEON_SW_INT_TEST)
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000204 DRM_WAKEUP(&dev_priv->swi_queue);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205
206 /* VBLANK interrupt */
Alex Deucher800b6992009-03-06 11:47:54 -0500207 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700208 if (r500_disp_int & R500_D1_VBLANK_INTERRUPT)
209 drm_handle_vblank(dev, 0);
210 if (r500_disp_int & R500_D2_VBLANK_INTERRUPT)
211 drm_handle_vblank(dev, 1);
212 } else {
213 if (stat & RADEON_CRTC_VBLANK_STAT)
214 drm_handle_vblank(dev, 0);
215 if (stat & RADEON_CRTC2_VBLANK_STAT)
216 drm_handle_vblank(dev, 1);
Dave Airlieaf6061a2008-05-07 12:15:39 +1000217 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 return IRQ_HANDLED;
219}
220
Dave Airlie84b1fd12007-07-11 15:53:27 +1000221static int radeon_emit_irq(struct drm_device * dev)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222{
223 drm_radeon_private_t *dev_priv = dev->dev_private;
224 unsigned int ret;
225 RING_LOCALS;
226
227 atomic_inc(&dev_priv->swi_emitted);
228 ret = atomic_read(&dev_priv->swi_emitted);
229
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000230 BEGIN_RING(4);
231 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
232 OUT_RING_REG(RADEON_GEN_INT_STATUS, RADEON_SW_INT_FIRE);
233 ADVANCE_RING();
234 COMMIT_RING();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
236 return ret;
237}
238
Dave Airlie84b1fd12007-07-11 15:53:27 +1000239static int radeon_wait_irq(struct drm_device * dev, int swi_nr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240{
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000241 drm_radeon_private_t *dev_priv =
242 (drm_radeon_private_t *) dev->dev_private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 int ret = 0;
244
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000245 if (RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr)
246 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247
248 dev_priv->stats.boxes |= RADEON_BOX_WAIT_IDLE;
249
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000250 DRM_WAIT_ON(ret, dev_priv->swi_queue, 3 * DRM_HZ,
251 RADEON_READ(RADEON_LAST_SWI_REG) >= swi_nr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252
253 return ret;
254}
255
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700256u32 radeon_get_vblank_counter(struct drm_device *dev, int crtc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257{
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700258 drm_radeon_private_t *dev_priv = dev->dev_private;
259
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000260 if (!dev_priv) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000261 DRM_ERROR("called with no initialization\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000262 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 }
264
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700265 if (crtc < 0 || crtc > 1) {
266 DRM_ERROR("Invalid crtc %d\n", crtc);
Eric Anholt20caafa2007-08-25 19:22:43 +1000267 return -EINVAL;
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700268 }
Dave Airlieddbee332007-07-11 12:16:01 +1000269
Alex Deucher800b6992009-03-06 11:47:54 -0500270 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600) {
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700271 if (crtc == 0)
272 return RADEON_READ(R500_D1CRTC_FRAME_COUNT);
273 else
274 return RADEON_READ(R500_D2CRTC_FRAME_COUNT);
275 } else {
276 if (crtc == 0)
277 return RADEON_READ(RADEON_CRTC_CRNT_FRAME);
278 else
279 return RADEON_READ(RADEON_CRTC2_CRNT_FRAME);
280 }
Dave Airlieddbee332007-07-11 12:16:01 +1000281}
282
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283/* Needs the lock as it touches the ring.
284 */
Eric Anholtc153f452007-09-03 12:06:45 +1000285int radeon_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 drm_radeon_private_t *dev_priv = dev->dev_private;
Eric Anholtc153f452007-09-03 12:06:45 +1000288 drm_radeon_irq_emit_t *emit = data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 int result;
290
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000291 if (!dev_priv) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000292 DRM_ERROR("called with no initialization\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000293 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 }
295
Darren Jenkins65aa2f42009-12-30 12:16:35 +1100296 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
297 return -EINVAL;
298
299 LOCK_TEST_WITH_RETURN(dev, file_priv);
300
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000301 result = radeon_emit_irq(dev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
Eric Anholtc153f452007-09-03 12:06:45 +1000303 if (DRM_COPY_TO_USER(emit->irq_seq, &result, sizeof(int))) {
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000304 DRM_ERROR("copy_to_user\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000305 return -EFAULT;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306 }
307
308 return 0;
309}
310
Linus Torvalds1da177e2005-04-16 15:20:36 -0700311/* Doesn't need the hardware lock.
312 */
Eric Anholtc153f452007-09-03 12:06:45 +1000313int radeon_irq_wait(struct drm_device *dev, void *data, struct drm_file *file_priv)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 drm_radeon_private_t *dev_priv = dev->dev_private;
Eric Anholtc153f452007-09-03 12:06:45 +1000316 drm_radeon_irq_wait_t *irqwait = data;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000318 if (!dev_priv) {
Márton Németh3e684ea2008-01-24 15:58:57 +1000319 DRM_ERROR("called with no initialization\n");
Eric Anholt20caafa2007-08-25 19:22:43 +1000320 return -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 }
322
Alex Deucherb15591f2009-09-17 14:25:12 -0400323 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
324 return -EINVAL;
325
Eric Anholtc153f452007-09-03 12:06:45 +1000326 return radeon_wait_irq(dev, irqwait->irq_seq);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327}
328
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329/* drm_dma.h hooks
330*/
Dave Airlie84b1fd12007-07-11 15:53:27 +1000331void radeon_driver_irq_preinstall(struct drm_device * dev)
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000332{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 drm_radeon_private_t *dev_priv =
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000334 (drm_radeon_private_t *) dev->dev_private;
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700335 u32 dummy;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336
Alex Deucherb15591f2009-09-17 14:25:12 -0400337 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
338 return;
339
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000340 /* Disable *all* interrupts */
Alex Deucher800b6992009-03-06 11:47:54 -0500341 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600)
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700342 RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000343 RADEON_WRITE(RADEON_GEN_INT_CNTL, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344
345 /* Clear bits if they're already high */
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700346 radeon_acknowledge_irqs(dev_priv, &dummy);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347}
348
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700349int radeon_driver_irq_postinstall(struct drm_device *dev)
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000350{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 drm_radeon_private_t *dev_priv =
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000352 (drm_radeon_private_t *) dev->dev_private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000354 atomic_set(&dev_priv->swi_emitted, 0);
355 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700357 dev->max_vblank_count = 0x001fffff;
358
Alex Deucherb15591f2009-09-17 14:25:12 -0400359 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
360 return 0;
361
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700362 radeon_irq_set_state(dev, RADEON_SW_INT_ENABLE, 1);
363
364 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365}
366
Dave Airlie84b1fd12007-07-11 15:53:27 +1000367void radeon_driver_irq_uninstall(struct drm_device * dev)
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000368{
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 drm_radeon_private_t *dev_priv =
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000370 (drm_radeon_private_t *) dev->dev_private;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 if (!dev_priv)
372 return;
373
Alex Deucherb15591f2009-09-17 14:25:12 -0400374 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_R600)
375 return;
376
Alex Deucher800b6992009-03-06 11:47:54 -0500377 if ((dev_priv->flags & RADEON_FAMILY_MASK) >= CHIP_RS600)
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700378 RADEON_WRITE(R500_DxMODE_INT_MASK, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 /* Disable *all* interrupts */
Dave Airlieb5e89ed2005-09-25 14:28:13 +1000380 RADEON_WRITE(RADEON_GEN_INT_CNTL, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381}
Dave Airlieddbee332007-07-11 12:16:01 +1000382
383
Dave Airlie84b1fd12007-07-11 15:53:27 +1000384int radeon_vblank_crtc_get(struct drm_device *dev)
Dave Airlieddbee332007-07-11 12:16:01 +1000385{
386 drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private;
Dave Airlieddbee332007-07-11 12:16:01 +1000387
Jesse Barnes0a3e67a2008-09-30 12:14:26 -0700388 return dev_priv->vblank_crtc;
Dave Airlieddbee332007-07-11 12:16:01 +1000389}
390
Dave Airlie84b1fd12007-07-11 15:53:27 +1000391int radeon_vblank_crtc_set(struct drm_device *dev, int64_t value)
Dave Airlieddbee332007-07-11 12:16:01 +1000392{
393 drm_radeon_private_t *dev_priv = (drm_radeon_private_t *) dev->dev_private;
394 if (value & ~(DRM_RADEON_VBLANK_CRTC1 | DRM_RADEON_VBLANK_CRTC2)) {
395 DRM_ERROR("called with invalid crtc 0x%x\n", (unsigned int)value);
Eric Anholt20caafa2007-08-25 19:22:43 +1000396 return -EINVAL;
Dave Airlieddbee332007-07-11 12:16:01 +1000397 }
398 dev_priv->vblank_crtc = (unsigned int)value;
Dave Airlieddbee332007-07-11 12:16:01 +1000399 return 0;
400}