Reputation: 55
I created an USB audio gadget using USB Audio Class 1 (UAC1) to send/receive audio over USB from a Linux device (Raspberry Pi) to/from a Windows host. The gadget is already working and Windows detects the Raspberry Pi as an audio in and output.
The problem I have is, that the audio output device is called "AC Interface" and the input audio device is called "capture input terminal (AC Interface) in Windows". However, I would like to define an own name, that will be display at the host. Can somebody help me how to do this?
I tried to change the name using uac1_legacy
(https://www.kernel.org/doc/Documentation/ABI/testing/configfs-usb-gadget-uac1_legacy), but I couldn't manged to add this to the script.
Or do I have to configure the USB audio gadget using gadget schemes?
# Load libcomposite
modprobe libcomposite
# Create USB Gadget
mkdir -p /sys/kernel/config/usb_gadget/g1
# Device Descriptors
echo 0x1d6b > /sys/kernel/config/usb_gadget/g1/idVendor # Linux Foundation
echo 0x0104 > /sys/kernel/config/usb_gadget/g1/idProduct # Multifunction Composite Gadget
echo 0x0100 > /sys/kernel/config/usb_gadget/g1/bcdDevice # v1.0.0
echo 0x0200 > /sys/kernel/config/usb_gadget/g1/bcdUSB # USB 2.0
echo 0xef > /sys/kernel/config/usb_gadget/g1/bDeviceClass # USB 2.0
echo 0x02 > /sys/kernel/config/usb_gadget/g1/bDeviceSubClass # USB 2.0
echo 0x01 > /sys/kernel/config/usb_gadget/g1/bDeviceProtocol # USB 2.0
mkdir -p /sys/kernel/config/usb_gadget/g1/strings/0x409
echo "000001" > /sys/kernel/config/usb_gadget/g1/strings/0x409/serialnumber
echo "xy" > /sys/kernel/config/usb_gadget/g1/strings/0x409/manufacturer
echo "xy" > /sys/kernel/config/usb_gadget/g1/strings/0x409/product
# Configure UAC1 (audio)
mkdir -p /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0
echo 0x1 > /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0/c_chmask
echo 48000 > /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0/c_srate
echo 0xf > /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0/p_chmask
echo 48000 > /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0/p_srate
mkdir -p /sys/kernel/config/usb_gadget/g1/configs/c.1
echo 250 > /sys/kernel/config/usb_gadget/g1/configs/c.1/MaxPower
ln -s /sys/kernel/config/usb_gadget/g1/functions/uac1.usb0 /sys/kernel/config/usb_gadget/g1/configs/c.1/
udevadm settle -t 5 || :
# End
ls /sys/class/udc/ > /sys/kernel/config/usb_gadget/sonoDSP_audio/UDC
Upvotes: 1
Views: 1877
Reputation: 179
You can check f_uac1.c
. For me it seems you can not change the gstrings on the fly for the predefined funcation f_uac.
static struct usb_string strings_uac1[] = {
[STR_AC_IF].s = "AC Interface",
...,
[STR_IO_IN_IT].s = "Capture Input terminal",
...,
{ }
};
What you can do is, creating a simple functionfs user space program with your custom configurations. See the following for further details on ffs.
How to load ffs? See: https://github.com/linkjumper/configfs/blob/master/setup_usb_gadget.sh
Documentation on how to write a userspace functionfs:
See: linux/tools/usb/ffs-test.c
. (Spoiler, those testfile did not work for all endpoints to me. But it is a good source as an example.)
It is a little work, but worth it.
Upvotes: 0