{"id":10758,"url":"https://patchwork.libcamera.org/api/patches/10758/?format=json","web_url":"https://patchwork.libcamera.org/patch/10758/","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":"<20201228165203.53771-4-jacopo@jmondi.org>","date":"2020-12-28T16:52:02","name":"[libcamera-devel,v3,3/4] android: camera_device: Report sensor physical size","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"3006736be47e321da923646e87594cd137f5206a","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":{"id":15,"url":"https://patchwork.libcamera.org/api/users/15/?format=json","username":"jmondi","first_name":"Jacopo","last_name":"Mondi","email":"jacopo@jmondi.org"},"mbox":"https://patchwork.libcamera.org/patch/10758/mbox/","series":[{"id":1557,"url":"https://patchwork.libcamera.org/api/series/1557/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1557","date":"2020-12-28T16:51:59","name":"libcamera: Introduce sensor database","version":3,"mbox":"https://patchwork.libcamera.org/series/1557/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/10758/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/10758/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 B6046C0F1B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 28 Dec 2020 16:51:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D84CE61D25;\n\tMon, 28 Dec 2020 17:51:57 +0100 (CET)","from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 36FFD619AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Dec 2020 17:51:54 +0100 (CET)","from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id EB79E1C000A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Dec 2020 16:51:53 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Mon, 28 Dec 2020 17:52:02 +0100","Message-Id":"<20201228165203.53771-4-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.29.2","In-Reply-To":"<20201228165203.53771-1-jacopo@jmondi.org>","References":"<20201228165203.53771-1-jacopo@jmondi.org>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 3/4] android: camera_device: Report\n\tsensor physical size","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Calculate the value of the ANDROID_SENSOR_INFO_PHYSICAL_SIZE property\nmultiplying the pixel unit cell size with the number of sensor's readable\npixels.\n\nMaintain a default value to support pipelines that do not register\nthe UnitCellSize property.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 38 ++++++++++++++++++++---------------\n 1 file changed, 22 insertions(+), 16 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 7678d4485ce9..9ad417ee6c3a 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -851,24 +851,37 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \tstaticMetadata_->addEntry(ANDROID_JPEG_MAX_SIZE, &maxJpegBufferSize_, 1);\n \n \t/* Sensor static metadata. */\n+\tstd::vector<int32_t> pixelArraySize(2);\n \tif (properties.contains(properties::PixelArraySize)) {\n \t\tconst Size &size =\n \t\t\tproperties.get(properties::PixelArraySize);\n-\t\tstd::vector<int32_t> data{\n-\t\t\tstatic_cast<int32_t>(size.width),\n-\t\t\tstatic_cast<int32_t>(size.height),\n-\t\t};\n-\t\tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE,\n-\t\t\t\t\t  data.data(), data.size());\n+\t\tpixelArraySize[0] = static_cast<int32_t>(size.width);\n+\t\tpixelArraySize[1] = static_cast<int32_t>(size.height);\n \t} else {\n \t\t/*\n \t\t * \\todo Drop the default once the ov5670 and ov13858 drivers\n \t\t * are updated to report the pixel array size.\n \t\t */\n-\t\tint32_t data[] = { 2592, 1944 };\n-\t\tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE,\n-\t\t\t\t\t  data, 2);\n+\t\tpixelArraySize = { 2592, 1944 };\n \t}\n+\tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_PIXEL_ARRAY_SIZE,\n+\t\t\t\t  pixelArraySize.data(), 2);\n+\n+\tstd::vector<float> physicalSize(2);\n+\tif (properties.contains(properties::UnitCellSize)) {\n+\t\tconst Size &unitCellSize =\n+\t\t\tproperties.get<Size>(properties::UnitCellSize);\n+\t\tphysicalSize[0] = unitCellSize.width * pixelArraySize[0] / 1e6f;\n+\t\tphysicalSize[1] = unitCellSize.height * pixelArraySize[1] / 1e6f;\n+\t} else {\n+\t\t/*\n+\t\t * \\todo Drop the default once all camera sensors report\n+\t\t * the pixel unit size.\n+\t\t */\n+\t\tphysicalSize = { 2.592, 1.944 };\n+\t}\n+\tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE,\n+\t\t\t\t  physicalSize.data(), physicalSize.size());\n \n \tif (properties.contains(properties::PixelArrayActiveAreas)) {\n \t\tconst Span<const Rectangle> &rects =\n@@ -919,13 +932,6 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n \t\t\t\t  testPatterModes.data(),\n \t\t\t\t  testPatterModes.size());\n \n-\tstd::vector<float> physicalSize = {\n-\t\t2592, 1944,\n-\t};\n-\tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_PHYSICAL_SIZE,\n-\t\t\t\t  physicalSize.data(),\n-\t\t\t\t  physicalSize.size());\n-\n \tuint8_t timestampSource = ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE_UNKNOWN;\n \tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_TIMESTAMP_SOURCE,\n \t\t\t\t  &timestampSource, 1);\n","prefixes":["libcamera-devel","v3","3/4"]}