stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Jeremy Rosen <jeremy.rosen@openwide.fr>,
	Clemens Ladisch <clemens@ladisch.de>,
	Takashi Iwai <tiwai@suse.de>
Subject: [ 01/17] ALSA: usb-audio: work around Android accessory firmware bug
Date: Tue, 25 Jun 2013 11:39:16 -0700	[thread overview]
Message-ID: <20130625183915.616233338@linuxfoundation.org> (raw)
In-Reply-To: <20130625183915.443950649@linuxfoundation.org>

3.0-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Clemens Ladisch <clemens@ladisch.de>

commit 342cda29343a6272c630f94ed56810a76740251b upstream.

When the Android firmware enables the audio interfaces in accessory
mode, it always declares in the control interface's baInterfaceNr array
that interfaces 0 and 1 belong to the audio function.  However, the
accessory interface itself, if also enabled, already is at index 0 and
shifts the actual audio interface numbers to 1 and 2, which prevents the
PCM streaming interface from being seen by the host driver.

To get the PCM interface interface to work, detect when the descriptors
point to the (for this driver useless) accessory interface, and redirect
to the correct one.

Reported-by: Jeremy Rosen <jeremy.rosen@openwide.fr>
Tested-by: Jeremy Rosen <jeremy.rosen@openwide.fr>
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 sound/usb/card.c |   22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

--- a/sound/usb/card.c
+++ b/sound/usb/card.c
@@ -148,14 +148,32 @@ static int snd_usb_create_stream(struct
 		return -EINVAL;
 	}
 
+	alts = &iface->altsetting[0];
+	altsd = get_iface_desc(alts);
+
+	/*
+	 * Android with both accessory and audio interfaces enabled gets the
+	 * interface numbers wrong.
+	 */
+	if ((chip->usb_id == USB_ID(0x18d1, 0x2d04) ||
+	     chip->usb_id == USB_ID(0x18d1, 0x2d05)) &&
+	    interface == 0 &&
+	    altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC &&
+	    altsd->bInterfaceSubClass == USB_SUBCLASS_VENDOR_SPEC) {
+		interface = 2;
+		iface = usb_ifnum_to_if(dev, interface);
+		if (!iface)
+			return -EINVAL;
+		alts = &iface->altsetting[0];
+		altsd = get_iface_desc(alts);
+	}
+
 	if (usb_interface_claimed(iface)) {
 		snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n",
 						dev->devnum, ctrlif, interface);
 		return -EINVAL;
 	}
 
-	alts = &iface->altsetting[0];
-	altsd = get_iface_desc(alts);
 	if ((altsd->bInterfaceClass == USB_CLASS_AUDIO ||
 	     altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) &&
 	    altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) {



  reply	other threads:[~2013-06-25 18:39 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-25 18:39 [ 00/17] 3.0.84-stable review Greg Kroah-Hartman
2013-06-25 18:39 ` Greg Kroah-Hartman [this message]
2013-06-25 18:39 ` [ 02/17] tilepro: work around module link error with gcc 4.7 Greg Kroah-Hartman
2013-06-25 18:39 ` [ 03/17] KVM: x86: remove vcpus CPL check in host-invoked XCR set Greg Kroah-Hartman
2013-06-25 18:39 ` [ 04/17] tcp: fix tcp_md5_hash_skb_data() Greg Kroah-Hartman
2013-06-25 18:39 ` [ 05/17] gianfar: add missing iounmap() on error in gianfar_ptp_probe() Greg Kroah-Hartman
2013-06-25 18:39 ` [ 06/17] ipv6: fix possible crashes in ip6_cork_release() Greg Kroah-Hartman
2013-06-25 18:39 ` [ 07/17] netlabel: improve domain mapping validation Greg Kroah-Hartman
2013-06-25 18:39 ` [ 08/17] tcp: xps: fix reordering issues Greg Kroah-Hartman
2013-06-25 18:39 ` [ 09/17] ip_tunnel: fix kernel panic with icmp_dest_unreach Greg Kroah-Hartman
2013-06-25 18:39 ` [ 10/17] net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg Greg Kroah-Hartman
2013-06-25 18:39 ` [ 11/17] net: force a reload of first item in hlist_nulls_for_each_entry_rcu Greg Kroah-Hartman
2013-06-25 18:39 ` [ 12/17] ipv6: assign rt6_info to inet6_ifaddr in init_loopback Greg Kroah-Hartman
2013-06-25 18:39 ` [ 13/17] net: sctp: fix NULL pointer dereference in socket destruction Greg Kroah-Hartman
2013-06-25 18:39 ` [ 14/17] packet: packet_getname_spkt: make sure string is always 0-terminated Greg Kroah-Hartman
2013-06-25 18:39 ` [ 15/17] l2tp: Fix PPP header erasure and memory leak Greg Kroah-Hartman
2013-06-25 18:39 ` [ 16/17] l2tp: Fix sendmsg() return value Greg Kroah-Hartman
2013-06-25 18:39 ` [ 17/17] USB: serial: ti_usb_3410_5052: new device id for Abbot strip port cable Greg Kroah-Hartman
2013-06-25 21:39   ` Anders Hammarquist
2013-06-26 17:21     ` Greg Kroah-Hartman
2013-06-27  0:28       ` Anders Hammarquist
2013-06-25 19:23 ` [ 00/17] 3.0.84-stable review Guenter Roeck
2013-06-25 19:32   ` Geert Uytterhoeven
2013-06-25 19:39     ` Guenter Roeck
2013-06-26  7:34       ` Geert Uytterhoeven
2013-06-26 14:40         ` Guenter Roeck
2013-06-26 23:06         ` Greg Ungerer
2013-06-26 23:29           ` Guenter Roeck
2013-08-01 14:35             ` Greg Ungerer
2013-08-01 15:08               ` Guenter Roeck
2013-06-26  4:16   ` Greg Kroah-Hartman
2013-06-26 16:57 ` Shuah Khan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130625183915.616233338@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=clemens@ladisch.de \
    --cc=jeremy.rosen@openwide.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).