Skip to content

Commit 05f254a

Browse files
puleglottiwai
authored andcommitted
ALSA: usb-audio: Improve filtering of sample rates on Focusrite devices
Previously we were filtering out only upper unsupported sampling rates. This patch adds filtering of the lower unsupported sampling rates. As a result there is 1:1 mapping between altsetting and supported rates. The issue was found on a Scarlett 3rd Gen card (see linked bug), but the same filtering is likely needed for the Scarlett 1st and 2nd Gen as well as the older Clarett cards which lacks Valid Alternate Setting Control. Patch was not tested on a real hardware. Link: https://bugzilla.kernel.org/show_bug.cgi?id=214493 Signed-off-by: Alexander Tsoy <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent ce174b4 commit 05f254a

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

sound/usb/format.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,14 @@ static bool focusrite_valid_sample_rate(struct snd_usb_audio *chip,
310310
struct audioformat *fp,
311311
unsigned int rate)
312312
{
313-
struct usb_interface *iface;
314313
struct usb_host_interface *alts;
315314
unsigned char *fmt;
316315
unsigned int max_rate;
317316

318-
iface = usb_ifnum_to_if(chip->dev, fp->iface);
319-
if (!iface)
317+
alts = snd_usb_get_host_interface(chip, fp->iface, fp->altsetting);
318+
if (!alts)
320319
return true;
321320

322-
alts = &iface->altsetting[fp->altset_idx];
323321
fmt = snd_usb_find_csint_desc(alts->extra, alts->extralen,
324322
NULL, UAC_FORMAT_TYPE);
325323
if (!fmt)
@@ -328,20 +326,20 @@ static bool focusrite_valid_sample_rate(struct snd_usb_audio *chip,
328326
if (fmt[0] == 10) { /* bLength */
329327
max_rate = combine_quad(&fmt[6]);
330328

331-
/* Validate max rate */
332-
if (max_rate != 48000 &&
333-
max_rate != 96000 &&
334-
max_rate != 192000 &&
335-
max_rate != 384000) {
336-
329+
switch (max_rate) {
330+
case 48000:
331+
return (rate == 44100 || rate == 48000);
332+
case 96000:
333+
return (rate == 88200 || rate == 96000);
334+
case 192000:
335+
return (rate == 176400 || rate == 192000);
336+
default:
337337
usb_audio_info(chip,
338338
"%u:%d : unexpected max rate: %u\n",
339339
fp->iface, fp->altsetting, max_rate);
340340

341341
return true;
342342
}
343-
344-
return rate <= max_rate;
345343
}
346344

347345
return true;

0 commit comments

Comments
 (0)