libcamera: pipeline: raspberrypi: Move StaggeredCtrl to libcamera namespace

The StaggeredCtrl class, part of the Raspberry Pi pipeline handler, is
part of libcamera. Move it to the libcamera namespace to simplify usage
of libcamera APIs.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Naushir Patuck <naush@raspberrypi.com>
This commit is contained in:
Laurent Pinchart 2020-05-12 03:18:02 +03:00
parent 4d536996c7
commit 79c5df21dd
3 changed files with 22 additions and 18 deletions

View file

@ -330,7 +330,7 @@ public:
std::vector<IPABuffer> ipaBuffers_; std::vector<IPABuffer> ipaBuffers_;
/* VCSM allocation helper. */ /* VCSM allocation helper. */
RPi::Vcsm vcsm_; ::RPi::Vcsm vcsm_;
void *lsTable_; void *lsTable_;
RPi::StaggeredCtrl staggeredCtrl_; RPi::StaggeredCtrl staggeredCtrl_;

View file

@ -9,20 +9,19 @@
#include <algorithm> #include <algorithm>
#include <libcamera/controls.h>
#include "log.h" #include "log.h"
#include "utils.h" #include "utils.h"
#include "v4l2_videodevice.h"
/* For logging... */ namespace libcamera {
using libcamera::LogCategory;
using libcamera::LogDebug;
using libcamera::LogInfo;
using libcamera::utils::hex;
LOG_DEFINE_CATEGORY(RPI_S_W); LOG_DEFINE_CATEGORY(RPI_S_W);
namespace RPi { namespace RPi {
void StaggeredCtrl::init(libcamera::V4L2VideoDevice *dev, void StaggeredCtrl::init(V4L2VideoDevice *dev,
std::initializer_list<std::pair<const uint32_t, uint8_t>> delayList) std::initializer_list<std::pair<const uint32_t, uint8_t>> delayList)
{ {
std::lock_guard<std::mutex> lock(lock_); std::lock_guard<std::mutex> lock(lock_);
@ -35,7 +34,7 @@ void StaggeredCtrl::init(libcamera::V4L2VideoDevice *dev,
maxDelay_ = 0; maxDelay_ = 0;
for (auto const &p : delay_) { for (auto const &p : delay_) {
LOG(RPI_S_W, Info) << "Init ctrl " LOG(RPI_S_W, Info) << "Init ctrl "
<< hex(p.first) << " with delay " << utils::hex(p.first) << " with delay "
<< static_cast<int>(p.second); << static_cast<int>(p.second);
maxDelay_ = std::max(maxDelay_, p.second); maxDelay_ = std::max(maxDelay_, p.second);
} }
@ -92,7 +91,7 @@ bool StaggeredCtrl::set(std::initializer_list<std::pair<const uint32_t, int32_t>
return true; return true;
} }
bool StaggeredCtrl::set(libcamera::ControlList &controls) bool StaggeredCtrl::set(ControlList &controls)
{ {
std::lock_guard<std::mutex> lock(lock_); std::lock_guard<std::mutex> lock(lock_);
@ -103,7 +102,7 @@ bool StaggeredCtrl::set(libcamera::ControlList &controls)
ctrl_[p.first][setCount_] = CtrlInfo(p.second.get<int32_t>()); ctrl_[p.first][setCount_] = CtrlInfo(p.second.get<int32_t>());
LOG(RPI_S_W, Debug) << "Setting ctrl " LOG(RPI_S_W, Debug) << "Setting ctrl "
<< hex(p.first) << " to " << utils::hex(p.first) << " to "
<< ctrl_[p.first][setCount_].value << ctrl_[p.first][setCount_].value
<< " at index " << " at index "
<< setCount_; << setCount_;
@ -115,7 +114,7 @@ bool StaggeredCtrl::set(libcamera::ControlList &controls)
int StaggeredCtrl::write() int StaggeredCtrl::write()
{ {
std::lock_guard<std::mutex> lock(lock_); std::lock_guard<std::mutex> lock(lock_);
libcamera::ControlList controls(dev_->controls()); ControlList controls(dev_->controls());
for (auto &p : ctrl_) { for (auto &p : ctrl_) {
int delayDiff = maxDelay_ - delay_[p.first]; int delayDiff = maxDelay_ - delay_[p.first];
@ -126,7 +125,7 @@ int StaggeredCtrl::write()
controls.set(p.first, p.second[index].value); controls.set(p.first, p.second[index].value);
p.second[index].updated = false; p.second[index].updated = false;
LOG(RPI_S_W, Debug) << "Writing ctrl " LOG(RPI_S_W, Debug) << "Writing ctrl "
<< hex(p.first) << " to " << utils::hex(p.first) << " to "
<< p.second[index].value << p.second[index].value
<< " at index " << " at index "
<< index; << index;
@ -149,7 +148,7 @@ void StaggeredCtrl::get(std::unordered_map<uint32_t, int32_t> &ctrl, uint8_t off
int index = std::max<int>(0, getCount_ - maxDelay_); int index = std::max<int>(0, getCount_ - maxDelay_);
ctrl[p.first] = p.second[index].value; ctrl[p.first] = p.second[index].value;
LOG(RPI_S_W, Debug) << "Getting ctrl " LOG(RPI_S_W, Debug) << "Getting ctrl "
<< hex(p.first) << " to " << utils::hex(p.first) << " to "
<< p.second[index].value << p.second[index].value
<< " at index " << " at index "
<< index; << index;
@ -171,3 +170,5 @@ void StaggeredCtrl::nextFrame()
} }
} /* namespace RPi */ } /* namespace RPi */
} /* namespace libcamera */

View file

@ -12,9 +12,10 @@
#include <unordered_map> #include <unordered_map>
#include <utility> #include <utility>
#include <libcamera/controls.h> namespace libcamera {
#include "v4l2_videodevice.h" class ControlList;
class V4L2VideoDevice;
namespace RPi { namespace RPi {
@ -31,7 +32,7 @@ public:
return init_; return init_;
} }
void init(libcamera::V4L2VideoDevice *dev, void init(V4L2VideoDevice *dev,
std::initializer_list<std::pair<const uint32_t, uint8_t>> delayList); std::initializer_list<std::pair<const uint32_t, uint8_t>> delayList);
void reset(); void reset();
@ -39,7 +40,7 @@ public:
bool set(uint32_t ctrl, int32_t value); bool set(uint32_t ctrl, int32_t value);
bool set(std::initializer_list<std::pair<const uint32_t, int32_t>> ctrlList); bool set(std::initializer_list<std::pair<const uint32_t, int32_t>> ctrlList);
bool set(libcamera::ControlList &controls); bool set(ControlList &controls);
int write(); int write();
@ -81,10 +82,12 @@ private:
uint32_t setCount_; uint32_t setCount_;
uint32_t getCount_; uint32_t getCount_;
uint8_t maxDelay_; uint8_t maxDelay_;
libcamera::V4L2VideoDevice *dev_; V4L2VideoDevice *dev_;
std::unordered_map<uint32_t, uint8_t> delay_; std::unordered_map<uint32_t, uint8_t> delay_;
std::unordered_map<uint32_t, CircularArray> ctrl_; std::unordered_map<uint32_t, CircularArray> ctrl_;
std::mutex lock_; std::mutex lock_;
}; };
} /* namespace RPi */ } /* namespace RPi */
} /* namespace libcamera */