Skip to content

Commit 717bfb5

Browse files
zonquetiwai
authored andcommitted
ALSA: snd-usb: handle raw data format of UAC2 devices
UAC2 compliant audio devices may announce the capability to transport raw audio data on their endpoints. Catch this and handle it as 'special' stream on the ALSA side. Signed-off-by: Daniel Mack <zonque@gmail.com> Reported-by: Andreas Koch <andreas@akdesigninc.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 2fcdb06 commit 717bfb5

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎include/linux/usb/audio-v2.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,8 @@ struct uac2_as_header_descriptor {
170170
__u8 iChannelNames;
171171
} __attribute__((packed));
172172

173+
#define UAC2_FORMAT_TYPE_I_RAW_DATA (1 << 31)
174+
173175
/* 4.10.1.2 Class-Specific AS Isochronous Audio Data Endpoint Descriptor */
174176

175177
struct uac2_iso_endpoint_descriptor {

‎sound/usb/format.c‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
4747
int protocol)
4848
{
4949
int sample_width, sample_bytes;
50-
u64 pcm_formats;
50+
u64 pcm_formats = 0;
5151

5252
switch (protocol) {
5353
case UAC_VERSION_1:
@@ -63,14 +63,17 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
6363
struct uac_format_type_i_ext_descriptor *fmt = _fmt;
6464
sample_width = fmt->bBitResolution;
6565
sample_bytes = fmt->bSubslotSize;
66+
67+
if (format & UAC2_FORMAT_TYPE_I_RAW_DATA)
68+
pcm_formats |= SNDRV_PCM_FMTBIT_SPECIAL;
69+
6670
format <<= 1;
6771
break;
6872
}
6973
}
7074

71-
pcm_formats = 0;
72-
73-
if (format == 0 || format == (1 << UAC_FORMAT_TYPE_I_UNDEFINED)) {
75+
if ((pcm_formats == 0) &&
76+
(format == 0 || format == (1 << UAC_FORMAT_TYPE_I_UNDEFINED))) {
7477
/* some devices don't define this correctly... */
7578
snd_printdd(KERN_INFO "%d:%u:%d : format type 0 is detected, processed as PCM\n",
7679
chip->dev->devnum, fp->iface, fp->altsetting);

0 commit comments

Comments
 (0)