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

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

DVB Audio Device

폐기된 DVB MPEG-2 audio decoder의 data type, ioctl, open/close/write 동작을 설명합니다.

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

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

1. 요약·해설

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

요약·해설

legacy_dvb_audio.rst:1-1642

이 API는 새 드라이버에서 사용하면 안 되는 legacy DVB decoder 인터페이스입니다. Audio input은 demux 또는 `write()` memory source에서 받고, ioctl로 재생·일시 정지·음소거·A/V sync·bypass·채널·sub-stream·mixer를 제어합니다.

원문의 symbol·호출 선언·오류 값은 그대로 보존했습니다. 선언과 표가 어긋나는 `AUDIO_PAUSED`/`AUDIO_PAUSE`, `AUDIO_SET_AV_SYNC`/`AUDIO_AV_SYNC` 표기는 번역 본문에서 검수 지점으로 명시했습니다.

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.audio
4
5 .. _dvb_audio:
6
7 ================
8 DVB Audio Device
9 ================
10
11 .. attention:: Do **not** use in new drivers!
12 See: :ref:`legacy_dvb_decoder_notes`
13
14 The DVB audio device controls the MPEG2 audio decoder of the DVB
15 hardware. It can be accessed through ``/dev/dvb/adapter?/audio?``. Data
16 types and ioctl definitions can be accessed by including
17 ``linux/dvb/audio.h`` in your application.
18
19 Please note that most DVB cards don’t have their own MPEG decoder, which
20 results in the omission of the audio and video device.
21
22 These ioctls were also used by V4L2 to control MPEG decoders implemented
23 in V4L2. The use of these ioctls for that purpose has been made obsolete
24 and proper V4L2 ioctls or controls have been created to replace that
25 functionality. Use :ref:`V4L2 ioctls<audio>` for new drivers!
26
27
28 Audio Data Types
29 ================
30
31 This section describes the structures, data types and defines used when
32 talking to the audio device.
33
34
35 -----
36
37
38 audio_stream_source_t
39 ---------------------
40
41 Synopsis
42 ~~~~~~~~
43
44 .. c:enum:: audio_stream_source_t
45
46 .. code-block:: c
47
48 typedef enum {
49 AUDIO_SOURCE_DEMUX,
50 AUDIO_SOURCE_MEMORY
51 } audio_stream_source_t;
52
53 Constants
54 ~~~~~~~~~
55
56 .. flat-table::
57 :header-rows: 0
58 :stub-columns: 0
59
60 - ..
61
62 - ``AUDIO_SOURCE_DEMUX``
63
64 - :cspan:`1` Selects the demultiplexer (fed either by the frontend
65 or the DVR device) as the source of the video stream.
66
67 - ..
68
69 - ``AUDIO_SOURCE_MEMORY``
70
71 - Selects the stream from the application that comes through
72 the `write()`_ system call.
73
74 Description
75 ~~~~~~~~~~~
76
77 The audio stream source is set through the `AUDIO_SELECT_SOURCE`_ call
78 and can take the following values, depending on whether we are replaying
79 from an internal (demux) or external (user write) source.
80
81 The data fed to the decoder is also controlled by the PID-filter.
82 Output selection: :c:type:`dmx_output` ``DMX_OUT_DECODER``.
83
84
85 -----
86
87
88 audio_play_state_t
89 ------------------
90
91 Synopsis
92 ~~~~~~~~
93
94 .. c:enum:: audio_play_state_t
95
96 .. code-block:: c
97
98 typedef enum {
99 AUDIO_STOPPED,
100 AUDIO_PLAYING,
101 AUDIO_PAUSED
102 } audio_play_state_t;
103
104 Constants
105 ~~~~~~~~~
106
107 .. flat-table::
108 :header-rows: 0
109 :stub-columns: 0
110
111 - ..
112
113 - ``AUDIO_STOPPED``
114
115 - Audio is stopped.
116
117 - ..
118
119 - ``AUDIO_PLAYING``
120
121 - Audio is currently playing.
122
123 - ..
124
125 - ``AUDIO_PAUSE``
126
127 - Audio is frozen.
128
129 Description
130 ~~~~~~~~~~~
131
132 This values can be returned by the `AUDIO_GET_STATUS`_ call
133 representing the state of audio playback.
134
135
136 -----
137
138
139 audio_channel_select_t
140 ----------------------
141
142 Synopsis
143 ~~~~~~~~
144
145 .. c:enum:: audio_channel_select_t
146
147 .. code-block:: c
148
149 typedef enum {
150 AUDIO_STEREO,
151 AUDIO_MONO_LEFT,
152 AUDIO_MONO_RIGHT,
153 AUDIO_MONO,
154 AUDIO_STEREO_SWAPPED
155 } audio_channel_select_t;
156
157 Constants
158 ~~~~~~~~~
159
160 .. flat-table::
161 :header-rows: 0
162 :stub-columns: 0
163
164 - ..
165
166 - ``AUDIO_STEREO``
167
168 - Stereo.
169
170 - ..
171
172 - ``AUDIO_MONO_LEFT``
173
174 - Mono, select left stereo channel as source.
175
176 - ..
177
178 - ``AUDIO_MONO_RIGHT``
179
180 - Mono, select right stereo channel as source.
181
182 - ..
183
184 - ``AUDIO_MONO``
185
186 - Mono source only.
187
188 - ..
189
190 - ``AUDIO_STEREO_SWAPPED``
191
192 - Stereo, swap L & R.
193
194 Description
195 ~~~~~~~~~~~
196
197 The audio channel selected via `AUDIO_CHANNEL_SELECT`_ is determined by
198 this value.
199
200
201 -----
202
203
204 audio_mixer_t
205 -------------
206
207 Synopsis
208 ~~~~~~~~
209
210 .. c:struct:: audio_mixer
211
212 .. code-block:: c
213
214 typedef struct audio_mixer {
215 unsigned int volume_left;
216 unsigned int volume_right;
217 } audio_mixer_t;
218
219 Variables
220 ~~~~~~~~~
221
222 .. flat-table::
223 :header-rows: 0
224 :stub-columns: 0
225
226 - ..
227
228 - ``unsigned int volume_left``
229
230 - Volume left channel.
231 Valid range: 0 ... 255
232
233 - ..
234
235 - ``unsigned int volume_right``
236
237 - Volume right channel.
238 Valid range: 0 ... 255
239
240 Description
241 ~~~~~~~~~~~
242
243 This structure is used by the `AUDIO_SET_MIXER`_ call to set the
244 audio volume.
245
246
247 -----
248
249
250 audio_status
251 ------------
252
253 Synopsis
254 ~~~~~~~~
255
256 .. c:struct:: audio_status
257
258 .. code-block:: c
259
260 typedef struct audio_status {
261 int AV_sync_state;
262 int mute_state;
263 audio_play_state_t play_state;
264 audio_stream_source_t stream_source;
265 audio_channel_select_t channel_select;
266 int bypass_mode;
267 audio_mixer_t mixer_state;
268 } audio_status_t;
269
270 Variables
271 ~~~~~~~~~
272
273 .. flat-table::
274 :header-rows: 0
275 :stub-columns: 0
276
277 - ..
278
279 - :rspan:`2` ``int AV_sync_state``
280
281 - :cspan:`1` Shows if A/V synchronization is ON or OFF.
282
283 - ..
284
285 - TRUE ( != 0 )
286
287 - AV-sync ON.
288
289 - ..
290
291 - FALSE ( == 0 )
292
293 - AV-sync OFF.
294
295 - ..
296
297 - :rspan:`2` ``int mute_state``
298
299 - :cspan:`1` Indicates if audio is muted or not.
300
301 - ..
302
303 - TRUE ( != 0 )
304
305 - mute audio
306
307 - ..
308
309 - FALSE ( == 0 )
310
311 - unmute audio
312
313 - ..
314
315 - `audio_play_state_t`_ ``play_state``
316
317 - Current playback state.
318
319 - ..
320
321 - `audio_stream_source_t`_ ``stream_source``
322
323 - Current source of the data.
324
325 - ..
326
327 - :rspan:`2` ``int bypass_mode``
328
329 - :cspan:`1` Is the decoding of the current Audio stream in
330 the DVB subsystem enabled or disabled.
331
332 - ..
333
334 - TRUE ( != 0 )
335
336 - Bypass disabled.
337
338 - ..
339
340 - FALSE ( == 0 )
341
342 - Bypass enabled.
343
344 - ..
345
346 - `audio_mixer_t`_ ``mixer_state``
347
348 - Current volume settings.
349
350 Description
351 ~~~~~~~~~~~
352
353 The `AUDIO_GET_STATUS`_ call returns this structure as information
354 about various states of the playback operation.
355
356
357 -----
358
359
360 audio encodings
361 ---------------
362
363 Synopsis
364 ~~~~~~~~
365
366 .. code-block:: c
367
368 #define AUDIO_CAP_DTS 1
369 #define AUDIO_CAP_LPCM 2
370 #define AUDIO_CAP_MP1 4
371 #define AUDIO_CAP_MP2 8
372 #define AUDIO_CAP_MP3 16
373 #define AUDIO_CAP_AAC 32
374 #define AUDIO_CAP_OGG 64
375 #define AUDIO_CAP_SDDS 128
376 #define AUDIO_CAP_AC3 256
377
378 Constants
379 ~~~~~~~~~
380
381 .. flat-table::
382 :header-rows: 0
383 :stub-columns: 0
384
385 - ..
386
387 - ``AUDIO_CAP_DTS``
388
389 - :cspan:`1` The hardware accepts DTS audio tracks.
390
391 - ..
392
393 - ``AUDIO_CAP_LPCM``
394
395 - The hardware accepts uncompressed audio with
396 Linear Pulse-Code Modulation (LPCM)
397
398 - ..
399
400 - ``AUDIO_CAP_MP1``
401
402 - The hardware accepts MPEG-1 Audio Layer 1.
403
404 - ..
405
406 - ``AUDIO_CAP_MP2``
407
408 - The hardware accepts MPEG-1 Audio Layer 2.
409 Also known as MUSICAM.
410
411 - ..
412
413 - ``AUDIO_CAP_MP3``
414
415 - The hardware accepts MPEG-1 Audio Layer III.
416 Commonly known as .mp3.
417
418 - ..
419
420 - ``AUDIO_CAP_AAC``
421
422 - The hardware accepts AAC (Advanced Audio Coding).
423
424 - ..
425
426 - ``AUDIO_CAP_OGG``
427
428 - The hardware accepts Vorbis audio tracks.
429
430 - ..
431
432 - ``AUDIO_CAP_SDDS``
433
434 - The hardware accepts Sony Dynamic Digital Sound (SDDS).
435
436 - ..
437
438 - ``AUDIO_CAP_AC3``
439
440 - The hardware accepts Dolby Digital ATSC A/52 audio.
441 Also known as AC-3.
442
443 Description
444 ~~~~~~~~~~~
445
446 A call to `AUDIO_GET_CAPABILITIES`_ returns an unsigned integer with the
447 following bits set according to the hardwares capabilities.
448
449
450 -----
451
452
453 Audio Function Calls
454 ====================
455
456
457 AUDIO_STOP
458 ----------
459
460 Synopsis
461 ~~~~~~~~
462
463 .. c:macro:: AUDIO_STOP
464
465 .. code-block:: c
466
467 int ioctl(int fd, int request = AUDIO_STOP)
468
469 Arguments
470 ~~~~~~~~~
471
472 .. flat-table::
473 :header-rows: 0
474 :stub-columns: 0
475
476 - ..
477
478 - ``int fd``
479
480 - File descriptor returned by a previous call to `open()`_.
481
482 - ..
483
484 - ``int request``
485
486 - :cspan:`1` Equals ``AUDIO_STOP`` for this command.
487
488 Description
489 ~~~~~~~~~~~
490
491 .. attention:: Do **not** use in new drivers!
492 See: :ref:`legacy_dvb_decoder_notes`
493
494 This ioctl call asks the Audio Device to stop playing the current
495 stream.
496
497 Return Value
498 ~~~~~~~~~~~~
499
500 On success 0 is returned, on error -1 and the ``errno`` variable is set
501 appropriately. The generic error codes are described at the
502 :ref:`Generic Error Codes <gen-errors>` chapter.
503
504
505 -----
506
507
508 AUDIO_PLAY
509 ----------
510
511 Synopsis
512 ~~~~~~~~
513
514 .. c:macro:: AUDIO_PLAY
515
516 .. code-block:: c
517
518 int ioctl(int fd, int request = AUDIO_PLAY)
519
520 Arguments
521 ~~~~~~~~~
522
523 .. flat-table::
524 :header-rows: 0
525 :stub-columns: 0
526
527 - ..
528
529 - ``int fd``
530
531 - File descriptor returned by a previous call to `open()`_.
532
533 - ..
534
535 - ``int request``
536
537 - :cspan:`1` Equals ``AUDIO_PLAY`` for this command.
538
539 Description
540 ~~~~~~~~~~~
541
542 .. attention:: Do **not** use in new drivers!
543 See: :ref:`legacy_dvb_decoder_notes`
544
545 This ioctl call asks the Audio Device to start playing an audio stream
546 from the selected source.
547
548 Return Value
549 ~~~~~~~~~~~~
550
551 On success 0 is returned, on error -1 and the ``errno`` variable is set
552 appropriately. The generic error codes are described at the
553 :ref:`Generic Error Codes <gen-errors>` chapter.
554
555
556 -----
557
558
559 AUDIO_PAUSE
560 -----------
561
562 Synopsis
563 ~~~~~~~~
564
565 .. c:macro:: AUDIO_PAUSE
566
567 .. code-block:: c
568
569 int ioctl(int fd, int request = AUDIO_PAUSE)
570
571 Arguments
572 ~~~~~~~~~
573
574 .. flat-table::
575 :header-rows: 0
576 :stub-columns: 0
577
578 - ..
579
580 - ``int fd``
581
582 - :cspan:`1` File descriptor returned by a previous call
583 to `open()`_.
584
585 - ..
586
587 - ``int request``
588
589 - Equals ``AUDIO_PAUSE`` for this command.
590
591 Description
592 ~~~~~~~~~~~
593
594 .. attention:: Do **not** use in new drivers!
595 See: :ref:`legacy_dvb_decoder_notes`
596
597 This ioctl call suspends the audio stream being played. Decoding and
598 playing are paused. It is then possible to restart again decoding and
599 playing process of the audio stream using `AUDIO_CONTINUE`_ command.
600
601 Return Value
602 ~~~~~~~~~~~~
603
604 On success 0 is returned, on error -1 and the ``errno`` variable is set
605 appropriately. The generic error codes are described at the
606 :ref:`Generic Error Codes <gen-errors>` chapter.
607
608
609 -----
610
611
612 AUDIO_CONTINUE
613 --------------
614
615 Synopsis
616 ~~~~~~~~
617
618 .. c:macro:: AUDIO_CONTINUE
619
620 .. code-block:: c
621
622 int ioctl(int fd, int request = AUDIO_CONTINUE)
623
624 Arguments
625 ~~~~~~~~~
626
627 .. flat-table::
628 :header-rows: 0
629 :stub-columns: 0
630
631 - ..
632
633 - ``int fd``
634
635 - :cspan:`1` File descriptor returned by a previous call
636 to `open()`_.
637
638 - ..
639
640 - ``int request``
641
642 - Equals ``AUDIO_CONTINUE`` for this command.
643
644 Description
645 ~~~~~~~~~~~
646
647 .. attention:: Do **not** use in new drivers!
648 See: :ref:`legacy_dvb_decoder_notes`
649
650 This ioctl restarts the decoding and playing process previously paused
651 with `AUDIO_PAUSE`_ command.
652
653 Return Value
654 ~~~~~~~~~~~~
655
656 On success 0 is returned, on error -1 and the ``errno`` variable is set
657 appropriately. The generic error codes are described at the
658 :ref:`Generic Error Codes <gen-errors>` chapter.
659
660
661 -----
662
663
664 AUDIO_SELECT_SOURCE
665 -------------------
666
667 Synopsis
668 ~~~~~~~~
669
670 .. c:macro:: AUDIO_SELECT_SOURCE
671
672 .. code-block:: c
673
674 int ioctl(int fd, int request = AUDIO_SELECT_SOURCE,
675 audio_stream_source_t source)
676
677 Arguments
678 ~~~~~~~~~
679
680 .. flat-table::
681 :header-rows: 0
682 :stub-columns: 0
683
684 - ..
685
686 - ``int fd``
687
688 - :cspan:`1` File descriptor returned by a previous call
689 to `open()`_.
690
691 - ..
692
693 - ``int request``
694
695 - Equals ``AUDIO_SELECT_SOURCE`` for this command.
696
697 - ..
698
699 - `audio_stream_source_t`_ ``source``
700
701 - Indicates the source that shall be used for the Audio stream.
702
703 Description
704 ~~~~~~~~~~~
705
706 .. attention:: Do **not** use in new drivers!
707 See: :ref:`legacy_dvb_decoder_notes`
708
709 This ioctl call informs the audio device which source shall be used for
710 the input data. The possible sources are demux or memory. If
711 ``AUDIO_SOURCE_MEMORY`` is selected, the data is fed to the Audio Device
712 through the write command. If ``AUDIO_SOURCE_DEMUX`` is selected, the data
713 is directly transferred from the onboard demux-device to the decoder.
714 Note: This only supports DVB-devices with one demux and one decoder so far.
715
716 Return Value
717 ~~~~~~~~~~~~
718
719 On success 0 is returned, on error -1 and the ``errno`` variable is set
720 appropriately. The generic error codes are described at the
721 :ref:`Generic Error Codes <gen-errors>` chapter.
722
723
724 -----
725
726
727 AUDIO_SET_MUTE
728 --------------
729
730 Synopsis
731 ~~~~~~~~
732
733 .. c:macro:: AUDIO_SET_MUTE
734
735 .. code-block:: c
736
737 int ioctl(int fd, int request = AUDIO_SET_MUTE, int state)
738
739 Arguments
740 ~~~~~~~~~
741
742 .. flat-table::
743 :header-rows: 0
744 :stub-columns: 0
745
746 - ..
747
748 - ``int fd``
749
750 - :cspan:`1` File descriptor returned by a previous call
751 to `open()`_.
752
753 - ..
754
755 - ``int request``
756
757 - :cspan:`1` Equals ``AUDIO_SET_MUTE`` for this command.
758
759 - ..
760
761 - :rspan:`2` ``int state``
762
763 - :cspan:`1` Indicates if audio device shall mute or not.
764
765 - ..
766
767 - TRUE ( != 0 )
768
769 - mute audio
770
771 - ..
772
773 - FALSE ( == 0 )
774
775 - unmute audio
776
777 Description
778 ~~~~~~~~~~~
779
780 .. attention:: Do **not** use in new drivers!
781 See: :ref:`legacy_dvb_decoder_notes`
782
783 This ioctl is for DVB devices only. To control a V4L2 decoder use the
784 V4L2 :ref:`VIDIOC_DECODER_CMD` with the
785 ``V4L2_DEC_CMD_START_MUTE_AUDIO`` flag instead.
786
787 This ioctl call asks the audio device to mute the stream that is
788 currently being played.
789
790 Return Value
791 ~~~~~~~~~~~~
792
793 On success 0 is returned, on error -1 and the ``errno`` variable is set
794 appropriately. The generic error codes are described at the
795 :ref:`Generic Error Codes <gen-errors>` chapter.
796
797
798 -----
799
800
801 AUDIO_SET_AV_SYNC
802 -----------------
803
804 Synopsis
805 ~~~~~~~~
806
807 .. c:macro:: AUDIO_SET_AV_SYNC
808
809 .. code-block:: c
810
811 int ioctl(int fd, int request = AUDIO_SET_AV_SYNC, int state)
812
813 Arguments
814 ~~~~~~~~~
815
816 .. flat-table::
817 :header-rows: 0
818 :stub-columns: 0
819
820 - ..
821
822 - ``int fd``
823
824 - :cspan:`1` File descriptor returned by a previous call
825 to `open()`_.
826
827 - ..
828
829 - ``int request``
830
831 - :cspan:`1` Equals ``AUDIO_AV_SYNC`` for this command.
832
833 - ..
834
835 - :rspan:`2` ``int state``
836
837 - :cspan:`1` Tells the DVB subsystem if A/V synchronization
838 shall be ON or OFF.
839
840 - ..
841
842 - TRUE ( != 0 )
843
844 - AV-sync ON.
845
846 - ..
847
848 - FALSE ( == 0 )
849
850 - AV-sync OFF.
851
852 Description
853 ~~~~~~~~~~~
854
855 .. attention:: Do **not** use in new drivers!
856 See: :ref:`legacy_dvb_decoder_notes`
857
858 This ioctl call asks the Audio Device to turn ON or OFF A/V
859 synchronization.
860
861 Return Value
862 ~~~~~~~~~~~~
863
864 On success 0 is returned, on error -1 and the ``errno`` variable is set
865 appropriately. The generic error codes are described at the
866 :ref:`Generic Error Codes <gen-errors>` chapter.
867
868
869 -----
870
871
872 AUDIO_SET_BYPASS_MODE
873 ---------------------
874
875 Synopsis
876 ~~~~~~~~
877
878 .. c:macro:: AUDIO_SET_BYPASS_MODE
879
880 .. code-block:: c
881
882 int ioctl(int fd, int request = AUDIO_SET_BYPASS_MODE, int mode)
883
884 Arguments
885 ~~~~~~~~~
886
887 .. flat-table::
888 :header-rows: 0
889 :stub-columns: 0
890
891 - ..
892
893 - ``int fd``
894
895 - :cspan:`1` File descriptor returned by a previous call
896 to `open()`_.
897
898 - ..
899
900 - ``int request``
901
902 - :cspan:`1` Equals ``AUDIO_SET_BYPASS_MODE`` for this command.
903
904 - ..
905
906 - :rspan:`2` ``int mode``
907
908 - :cspan:`1` Enables or disables the decoding of the current
909 Audio stream in the DVB subsystem.
910 - ..
911
912 - TRUE ( != 0 )
913
914 - Disable bypass
915
916 - ..
917
918 - FALSE ( == 0 )
919
920 - Enable bypass
921
922 Description
923 ~~~~~~~~~~~
924
925 .. attention:: Do **not** use in new drivers!
926 See: :ref:`legacy_dvb_decoder_notes`
927
928 This ioctl call asks the Audio Device to bypass the Audio decoder and
929 forward the stream without decoding. This mode shall be used if streams
930 that can’t be handled by the DVB system shall be decoded. Dolby
931 DigitalTM streams are automatically forwarded by the DVB subsystem if
932 the hardware can handle it.
933
934 Return Value
935 ~~~~~~~~~~~~
936
937 On success 0 is returned, on error -1 and the ``errno`` variable is set
938 appropriately. The generic error codes are described at the
939 :ref:`Generic Error Codes <gen-errors>` chapter.
940
941
942 -----
943
944
945 AUDIO_CHANNEL_SELECT
946 --------------------
947
948 Synopsis
949 ~~~~~~~~
950
951 .. c:macro:: AUDIO_CHANNEL_SELECT
952
953 .. code-block:: c
954
955 int ioctl(int fd, int request = AUDIO_CHANNEL_SELECT,
956 audio_channel_select_t)
957
958 Arguments
959 ~~~~~~~~~
960
961 .. flat-table::
962 :header-rows: 0
963 :stub-columns: 0
964
965 - ..
966
967 - ``int fd``
968
969 - :cspan:`1` File descriptor returned by a previous call
970 to `open()`_.
971
972 - ..
973
974 - ``int request``
975
976 - Equals ``AUDIO_CHANNEL_SELECT`` for this command.
977
978 - ..
979
980 - `audio_channel_select_t`_ ``ch``
981
982 - Select the output format of the audio (mono left/right, stereo).
983
984 Description
985 ~~~~~~~~~~~
986
987 .. attention:: Do **not** use in new drivers!
988 See: :ref:`legacy_dvb_decoder_notes`
989
990 This ioctl is for DVB devices only. To control a V4L2 decoder use the
991 V4L2 ``V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK`` control instead.
992
993 This ioctl call asks the Audio Device to select the requested channel if
994 possible.
995
996 Return Value
997 ~~~~~~~~~~~~
998
999 On success 0 is returned, on error -1 and the ``errno`` variable is set
1000 appropriately. The generic error codes are described at the
1001 :ref:`Generic Error Codes <gen-errors>` chapter.
1004 -----
1007 AUDIO_GET_STATUS
1008 ----------------
1010 Synopsis
1011 ~~~~~~~~
1013 .. c:macro:: AUDIO_GET_STATUS
1015 .. code-block:: c
1017 int ioctl(int fd, int request = AUDIO_GET_STATUS,
1018 struct audio_status *status)
1020 Arguments
1021 ~~~~~~~~~
1023 .. flat-table::
1024 :header-rows: 0
1025 :stub-columns: 0
1027 - ..
1029 - ``int fd``
1031 - :cspan:`1` File descriptor returned by a previous call
1032 to `open()`_.
1034 - ..
1036 - ``int request``
1038 - Equals AUDIO_GET_STATUS for this command.
1040 - ..
1042 - ``struct`` `audio_status`_ ``*status``
1044 - Returns the current state of Audio Device.
1046 Description
1047 ~~~~~~~~~~~
1049 .. attention:: Do **not** use in new drivers!
1050 See: :ref:`legacy_dvb_decoder_notes`
1052 This ioctl call asks the Audio Device to return the current state of the
1053 Audio Device.
1055 Return Value
1056 ~~~~~~~~~~~~
1058 On success 0 is returned, on error -1 and the ``errno`` variable is set
1059 appropriately. The generic error codes are described at the
1060 :ref:`Generic Error Codes <gen-errors>` chapter.
1063 -----
1066 AUDIO_GET_CAPABILITIES
1067 ----------------------
1069 Synopsis
1070 ~~~~~~~~
1072 .. c:macro:: AUDIO_GET_CAPABILITIES
1074 .. code-block:: c
1076 int ioctl(int fd, int request = AUDIO_GET_CAPABILITIES,
1077 unsigned int *cap)
1079 Arguments
1080 ~~~~~~~~~
1082 .. flat-table::
1083 :header-rows: 0
1084 :stub-columns: 0
1086 - ..
1088 - ``int fd``
1090 - :cspan:`1` File descriptor returned by a previous call
1091 to `open()`_.
1093 - ..
1095 - ``int request``
1097 - Equals ``AUDIO_GET_CAPABILITIES`` for this command.
1099 - ..
1101 - ``unsigned int *cap``
1103 - Returns a bit array of supported sound formats.
1104 Bits are defined in `audio encodings`_.
1106 Description
1107 ~~~~~~~~~~~
1109 .. attention:: Do **not** use in new drivers!
1110 See: :ref:`legacy_dvb_decoder_notes`
1112 This ioctl call asks the Audio Device to tell us about the decoding
1113 capabilities of the audio hardware.
1115 Return Value
1116 ~~~~~~~~~~~~
1118 On success 0 is returned, on error -1 and the ``errno`` variable is set
1119 appropriately. The generic error codes are described at the
1120 :ref:`Generic Error Codes <gen-errors>` chapter.
1123 -----
1126 AUDIO_CLEAR_BUFFER
1127 ------------------
1129 Synopsis
1130 ~~~~~~~~
1132 .. c:macro:: AUDIO_CLEAR_BUFFER
1134 .. code-block:: c
1136 int ioctl(int fd, int request = AUDIO_CLEAR_BUFFER)
1138 Arguments
1139 ~~~~~~~~~
1141 .. flat-table::
1142 :header-rows: 0
1143 :stub-columns: 0
1145 - ..
1147 - ``int fd``
1149 - :cspan:`1` File descriptor returned by a previous call
1150 to `open()`_.
1152 - ..
1154 - ``int request``
1156 - Equals ``AUDIO_CLEAR_BUFFER`` for this command.
1158 Description
1159 ~~~~~~~~~~~
1161 .. attention:: Do **not** use in new drivers!
1162 See: :ref:`legacy_dvb_decoder_notes`
1164 This ioctl call asks the Audio Device to clear all software and hardware
1165 buffers of the audio decoder device.
1167 Return Value
1168 ~~~~~~~~~~~~
1170 On success 0 is returned, on error -1 and the ``errno`` variable is set
1171 appropriately. The generic error codes are described at the
1172 :ref:`Generic Error Codes <gen-errors>` chapter.
1175 -----
1178 AUDIO_SET_ID
1179 ------------
1181 Synopsis
1182 ~~~~~~~~
1184 .. c:macro:: AUDIO_SET_ID
1186 .. code-block:: c
1188 int ioctl(int fd, int request = AUDIO_SET_ID, int id)
1190 Arguments
1191 ~~~~~~~~~
1193 .. flat-table::
1194 :header-rows: 0
1195 :stub-columns: 0
1197 - ..
1199 - ``int fd``
1201 - :cspan:`1` File descriptor returned by a previous call
1202 to `open()`_.
1204 - ..
1206 - ``int request``
1208 - Equals ``AUDIO_SET_ID`` for this command.
1210 - ..
1212 - ``int id``
1214 - Audio sub-stream id.
1216 Description
1217 ~~~~~~~~~~~
1219 .. attention:: Do **not** use in new drivers!
1220 See: :ref:`legacy_dvb_decoder_notes`
1222 This ioctl selects which sub-stream is to be decoded if a program or
1223 system stream is sent to the video device.
1225 If no audio stream type is set the id has to be in range [0xC0,0xDF]
1226 for MPEG sound, in [0x80,0x87] for AC3 and in [0xA0,0xA7] for LPCM.
1227 See ITU-T H.222.0 | ISO/IEC 13818-1 for further description.
1229 If the stream type is set with `AUDIO_SET_STREAMTYPE`_, specifies the
1230 id just the sub-stream id of the audio stream and only the first 5 bits
1231 (& 0x1F) are recognized.
1233 Return Value
1234 ~~~~~~~~~~~~
1236 On success 0 is returned, on error -1 and the ``errno`` variable is set
1237 appropriately. The generic error codes are described at the
1238 :ref:`Generic Error Codes <gen-errors>` chapter.
1241 -----
1244 AUDIO_SET_MIXER
1245 ---------------
1247 Synopsis
1248 ~~~~~~~~
1250 .. c:macro:: AUDIO_SET_MIXER
1252 .. code-block:: c
1254 int ioctl(int fd, int request = AUDIO_SET_MIXER, audio_mixer_t *mix)
1256 Arguments
1257 ~~~~~~~~~
1259 .. flat-table::
1260 :header-rows: 0
1261 :stub-columns: 0
1263 - ..
1265 - ``int fd``
1267 - :cspan:`1` File descriptor returned by a previous call
1268 to `open()`_.
1270 - ..
1272 - ``int request``
1274 - Equals ``AUDIO_SET_MIXER`` for this command.
1276 - ..
1278 - ``audio_mixer_t *mix``
1280 - Mixer settings.
1282 Description
1283 ~~~~~~~~~~~
1285 .. attention:: Do **not** use in new drivers!
1286 See: :ref:`legacy_dvb_decoder_notes`
1288 This ioctl lets you adjust the mixer settings of the audio decoder.
1290 Return Value
1291 ~~~~~~~~~~~~
1293 On success 0 is returned, on error -1 and the ``errno`` variable is set
1294 appropriately. The generic error codes are described at the
1295 :ref:`Generic Error Codes <gen-errors>` chapter.
1298 -----
1301 AUDIO_SET_STREAMTYPE
1302 --------------------
1304 Synopsis
1305 ~~~~~~~~
1307 .. c:macro:: AUDIO_SET_STREAMTYPE
1309 .. code-block:: c
1311 int ioctl(fd, int request = AUDIO_SET_STREAMTYPE, int type)
1313 Arguments
1314 ~~~~~~~~~
1316 .. flat-table::
1317 :header-rows: 0
1318 :stub-columns: 0
1320 - ..
1322 - ``int fd``
1324 - :cspan:`1` File descriptor returned by a previous call
1325 to `open()`_.
1327 - ..
1329 - ``int request``
1331 - Equals ``AUDIO_SET_STREAMTYPE`` for this command.
1333 - ..
1335 - ``int type``
1337 - Stream type.
1339 Description
1340 ~~~~~~~~~~~
1342 .. attention:: Do **not** use in new drivers!
1343 See: :ref:`legacy_dvb_decoder_notes`
1345 This ioctl tells the driver which kind of audio stream to expect. This
1346 is useful if the stream offers several audio sub-streams like LPCM and
1347 AC3.
1349 Stream types defined in ITU-T H.222.0 | ISO/IEC 13818-1 are used.
1352 Return Value
1353 ~~~~~~~~~~~~
1355 On success 0 is returned, on error -1 and the ``errno`` variable is set
1356 appropriately. The generic error codes are described at the
1357 :ref:`Generic Error Codes <gen-errors>` chapter.
1359 .. flat-table::
1360 :header-rows: 0
1361 :stub-columns: 0
1363 - ..
1365 - ``EINVAL``
1367 - Type is not a valid or supported stream type.
1370 -----
1373 AUDIO_BILINGUAL_CHANNEL_SELECT
1374 ------------------------------
1376 Synopsis
1377 ~~~~~~~~
1379 .. c:macro:: AUDIO_BILINGUAL_CHANNEL_SELECT
1381 .. code-block:: c
1383 int ioctl(int fd, int request = AUDIO_BILINGUAL_CHANNEL_SELECT,
1384 audio_channel_select_t)
1386 Arguments
1387 ~~~~~~~~~
1389 .. flat-table::
1390 :header-rows: 0
1391 :stub-columns: 0
1393 - ..
1395 - ``int fd``
1397 - :cspan:`1` File descriptor returned by a previous call
1398 to `open()`_.
1400 - ..
1402 - ``int request``
1404 - Equals ``AUDIO_BILINGUAL_CHANNEL_SELECT`` for this command.
1406 - ..
1408 - ``audio_channel_select_t ch``
1410 - Select the output format of the audio (mono left/right, stereo).
1412 Description
1413 ~~~~~~~~~~~
1415 .. attention:: Do **not** use in new drivers!
1416 See: :ref:`legacy_dvb_decoder_notes`
1418 This ioctl has been replaced by the V4L2
1419 ``V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK`` control
1420 for MPEG decoders controlled through V4L2.
1422 This ioctl call asks the Audio Device to select the requested channel
1423 for bilingual streams if possible.
1425 Return Value
1426 ~~~~~~~~~~~~
1428 On success 0 is returned, on error -1 and the ``errno`` variable is set
1429 appropriately. The generic error codes are described at the
1430 :ref:`Generic Error Codes <gen-errors>` chapter.
1433 -----
1436 open()
1437 ------
1439 Synopsis
1440 ~~~~~~~~
1442 .. code-block:: c
1444 #include <fcntl.h>
1446 .. c:function:: int open(const char *deviceName, int flags)
1448 Arguments
1449 ~~~~~~~~~
1451 .. flat-table::
1452 :header-rows: 0
1453 :stub-columns: 0
1455 - ..
1457 - ``const char *deviceName``
1459 - Name of specific audio device.
1461 - ..
1463 - :rspan:`3` ``int flags``
1465 - :cspan:`1` A bit-wise OR of the following flags:
1467 - ..
1469 - ``O_RDONLY``
1471 - read-only access
1473 - ..
1475 - ``O_RDWR``
1477 - read/write access
1479 - ..
1481 - ``O_NONBLOCK``
1482 - | Open in non-blocking mode
1483 | (blocking mode is the default)
1485 Description
1486 ~~~~~~~~~~~
1488 This system call opens a named audio device (e.g.
1489 ``/dev/dvb/adapter0/audio0``) for subsequent use. When an open() call has
1490 succeeded, the device will be ready for use. The significance of
1491 blocking or non-blocking mode is described in the documentation for
1492 functions where there is a difference. It does not affect the semantics
1493 of the open() call itself. A device opened in blocking mode can later be
1494 put into non-blocking mode (and vice versa) using the F_SETFL command
1495 of the fcntl system call. This is a standard system call, documented in
1496 the Linux manual page for fcntl. Only one user can open the Audio Device
1497 in O_RDWR mode. All other attempts to open the device in this mode will
1498 fail, and an error code will be returned. If the Audio Device is opened
1499 in O_RDONLY mode, the only ioctl call that can be used is
1500 `AUDIO_GET_STATUS`_. All other call will return with an error code.
1502 Return Value
1503 ~~~~~~~~~~~~
1505 .. flat-table::
1506 :header-rows: 0
1507 :stub-columns: 0
1509 - ..
1511 - ``ENODEV``
1513 - Device driver not loaded/available.
1515 - ..
1517 - ``EBUSY``
1519 - Device or resource busy.
1521 - ..
1523 - ``EINVAL``
1525 - Invalid argument.
1528 -----
1531 close()
1532 -------
1534 Synopsis
1535 ~~~~~~~~
1537 .. c:function:: int close(int fd)
1539 Arguments
1540 ~~~~~~~~~
1542 .. flat-table::
1543 :header-rows: 0
1544 :stub-columns: 0
1546 - ..
1548 - ``int fd``
1550 - :cspan:`1` File descriptor returned by a previous call
1551 to `open()`_.
1553 Description
1554 ~~~~~~~~~~~
1556 This system call closes a previously opened audio device.
1558 Return Value
1559 ~~~~~~~~~~~~
1561 .. flat-table::
1562 :header-rows: 0
1563 :stub-columns: 0
1565 - ..
1567 - ``EBADF``
1569 - Fd is not a valid open file descriptor.
1571 -----
1574 write()
1575 -------
1577 Synopsis
1578 ~~~~~~~~
1580 .. code-block:: c
1582 size_t write(int fd, const void *buf, size_t count)
1584 Arguments
1585 ~~~~~~~~~
1587 .. flat-table::
1588 :header-rows: 0
1589 :stub-columns: 0
1591 - ..
1593 - ``int fd``
1595 - :cspan:`1` File descriptor returned by a previous call
1596 to `open()`_.
1598 - ..
1600 - ``void *buf``
1602 - Pointer to the buffer containing the PES data.
1604 - ..
1606 - ``size_t count``
1608 - Size of buf.
1610 Description
1611 ~~~~~~~~~~~
1613 This system call can only be used if ``AUDIO_SOURCE_MEMORY`` is selected
1614 in the ioctl call `AUDIO_SELECT_SOURCE`_. The data provided shall be in
1615 PES format. If ``O_NONBLOCK`` is not specified the function will block
1616 until buffer space is available. The amount of data to be transferred is
1617 implied by count.
1619 Return Value
1620 ~~~~~~~~~~~~
1622 .. flat-table::
1623 :header-rows: 0
1624 :stub-columns: 0
1626 - ..
1628 - ``EPERM``
1630 - :cspan:`1` Mode ``AUDIO_SOURCE_MEMORY`` not selected.
1632 - ..
1634 - ``ENOMEM``
1636 - Attempted to write more data than the internal buffer can hold.
1638 - ..
1640 - ``EBADF``
1642 - Fd is not a valid open file descriptor.

3. 한국어 전문 번역

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

DVB audio 장치와 사용 중단 경고

1-34

DVB audio 장치는 DVB 하드웨어의 MPEG-2 audio decoder를 제어하며 `/dev/dvb/adapter?/audio?`를 통해 접근합니다. 응용 프로그램에서 `linux/dvb/audio.h`를 포함하면 data type과 ioctl 정의를 사용할 수 있습니다.

새 드라이버에서는 이 API를 사용하면 안 됩니다. 대부분의 DVB card에는 자체 MPEG decoder가 없어 audio와 video device node 자체가 생략됩니다.

이 ioctl들은 한때 V4L2의 MPEG decoder 제어에도 쓰였지만 그 용도는 폐기됐습니다. 새 V4L2 드라이버는 대체 V4L2 ioctl 또는 control을 사용해야 합니다.

Legacy audio 제어 범위
응용 프로그램이 audio device node를 opendemux 또는 write() memory 입력을 선택MPEG audio decoder의 재생·음소거·동기화 상태를 제어새 드라이버에서는 V4L2 ioctl/control로 기능을 구현

이 문서가 다루는 데이터 경로와 현대 구현에서의 대체 방향입니다.

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

.. c:namespace:: dtv.legacy.audio

.. _dvb_audio:

================
DVB Audio Device
================

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

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

