summaryrefslogtreecommitdiff
path: root/src/ipa/ipu3/ipu3.cpp
diff options
context:
space:
mode:
authorUmang Jain <umang.jain@ideasonboard.com>2022-03-06 00:35:49 +0530
committerUmang Jain <umang.jain@ideasonboard.com>2022-04-08 12:55:10 +0530
commitcbfa81cb4e9129622eb700cbc36e2856f77abb39 (patch)
treeb3ad53443bccaa4987703edde615d80d744490c1 /src/ipa/ipu3/ipu3.cpp
parent302731cdf8e107f8fa005309f3475f98581de8e6 (diff)
ipa: ipu3: Replace event-based ops with dedicated functions
The IPAIPU3 interface currently uses event-type based structures in order to communicate with the pipeline-handler (and vice-versa). Replace the event based structures with dedicated functions associated to each operation. The translated naming scheme of actions to signals are: ActionSetSensorControls => setSensorControls ActionParamFilled => paramsBufferReady ActionMetadataReady => metadataReady The translated naming scheme of events to dedicated functions are: EventProcessControls => queueRequest() EventStatReady => processStatsBuffer() EventFillParams => fillParamsBuffer() The dedicated functions are called from pipeline-handler to the IPA using IPC. These functions run asynchronously and when completed, the IPA emits the respective signals as stated above in the translated naming scheme. The EventProcessControls is translated to queueRequest() to bring symmetry to the IPU3 interface with other IPA interfaces. Signed-off-by: Umang Jain <umang.jain@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Diffstat (limited to 'src/ipa/ipu3/ipu3.cpp')
-rw-r--r--src/ipa/ipu3/ipu3.cpp130
1 files changed, 56 insertions, 74 deletions
diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp
index 50b52d8b..14f3f91e 100644
--- a/src/ipa/ipu3/ipu3.cpp
+++ b/src/ipa/ipu3/ipu3.cpp
@@ -65,8 +65,9 @@ namespace ipa::ipu3 {
* The IPU3 Pipeline defines an IPU3-specific interface for communication
* between the PipelineHandler and the IPA module.
*
- * We extend the IPAIPU3Interface to implement our algorithms and handle events
- * from the IPU3 PipelineHandler to satisfy requests from the application.
+ * We extend the IPAIPU3Interface to implement our algorithms and handle
+ * calls from the IPU3 PipelineHandler to satisfy requests from the
+ * application.
*
* At initialisation time, a CameraSensorHelper is instantiated to support
* camera-specific calculations, while the default controls are computed, and
@@ -81,14 +82,14 @@ namespace ipa::ipu3 {
* parameter buffer, and adapting the settings of the sensor attached to the
* IPU3 CIO2 through sensor-specific V4L2 controls.
*
- * When the event \a EventFillParams occurs we populate the ImgU parameter
- * buffer with settings to configure the device in preparation for handling the
- * frame queued in the Request.
+ * In fillParamsBuffer(), we populate the ImgU parameter buffer with
+ * settings to configure the device in preparation for handling the frame
+ * queued in the Request.
*
* When the frame has completed processing, the ImgU will generate a statistics
- * buffer which is given to the IPA as part of the \a EventStatReady event. At
- * this event we run the algorithms to parse the statistics and cache any
- * results for the next \a EventFillParams event.
+ * buffer which is given to the IPA with processStatsBuffer(). In this we run the
+ * algorithms to parse the statistics and cache any results for the next
+ * fillParamsBuffer() call.
*
* The individual algorithms are split into modular components that are called
* iteratively to allow them to process statistics from the ImgU in a defined
@@ -143,14 +144,18 @@ public:
void mapBuffers(const std::vector<IPABuffer> &buffers) override;
void unmapBuffers(const std::vector<unsigned int> &ids) override;
- void processEvent(const IPU3Event &event) override;
+ void queueRequest(const uint32_t frame, const ControlList &controls) override;
+ void fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) override;
+ void processStatsBuffer(const uint32_t frame, const int64_t frameTimestamp,
+ const uint32_t bufferId,
+ const ControlList &sensorControls) override;
private:
void updateControls(const IPACameraSensorInfo &sensorInfo,
const ControlInfoMap &sensorControls,
ControlInfoMap *ipaControls);
void updateSessionConfiguration(const ControlInfoMap &sensorControls);
- void processControls(unsigned int frame, const ControlList &controls);
+
void fillParams(unsigned int frame, ipu3_uapi_params *params);
void parseStatistics(unsigned int frame,
int64_t frameTimestamp,
@@ -505,73 +510,62 @@ void IPAIPU3::unmapBuffers(const std::vector<unsigned int> &ids)
}
/**
- * \brief Process an event generated by the pipeline handler
- * \param[in] event The event sent from pipeline handler
- *
- * The expected event handling over the lifetime of a Request has
- * the following sequence:
- *
- * - EventProcessControls : Handle controls from a new Request
- * - EventFillParams : Prepare the ISP to process the Request
- * - EventStatReady : Process statistics after ISP completion
+ * \brief Fill and return a buffer with ISP processing parameters for a frame
+ * \param[in] frame The frame number
+ * \param[in] bufferId ID of the parameter buffer to fill
*/
-void IPAIPU3::processEvent(const IPU3Event &event)
+void IPAIPU3::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
{
- switch (event.op) {
- case EventProcessControls: {
- processControls(event.frame, event.controls);
- break;
+ auto it = buffers_.find(bufferId);
+ if (it == buffers_.end()) {
+ LOG(IPAIPU3, Error) << "Could not find param buffer!";
+ return;
}
- case EventFillParams: {
- auto it = buffers_.find(event.bufferId);
- if (it == buffers_.end()) {
- LOG(IPAIPU3, Error) << "Could not find param buffer!";
- return;
- }
- Span<uint8_t> mem = it->second.planes()[0];
- ipu3_uapi_params *params =
- reinterpret_cast<ipu3_uapi_params *>(mem.data());
+ Span<uint8_t> mem = it->second.planes()[0];
+ ipu3_uapi_params *params =
+ reinterpret_cast<ipu3_uapi_params *>(mem.data());
- fillParams(event.frame, params);
- break;
- }
- case EventStatReady: {
- auto it = buffers_.find(event.bufferId);
- if (it == buffers_.end()) {
- LOG(IPAIPU3, Error) << "Could not find stats buffer!";
- return;
- }
+ fillParams(frame, params);
+}
- Span<uint8_t> mem = it->second.planes()[0];
- const ipu3_uapi_stats_3a *stats =
- reinterpret_cast<ipu3_uapi_stats_3a *>(mem.data());
+/**
+ * \brief Process statistics after ISP completion
+ * \param[in] frame The frame number
+ * \param[in] frameTimestamp Timestamp of the frame
+ * \param[in] bufferId ID of the statistics buffer
+ * \param[in] sensorControls Sensor controls
+ */
+void IPAIPU3::processStatsBuffer(const uint32_t frame,
+ [[maybe_unused]] const int64_t frameTimestamp,
+ const uint32_t bufferId, const ControlList &sensorControls)
+{
+ auto it = buffers_.find(bufferId);
+ if (it == buffers_.end()) {
+ LOG(IPAIPU3, Error) << "Could not find stats buffer!";
+ return;
+ }
- int32_t exposure = event.sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();
- int32_t gain = event.sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>();
+ Span<uint8_t> mem = it->second.planes()[0];
+ const ipu3_uapi_stats_3a *stats =
+ reinterpret_cast<ipu3_uapi_stats_3a *>(mem.data());
- context_.frameContext.sensor.exposure = exposure;
- context_.frameContext.sensor.gain = camHelper_->gain(gain);
+ context_.frameContext.sensor.exposure = sensorControls.get(V4L2_CID_EXPOSURE).get<int32_t>();
+ context_.frameContext.sensor.gain = camHelper_->gain(sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>());
- parseStatistics(event.frame, event.frameTimestamp, stats);
- break;
- }
- default:
- LOG(IPAIPU3, Error) << "Unknown event " << event.op;
- break;
- }
+ parseStatistics(frame, frameTimestamp, stats);
}
/**
- * \brief Process a control list for a request from the application
+ * \brief Queue a request and process the control list from the application
* \param[in] frame The number of the frame which will be processed next
* \param[in] controls The controls for the \a frame
*
* Parse the request to handle any IPA-managed controls that were set from the
* application such as manual sensor settings.
*/
-void IPAIPU3::processControls([[maybe_unused]] unsigned int frame,
- [[maybe_unused]] const ControlList &controls)
+void IPAIPU3::queueRequest([[maybe_unused]] const uint32_t frame,
+ [[maybe_unused]] const ControlList &controls)
{
/* \todo Start processing for 'frame' based on 'controls'. */
}
@@ -600,10 +594,7 @@ void IPAIPU3::fillParams(unsigned int frame, ipu3_uapi_params *params)
for (auto const &algo : algorithms_)
algo->prepare(context_, params);
- IPU3Action op;
- op.op = ActionParamFilled;
-
- queueFrameAction.emit(frame, op);
+ paramsBufferReady.emit(frame);
}
/**
@@ -647,11 +638,7 @@ void IPAIPU3::parseStatistics(unsigned int frame,
* likely want to avoid putting platform specific metadata in.
*/
- IPU3Action op;
- op.op = ActionMetadataReady;
- op.controls = ctrls;
-
- queueFrameAction.emit(frame, op);
+ metadataReady.emit(frame, ctrls);
}
/**
@@ -663,23 +650,18 @@ void IPAIPU3::parseStatistics(unsigned int frame,
*/
void IPAIPU3::setControls(unsigned int frame)
{
- IPU3Action op;
- op.op = ActionSetSensorControls;
-
int32_t exposure = context_.frameContext.agc.exposure;
int32_t gain = camHelper_->gainCode(context_.frameContext.agc.gain);
ControlList ctrls(sensorCtrls_);
ctrls.set(V4L2_CID_EXPOSURE, exposure);
ctrls.set(V4L2_CID_ANALOGUE_GAIN, gain);
- op.sensorControls = ctrls;
ControlList lensCtrls(lensCtrls_);
lensCtrls.set(V4L2_CID_FOCUS_ABSOLUTE,
static_cast<int32_t>(context_.frameContext.af.focus));
- op.lensControls = lensCtrls;
- queueFrameAction.emit(frame, op);
+ setSensorControls.emit(frame, ctrls, lensCtrls);
}
} /* namespace ipa::ipu3 */