v4l2_async

介绍

日期作者说明
2024/04/07Manfredxxc初版

内核版本:kernel-4.1.15


在v4l2框架里,若直接注册v4l2设备和子设备的话,需要保证v4l2设备在子设备之前注册。
v4l2_async_notifier就是用来解耦这种先后依赖关系的

数据结构简要说明

首先介绍两个全局链表:

  1. subdev_list:全局子设备链表,代表待注册到v4l2设备上的子设备们
  2. notifier_list:全局v4l2_async_notifier链表

struct v4l2_async_subdev表示一个异步子设备,支持四种匹配方式custom、devname、i2c、of

struct v4l2_async_subdev {
	enum v4l2_async_match_type match_type;
	union {
		struct {/* ... */} of;
		struct {/* ... */} device_name;
		struct {/* ... */} i2c;
		struct {/* ... */} custom;
	} match;
	/* v4l2-async core private: not to be used by drivers */
	struct list_head list; // 链接到v4l2异步通知器的等待链表上
};

v4l2_async_notifier表示一个v4l2异步通知器

struct v4l2_async_notifier {
	unsigned int num_subdevs; // 子设备数量
	struct v4l2_async_subdev **subdevs; // asd(异步子设备)数组
	struct v4l2_device *v4l2_dev; // 绑定的v4l2设备
	struct list_head waiting; // asd(异步子设备链表):等待驱动注册
	struct list_head done; // sd(子设备)链表:子设备驱动已成功注册
	struct list_head list; // 全局通知器的链表成员
    
    // 子设备驱动成功探测一个子设备
	int (*bound)(struct v4l2_async_notifier *notifier, struct v4l2_subdev *subdev, struct v4l2_async_subdev *asd);
    // 所有子设备都成功探测
	int (*complete)(struct v4l2_async_notifier *notifier);
	// 一个子设备正在接触绑定
    void (*unbind)(struct v4l2_async_notifier *notifier, struct v4l2_subdev *subdev, struct v4l2_async_subdev *asd);
};

API简要说明

v4l2_async_notifier_register

  • 描述:为v4l2设备注册v4l2异步通知器,用于子设备异步注册
  • 原型:int v4l2_async_notifier_register(struct v4l2_device *v4l2_dev, struct v4l2_async_notifier *notifier)
  • 详情:
    1. 添加@notifier->subdevs中符合匹配类型的asd到@notifier->waiting
    2. 添加@notifier到全局v4l2异步通知器链表:notifier_list
    3. 匹配全局子设备链表:subdev_list@notifier->waiting,如果有asd和subdev匹配上,则注册相应的子设备到v4l2设备上

v4l2_async_register_subdev

  • 描述:在全局v4l2异步通知器链表上匹配asd,有则注册,无则将该子设备加入到全局子设备链表上留待后续匹配注册
  • 原型:int v4l2_async_register_subdev(struct v4l2_subdev *sd)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值