v4l2

本文深入分析了V4L2(Video for Linux Two)驱动的工作流程,包括以vivi.c为例的设备注册、ioctl处理,特别是摄像头驱动必需的11个ioctl函数的介绍。此外,详细探讨了数据获取的过程,从请求缓冲区、查询映射到启动摄像头、数据产生和唤醒机制,以及应用程序如何读取数据。
摘要由CSDN通过智能技术生成

一.以vivi.c为例,分析v4l2流程:

a.分配video_device结构体  b.设置  c.注册: video_register_device();

1.分配:
vfd = video_device_alloc();
	if (!vfd)
		goto unreg_dev;
2.设置:
    /*************************control设置**************************/
    dev->volume = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops,
			V4L2_CID_AUDIO_VOLUME, 0, 255, 1, 200);
	dev->brightness = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops, //亮度信息设置,最大最小值等
			V4L2_CID_BRIGHTNESS, 0, 255, 1, 127);
	dev->contrast = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops,
			V4L2_CID_CONTRAST, 0, 255, 1, 16);
	dev->saturation = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops,
			V4L2_CID_SATURATION, 0, 255, 1, 127);
	dev->hue = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops,
			V4L2_CID_HUE, -128, 127, 1, 0);
	dev->autogain = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops,
			V4L2_CID_AUTOGAIN, 0, 1, 1, 1);
	dev->gain = v4l2_ctrl_new_std(hdl, &vivi_ctrl_ops,
			V4L2_CID_GAIN, 0, 255, 1, 100);
	dev->button = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_button, NULL);
	dev->int32 = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_int32, NULL);
	dev->int64 = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_int64, NULL);
	dev->boolean = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_boolean, NULL);
	dev->menu = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_menu, NULL);
	dev->string = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_string, NULL);
	dev->bitmask = v4l2_ctrl_new_custom(hdl, &vivi_ctrl_bitmask, NULL);

	dev->v4l2_dev.ctrl_handler = hdl

	vfd->v4l2_dev = &dev->v4l2_dev;
	*vfd = vivi_template;
	vfd->debug = debug;

3.注册:
ret = video_register_device(vfd, VFL_TYPE_GRABBER, video_nr);
static struct video_device vivi_template = {
	.name		= "vivi",
	.fops           = &vivi_fops,    
	.ioctl_ops 	= &vivi_ioctl_ops,
	.release
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值