@@ -339,6 +339,36 @@ 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
+ if (data -> is_streaming ) {
349
+ video_esp32_set_stream (dev , false);
350
+ }
351
+ if (data -> active_vbuf ) {
352
+ k_fifo_put (& data -> fifo_out , data -> active_vbuf );
353
+ data -> active_vbuf = NULL ;
354
+ }
355
+ while ((vbuf = k_fifo_get (& data -> fifo_in , K_NO_WAIT )) != NULL ) {
356
+ k_fifo_put (& data -> fifo_out , vbuf );
357
+ #ifdef CONFIG_POLL
358
+ if (data -> signal_out ) {
359
+ k_poll_signal_raise (data -> signal_out , VIDEO_BUF_ABORTED );
360
+ }
361
+ #endif
362
+ }
363
+ } else {
364
+ while (!k_fifo_is_empty (& data -> fifo_in )) {
365
+ k_sleep (K_MSEC (1 ));
366
+ }
367
+ }
368
+
369
+ return 0 ;
370
+ }
371
+
342
372
#ifdef CONFIG_POLL
343
373
int video_esp32_set_signal (const struct device * dev , enum video_endpoint_id ep ,
344
374
struct k_poll_signal * sig )
@@ -401,7 +431,7 @@ static DEVICE_API(video, esp32_driver_api) = {
401
431
/* optional callbacks */
402
432
.enqueue = video_esp32_enqueue ,
403
433
.dequeue = video_esp32_dequeue ,
404
- .flush = NULL ,
434
+ .flush = video_esp32_flush ,
405
435
.set_ctrl = video_esp32_set_ctrl ,
406
436
.get_ctrl = video_esp32_get_ctrl ,
407
437
#ifdef CONFIG_POLL
0 commit comments