diff options
Diffstat (limited to 'include/libcamera/ipa')
-rw-r--r-- | include/libcamera/ipa/core.mojom | 49 | ||||
-rw-r--r-- | include/libcamera/ipa/ipa_controls.h | 2 | ||||
-rw-r--r-- | include/libcamera/ipa/ipa_interface.h | 7 | ||||
-rw-r--r-- | include/libcamera/ipa/ipa_module_info.h | 2 | ||||
-rw-r--r-- | include/libcamera/ipa/meson.build | 45 | ||||
-rw-r--r-- | include/libcamera/ipa/raspberrypi.mojom | 267 | ||||
-rw-r--r-- | include/libcamera/ipa/rkisp1.mojom | 18 | ||||
-rw-r--r-- | include/libcamera/ipa/soft.mojom | 28 | ||||
-rw-r--r-- | include/libcamera/ipa/vimc.mojom | 14 |
9 files changed, 343 insertions, 89 deletions
diff --git a/include/libcamera/ipa/core.mojom b/include/libcamera/ipa/core.mojom index 74f3339e..bce79724 100644 --- a/include/libcamera/ipa/core.mojom +++ b/include/libcamera/ipa/core.mojom @@ -14,8 +14,8 @@ module libcamera; * - structs * * Attributes: - * - skipHeader - structs only, and only in core.mojom - * - Do not generate a C++ definition for the structure + * - skipHeader - allowed only for structs and enums in core.mojom + * - Do not generate a C++ definition for the structure or enum * - Any type used in a mojom interface definition must have a corresponding * definition in a mojom file for the code generator to accept it, except * for types solely used as map/array members for which a definition is not @@ -33,6 +33,15 @@ module libcamera; * available for the type and there's no need to generate one * - hasFd - struct fields or empty structs only * - Designate that this field or empty struct contains a SharedFD + * - scopedEnum - enum definitions + * - Designate that this enum should be an enum class, as opposed to a pure + * enum + * - flags - struct fields or function parameters that are enums + * - Designate that this enum type E should be Flags<E> in the generated C++ + * code + * - For example, if a struct field is defined as `[flags] ErrorFlag f;` + * (where ErrorFlag is defined as an enum elsewhere in mojom), then the + * generated code for this field will be `Flags<ErrorFlag> f` * * Rules: * - If the type is defined in a libcamera C++ header *and* a (de)serializer is @@ -43,6 +52,8 @@ module libcamera; * then the type definition in the core.mojom file should have the * [skipHeader] attribute only * - A (de)serializer will be generated for the type + * - enums that are defined in a libcamera C++ header also fall in this + * category * - If a type definition has [skipHeader], then the header where the type is * defined must be included in ipa_interface.h * - Types that are solely used as array/map members do not require a mojom @@ -130,6 +141,18 @@ module libcamera; */ /** + * \var IPACameraSensorInfo::cfaPattern + * \brief The arrangement of colour filters on the image sensor + * + * This takes a value defined by properties::draft::ColorFilterArrangementEnum. + * For non-Bayer colour sensors, the cfaPattern will be set to + * properties::draft::ColorFilterArrangementEnum::RGB. + * + * \todo Make this variable optional once mojom supports it, instead of using + * RGB for sensors that don't have a CFA. + */ + +/** * \var IPACameraSensorInfo::activeAreaSize * \brief The size of the pixel array active area of the sensor */ @@ -172,10 +195,17 @@ module libcamera; */ /** - * \var IPACameraSensorInfo::lineLength - * \brief Total line length in pixels + * \var IPACameraSensorInfo::minLineLength + * \brief The minimum line length in pixels * - * The total line length in pixel clock periods, including blanking. + * The minimum allowable line length in pixel clock periods, including blanking. + */ + +/** + * \var IPACameraSensorInfo::maxLineLength + * \brief The maximum line length in pixels + * + * The maximum allowable line length in pixel clock periods, including blanking. */ /** @@ -189,7 +219,7 @@ module libcamera; * To obtain the minimum frame duration: * * \verbatim - frameDuration(s) = minFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second) + frameDuration(s) = minFrameLength(lines) * minLineLength(pixels) / pixelRate(pixels per second) \endverbatim */ @@ -204,20 +234,23 @@ module libcamera; * To obtain the maximum frame duration: * * \verbatim - frameDuration(s) = maxFrameLength(lines) * lineLength(pixels) / pixelRate(pixels per second) + frameDuration(s) = maxFrameLength(lines) * maxLineLength(pixels) / pixelRate(pixels per second) \endverbatim */ struct IPACameraSensorInfo { string model; uint32 bitsPerPixel; + uint32 cfaPattern; Size activeAreaSize; Rectangle analogCrop; Size outputSize; uint64 pixelRate; - uint32 lineLength; + + uint32 minLineLength; + uint32 maxLineLength; uint32 minFrameLength; uint32 maxFrameLength; diff --git a/include/libcamera/ipa/ipa_controls.h b/include/libcamera/ipa/ipa_controls.h index e5da1946..5fd13394 100644 --- a/include/libcamera/ipa/ipa_controls.h +++ b/include/libcamera/ipa/ipa_controls.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * ipa_controls.h - IPA Control handling + * IPA Control handling */ #pragma once diff --git a/include/libcamera/ipa/ipa_interface.h b/include/libcamera/ipa/ipa_interface.h index 50ca0e7b..b93f1a15 100644 --- a/include/libcamera/ipa/ipa_interface.h +++ b/include/libcamera/ipa/ipa_interface.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * ipa_interface.h - Image Processing Algorithm interface + * Image Processing Algorithm interface */ #pragma once @@ -13,6 +13,7 @@ #include <map> #include <vector> +#include <libcamera/base/flags.h> #include <libcamera/base/signal.h> #include <libcamera/controls.h> @@ -22,8 +23,8 @@ namespace libcamera { /* - * Structs that are defined in core.mojom and have the skipHeader tag must be - * #included here. + * Structs and enums that are defined in core.mojom that have the skipHeader + * tag must be #included here. */ class IPAInterface diff --git a/include/libcamera/ipa/ipa_module_info.h b/include/libcamera/ipa/ipa_module_info.h index b19b00f7..3507a6d7 100644 --- a/include/libcamera/ipa/ipa_module_info.h +++ b/include/libcamera/ipa/ipa_module_info.h @@ -2,7 +2,7 @@ /* * Copyright (C) 2019, Google Inc. * - * ipa_module_info.h - Image Processing Algorithm module information + * Image Processing Algorithm module information */ #pragma once diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build index 442ca3dd..3352d08f 100644 --- a/include/libcamera/ipa/meson.build +++ b/include/libcamera/ipa/meson.build @@ -9,7 +9,7 @@ libcamera_ipa_headers = files([ ]) install_headers(libcamera_ipa_headers, - subdir: libcamera_ipa_include_dir) + subdir : libcamera_ipa_include_dir) libcamera_generated_ipa_headers = [] @@ -60,14 +60,14 @@ libcamera_generated_ipa_headers += custom_target('core_ipa_serializer_h', './' +'@INPUT@' ]) -ipa_mojom_files = [ - 'ipu3.mojom', - 'raspberrypi.mojom', - 'rkisp1.mojom', - 'vimc.mojom', -] - -ipa_mojoms = [] +# Mapping from pipeline handler name to mojom file +pipeline_ipa_mojom_mapping = { + 'ipu3': 'ipu3.mojom', + 'rkisp1': 'rkisp1.mojom', + 'rpi/vc4': 'raspberrypi.mojom', + 'simple': 'soft.mojom', + 'vimc': 'vimc.mojom', +} # # Generate headers from templates. @@ -75,14 +75,23 @@ ipa_mojoms = [] # TODO Define per-pipeline ControlInfoMap with yaml? -foreach file : ipa_mojom_files +ipa_mojoms = [] +mojoms_built = [] +foreach pipeline, file : pipeline_ipa_mojom_mapping name = file.split('.')[0] - if name not in pipelines + # Avoid building duplicate mojom interfaces with the same interface file + if name in mojoms_built continue endif - # {pipeline}.mojom-module + if pipeline not in pipelines + continue + endif + + mojoms_built += name + + # {interface}.mojom-module mojom = custom_target(name + '_mojom_module', input : file, output : file + '-module', @@ -94,7 +103,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 +119,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 +133,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', @@ -146,6 +155,12 @@ foreach file : ipa_mojom_files libcamera_generated_ipa_headers += [header, serializer, proxy_header] endforeach +ipa_mojom_files = [] +foreach pipeline, file : pipeline_ipa_mojom_mapping + if file not in ipa_mojom_files + ipa_mojom_files += file + endif +endforeach ipa_mojom_files = files(ipa_mojom_files) # Pass this to the documentation generator in src/libcamera/ipa diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index c0de435b..5986c436 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -8,82 +8,139 @@ 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. */ +/* Size of the LS grid allocation on VC4. */ const uint32 MaxLsGridSize = 0x8000; struct SensorConfig { uint32 gainDelay; uint32 exposureDelay; uint32 vblankDelay; + uint32 hblankDelay; uint32 sensorMetadata; }; -struct IPAInitResult { +struct InitParams { + bool lensPresent; + libcamera.IPACameraSensorInfo sensorInfo; + /* PISP specific */ + libcamera.SharedFD fe; + libcamera.SharedFD be; +}; + +struct InitResult { SensorConfig sensorConfig; libcamera.ControlInfoMap controlInfo; }; -struct ISPConfig { - uint32 embeddedBufferId; - uint32 bayerBufferId; - bool embeddedBufferPresent; - libcamera.ControlList controls; +struct BufferIds { + uint32 bayer; + uint32 embedded; + uint32 stats; }; -struct IPAConfig { +struct ConfigParams { uint32 transform; + libcamera.ControlInfoMap sensorControls; + libcamera.ControlInfoMap ispControls; + libcamera.ControlInfoMap lensControls; + /* VC4 specific */ libcamera.SharedFD lsTableHandle; }; -struct IPAConfigResult { - float modeSensitivity; - libcamera.ControlInfoMap controlInfo; +struct ConfigResult { + float modeSensitivity; + libcamera.ControlInfoMap controlInfo; + libcamera.ControlList sensorControls; + libcamera.ControlList lensControls; }; -struct StartConfig { +struct StartResult { libcamera.ControlList controls; int32 dropFrameCount; - uint32 maxSensorFrameLengthMs; +}; + +struct PrepareParams { + BufferIds buffers; + libcamera.ControlList sensorControls; + libcamera.ControlList requestControls; + uint32 ipaContext; + uint32 delayContext; +}; + +struct ProcessParams { + BufferIds buffers; + uint32 ipaContext; }; interface IPARPiInterface { - init(libcamera.IPASettings settings) - => (int32 ret, IPAInitResult result); - start(libcamera.ControlList controls) => (StartConfig startConfig); + /** + * \fn init() + * \brief Initialise the IPA + * \param[in] settings Camera sensor information and configuration file + * \param[in] params Platform specific initialisation parameters + * \param[out] ret 0 on success or a negative error code otherwise + * \param[out] result Static sensor configuration and controls available + * + * This function initialises the IPA for a particular sensor from the + * pipeline handler. + * + * The \a settings conveys information about the camera sensor and + * configuration file requested by the pipeline handler. + * + * The \a result parameter returns the sensor delay for the given camera + * as well as a ControlInfoMap of available controls that can be handled + * by the IPA. + */ + init(libcamera.IPASettings settings, InitParams params) + => (int32 ret, InitResult result); + + /** + * \fn start() + * \brief Start the IPA + * \param[in] controls List of control to handle + * \param[out] result Controls to apply and number of dropped frames + * + * This function sets the IPA to a started state. + * + * The \a controls provide a list of controls to handle immediately. The + * actual controls to apply on the sensor and ISP in the pipeline + * handler are returned in \a result. + * + * The number of convergence frames to be dropped is also returned in + * \a result. + */ + start(libcamera.ControlList controls) => (StartResult result); + + /** + * \fn start() + * \brief Stop the IPA + * + * This function sets the IPA to a stopped state. + */ 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. + * \brief Configure the IPA + * \param[in] sensorInfo Sensor mode configuration + * \param[in] params Platform configuration parameters + * \param[out] ret 0 on success or a negative error code otherwise + * \param[out] result Results of the configuration operation + * + * This function configures the IPA for a particular camera + * configuration + * + * The \a params parameter provides a list of available controls for the + * ISP, sensor and lens devices, and the user requested transform + * operation. It can also provide platform specific configuration + * parameters, e.g. the lens shading table memory handle for VC4. + * + * The \a result parameter returns the available controls for the given + * camera mode, a list of controls to apply to the sensor device, and + * the requested mode's sensitivity characteristics. */ - configure(libcamera.IPACameraSensorInfo sensorInfo, - map<uint32, libcamera.IPAStream> streamConfig, - map<uint32, libcamera.ControlInfoMap> entityControls, - IPAConfig ipaConfig) - => (int32 ret, libcamera.ControlList controls, IPAConfigResult result); + configure(libcamera.IPACameraSensorInfo sensorInfo, ConfigParams params) + => (int32 ret, ConfigResult result); /** * \fn mapBuffers() @@ -106,7 +163,7 @@ interface IPARPiInterface { * 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 + * 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. * @@ -126,15 +183,119 @@ interface IPARPiInterface { */ unmapBuffers(array<uint32> ids); - [async] signalStatReady(uint32 bufferId); - [async] signalQueueRequest(libcamera.ControlList controls); - [async] signalIspPrepare(ISPConfig data); + /** + * \fn prepareIsp() + * \brief Prepare the ISP configuration for a frame + * \param[in] params Parameter set for the frame to process + * + * This function call into all the algorithms in preparation for the + * frame to be processed by the ISP. + * + * The \a params parameter lists the buffer IDs for the Bayer and + * embedded data buffers, a ControlList of sensor frame params, and + * a ControlList of request controls for the current frame. + * + * Additionally, \a params also contains the IPA context (ipaContext) to + * use as an index location to store control algorithm results, and a + * historical IPA context (delayContext) that was active when the sensor + * settings were requested by the IPA. + */ + [async] prepareIsp(PrepareParams params); + + /** + * \fn processStats() + * \brief Process the statistics provided by the ISP + * \param[in] params Parameter set for the statistics to process + * + * This function call into all the algorithms to provide the statistics + * generated by the ISP for the processed frame. + * + * The \a params parameter lists the buffer ID for the statistics buffer + * and an IPA context (ipaContext) to use as an index location to store + * algorithm results. + */ + [async] processStats(ProcessParams params); }; interface IPARPiEventInterface { - statsMetadataComplete(uint32 bufferId, libcamera.ControlList controls); - runIsp(uint32 bufferId); - embeddedComplete(uint32 bufferId); + /** + * \fn prepareIspComplete() + * \brief Signal completion of \a prepareIsp + * \param[in] buffers Bayer and embedded buffers actioned. + * \param[in] stitchSwapBuffers Whether the stitch block buffers need to be swapped. + * + * This asynchronous event is signalled to the pipeline handler once + * the \a prepareIsp signal has completed, and the ISP is ready to start + * processing the frame. The embedded data buffer may be recycled after + * this event. + */ + prepareIspComplete(BufferIds buffers, bool stitchSwapBuffers); + + /** + * \fn processStatsComplete() + * \brief Signal completion of \a processStats + * \param[in] buffers Statistics buffers actioned. + * + * This asynchronous event is signalled to the pipeline handler once + * the \a processStats signal has completed. The statistics buffer may + * be recycled after this event. + */ + processStatsComplete(BufferIds buffers); + + /** + * \fn metadataReady() + * \brief Signal request metadata is to be merged + * \param[in] metadata Control list of metadata to be merged + * + * This asynchronous event is signalled to the pipeline handler once + * all the frame metadata has been gathered. The pipeline handler will + * copy or merge this metadata into the \a Request returned back to the + * application. + */ + metadataReady(libcamera.ControlList metadata); + + /** + * \fn setIspControls() + * \brief Signal ISP controls to be applied. + * \param[in] controls List of controls to be applied. + * + * This asynchronous event is signalled to the pipeline handler during + * the \a prepareISP signal after all algorithms have been run and the + * IPA requires ISP controls to be applied for the frame. + */ setIspControls(libcamera.ControlList controls); - setDelayedControls(libcamera.ControlList controls); + + /** + * \fn setDelayedControls() + * \brief Signal Sensor controls to be applied. + * \param[in] controls List of controls to be applied. + * \param[in] delayContext IPA context index used for this request + * + * This asynchronous event is signalled to the pipeline handler when + * the IPA requires sensor specific controls (e.g. shutter speed, gain, + * blanking) to be applied. + */ + setDelayedControls(libcamera.ControlList controls, uint32 delayContext); + + /** + * \fn setLensControls() + * \brief Signal lens controls to be applied. + * \param[in] controls List of controls to be applied. + * + * This asynchronous event is signalled to the pipeline handler when + * the IPA requires a lens movement control to be applied. + */ + setLensControls(libcamera.ControlList controls); + + /** + * \fn setCameraTimeout() + * \brief Request a watchdog timeout value to use + * \param[in] maxFrameLengthMs Timeout value in ms + * + * This asynchronous event is used by the IPA to inform the pipeline + * handler of an acceptable watchdog timer value to use for the sensor + * stream. This value is based on the history of frame lengths requested + * by the IPA. + */ + setCameraTimeout(uint32 maxFrameLengthMs); }; diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index e3537385..1009e970 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -8,17 +8,23 @@ module ipa.rkisp1; import "include/libcamera/ipa/core.mojom"; +struct IPAConfigInfo { + libcamera.IPACameraSensorInfo sensorInfo; + libcamera.ControlInfoMap sensorControls; +}; + interface IPARkISP1Interface { init(libcamera.IPASettings settings, - uint32 hwRevision) - => (int32 ret); + uint32 hwRevision, + libcamera.IPACameraSensorInfo sensorInfo, + libcamera.ControlInfoMap sensorControls) + => (int32 ret, libcamera.ControlInfoMap ipaControls); start() => (int32 ret); stop(); - configure(libcamera.IPACameraSensorInfo sensorInfo, - map<uint32, libcamera.IPAStream> streamConfig, - map<uint32, libcamera.ControlInfoMap> entityControls) - => (int32 ret); + configure(IPAConfigInfo configInfo, + map<uint32, libcamera.IPAStream> streamConfig) + => (int32 ret, libcamera.ControlInfoMap ipaControls); mapBuffers(array<libcamera.IPABuffer> buffers); unmapBuffers(array<uint32> ids); diff --git a/include/libcamera/ipa/soft.mojom b/include/libcamera/ipa/soft.mojom new file mode 100644 index 00000000..3aa2066e --- /dev/null +++ b/include/libcamera/ipa/soft.mojom @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +/* + * \todo Document the interface and remove the related EXCLUDE_PATTERNS entry. + */ + +module ipa.soft; + +import "include/libcamera/ipa/core.mojom"; + +interface IPASoftInterface { + init(libcamera.IPASettings settings, + libcamera.SharedFD fdStats, + libcamera.SharedFD fdParams, + libcamera.ControlInfoMap sensorCtrlInfoMap) + => (int32 ret); + start() => (int32 ret); + stop(); + configure(libcamera.ControlInfoMap sensorCtrlInfoMap) + => (int32 ret); + + [async] processStats(libcamera.ControlList sensorControls); +}; + +interface IPASoftEventInterface { + setSensorControls(libcamera.ControlList sensorControls); + setIspParams(); +}; diff --git a/include/libcamera/ipa/vimc.mojom b/include/libcamera/ipa/vimc.mojom index 718b9674..dd991f7e 100644 --- a/include/libcamera/ipa/vimc.mojom +++ b/include/libcamera/ipa/vimc.mojom @@ -17,8 +17,18 @@ enum IPAOperationCode { IPAOperationStop, }; +[scopedEnum] enum TestFlag { + Flag1 = 0x1, + Flag2 = 0x2, + Flag3 = 0x4, + Flag4 = 0x8, +}; + interface IPAVimcInterface { - init(libcamera.IPASettings settings) => (int32 ret); + init(libcamera.IPASettings settings, + IPAOperationCode code, + [flags] TestFlag inFlags) + => (int32 ret, [flags] TestFlag outFlags); configure(libcamera.IPACameraSensorInfo sensorInfo, map<uint32, libcamera.IPAStream> streamConfig, @@ -41,5 +51,5 @@ interface IPAVimcInterface { }; interface IPAVimcEventInterface { - paramsBufferReady(uint32 bufferId); + paramsBufferReady(uint32 bufferId, [flags] TestFlag flags); }; |