dev-capture.xml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <title>Video Capture Interface</title>
  2. <para>Video capture devices sample an analog video signal and store
  3. the digitized images in memory. Today nearly all devices can capture
  4. at full 25 or 30 frames/second. With this interface applications can
  5. control the capture process and move images from the driver into user
  6. space.</para>
  7. <para>Conventionally V4L2 video capture devices are accessed through
  8. character device special files named <filename>/dev/video</filename>
  9. and <filename>/dev/video0</filename> to
  10. <filename>/dev/video63</filename> with major number 81 and minor
  11. numbers 0 to 63. <filename>/dev/video</filename> is typically a
  12. symbolic link to the preferred video device. Note the same device
  13. files are used for video output devices.</para>
  14. <section>
  15. <title>Querying Capabilities</title>
  16. <para>Devices supporting the video capture interface set the
  17. <constant>V4L2_CAP_VIDEO_CAPTURE</constant> or
  18. <constant>V4L2_CAP_VIDEO_CAPTURE_MPLANE</constant> flag in the
  19. <structfield>capabilities</structfield> field of &v4l2-capability;
  20. returned by the &VIDIOC-QUERYCAP; ioctl. As secondary device functions
  21. they may also support the <link linkend="overlay">video overlay</link>
  22. (<constant>V4L2_CAP_VIDEO_OVERLAY</constant>) and the <link
  23. linkend="raw-vbi">raw VBI capture</link>
  24. (<constant>V4L2_CAP_VBI_CAPTURE</constant>) interface. At least one of
  25. the read/write or streaming I/O methods must be supported. Tuners and
  26. audio inputs are optional.</para>
  27. </section>
  28. <section>
  29. <title>Supplemental Functions</title>
  30. <para>Video capture devices shall support <link
  31. linkend="audio">audio input</link>, <link
  32. linkend="tuner">tuner</link>, <link linkend="control">controls</link>,
  33. <link linkend="crop">cropping and scaling</link> and <link
  34. linkend="streaming-par">streaming parameter</link> ioctls as needed.
  35. The <link linkend="video">video input</link> and <link
  36. linkend="standard">video standard</link> ioctls must be supported by
  37. all video capture devices.</para>
  38. </section>
  39. <section>
  40. <title>Image Format Negotiation</title>
  41. <para>The result of a capture operation is determined by
  42. cropping and image format parameters. The former select an area of the
  43. video picture to capture, the latter how images are stored in memory,
  44. &ie; in RGB or YUV format, the number of bits per pixel or width and
  45. height. Together they also define how images are scaled in the
  46. process.</para>
  47. <para>As usual these parameters are <emphasis>not</emphasis> reset
  48. at &func-open; time to permit Unix tool chains, programming a device
  49. and then reading from it as if it was a plain file. Well written V4L2
  50. applications ensure they really get what they want, including cropping
  51. and scaling.</para>
  52. <para>Cropping initialization at minimum requires to reset the
  53. parameters to defaults. An example is given in <xref
  54. linkend="crop" />.</para>
  55. <para>To query the current image format applications set the
  56. <structfield>type</structfield> field of a &v4l2-format; to
  57. <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant> or
  58. <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE</constant> and call the
  59. &VIDIOC-G-FMT; ioctl with a pointer to this structure. Drivers fill
  60. the &v4l2-pix-format; <structfield>pix</structfield> or the
  61. &v4l2-pix-format-mplane; <structfield>pix_mp</structfield> member of the
  62. <structfield>fmt</structfield> union.</para>
  63. <para>To request different parameters applications set the
  64. <structfield>type</structfield> field of a &v4l2-format; as above and
  65. initialize all fields of the &v4l2-pix-format;
  66. <structfield>vbi</structfield> member of the
  67. <structfield>fmt</structfield> union, or better just modify the
  68. results of <constant>VIDIOC_G_FMT</constant>, and call the
  69. &VIDIOC-S-FMT; ioctl with a pointer to this structure. Drivers may
  70. adjust the parameters and finally return the actual parameters as
  71. <constant>VIDIOC_G_FMT</constant> does.</para>
  72. <para>Like <constant>VIDIOC_S_FMT</constant> the
  73. &VIDIOC-TRY-FMT; ioctl can be used to learn about hardware limitations
  74. without disabling I/O or possibly time consuming hardware
  75. preparations.</para>
  76. <para>The contents of &v4l2-pix-format; and &v4l2-pix-format-mplane;
  77. are discussed in <xref linkend="pixfmt" />. See also the specification of the
  78. <constant>VIDIOC_G_FMT</constant>, <constant>VIDIOC_S_FMT</constant>
  79. and <constant>VIDIOC_TRY_FMT</constant> ioctls for details. Video
  80. capture devices must implement both the
  81. <constant>VIDIOC_G_FMT</constant> and
  82. <constant>VIDIOC_S_FMT</constant> ioctl, even if
  83. <constant>VIDIOC_S_FMT</constant> ignores all requests and always
  84. returns default parameters as <constant>VIDIOC_G_FMT</constant> does.
  85. <constant>VIDIOC_TRY_FMT</constant> is optional.</para>
  86. </section>
  87. <section>
  88. <title>Reading Images</title>
  89. <para>A video capture device may support the <link
  90. linkend="rw">read() function</link> and/or streaming (<link
  91. linkend="mmap">memory mapping</link> or <link
  92. linkend="userp">user pointer</link>) I/O. See <xref
  93. linkend="io" /> for details.</para>
  94. </section>