Jump to content

Recommended Posts

Posted (edited)

First time working with usb_f_uac1. Running buster image.

 

I have a configfs setup that hosts are able to enumerate but the attributes for capture (c_chmask, c_ssize, c_srate) and playback (p_chmask, p_ssize, p_srate) seem to be switched. i.e. c_chmask = 0x3f shows as a 6-channel capture endpoint on both Windows (ksstudio) and macOS (system information) hosts.

 

Is there something I’m misunderstanding here? Is there something I’m not doing correctly?

 

 

 

Edited by wraiths.patient
Posted

Your post is lacking a lot of required details and hence its hard to help you. Start by mentioning the image or Armbian version you are using and the kernel version being used. It would also help if you can capture logs using armbianmonitor and share the same.

Posted

@Gunjan Gupta good points...

Image:

Orange Pi PC 2.0.8 based on Debian Buster

 

Kernel: 

root@orangepipc:~# uname -a
Linux orangepipc 5.4.65-sunxi #2.0.8 SMP Mon Oct 26 10:20:38 CST 2020 armv7l GNU/Linux

 

I'm new to armbian - experienced *NIX - I'm unfamiliar with armbianmonitor and which logs exactly would be most helpful here?

Posted
1 hour ago, wraiths.patient said:

Image:

Orange Pi PC 2.0.8 based on Debian Buster

That is not an Armbian image.  Being an Armbian forum we can only support Armbian images.  You need to direct your question to the provider of your software image (orangepi).  We can't help you here.

Posted (edited)

Figured I'd checkout the actual armbian image using https://redirect.armbian.com/region/NA/orangepipc/Jammy_current

 

Just FYI, same thing hapeens on armbian... p_* and c_* settings are switched. e.g., setting the playback channel mask to 0x3f (5.1; 6 channels) actually sets the channel mask for what the host enumerates as the capture endpoint so you get a 6-channel microphone.

 

armbian-monitor -u

https://paste.armbian.com/yadagozohu

 

configfs configuration script

#!/bin/bash
set -x

# Set up the environment
modprobe libcomposite
cd /sys/kernel/config/usb_gadget/

# Create a new USB gadget
GADGET_DIR="g1"
mkdir -p $GADGET_DIR
cd $GADGET_DIR

# Set basic USB device settings
echo 0x1d6b > idVendor  # Linux Foundation
echo 0x0101 > idProduct # Multifunction Composite Gadget
echo 0x0100 > bcdDevice # v1.0.0
echo 0x0200 > bcdUSB    # USB2

mkdir -p strings/0x409
echo "serialnumber" > strings/0x409/serialnumber
echo "Me Ltd." > strings/0x409/manufacturer
echo "My UAC1 Gadget"      > strings/0x409/product

# Create a configuration
mkdir -p configs/c.1
mkdir -p configs/c.1/strings/0x409
echo "Configuration 1" > configs/c.1/strings/0x409/configuration
echo 250 > configs/c.1/MaxPower


# Add the UAC1 function with specific audio parameters
UAC1_DIR="functions/uac1.usb0"
mkdir -p $UAC1_DIR

echo 0x3f > $UAC1_DIR/p_chmask  # 1 for mono, 3 for stereo
echo 48000 > $UAC1_DIR/p_srate
echo 4 > $UAC1_DIR/p_ssize

# # Capture settings: Mono, 48000 Hz, 16-bit
echo 0x3 > $UAC1_DIR/c_chmask  # 1 for mono, 3 for stereo
echo 48000 > $UAC1_DIR/c_srate
echo 4 > $UAC1_DIR/c_ssize

# Bind the UAC1 function to the configuration
ln -s $UAC1_DIR configs/c.1/

# Enable the gadget
ls /sys/class/udc > UDC

echo "USB Gadget configured."

 

USB Descriptors enumerated on Windows

 

    =========================== USB Port2 ===========================

Connection Status        : 0x01 (Device is connected)
Port Chain               : 2-4-2-2

      ========================== Summary =========================
