← Documents Documentation/userspace-api/media/dvb/legacy_dvb_video.rst GitHub 원문 ↗

Linux 6.18.37 · Userspace API / Media / DVB / Legacy decoder

DVB Video Device

폐기된 DVB MPEG video decoder의 type, event, ioctl과 stream 입출력을 설명합니다.

Source pathDocumentation/userspace-api/media/dvb/legacy_dvb_video.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

legacy_dvb_video.rst:1-2430

이 API는 새 드라이버에서 사용하면 안 되는 legacy DVB MPEG decoder 인터페이스입니다. Demux 또는 memory stream을 받아 재생 상태, event, aspect ratio, still picture, 속도, codec type, PTS와 frame count를 제어·조회합니다.

원문 symbol과 호출 선언은 그대로 보존했습니다. `video_display_format_t`/`video_displayformat_t`와 `VIDEO_GET_FRAME_COUNT`의 `*pts`처럼 선언과 의미가 어긋나는 부분은 번역 본문에 검수 지점으로 명시했습니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later OR GPL-2.0
2
3 .. c:namespace:: dtv.legacy.video
4
5 .. _dvb_video:
6
7 ================
8 DVB Video Device
9 ================
10
11 .. attention:: Do **not** use in new drivers!
12 See: :ref:`legacy_dvb_decoder_notes`
13
14 The DVB video device controls the MPEG2 video decoder of the DVB
15 hardware. It can be accessed through ``/dev/dvb/adapter0/video0``. Data
16 types and ioctl definitions can be accessed by including
17 ``linux/dvb/video.h`` in your application.
18
19 Note that the DVB video device only controls decoding of the MPEG video
20 stream, not its presentation on the TV or computer screen. On PCs this
21 is typically handled by an associated video4linux device, e.g.
22 ``/dev/video``, which allows scaling and defining output windows.
23
24 Most DVB cards don’t have their own MPEG decoder, which results in the
25 omission of the audio and video device as well as the video4linux
26 device.
27
28 These ioctls were also used by V4L2 to control MPEG decoders implemented
29 in V4L2. The use of these ioctls for that purpose has been made obsolete
30 and proper V4L2 ioctls or controls have been created to replace that
31 functionality. Use :ref:`V4L2 ioctls<video>` for new drivers!
32
33
34 Video Data Types
35 ================
36
37
38
39 video_format_t
40 --------------
41
42 Synopsis
43 ~~~~~~~~
44
45 .. code-block:: c
46
47 typedef enum {
48 VIDEO_FORMAT_4_3,
49 VIDEO_FORMAT_16_9,
50 VIDEO_FORMAT_221_1
51 } video_format_t;
52
53 Constants
54 ~~~~~~~~~
55
56 .. flat-table::
57 :header-rows: 0
58 :stub-columns: 0
59
60 - ..
61
62 - ``VIDEO_FORMAT_4_3``
63
64 - Select 4:3 format.
65
66 - ..
67
68 - ``VIDEO_FORMAT_16_9``
69
70 - Select 16:9 format.
71
72 - ..
73
74 - ``VIDEO_FORMAT_221_1``
75
76 - Select 2.21:1 format.
77
78 Description
79 ~~~~~~~~~~~
80
81 The ``video_format_t`` data type
82 is used in the `VIDEO_SET_FORMAT`_ function to tell the driver which
83 aspect ratio the output hardware (e.g. TV) has. It is also used in the
84 data structures `video_status`_ returned by `VIDEO_GET_STATUS`_
85 and `video_event`_ returned by `VIDEO_GET_EVENT`_ which report
86 about the display format of the current video stream.
87
88
89 -----
90
91
92 video_displayformat_t
93 ---------------------
94
95 Synopsis
96 ~~~~~~~~
97
98 .. code-block:: c
99
100 typedef enum {
101 VIDEO_PAN_SCAN,
102 VIDEO_LETTER_BOX,
103 VIDEO_CENTER_CUT_OUT
104 } video_displayformat_t;
105
106 Constants
107 ~~~~~~~~~
108
109 .. flat-table::
110 :header-rows: 0
111 :stub-columns: 0
112
113 - ..
114
115 - ``VIDEO_PAN_SCAN``
116
117 - Use pan and scan format.
118
119 - ..
120
121 - ``VIDEO_LETTER_BOX``
122
123 - Use letterbox format.
124
125 - ..
126
127 - ``VIDEO_CENTER_CUT_OUT``
128
129 - Use center cut out format.
130
131 Description
132 ~~~~~~~~~~~
133
134 In case the display format of the video stream and of the display
135 hardware differ the application has to specify how to handle the
136 cropping of the picture. This can be done using the
137 `VIDEO_SET_DISPLAY_FORMAT`_ call which accepts this enum as argument.
138
139
140 -----
141
142
143 video_size_t
144 ------------
145
146 Synopsis
147 ~~~~~~~~
148
149 .. code-block:: c
150
151 typedef struct {
152 int w;
153 int h;
154 video_format_t aspect_ratio;
155 } video_size_t;
156
157 Variables
158 ~~~~~~~~~
159
160 .. flat-table::
161 :header-rows: 0
162 :stub-columns: 0
163
164 - ..
165
166 - ``int w``
167
168 - Video width in pixels.
169
170 - ..
171
172 - ``int h``
173
174 - Video height in pixels.
175
176 - ..
177
178 - `video_format_t`_ ``aspect_ratio``
179
180 - Aspect ratio.
181
182 Description
183 ~~~~~~~~~~~
184
185 Used in the struct `video_event`_. It stores the resolution and
186 aspect ratio of the video.
187
188
189 -----
190
191
192 video_stream_source_t
193 ---------------------
194
195 Synopsis
196 ~~~~~~~~
197
198 .. code-block:: c
199
200 typedef enum {
201 VIDEO_SOURCE_DEMUX,
202 VIDEO_SOURCE_MEMORY
203 } video_stream_source_t;
204
205 Constants
206 ~~~~~~~~~
207
208 .. flat-table::
209 :header-rows: 0
210 :stub-columns: 0
211
212 - ..
213
214 - ``VIDEO_SOURCE_DEMUX``
215
216 - :cspan:`1` Select the demux as the main source.
217
218 - ..
219
220 - ``VIDEO_SOURCE_MEMORY``
221
222 - If this source is selected, the stream
223 comes from the user through the write
224 system call.
225
226 Description
227 ~~~~~~~~~~~
228
229 The video stream source is set through the `VIDEO_SELECT_SOURCE`_ call
230 and can take the following values, depending on whether we are replaying
231 from an internal (demuxer) or external (user write) source.
232 VIDEO_SOURCE_DEMUX selects the demultiplexer (fed either by the
233 frontend or the DVR device) as the source of the video stream. If
234 VIDEO_SOURCE_MEMORY is selected the stream comes from the application
235 through the `write()`_ system call.
236
237
238 -----
239
240
241 video_play_state_t
242 ------------------
243
244 Synopsis
245 ~~~~~~~~
246
247 .. code-block:: c
248
249 typedef enum {
250 VIDEO_STOPPED,
251 VIDEO_PLAYING,
252 VIDEO_FREEZED
253 } video_play_state_t;
254
255 Constants
256 ~~~~~~~~~
257
258 .. flat-table::
259 :header-rows: 0
260 :stub-columns: 0
261
262 - ..
263
264 - ``VIDEO_STOPPED``
265
266 - Video is stopped.
267
268 - ..
269
270 - ``VIDEO_PLAYING``
271
272 - Video is currently playing.
273
274 - ..
275
276 - ``VIDEO_FREEZED``
277
278 - Video is frozen.
279
280 Description
281 ~~~~~~~~~~~
282
283 This values can be returned by the `VIDEO_GET_STATUS`_ call
284 representing the state of video playback.
285
286
287 -----
288
289
290 struct video_command
291 --------------------
292
293 Synopsis
294 ~~~~~~~~
295
296 .. code-block:: c
297
298 struct video_command {
299 __u32 cmd;
300 __u32 flags;
301 union {
302 struct {
303 __u64 pts;
304 } stop;
305
306 struct {
307 __s32 speed;
308 __u32 format;
309 } play;
310
311 struct {
312 __u32 data[16];
313 } raw;
314 };
315 };
316
317
318 Variables
319 ~~~~~~~~~
320
321 .. flat-table::
322 :header-rows: 0
323 :stub-columns: 0
324
325 - ..
326
327 - ``__u32 cmd``
328
329 - `Decoder command`_
330
331 - ..
332
333 - ``__u32 flags``
334
335 - Flags for the `Decoder command`_.
336
337 - ..
338
339 - ``struct stop``
340
341 - ``__u64 pts``
342
343 - MPEG PTS
344
345 - ..
346
347 - :rspan:`5` ``stuct play``
348
349 - :rspan:`4` ``__s32 speed``
350
351 - 0 or 1000 specifies normal speed,
352
353 - ..
354
355 - 1: specifies forward single stepping,
356
357 - ..
358
359 - -1: specifies backward single stepping,
360
361 - ..
362
363 - >1: playback at speed / 1000 of the normal speed
364
365 - ..
366
367 - <-1: reverse playback at ( -speed / 1000 ) of the normal speed.
368
369 - ..
370
371 - ``__u32 format``
372
373 - `Play input formats`_
374
375 - ..
376
377 - ``__u32 data[16]``
378
379 - Reserved
380
381 Description
382 ~~~~~~~~~~~
383
384 The structure must be zeroed before use by the application. This ensures
385 it can be extended safely in the future.
386
387
388 -----
389
390
391 Predefined decoder commands and flags
392 -------------------------------------
393
394 Synopsis
395 ~~~~~~~~
396
397 .. code-block:: c
398
399 #define VIDEO_CMD_PLAY (0)
400 #define VIDEO_CMD_STOP (1)
401 #define VIDEO_CMD_FREEZE (2)
402 #define VIDEO_CMD_CONTINUE (3)
403
404 #define VIDEO_CMD_FREEZE_TO_BLACK (1 << 0)
405
406 #define VIDEO_CMD_STOP_TO_BLACK (1 << 0)
407 #define VIDEO_CMD_STOP_IMMEDIATELY (1 << 1)
408
409 #define VIDEO_PLAY_FMT_NONE (0)
410 #define VIDEO_PLAY_FMT_GOP (1)
411
412 #define VIDEO_VSYNC_FIELD_UNKNOWN (0)
413 #define VIDEO_VSYNC_FIELD_ODD (1)
414 #define VIDEO_VSYNC_FIELD_EVEN (2)
415 #define VIDEO_VSYNC_FIELD_PROGRESSIVE (3)
416
417 Constants
418 ~~~~~~~~~
419
420 .. flat-table::
421 :header-rows: 0
422 :stub-columns: 0
423
424 - ..
425
426 - :rspan:`3` _`Decoder command`
427
428 - ``VIDEO_CMD_PLAY``
429
430 - Start playback.
431
432 - ..
433
434 - ``VIDEO_CMD_STOP``
435
436 - Stop playback.
437
438 - ..
439
440 - ``VIDEO_CMD_FREEZE``
441
442 - Freeze playback.
443
444 - ..
445
446 - ``VIDEO_CMD_CONTINUE``
447
448 - Continue playback after freeze.
449
450 - ..
451
452 - Flags for ``VIDEO_CMD_FREEZE``
453
454 - ``VIDEO_CMD_FREEZE_TO_BLACK``
455
456 - Show black picture on freeze.
457
458 - ..
459
460 - :rspan:`1` Flags for ``VIDEO_CMD_STOP``
461
462 - ``VIDEO_CMD_STOP_TO_BLACK``
463
464 - Show black picture on stop.
465
466 - ..
467
468 - ``VIDEO_CMD_STOP_IMMEDIATELY``
469
470 - Stop immediately, without emptying buffers.
471
472 - ..
473
474 - :rspan:`1` _`Play input formats`
475
476 - ``VIDEO_PLAY_FMT_NONE``
477
478 - The decoder has no special format requirements
479
480 - ..
481
482 - ``VIDEO_PLAY_FMT_GOP``
483
484 - The decoder requires full GOPs
485
486 - ..
487
488 - :rspan:`3` Field order
489
490 - ``VIDEO_VSYNC_FIELD_UNKNOWN``
491
492 - FIELD_UNKNOWN can be used if the hardware does not know
493 whether the Vsync is for an odd, even or progressive
494 (i.e. non-interlaced) field.
495
496 - ..
497
498 - ``VIDEO_VSYNC_FIELD_ODD``
499
500 - Vsync is for an odd field.
501
502 - ..
503
504 - ``VIDEO_VSYNC_FIELD_EVEN``
505
506 - Vsync is for an even field.
507
508 - ..
509
510 - ``VIDEO_VSYNC_FIELD_PROGRESSIVE``
511
512 - progressive (i.e. non-interlaced)
513
514
515 -----
516
517
518 video_event
519 -----------
520
521 Synopsis
522 ~~~~~~~~
523
524 .. code-block:: c
525
526 struct video_event {
527 __s32 type;
528 #define VIDEO_EVENT_SIZE_CHANGED 1
529 #define VIDEO_EVENT_FRAME_RATE_CHANGED 2
530 #define VIDEO_EVENT_DECODER_STOPPED 3
531 #define VIDEO_EVENT_VSYNC 4
532 long timestamp;
533 union {
534 video_size_t size;
535 unsigned int frame_rate;
536 unsigned char vsync_field;
537 } u;
538 };
539
540 Variables
541 ~~~~~~~~~
542
543 .. flat-table::
544 :header-rows: 0
545 :stub-columns: 0
546
547 - ..
548
549 - :rspan:`4` ``__s32 type``
550
551 - :cspan:`1` Event type.
552
553 - ..
554
555 - ``VIDEO_EVENT_SIZE_CHANGED``
556
557 - Size changed.
558
559 - ..
560
561 - ``VIDEO_EVENT_FRAME_RATE_CHANGED``
562
563 - Framerate changed.
564
565 - ..
566
567 - ``VIDEO_EVENT_DECODER_STOPPED``
568
569 - Decoder stopped.
570
571 - ..
572
573 - ``VIDEO_EVENT_VSYNC``
574
575 - Vsync occurred.
576
577 - ..
578
579 - ``long timestamp``
580
581 - :cspan:`1` MPEG PTS at occurrence.
582
583 - ..
584
585 - :rspan:`2` ``union u``
586
587 - `video_size_t`_ size
588
589 - Resolution and aspect ratio of the video.
590
591 - ..
592
593 - ``unsigned int frame_rate``
594
595 - in frames per 1000sec
596
597 - ..
598
599 - ``unsigned char vsync_field``
600
601 - | unknown / odd / even / progressive
602 | See: `Predefined decoder commands and flags`_
603
604 Description
605 ~~~~~~~~~~~
606
607 This is the structure of a video event as it is returned by the
608 `VIDEO_GET_EVENT`_ call. See there for more details.
609
610
611 -----
612
613
614 video_status
615 ------------
616
617 Synopsis
618 ~~~~~~~~
619
620 The `VIDEO_GET_STATUS`_ call returns the following structure informing
621 about various states of the playback operation.
622
623 .. code-block:: c
624
625 struct video_status {
626 int video_blank;
627 video_play_state_t play_state;
628 video_stream_source_t stream_source;
629 video_format_t video_format;
630 video_displayformat_t display_format;
631 };
632
633 Variables
634 ~~~~~~~~~
635
636 .. flat-table::
637 :header-rows: 0
638 :stub-columns: 0
639
640 - ..
641
642 - :rspan:`2` ``int video_blank``
643
644 - :cspan:`1` Show blank video on freeze?
645
646 - ..
647
648 - TRUE ( != 0 )
649
650 - Blank screen when freeze.
651
652 - ..
653
654 - FALSE ( == 0 )
655
656 - Show last decoded frame.
657
658 - ..
659
660 - `video_play_state_t`_ ``play_state``
661
662 - Current state of playback.
663
664 - ..
665
666 - `video_stream_source_t`_ ``stream_source``
667
668 - Current source (demux/memory).
669
670 - ..
671
672 - `video_format_t`_ ``video_format``
673
674 - Current aspect ratio of stream.
675
676 - ..
677
678 - `video_displayformat_t`_ ``display_format``
679
680 - Applied cropping mode.
681
682 Description
683 ~~~~~~~~~~~
684
685 If ``video_blank`` is set ``TRUE`` video will be blanked out if the
686 channel is changed or if playback is stopped. Otherwise, the last picture
687 will be displayed. ``play_state`` indicates if the video is currently
688 frozen, stopped, or being played back. The ``stream_source`` corresponds
689 to the selected source for the video stream. It can come either from the
690 demultiplexer or from memory. The ``video_format`` indicates the aspect
691 ratio (one of 4:3 or 16:9) of the currently played video stream.
692 Finally, ``display_format`` corresponds to the applied cropping mode in
693 case the source video format is not the same as the format of the output
694 device.
695
696
697 -----
698
699
700 video_still_picture
701 -------------------
702
703 Synopsis
704 ~~~~~~~~
705
706 .. code-block:: c
707
708 struct video_still_picture {
709 char *iFrame;
710 int32_t size;
711 };
712
713 Variables
714 ~~~~~~~~~
715
716 .. flat-table::
717 :header-rows: 0
718 :stub-columns: 0
719
720 - ..
721
722 - ``char *iFrame``
723
724 - Pointer to a single iframe in memory.
725
726 - ..
727
728 - ``int32_t size``
729
730 - Size of the iframe.
731
732
733 Description
734 ~~~~~~~~~~~
735
736 An I-frame displayed via the `VIDEO_STILLPICTURE`_ call is passed on
737 within this structure.
738
739
740 -----
741
742
743 video capabilities
744 ------------------
745
746 Synopsis
747 ~~~~~~~~
748
749 .. code-block:: c
750
751 #define VIDEO_CAP_MPEG1 1
752 #define VIDEO_CAP_MPEG2 2
753 #define VIDEO_CAP_SYS 4
754 #define VIDEO_CAP_PROG 8
755
756 Constants
757 ~~~~~~~~~
758 Bit definitions for capabilities:
759
760 .. flat-table::
761 :header-rows: 0
762 :stub-columns: 0
763
764 - ..
765
766 - ``VIDEO_CAP_MPEG1``
767
768 - :cspan:`1` The hardware can decode MPEG1.
769
770 - ..
771
772 - ``VIDEO_CAP_MPEG2``
773
774 - The hardware can decode MPEG2.
775
776 - ..
777
778 - ``VIDEO_CAP_SYS``
779
780 - The video device accepts system stream.
781
782 You still have to open the video and the audio device
783 but only send the stream to the video device.
784
785 - ..
786
787 - ``VIDEO_CAP_PROG``
788
789 - The video device accepts program stream.
790
791 You still have to open the video and the audio device
792 but only send the stream to the video device.
793
794 Description
795 ~~~~~~~~~~~
796
797 A call to `VIDEO_GET_CAPABILITIES`_ returns an unsigned integer with the
798 following bits set according to the hardware's capabilities.
799
800
801 -----
802
803
804 Video Function Calls
805 ====================
806
807
808 VIDEO_STOP
809 ----------
810
811 Synopsis
812 ~~~~~~~~
813
814 .. c:macro:: VIDEO_STOP
815
816 .. code-block:: c
817
818 int ioctl(fd, VIDEO_STOP, int mode)
819
820 Arguments
821 ~~~~~~~~~
822
823 .. flat-table::
824 :header-rows: 0
825 :stub-columns: 0
826
827 - ..
828
829 - ``int fd``
830
831 - :cspan:`1` File descriptor returned by a previous call
832 to `open()`_.
833
834 - ..
835
836 - ``int request``
837
838 - :cspan:`1` Equals ``VIDEO_STOP`` for this command.
839
840 - ..
841
842 - :rspan:`2` ``int mode``
843
844 - :cspan:`1` Indicates how the screen shall be handled.
845
846 - ..
847
848 - TRUE ( != 0 )
849
850 - Blank screen when stop.
851
852 - ..
853
854 - FALSE ( == 0 )
855
856 - Show last decoded frame.
857
858 Description
859 ~~~~~~~~~~~
860
861 .. attention:: Do **not** use in new drivers!
862 See: :ref:`legacy_dvb_decoder_notes`
863
864 This ioctl is for Digital TV devices only. To control a V4L2 decoder use
865 the V4L2 :ref:`VIDIOC_DECODER_CMD` instead.
866
867 This ioctl call asks the Video Device to stop playing the current
868 stream. Depending on the input parameter, the screen can be blanked out
869 or displaying the last decoded frame.
870
871 Return Value
872 ~~~~~~~~~~~~
873
874 On success 0 is returned, on error -1 and the ``errno`` variable is set
875 appropriately. The generic error codes are described at the
876 :ref:`Generic Error Codes <gen-errors>` chapter.
877
878
879 -----
880
881
882 VIDEO_PLAY
883 ----------
884
885 Synopsis
886 ~~~~~~~~
887
888 .. c:macro:: VIDEO_PLAY
889
890 .. code-block:: c
891
892 int ioctl(fd, VIDEO_PLAY)
893
894 Arguments
895 ~~~~~~~~~
896
897 .. flat-table::
898 :header-rows: 0
899 :stub-columns: 0
900
901 - ..
902
903 - ``int fd``
904
905 - :cspan:`1` File descriptor returned by a previous call
906 to `open()`_.
907
908 - ..
909
910 - ``int request``
911
912 - Equals ``VIDEO_PLAY`` for this command.
913
914 Description
915 ~~~~~~~~~~~
916
917 .. attention:: Do **not** use in new drivers!
918 See: :ref:`legacy_dvb_decoder_notes`
919
920 This ioctl is for Digital TV devices only. To control a V4L2 decoder use
921 the V4L2 :ref:`VIDIOC_DECODER_CMD` instead.
922
923 This ioctl call asks the Video Device to start playing a video stream
924 from the selected source.
925
926 Return Value
927 ~~~~~~~~~~~~
928
929 On success 0 is returned, on error -1 and the ``errno`` variable is set
930 appropriately. The generic error codes are described at the
931 :ref:`Generic Error Codes <gen-errors>` chapter.
932
933
934 -----
935
936
937 VIDEO_FREEZE
938 ------------
939
940 Synopsis
941 ~~~~~~~~
942
943 .. c:macro:: VIDEO_FREEZE
944
945 .. code-block:: c
946
947 int ioctl(fd, VIDEO_FREEZE)
948
949 Arguments
950 ~~~~~~~~~
951
952 .. flat-table::
953 :header-rows: 0
954 :stub-columns: 0
955
956 - ..
957
958 - ``int fd``
959
960 - :cspan:`1` File descriptor returned by a previous call
961 to `open()`_.
962
963 - ..
964
965 - ``int request``
966
967 - Equals ``VIDEO_FREEZE`` for this command.
968
969 Description
970 ~~~~~~~~~~~
971
972 .. attention:: Do **not** use in new drivers!
973 See: :ref:`legacy_dvb_decoder_notes`
974
975 This ioctl is for Digital TV devices only. To control a V4L2 decoder use
976 the V4L2 :ref:`VIDIOC_DECODER_CMD` instead.
977
978 This ioctl call suspends the live video stream being played, if
979 VIDEO_SOURCE_DEMUX is selected. Decoding and playing are frozen.
980 It is then possible to restart the decoding and playing process of the
981 video stream using the `VIDEO_CONTINUE`_ command.
982 If VIDEO_SOURCE_MEMORY is selected in the ioctl call
983 `VIDEO_SELECT_SOURCE`_, the Digital TV subsystem will not decode any more
984 data until the ioctl call `VIDEO_CONTINUE`_ or `VIDEO_PLAY`_ is performed.
985
986 Return Value
987 ~~~~~~~~~~~~
988
989 On success 0 is returned, on error -1 and the ``errno`` variable is set
990 appropriately. The generic error codes are described at the
991 :ref:`Generic Error Codes <gen-errors>` chapter.
992
993
994 -----
995
996
997 VIDEO_CONTINUE
998 --------------
999
1000 Synopsis
1001 ~~~~~~~~
1003 .. c:macro:: VIDEO_CONTINUE
1005 .. code-block:: c
1007 int ioctl(fd, VIDEO_CONTINUE)
1009 Arguments
1010 ~~~~~~~~~
1012 .. flat-table::
1013 :header-rows: 0
1014 :stub-columns: 0
1016 - ..
1018 - ``int fd``
1020 - :cspan:`1` File descriptor returned by a previous call
1021 to `open()`_.
1023 - ..
1025 - ``int request``
1027 - Equals ``VIDEO_CONTINUE`` for this command.
1029 Description
1030 ~~~~~~~~~~~
1032 .. attention:: Do **not** use in new drivers!
1033 See: :ref:`legacy_dvb_decoder_notes`
1035 This ioctl is for Digital TV devices only. To control a V4L2 decoder use
1036 the V4L2 :ref:`VIDIOC_DECODER_CMD` instead.
1038 This ioctl call restarts decoding and playing processes of the video
1039 stream which was played before a call to `VIDEO_FREEZE`_ was made.
1041 Return Value
1042 ~~~~~~~~~~~~
1044 On success 0 is returned, on error -1 and the ``errno`` variable is set
1045 appropriately. The generic error codes are described at the
1046 :ref:`Generic Error Codes <gen-errors>` chapter.
1049 -----
1052 VIDEO_SELECT_SOURCE
1053 -------------------
1055 Synopsis
1056 ~~~~~~~~
1058 .. c:macro:: VIDEO_SELECT_SOURCE
1060 .. code-block:: c
1062 int ioctl(fd, VIDEO_SELECT_SOURCE, video_stream_source_t source)
1064 Arguments
1065 ~~~~~~~~~
1067 .. flat-table::
1068 :header-rows: 0
1069 :stub-columns: 0
1071 - ..
1073 - ``int fd``
1075 - :cspan:`1` File descriptor returned by a previous call
1076 to `open()`_.
1078 - ..
1080 - ``int request``
1082 - Equals ``VIDEO_SELECT_SOURCE`` for this command.
1084 - ..
1086 - `video_stream_source_t`_ ``source``
1088 - Indicates which source shall be used for the Video stream.
1090 Description
1091 ~~~~~~~~~~~
1093 .. attention:: Do **not** use in new drivers!
1094 See: :ref:`legacy_dvb_decoder_notes`
1096 This ioctl is for Digital TV devices only. This ioctl was also supported
1097 by the V4L2 ivtv driver, but that has been replaced by the ivtv-specific
1098 ``IVTV_IOC_PASSTHROUGH_MODE`` ioctl.
1100 This ioctl call informs the video device which source shall be used for
1101 the input data. The possible sources are demux or memory. If memory is
1102 selected, the data is fed to the video device through the write command
1103 using the struct `video_stream_source_t`_. If demux is selected, the data
1104 is directly transferred from the onboard demux-device to the decoder.
1106 The data fed to the decoder is also controlled by the PID-filter.
1107 Output selection: :c:type:`dmx_output` ``DMX_OUT_DECODER``.
1110 Return Value
1111 ~~~~~~~~~~~~
1113 On success 0 is returned, on error -1 and the ``errno`` variable is set
1114 appropriately. The generic error codes are described at the
1115 :ref:`Generic Error Codes <gen-errors>` chapter.
1118 -----
1121 VIDEO_SET_BLANK
1122 ---------------
1124 Synopsis
1125 ~~~~~~~~
1127 .. c:macro:: VIDEO_SET_BLANK
1129 .. code-block:: c
1131 int ioctl(fd, VIDEO_SET_BLANK, int mode)
1133 Arguments
1134 ~~~~~~~~~
1136 .. flat-table::
1137 :header-rows: 0
1138 :stub-columns: 0
1140 - ..
1142 - ``int fd``
1144 - :cspan:`1` File descriptor returned by a previous call
1145 to `open()`_.
1147 - ..
1149 - ``int request``
1151 - :cspan:`1` Equals ``VIDEO_SET_BLANK`` for this command.
1153 - ..
1155 - :rspan:`2` ``int mode``
1157 - :cspan:`1` Indicates if the screen shall be blanked.
1159 - ..
1161 - TRUE ( != 0 )
1163 - Blank screen when stop.
1165 - ..
1167 - FALSE ( == 0 )
1169 - Show last decoded frame.
1171 Description
1172 ~~~~~~~~~~~
1174 .. attention:: Do **not** use in new drivers!
1175 See: :ref:`legacy_dvb_decoder_notes`
1177 This ioctl call asks the Video Device to blank out the picture.
1179 Return Value
1180 ~~~~~~~~~~~~
1182 On success 0 is returned, on error -1 and the ``errno`` variable is set
1183 appropriately. The generic error codes are described at the
1184 :ref:`Generic Error Codes <gen-errors>` chapter.
1187 -----
1190 VIDEO_GET_STATUS
1191 ----------------
1193 Synopsis
1194 ~~~~~~~~
1196 .. c:macro:: VIDEO_GET_STATUS
1198 .. code-block:: c
1200 int ioctl(fd, int request = VIDEO_GET_STATUS,
1201 struct video_status *status)
1203 Arguments
1204 ~~~~~~~~~
1206 .. flat-table::
1207 :header-rows: 0
1208 :stub-columns: 0
1210 - ..
1212 - ``int fd``
1214 - :cspan:`1` File descriptor returned by a previous call
1215 to `open()`_.
1217 - ..
1219 - ``int request``
1221 - Equals ``VIDEO_GET_STATUS`` for this command.
1223 - ..
1225 - ``struct`` `video_status`_ ``*status``
1227 - Returns the current status of the Video Device.
1229 Description
1230 ~~~~~~~~~~~
1232 .. attention:: Do **not** use in new drivers!
1233 See: :ref:`legacy_dvb_decoder_notes`
1235 This ioctl call asks the Video Device to return the current status of
1236 the device.
1238 Return Value
1239 ~~~~~~~~~~~~
1241 On success 0 is returned, on error -1 and the ``errno`` variable is set
1242 appropriately. The generic error codes are described at the
1243 :ref:`Generic Error Codes <gen-errors>` chapter.
1246 -----
1249 VIDEO_GET_EVENT
1250 ---------------
1252 Synopsis
1253 ~~~~~~~~
1255 .. c:macro:: VIDEO_GET_EVENT
1257 .. code-block:: c
1259 int ioctl(fd, int request = VIDEO_GET_EVENT,
1260 struct video_event *ev)
1262 Arguments
1263 ~~~~~~~~~
1265 .. flat-table::
1266 :header-rows: 0
1267 :stub-columns: 0
1269 - ..
1271 - ``int fd``
1273 - :cspan:`1` File descriptor returned by a previous call
1274 to `open()`_.
1276 - ..
1278 - ``int request``
1280 - Equals ``VIDEO_GET_EVENT`` for this command.
1282 - ..
1284 - ``struct`` `video_event`_ ``*ev``
1286 - Points to the location where the event, if any, is to be stored.
1288 Description
1289 ~~~~~~~~~~~
1291 .. attention:: Do **not** use in new drivers!
1292 See: :ref:`legacy_dvb_decoder_notes`
1294 This ioctl is for DVB devices only. To get events from a V4L2 decoder
1295 use the V4L2 :ref:`VIDIOC_DQEVENT` ioctl instead.
1297 This ioctl call returns an event of type `video_event`_ if available. A
1298 certain number of the latest events will be cued and returned in order of
1299 occurrence. Older events may be discarded if not fetched in time. If
1300 an event is not available, the behavior depends on whether the device is
1301 in blocking or non-blocking mode. In the latter case, the call fails
1302 immediately with errno set to ``EWOULDBLOCK``. In the former case, the
1303 call blocks until an event becomes available. The standard Linux poll()
1304 and/or select() system calls can be used with the device file descriptor
1305 to watch for new events. For select(), the file descriptor should be
1306 included in the exceptfds argument, and for poll(), POLLPRI should be
1307 specified as the wake-up condition. Read-only permissions are sufficient
1308 for this ioctl call.
1310 Return Value
1311 ~~~~~~~~~~~~
1313 On success 0 is returned, on error -1 and the ``errno`` variable is set
1314 appropriately. The generic error codes are described at the
1315 :ref:`Generic Error Codes <gen-errors>` chapter.
1317 .. flat-table::
1318 :header-rows: 0
1319 :stub-columns: 0
1321 - ..
1323 - ``EWOULDBLOCK``
1325 - :cspan:`1` There is no event pending, and the device is in
1326 non-blocking mode.
1328 - ..
1330 - ``EOVERFLOW``
1332 - Overflow in event queue - one or more events were lost.
1335 -----
1338 VIDEO_SET_DISPLAY_FORMAT
1339 ------------------------
1341 Synopsis
1342 ~~~~~~~~
1344 .. c:macro:: VIDEO_SET_DISPLAY_FORMAT
1346 .. code-block:: c
1348 int ioctl(fd, int request = VIDEO_SET_DISPLAY_FORMAT,
1349 video_display_format_t format)
1351 Arguments
1352 ~~~~~~~~~
1354 .. flat-table::
1355 :header-rows: 0
1356 :stub-columns: 0
1358 - ..
1360 - ``int fd``
1362 - :cspan:`1` File descriptor returned by a previous call
1363 to `open()`_.
1365 - ..
1367 - ``int request``
1369 - Equals ``VIDEO_SET_DISPLAY_FORMAT`` for this command.
1371 - ..
1373 - `video_displayformat_t`_ ``format``
1375 - Selects the video format to be used.
1377 Description
1378 ~~~~~~~~~~~
1380 .. attention:: Do **not** use in new drivers!
1381 See: :ref:`legacy_dvb_decoder_notes`
1383 This ioctl call asks the Video Device to select the video format to be
1384 applied by the MPEG chip on the video.
1386 Return Value
1387 ~~~~~~~~~~~~
1389 On success 0 is returned, on error -1 and the ``errno`` variable is set
1390 appropriately. The generic error codes are described at the
1391 :ref:`Generic Error Codes <gen-errors>` chapter.
1394 -----
1397 VIDEO_STILLPICTURE
1398 ------------------
1400 Synopsis
1401 ~~~~~~~~
1403 .. c:macro:: VIDEO_STILLPICTURE
1405 .. code-block:: c
1407 int ioctl(fd, int request = VIDEO_STILLPICTURE,
1408 struct video_still_picture *sp)
1410 Arguments
1411 ~~~~~~~~~
1413 .. flat-table::
1414 :header-rows: 0
1415 :stub-columns: 0
1417 - ..
1419 - ``int fd``
1421 - :cspan:`1` File descriptor returned by a previous call
1422 to `open()`_.
1424 - ..
1426 - ``int request``
1428 - Equals ``VIDEO_STILLPICTURE`` for this command.
1430 - ..
1432 - ``struct`` `video_still_picture`_ ``*sp``
1434 - Pointer to the location where the struct with the I-frame
1435 and size is stored.
1437 Description
1438 ~~~~~~~~~~~
1440 .. attention:: Do **not** use in new drivers!
1441 See: :ref:`legacy_dvb_decoder_notes`
1443 This ioctl call asks the Video Device to display a still picture
1444 (I-frame). The input data shall be the section of an elementary video
1445 stream containing an I-frame. Typically this section is extracted from a
1446 TS or PES recording. Resolution and codec (see `video capabilities`_) must
1447 be supported by the device. If the pointer is NULL, then the current
1448 displayed still picture is blanked.
1450 e.g. The AV7110 supports MPEG1 and MPEG2 with the common PAL-SD
1451 resolutions.
1453 Return Value
1454 ~~~~~~~~~~~~
1456 On success 0 is returned, on error -1 and the ``errno`` variable is set
1457 appropriately. The generic error codes are described at the
1458 :ref:`Generic Error Codes <gen-errors>` chapter.
1461 -----
1464 VIDEO_FAST_FORWARD
1465 ------------------
1467 Synopsis
1468 ~~~~~~~~
1470 .. c:macro:: VIDEO_FAST_FORWARD
1472 .. code-block:: c
1474 int ioctl(fd, int request = VIDEO_FAST_FORWARD, int nFrames)
1476 Arguments
1477 ~~~~~~~~~
1479 .. flat-table::
1480 :header-rows: 0
1481 :stub-columns: 0
1483 - ..
1485 - ``int fd``
1487 - :cspan:`1` File descriptor returned by a previous call
1488 to `open()`_.
1490 - ..
1492 - ``int request``
1494 - Equals ``VIDEO_FAST_FORWARD`` for this command.
1496 - ..
1498 - ``int nFrames``
1500 - The number of frames to skip.
1502 Description
1503 ~~~~~~~~~~~
1505 .. attention:: Do **not** use in new drivers!
1506 See: :ref:`legacy_dvb_decoder_notes`
1508 This ioctl call asks the Video Device to skip decoding of N number of
1509 I-frames. This call can only be used if ``VIDEO_SOURCE_MEMORY`` is
1510 selected.
1512 Return Value
1513 ~~~~~~~~~~~~
1515 On success 0 is returned, on error -1 and the ``errno`` variable is set
1516 appropriately. The generic error codes are described at the
1517 :ref:`Generic Error Codes <gen-errors>` chapter.
1519 .. flat-table::
1520 :header-rows: 0
1521 :stub-columns: 0
1523 - ..
1525 - ``EPERM``
1527 - Mode ``VIDEO_SOURCE_MEMORY`` not selected.
1530 -----
1533 VIDEO_SLOWMOTION
1534 ----------------
1536 Synopsis
1537 ~~~~~~~~
1539 .. c:macro:: VIDEO_SLOWMOTION
1541 .. code-block:: c
1543 int ioctl(fd, int request = VIDEO_SLOWMOTION, int nFrames)
1545 Arguments
1546 ~~~~~~~~~
1548 .. flat-table::
1549 :header-rows: 0
1550 :stub-columns: 0
1552 - ..
1554 - ``int fd``
1556 - :cspan:`1` File descriptor returned by a previous call
1557 to `open()`_.
1559 - ..
1561 - ``int request``
1563 - Equals ``VIDEO_SLOWMOTION`` for this command.
1565 - ..
1567 - ``int nFrames``
1569 - The number of times to repeat each frame.
1571 Description
1572 ~~~~~~~~~~~
1574 .. attention:: Do **not** use in new drivers!
1575 See: :ref:`legacy_dvb_decoder_notes`
1577 This ioctl call asks the video device to repeat decoding frames N number
1578 of times. This call can only be used if ``VIDEO_SOURCE_MEMORY`` is
1579 selected.
1581 Return Value
1582 ~~~~~~~~~~~~
1584 On success 0 is returned, on error -1 and the ``errno`` variable is set
1585 appropriately. The generic error codes are described at the
1586 :ref:`Generic Error Codes <gen-errors>` chapter.
1588 .. flat-table::
1589 :header-rows: 0
1590 :stub-columns: 0
1592 - ..
1594 - ``EPERM``
1596 - Mode ``VIDEO_SOURCE_MEMORY`` not selected.
1599 -----
1602 VIDEO_GET_CAPABILITIES
1603 ----------------------
1605 Synopsis
1606 ~~~~~~~~
1608 .. c:macro:: VIDEO_GET_CAPABILITIES
1610 .. code-block:: c
1612 int ioctl(fd, int request = VIDEO_GET_CAPABILITIES, unsigned int *cap)
1614 Arguments
1615 ~~~~~~~~~
1617 .. flat-table::
1618 :header-rows: 0
1619 :stub-columns: 0
1621 - ..
1623 - ``int fd``
1625 - :cspan:`1` File descriptor returned by a previous call
1626 to `open()`_.
1628 - ..
1630 - ``int request``
1632 - Equals ``VIDEO_GET_CAPABILITIES`` for this command.
1634 - ..
1636 - ``unsigned int *cap``
1638 - Pointer to a location where to store the capability information.
1640 Description
1641 ~~~~~~~~~~~
1643 .. attention:: Do **not** use in new drivers!
1644 See: :ref:`legacy_dvb_decoder_notes`
1646 This ioctl call asks the video device about its decoding capabilities.
1647 On success it returns an integer which has bits set according to the
1648 defines in `video capabilities`_.
1650 Return Value
1651 ~~~~~~~~~~~~
1653 On success 0 is returned, on error -1 and the ``errno`` variable is set
1654 appropriately. The generic error codes are described at the
1655 :ref:`Generic Error Codes <gen-errors>` chapter.
1658 -----
1661 VIDEO_CLEAR_BUFFER
1662 ------------------
1664 Synopsis
1665 ~~~~~~~~
1667 .. c:macro:: VIDEO_CLEAR_BUFFER
1669 .. code-block:: c
1671 int ioctl(fd, int request = VIDEO_CLEAR_BUFFER)
1673 Arguments
1674 ~~~~~~~~~
1676 .. flat-table::
1677 :header-rows: 0
1678 :stub-columns: 0
1680 - ..
1682 - ``int fd``
1684 - :cspan:`1` File descriptor returned by a previous call
1685 to `open()`_.
1687 - ..
1689 - ``int request``
1691 - Equals ``VIDEO_CLEAR_BUFFER`` for this command.
1693 Description
1694 ~~~~~~~~~~~
1696 .. attention:: Do **not** use in new drivers!
1697 See: :ref:`legacy_dvb_decoder_notes`
1699 This ioctl call clears all video buffers in the driver and in the
1700 decoder hardware.
1702 Return Value
1703 ~~~~~~~~~~~~
1705 On success 0 is returned, on error -1 and the ``errno`` variable is set
1706 appropriately. The generic error codes are described at the
1707 :ref:`Generic Error Codes <gen-errors>` chapter.
1710 -----
1713 VIDEO_SET_STREAMTYPE
1714 --------------------
1716 Synopsis
1717 ~~~~~~~~
1719 .. c:macro:: VIDEO_SET_STREAMTYPE
1721 .. code-block:: c
1723 int ioctl(fd, int request = VIDEO_SET_STREAMTYPE, int type)
1725 Arguments
1726 ~~~~~~~~~
1728 .. flat-table::
1729 :header-rows: 0
1730 :stub-columns: 0
1732 - ..
1734 - ``int fd``
1736 - :cspan:`1` File descriptor returned by a previous call
1737 to `open()`_.
1739 - ..
1741 - ``int request``
1743 - Equals ``VIDEO_SET_STREAMTYPE`` for this command.
1745 - ..
1747 - ``int type``
1749 - Stream type.
1751 Description
1752 ~~~~~~~~~~~
1754 .. attention:: Do **not** use in new drivers!
1755 See: :ref:`legacy_dvb_decoder_notes`
1757 This ioctl tells the driver which kind of stream to expect being written
1758 to it.
1759 Intelligent decoder might also not support or ignore (like the AV7110)
1760 this call and determine the stream type themselves.
1762 Currently used stream types:
1764 .. flat-table::
1765 :header-rows: 1
1766 :stub-columns: 0
1768 - ..
1770 - Codec
1772 - Stream type
1774 - ..
1776 - MPEG2
1778 - 0
1780 - ..
1782 - MPEG4 h.264
1784 - 1
1786 - ..
1788 - VC1
1790 - 3
1792 - ..
1794 - MPEG4 Part2
1796 - 4
1798 - ..
1800 - VC1 SM
1802 - 5
1804 - ..
1806 - MPEG1
1808 - 6
1810 - ..
1812 - HEVC h.265
1814 - | 7
1815 | DREAMBOX: 22
1817 - ..
1819 - AVS
1821 - 16
1823 - ..
1825 - AVS2
1827 - 40
1829 Not every decoder supports all stream types.
1831 Return Value
1832 ~~~~~~~~~~~~
1834 On success 0 is returned, on error -1 and the ``errno`` variable is set
1835 appropriately. The generic error codes are described at the
1836 :ref:`Generic Error Codes <gen-errors>` chapter.
1839 -----
1842 VIDEO_SET_FORMAT
1843 ----------------
1845 Synopsis
1846 ~~~~~~~~
1848 .. c:macro:: VIDEO_SET_FORMAT
1850 .. code-block:: c
1852 int ioctl(fd, int request = VIDEO_SET_FORMAT, video_format_t format)
1854 Arguments
1855 ~~~~~~~~~
1857 .. flat-table::
1858 :header-rows: 0
1859 :stub-columns: 0
1861 - ..
1863 - ``int fd``
1865 - :cspan:`1` File descriptor returned by a previous call
1866 to `open()`_.
1868 - ..
1870 - ``int request``
1872 - Equals ``VIDEO_SET_FORMAT`` for this command.
1874 - ..
1876 - `video_format_t`_ ``format``
1878 - Video format of TV as defined in section `video_format_t`_.
1880 Description
1881 ~~~~~~~~~~~
1883 .. attention:: Do **not** use in new drivers!
1884 See: :ref:`legacy_dvb_decoder_notes`
1886 This ioctl sets the screen format (aspect ratio) of the connected output
1887 device (TV) so that the output of the decoder can be adjusted
1888 accordingly.
1890 Return Value
1891 ~~~~~~~~~~~~
1893 On success 0 is returned, on error -1 and the ``errno`` variable is set
1894 appropriately. The generic error codes are described at the
1895 :ref:`Generic Error Codes <gen-errors>` chapter.
1898 -----
1901 VIDEO_GET_SIZE
1902 --------------
1904 Synopsis
1905 ~~~~~~~~
1907 .. c:macro:: VIDEO_GET_SIZE
1909 .. code-block:: c
1911 int ioctl(int fd, int request = VIDEO_GET_SIZE, video_size_t *size)
1913 Arguments
1914 ~~~~~~~~~
1916 .. flat-table::
1917 :header-rows: 0
1918 :stub-columns: 0
1920 - ..
1922 - ``int fd``
1924 - :cspan:`1` File descriptor returned by a previous call,
1925 to `open()`_.
1927 - ..
1929 - ``int request``
1931 - Equals ``VIDEO_GET_SIZE`` for this command.
1933 - ..
1935 - `video_size_t`_ ``*size``
1937 - Returns the size and aspect ratio.
1939 Description
1940 ~~~~~~~~~~~
1942 .. attention:: Do **not** use in new drivers!
1943 See: :ref:`legacy_dvb_decoder_notes`
1945 This ioctl returns the size and aspect ratio.
1947 Return Value
1948 ~~~~~~~~~~~~
1950 On success 0 is returned, on error -1 and the ``errno`` variable is set
1951 appropriately. The generic error codes are described at the
1952 :ref:`Generic Error Codes <gen-errors>` chapter.
1955 -----
1958 VIDEO_GET_PTS
1959 -------------
1961 Synopsis
1962 ~~~~~~~~
1964 .. c:macro:: VIDEO_GET_PTS
1966 .. code-block:: c
1968 int ioctl(int fd, int request = VIDEO_GET_PTS, __u64 *pts)
1970 Arguments
1971 ~~~~~~~~~
1973 .. flat-table::
1974 :header-rows: 0
1975 :stub-columns: 0
1977 - ..
1979 - ``int fd``
1981 - :cspan:`1` File descriptor returned by a previous call
1982 to `open()`_.
1984 - ..
1986 - ``int request``
1988 - Equals ``VIDEO_GET_PTS`` for this command.
1990 - ..
1992 - ``__u64 *pts``
1994 - Returns the 33-bit timestamp as defined in ITU T-REC-H.222.0 /
1995 ISO/IEC 13818-1.
1997 The PTS should belong to the currently played frame if possible,
1998 but may also be a value close to it like the PTS of the last
1999 decoded frame or the last PTS extracted by the PES parser.
2001 Description
2002 ~~~~~~~~~~~
2004 .. attention:: Do **not** use in new drivers!
2005 See: :ref:`legacy_dvb_decoder_notes`
2007 For V4L2 decoders this ioctl has been replaced by the
2008 ``V4L2_CID_MPEG_VIDEO_DEC_PTS`` control.
2010 This ioctl call asks the Video Device to return the current PTS
2011 timestamp.
2013 Return Value
2014 ~~~~~~~~~~~~
2016 On success 0 is returned, on error -1 and the ``errno`` variable is set
2017 appropriately. The generic error codes are described at the
2018 :ref:`Generic Error Codes <gen-errors>` chapter.
2021 -----
2024 VIDEO_GET_FRAME_COUNT
2025 ---------------------
2027 Synopsis
2028 ~~~~~~~~
2030 .. c:macro:: VIDEO_GET_FRAME_COUNT
2032 .. code-block:: c
2034 int ioctl(int fd, VIDEO_GET_FRAME_COUNT, __u64 *pts)
2036 Arguments
2037 ~~~~~~~~~
2039 .. flat-table::
2040 :header-rows: 0
2041 :stub-columns: 0
2043 - ..
2045 - ``int fd``
2047 - :cspan:`1` File descriptor returned by a previous call
2048 to `open()`_.
2050 - ..
2052 - ``int request``
2054 - Equals ``VIDEO_GET_FRAME_COUNT`` for this command.
2056 - ..
2058 - ``__u64 *pts``
2060 - Returns the number of frames displayed since the decoder was
2061 started.
2063 Description
2064 ~~~~~~~~~~~
2066 .. attention:: Do **not** use in new drivers!
2067 See: :ref:`legacy_dvb_decoder_notes`
2069 For V4L2 decoders this ioctl has been replaced by the
2070 ``V4L2_CID_MPEG_VIDEO_DEC_FRAME`` control.
2072 This ioctl call asks the Video Device to return the number of displayed
2073 frames since the decoder was started.
2075 Return Value
2076 ~~~~~~~~~~~~
2078 On success 0 is returned, on error -1 and the ``errno`` variable is set
2079 appropriately. The generic error codes are described at the
2080 :ref:`Generic Error Codes <gen-errors>` chapter.
2083 -----
2086 VIDEO_COMMAND
2087 -------------
2089 Synopsis
2090 ~~~~~~~~
2092 .. c:macro:: VIDEO_COMMAND
2094 .. code-block:: c
2096 int ioctl(int fd, int request = VIDEO_COMMAND,
2097 struct video_command *cmd)
2099 Arguments
2100 ~~~~~~~~~
2102 .. flat-table::
2103 :header-rows: 0
2104 :stub-columns: 0
2106 - ..
2108 - ``int fd``
2110 - :cspan:`1` File descriptor returned by a previous call
2111 to `open()`_.
2113 - ..
2115 - ``int request``
2117 - Equals ``VIDEO_COMMAND`` for this command.
2119 - ..
2121 - `struct video_command`_ ``*cmd``
2123 - Commands the decoder.
2125 Description
2126 ~~~~~~~~~~~
2128 .. attention:: Do **not** use in new drivers!
2129 See: :ref:`legacy_dvb_decoder_notes`
2131 For V4L2 decoders this ioctl has been replaced by the
2132 :ref:`VIDIOC_DECODER_CMD` ioctl.
2134 This ioctl commands the decoder. The `struct video_command`_ is a
2135 subset of the ``v4l2_decoder_cmd`` struct, so refer to the
2136 :ref:`VIDIOC_DECODER_CMD` documentation for
2137 more information.
2139 Return Value
2140 ~~~~~~~~~~~~
2142 On success 0 is returned, on error -1 and the ``errno`` variable is set
2143 appropriately. The generic error codes are described at the
2144 :ref:`Generic Error Codes <gen-errors>` chapter.
2147 -----
2150 VIDEO_TRY_COMMAND
2151 -----------------
2153 Synopsis
2154 ~~~~~~~~
2156 .. c:macro:: VIDEO_TRY_COMMAND
2158 .. code-block:: c
2160 int ioctl(int fd, int request = VIDEO_TRY_COMMAND,
2161 struct video_command *cmd)
2163 Arguments
2164 ~~~~~~~~~
2166 .. flat-table::
2167 :header-rows: 0
2168 :stub-columns: 0
2170 - ..
2172 - ``int fd``
2174 - :cspan:`1` File descriptor returned by a previous call
2175 to `open()`_.
2177 - ..
2179 - ``int request``
2181 - Equals ``VIDEO_TRY_COMMAND`` for this command.
2183 - ..
2185 - `struct video_command`_ ``*cmd``
2187 - Try a decoder command.
2189 Description
2190 ~~~~~~~~~~~
2192 .. attention:: Do **not** use in new drivers!
2193 See: :ref:`legacy_dvb_decoder_notes`
2195 For V4L2 decoders this ioctl has been replaced by the
2196 :ref:`VIDIOC_TRY_DECODER_CMD <VIDIOC_DECODER_CMD>` ioctl.
2198 This ioctl tries a decoder command. The `struct video_command`_ is a
2199 subset of the ``v4l2_decoder_cmd`` struct, so refer to the
2200 :ref:`VIDIOC_TRY_DECODER_CMD <VIDIOC_DECODER_CMD>` documentation
2201 for more information.
2203 Return Value
2204 ~~~~~~~~~~~~
2206 On success 0 is returned, on error -1 and the ``errno`` variable is set
2207 appropriately. The generic error codes are described at the
2208 :ref:`Generic Error Codes <gen-errors>` chapter.
2211 -----
2214 open()
2215 ------
2217 Synopsis
2218 ~~~~~~~~
2220 .. code-block:: c
2222 #include <fcntl.h>
2224 .. c:function:: int open(const char *deviceName, int flags)
2226 Arguments
2227 ~~~~~~~~~
2229 .. flat-table::
2230 :header-rows: 0
2231 :stub-columns: 0
2233 - ..
2235 - ``const char *deviceName``
2237 - Name of specific video device.
2239 - ..
2241 - :rspan:`3` ``int flags``
2243 - :cspan:`1` A bit-wise OR of the following flags:
2245 - ..
2247 - ``O_RDONLY``
2249 - read-only access
2251 - ..
2253 - ``O_RDWR``
2255 - read/write access
2257 - ..
2259 - ``O_NONBLOCK``
2260 - | Open in non-blocking mode
2261 | (blocking mode is the default)
2263 Description
2264 ~~~~~~~~~~~
2266 This system call opens a named video device (e.g.
2267 /dev/dvb/adapter?/video?) for subsequent use.
2269 When an open() call has succeeded, the device will be ready for use. The
2270 significance of blocking or non-blocking mode is described in the
2271 documentation for functions where there is a difference. It does not
2272 affect the semantics of the open() call itself. A device opened in
2273 blocking mode can later be put into non-blocking mode (and vice versa)
2274 using the F_SETFL command of the fcntl system call. This is a standard
2275 system call, documented in the Linux manual page for fcntl. Only one
2276 user can open the Video Device in O_RDWR mode. All other attempts to
2277 open the device in this mode will fail, and an error-code will be
2278 returned. If the Video Device is opened in O_RDONLY mode, the only
2279 ioctl call that can be used is `VIDEO_GET_STATUS`_. All other call will
2280 return an error code.
2282 Return Value
2283 ~~~~~~~~~~~~
2285 .. flat-table::
2286 :header-rows: 0
2287 :stub-columns: 0
2289 - ..
2291 - ``ENODEV``
2293 - :cspan:`1` Device driver not loaded/available.
2295 - ..
2297 - ``EINTERNAL``
2299 - Internal error.
2301 - ..
2303 - ``EBUSY``
2305 - Device or resource busy.
2307 - ..
2309 - ``EINVAL``
2311 - Invalid argument.
2314 -----
2317 close()
2318 -------
2320 Synopsis
2321 ~~~~~~~~
2323 .. c:function:: int close(int fd)
2325 Arguments
2326 ~~~~~~~~~
2328 .. flat-table::
2329 :header-rows: 0
2330 :stub-columns: 0
2332 - ..
2334 - ``int fd``
2336 - :cspan:`1` File descriptor returned by a previous call
2337 to `open()`_.
2339 Description
2340 ~~~~~~~~~~~
2342 This system call closes a previously opened video device.
2344 Return Value
2345 ~~~~~~~~~~~~
2347 .. flat-table::
2348 :header-rows: 0
2349 :stub-columns: 0
2351 - ..
2353 - ``EBADF``
2355 - fd is not a valid open file descriptor.
2358 -----
2361 write()
2362 -------
2364 Synopsis
2365 ~~~~~~~~
2367 .. c:function:: size_t write(int fd, const void *buf, size_t count)
2369 Arguments
2370 ~~~~~~~~~
2372 .. flat-table::
2373 :header-rows: 0
2374 :stub-columns: 0
2376 - ..
2378 - ``int fd``
2380 - :cspan:`1` File descriptor returned by a previous call
2381 to `open()`_.
2383 - ..
2385 - ``void *buf``
2387 - Pointer to the buffer containing the PES data.
2389 - ..
2391 - ``size_t count``
2393 - Size of buf.
2395 Description
2396 ~~~~~~~~~~~
2398 This system call can only be used if VIDEO_SOURCE_MEMORY is selected
2399 in the ioctl call `VIDEO_SELECT_SOURCE`_. The data provided shall be in
2400 PES format, unless the capability allows other formats. TS is the
2401 most common format for storing DVB-data, it is usually supported too.
2402 If O_NONBLOCK is not specified the function will block until buffer space
2403 is available. The amount of data to be transferred is implied by count.
2405 .. note:: See: :ref:`DVB Data Formats <legacy_dvb_decoder_formats>`
2407 Return Value
2408 ~~~~~~~~~~~~
2410 .. flat-table::
2411 :header-rows: 0
2412 :stub-columns: 0
2414 - ..
2416 - ``EPERM``
2418 - :cspan:`1` Mode ``VIDEO_SOURCE_MEMORY`` not selected.
2420 - ..
2422 - ``ENOMEM``
2424 - Attempted to write more data than the internal buffer can hold.
2426 - ..
2428 - ``EBADF``
2430 - fd is not a valid open file descriptor.

