From patchwork Wed Mar 25 09:26:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 26328 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 76412BD87C for ; Wed, 25 Mar 2026 09:27:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 73848627D7; Wed, 25 Mar 2026 10:27:05 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="O7HWW0HX"; 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 0393F620FA for ; Wed, 25 Mar 2026 10:27:03 +0100 (CET) Received: from pb-laptop.local (185.221.143.129.nat.pool.zt.hu [185.221.143.129]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 395E973B for ; Wed, 25 Mar 2026 10:25:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1774430745; bh=ZSPrVpKXvBFDEDNq6fDg3VUw1BEtXcPeqxRW9q9uUa0=; h=From:To:Subject:Date:From; b=O7HWW0HXEzjsxqaprJlVHsm3+PPmXou32p1yeV+06bhXyx1egSaWDA6PX8kTZtoOC aLCnfzY8CQP60NhtaBCeZA/4wZ4eJlm6drPQMMY23VcD7UHFIHSHGh4+QBzgX+wGAb kdWksfmT6NQdVWaFzPRR6eZ6WLDtOApxehbwawEE= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v1 1/4] libcamera: v4l2_device: Ensure consistent control types Date: Wed, 25 Mar 2026 10:26:56 +0100 Message-ID: <20260325092659.79453-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.53.0 MIME-Version: 1.0 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" While `setControls()` uses the specific types, `updateControls()` converts everything to 32-bit integers (except 64-bit integers). This causes, for example, that a 16-bit unsigned integer is retrieved as `int32_t` even though there is a specific libcamera control type for it. What's even more surprising is that setting such a control requires a `ControlValue` with `uint16_t`, but when `setControls()` updates the list to contain the actually applied values, it will now have type `int32_t`. So make sure that `updateControls()` uses the appropriate type. Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi Reviewed-by: Jacopo Mondi --- src/libcamera/v4l2_device.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 67bbaa037..e0099cb7a 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -823,19 +823,26 @@ void V4L2Device::updateControls(ControlList *ctrls, ASSERT(iter != controls_.end()); switch (iter->first->type()) { + case ControlTypeByte: + value.set(v4l2Ctrl.value); + break; + case ControlTypeUnsigned16: + value.set(v4l2Ctrl.value); + break; + case ControlTypeInteger32: + value.set(v4l2Ctrl.value); + break; + case ControlTypeUnsigned32: + value.set(v4l2Ctrl.value); + break; case ControlTypeInteger64: value.set(v4l2Ctrl.value64); break; - default: - /* - * Note: this catches the ControlTypeInteger32 case. - * - * \todo To be changed when support for string controls - * will be added. - */ - value.set(v4l2Ctrl.value); - break; + LOG(V4L2, Error) + << "Control " << utils::hex(id) + << " has unsupported type"; + continue; } ctrls->set(id, value);