From 343978af0b491002dd198b6465d2e3a5fae4e407 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 7 Oct 2019 22:31:59 +0300 Subject: libcamera: v4l2_device: Replace V4L2ControlList with ControlList MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The V4L2Device class uses V4L2ControlList as a controls container for the getControls() and setControls() operations. Having a distinct container from ControlList will makes the IPA API more complex, as it needs to explicitly transport both types of lists. This will become even more painful when implementing serialisation and deserialisation. To simplify the IPA API and ease the implementation of serialisation and deserialisation, replace usage of V4L2ControlList with ControlList in the V4L2Device (and thus CameraSensor) API. The V4L2ControlList class becomes a thin wrapper around ControlList that slightly simplifies the creation of control lists for V4L2 controls, and may be removed in the future. Signed-off-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Niklas Söderlund Tested-by: Niklas Söderlund --- test/v4l2_videodevice/controls.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'test/v4l2_videodevice') diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp index cfd47454..e59387ab 100644 --- a/test/v4l2_videodevice/controls.cpp +++ b/test/v4l2_videodevice/controls.cpp @@ -46,10 +46,10 @@ protected: const V4L2ControlInfo &saturation = info.find(V4L2_CID_SATURATION)->second; /* Test getting controls. */ - V4L2ControlList ctrls; - ctrls.add(V4L2_CID_BRIGHTNESS); - ctrls.add(V4L2_CID_CONTRAST); - ctrls.add(V4L2_CID_SATURATION); + V4L2ControlList ctrls(info); + ctrls.set(V4L2_CID_BRIGHTNESS, -1); + ctrls.set(V4L2_CID_CONTRAST, -1); + ctrls.set(V4L2_CID_SATURATION, -1); int ret = capture_->getControls(&ctrls); if (ret) { @@ -57,10 +57,17 @@ protected: return TestFail; } + if (ctrls.get(V4L2_CID_BRIGHTNESS).get() == -1 || + ctrls.get(V4L2_CID_CONTRAST).get() == -1 || + ctrls.get(V4L2_CID_SATURATION).get() == -1) { + cerr << "Incorrect value for retrieved controls" << endl; + return TestFail; + } + /* Test setting controls. */ - ctrls[V4L2_CID_BRIGHTNESS]->value() = brightness.range().min(); - ctrls[V4L2_CID_CONTRAST]->value() = contrast.range().max(); - ctrls[V4L2_CID_SATURATION]->value() = saturation.range().min(); + ctrls.set(V4L2_CID_BRIGHTNESS, brightness.range().min()); + ctrls.set(V4L2_CID_CONTRAST, contrast.range().max()); + ctrls.set(V4L2_CID_SATURATION, saturation.range().min()); ret = capture_->setControls(&ctrls); if (ret) { @@ -69,9 +76,9 @@ protected: } /* Test setting controls outside of range. */ - ctrls[V4L2_CID_BRIGHTNESS]->value() = brightness.range().min().get() - 1; - ctrls[V4L2_CID_CONTRAST]->value() = contrast.range().max().get() + 1; - ctrls[V4L2_CID_SATURATION]->value() = saturation.range().min().get() + 1; + ctrls.set(V4L2_CID_BRIGHTNESS, brightness.range().min().get() - 1); + ctrls.set(V4L2_CID_CONTRAST, contrast.range().max().get() + 1); + ctrls.set(V4L2_CID_SATURATION, saturation.range().min().get() + 1); ret = capture_->setControls(&ctrls); if (ret) { @@ -79,9 +86,9 @@ protected: return TestFail; } - if (ctrls[V4L2_CID_BRIGHTNESS]->value() != brightness.range().min() || - ctrls[V4L2_CID_CONTRAST]->value() != brightness.range().max() || - ctrls[V4L2_CID_SATURATION]->value() != saturation.range().min().get() + 1) { + if (ctrls.get(V4L2_CID_BRIGHTNESS) != brightness.range().min() || + ctrls.get(V4L2_CID_CONTRAST) != brightness.range().max() || + ctrls.get(V4L2_CID_SATURATION) != saturation.range().min().get() + 1) { cerr << "Controls not updated when set" << endl; return TestFail; } -- cgit v1.2.1