3. 한국어 전문 번역

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

MPEG-2 decoder 장치와 V4L2 대체

1-38

DVB video device는 DVB 하드웨어의 MPEG-2 video decoder를 제어합니다. `/dev/dvb/adapter0/video0`로 접근하고 응용 프로그램에서 `linux/dvb/video.h`를 포함해 data type과 ioctl 정의를 사용합니다.

이 장치는 MPEG video stream의 decoding만 제어하며 TV나 computer screen에 표시하는 방식은 제어하지 않습니다. PC에서는 보통 `/dev/video` 같은 연결된 Video4Linux 장치가 scaling과 output window를 담당합니다.

대부분의 DVB card에는 자체 MPEG decoder가 없어 audio·video·Video4Linux device node가 생략됩니다. 이 ioctl의 V4L2 decoder 제어 용도도 폐기됐으므로 새 driver는 V4L2 ioctl/control을 사용해야 합니다.

Legacy video data path
Demux 또는 write()가 MPEG stream 공급DVB video device가 MPEG stream decoding연결된 Video4Linux 장치가 scaling과 output window 설정TV 또는 computer screen에 frame 표시

Decoder 제어와 화면 표시가 분리되는 구조입니다.

.. SPDX-License-Identifier: GFDL-1.1-no-invariants-or-later OR GPL-2.0

.. c:namespace:: dtv.legacy.video

.. _dvb_video:

================
DVB Video Device
================

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

The DVB video device controls the MPEG2 video decoder of the DVB
hardware. It can be accessed through ``/dev/dvb/adapter0/video0``. Data
types and ioctl definitions can be accessed by including
``linux/dvb/video.h`` in your application.

Note that the DVB video device only controls decoding of the MPEG video
stream, not its presentation on the TV or computer screen. On PCs this
is typically handled by an associated video4linux device, e.g.
``/dev/video``, which allows scaling and defining output windows.

Most DVB cards don’t have their own MPEG decoder, which results in the
omission of the audio and video device as well as the video4linux
device.

These ioctls were also used by V4L2 to control MPEG decoders implemented
in V4L2. The use of these ioctls for that purpose has been made obsolete
and proper V4L2 ioctls or controls have been created to replace that
functionality. Use :ref:`V4L2 ioctls<video>` for new drivers!


Video Data Types
================


video_format_t aspect ratio

39-91

`video_format_t`는 output hardware의 aspect ratio를 driver에 알리거나 현재 stream의 display format을 보고할 때 사용합니다. `VIDEO_SET_FORMAT`, `video_status`, `video_event`가 이 type을 사용합니다.

video_format_t 상수
상수화면비
VIDEO_FORMAT_4_34:3
VIDEO_FORMAT_16_916:9
VIDEO_FORMAT_221_12.21:1

