@@ -339,6 +339,31 @@ static int video_esp32_get_ctrl(const struct device *dev, unsigned int cid, void
339
339
return video_get_ctrl (cfg -> source_dev , cid , value );
340
340
}
341
341
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
+
342
367
#ifdef CONFIG_POLL
343
368
int video_esp32_set_signal (const struct device * dev , enum video_endpoint_id ep ,
344
369
struct k_poll_signal * sig )
@@ -401,7 +426,7 @@ static DEVICE_API(video, esp32_driver_api) = {
401
426
/* optional callbacks */
402
427
.enqueue = video_esp32_enqueue ,
403
428
.dequeue = video_esp32_dequeue ,
404
- .flush = NULL ,
429
+ .flush = video_esp32_flush ,
405
430
.set_ctrl = video_esp32_set_ctrl ,
406
431
.get_ctrl = video_esp32_get_ctrl ,
407
432
#ifdef CONFIG_POLL
0 commit comments