linux v4l2系统详解,Linux摄像头驱动学习之:(一)V4L2_框架分析

这段时间开始搞安卓camera底层驱动了,把以前的的Linux视频驱动回顾一下,本篇主要概述一下vfl2(video for linux 2).

一. V4L2框架: video for linux version 2

虚拟视频驱动vivi.c分析:

1.分配video_device

2.设置

3.注册:video_register_device

vivi_init

vivi_create_instance

v4l2_device_register   // 不是主要, 只是用于初始化一些东西,比如自旋锁、引用计数

video_device_alloc

// 设置

1. vfd:

.fops           = &vivi_fops,

.ioctl_ops  = &vivi_ioctl_ops,

.release = video_device_release,

2.

vfd->v4l2_dev = &dev->v4l2_dev;

3. 设置"ctrl属性"(用于APP的ioctl):

v4l2_ctrl_handler_init(hdl, 11);

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);

video_register_device(video_device, type:VFL_TYPE_GRABBER, nr)

__video_register_device

vdev->cdev = cdev_alloc();

vdev->cdev->ops = &v4l2_fops;

cdev_add

video_device[vdev->minor] = vdev;

if (vdev->ctrl_handler == NULL)

vdev->ctrl_handler = vdev-

你可能感兴趣的:(linux,v4l2系统详解)