Path: blob/master/Documentation/DocBook/v4l/dev-osd.xml
10821 views
<title>Video Output Overlay Interface</title>1<subtitle>Also known as On-Screen Display (OSD)</subtitle>23<note>4<title>Experimental</title>56<para>This is an <link linkend="experimental">experimental</link>7interface and may change in the future.</para>8</note>910<para>Some video output devices can overlay a framebuffer image onto11the outgoing video signal. Applications can set up such an overlay12using this interface, which borrows structures and ioctls of the <link13linkend="overlay">Video Overlay</link> interface.</para>1415<para>The OSD function is accessible through the same character16special file as the <link linkend="capture">Video Output</link> function.17Note the default function of such a <filename>/dev/video</filename> device18is video capturing or output. The OSD function is only available after19calling the &VIDIOC-S-FMT; ioctl.</para>2021<section>22<title>Querying Capabilities</title>2324<para>Devices supporting the <wordasword>Video Output25Overlay</wordasword> interface set the26<constant>V4L2_CAP_VIDEO_OUTPUT_OVERLAY</constant> flag in the27<structfield>capabilities</structfield> field of &v4l2-capability;28returned by the &VIDIOC-QUERYCAP; ioctl.</para>29</section>3031<section>32<title>Framebuffer</title>3334<para>Contrary to the <wordasword>Video Overlay</wordasword>35interface the framebuffer is normally implemented on the TV card and36not the graphics card. On Linux it is accessible as a framebuffer37device (<filename>/dev/fbN</filename>). Given a V4L2 device,38applications can find the corresponding framebuffer device by calling39the &VIDIOC-G-FBUF; ioctl. It returns, amongst other information, the40physical address of the framebuffer in the41<structfield>base</structfield> field of &v4l2-framebuffer;. The42framebuffer device ioctl <constant>FBIOGET_FSCREENINFO</constant>43returns the same address in the <structfield>smem_start</structfield>44field of struct <structname>fb_fix_screeninfo</structname>. The45<constant>FBIOGET_FSCREENINFO</constant> ioctl and struct46<structname>fb_fix_screeninfo</structname> are defined in the47<filename>linux/fb.h</filename> header file.</para>4849<para>The width and height of the framebuffer depends on the50current video standard. A V4L2 driver may reject attempts to change51the video standard (or any other ioctl which would imply a framebuffer52size change) with an &EBUSY; until all applications closed the53framebuffer device.</para>5455<example>56<title>Finding a framebuffer device for OSD</title>5758<programlisting>59#include <linux/fb.h>6061&v4l2-framebuffer; fbuf;62unsigned int i;63int fb_fd;6465if (-1 == ioctl (fd, VIDIOC_G_FBUF, &fbuf)) {66perror ("VIDIOC_G_FBUF");67exit (EXIT_FAILURE);68}6970for (i = 0; i > 30; ++i) {71char dev_name[16];72struct fb_fix_screeninfo si;7374snprintf (dev_name, sizeof (dev_name), "/dev/fb%u", i);7576fb_fd = open (dev_name, O_RDWR);77if (-1 == fb_fd) {78switch (errno) {79case ENOENT: /* no such file */80case ENXIO: /* no driver */81continue;8283default:84perror ("open");85exit (EXIT_FAILURE);86}87}8889if (0 == ioctl (fb_fd, FBIOGET_FSCREENINFO, &si)) {90if (si.smem_start == (unsigned long) fbuf.base)91break;92} else {93/* Apparently not a framebuffer device. */94}9596close (fb_fd);97fb_fd = -1;98}99100/* fb_fd is the file descriptor of the framebuffer device101for the video output overlay, or -1 if no device was found. */102</programlisting>103</example>104</section>105106<section>107<title>Overlay Window and Scaling</title>108109<para>The overlay is controlled by source and target rectangles.110The source rectangle selects a subsection of the framebuffer image to111be overlaid, the target rectangle an area in the outgoing video signal112where the image will appear. Drivers may or may not support scaling,113and arbitrary sizes and positions of these rectangles. Further drivers114may support any (or none) of the clipping/blending methods defined for115the <link linkend="overlay">Video Overlay</link> interface.</para>116117<para>A &v4l2-window; defines the size of the source rectangle,118its position in the framebuffer and the clipping/blending method to be119used for the overlay. To get the current parameters applications set120the <structfield>type</structfield> field of a &v4l2-format; to121<constant>V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY</constant> and call the122&VIDIOC-G-FMT; ioctl. The driver fills the123<structname>v4l2_window</structname> substructure named124<structfield>win</structfield>. It is not possible to retrieve a125previously programmed clipping list or bitmap.</para>126127<para>To program the source rectangle applications set the128<structfield>type</structfield> field of a &v4l2-format; to129<constant>V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY</constant>, initialize130the <structfield>win</structfield> substructure and call the131&VIDIOC-S-FMT; ioctl. The driver adjusts the parameters against132hardware limits and returns the actual parameters as133<constant>VIDIOC_G_FMT</constant> does. Like134<constant>VIDIOC_S_FMT</constant>, the &VIDIOC-TRY-FMT; ioctl can be135used to learn about driver capabilities without actually changing136driver state. Unlike <constant>VIDIOC_S_FMT</constant> this also works137after the overlay has been enabled.</para>138139<para>A &v4l2-crop; defines the size and position of the target140rectangle. The scaling factor of the overlay is implied by the width141and height given in &v4l2-window; and &v4l2-crop;. The cropping API142applies to <wordasword>Video Output</wordasword> and <wordasword>Video143Output Overlay</wordasword> devices in the same way as to144<wordasword>Video Capture</wordasword> and <wordasword>Video145Overlay</wordasword> devices, merely reversing the direction of the146data flow. For more information see <xref linkend="crop" />.</para>147</section>148149<section>150<title>Enabling Overlay</title>151152<para>There is no V4L2 ioctl to enable or disable the overlay,153however the framebuffer interface of the driver may support the154<constant>FBIOBLANK</constant> ioctl.</para>155</section>156157<!--158Local Variables:159mode: sgml160sgml-parent-document: "v4l2.sgml"161indent-tabs-mode: nil162End:163-->164165166