VIDIOC_REQBUFS: 分配内存
VIDIOC_QUERYBUF: 把VIDIOC_REQBUFS中分配的数据缓存转换成物理地址
VIDIOC_QUERYCAP: 查询驱动功能
VIDIOC_ENUM_FMT: 获取当前驱动支持的视频格式
VIDIOC_S_FMT: 设置当前驱动的频捕获格式
VIDIOC_G_FMT: 读取当前驱动的频捕获格式
VIDIOC_TRY_FMT: 验证当前驱动的显示格式
VIDIOC_CROPCAP: 查询驱动的修剪能力
VIDIOC_S_CROP: 设置视频信号的边框
VIDIOC_G_CROP: 读取视频信号的边框
VIDIOC_QBUF: 把数据放回缓存队列
VIDIOC_DQBUF: 把数据从缓存中读取出来
VIDIOC_STREAMON: 开始视频显示函数
VIDIOC_STREAMOFF: 结束视频显示函数
VIDIOC_QUERYSTD: 检查当前视频设备支持的标准,例如PAL或NTSC。
常用的结构体(参见/usr/include/linux/videodev2.h):
struct v4l2_requestbuffers reqbufs; //向驱动申请帧缓冲的请求,里面包含申请的个数
struct v4l2_capability cap; //这个设备的功能,比如是否是视频输入设备
struct v4l2_input input; //视频输入
struct v4l2_standard std; //视频的制式,比如PAL,NTSC
struct v4l2_format fmt; //帧的格式,比如宽度,高度等
struct v4l2_buffer buf; //代表驱动中的一帧
v4l2_std_id stdid; //视频制式,例如:V4L2_STD_PAL_B
struct v4l2_queryctrl query; //查询的控制
struct v4l2_control control; //具体控制的值
///
struct v412_standard 结构体:
- typedef u64 v4l2_std_id;
- struct v4l2_standard {
- u32 index;
- v4l2_std_id id;
- u8 name[24];
- struct v4l2_fract frameperiod;
- u32 framelines;
- u32 reserved[4];
- };
///
struct v412_input 结构体:
- struct v4l2_input {
- __u32 index;
- __u8 name[32];
- __u32 type;
- __u32 audioset;
- __u32 tuner;
- v4l2_std_id std;
- __u32 status;
- __u32 reserved[4];
- };
///
struct v412_crop 结构体:
- struct v4l2_crop
- {
- enum v4l2_buf_type type;
- struct v4l2_rect c;
- }
////
struct v412_cropcap 结构体:
- struct v4l2_cropcap
- {
- enum v4l2_buf_type type;
- struct v4l2_rect bounds;
- struct v4l2_rect defrect;
- struct v4l2_fract pixelaspect;
- };
////
stuct v412_fmtdesc结构体:
- struct v4l2_fmtdesc
- {
- u32 index;
- enum v4l2_buf_type type;
- u32 flags;
- u8 description[32];
- u32 pixelformat;
- u32 reserved[4];
- };
////
struct v412_capability结构体:
- struct v4l2_capability
- {
- u8 driver[16];
- u8 card[32];
- u8 bus_info[32];
- u32 version;
- u32 capabilities;
- u32 reserved[4];
- };
其中域 capabilities 代表设备支持的操作模式,常见的值有 V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_STREAMING 表示是一个视频捕捉设备并且具有数据流控制模式;另外 driver 域需要和 struct video_device 中的 name 匹配
/////
v4l2_format 结构如下:
- struct v4l2_format {
- enum v4l2_buf_type type;
- union {
- struct v4l2_pix_format pix;
- struct v4l2_window win;
- struct v4l2_vbi_format vbi;
- struct v4l2_sliced_vbi_format sliced;
- __u8 raw_data[200];
- } fmt;
- };
- 其中
- enum v4l2_buf_type {
- V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
- V4L2_BUF_TYPE_VIDEO_OUTPUT = 2,
- V4L2_BUF_TYPE_VIDEO_OVERLAY = 3,
- ...
- V4L2_BUF_TYPE_PRIVATE = 0x80,
- };
-
- struct v4l2_pix_format {
- __u32 width;
- __u32 height;
- __u32 pixelformat;
- enum v4l2_field field;
- __u32 bytesperline;
- __u32 sizeimage;
- enum v4l2_colorspace colorspace;
- __u32 priv;
- };
/////
struct v412_requestbuffers结构体如下:
- struct v4l2_requestbuffers
- {
- __u32 count;
- enum v4l2_buf_type type;
- enum v4l2_memory memory;
- __u32 reserved[2];
- };
- enum v4l2_memory {
- V4L2_MEMORY_MMAP = 1,
- V4L2_MEMORY_USERPTR = 2,
- V4L2_MEMORY_OVERLAY = 3,
- };
/
typedef struct VideBuffer结构体:
- typedef struct VideoBuffer {
- void *start;
- size_t length;
- } VideoBuffer;
/////
stuct v412_buffer结构体
- truct v4l2_buffer
- {
- u32 index;
- enum v4l2_buf_type type;
- u32 byteused;
- u32 flags;
- enum v4l2_field field;
- struct timeval timestamp;
- struct v4l2_timecode timecode;
- u32 sequence;
- enum v4l2_memory memory;
- union m{
- u32 offset;
- unsigned long userptr;
- };
- u32 length;
- u32 input;
- u32 reserved;
- };