summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYudhistira Erlandinata <yerlandinata@chromium.org>2024-10-29 16:07:12 +0000
committerKieran Bingham <kieran.bingham@ideasonboard.com>2024-11-28 17:46:50 +0000
commit86902b39d7cd6701139f3de3a4ef4da57f2502ed (patch)
tree20d13b012a4990a29e4c3cd4373c830fd6794227 /test
parent1197fff4821e119c5aeca017fa095f2225aed292 (diff)
libcamera: Extend u32 control type
V4L2 Controls support a wide variety of types not yet supported by the ControlValue type system. Extend the libcamera ControlValue types to support an explicit 32 bit unsigned integer type, and map that to the corresponding V4L2_CTRL_TYPE_U32 type within the v4l2_device support class. Signed-off-by: Yudhistira Erlandinata <yerlandinata@chromium.org> Co-developed-by: Harvey Yang <chenghaoyang@chromium.org> Signed-off-by: Harvey Yang <chenghaoyang@chromium.org> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'test')
-rw-r--r--test/controls/control_value.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp
index 344107fa..6ca85b73 100644
--- a/test/controls/control_value.cpp
+++ b/test/controls/control_value.cpp
@@ -110,6 +110,46 @@ protected:
}
/*
+ * Unsigned Integer32 type.
+ */
+ value.set(static_cast<uint32_t>(42));
+ if (value.isNone() || value.isArray() ||
+ value.type() != ControlTypeUnsigned32) {
+ cerr << "Control type mismatch after setting to uint32_t" << endl;
+ return TestFail;
+ }
+
+ if (value.get<uint32_t>() != 42) {
+ cerr << "Control value mismatch after setting to uint32_t" << endl;
+ return TestFail;
+ }
+
+ if (value.toString() != "42") {
+ cerr << "Control string mismatch after setting to uint32_t" << endl;
+ return TestFail;
+ }
+
+ std::array<uint32_t, 4> uint32s{ 3, 14, 15, 9 };
+ value.set(Span<uint32_t>(uint32s));
+ if (value.isNone() || !value.isArray() ||
+ value.type() != ControlTypeUnsigned32) {
+ cerr << "Control type mismatch after setting to uint32_t array" << endl;
+ return TestFail;
+ }
+
+ Span<const uint32_t> uint32sResult = value.get<Span<const uint32_t>>();
+ if (uint32s.size() != uint32sResult.size() ||
+ !std::equal(uint32s.begin(), uint32s.end(), uint32sResult.begin())) {
+ cerr << "Control value mismatch after setting to uint32_t array" << endl;
+ return TestFail;
+ }
+
+ if (value.toString() != "[ 3, 14, 15, 9 ]") {
+ cerr << "Control string mismatch after setting to uint32_t array" << endl;
+ return TestFail;
+ }
+
+ /*
* Integer32 type.
*/
value.set(0x42000000);