From patchwork Mon Mar 8 07:48:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11505 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 4D27EBD80C for ; Mon, 8 Mar 2021 07:48:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0ADA968A9C; Mon, 8 Mar 2021 08:48:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="e+Aj949L"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3625460520 for ; Mon, 8 Mar 2021 08:48:40 +0100 (CET) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 21175E7B; Mon, 8 Mar 2021 08:48:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1615189719; bh=YvnsxGT1vhLUwJcK8YYkLvwKig+nsIT0JR72Iqt7qcA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e+Aj949LTQPoEwgP7wytysMuQl82TjDO72EMhpF2n5kt8oX3kN8EkaCUXXe+408mh edRjB1iUmxyiAS3okRVMJtm2+tc+uTT4WeV4sayTejPCqaDlivb9D6T1C/4ImU0PzT 19IrhVTKWQ8BHTHz7pI6tntLnrBY4lMcoQvZJiWU= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Mon, 8 Mar 2021 16:48:26 +0900 Message-Id: <20210308074828.13228-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210308074828.13228-1-paul.elder@ideasonboard.com> References: <20210308074828.13228-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] utils: ipc: Support custom parameters to init() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add support to the mojom-based code generator for custom parameters to init(). Remove the parameter type and count validation as well. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- No change in v2 Changes in v1.1 - remove unused variables in the python file --- .../libcamera_templates/module_ipa_proxy.cpp.tmpl | 15 ++++++++++++--- .../libcamera_templates/proxy_functions.tmpl | 13 ------------- utils/ipc/generators/mojom_libcamera_generator.py | 12 +----------- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl index d451fab3..3eb3dced 100644 --- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl +++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl @@ -141,10 +141,19 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data) {{proxy_funcs.func_sig(proxy_name, method, "Thread")}} { -{%- if method.mojom_name == "init" %} - {{proxy_funcs.init_thread_body()}} -{%- elif method.mojom_name == "stop" %} +{%- if method.mojom_name == "stop" %} {{proxy_funcs.stop_thread_body()}} +{%- elif method.mojom_name == "init" %} + {{ method|method_return_value + " _ret = " if method|method_return_value != "void" -}} + ipa_->{{method.mojom_name}}( + {%- for param in method|method_param_names -%} + {{param}}{{- ", " if not loop.last}} + {%- endfor -%} +); + + proxy_.moveToThread(&thread_); + + return {{ "_ret" if method|method_return_value != "void" }}; {%- elif method.mojom_name == "start" %} running_ = true; thread_.start(); diff --git a/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl b/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl index 40611feb..f2d86b67 100644 --- a/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl +++ b/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl @@ -19,19 +19,6 @@ ){{" override" if override}} {%- endmacro -%} -{# - # \brief Generate function body for IPA init() function for thread - #} -{%- macro init_thread_body() -%} - int ret = ipa_->init(settings); - if (ret) - return ret; - - proxy_.moveToThread(&thread_); - - return 0; -{%- endmacro -%} - {# # \brief Generate function body for IPA stop() function for thread #} diff --git a/utils/ipc/generators/mojom_libcamera_generator.py b/utils/ipc/generators/mojom_libcamera_generator.py index 438e41c6..fa0c21a2 100644 --- a/utils/ipc/generators/mojom_libcamera_generator.py +++ b/utils/ipc/generators/mojom_libcamera_generator.py @@ -341,19 +341,9 @@ def ValidateInterfaces(interfaces): ValidateSingleLength(f_start, 'start()', False) ValidateSingleLength(f_stop, 'stop()', False) - f_init = f_init[0] - f_start = f_start[0] f_stop = f_stop[0] - # Validate parameters to init() - ValidateSingleLength(f_init.parameters, 'input parameter to init()') - ValidateSingleLength(f_init.response_parameters, 'output parameter from init()') - if f_init.parameters[0].kind.mojom_name != 'IPASettings': - raise Exception('init() must have single IPASettings input parameter') - if f_init.response_parameters[0].kind.spec != 'i32': - raise Exception('init() must have single int32 output parameter') - - # No need to validate start() as it is customizable + # No need to validate init() and start() as they are customizable # Validate parameters to stop() ValidateZeroLength(f_stop.parameters, 'input parameter to stop()')