summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2021-08-13 15:16:17 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2021-08-17 12:57:48 +0100
commit61405952e61ec3623fa9d449c6ab40b55f6098c9 (patch)
tree87b73396601755eab78699c8d431f2a3ea058bc5
parentbf42754794d22e3dc7cc83dbf63cc64f417364ca (diff)
ipu3: Initialise controls in the IPA
In commit 11fe4333c54d ("libcamera: ipu3: Initialize controls in the IPA") the interface for the IPA was updated and the creation of exposure and frame duration controls are now the responsibility of the IPA. In libcamera, the code that creates these controls was moved to the integrated IPA for the IPU3. Duplicate the implementation here. Acked-by: Umang Jain <umang.jain@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
-rw-r--r--ipu3.cpp58
1 files changed, 56 insertions, 2 deletions
diff --git a/ipu3.cpp b/ipu3.cpp
index b8015af..3e89e6d 100644
--- a/ipu3.cpp
+++ b/ipu3.cpp
@@ -36,7 +36,10 @@ namespace ipa::ipu3 {
class IPAIPU3 : public IPAIPU3Interface
{
public:
- int init(const IPASettings &settings) override;
+ int init(const IPASettings &settings,
+ const IPACameraSensorInfo &sensorInfo,
+ const ControlInfoMap &sensorControls,
+ ControlInfoMap *ipaControls) override;
int start() override;
void stop() override {}
@@ -83,7 +86,10 @@ private:
BinaryData aiqd_;
};
-int IPAIPU3::init(const IPASettings &settings)
+int IPAIPU3::init(const IPASettings &settings,
+ const IPACameraSensorInfo &sensorInfo,
+ const ControlInfoMap &sensorControls,
+ ControlInfoMap *ipaControls)
{
int ret;
@@ -135,6 +141,54 @@ int IPAIPU3::init(const IPASettings &settings)
aiqInputParams_.init();
+ /* Initialize Controls. */
+ ControlInfoMap::Map controls{};
+
+ /*
+ * Compute exposure time limits.
+ *
+ * Initialize the control using the line length and pixel rate of the
+ * current configuration converted to microseconds. Use the
+ * V4L2_CID_EXPOSURE control to get exposure min, max and default and
+ * convert it from lines to microseconds.
+ */
+ double lineDuration = sensorInfo.lineLength / (sensorInfo.pixelRate / 1e6);
+ const ControlInfo &v4l2Exposure = sensorControls.find(V4L2_CID_EXPOSURE)->second;
+ int32_t minExposure = v4l2Exposure.min().get<int32_t>() * lineDuration;
+ int32_t maxExposure = v4l2Exposure.max().get<int32_t>() * lineDuration;
+ int32_t defExposure = v4l2Exposure.def().get<int32_t>() * lineDuration;
+ controls[&controls::ExposureTime] = ControlInfo(minExposure, maxExposure,
+ defExposure);
+
+ /*
+ * Compute the frame duration limits.
+ *
+ * The frame length is computed assuming a fixed line length combined
+ * with the vertical frame sizes.
+ */
+ const ControlInfo &v4l2HBlank = sensorControls.find(V4L2_CID_HBLANK)->second;
+ uint32_t hblank = v4l2HBlank.def().get<int32_t>();
+ uint32_t lineLength = sensorInfo.outputSize.width + hblank;
+
+ const ControlInfo &v4l2VBlank = sensorControls.find(V4L2_CID_VBLANK)->second;
+ std::array<uint32_t, 3> frameHeights{
+ v4l2VBlank.min().get<int32_t>() + sensorInfo.outputSize.height,
+ v4l2VBlank.max().get<int32_t>() + sensorInfo.outputSize.height,
+ v4l2VBlank.def().get<int32_t>() + sensorInfo.outputSize.height,
+ };
+
+ std::array<int64_t, 3> frameDurations;
+ for (unsigned int i = 0; i < frameHeights.size(); ++i) {
+ uint64_t frameSize = lineLength * frameHeights[i];
+ frameDurations[i] = frameSize / (sensorInfo.pixelRate / 1000000U);
+ }
+
+ controls[&controls::FrameDurationLimits] = ControlInfo(frameDurations[0],
+ frameDurations[1],
+ frameDurations[2]);
+
+ *ipaControls = ControlInfoMap(std::move(controls), controls::controls);
+
return 0;
}