History

ALSA: usb-audio: Add support for Processing Units in UAC3

This patch adds support for the Processig Units defined in the UAC3 spec. The main difference with the previous specs is the lack of on/off switches in the controls for these units and the addiction of the new Multi Function Processing Unit. The current version of the UAC3 spec doesn't define any useful controls for the new Multi Function Processing Unit so no control will get created once this unit is parsed.

Jorge Sanjuan committed 8 years ago

Commit 0f292f01 parent 4e887af3 files · +104 −11Browse files

Showing the changes to include/uapi/linux (1 of 3 files). Show all

Unified · Split

include/uapi/linux/usb/audio.h+40−9
@@ -390,33 +390,64 @@ static inline __u8 uac_processing_unit_iChannelNames(struct uac_processing_unit_ · 389 unmodified lines
390390 static inline __u8 uac_processing_unit_bControlSize(struct uac_processing_unit_descriptor *desc,
391391 int protocol)
392392 {
393− return (protocol == UAC_VERSION_1) ?
394− desc->baSourceID[desc->bNrInPins + 4] :
395− 2; /* in UAC2, this value is constant */
393+ switch (protocol) {
394+ case UAC_VERSION_1:
395+ return desc->baSourceID[desc->bNrInPins + 4];
396+ case UAC_VERSION_2:
397+ return 2; /* in UAC2, this value is constant */
398+ case UAC_VERSION_3:
399+ return 4; /* in UAC3, this value is constant */
400+ default:
401+ return 1;
402+ }
396403 }
397404
398405 static inline __u8 *uac_processing_unit_bmControls(struct uac_processing_unit_descriptor *desc,
399406 int protocol)
400407 {
401− return (protocol == UAC_VERSION_1) ?
402− &desc->baSourceID[desc->bNrInPins + 5] :
403− &desc->baSourceID[desc->bNrInPins + 6];
408+ switch (protocol) {
409+ case UAC_VERSION_1:
410+ return &desc->baSourceID[desc->bNrInPins + 5];
411+ case UAC_VERSION_2:
412+ return &desc->baSourceID[desc->bNrInPins + 6];
413+ case UAC_VERSION_3:
414+ return &desc->baSourceID[desc->bNrInPins + 2];
415+ default:
416+ return NULL;
417+ }
404418 }
405419
406420 static inline __u8 uac_processing_unit_iProcessing(struct uac_processing_unit_descriptor *desc,
407421 int protocol)
408422 {
409423 __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
410− return *(uac_processing_unit_bmControls(desc, protocol)
411− + control_size);
424+
425+ switch (protocol) {
426+ case UAC_VERSION_1:
427+ case UAC_VERSION_2:
428+ default:
429+ return *(uac_processing_unit_bmControls(desc, protocol)
430+ + control_size);
431+ case UAC_VERSION_3:
432+ return 0; /* UAC3 does not have this field */
433+ }
412434 }
413435
414436 static inline __u8 *uac_processing_unit_specific(struct uac_processing_unit_descriptor *desc,
415437 int protocol)
416438 {
417439 __u8 control_size = uac_processing_unit_bControlSize(desc, protocol);
418− return uac_processing_unit_bmControls(desc, protocol)
440+
441+ switch (protocol) {
442+ case UAC_VERSION_1:
443+ case UAC_VERSION_2:
444+ default:
445+ return uac_processing_unit_bmControls(desc, protocol)
419446 + control_size + 1;
447+ case UAC_VERSION_3:
448+ return uac_processing_unit_bmControls(desc, protocol)
449+ + control_size;
450+ }
420451 }
421452
422453 /* 4.5.2 Class-Specific AS Interface Descriptor */