leds-class-flash.txt 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. Flash LED handling under Linux
  2. ==============================
  3. Some LED devices provide two modes - torch and flash. In the LED subsystem
  4. those modes are supported by LED class (see Documentation/leds/leds-class.txt)
  5. and LED Flash class respectively. The torch mode related features are enabled
  6. by default and the flash ones only if a driver declares it by setting
  7. LED_DEV_CAP_FLASH flag.
  8. In order to enable the support for flash LEDs CONFIG_LEDS_CLASS_FLASH symbol
  9. must be defined in the kernel config. A LED Flash class driver must be
  10. registered in the LED subsystem with led_classdev_flash_register function.
  11. Following sysfs attributes are exposed for controlling flash LED devices:
  12. (see Documentation/ABI/testing/sysfs-class-led-flash)
  13. - flash_brightness
  14. - max_flash_brightness
  15. - flash_timeout
  16. - max_flash_timeout
  17. - flash_strobe
  18. - flash_fault
  19. V4L2 flash wrapper for flash LEDs
  20. =================================
  21. A LED subsystem driver can be controlled also from the level of VideoForLinux2
  22. subsystem. In order to enable this CONFIG_V4L2_FLASH_LED_CLASS symbol has to
  23. be defined in the kernel config.
  24. The driver must call the v4l2_flash_init function to get registered in the
  25. V4L2 subsystem. The function takes six arguments:
  26. - dev : flash device, e.g. an I2C device
  27. - of_node : of_node of the LED, may be NULL if the same as device's
  28. - fled_cdev : LED flash class device to wrap
  29. - iled_cdev : LED flash class device representing indicator LED associated with
  30. fled_cdev, may be NULL
  31. - ops : V4L2 specific ops
  32. * external_strobe_set - defines the source of the flash LED strobe -
  33. V4L2_CID_FLASH_STROBE control or external source, typically
  34. a sensor, which makes it possible to synchronise the flash
  35. strobe start with exposure start,
  36. * intensity_to_led_brightness and led_brightness_to_intensity - perform
  37. enum led_brightness <-> V4L2 intensity conversion in a device
  38. specific manner - they can be used for devices with non-linear
  39. LED current scale.
  40. - config : configuration for V4L2 Flash sub-device
  41. * dev_name - the name of the media entity, unique in the system,
  42. * flash_faults - bitmask of flash faults that the LED flash class
  43. device can report; corresponding LED_FAULT* bit definitions are
  44. available in <linux/led-class-flash.h>,
  45. * torch_intensity - constraints for the LED in TORCH mode
  46. in microamperes,
  47. * indicator_intensity - constraints for the indicator LED
  48. in microamperes,
  49. * has_external_strobe - determines whether the flash strobe source
  50. can be switched to external,
  51. On remove the v4l2_flash_release function has to be called, which takes one
  52. argument - struct v4l2_flash pointer returned previously by v4l2_flash_init.
  53. This function can be safely called with NULL or error pointer argument.
  54. Please refer to drivers/leds/leds-max77693.c for an exemplary usage of the
  55. v4l2 flash wrapper.
  56. Once the V4L2 sub-device is registered by the driver which created the Media
  57. controller device, the sub-device node acts just as a node of a native V4L2
  58. flash API device would. The calls are simply routed to the LED flash API.
  59. Opening the V4L2 flash sub-device makes the LED subsystem sysfs interface
  60. unavailable. The interface is re-enabled after the V4L2 flash sub-device
  61. is closed.