@@ -28,8 +28,9 @@ namespace RPi {
* unsupported control is encountered.
*/
static const ControlInfoMap Controls({
- { &controls::AeEnable, ControlInfo(false, true) },
+ { &controls::ExposureTimeMode, ControlInfo(controls::ExposureTimeModeValues) },
{ &controls::ExposureTime, ControlInfo(0, 999999) },
+ { &controls::AnalogueGainMode, ControlInfo(controls::AnalogueGainModeValues) },
{ &controls::AnalogueGain, ControlInfo(1.0f, 32.0f) },
{ &controls::AeMeteringMode, ControlInfo(controls::AeMeteringModeValues) },
{ &controls::AeConstraintMode, ControlInfo(controls::AeConstraintModeValues) },
@@ -27,6 +27,10 @@ public:
virtual void SetExposureMode(std::string const &exposure_mode_name) = 0;
virtual void
SetConstraintMode(std::string const &contraint_mode_name) = 0;
+ virtual void PauseShutter();
+ virtual void PauseGain();
+ virtual void ResumeShutter();
+ virtual void ResumeGain();
};
} // namespace RPiController
@@ -210,14 +210,34 @@ bool Agc::IsPaused() const
}
void Agc::Pause()
+{
+ PauseShutter();
+ PauseGain();
+}
+
+void Agc::Resume()
+{
+ ResumeShutter();
+ ResumeGain();
+}
+
+void Agc::PauseShutter()
{
fixed_shutter_ = status_.shutter_time;
+}
+
+void Agc::PauseGain()
+{
fixed_analogue_gain_ = status_.analogue_gain;
}
-void Agc::Resume()
+void Agc::ResumeShutter()
{
fixed_shutter_ = 0s;
+}
+
+void Agc::ResumeGain()
+{
fixed_analogue_gain_ = 0;
}
@@ -90,6 +90,11 @@ public:
void Prepare(Metadata *image_metadata) override;
void Process(StatisticsPtr &stats, Metadata *image_metadata) override;
+ void PauseShutter() override;
+ void PauseGain() override;
+ void ResumeShutter() override;
+ void ResumeGain() override;
+
private:
void updateLockStatus(DeviceStatus const &device_status);
AgcConfig config_;
@@ -53,6 +53,8 @@
#include "sharpen_algorithm.hpp"
#include "sharpen_status.h"
+#include "controller/rpi/agc.hpp"
+
namespace libcamera {
using namespace std::literals::chrono_literals;
@@ -483,7 +485,10 @@ void IPARPi::reportMetadata()
AgcStatus *agcStatus = rpiMetadata_.GetLocked<AgcStatus>("agc.status");
if (agcStatus) {
- libcameraMetadata_.set(controls::AeLocked, agcStatus->locked);
+ libcameraMetadata_.set(controls::AeState,
+ agcStatus->locked ?
+ controls::AeStateConverged :
+ controls::AeStateSearching);
libcameraMetadata_.set(controls::DigitalGain, agcStatus->digital_gain);
}
@@ -628,20 +633,22 @@ void IPARPi::queueRequest(const ControlList &controls)
<< " = " << ctrl.second.toString();
switch (ctrl.first) {
- case controls::AE_ENABLE: {
- RPiController::Algorithm *agc = controller_.GetAlgorithm("agc");
+ case controls::EXPOSURE_TIME_MODE: {
+ RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(
+ controller_.GetAlgorithm("agc"));
if (!agc) {
LOG(IPARPI, Warning)
- << "Could not set AE_ENABLE - no AGC algorithm";
+ << "Could not set EXPOSURE_TIME_MODE - no AGC algorithm";
break;
}
- if (ctrl.second.get<bool>() == false)
- agc->Pause();
+ if (ctrl.second.get<int32_t>() == controls::ExposureTimeModeDisabled)
+ agc->PauseShutter();
else
- agc->Resume();
+ agc->ResumeShutter();
- libcameraMetadata_.set(controls::AeEnable, ctrl.second.get<bool>());
+ libcameraMetadata_.set(controls::ExposureTimeMode,
+ ctrl.second.get<int32_t>());
break;
}
@@ -661,6 +668,25 @@ void IPARPi::queueRequest(const ControlList &controls)
break;
}
+ case controls::ANALOGUE_GAIN_MODE: {
+ RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(
+ controller_.GetAlgorithm("agc"));
+ if (!agc) {
+ LOG(IPARPI, Warning)
+ << "Could not set ANALOGUE_GAIN_MODE - no AGC algorithm";
+ break;
+ }
+
+ if (ctrl.second.get<int32_t>() == controls::AnalogueGainModeDisabled)
+ agc->PauseGain();
+ else
+ agc->ResumeGain();
+
+ libcameraMetadata_.set(controls::AnalogueGainMode,
+ ctrl.second.get<int32_t>());
+ break;
+ }
+
case controls::ANALOGUE_GAIN: {
RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(
controller_.GetAlgorithm("agc"));
Add support for the new AE controls in the raspberrypi pipeline handler, and in the IPA. Bug: https://bugs.libcamera.org/show_bug.cgi?id=42 Bug: https://bugs.libcamera.org/show_bug.cgi?id=43 Signed-off-by: Paul Elder <paul.elder@ideasonboard.com> --- Changes in v3: - s/Exposure/Shutter/ - move the new Pause/Resume functions to AgcAlgorithm - update callers as appropriate - make the original Pause/Resume functions call the new ones Changes in v2: - fix the rebase error where some uvc stuff was in rasberrypi - i haven't yet taken in the comments to move the new Pause/Resume functions Initial versoin: This is very hacky. I wasn't sure what the best way was to plumb it into the raspberrypi IPA as it was a bit hairy... --- include/libcamera/ipa/raspberrypi.h | 3 +- .../raspberrypi/controller/agc_algorithm.hpp | 4 ++ src/ipa/raspberrypi/controller/rpi/agc.cpp | 22 +++++++++- src/ipa/raspberrypi/controller/rpi/agc.hpp | 5 +++ src/ipa/raspberrypi/raspberrypi.cpp | 42 +++++++++++++++---- 5 files changed, 66 insertions(+), 10 deletions(-)