Vendor ID                : 0x1D6B (The Linux Foundation)
Product ID               : 0x0101
USB Version              : 2.0
Port maximum Speed       : High-Speed
Device maximum Speed     : High-Speed
Device Connection Speed  : High-Speed
Self powered             : no
Demanded Current         : 250 mA
Used Endpoints           : 2

      ======================== USB Device ========================

        +++++++++++++++++ Device Information ++++++++++++++++++
Device Description       : USB Composite Device
Device Path              : \\?\USB#VID_1D6B&PID_0101#serialnumber#{a5dcbf10-6530-11d2-901f-00c04fb951ed} (GUID_DEVINTERFACE_USB_DEVICE)
Kernel Name              : \Device\USBPDO-16
Device ID                : USB\VID_1D6B&PID_0101\SERIALNUMBER
Hardware IDs             : USB\VID_1D6B&PID_0101&REV_0100 USB\VID_1D6B&PID_0101
Driver KeyName           : {36fc9e60-c465-11cf-8056-444553540000}\0042 (GUID_DEVCLASS_USB)
Driver                   : \SystemRoot\System32\drivers\usbccgp.sys (Version: 10.0.22621.1194  Date: 2023-02-16)
Driver Inf               : C:\Windows\inf\usb.inf
Legacy BusType           : PNPBus
Class                    : USB
Class GUID               : {36fc9e60-c465-11cf-8056-444553540000} (GUID_DEVCLASS_USB)
Service                  : usbccgp
Enumerator               : USB
Location Info            : Port_#0002.Hub_#0005
Location IDs             : PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(4)#USB(2)#USB(2), ACPI(_SB_)#ACPI(PC00)#ACPI(XHCI)#ACPI(RHUB)#ACPI(HS04)#USB(2)#USB(2)
Container ID             : {4ce02247-74d0-5cd6-b2ee-4a880a757088}
Manufacturer Info        : (Standard USB Host Controller)
Capabilities             : 0x94 (Removable, UniqueID, SurpriseRemovalOK)
Status                   : 0x0180600A (DN_DRIVER_LOADED, DN_STARTED, DN_DISABLEABLE, DN_REMOVABLE, DN_NT_ENUMERATOR, DN_NT_DRIVER)
Problem Code             : 0
Address                  : 2
HcDisableSelectiveSuspend: 0
EnableSelectiveSuspend   : 0
SelectiveSuspendEnabled  : 0
EnhancedPowerMgmtEnabled : 0
IdleInWorkingState       : 0
WakeFromSleepState       : 0
Power State              : D0 (supported: D0, D2, D3, wake from D0, wake from D2)
 Child Device 1          : AC Interface (USB Audio Device)
  Device Path 1          : \\?\USB#VID_1D6B&PID_0101&MI_00#8&184ce4f3&0&0000#{6994ad04-93ef-11d0-a3cc-00a0c9223196}\global (AM_KSCATEGORY_AUDIO)
  Device Path 2          : \\?\USB#VID_1D6B&PID_0101&MI_00#8&184ce4f3&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global (AM_KSCATEGORY_CAPTURE)
  Device Path 3          : \\?\USB#VID_1D6B&PID_0101&MI_00#8&184ce4f3&0&0000#{65e8773e-8f56-11d0-a3b9-00a0c9223196}\global (AM_KSCATEGORY_RENDER)
  Kernel Name            : \Device\00000dd9
  Device ID              : USB\VID_1D6B&PID_0101&MI_00\8&184CE4F3&0&0000
  Class                  : MEDIA
  Driver KeyName         : {4d36e96c-e325-11ce-bfc1-08002be10318}\0019 (GUID_DEVCLASS_MEDIA)
  Service                : usbaudio
  Location               : 0000.0014.0000.004.002.002.000.000.000
  LocationPaths          : PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(4)#USB(2)#USB(2)#USBMI(0)  PCIROOT(0)#PCI(1400)#USBROOT(0)#USB(4)#USB(2)#USB(2)#USB(2)  ACPI(_SB_)#ACPI(PC00)#ACPI(XHCI)#ACPI(RHUB)#ACPI(HS04)#USB(2)#USB(2)#USBMI(0)  ACPI(_SB_)#ACPI(PC00)#ACPI(XHCI)#ACPI(RHUB)#ACPI(HS04)#USB(2)#USB(2)#USB(2)
   Child Device 1        : Speakers (5- AC Interface) (Audio Endpoint)
    Device ID            : SWD\MMDEVAPI\{0.0.0.00000000}.{CBD53598-1B0C-4348-A8DC-9D0E1E971B9E}
    Class                : AudioEndpoint
    Driver KeyName       : {c166523c-fe0c-4a94-a586-f1a80cfbbf3e}\0056 (AUDIOENDPOINT_CLASS_UUID)
   Child Device 2        : Capture Input terminal (5- AC Interface) (Audio Endpoint)
    Device ID            : SWD\MMDEVAPI\{0.0.1.00000000}.{5B1781AE-C053-4604-A488-8D1C3203C210}
    Class                : AudioEndpoint
    Driver KeyName       : {c166523c-fe0c-4a94-a586-f1a80cfbbf3e}\0055 (AUDIOENDPOINT_CLASS_UUID)

        +++++++++++++++++ Registry USB Flags +++++++++++++++++
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags\1D6B01010100
 osvc                    : REG_BINARY 00 00

        ---------------- Connection Information ---------------
