From patchwork Thu Apr 1 10:13:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11807 X-Patchwork-Delegate: paul.elder@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 486BBC0DA4 for ; Thu, 1 Apr 2021 10:13:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 084B968780; Thu, 1 Apr 2021 12:13:57 +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="uddHESHB"; 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 A88986877C for ; Thu, 1 Apr 2021 12:13:55 +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 DF3EEF7; Thu, 1 Apr 2021 12:13:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1617272035; bh=bDbm71P0EgTGkotKmwfKFQlyoRJVCXSvI8dyKJHgaAs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uddHESHBt0d/rI2dBbEpmmYYdUwi8rEFvxrGyRsHAAsXL0eUeGNo9z5SHtrLY+395 T4FysVV9aNPF3R9JUSHwb9nVXexXT8LeLoy1ONXnZJIWOzf0ydK+sZeLzDG7/RP96S y4QqOTiHD7aP6Gp+R4V9A3wxDa9v6JGQP9djmHNA= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Apr 2021 19:13:33 +0900 Message-Id: <20210401101340.160590-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210401101340.160590-1-paul.elder@ideasonboard.com> References: <20210401101340.160590-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 1/8] android: Switch to FULL 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" Signed-off-by: Paul Elder --- src/android/camera_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 04b41526..2a685507 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1157,7 +1157,7 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() staticMetadata_->addEntry(ANDROID_SCALER_CROPPING_TYPE, &croppingType, 1); /* Info static metadata. */ - uint8_t supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_LIMITED; + uint8_t supportedHWLevel = ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL_FULL; staticMetadata_->addEntry(ANDROID_INFO_SUPPORTED_HARDWARE_LEVEL, &supportedHWLevel, 1); From patchwork Thu Apr 1 10:13:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11808 X-Patchwork-Delegate: paul.elder@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 A40B8C0DA4 for ; Thu, 1 Apr 2021 10:13:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5D17C6877C; Thu, 1 Apr 2021 12:13:58 +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="rnZUWyjc"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 726DB6877C for ; Thu, 1 Apr 2021 12:13:57 +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 E917CF7; Thu, 1 Apr 2021 12:13:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1617272037; bh=Rt2fUsGmgRsrmQj4W1bmEZDWInTDjnToWsB5lFEwIPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rnZUWyjciCsdTNABfa5Fu+dv765IXFfAFqLmOYjpsfUsJWOZH4Qrnm3Eno7auy8WS X3DESXIYB1YEPgSG8TxrByz5R3LPS4JErLMcpxvLd6PIQjV/TfcWUbJ2sTRDao//Y2 G/i742dz/FL6MqpTW7EW/Ty4Fgj1Frg0s2dHtsgY= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Apr 2021 19:13:34 +0900 Message-Id: <20210401101340.160590-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210401101340.160590-1-paul.elder@ideasonboard.com> References: <20210401101340.160590-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 2/8] android: CameraDevice: Report proper min and max 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" The HAL layer was getting the min and max frame durations from from the camera, then rounding it to fps to report as available fps ranges. The same min and max frame durations were then being reported as min and max frame durations. Since the fps are integer values while the frame durations are in ns, this caused a rounding error making it seem like we were reporting an available max fps that was higher than was was allowed by the minimum frame duration. Fix this by recalculating the frame durations based on the rounded fps values. This allows the following CTS test to pass: - android.hardware.camera2.cts.SurfaceViewPreviewTest#testPreviewFpsRange Signed-off-by: Paul Elder --- src/android/camera_device.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 2a685507..30ea3ade 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -799,6 +799,10 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() int32_t minFps = std::round(1e9 / maxFrameDurationNsec); minFps = std::max(1, minFps); + /* Avoid rounding errors when we reuse these variables later */ + minFrameDurationNsec = 1e9 / maxFps; + maxFrameDurationNsec = 1e9 / minFps; + /* * Register to the camera service {min, max} and {max, max} * intervals as requested by the metadata documentation. From patchwork Thu Apr 1 10:13:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11809 X-Patchwork-Delegate: paul.elder@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 04241C0DA4 for ; Thu, 1 Apr 2021 10:14:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B786568783; Thu, 1 Apr 2021 12:14:00 +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="SRiK8O9y"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7018668782 for ; Thu, 1 Apr 2021 12:13:59 +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 DA7C9527; Thu, 1 Apr 2021 12:13:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1617272039; bh=Isxq6lyRGOGt+hyfbIAxaBP1CCH2NClRWPhXvUlbB7Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SRiK8O9yjHvsjuFy+bxlZ1YtI7eyW67yX6HwNGSBuqWgKqvS9PExSBM/omfOdq3PO snreGUdVpEcIN8G76V7ONHOatWp529jBgPHVveARHeNleScw0sZWQ9bLn1lxvfM/1O DEEtfgiYgK55yobYiWM47w28gp6tcCwVxicke1iQ= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Apr 2021 19:13:35 +0900 Message-Id: <20210401101340.160590-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210401101340.160590-1-paul.elder@ideasonboard.com> References: <20210401101340.160590-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 3/8] android: camera_device: Add separate template for still capture 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 separate template for still capture, so that we can set the noise reduction mode to high quality, as hardware level FULL requires this. This is part of a fix to allow the following CTS test to pass: - android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceStillTemplate Signed-off-by: Paul Elder --- src/android/camera_device.cpp | 23 ++++++++++++++++++----- src/android/camera_device.h | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 30ea3ade..ded57649 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1479,6 +1479,23 @@ std::unique_ptr CameraDevice::requestTemplateVideo() return previewTemplate; } +std::unique_ptr CameraDevice::requestTemplateStill() +{ + std::unique_ptr previewTemplate = requestTemplatePreview(); + if (!previewTemplate) + return nullptr; + + /* + * The still template with FULL requires the noise reduction mode to be + * HIGH_QUALITY. + */ + uint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY; + previewTemplate->updateEntry(ANDROID_NOISE_REDUCTION_MODE, + &noiseReduction, 1); + + return previewTemplate; +} + /* * Produce a metadata pack to be used as template for a capture request. */ @@ -1497,12 +1514,8 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type) 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(); + requestTemplate = requestTemplateStill(); break; case CAMERA3_TEMPLATE_VIDEO_RECORD: captureIntent = ANDROID_CONTROL_CAPTURE_INTENT_VIDEO_RECORD; diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 11bdfec8..388acf51 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -99,6 +99,7 @@ private: void notifyError(uint32_t frameNumber, camera3_stream_t *stream); std::unique_ptr requestTemplatePreview(); std::unique_ptr requestTemplateVideo(); + std::unique_ptr requestTemplateStill(); libcamera::PixelFormat toPixelFormat(int format) const; int processControls(Camera3RequestDescriptor *descriptor); std::unique_ptr getResultMetadata( From patchwork Thu Apr 1 10:13:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11810 X-Patchwork-Delegate: paul.elder@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 6F655C0DA4 for ; Thu, 1 Apr 2021 10:14:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 24DC268786; Thu, 1 Apr 2021 12:14:03 +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="cZ26l7mh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 42C7668782 for ; Thu, 1 Apr 2021 12:14:01 +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 CF39CF7; Thu, 1 Apr 2021 12:13:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1617272041; bh=mDh8j51KePPsrpsOwTeVl4thnj9CV52Rc1z67ivFfBY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cZ26l7mhg0/KO6juZjD0olTwnP+wttS7/D8cAl2ea2262giHo7P2BJRd/mlFgwon/ J7CuQXWatV1uTqHNRwDIFwbtCPQRCSkRLexsiVbNOv6TVnWhxjhEGclUbcQKCmGomy hxDIJL3qDdC0UQp0mqcBpbaFXx8cQdTOF4IPRYmU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Apr 2021 19:13:36 +0900 Message-Id: <20210401101340.160590-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210401101340.160590-1-paul.elder@ideasonboard.com> References: <20210401101340.160590-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 4/8] android: camera_device: Set proper frame duration 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" CTS tests that the frame duration is for every frame (after the first 6) are within an the frame duration ranges that we provide in the static metadata. One way it can do this, which it was doing previously, is to calculate it based on the timestamps that we report for each capture result. Another option is that we can report the frame duration ourselves. The frame durations that we report can be more "correct", so use this method to appease CTS. This is part of the fix to allow the following CTS test to pass: - android.hardware.camera2.cts.CaptureRequestTest#testNoiseReductionModeControl Signed-off-by: Paul Elder --- This probably isn't the right solution, but I can't seem to figure out what the correct route is. CTS checks if the frame duration that we report is within the frame duration range. The frame duration range comes from CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES (where the frame duration is less than or equal to 1e9/30). The frame duration for the current frame is either calculated by CTS by subtracting the SENSOR_TIMESTAMP of the current frame from the one of the last frame (which is what we did previously) or from what we report in SENSOR_FRAME_DURATION. The issue is that the frame duration calculated by CTS is less than the minimum available frame duration that we report. So should we lower that? Or report a different SENSOR_FRAME DURATION, if at all? --- src/android/camera_device.cpp | 13 +++++++++++-- src/android/camera_device.h | 2 ++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index ded57649..0dcfc880 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -311,7 +311,7 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor() = default; CameraDevice::CameraDevice(unsigned int id, std::shared_ptr camera) : id_(id), running_(false), camera_(std::move(camera)), - facing_(CAMERA_FACING_FRONT), orientation_(0) + facing_(CAMERA_FACING_FRONT), orientation_(0), lastResultTimestamp_(0) { camera_->requestCompleted.connect(this, &CameraDevice::requestComplete); @@ -1339,6 +1339,7 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() 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, @@ -1944,6 +1945,7 @@ void CameraDevice::requestComplete(Request *request) */ uint64_t timestamp = buffers.begin()->second->metadata().timestamp; resultMetadata = getResultMetadata(*descriptor, timestamp); + lastResultTimestamp_ = timestamp; /* Handle any JPEG compression. */ for (camera3_stream_buffer_t &buffer : descriptor->buffers_) { @@ -2074,7 +2076,7 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor, * Total bytes for JPEG metadata: 82 */ std::unique_ptr resultMetadata = - std::make_unique(44, 166); + std::make_unique(45, 174); if (!resultMetadata->isValid()) { LOG(HAL, Error) << "Failed to allocate result metadata"; return nullptr; @@ -2197,6 +2199,13 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor, value = ANDROID_NOISE_REDUCTION_MODE_OFF; resultMetadata->addEntry(ANDROID_NOISE_REDUCTION_MODE, &value, 1); + /* + * \todo Use sliding window average + * int64_t value64 = timestamp - lastResultTimestamp_; + */ + int64_t value64 = 33333333; + resultMetadata->addEntry(ANDROID_SENSOR_FRAME_DURATION, &value64, 1); + /* 33.3 msec */ const int64_t rolling_shutter_skew = 33300000; resultMetadata->addEntry(ANDROID_SENSOR_ROLLING_SHUTTER_SKEW, diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 388acf51..dc03a038 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -131,6 +131,8 @@ private: unsigned int maxJpegBufferSize_; + int64_t lastResultTimestamp_; + CameraMetadata lastSettings_; }; From patchwork Thu Apr 1 10:13:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11811 X-Patchwork-Delegate: paul.elder@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 D9B03C0DA4 for ; Thu, 1 Apr 2021 10:14:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 87F8A68788; Thu, 1 Apr 2021 12:14:04 +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="NQpiwFtQ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 020D06877D for ; Thu, 1 Apr 2021 12:14:03 +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 A6E75F7; Thu, 1 Apr 2021 12:14:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1617272042; bh=dekIEvQ68+4wkIbN3NGFvrZmLdKcvY2JvRv5zx0mktc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NQpiwFtQcyq0/GorDD4Gif9iHR/EDkyW18MM0MrHd4m6E877Q6E0PfjmXSl9GfMz0 o+GE7fNOgfozp8IDXxEixSPQJ6Uee572UmtnvI0Al3eZVHzabEzfpff1g6MzXYoUo4 W57EqN7d5FILzK1BYXcel5H6plWIzADJbS0T/1CM= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Apr 2021 19:13:37 +0900 Message-Id: <20210401101340.160590-6-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210401101340.160590-1-paul.elder@ideasonboard.com> References: <20210401101340.160590-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 5/8] android: camera_device: Set noise reduction values for FULL requirements 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" Set the appropriate values for noise reduction to satisfy the requirements for hardware level FULL. These are: - OFF and FAST and HIGH_QUALITY must be supported - the preview template should have noise reduction set to FAST - the capture result metadata should have the noise reduction mode set to the same mode as what was in the request metadata This, along with "android: camera_device: Add separate template for still capture" and "android: camera_device: Set proper frame duration", allows the following CTS tests to pass: - android.hardware.camera2.cts.CameraDeviceTest#testCameraDevicePreviewTemplate - android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceRecordingTemplate - android.hardware.camera2.cts.CameraDeviceTest#testCameraDeviceStillTemplate - android.hardware.camera2.cts.CaptureRequestTest#testNoiseReductionModeControl - android.hardware.camera2.cts.CaptureRequestTest#testNoiseReductionModeControlFastFps Signed-off-by: Paul Elder --- src/android/camera_device.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 0dcfc880..fc432263 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1087,12 +1087,18 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() { std::vector data; data.reserve(5); + /* + * \todo if this doesn't have OFF and FAST and HIGH_QUALITY + * then this camera does not support FULL + */ const auto &infoMap = controlsInfo.find(&controls::draft::NoiseReductionMode); if (infoMap != controlsInfo.end()) { for (const auto &value : infoMap->second.values()) data.push_back(value.get()); } else { data.push_back(ANDROID_NOISE_REDUCTION_MODE_OFF); + data.push_back(ANDROID_NOISE_REDUCTION_MODE_FAST); + data.push_back(ANDROID_NOISE_REDUCTION_MODE_HIGH_QUALITY); } staticMetadata_->addEntry(ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, data.data(), data.size()); @@ -1431,7 +1437,8 @@ std::unique_ptr CameraDevice::requestTemplatePreview() requestTemplate->addEntry(ANDROID_STATISTICS_FACE_DETECT_MODE, &faceDetectMode, 1); - uint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_OFF; + /* \todo FULL expects this to be FAST, not OFF*/ + uint8_t noiseReduction = ANDROID_NOISE_REDUCTION_MODE_FAST; requestTemplate->addEntry(ANDROID_NOISE_REDUCTION_MODE, &noiseReduction, 1); @@ -2197,7 +2204,9 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor, &value, 1); value = ANDROID_NOISE_REDUCTION_MODE_OFF; - resultMetadata->addEntry(ANDROID_NOISE_REDUCTION_MODE, &value, 1); + found = settings.getEntry(ANDROID_NOISE_REDUCTION_MODE, &entry); + resultMetadata->addEntry(ANDROID_NOISE_REDUCTION_MODE, + found ? entry.data.u8 : &value, 1); /* * \todo Use sliding window average From patchwork Thu Apr 1 10:13:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11812 X-Patchwork-Delegate: paul.elder@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 6AEE9C0DA4 for ; Thu, 1 Apr 2021 10:14:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 227F968785; Thu, 1 Apr 2021 12:14:07 +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="bT8TDX7z"; 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 23D0A68782 for ; Thu, 1 Apr 2021 12:14:05 +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 80A40F7; Thu, 1 Apr 2021 12:14:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1617272044; bh=7wpvxqxtt4w4YWjsL962OFpz2UjP/OB5emo3gR+5zCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bT8TDX7zPVkzl7vYFKtloh1jHLOttcAeqcAkOTnhfcZ9WlLFaIXhA3bQpESKOcl7K Za4T3NfBh4BvoVDo1SISJ+YPEVKCQG5nCurngGrBbs6AnYUBwUFQwwYudww1FfPswq nhvrENi7Lyx5k03xjagWuhMOyH/dgxiFrW1UKH7w= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Apr 2021 19:13:38 +0900 Message-Id: <20210401101340.160590-7-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210401101340.160590-1-paul.elder@ideasonboard.com> References: <20210401101340.160590-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 6/8] android: camera_device: Add AE mode off to AE available modes 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" Hardware level FULL requires that AE mode off is an available AE mode. Add it. This allows the following CTS test to pass: - android.hardware.camera2.cts.CaptureRequestTest#testAeModeAndLock Signed-off-by: Paul Elder --- src/android/camera_device.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index fc432263..584c3c4a 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -760,7 +760,9 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() aeAvailableAntiBandingModes.data(), aeAvailableAntiBandingModes.size()); + /* \todo FULL requires OFF */ std::vector aeAvailableModes = { + ANDROID_CONTROL_AE_MODE_OFF, ANDROID_CONTROL_AE_MODE_ON, }; staticMetadata_->addEntry(ANDROID_CONTROL_AE_AVAILABLE_MODES, From patchwork Thu Apr 1 10:13:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11813 X-Patchwork-Delegate: paul.elder@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 0B0D7C0DA4 for ; Thu, 1 Apr 2021 10:14:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BAC1D68792; Thu, 1 Apr 2021 12:14:08 +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="cshTrOU8"; 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 5B9A66878F for ; Thu, 1 Apr 2021 12:14:07 +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 8C26CF7; Thu, 1 Apr 2021 12:14:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1617272047; bh=x1KBS6uP/ftCL+BBxMAc2Y54i5C3CPyJHe130MLy8Yk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cshTrOU8quj62h85cFB555pS+IbRDYFLf9JyeGPo7jw7PtV9owXFGaFPgnzrc9xvM NXvJjP0hj5vpHT1W9X+BBGNyLbE//T7KTkSC08VMq6gvxDj6nT+nAVrLukE9xf7o3t noH70MzRZbphEurRoSy7oNQuQ9kPf3gzOyHF/6WY= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Apr 2021 19:13:39 +0900 Message-Id: <20210401101340.160590-8-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210401101340.160590-1-paul.elder@ideasonboard.com> References: <20210401101340.160590-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 7/8] android: camera_device: Add AWB mode off to available AWB modes 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" Hardware level FULL requires AWB mode off to be an available AWB mode. Add it. Hardware level FULL additionally requires the AWB mode of the result metadata to be what was provided in the request metadata. Do this. This allows the following CTS test to pass: - android.hardware.camera2.cts.CaptureRequestTest#testAwbModeAndLock Signed-off-by: Paul Elder --- src/android/camera_device.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 584c3c4a..a187beff 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -859,9 +859,11 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() /* * \todo Inspect the Camera capabilities to report the available - * AWB modes. Default to AUTO as CTS tests require it. + * AWB modes. Default to AUTO as CTS tests require it. FULL requires + * OFF. */ std::vector availableAwbModes = { + ANDROID_CONTROL_AWB_MODE_OFF, ANDROID_CONTROL_AWB_MODE_AUTO, }; staticMetadata_->addEntry(ANDROID_CONTROL_AWB_AVAILABLE_MODES, @@ -2141,7 +2143,9 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor, resultMetadata->addEntry(ANDROID_CONTROL_AF_TRIGGER, &value, 1); value = ANDROID_CONTROL_AWB_MODE_AUTO; - resultMetadata->addEntry(ANDROID_CONTROL_AWB_MODE, &value, 1); + found = settings.getEntry(ANDROID_CONTROL_AWB_MODE, &entry); + resultMetadata->addEntry(ANDROID_CONTROL_AWB_MODE, + found ? entry.data.u8 : &value, 1); value = ANDROID_CONTROL_AWB_LOCK_OFF; resultMetadata->addEntry(ANDROID_CONTROL_AWB_LOCK, &value, 1); From patchwork Thu Apr 1 10:13:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11814 X-Patchwork-Delegate: paul.elder@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 B3F91C0DA4 for ; Thu, 1 Apr 2021 10:14:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7188C6878B; Thu, 1 Apr 2021 12:14:11 +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="aMgWFTAX"; 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 4B82F6878B for ; Thu, 1 Apr 2021 12:14:09 +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 CBFA1527; Thu, 1 Apr 2021 12:14:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1617272049; bh=1+uVv3LJLbdpWJaTH6+9zQtHYgRPsq3BGfz+pTlOaKs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aMgWFTAXP+AwHksGfWxlrxwr841wzY50HgnLPEduQA0kkQniEmRxFnwH3EeSOBJYR Z/aw5Fsx8cS1tcLghRAs6RCwknov9vt4oP/F9eqyQzenUCmZ4Aevpw+E3hnf48V2oP 3KxbZobxKqAhP+URKj8kvt8dp+XZ9uM97xHgi7V4= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Thu, 1 Apr 2021 19:13:40 +0900 Message-Id: <20210401101340.160590-9-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210401101340.160590-1-paul.elder@ideasonboard.com> References: <20210401101340.160590-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 8/8] android: camera_device: Fix exposure time range and max analog 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 exposure time range minimum must be at most 100us, and the maximum at least 100ms. Clamp these values. The maximum analog sensitivity is a required static metadata entry for hardware level FULL. Add it. This allows the following CTS test to pass: - android.hardware.camera2.cts.CaptureRequestTest#testFlashControl Signed-off-by: Paul Elder --- src/android/camera_device.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index a187beff..9652b0e0 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -675,10 +675,10 @@ std::tuple CameraDevice::calculateStaticMetadataSize() { /* * \todo Keep this in sync with the actual number of entries. - * Currently: 54 entries, 874 bytes of static metadata + * Currently: 55 entries, 878 bytes of static metadata */ - uint32_t numEntries = 54; - uint32_t byteSize = 874; + uint32_t numEntries = 55; + uint32_t byteSize = 878; /* * Calculate space occupation in bytes for dynamically built metadata @@ -982,10 +982,20 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() exposureInfo->second.min().get() * 1000LL, exposureInfo->second.max().get() * 1000LL, }; + /* min must be at most 100us, max at least 100ms */ + if (exposureTimeRange[0] > 100000) + exposureTimeRange[0] = 100000; + if (exposureTimeRange[1] < 100000000) + exposureTimeRange[1] = 100000000; staticMetadata_->addEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE, &exposureTimeRange, 2); } + /* min at most 100, max at least 800 */ + int32_t maxAnalogSensitivity = 800; + staticMetadata_->addEntry(ANDROID_SENSOR_MAX_ANALOG_SENSITIVITY, + &maxAnalogSensitivity, 1); + staticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, &orientation_, 1); std::vector testPatterModes = { @@ -1270,6 +1280,7 @@ const camera_metadata_t *CameraDevice::getStaticMetadata() ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE, ANDROID_SENSOR_INFO_SENSITIVITY_RANGE, ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE, + ANDROID_SENSOR_MAX_ANALOG_SENSITIVITY, ANDROID_SENSOR_ORIENTATION, ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES, ANDROID_STATISTICS_INFO_MAX_FACE_COUNT,