연결된 display 또는 stream의 화면비입니다.

video_format_t
--------------

Synopsis
~~~~~~~~

.. code-block:: c

    typedef enum {
	VIDEO_FORMAT_4_3,
	VIDEO_FORMAT_16_9,
	VIDEO_FORMAT_221_1
    } video_format_t;

Constants
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``VIDEO_FORMAT_4_3``

       -  Select 4:3 format.

    -  ..

       -  ``VIDEO_FORMAT_16_9``

       -  Select 16:9 format.

    -  ..

       -  ``VIDEO_FORMAT_221_1``

       -  Select 2.21:1 format.

Description
~~~~~~~~~~~

The ``video_format_t`` data type
is used in the `VIDEO_SET_FORMAT`_ function to tell the driver which
aspect ratio the output hardware (e.g. TV) has. It is also used in the
data structures `video_status`_ returned by `VIDEO_GET_STATUS`_
and `video_event`_ returned by `VIDEO_GET_EVENT`_ which report
about the display format of the current video stream.


-----

video_displayformat_t cropping mode

92-142

Video stream과 display hardware의 화면비가 다르면 응용 프로그램이 picture를 자르는 방식을 `VIDEO_SET_DISPLAY_FORMAT`으로 지정합니다.

video_displayformat_t 상수
상수표시 방식
VIDEO_PAN_SCANPan-and-scan
VIDEO_LETTER_BOXLetterbox
VIDEO_CENTER_CUT_OUTCenter cut-out

