Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: docs: uAPI: dvb/video: completing the documentation (data types)

The existing documentation of the legacy DVB Decoder API was incomplete.

Revising the documentation, adding missing parts and arranging the
documentation files new.

This patch contains the documentation of the data types defined in
video.h.

Link: https://lore.kernel.org/linux-media/20240128233249.32794-6-herdler@nurfuerspam.de
Signed-off-by: Stefan Herdler <herdler@nurfuerspam.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>

authored by

Stefan Herdler and committed by
Mauro Carvalho Chehab
6fb68c13 53614720

+798
+798
Documentation/userspace-api/media/dvb/legacy_dvb_video.rst
··· 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.