Patch Detail
Show a patch.
GET /api/1.1/patches/2318/?format=api
{ "id": 2318, "url": "https://patchwork.libcamera.org/api/1.1/patches/2318/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2318/", "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": "<20191108205409.18845-23-laurent.pinchart@ideasonboard.com>", "date": "2019-11-08T20:54:07", "name": "[libcamera-devel,v2,22/24] ipa: Allow short-circuiting the ipa_context_ops", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "5b2cafa3d6479872634fb7745c44fae23d465804", "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/2318/mbox/", "series": [ { "id": 568, "url": "https://patchwork.libcamera.org/api/1.1/series/568/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=568", "date": "2019-11-08T20:53:45", "name": "Control serialization and IPA C API", "version": 2, "mbox": "https://patchwork.libcamera.org/series/568/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2318/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2318/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 341FF60180\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 8 Nov 2019 21:54:30 +0100 (CET)", "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D71EA31D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 8 Nov 2019 21:54:29 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1573246470;\n\tbh=Hx++/Nk/hJPzZip9OMMNUIBlRBXX4uP2hOEBsyenWKs=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=G46dyv9b/4ffThfOWd/uSlGZF+yLxlGU1rwMDT7v5VHEE8Yi0CEngQuwQad7VkYdd\n\tgFLpYEXB5BrEn5UIh7Jd2pcyiSudDtKDvutwF1BPg+o57h4GJADel8HEp0yV4miDpu\n\tez1T5STWFAn2sTIzI87i0TxWuZzVgUk6p9VedHFM=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 8 Nov 2019 22:54:07 +0200", "Message-Id": "<20191108205409.18845-23-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.23.0", "In-Reply-To": "<20191108205409.18845-1-laurent.pinchart@ideasonboard.com>", "References": "<20191108205409.18845-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 22/24] ipa: Allow short-circuiting the\n\tipa_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": "Fri, 08 Nov 2019 20:54:30 -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\nFor debugging purpose, make it possible to forcing usage of the C API by\ndefining the LIBCAMERA_IPA_FORCE_C_API environment variable.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\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 | 4 +++\n src/libcamera/ipa_context_wrapper.cpp | 34 +++++++++++++++++++--\n src/libcamera/ipa_interface.cpp | 18 +++++++++++\n 6 files changed, 64 insertions(+), 2 deletions(-)", "diff": "diff --git a/include/ipa/ipa_interface.h b/include/ipa/ipa_interface.h\nindex 92f1aac50b85..0ea53d120fe1 100644\n--- a/include/ipa/ipa_interface.h\n+++ b/include/ipa/ipa_interface.h\n@@ -62,6 +62,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 80c5648ffed6..6a389dfa714a 100644\n--- a/src/ipa/libipa/ipa_interface_wrapper.cpp\n+++ b/src/ipa/libipa/ipa_interface_wrapper.cpp\n@@ -72,6 +72,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_.get();\n+}\n+\n void IPAInterfaceWrapper::init(struct ipa_context *_ctx)\n {\n \tIPAInterfaceWrapper *ctx = static_cast<IPAInterfaceWrapper *>(_ctx);\n@@ -228,6 +235,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 17be2062b6c7..3fb7b4476439 100644\n--- a/src/ipa/libipa/ipa_interface_wrapper.h\n+++ b/src/ipa/libipa/ipa_interface_wrapper.h\n@@ -22,6 +22,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 060888218838..c9e194120de6 100644\n--- a/src/libcamera/include/ipa_context_wrapper.h\n+++ b/src/libcamera/include/ipa_context_wrapper.h\n@@ -33,7 +33,11 @@ private:\n \t\t\t\t struct ipa_operation_data &data);\n \tstatic const struct ipa_callback_ops callbacks_;\n \n+\tvoid doQueueFrameAction(unsigned int frame,\n+\t\t\t\tconst IPAOperationData &data);\n+\n \tstruct ipa_context *ctx_;\n+\tIPAInterface *intf_;\n \n \tControlSerializer serializer_;\n };\ndiff --git a/src/libcamera/ipa_context_wrapper.cpp b/src/libcamera/ipa_context_wrapper.cpp\nindex 66fc59b82373..0efbae0f675f 100644\n--- a/src/libcamera/ipa_context_wrapper.cpp\n+++ b/src/libcamera/ipa_context_wrapper.cpp\n@@ -12,6 +12,7 @@\n #include <libcamera/controls.h>\n \n #include \"byte_stream_buffer.h\"\n+#include \"utils.h\"\n \n /**\n * \\file ipa_context_wrapper.h\n@@ -43,11 +44,19 @@ namespace libcamera {\n * with it.\n */\n IPAContextWrapper::IPAContextWrapper(struct ipa_context *context)\n-\t: ctx_(context)\n+\t: ctx_(context), intf_(nullptr)\n {\n \tif (!ctx_)\n \t\treturn;\n \n+\tbool forceCApi = !!utils::secure_getenv(\"LIBCAMERA_IPA_FORCE_C_API\");\n+\n+\tif (!forceCApi && ctx_ && ctx_->ops->get_interface) {\n+\t\tintf_ = reinterpret_cast<IPAInterface *>(ctx_->ops->get_interface(ctx_));\n+\t\tintf_->queueFrameAction.connect(this, &IPAContextWrapper::doQueueFrameAction);\n+\t\treturn;\n+\t}\n+\n \tctx_->ops->register_callbacks(ctx_, &IPAContextWrapper::callbacks_,\n \t\t\t\t this);\n }\n@@ -60,6 +69,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@@ -71,6 +83,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, const ControlInfoMap &> &entityControls)\n {\n+\tif (intf_)\n+\t\treturn intf_->configure(streamConfig, entityControls);\n+\n \tif (!ctx_)\n \t\treturn;\n \n@@ -121,6 +136,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@@ -146,6 +164,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@@ -154,6 +175,9 @@ 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@@ -187,6 +211,12 @@ void IPAContextWrapper::processEvent(const IPAOperationData &data)\n \tctx_->ops->process_event(ctx_, &c_data);\n }\n \n+void IPAContextWrapper::doQueueFrameAction(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 \t\t\t\t\t struct ipa_operation_data &data)\n {\n@@ -203,7 +233,7 @@ void IPAContextWrapper::queue_frame_action(void *ctx, unsigned int frame,\n \t\topData.controls.push_back(_this->serializer_.deserialize<ControlList>(b));\n \t}\n \n-\t_this->queueFrameAction.emit(frame, opData);\n+\t_this->doQueueFrameAction(frame, opData);\n }\n \n #ifndef __DOXYGEN__\ndiff --git a/src/libcamera/ipa_interface.cpp b/src/libcamera/ipa_interface.cpp\nindex cb2767a04711..715e7972271b 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@@ -209,6 +215,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", "v2", "22/24" ] }