Skip to content

Commit eab2ff8

Browse files
author
Alain Volmat
committed
video: addition of video_transfer_buffer helper function
Addition of a helper function which takes care of dequeue from a source video device and queue into a sink video device. Signed-off-by: Alain Volmat <[email protected]>
1 parent cdb4458 commit eab2ff8

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

drivers/video/video_common.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,20 @@ int video_set_compose_format(const struct device *dev, struct video_format *fmt)
489489

490490
return video_set_format(dev, fmt);
491491
}
492+
493+
int video_transfer_buffer(const struct device *src, const struct device *sink,
494+
enum video_buf_type src_type, enum video_buf_type sink_type,
495+
k_timeout_t timeout)
496+
{
497+
struct video_buffer *buf = &(struct video_buffer){.type = src_type};
498+
int ret;
499+
500+
ret = video_dequeue(src, &buf, timeout);
501+
if (ret < 0) {
502+
return ret;
503+
}
504+
505+
buf->type = sink_type;
506+
507+
return video_enqueue(sink, buf);
508+
}

include/zephyr/drivers/video.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,24 @@ int video_estimate_fmt_size(struct video_format *fmt);
10031003
*/
10041004
int video_set_compose_format(const struct device *dev, struct video_format *fmt);
10051005

1006+
/**
1007+
* @brief Transfer a buffer between 2 video device
1008+
*
1009+
* Helper function which dequeues a buffer from a source device and enqueues it into a
1010+
* sink device, changing its buffer type between the two.
1011+
*
1012+
* @param src Video device from where buffer is dequeued (source)
1013+
* @param sink Video device into which the buffer is queued (sink)
1014+
* @param src_type Video buffer type on the source device
1015+
* @param sink_type Video buffer type on the sink device
1016+
* @param timeout Timeout to be applied on dequeue
1017+
*
1018+
* @return 0 on success, otherwise a negative errno code
1019+
*/
1020+
int video_transfer_buffer(const struct device *src, const struct device *sink,
1021+
enum video_buf_type src_type, enum video_buf_type sink_type,
1022+
k_timeout_t timeout);
1023+
10061024
/**
10071025
* @defgroup video_pixel_formats Video pixel formats
10081026
* The '|' characters separate the pixels or logical blocks, and spaces separate the bytes.

0 commit comments

Comments
 (0)