[{"id":14386,"web_url":"https://patchwork.libcamera.org/comment/14386/","msgid":"<20201229042645.GF67590@pyrite.rasen.tech>","date":"2020-12-29T04:26:45","subject":"Re: [libcamera-devel] [PATCH v3 3/4] android: camera_device: Report\n\tsensor physical size","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Mon, Dec 28, 2020 at 05:52:02PM +0100, Jacopo Mondi wrote:\n> Calculate the value of the ANDROID_SENSOR_INFO_PHYSICAL_SIZE property\n> multiplying the pixel unit cell size with the number of sensor's readable\n> pixels.\n> \n> Maintain a default value to support pipelines that do not register\n> the UnitCellSize property.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> ---\n>  src/android/camera_device.cpp | 38 ++++++++++++++++++++---------------\n>  1 file changed, 22 insertions(+), 16 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 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> -- \n> 2.29.2\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 8AA40C0F1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Dec 2020 04:26:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5A2B2615B2;\n\tTue, 29 Dec 2020 05:26:54 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id E25106031A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Dec 2020 05:26:52 +0100 (CET)","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 7175198;\n\tTue, 29 Dec 2020 05:26:51 +0100 (CET)"],"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=\"B8niEf/k\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1609216012;\n\tbh=/oD5p3K+B57ivRdtsaT/79F1WRIU7M+rA+aISt17gKk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=B8niEf/kAA0WeOzotdvwqfTNgRne0RMc7Cw449Rn7kqO0iFb58IO+2gQouufVbUR4\n\thsLSJxFJ8Jl+zeAY4x6ft8mBae8ECYRr94Qelg8QkCrbCGzQOlQJfKDnp7mO1rjeB0\n\tgLRtFAzvxTPM1UQv6Hp4G8+JJSeNgaiuwymFJWG0=","Date":"Tue, 29 Dec 2020 13:26:45 +0900","From":"paul.elder@ideasonboard.com","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20201229042645.GF67590@pyrite.rasen.tech>","References":"<20201228165203.53771-1-jacopo@jmondi.org>\n\t<20201228165203.53771-4-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201228165203.53771-4-jacopo@jmondi.org>","Subject":"Re: [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>","Cc":"libcamera-devel@lists.libcamera.org","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>"}},{"id":14400,"web_url":"https://patchwork.libcamera.org/comment/14400/","msgid":"<X+tn8orKB940/669@oden.dyn.berto.se>","date":"2020-12-29T17:31:30","subject":"Re: [libcamera-devel] [PATCH v3 3/4] android: camera_device: Report\n\tsensor physical size","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your work.\n\nOn 2020-12-28 17:52:02 +0100, Jacopo Mondi wrote:\n> Calculate the value of the ANDROID_SENSOR_INFO_PHYSICAL_SIZE property\n> multiplying the pixel unit cell size with the number of sensor's readable\n> pixels.\n> \n> Maintain a default value to support pipelines that do not register\n> the UnitCellSize property.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/android/camera_device.cpp | 38 ++++++++++++++++++++---------------\n>  1 file changed, 22 insertions(+), 16 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 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\nInstead of adding special cases for cameras that does not report all \ncontrols that the HAL needs would it make sens to add default values in \nthe CameraSensor/SensorDatabase classes? I'm thinking this could create \na leaner HAL implementation as the HAL is already rather complex and we \nwould collect all defaults values in components that are designed to \nprovided them. As an added bonus the controls would also be visible \noutside the HAL and possibly increasing the usage of them in other parts \nof the code?\n\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> -- \n> 2.29.2\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","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 0990BC0F1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 29 Dec 2020 17:31:36 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 88EC0615D2;\n\tTue, 29 Dec 2020 18:31:35 +0100 (CET)","from mail-lf1-x134.google.com (mail-lf1-x134.google.com\n\t[IPv6:2a00:1450:4864:20::134])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A32B6031F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Dec 2020 18:31:33 +0100 (CET)","by mail-lf1-x134.google.com with SMTP id h22so32408776lfu.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 29 Dec 2020 09:31:33 -0800 (PST)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tq21sm6959143ljj.31.2020.12.29.09.31.31\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 29 Dec 2020 09:31:31 -0800 (PST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"OSh+DF2z\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=Ezmmz5p6JIuJ4AeV6U3avBr03pAYC66UhiW2jm3ptnI=;\n\tb=OSh+DF2z+iXpMjs+/CMlUesVY/DEae3NpPGrYMDjeOaiHybc2on6ATtAl/Ko3O3ICZ\n\tBbShfdLgFWnkIpu2GgMHvdPPq7iAMHS2Ul2O4RWqiv0FoF03wOUvzhxEsR5ZZgUR9eZK\n\tc2KbWhXGG78PkknQErffyt+6kRa/KXIMf4LNW0wCFfPHamgOIrqkgvDOkMK6B7wMAoTd\n\tJaDSwkeIrOGWHEAQ8JW98fWHYcM+NL0NqCkfrbJo79qYMBw/7JnYbB6AcXdTOea21ZrX\n\tiO3SDUnVwxOz1ljXYSpM4Saah1DXo7JLveGcg58JlVVd1TX6eGP5gQ2P4GGXf4Ab0u0w\n\tu8Fg==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=Ezmmz5p6JIuJ4AeV6U3avBr03pAYC66UhiW2jm3ptnI=;\n\tb=I1dLV3uf7XTzQBEuT86noi6Of7S+dI/GqKXTuSJ30zTkkllLVIHO9i5Mu+//ml9XZs\n\txplRpBxvEEAdYl9EWCzLG4LNHkumrUDapsePhF+GN77qWLGYXT5brgrY3mBVd/tr6l9Q\n\tThFICplfHXAmUYBUDJMoqeYFtGofzmw0F1L1DgGdt3MPzEwsrGjCN4fL0AvvPJXTNnUZ\n\tdXSpjL1/ujkjY0k/2b80/oUw5FZc979q8ltqOQNeMr2PtYDVt/Het97HtnTBoafmOwMD\n\todLVj60sNMU9CmxT36NflBfFXYiSO+P7WU932KnVoL2r29Uu6M1HCALNEvzRX+jPgFeZ\n\tsN7A==","X-Gm-Message-State":"AOAM531sofbv46xlaTGKWr+9k8u2B73xuSKBizFPyhCADATtwYDGXtm4\n\tPCjbQUyFcPbUS079UBaUf2Dg4g==","X-Google-Smtp-Source":"ABdhPJyfsBFHK/GQmsWHyvo1PTPndM/wVu+zQDEPcSHUI+7QU5JU3olzHGntFuEEjyLx4k1PqgOyuw==","X-Received":"by 2002:a2e:b525:: with SMTP id\n\tz5mr25878272ljm.344.1609263092700; \n\tTue, 29 Dec 2020 09:31:32 -0800 (PST)","Date":"Tue, 29 Dec 2020 18:31:30 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<X+tn8orKB940/669@oden.dyn.berto.se>","References":"<20201228165203.53771-1-jacopo@jmondi.org>\n\t<20201228165203.53771-4-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20201228165203.53771-4-jacopo@jmondi.org>","Subject":"Re: [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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":14408,"web_url":"https://patchwork.libcamera.org/comment/14408/","msgid":"<20201230081922.z4qxzepmdjyseknm@uno.localdomain>","date":"2020-12-30T08:19:22","subject":"Re: [libcamera-devel] [PATCH v3 3/4] android: camera_device: Report\n\tsensor physical size","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Tue, Dec 29, 2020 at 06:31:30PM +0100, Niklas Söderlund wrote:\n> Hi Jacopo,\n>\n> Thanks for your work.\n>\n> On 2020-12-28 17:52:02 +0100, Jacopo Mondi wrote:\n> > Calculate the value of the ANDROID_SENSOR_INFO_PHYSICAL_SIZE property\n> > multiplying the pixel unit cell size with the number of sensor's readable\n> > pixels.\n> >\n> > Maintain a default value to support pipelines that do not register\n> > the UnitCellSize property.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  src/android/camera_device.cpp | 38 ++++++++++++++++++++---------------\n> >  1 file changed, 22 insertions(+), 16 deletions(-)\n> >\n> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> > index 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>\n> Instead of adding special cases for cameras that does not report all\n> controls that the HAL needs would it make sens to add default values in\n> the CameraSensor/SensorDatabase classes? I'm thinking this could create\n> a leaner HAL implementation as the HAL is already rather complex and we\n> would collect all defaults values in components that are designed to\n> provided them. As an added bonus the controls would also be visible\n> outside the HAL and possibly increasing the usage of them in other parts\n> of the code?\n\nI would rather think the contrary: if the property is not available\nlibcamera should not expose it. There's no much sense in providing\ndefault information, it might even mis-lead application.\n\nWe have defaults here to give time to all the test devices we have to\ncatch up with new requirements and do not break developments in the\nmeantime. After all we started with defaults in the HAL, so we're not\nmaking things worst by still reporting them. Down the line, as the\ntodo entry reports, we should aim at removing defaults from here too.\n\n>\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> > --\n> > 2.29.2\n> >\n> > _______________________________________________\n> > libcamera-devel mailing list\n> > libcamera-devel@lists.libcamera.org\n> > https://lists.libcamera.org/listinfo/libcamera-devel\n>\n> --\n> Regards,\n> Niklas Söderlund","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 D3802C0F1C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 30 Dec 2020 08:19:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5BFF7615B2;\n\tWed, 30 Dec 2020 09:19:10 +0100 (CET)","from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DFD1F6031B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 30 Dec 2020 09:19:08 +0100 (CET)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 3A9AC1BF209;\n\tWed, 30 Dec 2020 08:19:07 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Wed, 30 Dec 2020 09:19:22 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Message-ID":"<20201230081922.z4qxzepmdjyseknm@uno.localdomain>","References":"<20201228165203.53771-1-jacopo@jmondi.org>\n\t<20201228165203.53771-4-jacopo@jmondi.org>\n\t<X+tn8orKB940/669@oden.dyn.berto.se>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<X+tn8orKB940/669@oden.dyn.berto.se>","Subject":"Re: [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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]