From patchwork Wed May 3 12:20:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18586 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 313D7C0DA4 for ; Wed, 3 May 2023 12:20:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BC44F633B8; Wed, 3 May 2023 14:20:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1683116440; bh=7P/GgqAl2UBfQR9LrnSPIOwN3x8qtszmDXjO3hSgwD4=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=Nvo+zQ1Dv8yqOaTQYRF+kYj+miyqY0JwyVx/j244EzekSYV4rS3v0UwQ9EXmZBh5d GEPt4x6IuDlhl2gBzYBkT8qbuzCeGk5YPGhC+0jqYCkaoGkjHELLiSczzZz/t//xWp T73sjNLcSWfj4633gRo0XJrr4iyxmQbDK7nuwzLOzGDkuolRoAo4VRj/OKLaE7GiYo /ylUqX+O6+LumbLWkH5G2L4hKmhCStNFbHC2hNJ3/WxAn52odBBcYoA9YMGxho6YGx zdDkZlbqxluoFG6dXOVM9q8FFXDQ1GUC48JRKle6A6nxFZSynDWow5JW6Xg81Rmez/ Apr4HjuE9BIHg== Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A272C633A8 for ; Wed, 3 May 2023 14:20:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="tZA4NDp4"; dkim-atps=neutral Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-3f1763ee8f8so33441585e9.1 for ; Wed, 03 May 2023 05:20:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1683116438; x=1685708438; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=neWi2yniHpiu9WlFbT/hNGIChDnbjNoBYPmPLu8pArg=; b=tZA4NDp4gbIu/t0NVvV+ZuFX6DgOTL1Wc2vrXK1mOTaNE4NeJgXcG1zjcC3klvAUK6 ykcM3UlzhCLnJ9VjNHgivm5hQ1yhy6/Gx8MBZs17w88B5dVmqfVUm0LUHmm00i71eHrI 41g7zdXHOMxl4Rk1vqV2ll6oVOLohP9wOocCKcpKxsH0rzJezYmipFbc8TRtPQtpH1aB M0gASiuuoy+dAXlw4iJQ0Yir+11SNm/47FISHBST5riqgCVnl0wQxWtes9uUoFGNflP+ qVxTGVKhqhw33SA4ae16cr86fsqB7PVq3Nv8dXBfnYoRDKrV+HiZOcucLTbsa8bZU3i0 2Jfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683116438; x=1685708438; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=neWi2yniHpiu9WlFbT/hNGIChDnbjNoBYPmPLu8pArg=; b=Lok3xzlHXGnMR8o8pGduaZD9/FaZgL+IlcHXT25VdXikX2AqWBOVKKTms1q5txmQb1 P/lAREZ8w3J8RD4aINhCsOZRL8bPKuMFeBHnHOVQ3Wv6oE0bRvJhzNcEfdbXSpHE7MhD p8YnsxhviiFOZzpkbT3Uc3m1RHt1pKdWLBaTCt2N58P/xk3HGGDjoUJPcV3yA5lIXFAS NQP7NGmtpOxOxQmDmhtGj9wXWX7k1lGUqTzzoOoJ8Smd78ZVQXubOoANOMtYIUMx4lOJ TIftXtthK+de4qJZ7zwbhEJCX6ILGmqQCuer4i3NOx2vT68a6eAzZDJUzZ6KZK2l/x5l S+6w== X-Gm-Message-State: AC+VfDySZMSHEUq1/XXaonBPRUk+cmUC+y+7LVSj0ulXFxOwHNcdbTlH bUUhZibFI6YN4oKvI/eNfYOrDoAfUP7Rlfwxt6/Yyg== X-Google-Smtp-Source: ACHHUZ6yG8qBcxB2LI86NazapFtd2OVz/Zup74/aWI7XJhexJdfe06eGodRTQqsOJoS8kpkHqdcy9g== X-Received: by 2002:a7b:c015:0:b0:3f1:82ba:b03b with SMTP id c21-20020a7bc015000000b003f182bab03bmr14947638wmb.19.1683116437886; Wed, 03 May 2023 05:20:37 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id f23-20020a7bcd17000000b003ee443bf0c7sm1736785wmj.16.2023.05.03.05.20.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 May 2023 05:20:37 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 3 May 2023 13:20:23 +0100 Message-Id: <20230503122035.32026-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230503122035.32026-1-naush@raspberrypi.com> References: <20230503122035.32026-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 01/13] meson: ipa: Add mapping for pipeline handler to mojom interface file 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Allow an arbitrary mapping between the pipeline handler and IPA mojom interface file in the build system. This removes the 1:1 mapping of pipeline handler name to mojom filename, and allows more flexibility to pipeline developers. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- Documentation/guides/ipa.rst | 39 ++++++++++++++++++++----------- include/libcamera/ipa/meson.build | 36 +++++++++++++++++----------- 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/Documentation/guides/ipa.rst b/Documentation/guides/ipa.rst index fc0317451e24..51dbe3aad5f5 100644 --- a/Documentation/guides/ipa.rst +++ b/Documentation/guides/ipa.rst @@ -19,6 +19,16 @@ connect to, in order to receive data from the IPA asynchronously. In addition, it contains any custom data structures that the pipeline handler and IPA may pass to each other. +It is possible to use the same IPA interface with multiple pipeline handlers +on different hardware platforms. Generally in such cases, these platforms would +have a common hardware ISP pipeline. For instance, the rkisp1 pipeline handler +supports both the RK3399 and the i.MX8MP as they integrate the same ISP. +However, the i.MX8MP has a more complex camera pipeline, which may call for a +dedicated pipeline handler in the future. As the ISP is the same as for RK3399, +the same IPA interface could be used for both pipeline handlers. The build files +provide a mapping from pipeline handler to the IPA interface name as detailed in +:ref:`compiling-section`. + The IPA protocol refers to the agreement between the pipeline handler and the IPA regarding the expected response(s) from the IPA for given calls to the IPA. This protocol doesn't need to be declared anywhere in code, but it shall be @@ -43,7 +53,7 @@ interface definition is thus written by the pipeline handler author, based on how they design the interactions between the pipeline handler and the IPA. The entire IPA interface, including the functions, signals, and any custom -structs shall be defined in a file named {pipeline_name}.mojom under +structs shall be defined in a file named {interface_name}.mojom under include/libcamera/ipa/. .. _mojo Interface Definition Language: https://chromium.googlesource.com/chromium/src.git/+/master/mojo/public/tools/bindings/README.md @@ -150,8 +160,6 @@ and the Event IPA interface, which describes the signals received by the pipeline handler that the IPA can emit. Both must be defined. This section focuses on the Main IPA interface. -The main interface must be named as IPA{pipeline_name}Interface. - The functions that the pipeline handler can call from the IPA may be synchronous or asynchronous. Synchronous functions do not return until the IPA returns from the function, while asynchronous functions return immediately @@ -243,7 +251,7 @@ then it may be empty. These emissions are meant to notify the pipeline handler of some event, such as request data is ready, and *must not* be used to drive the camera pipeline from the IPA. -The event interface must be named as IPA{pipeline_name}EventInterface. +The event interface must be named as IPA{interface_name}EventInterface. Functions defined in the event interface are implicitly asynchronous. Thus they cannot return any value. Specifying the [async] tag is not @@ -266,38 +274,41 @@ The following is an example of an event interface definition: setStaggered(libcamera.ControlList controls); }; +.. _compiling-section: + Compiling the IPA interface --------------------------- -After the IPA interface is defined in include/libcamera/ipa/{pipeline_name}.mojom, +After the IPA interface is defined in include/libcamera/ipa/{interface_name}.mojom, an entry for it must be added in meson so that it can be compiled. The filename -must be added to the ipa_mojom_files object in include/libcamera/ipa/meson.build. +must be added to the pipeline_ipa_mojom_mapping object in include/libcamera/ipa/meson.build. +This object maps the pipeline handler name with an ipa interface file. For example, adding the raspberrypi.mojom file to meson: .. code-block:: none - ipa_mojom_files = [ - 'raspberrypi.mojom', + pipeline_ipa_mojom_mapping = [ + 'rpi/vc4': 'raspberrypi.mojom', ] This will cause the mojo data definition file to be compiled. Specifically, it generates five files: - a header describing the custom data structures, and the complete IPA - interface (at {$build_dir}/include/libcamera/ipa/{pipeline}_ipa_interface.h) + interface (at {$build_dir}/include/libcamera/ipa/{interface}_ipa_interface.h) - a serializer implementing de/serialization for the custom data structures (at - {$build_dir}/include/libcamera/ipa/{pipeline}_ipa_serializer.h) + {$build_dir}/include/libcamera/ipa/{interface}_ipa_serializer.h) - a proxy header describing a specialized IPA proxy (at - {$build_dir}/include/libcamera/ipa/{pipeline}_ipa_proxy.h) + {$build_dir}/include/libcamera/ipa/{interface}_ipa_proxy.h) - a proxy source implementing the IPA proxy (at - {$build_dir}/src/libcamera/proxy/{pipeline}_ipa_proxy.cpp) + {$build_dir}/src/libcamera/proxy/{interface}_ipa_proxy.cpp) - a proxy worker source implementing the other end of the IPA proxy (at - {$build_dir}/src/libcamera/proxy/worker/{pipeline}_ipa_proxy_worker.cpp) + {$build_dir}/src/libcamera/proxy/worker/{interface}_ipa_proxy_worker.cpp) The IPA proxy serves as the layer between the pipeline handler and the IPA, and handles threading vs isolation transparently. The pipeline handler and the IPA @@ -312,7 +323,7 @@ file, the following header must be included: .. code-block:: C++ - #include + #include The POD types of the structs simply become their C++ counterparts, eg. uint32 in mojo will become uint32_t in C++. mojo map becomes C++ std::map, and mojo diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build index 442ca3dd7e1c..c57b3a5e1570 100644 --- a/include/libcamera/ipa/meson.build +++ b/include/libcamera/ipa/meson.build @@ -60,13 +60,15 @@ libcamera_generated_ipa_headers += custom_target('core_ipa_serializer_h', './' +'@INPUT@' ]) -ipa_mojom_files = [ - 'ipu3.mojom', - 'raspberrypi.mojom', - 'rkisp1.mojom', - 'vimc.mojom', -] - +# Mapping from pipeline handler name to mojom file +pipeline_ipa_mojom_mapping = { + 'ipu3': 'ipu3.mojom', + 'rkisp1': 'rkisp1.mojom', + 'raspberrypi': 'raspberrypi.mojom', + 'vimc': 'vimc.mojom', +} + +ipa_mojom_files = [] ipa_mojoms = [] # @@ -75,14 +77,22 @@ ipa_mojoms = [] # TODO Define per-pipeline ControlInfoMap with yaml? -foreach file : ipa_mojom_files +foreach pipeline, file : pipeline_ipa_mojom_mapping + name = file.split('.')[0] - if name not in pipelines + # Ensure we do not build duplicate mojom modules + if file in ipa_mojom_files + continue + endif + + ipa_mojom_files += file + + if pipeline not in pipelines continue endif - # {pipeline}.mojom-module + # {interface}.mojom-module mojom = custom_target(name + '_mojom_module', input : file, output : file + '-module', @@ -94,7 +104,7 @@ foreach file : ipa_mojom_files '--mojoms', '@INPUT@' ]) - # {pipeline}_ipa_interface.h + # {interface}_ipa_interface.h header = custom_target(name + '_ipa_interface_h', input : mojom, output : name + '_ipa_interface.h', @@ -110,7 +120,7 @@ foreach file : ipa_mojom_files './' +'@INPUT@' ]) - # {pipeline}_ipa_serializer.h + # {interface}_ipa_serializer.h serializer = custom_target(name + '_ipa_serializer_h', input : mojom, output : name + '_ipa_serializer.h', @@ -124,7 +134,7 @@ foreach file : ipa_mojom_files './' +'@INPUT@' ]) - # {pipeline}_ipa_proxy.h + # {interface}_ipa_proxy.h proxy_header = custom_target(name + '_proxy_h', input : mojom, output : name + '_ipa_proxy.h',