From patchwork Fri Dec 2 12:40:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17936 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 02D46C3284 for ; Fri, 2 Dec 2022 12:40:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7FBEE63336; Fri, 2 Dec 2022 13:40:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669984809; bh=TgaFrZ36pHsllxeDpzU5ir7opt1PrTmJN2JU+duPlhA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=pur7SYgViFZ0v1PR65iwLFkh3YyQJib2NX3Lu2zKbrMyuLDrZuJg/9UWfoD0dLJhh iOD+GlrMC1I0+uuARVRQ4KXHMeZmYhk1xJ4S0XynIzMG60F/qGBytMq93L5yWIs4r2 vN+S3bfspiAg0rHv0SdqtMEw1/KOQNekJadggnsZkWBHb0pplQ0iwDskKHmEObdtea r6SHyKYFSbwov1qOc5ceHafZ90Wc8+ZAGg7M8UXlIqW6JieIa8sEVv79wBQqgSgSUz LVlIo60fPau7zv3eLe8l7xFSuoZiTiX4qyngCc8DfYLOolVuIx0E/NKf9veDqzh313 +zlF1Gm8vxo0Q== Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A9CDA60483 for ; Fri, 2 Dec 2022 13:40:07 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="LHgiyzKr"; dkim-atps=neutral Received: by mail-wr1-x434.google.com with SMTP id q7so7611553wrr.8 for ; Fri, 02 Dec 2022 04:40:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c643d3iJZKcn3dtADXotC7fEYERhkVq2zGvRgdDFG3s=; b=LHgiyzKrg8RquYMmNnZTV9w6vWzwrYNCxZu/fVo0jt8m0nQ7KaXXcRnZt3XNDbO+V7 1UHetRJ9vVIAe7oA0X6tLYt7Pg/FtT5PQhV+jbDGU0GuD7jtXzi5pdWn8+HsZ4QKuW86 g948iFah/8U1IVZl5a+HZHy/RMM0m1HdM3ikFZ0JGUKvIyPHck0hZJXayT9KPyud/lna 3Q3cNR5a7zazt/bI4SjBymhE/gVIGPx8XbyafLY3wvB5XmSPjd2SmP0rnytsbKqt9TZj xkj46ZX7KZe3bPKYgU2hd2D89Og0IVlGfCwlp3qWSO5JAgsz6x63oN1WjNKN/WVoj89/ XmSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c643d3iJZKcn3dtADXotC7fEYERhkVq2zGvRgdDFG3s=; b=MbynJfhh+8Vu2A16YSmwkTuNXvq0VYxoXZ455vEM33enbAOU1YRzvXDothoRT/2IWZ px9CXVfxqqYkq4sNZXr40OM2Ay8vwf5VgHyWo9n1OgyNTNALjONTS6ImGsjct6ctJ/hp LZ6++c2GqKD+xPldNKpTY1g3RYTnvkrD9wK4WaekUmVhJRYN1x1EzFNyY4TlWFrWfKYf QEVr3u1gsv4RtB6aEXPsrHk/AdWGgpR6dwCxl8wfI86pSH7B+SCZQXuoSNSvXSQeWHpY z8npq0/WLDVGIaus6ycf4EYeJGw/Hfz2KCvjla8e3OybMtWVvZsvdXKGmcOnFmE7KeFs fQpg== X-Gm-Message-State: ANoB5pklXHJOVn8f+7ql0hs7ohi3E9Lq9/OkR9rS+HF7POLdHEJx8p6d zcXMONNs35vE2NuN7szNJDPlGgEccP1PCUuO X-Google-Smtp-Source: AA0mqf7XAXVw/Flyqq/qmEbOLIuKNgJW0XDi1hqswxsbGoXpmDqVVl6Ip7AfpmhewNvo76Tq9NKm8g== X-Received: by 2002:adf:e78d:0:b0:241:d3e4:6544 with SMTP id n13-20020adfe78d000000b00241d3e46544mr18654900wrm.533.1669984807178; Fri, 02 Dec 2022 04:40:07 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id y15-20020a5d4acf000000b00241e5b917d0sm8276484wrs.36.2022.12.02.04.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 04:40:06 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Dec 2022 12:40:04 +0000 Message-Id: <20221202124005.3643-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221202124005.3643-1-naush@raspberrypi.com> References: <20221202124005.3643-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/2] libcamera: controls: 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: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a read-only flag to the ControlInfo flag to indicate whether a V4L2 control is read-only or not. This flag only makes sense for V2L2 controls at preset, so only update the ControlInfo constructor signature used by the V4L2Device class to set the value of the flag. Add a ControlInfo::readOnly() member function to retrive this flag. Signed-off-by: Naushir Patuck --- include/libcamera/controls.h | 5 ++++- src/libcamera/controls.cpp | 17 +++++++++++++---- src/libcamera/v4l2_device.cpp | 12 ++++++++---- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index cf94205577a5..488663a7ba04 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -270,7 +270,8 @@ class ControlInfo public: explicit ControlInfo(const ControlValue &min = {}, const ControlValue &max = {}, - const ControlValue &def = {}); + const ControlValue &def = {}, + bool readOnly = false); explicit ControlInfo(Span values, const ControlValue &def = {}); explicit ControlInfo(std::set values, bool def); @@ -279,6 +280,7 @@ public: const ControlValue &min() const { return min_; } const ControlValue &max() const { return max_; } const ControlValue &def() const { return def_; } + bool readOnly() const { return readOnly_; } const std::vector &values() const { return values_; } std::string toString() const; @@ -297,6 +299,7 @@ private: ControlValue min_; ControlValue max_; ControlValue def_; + bool readOnly_; std::vector values_; }; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 6dbf9b348709..fc66abad600d 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -484,11 +484,13 @@ void ControlValue::reserve(ControlType type, bool isArray, std::size_t numElemen * \param[in] min The control minimum value * \param[in] max The control maximum value * \param[in] def The control default value + * \param[in] readOnly Read-only status of a V4L2 control */ ControlInfo::ControlInfo(const ControlValue &min, const ControlValue &max, - const ControlValue &def) - : min_(min), max_(max), def_(def) + const ControlValue &def, + bool readOnly) + : min_(min), max_(max), def_(def), readOnly_(readOnly) { } @@ -525,7 +527,8 @@ ControlInfo::ControlInfo(Span values, * default value is \a def. */ ControlInfo::ControlInfo(std::set values, bool def) - : min_(false), max_(true), def_(def), values_({ false, true }) + : min_(false), max_(true), def_(def), readOnly_(false), + values_({ false, true }) { ASSERT(values.count(def) && values.size() == 2); } @@ -538,7 +541,7 @@ ControlInfo::ControlInfo(std::set values, bool def) * value. The minimum, maximum, and default values will all be \a value. */ ControlInfo::ControlInfo(bool value) - : min_(value), max_(value), def_(value) + : min_(value), max_(value), def_(value), readOnly_(false) { values_ = { value }; } @@ -571,6 +574,12 @@ ControlInfo::ControlInfo(bool value) * \return A ControlValue with the default value for the control */ +/** + * \fn ControlInfo::readOnly() + * \brief Identifies if a V4L2 control is flagged as read-only + * \return True if the V4L2 control is read-only, false otherwise + */ + /** * \fn ControlInfo::values() * \brief Retrieve the list of valid values diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 57a88d96b12c..9018f1b0b9e1 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -535,17 +535,20 @@ std::optional V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl case V4L2_CTRL_TYPE_U8: return ControlInfo(static_cast(ctrl.minimum), static_cast(ctrl.maximum), - static_cast(ctrl.default_value)); + static_cast(ctrl.default_value), + !!(ctrl.flags & V4L2_CTRL_FLAG_READ_ONLY)); case V4L2_CTRL_TYPE_BOOLEAN: return ControlInfo(static_cast(ctrl.minimum), static_cast(ctrl.maximum), - static_cast(ctrl.default_value)); + static_cast(ctrl.default_value), + !!(ctrl.flags & V4L2_CTRL_FLAG_READ_ONLY)); case V4L2_CTRL_TYPE_INTEGER64: return ControlInfo(static_cast(ctrl.minimum), static_cast(ctrl.maximum), - static_cast(ctrl.default_value)); + static_cast(ctrl.default_value), + !!(ctrl.flags & V4L2_CTRL_FLAG_READ_ONLY)); case V4L2_CTRL_TYPE_INTEGER_MENU: case V4L2_CTRL_TYPE_MENU: @@ -554,7 +557,8 @@ std::optional V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl default: return ControlInfo(static_cast(ctrl.minimum), static_cast(ctrl.maximum), - static_cast(ctrl.default_value)); + static_cast(ctrl.default_value), + !!(ctrl.flags & V4L2_CTRL_FLAG_READ_ONLY)); } }