本文共 1530 字,大约阅读时间需要 5 分钟。
应用程序是通过IOCTL操控摄像头芯片的,在master的ops中会通过 “vidioc_int_*” 类函数来调用slave中的函数接口(3.10.53版本,4.9.118版本就不是这样了)
v4l2-dev.c(核心层)提供file_operations v4l2_fops;
mxc_v4l2capture.c(master)提供v4l2_file_operations mxc_v4l_fops;
ak8859.c(slave)提供“vidioc_int_*” 类函数
//以下内容在slave驱动文件中static struct v4l2_int_ioctl_desc ak8859_ioctl_desc[] = { {vidioc_int_g_chip_ident_num, (v4l2_int_ioctl_func *) ioctl_g_chip_ident}, {···}, {···},};static struct v4l2_int_slave ak8859_slave = { .ioctls = ak8859_ioctl_desc,};/* ak8859_int_device这个结构体在ak8859_probe中进行了注册 */static struct v4l2_int_device ak8859_int_device = { .u = { .slave = &ak8859_slave, },};//以下内容在v4l2-int-device.h文件中enum v4l2_int_ioctl_num { ··· vidioc_int_g_chip_ident_num,} V4L2_INT_WRAPPER_1(g_chip_ident, int, *);······#define V4L2_INT_WRAPPER_1(name, arg_type, asterisk) \ static inline int vidioc_int_##name(struct v4l2_int_device *d, \ arg_type asterisk arg) \ { \ return v4l2_int_ioctl_1(d, vidioc_int_##name##_num, \ (void *)(unsigned long)arg); \ } \ \ static inline struct v4l2_int_ioctl_desc \ vidioc_int_##name##_cb(int (*func) \ (struct v4l2_int_device *, \ arg_type asterisk)) \ { \ struct v4l2_int_ioctl_desc desc; \ \ desc.num = vidioc_int_##name##_num; \ desc.func = (v4l2_int_ioctl_func *)func; \ \ return desc; \ }/* 将“V4L2_INT_WRAPPER_1”宏定义展开,最后就会得到vidioc_int_NAME()函数和ioctl_NAME()函数的一个对应关系比如:vidioc_int_g_chip_ident()函数其实是ioctl_g_chip_ident()函数*/
转载地址:http://weuen.baihongyu.com/