Blame view
include/media/v4l2-flash-led-class.h
5.75 KB
d2912cb15
|
1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
42bd6f59a
|
2 3 4 5 6 |
/* * V4L2 flash LED sub-device registration helpers. * * Copyright (C) 2015 Samsung Electronics Co., Ltd * Author: Jacek Anaszewski <j.anaszewski@samsung.com> |
42bd6f59a
|
7 8 9 10 11 12 13 14 15 16 17 18 |
*/ #ifndef _V4L2_FLASH_H #define _V4L2_FLASH_H #include <media/v4l2-ctrls.h> #include <media/v4l2-subdev.h> struct led_classdev_flash; struct led_classdev; struct v4l2_flash; enum led_brightness; |
0d56015d8
|
19 |
/** |
42bd6f59a
|
20 21 22 23 24 25 26 27 28 29 30 |
* struct v4l2_flash_ctrl_data - flash control initialization data, filled * basing on the features declared by the LED flash * class driver in the v4l2_flash_config * @config: initialization data for a control * @cid: contains v4l2 flash control id if the config * field was initialized, 0 otherwise */ struct v4l2_flash_ctrl_data { struct v4l2_ctrl_config config; u32 cid; }; |
0d56015d8
|
31 32 33 34 35 36 37 38 39 40 |
/** * struct v4l2_flash_ops - V4L2 flash operations * * @external_strobe_set: Setup strobing the flash by hardware pin state * assertion. * @intensity_to_led_brightness: Convert intensity to brightness in a device * specific manner * @led_brightness_to_intensity: convert brightness to intensity in a device * specific manner. */ |
42bd6f59a
|
41 |
struct v4l2_flash_ops { |
42bd6f59a
|
42 43 |
int (*external_strobe_set)(struct v4l2_flash *v4l2_flash, bool enable); |
42bd6f59a
|
44 45 |
enum led_brightness (*intensity_to_led_brightness) (struct v4l2_flash *v4l2_flash, s32 intensity); |
42bd6f59a
|
46 47 48 49 50 51 52 |
s32 (*led_brightness_to_intensity) (struct v4l2_flash *v4l2_flash, enum led_brightness); }; /** * struct v4l2_flash_config - V4L2 Flash sub-device initialization data * @dev_name: the name of the media entity, |
62ba6b22f
|
53 |
* unique in the system |
503dd28af
|
54 |
* @intensity: non-flash strobe constraints for the LED |
42bd6f59a
|
55 |
* @flash_faults: bitmask of flash faults that the LED flash class |
62ba6b22f
|
56 57 58 |
* device can report; corresponding LED_FAULT* bit * definitions are available in the header file * <linux/led-class-flash.h> |
42bd6f59a
|
59 60 61 62 |
* @has_external_strobe: external strobe capability */ struct v4l2_flash_config { char dev_name[32]; |
503dd28af
|
63 |
struct led_flash_setting intensity; |
42bd6f59a
|
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
u32 flash_faults; unsigned int has_external_strobe:1; }; /** * struct v4l2_flash - Flash sub-device context * @fled_cdev: LED flash class device controlled by this sub-device * @iled_cdev: LED class device representing indicator LED associated * with the LED flash class device * @ops: V4L2 specific flash ops * @sd: V4L2 sub-device * @hdl: flash controls handler * @ctrls: array of pointers to controls, whose values define * the sub-device state */ struct v4l2_flash { struct led_classdev_flash *fled_cdev; |
85f7ff970
|
81 |
struct led_classdev *iled_cdev; |
42bd6f59a
|
82 83 84 85 86 87 |
const struct v4l2_flash_ops *ops; struct v4l2_subdev sd; struct v4l2_ctrl_handler hdl; struct v4l2_ctrl **ctrls; }; |
716b87647
|
88 89 90 91 92 93 |
/** * v4l2_subdev_to_v4l2_flash - Returns a &struct v4l2_flash from the * &struct v4l2_subdev embedded on it. * * @sd: pointer to &struct v4l2_subdev */ |
42bd6f59a
|
94 95 96 97 98 |
static inline struct v4l2_flash *v4l2_subdev_to_v4l2_flash( struct v4l2_subdev *sd) { return container_of(sd, struct v4l2_flash, sd); } |
716b87647
|
99 100 101 102 103 104 |
/** * v4l2_ctrl_to_v4l2_flash - Returns a &struct v4l2_flash from the * &struct v4l2_ctrl embedded on it. * * @c: pointer to &struct v4l2_ctrl */ |
42bd6f59a
|
105 106 107 108 109 110 111 112 113 |
static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c) { return container_of(c->handler, struct v4l2_flash, hdl); } #if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS) /** * v4l2_flash_init - initialize V4L2 flash led sub-device * @dev: flash device, e.g. an I2C device |
048ea05b4
|
114 |
* @fwn: fwnode_handle of the LED, may be NULL if the same as device's |
42bd6f59a
|
115 |
* @fled_cdev: LED flash class device to wrap |
62ba6b22f
|
116 |
* @ops: V4L2 Flash device ops |
42bd6f59a
|
117 118 119 |
* @config: initialization data for V4L2 Flash sub-device * * Create V4L2 Flash sub-device wrapping given LED subsystem device. |
40cefffd3
|
120 121 122 |
* The ops pointer is stored by the V4L2 flash framework. No * references are held to config nor its contents once this function * has returned. |
42bd6f59a
|
123 124 125 126 127 128 |
* * Returns: A valid pointer, or, when an error occurs, the return * value is encoded using ERR_PTR(). Use IS_ERR() to check and * PTR_ERR() to obtain the numeric return value. */ struct v4l2_flash *v4l2_flash_init( |
048ea05b4
|
129 |
struct device *dev, struct fwnode_handle *fwn, |
42bd6f59a
|
130 |
struct led_classdev_flash *fled_cdev, |
503dd28af
|
131 132 133 134 135 136 137 138 139 140 |
const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config); /** * v4l2_flash_indicator_init - initialize V4L2 indicator sub-device * @dev: flash device, e.g. an I2C device * @fwn: fwnode_handle of the LED, may be NULL if the same as device's * @iled_cdev: LED flash class device representing the indicator LED * @config: initialization data for V4L2 Flash sub-device * * Create V4L2 Flash sub-device wrapping given LED subsystem device. |
40cefffd3
|
141 142 143 |
* The ops pointer is stored by the V4L2 flash framework. No * references are held to config nor its contents once this function * has returned. |
503dd28af
|
144 145 146 147 148 149 150 151 |
* * Returns: A valid pointer, or, when an error occurs, the return * value is encoded using ERR_PTR(). Use IS_ERR() to check and * PTR_ERR() to obtain the numeric return value. */ struct v4l2_flash *v4l2_flash_indicator_init( struct device *dev, struct fwnode_handle *fwn, struct led_classdev *iled_cdev, struct v4l2_flash_config *config); |
42bd6f59a
|
152 153 154 |
/** * v4l2_flash_release - release V4L2 Flash sub-device |
62ba6b22f
|
155 |
* @v4l2_flash: the V4L2 Flash sub-device to release |
42bd6f59a
|
156 157 158 159 160 161 162 |
* * Release V4L2 Flash sub-device. */ void v4l2_flash_release(struct v4l2_flash *v4l2_flash); #else static inline struct v4l2_flash *v4l2_flash_init( |
048ea05b4
|
163 |
struct device *dev, struct fwnode_handle *fwn, |
42bd6f59a
|
164 |
struct led_classdev_flash *fled_cdev, |
503dd28af
|
165 166 167 168 169 170 171 172 |
const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config) { return NULL; } static inline struct v4l2_flash *v4l2_flash_indicator_init( struct device *dev, struct fwnode_handle *fwn, struct led_classdev *iled_cdev, struct v4l2_flash_config *config) |
42bd6f59a
|
173 174 175 176 177 178 179 180 181 182 |
{ return NULL; } static inline void v4l2_flash_release(struct v4l2_flash *v4l2_flash) { } #endif /* CONFIG_V4L2_FLASH_LED_CLASS */ #endif /* _V4L2_FLASH_H */ |