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)); } } From patchwork Fri Dec 2 12:40:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17937 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 EEDD7BE08B 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 ED9D663346; 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=1669984810; bh=nvrOEvJVHz7j09luDy4xiun/bWXhoqUsyv867Z9Io5c=; 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=ShR0/4ZOF9x7J4Qg17lwTtEp8aUBKKpEAR7GiQrLVZfC2oAg+OwmA64IiLPbGwZg4 yfYKKQMSqxLFVUVIGd2GyMqlHuZJWw6lIJEZf/DBYP20Yplo80DTfHVqhrYe4215l6 RkBvgnh7Mow7bx98MhTRydRNG3bcTLAsmgvoHPBPoSvZK60foAjIZCc0iFQFYn9Uix 5M8ruYQ+O6pK+ljJrp6UguVGIkeihjTOPJpRpJEOn1FGlSPfR+NQ+96lhSo2b92OId 0FxWPKVLlxcZsGxZt0czHQchRr6C2W3t+kgEGizRFiv7xRwuRGIaJ76wIuBpofOZnB djZ/LRZsUJXiw== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 91FE96333E for ; Fri, 2 Dec 2022 13:40:08 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Y39Qfske"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id f18so7610423wrj.5 for ; Fri, 02 Dec 2022 04:40:08 -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=jdJada7Pm/o1Cp/fS3FBp6tTdVC42aBz9VmgOPqqXrw=; b=Y39Qfskej9W8PjV+t29zoAXyBl4BMAQqvzQYEAhsmaDERvQF/lQTl7kvZTgs/WozZq zThxF90fLlSYhJQ4yVaUKJqVZZTq9Gqe8SUx0hgj7f305/goedenZj0qgv/sRyunZDk7 Z4/KNhdyHbZvBmhesgVpW3telcOD8Ih8nYH0aoS/t2E3xd+ZRA7dqPQ/c6mVHtaX3hPF f1gBkZmJDrf2pww2ZP0J69E+mHjs1MuQUIftFjZ6FsymVj/0slQuBxSkj7433k48dxU0 dPTEqQFYoKo0+otMKCslTzbyyl1WslBtHd+kEu7i9Za/s5wUdCdwgimwF98kokt++gce GSLA== 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=jdJada7Pm/o1Cp/fS3FBp6tTdVC42aBz9VmgOPqqXrw=; b=JFarWwxEnuxQUf5YLdnQVhypftaX/A1HjWyYviZ5il2rs8WBFJBNRleylE5DTu2Vpc JYv8EFY7dP9OuBa8UawHdMfYVBHDEVnMAuOPXpbrMfy8W1dZdIweyNZQ9rSNyGGAXtQQ wBYasiQYDWveXv1VcT1JmEvZNAM2JvtaZByLSf4jy7VZdjBjwMlgf7gRkLo35lYZcx5H t70mxYBloj4TBQvGTuZBSVPybHlvoe68VD5NigkU4YrabuueNl0JdIsGwwhuqukIoZf4 /nm28VUmVNJUum1Z1+WSzkFqH0sPy7wwfRi2jTR+TKYEyIe2zkM+M+1Z2vUeeRDH1N5E K29w== X-Gm-Message-State: ANoB5pnO+xTAtmQClIYpIieHBYDaymKnBP2AKzmiDrmkSf+f+q6uMP/b jB1LtsYOl7yLnWHIWbiZvTZN6R/iafWaIj3F X-Google-Smtp-Source: AA0mqf6FNbUHTBOPH7SjrYFhEv8aHv4fdYPiXZsmS4wOB92KMZdQrTaw3Q78daqxI7qedKjTp4jfQw== X-Received: by 2002:adf:d206:0:b0:242:285f:c6f4 with SMTP id j6-20020adfd206000000b00242285fc6f4mr9425535wrh.452.1669984807927; 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.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 04:40:07 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Dec 2022 12:40:05 +0000 Message-Id: <20221202124005.3643-3-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 2/2] libcamera:camera_sensor, ipa: raspberrypi: Test readOnly() for HBLANK control 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" Use ControlInfo::readOnly() to test if the camera sensor accepts V4L2_CID_HBLANK control changes. This replaces the current workaround where we test if the V4L2_CID_HBLANK min and max values are the same to determine if a control is read-only. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- src/ipa/raspberrypi/raspberrypi.cpp | 12 +----------- src/libcamera/camera_sensor.cpp | 14 ++------------ 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index bead436def3c..57f01496fc44 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -1239,17 +1239,7 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) ctrls.set(V4L2_CID_EXPOSURE, exposureLines); ctrls.set(V4L2_CID_ANALOGUE_GAIN, gainCode); - /* - * At present, there is no way of knowing if a control is read-only. - * As a workaround, assume that if the minimum and maximum values of - * the V4L2_CID_HBLANK control are the same, it implies the control - * is read-only. This seems to be the case for all the cameras our IPA - * works with. - * - * \todo The control API ought to have a flag to specify if a control - * is read-only which could be used below. - */ - if (mode_.minLineLength != mode_.maxLineLength) + if (!sensorCtrls_.at(V4L2_CID_HBLANK).readOnly()) ctrls.set(V4L2_CID_HBLANK, static_cast(hblank)); } diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index ae3127d6b693..3785b6441b90 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -185,20 +185,10 @@ int CameraSensor::init() * Set HBLANK to the minimum to start with a well-defined line length, * allowing IPA modules that do not modify HBLANK to use the sensor * minimum line length in their calculations. - * - * At present, there is no way of knowing if a control is read-only. - * As a workaround, assume that if the minimum and maximum values of - * the V4L2_CID_HBLANK control are the same, it implies the control - * is read-only. - * - * \todo The control API ought to have a flag to specify if a control - * is read-only which could be used below. */ const ControlInfo hblank = ctrls.infoMap()->at(V4L2_CID_HBLANK); - const int32_t hblankMin = hblank.min().get(); - const int32_t hblankMax = hblank.max().get(); - - if (hblankMin != hblankMax) { + if (!hblank.readOnly()) { + const int32_t hblankMin = hblank.min().get(); ControlList ctrl(subdev_->controls()); ctrl.set(V4L2_CID_HBLANK, hblankMin);