![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0-only */ 0002 /* 0003 * V4L2 flash LED sub-device registration helpers. 0004 * 0005 * Copyright (C) 2015 Samsung Electronics Co., Ltd 0006 * Author: Jacek Anaszewski <j.anaszewski@samsung.com> 0007 */ 0008 0009 #ifndef _V4L2_FLASH_H 0010 #define _V4L2_FLASH_H 0011 0012 #include <media/v4l2-ctrls.h> 0013 #include <media/v4l2-subdev.h> 0014 0015 struct led_classdev_flash; 0016 struct led_classdev; 0017 struct v4l2_flash; 0018 enum led_brightness; 0019 0020 /** 0021 * struct v4l2_flash_ctrl_data - flash control initialization data, filled 0022 * basing on the features declared by the LED flash 0023 * class driver in the v4l2_flash_config 0024 * @config: initialization data for a control 0025 * @cid: contains v4l2 flash control id if the config 0026 * field was initialized, 0 otherwise 0027 */ 0028 struct v4l2_flash_ctrl_data { 0029 struct v4l2_ctrl_config config; 0030 u32 cid; 0031 }; 0032 0033 /** 0034 * struct v4l2_flash_ops - V4L2 flash operations 0035 * 0036 * @external_strobe_set: Setup strobing the flash by hardware pin state 0037 * assertion. 0038 * @intensity_to_led_brightness: Convert intensity to brightness in a device 0039 * specific manner 0040 * @led_brightness_to_intensity: convert brightness to intensity in a device 0041 * specific manner. 0042 */ 0043 struct v4l2_flash_ops { 0044 int (*external_strobe_set)(struct v4l2_flash *v4l2_flash, 0045 bool enable); 0046 enum led_brightness (*intensity_to_led_brightness) 0047 (struct v4l2_flash *v4l2_flash, s32 intensity); 0048 s32 (*led_brightness_to_intensity) 0049 (struct v4l2_flash *v4l2_flash, enum led_brightness); 0050 }; 0051 0052 /** 0053 * struct v4l2_flash_config - V4L2 Flash sub-device initialization data 0054 * @dev_name: the name of the media entity, 0055 * unique in the system 0056 * @intensity: non-flash strobe constraints for the LED 0057 * @flash_faults: bitmask of flash faults that the LED flash class 0058 * device can report; corresponding LED_FAULT* bit 0059 * definitions are available in the header file 0060 * <linux/led-class-flash.h> 0061 * @has_external_strobe: external strobe capability 0062 */ 0063 struct v4l2_flash_config { 0064 char dev_name[32]; 0065 struct led_flash_setting intensity; 0066 u32 flash_faults; 0067 unsigned int has_external_strobe:1; 0068 }; 0069 0070 /** 0071 * struct v4l2_flash - Flash sub-device context 0072 * @fled_cdev: LED flash class device controlled by this sub-device 0073 * @iled_cdev: LED class device representing indicator LED associated 0074 * with the LED flash class device 0075 * @ops: V4L2 specific flash ops 0076 * @sd: V4L2 sub-device 0077 * @hdl: flash controls handler 0078 * @ctrls: array of pointers to controls, whose values define 0079 * the sub-device state 0080 */ 0081 struct v4l2_flash { 0082 struct led_classdev_flash *fled_cdev; 0083 struct led_classdev *iled_cdev; 0084 const struct v4l2_flash_ops *ops; 0085 0086 struct v4l2_subdev sd; 0087 struct v4l2_ctrl_handler hdl; 0088 struct v4l2_ctrl **ctrls; 0089 }; 0090 0091 /** 0092 * v4l2_subdev_to_v4l2_flash - Returns a &struct v4l2_flash from the 0093 * &struct v4l2_subdev embedded on it. 0094 * 0095 * @sd: pointer to &struct v4l2_subdev 0096 */ 0097 static inline struct v4l2_flash *v4l2_subdev_to_v4l2_flash( 0098 struct v4l2_subdev *sd) 0099 { 0100 return container_of(sd, struct v4l2_flash, sd); 0101 } 0102 0103 /** 0104 * v4l2_ctrl_to_v4l2_flash - Returns a &struct v4l2_flash from the 0105 * &struct v4l2_ctrl embedded on it. 0106 * 0107 * @c: pointer to &struct v4l2_ctrl 0108 */ 0109 static inline struct v4l2_flash *v4l2_ctrl_to_v4l2_flash(struct v4l2_ctrl *c) 0110 { 0111 return container_of(c->handler, struct v4l2_flash, hdl); 0112 } 0113 0114 #if IS_ENABLED(CONFIG_V4L2_FLASH_LED_CLASS) 0115 /** 0116 * v4l2_flash_init - initialize V4L2 flash led sub-device 0117 * @dev: flash device, e.g. an I2C device 0118 * @fwn: fwnode_handle of the LED, may be NULL if the same as device's 0119 * @fled_cdev: LED flash class device to wrap 0120 * @ops: V4L2 Flash device ops 0121 * @config: initialization data for V4L2 Flash sub-device 0122 * 0123 * Create V4L2 Flash sub-device wrapping given LED subsystem device. 0124 * The ops pointer is stored by the V4L2 flash framework. No 0125 * references are held to config nor its contents once this function 0126 * has returned. 0127 * 0128 * Returns: A valid pointer, or, when an error occurs, the return 0129 * value is encoded using ERR_PTR(). Use IS_ERR() to check and 0130 * PTR_ERR() to obtain the numeric return value. 0131 */ 0132 struct v4l2_flash *v4l2_flash_init( 0133 struct device *dev, struct fwnode_handle *fwn, 0134 struct led_classdev_flash *fled_cdev, 0135 const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config); 0136 0137 /** 0138 * v4l2_flash_indicator_init - initialize V4L2 indicator sub-device 0139 * @dev: flash device, e.g. an I2C device 0140 * @fwn: fwnode_handle of the LED, may be NULL if the same as device's 0141 * @iled_cdev: LED flash class device representing the indicator LED 0142 * @config: initialization data for V4L2 Flash sub-device 0143 * 0144 * Create V4L2 Flash sub-device wrapping given LED subsystem device. 0145 * The ops pointer is stored by the V4L2 flash framework. No 0146 * references are held to config nor its contents once this function 0147 * has returned. 0148 * 0149 * Returns: A valid pointer, or, when an error occurs, the return 0150 * value is encoded using ERR_PTR(). Use IS_ERR() to check and 0151 * PTR_ERR() to obtain the numeric return value. 0152 */ 0153 struct v4l2_flash *v4l2_flash_indicator_init( 0154 struct device *dev, struct fwnode_handle *fwn, 0155 struct led_classdev *iled_cdev, struct v4l2_flash_config *config); 0156 0157 /** 0158 * v4l2_flash_release - release V4L2 Flash sub-device 0159 * @v4l2_flash: the V4L2 Flash sub-device to release 0160 * 0161 * Release V4L2 Flash sub-device. 0162 */ 0163 void v4l2_flash_release(struct v4l2_flash *v4l2_flash); 0164 0165 #else 0166 static inline struct v4l2_flash *v4l2_flash_init( 0167 struct device *dev, struct fwnode_handle *fwn, 0168 struct led_classdev_flash *fled_cdev, 0169 const struct v4l2_flash_ops *ops, struct v4l2_flash_config *config) 0170 { 0171 return NULL; 0172 } 0173 0174 static inline struct v4l2_flash *v4l2_flash_indicator_init( 0175 struct device *dev, struct fwnode_handle *fwn, 0176 struct led_classdev *iled_cdev, struct v4l2_flash_config *config) 0177 { 0178 return NULL; 0179 } 0180 0181 static inline void v4l2_flash_release(struct v4l2_flash *v4l2_flash) 0182 { 0183 } 0184 #endif /* CONFIG_V4L2_FLASH_LED_CLASS */ 0185 0186 #endif /* _V4L2_FLASH_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |