From patchwork Mon Mar 8 17:07:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11517 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 C7FE4BD1F1 for ; Mon, 8 Mar 2021 17:07:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B264668AA7; Mon, 8 Mar 2021 18:07:09 +0100 (CET) Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1C58B68A9C for ; Mon, 8 Mar 2021 18:07:08 +0100 (CET) Received: from uno.homenet.telecomitalia.it (host-79-22-58-175.retail.telecomitalia.it [79.22.58.175]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id BCE1420000E for ; Mon, 8 Mar 2021 17:07:07 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Mar 2021 18:07:26 +0100 Message-Id: <20210308170728.2212649-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210308170728.2212649-1-jacopo@jmondi.org> References: <20210308170728.2212649-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/3] android: camera_device: Refuse unsupported 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" The current implementation of constructDefaultRequestSettings() returns the same capture template for all the capture intent. As the correctness of the generated template is verified by CTS it is better to return an error for unsupported capture use cases. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 6a10b09938fa..c72e0c73eb5e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1495,14 +1495,11 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type) case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT: captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT; break; + /* \todo Implement templates generation for the remaining use cases. */ case CAMERA3_TEMPLATE_ZERO_SHUTTER_LAG: - captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_ZERO_SHUTTER_LAG; - break; case CAMERA3_TEMPLATE_MANUAL: - captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_MANUAL; - break; default: - LOG(HAL, Error) << "Invalid template request type: " << type; + LOG(HAL, Error) << "Unsupported template request type: " << type; return nullptr; } From patchwork Mon Mar 8 17:07:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11518 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 7D363BD1F1 for ; Mon, 8 Mar 2021 17:07:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E5E3F68AB1; Mon, 8 Mar 2021 18:07:10 +0100 (CET) Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE66B68AA4 for ; Mon, 8 Mar 2021 18:07:08 +0100 (CET) Received: from uno.homenet.telecomitalia.it (host-79-22-58-175.retail.telecomitalia.it [79.22.58.175]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 662E920000E for ; Mon, 8 Mar 2021 17:07:08 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Mar 2021 18:07:27 +0100 Message-Id: <20210308170728.2212649-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210308170728.2212649-1-jacopo@jmondi.org> References: <20210308170728.2212649-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/3] android: camera_device: Fail template on no 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 camera supported FPS range is crucial to distinguish between capture templates for preview and video recording. If the pipeline handler did not specify an available FPS range by registering the controls::FrameDurations property so far the control was simply not added to the generated capture template. In order to prepare to generate templates for video recording which require a fixed FPS range, fail earlier in generating any template at all if the available FPS range is not provided by the Camera. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 36 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index c72e0c73eb5e..0621ec26feb8 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1386,6 +1386,26 @@ CameraMetadata *CameraDevice::requestTemplatePreview() return nullptr; } + /* 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) { + LOG(HAL, Error) << "Cannot create capture template without FPS range"; + return nullptr; + } + + /* + * \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}}. + */ + requestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, + entry.data.i32, 2); + uint8_t aeMode = ANDROID_CONTROL_AE_MODE_ON; requestTemplate->addEntry(ANDROID_CONTROL_AE_MODE, &aeMode, 1); @@ -1402,22 +1422,6 @@ CameraMetadata *CameraDevice::requestTemplatePreview() requestTemplate->addEntry(ANDROID_CONTROL_AE_LOCK, &aeLock, 1); - /* 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}}. - */ - requestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, - entry.data.i32, 2); - uint8_t aeAntibandingMode = ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO; requestTemplate->addEntry(ANDROID_CONTROL_AE_ANTIBANDING_MODE, &aeAntibandingMode, 1); From patchwork Mon Mar 8 17:07:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 11519 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 68D2EBD1F1 for ; Mon, 8 Mar 2021 17:07:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3188A68AB2; Mon, 8 Mar 2021 18:07:12 +0100 (CET) Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C53FB68AAF for ; Mon, 8 Mar 2021 18:07:09 +0100 (CET) Received: from uno.homenet.telecomitalia.it (host-79-22-58-175.retail.telecomitalia.it [79.22.58.175]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 3071E20000E for ; Mon, 8 Mar 2021 17:07:08 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Mar 2021 18:07:28 +0100 Message-Id: <20210308170728.2212649-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210308170728.2212649-1-jacopo@jmondi.org> References: <20210308170728.2212649-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] android: camera_device: Generate template for Video 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 capture request template for video recording use cases requires a fixed FPS range. Generate the request templates for the VIDEO_RECORD and VIDEO_SNAPSHOT capture intents using the preview template and updating the supported FPS range. This change fixes the CTS tests android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceRecordingTemplate Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 39 +++++++++++++++++++++++++++++------ src/android/camera_device.h | 1 + 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 0621ec26feb8..58bebab31cb8 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1396,11 +1396,7 @@ CameraMetadata *CameraDevice::requestTemplatePreview() } /* - * \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 + * Assume the AE_AVAILABLE_TARGET_FPS_RANGE static metadata * has been assembled as {{min, max} {max, max}}. */ requestTemplate->addEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, @@ -1474,6 +1470,30 @@ CameraMetadata *CameraDevice::requestTemplatePreview() return requestTemplate; } +CameraMetadata *CameraDevice::requestTemplateVideo() +{ + CameraMetadata *previewTemplate = requestTemplatePreview(); + if (!previewTemplate) + return nullptr; + + /* + * The video template requires a fixed FPS range. Everything else + * stays the same as the preview template. + */ + camera_metadata_ro_entry_t entry; + staticMetadata_->getEntry(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, + &entry); + + /* + * Assume the AE_AVAILABLE_TARGET_FPS_RANGE static metadata + * has been assembled as {{min, max} {max, max}}. + */ + previewTemplate->updateEntry(ANDROID_CONTROL_AE_TARGET_FPS_RANGE, + entry.data.i32 + 2, 2); + + return previewTemplate; +} + /* * Produce a metadata pack to be used as template for a capture request. */ @@ -1489,14 +1509,22 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type) switch (type) { case CAMERA3_TEMPLATE_PREVIEW: captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_PREVIEW; + requestTemplate = requestTemplatePreview(); break; case CAMERA3_TEMPLATE_STILL_CAPTURE: + /* + * Use the preview template for still capture, they only differ + * for the torch mode we currently do not support. + */ captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_STILL_CAPTURE; + requestTemplate = requestTemplatePreview(); break; case CAMERA3_TEMPLATE_VIDEO_RECORD: + requestTemplate = requestTemplateVideo(); captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD; break; case CAMERA3_TEMPLATE_VIDEO_SNAPSHOT: + requestTemplate = requestTemplateVideo(); captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_SNAPSHOT; break; /* \todo Implement templates generation for the remaining use cases. */ @@ -1507,7 +1535,6 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type) return nullptr; } - requestTemplate = requestTemplatePreview(); if (!requestTemplate || !requestTemplate->isValid()) { LOG(HAL, Error) << "Failed to construct request template"; delete requestTemplate; diff --git a/src/android/camera_device.h b/src/android/camera_device.h index f96934dbf4e7..ebbd7b9b8ab1 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -101,6 +101,7 @@ private: void notifyShutter(uint32_t frameNumber, uint64_t timestamp); void notifyError(uint32_t frameNumber, camera3_stream_t *stream); CameraMetadata *requestTemplatePreview(); + CameraMetadata *requestTemplateVideo(); libcamera::PixelFormat toPixelFormat(int format) const; int processControls(Camera3RequestDescriptor *descriptor); std::unique_ptr getResultMetadata(