Zephyr API Documentation 4.5.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 * SPDX-FileCopyrightText: Copyright The Zephyr Project Contributors
6 * SPDX-License-Identifier: Apache-2.0
7 */
8
14
15#ifndef ZEPHYR_INCLUDE_VIDEO_VIDEO_H
16#define ZEPHYR_INCLUDE_VIDEO_VIDEO_H
17
26
27#include <stddef.h>
28#include <stdint.h>
29
30#include <zephyr/device.h>
31#include <zephyr/kernel.h>
32#include <zephyr/types.h>
35#include <zephyr/video/types.h>
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
46
60int video_enqueue(const struct device *dev, struct video_buffer *buf);
61
76int video_dequeue(const struct device *dev, struct video_buffer **vbuf, k_timeout_t timeout);
77
87struct video_buffer *video_buffer_aligned_alloc(size_t size, size_t align, k_timeout_t timeout);
88
98
110struct video_buffer *video_import_buffer(uint8_t *mem, size_t sz);
111
120
135int video_transfer_buffer(const struct device *src, const struct device *sink,
136 enum video_buf_type src_type, enum video_buf_type sink_type,
137 k_timeout_t timeout);
138
151int video_set_signal(const struct device *dev, struct k_poll_signal *sig);
152
156
162
178int video_set_ctrl(const struct device *dev, struct video_control *control);
179
194int video_get_ctrl(const struct device *dev, struct video_control *control);
195
215
225void video_print_ctrl(const struct video_ctrl_query *const cq);
226
242int64_t video_get_csi_link_freq(const struct device *dev, uint8_t bpp, uint8_t lane_nb);
243
247
253
270int video_stream_start(const struct device *dev, enum video_buf_type type);
271
285int video_stream_stop(const struct device *dev, enum video_buf_type type);
286
290
296
314int video_enum_frmival(const struct device *dev, struct video_frmival_enum *fie);
315
331int video_set_frmival(const struct device *dev, struct video_frmival *frmival);
332
346int video_get_frmival(const struct device *dev, struct video_frmival *frmival);
347
355static inline uint64_t video_frmival_nsec(const struct video_frmival *frmival)
356{
357 if (frmival == NULL || frmival->denominator == 0) {
358 return -EINVAL;
359 }
360
361 return (uint64_t)NSEC_PER_SEC * frmival->numerator / frmival->denominator;
362}
363
376 const struct video_frmival *desired,
377 struct video_frmival *match);
378
398int video_closest_frmival(const struct device *dev, struct video_frmival_enum *match);
399
403
409
425
445int video_set_compose_format(const struct device *dev, struct video_format *fmt);
446
460int video_set_format(const struct device *dev, struct video_format *fmt);
461
472int video_get_format(const struct device *dev, struct video_format *fmt);
473
493int video_set_selection(const struct device *dev, struct video_selection *sel);
494
512int video_get_selection(const struct device *dev, struct video_selection *sel);
513
517
523
533int video_get_caps(const struct device *dev, struct video_caps *caps);
534
567int video_transform_cap(const struct device *const dev,
568 const struct video_format_cap *const cap,
569 struct video_format_cap *const res_cap,
570 enum video_buf_type type, uint16_t ind);
571
582int video_format_caps_index(const struct video_format_cap *fmts, const struct video_format *fmt,
583 size_t *idx);
584
588
589#ifdef __cplusplus
590}
591#endif
592
596
597#endif /* ZEPHYR_INCLUDE_VIDEO_VIDEO_H */
Main header file for video controls IDs definitions.
APIs and macros for the Zephyr device model.
Main header file for video format API.
#define NSEC_PER_SEC
number of nanoseconds per second
Definition clock.h:113
#define EINVAL
Invalid argument.
Definition errno.h:61
int video_enqueue(const struct device *dev, struct video_buffer *buf)
Pass a video buffer to a video device.
struct video_buffer * video_buffer_aligned_alloc(size_t size, size_t align, k_timeout_t timeout)
Allocate aligned video buffer.
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_set_signal(const struct device *dev, struct k_poll_signal *sig)
Register/Unregister k_poll signal for a video endpoint.
struct video_buffer * video_import_buffer(uint8_t *mem, size_t sz)
Import an external memory to the video buffer pool.
int video_buffer_release(struct video_buffer *buf)
Release a video buffer.
int video_dequeue(const struct device *dev, struct video_buffer **vbuf, k_timeout_t timeout)
Get a video buffer from a video device.
struct video_buffer * video_buffer_alloc(size_t size, k_timeout_t timeout)
Allocate video buffer.
int video_get_caps(const struct device *dev, struct video_caps *caps)
Get the capabilities of a video endpoint.
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.
int video_format_caps_index(const struct video_format_cap *fmts, const struct video_format *fmt, size_t *idx)
Search for a format that matches in a list of capabilities.
int video_set_ctrl(const struct device *dev, struct video_control *control)
Set the value of a control.
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_get_ctrl(const struct device *dev, struct video_control *control)
Get the current value of a control.
int video_query_ctrl(struct video_ctrl_query *cq)
Query information about a control.
int video_get_selection(const struct device *dev, struct video_selection *sel)
Get video selection (crop/compose).
int video_set_format(const struct device *dev, struct video_format *fmt)
Set video format.
int video_set_selection(const struct device *dev, struct video_selection *sel)
Set video selection (crop/compose).
int video_estimate_fmt_size(struct video_format *fmt)
Estimate the size and pitch in bytes of a video_format.
int video_get_format(const struct device *dev, struct video_format *fmt)
Get video format of a driver.
int video_set_compose_format(const struct device *dev, struct video_format *fmt)
Set compose rectangle (if applicable) prior to setting format.
int video_enum_frmival(const struct device *dev, struct video_frmival_enum *fie)
List video frame intervals.
int video_get_frmival(const struct device *dev, struct video_frmival *frmival)
Get video frame interval of a driver.
int video_set_frmival(const struct device *dev, struct video_frmival *frmival)
Set video frame interval.
static uint64_t video_frmival_nsec(const struct video_frmival *frmival)
Compute the difference between two frame intervals.
Definition video.h:355
int 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.
int 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.
int video_stream_stop(const struct device *dev, enum video_buf_type type)
Stop the video device function.
int video_stream_start(const struct device *dev, enum video_buf_type type)
Start the video device function.
video_buf_type
video_buf_type enum
Definition types.h:42
Types used by both video drivers and subsystem.
Public kernel APIs.
__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:543
Poll signal object.
Definition kernel.h:6814
Kernel timeout type.
Definition clock.h:65
Video buffer structure.
Definition types.h:66
uint32_t size
size of the buffer in bytes.
Definition types.h:79
enum video_buf_type type
type of the buffer
Definition types.h:71
Video format capabilities.
Definition types.h:157
Video control structure.
Definition types.h:206
Video control query structure.
Definition types.h:221
Video format capability.
Definition types.h:135
Video format structure.
Definition types.h:100
Video frame interval enumeration structure.
Definition types.h:341
Video frame interval stepwise structure.
Definition types.h:327
Video frame interval structure.
Definition types.h:315
uint32_t numerator
numerator of the frame interval
Definition types.h:317
uint32_t denominator
denominator of the frame interval
Definition types.h:319
Video selection (crop / compose) structure.
Definition types.h:291