서로 다른 화면비를 맞추는 표시 방식입니다.

video_displayformat_t
---------------------

Synopsis
~~~~~~~~

.. code-block:: c

    typedef enum {
	VIDEO_PAN_SCAN,
	VIDEO_LETTER_BOX,
	VIDEO_CENTER_CUT_OUT
    } video_displayformat_t;

Constants
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``VIDEO_PAN_SCAN``

       -  Use pan and scan format.

    -  ..

       -  ``VIDEO_LETTER_BOX``

       -  Use letterbox format.

    -  ..

       -  ``VIDEO_CENTER_CUT_OUT``

       -  Use center cut out format.

Description
~~~~~~~~~~~

In case the display format of the video stream and of the display
hardware differ the application has to specify how to handle the
cropping of the picture. This can be done using the
`VIDEO_SET_DISPLAY_FORMAT`_ call which accepts this enum as argument.


-----

video_size_t 해상도

143-191

`video_size_t`는 `video_event`에서 video의 해상도와 aspect ratio를 전달합니다.

video_size_t 멤버
멤버의미
int wvideo width, pixel 단위
int hvideo height, pixel 단위
video_format_t aspect_ratioaspect ratio

Pixel 크기와 화면비를 함께 저장합니다.

video_size_t
------------

Synopsis
~~~~~~~~

.. code-block:: c

    typedef struct {
	int w;
	int h;
	video_format_t aspect_ratio;
    } video_size_t;

Variables
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int w``

       -  Video width in pixels.

    -  ..

       -  ``int h``

       -  Video height in pixels.

    -  ..

       -  `video_format_t`_ ``aspect_ratio``

       -  Aspect ratio.

Description
~~~~~~~~~~~

Used in the struct `video_event`_. It stores the resolution and
aspect ratio of the video.


-----

video_stream_source_t 입력원

192-240

`video_stream_source_t`는 `VIDEO_SELECT_SOURCE`가 내부 demux와 응용 프로그램의 `write()` memory source 중 어디에서 stream을 받을지 지정합니다.

video_stream_source_t 상수
상수입력 경로
VIDEO_SOURCE_DEMUXfrontend 또는 DVR에서 공급받는 demultiplexer
VIDEO_SOURCE_MEMORY응용 프로그램이 `write()`로 공급하는 stream

Decoder 입력 경로입니다.

video_stream_source_t
---------------------

Synopsis
~~~~~~~~

.. code-block:: c

    typedef enum {
	VIDEO_SOURCE_DEMUX,
	VIDEO_SOURCE_MEMORY
    } video_stream_source_t;

Constants
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``VIDEO_SOURCE_DEMUX``

       -  :cspan:`1` Select the demux as the main source.

    -  ..

       -  ``VIDEO_SOURCE_MEMORY``

       -  If this source is selected, the stream
          comes from the user through the write
          system call.

Description
~~~~~~~~~~~

The video stream source is set through the `VIDEO_SELECT_SOURCE`_ call
and can take the following values, depending on whether we are replaying
from an internal (demuxer) or external (user write) source.
VIDEO_SOURCE_DEMUX selects the demultiplexer (fed either by the
frontend or the DVR device) as the source of the video stream. If
VIDEO_SOURCE_MEMORY is selected the stream comes from the application
through the `write()`_ system call.


-----

video_play_state_t 재생 상태

241-289

`video_play_state_t`는 `VIDEO_GET_STATUS`가 반환하는 video 재생 상태입니다.

video_play_state_t 상수
상수상태
VIDEO_STOPPEDVideo 정지
VIDEO_PLAYINGVideo 재생 중
VIDEO_FREEZEDVideo freeze 상태

정지, 재생, freeze 상태입니다.

video_play_state_t
------------------

Synopsis
~~~~~~~~

.. code-block:: c

    typedef enum {
	VIDEO_STOPPED,
	VIDEO_PLAYING,
	VIDEO_FREEZED
    } video_play_state_t;

Constants
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``VIDEO_STOPPED``

       -  Video is stopped.

    -  ..

       -  ``VIDEO_PLAYING``

       -  Video is currently playing.

    -  ..

       -  ``VIDEO_FREEZED``

       -  Video is frozen.

Description
~~~~~~~~~~~

This values can be returned by the `VIDEO_GET_STATUS`_ call
representing the state of video playback.


-----

struct video_command

290-390

`struct video_command`는 decoder command, flag와 command별 union payload를 담습니다. 미래 확장과 호환되도록 응용 프로그램은 사용 전에 구조체 전체를 0으로 초기화해야 합니다.

video_command 멤버
멤버/값의미
__u32 cmddecoder command
__u32 flagscommand별 flag
stop.pts정지 command의 MPEG PTS
play.speed = 0 또는 1000normal speed
play.speed = 1 / -1forward / backward single step
play.speed > 1normal speed의 speed/1000 배로 순방향 재생
play.speed < -1normal speed의 -speed/1000 배로 역방향 재생
play.formatplay input format
raw.data[16]향후 확장용 reserved data

stop, play 또는 raw payload 중 하나를 사용합니다.

struct video_command
--------------------

Synopsis
~~~~~~~~

.. code-block:: c

    struct video_command {
	__u32 cmd;
	__u32 flags;
	union {
	    struct {
		__u64 pts;
	    } stop;

	    struct {
		__s32 speed;
		__u32 format;
	    } play;

	    struct {
		__u32 data[16];
	    } raw;
	};
    };


Variables
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``__u32 cmd``

       -  `Decoder command`_

    -  ..

       -  ``__u32 flags``

       -  Flags for the `Decoder command`_.

    -  ..

       -  ``struct stop``

       -  ``__u64 pts``

       -  MPEG PTS

    -  ..

       -  :rspan:`5` ``stuct play``

       -  :rspan:`4` ``__s32 speed``

       -   0 or 1000 specifies normal speed,

    -  ..

       -   1:  specifies forward single stepping,

    -  ..

       -   -1: specifies backward single stepping,

    -  ..

       -   >1: playback at speed / 1000 of the normal speed

    -  ..

       -   <-1: reverse playback at ( -speed / 1000 ) of the normal speed.

    -  ..

       -  ``__u32 format``

       -  `Play input formats`_

    -  ..

       -  ``__u32 data[16]``

       -  Reserved

Description
~~~~~~~~~~~

The structure must be zeroed before use by the application. This ensures
it can be extended safely in the future.


-----

Decoder command, flag와 field order

391-517
Predefined decoder command
상수동작
VIDEO_CMD_PLAY재생 시작
VIDEO_CMD_STOP재생 정지
VIDEO_CMD_FREEZE재생 freeze
VIDEO_CMD_CONTINUEfreeze 뒤 재생 계속

`video_command.cmd`에 지정하는 기본 동작입니다.

Decoder command flag와 input format
상수의미
VIDEO_CMD_FREEZE_TO_BLACKfreeze 시 검은 화면 표시
VIDEO_CMD_STOP_TO_BLACKstop 시 검은 화면 표시
VIDEO_CMD_STOP_IMMEDIATELYbuffer를 비우지 않고 즉시 stop
VIDEO_PLAY_FMT_NONEdecoder에 특별한 input format 요구가 없음
VIDEO_PLAY_FMT_GOPdecoder가 완전한 GOP를 요구

Freeze·stop 화면 처리와 play data 요구 형식입니다.

Vsync field order
상수field
VIDEO_VSYNC_FIELD_UNKNOWNodd, even, progressive 여부를 hardware가 모름
VIDEO_VSYNC_FIELD_ODDodd field
VIDEO_VSYNC_FIELD_EVENeven field
VIDEO_VSYNC_FIELD_PROGRESSIVEprogressive, non-interlaced

Vsync가 어느 field에 해당하는지 나타냅니다.

