요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.
1. 요약·해설
원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.
2. 영어 원문 전체
번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.
원문 전체 펼치기
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: V4L
.. _VIDIOC_DQEVENT:
********************
ioctl VIDIOC_DQEVENT
********************
Name
====
VIDIOC_DQEVENT - Dequeue event
Synopsis
========
.. c:macro:: VIDIOC_DQEVENT
``int ioctl(int fd, VIDIOC_DQEVENT, struct v4l2_event *argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`v4l2_event`.
Description
===========
Dequeue an event from a video device. No input is required for this
ioctl. All the fields of the struct :c:type:`v4l2_event`
structure are filled by the driver. The file handle will also receive
exceptions which the application may get by e.g. using the select system
call.
.. c:type:: v4l2_event
.. tabularcolumns:: |p{3.0cm}|p{3.4cm}|p{10.9cm}|
.. flat-table:: struct v4l2_event
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``type``
- Type of the event, see :ref:`event-type`.
* - union {
- ``u``
* - struct :c:type:`v4l2_event_vsync`
- ``vsync``
- Event data for event ``V4L2_EVENT_VSYNC``.
* - struct :c:type:`v4l2_event_ctrl`
- ``ctrl``
- Event data for event ``V4L2_EVENT_CTRL``.
* - struct :c:type:`v4l2_event_frame_sync`
- ``frame_sync``
- Event data for event ``V4L2_EVENT_FRAME_SYNC``.
* - struct :c:type:`v4l2_event_motion_det`
- ``motion_det``
- Event data for event V4L2_EVENT_MOTION_DET.
* - struct :c:type:`v4l2_event_src_change`
- ``src_change``
- Event data for event V4L2_EVENT_SOURCE_CHANGE.
* - __u8
- ``data``\ [64]
- Event data. Defined by the event type. The union should be used to
define easily accessible type for events.
* - }
-
* - __u32
- ``pending``
- Number of pending events excluding this one.
* - __u32
- ``sequence``
- Event sequence number. The sequence number is incremented for
every subscribed event that takes place. If sequence numbers are
not contiguous it means that events have been lost.
* - struct timespec
- ``timestamp``
- Event timestamp. The timestamp has been taken from the
``CLOCK_MONOTONIC`` clock. To access the same clock outside V4L2,
use :c:func:`clock_gettime`.
* - u32
- ``id``
- The ID associated with the event source. If the event does not
have an associated ID (this depends on the event type), then this
is 0.
* - __u32
- ``reserved``\ [8]
- Reserved for future extensions. Drivers must set the array to
zero.
.. tabularcolumns:: |p{6.2cm}|p{2.6cm}|p{8.5cm}|
.. cssclass:: longtable
.. _event-type:
.. flat-table:: Event Types
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4
* - ``V4L2_EVENT_ALL``
- 0
- All events. V4L2_EVENT_ALL is valid only for
VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
* - ``V4L2_EVENT_VSYNC``
- 1
- This event is triggered on the vertical sync. This event has a
struct :c:type:`v4l2_event_vsync` associated
with it.
* - ``V4L2_EVENT_EOS``
- 2
- This event is triggered when the end of a stream is reached. This
is typically used with MPEG decoders to report to the application
when the last of the MPEG stream has been decoded.
* - ``V4L2_EVENT_CTRL``
- 3
- This event requires that the ``id`` matches the control ID from
which you want to receive events. This event is triggered if the
control's value changes, if a button control is pressed or if the
control's flags change. This event has a struct
:c:type:`v4l2_event_ctrl` associated with it.
This struct contains much of the same information as struct
:ref:`v4l2_queryctrl <v4l2-queryctrl>` and struct
:c:type:`v4l2_control`.
If the event is generated due to a call to
:ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` or
:ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then the
event will *not* be sent to the file handle that called the ioctl
function. This prevents nasty feedback loops. If you *do* want to
get the event, then set the ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``
flag.
This event type will ensure that no information is lost when more
events are raised than there is room internally. In that case the
struct :c:type:`v4l2_event_ctrl` of the
second-oldest event is kept, but the ``changes`` field of the
second-oldest event is ORed with the ``changes`` field of the
oldest event.
* - ``V4L2_EVENT_FRAME_SYNC``
- 4
- Triggered immediately when the reception of a frame has begun.
This event has a struct
:c:type:`v4l2_event_frame_sync`
associated with it.
If the hardware needs to be stopped in the case of a buffer
underrun it might not be able to generate this event. In such
cases the ``frame_sequence`` field in struct
:c:type:`v4l2_event_frame_sync` will not
be incremented. This causes two consecutive frame sequence numbers
to have n times frame interval in between them.
* - ``V4L2_EVENT_SOURCE_CHANGE``
- 5
- This event is triggered when a source parameter change is detected
during runtime by the video device. It can be a runtime resolution
change triggered by a video decoder or the format change happening
on an input connector. This event requires that the ``id`` matches
the input index (when used with a video device node) or the pad
index (when used with a subdevice node) from which you want to
receive events.
This event has a struct
:c:type:`v4l2_event_src_change`
associated with it. The ``changes`` bitfield denotes what has
changed for the subscribed pad. If multiple events occurred before
application could dequeue them, then the changes will have the
ORed value of all the events generated.
* - ``V4L2_EVENT_MOTION_DET``
- 6
- Triggered whenever the motion detection state for one or more of
the regions changes. This event has a struct
:c:type:`v4l2_event_motion_det`
associated with it.
* - ``V4L2_EVENT_PRIVATE_START``
- 0x08000000
- Base event number for driver-private events.
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_event_vsync
.. flat-table:: struct v4l2_event_vsync
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u8
- ``field``
- The upcoming field. See enum :c:type:`v4l2_field`.
.. tabularcolumns:: |p{3.5cm}|p{3.0cm}|p{10.8cm}|
.. c:type:: v4l2_event_ctrl
.. flat-table:: struct v4l2_event_ctrl
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``changes``
- A bitmask that tells what has changed. See
:ref:`ctrl-changes-flags`.
* - __u32
- ``type``
- The type of the control. See enum
:c:type:`v4l2_ctrl_type`.
* - union {
- (anonymous)
* - __s32
- ``value``
- The 32-bit value of the control for 32-bit control types. This is
0 for string controls since the value of a string cannot be passed
using :ref:`VIDIOC_DQEVENT`.
* - __s64
- ``value64``
- The 64-bit value of the control for 64-bit control types.
* - }
-
* - __u32
- ``flags``
- The control flags. See :ref:`control-flags`.
* - __s32
- ``minimum``
- The minimum value of the control. See struct
:ref:`v4l2_queryctrl <v4l2-queryctrl>`.
* - __s32
- ``maximum``
- The maximum value of the control. See struct
:ref:`v4l2_queryctrl <v4l2-queryctrl>`.
* - __s32
- ``step``
- The step value of the control. See struct
:ref:`v4l2_queryctrl <v4l2-queryctrl>`.
* - __s32
- ``default_value``
- The default value of the control. See struct
:ref:`v4l2_queryctrl <v4l2-queryctrl>`.
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_event_frame_sync
.. flat-table:: struct v4l2_event_frame_sync
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``frame_sequence``
- The sequence number of the frame being received.
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_event_src_change
.. flat-table:: struct v4l2_event_src_change
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``changes``
- A bitmask that tells what has changed. See
:ref:`src-changes-flags`.
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_event_motion_det
.. flat-table:: struct v4l2_event_motion_det
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``flags``
- Currently only one flag is available: if
``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` is set, then the
``frame_sequence`` field is valid, otherwise that field should be
ignored.
* - __u32
- ``frame_sequence``
- The sequence number of the frame being received. Only valid if the
``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` flag was set.
* - __u32
- ``region_mask``
- The bitmask of the regions that reported motion. There is at least
one region. If this field is 0, then no motion was detected at
all. If there is no ``V4L2_CID_DETECT_MD_REGION_GRID`` control
(see :ref:`detect-controls`) to assign a different region to
each cell in the motion detection grid, then that all cells are
automatically assigned to the default region 0.
.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
.. _ctrl-changes-flags:
.. flat-table:: Control Changes
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4
* - ``V4L2_EVENT_CTRL_CH_VALUE``
- 0x0001
- This control event was triggered because the value of the control
changed. Special cases: Volatile controls do no generate this
event; If a control has the ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE``
flag set, then this event is sent as well, regardless its value.
* - ``V4L2_EVENT_CTRL_CH_FLAGS``
- 0x0002
- This control event was triggered because the control flags
changed.
* - ``V4L2_EVENT_CTRL_CH_RANGE``
- 0x0004
- This control event was triggered because the minimum, maximum,
step or the default value of the control changed.
* - ``V4L2_EVENT_CTRL_CH_DIMENSIONS``
- 0x0008
- This control event was triggered because the dimensions of the
control changed. Note that the number of dimensions remains the
same.
.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
.. _src-changes-flags:
.. flat-table:: Source Changes
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4
* - ``V4L2_EVENT_SRC_CH_RESOLUTION``
- 0x0001
- This event gets triggered when a resolution change is detected at
an input. This can come from an input connector or from a video
decoder. Applications will have to query the new resolution (if
any, the signal may also have been lost).
For stateful decoders follow the guidelines in :ref:`decoder`.
Video Capture devices have to query the new timings using
:ref:`VIDIOC_QUERY_DV_TIMINGS` or
:ref:`VIDIOC_QUERYSTD <VIDIOC_QUERYSTD>`.
*Important*: even if the new video timings appear identical to the old
ones, receiving this event indicates that there was an issue with the
video signal and you must stop and restart streaming
(:ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`
followed by :ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>`). The reason is
that many Video Capture devices are not able to recover from a temporary
loss of signal and so restarting streaming I/O is required in order for
the hardware to synchronize to the video signal.
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은 원문 표기를 유지합니다.
이름, 호출 형식과 인자
1-30`VIDIOC_DQEVENT`는 비디오 장치의 이벤트 큐에서 이벤트 하나를 꺼냅니다. 호출 형식은 `int ioctl(int fd, VIDIOC_DQEVENT, struct v4l2_event *argp)`입니다.
`fd`는 `open()`이 반환한 파일 디스크립터이며 `argp`는 드라이버가 채울 `struct v4l2_event`를 가리킵니다.
.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later
.. c:namespace:: V4L
.. _VIDIOC_DQEVENT:
********************
ioctl VIDIOC_DQEVENT
********************
Name
====
VIDIOC_DQEVENT - Dequeue event
Synopsis
========
.. c:macro:: VIDIOC_DQEVENT
``int ioctl(int fd, VIDIOC_DQEVENT, struct v4l2_event *argp)``
Arguments
=========
``fd``
File descriptor returned by :c:func:`open()`.
``argp``
Pointer to struct :c:type:`v4l2_event`.
이벤트 dequeue와 대기
31-39이 ioctl에는 입력값이 필요하지 않으며 드라이버가 `struct v4l2_event`의 모든 필드를 채웁니다. 파일 핸들은 이벤트가 준비될 때 exception 상태도 받으므로 응용 프로그램은 `select()` 같은 시스템 호출로 대기한 뒤 dequeue할 수 있습니다.
구독한 이벤트가 준비되면 exception 상태를 통해 깨워지고 큐에서 하나씩 꺼냅니다.
Description
===========
Dequeue an event from a video device. No input is required for this
ioctl. All the fields of the struct :c:type:`v4l2_event`
structure are filled by the driver. The file handle will also receive
exceptions which the application may get by e.g. using the select system
call.
v4l2_event 공통 구조체
40-99`type`은 이벤트 종류를 식별하고 union `u`는 종류별 데이터를 제공합니다. 알려지지 않았거나 드라이버 전용 이벤트는 64바이트 `data` 배열로 접근할 수 있습니다.
`pending`은 현재 꺼낸 이벤트를 제외하고 큐에 남은 수입니다. `sequence`는 구독한 이벤트가 발생할 때마다 증가하므로 연속되지 않으면 중간 이벤트가 유실됐음을 뜻합니다. `timestamp`는 `CLOCK_MONOTONIC` 기준이며 V4L2 밖에서는 `clock_gettime()`으로 같은 시계를 읽을 수 있습니다.
`id`는 control ID, 입력 인덱스, pad 인덱스처럼 이벤트 원천과 연결된 ID이며 연결된 ID가 없는 유형은 0입니다. `reserved[8]`은 드라이버가 0으로 설정해야 합니다.
공통 메타데이터와 이벤트별 union 멤버입니다.
.. c:type:: v4l2_event
.. tabularcolumns:: |p{3.0cm}|p{3.4cm}|p{10.9cm}|
.. flat-table:: struct v4l2_event
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``type``
- Type of the event, see :ref:`event-type`.
* - union {
- ``u``
* - struct :c:type:`v4l2_event_vsync`
- ``vsync``
- Event data for event ``V4L2_EVENT_VSYNC``.
* - struct :c:type:`v4l2_event_ctrl`
- ``ctrl``
- Event data for event ``V4L2_EVENT_CTRL``.
* - struct :c:type:`v4l2_event_frame_sync`
- ``frame_sync``
- Event data for event ``V4L2_EVENT_FRAME_SYNC``.
* - struct :c:type:`v4l2_event_motion_det`
- ``motion_det``
- Event data for event V4L2_EVENT_MOTION_DET.
* - struct :c:type:`v4l2_event_src_change`
- ``src_change``
- Event data for event V4L2_EVENT_SOURCE_CHANGE.
* - __u8
- ``data``\ [64]
- Event data. Defined by the event type. The union should be used to
define easily accessible type for events.
* - }
-
* - __u32
- ``pending``
- Number of pending events excluding this one.
* - __u32
- ``sequence``
- Event sequence number. The sequence number is incremented for
every subscribed event that takes place. If sequence numbers are
not contiguous it means that events have been lost.
* - struct timespec
- ``timestamp``
- Event timestamp. The timestamp has been taken from the
``CLOCK_MONOTONIC`` clock. To access the same clock outside V4L2,
use :c:func:`clock_gettime`.
* - u32
- ``id``
- The ID associated with the event source. If the event does not
have an associated ID (this depends on the event type), then this
is 0.
* - __u32
- ``reserved``\ [8]
- Reserved for future extensions. Drivers must set the array to
zero.
이벤트 유형
100-189`V4L2_EVENT_ALL`은 모든 이벤트를 한꺼번에 구독 해제할 때만 유효합니다. VSYNC는 수직 동기, EOS는 스트림 끝, CTRL은 control 상태, FRAME_SYNC는 프레임 수신 시작, SOURCE_CHANGE는 실행 중 원천 파라미터 변화, MOTION_DET는 움직임 감지 영역 상태 변화를 알립니다.
CTRL 이벤트를 받으려면 `id`가 대상 control ID와 일치해야 합니다. `VIDIOC_S_CTRL` 또는 `VIDIOC_S_EXT_CTRLS`를 호출해 값을 바꾼 파일 핸들에는 feedback loop 방지를 위해 기본적으로 같은 이벤트를 보내지 않습니다. 호출자도 받아야 한다면 구독 시 `V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK`을 설정합니다.
CTRL 이벤트 큐가 가득 차면 정보 손실을 막기 위해 두 번째로 오래된 이벤트 구조체를 유지하면서 그 `changes`에 가장 오래된 이벤트의 `changes`를 OR합니다. SOURCE_CHANGE도 dequeue 전에 여러 변화가 발생하면 모든 `changes` 비트를 OR해 전달합니다.
FRAME_SYNC는 프레임 수신이 시작되는 즉시 발생합니다. 버퍼 underrun으로 하드웨어를 멈춰야 하는 장치는 이벤트를 만들지 못할 수 있으며 그때 `frame_sequence`가 증가하지 않습니다. 인접 sequence 사이의 시간이 프레임 간격의 n배가 될 수 있습니다.
SOURCE_CHANGE의 `id`는 비디오 장치 노드에서는 입력 인덱스, sub-device 노드에서는 pad 인덱스입니다. MOTION_DET는 하나 이상의 영역 상태가 바뀔 때 발생합니다. `V4L2_EVENT_PRIVATE_START`는 드라이버 전용 이벤트 번호 공간의 시작값입니다.
원문 상수값과 연결 구조체를 보존합니다.
.. tabularcolumns:: |p{6.2cm}|p{2.6cm}|p{8.5cm}|
.. cssclass:: longtable
.. _event-type:
.. flat-table:: Event Types
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4
* - ``V4L2_EVENT_ALL``
- 0
- All events. V4L2_EVENT_ALL is valid only for
VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once.
* - ``V4L2_EVENT_VSYNC``
- 1
- This event is triggered on the vertical sync. This event has a
struct :c:type:`v4l2_event_vsync` associated
with it.
* - ``V4L2_EVENT_EOS``
- 2
- This event is triggered when the end of a stream is reached. This
is typically used with MPEG decoders to report to the application
when the last of the MPEG stream has been decoded.
* - ``V4L2_EVENT_CTRL``
- 3
- This event requires that the ``id`` matches the control ID from
which you want to receive events. This event is triggered if the
control's value changes, if a button control is pressed or if the
control's flags change. This event has a struct
:c:type:`v4l2_event_ctrl` associated with it.
This struct contains much of the same information as struct
:ref:`v4l2_queryctrl <v4l2-queryctrl>` and struct
:c:type:`v4l2_control`.
If the event is generated due to a call to
:ref:`VIDIOC_S_CTRL <VIDIOC_G_CTRL>` or
:ref:`VIDIOC_S_EXT_CTRLS <VIDIOC_G_EXT_CTRLS>`, then the
event will *not* be sent to the file handle that called the ioctl
function. This prevents nasty feedback loops. If you *do* want to
get the event, then set the ``V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK``
flag.
This event type will ensure that no information is lost when more
events are raised than there is room internally. In that case the
struct :c:type:`v4l2_event_ctrl` of the
second-oldest event is kept, but the ``changes`` field of the
second-oldest event is ORed with the ``changes`` field of the
oldest event.
* - ``V4L2_EVENT_FRAME_SYNC``
- 4
- Triggered immediately when the reception of a frame has begun.
This event has a struct
:c:type:`v4l2_event_frame_sync`
associated with it.
If the hardware needs to be stopped in the case of a buffer
underrun it might not be able to generate this event. In such
cases the ``frame_sequence`` field in struct
:c:type:`v4l2_event_frame_sync` will not
be incremented. This causes two consecutive frame sequence numbers
to have n times frame interval in between them.
* - ``V4L2_EVENT_SOURCE_CHANGE``
- 5
- This event is triggered when a source parameter change is detected
during runtime by the video device. It can be a runtime resolution
change triggered by a video decoder or the format change happening
on an input connector. This event requires that the ``id`` matches
the input index (when used with a video device node) or the pad
index (when used with a subdevice node) from which you want to
receive events.
This event has a struct
:c:type:`v4l2_event_src_change`
associated with it. The ``changes`` bitfield denotes what has
changed for the subscribed pad. If multiple events occurred before
application could dequeue them, then the changes will have the
ORed value of all the events generated.
* - ``V4L2_EVENT_MOTION_DET``
- 6
- Triggered whenever the motion detection state for one or more of
the regions changes. This event has a struct
:c:type:`v4l2_event_motion_det`
associated with it.
* - ``V4L2_EVENT_PRIVATE_START``
- 0x08000000
- Base event number for driver-private events.
VSYNC와 control 이벤트 데이터
190-253`v4l2_event_vsync.field`는 다음에 올 field를 나타내며 `enum v4l2_field` 값을 사용합니다.
`v4l2_event_ctrl.changes`는 무엇이 바뀌었는지 나타내는 비트마스크이고 `type`은 control 유형입니다. 32비트 유형은 `value`, 64비트 유형은 `value64`를 사용합니다. 문자열 값은 이벤트로 전달할 수 없으므로 문자열 control의 `value`는 0입니다.
`flags`, `minimum`, `maximum`, `step`, `default_value`는 현재 control의 플래그와 범위를 전달하며 `v4l2_queryctrl` 및 `v4l2_control` 정보와 대응합니다.
두 이벤트 union 멤버의 필드를 정리합니다.
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_event_vsync
.. flat-table:: struct v4l2_event_vsync
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u8
- ``field``
- The upcoming field. See enum :c:type:`v4l2_field`.
.. tabularcolumns:: |p{3.5cm}|p{3.0cm}|p{10.8cm}|
.. c:type:: v4l2_event_ctrl
.. flat-table:: struct v4l2_event_ctrl
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``changes``
- A bitmask that tells what has changed. See
:ref:`ctrl-changes-flags`.
* - __u32
- ``type``
- The type of the control. See enum
:c:type:`v4l2_ctrl_type`.
* - union {
- (anonymous)
* - __s32
- ``value``
- The 32-bit value of the control for 32-bit control types. This is
0 for string controls since the value of a string cannot be passed
using :ref:`VIDIOC_DQEVENT`.
* - __s64
- ``value64``
- The 64-bit value of the control for 64-bit control types.
* - }
-
* - __u32
- ``flags``
- The control flags. See :ref:`control-flags`.
* - __s32
- ``minimum``
- The minimum value of the control. See struct
:ref:`v4l2_queryctrl <v4l2-queryctrl>`.
* - __s32
- ``maximum``
- The maximum value of the control. See struct
:ref:`v4l2_queryctrl <v4l2-queryctrl>`.
* - __s32
- ``step``
- The step value of the control. See struct
:ref:`v4l2_queryctrl <v4l2-queryctrl>`.
* - __s32
- ``default_value``
- The default value of the control. See struct
:ref:`v4l2_queryctrl <v4l2-queryctrl>`.
프레임 동기·원천 변화·움직임 감지 데이터
254-311`v4l2_event_frame_sync.frame_sequence`는 현재 수신 중인 프레임의 sequence 번호입니다. `v4l2_event_src_change.changes`는 원천에서 바뀐 항목을 나타내는 비트마스크입니다.
움직임 감지 이벤트의 `V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ` 플래그가 설정돼야 `frame_sequence`가 유효합니다. 플래그가 없으면 해당 필드를 무시해야 합니다.
`region_mask`는 움직임을 보고한 영역들의 비트마스크입니다. 0이면 움직임이 전혀 감지되지 않았습니다. `V4L2_CID_DETECT_MD_REGION_GRID` control이 없어 grid의 각 cell에 별도 영역을 배정할 수 없으면 모든 cell은 기본 영역 0에 자동 배정됩니다.
프레임 번호와 변화 비트의 유효 조건을 포함합니다.
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_event_frame_sync
.. flat-table:: struct v4l2_event_frame_sync
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``frame_sequence``
- The sequence number of the frame being received.
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_event_src_change
.. flat-table:: struct v4l2_event_src_change
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``changes``
- A bitmask that tells what has changed. See
:ref:`src-changes-flags`.
.. tabularcolumns:: |p{4.4cm}|p{4.4cm}|p{8.5cm}|
.. c:type:: v4l2_event_motion_det
.. flat-table:: struct v4l2_event_motion_det
:header-rows: 0
:stub-columns: 0
:widths: 1 1 2
* - __u32
- ``flags``
- Currently only one flag is available: if
``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` is set, then the
``frame_sequence`` field is valid, otherwise that field should be
ignored.
* - __u32
- ``frame_sequence``
- The sequence number of the frame being received. Only valid if the
``V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ`` flag was set.
* - __u32
- ``region_mask``
- The bitmask of the regions that reported motion. There is at least
one region. If this field is 0, then no motion was detected at
all. If there is no ``V4L2_CID_DETECT_MD_REGION_GRID`` control
(see :ref:`detect-controls`) to assign a different region to
each cell in the motion detection grid, then that all cells are
automatically assigned to the default region 0.
Control Changes 비트
312-341control 이벤트의 `changes`는 값, 플래그, 범위 또는 차원 중 무엇이 바뀌었는지 표시합니다. 여러 이벤트가 병합되면 해당 비트들이 OR됩니다.
각 변화 비트의 값과 예외입니다.
.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
.. _ctrl-changes-flags:
.. flat-table:: Control Changes
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4
* - ``V4L2_EVENT_CTRL_CH_VALUE``
- 0x0001
- This control event was triggered because the value of the control
changed. Special cases: Volatile controls do no generate this
event; If a control has the ``V4L2_CTRL_FLAG_EXECUTE_ON_WRITE``
flag set, then this event is sent as well, regardless its value.
* - ``V4L2_EVENT_CTRL_CH_FLAGS``
- 0x0002
- This control event was triggered because the control flags
changed.
* - ``V4L2_EVENT_CTRL_CH_RANGE``
- 0x0004
- This control event was triggered because the minimum, maximum,
step or the default value of the control changed.
* - ``V4L2_EVENT_CTRL_CH_DIMENSIONS``
- 0x0008
- This control event was triggered because the dimensions of the
control changed. Note that the number of dimensions remains the
same.
Source Changes 비트와 스트리밍 재시작
342-371`V4L2_EVENT_SRC_CH_RESOLUTION` 값은 `0x0001`이며 입력 커넥터나 비디오 디코더에서 해상도 변화가 감지될 때 발생합니다. 신호가 사라졌을 수도 있으므로 응용 프로그램은 새 해상도를 다시 조회해야 합니다.
stateful 디코더는 decoder 문서의 절차를 따릅니다. 비디오 캡처 장치는 `VIDIOC_QUERY_DV_TIMINGS` 또는 `VIDIOC_QUERYSTD`로 새 타이밍을 조회합니다.
새 타이밍이 이전과 같아 보여도 이 이벤트는 영상 신호에 문제가 있었다는 뜻입니다. 많은 캡처 장치는 일시적 신호 손실에서 자동 복구하지 못하므로 `VIDIOC_STREAMOFF` 뒤 `VIDIOC_STREAMON`으로 스트리밍을 재시작해 하드웨어를 신호에 다시 동기화해야 합니다.
현재 정의된 source 변화 비트입니다.
.. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.5cm}|
.. _src-changes-flags:
.. flat-table:: Source Changes
:header-rows: 0
:stub-columns: 0
:widths: 3 1 4
* - ``V4L2_EVENT_SRC_CH_RESOLUTION``
- 0x0001
- This event gets triggered when a resolution change is detected at
an input. This can come from an input connector or from a video
decoder. Applications will have to query the new resolution (if
any, the signal may also have been lost).
For stateful decoders follow the guidelines in :ref:`decoder`.
Video Capture devices have to query the new timings using
:ref:`VIDIOC_QUERY_DV_TIMINGS` or
:ref:`VIDIOC_QUERYSTD <VIDIOC_QUERYSTD>`.
*Important*: even if the new video timings appear identical to the old
ones, receiving this event indicates that there was an issue with the
video signal and you must stop and restart streaming
(:ref:`VIDIOC_STREAMOFF <VIDIOC_STREAMON>`
followed by :ref:`VIDIOC_STREAMON <VIDIOC_STREAMON>`). The reason is
that many Video Capture devices are not able to recover from a temporary
loss of signal and so restarting streaming I/O is required in order for
the hardware to synchronize to the video signal.
반환값
372-377성공하면 0을 반환하고 실패하면 -1과 적절한 `errno`를 반환합니다. 공통 오류는 Generic Error Codes 절을 따릅니다.
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.
요약·해설
vidioc-dqevent.rst:1-377VIDIOC_DQEVENT로 구독 이벤트를 꺼내고 공통 sequence·timestamp·pending 메타데이터와 control, frame, source, motion 이벤트의 병합·유실·재시작 규칙을 해석합니다.