[libcamera-devel,27/38] ipa: raspberrypi: Add mojom data definition file

Message ID 20200922133537.258098-28-paul.elder@ideasonboard.com
State Superseded
Headers show
Series
  • IPA isolation implementation
Related show

Commit Message

Paul Elder Sept. 22, 2020, 1:35 p.m. UTC
Add a mojom data definition for raspberrypi pipeline handler's IPAs.
This is a direct translation of what the raspberrypi pipeline handler
and IPA was using before with IPAOperationData.

Also move the enums from raspberrypi.h to raspberrypi.mojom

Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>

---
Changes in v2:
- rebased on "libcamera: pipeline: ipa: raspberrypi: Rework drop frame
  signalling"
- add license
- move generic documentation to core.mojom
- move documentation from IPA interface
- customize the RPi IPA interface to make the pipeline and IPA code
  cleaner
---
 include/libcamera/ipa/meson.build       |   4 +-
 include/libcamera/ipa/raspberrypi.h     |  18 ---
 include/libcamera/ipa/raspberrypi.mojom | 157 ++++++++++++++++++++++++
 3 files changed, 160 insertions(+), 19 deletions(-)
 create mode 100644 include/libcamera/ipa/raspberrypi.mojom

Patch

diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build
index 9ec38198..0b74bc10 100644
--- a/include/libcamera/ipa/meson.build
+++ b/include/libcamera/ipa/meson.build
@@ -23,7 +23,9 @@  ipa_mojom_core = custom_target(core_mojom_file.split('.')[0] + '_mojom_module',
                                      '--mojoms', '@INPUT@'
                           ])
 
-ipa_mojom_files = []
+ipa_mojom_files = [
+    'raspberrypi.mojom',
+]
 
 ipa_mojoms = []
 
diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h
index dd6ebeac..4e38d009 100644
--- a/include/libcamera/ipa/raspberrypi.h
+++ b/include/libcamera/ipa/raspberrypi.h
@@ -10,24 +10,6 @@ 
 #include <libcamera/control_ids.h>
 #include <libcamera/controls.h>
 
