Show a patch.

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

{
    "id": 11640,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/11640/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11640/",
    "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": "<20210322104445.21528-1-paul.elder@ideasonboard.com>",
    "date": "2021-03-22T10:44:45",
    "name": "[libcamera-devel,v2] android: Return -EUSERS when failed to open a Camera that's in use",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "4c8ad9630e757de7bd9d775aeed3529d953bf553",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/1.1/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/11640/mbox/",
    "series": [
        {
            "id": 1813,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1813/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1813",
            "date": "2021-03-22T10:44:45",
            "name": "[libcamera-devel,v2] android: Return -EUSERS when failed to open a Camera that's in use",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/1813/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11640/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11640/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 53C5BBD80C\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 22 Mar 2021 10:57:44 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 9E87B68D62;\n\tMon, 22 Mar 2021 11:57:43 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 54A1668D58\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Mar 2021 11:57:42 +0100 (CET)",
            "from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0A344AD6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 22 Mar 2021 11:57:40 +0100 (CET)",
            "from perceval.ideasonboard.com by perceval.ideasonboard.com with\n\tLMTP id QIiuKS11WGDQGwAA4E0KoQ\n\t(envelope-from <paul.elder@ideasonboard.com>)\n\tfor <paul.elder@ideasonboard.com>; Mon, 22 Mar 2021 11:45:01 +0100",
            "from pyrite.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:2c71:1b79:d06d:5032])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 48F93AD6;\n\tMon, 22 Mar 2021 11:44:58 +0100 (CET)"
        ],
        "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"irdHSsUl\"; \n\tdkim=fail reason=\"signature verification failed\" (1024-bit key)\n\theader.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"rtx7Zqsi\"; dkim-atps=neutral",
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1616410662;\n\tbh=ai3IebQg9DIdRlRIFj1Mjii2x7wwEqScdm01UxNh+Ko=;\n\th=Resent-From:Resent-Date:Resent-To:From:To:Cc:Subject:Date:From;\n\tb=irdHSsUlOiE+VOOyyBO/GpE0B7JH9/CcWvM4UX4HWnNPLw/g8BHWmnaxcwfYev7Mp\n\tYYCe1ZudBjX8Vph4IvGmta61hC0k/NhaJ27yfMz/zkxu7cGciDMVgYOoToTP67GPXB\n\tj7xvz2EWkGVyjURD/VPcPZo18b5F/GQPHPflpL+s=",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1616409900;\n\tbh=ai3IebQg9DIdRlRIFj1Mjii2x7wwEqScdm01UxNh+Ko=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=rtx7ZqsimcirPiKhxslkFNABUMsjobpdzmIr1n/v/MtfqImTZUhDR/lRxvbNUrYOp\n\tUytUZ8/BQpPcb0zPsnf9RgNv5XX8clTAI55fD7u9KOsfKrmuqd3t3WvUlQbOR7wLkM\n\t3tg+tCMjXE8bEjIslYKQ7+MHokNccpqv2jK+/8ws="
        ],
        "Resent-From": "paul.elder@ideasonboard.com",
        "Resent-Date": "Mon, 22 Mar 2021 19:57:35 +0900",
        "Resent-Message-ID": "<20210322105735.GG9888@pyrite.rasen.tech>",
        "Resent-To": "libcamera-devel@lists.libcamera.org",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera@lists.ideasonboard.com",
        "Date": "Mon, 22 Mar 2021 19:44:45 +0900",
        "Message-Id": "<20210322104445.21528-1-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v2] android: Return -EUSERS when failed to\n\topen a Camera that's in use",
        "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>",
        "Cc": "hiroh@google.com",
        "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": "The correct return value for the HAL for hal_dev_open() when trying to\nopen a camera that's already opened is EUSERS. Make hal_dev_open()\nreturn -EUSERS, and plumb the logic for this through\nCameraHalManager::open().\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n\n---\nI think the only discussion point that we have so far is whether -EUSERS\nshould be returned only in HAL, or in libcamera as well, which currently\nreturners -EBUSY.\n\nChanges in v2:\n- use structured binding when opening the camera in hal_dev_open()\n- expand the error message\n---\n src/android/camera3_hal.cpp        |  9 +++++++--\n src/android/camera_hal_manager.cpp | 15 ++++++++-------\n src/android/camera_hal_manager.h   |  4 +++-\n 3 files changed, 18 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/src/android/camera3_hal.cpp b/src/android/camera3_hal.cpp\nindex d6e04af2..7b5f3898 100644\n--- a/src/android/camera3_hal.cpp\n+++ b/src/android/camera3_hal.cpp\n@@ -77,8 +77,13 @@ static int hal_dev_open(const hw_module_t *module, const char *name,\n \tLOG(HAL, Debug) << \"Open camera \" << name;\n \n \tint id = atoi(name);\n-\tCameraDevice *camera = cameraManager.open(id, module);\n-\tif (!camera) {\n+\tauto [camera, ret] = cameraManager.open(id, module);\n+\tif (ret == -EBUSY) {\n+\t\tLOG(HAL, Error)\n+\t\t\t<< \"Failed to open camera module '\" << id\n+\t\t\t<< \"', as it is in use\";\n+\t\treturn -EUSERS;\n+\t} else if (!camera) {\n \t\tLOG(HAL, Error)\n \t\t\t<< \"Failed to open camera module '\" << id << \"'\";\n \t\treturn -ENODEV;\ndiff --git a/src/android/camera_hal_manager.cpp b/src/android/camera_hal_manager.cpp\nindex 189eda2b..aeff14bd 100644\n--- a/src/android/camera_hal_manager.cpp\n+++ b/src/android/camera_hal_manager.cpp\n@@ -65,28 +65,29 @@ int CameraHalManager::init()\n \treturn 0;\n }\n \n-CameraDevice *CameraHalManager::open(unsigned int id,\n-\t\t\t\t     const hw_module_t *hardwareModule)\n+std::tuple<CameraDevice *, int>\n+CameraHalManager::open(unsigned int id, const hw_module_t *hardwareModule)\n {\n \tMutexLocker locker(mutex_);\n \n \tif (!callbacks_) {\n \t\tLOG(HAL, Error) << \"Can't open camera before callbacks are set\";\n-\t\treturn nullptr;\n+\t\treturn { nullptr, -ENODEV };\n \t}\n \n \tCameraDevice *camera = cameraDeviceFromHalId(id);\n \tif (!camera) {\n \t\tLOG(HAL, Error) << \"Invalid camera id '\" << id << \"'\";\n-\t\treturn nullptr;\n+\t\treturn { nullptr, -ENODEV };\n \t}\n \n-\tif (camera->open(hardwareModule))\n-\t\treturn nullptr;\n+\tint ret = camera->open(hardwareModule);\n+\tif (ret)\n+\t\treturn { nullptr, ret };\n \n \tLOG(HAL, Info) << \"Open camera '\" << id << \"'\";\n \n-\treturn camera;\n+\treturn { camera, 0 };\n }\n \n void CameraHalManager::cameraAdded(std::shared_ptr<Camera> cam)\ndiff --git a/src/android/camera_hal_manager.h b/src/android/camera_hal_manager.h\nindex a91decc7..24bf716c 100644\n--- a/src/android/camera_hal_manager.h\n+++ b/src/android/camera_hal_manager.h\n@@ -10,6 +10,7 @@\n #include <map>\n #include <mutex>\n #include <stddef.h>\n+#include <tuple>\n #include <vector>\n \n #include <hardware/camera_common.h>\n@@ -28,7 +29,8 @@ public:\n \n \tint init();\n \n-\tCameraDevice *open(unsigned int id, const hw_module_t *module);\n+\tstd::tuple<CameraDevice *, int>\n+\topen(unsigned int id, const hw_module_t *module);\n \n \tunsigned int numCameras() const;\n \tint getCameraInfo(unsigned int id, struct camera_info *info);\n",
    "prefixes": [
        "libcamera-devel",
        "v2"
    ]
}