@@ -45,7 +45,7 @@ struct video_stm32_dcmi_data {
45
45
struct k_fifo fifo_in ;
46
46
struct k_fifo fifo_out ;
47
47
struct video_buffer * vbuf ;
48
- bool snapshot_mode : 1 ;
48
+ bool snapshot_mode ;
49
49
};
50
50
51
51
struct video_stm32_dcmi_config {
@@ -315,7 +315,6 @@ static int video_stm32_dcmi_enqueue(const struct device *dev, struct video_buffe
315
315
{
316
316
struct video_stm32_dcmi_data * data = dev -> data ;
317
317
const uint32_t buffer_size = data -> fmt .pitch * data -> fmt .height ;
318
-
319
318
if (buffer_size > vbuf -> size ) {
320
319
return - EINVAL ;
321
320
}
@@ -334,11 +333,20 @@ static int video_stm32_dcmi_dequeue(const struct device *dev, struct video_buffe
334
333
struct video_stm32_dcmi_data * data = dev -> data ;
335
334
336
335
if (data -> snapshot_mode ) {
337
- printk ("dequeue snapshot: %p %llu\n" , data -> vbuf , timeout .ticks );
336
+ // printk("dequeue snapshot: %p %llu\n", data->vbuf, timeout.ticks);
338
337
/* See if we were already called and have an active buffer */
339
338
if (data -> vbuf == NULL ) {
339
+ /* check first to see if we already have a buffer returned */
340
+ * vbuf = k_fifo_get (& data -> fifo_out , K_NO_WAIT );
341
+ if (* vbuf != NULL ) {
342
+ // printk("k_fifo_get returned: %p\n", *vbuf);
343
+ if (HAL_DCMI_Stop (& data -> hdcmi ) != HAL_OK ) {
344
+ LOG_WRN ("Snapshot: HAL_DCMI_Stop FAILED!" );
345
+ }
346
+ return 0 ;
347
+ }
340
348
data -> vbuf = k_fifo_get (& data -> fifo_in , K_NO_WAIT );
341
- printk ("\tcamera buf: %p\n" , data -> vbuf );
349
+ // printk("\tcamera buf: %p\n", data->vbuf);
342
350
if (data -> vbuf == NULL ) {
343
351
LOG_WRN ("Snapshot: No Buffers available!" );
344
352
return - ENOMEM ;
@@ -356,7 +364,7 @@ static int video_stm32_dcmi_dequeue(const struct device *dev, struct video_buffe
356
364
}
357
365
358
366
* vbuf = k_fifo_get (& data -> fifo_out , timeout );
359
- printk ("k_fifo_get returned: %p\n" , * vbuf );
367
+ // printk("k_fifo_get returned: %p\n", *vbuf);
360
368
361
369
if (* vbuf == NULL ) {
362
370
return - EAGAIN ;
0 commit comments