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

Linux 6.18.37 · LEDs

Multicolor LED Handling under Linux

여러 color channel의 hue 구성과 global brightness scaling을 제공하는 multicolor LED class입니다.

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

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

1. 요약·해설

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

요약·해설

leds-class-multicolor.rst:1-106

`multi_intensity`가 channel 비율로 hue를 만들고 global `brightness`가 그 비율을 유지하면서 전체 lightness를 조절합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ====================================
4 Multicolor LED handling under Linux
5 ====================================
6
7 Description
8 ===========
9 The multicolor class groups monochrome LEDs and allows controlling two
10 aspects of the final combined color: hue and lightness. The former is
11 controlled via the multi_intensity array file and the latter is controlled
12 via brightness file.
13
14 Multicolor Class Control
15 ========================
16 The multicolor class presents files that groups the colors as indexes in an
17 array. These files are children under the LED parent node created by the
18 led_class framework. The led_class framework is documented in led-class.rst
19 within this documentation directory.
20
21 Each colored LED will be indexed under the ``multi_*`` files. The order of the
22 colors will be arbitrary. The ``multi_index`` file can be read to determine the
23 color name to indexed value.
24
25 The ``multi_index`` file is an array that contains the string list of the colors as
26 they are defined in each ``multi_*`` array file.
27
28 The ``multi_intensity`` is an array that can be read or written to for the
29 individual color intensities. All elements within this array must be written in
30 order for the color LED intensities to be updated.
31
32 Directory Layout Example
33 ========================
34 .. code-block:: console
35
36 root:/sys/class/leds/multicolor:status# ls -lR
37 -rw-r--r-- 1 root root 4096 Oct 19 16:16 brightness
38 -r--r--r-- 1 root root 4096 Oct 19 16:16 max_brightness
39 -r--r--r-- 1 root root 4096 Oct 19 16:16 multi_index
40 -rw-r--r-- 1 root root 4096 Oct 19 16:16 multi_intensity
41
42 ..
43
44 Multicolor Class Brightness Control
45 ===================================
46 The brightness level for each LED is calculated based on the color LED
47 intensity setting divided by the global max_brightness setting multiplied by
48 the requested brightness.
49
50 ``led_brightness = brightness * multi_intensity/max_brightness``
51
52 Example:
53 A user first writes the multi_intensity file with the brightness levels
54 for each LED that are necessary to achieve a certain color output from a
55 multicolor LED group.
56
57 .. code-block:: console
58
59 # cat /sys/class/leds/multicolor:status/multi_index
60 green blue red
61
62 # echo 43 226 138 > /sys/class/leds/multicolor:status/multi_intensity
63
64 red -
65 intensity = 138
66 max_brightness = 255
67 green -
68 intensity = 43
69 max_brightness = 255
70 blue -
71 intensity = 226
72 max_brightness = 255
73
74 ..
75
76 The user can control the brightness of that multicolor LED group by writing the
77 global 'brightness' control. Assuming a max_brightness of 255 the user
78 may want to dim the LED color group to half. The user would write a value of
79 128 to the global brightness file then the values written to each LED will be
80 adjusted base on this value.
81
82 .. code-block:: console
83
84 # cat /sys/class/leds/multicolor:status/max_brightness
85 255
86 # echo 128 > /sys/class/leds/multicolor:status/brightness
87
88 ..
89
90 .. code-block:: none
91
92 adjusted_red_value = 128 * 138/255 = 69
93 adjusted_green_value = 128 * 43/255 = 21
94 adjusted_blue_value = 128 * 226/255 = 113
95
96 ..
97
98 Reading the global brightness file will return the current brightness value of
99 the color LED group.
100
101 .. code-block:: console
102
103 # cat /sys/class/leds/multicolor:status/brightness
104 128
105
106 ..
107

3. 한국어 전문 번역

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

Multicolor class와 색상 제어

1-36

Multicolor class는 여러 monochrome LED를 한 group으로 묶고 최종 조합 색상의 hue와 lightness를 제어합니다. Hue는 `multi_intensity` array file, lightness는 공통 `brightness` file이 담당합니다.

Multicolor file은 LED class framework가 만든 parent node 아래에 있고 color를 array index로 묶습니다. 각 color LED는 `multi_*` file의 같은 index에 대응하지만 순서는 임의이므로 `multi_index`를 읽어 color 이름과 index를 확인해야 합니다.

`multi_index`는 각 `multi_*` array에서 사용하는 color string 목록입니다. `multi_intensity`는 각 color intensity를 읽고 쓰는 array이며, color update를 적용하려면 모든 element를 순서대로 한 번에 써야 합니다.

Multicolor control file
File역할접근
`multi_index`Array index별 color 이름Read-only
`multi_intensity`개별 color intensity 전체 배열Read/write
`brightness`조합된 LED group의 global lightnessRead/write
`max_brightness`Global scaling denominatorRead-only

