vidioc-g-fbuf.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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>struct</entry>
  143. <entry><structfield>fmt</structfield></entry>
  144. <entry></entry>
  145. <entry>Layout of the frame buffer.</entry>
  146. </row>
  147. <row>
  148. <entry></entry>
  149. <entry>__u32</entry>
  150. <entry><structfield>width</structfield></entry>
  151. <entry>Width of the frame buffer in pixels.</entry>
  152. </row>
  153. <row>
  154. <entry></entry>
  155. <entry>__u32</entry>
  156. <entry><structfield>height</structfield></entry>
  157. <entry>Height of the frame buffer in pixels.</entry>
  158. </row>
  159. <row>
  160. <entry></entry>
  161. <entry>__u32</entry>
  162. <entry><structfield>pixelformat</structfield></entry>
  163. <entry>The pixel format of the
  164. framebuffer.</entry>
  165. </row>
  166. <row>
  167. <entry></entry>
  168. <entry></entry>
  169. <entry></entry>
  170. <entry>For <wordasword>non-destructive Video
  171. Overlays</wordasword> this field only defines a format for the
  172. &v4l2-window; <structfield>chromakey</structfield> field.</entry>
  173. </row>
  174. <row>
  175. <entry></entry>
  176. <entry></entry>
  177. <entry></entry>
  178. <entry>For <wordasword>destructive Video
  179. Overlays</wordasword> applications must initialize this field. For
  180. <wordasword>Video Output Overlays</wordasword> the driver must return
  181. a valid format.</entry>
  182. </row>
  183. <row>
  184. <entry></entry>
  185. <entry></entry>
  186. <entry></entry>
  187. <entry>Usually this is an RGB format (for example
  188. <link linkend="V4L2-PIX-FMT-RGB565"><constant>V4L2_PIX_FMT_RGB565</constant></link>)
  189. but YUV formats (only packed YUV formats when chroma keying is used,
  190. not including <constant>V4L2_PIX_FMT_YUYV</constant> and
  191. <constant>V4L2_PIX_FMT_UYVY</constant>) and the
  192. <constant>V4L2_PIX_FMT_PAL8</constant> format are also permitted. The
  193. behavior of the driver when an application requests a compressed
  194. format is undefined. See <xref linkend="pixfmt" /> for information on
  195. pixel formats.</entry>
  196. </row>
  197. <row>
  198. <entry></entry>
  199. <entry>&v4l2-field;</entry>
  200. <entry><structfield>field</structfield></entry>
  201. <entry>Drivers and applications shall ignore this field.
  202. If applicable, the field order is selected with the &VIDIOC-S-FMT;
  203. ioctl, using the <structfield>field</structfield> field of
  204. &v4l2-window;.</entry>
  205. </row>
  206. <row>
  207. <entry></entry>
  208. <entry>__u32</entry>
  209. <entry><structfield>bytesperline</structfield></entry>
  210. <entry>Distance in bytes between the leftmost pixels in
  211. two adjacent lines.</entry>
  212. </row>
  213. <row>
  214. <entry spanname="hspan"><para>This field is irrelevant to
  215. <wordasword>non-destructive Video
  216. Overlays</wordasword>.</para><para>For <wordasword>destructive Video
  217. Overlays</wordasword> both applications and drivers can set this field
  218. to request padding bytes at the end of each line. Drivers however may
  219. ignore the requested value, returning <structfield>width</structfield>
  220. times bytes-per-pixel or a larger value required by the hardware. That
  221. implies applications can just set this field to zero to get a
  222. reasonable default.</para><para>For <wordasword>Video Output
  223. Overlays</wordasword> the driver must return a valid
  224. value.</para><para>Video hardware may access padding bytes, therefore
  225. they must reside in accessible memory. Consider for example the case
  226. where padding bytes after the last line of an image cross a system
  227. page boundary. Capture devices may write padding bytes, the value is
  228. undefined. Output devices ignore the contents of padding
  229. bytes.</para><para>When the image format is planar the
  230. <structfield>bytesperline</structfield> value applies to the first
  231. plane and is divided by the same factor as the
  232. <structfield>width</structfield> field for the other planes. For
  233. example the Cb and Cr planes of a YUV 4:2:0 image have half as many
  234. padding bytes following each line as the Y plane. To avoid ambiguities
  235. drivers must return a <structfield>bytesperline</structfield> value
  236. rounded up to a multiple of the scale factor.</para></entry>
  237. </row>
  238. <row>
  239. <entry></entry>
  240. <entry>__u32</entry>
  241. <entry><structfield>sizeimage</structfield></entry>
  242. <entry><para>This field is irrelevant to
  243. <wordasword>non-destructive Video Overlays</wordasword>. For
  244. <wordasword>destructive Video Overlays</wordasword> applications must
  245. initialize this field. For <wordasword>Video Output
  246. Overlays</wordasword> the driver must return a valid
  247. format.</para><para>Together with <structfield>base</structfield> it
  248. defines the framebuffer memory accessible by the
  249. driver.</para></entry>
  250. </row>
  251. <row>
  252. <entry></entry>
  253. <entry>&v4l2-colorspace;</entry>
  254. <entry><structfield>colorspace</structfield></entry>
  255. <entry>This information supplements the
  256. <structfield>pixelformat</structfield> and must be set by the driver,
  257. see <xref linkend="colorspaces" />.</entry>
  258. </row>
  259. <row>
  260. <entry></entry>
  261. <entry>__u32</entry>
  262. <entry><structfield>priv</structfield></entry>
  263. <entry>Reserved. Drivers and applications must set this field to
  264. zero.</entry>
  265. </row>
  266. </tbody>
  267. </tgroup>
  268. </table>
  269. <table pgwide="1" frame="none" id="framebuffer-cap">
  270. <title>Frame Buffer Capability Flags</title>
  271. <tgroup cols="3">
  272. &cs-def;
  273. <tbody valign="top">
  274. <row>
  275. <entry><constant>V4L2_FBUF_CAP_EXTERNOVERLAY</constant></entry>
  276. <entry>0x0001</entry>
  277. <entry>The device is capable of non-destructive overlays.
  278. When the driver clears this flag, only destructive overlays are
  279. supported. There are no drivers yet which support both destructive and
  280. non-destructive overlays. Video Output Overlays are in practice always
  281. non-destructive.</entry>
  282. </row>
  283. <row>
  284. <entry><constant>V4L2_FBUF_CAP_CHROMAKEY</constant></entry>
  285. <entry>0x0002</entry>
  286. <entry>The device supports clipping by chroma-keying the
  287. images. That is, image pixels replace pixels in the VGA or video
  288. signal only where the latter assume a certain color. Chroma-keying
  289. makes no sense for destructive overlays.</entry>
  290. </row>
  291. <row>
  292. <entry><constant>V4L2_FBUF_CAP_LIST_CLIPPING</constant></entry>
  293. <entry>0x0004</entry>
  294. <entry>The device supports clipping using a list of clip
  295. rectangles.</entry>
  296. </row>
  297. <row>
  298. <entry><constant>V4L2_FBUF_CAP_BITMAP_CLIPPING</constant></entry>
  299. <entry>0x0008</entry>
  300. <entry>The device supports clipping using a bit mask.</entry>
  301. </row>
  302. <row>
  303. <entry><constant>V4L2_FBUF_CAP_LOCAL_ALPHA</constant></entry>
  304. <entry>0x0010</entry>
  305. <entry>The device supports clipping/blending using the
  306. alpha channel of the framebuffer or VGA signal. Alpha blending makes
  307. no sense for destructive overlays.</entry>
  308. </row>
  309. <row>
  310. <entry><constant>V4L2_FBUF_CAP_GLOBAL_ALPHA</constant></entry>
  311. <entry>0x0020</entry>
  312. <entry>The device supports alpha blending using a global
  313. alpha value. Alpha blending makes no sense for destructive overlays.</entry>
  314. </row>
  315. <row>
  316. <entry><constant>V4L2_FBUF_CAP_LOCAL_INV_ALPHA</constant></entry>
  317. <entry>0x0040</entry>
  318. <entry>The device supports clipping/blending using the
  319. inverted alpha channel of the framebuffer or VGA signal. Alpha
  320. blending makes no sense for destructive overlays.</entry>
  321. </row>
  322. <row>
  323. <entry><constant>V4L2_FBUF_CAP_SRC_CHROMAKEY</constant></entry>
  324. <entry>0x0080</entry>
  325. <entry>The device supports Source Chroma-keying. Video pixels
  326. with the chroma-key colors are replaced by framebuffer pixels, which is exactly opposite of
  327. <constant>V4L2_FBUF_CAP_CHROMAKEY</constant></entry>
  328. </row>
  329. </tbody>
  330. </tgroup>
  331. </table>
  332. <table pgwide="1" frame="none" id="framebuffer-flags">
  333. <title>Frame Buffer Flags</title>
  334. <tgroup cols="3">
  335. &cs-def;
  336. <tbody valign="top">
  337. <row>
  338. <entry><constant>V4L2_FBUF_FLAG_PRIMARY</constant></entry>
  339. <entry>0x0001</entry>
  340. <entry>The framebuffer is the primary graphics surface.
  341. In other words, the overlay is destructive. This flag is typically set by any
  342. driver that doesn't have the <constant>V4L2_FBUF_CAP_EXTERNOVERLAY</constant>
  343. capability and it is cleared otherwise.</entry>
  344. </row>
  345. <row>
  346. <entry><constant>V4L2_FBUF_FLAG_OVERLAY</constant></entry>
  347. <entry>0x0002</entry>
  348. <entry>If this flag is set for a video capture device, then the
  349. driver will set the initial overlay size to cover the full framebuffer size,
  350. otherwise the existing overlay size (as set by &VIDIOC-S-FMT;) will be used.
  351. Only one video capture driver (bttv) supports this flag. The use of this flag
  352. for capture devices is deprecated. There is no way to detect which drivers
  353. support this flag, so the only reliable method of setting the overlay size is
  354. through &VIDIOC-S-FMT;.
  355. If this flag is set for a video output device, then the video output overlay
  356. window is relative to the top-left corner of the framebuffer and restricted
  357. to the size of the framebuffer. If it is cleared, then the video output
  358. overlay window is relative to the video output display.
  359. </entry>
  360. </row>
  361. <row>
  362. <entry><constant>V4L2_FBUF_FLAG_CHROMAKEY</constant></entry>
  363. <entry>0x0004</entry>
  364. <entry>Use chroma-keying. The chroma-key color is
  365. determined by the <structfield>chromakey</structfield> field of
  366. &v4l2-window; and negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  367. linkend="overlay" />
  368. and
  369. <xref linkend="osd" />.</entry>
  370. </row>
  371. <row>
  372. <entry spanname="hspan">There are no flags to enable
  373. clipping using a list of clip rectangles or a bitmap. These methods
  374. are negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  375. linkend="overlay" /> and <xref linkend="osd" />.</entry>
  376. </row>
  377. <row>
  378. <entry><constant>V4L2_FBUF_FLAG_LOCAL_ALPHA</constant></entry>
  379. <entry>0x0008</entry>
  380. <entry>Use the alpha channel of the framebuffer to clip or
  381. blend framebuffer pixels with video images. The blend
  382. function is: output = framebuffer pixel * alpha + video pixel * (1 -
  383. alpha). The actual alpha depth depends on the framebuffer pixel
  384. format.</entry>
  385. </row>
  386. <row>
  387. <entry><constant>V4L2_FBUF_FLAG_GLOBAL_ALPHA</constant></entry>
  388. <entry>0x0010</entry>
  389. <entry>Use a global alpha value to blend the framebuffer
  390. with video images. The blend function is: output = (framebuffer pixel
  391. * alpha + video pixel * (255 - alpha)) / 255. The alpha value is
  392. determined by the <structfield>global_alpha</structfield> field of
  393. &v4l2-window; and negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  394. linkend="overlay" />
  395. and <xref linkend="osd" />.</entry>
  396. </row>
  397. <row>
  398. <entry><constant>V4L2_FBUF_FLAG_LOCAL_INV_ALPHA</constant></entry>
  399. <entry>0x0020</entry>
  400. <entry>Like
  401. <constant>V4L2_FBUF_FLAG_LOCAL_ALPHA</constant>, use the alpha channel
  402. of the framebuffer to clip or blend framebuffer pixels with video
  403. images, but with an inverted alpha value. The blend function is:
  404. output = framebuffer pixel * (1 - alpha) + video pixel * alpha. The
  405. actual alpha depth depends on the framebuffer pixel format.</entry>
  406. </row>
  407. <row>
  408. <entry><constant>V4L2_FBUF_FLAG_SRC_CHROMAKEY</constant></entry>
  409. <entry>0x0040</entry>
  410. <entry>Use source chroma-keying. The source chroma-key color is
  411. determined by the <structfield>chromakey</structfield> field of
  412. &v4l2-window; and negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  413. linkend="overlay" /> and <xref linkend="osd" />.
  414. Both chroma-keying are mutual exclusive to each other, so same
  415. <structfield>chromakey</structfield> field of &v4l2-window; is being used.</entry>
  416. </row>
  417. </tbody>
  418. </tgroup>
  419. </table>
  420. </refsect1>
  421. <refsect1>
  422. &return-value;
  423. <variablelist>
  424. <varlistentry>
  425. <term><errorcode>EPERM</errorcode></term>
  426. <listitem>
  427. <para><constant>VIDIOC_S_FBUF</constant> can only be called
  428. by a privileged user to negotiate the parameters for a destructive
  429. overlay.</para>
  430. </listitem>
  431. </varlistentry>
  432. <varlistentry>
  433. <term><errorcode>EINVAL</errorcode></term>
  434. <listitem>
  435. <para>The <constant>VIDIOC_S_FBUF</constant> parameters are unsuitable.</para>
  436. </listitem>
  437. </varlistentry>
  438. </variablelist>
  439. </refsect1>
  440. </refentry>