Zephyr Project API 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
15#ifndef ZEPHYR_INCLUDE_VIDEO_H_
16#define ZEPHYR_INCLUDE_VIDEO_H_
17
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
37/*
38 * Flag used by @ref video_caps structure to indicate endpoint operates on
39 * buffers the size of the video frame
40 */
41#define LINE_COUNT_HEIGHT (-1)
42
43struct video_control;
44
59
83
105
137
145 /* It must be kept as first field of the struct if used for @ref k_fifo APIs. */
168};
169
179
191
205
215 const struct video_format *format;
219 union {
220 struct video_frmival discrete;
221 struct video_frmival_stepwise stepwise;
222 };
223};
224
235
253
269
283
290typedef int (*video_api_format_t)(const struct device *dev, struct video_format *fmt);
291
298typedef int (*video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival);
299
306typedef int (*video_api_enum_frmival_t)(const struct device *dev, struct video_frmival_enum *fie);
307
314typedef int (*video_api_enqueue_t)(const struct device *dev, struct video_buffer *buf);
315
322typedef int (*video_api_dequeue_t)(const struct device *dev, struct video_buffer **buf,
323 k_timeout_t timeout);
324
332typedef int (*video_api_flush_t)(const struct device *dev, bool cancel);
333
346typedef int (*video_api_set_stream_t)(const struct device *dev, bool enable,
347 enum video_buf_type type);
348
356typedef int (*video_api_ctrl_t)(const struct device *dev, uint32_t cid);
357
364typedef int (*video_api_get_caps_t)(const struct device *dev, struct video_caps *caps);
365
372typedef int (*video_api_set_signal_t)(const struct device *dev, struct k_poll_signal *sig);
373
380typedef int (*video_api_selection_t)(const struct device *dev, struct video_selection *sel);
381
401
415static inline int video_set_format(const struct device *dev, struct video_format *fmt)
416{
417 const struct video_driver_api *api;
418
419 __ASSERT_NO_MSG(dev != NULL);
420 __ASSERT_NO_MSG(fmt != NULL);
421
422 api = (const struct video_driver_api *)dev->api;
423 if (api->set_format == NULL) {
424 return -ENOSYS;
425 }
426
427 return api->set_format(dev, fmt);
428}
429
440static inline int video_get_format(const struct device *dev, struct video_format *fmt)
441{
442 const struct video_driver_api *api;
443
444 __ASSERT_NO_MSG(dev != NULL);
445 __ASSERT_NO_MSG(fmt != NULL);
446
447 api = (const struct video_driver_api *)dev->api;
448 if (api->get_format == NULL) {
449 return -ENOSYS;
450 }
451
452 return api->get_format(dev, fmt);
453}
454
471static inline int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
472{
473 const struct video_driver_api *api;
474
475 __ASSERT_NO_MSG(dev != NULL);
476 __ASSERT_NO_MSG(frmival != NULL);
477
478 if (frmival->numerator == 0 || frmival->denominator == 0) {
479 return -EINVAL;
480 }
481
482 api = (const struct video_driver_api *)dev->api;
483 if (api->set_frmival == NULL) {
484 return -ENOSYS;
485 }
486
487 return api->set_frmival(dev, frmival);
488}
489
503static inline int video_get_frmival(const struct device *dev, struct video_frmival *frmival)
504{
505 const struct video_driver_api *api;
506
507 __ASSERT_NO_MSG(dev != NULL);
508 __ASSERT_NO_MSG(frmival != NULL);
509
510 api = (const struct video_driver_api *)dev->api;
511 if (api->get_frmival == NULL) {
512 return -ENOSYS;
513 }
514
515 return api->get_frmival(dev, frmival);
516}
517
535static inline int video_enum_frmival(const struct device *dev, struct video_frmival_enum *fie)
536{
537 const struct video_driver_api *api;
538
539 __ASSERT_NO_MSG(dev != NULL);
540 __ASSERT_NO_MSG(fie != NULL);
541 __ASSERT_NO_MSG(fie->format != NULL);
542
543 api = (const struct video_driver_api *)dev->api;
544 if (api->enum_frmival == NULL) {
545 return -ENOSYS;
546 }
547
548 return api->enum_frmival(dev, fie);
549}
550
564static inline int video_enqueue(const struct device *dev, struct video_buffer *buf)
565{
566 const struct video_driver_api *api = (const struct video_driver_api *)dev->api;
567
568 __ASSERT_NO_MSG(dev != NULL);
569 __ASSERT_NO_MSG(buf != NULL);
570 __ASSERT_NO_MSG(buf->buffer != NULL);
571
572 api = (const struct video_driver_api *)dev->api;
573 if (api->enqueue == NULL) {
574 return -ENOSYS;
575 }
576
577 return api->enqueue(dev, buf);
578}
579
594static inline int video_dequeue(const struct device *dev, struct video_buffer **buf,
595 k_timeout_t timeout)
596{
597 const struct video_driver_api *api;
598
599 __ASSERT_NO_MSG(dev != NULL);
600 __ASSERT_NO_MSG(buf != NULL);
601
602 api = (const struct video_driver_api *)dev->api;
603 if (api->dequeue == NULL) {
604 return -ENOSYS;
605 }
606
607 return api->dequeue(dev, buf, timeout);
608}
609
623static inline int video_flush(const struct device *dev, bool cancel)
624{
625 const struct video_driver_api *api;
626
627 __ASSERT_NO_MSG(dev != NULL);
628
629 api = (const struct video_driver_api *)dev->api;
630 if (api->flush == NULL) {
631 return -ENOSYS;
632 }
633
634 return api->flush(dev, cancel);
635}
636
652static inline int video_stream_start(const struct device *dev, enum video_buf_type type)
653{
654 const struct video_driver_api *api;
655
656 __ASSERT_NO_MSG(dev != NULL);
657
658 api = (const struct video_driver_api *)dev->api;
659 if (api->set_stream == NULL) {
660 return -ENOSYS;
661 }
662
663 return api->set_stream(dev, true, type);
664}
665
678static inline int video_stream_stop(const struct device *dev, enum video_buf_type type)
679{
680 const struct video_driver_api *api;
681 int ret;
682
683 __ASSERT_NO_MSG(dev != NULL);
684
685 api = (const struct video_driver_api *)dev->api;
686 if (api->set_stream == NULL) {
687 return -ENOSYS;
688 }
689
690 ret = api->set_stream(dev, false, type);
691 video_flush(dev, true);
692
693 return ret;
694}
695
704static inline int video_get_caps(const struct device *dev, struct video_caps *caps)
705{
706 const struct video_driver_api *api;
707
708 __ASSERT_NO_MSG(dev != NULL);
709 __ASSERT_NO_MSG(caps != NULL);
710
711 api = (const struct video_driver_api *)dev->api;
712 if (api->get_caps == NULL) {
713 return -ENOSYS;
714 }
715
716 return api->get_caps(dev, caps);
717}
718
733int video_set_ctrl(const struct device *dev, struct video_control *control);
734
749int video_get_ctrl(const struct device *dev, struct video_control *control);
750
751struct video_ctrl_query;
752
772
782void video_print_ctrl(const struct video_ctrl_query *const cq);
783
796static inline int video_set_signal(const struct device *dev, struct k_poll_signal *sig)
797{
798 const struct video_driver_api *api;
799
800 __ASSERT_NO_MSG(dev != NULL);
801 __ASSERT_NO_MSG(sig != NULL);
802
803 api = (const struct video_driver_api *)dev->api;
804 if (api->set_signal == NULL) {
805 return -ENOSYS;
806 }
807
808 return api->set_signal(dev, sig);
809}
810
830static inline int video_set_selection(const struct device *dev, struct video_selection *sel)
831{
832 const struct video_driver_api *api;
833
834 __ASSERT_NO_MSG(dev != NULL);
835 __ASSERT_NO_MSG(sel != NULL);
836
837 api = (const struct video_driver_api *)dev->api;
838 if (api->set_selection == NULL) {
839 return -ENOSYS;
840 }
841
842 return api->set_selection(dev, sel);
843}
844
862static inline int video_get_selection(const struct device *dev, struct video_selection *sel)
863{
864 const struct video_driver_api *api;
865
866 __ASSERT_NO_MSG(dev != NULL);
867 __ASSERT_NO_MSG(sel != NULL);
868
869 api = (const struct video_driver_api *)dev->api;
870 if (api->get_selection == NULL) {
871 return -ENOSYS;
872 }
873
874 return api->get_selection(dev, sel);
875}
876
886struct video_buffer *video_buffer_aligned_alloc(size_t size, size_t align, k_timeout_t timeout);
887
897
904
915int video_format_caps_index(const struct video_format_cap *fmts, const struct video_format *fmt,
916 size_t *idx);
917
925static inline uint64_t video_frmival_nsec(const struct video_frmival *frmival)
926{
927 __ASSERT_NO_MSG(frmival != NULL);
928 __ASSERT_NO_MSG(frmival->denominator != 0);
929
930 return (uint64_t)NSEC_PER_SEC * frmival->numerator / frmival->denominator;
931}
932
941 const struct video_frmival *desired,
942 struct video_frmival *match);
943
961void video_closest_frmival(const struct device *dev, struct video_frmival_enum *match);
962
978int64_t video_get_csi_link_freq(const struct device *dev, uint8_t bpp, uint8_t lane_nb);
979
991#define VIDEO_FOURCC(a, b, c, d) \
992 ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
993
1003#define VIDEO_FOURCC_FROM_STR(str) VIDEO_FOURCC((str)[0], (str)[1], (str)[2], (str)[3])
1004
1014#define VIDEO_FOURCC_TO_STR(fourcc) \
1015 ((char[]){ \
1016 (char)((fourcc) & 0xFF), \
1017 (char)(((fourcc) >> 8) & 0xFF), \
1018 (char)(((fourcc) >> 16) & 0xFF), \
1019 (char)(((fourcc) >> 24) & 0xFF), \
1020 '\0' \
1021 })
1022
1044#define VIDEO_PIX_FMT_SBGGR8 VIDEO_FOURCC('B', 'A', '8', '1')
1045
1053#define VIDEO_PIX_FMT_SGBRG8 VIDEO_FOURCC('G', 'B', 'R', 'G')
1054
1062#define VIDEO_PIX_FMT_SGRBG8 VIDEO_FOURCC('G', 'R', 'B', 'G')
1063
1071#define VIDEO_PIX_FMT_SRGGB8 VIDEO_FOURCC('R', 'G', 'G', 'B')
1072
1080#define VIDEO_PIX_FMT_SBGGR10P VIDEO_FOURCC('p', 'B', 'A', 'A')
1081
1089#define VIDEO_PIX_FMT_SGBRG10P VIDEO_FOURCC('p', 'G', 'A', 'A')
1090
1098#define VIDEO_PIX_FMT_SGRBG10P VIDEO_FOURCC('p', 'g', 'A', 'A')
1099
1107#define VIDEO_PIX_FMT_SRGGB10P VIDEO_FOURCC('p', 'R', 'A', 'A')
1108
1116#define VIDEO_PIX_FMT_SBGGR12P VIDEO_FOURCC('p', 'B', 'C', 'C')
1117
1125#define VIDEO_PIX_FMT_SGBRG12P VIDEO_FOURCC('p', 'G', 'C', 'C')
1126
1134#define VIDEO_PIX_FMT_SGRBG12P VIDEO_FOURCC('p', 'g', 'C', 'C')
1135
1143#define VIDEO_PIX_FMT_SRGGB12P VIDEO_FOURCC('p', 'R', 'C', 'C')
1144
1152#define VIDEO_PIX_FMT_SBGGR14P VIDEO_FOURCC('p', 'B', 'E', 'E')
1153
1161#define VIDEO_PIX_FMT_SGBRG14P VIDEO_FOURCC('p', 'G', 'E', 'E')
1162
1170#define VIDEO_PIX_FMT_SGRBG14P VIDEO_FOURCC('p', 'g', 'E', 'E')
1171
1179#define VIDEO_PIX_FMT_SRGGB14P VIDEO_FOURCC('p', 'R', 'E', 'E')
1180
1187#define VIDEO_PIX_FMT_SBGGR10 VIDEO_FOURCC('B', 'G', '1', '0')
1188
1195#define VIDEO_PIX_FMT_SGBRG10 VIDEO_FOURCC('G', 'B', '1', '0')
1196
1203#define VIDEO_PIX_FMT_SGRBG10 VIDEO_FOURCC('B', 'A', '1', '0')
1204
1211#define VIDEO_PIX_FMT_SRGGB10 VIDEO_FOURCC('R', 'G', '1', '0')
1212
1219#define VIDEO_PIX_FMT_SBGGR12 VIDEO_FOURCC('B', 'G', '1', '2')
1220
1227#define VIDEO_PIX_FMT_SGBRG12 VIDEO_FOURCC('G', 'B', '1', '2')
1228
1235#define VIDEO_PIX_FMT_SGRBG12 VIDEO_FOURCC('B', 'A', '1', '2')
1236
1243#define VIDEO_PIX_FMT_SRGGB12 VIDEO_FOURCC('R', 'G', '1', '2')
1244
1251#define VIDEO_PIX_FMT_SBGGR14 VIDEO_FOURCC('B', 'G', '1', '4')
1252
1259#define VIDEO_PIX_FMT_SGBRG14 VIDEO_FOURCC('G', 'B', '1', '4')
1260
1267#define VIDEO_PIX_FMT_SGRBG14 VIDEO_FOURCC('G', 'R', '1', '4')
1268
1275#define VIDEO_PIX_FMT_SRGGB14 VIDEO_FOURCC('R', 'G', '1', '4')
1276
1283#define VIDEO_PIX_FMT_SBGGR16 VIDEO_FOURCC('B', 'Y', 'R', '2')
1284
1291#define VIDEO_PIX_FMT_SGBRG16 VIDEO_FOURCC('G', 'B', '1', '6')
1292
1299#define VIDEO_PIX_FMT_SGRBG16 VIDEO_FOURCC('G', 'R', '1', '6')
1300
1307#define VIDEO_PIX_FMT_SRGGB16 VIDEO_FOURCC('R', 'G', '1', '6')
1308
1334#define VIDEO_PIX_FMT_GREY VIDEO_FOURCC('G', 'R', 'E', 'Y')
1335
1342#define VIDEO_PIX_FMT_Y10P VIDEO_FOURCC('Y', '1', '0', 'P')
1343
1351#define VIDEO_PIX_FMT_Y12P VIDEO_FOURCC('Y', '1', '2', 'P')
1352
1360#define VIDEO_PIX_FMT_Y14P VIDEO_FOURCC('Y', '1', '4', 'P')
1361
1370#define VIDEO_PIX_FMT_Y10 VIDEO_FOURCC('Y', '1', '0', ' ')
1371
1380#define VIDEO_PIX_FMT_Y12 VIDEO_FOURCC('Y', '1', '2', ' ')
1381
1390#define VIDEO_PIX_FMT_Y14 VIDEO_FOURCC('Y', '1', '4', ' ')
1391
1400#define VIDEO_PIX_FMT_Y16 VIDEO_FOURCC('Y', '1', '6', ' ')
1401
1421#define VIDEO_PIX_FMT_RGB565X VIDEO_FOURCC('R', 'G', 'B', 'R')
1422
1432#define VIDEO_PIX_FMT_RGB565 VIDEO_FOURCC('R', 'G', 'B', 'P')
1433
1441#define VIDEO_PIX_FMT_BGR24 VIDEO_FOURCC('B', 'G', 'R', '3')
1442
1450#define VIDEO_PIX_FMT_RGB24 VIDEO_FOURCC('R', 'G', 'B', '3')
1451
1458#define VIDEO_PIX_FMT_ARGB32 VIDEO_FOURCC('B', 'A', '2', '4')
1459
1466#define VIDEO_PIX_FMT_ABGR32 VIDEO_FOURCC('A', 'R', '2', '4')
1467
1474#define VIDEO_PIX_FMT_RGBA32 VIDEO_FOURCC('A', 'B', '2', '4')
1475
1482#define VIDEO_PIX_FMT_BGRA32 VIDEO_FOURCC('R', 'A', '2', '4')
1483
1491#define VIDEO_PIX_FMT_XRGB32 VIDEO_FOURCC('B', 'X', '2', '4')
1492
1511#define VIDEO_PIX_FMT_YUYV VIDEO_FOURCC('Y', 'U', 'Y', 'V')
1512
1518#define VIDEO_PIX_FMT_YVYU VIDEO_FOURCC('Y', 'V', 'Y', 'U')
1519
1525#define VIDEO_PIX_FMT_VYUY VIDEO_FOURCC('V', 'Y', 'U', 'Y')
1526
1532#define VIDEO_PIX_FMT_UYVY VIDEO_FOURCC('U', 'Y', 'V', 'Y')
1533
1541#define VIDEO_PIX_FMT_XYUV32 VIDEO_FOURCC('X', 'Y', 'U', 'V')
1542
1568#define VIDEO_PIX_FMT_NV12 VIDEO_FOURCC('N', 'V', '1', '2')
1569
1592#define VIDEO_PIX_FMT_NV21 VIDEO_FOURCC('N', 'V', '2', '1')
1593
1618#define VIDEO_PIX_FMT_NV16 VIDEO_FOURCC('N', 'V', '1', '6')
1619
1645#define VIDEO_PIX_FMT_NV61 VIDEO_FOURCC('N', 'V', '6', '1')
1646
1671#define VIDEO_PIX_FMT_NV24 VIDEO_FOURCC('N', 'V', '2', '4')
1672
1697#define VIDEO_PIX_FMT_NV42 VIDEO_FOURCC('N', 'V', '4', '2')
1698
1726#define VIDEO_PIX_FMT_YUV420 VIDEO_FOURCC('Y', 'U', '1', '2')
1727
1755#define VIDEO_PIX_FMT_YVU420 VIDEO_FOURCC('Y', 'V', '1', '2')
1756
1769#define VIDEO_PIX_FMT_JPEG VIDEO_FOURCC('J', 'P', 'E', 'G')
1770
1783static inline unsigned int video_bits_per_pixel(uint32_t pixfmt)
1784{
1785 switch (pixfmt) {
1790 case VIDEO_PIX_FMT_GREY:
1791 return 8;
1796 case VIDEO_PIX_FMT_Y10P:
1797 return 10;
1802 case VIDEO_PIX_FMT_Y12P:
1803 case VIDEO_PIX_FMT_NV12:
1804 case VIDEO_PIX_FMT_NV21:
1807 return 12;
1812 case VIDEO_PIX_FMT_Y14P:
1813 return 14;
1815 case VIDEO_PIX_FMT_YUYV:
1816 case VIDEO_PIX_FMT_YVYU:
1817 case VIDEO_PIX_FMT_UYVY:
1818 case VIDEO_PIX_FMT_VYUY:
1835 case VIDEO_PIX_FMT_Y10:
1836 case VIDEO_PIX_FMT_Y12:
1837 case VIDEO_PIX_FMT_Y14:
1838 case VIDEO_PIX_FMT_Y16:
1839 case VIDEO_PIX_FMT_NV16:
1840 case VIDEO_PIX_FMT_NV61:
1841 return 16;
1844 case VIDEO_PIX_FMT_NV24:
1845 case VIDEO_PIX_FMT_NV42:
1846 return 24;
1853 return 32;
1854 default:
1855 /* Variable number of bits per pixel or unknown format */
1856 return 0;
1857 }
1858}
1859
1876#define VIDEO_MIPI_CSI2_DT_NULL 0x10
1878#define VIDEO_MIPI_CSI2_DT_BLANKING 0x11
1880#define VIDEO_MIPI_CSI2_DT_EMBEDDED_8 0x12
1882#define VIDEO_MIPI_CSI2_DT_YUV420_8 0x18
1884#define VIDEO_MIPI_CSI2_DT_YUV420_10 0x19
1886#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_8 0x1c
1888#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_10 0x1d
1890#define VIDEO_MIPI_CSI2_DT_YUV422_8 0x1e
1892#define VIDEO_MIPI_CSI2_DT_YUV422_10 0x1f
1894#define VIDEO_MIPI_CSI2_DT_RGB444 0x20
1896#define VIDEO_MIPI_CSI2_DT_RGB555 0x21
1898#define VIDEO_MIPI_CSI2_DT_RGB565 0x22
1900#define VIDEO_MIPI_CSI2_DT_RGB666 0x23
1902#define VIDEO_MIPI_CSI2_DT_RGB888 0x24
1904#define VIDEO_MIPI_CSI2_DT_RAW6 0x28
1906#define VIDEO_MIPI_CSI2_DT_RAW7 0x29
1908#define VIDEO_MIPI_CSI2_DT_RAW8 0x2a
1910#define VIDEO_MIPI_CSI2_DT_RAW10 0x2b
1912#define VIDEO_MIPI_CSI2_DT_RAW12 0x2c
1914#define VIDEO_MIPI_CSI2_DT_RAW14 0x2d
1915
1927#define VIDEO_MIPI_CSI2_DT_USER(n) (0x30 + (n))
1928
1933#ifdef __cplusplus
1934}
1935#endif
1936
1941#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_selection_t)(const struct device *dev, struct video_selection *sel)
Get/Set video selection (crop / compose)
Definition video.h:380
video_signal_result
Video signal result.
Definition video.h:230
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:830
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:314
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:346
void video_print_ctrl(const struct video_ctrl_query *const cq)
Print all the information of a control.
int(* video_api_get_caps_t)(const struct device *dev, struct video_caps *caps)
Get capabilities of a video endpoint.
Definition video.h:364
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.
static int video_dequeue(const struct device *dev, struct video_buffer **buf, k_timeout_t timeout)
Dequeue a video buffer.
Definition video.h:594
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:322
video_frmival_type
Supported frame interval type of a video device.
Definition video.h:173
static uint64_t video_frmival_nsec(const struct video_frmival *frmival)
Compute the difference between two frame intervals.
Definition video.h:925
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:535
static int video_stream_start(const struct device *dev, enum video_buf_type type)
Start the video device function.
Definition video.h:652
int(* video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival)
Function pointer type for video_set/get_frmival()
Definition video.h:298
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:704
static int video_get_selection(const struct device *dev, struct video_selection *sel)
Get video selection (crop/compose).
Definition video.h:862
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:306
int(* video_api_ctrl_t)(const struct device *dev, uint32_t cid)
Set/Get a video control value.
Definition video.h:356
static int video_flush(const struct device *dev, bool cancel)
Flush endpoint buffers.
Definition video.h:623
static int video_stream_stop(const struct device *dev, enum video_buf_type type)
Stop the video device function.
Definition video.h:678
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:332
static int video_set_format(const struct device *dev, struct video_format *fmt)
Set video format.
Definition video.h:415
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:796
static int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
Set video frame interval.
Definition video.h:471
static int video_enqueue(const struct device *dev, struct video_buffer *buf)
Enqueue a video buffer.
Definition video.h:564
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.
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:372
video_buf_type
video_buf_type enum
Definition video.h:53
static int video_get_format(const struct device *dev, struct video_format *fmt)
Get video format.
Definition video.h:440
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:241
int(* video_api_format_t)(const struct device *dev, struct video_format *fmt)
Function pointer type for video_set/get_format()
Definition video.h:290
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:503
@ VIDEO_BUF_ABORTED
Buffer is aborted.
Definition video.h:232
@ VIDEO_BUF_DONE
Buffer is done.
Definition video.h:231
@ VIDEO_BUF_ERROR
Buffer is in error.
Definition video.h:233
@ VIDEO_FRMIVAL_TYPE_DISCRETE
discrete frame interval type
Definition video.h:175
@ VIDEO_FRMIVAL_TYPE_STEPWISE
stepwise frame interval type
Definition video.h:177
@ VIDEO_BUF_TYPE_INPUT
input buffer type
Definition video.h:55
@ VIDEO_BUF_TYPE_OUTPUT
output buffer type
Definition video.h:57
@ VIDEO_SEL_TGT_COMPOSE_BOUND
Compose bound (aka the maximum compose achievable)
Definition video.h:251
@ VIDEO_SEL_TGT_COMPOSE
Current compose setting.
Definition video.h:249
@ VIDEO_SEL_TGT_NATIVE_SIZE
Native size of the input frame.
Definition video.h:247
@ VIDEO_SEL_TGT_CROP
Current crop setting.
Definition video.h:243
@ VIDEO_SEL_TGT_CROP_BOUND
Crop bound (aka the maximum crop achievable)
Definition video.h:245
#define VIDEO_PIX_FMT_SGRBG10
Definition video.h:1203
#define VIDEO_PIX_FMT_XYUV32
The first byte is empty (X) for each pixel.
Definition video.h:1541
#define VIDEO_PIX_FMT_SGRBG12P
Definition video.h:1134
#define VIDEO_PIX_FMT_RGB24
24 bit RGB format with 8 bit per component
Definition video.h:1450
#define VIDEO_PIX_FMT_Y10
Little endian, with the 6 most significant bits set to Zero.
Definition video.h:1370
#define VIDEO_PIX_FMT_NV24
Chroma (U/V) are not subsampled.
Definition video.h:1671
#define VIDEO_PIX_FMT_SBGGR10
Definition video.h:1187
#define VIDEO_PIX_FMT_Y12
Little endian, with the 4 most significant bits set to Zero.
Definition video.h:1380
#define VIDEO_PIX_FMT_NV21
Chroma (U/V) are subsampled horizontaly and vertically.
Definition video.h:1592
#define VIDEO_PIX_FMT_SGRBG8
Definition video.h:1062
#define VIDEO_PIX_FMT_SRGGB10
Definition video.h:1211
#define VIDEO_PIX_FMT_Y12P
Definition video.h:1351
#define VIDEO_PIX_FMT_YVYU
Definition video.h:1518
#define VIDEO_PIX_FMT_NV61
Chroma (U/V) are subsampled horizontaly.
Definition video.h:1645
#define VIDEO_PIX_FMT_SRGGB12P
Definition video.h:1143
#define VIDEO_PIX_FMT_SBGGR10P
Definition video.h:1080
#define VIDEO_PIX_FMT_SBGGR14
Definition video.h:1251
#define VIDEO_PIX_FMT_SGRBG16
Definition video.h:1299
#define VIDEO_PIX_FMT_SRGGB16
Definition video.h:1307
#define VIDEO_PIX_FMT_Y10P
Definition video.h:1342
#define VIDEO_PIX_FMT_BGRA32
Definition video.h:1482
#define VIDEO_PIX_FMT_ARGB32
Definition video.h:1458
#define VIDEO_PIX_FMT_SRGGB10P
Definition video.h:1107
#define VIDEO_PIX_FMT_VYUY
Definition video.h:1525
#define VIDEO_PIX_FMT_SRGGB14P
Definition video.h:1179
#define VIDEO_PIX_FMT_SGBRG14
Definition video.h:1259
#define VIDEO_PIX_FMT_NV12
Planar formats.
Definition video.h:1568
#define VIDEO_PIX_FMT_SRGGB12
Definition video.h:1243
#define VIDEO_PIX_FMT_Y14
Little endian, with the 2 most significant bits set to Zero.
Definition video.h:1390
#define VIDEO_PIX_FMT_SGBRG16
Definition video.h:1291
#define VIDEO_PIX_FMT_SGBRG14P
Definition video.h:1161
#define VIDEO_PIX_FMT_XRGB32
The first byte is empty (X) for each pixel.
Definition video.h:1491
#define VIDEO_PIX_FMT_SGBRG10
Definition video.h:1195
#define VIDEO_PIX_FMT_RGBA32
Definition video.h:1474
#define VIDEO_PIX_FMT_YUV420
Chroma (U/V) are subsampled horizontaly and vertically.
Definition video.h:1726
#define VIDEO_PIX_FMT_YVU420
Chroma (U/V) are subsampled horizontaly and vertically.
Definition video.h:1755
#define VIDEO_PIX_FMT_SGRBG10P
Definition video.h:1098
#define VIDEO_PIX_FMT_SBGGR12
Definition video.h:1219
#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:1334
#define VIDEO_PIX_FMT_SGBRG12
Definition video.h:1227
#define VIDEO_PIX_FMT_Y16
Little endian.
Definition video.h:1400
#define VIDEO_PIX_FMT_SRGGB14
Definition video.h:1275
#define VIDEO_PIX_FMT_SGBRG8
Definition video.h:1053
#define VIDEO_PIX_FMT_SBGGR12P
Definition video.h:1116
#define VIDEO_PIX_FMT_NV16
Chroma (U/V) are subsampled horizontaly.
Definition video.h:1618
#define VIDEO_PIX_FMT_SBGGR8
Definition video.h:1044
static unsigned int video_bits_per_pixel(uint32_t pixfmt)
Get number of bits per pixel of a pixel format.
Definition video.h:1783
#define VIDEO_PIX_FMT_SRGGB8
Definition video.h:1071
#define VIDEO_PIX_FMT_SBGGR14P
Definition video.h:1152
#define VIDEO_PIX_FMT_NV42
Chroma (U/V) are not subsampled.
Definition video.h:1697
#define VIDEO_PIX_FMT_YUYV
There is either a missing channel per pixel, U or V.
Definition video.h:1511
#define VIDEO_PIX_FMT_SGBRG10P
Definition video.h:1089
#define VIDEO_PIX_FMT_Y14P
Definition video.h:1360
#define VIDEO_PIX_FMT_UYVY
Definition video.h:1532
#define VIDEO_PIX_FMT_SGRBG14P
Definition video.h:1170
#define VIDEO_PIX_FMT_SBGGR16
Definition video.h:1283
#define VIDEO_PIX_FMT_SGBRG12P
Definition video.h:1125
#define VIDEO_PIX_FMT_RGB565
5 red bits [15:11], 6 green bits [10:5], 5 blue bits [4:0].
Definition video.h:1432
#define VIDEO_PIX_FMT_SGRBG12
Definition video.h:1235
#define VIDEO_PIX_FMT_BGR24
24 bit RGB format with 8 bit per component
Definition video.h:1441
#define VIDEO_PIX_FMT_SGRBG14
Definition video.h:1267
#define VIDEO_PIX_FMT_ABGR32
Definition video.h:1466
#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:6127
Kernel timeout type.
Definition clock.h:65
Video buffer structure.
Definition video.h:143
uint32_t bytesused
number of bytes occupied by the valid data in the buffer.
Definition video.h:156
uint32_t size
size of the buffer in bytes.
Definition video.h:154
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:150
void * driver_data
Pointer to driver specific data.
Definition video.h:146
uint16_t line_offset
Line offset within frame this buffer represents, from the beginning of the frame.
Definition video.h:167
uint8_t index
index of the buffer, optionally set by the application
Definition video.h:152
uint32_t timestamp
time reference in milliseconds at which the last data byte was actually received for input endpoints ...
Definition video.h:161
Video format capabilities.
Definition video.h:111
uint8_t min_vbuf_count
minimal count of video buffers to enqueue before being able to start the stream.
Definition video.h:119
enum video_buf_type type
type of the buffer
Definition video.h:113
int16_t min_line_count
Denotes minimum line count of a video buffer that this endpoint can fill or process.
Definition video.h:128
int16_t max_line_count
Denotes maximum line count of a video buffer that this endpoint can fill or process.
Definition video.h:135
const struct video_format_cap * format_caps
list of video format capabilities (zero terminated).
Definition video.h:115
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:382
video_api_format_t set_format
Definition video.h:384
video_api_ctrl_t set_ctrl
Definition video.h:392
video_api_enqueue_t enqueue
Definition video.h:389
video_api_set_signal_t set_signal
Definition video.h:394
video_api_enum_frmival_t enum_frmival
Definition video.h:397
video_api_get_caps_t get_caps
Definition video.h:387
video_api_selection_t get_selection
Definition video.h:399
video_api_selection_t set_selection
Definition video.h:398
video_api_format_t get_format
Definition video.h:385
video_api_flush_t flush
Definition video.h:391
video_api_dequeue_t dequeue
Definition video.h:390
video_api_frmival_t get_frmival
Definition video.h:396
video_api_frmival_t set_frmival
Definition video.h:395
video_api_set_stream_t set_stream
Definition video.h:386
video_api_ctrl_t get_volatile_ctrl
Definition video.h:393
Video format capability.
Definition video.h:89
uint16_t height_step
height step size in pixels.
Definition video.h:103
uint32_t width_min
minimum supported frame width in pixels.
Definition video.h:93
uint32_t width_max
maximum supported frame width in pixels.
Definition video.h:95
uint16_t width_step
width step size in pixels.
Definition video.h:101
uint32_t height_max
maximum supported frame height in pixels.
Definition video.h:99
uint32_t height_min
minimum supported frame height in pixels.
Definition video.h:97
uint32_t pixelformat
FourCC pixel format value (Video pixel formats).
Definition video.h:91
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:211
uint32_t index
frame interval index during enumeration
Definition video.h:213
const struct video_format * format
video format for which the query is made
Definition video.h:215
enum video_frmival_type type
frame interval type the device supports
Definition video.h:217
Video frame interval stepwise structure.
Definition video.h:197
struct video_frmival min
minimum frame interval in seconds
Definition video.h:199
struct video_frmival max
maximum frame interval in seconds
Definition video.h:201
struct video_frmival step
frame interval step size in seconds
Definition video.h:203
Video frame interval structure.
Definition video.h:185
uint32_t numerator
numerator of the frame interval
Definition video.h:187
uint32_t denominator
denominator of the frame interval
Definition video.h:189
Description of a rectangle area.
Definition video.h:259
uint32_t width
width of selection rectangle
Definition video.h:265
uint32_t height
height of selection rectangle
Definition video.h:267
uint32_t top
top offset of selection rectangle
Definition video.h:263
uint32_t left
left offset of selection rectangle
Definition video.h:261
Video selection (crop / compose) structure.
Definition video.h:275
struct video_rect rect
selection target rectangle
Definition video.h:281
enum video_buf_type type
buffer type, allow to select for device having both input and output
Definition video.h:277
enum video_selection_target target
selection target enum
Definition video.h:279