Hue 구성과 group lightness를 분리합니다.

.. SPDX-License-Identifier: GPL-2.0

====================================
Multicolor LED handling under Linux
====================================

Description
===========
The multicolor class groups monochrome LEDs and allows controlling two
aspects of the final combined color: hue and lightness. The former is
controlled via the multi_intensity array file and the latter is controlled
via brightness file.

Multicolor Class Control
========================
The multicolor class presents files that groups the colors as indexes in an
array.  These files are children under the LED parent node created by the
led_class framework.  The led_class framework is documented in led-class.rst
within this documentation directory.

Each colored LED will be indexed under the ``multi_*`` files. The order of the
colors will be arbitrary. The ``multi_index`` file can be read to determine the
color name to indexed value.

The ``multi_index`` file is an array that contains the string list of the colors as
they are defined in each ``multi_*`` array file.

The ``multi_intensity`` is an array that can be read or written to for the
individual color intensities.  All elements within this array must be written in
order for the color LED intensities to be updated.

Directory Layout Example
========================
.. code-block:: console

    root:/sys/class/leds/multicolor:status# ls -lR

Directory layout과 brightness 계산

37-80

예제 `/sys/class/leds/multicolor:status`에는 `brightness`, `max_brightness`, `multi_index`, `multi_intensity` 네 file이 있습니다.

각 color LED에 실제로 전달되는 brightness는 global brightness와 해당 color intensity를 곱하고 `max_brightness`로 나누어 계산합니다.

공식은 `led_brightness = brightness * multi_intensity / max_brightness`입니다. 따라서 `multi_intensity`가 hue 비율을 정하고 `brightness`가 비율을 보존하면서 전체 밝기를 scale합니다.

예제에서 `multi_index`는 `green blue red`이고 `multi_intensity`에 `43 226 138`을 씁니다. 이에 따라 green=43, blue=226, red=138이며 각 최대값은 255입니다.

Multicolor brightness 계산
`multi_index`에서 green·blue·red 순서 확인`multi_intensity`에 `43 226 138` 전체 배열 기록Global `brightness` 값 선택각 channel에 `brightness × intensity ÷ max_brightness` 적용

Color composition을 먼저 고정한 뒤 global brightness로 동일 비율을 scale합니다.

    -rw-r--r--    1 root     root          4096 Oct 19 16:16 brightness
    -r--r--r--    1 root     root          4096 Oct 19 16:16 max_brightness
    -r--r--r--    1 root     root          4096 Oct 19 16:16 multi_index
    -rw-r--r--    1 root     root          4096 Oct 19 16:16 multi_intensity

..

Multicolor Class Brightness Control
===================================
The brightness level for each LED is calculated based on the color LED
intensity setting divided by the global max_brightness setting multiplied by
the requested brightness.

``led_brightness = brightness * multi_intensity/max_brightness``

Example:
A user first writes the multi_intensity file with the brightness levels
for each LED that are necessary to achieve a certain color output from a
multicolor LED group.

.. code-block:: console

    # cat /sys/class/leds/multicolor:status/multi_index
    green blue red

    # echo 43 226 138 > /sys/class/leds/multicolor:status/multi_intensity

    red -
            intensity = 138
            max_brightness = 255
    green -
            intensity = 43
            max_brightness = 255
    blue -
            intensity = 226
            max_brightness = 255

..

The user can control the brightness of that multicolor LED group by writing the
global 'brightness' control.  Assuming a max_brightness of 255 the user
may want to dim the LED color group to half.  The user would write a value of
128 to the global brightness file then the values written to each LED will be
adjusted base on this value.

Group dimming 예제

81-106

사용자는 global `brightness` file을 써서 multicolor LED group 전체 밝기를 제어합니다. `max_brightness=255`에서 절반 수준으로 낮추려면 `brightness`에 `128`을 씁니다.

Brightness 128 적용 결과
Color계산조정값
Red`128 × 138 / 255``69`
Green`128 × 43 / 255``21`
Blue`128 × 226 / 255``113`

원래 hue 비율을 유지하면서 모든 channel이 같은 비율로 줄어듭니다.

Global `brightness`를 읽으면 group의 현재 밝기 값인 `128`을 반환합니다. `multi_intensity`의 색상 배합과 global `brightness`의 lightness 제어가 독립적이므로 dimming해도 hue가 유지됩니다.


.. code-block:: console

    # cat /sys/class/leds/multicolor:status/max_brightness
    255
    # echo 128 > /sys/class/leds/multicolor:status/brightness

..

.. code-block:: none

    adjusted_red_value = 128 * 138/255 = 69
    adjusted_green_value = 128 * 43/255 = 21
    adjusted_blue_value = 128 * 226/255 = 113

..

Reading the global brightness file will return the current brightness value of
the color LED group.

.. code-block:: console

    # cat /sys/class/leds/multicolor:status/brightness
    128

..