From patchwork Thu Jul 2 21:40:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8565 X-Patchwork-Delegate: kieran.bingham@ideasonboard.com 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 9FAA3BFFE2 for ; Thu, 2 Jul 2020 21:40:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 35E4C60C59; Thu, 2 Jul 2020 23:40:14 +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="SF5MmbN4"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 268F7603B4 for ; Thu, 2 Jul 2020 23:40:13 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 96D2E9CB; Thu, 2 Jul 2020 23:40:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593726012; bh=6GtpFet9ghgfi2Mzx4j35GnpTc20K7X/RaH3wiOVkqE=; h=From:To:Cc:Subject:Date:From; b=SF5MmbN4KjYyVB3b+SYGdfurfirc6bqC0ifDStU9jcuJNciiP7YgcNkn+Gkju/RRV JkHXoY8VryB+io7aiq13qbE11uYsk4comuaCMJoXWKlAnypqO+GPchwX5qGtje859k 7FBV3mh/x3e7l5rsdUgevI3d17/IrjU+SP1mRSq4= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:40:09 +0100 Message-Id: <20200702214009.2129404-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH][RFC/UNTESTED] android: camera_metadata: Track tags of each entry added 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" Provide automatic tracking of tags added to automatically report the keys used for the entry: ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, This allows automatic addition of added keys without having to manually maintain the list in the code base. Signed-off-by: Kieran Bingham --- src/android/camera_device.cpp | 57 ++++----------------------------- src/android/camera_metadata.cpp | 4 ++- src/android/camera_metadata.h | 4 +++ 3 files changed, 13 insertions(+), 52 deletions(-) Sending this, completely untested because ... that's how I roll, and I wanted to know if this is a reasonable route to reduce maintainance burden. A next step beyond this is also to consider a two-pass iteration on all of the meta-data structures, where the first pass will determine the number of entries, and bytes required, while the second pass will actually populate the android metadata. Anythoughts on this? It would mean processing the entries twice, but would stop the guessing game of 'is there enough memory allocated here'... diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 5a3b4dfae6a0..de73c31ed3ea 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -721,58 +721,13 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() availableCapabilities.data(), availableCapabilities.size()); - 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_AF_AVAILABLE_MODES, - ANDROID_CONTROL_AVAILABLE_EFFECTS, - ANDROID_CONTROL_AVAILABLE_SCENE_MODES, - ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES, - ANDROID_CONTROL_AWB_AVAILABLE_MODES, - ANDROID_CONTROL_MAX_REGIONS, - ANDROID_CONTROL_SCENE_MODE_OVERRIDES, - ANDROID_CONTROL_AE_LOCK_AVAILABLE, - ANDROID_CONTROL_AWB_LOCK_AVAILABLE, - ANDROID_CONTROL_AVAILABLE_MODES, - ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, - ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, - ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, - ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, - ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, - ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, - ANDROID_SENSOR_ORIENTATION, - ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, - ANDROID_SENSOR_INFO_PHYSICAL_SIZE, - ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, - ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, - ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, - ANDROID_SYNC_MAX_LATENCY, - ANDROID_FLASH_INFO_AVAILABLE, - ANDROID_LENS_INFO_AVAILABLE_APERTURES, - ANDROID_LENS_FACING, - 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_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, - ANDROID_SCALER_AVAILABLE_FORMATS, - ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS, - ANDROID_SCALER_AVAILABLE_STALL_DURATIONS, - ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, - ANDROID_SCALER_CROPPING_TYPE, - ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, - ANDROID_REQUEST_PARTIAL_RESULT_COUNT, - ANDROID_REQUEST_PIPELINE_MAX_DEPTH, - ANDROID_REQUEST_AVAILABLE_CAPABILITIES, - }; + /* + * All tags added to staticMetadata_ to this point are added + * as keys for the available characteristics. + */ staticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, - availableCharacteristicsKeys.data(), - availableCharacteristicsKeys.size()); + staticMetadata_->tags().data(), + staticMetadata_->tags().size()); std::vector availableRequestKeys = { ANDROID_CONTROL_AE_MODE, diff --git a/src/android/camera_metadata.cpp b/src/android/camera_metadata.cpp index 47b2e4ef117a..15b569aea52b 100644 --- a/src/android/camera_metadata.cpp +++ b/src/android/camera_metadata.cpp @@ -30,8 +30,10 @@ bool CameraMetadata::addEntry(uint32_t tag, const void *data, size_t count) if (!valid_) return false; - if (!add_camera_metadata_entry(metadata_, tag, data, count)) + if (!add_camera_metadata_entry(metadata_, tag, data, count)) { + tags_.push_back(tag); return true; + } const char *name = get_camera_metadata_tag_name(tag); if (name) diff --git a/src/android/camera_metadata.h b/src/android/camera_metadata.h index 75a9d7066f31..a0e23119e68f 100644 --- a/src/android/camera_metadata.h +++ b/src/android/camera_metadata.h @@ -8,6 +8,7 @@ #define __ANDROID_CAMERA_METADATA_H__ #include +#include #include @@ -20,10 +21,13 @@ public: bool isValid() { return valid_; } bool addEntry(uint32_t tag, const void *data, size_t data_count); + const std::vector &tags() { return tags_; } + camera_metadata_t *get(); private: camera_metadata_t *metadata_; + std::vector tags_; bool valid_; };