Predefined decoder commands and flags
-------------------------------------

Synopsis
~~~~~~~~

.. code-block:: c

    #define VIDEO_CMD_PLAY                      (0)
    #define VIDEO_CMD_STOP                      (1)
    #define VIDEO_CMD_FREEZE                    (2)
    #define VIDEO_CMD_CONTINUE                  (3)

    #define VIDEO_CMD_FREEZE_TO_BLACK      (1 << 0)

    #define VIDEO_CMD_STOP_TO_BLACK        (1 << 0)
    #define VIDEO_CMD_STOP_IMMEDIATELY     (1 << 1)

    #define VIDEO_PLAY_FMT_NONE                 (0)
    #define VIDEO_PLAY_FMT_GOP                  (1)

    #define VIDEO_VSYNC_FIELD_UNKNOWN           (0)
    #define VIDEO_VSYNC_FIELD_ODD               (1)
    #define VIDEO_VSYNC_FIELD_EVEN              (2)
    #define VIDEO_VSYNC_FIELD_PROGRESSIVE       (3)

Constants
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  :rspan:`3` _`Decoder command`

       -  ``VIDEO_CMD_PLAY``

       -  Start playback.

    -  ..

       -  ``VIDEO_CMD_STOP``

       -  Stop playback.

    -  ..

       -  ``VIDEO_CMD_FREEZE``

       -  Freeze playback.

    -  ..

       -  ``VIDEO_CMD_CONTINUE``

       -  Continue playback after freeze.

    -  ..

       -  Flags for ``VIDEO_CMD_FREEZE``

       -  ``VIDEO_CMD_FREEZE_TO_BLACK``

       -  Show black picture on freeze.

    -  ..

       -  :rspan:`1` Flags for ``VIDEO_CMD_STOP``

       -  ``VIDEO_CMD_STOP_TO_BLACK``

       -  Show black picture on stop.

    -  ..

       -  ``VIDEO_CMD_STOP_IMMEDIATELY``

       -  Stop immediately, without emptying buffers.

    -  ..

       -  :rspan:`1` _`Play input formats`

       -  ``VIDEO_PLAY_FMT_NONE``

       -  The decoder has no special format requirements

    -  ..

       -  ``VIDEO_PLAY_FMT_GOP``

       -  The decoder requires full GOPs

    -  ..

       -  :rspan:`3` Field order

       -  ``VIDEO_VSYNC_FIELD_UNKNOWN``

       -  FIELD_UNKNOWN can be used if the hardware does not know
          whether the Vsync is for an odd, even or progressive
          (i.e. non-interlaced) field.

    -  ..

       -  ``VIDEO_VSYNC_FIELD_ODD``

       -  Vsync is for an odd field.

    -  ..

       -  ``VIDEO_VSYNC_FIELD_EVEN``

       -  Vsync is for an even field.

    -  ..

       -  ``VIDEO_VSYNC_FIELD_PROGRESSIVE``

       -  progressive (i.e. non-interlaced)


-----

video_event 비동기 event

518-613

`VIDEO_GET_EVENT`는 `video_event` 구조체로 크기, frame rate, decoder 정지, Vsync event를 반환합니다.

video_event 멤버와 type
멤버/상수의미
VIDEO_EVENT_SIZE_CHANGED해상도 또는 aspect ratio 변경, `u.size` 사용
VIDEO_EVENT_FRAME_RATE_CHANGEDframe rate 변경, `u.frame_rate` 사용
VIDEO_EVENT_DECODER_STOPPEDdecoder 정지
VIDEO_EVENT_VSYNCVsync 발생, `u.vsync_field` 사용
long timestampevent 발생 시 MPEG PTS
video_size_t sizevideo 해상도와 aspect ratio
unsigned int frame_rate원문 표현으로 frames per 1000sec
unsigned char vsync_fieldunknown, odd, even 또는 progressive

Event 발생 시각은 MPEG PTS로 기록합니다.

video_event
-----------

Synopsis
~~~~~~~~

.. code-block:: c

    struct video_event {
	__s32 type;
    #define VIDEO_EVENT_SIZE_CHANGED        1
    #define VIDEO_EVENT_FRAME_RATE_CHANGED  2
    #define VIDEO_EVENT_DECODER_STOPPED     3
    #define VIDEO_EVENT_VSYNC               4
	long timestamp;
	union {
	    video_size_t size;
	    unsigned int frame_rate;
	    unsigned char vsync_field;
	} u;
    };

Variables
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  :rspan:`4` ``__s32 type``

       -  :cspan:`1` Event type.

    -  ..

       -  ``VIDEO_EVENT_SIZE_CHANGED``

       -  Size changed.

    -  ..

       -  ``VIDEO_EVENT_FRAME_RATE_CHANGED``

       -  Framerate changed.

    -  ..

       -  ``VIDEO_EVENT_DECODER_STOPPED``

       -  Decoder stopped.

    -  ..

       -  ``VIDEO_EVENT_VSYNC``

       -  Vsync occurred.

    -  ..

       -  ``long timestamp``

       -  :cspan:`1` MPEG PTS at occurrence.

    -  ..

       -  :rspan:`2` ``union u``

       -  `video_size_t`_ size

       -  Resolution and aspect ratio of the video.

    -  ..

       -  ``unsigned int frame_rate``

       -  in frames per 1000sec

    -  ..

       -  ``unsigned char vsync_field``

       -  | unknown / odd / even / progressive
          | See: `Predefined decoder commands and flags`_

Description
~~~~~~~~~~~

This is the structure of a video event as it is returned by the
`VIDEO_GET_EVENT`_ call. See there for more details.


-----

video_status 종합 상태

614-699

`VIDEO_GET_STATUS`는 blank 방식, 재생 상태, 입력원, stream aspect ratio, cropping mode를 `video_status`로 반환합니다.

video_status 멤버
멤버/값의미
video_blank != 0channel 변경 또는 stop/freeze 시 blank screen
video_blank == 0마지막으로 decode한 frame 표시
video_play_state_t play_statefrozen, stopped 또는 playing
video_stream_source_t stream_sourcedemux 또는 memory
video_format_t video_format현재 stream의 aspect ratio
video_displayformat_t display_formatoutput 화면비와 다를 때 적용한 cropping mode

현재 playback 동작과 화면 처리 상태입니다.

video_status
------------

Synopsis
~~~~~~~~

The `VIDEO_GET_STATUS`_ call returns the following structure informing
about various states of the playback operation.

.. code-block:: c

    struct video_status {
	int                    video_blank;
	video_play_state_t     play_state;
	video_stream_source_t  stream_source;
	video_format_t         video_format;
	video_displayformat_t  display_format;
    };

Variables
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  :rspan:`2` ``int video_blank``

       -  :cspan:`1` Show blank video on freeze?

    -  ..

       -  TRUE  ( != 0 )

       -  Blank screen when freeze.

    -  ..

       -  FALSE ( == 0 )

       -  Show last decoded frame.

    -  ..

       -  `video_play_state_t`_ ``play_state``

       -  Current state of playback.

    -  ..

       -  `video_stream_source_t`_ ``stream_source``

       -  Current source (demux/memory).

    -  ..

       -  `video_format_t`_ ``video_format``

       -  Current aspect ratio of stream.

    -  ..

       -  `video_displayformat_t`_ ``display_format``

       -  Applied cropping mode.

Description
~~~~~~~~~~~

If ``video_blank`` is set ``TRUE`` video will be blanked out if the
channel is changed or if playback is stopped. Otherwise, the last picture
will be displayed. ``play_state`` indicates if the video is currently
frozen, stopped, or being played back. The ``stream_source`` corresponds
to the selected source for the video stream. It can come either from the
demultiplexer or from memory. The ``video_format`` indicates the aspect
ratio (one of 4:3 or 16:9) of the currently played video stream.
Finally, ``display_format`` corresponds to the applied cropping mode in
case the source video format is not the same as the format of the output
device.


-----

video_still_picture I-frame

700-742

`video_still_picture`는 `VIDEO_STILLPICTURE`가 표시할 단일 I-frame의 memory pointer와 크기를 전달합니다.

video_still_picture 멤버
멤버의미
char *iFramememory의 단일 I-frame pointer
int32_t sizeI-frame byte 크기

Elementary stream에서 추출한 I-frame을 가리킵니다.

video_still_picture
-------------------

Synopsis
~~~~~~~~

.. code-block:: c

    struct video_still_picture {
    char *iFrame;
    int32_t size;
    };

Variables
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``char *iFrame``

       -  Pointer to a single iframe in memory.

    -  ..

       -  ``int32_t size``

       -  Size of the iframe.


Description
~~~~~~~~~~~

An I-frame displayed via the `VIDEO_STILLPICTURE`_ call is passed on
within this structure.


-----

Video capability bit

743-803

`VIDEO_GET_CAPABILITIES`는 hardware가 지원하는 codec과 stream container를 unsigned integer bit mask로 반환합니다.

Video capability bit
Bitcapability
VIDEO_CAP_MPEG1hardware가 MPEG-1 decoding 지원
VIDEO_CAP_MPEG2hardware가 MPEG-2 decoding 지원
VIDEO_CAP_SYSvideo device가 system stream 수용
VIDEO_CAP_PROGvideo device가 program stream 수용

System/program stream은 audio와 video device를 모두 열되 stream은 video device에만 보냅니다.

video capabilities
------------------

Synopsis
~~~~~~~~

.. code-block:: c

    #define VIDEO_CAP_MPEG1   1
    #define VIDEO_CAP_MPEG2   2
    #define VIDEO_CAP_SYS     4
    #define VIDEO_CAP_PROG    8

Constants
~~~~~~~~~
Bit definitions for capabilities:

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``VIDEO_CAP_MPEG1``

       -  :cspan:`1` The hardware can decode MPEG1.

    -  ..

       -  ``VIDEO_CAP_MPEG2``

       -  The hardware can decode MPEG2.

    -  ..

       -  ``VIDEO_CAP_SYS``

       -  The video device accepts system stream.

          You still have to open the video and the audio device
          but only send the stream to the video device.

    -  ..

       -  ``VIDEO_CAP_PROG``

       -  The video device accepts program stream.

          You still have to open the video and the audio device
          but only send the stream to the video device.

Description
~~~~~~~~~~~

A call to `VIDEO_GET_CAPABILITIES`_ returns an unsigned integer with the
following bits set according to the hardware's capabilities.


-----

VIDEO_STOP

804-881

`VIDEO_STOP`은 현재 stream 재생을 정지하고 `mode`에 따라 화면을 blank 처리하거나 마지막 decoded frame을 유지합니다. V4L2 decoder는 `VIDIOC_DECODER_CMD`를 사용합니다.

VIDEO_STOP 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_STOP`
mode != 0stop 시 blank screen
mode == 0마지막 decoded frame 표시

호출에 전달하거나 호출에서 돌려받는 값입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

Video Function Calls
====================


VIDEO_STOP
----------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_STOP

.. code-block:: c

	int ioctl(fd, VIDEO_STOP, int mode)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  :cspan:`1` Equals ``VIDEO_STOP`` for this command.

    -  ..

       -  :rspan:`2` ``int mode``

       -  :cspan:`1` Indicates how the screen shall be handled.

    -  ..

       -  TRUE  ( != 0 )

       -  Blank screen when stop.

    -  ..

       -  FALSE ( == 0 )

       -  Show last decoded frame.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl is for Digital TV devices only. To control a V4L2 decoder use
the V4L2 :ref:`VIDIOC_DECODER_CMD` instead.

This ioctl call asks the Video Device to stop playing the current
stream. Depending on the input parameter, the screen can be blanked out
or displaying the last decoded frame.

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.


-----

VIDEO_PLAY

882-936

`VIDEO_PLAY`는 선택한 source의 video stream 재생을 시작합니다. V4L2 decoder는 `VIDIOC_DECODER_CMD`를 사용합니다.

VIDEO_PLAY 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_PLAY`

호출에 전달하거나 호출에서 돌려받는 값입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_PLAY
----------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_PLAY

.. code-block:: c

	int ioctl(fd, VIDEO_PLAY)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_PLAY`` for this command.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl is for Digital TV devices only. To control a V4L2 decoder use
the V4L2 :ref:`VIDIOC_DECODER_CMD` instead.

This ioctl call asks the Video Device to start playing a video stream
from the selected source.

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.


-----

VIDEO_FREEZE

937-996

`VIDEO_FREEZE`는 재생 중인 live video를 freeze합니다. `VIDEO_SOURCE_DEMUX`에서는 decoding과 재생을 멈추고, `VIDEO_SOURCE_MEMORY`에서는 `VIDEO_CONTINUE` 또는 `VIDEO_PLAY`까지 더 이상 data를 decode하지 않습니다.

VIDEO_FREEZE 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_FREEZE`

호출에 전달하거나 호출에서 돌려받는 값입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_FREEZE
------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_FREEZE

.. code-block:: c

	int ioctl(fd, VIDEO_FREEZE)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_FREEZE`` for this command.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl is for Digital TV devices only. To control a V4L2 decoder use
the V4L2 :ref:`VIDIOC_DECODER_CMD` instead.

This ioctl call suspends the live video stream being played, if
VIDEO_SOURCE_DEMUX is selected. Decoding and playing are frozen.
It is then possible to restart the decoding and playing process of the
video stream using the `VIDEO_CONTINUE`_ command.
If VIDEO_SOURCE_MEMORY is selected in the ioctl call
`VIDEO_SELECT_SOURCE`_, the Digital TV subsystem will not decode any more
data until the ioctl call `VIDEO_CONTINUE`_ or `VIDEO_PLAY`_ is performed.

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.


-----

VIDEO_CONTINUE

997-1051

`VIDEO_CONTINUE`는 `VIDEO_FREEZE` 전의 video stream decoding과 재생을 다시 시작합니다.

VIDEO_CONTINUE 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_CONTINUE`

호출에 전달하거나 호출에서 돌려받는 값입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_CONTINUE
--------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_CONTINUE

.. code-block:: c

	int ioctl(fd, VIDEO_CONTINUE)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_CONTINUE`` for this command.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl is for Digital TV devices only. To control a V4L2 decoder use
the V4L2 :ref:`VIDIOC_DECODER_CMD` instead.

This ioctl call restarts decoding and playing processes of the video
stream which was played before a call to `VIDEO_FREEZE`_ was made.

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.


-----

VIDEO_SELECT_SOURCE

1052-1120

`VIDEO_SELECT_SOURCE`는 input data를 demux 또는 응용 프로그램 memory에서 받을지 지정합니다. ivtv의 V4L2 지원은 `IVTV_IOC_PASSTHROUGH_MODE`로 대체됐습니다.

VIDEO_SELECT_SOURCE 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_SELECT_SOURCE`
video_stream_source_t source`VIDEO_SOURCE_DEMUX` 또는 `VIDEO_SOURCE_MEMORY`

호출에 전달하거나 호출에서 돌려받는 값입니다.

Memory source는 `write()`로 공급하고 demux source는 onboard demux가 decoder로 직접 보냅니다. Decoder data는 PID filter의 제어도 받으며 demux output은 `DMX_OUT_DECODER`를 선택합니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_SELECT_SOURCE
-------------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_SELECT_SOURCE

.. code-block:: c

	int ioctl(fd, VIDEO_SELECT_SOURCE, video_stream_source_t source)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_SELECT_SOURCE`` for this command.

    -  ..

       -  `video_stream_source_t`_ ``source``

       -  Indicates which source shall be used for the Video stream.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl is for Digital TV devices only. This ioctl was also supported
by the V4L2 ivtv driver, but that has been replaced by the ivtv-specific
``IVTV_IOC_PASSTHROUGH_MODE`` ioctl.

This ioctl call informs the video device which source shall be used for
the input data. The possible sources are demux or memory. If memory is
selected, the data is fed to the video device through the write command
using the struct `video_stream_source_t`_. If demux is selected, the data
is directly transferred from the onboard demux-device to the decoder.

The data fed to the decoder is also controlled by the PID-filter.
Output selection: :c:type:`dmx_output` ``DMX_OUT_DECODER``.


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.


-----

VIDEO_SET_BLANK

1121-1189

`VIDEO_SET_BLANK`는 picture를 blank 처리할지 정합니다.

VIDEO_SET_BLANK 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_SET_BLANK`
mode != 0stop 시 blank screen
mode == 0마지막 decoded frame 표시

호출에 전달하거나 호출에서 돌려받는 값입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_SET_BLANK
---------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_SET_BLANK

.. code-block:: c

	int ioctl(fd, VIDEO_SET_BLANK, int mode)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  :cspan:`1` Equals ``VIDEO_SET_BLANK`` for this command.

    -  ..

       -  :rspan:`2` ``int mode``

       -  :cspan:`1` Indicates if the screen shall be blanked.

    -  ..

       -  TRUE  ( != 0 )

       -  Blank screen when stop.

    -  ..

       -  FALSE ( == 0 )

       -  Show last decoded frame.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl call asks the Video Device to blank out the picture.

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.


-----

VIDEO_GET_STATUS

1190-1248

`VIDEO_GET_STATUS`는 Video Device의 현재 상태를 `struct video_status`에 채워 반환합니다.

VIDEO_GET_STATUS 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_GET_STATUS`
struct video_status *status현재 상태를 받을 구조체 pointer

호출에 전달하거나 호출에서 돌려받는 값입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_GET_STATUS
----------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_GET_STATUS

.. code-block:: c

	int ioctl(fd, int request = VIDEO_GET_STATUS,
	struct video_status *status)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_GET_STATUS`` for this command.

    -  ..

       -  ``struct`` `video_status`_ ``*status``

       -  Returns the current status of the Video Device.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl call asks the Video Device to return the current status of
the device.

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.


-----

VIDEO_GET_EVENT

1249-1337

`VIDEO_GET_EVENT`는 대기 중인 `video_event`를 발생 순서대로 반환합니다. 제한된 최신 event만 queue에 남으므로 늦게 가져오면 오래된 event가 폐기될 수 있습니다.

VIDEO_GET_EVENT 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_GET_EVENT`
struct video_event *evevent를 저장할 구조체 pointer

호출에 전달하거나 호출에서 돌려받는 값입니다.

VIDEO_GET_EVENT 대기와 오류
조건동작
blocking modeevent가 생길 때까지 block
non-blocking modeevent가 없으면 즉시 `EWOULDBLOCK`
select()fd를 `exceptfds`에 포함
poll()wake-up condition으로 `POLLPRI` 지정
EOVERFLOWevent queue overflow로 하나 이상 유실

Blocking mode와 event queue 상태에 따른 동작입니다.

Read-only 권한으로도 호출할 수 있습니다. V4L2 decoder는 `VIDIOC_DQEVENT`를 사용합니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_GET_EVENT
---------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_GET_EVENT

.. code-block:: c

	int ioctl(fd, int request = VIDEO_GET_EVENT,
	struct video_event *ev)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_GET_EVENT`` for this command.

    -  ..

       -  ``struct`` `video_event`_ ``*ev``

       -  Points to the location where the event, if any, is to be stored.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl is for DVB devices only. To get events from a V4L2 decoder
use the V4L2 :ref:`VIDIOC_DQEVENT` ioctl instead.

This ioctl call returns an event of type `video_event`_ if available. A
certain number of the latest events will be cued and returned in order of
occurrence. Older events may be discarded if not fetched in time. If
an event is not available, the behavior depends on whether the device is
in blocking or non-blocking mode. In the latter case, the call fails
immediately with errno set to ``EWOULDBLOCK``. In the former case, the
call blocks until an event becomes available. The standard Linux poll()
and/or select() system calls can be used with the device file descriptor
to watch for new events. For select(), the file descriptor should be
included in the exceptfds argument, and for poll(), POLLPRI should be
specified as the wake-up condition. Read-only permissions are sufficient
for this ioctl call.

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.

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``EWOULDBLOCK``

       -  :cspan:`1` There is no event pending, and the device is in
          non-blocking mode.

    -  ..

       -  ``EOVERFLOW``

       -  Overflow in event queue - one or more events were lost.


-----

VIDEO_SET_DISPLAY_FORMAT

1338-1396

`VIDEO_SET_DISPLAY_FORMAT`은 MPEG chip이 video에 적용할 pan-scan, letterbox 또는 center cut-out 형식을 선택합니다.

VIDEO_SET_DISPLAY_FORMAT 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_SET_DISPLAY_FORMAT`
video_displayformat_t format적용할 cropping/display mode

호출에 전달하거나 호출에서 돌려받는 값입니다.

원문 synopsis는 `video_display_format_t`라고 적지만 앞에서 정의한 type과 인자 표는 `video_displayformat_t`입니다. 원문 표기는 수정하지 않고 차이를 표시했습니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_SET_DISPLAY_FORMAT
------------------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_SET_DISPLAY_FORMAT

.. code-block:: c

	int ioctl(fd, int request = VIDEO_SET_DISPLAY_FORMAT,
	video_display_format_t format)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_SET_DISPLAY_FORMAT`` for this command.

    -  ..

       -  `video_displayformat_t`_ ``format``

       -  Selects the video format to be used.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl call asks the Video Device to select the video format to be
applied by the MPEG chip on the video.

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.


-----

VIDEO_STILLPICTURE

1397-1463

`VIDEO_STILLPICTURE`는 elementary video stream의 I-frame 하나를 still picture로 표시합니다. 보통 TS 또는 PES recording에서 해당 구간을 추출하며, device가 resolution과 codec을 지원해야 합니다.

VIDEO_STILLPICTURE 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_STILLPICTURE`
struct video_still_picture *spI-frame pointer와 size를 담은 구조체

호출에 전달하거나 호출에서 돌려받는 값입니다.

Pointer가 NULL이면 현재 still picture를 blank 처리합니다. AV7110은 일반적인 PAL-SD 해상도의 MPEG-1과 MPEG-2를 지원합니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_STILLPICTURE
------------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_STILLPICTURE

.. code-block:: c

	int ioctl(fd, int request = VIDEO_STILLPICTURE,
	struct video_still_picture *sp)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_STILLPICTURE`` for this command.

    -  ..

       -  ``struct`` `video_still_picture`_ ``*sp``

       -  Pointer to the location where the struct with the I-frame
          and size is stored.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl call asks the Video Device to display a still picture
(I-frame). The input data shall be the section of an elementary video
stream containing an I-frame. Typically this section is extracted from a
TS or PES recording. Resolution and codec (see `video capabilities`_) must
be supported by the device. If the pointer is NULL, then the current
displayed still picture is blanked.

e.g. The AV7110 supports MPEG1 and MPEG2 with the common PAL-SD
resolutions.

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.


-----

VIDEO_FAST_FORWARD

1464-1532

`VIDEO_FAST_FORWARD`는 N개의 I-frame decoding을 건너뜁니다. `VIDEO_SOURCE_MEMORY`를 선택한 경우에만 사용할 수 있습니다.

VIDEO_FAST_FORWARD 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_FAST_FORWARD`
int nFrames건너뛸 I-frame 수

호출에 전달하거나 호출에서 돌려받는 값입니다.

VIDEO_FAST_FORWARD 오류
오류의미
EPERM`VIDEO_SOURCE_MEMORY`를 선택하지 않음

입력 source 제약입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_FAST_FORWARD
------------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_FAST_FORWARD

.. code-block:: c

	int ioctl(fd, int request = VIDEO_FAST_FORWARD, int nFrames)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_FAST_FORWARD`` for this command.

    -  ..

       -  ``int nFrames``

       -  The number of frames to skip.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl call asks the Video Device to skip decoding of N number of
I-frames. This call can only be used if ``VIDEO_SOURCE_MEMORY`` is
selected.

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.

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``EPERM``

       -  Mode ``VIDEO_SOURCE_MEMORY`` not selected.


-----

VIDEO_SLOWMOTION

1533-1601

`VIDEO_SLOWMOTION`은 각 frame을 N번 반복 decode해 slow motion을 구현합니다. `VIDEO_SOURCE_MEMORY`를 선택한 경우에만 사용할 수 있습니다.

VIDEO_SLOWMOTION 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_SLOWMOTION`
int nFrames각 frame을 반복할 횟수

호출에 전달하거나 호출에서 돌려받는 값입니다.

VIDEO_SLOWMOTION 오류
오류의미
EPERM`VIDEO_SOURCE_MEMORY`를 선택하지 않음

입력 source 제약입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_SLOWMOTION
----------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_SLOWMOTION

.. code-block:: c

	int ioctl(fd, int request = VIDEO_SLOWMOTION, int nFrames)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_SLOWMOTION`` for this command.

    -  ..

       -  ``int nFrames``

       -  The number of times to repeat each frame.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl call asks the video device to repeat decoding frames N number
of times. This call can only be used if ``VIDEO_SOURCE_MEMORY`` is
selected.

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.

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``EPERM``

       -  Mode ``VIDEO_SOURCE_MEMORY`` not selected.


-----

VIDEO_GET_CAPABILITIES

1602-1660

`VIDEO_GET_CAPABILITIES`는 video hardware의 decoding capability bit mask를 조회합니다.

VIDEO_GET_CAPABILITIES 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_GET_CAPABILITIES`
unsigned int *capcapability bit mask를 받을 pointer

호출에 전달하거나 호출에서 돌려받는 값입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_GET_CAPABILITIES
----------------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_GET_CAPABILITIES

.. code-block:: c

	int ioctl(fd, int request = VIDEO_GET_CAPABILITIES, unsigned int *cap)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_GET_CAPABILITIES`` for this command.

    -  ..

       -  ``unsigned int *cap``

       -  Pointer to a location where to store the capability information.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl call asks the video device about its decoding capabilities.
On success it returns an integer which has bits set according to the
defines in `video capabilities`_.

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.


-----

VIDEO_CLEAR_BUFFER

1661-1712

`VIDEO_CLEAR_BUFFER`는 driver와 decoder hardware의 모든 video buffer를 비웁니다.

VIDEO_CLEAR_BUFFER 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_CLEAR_BUFFER`

호출에 전달하거나 호출에서 돌려받는 값입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_CLEAR_BUFFER
------------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_CLEAR_BUFFER

.. code-block:: c

	int ioctl(fd, int request = VIDEO_CLEAR_BUFFER)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_CLEAR_BUFFER`` for this command.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl call clears all video buffers in the driver and in the
decoder hardware.

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.


-----

VIDEO_SET_STREAMTYPE

1713-1841

`VIDEO_SET_STREAMTYPE`은 `write()`로 들어올 stream codec type을 driver에 알립니다. AV7110 같은 지능형 decoder는 이 호출을 지원하지 않거나 무시하고 stream type을 스스로 판별할 수 있습니다.

VIDEO_SET_STREAMTYPE 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_SET_STREAMTYPE`
int type예상할 stream type 번호

호출에 전달하거나 호출에서 돌려받는 값입니다.

현재 사용되는 video stream type
Codecstream type
MPEG-20
MPEG-4 H.2641
VC-13
MPEG-4 Part 24
VC-1 Simple/Main5
MPEG-16
HEVC H.2657, DREAMBOX에서는 22
AVS16
AVS240

모든 decoder가 모든 codec을 지원하는 것은 아닙니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_SET_STREAMTYPE
--------------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_SET_STREAMTYPE

.. code-block:: c

	int ioctl(fd, int request = VIDEO_SET_STREAMTYPE, int type)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_SET_STREAMTYPE`` for this command.

    -  ..

       -  ``int type``

       -  Stream type.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl tells the driver which kind of stream to expect being written
to it.
Intelligent decoder might also not support or ignore (like the AV7110)
this call and determine the stream type themselves.

Currently used stream types:

.. flat-table::
    :header-rows:  1
    :stub-columns: 0

    -  ..

       -  Codec

       -  Stream type

    -  ..

       -  MPEG2

       -  0

    -  ..

       -  MPEG4 h.264

       -  1

    -  ..

       -  VC1

       -  3

    -  ..

       -  MPEG4 Part2

       -  4

    -  ..

       -  VC1 SM

       -  5

    -  ..

       -  MPEG1

       -  6

    -  ..

       -  HEVC h.265

       -  | 7
          | DREAMBOX: 22

    -  ..

       -  AVS

       -  16

    -  ..

       -  AVS2

       -  40

Not every decoder supports all stream types.

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.


-----

VIDEO_SET_FORMAT

1842-1900

`VIDEO_SET_FORMAT`은 연결된 output device, 예를 들어 TV의 screen aspect ratio를 설정해 decoder output을 맞춥니다.

VIDEO_SET_FORMAT 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_SET_FORMAT`
video_format_t formatoutput TV의 4:3, 16:9 또는 2.21:1 format

호출에 전달하거나 호출에서 돌려받는 값입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_SET_FORMAT
----------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_SET_FORMAT

.. code-block:: c

	int ioctl(fd, int request = VIDEO_SET_FORMAT, video_format_t format)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_SET_FORMAT`` for this command.

    -  ..

       -  `video_format_t`_ ``format``

       -  Video format of TV as defined in section `video_format_t`_.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl sets the screen format (aspect ratio) of the connected output
device (TV) so that the output of the decoder can be adjusted
accordingly.

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.


-----

VIDEO_GET_SIZE

1901-1957

`VIDEO_GET_SIZE`는 현재 video의 pixel size와 aspect ratio를 `video_size_t`로 반환합니다.

VIDEO_GET_SIZE 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_GET_SIZE`
video_size_t *sizewidth, height, aspect ratio를 받을 pointer

호출에 전달하거나 호출에서 돌려받는 값입니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_GET_SIZE
--------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_GET_SIZE

.. code-block:: c

	int ioctl(int fd, int request = VIDEO_GET_SIZE, video_size_t *size)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call,
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_GET_SIZE`` for this command.

    -  ..

       -  `video_size_t`_ ``*size``

       -  Returns the size and aspect ratio.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

This ioctl returns the size and aspect ratio.

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.


-----

VIDEO_GET_PTS

1958-2023

`VIDEO_GET_PTS`는 ITU T-REC-H.222.0 / ISO/IEC 13818-1에 정의된 현재 33-bit PTS를 반환합니다. 가능하면 현재 frame의 PTS지만 마지막 decoded frame 또는 PES parser가 마지막으로 추출한 가까운 값일 수 있습니다.

VIDEO_GET_PTS 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_GET_PTS`
__u64 *pts33-bit PTS를 받을 pointer

호출에 전달하거나 호출에서 돌려받는 값입니다.

V4L2 decoder에서는 `V4L2_CID_MPEG_VIDEO_DEC_PTS` control로 대체됐습니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_GET_PTS
-------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_GET_PTS

.. code-block:: c

	int ioctl(int fd, int request = VIDEO_GET_PTS, __u64 *pts)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_GET_PTS`` for this command.

    -  ..

       -  ``__u64 *pts``

       -  Returns the 33-bit timestamp as defined in ITU T-REC-H.222.0 /
          ISO/IEC 13818-1.

          The PTS should belong to the currently played frame if possible,
          but may also be a value close to it like the PTS of the last
          decoded frame or the last PTS extracted by the PES parser.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

For V4L2 decoders this ioctl has been replaced by the
``V4L2_CID_MPEG_VIDEO_DEC_PTS`` control.

This ioctl call asks the Video Device to return the current PTS
timestamp.

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.


-----

VIDEO_GET_FRAME_COUNT

2024-2085

`VIDEO_GET_FRAME_COUNT`는 decoder 시작 뒤 표시한 frame 수를 반환합니다.

VIDEO_GET_FRAME_COUNT 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_GET_FRAME_COUNT`
__u64 *pts표시한 frame 수를 받을 pointer

호출에 전달하거나 호출에서 돌려받는 값입니다.

원문은 결과 pointer 이름을 `pts`라고 적지만 의미는 PTS가 아니라 frame count입니다. V4L2에서는 `V4L2_CID_MPEG_VIDEO_DEC_FRAME` control로 대체됐습니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_GET_FRAME_COUNT
---------------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_GET_FRAME_COUNT

.. code-block:: c

	int ioctl(int fd, VIDEO_GET_FRAME_COUNT, __u64 *pts)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_GET_FRAME_COUNT`` for this command.

    -  ..

       -  ``__u64 *pts``

       -  Returns the number of frames displayed since the decoder was
          started.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

For V4L2 decoders this ioctl has been replaced by the
``V4L2_CID_MPEG_VIDEO_DEC_FRAME`` control.

This ioctl call asks the Video Device to return the number of displayed
frames since the decoder was started.

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.


-----

VIDEO_COMMAND

2086-2149

`VIDEO_COMMAND`는 `struct video_command`로 decoder에 play, stop, freeze 또는 continue command를 실행합니다.

VIDEO_COMMAND 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_COMMAND`
struct video_command *cmd실행할 decoder command 구조체

호출에 전달하거나 호출에서 돌려받는 값입니다.

이 구조체는 `v4l2_decoder_cmd`의 부분집합입니다. V4L2 decoder는 `VIDIOC_DECODER_CMD`를 사용합니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_COMMAND
-------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_COMMAND

.. code-block:: c

	int ioctl(int fd, int request = VIDEO_COMMAND,
	struct video_command *cmd)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_COMMAND`` for this command.

    -  ..

       -  `struct video_command`_ ``*cmd``

       -  Commands the decoder.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

For V4L2 decoders this ioctl has been replaced by the
:ref:`VIDIOC_DECODER_CMD` ioctl.

This ioctl commands the decoder. The `struct video_command`_ is a
subset of the ``v4l2_decoder_cmd`` struct, so refer to the
:ref:`VIDIOC_DECODER_CMD` documentation for
more information.

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.


-----

VIDEO_TRY_COMMAND

2150-2213

`VIDEO_TRY_COMMAND`는 `struct video_command`가 지원 가능한지 시험합니다. 실제 실행 전 command를 검증하는 경로입니다.

VIDEO_TRY_COMMAND 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
int request이 명령에서는 `VIDEO_TRY_COMMAND`
struct video_command *cmd시험할 decoder command 구조체

호출에 전달하거나 호출에서 돌려받는 값입니다.

이 구조체는 `v4l2_decoder_cmd`의 부분집합이며 V4L2에서는 `VIDIOC_TRY_DECODER_CMD`를 사용합니다.

주의: 이 ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 V4L2 decoder는 대응하는 V4L2 ioctl 또는 control을 사용해야 합니다.

성공하면 0을 반환합니다. 오류이면 -1을 반환하고 `errno`를 설정하며, 공통 오류 의미는 Generic Error Codes 절을 따릅니다.

VIDEO_TRY_COMMAND
-----------------

Synopsis
~~~~~~~~

.. c:macro:: VIDEO_TRY_COMMAND

.. code-block:: c

	int ioctl(int fd, int request = VIDEO_TRY_COMMAND,
	struct video_command *cmd)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``int request``

       -  Equals ``VIDEO_TRY_COMMAND`` for this command.

    -  ..

       -  `struct video_command`_ ``*cmd``

       -  Try a decoder command.

Description
~~~~~~~~~~~

.. attention:: Do **not** use in new drivers!
             See: :ref:`legacy_dvb_decoder_notes`

For V4L2 decoders this ioctl has been replaced by the
:ref:`VIDIOC_TRY_DECODER_CMD <VIDIOC_DECODER_CMD>` ioctl.

This ioctl tries a decoder command. The `struct video_command`_ is a
subset of the ``v4l2_decoder_cmd`` struct, so refer to the
:ref:`VIDIOC_TRY_DECODER_CMD <VIDIOC_DECODER_CMD>` documentation
for more information.

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.


-----

open() video 장치 열기

2214-2316

`open()`은 `/dev/dvb/adapter?/video?` 장치를 열어 이후 호출에 사용할 file descriptor를 얻습니다. Blocking mode는 나중에 `fcntl(F_SETFL)`로 바꿀 수 있습니다.

open() 인자와 flag
인자/flag의미
const char *deviceName열 video device 이름
O_RDONLY읽기 전용 접근
O_RDWR읽기/쓰기 접근
O_NONBLOCKnon-blocking mode, 기본값은 blocking

`flags`는 access와 non-blocking flag를 bitwise OR로 조합합니다.

`O_RDWR`는 한 사용자만 열 수 있습니다. `O_RDONLY`로 열면 `VIDEO_GET_STATUS`만 사용할 수 있고 다른 ioctl은 오류를 반환합니다.

open() 오류
오류의미
ENODEVdriver가 load되지 않았거나 사용할 수 없음
EINTERNAL내부 오류
EBUSYdevice 또는 resource가 사용 중
EINVAL잘못된 인자

대표 오류 code입니다.

open()
------

Synopsis
~~~~~~~~

.. code-block:: c

    #include <fcntl.h>

.. c:function:: 	int open(const char *deviceName, int flags)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``const char *deviceName``

       -  Name of specific video device.

    -  ..

       -  :rspan:`3` ``int flags``

       -  :cspan:`1` A bit-wise OR of the following flags:

    -  ..

       -  ``O_RDONLY``

       -  read-only access

    -  ..

       -  ``O_RDWR``

       -  read/write access

    -  ..

       -  ``O_NONBLOCK``
       -  | Open in non-blocking mode
          | (blocking mode is the default)

Description
~~~~~~~~~~~

This system call opens a named video device (e.g.
/dev/dvb/adapter?/video?) for subsequent use.

When an open() call has succeeded, the device will be ready for use. The
significance of blocking or non-blocking mode is described in the
documentation for functions where there is a difference. It does not
affect the semantics of the open() call itself. A device opened in
blocking mode can later be put into non-blocking mode (and vice versa)
using the F_SETFL command of the fcntl system call. This is a standard
system call, documented in the Linux manual page for fcntl. Only one
user can open the Video Device in O_RDWR mode. All other attempts to
open the device in this mode will fail, and an error-code will be
returned. If the Video Device is opened in O_RDONLY mode, the only
ioctl call that can be used is `VIDEO_GET_STATUS`_. All other call will
return an error code.

Return Value
~~~~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``ENODEV``

       -  :cspan:`1` Device driver not loaded/available.

    -  ..

       -  ``EINTERNAL``

       -  Internal error.

    -  ..

       -  ``EBUSY``

       -  Device or resource busy.

    -  ..

       -  ``EINVAL``

       -  Invalid argument.


-----

close() video 장치 닫기

2317-2360

`close(fd)`는 이전에 연 video device를 닫습니다.

close() 인자와 오류
인자/오류설명
int fd이전 `open()`에서 받은 file descriptor
EBADFfd가 유효한 열린 file descriptor가 아님

유효한 열린 file descriptor를 전달해야 합니다.

close()
-------

Synopsis
~~~~~~~~

.. c:function:: 	int close(int fd)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

Description
~~~~~~~~~~~

This system call closes a previously opened video device.

Return Value
~~~~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``EBADF``

       -  fd is not a valid open file descriptor.


-----

write() video stream 공급

2361-2430

`write(fd, buf, count)`는 `VIDEO_SELECT_SOURCE`에서 `VIDEO_SOURCE_MEMORY`를 선택했을 때만 사용할 수 있습니다. 기본 data는 PES format이며 capability가 허용하면 다른 형식도 가능하고, DVB recording에 흔한 TS도 보통 지원됩니다.

write() 인자
인자설명
int fd이전 `open()`에서 받은 file descriptor
const void *bufPES 또는 지원 stream data buffer
size_t count전송할 byte 수

사용자 공간 buffer의 stream을 decoder에 전달합니다.

`O_NONBLOCK`을 지정하지 않으면 buffer 공간이 생길 때까지 block됩니다. 지원 형식은 DVB Data Formats와 capability를 함께 확인해야 합니다.

write() 오류
오류의미
EPERM`VIDEO_SOURCE_MEMORY`를 선택하지 않음
ENOMEM내부 buffer 용량보다 많은 data를 쓰려고 함
EBADFfd가 유효한 열린 file descriptor가 아님

Source mode, buffer 용량, descriptor 상태에 따른 오류입니다.

Memory source 재생
VIDEO_SELECT_SOURCE로 VIDEO_SOURCE_MEMORY 선택지원 codec·container와 VIDEO_SET_STREAMTYPE 확인PES 또는 지원되는 TS data를 buffer에 준비write(fd, buf, count) 호출VIDEO_PLAY 또는 VIDEO_COMMAND로 재생 제어

응용 프로그램 stream이 decoder로 들어가는 순서입니다.

write()
-------

Synopsis
~~~~~~~~

.. c:function:: size_t write(int fd, const void *buf, size_t count)

Arguments
~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``int fd``

       -  :cspan:`1` File descriptor returned by a previous call
          to `open()`_.

    -  ..

       -  ``void *buf``

       -  Pointer to the buffer containing the PES data.

    -  ..

       -  ``size_t count``

       -  Size of buf.

Description
~~~~~~~~~~~

This system call can only be used if VIDEO_SOURCE_MEMORY is selected
in the ioctl call `VIDEO_SELECT_SOURCE`_. The data provided shall be in
PES format, unless the capability allows other formats. TS is the
most common format for storing DVB-data, it is usually supported too.
If O_NONBLOCK is not specified the function will block until buffer space
is available. The amount of data to be transferred is implied by count.

.. note:: See: :ref:`DVB Data Formats <legacy_dvb_decoder_formats>`

Return Value
~~~~~~~~~~~~

.. flat-table::
    :header-rows:  0
    :stub-columns: 0

    -  ..

       -  ``EPERM``

       -  :cspan:`1` Mode ``VIDEO_SOURCE_MEMORY`` not selected.

    -  ..

       -  ``ENOMEM``

       -  Attempted to write more data than the internal buffer can hold.

    -  ..

       -  ``EBADF``

       -  fd is not a valid open file descriptor.