From patchwork Mon Feb 17 14:26:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 2841 Return-Path: Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BC817617B6 for ; Mon, 17 Feb 2020 15:28:20 +0100 (CET) Received: by mail-wr1-x431.google.com with SMTP id y17so19967095wrh.5 for ; Mon, 17 Feb 2020 06:28:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ylPR30yh3hEPaSqmXUBgYdKNFJBSVfN9rHKln9M5vmQ=; b=qqjpDoxjrRY3h4njTn8Gbe0jUHg2ejUf3pBXxPM6IRgKgzzqwLhO8zKnki1MGKSgcZ NyiIws951D3lp6swK+ZwdCba2gkKNnSW71DlSUj6w0Q70XRsN6NhdQInEFMzJtEIQfCw 5SLOV0wNwJiUf6s0vEyaasGDbLF1thP1WTyblmhlQbEyy5viH/SOAAgFCmYUlT+FrZ5/ JG0DZK9af3CXT5DwJFnTP3BH+IymPoSOtETLpE/GAHRO79LTy7vzGfKGDbQww6xaIf6b yU2XlVSbMge2KjG4JVIURJJbLFowsVRjca2ifDoAg9s0L4BZEYcB/G4WFMV8+V7D4iBx 6M4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ylPR30yh3hEPaSqmXUBgYdKNFJBSVfN9rHKln9M5vmQ=; b=S7Gv9b4xeFBORPWkcqKriOQEm8x45Rx8iMJ8Q1LVitFR+3tAniT78vRMe2FZUJrj78 PqKVAfWlEwVh2PR4J4jjWF6oZf3JgxHETZI7LVDSFwHgji9NNgBDV5Ae9NKNK7w0ofDp fXik3WYIt/EDAir0cg+SrMYrCJWMFZTqrZBV/UaPtEH/BFYp87xgUtk8gF6t+zy1gmZ2 Mt4RPIbCj074VT5ntzQhIAR4EmX41mVj/cIBv6BKAkny9TWWsbAHWScEoi1WYXoqHm27 2vSlI8mrvkYUr9uSi1yK8z8xIahahP2mudXw6BDOz6H7sk06ovDYxJj3uRBgJfGh3MBw bhfg== X-Gm-Message-State: APjAAAXRu6MMhyCMJy0bPQUhztN0gH+CTQTVg+EDQ2K5DSsjN3/swnKw jgPYxHlyV1/Sf8XoKXVzG9xZ3f6IPF9ZOg== X-Google-Smtp-Source: APXvYqwOb1NItIJZSplNcKEb+eZ9J7dGD+RTjaXGoG5OjuZAzKbfC0OFNfGj91cEl75xPChmTdWArA== X-Received: by 2002:adf:b605:: with SMTP id f5mr21452730wre.383.1581949700134; Mon, 17 Feb 2020 06:28:20 -0800 (PST) Received: from naushir-VirtualBox.pitowers.org (cust51-dsl50.idnet.net. [212.69.50.51]) by smtp.gmail.com with ESMTPSA id p15sm760960wma.40.2020.02.17.06.28.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 06:28:19 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 17 Feb 2020 14:26:07 +0000 Message-Id: <20200217142609.22837-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200217142609.22837-1-naush@raspberrypi.com> References: <20200217142609.22837-1-naush@raspberrypi.com> Subject: [libcamera-devel] [PATCH 1/3] libcamera: controls: Add std::string and double ControlValue type. 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-List-Received-Date: Mon, 17 Feb 2020 14:28:20 -0000 Strings are a convenient control type for controls such as AWB mode ("indoor", "outdoor", "halogen", etc.) or AGC mode ("sports", "long exposure", "spot", etc.). Double control values are useful for control values such as EV and even gains. This commit adds support for std::string and double control types. Functionality such as ControlRange on std::string types do not really make sense, so do nothing with that for now. Also add appropriate test for the new ControlValue types. Signed-off-by: Naushir Patuck --- include/libcamera/controls.h | 6 +++ src/libcamera/controls.cpp | 72 ++++++++++++++++++++++++++++++++- test/controls/control_value.cpp | 26 ++++++++++++ 3 files changed, 103 insertions(+), 1 deletion(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 458b84e..ac74122 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -20,6 +20,8 @@ enum ControlType { ControlTypeBool, ControlTypeInteger32, ControlTypeInteger64, + ControlTypeString, + ControlTypeDouble, }; class ControlValue @@ -29,6 +31,8 @@ public: ControlValue(bool value); ControlValue(int32_t value); ControlValue(int64_t value); + ControlValue(std::string value); + ControlValue(double value); ControlType type() const { return type_; } bool isNone() const { return type_ == ControlTypeNone; } @@ -53,7 +57,9 @@ private: bool bool_; int32_t integer32_; int64_t integer64_; + double double_; }; + std::string string_; }; class ControlId diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 0031cd0..6eb79c9 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -58,6 +58,10 @@ LOG_DEFINE_CATEGORY(Controls) * The control stores a 32-bit integer value * \var ControlTypeInteger64 * The control stores a 64-bit integer value + * \var ControlTypeString + * The control stores a std::string value + * \var ControlTypeDouble + * The control stores a double value */ /** @@ -100,6 +104,24 @@ ControlValue::ControlValue(int64_t value) { } +/** + * \brief Construct a std::string ControlValue + * \param[in] value String value to store + */ +ControlValue::ControlValue(std::string value) + : type_(ControlTypeString), string_(value) +{ +} + +/** + * \brief Construct a double ControlValue + * \param[in] value Double value to store + */ +ControlValue::ControlValue(double value) + : type_(ControlTypeDouble), double_(value) +{ +} + /** * \fn ControlValue::type() * \brief Retrieve the data type of the value @@ -153,6 +175,18 @@ const int64_t &ControlValue::get() const return integer64_; } +template<> +const std::string &ControlValue::get() const +{ + return string_; +} + +template<> +const double &ControlValue::get() const +{ + return double_; +} + template<> void ControlValue::set(const bool &value) { @@ -173,6 +207,21 @@ void ControlValue::set(const int64_t &value) type_ = ControlTypeInteger64; integer64_ = value; } + +template<> +void ControlValue::set(const std::string &value) +{ + type_ = ControlTypeString; + string_ = value; +} + +template<> +void ControlValue::set(const double &value) +{ + type_ = ControlTypeDouble; + double_ = value; +} + #endif /* __DOXYGEN__ */ /** @@ -190,6 +239,10 @@ std::string ControlValue::toString() const return std::to_string(integer32_); case ControlTypeInteger64: return std::to_string(integer64_); + case ControlTypeString: + return string_; + case ControlTypeDouble: + return std::to_string(double_); } return ""; @@ -211,6 +264,10 @@ bool ControlValue::operator==(const ControlValue &other) const return integer32_ == other.integer32_; case ControlTypeInteger64: return integer64_ == other.integer64_; + case ControlTypeString: + return string_ == other.string_; + case ControlTypeDouble: + return double_ == other.double_; default: return false; } @@ -341,6 +398,18 @@ Control::Control(unsigned int id, const char *name) : ControlId(id, name, ControlTypeInteger64) { } + +template<> +Control::Control(unsigned int id, const char *name) + : ControlId(id, name, ControlTypeString) +{ +} + +template<> +Control::Control(unsigned int id, const char *name) + : ControlId(id, name, ControlTypeDouble) +{ +} #endif /* __DOXYGEN__ */ /** @@ -583,7 +652,8 @@ void ControlInfoMap::generateIdmap() idmap_.clear(); for (const auto &ctrl : *this) { - if (ctrl.first->type() != ctrl.second.min().type()) { + if (ctrl.first->type() != ControlTypeString && + (ctrl.first->type() != ctrl.second.min().type())) { LOG(Controls, Error) << "Control " << utils::hex(ctrl.first->id()) << " type and range type mismatch"; diff --git a/test/controls/control_value.cpp b/test/controls/control_value.cpp index a1ffa84..55174da 100644 --- a/test/controls/control_value.cpp +++ b/test/controls/control_value.cpp @@ -21,10 +21,14 @@ protected: { ControlValue integer(1234); ControlValue boolean(true); + ControlValue fractional(3.142); + ControlValue string(std::string("MyString")); /* Just a string conversion output test... no validation */ cout << "Int: " << integer.toString() << " Bool: " << boolean.toString() + << " Frac: " << fractional.toString() + << " String: " << string.toString() << endl; if (integer.get() != 1234) { @@ -37,6 +41,16 @@ protected: return TestFail; } + if (fractional.get() != 3.142) { + cerr << "Failed to get Fractional" << endl; + return TestFail; + } + + if (string.get() != std::string("MyString")) { + cerr << "Failed to get String" << endl; + return TestFail; + } + /* Test an uninitialised value, and updating it. */ ControlValue value; @@ -62,6 +76,18 @@ protected: return TestFail; } + value.set(2.718); + if (value.get() != 2.718) { + cerr << "Failed to get Fractional" << endl; + return TestFail; + } + + value.set(std::string("Test")); + if (value.get() != std::string("Test")) { + cerr << "Failed to get String" << endl; + return TestFail; + } + return TestPass; } }; From patchwork Mon Feb 17 14:26:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 2842 Return-Path: Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D4B3C617B6 for ; Mon, 17 Feb 2020 15:28:22 +0100 (CET) Received: by mail-wr1-x444.google.com with SMTP id r11so19932087wrq.10 for ; Mon, 17 Feb 2020 06:28:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=A/4b+JCQNP8NQmqirhXCx7H1RDp7oKCdXS8ALhz71PA=; b=MtT2yP3dSuPPJRNNBM6A29P9p27danVj5cISd05GEX23Za7Ea0urvGwkTxMl9Zx+BZ NfUk5TzGi/iw37Ol+onBtqObcY5loci/FMTLnf148SKPqvqRI2tZMVPHBKVbbXmONj1L 5uhzuoJwrwz+/GtI+3Vuobvz66uPyrBv9NpcKXxlNJTzD+/PHpN7InqhNFkn3bCRGQSy bKAkzoyICG1A/OGDONQPrQST3jqkdet8B9Tn0EZDZ1CMvTDLwCFNqNdRhmxOPupfMTOT vD5I4l/87zh//WjoFe7Qx4o7z1Rzg99sFCN1TFVVTkxPMnG+fWZKnKCSAhzyGJ4zADX6 vxOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=A/4b+JCQNP8NQmqirhXCx7H1RDp7oKCdXS8ALhz71PA=; b=hWxnzXu9ubofFb6AckQF84cVzScUMkbe/GpfLB1zVy075+nZKOW1FsxwELwflZ+kwL Dm5nJYOCBOYrc3LeJC7pAhqUOmJRyq5pnW5hdUsF1w6LypqimEyDc1CPOVhFUIqdYjzq rviYe+QFLlHo4LWEN4Nc2i6Uu8jAMeX6rFC8SIEmzmNsEzxI9aMlXraSBjI1YpB8C9OE ulCM3z2VbROL/lTMAjZ1juWIFWZuxalh16TBp4HOG9GRRmeHPDRA5+mWDDNCT+0O/XFZ VgZOZ66gsR8Af/ujkQwtIyj3ZQxcnpEKX14rfd/n6uGGKLpt4p7I+1yZIPIGgtlhSkP4 KRDg== X-Gm-Message-State: APjAAAVkj7T9pnQ+Ce1Vj1Z6twKNQfmZrxHACHgUc3gLhEDihcxB8UTp MoPJDf6lxrov+slzAhVYuEvpd43Oei/c4g== X-Google-Smtp-Source: APXvYqw4g4rzPt92O10ZYaOWQO0J+H0uyy7x/Cdfn7bkf4Z1Y7oDtpTZ/yDRpvUiAdcP9Nfhsi23FQ== X-Received: by 2002:a5d:484d:: with SMTP id n13mr22232422wrs.420.1581949702471; Mon, 17 Feb 2020 06:28:22 -0800 (PST) Received: from naushir-VirtualBox.pitowers.org (cust51-dsl50.idnet.net. [212.69.50.51]) by smtp.gmail.com with ESMTPSA id p15sm760960wma.40.2020.02.17.06.28.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 06:28:22 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Mon, 17 Feb 2020 14:26:08 +0000 Message-Id: <20200217142609.22837-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200217142609.22837-1-naush@raspberrypi.com> References: <20200217142609.22837-1-naush@raspberrypi.com> Subject: [libcamera-devel] [PATCH 2/3] libcamera: controls: Specify manual gain units and change exposure units 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-List-Received-Date: Mon, 17 Feb 2020 14:28:23 -0000 Use micro-seconds for ManualExposure. This is changed from milli- seconds. The latter would not allow very low exposure times. Use double for ManualGain to allow fractional gain adjustments. Signed-off-by: Naushir Patuck --- src/libcamera/control_ids.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index 4befec7..33062d6 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -44,10 +44,10 @@ controls: - ManualExposure: type: int32_t - description: Specify a fixed exposure time in milli-seconds + description: Specify a fixed exposure time in micro-seconds - ManualGain: - type: int32_t - description: Specify a fixed gain parameter + type: double + description: Specify a fixed gain parameter. ... From patchwork Mon Feb 17 14:26:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 2843 Return-Path: Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 00AB5617B6 for ; Mon, 17 Feb 2020 15:28:25 +0100 (CET) Received: by mail-wm1-x342.google.com with SMTP id b17so18701345wmb.0 for ; Mon, 17 Feb 2020 06:28:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uLQnWOAqxB0p6T2Eo7lR0VVhkPlZJIwfGfueX79Ynws=; b=QAXpa8ax0/vNtdKaIjMVK25CIie9OIcgfc0/g5m9oYTh029QLSLBNraEftcH0+eH7l 5c1hs2iE5s6rvhNVnk+VrHUIS89XnGuJRaW8qq31Eb7hi63WcP3PXsooUv/Qly2ImmiQ BZIl3bbV1RmOZE7LxXXDVrj2JdzByt8BTl3sIgl9/OCiOa/FAWZhnnEQLwhuHJHIXGHC 3FpVQOz8qglc4PUjswBuXBSVTdgPMe86jXf+J2brB9/ST+GWmY98YqhcNZwrr2lUxS5S Xf4IpA4t7w/Rn71HOg6RTO2HxjqpEf/bVv4r0IBn2g+SBgRff51almF1UI1BMHl05h0Y p6sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uLQnWOAqxB0p6T2Eo7lR0VVhkPlZJIwfGfueX79Ynws=; b=UWXJr/6QhVZtqmGJ1vsu5Gojd0+t2LGiO7PryNxSrGPG80AAz+ZB7rRBVZmTshytPP 0DcrZmn8HfTyEMOOKaKJwzYOoVoguSxa9lMz4dp1vuIb9KSNvqFFBkTaC5Zx+u0/+SgB TIcuoZdgqEew1Do0TXz7t1mEWnKQAmPl3LLQucg1nMsKigXLRhgf4qbFF2wjqJgHSGAb kPO5DjYR0eOC96PxK98EAr/lzj0ux09nSk3P4GcE3SEsGlCveXQl11MWQCklfX7jPkNo pRTfmKjrhaBiZrHNcR0pakcKrHcyqpow64+rNqXfIWrzq95j3j9DPzhbGatvtPx+OfJz 4w2A== X-Gm-Message-State: APjAAAXSAw2bmAYzpJnZc7S+x61vAgzfhEbmpQd1cDumeKyTo1LY48Hm xcCWqmMbvVRGP7Fp2/11vAygLOrWbIOReA== X-Google-Smtp-Source: APXvYqz9JnpBy+5YzUjA9akoTJS2B8Awi+IMnSUU2Tri147/L6KTrwfPoEI2h90emd0efQw5jdAYLQ== X-Received: by 2002:a1c:16:: with SMTP id 22mr22416595wma.8.1581949704560; Mon, 17 Feb 2020 06:28:24 -0800 (PST) Received: from naushir-VirtualBox.pitowers.org (cust51-dsl50.idnet.net. [212.69.50.51]) by smtp.gmail.com with ESMTPSA id p15sm760960wma.40.2020.02.17.06.28.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Feb 2020 06:28:24 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Cc: Naushir Patuck , Naushir Patuck Date: Mon, 17 Feb 2020 14:26:09 +0000 Message-Id: <20200217142609.22837-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200217142609.22837-1-naush@raspberrypi.com> References: <20200217142609.22837-1-naush@raspberrypi.com> Subject: [libcamera-devel] [PATCH 3/3] libcamera: controls: Add AE/AWB mode, manual and EV controls. 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-List-Received-Date: Mon, 17 Feb 2020 14:28:25 -0000 AeMode is a new std::string type control used to set the AE algorithm mode. The mode may not always be supported by all platforms. AwbMode is a new std::string type control used to set the AWB algorithm illuminant mode. The mode may not always be supported by all platforms. EV is a new double type control used to set the log2 exposure adjustment for the AE algorithm. ManualGainR is a new double type control used to set the Red channel gain in manual AWB mode. ManualGainB is a new double type control used to set the Blue channel gain in manual AWB mode. Signed-off-by: Naushir Patuck --- src/libcamera/control_ids.yaml | 40 ++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index 33062d6..21d2065 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -50,4 +50,44 @@ controls: type: double description: Specify a fixed gain parameter. + - AeMode: + type: std::string + description: | + Specify an exposure mode for the AE algorithm to use. The exposure modes + supported are platform spcific, and not all modes may be supported. + + Examples include "normal", "sport", "low light", etc. + + - AwbMode: + type: std::string + description: | + Specify the range of illuminant to use for the AWB algorihtm. The modes + supported are platform specific, and not all modes may be supported. + + Examples include "auto", "incandescent", "daylight", etc. + + - EV: + type: double + description: | + Specify an Exposure Value (EV) parameter. + + By convention, EV adjusts the exposure by a factor of 2^EV. For example + EV = [-2, -1, 0.5, 0, 0.5, 1, 2] results in an exposure adjustment + of [1/4x, 1/2x, 1/sqrt(2)x, 1x, sqrt(2)x, 2x, 4x]. + + - ManualGainR: + type: double + description: | + Specify a fixed gain parameter for the Red colour channel. This must be + set together with ManualGainB to be applied. + + \sa ManualGainB + + - ManualGainB: + type: double + description: | + Specify a fixed gain parameter for the Green colour channel. This must + bet together with AwbManualGainR to be applied. + + \sa ManualGainR ...