From patchwork Tue Jul 20 10:12:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 13050 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 1BF19C0109 for ; Tue, 20 Jul 2021 10:13:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A561F6852A; Tue, 20 Jul 2021 12:13:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="lz9r7PJj"; dkim-atps=neutral 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 A3DFC68536 for ; Tue, 20 Jul 2021 12:13:21 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 35B19443; Tue, 20 Jul 2021 12:13:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626776001; bh=7UaYDL5xasEAJ+2CgYNb8NGjBMmSqJkV3w1uQ3H7DAo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lz9r7PJjCXUsIybDFUUr4vBK8gDULTp0ygz1zqJxMUzdb0mtb7R4BhprP0dJTxypX 82rhlfj4ZKGXFFp3Pfv28rtKo2aEBWbCs1g4XKawTusg/6eLw1A7YK8Q/qztAU5oe5 ABS0O5lTTKKEyGtuqpFs/OSgMVJGQUf3ap/H+rqc= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Jul 2021 19:12:59 +0900 Message-Id: <20210720101307.26010-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210720101307.26010-1-paul.elder@ideasonboard.com> References: <20210720101307.26010-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 1/9] controls: Add boolean constructors for 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" It would be convenient to be able to iterate over available boolean values, for example for controls that designate if some function can be enabled/disabled. The current min/max/def constructor is insufficient, as .values() is empty, so the values cannot be easily iterated over, and creating a Span of booleans does not work for the values constructor. Add new constructors to ControlInfo that takes a set of booleans (if both booleans are valid values) plus a default, and another that takes only one boolean (if only one boolean is a valid value). Update the ControlInfo test accordingly. Signed-off-by: Paul Elder Reviewed-by: Jacopo Mondi --- Changes in v5: - break away the single-value one to a different constructor Changes in v2: - use set instead of span of bools - add assertion to make sure that the default is a valid value - update the test --- include/libcamera/controls.h | 3 +++ src/libcamera/controls.cpp | 29 +++++++++++++++++++++++++++++ test/controls/control_info.cpp | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 1bc958a4..de733bd8 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -9,6 +9,7 @@ #define __LIBCAMERA_CONTROLS_H__ #include +#include #include #include #include @@ -272,6 +273,8 @@ public: const ControlValue &def = 0); explicit ControlInfo(Span values, const ControlValue &def = {}); + explicit ControlInfo(std::set values, bool def); + explicit ControlInfo(bool value); const ControlValue &min() const { return min_; } const ControlValue &max() const { return max_; } diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 78109f41..283472c5 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -514,6 +514,35 @@ ControlInfo::ControlInfo(Span values, values_.push_back(value); } +/** + * \brief Construct a boolean ControlInfo with both boolean values + * \param[in] values The control valid boolean values (both true and false) + * \param[in] def The control default boolean value + * + * Construct a ControlInfo for a boolean control, where both true and false are + * valid values. \a values must be { false, true } (the order is irrelevant). + * The minimum value will always be false, and the maximum always true. The + * default value is \a def. + */ +ControlInfo::ControlInfo(std::set values, bool def) + : min_(false), max_(true), def_(def), values_({ false, true }) +{ + assert(values.count(def) && values.size() == 2); +} + +/** + * \brief Construct a boolean ControlInfo with only one valid value + * \param[in] value The control valid boolean value + * + * Construct a ControlInfo for a boolean control, where there is only valid + * value. The minimum, maximum, and default values will all be \a value. + */ +ControlInfo::ControlInfo(bool value) + : min_(value), max_(value), def_(value) +{ + values_ = { value }; +} + /** * \fn ControlInfo::min() * \brief Retrieve the minimum value of the control diff --git a/test/controls/control_info.cpp b/test/controls/control_info.cpp index 1e05e131..2827473b 100644 --- a/test/controls/control_info.cpp +++ b/test/controls/control_info.cpp @@ -44,6 +44,39 @@ protected: return TestFail; } + /* + * Test information retrieval from a control with boolean + * values. + */ + ControlInfo aeEnable({ false, true }, false); + + if (aeEnable.min().get() != false || + aeEnable.def().get() != false || + aeEnable.max().get() != true) { + cout << "Invalid control range for AeEnable" << endl; + return TestFail; + } + + if (aeEnable.values()[0].get() != false || + aeEnable.values()[1].get() != true) { + cout << "Invalid control values for AeEnable" << endl; + return TestFail; + } + + ControlInfo awbEnable(true); + + if (awbEnable.min().get() != true || + awbEnable.def().get() != true || + awbEnable.max().get() != true) { + cout << "Invalid control range for AwbEnable" << endl; + return TestFail; + } + + if (awbEnable.values()[0].get() != true) { + cout << "Invalid control values for AwbEnable" << endl; + return TestFail; + } + return TestPass; } }; From patchwork Tue Jul 20 10:13:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 13051 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 4D99BC0109 for ; Tue, 20 Jul 2021 10:13:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 10FAF68536; Tue, 20 Jul 2021 12:13:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="XYLtAY93"; dkim-atps=neutral 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 7DC8968545 for ; Tue, 20 Jul 2021 12:13:23 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0F40D51D; Tue, 20 Jul 2021 12:13:21 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626776003; bh=xj6Q2s9ieFwnt/fu+W8h11HgI+xs6p4AmUSCqNLCLcY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XYLtAY93XLW8o2B1ahgnozPMj3n+TJ+wDvRybZd9gEHvOYnACu+9Pw+1yMUVSmWAs cA5pD6eQU0VuElZkO1TzSjKfspEOv8r3e/Q9LvDXsoXxVjIKty4zL5/69mRalK4sJT I7rhjV+QgXsvYG/zZots53sdy7EnPFHjFjnlVc5Q= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Jul 2021 19:13:00 +0900 Message-Id: <20210720101307.26010-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210720101307.26010-1-paul.elder@ideasonboard.com> References: <20210720101307.26010-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 2/9] android: metadata: Add hasEntry and entryContains 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add convenience functions for checking if an entry is present in a CameraMetadata instance, and to check if an array entry includes a specific value. Signed-off-by: Paul Elder Reviewed-by: Jacopo Mondi --- Changes in v5: - refactor template code to reduce the footprint of specialized template code New in v4 --- src/android/camera_metadata.cpp | 18 ++++++++++++++++++ src/android/camera_metadata.h | 14 ++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/android/camera_metadata.cpp b/src/android/camera_metadata.cpp index 3fc7cf27..ac86c5fc 100644 --- a/src/android/camera_metadata.cpp +++ b/src/android/camera_metadata.cpp @@ -121,6 +121,24 @@ bool CameraMetadata::resize(size_t count, size_t size) return true; } +template<> +bool CameraMetadata::entryContainsOne(const camera_metadata_ro_entry_t &entry, + uint8_t value) const +{ + for (unsigned int i = 0; i < entry.count; i++) { + if (entry.data.u8[i] == value) + return true; + } + + return false; +} + +bool CameraMetadata::hasEntry(uint32_t tag) const +{ + camera_metadata_ro_entry_t entry; + return getEntry(tag, &entry); +} + bool CameraMetadata::addEntry(uint32_t tag, const void *data, size_t count, size_t elementSize) { diff --git a/src/android/camera_metadata.h b/src/android/camera_metadata.h index 3b7c9e24..72ba4db2 100644 --- a/src/android/camera_metadata.h +++ b/src/android/camera_metadata.h @@ -29,6 +29,20 @@ public: bool isValid() const { return valid_; } bool getEntry(uint32_t tag, camera_metadata_ro_entry_t *entry) const; + template + bool entryContainsOne(const camera_metadata_ro_entry_t &entry, T value) const; + + template bool entryContains(uint32_t tag, T value) const + { + camera_metadata_ro_entry_t entry; + if (!getEntry(tag, &entry)) + return false; + + return entryContainsOne(entry, value); + } + + bool hasEntry(uint32_t tag) const; + template> * = nullptr> bool addEntry(uint32_t tag, const T &data) From patchwork Tue Jul 20 10:13:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 13052 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 ACBDCC0109 for ; Tue, 20 Jul 2021 10:13:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6BCDD68548; Tue, 20 Jul 2021 12:13:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="QgRYHm0v"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A2F9E68542 for ; Tue, 20 Jul 2021 12:13:25 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DEB70443; Tue, 20 Jul 2021 12:13:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626776005; bh=VbLW1FiuGdE15Hs8cWDAmhkYGKTN+Pxz7VADKZyAqzM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QgRYHm0vBPHfpIQUgbvT/fGDjlmPyEul65OdeeDb7STvy39ElQwfNFyvzc6snM7jk YF24d0TGJrAMyZ2uX3agms7VIo5ZIWmtioG+TbYmgmoikNCEGniTc8ID37hFCUorxh go6MMSQFhIylIuq9fFNjiyGqV73mvlvDaj0fUQ/M= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Jul 2021 19:13:01 +0900 Message-Id: <20210720101307.26010-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210720101307.26010-1-paul.elder@ideasonboard.com> References: <20210720101307.26010-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 3/9] android: metadata: Fix addEntry template 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Since we set entries with android tags directly, which are enums and not arithmetic types, the addEntry template fails to match. Fix this by also allowing enum values in addEntry. Signed-off-by: Paul Elder Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- New in v4 --- src/android/camera_metadata.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/android/camera_metadata.h b/src/android/camera_metadata.h index 72ba4db2..6e51efb5 100644 --- a/src/android/camera_metadata.h +++ b/src/android/camera_metadata.h @@ -44,7 +44,8 @@ public: bool hasEntry(uint32_t tag) const; template> * = nullptr> + std::enable_if_t || + std::is_enum_v> * = nullptr> bool addEntry(uint32_t tag, const T &data) { return addEntry(tag, &data, 1, sizeof(T)); From patchwork Tue Jul 20 10:13:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 13053 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 137FBC0109 for ; Tue, 20 Jul 2021 10:13:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CAA0A68542; Tue, 20 Jul 2021 12:13:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="O9dKyBbQ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1F18668521 for ; Tue, 20 Jul 2021 12:13:28 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0DC41443; Tue, 20 Jul 2021 12:13:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626776007; bh=rz5X/sWfBsiMTCFJhar1UOJqv3uUzbLAu4rkrHCLTf0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O9dKyBbQCxBvKbw6J42RRbBEM3SyGoRmnYUACrk1GE4jvyMJBcZlYoEo+nHHYbdiJ GnGJHGZD9wXc2kSQEE+jz2sz72wsjAYHMnocJgcpjf1BK+SF4YZROifFlQ3LUT0ti7 I2tYzUczE7m1jKwxGUSfrlVbHELQPYzHMtyQ7pBI= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Jul 2021 19:13:02 +0900 Message-Id: <20210720101307.26010-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210720101307.26010-1-paul.elder@ideasonboard.com> References: <20210720101307.26010-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 4/9] android: jpeg: get ISO from SENSOR_SENSITIVITY 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The data for the exif ISO tag needs to come from SENSOR_SENSITIVITY. Set it. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- This on its own doesn't fix any CTS tests, but it prevents a test failure later on when we add the proper static metadata for the FULL hardware level. --- src/android/jpeg/post_processor_jpeg.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/android/jpeg/post_processor_jpeg.cpp b/src/android/jpeg/post_processor_jpeg.cpp index 0e93f365..3160a784 100644 --- a/src/android/jpeg/post_processor_jpeg.cpp +++ b/src/android/jpeg/post_processor_jpeg.cpp @@ -119,7 +119,10 @@ int PostProcessorJpeg::process(const FrameBuffer &source, ret = requestMetadata.getEntry(ANDROID_LENS_APERTURE, &entry); if (ret) exif.setAperture(*entry.data.f); - exif.setISO(100); + + ret = resultMetadata->getEntry(ANDROID_SENSOR_SENSITIVITY, &entry); + exif.setISO(ret ? *entry.data.i32 : 100); + exif.setFlash(Exif::Flash::FlashNotPresent); exif.setWhiteBalance(Exif::WhiteBalance::Auto); From patchwork Tue Jul 20 10:13:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 13054 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 70AAAC0109 for ; Tue, 20 Jul 2021 10:13:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 34D3D6854B; Tue, 20 Jul 2021 12:13:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qV2aSBf9"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DC98B68521 for ; Tue, 20 Jul 2021 12:13:29 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7DAA3443; Tue, 20 Jul 2021 12:13:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626776009; bh=h6yH//HaMU1rt8p2EyZSeEeXxJWP9BWQ68biLtq7QOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qV2aSBf9WmtWgRRCZVEstHmIkLKswI8DYTthpqEUuOHRfpZaIErRRmDeaAoJfbriw qegiONJHMpty6K45EGRus9PXXZVcDpfhpc0D+2oywz9GjIxc/sA/8agRgicxNBYGzN Xd2cCFukV7OOCofAwzVxK+8pw7+2jFq+TY26eq3U= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Jul 2021 19:13:03 +0900 Message-Id: <20210720101307.26010-6-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210720101307.26010-1-paul.elder@ideasonboard.com> References: <20210720101307.26010-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 5/9] android: Add infrastructure for determining capabilities and hardware level 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add the infrastructure for checking and reporting capabilities. Use these capabilities to determine the hardware level as well. Bug: https://bugs.libcamera.org/show_bug.cgi?id=55 Signed-off-by: Paul Elder --- I'm thinking that we should hardcode the validate* functions to return false for now until we add all the required capabilities. They cannot return true anyway until that happens. Changes in v6: - make all args const - convert the caps list from set to vector Changes in v5: - change the whole thing to turn on capabilities after they are all confirmed, instead of disabling them as conditions are not met Changes in v4: - rebase on camera capabilities refactoring - switch to std::set from std::map - make hwlevel similar to capabilities Changes in v3: - fix some compiler errors - go ahead and initialize the capabilities to true, update the commit message accordingly Changes in v2: - add a flag for FULL, since there are a few requirements that are not obtained from capabilities alone - add burst capture capability, since that is required for FULL as well --- src/android/camera_capabilities.cpp | 174 +++++++++++++++++++++++++--- src/android/camera_capabilities.h | 12 ++ 2 files changed, 171 insertions(+), 15 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 9e2714f1..c97a17e6 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -7,8 +7,10 @@ #include "camera_capabilities.h" +#include #include #include +#include #include @@ -114,8 +116,153 @@ const std::map camera3FormatsMap = { }, }; +const std::map +hwLevelStrings = { + { ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED, "LIMITED" }, + { ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL, "FULL" }, + { ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY, "LEGACY" }, + { ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_3, "LEVEL_3" }, + { ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL, "EXTERNAL" }, +}; + } /* namespace */ +bool CameraCapabilities::validateManualSensorCapability(const CameraMetadata *staticMetadata) +{ + camera_metadata_ro_entry_t entry; + bool found; + + const char *noMode = "Manual sensor capability unavailable: "; + + if (!(found = staticMetadata->entryContains(ANDROID_CONTROL_AE_AVAILABLE_MODES, + ANDROID_CONTROL_AE_MODE_OFF))) { + LOG(HAL, Info) + << noMode << "missing AE mode off: " + << (found ? "not supported" : "not found"); + return false; + } + + found = staticMetadata->getEntry(ANDROID_CONTROL_AE_LOCK_AVAILABLE, + &entry); + if (!found || !(*entry.data.u8 == ANDROID_CONTROL_AE_LOCK_AVAILABLE_TRUE)) { + LOG(HAL, Info) << noMode << "missing AE lock"; + return false; + } + + return true; +} + +bool CameraCapabilities::validateManualPostProcessingCapability(const CameraMetadata *staticMetadata) +{ + camera_metadata_ro_entry_t entry; + bool found; + + const char *noMode = "Manual post processing capability unavailable: "; + + if (!staticMetadata->entryContains(ANDROID_CONTROL_AWB_AVAILABLE_MODES, + ANDROID_CONTROL_AWB_MODE_OFF)) { + LOG(HAL, Info) << noMode << "missing AWB mode off"; + return false; + } + + found = staticMetadata->getEntry(ANDROID_CONTROL_AWB_LOCK_AVAILABLE, + &entry); + if (!found || !(*entry.data.u8 == ANDROID_CONTROL_AWB_LOCK_AVAILABLE_TRUE)) { + LOG(HAL, Info) << noMode << "missing AWB lock"; + return false; + } + + return true; +} + +bool CameraCapabilities::validateBurstCaptureCapability(const CameraMetadata *staticMetadata) +{ + camera_metadata_ro_entry_t entry; + bool found; + + const char *noMode = "Burst capture capability unavailable: "; + + found = staticMetadata->getEntry(ANDROID_CONTROL_AE_LOCK_AVAILABLE, + &entry); + if (!found || !(*entry.data.u8 == ANDROID_CONTROL_AE_LOCK_AVAILABLE_TRUE)) { + LOG(HAL, Info) << noMode << "missing AE lock"; + return false; + } + + found = staticMetadata->getEntry(ANDROID_CONTROL_AWB_LOCK_AVAILABLE, + &entry); + if (!found || !(*entry.data.u8 == ANDROID_CONTROL_AWB_LOCK_AVAILABLE_TRUE)) { + LOG(HAL, Info) << noMode << "missing AWB lock"; + return false; + } + + found = staticMetadata->getEntry(ANDROID_SYNC_MAX_LATENCY, &entry); + if (!found || *entry.data.i32 < 0 || 4 < *entry.data.i32) { + LOG(HAL, Info) + << noMode << "max sync latency is " + << (found ? std::to_string(*entry.data.i32) : "not present"); + return false; + } + + return true; +} + +std::vector +CameraCapabilities::computeCapabilities(const CameraMetadata *staticMetadata) +{ + std::vector + capabilities; + + capabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE); + + if (validateManualSensorCapability(staticMetadata)) + capabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR); + + if (validateManualPostProcessingCapability(staticMetadata)) + capabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING); + + if (validateBurstCaptureCapability(staticMetadata)) + capabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE); + + if (rawStreamAvailable_) + capabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW); + + return capabilities; +} + +camera_metadata_enum_android_info_supported_hardware_level +CameraCapabilities::computeHwLevel(const CameraMetadata *staticMetadata, + const std::vector &caps) +{ + camera_metadata_ro_entry_t entry; + bool found; + camera_metadata_enum_android_info_supported_hardware_level + hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL; + + if (std::find(caps.begin(), caps.end(), + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_SENSOR) == caps.end()) { + hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } + + if (std::find(caps.begin(), caps.end(), + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_MANUAL_POST_PROCESSING) == caps.end()) { + hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } + + if (std::find(caps.begin(), caps.end(), + ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BURST_CAPTURE) == caps.end()) { + hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + } + + found = staticMetadata->getEntry(ANDROID_SYNC_MAX_LATENCY, &entry); + if (!found || *entry.data.i32 != 0) + hwLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + + hwLevel_ = hwLevel; + + return hwLevel; +} + int CameraCapabilities::initialize(std::shared_ptr camera, int orientation, int facing) { @@ -840,11 +987,6 @@ int CameraCapabilities::initializeStaticMetadata() uint8_t croppingType = ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY; staticMetadata_->addEntry(ANDROID_SCALER_CROPPING_TYPE, croppingType); - /* Info static metadata. */ - uint8_t supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; - staticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, - supportedHWLevel); - /* Request static metadata. */ int32_t partialResultCount = 1; staticMetadata_->addEntry(ANDROID_REQUEST_PARTIAL_RESULT_COUNT, @@ -865,21 +1007,23 @@ int CameraCapabilities::initializeStaticMetadata() staticMetadata_->addEntry(ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS, maxNumInputStreams); - std::vector availableCapabilities = { - ANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE, - }; - - /* Report if camera supports RAW. */ - if (rawStreamAvailable_) - availableCapabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW); - /* Number of { RAW, YUV, JPEG } supported output streams */ int32_t numOutStreams[] = { rawStreamAvailable_, 2, 1 }; staticMetadata_->addEntry(ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, numOutStreams); - staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, - availableCapabilities); + /* Check capabilities */ + std::vector + capabilities = computeCapabilities(staticMetadata_.get()); + staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES, capabilities); + + camera_metadata_enum_android_info_supported_hardware_level hwLevel = + computeHwLevel(staticMetadata_.get(), capabilities); + staticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, hwLevel); + + LOG(HAL, Info) + << "Hardware level: " + << hwLevelStrings.find((camera_metadata_enum_android_info_supported_hardware_level)hwLevel)->second; std::vector availableCharacteristicsKeys = { ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h index 42a976d3..6ef81714 100644 --- a/src/android/camera_capabilities.h +++ b/src/android/camera_capabilities.h @@ -42,6 +42,17 @@ private: int androidFormat; }; + bool validateManualSensorCapability(const CameraMetadata *staticMetadata); + bool validateManualPostProcessingCapability(const CameraMetadata *staticMetadata); + bool validateBurstCaptureCapability(const CameraMetadata *staticMetadata); + + std::vector + computeCapabilities(const CameraMetadata *staticMetadata); + + camera_metadata_enum_android_info_supported_hardware_level + computeHwLevel(const CameraMetadata *staticMetadata, + const std::vector &caps); + std::vector initializeYUVResolutions(const libcamera::PixelFormat &pixelFormat, const std::vector &resolutions); @@ -56,6 +67,7 @@ private: int facing_; int orientation_; bool rawStreamAvailable_; + camera_metadata_enum_android_info_supported_hardware_level hwLevel_; std::vector streamConfigurations_; std::map formatsMap_; From patchwork Tue Jul 20 10:13:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 13055 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 2D490C0109 for ; Tue, 20 Jul 2021 10:13:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DADB76854A; Tue, 20 Jul 2021 12:13:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Ql6WQV4r"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BB29B68547 for ; Tue, 20 Jul 2021 12:13:31 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 57439443; Tue, 20 Jul 2021 12:13:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626776011; bh=d1X10EYGPM85ZodyM1tCiEIUhaOTFbIdzGP3+80v8Qw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ql6WQV4rVG3DMHGdzXCt7om0dds4IOCu1VM82Tg67HzeILUguK1hguZe0as4GovEX ypfn7i9mXhsCqBvP19aeItC1hi7/BnE4nu114DT0pS1LMJExrxjizq+XBOp2exBXN6 EPgL1ZoykxS5vAv8z8JwABmfXNT4il+5Dx4a9kGQ= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Jul 2021 19:13:04 +0900 Message-Id: <20210720101307.26010-7-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210720101307.26010-1-paul.elder@ideasonboard.com> References: <20210720101307.26010-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 6/9] android: Add helpers for setting android metadata from libcamera 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add helpers for setting android metadata from libcamera controls. There are two versions, for scalars and collections, both of which take a default value to fill in the android control if the libcamera control is not found. A version for scalars exists for no default, to not set the android control at all if it is not found in libcamera. The functions take two template parameters, the first for the android type, and the second for the libcamera type of the control. They can be different, for example, if the former is an enum and the latter is a boolean, or if the former is an enum (uint8_t) and the latter is an enum (int32_t). The versions that take a default value return the value that was set in the android metadata. Signed-off-by: Paul Elder --- Changes in v4: - remove vector copy from the vector setter Changes in v3: - setMetadata for collection only works with vectors - change enum to enum class - add two template parameters for android type and libcamera type - add docs New in v2 TODO: make ControlList versions so that we can use them in result metadata --- src/android/camera_capabilities.cpp | 137 ++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index c97a17e6..a8fa7ffe 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include @@ -125,6 +126,142 @@ hwLevelStrings = { { ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_EXTERNAL, "EXTERNAL" }, }; +enum class ControlRange { + Min, + Def, + Max, +}; + +/** + * \brief Set android metadata from libcamera ControlInfo + * \tparam T Type of the control in android + * \tparam V Type of the control in libcamera + * \param[in] metadata Android metadata pack to add the control value to + * \param[in] tag Android metadata tag + * \param[in] controlsInfo libcamera ControlInfoMap from which to find the control info + * \param[in] control libcamera ControlId to find from \a controlsInfo + * \param[in] controlRange Whether to use the min, def, or max value from the control info + * + * Set the android metadata entry in \a metadata with tag \a tag based on the + * control info found for the libcamera control \a control in the libcamera + * ControlInfoMap \a controlsInfo. If no libcamera ControlInfo is found, then + * the function returns without modifying anything. + * + * This function is for scalar values. + */ +template> * = nullptr, + typename V> +void setMetadata(CameraMetadata *metadata, uint32_t tag, + const ControlInfoMap &controlsInfo, const ControlId *control, + enum ControlRange controlRange) +{ + const auto &info = controlsInfo.find(control); + if (info == controlsInfo.end()) + return; + + T ret; + switch (controlRange) { + case ControlRange::Min: + ret = info->second.min().get(); + break; + case ControlRange::Def: + ret = info->second.def().get(); + break; + case ControlRange::Max: + ret = info->second.max().get(); + break; + } + + metadata->addEntry(tag, ret); + return; +} + +/** + * \brief Set android metadata from libcamera ControlInfo or a default value + * \tparam T Type of the control in android + * \tparam U Type of the control in libcamera + * \param[in] metadata Android metadata pack to add the control value to + * \param[in] tag Android metadata tag + * \param[in] controlsInfo libcamera ControlInfoMap from which to find the control info + * \param[in] control libcamera ControlId to find from \a controlsInfo + * \param[in] controlRange Whether to use the min, def, or max value from the control info + * \param[in] defaultValue The value to set in \a metadata if \a control is not found + * + * Set the android metadata entry in \a metadata with tag \a tag based on the + * control info found for the libcamera control \a control in the libcamera + * ControlInfoMap \a controlsInfo. If no libcamera ControlInfo is found, then + * the android metadata entry is set to \a defaultValue. + * + * This function is for scalar values. + */ +template || + std::is_enum_v> * = nullptr> +T setMetadata(CameraMetadata *metadata, uint32_t tag, + const ControlInfoMap &controlsInfo, const ControlId *control, + enum ControlRange controlRange, const V defaultValue) +{ + T ret = defaultValue; + + const auto &info = controlsInfo.find(control); + if (info != controlsInfo.end()) { + switch (controlRange) { + case ControlRange::Min: + ret = info->second.min().get(); + break; + case ControlRange::Def: + ret = info->second.def().get(); + break; + case ControlRange::Max: + ret = info->second.max().get(); + break; + } + } + + metadata->addEntry(tag, ret); + return ret; +} + +/** + * \brief Set android metadata from libcamera ControlInfo or a default value + * \tparam T Type of the control in android + * \tparam V Type of the control in libcamera + * \param[in] metadata Android metadata pack to add the control value to + * \param[in] tag Android metadata tag + * \param[in] controlsInfo libcamera ControlInfoMap from which to find the control info + * \param[in] control libcamera ControlId to find from \a controlsInfo + * \param[in] defaultVector The value to set in \a metadata if \a control is not found + * + * Set the android metadata entry in \a metadata with tag \a tag based on the + * control info found for the libcamera control \a control in the libcamera + * ControlInfoMap \a controlsInfo. If no libcamera ControlInfo is found, then + * the android metadata entry is set to \a defaultVector. + * + * This function is for vector values. + */ +template +std::vector setMetadata(CameraMetadata *metadata, uint32_t tag, + const ControlInfoMap &controlsInfo, + const ControlId *control, + const std::vector &defaultVector) +{ + const auto &info = controlsInfo.find(control); + if (info == controlsInfo.end()) { + metadata->addEntry(tag, defaultVector); + return defaultVector; + } + + std::vector ret(info->second.values().size()); + for (const auto &value : info->second.values()) + ret.push_back(value.get()); + metadata->addEntry(tag, ret); + + return ret; +} + } /* namespace */ bool CameraCapabilities::validateManualSensorCapability(const CameraMetadata *staticMetadata) From patchwork Tue Jul 20 10:13:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 13056 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 7A786C0109 for ; Tue, 20 Jul 2021 10:13:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 38EB268547; Tue, 20 Jul 2021 12:13:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="dJpa2Ro4"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D738D68547 for ; Tue, 20 Jul 2021 12:13:33 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 31004443; Tue, 20 Jul 2021 12:13:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626776013; bh=TYRcC+LHcqBXNE0KlIZ3hUJNeDIBmvrlSH7X9tcWsVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dJpa2Ro4ofZF8y7rfUxKZA0fWlVKjbbc32iMz2dcMMwcQ9xK1r5HjGVRjyPhemuHR Kz/v+BKdjD1kaJ1iyAf52ZHQICmNtf4i/EHxgGAT2+nRfA8Nq0+EnOz3MZHfv1By4e V3D4MUTSe+zmXP0bXBz7Jmdq6FqgjfwlyEmGqeYI= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Jul 2021 19:13:05 +0900 Message-Id: <20210720101307.26010-8-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210720101307.26010-1-paul.elder@ideasonboard.com> References: <20210720101307.26010-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 7/9] android: capabilities: Make keys list into set and member variable 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" We need to be able to add additional characteristics/request/result keys into the corresponding list in the static metadata based on libcamera camera capabilities. We also need to be able to easily check if the lists have specific keys, for populating templates and result metadata. Turn the characteristics, requests, and results keys vectors into sets, and move them to member variables to achieve this. Signed-off-by: Paul Elder Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_capabilities.cpp | 266 ++++++++++++++-------------- src/android/camera_capabilities.h | 5 + 2 files changed, 141 insertions(+), 130 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index a8fa7ffe..4048a94b 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -666,6 +666,136 @@ int CameraCapabilities::initializeStaticMetadata() const ControlInfoMap &controlsInfo = camera_->controls(); const ControlList &properties = camera_->properties(); + availableCharacteristicsKeys_ = { + ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, + ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, + ANDROID_CONTROL_AE_AVAILABLE_MODES, + ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, + ANDROID_CONTROL_AE_COMPENSATION_RANGE, + ANDROID_CONTROL_AE_COMPENSATION_STEP, + ANDROID_CONTROL_AE_LOCK_AVAILABLE, + ANDROID_CONTROL_AF_AVAILABLE_MODES, + ANDROID_CONTROL_AVAILABLE_EFFECTS, + ANDROID_CONTROL_AVAILABLE_MODES, + ANDROID_CONTROL_AVAILABLE_SCENE_MODES, + ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, + ANDROID_CONTROL_AWB_AVAILABLE_MODES, + ANDROID_CONTROL_AWB_LOCK_AVAILABLE, + ANDROID_CONTROL_MAX_REGIONS, + ANDROID_CONTROL_SCENE_MODE_OVERRIDES, + ANDROID_FLASH_INFO_AVAILABLE, + ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, + ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, + ANDROID_JPEG_MAX_SIZE, + ANDROID_LENS_FACING, + ANDROID_LENS_INFO_AVAILABLE_APERTURES, + ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, + ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION, + ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE, + ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, + ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, + ANDROID_REQUEST_AVAILABLE_CAPABILITIES, + ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS, + ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, + ANDROID_REQUEST_PARTIAL_RESULT_COUNT, + ANDROID_REQUEST_PIPELINE_MAX_DEPTH, + ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, + ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, + ANDROID_SCALER_AVAILABLE_STALL_DURATIONS, + ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, + ANDROID_SCALER_CROPPING_TYPE, + ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, + ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, + ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, + ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, + ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, + ANDROID_SENSOR_INFO_PHYSICAL_SIZE, + ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, + ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, + ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, + ANDROID_SENSOR_ORIENTATION, + ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, + ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, + ANDROID_SYNC_MAX_LATENCY, + }; + + availableRequestKeys_ = { + ANDROID_COLOR_CORRECTION_ABERRATION_MODE, + ANDROID_CONTROL_AE_ANTIBANDING_MODE, + ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, + ANDROID_CONTROL_AE_LOCK, + ANDROID_CONTROL_AE_MODE, + ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, + ANDROID_CONTROL_AE_TARGET_FPS_RANGE, + ANDROID_CONTROL_AF_MODE, + ANDROID_CONTROL_AF_TRIGGER, + ANDROID_CONTROL_AWB_LOCK, + ANDROID_CONTROL_AWB_MODE, + ANDROID_CONTROL_CAPTURE_INTENT, + ANDROID_CONTROL_EFFECT_MODE, + ANDROID_CONTROL_MODE, + ANDROID_CONTROL_SCENE_MODE, + ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, + ANDROID_FLASH_MODE, + ANDROID_JPEG_ORIENTATION, + ANDROID_JPEG_QUALITY, + ANDROID_JPEG_THUMBNAIL_QUALITY, + ANDROID_JPEG_THUMBNAIL_SIZE, + ANDROID_LENS_APERTURE, + ANDROID_LENS_OPTICAL_STABILIZATION_MODE, + ANDROID_NOISE_REDUCTION_MODE, + ANDROID_SCALER_CROP_REGION, + ANDROID_STATISTICS_FACE_DETECT_MODE + }; + + availableResultKeys_ = { + ANDROID_COLOR_CORRECTION_ABERRATION_MODE, + ANDROID_CONTROL_AE_ANTIBANDING_MODE, + ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, + ANDROID_CONTROL_AE_LOCK, + ANDROID_CONTROL_AE_MODE, + ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, + ANDROID_CONTROL_AE_STATE, + ANDROID_CONTROL_AE_TARGET_FPS_RANGE, + ANDROID_CONTROL_AF_MODE, + ANDROID_CONTROL_AF_STATE, + ANDROID_CONTROL_AF_TRIGGER, + ANDROID_CONTROL_AWB_LOCK, + ANDROID_CONTROL_AWB_MODE, + ANDROID_CONTROL_AWB_STATE, + ANDROID_CONTROL_CAPTURE_INTENT, + ANDROID_CONTROL_EFFECT_MODE, + ANDROID_CONTROL_MODE, + ANDROID_CONTROL_SCENE_MODE, + ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, + ANDROID_FLASH_MODE, + ANDROID_FLASH_STATE, + ANDROID_JPEG_GPS_COORDINATES, + ANDROID_JPEG_GPS_PROCESSING_METHOD, + ANDROID_JPEG_GPS_TIMESTAMP, + ANDROID_JPEG_ORIENTATION, + ANDROID_JPEG_QUALITY, + ANDROID_JPEG_SIZE, + ANDROID_JPEG_THUMBNAIL_QUALITY, + ANDROID_JPEG_THUMBNAIL_SIZE, + ANDROID_LENS_APERTURE, + ANDROID_LENS_FOCAL_LENGTH, + ANDROID_LENS_OPTICAL_STABILIZATION_MODE, + ANDROID_LENS_STATE, + ANDROID_NOISE_REDUCTION_MODE, + ANDROID_REQUEST_PIPELINE_DEPTH, + ANDROID_SCALER_CROP_REGION, + ANDROID_SENSOR_EXPOSURE_TIME, + ANDROID_SENSOR_FRAME_DURATION, + ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, + ANDROID_SENSOR_TEST_PATTERN_MODE, + ANDROID_SENSOR_TIMESTAMP, + ANDROID_STATISTICS_FACE_DETECT_MODE, + ANDROID_STATISTICS_LENS_SHADING_MAP_MODE, + ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE, + ANDROID_STATISTICS_SCENE_FLICKER, + }; + /* Color correction static metadata. */ { std::vector data; @@ -1162,141 +1292,17 @@ int CameraCapabilities::initializeStaticMetadata() << "Hardware level: " << hwLevelStrings.find((camera_metadata_enum_android_info_supported_hardware_level)hwLevel)->second; - std::vector availableCharacteristicsKeys = { - ANDROID_COLOR_CORRECTION_AVAILABLE_ABERRATION_MODES, - ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES, - ANDROID_CONTROL_AE_AVAILABLE_MODES, - ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, - ANDROID_CONTROL_AE_COMPENSATION_RANGE, - ANDROID_CONTROL_AE_COMPENSATION_STEP, - ANDROID_CONTROL_AE_LOCK_AVAILABLE, - ANDROID_CONTROL_AF_AVAILABLE_MODES, - ANDROID_CONTROL_AVAILABLE_EFFECTS, - ANDROID_CONTROL_AVAILABLE_MODES, - ANDROID_CONTROL_AVAILABLE_SCENE_MODES, - ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, - ANDROID_CONTROL_AWB_AVAILABLE_MODES, - ANDROID_CONTROL_AWB_LOCK_AVAILABLE, - ANDROID_CONTROL_MAX_REGIONS, - ANDROID_CONTROL_SCENE_MODE_OVERRIDES, - ANDROID_FLASH_INFO_AVAILABLE, - ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, - ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, - ANDROID_JPEG_MAX_SIZE, - ANDROID_LENS_FACING, - ANDROID_LENS_INFO_AVAILABLE_APERTURES, - ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, - ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION, - ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE, - ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, - ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, - ANDROID_REQUEST_AVAILABLE_CAPABILITIES, - ANDROID_REQUEST_MAX_NUM_INPUT_STREAMS, - ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, - ANDROID_REQUEST_PARTIAL_RESULT_COUNT, - ANDROID_REQUEST_PIPELINE_MAX_DEPTH, - ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, - ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, - ANDROID_SCALER_AVAILABLE_STALL_DURATIONS, - ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, - ANDROID_SCALER_CROPPING_TYPE, - ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, - ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, - ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, - ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, - ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, - ANDROID_SENSOR_INFO_PHYSICAL_SIZE, - ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, - ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, - ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, - ANDROID_SENSOR_ORIENTATION, - ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, - ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, - ANDROID_SYNC_MAX_LATENCY, - }; staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, - availableCharacteristicsKeys); + std::vector(availableCharacteristicsKeys_.begin(), + availableCharacteristicsKeys_.end())); - std::vector availableRequestKeys = { - ANDROID_COLOR_CORRECTION_ABERRATION_MODE, - ANDROID_CONTROL_AE_ANTIBANDING_MODE, - ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, - ANDROID_CONTROL_AE_LOCK, - ANDROID_CONTROL_AE_MODE, - ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, - ANDROID_CONTROL_AE_TARGET_FPS_RANGE, - ANDROID_CONTROL_AF_MODE, - ANDROID_CONTROL_AF_TRIGGER, - ANDROID_CONTROL_AWB_LOCK, - ANDROID_CONTROL_AWB_MODE, - ANDROID_CONTROL_CAPTURE_INTENT, - ANDROID_CONTROL_EFFECT_MODE, - ANDROID_CONTROL_MODE, - ANDROID_CONTROL_SCENE_MODE, - ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, - ANDROID_FLASH_MODE, - ANDROID_JPEG_ORIENTATION, - ANDROID_JPEG_QUALITY, - ANDROID_JPEG_THUMBNAIL_QUALITY, - ANDROID_JPEG_THUMBNAIL_SIZE, - ANDROID_LENS_APERTURE, - ANDROID_LENS_OPTICAL_STABILIZATION_MODE, - ANDROID_NOISE_REDUCTION_MODE, - ANDROID_SCALER_CROP_REGION, - ANDROID_STATISTICS_FACE_DETECT_MODE - }; staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_REQUEST_KEYS, - availableRequestKeys); + std::vector(availableRequestKeys_.begin(), + availableRequestKeys_.end())); - std::vector availableResultKeys = { - ANDROID_COLOR_CORRECTION_ABERRATION_MODE, - ANDROID_CONTROL_AE_ANTIBANDING_MODE, - ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION, - ANDROID_CONTROL_AE_LOCK, - ANDROID_CONTROL_AE_MODE, - ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER, - ANDROID_CONTROL_AE_STATE, - ANDROID_CONTROL_AE_TARGET_FPS_RANGE, - ANDROID_CONTROL_AF_MODE, - ANDROID_CONTROL_AF_STATE, - ANDROID_CONTROL_AF_TRIGGER, - ANDROID_CONTROL_AWB_LOCK, - ANDROID_CONTROL_AWB_MODE, - ANDROID_CONTROL_AWB_STATE, - ANDROID_CONTROL_CAPTURE_INTENT, - ANDROID_CONTROL_EFFECT_MODE, - ANDROID_CONTROL_MODE, - ANDROID_CONTROL_SCENE_MODE, - ANDROID_CONTROL_VIDEO_STABILIZATION_MODE, - ANDROID_FLASH_MODE, - ANDROID_FLASH_STATE, - ANDROID_JPEG_GPS_COORDINATES, - ANDROID_JPEG_GPS_PROCESSING_METHOD, - ANDROID_JPEG_GPS_TIMESTAMP, - ANDROID_JPEG_ORIENTATION, - ANDROID_JPEG_QUALITY, - ANDROID_JPEG_SIZE, - ANDROID_JPEG_THUMBNAIL_QUALITY, - ANDROID_JPEG_THUMBNAIL_SIZE, - ANDROID_LENS_APERTURE, - ANDROID_LENS_FOCAL_LENGTH, - ANDROID_LENS_OPTICAL_STABILIZATION_MODE, - ANDROID_LENS_STATE, - ANDROID_NOISE_REDUCTION_MODE, - ANDROID_REQUEST_PIPELINE_DEPTH, - ANDROID_SCALER_CROP_REGION, - ANDROID_SENSOR_EXPOSURE_TIME, - ANDROID_SENSOR_FRAME_DURATION, - ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, - ANDROID_SENSOR_TEST_PATTERN_MODE, - ANDROID_SENSOR_TIMESTAMP, - ANDROID_STATISTICS_FACE_DETECT_MODE, - ANDROID_STATISTICS_LENS_SHADING_MAP_MODE, - ANDROID_STATISTICS_HOT_PIXEL_MAP_MODE, - ANDROID_STATISTICS_SCENE_FLICKER, - }; staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_RESULT_KEYS, - availableResultKeys); + std::vector(availableResultKeys_.begin(), + availableResultKeys_.end())); if (!staticMetadata_->isValid()) { LOG(HAL, Error) << "Failed to construct static metadata"; diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h index 6ef81714..e0c2786b 100644 --- a/src/android/camera_capabilities.h +++ b/src/android/camera_capabilities.h @@ -9,6 +9,7 @@ #include #include +#include #include #include @@ -73,6 +74,10 @@ private: std::map formatsMap_; std::unique_ptr staticMetadata_; unsigned int maxJpegBufferSize_; + + std::set availableCharacteristicsKeys_; + std::set availableRequestKeys_; + std::set availableResultKeys_; }; #endif /* __ANDROID_CAMERA_CAPABILITIES_H__ */ From patchwork Tue Jul 20 10:13:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 13057 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 D1075C0109 for ; Tue, 20 Jul 2021 10:13:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 94C8568550; Tue, 20 Jul 2021 12:13:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="CAXbMsqB"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1685368541 for ; Tue, 20 Jul 2021 12:13:36 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 55D5B51D; Tue, 20 Jul 2021 12:13:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626776015; bh=glE8P1C2yIQv2kk1hPmHaoL/GPVfbGpOaNGOaLZEG8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CAXbMsqBrggsafhQBya4clRQvMDXWEg3iJwXI3oddr5Mse0U7XJFz+FAtzgKBktB/ 28bYgkSC6MzdnwAsa25g81XQ/bSmYUCLCTBKYz4EQDZlzgv8ctuMAU5DylUZcuf0JE IyQ8ukqMTvrBg5r452NQJOZq3nYJP6cXCc2wEg4s= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Jul 2021 19:13:06 +0900 Message-Id: <20210720101307.26010-9-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210720101307.26010-1-paul.elder@ideasonboard.com> References: <20210720101307.26010-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 8/9] android: Add skeletal still and manual request templates 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add skeletal still and manual request templates so that we can expand them for FULL support. Signed-off-by: Paul Elder Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_capabilities.cpp | 18 ++++++++++++++++++ src/android/camera_capabilities.h | 2 ++ src/android/camera_device.cpp | 7 +++++-- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 4048a94b..8c425138 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -1445,3 +1445,21 @@ std::unique_ptr CameraCapabilities::requestTemplateVideo() const return previewTemplate; } + +std::unique_ptr CameraCapabilities::requestTemplateStill() const +{ + std::unique_ptr stillTemplate = requestTemplatePreview(); + if (!stillTemplate) + return nullptr; + + return stillTemplate; +} + +std::unique_ptr CameraCapabilities::requestTemplateManual() const +{ + std::unique_ptr manualTemplate = requestTemplatePreview(); + if (!manualTemplate) + return nullptr; + + return manualTemplate; +} diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h index e0c2786b..b9395544 100644 --- a/src/android/camera_capabilities.h +++ b/src/android/camera_capabilities.h @@ -34,6 +34,8 @@ public: std::unique_ptr requestTemplatePreview() const; std::unique_ptr requestTemplateVideo() const; + std::unique_ptr requestTemplateStill() const; + std::unique_ptr requestTemplateManual() const; private: LIBCAMERA_DISABLE_COPY_AND_MOVE(CameraCapabilities) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 678cde23..692d0a5b 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -487,7 +487,7 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type) * for the torch mode we currently do not support. */ captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE; - requestTemplate = capabilities_.requestTemplatePreview(); + requestTemplate = capabilities_.requestTemplateStill(); break; case CAMERA3_TEMPLATE_VIDEO_RECORD: captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD; @@ -497,9 +497,12 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type) captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT; requestTemplate = capabilities_.requestTemplateVideo(); break; + case CAMERA3_TEMPLATE_MANUAL: + captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_MANUAL; + requestTemplate = capabilities_.requestTemplateManual(); + break; /* \todo Implement templates generation for the remaining use cases. */ case CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG: - case CAMERA3_TEMPLATE_MANUAL: default: LOG(HAL, Error) << "Unsupported template request type: " << type; return nullptr; From patchwork Tue Jul 20 10:13:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 13058 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 32289C0109 for ; Tue, 20 Jul 2021 10:13:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E5F7068536; Tue, 20 Jul 2021 12:13:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="HaNPIqEf"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 954AE68547 for ; Tue, 20 Jul 2021 12:13:38 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 937FA443; Tue, 20 Jul 2021 12:13:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626776018; bh=czes8D+IRFHoIjzwO7glNFtCkmRWn6OMXtUdhOZwcuw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HaNPIqEf1yxeSLKa93eySX9+0UljRj31Idw44MI8Eh0N1Pidwu/jTup0ZTpyeu4dp BN5Rd4NXTGUo4/j68mtiYs10jwgxVvjElC7kcgI8UKntDWyshxDC52crd7bXNtg/aO fDIBbgHOBPYwFeDMZswHZdSSyvzJ8iymzX2ok7QY= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Tue, 20 Jul 2021 19:13:07 +0900 Message-Id: <20210720101307.26010-10-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210720101307.26010-1-paul.elder@ideasonboard.com> References: <20210720101307.26010-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 9/9] android, controls: Add and plumb MaxLatency 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a MaxLatency control, and plumb it into the HAL accordingly. Bug: https://bugs.libcamera.org/show_bug.cgi?id=50 Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- Changes in v3: - use v3 setMetadata - add comment to explain 4 - remove todo Changes in v2: - use new setMetadata - rebase on camera capabilities refactor --- src/android/camera_capabilities.cpp | 7 +++++-- src/libcamera/control_ids.yaml | 10 ++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 8c425138..5010289b 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -1130,8 +1130,11 @@ int CameraCapabilities::initializeStaticMetadata() } /* Sync static metadata. */ - int32_t maxLatency = ANDROID_SYNC_MAX_LATENCY_UNKNOWN; - staticMetadata_->addEntry(ANDROID_SYNC_MAX_LATENCY, maxLatency); + setMetadata( + staticMetadata_.get(), ANDROID_SYNC_MAX_LATENCY, + controlsInfo, &controls::draft::MaxLatency, + ControlRange::Def, + ANDROID_SYNC_MAX_LATENCY_UNKNOWN); /* Flash static metadata. */ char flashAvailable = ANDROID_FLASH_INFO_AVAILABLE_FALSE; diff --git a/src/libcamera/control_ids.yaml b/src/libcamera/control_ids.yaml index d92f29f5..9d4638ae 100644 --- a/src/libcamera/control_ids.yaml +++ b/src/libcamera/control_ids.yaml @@ -622,6 +622,16 @@ controls: detection, additional format conversions etc) count as an additional pipeline stage. + - MaxLatency: + type: int32_t + draft: true + description: | + The maximum number of frames that can occur after a request (different + than the previous) has been submitted, and before the result's state + becomes synchronized. A value of -1 indicates unknown latency, and 0 + indicates per-frame control. Currently identical to + ANDROID_SYNC_MAX_LATENCY. + - TestPatternMode: type: int32_t draft: true