aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/mga_irq.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/drm/mga_irq.c')
-rw-r--r--drivers/char/drm/mga_irq.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/drivers/char/drm/mga_irq.c b/drivers/char/drm/mga_irq.c
index 52eaa4e788f9..eb9644024172 100644
--- a/drivers/char/drm/mga_irq.c
+++ b/drivers/char/drm/mga_irq.c
@@ -1,7 +1,7 @@
1/* mga_irq.c -- IRQ handling for radeon -*- linux-c -*- 1/* mga_irq.c -- IRQ handling for radeon -*- linux-c -*-
2 * 2 *
3 * Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved. 3 * Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
4 * 4 *
5 * The Weather Channel (TM) funded Tungsten Graphics to develop the 5 * The Weather Channel (TM) funded Tungsten Graphics to develop the
6 * initial release of the Radeon 8500 driver under the XFree86 license. 6 * initial release of the Radeon 8500 driver under the XFree86 license.
7 * This notice must be preserved. 7 * This notice must be preserved.
@@ -35,19 +35,18 @@
35#include "mga_drm.h" 35#include "mga_drm.h"
36#include "mga_drv.h" 36#include "mga_drv.h"
37 37
38irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS ) 38irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
39{ 39{
40 drm_device_t *dev = (drm_device_t *) arg; 40 drm_device_t *dev = (drm_device_t *) arg;
41 drm_mga_private_t *dev_priv = 41 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
42 (drm_mga_private_t *)dev->dev_private;
43 int status; 42 int status;
44 int handled = 0; 43 int handled = 0;
45 44
46 status = MGA_READ(MGA_STATUS); 45 status = MGA_READ(MGA_STATUS);
47 46
48 /* VBLANK interrupt */ 47 /* VBLANK interrupt */
49 if ( status & MGA_VLINEPEN ) { 48 if (status & MGA_VLINEPEN) {
50 MGA_WRITE( MGA_ICLEAR, MGA_VLINEICLR ); 49 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
51 atomic_inc(&dev->vbl_received); 50 atomic_inc(&dev->vbl_received);
52 DRM_WAKEUP(&dev->vbl_queue); 51 DRM_WAKEUP(&dev->vbl_queue);
53 drm_vbl_send_signals(dev); 52 drm_vbl_send_signals(dev);
@@ -57,15 +56,14 @@ irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS )
57 /* SOFTRAP interrupt */ 56 /* SOFTRAP interrupt */
58 if (status & MGA_SOFTRAPEN) { 57 if (status & MGA_SOFTRAPEN) {
59 const u32 prim_start = MGA_READ(MGA_PRIMADDRESS); 58 const u32 prim_start = MGA_READ(MGA_PRIMADDRESS);
60 const u32 prim_end = MGA_READ(MGA_PRIMEND); 59 const u32 prim_end = MGA_READ(MGA_PRIMEND);
61
62 60
63 MGA_WRITE(MGA_ICLEAR, MGA_SOFTRAPICLR); 61 MGA_WRITE(MGA_ICLEAR, MGA_SOFTRAPICLR);
64 62
65 /* In addition to clearing the interrupt-pending bit, we 63 /* In addition to clearing the interrupt-pending bit, we
66 * have to write to MGA_PRIMEND to re-start the DMA operation. 64 * have to write to MGA_PRIMEND to re-start the DMA operation.
67 */ 65 */
68 if ( (prim_start & ~0x03) != (prim_end & ~0x03) ) { 66 if ((prim_start & ~0x03) != (prim_end & ~0x03)) {
69 MGA_WRITE(MGA_PRIMEND, prim_end); 67 MGA_WRITE(MGA_PRIMEND, prim_end);
70 } 68 }
71 69
@@ -74,24 +72,24 @@ irqreturn_t mga_driver_irq_handler( DRM_IRQ_ARGS )
74 handled = 1; 72 handled = 1;
75 } 73 }
76 74
77 if ( handled ) { 75 if (handled) {
78 return IRQ_HANDLED; 76 return IRQ_HANDLED;
79 } 77 }
80 return IRQ_NONE; 78 return IRQ_NONE;
81} 79}
82 80
83int mga_driver_vblank_wait(drm_device_t *dev, unsigned int *sequence) 81int mga_driver_vblank_wait(drm_device_t * dev, unsigned int *sequence)
84{ 82{
85 unsigned int cur_vblank; 83 unsigned int cur_vblank;
86 int ret = 0; 84 int ret = 0;
87 85
88 /* Assume that the user has missed the current sequence number 86 /* Assume that the user has missed the current sequence number
89 * by about a day rather than she wants to wait for years 87 * by about a day rather than she wants to wait for years
90 * using vertical blanks... 88 * using vertical blanks...
91 */ 89 */
92 DRM_WAIT_ON( ret, dev->vbl_queue, 3*DRM_HZ, 90 DRM_WAIT_ON(ret, dev->vbl_queue, 3 * DRM_HZ,
93 ( ( ( cur_vblank = atomic_read(&dev->vbl_received ) ) 91 (((cur_vblank = atomic_read(&dev->vbl_received))
94 - *sequence ) <= (1<<23) ) ); 92 - *sequence) <= (1 << 23)));
95 93
96 *sequence = cur_vblank; 94 *sequence = cur_vblank;
97 95
@@ -122,29 +120,29 @@ void mga_driver_irq_preinstall(drm_device_t * dev)
122 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; 120 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
123 121
124 /* Disable *all* interrupts */ 122 /* Disable *all* interrupts */
125 MGA_WRITE( MGA_IEN, 0 ); 123 MGA_WRITE(MGA_IEN, 0);
126 /* Clear bits if they're already high */ 124 /* Clear bits if they're already high */
127 MGA_WRITE( MGA_ICLEAR, ~0 ); 125 MGA_WRITE(MGA_ICLEAR, ~0);
128} 126}
129 127
130void mga_driver_irq_postinstall(drm_device_t * dev) 128void mga_driver_irq_postinstall(drm_device_t * dev)
131{ 129{
132 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private; 130 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
133 131
134 DRM_INIT_WAITQUEUE( &dev_priv->fence_queue ); 132 DRM_INIT_WAITQUEUE(&dev_priv->fence_queue);
135 133
136 /* Turn on vertical blank interrupt and soft trap interrupt. */ 134 /* Turn on vertical blank interrupt and soft trap interrupt. */
137 MGA_WRITE(MGA_IEN, MGA_VLINEIEN | MGA_SOFTRAPEN); 135 MGA_WRITE(MGA_IEN, MGA_VLINEIEN | MGA_SOFTRAPEN);
138} 136}
139 137
140void mga_driver_irq_uninstall( drm_device_t *dev ) { 138void mga_driver_irq_uninstall(drm_device_t * dev)
141 drm_mga_private_t *dev_priv = 139{
142 (drm_mga_private_t *)dev->dev_private; 140 drm_mga_private_t *dev_priv = (drm_mga_private_t *) dev->dev_private;
143 if (!dev_priv) 141 if (!dev_priv)
144 return; 142 return;
145 143
146 /* Disable *all* interrupts */ 144 /* Disable *all* interrupts */
147 MGA_WRITE(MGA_IEN, 0); 145 MGA_WRITE(MGA_IEN, 0);
148 146
149 dev->irq_enabled = 0; 147 dev->irq_enabled = 0;
150} 148}