vidioc-g-fbuf.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463
  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. Video Output Overlays are in practice always
  285. non-destructive.</entry>
  286. </row>
  287. <row>
  288. <entry><constant>V4L2_FBUF_CAP_CHROMAKEY</constant></entry>
  289. <entry>0x0002</entry>
  290. <entry>The device supports clipping by chroma-keying the
  291. images. That is, image pixels replace pixels in the VGA or video
  292. signal only where the latter assume a certain color. Chroma-keying
  293. makes no sense for destructive overlays.</entry>
  294. </row>
  295. <row>
  296. <entry><constant>V4L2_FBUF_CAP_LIST_CLIPPING</constant></entry>
  297. <entry>0x0004</entry>
  298. <entry>The device supports clipping using a list of clip
  299. rectangles.</entry>
  300. </row>
  301. <row>
  302. <entry><constant>V4L2_FBUF_CAP_BITMAP_CLIPPING</constant></entry>
  303. <entry>0x0008</entry>
  304. <entry>The device supports clipping using a bit mask.</entry>
  305. </row>
  306. <row>
  307. <entry><constant>V4L2_FBUF_CAP_LOCAL_ALPHA</constant></entry>
  308. <entry>0x0010</entry>
  309. <entry>The device supports clipping/blending using the
  310. alpha channel of the framebuffer or VGA signal. Alpha blending makes
  311. no sense for destructive overlays.</entry>
  312. </row>
  313. <row>
  314. <entry><constant>V4L2_FBUF_CAP_GLOBAL_ALPHA</constant></entry>
  315. <entry>0x0020</entry>
  316. <entry>The device supports alpha blending using a global
  317. alpha value. Alpha blending makes no sense for destructive overlays.</entry>
  318. </row>
  319. <row>
  320. <entry><constant>V4L2_FBUF_CAP_LOCAL_INV_ALPHA</constant></entry>
  321. <entry>0x0040</entry>
  322. <entry>The device supports clipping/blending using the
  323. inverted alpha channel of the framebuffer or VGA signal. Alpha
  324. blending makes no sense for destructive overlays.</entry>
  325. </row>
  326. <row>
  327. <entry><constant>V4L2_FBUF_CAP_SRC_CHROMAKEY</constant></entry>
  328. <entry>0x0080</entry>
  329. <entry>The device supports Source Chroma-keying. Video pixels
  330. with the chroma-key colors are replaced by framebuffer pixels, which is exactly opposite of
  331. <constant>V4L2_FBUF_CAP_CHROMAKEY</constant></entry>
  332. </row>
  333. </tbody>
  334. </tgroup>
  335. </table>
  336. <table pgwide="1" frame="none" id="framebuffer-flags">
  337. <title>Frame Buffer Flags</title>
  338. <tgroup cols="3">
  339. &cs-def;
  340. <tbody valign="top">
  341. <row>
  342. <entry><constant>V4L2_FBUF_FLAG_PRIMARY</constant></entry>
  343. <entry>0x0001</entry>
  344. <entry>The framebuffer is the primary graphics surface.
  345. In other words, the overlay is destructive. This flag is typically set by any
  346. driver that doesn't have the <constant>V4L2_FBUF_CAP_EXTERNOVERLAY</constant>
  347. capability and it is cleared otherwise.</entry>
  348. </row>
  349. <row>
  350. <entry><constant>V4L2_FBUF_FLAG_OVERLAY</constant></entry>
  351. <entry>0x0002</entry>
  352. <entry>If this flag is set for a video capture device, then the
  353. driver will set the initial overlay size to cover the full framebuffer size,
  354. otherwise the existing overlay size (as set by &VIDIOC-S-FMT;) will be used.
  355. Only one video capture driver (bttv) supports this flag. The use of this flag
  356. for capture devices is deprecated. There is no way to detect which drivers
  357. support this flag, so the only reliable method of setting the overlay size is
  358. through &VIDIOC-S-FMT;.
  359. If this flag is set for a video output device, then the video output overlay
  360. window is relative to the top-left corner of the framebuffer and restricted
  361. to the size of the framebuffer. If it is cleared, then the video output
  362. overlay window is relative to the video output display.
  363. </entry>
  364. </row>
  365. <row>
  366. <entry><constant>V4L2_FBUF_FLAG_CHROMAKEY</constant></entry>
  367. <entry>0x0004</entry>
  368. <entry>Use chroma-keying. The chroma-key color is
  369. determined by the <structfield>chromakey</structfield> field of
  370. &v4l2-window; and negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  371. linkend="overlay" />
  372. and
  373. <xref linkend="osd" />.</entry>
  374. </row>
  375. <row>
  376. <entry spanname="hspan">There are no flags to enable
  377. clipping using a list of clip rectangles or a bitmap. These methods
  378. are negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  379. linkend="overlay" /> and <xref linkend="osd" />.</entry>
  380. </row>
  381. <row>
  382. <entry><constant>V4L2_FBUF_FLAG_LOCAL_ALPHA</constant></entry>
  383. <entry>0x0008</entry>
  384. <entry>Use the alpha channel of the framebuffer to clip or
  385. blend framebuffer pixels with video images. The blend
  386. function is: output = framebuffer pixel * alpha + video pixel * (1 -
  387. alpha). The actual alpha depth depends on the framebuffer pixel
  388. format.</entry>
  389. </row>
  390. <row>
  391. <entry><constant>V4L2_FBUF_FLAG_GLOBAL_ALPHA</constant></entry>
  392. <entry>0x0010</entry>
  393. <entry>Use a global alpha value to blend the framebuffer
  394. with video images. The blend function is: output = (framebuffer pixel
  395. * alpha + video pixel * (255 - alpha)) / 255. The alpha value is
  396. determined by the <structfield>global_alpha</structfield> field of
  397. &v4l2-window; and negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  398. linkend="overlay" />
  399. and <xref linkend="osd" />.</entry>
  400. </row>
  401. <row>
  402. <entry><constant>V4L2_FBUF_FLAG_LOCAL_INV_ALPHA</constant></entry>
  403. <entry>0x0020</entry>
  404. <entry>Like
  405. <constant>V4L2_FBUF_FLAG_LOCAL_ALPHA</constant>, use the alpha channel
  406. of the framebuffer to clip or blend framebuffer pixels with video
  407. images, but with an inverted alpha value. The blend function is:
  408. output = framebuffer pixel * (1 - alpha) + video pixel * alpha. The
  409. actual alpha depth depends on the framebuffer pixel format.</entry>
  410. </row>
  411. <row>
  412. <entry><constant>V4L2_FBUF_FLAG_SRC_CHROMAKEY</constant></entry>
  413. <entry>0x0040</entry>
  414. <entry>Use source chroma-keying. The source chroma-key color is
  415. determined by the <structfield>chromakey</structfield> field of
  416. &v4l2-window; and negotiated with the &VIDIOC-S-FMT; ioctl, see <xref
  417. linkend="overlay" /> and <xref linkend="osd" />.
  418. Both chroma-keying are mutual exclusive to each other, so same
  419. <structfield>chromakey</structfield> field of &v4l2-window; is being used.</entry>
  420. </row>
  421. </tbody>
  422. </tgroup>
  423. </table>
  424. </refsect1>
  425. <refsect1>
  426. &return-value;
  427. <variablelist>
  428. <varlistentry>
  429. <term><errorcode>EPERM</errorcode></term>
  430. <listitem>
  431. <para><constant>VIDIOC_S_FBUF</constant> can only be called
  432. by a privileged user to negotiate the parameters for a destructive
  433. overlay.</para>
  434. </listitem>
  435. </varlistentry>
  436. <varlistentry>
  437. <term><errorcode>EINVAL</errorcode></term>
  438. <listitem>
  439. <para>The <constant>VIDIOC_S_FBUF</constant> parameters are unsuitable.</para>
  440. </listitem>
  441. </varlistentry>
  442. </variablelist>
  443. </refsect1>
  444. </refentry>