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
7/*
8 * Copyright (c) 2019 Linaro Limited.
9 * Copyright 2025 NXP
10 * Copyright (c) 2025 STMicroelectronics
11 *
12 * SPDX-License-Identifier: Apache-2.0
13 */
14#ifndef ZEPHYR_INCLUDE_VIDEO_H_
15#define ZEPHYR_INCLUDE_VIDEO_H_
16
26#include <zephyr/device.h>
27#include <stddef.h>
28#include <zephyr/kernel.h>
29
30#include <zephyr/types.h>
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/*
37 * Flag used by @ref video_caps structure to indicate endpoint operates on
38 * buffers the size of the video frame
39 */
40#define LINE_COUNT_HEIGHT (-1)
41
42struct video_control;
43
58
82
104
136
144 /* It must be kept as first field of the struct if used for @ref k_fifo APIs. */
167};
168
178
190
204
214 const struct video_format *format;
218 union {
219 struct video_frmival discrete;
220 struct video_frmival_stepwise stepwise;
221 };
222};
223
234
252
268
282
289typedef int (*video_api_format_t)(const struct device *dev, struct video_format *fmt);
290
297typedef int (*video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival);
298
305typedef int (*video_api_enum_frmival_t)(const struct device *dev, struct video_frmival_enum *fie);
306
313typedef int (*video_api_enqueue_t)(const struct device *dev, struct video_buffer *buf);
314
321typedef int (*video_api_dequeue_t)(const struct device *dev, struct video_buffer **buf,
322 k_timeout_t timeout);
323
331typedef int (*video_api_flush_t)(const struct device *dev, bool cancel);
332
345typedef int (*video_api_set_stream_t)(const struct device *dev, bool enable,
346 enum video_buf_type type);
347
355typedef int (*video_api_ctrl_t)(const struct device *dev, uint32_t cid);
356
363typedef int (*video_api_get_caps_t)(const struct device *dev, struct video_caps *caps);
364
371typedef int (*video_api_set_signal_t)(const struct device *dev, struct k_poll_signal *sig);
372
379typedef int (*video_api_selection_t)(const struct device *dev, struct video_selection *sel);
380
400
414static inline int video_set_format(const struct device *dev, struct video_format *fmt)
415{
416 const struct video_driver_api *api;
417
418 __ASSERT_NO_MSG(dev != NULL);
419 __ASSERT_NO_MSG(fmt != NULL);
420
421 api = (const struct video_driver_api *)dev->api;
422 if (api->set_format == NULL) {
423 return -ENOSYS;
424 }
425
426 return api->set_format(dev, fmt);
427}
428
439static inline int video_get_format(const struct device *dev, struct video_format *fmt)
440{
441 const struct video_driver_api *api;
442
443 __ASSERT_NO_MSG(dev != NULL);
444 __ASSERT_NO_MSG(fmt != NULL);
445
446 api = (const struct video_driver_api *)dev->api;
447 if (api->get_format == NULL) {
448 return -ENOSYS;
449 }
450
451 return api->get_format(dev, fmt);
452}
453
470static inline int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
471{
472 const struct video_driver_api *api;
473
474 __ASSERT_NO_MSG(dev != NULL);
475 __ASSERT_NO_MSG(frmival != NULL);
476
477 if (frmival->numerator == 0 || frmival->denominator == 0) {
478 return -EINVAL;
479 }
480
481 api = (const struct video_driver_api *)dev->api;
482 if (api->set_frmival == NULL) {
483 return -ENOSYS;
484 }
485
486 return api->set_frmival(dev, frmival);
487}
488
502static inline int video_get_frmival(const struct device *dev, struct video_frmival *frmival)
503{
504 const struct video_driver_api *api;
505
506 __ASSERT_NO_MSG(dev != NULL);
507 __ASSERT_NO_MSG(frmival != NULL);
508
509 api = (const struct video_driver_api *)dev->api;
510 if (api->get_frmival == NULL) {
511 return -ENOSYS;
512 }
513
514 return api->get_frmival(dev, frmival);
515}
516
534static inline int video_enum_frmival(const struct device *dev, struct video_frmival_enum *fie)
535{
536 const struct video_driver_api *api;
537
538 __ASSERT_NO_MSG(dev != NULL);
539 __ASSERT_NO_MSG(fie != NULL);
540 __ASSERT_NO_MSG(fie->format != NULL);
541
542 api = (const struct video_driver_api *)dev->api;
543 if (api->enum_frmival == NULL) {
544 return -ENOSYS;
545 }
546
547 return api->enum_frmival(dev, fie);
548}
549
563static inline int video_enqueue(const struct device *dev, struct video_buffer *buf)
564{
565 const struct video_driver_api *api = (const struct video_driver_api *)dev->api;
566
567 __ASSERT_NO_MSG(dev != NULL);
568 __ASSERT_NO_MSG(buf != NULL);
569 __ASSERT_NO_MSG(buf->buffer != NULL);
570
571 api = (const struct video_driver_api *)dev->api;
572 if (api->enqueue == NULL) {
573 return -ENOSYS;
574 }
575
576 return api->enqueue(dev, buf);
577}
578
593static inline int video_dequeue(const struct device *dev, struct video_buffer **buf,
594 k_timeout_t timeout)
595{
596 const struct video_driver_api *api;
597
598 __ASSERT_NO_MSG(dev != NULL);
599 __ASSERT_NO_MSG(buf != NULL);
600
601 api = (const struct video_driver_api *)dev->api;
602 if (api->dequeue == NULL) {
603 return -ENOSYS;
604 }
605
606 return api->dequeue(dev, buf, timeout);
607}
608
622static inline int video_flush(const struct device *dev, bool cancel)
623{
624 const struct video_driver_api *api;
625
626 __ASSERT_NO_MSG(dev != NULL);
627
628 api = (const struct video_driver_api *)dev->api;
629 if (api->flush == NULL) {
630 return -ENOSYS;
631 }
632
633 return api->flush(dev, cancel);
634}
635
651static inline int video_stream_start(const struct device *dev, enum video_buf_type type)
652{
653 const struct video_driver_api *api;
654
655 __ASSERT_NO_MSG(dev != NULL);
656
657 api = (const struct video_driver_api *)dev->api;
658 if (api->set_stream == NULL) {
659 return -ENOSYS;
660 }
661
662 return api->set_stream(dev, true, type);
663}
664
677static inline int video_stream_stop(const struct device *dev, enum video_buf_type type)
678{
679 const struct video_driver_api *api;
680 int ret;
681
682 __ASSERT_NO_MSG(dev != NULL);
683
684 api = (const struct video_driver_api *)dev->api;
685 if (api->set_stream == NULL) {
686 return -ENOSYS;
687 }
688
689 ret = api->set_stream(dev, false, type);
690 video_flush(dev, true);
691
692 return ret;
693}
694
703static inline int video_get_caps(const struct device *dev, struct video_caps *caps)
704{
705 const struct video_driver_api *api;
706
707 __ASSERT_NO_MSG(dev != NULL);
708 __ASSERT_NO_MSG(caps != NULL);
709
710 api = (const struct video_driver_api *)dev->api;
711 if (api->get_caps == NULL) {
712 return -ENOSYS;
713 }
714
715 return api->get_caps(dev, caps);
716}
717
732int video_set_ctrl(const struct device *dev, struct video_control *control);
733
748int video_get_ctrl(const struct device *dev, struct video_control *control);
749
750struct video_ctrl_query;
751
771
781void video_print_ctrl(const struct video_ctrl_query *const cq);
782
795static inline int video_set_signal(const struct device *dev, struct k_poll_signal *sig)
796{
797 const struct video_driver_api *api;
798
799 __ASSERT_NO_MSG(dev != NULL);
800 __ASSERT_NO_MSG(sig != NULL);
801
802 api = (const struct video_driver_api *)dev->api;
803 if (api->set_signal == NULL) {
804 return -ENOSYS;
805 }
806
807 return api->set_signal(dev, sig);
808}
809
829static inline int video_set_selection(const struct device *dev, struct video_selection *sel)
830{
831 const struct video_driver_api *api;
832
833 __ASSERT_NO_MSG(dev != NULL);
834 __ASSERT_NO_MSG(sel != NULL);
835
836 api = (const struct video_driver_api *)dev->api;
837 if (api->set_selection == NULL) {
838 return -ENOSYS;
839 }
840
841 return api->set_selection(dev, sel);
842}
843
861static inline int video_get_selection(const struct device *dev, struct video_selection *sel)
862{
863 const struct video_driver_api *api;
864
865 __ASSERT_NO_MSG(dev != NULL);
866 __ASSERT_NO_MSG(sel != NULL);
867
868 api = (const struct video_driver_api *)dev->api;
869 if (api->get_selection == NULL) {
870 return -ENOSYS;
871 }
872
873 return api->get_selection(dev, sel);
874}
875
885struct video_buffer *video_buffer_aligned_alloc(size_t size, size_t align, k_timeout_t timeout);
886
896
903
914int video_format_caps_index(const struct video_format_cap *fmts, const struct video_format *fmt,
915 size_t *idx);
916
924static inline uint64_t video_frmival_nsec(const struct video_frmival *frmival)
925{
926 __ASSERT_NO_MSG(frmival != NULL);
927 __ASSERT_NO_MSG(frmival->denominator != 0);
928
929 return (uint64_t)NSEC_PER_SEC * frmival->numerator / frmival->denominator;
930}
931
940 const struct video_frmival *desired,
941 struct video_frmival *match);
942
960void video_closest_frmival(const struct device *dev, struct video_frmival_enum *match);
961
977int64_t video_get_csi_link_freq(const struct device *dev, uint8_t bpp, uint8_t lane_nb);
978
990#define VIDEO_FOURCC(a, b, c, d) \
991 ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
992
1002#define VIDEO_FOURCC_FROM_STR(str) VIDEO_FOURCC((str)[0], (str)[1], (str)[2], (str)[3])
1003
1013#define VIDEO_FOURCC_TO_STR(fourcc) \
1014 ((char[]){ \
1015 (char)((fourcc) & 0xFF), \
1016 (char)(((fourcc) >> 8) & 0xFF), \
1017 (char)(((fourcc) >> 16) & 0xFF), \
1018 (char)(((fourcc) >> 24) & 0xFF), \
1019 '\0' \
1020 })
1021
1043#define VIDEO_PIX_FMT_SBGGR8 VIDEO_FOURCC('B', 'A', '8', '1')
1044
1052#define VIDEO_PIX_FMT_SGBRG8 VIDEO_FOURCC('G', 'B', 'R', 'G')
1053
1061#define VIDEO_PIX_FMT_SGRBG8 VIDEO_FOURCC('G', 'R', 'B', 'G')
1062
1070#define VIDEO_PIX_FMT_SRGGB8 VIDEO_FOURCC('R', 'G', 'G', 'B')
1071
1079#define VIDEO_PIX_FMT_SBGGR10P VIDEO_FOURCC('p', 'B', 'A', 'A')
1080
1088#define VIDEO_PIX_FMT_SGBRG10P VIDEO_FOURCC('p', 'G', 'A', 'A')
1089
1097#define VIDEO_PIX_FMT_SGRBG10P VIDEO_FOURCC('p', 'g', 'A', 'A')
1098
1106#define VIDEO_PIX_FMT_SRGGB10P VIDEO_FOURCC('p', 'R', 'A', 'A')
1107
1115#define VIDEO_PIX_FMT_SBGGR12P VIDEO_FOURCC('p', 'B', 'C', 'C')
1116
1124#define VIDEO_PIX_FMT_SGBRG12P VIDEO_FOURCC('p', 'G', 'C', 'C')
1125
1133#define VIDEO_PIX_FMT_SGRBG12P VIDEO_FOURCC('p', 'g', 'C', 'C')
1134
1142#define VIDEO_PIX_FMT_SRGGB12P VIDEO_FOURCC('p', 'R', 'C', 'C')
1143
1151#define VIDEO_PIX_FMT_SBGGR14P VIDEO_FOURCC('p', 'B', 'E', 'E')
1152
1160#define VIDEO_PIX_FMT_SGBRG14P VIDEO_FOURCC('p', 'G', 'E', 'E')
1161
1169#define VIDEO_PIX_FMT_SGRBG14P VIDEO_FOURCC('p', 'g', 'E', 'E')
1170
1178#define VIDEO_PIX_FMT_SRGGB14P VIDEO_FOURCC('p', 'R', 'E', 'E')
1179
1186#define VIDEO_PIX_FMT_SBGGR10 VIDEO_FOURCC('B', 'G', '1', '0')
1187
1194#define VIDEO_PIX_FMT_SGBRG10 VIDEO_FOURCC('G', 'B', '1', '0')
1195
1202#define VIDEO_PIX_FMT_SGRBG10 VIDEO_FOURCC('B', 'A', '1', '0')
1203
1210#define VIDEO_PIX_FMT_SRGGB10 VIDEO_FOURCC('R', 'G', '1', '0')
1211
1218#define VIDEO_PIX_FMT_SBGGR12 VIDEO_FOURCC('B', 'G', '1', '2')
1219
1226#define VIDEO_PIX_FMT_SGBRG12 VIDEO_FOURCC('G', 'B', '1', '2')
1227
1234#define VIDEO_PIX_FMT_SGRBG12 VIDEO_FOURCC('B', 'A', '1', '2')
1235
1242#define VIDEO_PIX_FMT_SRGGB12 VIDEO_FOURCC('R', 'G', '1', '2')
1243
1250#define VIDEO_PIX_FMT_SBGGR14 VIDEO_FOURCC('B', 'G', '1', '4')
1251
1258#define VIDEO_PIX_FMT_SGBRG14 VIDEO_FOURCC('G', 'B', '1', '4')
1259
1266#define VIDEO_PIX_FMT_SGRBG14 VIDEO_FOURCC('G', 'R', '1', '4')
1267
1274#define VIDEO_PIX_FMT_SRGGB14 VIDEO_FOURCC('R', 'G', '1', '4')
1275
1282#define VIDEO_PIX_FMT_SBGGR16 VIDEO_FOURCC('B', 'Y', 'R', '2')
1283
1290#define VIDEO_PIX_FMT_SGBRG16 VIDEO_FOURCC('G', 'B', '1', '6')
1291
1298#define VIDEO_PIX_FMT_SGRBG16 VIDEO_FOURCC('G', 'R', '1', '6')
1299
1306#define VIDEO_PIX_FMT_SRGGB16 VIDEO_FOURCC('R', 'G', '1', '6')
1307
1333#define VIDEO_PIX_FMT_GREY VIDEO_FOURCC('G', 'R', 'E', 'Y')
1334
1341#define VIDEO_PIX_FMT_Y10P VIDEO_FOURCC('Y', '1', '0', 'P')
1342
1350#define VIDEO_PIX_FMT_Y12P VIDEO_FOURCC('Y', '1', '2', 'P')
1351
1359#define VIDEO_PIX_FMT_Y14P VIDEO_FOURCC('Y', '1', '4', 'P')
1360
1369#define VIDEO_PIX_FMT_Y10 VIDEO_FOURCC('Y', '1', '0', ' ')
1370
1379#define VIDEO_PIX_FMT_Y12 VIDEO_FOURCC('Y', '1', '2', ' ')
1380
1389#define VIDEO_PIX_FMT_Y14 VIDEO_FOURCC('Y', '1', '4', ' ')
1390
1399#define VIDEO_PIX_FMT_Y16 VIDEO_FOURCC('Y', '1', '6', ' ')
1400
1420#define VIDEO_PIX_FMT_RGB565X VIDEO_FOURCC('R', 'G', 'B', 'R')
1421
1431#define VIDEO_PIX_FMT_RGB565 VIDEO_FOURCC('R', 'G', 'B', 'P')
1432
1440#define VIDEO_PIX_FMT_BGR24 VIDEO_FOURCC('B', 'G', 'R', '3')
1441
1449#define VIDEO_PIX_FMT_RGB24 VIDEO_FOURCC('R', 'G', 'B', '3')
1450
1457#define VIDEO_PIX_FMT_ARGB32 VIDEO_FOURCC('B', 'A', '2', '4')
1458
1465#define VIDEO_PIX_FMT_ABGR32 VIDEO_FOURCC('A', 'R', '2', '4')
1466
1473#define VIDEO_PIX_FMT_RGBA32 VIDEO_FOURCC('A', 'B', '2', '4')
1474
1481#define VIDEO_PIX_FMT_BGRA32 VIDEO_FOURCC('R', 'A', '2', '4')
1482
1490#define VIDEO_PIX_FMT_XRGB32 VIDEO_FOURCC('B', 'X', '2', '4')
1491
1510#define VIDEO_PIX_FMT_YUYV VIDEO_FOURCC('Y', 'U', 'Y', 'V')
1511
1517#define VIDEO_PIX_FMT_YVYU VIDEO_FOURCC('Y', 'V', 'Y', 'U')
1518
1524#define VIDEO_PIX_FMT_VYUY VIDEO_FOURCC('V', 'Y', 'U', 'Y')
1525
1531#define VIDEO_PIX_FMT_UYVY VIDEO_FOURCC('U', 'Y', 'V', 'Y')
1532
1540#define VIDEO_PIX_FMT_XYUV32 VIDEO_FOURCC('X', 'Y', 'U', 'V')
1541
1554#define VIDEO_PIX_FMT_JPEG VIDEO_FOURCC('J', 'P', 'E', 'G')
1555
1568static inline unsigned int video_bits_per_pixel(uint32_t pixfmt)
1569{
1570 switch (pixfmt) {
1575 case VIDEO_PIX_FMT_GREY:
1576 return 8;
1581 case VIDEO_PIX_FMT_Y10P:
1582 return 10;
1587 case VIDEO_PIX_FMT_Y12P:
1588 return 12;
1593 case VIDEO_PIX_FMT_Y14P:
1594 return 14;
1596 case VIDEO_PIX_FMT_YUYV:
1597 case VIDEO_PIX_FMT_YVYU:
1598 case VIDEO_PIX_FMT_UYVY:
1599 case VIDEO_PIX_FMT_VYUY:
1616 case VIDEO_PIX_FMT_Y10:
1617 case VIDEO_PIX_FMT_Y12:
1618 case VIDEO_PIX_FMT_Y14:
1619 case VIDEO_PIX_FMT_Y16:
1620 return 16;
1623 return 24;
1630 return 32;
1631 default:
1632 /* Variable number of bits per pixel or unknown format */
1633 return 0;
1634 }
1635}
1636
1653#define VIDEO_MIPI_CSI2_DT_NULL 0x10
1655#define VIDEO_MIPI_CSI2_DT_BLANKING 0x11
1657#define VIDEO_MIPI_CSI2_DT_EMBEDDED_8 0x12
1659#define VIDEO_MIPI_CSI2_DT_YUV420_8 0x18
1661#define VIDEO_MIPI_CSI2_DT_YUV420_10 0x19
1663#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_8 0x1c
1665#define VIDEO_MIPI_CSI2_DT_YUV420_CSPS_10 0x1d
1667#define VIDEO_MIPI_CSI2_DT_YUV422_8 0x1e
1669#define VIDEO_MIPI_CSI2_DT_YUV422_10 0x1f
1671#define VIDEO_MIPI_CSI2_DT_RGB444 0x20
1673#define VIDEO_MIPI_CSI2_DT_RGB555 0x21
1675#define VIDEO_MIPI_CSI2_DT_RGB565 0x22
1677#define VIDEO_MIPI_CSI2_DT_RGB666 0x23
1679#define VIDEO_MIPI_CSI2_DT_RGB888 0x24
1681#define VIDEO_MIPI_CSI2_DT_RAW6 0x28
1683#define VIDEO_MIPI_CSI2_DT_RAW7 0x29
1685#define VIDEO_MIPI_CSI2_DT_RAW8 0x2a
1687#define VIDEO_MIPI_CSI2_DT_RAW10 0x2b
1689#define VIDEO_MIPI_CSI2_DT_RAW12 0x2c
1691#define VIDEO_MIPI_CSI2_DT_RAW14 0x2d
1692
1704#define VIDEO_MIPI_CSI2_DT_USER(n) (0x30 + (n))
1705
1710#ifdef __cplusplus
1711}
1712#endif
1713
1718#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:379
video_signal_result
Video signal result.
Definition video.h:229
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:829
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:313
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:345
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:363
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:593
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:321
video_frmival_type
Supported frame interval type of a video device.
Definition video.h:172
static uint64_t video_frmival_nsec(const struct video_frmival *frmival)
Compute the difference between two frame intervals.
Definition video.h:924
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:534
static int video_stream_start(const struct device *dev, enum video_buf_type type)
Start the video device function.
Definition video.h:651
int(* video_api_frmival_t)(const struct device *dev, struct video_frmival *frmival)
Function pointer type for video_set/get_frmival()
Definition video.h:297
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:703
static int video_get_selection(const struct device *dev, struct video_selection *sel)
Get video selection (crop/compose).
Definition video.h:861
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:305
int(* video_api_ctrl_t)(const struct device *dev, uint32_t cid)
Set/Get a video control value.
Definition video.h:355
static int video_flush(const struct device *dev, bool cancel)
Flush endpoint buffers.
Definition video.h:622
static int video_stream_stop(const struct device *dev, enum video_buf_type type)
Stop the video device function.
Definition video.h:677
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:331
static int video_set_format(const struct device *dev, struct video_format *fmt)
Set video format.
Definition video.h:414
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:795
static int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
Set video frame interval.
Definition video.h:470
static int video_enqueue(const struct device *dev, struct video_buffer *buf)
Enqueue a video buffer.
Definition video.h:563
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:371
video_buf_type
video_buf_type enum
Definition video.h:52
static int video_get_format(const struct device *dev, struct video_format *fmt)
Get video format.
Definition video.h:439
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:240
int(* video_api_format_t)(const struct device *dev, struct video_format *fmt)
Function pointer type for video_set/get_format()
Definition video.h:289
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:502
@ VIDEO_BUF_ABORTED
Buffer is aborted.
Definition video.h:231
@ VIDEO_BUF_DONE
Buffer is done.
Definition video.h:230
@ VIDEO_BUF_ERROR
Buffer is in error.
Definition video.h:232
@ VIDEO_FRMIVAL_TYPE_DISCRETE
discrete frame interval type
Definition video.h:174
@ VIDEO_FRMIVAL_TYPE_STEPWISE
stepwise frame interval type
Definition video.h:176
@ VIDEO_BUF_TYPE_INPUT
input buffer type
Definition video.h:54
@ VIDEO_BUF_TYPE_OUTPUT
output buffer type
Definition video.h:56
@ VIDEO_SEL_TGT_COMPOSE_BOUND
Compose bound (aka the maximum compose achievable)
Definition video.h:250
@ VIDEO_SEL_TGT_COMPOSE
Current compose setting.
Definition video.h:248
@ VIDEO_SEL_TGT_NATIVE_SIZE
Native size of the input frame.
Definition video.h:246
@ VIDEO_SEL_TGT_CROP
Current crop setting.
Definition video.h:242
@ VIDEO_SEL_TGT_CROP_BOUND
Crop bound (aka the maximum crop achievable)
Definition video.h:244
#define VIDEO_PIX_FMT_SGRBG10
Definition video.h:1202
#define VIDEO_PIX_FMT_XYUV32
The first byte is empty (X) for each pixel.
Definition video.h:1540
#define VIDEO_PIX_FMT_SGRBG12P
Definition video.h:1133
#define VIDEO_PIX_FMT_RGB24
24 bit RGB format with 8 bit per component
Definition video.h:1449
#define VIDEO_PIX_FMT_Y10
Little endian, with the 6 most significant bits set to Zero.
Definition video.h:1369
#define VIDEO_PIX_FMT_SBGGR10
Definition video.h:1186
#define VIDEO_PIX_FMT_Y12
Little endian, with the 4 most significant bits set to Zero.
Definition video.h:1379
#define VIDEO_PIX_FMT_SGRBG8
Definition video.h:1061
#define VIDEO_PIX_FMT_SRGGB10
Definition video.h:1210
#define VIDEO_PIX_FMT_Y12P
Definition video.h:1350
#define VIDEO_PIX_FMT_YVYU
Definition video.h:1517
#define VIDEO_PIX_FMT_SRGGB12P
Definition video.h:1142
#define VIDEO_PIX_FMT_SBGGR10P
Definition video.h:1079
#define VIDEO_PIX_FMT_SBGGR14
Definition video.h:1250
#define VIDEO_PIX_FMT_SGRBG16
Definition video.h:1298
#define VIDEO_PIX_FMT_SRGGB16
Definition video.h:1306
#define VIDEO_PIX_FMT_Y10P
Definition video.h:1341
#define VIDEO_PIX_FMT_BGRA32
Definition video.h:1481
#define VIDEO_PIX_FMT_ARGB32
Definition video.h:1457
#define VIDEO_PIX_FMT_SRGGB10P
Definition video.h:1106
#define VIDEO_PIX_FMT_VYUY
Definition video.h:1524
#define VIDEO_PIX_FMT_SRGGB14P
Definition video.h:1178
#define VIDEO_PIX_FMT_SGBRG14
Definition video.h:1258
#define VIDEO_PIX_FMT_SRGGB12
Definition video.h:1242
#define VIDEO_PIX_FMT_Y14
Little endian, with the 2 most significant bits set to Zero.
Definition video.h:1389
#define VIDEO_PIX_FMT_SGBRG16
Definition video.h:1290
#define VIDEO_PIX_FMT_SGBRG14P
Definition video.h:1160
#define VIDEO_PIX_FMT_XRGB32
The first byte is empty (X) for each pixel.
Definition video.h:1490
#define VIDEO_PIX_FMT_SGBRG10
Definition video.h:1194
#define VIDEO_PIX_FMT_RGBA32
Definition video.h:1473
#define VIDEO_PIX_FMT_SGRBG10P
Definition video.h:1097
#define VIDEO_PIX_FMT_SBGGR12
Definition video.h:1218
#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:1333
#define VIDEO_PIX_FMT_SGBRG12
Definition video.h:1226
#define VIDEO_PIX_FMT_Y16
Little endian.
Definition video.h:1399
#define VIDEO_PIX_FMT_SRGGB14
Definition video.h:1274
#define VIDEO_PIX_FMT_SGBRG8
Definition video.h:1052
#define VIDEO_PIX_FMT_SBGGR12P
Definition video.h:1115
#define VIDEO_PIX_FMT_SBGGR8
Definition video.h:1043
static unsigned int video_bits_per_pixel(uint32_t pixfmt)
Get number of bits per pixel of a pixel format.
Definition video.h:1568
#define VIDEO_PIX_FMT_SRGGB8
Definition video.h:1070
#define VIDEO_PIX_FMT_SBGGR14P
Definition video.h:1151
#define VIDEO_PIX_FMT_YUYV
There is either a missing channel per pixel, U or V.
Definition video.h:1510
#define VIDEO_PIX_FMT_SGBRG10P
Definition video.h:1088
#define VIDEO_PIX_FMT_Y14P
Definition video.h:1359
#define VIDEO_PIX_FMT_UYVY
Definition video.h:1531
#define VIDEO_PIX_FMT_SGRBG14P
Definition video.h:1169
#define VIDEO_PIX_FMT_SBGGR16
Definition video.h:1282
#define VIDEO_PIX_FMT_SGBRG12P
Definition video.h:1124
#define VIDEO_PIX_FMT_RGB565
5 red bits [15:11], 6 green bits [10:5], 5 blue bits [4:0].
Definition video.h:1431
#define VIDEO_PIX_FMT_SGRBG12
Definition video.h:1234
#define VIDEO_PIX_FMT_BGR24
24 bit RGB format with 8 bit per component
Definition video.h:1440
#define VIDEO_PIX_FMT_SGRBG14
Definition video.h:1266
#define VIDEO_PIX_FMT_ABGR32
Definition video.h:1465
#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:6149
Kernel timeout type.
Definition clock.h:65
Video buffer structure.
Definition video.h:142
uint32_t bytesused
number of bytes occupied by the valid data in the buffer.
Definition video.h:155
uint32_t size
size of the buffer in bytes.
Definition video.h:153
enum video_buf_type type
type of the buffer
Definition video.h:147
uint8_t * buffer
pointer to the start of the buffer.
Definition video.h:149
void * driver_data
Pointer to driver specific data.
Definition video.h:145
uint16_t line_offset
Line offset within frame this buffer represents, from the beginning of the frame.
Definition video.h:166
uint8_t index
index of the buffer, optionally set by the application
Definition video.h:151
uint32_t timestamp
time reference in milliseconds at which the last data byte was actually received for input endpoints ...
Definition video.h:160
Video format capabilities.
Definition video.h:110
uint8_t min_vbuf_count
minimal count of video buffers to enqueue before being able to start the stream.
Definition video.h:118
enum video_buf_type type
type of the buffer
Definition video.h:112
int16_t min_line_count
Denotes minimum line count of a video buffer that this endpoint can fill or process.
Definition video.h:127
int16_t max_line_count
Denotes maximum line count of a video buffer that this endpoint can fill or process.
Definition video.h:134
const struct video_format_cap * format_caps
list of video format capabilities (zero terminated).
Definition video.h:114
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:381
video_api_format_t set_format
Definition video.h:383
video_api_ctrl_t set_ctrl
Definition video.h:391
video_api_enqueue_t enqueue
Definition video.h:388
video_api_set_signal_t set_signal
Definition video.h:393
video_api_enum_frmival_t enum_frmival
Definition video.h:396
video_api_get_caps_t get_caps
Definition video.h:386
video_api_selection_t get_selection
Definition video.h:398
video_api_selection_t set_selection
Definition video.h:397
video_api_format_t get_format
Definition video.h:384
video_api_flush_t flush
Definition video.h:390
video_api_dequeue_t dequeue
Definition video.h:389
video_api_frmival_t get_frmival
Definition video.h:395
video_api_frmival_t set_frmival
Definition video.h:394
video_api_set_stream_t set_stream
Definition video.h:385
video_api_ctrl_t get_volatile_ctrl
Definition video.h:392
Video format capability.
Definition video.h:88
uint16_t height_step
height step size in pixels.
Definition video.h:102
uint32_t width_min
minimum supported frame width in pixels.
Definition video.h:92
uint32_t width_max
maximum supported frame width in pixels.
Definition video.h:94
uint16_t width_step
width step size in pixels.
Definition video.h:100
uint32_t height_max
maximum supported frame height in pixels.
Definition video.h:98
uint32_t height_min
minimum supported frame height in pixels.
Definition video.h:96
uint32_t pixelformat
FourCC pixel format value (Video pixel formats).
Definition video.h:90
Video format structure.
Definition video.h:64
uint32_t height
frame height in pixels.
Definition video.h:72
enum video_buf_type type
type of the buffer
Definition video.h:66
uint32_t width
frame width in pixels.
Definition video.h:70
uint32_t pitch
line stride.
Definition video.h:80
uint32_t pixelformat
FourCC pixel format value (Video pixel formats)
Definition video.h:68
Video frame interval enumeration structure.
Definition video.h:210
uint32_t index
frame interval index during enumeration
Definition video.h:212
const struct video_format * format
video format for which the query is made
Definition video.h:214
enum video_frmival_type type
frame interval type the device supports
Definition video.h:216
Video frame interval stepwise structure.
Definition video.h:196
struct video_frmival min
minimum frame interval in seconds
Definition video.h:198
struct video_frmival max
maximum frame interval in seconds
Definition video.h:200
struct video_frmival step
frame interval step size in seconds
Definition video.h:202
Video frame interval structure.
Definition video.h:184
uint32_t numerator
numerator of the frame interval
Definition video.h:186
uint32_t denominator
denominator of the frame interval
Definition video.h:188
Description of a rectangle area.
Definition video.h:258
uint32_t width
width of selection rectangle
Definition video.h:264
uint32_t height
height of selection rectangle
Definition video.h:266
uint32_t top
top offset of selection rectangle
Definition video.h:262
uint32_t left
left offset of selection rectangle
Definition video.h:260
Video selection (crop / compose) structure.
Definition video.h:274
struct video_rect rect
selection target rectangle
Definition video.h:280
enum video_buf_type type
buffer type, allow to select for device having both input and output
Definition video.h:276
enum video_selection_target target
selection target enum
Definition video.h:278