Zephyr API Documentation 4.2.00-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
video.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2019 Linaro Limited.
9 * Copyright 2025 NXP
10 * Copyright (c) 2025 STMicroelectronics
11 *
12 * SPDX-License-Identifier: Apache-2.0
13 */
14#ifndef ZEPHYR_INCLUDE_VIDEO_H_
15#define ZEPHYR_INCLUDE_VIDEO_H_
16
26#include <zephyr/device.h>
27#include <stddef.h>
28#include <zephyr/kernel.h>
29
30#include <zephyr/types.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/*
37 * Flag used by @ref video_caps structure to indicate endpoint operates on
38 * buffers the size of the video frame
39 */
40#define LINE_COUNT_HEIGHT (-1)
41
42struct video_control;
43
58
83
106
139
171
183
196
211
222 const struct video_format *format;
226 union {
227 struct video_frmival discrete;
228 struct video_frmival_stepwise stepwise;
229 };
230};
231
242
261
278
293
300typedef int (*video_api_format_t)(const struct device *dev, struct video_format *fmt);
301
308typedef int (*video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival);
309
316typedef int (*video_api_enum_frmival_t)(const struct device *dev, struct video_frmival_enum *fie);
317
324typedef int (*video_api_enqueue_t)(const struct device *dev, struct video_buffer *buf);
325
332typedef int (*video_api_dequeue_t)(const struct device *dev, struct video_buffer **buf,
333 k_timeout_t timeout);
334
342typedef int (*video_api_flush_t)(const struct device *dev, bool cancel);
343
356typedef int (*video_api_set_stream_t)(const struct device *dev, bool enable,
357 enum video_buf_type type);
358
366typedef int (*video_api_ctrl_t)(const struct device *dev, uint32_t cid);
367
374typedef int (*video_api_get_caps_t)(const struct device *dev, struct video_caps *caps);
375
382typedef int (*video_api_set_signal_t)(const struct device *dev, struct k_poll_signal *sig);
383
390typedef int (*video_api_selection_t)(const struct device *dev, struct video_selection *sel);
391
411
425static inline int video_set_format(const struct device *dev, struct video_format *fmt)
426{
427 const struct video_driver_api *api;
428
429 __ASSERT_NO_MSG(dev != NULL);
430 __ASSERT_NO_MSG(fmt != NULL);
431
432 api = (const struct video_driver_api *)dev->api;
433 if (api->set_format == NULL) {
434 return -ENOSYS;
435 }
436
437 return api->set_format(dev, fmt);
438}
439
450static inline int video_get_format(const struct device *dev, struct video_format *fmt)
451{
452 const struct video_driver_api *api;
453
454 __ASSERT_NO_MSG(dev != NULL);
455 __ASSERT_NO_MSG(fmt != NULL);
456
457 api = (const struct video_driver_api *)dev->api;
458 if (api->get_format == NULL) {
459 return -ENOSYS;
460 }
461
462 return api->get_format(dev, fmt);
463}
464
481static inline int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
482{
483 const struct video_driver_api *api;
484
485 __ASSERT_NO_MSG(dev != NULL);
486 __ASSERT_NO_MSG(frmival != NULL);
487
488 if (frmival->numerator == 0 || frmival->denominator == 0) {
489 return -EINVAL;
490 }
491
492 api = (const struct video_driver_api *)dev->api;
493 if (api->set_frmival == NULL) {
494 return -ENOSYS;
495 }
496
497 return api->set_frmival(dev, frmival);
498}
499
513static inline int video_get_frmival(const struct device *dev, struct video_frmival *frmival)
514{
515 const struct video_driver_api *api;
516
517 __ASSERT_NO_MSG(dev != NULL);
518 __ASSERT_NO_MSG(frmival != NULL);
519
520 api = (const struct video_driver_api *)dev->api;
521 if (api->get_frmival == NULL) {
522 return -ENOSYS;
523 }
524
525 return api->get_frmival(dev, frmival);
526}
527
545static inline int video_enum_frmival(const struct device *dev, struct video_frmival_enum *fie)
546{
547 const struct video_driver_api *api;
548
549 __ASSERT_NO_MSG(dev != NULL);
550 __ASSERT_NO_MSG(fie != NULL);
551 __ASSERT_NO_MSG(fie->format != NULL);
552
553 api = (const struct video_driver_api *)dev->api;
554 if (api->enum_frmival == NULL) {
555 return -ENOSYS;
556 }
557
558 return api->enum_frmival(dev, fie);
559}
560
574static inline int video_enqueue(const struct device *dev, struct video_buffer *buf)
575{
576 const struct video_driver_api *api = (const struct video_driver_api *)dev->api;
577
578 __ASSERT_NO_MSG(dev != NULL);
579 __ASSERT_NO_MSG(buf != NULL);
580 __ASSERT_NO_MSG(buf->buffer != NULL);
581
582 api = (const struct video_driver_api *)dev->api;
583 if (api->enqueue == NULL) {
584 return -ENOSYS;
585 }
586
587 return api->enqueue(dev, buf);
588}
589
604static inline int video_dequeue(const struct device *dev, struct video_buffer **buf,
605 k_timeout_t timeout)
606{
607 const struct video_driver_api *api;
608
609 __ASSERT_NO_MSG(dev != NULL);
610 __ASSERT_NO_MSG(buf != NULL);
611
612 api = (const struct video_driver_api *)dev->api;
613 if (api->dequeue == NULL) {
614 return -ENOSYS;
615 }
616
617 return api->dequeue(dev, buf, timeout);
618}
619
633static inline int video_flush(const struct device *dev, bool cancel)
634{
635 const struct video_driver_api *api;
636
637 __ASSERT_NO_MSG(dev != NULL);
638
639 api = (const struct video_driver_api *)dev->api;
640 if (api->flush == NULL) {
641 return -ENOSYS;
642 }
643
644 return api->flush(dev, cancel);
645}
646
662static inline int video_stream_start(const struct device *dev, enum video_buf_type type)
663{
664 const struct video_driver_api *api;
665
666 __ASSERT_NO_MSG(dev != NULL);
667
668 api = (const struct video_driver_api *)dev->api;
669 if (api->set_stream == NULL) {
670 return -ENOSYS;
671 }
672
673 return api->set_stream(dev, true, type);
674}
675
688static inline int video_stream_stop(const struct device *dev, enum video_buf_type type)
689{
690 const struct video_driver_api *api;
691 int ret;
692
693 __ASSERT_NO_MSG(dev != NULL);
694
695 api = (const struct video_driver_api *)dev->api;
696 if (api->set_stream == NULL) {
697 return -ENOSYS;
698 }
699
700 ret = api->set_stream(dev, false, type);
701 video_flush(dev, true);
702
703 return ret;
704}
705
714static inline int video_get_caps(const struct device *dev, struct video_caps *caps)
715{
716 const struct video_driver_api *api;
717
718 __ASSERT_NO_MSG(dev != NULL);
719 __ASSERT_NO_MSG(caps != NULL);
720
721 api = (const struct video_driver_api *)dev->api;
722 if (api->get_caps == NULL) {
723 return -ENOSYS;
724 }
725
726 return api->get_caps(dev, caps);
727}
728
743int video_set_ctrl(const struct device *dev, struct video_control *control);
744
759int video_get_ctrl(const struct device *dev, struct video_control *control);
760
761struct video_ctrl_query;
762
782
792void video_print_ctrl(const struct video_ctrl_query *const cq);
793
806static inline int video_set_signal(const struct device *dev, struct k_poll_signal *sig)
807{
808 const struct video_driver_api *api;
809
810 __ASSERT_NO_MSG(dev != NULL);
811 __ASSERT_NO_MSG(sig != NULL);
812
813 api = (const struct video_driver_api *)dev->api;
814 if (api->set_signal == NULL) {
815 return -ENOSYS;
816 }
817
818 return api->set_signal(dev, sig);
819}
820
840static inline int video_set_selection(const struct device *dev, struct video_selection *sel)
841{
842 const struct video_driver_api *api;
843
844 __ASSERT_NO_MSG(dev != NULL);
845 __ASSERT_NO_MSG(sel != NULL);
846
847 api = (const struct video_driver_api *)dev->api;
848 if (api->set_selection == NULL) {
849 return -ENOSYS;
850 }
851
852 return api->set_selection(dev, sel);
853}
854
872static inline int video_get_selection(const struct device *dev, struct video_selection *sel)
873{
874 const struct video_driver_api *api;
875
876 __ASSERT_NO_MSG(dev != NULL);
877 __ASSERT_NO_MSG(sel != NULL);
878
879 api = (const struct video_driver_api *)dev->api;
880 if (api->get_selection == NULL) {
881 return -ENOSYS;
882 }
883
884 return api->get_selection(dev, sel);
885}
886
896struct video_buffer *video_buffer_aligned_alloc(size_t size, size_t align, k_timeout_t timeout);
897
907
914
925int video_format_caps_index(const struct video_format_cap *fmts, const struct video_format *fmt,
926 size_t *idx);
927
935static inline uint64_t video_frmival_nsec(const struct video_frmival *frmival)
936{
937 __ASSERT_NO_MSG(frmival != NULL);
938 __ASSERT_NO_MSG(frmival->denominator != 0);
939
940 return (uint64_t)NSEC_PER_SEC * frmival->numerator / frmival->denominator;
941}
942
951 const struct video_frmival *desired,
952 struct video_frmival *match);
953
971void video_closest_frmival(const struct device *dev, struct video_frmival_enum *match);
972
988int64_t video_get_csi_link_freq(const struct device *dev, uint8_t bpp, uint8_t lane_nb);
989
1001#define VIDEO_FOURCC(a, b, c, d) \
1002 ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
1003
1013#define VIDEO_FOURCC_FROM_STR(str) VIDEO_FOURCC((str)[0], (str)[1], (str)[2], (str)[3])
1014
1024#define VIDEO_FOURCC_TO_STR(fourcc) \
1025 ((char[]){ \
1026 (char)((fourcc) & 0xFF), \
1027 (char)(((fourcc) >> 8) & 0xFF), \
1028 (char)(((fourcc) >> 16) & 0xFF), \
1029 (char)(((fourcc) >> 24) & 0xFF), \
1030 '\0' \
1031 })
1032
1054#define VIDEO_PIX_FMT_SBGGR8 VIDEO_FOURCC('B', 'A', '8', '1')
1055
1063#define VIDEO_PIX_FMT_SGBRG8 VIDEO_FOURCC('G', 'B', 'R', 'G')
1064
1072#define VIDEO_PIX_FMT_SGRBG8 VIDEO_FOURCC('G', 'R', 'B', 'G')
1073
1081#define VIDEO_PIX_FMT_SRGGB8 VIDEO_FOURCC('R', 'G', 'G', 'B')
1082
1090#define VIDEO_PIX_FMT_SBGGR10P VIDEO_FOURCC('p', 'B', 'A', 'A')
1091
1099#define VIDEO_PIX_FMT_SGBRG10P VIDEO_FOURCC('p', 'G', 'A', 'A')
1100
1108#define VIDEO_PIX_FMT_SGRBG10P VIDEO_FOURCC('p', 'g', 'A', 'A')
1109
1117#define VIDEO_PIX_FMT_SRGGB10P VIDEO_FOURCC('p', 'R', 'A', 'A')
1118
1126#define VIDEO_PIX_FMT_SBGGR12P VIDEO_FOURCC('p', 'B', 'C', 'C')
1127
1135#define VIDEO_PIX_FMT_SGBRG12P VIDEO_FOURCC('p', 'G', 'C', 'C')
1136
1144#define VIDEO_PIX_FMT_SGRBG12P VIDEO_FOURCC('p', 'g', 'C', 'C')
1145
1153#define VIDEO_PIX_FMT_SRGGB12P VIDEO_FOURCC('p', 'R', 'C', 'C')
1154
1162#define VIDEO_PIX_FMT_SBGGR14P VIDEO_FOURCC('p', 'B', 'E', 'E')
1163
1171#define VIDEO_PIX_FMT_SGBRG14P VIDEO_FOURCC('p', 'G', 'E', 'E')
1172
1180#define VIDEO_PIX_FMT_SGRBG14P VIDEO_FOURCC('p', 'g', 'E', 'E')
1181
1189#define VIDEO_PIX_FMT_SRGGB14P VIDEO_FOURCC('p', 'R', 'E', 'E')
1190
1197#define VIDEO_PIX_FMT_SBGGR10 VIDEO_FOURCC('B', 'G', '1', '0')
1198
1205#define VIDEO_PIX_FMT_SGBRG10 VIDEO_FOURCC('G', 'B', '1', '0')
1206
1213#define VIDEO_PIX_FMT_SGRBG10 VIDEO_FOURCC('B', 'A', '1', '0')
1214
1221#define VIDEO_PIX_FMT_SRGGB10 VIDEO_FOURCC('R', 'G', '1', '0')
1222
1229#define VIDEO_PIX_FMT_SBGGR12 VIDEO_FOURCC('B', 'G', '1', '2')
1230
1237#define VIDEO_PIX_FMT_SGBRG12 VIDEO_FOURCC('G', 'B', '1', '2')
1238
1245#define VIDEO_PIX_FMT_SGRBG12 VIDEO_FOURCC('B', 'A', '1', '2')
1246
1253#define VIDEO_PIX_FMT_SRGGB12 VIDEO_FOURCC('R', 'G', '1', '2')
1254
1261#define VIDEO_PIX_FMT_SBGGR14 VIDEO_FOURCC('B', 'G', '1', '4')
1262
1269#define VIDEO_PIX_FMT_SGBRG14 VIDEO_FOURCC('G', 'B', '1', '4')
1270
1277#define VIDEO_PIX_FMT_SGRBG14 VIDEO_FOURCC('G', 'R', '1', '4')
1278
1285#define VIDEO_PIX_FMT_SRGGB14 VIDEO_FOURCC('R', 'G', '1', '4')
1286
1293#define VIDEO_PIX_FMT_SBGGR16 VIDEO_FOURCC('B', 'Y', 'R', '2')
1294
1301#define VIDEO_PIX_FMT_SGBRG16 VIDEO_FOURCC('G', 'B', '1', '6')
1302
1309#define VIDEO_PIX_FMT_SGRBG16 VIDEO_FOURCC('G', 'R', '1', '6')
1310
1317#define VIDEO_PIX_FMT_SRGGB16 VIDEO_FOURCC('R', 'G', '1', '6')
1318
1344#define VIDEO_PIX_FMT_GREY VIDEO_FOURCC('G', 'R', 'E', 'Y')
1345
1352#define VIDEO_PIX_FMT_Y10P VIDEO_FOURCC('Y', '1', '0', 'P')
1353
1361#define VIDEO_PIX_FMT_Y12P VIDEO_FOURCC('Y', '1', '2', 'P')
1362
1370#define VIDEO_PIX_FMT_Y14P VIDEO_FOURCC('Y', '1', '4', 'P')
1371
1380#define VIDEO_PIX_FMT_Y10 VIDEO_FOURCC('Y', '1', '0', ' ')
1381
1390#define VIDEO_PIX_FMT_Y12 VIDEO_FOURCC('Y', '1', '2', ' ')
1391
1400#define VIDEO_PIX_FMT_Y14 VIDEO_FOURCC('Y', '1', '4', ' ')
1401
1410#define VIDEO_PIX_FMT_Y16 VIDEO_FOURCC('Y', '1', '6', ' ')
1411
1431#define VIDEO_PIX_FMT_RGB565X VIDEO_FOURCC('R', 'G', 'B', 'R')
1432
1442#define VIDEO_PIX_FMT_RGB565 VIDEO_FOURCC('R', 'G', 'B', 'P')
1443
1451#define VIDEO_PIX_FMT_BGR24 VIDEO_FOURCC('B', 'G', 'R', '3')
1452
1460#define VIDEO_PIX_FMT_RGB24 VIDEO_FOURCC('R', 'G', 'B', '3')
1461
1468#define VIDEO_PIX_FMT_ARGB32 VIDEO_FOURCC('B', 'A', '2', '4')
1469
1476#define VIDEO_PIX_FMT_ABGR32 VIDEO_FOURCC('A', 'R', '2', '4')
1477
1484#define VIDEO_PIX_FMT_RGBA32 VIDEO_FOURCC('A', 'B', '2', '4')
1485
1492#define VIDEO_PIX_FMT_BGRA32 VIDEO_FOURCC('R', 'A', '2', '4')
1493
1501#define VIDEO_PIX_FMT_XRGB32 VIDEO_FOURCC('B', 'X', '2', '4')
1502
1521#define VIDEO_PIX_FMT_YUYV VIDEO_FOURCC('Y', 'U', 'Y', 'V')
1522
1528#define VIDEO_PIX_FMT_YVYU VIDEO_FOURCC('Y', 'V', 'Y', 'U')
1529
1535#define VIDEO_PIX_FMT_VYUY VIDEO_FOURCC('V', 'Y', 'U', 'Y')
1536
1542#define VIDEO_PIX_FMT_UYVY VIDEO_FOURCC('U', 'Y', 'V', 'Y')
1543
1551#define VIDEO_PIX_FMT_XYUV32 VIDEO_FOURCC('X', 'Y', 'U', 'V')
1552
1565#define VIDEO_PIX_FMT_JPEG VIDEO_FOURCC('J', 'P', 'E', 'G')
1566
1579static inline unsigned int video_bits_per_pixel(uint32_t pixfmt)
1580{
1581 switch (pixfmt) {
1586 case VIDEO_PIX_FMT_GREY:
1587 return 8;
1592 case VIDEO_PIX_FMT_Y10P:
1593 return 10;
1598 case VIDEO_PIX_FMT_Y12P:
1599 return 12;
1604 case VIDEO_PIX_FMT_Y14P:
1605 return 14;
1607 case VIDEO_PIX_FMT_YUYV:
1608 case VIDEO_PIX_FMT_YVYU:
1609 case VIDEO_PIX_FMT_UYVY:
1610 case VIDEO_PIX_FMT_VYUY:
1627 case VIDEO_PIX_FMT_Y10:
1628 case VIDEO_PIX_FMT_Y12:
1629 case VIDEO_PIX_FMT_Y14:
1630 case VIDEO_PIX_FMT_Y16:
1631 return 16;
1634 return 24;
1641 return 32;
1642 default:
1643 /* Variable number of bits per pixel or unknown format */
1644 return 0;
1645 }
1646}
1647
1657#define VIDEO_MIPI_CSI2_DT_NULL 0x10
1658#define VIDEO_MIPI_CSI2_DT_BLANKING 0x11
1659#define VIDEO_MIPI_CSI2_DT_EMBEDDED_8 0x12
1660#define VIDEO_MIPI_CSI2_DT_YUV420_8 0x18
1661#define VIDEO_MIPI_CSI2_DT_YUV420_10 0x19
1662#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_8 0x1c
1663#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_10 0x1d
1664#define VIDEO_MIPI_CSI2_DT_YUV422_8 0x1e
1665#define VIDEO_MIPI_CSI2_DT_YUV422_10 0x1f
1666#define VIDEO_MIPI_CSI2_DT_RGB444 0x20
1667#define VIDEO_MIPI_CSI2_DT_RGB555 0x21
1668#define VIDEO_MIPI_CSI2_DT_RGB565 0x22
1669#define VIDEO_MIPI_CSI2_DT_RGB666 0x23
1670#define VIDEO_MIPI_CSI2_DT_RGB888 0x24
1671#define VIDEO_MIPI_CSI2_DT_RAW6 0x28
1672#define VIDEO_MIPI_CSI2_DT_RAW7 0x29
1673#define VIDEO_MIPI_CSI2_DT_RAW8 0x2a
1674#define VIDEO_MIPI_CSI2_DT_RAW10 0x2b
1675#define VIDEO_MIPI_CSI2_DT_RAW12 0x2c
1676#define VIDEO_MIPI_CSI2_DT_RAW14 0x2d
1677
1678/* User-defined Data-Type range from 0x30 to 0x37 */
1679#define VIDEO_MIPI_CSI2_DT_USER(n) (0x30 + (n))
1680
1685#ifdef __cplusplus
1686}
1687#endif
1688
1693#endif /* ZEPHYR_INCLUDE_VIDEO_H_ */
#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:316
int(* video_api_get_caps_t)(const struct device *dev, struct video_caps *caps)
Get capabilities of a video endpoint.
Definition video.h:374
video_signal_result
video_event enum
Definition video.h:237
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:840
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:332
static int video_dequeue(const struct device *dev, struct video_buffer **buf, k_timeout_t timeout)
Dequeue a video buffer.
Definition video.h:604
int(* video_api_ctrl_t)(const struct device *dev, uint32_t cid)
Set/Get a video control value.
Definition video.h:366
video_frmival_type
video_frmival_type enum
Definition video.h:177
static uint64_t video_frmival_nsec(const struct video_frmival *frmival)
Compute the difference between two frame intervals.
Definition video.h:935
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:545
static int video_stream_start(const struct device *dev, enum video_buf_type type)
Start the video device function.
Definition video.h:662
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:714
static int video_get_selection(const struct device *dev, struct video_selection *sel)
Get video selection (crop/compose).
Definition video.h:872
int(* video_api_format_t)(const struct device *dev, struct video_format *fmt)
Function pointer type for video_set/get_format()
Definition video.h:300
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:342
static int video_flush(const struct device *dev, bool cancel)
Flush endpoint buffers.
Definition video.h:633
static int video_stream_stop(const struct device *dev, enum video_buf_type type)
Stop the video device function.
Definition video.h:688
int(* video_api_selection_t)(const struct device *dev, struct video_selection *sel)
Get/Set video selection (crop / compose)
Definition video.h:390
static int video_set_format(const struct device *dev, struct video_format *fmt)
Set video format.
Definition video.h:425
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:806
static int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
Set video frame interval.
Definition video.h:481
static int video_enqueue(const struct device *dev, struct video_buffer *buf)
Enqueue a video buffer.
Definition video.h:574
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:356
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:450
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:382
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:324
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:513
int(* video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival)
Function pointer type for video_set/get_frmival()
Definition video.h:308
@ VIDEO_BUF_ABORTED
Definition video.h:239
@ VIDEO_BUF_DONE
Definition video.h:238
@ VIDEO_BUF_ERROR
Definition video.h:240
@ VIDEO_FRMIVAL_TYPE_DISCRETE
discrete frame interval type
Definition video.h:179
@ VIDEO_FRMIVAL_TYPE_STEPWISE
stepwise frame interval type
Definition video.h:181
@ 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:259
@ VIDEO_SEL_TGT_COMPOSE
Current compose setting.
Definition video.h:257
@ VIDEO_SEL_TGT_NATIVE_SIZE
Native size of the input frame.
Definition video.h:255
@ VIDEO_SEL_TGT_CROP
Current crop setting.
Definition video.h:251
@ VIDEO_SEL_TGT_CROP_BOUND
Crop bound (aka the maximum crop achievable)
Definition video.h:253
#define VIDEO_PIX_FMT_SGRBG10
Definition video.h:1213
#define VIDEO_PIX_FMT_XYUV32
The first byte is empty (X) for each pixel.
Definition video.h:1551
#define VIDEO_PIX_FMT_SGRBG12P
Definition video.h:1144
#define VIDEO_PIX_FMT_RGB24
24 bit RGB format with 8 bit per component
Definition video.h:1460
#define VIDEO_PIX_FMT_Y10
Little endian, with the 6 most significant bits set to Zero.
Definition video.h:1380
#define VIDEO_PIX_FMT_SBGGR10
Definition video.h:1197
#define VIDEO_PIX_FMT_Y12
Little endian, with the 4 most significant bits set to Zero.
Definition video.h:1390
#define VIDEO_PIX_FMT_SGRBG8
Definition video.h:1072
#define VIDEO_PIX_FMT_SRGGB10
Definition video.h:1221
#define VIDEO_PIX_FMT_Y12P
Definition video.h:1361
#define VIDEO_PIX_FMT_YVYU
Definition video.h:1528
#define VIDEO_PIX_FMT_SRGGB12P
Definition video.h:1153
#define VIDEO_PIX_FMT_SBGGR10P
Definition video.h:1090
#define VIDEO_PIX_FMT_SBGGR14
Definition video.h:1261
#define VIDEO_PIX_FMT_SGRBG16
Definition video.h:1309
#define VIDEO_PIX_FMT_SRGGB16
Definition video.h:1317
#define VIDEO_PIX_FMT_Y10P
Definition video.h:1352
#define VIDEO_PIX_FMT_BGRA32
Definition video.h:1492
#define VIDEO_PIX_FMT_ARGB32
Definition video.h:1468
#define VIDEO_PIX_FMT_SRGGB10P
Definition video.h:1117
#define VIDEO_PIX_FMT_VYUY
Definition video.h:1535
#define VIDEO_PIX_FMT_SRGGB14P
Definition video.h:1189
#define VIDEO_PIX_FMT_SGBRG14
Definition video.h:1269
#define VIDEO_PIX_FMT_SRGGB12
Definition video.h:1253
#define VIDEO_PIX_FMT_Y14
Little endian, with the 2 most significant bits set to Zero.
Definition video.h:1400
#define VIDEO_PIX_FMT_SGBRG16
Definition video.h:1301
#define VIDEO_PIX_FMT_SGBRG14P
Definition video.h:1171
#define VIDEO_PIX_FMT_XRGB32
The first byte is empty (X) for each pixel.
Definition video.h:1501
#define VIDEO_PIX_FMT_SGBRG10
Definition video.h:1205
#define VIDEO_PIX_FMT_RGBA32
Definition video.h:1484
#define VIDEO_PIX_FMT_SGRBG10P
Definition video.h:1108
#define VIDEO_PIX_FMT_SBGGR12
Definition video.h:1229
#define VIDEO_PIX_FMT_GREY
Same as Y8 (8-bit luma-only) following the standard FOURCC naming, or L8 in some graphics libraries.
Definition video.h:1344
#define VIDEO_PIX_FMT_SGBRG12
Definition video.h:1237
#define VIDEO_PIX_FMT_Y16
Little endian.
Definition video.h:1410
#define VIDEO_PIX_FMT_SRGGB14
Definition video.h:1285
#define VIDEO_PIX_FMT_SGBRG8
Definition video.h:1063
#define VIDEO_PIX_FMT_SBGGR12P
Definition video.h:1126
#define VIDEO_PIX_FMT_SBGGR8
Definition video.h:1054
static unsigned int video_bits_per_pixel(uint32_t pixfmt)
Get number of bits per pixel of a pixel format.
Definition video.h:1579
#define VIDEO_PIX_FMT_SRGGB8
Definition video.h:1081
#define VIDEO_PIX_FMT_SBGGR14P
Definition video.h:1162
#define VIDEO_PIX_FMT_YUYV
There is either a missing channel per pixel, U or V.
Definition video.h:1521
#define VIDEO_PIX_FMT_SGBRG10P
Definition video.h:1099
#define VIDEO_PIX_FMT_Y14P
Definition video.h:1370
#define VIDEO_PIX_FMT_UYVY
Definition video.h:1542
#define VIDEO_PIX_FMT_SGRBG14P
Definition video.h:1180
#define VIDEO_PIX_FMT_SBGGR16
Definition video.h:1293
#define VIDEO_PIX_FMT_SGBRG12P
Definition video.h:1135
#define VIDEO_PIX_FMT_RGB565
5 red bits [15:11], 6 green bits [10:5], 5 blue bits [4:0].
Definition video.h:1442
#define VIDEO_PIX_FMT_SGRBG12
Definition video.h:1245
#define VIDEO_PIX_FMT_BGR24
24 bit RGB format with 8 bit per component
Definition video.h:1451
#define VIDEO_PIX_FMT_SGRBG14
Definition video.h:1277
#define VIDEO_PIX_FMT_ABGR32
Definition video.h:1476
#define NULL
Definition iar_missing_defs.h:20
Public kernel APIs.
__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
Definition kernel.h:6122
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:158
uint32_t size
size of the buffer in bytes.
Definition video.h:156
enum video_buf_type type
type of the buffer
Definition video.h:148
uint8_t * buffer
pointer to the start of the buffer.
Definition video.h:152
void * driver_data
pointer to driver specific data.
Definition video.h:150
uint16_t line_offset
Line offset within frame this buffer represents, from the beginning of the frame.
Definition video.h:169
uint8_t index
index of the buffer, optionally set by the application
Definition video.h:154
uint32_t timestamp
time reference in milliseconds at which the last data byte was actually received for input endpoints ...
Definition video.h:163
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
Definition video.h:392
video_api_format_t set_format
Definition video.h:394
video_api_ctrl_t set_ctrl
Definition video.h:402
video_api_enqueue_t enqueue
Definition video.h:399
video_api_set_signal_t set_signal
Definition video.h:404
video_api_enum_frmival_t enum_frmival
Definition video.h:407
video_api_get_caps_t get_caps
Definition video.h:397
video_api_selection_t get_selection
Definition video.h:409
video_api_selection_t set_selection
Definition video.h:408
video_api_format_t get_format
Definition video.h:395
video_api_flush_t flush
Definition video.h:401
video_api_dequeue_t dequeue
Definition video.h:400
video_api_frmival_t get_frmival
Definition video.h:406
video_api_frmival_t set_frmival
Definition video.h:405
video_api_set_stream_t set_stream
Definition video.h:396
video_api_ctrl_t get_volatile_ctrl
Definition video.h:403
Video format capability.
Definition video.h:90
uint16_t height_step
height step size in pixels.
Definition video.h:104
uint32_t width_min
minimum supported frame width in pixels.
Definition video.h:94
uint32_t width_max
maximum supported frame width in pixels.
Definition video.h:96
uint16_t width_step
width step size in pixels.
Definition video.h:102
uint32_t height_max
maximum supported frame height in pixels.
Definition video.h:100
uint32_t height_min
minimum supported frame height in pixels.
Definition video.h:98
uint32_t pixelformat
FourCC pixel format value (Video pixel formats).
Definition video.h:92
Video format structure.
Definition video.h:65
uint32_t height
frame height in pixels.
Definition video.h:73
enum video_buf_type type
type of the buffer
Definition video.h:67
uint32_t width
frame width in pixels.
Definition video.h:71
uint32_t pitch
line stride.
Definition video.h:81
uint32_t pixelformat
FourCC pixel format value (Video pixel formats)
Definition video.h:69
Video frame interval enumeration structure.
Definition video.h:218
uint32_t index
frame interval index during enumeration
Definition video.h:220
const struct video_format * format
video format for which the query is made
Definition video.h:222
enum video_frmival_type type
frame interval type the device supports
Definition video.h:224
Video frame interval stepwise structure.
Definition video.h:203
struct video_frmival min
minimum frame interval in seconds
Definition video.h:205
struct video_frmival max
maximum frame interval in seconds
Definition video.h:207
struct video_frmival step
frame interval step size in seconds
Definition video.h:209
Video frame interval structure.
Definition video.h:190
uint32_t numerator
numerator of the frame interval
Definition video.h:192
uint32_t denominator
denominator of the frame interval
Definition video.h:194
Description of a rectangle area.
Definition video.h:268
uint32_t width
width of selection rectangle
Definition video.h:274
uint32_t height
height of selection rectangle
Definition video.h:276
uint32_t top
top offset of selection rectangle
Definition video.h:272
uint32_t left
left offset of selection rectangle
Definition video.h:270
Video selection target enum.
Video selection (crop / compose) structure.
Definition video.h:285
struct video_rect rect
selection target rectangle
Definition video.h:291
enum video_buf_type type
buffer type, allow to select for device having both input and output
Definition video.h:287
enum video_selection_target target
selection target enum
Definition video.h:289