{"id":13818,"url":"https://patchwork.libcamera.org/api/patches/13818/?format=json","web_url":"https://patchwork.libcamera.org/patch/13818/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210913073125.1755107-1-paul.elder@ideasonboard.com>","date":"2021-09-13T07:31:25","name":"[libcamera-devel,RFC] android: Plumb lens focus distance","commit_ref":null,"pull_url":null,"state":"not-applicable","archived":false,"hash":"467e09616faf1c8708e6ac8ae692c935682cca3d","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":{"id":17,"url":"https://patchwork.libcamera.org/api/users/17/?format=json","username":"epaul","first_name":"Paul","last_name":"Elder","email":"paul.elder@ideasonboard.com"},"mbox":"https://patchwork.libcamera.org/patch/13818/mbox/","series":[{"id":2520,"url":"https://patchwork.libcamera.org/api/series/2520/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2520","date":"2021-09-13T07:31:25","name":"[libcamera-devel,RFC] android: Plumb lens focus distance","version":1,"mbox":"https://patchwork.libcamera.org/series/2520/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13818/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13818/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 0E4CBBDB1D\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 13 Sep 2021 07:31:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5E78769185;\n\tMon, 13 Sep 2021 09:31:39 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E7F8760132\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 13 Sep 2021 09:31:37 +0200 (CEST)","from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 666279E;\n\tMon, 13 Sep 2021 09:31:36 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"KqRIsjde\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1631518297;\n\tbh=KZ+OVOJEoGeSKW9IwUj3ChgLq7N7VNtMazyHckrk0rE=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=KqRIsjdeJZ9cxJ5J/lKsMKxFjrCf/qGlsDQ3JgxMX5oF8JtMRoJ+nUoP4u9BfYGlf\n\te6LgwxXlyWeen9Pv5IsaXwDMnUctIxEKQQS0iLOCCGp3GuggJAYlfE55RwFsFE90yO\n\tt0NFqsrqjOU7g6lEnNf/VTzXwl1FdbnuZWANW19g=","From":"Paul Elder <paul.elder@ideasonboard.com>","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","Content-Transfer-Encoding":"8bit","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":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Plumb the controls related to lens focus distance:\n- LENS_INFO_FOCUS_DISTANCE_CALIBRATION (static)\n- LENS_INFO_MINIMUM_FOCUS_DISTANCE (static)\n- LENS_FOCUS_DISTANCE (request, result)\n\nConceptually, the first two controls determine the range of possible\nvalues of the third. None of our lenses are calibrated, so hardcode the\nfirst to uncalibrated. The valid focus distances are then [0, min].\nSince we don't yet support variable-focus lenses, hardcode the second to\n0.0f, making the range of valid focus distances [0, 0]. Hence, hardcode\nthe focus distance in the result metadata to 0, and ignore the control\nin the request. Add todos for adding proper controls later, once we have\nfocus support.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\nThis is also on top of my ctsw branch, so it won't apply on master, but\nI would like comments to confirm the direction and design.\n---\n src/android/camera_capabilities.cpp | 13 +++++++++++++\n src/android/camera_device.cpp       |  4 ++++\n 2 files changed, 17 insertions(+)","diff":"diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp\nindex 461c208b..a807712d 100644\n--- a/src/android/camera_capabilities.cpp\n+++ b/src/android/camera_capabilities.cpp\n@@ -717,6 +717,7 @@ int CameraCapabilities::initializeStaticMetadata()\n \t\tANDROID_LENS_INFO_AVAILABLE_APERTURES,\n \t\tANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS,\n \t\tANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,\n+\t\tANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION,\n \t\tANDROID_LENS_INFO_HYPERFOCAL_DISTANCE,\n \t\tANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE,\n \t\tANDROID_NOISE_REDUCTION_AVAILABLE_NOISE_REDUCTION_MODES,\n@@ -805,6 +806,7 @@ int CameraCapabilities::initializeStaticMetadata()\n \t\tANDROID_JPEG_THUMBNAIL_SIZE,\n \t\tANDROID_LENS_APERTURE,\n \t\tANDROID_LENS_FOCAL_LENGTH,\n+\t\tANDROID_LENS_FOCUS_DISTANCE,\n \t\tANDROID_LENS_OPTICAL_STABILIZATION_MODE,\n \t\tANDROID_LENS_STATE,\n \t\tANDROID_NOISE_REDUCTION_MODE,\n@@ -1247,10 +1249,21 @@ int CameraCapabilities::initializeStaticMetadata()\n \tstaticMetadata_->addEntry(ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,\n \t\t\t\t  opticalStabilizations);\n \n+\t/*\n+\t * Must be populated for FULL, optional for LIMITED. The value doesn't\n+\t * matter, so just hardcode to uncalibrated. Uncalibrated means that\n+\t * the max focus distance is zero (= infinite focus) and the min focus\n+\t * distance is specified in LENS_INFO_MINIMUM_FOCUS_DISTANCE.\n+\t */\n+\tint distanceCalibration = ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION_UNCALIBRATED;\n+\tstaticMetadata_->addEntry(ANDROID_LENS_INFO_FOCUS_DISTANCE_CALIBRATION,\n+\t\t\t\t  distanceCalibration);\n+\n \tfloat hypeFocalDistance = 0;\n \tstaticMetadata_->addEntry(ANDROID_LENS_INFO_HYPERFOCAL_DISTANCE,\n \t\t\t\t  hypeFocalDistance);\n \n+\t/* \\todo Get this from the HAL config. */\n \tfloat minFocusDistance = 0;\n \tstaticMetadata_->addEntry(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE,\n \t\t\t\t  minFocusDistance);\ndiff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 373e0f98..cfbb84aa 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -1396,6 +1396,10 @@ CameraDevice::getResultMetadata(const Camera3RequestDescriptor &descriptor) cons\n \tfloat focal_length = 1.0;\n \tresultMetadata->addEntry(ANDROID_LENS_FOCAL_LENGTH, focal_length);\n \n+\t/* \\todo Add a libcamera control for this, and plumb it. */\n+\tfloat focalDistance = 0.0;\n+\tresultMetadata->addEntry(ANDROID_LENS_FOCUS_DISTANCE, focalDistance);\n+\n \tvalue = ANDROID_LENS_STATE_STATIONARY;\n \tresultMetadata->addEntry(ANDROID_LENS_STATE, value);\n \n","prefixes":["libcamera-devel","RFC"]}