Skip to content

Commit bc0ae70

Browse files
committed
video: stm32_dcmi: snapshot check returned buffer
If we had a timeout it would not check to see on next call if maybe it had completed. Signed-off-by: Kurt Eckhardt <[email protected]>
1 parent 6d0de1f commit bc0ae70

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

drivers/video/video_stm32_dcmi.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ struct video_stm32_dcmi_data {
4545
struct k_fifo fifo_in;
4646
struct k_fifo fifo_out;
4747
struct video_buffer *vbuf;
48-
bool snapshot_mode : 1;
48+
bool snapshot_mode;
4949
};
5050

5151
struct video_stm32_dcmi_config {
@@ -315,7 +315,6 @@ static int video_stm32_dcmi_enqueue(const struct device *dev, struct video_buffe
315315
{
316316
struct video_stm32_dcmi_data *data = dev->data;
317317
const uint32_t buffer_size = data->fmt.pitch * data->fmt.height;
318-
319318
if (buffer_size > vbuf->size) {
320319
return -EINVAL;
321320
}
@@ -334,11 +333,20 @@ static int video_stm32_dcmi_dequeue(const struct device *dev, struct video_buffe
334333
struct video_stm32_dcmi_data *data = dev->data;
335334

336335
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);
338337
/* See if we were already called and have an active buffer */
339338
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+
}
340348
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);
342350
if (data->vbuf == NULL) {
343351
LOG_WRN("Snapshot: No Buffers available!");
344352
return -ENOMEM;
@@ -356,7 +364,7 @@ static int video_stm32_dcmi_dequeue(const struct device *dev, struct video_buffe
356364
}
357365

358366
*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);
360368

361369
if (*vbuf == NULL) {
362370
return -EAGAIN;

0 commit comments

Comments
 (0)