~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/led-class-flash.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php