Show a patch.

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

{
    "id": 11655,
    "url": "https://patchwork.libcamera.org/api/patches/11655/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/11655/",
    "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": "<20210323100906.17488-1-paul.elder@ideasonboard.com>",
    "date": "2021-03-23T10:09:06",
    "name": "[libcamera-devel,v3] android: Return -EUSERS when failed to open a Camera that's in use",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "21b8c500a17d444cdf6e1d76376b5edb8db9f3c0",
    "submitter": {
        "id": 17,
        "url": "https://patchwork.libcamera.org/api/people/17/?format=api",
        "name": "Paul Elder",
        "email": "paul.elder@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/11655/mbox/",
    "series": [
        {
            "id": 1819,
            "url": "https://patchwork.libcamera.org/api/series/1819/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1819",
            "date": "2021-03-23T10:09:06",
            "name": "[libcamera-devel,v3] android: Return -EUSERS when failed to open a Camera that's in use",
            "version": 3,
            "mbox": "https://patchwork.libcamera.org/series/1819/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/11655/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/11655/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 4054AC32E4\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 23 Mar 2021 10:09:32 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7A91E68D65;\n\tTue, 23 Mar 2021 11:09:31 +0100 (CET)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DA316602E3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Mar 2021 11:09:29 +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 2D98C885;\n\tTue, 23 Mar 2021 11:09:26 +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=\"XwSSYPbE\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1616494169;\n\tbh=C+ls2pPkWW6SmNXUQHTbqFIbXi+oqBycH7+XGa5KJ0U=;\n\th=From:To:Cc:Subject:Date:From;\n\tb=XwSSYPbEc7uPrCi/7t/zVAFd6tZs+MSmYEYw/+Mdu6KlJcATsaBN/OjjQORyPbSnG\n\tMlOS47rb3Lb7f0MRRt0XwB0AyW5nF0L9cNz8STKn1AtIcYD7a+RAovNVlL1Ues94lm\n\txJhejZpQo2vqvRlNm4ahyzzPeMTveMdr8dEG2V2s=",
        "From": "Paul Elder <paul.elder@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Tue, 23 Mar 2021 19:09:06 +0900",
        "Message-Id": "<20210323100906.17488-1-paul.elder@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.27.0",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v3] 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\nThis allows the following CTS tests to pass:\n- android.hardware.camera2.cts.CameraManagerTest#testCameraManagerOpenAllCameras\n- android.hardware.camera2.cts.MultiViewTest#testDualCameraPreview\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\n---\nChanges in v3:\n- simplify the error handling in hal_dev_open()\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        |  4 ++--\n src/android/camera_hal_manager.cpp | 15 ++++++++-------\n src/android/camera_hal_manager.h   |  4 +++-\n 3 files changed, 13 insertions(+), 10 deletions(-)",
    "diff": "diff --git a/src/android/camera3_hal.cpp b/src/android/camera3_hal.cpp\nindex d6e04af2..08773d33 100644\n--- a/src/android/camera3_hal.cpp\n+++ b/src/android/camera3_hal.cpp\n@@ -77,11 +77,11 @@ 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+\tauto [camera, ret] = cameraManager.open(id, module);\n \tif (!camera) {\n \t\tLOG(HAL, Error)\n \t\t\t<< \"Failed to open camera module '\" << id << \"'\";\n-\t\treturn -ENODEV;\n+\t\treturn ret == -EBUSY ? -EUSERS : ret;\n \t}\n \n \t*device = &camera->camera3Device()->common;\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",
        "v3"
    ]
}