[{"id":11692,"web_url":"https://patchwork.libcamera.org/comment/11692/","msgid":"<20200729085106.mkzpynwqxczu7ziw@uno.localdomain>","date":"2020-07-29T08:51:06","subject":"Re: [libcamera-devel] [PATCH 3/3] android: camera_device: Report\n\tRAW capability if supported","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Tue, Jul 28, 2020 at 08:55:48PM +0200, Niklas Söderlund wrote:\n> Probe the libcamera Camera for RAW support and if supported report RAW\n> capability in the static metadata reported to Android.\n>\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/android/camera_device.cpp | 10 ++++++++++\n>  1 file changed, 10 insertions(+)\n>\n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 95a563b1aafe86de..76c128564550419a 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -15,6 +15,7 @@\n>  #include <libcamera/formats.h>\n>  #include <libcamera/property_ids.h>\n>\n> +#include \"libcamera/internal/formats.h\"\n>  #include \"libcamera/internal/log.h\"\n>  #include \"libcamera/internal/utils.h\"\n>\n> @@ -727,6 +728,15 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n>  \tstd::vector<uint8_t> availableCapabilities = {\n>  \t\tANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE,\n>  \t};\n> +\n> +\t/* Report if camera supports RAW. */\n> +\tstd::unique_ptr<CameraConfiguration> cameraConfig =\n> +\t\tcamera_->generateConfiguration({ StillCaptureRaw });\n> +\tconst PixelFormatInfo &info =\n> +\t\tPixelFormatInfo::info(cameraConfig->at(0).pixelFormat);\n> +\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)\n> +\t\tavailableCapabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW);\n> +\n\nThe documentation reports\n\n\"RAW (v3.2) [optional]\nThe camera device supports outputting RAW buffers and metadata for\ninterpreting them.  Devices supporting the RAW capability allow both\nfor saving DNG files, and for direct application processing of raw\nsensor images.\n\nRAW_SENSOR is supported as an output format.\nThe maximum available resolution for RAW_SENSOR streams will match\neither the value in android.sensor.info.pixelArraySize or\nandroid.sensor.info.preCorrectionActiveArraySize.  All DNG-related\noptional metadata entries are provided by the camera device.\"\n\nSearching the documentation I see a few mentions of RAW_SENSOR and\n\"supported as an output format\" might means that we just need to\nreport one RAW streams as part of the\nANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT property as\nwe're doing already.\n\nThe size check might instead be faulty. Currently the list of\nresolutions to test against a format to construct the\nstreamConfigurations_ output formats map is taken from\n\n\tstd::unique_ptr<CameraConfiguration> cameraConfig =\n\t\tcamera_->generateConfiguration({ StillCapture });\n\tStreamConfiguration &cfg = cameraConfig->at(0);\n\tconst Size maxRes = cfg.size;\n\nHence, it's not the pixelArraySize. It will, as there's a comment\nabove the preceeding block that says:\n\t * \\todo Get this from the camera properties once defined\n\nBut at the moment, it's not. I wonder if we should record a todo for\nraw or just let this happen.\n\nAnyway, I encourage to run CTS and cros_camera_test once new features\nare advertised to the camera service to know if all the required\nproperties are actually there.\n\nThanks\n  j\n\n>  \tstaticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES,\n>  \t\t\t\t  availableCapabilities.data(),\n>  \t\t\t\t  availableCapabilities.size());\n> --\n> 2.27.0\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 53E8DBD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Jul 2020 08:47:28 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EAF31613C6;\n\tWed, 29 Jul 2020 10:47:27 +0200 (CEST)","from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D36B7605B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Jul 2020 10:47:26 +0200 (CEST)","from uno.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay1-d.mail.gandi.net (Postfix) with ESMTPSA id F2FC5240005;\n\tWed, 29 Jul 2020 08:47:25 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","Date":"Wed, 29 Jul 2020 10:51:06 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Message-ID":"<20200729085106.mkzpynwqxczu7ziw@uno.localdomain>","References":"<20200728185548.3361465-1-niklas.soderlund@ragnatech.se>\n\t<20200728185548.3361465-4-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200728185548.3361465-4-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH 3/3] android: camera_device: Report\n\tRAW capability if supported","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>"}},{"id":11702,"web_url":"https://patchwork.libcamera.org/comment/11702/","msgid":"<20200729111048.GA322953@oden.dyn.berto.se>","date":"2020-07-29T11:10:48","subject":"Re: [libcamera-devel] [PATCH 3/3] android: camera_device: Report\n\tRAW capability if supported","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 comments.\n\nOn 2020-07-29 10:51:06 +0200, Jacopo Mondi wrote:\n> Hi Niklas,\n> \n> On Tue, Jul 28, 2020 at 08:55:48PM +0200, Niklas Söderlund wrote:\n> > Probe the libcamera Camera for RAW support and if supported report RAW\n> > capability in the static metadata reported to Android.\n> >\n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> >  src/android/camera_device.cpp | 10 ++++++++++\n> >  1 file changed, 10 insertions(+)\n> >\n> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> > index 95a563b1aafe86de..76c128564550419a 100644\n> > --- a/src/android/camera_device.cpp\n> > +++ b/src/android/camera_device.cpp\n> > @@ -15,6 +15,7 @@\n> >  #include <libcamera/formats.h>\n> >  #include <libcamera/property_ids.h>\n> >\n> > +#include \"libcamera/internal/formats.h\"\n> >  #include \"libcamera/internal/log.h\"\n> >  #include \"libcamera/internal/utils.h\"\n> >\n> > @@ -727,6 +728,15 @@ const camera_metadata_t *CameraDevice::getStaticMetadata()\n> >  \tstd::vector<uint8_t> availableCapabilities = {\n> >  \t\tANDROID_REQUEST_AVAILABLE_CAPABILITIES_BACKWARD_COMPATIBLE,\n> >  \t};\n> > +\n> > +\t/* Report if camera supports RAW. */\n> > +\tstd::unique_ptr<CameraConfiguration> cameraConfig =\n> > +\t\tcamera_->generateConfiguration({ StillCaptureRaw });\n> > +\tconst PixelFormatInfo &info =\n> > +\t\tPixelFormatInfo::info(cameraConfig->at(0).pixelFormat);\n> > +\tif (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW)\n> > +\t\tavailableCapabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW);\n> > +\n> \n> The documentation reports\n> \n> \"RAW (v3.2) [optional]\n> The camera device supports outputting RAW buffers and metadata for\n> interpreting them.  Devices supporting the RAW capability allow both\n> for saving DNG files, and for direct application processing of raw\n> sensor images.\n> \n> RAW_SENSOR is supported as an output format.\n> The maximum available resolution for RAW_SENSOR streams will match\n> either the value in android.sensor.info.pixelArraySize or\n> android.sensor.info.preCorrectionActiveArraySize.  All DNG-related\n> optional metadata entries are provided by the camera device.\"\n> \n> Searching the documentation I see a few mentions of RAW_SENSOR and\n> \"supported as an output format\" might means that we just need to\n> report one RAW streams as part of the\n> ANDROID_SCALER_AVAILABLE_STREAM_CONFIGURATIONS_OUTPUT property as\n> we're doing already.\n\nI was a bit confused about this at first as well. Then after digging \nthru the code it dawned on me, RAW_SENSOR == RAW16. In earlier code only \nRAW16 was supported and the snapshot of the code base we are targeting \nthe transition does not seems to be complete in all parts of the \ndocumentation.\n\nSee ANDROID_SCALER_AVAILABLE_FORMATS_RAW16 vs HAL_PIXEL_FORMAT_RAW16. At \nour code point the NDROID_SCALER_AVAILABLE_FORMATS_* are depricated in \nfavor of HAL_PIXEL_FORMAT_* but the intersection between the two are \nkept ABI compatible.\n\n> \n> The size check might instead be faulty. Currently the list of\n> resolutions to test against a format to construct the\n> streamConfigurations_ output formats map is taken from\n> \n> \tstd::unique_ptr<CameraConfiguration> cameraConfig =\n> \t\tcamera_->generateConfiguration({ StillCapture });\n> \tStreamConfiguration &cfg = cameraConfig->at(0);\n> \tconst Size maxRes = cfg.size;\n> \n> Hence, it's not the pixelArraySize. It will, as there's a comment\n> above the preceeding block that says:\n> \t * \\todo Get this from the camera properties once defined\n> \n> But at the moment, it's not. I wonder if we should record a todo for\n> raw or just let this happen.\n\nI read the TODO and toight it was enough. There are so much that needs \nto be fetched from the camera and I think we should let it happen as a \nlarger targeted change.\n\n> \n> Anyway, I encourage to run CTS and cros_camera_test once new features\n> are advertised to the camera service to know if all the required\n> properties are actually there.\n> \n> Thanks\n>   j\n> \n> >  \tstaticMetadata_->addEntry(ANDROID_REQUEST_AVAILABLE_CAPABILITIES,\n> >  \t\t\t\t  availableCapabilities.data(),\n> >  \t\t\t\t  availableCapabilities.size());\n> > --\n> > 2.27.0\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 17A7ABD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 29 Jul 2020 11:10:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 70F4E613C6;\n\tWed, 29 Jul 2020 13:10:51 +0200 (CEST)","from mail-lf1-x143.google.com (mail-lf1-x143.google.com\n\t[IPv6:2a00:1450:4864:20::143])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B2CEB6039D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Jul 2020 13:10:50 +0200 (CEST)","by mail-lf1-x143.google.com with SMTP id d2so7157533lfj.1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 29 Jul 2020 04:10:50 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\ta23sm330155ljp.121.2020.07.29.04.10.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 29 Jul 2020 04:10:49 -0700 (PDT)"],"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=\"P4/0gpYg\"; 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=dz4n8mm5Q4/nYeB2PFXVyTqSohcEG+vu8RWRxBVSK5Q=;\n\tb=P4/0gpYgRaYsOhfABJ9Jc0Vpx/YrqHsplHc7R0VAJk2PDNoJF05FpuqnF+vTvp1DNd\n\tf1hZT2LuVBZCmXEGpMhvnNPxEqhwnAWuPbVkUt7bebdeFje7KDLVCAZrN7X0XNucxZ0D\n\t5DKeZ6KKlsc+rIeJwwltPY+/ngclyma+ZtjoCyyJGfqPYKgHikt2d7K+JZaAL5R9eegQ\n\tPEDt03VhqflnrVhp8a38xuQ7PPjGiSQ4a7jkoTK7GgLrIYz+SWWZRNAzwrO+bNiGaGwR\n\tZU83WoV+X4w0+wHYvrWdCZcyQiHcUTparvtxN05vRPLVEqtD6xPbikpws2JI6tW0LLe7\n\tK7Tw==","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=dz4n8mm5Q4/nYeB2PFXVyTqSohcEG+vu8RWRxBVSK5Q=;\n\tb=EoaRSU0hN4loLfsEi3yBqf5AChjfamuZOIBQerwAknS+nMSyxEErZlncTNZB7KiKDw\n\tYsz4X1XI9AiXskucOdF+jJCM0GxPfp3L+5FV7e6SSlpil+V8mB4netRLZKfVPIa6Obua\n\tRQb/x60HBwl2fSZICDZUJjdyMT4iVUQkDdR6X/z16tPC4DEN2IVVTy/SSW/9VNuYcMbW\n\tetD9qvHfL9DE3uMvuwGIE+gjF7OzWhOU45zqGA84J+c7Fd1ECZVhn5PVaVrJMwRvyFqh\n\tVKmJhgITbH3xpT6wHo+3DX76BGAeZe8xxmFa8tZl1cmKuWa7moe8Yf+f0HS7aF0cpMTj\n\tarAg==","X-Gm-Message-State":"AOAM533CGzXF3iojsjzNmEhDNDZfnxXow+uHQcTv7MyqKuaotuOEJvkJ\n\tthCRkixovn0Eanem+nqqVBeAGA==","X-Google-Smtp-Source":"ABdhPJyCdkHjpGI0J0okgR1DvnNvkwQ+YkD0gv1bYtlLHwMj8/Z9PN/eRtUDjteuTSRFTIXEUm+ITA==","X-Received":"by 2002:a05:6512:3138:: with SMTP id\n\tp24mr17209271lfd.143.1596021049996; \n\tWed, 29 Jul 2020 04:10:49 -0700 (PDT)","Date":"Wed, 29 Jul 2020 13:10:48 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200729111048.GA322953@oden.dyn.berto.se>","References":"<20200728185548.3361465-1-niklas.soderlund@ragnatech.se>\n\t<20200728185548.3361465-4-niklas.soderlund@ragnatech.se>\n\t<20200729085106.mkzpynwqxczu7ziw@uno.localdomain>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200729085106.mkzpynwqxczu7ziw@uno.localdomain>","Subject":"Re: [libcamera-devel] [PATCH 3/3] android: camera_device: Report\n\tRAW capability if supported","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>"}}]