Show a patch.

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

{
    "id": 11849,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/11849/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11849/",
    "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": "<20210406154557.27303-5-jacopo@jmondi.org>",
    "date": "2021-04-06T15:45:56",
    "name": "[libcamera-devel,v4,4/5] android: camera_device: Get properties from configuration",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "0914888d12db83c50e9e2408fe024ad96ffd0b18",
    "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/11849/mbox/",
    "series": [
        {
            "id": 1896,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1896/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1896",
            "date": "2021-04-06T15:45:52",
            "name": "android: Introduce HAL configuration file",
            "version": 4,
            "mbox": "https://patchwork.libcamera.org/series/1896/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11849/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11849/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 9F61BBD695\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue,  6 Apr 2021 15:45:31 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3C8EB687E1;\n\tTue,  6 Apr 2021 17:45:31 +0200 (CEST)",
            "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 4F634687A1\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  6 Apr 2021 17:45:29 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id D6FF31BF204;\n\tTue,  6 Apr 2021 15:45:28 +0000 (UTC)"
        ],
        "X-Originating-IP": "93.34.118.233",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue,  6 Apr 2021 17:45:56 +0200",
        "Message-Id": "<20210406154557.27303-5-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20210406154557.27303-1-jacopo@jmondi.org>",
        "References": "<20210406154557.27303-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v4 4/5] android: camera_device: Get\n\tproperties from configuration",
        "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": "Open the HAL configuration file in the Camera HAL manager and get\nthe camera properties for each created CameraDevice and initialize it\nwith them.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp      | 29 ++++++++++++++++++++++-------\n src/android/camera_device.h        |  3 ++-\n src/android/camera_hal_manager.cpp | 21 +++++++++++++++++++--\n src/android/camera_hal_manager.h   |  3 +++\n 4 files changed, 46 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 89044efa7ebe..66030c012db0 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -6,6 +6,7 @@\n  */\n \n #include \"camera_device.h\"\n+#include \"camera_hal_config.h\"\n #include \"camera_ops.h\"\n #include \"post_processor.h\"\n \n@@ -446,9 +447,15 @@ std::unique_ptr<CameraDevice> CameraDevice::create(unsigned int id,\n  * Initialize the camera static information.\n  * This method is called before the camera device is opened.\n  */\n-int CameraDevice::initialize()\n+int CameraDevice::initialize(const CameraProps &cameraProps)\n {\n-\t/* Initialize orientation and facing side of the camera. */\n+\t/*\n+\t * Initialize orientation and facing side of the camera.\n+\t *\n+\t * If the libcamera::Camera provides those information as retrieved\n+\t * from firmware use that, otherwise fallback to values parsed from\n+\t * the configuration file.\n+\t */\n \tconst ControlList &properties = camera_->properties();\n \n \tif (properties.contains(properties::Location)) {\n@@ -464,12 +471,14 @@ int CameraDevice::initialize()\n \t\t\tfacing_ = CAMERA_FACING_EXTERNAL;\n \t\t\tbreak;\n \t\t}\n+\n+\t\tif (facing_ != cameraProps.facing)\n+\t\t\tLOG(HAL, Warning)\n+\t\t\t\t<< \"Camera location does not match\"\n+\t\t\t\t<< \" configuration file. Use \" << facing_;\n+\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_ = cameraProps.facing;\n \t}\n \n \t/*\n@@ -483,6 +492,12 @@ int CameraDevice::initialize()\n \tif (properties.contains(properties::Rotation)) {\n \t\tint rotation = properties.get(properties::Rotation);\n \t\torientation_ = (360 - rotation) % 360;\n+\t\tif (orientation_ != cameraProps.rotation)\n+\t\t\tLOG(HAL, Warning)\n+\t\t\t\t<< \"Camera orientation does not match\"\n+\t\t\t\t<< \" configuration file. Use \" << orientation_;\n+\t} else {\n+\t\torientation_ = cameraProps.rotation;\n \t}\n \n \tint ret = camera_->acquire();\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 11bdfec8d587..ba3ec8770e11 100644\n--- a/src/android/camera_device.h\n+++ b/src/android/camera_device.h\n@@ -29,6 +29,7 @@\n #include \"camera_worker.h\"\n #include \"jpeg/encoder.h\"\n \n+class CameraProps;\n class CameraDevice : protected libcamera::Loggable\n {\n public:\n@@ -36,7 +37,7 @@ public:\n \t\t\t\t\t\t    std::shared_ptr<libcamera::Camera> cam);\n \t~CameraDevice();\n \n-\tint initialize();\n+\tint initialize(const CameraProps &cameraProps);\n \n \tint open(const hw_module_t *hardwareModule);\n \tvoid close();\ndiff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\nindex bf3fcda75237..a517727ea0b8 100644\n--- a/src/android/camera_hal_manager.cpp\n+++ b/src/android/camera_hal_manager.cpp\n@@ -39,13 +39,17 @@ CameraHalManager::~CameraHalManager() = default;\n \n int CameraHalManager::init()\n {\n+\tint ret = halConfig_.open();\n+\tif (ret)\n+\t\treturn ret;\n+\n \tcameraManager_ = std::make_unique<CameraManager>();\n \n \t/* Support camera hotplug. */\n \tcameraManager_->cameraAdded.connect(this, &CameraHalManager::cameraAdded);\n \tcameraManager_->cameraRemoved.connect(this, &CameraHalManager::cameraRemoved);\n \n-\tint ret = cameraManager_->start();\n+\tret = cameraManager_->start();\n \tif (ret) {\n \t\tLOG(HAL, Error) << \"Failed to start camera manager: \"\n \t\t\t\t<< strerror(-ret);\n@@ -115,9 +119,22 @@ void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\n \t\t}\n \t}\n \n+\t/*\n+\t * Get camera properties from the configuration file.\n+\t *\n+\t * The camera properties as recorded in the configuration file\n+\t * supplement information that cannot be retrieved from the\n+\t * libcamera::Camera at run time.\n+\t */\n+\tconst CameraProps &cameraProps = halConfig_.cameraProps(cam->id());\n+\tif (!cameraProps.valid) {\n+\t\tLOG(HAL, Error) << \"Failed to register camera: \" << cam->id();\n+\t\treturn;\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-\tint ret = camera->initialize();\n+\tint ret = camera->initialize(cameraProps);\n \tif (ret) {\n \t\tLOG(HAL, Error) << \"Failed to initialize camera: \" << cam->id();\n \t\treturn;\ndiff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\nindex d9bf27989965..af1581da6579 100644\n--- a/src/android/camera_hal_manager.h\n+++ b/src/android/camera_hal_manager.h\n@@ -19,6 +19,8 @@\n \n #include <libcamera/camera_manager.h>\n \n+#include \"camera_hal_config.h\"\n+\n class CameraDevice;\n \n class CameraHalManager\n@@ -50,6 +52,7 @@ private:\n \tCameraDevice *cameraDeviceFromHalId(unsigned int id);\n \n \tstd::unique_ptr<libcamera::CameraManager> cameraManager_;\n+\tCameraHalConfig halConfig_;\n \n \tconst camera_module_callbacks_t *callbacks_;\n \tstd::vector<std::unique_ptr<CameraDevice>> cameras_;\n",
    "prefixes": [
        "libcamera-devel",
        "v4",
        "4/5"
    ]
}