Zephyr API Documentation 4.2.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
video.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Linaro Limited.
3 * Copyright 2025 NXP
4 * Copyright (c) 2025 STMicroelectronics
5 *
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
14
15#ifndef ZEPHYR_INCLUDE_VIDEO_H_
16#define ZEPHYR_INCLUDE_VIDEO_H_
17
26
27#include <zephyr/device.h>
28#include <stddef.h>
29#include <zephyr/kernel.h>
30
31#include <zephyr/types.h>
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37struct video_control;
38
53
88
110
126
134 /* It must be kept as first field of the struct if used for @ref k_fifo APIs. */
157};
158
168
180
194
213
224
242
258
272
279typedef int (*video_api_format_t)(const struct device *dev, struct video_format *fmt);
280
287typedef int (*video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival);
288
295typedef int (*video_api_enum_frmival_t)(const struct device *dev, struct video_frmival_enum *fie);
296
303typedef int (*video_api_enqueue_t)(const struct device *dev, struct video_buffer *buf);
304
311typedef int (*video_api_dequeue_t)(const struct device *dev, struct video_buffer **buf,
312 k_timeout_t timeout);
313
321typedef int (*video_api_flush_t)(const struct device *dev, bool cancel);
322
335typedef int (*video_api_set_stream_t)(const struct device *dev, bool enable,
336 enum video_buf_type type);
337
345typedef int (*video_api_ctrl_t)(const struct device *dev, uint32_t cid);
346
353typedef int (*video_api_get_caps_t)(const struct device *dev, struct video_caps *caps);
354
361typedef int (*video_api_set_signal_t)(const struct device *dev, struct k_poll_signal *sig);
362
369typedef int (*video_api_selection_t)(const struct device *dev, struct video_selection *sel);
370
390
404static inline int video_set_format(const struct device *dev, struct video_format *fmt)
405{
406 const struct video_driver_api *api;
407
408 __ASSERT_NO_MSG(dev != NULL);
409 __ASSERT_NO_MSG(fmt != NULL);
410
411 api = (const struct video_driver_api *)dev->api;
412 if (api->set_format == NULL) {
413 return -ENOSYS;
414 }
415
416 return api->set_format(dev, fmt);
417}
418
429static inline int video_get_format(const struct device *dev, struct video_format *fmt)
430{
431 const struct video_driver_api *api;
432
433 __ASSERT_NO_MSG(dev != NULL);
434 __ASSERT_NO_MSG(fmt != NULL);
435
436 api = (const struct video_driver_api *)dev->api;
437 if (api->get_format == NULL) {
438 return -ENOSYS;
439 }
440
441 return api->get_format(dev, fmt);
442}
443
460static inline int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
461{
462 const struct video_driver_api *api;
463
464 __ASSERT_NO_MSG(dev != NULL);
465 __ASSERT_NO_MSG(frmival != NULL);
466
467 if (frmival->numerator == 0 || frmival->denominator == 0) {
468 return -EINVAL;
469 }
470
471 api = (const struct video_driver_api *)dev->api;
472 if (api->set_frmival == NULL) {
473 return -ENOSYS;
474 }
475
476 return api->set_frmival(dev, frmival);
477}
478
492static inline int video_get_frmival(const struct device *dev, struct video_frmival *frmival)
493{
494 const struct video_driver_api *api;
495
496 __ASSERT_NO_MSG(dev != NULL);
497 __ASSERT_NO_MSG(frmival != NULL);
498
499 api = (const struct video_driver_api *)dev->api;
500 if (api->get_frmival == NULL) {
501 return -ENOSYS;
502 }
503
504 return api->get_frmival(dev, frmival);
505}
506
524static inline int video_enum_frmival(const struct device *dev, struct video_frmival_enum *fie)
525{
526 const struct video_driver_api *api;
527
528 __ASSERT_NO_MSG(dev != NULL);
529 __ASSERT_NO_MSG(fie != NULL);
530 __ASSERT_NO_MSG(fie->format != NULL);
531
532 api = (const struct video_driver_api *)dev->api;
533 if (api->enum_frmival == NULL) {
534 return -ENOSYS;
535 }
536
537 return api->enum_frmival(dev, fie);
538}
539
553static inline int video_enqueue(const struct device *dev, struct video_buffer *buf)
554{
555 const struct video_driver_api *api = (const struct video_driver_api *)dev->api;
556
557 __ASSERT_NO_MSG(dev != NULL);
558 __ASSERT_NO_MSG(buf != NULL);
559 __ASSERT_NO_MSG(buf->buffer != NULL);
560
561 api = (const struct video_driver_api *)dev->api;
562 if (api->enqueue == NULL) {
563 return -ENOSYS;
564 }
565
566 return api->enqueue(dev, buf);
567}
568
583static inline int video_dequeue(const struct device *dev, struct video_buffer **buf,
584 k_timeout_t timeout)
585{
586 const struct video_driver_api *api;
587
588 __ASSERT_NO_MSG(dev != NULL);
589 __ASSERT_NO_MSG(buf != NULL);
590
591 api = (const struct video_driver_api *)dev->api;
592 if (api->dequeue == NULL) {
593 return -ENOSYS;
594 }
595
596 return api->dequeue(dev, buf, timeout);
597}
598
612static inline int video_flush(const struct device *dev, bool cancel)
613{
614 const struct video_driver_api *api;
615
616 __ASSERT_NO_MSG(dev != NULL);
617
618 api = (const struct video_driver_api *)dev->api;
619 if (api->flush == NULL) {
620 return -ENOSYS;
621 }
622
623 return api->flush(dev, cancel);
624}
625
641static inline int video_stream_start(const struct device *dev, enum video_buf_type type)
642{
643 const struct video_driver_api *api;
644
645 __ASSERT_NO_MSG(dev != NULL);
646
647 api = (const struct video_driver_api *)dev->api;
648 if (api->set_stream == NULL) {
649 return -ENOSYS;
650 }
651
652 return api->set_stream(dev, true, type);
653}
654
667static inline int video_stream_stop(const struct device *dev, enum video_buf_type type)
668{
669 const struct video_driver_api *api;
670 int ret;
671
672 __ASSERT_NO_MSG(dev != NULL);
673
674 api = (const struct video_driver_api *)dev->api;
675 if (api->set_stream == NULL) {
676 return -ENOSYS;
677 }
678
679 ret = api->set_stream(dev, false, type);
680 video_flush(dev, true);
681
682 return ret;
683}
684
693static inline int video_get_caps(const struct device *dev, struct video_caps *caps)
694{
695 const struct video_driver_api *api;
696
697 __ASSERT_NO_MSG(dev != NULL);
698 __ASSERT_NO_MSG(caps != NULL);
699
700 api = (const struct video_driver_api *)dev->api;
701 if (api->get_caps == NULL) {
702 return -ENOSYS;
703 }
704
705 return api->get_caps(dev, caps);
706}
707
722int video_set_ctrl(const struct device *dev, struct video_control *control);
723
738int video_get_ctrl(const struct device *dev, struct video_control *control);
739
740struct video_ctrl_query;
741
761
771void video_print_ctrl(const struct video_ctrl_query *const cq);
772
785static inline int video_set_signal(const struct device *dev, struct k_poll_signal *sig)
786{
787 const struct video_driver_api *api;
788
789 __ASSERT_NO_MSG(dev != NULL);
790 __ASSERT_NO_MSG(sig != NULL);
791
792 api = (const struct video_driver_api *)dev->api;
793 if (api->set_signal == NULL) {
794 return -ENOSYS;
795 }
796
797 return api->set_signal(dev, sig);
798}
799
819static inline int video_set_selection(const struct device *dev, struct video_selection *sel)
820{
821 const struct video_driver_api *api;
822
823 __ASSERT_NO_MSG(dev != NULL);
824 __ASSERT_NO_MSG(sel != NULL);
825
826 api = (const struct video_driver_api *)dev->api;
827 if (api->set_selection == NULL) {
828 return -ENOSYS;
829 }
830
831 return api->set_selection(dev, sel);
832}
833
851static inline int video_get_selection(const struct device *dev, struct video_selection *sel)
852{
853 const struct video_driver_api *api;
854
855 __ASSERT_NO_MSG(dev != NULL);
856 __ASSERT_NO_MSG(sel != NULL);
857
858 api = (const struct video_driver_api *)dev->api;
859 if (api->get_selection == NULL) {
860 return -ENOSYS;
861 }
862
863 return api->get_selection(dev, sel);
864}
865
875struct video_buffer *video_buffer_aligned_alloc(size_t size, size_t align, k_timeout_t timeout);
876
886
893
904int video_format_caps_index(const struct video_format_cap *fmts, const struct video_format *fmt,
905 size_t *idx);
906
914static inline uint64_t video_frmival_nsec(const struct video_frmival *frmival)
915{
916 __ASSERT_NO_MSG(frmival != NULL);
917 __ASSERT_NO_MSG(frmival->denominator != 0);
918
919 return (uint64_t)NSEC_PER_SEC * frmival->numerator / frmival->denominator;
920}
921
930 const struct video_frmival *desired,
931 struct video_frmival *match);
932
950void video_closest_frmival(const struct device *dev, struct video_frmival_enum *match);
951
967int64_t video_get_csi_link_freq(const struct device *dev, uint8_t bpp, uint8_t lane_nb);
968
984
992
996#define VIDEO_FOURCC(a, b, c, d) \
997 ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
998
1008#define VIDEO_FOURCC_FROM_STR(str) VIDEO_FOURCC((str)[0], (str)[1], (str)[2], (str)[3])
1009
1019#define VIDEO_FOURCC_TO_STR(fourcc) \
1020 ((char[]){ \
1021 (char)((fourcc) & 0xFF), \
1022 (char)(((fourcc) >> 8) & 0xFF), \
1023 (char)(((fourcc) >> 16) & 0xFF), \
1024 (char)(((fourcc) >> 24) & 0xFF), \
1025 '\0' \
1026 })
1027
1041
1049#define VIDEO_PIX_FMT_SBGGR8 VIDEO_FOURCC('B', 'A', '8', '1')
1050
1058#define VIDEO_PIX_FMT_SGBRG8 VIDEO_FOURCC('G', 'B', 'R', 'G')
1059
1067#define VIDEO_PIX_FMT_SGRBG8 VIDEO_FOURCC('G', 'R', 'B', 'G')
1068
1076#define VIDEO_PIX_FMT_SRGGB8 VIDEO_FOURCC('R', 'G', 'G', 'B')
1077
1085#define VIDEO_PIX_FMT_SBGGR10P VIDEO_FOURCC('p', 'B', 'A', 'A')
1086
1094#define VIDEO_PIX_FMT_SGBRG10P VIDEO_FOURCC('p', 'G', 'A', 'A')
1095
1103#define VIDEO_PIX_FMT_SGRBG10P VIDEO_FOURCC('p', 'g', 'A', 'A')
1104
1112#define VIDEO_PIX_FMT_SRGGB10P VIDEO_FOURCC('p', 'R', 'A', 'A')
1113
1121#define VIDEO_PIX_FMT_SBGGR12P VIDEO_FOURCC('p', 'B', 'C', 'C')
1122
1130#define VIDEO_PIX_FMT_SGBRG12P VIDEO_FOURCC('p', 'G', 'C', 'C')
1131
1139#define VIDEO_PIX_FMT_SGRBG12P VIDEO_FOURCC('p', 'g', 'C', 'C')
1140
1148#define VIDEO_PIX_FMT_SRGGB12P VIDEO_FOURCC('p', 'R', 'C', 'C')
1149
1157#define VIDEO_PIX_FMT_SBGGR14P VIDEO_FOURCC('p', 'B', 'E', 'E')
1158
1166#define VIDEO_PIX_FMT_SGBRG14P VIDEO_FOURCC('p', 'G', 'E', 'E')
1167
1175#define VIDEO_PIX_FMT_SGRBG14P VIDEO_FOURCC('p', 'g', 'E', 'E')
1176
1184#define VIDEO_PIX_FMT_SRGGB14P VIDEO_FOURCC('p', 'R', 'E', 'E')
1185
1192#define VIDEO_PIX_FMT_SBGGR10 VIDEO_FOURCC('B', 'G', '1', '0')
1193
1200#define VIDEO_PIX_FMT_SGBRG10 VIDEO_FOURCC('G', 'B', '1', '0')
1201
1208#define VIDEO_PIX_FMT_SGRBG10 VIDEO_FOURCC('B', 'A', '1', '0')
1209
1216#define VIDEO_PIX_FMT_SRGGB10 VIDEO_FOURCC('R', 'G', '1', '0')
1217
1224#define VIDEO_PIX_FMT_SBGGR12 VIDEO_FOURCC('B', 'G', '1', '2')
1225
1232#define VIDEO_PIX_FMT_SGBRG12 VIDEO_FOURCC('G', 'B', '1', '2')
1233
1240#define VIDEO_PIX_FMT_SGRBG12 VIDEO_FOURCC('B', 'A', '1', '2')
1241
1248#define VIDEO_PIX_FMT_SRGGB12 VIDEO_FOURCC('R', 'G', '1', '2')
1249
1256#define VIDEO_PIX_FMT_SBGGR14 VIDEO_FOURCC('B', 'G', '1', '4')
1257
1264#define VIDEO_PIX_FMT_SGBRG14 VIDEO_FOURCC('G', 'B', '1', '4')
1265
1272#define VIDEO_PIX_FMT_SGRBG14 VIDEO_FOURCC('G', 'R', '1', '4')
1273
1280#define VIDEO_PIX_FMT_SRGGB14 VIDEO_FOURCC('R', 'G', '1', '4')
1281
1288#define VIDEO_PIX_FMT_SBGGR16 VIDEO_FOURCC('B', 'Y', 'R', '2')
1289
1296#define VIDEO_PIX_FMT_SGBRG16 VIDEO_FOURCC('G', 'B', '1', '6')
1297
1304#define VIDEO_PIX_FMT_SGRBG16 VIDEO_FOURCC('G', 'R', '1', '6')
1305
1312#define VIDEO_PIX_FMT_SRGGB16 VIDEO_FOURCC('R', 'G', '1', '6')
1313
1317
1329
1339#define VIDEO_PIX_FMT_GREY VIDEO_FOURCC('G', 'R', 'E', 'Y')
1340
1347#define VIDEO_PIX_FMT_Y10P VIDEO_FOURCC('Y', '1', '0', 'P')
1348
1356#define VIDEO_PIX_FMT_Y12P VIDEO_FOURCC('Y', '1', '2', 'P')
1357
1365#define VIDEO_PIX_FMT_Y14P VIDEO_FOURCC('Y', '1', '4', 'P')
1366
1375#define VIDEO_PIX_FMT_Y10 VIDEO_FOURCC('Y', '1', '0', ' ')
1376
1385#define VIDEO_PIX_FMT_Y12 VIDEO_FOURCC('Y', '1', '2', ' ')
1386
1395#define VIDEO_PIX_FMT_Y14 VIDEO_FOURCC('Y', '1', '4', ' ')
1396
1405#define VIDEO_PIX_FMT_Y16 VIDEO_FOURCC('Y', '1', '6', ' ')
1406
1410
1416
1426#define VIDEO_PIX_FMT_RGB565X VIDEO_FOURCC('R', 'G', 'B', 'R')
1427
1437#define VIDEO_PIX_FMT_RGB565 VIDEO_FOURCC('R', 'G', 'B', 'P')
1438
1446#define VIDEO_PIX_FMT_BGR24 VIDEO_FOURCC('B', 'G', 'R', '3')
1447
1455#define VIDEO_PIX_FMT_RGB24 VIDEO_FOURCC('R', 'G', 'B', '3')
1456
1462
1463#define VIDEO_PIX_FMT_ARGB32 VIDEO_FOURCC('B', 'A', '2', '4')
1464
1470
1471#define VIDEO_PIX_FMT_ABGR32 VIDEO_FOURCC('A', 'R', '2', '4')
1472
1478
1479#define VIDEO_PIX_FMT_RGBA32 VIDEO_FOURCC('A', 'B', '2', '4')
1480
1486
1487#define VIDEO_PIX_FMT_BGRA32 VIDEO_FOURCC('R', 'A', '2', '4')
1488
1496#define VIDEO_PIX_FMT_XRGB32 VIDEO_FOURCC('B', 'X', '2', '4')
1497
1501
1507
1516#define VIDEO_PIX_FMT_YUYV VIDEO_FOURCC('Y', 'U', 'Y', 'V')
1517
1523#define VIDEO_PIX_FMT_YVYU VIDEO_FOURCC('Y', 'V', 'Y', 'U')
1524
1530#define VIDEO_PIX_FMT_VYUY VIDEO_FOURCC('V', 'Y', 'U', 'Y')
1531
1537#define VIDEO_PIX_FMT_UYVY VIDEO_FOURCC('U', 'Y', 'V', 'Y')
1538
1546#define VIDEO_PIX_FMT_XYUV32 VIDEO_FOURCC('X', 'Y', 'U', 'V')
1547
1573#define VIDEO_PIX_FMT_NV12 VIDEO_FOURCC('N', 'V', '1', '2')
1574
1597#define VIDEO_PIX_FMT_NV21 VIDEO_FOURCC('N', 'V', '2', '1')
1598
1623#define VIDEO_PIX_FMT_NV16 VIDEO_FOURCC('N', 'V', '1', '6')
1624
1649
1650#define VIDEO_PIX_FMT_NV61 VIDEO_FOURCC('N', 'V', '6', '1')
1651
1676#define VIDEO_PIX_FMT_NV24 VIDEO_FOURCC('N', 'V', '2', '4')
1677
1702#define VIDEO_PIX_FMT_NV42 VIDEO_FOURCC('N', 'V', '4', '2')
1703
1731#define VIDEO_PIX_FMT_YUV420 VIDEO_FOURCC('Y', 'U', '1', '2')
1732
1760#define VIDEO_PIX_FMT_YVU420 VIDEO_FOURCC('Y', 'V', '1', '2')
1761
1765
1770
1774#define VIDEO_PIX_FMT_JPEG VIDEO_FOURCC('J', 'P', 'E', 'G')
1775
1779#define VIDEO_PIX_FMT_H264 VIDEO_FOURCC('H', '2', '6', '4')
1780
1784#define VIDEO_PIX_FMT_H264_NO_SC VIDEO_FOURCC('A', 'V', 'C', '1')
1785
1789
1798static inline unsigned int video_bits_per_pixel(uint32_t pixfmt)
1799{
1800 switch (pixfmt) {
1805 case VIDEO_PIX_FMT_GREY:
1806 return 8;
1811 case VIDEO_PIX_FMT_Y10P:
1812 return 10;
1817 case VIDEO_PIX_FMT_Y12P:
1818 case VIDEO_PIX_FMT_NV12:
1819 case VIDEO_PIX_FMT_NV21:
1822 return 12;
1827 case VIDEO_PIX_FMT_Y14P:
1828 return 14;
1830 case VIDEO_PIX_FMT_YUYV:
1831 case VIDEO_PIX_FMT_YVYU:
1832 case VIDEO_PIX_FMT_UYVY:
1833 case VIDEO_PIX_FMT_VYUY:
1850 case VIDEO_PIX_FMT_Y10:
1851 case VIDEO_PIX_FMT_Y12:
1852 case VIDEO_PIX_FMT_Y14:
1853 case VIDEO_PIX_FMT_Y16:
1854 case VIDEO_PIX_FMT_NV16:
1855 case VIDEO_PIX_FMT_NV61:
1856 return 16;
1859 case VIDEO_PIX_FMT_NV24:
1860 case VIDEO_PIX_FMT_NV42:
1861 return 24;
1868 return 32;
1869 default:
1870 /* Variable number of bits per pixel or unknown format */
1871 return 0;
1872 }
1873}
1874
1878
1889
1891#define VIDEO_MIPI_CSI2_DT_NULL 0x10
1893#define VIDEO_MIPI_CSI2_DT_BLANKING 0x11
1895#define VIDEO_MIPI_CSI2_DT_EMBEDDED_8 0x12
1897#define VIDEO_MIPI_CSI2_DT_YUV420_8 0x18
1899#define VIDEO_MIPI_CSI2_DT_YUV420_10 0x19
1901#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_8 0x1c
1903#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_10 0x1d
1905#define VIDEO_MIPI_CSI2_DT_YUV422_8 0x1e
1907#define VIDEO_MIPI_CSI2_DT_YUV422_10 0x1f
1909#define VIDEO_MIPI_CSI2_DT_RGB444 0x20
1911#define VIDEO_MIPI_CSI2_DT_RGB555 0x21
1913#define VIDEO_MIPI_CSI2_DT_RGB565 0x22
1915#define VIDEO_MIPI_CSI2_DT_RGB666 0x23
1917#define VIDEO_MIPI_CSI2_DT_RGB888 0x24
1919#define VIDEO_MIPI_CSI2_DT_RAW6 0x28
1921#define VIDEO_MIPI_CSI2_DT_RAW7 0x29
1923#define VIDEO_MIPI_CSI2_DT_RAW8 0x2a
1925#define VIDEO_MIPI_CSI2_DT_RAW10 0x2b
1927#define VIDEO_MIPI_CSI2_DT_RAW12 0x2c
1929#define VIDEO_MIPI_CSI2_DT_RAW14 0x2d
1930
1942#define VIDEO_MIPI_CSI2_DT_USER(n) (0x30 + (n))
1943
1947
1948#ifdef __cplusplus
1949}
1950#endif
1951
1955
1956#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:295
int(* video_api_get_caps_t)(const struct device *dev, struct video_caps *caps)
Get capabilities of a video endpoint.
Definition video.h:353
video_signal_result
Video signal result.
Definition video.h:219
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:819
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:311
static int video_dequeue(const struct device *dev, struct video_buffer **buf, k_timeout_t timeout)
Dequeue a video buffer.
Definition video.h:583
int(* video_api_ctrl_t)(const struct device *dev, uint32_t cid)
Set/Get a video control value.
Definition video.h:345
video_frmival_type
Supported frame interval type of a video device.
Definition video.h:162
static uint64_t video_frmival_nsec(const struct video_frmival *frmival)
Compute the difference between two frame intervals.
Definition video.h:914
int video_get_ctrl(const struct device *dev, struct video_control *control)
Get the current value of a control.
int video_estimate_fmt_size(struct video_format *fmt)
Estimate the size and pitch in bytes of a video_format.
static int video_enum_frmival(const struct device *dev, struct video_frmival_enum *fie)
List video frame intervals.
Definition video.h:524
static int video_stream_start(const struct device *dev, enum video_buf_type type)
Start the video device function.
Definition video.h:641
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:693
static int video_get_selection(const struct device *dev, struct video_selection *sel)
Get video selection (crop/compose).
Definition video.h:851
int(* video_api_format_t)(const struct device *dev, struct video_format *fmt)
Function pointer type for video_set/get_format()
Definition video.h:279
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:321
static int video_flush(const struct device *dev, bool cancel)
Flush endpoint buffers.
Definition video.h:612
static int video_stream_stop(const struct device *dev, enum video_buf_type type)
Stop the video device function.
Definition video.h:667
int(* video_api_selection_t)(const struct device *dev, struct video_selection *sel)
Get/Set video selection (crop / compose)
Definition video.h:369
static int video_set_format(const struct device *dev, struct video_format *fmt)
Set video format.
Definition video.h:404
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:785
static int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
Set video frame interval.
Definition video.h:460
static int video_enqueue(const struct device *dev, struct video_buffer *buf)
Enqueue a video buffer.
Definition video.h:553
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:335
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:47
static int video_get_format(const struct device *dev, struct video_format *fmt)
Get video format.
Definition video.h:429
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:361
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.
video_selection_target
Video selection target.
Definition video.h:230
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:303
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:492
int(* video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival)
Function pointer type for video_set/get_frmival()
Definition video.h:287
@ VIDEO_BUF_ABORTED
Buffer is aborted.
Definition video.h:221
@ VIDEO_BUF_DONE
Buffer is done.
Definition video.h:220
@ VIDEO_BUF_ERROR
Buffer is in error.
Definition video.h:222
@ VIDEO_FRMIVAL_TYPE_DISCRETE
discrete frame interval type
Definition video.h:164
@ VIDEO_FRMIVAL_TYPE_STEPWISE
stepwise frame interval type
Definition video.h:166
@ VIDEO_BUF_TYPE_INPUT
input buffer type
Definition video.h:49
@ VIDEO_BUF_TYPE_OUTPUT
output buffer type
Definition video.h:51
@ VIDEO_SEL_TGT_COMPOSE_BOUND
Compose bound (aka the maximum compose achievable)
Definition video.h:240
@ VIDEO_SEL_TGT_COMPOSE
Current compose setting.
Definition video.h:238
@ VIDEO_SEL_TGT_NATIVE_SIZE
Native size of the input frame.
Definition video.h:236
@ VIDEO_SEL_TGT_CROP
Current crop setting.
Definition video.h:232
@ VIDEO_SEL_TGT_CROP_BOUND
Crop bound (aka the maximum crop achievable)
Definition video.h:234
#define VIDEO_PIX_FMT_SGRBG10
Definition video.h:1208
#define VIDEO_PIX_FMT_XYUV32
The first byte is empty (X) for each pixel.
Definition video.h:1546
#define VIDEO_PIX_FMT_SGRBG12P
Definition video.h:1139
#define VIDEO_PIX_FMT_RGB24
24 bit RGB format with 8 bit per component
Definition video.h:1455
#define VIDEO_PIX_FMT_Y10
Little endian, with the 6 most significant bits set to Zero.
Definition video.h:1375
#define VIDEO_PIX_FMT_NV24
Chroma (U/V) are not subsampled.
Definition video.h:1676
#define VIDEO_PIX_FMT_SBGGR10
Definition video.h:1192
#define VIDEO_PIX_FMT_Y12
Little endian, with the 4 most significant bits set to Zero.
Definition video.h:1385
#define VIDEO_PIX_FMT_NV21
Chroma (U/V) are subsampled horizontaly and vertically.
Definition video.h:1597
#define VIDEO_PIX_FMT_SGRBG8
Definition video.h:1067
#define VIDEO_PIX_FMT_SRGGB10
Definition video.h:1216
#define VIDEO_PIX_FMT_Y12P
Definition video.h:1356
#define VIDEO_PIX_FMT_YVYU
Definition video.h:1523
#define VIDEO_PIX_FMT_NV61
Chroma (U/V) are subsampled horizontaly.
Definition video.h:1650
#define VIDEO_PIX_FMT_SRGGB12P
Definition video.h:1148
#define VIDEO_PIX_FMT_SBGGR10P
Definition video.h:1085
#define VIDEO_PIX_FMT_SBGGR14
Definition video.h:1256
#define VIDEO_PIX_FMT_SGRBG16
Definition video.h:1304
#define VIDEO_PIX_FMT_SRGGB16
Definition video.h:1312
#define VIDEO_PIX_FMT_Y10P
Definition video.h:1347
#define VIDEO_PIX_FMT_BGRA32
Definition video.h:1487
#define VIDEO_PIX_FMT_ARGB32
Definition video.h:1463
#define VIDEO_PIX_FMT_SRGGB10P
Definition video.h:1112
#define VIDEO_PIX_FMT_VYUY
Definition video.h:1530
#define VIDEO_PIX_FMT_SRGGB14P
Definition video.h:1184
#define VIDEO_PIX_FMT_SGBRG14
Definition video.h:1264
#define VIDEO_PIX_FMT_NV12
Planar formats.
Definition video.h:1573
#define VIDEO_PIX_FMT_SRGGB12
Definition video.h:1248
#define VIDEO_PIX_FMT_Y14
Little endian, with the 2 most significant bits set to Zero.
Definition video.h:1395
#define VIDEO_PIX_FMT_SGBRG16
Definition video.h:1296
#define VIDEO_PIX_FMT_SGBRG14P
Definition video.h:1166
#define VIDEO_PIX_FMT_XRGB32
The first byte is empty (X) for each pixel.
Definition video.h:1496
#define VIDEO_PIX_FMT_SGBRG10
Definition video.h:1200
#define VIDEO_PIX_FMT_RGBA32
Definition video.h:1479
#define VIDEO_PIX_FMT_YUV420
Chroma (U/V) are subsampled horizontaly and vertically.
Definition video.h:1731
#define VIDEO_PIX_FMT_YVU420
Chroma (U/V) are subsampled horizontaly and vertically.
Definition video.h:1760
#define VIDEO_PIX_FMT_SGRBG10P
Definition video.h:1103
#define VIDEO_PIX_FMT_SBGGR12
Definition video.h:1224
#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:1339
#define VIDEO_PIX_FMT_SGBRG12
Definition video.h:1232
#define VIDEO_PIX_FMT_Y16
Little endian.
Definition video.h:1405
#define VIDEO_PIX_FMT_SRGGB14
Definition video.h:1280
#define VIDEO_PIX_FMT_SGBRG8
Definition video.h:1058
#define VIDEO_PIX_FMT_SBGGR12P
Definition video.h:1121
#define VIDEO_PIX_FMT_NV16
Chroma (U/V) are subsampled horizontaly.
Definition video.h:1623
#define VIDEO_PIX_FMT_SBGGR8
Definition video.h:1049
static unsigned int video_bits_per_pixel(uint32_t pixfmt)
Get number of bits per pixel of a pixel format.
Definition video.h:1798
#define VIDEO_PIX_FMT_SRGGB8
Definition video.h:1076
#define VIDEO_PIX_FMT_SBGGR14P
Definition video.h:1157
#define VIDEO_PIX_FMT_NV42
Chroma (U/V) are not subsampled.
Definition video.h:1702
#define VIDEO_PIX_FMT_YUYV
There is either a missing channel per pixel, U or V.
Definition video.h:1516
#define VIDEO_PIX_FMT_SGBRG10P
Definition video.h:1094
#define VIDEO_PIX_FMT_Y14P
Definition video.h:1365
#define VIDEO_PIX_FMT_UYVY
Definition video.h:1537
#define VIDEO_PIX_FMT_SGRBG14P
Definition video.h:1175
#define VIDEO_PIX_FMT_SBGGR16
Definition video.h:1288
#define VIDEO_PIX_FMT_SGBRG12P
Definition video.h:1130
#define VIDEO_PIX_FMT_RGB565
5 red bits [15:11], 6 green bits [10:5], 5 blue bits [4:0].
Definition video.h:1437
#define VIDEO_PIX_FMT_SGRBG12
Definition video.h:1240
#define VIDEO_PIX_FMT_BGR24
24 bit RGB format with 8 bit per component
Definition video.h:1446
#define VIDEO_PIX_FMT_SGRBG14
Definition video.h:1272
#define VIDEO_PIX_FMT_ABGR32
Definition video.h:1471
#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
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:6179
Kernel timeout type.
Definition clock.h:65
Video buffer structure.
Definition video.h:132
uint32_t bytesused
number of bytes occupied by the valid data in the buffer.
Definition video.h:145
uint32_t size
size of the buffer in bytes.
Definition video.h:143
enum video_buf_type type
type of the buffer
Definition video.h:137
uint8_t * buffer
pointer to the start of the buffer.
Definition video.h:139
void * driver_data
Pointer to driver specific data.
Definition video.h:135
uint16_t line_offset
Line offset within frame this buffer represents, from the beginning of the frame.
Definition video.h:156
uint8_t index
index of the buffer, optionally set by the application
Definition video.h:141
uint32_t timestamp
time reference in milliseconds at which the last data byte was actually received for input endpoints ...
Definition video.h:150
Video format capabilities.
Definition video.h:116
uint8_t min_vbuf_count
minimal count of video buffers to enqueue before being able to start the stream.
Definition video.h:124
enum video_buf_type type
type of the buffer
Definition video.h:118
const struct video_format_cap * format_caps
list of video format capabilities (zero terminated).
Definition video.h:120
Video control structure.
Definition video-controls.h:428
Definition video-controls.h:475
const struct device * dev
device being queried, application needs to set this field
Definition video-controls.h:477
Definition video.h:371
video_api_format_t set_format
Definition video.h:373
video_api_ctrl_t set_ctrl
Definition video.h:381
video_api_enqueue_t enqueue
Definition video.h:378
video_api_set_signal_t set_signal
Definition video.h:383
video_api_enum_frmival_t enum_frmival
Definition video.h:386
video_api_get_caps_t get_caps
Definition video.h:376
video_api_selection_t get_selection
Definition video.h:388
video_api_selection_t set_selection
Definition video.h:387
video_api_format_t get_format
Definition video.h:374
video_api_flush_t flush
Definition video.h:380
video_api_dequeue_t dequeue
Definition video.h:379
video_api_frmival_t get_frmival
Definition video.h:385
video_api_frmival_t set_frmival
Definition video.h:384
video_api_set_stream_t set_stream
Definition video.h:375
video_api_ctrl_t get_volatile_ctrl
Definition video.h:382
Video format capability.
Definition video.h:94
uint16_t height_step
height step size in pixels.
Definition video.h:108
uint32_t width_min
minimum supported frame width in pixels.
Definition video.h:98
uint32_t width_max
maximum supported frame width in pixels.
Definition video.h:100
uint16_t width_step
width step size in pixels.
Definition video.h:106
uint32_t height_max
maximum supported frame height in pixels.
Definition video.h:104
uint32_t height_min
minimum supported frame height in pixels.
Definition video.h:102
uint32_t pixelformat
FourCC pixel format value (Video pixel formats).
Definition video.h:96
Video format structure.
Definition video.h:59
uint32_t height
frame height in pixels.
Definition video.h:67
enum video_buf_type type
type of the buffer
Definition video.h:61
uint32_t size
size of the buffer in bytes, need to be set by the drivers
Definition video.h:86
uint32_t width
frame width in pixels.
Definition video.h:65
uint32_t pitch
line stride.
Definition video.h:75
uint32_t pixelformat
FourCC pixel format value (Video pixel formats)
Definition video.h:63
Video frame interval enumeration structure.
Definition video.h:200
uint32_t index
frame interval index during enumeration
Definition video.h:202
const struct video_format * format
video format for which the query is made
Definition video.h:204
struct video_frmival_stepwise stepwise
Definition video.h:210
enum video_frmival_type type
frame interval type the device supports
Definition video.h:206
struct video_frmival discrete
Definition video.h:209
Video frame interval stepwise structure.
Definition video.h:186
struct video_frmival min
minimum frame interval in seconds
Definition video.h:188
struct video_frmival max
maximum frame interval in seconds
Definition video.h:190
struct video_frmival step
frame interval step size in seconds
Definition video.h:192
Video frame interval structure.
Definition video.h:174
uint32_t numerator
numerator of the frame interval
Definition video.h:176
uint32_t denominator
denominator of the frame interval
Definition video.h:178
Description of a rectangle area.
Definition video.h:248
uint32_t width
width of selection rectangle
Definition video.h:254
uint32_t height
height of selection rectangle
Definition video.h:256
uint32_t top
top offset of selection rectangle
Definition video.h:252
uint32_t left
left offset of selection rectangle
Definition video.h:250
Video selection (crop / compose) structure.
Definition video.h:264
struct video_rect rect
selection target rectangle
Definition video.h:270
enum video_buf_type type
buffer type, allow to select for device having both input and output
Definition video.h:266
enum video_selection_target target
selection target enum
Definition video.h:268