-enum RPiConfigParameters {
-	RPI_IPA_CONFIG_LS_TABLE = (1 << 0),
-	RPI_IPA_CONFIG_STAGGERED_WRITE = (1 << 1),
-	RPI_IPA_CONFIG_SENSOR = (1 << 2),
-	RPI_IPA_CONFIG_DROP_FRAMES = (1 << 3),
-};
-
-enum RPiOperations {
-	RPI_IPA_ACTION_V4L2_SET_STAGGERED = 1,
-	RPI_IPA_ACTION_V4L2_SET_ISP,
-	RPI_IPA_ACTION_STATS_METADATA_COMPLETE,
-	RPI_IPA_ACTION_RUN_ISP,
-	RPI_IPA_ACTION_EMBEDDED_COMPLETE,
-	RPI_IPA_EVENT_SIGNAL_STAT_READY,
-	RPI_IPA_EVENT_SIGNAL_ISP_PREPARE,
-	RPI_IPA_EVENT_QUEUE_REQUEST,
-};
-
 enum RPiBufferMask {
 	ID		= 0x00ffff,
 	STATS		= 0x010000,
diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom
new file mode 100644
index 00000000..1573f818
--- /dev/null
+++ b/include/libcamera/ipa/raspberrypi.mojom
@@ -0,0 +1,157 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+import "include/libcamera/ipa/core.mojom";
+
+interface IPARPiInterface {
+/**
+ * \fn 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.
+ */
+	init(IPASettings settings) => (int32 ret);
+
+/**
+ * \fn start()
+ * \brief Start the IPA
+ *
+ * This method informs the IPA module that the camera is about to be started.
+ * The IPA module shall prepare any resources it needs to operate.
+ *
+ * \return 0 on success or a negative error code otherwise
+ */
+	start() => (int32 ret);
+
+/**
+ * \fn 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().
+ */
+	stop();
+
+/**
+ * \fn configure()
+ * \brief Configure the IPA stream and sensor settings
+ * \param[in] sensorInfo Camera sensor information
+ * \param[in] streamConfig Configuration of all active streams
+ * \param[in] entityControls Controls provided by the pipeline entities
+ * \param[in] ipaConfig Pipeline-handler-specific configuration data
+ * \param[out] result Pipeline-handler-specific configuration result
+ *
+ * This method shall be called when the camera is started to inform the IPA of
+ * the camera's streams and the sensor settings. The meaning of the numerical
+ * keys in the \a streamConfig and \a entityControls maps is defined by the IPA
+ * protocol.
+ *
+ * The \a sensorInfo conveys information about the camera sensor settings that
+ * the pipeline handler has selected for the configuration. The IPA may use
+ * that information to tune its algorithms.
+ *
+ * The \a ipaConfig and \a result parameters carry custom data passed by the
+ * pipeline handler to the IPA and back. The pipeline handler may set the \a
+ * result parameter to null if the IPA protocol doesn't need to pass a result
+ * back through the configure() function.
+ */
+	configure(CameraSensorInfo sensorInfo,
+		  map<uint32, IPAStream> streamConfig,
+		  map<uint32, ControlInfoMap> entityControls,
+		  RPiConfigInput ipaConfig)
+		=> (RPiConfigOutput results);
+
+	// arrays get turned into vectors
+
+/**
+ * \fn mapBuffers()
+ * \brief Map buffers shared between the pipeline handler and the IPA
+ * \param[in] buffers List of buffers to map
+ *
+ * This method informs the IPA module of memory buffers set up by the pipeline
+ * handler that the IPA needs to access. It provides dmabuf file handles for
+ * each buffer, and associates the buffers with unique numerical IDs.
+ *
+ * IPAs shall map the dmabuf file handles to their address space and keep a
+ * cache of the mappings, indexed by the buffer numerical IDs. The IDs are used
+ * in all other IPA interface methods to refer to buffers, including the
+ * unmapBuffers() method.
+ *
+ * All buffers that the pipeline handler wishes to share with an IPA shall be
+ * mapped with this method. Buffers may be mapped all at once with a single
+ * call, or mapped and unmapped dynamically at runtime, depending on the IPA
+ * protocol. Regardless of the protocol, all buffers mapped at a given time
+ * shall have unique numerical IDs.
+ *
+ * The numerical IDs have no meaning defined by the IPA interface, and IPA
+ * protocols shall not give them any specific meaning either. They should be
+ * treated as opaque handles by IPAs, with the only exception that ID zero is
+ * invalid.
+ *
+ * \sa unmapBuffers()
+ *
+ * \todo Provide a generic implementation of mapBuffers and unmapBuffers for
+ * IPAs
+ */
+	mapBuffers(array<IPABuffer> buffers);
+
+/**
+ * \fn unmapBuffers()
+ * \brief Unmap buffers shared by the pipeline to the IPA
+ * \param[in] ids List of buffer IDs to unmap
+ *
+ * This method removes mappings set up with mapBuffers(). Buffers may be
+ * unmapped all at once with a single call, or selectively at runtime, depending
+ * on the IPA protocol. Numerical IDs of unmapped buffers may be reused when
+ * mapping new buffers.
+ *
+ * \sa mapBuffers()
+ */
+	unmapBuffers(array<uint32> ids);
+
+	[async] signalStatReady(uint32 bufferId);
+	[async] signalQueueRequest(ControlList controls);
+	[async] signalIspPrepare(RPiIspPreparePayload data);
+};
+
+interface IPARPiCallbackInterface {
+	statsMetadataComplete(uint32 bufferId, ControlList controls);
+	runIsp(uint32 bufferId);
+	embeddedComplete(uint32 bufferId);
+	setIsp(ControlList controls);
+	setStaggered(ControlList controls);
+};
+
+
+enum RPiConfigParameters {
+	RPI_IPA_CONFIG_LS_TABLE = 0x01,
+	RPI_IPA_CONFIG_STAGGERED_WRITE = 0x02,
+	RPI_IPA_CONFIG_SENSOR = 0x04,
+	RPI_IPA_CONFIG_DROP_FRAMES = 0x08,
+};
+
+struct RPiStaggeredWritePayload {
+	uint32 gainDelay;
+	uint32 exposureDelay;
+	uint32 sensorMetadata;
+};
+
+struct RPiIspPreparePayload {
+	uint32 embeddedbufferId;
+	uint32 bayerbufferId;
+};
+
+struct RPiConfigInput {
+	uint32 op;
+	FileDescriptor lsTableHandle;
+	int32 lsTableHandleStatic = -1;
+};
+
+struct RPiConfigOutput {
+	uint32 op;
+	RPiStaggeredWritePayload staggeredWriteResult;
+	ControlList controls;
+	int32 dropFrameCount;
+};