From patchwork Mon Jan 13 22:02:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Schaefer X-Patchwork-Id: 21574 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1W2pZM-0007IS-Ni; Mon, 13 Jan 2014 23:01:16 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.72/mailfrontend-7) with esmtp id 1W2pZK-0002xE-17; Mon, 13 Jan 2014 23:01:16 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752044AbaAMWBL (ORCPT + 1 other); Mon, 13 Jan 2014 17:01:11 -0500 Received: from mail-ee0-f53.google.com ([74.125.83.53]:64216 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751623AbaAMWBJ (ORCPT ); Mon, 13 Jan 2014 17:01:09 -0500 Received: by mail-ee0-f53.google.com with SMTP id t10so455998eei.26 for ; Mon, 13 Jan 2014 14:01:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=8BpYDxhOrAofrAWIACXFsHRd4d6l1y3fWzAqRCVYA2E=; b=iRPGOT6iyE/2okodV8W7e0qzWsFkT7XSO4sY/8RLcWnxM3kUJa1ZBe64SxfHW6YBPQ Kc/q9a05jEUoDIMhEWLLDu5gTbNCH+zZKP1hXRG3b04k+l95cBDxpoI5jDZBp4LRNDJW t6ZVfIg8yIQ52Tj6QE7qTtUlfugczLX6bIo71//yeMa0txuLrCIWzynEDV1kh5Qf2BY/ GpiyEwTS2gzyabywmxnZ2l3Kp4PEaapRr+K9G3YcsmRjkpMxFbpf9KzRJAJas+gI0MDs ncVkLMJv+LPB1gfvZXPev/32kM5rAxEkIunX5htXZbYFEKNWqZMOufuD5/3+Wfx1sY/8 2QtA== X-Received: by 10.15.74.200 with SMTP id j48mr6348230eey.102.1389650468549; Mon, 13 Jan 2014 14:01:08 -0800 (PST) Received: from Athlon64X2-5000.site (ip-109-90-247-29.unitymediagroup.de. [109.90.247.29]) by mx.google.com with ESMTPSA id o47sm43386476eem.21.2014.01.13.14.01.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Jan 2014 14:01:08 -0800 (PST) From: =?UTF-8?q?Frank=20Sch=C3=A4fer?= To: m.chehab@samsung.com Cc: linux-media@vger.kernel.org, =?UTF-8?q?Frank=20Sch=C3=A4fer?= Subject: [PATCH v2 1/2] em28xx: fix usb alternate setting for analog and digital video endpoints > 0 Date: Mon, 13 Jan 2014 23:02:06 +0100 Message-Id: <1389650527-3962-1-git-send-email-fschaefer.oss@googlemail.com> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2014.1.13.215715 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_5000_5999 0, BODY_SIZE_7000_LESS 0, CT_TEXT_PLAIN_UTF8_CAPS 0, DKIM_SIGNATURE 0, URI_ENDS_IN_HTML 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __HAS_FROM 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 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 --- drivers/media/usb/em28xx/em28xx-audio.c | 18 +++++++++--------- drivers/media/usb/em28xx/em28xx-cards.c | 2 +- drivers/media/usb/em28xx/em28xx-dvb.c | 2 +- drivers/media/usb/em28xx/em28xx-video.c | 2 +- drivers/media/usb/em28xx/em28xx.h | 3 +-- 5 Dateien geändert, 13 Zeilen hinzugefügt(+), 14 Zeilen entfernt(-) diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c index f3e3200..f80c3533 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; @@ -728,16 +728,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; } @@ -761,7 +761,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); @@ -869,7 +869,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 6efb902..c7e3667 100644 --- a/drivers/media/usb/em28xx/em28xx-cards.c +++ b/drivers/media/usb/em28xx/em28xx-cards.c @@ -3273,7 +3273,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 7dba175..4c0338b 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 a1dcceb..9c1916a 100644 --- a/drivers/media/usb/em28xx/em28xx-video.c +++ b/drivers/media/usb/em28xx/em28xx-video.c @@ -382,7 +382,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 5d5d1b6..f5e7da6 100644 --- a/drivers/media/usb/em28xx/em28xx.h +++ b/drivers/media/usb/em28xx/em28xx.h @@ -547,8 +547,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; @@ -662,6 +660,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 */