Commit 342cda29343a6272c630f94ed56810a76740251b
Committed by
Takashi Iwai
1 parent
d81bf8cf54
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
ALSA: usb-audio: work around Android accessory firmware bug
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> Cc: <stable@vger.kernel.org> Signed-off-by: Clemens Ladisch <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Showing 1 changed file with 20 additions and 2 deletions Side-by-side Diff
sound/usb/card.c
... | ... | @@ -147,14 +147,32 @@ |
147 | 147 | return -EINVAL; |
148 | 148 | } |
149 | 149 | |
150 | + alts = &iface->altsetting[0]; | |
151 | + altsd = get_iface_desc(alts); | |
152 | + | |
153 | + /* | |
154 | + * Android with both accessory and audio interfaces enabled gets the | |
155 | + * interface numbers wrong. | |
156 | + */ | |
157 | + if ((chip->usb_id == USB_ID(0x18d1, 0x2d04) || | |
158 | + chip->usb_id == USB_ID(0x18d1, 0x2d05)) && | |
159 | + interface == 0 && | |
160 | + altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC && | |
161 | + altsd->bInterfaceSubClass == USB_SUBCLASS_VENDOR_SPEC) { | |
162 | + interface = 2; | |
163 | + iface = usb_ifnum_to_if(dev, interface); | |
164 | + if (!iface) | |
165 | + return -EINVAL; | |
166 | + alts = &iface->altsetting[0]; | |
167 | + altsd = get_iface_desc(alts); | |
168 | + } | |
169 | + | |
150 | 170 | if (usb_interface_claimed(iface)) { |
151 | 171 | snd_printdd(KERN_INFO "%d:%d:%d: skipping, already claimed\n", |
152 | 172 | dev->devnum, ctrlif, interface); |
153 | 173 | return -EINVAL; |
154 | 174 | } |
155 | 175 | |
156 | - alts = &iface->altsetting[0]; | |
157 | - altsd = get_iface_desc(alts); | |
158 | 176 | if ((altsd->bInterfaceClass == USB_CLASS_AUDIO || |
159 | 177 | altsd->bInterfaceClass == USB_CLASS_VENDOR_SPEC) && |
160 | 178 | altsd->bInterfaceSubClass == USB_SUBCLASS_MIDISTREAMING) { |