2.22. V4L2 异步 kAPI

enum v4l2_async_match_type

用于识别匹配项的异步子设备逻辑类型

常量

V4L2_ASYNC_MATCH_TYPE_I2C

匹配将检查 I2C 适配器 ID 和地址

V4L2_ASYNC_MATCH_TYPE_FWNODE

匹配将使用固件节点

描述

此枚举由异步连接逻辑使用,以定义将用于匹配异步设备的算法。

struct v4l2_async_match_desc

异步连接匹配信息

定义:

struct v4l2_async_match_desc {
    enum v4l2_async_match_type type;
    union {
        struct fwnode_handle *fwnode;
        struct {
            int adapter_id;
            unsigned short address;
        } i2c;
    };
};

成员

type

将使用的匹配类型

{unnamed_union}

anonymous

fwnode

要匹配的 struct fwnode_handle 的指针。如果 match_typeV4L2_ASYNC_MATCH_TYPE_FWNODE,则使用。

i2c

嵌入式结构,包含要匹配的 I2C 参数。 match.i2c.adapter_idmatch.i2c.address 都应匹配。如果 match_typeV4L2_ASYNC_MATCH_TYPE_I2C,则使用。

i2c.adapter_id

要匹配的 I2C 适配器 ID。如果 match_typeV4L2_ASYNC_MATCH_TYPE_I2C,则使用。

i2c.address

要匹配的 I2C 地址。如果 match_typeV4L2_ASYNC_MATCH_TYPE_I2C,则使用。

struct v4l2_async_connection

子设备连接描述符,如桥接器所知

定义:

struct v4l2_async_connection {
    struct v4l2_async_match_desc match;
    struct v4l2_async_notifier *notifier;
    struct list_head asc_entry;
    struct list_head asc_subdev_entry;
    struct v4l2_subdev *sd;
};

成员

match

匹配类型和每个总线类型匹配数据集的结构

notifier

连接相关的异步通知程序

asc_entry

用于将 struct v4l2_async_connection 对象添加到通知程序的 waiting_listdone_list

asc_subdev_entry

struct v4l2_async_subdev.asc_list 列表中的条目

sd

相关的子设备

描述

当此结构用作驱动程序特定结构中的成员时,驱动程序特定结构应包含 struct v4l2_async_connection 作为其第一个成员。

struct v4l2_async_notifier_operations

异步 V4L2 通知程序操作

定义:

struct v4l2_async_notifier_operations {
    int (*bound)(struct v4l2_async_notifier *notifier,struct v4l2_subdev *subdev, struct v4l2_async_connection *asc);
    int (*complete)(struct v4l2_async_notifier *notifier);
    void (*unbind)(struct v4l2_async_notifier *notifier,struct v4l2_subdev *subdev, struct v4l2_async_connection *asc);
    void (*destroy)(struct v4l2_async_connection *asc);
};

成员

bound

子设备已由给定的连接绑定

complete

所有连接都已成功绑定。complete 回调仅针对根通知程序执行。

unbind

子设备正在离开

destroy

asc 即将被释放

struct v4l2_async_notifier

v4l2_device 通知程序数据

定义:

struct v4l2_async_notifier {
    const struct v4l2_async_notifier_operations *ops;
    struct v4l2_device *v4l2_dev;
    struct v4l2_subdev *sd;
    struct v4l2_async_notifier *parent;
    struct list_head waiting_list;
    struct list_head done_list;
    struct list_head notifier_entry;
};

成员

ops

通知程序操作

v4l2_dev

根通知程序的 v4l2_device,否则为 NULL

sd

注册通知程序的子设备,否则为 NULL

parent

父通知程序

waiting_list

struct v4l2_async_connection 列表,等待其驱动程序

done_list

struct v4l2_subdev 列表,已探测

notifier_entry

全局通知程序列表中的成员

struct v4l2_async_subdev_endpoint

子设备的 fwnode 列表中的条目

定义:

struct v4l2_async_subdev_endpoint {
    struct list_head async_subdev_endpoint_entry;
    struct fwnode_handle *endpoint;
};

成员

async_subdev_endpoint_entry

struct v4l2_subdev 的 async_subdev_endpoint_list 中的条目

endpoint

端点 fwnode,用于匹配子设备

void v4l2_async_debug_init(struct dentry *debugfs_dir)

初始化调试工具。

参数

struct dentry *debugfs_dir

指向父 debugfs struct dentry 的指针

void v4l2_async_nf_init(struct v4l2_async_notifier *notifier, struct v4l2_device *v4l2_dev)

初始化通知程序。

参数

struct v4l2_async_notifier *notifier

指向 struct v4l2_async_notifier 的指针

struct v4l2_device *v4l2_dev

指向 struct v4l2_device 的指针

描述

此函数初始化通知程序的 asc_entry。必须在使用以下方法之一将子设备添加到通知程序之前调用它:v4l2_async_nf_add_fwnode_remote()v4l2_async_nf_add_fwnode()v4l2_async_nf_add_i2c()

void v4l2_async_subdev_nf_init(struct v4l2_async_notifier *notifier, struct v4l2_subdev *sd)

初始化子设备通知程序。

参数

struct v4l2_async_notifier *notifier

指向 struct v4l2_async_notifier 的指针

struct v4l2_subdev *sd

指向 struct v4l2_subdev 的指针

描述

此函数初始化通知程序的 asc_list。必须在使用以下方法之一将子设备添加到通知程序之前调用它:v4l2_async_nf_add_fwnode_remote()v4l2_async_nf_add_fwnode()v4l2_async_nf_add_i2c()

v4l2_async_nf_add_fwnode

v4l2_async_nf_add_fwnode (notifier, fwnode, type)

分配并将 fwnode 异步子设备添加到通知程序的主 asc_list。

参数

notifier

指向 struct v4l2_async_notifier 的指针

fwnode

要匹配的子设备的 fwnode 句柄,指向 struct fwnode_handle

type

驱动程序的异步子设备或连接结构的类型。 struct v4l2_async_connection 应该是驱动程序的异步结构的第一个成员,即两者都从相同的内存地址开始。

描述

分配大小为 asc_struct_size 的 fwnode 匹配的 asc,并将其添加到通知程序的 asc_list。此函数还会获取 fwnode 的引用,该引用稍后会在通知程序清理时释放。

v4l2_async_nf_add_fwnode_remote

v4l2_async_nf_add_fwnode_remote (notifier, ep, type)

分配并将 fwnode 远程异步子设备添加到通知程序的主 asc_list。

参数

notifier

指向 struct v4l2_async_notifier 的指针

ep

指向要匹配的远程连接的本地端点,指向 struct fwnode_handle

type

驱动程序的异步连接结构的类型。 struct v4l2_async_connection 应该是驱动程序的异步连接结构的第一个成员,即两者都从相同的内存地址开始。

描述

获取给定本地端点的远程端点,将其设置为 fwnode 匹配,并将异步连接添加到通知程序的 asc_list。此函数还会获取 fwnode 的引用,该引用稍后会在通知程序清理时释放。

这就像 v4l2_async_nf_add_fwnode(),但不同之处在于 fwnode 引用本地端点,而不是远程端点。

v4l2_async_nf_add_i2c

v4l2_async_nf_add_i2c (notifier, adapter, address, type)

分配并将 i2c 异步子设备添加到通知程序的主 asc_list。

参数

notifier

指向 struct v4l2_async_notifier 的指针

adapter

要匹配的 I2C 适配器 ID

address

要匹配的连接的 I2C 地址

type

驱动程序的异步连接结构的类型。 struct v4l2_async_connection 应该是驱动程序的异步连接结构的第一个成员,即两者都从相同的内存地址开始。

描述

v4l2_async_nf_add_fwnode() 相同,但适用于 I2C 匹配的连接。

int v4l2_async_subdev_endpoint_add(struct v4l2_subdev *sd, struct fwnode_handle *fwnode)

将端点 fwnode 添加到异步子设备匹配列表

参数

struct v4l2_subdev *sd

子设备

struct fwnode_handle *fwnode

要匹配的端点 fwnode

描述

将 fwnode 添加到异步子设备的匹配列表。这允许从单个设备注册多个异步子设备。

请注意,如果已将端点添加到子设备的 fwnode 匹配列表,则调用 v4l2_subdev_cleanup() 作为子设备清理的一部分。

失败时返回错误,成功时返回 0。

struct v4l2_async_connection *v4l2_async_connection_unique(struct v4l2_subdev *sd)

返回子设备的唯一 struct v4l2_async_connection

参数

struct v4l2_subdev *sd

子设备

描述

当只有一个异步连接时,返回子设备的异步连接。

int v4l2_async_nf_register(struct v4l2_async_notifier *notifier)

注册子设备异步通知程序

参数

struct v4l2_async_notifier *notifier

指向 struct v4l2_async_notifier 的指针

void v4l2_async_nf_unregister(struct v4l2_async_notifier *notifier)

注销子设备异步通知程序

参数

struct v4l2_async_notifier *notifier

指向 struct v4l2_async_notifier 的指针

void v4l2_async_nf_cleanup(struct v4l2_async_notifier *notifier)

清理通知程序资源

参数

struct v4l2_async_notifier *notifier

要清理其资源的通知程序

描述

释放与通知程序相关的内存资源,包括为通知程序分配的异步连接,但不包括通知程序本身。在调用 v4l2_async_nf_add_fwnode_remote()v4l2_async_nf_add_fwnode()v4l2_async_nf_add_i2c() 之后,用户负责调用此函数以清理通知程序。

在其他情况下调用 v4l2_async_nf_cleanup() 没有害处,只要其内存在分配后已清零。

v4l2_async_register_subdev

v4l2_async_register_subdev (sd)

将子设备注册到异步子设备框架

参数

sd

指向 struct v4l2_subdev 的指针

int v4l2_async_register_subdev_sensor(struct v4l2_subdev *sd)

将传感器子设备注册到异步子设备框架,并解析设置常见的传感器相关设备

参数

struct v4l2_subdev *sd

指向 struct v4l2_subdev 的指针

描述

此函数就像 v4l2_async_register_subdev() 一样,但不同之处在于调用它也会使用 v4l2_async_nf_parse_fwnode_sensor() 解析固件接口以获取远程引用,并注册异步子设备。通过调用 v4l2_async_unregister_subdev() 类似地注销子设备。

注册后,子设备模块将被标记为正在使用。

如果模块不再加载任何注册尝试,则会返回错误。

void v4l2_async_unregister_subdev(struct v4l2_subdev *sd)

将子设备从异步子设备框架中注销

参数

struct v4l2_subdev *sd

指向 struct v4l2_subdev 的指针