Commit b531f81b0d70ffbe8d70500512483227cc532608
Committed by
Takashi Iwai
1 parent
92c69e796b
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
ALSA: usb: Fix Processing Unit Descriptor parsers
Commit 99fc86450c439039d2ef88d06b222fd51a779176 "ALSA: usb-mixer: parse descriptors with structs" introduced a set of useful parsers for descriptors. Unfortunately the parses for the Processing Unit Descriptor came with a very subtle bug... Functions uac_processing_unit_iProcessing() and uac_processing_unit_specific() were indexing the baSourceID array forgetting the fields before the iProcessing and process-specific descriptors. The problem was observed with Sound Blaster Extigy mixer, where nNrModes in Up/Down-mix Processing Unit Descriptor was accessed at offset 10 of the descriptor (value 0) instead of offset 15 (value 7). In result the resulting control had interesting limit values: Simple mixer control 'Channel Routing Mode Select',0 Capabilities: volume volume-joined penum Playback channels: Mono Capture channels: Mono Limits: 0 - -1 Mono: -1 [100%] Fixed by starting from the bmControls, which was calculated correctly, instead of baSourceID. Now the mentioned control is fine: Simple mixer control 'Channel Routing Mode Select',0 Capabilities: volume volume-joined penum Playback channels: Mono Capture channels: Mono Limits: 0 - 6 Mono: 0 [0%] Signed-off-by: Pawel Moll <mail@pawelmoll.com> Cc: <stable@vger.kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Showing 1 changed file with 4 additions and 2 deletions Side-by-side Diff
include/uapi/linux/usb/audio.h
... | ... | @@ -384,14 +384,16 @@ |
384 | 384 | int protocol) |
385 | 385 | { |
386 | 386 | __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); |
387 | - return desc->baSourceID[desc->bNrInPins + control_size]; | |
387 | + return *(uac_processing_unit_bmControls(desc, protocol) | |
388 | + + control_size); | |
388 | 389 | } |
389 | 390 | |
390 | 391 | static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc, |
391 | 392 | int protocol) |
392 | 393 | { |
393 | 394 | __u8 control_size = uac_processing_unit_bControlSize(desc, protocol); |
394 | - return &desc->baSourceID[desc->bNrInPins + control_size + 1]; | |
395 | + return uac_processing_unit_bmControls(desc, protocol) | |
396 | + + control_size + 1; | |
395 | 397 | } |
396 | 398 | |
397 | 399 | /* 4.5.2 Class-Specific AS Interface Descriptor */ |