요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
Scan element 선택과 binary layout
sysfs-bus-iio:24-137_en은 channel 포함 여부, _index는 buffer 안의 순서, _type은 endian·signedness·유효 bit·storage bit·shift를 표현합니다. 세 정보를 함께 읽어야 user space가 sample layout을 복원할 수 있습니다.
Wakeup 조건과 읽을 수 있는 byte 수
sysfs-bus-iio:138-174watermark는 poll과 blocking read가 기다리는 sample 조건을 정하고 data_available은 input에서 읽을 byte 수, output에서 쓸 수 있는 빈 공간을 보고합니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
What: /sys/bus/iio/devices/iio:deviceX/buffer/length
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
Description:
Number of scans contained by the buffer.
Since Kernel 5.11, multiple buffers are supported.
so, it is better to use, instead:
/sys/bus/iio/devices/iio:deviceX/bufferY/length
What: /sys/bus/iio/devices/iio:deviceX/buffer/enable
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
Description:
Actually start the buffer capture up. Will start trigger
if first device and appropriate.
Since Kernel 5.11, multiple buffers are supported.
so, it is better to use, instead:
/sys/bus/iio/devices/iio:deviceX/bufferY/enable
What: /sys/bus/iio/devices/iio:deviceX/scan_elements
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
Directory containing interfaces for elements that will be
captured for a single triggered sample set in the buffer.
Since kernel 5.11 the scan_elements attributes are merged into
the bufferY directory, to be configurable per buffer.
What: /sys/.../iio:deviceX/scan_elements/in_accel_x_en
What: /sys/.../iio:deviceX/scan_elements/in_accel_y_en
What: /sys/.../iio:deviceX/scan_elements/in_accel_z_en
What: /sys/.../iio:deviceX/scan_elements/in_anglvel_x_en
What: /sys/.../iio:deviceX/scan_elements/in_anglvel_y_en
What: /sys/.../iio:deviceX/scan_elements/in_anglvel_z_en
What: /sys/.../iio:deviceX/scan_elements/in_magn_x_en
What: /sys/.../iio:deviceX/scan_elements/in_magn_y_en
What: /sys/.../iio:deviceX/scan_elements/in_magn_z_en
What: /sys/.../iio:deviceX/scan_elements/in_rot_from_north_magnetic_en
What: /sys/.../iio:deviceX/scan_elements/in_rot_from_north_true_en
What: /sys/.../iio:deviceX/scan_elements/in_rot_from_north_magnetic_tilt_comp_en
What: /sys/.../iio:deviceX/scan_elements/in_rot_from_north_true_tilt_comp_en
What: /sys/.../iio:deviceX/scan_elements/in_timestamp_en
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_supply_en
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_en
What: /sys/.../iio:deviceX/scan_elements/in_voltageY-voltageZ_en
What: /sys/.../iio:deviceX/scan_elements/in_incli_x_en
What: /sys/.../iio:deviceX/scan_elements/in_incli_y_en
What: /sys/.../iio:deviceX/scan_elements/in_pressureY_en
What: /sys/.../iio:deviceX/scan_elements/in_pressure_en
What: /sys/.../iio:deviceX/scan_elements/in_rot_quaternion_en
What: /sys/.../iio:deviceX/scan_elements/in_proximity_en
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
Scan element control for triggered data capture.
Since kernel 5.11 the scan_elements attributes are merged into
the bufferY directory, to be configurable per buffer.
What: /sys/.../iio:deviceX/scan_elements/in_accel_type
What: /sys/.../iio:deviceX/scan_elements/in_anglvel_type
What: /sys/.../iio:deviceX/scan_elements/in_magn_type
What: /sys/.../iio:deviceX/scan_elements/in_incli_type
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_type
What: /sys/.../iio:deviceX/scan_elements/in_voltage_type
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_supply_type
What: /sys/.../iio:deviceX/scan_elements/in_timestamp_type
What: /sys/.../iio:deviceX/scan_elements/in_pressureY_type
What: /sys/.../iio:deviceX/scan_elements/in_pressure_type
What: /sys/.../iio:deviceX/scan_elements/in_rot_quaternion_type
What: /sys/.../iio:deviceX/scan_elements/in_proximity_type
KernelVersion: 2.6.37
Contact: linux-iio@vger.kernel.org
Description:
Description of the scan element data storage within the buffer
and hence the form in which it is read from user-space.
Form is [be|le]:[s|u]bits/storagebits[>>shift].
be or le specifies big or little endian. s or u specifies if
signed (2's complement) or unsigned. bits is the number of bits
of data and storagebits is the space (after padding) that it
occupies in the buffer. shift if specified, is the shift that
needs to be applied prior to masking out unused bits. Some
devices put their data in the middle of the transferred elements
with additional information on both sides. Note that some
devices will have additional information in the unused bits
so to get a clean value, the bits value must be used to mask
the buffer output value appropriately. The storagebits value
also specifies the data alignment. So s48/64>>2 will be a
signed 48 bit integer stored in a 64 bit location aligned to
a 64 bit boundary. To obtain the clean value, shift right 2
and apply a mask to zero the top 16 bits of the result.
For other storage combinations this attribute will be extended
appropriately.
Since kernel 5.11 the scan_elements attributes are merged into
the bufferY directory, to be configurable per buffer.
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_index
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_supply_index
What: /sys/.../iio:deviceX/scan_elements/in_accel_x_index
What: /sys/.../iio:deviceX/scan_elements/in_accel_y_index
What: /sys/.../iio:deviceX/scan_elements/in_accel_z_index
What: /sys/.../iio:deviceX/scan_elements/in_anglvel_x_index
What: /sys/.../iio:deviceX/scan_elements/in_anglvel_y_index
What: /sys/.../iio:deviceX/scan_elements/in_anglvel_z_index
What: /sys/.../iio:deviceX/scan_elements/in_magn_x_index
What: /sys/.../iio:deviceX/scan_elements/in_magn_y_index
What: /sys/.../iio:deviceX/scan_elements/in_magn_z_index
What: /sys/.../iio:deviceX/scan_elements/in_rot_from_north_magnetic_index
What: /sys/.../iio:deviceX/scan_elements/in_rot_from_north_true_index
What: /sys/.../iio:deviceX/scan_elements/in_rot_from_north_magnetic_tilt_comp_index
What: /sys/.../iio:deviceX/scan_elements/in_rot_from_north_true_tilt_comp_index
What: /sys/.../iio:deviceX/scan_elements/in_incli_x_index
What: /sys/.../iio:deviceX/scan_elements/in_incli_y_index
What: /sys/.../iio:deviceX/scan_elements/in_timestamp_index
What: /sys/.../iio:deviceX/scan_elements/in_pressureY_index
What: /sys/.../iio:deviceX/scan_elements/in_pressure_index
What: /sys/.../iio:deviceX/scan_elements/in_rot_quaternion_index
What: /sys/.../iio:deviceX/scan_elements/in_proximity_index
KernelVersion: 2.6.37
Description:
A single positive integer specifying the position of this
scan element in the buffer. Note these are not dependent on
what is enabled and may not be contiguous. Thus for user-space
to establish the full layout these must be used in conjunction
with all _en attributes to establish which channels are present,
and the relevant _type attributes to establish the data storage
format.
Since kernel 5.11 the scan_elements attributes are merged into
the bufferY directory, to be configurable per buffer.
What: /sys/bus/iio/devices/iio:deviceX/buffer/watermark
KernelVersion: 4.2
Contact: linux-iio@vger.kernel.org
Description:
A single positive integer specifying the maximum number of scan
elements to wait for.
Poll will block until the watermark is reached.
Blocking read will wait until the minimum between the requested
read amount or the low water mark is available.
Non-blocking read will retrieve the available samples from the
buffer even if there are less samples then watermark level. This
allows the application to block on poll with a timeout and read
the available samples after the timeout expires and thus have a
maximum delay guarantee.
Since Kernel 5.11, multiple buffers are supported.
so, it is better to use, instead:
/sys/bus/iio/devices/iio:deviceX/bufferY/watermark
What: /sys/bus/iio/devices/iio:deviceX/buffer/data_available
KernelVersion: 4.16
Contact: linux-iio@vger.kernel.org
Description:
A read-only value indicating the bytes of data available in the
buffer. In the case of an output buffer, this indicates the
amount of empty space available to write data to. In the case of
an input buffer, this indicates the amount of data available for
reading.
Since Kernel 5.11, multiple buffers are supported.
so, it is better to use, instead:
/sys/bus/iio/devices/iio:deviceX/bufferY/data_available
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
Buffer length
1-10| 항목 | 값 |
|---|---|
| What | /sys/bus/iio/devices/iio:deviceX/buffer/length |
| KernelVersion | 2.6.35 |
| Contact | linux-iio@vger.kernel.org |
buffer에 들어가는 scan 수를 나타낸다.
Linux 5.11부터 여러 buffer를 지원하므로 다음처럼 buffer 번호를 포함한 경로를 사용하는 편이 좋다.
/sys/bus/iio/devices/iio:deviceX/bufferY/length
Buffer enable
12-22| 항목 | 값 |
|---|---|
| What | /sys/bus/iio/devices/iio:deviceX/buffer/enable |
| KernelVersion | 2.6.35 |
| Contact | linux-iio@vger.kernel.org |
실제 buffer capture를 시작한다. 이 device가 첫 번째 device이고 조건이 맞으면 trigger도 시작한다.
Linux 5.11부터 여러 buffer를 지원하므로 다음 경로를 권장한다.
/sys/bus/iio/devices/iio:deviceX/bufferY/enable
Scan element directory와 channel enable
24-63| 항목 | 값 |
|---|---|
| What | /sys/bus/iio/devices/iio:deviceX/scan_elements |
| KernelVersion | 2.6.37 |
| Contact | linux-iio@vger.kernel.org |
buffer에 한 번의 triggered sample set을 저장할 때 capture할 element를 설정하는 interface directory다.
Linux 5.11부터 scan_elements attribute는 buffer마다 설정할 수 있도록 bufferY directory에 합쳐졌다.
다음 `_en` attribute는 triggered data capture에 각 scan element를 포함할지 제어한다.
/sys/.../iio:deviceX/scan_elements/in_accel_x_en
/sys/.../iio:deviceX/scan_elements/in_accel_y_en
/sys/.../iio:deviceX/scan_elements/in_accel_z_en
/sys/.../iio:deviceX/scan_elements/in_anglvel_x_en
/sys/.../iio:deviceX/scan_elements/in_anglvel_y_en
/sys/.../iio:deviceX/scan_elements/in_anglvel_z_en
/sys/.../iio:deviceX/scan_elements/in_magn_x_en
/sys/.../iio:deviceX/scan_elements/in_magn_y_en
/sys/.../iio:deviceX/scan_elements/in_magn_z_en
/sys/.../iio:deviceX/scan_elements/in_rot_from_north_magnetic_en
/sys/.../iio:deviceX/scan_elements/in_rot_from_north_true_en
/sys/.../iio:deviceX/scan_elements/in_rot_from_north_magnetic_tilt_comp_en
/sys/.../iio:deviceX/scan_elements/in_rot_from_north_true_tilt_comp_en
/sys/.../iio:deviceX/scan_elements/in_timestamp_en
/sys/.../iio:deviceX/scan_elements/in_voltageY_supply_en
/sys/.../iio:deviceX/scan_elements/in_voltageY_en
/sys/.../iio:deviceX/scan_elements/in_voltageY-voltageZ_en
/sys/.../iio:deviceX/scan_elements/in_incli_x_en
/sys/.../iio:deviceX/scan_elements/in_incli_y_en
/sys/.../iio:deviceX/scan_elements/in_pressureY_en
/sys/.../iio:deviceX/scan_elements/in_pressure_en
/sys/.../iio:deviceX/scan_elements/in_rot_quaternion_en
/sys/.../iio:deviceX/scan_elements/in_proximity_en
이 `_en` attribute도 Linux 5.11부터 bufferY directory에 합쳐져 buffer별로 설정한다.
Scan element storage type
65-101다음 `_type` attribute는 buffer에서 scan element data가 저장되는 방식과 user space가 읽게 되는 binary 형식을 설명한다.
/sys/.../iio:deviceX/scan_elements/in_accel_type
/sys/.../iio:deviceX/scan_elements/in_anglvel_type
/sys/.../iio:deviceX/scan_elements/in_magn_type
/sys/.../iio:deviceX/scan_elements/in_incli_type
/sys/.../iio:deviceX/scan_elements/in_voltageY_type
/sys/.../iio:deviceX/scan_elements/in_voltage_type
/sys/.../iio:deviceX/scan_elements/in_voltageY_supply_type
/sys/.../iio:deviceX/scan_elements/in_timestamp_type
/sys/.../iio:deviceX/scan_elements/in_pressureY_type
/sys/.../iio:deviceX/scan_elements/in_pressure_type
/sys/.../iio:deviceX/scan_elements/in_rot_quaternion_type
/sys/.../iio:deviceX/scan_elements/in_proximity_type
| 항목 | 값 |
|---|---|
| KernelVersion | 2.6.37 |
| Contact | linux-iio@vger.kernel.org |
| 형식 | [be|le]:[s|u]bits/storagebits[>>shift] |
be와 le는 각각 big endian과 little endian을 뜻한다. s는 2's complement signed 값, u는 unsigned 값을 뜻한다. bits는 유효 data bit 수이고 storagebits는 padding을 포함해 buffer에서 차지하는 공간이다.
shift가 있으면 사용하지 않는 bit를 mask하기 전에 적용할 right shift 수다. 일부 device는 전송 element의 가운데에 data를 배치하고 양쪽에 다른 정보를 넣는다. 사용하지 않는 bit에도 추가 정보가 있을 수 있으므로 깨끗한 값을 얻으려면 bits를 기준으로 buffer 값을 mask해야 한다.
storagebits는 data alignment도 지정한다. 예를 들어 s48/64>>2는 64-bit boundary에 정렬된 64-bit 저장 공간에 signed 48-bit integer가 들어 있음을 뜻한다. 먼저 2-bit right shift한 다음 결과의 상위 16-bit를 0으로 만드는 mask를 적용한다.
다른 storage 조합이 필요하면 이 attribute 형식을 그에 맞게 확장한다. Linux 5.11부터 `_type` attribute도 bufferY directory에 합쳐졌다.
Scan element index
103-136다음 `_index` attribute는 각 scan element가 buffer에서 차지하는 위치를 하나의 positive integer로 나타낸다.
/sys/.../iio:deviceX/scan_elements/in_voltageY_index
/sys/.../iio:deviceX/scan_elements/in_voltageY_supply_index
/sys/.../iio:deviceX/scan_elements/in_accel_x_index
/sys/.../iio:deviceX/scan_elements/in_accel_y_index
/sys/.../iio:deviceX/scan_elements/in_accel_z_index
/sys/.../iio:deviceX/scan_elements/in_anglvel_x_index
/sys/.../iio:deviceX/scan_elements/in_anglvel_y_index
/sys/.../iio:deviceX/scan_elements/in_anglvel_z_index
/sys/.../iio:deviceX/scan_elements/in_magn_x_index
/sys/.../iio:deviceX/scan_elements/in_magn_y_index
/sys/.../iio:deviceX/scan_elements/in_magn_z_index
/sys/.../iio:deviceX/scan_elements/in_rot_from_north_magnetic_index
/sys/.../iio:deviceX/scan_elements/in_rot_from_north_true_index
/sys/.../iio:deviceX/scan_elements/in_rot_from_north_magnetic_tilt_comp_index
/sys/.../iio:deviceX/scan_elements/in_rot_from_north_true_tilt_comp_index
/sys/.../iio:deviceX/scan_elements/in_incli_x_index
/sys/.../iio:deviceX/scan_elements/in_incli_y_index
/sys/.../iio:deviceX/scan_elements/in_timestamp_index
/sys/.../iio:deviceX/scan_elements/in_pressureY_index
/sys/.../iio:deviceX/scan_elements/in_pressure_index
/sys/.../iio:deviceX/scan_elements/in_rot_quaternion_index
/sys/.../iio:deviceX/scan_elements/in_proximity_index
index는 현재 enable된 element에 따라 달라지지 않고 연속된 숫자일 필요도 없다. user space가 전체 layout을 구성하려면 모든 `_en` attribute로 존재하는 channel을 확인하고, 해당 `_type` attribute로 storage format을 확인하면서 `_index` 순서에 배치해야 한다.
Linux 5.11부터 `_index` attribute도 buffer마다 설정할 수 있도록 bufferY directory에 합쳐졌다.
Buffer watermark
138-159| 항목 | 값 |
|---|---|
| What | /sys/bus/iio/devices/iio:deviceX/buffer/watermark |
| KernelVersion | 4.2 |
| Contact | linux-iio@vger.kernel.org |
기다릴 최대 scan element 수를 하나의 positive integer로 지정한다.
poll은 watermark에 도달할 때까지 block된다. blocking read는 요청한 read 양과 low watermark 중 작은 수만큼 data가 준비될 때까지 기다린다.
non-blocking read는 sample 수가 watermark보다 작아도 buffer에서 현재 사용 가능한 sample을 가져온다. application은 timeout을 둔 poll에서 기다린 뒤 timeout이 끝나면 준비된 sample을 읽을 수 있으므로 최대 delay를 보장할 수 있다.
Linux 5.11부터 여러 buffer를 지원하므로 다음 경로를 권장한다.
/sys/bus/iio/devices/iio:deviceX/bufferY/watermark
Buffer data_available
161-174| 항목 | 값 |
|---|---|
| What | /sys/bus/iio/devices/iio:deviceX/buffer/data_available |
| KernelVersion | 4.16 |
| Contact | linux-iio@vger.kernel.org |
buffer에서 사용할 수 있는 data byte 수를 나타내는 read-only 값이다. output buffer에서는 data를 쓸 수 있는 빈 공간의 양이고 input buffer에서는 읽을 수 있는 data의 양이다.
Linux 5.11부터 여러 buffer를 지원하므로 다음 경로를 권장한다.
/sys/bus/iio/devices/iio:deviceX/bufferY/data_available
Buffer 크기와 capture 제어
sysfs-bus-iio:1-23length는 buffer가 담는 scan 수를 정하고 enable은 실제 capture와 필요한 trigger를 시작합니다. Linux 5.11의 multi-buffer 지원 이후에는 bufferY별 attribute를 사용합니다.