博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
camera驱动(四)
阅读量:3897 次
发布时间:2019-05-23

本文共 1530 字,大约阅读时间需要 5 分钟。

vidioc_int_* 类函数的实现

        应用程序是通过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/

你可能感兴趣的文章
【设计模式基础】行为模式 - 1 - 观察者(Observer)
查看>>
从关系型数据库到非关系型数据库
查看>>
【数据库基础】数据库事务 - Transaction
查看>>
【设计模式基础】行为模式 - 3 - 职责链(Chain of responsibility)
查看>>
【Java基础】反射 - Reflection
查看>>
【C++基础】const成员函数
查看>>
【设计模式基础】行为模式 - 5 - 策略(Strategy)
查看>>
【Maven】Archetype
查看>>
【Java.Web】Cookie —— 基础
查看>>
【Tools.Eclipse】代码自动提示
查看>>
【Java.Web】MVC —— Model1 V.S. Model2
查看>>
【Java.Web】MVC —— 基于Servlet Controller的Model2 —— 示例
查看>>
【Java.Web】MVC —— 基于Filter Dispatcher的Model2 —— 示例
查看>>
【Java.Web】MVC —— Action的验证器 —— Validator
查看>>
【Java.Spring.MVC】使用Spring MVC构建Web应用程序
查看>>
【DB.PL/SQL】程序流程控制 —— 异常处理
查看>>
【Java.IO】I/O 【字节】【处理流】 - 之 - 【压缩流】 - ZipInputStream,ZipOutputStream
查看>>
【Java.JDBC/ORM】纯JDBC系统的开发随想
查看>>
【Unix/Linux】【系统】环境变量
查看>>
【Architecture】CPU-bound(计算密集型) 和I/O bound(I/O密集型)
查看>>