We are use imx8mp android 11 bsp , and we want to enable UVC+UAC composite gadget feature , kernel config we have enable:
CONFIG_USB_CONFIGFS_F_UVC=y
CONFIG_USB_CONFIGFS_F_UAC1=y
CONFIG_USB_CONFIGFS_F_UAC2=y
and use below script to enable UVC and UAC:
stop adbd
echo "" > /config/usb_gadget/g1/UDC
mkdir /config/usb_gadget/g1/functions/uvc.0
mkdir /config/usb_gadget/g1/functions/uac1.0
cd /config/usb_gadget/g1/functions/uvc.0
echo 3072 > streaming_maxpacket
echo 0 > streaming_maxburst
echo 1 > streaming_interval
mkdir control/header/h
ln -s control/header/h control/class/fs/
ln -s control/header/h control/class/ss
mkdir -p streaming/mjpeg/m/720p
echo 1280 > streaming/mjpeg/m/720p/wWidth
echo 720 > streaming/mjpeg/m/720p/wHeight
echo 29491200 > streaming/mjpeg/m/720p/dwMinBitRate
echo 29491200 > streaming/mjpeg/m/720p/dwMaxBitRate
echo 3110400 > streaming/mjpeg/m/720p/dwMaxVideoFrameBufferSize
echo 333333 > streaming/mjpeg/m/720p/dwDefaultFrameInterval
echo "333333\n666666\n1000000\n" > streaming/mjpeg/m/720p/dwFrameInterval
mkdir streaming/header/h
ln -s streaming/mjpeg/m streaming/header/h
ln -s streaming/header/h streaming/class/fs/
ln -s streaming/header/h streaming/class/hs/
ln -s streaming/header/h streaming/class/ss/
echo "uvc_uac1" > /config/usb_gadget/g1/configs/b.1/strings/0x409/configuration
rm /config/usb_gadget/g1/configs/b.1/function0
rm /config/usb_gadget/g1/configs/b.1/function1
echo "0x1d6b" > /config/usb_gadget/g1/idVendor
echo "0x0104" > /config/usb_gadget/g1/idProduct
ln -s /config/usb_gadget/g1/functions/uvc.0 /config/usb_gadget/g1/configs/b.1/function0
ln -s /config/usb_gadget/g1/functions/uac1.0 /config/usb_gadget/g1/configs/b.1/function1
echo "38100000.dwc3" > /config/usb_gadget/g1/UDC
uvc_gadget -v /dev/video2 -u /dev/video6
after run script , i can see host pc can detect UVC + UAC
[ 4166.912769] uvcvideo: Found UVC 1.00 device LATAM (1d6b:0104)
[ 4166.924081] input: LATAM: UVC Camera as /devices/pci0000:00/0000:00:14.0/usb1/1-6/1-6:1.0/input/input38
kevinwei@kevinwei-TUF-Gaming-FX505GT:~$ cat /proc/asound/cards
0 [NVidia ]: HDA-Intel - HDA NVidia
HDA NVidia at 0xa4080000 irq 17
1 [sofsklhdacard ]: sof-hda-dsp - sof-hda-dsp
ASUSTeKCOMPUTERINC.-TUFGamingFX505GT-1.0-FX505GT
2 [LATAM ]: USB-Audio - LATAM
Pegatron LATAM at usb-0000:00:14.0-6, high speed
but i use below command to try UAC device , imx8mp kernel will crash
1. host pc:
gst-launch-1.0 -v filesrc location=c304-2.wav ! wavparse ! audioconvert ! alsasink device=hw:2
2. imx8mp device:
gst-launch-1.0 -v alsasrc device=hw:6 ! audio/x-raw, rate=48000 ! audioconvert ! alsasink device=hw:5 // to speaker
imx8mp kernel will crash:
[ 269.974571] WARNING: CPU: 3 PID: 1903 at drivers/usb/gadget/composite.c:427 usb_function_activate+0x88/0x94
[ 269.987846] Modules linked in: fec ptp pps_core realtek pci_imx6 snd_soc_imx_rpmsg snd_soc_rpmsg_wm8960_i2c snd_soc_rpmsg_wm8960 imx_audio_rpmsg snd_soc_fsl_rpmsg imx_pcm_rpmsg i2c_rpmsg_imx imx_dsp_r0
[ 269.987993] v4l2_fwnode imx_cpufreq_dt cpufreq_dt imx8mm_thermal device_cooling nvmem_imx_ocotp dummy_battery gpio_switch dwc3_imx8mp panel_simple panel_jadard_jd9365da_h3 panel_raydium_rm67191 sec_mim
[ 270.153933] CPU: 3 PID: 1903 Comm: gst-launch-1.0 Tainted: G C O 5.10.72-g44cf7994ab03-dirty #35
[ 270.167393] Hardware name: LATAM R11 (DT)
[ 270.174958] pstate: 20400085 (nzCv daIf +PAN -UAO -TCO BTYPE=--)
[ 270.184520] pc : usb_function_activate+0x88/0x94
[ 270.192685] lr : usb_function_activate+0x28/0x94
[ 270.200852] sp : ffffffc0289fba80
[ 270.207720] x29: ffffffc0289fba80 x28: 0000000000000243
[ 270.216583] x27: 0000000000020002 x26: ffffff8012c7ca00
[ 270.225447] x25: ffffff80112789c0 x24: ffffff80da80dba8
[ 270.234311] x23: 0000000000000000 x22: ffffff80ca0ee600
[ 270.243175] x21: ffffff80c9170000 x20: ffffff80ca16d470
[ 270.252039] x19: ffffff80ca16d500 x18: ffffffc02815d078
[ 270.260908] x17: 0000000000000002 x16: ffffffffffffffff
[ 270.269767] x15: 0000000000000030 x14: 0000000000000006
[ 270.278631] x13: ffffff80112789c8 x12: 00000000534f434b
[ 270.287495] x11: 0000000000000000 x10: 0000000000000001
[ 270.296358] x9 : 0000000000000000 x8 : 0000000000000000
[ 270.305222] x7 : 0000000000000000 x6 : 000000000000003f
[ 270.314087] x5 : 0000000000000040 x4 : 0000000000000100
[ 270.322950] x3 : ffffff80df044e00 x2 : ffffff80df044e00
[ 270.331815] x1 : 0000000000000000 x0 : 0000000000000000
[ 270.340678] Call trace:
[ 270.346682] usb_function_activate+0x88/0x94
[ 270.354502] uvc_function_connect+0x20/0x60
[ 270.362238] uvc_v4l2_open+0x68/0x8c
[ 270.369366] v4l2_open+0xe0/0x11c
[ 270.376234] chrdev_open+0x1c4/0x230
[ 270.383361] do_dentry_open+0x234/0x42c
[ 270.390749] vfs_open+0x30/0x40
[ 270.397442] path_openat+0x8b8/0xaf0
[ 270.404570] do_filp_open+0x7c/0x12c
[ 270.411698] do_sys_openat2+0x80/0x168
[ 270.419000] __arm64_sys_openat+0x74/0xa0
[ 270.426564] el0_svc_common+0xb8/0x1a4
[ 270.433863] do_el0_svc+0x28/0x7c
[ 270.440731] el0_svc+0x14/0x24
[ 270.447338] el0_sync_handler+0x6c/0xb4
[ 270.454726] el0_sync+0x1b4/0x1c0
[ 270.461592] ---[ end trace e38e44029c5dcd28 ]---
[ 270.469865] configfs-gadget gadget: uvc: UVC connect failed with -22
[ 270.479836] configfs-gadget gadget: uvc: uvc_function_disable()
so how to enable UVC+UAC composite gadget on imx8mp android 11 bsp?