Re: [PATCH v1 1/8] lsusb: Split subtype mapping out of AudioControl interface handling.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 05/12/17 16:31, Greg KH wrote:
On Tue, Dec 05, 2017 at 04:14:24PM +0000, 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 majordomo@xxxxxxxxxxxxxxx
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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux