aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/saa7134/saa7134-oss.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/saa7134/saa7134-oss.c')
-rw-r--r--drivers/media/video/saa7134/saa7134-oss.c46
1 files changed, 22 insertions, 24 deletions
diff --git a/drivers/media/video/saa7134/saa7134-oss.c b/drivers/media/video/saa7134/saa7134-oss.c
index 7448e386a804..d79d05f88705 100644
--- a/drivers/media/video/saa7134/saa7134-oss.c
+++ b/drivers/media/video/saa7134/saa7134-oss.c
@@ -84,8 +84,7 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
84{ 84{
85 int err; 85 int err;
86 86
87 if (!dev->dmasound.bufsize) 87 BUG_ON(!dev->dmasound.bufsize);
88 BUG();
89 videobuf_dma_init(&dev->dmasound.dma); 88 videobuf_dma_init(&dev->dmasound.dma);
90 err = videobuf_dma_init_kernel(&dev->dmasound.dma, PCI_DMA_FROMDEVICE, 89 err = videobuf_dma_init_kernel(&dev->dmasound.dma, PCI_DMA_FROMDEVICE,
91 (dev->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT); 90 (dev->dmasound.bufsize + PAGE_SIZE) >> PAGE_SHIFT);
@@ -96,8 +95,7 @@ static int dsp_buffer_init(struct saa7134_dev *dev)
96 95
97static int dsp_buffer_free(struct saa7134_dev *dev) 96static int dsp_buffer_free(struct saa7134_dev *dev)
98{ 97{
99 if (!dev->dmasound.blksize) 98 BUG_ON(!dev->dmasound.blksize);
100 BUG();
101 videobuf_dma_free(&dev->dmasound.dma); 99 videobuf_dma_free(&dev->dmasound.dma);
102 dev->dmasound.blocks = 0; 100 dev->dmasound.blocks = 0;
103 dev->dmasound.blksize = 0; 101 dev->dmasound.blksize = 0;
@@ -254,7 +252,7 @@ static int dsp_open(struct inode *inode, struct file *file)
254 if (NULL == dev) 252 if (NULL == dev)
255 return -ENODEV; 253 return -ENODEV;
256 254
257 down(&dev->dmasound.lock); 255 mutex_lock(&dev->dmasound.lock);
258 err = -EBUSY; 256 err = -EBUSY;
259 if (dev->dmasound.users_dsp) 257 if (dev->dmasound.users_dsp)
260 goto fail1; 258 goto fail1;
@@ -270,13 +268,13 @@ static int dsp_open(struct inode *inode, struct file *file)
270 if (0 != err) 268 if (0 != err)
271 goto fail2; 269 goto fail2;
272 270
273 up(&dev->dmasound.lock); 271 mutex_unlock(&dev->dmasound.lock);
274 return 0; 272 return 0;
275 273
276 fail2: 274 fail2:
277 dev->dmasound.users_dsp--; 275 dev->dmasound.users_dsp--;
278 fail1: 276 fail1:
279 up(&dev->dmasound.lock); 277 mutex_unlock(&dev->dmasound.lock);
280 return err; 278 return err;
281} 279}
282 280
@@ -284,13 +282,13 @@ static int dsp_release(struct inode *inode, struct file *file)
284{ 282{
285 struct saa7134_dev *dev = file->private_data; 283 struct saa7134_dev *dev = file->private_data;
286 284
287 down(&dev->dmasound.lock); 285 mutex_lock(&dev->dmasound.lock);
288 if (dev->dmasound.recording_on) 286 if (dev->dmasound.recording_on)
289 dsp_rec_stop(dev); 287 dsp_rec_stop(dev);
290 dsp_buffer_free(dev); 288 dsp_buffer_free(dev);
291 dev->dmasound.users_dsp--; 289 dev->dmasound.users_dsp--;
292 file->private_data = NULL; 290 file->private_data = NULL;
293 up(&dev->dmasound.lock); 291 mutex_unlock(&dev->dmasound.lock);
294 return 0; 292 return 0;
295} 293}
296 294
@@ -304,7 +302,7 @@ static ssize_t dsp_read(struct file *file, char __user *buffer,
304 int err,ret = 0; 302 int err,ret = 0;
305 303
306 add_wait_queue(&dev->dmasound.wq, &wait); 304 add_wait_queue(&dev->dmasound.wq, &wait);
307 down(&dev->dmasound.lock); 305 mutex_lock(&dev->dmasound.lock);
308 while (count > 0) { 306 while (count > 0) {
309 /* wait for data if needed */ 307 /* wait for data if needed */
310 if (0 == dev->dmasound.read_count) { 308 if (0 == dev->dmasound.read_count) {
@@ -328,12 +326,12 @@ static ssize_t dsp_read(struct file *file, char __user *buffer,
328 ret = -EAGAIN; 326 ret = -EAGAIN;
329 break; 327 break;
330 } 328 }
331 up(&dev->dmasound.lock); 329 mutex_unlock(&dev->dmasound.lock);
332 set_current_state(TASK_INTERRUPTIBLE); 330 set_current_state(TASK_INTERRUPTIBLE);
333 if (0 == dev->dmasound.read_count) 331 if (0 == dev->dmasound.read_count)
334 schedule(); 332 schedule();
335 set_current_state(TASK_RUNNING); 333 set_current_state(TASK_RUNNING);
336 down(&dev->dmasound.lock); 334 mutex_lock(&dev->dmasound.lock);
337 if (signal_pending(current)) { 335 if (signal_pending(current)) {
338 if (0 == ret) 336 if (0 == ret)
339 ret = -EINTR; 337 ret = -EINTR;
@@ -362,7 +360,7 @@ static ssize_t dsp_read(struct file *file, char __user *buffer,
362 if (dev->dmasound.read_offset == dev->dmasound.bufsize) 360 if (dev->dmasound.read_offset == dev->dmasound.bufsize)
363 dev->dmasound.read_offset = 0; 361 dev->dmasound.read_offset = 0;
364 } 362 }
365 up(&dev->dmasound.lock); 363 mutex_unlock(&dev->dmasound.lock);
366 remove_wait_queue(&dev->dmasound.wq, &wait); 364 remove_wait_queue(&dev->dmasound.wq, &wait);
367 return ret; 365 return ret;
368} 366}
@@ -435,13 +433,13 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
435 case SNDCTL_DSP_STEREO: 433 case SNDCTL_DSP_STEREO:
436 if (get_user(val, p)) 434 if (get_user(val, p))
437 return -EFAULT; 435 return -EFAULT;
438 down(&dev->dmasound.lock); 436 mutex_lock(&dev->dmasound.lock);
439 dev->dmasound.channels = val ? 2 : 1; 437 dev->dmasound.channels = val ? 2 : 1;
440 if (dev->dmasound.recording_on) { 438 if (dev->dmasound.recording_on) {
441 dsp_rec_stop(dev); 439 dsp_rec_stop(dev);
442 dsp_rec_start(dev); 440 dsp_rec_start(dev);
443 } 441 }
444 up(&dev->dmasound.lock); 442 mutex_unlock(&dev->dmasound.lock);
445 return put_user(dev->dmasound.channels-1, p); 443 return put_user(dev->dmasound.channels-1, p);
446 444
447 case SNDCTL_DSP_CHANNELS: 445 case SNDCTL_DSP_CHANNELS:
@@ -449,13 +447,13 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
449 return -EFAULT; 447 return -EFAULT;
450 if (val != 1 && val != 2) 448 if (val != 1 && val != 2)
451 return -EINVAL; 449 return -EINVAL;
452 down(&dev->dmasound.lock); 450 mutex_lock(&dev->dmasound.lock);
453 dev->dmasound.channels = val; 451 dev->dmasound.channels = val;
454 if (dev->dmasound.recording_on) { 452 if (dev->dmasound.recording_on) {
455 dsp_rec_stop(dev); 453 dsp_rec_stop(dev);
456 dsp_rec_start(dev); 454 dsp_rec_start(dev);
457 } 455 }
458 up(&dev->dmasound.lock); 456 mutex_unlock(&dev->dmasound.lock);
459 /* fall through */ 457 /* fall through */
460 case SOUND_PCM_READ_CHANNELS: 458 case SOUND_PCM_READ_CHANNELS:
461 return put_user(dev->dmasound.channels, p); 459 return put_user(dev->dmasound.channels, p);
@@ -478,13 +476,13 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
478 case AFMT_U16_BE: 476 case AFMT_U16_BE:
479 case AFMT_S16_LE: 477 case AFMT_S16_LE:
480 case AFMT_S16_BE: 478 case AFMT_S16_BE:
481 down(&dev->dmasound.lock); 479 mutex_lock(&dev->dmasound.lock);
482 dev->dmasound.afmt = val; 480 dev->dmasound.afmt = val;
483 if (dev->dmasound.recording_on) { 481 if (dev->dmasound.recording_on) {
484 dsp_rec_stop(dev); 482 dsp_rec_stop(dev);
485 dsp_rec_start(dev); 483 dsp_rec_start(dev);
486 } 484 }
487 up(&dev->dmasound.lock); 485 mutex_unlock(&dev->dmasound.lock);
488 return put_user(dev->dmasound.afmt, p); 486 return put_user(dev->dmasound.afmt, p);
489 default: 487 default:
490 return -EINVAL; 488 return -EINVAL;
@@ -509,10 +507,10 @@ static int dsp_ioctl(struct inode *inode, struct file *file,
509 return 0; 507 return 0;
510 508
511 case SNDCTL_DSP_RESET: 509 case SNDCTL_DSP_RESET:
512 down(&dev->dmasound.lock); 510 mutex_lock(&dev->dmasound.lock);
513 if (dev->dmasound.recording_on) 511 if (dev->dmasound.recording_on)
514 dsp_rec_stop(dev); 512 dsp_rec_stop(dev);
515 up(&dev->dmasound.lock); 513 mutex_unlock(&dev->dmasound.lock);
516 return 0; 514 return 0;
517 case SNDCTL_DSP_GETBLKSIZE: 515 case SNDCTL_DSP_GETBLKSIZE:
518 return put_user(dev->dmasound.blksize, p); 516 return put_user(dev->dmasound.blksize, p);
@@ -556,10 +554,10 @@ static unsigned int dsp_poll(struct file *file, struct poll_table_struct *wait)
556 poll_wait(file, &dev->dmasound.wq, wait); 554 poll_wait(file, &dev->dmasound.wq, wait);
557 555
558 if (0 == dev->dmasound.read_count) { 556 if (0 == dev->dmasound.read_count) {
559 down(&dev->dmasound.lock); 557 mutex_lock(&dev->dmasound.lock);
560 if (!dev->dmasound.recording_on) 558 if (!dev->dmasound.recording_on)
561 dsp_rec_start(dev); 559 dsp_rec_start(dev);
562 up(&dev->dmasound.lock); 560 mutex_unlock(&dev->dmasound.lock);
563 } else 561 } else
564 mask |= (POLLIN | POLLRDNORM); 562 mask |= (POLLIN | POLLRDNORM);
565 return mask; 563 return mask;
@@ -852,7 +850,7 @@ int saa7134_oss_init1(struct saa7134_dev *dev)
852 return -1; 850 return -1;
853 851
854 /* general */ 852 /* general */
855 init_MUTEX(&dev->dmasound.lock); 853 mutex_init(&dev->dmasound.lock);
856 init_waitqueue_head(&dev->dmasound.wq); 854 init_waitqueue_head(&dev->dmasound.wq);
857 855
858 switch (dev->pci->device) { 856 switch (dev->pci->device) {