dev-capture.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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> flag in the
  18. <structfield>capabilities</structfield> field of &v4l2-capability;
  19. returned by the &VIDIOC-QUERYCAP; ioctl. As secondary device functions
  20. they may also support the <link linkend="overlay">video overlay</link>
  21. (<constant>V4L2_CAP_VIDEO_OVERLAY</constant>) and the <link
  22. linkend="raw-vbi">raw VBI capture</link>
  23. (<constant>V4L2_CAP_VBI_CAPTURE</constant>) interface. At least one of
  24. the read/write or streaming I/O methods must be supported. Tuners and
  25. audio inputs are optional.</para>
  26. </section>
  27. <section>
  28. <title>Supplemental Functions</title>
  29. <para>Video capture devices shall support <link
  30. linkend="audio">audio input</link>, <link
  31. linkend="tuner">tuner</link>, <link linkend="control">controls</link>,
  32. <link linkend="crop">cropping and scaling</link> and <link
  33. linkend="streaming-par">streaming parameter</link> ioctls as needed.
  34. The <link linkend="video">video input</link> and <link
  35. linkend="standard">video standard</link> ioctls must be supported by
  36. all video capture devices.</para>
  37. </section>
  38. <section>
  39. <title>Image Format Negotiation</title>
  40. <para>The result of a capture operation is determined by
  41. cropping and image format parameters. The former select an area of the
  42. video picture to capture, the latter how images are stored in memory,
  43. &ie; in RGB or YUV format, the number of bits per pixel or width and
  44. height. Together they also define how images are scaled in the
  45. process.</para>
  46. <para>As usual these parameters are <emphasis>not</emphasis> reset
  47. at &func-open; time to permit Unix tool chains, programming a device
  48. and then reading from it as if it was a plain file. Well written V4L2
  49. applications ensure they really get what they want, including cropping
  50. and scaling.</para>
  51. <para>Cropping initialization at minimum requires to reset the
  52. parameters to defaults. An example is given in <xref
  53. linkend="crop" />.</para>
  54. <para>To query the current image format applications set the
  55. <structfield>type</structfield> field of a &v4l2-format; to
  56. <constant>V4L2_BUF_TYPE_VIDEO_CAPTURE</constant> and call the
  57. &VIDIOC-G-FMT; ioctl with a pointer to this structure. Drivers fill
  58. the &v4l2-pix-format; <structfield>pix</structfield> member of the
  59. <structfield>fmt</structfield> union.</para>
  60. <para>To request different parameters applications set the
  61. <structfield>type</structfield> field of a &v4l2-format; as above and
  62. initialize all fields of the &v4l2-pix-format;
  63. <structfield>vbi</structfield> member of the
  64. <structfield>fmt</structfield> union, or better just modify the
  65. results of <constant>VIDIOC_G_FMT</constant>, and call the
  66. &VIDIOC-S-FMT; ioctl with a pointer to this structure. Drivers may
  67. adjust the parameters and finally return the actual parameters as
  68. <constant>VIDIOC_G_FMT</constant> does.</para>
  69. <para>Like <constant>VIDIOC_S_FMT</constant> the
  70. &VIDIOC-TRY-FMT; ioctl can be used to learn about hardware limitations
  71. without disabling I/O or possibly time consuming hardware
  72. preparations.</para>
  73. <para>The contents of &v4l2-pix-format; are discussed in <xref
  74. linkend="pixfmt" />. See also the specification of the
  75. <constant>VIDIOC_G_FMT</constant>, <constant>VIDIOC_S_FMT</constant>
  76. and <constant>VIDIOC_TRY_FMT</constant> ioctls for details. Video
  77. capture devices must implement both the
  78. <constant>VIDIOC_G_FMT</constant> and
  79. <constant>VIDIOC_S_FMT</constant> ioctl, even if
  80. <constant>VIDIOC_S_FMT</constant> ignores all requests and always
  81. returns default parameters as <constant>VIDIOC_G_FMT</constant> does.
  82. <constant>VIDIOC_TRY_FMT</constant> is optional.</para>
  83. </section>
  84. <section>
  85. <title>Reading Images</title>
  86. <para>A video capture device may support the <link
  87. linkend="rw">read() function</link> and/or streaming (<link
  88. linkend="mmap">memory mapping</link> or <link
  89. linkend="userp">user pointer</link>) I/O. See <xref
  90. linkend="io" /> for details.</para>
  91. </section>
  92. <!--
  93. Local Variables:
  94. mode: sgml
  95. sgml-parent-document: "v4l2.sgml"
  96. indent-tabs-mode: nil
  97. End:
  98. -->