[PATCH v1 8/8] lsusb: Dump USB3 BOS Configuration Summary Descriptor.
--- lsusb.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/lsusb.c b/lsusb.c index c9d0d74..ddc19e0 100644 --- a/lsusb.c +++ b/lsusb.c @@ -75,6 +75,7 @@ #define USB_DC_PLATFORM0x05 #define USB_DC_SUPERSPEEDPLUS 0x0a #define USB_DC_BILLBOARD 0x0d +#define USB_DC_CONFIGURATION_SUMMARY 0x10 /* Conventional codes for class-specific descriptors. The convention is * defined in the USB "Common Class" Spec (3.11). Individual class specs @@ -3513,6 +3514,11 @@ static void dump_bos_descriptor(libusb_device_handle *fd) case USB_DC_BILLBOARD: dump_billboard_device_capability_desc(fd, buf); break; + case USB_DC_CONFIGURATION_SUMMARY: + printf(" Configuration Summary Device Capability:\n"); + desc_dump(fd, desc_usb3_dc_configuration_summary, + buf, DESC_BUF_LEN_FROM_BUF, 2); + break; default: printf(" ** UNRECOGNIZED: "); dump_bytes(buf, buf[0]); -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 4/8] lsusb: Switch to descriptor-definition based dump for UAC1 and UAC2.
This gives us more consistency in handling of incorrect descriptor buffer lengths, and improves whitespace/alignment consistency. --- Makefile.am | 2 + lsusb.c | 779 +--- 2 files changed, 63 insertions(+), 718 deletions(-) diff --git a/Makefile.am b/Makefile.am index 117e94b..46fd7b5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,6 +19,8 @@ lsusb_SOURCES = \ lsusb.c lsusb.h \ lsusb-t.c \ list.h \ + desc-defs.c desc-defs.h \ + desc-dump.c desc-dump.h \ names.c names.h \ usb-spec.h \ usbmisc.c usbmisc.h diff --git a/lsusb.c b/lsusb.c index c35d92e..ac6e061 100644 --- a/lsusb.c +++ b/lsusb.c @@ -31,6 +31,7 @@ #include #include #include +#include #ifdef HAVE_BYTESWAP_H #include @@ -42,6 +43,8 @@ #include "lsusb.h" #include "names.h" #include "usbmisc.h" +#include "desc-defs.h" +#include "desc-dump.h" #include @@ -159,7 +162,7 @@ static void dump_videostreaming_interface(const unsigned char *buf); static void dump_dfu_interface(const unsigned char *buf); static char *dump_comm_descriptor(libusb_device_handle *dev, const unsigned char *buf, char *indent); static void dump_hid_device(libusb_device_handle *dev, const struct libusb_interface_descriptor *interface, const unsigned char *buf); -static void dump_audiostreaming_endpoint(const unsigned char *buf, int protocol); +static void dump_audiostreaming_endpoint(libusb_device_handle *dev, const unsigned char *buf, int protocol); static void dump_midistreaming_endpoint(const unsigned char *buf); static void dump_hub(const char *prefix, const unsigned char *p, int tt_type); static void dump_ccid_device(const unsigned char *buf); @@ -626,7 +629,7 @@ static void dump_altsetting(libusb_device_handle *dev, const struct libusb_inter case USB_DT_CS_ENDPOINT: switch (interface->bInterfaceSubClass) { case 2: - dump_audiostreaming_endpoint(buf, interface->bInterfaceProtocol); + dump_audiostreaming_endpoint(dev, buf, interface->bInterfaceProtocol); break; default: goto dump; @@ -756,7 +759,7 @@ static void dump_endpoint(libusb_device_handle *dev, const struct libusb_interfa switch (buf[1]) { case USB_DT_CS_ENDPOINT: if (interface->bInterfaceClass == 1 && interface->bInterfaceSubClass == 2) - dump_audiostreaming_endpoint(buf, interface->bInterfaceProtocol); + dump_audiostreaming_endpoint(dev, buf, interface->bInterfaceProtocol); else if (interface->bInterfaceClass == 1 && interface->bInterfaceSubClass == 3) dump_midistreaming_endpoint(buf); break; @@ -880,125 +883,32 @@ static void dump_unit(unsigned int data, unsigned int len) * Audio Class descriptor dump */ -struct bmcontrol { - const char *name; - unsigned int bit; -}; - -static const struct bmcontrol uac2_interface_header_bmcontrols[] = { - { "Latency control",0 }, - { NULL } -}; - -static const struct bmcontrol uac_fu_bmcontrols[] = { - { "Mute", 0 }, - { "Volume", 1 }, - { "Bass", 2 }, - { "Mid",3 }, - { "Treble", 4 }, - { "Graphic Equalizer", 5 }, - { "Automatic Gain", 6 }, - { "Delay", 7 }, - { "Bass Boost", 8 }, - { "Loudness", 9 }, - { "Input gain", 10 }, - { "Input gain pad", 11 }, - { "Phase inverter", 12 }, - { NULL } -}; - -static const struct bmcontrol uac2_input_term_bmcontrols[] = { - { "Copy Protect", 0 }, - { "Connector", 1 }, - { "Overload", 2 }, - { "Cluster",3 }, - { "Underflow", 4 }, - { "Overflow", 5 }, - { NULL } -}; - -static const struct bmcontrol uac2_output_term_bmcontrols[] = { - { "Copy Protect", 0 }, - { "Connector", 1 }, - { "Overload", 2 }, - { "Underflow", 3 }, - { "Overflow", 4 }, - { NULL } -}; - -static const struct bmcontrol uac2_mixer_unit_bmcontrols[] = { - { "Cluster",0 }, - { "Underflow", 1 }, - { "Overflow", 2 }, - { NULL } -}; - -static const struct bmcontrol uac2_extension_unit_bmcontrols[] = { -
[PATCH v1 0/8] lsusb: Add initial support for USB Audio Class 3
This adds a new way of dumping descriptors, which splits the knowledge of how to interpret descriptor data from the actual dumping. This has two advantages: 1. It is easy to add support for new descriptors, since they are now simple definitions that resemble the tables in the USB specifications. 2. The code for dumping descriptors is common, so the output is easy to keep consistent. It is also consistent and thorough in its handling of insufficient descriptor data buffer, and junk data at the end of a descriptor. UAC1 and UAC2 are converted to use the new mechanism, initial support for UAC3 is added. Finally, support for the USB3 BOS Configuration Summary Descriptor is added. This was previously opened as a github pull request here: https://github.com/gregkh/usbutils/pull/61 Michael Drake (8): lsusb: Split subtype mapping out of AudioControl interface handling. lsusb: Add declarative definitions for UAC1 and UAC2 descriptors. lsusb: Add code to dump descriptor data using descriptor definition. lsusb: Switch to descriptor-definition based dump for UAC1 and UAC2. lsusb: Add descriptor definitions for UAC3. lsusb: Add initial support for UAC3. lsusb: Add descriptor definition for USB3 BOS Configuration Summary. lsusb: Dump USB3 BOS Configuration Summary Descriptor. Makefile.am | 2 + desc-defs.c | 910 desc-defs.h | 159 +++ desc-dump.c | 555 desc-dump.h | 64 + lsusb.c | 881 ++ 6 files changed, 1842 insertions(+), 729 deletions(-) create mode 100644 desc-defs.c create mode 100644 desc-defs.h create mode 100644 desc-dump.c create mode 100644 desc-dump.h -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 1/8] lsusb: Split subtype mapping out of AudioControl interface handling.
UAC1 and UAC2 have different different meanings for the same subtype value. This splits the subtype mapping out. --- lsusb.c | 100 ++-- 1 file changed, 79 insertions(+), 21 deletions(-) diff --git a/lsusb.c b/lsusb.c index f611f2e..c35d92e 100644 --- a/lsusb.c +++ b/lsusb.c @@ -1000,8 +1000,85 @@ static const char * const chconfig_uac2[] = { "Back Left of Center (BLC)", "Back Right of Center (BRC)" }; +/* USB Audio Class subtypes */ +enum uac_interface_subtype { + UAC_INTERFACE_SUBTYPE_AC_DESCRIPTOR_UNDEFINED = 0x00, + UAC_INTERFACE_SUBTYPE_HEADER = 0x01, + UAC_INTERFACE_SUBTYPE_INPUT_TERMINAL = 0x02, + UAC_INTERFACE_SUBTYPE_OUTPUT_TERMINAL = 0x03, + UAC_INTERFACE_SUBTYPE_EXTENDED_TERMINAL = 0x04, + UAC_INTERFACE_SUBTYPE_MIXER_UNIT = 0x05, + UAC_INTERFACE_SUBTYPE_SELECTOR_UNIT = 0x06, + UAC_INTERFACE_SUBTYPE_FEATURE_UNIT= 0x07, + UAC_INTERFACE_SUBTYPE_EFFECT_UNIT = 0x08, + UAC_INTERFACE_SUBTYPE_PROCESSING_UNIT = 0x09, + UAC_INTERFACE_SUBTYPE_EXTENSION_UNIT = 0x0a, + UAC_INTERFACE_SUBTYPE_CLOCK_SOURCE= 0x0b, + UAC_INTERFACE_SUBTYPE_CLOCK_SELECTOR = 0x0c, + UAC_INTERFACE_SUBTYPE_CLOCK_MULTIPLIER= 0x0d, + UAC_INTERFACE_SUBTYPE_SAMPLE_RATE_CONVERTER = 0x0e, + UAC_INTERFACE_SUBTYPE_CONNECTORS = 0x0f, + UAC_INTERFACE_SUBTYPE_POWER_DOMAIN= 0x10, +}; + + +/* + * UAC1, and UAC2 define bDescriptorSubtype differently for the + * AudioControl interface, so we need to do some ugly remapping: + * + * val | UAC1| UAC2 + * -|-|-- + * 0x00 | AC UNDEFINED| AC UNDEFINED + * 0x01 | HEADER | HEADER + * 0x02 | INPUT_TERMINAL | INPUT_TERMINAL + * 0x03 | OUTPUT_TERMINAL | OUTPUT_TERMINAL + * 0x04 | MIXER_UNIT | MIXER_UNIT + * 0x05 | SELECTOR_UNIT | SELECTOR_UNIT + * 0x06 | FEATURE_UNIT| FEATURE_UNIT + * 0x07 | PROCESSING_UNIT | EFFECT_UNIT + * 0x08 | EXTENSION_UNIT | PROCESSING_UNIT + * 0x09 | - | EXTENSION_UNIT + * 0x0a | - | CLOCK_SOURCE + * 0x0b | - | CLOCK_SELECTOR + * 0x0c | - | CLOCK_MULTIPLIER + * 0x0d | - | SAMPLE_RATE_CONVERTER + */ +static enum uac_interface_subtype get_uac_interface_subtype(unsigned char c, int protocol) +{ + switch (protocol) { + case USB_AUDIO_CLASS_1: + switch(c) { + case 0x04: return UAC_INTERFACE_SUBTYPE_MIXER_UNIT; + case 0x05: return UAC_INTERFACE_SUBTYPE_SELECTOR_UNIT; + case 0x06: return UAC_INTERFACE_SUBTYPE_FEATURE_UNIT; + case 0x07: return UAC_INTERFACE_SUBTYPE_PROCESSING_UNIT; + case 0x08: return UAC_INTERFACE_SUBTYPE_EXTENSION_UNIT; + } + break; + case USB_AUDIO_CLASS_2: + switch(c) { + case 0x04: return UAC_INTERFACE_SUBTYPE_MIXER_UNIT; + case 0x05: return UAC_INTERFACE_SUBTYPE_SELECTOR_UNIT; + case 0x06: return UAC_INTERFACE_SUBTYPE_FEATURE_UNIT; + case 0x07: return UAC_INTERFACE_SUBTYPE_EFFECT_UNIT; + case 0x08: return UAC_INTERFACE_SUBTYPE_PROCESSING_UNIT; + case 0x09: return UAC_INTERFACE_SUBTYPE_EXTENSION_UNIT; + case 0x0a: return UAC_INTERFACE_SUBTYPE_CLOCK_SOURCE; + case 0x0b: return UAC_INTERFACE_SUBTYPE_CLOCK_SELECTOR; + case 0x0c: return UAC_INTERFACE_SUBTYPE_CLOCK_MULTIPLIER; + case 0x0d: return UAC_INTERFACE_SUBTYPE_SAMPLE_RATE_CONVERTER; + } + break; + } + + return c; +} + + + static void dump_audiocontrol_interface(libusb_device_handle *dev, const unsigned char *buf, int protocol) { + enum uac_interface_subtype subtype; static const char * const chconfig[] = { "Left Front (L)", "Right Front (R)", "Center Front (C)", "Low Frequency Enhancement (LFE)", "Left Surround (LS)", "Right Surround (RS)", "Left of Center (LC)", "Right of Center (RC)", @@ -1010,7 +1087,7 @@ static void dump_audiocontrol_interface(libusb_device_handle *dev, const unsigne static const char * const clock_source_attrs[] = { "External", "Internal fixed", "Internal variable", "Internal programmable" }; - unsigned int i, chcfg, j, k, N, termt, subtype; + unsigned int i, chcfg, j, k, N, termt; char *chnames = NULL, *term = NULL, termts[128]; if (buf[1] != USB_DT_CS_INTERFACE) @@ -1023,26 +1100,7 @@ static void dump_audiocontrol_interface(libusb_device_handle *dev, const unsigne "bDescriptorSubtype %5u ", buf[0], buf[1], buf[2]); - /* -* This is an
[PATCH v1 7/8] lsusb: Add descriptor definition for USB3 BOS Configuration Summary.
--- desc-defs.c | 16 desc-defs.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/desc-defs.c b/desc-defs.c index 3b5ea1e..885e3fa 100644 --- a/desc-defs.c +++ b/desc-defs.c @@ -892,3 +892,19 @@ const struct desc * const desc_audio_as_isochronous_audio_data_endpoint[3] = { desc_audio_2_as_isochronous_audio_data_endpoint, desc_audio_3_as_isochronous_audio_data_endpoint, }; + + +/** USB3: 9.6.2.7 Configuration Summary Descriptor; Table 9-21. */ +const struct desc desc_usb3_dc_configuration_summary[] = { + { .field = "bLength", .size = 1, .type = DESC_NUMBER }, + { .field = "bDescriptorType", .size = 1, .type = DESC_CONSTANT }, + { .field = "bDevCapabilityType", .size = 1, .type = DESC_NUMBER }, + { .field = "bcdVersion", .size = 2, .type = DESC_BCD }, + { .field = "bClass", .size = 1, .type = DESC_NUMBER }, + { .field = "bSubClass", .size = 1, .type = DESC_NUMBER }, + { .field = "bProtocol", .size = 1, .type = DESC_NUMBER }, + { .field = "bConfigurationCount", .size = 1, .type = DESC_NUMBER }, + { .field = "bConfigurationIndex", .size = 1, .type = DESC_NUMBER, + .array = { .array = true, .length_field1 = "bConfigurationCount" } }, + { .field = NULL } +}; diff --git a/desc-defs.h b/desc-defs.h index d88ebd8..2c8f1b3 100644 --- a/desc-defs.h +++ b/desc-defs.h @@ -151,6 +151,9 @@ extern const struct desc * const desc_audio_ac_sample_rate_converter[3]; extern const struct desc * const desc_audio_as_interface[3]; extern const struct desc * const desc_audio_as_isochronous_audio_data_endpoint[3]; +/* Device Capability (DC) descriptor definitions */ +extern const struct desc desc_usb3_dc_configuration_summary[]; + /* -- */ #endif /* _DESC_DEFS_H */ -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 3/8] lsusb: Add code to dump descriptor data using descriptor definition.
This adds a new way of dumping descriptors. It takes the descriptor data to be dumped, and a descriptor definition as input. The descriptor definition takes the form of a NULL terminated array of descriptor field definitions. These definitions describe how the raw descriptor data buffer should be interpreted. Thus the knowledge of how to interpret a descriptor buffer is separate from the shared code that renders the descriptor dump. This has two advantages: 1. The code for dumping descriptors is common, so the output is easy to keep consistent. It is also consistent and thorough in its handling of insufficient descriptor data buffer, and junk data at the end of a descriptor. 2. It is easy to add support for new descriptors, since they are now simple definitions that resemble the tables in the USB specifications. --- desc-dump.c | 550 desc-dump.h | 64 +++ 2 files changed, 614 insertions(+) create mode 100644 desc-dump.c create mode 100644 desc-dump.h diff --git a/desc-dump.c b/desc-dump.c new file mode 100644 index 000..eb79eaf --- /dev/null +++ b/desc-dump.c @@ -0,0 +1,550 @@ +/*/ + +/* + * desc-dump.c -- USB descriptor dumping + * + * Copyright (C) 2017 Michael Drake + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +/*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +#include + +#include "desc-defs.h" +#include "desc-dump.h" +#include "usbmisc.h" +#include "names.h" + + +/** + * Print a description of a bmControls field value, using a given string array. + * + * Handles the DESC_BMCONTROL_1 and DESC_BMCONTROL_2 field types. The former + * is one bit per string, and the latter is 2 bits per string, with the + * additional bit specifying whether the control is read-only. + * + * \param[in] bmcontrols The value to dump a human-readable representation of. + * \param[in] strings Array of human-readable strings, must be NULL terminated. + * \param[in] typeThe type of the value in bmcontrols. + * \param[in] indent The current indent level. + */ +static void desc_bmcontrol_dump( + unsigned long long bmcontrols, + const char * const * strings, + enum desc_type type, + unsigned int indent) +{ + static const char * const setting[] = { + "read-only", + "ILLEGAL VALUE (0b10)", + "read/write" + }; + unsigned int count = 0; + unsigned int control; + + assert((type == DESC_BMCONTROL_1) || + (type == DESC_BMCONTROL_2)); + + while (strings[count] != NULL) { + if (strings[0] != '\0') { + if (type == DESC_BMCONTROL_1) { + if ((strings[count][0] != '\0') && + (bmcontrols >> count) & 0x1) { + printf("%*s%s Control\n", + indent * 2, "", + strings[count]); + } + } else { + control = (bmcontrols >> (count * 2)) & 0x3; + if ((strings[count][0] != '\0') && control) { + printf("%*s%s Control (%s)\n", + indent * 2, "", + strings[count], + setting[control-1]); + } + } + } + count++; + } +} + + +/** + * Read N bytes from descriptor data buffer into a value. + * + * Only supports values of up to 8 bytes. + * + * \param[in] buf Buffer containing the bytes to read. + * \param[in] offset Offset in buffer to start reading bytes from. + * \param[in] bytes Number of bytes to read. + * \return Value contained wit
[PATCH v1 2/8] lsusb: Add declarative definitions for UAC1 and UAC2 descriptors.
These descriptor definitions descibe how raw descriptor data should be interpreted. --- desc-defs.c | 647 desc-defs.h | 153 ++ 2 files changed, 800 insertions(+) create mode 100644 desc-defs.c create mode 100644 desc-defs.h diff --git a/desc-defs.c b/desc-defs.c new file mode 100644 index 000..6bc558e --- /dev/null +++ b/desc-defs.c @@ -0,0 +1,647 @@ +/*/ + +/* + * desc-defs.c -- USB descriptor definitions + * + * Copyright (C) 2017 Michael Drake + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +/*/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include + +#include "desc-defs.h" + +static const char * const uac2_interface_header_bmcontrols[] = { + "Latency control", + NULL +}; + +static const char * const uac_feature_unit_bmcontrols[] = { + "Mute", + "Volume", + "Bass", + "Mid", + "Treble", + "Graphic Equalizer", + "Automatic Gain", + "Delay", + "Bass Boost", + "Loudness", + "Input gain", + "Input gain pad", + "Phase inverter", + NULL +}; + +static const char * const uac2_input_term_bmcontrols[] = { + "Copy Protect", + "Connector", + "Overload", + "Cluster", + "Underflow", + "Overflow", + NULL +}; + +static const char * const uac2_output_term_bmcontrols[] = { + "Copy Protect", + "Connector", + "Overload", + "Underflow", + "Overflow", + NULL +}; + +static const char * const uac2_mixer_unit_bmcontrols[] = { + "Cluster", + "Underflow", + "Overflow", + NULL +}; + +static const char * const uac2_extension_unit_bmcontrols[] = { + "Enable", + "Cluster", + "Underflow", + "Overflow", + NULL +}; + +static const char * const uac2_clock_source_bmcontrols[] = { + "Clock Frequency", + "Clock Validity", + NULL +}; + +static const char * const uac2_clock_selector_bmcontrols[] = { + "Clock Selector", + NULL +}; + +static const char * const uac2_clock_multiplier_bmcontrols[] = { + "Clock Numerator", + "Clock Denominator", + NULL +}; + +static const char * const uac2_selector_bmcontrols[] = { + "Selector", + NULL +}; + +static const char * const uac1_channel_names[] = { + "Left Front (L)", "Right Front (R)", "Center Front (C)", + "Low Frequency Enhancement (LFE)", "Left Surround (LS)", + "Right Surround (RS)", "Left of Center (LC)", "Right of Center (RC)", + "Surround (S)", "Side Left (SL)", "Side Right (SR)", "Top (T)" +}; + +static const char * const uac2_channel_names[] = { + "Front Left (FL)", "Front Right (FR)", "Front Center (FC)", + "Low Frequency Effects (LFE)", "Back Left (BL)", "Back Right (BR)", + "Front Left of Center (FLC)", "Front Right of Center (FRC)", + "Back Center (BC)", "Side Left (SL)", "Side Right (SR)", + "Top Center (TC)", "Top Front Left (TFL)", "Top Front Center (TFC)", + "Top Front Right (TFR)", "Top Back Left (TBL)", "Top Back Center (TBC)", + "Top Back Right (TBR)", "Top Front Left of Center (TFLC)", + "Top Front Right of Center (TFRC)", "Left Low Frequency Effects (LLFE)", + "Right Low Frequency Effects (RLFE)", "Top Side Left (TSL)", + "Top Side Right (TSR)", "Bottom Center (BC)", + "Back Left of Center (BLC)", "Back Right of Center (BRC)" +}; + +/** UAC1: 4.
[PATCH v1 6/8] lsusb: Add initial support for UAC3.
--- lsusb.c | 52 ++-- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/lsusb.c b/lsusb.c index ac6e061..c9d0d74 100644 --- a/lsusb.c +++ b/lsusb.c @@ -106,6 +106,11 @@ #define USB_AUDIO_CLASS_2 0x20 #endif +/* USB DCD for Audio Devices Release 3.0: Section A.6, pp139 */ +#ifndef USB_AUDIO_CLASS_3 +#define USB_AUDIO_CLASS_3 0x30 +#endif + #ifndef USB_VIDEO_PROTOCOL_15 #define USB_VIDEO_PROTOCOL_15 0x01 #endif @@ -890,11 +895,12 @@ static void dump_audio_subtype(libusb_device_handle *dev, int protocol, unsigned int indent) { - static const char * const strings[] = { "UAC1", "UAC2" }; + static const char * const strings[] = { "UAC1", "UAC2", "UAC3" }; unsigned int idx = 0; switch (protocol) { case USB_AUDIO_CLASS_2: idx = 1; break; + case USB_AUDIO_CLASS_3: idx = 2; break; } printf("(%s)\n", name); @@ -933,25 +939,28 @@ enum uac_interface_subtype { /* - * UAC1, and UAC2 define bDescriptorSubtype differently for the + * UAC1, UAC2, and UAC3 define bDescriptorSubtype differently for the * AudioControl interface, so we need to do some ugly remapping: * - * val | UAC1| UAC2 - * -|-|-- - * 0x00 | AC UNDEFINED| AC UNDEFINED - * 0x01 | HEADER | HEADER - * 0x02 | INPUT_TERMINAL | INPUT_TERMINAL - * 0x03 | OUTPUT_TERMINAL | OUTPUT_TERMINAL - * 0x04 | MIXER_UNIT | MIXER_UNIT - * 0x05 | SELECTOR_UNIT | SELECTOR_UNIT - * 0x06 | FEATURE_UNIT| FEATURE_UNIT - * 0x07 | PROCESSING_UNIT | EFFECT_UNIT - * 0x08 | EXTENSION_UNIT | PROCESSING_UNIT - * 0x09 | - | EXTENSION_UNIT - * 0x0a | - | CLOCK_SOURCE - * 0x0b | - | CLOCK_SELECTOR - * 0x0c | - | CLOCK_MULTIPLIER - * 0x0d | - | SAMPLE_RATE_CONVERTER + * val | UAC1| UAC2 | UAC3 + * -|-|---|- + * 0x00 | AC UNDEFINED| AC UNDEFINED | AC UNDEFINED + * 0x01 | HEADER | HEADER| HEADER + * 0x02 | INPUT_TERMINAL | INPUT_TERMINAL| INPUT_TERMINAL + * 0x03 | OUTPUT_TERMINAL | OUTPUT_TERMINAL | OUTPUT_TERMINAL + * 0x04 | MIXER_UNIT | MIXER_UNIT| EXTENDED_TERMINAL + * 0x05 | SELECTOR_UNIT | SELECTOR_UNIT | MIXER_UNIT + * 0x06 | FEATURE_UNIT| FEATURE_UNIT | SELECTOR_UNIT + * 0x07 | PROCESSING_UNIT | EFFECT_UNIT | FEATURE_UNIT + * 0x08 | EXTENSION_UNIT | PROCESSING_UNIT | EFFECT_UNIT + * 0x09 | - | EXTENSION_UNIT| PROCESSING_UNIT + * 0x0a | - | CLOCK_SOURCE | EXTENSION_UNIT + * 0x0b | - | CLOCK_SELECTOR| CLOCK_SOURCE + * 0x0c | - | CLOCK_MULTIPLIER | CLOCK_SELECTOR + * 0x0d | - | SAMPLE_RATE_CONVERTER | CLOCK_MULTIPLIER + * 0x0e | - | - | SAMPLE_RATE_CONVERTER + * 0x0f | - | - | CONNECTORS + * 0x10 | - | - | POWER_DOMAIN */ static enum uac_interface_subtype get_uac_interface_subtype(unsigned char c, int protocol) { @@ -979,6 +988,9 @@ static enum uac_interface_subtype get_uac_interface_subtype(unsigned char c, int case 0x0d: return UAC_INTERFACE_SUBTYPE_SAMPLE_RATE_CONVERTER; } break; + case USB_AUDIO_CLASS_3: + /* No mapping required */ + break; } return c; @@ -1053,6 +1065,10 @@ static void dump_audiocontrol_interface(libusb_device_handle *dev, const unsigne dump_audio_subtype(dev, "EFFECT_UNIT", desc_audio_ac_effect_unit, buf, protocol, 4); break; + case UAC_INTERFACE_SUBTYPE_POWER_DOMAIN: + dump_audio_subtype(dev, "POWER_DOMAIN", desc_audio_ac_power_domain, buf, protocol, 4); + break; + default: printf("(unknown)\n" "Invalid desc subtype:"); -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 5/8] lsusb: Add descriptor definitions for UAC3.
--- desc-defs.c | 277 desc-defs.h | 3 + desc-dump.c | 5 ++ 3 files changed, 270 insertions(+), 15 deletions(-) diff --git a/desc-defs.c b/desc-defs.c index 6bc558e..3b5ea1e 100644 --- a/desc-defs.c +++ b/desc-defs.c @@ -61,6 +61,16 @@ static const char * const uac2_input_term_bmcontrols[] = { NULL }; +/* USB DCD for Audio Devices Release 3.0: Section 4.5.2.1, Table 4-16, pp67 */ +static const char * const uac3_input_term_bmcontrols[] = { + "Insertion", + "Overload", + "Underflow", + "Overflow", + "Underflow", + NULL +}; + static const char * const uac2_output_term_bmcontrols[] = { "Copy Protect", "Connector", @@ -70,6 +80,15 @@ static const char * const uac2_output_term_bmcontrols[] = { NULL }; +/* USB DCD for Audio Devices Release 3.0: Section 4.5.2.2, Table 4-17, pp69 */ +static const char * const uac3_output_term_bmcontrols[] = { + "Insertion", + "Overload", + "Underflow", + "Overflow", + NULL +}; + static const char * const uac2_mixer_unit_bmcontrols[] = { "Cluster", "Underflow", @@ -77,6 +96,13 @@ static const char * const uac2_mixer_unit_bmcontrols[] = { NULL }; +/* USB DCD for Audio Devices Release 3.0: Section 4.5.2.5, Table 4-29, pp79 */ +static const char * const uac3_mixer_unit_bmcontrols[] = { + "Underflow", + "Overflow", + NULL +}; + static const char * const uac2_extension_unit_bmcontrols[] = { "Enable", "Cluster", @@ -85,6 +111,13 @@ static const char * const uac2_extension_unit_bmcontrols[] = { NULL }; +/* USB DCD for Audio Devices Release 3.0: Section 4.5.2.11, Table 4-42, pp91 */ +static const char * const uac3_extension_unit_bmcontrols[] = { + "Underflow", + "Overflow", + NULL +}; + static const char * const uac2_clock_source_bmcontrols[] = { "Clock Frequency", "Clock Validity", @@ -146,10 +179,18 @@ static const struct desc desc_audio_2_ac_header[] = { .bmcontrol = uac2_interface_header_bmcontrols }, { .field = NULL } }; +/** UAC3: 4.5.2 Class-Specific AC Interface Descriptor; Table 4-15. */ +static const struct desc desc_audio_3_ac_header[] = { + { .field = "bCategory",.size = 1, .type = DESC_CONSTANT }, + { .field = "wTotalLength", .size = 2, .type = DESC_NUMBER }, + { .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2, + .bmcontrol = uac2_interface_header_bmcontrols }, + { .field = NULL } +}; const struct desc * const desc_audio_ac_header[3] = { desc_audio_1_ac_header, desc_audio_2_ac_header, - NULL, /* UAC3 not implemented yet */ + desc_audio_3_ac_header, }; /** UAC2: 4.7.2.10 Effect Unit Descriptor; Table 4-15. */ @@ -162,10 +203,20 @@ static const struct desc desc_audio_2_ac_effect_unit[] = { { .field = "iEffects",.size = 1, .type = DESC_STR_DESC_INDEX }, { .field = NULL } }; +/** UAC3: 4.5.2.9 Effect Unit Descriptor; Table 4-33. */ +static const struct desc desc_audio_3_ac_effect_unit[] = { + { .field = "bUnitID", .size = 1, .type = DESC_NUMBER }, + { .field = "wEffectType", .size = 2, .type = DESC_CONSTANT }, + { .field = "bSourceID",.size = 1, .type = DESC_CONSTANT }, + { .field = "bmaControls", .size = 4, .type = DESC_BITMAP, + .array = { .array = true } }, + { .field = "wEffectsDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID }, + { .field = NULL } +}; const struct desc * const desc_audio_ac_effect_unit[3] = { NULL, /* UAC1 not supported */ desc_audio_2_ac_effect_unit, - NULL, /* UAC3 not implemented yet */ + desc_audio_3_ac_effect_unit, }; @@ -196,10 +247,24 @@ static const struct desc desc_audio_2_ac_input_terminal[] = { { .field = "iTerminal", .size = 1, .type = DESC_STR_DESC_INDEX }, { .field = NULL } }; +/** UAC3: 4.5.2.1 Input Terminal Descriptor; Table 4-16. */ +static const struct desc desc_audio_3_ac_input_terminal[] = { + { .field = "bTerminalID",.size = 1, .type = DESC_NUMBER }, + { .field = "wTerminalType", .size = 2, .type = DESC_TERMINAL_STR }, + { .field = "bAssocTerminal", .size = 1, .type = DESC_NUMBER }, + { .field = "bCSourceID", .size = 1, .type = DESC_NUMBER }, + { .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2, + .bmcontrol = uac3_input_term_bmcontrols }, + { .field = "wClusterDescrID",.size = 2, .type = DESC_NUMBER }, + { .field = "wExTerminalDescrID", .size = 2, .type = DESC_NUMBER }, + { .field = "wConnectorsDescrID", .size = 2, .type = DESC_NUMBER }, + { .field = "wTerminalDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID }, + { .field = NULL } +}; const
Re: [PATCH v1 1/8] lsusb: Split subtype mapping out of AudioControl interface handling.
On 05/12/17 16:31, Greg KH wrote: On Tue, Dec 05, 2017 at 04:14:24PM +, Michael Drake wrote: UAC1 and UAC2 have different different meanings for the same subtype value. This splits the subtype mapping out. --- Minor nit, can you sign-off on your patches like kernel patches have? That way I know you are contributing this properly :) OK, will do. lsusb.c | 100 ++-- 1 file changed, 79 insertions(+), 21 deletions(-) diff --git a/lsusb.c b/lsusb.c index f611f2e..c35d92e 100644 --- a/lsusb.c +++ b/lsusb.c @@ -1000,8 +1000,85 @@ static const char * const chconfig_uac2[] = { "Back Left of Center (BLC)", "Back Right of Center (BRC)" }; +/* USB Audio Class subtypes */ +enum uac_interface_subtype { + UAC_INTERFACE_SUBTYPE_AC_DESCRIPTOR_UNDEFINED = 0x00, + UAC_INTERFACE_SUBTYPE_HEADER = 0x01, + UAC_INTERFACE_SUBTYPE_INPUT_TERMINAL = 0x02, + UAC_INTERFACE_SUBTYPE_OUTPUT_TERMINAL = 0x03, + UAC_INTERFACE_SUBTYPE_EXTENDED_TERMINAL = 0x04, + UAC_INTERFACE_SUBTYPE_MIXER_UNIT = 0x05, + UAC_INTERFACE_SUBTYPE_SELECTOR_UNIT = 0x06, + UAC_INTERFACE_SUBTYPE_FEATURE_UNIT= 0x07, + UAC_INTERFACE_SUBTYPE_EFFECT_UNIT = 0x08, + UAC_INTERFACE_SUBTYPE_PROCESSING_UNIT = 0x09, + UAC_INTERFACE_SUBTYPE_EXTENSION_UNIT = 0x0a, + UAC_INTERFACE_SUBTYPE_CLOCK_SOURCE= 0x0b, + UAC_INTERFACE_SUBTYPE_CLOCK_SELECTOR = 0x0c, + UAC_INTERFACE_SUBTYPE_CLOCK_MULTIPLIER= 0x0d, + UAC_INTERFACE_SUBTYPE_SAMPLE_RATE_CONVERTER = 0x0e, + UAC_INTERFACE_SUBTYPE_CONNECTORS = 0x0f, + UAC_INTERFACE_SUBTYPE_POWER_DOMAIN= 0x10, +}; + + Only 1 blank line between functions/things please, otherwise it's just a lot of whitespace :) OK, I've changed that everywhere. +/* + * UAC1, and UAC2 define bDescriptorSubtype differently for the + * AudioControl interface, so we need to do some ugly remapping: + * + * val | UAC1| UAC2 + * -|-|-- + * 0x00 | AC UNDEFINED| AC UNDEFINED + * 0x01 | HEADER | HEADER + * 0x02 | INPUT_TERMINAL | INPUT_TERMINAL + * 0x03 | OUTPUT_TERMINAL | OUTPUT_TERMINAL + * 0x04 | MIXER_UNIT | MIXER_UNIT + * 0x05 | SELECTOR_UNIT | SELECTOR_UNIT + * 0x06 | FEATURE_UNIT| FEATURE_UNIT + * 0x07 | PROCESSING_UNIT | EFFECT_UNIT + * 0x08 | EXTENSION_UNIT | PROCESSING_UNIT + * 0x09 | - | EXTENSION_UNIT + * 0x0a | - | CLOCK_SOURCE + * 0x0b | - | CLOCK_SELECTOR + * 0x0c | - | CLOCK_MULTIPLIER + * 0x0d | - | SAMPLE_RATE_CONVERTER + */ +static enum uac_interface_subtype get_uac_interface_subtype(unsigned char c, int protocol) +{ + switch (protocol) { + case USB_AUDIO_CLASS_1: + switch(c) { + case 0x04: return UAC_INTERFACE_SUBTYPE_MIXER_UNIT; + case 0x05: return UAC_INTERFACE_SUBTYPE_SELECTOR_UNIT; + case 0x06: return UAC_INTERFACE_SUBTYPE_FEATURE_UNIT; + case 0x07: return UAC_INTERFACE_SUBTYPE_PROCESSING_UNIT; + case 0x08: return UAC_INTERFACE_SUBTYPE_EXTENSION_UNIT; + } + break; + case USB_AUDIO_CLASS_2: + switch(c) { + case 0x04: return UAC_INTERFACE_SUBTYPE_MIXER_UNIT; + case 0x05: return UAC_INTERFACE_SUBTYPE_SELECTOR_UNIT; + case 0x06: return UAC_INTERFACE_SUBTYPE_FEATURE_UNIT; + case 0x07: return UAC_INTERFACE_SUBTYPE_EFFECT_UNIT; + case 0x08: return UAC_INTERFACE_SUBTYPE_PROCESSING_UNIT; + case 0x09: return UAC_INTERFACE_SUBTYPE_EXTENSION_UNIT; + case 0x0a: return UAC_INTERFACE_SUBTYPE_CLOCK_SOURCE; + case 0x0b: return UAC_INTERFACE_SUBTYPE_CLOCK_SELECTOR; + case 0x0c: return UAC_INTERFACE_SUBTYPE_CLOCK_MULTIPLIER; + case 0x0d: return UAC_INTERFACE_SUBTYPE_SAMPLE_RATE_CONVERTER; + } + break; No "default" handler saying we don't know what the type is? I added a default in the outer switch, and some comments to explain things a little better. Basically, anything that reached a default required no mapping, and would use the original input value for sub-type. Otherwise, looks great, thanks for this. greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- Michael Drake http://www.codethink.co.uk/ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.ke
Re: [PATCH v1 2/8] lsusb: Add declarative definitions for UAC1 and UAC2 descriptors.
On 05/12/17 16:37, Greg KH wrote: On Tue, Dec 05, 2017 at 04:14:25PM +, Michael Drake wrote: These descriptor definitions descibe how raw descriptor data should be interpreted. --- desc-defs.c | 647 desc-defs.h | 153 ++ 2 files changed, 800 insertions(+) Don't we need to add the file to the build here? As noted in the other patch review, its added to the build in the patch that update lsusb to use it. create mode 100644 desc-defs.c create mode 100644 desc-defs.h diff --git a/desc-defs.c b/desc-defs.c new file mode 100644 index 000..6bc558e --- /dev/null +++ b/desc-defs.c @@ -0,0 +1,647 @@ +/*/ + +/* + * desc-defs.c -- USB descriptor definitions + * + * Copyright (C) 2017 Michael Drake + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +/*/ Wow that's a large boiler plate of a header. Not your fault, you are copying lsusb.c, I'll fix that up later :) Yes, I actually copied the boiler plate from names.{c|h}, since its an existing module used by lsusb.c. + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif Why #ifdef this? Purely because names.c did. I've removed the #ifdef and it still builds. + +#include +#include +#include + +#include "desc-defs.h" + +static const char * const uac2_interface_header_bmcontrols[] = { + "Latency control", + NULL +}; All of these arrays have to be in the specific order, right? Do we need a comment somewhere saying this? Yes, I've added designated initializers and comments to make this clearer. +const struct desc * const desc_audio_ac_processing_unit[3] = { + desc_audio_1_ac_processing_unit, + desc_audio_2_ac_processing_unit, + NULL, /* UAC3 not implemented yet */ +}; + + +/** UAC1: 4.3.2.5 Feature Unit Descriptor; Table 4-7. */ +static const struct desc desc_audio_1_ac_feature_unit[] = { + { .field = "bUnitID", .size = 1,.type = DESC_NUMBER }, + { .field = "bSourceID",.size = 1,.type = DESC_CONSTANT }, + { .field = "bControlSize", .size = 1,.type = DESC_NUMBER }, + { .field = "bmaControls", .size_field = "bControlSize", .type = DESC_BMCONTROL_1, + .bmcontrol = uac_feature_unit_bmcontrols, .array = { .array = true } }, + { .field = "iFeature", .size = 1,.type = DESC_STR_DESC_INDEX }, + { .field = NULL } +}; +/** UAC2: 4.7.2.8 Feature Unit Descriptor; Table 4-13. */ +static const struct desc desc_audio_2_ac_feature_unit[] = { + { .field = "bUnitID", .size = 1, .type = DESC_NUMBER }, + { .field = "bSourceID", .size = 1, .type = DESC_CONSTANT }, + { .field = "bmaControls", .size = 4, .type = DESC_BMCONTROL_2, + .bmcontrol = uac_feature_unit_bmcontrols, .array = { .array = true } }, + { .field = "iFeature",.size = 1, .type = DESC_STR_DESC_INDEX }, + { .field = NULL } +}; +const struct desc * const desc_audio_ac_feature_unit[3] = { + desc_audio_1_ac_feature_unit, + desc_audio_2_ac_feature_unit, + NULL, /* UAC3 not implemented yet */ +}; + + Just put 1 blank line between everything, makes it simpler to manage over time and to read :) Done. +/** UAC1: 4.3.2.7 Extension Unit Descriptor; Table 4-15. */ +static const struct desc desc_audio_1_ac_extension_unit[] = { + { .field = "bUnitID",.size = 1, .type = DESC_NUMBER }, + { .field = "wExtensionCode", .size = 2, .type = DESC_CONSTANT }, + { .field = "bNrInPins", .size = 1, .type = DESC_NUMBER }, + { .field = "baSourceID", .size = 1, .type = DESC_NUMBER, + .array = { .array = true, .length_field1 = "bNrInPins" } }, + { .field = "bNrChannels",.size = 1, .type = DESC_NUMBER }, + { .field = "wChannelConfig", .size = 2, .type = DESC_BITMAP_STRINGS, + .bitmap_strings = { .strings = uac1_channel_names, .count = 12 } }, + { .field = "iChannelNames&quo
Re: [PATCH v1 3/8] lsusb: Add code to dump descriptor data using descriptor definition.
On 05/12/17 16:38, Greg KH wrote: On Tue, Dec 05, 2017 at 04:14:26PM +, Michael Drake wrote: This adds a new way of dumping descriptors. It takes the descriptor data to be dumped, and a descriptor definition as input. The descriptor definition takes the form of a NULL terminated array of descriptor field definitions. These definitions describe how the raw descriptor data buffer should be interpreted. Thus the knowledge of how to interpret a descriptor buffer is separate from the shared code that renders the descriptor dump. This has two advantages: 1. The code for dumping descriptors is common, so the output is easy to keep consistent. It is also consistent and thorough in its handling of insufficient descriptor data buffer, and junk data at the end of a descriptor. 2. It is easy to add support for new descriptors, since they are now simple definitions that resemble the tables in the USB specifications. --- desc-dump.c | 550 desc-dump.h | 64 +++ 2 files changed, 614 insertions(+) create mode 100644 desc-dump.c create mode 100644 desc-dump.h Same meta-comments as on patch 2 apply here :) Removed the #ifdef around #include "config.h", and removed the instances of 2 consecutive blanks. -- Michael Drake http://www.codethink.co.uk/ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v1 5/8] lsusb: Add descriptor definitions for UAC3.
On 05/12/17 16:39, Greg KH wrote: On Tue, Dec 05, 2017 at 04:14:28PM +, Michael Drake wrote: --- desc-defs.c | 277 desc-defs.h | 3 + desc-dump.c | 5 ++ 3 files changed, 270 insertions(+), 15 deletions(-) We need some kind of changelog text here to describe what is going on. I'm happy to do this, however I'm unclear on exactly what needs doing. (Ditto for the comments on patches 6, 7, and 8). The ChangeLog file has not been updated since an entry in 2009 which I read as saying to stop updating that file: * switched over to git, look at the changelog there instead of here. From that I assumed it meant that the `git log` would become the ChangeLog from that point. The other relevant file is NEWS, and it looks, from history, like that's only updated for releases. Cheers, -- Michael Drake http://www.codethink.co.uk/ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v1 0/8] lsusb: Add initial support for USB Audio Class 3
On 05/12/17 16:32, Greg KH wrote: On Tue, Dec 05, 2017 at 04:14:23PM +, Michael Drake wrote: This adds a new way of dumping descriptors, which splits the knowledge of how to interpret descriptor data from the actual dumping. This has two advantages: 1. It is easy to add support for new descriptors, since they are now simple definitions that resemble the tables in the USB specifications. 2. The code for dumping descriptors is common, so the output is easy to keep consistent. It is also consistent and thorough in its handling of insufficient descriptor data buffer, and junk data at the end of a descriptor. UAC1 and UAC2 are converted to use the new mechanism, initial support for UAC3 is added. Finally, support for the USB3 BOS Configuration Summary Descriptor is added. This was previously opened as a github pull request here: https://github.com/gregkh/usbutils/pull/61 Overall this looks great, I only have a few minor formatting and other procedural issues with the patches. I'll respond to them individually as to what could be fixed up for a resend. Thanks for your review! I'll submit a v2 when I know what to do about the ChangeLog. Cheers, -- Michael Drake http://www.codethink.co.uk/ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/8] lsusb: Add initial support for USB Audio Class 3
This adds a new way of dumping descriptors, which splits the knowledge of how to interpret descriptor data from the actual dumping. This has two advantages: 1. It is easy to add support for new descriptors, since they are now simple definitions that resemble the tables in the USB specifications. 2. The code for dumping descriptors is common, so the output is easy to keep consistent. It is also consistent and thorough in its handling of insufficient descriptor data buffer, and junk data at the end of a descriptor. UAC1 and UAC2 are converted to use the new mechanism, initial support for UAC3 is added. Finally, support for the USB3 BOS Configuration Summary Descriptor is added. This was previously opened as a github pull request here: https://github.com/gregkh/usbutils/pull/61 Changes since v2: - Signed off commits. - Added detail sections to all commit messages. - Single blank lines between things. - Improved comments. - Designated initilisers for arrays of bmControls bit names. - Added default to subtype mapping switch. - Fixed subtype mapping commit to make use of the enum in the switch that switches on subtype. - Removed redundant #ifdef around #include "config.h" - Fixed use of magic numbers in wFormatTag snowflake renderer. Michael Drake (8): lsusb: Split subtype mapping out of AudioControl interface handling. lsusb: Add declarative definitions for UAC1 and UAC2 descriptors. lsusb: Add code to dump descriptor data using descriptor definition. lsusb: Switch to descriptor-definition based dump for UAC1 and UAC2. lsusb: Add descriptor definitions for UAC3. lsusb: Add initial support for USB Audio Device Class 3. lsusb: Add descriptor definition for USB3 BOS Configuration Summary. lsusb: Dump USB3 BOS Configuration Summary Descriptor. Makefile.am | 2 + desc-defs.c | 995 desc-defs.h | 159 ++ desc-dump.c | 546 + desc-dump.h | 64 lsusb.c | 887 ++--- 6 files changed, 1923 insertions(+), 730 deletions(-) create mode 100644 desc-defs.c create mode 100644 desc-defs.h create mode 100644 desc-dump.c create mode 100644 desc-dump.h -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/8] lsusb: Split subtype mapping out of AudioControl interface handling.
UAC1 and UAC2 have different different meanings for the same subtype value. This splits the subtype mapping out. Signed-off-by: Michael Drake --- lsusb.c | 128 +++- 1 file changed, 94 insertions(+), 34 deletions(-) diff --git a/lsusb.c b/lsusb.c index f611f2e..26df98e 100644 --- a/lsusb.c +++ b/lsusb.c @@ -1000,8 +1000,87 @@ static const char * const chconfig_uac2[] = { "Back Left of Center (BLC)", "Back Right of Center (BRC)" }; +/* USB Audio Class subtypes */ +enum uac_interface_subtype { + UAC_INTERFACE_SUBTYPE_AC_DESCRIPTOR_UNDEFINED = 0x00, + UAC_INTERFACE_SUBTYPE_HEADER = 0x01, + UAC_INTERFACE_SUBTYPE_INPUT_TERMINAL = 0x02, + UAC_INTERFACE_SUBTYPE_OUTPUT_TERMINAL = 0x03, + UAC_INTERFACE_SUBTYPE_EXTENDED_TERMINAL = 0x04, + UAC_INTERFACE_SUBTYPE_MIXER_UNIT = 0x05, + UAC_INTERFACE_SUBTYPE_SELECTOR_UNIT = 0x06, + UAC_INTERFACE_SUBTYPE_FEATURE_UNIT= 0x07, + UAC_INTERFACE_SUBTYPE_EFFECT_UNIT = 0x08, + UAC_INTERFACE_SUBTYPE_PROCESSING_UNIT = 0x09, + UAC_INTERFACE_SUBTYPE_EXTENSION_UNIT = 0x0a, + UAC_INTERFACE_SUBTYPE_CLOCK_SOURCE= 0x0b, + UAC_INTERFACE_SUBTYPE_CLOCK_SELECTOR = 0x0c, + UAC_INTERFACE_SUBTYPE_CLOCK_MULTIPLIER= 0x0d, + UAC_INTERFACE_SUBTYPE_SAMPLE_RATE_CONVERTER = 0x0e, + UAC_INTERFACE_SUBTYPE_CONNECTORS = 0x0f, + UAC_INTERFACE_SUBTYPE_POWER_DOMAIN= 0x10, +}; + +/* + * UAC1, and UAC2 define bDescriptorSubtype differently for the + * AudioControl interface, so we need to do some ugly remapping: + * + * val | UAC1| UAC2 + * -|-|-- + * 0x00 | AC UNDEFINED| AC UNDEFINED + * 0x01 | HEADER | HEADER + * 0x02 | INPUT_TERMINAL | INPUT_TERMINAL + * 0x03 | OUTPUT_TERMINAL | OUTPUT_TERMINAL + * 0x04 | MIXER_UNIT | MIXER_UNIT + * 0x05 | SELECTOR_UNIT | SELECTOR_UNIT + * 0x06 | FEATURE_UNIT| FEATURE_UNIT + * 0x07 | PROCESSING_UNIT | EFFECT_UNIT + * 0x08 | EXTENSION_UNIT | PROCESSING_UNIT + * 0x09 | - | EXTENSION_UNIT + * 0x0a | - | CLOCK_SOURCE + * 0x0b | - | CLOCK_SELECTOR + * 0x0c | - | CLOCK_MULTIPLIER + * 0x0d | - | SAMPLE_RATE_CONVERTER + */ +static enum uac_interface_subtype get_uac_interface_subtype(unsigned char c, int protocol) +{ + switch (protocol) { + case USB_AUDIO_CLASS_1: + switch(c) { + case 0x04: return UAC_INTERFACE_SUBTYPE_MIXER_UNIT; + case 0x05: return UAC_INTERFACE_SUBTYPE_SELECTOR_UNIT; + case 0x06: return UAC_INTERFACE_SUBTYPE_FEATURE_UNIT; + case 0x07: return UAC_INTERFACE_SUBTYPE_PROCESSING_UNIT; + case 0x08: return UAC_INTERFACE_SUBTYPE_EXTENSION_UNIT; + } + break; + case USB_AUDIO_CLASS_2: + switch(c) { + case 0x04: return UAC_INTERFACE_SUBTYPE_MIXER_UNIT; + case 0x05: return UAC_INTERFACE_SUBTYPE_SELECTOR_UNIT; + case 0x06: return UAC_INTERFACE_SUBTYPE_FEATURE_UNIT; + case 0x07: return UAC_INTERFACE_SUBTYPE_EFFECT_UNIT; + case 0x08: return UAC_INTERFACE_SUBTYPE_PROCESSING_UNIT; + case 0x09: return UAC_INTERFACE_SUBTYPE_EXTENSION_UNIT; + case 0x0a: return UAC_INTERFACE_SUBTYPE_CLOCK_SOURCE; + case 0x0b: return UAC_INTERFACE_SUBTYPE_CLOCK_SELECTOR; + case 0x0c: return UAC_INTERFACE_SUBTYPE_CLOCK_MULTIPLIER; + case 0x0d: return UAC_INTERFACE_SUBTYPE_SAMPLE_RATE_CONVERTER; + } + break; + default: + /* Unknown protocol */ + break; + } + + /* If the protocol was unknown, or the value was not known to require +* mapping, just return it unchanged. */ + return c; +} + static void dump_audiocontrol_interface(libusb_device_handle *dev, const unsigned char *buf, int protocol) { + enum uac_interface_subtype subtype; static const char * const chconfig[] = { "Left Front (L)", "Right Front (R)", "Center Front (C)", "Low Frequency Enhancement (LFE)", "Left Surround (LS)", "Right Surround (RS)", "Left of Center (LC)", "Right of Center (RC)", @@ -1010,7 +1089,7 @@ static void dump_audiocontrol_interface(libusb_device_handle *dev, const unsigne static const char * const clock_source_attrs[] = { "External", "Internal fixed", "Internal variable", "Internal programmable" }; - unsigned int i, chcfg, j, k, N, termt, subtype; +
[PATCH v2 6/8] lsusb: Add initial support for USB Audio Device Class 3.
Make lsusb display verbose descriptor output for USB Audio Devide Class 3 devices. The descriptors have changed for version 3 of the protocol. Signed-off-by: Michael Drake --- lsusb.c | 52 ++-- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/lsusb.c b/lsusb.c index fb5e6ee..e3eb423 100644 --- a/lsusb.c +++ b/lsusb.c @@ -106,6 +106,11 @@ #define USB_AUDIO_CLASS_2 0x20 #endif +/* USB DCD for Audio Devices Release 3.0: Section A.6, pp139 */ +#ifndef USB_AUDIO_CLASS_3 +#define USB_AUDIO_CLASS_3 0x30 +#endif + #ifndef USB_VIDEO_PROTOCOL_15 #define USB_VIDEO_PROTOCOL_15 0x01 #endif @@ -890,11 +895,12 @@ static void dump_audio_subtype(libusb_device_handle *dev, int protocol, unsigned int indent) { - static const char * const strings[] = { "UAC1", "UAC2" }; + static const char * const strings[] = { "UAC1", "UAC2", "UAC3" }; unsigned int idx = 0; switch (protocol) { case USB_AUDIO_CLASS_2: idx = 1; break; + case USB_AUDIO_CLASS_3: idx = 2; break; } printf("(%s)\n", name); @@ -932,25 +938,28 @@ enum uac_interface_subtype { }; /* - * UAC1, and UAC2 define bDescriptorSubtype differently for the + * UAC1, UAC2, and UAC3 define bDescriptorSubtype differently for the * AudioControl interface, so we need to do some ugly remapping: * - * val | UAC1| UAC2 - * -|-|-- - * 0x00 | AC UNDEFINED| AC UNDEFINED - * 0x01 | HEADER | HEADER - * 0x02 | INPUT_TERMINAL | INPUT_TERMINAL - * 0x03 | OUTPUT_TERMINAL | OUTPUT_TERMINAL - * 0x04 | MIXER_UNIT | MIXER_UNIT - * 0x05 | SELECTOR_UNIT | SELECTOR_UNIT - * 0x06 | FEATURE_UNIT| FEATURE_UNIT - * 0x07 | PROCESSING_UNIT | EFFECT_UNIT - * 0x08 | EXTENSION_UNIT | PROCESSING_UNIT - * 0x09 | - | EXTENSION_UNIT - * 0x0a | - | CLOCK_SOURCE - * 0x0b | - | CLOCK_SELECTOR - * 0x0c | - | CLOCK_MULTIPLIER - * 0x0d | - | SAMPLE_RATE_CONVERTER + * val | UAC1| UAC2 | UAC3 + * -|-|---|- + * 0x00 | AC UNDEFINED| AC UNDEFINED | AC UNDEFINED + * 0x01 | HEADER | HEADER| HEADER + * 0x02 | INPUT_TERMINAL | INPUT_TERMINAL| INPUT_TERMINAL + * 0x03 | OUTPUT_TERMINAL | OUTPUT_TERMINAL | OUTPUT_TERMINAL + * 0x04 | MIXER_UNIT | MIXER_UNIT| EXTENDED_TERMINAL + * 0x05 | SELECTOR_UNIT | SELECTOR_UNIT | MIXER_UNIT + * 0x06 | FEATURE_UNIT| FEATURE_UNIT | SELECTOR_UNIT + * 0x07 | PROCESSING_UNIT | EFFECT_UNIT | FEATURE_UNIT + * 0x08 | EXTENSION_UNIT | PROCESSING_UNIT | EFFECT_UNIT + * 0x09 | - | EXTENSION_UNIT| PROCESSING_UNIT + * 0x0a | - | CLOCK_SOURCE | EXTENSION_UNIT + * 0x0b | - | CLOCK_SELECTOR| CLOCK_SOURCE + * 0x0c | - | CLOCK_MULTIPLIER | CLOCK_SELECTOR + * 0x0d | - | SAMPLE_RATE_CONVERTER | CLOCK_MULTIPLIER + * 0x0e | - | - | SAMPLE_RATE_CONVERTER + * 0x0f | - | - | CONNECTORS + * 0x10 | - | - | POWER_DOMAIN */ static enum uac_interface_subtype get_uac_interface_subtype(unsigned char c, int protocol) { @@ -978,6 +987,9 @@ static enum uac_interface_subtype get_uac_interface_subtype(unsigned char c, int case 0x0d: return UAC_INTERFACE_SUBTYPE_SAMPLE_RATE_CONVERTER; } break; + case USB_AUDIO_CLASS_3: + /* No mapping required. */ + break; default: /* Unknown protocol */ break; @@ -1057,6 +1069,10 @@ static void dump_audiocontrol_interface(libusb_device_handle *dev, const unsigne dump_audio_subtype(dev, "EFFECT_UNIT", desc_audio_ac_effect_unit, buf, protocol, 4); break; + case UAC_INTERFACE_SUBTYPE_POWER_DOMAIN: + dump_audio_subtype(dev, "POWER_DOMAIN", desc_audio_ac_power_domain, buf, protocol, 4); + break; + default: printf("(unknown)\n" "Invalid desc subtype:"); -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 7/8] lsusb: Add descriptor definition for USB3 BOS Configuration Summary.
Add definition of the BOS configuration summary descriptor, as specified by the USB 3 standard, to the descriptor definitions for lsusb. Signed-off-by: Michael Drake --- desc-defs.c | 15 +++ desc-defs.h | 3 +++ 2 files changed, 18 insertions(+) diff --git a/desc-defs.c b/desc-defs.c index 590f34a..9d3e312 100644 --- a/desc-defs.c +++ b/desc-defs.c @@ -978,3 +978,18 @@ const struct desc * const desc_audio_as_isochronous_audio_data_endpoint[3] = { desc_audio_2_as_isochronous_audio_data_endpoint, desc_audio_3_as_isochronous_audio_data_endpoint, }; + +/** USB3: 9.6.2.7 Configuration Summary Descriptor; Table 9-21. */ +const struct desc desc_usb3_dc_configuration_summary[] = { + { .field = "bLength", .size = 1, .type = DESC_NUMBER }, + { .field = "bDescriptorType", .size = 1, .type = DESC_CONSTANT }, + { .field = "bDevCapabilityType", .size = 1, .type = DESC_NUMBER }, + { .field = "bcdVersion", .size = 2, .type = DESC_BCD }, + { .field = "bClass", .size = 1, .type = DESC_NUMBER }, + { .field = "bSubClass", .size = 1, .type = DESC_NUMBER }, + { .field = "bProtocol", .size = 1, .type = DESC_NUMBER }, + { .field = "bConfigurationCount", .size = 1, .type = DESC_NUMBER }, + { .field = "bConfigurationIndex", .size = 1, .type = DESC_NUMBER, + .array = { .array = true, .length_field1 = "bConfigurationCount" } }, + { .field = NULL } +}; diff --git a/desc-defs.h b/desc-defs.h index d88ebd8..2c8f1b3 100644 --- a/desc-defs.h +++ b/desc-defs.h @@ -151,6 +151,9 @@ extern const struct desc * const desc_audio_ac_sample_rate_converter[3]; extern const struct desc * const desc_audio_as_interface[3]; extern const struct desc * const desc_audio_as_isochronous_audio_data_endpoint[3]; +/* Device Capability (DC) descriptor definitions */ +extern const struct desc desc_usb3_dc_configuration_summary[]; + /* -- */ #endif /* _DESC_DEFS_H */ -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 5/8] lsusb: Add descriptor definitions for UAC3.
These descriptor definitions descibe how raw descriptor data should be interpreted. Signed-off-by: Michael Drake --- desc-defs.c | 338 desc-defs.h | 3 + desc-dump.c | 5 + 3 files changed, 303 insertions(+), 43 deletions(-) diff --git a/desc-defs.c b/desc-defs.c index a01aae2..590f34a 100644 --- a/desc-defs.c +++ b/desc-defs.c @@ -79,11 +79,20 @@ static const struct desc desc_audio_2_ac_header[] = { { .field = NULL } }; +/** UAC3: 4.5.2 Class-Specific AC Interface Descriptor; Table 4-15. */ +static const struct desc desc_audio_3_ac_header[] = { + { .field = "bCategory",.size = 1, .type = DESC_CONSTANT }, + { .field = "wTotalLength", .size = 2, .type = DESC_NUMBER }, + { .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2, + .bmcontrol = uac2_interface_header_bmcontrols }, + { .field = NULL } +}; + /** AudioControl Header descriptor definitions for the three Audio Device Class protocols */ const struct desc * const desc_audio_ac_header[3] = { desc_audio_1_ac_header, desc_audio_2_ac_header, - NULL, /* UAC3 not implemented yet */ + desc_audio_3_ac_header, }; /** UAC2: 4.7.2.10 Effect Unit Descriptor; Table 4-15. */ @@ -97,11 +106,22 @@ static const struct desc desc_audio_2_ac_effect_unit[] = { { .field = NULL } }; +/** UAC3: 4.5.2.9 Effect Unit Descriptor; Table 4-33. */ +static const struct desc desc_audio_3_ac_effect_unit[] = { + { .field = "bUnitID", .size = 1, .type = DESC_NUMBER }, + { .field = "wEffectType", .size = 2, .type = DESC_CONSTANT }, + { .field = "bSourceID",.size = 1, .type = DESC_CONSTANT }, + { .field = "bmaControls", .size = 4, .type = DESC_BITMAP, + .array = { .array = true } }, + { .field = "wEffectsDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID }, + { .field = NULL } +}; + /** Effect Unit descriptor definitions for the three Audio Device Class protocols */ const struct desc * const desc_audio_ac_effect_unit[3] = { NULL, /* UAC1 not supported */ desc_audio_2_ac_effect_unit, - NULL, /* UAC3 not implemented yet */ + desc_audio_3_ac_effect_unit, }; /** UAC2 Input Terminal bmControls; Human readable bit meanings. */ @@ -115,6 +135,16 @@ static const char * const uac2_input_term_bmcontrols[] = { [6] = NULL }; +/** UAC3 Input Terminal bmControls; Human readable bit meanings. */ +static const char * const uac3_input_term_bmcontrols[] = { + [0] = "Insertion", + [1] = "Overload", + [2] = "Underflow", + [3] = "Overflow", + [4] = "Underflow", + [5] = NULL +}; + /** UAC1: 4.3.2.1 Input Terminal Descriptor; Table 4-3. */ static const struct desc desc_audio_1_ac_input_terminal[] = { { .field = "bTerminalID",.size = 1, .type = DESC_NUMBER }, @@ -144,11 +174,26 @@ static const struct desc desc_audio_2_ac_input_terminal[] = { { .field = NULL } }; +/** UAC3: 4.5.2.1 Input Terminal Descriptor; Table 4-16. */ +static const struct desc desc_audio_3_ac_input_terminal[] = { + { .field = "bTerminalID",.size = 1, .type = DESC_NUMBER }, + { .field = "wTerminalType", .size = 2, .type = DESC_TERMINAL_STR }, + { .field = "bAssocTerminal", .size = 1, .type = DESC_NUMBER }, + { .field = "bCSourceID", .size = 1, .type = DESC_NUMBER }, + { .field = "bmControls", .size = 4, .type = DESC_BMCONTROL_2, + .bmcontrol = uac3_input_term_bmcontrols }, + { .field = "wClusterDescrID",.size = 2, .type = DESC_NUMBER }, + { .field = "wExTerminalDescrID", .size = 2, .type = DESC_NUMBER }, + { .field = "wConnectorsDescrID", .size = 2, .type = DESC_NUMBER }, + { .field = "wTerminalDescrStr", .size = 2, .type = DESC_CS_STR_DESC_ID }, + { .field = NULL } +}; + /** Input Terminal descriptor definitions for the three Audio Device Class protocols */ const struct desc * const desc_audio_ac_input_terminal[3] = { desc_audio_1_ac_input_terminal, desc_audio_2_ac_input_terminal, - NULL, /* UAC3 not implemented yet */ + desc_audio_3_ac_input_terminal, }; /** UAC2 Output Terminal bmControls; Human readable bit meanings. */ @@ -161,6 +206,15 @@ static const char * const uac2_output_term_bmcontrols[] = { [5] = NULL }; +/** UAC3 Output Terminal bmControls; Human readable bit meanings. */ +static const char * const uac3_output_term_bmcontrols[] = { + [0] = "Insertion", + [1] = "Overload", + [2] = "Underflow", + [3] = "Overflow
[PATCH v2 3/8] lsusb: Add code to dump descriptor data using descriptor definition.
This adds a new way of dumping descriptors. It takes the descriptor data to be dumped, and a descriptor definition as input. The descriptor definition takes the form of a NULL terminated array of descriptor field definitions. These definitions describe how the raw descriptor data buffer should be interpreted. Thus the knowledge of how to interpret a descriptor buffer is separate from the shared code that renders the descriptor dump. This has two advantages: 1. The code for dumping descriptors is common, so the output is easy to keep consistent. It is also consistent and thorough in its handling of insufficient descriptor data buffer, and junk data at the end of a descriptor. 2. It is easy to add support for new descriptors, since they are now simple definitions that resemble the tables in the USB specifications. Signed-off-by: Michael Drake --- desc-dump.c | 541 desc-dump.h | 64 +++ 2 files changed, 605 insertions(+) create mode 100644 desc-dump.c create mode 100644 desc-dump.h diff --git a/desc-dump.c b/desc-dump.c new file mode 100644 index 000..711889b --- /dev/null +++ b/desc-dump.c @@ -0,0 +1,541 @@ +/*/ + +/* + * desc-dump.c -- USB descriptor dumping + * + * Copyright (C) 2017 Michael Drake + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +/*/ + +#include "config.h" + +#include +#include +#include +#include +#include + +#include + +#include "desc-defs.h" +#include "desc-dump.h" +#include "usbmisc.h" +#include "names.h" + +/** + * Print a description of a bmControls field value, using a given string array. + * + * Handles the DESC_BMCONTROL_1 and DESC_BMCONTROL_2 field types. The former + * is one bit per string, and the latter is 2 bits per string, with the + * additional bit specifying whether the control is read-only. + * + * \param[in] bmcontrols The value to dump a human-readable representation of. + * \param[in] strings Array of human-readable strings, must be NULL terminated. + * \param[in] typeThe type of the value in bmcontrols. + * \param[in] indent The current indent level. + */ +static void desc_bmcontrol_dump( + unsigned long long bmcontrols, + const char * const * strings, + enum desc_type type, + unsigned int indent) +{ + static const char * const setting[] = { + "read-only", + "ILLEGAL VALUE (0b10)", + "read/write" + }; + unsigned int count = 0; + unsigned int control; + + assert((type == DESC_BMCONTROL_1) || + (type == DESC_BMCONTROL_2)); + + while (strings[count] != NULL) { + if (strings[0] != '\0') { + if (type == DESC_BMCONTROL_1) { + if ((strings[count][0] != '\0') && + (bmcontrols >> count) & 0x1) { + printf("%*s%s Control\n", + indent * 2, "", + strings[count]); + } + } else { + control = (bmcontrols >> (count * 2)) & 0x3; + if ((strings[count][0] != '\0') && control) { + printf("%*s%s Control (%s)\n", + indent * 2, "", + strings[count], + setting[control-1]); + } + } + } + count++; + } +} + +/** + * Read N bytes from descriptor data buffer into a value. + * + * Only supports values of up to 8 bytes. + * + * \param[in] buf Buffer containing the bytes to read. + * \param[in] offset Offset in buffer to start reading bytes from. + * \param[in] bytes Number of bytes to read. + * \return Value contained within the given bytes.
[PATCH v2 2/8] lsusb: Add declarative definitions for UAC1 and UAC2 descriptors.
These descriptor definitions descibe how raw descriptor data should be interpreted. Signed-off-by: Michael Drake --- desc-defs.c | 728 desc-defs.h | 153 + 2 files changed, 881 insertions(+) create mode 100644 desc-defs.c create mode 100644 desc-defs.h diff --git a/desc-defs.c b/desc-defs.c new file mode 100644 index 000..a01aae2 --- /dev/null +++ b/desc-defs.c @@ -0,0 +1,728 @@ +/*/ + +/* + * desc-defs.c -- USB descriptor definitions + * + * Copyright (C) 2017 Michael Drake + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ + +/*/ + +#include "config.h" + +#include +#include +#include + +#include "desc-defs.h" + +/** Macro for computing number of elements in array. */ +#define ARRAY_LEN(a) ((sizeof(a)) / (sizeof(a[0]))) + +/** USB Audio Device Class 1 Channel Names. (Note: Order matters.) */ +static const char * const uac1_channel_names[] = { + "Left Front (L)", "Right Front (R)", "Center Front (C)", + "Low Frequency Enhancement (LFE)", "Left Surround (LS)", + "Right Surround (RS)", "Left of Center (LC)", "Right of Center (RC)", + "Surround (S)", "Side Left (SL)", "Side Right (SR)", "Top (T)" +}; + +/** USB Audio Device Class 2 Channel Names. (Note: Order matters.) */ +static const char * const uac2_channel_names[] = { + "Front Left (FL)", "Front Right (FR)", "Front Center (FC)", + "Low Frequency Effects (LFE)", "Back Left (BL)", "Back Right (BR)", + "Front Left of Center (FLC)", "Front Right of Center (FRC)", + "Back Center (BC)", "Side Left (SL)", "Side Right (SR)", + "Top Center (TC)", "Top Front Left (TFL)", "Top Front Center (TFC)", + "Top Front Right (TFR)", "Top Back Left (TBL)", "Top Back Center (TBC)", + "Top Back Right (TBR)", "Top Front Left of Center (TFLC)", + "Top Front Right of Center (TFRC)", "Left Low Frequency Effects (LLFE)", + "Right Low Frequency Effects (RLFE)", "Top Side Left (TSL)", + "Top Side Right (TSR)", "Bottom Center (BC)", + "Back Left of Center (BLC)", "Back Right of Center (BRC)" +}; + +/** Audio Control Interface Header bmControls; Human readable bit meanings. */ +static const char * const uac2_interface_header_bmcontrols[] = { + [0] = "Latency control", + [1] = NULL +}; + +/** UAC1: 4.3.2 Class-Specific AC Interface Descriptor; Table 4-2. */ +static const struct desc desc_audio_1_ac_header[] = { + { .field = "bcdADC",.size = 2, .type = DESC_BCD }, + { .field = "wTotalLength", .size = 2, .type = DESC_CONSTANT }, + { .field = "bInCollection", .size = 1, .type = DESC_CONSTANT }, + { .field = "baInterfaceNr", .size = 1, .type = DESC_NUMBER, + .array = { .array = true } }, + { .field = NULL } +}; + +/** UAC2: 4.7.2 Class-Specific AC Interface Descriptor; Table 4-5. */ +static const struct desc desc_audio_2_ac_header[] = { + { .field = "bcdADC", .size = 2, .type = DESC_BCD }, + { .field = "bCategory",.size = 1, .type = DESC_CONSTANT }, + { .field = "wTotalLength", .size = 2, .type = DESC_NUMBER }, + { .field = "bmControls", .size = 1, .type = DESC_BMCONTROL_2, + .bmcontrol = uac2_interface_header_bmcontrols }, + { .field = NULL } +}; + +/** AudioControl Header descriptor definitions for the three Audio Device Class protocols */ +const struct desc * const desc_audio_ac_header[3] = { + desc_audio_1_ac_header, + desc_audio_2_ac_header, + NULL, /* UAC3 not implemented yet */ +}; + +/** UAC2: 4.7.2.10 Effect Unit Descriptor; Table 4-15. */ +static const struct desc desc_audio_2_ac_effect_unit[] = { + { .field = "bUnitID", .size = 1, .type = DESC_NUMBER }, + { .field
[PATCH v2 4/8] lsusb: Switch to descriptor-definition based dump for UAC1 and UAC2.
This gives us more consistency in handling of incorrect descriptor buffer lengths, and improves whitespace/alignment consistency. Signed-off-by: Michael Drake --- Makefile.am | 2 + lsusb.c | 751 2 files changed, 50 insertions(+), 703 deletions(-) diff --git a/Makefile.am b/Makefile.am index 117e94b..46fd7b5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -19,6 +19,8 @@ lsusb_SOURCES = \ lsusb.c lsusb.h \ lsusb-t.c \ list.h \ + desc-defs.c desc-defs.h \ + desc-dump.c desc-dump.h \ names.c names.h \ usb-spec.h \ usbmisc.c usbmisc.h diff --git a/lsusb.c b/lsusb.c index 26df98e..fb5e6ee 100644 --- a/lsusb.c +++ b/lsusb.c @@ -31,6 +31,7 @@ #include #include #include +#include #ifdef HAVE_BYTESWAP_H #include @@ -42,6 +43,8 @@ #include "lsusb.h" #include "names.h" #include "usbmisc.h" +#include "desc-defs.h" +#include "desc-dump.h" #include @@ -159,7 +162,7 @@ static void dump_videostreaming_interface(const unsigned char *buf); static void dump_dfu_interface(const unsigned char *buf); static char *dump_comm_descriptor(libusb_device_handle *dev, const unsigned char *buf, char *indent); static void dump_hid_device(libusb_device_handle *dev, const struct libusb_interface_descriptor *interface, const unsigned char *buf); -static void dump_audiostreaming_endpoint(const unsigned char *buf, int protocol); +static void dump_audiostreaming_endpoint(libusb_device_handle *dev, const unsigned char *buf, int protocol); static void dump_midistreaming_endpoint(const unsigned char *buf); static void dump_hub(const char *prefix, const unsigned char *p, int tt_type); static void dump_ccid_device(const unsigned char *buf); @@ -626,7 +629,7 @@ static void dump_altsetting(libusb_device_handle *dev, const struct libusb_inter case USB_DT_CS_ENDPOINT: switch (interface->bInterfaceSubClass) { case 2: - dump_audiostreaming_endpoint(buf, interface->bInterfaceProtocol); + dump_audiostreaming_endpoint(dev, buf, interface->bInterfaceProtocol); break; default: goto dump; @@ -756,7 +759,7 @@ static void dump_endpoint(libusb_device_handle *dev, const struct libusb_interfa switch (buf[1]) { case USB_DT_CS_ENDPOINT: if (interface->bInterfaceClass == 1 && interface->bInterfaceSubClass == 2) - dump_audiostreaming_endpoint(buf, interface->bInterfaceProtocol); + dump_audiostreaming_endpoint(dev, buf, interface->bInterfaceProtocol); else if (interface->bInterfaceClass == 1 && interface->bInterfaceSubClass == 3) dump_midistreaming_endpoint(buf); break; @@ -880,125 +883,32 @@ static void dump_unit(unsigned int data, unsigned int len) * Audio Class descriptor dump */ -struct bmcontrol { - const char *name; - unsigned int bit; -}; - -static const struct bmcontrol uac2_interface_header_bmcontrols[] = { - { "Latency control",0 }, - { NULL } -}; - -static const struct bmcontrol uac_fu_bmcontrols[] = { - { "Mute", 0 }, - { "Volume", 1 }, - { "Bass", 2 }, - { "Mid",3 }, - { "Treble", 4 }, - { "Graphic Equalizer", 5 }, - { "Automatic Gain", 6 }, - { "Delay", 7 }, - { "Bass Boost", 8 }, - { "Loudness", 9 }, - { "Input gain", 10 }, - { "Input gain pad", 11 }, - { "Phase inverter", 12 }, - { NULL } -}; - -static const struct bmcontrol uac2_input_term_bmcontrols[] = { - { "Copy Protect", 0 }, - { "Connector", 1 }, - { "Overload", 2 }, - { "Cluster",3 }, - { "Underflow", 4 }, - { "Overflow", 5 }, - { NULL } -}; - -static const struct bmcontrol uac2_output_term_bmcontrols[] = { - { "Copy Protect", 0 }, - { "Connector", 1 }, - { "Overload", 2 }, -
[PATCH v2 8/8] lsusb: Dump USB3 BOS Configuration Summary Descriptor.
Add support for dumping the configuration summary device capability descriptor to the verbose output of lsusb. Signed-off-by: Michael Drake --- lsusb.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/lsusb.c b/lsusb.c index e3eb423..c7a237e 100644 --- a/lsusb.c +++ b/lsusb.c @@ -75,6 +75,7 @@ #define USB_DC_PLATFORM0x05 #define USB_DC_SUPERSPEEDPLUS 0x0a #define USB_DC_BILLBOARD 0x0d +#define USB_DC_CONFIGURATION_SUMMARY 0x10 /* Conventional codes for class-specific descriptors. The convention is * defined in the USB "Common Class" Spec (3.11). Individual class specs @@ -3517,6 +3518,11 @@ static void dump_bos_descriptor(libusb_device_handle *fd) case USB_DC_BILLBOARD: dump_billboard_device_capability_desc(fd, buf); break; + case USB_DC_CONFIGURATION_SUMMARY: + printf(" Configuration Summary Device Capability:\n"); + desc_dump(fd, desc_usb3_dc_configuration_summary, + buf, DESC_BUF_LEN_FROM_BUF, 2); + break; default: printf(" ** UNRECOGNIZED: "); dump_bytes(buf, buf[0]); -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 2/2] lsusb: Remove unused function.
The get_audioterminal_string() function is now unused. Signed-off-by: Michael Drake --- lsusb.c | 12 1 file changed, 12 deletions(-) diff --git a/lsusb.c b/lsusb.c index a1b7f8d..1650016 100644 --- a/lsusb.c +++ b/lsusb.c @@ -217,18 +217,6 @@ static int get_protocol_string(char *buf, size_t size, u_int8_t cls, u_int8_t su return snprintf(buf, size, "%s", cp); } -static int get_audioterminal_string(char *buf, size_t size, u_int16_t termt) -{ - const char *cp; - - if (size < 1) - return 0; - *buf = 0; - if (!(cp = names_audioterminal(termt))) - return 0; - return snprintf(buf, size, "%s", cp); -} - static int get_videoterminal_string(char *buf, size_t size, u_int16_t termt) { const char *cp; -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 0/2] lsusb: Squash warnings from UAC3 merge.
This series is to fix some warnings reported by Greg. Michael Drake (2): lsusb: Squash Wpointer-compare warning. lsusb: Remove unused function. desc-dump.c | 7 +++ lsusb.c | 12 2 files changed, 3 insertions(+), 16 deletions(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 1/2] lsusb: Squash Wpointer-compare warning.
This squashes "warning: comparison between pointer and zero character" This was an empty string check that was checking the pointer rather than the first character. The check was done correctly before the string was used, so here we yank the correct check up, to the upper level, replacing the ineffectual/broken one. Signed-off-by: Michael Drake --- desc-dump.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/desc-dump.c b/desc-dump.c index 5c8e8ae..0df0e00 100644 --- a/desc-dump.c +++ b/desc-dump.c @@ -64,17 +64,16 @@ static void desc_bmcontrol_dump( (type == DESC_BMCONTROL_2)); while (strings[count] != NULL) { - if (strings[0] != '\0') { + if (strings[count][0] != '\0') { if (type == DESC_BMCONTROL_1) { - if ((strings[count][0] != '\0') && - (bmcontrols >> count) & 0x1) { + if ((bmcontrols >> count) & 0x1) { printf("%*s%s Control\n", indent * 2, "", strings[count]); } } else { control = (bmcontrols >> (count * 2)) & 0x3; - if ((strings[count][0] != '\0') && control) { + if (control) { printf("%*s%s Control (%s)\n", indent * 2, "", strings[count], -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 0/8] lsusb: Add initial support for USB Audio Class 3
On 07/12/17 15:00, Greg KH wrote: On Thu, Dec 07, 2017 at 10:26:21AM +, Michael Drake wrote: This adds a new way of dumping descriptors, which splits the knowledge of how to interpret descriptor data from the actual dumping. This has two advantages: 1. It is easy to add support for new descriptors, since they are now simple definitions that resemble the tables in the USB specifications. 2. The code for dumping descriptors is common, so the output is easy to keep consistent. It is also consistent and thorough in its handling of insufficient descriptor data buffer, and junk data at the end of a descriptor. UAC1 and UAC2 are converted to use the new mechanism, initial support for UAC3 is added. Finally, support for the USB3 BOS Configuration Summary Descriptor is added. This was previously opened as a github pull request here: https://github.com/gregkh/usbutils/pull/61 Thanks for this, all of the patches are now applied. There were some intermediate build warnings, but future patches in the series fixed that up, next time be more careful, each patch should be "clean". However the build now gets the following warnings: CC lsusb-lsusb.o lsusb.c:220:12: warning: ‘get_audioterminal_string’ defined but not used [-Wunused-function] static int get_audioterminal_string(char *buf, size_t size, u_int16_t termt) ^~~~ CC lsusb-lsusb-t.o CC lsusb-desc-defs.o CC lsusb-desc-dump.o desc-dump.c: In function ‘desc_bmcontrol_dump’: desc-dump.c:67:18: warning: comparison between pointer and zero character constant [-Wpointer-compare] if (strings[0] != '\0') { ^~ desc-dump.c:67:7: note: did you mean to dereference the pointer? if (strings[0] != '\0') { ^ CC lsusb-names.o Can you fix this up and send a patch for them? Done. Oddly I didn't see the warnings with the default `make`. I hacked "Makefile.am" locally to add "-Wall -Wextra -pedantic -O2" to the CCFLAGS, and I saw the one about the unused get_audioterminal_string() function. However I still didn't see the other. (Using gcc (Debian 6.3.0-18) 6.3.0 20170516) Cheers, -- Michael Drake http://www.codethink.co.uk/ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 0/8] lsusb: Add initial support for USB Audio Class 3
On 07/12/17 15:16, Greg KH wrote: On Thu, Dec 07, 2017 at 04:01:23PM +0100, Greg KH wrote: On Thu, Dec 07, 2017 at 04:00:36PM +0100, Greg KH wrote: On Thu, Dec 07, 2017 at 10:26:21AM +, Michael Drake wrote: This adds a new way of dumping descriptors, which splits the knowledge of how to interpret descriptor data from the actual dumping. This has two advantages: 1. It is easy to add support for new descriptors, since they are now simple definitions that resemble the tables in the USB specifications. 2. The code for dumping descriptors is common, so the output is easy to keep consistent. It is also consistent and thorough in its handling of insufficient descriptor data buffer, and junk data at the end of a descriptor. UAC1 and UAC2 are converted to use the new mechanism, initial support for UAC3 is added. Finally, support for the USB3 BOS Configuration Summary Descriptor is added. This was previously opened as a github pull request here: https://github.com/gregkh/usbutils/pull/61 Thanks for this, all of the patches are now applied. There were some intermediate build warnings, but future patches in the series fixed that up, next time be more careful, each patch should be "clean". However the build now gets the following warnings: CC lsusb-lsusb.o lsusb.c:220:12: warning: ‘get_audioterminal_string’ defined but not used [-Wunused-function] static int get_audioterminal_string(char *buf, size_t size, u_int16_t termt) ^~~~ CC lsusb-lsusb-t.o CC lsusb-desc-defs.o CC lsusb-desc-dump.o desc-dump.c: In function ‘desc_bmcontrol_dump’: desc-dump.c:67:18: warning: comparison between pointer and zero character constant [-Wpointer-compare] if (strings[0] != '\0') { ^~ desc-dump.c:67:7: note: did you mean to dereference the pointer? if (strings[0] != '\0') { ^ CC lsusb-names.o Can you fix this up and send a patch for them? Oops, I should have tested the code, it now crashes for me with the following error: Floating point exception (core dumped) Do you see this as well? No, I don't see that. And it's crashing on my USB audio device. Here's the output of it from the "old" lsusb output. [snip] Does it still crash with the warning fixes I posted? If so I'll look in detail tomorrow. Cheers, -- Michael Drake http://www.codethink.co.uk/ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 1/1] lsusb: Fix array entry count for variable sized entries.
This fixes a divide by zero which happened when an array, without an explicit entry count (ultimately calculated from the value in the descriptor data's bLength field) was used on field with a variable size. The solultion is to use the get_entry_size() function on the array entry, which can get the entry size from a referenced field. Signed-off-by: Michael Drake --- desc-dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desc-dump.c b/desc-dump.c index 0df0e00..0adf39d 100644 --- a/desc-dump.c +++ b/desc-dump.c @@ -423,7 +423,7 @@ static unsigned int get_array_entry_count( } } - entries = size / array_entry->size; + entries = size / get_entry_size(buf, desc, array_entry); } return entries; -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v1 0/1] lsusb: Fix potential floating point exception.
This fixes the likely cause of a crash found by Greg. Michael Drake (1): lsusb: Fix array entry count for variable sized entries. desc-dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 0/8] lsusb: Add initial support for USB Audio Class 3
On 07/12/17 17:26, Greg KH wrote: On Thu, Dec 07, 2017 at 05:14:10PM +, Michael Drake wrote: On 07/12/17 15:16, Greg KH wrote: On Thu, Dec 07, 2017 at 04:01:23PM +0100, Greg KH wrote: Oops, I should have tested the code, it now crashes for me with the following error: Floating point exception (core dumped) Do you see this as well? No, I don't see that. And it's crashing on my USB audio device. Here's the output of it from the "old" lsusb output. [snip] Does it still crash with the warning fixes I posted? If so I'll look in detail tomorrow. I will check when I get home tonight, I don't have the USB device on me at the moment. Thank you. I believe I've guessed the problem and sent a patch. Cheers, -- Michael Drake http://www.codethink.co.uk/ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v1 1/1] lsusb: Fix array entry count for variable sized entries.
On 07/12/17 20:02, Greg KH wrote: On Thu, Dec 07, 2017 at 07:18:39PM +, Michael Drake wrote: This fixes a divide by zero which happened when an array, without an explicit entry count (ultimately calculated from the value in the descriptor data's bLength field) was used on field with a variable size. The solultion is to use the get_entry_size() function on the array entry, which can get the entry size from a referenced field. Signed-off-by: Michael Drake --- desc-dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) Nice, that fixed the problem, thanks. Great, thanks Greg! Now applied and pushed out. I can't see this commit yet on https://github.com/gregkh/usbutils/commits/master Cheers, -- Michael Drake http://www.codethink.co.uk/ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 0/8] lsusb: Add initial support for USB Audio Class 3
On 07/12/17 20:04, Greg KH wrote: On Thu, Dec 07, 2017 at 07:24:35PM +, Michael Drake wrote: On 07/12/17 17:26, Greg KH wrote: On Thu, Dec 07, 2017 at 05:14:10PM +, Michael Drake wrote: On 07/12/17 15:16, Greg KH wrote: On Thu, Dec 07, 2017 at 04:01:23PM +0100, Greg KH wrote: Oops, I should have tested the code, it now crashes for me with the following error: Floating point exception (core dumped) Do you see this as well? No, I don't see that. And it's crashing on my USB audio device. Here's the output of it from the "old" lsusb output. [snip] Does it still crash with the warning fixes I posted? If so I'll look in detail tomorrow. I will check when I get home tonight, I don't have the USB device on me at the moment. Thank you. I believe I've guessed the problem and sent a patch. Ok, that now works. But there is a difference in the "old" and "new" outputs, here's a diff of a full -v output of my laptop and a bunch of USB devices plugged in, showing the fields that now look different. The big one is the change from "streaming" to "control", is that correct? Replied inline below. thanks, greg k-h --- lsusb-v.orig2017-12-07 21:01:26.153185002 +0100 +++ lsusb-v.new 2017-12-07 21:01:32.806517978 +0100 @@ -1110,9 +1110,9 @@ bDescriptorType36 bDescriptorSubtype 1 (HEADER) bcdADC 1.00 -wTotalLength 0x0028 +wTotalLength 40 I was a bit confused by this diff at first, because the "-" lines are my version and the "+" lines are the old version. Anyway, this is expected. For NUMBER type fields, my code uses the heuristic that 1 byte fields are shown as decimal and >1 byte is shown as full hexadecimal, with leading zeros shown. This is consistent with the way the old lsusb behaved in most cases, although it was slightly inconsistent about it, and this is an example of that inconsistency. Anyway, since it's a 2 byte field the hex representation is expected here, and the actual value is the same. bInCollection 1 -baInterfaceNr(0)1 +baInterfaceNr( 0) 1 Just a whitespace change. My version's not using a fixed width for the array index, and only uses what's needed for the largest index to be represented. AudioControl Interface Descriptor: bLength12 bDescriptorType36 @@ -1142,10 +1142,10 @@ bUnitID13 bSourceID 1 bControlSize1 -bmaControls(0) 0x01 +bmaControls( 0) 0x01 Mute Control -bmaControls(1) 0x00 -bmaControls(2) 0x00 +bmaControls( 1) 0x00 +bmaControls( 2) 0x00 Ditto for these. iFeature0 Interface Descriptor: bLength 9 @@ -1173,7 +1173,7 @@ bDescriptorSubtype 1 (AS_GENERAL) bTerminalLink 1 bDelay 1 frames -wFormatTag 0x0001 PCM +wFormatTag 1 PCM This is the >1 byte shown as hexadecimal thing. AudioStreaming Interface Descriptor: bLength20 bDescriptorType36 @@ -1199,14 +1199,14 @@ bInterval 4 bRefresh0 bSynchAddress 133 -AudioStreaming Endpoint Descriptor: +AudioControl Endpoint Descriptor: This is from the dump_audiostreaming_endpoint() function. The "AudioStreaming" string is correct. Looks like a typo in the old lsusb output. bLength 7 bDescriptorType37 bDescriptorSubtype 1 (EP_GENERAL) bmAttributes 0x01 Sampling Frequency bLockDelayUnits 0 Undefined - wLockDelay 0x + wLockDelay 0 Undefined This and the remaining entries are similar to the above ones. Endpoint Descriptor: bLength 9 bDescriptorType 5 @@ -1235,7 +1235,7 @@ bDescriptorSubtype 1 (AS_GENERAL) bTerminalLink 1 bDelay 1 frames -wFormatTag 0x0001 PCM +wFormatTag 1 PCM AudioStreaming Interface Descriptor: bLength20 bDescriptorType36 @@ -1261,14 +1261,14 @@ bInterval 4 bRefresh0 bSynchAddress 133 -AudioStreaming Endpoint Descriptor: +AudioControl Endpoint Descriptor: bLength 7 bDescriptorType37 bDescriptor
Re: [PATCH v2 0/8] lsusb: Add initial support for USB Audio Class 3
On 08/12/17 14:27, Greg KH wrote: On Fri, Dec 08, 2017 at 10:30:43AM +, Michael Drake wrote: On 07/12/17 20:04, Greg KH wrote: --- lsusb-v.orig2017-12-07 21:01:26.153185002 +0100 +++ lsusb-v.new 2017-12-07 21:01:32.806517978 +0100 @@ -1110,9 +1110,9 @@ bDescriptorType36 bDescriptorSubtype 1 (HEADER) bcdADC 1.00 -wTotalLength 0x0028 +wTotalLength 40 [snip] Anyway, since it's a 2 byte field the hex representation is expected here, and the actual value is the same. Yes, the value is the same, but all other wTotalLength fields exported by lsusb are in decimal. Changing just this one feels odd to me. Yes, that's a good reason for wanting to change the other ones. [snip] I'll look at moving those other wFields to be also in 0x mode to match up here. If you like I can work up a patch for that. I'd just be tweaking the old printfs to dump wFields with "0x%04x". I'm also thinking of porting more of the existing lsusb dumping to use the desc_dump() function, but that would have to be piece by piece, as I get time. Cheers, -- Michael Drake http://www.codethink.co.uk/ -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html