[{"id":3206,"web_url":"https://patchwork.libcamera.org/comment/3206/","msgid":"<20191206224741.GU28879@bigcity.dyn.berto.se>","date":"2019-12-06T22:47:41","subject":"Re: [libcamera-devel] [PATCH v2 09/10] android: camera_device: Use\n\tCamera properties for static Metadata","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nI really like this patch!\n\nOn 2019-12-05 21:43:49 +0100, Jacopo Mondi wrote:\n> Construct two example static metadata to be reported to the Android\n> framework using the properties reported by the Camera.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/android/camera_device.cpp | 29 +++++++++++++++++++++++++++--\n>  1 file changed, 27 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> index 065e0292e186..e01c7fb2e541 100644\n> --- a/src/android/camera_device.cpp\n> +++ b/src/android/camera_device.cpp\n> @@ -7,6 +7,9 @@\n>  \n>  #include \"camera_device.h\"\n>  \n> +#include <libcamera/controls.h>\n> +#include <libcamera/property_ids.h>\n> +\n>  #include \"log.h\"\n>  #include \"utils.h\"\n>  \n> @@ -97,6 +100,8 @@ camera_metadata_t *CameraDevice::getStaticMetadata()\n>  \tif (staticMetadata_)\n>  \t\treturn staticMetadata_->get();\n>  \n> +\tconst ControlList &properties = camera_->properties();\n> +\n>  \t/*\n>  \t * The here reported metadata are enough to implement a basic capture\n>  \t * example application, but a real camera implementation will require\n> @@ -261,9 +266,15 @@ camera_metadata_t *CameraDevice::getStaticMetadata()\n>  \tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE,\n>  \t\t\t\t  &exposureTimeRange, 2);\n>  \n> +\t/*\n> +\t * Android reports orientation as clockwise correction, while libcamera\n> +\t * uses counter-clockwise.\n> +\t */\n>  \tint32_t orientation = 0;\n> -\tstaticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION,\n> -\t\t\t\t  &orientation, 1);\n> +\tif (properties.contains(properties::Rotation))\n> +\t\torientation = (360 - properties.get(properties::Rotation))\n> +\t\t\t    % 360;\n\nIf we limit properties::Rotation to 0 - 360 degrees the mod operation is \nnot need here.\n\nWith or without adding the bound in previous patches and dropping the \nmod here,\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> +\tstaticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, &orientation, 1);\n>  \n>  \tstd::vector<int32_t> testPatterModes = {\n>  \t\tANDROID_SENSOR_TEST_PATTERN_MODE_OFF,\n> @@ -310,6 +321,20 @@ camera_metadata_t *CameraDevice::getStaticMetadata()\n>  \t\t\t\t  lensApertures.size());\n>  \n>  \tuint8_t lensFacing = ANDROID_LENS_FACING_FRONT;\n> +\tif (properties.contains(properties::Location)) {\n> +\t\tint32_t location = properties.get(properties::Location);\n> +\t\tswitch (location) {\n> +\t\tcase CAMERA_LOCATION_FRONT:\n> +\t\t\tlensFacing = ANDROID_LENS_FACING_FRONT;\n> +\t\t\tbreak;\n> +\t\tcase CAMERA_LOCATION_BACK:\n> +\t\t\tlensFacing = ANDROID_LENS_FACING_BACK;\n> +\t\t\tbreak;\n> +\t\tcase CAMERA_LOCATION_EXTERNAL:\n> +\t\t\tlensFacing = ANDROID_LENS_FACING_EXTERNAL;\n> +\t\t\tbreak;\n> +\t\t}\n> +\t}\n>  \tstaticMetadata_->addEntry(ANDROID_LENS_FACING, &lensFacing, 1);\n>  \n>  \tstd::vector<float> lensFocalLenghts = {\n> -- \n> 2.23.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":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x243.google.com (mail-lj1-x243.google.com\n\t[IPv6:2a00:1450:4864:20::243])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 847ED60BBC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri,  6 Dec 2019 23:47:42 +0100 (CET)","by mail-lj1-x243.google.com with SMTP id j6so9367120lja.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 06 Dec 2019 14:47:42 -0800 (PST)","from localhost (h-93-159.A463.priv.bahnhof.se. [46.59.93.159])\n\tby smtp.gmail.com with ESMTPSA id\n\tu19sm7176944ljk.75.2019.12.06.14.47.41\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 06 Dec 2019 14:47:41 -0800 (PST)"],"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\t:user-agent; bh=oBim006UCQC9o4DAuCnk5V9q1GN8A8/Qef3zFfVACos=;\n\tb=SiPMGba0oxwYh6N6PDfzgealdADU62TQMrwgH0OZZ9eJk9YtTqjuXgXlhMAVBEJbwq\n\teCmDcn/K9p26GfH1CGio3k1/OTbPIwFu0KYN7rTtZu2Le/SKFy3MvoDkIAN0P5BP8jMb\n\t61gfMxXX8ncjZbUknv6M+zU0A5wLxCqt8X6yjgMAa8tmGvzF0vif1K3LFwuzMQf8AMla\n\tZOA3PoftGiidTw4aK0IeBmQZs8XUiTrWT6EqvLhnG6gpLzaqqjLun2NoHYWfLfQiajaw\n\tAmu+CpE+PGzcK9pKB4DybabYX0QftOaUwlumHW2XaJSS4XN6NVaCEXWFYelJK9SPwBxJ\n\tMa9A==","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:user-agent;\n\tbh=oBim006UCQC9o4DAuCnk5V9q1GN8A8/Qef3zFfVACos=;\n\tb=I1ius7TWd58xnZ5WOSFyKVIfip7nuX9Ayd72O1khfHp/JyblocJjOQKXu7KDN/lHME\n\tpkuLJCk1F0QdL3iVY6gMY+kXZs6YJ30l52XH47KNoEN1zhm/gUzwxinBn7Li9vWitk5p\n\tl5rQEIv0BuBfIDeL4CioHvXFa/aZ1CnVvfP1doR/6/6rCL2YEXHA8h/1w+ocIAqBIYHK\n\t1dzRI3lQT6OrNhg07/oK4f6ZMbL1yQJhUo/dzFAg2ZtOd08MQb/sWcTSPfKg4+RE5CAl\n\tR9HVgOwkp3lqlcJZUH8UqaJRXuTcgCozN+Aune2UvHf7SgdXDtntNpN1i3aBzVrSH/Zq\n\t4Ikw==","X-Gm-Message-State":"APjAAAXWHUA8UDNXUW5VoUZJI7Oqjrc6KIp9WnSaIfFGgmCX/m0pw74I\n\ta0NpqEqMIVZl96497kfypVU4yA==","X-Google-Smtp-Source":"APXvYqykx6tqmyCjB1TnWnQ3m60UK7lhNh6PKjXf1MCR/dSEaBPMnbaUApHVPVH3mbB+/MY6BHzNFQ==","X-Received":"by 2002:a2e:9708:: with SMTP id r8mr10041070lji.92.1575672462004;\n\tFri, 06 Dec 2019 14:47:42 -0800 (PST)","Date":"Fri, 6 Dec 2019 23:47:41 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191206224741.GU28879@bigcity.dyn.berto.se>","References":"<20191205204350.28196-1-jacopo@jmondi.org>\n\t<20191205204350.28196-10-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20191205204350.28196-10-jacopo@jmondi.org>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH v2 09/10] android: camera_device: Use\n\tCamera properties for static Metadata","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>","X-List-Received-Date":"Fri, 06 Dec 2019 22:47:42 -0000"}},{"id":3211,"web_url":"https://patchwork.libcamera.org/comment/3211/","msgid":"<20191208181819.rwzzmubuclba6uof@uno.localdomain>","date":"2019-12-08T18:18:19","subject":"Re: [libcamera-devel] [PATCH v2 09/10] android: camera_device: Use\n\tCamera properties for static Metadata","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Fri, Dec 06, 2019 at 11:47:41PM +0100, Niklas Söderlund wrote:\n> Hi Jacopo,\n>\n> I really like this patch!\n>\n\nThanks, I'm happy the direction this series takes is welcome\n\n> On 2019-12-05 21:43:49 +0100, Jacopo Mondi wrote:\n> > Construct two example static metadata to be reported to the Android\n> > framework using the properties reported by the Camera.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  src/android/camera_device.cpp | 29 +++++++++++++++++++++++++++--\n> >  1 file changed, 27 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\n> > index 065e0292e186..e01c7fb2e541 100644\n> > --- a/src/android/camera_device.cpp\n> > +++ b/src/android/camera_device.cpp\n> > @@ -7,6 +7,9 @@\n> >\n> >  #include \"camera_device.h\"\n> >\n> > +#include <libcamera/controls.h>\n> > +#include <libcamera/property_ids.h>\n> > +\n> >  #include \"log.h\"\n> >  #include \"utils.h\"\n> >\n> > @@ -97,6 +100,8 @@ camera_metadata_t *CameraDevice::getStaticMetadata()\n> >  \tif (staticMetadata_)\n> >  \t\treturn staticMetadata_->get();\n> >\n> > +\tconst ControlList &properties = camera_->properties();\n> > +\n> >  \t/*\n> >  \t * The here reported metadata are enough to implement a basic capture\n> >  \t * example application, but a real camera implementation will require\n> > @@ -261,9 +266,15 @@ camera_metadata_t *CameraDevice::getStaticMetadata()\n> >  \tstaticMetadata_->addEntry(ANDROID_SENSOR_INFO_EXPOSURE_TIME_RANGE,\n> >  \t\t\t\t  &exposureTimeRange, 2);\n> >\n> > +\t/*\n> > +\t * Android reports orientation as clockwise correction, while libcamera\n> > +\t * uses counter-clockwise.\n> > +\t */\n> >  \tint32_t orientation = 0;\n> > -\tstaticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION,\n> > -\t\t\t\t  &orientation, 1);\n> > +\tif (properties.contains(properties::Rotation))\n> > +\t\torientation = (360 - properties.get(properties::Rotation))\n> > +\t\t\t    % 360;\n>\n> If we limit properties::Rotation to 0 - 360 degrees the mod operation is\n> not need here.\n\nI need the modulo operation to make sure a rotation of 0 degrees, it's\nactually 0, otherwise 360 - 0 = 360\n\n>\n> With or without adding the bound in previous patches and dropping the\n> mod here,\n\nIt should be bounded and verified by kernel, but we can stay safe and\ndo the same when parsing the property maybe.\n\n>\n> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nThanks\n   j\n\n>\n> > +\tstaticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, &orientation, 1);\n> >\n> >  \tstd::vector<int32_t> testPatterModes = {\n> >  \t\tANDROID_SENSOR_TEST_PATTERN_MODE_OFF,\n> > @@ -310,6 +321,20 @@ camera_metadata_t *CameraDevice::getStaticMetadata()\n> >  \t\t\t\t  lensApertures.size());\n> >\n> >  \tuint8_t lensFacing = ANDROID_LENS_FACING_FRONT;\n> > +\tif (properties.contains(properties::Location)) {\n> > +\t\tint32_t location = properties.get(properties::Location);\n> > +\t\tswitch (location) {\n> > +\t\tcase CAMERA_LOCATION_FRONT:\n> > +\t\t\tlensFacing = ANDROID_LENS_FACING_FRONT;\n> > +\t\t\tbreak;\n> > +\t\tcase CAMERA_LOCATION_BACK:\n> > +\t\t\tlensFacing = ANDROID_LENS_FACING_BACK;\n> > +\t\t\tbreak;\n> > +\t\tcase CAMERA_LOCATION_EXTERNAL:\n> > +\t\t\tlensFacing = ANDROID_LENS_FACING_EXTERNAL;\n> > +\t\t\tbreak;\n> > +\t\t}\n> > +\t}\n> >  \tstaticMetadata_->addEntry(ANDROID_LENS_FACING, &lensFacing, 1);\n> >\n> >  \tstd::vector<float> lensFocalLenghts = {\n> > --\n> > 2.23.0\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":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 082E360BD1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  8 Dec 2019 19:16:13 +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 relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 6E71DC0003;\n\tSun,  8 Dec 2019 18:16:12 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Sun, 8 Dec 2019 19:18:19 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191208181819.rwzzmubuclba6uof@uno.localdomain>","References":"<20191205204350.28196-1-jacopo@jmondi.org>\n\t<20191205204350.28196-10-jacopo@jmondi.org>\n\t<20191206224741.GU28879@bigcity.dyn.berto.se>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"m6vdsysmrmagromz\"","Content-Disposition":"inline","In-Reply-To":"<20191206224741.GU28879@bigcity.dyn.berto.se>","Subject":"Re: [libcamera-devel] [PATCH v2 09/10] android: camera_device: Use\n\tCamera properties for static Metadata","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>","X-List-Received-Date":"Sun, 08 Dec 2019 18:16:13 -0000"}}]