Connection Index         : 0x02 (Port 2)
Connection Status        : 0x01 (DeviceConnected)
Current Config Value     : 0x01 (Configuration 1)
Device Address           : 0x1C (28)
Is Hub                   : 0x00 (no)
Device Bus Speed         : 0x02 (High-Speed)
Number Of Open Pipes     : 0x01 (1 pipe to data endpoints)
Pipe[0]                  : EndpointID=1  Direction=IN   ScheduleOffset=0  Type=Interrupt  wMaxPacketSize=0x2     bInterval=4   -> 140 Bits/ms = 17500 Bytes/s
Data (HexDump)           : 02 00 00 00 12 01 00 02 00 00 00 40 6B 1D 01 01   ...........@k...
                           00 01 01 02 03 01 01 02 00 1C 00 01 00 00 00 01   ................
                           00 00 00 07 05 81 03 02 00 04 00 00 00 00         ..............

        --------------- Connection Information V2 -------------
Connection Index         : 0x02 (2)
Length                   : 0x10 (16 bytes)
SupportedUsbProtocols    : 0x03
 Usb110                  : 1 (yes, port supports USB 1.1)
 Usb200                  : 1 (yes, port supports USB 2.0)
 Usb300                  : 0 (no, port not supports USB 3.0)
 ReservedMBZ             : 0x00
Flags                    : 0x00
 DevIsOpAtSsOrHigher     : 0 (Device is not operating at SuperSpeed or higher)
 DevIsSsCapOrHigher      : 0 (Device is not SuperSpeed capable or higher)
 DevIsOpAtSsPlusOrHigher : 0 (Device is not operating at SuperSpeedPlus or higher)
 DevIsSsPlusCapOrHigher  : 0 (Device is not SuperSpeedPlus capable or higher)
 ReservedMBZ             : 0x00
Data (HexDump)           : 02 00 00 00 10 00 00 00 03 00 00 00 00 00 00 00   ................

    ---------------------- Device Descriptor ----------------------
bLength                  : 0x12 (18 bytes)
bDescriptorType          : 0x01 (Device Descriptor)
bcdUSB                   : 0x200 (USB Version 2.0)
bDeviceClass             : 0x00 (defined by the interface descriptors)
bDeviceSubClass          : 0x00
bDeviceProtocol          : 0x00
bMaxPacketSize0          : 0x40 (64 bytes)
idVendor                 : 0x1D6B (The Linux Foundation)
idProduct                : 0x0101
bcdDevice                : 0x0100
iManufacturer            : 0x01 (String Descriptor 1)
 Language 0x0409         : "Me Ltd."
iProduct                 : 0x02 (String Descriptor 2)
 Language 0x0409         : "My UAC1 Gadget"
iSerialNumber            : 0x03 (String Descriptor 3)
 Language 0x0409         : "serialnumber"
