Skip to content

Commit 44531a2

Browse files
committed
drivers: video: Drivers implement submit() instead of video_enqueue() API
Signed-off-by: Phi Bang Nguyen <phibang.nguyen@nxp.com>
1 parent 471e667 commit 44531a2

File tree

3 files changed

+10
-42
lines changed

3 files changed

+10
-42
lines changed

drivers/video/video_buffer.c

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,8 @@ RTIO_DEFINE(rtio, CONFIG_VIDEO_BUFFER_POOL_NUM_MAX, CONFIG_VIDEO_BUFFER_POOL_NUM
130130

131131
int video_enqueue(const struct device *dev, struct video_buffer *buf)
132132
{
133-
int ret;
134-
135133
__ASSERT_NO_MSG(dev != NULL);
136134

137-
const struct video_driver_api *api = (const struct video_driver_api *)dev->api;
138-
if (api->enqueue == NULL) {
139-
return -ENOSYS;
140-
}
141-
142135
if (video_buf[buf->index].type != buf->type ||
143136
video_buf[buf->index].memory != buf->memory ||
144137
video_buf[buf->index].state != VIDEO_BUF_STATE_DONE) {
@@ -153,11 +146,6 @@ int video_enqueue(const struct device *dev, struct video_buffer *buf)
153146
video_buf[buf->index].buffer = buf->buffer;
154147
}
155148

156-
ret = api->enqueue(dev, &video_buf[buf->index]);
157-
if (ret < 0) {
158-
return ret;
159-
}
160-
161149
/* RTIO submission */
162150
struct rtio_iodev *ri = video_find_iodev(dev);
163151
struct rtio_sqe *sqe = rtio_sqe_acquire(&rtio);
@@ -189,26 +177,6 @@ void video_release_buf(struct rtio_cqe *cqe)
189177
rtio_cqe_release(&rtio, cqe);
190178
}
191179

192-
struct video_buffer *video_get_buf_sqe(struct mpsc *io_q)
193-
{
194-
struct mpsc_node *node = mpsc_pop(io_q);
195-
if (node == NULL) {
196-
return NULL;
197-
}
198-
199-
struct rtio_iodev_sqe *iodev_sqe = CONTAINER_OF(node, struct rtio_iodev_sqe, q);
200-
struct rtio_sqe *sqe = &iodev_sqe->sqe;
201-
202-
if (sqe->op != RTIO_OP_RX) {
203-
LOG_ERR("Invalid operation %d of length %u for submission %p", sqe->op,
204-
sqe->rx.buf_len, (void *)iodev_sqe);
205-
rtio_iodev_sqe_err(iodev_sqe, -EINVAL);
206-
return NULL;
207-
}
208-
209-
return sqe->userdata;
210-
}
211-
212180
struct rtio_iodev_sqe *video_pop_io_q(struct mpsc *io_q)
213181
{
214182
struct mpsc_node *node;
@@ -239,6 +207,11 @@ struct rtio_iodev_sqe *video_pop_io_q(struct mpsc *io_q)
239207
static void video_iodev_submit(struct rtio_iodev_sqe *iodev_sqe)
240208
{
241209
struct video_interface *vi = iodev_sqe->sqe.iodev->data;
210+
const struct video_driver_api *api = vi->dev->api;
211+
212+
if (api->iodev_submit != NULL) {
213+
api->iodev_submit(vi->dev, iodev_sqe);
214+
}
242215

243216
mpsc_push(vi->io_q, &iodev_sqe->q);
244217
}

drivers/video/video_buffer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* Copyright 2025 NXP
3-
*
3+
* Copyright (c) 2024-2025, tinyVision.ai Inc.
4+
*
45
* SPDX-License-Identifier: Apache-2.0
56
*/
67

7-
struct video_buffer *video_get_buf_sqe(struct mpsc *io_q);
88
struct rtio_iodev_sqe *video_pop_io_q(struct mpsc *io_q);

include/zephyr/drivers/video.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -343,13 +343,8 @@ typedef int (*video_api_frmival_t)(const struct device *dev, struct video_frmiva
343343
*/
344344
typedef int (*video_api_enum_frmival_t)(const struct device *dev, struct video_frmival_enum *fie);
345345

346-
/**
347-
* @typedef video_api_enqueue_t
348-
* @brief Enqueue a buffer in the driver’s incoming queue.
349-
*
350-
* See video_enqueue() for argument descriptions.
351-
*/
352-
typedef int (*video_api_enqueue_t)(const struct device *dev, struct video_buffer *buf);
346+
typedef void (*video_api_iodev_submit_t)(const struct device *dev,
347+
struct rtio_iodev_sqe *iodev_sqe);
353348

354349
/**
355350
* @typedef video_api_flush_t
@@ -415,7 +410,6 @@ __subsystem struct video_driver_api {
415410
video_api_set_stream_t set_stream;
416411
video_api_get_caps_t get_caps;
417412
/* optional callbacks */
418-
video_api_enqueue_t enqueue;
419413
video_api_flush_t flush;
420414
video_api_ctrl_t set_ctrl;
421415
video_api_ctrl_t get_volatile_ctrl;
@@ -425,6 +419,7 @@ __subsystem struct video_driver_api {
425419
video_api_enum_frmival_t enum_frmival;
426420
video_api_selection_t set_selection;
427421
video_api_selection_t get_selection;
422+
video_api_iodev_submit_t iodev_submit;
428423
};
429424

430425
/**

0 commit comments

Comments
 (0)