aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-audio.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-audio.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-audio.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/drivers/media/video/em28xx/em28xx-audio.c b/drivers/media/video/em28xx/em28xx-audio.c
index 47f21a382546..cff0768afbf5 100644
--- a/drivers/media/video/em28xx/em28xx-audio.c
+++ b/drivers/media/video/em28xx/em28xx-audio.c
@@ -3,9 +3,9 @@
3 * 3 *
4 * Copyright (C) 2006 Markus Rechberger <mrechberger@gmail.com> 4 * Copyright (C) 2006 Markus Rechberger <mrechberger@gmail.com>
5 * 5 *
6 * Copyright (C) 2007 Mauro Carvalho Chehab <mchehab@infradead.org> 6 * Copyright (C) 2007-2011 Mauro Carvalho Chehab <mchehab@redhat.com>
7 * - Port to work with the in-kernel driver 7 * - Port to work with the in-kernel driver
8 * - Several cleanups 8 * - Cleanups, fixes, alsa-controls, etc.
9 * 9 *
10 * This driver is based on my previous au600 usb pstn audio driver 10 * This driver is based on my previous au600 usb pstn audio driver
11 * and inherits all the copyrights 11 * and inherits all the copyrights
@@ -281,23 +281,27 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
281 return -ENODEV; 281 return -ENODEV;
282 } 282 }
283 283
284 /* Sets volume, mute, etc */ 284 runtime->hw = snd_em28xx_hw_capture;
285 if ((dev->alt == 0 || dev->audio_ifnum) && dev->adev.users == 0) {
286 if (dev->audio_ifnum)
287 dev->alt = 1;
288 else
289 dev->alt = 7;
285 290
286 dev->mute = 0; 291 dprintk("changing alternate number on interface %d to %d\n",
287 mutex_lock(&dev->lock); 292 dev->audio_ifnum, dev->alt);
288 ret = em28xx_audio_analog_set(dev); 293 usb_set_interface(dev->udev, dev->audio_ifnum, dev->alt);
289 if (ret < 0)
290 goto err;
291 294
292 runtime->hw = snd_em28xx_hw_capture; 295 /* Sets volume, mute, etc */
293 if (dev->alt == 0 && dev->adev.users == 0) { 296 dev->mute = 0;
294 dev->alt = 7; 297 mutex_lock(&dev->lock);
295 dprintk("changing alternate number to 7\n"); 298 ret = em28xx_audio_analog_set(dev);
296 usb_set_interface(dev->udev, 0, 7); 299 if (ret < 0)
297 } 300 goto err;
298 301
299 dev->adev.users++; 302 dev->adev.users++;
300 mutex_unlock(&dev->lock); 303 mutex_unlock(&dev->lock);
304 }
301 305
302 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); 306 snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
303 dev->adev.capture_pcm_substream = substream; 307 dev->adev.capture_pcm_substream = substream;
@@ -635,17 +639,17 @@ static int em28xx_audio_init(struct em28xx *dev)
635 static int devnr; 639 static int devnr;
636 int err; 640 int err;
637 641
638 if (dev->has_alsa_audio != 1) { 642 if (!dev->has_alsa_audio || dev->audio_ifnum < 0) {
639 /* This device does not support the extension (in this case 643 /* This device does not support the extension (in this case
640 the device is expecting the snd-usb-audio module or 644 the device is expecting the snd-usb-audio module or
641 doesn't have analog audio support at all) */ 645 doesn't have analog audio support at all) */
642 return 0; 646 return 0;
643 } 647 }
644 648
645 printk(KERN_INFO "em28xx-audio.c: probing for em28x1 " 649 printk(KERN_INFO "em28xx-audio.c: probing for em28xx Audio Vendor Class\n");
646 "non standard usbaudio\n");
647 printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus " 650 printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2006 Markus "
648 "Rechberger\n"); 651 "Rechberger\n");
652 printk(KERN_INFO "em28xx-audio.c: Copyright (C) 2007-2011 Mauro Carvalho Chehab\n");
649 653
650 err = snd_card_create(index[devnr], "Em28xx Audio", THIS_MODULE, 0, 654 err = snd_card_create(index[devnr], "Em28xx Audio", THIS_MODULE, 0,
651 &card); 655 &card);
@@ -737,7 +741,7 @@ static void __exit em28xx_alsa_unregister(void)
737 741
738MODULE_LICENSE("GPL"); 742MODULE_LICENSE("GPL");
739MODULE_AUTHOR("Markus Rechberger <mrechberger@gmail.com>"); 743MODULE_AUTHOR("Markus Rechberger <mrechberger@gmail.com>");
740MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@infradead.org>"); 744MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
741MODULE_DESCRIPTION("Em28xx Audio driver"); 745MODULE_DESCRIPTION("Em28xx Audio driver");
742 746
743module_init(em28xx_alsa_register); 747module_init(em28xx_alsa_register);