Show a patch.

GET /api/1.1/patches/2393/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2393,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2393/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2393/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20191204132106.21582-10-jacopo@jmondi.org>",
    "date": "2019-12-04T13:21:05",
    "name": "[libcamera-devel,09/10] android: camera_device: Use Camera properties for static Metadata",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "f68067efdac8f8fd7be324107637cf5ecc5bd09a",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2393/mbox/",
    "series": [
        {
            "id": 581,
            "url": "https://patchwork.libcamera.org/api/1.1/series/581/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=581",
            "date": "2019-12-04T13:20:56",
            "name": "Introduce camera properties",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/581/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2393/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2393/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 E0A8E61D19\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  4 Dec 2019 14:21: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 relay10.mail.gandi.net (Postfix) with ESMTPSA id 89A92240002;\n\tWed,  4 Dec 2019 13:21:24 +0000 (UTC)"
        ],
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed,  4 Dec 2019 14:21:05 +0100",
        "Message-Id": "<20191204132106.21582-10-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.23.0",
        "In-Reply-To": "<20191204132106.21582-1-jacopo@jmondi.org>",
        "References": "<20191204132106.21582-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 09/10] 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": "Wed, 04 Dec 2019 13:21:25 -0000"
    },
    "content": "Construct two example static metadata to be reported to the Android\nframework using the properties reported by the Camera.\n\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..674867d313ac 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 Linux\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 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",
    "prefixes": [
        "libcamera-devel",
        "09/10"
    ]
}