参考文档:\doc\开发使用说明\USB使用说明文档\设备\USB_UVC\xburst2\USB_UVC.pdf
一、内核添加USB UVC功能
1、确定所用dts文件
进入到/tools/iconfigtool/IConfigToolApp/路径下,执行./IConfigTool
选择config文件,查看kernel默认配置
配置文件为x2000_module_base_linux_sfc_nand_defconfig,然后退出。
2、查看内核所用dts文件
cd kernel/kernel-x2000/
make x2000_module_base_linux_sfc_nand_defconfig
make menuconfig
目标位于
-> Machine selection
-> SOC Type Selection
所用dts文件为x2000_module_base.dts,
文件位置:\kernel\kernel-x2000\arch\mips\boot\dts\ingenic\x2000_module_base.dts
3、修改otg节点的内容
&otg {
// g-use-dma;
dr_mode = "otg";
status = "okay";
};
改为
&otg {
g-use-dma;
dr_mode = "otg";
status = "okay";
};
4、修改config文件
执行命令:
cd kernel/kernel-x2000/
make x2000_module_base_linux_sfc_nand_defconfig
make menuconfig
Device Drivers --->
<*> Multimedia support --->
[*] Cameras/video grabbers support
Device Drivers --->
[*] USB support --->
<*> USB Gadget Support --->
<*> USB Gadget Drivers(USB functions configurable through configfs) --->
[*] USB Webcam function
如下图所示:
保存配置文件,执行命令:
cp .config arch/mips/configs/x2000_module_base_linux_sfc_nand_defconfig
5、重新编译固件
cd 到build路径,执行命令:
make x2100_nand_defconfig
make kernel
二、编译应用
将\doc\开发使用说明\USB使用说明文档\设备 路径下的USB_UVC拷贝到\demo下
进入到\demo\USB_UVC\xburst2目录,然后编译代码:
$ cd demos/USB_UVC/xburst2/
$ ../../../buildroot/buildroot/output/host/usr/bin/mips-linux-gnu-gcc uvc-camera.c uvc_lib.c -lhardware2 -o uvc-camera
编译之后会生成uvc-camera文件。
三、将应用推送到设备
adb push uvc-camera uvc-device-config.sh /usr/data
四、测试
1、关闭adb功能
/etc/init.d/S90adb stop
2、修改文件权限
# chmod 755 ./uvc-device-config.sh
# chmod 755 uvc-camera
3、配置UVC参数
# cd usr/data/
# ./uvc-device-config.sh start uvc-ch0:format=yuyv,1280,720,1000000/package_size=2048
Creating the USB gadget
Creating gadget directory uvc_demo
Setting Device Descriptor
Setting English strings
Creating Config
Creating functions...
/sys/kernel/config/usb_gadget/uvc_demo
/sys/kernel/config/usb_gadget/uvc_demo
/sys/kernel/config/usb_gadget/uvc_demo
/sys/kernel/config/usb_gadget/uvc_demo
/sys/kernel/config/usb_gadget/uvc_demo
# ls /dev/video*
/dev/video0 /dev/video1 /dev/video12 /dev/video2 /dev/video3
4、预览单路UVC摄像头,运行命令:
# ./uvc-camera /dev/vic0 video_device=/dev/video12 format=yuyv,1280,720,10 packa
ge_size=2048 io_method=mmap nbufs=3
streaming request (req 81 cs 01)
streaming request (req 01 cs 01)
setting probe control, length = 26
streaming request (req 81 cs 01)
streaming request (req 83 cs 01)
streaming request (req 82 cs 01)
streaming request (req 01 cs 01)
setting probe control, length = 26
streaming request (req 81 cs 01)
streaming request (req 01 cs 02)
setting commit control, length = 26
UVC: Buffer 0 mapped at address 0x77722000.
UVC: Buffer 1 mapped at address 0x77560000.
UVC: Buffer 2 mapped at address 0x7739e000.
UVC: 3 buffers allocated.
[ 660.949174] ## VIC WARN status = 0x00000020
执行命令之后,电脑上的设备管理器,照相机下会多一个UVC Camera的相机。
5、电脑上预览摄像头画面
打开电脑的 相机应用 即可预览摄像头的画面