14#ifndef ZEPHYR_INCLUDE_VIDEO_H_
15#define ZEPHYR_INCLUDE_VIDEO_H_
40#define LINE_COUNT_HEIGHT (-1)
430 __ASSERT_NO_MSG(dev !=
NULL);
431 __ASSERT_NO_MSG(fmt !=
NULL);
455 __ASSERT_NO_MSG(dev !=
NULL);
456 __ASSERT_NO_MSG(fmt !=
NULL);
486 __ASSERT_NO_MSG(dev !=
NULL);
487 __ASSERT_NO_MSG(frmival !=
NULL);
518 __ASSERT_NO_MSG(dev !=
NULL);
519 __ASSERT_NO_MSG(frmival !=
NULL);
550 __ASSERT_NO_MSG(dev !=
NULL);
551 __ASSERT_NO_MSG(fie !=
NULL);
579 __ASSERT_NO_MSG(dev !=
NULL);
580 __ASSERT_NO_MSG(buf !=
NULL);
610 __ASSERT_NO_MSG(dev !=
NULL);
611 __ASSERT_NO_MSG(buf !=
NULL);
618 return api->
dequeue(dev, buf, timeout);
638 __ASSERT_NO_MSG(dev !=
NULL);
645 return api->
flush(dev, cancel);
667 __ASSERT_NO_MSG(dev !=
NULL);
694 __ASSERT_NO_MSG(dev !=
NULL);
719 __ASSERT_NO_MSG(dev !=
NULL);
720 __ASSERT_NO_MSG(caps !=
NULL);
811 __ASSERT_NO_MSG(dev !=
NULL);
812 __ASSERT_NO_MSG(sig !=
NULL);
845 __ASSERT_NO_MSG(dev !=
NULL);
846 __ASSERT_NO_MSG(sel !=
NULL);
877 __ASSERT_NO_MSG(dev !=
NULL);
878 __ASSERT_NO_MSG(sel !=
NULL);
938 __ASSERT_NO_MSG(frmival !=
NULL);
1002#define VIDEO_FOURCC(a, b, c, d) \
1003 ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
1002#define VIDEO_FOURCC(a, b, c, d) \ …
1014#define VIDEO_FOURCC_FROM_STR(str) VIDEO_FOURCC((str)[0], (str)[1], (str)[2], (str)[3])
1025#define VIDEO_FOURCC_TO_STR(fourcc) \
1027 (char)((fourcc) & 0xFF), \
1028 (char)(((fourcc) >> 8) & 0xFF), \
1029 (char)(((fourcc) >> 16) & 0xFF), \
1030 (char)(((fourcc) >> 24) & 0xFF), \
1025#define VIDEO_FOURCC_TO_STR(fourcc) \ …
1055#define VIDEO_PIX_FMT_SBGGR8 VIDEO_FOURCC('B', 'A', '8', '1')
1064#define VIDEO_PIX_FMT_SGBRG8 VIDEO_FOURCC('G', 'B', 'R', 'G')
1073#define VIDEO_PIX_FMT_SGRBG8 VIDEO_FOURCC('G', 'R', 'B', 'G')
1082#define VIDEO_PIX_FMT_SRGGB8 VIDEO_FOURCC('R', 'G', 'G', 'B')
1091#define VIDEO_PIX_FMT_SBGGR10P VIDEO_FOURCC('p', 'B', 'A', 'A')
1100#define VIDEO_PIX_FMT_SGBRG10P VIDEO_FOURCC('p', 'G', 'A', 'A')
1109#define VIDEO_PIX_FMT_SGRBG10P VIDEO_FOURCC('p', 'g', 'A', 'A')
1118#define VIDEO_PIX_FMT_SRGGB10P VIDEO_FOURCC('p', 'R', 'A', 'A')
1127#define VIDEO_PIX_FMT_SBGGR12P VIDEO_FOURCC('p', 'B', 'C', 'C')
1136#define VIDEO_PIX_FMT_SGBRG12P VIDEO_FOURCC('p', 'G', 'C', 'C')
1145#define VIDEO_PIX_FMT_SGRBG12P VIDEO_FOURCC('p', 'g', 'C', 'C')
1154#define VIDEO_PIX_FMT_SRGGB12P VIDEO_FOURCC('p', 'R', 'C', 'C')
1163#define VIDEO_PIX_FMT_SBGGR14P VIDEO_FOURCC('p', 'B', 'E', 'E')
1172#define VIDEO_PIX_FMT_SGBRG14P VIDEO_FOURCC('p', 'G', 'E', 'E')
1181#define VIDEO_PIX_FMT_SGRBG14P VIDEO_FOURCC('p', 'g', 'E', 'E')
1190#define VIDEO_PIX_FMT_SRGGB14P VIDEO_FOURCC('p', 'R', 'E', 'E')
1198#define VIDEO_PIX_FMT_SBGGR10 VIDEO_FOURCC('B', 'G', '1', '0')
1206#define VIDEO_PIX_FMT_SGBRG10 VIDEO_FOURCC('G', 'B', '1', '0')
1214#define VIDEO_PIX_FMT_SGRBG10 VIDEO_FOURCC('B', 'A', '1', '0')
1222#define VIDEO_PIX_FMT_SRGGB10 VIDEO_FOURCC('R', 'G', '1', '0')
1230#define VIDEO_PIX_FMT_SBGGR12 VIDEO_FOURCC('B', 'G', '1', '2')
1238#define VIDEO_PIX_FMT_SGBRG12 VIDEO_FOURCC('G', 'B', '1', '2')
1246#define VIDEO_PIX_FMT_SGRBG12 VIDEO_FOURCC('B', 'A', '1', '2')
1254#define VIDEO_PIX_FMT_SRGGB12 VIDEO_FOURCC('R', 'G', '1', '2')
1262#define VIDEO_PIX_FMT_SBGGR14 VIDEO_FOURCC('B', 'G', '1', '4')
1270#define VIDEO_PIX_FMT_SGBRG14 VIDEO_FOURCC('G', 'B', '1', '4')
1278#define VIDEO_PIX_FMT_SGRBG14 VIDEO_FOURCC('G', 'R', '1', '4')
1286#define VIDEO_PIX_FMT_SRGGB14 VIDEO_FOURCC('R', 'G', '1', '4')
1294#define VIDEO_PIX_FMT_SBGGR16 VIDEO_FOURCC('B', 'Y', 'R', '2')
1302#define VIDEO_PIX_FMT_SGBRG16 VIDEO_FOURCC('G', 'B', '1', '6')
1310#define VIDEO_PIX_FMT_SGRBG16 VIDEO_FOURCC('G', 'R', '1', '6')
1318#define VIDEO_PIX_FMT_SRGGB16 VIDEO_FOURCC('R', 'G', '1', '6')
1345#define VIDEO_PIX_FMT_GREY VIDEO_FOURCC('G', 'R', 'E', 'Y')
1353#define VIDEO_PIX_FMT_Y10P VIDEO_FOURCC('Y', '1', '0', 'P')
1362#define VIDEO_PIX_FMT_Y12P VIDEO_FOURCC('Y', '1', '2', 'P')
1371#define VIDEO_PIX_FMT_Y14P VIDEO_FOURCC('Y', '1', '4', 'P')
1381#define VIDEO_PIX_FMT_Y10 VIDEO_FOURCC('Y', '1', '0', ' ')
1391#define VIDEO_PIX_FMT_Y12 VIDEO_FOURCC('Y', '1', '2', ' ')
1401#define VIDEO_PIX_FMT_Y14 VIDEO_FOURCC('Y', '1', '4', ' ')
1411#define VIDEO_PIX_FMT_Y16 VIDEO_FOURCC('Y', '1', '6', ' ')
1432#define VIDEO_PIX_FMT_RGB565X VIDEO_FOURCC('R', 'G', 'B', 'R')
1443#define VIDEO_PIX_FMT_RGB565 VIDEO_FOURCC('R', 'G', 'B', 'P')
1452#define VIDEO_PIX_FMT_BGR24 VIDEO_FOURCC('B', 'G', 'R', '3')
1461#define VIDEO_PIX_FMT_RGB24 VIDEO_FOURCC('R', 'G', 'B', '3')
1469#define VIDEO_PIX_FMT_ARGB32 VIDEO_FOURCC('B', 'A', '2', '4')
1477#define VIDEO_PIX_FMT_ABGR32 VIDEO_FOURCC('A', 'R', '2', '4')
1485#define VIDEO_PIX_FMT_RGBA32 VIDEO_FOURCC('A', 'B', '2', '4')
1493#define VIDEO_PIX_FMT_BGRA32 VIDEO_FOURCC('R', 'A', '2', '4')
1502#define VIDEO_PIX_FMT_XRGB32 VIDEO_FOURCC('B', 'X', '2', '4')
1522#define VIDEO_PIX_FMT_YUYV VIDEO_FOURCC('Y', 'U', 'Y', 'V')
1529#define VIDEO_PIX_FMT_YVYU VIDEO_FOURCC('Y', 'V', 'Y', 'U')
1536#define VIDEO_PIX_FMT_VYUY VIDEO_FOURCC('V', 'Y', 'U', 'Y')
1543#define VIDEO_PIX_FMT_UYVY VIDEO_FOURCC('U', 'Y', 'V', 'Y')
1552#define VIDEO_PIX_FMT_XYUV32 VIDEO_FOURCC('X', 'Y', 'U', 'V')
1566#define VIDEO_PIX_FMT_JPEG VIDEO_FOURCC('J', 'P', 'E', 'G')
1658#define VIDEO_MIPI_CSI2_DT_NULL 0x10
1659#define VIDEO_MIPI_CSI2_DT_BLANKING 0x11
1660#define VIDEO_MIPI_CSI2_DT_EMBEDDED_8 0x12
1661#define VIDEO_MIPI_CSI2_DT_YUV420_8 0x18
1662#define VIDEO_MIPI_CSI2_DT_YUV420_10 0x19
1663#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_8 0x1c
1664#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_10 0x1d
1665#define VIDEO_MIPI_CSI2_DT_YUV422_8 0x1e
1666#define VIDEO_MIPI_CSI2_DT_YUV422_10 0x1f
1667#define VIDEO_MIPI_CSI2_DT_RGB444 0x20
1668#define VIDEO_MIPI_CSI2_DT_RGB555 0x21
1669#define VIDEO_MIPI_CSI2_DT_RGB565 0x22
1670#define VIDEO_MIPI_CSI2_DT_RGB666 0x23
1671#define VIDEO_MIPI_CSI2_DT_RGB888 0x24
1672#define VIDEO_MIPI_CSI2_DT_RAW6 0x28
1673#define VIDEO_MIPI_CSI2_DT_RAW7 0x29
1674#define VIDEO_MIPI_CSI2_DT_RAW8 0x2a
1675#define VIDEO_MIPI_CSI2_DT_RAW10 0x2b
1676#define VIDEO_MIPI_CSI2_DT_RAW12 0x2c
1677#define VIDEO_MIPI_CSI2_DT_RAW14 0x2d
1680#define VIDEO_MIPI_CSI2_DT_USER(n) (0x30 + (n))
#define NSEC_PER_SEC
number of nanoseconds per second
Definition clock.h:113
#define EINVAL
Invalid argument.
Definition errno.h:60
#define ENOSYS
Function not implemented.
Definition errno.h:82
int(* video_api_enum_frmival_t)(const struct device *dev, struct video_frmival_enum *fie)
List all supported frame intervals of a given format.
Definition video.h:317
int(* video_api_get_caps_t)(const struct device *dev, struct video_caps *caps)
Get capabilities of a video endpoint.
Definition video.h:375
video_signal_result
video_event enum
Definition video.h:238
struct video_buffer * video_buffer_aligned_alloc(size_t size, size_t align, k_timeout_t timeout)
Allocate aligned video buffer.
int video_set_ctrl(const struct device *dev, struct video_control *control)
Set the value of a control.
static int video_set_selection(const struct device *dev, struct video_selection *sel)
Set video selection (crop/compose).
Definition video.h:841
void video_print_ctrl(const struct video_ctrl_query *const cq)
Print all the information of a control.
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.
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.
Definition video.h:333
static int video_dequeue(const struct device *dev, struct video_buffer **buf, k_timeout_t timeout)
Dequeue a video buffer.
Definition video.h:605
int(* video_api_ctrl_t)(const struct device *dev, uint32_t cid)
Set/Get a video control value.
Definition video.h:367
video_frmival_type
video_frmival_type enum
Definition video.h:178
static uint64_t video_frmival_nsec(const struct video_frmival *frmival)
Compute the difference between two frame intervals.
Definition video.h:936
int video_get_ctrl(const struct device *dev, struct video_control *control)
Get the current value of a control.
static int video_enum_frmival(const struct device *dev, struct video_frmival_enum *fie)
List video frame intervals.
Definition video.h:546
static int video_stream_start(const struct device *dev, enum video_buf_type type)
Start the video device function.
Definition video.h:663
int video_query_ctrl(struct video_ctrl_query *cq)
Query information about a control.
static int video_get_caps(const struct device *dev, struct video_caps *caps)
Get the capabilities of a video endpoint.
Definition video.h:715
static int video_get_selection(const struct device *dev, struct video_selection *sel)
Get video selection (crop/compose).
Definition video.h:873
int(* video_api_format_t)(const struct device *dev, struct video_format *fmt)
Function pointer type for video_set/get_format()
Definition video.h:301
int(* video_api_flush_t)(const struct device *dev, bool cancel)
Flush endpoint buffers, buffer are moved from incoming queue to outgoing queue.
Definition video.h:343
static int video_flush(const struct device *dev, bool cancel)
Flush endpoint buffers.
Definition video.h:634
static int video_stream_stop(const struct device *dev, enum video_buf_type type)
Stop the video device function.
Definition video.h:689
int(* video_api_selection_t)(const struct device *dev, struct video_selection *sel)
Get/Set video selection (crop / compose)
Definition video.h:391
static int video_set_format(const struct device *dev, struct video_format *fmt)
Set video format.
Definition video.h:426
static int video_set_signal(const struct device *dev, struct k_poll_signal *sig)
Register/Unregister k_poll signal for a video endpoint.
Definition video.h:807
static int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
Set video frame interval.
Definition video.h:482
static int video_enqueue(const struct device *dev, struct video_buffer *buf)
Enqueue a video buffer.
Definition video.h:575
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.
Definition video.h:357
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_buffer_release(struct video_buffer *buf)
Release a video buffer.
video_buf_type
video_buf_type enum
Definition video.h:52
static int video_get_format(const struct device *dev, struct video_format *fmt)
Get video format.
Definition video.h:451
int(* video_api_set_signal_t)(const struct device *dev, struct k_poll_signal *sig)
Register/Unregister poll signal for buffer events.
Definition video.h:383
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.
int(* video_api_enqueue_t)(const struct device *dev, struct video_buffer *buf)
Enqueue a buffer in the driver’s incoming queue.
Definition video.h:325
struct video_buffer * video_buffer_alloc(size_t size, k_timeout_t timeout)
Allocate video buffer.
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.
static int video_get_frmival(const struct device *dev, struct video_frmival *frmival)
Get video frame interval.
Definition video.h:514
int(* video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival)
Function pointer type for video_set/get_frmival()
Definition video.h:309
@ VIDEO_BUF_ABORTED
Definition video.h:240
@ VIDEO_BUF_DONE
Definition video.h:239
@ VIDEO_BUF_ERROR
Definition video.h:241
@ VIDEO_FRMIVAL_TYPE_DISCRETE
discrete frame interval type
Definition video.h:180
@ VIDEO_FRMIVAL_TYPE_STEPWISE
stepwise frame interval type
Definition video.h:182
@ VIDEO_BUF_TYPE_INPUT
input buffer type
Definition video.h:54
@ VIDEO_BUF_TYPE_OUTPUT
output buffer type
Definition video.h:56
@ VIDEO_SEL_TGT_COMPOSE_BOUND
Compose bound (aka the maximum compose achievable)
Definition video.h:260
@ VIDEO_SEL_TGT_COMPOSE
Current compose setting.
Definition video.h:258
@ VIDEO_SEL_TGT_NATIVE_SIZE
Native size of the input frame.
Definition video.h:256
@ VIDEO_SEL_TGT_CROP
Current crop setting.
Definition video.h:252
@ VIDEO_SEL_TGT_CROP_BOUND
Crop bound (aka the maximum crop achievable)
Definition video.h:254
#define NULL
Definition iar_missing_defs.h:20
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT64_TYPE__ int64_t
Definition stdint.h:75
__INT16_TYPE__ int16_t
Definition stdint.h:73
Runtime device structure (in ROM) per driver instance.
Definition device.h:510
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:516
Kernel timeout type.
Definition clock.h:65
Video buffer structure.
Definition video.h:146
uint32_t bytesused
number of bytes occupied by the valid data in the buffer.
Definition video.h:159
uint32_t size
size of the buffer in bytes.
Definition video.h:157
enum video_buf_type type
type of the buffer
Definition video.h:151
uint8_t * buffer
pointer to the start of the buffer.
Definition video.h:153
void * driver_data
Pointer to driver specific data.
Definition video.h:149
uint16_t line_offset
Line offset within frame this buffer represents, from the beginning of the frame.
Definition video.h:170
uint8_t index
index of the buffer, optionally set by the application
Definition video.h:155
uint32_t timestamp
time reference in milliseconds at which the last data byte was actually received for input endpoints ...
Definition video.h:164
Video format capabilities.
Definition video.h:113
uint8_t min_vbuf_count
minimal count of video buffers to enqueue before being able to start the stream.
Definition video.h:121
enum video_buf_type type
type of the buffer
Definition video.h:115
int16_t min_line_count
Denotes minimum line count of a video buffer that this endpoint can fill or process.
Definition video.h:130
int16_t max_line_count
Denotes maximum line count of a video buffer that this endpoint can fill or process.
Definition video.h:137
const struct video_format_cap * format_caps
list of video format capabilities (zero terminated).
Definition video.h:117
Video control structure.
Definition video-controls.h:410
Definition video-controls.h:457
const struct device * dev
device being queried, application needs to set this field
Definition video-controls.h:459
video_api_format_t set_format
Definition video.h:395
video_api_ctrl_t set_ctrl
Definition video.h:403
video_api_enqueue_t enqueue
Definition video.h:400
video_api_set_signal_t set_signal
Definition video.h:405
video_api_enum_frmival_t enum_frmival
Definition video.h:408
video_api_get_caps_t get_caps
Definition video.h:398
video_api_selection_t get_selection
Definition video.h:410
video_api_selection_t set_selection
Definition video.h:409
video_api_format_t get_format
Definition video.h:396
video_api_flush_t flush
Definition video.h:402
video_api_dequeue_t dequeue
Definition video.h:401
video_api_frmival_t get_frmival
Definition video.h:407
video_api_frmival_t set_frmival
Definition video.h:406
video_api_set_stream_t set_stream
Definition video.h:397
video_api_ctrl_t get_volatile_ctrl
Definition video.h:404
Video frame interval enumeration structure.
Definition video.h:219
uint32_t index
frame interval index during enumeration
Definition video.h:221
const struct video_format * format
video format for which the query is made
Definition video.h:223
enum video_frmival_type type
frame interval type the device supports
Definition video.h:225
Video frame interval stepwise structure.
Definition video.h:204
struct video_frmival min
minimum frame interval in seconds
Definition video.h:206
struct video_frmival max
maximum frame interval in seconds
Definition video.h:208
struct video_frmival step
frame interval step size in seconds
Definition video.h:210
Video frame interval structure.
Definition video.h:191
uint32_t numerator
numerator of the frame interval
Definition video.h:193
uint32_t denominator
denominator of the frame interval
Definition video.h:195
Description of a rectangle area.
Definition video.h:269
uint32_t width
width of selection rectangle
Definition video.h:275
uint32_t height
height of selection rectangle
Definition video.h:277
uint32_t top
top offset of selection rectangle
Definition video.h:273
uint32_t left
left offset of selection rectangle
Definition video.h:271
Video selection target enum.
Video selection (crop / compose) structure.
Definition video.h:286
struct video_rect rect
selection target rectangle
Definition video.h:292
enum video_buf_type type
buffer type, allow to select for device having both input and output
Definition video.h:288
enum video_selection_target target
selection target enum
Definition video.h:290