6.2. Changes of the V4L2 API¶
Soon after the V4L API was added to the kernel it was criticised as too inflexible. In August 1998 Bill Dirks proposed a number of improvements and began to work on documentation, example drivers and applications. With the help of other volunteers this eventually became the V4L2 API, not just an extension but a replacement for the V4L API. However it took another four years and two stable kernel releases until the new API was finally accepted for inclusion into the kernel in its present form.
6.2.1. Early Versions¶
1998-08-20: First version.
1998-08-27: The select() function was introduced.
1998-09-10: New video standard interface.
1998-09-18: The VIDIOC_NONCAP ioctl was replaced by the otherwise
meaningless O_TRUNC open() flag, and the
aliases O_NONCAP and O_NOIO were defined. Applications can set
this flag if they intend to access controls only, as opposed to capture
applications which need exclusive access. The VIDEO_STD_XXX
identifiers are now ordinals instead of flags, and the
video_std_construct() helper function takes id and
transmission arguments.
1998-09-28: Revamped video standard. Made video controls individually enumerable.
1998-10-02: The id field was removed from
struct video_standard and the color subcarrier fields were
renamed. The ioctl VIDIOC_QUERYSTD, VIDIOC_SUBDEV_QUERYSTD ioctl was
renamed to ioctl VIDIOC_ENUMSTD, VIDIOC_SUBDEV_ENUMSTD,
VIDIOC_G_INPUT to
ioctl VIDIOC_ENUMINPUT. A first draft of the
Codec API was released.
1998-11-08: Many minor changes. Most symbols have been renamed. Some
material changes to struct v4l2_capability.
1998-11-12: The read/write direction of some ioctls was misdefined.
1998-11-14: V4L2_PIX_FMT_RGB24 changed to V4L2_PIX_FMT_BGR24,
and V4L2_PIX_FMT_RGB32 changed to V4L2_PIX_FMT_BGR32. Audio
controls are now accessible with the
VIDIOC_G_CTRL and
VIDIOC_S_CTRL ioctls under names starting
with V4L2_CID_AUDIO. The V4L2_MAJOR define was removed from
videodev.h since it was only used once in the videodev kernel
module. The YUV422 and YUV411 planar image formats were added.
1998-11-28: A few ioctl symbols changed. Interfaces for codecs and video output devices were added.
1999-01-14: A raw VBI capture interface was added.
1999-01-19: The VIDIOC_NEXTBUF ioctl was removed.
6.2.2. V4L2 Version 0.16 1999-01-31¶
1999-01-27: There is now one QBUF ioctl, VIDIOC_QWBUF and VIDIOC_QRBUF are gone. VIDIOC_QBUF takes a v4l2_buffer as a parameter. Added digital zoom (cropping) controls.
6.2.3. V4L2 Version 0.18 1999-03-16¶
Added a v4l to V4L2 ioctl compatibility layer to videodev.c. Driver writers, this changes how you implement your ioctl handler. See the Driver Writer’s Guide. Added some more control id codes.
6.2.4. V4L2 Version 0.19 1999-06-05¶
1999-03-18: Fill in the category and catname fields of v4l2_queryctrl objects before passing them to the driver. Required a minor change to the VIDIOC_QUERYCTRL handlers in the sample drivers.
1999-03-31: Better compatibility for v4l memory capture ioctls. Requires changes to drivers to fully support new compatibility features, see Driver Writer’s Guide and v4l2cap.c. Added new control IDs: V4L2_CID_HFLIP, _VFLIP. Changed V4L2_PIX_FMT_YUV422P to _YUV422P, and _YUV411P to _YUV411P.
1999-04-04: Added a few more control IDs.
1999-04-07: Added the button control type.
1999-05-02: Fixed a typo in videodev.h, and added the V4L2_CTRL_FLAG_GRAYED (later V4L2_CTRL_FLAG_GRABBED) flag.
1999-05-20: Definition of VIDIOC_G_CTRL was wrong causing a malfunction of this ioctl.
1999-06-05: Changed the value of V4L2_CID_WHITENESS.
6.2.5. V4L2 Version 0.20 (1999-09-10)¶
Version 0.20 introduced a number of changes which were not backward compatible with 0.19 and earlier versions. Purpose of these changes was to simplify the API, while making it more extensible and following common Linux driver API conventions.
Some typos in
V4L2_FMT_FLAGsymbols were fixed.struct v4l2_clipwas changed for compatibility with v4l. (1999-08-30)V4L2_TUNER_SUB_LANG1was added. (1999-09-05)All
ioctl()commands that used an integer argument now take a pointer to an integer. Where it makes sense, ioctls will return the actual new value in the integer pointed to by the argument, a common convention in the V4L2 API. The affected ioctls are: VIDIOC_PREVIEW, VIDIOC_STREAMON, VIDIOC_STREAMOFF, VIDIOC_S_FREQ, VIDIOC_S_INPUT, VIDIOC_S_OUTPUT, VIDIOC_S_EFFECT. For exampleerr = ioctl (fd, VIDIOC_XXX, V4L2_XXX);
becomes
int a = V4L2_XXX; err = ioctl(fd, VIDIOC_XXX, &a);
All the different get- and set-format commands were swept into one VIDIOC_G_FMT and VIDIOC_S_FMT ioctl taking a
union anda type field selecting theunion memberas parameter. Purpose is to simplify the API by eliminating several ioctls and to allow new and driver private data streams without adding new ioctls.This change obsoletes the following ioctls:
VIDIOC_S_INFMT,VIDIOC_G_INFMT,VIDIOC_S_OUTFMT,VIDIOC_G_OUTFMT,VIDIOC_S_VBIFMTandVIDIOC_G_VBIFMT. The image formatstruct v4l2_formatwas renamed tostruct v4l2_pix_format, whilestruct v4l2_formatis now the enveloping structure for all format negotiations.Similar to the changes above, the
VIDIOC_G_PARMandVIDIOC_S_PARMioctls were merged withVIDIOC_G_OUTPARMandVIDIOC_S_OUTPARM. Atypefield in the newstruct v4l2_streamparmselects the respectiveunion member.This change obsoletes the
VIDIOC_G_OUTPARMandVIDIOC_S_OUTPARMioctls.Control enumeration was simplified, and two new control flags were introduced and one dropped. The
catnamefield was replaced by agroupfield.Drivers can now flag unsupported and temporarily unavailable controls with
V4L2_CTRL_FLAG_DISABLEDandV4L2_CTRL_FLAG_GRABBEDrespectively. Thegroupname indicates a possibly narrower classification than thecategory. In other words, there may be multiple groups within a category. Controls within a group would typically be drawn within a group box. Controls in different categories might have a greater separation, or may even appear in separate windows.The
struct v4l2_buffertimestampwas changed to a 64 bit integer, containing the sampling or output time of the frame in nanoseconds. Additionally timestamps will be in absolute system time, not starting from zero at the beginning of a stream. The data type name for timestamps is stamp_t, defined as a signed 64-bit integer. Output devices should not send a buffer out until the time in the timestamp field has arrived. I would like to follow SGI’s lead, and adopt a multimedia timestamping system like their UST (Unadjusted System Time). See http://web.archive.org/web/*/http://reality.sgi.com /cpirazzi_engr/lg/time/intro.html. UST uses timestamps that are 64-bit signed integers (notstruct timeval’s) and given in nanosecond units. The UST clock starts at zero when the system is booted and runs continuously and uniformly. It takes a little over 292 years for UST to overflow. There is no way to set the UST clock. The regular Linux time-of-day clock can be changed periodically, which would cause errors if it were being used for timestamping a multimedia stream. A real UST style clock will require some support in the kernel that is not there yet. But in anticipation, I will change the timestamp field to a 64-bit integer, and I will change thev4l2_masterclock_gettime()function (used only by drivers) to return a 64-bit integer.A
sequencefield was added tostruct v4l2_buffer. Thesequencefield counts captured frames, it is ignored by output devices. When a capture driver drops a frame, the sequence number of that frame is skipped.
6.2.6. V4L2 Version 0.20 incremental changes¶
1999-12-23: In struct v4l2_vbi_format the
reserved1 field became offset. Previously drivers were required
to clear the reserved1 field.
2000-01-13: The V4L2_FMT_FLAG_NOT_INTERLACED flag was added.
2000-07-31: The linux/poll.h header is now included by
videodev.h for compatibility with the original videodev.h file.
2000-11-20: V4L2_TYPE_VBI_OUTPUT and V4L2_PIX_FMT_Y41P were
added.
2000-11-25: V4L2_TYPE_VBI_INPUT was added.
2000-12-04: A couple typos in symbol names were fixed.
2001-01-18: To avoid namespace conflicts the fourcc macro defined in
the videodev.h header file was renamed to v4l2_fourcc.
2001-01-25: A possible driver-level compatibility problem between the
videodev.h file in Linux 2.4.0 and the videodev.h file included
in the videodevX patch was fixed. Users of an earlier version of
videodevX on Linux 2.4.0 should recompile their V4L and V4L2
drivers.
2001-01-26: A possible kernel-level incompatibility between the
videodev.h file in the videodevX patch and the videodev.h
file in Linux 2.2.x with devfs patches applied was fixed.
2001-03-02: Certain V4L ioctls which pass data in both direction although they are defined with read-only parameter, did not work correctly through the backward compatibility layer. [Solution?]
2001-04-13: Big endian 16-bit RGB formats were added.
2001-09-17: New YUV formats and the
VIDIOC_G_FREQUENCY and
VIDIOC_S_FREQUENCY ioctls were added.
(The old VIDIOC_G_FREQ and VIDIOC_S_FREQ ioctls did not take
multiple tuners into account.)
2000-09-18: V4L2_BUF_TYPE_VBI was added. This may break
compatibility as the VIDIOC_G_FMT and
VIDIOC_S_FMT ioctls may fail now if the
struct v4l2_fmt type field does not contain
V4L2_BUF_TYPE_VBI. In the documentation of the struct v4l2_vbi_format`,
the offset field the ambiguous phrase “rising edge” was changed to
“leading edge”.
6.2.7. V4L2 Version 0.20 2000-11-23¶
A number of changes were made to the raw VBI interface.
Figures clarifying the line numbering scheme were added to the V4L2 API specification. The
start[0] andstart[1] fields no longer count line numbers beginning at zero. Rationale: a) The previous definition was unclear. b) Thestart[] values are ordinal numbers. c) There is no point in inventing a new line numbering scheme. We now use line number as defined by ITU-R, period. Compatibility: Add one to the start values. Applications depending on the previous semantics may not function correctly.The restriction “count[0] > 0 and count[1] > 0” has been relaxed to “(count[0] + count[1]) > 0”. Rationale: Drivers may allocate resources at scan line granularity and some data services are transmitted only on the first field. The comment that both
countvalues will usually be equal is misleading and pointless and has been removed. This change breaks compatibility with earlier versions: Drivers may returnEINVAL, applications may not function correctly.Drivers are again permitted to return negative (unknown) start values as proposed earlier. Why this feature was dropped is unclear. This change may break compatibility with applications depending on the start values being positive. The use of
EBUSYandEINVALerror codes with the VIDIOC_S_FMT ioctl was clarified. TheEBUSYerror code was finally documented, and thereserved2field which was previously mentioned only in thevideodev.hheader file.New buffer types
V4L2_TYPE_VBI_INPUTandV4L2_TYPE_VBI_OUTPUTwere added. The former is an alias for the oldV4L2_TYPE_VBI, the latter was missing in thevideodev.hfile.
6.2.8. V4L2 Version 0.20 2002-07-25¶
Added sliced VBI interface proposal.
6.2.9. V4L2 in Linux 2.5.46, 2002-10¶
Around October-November 2002, prior to an announced feature freeze of Linux 2.5, the API was revised, drawing from experience with V4L2 0.20. This unnamed version was finally merged into Linux 2.5.46.
As specified in Related Devices, drivers must make related device functions available under all minor device numbers.
The
open()function requires access modeO_RDWRregardless of the device type. All V4L2 drivers exchanging data with applications must support theO_NONBLOCKflag. TheO_NOIOflag, a V4L2 symbol which aliased the meaninglessO_TRUNCto indicate accesses without data exchange (panel applications) was dropped. Drivers must stay in “panel mode” until the application attempts to initiate a data exchange, see Opening and Closing Devices.The
struct v4l2_capabilitychanged dramatically. Note that also the size of the structure changed, which is encoded in the ioctl request code, thus older V4L2 devices will respond with anEINVALerror code to the new ioctl VIDIOC_QUERYCAP ioctl.There are new fields to identify the driver, a new RDS device function
V4L2_CAP_RDS_CAPTURE, theV4L2_CAP_AUDIOflag indicates if the device has any audio connectors, another I/O capability V4L2_CAP_ASYNCIO can be flagged. In response to these changes thetypefield became a bit set and was merged into theflagsfield.V4L2_FLAG_TUNERwas renamed toV4L2_CAP_TUNER,V4L2_CAP_VIDEO_OVERLAYreplacedV4L2_FLAG_PREVIEWandV4L2_CAP_VBI_CAPTUREandV4L2_CAP_VBI_OUTPUTreplacedV4L2_FLAG_DATA_SERVICE.V4L2_FLAG_READandV4L2_FLAG_WRITEwere merged intoV4L2_CAP_READWRITE.The redundant fields
inputs,outputsandaudioswere removed. These properties can be determined as described in Video Inputs and Outputs and Audio Inputs and Outputs.The somewhat volatile and therefore barely useful fields
maxwidth,maxheight,minwidth,minheight,maxframeratewere removed. This information is available as described in Data Formats and Video Standards.V4L2_FLAG_SELECTwas removed. We believe theselect()function is important enough to require support of it in all V4L2 drivers exchanging data with applications. The redundantV4L2_FLAG_MONOCHROMEflag was removed, this information is available as described in Data Formats.In
struct v4l2_inputtheassoc_audiofield and thecapabilityfield and its only flagV4L2_INPUT_CAP_AUDIOwas replaced by the newaudiosetfield. Instead of linking one video input to one audio input this field reports all audio inputs this video input combines with.New fields are
tuner(reversing the former link from tuners to video inputs),stdandstatus.Accordingly
struct v4l2_outputlost itscapabilityandassoc_audiofields.audioset,modulatorandstdwhere added instead.The
struct v4l2_audiofieldaudiowas renamed toindex, for consistency with other structures. A new capability flagV4L2_AUDCAP_STEREOwas added to indicated if the audio input in question supports stereo sound.V4L2_AUDCAP_EFFECTSand the correspondingV4L2_AUDMODEflags where removed. This can be easily implemented using controls. (However the same applies to AVL which is still there.)Again for consistency the
struct v4l2_audiooutfieldaudiowas renamed toindex.The
struct v4l2_tunerinputfield was replaced by anindexfield, permitting devices with multiple tuners. The link between video inputs and tuners is now reversed, inputs point to their tuner. Thestdsubstructure became a simple set (more about this below) and moved intostruct v4l2_input. Atypefield was added.Accordingly in
struct v4l2_modulatortheoutputwas replaced by anindexfield.In
struct v4l2_frequencytheportfield was replaced by atunerfield containing the respective tuner or modulator index number. A tunertypefield was added and thereservedfield became larger for future extensions (satellite tuners in particular).The idea of completely transparent video standards was dropped. Experience showed that applications must be able to work with video standards beyond presenting the user a menu. Instead of enumerating supported standards with an ioctl applications can now refer to standards by v4l2_std_id and symbols defined in the
videodev2.hheader file. For details see Video Standards. The VIDIOC_G_STD and VIDIOC_S_STD now take a pointer to this type as argument. ioctl VIDIOC_QUERYSTD, VIDIOC_SUBDEV_QUERYSTD was added to autodetect the received standard, if the hardware has this capability. Instruct v4l2_standardanindexfield was added for ioctl VIDIOC_ENUMSTD, VIDIOC_SUBDEV_ENUMSTD. A v4l2_std_id field namedidwas added as machine readable identifier, also replacing thetransmissionfield. The misleadingframeratefield was renamed toframeperiod. The now obsoletecolorstandardinformation, originally needed to distguish between variations of standards, were removed.Struct
v4l2_enumstdceased to be. ioctl VIDIOC_ENUMSTD, VIDIOC_SUBDEV_ENUMSTD now takes a pointer to astruct v4l2_standarddirectly. The information which standards are supported by a particular video input or output moved intostruct v4l2_inputandstruct v4l2_outputfields namedstd, respectively.The struct v4l2_queryctrl fields
categoryandgroupdid not catch on and/or were not implemented as expected and therefore removed.The VIDIOC_TRY_FMT ioctl was added to negotiate data formats as with VIDIOC_S_FMT, but without the overhead of programming the hardware and regardless of I/O in progress.
In
struct v4l2_formatthefmtunion wasextended to containstruct v4l2_window. All image format negotiations are now possible withVIDIOC_G_FMT,VIDIOC_S_FMTandVIDIOC_TRY_FMT; ioctl. TheVIDIOC_G_WINandVIDIOC_S_WINioctls to prepare for a video overlay were removed. Thetypefield changed to typeenum v4l2_buf_typeand the buffer type names changed as follows.Old defines
V4L2_BUF_TYPE_CAPTUREV4L2_BUF_TYPE_VIDEO_CAPTUREV4L2_BUF_TYPE_CODECINOmitted for now
V4L2_BUF_TYPE_CODECOUTOmitted for now
V4L2_BUF_TYPE_EFFECTSINOmitted for now
V4L2_BUF_TYPE_EFFECTSIN2Omitted for now
V4L2_BUF_TYPE_EFFECTSOUTOmitted for now
V4L2_BUF_TYPE_VIDEOOUTV4L2_BUF_TYPE_VIDEO_OUTPUT-V4L2_BUF_TYPE_VIDEO_OVERLAY-V4L2_BUF_TYPE_VBI_CAPTURE-V4L2_BUF_TYPE_VBI_OUTPUT-V4L2_BUF_TYPE_SLICED_VBI_CAPTURE-V4L2_BUF_TYPE_SLICED_VBI_OUTPUTV4L2_BUF_TYPE_PRIVATE_BASEV4L2_BUF_TYPE_PRIVATE(but this is deprecated)In
struct v4l2_fmtdescaenum v4l2_buf_typefield namedtypewas added as instruct v4l2_format. TheVIDIOC_ENUM_FBUFFMTioctl is no longer needed and was removed. These calls can be replaced by ioctl VIDIOC_ENUM_FMT with typeV4L2_BUF_TYPE_VIDEO_OVERLAY.In
struct v4l2_pix_formatthedepthfield was removed, assuming applications which recognize the format by its four-character-code already know the color depth, and others do not care about it. The same rationale lead to the removal of theV4L2_FMT_FLAG_COMPRESSEDflag. TheV4L2_FMT_FLAG_SWCONVECOMPRESSEDflag was removed because drivers are not supposed to convert images in kernel space. A user library of conversion functions should be provided instead. TheV4L2_FMT_FLAG_BYTESPERLINEflag was redundant. Applications can set thebytesperlinefield to zero to get a reasonable default. Since the remaining flags were replaced as well, theflagsfield itself was removed.The interlace flags were replaced by a
enum v4l2_fieldvalue in a newly addedfieldfield.Old flag
enum v4l2_fieldV4L2_FMT_FLAG_NOT_INTERLACED?
V4L2_FMT_FLAG_INTERLACED=V4L2_FMT_FLAG_COMBINEDV4L2_FIELD_INTERLACEDV4L2_FMT_FLAG_TOPFIELD=V4L2_FMT_FLAG_ODDFIELDV4L2_FIELD_TOPV4L2_FMT_FLAG_BOTFIELD=V4L2_FMT_FLAG_EVENFIELDV4L2_FIELD_BOTTOM-V4L2_FIELD_SEQ_TB-V4L2_FIELD_SEQ_BT-V4L2_FIELD_ALTERNATEThe color space flags were replaced by a
enum v4l2_colorspacevalue in a newly addedcolorspacefield, where one ofV4L2_COLORSPACE_SMPTE170M,V4L2_COLORSPACE_BT878,V4L2_COLORSPACE_470_SYSTEM_MorV4L2_COLORSPACE_470_SYSTEM_BGreplacesV4L2_FMT_CS_601YUV.In
struct v4l2_requestbuffersthetypefield was properly defined asenum v4l2_buf_type. Buffer types changed as mentioned above. A newmemoryfield of typeenum v4l2_memorywas added to distinguish between I/O methods using buffers allocated by the driver or the application. See Input/Output for details.In
struct v4l2_bufferthetypefield was properly defined asenum v4l2_buf_type. Buffer types changed as mentioned above. Afieldfield of typeenum v4l2_fieldwas added to indicate if a buffer contains a top or bottom field. The old field flags were removed. Since no unadjusted system time clock was added to the kernel as planned, thetimestampfield changed back from type stamp_t, an unsigned 64 bit integer expressing the sample time in nanoseconds, tostruct timeval. With the addition of a second memory mapping method theoffsetfield moved into unionm, and a newmemoryfield of typeenum v4l2_memorywas added to distinguish between I/O methods. See Input/Output for details.The
V4L2_BUF_REQ_CONTIGflag was used by the V4L compatibility layer, after changes to this code it was no longer needed. TheV4L2_BUF_ATTR_DEVICEMEMflag would indicate if the buffer was indeed allocated in device memory rather than DMA-able system memory. It was barely useful and so was removed.In
struct v4l2_framebufferthebase[3]array anticipating double- and triple-buffering in off-screen video memory, however without defining a synchronization mechanism, was replaced by a single pointer. TheV4L2_FBUF_CAP_SCALEUPandV4L2_FBUF_CAP_SCALEDOWNflags were removed. Applications can determine this capability more accurately using the new cropping and scaling interface. TheV4L2_FBUF_CAP_CLIPPINGflag was replaced byV4L2_FBUF_CAP_LIST_CLIPPINGandV4L2_FBUF_CAP_BITMAP_CLIPPING.In
struct v4l2_clipthex,y,widthandheightfield moved into acsubstructure of typestruct v4l2_rect. Thexandyfields were renamed toleftandtop, i. e. offsets to a context dependent origin.In
struct v4l2_windowthex,y,widthandheightfield moved into awsubstructure as above. Afieldfield of typeenum v4l2_fieldwas added to distinguish between field and frame (interlaced) overlay.The digital zoom interface, including struct
v4l2_zoomcap, structv4l2_zoom,V4L2_ZOOM_NONCAPandV4L2_ZOOM_WHILESTREAMINGwas replaced by a new cropping and scaling interface. The previously unusedstruct v4l2_cropcapandstruct v4l2_cropwhere redefined for this purpose. See Image Cropping, Insertion and Scaling -- the CROP API for details.In
struct v4l2_vbi_formattheSAMPLE_FORMATfield now contains a four-character-code as used to identify video image formats andV4L2_PIX_FMT_GREYreplaces theV4L2_VBI_SF_UBYTEdefine. Thereservedfield was extended.In
struct v4l2_captureparmthe type of thetimeperframefield changed from unsigned long tostruct v4l2_fract. This allows the accurate expression of multiples of the NTSC-M frame rate 30000 / 1001. A new fieldreadbufferswas added to control the driver behaviour in read I/O mode.Similar changes were made to
struct v4l2_outputparm.The struct
v4l2_performanceandVIDIOC_G_PERFioctl were dropped. Except when using the read/write I/O method, which is limited anyway, this information is already available to applications.The example transformation from RGB to YCbCr color space in the old V4L2 documentation was inaccurate, this has been corrected in Image Formats.
6.2.10. V4L2 2003-06-19¶
A new capability flag
V4L2_CAP_RADIOwas added for radio devices. Prior to this change radio devices would identify solely by having exactly one tuner whose type field readsV4L2_TUNER_RADIO.An optional driver access priority mechanism was added, see Application Priority for details.
The audio input and output interface was found to be incomplete.
Previously the VIDIOC_G_AUDIO ioctl would enumerate the available audio inputs. An ioctl to determine the current audio input, if more than one combines with the current video input, did not exist. So
VIDIOC_G_AUDIOwas renamed toVIDIOC_G_AUDIO_OLD, this ioctl was removed on Kernel 2.6.39. The ioctl VIDIOC_ENUMAUDIO ioctl was added to enumerate audio inputs, while VIDIOC_G_AUDIO now reports the current audio input.The same changes were made to VIDIOC_G_AUDOUT and VIDIOC_ENUMAUDOUT.
Until further the “videodev” module will automatically translate between the old and new ioctls, but drivers and applications must be updated to successfully compile again.
The ioctl VIDIOC_OVERLAY ioctl was incorrectly defined with write-read parameter. It was changed to write-only, while the write-read version was renamed to
VIDIOC_OVERLAY_OLD. The old ioctl was removed on Kernel 2.6.39. Until further the “videodev” kernel module will automatically translate to the new version, so drivers must be recompiled, but not applications.Video Overlay Interface incorrectly stated that clipping rectangles define regions where the video can be seen. Correct is that clipping rectangles define regions where no video shall be displayed and so the graphics surface can be seen.
The VIDIOC_S_PARM and VIDIOC_S_CTRL ioctls were defined with write-only parameter, inconsistent with other ioctls modifying their argument. They were changed to write-read, while a
_OLDsuffix was added to the write-only versions. The old ioctls were removed on Kernel 2.6.39. Drivers and applications assuming a constant parameter need an update.
6.2.11. V4L2 2003-11-05¶
In RGB Formats the following pixel formats were incorrectly transferred from Bill Dirks’ V4L2 specification. Descriptions below refer to bytes in memory, in ascending address order.
Symbol
In this document prior to revision 0.5
Corrected
V4L2_PIX_FMT_RGB24B, G, R
R, G, B
V4L2_PIX_FMT_BGR24R, G, B
B, G, R
V4L2_PIX_FMT_RGB32B, G, R, X
R, G, B, X
V4L2_PIX_FMT_BGR32R, G, B, X
B, G, R, X
The
V4L2_PIX_FMT_BGR24example was always correct.In Image Properties the mapping of the V4L
VIDEO_PALETTE_RGB24andVIDEO_PALETTE_RGB32formats to V4L2 pixel formats was accordingly corrected.Unrelated to the fixes above, drivers may still interpret some V4L2 RGB pixel formats differently. These issues have yet to be addressed, for details see RGB Formats.
6.2.12. V4L2 in Linux 2.6.6, 2004-05-09¶
The ioctl VIDIOC_CROPCAP ioctl was incorrectly defined with read-only parameter. It is now defined as write-read ioctl, while the read-only version was renamed to
VIDIOC_CROPCAP_OLD. The old ioctl was removed on Kernel 2.6.39.
6.2.13. V4L2 in Linux 2.6.8¶
A new field
input(formerreserved[0]) was added to thestruct v4l2_buffer. Purpose of this field is to alternate between video inputs (e. g. cameras) in step with the video capturing process. This function must be enabled with the newV4L2_BUF_FLAG_INPUTflag. Theflagsfield is no longer read-only.
6.2.14. V4L2 spec erratum 2004-08-01¶
The return value of the V4L2 open() function was incorrectly documented.
Audio output ioctls end in -AUDOUT, not -AUDIOOUT.
In the Current Audio Input example the
VIDIOC_G_AUDIOioctl took the wrong argument.The documentation of the ioctl VIDIOC_QBUF, VIDIOC_DQBUF and VIDIOC_DQBUF ioctls did not mention the
struct v4l2_buffermemoryfield. It was also missing from examples. Also on theVIDIOC_DQBUFpage theEIOerror code was not documented.
6.2.15. V4L2 in Linux 2.6.14¶
A new sliced VBI interface was added. It is documented in Sliced VBI Data Interface and replaces the interface first proposed in V4L2 specification 0.8.
6.2.16. V4L2 in Linux 2.6.15¶
The ioctl VIDIOC_LOG_STATUS ioctl was added.
New video standards
V4L2_STD_NTSC_443,V4L2_STD_SECAM_LC,V4L2_STD_SECAM_DK(a set of SECAM D, K and K1), andV4L2_STD_ATSC(a set ofV4L2_STD_ATSC_8_VSBandV4L2_STD_ATSC_16_VSB) were defined. Note theV4L2_STD_525_60set now includesV4L2_STD_NTSC_443. See also typedef v4l2_std_id.The
VIDIOC_G_COMPandVIDIOC_S_COMPioctl were renamed toVIDIOC_G_MPEGCOMPandVIDIOC_S_MPEGCOMPrespectively. Their argument was replaced by a structv4l2_mpeg_compressionpointer. (TheVIDIOC_G_MPEGCOMPandVIDIOC_S_MPEGCOMPioctls where removed in Linux 2.6.25.)
6.2.17. V4L2 spec erratum 2005-11-27¶
The capture example in Video Capture Example called the VIDIOC_S_CROP ioctl without checking if cropping is supported. In the video standard selection example in Video Standards the VIDIOC_S_STD call used the wrong argument type.
6.2.18. V4L2 spec erratum 2006-01-10¶
The
V4L2_IN_ST_COLOR_KILLflag instruct v4l2_inputnot only indicates if the color killer is enabled, but also if it is active. (The color killer disables color decoding when it detects no color in the video signal to improve the image quality.)VIDIOC_S_PARM is a write-read ioctl, not write-only as stated on its reference page. The ioctl changed in 2003 as noted above.
6.2.19. V4L2 spec erratum 2006-02-03¶
In
struct v4l2_captureparmandstruct v4l2_outputparmthetimeperframefield gives the time in seconds, not microseconds.
6.2.20. V4L2 spec erratum 2006-02-04¶
The
clipsfield instruct v4l2_windowmust point to an array ofstruct v4l2_clip, not a linked list, because drivers ignore thestruct v4l2_clip.nextpointer.
6.2.21. V4L2 in Linux 2.6.17¶
New video standard macros were added:
V4L2_STD_NTSC_M_KR(NTSC M South Korea), and the setsV4L2_STD_MN,V4L2_STD_B,V4L2_STD_GHandV4L2_STD_DK. TheV4L2_STD_NTSCandV4L2_STD_SECAMsets now includeV4L2_STD_NTSC_M_KRandV4L2_STD_SECAM_LCrespectively.A new
V4L2_TUNER_MODE_LANG1_LANG2was defined to record both languages of a bilingual program. The use ofV4L2_TUNER_MODE_STEREOfor this purpose is deprecated now. See the VIDIOC_G_TUNER section for details.
6.2.22. V4L2 spec erratum 2006-09-23 (Draft 0.15)¶
In various places
V4L2_BUF_TYPE_SLICED_VBI_CAPTUREandV4L2_BUF_TYPE_SLICED_VBI_OUTPUTof the sliced VBI interface were not mentioned along with other buffer types.In VIDIOC_G_AUDIO it was clarified that the
struct v4l2_audiomodefield is a flags field.ioctl VIDIOC_QUERYCAP did not mention the sliced VBI and radio capability flags.
In VIDIOC_G_FREQUENCY it was clarified that applications must initialize the tuner
typefield ofstruct v4l2_frequencybefore calling VIDIOC_S_FREQUENCY.The
reservedarray instruct v4l2_requestbuffershas 2 elements, not 32.In Video Output Interface and Raw VBI Data Interface the device file names
/dev/voutwhich never caught on were replaced by/dev/video.With Linux 2.6.15 the possible range for VBI device minor numbers was extended from 224-239 to 224-255. Accordingly device file names
/dev/vbi0to/dev/vbi31are possible now.
6.2.23. V4L2 in Linux 2.6.18¶
New ioctls VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS and VIDIOC_TRY_EXT_CTRLS were added, a flag to skip unsupported controls with ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU, new control types
V4L2_CTRL_TYPE_INTEGER64andV4L2_CTRL_TYPE_CTRL_CLASS(enum v4l2_ctrl_type), and new control flagsV4L2_CTRL_FLAG_READ_ONLY,V4L2_CTRL_FLAG_UPDATE,V4L2_CTRL_FLAG_INACTIVEandV4L2_CTRL_FLAG_SLIDER(Control Flags). See Extended Controls API for details.
6.2.24. V4L2 in Linux 2.6.19¶
In
struct v4l2_sliced_vbi_capa buffer type field was added replacing a reserved field. Note on architectures where the size ofenum typesdiffers from int types the size of the structure changed. The VIDIOC_G_SLICED_VBI_CAP ioctl was redefined from being read-only to write-read. Applications must initialize the type field and clear the reserved fields now. These changes may break the compatibility with older drivers and applications.The ioctls ioctl VIDIOC_ENUM_FRAMESIZES and ioctl VIDIOC_ENUM_FRAMEINTERVALS were added.
A new pixel format
V4L2_PIX_FMT_RGB444(RGB Formats) was added.
6.2.25. V4L2 spec erratum 2006-10-12 (Draft 0.17)¶
V4L2_PIX_FMT_HM12(Reserved Image Formats) is a YUV 4:2:0, not 4:2:2 format.
6.2.26. V4L2 in Linux 2.6.21¶
The
videodev2.hheader file is now dual licensed under GNU General Public License version two or later, and under a 3-clause BSD-style license.
6.2.27. V4L2 in Linux 2.6.22¶
Two new field orders
V4L2_FIELD_INTERLACED_TBandV4L2_FIELD_INTERLACED_BTwere added. Seeenum v4l2_fieldfor details.Three new clipping/blending methods with a global or straight or inverted local alpha value were added to the video overlay interface. See the description of the VIDIOC_G_FBUF and VIDIOC_S_FBUF ioctls for details.
A new
global_alphafield was added tostruct v4l2_window, extending the structure. This may break compatibility with applications using astruct v4l2_windowdirectly. However the VIDIOC_G/S/TRY_FMT ioctls, which take a pointer to astruct v4l2_formatparent structure with padding bytes at the end, are not affected.The format of the
chromakeyfield instruct v4l2_windowchanged from “host order RGB32” to a pixel value in the same format as the framebuffer. This may break compatibility with existing applications. Drivers supporting the “host order RGB32” format are not known.
6.2.28. V4L2 in Linux 2.6.24¶
The pixel formats
V4L2_PIX_FMT_PAL8,V4L2_PIX_FMT_YUV444,V4L2_PIX_FMT_YUV555,V4L2_PIX_FMT_YUV565andV4L2_PIX_FMT_YUV32were added.
6.2.29. V4L2 in Linux 2.6.25¶
The pixel formats V4L2_PIX_FMT_Y16 and V4L2_PIX_FMT_SBGGR16 were added.
New controls
V4L2_CID_POWER_LINE_FREQUENCY,V4L2_CID_HUE_AUTO,V4L2_CID_WHITE_BALANCE_TEMPERATURE,V4L2_CID_SHARPNESSandV4L2_CID_BACKLIGHT_COMPENSATIONwere added. The controlsV4L2_CID_BLACK_LEVEL,V4L2_CID_WHITENESS,V4L2_CID_HCENTERandV4L2_CID_VCENTERwere deprecated.A Camera controls class was added, with the new controls
V4L2_CID_EXPOSURE_AUTO,V4L2_CID_EXPOSURE_ABSOLUTE,V4L2_CID_EXPOSURE_AUTO_PRIORITY,V4L2_CID_PAN_RELATIVE,V4L2_CID_TILT_RELATIVE,V4L2_CID_PAN_RESET,V4L2_CID_TILT_RESET,V4L2_CID_PAN_ABSOLUTE,V4L2_CID_TILT_ABSOLUTE,V4L2_CID_FOCUS_ABSOLUTE,V4L2_CID_FOCUS_RELATIVEandV4L2_CID_FOCUS_AUTO.The
VIDIOC_G_MPEGCOMPandVIDIOC_S_MPEGCOMPioctls, which were superseded by the extended controls interface in Linux 2.6.18, where finally removed from thevideodev2.hheader file.
6.2.30. V4L2 in Linux 2.6.26¶
The pixel formats
V4L2_PIX_FMT_Y16andV4L2_PIX_FMT_SBGGR16were added.Added user controls
V4L2_CID_CHROMA_AGCandV4L2_CID_COLOR_KILLER.
6.2.31. V4L2 in Linux 2.6.27¶
The ioctl VIDIOC_S_HW_FREQ_SEEK ioctl and the
V4L2_CAP_HW_FREQ_SEEKcapability were added.The pixel formats
V4L2_PIX_FMT_YVYU,V4L2_PIX_FMT_PCA501,V4L2_PIX_FMT_PCA505,V4L2_PIX_FMT_PCA508,V4L2_PIX_FMT_PCA561,V4L2_PIX_FMT_SGBRG8,V4L2_PIX_FMT_PAC207andV4L2_PIX_FMT_PJPGwere added.
6.2.32. V4L2 in Linux 2.6.28¶
Added
V4L2_MPEG_AUDIO_ENCODING_AACandV4L2_MPEG_AUDIO_ENCODING_AC3MPEG audio encodings.Added
V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVCMPEG video encoding.The pixel formats
V4L2_PIX_FMT_SGRBG10andV4L2_PIX_FMT_SGRBG10DPCM8were added.
6.2.33. V4L2 in Linux 2.6.29¶
The
VIDIOC_G_CHIP_IDENTioctl was renamed toVIDIOC_G_CHIP_IDENT_OLDandVIDIOC_DBG_G_CHIP_IDENTwas introduced in its place. The old structv4l2_chip_identwas renamed to structv4l2_chip_ident_old.The pixel formats
V4L2_PIX_FMT_VYUY,V4L2_PIX_FMT_NV16andV4L2_PIX_FMT_NV61were added.Added camera controls
V4L2_CID_ZOOM_ABSOLUTE,V4L2_CID_ZOOM_RELATIVE,V4L2_CID_ZOOM_CONTINUOUSandV4L2_CID_PRIVACY.
6.2.34. V4L2 in Linux 2.6.30¶
New control flag
V4L2_CTRL_FLAG_WRITE_ONLYwas added.New control
V4L2_CID_COLORFXwas added.
6.2.35. V4L2 in Linux 2.6.32¶
In order to be easier to compare a V4L2 API and a kernel version, now V4L2 API is numbered using the Linux Kernel version numeration.
Finalized the RDS capture API. See RDS Interface for more information.
Added new capabilities for modulators and RDS encoders.
Add description for libv4l API.
Added support for string controls via new type
V4L2_CTRL_TYPE_STRING.Added
V4L2_CID_BAND_STOP_FILTERdocumentation.Added FM Modulator (FM TX) Extended Control Class:
V4L2_CTRL_CLASS_FM_TXand their Control IDs.Added FM Receiver (FM RX) Extended Control Class:
V4L2_CTRL_CLASS_FM_RXand their Control IDs.Added Remote Controller chapter, describing the default Remote Controller mapping for media devices.
6.2.36. V4L2 in Linux 2.6.33¶
Added support for Digital Video timings in order to support HDTV receivers and transmitters.
6.2.37. V4L2 in Linux 2.6.34¶
Added
V4L2_CID_IRIS_ABSOLUTEandV4L2_CID_IRIS_RELATIVEcontrols to the Camera controls class.
6.2.38. V4L2 in Linux 2.6.37¶
Remove the vtx (videotext/teletext) API. This API was no longer used and no hardware exists to verify the API. Nor were any userspace applications found that used it. It was originally scheduled for removal in 2.6.35.
6.2.39. V4L2 in Linux 2.6.39¶
The old VIDIOC_*_OLD symbols and V4L1 support were removed.
Multi-planar API added. Does not affect the compatibility of current drivers and applications. See multi-planar API for details.
6.2.40. V4L2 in Linux 3.1¶
VIDIOC_QUERYCAP now returns a per-subsystem version instead of a per-driver one.
Standardize an error code for invalid ioctl.
Added V4L2_CTRL_TYPE_BITMASK.
6.2.41. V4L2 in Linux 3.2¶
V4L2_CTRL_FLAG_VOLATILE was added to signal volatile controls to userspace.
Add selection API for extended control over cropping and composing. Does not affect the compatibility of current drivers and applications. See selection API for details.
6.2.42. V4L2 in Linux 3.3¶
Added
V4L2_CID_ALPHA_COMPONENTcontrol to the User controls class.Added the device_caps field to
struct v4l2_capabilitiesand added the new V4L2_CAP_DEVICE_CAPS capability.
6.2.43. V4L2 in Linux 3.4¶
Extended the DV Timings API: ioctl VIDIOC_ENUM_DV_TIMINGS, VIDIOC_SUBDEV_ENUM_DV_TIMINGS, ioctl VIDIOC_QUERY_DV_TIMINGS and ioctl VIDIOC_DV_TIMINGS_CAP, VIDIOC_SUBDEV_DV_TIMINGS_CAP.
6.2.44. V4L2 in Linux 3.5¶
Added integer menus, the new type will be V4L2_CTRL_TYPE_INTEGER_MENU.
Added selection API for V4L2 subdev interface: ioctl VIDIOC_SUBDEV_G_SELECTION, VIDIOC_SUBDEV_S_SELECTION and VIDIOC_SUBDEV_S_SELECTION.
Added
V4L2_COLORFX_ANTIQUE,V4L2_COLORFX_ART_FREEZE,V4L2_COLORFX_AQUA,V4L2_COLORFX_SILHOUETTE,V4L2_COLORFX_SOLARIZATION,V4L2_COLORFX_VIVIDandV4L2_COLORFX_ARBITRARY_CBCRmenu items to theV4L2_CID_COLORFXcontrol.Added
V4L2_CID_COLORFX_CBCRcontrol.Added camera controls
V4L2_CID_AUTO_EXPOSURE_BIAS,V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE,V4L2_CID_IMAGE_STABILIZATION,V4L2_CID_ISO_SENSITIVITY,V4L2_CID_ISO_SENSITIVITY_AUTO,V4L2_CID_EXPOSURE_METERING,V4L2_CID_SCENE_MODE,V4L2_CID_3A_LOCK,V4L2_CID_AUTO_FOCUS_START,V4L2_CID_AUTO_FOCUS_STOP,V4L2_CID_AUTO_FOCUS_STATUSandV4L2_CID_AUTO_FOCUS_RANGE.
6.2.45. V4L2 in Linux 3.6¶
Replaced
inputinstruct v4l2_bufferbyreserved2and removedV4L2_BUF_FLAG_INPUT.Added V4L2_CAP_VIDEO_M2M and V4L2_CAP_VIDEO_M2M_MPLANE capabilities.
Added support for frequency band enumerations: ioctl VIDIOC_ENUM_FREQ_BANDS.
6.2.46. V4L2 in Linux 3.9¶
Added timestamp types to
flagsfield instruct v4l2_buffer. See Buffer Flags.Added
V4L2_EVENT_CTRL_CH_RANGEcontrol event changes flag. See Control Changes.
6.2.47. V4L2 in Linux 3.10¶
Removed obsolete and unused DV_PRESET ioctls VIDIOC_G_DV_PRESET, VIDIOC_S_DV_PRESET, VIDIOC_QUERY_DV_PRESET and VIDIOC_ENUM_DV_PRESET. Remove the related v4l2_input/output capability flags V4L2_IN_CAP_PRESETS and V4L2_OUT_CAP_PRESETS.
Added new debugging ioctl ioctl VIDIOC_DBG_G_CHIP_INFO.
6.2.48. V4L2 in Linux 3.11¶
Remove obsolete
VIDIOC_DBG_G_CHIP_IDENTioctl.
6.2.49. V4L2 in Linux 3.14¶
In
struct v4l2_rect, the type ofwidthandheightfields changed from _s32 to _u32.
6.2.50. V4L2 in Linux 3.15¶
Added Software Defined Radio (SDR) Interface.
6.2.51. V4L2 in Linux 3.16¶
Added event V4L2_EVENT_SOURCE_CHANGE.
6.2.52. V4L2 in Linux 3.17¶
Extended
struct v4l2_pix_format. Added format flags.Added compound control types and VIDIOC_QUERY_EXT_CTRL.
6.2.53. V4L2 in Linux 3.18¶
Added
V4L2_CID_PAN_SPEEDandV4L2_CID_TILT_SPEEDcamera controls.
6.2.54. V4L2 in Linux 3.19¶
Rewrote Colorspace chapter, added new
enum v4l2_ycbcr_encodingandenum v4l2_quantizationfields tostruct v4l2_pix_format,struct v4l2_pix_format_mplaneandstruct v4l2_mbus_framefmt.
6.2.55. V4L2 in Linux 4.4¶
Renamed
V4L2_TUNER_ADCtoV4L2_TUNER_SDR. The use ofV4L2_TUNER_ADCis deprecated now.Added
V4L2_CID_RF_TUNER_RF_GAINRF Tuner control.Added transmitter support for Software Defined Radio (SDR) Interface.
6.2.56. Relation of V4L2 to other Linux multimedia APIs¶
6.2.56.1. X Video Extension¶
The X Video Extension (abbreviated XVideo or just Xv) is an extension of the X Window system, implemented for example by the XFree86 project. Its scope is similar to V4L2, an API to video capture and output devices for X clients. Xv allows applications to display live video in a window, send window contents to a TV output, and capture or output still images in XPixmaps [1]. With their implementation XFree86 makes the extension available across many operating systems and architectures.
Because the driver is embedded into the X server Xv has a number of advantages over the V4L2 video overlay interface. The driver can easily determine the overlay target, i. e. visible graphics memory or off-screen buffers for a destructive overlay. It can program the RAMDAC for a non-destructive overlay, scaling or color-keying, or the clipping functions of the video capture hardware, always in sync with drawing operations or windows moving or changing their stacking order.
To combine the advantages of Xv and V4L a special Xv driver exists in
XFree86 and XOrg, just programming any overlay capable Video4Linux
device it finds. To enable it /etc/X11/XF86Config must contain these
lines:
Section "Module"
Load "v4l"
EndSection
As of XFree86 4.2 this driver still supports only V4L ioctls, however it should work just fine with all V4L2 devices through the V4L2 backward-compatibility layer. Since V4L2 permits multiple opens it is possible (if supported by the V4L2 driver) to capture video while an X client requested video overlay. Restrictions of simultaneous capturing and overlay are discussed in Video Overlay Interface apply.
Only marginally related to V4L2, XFree86 extended Xv to support hardware YUV to RGB conversion and scaling for faster video playback, and added an interface to MPEG-2 decoding hardware. This API is useful to display images captured with V4L2 devices.
6.2.56.2. Digital Video¶
V4L2 does not support digital terrestrial, cable or satellite broadcast. A separate project aiming at digital receivers exists. You can find its homepage at https://linuxtv.org. The Linux DVB API has no connection to the V4L2 API except that drivers for hybrid hardware may support both.
6.2.56.3. Audio Interfaces¶
[to do - OSS/ALSA]
6.2.57. Experimental API Elements¶
The following V4L2 API elements are currently experimental and may change in the future.
6.2.58. Obsolete API Elements¶
The following V4L2 API elements were superseded by new interfaces and should not be implemented in new drivers.
VIDIOC_G_MPEGCOMPandVIDIOC_S_MPEGCOMPioctls. Use Extended Controls, Extended Controls API.VIDIOC_G_DV_PRESET, VIDIOC_S_DV_PRESET, VIDIOC_ENUM_DV_PRESETS and VIDIOC_QUERY_DV_PRESET ioctls. Use the DV Timings API (Digital Video (DV) Timings).
VIDIOC_SUBDEV_G_CROPandVIDIOC_SUBDEV_S_CROPioctls. UseVIDIOC_SUBDEV_G_SELECTIONandVIDIOC_SUBDEV_S_SELECTION, ioctl VIDIOC_SUBDEV_G_SELECTION, VIDIOC_SUBDEV_S_SELECTION.