iwlwifi: rs: remove unneeded check of average tpt in window
[linux-2.6/btrfs-unstable.git] / include / linux / led-class-flash.h
blob5ba2facd7a5162fab65a89d999d90e54f392790f
1 /*
2 * LED Flash class interface
4 * Copyright (C) 2015 Samsung Electronics Co., Ltd.
5 * Author: Jacek Anaszewski <j.anaszewski@samsung.com>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
12 #ifndef __LINUX_FLASH_LEDS_H_INCLUDED
13 #define __LINUX_FLASH_LEDS_H_INCLUDED
15 #include <linux/leds.h>
16 #include <uapi/linux/v4l2-controls.h>
18 struct device_node;
19 struct led_classdev_flash;
22 * Supported led fault bits - must be kept in synch
23 * with V4L2_FLASH_FAULT bits.
25 #define LED_FAULT_OVER_VOLTAGE (1 << 0)
26 #define LED_FAULT_TIMEOUT (1 << 1)
27 #define LED_FAULT_OVER_TEMPERATURE (1 << 2)
28 #define LED_FAULT_SHORT_CIRCUIT (1 << 3)
29 #define LED_FAULT_OVER_CURRENT (1 << 4)
30 #define LED_FAULT_INDICATOR (1 << 5)
31 #define LED_FAULT_UNDER_VOLTAGE (1 << 6)
32 #define LED_FAULT_INPUT_VOLTAGE (1 << 7)
33 #define LED_FAULT_LED_OVER_TEMPERATURE (1 << 8)
34 #define LED_NUM_FLASH_FAULTS 9
36 #define LED_FLASH_MAX_SYSFS_GROUPS 7
38 struct led_flash_ops {
39 /* set flash brightness */
40 int (*flash_brightness_set)(struct led_classdev_flash *fled_cdev,
41 u32 brightness);
42 /* get flash brightness */
43 int (*flash_brightness_get)(struct led_classdev_flash *fled_cdev,
44 u32 *brightness);
45 /* set flash strobe state */
46 int (*strobe_set)(struct led_classdev_flash *fled_cdev, bool state);
47 /* get flash strobe state */
48 int (*strobe_get)(struct led_classdev_flash *fled_cdev, bool *state);
49 /* set flash timeout */
50 int (*timeout_set)(struct led_classdev_flash *fled_cdev, u32 timeout);
51 /* get the flash LED fault */
52 int (*fault_get)(struct led_classdev_flash *fled_cdev, u32 *fault);
56 * Current value of a flash setting along
57 * with its constraints.
59 struct led_flash_setting {
60 /* maximum allowed value */
61 u32 min;
62 /* maximum allowed value */
63 u32 max;
64 /* step value */
65 u32 step;
66 /* current value */
67 u32 val;
70 struct led_classdev_flash {
71 /* led class device */
72 struct led_classdev led_cdev;
74 /* flash led specific ops */
75 const struct led_flash_ops *ops;
77 /* flash brightness value in microamperes along with its constraints */
78 struct led_flash_setting brightness;
80 /* flash timeout value in microseconds along with its constraints */
81 struct led_flash_setting timeout;
83 /* LED Flash class sysfs groups */
84 const struct attribute_group *sysfs_groups[LED_FLASH_MAX_SYSFS_GROUPS];
86 /* LEDs available for flash strobe synchronization */
87 struct led_classdev_flash **sync_leds;
89 /* Number of LEDs available for flash strobe synchronization */
90 int num_sync_leds;
93 * The identifier of the sub-led to synchronize the flash strobe with.
94 * Identifiers start from 1, which reflects the first element from the
95 * sync_leds array. 0 means that the flash strobe should not be
96 * synchronized.
98 u32 sync_led_id;
101 static inline struct led_classdev_flash *lcdev_to_flcdev(
102 struct led_classdev *lcdev)
104 return container_of(lcdev, struct led_classdev_flash, led_cdev);
108 * led_classdev_flash_register - register a new object of led_classdev class
109 * with support for flash LEDs
110 * @parent: the flash LED to register
111 * @fled_cdev: the led_classdev_flash structure for this device
113 * Returns: 0 on success or negative error value on failure
115 extern int led_classdev_flash_register(struct device *parent,
116 struct led_classdev_flash *fled_cdev);
119 * led_classdev_flash_unregister - unregisters an object of led_classdev class
120 * with support for flash LEDs
121 * @fled_cdev: the flash LED to unregister
123 * Unregister a previously registered via led_classdev_flash_register object
125 extern void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev);
128 * led_set_flash_strobe - setup flash strobe
129 * @fled_cdev: the flash LED to set strobe on
130 * @state: 1 - strobe flash, 0 - stop flash strobe
132 * Strobe the flash LED.
134 * Returns: 0 on success or negative error value on failure
136 static inline int led_set_flash_strobe(struct led_classdev_flash *fled_cdev,
137 bool state)
139 return fled_cdev->ops->strobe_set(fled_cdev, state);
143 * led_get_flash_strobe - get flash strobe status
144 * @fled_cdev: the flash LED to query
145 * @state: 1 - flash is strobing, 0 - flash is off
147 * Check whether the flash is strobing at the moment.
149 * Returns: 0 on success or negative error value on failure
151 static inline int led_get_flash_strobe(struct led_classdev_flash *fled_cdev,
152 bool *state)
154 if (fled_cdev->ops->strobe_get)
155 return fled_cdev->ops->strobe_get(fled_cdev, state);
157 return -EINVAL;
161 * led_set_flash_brightness - set flash LED brightness
162 * @fled_cdev: the flash LED to set
163 * @brightness: the brightness to set it to
165 * Set a flash LED's brightness.
167 * Returns: 0 on success or negative error value on failure
169 extern int led_set_flash_brightness(struct led_classdev_flash *fled_cdev,
170 u32 brightness);
173 * led_update_flash_brightness - update flash LED brightness
174 * @fled_cdev: the flash LED to query
176 * Get a flash LED's current brightness and update led_flash->brightness
177 * member with the obtained value.
179 * Returns: 0 on success or negative error value on failure
181 extern int led_update_flash_brightness(struct led_classdev_flash *fled_cdev);
184 * led_set_flash_timeout - set flash LED timeout
185 * @fled_cdev: the flash LED to set
186 * @timeout: the flash timeout to set it to
188 * Set the flash strobe duration.
190 * Returns: 0 on success or negative error value on failure
192 extern int led_set_flash_timeout(struct led_classdev_flash *fled_cdev,
193 u32 timeout);
196 * led_get_flash_fault - get the flash LED fault
197 * @fled_cdev: the flash LED to query
198 * @fault: bitmask containing flash faults
200 * Get the flash LED fault.
202 * Returns: 0 on success or negative error value on failure
204 extern int led_get_flash_fault(struct led_classdev_flash *fled_cdev,
205 u32 *fault);
207 #endif /* __LINUX_FLASH_LEDS_H_INCLUDED */