{"id":2541,"url":"https://patchwork.libcamera.org/api/patches/2541/?format=json","web_url":"https://patchwork.libcamera.org/patch/2541/","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":"<20200108163434.19530-10-jacopo@jmondi.org>","date":"2020-01-08T16:34:33","name":"[libcamera-devel,v4,09/10] android: camera_device: Use Camera properties for static Metadata","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"f690d88295a213929f1cd1f8d92caaf9593876ec","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/?format=json","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/2541/mbox/","series":[{"id":610,"url":"https://patchwork.libcamera.org/api/series/610/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=610","date":"2020-01-08T16:34:24","name":"Camera properties","version":4,"mbox":"https://patchwork.libcamera.org/series/610/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2541/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2541/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["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 6181B60674\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  8 Jan 2020 17:32:24 +0100 (CET)","from uno.lan (93-34-114-233.ip49.fastwebnet.it [93.34.114.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id C78891BF206;\n\tWed,  8 Jan 2020 16:32:23 +0000 (UTC)"],"X-Originating-IP":"93.34.114.233","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed,  8 Jan 2020 17:34:33 +0100","Message-Id":"<20200108163434.19530-10-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.24.0","In-Reply-To":"<20200108163434.19530-1-jacopo@jmondi.org>","References":"<20200108163434.19530-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 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":"Wed, 08 Jan 2020 16:32:24 -0000"},"content":"Construct two example static metadata to be reported to the Android\nframework using the properties reported by the Camera.\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp | 29 +++++++++++++++++++++++++++--\n 1 file changed, 27 insertions(+), 2 deletions(-)","diff":"diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 065e0292e186..f434ea2020bd 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+\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 properties::CameraLocationFront:\n+\t\t\tlensFacing = ANDROID_LENS_FACING_FRONT;\n+\t\t\tbreak;\n+\t\tcase properties::CameraLocationBack:\n+\t\t\tlensFacing = ANDROID_LENS_FACING_BACK;\n+\t\t\tbreak;\n+\t\tcase properties::CameraLocationExternal:\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","prefixes":["libcamera-devel","v4","09/10"]}