{"id":2785,"url":"https://patchwork.libcamera.org/api/patches/2785/?format=json","web_url":"https://patchwork.libcamera.org/patch/2785/","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":"<20200206012601.153858-10-jacopo@jmondi.org>","date":"2020-02-06T01:26:01","name":"[libcamera-devel,v5,9/9] android: camera_device: Use Camera properties for static Metadata","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"ed965a8d19e5232bbf9de9a2fe9aa9a18c1f78b5","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/2785/mbox/","series":[{"id":662,"url":"https://patchwork.libcamera.org/api/series/662/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=662","date":"2020-02-06T01:25:52","name":"Introduce camera properties","version":5,"mbox":"https://patchwork.libcamera.org/series/662/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/2785/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/2785/checks/","tags":{},"headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay10.mail.gandi.net (relay10.mail.gandi.net\n\t[217.70.178.230])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5BEC5607E9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 Feb 2020 02:23:36 +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 relay10.mail.gandi.net (Postfix) with ESMTPSA id 30A8A240002\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  6 Feb 2020 01:23:36 +0000 (UTC)"],"From":"Jacopo Mondi <jacopo@jmondi.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  6 Feb 2020 02:26:01 +0100","Message-Id":"<20200206012601.153858-10-jacopo@jmondi.org>","X-Mailer":"git-send-email 2.24.1","In-Reply-To":"<20200206012601.153858-1-jacopo@jmondi.org>","References":"<20200206012601.153858-1-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=UTF-8","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 9/9] android: camera_device: Use Camera\n\tproperties 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":"Thu, 06 Feb 2020 01:23:38 -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: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\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 67c1d47e67ed..96674698cece 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@@ -95,6 +98,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@@ -259,9 +264,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 * The Android orientation metadata and libcamera rotation property are\n+\t * defined differently but have identical numerical values for Android\n+\t * devices such as phones and tablets.\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 = properties.get(properties::Rotation);\n+\tstaticMetadata_->addEntry(ANDROID_SENSOR_ORIENTATION, &orientation, 1);\n \n \tstd::vector<int32_t> testPatterModes = {\n \t\tANDROID_SENSOR_TEST_PATTERN_MODE_OFF,\n@@ -308,6 +319,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","v5","9/9"]}