summaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorFrank Schaefer <fschaefer.oss@googlemail.com>2014-01-13 17:02:06 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-14 16:24:38 -0500
commit961717b41bc1103dcd30d293fd689a614fbfa90c (patch)
treefdff0e05b3a227f1454d6550de6607373b169311 /drivers/media
parent8068eb885a13e33244a8692c880eca478b467d9d (diff)
[media] em28xx: fix usb alternate setting for analog and digital video endpoints > 0
The current code assumes that the analog + digital video endpoints are always at interface number 0 when changing the alternate setting. This seems to work fine for most existing devices. However, at least the SpeedLink VAD Laplace webcam has the video endpoint on interface number 3 (which fortunately doesn't cause any trouble because ist uses bulk transfers only). We already consider the actual interface number for audio endpoints, so rename the the audio_ifnum variable and use it for all device types. Also get get rid of a pointless (ifnum < 0) in em28xx-audio. Signed-off-by: Frank Schäfer <fschaefer.oss@googlemail.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/usb/em28xx/em28xx-audio.c18
-rw-r--r--drivers/media/usb/em28xx/em28xx-cards.c2
-rw-r--r--drivers/media/usb/em28xx/em28xx-dvb.c2
-rw-r--r--drivers/media/usb/em28xx/em28xx-video.c2
-rw-r--r--drivers/media/usb/em28xx/em28xx.h3
5 files changed, 13 insertions, 14 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c
index 45bea1adc11c..50c4ab49a276 100644
--- a/drivers/media/usb/em28xx/em28xx-audio.c
+++ b/drivers/media/usb/em28xx/em28xx-audio.c
@@ -266,7 +266,7 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
266 dprintk("opening device and trying to acquire exclusive lock\n"); 266 dprintk("opening device and trying to acquire exclusive lock\n");
267 267
268 runtime->hw = snd_em28xx_hw_capture; 268 runtime->hw = snd_em28xx_hw_capture;
269 if ((dev->alt == 0 || dev->audio_ifnum) && dev->adev.users == 0) { 269 if ((dev->alt == 0 || dev->ifnum) && dev->adev.users == 0) {
270 int nonblock = !!(substream->f_flags & O_NONBLOCK); 270 int nonblock = !!(substream->f_flags & O_NONBLOCK);
271 271
272 if (nonblock) { 272 if (nonblock) {
@@ -274,14 +274,14 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream)
274 return -EAGAIN; 274 return -EAGAIN;
275 } else 275 } else
276 mutex_lock(&dev->lock); 276 mutex_lock(&dev->lock);
277 if (dev->audio_ifnum) 277 if (dev->ifnum)
278 dev->alt = 1; 278 dev->alt = 1;
279 else 279 else
280 dev->alt = 7; 280 dev->alt = 7;
281 281
282 dprintk("changing alternate number on interface %d to %d\n", 282 dprintk("changing alternate number on interface %d to %d\n",
283 dev->audio_ifnum, dev->alt); 283 dev->ifnum, dev->alt);
284 usb_set_interface(dev->udev, dev->audio_ifnum, dev->alt); 284 usb_set_interface(dev->udev, dev->ifnum, dev->alt);
285 285
286 /* Sets volume, mute, etc */ 286 /* Sets volume, mute, etc */
287 dev->mute = 0; 287 dev->mute = 0;
@@ -733,16 +733,16 @@ static int em28xx_audio_urb_init(struct em28xx *dev)
733 int urb_size, bytes_per_transfer; 733 int urb_size, bytes_per_transfer;
734 u8 alt; 734 u8 alt;
735 735
736 if (dev->audio_ifnum) 736 if (dev->ifnum)
737 alt = 1; 737 alt = 1;
738 else 738 else
739 alt = 7; 739 alt = 7;
740 740
741 intf = usb_ifnum_to_if(dev->udev, dev->audio_ifnum); 741 intf = usb_ifnum_to_if(dev->udev, dev->ifnum);
742 742
743 if (intf->num_altsetting <= alt) { 743 if (intf->num_altsetting <= alt) {
744 em28xx_errdev("alt %d doesn't exist on interface %d\n", 744 em28xx_errdev("alt %d doesn't exist on interface %d\n",
745 dev->audio_ifnum, alt); 745 dev->ifnum, alt);
746 return -ENODEV; 746 return -ENODEV;
747 } 747 }
748 748
@@ -766,7 +766,7 @@ static int em28xx_audio_urb_init(struct em28xx *dev)
766 766
767 em28xx_info("Endpoint 0x%02x %s on intf %d alt %d interval = %d, size %d\n", 767 em28xx_info("Endpoint 0x%02x %s on intf %d alt %d interval = %d, size %d\n",
768 EM28XX_EP_AUDIO, usb_speed_string(dev->udev->speed), 768 EM28XX_EP_AUDIO, usb_speed_string(dev->udev->speed),
769 dev->audio_ifnum, alt, 769 dev->ifnum, alt,
770 interval, 770 interval,
771 ep_size); 771 ep_size);
772 772
@@ -877,7 +877,7 @@ static int em28xx_audio_init(struct em28xx *dev)
877 static int devnr; 877 static int devnr;
878 int err; 878 int err;
879 879
880 if (!dev->has_alsa_audio || dev->audio_ifnum < 0) { 880 if (!dev->has_alsa_audio) {
881 /* This device does not support the extension (in this case 881 /* This device does not support the extension (in this case
882 the device is expecting the snd-usb-audio module or 882 the device is expecting the snd-usb-audio module or
883 doesn't have analog audio support at all) */ 883 doesn't have analog audio support at all) */
diff --git a/drivers/media/usb/em28xx/em28xx-cards.c b/drivers/media/usb/em28xx/em28xx-cards.c
index e08d65b2e352..6318e459744e 100644
--- a/drivers/media/usb/em28xx/em28xx-cards.c
+++ b/drivers/media/usb/em28xx/em28xx-cards.c
@@ -3274,7 +3274,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
3274 dev->has_alsa_audio = has_audio; 3274 dev->has_alsa_audio = has_audio;
3275 dev->audio_mode.has_audio = has_audio; 3275 dev->audio_mode.has_audio = has_audio;
3276 dev->has_video = has_video; 3276 dev->has_video = has_video;
3277 dev->audio_ifnum = ifnum; 3277 dev->ifnum = ifnum;
3278 3278
3279 /* Checks if audio is provided by some interface */ 3279 /* Checks if audio is provided by some interface */
3280 for (i = 0; i < udev->config->desc.bNumInterfaces; i++) { 3280 for (i = 0; i < udev->config->desc.bNumInterfaces; i++) {
diff --git a/drivers/media/usb/em28xx/em28xx-dvb.c b/drivers/media/usb/em28xx/em28xx-dvb.c
index 881a813836eb..a0a669e81362 100644
--- a/drivers/media/usb/em28xx/em28xx-dvb.c
+++ b/drivers/media/usb/em28xx/em28xx-dvb.c
@@ -203,7 +203,7 @@ static int em28xx_start_streaming(struct em28xx_dvb *dvb)
203 dvb_alt = dev->dvb_alt_isoc; 203 dvb_alt = dev->dvb_alt_isoc;
204 } 204 }
205 205
206 usb_set_interface(dev->udev, 0, dvb_alt); 206 usb_set_interface(dev->udev, dev->ifnum, dvb_alt);
207 rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); 207 rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE);
208 if (rc < 0) 208 if (rc < 0)
209 return rc; 209 return rc;
diff --git a/drivers/media/usb/em28xx/em28xx-video.c b/drivers/media/usb/em28xx/em28xx-video.c
index 36b69cbf36c7..c3c928937dcd 100644
--- a/drivers/media/usb/em28xx/em28xx-video.c
+++ b/drivers/media/usb/em28xx/em28xx-video.c
@@ -383,7 +383,7 @@ set_alt:
383 } 383 }
384 em28xx_videodbg("setting alternate %d with wMaxPacketSize=%u\n", 384 em28xx_videodbg("setting alternate %d with wMaxPacketSize=%u\n",
385 dev->alt, dev->max_pkt_size); 385 dev->alt, dev->max_pkt_size);
386 errCode = usb_set_interface(dev->udev, 0, dev->alt); 386 errCode = usb_set_interface(dev->udev, dev->ifnum, dev->alt);
387 if (errCode < 0) { 387 if (errCode < 0) {
388 em28xx_errdev("cannot change alternate number to %d (error=%i)\n", 388 em28xx_errdev("cannot change alternate number to %d (error=%i)\n",
389 dev->alt, errCode); 389 dev->alt, errCode);
diff --git a/drivers/media/usb/em28xx/em28xx.h b/drivers/media/usb/em28xx/em28xx.h
index 10b817245f7e..32d8a4bb7961 100644
--- a/drivers/media/usb/em28xx/em28xx.h
+++ b/drivers/media/usb/em28xx/em28xx.h
@@ -549,8 +549,6 @@ struct em28xx {
549 unsigned int has_alsa_audio:1; 549 unsigned int has_alsa_audio:1;
550 unsigned int is_audio_only:1; 550 unsigned int is_audio_only:1;
551 551
552 int audio_ifnum;
553
554 struct v4l2_device v4l2_dev; 552 struct v4l2_device v4l2_dev;
555 struct v4l2_ctrl_handler ctrl_handler; 553 struct v4l2_ctrl_handler ctrl_handler;
556 struct v4l2_clk *clk; 554 struct v4l2_clk *clk;
@@ -664,6 +662,7 @@ struct em28xx {
664 662
665 /* usb transfer */ 663 /* usb transfer */
666 struct usb_device *udev; /* the usb device */ 664 struct usb_device *udev; /* the usb device */
665 u8 ifnum; /* number of the assigned usb interface */
667 u8 analog_ep_isoc; /* address of isoc endpoint for analog */ 666 u8 analog_ep_isoc; /* address of isoc endpoint for analog */
668 u8 analog_ep_bulk; /* address of bulk endpoint for analog */ 667 u8 analog_ep_bulk; /* address of bulk endpoint for analog */
669 u8 dvb_ep_isoc; /* address of isoc endpoint for DVB */ 668 u8 dvb_ep_isoc; /* address of isoc endpoint for DVB */