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 --- src/libcamera/pipeline/vimc.cpp | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) (limited to 'src/libcamera/pipeline/vimc.cpp') diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index f1cfd0ed..53d00360 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -279,26 +279,24 @@ void PipelineHandlerVimc::stop(Camera *camera) int PipelineHandlerVimc::processControls(VimcCameraData *data, Request *request) { - V4L2ControlList controls; + V4L2ControlList controls(data->sensor_->controls()); for (auto it : request->controls()) { const ControlId &id = *it.first; ControlValue &value = it.second; - if (id == controls::Brightness) { - controls.add(V4L2_CID_BRIGHTNESS, value.get()); - } else if (id == controls::Contrast) { - controls.add(V4L2_CID_CONTRAST, value.get()); - } else if (id == controls::Saturation) { - controls.add(V4L2_CID_SATURATION, value.get()); - } + if (id == controls::Brightness) + controls.set(V4L2_CID_BRIGHTNESS, value); + else if (id == controls::Contrast) + controls.set(V4L2_CID_CONTRAST, value); + else if (id == controls::Saturation) + controls.set(V4L2_CID_SATURATION, value); } - for (const V4L2Control &ctrl : controls) + for (const auto &ctrl : controls) LOG(VIMC, Debug) - << "Setting control 0x" - << std::hex << std::setw(8) << ctrl.id() << std::dec - << " to " << ctrl.value().toString(); + << "Setting control " << ctrl.first->name() + << " to " << ctrl.second.toString(); int ret = data->sensor_->setControls(&controls); if (ret) { @@ -415,11 +413,10 @@ int VimcCameraData::init(MediaDevice *media) /* Initialise the supported controls. */ const V4L2ControlInfoMap &controls = sensor_->controls(); for (const auto &ctrl : controls) { - unsigned int v4l2Id = ctrl.first; const V4L2ControlInfo &info = ctrl.second; const ControlId *id; - switch (v4l2Id) { + switch (info.id().id()) { case V4L2_CID_BRIGHTNESS: id = &controls::Brightness; break; -- cgit v1.2.1