@@ -15,13 +15,22 @@ namespace RPiController {
class AgcAlgorithm : public Algorithm
{
public:
+ struct SensorLimits {
+ libcamera::utils::Duration minShutter;
+ libcamera::utils::Duration maxShutter;
+ libcamera::utils::Duration minFrameDuration;
+ libcamera::utils::Duration maxFrameDuration;
+ double minAnalogueGain;
+ double maxAnalogueGain;
+ };
+
AgcAlgorithm(Controller *controller) : Algorithm(controller) {}
/* An AGC algorithm must provide the following: */
virtual unsigned int getConvergenceFrames() const = 0;
virtual void setEv(double ev) = 0;
virtual void setFlickerPeriod(libcamera::utils::Duration flickerPeriod) = 0;
virtual void setFixedShutter(libcamera::utils::Duration fixedShutter) = 0;
- virtual void setMaxShutter(libcamera::utils::Duration maxShutter) = 0;
+ virtual void setSensorLimits(const SensorLimits &limits) = 0;
virtual void setFixedAnalogueGain(double fixedAnalogueGain) = 0;
virtual void setMeteringMode(std::string const &meteringModeName) = 0;
virtual void setExposureMode(std::string const &exposureModeName) = 0;
@@ -225,7 +225,7 @@ Agc::Agc(Controller *controller)
frameCount_(0), lockCount_(0),
lastTargetExposure_(0s), lastSensitivity_(0.0),
ev_(1.0), flickerPeriod_(0s),
- maxShutter_(0s), fixedShutter_(0s), fixedAnalogueGain_(0.0)
+ fixedShutter_(0s), fixedAnalogueGain_(0.0)
{
memset(&awb_, 0, sizeof(awb_));
/*
@@ -300,9 +300,9 @@ void Agc::setFlickerPeriod(Duration flickerPeriod)
flickerPeriod_ = flickerPeriod;
}
-void Agc::setMaxShutter(Duration maxShutter)
+void Agc::setSensorLimits(const SensorLimits &limits)
{
- maxShutter_ = maxShutter;
+ sensorLimits_ = limits;
}
void Agc::setFixedShutter(Duration fixedShutter)
@@ -874,8 +874,8 @@ void Agc::writeAndFinish(Metadata *imageMetadata, bool desaturate)
Duration Agc::clipShutter(Duration shutter)
{
- if (maxShutter_)
- shutter = std::min(shutter, maxShutter_);
+ if (sensorLimits_.maxShutter)
+ shutter = std::min(shutter, sensorLimits_.maxShutter);
return shutter;
}
@@ -78,7 +78,7 @@ public:
unsigned int getConvergenceFrames() const override;
void setEv(double ev) override;
void setFlickerPeriod(libcamera::utils::Duration flickerPeriod) override;
- void setMaxShutter(libcamera::utils::Duration maxShutter) override;
+ void setSensorLimits(const SensorLimits &limits) override;
void setFixedShutter(libcamera::utils::Duration fixedShutter) override;
void setFixedAnalogueGain(double fixedAnalogueGain) override;
void setMeteringMode(std::string const &meteringModeName) override;
@@ -131,7 +131,7 @@ private:
std::string constraintModeName_;
double ev_;
libcamera::utils::Duration flickerPeriod_;
- libcamera::utils::Duration maxShutter_;
+ SensorLimits sensorLimits_;
libcamera::utils::Duration fixedShutter_;
double fixedAnalogueGain_;
};
@@ -1505,12 +1505,13 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur
* getBlanking() will update maxShutter with the largest exposure
* value possible.
*/
- Duration maxShutter = Duration::max();
- helper_->getBlanking(maxShutter, minFrameDuration_, maxFrameDuration_);
+ RPiController::AgcAlgorithm::SensorLimits limits;
+ limits.maxShutter = Duration::max();
+ helper_->getBlanking(limits.maxShutter, minFrameDuration_, maxFrameDuration_);
RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(
controller_.getAlgorithm("agc"));
- agc->setMaxShutter(maxShutter);
+ agc->setSensorLimits(limits);
}
void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)