FreeBSD/Linux Kernel Cross Reference
sys/dev/drm/r128_irq.c
1 /* r128_irq.c -- IRQ handling for radeon -*- linux-c -*-
2 */
3 /*-
4 * Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
5 *
6 * The Weather Channel (TM) funded Tungsten Graphics to develop the
7 * initial release of the Radeon 8500 driver under the XFree86 license.
8 * This notice must be preserved.
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice (including the next
18 * paragraph) shall be included in all copies or substantial portions of the
19 * Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
27 * DEALINGS IN THE SOFTWARE.
28 *
29 * Authors:
30 * Keith Whitwell <keith@tungstengraphics.com>
31 * Eric Anholt <anholt@FreeBSD.org>
32 */
33
34 #include <sys/cdefs.h>
35 __FBSDID("$FreeBSD: releng/6.4/sys/dev/drm/r128_irq.c 153401 2005-12-14 00:52:59Z anholt $");
36
37 #include "dev/drm/drmP.h"
38 #include "dev/drm/drm.h"
39 #include "dev/drm/r128_drm.h"
40 #include "dev/drm/r128_drv.h"
41
42 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
43 {
44 drm_device_t *dev = (drm_device_t *) arg;
45 drm_r128_private_t *dev_priv = (drm_r128_private_t *) dev->dev_private;
46 int status;
47
48 status = R128_READ(R128_GEN_INT_STATUS);
49
50 /* VBLANK interrupt */
51 if (status & R128_CRTC_VBLANK_INT) {
52 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
53 atomic_inc(&dev->vbl_received);
54 DRM_WAKEUP(&dev->vbl_queue);
55 drm_vbl_send_signals(dev);
56 return IRQ_HANDLED;
57 }
58 return IRQ_NONE;
59 }
60
61 int r128_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
62 {
63 unsigned int cur_vblank;
64 int ret = 0;
65
66 /* Assume that the user has missed the current sequence number
67 * by about a day rather than she wants to wait for years
68 * using vertical blanks...
69 */
70 DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
71 (((cur_vblank = atomic_read(&dev->vbl_received))
72 - *sequence) <= (1 << 23)));
73
74 *sequence = cur_vblank;
75
76 return ret;
77 }
78
79 void r128_driver_irq_preinstall(drm_device_t * dev)
80 {
81 drm_r128_private_t *dev_priv = (drm_r128_private_t *) dev->dev_private;
82
83 /* Disable *all* interrupts */
84 R128_WRITE(R128_GEN_INT_CNTL, 0);
85 /* Clear vblank bit if it's already high */
86 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
87 }
88
89 void r128_driver_irq_postinstall(drm_device_t * dev)
90 {
91 drm_r128_private_t *dev_priv = (drm_r128_private_t *) dev->dev_private;
92
93 /* Turn on VBL interrupt */
94 R128_WRITE(R128_GEN_INT_CNTL, R128_CRTC_VBLANK_INT_EN);
95 }
96
97 void r128_driver_irq_uninstall(drm_device_t * dev)
98 {
99 drm_r128_private_t *dev_priv = (drm_r128_private_t *) dev->dev_private;
100 if (!dev_priv)
101 return;
102
103 /* Disable *all* interrupts */
104 R128_WRITE(R128_GEN_INT_CNTL, 0);
105 }
Cache object: 944770e2062eeab93980ef3aa787dd48
|