ipa: raspberry: Port to the new AEGC controls

The newly introduced controls to drive the AEGC algorithm allow to
control the computation of the exposure time and analogue gain
separately.

The RPi AEGC implementation already computes the shutter and gain values
separately but does not expose separate functions to control them.

Augment the AgcAlgorithm interface to allow pausing/resuming the shutter
and gain automatic computations separately and plumb them to the newly
introduced controls.

Add safety checks to ignore ExposureTime and AnalogueGain values if the
algorithms are not paused, and report the correct AeState value by
checking if both algorithms have been paused or if they have converged.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
Acked-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Jacopo Mondi
2025-01-14 15:33:37 -06:00
committed by Laurent Pinchart
parent 72b2c9dddf
commit c45a2682c3
6 changed files with 167 additions and 35 deletions
+6 -2
View File
@@ -30,8 +30,12 @@ public:
virtual void setMeteringMode(std::string const &meteringModeName) = 0;
virtual void setExposureMode(std::string const &exposureModeName) = 0;
virtual void setConstraintMode(std::string const &contraintModeName) = 0;
virtual void enableAuto() = 0;
virtual void disableAuto() = 0;
virtual void enableAutoExposure() = 0;
virtual void disableAutoExposure() = 0;
virtual bool autoExposureEnabled() const = 0;
virtual void enableAutoGain() = 0;
virtual void disableAutoGain() = 0;
virtual bool autoGainEnabled() const = 0;
virtual void setActiveChannels(const std::vector<unsigned int> &activeChannels) = 0;
};
+46 -6
View File
@@ -74,22 +74,62 @@ int Agc::checkChannel(unsigned int channelIndex) const
return 0;
}
void Agc::disableAuto()
void Agc::disableAutoExposure()
{
LOG(RPiAgc, Debug) << "disableAuto";
LOG(RPiAgc, Debug) << "disableAutoExposure";
/* All channels are enabled/disabled together. */
for (auto &data : channelData_)
data.channel.disableAuto();
data.channel.disableAutoExposure();
}
void Agc::enableAuto()
void Agc::enableAutoExposure()
{
LOG(RPiAgc, Debug) << "enableAuto";
LOG(RPiAgc, Debug) << "enableAutoExposure";
/* All channels are enabled/disabled together. */
for (auto &data : channelData_)
data.channel.enableAuto();
data.channel.enableAutoExposure();
}
bool Agc::autoExposureEnabled() const
{
LOG(RPiAgc, Debug) << "autoExposureEnabled";
/*
* We always have at least one channel, and since all channels are
* enabled and disabled together we can simply check the first one.
*/
return channelData_[0].channel.autoExposureEnabled();
}
void Agc::disableAutoGain()
{
LOG(RPiAgc, Debug) << "disableAutoGain";
/* All channels are enabled/disabled together. */
for (auto &data : channelData_)
data.channel.disableAutoGain();
}
void Agc::enableAutoGain()
{
LOG(RPiAgc, Debug) << "enableAutoGain";
/* All channels are enabled/disabled together. */
for (auto &data : channelData_)
data.channel.enableAutoGain();
}
bool Agc::autoGainEnabled() const
{
LOG(RPiAgc, Debug) << "autoGainEnabled";
/*
* We always have at least one channel, and since all channels are
* enabled and disabled together we can simply check the first one.
*/
return channelData_[0].channel.autoGainEnabled();
}
unsigned int Agc::getConvergenceFrames() const
+6 -2
View File
@@ -40,8 +40,12 @@ public:
void setMeteringMode(std::string const &meteringModeName) override;
void setExposureMode(std::string const &exposureModeName) override;
void setConstraintMode(std::string const &contraintModeName) override;
void enableAuto() override;
void disableAuto() override;
void enableAutoExposure() override;
void disableAutoExposure() override;
bool autoExposureEnabled() const override;
void enableAutoGain() override;
void disableAutoGain() override;
bool autoGainEnabled() const override;
void switchMode(CameraMode const &cameraMode, Metadata *metadata) override;
void prepare(Metadata *imageMetadata) override;
void process(StatisticsPtr &stats, Metadata *imageMetadata) override;
+21 -3
View File
@@ -319,18 +319,36 @@ int AgcChannel::read(const libcamera::YamlObject &params,
return 0;
}
void AgcChannel::disableAuto()
void AgcChannel::disableAutoExposure()
{
fixedExposureTime_ = status_.exposureTime;
}
void AgcChannel::enableAutoExposure()
{
fixedExposureTime_ = 0s;
}
bool AgcChannel::autoExposureEnabled() const
{
return fixedExposureTime_ == 0s;
}
void AgcChannel::disableAutoGain()
{
fixedAnalogueGain_ = status_.analogueGain;
}
void AgcChannel::enableAuto()
void AgcChannel::enableAutoGain()
{
fixedExposureTime_ = 0s;
fixedAnalogueGain_ = 0;
}
bool AgcChannel::autoGainEnabled() const
{
return fixedAnalogueGain_ == 0;
}
unsigned int AgcChannel::getConvergenceFrames() const
{
/*
+6 -2
View File
@@ -96,8 +96,12 @@ public:
void setMeteringMode(std::string const &meteringModeName);
void setExposureMode(std::string const &exposureModeName);
void setConstraintMode(std::string const &contraintModeName);
void enableAuto();
void disableAuto();
void enableAutoExposure();
void disableAutoExposure();
bool autoExposureEnabled() const;
void enableAutoGain();
void disableAutoGain();
bool autoGainEnabled() const;
void switchMode(CameraMode const &cameraMode, Metadata *metadata);
void prepare(Metadata *imageMetadata);
void process(StatisticsPtr &stats, DeviceStatus const &deviceStatus, Metadata *imageMetadata,