summaryrefslogtreecommitdiff
path: root/src/ipa/raspberrypi/cam_helper.cpp
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2021-06-29 11:45:00 +0100
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-06-30 23:16:18 +0300
commit579f55b1086db0d7df1608ad24513a673818f408 (patch)
treecda9f085220bd961ed8c36fd70e891860566d192 /src/ipa/raspberrypi/cam_helper.cpp
parentd3ea8e78852ba91245fdb9069363c1149e99c3b0 (diff)
ipa: raspberrypi: Generalise the SMIA metadata parser
Instead of having each CamHelper subclass the MdParserSmia, change the implementation of MdParserSmia to be more generic. The MdParserSmia now gets given a list of registers to search for and helper functions are used to compute exposure lines and gain codes from these registers. Update the imx219 and imx477 CamHelpers by using this new mechanism. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src/ipa/raspberrypi/cam_helper.cpp')
-rw-r--r--src/ipa/raspberrypi/cam_helper.cpp33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/ipa/raspberrypi/cam_helper.cpp b/src/ipa/raspberrypi/cam_helper.cpp
index 90498c37..e6d2258c 100644
--- a/src/ipa/raspberrypi/cam_helper.cpp
+++ b/src/ipa/raspberrypi/cam_helper.cpp
@@ -159,32 +159,34 @@ unsigned int CamHelper::MistrustFramesModeSwitch() const
void CamHelper::parseEmbeddedData(Span<const uint8_t> buffer,
Metadata &metadata)
{
+ MdParser::RegisterMap registers;
+ Metadata parsedMetadata;
+
if (buffer.empty())
return;
- uint32_t exposureLines, gainCode;
-
- if (parser_->Parse(buffer) != MdParser::Status::OK ||
- parser_->GetExposureLines(exposureLines) != MdParser::Status::OK ||
- parser_->GetGainCode(gainCode) != MdParser::Status::OK) {
+ if (parser_->Parse(buffer, registers) != MdParser::Status::OK) {
LOG(IPARPI, Error) << "Embedded data buffer parsing failed";
return;
}
+ PopulateMetadata(registers, parsedMetadata);
+ metadata.Merge(parsedMetadata);
+
/*
- * Overwrite the exposure/gain values in the DeviceStatus, as
- * we know better. Fetch it first in case any other fields were
- * set meaningfully.
+ * Overwrite the exposure/gain values in the existing DeviceStatus with
+ * values from the parsed embedded buffer. Fetch it first in case any
+ * other fields were set meaningfully.
*/
- DeviceStatus deviceStatus;
-
- if (metadata.Get("device.status", deviceStatus) != 0) {
+ DeviceStatus deviceStatus, parsedDeviceStatus;
+ if (metadata.Get("device.status", deviceStatus) ||
+ parsedMetadata.Get("device.status", parsedDeviceStatus)) {
LOG(IPARPI, Error) << "DeviceStatus not found";
return;
}
- deviceStatus.shutter_speed = Exposure(exposureLines);
- deviceStatus.analogue_gain = Gain(gainCode);
+ deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed;
+ deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain;
LOG(IPARPI, Debug) << "Metadata updated - Exposure : "
<< deviceStatus.shutter_speed
@@ -194,6 +196,11 @@ void CamHelper::parseEmbeddedData(Span<const uint8_t> buffer,
metadata.Set("device.status", deviceStatus);
}
+void CamHelper::PopulateMetadata([[maybe_unused]] const MdParser::RegisterMap &registers,
+ [[maybe_unused]] Metadata &metadata) const
+{
+}
+
RegisterCamHelper::RegisterCamHelper(char const *cam_name,
CamHelperCreateFunc create_func)
{