bNumConfigurations       : 0x01 (1 Configuration)
Data (HexDump)           : 12 01 00 02 00 00 00 40 6B 1D 01 01 00 01 01 02   .......@k.......
                           03 01                                             ..

    ------------------ Configuration Descriptor -------------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x02 (Configuration Descriptor)
wTotalLength             : 0x00D7 (215 bytes)
bNumInterfaces           : 0x03 (3 Interfaces)
bConfigurationValue      : 0x01 (Configuration 1)
iConfiguration           : 0x04 (String Descriptor 4)
 Language 0x0409         : "Configuration 1"
bmAttributes             : 0x80
 D7: Reserved, set 1     : 0x01
 D6: Self Powered        : 0x00 (no)
 D5: Remote Wakeup       : 0x00 (no)
 D4..0: Reserved, set 0  : 0x00
MaxPower                 : 0x7D (250 mA)
Data (HexDump)           : 09 02 D7 00 03 01 04 80 7D 09 04 00 00 01 01 01   ........}.......
                           00 05 0A 24 01 00 01 56 00 02 01 02 0C 24 02 01   ...$...V.....$..
                           01 01 00 02 03 00 07 06 09 24 03 03 01 03 00 05   .........$......
                           08 0D 24 06 05 01 02 03 00 00 00 00 00 0D 0C 24   ..$............$
                           02 02 01 02 00 06 3F 00 0A 09 09 24 03 04 01 01   ......?....$....
                           00 06 0B 15 24 06 06 02 02 03 00 00 00 00 00 00   ....$...........
                           00 00 00 00 00 00 00 0C 07 05 81 03 02 00 04 09   ................
                           04 01 00 00 01 02 00 0E 09 04 01 01 01 01 02 00   ................
                           0F 07 24 01 01 01 01 00 0B 24 02 01 02 04 20 01   ..$......$.... .
                           80 BB 00 09 05 01 09 C8 00 04 00 00 07 25 01 01   .............%..
                           01 01 00 09 04 02 00 00 01 02 00 10 09 04 02 01   ................
                           01 01 02 00 11 07 24 01 04 01 01 00 0B 24 02 01   ......$......$..
                           06 04 20 01 80 BB 00 09 05 82 05 C8 00 04 00 00   .. .............
                           07 25 01 01 00 00 00                              .%.....

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x00 (Interface 0)
bAlternateSetting        : 0x00
bNumEndpoints            : 0x01 (1 Endpoint)
bInterfaceClass          : 0x01 (Audio)
bInterfaceSubClass       : 0x01 (Audio Control)
bInterfaceProtocol       : 0x00
iInterface               : 0x05 (String Descriptor 5)
 Language 0x0409         : "AC Interface"
Data (HexDump)           : 09 04 00 00 01 01 01 00 05                        .........

        ------ Audio Control Interface Header Descriptor ------
