Zephyr Project API 4.0.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
video.h File Reference

Public APIs for Video. More...

#include <zephyr/device.h>
#include <stddef.h>
#include <zephyr/kernel.h>
#include <zephyr/types.h>

Go to the source code of this file.

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)
 
#define VIDEO_FOURCC(a, b, c, d)    ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
 Four-character-code uniquely identifying the pixel format.
 
#define VIDEO_FOURCC_FROM_STR(str)   VIDEO_FOURCC((str)[0], (str)[1], (str)[2], (str)[3])
 Convert a four-character-string to a four-character-code.
 
Bayer formats (R, G, B channels).

The full color information is spread over multiple pixels.

#define VIDEO_PIX_FMT_BGGR8   VIDEO_FOURCC('B', 'A', '8', '1')
 
#define VIDEO_PIX_FMT_GBRG8   VIDEO_FOURCC('G', 'B', 'R', 'G')
 
#define VIDEO_PIX_FMT_GRBG8   VIDEO_FOURCC('G', 'R', 'B', 'G')
 
#define VIDEO_PIX_FMT_RGGB8   VIDEO_FOURCC('R', 'G', 'G', 'B')
 
RGB formats

Per-color (R, G, B) channels.

#define VIDEO_PIX_FMT_RGB565X   VIDEO_FOURCC('R', 'G', 'B', 'R')
 5 red bits [15:11], 6 green bits [10:5], 5 blue bits [4:0].
 
#define VIDEO_PIX_FMT_RGB565   VIDEO_FOURCC('R', 'G', 'B', 'P')
 5 red bits [15:11], 6 green bits [10:5], 5 blue bits [4:0].
 
#define VIDEO_PIX_FMT_XRGB32   VIDEO_FOURCC('B', 'X', '2', '4')
 The first byte is empty (X) for each pixel.
 
YUV formats

Luminance (Y) and chrominance (U, V) channels.

#define VIDEO_PIX_FMT_YUYV   VIDEO_FOURCC('Y', 'U', 'Y', 'V')
 There is either a missing channel per pixel, U or V.
 
#define VIDEO_PIX_FMT_XYUV32   VIDEO_FOURCC('X', 'Y', 'U', 'V')
 The first byte is empty (X) for each pixel.
 
Compressed formats
#define VIDEO_PIX_FMT_JPEG   VIDEO_FOURCC('J', 'P', 'E', 'G')
 Both JPEG (single frame) and Motion-JPEG (MJPEG, multiple JPEG frames concatenated)
 

Typedefs

typedef int(* video_api_set_format_t) (const struct device *dev, enum video_endpoint_id ep, struct video_format *fmt)
 Set video format.
 
typedef int(* video_api_get_format_t) (const struct device *dev, enum video_endpoint_id ep, struct video_format *fmt)
 Get current video format.
 
typedef int(* video_api_set_frmival_t) (const struct device *dev, enum video_endpoint_id ep, struct video_frmival *frmival)
 Set video frame interval.
 
typedef int(* video_api_get_frmival_t) (const struct device *dev, enum video_endpoint_id ep, struct video_frmival *frmival)
 Get current video frame interval.
 
typedef int(* video_api_enum_frmival_t) (const struct device *dev, enum video_endpoint_id ep, struct video_frmival_enum *fie)
 List all supported frame intervals of a given format.
 
typedef int(* video_api_enqueue_t) (const struct device *dev, enum video_endpoint_id ep, struct video_buffer *buf)
 Enqueue a buffer in the driver’s incoming queue.
 
typedef int(* video_api_dequeue_t) (const struct device *dev, enum video_endpoint_id ep, 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, enum video_endpoint_id ep, bool cancel)
 Flush endpoint buffers, buffer are moved from incoming queue to outgoing queue.
 
typedef int(* video_api_stream_start_t) (const struct device *dev)
 Start the capture or output process.
 
typedef int(* video_api_stream_stop_t) (const struct device *dev)
 Stop the capture or output process.
 
typedef int(* video_api_set_ctrl_t) (const struct device *dev, unsigned int cid, void *value)
 Set a video control value.
 
typedef int(* video_api_get_ctrl_t) (const struct device *dev, unsigned int cid, void *value)
 Get a video control value.
 
typedef int(* video_api_get_caps_t) (const struct device *dev, enum video_endpoint_id ep, struct video_caps *caps)
 Get capabilities of a video endpoint.
 
typedef int(* video_api_set_signal_t) (const struct device *dev, enum video_endpoint_id ep, struct k_poll_signal *signal)
 Register/Unregister poll signal for buffer events.
 

Enumerations

enum  video_frmival_type { VIDEO_FRMIVAL_TYPE_DISCRETE = 1 , VIDEO_FRMIVAL_TYPE_STEPWISE = 2 }
 video_frmival_type enum More...
 
enum  video_endpoint_id { VIDEO_EP_NONE = -1 , VIDEO_EP_ALL = -2 , VIDEO_EP_IN = -3 , VIDEO_EP_OUT = -4 }
 video_endpoint_id 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, enum video_endpoint_id ep, struct video_format *fmt)
 Set video format.
 
static int video_get_format (const struct device *dev, enum video_endpoint_id ep, struct video_format *fmt)
 Get video format.
 
static int video_set_frmival (const struct device *dev, enum video_endpoint_id ep, struct video_frmival *frmival)
 Set video frame interval.
 
static int video_get_frmival (const struct device *dev, enum video_endpoint_id ep, struct video_frmival *frmival)
 Get video frame interval.
 
static int video_enum_frmival (const struct device *dev, enum video_endpoint_id ep, struct video_frmival_enum *fie)
 List video frame intervals.
 
static int video_enqueue (const struct device *dev, enum video_endpoint_id ep, struct video_buffer *buf)
 Enqueue a video buffer.
 
static int video_dequeue (const struct device *dev, enum video_endpoint_id ep, struct video_buffer **buf, k_timeout_t timeout)
 Dequeue a video buffer.
 
static int video_flush (const struct device *dev, enum video_endpoint_id ep, bool cancel)
 Flush endpoint buffers.
 
static int video_stream_start (const struct device *dev)
 Start the video device function.
 
static int video_stream_stop (const struct device *dev)
 Stop the video device function.
 
static int video_get_caps (const struct device *dev, enum video_endpoint_id ep, struct video_caps *caps)
 Get the capabilities of a video endpoint.
 
static int video_set_ctrl (const struct device *dev, unsigned int cid, void *value)
 Set the value of a control.
 
static int video_get_ctrl (const struct device *dev, unsigned int cid, void *value)
 Get the current value of a control.
 
static int video_set_signal (const struct device *dev, enum video_endpoint_id ep, struct k_poll_signal *signal)
 Register/Unregister k_poll signal for a video endpoint.
 
struct video_buffervideo_buffer_aligned_alloc (size_t size, size_t align, k_timeout_t timeout)
 Allocate aligned video buffer.
 
struct video_buffervideo_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, enum video_endpoint_id ep, struct video_frmival_enum *match)
 Find the closest match to a frame interval value within a video device.
 
static unsigned int video_bits_per_pixel (uint32_t pixfmt)
 Get number of bits per pixel of a pixel format.
 

Detailed Description

Public APIs for Video.