aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/usb/em28xx/em28xx-audio.c48
1 files changed, 43 insertions, 5 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
index f6fcee3d4fb9..f004680219e7 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -258,6 +258,13 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
258 258
259 runtime->hw = snd_em28xx_hw_capture; 259 runtime->hw = snd_em28xx_hw_capture;
260 if ((dev->alt == 0 || dev->audio_ifnum) && dev->adev.users == 0) { 260 if ((dev->alt == 0 || dev->audio_ifnum) && dev->adev.users == 0) {
261 int nonblock = !!(substream->f_flags & O_NONBLOCK);
262
263 if (nonblock) {
264 if (!mutex_trylock(&dev->lock))
265 return -EAGAIN;
266 } else
267 mutex_lock(&dev->lock);
261 if (dev->audio_ifnum) 268 if (dev->audio_ifnum)
262 dev->alt = 1; 269 dev->alt = 1;
263 else 270 else
@@ -269,7 +276,6 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
269 276
270 /* Sets volume, mute, etc */ 277 /* Sets volume, mute, etc */
271 dev->mute = 0; 278 dev->mute = 0;
272 mutex_lock(&dev->lock);
273 ret = em28xx_audio_analog_set(dev); 279 ret = em28xx_audio_analog_set(dev);
274 if (ret < 0) 280 if (ret < 0)
275 goto err; 281 goto err;
@@ -441,11 +447,19 @@ static int em28xx_vol_put(struct snd_kcontrol *kcontrol,
441 struct snd_ctl_elem_value *value) 447 struct snd_ctl_elem_value *value)
442{ 448{
443 struct em28xx *dev = snd_kcontrol_chip(kcontrol); 449 struct em28xx *dev = snd_kcontrol_chip(kcontrol);
450 struct snd_pcm_substream *substream = dev->adev.capture_pcm_substream;
444 u16 val = (0x1f - (value->value.integer.value[0] & 0x1f)) | 451 u16 val = (0x1f - (value->value.integer.value[0] & 0x1f)) |
445 (0x1f - (value->value.integer.value[1] & 0x1f)) << 8; 452 (0x1f - (value->value.integer.value[1] & 0x1f)) << 8;
453 int nonblock = 0;
446 int rc; 454 int rc;
447 455
448 mutex_lock(&dev->lock); 456 if (substream)
457 nonblock = !!(substream->f_flags & O_NONBLOCK);
458 if (nonblock) {
459 if (!mutex_trylock(&dev->lock))
460 return -EAGAIN;
461 } else
462 mutex_lock(&dev->lock);
449 rc = em28xx_read_ac97(dev, kcontrol->private_value); 463 rc = em28xx_read_ac97(dev, kcontrol->private_value);
450 if (rc < 0) 464 if (rc < 0)
451 goto err; 465 goto err;
@@ -470,9 +484,17 @@ static int em28xx_vol_get(struct snd_kcontrol *kcontrol,
470 struct snd_ctl_elem_value *value) 484 struct snd_ctl_elem_value *value)
471{ 485{
472 struct em28xx *dev = snd_kcontrol_chip(kcontrol); 486 struct em28xx *dev = snd_kcontrol_chip(kcontrol);
487 struct snd_pcm_substream *substream = dev->adev.capture_pcm_substream;
488 int nonblock = 0;
473 int val; 489 int val;
474 490
475 mutex_lock(&dev->lock); 491 if (substream)
492 nonblock = !!(substream->f_flags & O_NONBLOCK);
493 if (nonblock) {
494 if (!mutex_trylock(&dev->lock))
495 return -EAGAIN;
496 } else
497 mutex_lock(&dev->lock);
476 val = em28xx_read_ac97(dev, kcontrol->private_value); 498 val = em28xx_read_ac97(dev, kcontrol->private_value);
477 mutex_unlock(&dev->lock); 499 mutex_unlock(&dev->lock);
478 if (val < 0) 500 if (val < 0)
@@ -494,9 +516,17 @@ static int em28xx_vol_put_mute(struct snd_kcontrol *kcontrol,
494{ 516{
495 struct em28xx *dev = snd_kcontrol_chip(kcontrol); 517 struct em28xx *dev = snd_kcontrol_chip(kcontrol);
496 u16 val = value->value.integer.value[0]; 518 u16 val = value->value.integer.value[0];
519 struct snd_pcm_substream *substream = dev->adev.capture_pcm_substream;
520 int nonblock = 0;
497 int rc; 521 int rc;
498 522
499 mutex_lock(&dev->lock); 523 if (substream)
524 nonblock = !!(substream->f_flags & O_NONBLOCK);
525 if (nonblock) {
526 if (!mutex_trylock(&dev->lock))
527 return -EAGAIN;
528 } else
529 mutex_lock(&dev->lock);
500 rc = em28xx_read_ac97(dev, kcontrol->private_value); 530 rc = em28xx_read_ac97(dev, kcontrol->private_value);
501 if (rc < 0) 531 if (rc < 0)
502 goto err; 532 goto err;
@@ -524,9 +554,17 @@ static int em28xx_vol_get_mute(struct snd_kcontrol *kcontrol,
524 struct snd_ctl_elem_value *value) 554 struct snd_ctl_elem_value *value)
525{ 555{
526 struct em28xx *dev = snd_kcontrol_chip(kcontrol); 556 struct em28xx *dev = snd_kcontrol_chip(kcontrol);
557 struct snd_pcm_substream *substream = dev->adev.capture_pcm_substream;
558 int nonblock = 0;
527 int val; 559 int val;
528 560
529 mutex_lock(&dev->lock); 561 if (substream)
562 nonblock = !!(substream->f_flags & O_NONBLOCK);
563 if (nonblock) {
564 if (!mutex_trylock(&dev->lock))
565 return -EAGAIN;
566 } else
567 mutex_lock(&dev->lock);
530 val = em28xx_read_ac97(dev, kcontrol->private_value); 568 val = em28xx_read_ac97(dev, kcontrol->private_value);
531 mutex_unlock(&dev->lock); 569 mutex_unlock(&dev->lock);
532 if (val < 0) 570 if (val < 0)