From patchwork Mon Mar 9 16:24:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 3076 Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8091C62940 for ; Mon, 9 Mar 2020 17:21:32 +0100 (CET) X-Originating-IP: 93.34.114.233 Received: from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233]) (Authenticated sender: jacopo@jmondi.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 2D25E60015 for ; Mon, 9 Mar 2020 16:21:31 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 9 Mar 2020 17:24:14 +0100 Message-Id: <20200309162414.720306-12-jacopo@jmondi.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200309162414.720306-1-jacopo@jmondi.org> References: <20200309162414.720306-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 11/11] test: v4l2_videodevice: Test U8 array 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, 09 Mar 2020 16:21:33 -0000 Test V4L2 array control using vivid control VIVID_CID_U8_4D_ARRAY. Signed-off-by: Jacopo Mondi --- test/v4l2_videodevice/controls.cpp | 31 +++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/test/v4l2_videodevice/controls.cpp b/test/v4l2_videodevice/controls.cpp index 478de3707a3c..e2601b7594bb 100644 --- a/test/v4l2_videodevice/controls.cpp +++ b/test/v4l2_videodevice/controls.cpp @@ -5,6 +5,7 @@ * controls.cpp - V4L2 device controls handling test */ +#include #include #include @@ -12,6 +13,13 @@ #include "v4l2_videodevice_test.h" +/* These come from the vivid driver */ +#define VIVID_CID_CUSTOM_BASE (V4L2_CID_USER_BASE | 0xf000) +#define VIVID_CID_U8_4D_ARRAY (VIVID_CID_CUSTOM_BASE + 10) + +/* Helper for VIVID_CID_U8_4D_ARRAY control array size: not from kernel. */ +#define VIVID_CID_U8_ARRAY_SIZE (2 * 3 * 4 * 5) + using namespace std; using namespace libcamera; @@ -36,7 +44,8 @@ protected: if (infoMap.find(V4L2_CID_BRIGHTNESS) == infoMap.end() || infoMap.find(V4L2_CID_CONTRAST) == infoMap.end() || - infoMap.find(V4L2_CID_SATURATION) == infoMap.end()) { + infoMap.find(V4L2_CID_SATURATION) == infoMap.end() || + infoMap.find(VIVID_CID_U8_4D_ARRAY) == infoMap.end()) { cerr << "Missing controls" << endl; return TestFail; } @@ -44,6 +53,7 @@ protected: const ControlInfo &brightness = infoMap.find(V4L2_CID_BRIGHTNESS)->second; const ControlInfo &contrast = infoMap.find(V4L2_CID_CONTRAST)->second; const ControlInfo &saturation = infoMap.find(V4L2_CID_SATURATION)->second; + const ControlInfo &u8 = infoMap.find(VIVID_CID_U8_4D_ARRAY)->second; /* Test getting controls. */ ControlList ctrls(infoMap); @@ -51,6 +61,10 @@ protected: ctrls.set(V4L2_CID_CONTRAST, -1); ctrls.set(V4L2_CID_SATURATION, -1); + std::array u8Values; + Span u8Span(u8Values); + ctrls.set(VIVID_CID_U8_4D_ARRAY, u8Span); + int ret = capture_->getControls(&ctrls); if (ret) { cerr << "Failed to get controls" << endl; @@ -64,11 +78,26 @@ protected: return TestFail; } + u8Span = ctrls.get(VIVID_CID_U8_4D_ARRAY).get>(); + for (unsigned int i = 0; i < VIVID_CID_U8_ARRAY_SIZE; ++i) { + if (u8Span[i] != 0) + continue; + + cerr << "Incorrect value for retrieved array control" + << endl; + return TestFail; + } + /* Test setting controls. */ ctrls.set(V4L2_CID_BRIGHTNESS, brightness.min()); ctrls.set(V4L2_CID_CONTRAST, contrast.max()); ctrls.set(V4L2_CID_SATURATION, saturation.min()); + for (unsigned int i = 0; i < VIVID_CID_U8_ARRAY_SIZE; ++i) + u8Values[i] = u8.min().get(); + u8Span = u8Values; + ctrls.set(VIVID_CID_U8_4D_ARRAY, u8Span); + ret = capture_->setControls(&ctrls); if (ret) { cerr << "Failed to set controls" << endl;