blob: 6ec12c5a1a0e1d62206c6140517667c94c916c7c [file] [log] [blame]
Mauro Carvalho Chehab8dab9192019-06-28 09:20:20 -03001==============================
Jacek Anaszewskif6ad3952015-03-04 08:14:24 -08002Flash LED handling under Linux
3==============================
4
5Some LED devices provide two modes - torch and flash. In the LED subsystem
Mauro Carvalho Chehab8dab9192019-06-28 09:20:20 -03006those modes are supported by LED class (see Documentation/leds/leds-class.rst)
Jacek Anaszewskif6ad3952015-03-04 08:14:24 -08007and LED Flash class respectively. The torch mode related features are enabled
8by default and the flash ones only if a driver declares it by setting
9LED_DEV_CAP_FLASH flag.
10
11In order to enable the support for flash LEDs CONFIG_LEDS_CLASS_FLASH symbol
12must be defined in the kernel config. A LED Flash class driver must be
13registered in the LED subsystem with led_classdev_flash_register function.
14
15Following sysfs attributes are exposed for controlling flash LED devices:
16(see Documentation/ABI/testing/sysfs-class-led-flash)
Mauro Carvalho Chehab8dab9192019-06-28 09:20:20 -030017
Jacek Anaszewskif6ad3952015-03-04 08:14:24 -080018 - flash_brightness
19 - max_flash_brightness
20 - flash_timeout
21 - max_flash_timeout
22 - flash_strobe
23 - flash_fault
Jacek Anaszewskiaaf2cbc2015-06-08 02:02:18 -070024
25
26V4L2 flash wrapper for flash LEDs
27=================================
28
29A LED subsystem driver can be controlled also from the level of VideoForLinux2
30subsystem. In order to enable this CONFIG_V4L2_FLASH_LED_CLASS symbol has to
31be defined in the kernel config.
32
33The driver must call the v4l2_flash_init function to get registered in the
34V4L2 subsystem. The function takes six arguments:
Mauro Carvalho Chehab8dab9192019-06-28 09:20:20 -030035
36- dev:
37 flash device, e.g. an I2C device
38- of_node:
39 of_node of the LED, may be NULL if the same as device's
40- fled_cdev:
41 LED flash class device to wrap
42- iled_cdev:
43 LED flash class device representing indicator LED associated with
44 fled_cdev, may be NULL
45- ops:
46 V4L2 specific ops
47
48 * external_strobe_set
49 defines the source of the flash LED strobe -
Jacek Anaszewskiaaf2cbc2015-06-08 02:02:18 -070050 V4L2_CID_FLASH_STROBE control or external source, typically
51 a sensor, which makes it possible to synchronise the flash
52 strobe start with exposure start,
Mauro Carvalho Chehab8dab9192019-06-28 09:20:20 -030053 * intensity_to_led_brightness and led_brightness_to_intensity
54 perform
Jacek Anaszewskiaaf2cbc2015-06-08 02:02:18 -070055 enum led_brightness <-> V4L2 intensity conversion in a device
56 specific manner - they can be used for devices with non-linear
57 LED current scale.
Mauro Carvalho Chehab8dab9192019-06-28 09:20:20 -030058- config:
59 configuration for V4L2 Flash sub-device
60
61 * dev_name
62 the name of the media entity, unique in the system,
63 * flash_faults
64 bitmask of flash faults that the LED flash class
Jacek Anaszewskiaaf2cbc2015-06-08 02:02:18 -070065 device can report; corresponding LED_FAULT* bit definitions are
66 available in <linux/led-class-flash.h>,
Mauro Carvalho Chehab8dab9192019-06-28 09:20:20 -030067 * torch_intensity
68 constraints for the LED in TORCH mode
Jacek Anaszewskiaaf2cbc2015-06-08 02:02:18 -070069 in microamperes,
Mauro Carvalho Chehab8dab9192019-06-28 09:20:20 -030070 * indicator_intensity
71 constraints for the indicator LED
Jacek Anaszewskiaaf2cbc2015-06-08 02:02:18 -070072 in microamperes,
Mauro Carvalho Chehab8dab9192019-06-28 09:20:20 -030073 * has_external_strobe
74 determines whether the flash strobe source
Jacek Anaszewskiaaf2cbc2015-06-08 02:02:18 -070075 can be switched to external,
76
77On remove the v4l2_flash_release function has to be called, which takes one
78argument - struct v4l2_flash pointer returned previously by v4l2_flash_init.
79This function can be safely called with NULL or error pointer argument.
80
81Please refer to drivers/leds/leds-max77693.c for an exemplary usage of the
82v4l2 flash wrapper.
83
84Once the V4L2 sub-device is registered by the driver which created the Media
85controller device, the sub-device node acts just as a node of a native V4L2
86flash API device would. The calls are simply routed to the LED flash API.
87
88Opening the V4L2 flash sub-device makes the LED subsystem sysfs interface
89unavailable. The interface is re-enabled after the V4L2 flash sub-device
90is closed.