1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"> 2 <HTML 3 ><HEAD 4 ><TITLE 5 >Video Output Overlay Interface</TITLE 6 ><META 7 NAME="GENERATOR" 8 CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK 9 REL="HOME" 10 TITLE="Video for Linux Two API Specification" 11 HREF="book1.htm"><LINK 12 REL="UP" 13 TITLE="Interfaces" 14 HREF="c6488.htm"><LINK 15 REL="PREVIOUS" 16 TITLE="Video Output Interface" 17 HREF="x6831.htm"><LINK 18 REL="NEXT" 19 TITLE="Codec Interface" 20 HREF="x6991.htm"></HEAD 21 ><BODY 22 CLASS="SECTION" 23 BGCOLOR="#FFFFFF" 24 TEXT="#000000" 25 LINK="#0000FF" 26 VLINK="#840084" 27 ALINK="#0000FF" 28 ><DIV 29 CLASS="NAVHEADER" 30 ><TABLE 31 SUMMARY="Header navigation table" 32 WIDTH="100%" 33 BORDER="0" 34 CELLPADDING="0" 35 CELLSPACING="0" 36 ><TR 37 ><TH 38 COLSPAN="3" 39 ALIGN="center" 40 >Video for Linux Two API Specification: Revision 0.24</TH 41 ></TR 42 ><TR 43 ><TD 44 WIDTH="10%" 45 ALIGN="left" 46 VALIGN="bottom" 47 ><A 48 HREF="x6831.htm" 49 ACCESSKEY="P" 50 >Prev</A 51 ></TD 52 ><TD 53 WIDTH="80%" 54 ALIGN="center" 55 VALIGN="bottom" 56 >Chapter 4. Interfaces</TD 57 ><TD 58 WIDTH="10%" 59 ALIGN="right" 60 VALIGN="bottom" 61 ><A 62 HREF="x6991.htm" 63 ACCESSKEY="N" 64 >Next</A 65 ></TD 66 ></TR 67 ></TABLE 68 ><HR 69 ALIGN="LEFT" 70 WIDTH="100%"></DIV 71 ><DIV 72 CLASS="SECTION" 73 ><H1 74 CLASS="SECTION" 75 ><A 76 NAME="OSD" 77 >4.4. Video Output Overlay Interface</A 78 ></H1 79 ><FONT 80 COLOR="RED" 81 >Also known as On-Screen Display (OSD)</FONT 82 ><DIV 83 CLASS="NOTE" 84 ><BLOCKQUOTE 85 CLASS="NOTE" 86 ><P 87 ><B 88 >Experimental: </B 89 >This is an <A 90 HREF="x16453.htm" 91 >experimental</A 92 > 93 interface and may change in the future.</P 94 ></BLOCKQUOTE 95 ></DIV 96 ><P 97 >Some video output devices can overlay a framebuffer image onto 98 the outgoing video signal. Applications can set up such an overlay 99 using this interface, which borrows structures and ioctls of the <A 100 HREF="x6570.htm" 101 >Video Overlay</A 102 > interface.</P 103 ><P 104 >The OSD function is accessible through the same character 105 special file as the <A 106 HREF="c6488.htm#CAPTURE" 107 >Video Output</A 108 > function. 109 Note the default function of such a <TT 110 CLASS="FILENAME" 111 >/dev/video</TT 112 > device 113 is video capturing or output. The OSD function is only available after 114 calling the <A 115 HREF="r10944.htm" 116 ><CODE 117 CLASS="CONSTANT" 118 >VIDIOC_S_FMT</CODE 119 ></A 120 > ioctl.</P 121 ><DIV 122 CLASS="SECTION" 123 ><H2 124 CLASS="SECTION" 125 ><A 126 NAME="AEN6923" 127 >4.4.1. Querying Capabilities</A 128 ></H2 129 ><P 130 >Devices supporting the <I 131 CLASS="WORDASWORD" 132 >Video Output 133 Overlay</I 134 > interface set the 135 <CODE 136 CLASS="CONSTANT" 137 >V4L2_CAP_VIDEO_OUTPUT_OVERLAY</CODE 138 > flag in the 139 <CODE 140 CLASS="STRUCTFIELD" 141 >capabilities</CODE 142 > field of struct <A 143 HREF="r13105.htm#V4L2-CAPABILITY" 144 >v4l2_capability</A 145 > 146 returned by the <A 147 HREF="r13105.htm" 148 ><CODE 149 CLASS="CONSTANT" 150 >VIDIOC_QUERYCAP</CODE 151 ></A 152 > ioctl.</P 153 ></DIV 154 ><DIV 155 CLASS="SECTION" 156 ><H2 157 CLASS="SECTION" 158 ><A 159 NAME="AEN6932" 160 >4.4.2. Framebuffer</A 161 ></H2 162 ><P 163 >Contrary to the <I 164 CLASS="WORDASWORD" 165 >Video Overlay</I 166 > 167 interface the framebuffer is normally implemented on the TV card and 168 not the graphics card. On Linux it is accessible as a framebuffer 169 device (<TT 170 CLASS="FILENAME" 171 >/dev/fbN</TT 172 >). Given a V4L2 device, 173 applications can find the corresponding framebuffer device by calling 174 the <A 175 HREF="r10595.htm" 176 ><CODE 177 CLASS="CONSTANT" 178 >VIDIOC_G_FBUF</CODE 179 ></A 180 > ioctl. It returns, amongst other information, the 181 physical address of the framebuffer in the 182 <CODE 183 CLASS="STRUCTFIELD" 184 >base</CODE 185 > field of struct <A 186 HREF="r10595.htm#V4L2-FRAMEBUFFER" 187 >v4l2_framebuffer</A 188 >. The 189 framebuffer device ioctl <CODE 190 CLASS="CONSTANT" 191 >FBIOGET_FSCREENINFO</CODE 192 > 193 returns the same address in the <CODE 194 CLASS="STRUCTFIELD" 195 >smem_start</CODE 196 > 197 field of struct <CODE 198 CLASS="STRUCTNAME" 199 >fb_fix_screeninfo</CODE 200 >. The 201 <CODE 202 CLASS="CONSTANT" 203 >FBIOGET_FSCREENINFO</CODE 204 > ioctl and struct 205 <CODE 206 CLASS="STRUCTNAME" 207 >fb_fix_screeninfo</CODE 208 > are defined in the 209 <TT 210 CLASS="FILENAME" 211 >linux/fb.h</TT 212 > header file.</P 213 ><P 214 >The width and height of the framebuffer depends on the 215 current video standard. A V4L2 driver may reject attempts to change 216 the video standard (or any other ioctl which would imply a framebuffer 217 size change) with an <SPAN 218 CLASS="ERRORCODE" 219 >EBUSY</SPAN 220 > error code until all applications closed the 221 framebuffer device.</P 222 ><DIV 223 CLASS="EXAMPLE" 224 ><A 225 NAME="AEN6949" 226 ></A 227 ><P 228 ><B 229 >Example 4-1. Finding a framebuffer device for OSD</B 230 ></P 231 ><PRE 232 CLASS="PROGRAMLISTING" 233 >#include <linux/fb.h> 234 235 struct <A 236 HREF="r10595.htm#V4L2-FRAMEBUFFER" 237 >v4l2_framebuffer</A 238 > fbuf; 239 unsigned int i; 240 int fb_fd; 241 242 if (-1 == ioctl (fd, VIDIOC_G_FBUF, &fbuf)) { 243 perror ("VIDIOC_G_FBUF"); 244 exit (EXIT_FAILURE); 245 } 246 247 for (i = 0; i < 30; ++i) { 248 char dev_name[16]; 249 struct fb_fix_screeninfo si; 250 251 snprintf (dev_name, sizeof (dev_name), "/dev/fb%u", i); 252 253 fb_fd = open (dev_name, O_RDWR); 254 if (-1 == fb_fd) { 255 switch (errno) { 256 case ENOENT: /* no such file */ 257 case ENXIO: /* no driver */ 258 continue; 259 260 default: 261 perror ("open"); 262 exit (EXIT_FAILURE); 263 } 264 } 265 266 if (0 == ioctl (fb_fd, FBIOGET_FSCREENINFO, &si)) { 267 if (si.smem_start == (unsigned long) fbuf.base) 268 break; 269 } else { 270 /* Apparently not a framebuffer device. */ 271 } 272 273 close (fb_fd); 274 fb_fd = -1; 275 } 276 277 /* fb_fd is the file descriptor of the framebuffer device 278 for the video output overlay, or -1 if no device was found. */</PRE 279 ></DIV 280 ></DIV 281 ><DIV 282 CLASS="SECTION" 283 ><H2 284 CLASS="SECTION" 285 ><A 286 NAME="AEN6953" 287 >4.4.3. Overlay Window and Scaling</A 288 ></H2 289 ><P 290 >The overlay is controlled by source and target rectangles. 291 The source rectangle selects a subsection of the framebuffer image to 292 be overlaid, the target rectangle an area in the outgoing video signal 293 where the image will appear. Drivers may or may not support scaling, 294 and arbitrary sizes and positions of these rectangles. Further drivers 295 may support any (or none) of the clipping/blending methods defined for 296 the <A 297 HREF="x6570.htm" 298 >Video Overlay</A 299 > interface.</P 300 ><P 301 >A struct <A 302 HREF="x6570.htm#V4L2-WINDOW" 303 >v4l2_window</A 304 > defines the size of the source rectangle, 305 its position in the framebuffer and the clipping/blending method to be 306 used for the overlay. To get the current parameters applications set 307 the <CODE 308 CLASS="STRUCTFIELD" 309 >type</CODE 310 > field of a struct <A 311 HREF="r10944.htm#V4L2-FORMAT" 312 >v4l2_format</A 313 > to 314 <CODE 315 CLASS="CONSTANT" 316 >V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY</CODE 317 > and call the 318 <A 319 HREF="r10944.htm" 320 ><CODE 321 CLASS="CONSTANT" 322 >VIDIOC_G_FMT</CODE 323 ></A 324 > ioctl. The driver fills the 325 <CODE 326 CLASS="STRUCTNAME" 327 >v4l2_window</CODE 328 > substructure named 329 <CODE 330 CLASS="STRUCTFIELD" 331 >win</CODE 332 >. It is not possible to retrieve a 333 previously programmed clipping list or bitmap.</P 334 ><P 335 >To program the source rectangle applications set the 336 <CODE 337 CLASS="STRUCTFIELD" 338 >type</CODE 339 > field of a struct <A 340 HREF="r10944.htm#V4L2-FORMAT" 341 >v4l2_format</A 342 > to 343 <CODE 344 CLASS="CONSTANT" 345 >V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY</CODE 346 >, initialize 347 the <CODE 348 CLASS="STRUCTFIELD" 349 >win</CODE 350 > substructure and call the 351 <A 352 HREF="r10944.htm" 353 ><CODE 354 CLASS="CONSTANT" 355 >VIDIOC_S_FMT</CODE 356 ></A 357 > ioctl. The driver adjusts the parameters against 358 hardware limits and returns the actual parameters as 359 <CODE 360 CLASS="CONSTANT" 361 >VIDIOC_G_FMT</CODE 362 > does. Like 363 <CODE 364 CLASS="CONSTANT" 365 >VIDIOC_S_FMT</CODE 366 >, the <A 367 HREF="r10944.htm" 368 ><CODE 369 CLASS="CONSTANT" 370 >VIDIOC_TRY_FMT</CODE 371 ></A 372 > ioctl can be 373 used to learn about driver capabilities without actually changing 374 driver state. Unlike <CODE 375 CLASS="CONSTANT" 376 >VIDIOC_S_FMT</CODE 377 > this also works 378 after the overlay has been enabled.</P 379 ><P 380 >A struct <A 381 HREF="r9994.htm#V4L2-CROP" 382 >v4l2_crop</A 383 > defines the size and position of the target 384 rectangle. The scaling factor of the overlay is implied by the width 385 and height given in struct <A 386 HREF="x6570.htm#V4L2-WINDOW" 387 >v4l2_window</A 388 > and struct <A 389 HREF="r9994.htm#V4L2-CROP" 390 >v4l2_crop</A 391 >. The cropping API 392 applies to <I 393 CLASS="WORDASWORD" 394 >Video Output</I 395 > and <I 396 CLASS="WORDASWORD" 397 >Video 398 Output Overlay</I 399 > devices in the same way as to 400 <I 401 CLASS="WORDASWORD" 402 >Video Capture</I 403 > and <I 404 CLASS="WORDASWORD" 405 >Video 406 Overlay</I 407 > devices, merely reversing the direction of the 408 data flow. For more information see <A 409 HREF="x1904.htm" 410 >Section 1.11</A 411 >.</P 412 ></DIV 413 ><DIV 414 CLASS="SECTION" 415 ><H2 416 CLASS="SECTION" 417 ><A 418 NAME="AEN6987" 419 >4.4.4. Enabling Overlay</A 420 ></H2 421 ><P 422 >There is no V4L2 ioctl to enable or disable the overlay, 423 however the framebuffer interface of the driver may support the 424 <CODE 425 CLASS="CONSTANT" 426 >FBIOBLANK</CODE 427 > ioctl.</P 428 ></DIV 429 ></DIV 430 ><DIV 431 CLASS="NAVFOOTER" 432 ><HR 433 ALIGN="LEFT" 434 WIDTH="100%"><TABLE 435 SUMMARY="Footer navigation table" 436 WIDTH="100%" 437 BORDER="0" 438 CELLPADDING="0" 439 CELLSPACING="0" 440 ><TR 441 ><TD 442 WIDTH="33%" 443 ALIGN="left" 444 VALIGN="top" 445 ><A 446 HREF="x6831.htm" 447 ACCESSKEY="P" 448 >Prev</A 449 ></TD 450 ><TD 451 WIDTH="34%" 452 ALIGN="center" 453 VALIGN="top" 454 ><A 455 HREF="book1.htm" 456 ACCESSKEY="H" 457 >Home</A 458 ></TD 459 ><TD 460 WIDTH="33%" 461 ALIGN="right" 462 VALIGN="top" 463 ><A 464 HREF="x6991.htm" 465 ACCESSKEY="N" 466 >Next</A 467 ></TD 468 ></TR 469 ><TR 470 ><TD 471 WIDTH="33%" 472 ALIGN="left" 473 VALIGN="top" 474 >Video Output Interface</TD 475 ><TD 476 WIDTH="34%" 477 ALIGN="center" 478 VALIGN="top" 479 ><A 480 HREF="c6488.htm" 481 ACCESSKEY="U" 482 >Up</A 483 ></TD 484 ><TD 485 WIDTH="33%" 486 ALIGN="right" 487 VALIGN="top" 488 >Codec Interface</TD 489 ></TR 490 ></TABLE 491 ></DIV 492 ></BODY 493 ></HTML 494 > 495