aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_irq.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@starflyer.(none)>2005-09-25 00:28:13 -0400
committerDave Airlie <airlied@linux.ie>2005-09-25 00:28:13 -0400
commitb5e89ed53ed8d24f83ba1941c07382af00ed238e (patch)
tree747bae7a565f88a2e1d5974776eeb054a932c505 /drivers/char/drm/drm_irq.c
parent99a2657a29e2d623c3568cd86b27cac13fb63140 (diff)
drm: lindent the drm directory.
I've been threatening this for a while, so no point hanging around. This lindents the DRM code which was always really bad in tabbing department. I've also fixed some misnamed files in comments and removed some trailing whitespace. Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/drm_irq.c')
-rw-r--r--drivers/char/drm/drm_irq.c169
1 files changed, 86 insertions, 83 deletions
diff --git a/drivers/char/drm/drm_irq.c b/drivers/char/drm/drm_irq.c
index cdd4aecd25e..b0d4b236e83 100644
--- a/drivers/char/drm/drm_irq.c
+++ b/drivers/char/drm/drm_irq.c
@@ -1,5 +1,5 @@
1/** 1/**
2 * \file drm_irq.h 2 * \file drm_irq.c
3 * IRQ support 3 * IRQ support
4 * 4 *
5 * \author Rickard E. (Rik) Faith <faith@valinux.com> 5 * \author Rickard E. (Rik) Faith <faith@valinux.com>
@@ -39,19 +39,19 @@
39 39
40/** 40/**
41 * Get interrupt from bus id. 41 * Get interrupt from bus id.
42 * 42 *
43 * \param inode device inode. 43 * \param inode device inode.
44 * \param filp file pointer. 44 * \param filp file pointer.
45 * \param cmd command. 45 * \param cmd command.
46 * \param arg user argument, pointing to a drm_irq_busid structure. 46 * \param arg user argument, pointing to a drm_irq_busid structure.
47 * \return zero on success or a negative number on failure. 47 * \return zero on success or a negative number on failure.
48 * 48 *
49 * Finds the PCI device with the specified bus id and gets its IRQ number. 49 * Finds the PCI device with the specified bus id and gets its IRQ number.
50 * This IOCTL is deprecated, and will now return EINVAL for any busid not equal 50 * This IOCTL is deprecated, and will now return EINVAL for any busid not equal
51 * to that of the device that this DRM instance attached to. 51 * to that of the device that this DRM instance attached to.
52 */ 52 */
53int drm_irq_by_busid(struct inode *inode, struct file *filp, 53int drm_irq_by_busid(struct inode *inode, struct file *filp,
54 unsigned int cmd, unsigned long arg) 54 unsigned int cmd, unsigned long arg)
55{ 55{
56 drm_file_t *priv = filp->private_data; 56 drm_file_t *priv = filp->private_data;
57 drm_device_t *dev = priv->head->dev; 57 drm_device_t *dev = priv->head->dev;
@@ -66,14 +66,12 @@ int drm_irq_by_busid(struct inode *inode, struct file *filp,
66 66
67 if ((p.busnum >> 8) != dev->pci_domain || 67 if ((p.busnum >> 8) != dev->pci_domain ||
68 (p.busnum & 0xff) != dev->pci_bus || 68 (p.busnum & 0xff) != dev->pci_bus ||
69 p.devnum != dev->pci_slot || 69 p.devnum != dev->pci_slot || p.funcnum != dev->pci_func)
70 p.funcnum != dev->pci_func)
71 return -EINVAL; 70 return -EINVAL;
72 71
73 p.irq = dev->irq; 72 p.irq = dev->irq;
74 73
75 DRM_DEBUG("%d:%d:%d => IRQ %d\n", 74 DRM_DEBUG("%d:%d:%d => IRQ %d\n", p.busnum, p.devnum, p.funcnum, p.irq);
76 p.busnum, p.devnum, p.funcnum, p.irq);
77 if (copy_to_user(argp, &p, sizeof(p))) 75 if (copy_to_user(argp, &p, sizeof(p)))
78 return -EFAULT; 76 return -EFAULT;
79 return 0; 77 return 0;
@@ -89,61 +87,61 @@ int drm_irq_by_busid(struct inode *inode, struct file *filp,
89 * \c drm_driver_irq_preinstall() and \c drm_driver_irq_postinstall() functions 87 * \c drm_driver_irq_preinstall() and \c drm_driver_irq_postinstall() functions
90 * before and after the installation. 88 * before and after the installation.
91 */ 89 */
92static int drm_irq_install( drm_device_t *dev ) 90static int drm_irq_install(drm_device_t * dev)
93{ 91{
94 int ret; 92 int ret;
95 unsigned long sh_flags=0; 93 unsigned long sh_flags = 0;
96 94
97 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 95 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
98 return -EINVAL; 96 return -EINVAL;
99 97
100 if ( dev->irq == 0 ) 98 if (dev->irq == 0)
101 return -EINVAL; 99 return -EINVAL;
102 100
103 down( &dev->struct_sem ); 101 down(&dev->struct_sem);
104 102
105 /* Driver must have been initialized */ 103 /* Driver must have been initialized */
106 if ( !dev->dev_private ) { 104 if (!dev->dev_private) {
107 up( &dev->struct_sem ); 105 up(&dev->struct_sem);
108 return -EINVAL; 106 return -EINVAL;
109 } 107 }
110 108
111 if ( dev->irq_enabled ) { 109 if (dev->irq_enabled) {
112 up( &dev->struct_sem ); 110 up(&dev->struct_sem);
113 return -EBUSY; 111 return -EBUSY;
114 } 112 }
115 dev->irq_enabled = 1; 113 dev->irq_enabled = 1;
116 up( &dev->struct_sem ); 114 up(&dev->struct_sem);
117 115
118 DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq ); 116 DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq);
119 117
120 if (drm_core_check_feature(dev, DRIVER_IRQ_VBL)) { 118 if (drm_core_check_feature(dev, DRIVER_IRQ_VBL)) {
121 init_waitqueue_head(&dev->vbl_queue); 119 init_waitqueue_head(&dev->vbl_queue);
122 120
123 spin_lock_init( &dev->vbl_lock ); 121 spin_lock_init(&dev->vbl_lock);
124 122
125 INIT_LIST_HEAD( &dev->vbl_sigs.head ); 123 INIT_LIST_HEAD(&dev->vbl_sigs.head);
126 124
127 dev->vbl_pending = 0; 125 dev->vbl_pending = 0;
128 } 126 }
129 127
130 /* Before installing handler */ 128 /* Before installing handler */
131 dev->driver->irq_preinstall(dev); 129 dev->driver->irq_preinstall(dev);
132 130
133 /* Install handler */ 131 /* Install handler */
134 if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED)) 132 if (drm_core_check_feature(dev, DRIVER_IRQ_SHARED))
135 sh_flags = SA_SHIRQ; 133 sh_flags = SA_SHIRQ;
136 134
137 ret = request_irq( dev->irq, dev->driver->irq_handler, 135 ret = request_irq(dev->irq, dev->driver->irq_handler,
138 sh_flags, dev->devname, dev ); 136 sh_flags, dev->devname, dev);
139 if ( ret < 0 ) { 137 if (ret < 0) {
140 down( &dev->struct_sem ); 138 down(&dev->struct_sem);
141 dev->irq_enabled = 0; 139 dev->irq_enabled = 0;
142 up( &dev->struct_sem ); 140 up(&dev->struct_sem);
143 return ret; 141 return ret;
144 } 142 }
145 143
146 /* After installing handler */ 144 /* After installing handler */
147 dev->driver->irq_postinstall(dev); 145 dev->driver->irq_postinstall(dev);
148 146
149 return 0; 147 return 0;
@@ -156,29 +154,30 @@ static int drm_irq_install( drm_device_t *dev )
156 * 154 *
157 * Calls the driver's \c drm_driver_irq_uninstall() function, and stops the irq. 155 * Calls the driver's \c drm_driver_irq_uninstall() function, and stops the irq.
158 */ 156 */
159int drm_irq_uninstall( drm_device_t *dev ) 157int drm_irq_uninstall(drm_device_t * dev)
160{ 158{
161 int irq_enabled; 159 int irq_enabled;
162 160
163 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 161 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
164 return -EINVAL; 162 return -EINVAL;
165 163
166 down( &dev->struct_sem ); 164 down(&dev->struct_sem);
167 irq_enabled = dev->irq_enabled; 165 irq_enabled = dev->irq_enabled;
168 dev->irq_enabled = 0; 166 dev->irq_enabled = 0;
169 up( &dev->struct_sem ); 167 up(&dev->struct_sem);
170 168
171 if ( !irq_enabled ) 169 if (!irq_enabled)
172 return -EINVAL; 170 return -EINVAL;
173 171
174 DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq ); 172 DRM_DEBUG("%s: irq=%d\n", __FUNCTION__, dev->irq);
175 173
176 dev->driver->irq_uninstall(dev); 174 dev->driver->irq_uninstall(dev);
177 175
178 free_irq( dev->irq, dev ); 176 free_irq(dev->irq, dev);
179 177
180 return 0; 178 return 0;
181} 179}
180
182EXPORT_SYMBOL(drm_irq_uninstall); 181EXPORT_SYMBOL(drm_irq_uninstall);
183 182
184/** 183/**
@@ -192,30 +191,30 @@ EXPORT_SYMBOL(drm_irq_uninstall);
192 * 191 *
193 * Calls irq_install() or irq_uninstall() according to \p arg. 192 * Calls irq_install() or irq_uninstall() according to \p arg.
194 */ 193 */
195int drm_control( struct inode *inode, struct file *filp, 194int drm_control(struct inode *inode, struct file *filp,
196 unsigned int cmd, unsigned long arg ) 195 unsigned int cmd, unsigned long arg)
197{ 196{
198 drm_file_t *priv = filp->private_data; 197 drm_file_t *priv = filp->private_data;
199 drm_device_t *dev = priv->head->dev; 198 drm_device_t *dev = priv->head->dev;
200 drm_control_t ctl; 199 drm_control_t ctl;
201 200
202 /* if we haven't irq we fallback for compatibility reasons - this used to be a separate function in drm_dma.h */ 201 /* if we haven't irq we fallback for compatibility reasons - this used to be a separate function in drm_dma.h */
203 202
204 if ( copy_from_user( &ctl, (drm_control_t __user *)arg, sizeof(ctl) ) ) 203 if (copy_from_user(&ctl, (drm_control_t __user *) arg, sizeof(ctl)))
205 return -EFAULT; 204 return -EFAULT;
206 205
207 switch ( ctl.func ) { 206 switch (ctl.func) {
208 case DRM_INST_HANDLER: 207 case DRM_INST_HANDLER:
209 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 208 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
210 return 0; 209 return 0;
211 if (dev->if_version < DRM_IF_VERSION(1, 2) && 210 if (dev->if_version < DRM_IF_VERSION(1, 2) &&
212 ctl.irq != dev->irq) 211 ctl.irq != dev->irq)
213 return -EINVAL; 212 return -EINVAL;
214 return drm_irq_install( dev ); 213 return drm_irq_install(dev);
215 case DRM_UNINST_HANDLER: 214 case DRM_UNINST_HANDLER:
216 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) 215 if (!drm_core_check_feature(dev, DRIVER_HAVE_IRQ))
217 return 0; 216 return 0;
218 return drm_irq_uninstall( dev ); 217 return drm_irq_uninstall(dev);
219 default: 218 default:
220 return -EINVAL; 219 return -EINVAL;
221 } 220 }
@@ -230,7 +229,7 @@ int drm_control( struct inode *inode, struct file *filp,
230 * \param data user argument, pointing to a drm_wait_vblank structure. 229 * \param data user argument, pointing to a drm_wait_vblank structure.
231 * \return zero on success or a negative number on failure. 230 * \return zero on success or a negative number on failure.
232 * 231 *
233 * Verifies the IRQ is installed. 232 * Verifies the IRQ is installed.
234 * 233 *
235 * If a signal is requested checks if this task has already scheduled the same signal 234 * If a signal is requested checks if this task has already scheduled the same signal
236 * for the same vblank sequence number - nothing to be done in 235 * for the same vblank sequence number - nothing to be done in
@@ -240,7 +239,7 @@ int drm_control( struct inode *inode, struct file *filp,
240 * 239 *
241 * If a signal is not requested, then calls vblank_wait(). 240 * If a signal is not requested, then calls vblank_wait().
242 */ 241 */
243int drm_wait_vblank( DRM_IOCTL_ARGS ) 242int drm_wait_vblank(DRM_IOCTL_ARGS)
244{ 243{
245 drm_file_t *priv = filp->private_data; 244 drm_file_t *priv = filp->private_data;
246 drm_device_t *dev = priv->head->dev; 245 drm_device_t *dev = priv->head->dev;
@@ -256,11 +255,11 @@ int drm_wait_vblank( DRM_IOCTL_ARGS )
256 if (!dev->irq) 255 if (!dev->irq)
257 return -EINVAL; 256 return -EINVAL;
258 257
259 DRM_COPY_FROM_USER_IOCTL( vblwait, argp, sizeof(vblwait) ); 258 DRM_COPY_FROM_USER_IOCTL(vblwait, argp, sizeof(vblwait));
260 259
261 switch ( vblwait.request.type & ~_DRM_VBLANK_FLAGS_MASK ) { 260 switch (vblwait.request.type & ~_DRM_VBLANK_FLAGS_MASK) {
262 case _DRM_VBLANK_RELATIVE: 261 case _DRM_VBLANK_RELATIVE:
263 vblwait.request.sequence += atomic_read( &dev->vbl_received ); 262 vblwait.request.sequence += atomic_read(&dev->vbl_received);
264 vblwait.request.type &= ~_DRM_VBLANK_RELATIVE; 263 vblwait.request.type &= ~_DRM_VBLANK_RELATIVE;
265 case _DRM_VBLANK_ABSOLUTE: 264 case _DRM_VBLANK_ABSOLUTE:
266 break; 265 break;
@@ -269,64 +268,68 @@ int drm_wait_vblank( DRM_IOCTL_ARGS )
269 } 268 }
270 269
271 flags = vblwait.request.type & _DRM_VBLANK_FLAGS_MASK; 270 flags = vblwait.request.type & _DRM_VBLANK_FLAGS_MASK;
272 271
273 if ( flags & _DRM_VBLANK_SIGNAL ) { 272 if (flags & _DRM_VBLANK_SIGNAL) {
274 unsigned long irqflags; 273 unsigned long irqflags;
275 drm_vbl_sig_t *vbl_sig; 274 drm_vbl_sig_t *vbl_sig;
276
277 vblwait.reply.sequence = atomic_read( &dev->vbl_received );
278 275
279 spin_lock_irqsave( &dev->vbl_lock, irqflags ); 276 vblwait.reply.sequence = atomic_read(&dev->vbl_received);
277
278 spin_lock_irqsave(&dev->vbl_lock, irqflags);
280 279
281 /* Check if this task has already scheduled the same signal 280 /* Check if this task has already scheduled the same signal
282 * for the same vblank sequence number; nothing to be done in 281 * for the same vblank sequence number; nothing to be done in
283 * that case 282 * that case
284 */ 283 */
285 list_for_each_entry( vbl_sig, &dev->vbl_sigs.head, head ) { 284 list_for_each_entry(vbl_sig, &dev->vbl_sigs.head, head) {
286 if (vbl_sig->sequence == vblwait.request.sequence 285 if (vbl_sig->sequence == vblwait.request.sequence
287 && vbl_sig->info.si_signo == vblwait.request.signal 286 && vbl_sig->info.si_signo == vblwait.request.signal
288 && vbl_sig->task == current) 287 && vbl_sig->task == current) {
289 { 288 spin_unlock_irqrestore(&dev->vbl_lock,
290 spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); 289 irqflags);
291 goto done; 290 goto done;
292 } 291 }
293 } 292 }
294 293
295 if ( dev->vbl_pending >= 100 ) { 294 if (dev->vbl_pending >= 100) {
296 spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); 295 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
297 return -EBUSY; 296 return -EBUSY;
298 } 297 }
299 298
300 dev->vbl_pending++; 299 dev->vbl_pending++;
301 300
302 spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); 301 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
303 302
304 if ( !( vbl_sig = drm_alloc( sizeof( drm_vbl_sig_t ), DRM_MEM_DRIVER ) ) ) { 303 if (!
304 (vbl_sig =
305 drm_alloc(sizeof(drm_vbl_sig_t), DRM_MEM_DRIVER))) {
305 return -ENOMEM; 306 return -ENOMEM;
306 } 307 }
307 308
308 memset( (void *)vbl_sig, 0, sizeof(*vbl_sig) ); 309 memset((void *)vbl_sig, 0, sizeof(*vbl_sig));
309 310
310 vbl_sig->sequence = vblwait.request.sequence; 311 vbl_sig->sequence = vblwait.request.sequence;
311 vbl_sig->info.si_signo = vblwait.request.signal; 312 vbl_sig->info.si_signo = vblwait.request.signal;
312 vbl_sig->task = current; 313 vbl_sig->task = current;
313 314
314 spin_lock_irqsave( &dev->vbl_lock, irqflags ); 315 spin_lock_irqsave(&dev->vbl_lock, irqflags);
315 316
316 list_add_tail( (struct list_head *) vbl_sig, &dev->vbl_sigs.head ); 317 list_add_tail((struct list_head *)vbl_sig, &dev->vbl_sigs.head);
317 318
318 spin_unlock_irqrestore( &dev->vbl_lock, irqflags ); 319 spin_unlock_irqrestore(&dev->vbl_lock, irqflags);
319 } else { 320 } else {
320 if (dev->driver->vblank_wait) 321 if (dev->driver->vblank_wait)
321 ret = dev->driver->vblank_wait( dev, &vblwait.request.sequence ); 322 ret =
323 dev->driver->vblank_wait(dev,
324 &vblwait.request.sequence);
322 325
323 do_gettimeofday( &now ); 326 do_gettimeofday(&now);
324 vblwait.reply.tval_sec = now.tv_sec; 327 vblwait.reply.tval_sec = now.tv_sec;
325 vblwait.reply.tval_usec = now.tv_usec; 328 vblwait.reply.tval_usec = now.tv_usec;
326 } 329 }
327 330
328done: 331 done:
329 DRM_COPY_TO_USER_IOCTL( argp, vblwait, sizeof(vblwait) ); 332 DRM_COPY_TO_USER_IOCTL(argp, vblwait, sizeof(vblwait));
330 333
331 return ret; 334 return ret;
332} 335}
@@ -340,31 +343,31 @@ done:
340 * 343 *
341 * If a signal is not requested, then calls vblank_wait(). 344 * If a signal is not requested, then calls vblank_wait().
342 */ 345 */
343void drm_vbl_send_signals( drm_device_t *dev ) 346void drm_vbl_send_signals(drm_device_t * dev)
344{ 347{
345 struct list_head *list, *tmp; 348 struct list_head *list, *tmp;
346 drm_vbl_sig_t *vbl_sig; 349 drm_vbl_sig_t *vbl_sig;
347 unsigned int vbl_seq = atomic_read( &dev->vbl_received ); 350 unsigned int vbl_seq = atomic_read(&dev->vbl_received);
348 unsigned long flags; 351 unsigned long flags;
349 352
350 spin_lock_irqsave( &dev->vbl_lock, flags ); 353 spin_lock_irqsave(&dev->vbl_lock, flags);
351 354
352 list_for_each_safe( list, tmp, &dev->vbl_sigs.head ) { 355 list_for_each_safe(list, tmp, &dev->vbl_sigs.head) {
353 vbl_sig = list_entry( list, drm_vbl_sig_t, head ); 356 vbl_sig = list_entry(list, drm_vbl_sig_t, head);
354 if ( ( vbl_seq - vbl_sig->sequence ) <= (1<<23) ) { 357 if ((vbl_seq - vbl_sig->sequence) <= (1 << 23)) {
355 vbl_sig->info.si_code = vbl_seq; 358 vbl_sig->info.si_code = vbl_seq;
356 send_sig_info( vbl_sig->info.si_signo, &vbl_sig->info, vbl_sig->task ); 359 send_sig_info(vbl_sig->info.si_signo, &vbl_sig->info,
360 vbl_sig->task);
357 361
358 list_del( list ); 362 list_del(list);
359 363
360 drm_free( vbl_sig, sizeof(*vbl_sig), DRM_MEM_DRIVER ); 364 drm_free(vbl_sig, sizeof(*vbl_sig), DRM_MEM_DRIVER);
361 365
362 dev->vbl_pending--; 366 dev->vbl_pending--;
363 } 367 }
364 } 368 }
365 369
366 spin_unlock_irqrestore( &dev->vbl_lock, flags ); 370 spin_unlock_irqrestore(&dev->vbl_lock, flags);
367} 371}
368EXPORT_SYMBOL(drm_vbl_send_signals);
369
370 372
373EXPORT_SYMBOL(drm_vbl_send_signals);