0

The linux kernel version 4.9.37 adds the necessary UVC and UAC components, as well as the USB sound card component. A shell script was executed to configure the device information, and then the ko driver provided by the ARM device was executed. The result is that UVC device works fine, UAC only has playback device "/dev/snd/pcmC0D0p" and control device "/dev/snd/controlC0", no recording device "/dev/snd/pcmC0D0c ". How to add the recording device "/dev/snd/pcmC0D0c"?

The following components have been added to the kernel version 4.9.37:

CONFIG_USB_LIBCOMPOSITE=y
CONFIG_USB_F_ACM=y
CONFIG_USB_U_SERIAL=y
CONFIG_USB_U_ETHER=y
CONFIG_USB_U_AUDIO=y
CONFIG_USB_F_ECM=y
CONFIG_USB_F_RNDIS=y
CONFIG_USB_F_MASS_STORAGE=y
CONFIG_USB_F_UAC1=y
CONFIG_USB_F_UAC2=y
CONFIG_USB_F_UVC=y
CONFIG_USB_CONFIGFS=y
CONFIG_USB_CONFIGFS_F_UAC1=y
CONFIG_USB_CONFIGFS_F_UAC2=y
CONFIG_SOUND=y
CONFIG_SND=y
CONFIG_SND_PCM=y
CONFIG_SND_RAWMIDI=y
CONFIG_SND_USB=y
CONFIG_SND_USB_AUDIO=y
CONFIG_MEDIA_SUPPORT=y
CONFIG_MEDIA_CAMERA_SUPPORT=y
CONFIG_VIDEO_DEV=y
CONFIG_VIDEO_V4L2=y
CONFIG_VIDEOBUF_GEN=y
CONFIG_VIDEOBUF2_CORE=y
CONFIG_VIDEOBUF2_MEMOPS=y
CONFIG_VIDEOBUF2_VMALLOC=y
CONFIG_MEDIA_USB_SUPPORT=y
CONFIG_USB_VIDEO_CLASS=y
CONFIG_USB_VIDEO_CLASS_INPUT_EVDEV=y
CONFIG_V4L_PLATFORM_DRIVERS=y

The following shell script is the configuration script for UVC and UAC.

#!/bin/sh

mount -t configfs none /sys/kernel/config/
cd /sys/kernel/config/usb_gadget/
mkdir camera
cd camera

echo "0x01" > bDeviceProtocol
echo "0x02" > bDeviceSubClass
echo "0xEF" > bDeviceClass
echo $VID > idVendor
echo $PID > idProduct
mkdir strings/0x409
echo $MANUFACTURER > strings/0x409/manufacturer
echo $PRODUCT > strings/0x409/product
echo $SERIALNUMBER > strings/0x409/serialnumber

mkdir functions/uvc.usb0
cd functions/uvc.usb0
mkdir control/header/h/
echo "0x0110" > control/header/h/bcdUVC
echo "48000000" > control/header/h/dwClockFrequency
ln -s control/header/h/ control/class/fs/
ln -s control/header/h/ control/class/ss/

#YUV
mkdir streaming/uncompressed/u/
for i in $YUV
do
    if [ $i = 360p ];then
        mkdir streaming/uncompressed/u/360p/                                     
    echo "333333" > streaming/uncompressed/u/360p/dwFrameInterval           
    echo "333333" > streaming/uncompressed/u/360p/dwDefaultFrameInterval           
    echo "55296000" > streaming/uncompressed/u/360p/dwMaxBitRate            
    echo "460800" > streaming/uncompressed/u/360p/dwMaxVideoFrameBufferSize  
    echo "55296000" > streaming/uncompressed/u/360p/dwMinBitRate     
    echo "360" > streaming/uncompressed/u/360p/wHeight                       
    echo "640" > streaming/uncompressed/u/360p/wWidth
    elif [ $i = 720p ];then
        mkdir streaming/uncompressed/u/720p/                                     
    echo "333333" > streaming/uncompressed/u/720p/dwFrameInterval           
    echo "333333" > streaming/uncompressed/u/720p/dwDefaultFrameInterval   
    echo "29491200" > streaming/uncompressed/u/720p/dwMaxBitRate             
    echo "1843200" > streaming/uncompressed/u/720p/dwMaxVideoFrameBufferSize
    echo "29491200" > streaming/uncompressed/u/720p/dwMinBitRate             
    echo "720" > streaming/uncompressed/u/720p/wHeight               
    echo "1280" > streaming/uncompressed/u/720p/wWidth
    elif [ $i = 1080p ];then
        mkdir streaming/uncompressed/u/1080p/                                    
    echo "333333" > streaming/uncompressed/u/1080p/dwFrameInterval           
    echo "333333" > streaming/uncompressed/u/1080p/dwDefaultFrameInterval
    echo "29491200" > streaming/uncompressed/u/1080p/dwMaxBitRate            
    echo "4147200" > streaming/uncompressed/u/1080p/dwMaxVideoFrameBufferSize
    echo "29491200" > streaming/uncompressed/u/1080p/dwMinBitRate          
    echo "1080" > streaming/uncompressed/u/1080p/wHeight              
    echo "1920" > streaming/uncompressed/u/1080p/wWidth
    else
        echo "YUV $i is invalid!"
    fi
done

#MJPEG
mkdir streaming/mjpeg/m/
for i in $MJPEG
do
    if [ $i = 360p ];then
        mkdir streaming/mjpeg/m/360p/                                            
    echo "333333" > streaming/mjpeg/m/360p/dwFrameInterval                  
    echo "333333" > streaming/mjpeg/m/360p/dwDefaultFrameInterval
    echo "10240000" > streaming/mjpeg/m/360p/dwMaxBitRate                   
    echo "460800" > streaming/mjpeg/m/360p/dwMaxVideoFrameBufferSize        
    echo "10240000" > streaming/mjpeg/m/360p/dwMinBitRate                   
    echo "360" > streaming/mjpeg/m/360p/wHeight                       
    echo "640" > streaming/mjpeg/m/360p/wWidth 
    elif [ $i = 720p ];then
        mkdir streaming/mjpeg/m/720p/                                       
    echo "333333" > streaming/mjpeg/m/720p/dwFrameInterval                   
    echo "333333" > streaming/mjpeg/m/720p/dwDefaultFrameInterval
    echo "20480000" > streaming/mjpeg/m/720p/dwMaxBitRate                    
    echo "1843200" > streaming/mjpeg/m/720p/dwMaxVideoFrameBufferSize        
    echo "20480000" > streaming/mjpeg/m/720p/dwMinBitRate                    
    echo "720" > streaming/mjpeg/m/720p/wHeight                              
    echo "1280" > streaming/mjpeg/m/720p/wWidth 
    elif [ $i = 1080p ];then
        mkdir streaming/mjpeg/m/1080p/                                    
    echo "333333" > streaming/mjpeg/m/1080p/dwFrameInterval             
    echo "333333" > streaming/mjpeg/m/1080p/dwDefaultFrameInterval
    echo "40960000" > streaming/mjpeg/m/1080p/dwMaxBitRate            
    echo "4147200" > streaming/mjpeg/m/1080p/dwMaxVideoFrameBufferSize       
    echo "40960000" > streaming/mjpeg/m/1080p/dwMinBitRate                   
    echo "1080" > streaming/mjpeg/m/1080p/wHeight                            
    echo "1920" > streaming/mjpeg/m/1080p/wWidth 
    elif [ $i = 2160p ];then
        mkdir streaming/mjpeg/m/2160p/                                     
    echo "333333" > streaming/mjpeg/m/2160p/dwFrameInterval            
    echo "333333" > streaming/mjpeg/m/2160p/dwDefaultFrameInterval
    echo "61440000" > streaming/mjpeg/m/2160p/dwMaxBitRate             
    echo "16588800" > streaming/mjpeg/m/2160p/dwMaxVideoFrameBufferSize
    echo "61440000" > streaming/mjpeg/m/2160p/dwMinBitRate          
    echo "2160" > streaming/mjpeg/m/2160p/wHeight                   
    echo "3840" > streaming/mjpeg/m/2160p/wWidth
    else
        echo "MJPEG $i is invalid!"
    fi
done

#FRAMEBASED
mkdir streaming/framebased/fb/
for i in $H264
do
    if [ $i = 360p ];then
        mkdir streaming/framebased/fb/360p/                                      
    echo "333333" > streaming/framebased/fb/360p/dwFrameInterval     
    echo "333333" > streaming/framebased/fb/360p/dwDefaultFrameInterval
    echo "8192000" > streaming/framebased/fb/360p/dwMaxBitRate               
    echo "8192000" > streaming/framebased/fb/360p/dwMinBitRate               
    echo "360" > streaming/framebased/fb/360p/wHeight                        
    echo "640" > streaming/framebased/fb/360p/wWidth
    elif [ $i = 720p ];then
        mkdir streaming/framebased/fb/720p/                                      
    echo "333333" > streaming/framebased/fb/720p/dwFrameInterval             
    echo "333333" > streaming/framebased/fb/720p/dwDefaultFrameInterval
    echo "10240000" > streaming/framebased/fb/720p/dwMaxBitRate            
    echo "10240000" > streaming/framebased/fb/720p/dwMinBitRate       
    echo "720" > streaming/framebased/fb/720p/wHeight                 
    echo "1280" > streaming/framebased/fb/720p/wWidth  
    elif [ $i = 1080p ];then
        mkdir streaming/framebased/fb/1080p/                                
    echo "333333" > streaming/framebased/fb/1080p/dwFrameInterval            
    echo "333333" > streaming/framebased/fb/1080p/dwDefaultFrameInterval
    echo "15360000" > streaming/framebased/fb/1080p/dwMaxBitRate            
    echo "15360000" > streaming/framebased/fb/1080p/dwMinBitRate            
    echo "1080" > streaming/framebased/fb/1080p/wHeight                     
    echo "1920" > streaming/framebased/fb/1080p/wWidth
    elif [ $i = 2160p ];then
        mkdir streaming/framebased/fb/2160p/                               
    echo "333333" > streaming/framebased/fb/2160p/dwFrameInterval      
    echo "333333" > streaming/framebased/fb/2160p/dwDefaultFrameInterval
    echo "30720000" > streaming/framebased/fb/2160p/dwMaxBitRate       
    echo "30720000" > streaming/framebased/fb/2160p/dwMinBitRate            
    echo "2160" > streaming/framebased/fb/2160p/wHeight                     
    echo "3840" > streaming/framebased/fb/2160p/wWidth
    else
        echo "H264 $i is invalid!"
    fi
done
mkdir streaming/header/h/                                                
ln -s streaming/uncompressed/u/ streaming/header/h/                 
ln -s streaming/mjpeg/m/ streaming/header/h/                        
ln -s streaming/framebased/fb/ 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/                            
                                                                         
#-Create and setup configuration
cd ../../                                                                

mkdir functions/uac1.usb0                                                       
echo "0x00" > functions/uac1.usb0/c_chmask

mkdir configs/c.1/                                                       
echo "0x01" > configs/c.1/MaxPower                                        
echo "0xc0" > configs/c.1/bmAttributes                                        
mkdir configs/c.1/strings/0x409/                                    
echo "Config 1" > configs/c.1/strings/0x409/configuration           

ln -s functions/uvc.usb0/ configs/c.1/                              
ln -s functions/uac1.usb0/ configs/c.1/

ls /sys/class/udc > UDC  

enter image description here

How can I get a recording device "/dev/snd/pcmC0D0c"?

Ken.Zhang
  • 1
  • 1
  • 1
    "*How can I get a recording device "/dev/snd/pcmC0D0c*"?" -- The Linux kernel is typically not responsible for creating device nodes nor populating the **/dev/** subdirectory. What is relevant is the form of device management employed by your system, e.g. **mdev** or **eudev** or ??? – sawdust Jun 29 '23 at 21:41
  • I understand that it is configured by USB Configfs, the configuration script in the problem description, I changed 0x00 in this sentence to 0x03: echo "0x00" > functions/uac1.usb0/c_chmask , and there is a recording device. But there is another problem, after the UVC device is connected to the computer, the speaker cannot play sound, it is in the state of disable, the speaker flag is an X, and it cannot be turned on. – Ken.Zhang Jul 01 '23 at 04:51

0 Answers0