2.18. V4L2 閃光燈功能和資料結構

struct v4l2_flash_ctrl_data

閃光燈控制初始化資料,根據 LED 閃光燈類驅動程式在 v4l2_flash_config 中宣告的特性填充

定義:

struct v4l2_flash_ctrl_data {
    struct v4l2_ctrl_config config;
    u32 cid;
};

成員

config

控制的初始化資料

cid

如果 config 欄位已初始化,則包含 v4l2 閃光燈控制 ID,否則為 0

struct v4l2_flash_ops

V4L2 閃光燈操作

定義:

struct v4l2_flash_ops {
    int (*external_strobe_set)(struct v4l2_flash *v4l2_flash, bool enable);
    enum led_brightness (*intensity_to_led_brightness) (struct v4l2_flash *v4l2_flash, s32 intensity);
    s32 (*led_brightness_to_intensity) (struct v4l2_flash *v4l2_flash, enum led_brightness);
};

成員

external_strobe_set

透過硬體引腳狀態斷言設定閃光燈選通。

intensity_to_led_brightness

以裝置特定的方式將強度轉換為亮度

led_brightness_to_intensity

以裝置特定的方式將亮度轉換為強度。

struct v4l2_flash_config

V4L2 閃光燈子裝置初始化資料

定義:

struct v4l2_flash_config {
    char dev_name[32];
    struct led_flash_setting intensity;
    u32 flash_faults;
    unsigned int has_external_strobe:1;
};

成員

dev_name

媒體實體的名稱,在系統中是唯一的

intensity

LED 的非閃光燈選通約束

flash_faults

LED 閃光燈類裝置可以報告的閃光燈故障的位掩碼;相應的 LED_FAULT* 位定義在標頭檔案 <linux/led-class-flash.h> 中可用

has_external_strobe

外部選通能力

struct v4l2_flash

閃光燈子裝置上下文

定義:

struct v4l2_flash {
    struct led_classdev_flash *fled_cdev;
    struct led_classdev *iled_cdev;
    const struct v4l2_flash_ops *ops;
    struct v4l2_subdev sd;
    struct v4l2_ctrl_handler hdl;
    struct v4l2_ctrl **ctrls;
};

成員

fled_cdev

由此子裝置控制的 LED 閃光燈類裝置

iled_cdev

表示與 LED 閃光燈類裝置關聯的指示燈 LED 的 LED 類裝置

ops

V4L2 特定閃光燈操作

sd

V4L2 子裝置

hdl

閃光燈控制處理程式

ctrls

指向控制器的指標陣列,其值定義了子裝置狀態

struct v4l2_flash *v4l2_subdev_to_v4l2_flash(struct v4l2_subdev *sd)

從嵌入的 struct v4l2_subdev 返回 struct v4l2_flash

引數

struct v4l2_subdev *sd

指向 struct v4l2_subdev 的指標

struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c)

從嵌入的 struct v4l2_ctrl 返回 struct v4l2_flash

引數

struct v4l2_ctrl *c

指向 struct v4l2_ctrl 的指標

struct v4l2_flash *v4l2_flash_init(struct device *dev, struct fwnode_handle *fwn, struct led_classdev_flash *fled_cdev, const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config)

初始化 V4L2 閃光燈 LED 子裝置

引數

struct device *dev

閃光燈裝置,例如 I2C 裝置

struct fwnode_handle *fwn

LED 的 fwnode_handle,如果與裝置的相同,則可能為 NULL

struct led_classdev_flash *fled_cdev

要包裝的 LED 閃光燈類裝置

const struct v4l2_flash_ops *ops

V4L2 閃光燈裝置操作

struct v4l2_flash_config *config

V4L2 閃光燈子裝置的初始化資料

描述

建立 V4L2 閃光燈子裝置,包裝給定的 LED 子系統裝置。 ops 指標由 V4L2 閃光燈框架儲存。 此函式返回後,不會保留對 config 及其內容的引用。

返回

一個有效的指標,或者,當發生錯誤時,返回值使用 ERR_PTR() 編碼。 使用 IS_ERR() 檢查,並使用 PTR_ERR() 獲取數字返回值。

struct v4l2_flash *v4l2_flash_indicator_init(struct device *dev, struct fwnode_handle *fwn, struct led_classdev *iled_cdev, struct v4l2_flash_config *config)

初始化 V4L2 指示器子裝置

引數

struct device *dev

閃光燈裝置,例如 I2C 裝置

struct fwnode_handle *fwn

LED 的 fwnode_handle,如果與裝置的相同,則可能為 NULL

struct led_classdev *iled_cdev

表示指示燈 LED 的 LED 閃光燈類裝置

struct v4l2_flash_config *config

V4L2 閃光燈子裝置的初始化資料

描述

建立 V4L2 閃光燈子裝置,包裝給定的 LED 子系統裝置。 ops 指標由 V4L2 閃光燈框架儲存。 此函式返回後,不會保留對 config 及其內容的引用。

返回

一個有效的指標,或者,當發生錯誤時,返回值使用 ERR_PTR() 編碼。 使用 IS_ERR() 檢查,並使用 PTR_ERR() 獲取數字返回值。

void v4l2_flash_release(struct v4l2_flash *v4l2_flash)

釋放 V4L2 閃光燈子裝置

引數

struct v4l2_flash *v4l2_flash

要釋放的 V4L2 閃光燈子裝置

描述

釋放 V4L2 閃光燈子裝置。