bLength                  : 0x0A (10 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x01 (Header)
bcdADC                   : 0x0100
wTotalLength             : 0x0056 (86 bytes)
bInCollection            : 0x02
baInterfaceNr[1]         : 0x01
baInterfaceNr[2]         : 0x02
Data (HexDump)           : 0A 24 01 00 01 56 00 02 01 02                     .$...V....

        ------- Audio Control Input Terminal Descriptor -------
bLength                  : 0x0C (12 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x02 (Input Terminal)
bTerminalID              : 0x01
wTerminalType            : 0x0101 (USB Streaming)
bAssocTerminal           : 0x00
bNrChannels              : 0x02 (2 channels)
wChannelConfig           : 0x0003 (L, R)
iChannelNames            : 0x07 (String Descriptor 7)
 Language 0x0409         : "Playback Channels"
iTerminal                : 0x06 (String Descriptor 6)
 Language 0x0409         : "Playback Input terminal"
Data (HexDump)           : 0C 24 02 01 01 01 00 02 03 00 07 06               .$..........

        ------- Audio Control Output Terminal Descriptor ------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x03 (Output Terminal)
bTerminalID              : 0x03
wTerminalType            : 0x0301 (Speaker)
bAssocTerminal           : 0x00 (0)
bSourceID                : 0x05 (5)
iTerminal                : 0x08 (String Descriptor 8)
 Language 0x0409         : "Playback Output terminal"
Data (HexDump)           : 09 24 03 03 01 03 00 05 08                        .$.......

        -------- Audio Control Feature Unit Descriptor --------
bLength                  : 0x0D (13 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x06 (Feature Unit)
bUnitID                  : 0x05 (5)
bSourceID                : 0x01 (1)
bControlSize             : 0x02 (2 bytes per control)
bmaControls[0]           : 0x03, 0x00
 D0: Mute                : 1
 D1: Volume              : 1
 D2: Bass                : 0
 D3: Mid                 : 0
 D4: Treble              : 0
 D5: Graphic Equalizer   : 0
 D6: Automatic Gain      : 0
 D7: Delay               : 0
 D8: Bass Boost          : 0
 D9: Loudness            : 0
 D10: Reserved           : 0
 D11: Reserved           : 0
 D12: Reserved           : 0
 D13: Reserved           : 0
 D14: Reserved           : 0
 D15: Reserved           : 0
bmaControls[1]           : 0x00, 0x00
 D0: Mute                : 0
 D1: Volume              : 0
 D2: Bass                : 0
 D3: Mid                 : 0
 D4: Treble              : 0
 D5: Graphic Equalizer   : 0
 D6: Automatic Gain      : 0
 D7: Delay               : 0
 D8: Bass Boost          : 0
 D9: Loudness            : 0
 D10: Reserved           : 0
 D11: Reserved           : 0
 D12: Reserved           : 0
 D13: Reserved           : 0
 D14: Reserved           : 0
 D15: Reserved           : 0
bmaControls[2]           : 0x00, 0x00
 D0: Mute                : 0
 D1: Volume              : 0
 D2: Bass                : 0
 D3: Mid                 : 0
 D4: Treble              : 0
 D5: Graphic Equalizer   : 0
 D6: Automatic Gain      : 0
 D7: Delay               : 0
 D8: Bass Boost          : 0
 D9: Loudness            : 0
 D10: Reserved           : 0
 D11: Reserved           : 0
 D12: Reserved           : 0
 D13: Reserved           : 0
 D14: Reserved           : 0
 D15: Reserved           : 0
iFeature                 : 0x0D (String Descriptor 13)
 Language 0x0409         : "Playback Volume"
Data (HexDump)           : 0D 24 06 05 01 02 03 00 00 00 00 00 0D            .$...........

        ------- Audio Control Input Terminal Descriptor -------
bLength                  : 0x0C (12 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x02 (Input Terminal)
bTerminalID              : 0x02
wTerminalType            : 0x0201 (Microphone)
bAssocTerminal           : 0x00
bNrChannels              : 0x06 (6 channels)
wChannelConfig           : 0x003F (L, R, C, LFE, LS, RS)
iChannelNames            : 0x0A (String Descriptor 10)
 Language 0x0409         : "Capture Channels"
iTerminal                : 0x09 (String Descriptor 9)
 Language 0x0409         : "Capture Input terminal"
Data (HexDump)           : 0C 24 02 02 01 02 00 06 3F 00 0A 09               .$......?...

        ------- Audio Control Output Terminal Descriptor ------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x24 (Audio Interface Descriptor)
bDescriptorSubtype       : 0x03 (Output Terminal)
bTerminalID              : 0x04
wTerminalType            : 0x0101 (USB Streaming)
bAssocTerminal           : 0x00 (0)
bSourceID                : 0x06 (6)
iTerminal                : 0x0B (String Descriptor 11)
 Language 0x0409         : "Capture Output terminal"
Data (HexDump)           : 09 24 03 04 01 01 00 06 0B                        .$.......

 

USB Descriptors enumerated on macOS 

 

Playback Inactive:

  Default Output Device:	Yes
  Default System Output Device:	Yes
  Manufacturer:	Me Ltd.
  Output Channels:	2
  Current SampleRate:	48000
  Transport:	USB
  Output Source:	Default

Capture Inactive:

  Input Channels:	6
  Manufacturer:	Me Ltd.
  Current SampleRate:	48000
  Transport:	USB
  Input Source:	Default

 

 

Edited by wraiths.patient

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines