Skip to content

Conversation

KurtE
Copy link
Contributor

@KurtE KurtE commented Oct 21, 2025

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

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 <kurte@rockisland.com>
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 <kurte@rockisland.com>
@KurtE
Copy link
Contributor Author

KurtE commented Oct 22, 2025

Update:

I added 2nd mode to snapshot to experiment with starting and stopping the video streams along with
the HAL start/stop.

Wondering if it might help or hurt on startup speed. That is in Snapshot mode:
HAL_DCMI_START_DMA with the DCMI_MODE_SNAPSHOT, the code is supposed to align itself to the start of
a frame before it starts to return data. Now if it is free running maybe it has to wait through almost a full
frame before it sees the start of next frame. Maybe if it is started up fresh, maybe it starts a a new frame...

Also was wondering if it might help reduce tearing when it gets an error. So far It looks like I at times it still
gets into tearing images if a DMA error happens. I think I am getting fewer of those errors in this mode,
but still at times showing split images and often takes until next error to maybe recover.

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.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants