summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller/rpi/agc.h
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2023-05-03 13:20:27 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2023-05-04 20:47:40 +0300
commit726e9274ea95fa46352556d340c5793a8da51fcd (patch)
tree80f6adcdbf744f9317e09eff3e80c602b384a753 /src/ipa/raspberrypi/controller/rpi/agc.h
parent46aefed208fef4bc8d6f6e8882b92b9af710a60b (diff)
pipeline: ipa: raspberrypi: Refactor and move the Raspberry Pi code
Split the Raspberry Pi pipeline handler and IPA source code into common and VC4/BCM2835 specific file structures. For the pipeline handler, the common code files now live in src/libcamera/pipeline/rpi/common/ and the VC4-specific files in src/libcamera/pipeline/rpi/vc4/. For the IPA, the common code files now live in src/ipa/rpi/{cam_helper,controller}/ and the vc4 specific files in src/ipa/rpi/vc4/. With this change, the camera tuning files are now installed under share/libcamera/ipa/rpi/vc4/. To build the pipeline and IPA, the meson configuration options have now changed from "raspberrypi" to "rpi/vc4": meson setup build -Dipas=rpi/vc4 -Dpipelines=rpi/vc4 Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller/rpi/agc.h')
-rw-r--r--src/ipa/raspberrypi/controller/rpi/agc.h133
1 files changed, 0 insertions, 133 deletions
diff --git a/src/ipa/raspberrypi/controller/rpi/agc.h b/src/ipa/raspberrypi/controller/rpi/agc.h
deleted file mode 100644
index 4e5f272f..00000000
--- a/src/ipa/raspberrypi/controller/rpi/agc.h
+++ /dev/null
@@ -1,133 +0,0 @@
-/* SPDX-License-Identifier: BSD-2-Clause */
-/*
- * Copyright (C) 2019, Raspberry Pi Ltd
- *
- * agc.h - AGC/AEC control algorithm
- */
-#pragma once
-
-#include <vector>
-#include <mutex>
-
-#include <libcamera/base/utils.h>
-
-#include "../agc_algorithm.h"
-#include "../agc_status.h"
-#include "../pwl.h"
-
-/* This is our implementation of AGC. */
-
-namespace RPiController {
-
-struct AgcMeteringMode {
- std::vector<double> weights;
- int read(const libcamera::YamlObject &params);
-};
-
-struct AgcExposureMode {
- std::vector<libcamera::utils::Duration> shutter;
- std::vector<double> gain;
- int read(const libcamera::YamlObject &params);
-};
-
-struct AgcConstraint {
- enum class Bound { LOWER = 0, UPPER = 1 };
- Bound bound;
- double qLo;
- double qHi;
- Pwl yTarget;
- int read(const libcamera::YamlObject &params);
-};
-
-typedef std::vector<AgcConstraint> AgcConstraintMode;
-
-struct AgcConfig {
- int read(const libcamera::YamlObject &params);
- std::map<std::string, AgcMeteringMode> meteringModes;
- std::map<std::string, AgcExposureMode> exposureModes;
- std::map<std::string, AgcConstraintMode> constraintModes;
- Pwl yTarget;
- double speed;
- uint16_t startupFrames;
- unsigned int convergenceFrames;
- double maxChange;
- double minChange;
- double fastReduceThreshold;
- double speedUpThreshold;
- std::string defaultMeteringMode;
- std::string defaultExposureMode;
- std::string defaultConstraintMode;
- double baseEv;
- libcamera::utils::Duration defaultExposureTime;
- double defaultAnalogueGain;
-};
-
-class Agc : public AgcAlgorithm
-{
-public:
- Agc(Controller *controller);
- char const *name() const override;
- int read(const libcamera::YamlObject &params) override;
- 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 setFixedShutter(libcamera::utils::Duration fixedShutter) override;
- void setFixedAnalogueGain(double fixedAnalogueGain) override;
- 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 switchMode(CameraMode const &cameraMode, Metadata *metadata) override;
- void prepare(Metadata *imageMetadata) override;
- void process(StatisticsPtr &stats, Metadata *imageMetadata) override;
-
-private:
- void updateLockStatus(DeviceStatus const &deviceStatus);
- AgcConfig config_;
- void housekeepConfig();
- void fetchCurrentExposure(Metadata *imageMetadata);
- void fetchAwbStatus(Metadata *imageMetadata);
- void computeGain(StatisticsPtr &statistics, Metadata *imageMetadata,
- double &gain, double &targetY);
- void computeTargetExposure(double gain);
- bool applyDigitalGain(double gain, double targetY);
- void filterExposure(bool desaturate);
- void divideUpExposure();
- void writeAndFinish(Metadata *imageMetadata, bool desaturate);
- libcamera::utils::Duration limitShutter(libcamera::utils::Duration shutter);
- double limitGain(double gain) const;
- AgcMeteringMode *meteringMode_;
- AgcExposureMode *exposureMode_;
- AgcConstraintMode *constraintMode_;
- CameraMode mode_;
- uint64_t frameCount_;
- AwbStatus awb_;
- struct ExposureValues {
- ExposureValues();
-
- libcamera::utils::Duration shutter;
- double analogueGain;
- libcamera::utils::Duration totalExposure;
- libcamera::utils::Duration totalExposureNoDG; /* without digital gain */
- };
- ExposureValues current_; /* values for the current frame */
- ExposureValues target_; /* calculate the values we want here */
- ExposureValues filtered_; /* these values are filtered towards target */
- AgcStatus status_;
- int lockCount_;
- DeviceStatus lastDeviceStatus_;
- libcamera::utils::Duration lastTargetExposure_;
- /* Below here the "settings" that applications can change. */
- std::string meteringModeName_;
- std::string exposureModeName_;
- std::string constraintModeName_;
- double ev_;
- libcamera::utils::Duration flickerPeriod_;
- libcamera::utils::Duration maxShutter_;
- libcamera::utils::Duration fixedShutter_;
- double fixedAnalogueGain_;
-};
-
-} /* namespace RPiController */