From patchwork Sat Feb 13 04:21:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 11278 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 923B1BD160 for ; Sat, 13 Feb 2021 04:22:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 60534637B1; Sat, 13 Feb 2021 05:22:23 +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="gSaR/K4r"; 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 200BA637A1 for ; Sat, 13 Feb 2021 05:22:21 +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 097FC564; Sat, 13 Feb 2021 05:22:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1613190140; bh=sJ9mEd2Owt3YLui8yxOnTvVYaV86oHY/9gOt0fJnVxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gSaR/K4rX0ZvcFwP+ay3Ykqi69kkHsk8homBam2e2kXg+sT3W3YvsqwCMJxm8sqFG ws130HeqbPFjR+aIFON+9YnqX7h1FPeKYdjYoXLc2G8YlrpE7MfPn6fGJ9xhv5YyLK WWI++2KYmDo5s5GvyOqTilYb59X7Hr8Nx+4/sXRY= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Sat, 13 Feb 2021 13:21:43 +0900 Message-Id: <20210213042143.112361-10-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210213042143.112361-1-paul.elder@ideasonboard.com> References: <20210213042143.112361-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v8 9/9] ipa: Add core.mojom 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 a base mojom file to contain empty mojom definitions of libcamera objects, as well as documentation for the IPA interfaces that need to be defined in the mojom files. Signed-off-by: Paul Elder Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- No change in v8 Changes in v7: - update documentation and code for the switch from genHeader/genSerdes to skipHeader/skipSerdes - rebase on new CameraSensorInfo - other cosmetic changes Changes in v6: - expand documentation on what can and can't be done in mojom - add definitions for geometry.h structs, and the structs that used to be in ipa_interface.h, including their documentation - remove documentation for start() Changes in v5: - add todo for defining some libcamera ipa structs in mojom - remove ipa_mojom_core from dependencies of everything in the generator stage - add documentation for the base IPA functions (init, stop, start) Changes in v4: - move docs to IPA guide Changes in v3: - add doc that structs need to be defined - add doc to recommend namespacing - change indentation - add requirement that base controls *must* be defined in libcamera::{pipeline_name}::Controls New in v2 --- include/libcamera/ipa/core.mojom | 191 +++++++++++++++++++++++++++++++ 1 file changed, 191 insertions(+) create mode 100644 include/libcamera/ipa/core.mojom diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom new file mode 100644 index 00000000..5236a672 --- /dev/null +++ b/include/libcamera/ipa/core.mojom @@ -0,0 +1,191 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +/* + * Things that can be defined here (and in other mojom files): + * - consts + * - enums + * - structs + * + * Attributes: + * - skipHeader - structs only, and only in core.mojom + * - designate that this struct shall not have a C++ header definition + * generated + * - skipSerdes - structs only, and only in core.mojom + * - designate that this struct shall not have a (de)serializer generated + * - all fields need a (de)serializer to be defined, either hand-written + * in ipa_data_serializer.h + * - hasFd - struct fields or empty structs only + * - designate that this field or empty struct contains a FileDescriptor + * + * Rules: + * - Any struct that is used in a struct definition in mojom must also be + * defined in mojom + * - If the struct has both a definition in a C++ header and a (de)serializer + * in ipa_data_serializer.h, then the struct shall be declared as empty, + * with both the [skipHeader] and [skipSerdes] attributes + * - If the struct only has a definition in a C++ header, but no + * (de)serializer, then the struct definition should have the [skipHeader] + * attribute + * - Nested structures (e.g. FrameBuffer::Plane) cannot be defined in mojom. + * - Avoid them, by defining them in a header in C++ and a (de)serializer in + * ipa_data_serializer.h + * - If a struct is in an array/map inside a struct, then the struct that is + * the member of the array/map does not need a mojom definition if it is + * defined in a C++ header. + * - This can be used to embed nested structures. The C++ double colon is + * replaced with a dot (e.g. FrameBuffer::Plane -> FrameBuffer.Plane) + * - The struct must still be defined in a header in C++ and a (de)serializer + * implemented in ipa_data_serializer.h, as it cannot be defined in mojom + * - [skipHeader] and [skipSerdes] only work here in core.mojom. + * - If a struct definition has [skipHeader], then the header where the + * struct is defined must be #included (or the struct forward-declared) in + * ipa_interface.h + * - If a field in a struct has a FileDescriptor, but is not explicitly + * defined so in mojom, then the field must be marked with the [hasFd] + * attribute. + * + * \todo Generate documentation from Doxygen comments in .mojom files + * \todo Figure out how to keep the skipHeader structs in sync with their + * C++ definitions, and the skipSerdes structs in sync with their + * (de)serializers + */ +[skipSerdes, skipHeader] struct ControlInfoMap {}; +[skipSerdes, skipHeader] struct ControlList {}; +[skipSerdes, skipHeader] struct FileDescriptor {}; + +[skipHeader] struct Point { + int32 x; + int32 y; +}; + +[skipHeader] struct Size { + uint32 width; + uint32 height; +}; + +[skipHeader] struct SizeRange { + Size min; + Size max; + uint32 hStep; + uint32 vStep; +}; + +[skipHeader] struct Rectangle { + int32 x; + int32 y; + uint32 width; + uint32 height; +}; + +[skipHeader] struct CameraSensorInfo { + string model; + + uint32 bitsPerPixel; + + Size activeAreaSize; + Rectangle analogCrop; + Size outputSize; + + uint64 pixelRate; + uint32 lineLength; + + uint32 minFrameLength; + uint32 maxFrameLength; +}; + +/** + * \struct IPABuffer + * \brief Buffer information for the IPA interface + * + * The IPABuffer structure associates buffer memory with a unique ID. It is + * used to map buffers to the IPA with IPAInterface::mapBuffers(), after which + * buffers will be identified by their ID in the IPA interface. + */ + +/** + * \var IPABuffer::id + * \brief The buffer unique ID + * + * Buffers mapped to the IPA are identified by numerical unique IDs. The IDs + * are chosen by the pipeline handler to fulfil the following constraints: + * + * - IDs shall be positive integers different than zero + * - IDs shall be unique among all mapped buffers + * + * When buffers are unmapped with IPAInterface::unmapBuffers() their IDs are + * freed and may be reused for new buffer mappings. + */ + +/** + * \var IPABuffer::planes + * \brief The buffer planes description + * + * Stores the dmabuf handle and length for each plane of the buffer. + */ + +struct IPABuffer { + uint32 id; + [hasFd] array planes; +}; + +/** + * \struct IPASettings + * \brief IPA interface initialization settings + * + * The IPASettings structure stores data passed to the IPAInterface::init() + * function. The data contains settings that don't depend on a particular camera + * or pipeline configuration and are valid for the whole life time of the IPA + * interface. + */ + +/** + * \var IPASettings::configurationFile + * \brief The name of the IPA configuration file + * + * This field may be an empty string if the IPA doesn't require a configuration + * file. + */ +struct IPASettings { + string configurationFile; +}; + +/** + * \struct IPAStream + * \brief Stream configuration for the IPA interface + * + * The IPAStream structure stores stream configuration parameters needed by the + * IPAInterface::configure() method. It mirrors the StreamConfiguration class + * that is not suitable for this purpose due to not being serializable. + */ + +/** + * \var IPAStream::pixelFormat + * \brief The stream pixel format + */ + +/** + * \var IPAStream::size + * \brief The stream size in pixels + */ +struct IPAStream { + uint32 pixelFormat; + Size size; +}; + +/** + * \fn IPAInterface::init() + * \brief Initialise the IPAInterface + * \param[in] settings The IPA initialization settings + * + * This function initializes the IPA interface. It shall be called before any + * other function of the IPAInterface. The \a settings carry initialization + * parameters that are valid for the whole life time of the IPA interface. + */ + +/** + * \fn IPAInterface::stop() + * \brief Stop the IPA + * + * This method informs the IPA module that the camera is stopped. The IPA module + * shall release resources prepared in start(). + */