Message ID | 20220725134639.4572-2-naush@raspberrypi.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Naush, Thank you for the patch. On Mon, Jul 25, 2022 at 02:46:25PM +0100, Naushir Patuck via libcamera-devel wrote: > Refactor the source files in src/ipa/raspberrypi/ to match the > recommended formatting guidelines for the libcamera project. The vast majority > of changes in this commit comprise of switching from snake_case to CamelCase, > and starting class member functions with a lower case character. > > Signed-off-by: Naushir Patuck <naush@raspberrypi.com> > --- > .../controller/sharpen_algorithm.hpp | 2 +- > .../raspberrypi/controller/sharpen_status.h | 2 +- > src/ipa/raspberrypi/md_parser.hpp | 34 +-- > src/ipa/raspberrypi/md_parser_smia.cpp | 96 +++---- > src/ipa/raspberrypi/raspberrypi.cpp | 254 +++++++++--------- > 5 files changed, 194 insertions(+), 194 deletions(-) > > diff --git a/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp b/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp > index ca800308fd6c..888f4569c56a 100644 > --- a/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp > +++ b/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp > @@ -15,7 +15,7 @@ class SharpenAlgorithm : public Algorithm > public: > SharpenAlgorithm(Controller *controller) : Algorithm(controller) {} > // A sharpness control algorithm must provide the following: > - virtual void SetStrength(double strength) = 0; > + virtual void setStrength(double strength) = 0; > }; > > } // namespace RPiController > diff --git a/src/ipa/raspberrypi/controller/sharpen_status.h b/src/ipa/raspberrypi/controller/sharpen_status.h > index 7501b191d6f6..2b0490742fba 100644 > --- a/src/ipa/raspberrypi/controller/sharpen_status.h > +++ b/src/ipa/raspberrypi/controller/sharpen_status.h > @@ -20,7 +20,7 @@ struct SharpenStatus { > // upper limit of the allowed sharpening response > double limit; > // The sharpening strength requested by the user or application. > - double user_strength; > + double userStrength; > }; > > #ifdef __cplusplus > diff --git a/src/ipa/raspberrypi/md_parser.hpp b/src/ipa/raspberrypi/md_parser.hpp > index d32d0f549b9c..e505108a7adc 100644 > --- a/src/ipa/raspberrypi/md_parser.hpp > +++ b/src/ipa/raspberrypi/md_parser.hpp > @@ -81,27 +81,27 @@ public: > > virtual ~MdParser() = default; > > - void Reset() > + void reset() > { > reset_ = true; > } > > - void SetBitsPerPixel(int bpp) > + void setBitsPerPixel(int bpp) > { > bits_per_pixel_ = bpp; I think this, and num_lines_ and line_length_bytes_ below, should also be updated. > } > > - void SetNumLines(unsigned int num_lines) > + void setNumLines(unsigned int numLines) > { > - num_lines_ = num_lines; > + num_lines_ = numLines; > } > > - void SetLineLengthBytes(unsigned int num_bytes) > + void setLineLengthBytes(unsigned int numBytes) > { > - line_length_bytes_ = num_bytes; > + line_length_bytes_ = numBytes; > } > > - virtual Status Parse(libcamera::Span<const uint8_t> buffer, > + virtual Status parse(libcamera::Span<const uint8_t> buffer, > RegisterMap ®isters) = 0; > > protected: > @@ -123,7 +123,7 @@ class MdParserSmia final : public MdParser > public: > MdParserSmia(std::initializer_list<uint32_t> registerList); > > - MdParser::Status Parse(libcamera::Span<const uint8_t> buffer, > + MdParser::Status parse(libcamera::Span<const uint8_t> buffer, > RegisterMap ®isters) override; > > private: > @@ -133,18 +133,18 @@ private: > /* > * Note that error codes > 0 are regarded as non-fatal; codes < 0 > * indicate a bad data buffer. Status codes are: > - * PARSE_OK - found all registers, much happiness > - * MISSING_REGS - some registers found; should this be a hard error? > + * ParseOk - found all registers, much happiness > + * MissingRegs - some registers found; should this be a hard error? > * The remaining codes are all hard errors. > */ > enum ParseStatus { > - PARSE_OK = 0, > - MISSING_REGS = 1, > - NO_LINE_START = -1, > - ILLEGAL_TAG = -2, > - BAD_DUMMY = -3, > - BAD_LINE_END = -4, > - BAD_PADDING = -5 > + ParseOk = 0, > + MissingRegs = 1, > + NoLineStart = -1, > + IllegalTag = -2, > + BadDummy = -3, > + BadLineEnd = -4, > + BadPadding = -5 > }; > > ParseStatus findRegs(libcamera::Span<const uint8_t> buffer); > diff --git a/src/ipa/raspberrypi/md_parser_smia.cpp b/src/ipa/raspberrypi/md_parser_smia.cpp > index ea5eac414b36..f2b37cab4e97 100644 > --- a/src/ipa/raspberrypi/md_parser_smia.cpp > +++ b/src/ipa/raspberrypi/md_parser_smia.cpp > @@ -20,12 +20,12 @@ using namespace libcamera; > * sensors, I think. > */ > > -constexpr unsigned int LINE_START = 0x0a; > -constexpr unsigned int LINE_END_TAG = 0x07; > -constexpr unsigned int REG_HI_BITS = 0xaa; > -constexpr unsigned int REG_LOW_BITS = 0xa5; > -constexpr unsigned int REG_VALUE = 0x5a; > -constexpr unsigned int REG_SKIP = 0x55; > +constexpr unsigned int LineStart = 0x0a; > +constexpr unsigned int LineEndTag = 0x07; > +constexpr unsigned int RegHiBits = 0xaa; > +constexpr unsigned int RegLowBits = 0xa5; > +constexpr unsigned int RegValue = 0x5a; > +constexpr unsigned int RegSkip = 0x55; We prefix constant names with k, so this would be kRegSkip. Same for the other ones. > > MdParserSmia::MdParserSmia(std::initializer_list<uint32_t> registerList) > { > @@ -33,7 +33,7 @@ MdParserSmia::MdParserSmia(std::initializer_list<uint32_t> registerList) > offsets_[r] = {}; > } > > -MdParser::Status MdParserSmia::Parse(libcamera::Span<const uint8_t> buffer, > +MdParser::Status MdParserSmia::parse(libcamera::Span<const uint8_t> buffer, > RegisterMap ®isters) > { > if (reset_) { > @@ -53,7 +53,7 @@ MdParser::Status MdParserSmia::Parse(libcamera::Span<const uint8_t> buffer, > * > * In either case, we retry parsing on the next frame. > */ > - if (ret != PARSE_OK) > + if (ret != ParseOk) > return ERROR; > > reset_ = false; > @@ -76,74 +76,74 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t> > { > ASSERT(offsets_.size()); > > - if (buffer[0] != LINE_START) > - return NO_LINE_START; > + if (buffer[0] != LineStart) > + return NoLineStart; > > - unsigned int current_offset = 1; /* after the LINE_START */ > - unsigned int current_line_start = 0, current_line = 0; > - unsigned int reg_num = 0, regs_done = 0; > + unsigned int currentOffset = 1; /* after the LINE_START */ s/LINE_START/LineStart/ in the comment ? > + unsigned int currentLineStart = 0, currentLine = 0; > + unsigned int regNum = 0, regsDone = 0; > > while (1) { > - int tag = buffer[current_offset++]; > + int tag = buffer[currentOffset++]; > > if ((bits_per_pixel_ == 10 && > - (current_offset + 1 - current_line_start) % 5 == 0) || > + (currentOffset + 1 - currentLineStart) % 5 == 0) || > (bits_per_pixel_ == 12 && > - (current_offset + 1 - current_line_start) % 3 == 0)) { > - if (buffer[current_offset++] != REG_SKIP) > - return BAD_DUMMY; > + (currentOffset + 1 - currentLineStart) % 3 == 0)) { > + if (buffer[currentOffset++] != RegSkip) > + return BadDummy; > } > > - int data_byte = buffer[current_offset++]; > + int dataByte = buffer[currentOffset++]; > > - if (tag == LINE_END_TAG) { > - if (data_byte != LINE_END_TAG) > - return BAD_LINE_END; > + if (tag == LineEndTag) { > + if (dataByte != LineEndTag) > + return BadLineEnd; > > - if (num_lines_ && ++current_line == num_lines_) > - return MISSING_REGS; > + if (num_lines_ && ++currentLine == num_lines_) > + return MissingRegs; > > if (line_length_bytes_) { > - current_offset = current_line_start + line_length_bytes_; > + currentOffset = currentLineStart + line_length_bytes_; > > /* Require whole line to be in the buffer (if buffer size set). */ > if (buffer.size() && > - current_offset + line_length_bytes_ > buffer.size()) > - return MISSING_REGS; > + currentOffset + line_length_bytes_ > buffer.size()) > + return MissingRegs; > > - if (buffer[current_offset] != LINE_START) > - return NO_LINE_START; > + if (buffer[currentOffset] != LineStart) > + return NoLineStart; > } else { > /* allow a zero line length to mean "hunt for the next line" */ > - while (current_offset < buffer.size() && > - buffer[current_offset] != LINE_START) > - current_offset++; > + while (currentOffset < buffer.size() && > + buffer[currentOffset] != LineStart) > + currentOffset++; > > - if (current_offset == buffer.size()) > - return NO_LINE_START; > + if (currentOffset == buffer.size()) > + return NoLineStart; > } > > /* inc current_offset to after LINE_START */ This comment needs to be updated too. > - current_line_start = current_offset++; > + currentLineStart = currentOffset++; > } else { > - if (tag == REG_HI_BITS) > - reg_num = (reg_num & 0xff) | (data_byte << 8); > - else if (tag == REG_LOW_BITS) > - reg_num = (reg_num & 0xff00) | data_byte; > - else if (tag == REG_SKIP) > - reg_num++; > - else if (tag == REG_VALUE) { > - auto reg = offsets_.find(reg_num); > + if (tag == RegHiBits) > + regNum = (regNum & 0xff) | (dataByte << 8); > + else if (tag == RegLowBits) > + regNum = (regNum & 0xff00) | dataByte; > + else if (tag == RegSkip) > + regNum++; > + else if (tag == RegValue) { > + auto reg = offsets_.find(regNum); > > if (reg != offsets_.end()) { > - offsets_[reg_num] = current_offset - 1; > + offsets_[regNum] = currentOffset - 1; > > - if (++regs_done == offsets_.size()) > - return PARSE_OK; > + if (++regsDone == offsets_.size()) > + return ParseOk; > } > - reg_num++; > + regNum++; > } else > - return ILLEGAL_TAG; > + return IllegalTag; > } > } > } > diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp > index c7492a77a3fd..5cd8af3f0305 100644 > --- a/src/ipa/raspberrypi/raspberrypi.cpp > +++ b/src/ipa/raspberrypi/raspberrypi.cpp > @@ -208,7 +208,7 @@ int IPARPi::init(const IPASettings &settings, IPAInitResult *result) > * that the kernel driver doesn't. We only do this the first time; we don't need > * to re-parse the metadata after a simple mode-switch for no reason. > */ > - helper_ = std::unique_ptr<RPiController::CamHelper>(RPiController::CamHelper::Create(settings.sensorModel)); > + helper_ = std::unique_ptr<RPiController::CamHelper>(RPiController::CamHelper::create(settings.sensorModel)); Not a condidate for this patch, but I think RPiController::CamHelper::create() should return a std::unique_ptr<>. Same for Controller::createAlgorithm(). > if (!helper_) { > LOG(IPARPI, Error) << "Could not create camera helper for " > << settings.sensorModel; > @@ -220,8 +220,8 @@ int IPARPi::init(const IPASettings &settings, IPAInitResult *result) > * to setup the staggered writer class. > */ > int gainDelay, exposureDelay, vblankDelay, sensorMetadata; > - helper_->GetDelays(exposureDelay, gainDelay, vblankDelay); > - sensorMetadata = helper_->SensorEmbeddedDataPresent(); > + helper_->getDelays(exposureDelay, gainDelay, vblankDelay); > + sensorMetadata = helper_->sensorEmbeddedDataPresent(); > > result->sensorConfig.gainDelay = gainDelay; > result->sensorConfig.exposureDelay = exposureDelay; > @@ -229,8 +229,8 @@ int IPARPi::init(const IPASettings &settings, IPAInitResult *result) > result->sensorConfig.sensorMetadata = sensorMetadata; > > /* Load the tuning file for this sensor. */ > - controller_.Read(settings.configurationFile.c_str()); > - controller_.Initialise(); > + controller_.read(settings.configurationFile.c_str()); > + controller_.initialise(); > > /* Return the controls handled by the IPA */ > ControlInfoMap::Map ctrlMap = ipaControls; > @@ -249,15 +249,15 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) > queueRequest(controls); > } > > - controller_.SwitchMode(mode_, &metadata); > + controller_.switchMode(mode_, &metadata); > > /* SwitchMode may supply updated exposure/gain values to use. */ > AgcStatus agcStatus; > - agcStatus.shutter_time = 0.0s; > - agcStatus.analogue_gain = 0.0; > + agcStatus.shutterTime = 0.0s; > + agcStatus.analogueGain = 0.0; > > - metadata.Get("agc.status", agcStatus); > - if (agcStatus.shutter_time && agcStatus.analogue_gain) { > + metadata.get("agc.status", agcStatus); > + if (agcStatus.shutterTime && agcStatus.analogueGain) { > ControlList ctrls(sensorCtrls_); > applyAGC(&agcStatus, ctrls); > startConfig->controls = std::move(ctrls); > @@ -271,8 +271,8 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) > frameCount_ = 0; > checkCount_ = 0; > if (firstStart_) { > - dropFrameCount_ = helper_->HideFramesStartup(); > - mistrustCount_ = helper_->MistrustFramesStartup(); > + dropFrameCount_ = helper_->hideFramesStartup(); > + mistrustCount_ = helper_->mistrustFramesStartup(); > > /* > * Query the AGC/AWB for how many frames they may take to > @@ -283,18 +283,18 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) > */ > unsigned int agcConvergenceFrames = 0; > RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( > - controller_.GetAlgorithm("agc")); > + controller_.getAlgorithm("agc")); > if (agc) { > - agcConvergenceFrames = agc->GetConvergenceFrames(); > + agcConvergenceFrames = agc->getConvergenceFrames(); > if (agcConvergenceFrames) > agcConvergenceFrames += mistrustCount_; > } > > unsigned int awbConvergenceFrames = 0; > RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>( > - controller_.GetAlgorithm("awb")); > + controller_.getAlgorithm("awb")); > if (awb) { > - awbConvergenceFrames = awb->GetConvergenceFrames(); > + awbConvergenceFrames = awb->getConvergenceFrames(); > if (awbConvergenceFrames) > awbConvergenceFrames += mistrustCount_; > } > @@ -302,12 +302,12 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) > dropFrameCount_ = std::max({ dropFrameCount_, agcConvergenceFrames, awbConvergenceFrames }); > LOG(IPARPI, Debug) << "Drop " << dropFrameCount_ << " frames on startup"; > } else { > - dropFrameCount_ = helper_->HideFramesModeSwitch(); > - mistrustCount_ = helper_->MistrustFramesModeSwitch(); > + dropFrameCount_ = helper_->hideFramesModeSwitch(); > + mistrustCount_ = helper_->mistrustFramesModeSwitch(); > } > > startConfig->dropFrameCount = dropFrameCount_; > - const Duration maxSensorFrameDuration = mode_.max_frame_length * mode_.line_length; > + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; > startConfig->maxSensorFrameLengthMs = maxSensorFrameDuration.get<std::milli>(); > > firstStart_ = false; > @@ -319,17 +319,17 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) > mode_.bitdepth = sensorInfo.bitsPerPixel; > mode_.width = sensorInfo.outputSize.width; > mode_.height = sensorInfo.outputSize.height; > - mode_.sensor_width = sensorInfo.activeAreaSize.width; > - mode_.sensor_height = sensorInfo.activeAreaSize.height; > - mode_.crop_x = sensorInfo.analogCrop.x; > - mode_.crop_y = sensorInfo.analogCrop.y; > + mode_.sensorWidth = sensorInfo.activeAreaSize.width; > + mode_.sensorHeight = sensorInfo.activeAreaSize.height; > + mode_.cropX = sensorInfo.analogCrop.x; > + mode_.cropY = sensorInfo.analogCrop.y; > > /* > * Calculate scaling parameters. The scale_[xy] factors are determined > * by the ratio between the crop rectangle size and the output size. > */ > - mode_.scale_x = sensorInfo.analogCrop.width / sensorInfo.outputSize.width; > - mode_.scale_y = sensorInfo.analogCrop.height / sensorInfo.outputSize.height; > + mode_.scaleX = sensorInfo.analogCrop.width / sensorInfo.outputSize.width; > + mode_.scaleY = sensorInfo.analogCrop.height / sensorInfo.outputSize.height; > > /* > * We're not told by the pipeline handler how scaling is split between > @@ -339,30 +339,30 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) > * > * \todo Get the pipeline handle to provide the full data > */ > - mode_.bin_x = std::min(2, static_cast<int>(mode_.scale_x)); > - mode_.bin_y = std::min(2, static_cast<int>(mode_.scale_y)); > + mode_.binX = std::min(2, static_cast<int>(mode_.scaleX)); > + mode_.binY = std::min(2, static_cast<int>(mode_.scaleY)); > > /* The noise factor is the square root of the total binning factor. */ > - mode_.noise_factor = sqrt(mode_.bin_x * mode_.bin_y); > + mode_.noiseFactor = sqrt(mode_.binX * mode_.binY); > > /* > * Calculate the line length as the ratio between the line length in > * pixels and the pixel rate. > */ > - mode_.line_length = sensorInfo.lineLength * (1.0s / sensorInfo.pixelRate); > + mode_.lineLength = sensorInfo.lineLength * (1.0s / sensorInfo.pixelRate); > > /* > * Set the frame length limits for the mode to ensure exposure and > * framerate calculations are clipped appropriately. > */ > - mode_.min_frame_length = sensorInfo.minFrameLength; > - mode_.max_frame_length = sensorInfo.maxFrameLength; > + mode_.minFrameLength = sensorInfo.minFrameLength; > + mode_.maxFrameLength = sensorInfo.maxFrameLength; > > /* > * Some sensors may have different sensitivities in different modes; > * the CamHelper will know the correct value. > */ > - mode_.sensitivity = helper_->GetModeSensitivity(mode_); > + mode_.sensitivity = helper_->getModeSensitivity(mode_); > } > > int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, > @@ -421,7 +421,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, > } > > /* Pass the camera mode to the CamHelper to setup algorithms. */ > - helper_->SetCameraMode(mode_); > + helper_->setCameraMode(mode_); > > /* > * Initialise this ControlList correctly, even if empty, in case the IPA is > @@ -438,8 +438,8 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, > > /* Supply initial values for gain and exposure. */ > AgcStatus agcStatus; > - agcStatus.shutter_time = defaultExposureTime; > - agcStatus.analogue_gain = defaultAnalogueGain; > + agcStatus.shutterTime = defaultExposureTime; > + agcStatus.analogueGain = defaultAnalogueGain; > applyAGC(&agcStatus, ctrls); > } > > @@ -451,25 +451,25 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, > * based on the current sensor mode. > */ > ControlInfoMap::Map ctrlMap = ipaControls; > - const Duration minSensorFrameDuration = mode_.min_frame_length * mode_.line_length; > - const Duration maxSensorFrameDuration = mode_.max_frame_length * mode_.line_length; > + const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength; > + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; > ctrlMap[&controls::FrameDurationLimits] = > ControlInfo(static_cast<int64_t>(minSensorFrameDuration.get<std::micro>()), > static_cast<int64_t>(maxSensorFrameDuration.get<std::micro>())); > > ctrlMap[&controls::AnalogueGain] = > - ControlInfo(1.0f, static_cast<float>(helper_->Gain(maxSensorGainCode_))); > + ControlInfo(1.0f, static_cast<float>(helper_->gain(maxSensorGainCode_))); > > /* > * Calculate the max exposure limit from the frame duration limit as V4L2 > * will limit the maximum control value based on the current VBLANK value. > */ > Duration maxShutter = Duration::max(); > - helper_->GetVBlanking(maxShutter, minSensorFrameDuration, maxSensorFrameDuration); > + helper_->getVBlanking(maxShutter, minSensorFrameDuration, maxSensorFrameDuration); > const uint32_t exposureMin = sensorCtrls_.at(V4L2_CID_EXPOSURE).min().get<int32_t>(); > > ctrlMap[&controls::ExposureTime] = > - ControlInfo(static_cast<int32_t>(helper_->Exposure(exposureMin).get<std::micro>()), > + ControlInfo(static_cast<int32_t>(helper_->exposure(exposureMin).get<std::micro>()), > static_cast<int32_t>(maxShutter.get<std::micro>())); > > result->controlInfo = ControlInfoMap(std::move(ctrlMap), controls::controls); > @@ -536,35 +536,35 @@ void IPARPi::reportMetadata() > * processed can be extracted and placed into the libcamera metadata > * buffer, where an application could query it. > */ > - DeviceStatus *deviceStatus = rpiMetadata_.GetLocked<DeviceStatus>("device.status"); > + DeviceStatus *deviceStatus = rpiMetadata_.getLocked<DeviceStatus>("device.status"); > if (deviceStatus) { > libcameraMetadata_.set(controls::ExposureTime, > - deviceStatus->shutter_speed.get<std::micro>()); > - libcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogue_gain); > + deviceStatus->shutterSpeed.get<std::micro>()); > + libcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogueGain); > libcameraMetadata_.set(controls::FrameDuration, > - helper_->Exposure(deviceStatus->frame_length).get<std::micro>()); > - if (deviceStatus->sensor_temperature) > - libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensor_temperature); > + helper_->exposure(deviceStatus->frameLength).get<std::micro>()); > + if (deviceStatus->sensorTemperature) > + libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensorTemperature); > } > > - AgcStatus *agcStatus = rpiMetadata_.GetLocked<AgcStatus>("agc.status"); > + AgcStatus *agcStatus = rpiMetadata_.getLocked<AgcStatus>("agc.status"); > if (agcStatus) { > libcameraMetadata_.set(controls::AeLocked, agcStatus->locked); > - libcameraMetadata_.set(controls::DigitalGain, agcStatus->digital_gain); > + libcameraMetadata_.set(controls::DigitalGain, agcStatus->digitalGain); > } > > - LuxStatus *luxStatus = rpiMetadata_.GetLocked<LuxStatus>("lux.status"); > + LuxStatus *luxStatus = rpiMetadata_.getLocked<LuxStatus>("lux.status"); > if (luxStatus) > libcameraMetadata_.set(controls::Lux, luxStatus->lux); > > - AwbStatus *awbStatus = rpiMetadata_.GetLocked<AwbStatus>("awb.status"); > + AwbStatus *awbStatus = rpiMetadata_.getLocked<AwbStatus>("awb.status"); > if (awbStatus) { > - libcameraMetadata_.set(controls::ColourGains, { static_cast<float>(awbStatus->gain_r), > - static_cast<float>(awbStatus->gain_b) }); > - libcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperature_K); > + libcameraMetadata_.set(controls::ColourGains, { static_cast<float>(awbStatus->gainR), > + static_cast<float>(awbStatus->gainB) }); > + libcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperatureK); > } > > - BlackLevelStatus *blackLevelStatus = rpiMetadata_.GetLocked<BlackLevelStatus>("black_level.status"); > + BlackLevelStatus *blackLevelStatus = rpiMetadata_.getLocked<BlackLevelStatus>("black_level.status"); > if (blackLevelStatus) > libcameraMetadata_.set(controls::SensorBlackLevels, > { static_cast<int32_t>(blackLevelStatus->black_level_r), > @@ -572,18 +572,18 @@ void IPARPi::reportMetadata() > static_cast<int32_t>(blackLevelStatus->black_level_g), > static_cast<int32_t>(blackLevelStatus->black_level_b) }); > > - FocusStatus *focusStatus = rpiMetadata_.GetLocked<FocusStatus>("focus.status"); > + FocusStatus *focusStatus = rpiMetadata_.getLocked<FocusStatus>("focus.status"); > if (focusStatus && focusStatus->num == 12) { > /* > * We get a 4x3 grid of regions by default. Calculate the average > * FoM over the central two positions to give an overall scene FoM. > * This can change later if it is not deemed suitable. > */ > - int32_t focusFoM = (focusStatus->focus_measures[5] + focusStatus->focus_measures[6]) / 2; > + int32_t focusFoM = (focusStatus->focusMeasures[5] + focusStatus->focusMeasures[6]) / 2; > libcameraMetadata_.set(controls::FocusFoM, focusFoM); > } > > - CcmStatus *ccmStatus = rpiMetadata_.GetLocked<CcmStatus>("ccm.status"); > + CcmStatus *ccmStatus = rpiMetadata_.getLocked<CcmStatus>("ccm.status"); > if (ccmStatus) { > float m[9]; > for (unsigned int i = 0; i < 9; i++) > @@ -695,7 +695,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > switch (ctrl.first) { > case controls::AE_ENABLE: { > - RPiController::Algorithm *agc = controller_.GetAlgorithm("agc"); > + RPiController::Algorithm *agc = controller_.getAlgorithm("agc"); > if (!agc) { > LOG(IPARPI, Warning) > << "Could not set AE_ENABLE - no AGC algorithm"; > @@ -703,9 +703,9 @@ void IPARPi::queueRequest(const ControlList &controls) > } > > if (ctrl.second.get<bool>() == false) > - agc->Pause(); > + agc->pause(); > else > - agc->Resume(); > + agc->resume(); > > libcameraMetadata_.set(controls::AeEnable, ctrl.second.get<bool>()); > break; > @@ -713,7 +713,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::EXPOSURE_TIME: { > RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( > - controller_.GetAlgorithm("agc")); > + controller_.getAlgorithm("agc")); > if (!agc) { > LOG(IPARPI, Warning) > << "Could not set EXPOSURE_TIME - no AGC algorithm"; > @@ -721,7 +721,7 @@ void IPARPi::queueRequest(const ControlList &controls) > } > > /* The control provides units of microseconds. */ > - agc->SetFixedShutter(ctrl.second.get<int32_t>() * 1.0us); > + agc->setFixedShutter(ctrl.second.get<int32_t>() * 1.0us); > > libcameraMetadata_.set(controls::ExposureTime, ctrl.second.get<int32_t>()); > break; > @@ -729,14 +729,14 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::ANALOGUE_GAIN: { > RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( > - controller_.GetAlgorithm("agc")); > + controller_.getAlgorithm("agc")); > if (!agc) { > LOG(IPARPI, Warning) > << "Could not set ANALOGUE_GAIN - no AGC algorithm"; > break; > } > > - agc->SetFixedAnalogueGain(ctrl.second.get<float>()); > + agc->setFixedAnalogueGain(ctrl.second.get<float>()); > > libcameraMetadata_.set(controls::AnalogueGain, > ctrl.second.get<float>()); > @@ -745,7 +745,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::AE_METERING_MODE: { > RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( > - controller_.GetAlgorithm("agc")); > + controller_.getAlgorithm("agc")); > if (!agc) { > LOG(IPARPI, Warning) > << "Could not set AE_METERING_MODE - no AGC algorithm"; > @@ -754,7 +754,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > int32_t idx = ctrl.second.get<int32_t>(); > if (MeteringModeTable.count(idx)) { > - agc->SetMeteringMode(MeteringModeTable.at(idx)); > + agc->setMeteringMode(MeteringModeTable.at(idx)); > libcameraMetadata_.set(controls::AeMeteringMode, idx); > } else { > LOG(IPARPI, Error) << "Metering mode " << idx > @@ -765,7 +765,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::AE_CONSTRAINT_MODE: { > RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( > - controller_.GetAlgorithm("agc")); > + controller_.getAlgorithm("agc")); > if (!agc) { > LOG(IPARPI, Warning) > << "Could not set AE_CONSTRAINT_MODE - no AGC algorithm"; > @@ -774,7 +774,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > int32_t idx = ctrl.second.get<int32_t>(); > if (ConstraintModeTable.count(idx)) { > - agc->SetConstraintMode(ConstraintModeTable.at(idx)); > + agc->setConstraintMode(ConstraintModeTable.at(idx)); > libcameraMetadata_.set(controls::AeConstraintMode, idx); > } else { > LOG(IPARPI, Error) << "Constraint mode " << idx > @@ -785,7 +785,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::AE_EXPOSURE_MODE: { > RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( > - controller_.GetAlgorithm("agc")); > + controller_.getAlgorithm("agc")); > if (!agc) { > LOG(IPARPI, Warning) > << "Could not set AE_EXPOSURE_MODE - no AGC algorithm"; > @@ -794,7 +794,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > int32_t idx = ctrl.second.get<int32_t>(); > if (ExposureModeTable.count(idx)) { > - agc->SetExposureMode(ExposureModeTable.at(idx)); > + agc->setExposureMode(ExposureModeTable.at(idx)); > libcameraMetadata_.set(controls::AeExposureMode, idx); > } else { > LOG(IPARPI, Error) << "Exposure mode " << idx > @@ -805,7 +805,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::EXPOSURE_VALUE: { > RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( > - controller_.GetAlgorithm("agc")); > + controller_.getAlgorithm("agc")); > if (!agc) { > LOG(IPARPI, Warning) > << "Could not set EXPOSURE_VALUE - no AGC algorithm"; > @@ -817,14 +817,14 @@ void IPARPi::queueRequest(const ControlList &controls) > * So convert to 2^EV > */ > double ev = pow(2.0, ctrl.second.get<float>()); > - agc->SetEv(ev); > + agc->setEv(ev); > libcameraMetadata_.set(controls::ExposureValue, > ctrl.second.get<float>()); > break; > } > > case controls::AWB_ENABLE: { > - RPiController::Algorithm *awb = controller_.GetAlgorithm("awb"); > + RPiController::Algorithm *awb = controller_.getAlgorithm("awb"); > if (!awb) { > LOG(IPARPI, Warning) > << "Could not set AWB_ENABLE - no AWB algorithm"; > @@ -832,9 +832,9 @@ void IPARPi::queueRequest(const ControlList &controls) > } > > if (ctrl.second.get<bool>() == false) > - awb->Pause(); > + awb->pause(); > else > - awb->Resume(); > + awb->resume(); > > libcameraMetadata_.set(controls::AwbEnable, > ctrl.second.get<bool>()); > @@ -843,7 +843,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::AWB_MODE: { > RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>( > - controller_.GetAlgorithm("awb")); > + controller_.getAlgorithm("awb")); > if (!awb) { > LOG(IPARPI, Warning) > << "Could not set AWB_MODE - no AWB algorithm"; > @@ -852,7 +852,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > int32_t idx = ctrl.second.get<int32_t>(); > if (AwbModeTable.count(idx)) { > - awb->SetMode(AwbModeTable.at(idx)); > + awb->setMode(AwbModeTable.at(idx)); > libcameraMetadata_.set(controls::AwbMode, idx); > } else { > LOG(IPARPI, Error) << "AWB mode " << idx > @@ -864,14 +864,14 @@ void IPARPi::queueRequest(const ControlList &controls) > case controls::COLOUR_GAINS: { > auto gains = ctrl.second.get<Span<const float>>(); > RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>( > - controller_.GetAlgorithm("awb")); > + controller_.getAlgorithm("awb")); > if (!awb) { > LOG(IPARPI, Warning) > << "Could not set COLOUR_GAINS - no AWB algorithm"; > break; > } > > - awb->SetManualGains(gains[0], gains[1]); > + awb->setManualGains(gains[0], gains[1]); > if (gains[0] != 0.0f && gains[1] != 0.0f) > /* A gain of 0.0f will switch back to auto mode. */ > libcameraMetadata_.set(controls::ColourGains, > @@ -881,14 +881,14 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::BRIGHTNESS: { > RPiController::ContrastAlgorithm *contrast = dynamic_cast<RPiController::ContrastAlgorithm *>( > - controller_.GetAlgorithm("contrast")); > + controller_.getAlgorithm("contrast")); > if (!contrast) { > LOG(IPARPI, Warning) > << "Could not set BRIGHTNESS - no contrast algorithm"; > break; > } > > - contrast->SetBrightness(ctrl.second.get<float>() * 65536); > + contrast->setBrightness(ctrl.second.get<float>() * 65536); > libcameraMetadata_.set(controls::Brightness, > ctrl.second.get<float>()); > break; > @@ -896,14 +896,14 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::CONTRAST: { > RPiController::ContrastAlgorithm *contrast = dynamic_cast<RPiController::ContrastAlgorithm *>( > - controller_.GetAlgorithm("contrast")); > + controller_.getAlgorithm("contrast")); > if (!contrast) { > LOG(IPARPI, Warning) > << "Could not set CONTRAST - no contrast algorithm"; > break; > } > > - contrast->SetContrast(ctrl.second.get<float>()); > + contrast->setContrast(ctrl.second.get<float>()); > libcameraMetadata_.set(controls::Contrast, > ctrl.second.get<float>()); > break; > @@ -911,14 +911,14 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::SATURATION: { > RPiController::CcmAlgorithm *ccm = dynamic_cast<RPiController::CcmAlgorithm *>( > - controller_.GetAlgorithm("ccm")); > + controller_.getAlgorithm("ccm")); > if (!ccm) { > LOG(IPARPI, Warning) > << "Could not set SATURATION - no ccm algorithm"; > break; > } > > - ccm->SetSaturation(ctrl.second.get<float>()); > + ccm->setSaturation(ctrl.second.get<float>()); > libcameraMetadata_.set(controls::Saturation, > ctrl.second.get<float>()); > break; > @@ -926,14 +926,14 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::SHARPNESS: { > RPiController::SharpenAlgorithm *sharpen = dynamic_cast<RPiController::SharpenAlgorithm *>( > - controller_.GetAlgorithm("sharpen")); > + controller_.getAlgorithm("sharpen")); > if (!sharpen) { > LOG(IPARPI, Warning) > << "Could not set SHARPNESS - no sharpen algorithm"; > break; > } > > - sharpen->SetStrength(ctrl.second.get<float>()); > + sharpen->setStrength(ctrl.second.get<float>()); > libcameraMetadata_.set(controls::Sharpness, > ctrl.second.get<float>()); > break; > @@ -952,7 +952,7 @@ void IPARPi::queueRequest(const ControlList &controls) > > case controls::NOISE_REDUCTION_MODE: { > RPiController::DenoiseAlgorithm *sdn = dynamic_cast<RPiController::DenoiseAlgorithm *>( > - controller_.GetAlgorithm("SDN")); > + controller_.getAlgorithm("SDN")); > if (!sdn) { > LOG(IPARPI, Warning) > << "Could not set NOISE_REDUCTION_MODE - no SDN algorithm"; > @@ -962,7 +962,7 @@ void IPARPi::queueRequest(const ControlList &controls) > int32_t idx = ctrl.second.get<int32_t>(); > auto mode = DenoiseModeTable.find(idx); > if (mode != DenoiseModeTable.end()) { > - sdn->SetMode(mode->second); > + sdn->setMode(mode->second); > > /* > * \todo If the colour denoise is not going to run due to an > @@ -1014,7 +1014,7 @@ void IPARPi::prepareISP(const ISPConfig &data) > * This may overwrite the DeviceStatus using values from the sensor > * metadata, and may also do additional custom processing. > */ > - helper_->Prepare(embeddedBuffer, rpiMetadata_); > + helper_->prepare(embeddedBuffer, rpiMetadata_); > > /* Done with embedded data now, return to pipeline handler asap. */ > if (data.embeddedBufferPresent) > @@ -1030,7 +1030,7 @@ void IPARPi::prepareISP(const ISPConfig &data) > * current frame, or any other bits of metadata that were added > * in helper_->Prepare(). > */ > - rpiMetadata_.Merge(lastMetadata); > + rpiMetadata_.merge(lastMetadata); > processPending_ = false; > return; > } > @@ -1040,48 +1040,48 @@ void IPARPi::prepareISP(const ISPConfig &data) > > ControlList ctrls(ispCtrls_); > > - controller_.Prepare(&rpiMetadata_); > + controller_.prepare(&rpiMetadata_); > > /* Lock the metadata buffer to avoid constant locks/unlocks. */ > std::unique_lock<RPiController::Metadata> lock(rpiMetadata_); > > - AwbStatus *awbStatus = rpiMetadata_.GetLocked<AwbStatus>("awb.status"); > + AwbStatus *awbStatus = rpiMetadata_.getLocked<AwbStatus>("awb.status"); > if (awbStatus) > applyAWB(awbStatus, ctrls); > > - CcmStatus *ccmStatus = rpiMetadata_.GetLocked<CcmStatus>("ccm.status"); > + CcmStatus *ccmStatus = rpiMetadata_.getLocked<CcmStatus>("ccm.status"); > if (ccmStatus) > applyCCM(ccmStatus, ctrls); > > - AgcStatus *dgStatus = rpiMetadata_.GetLocked<AgcStatus>("agc.status"); > + AgcStatus *dgStatus = rpiMetadata_.getLocked<AgcStatus>("agc.status"); > if (dgStatus) > applyDG(dgStatus, ctrls); > > - AlscStatus *lsStatus = rpiMetadata_.GetLocked<AlscStatus>("alsc.status"); > + AlscStatus *lsStatus = rpiMetadata_.getLocked<AlscStatus>("alsc.status"); > if (lsStatus) > applyLS(lsStatus, ctrls); > > - ContrastStatus *contrastStatus = rpiMetadata_.GetLocked<ContrastStatus>("contrast.status"); > + ContrastStatus *contrastStatus = rpiMetadata_.getLocked<ContrastStatus>("contrast.status"); > if (contrastStatus) > applyGamma(contrastStatus, ctrls); > > - BlackLevelStatus *blackLevelStatus = rpiMetadata_.GetLocked<BlackLevelStatus>("black_level.status"); > + BlackLevelStatus *blackLevelStatus = rpiMetadata_.getLocked<BlackLevelStatus>("black_level.status"); > if (blackLevelStatus) > applyBlackLevel(blackLevelStatus, ctrls); > > - GeqStatus *geqStatus = rpiMetadata_.GetLocked<GeqStatus>("geq.status"); > + GeqStatus *geqStatus = rpiMetadata_.getLocked<GeqStatus>("geq.status"); > if (geqStatus) > applyGEQ(geqStatus, ctrls); > > - DenoiseStatus *denoiseStatus = rpiMetadata_.GetLocked<DenoiseStatus>("denoise.status"); > + DenoiseStatus *denoiseStatus = rpiMetadata_.getLocked<DenoiseStatus>("denoise.status"); > if (denoiseStatus) > applyDenoise(denoiseStatus, ctrls); > > - SharpenStatus *sharpenStatus = rpiMetadata_.GetLocked<SharpenStatus>("sharpen.status"); > + SharpenStatus *sharpenStatus = rpiMetadata_.getLocked<SharpenStatus>("sharpen.status"); > if (sharpenStatus) > applySharpen(sharpenStatus, ctrls); > > - DpcStatus *dpcStatus = rpiMetadata_.GetLocked<DpcStatus>("dpc.status"); > + DpcStatus *dpcStatus = rpiMetadata_.getLocked<DpcStatus>("dpc.status"); > if (dpcStatus) > applyDPC(dpcStatus, ctrls); > > @@ -1097,13 +1097,13 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls) > int32_t gainCode = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>(); > int32_t vblank = sensorControls.get(V4L2_CID_VBLANK).get<int32_t>(); > > - deviceStatus.shutter_speed = helper_->Exposure(exposureLines); > - deviceStatus.analogue_gain = helper_->Gain(gainCode); > - deviceStatus.frame_length = mode_.height + vblank; > + deviceStatus.shutterSpeed = helper_->exposure(exposureLines); > + deviceStatus.analogueGain = helper_->gain(gainCode); > + deviceStatus.frameLength = mode_.height + vblank; > > LOG(IPARPI, Debug) << "Metadata - " << deviceStatus; > > - rpiMetadata_.Set("device.status", deviceStatus); > + rpiMetadata_.set("device.status", deviceStatus); > } > > void IPARPi::processStats(unsigned int bufferId) > @@ -1117,11 +1117,11 @@ void IPARPi::processStats(unsigned int bufferId) > Span<uint8_t> mem = it->second.planes()[0]; > bcm2835_isp_stats *stats = reinterpret_cast<bcm2835_isp_stats *>(mem.data()); > RPiController::StatisticsPtr statistics = std::make_shared<bcm2835_isp_stats>(*stats); > - helper_->Process(statistics, rpiMetadata_); > - controller_.Process(statistics, &rpiMetadata_); > + helper_->process(statistics, rpiMetadata_); > + controller_.process(statistics, &rpiMetadata_); > > struct AgcStatus agcStatus; > - if (rpiMetadata_.Get("agc.status", agcStatus) == 0) { > + if (rpiMetadata_.get("agc.status", agcStatus) == 0) { > ControlList ctrls(sensorCtrls_); > applyAGC(&agcStatus, ctrls); > > @@ -1131,19 +1131,19 @@ void IPARPi::processStats(unsigned int bufferId) > > void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) > { > - LOG(IPARPI, Debug) << "Applying WB R: " << awbStatus->gain_r << " B: " > - << awbStatus->gain_b; > + LOG(IPARPI, Debug) << "Applying WB R: " << awbStatus->gainR << " B: " > + << awbStatus->gainB; > > ctrls.set(V4L2_CID_RED_BALANCE, > - static_cast<int32_t>(awbStatus->gain_r * 1000)); > + static_cast<int32_t>(awbStatus->gainR * 1000)); > ctrls.set(V4L2_CID_BLUE_BALANCE, > - static_cast<int32_t>(awbStatus->gain_b * 1000)); > + static_cast<int32_t>(awbStatus->gainB * 1000)); > } > > void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDuration) > { > - const Duration minSensorFrameDuration = mode_.min_frame_length * mode_.line_length; > - const Duration maxSensorFrameDuration = mode_.max_frame_length * mode_.line_length; > + const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength; > + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; > > /* > * This will only be applied once AGC recalculations occur. > @@ -1164,20 +1164,20 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur > > /* > * Calculate the maximum exposure time possible for the AGC to use. > - * GetVBlanking() will update maxShutter with the largest exposure > + * getVBlanking() will update maxShutter with the largest exposure > * value possible. > */ > Duration maxShutter = Duration::max(); > - helper_->GetVBlanking(maxShutter, minFrameDuration_, maxFrameDuration_); > + helper_->getVBlanking(maxShutter, minFrameDuration_, maxFrameDuration_); > > RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( > - controller_.GetAlgorithm("agc")); > - agc->SetMaxShutter(maxShutter); > + controller_.getAlgorithm("agc")); > + agc->setMaxShutter(maxShutter); > } > > void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) > { > - int32_t gainCode = helper_->GainCode(agcStatus->analogue_gain); > + int32_t gainCode = helper_->gainCode(agcStatus->analogueGain); > > /* > * Ensure anything larger than the max gain code will not be passed to > @@ -1186,15 +1186,15 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) > */ > gainCode = std::min<int32_t>(gainCode, maxSensorGainCode_); > > - /* GetVBlanking might clip exposure time to the fps limits. */ > - Duration exposure = agcStatus->shutter_time; > - int32_t vblanking = helper_->GetVBlanking(exposure, minFrameDuration_, maxFrameDuration_); > - int32_t exposureLines = helper_->ExposureLines(exposure); > + /* getVBlanking might clip exposure time to the fps limits. */ > + Duration exposure = agcStatus->shutterTime; > + int32_t vblanking = helper_->getVBlanking(exposure, minFrameDuration_, maxFrameDuration_); > + int32_t exposureLines = helper_->exposureLines(exposure); > > LOG(IPARPI, Debug) << "Applying AGC Exposure: " << exposure > << " (Shutter lines: " << exposureLines << ", AGC requested " > - << agcStatus->shutter_time << ") Gain: " > - << agcStatus->analogue_gain << " (Gain Code: " > + << agcStatus->shutterTime << ") Gain: " > + << agcStatus->analogueGain << " (Gain Code: " > << gainCode << ")"; > > /* > @@ -1210,7 +1210,7 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) > void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls) > { > ctrls.set(V4L2_CID_DIGITAL_GAIN, > - static_cast<int32_t>(dgStatus->digital_gain * 1000)); > + static_cast<int32_t>(dgStatus->digitalGain * 1000)); > } > > void IPARPi::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls)
diff --git a/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp b/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp index ca800308fd6c..888f4569c56a 100644 --- a/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp +++ b/src/ipa/raspberrypi/controller/sharpen_algorithm.hpp @@ -15,7 +15,7 @@ class SharpenAlgorithm : public Algorithm public: SharpenAlgorithm(Controller *controller) : Algorithm(controller) {} // A sharpness control algorithm must provide the following: - virtual void SetStrength(double strength) = 0; + virtual void setStrength(double strength) = 0; }; } // namespace RPiController diff --git a/src/ipa/raspberrypi/controller/sharpen_status.h b/src/ipa/raspberrypi/controller/sharpen_status.h index 7501b191d6f6..2b0490742fba 100644 --- a/src/ipa/raspberrypi/controller/sharpen_status.h +++ b/src/ipa/raspberrypi/controller/sharpen_status.h @@ -20,7 +20,7 @@ struct SharpenStatus { // upper limit of the allowed sharpening response double limit; // The sharpening strength requested by the user or application. - double user_strength; + double userStrength; }; #ifdef __cplusplus diff --git a/src/ipa/raspberrypi/md_parser.hpp b/src/ipa/raspberrypi/md_parser.hpp index d32d0f549b9c..e505108a7adc 100644 --- a/src/ipa/raspberrypi/md_parser.hpp +++ b/src/ipa/raspberrypi/md_parser.hpp @@ -81,27 +81,27 @@ public: virtual ~MdParser() = default; - void Reset() + void reset() { reset_ = true; } - void SetBitsPerPixel(int bpp) + void setBitsPerPixel(int bpp) { bits_per_pixel_ = bpp; } - void SetNumLines(unsigned int num_lines) + void setNumLines(unsigned int numLines) { - num_lines_ = num_lines; + num_lines_ = numLines; } - void SetLineLengthBytes(unsigned int num_bytes) + void setLineLengthBytes(unsigned int numBytes) { - line_length_bytes_ = num_bytes; + line_length_bytes_ = numBytes; } - virtual Status Parse(libcamera::Span<const uint8_t> buffer, + virtual Status parse(libcamera::Span<const uint8_t> buffer, RegisterMap ®isters) = 0; protected: @@ -123,7 +123,7 @@ class MdParserSmia final : public MdParser public: MdParserSmia(std::initializer_list<uint32_t> registerList); - MdParser::Status Parse(libcamera::Span<const uint8_t> buffer, + MdParser::Status parse(libcamera::Span<const uint8_t> buffer, RegisterMap ®isters) override; private: @@ -133,18 +133,18 @@ private: /* * Note that error codes > 0 are regarded as non-fatal; codes < 0 * indicate a bad data buffer. Status codes are: - * PARSE_OK - found all registers, much happiness - * MISSING_REGS - some registers found; should this be a hard error? + * ParseOk - found all registers, much happiness + * MissingRegs - some registers found; should this be a hard error? * The remaining codes are all hard errors. */ enum ParseStatus { - PARSE_OK = 0, - MISSING_REGS = 1, - NO_LINE_START = -1, - ILLEGAL_TAG = -2, - BAD_DUMMY = -3, - BAD_LINE_END = -4, - BAD_PADDING = -5 + ParseOk = 0, + MissingRegs = 1, + NoLineStart = -1, + IllegalTag = -2, + BadDummy = -3, + BadLineEnd = -4, + BadPadding = -5 }; ParseStatus findRegs(libcamera::Span<const uint8_t> buffer); diff --git a/src/ipa/raspberrypi/md_parser_smia.cpp b/src/ipa/raspberrypi/md_parser_smia.cpp index ea5eac414b36..f2b37cab4e97 100644 --- a/src/ipa/raspberrypi/md_parser_smia.cpp +++ b/src/ipa/raspberrypi/md_parser_smia.cpp @@ -20,12 +20,12 @@ using namespace libcamera; * sensors, I think. */ -constexpr unsigned int LINE_START = 0x0a; -constexpr unsigned int LINE_END_TAG = 0x07; -constexpr unsigned int REG_HI_BITS = 0xaa; -constexpr unsigned int REG_LOW_BITS = 0xa5; -constexpr unsigned int REG_VALUE = 0x5a; -constexpr unsigned int REG_SKIP = 0x55; +constexpr unsigned int LineStart = 0x0a; +constexpr unsigned int LineEndTag = 0x07; +constexpr unsigned int RegHiBits = 0xaa; +constexpr unsigned int RegLowBits = 0xa5; +constexpr unsigned int RegValue = 0x5a; +constexpr unsigned int RegSkip = 0x55; MdParserSmia::MdParserSmia(std::initializer_list<uint32_t> registerList) { @@ -33,7 +33,7 @@ MdParserSmia::MdParserSmia(std::initializer_list<uint32_t> registerList) offsets_[r] = {}; } -MdParser::Status MdParserSmia::Parse(libcamera::Span<const uint8_t> buffer, +MdParser::Status MdParserSmia::parse(libcamera::Span<const uint8_t> buffer, RegisterMap ®isters) { if (reset_) { @@ -53,7 +53,7 @@ MdParser::Status MdParserSmia::Parse(libcamera::Span<const uint8_t> buffer, * * In either case, we retry parsing on the next frame. */ - if (ret != PARSE_OK) + if (ret != ParseOk) return ERROR; reset_ = false; @@ -76,74 +76,74 @@ MdParserSmia::ParseStatus MdParserSmia::findRegs(libcamera::Span<const uint8_t> { ASSERT(offsets_.size()); - if (buffer[0] != LINE_START) - return NO_LINE_START; + if (buffer[0] != LineStart) + return NoLineStart; - unsigned int current_offset = 1; /* after the LINE_START */ - unsigned int current_line_start = 0, current_line = 0; - unsigned int reg_num = 0, regs_done = 0; + unsigned int currentOffset = 1; /* after the LINE_START */ + unsigned int currentLineStart = 0, currentLine = 0; + unsigned int regNum = 0, regsDone = 0; while (1) { - int tag = buffer[current_offset++]; + int tag = buffer[currentOffset++]; if ((bits_per_pixel_ == 10 && - (current_offset + 1 - current_line_start) % 5 == 0) || + (currentOffset + 1 - currentLineStart) % 5 == 0) || (bits_per_pixel_ == 12 && - (current_offset + 1 - current_line_start) % 3 == 0)) { - if (buffer[current_offset++] != REG_SKIP) - return BAD_DUMMY; + (currentOffset + 1 - currentLineStart) % 3 == 0)) { + if (buffer[currentOffset++] != RegSkip) + return BadDummy; } - int data_byte = buffer[current_offset++]; + int dataByte = buffer[currentOffset++]; - if (tag == LINE_END_TAG) { - if (data_byte != LINE_END_TAG) - return BAD_LINE_END; + if (tag == LineEndTag) { + if (dataByte != LineEndTag) + return BadLineEnd; - if (num_lines_ && ++current_line == num_lines_) - return MISSING_REGS; + if (num_lines_ && ++currentLine == num_lines_) + return MissingRegs; if (line_length_bytes_) { - current_offset = current_line_start + line_length_bytes_; + currentOffset = currentLineStart + line_length_bytes_; /* Require whole line to be in the buffer (if buffer size set). */ if (buffer.size() && - current_offset + line_length_bytes_ > buffer.size()) - return MISSING_REGS; + currentOffset + line_length_bytes_ > buffer.size()) + return MissingRegs; - if (buffer[current_offset] != LINE_START) - return NO_LINE_START; + if (buffer[currentOffset] != LineStart) + return NoLineStart; } else { /* allow a zero line length to mean "hunt for the next line" */ - while (current_offset < buffer.size() && - buffer[current_offset] != LINE_START) - current_offset++; + while (currentOffset < buffer.size() && + buffer[currentOffset] != LineStart) + currentOffset++; - if (current_offset == buffer.size()) - return NO_LINE_START; + if (currentOffset == buffer.size()) + return NoLineStart; } /* inc current_offset to after LINE_START */ - current_line_start = current_offset++; + currentLineStart = currentOffset++; } else { - if (tag == REG_HI_BITS) - reg_num = (reg_num & 0xff) | (data_byte << 8); - else if (tag == REG_LOW_BITS) - reg_num = (reg_num & 0xff00) | data_byte; - else if (tag == REG_SKIP) - reg_num++; - else if (tag == REG_VALUE) { - auto reg = offsets_.find(reg_num); + if (tag == RegHiBits) + regNum = (regNum & 0xff) | (dataByte << 8); + else if (tag == RegLowBits) + regNum = (regNum & 0xff00) | dataByte; + else if (tag == RegSkip) + regNum++; + else if (tag == RegValue) { + auto reg = offsets_.find(regNum); if (reg != offsets_.end()) { - offsets_[reg_num] = current_offset - 1; + offsets_[regNum] = currentOffset - 1; - if (++regs_done == offsets_.size()) - return PARSE_OK; + if (++regsDone == offsets_.size()) + return ParseOk; } - reg_num++; + regNum++; } else - return ILLEGAL_TAG; + return IllegalTag; } } } diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index c7492a77a3fd..5cd8af3f0305 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -208,7 +208,7 @@ int IPARPi::init(const IPASettings &settings, IPAInitResult *result) * that the kernel driver doesn't. We only do this the first time; we don't need * to re-parse the metadata after a simple mode-switch for no reason. */ - helper_ = std::unique_ptr<RPiController::CamHelper>(RPiController::CamHelper::Create(settings.sensorModel)); + helper_ = std::unique_ptr<RPiController::CamHelper>(RPiController::CamHelper::create(settings.sensorModel)); if (!helper_) { LOG(IPARPI, Error) << "Could not create camera helper for " << settings.sensorModel; @@ -220,8 +220,8 @@ int IPARPi::init(const IPASettings &settings, IPAInitResult *result) * to setup the staggered writer class. */ int gainDelay, exposureDelay, vblankDelay, sensorMetadata; - helper_->GetDelays(exposureDelay, gainDelay, vblankDelay); - sensorMetadata = helper_->SensorEmbeddedDataPresent(); + helper_->getDelays(exposureDelay, gainDelay, vblankDelay); + sensorMetadata = helper_->sensorEmbeddedDataPresent(); result->sensorConfig.gainDelay = gainDelay; result->sensorConfig.exposureDelay = exposureDelay; @@ -229,8 +229,8 @@ int IPARPi::init(const IPASettings &settings, IPAInitResult *result) result->sensorConfig.sensorMetadata = sensorMetadata; /* Load the tuning file for this sensor. */ - controller_.Read(settings.configurationFile.c_str()); - controller_.Initialise(); + controller_.read(settings.configurationFile.c_str()); + controller_.initialise(); /* Return the controls handled by the IPA */ ControlInfoMap::Map ctrlMap = ipaControls; @@ -249,15 +249,15 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) queueRequest(controls); } - controller_.SwitchMode(mode_, &metadata); + controller_.switchMode(mode_, &metadata); /* SwitchMode may supply updated exposure/gain values to use. */ AgcStatus agcStatus; - agcStatus.shutter_time = 0.0s; - agcStatus.analogue_gain = 0.0; + agcStatus.shutterTime = 0.0s; + agcStatus.analogueGain = 0.0; - metadata.Get("agc.status", agcStatus); - if (agcStatus.shutter_time && agcStatus.analogue_gain) { + metadata.get("agc.status", agcStatus); + if (agcStatus.shutterTime && agcStatus.analogueGain) { ControlList ctrls(sensorCtrls_); applyAGC(&agcStatus, ctrls); startConfig->controls = std::move(ctrls); @@ -271,8 +271,8 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) frameCount_ = 0; checkCount_ = 0; if (firstStart_) { - dropFrameCount_ = helper_->HideFramesStartup(); - mistrustCount_ = helper_->MistrustFramesStartup(); + dropFrameCount_ = helper_->hideFramesStartup(); + mistrustCount_ = helper_->mistrustFramesStartup(); /* * Query the AGC/AWB for how many frames they may take to @@ -283,18 +283,18 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) */ unsigned int agcConvergenceFrames = 0; RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (agc) { - agcConvergenceFrames = agc->GetConvergenceFrames(); + agcConvergenceFrames = agc->getConvergenceFrames(); if (agcConvergenceFrames) agcConvergenceFrames += mistrustCount_; } unsigned int awbConvergenceFrames = 0; RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>( - controller_.GetAlgorithm("awb")); + controller_.getAlgorithm("awb")); if (awb) { - awbConvergenceFrames = awb->GetConvergenceFrames(); + awbConvergenceFrames = awb->getConvergenceFrames(); if (awbConvergenceFrames) awbConvergenceFrames += mistrustCount_; } @@ -302,12 +302,12 @@ void IPARPi::start(const ControlList &controls, StartConfig *startConfig) dropFrameCount_ = std::max({ dropFrameCount_, agcConvergenceFrames, awbConvergenceFrames }); LOG(IPARPI, Debug) << "Drop " << dropFrameCount_ << " frames on startup"; } else { - dropFrameCount_ = helper_->HideFramesModeSwitch(); - mistrustCount_ = helper_->MistrustFramesModeSwitch(); + dropFrameCount_ = helper_->hideFramesModeSwitch(); + mistrustCount_ = helper_->mistrustFramesModeSwitch(); } startConfig->dropFrameCount = dropFrameCount_; - const Duration maxSensorFrameDuration = mode_.max_frame_length * mode_.line_length; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; startConfig->maxSensorFrameLengthMs = maxSensorFrameDuration.get<std::milli>(); firstStart_ = false; @@ -319,17 +319,17 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) mode_.bitdepth = sensorInfo.bitsPerPixel; mode_.width = sensorInfo.outputSize.width; mode_.height = sensorInfo.outputSize.height; - mode_.sensor_width = sensorInfo.activeAreaSize.width; - mode_.sensor_height = sensorInfo.activeAreaSize.height; - mode_.crop_x = sensorInfo.analogCrop.x; - mode_.crop_y = sensorInfo.analogCrop.y; + mode_.sensorWidth = sensorInfo.activeAreaSize.width; + mode_.sensorHeight = sensorInfo.activeAreaSize.height; + mode_.cropX = sensorInfo.analogCrop.x; + mode_.cropY = sensorInfo.analogCrop.y; /* * Calculate scaling parameters. The scale_[xy] factors are determined * by the ratio between the crop rectangle size and the output size. */ - mode_.scale_x = sensorInfo.analogCrop.width / sensorInfo.outputSize.width; - mode_.scale_y = sensorInfo.analogCrop.height / sensorInfo.outputSize.height; + mode_.scaleX = sensorInfo.analogCrop.width / sensorInfo.outputSize.width; + mode_.scaleY = sensorInfo.analogCrop.height / sensorInfo.outputSize.height; /* * We're not told by the pipeline handler how scaling is split between @@ -339,30 +339,30 @@ void IPARPi::setMode(const IPACameraSensorInfo &sensorInfo) * * \todo Get the pipeline handle to provide the full data */ - mode_.bin_x = std::min(2, static_cast<int>(mode_.scale_x)); - mode_.bin_y = std::min(2, static_cast<int>(mode_.scale_y)); + mode_.binX = std::min(2, static_cast<int>(mode_.scaleX)); + mode_.binY = std::min(2, static_cast<int>(mode_.scaleY)); /* The noise factor is the square root of the total binning factor. */ - mode_.noise_factor = sqrt(mode_.bin_x * mode_.bin_y); + mode_.noiseFactor = sqrt(mode_.binX * mode_.binY); /* * Calculate the line length as the ratio between the line length in * pixels and the pixel rate. */ - mode_.line_length = sensorInfo.lineLength * (1.0s / sensorInfo.pixelRate); + mode_.lineLength = sensorInfo.lineLength * (1.0s / sensorInfo.pixelRate); /* * Set the frame length limits for the mode to ensure exposure and * framerate calculations are clipped appropriately. */ - mode_.min_frame_length = sensorInfo.minFrameLength; - mode_.max_frame_length = sensorInfo.maxFrameLength; + mode_.minFrameLength = sensorInfo.minFrameLength; + mode_.maxFrameLength = sensorInfo.maxFrameLength; /* * Some sensors may have different sensitivities in different modes; * the CamHelper will know the correct value. */ - mode_.sensitivity = helper_->GetModeSensitivity(mode_); + mode_.sensitivity = helper_->getModeSensitivity(mode_); } int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, @@ -421,7 +421,7 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, } /* Pass the camera mode to the CamHelper to setup algorithms. */ - helper_->SetCameraMode(mode_); + helper_->setCameraMode(mode_); /* * Initialise this ControlList correctly, even if empty, in case the IPA is @@ -438,8 +438,8 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, /* Supply initial values for gain and exposure. */ AgcStatus agcStatus; - agcStatus.shutter_time = defaultExposureTime; - agcStatus.analogue_gain = defaultAnalogueGain; + agcStatus.shutterTime = defaultExposureTime; + agcStatus.analogueGain = defaultAnalogueGain; applyAGC(&agcStatus, ctrls); } @@ -451,25 +451,25 @@ int IPARPi::configure(const IPACameraSensorInfo &sensorInfo, * based on the current sensor mode. */ ControlInfoMap::Map ctrlMap = ipaControls; - const Duration minSensorFrameDuration = mode_.min_frame_length * mode_.line_length; - const Duration maxSensorFrameDuration = mode_.max_frame_length * mode_.line_length; + const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; ctrlMap[&controls::FrameDurationLimits] = ControlInfo(static_cast<int64_t>(minSensorFrameDuration.get<std::micro>()), static_cast<int64_t>(maxSensorFrameDuration.get<std::micro>())); ctrlMap[&controls::AnalogueGain] = - ControlInfo(1.0f, static_cast<float>(helper_->Gain(maxSensorGainCode_))); + ControlInfo(1.0f, static_cast<float>(helper_->gain(maxSensorGainCode_))); /* * Calculate the max exposure limit from the frame duration limit as V4L2 * will limit the maximum control value based on the current VBLANK value. */ Duration maxShutter = Duration::max(); - helper_->GetVBlanking(maxShutter, minSensorFrameDuration, maxSensorFrameDuration); + helper_->getVBlanking(maxShutter, minSensorFrameDuration, maxSensorFrameDuration); const uint32_t exposureMin = sensorCtrls_.at(V4L2_CID_EXPOSURE).min().get<int32_t>(); ctrlMap[&controls::ExposureTime] = - ControlInfo(static_cast<int32_t>(helper_->Exposure(exposureMin).get<std::micro>()), + ControlInfo(static_cast<int32_t>(helper_->exposure(exposureMin).get<std::micro>()), static_cast<int32_t>(maxShutter.get<std::micro>())); result->controlInfo = ControlInfoMap(std::move(ctrlMap), controls::controls); @@ -536,35 +536,35 @@ void IPARPi::reportMetadata() * processed can be extracted and placed into the libcamera metadata * buffer, where an application could query it. */ - DeviceStatus *deviceStatus = rpiMetadata_.GetLocked<DeviceStatus>("device.status"); + DeviceStatus *deviceStatus = rpiMetadata_.getLocked<DeviceStatus>("device.status"); if (deviceStatus) { libcameraMetadata_.set(controls::ExposureTime, - deviceStatus->shutter_speed.get<std::micro>()); - libcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogue_gain); + deviceStatus->shutterSpeed.get<std::micro>()); + libcameraMetadata_.set(controls::AnalogueGain, deviceStatus->analogueGain); libcameraMetadata_.set(controls::FrameDuration, - helper_->Exposure(deviceStatus->frame_length).get<std::micro>()); - if (deviceStatus->sensor_temperature) - libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensor_temperature); + helper_->exposure(deviceStatus->frameLength).get<std::micro>()); + if (deviceStatus->sensorTemperature) + libcameraMetadata_.set(controls::SensorTemperature, *deviceStatus->sensorTemperature); } - AgcStatus *agcStatus = rpiMetadata_.GetLocked<AgcStatus>("agc.status"); + AgcStatus *agcStatus = rpiMetadata_.getLocked<AgcStatus>("agc.status"); if (agcStatus) { libcameraMetadata_.set(controls::AeLocked, agcStatus->locked); - libcameraMetadata_.set(controls::DigitalGain, agcStatus->digital_gain); + libcameraMetadata_.set(controls::DigitalGain, agcStatus->digitalGain); } - LuxStatus *luxStatus = rpiMetadata_.GetLocked<LuxStatus>("lux.status"); + LuxStatus *luxStatus = rpiMetadata_.getLocked<LuxStatus>("lux.status"); if (luxStatus) libcameraMetadata_.set(controls::Lux, luxStatus->lux); - AwbStatus *awbStatus = rpiMetadata_.GetLocked<AwbStatus>("awb.status"); + AwbStatus *awbStatus = rpiMetadata_.getLocked<AwbStatus>("awb.status"); if (awbStatus) { - libcameraMetadata_.set(controls::ColourGains, { static_cast<float>(awbStatus->gain_r), - static_cast<float>(awbStatus->gain_b) }); - libcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperature_K); + libcameraMetadata_.set(controls::ColourGains, { static_cast<float>(awbStatus->gainR), + static_cast<float>(awbStatus->gainB) }); + libcameraMetadata_.set(controls::ColourTemperature, awbStatus->temperatureK); } - BlackLevelStatus *blackLevelStatus = rpiMetadata_.GetLocked<BlackLevelStatus>("black_level.status"); + BlackLevelStatus *blackLevelStatus = rpiMetadata_.getLocked<BlackLevelStatus>("black_level.status"); if (blackLevelStatus) libcameraMetadata_.set(controls::SensorBlackLevels, { static_cast<int32_t>(blackLevelStatus->black_level_r), @@ -572,18 +572,18 @@ void IPARPi::reportMetadata() static_cast<int32_t>(blackLevelStatus->black_level_g), static_cast<int32_t>(blackLevelStatus->black_level_b) }); - FocusStatus *focusStatus = rpiMetadata_.GetLocked<FocusStatus>("focus.status"); + FocusStatus *focusStatus = rpiMetadata_.getLocked<FocusStatus>("focus.status"); if (focusStatus && focusStatus->num == 12) { /* * We get a 4x3 grid of regions by default. Calculate the average * FoM over the central two positions to give an overall scene FoM. * This can change later if it is not deemed suitable. */ - int32_t focusFoM = (focusStatus->focus_measures[5] + focusStatus->focus_measures[6]) / 2; + int32_t focusFoM = (focusStatus->focusMeasures[5] + focusStatus->focusMeasures[6]) / 2; libcameraMetadata_.set(controls::FocusFoM, focusFoM); } - CcmStatus *ccmStatus = rpiMetadata_.GetLocked<CcmStatus>("ccm.status"); + CcmStatus *ccmStatus = rpiMetadata_.getLocked<CcmStatus>("ccm.status"); if (ccmStatus) { float m[9]; for (unsigned int i = 0; i < 9; i++) @@ -695,7 +695,7 @@ void IPARPi::queueRequest(const ControlList &controls) switch (ctrl.first) { case controls::AE_ENABLE: { - RPiController::Algorithm *agc = controller_.GetAlgorithm("agc"); + RPiController::Algorithm *agc = controller_.getAlgorithm("agc"); if (!agc) { LOG(IPARPI, Warning) << "Could not set AE_ENABLE - no AGC algorithm"; @@ -703,9 +703,9 @@ void IPARPi::queueRequest(const ControlList &controls) } if (ctrl.second.get<bool>() == false) - agc->Pause(); + agc->pause(); else - agc->Resume(); + agc->resume(); libcameraMetadata_.set(controls::AeEnable, ctrl.second.get<bool>()); break; @@ -713,7 +713,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::EXPOSURE_TIME: { RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set EXPOSURE_TIME - no AGC algorithm"; @@ -721,7 +721,7 @@ void IPARPi::queueRequest(const ControlList &controls) } /* The control provides units of microseconds. */ - agc->SetFixedShutter(ctrl.second.get<int32_t>() * 1.0us); + agc->setFixedShutter(ctrl.second.get<int32_t>() * 1.0us); libcameraMetadata_.set(controls::ExposureTime, ctrl.second.get<int32_t>()); break; @@ -729,14 +729,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::ANALOGUE_GAIN: { RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set ANALOGUE_GAIN - no AGC algorithm"; break; } - agc->SetFixedAnalogueGain(ctrl.second.get<float>()); + agc->setFixedAnalogueGain(ctrl.second.get<float>()); libcameraMetadata_.set(controls::AnalogueGain, ctrl.second.get<float>()); @@ -745,7 +745,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AE_METERING_MODE: { RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set AE_METERING_MODE - no AGC algorithm"; @@ -754,7 +754,7 @@ void IPARPi::queueRequest(const ControlList &controls) int32_t idx = ctrl.second.get<int32_t>(); if (MeteringModeTable.count(idx)) { - agc->SetMeteringMode(MeteringModeTable.at(idx)); + agc->setMeteringMode(MeteringModeTable.at(idx)); libcameraMetadata_.set(controls::AeMeteringMode, idx); } else { LOG(IPARPI, Error) << "Metering mode " << idx @@ -765,7 +765,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AE_CONSTRAINT_MODE: { RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set AE_CONSTRAINT_MODE - no AGC algorithm"; @@ -774,7 +774,7 @@ void IPARPi::queueRequest(const ControlList &controls) int32_t idx = ctrl.second.get<int32_t>(); if (ConstraintModeTable.count(idx)) { - agc->SetConstraintMode(ConstraintModeTable.at(idx)); + agc->setConstraintMode(ConstraintModeTable.at(idx)); libcameraMetadata_.set(controls::AeConstraintMode, idx); } else { LOG(IPARPI, Error) << "Constraint mode " << idx @@ -785,7 +785,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AE_EXPOSURE_MODE: { RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set AE_EXPOSURE_MODE - no AGC algorithm"; @@ -794,7 +794,7 @@ void IPARPi::queueRequest(const ControlList &controls) int32_t idx = ctrl.second.get<int32_t>(); if (ExposureModeTable.count(idx)) { - agc->SetExposureMode(ExposureModeTable.at(idx)); + agc->setExposureMode(ExposureModeTable.at(idx)); libcameraMetadata_.set(controls::AeExposureMode, idx); } else { LOG(IPARPI, Error) << "Exposure mode " << idx @@ -805,7 +805,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::EXPOSURE_VALUE: { RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( - controller_.GetAlgorithm("agc")); + controller_.getAlgorithm("agc")); if (!agc) { LOG(IPARPI, Warning) << "Could not set EXPOSURE_VALUE - no AGC algorithm"; @@ -817,14 +817,14 @@ void IPARPi::queueRequest(const ControlList &controls) * So convert to 2^EV */ double ev = pow(2.0, ctrl.second.get<float>()); - agc->SetEv(ev); + agc->setEv(ev); libcameraMetadata_.set(controls::ExposureValue, ctrl.second.get<float>()); break; } case controls::AWB_ENABLE: { - RPiController::Algorithm *awb = controller_.GetAlgorithm("awb"); + RPiController::Algorithm *awb = controller_.getAlgorithm("awb"); if (!awb) { LOG(IPARPI, Warning) << "Could not set AWB_ENABLE - no AWB algorithm"; @@ -832,9 +832,9 @@ void IPARPi::queueRequest(const ControlList &controls) } if (ctrl.second.get<bool>() == false) - awb->Pause(); + awb->pause(); else - awb->Resume(); + awb->resume(); libcameraMetadata_.set(controls::AwbEnable, ctrl.second.get<bool>()); @@ -843,7 +843,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::AWB_MODE: { RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>( - controller_.GetAlgorithm("awb")); + controller_.getAlgorithm("awb")); if (!awb) { LOG(IPARPI, Warning) << "Could not set AWB_MODE - no AWB algorithm"; @@ -852,7 +852,7 @@ void IPARPi::queueRequest(const ControlList &controls) int32_t idx = ctrl.second.get<int32_t>(); if (AwbModeTable.count(idx)) { - awb->SetMode(AwbModeTable.at(idx)); + awb->setMode(AwbModeTable.at(idx)); libcameraMetadata_.set(controls::AwbMode, idx); } else { LOG(IPARPI, Error) << "AWB mode " << idx @@ -864,14 +864,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::COLOUR_GAINS: { auto gains = ctrl.second.get<Span<const float>>(); RPiController::AwbAlgorithm *awb = dynamic_cast<RPiController::AwbAlgorithm *>( - controller_.GetAlgorithm("awb")); + controller_.getAlgorithm("awb")); if (!awb) { LOG(IPARPI, Warning) << "Could not set COLOUR_GAINS - no AWB algorithm"; break; } - awb->SetManualGains(gains[0], gains[1]); + awb->setManualGains(gains[0], gains[1]); if (gains[0] != 0.0f && gains[1] != 0.0f) /* A gain of 0.0f will switch back to auto mode. */ libcameraMetadata_.set(controls::ColourGains, @@ -881,14 +881,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::BRIGHTNESS: { RPiController::ContrastAlgorithm *contrast = dynamic_cast<RPiController::ContrastAlgorithm *>( - controller_.GetAlgorithm("contrast")); + controller_.getAlgorithm("contrast")); if (!contrast) { LOG(IPARPI, Warning) << "Could not set BRIGHTNESS - no contrast algorithm"; break; } - contrast->SetBrightness(ctrl.second.get<float>() * 65536); + contrast->setBrightness(ctrl.second.get<float>() * 65536); libcameraMetadata_.set(controls::Brightness, ctrl.second.get<float>()); break; @@ -896,14 +896,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::CONTRAST: { RPiController::ContrastAlgorithm *contrast = dynamic_cast<RPiController::ContrastAlgorithm *>( - controller_.GetAlgorithm("contrast")); + controller_.getAlgorithm("contrast")); if (!contrast) { LOG(IPARPI, Warning) << "Could not set CONTRAST - no contrast algorithm"; break; } - contrast->SetContrast(ctrl.second.get<float>()); + contrast->setContrast(ctrl.second.get<float>()); libcameraMetadata_.set(controls::Contrast, ctrl.second.get<float>()); break; @@ -911,14 +911,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::SATURATION: { RPiController::CcmAlgorithm *ccm = dynamic_cast<RPiController::CcmAlgorithm *>( - controller_.GetAlgorithm("ccm")); + controller_.getAlgorithm("ccm")); if (!ccm) { LOG(IPARPI, Warning) << "Could not set SATURATION - no ccm algorithm"; break; } - ccm->SetSaturation(ctrl.second.get<float>()); + ccm->setSaturation(ctrl.second.get<float>()); libcameraMetadata_.set(controls::Saturation, ctrl.second.get<float>()); break; @@ -926,14 +926,14 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::SHARPNESS: { RPiController::SharpenAlgorithm *sharpen = dynamic_cast<RPiController::SharpenAlgorithm *>( - controller_.GetAlgorithm("sharpen")); + controller_.getAlgorithm("sharpen")); if (!sharpen) { LOG(IPARPI, Warning) << "Could not set SHARPNESS - no sharpen algorithm"; break; } - sharpen->SetStrength(ctrl.second.get<float>()); + sharpen->setStrength(ctrl.second.get<float>()); libcameraMetadata_.set(controls::Sharpness, ctrl.second.get<float>()); break; @@ -952,7 +952,7 @@ void IPARPi::queueRequest(const ControlList &controls) case controls::NOISE_REDUCTION_MODE: { RPiController::DenoiseAlgorithm *sdn = dynamic_cast<RPiController::DenoiseAlgorithm *>( - controller_.GetAlgorithm("SDN")); + controller_.getAlgorithm("SDN")); if (!sdn) { LOG(IPARPI, Warning) << "Could not set NOISE_REDUCTION_MODE - no SDN algorithm"; @@ -962,7 +962,7 @@ void IPARPi::queueRequest(const ControlList &controls) int32_t idx = ctrl.second.get<int32_t>(); auto mode = DenoiseModeTable.find(idx); if (mode != DenoiseModeTable.end()) { - sdn->SetMode(mode->second); + sdn->setMode(mode->second); /* * \todo If the colour denoise is not going to run due to an @@ -1014,7 +1014,7 @@ void IPARPi::prepareISP(const ISPConfig &data) * This may overwrite the DeviceStatus using values from the sensor * metadata, and may also do additional custom processing. */ - helper_->Prepare(embeddedBuffer, rpiMetadata_); + helper_->prepare(embeddedBuffer, rpiMetadata_); /* Done with embedded data now, return to pipeline handler asap. */ if (data.embeddedBufferPresent) @@ -1030,7 +1030,7 @@ void IPARPi::prepareISP(const ISPConfig &data) * current frame, or any other bits of metadata that were added * in helper_->Prepare(). */ - rpiMetadata_.Merge(lastMetadata); + rpiMetadata_.merge(lastMetadata); processPending_ = false; return; } @@ -1040,48 +1040,48 @@ void IPARPi::prepareISP(const ISPConfig &data) ControlList ctrls(ispCtrls_); - controller_.Prepare(&rpiMetadata_); + controller_.prepare(&rpiMetadata_); /* Lock the metadata buffer to avoid constant locks/unlocks. */ std::unique_lock<RPiController::Metadata> lock(rpiMetadata_); - AwbStatus *awbStatus = rpiMetadata_.GetLocked<AwbStatus>("awb.status"); + AwbStatus *awbStatus = rpiMetadata_.getLocked<AwbStatus>("awb.status"); if (awbStatus) applyAWB(awbStatus, ctrls); - CcmStatus *ccmStatus = rpiMetadata_.GetLocked<CcmStatus>("ccm.status"); + CcmStatus *ccmStatus = rpiMetadata_.getLocked<CcmStatus>("ccm.status"); if (ccmStatus) applyCCM(ccmStatus, ctrls); - AgcStatus *dgStatus = rpiMetadata_.GetLocked<AgcStatus>("agc.status"); + AgcStatus *dgStatus = rpiMetadata_.getLocked<AgcStatus>("agc.status"); if (dgStatus) applyDG(dgStatus, ctrls); - AlscStatus *lsStatus = rpiMetadata_.GetLocked<AlscStatus>("alsc.status"); + AlscStatus *lsStatus = rpiMetadata_.getLocked<AlscStatus>("alsc.status"); if (lsStatus) applyLS(lsStatus, ctrls); - ContrastStatus *contrastStatus = rpiMetadata_.GetLocked<ContrastStatus>("contrast.status"); + ContrastStatus *contrastStatus = rpiMetadata_.getLocked<ContrastStatus>("contrast.status"); if (contrastStatus) applyGamma(contrastStatus, ctrls); - BlackLevelStatus *blackLevelStatus = rpiMetadata_.GetLocked<BlackLevelStatus>("black_level.status"); + BlackLevelStatus *blackLevelStatus = rpiMetadata_.getLocked<BlackLevelStatus>("black_level.status"); if (blackLevelStatus) applyBlackLevel(blackLevelStatus, ctrls); - GeqStatus *geqStatus = rpiMetadata_.GetLocked<GeqStatus>("geq.status"); + GeqStatus *geqStatus = rpiMetadata_.getLocked<GeqStatus>("geq.status"); if (geqStatus) applyGEQ(geqStatus, ctrls); - DenoiseStatus *denoiseStatus = rpiMetadata_.GetLocked<DenoiseStatus>("denoise.status"); + DenoiseStatus *denoiseStatus = rpiMetadata_.getLocked<DenoiseStatus>("denoise.status"); if (denoiseStatus) applyDenoise(denoiseStatus, ctrls); - SharpenStatus *sharpenStatus = rpiMetadata_.GetLocked<SharpenStatus>("sharpen.status"); + SharpenStatus *sharpenStatus = rpiMetadata_.getLocked<SharpenStatus>("sharpen.status"); if (sharpenStatus) applySharpen(sharpenStatus, ctrls); - DpcStatus *dpcStatus = rpiMetadata_.GetLocked<DpcStatus>("dpc.status"); + DpcStatus *dpcStatus = rpiMetadata_.getLocked<DpcStatus>("dpc.status"); if (dpcStatus) applyDPC(dpcStatus, ctrls); @@ -1097,13 +1097,13 @@ void IPARPi::fillDeviceStatus(const ControlList &sensorControls) int32_t gainCode = sensorControls.get(V4L2_CID_ANALOGUE_GAIN).get<int32_t>(); int32_t vblank = sensorControls.get(V4L2_CID_VBLANK).get<int32_t>(); - deviceStatus.shutter_speed = helper_->Exposure(exposureLines); - deviceStatus.analogue_gain = helper_->Gain(gainCode); - deviceStatus.frame_length = mode_.height + vblank; + deviceStatus.shutterSpeed = helper_->exposure(exposureLines); + deviceStatus.analogueGain = helper_->gain(gainCode); + deviceStatus.frameLength = mode_.height + vblank; LOG(IPARPI, Debug) << "Metadata - " << deviceStatus; - rpiMetadata_.Set("device.status", deviceStatus); + rpiMetadata_.set("device.status", deviceStatus); } void IPARPi::processStats(unsigned int bufferId) @@ -1117,11 +1117,11 @@ void IPARPi::processStats(unsigned int bufferId) Span<uint8_t> mem = it->second.planes()[0]; bcm2835_isp_stats *stats = reinterpret_cast<bcm2835_isp_stats *>(mem.data()); RPiController::StatisticsPtr statistics = std::make_shared<bcm2835_isp_stats>(*stats); - helper_->Process(statistics, rpiMetadata_); - controller_.Process(statistics, &rpiMetadata_); + helper_->process(statistics, rpiMetadata_); + controller_.process(statistics, &rpiMetadata_); struct AgcStatus agcStatus; - if (rpiMetadata_.Get("agc.status", agcStatus) == 0) { + if (rpiMetadata_.get("agc.status", agcStatus) == 0) { ControlList ctrls(sensorCtrls_); applyAGC(&agcStatus, ctrls); @@ -1131,19 +1131,19 @@ void IPARPi::processStats(unsigned int bufferId) void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls) { - LOG(IPARPI, Debug) << "Applying WB R: " << awbStatus->gain_r << " B: " - << awbStatus->gain_b; + LOG(IPARPI, Debug) << "Applying WB R: " << awbStatus->gainR << " B: " + << awbStatus->gainB; ctrls.set(V4L2_CID_RED_BALANCE, - static_cast<int32_t>(awbStatus->gain_r * 1000)); + static_cast<int32_t>(awbStatus->gainR * 1000)); ctrls.set(V4L2_CID_BLUE_BALANCE, - static_cast<int32_t>(awbStatus->gain_b * 1000)); + static_cast<int32_t>(awbStatus->gainB * 1000)); } void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDuration) { - const Duration minSensorFrameDuration = mode_.min_frame_length * mode_.line_length; - const Duration maxSensorFrameDuration = mode_.max_frame_length * mode_.line_length; + const Duration minSensorFrameDuration = mode_.minFrameLength * mode_.lineLength; + const Duration maxSensorFrameDuration = mode_.maxFrameLength * mode_.lineLength; /* * This will only be applied once AGC recalculations occur. @@ -1164,20 +1164,20 @@ void IPARPi::applyFrameDurations(Duration minFrameDuration, Duration maxFrameDur /* * Calculate the maximum exposure time possible for the AGC to use. - * GetVBlanking() will update maxShutter with the largest exposure + * getVBlanking() will update maxShutter with the largest exposure * value possible. */ Duration maxShutter = Duration::max(); - helper_->GetVBlanking(maxShutter, minFrameDuration_, maxFrameDuration_); + helper_->getVBlanking(maxShutter, minFrameDuration_, maxFrameDuration_); RPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>( - controller_.GetAlgorithm("agc")); - agc->SetMaxShutter(maxShutter); + controller_.getAlgorithm("agc")); + agc->setMaxShutter(maxShutter); } void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) { - int32_t gainCode = helper_->GainCode(agcStatus->analogue_gain); + int32_t gainCode = helper_->gainCode(agcStatus->analogueGain); /* * Ensure anything larger than the max gain code will not be passed to @@ -1186,15 +1186,15 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) */ gainCode = std::min<int32_t>(gainCode, maxSensorGainCode_); - /* GetVBlanking might clip exposure time to the fps limits. */ - Duration exposure = agcStatus->shutter_time; - int32_t vblanking = helper_->GetVBlanking(exposure, minFrameDuration_, maxFrameDuration_); - int32_t exposureLines = helper_->ExposureLines(exposure); + /* getVBlanking might clip exposure time to the fps limits. */ + Duration exposure = agcStatus->shutterTime; + int32_t vblanking = helper_->getVBlanking(exposure, minFrameDuration_, maxFrameDuration_); + int32_t exposureLines = helper_->exposureLines(exposure); LOG(IPARPI, Debug) << "Applying AGC Exposure: " << exposure << " (Shutter lines: " << exposureLines << ", AGC requested " - << agcStatus->shutter_time << ") Gain: " - << agcStatus->analogue_gain << " (Gain Code: " + << agcStatus->shutterTime << ") Gain: " + << agcStatus->analogueGain << " (Gain Code: " << gainCode << ")"; /* @@ -1210,7 +1210,7 @@ void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls) void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls) { ctrls.set(V4L2_CID_DIGITAL_GAIN, - static_cast<int32_t>(dgStatus->digital_gain * 1000)); + static_cast<int32_t>(dgStatus->digitalGain * 1000)); } void IPARPi::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls)
Refactor the source files in src/ipa/raspberrypi/ to match the recommended formatting guidelines for the libcamera project. The vast majority of changes in this commit comprise of switching from snake_case to CamelCase, and starting class member functions with a lower case character. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> --- .../controller/sharpen_algorithm.hpp | 2 +- .../raspberrypi/controller/sharpen_status.h | 2 +- src/ipa/raspberrypi/md_parser.hpp | 34 +-- src/ipa/raspberrypi/md_parser_smia.cpp | 96 +++---- src/ipa/raspberrypi/raspberrypi.cpp | 254 +++++++++--------- 5 files changed, 194 insertions(+), 194 deletions(-)