UVC REFERENCE


1. Hardware

When using EVB as a USB device, please disconnect JP84 and connect JP87.

Check whether R456 and R457 are soldered (the default is not), if not, mini-USB cannot be used, only USB type A can be used.


2. Software


2.1. Kernel Config

There are two ways to increase the uvc config on the basis of the existing config:

  1. Modify the current default configuration directly (recommended)

    Such as the current EVB config: pioneer3_ssc020a_s01a_defconfig

    Add the following contents:

    CONFIG_MEDIA_SUPPORT=m
    CONFIG_MEDIA_CAMERA_SUPPORT=y
    CONFIG_MEDIA_CONTROLLER=y
    CONFIG_VIDEO_DEV=m
    CONFIG_VIDEO_V4L2=m
    CONFIG_VIDEOBUF2_CORE=m
    CONFIG_VIDEOBUF2_MEMOPS=m
    CONFIG_VIDEOBUF2_VMALLOC=m
    CONFIG_MEDIA_SUBDRV_AUTOSELECT=y
    CONFIG_USB_GADGET=m
    CONFIG_USB_GADGET_VBUS_DRAW=2
    CONFIG_USB_GADGET_STORAGE_NUM_BUFFERS=2
    CONFIG_USB_GADGET_SSTAR_DEVICE=m
    CONFIG_USB_AVOID_SHORT_PACKET_IN_BULK_OUT_WITH_DMA_FOR_ETHERNET=y
    CONFIG_USB_LIBCOMPOSITE=m
    CONFIG_SS_GADGET=m
    CONFIG_USB_F_UVC=m
    CONFIG_USB_G_WEBCAM=m
    CONFIG_USB_WEBCAM_UVC=y
    CONFIG_MULTI_STREAM_FUNC_NUM=1
    

    See diff file for details.

  2. Use current default config

    1. Code

      cd kernel;./list_config.sh
      
      make pioneer3_ssc020a_s01a_defconfig
      
    2. Add: make menuconfig

      1. media frame config

        Device Drivers
        
        Multimedia support
        
        Device Drivers
        
        Multimedia support
        
        Cameras/video grabbers support
        
        Device Drivers
        
        Multimedia support
        
        Media Controller API
        

        Output module: media.ko videodev.ko v4l2-common.ko

      2. usb Gadget frame config

        Device Drivers
        
        USB support
        
        Device Drivers
        
        USB support
        
        USB Gadget Support
        

        Output module: usb-common.ko udc-core.ko

      3. udc driver config: this is a HW IP related module, configured according to the specific situation.

        Device Drivers
        
        USB support
        
        USB Gadget Support
        
        USB Peripheral Controller
        
        Sstar USB 2.0 Device Controller
        

        Output module: udc-msb250x.ko

      4. gadget webcam

        Device Drivers
        
        USB support
        
        USB Gadget Support
        
        USB Gadget Drivers
        
        Device Drivers
        
        USB support
        
        USB Gadget Support
        
        USB Gadget Drivers
        
        USB Webcam Gadget
        
        Device Drivers
        
        USB support
        
        USB Gadget Support
        
        USB Peripheral Controller
        
        Sstar USB 2.0 Device Controller
        
        Avoid short packet in bulk out with DMA for ethernet
        

        Output module: libcomposite.ko videobuf2-core.ko videobuf2-v4l2.ko

        videobuf2-memops.ko videobuf2-vmalloc.ko

        usb_f_uvc.ko g_webcam.ko


2.2. Project Config

Because there is no UVC related configuration added, the following files need to be manually modified when compiling the uvc function.

  1. If you use the second way in the kernel config, please modify the project/makefile and comment $(MAKE)linux-kernel in image to avoid overwriting the manual compilation when recompiling the kernel;

  2. Add the following cotents in project/kbuild/customize/4.9.84/p3/dispcam/kernel_mod_list.

    media.ko
    videodev.ko
    v4l2-common.ko
    videobuf2-core.ko use_mi_buf=1
    videobuf2-v4l2.ko
    videobuf2-memops.ko
    videobuf2-vmalloc.ko
    udc-core.ko
    libcomposite.ko
    usb_f_uvc.ko
    udc-msb250x.ko
    g_webcam.ko streaming_maxpacket=3072 streaming_maxburst=13 uac_function_enable=0
    

3. APP Test

Use mi_demo to test, enter sdk/verify/mi\_demo/alderaan and execute make uvc, after successful compilation, you can get prog_uvc in sdk\verify\mi_demo\out\demo\app, copy it to the board and run ./prog_uvc. Without parameters, pad0 is used by default. Use -a to specify sensor pad (For example: ./prog_uvc -a1 specifies the image of pad 1), and use prog_uvc-h to print all supported parameters.

After prog_uvc is running, connect to PC by usb, and use potplayer (or other similar programs) to open the camera on PC.

Take potplayer as an example, use ctrl+j to open camera after running.

Right-click in the video preview area, you can modify the video stream parameters in the "Capture Properties" in the following path.