요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: MC
.. _media_ioc_device_info:
***************************
ioctl MEDIA_IOC_DEVICE_INFO
***************************
Name
====
MEDIA_IOC_DEVICE_INFO - Query device information
Synopsis
========
.. c:macro:: MEDIA_IOC_DEVICE_INFO
``int ioctl(int fd, MEDIA_IOC_DEVICE_INFO, struct media_device_info *argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`media_device_info`.
Description
===========
All media devices must support the ``MEDIA_IOC_DEVICE_INFO`` ioctl. To
query device information, applications call the ioctl with a pointer to
a struct :c:type:`media_device_info`. The driver
fills the structure and returns the information to the application. The
ioctl never fails.
.. c:type:: media_device_info
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct media_device_info
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - char
- ``driver``\ [16]
- Name of the driver implementing the media API as a NUL-terminated
ASCII string. The driver version is stored in the
``driver_version`` field.
Driver specific applications can use this information to verify
the driver identity. It is also useful to work around known bugs,
or to identify drivers in error reports.
* - char
- ``model``\ [32]
- Device model name as a NUL-terminated UTF-8 string. The device
version is stored in the ``device_version`` field and is not be
appended to the model name.
* - char
- ``serial``\ [40]
- Serial number as a NUL-terminated ASCII string.
* - char
- ``bus_info``\ [32]
- Location of the device in the system as a NUL-terminated ASCII
string. This includes the bus type name (PCI, USB, ...) and a
bus-specific identifier.
* - __u32
- ``media_version``
- Media API version, formatted with the ``KERNEL_VERSION()`` macro.
* - __u32
- ``hw_revision``
- Hardware device revision in a driver-specific format.
* - __u32
- ``driver_version``
- Media device driver version, formatted with the
``KERNEL_VERSION()`` macro. Together with the ``driver`` field
this identifies a particular driver.
* - __u32
- ``reserved``\ [31]
- Reserved for future extensions. Drivers and applications must set
this array to zero.
The ``serial`` and ``bus_info`` fields can be used to distinguish
between multiple instances of otherwise identical hardware. The serial
number takes precedence when provided and can be assumed to be unique.
If the serial number is an empty string, the ``bus_info`` field can be
used instead. The ``bus_info`` field is guaranteed to be unique, but can
vary across reboots or device unplug/replug.
Return Value
============
On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter.
3. 한국어 전문 번역
영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.
이름, 호출 형식과 arguments
1-30`MEDIA_IOC_DEVICE_INFO`는 media device 정보를 조회합니다. 모든 media device가 지원해야 하는 `MC` namespace ioctl입니다.
int ioctl(int fd, MEDIA_IOC_DEVICE_INFO, struct media_device_info *argp);
열린 media device와 결과 structure를 전달합니다.
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: MC
.. _media_ioc_device_info:
***************************
ioctl MEDIA_IOC_DEVICE_INFO
***************************
Name
====
MEDIA_IOC_DEVICE_INFO - Query device information
Synopsis
========
.. c:macro:: MEDIA_IOC_DEVICE_INFO
``int ioctl(int fd, MEDIA_IOC_DEVICE_INFO, struct media_device_info *argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`media_device_info`.
조회 동작
31-39Application은 `struct media_device_info` pointer로 `MEDIA_IOC_DEVICE_INFO`를 호출합니다. Driver가 structure를 채워 device 정보를 application에 반환합니다.
원문은 이 ioctl이 절대로 실패하지 않는다고 명시합니다.
Description
===========
All media devices must support the ``MEDIA_IOC_DEVICE_INFO`` ioctl. To
query device information, applications call the ioctl with a pointer to
a struct :c:type:`media_device_info`. The driver
fills the structure and returns the information to the application. The
ioctl never fails.
struct media_device_info
40-93각 field의 type, 길이, encoding과 안정성 규칙을 보존합니다.
Driver 전용 application은 `driver`와 `driver_version`으로 driver identity를 확인할 수 있습니다. 알려진 bug를 우회하거나 오류 보고서에서 driver를 식별할 때도 유용합니다.
`model`에는 device version을 덧붙이지 않습니다. 원문은 device version을 `device_version` field에 저장한다고 설명합니다.
.. c:type:: media_device_info
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. flat-table:: struct media_device_info
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - char
- ``driver``\ [16]
- Name of the driver implementing the media API as a NUL-terminated
ASCII string. The driver version is stored in the
``driver_version`` field.
Driver specific applications can use this information to verify
the driver identity. It is also useful to work around known bugs,
or to identify drivers in error reports.
* - char
- ``model``\ [32]
- Device model name as a NUL-terminated UTF-8 string. The device
version is stored in the ``device_version`` field and is not be
appended to the model name.
* - char
- ``serial``\ [40]
- Serial number as a NUL-terminated ASCII string.
* - char
- ``bus_info``\ [32]
- Location of the device in the system as a NUL-terminated ASCII
string. This includes the bus type name (PCI, USB, ...) and a
bus-specific identifier.
* - __u32
- ``media_version``
- Media API version, formatted with the ``KERNEL_VERSION()`` macro.
* - __u32
- ``hw_revision``
- Hardware device revision in a driver-specific format.
* - __u32
- ``driver_version``
- Media device driver version, formatted with the
``KERNEL_VERSION()`` macro. Together with the ``driver`` field
this identifies a particular driver.
* - __u32
- ``reserved``\ [31]
- Reserved for future extensions. Drivers and applications must set
this array to zero.
serial과 bus_info의 우선순위
94-100`serial`과 `bus_info`는 그 밖의 특성이 같은 hardware instance 여러 개를 구별하는 데 사용할 수 있습니다.
제공된다면 serial number가 우선하며 unique하다고 가정할 수 있습니다. `serial`이 빈 string이면 `bus_info`를 대신 사용합니다.
`bus_info`는 unique함이 보장되지만 reboot 또는 device unplug/replug를 거치면 바뀔 수 있습니다.
안정적인 identifier를 선택하는 우선순위입니다.
The ``serial`` and ``bus_info`` fields can be used to distinguish
between multiple instances of otherwise identical hardware. The serial
number takes precedence when provided and can be assumed to be unique.
If the serial number is an empty string, the ``bus_info`` field can be
used instead. The ``bus_info`` field is guaranteed to be unique, but can
vary across reboots or device unplug/replug.
반환값
101-106성공하면 0을 반환합니다. 오류가 발생하면 -1을 반환하고 `errno`를 알맞게 설정하며, 공통 오류는 `Generic Error Codes <gen-errors>` 장에서 설명합니다.
Return Value
============
On success 0 is returned, on error -1 and the ``errno`` variable is set
appropriately. The generic error codes are described at the
:ref:`Generic Error Codes <gen-errors>` chapter.
요약·해설
media-ioc-device-info.rst:1-106Hardware instance 식별에는 serial을 우선 사용하고, 없으면 bus_info를 사용합니다. bus_info는 unique하지만 reboot나 재연결 뒤 바뀔 수 있으므로 장기 식별자로 사용할 때 주의해야 합니다.