1 .. SPDX-License-Identifier: GFDL-1.1-no-invari 2 3 .. _standard: 4 5 *************** 6 Video Standards 7 *************** 8 9 Video devices typically support one or more di 10 variations of standards. Each video input and 11 set of standards. This set is reported by the 12 :c:type:`v4l2_input` and struct 13 :c:type:`v4l2_output` returned by the 14 :ref:`VIDIOC_ENUMINPUT` and 15 :ref:`VIDIOC_ENUMOUTPUT` ioctls, respectively. 16 17 V4L2 defines one bit for each analog video sta 18 worldwide, and sets aside bits for driver defi 19 hybrid standards to watch NTSC video tapes on 20 Applications can use the predefined bits to se 21 standard, although presenting the user a menu 22 preferred. To enumerate and query the attribut 23 standards applications use the :ref:`VIDIOC_EN 24 ioctl. 25 26 Many of the defined standards are actually jus 27 major standards. The hardware may in fact not 28 or do so internal and switch automatically. Th 29 standards also contain sets of one or more sta 30 31 Assume a hypothetic tuner capable of demodulat 32 signals. The first enumerated standard is a se 33 automatically depending on the selected radio 34 band. Enumeration gives a "PAL-B/G" or "PAL-I" 35 Composite input may collapse standards, enumer 36 "NTSC-M" and "SECAM-D/K". [#f1]_ 37 38 To query and select the standard used by the c 39 output applications call the :ref:`VIDIOC_G_ST 40 :ref:`VIDIOC_S_STD <VIDIOC_G_STD>` ioctl, resp 41 *received* standard can be sensed with the 42 :ref:`VIDIOC_QUERYSTD` ioctl. 43 44 .. note:: 45 46 The parameter of all these ioctls is a poin 47 :ref:`v4l2_std_id <v4l2-std-id>` type (a st 48 index into the standard enumeration. Driver 49 standard ioctls when the device has one or 50 51 Special rules apply to devices such as USB cam 52 video standards makes little sense. More gener 53 output device which is: 54 55 - incapable of capturing fields or frames at 56 video standard, or 57 58 - that does not support the video standard fo 59 60 Here the driver shall set the ``std`` field of 61 :c:type:`v4l2_input` and struct 62 :c:type:`v4l2_output` to zero and the :ref:`VI 63 :ref:`VIDIOC_S_STD <VIDIOC_G_STD>`, :ref:`VIDI 64 shall return the ``ENOTTY`` error code or the 65 66 Applications can make use of the :ref:`input-c 67 :ref:`output-capabilities` flags to determine 68 standard ioctls can be used with the given inp 69 70 Example: Information about the current video s 71 ============================================== 72 73 .. code-block:: c 74 75 v4l2_std_id std_id; 76 struct v4l2_standard standard; 77 78 if (-1 == ioctl(fd, VIDIOC_G_STD, &std_id) 79 /* Note when VIDIOC_ENUMSTD always ret 80 is no video device or it falls unde 81 and VIDIOC_G_STD returning ENOTTY i 82 83 perror("VIDIOC_G_STD"); 84 exit(EXIT_FAILURE); 85 } 86 87 memset(&standard, 0, sizeof(standard)); 88 standard.index = 0; 89 90 while (0 == ioctl(fd, VIDIOC_ENUMSTD, &sta 91 if (standard.id & std_id) { 92 printf("Current video standard: 93 exit(EXIT_SUCCESS); 94 } 95 96 standard.index++; 97 } 98 99 /* EINVAL indicates the end of the enumera 100 empty unless this device falls under th 101 102 if (errno == EINVAL || standard.index == 0 103 perror("VIDIOC_ENUMSTD"); 104 exit(EXIT_FAILURE); 105 } 106 107 Example: Listing the video standards supported 108 ============================================== 109 110 .. code-block:: c 111 112 struct v4l2_input input; 113 struct v4l2_standard standard; 114 115 memset(&input, 0, sizeof(input)); 116 117 if (-1 == ioctl(fd, VIDIOC_G_INPUT, &input 118 perror("VIDIOC_G_INPUT"); 119 exit(EXIT_FAILURE); 120 } 121 122 if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &inp 123 perror("VIDIOC_ENUM_INPUT"); 124 exit(EXIT_FAILURE); 125 } 126 127 printf("Current input %s supports:\\n", in 128 129 memset(&standard, 0, sizeof(standard)); 130 standard.index = 0; 131 132 while (0 == ioctl(fd, VIDIOC_ENUMSTD, &sta 133 if (standard.id & input.std) 134 printf("%s\\n", standard.name); 135 136 standard.index++; 137 } 138 139 /* EINVAL indicates the end of the enumera 140 empty unless this device falls under th 141 142 if (errno != EINVAL || standard.index == 0 143 perror("VIDIOC_ENUMSTD"); 144 exit(EXIT_FAILURE); 145 } 146 147 Example: Selecting a new video standard 148 ======================================= 149 150 .. code-block:: c 151 152 struct v4l2_input input; 153 v4l2_std_id std_id; 154 155 memset(&input, 0, sizeof(input)); 156 157 if (-1 == ioctl(fd, VIDIOC_G_INPUT, &input 158 perror("VIDIOC_G_INPUT"); 159 exit(EXIT_FAILURE); 160 } 161 162 if (-1 == ioctl(fd, VIDIOC_ENUMINPUT, &inp 163 perror("VIDIOC_ENUM_INPUT"); 164 exit(EXIT_FAILURE); 165 } 166 167 if (0 == (input.std & V4L2_STD_PAL_BG)) { 168 fprintf(stderr, "Oops. B/G PAL is not 169 exit(EXIT_FAILURE); 170 } 171 172 /* Note this is also supposed to work when 173 or G/PAL is supported. */ 174 175 std_id = V4L2_STD_PAL_BG; 176 177 if (-1 == ioctl(fd, VIDIOC_S_STD, &std_id) 178 perror("VIDIOC_S_STD"); 179 exit(EXIT_FAILURE); 180 } 181 182 .. [#f1] 183 Some users are already confused by technica 184 SECAM. There is no point asking them to dis 185 or K when the software or hardware can do t
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.