Show a patch.

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

{
    "id": 11689,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/11689/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11689/",
    "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": "<20210324112527.63701-7-jacopo@jmondi.org>",
    "date": "2021-03-24T11:25:26",
    "name": "[libcamera-devel,6/7] android: camera_device: Get properties from config",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "6c5c86e5d2f42c2c992116a06e744d6c04217130",
    "submitter": {
        "id": 3,
        "url": "https://patchwork.libcamera.org/api/1.1/people/3/?format=api",
        "name": "Jacopo Mondi",
        "email": "jacopo@jmondi.org"
    },
    "delegate": {
        "id": 15,
        "url": "https://patchwork.libcamera.org/api/1.1/users/15/?format=api",
        "username": "jmondi",
        "first_name": "Jacopo",
        "last_name": "Mondi",
        "email": "jacopo@jmondi.org"
    },
    "mbox": "https://patchwork.libcamera.org/patch/11689/mbox/",
    "series": [
        {
            "id": 1826,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1826/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1826",
            "date": "2021-03-24T11:25:20",
            "name": "android: Add support for HAL configuration file",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/1826/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11689/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11689/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 69468C32E7\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 24 Mar 2021 11:25:26 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2F67668D63;\n\tWed, 24 Mar 2021 12:25:26 +0100 (CET)",
            "from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9BEDD602E3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Mar 2021 12:25:24 +0100 (CET)",
            "from uno.homenet.telecomitalia.it\n\t(host-82-63-7-72.business.telecomitalia.it [82.63.7.72])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay1-d.mail.gandi.net (Postfix) with ESMTPSA id E978524000A;\n\tWed, 24 Mar 2021 11:25:22 +0000 (UTC)"
        ],
        "X-Originating-IP": "82.63.7.72",
        "From": "Jacopo Mondi <jacopo@jmondi.org>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Wed, 24 Mar 2021 12:25:26 +0100",
        "Message-Id": "<20210324112527.63701-7-jacopo@jmondi.org>",
        "X-Mailer": "git-send-email 2.30.0",
        "In-Reply-To": "<20210324112527.63701-1-jacopo@jmondi.org>",
        "References": "<20210324112527.63701-1-jacopo@jmondi.org>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH 6/7] android: camera_device: Get\n\tproperties 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 device and camera properties.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n src/android/camera_device.cpp      | 71 ++++++++++++++++--------------\n src/android/camera_device.h        |  8 +++-\n src/android/camera_hal_manager.cpp |  3 +-\n 3 files changed, 47 insertions(+), 35 deletions(-)",
    "diff": "diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp\nindex 72a89258386d..403d149e4f68 100644\n--- a/src/android/camera_device.cpp\n+++ b/src/android/camera_device.cpp\n@@ -312,33 +312,22 @@ CameraDevice::Camera3RequestDescriptor::~Camera3RequestDescriptor()\n  * back to the framework using the designated callbacks.\n  */\n \n-CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camera)\n-\t: id_(id), running_(false), camera_(camera), staticMetadata_(nullptr),\n-\t  facing_(CAMERA_FACING_FRONT), orientation_(0)\n+CameraDevice::CameraDevice(unsigned int id, const std::shared_ptr<Camera> &camera,\n+\t\t\t   CameraHalConfig &halConfig)\n+\t: id_(id), running_(false), camera_(camera), halConfig_(&halConfig),\n+\t  staticMetadata_(nullptr), facing_(CAMERA_FACING_FRONT), orientation_(0)\n {\n-\tcamera_->requestCompleted.connect(this, &CameraDevice::requestComplete);\n-\n-\tmaker_ = \"libcamera\";\n-\tmodel_ = \"cameraModel\";\n-\n-\t/* \\todo Support getting properties on Android */\n-\tstd::ifstream fstream(\"/var/cache/camera/camera.prop\");\n-\tif (!fstream.is_open())\n-\t\treturn;\n-\n-\tstd::string line;\n-\twhile (std::getline(fstream, line)) {\n-\t\tstd::string::size_type delimPos = line.find(\"=\");\n-\t\tif (delimPos == std::string::npos)\n-\t\t\tcontinue;\n-\t\tstd::string key = line.substr(0, delimPos);\n-\t\tstd::string val = line.substr(delimPos + 1);\n-\n-\t\tif (!key.compare(\"ro.product.model\"))\n-\t\t\tmodel_ = val;\n-\t\telse if (!key.compare(\"ro.product.manufacturer\"))\n-\t\t\tmaker_ = val;\n+\tmaker_ = halConfig_->deviceMaker();\n+\tmodel_ = halConfig_->deviceModel();\n+\tif (maker_.empty() || model_.empty()) {\n+\t\tmaker_ = \"libcamera\";\n+\t\tmodel_ = \"cameraModel\";\n+\t\tLOG(HAL, Warning)\n+\t\t\t<< \"Cannot find manufacturer information. \"\n+\t\t\t<< \"Default it to '\" << maker_ << \" - \" << model_;\n \t}\n+\n+\tcamera_->requestCompleted.connect(this, &CameraDevice::requestComplete);\n }\n \n CameraDevice::~CameraDevice()\n@@ -351,9 +340,10 @@ CameraDevice::~CameraDevice()\n }\n \n std::shared_ptr<CameraDevice> CameraDevice::create(unsigned int id,\n-\t\t\t\t\t\t   const std::shared_ptr<Camera> &cam)\n+\t\t\t\t\t\t   const std::shared_ptr<Camera> &cam,\n+\t\t\t\t\t\t   CameraHalConfig &halConfig)\n {\n-\tCameraDevice *camera = new CameraDevice(id, cam);\n+\tCameraDevice *camera = new CameraDevice(id, cam, halConfig);\n \treturn std::shared_ptr<CameraDevice>(camera);\n }\n \n@@ -380,11 +370,28 @@ 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\tstd::string location = halConfig_->cameraLocation(camera_->id());\n+\t\tif (location.empty()) {\n+\t\t\tLOG(HAL, Error) << \"Location for camera \"\n+\t\t\t\t\t<< camera_->id() << \" not reported\";\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tif (location == \"front\") {\n+\t\t\tfacing_ = CAMERA_FACING_FRONT;\n+\t\t} else if (location == \"back\") {\n+\t\t\tfacing_ = CAMERA_FACING_BACK;\n+\t\t} else if (location == \"external\") {\n+\t\t\tfacing_ = CAMERA_FACING_EXTERNAL;\n+\t\t} else {\n+\t\t\tLOG(HAL, Error) << \"Unsupported camera location \"\n+\t\t\t\t\t<< location;\n+\t\t\treturn -EINVAL;\n+\t\t}\n+\n+\t\tLOG(HAL, Debug)\n+\t\t\t<< \"Camera location retrieved from configration file: \"\n+\t\t\t<< location;\n \t}\n \n \t/*\ndiff --git a/src/android/camera_device.h b/src/android/camera_device.h\nindex 823d561cc295..33bfd115a703 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::shared_ptr<CameraDevice> create(unsigned int id,\n-\t\t\t\t\t\t    const std::shared_ptr<libcamera::Camera> &cam);\n+\t\t\t\t\t\t    const 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, const std::shared_ptr<libcamera::Camera> &camera);\n+\tCameraDevice(unsigned int id, const 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+\tCameraHalConfig *halConfig_;\n \n \tCameraMetadata *staticMetadata_;\n \tstd::map<unsigned int, const CameraMetadata *> requestTemplates_;\ndiff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\nindex a19f80edede8..4fb5c87e2a68 100644\n--- a/src/android/camera_hal_manager.cpp\n+++ b/src/android/camera_hal_manager.cpp\n@@ -129,7 +129,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::shared_ptr<CameraDevice> camera = CameraDevice::create(id, std::move(cam));\n+\tstd::shared_ptr<CameraDevice> camera = CameraDevice::create(id, std::move(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",
        "6/7"
    ]
}