7.30. ioctl VIDIOC_G_FBUF, VIDIOC_S_FBUF¶
7.30.1. Name¶
VIDIOC_G_FBUF - VIDIOC_S_FBUF - Get or set frame buffer overlay parameters
7.30.2. Synopsis¶
-
VIDIOC_G_FBUF¶
int ioctl(int fd, VIDIOC_G_FBUF, struct v4l2_framebuffer *argp)
-
VIDIOC_S_FBUF¶
int ioctl(int fd, VIDIOC_S_FBUF, const struct v4l2_framebuffer *argp)
7.30.3. Arguments¶
fd
File descriptor returned by
open()
.argp
Pointer to struct
v4l2_framebuffer
.
7.30.4. Description¶
Applications can use the VIDIOC_G_FBUF and VIDIOC_S_FBUF ioctl
to get and set the framebuffer parameters for a
Video Overlay or Video Output Overlay
(OSD). The type of overlay is implied by the device type (capture or
output device) and can be determined with the
ioctl VIDIOC_QUERYCAP ioctl. One /dev/videoN
device must not support both kinds of overlay.
The V4L2 API distinguishes destructive and non-destructive overlays. A destructive overlay copies captured video images into the video memory of a graphics card. A non-destructive overlay blends video images into a VGA signal or graphics into a video signal. Video Output Overlays are always non-destructive.
Destructive overlay support has been removed: with modern GPUs and CPUs this is no longer needed, and it was always a very dangerous feature.
To get the current parameters applications call the VIDIOC_G_FBUF
ioctl with a pointer to a struct v4l2_framebuffer
structure. The driver fills all fields of the structure or returns an
EINVAL error code when overlays are not supported.
To set the parameters for a Video Output Overlay, applications must
initialize the flags
field of a struct
v4l2_framebuffer
. Since the framebuffer is
implemented on the TV card all other parameters are determined by the
driver. When an application calls VIDIOC_S_FBUF with a pointer to
this structure, the driver prepares for the overlay and returns the
framebuffer parameters as VIDIOC_G_FBUF does, or it returns an error
code.
To set the parameters for a Video Capture Overlay
applications must initialize the flags
field, the fmt
substructure, and call VIDIOC_S_FBUF. Again the driver prepares for
the overlay and returns the framebuffer parameters as VIDIOC_G_FBUF
does, or it returns an error code.
-
type v4l2_framebuffer¶
__u32 |
|
Overlay capability flags set by the driver, see Frame Buffer Capability Flags. |
|
__u32 |
|
Overlay control flags set by application and driver, see Frame Buffer Flags |
|
void * |
|
Physical base address of the framebuffer, that is the address of the pixel in the top left corner of the framebuffer. For VIDIOC_S_FBUF this field is no longer supported and the kernel will always set this to NULL. For Video Output Overlays the driver will return a valid base address, so applications can find the corresponding Linux framebuffer device (see Video Output Overlay Interface). For Video Capture Overlays this field will always be NULL. |
|
struct |
|
Layout of the frame buffer. |
|
__u32 |
|
Width of the frame buffer in pixels. |
|
__u32 |
|
Height of the frame buffer in pixels. |
|
__u32 |
|
The pixel format of the framebuffer. |
|
For non-destructive Video Overlays this field only defines a
format for the struct |
|||
For Video Output Overlays the driver must return a valid format. |
|||
Usually this is an RGB format (for example
V4L2_PIX_FMT_RGB565) but YUV
formats (only packed YUV formats when chroma keying is used, not
including |
|||
enum |
|
Drivers and applications shall ignore this field. If applicable,
the field order is selected with the
VIDIOC_S_FMT ioctl, using the |
|
__u32 |
|
Distance in bytes between the leftmost pixels in two adjacent lines. |
|
This field is irrelevant to non-destructive Video Overlays. For Video Output Overlays the driver must return a valid value. Video hardware may access padding bytes, therefore they must reside in accessible memory. Consider for example the case where padding bytes after the last line of an image cross a system page boundary. Capture devices may write padding bytes, the value is undefined. Output devices ignore the contents of padding bytes. When the image format is planar the |
|||
__u32 |
|
This field is irrelevant to non-destructive Video Overlays. For Video Output Overlays the driver must return a valid format. Together with |
|
enum |
|
This information supplements the |
|
__u32 |
|
Reserved. Drivers and applications must set this field to zero. |
|
0x0001 |
The device is capable of non-destructive overlays. When the driver clears this flag, only destructive overlays are supported. There are no drivers yet which support both destructive and non-destructive overlays. Video Output Overlays are in practice always non-destructive. |
|
0x0002 |
The device supports clipping by chroma-keying the images. That is, image pixels replace pixels in the VGA or video signal only where the latter assume a certain color. Chroma-keying makes no sense for destructive overlays. |
|
0x0004 |
The device supports clipping using a list of clip rectangles. Note that this is no longer supported. |
|
0x0008 |
The device supports clipping using a bit mask. Note that this is no longer supported. |
|
0x0010 |
The device supports clipping/blending using the alpha channel of the framebuffer or VGA signal. Alpha blending makes no sense for destructive overlays. |
|
0x0020 |
The device supports alpha blending using a global alpha value. Alpha blending makes no sense for destructive overlays. |
|
0x0040 |
The device supports clipping/blending using the inverted alpha channel of the framebuffer or VGA signal. Alpha blending makes no sense for destructive overlays. |
|
0x0080 |
The device supports Source Chroma-keying. Video pixels with the
chroma-key colors are replaced by framebuffer pixels, which is
exactly opposite of |
|
0x0001 |
The framebuffer is the primary graphics surface. In other words,
the overlay is destructive. This flag is typically set by any
driver that doesn’t have the |
|
0x0002 |
If this flag is set for a video capture device, then the driver will set the initial overlay size to cover the full framebuffer size, otherwise the existing overlay size (as set by VIDIOC_S_FMT) will be used. Only one video capture driver (bttv) supports this flag. The use of this flag for capture devices is deprecated. There is no way to detect which drivers support this flag, so the only reliable method of setting the overlay size is through VIDIOC_S_FMT. If this flag is set for a video output device, then the video output overlay window is relative to the top-left corner of the framebuffer and restricted to the size of the framebuffer. If it is cleared, then the video output overlay window is relative to the video output display. |
|
0x0004 |
Use chroma-keying. The chroma-key color is determined by the
|
There are no flags to enable clipping using a list of clip rectangles or a bitmap. These methods are negotiated with the VIDIOC_S_FMT ioctl, see Video Overlay Interface and Video Output Overlay Interface. |
||
|
0x0008 |
Use the alpha channel of the framebuffer to clip or blend framebuffer pixels with video images. The blend function is: output = framebuffer pixel * alpha + video pixel * (1 - alpha). The actual alpha depth depends on the framebuffer pixel format. |
|
0x0010 |
Use a global alpha value to blend the framebuffer with video
images. The blend function is: output = (framebuffer pixel * alpha
+ video pixel * (255 - alpha)) / 255. The alpha value is
determined by the |
|
0x0020 |
Like |
|
0x0040 |
Use source chroma-keying. The source chroma-key color is
determined by the |
7.30.5. Return Value¶
On success 0 is returned, on error -1 and the errno
variable is set
appropriately. The generic error codes are described at the
Generic Error Codes chapter.
- EPERM
VIDIOC_S_FBUF can only be called by a privileged user to negotiate the parameters for a destructive overlay.
- EINVAL
The VIDIOC_S_FBUF parameters are unsuitable.