Please note that most DVB cards don’t have their own MPEG decoder, which
results in the omission of the audio and video 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<audio>` for new drivers!


Audio Data Types
================

This section describes the structures, data types and defines used when
talking to the audio device.

audio_stream_source_t 입력원

35-84

`audio_stream_source_t`는 `AUDIO_SELECT_SOURCE`가 audio stream을 내부 demux에서 받을지, 사용자 공간의 `write()` 호출에서 받을지 정합니다.

audio_stream_source_t 상수
상수입력 경로
AUDIO_SOURCE_DEMUXfrontend 또는 DVR에서 공급받는 demultiplexer를 입력원으로 선택합니다.
AUDIO_SOURCE_MEMORY응용 프로그램이 `write()`로 제공하는 stream을 선택합니다.

decoder에 공급할 stream의 출처입니다.

Decoder로 들어가는 데이터는 PID filter의 제어도 받습니다. demux 출력은 `dmx_output`의 `DMX_OUT_DECODER`를 선택합니다.

-----


audio_stream_source_t
---------------------

Synopsis
~~~~~~~~

.. c:enum:: audio_stream_source_t

.. code-block:: c

    typedef enum {
    AUDIO_SOURCE_DEMUX,
    AUDIO_SOURCE_MEMORY
    } audio_stream_source_t;

Constants
~~~~~~~~~

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

    -  ..

       -  ``AUDIO_SOURCE_DEMUX``

       -  :cspan:`1` Selects the demultiplexer (fed either by the frontend
          or the DVR device) as the source of the video stream.

    -  ..

       -  ``AUDIO_SOURCE_MEMORY``

       -  Selects the stream from the application that comes through
          the `write()`_ system call.

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

The audio stream source is set through the `AUDIO_SELECT_SOURCE`_ call
and can take the following values, depending on whether we are replaying
from an internal (demux) or external (user write) source.

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

audio_play_state_t 재생 상태

85-135

`audio_play_state_t`는 `AUDIO_GET_STATUS`가 반환하는 현재 audio 재생 상태입니다.

audio_play_state_t 상수
상수상태
AUDIO_STOPPEDAudio가 정지했습니다.
AUDIO_PLAYINGAudio가 현재 재생 중입니다.
AUDIO_PAUSEDAudio가 일시 정지되어 고정된 상태입니다.

정지, 재생, 일시 정지 상태를 나타냅니다.

원문 C 선언은 `AUDIO_PAUSED`를 정의하지만 바로 아래 상수 표는 `AUDIO_PAUSE`라고 적습니다. 번역은 선언의 실제 symbol을 기준으로 설명하되 원문 표기는 수정하지 않았습니다.

-----


audio_play_state_t
------------------

Synopsis
~~~~~~~~

.. c:enum:: audio_play_state_t

.. code-block:: c

    typedef enum {
	AUDIO_STOPPED,
	AUDIO_PLAYING,
	AUDIO_PAUSED
    } audio_play_state_t;

Constants
~~~~~~~~~

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

    -  ..

       -  ``AUDIO_STOPPED``

       -  Audio is stopped.

    -  ..

       -  ``AUDIO_PLAYING``

       -  Audio is currently playing.

    -  ..

       -  ``AUDIO_PAUSE``

       -  Audio is frozen.

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

This values can be returned by the `AUDIO_GET_STATUS`_ call
representing the state of audio playback.

audio_channel_select_t 출력 채널

136-200

`audio_channel_select_t`는 `AUDIO_CHANNEL_SELECT`가 선택할 audio 출력 채널 형식을 지정합니다.

audio_channel_select_t 상수
상수출력 형식
AUDIO_STEREOStereo 출력입니다.
AUDIO_MONO_LEFT왼쪽 stereo 채널을 source로 사용하는 mono 출력입니다.
AUDIO_MONO_RIGHT오른쪽 stereo 채널을 source로 사용하는 mono 출력입니다.
AUDIO_MONOMono source 전용 출력입니다.
AUDIO_STEREO_SWAPPEDStereo의 왼쪽과 오른쪽 채널을 서로 바꿉니다.

Stereo 또는 mono 채널 선택 규칙입니다.

-----


audio_channel_select_t
----------------------

Synopsis
~~~~~~~~

.. c:enum:: audio_channel_select_t

.. code-block:: c

    typedef enum {
	AUDIO_STEREO,
	AUDIO_MONO_LEFT,
	AUDIO_MONO_RIGHT,
	AUDIO_MONO,
	AUDIO_STEREO_SWAPPED
    } audio_channel_select_t;

Constants
~~~~~~~~~

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

    -  ..

       -  ``AUDIO_STEREO``

       -  Stereo.

    -  ..

       -  ``AUDIO_MONO_LEFT``

       -  Mono, select left stereo channel as source.

    -  ..

       -  ``AUDIO_MONO_RIGHT``

       -  Mono, select right stereo channel as source.

    -  ..

       -  ``AUDIO_MONO``

       -  Mono source only.

    -  ..

       -  ``AUDIO_STEREO_SWAPPED``

       -  Stereo, swap L & R.

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

The audio channel selected via `AUDIO_CHANNEL_SELECT`_ is determined by
this value.

audio_mixer_t 음량

201-246

`audio_mixer_t`는 `AUDIO_SET_MIXER`에 전달해 audio decoder의 왼쪽·오른쪽 음량을 설정하는 구조체입니다.

audio_mixer_t 멤버
멤버의미
unsigned int volume_left왼쪽 채널 음량, 0...255
unsigned int volume_right오른쪽 채널 음량, 0...255

각 채널 값의 유효 범위는 0부터 255까지입니다.

-----


audio_mixer_t
-------------

Synopsis
~~~~~~~~

.. c:struct:: audio_mixer

.. code-block:: c

    typedef struct audio_mixer {
	unsigned int volume_left;
	unsigned int volume_right;
    } audio_mixer_t;

Variables
~~~~~~~~~

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

    -  ..

       -  ``unsigned int volume_left``

       -  Volume left channel.
          Valid range: 0 ... 255

    -  ..

       -  ``unsigned int volume_right``

       -  Volume right channel.
          Valid range: 0 ... 255

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

This structure is used by the `AUDIO_SET_MIXER`_ call to set the
audio volume.

audio_status 재생 상태 묶음

247-356

`audio_status_t`는 `AUDIO_GET_STATUS`가 반환하는 재생 동작의 종합 상태입니다.

audio_status 멤버
멤버상태 의미
int AV_sync_state0이 아니면 A/V sync ON, 0이면 OFF입니다.
int mute_state0이 아니면 mute, 0이면 unmute입니다.
audio_play_state_t play_state현재 재생 상태입니다.
audio_stream_source_t stream_source현재 데이터 입력원입니다.
audio_channel_select_t channel_select현재 선택한 출력 채널입니다.
int bypass_mode0이 아니면 bypass disabled, 0이면 bypass enabled입니다.
audio_mixer_t mixer_state현재 왼쪽·오른쪽 음량 설정입니다.

동기화, 음소거, 재생, source, channel, bypass, mixer 상태를 한 구조체에 담습니다.

-----


audio_status
------------

Synopsis
~~~~~~~~

.. c:struct:: audio_status

.. code-block:: c

    typedef struct audio_status {
	int AV_sync_state;
	int mute_state;
	audio_play_state_t play_state;
	audio_stream_source_t stream_source;
	audio_channel_select_t channel_select;
	int bypass_mode;
	audio_mixer_t mixer_state;
    } audio_status_t;

Variables
~~~~~~~~~

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

    -  ..

       -  :rspan:`2` ``int AV_sync_state``

       -  :cspan:`1` Shows if A/V synchronization is ON or OFF.

    -  ..

       -  TRUE  ( != 0 )

       -  AV-sync ON.

    -  ..

       -  FALSE ( == 0 )

       -  AV-sync OFF.

    -  ..

       -  :rspan:`2` ``int mute_state``

       -  :cspan:`1` Indicates if audio is muted or not.

    -  ..

       -  TRUE  ( != 0 )

       -  mute audio

    -  ..

       -  FALSE ( == 0 )

       -  unmute audio

    -  ..

       -  `audio_play_state_t`_ ``play_state``

       -  Current playback state.

    -  ..

       -  `audio_stream_source_t`_ ``stream_source``

       -  Current source of the data.

    -  ..

       -  :rspan:`2` ``int bypass_mode``

       -  :cspan:`1` Is the decoding of the current Audio stream in
          the DVB subsystem enabled or disabled.

    -  ..

       -  TRUE  ( != 0 )

       -  Bypass disabled.

    -  ..

       -  FALSE ( == 0 )

       -  Bypass enabled.

    -  ..

       -  `audio_mixer_t`_ ``mixer_state``

       -  Current volume settings.

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

The `AUDIO_GET_STATUS`_ call returns this structure as information
about various states of the playback operation.

Audio encoding capability bit

357-449

`AUDIO_GET_CAPABILITIES`는 하드웨어가 받아들일 수 있는 audio format을 unsigned integer bit mask로 반환합니다.

Audio capability bit
Bit지원 format
AUDIO_CAP_DTS = 1DTS audio track
AUDIO_CAP_LPCM = 2비압축 Linear Pulse-Code Modulation
AUDIO_CAP_MP1 = 4MPEG-1 Audio Layer 1
AUDIO_CAP_MP2 = 8MPEG-1 Audio Layer 2, MUSICAM
AUDIO_CAP_MP3 = 16MPEG-1 Audio Layer III, 일반적으로 .mp3
AUDIO_CAP_AAC = 32Advanced Audio Coding
AUDIO_CAP_OGG = 64Vorbis audio track
AUDIO_CAP_SDDS = 128Sony Dynamic Digital Sound
AUDIO_CAP_AC3 = 256Dolby Digital ATSC A/52, AC-3

각 `AUDIO_CAP_*` 값은 지원하는 encoding 하나를 나타냅니다.

여러 format을 지원하면 대응하는 bit들이 함께 설정됩니다.

-----


audio encodings
---------------

Synopsis
~~~~~~~~

.. code-block:: c

     #define AUDIO_CAP_DTS    1
     #define AUDIO_CAP_LPCM   2
     #define AUDIO_CAP_MP1    4
     #define AUDIO_CAP_MP2    8
     #define AUDIO_CAP_MP3   16
     #define AUDIO_CAP_AAC   32
     #define AUDIO_CAP_OGG   64
     #define AUDIO_CAP_SDDS 128
     #define AUDIO_CAP_AC3  256

Constants
~~~~~~~~~

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

    -  ..

       -  ``AUDIO_CAP_DTS``

       -  :cspan:`1` The hardware accepts DTS audio tracks.

    -  ..

       -  ``AUDIO_CAP_LPCM``

       -   The hardware accepts uncompressed audio with
           Linear Pulse-Code Modulation (LPCM)

    -  ..

       -  ``AUDIO_CAP_MP1``

       -  The hardware accepts MPEG-1 Audio Layer 1.

    -  ..

       -  ``AUDIO_CAP_MP2``

       -  The hardware accepts MPEG-1 Audio Layer 2.
          Also known as MUSICAM.

    -  ..

       -  ``AUDIO_CAP_MP3``

       -  The hardware accepts MPEG-1 Audio Layer III.
          Commonly known as .mp3.

    -  ..

       -  ``AUDIO_CAP_AAC``

       -  The hardware accepts AAC (Advanced Audio Coding).

    -  ..

       -  ``AUDIO_CAP_OGG``

       -  The hardware accepts Vorbis audio tracks.

    -  ..

       -  ``AUDIO_CAP_SDDS``

       -  The hardware accepts Sony Dynamic Digital Sound (SDDS).

    -  ..

       -  ``AUDIO_CAP_AC3``

       -  The hardware accepts Dolby Digital ATSC A/52 audio.
          Also known as AC-3.

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

A call to `AUDIO_GET_CAPABILITIES`_ returns an unsigned integer with the
following bits set according to the hardwares capabilities.

AUDIO_STOP

450-505

`ioctl(fd, AUDIO_STOP)`은 현재 stream 재생을 멈추도록 Audio Device에 요청합니다.

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

추가 payload가 없는 정지 명령입니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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

-----


Audio Function Calls
====================


AUDIO_STOP
----------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_STOP

.. code-block:: c

	 int ioctl(int fd, int request = AUDIO_STOP)

Arguments
~~~~~~~~~

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

    -  ..

       -  ``int fd``

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

    -  ..

       -  ``int request``

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

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

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

This ioctl call asks the Audio Device to stop playing the current
stream.

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.


-----

AUDIO_PLAY

506-556

`ioctl(fd, AUDIO_PLAY)`는 선택한 source에서 audio stream 재생을 시작하도록 요청합니다.

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

선택한 입력원은 별도의 source 설정을 따릅니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_PLAY
----------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_PLAY

.. code-block:: c

	 int  ioctl(int fd, int request = AUDIO_PLAY)

Arguments
~~~~~~~~~

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

    -  ..

       -  ``int fd``

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

    -  ..

       -  ``int request``

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

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

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

This ioctl call asks the Audio Device to start playing an audio 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.


-----

AUDIO_PAUSE

557-609

`ioctl(fd, AUDIO_PAUSE)`는 재생 중인 audio stream의 decoding과 재생을 함께 일시 정지합니다. 이후 `AUDIO_CONTINUE`로 같은 과정을 다시 시작할 수 있습니다.

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

추가 payload가 없는 일시 정지 명령입니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_PAUSE
-----------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_PAUSE

.. code-block:: c

	 int  ioctl(int fd, int request = AUDIO_PAUSE)

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 ``AUDIO_PAUSE`` for this command.

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

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

This ioctl call suspends the audio stream being played. Decoding and
playing are paused. It is then possible to restart again decoding and
playing process of the audio stream using `AUDIO_CONTINUE`_ command.

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.


-----

AUDIO_CONTINUE

610-661

`ioctl(fd, AUDIO_CONTINUE)`는 앞서 `AUDIO_PAUSE`로 멈춘 decoding과 재생을 재개합니다.

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

일시 정지 상태에서 재생 상태로 전환합니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_CONTINUE
--------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_CONTINUE

.. code-block:: c

	 int  ioctl(int fd, int request = AUDIO_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 ``AUDIO_CONTINUE`` for this command.

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

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

This ioctl restarts the decoding and playing process previously paused
with `AUDIO_PAUSE`_ command.

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.


-----

AUDIO_SELECT_SOURCE

662-724

`AUDIO_SELECT_SOURCE`는 Audio Device의 입력 데이터를 demux 또는 응용 프로그램 memory 중 어디서 받을지 지정합니다.

AUDIO_SELECT_SOURCE 인자
인자설명
int fd이전 `open()` 호출에서 받은 file descriptor
int request이 명령에서는 `AUDIO_SELECT_SOURCE`
audio_stream_source_t sourceaudio stream 입력원

`source`는 `audio_stream_source_t` 값입니다.

Audio source 선택
AUDIO_SOURCE_MEMORY 선택 시 응용 프로그램이 write()로 PES data 공급AUDIO_SOURCE_DEMUX 선택 시 onboard demux가 decoder로 직접 전송현재 설명의 범위는 demux 하나와 decoder 하나인 DVB 장치

선택한 source에 따른 decoder 공급 경로입니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_SELECT_SOURCE
-------------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_SELECT_SOURCE

.. code-block:: c

	 int ioctl(int fd, int request = AUDIO_SELECT_SOURCE,
	 audio_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 ``AUDIO_SELECT_SOURCE`` for this command.

    -  ..

       -  `audio_stream_source_t`_ ``source``

       -  Indicates the source that shall be used for the Audio stream.

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

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

This ioctl call informs the audio device which source shall be used for
the input data. The possible sources are demux or memory. If
``AUDIO_SOURCE_MEMORY`` is selected, the data is fed to the Audio Device
through the write command. If ``AUDIO_SOURCE_DEMUX`` is selected, the data
is directly transferred from the onboard demux-device to the decoder.
Note: This only supports DVB-devices with one demux and one decoder so far.

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.


-----

AUDIO_SET_MUTE

725-798

`AUDIO_SET_MUTE`는 현재 재생 중인 stream의 audio를 mute하거나 다시 들리게 합니다. 이 ioctl은 DVB 장치 전용입니다.

AUDIO_SET_MUTE 인자
인자/값동작
int fd이전 `open()` 호출에서 받은 file descriptor
int request이 명령에서는 `AUDIO_SET_MUTE`
state != 0audio mute
state == 0audio unmute

`state`가 0인지 여부로 mute 상태를 정합니다.

V4L2 decoder는 대신 `VIDIOC_DECODER_CMD`와 `V4L2_DEC_CMD_START_MUTE_AUDIO` flag를 사용합니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_SET_MUTE
--------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_SET_MUTE

.. code-block:: c

	 int  ioctl(int fd, int request = AUDIO_SET_MUTE, int state)

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 ``AUDIO_SET_MUTE`` for this command.

    -  ..

       -  :rspan:`2` ``int state``

       -  :cspan:`1` Indicates if audio device shall mute or not.

    -  ..

       -  TRUE  ( != 0 )

       -  mute audio

    -  ..

       -  FALSE ( == 0 )

       -  unmute audio

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

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

This ioctl is for DVB devices only. To control a V4L2 decoder use the
V4L2 :ref:`VIDIOC_DECODER_CMD` with the
``V4L2_DEC_CMD_START_MUTE_AUDIO`` flag instead.

This ioctl call asks the audio device to mute the stream that is
currently being played.

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.


-----

AUDIO_SET_AV_SYNC

799-869

`AUDIO_SET_AV_SYNC`는 Audio Device의 A/V synchronization을 켜거나 끕니다.

AUDIO_SET_AV_SYNC 인자
인자/값동작
int fd이전 `open()` 호출에서 받은 file descriptor
int request호출 선언은 `AUDIO_SET_AV_SYNC`를 사용합니다.
state != 0A/V sync ON
state == 0A/V sync OFF

`state`가 0인지 여부로 동기화 상태를 정합니다.

원문 인자 표는 request가 `AUDIO_AV_SYNC`와 같다고 적지만 synopsis의 실제 명령은 `AUDIO_SET_AV_SYNC`입니다. 원문 불일치는 보존했습니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_SET_AV_SYNC
-----------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_SET_AV_SYNC

.. code-block:: c

	 int  ioctl(int fd, int request = AUDIO_SET_AV_SYNC, int state)

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 ``AUDIO_AV_SYNC`` for this command.

    -  ..

       -  :rspan:`2` ``int state``

       -  :cspan:`1` Tells the DVB subsystem if A/V synchronization
          shall be ON or OFF.

    -  ..

       -  TRUE  ( != 0 )

       -  AV-sync ON.

    -  ..

       -  FALSE ( == 0 )

       -  AV-sync OFF.

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

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

This ioctl call asks the Audio Device to turn ON or OFF A/V
synchronization.

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.


-----

AUDIO_SET_BYPASS_MODE

870-942

`AUDIO_SET_BYPASS_MODE`는 DVB audio decoder를 우회해 stream을 decoding하지 않고 전달할지 정합니다. DVB subsystem이 처리할 수 없는 stream을 외부 decoder로 보낼 때 사용합니다.

AUDIO_SET_BYPASS_MODE 인자
인자/값동작
int fd이전 `open()` 호출에서 받은 file descriptor
int request이 명령에서는 `AUDIO_SET_BYPASS_MODE`
mode != 0bypass 비활성화, DVB subsystem에서 decoding
mode == 0bypass 활성화, decoding 없이 전달

원문이 정의한 `mode`의 참/거짓 의미입니다.

하드웨어가 Dolby Digital stream을 처리할 수 있으면 DVB subsystem이 자동으로 전달합니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_SET_BYPASS_MODE
---------------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_SET_BYPASS_MODE

.. code-block:: c

	 int ioctl(int fd, int request = AUDIO_SET_BYPASS_MODE, 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 ``AUDIO_SET_BYPASS_MODE`` for this command.

    -  ..

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

       -  :cspan:`1` Enables or disables the decoding of the current
          Audio stream in the DVB subsystem.
    -  ..

       -  TRUE  ( != 0 )

       -  Disable bypass

    -  ..

       -  FALSE ( == 0 )

       -  Enable bypass

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

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

This ioctl call asks the Audio Device to bypass the Audio decoder and
forward the stream without decoding. This mode shall be used if streams
that can’t be handled by the DVB system shall be decoded. Dolby
DigitalTM streams are automatically forwarded by the DVB subsystem if
the hardware can handle it.

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.


-----

AUDIO_CHANNEL_SELECT

943-1004

`AUDIO_CHANNEL_SELECT`는 가능한 경우 mono left, mono right, stereo 등 요청한 audio 출력 채널을 선택합니다. DVB 장치 전용 ioctl입니다.

AUDIO_CHANNEL_SELECT 인자
인자설명
int fd이전 `open()` 호출에서 받은 file descriptor
int request이 명령에서는 `AUDIO_CHANNEL_SELECT`
audio_channel_select_t ch요청할 mono/stereo 출력 형식

채널 형식은 `audio_channel_select_t`로 지정합니다.

V4L2 decoder는 대신 `V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK` control을 사용합니다. 원문 synopsis에는 세 번째 인자의 변수명이 없지만 인자 표에서는 `ch`라고 부릅니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_CHANNEL_SELECT
--------------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_CHANNEL_SELECT

.. code-block:: c

	 int ioctl(int fd, int request = AUDIO_CHANNEL_SELECT,
	 audio_channel_select_t)

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 ``AUDIO_CHANNEL_SELECT`` for this command.

    -  ..

       -  `audio_channel_select_t`_ ``ch``

       -  Select the output format of the audio (mono left/right, stereo).

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

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

This ioctl is for DVB devices only. To control a V4L2 decoder use the
V4L2 ``V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK`` control instead.

This ioctl call asks the Audio Device to select the requested channel if
possible.

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.


-----

AUDIO_GET_STATUS

1005-1063

`AUDIO_GET_STATUS`는 Audio Device의 현재 상태를 `struct audio_status`에 채워 반환합니다.

AUDIO_GET_STATUS 인자
인자설명
int fd이전 `open()` 호출에서 받은 file descriptor
int request이 명령에서는 `AUDIO_GET_STATUS`
struct audio_status *status현재 Audio Device 상태를 받을 구조체

상태 구조체는 호출자가 제공한 pointer를 통해 반환됩니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_GET_STATUS
----------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_GET_STATUS

.. code-block:: c

	 int ioctl(int fd, int request = AUDIO_GET_STATUS,
	 struct audio_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 AUDIO_GET_STATUS for this command.

    -  ..

       -  ``struct`` `audio_status`_ ``*status``

       -  Returns the current state of Audio Device.

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

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

This ioctl call asks the Audio Device to return the current state of the
Audio 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.


-----

AUDIO_GET_CAPABILITIES

1064-1123

`AUDIO_GET_CAPABILITIES`는 audio 하드웨어가 decoding할 수 있는 sound format을 bit array로 조회합니다.

AUDIO_GET_CAPABILITIES 인자
인자설명
int fd이전 `open()` 호출에서 받은 file descriptor
int request이 명령에서는 `AUDIO_GET_CAPABILITIES`
unsigned int *cap지원 format bit mask를 받을 pointer

`cap`의 bit 정의는 audio encodings 절을 따릅니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_GET_CAPABILITIES
----------------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_GET_CAPABILITIES

.. code-block:: c

	 int ioctl(int fd, int request = AUDIO_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 ``AUDIO_GET_CAPABILITIES`` for this command.

    -  ..

       -  ``unsigned int *cap``

       -  Returns a bit array of supported sound formats.
          Bits are defined in `audio encodings`_.

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

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

This ioctl call asks the Audio Device to tell us about the decoding
capabilities of the audio 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.


-----

AUDIO_CLEAR_BUFFER

1124-1175

`AUDIO_CLEAR_BUFFER`는 audio decoder 장치의 software buffer와 hardware buffer를 모두 비우도록 요청합니다.

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

추가 payload가 없는 buffer 초기화 명령입니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_CLEAR_BUFFER
------------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_CLEAR_BUFFER

.. code-block:: c

	 int  ioctl(int fd, int request = AUDIO_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 ``AUDIO_CLEAR_BUFFER`` for this command.

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

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

This ioctl call asks the Audio Device to clear all software and hardware
buffers of the audio decoder 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.


-----

AUDIO_SET_ID

1176-1241

`AUDIO_SET_ID`는 program 또는 system stream에 여러 audio sub-stream이 있을 때 decoding할 sub-stream id를 선택합니다.

AUDIO_SET_ID 인자와 ID 범위
인자/format값 또는 의미
int fd이전 `open()` 호출에서 받은 file descriptor
int request이 명령에서는 `AUDIO_SET_ID`
MPEG audiostream type 미설정 시 id 0xC0...0xDF
AC-3stream type 미설정 시 id 0x80...0x87
LPCMstream type 미설정 시 id 0xA0...0xA7
stream type 설정 시sub-stream id의 하위 5 bit, `id & 0x1F`만 인식

stream type을 별도로 설정했는지에 따라 `id` 해석이 달라집니다.

범위 정의는 ITU-T H.222.0 | ISO/IEC 13818-1을 따릅니다. 원문은 stream이 `video device`로 전송된다고 표현하며, 이 문구도 원문 블록에 그대로 보존했습니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_SET_ID
------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_SET_ID

.. code-block:: c

	 int  ioctl(int fd, int request = AUDIO_SET_ID, int id)

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 ``AUDIO_SET_ID`` for this command.

    -  ..

       -  ``int id``

       -  Audio sub-stream id.

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

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

This ioctl selects which sub-stream is to be decoded if a program or
system stream is sent to the video device.

If no audio stream type is set the id has to be in range [0xC0,0xDF]
for MPEG sound, in [0x80,0x87] for AC3 and in [0xA0,0xA7] for LPCM.
See ITU-T H.222.0 | ISO/IEC 13818-1 for further description.

If the stream type is set with `AUDIO_SET_STREAMTYPE`_, specifies the
id just the sub-stream id of the audio stream and only the first 5 bits
(& 0x1F) are recognized.

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.


-----

AUDIO_SET_MIXER

1242-1298

`AUDIO_SET_MIXER`는 `audio_mixer_t` 구조체로 audio decoder의 왼쪽·오른쪽 mixer 음량을 조정합니다.

AUDIO_SET_MIXER 인자
인자설명
int fd이전 `open()` 호출에서 받은 file descriptor
int request이 명령에서는 `AUDIO_SET_MIXER`
audio_mixer_t *mix적용할 mixer 설정 pointer

`mix`가 두 채널의 설정을 전달합니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_SET_MIXER
---------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_SET_MIXER

.. code-block:: c

	 int ioctl(int fd, int request = AUDIO_SET_MIXER, audio_mixer_t *mix)

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 ``AUDIO_SET_MIXER`` for this command.

    -  ..

       -  ``audio_mixer_t *mix``

       -  Mixer settings.

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

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

This ioctl lets you adjust the mixer settings of the audio 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.


-----

AUDIO_SET_STREAMTYPE

1299-1370

`AUDIO_SET_STREAMTYPE`은 driver가 어떤 종류의 audio stream을 받게 될지 알려 줍니다. LPCM과 AC-3처럼 여러 audio sub-stream을 제공하는 stream에서 유용합니다.

AUDIO_SET_STREAMTYPE 인자
인자/오류설명
int fd이전 `open()` 호출에서 받은 file descriptor
int request이 명령에서는 `AUDIO_SET_STREAMTYPE`
int type예상할 audio stream type
EINVAL유효하지 않거나 지원하지 않는 stream type

stream type 값은 ITU-T H.222.0 | ISO/IEC 13818-1의 정의를 사용합니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_SET_STREAMTYPE
--------------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_SET_STREAMTYPE

.. code-block:: c

	 int  ioctl(fd, int request = AUDIO_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 ``AUDIO_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 audio stream to expect. This
is useful if the stream offers several audio sub-streams like LPCM and
AC3.

Stream types defined in ITU-T H.222.0 | ISO/IEC 13818-1 are used.


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

    -  ..

       -  ``EINVAL``

       -  Type is not a valid or supported stream type.


-----

AUDIO_BILINGUAL_CHANNEL_SELECT

1371-1433

`AUDIO_BILINGUAL_CHANNEL_SELECT`는 bilingual stream에서 가능한 경우 요청한 mono left, mono right 또는 stereo 채널을 선택합니다.

AUDIO_BILINGUAL_CHANNEL_SELECT 인자
인자설명
int fd이전 `open()` 호출에서 받은 file descriptor
int request이 명령에서는 `AUDIO_BILINGUAL_CHANNEL_SELECT`
audio_channel_select_t ch요청할 mono/stereo 출력 형식

출력 형식은 `audio_channel_select_t ch`로 전달합니다.

V4L2로 제어하는 MPEG decoder에서는 이 ioctl이 `V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK` control로 대체됐습니다.

주의: 이 legacy ioctl은 새 드라이버에서 사용하면 안 됩니다. 새 구현은 해당 기능의 V4L2 ioctl 또는 control을 사용해야 합니다.

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



AUDIO_BILINGUAL_CHANNEL_SELECT
------------------------------

Synopsis
~~~~~~~~

.. c:macro:: AUDIO_BILINGUAL_CHANNEL_SELECT

.. code-block:: c

	 int ioctl(int fd, int request = AUDIO_BILINGUAL_CHANNEL_SELECT,
	 audio_channel_select_t)

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 ``AUDIO_BILINGUAL_CHANNEL_SELECT`` for this command.

    -  ..

       -  ``audio_channel_select_t ch``

       -  Select the output format of the audio (mono left/right, stereo).

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

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

This ioctl has been replaced by the V4L2
``V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK`` control
for MPEG decoders controlled through V4L2.

This ioctl call asks the Audio Device to select the requested channel
for bilingual streams if possible.

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() 장치 열기

1434-1528

`open()`은 `/dev/dvb/adapter0/audio0` 같은 audio device를 열어 이후 호출에 사용할 file descriptor를 얻습니다. blocking 여부는 `open()` 자체의 의미를 바꾸지 않으며, 나중에 `fcntl(F_SETFL)`로 전환할 수 있습니다.

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

`flags`는 다음 값을 bitwise OR로 조합합니다.

`O_RDWR`로는 한 사용자만 Audio Device를 열 수 있습니다. 다른 `O_RDWR` open은 실패합니다. `O_RDONLY`로 열면 `AUDIO_GET_STATUS`만 호출할 수 있고 다른 ioctl은 오류를 반환합니다.

open() 오류
오류의미
ENODEVdevice driver가 load되지 않았거나 사용할 수 없음
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 audio 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 audio device (e.g.
``/dev/dvb/adapter0/audio0``) 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 Audio 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 Audio Device is opened
in O_RDONLY mode, the only ioctl call that can be used is
`AUDIO_GET_STATUS`_. All other call will return with an error code.

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

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

    -  ..

       -  ``ENODEV``

       -  Device driver not loaded/available.

    -  ..

       -  ``EBUSY``

       -  Device or resource busy.

    -  ..

       -  ``EINVAL``

       -  Invalid argument.


-----

close() 장치 닫기

1529-1571

`close(fd)`는 이전에 연 audio 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 audio device.

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

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

    -  ..

       -  ``EBADF``

       -  Fd is not a valid open file descriptor.

-----

write() PES 데이터 공급

1572-1642

`write(fd, buf, count)`는 `AUDIO_SELECT_SOURCE`에서 `AUDIO_SOURCE_MEMORY`를 선택했을 때만 사용할 수 있습니다. `buf`의 데이터는 PES format이어야 합니다.

write() 인자
인자설명
int fd이전 `open()` 호출에서 받은 file descriptor
const void *bufPES data가 든 buffer pointer
size_t countbuffer에서 전송할 byte 수

응용 프로그램 memory에서 decoder로 PES data를 전달합니다.

`O_NONBLOCK`을 지정하지 않으면 buffer 공간이 생길 때까지 호출이 block됩니다. 전송량은 `count`가 정합니다.

write() 오류
오류의미
EPERM`AUDIO_SOURCE_MEMORY` mode를 선택하지 않음
ENOMEM내부 buffer가 담을 수 있는 양보다 많은 data를 쓰려고 함
EBADFfd가 유효한 열린 file descriptor가 아님

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

Memory source 전송
AUDIO_SELECT_SOURCE로 AUDIO_SOURCE_MEMORY 선택PES 형식 data를 buf에 준비write(fd, buf, count) 호출buffer가 가득 찼고 blocking mode이면 공간이 생길 때까지 대기Audio decoder가 전달받은 PES stream 처리

사용자 공간 PES data가 decoder로 들어가는 순서입니다.



write()
-------

Synopsis
~~~~~~~~

.. code-block:: c

	 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 ``AUDIO_SOURCE_MEMORY`` is selected
in the ioctl call `AUDIO_SELECT_SOURCE`_. The data provided shall be in
PES format. 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.

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

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

    -  ..

       -  ``EPERM``

       -  :cspan:`1` Mode ``AUDIO_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.