From 0612bef6013e31345dd9181869775fd704026f52 Mon Sep 17 00:00:00 2001 From: Paul Elder Date: Mon, 8 Mar 2021 16:48:27 +0900 Subject: utils: ipc: Make first output parameter direct return if int32 To make it more convenient for synchronous IPA calls to return a status, convert the first output into a direct return if it is an int32. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart Acked-by: Naushir Patuck --- .../ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl | 7 ++++++- .../libcamera_templates/module_ipa_proxy_worker.cpp.tmpl | 8 +++----- utils/ipc/generators/libcamera_templates/proxy_functions.tmpl | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) (limited to 'utils/ipc/generators/libcamera_templates') 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 3eb3dced..f75b1206 100644 --- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl +++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy.cpp.tmpl @@ -209,7 +209,12 @@ void {{proxy_name}}::recvMessage(const IPCMessage &data) {%- endif %} } {% if method|method_return_value != "void" %} - return IPADataSerializer<{{method.response_parameters|first|name}}>::deserialize(_ipcOutputBuf.data(), 0); + {{method|method_return_value}} _retValue = IPADataSerializer<{{method|method_return_value}}>::deserialize(_ipcOutputBuf.data(), 0); + +{{proxy_funcs.deserialize_call(method|method_param_outputs, '_ipcOutputBuf.data()', '_ipcOutputBuf.fds()', init_offset = method|method_return_value|byte_width|int)}} + + return _retValue; + {% elif method|method_param_outputs|length > 0 %} {{proxy_funcs.deserialize_call(method|method_param_outputs, '_ipcOutputBuf.data()', '_ipcOutputBuf.fds()')}} {% endif -%} diff --git a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl index ac037fa1..8a57b6cc 100644 --- a/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl +++ b/utils/ipc/generators/libcamera_templates/module_ipa_proxy_worker.cpp.tmpl @@ -83,15 +83,14 @@ public: {{param|name}} {{param.mojom_name}}; {% endfor %} {%- if method|method_return_value != "void" %} - {{method|method_return_value}} _callRet = ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}}); -{%- else %} + {{method|method_return_value}} _callRet = +{%- endif -%} ipa_->{{method.mojom_name}}({{method.parameters|params_comma_sep}} {{- ", " if method|method_param_outputs|params_comma_sep -}} {%- for param in method|method_param_outputs -%} &{{param.mojom_name}}{{", " if not loop.last}} {%- endfor -%} ); -{%- endif %} {% if not method|is_async %} IPCMessage::Header header = { _ipcMessage.header().cmd, _ipcMessage.header().cookie }; IPCMessage _response(header); @@ -100,9 +99,8 @@ public: std::tie(_callRetBuf, std::ignore) = IPADataSerializer<{{method|method_return_value}}>::serialize(_callRet); _response.data().insert(_response.data().end(), _callRetBuf.cbegin(), _callRetBuf.cend()); -{%- else %} - {{proxy_funcs.serialize_call(method|method_param_outputs, "_response.data()", "_response.fds()")|indent(16, true)}} {%- endif %} + {{proxy_funcs.serialize_call(method|method_param_outputs, "_response.data()", "_response.fds()")|indent(16, true)}} int _ret = socket_.send(_response.payload()); if (_ret < 0) { LOG({{proxy_worker_name}}, Error) diff --git a/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl b/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl index f2d86b67..c2ac42fc 100644 --- a/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl +++ b/utils/ipc/generators/libcamera_templates/proxy_functions.tmpl @@ -135,8 +135,8 @@ # # \todo Avoid intermediate vectors #} -{%- macro deserialize_call(params, buf, fds, pointer = true, declare = false, iter = false, data_size = '') -%} -{% set ns = namespace(size_offset = 0) %} +{%- macro deserialize_call(params, buf, fds, pointer = true, declare = false, iter = false, data_size = '', init_offset = 0) -%} +{% set ns = namespace(size_offset = init_offset) %} {%- if params|length > 1 %} {%- for param in params %} [[maybe_unused]] const size_t {{param.mojom_name}}BufSize = readPOD({{buf}}, {{ns.size_offset}} -- cgit v1.2.1