Blame view
include/linux/led-class-flash.h
6.08 KB
d2912cb15
|
1 |
/* SPDX-License-Identifier: GPL-2.0-only */ |
7aea8389a
|
2 3 4 5 6 |
/* * LED Flash class interface * * Copyright (C) 2015 Samsung Electronics Co., Ltd. * Author: Jacek Anaszewski <j.anaszewski@samsung.com> |
7aea8389a
|
7 8 9 10 11 |
*/ #ifndef __LINUX_FLASH_LEDS_H_INCLUDED #define __LINUX_FLASH_LEDS_H_INCLUDED #include <linux/leds.h> |
7aea8389a
|
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
struct device_node; struct led_classdev_flash; /* * Supported led fault bits - must be kept in synch * with V4L2_FLASH_FAULT bits. */ #define LED_FAULT_OVER_VOLTAGE (1 << 0) #define LED_FAULT_TIMEOUT (1 << 1) #define LED_FAULT_OVER_TEMPERATURE (1 << 2) #define LED_FAULT_SHORT_CIRCUIT (1 << 3) #define LED_FAULT_OVER_CURRENT (1 << 4) #define LED_FAULT_INDICATOR (1 << 5) #define LED_FAULT_UNDER_VOLTAGE (1 << 6) #define LED_FAULT_INPUT_VOLTAGE (1 << 7) #define LED_FAULT_LED_OVER_TEMPERATURE (1 << 8) #define LED_NUM_FLASH_FAULTS 9 |
9647507af
|
30 |
#define LED_FLASH_SYSFS_GROUPS_SIZE 5 |
7aea8389a
|
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
struct led_flash_ops { /* set flash brightness */ int (*flash_brightness_set)(struct led_classdev_flash *fled_cdev, u32 brightness); /* get flash brightness */ int (*flash_brightness_get)(struct led_classdev_flash *fled_cdev, u32 *brightness); /* set flash strobe state */ int (*strobe_set)(struct led_classdev_flash *fled_cdev, bool state); /* get flash strobe state */ int (*strobe_get)(struct led_classdev_flash *fled_cdev, bool *state); /* set flash timeout */ int (*timeout_set)(struct led_classdev_flash *fled_cdev, u32 timeout); /* get the flash LED fault */ int (*fault_get)(struct led_classdev_flash *fled_cdev, u32 *fault); }; /* * Current value of a flash setting along * with its constraints. */ struct led_flash_setting { /* maximum allowed value */ u32 min; /* maximum allowed value */ u32 max; /* step value */ u32 step; /* current value */ u32 val; }; struct led_classdev_flash { /* led class device */ struct led_classdev led_cdev; /* flash led specific ops */ const struct led_flash_ops *ops; /* flash brightness value in microamperes along with its constraints */ struct led_flash_setting brightness; /* flash timeout value in microseconds along with its constraints */ struct led_flash_setting timeout; /* LED Flash class sysfs groups */ |
9647507af
|
78 |
const struct attribute_group *sysfs_groups[LED_FLASH_SYSFS_GROUPS_SIZE]; |
7aea8389a
|
79 80 81 82 83 84 85 86 87 |
}; static inline struct led_classdev_flash *lcdev_to_flcdev( struct led_classdev *lcdev) { return container_of(lcdev, struct led_classdev_flash, led_cdev); } /** |
b2b998c0f
|
88 89 90 |
* led_classdev_flash_register_ext - register a new object of LED class with * init data and with support for flash LEDs * @parent: LED flash controller device this flash LED is driven by |
7aea8389a
|
91 |
* @fled_cdev: the led_classdev_flash structure for this device |
b2b998c0f
|
92 |
* @init_data: the LED class flash device initialization data |
7aea8389a
|
93 94 95 |
* * Returns: 0 on success or negative error value on failure */ |
57e5c31e5
|
96 97 98 |
int led_classdev_flash_register_ext(struct device *parent, struct led_classdev_flash *fled_cdev, struct led_init_data *init_data); |
b2b998c0f
|
99 |
|
4a29f90e6
|
100 |
static inline int led_classdev_flash_register(struct device *parent, |
57e5c31e5
|
101 |
struct led_classdev_flash *fled_cdev) |
4a29f90e6
|
102 103 104 |
{ return led_classdev_flash_register_ext(parent, fled_cdev, NULL); } |
7aea8389a
|
105 106 107 108 109 110 111 112 |
/** * led_classdev_flash_unregister - unregisters an object of led_classdev class * with support for flash LEDs * @fled_cdev: the flash LED to unregister * * Unregister a previously registered via led_classdev_flash_register object */ |
57e5c31e5
|
113 |
void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev); |
7aea8389a
|
114 |
|
20cdba9d9
|
115 116 117 118 119 120 121 122 123 124 125 126 127 |
int devm_led_classdev_flash_register_ext(struct device *parent, struct led_classdev_flash *fled_cdev, struct led_init_data *init_data); static inline int devm_led_classdev_flash_register(struct device *parent, struct led_classdev_flash *fled_cdev) { return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); } void devm_led_classdev_flash_unregister(struct device *parent, struct led_classdev_flash *fled_cdev); |
7aea8389a
|
128 129 130 131 132 133 134 135 136 137 138 139 |
/** * led_set_flash_strobe - setup flash strobe * @fled_cdev: the flash LED to set strobe on * @state: 1 - strobe flash, 0 - stop flash strobe * * Strobe the flash LED. * * Returns: 0 on success or negative error value on failure */ static inline int led_set_flash_strobe(struct led_classdev_flash *fled_cdev, bool state) { |
09db1a462
|
140 141 |
if (!fled_cdev) return -EINVAL; |
7aea8389a
|
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
return fled_cdev->ops->strobe_set(fled_cdev, state); } /** * led_get_flash_strobe - get flash strobe status * @fled_cdev: the flash LED to query * @state: 1 - flash is strobing, 0 - flash is off * * Check whether the flash is strobing at the moment. * * Returns: 0 on success or negative error value on failure */ static inline int led_get_flash_strobe(struct led_classdev_flash *fled_cdev, bool *state) { |
09db1a462
|
157 158 |
if (!fled_cdev) return -EINVAL; |
7aea8389a
|
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
if (fled_cdev->ops->strobe_get) return fled_cdev->ops->strobe_get(fled_cdev, state); return -EINVAL; } /** * led_set_flash_brightness - set flash LED brightness * @fled_cdev: the flash LED to set * @brightness: the brightness to set it to * * Set a flash LED's brightness. * * Returns: 0 on success or negative error value on failure */ |
57e5c31e5
|
174 175 |
int led_set_flash_brightness(struct led_classdev_flash *fled_cdev, u32 brightness); |
7aea8389a
|
176 177 178 179 180 181 182 183 184 185 |
/** * led_update_flash_brightness - update flash LED brightness * @fled_cdev: the flash LED to query * * Get a flash LED's current brightness and update led_flash->brightness * member with the obtained value. * * Returns: 0 on success or negative error value on failure */ |
57e5c31e5
|
186 |
int led_update_flash_brightness(struct led_classdev_flash *fled_cdev); |
7aea8389a
|
187 188 189 190 191 192 193 194 195 196 |
/** * led_set_flash_timeout - set flash LED timeout * @fled_cdev: the flash LED to set * @timeout: the flash timeout to set it to * * Set the flash strobe duration. * * Returns: 0 on success or negative error value on failure */ |
57e5c31e5
|
197 |
int led_set_flash_timeout(struct led_classdev_flash *fled_cdev, u32 timeout); |
7aea8389a
|
198 199 200 201 202 203 204 205 206 207 |
/** * led_get_flash_fault - get the flash LED fault * @fled_cdev: the flash LED to query * @fault: bitmask containing flash faults * * Get the flash LED fault. * * Returns: 0 on success or negative error value on failure */ |
57e5c31e5
|
208 |
int led_get_flash_fault(struct led_classdev_flash *fled_cdev, u32 *fault); |
7aea8389a
|
209 210 |
#endif /* __LINUX_FLASH_LEDS_H_INCLUDED */ |