5.5. 视频接入 - Camera
5.5.1. 模块描述
Camera 接入方式
X5 支持 MIPI CSI 视频输入或者通过解串器( deserial )转换为 MIPI CSI 信号接入两种方式。
这两种方式使用时需要通过 attach 和 detach 接口与 VIN Node 绑定和解绑,从而初始化和去初始化 sensor 。
MIPI CSI 直接接入时需要通过
hbn_camera_attach_to_vin和hbn_camera_detach_from_vin接口将 Camera 与 VIN Node 绑定和解绑。解串器(deserial)接入使用时需要通过
hbn_deserial_attach_to_vin和hbn_deserial_detach_from_vin接口将 deserial 与 VIN Node 绑定和解绑。
关于 VIN Node的描述,参考视频接入- VIN。
5.5.1.1. 基础规格
支持 MIPI CSI 视频输入:
兼容 MIPI 联盟接口规范 v2.1
支持最多 8 条数据通道,每条数据通道最高支持 2.5Gbps 数据速率
支持 MIPI-HS 和 MIPI-LP 模式
每 4 条数据通道支持两种模式:
单接口:1 条时钟通道和 4 条数据通道,支持最多 2 个虚拟通道
双接口:每个接口包含 1 条时钟通道和 2 条数据通道,支持最多 4 个虚拟通道
支持最高分辨率 5472 x 3076 像素@30fps 视频输入
支持多种视频格式:
RAW 8-/10-/12-/14-/16-bit 格式
YUV 422 格式(8-/10-bit)
支持视频输入到输出直通模式:
支持 MIPI CSI RX 到 MIPI CSI TX 的直通(back-to-back)模式
5.5.2. 参考示例
Camera 接入部分示例代码可以参考 sample_vin 章节
5.5.3. API 参考
| API 接口 | 接口功能 |
|---|---|
| hbn_camera_create | 根据 camera_config_t 传入的配置创建 camera handle。 |
| hbn_camera_destroy | 根据 camera handle 销毁对应的软件资源。 |
| hbn_camera_attach_to_vin | 通过 camera 和 vin node 的 handle,将两者在 vpf 框架中绑定,并对 camera 的硬件初始化。 |
| hbn_camera_detach_from_vin | 将 camera 与 vin node 解绑,并做去初始化操作。 |
| hbn_camera_attach_to_deserial | 通过 camera 和 deserial 的 handle,将两者绑定,并对 deserial 和 camera 硬件初始化。 |
| hbn_camera_detach_from_deserial | 将 camera 与 deserial 解绑,并做去初始化操作。 |
| hbn_camera_start | 配置 camera 寄存器,开始出流。 |
| hbn_camera_stop | 配置 camera 寄存器,关流。 |
| hbn_camera_reset | 通过重新初始化 sensor 来做 reset。 |
| hbn_camera_change_fps | 动态切换 sensor 帧率。 |
| hbn_camera_read_register | 读取 camera 寄存器的值。 |
| hbn_camera_get_handle | 通过 vin node handle 或者 camera port index,获取对应的 camera handle。 |
| hbn_camera_init_cfg | 通过传入的配置,创建 camera handle 和 deserial handle 并绑定。 |
| hbn_deserial_create | 根据传入的配置,创建 deserial handle。 |
| hbn_deserial_destroy | 根据 deserial handle 销毁对应的软件资源。 |
| hbn_deserial_attach_to_vin | 将 deserial 与 vin node 绑定。 |
| hbn_deserial_detach_from_vin | 将 deserial 与 vin node 解绑。 |
| hbn_txser_create | 根据传入的配置,创建串行器句柄 tx serial handle。 |
| hbn_txser_destroy | 根据 tx serial handle 销毁对应的软件资源。 |
| hbn_txser_attach_to_vin | 将 tx serial 与 vin node 绑定。 |
| hbn_txser_detach_from_vin | 将 tx serial 与 vin node 解绑。 |
| hbn_camera_switch_scence | 动态切换 camera isp tuning 效果文件。 |
5.5.3.1. hbn_camera_create
【函数声明】
int32_t hbn_camera_create(camera_config_t *cam_config, camera_handle_t *cam_fd)
【参数描述】
[IN] camera_config_t *cam_config:要配置的 camera 对应的参数结构体指针;
[OUT] camera_handle_t *cam_fd:根据配置参数返回的 fd,作为 camera 的操作 handle;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
根据 camera_config_t 传入的配置创建 camera handle。
【注意事项】
API 里面会对 sensor lib 进行检查,如果 sensor 驱动代码不符合 HBN 框架规范,则会检查报错。
API 里面会对 cam_config 进行检查,如果配置不符合 IP 硬件能力,则会检查报错。
5.5.3.2. hbn_camera_destroy
【函数声明】
int32_t hbn_camera_destroy(camera_handle_t cam_fd)
【参数描述】
[IN] camera_handle_t cam_fd:camera 的操作 handle,由 hbn_camera_create 所创建;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
根据 camera handle 销毁对应的软件资源。
【注意事项】
hbn_camera_destroy 需要和 hbn_camera_create 成对使用。
hbn_camera_destroy 会释放 sensor lib, 执行完成后,sensor 将无法正常访问。
hbn_camera_destroy 内部会调用 hbn_camera_detach_from_vin,会触发 sensor 停流操作,所以 hbn_camera_destroy 需要在 hbn_vflow_destroy 之前调用。
5.5.3.3. hbn_camera_attach_to_vin
【函数声明】
int32_t hbn_camera_attach_to_vin(camera_handle_t cam_fd, vpf_handle_t vin_fd)
【参数描述】
[IN] camera_handle_t cam_fd:camera handle,由 hbn_camera_create 创建;
[IN] vpf_handle_t vin_fd:由 hbn_vnode_open 接口创建的 vin node handle。
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
通过 camera 和 vin node 的 handle,将两者在 vpf 框架中绑定,并对 camera 的硬件初始化。
【注意事项】
同一个 camera,不能重复执行 hbn_camera_attach_to_vin,否则会报 attach error 错误。
5.5.3.4. hbn_camera_detach_from_vin
【函数声明】
int32_t hbn_camera_detach_from_vin(camera_handle_t cam_fd)
【参数描述】
[IN] camera_handle_t cam_fd:camera handle,由 hbn_camera_create 创建;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
将 camera 与 vin node 解绑,并做去初始化操作。
【注意事项】
hbn_camera_detach_from_vin 需要和 hbn_camera_attach_to_vin 成对使用。
hbn_camera_destroy 内部调用了 hbn_camera_detach_from_vin,所以调用了 hbn_camera_destroy 接口,hbn_camera_detach_from_vin 可以不再调用。
5.5.3.5. hbn_camera_attach_to_deserial
【函数声明】
int32_t hbn_camera_attach_to_deserial(camera_handle_t cam_fd, deserial_handle_t des_fd, camera_des_link_t link)
【参数描述】
[IN] camera_handle_t cam_fd:camera handle,由 hbn_camera_create 创建;
[IN] deserial_handle_t des_fd:deserial handle,由 hbn_deserial_create 创建;
[IN] camera_des_link_t link:camera 与 deserial 的 link 方式,根据 camera 接到哪个 link 决定。
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
通过 camera 和 deserial 的 handle,将两者绑定,并对 deserial 和 camera 硬件初始化。
【注意事项】
硬件上有解串器时才需要调用该接口。
执行 hbn_camera_attach_to_deserial 后,就不需要再执行 hbn_camera_attach_to_vin,而是由 deserial 绑定到 vin node。
5.5.3.6. hbn_camera_detach_from_deserial
【函数声明】
int32_t hbn_camera_detach_from_deserial(camera_handle_t cam_fd)
【参数描述】
[IN] camera_handle_t cam_fd:camera handle,由 hbn_camera_create 创建;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
将 camera 与 deserial 解绑,并做去初始化操作。
【注意事项】
hbn_camera_detach_from_deserial 需要和 hbn_camera_attach_to_deserial 成对使用。
5.5.3.7. hbn_camera_start
【函数声明】
int32_t hbn_camera_start(camera_handle_t cam_fd)
【参数描述】
[IN] camera_handle_t cam_fd:camera handle,由 hbn_camera_create 创建;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
配置 camera 寄存器,开始出流。
【注意事项】
camera handle attach 到 vflow 后,该接口可以不调用。如果要调用必须先调用 hbn_vflow_start,再调用 hbn_camera_start。
5.5.3.8. hbn_camera_stop
【函数声明】
int32_t hbn_camera_stop(camera_handle_t cam_fd)
【参数描述】
[IN] camera_handle_t cam_fd:camera handle,由 hbn_camera_create 创建;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
配置 camera 寄存器,关流。
【注意事项】
需要和 hbn_camera_start 成对使用。
5.5.3.9. hbn_camera_reset
【函数声明】
int32_t hbn_camera_reset(camera_handle_t cam_fd)
【参数描述】
[IN] camera_handle_t cam_fd:camera handle,由 hbn_camera_create 创建;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
通过重新初始化 sensor 来做 reset。
【注意事项】
如果在 camera attach vin 之前调用该接口,则会通过 camera_attach_to_vin 接口来给 sensor 初始化,达到 reset 效果。如果是在 camera attach vin 之后调用该接口,则会调用 sensor stop,sensor deinit,然后初始化再重新 init sensor,start sensor。
5.5.3.10. hbn_camera_change_fps
【函数声明】
int32_t hbn_camera_change_fps(camera_handle_t cam_fd, int32_t fps)
【参数描述】
[IN] camera_handle_t cam_fd:camera handle,由 hbn_camera_create 创建;
[IN] int32_t fps:sensor 出图帧率;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
动态切换 sensor 帧率。
【注意事项】
该功能需要在 sensor lib 库中实现相应的回调函数 dynamic_switch_fps。
5.5.3.11. hbn_camera_read_register
【函数声明】
int32_t hbn_camera_read_register(camera_handle_t cam_fd, camera_reg_type_t type, uint32_t reg_addr)
【参数描述】
[IN] camera_handle_t cam_fd:camera handle,由 hbn_camera_create 创建;
[IN] camera_reg_type_t type:读取 sensor 寄存器的类型;
[IN] uint32_t reg_addr:寄存器地址;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
读取 camera 寄存器的值。
【注意事项】
无
5.5.3.12. hbn_camera_get_handle
【函数声明】
camera_handle_t hbn_camera_get_handle(vpf_handle_t vin_fd, int32_t camera_index)
【参数描述】
[IN] vpf_handle_t vin_fd:vin node 的 fd;
[IN] int32_t camera_index:camera 的 port index;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
通过 vin node handle 或者 camera port index,获取对应的 camera handle。
【注意事项】
无
5.5.3.13. hbn_camera_init_cfg
【函数声明】
int32_t hbn_camera_init_cfg(const char *cfg_file)
【参数描述】
[IN] const char *cfg_file:camera 配置文件路径(json);
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
通过传入的配置,创建 camera handle 和 deserial handle 并绑定。
【注意事项】
该 API 是通过解析 json 方式来创建 camera,与 sample 中非 json 方式接口不同,详情请咨询 FAE。
5.5.3.14. hbn_deserial_create
【函数声明】
int32_t hbn_deserial_create(deserial_config_t *des_config, deserial_handle_t *des_fd)
【参数描述】
[IN] deserial_config_t *des_config:deserial 配置参数结构体指针;
[OUT] deserial_handle_t *des_fd:根据配置创建的 deserial handle;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
根据传入的配置,创建 deserial handle。
【注意事项】
硬件上有解串器时才需要调用该接口。
该接口会对 deserial 的配置进行检查,如果配置超出一定范围,则会报错。
该接口会对 deserial lib 进行检查,如果不符合 HBN 架构规范,则会报错。
5.5.3.15. hbn_deserial_destroy
【函数声明】
int32_t hbn_deserial_destroy(deserial_handle_t des_fd)
【参数描述】
[IN] deserial_handle_t des_fd:deserial handle,由 hbn_deserial_create 创建;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
根据 deserial handle 销毁对应的软件资源。
【注意事项】
hbn_deserial_destroy 需要和 hbn_deserial_create 成对使用。
5.5.3.16. hbn_deserial_attach_to_vin
【函数声明】
int32_t hbn_deserial_attach_to_vin(deserial_handle_t des_fd, camera_des_link_t link, vpf_handle_t vin_fd)
【参数描述】
[IN] deserial_handle_t des_fd:deserial handle,由 hbn_deserial_create 创建;
[IN] camera_des_link_t link:deserial 的 link 编号;
[IN] vpf_handle_t vin_fd:要绑定到的 vin node handle;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
将 deserial 与 vin node 绑定。
【注意事项】
硬件上带有解串器,则 camera 与 deserial 进行绑定,deserial 与 vin node 绑定。
5.5.3.17. hbn_deserial_detach_from_vin
【函数声明】
int32_t hbn_deserial_detach_from_vin(deserial_handle_t des_fd, camera_des_link_t link)
【参数描述】
[IN] deserial_handle_t des_fd:deserial handle,由 hbn_deserial_create 创建;
[IN] camera_des_link_t link:deserial 的 link 编号;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
将 deserial 与 vin node 解绑。
【注意事项】
hbn_deserial_detach_from_vin 与 hbn_deserial_attach_to_vin 需要成对使用。
5.5.3.18. hbn_txser_create
【函数声明】
int32_t hbn_txser_create(txser_config_t *txs_config, txser_handle_t *txs_fd)
【参数描述】
[IN] txser_config_t *txs_config:tx serial 配置参数结构体指针;
[OUT] txser_handle_t *txs_fd:根据配置创建的 tx serial handle;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
根据传入的配置,创建串行器句柄 tx serial handle。
【注意事项】
硬件上有串行器时才需要调用该接口。
该接口会对 txser 的配置进行检查,如果配置超出一定范围,则会报错。
该接口会对 txser lib 进行检查,如果不符合 HBN 架构规范,则会报错。
5.5.3.19. hbn_txser_destroy
【函数声明】
int32_t hbn_txser_destroy(txser_handle_t txs_fd)
【参数描述】
[IN] txser_handle_t txs_fd:tx serial handle,由 hbn_txser_create 创建;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
根据 tx serial handle 销毁对应的软件资源。
【注意事项】
硬件上有串行器时才需要调用该接口。
hbn_txser_destroy 与 hbn_txser_create 需要成对使用。
5.5.3.20. hbn_txser_attach_to_vin
【函数声明】
int32_t hbn_txser_attach_to_vin(txser_handle_t txs_fd, camera_txs_csi_t csi, vpf_handle_t vin_fd)
【参数描述】
[IN] txser_handle_t txs_fd:tx serialhandle,由 hbn_txser_create 创建;
[IN] camera_txs_csi_t csi:tx csi index;
[IN] vpf_handle_t vin_fd:要绑定到的 vin node handle;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
将 tx serial 与 vin node 绑定。
【注意事项】
硬件上有串行器时才需要调用该接口。
该接口会对 txser 硬件进行初始化。
硬件上带有串行器,则 camera 与 txser 进行绑定,txser 与 vin node 绑定。
5.5.3.21. hbn_txser_detach_from_vin
【函数声明】
int32_t hbn_txser_detach_from_vin(txser_handle_t txs_fd, camera_txs_csi_t csi)
【参数描述】
[IN] txser_handle_t txs_fd:tx serial handle,由 hbn_txser_create 创建;
[IN] camera_txs_csi_t csi:tx csi index;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
将 tx serial 与 vin node 解绑。
【注意事项】
hbn_txser_detach_from_vin 需要与 hbn_txser_attach_to_vin 成对使用。
5.5.3.22. hbn_camera_switch_scence
【函数声明】
int32_t hbn_camera_switch_scence(int64_t vflow_fd, int64_t isp_vnode_fd, const char *cname)
【参数描述】
[IN] int64_t vflow_fd:camera flow handle,由 hbn_vflow_create 创建;
[IN] int64_t isp_vnode_fd:isp node handle,由 hbn_vflow_get_vnode_handle 获取;
[IN] const char *cname:isp tuning json 字符串,默认从/usr/hobot/lib/sensor 目录找指定的 tuning 文件,如果 tuning 文件不在/usr/hobot/lib/sensor 目录,需要指定 tuning 文件的绝对路径;
【返回值】
成功:RET_OK 0
失败:异常为负值错误码
【功能描述】
动态切换 camera isp tuning 效果文件。
【注意事项】
该 API 会先 stop vflow,然后进行切换 isp tuning 文件,最后再重新 start vflow。
5.5.4. 数据结构
Camera 参数
typedef struct camera_config_s
| 名称 | 类型 | 最小值 | 最大值 | 默认值 | 含义 | 必选 |
|---|---|---|---|---|---|---|
| name[CAMERA_MODULE_NAME_LEN] | char | - | CAMERA_MODULE_NAME_LEN(108) | - | camera 模组名称,需要和 sensor lib 名称对应,如:sensor 驱动名称为:libsc1330t.so,那么 name 为 sc1330t | 是 |
| addr | uint32_t | 0x00 | 0x7f | 0x00 | sensor 设备地址,一般是 i2c 7位地址 | 是 |
| isp_addr | uint32_t | 0x00 | 0x7f | 0x00 | isp 设备地址(如有),默认无 | 否 |
| eeprom_addr | uint32_t | 0x00 | 0x7f | 0x00 | eeprom 设备地址(如有),默认无 | 否 |
| serial_addr | uint32_t | 0x00 | 0x7f | 0x00 | serdes 设备地址(如有),默认无 | 否 |
| sensor_mode | uint32_t | 1 | 6 | 1 | sensor 工作模式,可以使用 enum sensor_mode_e 枚举,定义如下: 1:NORMAL_M,linear 模式; 2:DOL2_M,hdr2帧合成1帧; 3:DOL3_M,hdr3帧合成1帧; 4:DOL4_M,hdr4帧合成1帧; 5:PWL_M,hdr 模式 sensor 内部合成 6:SLAVE_M,slave 模式, 需要外界 trigger 信号,才能正常出流 |
是 |
| sensor_clk | uint32_t | - | - | 0x00 | sensor 一些 clk 时钟配置,目前未生效,备用 | 否 |
| gpio_enable_bit | uint32_t | 0 | 0xFFFFFFFF | 0 | 是否使用 X5 gpio 控制 camera sensor 的引脚,以满足 sensor 上下电的时序要求。 如:使用 gpio 来控制 sensor XSHUTDN 引脚。 注意:需要在 dts 中配置对应的 gpio number。 0:不使用 gpio 来控制; 非0:使用 gpio 来控制 sensor,按照 bit 来使能 gpio。比如: 0x07 则代表使能 [gpio_a, gpio_b, gpio_c] 3 个 gpio。 |
是 |
| gpio_level_bit | uint32_t | 0 | 1 | 0 | 如果选择 gpio_enable_bit,则可以配置 gpio_level_bit 来控制 sensor 引脚高低电平。某个 gpio bit 与 sensor 管脚高低电平关系如下: 0: 先输出低电平, sleep 1s,再输出高电平; 1: 先输出高电平,sleep 1s,再输出低电平。 比如:0x05 = 101,从 bit0 到 bit2 分别代表 gpio_a 先输出高电平,再输出低电平,gpio_b 先输出低电平,再输出高电平,gpio_c 先输出高电平,再输出低电平。 需要根据 sensor spec 上电时序来自定义。 |
是 |
| bus_select | uint32_t | 0 | 6 | 0 | sensor i2c number 选择,一般硬件固定后,对应的 i2c 也是固定的,所以建议在 dts 中配置,这里可以省去。 dts 中绑定 sensor i2c,详情见:camera 点亮说明文档。 |
否 |
| bus_timeout | uint32_t | 0 | - | 0 | I2C 的 timeout 时间配置。配置了 bus_select,才需要配置。 | 否 |
| fps | uint32_t | 0 | 120 | 0 | sensor 帧率配置。 | 是 |
| width | uint32_t | 0 | 8192 | 0 | sensor 出图宽度(pixel) | 是 |
| height | uint32_t | 0 | 4096 | 0 | sensor 出图高度(pixel) | 是 |
| format | uint32_t | - | - | - | sensor 数据类型,常见的如下: RAW8: 0x2A; RAW10: 0x2B; RAW12: 0x2C; YUV422 8-bit: 0x1E |
是 |
| flags | uint32_t | 0 | - | 0 | 可选功能:诊断,恢复,debug 等 | 否 |
| extra_mode | uint32_t | 0 | - | 0 | 各 sensor 库内部定制配置: 多用于区分模组与功能开关 | 是 |
| config_index | uint32_t | 0 | - | 0 | 各 sensor 库内部定制配置: 多用于区分模组与功能开关 | 是 |
| ts_compensate | uint32_t | 0 | - | 0 | 预留参数,备用 | 否 |
| mipi_cfg | mipi_config_t | - | - | - | MIPI 配置, 置为 NULL 自动从 sensor 驱动中获取配置(get_csi_attr)。 | 是 |
| calib_lname | char | - | - | - | sensor 效果库路径,默认路径为 /usr/hobot/lib/sensor,支持自定义路径,总长度不超过 100 字节。 比如: calib_lname="/userdata/test_tuning.json"。 目前软件版本,如果设置为 disable,则代码中默认使用 sensor_name_tuning.json 的字符串传给 isp。 |
是 |
| sensor_param | char | - | - | - | sensor 自定义数据 | 否 |
| iparam_mode | uint32_t | - | - | - | 预留参数,备用 | 否 |
| end_flag | uint32_t | - | - | - | 预留参数,备用 | 否 |
typedef struct deserial_config_s
| 名称 | 类型 | 最小值 | 最大值 | 默认值 | 含义 | 必选 |
|---|---|---|---|---|---|---|
| name | char[CAMERA_MODULE_NAME_LEN] | - | - | - | Deserial 的名称,例如 max9296。 | 是 |
| addr | uint32_t | 0 | - | - | Deserial 设备的地址。 | 是 |
| gpio_enable_bit | uint32_t | 0 | - | - | GPIO 操作使能位,索引自 VCON。 | 是 |
| gpio_level_bit | uint32_t | 0 | - | - | GPIO 工作状态位,表示当前 GPIO 状态。 | 是 |
| gpio_mfp | uint8_t[CAMERA_DES_GPIO_MAX] | 0 | CAMERA_DES_GPIO_MAX | 0x0 | MFP 的 GPIO 功能选择,用于指定 GPIO 的多功能配置。 | 是 |
| bus_select | uint32_t | 0 | - | - | I2C 总线选择,索引自 VCON。 | 是 |
| bus_timeout | uint32_t | 0 | - | - | I2C 超时时间设置,单位为毫秒。 | 是 |
| lane_mode | uint32_t | 0 | - | - | PHY 配置的 lane 模式选择。 | 是 |
| lane_speed | uint32_t | 0 | - | - | PHY 配置的 lane 速率。 | 是 |
| link_map | uint32_t | 0 | - | - | Link 和 CSI/VC 的映射关系配置。 | 是 |
| link_desp | char[CAMERA_DES_LINKMAX][CAMERA_DES_PORTDESP_LEN] | - | - | - | 各 Link 连接模组的配置描述,用于多进程使用。 | 是 |
| reset_delay | uint32_t | 0 | - | - | Reset 操作的延迟时间,单位为毫秒。 | 是 |
| flags | uint32_t | 0 | - | - | 可选功能标志,例如诊断、调试等。 | 否 |
| poc_cfg | poc_config_t* | - | - | NULL | POC 配置指针,若为 NULL 则无 POC 功能。 | 否 |
| mipi_cfg | mipi_config_t* | - | - | NULL | MIPI 配置指针,若为 NULL 则自动获取配置。 | 否 |
| deserial_param | char* | - | - | NULL | Deserial 自定义数据指针。 | 否 |
| end_flag | uint32_t | 0 | 0xFFFFFFFF | - | 结构体配置的结束标志。 | 是 |
typedef struct poc_config_s
| 名称 | 类型 | 最小值 | 最大值 | 默认值 | 含义 | 必选 |
|---|---|---|---|---|---|---|
| name | char[CAMERA_MODULE_NAME_LEN] | - | - | - | POC 的名称,例如 max20087。 | 是 |
| addr | uint32_t | 0 | - | - | POC 设备的地址。 | 是 |
| gpio_enable_bit | uint32_t | 0 | - | - | GPIO 操作使能位,索引自 VCON。 | 是 |
| gpio_level_bit | uint32_t | 0 | - | - | GPIO 工作状态位,表示当前 GPIO 状态。 | 是 |
| poc_map | uint32_t | 0 | - | - | POC 与 Link 的映射关系。 | 是 |
| power_delay | uint32_t | 0 | - | - | POC 开关操作的延迟时间,单位为毫秒。 | 是 |
| end_flag | uint32_t | 0 | 0xFFFFFFFF | - | 结构体配置的结束标志,用于校验完整性。 | 是 |
5.5.5. 返回值说明
| 错误码 | 宏定义 | 描述 | 常见原因及解决方法 |
|---|---|---|---|
| 0 | HBN_STATUS_SUCESS | 成功 | |
| 1 | HBN_STATUS_INVALID_NODE | vnode 无效,找不到对应的 vnode | |
| 2 | HBN_STATUS_INVALID_NODETYPE | vnode 类型无效,找不到对应的 vnode | 对于 VIN,vnode 类型为 HB_VIN |
| 3 | HBN_STATUS_INVALID_HWID | 无效的硬件模块 id | 对于 VIN,hw_id 取值为 0 |
| 4 | HBN_STATUS_INVALID_CTXID | 无效的 context id | 可设置为 AUTO_ALLOC_ID,由 HBN 框架自动分配 |
| 5 | HBN_STATUS_INVALID_OCHNID | 无效的输出通道 id | VIN 输出通道为 0 |
| 6 | HBN_STATUS_INVALID_ICHNID | 无效的输入通道 id | VIN 仅支持1个输入通道 |
| 7 | HBN_STATUS_INVALID_FORMAT | 无效的格式 | |
| 8 | HBN_STATUS_INVALID_NULL_PTR | 空指针 | |
| 9 | HBN_STATUS_INVALID_PARAMETER | 无效的参数,版本检查失败 | |
| 10 | HBN_STATUS_ILLEGAL_ATTR | 无效的参数 | |
| 11 | HBN_STATUS_INVALID_FLOW | 无效的 flow,找不到对应的 flow | |
| 12 | HBN_STATUS_FLOW_EXIST | flow 已经存在 | |
| 13 | HBN_STATUS_FLOW_UNEXIST | flow 不存在 | |
| 14 | HBN_STATUS_NODE_EXIST | node 已经存在 | |
| 15 | HBN_STATUS_NODE_UNEXIST | node 不存在 | |
| 16 | HBN_STATUS_NOT_CONFIG | 预留 | |
| 17 | HBN_STATUS_CHN_NOT_ENABLED | 通道未使能 | |
| 18 | HBN_STATUS_CHN_ALREADY_ENABLED | 通道已使能 | |
| 19 | HBN_STATUS_ALREADY_BINDED | node 已经绑定 | |
| 20 | HBN_STATUS_NOT_BINDED | node 未绑定 | |
| 21 | HBN_STATUS_TIMEOUT | 超时 | |
| 22 | HBN_STATUS_NOT_INITIALIZED | 未初始化 | |
| 23 | HBN_STATUS_NOT_SUPPORT | 通道不支持或未激活 | |
| 24 | HBN_STATUS_NOT_PERM | 操作不允许 | |
| 25 | HBN_STATUS_NOMEM | 内存不足 | |
| 26 | HBN_STATUS_INVALID_VNODE_FD | 无效的 node 文件描述符 | |
| 27 | HBN_STATUS_INVALID_ICHNID_FD | 无效的输入通道文件描述符 | |
| 28 | HBN_STATUS_INVALID_OCHNID_FD | 无效的输出通道文件描述符 | |
| 29 | HBN_STATUS_OPEN_OCHN_FAIL | 打开输出通道失败 | |
| 30 | HBN_STATUS_OPEN_ICHN_FAIL | 打开输入通道失败 | |
| 31 | HBN_STATUS_JSON_PARSE_FAIL | json 解析失败 | |
| 32 | HBN_STATUS_REQ_BUF_FAIL | 请求 buffer 失败 | |
| 33 | HBN_STATUS_QUERY_BUF_FAIL | 查询 buffer 信息失败 | |
| 34 | HBN_STATUS_SET_CONTROL_FAIL | 模块控制、调节参数(如 ISP 效果参数)设置失败 | |
| 35 | HBN_STATUS_GET_CONTROL_FAIL | 模块控制、调节参数(如 ISP 效果参数)获取失败 | |
| 36 | HBN_STATUS_NODE_START_FAIL | node 开启失败 | |
| 37 | HBN_STATUS_NODE_STOP_FAIL | node 停止失败 | |
| 38 | HBN_STATUS_NODE_POLL_ERROR | node 通道 poll 错误 | |
| 39 | HBN_STATUS_NODE_POLL_TIMEOUT | node 通道 poll 超时 | |
| 40 | HBN_STATUS_NODE_POLL_FRAME_DROP | node 通道 poll 时发生丢帧 | |
| 41 | HBN_STATUS_NODE_POLL_HUP | node 通道 poll 时描述符挂起 | |
| 42 | HBN_STATUS_NODE_ILLEGAL_EVENT | node 通道 poll 时事件非法 | |
| 43 | HBN_STATUS_NODE_DEQUE_ERROR | node 通道 dequeue buffer 错误 | |
| 44 | HBN_STATUS_ILLEGAL_BUF_INDEX | 无效的 buffer 索引 | |
| 45 | HBN_STATUS_NODE_QUE_ERROR | node 通道 queue buffer 错误 | |
| 46 | HBN_STATUS_FLUSH_FRAME_ERROR | node 通道帧 flush 错误 | |
| 47 | HBN_STATUS_INIT_BIND_ERROR | 用 json 解析并绑定时发生错误 | |
| 48 | HBN_STATUS_ADD_NODE_FAIL | 向 flow 中添加 node 失败 | |
| 49 | HBN_STATUS_WRONG_CONFIG_ID | 系统不支持的 node id | |
| 50 | HBN_STATUS_BIND_NODE_FAIL | flow 绑定 node 时发生错误 | |
| 51 | HBN_STATUS_INVALID_VERSION | 底层驱动模块和上层库版本号不匹配错误 | |
| 52 | HBN_STATUS_GET_VERSION_ERROR | 获取底层驱动模块版本号错误 | |
| 53 | HBN_STATUS_MEM_INIT_FAIL | hbmem 内存初始化失败 | |
| 54 | HBN_STATUS_MEM_IMPORT_FAIL | hbmem 内存引入失败 | |
| 55 | HBN_STATUS_MEM_FREE_FAIL | hbmem 内存释放失败 | |
| 56 | HBN_STATUS_SYSFS_OPEN_FAIL | 系统文件打开失败 | |
| 57 | HBN_STATUS_STRUCT_SIZE_NOT_MATCH | hal 层结构体大小与 kernel 层不匹配 | |
| 58 | HBN_STATUS_RGN_UNEXIST | 获取不到对应的 rgn 数据 | |
| 59 | HBN_STATUS_RGN_INVALID_OPERATION | rgn 操作无效 | |
| 60 | HBN_STATUS_RGN_OPEN_FILE_FAIL | rgn 模块打开文件失败 | |
| 128 | HBN_STATUS_ERR_UNKNOW | 未知错误 |