leds-class-flash.rst 3.2 KB

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