From patchwork Wed Jan 15 21:31:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frank Schaefer X-Patchwork-Id: 21606 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1W3Y3K-0002u2-1x; Wed, 15 Jan 2014 22:31:10 +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 1W3Y3H-0002ze-0B; Wed, 15 Jan 2014 22:31:09 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751369AbaAOVbE (ORCPT + 1 other); Wed, 15 Jan 2014 16:31:04 -0500 Received: from mail-ea0-f174.google.com ([209.85.215.174]:39317 "EHLO mail-ea0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750952AbaAOVbD (ORCPT ); Wed, 15 Jan 2014 16:31:03 -0500 Received: by mail-ea0-f174.google.com with SMTP id b10so736593eae.33 for ; Wed, 15 Jan 2014 13:31:01 -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=vL6JIP4hTMZq9smPzYR8gEFFx80Mi47sYqr4QUyZ/R8=; b=l6Zv8YZsQHGO4ViYMUXIK3LSYChnWxoxbYeeqsgbEI1sM5pisjOeVC5dAsk5r70W/j RAlyBWimE0D3/NaGyyt6oiUiwrUFfOGNIRw8mlGNovngcjiTOHKpDwRsm3twoMb8x6U+ 2ti6lpZx6sQsQ+30wGX/DAwxEP6J1qqKDM4gvZVAiwcffGbUt4IEOvs7XiJnpBOAnWb8 MCkAGWBlTpKpF3Mpxao/166G0tgg3lXPRLBxSh9meZbvDQypLpHr+PLQMm6AhSem0qzw /3+T+5sYO0Sju33IlR4b348heiL97HQoLv2wChnJPImj1oTHupYBoqeuMfqb7LwbAiqy whPg== X-Received: by 10.15.23.139 with SMTP id h11mr6898047eeu.25.1389821461434; Wed, 15 Jan 2014 13:31:01 -0800 (PST) Received: from Athlon64X2-5000.site ([109.90.213.159]) by mx.google.com with ESMTPSA id m47sm13404475eey.7.2014.01.15.13.31.00 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Jan 2014 13:31:01 -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: [RFT PATCH] em28xx-audio: don't overwrite the usb alt setting made by the video part Date: Wed, 15 Jan 2014 22:31:42 +0100 Message-Id: <1389821502-11346-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.15.211815 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 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, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS , __YOUTUBE_RCVD 0' em28xx-audio currently switches to usb alternate setting #7 in case of a mixed interface. This may overwrite the setting made by the video part and break video streaming. As far as we know, there is no difference between the alt settings with regards to the audio endpoint if the interface is a mixed interface, the audio part only has to make sure that alt is > 0, which is fortunately only the case when video streaming is off. Signed-off-by: Frank Schäfer --- drivers/media/usb/em28xx/em28xx-audio.c | 41 ++++++++++++------------------- 1 Datei geändert, 16 Zeilen hinzugefügt(+), 25 Zeilen entfernt(-) diff --git a/drivers/media/usb/em28xx/em28xx-audio.c b/drivers/media/usb/em28xx/em28xx-audio.c index 05e9bd1..2e7a3ad 100644 --- a/drivers/media/usb/em28xx/em28xx-audio.c +++ b/drivers/media/usb/em28xx/em28xx-audio.c @@ -266,33 +266,30 @@ 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->is_audio_only) && dev->adev.users == 0) { - int nonblock = !!(substream->f_flags & O_NONBLOCK); + if (dev->adev.users == 0) { + int nonblock = !!(substream->f_flags & O_NONBLOCK); if (nonblock) { if (!mutex_trylock(&dev->lock)) return -EAGAIN; } else mutex_lock(&dev->lock); - if (dev->is_audio_only) - /* vendor audio is on a separate interface */ + + /* Select initial alternate setting (if necessary) */ + if (dev->alt == 0) { dev->alt = 1; - else - /* vendor audio is on the same interface as video */ - dev->alt = 7; /* - * FIXME: The intention seems to be to select the alt - * setting with the largest wMaxPacketSize for the video - * endpoint. - * At least dev->alt should be used instead, but we - * should probably not touch it at all if it is - * already >0, because wMaxPacketSize of the audio - * endpoints seems to be the same for all. + * NOTE: in case of a mixed (audio+video) interface, we + * don't want to touch the alt setting made by the video + * part. There is no difference between the alt settings + * with regards to the audio endpoint. + * TODO: in case of a pure audio interface, this could + * be improved. The alt settings are different here. */ - - dprintk("changing alternate number on interface %d to %d\n", - dev->ifnum, dev->alt); - usb_set_interface(dev->udev, dev->ifnum, dev->alt); + dprintk("changing alternate number on interface %d to %d\n", + dev->ifnum, dev->alt); + usb_set_interface(dev->udev, dev->ifnum, dev->alt); + } /* Sets volume, mute, etc */ dev->mute = 0; @@ -740,15 +737,9 @@ static int em28xx_audio_urb_init(struct em28xx *dev) struct usb_endpoint_descriptor *e, *ep = NULL; int i, ep_size, interval, num_urb, npackets; int urb_size, bytes_per_transfer; - u8 alt; - - if (dev->ifnum) - alt = 1; - else - alt = 7; + u8 alt = 1; 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->ifnum, alt);