Show a patch.

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

{
    "id": 11768,
    "url": "https://patchwork.libcamera.org/api/patches/11768/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11768/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/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": "<20210329152807.28331-5-jacopo@jmondi.org>",
    "date": "2021-03-29T15:28:06",
    "name": "[libcamera-devel,v2,5/6] android: camera_device: Get location from config",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "41a3ae9a2c672917dfbf8b8fc94bd608e6e37659",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": {
        "id": 15,
        "url": "https://patchwork.libcamera.org/api/users/15/?format=api",
        "username": "jmondi",
        "first_name": "Jacopo",
        "last_name": "Mondi",
        "email": "jacopo@jmondi.org"
    },
    "mbox": "https://patchwork.libcamera.org/patch/11768/mbox/",
    "series": [
        {
            "id": 1862,
            "url": "https://patchwork.libcamera.org/api/series/1862/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1862",
            "date": "2021-03-29T15:28:02",
            "name": "[libcamera-devel,v2,1/6] libcamera: List dependency for Android Camera3 HAL",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/1862/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11768/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11768/checks/",
    "tags": {},
    "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 9B878C32F0\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 29 Mar 2021 15:27:45 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 673A668783;\n\tMon, 29 Mar 2021 17:27:45 +0200 (CEST)",
            "from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9C7F168789\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 29 Mar 2021 17:27:39 +0200 (CEST)",
            "from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 38AE840009;\n\tMon, 29 Mar 2021 15:27:39 +0000 (UTC)"
        ],
        "X-Originating-IP": "93.34.118.233",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 29 Mar 2021 17:28:06 +0200",
        "Message-Id": "<20210329152807.28331-5-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.30.0",
        "In-Reply-To": "<20210329152807.28331-1-jacopo@jmondi.org>",
        "References": "<20210329152807.28331-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v2 5/6] android: camera_device: Get\n\tlocation from config",
        "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>",
        "Content-Type": "text/plain; charset=\"us-ascii\"",
        "Content-Transfer-Encoding": "7bit",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Create the CameraDevice with a reference to the HAL configuration\nfile and use it to retrieve the camera location if not available\nfrom the Camera.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp      | 18 +++++++++---------\n src/android/camera_device.h        |  8 ++++++--\n src/android/camera_hal_manager.cpp |  3 ++-\n 3 files changed, 17 insertions(+), 12 deletions(-)",
    "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex ae6936647660..1731fe166887 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -309,9 +309,10 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor() = default;\n  * back to the framework using the designated callbacks.\n  */\n \n-CameraDevice::CameraDevice(unsigned int id, std::shared_ptr<Camera> camera)\n+CameraDevice::CameraDevice(unsigned int id, std::shared_ptr<Camera> camera,\n+\t\t\t   CameraHalConfig &halConfig)\n \t: id_(id), running_(false), camera_(std::move(camera)),\n-\t  facing_(CAMERA_FACING_FRONT), orientation_(0)\n+\t  halConfig_(halConfig), facing_(CAMERA_FACING_FRONT), orientation_(0)\n {\n \tcamera_->requestCompleted.connect(this, &CameraDevice::requestComplete);\n \n@@ -341,10 +342,11 @@ CameraDevice::CameraDevice(unsigned int id, std::shared_ptr<Camera> camera)\n CameraDevice::~CameraDevice() = default;\n \n std::unique_ptr<CameraDevice> CameraDevice::create(unsigned int id,\n-\t\t\t\t\t\t   std::shared_ptr<Camera> cam)\n+\t\t\t\t\t\t   std::shared_ptr<Camera> cam,\n+\t\t\t\t\t\t   CameraHalConfig &halConfig)\n {\n \treturn std::unique_ptr<CameraDevice>(\n-\t\tnew CameraDevice(id, std::move(cam)));\n+\t\tnew CameraDevice(id, std::move(cam), halConfig));\n }\n \n /*\n@@ -370,11 +372,9 @@ int CameraDevice::initialize()\n \t\t\tbreak;\n \t\t}\n \t} else {\n-\t\t/*\n-\t\t * \\todo Retrieve the camera location from configuration file\n-\t\t * if not available from the library.\n-\t\t */\n-\t\tfacing_ = CAMERA_FACING_FRONT;\n+\t\tfacing_ = halConfig_.cameraLocation(camera_->id());\n+\t\tif (facing_ < 0)\n+\t\t\treturn facing_;\n \t}\n \n \t/*\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 11bdfec8d587..6355e8d8c26a 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -24,6 +24,7 @@\n #include \"libcamera/internal/log.h\"\n #include \"libcamera/internal/message.h\"\n \n+#include \"camera_hal_config.h\"\n #include \"camera_metadata.h\"\n #include \"camera_stream.h\"\n #include \"camera_worker.h\"\n@@ -33,7 +34,8 @@ class CameraDevice : protected libcamera::Loggable\n {\n public:\n \tstatic std::unique_ptr<CameraDevice> create(unsigned int id,\n-\t\t\t\t\t\t    std::shared_ptr<libcamera::Camera> cam);\n+\t\t\t\t\t\t    std::shared_ptr<libcamera::Camera> cam,\n+\t\t\t\t\t\t    CameraHalConfig &halConfig);\n \t~CameraDevice();\n \n \tint initialize();\n@@ -66,7 +68,8 @@ protected:\n \tstd::string logPrefix() const override;\n \n private:\n-\tCameraDevice(unsigned int id, std::shared_ptr<libcamera::Camera> camera);\n+\tCameraDevice(unsigned int id, std::shared_ptr<libcamera::Camera> camera,\n+\t\t     CameraHalConfig &halConfig);\n \n \tstruct Camera3RequestDescriptor {\n \t\tCamera3RequestDescriptor(libcamera::Camera *camera,\n@@ -113,6 +116,7 @@ private:\n \tbool running_;\n \tstd::shared_ptr<libcamera::Camera> camera_;\n \tstd::unique_ptr<libcamera::CameraConfiguration> config_;\n+\tconst CameraHalConfig &halConfig_;\n \n \tstd::unique_ptr<CameraMetadata> staticMetadata_;\n \tstd::map<unsigned int, std::unique_ptr<CameraMetadata>> requestTemplates_;\ndiff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\nindex f79789b5bfb8..9ff7534a16f3 100644\n--- a/src/android/camera_hal_manager.cpp\n+++ b/src/android/camera_hal_manager.cpp\n@@ -120,7 +120,8 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n \t}\n \n \t/* Create a CameraDevice instance to wrap the libcamera Camera. */\n-\tstd::unique_ptr<CameraDevice> camera = CameraDevice::create(id, cam);\n+\tstd::unique_ptr<CameraDevice> camera = CameraDevice::create(id, cam,\n+\t\t\t\t\t\t\t\t    halConfig_);\n \tint ret = camera->initialize();\n \tif (ret) {\n \t\tLOG(HAL, Error) << \"Failed to initialize camera: \" << cam->id();\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "5/6"
    ]
}