VIDEO(9)
π VIDEO(9) π
okay so this is the video(9) page from the Kernel Developer's Manual β and itβs literally the interface between low and high level video drivers. Itβs the go-between, the group chat admin, the vibe translator β¨ No cap.
π NAME π
video β interface between low and high level video drivers π¦ periodt
β¨ SYNOPSIS β¨
bestie, include this header and call these:
#include <dev/video_if.h>
device_t
video_attach_mi(const struct video_hw_if *hw_if, device_t hw_dev);
void
video_submit_payload(device_t vl_dev,
const struct video_payload *payload);
πΈ DESCRIPTION πΈ
The video device driver is split into a high level, machine independent layer and a low level hardware dependent layer. The interface between them is the video_hw_if structure β those function pointers get called by the video layer β plus the video layer functions called by the hardware driver. Itβs giving mutual besties fr fr.
The high level video driver attaches to the low level driver when the latter calls video_attach_mi. The video_hw_if struct is as shown below. dev is the device struct for the hardware device. Return value is the video layer device.
struct video_hw_if {
int (*open)(void *, int); /* open hardware */
void (*close)(void *); /* close hardware */
const char * (*get_devname)(void *);
int (*enum_format)(void *, uint32_t, struct video_format *);
int (*get_format)(void *, struct video_format *);
int (*set_format)(void *, struct video_format *);
int (*try_format)(void *, struct video_format *);
int (*start_transfer)(void *);
int (*stop_transfer)(void *);
int (*control_iter_init)(void *, struct video_control_iter *);
int (*control_iter_next)(void *, struct video_control_iter *);
int (*get_control_desc_group)(void *,
struct video_control_desc_group *);
int (*get_control_group)(void *, struct video_control_group *);
int (*set_control_group)(void *, const struct video_control_group *);
};
The upper layer of the video driver allocates buffers for video samples. The hardware driver submits data to the video layer with video_submit_payload. vl_dev is the video layer device returned by video_attach_mi.
struct video_payload {
const uint8_t *data;
size_t size;
int frameno;
bool end_of_frame;
};
dataβ Pointer to the video data for this payload. This may only be a portion of the data in one video sample or frame.sizeβ Size in bytes of the video data in this payload.framenoβ Frame number to which this payload belongs. The hardware driver must toggle the frame number between0and1so the video layer can detect sample or frame boundaries.end_of_frameβ Optional end of frame marker. If the hardware layer sets this, the video layer can immediately pass the completed sample or frame to userspace rather than waiting for the next payload to toggleframeno.
π HARDWARE-LAYER FUNCTIONS π
The fields of video_hw_if are described in some more detail below. Some fields are optional and can be set to NULL if not needed. Okay so hereβs the rundown, bestie:
int open(void *hdl, int flags)β optional, is called when the video device is opened. It should initialize the hardware for I/O. Every successful call toopenis matched by a call toclose. Return0on success, otherwise an error code.void close(void *hdl)β optional, is called when the audio device is closed.const char * get_devname(void *hdl)β mandatory, returns aNUL-terminated string naming the device, e.g. a vendor and product model name.int enum_format(void *hdl, uint32_t index, struct video_format *format);β mandatory, called with an index from0tomax_index - 1. Fillsformatwith the format description at that index. Returns0on success, otherwise an error code.int get_format(void *hdl, struct video_format *format)β mandatory, fillsformatwith the current video format. There should be a default format so this function works before and streaming has begun. Returns0on success, otherwise an error code.int set_format(void *hdl, struct video_format *format)β mandatory, sets the format of the video stream based onformat. Fillsformatwith the actual format used which may not be the same as requested. Returns0on success, otherwise an error code.int try_format(void *hdl, struct video_format *format)β optional, likeset_formatbut does not actually change the stream format, just checks what is available. Returns0on success, otherwise an error code.int start_transfer(void *hdl)β mandatory, starts the capture of video frames. Incoming video data must be submitted to the video layer with repeated calls tovideo_submit_payload().int stop_transfer(void *hdl)β the original lists this signature here without extra prose, so weβre not inventing any πint control_iter_init(void *hdl, struct video_control_iter *)β Does nothing at this time.int control_iter_next(void *hdl, struct video_control_iter *)β Does nothing at this time.int get_control_group(void *hdl, struct video_control_group *)β the original just gives the signature here, no extra description.int set_control_group(void *hdl, struct video_control_group *)β same vibe: signature only, no extra description in the original.
π¦ SEE ALSO π¦
video(4) β go read that next, bestie π«Ά
π AUTHORS π
Patrick Mahoney <pat@polycrystal.org> π
π BUGS π
bestie, the page says itβs incomplete β no cap, here are the caveats.
- Incomplete.
- Only supports a single video capture stream.
- Does not support output streams.
- Format handling may change in the future.
- Control handling may change.
- Current design requires copying all incoming video data.
okay bye β this pageβs footer vibe is Debian, July 24, 2008 π«Άπ
π¦ where this page comes from
- nixpkgs unstable: netbsd-source 11.0
- Copyright (c) 2008 Patrick Mahoney
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms