Video for Linux Two API Specification

Revision 2.6.32

Michael H Schimek


    
  

Bill Dirks

Original author of the V4L2 API and documentation. 

Hans Verkuil

Designed and documented the VIDIOC_LOG_STATUS ioctl, the extended control ioctls and major parts of the sliced VBI API. 


    
  

Martin Rubli

Designed and documented the VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS ioctls. 

Andy Walls

Documented the fielded V4L2_MPEG_STREAM_VBI_FMT_IVTV MPEG stream embedded, sliced VBI data format in this specification.  


    
  

Mauro Carvalho Chehab

Documented libv4l, designed and added v4l2grab example, Remote Controller chapter  


    
  

This document is copyrighted © 1999-2009 by Bill Dirks, Michael H. Schimek, Hans Verkuil, Martin Rubli, Andy Walls and Mauro Carvalho Chehab.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the appendix entitled "GNU Free Documentation License".

Programming examples can be used and distributed without restrictions.

Revision History
Revision 2.6.322009-08-31mcc
Now, revisions will match the kernel version where the V4L2 API changes will be used by the Linux Kernel. Also added Remote Controller chapter.
Revision 0.292009-08-26ev
Added documentation for string controls and for FM Transmitter controls.
Revision 0.282009-08-26gl
Added V4L2_CID_BAND_STOP_FILTER documentation.
Revision 0.272009-08-15mcc
Added libv4l and Remote Controller documentation; added v4l2grab and keytable application examples.
Revision 0.262009-07-23hv
Finalized the RDS capture API. Added modulator and RDS encoder capabilities. Added support for string controls.
Revision 0.252009-01-18hv
Added pixel formats VYUY, NV16 and NV61, and changed the debug ioctls VIDIOC_DBG_G/S_REGISTER and VIDIOC_DBG_G_CHIP_IDENT. Added camera controls V4L2_CID_ZOOM_ABSOLUTE, V4L2_CID_ZOOM_RELATIVE, V4L2_CID_ZOOM_CONTINUOUS and V4L2_CID_PRIVACY.
Revision 0.242008-03-04mhs
Added pixel formats Y16 and SBGGR16, new controls and a camera controls class. Removed VIDIOC_G/S_MPEGCOMP.
Revision 0.232007-08-30mhs
Fixed a typo in VIDIOC_DBG_G/S_REGISTER. Clarified the byte order of packed pixel formats.
Revision 0.222007-08-29mhs
Added the Video Output Overlay interface, new MPEG controls, V4L2_FIELD_INTERLACED_TB and V4L2_FIELD_INTERLACED_BT, VIDIOC_DBG_G/S_REGISTER, VIDIOC_(TRY_)ENCODER_CMD, VIDIOC_G_CHIP_IDENT, VIDIOC_G_ENC_INDEX, new pixel formats. Clarifications in the cropping chapter, about RGB pixel formats, the mmap(), poll(), select(), read() and write() functions. Typographical fixes.
Revision 0.212006-12-19mhs
Fixed a link in the VIDIOC_G_EXT_CTRLS section.
Revision 0.202006-11-24mhs
Clarified the purpose of the audioset field in struct v4l2_input and v4l2_output.
Revision 0.192006-10-19mhs
Documented V4L2_PIX_FMT_RGB444.
Revision 0.182006-10-18mhs
Added the description of extended controls by Hans Verkuil. Linked V4L2_PIX_FMT_MPEG to V4L2_CID_MPEG_STREAM_TYPE.
Revision 0.172006-10-12mhs
Corrected V4L2_PIX_FMT_HM12 description.
Revision 0.162006-10-08mhs
VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS are now part of the API.
Revision 0.152006-09-23mhs
Cleaned up the bibliography, added BT.653 and BT.1119. capture.c/start_capturing() for user pointer I/O did not initialize the buffer index. Documented the V4L MPEG and MJPEG VID_TYPEs and V4L2_PIX_FMT_SBGGR8. Updated the list of reserved pixel formats. See the history chapter for API changes.
Revision 0.142006-09-14mr
Added VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS proposal for frame format enumeration of digital devices.
Revision 0.132006-04-07mhs
Corrected the description of struct v4l2_window clips. New V4L2_STD_ and V4L2_TUNER_MODE_LANG1_LANG2 defines.
Revision 0.122006-02-03mhs
Corrected the description of struct v4l2_captureparm and v4l2_outputparm.
Revision 0.112006-01-27mhs
Improved the description of struct v4l2_tuner.
Revision 0.102006-01-10mhs
VIDIOC_G_INPUT and VIDIOC_S_PARM clarifications.
Revision 0.92005-11-27mhs
Improved the 525 line numbering diagram. Hans Verkuil and I rewrote the sliced VBI section. He also contributed a VIDIOC_LOG_STATUS page. Fixed VIDIOC_S_STD call in the video standard selection example. Various updates.
Revision 0.82004-10-04mhs
Somehow a piece of junk slipped into the capture example, removed.
Revision 0.72004-09-19mhs
Fixed video standard selection, control enumeration, downscaling and aspect example. Added read and user pointer i/o to video capture example.
Revision 0.62004-08-01mhs
v4l2_buffer changes, added video capture example, various corrections.
Revision 0.52003-11-05mhs
Pixel format erratum.
Revision 0.42003-09-17mhs
Corrected source and Makefile to generate a PDF. SGML fixes. Added latest API changes. Closed gaps in the history chapter.
Revision 0.32003-02-05mhs
Another draft, more corrections.
Revision 0.22003-01-15mhs
Second draft, with corrections pointed out by Gerd Knorr.
Revision 0.12002-12-01mhs
First draft, based on documentation by Bill Dirks and discussions on the V4L mailing list.

Table of Contents

Introduction
1. Common API Elements
1.1. Opening and Closing Devices
1.1.1. Device Naming
1.1.2. Related Devices
1.1.3. Multiple Opens
1.1.4. Shared Data Streams
1.1.5. Functions
1.2. Querying Capabilities
1.3. Application Priority
1.4. Video Inputs and Outputs
1.5. Audio Inputs and Outputs
1.6. Tuners and Modulators
1.6.1. Tuners
1.6.2. Modulators
1.6.3. Radio Frequency
1.6.4. Satellite Receivers
1.7. Video Standards
1.8. User Controls
1.9. Extended Controls
1.9.1. Introduction
1.9.2. The Extended Control API
1.9.3. Enumerating Extended Controls
1.9.4. Creating Control Panels
1.9.5. MPEG Control Reference
1.9.5.1. Generic MPEG Controls
1.9.5.2. CX2341x MPEG Controls
1.9.6. Camera Control Reference
1.9.7. FM Transmitter Control Reference
1.10. Data Formats
1.10.1. Data Format Negotiation
1.10.2. Image Format Enumeration
1.11. Image Cropping, Insertion and Scaling
1.11.1. Cropping Structures
1.11.2. Scaling Adjustments
1.11.3. Examples
1.12. Streaming Parameters
2. Image Formats
2.1. Standard Image Formats
2.2. Colorspaces
2.3. Indexed Format
2.4. RGB Formats
2.5. YUV Formats
2.6. Compressed Formats
2.7. Reserved Format Identifiers
3. Input/Output
3.1. Read/Write
3.2. Streaming I/O (Memory Mapping)
3.3. Streaming I/O (User Pointers)
3.4. Asynchronous I/O
3.5. Buffers
3.5.1. Timecodes
3.6. Field Order
4. Interfaces
4.1. Video Capture Interface
4.1.1. Querying Capabilities
4.1.2. Supplemental Functions
4.1.3. Image Format Negotiation
4.1.4. Reading Images
4.2. Video Overlay Interface
4.2.1. Querying Capabilities
4.2.2. Supplemental Functions
4.2.3. Setup
4.2.4. Overlay Window
4.2.5. Enabling Overlay
4.3. Video Output Interface
4.3.1. Querying Capabilities
4.3.2. Supplemental Functions
4.3.3. Image Format Negotiation
4.3.4. Writing Images
4.4. Video Output Overlay Interface
4.4.1. Querying Capabilities
4.4.2. Framebuffer
4.4.3. Overlay Window and Scaling
4.4.4. Enabling Overlay
4.5. Codec Interface
4.6. Effect Devices Interface
4.7. Raw VBI Data Interface
4.7.1. Querying Capabilities
4.7.2. Supplemental Functions
4.7.3. Raw VBI Format Negotiation
4.7.4. Reading and writing VBI images
4.8. Sliced VBI Data Interface
4.8.1. Querying Capabilities
4.8.2. Supplemental Functions
4.8.3. Sliced VBI Format Negotiation
4.8.4. Reading and writing sliced VBI data
4.8.5. Sliced VBI Data in MPEG Streams
4.8.5.1. MPEG Stream Embedded, Sliced VBI Data Format: NONE
4.8.5.2. MPEG Stream Embedded, Sliced VBI Data Format: IVTV
4.9. Teletext Interface
4.10. Radio Interface
4.10.1. Querying Capabilities
4.10.2. Supplemental Functions
4.10.3. Programming
4.11. RDS Interface
4.11.1. Querying Capabilities
4.11.2. Reading RDS data
I. Function Reference
V4L2 close() — Close a V4L2 device
V4L2 ioctl() — Program a V4L2 device
ioctl VIDIOC_CROPCAP — Information about the video cropping and scaling abilities
ioctl VIDIOC_DBG_G_CHIP_IDENT — Identify the chips on a TV card
ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER — Read or write hardware registers
ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD — Execute an encoder command
ioctl VIDIOC_ENUMAUDIO — Enumerate audio inputs
ioctl VIDIOC_ENUMAUDOUT — Enumerate audio outputs
ioctl VIDIOC_ENUM_FMT — Enumerate image formats
ioctl VIDIOC_ENUM_FRAMESIZES — Enumerate frame sizes
ioctl VIDIOC_ENUM_FRAMEINTERVALS — Enumerate frame intervals
ioctl VIDIOC_ENUMINPUT — Enumerate video inputs
ioctl VIDIOC_ENUMOUTPUT — Enumerate video outputs
ioctl VIDIOC_ENUMSTD — Enumerate supported video standards
ioctl VIDIOC_G_AUDIO, VIDIOC_S_AUDIO — Query or select the current audio input and its attributes
ioctl VIDIOC_G_AUDOUT, VIDIOC_S_AUDOUT — Query or select the current audio output
ioctl VIDIOC_G_CROP, VIDIOC_S_CROP — Get or set the current cropping rectangle
ioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL — Get or set the value of a control
ioctl VIDIOC_G_ENC_INDEX — Get meta data about a compressed video stream
ioctl VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS, VIDIOC_TRY_EXT_CTRLS — Get or set the value of several controls, try control values
ioctl VIDIOC_G_FBUF, VIDIOC_S_FBUF — Get or set frame buffer overlay parameters
ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT — Get or set the data format, try a format
ioctl VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY — Get or set tuner or modulator radio frequency
ioctl VIDIOC_G_INPUT, VIDIOC_S_INPUT — Query or select the current video input
ioctl VIDIOC_G_JPEGCOMP, VIDIOC_S_JPEGCOMP
ioctl VIDIOC_G_MODULATOR, VIDIOC_S_MODULATOR — Get or set modulator attributes
ioctl VIDIOC_G_OUTPUT, VIDIOC_S_OUTPUT — Query or select the current video output
ioctl VIDIOC_G_PARM, VIDIOC_S_PARM — Get or set streaming parameters
ioctl VIDIOC_G_PRIORITY, VIDIOC_S_PRIORITY — Query or request the access priority associated with a file descriptor
ioctl VIDIOC_G_SLICED_VBI_CAP — Query sliced VBI capabilities
ioctl VIDIOC_G_STD, VIDIOC_S_STD — Query or select the video standard of the current input
ioctl VIDIOC_G_TUNER, VIDIOC_S_TUNER — Get or set tuner attributes
ioctl VIDIOC_LOG_STATUS — Log driver status information
ioctl VIDIOC_OVERLAY — Start or stop video overlay
ioctl VIDIOC_QBUF, VIDIOC_DQBUF — Exchange a buffer with the driver
ioctl VIDIOC_QUERYBUF — Query the status of a buffer
ioctl VIDIOC_QUERYCAP — Query device capabilities
ioctl VIDIOC_QUERYCTRL, VIDIOC_QUERYMENU — Enumerate controls and menu control items
ioctl VIDIOC_QUERYSTD — Sense the video standard received by the current input
ioctl VIDIOC_REQBUFS — Initiate Memory Mapping or User Pointer I/O
ioctl VIDIOC_S_HW_FREQ_SEEK — Perform a hardware frequency seek
ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF — Start or stop streaming I/O
V4L2 mmap() — Map device memory into application address space
V4L2 munmap() — Unmap device memory
V4L2 open() — Open a V4L2 device
V4L2 poll() — Wait for some event on a file descriptor
V4L2 read() — Read from a V4L2 device
V4L2 select() — Synchronous I/O multiplexing
V4L2 write() — Write to a V4L2 device
5. V4L2 Driver Programming
6. Libv4l Userspace Library
6.1. Introduction
6.1.1. libv4lconvert
6.1.2. libv4l1
6.1.3. libv4l2
6.1.3.1. Libv4l device control functions
6.1.4. v4l1compat.so wrapper library
7. Remote Controllers
7.1. Introduction
7.2. Changing default Remote Controller mappings
8. Changes
8.1. Differences between V4L and V4L2
8.1.1. Opening and Closing Devices
8.1.2. Querying Capabilities
8.1.3. Video Sources
8.1.4. Tuning
8.1.5. Image Properties
8.1.6. Audio
8.1.7. Frame Buffer Overlay
8.1.8. Cropping
8.1.9. Reading Images, Memory Mapping
8.1.9.1. Capturing using the read method
8.1.9.2. Capturing using memory mapping
8.1.10. Reading Raw VBI Data
8.1.11. Miscellaneous
8.2. Changes of the V4L2 API
8.2.1. Early Versions
8.2.2. V4L2 Version 0.16 1999-01-31
8.2.3. V4L2 Version 0.18 1999-03-16
8.2.4. V4L2 Version 0.19 1999-06-05
8.2.5. V4L2 Version 0.20 (1999-09-10)
8.2.6. V4L2 Version 0.20 incremental changes
8.2.7. V4L2 Version 0.20 2000-11-23
8.2.8. V4L2 Version 0.20 2002-07-25
8.2.9. V4L2 in Linux 2.5.46, 2002-10
8.2.10. V4L2 2003-06-19
8.2.11. V4L2 2003-11-05
8.2.12. V4L2 in Linux 2.6.6, 2004-05-09
8.2.13. V4L2 in Linux 2.6.8
8.2.14. V4L2 spec erratum 2004-08-01
8.2.15. V4L2 in Linux 2.6.14
8.2.16. V4L2 in Linux 2.6.15
8.2.17. V4L2 spec erratum 2005-11-27
8.2.18. V4L2 spec erratum 2006-01-10
8.2.19. V4L2 spec erratum 2006-02-03
8.2.20. V4L2 spec erratum 2006-02-04
8.2.21. V4L2 in Linux 2.6.17
8.2.22. V4L2 spec erratum 2006-09-23 (Draft 0.15)
8.2.23. V4L2 in Linux 2.6.18
8.2.24. V4L2 in Linux 2.6.19
8.2.25. V4L2 spec erratum 2006-10-12 (Draft 0.17)
8.2.26. V4L2 in Linux 2.6.21
8.2.27. V4L2 in Linux 2.6.22
8.2.28. V4L2 in Linux 2.6.24
8.2.29. V4L2 in Linux 2.6.25
8.2.30. V4L2 in Linux 2.6.26
8.2.31. V4L2 in Linux 2.6.27
8.2.32. V4L2 in Linux 2.6.28
8.2.33. V4L2 in Linux 2.6.29
8.2.34. V4L2 in Linux 2.6.30
8.2.35. V4L2 in Linux 2.6.32
8.3. Relation of V4L2 to other Linux multimedia APIs
8.3.1. X Video Extension
8.3.2. Digital Video
8.3.3. Audio Interfaces
8.4. Experimental API Elements
8.5. Obsolete API Elements
A. Video For Linux Two Header File
B. Video Capture Example
C. Video Grabber example using libv4l
D. GNU Free Documentation License
D.1. 0. PREAMBLE
D.2. 1. APPLICABILITY AND DEFINITIONS
D.3. 2. VERBATIM COPYING
D.4. 3. COPYING IN QUANTITY
D.5. 4. MODIFICATIONS
D.6. 5. COMBINING DOCUMENTS
D.7. 6. COLLECTIONS OF DOCUMENTS
D.8. 7. AGGREGATION WITH INDEPENDENT WORKS
D.9. 8. TRANSLATION
D.10. 9. TERMINATION
D.11. 10. FUTURE REVISIONS OF THIS LICENSE
D.12. Addendum
List of Types
References
List of Figures
List of Tables
List of Examples