summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-04-26 02:08:37 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-04-28 20:44:48 +0300
commit79ab0e925a782a6781d38237435fcfc29ddd2e20 (patch)
treeb6dea7352f9ce9d544c15fde6bd1727076ed927a /test
parentd4680c8ca2b5cac4f723ec869b297099000b1100 (diff)
libcamera: v4l2_device: Simplify usage of getControls()
The V4L2Device::getControls() function takes a ControlList that needs to be pre-populated with dummy entries for the controls that need to be read. This is a cumbersome API, especially when reading a single control. Make it nicer by passing the list of V4L2 controls as a vector of control IDs, and returning a ControlList. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'test')
-rw-r--r--test/v4l2_videodevice/controls.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp
index da9e0111..347af211 100644
--- a/test/v4l2_videodevice/controls.cpp
+++ b/test/v4l2_videodevice/controls.cpp
@@ -57,18 +57,20 @@ protected:
const ControlInfo &u8 = infoMap.find(VIVID_CID_U8_4D_ARRAY)->second;
/* Test getting controls. */
- ControlList ctrls(infoMap);
- ctrls.set(V4L2_CID_BRIGHTNESS, -1);
- ctrls.set(V4L2_CID_CONTRAST, -1);
- ctrls.set(V4L2_CID_SATURATION, -1);
- ctrls.set(VIVID_CID_U8_4D_ARRAY, 0);
-
- int ret = capture_->getControls(&ctrls);
- if (ret) {
+ ControlList ctrls = capture_->getControls({ V4L2_CID_BRIGHTNESS,
+ V4L2_CID_CONTRAST,
+ V4L2_CID_SATURATION,
+ VIVID_CID_U8_4D_ARRAY });
+ if (ctrls.empty()) {
cerr << "Failed to get controls" << endl;
return TestFail;
}
+ if (ctrls.infoMap() != &infoMap) {
+ cerr << "Incorrect infoMap for retrieved controls" << endl;
+ return TestFail;
+ }
+
if (ctrls.get(V4L2_CID_BRIGHTNESS).get<int32_t>() == -1 ||
ctrls.get(V4L2_CID_CONTRAST).get<int32_t>() == -1 ||
ctrls.get(V4L2_CID_SATURATION).get<int32_t>() == -1) {
@@ -97,7 +99,7 @@ protected:
std::fill(u8Values.begin(), u8Values.end(), u8.min().get<uint8_t>());
ctrls.set(VIVID_CID_U8_4D_ARRAY, Span<const uint8_t>(u8Values));
- ret = capture_->setControls(&ctrls);
+ int ret = capture_->setControls(&ctrls);
if (ret) {
cerr << "Failed to set controls" << endl;
return TestFail;