@@ -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
+
...
@@ -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. */
new file mode 100644
@@ -0,0 +1,71 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * compound_controls.cpp - CompoundControls test
+ */
+
+#include <iostream>
+#include <vector>
+
+#include <libcamera/camera.h>
+#include <libcamera/camera_manager.h>
+#include <libcamera/control_ids.h>
+#include <libcamera/controls.h>
+#include <libcamera/span.h>
+
+#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<int32_t, 3> array = { 1, 2, 3 };
+ Span<int32_t> 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<int32_t> values = { 0, 125, 253 };
+ list.set(controls::CompoundControl, Span<int32_t>{ values });
+ Span<int32_t> iSpan = list.get(controls::CompoundControl);
+
+ cout << iSpan.size() << endl;
+ for (uint32_t i : iSpan)
+ cout << i << endl;
+
+ return TestPass;
+ }
+};
+
+TEST_REGISTER(CompoundControlsTest)
@@ -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