From patchwork Tue May 25 08:55:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12398 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 48D9BC3200 for ; Tue, 25 May 2021 08:55:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AA0DE68921; Tue, 25 May 2021 10:55:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FKAmDacV"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B5A95602AF for ; Tue, 25 May 2021 10:55:42 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1477F344; Tue, 25 May 2021 10:55:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1621932942; bh=zpIX6NtTFmg9QrogEc3mhVOHcFskBZBriXMqbHCZV2k=; h=From:To:Cc:Subject:Date:From; b=FKAmDacVgZIFeFm7CANuj/ebBA0NYYyQo3fGHHJ+iMav9fJnmc35lviD1/tZibT+e 4PxMBWAM4ET2VjAV1q84PJJBzTAF/H3JyUUqy0ey5+DLDxp5N2whtG2ZxEZJHqLKgT OXRqbtjZgokIlElE5tlpNT/JuXAHj5331RYF4jaI= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 25 May 2021 11:55:28 +0300 Message-Id: <20210525085528.11477-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] Revert "libcamera: V4L2Device: Remove the controls order assumption in updateControls()" 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This reverts commit 34bee5e84ecba01e0ded5cacbc46c277c5a0edba. The commit introduced a breakage in the master branch, reported by linux-surface users already. Let's revert it while discussing the propert fix. Signed-off-by: Laurent Pinchart Acked-by: Jacopo Mondi Acked-by: Hirokazu Honda Reviewed-by: Jean-Michel Hautbois Tested-by: Umang Jain --- src/libcamera/v4l2_device.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 7f7e5b8fdf09..caafbc2d16bb 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -244,6 +244,12 @@ ControlList V4L2Device::getControls(const std::vector &ids) ControlList ctrls{ controls_ }; + /* + * Start by filling the ControlList. This can't be combined with filling + * v4l2Ctrls, as updateControls() relies on both containers having the + * same order, and the control list is based on a map, which is not + * sorted by insertion order. + */ for (uint32_t id : ids) { const auto iter = controls_.find(id); if (iter == controls_.end()) { @@ -617,13 +623,19 @@ void V4L2Device::updateControlInfo() void V4L2Device::updateControls(ControlList *ctrls, Span v4l2Ctrls) { - for (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) { - const unsigned int id = v4l2Ctrl.id; + unsigned int i = 0; + for (auto &ctrl : *ctrls) { + if (i == v4l2Ctrls.size()) + break; - ControlValue value = ctrls->get(id); - switch (value.type()) { + const struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i]; + unsigned int id = ctrl.first; + ControlValue &value = ctrl.second; + + const auto iter = controls_.find(id); + switch (iter->first->type()) { case ControlTypeInteger64: - value.set(v4l2Ctrl.value64); + value.set(v4l2Ctrl->value64); break; case ControlTypeByte: @@ -638,11 +650,11 @@ void V4L2Device::updateControls(ControlList *ctrls, * \todo To be changed when support for string controls * will be added. */ - value.set(v4l2Ctrl.value); + value.set(v4l2Ctrl->value); break; } - ctrls->set(id, value); + i++; } }