ipa: raspberrypi: Add sensor temperature to DeviceStatus

Add an optional sensor_temperature field to the DeviceStatus structure. If a
temperature measurement is available for a frame, the value is returned out
through the SensorTemperature control in the Request metadata.

Additionally, provide the sensor temperature value from the std::ostream &operator<<
overload.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Naushir Patuck 2022-06-29 09:57:20 +01:00 committed by Kieran Bingham
parent 71fb654918
commit 2a321be376
4 changed files with 13 additions and 3 deletions

View file

@ -185,9 +185,9 @@ void CamHelper::parseEmbeddedData(Span<const uint8_t> buffer,
metadata.Merge(parsedMetadata); metadata.Merge(parsedMetadata);
/* /*
* Overwrite the exposure/gain values in the existing DeviceStatus with * Overwrite the exposure/gain, frame length and sensor temperature values
* values from the parsed embedded buffer. Fetch it first in case any * in the existing DeviceStatus with values from the parsed embedded buffer.
* other fields were set meaningfully. * Fetch it first in case any other fields were set meaningfully.
*/ */
DeviceStatus deviceStatus, parsedDeviceStatus; DeviceStatus deviceStatus, parsedDeviceStatus;
if (metadata.Get("device.status", deviceStatus) || if (metadata.Get("device.status", deviceStatus) ||
@ -199,6 +199,8 @@ void CamHelper::parseEmbeddedData(Span<const uint8_t> buffer,
deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed; deviceStatus.shutter_speed = parsedDeviceStatus.shutter_speed;
deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain; deviceStatus.analogue_gain = parsedDeviceStatus.analogue_gain;
deviceStatus.frame_length = parsedDeviceStatus.frame_length; deviceStatus.frame_length = parsedDeviceStatus.frame_length;
if (parsedDeviceStatus.sensor_temperature)
deviceStatus.sensor_temperature = parsedDeviceStatus.sensor_temperature;
LOG(IPARPI, Debug) << "Metadata updated - " << deviceStatus; LOG(IPARPI, Debug) << "Metadata updated - " << deviceStatus;

View file

@ -17,5 +17,8 @@ std::ostream &operator<<(std::ostream &out, const DeviceStatus &d)
<< " Lens: " << d.lens_position << " Lens: " << d.lens_position
<< " Flash: " << d.flash_intensity; << " Flash: " << d.flash_intensity;
if (d.sensor_temperature)
out << " Temperature: " << *d.sensor_temperature;
return out; return out;
} }

View file

@ -7,6 +7,7 @@
#pragma once #pragma once
#include <iostream> #include <iostream>
#include <optional>
#include <libcamera/base/utils.h> #include <libcamera/base/utils.h>
@ -36,4 +37,6 @@ struct DeviceStatus {
double aperture; double aperture;
/* proportional to brightness with 0 = no flash, 1 = maximum flash */ /* proportional to brightness with 0 = no flash, 1 = maximum flash */
double flash_intensity; double flash_intensity;
/* Sensor reported temperature value (in degrees) */
std::optional<double> sensor_temperature;
}; };

View file

@ -491,6 +491,8 @@ void IPARPi::reportMetadata()
libcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogue_gain); libcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogue_gain);
libcameraMetadata_.set(controls::FrameDuration, libcameraMetadata_.set(controls::FrameDuration,
helper_->Exposure(deviceStatus->frame_length).get<std::micro>()); helper_->Exposure(deviceStatus->frame_length).get<std::micro>());
if (deviceStatus->sensor_temperature)
libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensor_temperature);
} }
AgcStatus *agcStatus = rpiMetadata_.GetLocked<AgcStatus>("agc.status"); AgcStatus *agcStatus = rpiMetadata_.GetLocked<AgcStatus>("agc.status");