ipa: raspberrypi: Add a constructor struct DeviceStatus

The constructor sets all fields to 0. This replaces the memset(0) and default
value initialisation usage in the agc and lux controllers respectively.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Reviewed-by: David Plowman <david.plowman@raspberrypi.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Naushir Patuck 2021-07-12 11:02:03 +01:00 committed by Laurent Pinchart
parent ace5e21feb
commit df8cafaf87
4 changed files with 8 additions and 10 deletions

View file

@ -14,6 +14,12 @@
*/ */
struct DeviceStatus { struct DeviceStatus {
DeviceStatus()
: shutter_speed(std::chrono::seconds(0)), analogue_gain(0.0),
lens_position(0.0), aperture(0.0), flash_intensity(0.0)
{
}
/* time shutter is open */ /* time shutter is open */
libcamera::utils::Duration shutter_speed; libcamera::utils::Duration shutter_speed;
double analogue_gain; double analogue_gain;

View file

@ -172,7 +172,6 @@ Agc::Agc(Controller *controller)
// it's not been calculated yet (i.e. Process hasn't yet run). // it's not been calculated yet (i.e. Process hasn't yet run).
memset(&status_, 0, sizeof(status_)); memset(&status_, 0, sizeof(status_));
status_.ev = ev_; status_.ev = ev_;
memset(&last_device_status_, 0, sizeof(last_device_status_));
} }
char const *Agc::Name() const char const *Agc::Name() const

View file

@ -49,7 +49,7 @@ void Geq::Prepare(Metadata *image_metadata)
lux_status.lux = 400; lux_status.lux = 400;
if (image_metadata->Get("lux.status", lux_status)) if (image_metadata->Get("lux.status", lux_status))
LOG(RPiGeq, Warning) << "no lux data found"; LOG(RPiGeq, Warning) << "no lux data found";
DeviceStatus device_status = {}; DeviceStatus device_status;
device_status.analogue_gain = 1.0; // in case not found device_status.analogue_gain = 1.0; // in case not found
if (image_metadata->Get("device.status", device_status)) if (image_metadata->Get("device.status", device_status))
LOG(RPiGeq, Warning) LOG(RPiGeq, Warning)

View file

@ -60,14 +60,7 @@ void Lux::Prepare(Metadata *image_metadata)
void Lux::Process(StatisticsPtr &stats, Metadata *image_metadata) void Lux::Process(StatisticsPtr &stats, Metadata *image_metadata)
{ {
// set some initial values to shut the compiler up DeviceStatus device_status;
DeviceStatus device_status = {
.shutter_speed = 1.0ms,
.analogue_gain = 1.0,
.lens_position = 0.0,
.aperture = 0.0,
.flash_intensity = 0.0
};
if (image_metadata->Get("device.status", device_status) == 0) { if (image_metadata->Get("device.status", device_status) == 0) {
double current_gain = device_status.analogue_gain; double current_gain = device_status.analogue_gain;
double current_aperture = device_status.aperture; double current_aperture = device_status.aperture;