← Documents Documentation/leds/leds-class-flash.rst GitHub 원문 ↗

Linux 6.18.37 · LEDs

Flash LED Handling under Linux

Torch·flash LED class와 V4L2 flash wrapper의 등록, intensity 변환, 제어권 규칙입니다.

Source pathDocumentation/leds/leds-class-flash.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

leds-class-flash.rst:1-90

Flash capability를 선언한 LED는 flash brightness·timeout·strobe·fault sysfs API와 선택적인 V4L2 sub-device wrapper를 제공합니다.

V4L2 node가 열려 있는 동안 sysfs 제어를 막아 두 interface의 동시 접근을 방지합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 ==============================
2 Flash LED handling under Linux
3 ==============================
4
5 Some LED devices provide two modes - torch and flash. In the LED subsystem
6 those modes are supported by LED class (see Documentation/leds/leds-class.rst)
7 and LED Flash class respectively. The torch mode related features are enabled
8 by default and the flash ones only if a driver declares it by setting
9 LED_DEV_CAP_FLASH flag.
10
11 In order to enable the support for flash LEDs CONFIG_LEDS_CLASS_FLASH symbol
12 must be defined in the kernel config. A LED Flash class driver must be
13 registered in the LED subsystem with led_classdev_flash_register function.
14
15 Following sysfs attributes are exposed for controlling flash LED devices:
16 (see Documentation/ABI/testing/sysfs-class-led-flash)
17
18 - flash_brightness
19 - max_flash_brightness
20 - flash_timeout
21 - max_flash_timeout
22 - flash_strobe
23 - flash_fault
24
25
26 V4L2 flash wrapper for flash LEDs
27 =================================
28
29 A LED subsystem driver can be controlled also from the level of VideoForLinux2
30 subsystem. In order to enable this CONFIG_V4L2_FLASH_LED_CLASS symbol has to
31 be defined in the kernel config.
32
33 The driver must call the v4l2_flash_init function to get registered in the
34 V4L2 subsystem. The function takes six arguments:
35
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 -
50 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,
53 * intensity_to_led_brightness and led_brightness_to_intensity
54 perform
55 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.
58 - 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
65 device can report; corresponding LED_FAULT* bit definitions are
66 available in <linux/led-class-flash.h>,
67 * torch_intensity
68 constraints for the LED in TORCH mode
69 in microamperes,
70 * indicator_intensity
71 constraints for the indicator LED
72 in microamperes,
73 * has_external_strobe
74 determines whether the flash strobe source
75 can be switched to external,
76
77 On remove the v4l2_flash_release function has to be called, which takes one
78 argument - struct v4l2_flash pointer returned previously by v4l2_flash_init.
79 This function can be safely called with NULL or error pointer argument.
80
81 Please refer to drivers/leds/leds-max77693.c for an exemplary usage of the
82 v4l2 flash wrapper.
83
84 Once the V4L2 sub-device is registered by the driver which created the Media
85 controller device, the sub-device node acts just as a node of a native V4L2
86 flash API device would. The calls are simply routed to the LED flash API.
87
88 Opening the V4L2 flash sub-device makes the LED subsystem sysfs interface
89 unavailable. The interface is re-enabled after the V4L2 flash sub-device
90 is closed.
91

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Torch와 flash LED class

1-28

일부 LED device는 torch와 flash 두 mode를 제공합니다. LED subsystem은 torch 기능을 일반 LED class로, flash 기능을 LED Flash class로 지원합니다. Torch 관련 기능은 기본 활성화되고 flash 기능은 driver가 `LED_DEV_CAP_FLASH` flag를 설정해 capability를 선언할 때만 활성화됩니다.

Flash LED 지원에는 kernel configuration의 `CONFIG_LEDS_CLASS_FLASH`가 필요합니다. Driver는 `led_classdev_flash_register`로 LED Flash class device를 LED subsystem에 등록해야 합니다.

Flash LED sysfs attribute
Attribute용도
`flash_brightness`Flash pulse 밝기
`max_flash_brightness`지원하는 최대 flash 밝기
`flash_timeout`Flash 지속 시간
`max_flash_timeout`최대 지속 시간
`flash_strobe`Strobe 시작·중지
`flash_fault`Flash hardware fault 상태

`Documentation/ABI/testing/sysfs-class-led-flash`에 정의된 제어 항목입니다.

==============================
Flash LED handling under Linux
==============================

Some LED devices provide two modes - torch and flash. In the LED subsystem
those modes are supported by LED class (see Documentation/leds/leds-class.rst)
and LED Flash class respectively. The torch mode related features are enabled
by default and the flash ones only if a driver declares it by setting
LED_DEV_CAP_FLASH flag.

In order to enable the support for flash LEDs CONFIG_LEDS_CLASS_FLASH symbol
must be defined in the kernel config. A LED Flash class driver must be
registered in the LED subsystem with led_classdev_flash_register function.

