Zephyr Project API 4.3.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
128
136 /* It must be kept as first field of the struct if used for @ref k_fifo APIs. */
159};
160
170
182
196
215
226
244
260
274
281typedef int (*video_api_format_t)(const struct device *dev, struct video_format *fmt);
282
289typedef int (*video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival);
290
297typedef int (*video_api_enum_frmival_t)(const struct device *dev, struct video_frmival_enum *fie);
298
305typedef int (*video_api_enqueue_t)(const struct device *dev, struct video_buffer *buf);
306
313typedef int (*video_api_dequeue_t)(const struct device *dev, struct video_buffer **buf,
314 k_timeout_t timeout);
315
323typedef int (*video_api_flush_t)(const struct device *dev, bool cancel);
324
337typedef int (*video_api_set_stream_t)(const struct device *dev, bool enable,
338 enum video_buf_type type);
339
347typedef int (*video_api_ctrl_t)(const struct device *dev, uint32_t cid);
348
355typedef int (*video_api_get_caps_t)(const struct device *dev, struct video_caps *caps);
356
364typedef int (*video_api_transform_cap_t)(const struct device *const dev,
365 const struct video_format_cap *const cap,
366 struct video_format_cap *const res_cap,
367 enum video_buf_type type, uint16_t ind);
368
375typedef int (*video_api_set_signal_t)(const struct device *dev, struct k_poll_signal *sig);
376
383typedef int (*video_api_selection_t)(const struct device *dev, struct video_selection *sel);
384
406
420static inline int video_set_format(const struct device *dev, struct video_format *fmt)
421{
422 const struct video_driver_api *api;
423
424 if (dev == NULL || fmt == NULL) {
425 return -EINVAL;
426 }
427
428 api = (const struct video_driver_api *)dev->api;
429 if (api->set_format == NULL) {
430 return -ENOSYS;
431 }
432
433 return api->set_format(dev, fmt);
434}
435
446static inline int video_get_format(const struct device *dev, struct video_format *fmt)
447{
448 const struct video_driver_api *api;
449
450 if (dev == NULL || fmt == NULL) {
451 return -EINVAL;
452 }
453
454 api = (const struct video_driver_api *)dev->api;
455 if (api->get_format == NULL) {
456 return -ENOSYS;
457 }
458
459 return api->get_format(dev, fmt);
460}
461
478static inline int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
479{
480 const struct video_driver_api *api;
481
482 if (dev == NULL || frmival == NULL) {
483 return -EINVAL;
484 }
485
486 if (frmival->numerator == 0 || frmival->denominator == 0) {
487 return -EINVAL;
488 }
489
490 api = (const struct video_driver_api *)dev->api;
491 if (api->set_frmival == NULL) {
492 return -ENOSYS;
493 }
494
495 return api->set_frmival(dev, frmival);
496}
497
511static inline int video_get_frmival(const struct device *dev, struct video_frmival *frmival)
512{
513 const struct video_driver_api *api;
514
515 if (dev == NULL || frmival == NULL) {
516 return -EINVAL;
517 }
518
519 api = (const struct video_driver_api *)dev->api;
520 if (api->get_frmival == NULL) {
521 return -ENOSYS;
522 }
523
524 return api->get_frmival(dev, frmival);
525}
526
544static inline int video_enum_frmival(const struct device *dev, struct video_frmival_enum *fie)
545{
546 const struct video_driver_api *api;
547
548 if (dev == NULL || fie == NULL || fie->format == NULL) {
549 return -EINVAL;
550 }
551
552 api = (const struct video_driver_api *)dev->api;
553 if (api->enum_frmival == NULL) {
554 return -ENOSYS;
555 }
556
557 return api->enum_frmival(dev, fie);
558}
559
573static inline int video_enqueue(const struct device *dev, struct video_buffer *buf)
574{
575 const struct video_driver_api *api = (const struct video_driver_api *)dev->api;
576
577 if (dev == NULL || buf == NULL || buf->buffer == NULL) {
578 return -EINVAL;
579 }
580
581 api = (const struct video_driver_api *)dev->api;
582 if (api->enqueue == NULL) {
583 return -ENOSYS;
584 }
585
586 return api->enqueue(dev, buf);
587}
588
603static inline int video_dequeue(const struct device *dev, struct video_buffer **buf,
604 k_timeout_t timeout)
605{
606 const struct video_driver_api *api;
607
608 if (dev == NULL || buf == NULL) {
609 return -EINVAL;
610 }
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 if (dev == NULL) {
638 return -EINVAL;
639 }
640
641 api = (const struct video_driver_api *)dev->api;
642 if (api->flush == NULL) {
643 return -ENOSYS;
644 }
645
646 return api->flush(dev, cancel);
647}
648
665static inline int video_stream_start(const struct device *dev, enum video_buf_type type)
666{
667 const struct video_driver_api *api;
668
669 if (dev == NULL) {
670 return -EINVAL;
671 }
672
673 api = (const struct video_driver_api *)dev->api;
674 if (api->set_stream == NULL) {
675 return -ENOSYS;
676 }
677
678 return api->set_stream(dev, true, type);
679}
680
694static inline int video_stream_stop(const struct device *dev, enum video_buf_type type)
695{
696 const struct video_driver_api *api;
697 int ret;
698
699 if (dev == NULL) {
700 return -EINVAL;
701 }
702
703 api = (const struct video_driver_api *)dev->api;
704 if (api->set_stream == NULL) {
705 return -ENOSYS;
706 }
707
708 ret = api->set_stream(dev, false, type);
709 video_flush(dev, true);
710
711 return ret;
712}
713
722static inline int video_get_caps(const struct device *dev, struct video_caps *caps)
723{
724 const struct video_driver_api *api;
725
726 if (dev == NULL || caps == NULL ||
727 (caps->type != VIDEO_BUF_TYPE_INPUT && caps->type != VIDEO_BUF_TYPE_OUTPUT)) {
728 return -EINVAL;
729 }
730
731 api = (const struct video_driver_api *)dev->api;
732 if (api->get_caps == NULL) {
733 return -ENOSYS;
734 }
735
736 return api->get_caps(dev, caps);
737}
738
773static inline int video_transform_cap(const struct device *const dev,
774 const struct video_format_cap *const cap,
775 struct video_format_cap *const res_cap,
776 enum video_buf_type type, uint16_t ind)
777{
778 const struct video_driver_api *api;
779
780 if (dev == NULL || cap == NULL || res_cap == NULL ||
781 (type != VIDEO_BUF_TYPE_INPUT && type != VIDEO_BUF_TYPE_OUTPUT)) {
782 return -EINVAL;
783 }
784
785 api = (const struct video_driver_api *)dev->api;
786 if (api->transform_cap == NULL) {
787 return -ENOSYS;
788 }
789
790 return api->transform_cap(dev, cap, res_cap, type, ind);
791}
792
807int video_set_ctrl(const struct device *dev, struct video_control *control);
808
823int video_get_ctrl(const struct device *dev, struct video_control *control);
824
825struct video_ctrl_query;
826
846
856void video_print_ctrl(const struct video_ctrl_query *const cq);
857
870static inline int video_set_signal(const struct device *dev, struct k_poll_signal *sig)
871{
872 const struct video_driver_api *api;
873
874 if (dev == NULL || sig == NULL) {
875 return -EINVAL;
876 }
877
878 api = (const struct video_driver_api *)dev->api;
879 if (api->set_signal == NULL) {
880 return -ENOSYS;
881 }
882
883 return api->set_signal(dev, sig);
884}
885
905static inline int video_set_selection(const struct device *dev, struct video_selection *sel)
906{
907 const struct video_driver_api *api;
908
909 if (dev == NULL || sel == NULL) {
910 return -EINVAL;
911 }
912
913 api = (const struct video_driver_api *)dev->api;
914 if (api->set_selection == NULL) {
915 return -ENOSYS;
916 }
917
918 return api->set_selection(dev, sel);
919}
920
938static inline int video_get_selection(const struct device *dev, struct video_selection *sel)
939{
940 const struct video_driver_api *api;
941
942 if (dev == NULL || sel == NULL) {
943 return -EINVAL;
944 }
945
946 api = (const struct video_driver_api *)dev->api;
947 if (api->get_selection == NULL) {
948 return -ENOSYS;
949 }
950
951 return api->get_selection(dev, sel);
952}
953
963struct video_buffer *video_buffer_aligned_alloc(size_t size, size_t align, k_timeout_t timeout);
964
974
981
992int video_format_caps_index(const struct video_format_cap *fmts, const struct video_format *fmt,
993 size_t *idx);
994
1002static inline uint64_t video_frmival_nsec(const struct video_frmival *frmival)
1003{
1004 if (frmival == NULL || frmival->denominator == 0) {
1005 return -EINVAL;
1006 }
1007
1008 return (uint64_t)NSEC_PER_SEC * frmival->numerator / frmival->denominator;
1009}
1010
1019 const struct video_frmival *desired,
1020 struct video_frmival *match);
1021
1039void video_closest_frmival(const struct device *dev, struct video_frmival_enum *match);
1040
1056int64_t video_get_csi_link_freq(const struct device *dev, uint8_t bpp, uint8_t lane_nb);
1057
1073
1093int video_set_compose_format(const struct device *dev, struct video_format *fmt);
1094
1109int video_transfer_buffer(const struct device *src, const struct device *sink,
1110 enum video_buf_type src_type, enum video_buf_type sink_type,
1111 k_timeout_t timeout);
1112
1120
1124#define VIDEO_FOURCC(a, b, c, d) \
1125 ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
1126
1136#define VIDEO_FOURCC_FROM_STR(str) VIDEO_FOURCC((str)[0], (str)[1], (str)[2], (str)[3])
1137
1147#define VIDEO_FOURCC_TO_STR(fourcc) \
1148 ((char[]){ \
1149 (char)((fourcc) & 0xFF), \
1150 (char)(((fourcc) >> 8) & 0xFF), \
1151 (char)(((fourcc) >> 16) & 0xFF), \
1152 (char)(((fourcc) >> 24) & 0xFF), \
1153 '\0' \
1154 })
1155
1169
1177#define VIDEO_PIX_FMT_SBGGR8 VIDEO_FOURCC('B', 'A', '8', '1')
1178
1186#define VIDEO_PIX_FMT_SGBRG8 VIDEO_FOURCC('G', 'B', 'R', 'G')
1187
1195#define VIDEO_PIX_FMT_SGRBG8 VIDEO_FOURCC('G', 'R', 'B', 'G')
1196
1204#define VIDEO_PIX_FMT_SRGGB8 VIDEO_FOURCC('R', 'G', 'G', 'B')
1205
1213#define VIDEO_PIX_FMT_SBGGR10P VIDEO_FOURCC('p', 'B', 'A', 'A')
1214
1222#define VIDEO_PIX_FMT_SGBRG10P VIDEO_FOURCC('p', 'G', 'A', 'A')
1223
1231#define VIDEO_PIX_FMT_SGRBG10P VIDEO_FOURCC('p', 'g', 'A', 'A')
1232
1240#define VIDEO_PIX_FMT_SRGGB10P VIDEO_FOURCC('p', 'R', 'A', 'A')
1241
1249#define VIDEO_PIX_FMT_SBGGR12P VIDEO_FOURCC('p', 'B', 'C', 'C')
1250
1258#define VIDEO_PIX_FMT_SGBRG12P VIDEO_FOURCC('p', 'G', 'C', 'C')
1259
1267#define VIDEO_PIX_FMT_SGRBG12P VIDEO_FOURCC('p', 'g', 'C', 'C')
1268
1276#define VIDEO_PIX_FMT_SRGGB12P VIDEO_FOURCC('p', 'R', 'C', 'C')
1277
1285#define VIDEO_PIX_FMT_SBGGR14P VIDEO_FOURCC('p', 'B', 'E', 'E')
1286
1294#define VIDEO_PIX_FMT_SGBRG14P VIDEO_FOURCC('p', 'G', 'E', 'E')
1295
1303#define VIDEO_PIX_FMT_SGRBG14P VIDEO_FOURCC('p', 'g', 'E', 'E')
1304
1312#define VIDEO_PIX_FMT_SRGGB14P VIDEO_FOURCC('p', 'R', 'E', 'E')
1313
1320#define VIDEO_PIX_FMT_SBGGR10 VIDEO_FOURCC('B', 'G', '1', '0')
1321
1328#define VIDEO_PIX_FMT_SGBRG10 VIDEO_FOURCC('G', 'B', '1', '0')
1329
1336#define VIDEO_PIX_FMT_SGRBG10 VIDEO_FOURCC('B', 'A', '1', '0')
1337
1344#define VIDEO_PIX_FMT_SRGGB10 VIDEO_FOURCC('R', 'G', '1', '0')
1345
1352#define VIDEO_PIX_FMT_SBGGR12 VIDEO_FOURCC('B', 'G', '1', '2')
1353
1360#define VIDEO_PIX_FMT_SGBRG12 VIDEO_FOURCC('G', 'B', '1', '2')
1361
1368#define VIDEO_PIX_FMT_SGRBG12 VIDEO_FOURCC('B', 'A', '1', '2')
1369
1376#define VIDEO_PIX_FMT_SRGGB12 VIDEO_FOURCC('R', 'G', '1', '2')
1377
1384#define VIDEO_PIX_FMT_SBGGR14 VIDEO_FOURCC('B', 'G', '1', '4')
1385
1392#define VIDEO_PIX_FMT_SGBRG14 VIDEO_FOURCC('G', 'B', '1', '4')
1393
1400#define VIDEO_PIX_FMT_SGRBG14 VIDEO_FOURCC('G', 'R', '1', '4')
1401
1408#define VIDEO_PIX_FMT_SRGGB14 VIDEO_FOURCC('R', 'G', '1', '4')
1409
1416#define VIDEO_PIX_FMT_SBGGR16 VIDEO_FOURCC('B', 'Y', 'R', '2')
1417
1424#define VIDEO_PIX_FMT_SGBRG16 VIDEO_FOURCC('G', 'B', '1', '6')
1425
1432#define VIDEO_PIX_FMT_SGRBG16 VIDEO_FOURCC('G', 'R', '1', '6')
1433
1440#define VIDEO_PIX_FMT_SRGGB16 VIDEO_FOURCC('R', 'G', '1', '6')
1441
1445
1457
1467#define VIDEO_PIX_FMT_GREY VIDEO_FOURCC('G', 'R', 'E', 'Y')
1468
1469
1476#define VIDEO_PIX_FMT_Y4 VIDEO_FOURCC('Y', '0', '4', ' ')
1477
1484#define VIDEO_PIX_FMT_Y10P VIDEO_FOURCC('Y', '1', '0', 'P')
1485
1493#define VIDEO_PIX_FMT_Y12P VIDEO_FOURCC('Y', '1', '2', 'P')
1494
1502#define VIDEO_PIX_FMT_Y14P VIDEO_FOURCC('Y', '1', '4', 'P')
1503
1512#define VIDEO_PIX_FMT_Y10 VIDEO_FOURCC('Y', '1', '0', ' ')
1513
1522#define VIDEO_PIX_FMT_Y12 VIDEO_FOURCC('Y', '1', '2', ' ')
1523
1532#define VIDEO_PIX_FMT_Y14 VIDEO_FOURCC('Y', '1', '4', ' ')
1533
1542#define VIDEO_PIX_FMT_Y16 VIDEO_FOURCC('Y', '1', '6', ' ')
1543
1547
1553
1563#define VIDEO_PIX_FMT_RGB565X VIDEO_FOURCC('R', 'G', 'B', 'R')
1564
1574#define VIDEO_PIX_FMT_RGB565 VIDEO_FOURCC('R', 'G', 'B', 'P')
1575
1583#define VIDEO_PIX_FMT_BGR24 VIDEO_FOURCC('B', 'G', 'R', '3')
1584
1592#define VIDEO_PIX_FMT_RGB24 VIDEO_FOURCC('R', 'G', 'B', '3')
1593
1599
1600#define VIDEO_PIX_FMT_ARGB32 VIDEO_FOURCC('B', 'A', '2', '4')
1601
1607
1608#define VIDEO_PIX_FMT_ABGR32 VIDEO_FOURCC('A', 'R', '2', '4')
1609
1615
1616#define VIDEO_PIX_FMT_RGBA32 VIDEO_FOURCC('A', 'B', '2', '4')
1617
1623
1624#define VIDEO_PIX_FMT_BGRA32 VIDEO_FOURCC('R', 'A', '2', '4')
1625
1633#define VIDEO_PIX_FMT_XRGB32 VIDEO_FOURCC('B', 'X', '2', '4')
1634
1638
1644
1653#define VIDEO_PIX_FMT_YUYV VIDEO_FOURCC('Y', 'U', 'Y', 'V')
1654
1660#define VIDEO_PIX_FMT_YVYU VIDEO_FOURCC('Y', 'V', 'Y', 'U')
1661
1667#define VIDEO_PIX_FMT_VYUY VIDEO_FOURCC('V', 'Y', 'U', 'Y')
1668
1674#define VIDEO_PIX_FMT_UYVY VIDEO_FOURCC('U', 'Y', 'V', 'Y')
1675
1683#define VIDEO_PIX_FMT_XYUV32 VIDEO_FOURCC('X', 'Y', 'U', 'V')
1684
1692#define VIDEO_PIX_FMT_YUV24 VIDEO_FOURCC('Y', 'U', 'V', '3')
1693
1719#define VIDEO_PIX_FMT_NV12 VIDEO_FOURCC('N', 'V', '1', '2')
1720
1743#define VIDEO_PIX_FMT_NV21 VIDEO_FOURCC('N', 'V', '2', '1')
1744
1769#define VIDEO_PIX_FMT_NV16 VIDEO_FOURCC('N', 'V', '1', '6')
1770
1795
1796#define VIDEO_PIX_FMT_NV61 VIDEO_FOURCC('N', 'V', '6', '1')
1797
1822#define VIDEO_PIX_FMT_NV24 VIDEO_FOURCC('N', 'V', '2', '4')
1823
1848#define VIDEO_PIX_FMT_NV42 VIDEO_FOURCC('N', 'V', '4', '2')
1849
1877#define VIDEO_PIX_FMT_YUV420 VIDEO_FOURCC('Y', 'U', '1', '2')
1878
1906#define VIDEO_PIX_FMT_YVU420 VIDEO_FOURCC('Y', 'V', '1', '2')
1907
1911
1916
1920#define VIDEO_PIX_FMT_JPEG VIDEO_FOURCC('J', 'P', 'E', 'G')
1921
1925#define VIDEO_PIX_FMT_H264 VIDEO_FOURCC('H', '2', '6', '4')
1926
1930#define VIDEO_PIX_FMT_H264_NO_SC VIDEO_FOURCC('A', 'V', 'C', '1')
1931
1935#define VIDEO_PIX_FMT_PNG VIDEO_FOURCC('P', 'N', 'G', ' ')
1936
1940
1949static inline unsigned int video_bits_per_pixel(uint32_t pixfmt)
1950{
1951 switch (pixfmt) {
1956 case VIDEO_PIX_FMT_GREY:
1957 return 8;
1962 case VIDEO_PIX_FMT_Y10P:
1963 return 10;
1968 case VIDEO_PIX_FMT_Y12P:
1969 case VIDEO_PIX_FMT_NV12:
1970 case VIDEO_PIX_FMT_NV21:
1973 return 12;
1978 case VIDEO_PIX_FMT_Y14P:
1979 return 14;
1981 case VIDEO_PIX_FMT_YUYV:
1982 case VIDEO_PIX_FMT_YVYU:
1983 case VIDEO_PIX_FMT_UYVY:
1984 case VIDEO_PIX_FMT_VYUY:
2001 case VIDEO_PIX_FMT_Y10:
2002 case VIDEO_PIX_FMT_Y12:
2003 case VIDEO_PIX_FMT_Y14:
2004 case VIDEO_PIX_FMT_Y16:
2005 case VIDEO_PIX_FMT_NV16:
2006 case VIDEO_PIX_FMT_NV61:
2007 case VIDEO_PIX_FMT_Y4:
2008 return 16;
2011 case VIDEO_PIX_FMT_NV24:
2012 case VIDEO_PIX_FMT_NV42:
2014 return 24;
2021 return 32;
2022 default:
2023 /* Variable number of bits per pixel or unknown format */
2024 return 0;
2025 }
2026}
2027
2031
2042
2044#define VIDEO_MIPI_CSI2_DT_NULL 0x10
2046#define VIDEO_MIPI_CSI2_DT_BLANKING 0x11
2048#define VIDEO_MIPI_CSI2_DT_EMBEDDED_8 0x12
2050#define VIDEO_MIPI_CSI2_DT_YUV420_8 0x18
2052#define VIDEO_MIPI_CSI2_DT_YUV420_10 0x19
2054#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_8 0x1c
2056#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_10 0x1d
2058#define VIDEO_MIPI_CSI2_DT_YUV422_8 0x1e
2060#define VIDEO_MIPI_CSI2_DT_YUV422_10 0x1f
2062#define VIDEO_MIPI_CSI2_DT_RGB444 0x20
2064#define VIDEO_MIPI_CSI2_DT_RGB555 0x21
2066#define VIDEO_MIPI_CSI2_DT_RGB565 0x22
2068#define VIDEO_MIPI_CSI2_DT_RGB666 0x23
2070#define VIDEO_MIPI_CSI2_DT_RGB888 0x24
2072#define VIDEO_MIPI_CSI2_DT_RAW6 0x28
2074#define VIDEO_MIPI_CSI2_DT_RAW7 0x29
2076#define VIDEO_MIPI_CSI2_DT_RAW8 0x2a
2078#define VIDEO_MIPI_CSI2_DT_RAW10 0x2b
2080#define VIDEO_MIPI_CSI2_DT_RAW12 0x2c
2082#define VIDEO_MIPI_CSI2_DT_RAW14 0x2d
2083
2095#define VIDEO_MIPI_CSI2_DT_USER(n) (0x30 + (n))
2096
2100
2101#ifdef __cplusplus
2102}
2103#endif
2104
2108
2109#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:297
int(* video_api_get_caps_t)(const struct device *dev, struct video_caps *caps)
Get capabilities of a video endpoint.
Definition video.h:355
int(* video_api_transform_cap_t)(const struct device *const dev, const struct video_format_cap *const cap, struct video_format_cap *const res_cap, enum video_buf_type type, uint16_t ind)
Function pointer type for transforming a video_format_cap from one end to the other end of a m2m vide...
Definition video.h:364
video_signal_result
Video signal result.
Definition video.h:221
static int video_transform_cap(const struct device *const dev, const struct video_format_cap *const cap, struct video_format_cap *const res_cap, enum video_buf_type type, uint16_t ind)
Transform a video format capability from one end to the other end of a m2m video device.
Definition video.h:773
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:905
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:313
static int video_dequeue(const struct device *dev, struct video_buffer **buf, k_timeout_t timeout)
Dequeue a video buffer.
Definition video.h:603
int video_transfer_buffer(const struct device *src, const struct device *sink, enum video_buf_type src_type, enum video_buf_type sink_type, k_timeout_t timeout)
Transfer a buffer between 2 video device.
int(* video_api_ctrl_t)(const struct device *dev, uint32_t cid)
Set/Get a video control value.
Definition video.h:347
video_frmival_type
Supported frame interval type of a video device.
Definition video.h:164
static uint64_t video_frmival_nsec(const struct video_frmival *frmival)
Compute the difference between two frame intervals.
Definition video.h:1002
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:544
static int video_stream_start(const struct device *dev, enum video_buf_type type)
Start the video device function.
Definition video.h:665
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:722
static int video_get_selection(const struct device *dev, struct video_selection *sel)
Get video selection (crop/compose).
Definition video.h:938
int(* video_api_format_t)(const struct device *dev, struct video_format *fmt)
Function pointer type for video_set/get_format()
Definition video.h:281
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:323
int video_set_compose_format(const struct device *dev, struct video_format *fmt)
Set compose rectangle (if applicable) prior to setting format.
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:694
int(* video_api_selection_t)(const struct device *dev, struct video_selection *sel)
Get/Set video selection (crop / compose)
Definition video.h:383
static int video_set_format(const struct device *dev, struct video_format *fmt)
Set video format.
Definition video.h:420
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:870
static int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
Set video frame interval.
Definition video.h:478
static int video_enqueue(const struct device *dev, struct video_buffer *buf)
Enqueue a video buffer.
Definition video.h:573
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:337
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:446
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:375
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:232
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:305
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:511
int(* video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival)
Function pointer type for video_set/get_frmival()
Definition video.h:289
@ VIDEO_BUF_ABORTED
Buffer is aborted.
Definition video.h:223
@ VIDEO_BUF_DONE
Buffer is done.
Definition video.h:222
@ VIDEO_BUF_ERROR
Buffer is in error.
Definition video.h:224
@ VIDEO_FRMIVAL_TYPE_DISCRETE
discrete frame interval type
Definition video.h:166
@ VIDEO_FRMIVAL_TYPE_STEPWISE
stepwise frame interval type
Definition video.h:168
@ 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:242
@ VIDEO_SEL_TGT_COMPOSE
Current compose setting.
Definition video.h:240
@ VIDEO_SEL_TGT_NATIVE_SIZE
Native size of the input frame.
Definition video.h:238
@ VIDEO_SEL_TGT_CROP
Current crop setting.
Definition video.h:234
@ VIDEO_SEL_TGT_CROP_BOUND
Crop bound (aka the maximum crop achievable)
Definition video.h:236
#define VIDEO_PIX_FMT_SGRBG10
Definition video.h:1336
#define VIDEO_PIX_FMT_XYUV32
The first byte is empty (X) for each pixel.
Definition video.h:1683
#define VIDEO_PIX_FMT_SGRBG12P
Definition video.h:1267
#define VIDEO_PIX_FMT_RGB24
24 bit RGB format with 8 bit per component
Definition video.h:1592
#define VIDEO_PIX_FMT_Y10
Little endian, with the 6 most significant bits set to Zero.
Definition video.h:1512
#define VIDEO_PIX_FMT_NV24
Chroma (U/V) are not subsampled.
Definition video.h:1822
#define VIDEO_PIX_FMT_SBGGR10
Definition video.h:1320
#define VIDEO_PIX_FMT_Y12
Little endian, with the 4 most significant bits set to Zero.
Definition video.h:1522
#define VIDEO_PIX_FMT_NV21
Chroma (U/V) are subsampled horizontaly and vertically.
Definition video.h:1743
#define VIDEO_PIX_FMT_SGRBG8
Definition video.h:1195
#define VIDEO_PIX_FMT_SRGGB10
Definition video.h:1344
#define VIDEO_PIX_FMT_Y12P
Definition video.h:1493
#define VIDEO_PIX_FMT_YVYU
Definition video.h:1660
#define VIDEO_PIX_FMT_NV61
Chroma (U/V) are subsampled horizontaly.
Definition video.h:1796
#define VIDEO_PIX_FMT_SRGGB12P
Definition video.h:1276
#define VIDEO_PIX_FMT_SBGGR10P
Definition video.h:1213
#define VIDEO_PIX_FMT_SBGGR14
Definition video.h:1384
#define VIDEO_PIX_FMT_SGRBG16
Definition video.h:1432
#define VIDEO_PIX_FMT_Y4
Definition video.h:1476
#define VIDEO_PIX_FMT_SRGGB16
Definition video.h:1440
#define VIDEO_PIX_FMT_Y10P
Definition video.h:1484
#define VIDEO_PIX_FMT_BGRA32
Definition video.h:1624
#define VIDEO_PIX_FMT_ARGB32
Definition video.h:1600
#define VIDEO_PIX_FMT_SRGGB10P
Definition video.h:1240
#define VIDEO_PIX_FMT_VYUY
Definition video.h:1667
#define VIDEO_PIX_FMT_SRGGB14P
Definition video.h:1312
#define VIDEO_PIX_FMT_SGBRG14
Definition video.h:1392
#define VIDEO_PIX_FMT_NV12
Planar formats.
Definition video.h:1719
#define VIDEO_PIX_FMT_SRGGB12
Definition video.h:1376
#define VIDEO_PIX_FMT_Y14
Little endian, with the 2 most significant bits set to Zero.
Definition video.h:1532
#define VIDEO_PIX_FMT_SGBRG16
Definition video.h:1424
#define VIDEO_PIX_FMT_SGBRG14P
Definition video.h:1294
#define VIDEO_PIX_FMT_XRGB32
The first byte is empty (X) for each pixel.
Definition video.h:1633
#define VIDEO_PIX_FMT_SGBRG10
Definition video.h:1328
#define VIDEO_PIX_FMT_RGBA32
Definition video.h:1616
#define VIDEO_PIX_FMT_YUV420
Chroma (U/V) are subsampled horizontaly and vertically.
Definition video.h:1877
#define VIDEO_PIX_FMT_YVU420
Chroma (U/V) are subsampled horizontaly and vertically.
Definition video.h:1906
#define VIDEO_PIX_FMT_SGRBG10P
Definition video.h:1231
#define VIDEO_PIX_FMT_SBGGR12
Definition video.h:1352
#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:1467
#define VIDEO_PIX_FMT_SGBRG12
Definition video.h:1360
#define VIDEO_PIX_FMT_Y16
Little endian.
Definition video.h:1542
#define VIDEO_PIX_FMT_SRGGB14
Definition video.h:1408
#define VIDEO_PIX_FMT_SGBRG8
Definition video.h:1186
#define VIDEO_PIX_FMT_SBGGR12P
Definition video.h:1249
#define VIDEO_PIX_FMT_NV16
Chroma (U/V) are subsampled horizontaly.
Definition video.h:1769
#define VIDEO_PIX_FMT_SBGGR8
Definition video.h:1177
#define VIDEO_PIX_FMT_YUV24
24 bit YUV format with 8 bit per component
Definition video.h:1692
static unsigned int video_bits_per_pixel(uint32_t pixfmt)
Get number of bits per pixel of a pixel format.
Definition video.h:1949
#define VIDEO_PIX_FMT_SRGGB8
Definition video.h:1204
#define VIDEO_PIX_FMT_SBGGR14P
Definition video.h:1285
#define VIDEO_PIX_FMT_NV42
Chroma (U/V) are not subsampled.
Definition video.h:1848
#define VIDEO_PIX_FMT_YUYV
There is either a missing channel per pixel, U or V.
Definition video.h:1653
#define VIDEO_PIX_FMT_SGBRG10P
Definition video.h:1222
#define VIDEO_PIX_FMT_Y14P
Definition video.h:1502
#define VIDEO_PIX_FMT_UYVY
Definition video.h:1674
#define VIDEO_PIX_FMT_SGRBG14P
Definition video.h:1303
#define VIDEO_PIX_FMT_SBGGR16
Definition video.h:1416
#define VIDEO_PIX_FMT_SGBRG12P
Definition video.h:1258
#define VIDEO_PIX_FMT_RGB565
5 red bits [15:11], 6 green bits [10:5], 5 blue bits [4:0].
Definition video.h:1574
#define VIDEO_PIX_FMT_SGRBG12
Definition video.h:1368
#define VIDEO_PIX_FMT_BGR24
24 bit RGB format with 8 bit per component
Definition video.h:1583
#define VIDEO_PIX_FMT_SGRBG14
Definition video.h:1400
#define VIDEO_PIX_FMT_ABGR32
Definition video.h:1608
#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:513
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:519
Definition kernel.h:6434
Kernel timeout type.
Definition clock.h:65
Video buffer structure.
Definition video.h:134
uint32_t bytesused
number of bytes occupied by the valid data in the buffer.
Definition video.h:147
uint32_t size
size of the buffer in bytes.
Definition video.h:145
enum video_buf_type type
type of the buffer
Definition video.h:139
uint8_t * buffer
pointer to the start of the buffer.
Definition video.h:141
void * driver_data
Pointer to driver specific data.
Definition video.h:137
uint16_t line_offset
Line offset within frame this buffer represents, from the beginning of the frame.
Definition video.h:158
uint8_t index
index of the buffer, optionally set by the application
Definition video.h:143
uint32_t timestamp
time reference in milliseconds at which the last data byte was actually received for input endpoints ...
Definition video.h:152
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
size_t buf_align
requirement on the buffer alignment, in bytes
Definition video.h:126
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:445
Definition video-controls.h:492
const struct device * dev
device being queried, application needs to set this field
Definition video-controls.h:494
Definition video.h:385
video_api_transform_cap_t transform_cap
Transform capability from one end to the other end of an m2m device.
Definition video.h:404
video_api_format_t set_format
Definition video.h:387
video_api_ctrl_t set_ctrl
Definition video.h:395
video_api_enqueue_t enqueue
Definition video.h:392
video_api_set_signal_t set_signal
Definition video.h:397
video_api_enum_frmival_t enum_frmival
Definition video.h:400
video_api_get_caps_t get_caps
Definition video.h:390
video_api_selection_t get_selection
Definition video.h:402
video_api_selection_t set_selection
Definition video.h:401
video_api_format_t get_format
Definition video.h:388
video_api_flush_t flush
Definition video.h:394
video_api_dequeue_t dequeue
Definition video.h:393
video_api_frmival_t get_frmival
Definition video.h:399
video_api_frmival_t set_frmival
Definition video.h:398
video_api_set_stream_t set_stream
Definition video.h:389
video_api_ctrl_t get_volatile_ctrl
Definition video.h:396
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:202
uint32_t index
frame interval index during enumeration
Definition video.h:204
const struct video_format * format
video format for which the query is made
Definition video.h:206
struct video_frmival_stepwise stepwise
Definition video.h:212
enum video_frmival_type type
frame interval type the device supports
Definition video.h:208
struct video_frmival discrete
Definition video.h:211
Video frame interval stepwise structure.
Definition video.h:188
struct video_frmival min
minimum frame interval in seconds
Definition video.h:190
struct video_frmival max
maximum frame interval in seconds
Definition video.h:192
struct video_frmival step
frame interval step size in seconds
Definition video.h:194
Video frame interval structure.
Definition video.h:176
uint32_t numerator
numerator of the frame interval
Definition video.h:178
uint32_t denominator
denominator of the frame interval
Definition video.h:180
Description of a rectangle area.
Definition video.h:250
uint32_t width
width of selection rectangle
Definition video.h:256
uint32_t height
height of selection rectangle
Definition video.h:258
uint32_t top
top offset of selection rectangle
Definition video.h:254
uint32_t left
left offset of selection rectangle
Definition video.h:252
Video selection (crop / compose) structure.
Definition video.h:266
struct video_rect rect
selection target rectangle
Definition video.h:272
enum video_buf_type type
buffer type, allow to select for device having both input and output
Definition video.h:268
enum video_selection_target target
selection target enum
Definition video.h:270