vidioc-g-fbuf.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  1. <refentry id="vidioc-g-fbuf">
  2. <refmeta>
  3. <refentrytitle>ioctl VIDIOC_G_FBUF, VIDIOC_S_FBUF</refentrytitle>
  4. &manvol;
  5. </refmeta>
  6. <refnamediv>
  7. <refname>VIDIOC_G_FBUF</refname>
  8. <refname>VIDIOC_S_FBUF</refname>
  9. <refpurpose>Get or set frame buffer overlay parameters</refpurpose>
  10. </refnamediv>
  11. <refsynopsisdiv>
  12. <funcsynopsis>
  13. <funcprototype>
  14. <funcdef>int <function>ioctl</function></funcdef>
  15. <paramdef>int <parameter>fd</parameter></paramdef>
  16. <paramdef>int <parameter>request</parameter></paramdef>
  17. <paramdef>struct v4l2_framebuffer *<parameter>argp</parameter></paramdef>
  18. </funcprototype>
  19. </funcsynopsis>
  20. <funcsynopsis>
  21. <funcprototype>
  22. <funcdef>int <function>ioctl</function></funcdef>
  23. <paramdef>int <parameter>fd</parameter></paramdef>
  24. <paramdef>int <parameter>request</parameter></paramdef>
  25. <paramdef>const struct v4l2_framebuffer *<parameter>argp</parameter></paramdef>
  26. </funcprototype>
  27. </funcsynopsis>
  28. </refsynopsisdiv>
  29. <refsect1>
  30. <title>Arguments</title>
  31. <variablelist>
  32. <varlistentry>
  33. <term><parameter>fd</parameter></term>
  34. <listitem>
  35. <para>&fd;</para>
  36. </listitem>
  37. </varlistentry>
  38. <varlistentry>
  39. <term><parameter>request</parameter></term>
  40. <listitem>
  41. <para>VIDIOC_G_FBUF, VIDIOC_S_FBUF</para>
  42. </listitem>
  43. </varlistentry>
  44. <varlistentry>
  45. <term><parameter>argp</parameter></term>
  46. <listitem>
  47. <para></para>
  48. </listitem>
  49. </varlistentry>
  50. </variablelist>
  51. </refsect1>
  52. <refsect1>
  53. <title>Description</title>
  54. <para>Applications can use the <constant>VIDIOC_G_FBUF</constant> and
  55. <constant>VIDIOC_S_FBUF</constant> ioctl to get and set the
  56. framebuffer parameters for a <link linkend="overlay">Video
  57. Overlay</link> or <link linkend="osd">Video Output Overlay</link>
  58. (OSD). The type of overlay is implied by the device type (capture or
  59. output device) and can be determined with the &VIDIOC-QUERYCAP; ioctl.
  60. One <filename>/dev/videoN</filename> device must not support both
  61. kinds of overlay.</para>
  62. <para>The V4L2 API distinguishes destructive and non-destructive
  63. overlays. A destructive overlay copies captured video images into the
  64. video memory of a graphics card. A non-destructive overlay blends
  65. video images into a VGA signal or graphics into a video signal.
  66. <wordasword>Video Output Overlays</wordasword> are always
  67. non-destructive.</para>
  68. <para>To get the current parameters applications call the
  69. <constant>VIDIOC_G_FBUF</constant> ioctl with a pointer to a
  70. <structname>v4l2_framebuffer</structname> structure. The driver fills
  71. all fields of the structure or returns an &EINVAL; when overlays are
  72. not supported.</para>
  73. <para>To set the parameters for a <wordasword>Video Output
  74. Overlay</wordasword>, applications must initialize the
  75. <structfield>flags</structfield> field of a struct
  76. <structname>v4l2_framebuffer</structname>. Since the framebuffer is
  77. implemented on the TV card all other parameters are determined by the
  78. driver. When an application calls <constant>VIDIOC_S_FBUF</constant>
  79. with a pointer to this structure, the driver prepares for the overlay
  80. and returns the framebuffer parameters as
  81. <constant>VIDIOC_G_FBUF</constant> does, or it returns an error
  82. code.</para>
  83. <para>To set the parameters for a <wordasword>non-destructive
  84. Video Overlay</wordasword>, applications must initialize the
  85. <structfield>flags</structfield> field, the
  86. <structfield>fmt</structfield> substructure, and call
  87. <constant>VIDIOC_S_FBUF</constant>. Again the driver prepares for the
  88. overlay and returns the framebuffer parameters as
  89. <constant>VIDIOC_G_FBUF</constant> does, or it returns an error
  90. code.</para>
  91. <para>For a <wordasword>destructive Video Overlay</wordasword>
  92. applications must additionally provide a
  93. <structfield>base</structfield> address. Setting up a DMA to a
  94. random memory location can jeopardize the system security, its
  95. stability or even damage the hardware, therefore only the superuser
  96. can set the parameters for a destructive video overlay.</para>
  97. <!-- NB v4l2_pix_format is also specified in pixfmt.sgml.-->
  98. <table pgwide="1" frame="none" id="v4l2-framebuffer">
  99. <title>struct <structname>v4l2_framebuffer</structname></title>
  100. <tgroup cols="4">
  101. &cs-ustr;
  102. <tbody valign="top">
  103. <row>
  104. <entry>__u32</entry>
  105. <entry><structfield>capability</structfield></entry>
  106. <entry></entry>
  107. <entry>Overlay capability flags set by the driver, see
  108. <xref linkend="framebuffer-cap" />.</entry>
  109. </row>
  110. <row>
  111. <entry>__u32</entry>
  112. <entry><structfield>flags</structfield></entry>
  113. <entry></entry>
  114. <entry>Overlay control flags set by application and
  115. driver, see <xref linkend="framebuffer-flags" /></entry>
  116. </row>
  117. <row>
  118. <entry>void *</entry>
  119. <entry><structfield>base</structfield></entry>
  120. <entry></entry>
  121. <entry>Physical base address of the framebuffer,
  122. that is the address of the pixel in the top left corner of the
  123. framebuffer.<footnote><para>A physical base address may not suit all
  124. platforms. GK notes in theory we should pass something like PCI device
  125. + memory region + offset instead. If you encounter problems please
  126. discuss on the linux-media mailing list: &v4l-ml;.</para></footnote></entry>
  127. </row>
  128. <row>
  129. <entry></entry>
  130. <entry></entry>
  131. <entry></entry>
  132. <entry>This field is irrelevant to
  133. <wordasword>non-destructive Video Overlays</wordasword>. For
  134. <wordasword>destructive Video Overlays</wordasword> applications must
  135. provide a base address. The driver may accept only base addresses
  136. which are a multiple of two, four or eight bytes. For
  137. <wordasword>Video Output Overlays</wordasword> the driver must return
  138. a valid base address, so applications can find the corresponding Linux
  139. framebuffer device (see <xref linkend="osd" />).</entry>
  140. </row>
  141. <row>
  142. <entry>&v4l2-pix-format;</entry>
  143. <entry><structfield>fmt</structfield></entry>
  144. <entry></entry>
  145. <entry>Layout of the frame buffer. The
  146. <structname>v4l2_pix_format</structname> structure is defined in <xref
  147. linkend="pixfmt" />, for clarification the fields and acceptable values
  148. are listed below:</entry>
  149. </row>
  150. <row>
  151. <entry></entry>
  152. <entry>__u32</entry>
  153. <entry><structfield>width</structfield></entry>
  154. <entry>Width of the frame buffer in pixels.</entry>
  155. </row>
  156. <row>
  157. <entry></entry>
  158. <entry>__u32</entry>
  159. <entry><structfield>height</structfield></entry>
  160. <entry>Height of the frame buffer in pixels.</entry>
  161. </row>
  162. <row>
  163. <entry></entry>
  164. <entry>__u32</entry>
  165. <entry><structfield>pixelformat</structfield></entry>
  166. <entry>The pixel format of the
  167. framebuffer.</entry>
  168. </row>
  169. <row>
  170. <entry></entry>
  171. <entry></entry>
  172. <entry></entry>
  173. <entry>For <wordasword>non-destructive Video
  174. Overlays</wordasword> this field only defines a format for the
  175. &v4l2-window; <structfield>chromakey</structfield> field.</entry>
  176. </row>
  177. <row>
  178. <entry></entry>
  179. <entry></entry>
  180. <entry></entry>
  181. <entry>For <wordasword>destructive Video
  182. Overlays</wordasword> applications must initialize this field. For
  183. <wordasword>Video Output Overlays</wordasword> the driver must return
  184. a valid format.</entry>
  185. </row>
  186. <row>
  187. <entry></entry>
  188. <entry></entry>
  189. <entry></entry>
  190. <entry>Usually this is an RGB format (for example
  191. <link linkend="V4L2-PIX-FMT-RGB565"><constant>V4L2_PIX_FMT_RGB565</constant></link>)
  192. but YUV formats (only packed YUV formats when chroma keying is used,
  193. not including <constant>V4L2_PIX_FMT_YUYV</constant> and
  194. <constant>V4L2_PIX_FMT_UYVY</constant>) and the
  195. <constant>V4L2_PIX_FMT_PAL8</constant> format are also permitted. The
  196. behavior of the driver when an application requests a compressed
  197. format is undefined. See <xref linkend="pixfmt" /> for information on
  198. pixel formats.</entry>
  199. </row>
  200. <row>
  201. <entry></entry>
  202. <entry>&v4l2-field;</entry>
  203. <entry><structfield>field</structfield></entry>
  204. <entry>Drivers and applications shall ignore this field.
  205. If applicable, the field order is selected with the &VIDIOC-S-FMT;
  206. ioctl, using the <structfield>field</structfield> field of
  207. &v4l2-window;.</entry>
  208. </row>
  209. <row>
  210. <entry></entry>
  211. <entry>__u32</entry>
  212. <entry><structfield>bytesperline</structfield></entry>
  213. <entry>Distance in bytes between the leftmost pixels in
  214. two adjacent lines.</entry>
  215. </row>
  216. <row>
  217. <entry spanname="hspan"><para>This field is irrelevant to
  218. <wordasword>non-destructive Video
  219. Overlays</wordasword>.</para><para>For <wordasword>destructive Video
  220. Overlays</wordasword> both applications and drivers can set this field
  221. to request padding bytes at the end of each line. Drivers however may
  222. ignore the requested value, returning <structfield>width</structfield>
  223. times bytes-per-pixel or a larger value required by the hardware. That
  224. implies applications can just set this field to zero to get a
  225. reasonable default.</para><para>For <wordasword>Video Output
  226. Overlays</wordasword> the driver must return a valid
  227. value.</para><para>Video hardware may access padding bytes, therefore
  228. they must reside in accessible memory. Consider for example the case
  229. where padding bytes after the last line of an image cross a system
  230. page boundary. Capture devices may write padding bytes, the value is
  231. undefined. Output devices ignore the contents of padding
  232. bytes.</para><para>When the image format is planar the
  233. <structfield>bytesperline</structfield> value applies to the largest
  234. plane and is divided by the same factor as the
  235. <structfield>width</structfield> field for any smaller planes. For
  236. example the Cb and Cr planes of a YUV 4:2:0 image have half as many
  237. padding bytes following each line as the Y plane. To avoid ambiguities
  238. drivers must return a <structfield>bytesperline</structfield> value
  239. rounded up to a multiple of the scale factor.</para></entry>
  240. </row>
  241. <row>
  242. <entry></entry>
  243. <entry>__u32</entry>
  244. <entry><structfield>sizeimage</structfield></entry>
  245. <entry><para>This field is irrelevant to
  246. <wordasword>non-destructive Video Overlays</wordasword>. For
  247. <wordasword>destructive Video Overlays</wordasword> applications must
  248. initialize this field. For <wordasword>Video Output
  249. Overlays</wordasword> the driver must return a valid
  250. format.</para><para>Together with <structfield>base</structfield> it
  251. defines the framebuffer memory accessible by the
  252. driver.</para></entry>
  253. </row>
  254. <row>
  255. <entry></entry>
  256. <entry>&v4l2-colorspace;</entry>
  257. <entry><structfield>colorspace</structfield></entry>
  258. <entry>This information supplements the
  259. <structfield>pixelformat</structfield> and must be set by the driver,
  260. see <xref linkend="colorspaces" />.</entry>
  261. </row>
  262. <row>
  263. <entry></entry>
  264. <entry>__u32</entry>
  265. <entry><structfield>priv</structfield></entry>
  266. <entry>Reserved for additional information about custom
  267. (driver defined) formats. When not used drivers and applications must
  268. set this field to zero.</entry>
  269. </row>
  270. </tbody>
  271. </tgroup>
  272. </table>
  273. <table pgwide="1" frame="none" id="framebuffer-cap">
  274. <title>Frame Buffer Capability Flags</title>
  275. <tgroup cols="3">
  276. &cs-def;
  277. <tbody valign="top">
  278. <row>
  279. <entry><constant>V4L2_FBUF_CAP_EXTERNOVERLAY</constant></entry>
  280. <entry>0x0001</entry>
  281. <entry>The device is capable of non-destructive overlays.
  282. When the driver clears this flag, only destructive overlays are
  283. supported. There are no drivers yet which support both destructive and
  284. non-destructive overlays.</entry>
  285. </row>
  286. <row>
  287. <entry><constant>V4L2_FBUF_CAP_CHROMAKEY</constant></entry>
  288. <entry>0x0002</entry>
  289. <entry>The device supports clipping by chroma-keying the
  290. images. That is, image pixels replace pixels in the VGA or video
  291. signal only where the latter assume a certain color. Chroma-keying
  292. makes no sense for destructive overlays.</entry>
  293. </row>
  294. <row>
  295. <entry><constant>V4L2_FBUF_CAP_LIST_CLIPPING</constant></entry>
  296. <entry>0x0004</entry>
  297. <entry>The device supports clipping using a list of clip
  298. rectangles.</entry>
  299. </row>
  300. <row>
  301. <entry><constant>V4L2_FBUF_CAP_BITMAP_CLIPPING</constant></entry>
  302. <entry>0x0008</entry>
  303. <entry>The device supports clipping using a bit mask.</entry>
  304. </row>
  305. <row>
  306. <entry><constant>V4L2_FBUF_CAP_LOCAL_ALPHA</constant></entry>
  307. <entry>0x0010</entry>
  308. <entry>The device supports clipping/blending using the
  309. alpha channel of the framebuffer or VGA signal. Alpha blending makes
  310. no sense for destructive overlays.</entry>
  311. </row>
  312. <row>
  313. <entry><constant>V4L2_FBUF_CAP_GLOBAL_ALPHA</constant></entry>
  314. <entry>0x0020</entry>
  315. <entry>The device supports alpha blending using a global
  316. alpha value. Alpha blending makes no sense for destructive overlays.</entry>
  317. </row>
  318. <row>
  319. <entry><constant>V4L2_FBUF_CAP_LOCAL_INV_ALPHA</constant></entry>
  320. <entry>0x0040</entry>
  321. <entry>The device supports clipping/blending using the
  322. inverted alpha channel of the framebuffer or VGA signal. Alpha
  323. blending makes no sense for destructive overlays.</entry>
  324. </row>
  325. <row>
  326. <entry><constant>V4L2_FBUF_CAP_SRC_CHROMAKEY</constant></entry>
  327. <entry>0x0080</entry>
  328. <entry>The device supports Source Chroma-keying. Framebuffer pixels
  329. with the chroma-key colors are replaced by video pixels, which is exactly opposite of
  330. <constant>V4L2_FBUF_CAP_CHROMAKEY</constant></entry>
  331. </row>
  332. </tbody>
  333. </tgroup>
  334. </table>
  335. <table pgwide="1" frame="none" id="framebuffer-flags">
  336. <title>Frame Buffer Flags</title>
  337. <tgroup cols="3">
  338. &cs-def;
  339. <tbody valign="top">
  340. <row>
  341. <entry><constant>V4L2_FBUF_FLAG_PRIMARY</constant></entry>
  342. <entry>0x0001</entry>
  343. <entry>The framebuffer is the primary graphics surface.
  344. In other words, the overlay is destructive. [?]</entry>
  345. </row>
  346. <row>
  347. <entry><constant>V4L2_FBUF_FLAG_OVERLAY</constant></entry>
  348. <entry>0x0002</entry>
  349. <entry>The frame buffer is an overlay surface the same
  350. size as the capture. [?]</entry>
  351. </row>
  352. <row>
  353. <entry spanname="hspan">The purpose of
  354. <constant>V4L2_FBUF_FLAG_PRIMARY</constant> and
  355. <constant>V4L2_FBUF_FLAG_OVERLAY</constant> was never quite clear.
  356. Most drivers seem to ignore these flags. For compatibility with the
  357. <wordasword>bttv</wordasword> driver applications should set the
  358. <constant>V4L2_FBUF_FLAG_OVERLAY</constant> flag.</entry>
  359. </row>
  360. <row>
  361. <entry><constant>V4L2_FBUF_FLAG_CHROMAKEY</constant></entry>
  362. <entry>0x0004</entry>
  363. <entry>Use chroma-keying. The chroma-key color is
  364. determined by the <structfield>chromakey</structfield> field of
  365. &v4l2-window; and negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  366. linkend="overlay" />
  367. and
  368. <xref linkend="osd" />.</entry>
  369. </row>
  370. <row>
  371. <entry spanname="hspan">There are no flags to enable
  372. clipping using a list of clip rectangles or a bitmap. These methods
  373. are negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  374. linkend="overlay" /> and <xref linkend="osd" />.</entry>
  375. </row>
  376. <row>
  377. <entry><constant>V4L2_FBUF_FLAG_LOCAL_ALPHA</constant></entry>
  378. <entry>0x0008</entry>
  379. <entry>Use the alpha channel of the framebuffer to clip or
  380. blend framebuffer pixels with video images. The blend
  381. function is: output = framebuffer pixel * alpha + video pixel * (1 -
  382. alpha). The actual alpha depth depends on the framebuffer pixel
  383. format.</entry>
  384. </row>
  385. <row>
  386. <entry><constant>V4L2_FBUF_FLAG_GLOBAL_ALPHA</constant></entry>
  387. <entry>0x0010</entry>
  388. <entry>Use a global alpha value to blend the framebuffer
  389. with video images. The blend function is: output = (framebuffer pixel
  390. * alpha + video pixel * (255 - alpha)) / 255. The alpha value is
  391. determined by the <structfield>global_alpha</structfield> field of
  392. &v4l2-window; and negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  393. linkend="overlay" />
  394. and <xref linkend="osd" />.</entry>
  395. </row>
  396. <row>
  397. <entry><constant>V4L2_FBUF_FLAG_LOCAL_INV_ALPHA</constant></entry>
  398. <entry>0x0020</entry>
  399. <entry>Like
  400. <constant>V4L2_FBUF_FLAG_LOCAL_ALPHA</constant>, use the alpha channel
  401. of the framebuffer to clip or blend framebuffer pixels with video
  402. images, but with an inverted alpha value. The blend function is:
  403. output = framebuffer pixel * (1 - alpha) + video pixel * alpha. The
  404. actual alpha depth depends on the framebuffer pixel format.</entry>
  405. </row>
  406. <row>
  407. <entry><constant>V4L2_FBUF_FLAG_SRC_CHROMAKEY</constant></entry>
  408. <entry>0x0040</entry>
  409. <entry>Use source chroma-keying. The source chroma-key color is
  410. determined by the <structfield>chromakey</structfield> field of
  411. &v4l2-window; and negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  412. linkend="overlay" /> and <xref linkend="osd" />.
  413. Both chroma-keying are mutual exclusive to each other, so same
  414. <structfield>chromakey</structfield> field of &v4l2-window; is being used.</entry>
  415. </row>
  416. </tbody>
  417. </tgroup>
  418. </table>
  419. </refsect1>
  420. <refsect1>
  421. &return-value;
  422. <variablelist>
  423. <varlistentry>
  424. <term><errorcode>EPERM</errorcode></term>
  425. <listitem>
  426. <para><constant>VIDIOC_S_FBUF</constant> can only be called
  427. by a privileged user to negotiate the parameters for a destructive
  428. overlay.</para>
  429. </listitem>
  430. </varlistentry>
  431. <varlistentry>
  432. <term><errorcode>EBUSY</errorcode></term>
  433. <listitem>
  434. <para>The framebuffer parameters cannot be changed at this
  435. time because overlay is already enabled, or capturing is enabled
  436. and the hardware cannot capture and overlay simultaneously.</para>
  437. </listitem>
  438. </varlistentry>
  439. <varlistentry>
  440. <term><errorcode>EINVAL</errorcode></term>
  441. <listitem>
  442. <para>The ioctl is not supported or the
  443. <constant>VIDIOC_S_FBUF</constant> parameters are unsuitable.</para>
  444. </listitem>
  445. </varlistentry>
  446. </variablelist>
  447. </refsect1>
  448. </refentry>
  449. <!--
  450. Local Variables:
  451. mode: sgml
  452. sgml-parent-document: "v4l2.sgml"
  453. indent-tabs-mode: nil
  454. End:
  455. -->