← Documents Documentation/userspace-api/gpio/gpio-handle-get-line-values-ioctl.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API

GPIOHANDLE_GET_LINE_VALUES_IOCTL

Line handle 또는 event descriptor에서 logical value를 읽고 ACTIVE_LOW polarity를 적용하는 규칙을 설명합니다.

Source pathDocumentation/userspace-api/gpio/gpio-handle-get-line-values-ioctl.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

gpio-handle-get-line-values-ioctl.rst:1-63

Line handle 또는 event descriptor에서 logical value를 읽고 ACTIVE_LOW polarity를 적용하는 규칙을 설명합니다.

원문의 read/ioctl prototype, struct, flag, errno, clock, buffer 규칙과 줄 좌표를 보존해 전문 번역했습니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 .. _GPIOHANDLE_GET_LINE_VALUES_IOCTL:
4
5 ********************************
6 GPIOHANDLE_GET_LINE_VALUES_IOCTL
7 ********************************
8 .. warning::
9 This ioctl is part of chardev_v1.rst and is obsoleted by
10 gpio-v2-line-get-values-ioctl.rst.
11
12 Name
13 ====
14
15 GPIOHANDLE_GET_LINE_VALUES_IOCTL - Get the values of all requested lines.
16
17 Synopsis
18 ========
19
20 .. c:macro:: GPIOHANDLE_GET_LINE_VALUES_IOCTL
21
22 ``int ioctl(int handle_fd, GPIOHANDLE_GET_LINE_VALUES_IOCTL, struct gpiohandle_data *values)``
23
24 Arguments
25 =========
26
27 ``handle_fd``
28 The file descriptor of the GPIO character device, as returned in the
29 :c:type:`request.fd<gpiohandle_request>` by gpio-get-linehandle-ioctl.rst.
30
31 ``values``
32 The :c:type:`line_values<gpiohandle_data>` to be populated.
33
34 Description
35 ===========
36
37 Get the values of all requested lines.
38
39 The values returned are logical, indicating if the line is active or inactive.
40 The ``GPIOHANDLE_REQUEST_ACTIVE_LOW`` flag controls the mapping between physical
41 values (high/low) and logical values (active/inactive).
42 If ``GPIOHANDLE_REQUEST_ACTIVE_LOW`` is not set then high is active and
43 low is inactive. If ``GPIOHANDLE_REQUEST_ACTIVE_LOW`` is set then low is active
44 and high is inactive.
45
46 The values of both input and output lines may be read.
47
48 For output lines, the value returned is driver and configuration dependent and
49 may be either the output buffer (the last requested value set) or the input
50 buffer (the actual level of the line), and depending on the hardware and
51 configuration these may differ.
52
53 This ioctl can also be used to read the line value for line events,
54 substituting the ``event_fd`` for the ``handle_fd``. As there is only
55 one line requested in that case, only the one value is returned in ``values``.
56
57 Return Value
58 ============
59
60 On success 0 and ``values`` populated with the values read.
61
62 On error -1 and the ``errno`` variable is set appropriately.
63 Common error codes are described in error-codes.rst.
64

3. 한국어 전문 번역

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

상태, 이름, 호출 형식

1-33

`GPIOHANDLE_GET_LINE_VALUES_IOCTL`은 요청한 모든 GPIO line의 값을 가져옵니다. ABI v1 ioctl이며 `gpio-v2-line-get-values-ioctl.rst`로 대체되었습니다.

호출 형식은 `int ioctl(int handle_fd, GPIOHANDLE_GET_LINE_VALUES_IOCTL, struct gpiohandle_data *values)`입니다. `handle_fd`는 `gpio-get-linehandle-ioctl.rst`가 `gpiohandle_request`의 `request.fd`에 반환한 descriptor이고, `values`는 읽은 값을 저장할 `gpiohandle_data` 구조체입니다.

Line 값 읽기 인자
항목설명
handle_fdLine handle file descriptor
values채워질 struct gpiohandle_data

Handle에 포함된 모든 line의 logical value를 한 번에 읽습니다.

