看一下drivers/media/video下的Makefile你会发现:
videodev-objs:=v4l2-dev.o v4l2-ioctl.o v4l2-device.o v4l2-fh.o \
v4l2-event.o v4l2-ctrls.o v4l2-subdev.o
这是生成videodev.ko必要的文件。网上有很多讲解v4l2驱动编写的文章。推荐网址:
这是主要说用户使用:
http://linuxtv.org/downloads/v4l-dvb-apis/
这是说驱动编写:
http://lwn.net/Articles/203924/
对应的中文翻译(用户的不是很全)
http://download.csdn.net/detail/xxxxxlllllxl/7076235
我的博客将从Makefile中涉及的文件对应的头文件去分析:先从v4l2_dev.h开始
/*
*
* V 4 L 2 D R I V E R H E L P E R A P I
*
* Moved from videodev2.h//从videodev2.h中移出来的
*
* Some commonly needed functions for drivers (v4l2-common.o module)
*/
#ifndef _V4L2_DEV_H
#define _V4L2_DEV_H
#include <linux/poll.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/cdev.h>
#include <linux/mutex.h>
#include <linux/videodev2.h>
#include <media/media-entity.h>
#define VIDEO_MAJOR 81
//下面不同的宏生成的设备名不一样
#define VFL_TYPE_GRABBER 0 //"video"
#define VFL_TYPE_VBI 1 //"vbi"
#define VFL_TYPE_RADIO 2 //"radio"
#define VFL_TYPE_SUBDEV 3 //"v4l-subdev"
#define VFL_TYPE_MAX 4
struct v4l2_ioctl_callbacks;
struct video_device;
struct v4l2_device;
struct v4l2_ctrl_handler;
/* Flag to mark the video_device struct as registered.
Drivers can clear this flag if they want to block all future
device access. It is cleared by video_unregister_device. */
#define V4L2_FL_REGISTERED (0)//标记设备是否被注册
/* file->private_data points to struct v4l2_fh */
#define V4L2_FL_USES_V4L2_FH (1) //使用文件操作
/* Use the prio field of v4l2_fh for core priority checking */
#define V4