Zephyr API Documentation 4.1.99
A Scalable Open Source RTOS
|
|
4.1.99 |
Video Interface . More...
Topics | |
Video pixel formats | |
The '|' characters separate the pixels or logical blocks, and spaces separate the bytes. | |
Data Structures | |
struct | video_format |
Video format structure. More... | |
struct | video_format_cap |
Video format capability. More... | |
struct | video_caps |
Video format capabilities. More... | |
struct | video_buffer |
Video buffer structure. More... | |
struct | video_frmival |
Video frame interval structure. More... | |
struct | video_frmival_stepwise |
Video frame interval stepwise structure. More... | |
struct | video_frmival_enum |
Video frame interval enumeration structure. More... | |
struct | video_driver_api |
Macros | |
#define | LINE_COUNT_HEIGHT (-1) |
Typedefs | |
typedef int(* | video_api_format_t) (const struct device *dev, struct video_format *fmt) |
Function pointer type for video_set/get_format() | |
typedef int(* | video_api_frmival_t) (const struct device *dev, struct video_frmival *frmival) |
Function pointer type for video_set/get_frmival() | |
typedef int(* | video_api_enum_frmival_t) (const struct device *dev, struct video_frmival_enum *fie) |
List all supported frame intervals of a given format. | |
typedef int(* | video_api_enqueue_t) (const struct device *dev, struct video_buffer *buf) |
Enqueue a buffer in the driver’s incoming queue. | |
typedef int(* | video_api_dequeue_t) (const struct device *dev, struct video_buffer **buf, k_timeout_t timeout) |
Dequeue a buffer from the driver’s outgoing queue. | |
typedef int(* | video_api_flush_t) (const struct device *dev, bool cancel) |
Flush endpoint buffers, buffer are moved from incoming queue to outgoing queue. | |
typedef int(* | video_api_set_stream_t) (const struct device *dev, bool enable, enum video_buf_type type) |
Start or stop streaming on the video device. | |
typedef int(* | video_api_ctrl_t) (const struct device *dev, uint32_t cid) |
Set/Get a video control value. | |
typedef int(* | video_api_get_caps_t) (const struct device *dev, struct video_caps *caps) |
Get capabilities of a video endpoint. | |
typedef int(* | video_api_set_signal_t) (const struct device *dev, struct k_poll_signal *sig) |
Register/Unregister poll signal for buffer events. | |
Enumerations | |
enum | video_buf_type { VIDEO_BUF_TYPE_INPUT , VIDEO_BUF_TYPE_OUTPUT } |
video_buf_type enum More... | |
enum | video_frmival_type { VIDEO_FRMIVAL_TYPE_DISCRETE = 1 , VIDEO_FRMIVAL_TYPE_STEPWISE = 2 } |
video_frmival_type enum More... | |
enum | video_signal_result { VIDEO_BUF_DONE , VIDEO_BUF_ABORTED , VIDEO_BUF_ERROR } |
video_event enum More... | |
Functions | |
static int | video_set_format (const struct device *dev, struct video_format *fmt) |
Set video format. | |
static int | video_get_format (const struct device *dev, struct video_format *fmt) |
Get video format. | |
static int | video_set_frmival (const struct device *dev, struct video_frmival *frmival) |
Set video frame interval. | |
static int | video_get_frmival (const struct device *dev, struct video_frmival *frmival) |
Get video frame interval. | |
static int | video_enum_frmival (const struct device *dev, struct video_frmival_enum *fie) |
List video frame intervals. | |
static int | video_enqueue (const struct device *dev, struct video_buffer *buf) |
Enqueue a video buffer. | |
static int | video_dequeue (const struct device *dev, struct video_buffer **buf, k_timeout_t timeout) |
Dequeue a video buffer. | |
static int | video_flush (const struct device *dev, bool cancel) |
Flush endpoint buffers. | |
static int | video_stream_start (const struct device *dev, enum video_buf_type type) |
Start the video device function. | |
static int | video_stream_stop (const struct device *dev, enum video_buf_type type) |
Stop the video device function. | |
static int | video_get_caps (const struct device *dev, struct video_caps *caps) |
Get the capabilities of a video endpoint. | |
int | video_set_ctrl (const struct device *dev, struct video_control *control) |
Set the value of a control. | |
int | video_get_ctrl (const struct device *dev, struct video_control *control) |
Get the current value of a control. | |
int | video_query_ctrl (const struct device *dev, struct video_ctrl_query *cq) |
Query information about a control. | |
void | video_print_ctrl (const struct device *const dev, const struct video_ctrl_query *const cq) |
Print all the information of a control. | |
static int | video_set_signal (const struct device *dev, struct k_poll_signal *sig) |
Register/Unregister k_poll signal for a video endpoint. | |
struct video_buffer * | video_buffer_aligned_alloc (size_t size, size_t align, k_timeout_t timeout) |
Allocate aligned video buffer. | |
struct video_buffer * | video_buffer_alloc (size_t size, k_timeout_t timeout) |
Allocate video buffer. | |
void | video_buffer_release (struct video_buffer *buf) |
Release a video buffer. | |
int | video_format_caps_index (const struct video_format_cap *fmts, const struct video_format *fmt, size_t *idx) |
Search for a format that matches in a list of capabilities. | |
static uint64_t | video_frmival_nsec (const struct video_frmival *frmival) |
Compute the difference between two frame intervals. | |
void | video_closest_frmival_stepwise (const struct video_frmival_stepwise *stepwise, const struct video_frmival *desired, struct video_frmival *match) |
Find the closest match to a frame interval value within a stepwise frame interval. | |
void | video_closest_frmival (const struct device *dev, struct video_frmival_enum *match) |
Find the closest match to a frame interval value within a video device. | |
int64_t | video_get_csi_link_freq (const struct device *dev, uint8_t bpp, uint8_t lane_nb) |
Return the link-frequency advertised by a device. | |
MIPI CSI2 Data-types | |
#define | VIDEO_MIPI_CSI2_DT_NULL 0x10 |
#define | VIDEO_MIPI_CSI2_DT_BLANKING 0x11 |
#define | VIDEO_MIPI_CSI2_DT_EMBEDDED_8 0x12 |
#define | VIDEO_MIPI_CSI2_DT_YUV420_8 0x18 |
#define | VIDEO_MIPI_CSI2_DT_YUV420_10 0x19 |
#define | VIDEO_MIPI_CSI2_DT_YUV420_CSPS_8 0x1c |
#define | VIDEO_MIPI_CSI2_DT_YUV420_CSPS_10 0x1d |
#define | VIDEO_MIPI_CSI2_DT_YUV422_8 0x1e |
#define | VIDEO_MIPI_CSI2_DT_YUV422_10 0x1f |
#define | VIDEO_MIPI_CSI2_DT_RGB444 0x20 |
#define | VIDEO_MIPI_CSI2_DT_RGB555 0x21 |
#define | VIDEO_MIPI_CSI2_DT_RGB565 0x22 |
#define | VIDEO_MIPI_CSI2_DT_RGB666 0x23 |
#define | VIDEO_MIPI_CSI2_DT_RGB888 0x24 |
#define | VIDEO_MIPI_CSI2_DT_RAW6 0x28 |
#define | VIDEO_MIPI_CSI2_DT_RAW7 0x29 |
#define | VIDEO_MIPI_CSI2_DT_RAW8 0x2a |
#define | VIDEO_MIPI_CSI2_DT_RAW10 0x2b |
#define | VIDEO_MIPI_CSI2_DT_RAW12 0x2c |
#define | VIDEO_MIPI_CSI2_DT_RAW14 0x2d |
#define | VIDEO_MIPI_CSI2_DT_USER(n) |
Video Interface .
#define LINE_COUNT_HEIGHT (-1) |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_BLANKING 0x11 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_EMBEDDED_8 0x12 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_NULL 0x10 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_RAW10 0x2b |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_RAW12 0x2c |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_RAW14 0x2d |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_RAW6 0x28 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_RAW7 0x29 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_RAW8 0x2a |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_RGB444 0x20 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_RGB555 0x21 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_RGB565 0x22 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_RGB666 0x23 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_RGB888 0x24 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_USER | ( | n | ) |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_YUV420_10 0x19 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_YUV420_8 0x18 |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_10 0x1d |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_8 0x1c |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_YUV422_10 0x1f |
#include <zephyr/drivers/video.h>
#define VIDEO_MIPI_CSI2_DT_YUV422_8 0x1e |
#include <zephyr/drivers/video.h>
#include <zephyr/drivers/video.h>
Set/Get a video control value.
dev | Pointer to the device structure. |
cid | Id of the control to set/get its value. |
typedef int(* video_api_dequeue_t) (const struct device *dev, struct video_buffer **buf, k_timeout_t timeout) |
#include <zephyr/drivers/video.h>
Dequeue a buffer from the driver’s outgoing queue.
See video_dequeue() for argument descriptions.
typedef int(* video_api_enqueue_t) (const struct device *dev, struct video_buffer *buf) |
#include <zephyr/drivers/video.h>
Enqueue a buffer in the driver’s incoming queue.
See video_enqueue() for argument descriptions.
typedef int(* video_api_enum_frmival_t) (const struct device *dev, struct video_frmival_enum *fie) |
#include <zephyr/drivers/video.h>
List all supported frame intervals of a given format.
See video_enum_frmival() for argument descriptions.
#include <zephyr/drivers/video.h>
Flush endpoint buffers, buffer are moved from incoming queue to outgoing queue.
See video_flush() for argument descriptions.
typedef int(* video_api_format_t) (const struct device *dev, struct video_format *fmt) |
#include <zephyr/drivers/video.h>
Function pointer type for video_set/get_format()
See video_set/get_format() for argument descriptions.
typedef int(* video_api_frmival_t) (const struct device *dev, struct video_frmival *frmival) |
#include <zephyr/drivers/video.h>
Function pointer type for video_set/get_frmival()
See video_set/get_frmival() for argument descriptions.
typedef int(* video_api_get_caps_t) (const struct device *dev, struct video_caps *caps) |
#include <zephyr/drivers/video.h>
Get capabilities of a video endpoint.
See video_get_caps() for argument descriptions.
typedef int(* video_api_set_signal_t) (const struct device *dev, struct k_poll_signal *sig) |
#include <zephyr/drivers/video.h>
Register/Unregister poll signal for buffer events.
See video_set_signal() for argument descriptions.
typedef int(* video_api_set_stream_t) (const struct device *dev, bool enable, enum video_buf_type type) |
#include <zephyr/drivers/video.h>
Start or stop streaming on the video device.
Start (enable == true) or stop (enable == false) streaming on the video device.
dev | Pointer to the device structure. |
enable | If true, start streaming, otherwise stop streaming. |
type | The type of the buffers stream to start or stop. |
0 | on success, otherwise a negative errno code. |
enum video_buf_type |
#include <zephyr/drivers/video.h>
video_buf_type enum
Supported video buffer types of a video device. The direction (input or output) is defined from the device's point of view. Devices like cameras support only output type, encoders support only input types while m2m devices like ISP, PxP support both input and output types.
Enumerator | |
---|---|
VIDEO_BUF_TYPE_INPUT | input buffer type |
VIDEO_BUF_TYPE_OUTPUT | output buffer type |
enum video_frmival_type |
#include <zephyr/drivers/video.h>
video_frmival_type enum
Supported frame interval type of a video device.
Enumerator | |
---|---|
VIDEO_FRMIVAL_TYPE_DISCRETE | discrete frame interval type |
VIDEO_FRMIVAL_TYPE_STEPWISE | stepwise frame interval type |
enum video_signal_result |
#include <zephyr/drivers/video.h>
video_event enum
Identify video event.
Enumerator | |
---|---|
VIDEO_BUF_DONE | |
VIDEO_BUF_ABORTED | |
VIDEO_BUF_ERROR |
struct video_buffer * video_buffer_aligned_alloc | ( | size_t | size, |
size_t | align, | ||
k_timeout_t | timeout ) |
#include <zephyr/drivers/video.h>
Allocate aligned video buffer.
size | Size of the video buffer (in bytes). |
align | Alignment of the requested memory, must be a power of two. |
timeout | Timeout duration or K_NO_WAIT |
pointer | to allocated video buffer |
struct video_buffer * video_buffer_alloc | ( | size_t | size, |
k_timeout_t | timeout ) |
#include <zephyr/drivers/video.h>
Allocate video buffer.
size | Size of the video buffer (in bytes). |
timeout | Timeout duration or K_NO_WAIT |
pointer | to allocated video buffer |
void video_buffer_release | ( | struct video_buffer * | buf | ) |
#include <zephyr/drivers/video.h>
Release a video buffer.
buf | Pointer to the video buffer to release. |
void video_closest_frmival | ( | const struct device * | dev, |
struct video_frmival_enum * | match ) |
#include <zephyr/drivers/video.h>
Find the closest match to a frame interval value within a video device.
To compute the closest match, fill match
with the following fields:
match->format
to the video_format of interest.match->type
to VIDEO_FRMIVAL_TYPE_DISCRETE.match->discrete
to the desired frame interval.The result will be loaded into match
, with the following fields set:
match->discrete
to the value of the closest frame interval.match->index
to the index of the closest frame interval.dev | Video device to query. |
match | Frame interval enumerator with the query, and loaded with the result. |
void video_closest_frmival_stepwise | ( | const struct video_frmival_stepwise * | stepwise, |
const struct video_frmival * | desired, | ||
struct video_frmival * | match ) |
#include <zephyr/drivers/video.h>
Find the closest match to a frame interval value within a stepwise frame interval.
stepwise | The stepwise frame interval range to search |
desired | The frame interval for which find the closest match |
match | The resulting frame interval closest to desired |
|
inlinestatic |
#include <zephyr/drivers/video.h>
Dequeue a video buffer.
Dequeue a filled (capturing) or displayed (output) buffer from the driver’s endpoint outgoing queue.
dev | Pointer to the device structure for the driver instance. |
buf | Pointer a video buffer pointer. |
timeout | Timeout |
0 | Is successful. |
-EINVAL | If parameters are invalid. |
-EIO | General input / output error. |
|
inlinestatic |
#include <zephyr/drivers/video.h>
Enqueue a video buffer.
Enqueue an empty (capturing) or filled (output) video buffer in the driver’s endpoint incoming queue.
dev | Pointer to the device structure for the driver instance. |
buf | Pointer to the video buffer. |
0 | Is successful. |
-EINVAL | If parameters are invalid. |
-EIO | General input / output error. |
|
inlinestatic |
#include <zephyr/drivers/video.h>
List video frame intervals.
List all supported video frame intervals of a given format.
Applications should fill the pixelformat, width and height fields of the video_frmival_enum struct first to form a query. Then, the index field is used to iterate through the supported frame intervals list.
dev | Pointer to the device structure for the driver instance. |
fie | Pointer to a video frame interval enumeration struct. |
0 | If successful. |
-ENOSYS | If API is not implemented. |
-EINVAL | If parameters are invalid. |
-EIO | General input / output error. |
#include <zephyr/drivers/video.h>
Flush endpoint buffers.
A call to flush finishes when all endpoint buffers have been moved from incoming queue to outgoing queue. Either because canceled or fully processed through the video function.
dev | Pointer to the device structure for the driver instance. |
cancel | If true, cancel buffer processing instead of waiting for completion. |
0 | Is successful, -ERRNO code otherwise. |
int video_format_caps_index | ( | const struct video_format_cap * | fmts, |
const struct video_format * | fmt, | ||
size_t * | idx ) |
#include <zephyr/drivers/video.h>
Search for a format that matches in a list of capabilities.
fmts | The format capability list to search. |
fmt | The format to find in the list. |
idx | The pointer to a number of the first format that matches. |
|
inlinestatic |
#include <zephyr/drivers/video.h>
Compute the difference between two frame intervals.
frmival | Frame interval to turn into microseconds. |
|
inlinestatic |
#include <zephyr/drivers/video.h>
Get the capabilities of a video endpoint.
dev | Pointer to the device structure for the driver instance. |
caps | Pointer to the video_caps struct to fill. |
0 | Is successful, -ERRNO code otherwise. |
#include <zephyr/drivers/video.h>
Return the link-frequency advertised by a device.
Device exposing a CSI link should advertise at least one of the following two controls:
At first the helper will try read the VIDEO_CID_LINK_FREQ and if not available will approximate the link-frequency from the VIDEO_CID_PIXEL_RATE value, taking into consideration the bits per pixel of the format and the number of lanes.
dev | Video device to query. |
bpp | Amount of bits per pixel of the pixel format produced by the device |
lane_nb | Number of CSI-2 lanes used |
int video_get_ctrl | ( | const struct device * | dev, |
struct video_control * | control ) |
#include <zephyr/drivers/video.h>
Get the current value of a control.
This retrieve the value of a video control, value type depends on control ID, and must be interpreted accordingly.
dev | Pointer to the device structure. |
control | Pointer to the video control struct. |
0 | Is successful. |
-EINVAL | If parameters are invalid. |
-ENOTSUP | If format is not supported. |
-EIO | General input / output error. |
|
inlinestatic |
#include <zephyr/drivers/video.h>
Get video format.
Get video device current video format.
dev | Pointer to the device structure for the driver instance. |
fmt | Pointer to video format struct. |
pointer | to video format |
|
inlinestatic |
#include <zephyr/drivers/video.h>
Get video frame interval.
Get current frame interval of the video device.
dev | Pointer to the device structure for the driver instance. |
frmival | Pointer to a video frame interval struct. |
0 | If successful. |
-ENOSYS | If API is not implemented. |
-EINVAL | If parameters are invalid. |
-EIO | General input / output error. |
void video_print_ctrl | ( | const struct device *const | dev, |
const struct video_ctrl_query *const | cq ) |
#include <zephyr/drivers/video.h>
Print all the information of a control.
Print all the information of a control including its name, type, flag, range, menu (if any) and current value, i.e. by invoking the video_get_ctrl(), in a human readble format.
dev | Pointer to the device structure. |
cq | Pointer to the control query struct. |
int video_query_ctrl | ( | const struct device * | dev, |
struct video_ctrl_query * | cq ) |
#include <zephyr/drivers/video.h>
Query information about a control.
Applications set the id field of the query structure, the function fills the rest of this structure. It is possible to enumerate base class controls (i.e., VIDEO_CID_BASE + x) by calling this function with successive id values starting from VIDEO_CID_BASE up to and exclusive VIDEO_CID_LASTP1. The function may return -ENOTSUP if a control in this range is not supported. Applications can also enumerate private controls by starting at VIDEO_CID_PRIVATE_BASE and incrementing the id until the driver returns -ENOTSUP. For other control classes, it's a bit more difficult. Hence, the best way to enumerate all kinds of device's supported controls is to iterate with VIDEO_CTRL_FLAG_NEXT_CTRL.
dev | Pointer to the device structure. |
cq | Pointer to the control query struct. |
0 | If successful. |
-EINVAL | If the control id is invalid. |
-ENOTSUP | If the control id is not supported. |
int video_set_ctrl | ( | const struct device * | dev, |
struct video_control * | control ) |
#include <zephyr/drivers/video.h>
Set the value of a control.
This set the value of a video control, value type depends on control ID, and must be interpreted accordingly.
dev | Pointer to the device structure for the driver instance. |
control | Pointer to the video control struct. |
0 | Is successful. |
-EINVAL | If parameters are invalid. |
-ENOTSUP | If format is not supported. |
-EIO | General input / output error. |
|
inlinestatic |
#include <zephyr/drivers/video.h>
Set video format.
Configure video device with a specific format.
dev | Pointer to the device structure for the driver instance. |
fmt | Pointer to a video format struct. |
0 | Is successful. |
-EINVAL | If parameters are invalid. |
-ENOTSUP | If format is not supported. |
-EIO | General input / output error. |
|
inlinestatic |
#include <zephyr/drivers/video.h>
Set video frame interval.
Configure video device with a specific frame interval.
Drivers must not return an error solely because the requested interval doesn’t match the device capabilities. They must instead modify the interval to match what the hardware can provide.
dev | Pointer to the device structure for the driver instance. |
frmival | Pointer to a video frame interval struct. |
0 | If successful. |
-ENOSYS | If API is not implemented. |
-EINVAL | If parameters are invalid. |
-EIO | General input / output error. |
|
inlinestatic |
#include <zephyr/drivers/video.h>
Register/Unregister k_poll signal for a video endpoint.
Register a poll signal to the endpoint, which will be signaled on frame completion (done, aborted, error). Registering a NULL poll signal unregisters any previously registered signal.
dev | Pointer to the device structure for the driver instance. |
sig | Pointer to k_poll_signal |
0 | Is successful, -ERRNO code otherwise. |
|
inlinestatic |
#include <zephyr/drivers/video.h>
Start the video device function.
video_stream_start is called to enter ‘streaming’ state (capture, output...). The driver may receive buffers with video_enqueue() before video_stream_start is called. If driver/device needs a minimum number of buffers before being able to start streaming, then driver set the min_vbuf_count to the related endpoint capabilities.
dev | Pointer to the device structure. |
type | The type of the buffers stream to start. |
0 | Is successful. |
-EIO | General input / output error. |
|
inlinestatic |
#include <zephyr/drivers/video.h>
Stop the video device function.
On video_stream_stop, driver must stop any transactions or wait until they finish.
dev | Pointer to the device structure. |
type | The type of the buffers stream to stop. |
0 | Is successful. |
-EIO | General input / output error. |