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

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

Version: ~ [ linux-5.3-rc1 ] ~ [ linux-5.2.2 ] ~ [ linux-5.1.19 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.60 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.134 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.186 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.186 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.70 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

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

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

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | 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.

osdn.jp