<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Video Output Interface</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1" /><link rel="home" href="index.html" title="LINUX MEDIA INFRASTRUCTURE API" /><link rel="up" href="devices.html" title="Chapter 4. Interfaces" /><link rel="prev" href="overlay.html" title="Video Overlay Interface" /><link rel="next" href="osd.html" title="Video Output Overlay Interface" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Video Output Interface</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="overlay.html">Prev</a> </td><th width="60%" align="center">Chapter 4. Interfaces</th><td width="20%" align="right"> <a accesskey="n" href="osd.html">Next</a></td></tr></table><hr /></div><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="output"></a>Video Output Interface</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="section"><a href="output.html#idm140470021752160">Querying Capabilities</a></span></dt><dt><span class="section"><a href="output.html#idm140470021746832">Supplemental Functions</a></span></dt><dt><span class="section"><a href="output.html#idm140470021739840">Image Format Negotiation</a></span></dt><dt><span class="section"><a href="output.html#idm140470021715808">Writing Images</a></span></dt></dl></div><p>Video output devices encode stills or image sequences as analog video signal. With this interface applications can control the encoding process and move images from user space to the driver.</p><p>Conventionally V4L2 video output devices are accessed through character device special files named <code class="filename">/dev/video</code> and <code class="filename">/dev/video0</code> to <code class="filename">/dev/video63</code> with major number 81 and minor numbers 0 to 63. <code class="filename">/dev/video</code> is typically a symbolic link to the preferred video device. Note the same device files are used for video capture devices.</p><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idm140470021752160"></a>Querying Capabilities</h3></div></div></div><p>Devices supporting the video output interface set the <code class="constant">V4L2_CAP_VIDEO_OUTPUT</code> or <code class="constant">V4L2_CAP_VIDEO_OUTPUT_MPLANE</code> flag in the <em class="structfield"><code>capabilities</code></em> field of struct <a class="link" href="vidioc-querycap.html#v4l2-capability" title="Table A.88. struct v4l2_capability">v4l2_capability</a> returned by the <a class="link" href="vidioc-querycap.html" title="ioctl VIDIOC_QUERYCAP"><code class="constant">VIDIOC_QUERYCAP</code></a> ioctl. As secondary device functions they may also support the <a class="link" href="raw-vbi.html" title="Raw VBI Data Interface">raw VBI output</a> (<code class="constant">V4L2_CAP_VBI_OUTPUT</code>) interface. At least one of the read/write or streaming I/O methods must be supported. Modulators and audio outputs are optional.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idm140470021746832"></a>Supplemental Functions</h3></div></div></div><p>Video output devices shall support <a class="link" href="audio.html" title="Audio Inputs and Outputs">audio output</a>, <a class="link" href="tuner.html" title="Tuners and Modulators">modulator</a>, <a class="link" href="control.html" title="User Controls">controls</a>, <a class="link" href="crop.html" title="Image Cropping, Insertion and Scaling">cropping and scaling</a> and <a class="link" href="streaming-par.html" title="Streaming Parameters">streaming parameter</a> ioctls as needed. The <a class="link" href="video.html" title="Video Inputs and Outputs">video output</a> and <a class="link" href="standard.html" title="Video Standards">video standard</a> ioctls must be supported by all video output devices.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idm140470021739840"></a>Image Format Negotiation</h3></div></div></div><p>The output is determined by cropping and image format parameters. The former select an area of the video picture where the image will appear, the latter how images are stored in memory, i. e. in RGB or YUV format, the number of bits per pixel or width and height. Together they also define how images are scaled in the process.</p><p>As usual these parameters are <span class="emphasis"><em>not</em></span> reset at <a class="link" href="func-open.html" title="V4L2 open()"><code class="function">open()</code></a> time to permit Unix tool chains, programming a device and then writing to it as if it was a plain file. Well written V4L2 applications ensure they really get what they want, including cropping and scaling.</p><p>Cropping initialization at minimum requires to reset the parameters to defaults. An example is given in <a class="xref" href="crop.html" title="Image Cropping, Insertion and Scaling">the section called “Image Cropping, Insertion and Scaling”</a>.</p><p>To query the current image format applications set the <em class="structfield"><code>type</code></em> field of a struct <a class="link" href="vidioc-g-fmt.html#v4l2-format" title="Table A.67. struct v4l2_format">v4l2_format</a> to <code class="constant">V4L2_BUF_TYPE_VIDEO_OUTPUT</code> or <code class="constant">V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE</code> and call the <a class="link" href="vidioc-g-fmt.html" title="ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT"><code class="constant">VIDIOC_G_FMT</code></a> ioctl with a pointer to this structure. Drivers fill the struct <a class="link" href="pixfmt.html#v4l2-pix-format" title="Table 2.1. struct v4l2_pix_format">v4l2_pix_format</a> <em class="structfield"><code>pix</code></em> or the struct <a class="link" href="ch02s02.html#v4l2-pix-format-mplane" title="Table 2.3. struct v4l2_pix_format_mplane">v4l2_pix_format_mplane</a> <em class="structfield"><code>pix_mp</code></em> member of the <em class="structfield"><code>fmt</code></em> union.</p><p>To request different parameters applications set the <em class="structfield"><code>type</code></em> field of a struct <a class="link" href="vidioc-g-fmt.html#v4l2-format" title="Table A.67. struct v4l2_format">v4l2_format</a> as above and initialize all fields of the struct <a class="link" href="pixfmt.html#v4l2-pix-format" title="Table 2.1. struct v4l2_pix_format">v4l2_pix_format</a> <em class="structfield"><code>vbi</code></em> member of the <em class="structfield"><code>fmt</code></em> union, or better just modify the results of <code class="constant">VIDIOC_G_FMT</code>, and call the <a class="link" href="vidioc-g-fmt.html" title="ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT"><code class="constant">VIDIOC_S_FMT</code></a> ioctl with a pointer to this structure. Drivers may adjust the parameters and finally return the actual parameters as <code class="constant">VIDIOC_G_FMT</code> does.</p><p>Like <code class="constant">VIDIOC_S_FMT</code> the <a class="link" href="vidioc-g-fmt.html" title="ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT"><code class="constant">VIDIOC_TRY_FMT</code></a> ioctl can be used to learn about hardware limitations without disabling I/O or possibly time consuming hardware preparations.</p><p>The contents of struct <a class="link" href="pixfmt.html#v4l2-pix-format" title="Table 2.1. struct v4l2_pix_format">v4l2_pix_format</a> and struct <a class="link" href="ch02s02.html#v4l2-pix-format-mplane" title="Table 2.3. struct v4l2_pix_format_mplane">v4l2_pix_format_mplane</a> are discussed in <a class="xref" href="pixfmt.html" title="Chapter 2. Image Formats">Chapter 2, <em>Image Formats</em></a>. See also the specification of the <code class="constant">VIDIOC_G_FMT</code>, <code class="constant">VIDIOC_S_FMT</code> and <code class="constant">VIDIOC_TRY_FMT</code> ioctls for details. Video output devices must implement both the <code class="constant">VIDIOC_G_FMT</code> and <code class="constant">VIDIOC_S_FMT</code> ioctl, even if <code class="constant">VIDIOC_S_FMT</code> ignores all requests and always returns default parameters as <code class="constant">VIDIOC_G_FMT</code> does. <code class="constant">VIDIOC_TRY_FMT</code> is optional.</p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="idm140470021715808"></a>Writing Images</h3></div></div></div><p>A video output device may support the <a class="link" href="io.html#rw" title="Read/Write">write() function</a> and/or streaming (<a class="link" href="mmap.html" title="Streaming I/O (Memory Mapping)">memory mapping</a> or <a class="link" href="userp.html" title="Streaming I/O (User Pointers)">user pointer</a>) I/O. See <a class="xref" href="io.html" title="Chapter 3. Input/Output">Chapter 3, <em>Input/Output</em></a> for details.</p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="overlay.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="devices.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="osd.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Video Overlay Interface </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Video Output Overlay Interface</td></tr></table></div></body></html>