Show a patch.

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

{
    "id": 13219,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/13219/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/13219/",
    "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": "<20210805175848.24188-2-laurent.pinchart@ideasonboard.com>",
    "date": "2021-08-05T17:58:38",
    "name": "[libcamera-devel,v2,01/11] libcamera: camera: Pass Private pointer to Camera constructor",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": false,
    "hash": "05ea75b7cf3dbc21fec61abdbc857d245a0c8fe5",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/13219/mbox/",
    "series": [
        {
            "id": 2312,
            "url": "https://patchwork.libcamera.org/api/1.1/series/2312/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=2312",
            "date": "2021-08-05T17:58:37",
            "name": "libcamera: Replace CameraData with Camera::Private",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/2312/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/13219/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/13219/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 7034CC3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  5 Aug 2021 17:59:09 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id D251068886;\n\tThu,  5 Aug 2021 19:59:06 +0200 (CEST)",
            "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 579B3687CF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  5 Aug 2021 19:59:05 +0200 (CEST)",
            "from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id F072FF95\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  5 Aug 2021 19:59:04 +0200 (CEST)"
        ],
        "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=\"KCsFYMXr\"; dkim-atps=neutral",
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1628186345;\n\tbh=av+M2wIUNafKLZGtBRQnfhfSsifibU1gbXmn1PZJotI=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=KCsFYMXrSPhjRmuBGHQNDMiCKxZun9BIvpJ9dsCCppa9q/9ffvJcl61HCOLKd4p6J\n\tMZMRnm7SSXZZrW7k3VRNfqvR1CwF8eKkBjUD3BXVbEb/dVe8mn9k6nbWN3wJPM0u0O\n\th+/HMXlgBXES3knB7Zrqn/cwb8dTIXYoFdnobUKg=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu,  5 Aug 2021 20:58:38 +0300",
        "Message-Id": "<20210805175848.24188-2-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20210805175848.24188-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20210805175848.24188-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH v2 01/11] libcamera: camera: Pass Private\n\tpointer to Camera constructor",
        "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>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "In order to allow subclassing Camera::Private in pipeline handlers, pass\nthe pointer to the private data to the Camera constructor, and to the\nCamera::createCamera() function.\n\nThe Camera::Private id_ and streams_ members now need to be initialized\nby the Camera constructor instead of the Camera::Private constructor, to\nallow storage of the streams in a pipeline handler-specific subclass of\nCamera::Private.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/libcamera/camera.h                    |  5 ++--\n include/libcamera/internal/camera.h           |  3 +--\n src/libcamera/camera.cpp                      | 26 ++++++++++++-------\n src/libcamera/pipeline/ipu3/ipu3.cpp          |  4 ++-\n .../pipeline/raspberrypi/raspberrypi.cpp      |  4 ++-\n src/libcamera/pipeline/rkisp1/rkisp1.cpp      |  4 ++-\n src/libcamera/pipeline/simple/simple.cpp      |  4 ++-\n src/libcamera/pipeline/uvcvideo/uvcvideo.cpp  |  4 ++-\n src/libcamera/pipeline/vimc/vimc.cpp          |  4 ++-\n 9 files changed, 37 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h\nindex b081907e0cb1..17ddddc2722a 100644\n--- a/include/libcamera/camera.h\n+++ b/include/libcamera/camera.h\n@@ -78,8 +78,7 @@ class Camera final : public Object, public std::enable_shared_from_this<Camera>,\n \tLIBCAMERA_DECLARE_PRIVATE()\n \n public:\n-\tstatic std::shared_ptr<Camera> create(PipelineHandler *pipe,\n-\t\t\t\t\t      const std::string &id,\n+\tstatic std::shared_ptr<Camera> create(Private *d, const std::string &id,\n \t\t\t\t\t      const std::set<Stream *> &streams);\n \n \tconst std::string &id() const;\n@@ -107,7 +106,7 @@ public:\n private:\n \tLIBCAMERA_DISABLE_COPY(Camera)\n \n-\tCamera(PipelineHandler *pipe, const std::string &id,\n+\tCamera(Private *d, const std::string &id,\n \t       const std::set<Stream *> &streams);\n \t~Camera();\n \ndiff --git a/include/libcamera/internal/camera.h b/include/libcamera/internal/camera.h\nindex b60ed140356a..9ec8321a9a21 100644\n--- a/include/libcamera/internal/camera.h\n+++ b/include/libcamera/internal/camera.h\n@@ -26,8 +26,7 @@ class Camera::Private : public Extensible::Private\n \tLIBCAMERA_DECLARE_PUBLIC(Camera)\n \n public:\n-\tPrivate(PipelineHandler *pipe, const std::string &id,\n-\t\tconst std::set<Stream *> &streams);\n+\tPrivate(PipelineHandler *pipe);\n \t~Private();\n \n private:\ndiff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\nindex 4b5bc891fc37..a5bb60c698bc 100644\n--- a/src/libcamera/camera.cpp\n+++ b/src/libcamera/camera.cpp\n@@ -332,11 +332,13 @@ std::size_t CameraConfiguration::size() const\n  * \\brief The vector of stream configurations\n  */\n \n-Camera::Private::Private(PipelineHandler *pipe,\n-\t\t\t const std::string &id,\n-\t\t\t const std::set<Stream *> &streams)\n-\t: pipe_(pipe->shared_from_this()), id_(id), streams_(streams),\n-\t  disconnected_(false), state_(CameraAvailable)\n+/**\n+ * \\brief Construct a Camera::Private instance\n+ * \\param[in] pipe The pipeline handler responsible for the camera device\n+ */\n+Camera::Private::Private(PipelineHandler *pipe)\n+\t: pipe_(pipe->shared_from_this()), disconnected_(false),\n+\t  state_(CameraAvailable)\n {\n }\n \n@@ -513,7 +515,7 @@ void Camera::Private::setState(State state)\n \n /**\n  * \\brief Create a camera instance\n- * \\param[in] pipe The pipeline handler responsible for the camera device\n+ * \\param[in] d Camera private data\n  * \\param[in] id The ID of the camera device\n  * \\param[in] streams Array of streams the camera provides\n  *\n@@ -527,10 +529,12 @@ void Camera::Private::setState(State state)\n  *\n  * \\return A shared pointer to the newly created camera object\n  */\n-std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,\n+std::shared_ptr<Camera> Camera::create(Private *d,\n \t\t\t\t       const std::string &id,\n \t\t\t\t       const std::set<Stream *> &streams)\n {\n+\tASSERT(d);\n+\n \tstruct Deleter : std::default_delete<Camera> {\n \t\tvoid operator()(Camera *camera)\n \t\t{\n@@ -541,7 +545,7 @@ std::shared_ptr<Camera> Camera::create(PipelineHandler *pipe,\n \t\t}\n \t};\n \n-\tCamera *camera = new Camera(pipe, id, streams);\n+\tCamera *camera = new Camera(d, id, streams);\n \n \treturn std::shared_ptr<Camera>(camera, Deleter());\n }\n@@ -594,10 +598,12 @@ const std::string &Camera::id() const\n  * application API calls by returning errors immediately.\n  */\n \n-Camera::Camera(PipelineHandler *pipe, const std::string &id,\n+Camera::Camera(Private *d, const std::string &id,\n \t       const std::set<Stream *> &streams)\n-\t: Extensible(new Private(pipe, id, streams))\n+\t: Extensible(d)\n {\n+\td->id_ = id;\n+\td->streams_ = streams;\n }\n \n Camera::~Camera()\ndiff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\nindex 76c3bb3d8aa9..15d6cca609ff 100644\n--- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n@@ -23,6 +23,7 @@\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n+#include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/camera_sensor.h\"\n #include \"libcamera/internal/delayed_controls.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n@@ -1185,7 +1186,8 @@ int PipelineHandlerIPU3::registerCameras()\n \t\t/* Create and register the Camera instance. */\n \t\tstd::string cameraId = cio2->sensor()->id();\n \t\tstd::shared_ptr<Camera> camera =\n-\t\t\tCamera::create(this, cameraId, streams);\n+\t\t\tCamera::create(new Camera::Private(this), cameraId,\n+\t\t\t\t       streams);\n \n \t\tregisterCamera(std::move(camera), std::move(data));\n \ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 0bab3bedd402..33cd5765b52e 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -30,6 +30,7 @@\n #include <linux/videodev2.h>\n \n #include \"libcamera/internal/bayer_format.h\"\n+#include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/camera_sensor.h\"\n #include \"libcamera/internal/delayed_controls.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n@@ -1106,7 +1107,8 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator)\n \n \t/* Create and register the camera. */\n \tstd::shared_ptr<Camera> camera =\n-\t\tCamera::create(this, data->sensor_->id(), streams);\n+\t\tCamera::create(new Camera::Private(this), data->sensor_->id(),\n+\t\t\t       streams);\n \tregisterCamera(std::move(camera), std::move(data));\n \n \treturn true;\ndiff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\nindex 42911a8fdfdb..4a8ac97d5ef0 100644\n--- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n+++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n@@ -27,6 +27,7 @@\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n+#include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/camera_sensor.h\"\n #include \"libcamera/internal/delayed_controls.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n@@ -970,7 +971,8 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor)\n \t\t&data->selfPathStream_,\n \t};\n \tstd::shared_ptr<Camera> camera =\n-\t\tCamera::create(this, data->sensor_->id(), streams);\n+\t\tCamera::create(new Camera::Private(this), data->sensor_->id(),\n+\t\t\t       streams);\n \tregisterCamera(std::move(camera), std::move(data));\n \n \treturn 0;\ndiff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex b29fff9820e5..43af3fafa475 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -28,6 +28,7 @@\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n+#include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/camera_sensor.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/media_device.h\"\n@@ -1046,7 +1047,8 @@ bool SimplePipelineHandler::match(DeviceEnumerator *enumerator)\n \t\t\t       [](Stream &stream) { return &stream; });\n \n \t\tstd::shared_ptr<Camera> camera =\n-\t\t\tCamera::create(this, data->sensor_->id(), streams);\n+\t\t\tCamera::create(new Camera::Private(this),\n+\t\t\t\t       data->sensor_->id(), streams);\n \t\tregisterCamera(std::move(camera), std::move(data));\n \t\tregistered = true;\n \t}\ndiff --git a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\nindex 0f634b8da609..63cb1daaae22 100644\n--- a/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n+++ b/src/libcamera/pipeline/uvcvideo/uvcvideo.cpp\n@@ -22,6 +22,7 @@\n #include <libcamera/request.h>\n #include <libcamera/stream.h>\n \n+#include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/media_device.h\"\n #include \"libcamera/internal/pipeline_handler.h\"\n@@ -470,7 +471,8 @@ bool PipelineHandlerUVC::match(DeviceEnumerator *enumerator)\n \t}\n \n \tstd::set<Stream *> streams{ &data->stream_ };\n-\tstd::shared_ptr<Camera> camera = Camera::create(this, id, streams);\n+\tstd::shared_ptr<Camera> camera =\n+\t\tCamera::create(new Camera::Private(this), id, streams);\n \tregisterCamera(std::move(camera), std::move(data));\n \n \t/* Enable hot-unplug notifications. */\ndiff --git a/src/libcamera/pipeline/vimc/vimc.cpp b/src/libcamera/pipeline/vimc/vimc.cpp\nindex 12f7517fd0ae..d63562b1ee54 100644\n--- a/src/libcamera/pipeline/vimc/vimc.cpp\n+++ b/src/libcamera/pipeline/vimc/vimc.cpp\n@@ -29,6 +29,7 @@\n #include <libcamera/ipa/vimc_ipa_interface.h>\n #include <libcamera/ipa/vimc_ipa_proxy.h>\n \n+#include \"libcamera/internal/camera.h\"\n #include \"libcamera/internal/camera_sensor.h\"\n #include \"libcamera/internal/device_enumerator.h\"\n #include \"libcamera/internal/ipa_manager.h\"\n@@ -438,7 +439,8 @@ bool PipelineHandlerVimc::match(DeviceEnumerator *enumerator)\n \t/* Create and register the camera. */\n \tstd::set<Stream *> streams{ &data->stream_ };\n \tstd::shared_ptr<Camera> camera =\n-\t\tCamera::create(this, data->sensor_->id(), streams);\n+\t\tCamera::create(new Camera::Private(this), data->sensor_->id(),\n+\t\t\t       streams);\n \tregisterCamera(std::move(camera), std::move(data));\n \n \treturn true;\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "01/11"
    ]
}