-
Notifications
You must be signed in to change notification settings - Fork 8.1k
video: stm32_dcmi: Snapshot mode #98004
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
800dfe7
to
46bf294
Compare
Update: I added 2nd mode to snapshot to experiment with starting and stopping the video streams along with Wondering if it might help or hurt on startup speed. That is in Snapshot mode: Also was wondering if it might help reduce tearing when it gets an error. So far It looks like I at times it still Note: I have not yet adding the stop/start in the DMA recovery code will try that as well. Also wondering if maybe something with the DMA buffer should be cleared when error happens. |
Add the ability to run cameras in a logical snapshot mode instead of always running in video mode. In particular, the camera starts when you ask for an image to be dequeued and stops when it receives an image. There are three ways to setup to run in this mode: a) define a max of 1 buffer: CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=1 b) Tell it to do so in the overlay by giving the DCMI object the property: snapshot-mode c) At run time: I added a video control: VIDEO_CID_SNAPSHOT_MODE Which can have the values 0 - normal, 1 - snapshot As mentioned in snapshot mode, the HAL DMA is stopped after each image and restarted when the user asks for another image. I added a timeout default to 1 second, that handles the case where sometimes the HAL is silently not successful in retrieving an image. Signed-off-by: Kurt Eckhardt <[email protected]>
Experimenting with the optional snapshot_mode=2 With this it calls off to stop the video stream after each frame is returned and restarts it when you ask for a new frame. Testing to see if it helps or hurts the throughput speed. Also testing if it helps/hurts with image tearing after DMA errors. Signed-off-by: Kurt Eckhardt <[email protected]>
8ab99bc
to
8a69c9e
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mainly minor comments.
struct dma_config cfg; | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this extra empty line?
struct video_stm32_dcmi_data *data = dev->data; | ||
const struct video_stm32_dcmi_config *config = dev->config; | ||
|
||
LOG_DBG("dequeue snapshot: %p %llu\n", data->vbuf, timeout.ticks); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpipcking: \n
not neded.
Here and below.
return 0; | ||
} | ||
data->vbuf = k_fifo_get(&data->fifo_in, K_NO_WAIT); | ||
LOG_DBG("\tcamera buf: %p\n", data->vbuf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heading tab \t
expected?
*vbuf = k_fifo_get(&data->fifo_out, timeout); | ||
if (*vbuf == NULL) { | ||
uint32_t time_since_start_time = | ||
(uint32_t)(k_uptime_get_32() - data->snapshot_start_time); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add an empty line below this variable definition?
} | ||
/* verify it did not come in during this procuessing */ | ||
*vbuf = k_fifo_get(&data->fifo_out, K_NO_WAIT); | ||
if (*vbuf) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (*vbuf) { | |
if (*vbuf != NULL) { |
|
||
LOG_INF("Set Snapshot: %d\n", value); | ||
if ((CONFIG_VIDEO_BUFFER_POOL_NUM_MAX == 1) && (value == 0)) { | ||
LOG_DBG("Only one buffer so snapshot mode only"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Worth a LOG_ERR()
?
.def = data->snapshot_mode ? 1 : 0}); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove this extra empty line.
drivers/video/video_stm32_dcmi.c
Outdated
return video_init_ctrl(&ctrls->snapshot, dev, VIDEO_CID_SNAPSHOT_MODE, | ||
(struct video_ctrl_range){.min = 0, .max = 1, .step = 1, | ||
.def = data->snapshot_mode ? 1 : 0}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requires an extra indentation space char:
return video_init_ctrl(&ctrls->snapshot, dev, VIDEO_CID_SNAPSHOT_MODE, | |
(struct video_ctrl_range){.min = 0, .max = 1, .step = 1, | |
.def = data->snapshot_mode ? 1 : 0}); | |
return video_init_ctrl(&ctrls->snapshot, dev, VIDEO_CID_SNAPSHOT_MODE, | |
(struct video_ctrl_range){.min = 0, .max = 1, .step = 1, | |
.def = data->snapshot_mode ? 1 : 0}); |
drivers/video/video_stm32_dcmi.c
Outdated
data->snapshot_mode = config->snapshot_mode; | ||
if (CONFIG_VIDEO_BUFFER_POOL_NUM_MAX == 1) { | ||
LOG_DBG("Only one buffer so snapshot mode only"); | ||
data->snapshot_mode = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer
if (CONFIG_VIDEO_BUFFER_POOL_NUM_MAX == 1) {
LOG_DBG("Only one buffer so snapshot mode only");
data->snapshot_mode = true;
} else {
data->snapshot_mode = config->snapshot_mode;
}
}; | ||
|
||
|
||
#define SNAPSHOT_STOP_STREAM_MODE 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer have all macros defined before the struct's.
Could you remove the extra empty line below?
Add the ability to run cameras in a logical
snapshot mode instead of always running
in video mode. In particular, the camera
starts when you ask for an image to be dequeued
and stops when it receives an image.
There are three ways to setup to run in this mode:
a) define a max of 1 buffer:
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=1
b) Tell it to do so in the overlay by giving the DCMI object the property: snapshot-mode
c) At run time: I added a video control: VIDEO_CID_SNAPSHOT_MODE Which can have the values 0 - normal, 1 - snapshot
As mentioned in snapshot mode, the HAL DMA is stopped after each image and restarted when the user asks for another image. I added a timeout default to 1 second, that handles the case where sometimes the HAL is silently not successful in retrieving an image.
Note: This is the second half of what used to be #93797