/*imx6摄像头部分代码分析*/
imx6代码结构.1
app
|
v4l2-dev.c(提供注册和应用app调用接口)
|
mxc_v4l2_capture.c (执行IOCTRL命令)
|
ov5640.c (执行真正摄像头硬件操作)
///
imx6代码结构.2
app
|
v4l2-dev.c (提供注册和应用app调用接口)
|
TW68-video.c TW68-core.c (执行IOCTRL命令)
//应用调用1
app open
|
..........................................................................
|
|
static int v4l2_open(struct inode *inode, struct file *filp) /*v4l2-dev.c*/
{ |
static int mxc_v4l_open(struct file *file) /*mxc_v4l2_capture.c*/
{ |
|
int vidioc_int_g_ifparm(struct v4l2_int_device *s) /*Ov5640.c*/
//应用调用2
ioctl
|
..........................................................................
video_usercopy(file, cmd, arg, __video_do_ioctl); /*v4l2-ioctl.c*/
|
|
..........................................................................
static long mxc_v4l_do_ioctl(struct file *file,unsigned int ioctlnr, void *arg)
| /*mxc_v4l2_capture.c*/
|
.........................................................................
static struct v4l2_int_ioctl_desc ov5640_ioctl_desc[] = {
/*ov5640.c*/
vivi.c 的调用过程
..........................................................................
ivi.c 注册过程
static int __init vivi_create_instance(int inst)
|
v4l2_device_register
|
INIT_LIST_HEAD(&dev->vidq.active);
|
init_waitqueue_head(&dev->vidq.wq);
|
*vfd =video_device_alloc
|
video_register_device(vfd, VFL_TYPE_GRABBER, video_nr);
..................................................................................................................................
app
|
open read write ioctl
....................................
| v4l2-dev.c
|
open read writ |
vdev-> |
fops-> |
open |
| |
....|...................|.....................................................................................................................
| | vivi.c |
int v4l2_fh_open(struct| file *filp) static const struct v4l2_ioctl_ops vivi_ioctl_ops = {
| .vidioc_querycap = vidioc_querycap,
| =======>
static long v4l2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) |
| |
| |
ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); |
| |
因为 vivi.c 中 .unlocked_ioctl = video_ioctl2 的定义 |
..............................................................................................v4l2-ioctl.c |
这里调用v | |
video_ioctl2(struct file *file, |
| |
video_usercopy(file, cmd, arg, __video_do_ioctl); |
| |
long __video_do_ioctl(struct file *file, |
| |
ioctl实现再次调用 vivi.c 中的 ====================