Linux camera驱动(4) - vidioc_int_* 类

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()函数*/

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值