From patchwork Mon Sep 13 07:31:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 13818 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 0E4CBBDB1D for ; Mon, 13 Sep 2021 07:31:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5E78769185; Mon, 13 Sep 2021 09:31:39 +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="KqRIsjde"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E7F8760132 for ; Mon, 13 Sep 2021 09:31:37 +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 666279E; Mon, 13 Sep 2021 09:31:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1631518297; bh=KZ+OVOJEoGeSKW9IwUj3ChgLq7N7VNtMazyHckrk0rE=; h=From:To:Cc:Subject:Date:From; b=KqRIsjdeJZ9cxJ5J/lKsMKxFjrCf/qGlsDQ3JgxMX5oF8JtMRoJ+nUoP4u9BfYGlf e6LgwxXlyWeen9Pv5IsaXwDMnUctIxEKQQS0iLOCCGp3GuggJAYlfE55RwFsFE90yO t0NFqsrqjOU7g6lEnNf/VTzXwl1FdbnuZWANW19g= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 13 Sep 2021 16:31:25 +0900 Message-Id: <20210913073125.1755107-1-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH] android: Plumb lens focus distance 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" Plumb the controls related to lens focus distance: - LENS_INFO_FOCUS_DISTANCE_CALIBRATION (static) - LENS_INFO_MINIMUM_FOCUS_DISTANCE (static) - LENS_FOCUS_DISTANCE (request, result) Conceptually, the first two controls determine the range of possible values of the third. None of our lenses are calibrated, so hardcode the first to uncalibrated. The valid focus distances are then [0, min]. Since we don't yet support variable-focus lenses, hardcode the second to 0.0f, making the range of valid focus distances [0, 0]. Hence, hardcode the focus distance in the result metadata to 0, and ignore the control in the request. Add todos for adding proper controls later, once we have focus support. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- This is also on top of my ctsw branch, so it won't apply on master, but I would like comments to confirm the direction and design. --- src/android/camera_capabilities.cpp | 13 +++++++++++++ src/android/camera_device.cpp | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 461c208b..a807712d 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -717,6 +717,7 @@ int CameraCapabilities::initializeStaticMetadata() ANDROID_LENS_INFO_AVAILABLE_APERTURES, ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS, ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION, + ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION, ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE, ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, ANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES, @@ -805,6 +806,7 @@ int CameraCapabilities::initializeStaticMetadata() ANDROID_JPEG_THUMBNAIL_SIZE, ANDROID_LENS_APERTURE, ANDROID_LENS_FOCAL_LENGTH, + ANDROID_LENS_FOCUS_DISTANCE, ANDROID_LENS_OPTICAL_STABILIZATION_MODE, ANDROID_LENS_STATE, ANDROID_NOISE_REDUCTION_MODE, @@ -1247,10 +1249,21 @@ int CameraCapabilities::initializeStaticMetadata() staticMetadata_->addEntry(ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION, opticalStabilizations); + /* + * Must be populated for FULL, optional for LIMITED. The value doesn't + * matter, so just hardcode to uncalibrated. Uncalibrated means that + * the max focus distance is zero (= infinite focus) and the min focus + * distance is specified in LENS_INFO_MINIMUM_FOCUS_DISTANCE. + */ + int distanceCalibration = ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_UNCALIBRATED; + staticMetadata_->addEntry(ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION, + distanceCalibration); + float hypeFocalDistance = 0; staticMetadata_->addEntry(ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE, hypeFocalDistance); + /* \todo Get this from the HAL config. */ float minFocusDistance = 0; staticMetadata_->addEntry(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, minFocusDistance); diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 373e0f98..cfbb84aa 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1396,6 +1396,10 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons float focal_length = 1.0; resultMetadata->addEntry(ANDROID_LENS_FOCAL_LENGTH, focal_length); + /* \todo Add a libcamera control for this, and plumb it. */ + float focalDistance = 0.0; + resultMetadata->addEntry(ANDROID_LENS_FOCUS_DISTANCE, focalDistance); + value = ANDROID_LENS_STATE_STATIONARY; resultMetadata->addEntry(ANDROID_LENS_STATE, value);