{"id":26330,"url":"https://patchwork.libcamera.org/api/1.1/patches/26330/?format=json","web_url":"https://patchwork.libcamera.org/patch/26330/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260325092659.79453-3-barnabas.pocze@ideasonboard.com>","date":"2026-03-25T09:26:58","name":"[v1,3/4] libcamera: v4l2_device: Use `bool` for boolean controls","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"2eb0467503ac93d172dbdd3022aec6c132e37b99","submitter":{"id":216,"url":"https://patchwork.libcamera.org/api/1.1/people/216/?format=json","name":"Barnabás Pőcze","email":"barnabas.pocze@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/26330/mbox/","series":[{"id":5844,"url":"https://patchwork.libcamera.org/api/1.1/series/5844/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5844","date":"2026-03-25T09:26:56","name":"[v1,1/4] libcamera: v4l2_device: Ensure consistent control types","version":1,"mbox":"https://patchwork.libcamera.org/series/5844/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/26330/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/26330/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id CE7B1C32F5\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 25 Mar 2026 09:27:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3ED57627A1;\n\tWed, 25 Mar 2026 10:27:07 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 6340F62791\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Mar 2026 10:27:03 +0100 (CET)","from pb-laptop.local (185.221.143.129.nat.pool.zt.hu\n\t[185.221.143.129])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 95E071123\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 25 Mar 2026 10:25:45 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"SKsl5bTY\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1774430745;\n\tbh=sWM8NhFpHWnORQEBgBj+5vljpNdZafni8T1NPAT6aBU=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=SKsl5bTYeoTjqmwYs/rCXlSpZ/Hu37B1/SuJDhD47ZYeJQo3Pp0KJ1klElpYXuADk\n\tadQBrb9DPkuKq1Ked//D8SuFbFDjNhpzIx6y2W8leIF1rvLku0iSkpKeM/1afJlIkQ\n\tjZfZfUE1XE2O8SU0mwPb7IM4KCxPT9cDPyHWyeOs=","From":"=?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= <barnabas.pocze@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Subject":"[PATCH v1 3/4] libcamera: v4l2_device: Use `bool` for boolean\n\tcontrols","Date":"Wed, 25 Mar 2026 10:26:58 +0100","Message-ID":"<20260325092659.79453-3-barnabas.pocze@ideasonboard.com>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260325092659.79453-1-barnabas.pocze@ideasonboard.com>","References":"<20260325092659.79453-1-barnabas.pocze@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The `ControlInfo` generated by `V4L2Device::v4l2ControlInfo()` already\nuses the `bool` type, and there is no reason to disallow setting proper\n\"bool\" values.\n\nSo adjust `updateControls()` and `setControls()` accordingly, and also\ndo the necessary adjustments wrt. `V4L2_CID_{V,H}FLIP`.\n\nSigned-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n---\n src/libcamera/sensor/camera_sensor_legacy.cpp | 10 ++++------\n src/libcamera/sensor/camera_sensor_raw.cpp    |  6 ++----\n src/libcamera/v4l2_device.cpp                 | 14 ++++++++++++++\n 3 files changed, 20 insertions(+), 10 deletions(-)","diff":"diff --git a/src/libcamera/sensor/camera_sensor_legacy.cpp b/src/libcamera/sensor/camera_sensor_legacy.cpp\nindex 6a683821f..99ce7ffb0 100644\n--- a/src/libcamera/sensor/camera_sensor_legacy.cpp\n+++ b/src/libcamera/sensor/camera_sensor_legacy.cpp\n@@ -212,9 +212,9 @@ int CameraSensorLegacy::init()\n \t */\n \tControlList ctrls(subdev_->controls());\n \tif (subdev_->controls().find(V4L2_CID_HFLIP) != subdev_->controls().end())\n-\t\tctrls.set(V4L2_CID_HFLIP, 0);\n+\t\tctrls.set(V4L2_CID_HFLIP, false);\n \tif (subdev_->controls().find(V4L2_CID_VFLIP) != subdev_->controls().end())\n-\t\tctrls.set(V4L2_CID_VFLIP, 0);\n+\t\tctrls.set(V4L2_CID_VFLIP, false);\n \tsubdev_->setControls(&ctrls);\n \n \t/* Enumerate, sort and cache media bus codes and sizes. */\n@@ -762,10 +762,8 @@ int CameraSensorLegacy::setFormat(V4L2SubdeviceFormat *format, Transform transfo\n \tif (supportFlips_) {\n \t\tControlList flipCtrls(subdev_->controls());\n \n-\t\tflipCtrls.set(V4L2_CID_HFLIP,\n-\t\t\t      static_cast<int32_t>(!!(transform & Transform::HFlip)));\n-\t\tflipCtrls.set(V4L2_CID_VFLIP,\n-\t\t\t      static_cast<int32_t>(!!(transform & Transform::VFlip)));\n+\t\tflipCtrls.set(V4L2_CID_HFLIP, !!(transform & Transform::HFlip));\n+\t\tflipCtrls.set(V4L2_CID_VFLIP, !!(transform & Transform::VFlip));\n \n \t\tint ret = subdev_->setControls(&flipCtrls);\n \t\tif (ret)\ndiff --git a/src/libcamera/sensor/camera_sensor_raw.cpp b/src/libcamera/sensor/camera_sensor_raw.cpp\nindex 10eba0331..882c1cc1a 100644\n--- a/src/libcamera/sensor/camera_sensor_raw.cpp\n+++ b/src/libcamera/sensor/camera_sensor_raw.cpp\n@@ -822,10 +822,8 @@ int CameraSensorRaw::setFormat(V4L2SubdeviceFormat *format, Transform transform)\n \tif (supportFlips_) {\n \t\tControlList flipCtrls(subdev_->controls());\n \n-\t\tflipCtrls.set(V4L2_CID_HFLIP,\n-\t\t\t      static_cast<int32_t>(!!(transform & Transform::HFlip)));\n-\t\tflipCtrls.set(V4L2_CID_VFLIP,\n-\t\t\t      static_cast<int32_t>(!!(transform & Transform::VFlip)));\n+\t\tflipCtrls.set(V4L2_CID_HFLIP, !!(transform & Transform::HFlip));\n+\t\tflipCtrls.set(V4L2_CID_VFLIP, !!(transform & Transform::VFlip));\n \n \t\tint ret = subdev_->setControls(&flipCtrls);\n \t\tif (ret)\ndiff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex db1eb70e4..426664b83 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -327,6 +327,17 @@ int V4L2Device::setControls(ControlList *ctrls, const V4L2Request *request)\n \t\t/* Set the v4l2_ext_control value for the write operation. */\n \t\tControlValue &value = ctrl->second;\n \t\tswitch (iter->first->type()) {\n+\t\tcase ControlTypeBool: {\n+\t\t\tif (value.isArray()) {\n+\t\t\t\tLOG(V4L2, Error)\n+\t\t\t\t\t<< \"Array of bool not supported for control \" << utils::hex(id);\n+\t\t\t\treturn -ENOTSUP;\n+\t\t\t}\n+\n+\t\t\tv4l2Ctrl.value = value.get<bool>();\n+\t\t\tbreak;\n+\t\t}\n+\n \t\tcase ControlTypeUnsigned16: {\n \t\t\tif (value.isArray()) {\n \t\t\t\tSpan<uint8_t> data = value.data();\n@@ -824,6 +835,9 @@ void V4L2Device::updateControls(ControlList *ctrls,\n \t\tASSERT(iter != controls_.end());\n \n \t\tswitch (iter->first->type()) {\n+\t\tcase ControlTypeBool:\n+\t\t\tvalue.set<bool>(v4l2Ctrl.value);\n+\t\t\tbreak;\n \t\tcase ControlTypeByte:\n \t\t\tvalue.set<uint8_t>(v4l2Ctrl.value);\n \t\t\tbreak;\n","prefixes":["v1","3/4"]}