From patchwork Tue Jan 26 17:30:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11017 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 6C1FBBD808 for ; Tue, 26 Jan 2021 17:29:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C634B6832A; Tue, 26 Jan 2021 18:29:55 +0100 (CET) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8D90868318 for ; Tue, 26 Jan 2021 18:29:53 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 59E95E0002 for ; Tue, 26 Jan 2021 17:29:53 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 18:30:03 +0100 Message-Id: <20210126173008.446321-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126173008.446321-1-jacopo@jmondi.org> References: <20210126173008.446321-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/6] libcamera: camera_sensor: Make VBLANK mandatory 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 V4L2_CID_VBLANK control to the list of mandatory controls the sensor driver has to report and document the new requirement. The vertical blanking control is used to calculate the frame duration. Signed-off-by: Jacopo Mondi --- Documentation/sensor_driver_requirements.rst | 6 ++++-- src/libcamera/camera_sensor.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Documentation/sensor_driver_requirements.rst b/Documentation/sensor_driver_requirements.rst index 6dcd4e68d64d..590797f054ce 100644 --- a/Documentation/sensor_driver_requirements.rst +++ b/Documentation/sensor_driver_requirements.rst @@ -27,18 +27,20 @@ The sensor driver shall support the following V4L2 controls: * `V4L2_CID_EXPOSURE`_ * `V4L2_CID_HBLANK`_ * `V4L2_CID_PIXEL_RATE`_ +* `V4L2_CID_VBLANK`_ .. _V4L2_CID_EXPOSURE: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/control.html .. _V4L2_CID_HBLANK: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/ext-ctrls-image-source.html .. _V4L2_CID_PIXEL_RATE: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/ext-ctrls-image-process.html +.. _V4L2_CID_VBLANK: https://www.kernel.org/doc/html/latest/userspace-api/media/v4l/ext-ctrls-image-source.html While V4L2 doesn't specify a unit for the `EXPOSURE` control, libcamera requires it to be expressed as a number of image lines. Camera sensor drivers that do not comply with this requirement will need to be adapted or will produce incorrect results. -The `HBLANK` and `PIXEL_RATE` controls are used to compute the sensor output -timings. +The `HBLANK`, `PIXEL_RATE` and `VBLANK` controls are used to compute the sensor +output timings. Optional Requirements --------------------- diff --git a/src/libcamera/camera_sensor.cpp b/src/libcamera/camera_sensor.cpp index ca33c0094088..ab315bdc468c 100644 --- a/src/libcamera/camera_sensor.cpp +++ b/src/libcamera/camera_sensor.cpp @@ -244,6 +244,7 @@ int CameraSensor::validateSensorDriver() V4L2_CID_EXPOSURE, V4L2_CID_HBLANK, V4L2_CID_PIXEL_RATE, + V4L2_CID_VBLANK, }; ControlList ctrls = subdev_->getControls(mandatoryControls); From patchwork Tue Jan 26 17:30:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11018 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 F0EFFBD808 for ; Tue, 26 Jan 2021 17:29:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 84E9E6832D; Tue, 26 Jan 2021 18:29:56 +0100 (CET) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E267268318 for ; Tue, 26 Jan 2021 18:29:53 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id B14A7E0009 for ; Tue, 26 Jan 2021 17:29:53 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 18:30:04 +0100 Message-Id: <20210126173008.446321-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126173008.446321-1-jacopo@jmondi.org> References: <20210126173008.446321-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/6] libcamera: ipu3: Register FrameDurations 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" Register the FrameDurations control in the IPU3 pipeline handler computed using the vertical blanking limits and the current configuration pixel rate as parameters. The FrameDurations control limits should be updated everytime a new configuration is applied to the sensor. Signed-off-by: Jacopo Mondi --- src/libcamera/pipeline/ipu3/ipu3.cpp | 35 +++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp index db0d6b91be70..fe5694f9893a 100644 --- a/src/libcamera/pipeline/ipu3/ipu3.cpp +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp @@ -754,6 +754,7 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) return ret; ControlInfoMap::Map controls = IPU3Controls; + const ControlInfoMap &sensorControls = sensor->controls(); /* * Compute exposure time limits. @@ -766,7 +767,6 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) */ double lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6); - const ControlInfoMap &sensorControls = sensor->controls(); const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second; int32_t minExposure = v4l2Exposure.min().get() * lineDuration; int32_t maxExposure = v4l2Exposure.max().get() * lineDuration; @@ -781,6 +781,39 @@ int PipelineHandlerIPU3::initControls(IPU3CameraData *data) controls[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure, defExposure); + /* + * Compute the frame duration limits. + * + * \todo The frame duration limits depend on the sensor configuration. + * Initialize the control using the frame sizes and pixel rate of the + * current configuration. + * + * The frame length is computed assuming a fixed line length combined + * with the vertical frame sizes. + */ + const ControlInfo &v4l2HBlank = sensorControls.find(V4L2_CID_HBLANK)->second; + uint32_t hblank = v4l2HBlank.def().get(); + uint32_t lineLength = sensorInfo.outputSize.width + hblank; + + const ControlInfo &v4l2VBlank = sensorControls.find(V4L2_CID_VBLANK)->second; + std::array frameHeights{ + (v4l2VBlank.min().get() + sensorInfo.outputSize.height), + (v4l2VBlank.max().get() + sensorInfo.outputSize.height), + (v4l2VBlank.def().get() + sensorInfo.outputSize.height), + }; + + std::vector frameDurations; + frameDurations.reserve(3); + std::transform(frameHeights.begin(), frameHeights.end(), + std::back_inserter(frameDurations), + [&](int32_t frameHeight) { + int64_t frameSize = lineLength * frameHeight; + return frameSize / (sensorInfo.pixelRate / 1000000U); + }); + controls[&controls::FrameDurations] = ControlInfo(frameDurations[0], + frameDurations[1], + frameDurations[2]); + /* * Compute the scaler crop limits. * From patchwork Tue Jan 26 17:30:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11019 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 99121BD808 for ; Tue, 26 Jan 2021 17:29:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DCF2D68331; Tue, 26 Jan 2021 18:29:57 +0100 (CET) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 426A16831B for ; Tue, 26 Jan 2021 18:29:54 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 0F6FAE0009 for ; Tue, 26 Jan 2021 17:29:53 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 18:30:05 +0100 Message-Id: <20210126173008.446321-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126173008.446321-1-jacopo@jmondi.org> References: <20210126173008.446321-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/6] android: camera_device: Compute frame durations 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" Use the FrameDuration control reported by pipeline handlers to register the Auto-Exposure routine FPS range, the minimum stream frame durations and the sensor maximum frame duration. Signed-off-by: Jacopo Mondi --- src/android/camera_device.cpp | 72 +++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 20 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 1a384460974c..e3d43bea4700 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -9,6 +9,7 @@ #include "camera_ops.h" #include "post_processor.h" +#include #include #include #include @@ -682,10 +683,10 @@ std::tuple CameraDevice::calculateStaticMetadataSize() { /* * \todo Keep this in sync with the actual number of entries. - * Currently: 53 entries, 782 bytes of static metadata + * Currently: 54 entries, 802 bytes of static metadata */ - uint32_t numEntries = 53; - uint32_t byteSize = 782; + uint32_t numEntries = 54; + uint32_t byteSize = 802; /* * Calculate space occupation in bytes for dynamically built metadata @@ -760,12 +761,34 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() aeAvailableModes.data(), aeAvailableModes.size()); - std::vector availableAeFpsTarget = { - 15, 30, - }; - staticMetadata_->addEntry(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, - availableAeFpsTarget.data(), - availableAeFpsTarget.size()); + int64_t minFrameDurationUsec = -1; + int64_t maxFrameDurationUsec = -1; + const auto frameDurationsInfo = controlsInfo.find(&controls::FrameDurations); + if (frameDurationsInfo != controlsInfo.end()) { + minFrameDurationUsec = frameDurationsInfo->second.min().get(); + maxFrameDurationUsec = frameDurationsInfo->second.max().get(); + + /* + * The AE routine frame rate limits are computed using the frame + * duration limits, as libcamera clips the AE routine to the + * frame durations. + */ + int32_t minFps = static_cast(::round(1000000.0f / + maxFrameDurationUsec)); + minFps = std::max(1, minFps); + int maxFps = static_cast(::round(1000000.0f / + minFrameDurationUsec)); + + /* + * Register to the camera service {min, max} and {max, max} + * intervals as requested by the metadata documentation. + */ + int32_t availableAeFpsTarget[] = { + minFps, maxFps, maxFps, maxFps + }; + staticMetadata_->addEntry(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, + availableAeFpsTarget, 4); + } std::vector aeCompensationRange = { 0, 0, @@ -929,6 +952,12 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, ×tampSource, 1); + if (maxFrameDurationUsec > 0) { + int64_t maxFrameDuration = maxFrameDurationUsec * 1000; + staticMetadata_->addEntry(ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, + &maxFrameDuration, 1); + } + /* Statistics static metadata. */ uint8_t faceDetectMode = ANDROID_STATISTICS_FACE_DETECT_MODE_OFF; staticMetadata_->addEntry(ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, @@ -1063,18 +1092,20 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() availableStallDurations.data(), availableStallDurations.size()); - /* \todo Collect the minimum frame duration from the camera. */ - std::vector minFrameDurations; - minFrameDurations.reserve(streamConfigurations_.size() * 4); - for (const auto &entry : streamConfigurations_) { - minFrameDurations.push_back(entry.androidFormat); - minFrameDurations.push_back(entry.resolution.width); - minFrameDurations.push_back(entry.resolution.height); - minFrameDurations.push_back(33333333); + /* Use the minimum frame duration for all the YUV/RGB formats. */ + if (minFrameDurationUsec > 0) { + std::vector minFrameDurations; + minFrameDurations.reserve(streamConfigurations_.size() * 4); + for (const auto &entry : streamConfigurations_) { + minFrameDurations.push_back(entry.androidFormat); + minFrameDurations.push_back(entry.resolution.width); + minFrameDurations.push_back(entry.resolution.height); + minFrameDurations.push_back(minFrameDurationUsec * 1000); + } + staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, + minFrameDurations.data(), + minFrameDurations.size()); } - staticMetadata_->addEntry(ANDROID_SCALER_AVAILABLE_MIN_FRAME_DURATIONS, - minFrameDurations.data(), - minFrameDurations.size()); uint8_t croppingType = ANDROID_SCALER_CROPPING_TYPE_CENTER_ONLY; staticMetadata_->addEntry(ANDROID_SCALER_CROPPING_TYPE, &croppingType, 1); @@ -1156,6 +1187,7 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, ANDROID_SENSOR_INFO_COLOR_FILTER_ARRANGEMENT, ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, + ANDROID_SENSOR_INFO_MAX_FRAME_DURATION, ANDROID_SENSOR_ORIENTATION, ANDROID_SENSOR_AVAILABLE_TEST_PATTERN_MODES, ANDROID_SENSOR_INFO_PHYSICAL_SIZE, From patchwork Tue Jan 26 17:30:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11020 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 15369BD808 for ; Tue, 26 Jan 2021 17:29:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 048BA68334; Tue, 26 Jan 2021 18:29:58 +0100 (CET) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C1BD6831B for ; Tue, 26 Jan 2021 18:29:54 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 66E57E000A for ; Tue, 26 Jan 2021 17:29:54 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 18:30:06 +0100 Message-Id: <20210126173008.446321-5-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126173008.446321-1-jacopo@jmondi.org> References: <20210126173008.446321-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/6] fixup! android: camera_device: Compute frame durations 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" --- src/android/camera_device.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) Reviewed-by: Laurent Pinchart diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index e3d43bea4700..5a8072a8a007 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -768,6 +768,26 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() minFrameDurationUsec = frameDurationsInfo->second.min().get(); maxFrameDurationUsec = frameDurationsInfo->second.max().get(); + /* + * Adjust the minimum frame duration to comply with Android + * requirements. The camera service mandates all preview/record + * streams to have a minimum frame duration < 33,366 milliseconds + * (see MAX_PREVIEW_RECORD_DURATION_NS in the camera service + * implementation). + * + * If we're close enough (+- 500 useconds) to that value round + * the minimum frame duration of the camera to an accepted + * value. + */ + static constexpr double MIN_PREVIEW_RECORD_FPS = 29.97; + static constexpr int64_t MAX_PREVIEW_RECORD_DURATION_US = 1e6 / MIN_PREVIEW_RECORD_FPS; + if (minFrameDurationUsec > MAX_PREVIEW_RECORD_DURATION_US) { + double frameDurationDelta = minFrameDurationUsec - + MAX_PREVIEW_RECORD_DURATION_US; + if (frameDurationDelta < 500) + minFrameDurationUsec = MAX_PREVIEW_RECORD_DURATION_US - 1; + } + /* * The AE routine frame rate limits are computed using the frame * duration limits, as libcamera clips the AE routine to the From patchwork Tue Jan 26 17:30:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11021 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 6B139C0F2C for ; Tue, 26 Jan 2021 17:29:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2020868337; Tue, 26 Jan 2021 18:29:58 +0100 (CET) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0BD3768325 for ; Tue, 26 Jan 2021 18:29:55 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id CC193E0004 for ; Tue, 26 Jan 2021 17:29:54 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 18:30:07 +0100 Message-Id: <20210126173008.446321-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126173008.446321-1-jacopo@jmondi.org> References: <20210126173008.446321-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/6] android: camera_device: Use AE FPS range in template 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 request template returned by requestTemplatePreview() uses an arbitrary {15, 30} Auto-Exposure algorithm FPS range. Use the one calculated at static metadata creation time, which is consistent with the camera limits. Once template generation will be performed inspecting the requested capture intent, the FPS range over which the AE algorithm can range shall be tuned accordingly. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 5a8072a8a007..f3f59f7dcb77 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1339,12 +1339,26 @@ CameraMetadata *CameraDevice::requestTemplatePreview() requestTemplate->addEntry(ANDROID_CONTROL_AE_LOCK, &aeLock, 1); - std::vector aeFpsTarget = { - 15, 30, - }; - requestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, - aeFpsTarget.data(), - aeFpsTarget.size()); + /* Get the FPS range registered in the static metadata. */ + camera_metadata_ro_entry_t entry; + bool found = staticMetadata_->getEntry(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, + &entry); + if (found) { + /* + * \todo Depending on the requested CaptureIntent, the FPS range + * needs to be adjusted. For example, the capture template for + * video capture intent shall report a fixed value. + * + * Also assume the AE_AVAILABLE_TARGET_FPS_RANGE static metadata + * has been assembled as {{min, max} {max, max}}. + */ + const int32_t *data = entry.data.i32; + std::vector aeFpsTarget = { + data[0], data[1], + }; + requestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, + aeFpsTarget.data(), aeFpsTarget.size()); + } uint8_t aeAntibandingMode = ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO; requestTemplate->addEntry(ANDROID_CONTROL_AE_ANTIBANDING_MODE, From patchwork Tue Jan 26 17:30:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11022 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 B2390BD808 for ; Tue, 26 Jan 2021 17:29:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4ACA768318; Tue, 26 Jan 2021 18:29:58 +0100 (CET) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 850D068328 for ; Tue, 26 Jan 2021 18:29:55 +0100 (CET) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 3439DE0004 for ; Tue, 26 Jan 2021 17:29:55 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 26 Jan 2021 18:30:08 +0100 Message-Id: <20210126173008.446321-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210126173008.446321-1-jacopo@jmondi.org> References: <20210126173008.446321-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 6/6] android: camera_device: Return AE FPS range 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 result metadata reported an arbitrary {30, 30} FPS range for the AE algorithm. The actual FPS range should be returned in the Request::metadata, but as libcamera currently does not support that feature temporary work around the issue and return the FPS range requested by the camera framework. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index f3f59f7dcb77..6339ef257906 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1951,6 +1951,7 @@ std::unique_ptr CameraDevice::getResultMetadata(Camera3RequestDescriptor *descriptor, int64_t timestamp) { + const CameraMetadata &settings = descriptor->settings_; const ControlList &metadata = descriptor->request_->metadata(); /* @@ -1977,9 +1978,21 @@ CameraDevice::getResultMetadata(Camera3RequestDescriptor *descriptor, value = ANDROID_CONTROL_AE_MODE_ON; resultMetadata->addEntry(ANDROID_CONTROL_AE_MODE, &value, 1); - std::vector aeFpsTarget = { 30, 30 }; - resultMetadata->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, - aeFpsTarget.data(), aeFpsTarget.size()); + camera_metadata_ro_entry_t entry; + bool found = settings.getEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, &entry); + if (found) { + /* + * \todo Retrieve the AE FPS range from the libcamera metadata. + * As libcamera does not support that control, as a temporary + * workaround return what the framework asked. + */ + const int32_t *data = entry.data.i32; + std::vector aeFpsTarget = { + data[0], data[1], + }; + resultMetadata->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, + aeFpsTarget.data(), aeFpsTarget.size()); + } value = ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER_IDLE; resultMetadata->addEntry(ANDROID_CONTROL_AE_PRECAPTURE_TRIGGER,