diff options
author | Frank Schaefer <fschaefer.oss@googlemail.com> | 2014-01-13 19:02:06 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-01-14 19:24:38 -0200 |
commit | 961717b41bc1103dcd30d293fd689a614fbfa90c (patch) | |
tree | fdff0e05b3a227f1454d6550de6607373b169311 /drivers/media | |
parent | 8068eb885a13e33244a8692c880eca478b467d9d (diff) | |
download | linux-961717b41bc1103dcd30d293fd689a614fbfa90c.tar.bz2 |
[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.c | 18 | ||||
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-cards.c | 2 | ||||
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-dvb.c | 2 | ||||
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-video.c | 2 | ||||
-rw-r--r-- | drivers/media/usb/em28xx/em28xx.h | 3 |
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) dprintk("opening device and trying to acquire exclusive lock\n"); runtime->hw = snd_em28xx_hw_capture; - if ((dev->alt == 0 || dev->audio_ifnum) && dev->adev.users == 0) { + if ((dev->alt == 0 || dev->ifnum) && dev->adev.users == 0) { int nonblock = !!(substream->f_flags & O_NONBLOCK); if (nonblock) { @@ -274,14 +274,14 @@ static int snd_em28xx_capture_open(struct snd_pcm_substream *substream) return -EAGAIN; } else mutex_lock(&dev->lock); - if (dev->audio_ifnum) + if (dev->ifnum) dev->alt = 1; else dev->alt = 7; dprintk("changing alternate number on interface %d to %d\n", - dev->audio_ifnum, dev->alt); - usb_set_interface(dev->udev, dev->audio_ifnum, dev->alt); + dev->ifnum, dev->alt); + usb_set_interface(dev->udev, dev->ifnum, dev->alt); /* Sets volume, mute, etc */ dev->mute = 0; @@ -733,16 +733,16 @@ static int em28xx_audio_urb_init(struct em28xx *dev) int urb_size, bytes_per_transfer; u8 alt; - if (dev->audio_ifnum) + if (dev->ifnum) alt = 1; else alt = 7; - intf = usb_ifnum_to_if(dev->udev, dev->audio_ifnum); + intf = usb_ifnum_to_if(dev->udev, dev->ifnum); if (intf->num_altsetting <= alt) { em28xx_errdev("alt %d doesn't exist on interface %d\n", - dev->audio_ifnum, alt); + dev->ifnum, alt); return -ENODEV; } @@ -766,7 +766,7 @@ static int em28xx_audio_urb_init(struct em28xx *dev) em28xx_info("Endpoint 0x%02x %s on intf %d alt %d interval = %d, size %d\n", EM28XX_EP_AUDIO, usb_speed_string(dev->udev->speed), - dev->audio_ifnum, alt, + dev->ifnum, alt, interval, ep_size); @@ -877,7 +877,7 @@ static int em28xx_audio_init(struct em28xx *dev) static int devnr; int err; - if (!dev->has_alsa_audio || dev->audio_ifnum < 0) { + if (!dev->has_alsa_audio) { /* This device does not support the extension (in this case the device is expecting the snd-usb-audio module or 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, dev->has_alsa_audio = has_audio; dev->audio_mode.has_audio = has_audio; dev->has_video = has_video; - dev->audio_ifnum = ifnum; + dev->ifnum = ifnum; /* Checks if audio is provided by some interface */ 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) dvb_alt = dev->dvb_alt_isoc; } - usb_set_interface(dev->udev, 0, dvb_alt); + usb_set_interface(dev->udev, dev->ifnum, dvb_alt); rc = em28xx_set_mode(dev, EM28XX_DIGITAL_MODE); if (rc < 0) 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: } em28xx_videodbg("setting alternate %d with wMaxPacketSize=%u\n", dev->alt, dev->max_pkt_size); - errCode = usb_set_interface(dev->udev, 0, dev->alt); + errCode = usb_set_interface(dev->udev, dev->ifnum, dev->alt); if (errCode < 0) { em28xx_errdev("cannot change alternate number to %d (error=%i)\n", 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 { unsigned int has_alsa_audio:1; unsigned int is_audio_only:1; - int audio_ifnum; - struct v4l2_device v4l2_dev; struct v4l2_ctrl_handler ctrl_handler; struct v4l2_clk *clk; @@ -664,6 +662,7 @@ struct em28xx { /* usb transfer */ struct usb_device *udev; /* the usb device */ + u8 ifnum; /* number of the assigned usb interface */ u8 analog_ep_isoc; /* address of isoc endpoint for analog */ u8 analog_ep_bulk; /* address of bulk endpoint for analog */ u8 dvb_ep_isoc; /* address of isoc endpoint for DVB */ |