Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23aee1bb authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "terminal_type_fix"

* changes:
  Add test for UsbDescriptorParser.java
  USB Audio: broaden Terminal Type interpretation
parents 7cd6e3a0 7db57cbe
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -380,11 +380,10 @@ public final class UsbDescriptorParser {
                if (DEBUG) {
                    Log.d(TAG, "  type:0x" + Integer.toHexString(type));
                }
                if ((type >= UsbTerminalTypes.TERMINAL_IN_UNDEFINED
                            && type <= UsbTerminalTypes.TERMINAL_IN_PROC_MIC_ARRAY)
                        || (type >= UsbTerminalTypes.TERMINAL_BIDIR_UNDEFINED
                            && type <= UsbTerminalTypes.TERMINAL_BIDIR_SKRPHONE_CANCEL)
                        || (type == UsbTerminalTypes.TERMINAL_USB_STREAMING)) {
                int terminalCategory = type & ~0xFF;
                if (terminalCategory != UsbTerminalTypes.TERMINAL_USB_UNDEFINED
                        && terminalCategory != UsbTerminalTypes.TERMINAL_OUT_UNDEFINED) {
                    // If not explicitly a USB connection or output, it could be an input.
                    hasInput = true;
                    break;
                }
@@ -419,10 +418,10 @@ public final class UsbDescriptorParser {
                if (DEBUG) {
                    Log.d(TAG, "  type:0x" + Integer.toHexString(type));
                }
                if ((type >= UsbTerminalTypes.TERMINAL_OUT_UNDEFINED
                            && type <= UsbTerminalTypes.TERMINAL_OUT_LFSPEAKER)
                        || (type >= UsbTerminalTypes.TERMINAL_BIDIR_UNDEFINED
                            && type <= UsbTerminalTypes.TERMINAL_BIDIR_SKRPHONE_CANCEL)) {
                int terminalCategory = type & ~0xFF;
                if (terminalCategory != UsbTerminalTypes.TERMINAL_USB_UNDEFINED
                        && terminalCategory != UsbTerminalTypes.TERMINAL_IN_UNDEFINED) {
                    // If not explicitly a USB connection or input, it could be an output.
                    hasOutput = true;
                    break;
                }
+1 −0
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ public final class UsbTerminalTypes {
    private static final String TAG = "UsbTerminalTypes";

    // USB
    public static final int TERMINAL_USB_UNDEFINED   = 0x0100;
    public static final int TERMINAL_USB_STREAMING   = 0x0101;

    // Inputs
+35 −0
Original line number Diff line number Diff line
The usbdescriptors_ files contain raw USB descriptors from the Google
USB-C to 3.5mm adapter, with different loads connected to the 3.5mm
jack.

usbdescriptors_nothing.bin:
 - The descriptors when the jack is disconnected.

usbdescriptors_headphones.bin:
 - The descriptors when the jack is connected to 32-ohm headphones,
   no microphone.
   The relevant output terminal is:
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            15
        wTerminalType      0x0302 Headphones
   
usbdescriptors_lineout.bin:
 - The descriptors when the jack is connected to a PC line-in jack.
   The relevant output terminal is:
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            15
        wTerminalType      0x0603 Line Connector

usbdescriptors_headset.bin:
 - The descriptors when a headset with microphone and low-impedance
   headphones are connected.
   The relevant input terminal is:
        bDescriptorSubtype      2 (INPUT_TERMINAL)
        bTerminalID             1
        wTerminalType      0x0201 Microphone
   The relevant output terminal is:
        bDescriptorSubtype      3 (OUTPUT_TERMINAL)
        bTerminalID            15
        wTerminalType      0x0302 Headphones

+180 B

File added.

No diff preview for this file type.

+305 B

File added.

No diff preview for this file type.

Loading