您的位置:首页 > 其它

知识精华部分

2015-09-10 17:07 316 查看
*************************************************************************************************

vivi_dev *dev //这个设备定义了vivi_dev摄像头驱动的结构体

程序的思路:(1)最重要的是vivi_dev这个抽象出来的设备,即*dev。它其实定义了一个vivi虚拟摄像头设备,其中有相机的照片大
小、v4l2_ctrl结构体、video_device设备等结构体成员。在vivi_init()函数中完成了height width/v4l2_ctrl的 赋值,对于video_device,定义了vfd这个变量,将vivi_template{ .fops = ;. ioctl = ;...}赋值给了vfd。

(2)video_register_device()函数中完成了对vfd这个video_device这个结构体的赋值,其中主要是对vfd->cdev的赋值

vdev->cdev = cdev_alloc();

vdev->cdev->ops = &v4l2_fops;

vdev->cdev->owner = owner;

其中:stuct file_operation v4l2_fops =

{ .owner = ;

.read = v4l2_read;

......}

另外一个成员vfd->dev这个成员进行了注册device_register(&vdev->dev); video_device结构体中包含了cdev
和 device dev两个成员变量。

(3)最后将dev->vfd = vfd; 完成对vivi_dev的赋值。

总结:vivi_dev包含了video_device重要成员,video_device中包含了cdev/dev/*ioctl_ops/*fops(v4l2_file_operateion)成员,

而cdev中又包含了ops/owner等成员。

/video_device只是一个vivi_dev摄像头设备的一个重要部分而已。

*************************************************************************************************

vivi.c中的头文件包含:

vivi.c包含头文件v4l2-device.h和v4l2-ioctl.h,其中v4l2-device.h中包含了v4l2-subdev.h,v4l2-subdev.h中又包含了v4l2-common.h,v4l2-common.h中包含了v4l2-dev.h。vivi.h

在v4l2-dev.h中定义了结构体video_device和v4l2_file_operations;

在v4l2-ioctl.h中定义了结构体v4l2_ioctl_ops;

在v4l2-device.h中定义了结构体v4l2_device、v4l2_file_operation结构;

struct v4l2_capability/v4l2_cropcap/v4l2_crop在/include/linux/videodev2.h定义

其中cap为struct v4l2_capability;

/include/linux/videodev2.h定义,v4l2_cropcap/v4l2_crop也在其中有定义。

struct v4l2_capability

{

__u8 driver[16];

__u8 card[32];

__u8 bus_info[32];

__u32 version;

__u32 capabilities;

__u32 device_caps;

__u32 reserved[3];

}

video_capability在videodev.h中定义的,在linux-3.4.2中已经没有这个文件了!!!

struct video_capability

{

char name[32];

int type;

int channels;

int audios;

int maxwidth;

int maxheight;

int minwidth;

int minheight;

}

结构体包含关系

struct video_device

->vivi_fops (v4l2_file_operations)

->vivi_ioctl_ops(v4l2_ioctl_ops)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: