From patchwork Mon Jan 13 16:42:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 2635 X-Patchwork-Delegate: jacopo@jmondi.org Return-Path: Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 69CC66073E for ; Mon, 13 Jan 2020 17:40:39 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay11.mail.gandi.net (Postfix) with ESMTPSA id C508A100011; Mon, 13 Jan 2020 16:40:38 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 13 Jan 2020 17:42:42 +0100 Message-Id: <20200113164245.52535-21-jacopo@jmondi.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20200113164245.52535-1-jacopo@jmondi.org> References: <20200113164245.52535-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 20/23] DNI: test compound controls X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Jan 2020 16:40:41 -0000 Define a fictional compound control and register it in the VIMC pipeline handler. Add a test to exercize it. Do not include, just a proof of concept. The test could be included once we'll have real compound controls defined. Signed-off-by: Laurent Pinchart Signed-off-by: Jacopo Mondi --- src/libcamera/control_ids.yaml | 5 ++ src/libcamera/pipeline/vimc.cpp | 5 ++ test/controls/compound_controls.cpp | 71 +++++++++++++++++++++++++++++ test/controls/meson.build | 1 + 4 files changed, 82 insertions(+) create mode 100644 test/controls/compound_controls.cpp diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index 4befec746a59..1bdece651638 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -50,4 +50,9 @@ controls: type: int32_t description: Specify a fixed gain parameter + - CompoundControl: + type: int32_t + description: A fictional compound control + compound: true + ... diff --git a/src/libcamera/pipeline/vimc.cpp b/src/libcamera/pipeline/vimc.cpp index 2df5447177fa..2bcb9f2248e6 100644 --- a/src/libcamera/pipeline/vimc.cpp +++ b/src/libcamera/pipeline/vimc.cpp @@ -453,6 +453,11 @@ int VimcCameraData::init(MediaDevice *media) std::forward_as_tuple(range)); } + /* Register a compound control. */ + ctrls.emplace(std::piecewise_construct, + std::forward_as_tuple(&controls::CompoundControl), + std::forward_as_tuple(0, 100)); + controlInfo_ = std::move(ctrls); /* Initialize the camera properties. */ diff --git a/test/controls/compound_controls.cpp b/test/controls/compound_controls.cpp new file mode 100644 index 000000000000..96d3d9204c74 --- /dev/null +++ b/test/controls/compound_controls.cpp @@ -0,0 +1,71 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * compound_controls.cpp - CompoundControls test + */ + +#include +#include + +#include +#include +#include +#include +#include + +#include "camera_controls.h" + +#include "camera_test.h" +#include "test.h" + +using namespace std; +using namespace libcamera; + +class CompoundControlsTest : public CameraTest, public Test +{ +public: + CompoundControlsTest() + : CameraTest("VIMC Sensor B") + { + } + +protected: + int init() override + { + return status_; + } + + int run() override + { + CameraControlValidator validator(camera_.get()); + ControlList list(controls::controls, &validator); + + /* + * Span + * + * A Span can be initialized with an initializer list + * and sequentially or random accessed + */ + std::array array = { 1, 2, 3 }; + Span span{ array }; + for (uint32_t i : span) + cout << i << endl; + cout << span[0] << endl; + + /* + * Compound Controls: can be set with a span of values + */ + std::vector values = { 0, 125, 253 }; + list.set(controls::CompoundControl, Span{ values }); + Span iSpan = list.get(controls::CompoundControl); + + cout << iSpan.size() << endl; + for (uint32_t i : iSpan) + cout << i << endl; + + return TestPass; + } +}; + +TEST_REGISTER(CompoundControlsTest) diff --git a/test/controls/meson.build b/test/controls/meson.build index f0850df28c8a..f4752dcff33b 100644 --- a/test/controls/meson.build +++ b/test/controls/meson.build @@ -3,6 +3,7 @@ control_tests = [ [ 'control_list', 'control_list.cpp' ], [ 'control_range', 'control_range.cpp' ], [ 'control_value', 'control_value.cpp' ], + [ 'compound_controls', 'compound_controls.cpp'], ] foreach t : control_tests