Show a patch.

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

{
    "id": 2180,
    "url": "https://patchwork.libcamera.org/api/patches/2180/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2180/",
    "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": "<20191013001340.14266-5-laurent.pinchart@ideasonboard.com>",
    "date": "2019-10-13T00:13:40",
    "name": "[libcamera-devel,PATCH/RFC,v2,4/4] ipa: Allow short-circuiting the ipa_context_ops",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "bc346a55cf480c151278142b715c58e68ec99536",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2180/mbox/",
    "series": [
        {
            "id": 532,
            "url": "https://patchwork.libcamera.org/api/series/532/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=532",
            "date": "2019-10-13T00:13:36",
            "name": "Convert IPA API to plain C",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/532/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2180/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2180/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "<laurent.pinchart@ideasonboard.com>",
        "Received": [
            "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 3F06560BE5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 13 Oct 2019 02:13:50 +0200 (CEST)",
            "from pendragon.bb.dnainternet.fi\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D307333A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 13 Oct 2019 02:13:49 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570925630;\n\tbh=WIH2FNXIlC1GM2+5g/DM4cX0pyVtFIf0+aAyL2YJED8=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=VRJc3is7kGTi2C8bYifd1Wbk2wJ4kTxFU90hJvDB05N9kDKmGdP/iVAfoRFOu1TwD\n\tYB7fO/2TgFkP3UEPw5D6s3jNEUs7IKfyujf4n4m8x7brCH3ajOfMpGvOYVLv7TIzGD\n\tnRtYjZdG8QiHKgpK4Os1aElxf/nzalHWJ/OpM+JU=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun, 13 Oct 2019 03:13:40 +0300",
        "Message-Id": "<20191013001340.14266-5-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20191013001340.14266-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20191013001340.14266-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Type": "text/plain; charset=UTF-8",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH/RFC v2 4/4] ipa: Allow short-circuiting\n\tthe ipa_context_ops",
        "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>",
        "X-List-Received-Date": "Sun, 13 Oct 2019 00:13:50 -0000"
    },
    "content": "When an IPA module is loaded without isolation and implements the\nIPAInterface internally, going through ipa_context_ops is a waste of\ntime. Add an operation to retrieve the IPAInterface, and use it directly\nin the IPAContextWrapper.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n include/ipa/ipa_interface.h                 |  1 +\n src/ipa/libipa/ipa_interface_wrapper.cpp    |  8 ++++++\n src/ipa/libipa/ipa_interface_wrapper.h      |  1 +\n src/libcamera/include/ipa_context_wrapper.h |  3 +++\n src/libcamera/ipa_context_wrapper.cpp       | 29 ++++++++++++++++++++-\n src/libcamera/ipa_interface.cpp             | 18 +++++++++++++\n 6 files changed, 59 insertions(+), 1 deletion(-)",
    "diff": "diff --git a/include/ipa/ipa_interface.h b/include/ipa/ipa_interface.h\nindex acb491e3958c..c104b8805e7e 100644\n--- a/include/ipa/ipa_interface.h\n+++ b/include/ipa/ipa_interface.h\n@@ -34,6 +34,7 @@ struct ipa_callback_ops {\n \n struct ipa_context_ops {\n \tvoid (*destroy)(struct ipa_context *ctx);\n+\tvoid *(*get_interface)(struct ipa_context *ctx);\n \tvoid (*init)(struct ipa_context *ctx);\n \tvoid (*register_callbacks)(struct ipa_context *ctx,\n \t\t\t\t   const struct ipa_callback_ops *callbacks,\ndiff --git a/src/ipa/libipa/ipa_interface_wrapper.cpp b/src/ipa/libipa/ipa_interface_wrapper.cpp\nindex d7c4905e72ee..baed3acd2b01 100644\n--- a/src/ipa/libipa/ipa_interface_wrapper.cpp\n+++ b/src/ipa/libipa/ipa_interface_wrapper.cpp\n@@ -65,6 +65,13 @@ void IPAInterfaceWrapper::destroy(struct ipa_context *_ctx)\n \tdelete ctx;\n }\n \n+void *IPAInterfaceWrapper::get_interface(struct ipa_context *_ctx)\n+{\n+\tIPAInterfaceWrapper *ctx = static_cast<IPAInterfaceWrapper *>(_ctx);\n+\n+\treturn ctx->ipa_;\n+}\n+\n void IPAInterfaceWrapper::init(struct ipa_context *_ctx)\n {\n \tIPAInterfaceWrapper *ctx = static_cast<IPAInterfaceWrapper *>(_ctx);\n@@ -139,6 +146,7 @@ void IPAInterfaceWrapper::queueFrameAction(unsigned int frame,\n  */\n const struct ipa_context_ops IPAInterfaceWrapper::operations_ = {\n \t.destroy = &IPAInterfaceWrapper::destroy,\n+\t.get_interface = &IPAInterfaceWrapper::get_interface,\n \t.init = &IPAInterfaceWrapper::init,\n \t.register_callbacks = &IPAInterfaceWrapper::register_callbacks,\n \t.configure = &IPAInterfaceWrapper::configure,\ndiff --git a/src/ipa/libipa/ipa_interface_wrapper.h b/src/ipa/libipa/ipa_interface_wrapper.h\nindex a7c70cdc2d83..c4b9d4b668d8 100644\n--- a/src/ipa/libipa/ipa_interface_wrapper.h\n+++ b/src/ipa/libipa/ipa_interface_wrapper.h\n@@ -18,6 +18,7 @@ public:\n \n private:\n \tstatic void destroy(struct ipa_context *ctx);\n+\tstatic void *get_interface(struct ipa_context *ctx);\n \tstatic void init(struct ipa_context *ctx);\n \tstatic void register_callbacks(struct ipa_context *ctx,\n \t\t\t\t       const struct ipa_callback_ops *callbacks,\ndiff --git a/src/libcamera/include/ipa_context_wrapper.h b/src/libcamera/include/ipa_context_wrapper.h\nindex f758bb07abea..218768eaa8be 100644\n--- a/src/libcamera/include/ipa_context_wrapper.h\n+++ b/src/libcamera/include/ipa_context_wrapper.h\n@@ -30,7 +30,10 @@ private:\n \tstatic void queue_frame_action(void *ctx, unsigned int frame);\n \tstatic const struct ipa_callback_ops callbacks_;\n \n+\tvoid queueFrameAction(unsigned int frame, const IPAOperationData &data);\n+\n \tstruct ipa_context *ctx_;\n+\tIPAInterface *intf_;\n };\n \n } /* namespace libcamera */\ndiff --git a/src/libcamera/ipa_context_wrapper.cpp b/src/libcamera/ipa_context_wrapper.cpp\nindex 355911791d43..7e58a7971391 100644\n--- a/src/libcamera/ipa_context_wrapper.cpp\n+++ b/src/libcamera/ipa_context_wrapper.cpp\n@@ -41,6 +41,12 @@ namespace libcamera {\n IPAContextWrapper::IPAContextWrapper(struct ipa_context *context)\n \t: ctx_(context)\n {\n+\tif (ctx_ && ctx_->ops->get_interface) {\n+\t\tintf_ = reinterpret_cast<IPAInterface *>(ctx_->ops->get_interface(ctx_));\n+\t\tintf_->queueFrameAction.connect(this, &IPAContextWrapper::queueFrameAction);\n+\t} else {\n+\t\tintf_ = nullptr;\n+\t}\n }\n \n IPAContextWrapper::~IPAContextWrapper()\n@@ -51,6 +57,9 @@ IPAContextWrapper::~IPAContextWrapper()\n \n int IPAContextWrapper::init()\n {\n+\tif (intf_)\n+\t\treturn intf_->init();\n+\n \tif (!ctx_)\n \t\treturn 0;\n \n@@ -63,6 +72,9 @@ int IPAContextWrapper::init()\n void IPAContextWrapper::configure(const std::map<unsigned int, IPAStream> &streamConfig,\n \t\t\t\t  const std::map<unsigned int, V4L2ControlInfoMap> &entityControls)\n {\n+\tif (intf_)\n+\t\treturn intf_->configure(streamConfig, entityControls);\n+\n \tif (!ctx_)\n \t\treturn;\n \n@@ -71,6 +83,9 @@ void IPAContextWrapper::configure(const std::map<unsigned int, IPAStream> &strea\n \n void IPAContextWrapper::mapBuffers(const std::vector<IPABuffer> &buffers)\n {\n+\tif (intf_)\n+\t\treturn intf_->mapBuffers(buffers);\n+\n \tif (!ctx_)\n \t\treturn;\n \n@@ -96,6 +111,9 @@ void IPAContextWrapper::mapBuffers(const std::vector<IPABuffer> &buffers)\n \n void IPAContextWrapper::unmapBuffers(const std::vector<unsigned int> &ids)\n {\n+\tif (intf_)\n+\t\treturn intf_->unmapBuffers(ids);\n+\n \tif (!ctx_)\n \t\treturn;\n \n@@ -104,18 +122,27 @@ void IPAContextWrapper::unmapBuffers(const std::vector<unsigned int> &ids)\n \n void IPAContextWrapper::processEvent(const IPAOperationData &data)\n {\n+\tif (intf_)\n+\t\treturn intf_->processEvent(data);\n+\n \tif (!ctx_)\n \t\treturn;\n \n \tctx_->ops->process_event(ctx_);\n }\n \n+void IPAContextWrapper::queueFrameAction(unsigned int frame,\n+\t\t\t\t\t const IPAOperationData &data)\n+{\n+\tIPAInterface::queueFrameAction.emit(frame, data);\n+}\n+\n void IPAContextWrapper::queue_frame_action(void *ctx, unsigned int frame)\n {\n \tIPAContextWrapper *_this = static_cast<IPAContextWrapper *>(ctx);\n \tIPAOperationData data;\n \n-\t_this->queueFrameAction.emit(frame, data);\n+\t_this->queueFrameAction(frame, data);\n }\n \n #ifndef __DOXYGEN__\ndiff --git a/src/libcamera/ipa_interface.cpp b/src/libcamera/ipa_interface.cpp\nindex 1df430d721f0..a0647b112466 100644\n--- a/src/libcamera/ipa_interface.cpp\n+++ b/src/libcamera/ipa_interface.cpp\n@@ -62,6 +62,12 @@\n  * handlers to communicate with IPA modules. IPA modules may use the\n  * IPAInterface API internally if they want to benefit from the data and helper\n  * classes offered by libcamera.\n+ *\n+ * When an IPA module is loaded directly into the libcamera process and uses\n+ * the IPAInterface API internally, short-circuiting the path to the\n+ * ipa_context_ops and back to IPAInterface is desirable. To support this, IPA\n+ * modules may implement the ipa_context_ops::get_interface function to return a\n+ * pointer to their internal IPAInterface.\n  */\n \n /**\n@@ -146,6 +152,18 @@\n  * \\param[in] ctx The IPA context\n  */\n \n+/**\n+ * \\var ipa_context_ops::get_interface\n+ * \\brief Retrieve the IPAInterface implemented by the ipa_context (optional)\n+ * \\param[in] ctx The IPA context\n+ *\n+ * IPA modules may implement this function to expose their internal\n+ * IPAInterface, if any. When implemented, libcamera may at its sole discretion\n+ * call it and then bypass the ipa_context_ops API by calling the IPAInterface\n+ * methods directly. IPA modules shall still implement and support the full\n+ * ipa_context_ops API.\n+ */\n+\n /**\n  * \\var ipa_context_ops::init\n  * \\brief Initialise the IPA context\n",
    "prefixes": [
        "libcamera-devel",
        "PATCH/RFC",
        "v2",
        "4/4"
    ]
}