Back to home page

OSCL-LXR

 
 

    


0001 ==============================
0002 Flash LED handling under Linux
0003 ==============================
0004 
0005 Some LED devices provide two modes - torch and flash. In the LED subsystem
0006 those modes are supported by LED class (see Documentation/leds/leds-class.rst)
0007 and LED Flash class respectively. The torch mode related features are enabled
0008 by default and the flash ones only if a driver declares it by setting
0009 LED_DEV_CAP_FLASH flag.
0010 
0011 In order to enable the support for flash LEDs CONFIG_LEDS_CLASS_FLASH symbol
0012 must be defined in the kernel config. A LED Flash class driver must be
0013 registered in the LED subsystem with led_classdev_flash_register function.
0014 
0015 Following sysfs attributes are exposed for controlling flash LED devices:
0016 (see Documentation/ABI/testing/sysfs-class-led-flash)
0017 
0018         - flash_brightness
0019         - max_flash_brightness
0020         - flash_timeout
0021         - max_flash_timeout
0022         - flash_strobe
0023         - flash_fault
0024 
0025 
0026 V4L2 flash wrapper for flash LEDs
0027 =================================
0028 
0029 A LED subsystem driver can be controlled also from the level of VideoForLinux2
0030 subsystem. In order to enable this CONFIG_V4L2_FLASH_LED_CLASS symbol has to
0031 be defined in the kernel config.
0032 
0033 The driver must call the v4l2_flash_init function to get registered in the
0034 V4L2 subsystem. The function takes six arguments:
0035 
0036 - dev:
0037         flash device, e.g. an I2C device
0038 - of_node:
0039         of_node of the LED, may be NULL if the same as device's
0040 - fled_cdev:
0041         LED flash class device to wrap
0042 - iled_cdev:
0043         LED flash class device representing indicator LED associated with
0044         fled_cdev, may be NULL
0045 - ops:
0046         V4L2 specific ops
0047 
0048         * external_strobe_set
0049                 defines the source of the flash LED strobe -
0050                 V4L2_CID_FLASH_STROBE control or external source, typically
0051                 a sensor, which makes it possible to synchronise the flash
0052                 strobe start with exposure start,
0053         * intensity_to_led_brightness and led_brightness_to_intensity
0054                 perform
0055                 enum led_brightness <-> V4L2 intensity conversion in a device
0056                 specific manner - they can be used for devices with non-linear
0057                 LED current scale.
0058 - config:
0059         configuration for V4L2 Flash sub-device
0060 
0061         * dev_name
0062                 the name of the media entity, unique in the system,
0063         * flash_faults
0064                 bitmask of flash faults that the LED flash class
0065                 device can report; corresponding LED_FAULT* bit definitions are
0066                 available in <linux/led-class-flash.h>,
0067         * torch_intensity
0068                 constraints for the LED in TORCH mode
0069                 in microamperes,
0070         * indicator_intensity
0071                 constraints for the indicator LED
0072                 in microamperes,
0073         * has_external_strobe
0074                 determines whether the flash strobe source
0075                 can be switched to external,
0076 
0077 On remove the v4l2_flash_release function has to be called, which takes one
0078 argument - struct v4l2_flash pointer returned previously by v4l2_flash_init.
0079 This function can be safely called with NULL or error pointer argument.
0080 
0081 Please refer to drivers/leds/leds-max77693.c for an exemplary usage of the
0082 v4l2 flash wrapper.
0083 
0084 Once the V4L2 sub-device is registered by the driver which created the Media
0085 controller device, the sub-device node acts just as a node of a native V4L2
0086 flash API device would. The calls are simply routed to the LED flash API.
0087 
0088 Opening the V4L2 flash sub-device makes the LED subsystem sysfs interface
0089 unavailable. The interface is re-enabled after the V4L2 flash sub-device
0090 is closed.