From patchwork Thu Nov 2 17:24:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 19187 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 E9ADEBD16B for ; Thu, 2 Nov 2023 17:24:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 385FF62991; Thu, 2 Nov 2023 18:24:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1698945886; bh=ZkbzwoUMXcZNegdS52rCLn2Bs2Ot6PCmyAYY58Fax90=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=MbDbFVicmGP9/CHCmAvSMO1Z62l60Pc7vu6/LbmGDT5TOk6FD4KGlzTVZenlTJnrS 4A/aYcX9DBApMBQg26HshdaRtX74cQYiGKBquIRr+FrEgIEjZFxhFYeMiafUEWsyHE j11R6tEtLngViwZtIdxiTC1Ki5fgtc22fOPd50+zRNZtQ3wV/btc3o+sFHpudiRXtb 32DdpIuqpyiL8l4/6WzK4HluTvWnN4AOlBYCKpcKAzGE51Q4yy0wWOaddHJGQj5+jw ddgTb5Lzm9cK5eX2z/NeD2U6WcYiPOj1Mnplw5zsnlu44RnOqYlJHeNLTD9LIbl4Es 8U+TE+eXGpYJQ== 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 D738561DC6 for ; Thu, 2 Nov 2023 18:24:44 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MucKTqj/"; dkim-atps=neutral Received: from Monstersaurus.local (aztw-30-b2-v4wan-166917-cust845.vm26.cable.virginm.net [82.37.23.78]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1F6058C1; Thu, 2 Nov 2023 18:24:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1698945867; bh=ZkbzwoUMXcZNegdS52rCLn2Bs2Ot6PCmyAYY58Fax90=; h=From:To:Cc:Subject:Date:From; b=MucKTqj/oZhlR8EKJgFa6PTqjCWFZjNVvuYf2MMWRr52sE6Puk9pJss45rYWqmFpe mtXnu5N1PbXXqE1st6ybZOx1ZjeJhey2zC/k4AYiqQ2962Zme2XE+VEXJgPQiS6OmO yp3dxA+sGD57VAtOcAwrKpdvnlBQuGfgZVQUfU48= To: libcamera devel Date: Thu, 2 Nov 2023 17:24:37 +0000 Message-Id: <20231102172439.3543870-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 0/2] Add read-only flag to ControlInfo 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-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This small patch series adds a read-only flag to ControlInfo. This is used to test if a control, in particular V4L2_CID_HBLANK, can be written to by userland. It replaces the slightly fragile workaround we have right now where we test if the min and max values of a control are the same to determine if a control is read-only. Only modified one ControlInfo constructor is modified which is used by the V4L2Device class to allow this flag to be set, as setting it for a non-v4l2 control probably does not make sense at this point. Modifying other ControlInfo constructors fails quite quickly falling into a range of template issues due to multiple signatures matching. The alternative here would be to rework this such that the ReadOnly flag could be set /after/ construction with a setter allowing something like: V4L2_CTRL_TYPE_INTEGER64: return ControlInfo(static_cast(ctrl.minimum), static_cast(ctrl.maximum), - static_cast(ctrl.default_value)); + static_cast(ctrl.default_value)) .setReadOnly(ctrl.flags & V4L2_CTRL_FLAG_READ_ONLY); Of course that feels like it could remove the 'contract' of the read only property by opening up the ability for a ReadOnly control to have the ReadOnly flag unset - or by opening up the ability to arbitrarily affect a 'property' of a ControlInfo after it has been made. Since v2, I have made the following changes to Naush' patches: - Initialised ReadOnly flag as false for ControlInfo(Span<>) - Improved documentation Naushir Patuck (2): libcamera: controls: Add read-only flag to ControlInfo libcamera:camera_sensor, ipa: raspberrypi: Test readOnly() for HBLANK control include/libcamera/controls.h | 5 ++++- src/ipa/rpi/common/ipa_base.cpp | 12 +----------- src/libcamera/camera_sensor.cpp | 14 ++------------ src/libcamera/controls.cpp | 22 ++++++++++++++++++---- src/libcamera/v4l2_device.cpp | 12 ++++++++---- 5 files changed, 33 insertions(+), 32 deletions(-)