uvc摄像头代码解析1

一.FAQ

1.判断自己的摄像头是否支持uvc标准
输入lsusb //列出usb设备
[cpp]  
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  
Bus 001 Device 003: ID 0c45:62f1 Microdia                       //摄像头  
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub  
Bus 002 Device 002: ID 1a40:0101 TERMINUS TECHNOLOGY INC.   
Bus 002 Device 003: ID 17ef:6025 Lenovo   
更详细的树形图lsusb -t
[cpp] 
/:  Bus 02.Port 1: Dev 1, class="root_hub", Driver=musb-hdrc/1p, 480M  
    |__ Port 1: Dev 2, If 0, class="hub", Driver=hub/4p, 480M  
/:  Bus 01.Port 1: Dev 1, class="root_hub", Driver=musb-hdrc/1p, 480M  
    |__ Port 1: Dev 4, If 0, Class='bInterfaceClass 0x0e not yet handled', Driver=, 480M  
    |__ Port 1: Dev 4, If 1, Class='bInterfaceClass 0x0e not yet handled', Driver=, 480M  
    |__ Port 1: Dev 4, If 2, class="audio", Driver=snd-usb-audio, 480M  
    |__ Port 1: Dev 4, If 3, class="audio", Driver=snd-usb-audio, 480M  
lsusb -d 0c45:62f1 -v | grep "14 Video" 检测设备属性
[cpp]  
bFunctionClasss      14 Video  
bInterfaceClass        14 Video  
bInterfaceClass        14 Video  
bInterfaceClass        14 Video  
bInterfaceClass        14 Video  
bInterfaceClass        14 Video  
bInterfaceClass        14 Video  
bInterfaceClass        14 Video  
bInterfaceClass        14 Video  
显示类似上面信息表示该摄像头是支持uvc标准的
2.使能/关闭调试的trace打印信息
[cpp] 
echo 0xffff > /sys/module/uvcvideo/parameters/trace  
echo 0 > /sys/module/uvcvideo/parameters/trace  
3.播放测试
[cpp] view plaincopy
mplayer tv:// -tv fps=25  
 
二.uvc类标准
1.下载标准协议地址
[cpp]  
http://www.usb.org/developers/devclass_docs  
2.功能特性(翻译)
Each video function has a single VideoControl (VC) interface and can have several VideoStreaming (VS) interfaces
每个视频有且仅有1个VideoControl (VC)接口和可有多个 VideoStreaming (VS) 接口
The VideoControl (VC) interface is used to access the device controls of the function whereas
the VideoStreaming (VS) interfaces are used to transport data streams into and out of the function.
VC接口用于设备功能控制,VS接口用于传输数据流进出
Video Interface Class Code(A.1 P171)
视频接口类代码 就是宏定义的USB_CLASS_VIDEO
总共有3种子类subclass
1.VideoControl Interface 视频控制接口子类
2.VideoStreaming Interface 视频数据流接口子类
3.Video Interface Collection 视频接口集合子类
宏定义
[cpp] v 
/* A.2. Video Interface Subclass Codes */  
#define UVC_SC_UNDEFINED                        0x00  
#define UVC_SC_VIDEOCONTROL                     0x01  
#define UVC_SC_VIDEOSTREAMING                   0x02  
#define UVC_SC_VIDEO_INTERFACE_COLLECTION       0x03  
Units provide the basic building blocks to fully describe most video functions ,A Unit has one or more Input Pins and a single Output Pin,
Unit提供了基础模块来全面描述大部分的视频功能,一个Unit可以由一个或多个输入引脚和仅一个输出引脚(这里的每一个pin代表一个逻辑上的数据流)
原文地址:https://www.cnblogs.com/senior-engineer/p/4882470.html