Following sysfs attributes are exposed for controlling flash LED devices:
(see Documentation/ABI/testing/sysfs-class-led-flash)

        - flash_brightness
        - max_flash_brightness
        - flash_timeout
        - max_flash_timeout
        - flash_strobe
        - flash_fault


V4L2 flash wrapper for flash LEDs
=================================

V4L2 flash wrapper

29-90

LED subsystem driver는 VideoForLinux2에서도 제어할 수 있습니다. `CONFIG_V4L2_FLASH_LED_CLASS`를 활성화하고 `v4l2_flash_init`을 호출해 V4L2 subsystem에 등록합니다.

v4l2_flash_init 인자
인자의미
`dev`I2C device 같은 flash device
`of_node`LED의 device tree node, device와 같으면 `NULL` 가능
`fled_cdev`감쌀 LED flash class device
`iled_cdev`연결된 indicator LED flash class device, 선택 사항
`ops`External strobe와 intensity 변환을 포함한 V4L2-specific operation
`config`Media entity 이름, fault, intensity constraint, external strobe capability

LED Flash class device를 V4L2 flash sub-device로 감싸는 입력입니다.

`ops.external_strobe_set`은 strobe source를 `V4L2_CID_FLASH_STROBE` control 또는 보통 sensor인 external source 중에서 선택합니다. External source를 사용하면 flash strobe 시작과 exposure 시작을 동기화할 수 있습니다.

`intensity_to_led_brightness`와 `led_brightness_to_intensity`는 `enum led_brightness`와 V4L2 intensity를 device-specific 방식으로 변환합니다. LED current scale이 비선형인 device에 필요합니다.

Configuration의 `dev_name`은 system에서 유일한 media entity 이름입니다. `flash_faults`는 `<linux/led-class-flash.h>`의 `LED_FAULT*` bit로 보고할 수 있는 fault를 나타내고, `torch_intensity`와 `indicator_intensity`는 microampere 단위 constraint를 지정합니다. `has_external_strobe`는 strobe source 전환 가능 여부를 나타냅니다.

Driver 제거 시 `v4l2_flash_init`이 반환한 `struct v4l2_flash` pointer로 `v4l2_flash_release`를 호출합니다. 이 함수는 `NULL` 또는 error pointer로도 안전하게 호출할 수 있습니다. 사용 예는 `drivers/leds/leds-max77693.c`에 있습니다.

V4L2 wrapper 제어권
LED Flash class device 등록`v4l2_flash_init`으로 V4L2 sub-device 생성V4L2 node open 시 LED sysfs interface 비활성화V4L2 call을 LED flash API로 전달V4L2 node close 후 sysfs interface 재활성화Driver remove에서 `v4l2_flash_release` 호출

V4L2 sub-device가 열려 있는 동안 sysfs와의 동시 제어를 막습니다.

A LED subsystem driver can be controlled also from the level of VideoForLinux2
subsystem. In order to enable this CONFIG_V4L2_FLASH_LED_CLASS symbol has to
be defined in the kernel config.

The driver must call the v4l2_flash_init function to get registered in the
V4L2 subsystem. The function takes six arguments:

- dev:
        flash device, e.g. an I2C device
- of_node:
        of_node of the LED, may be NULL if the same as device's
- fled_cdev:
        LED flash class device to wrap
- iled_cdev:
        LED flash class device representing indicator LED associated with
        fled_cdev, may be NULL
- ops:
        V4L2 specific ops

        * external_strobe_set
                defines the source of the flash LED strobe -
                V4L2_CID_FLASH_STROBE control or external source, typically
                a sensor, which makes it possible to synchronise the flash
                strobe start with exposure start,
        * intensity_to_led_brightness and led_brightness_to_intensity
                perform
                enum led_brightness <-> V4L2 intensity conversion in a device
                specific manner - they can be used for devices with non-linear
                LED current scale.
- config:
        configuration for V4L2 Flash sub-device

        * dev_name
                the name of the media entity, unique in the system,
        * flash_faults
                bitmask of flash faults that the LED flash class
                device can report; corresponding LED_FAULT* bit definitions are
                available in <linux/led-class-flash.h>,
        * torch_intensity
                constraints for the LED in TORCH mode
                in microamperes,
        * indicator_intensity
                constraints for the indicator LED
                in microamperes,
        * has_external_strobe
                determines whether the flash strobe source
                can be switched to external,

On remove the v4l2_flash_release function has to be called, which takes one
argument - struct v4l2_flash pointer returned previously by v4l2_flash_init.
This function can be safely called with NULL or error pointer argument.

Please refer to drivers/leds/leds-max77693.c for an exemplary usage of the
v4l2 flash wrapper.

Once the V4L2 sub-device is registered by the driver which created the Media
controller device, the sub-device node acts just as a node of a native V4L2
flash API device would. The calls are simply routed to the LED flash API.

Opening the V4L2 flash sub-device makes the LED subsystem sysfs interface
unavailable. The interface is re-enabled after the V4L2 flash sub-device
is closed.