Commit graph

4 commits

Author SHA1 Message Date
Naushir Patuck
f5d3fa1254 test: delayed_controls: Rename delayed_contols.cpp to delayed_controls.cpp
There was a typo in the unit test filename. Fix this typo, no other
functional change in this commit.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-12 14:20:51 +00:00
Naushir Patuck
bc8b6f266b test: delayed_controls: Fixup tests after recent DelayedControls changes
The recent fixes applied to DelayedControls change the behavior of the
library. As such, the tests ended up failing as they relied on the old
behavior of the helper. Update the tests to account for the new behavior
and get the tests passing again.

Specifically, the following changes have been made for each test:

singleControlNoDelay():
- Add a call to reset() to initialise internal DelayedControls state
only after setting the control on the device.
- Trigger a first frame start by calling applyControls() as a pipeline
handler would.
- Test frames from 1 onwards, as we will never have a queue item at
frame 0, since the reset() handles that.

singleControlWithDelay():
- Trigger a first frame start by calling applyControls() as a pipeline
handler would.
- Test frames from 1 onwards, as we will never have a queue item at
frame 0, since the reset() handles that.

dualControlsWithDelay() and dualControlsMultiQueue():
- Trigger a first frame start by calling applyControls() as a pipeline
handler would.
- Test frames from (startOffset + 1) onwards, as we will never have a
queue item at frame startOffset.
- Use the max delay (2 in this case) to determine the expected result
value.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-12 14:12:55 +00:00
Naushir Patuck
96c0eb338e libcamera: delayed_controls: Add notion of priority write
If an exposure time change adjusts the vblanking limits, and we set both
VBLANK and EXPOSURE controls through the VIDIOC_S_EXT_CTRLS ioctl, the
latter may fail if the value is outside of the limits calculated by the
old VBLANK value. This is a limitation in V4L2 and cannot be fixed by
setting VBLANK before EXPOSURE in a single VIDIOC_S_EXT_CTRLS ioctl.

The workaround here is to have the DelayedControls object mark the
VBLANK control as "priority write", which then write VBLANK separately
from (and ahead of) any other controls. This way, the sensor driver will
update the EXPOSURE control with new limits before the new values is
presented, and will thus be seen as valid.

To support this, a new struct DelayedControls::ControlParams is used in
the constructor to provide the control delay value as well as the
priority write flag.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Tested-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Tested-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
[Kieran: Fix up trivial comments, merge conflicts]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-03-12 14:12:32 +00:00
Niklas Söderlund
5023ad293d test: delayed_controls: Add test case for DelayedControls
Add a test case for DelayedControls that exercises the setting of
controls and reading back what controls were used for a particular
frame. Also exercise corner cases such as a V4L2 device that does not
reset its sequence number to 0 at stream on and sequence number wrapping
around the uint32_t value space.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
2021-01-29 15:35:28 +01:00