.. SPDX-License-Identifier: GPL-2.0

.. _GPIOHANDLE_GET_LINE_VALUES_IOCTL:

********************************
GPIOHANDLE_GET_LINE_VALUES_IOCTL
********************************
.. warning::
    This ioctl is part of chardev_v1.rst and is obsoleted by
    gpio-v2-line-get-values-ioctl.rst.

Name
====

GPIOHANDLE_GET_LINE_VALUES_IOCTL - Get the values of all requested lines.

Synopsis
========

.. c:macro:: GPIOHANDLE_GET_LINE_VALUES_IOCTL

``int ioctl(int handle_fd, GPIOHANDLE_GET_LINE_VALUES_IOCTL, struct gpiohandle_data *values)``

Arguments
=========

``handle_fd``
    The file descriptor of the GPIO character device, as returned in the
    :c:type:`request.fd<gpiohandle_request>` by gpio-get-linehandle-ioctl.rst.

``values``
    The :c:type:`line_values<gpiohandle_data>` to be populated.

Logical value와 physical level

34-56

반환되는 값은 logical value이며 line이 active인지 inactive인지를 나타냅니다. `GPIOHANDLE_REQUEST_ACTIVE_LOW` flag가 physical high/low와 logical active/inactive 사이의 대응을 결정합니다.

`GPIOHANDLE_REQUEST_ACTIVE_LOW`가 없으면 high가 active이고 low가 inactive입니다. Flag가 있으면 반대로 low가 active이고 high가 inactive입니다. Input과 output line의 값 모두 읽을 수 있습니다.

Output line에서 읽히는 값은 driver와 configuration에 따라 output buffer의 마지막 설정값일 수도 있고 input buffer에서 읽은 실제 line level일 수도 있습니다. Hardware와 구성에 따라 두 값은 다를 수 있습니다.

이 ioctl은 `handle_fd` 대신 `event_fd`를 전달하여 line event의 값도 읽을 수 있습니다. Line event에는 line이 하나뿐이므로 `values`에는 값 하나만 반환됩니다.

ACTIVE_LOW 읽기 변환
조건반환 logical value
ACTIVE_LOW 없음 + physical highactive
ACTIVE_LOW 없음 + physical lowinactive
ACTIVE_LOW 설정 + physical lowactive
ACTIVE_LOW 설정 + physical highinactive

ioctl은 physical level이 아니라 logical state를 반환합니다.

Line 값 읽기
handle_fd 또는 event_fd 선택GPIOHANDLE_GET_LINE_VALUES_IOCTL 호출Driver가 line level 또는 output buffer 확인ACTIVE_LOW에 따라 logical value 변환gpiohandle_data에 값 저장

Descriptor 종류와 polarity 설정을 반영해 logical value를 반환합니다.

Description
===========

Get the values of all requested lines.

The values returned are logical, indicating if the line is active or inactive.
The ``GPIOHANDLE_REQUEST_ACTIVE_LOW`` flag controls the mapping between physical
values (high/low) and logical values (active/inactive).
If ``GPIOHANDLE_REQUEST_ACTIVE_LOW`` is not set then high is active and
low is inactive. If ``GPIOHANDLE_REQUEST_ACTIVE_LOW`` is set then low is active
and high is inactive.

The values of both input and output lines may be read.

For output lines, the value returned is driver and configuration dependent and
may be either the output buffer (the last requested value set) or the input
buffer (the actual level of the line), and depending on the hardware and
configuration these may differ.

This ioctl can also be used to read the line value for line events,
substituting the ``event_fd`` for the ``handle_fd``.  As there is only
one line requested in that case, only the one value is returned in ``values``.

반환값

57-63

성공하면 0을 반환하고 `values`를 읽은 값으로 채웁니다. 실패하면 -1을 반환하고 `errno`를 알맞게 설정합니다. 공통 오류 코드는 `error-codes.rst`를 따릅니다.

Return Value
============

On success 0 and ``values`` populated with the values read.

On error -1 and the ``errno`` variable is set appropriately.
Common error codes are described in error-codes.rst.