summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/controller
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2023-03-27 13:20:22 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2023-03-31 13:29:18 +0100
commitf6cc78b446de8dc03251aa5aab094852bca77285 (patch)
treeb0170e2ed5d6cbecc62fa5eae9c41e7ca7a8fd09 /src/ipa/raspberrypi/controller
parentcf6df17958f8af629410038d96e18b36df0ae6e7 (diff)
ipa: raspberrypi: Add hardware configuration to the controller
Add a new Controller::HardwareConfig structure that captures the hardware statistics grid/histogram sizes and pipeline widths. This ensures there is a single centralised places for these parameters. Add a getHardwareConfig() helper function to retrieve these values for a given hardware target. Update the statistics populating routine in the IPA to use the values from this structure instead of the hardcoded numbers. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/controller')
-rw-r--r--src/ipa/raspberrypi/controller/algorithm.h4
-rw-r--r--src/ipa/raspberrypi/controller/controller.cpp31
-rw-r--r--src/ipa/raspberrypi/controller/controller.h11
3 files changed, 46 insertions, 0 deletions
diff --git a/src/ipa/raspberrypi/controller/algorithm.h b/src/ipa/raspberrypi/controller/algorithm.h
index 7c22fbe4..4aa814eb 100644
--- a/src/ipa/raspberrypi/controller/algorithm.h
+++ b/src/ipa/raspberrypi/controller/algorithm.h
@@ -45,6 +45,10 @@ public:
{
return controller_->getTarget();
}
+ const Controller::HardwareConfig &getHardwareConfig() const
+ {
+ return controller_->getHardwareConfig();
+ }
private:
Controller *controller_;
diff --git a/src/ipa/raspberrypi/controller/controller.cpp b/src/ipa/raspberrypi/controller/controller.cpp
index a6250ee1..fa172113 100644
--- a/src/ipa/raspberrypi/controller/controller.cpp
+++ b/src/ipa/raspberrypi/controller/controller.cpp
@@ -20,6 +20,25 @@ using namespace libcamera;
LOG_DEFINE_CATEGORY(RPiController)
+static const std::map<std::string, Controller::HardwareConfig> HardwareConfigMap = {
+ {
+ "bcm2835",
+ {
+ /*
+ * There are only ever 15 AGC regions computed by the firmware
+ * due to zoning, but the HW defines AGC_REGIONS == 16!
+ */
+ .agcRegions = { 15 , 1 },
+ .agcZoneWeights = { 15 , 1 },
+ .awbRegions = { 16, 12 },
+ .focusRegions = { 4, 3 },
+ .numHistogramBins = 128,
+ .numGammaPoints = 33,
+ .pipelineWidth = 13
+ }
+ },
+};
+
Controller::Controller()
: switchModeCalled_(false)
{
@@ -148,3 +167,15 @@ const std::string &Controller::getTarget() const
{
return target_;
}
+
+const Controller::HardwareConfig &Controller::getHardwareConfig() const
+{
+ auto cfg = HardwareConfigMap.find(getTarget());
+
+ /*
+ * This really should not happen, the IPA ought to validate the target
+ * on initialisation.
+ */
+ ASSERT(cfg != HardwareConfigMap.end());
+ return cfg->second;
+}
diff --git a/src/ipa/raspberrypi/controller/controller.h b/src/ipa/raspberrypi/controller/controller.h
index 24e02903..c6af5cd6 100644
--- a/src/ipa/raspberrypi/controller/controller.h
+++ b/src/ipa/raspberrypi/controller/controller.h
@@ -37,6 +37,16 @@ typedef std::unique_ptr<Algorithm> AlgorithmPtr;
class Controller
{
public:
+ struct HardwareConfig {
+ libcamera::Size agcRegions;
+ libcamera::Size agcZoneWeights;
+ libcamera::Size awbRegions;
+ libcamera::Size focusRegions;
+ unsigned int numHistogramBins;
+ unsigned int numGammaPoints;
+ unsigned int pipelineWidth;
+ };
+
Controller();
~Controller();
int read(char const *filename);
@@ -47,6 +57,7 @@ public:
Metadata &getGlobalMetadata();
Algorithm *getAlgorithm(std::string const &name) const;
const std::string &getTarget() const;
+ const HardwareConfig &getHardwareConfig() const;
protected:
int createAlgorithm(const std::string &name, const libcamera::YamlObject &params);