4.USB摄像头驱动框架分析

      Linux系统中USB摄像头一般都采用的是UVC硬件架构设计,因此我们在分析USB摄像头驱动的重点在于分析UVC框架。它融合了usb驱动框架和v4l2驱动框架,我们可以从中抽象出一个通用的USB摄像头驱动框架。

uvc架构官方手册参考网上:uvc 1.5 specifications

http://www.usb.org/developers/docs/devclass_docs/  的Video Class的Video Class 1.5 document set 
只需查看UVC 1.5 Class specification  和  USB_Video_Example 1.5
在USB_Video_Example 1.5 里的12页USB Video Camera Topology 即可大致了解USB摄像头大致框架

Video functions are addressed through their video interfaces. Each video function has a single
VideoControl (VC) interface and can have several VideoStreaming (VS) interfaces. 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.


这个uvc框架包含两大接口:
1. VideoControl (VC) interface:
控制接口 包含 CT(Camera Terminal) IT(Input Terminal) OT(Output Terminal) SU(Selector Unit) PU (Process Unit)

2.VideoStreaming (VS)interface:
视频数据接口,主要产生视频数据

一、USB摄像头驱动框架:
1.构造一个usb_driver结构体
2.设置
  在probe函数中:
分配video_device :video_device_alloc
设置:fops,ioctl_fops(里面有11项)
     如果要用内核提供的缓冲区操作函数,还要构造一个video_buf_queue_ops
注册:video_register_device
  id_table:表示支持哪些usb设备
3.注册


在Linux内核里自带usb摄像头驱动程序,它支持uvc规格的摄像头(uvc即usb video class),它在drivers/media/video/uvc 下的uvc_driver.c。

以下是uvc_driver.c 分析:

从入口函数开始
uvc_init
usb_register(&uvc_driver.driver);

struct uvc_driver uvc_driver = {
.driver = {
.name = "uvcvideo",
.probe = uvc_probe,
.disconnect = uvc_disconnect,
.suspend = uvc_suspend,
.resume = uvc_resume,

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值