Zephyr Project API 4.4.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
177int video_set_ctrl(const struct device *dev, struct video_control *control);
178
193int video_get_ctrl(const struct device *dev, struct video_control *control);
194
214
224void video_print_ctrl(const struct video_ctrl_query *const cq);
225
241int64_t video_get_csi_link_freq(const struct device *dev, uint8_t bpp, uint8_t lane_nb);
242
246
252
269int video_stream_start(const struct device *dev, enum video_buf_type type);
270
284int video_stream_stop(const struct device *dev, enum video_buf_type type);
285
289
295
313int video_enum_frmival(const struct device *dev, struct video_frmival_enum *fie);
314
330int video_set_frmival(const struct device *dev, struct video_frmival *frmival);
331
345int video_get_frmival(const struct device *dev, struct video_frmival *frmival);
346
354static inline uint64_t video_frmival_nsec(const struct video_frmival *frmival)
355{
356 if (frmival == NULL || frmival->denominator == 0) {
357 return -EINVAL;
358 }
359
360 return (uint64_t)NSEC_PER_SEC * frmival->numerator / frmival->denominator;
361}
362
373 const struct video_frmival *desired,
374 struct video_frmival *match);
375
395int video_closest_frmival(const struct device *dev, struct video_frmival_enum *match);
396
400
406
422
442int video_set_compose_format(const struct device *dev, struct video_format *fmt);
443
457int video_set_format(const struct device *dev, struct video_format *fmt);
458
469int video_get_format(const struct device *dev, struct video_format *fmt);
470
490int video_set_selection(const struct device *dev, struct video_selection *sel);
491
509int video_get_selection(const struct device *dev, struct video_selection *sel);
510
514
520
530int video_get_caps(const struct device *dev, struct video_caps *caps);
531
564int video_transform_cap(const struct device *const dev,
565 const struct video_format_cap *const cap,
566 struct video_format_cap *const res_cap,
567 enum video_buf_type type, uint16_t ind);
568
579int video_format_caps_index(const struct video_format_cap *fmts, const struct video_format *fmt,
580 size_t *idx);
581
585
586#ifdef __cplusplus
587}
588#endif
589
593
594#endif /* ZEPHYR_INCLUDE_VIDEO_VIDEO_H */
Main header file for video controls IDs definitions.
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:354
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
#define NULL
Definition iar_missing_defs.h:20
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:513
Poll signal object.
Definition kernel.h:6798
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