Skip to content

Commit 5fe0497

Browse files
committed
driver: video: esp32: add video_flush() callback
Adding missing `video_flush()` callback to driver. Signed-off-by: Armin Kessler <ake@espros.com>
1 parent 7127757 commit 5fe0497

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

drivers/video/video_esp32_dvp.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,31 @@ static int video_esp32_get_ctrl(const struct device *dev, unsigned int cid, void
339339
return video_get_ctrl(cfg->source_dev, cid, value);
340340
}
341341

342+
static int video_esp32_flush(const struct device *dev, enum video_endpoint_id ep, bool cancel)
343+
{
344+
struct video_esp32_data *data = dev->data;
345+
struct video_buffer *vbuf = NULL;
346+
347+
if (cancel) {
348+
video_esp32_set_stream(dev, false);
349+
if (data->active_vbuf) {
350+
k_fifo_put(&data->fifo_out, data->active_vbuf);
351+
data->active_vbuf = NULL;
352+
}
353+
vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT);
354+
while (vbuf != NULL) {
355+
k_fifo_put(&data->fifo_out, vbuf);
356+
vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT);
357+
}
358+
} else {
359+
while (!k_fifo_is_empty(&data->fifo_in)) {
360+
k_sleep(K_MSEC(1));
361+
}
362+
}
363+
364+
return 0;
365+
}
366+
342367
#ifdef CONFIG_POLL
343368
int video_esp32_set_signal(const struct device *dev, enum video_endpoint_id ep,
344369
struct k_poll_signal *sig)
@@ -401,7 +426,7 @@ static DEVICE_API(video, esp32_driver_api) = {
401426
/* optional callbacks */
402427
.enqueue = video_esp32_enqueue,
403428
.dequeue = video_esp32_dequeue,
404-
.flush = NULL,
429+
.flush = video_esp32_flush,
405430
.set_ctrl = video_esp32_set_ctrl,
406431
.get_ctrl = video_esp32_get_ctrl,
407432
#ifdef CONFIG_POLL

0 commit comments

Comments
 (0)