Skip to content

Commit

Permalink
ALSA: usb: add UAC3 BADD profiles support
Browse files Browse the repository at this point in the history
Recently released USB Audio Class 3.0 specification
contains BADD (Basic Audio Device Definition) document
which describes pre-defined UAC3 configurations.

BADD support is mandatory for UAC3 devices, it should be
implemented as a separate USB device configuration.
As per BADD document, class-specific descriptors
shall not be included in the Device’s Configuration
descriptor ("inferred"), but host can guess them
from BADD profile number, number of endpoints and
their max packed sizes.

This patch adds support of all BADD profiles from the spec

Signed-off-by: Ruslan Bilovol <ruslan.bilovol@gmail.com>
Tested-by: Jorge Sanjuan <jorge.sanjuan@codethink.co.uk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Ruslan Bilovol authored and Takashi Iwai committed May 13, 2018
1 parent 10aa7ca commit 17156f2
Show file tree
Hide file tree
Showing 6 changed files with 459 additions and 41 deletions.
14 changes: 14 additions & 0 deletions sound/usb/card.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,20 @@ static int snd_usb_create_streams(struct snd_usb_audio *chip, int ctrlif)
return -EINVAL;
}

if (protocol == UAC_VERSION_3) {
int badd = assoc->bFunctionSubClass;

if (badd != UAC3_FUNCTION_SUBCLASS_FULL_ADC_3_0 &&
(badd < UAC3_FUNCTION_SUBCLASS_GENERIC_IO ||
badd > UAC3_FUNCTION_SUBCLASS_SPEAKERPHONE)) {
dev_err(&dev->dev,
"Unsupported UAC3 BADD profile\n");
return -EINVAL;
}

chip->badd_profile = badd;
}

for (i = 0; i < assoc->bInterfaceCount; i++) {
int intf = assoc->bFirstInterface + i;

Expand Down
9 changes: 8 additions & 1 deletion sound/usb/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,15 @@ int snd_usb_init_sample_rate(struct snd_usb_audio *chip, int iface,
default:
return set_sample_rate_v1(chip, iface, alts, fmt, rate);

case UAC_VERSION_2:
case UAC_VERSION_3:
if (chip->badd_profile >= UAC3_FUNCTION_SUBCLASS_GENERIC_IO) {
if (rate != UAC3_BADD_SAMPLING_RATE)
return -ENXIO;
else
return 0;
}
/* fall through */
case UAC_VERSION_2:
return set_sample_rate_v2v3(chip, iface, alts, fmt, rate);
}
}
Expand Down
Loading

0 comments on commit 17156f2

Please sign in to comment.