ipa: rpi: agc: Use std::string instead of char arrays
Replace the char array strings in struct AgcStatus with std::string objects. This simplifies the string handling in the source code. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
c6ff999053
commit
5242b78c0b
2 changed files with 12 additions and 19 deletions
|
@ -6,6 +6,8 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <libcamera/base/utils.h>
|
#include <libcamera/base/utils.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -24,9 +26,9 @@ struct AgcStatus {
|
||||||
libcamera::utils::Duration targetExposureValue; /* (unfiltered) target total exposure AGC is aiming for */
|
libcamera::utils::Duration targetExposureValue; /* (unfiltered) target total exposure AGC is aiming for */
|
||||||
libcamera::utils::Duration shutterTime;
|
libcamera::utils::Duration shutterTime;
|
||||||
double analogueGain;
|
double analogueGain;
|
||||||
char exposureMode[32];
|
std::string exposureMode;
|
||||||
char constraintMode[32];
|
std::string constraintMode;
|
||||||
char meteringMode[32];
|
std::string meteringMode;
|
||||||
double ev;
|
double ev;
|
||||||
libcamera::utils::Duration flickerPeriod;
|
libcamera::utils::Duration flickerPeriod;
|
||||||
int floatingRegionEnable;
|
int floatingRegionEnable;
|
||||||
|
|
|
@ -226,7 +226,7 @@ Agc::Agc(Controller *controller)
|
||||||
* Setting status_.totalExposureValue_ to zero initially tells us
|
* Setting status_.totalExposureValue_ to zero initially tells us
|
||||||
* 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_));
|
status_ = {};
|
||||||
status_.ev = ev_;
|
status_.ev = ev_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,12 +524,6 @@ void Agc::updateLockStatus(DeviceStatus const &deviceStatus)
|
||||||
status_.locked = lockCount_ == maxLockCount;
|
status_.locked = lockCount_ == maxLockCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copyString(std::string const &s, char *d, size_t size)
|
|
||||||
{
|
|
||||||
size_t length = s.copy(d, size - 1);
|
|
||||||
d[length] = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
void Agc::housekeepConfig()
|
void Agc::housekeepConfig()
|
||||||
{
|
{
|
||||||
/* First fetch all the up-to-date settings, so no one else has to do it. */
|
/* First fetch all the up-to-date settings, so no one else has to do it. */
|
||||||
|
@ -544,30 +538,27 @@ void Agc::housekeepConfig()
|
||||||
* Make sure the "mode" pointers point to the up-to-date things, if
|
* Make sure the "mode" pointers point to the up-to-date things, if
|
||||||
* they've changed.
|
* they've changed.
|
||||||
*/
|
*/
|
||||||
if (strcmp(meteringModeName_.c_str(), status_.meteringMode)) {
|
if (meteringModeName_ != status_.meteringMode) {
|
||||||
auto it = config_.meteringModes.find(meteringModeName_);
|
auto it = config_.meteringModes.find(meteringModeName_);
|
||||||
if (it == config_.meteringModes.end())
|
if (it == config_.meteringModes.end())
|
||||||
LOG(RPiAgc, Fatal) << "No metering mode " << meteringModeName_;
|
LOG(RPiAgc, Fatal) << "No metering mode " << meteringModeName_;
|
||||||
meteringMode_ = &it->second;
|
meteringMode_ = &it->second;
|
||||||
copyString(meteringModeName_, status_.meteringMode,
|
status_.meteringMode = meteringModeName_;
|
||||||
sizeof(status_.meteringMode));
|
|
||||||
}
|
}
|
||||||
if (strcmp(exposureModeName_.c_str(), status_.exposureMode)) {
|
if (exposureModeName_ != status_.exposureMode) {
|
||||||
auto it = config_.exposureModes.find(exposureModeName_);
|
auto it = config_.exposureModes.find(exposureModeName_);
|
||||||
if (it == config_.exposureModes.end())
|
if (it == config_.exposureModes.end())
|
||||||
LOG(RPiAgc, Fatal) << "No exposure profile " << exposureModeName_;
|
LOG(RPiAgc, Fatal) << "No exposure profile " << exposureModeName_;
|
||||||
exposureMode_ = &it->second;
|
exposureMode_ = &it->second;
|
||||||
copyString(exposureModeName_, status_.exposureMode,
|
status_.exposureMode = exposureModeName_;
|
||||||
sizeof(status_.exposureMode));
|
|
||||||
}
|
}
|
||||||
if (strcmp(constraintModeName_.c_str(), status_.constraintMode)) {
|
if (constraintModeName_ != status_.constraintMode) {
|
||||||
auto it =
|
auto it =
|
||||||
config_.constraintModes.find(constraintModeName_);
|
config_.constraintModes.find(constraintModeName_);
|
||||||
if (it == config_.constraintModes.end())
|
if (it == config_.constraintModes.end())
|
||||||
LOG(RPiAgc, Fatal) << "No constraint list " << constraintModeName_;
|
LOG(RPiAgc, Fatal) << "No constraint list " << constraintModeName_;
|
||||||
constraintMode_ = &it->second;
|
constraintMode_ = &it->second;
|
||||||
copyString(constraintModeName_, status_.constraintMode,
|
status_.constraintMode = constraintModeName_;
|
||||||
sizeof(status_.constraintMode));
|
|
||||||
}
|
}
|
||||||
LOG(RPiAgc, Debug) << "exposureMode "
|
LOG(RPiAgc, Debug) << "exposureMode "
|
||||||
<< exposureModeName_ << " constraintMode "
|
<< exposureModeName_ << " constraintMode "
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue