summaryrefslogtreecommitdiff
path: root/include/libcamera/ipa/raspberrypi.mojom
blob: a60c3bb43d3c75c1fc89dd52200327c2b7237319 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* SPDX-License-Identifier: LGPL-2.1-or-later */

/*
 * \todo Document the interface and remove the related EXCLUDE_PATTERNS entry.
 */

module ipa.RPi;

import "include/libcamera/ipa/core.mojom";

enum BufferMask {
	MaskID			= 0x00ffff,
	MaskStats		= 0x010000,
	MaskEmbeddedData	= 0x020000,
	MaskBayerData		= 0x040000,
	MaskExternalBuffer	= 0x100000,
};

/* Size of the LS grid allocation. */
const uint32 MaxLsGridSize = 0x8000;

struct SensorConfig {
	uint32 gainDelay;
	uint32 exposureDelay;
	uint32 vblankDelay;
	uint32 sensorMetadata;
};

struct ISPConfig {
	uint32 embeddedBufferId;
	uint32 bayerBufferId;
	bool embeddedBufferPresent;
	libcamera.ControlList controls;
};

struct IPAConfig {
	uint32 transform;
	libcamera.SharedFD lsTableHandle;
};

struct IPAConfigResult {
       float modeSensitivity;
};

struct StartConfig {
	libcamera.ControlList controls;
	int32 dropFrameCount;
	uint32 maxSensorFrameLengthMs;
};

interface IPARPiInterface {
	init(libcamera.IPASettings settings)
		=> (int32 ret, SensorConfig sensorConfig);
	start(libcamera.ControlList controls) => (StartConfig startConfig);
	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] controls Controls to apply by the pipeline entity
	 * \param[out] result Other results that the pipeline handler may require
	 *
	 * This function shall be called when the camera is configured to inform
	 * the IPA of the camera's streams and the sensor settings.
	 *
	 * The \a sensorInfo conveys information about the camera sensor settings that
	 * the pipeline handler has selected for the configuration.
	 *
	 * The \a ipaConfig and \a controls parameters carry data passed by the
	 * pipeline handler to the IPA and back.
	 */
	configure(libcamera.IPACameraSensorInfo sensorInfo,
		  map<uint32, libcamera.IPAStream> streamConfig,
		  map<uint32, libcamera.ControlInfoMap> entityControls,
		  IPAConfig ipaConfig)
		=> (int32 ret, libcamera.ControlList controls, IPAConfigResult result);

	/**
	 * \fn mapBuffers()
	 * \brief Map buffers shared between the pipeline handler and the IPA
	 * \param[in] buffers List of buffers to map
	 *
	 * This function 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 functions to refer to
	 * buffers, including the unmapBuffers() function.
	 *
	 * All buffers that the pipeline handler wishes to share with an IPA
	 * shall be mapped with this function. 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 
	 * should be treated as opaque handles by IPAs, with the only exception
	 * that ID zero is invalid.
	 *
	 * \sa unmapBuffers()
	 */
	mapBuffers(array<libcamera.IPABuffer> buffers);

	/**
	 * \fn unmapBuffers()
	 * \brief Unmap buffers shared by the pipeline to the IPA
	 * \param[in] ids List of buffer IDs to unmap
	 *
	 * This function removes mappings set up with mapBuffers(). Numerical
	 * IDs of unmapped buffers may be reused when mapping new buffers.
	 *
	 * \sa mapBuffers()
	 */
	unmapBuffers(array<uint32> ids);

	[async] signalStatReady(uint32 bufferId);
	[async] signalQueueRequest(libcamera.ControlList controls);
	[async] signalIspPrepare(ISPConfig data);
};

interface IPARPiEventInterface {
	statsMetadataComplete(uint32 bufferId, libcamera.ControlList controls);
	runIsp(uint32 bufferId);
	embeddedComplete(uint32 bufferId);
	setIspControls(libcamera.ControlList controls);
	setDelayedControls(libcamera.ControlList controls);
};