ipa: rkisp1: Convert to use the FCQueue

Establish a queue of FrameContexts using the new FCQueue and use it to
supply the FrameContext to the algorithms.

The algorithms on the RKISP1 do not use this yet themselves, but are
able to do so after the introduction of this patch.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
This commit is contained in:
Kieran Bingham 2022-07-21 13:13:05 +01:00 committed by Laurent Pinchart
parent 9f5ab89fb3
commit 05e6a19373
3 changed files with 29 additions and 13 deletions

View file

@ -205,8 +205,7 @@ namespace libcamera::ipa::rkisp1 {
* \struct IPAFrameContext * \struct IPAFrameContext
* \brief Per-frame context for algorithms * \brief Per-frame context for algorithms
* *
* This structure is currently unused and will be replaced by a real per-frame * \todo Populate the frame context for all algorithms
* context.
*/ */
/** /**
@ -219,7 +218,8 @@ namespace libcamera::ipa::rkisp1 {
* \var IPAContext::activeState * \var IPAContext::activeState
* \brief The IPA active state, storing the latest state for all algorithms * \brief The IPA active state, storing the latest state for all algorithms
* *
* \todo Introduce per-frame contexts * \var IPAContext::frameContexts
* \brief Ring buffer of per-frame contexts
*/ */
} /* namespace libcamera::ipa::rkisp1 */ } /* namespace libcamera::ipa::rkisp1 */

View file

@ -97,6 +97,8 @@ struct IPAFrameContext : public FrameContext {
struct IPAContext { struct IPAContext {
IPASessionConfiguration configuration; IPASessionConfiguration configuration;
IPAActiveState activeState; IPAActiveState activeState;
FCQueue<IPAFrameContext> frameContexts;
}; };
} /* namespace ipa::rkisp1 */ } /* namespace ipa::rkisp1 */

View file

@ -40,13 +40,18 @@ using namespace std::literals::chrono_literals;
namespace ipa::rkisp1 { namespace ipa::rkisp1 {
/* Maximum number of frame contexts to be held */
static constexpr uint32_t kMaxFrameContexts = 16;
class IPARkISP1 : public IPARkISP1Interface, public Module class IPARkISP1 : public IPARkISP1Interface, public Module
{ {
public: public:
IPARkISP1();
int init(const IPASettings &settings, unsigned int hwRevision, int init(const IPASettings &settings, unsigned int hwRevision,
ControlInfoMap *ipaControls) override; ControlInfoMap *ipaControls) override;
int start() override; int start() override;
void stop() override {} void stop() override;
int configure(const IPACameraSensorInfo &info, int configure(const IPACameraSensorInfo &info,
const std::map<uint32_t, IPAStream> &streamConfig, const std::map<uint32_t, IPAStream> &streamConfig,
@ -100,6 +105,11 @@ const ControlInfoMap::Map rkisp1Controls{
} /* namespace */ } /* namespace */
IPARkISP1::IPARkISP1()
: context_({ {}, {}, { kMaxFrameContexts } })
{
}
std::string IPARkISP1::logPrefix() const std::string IPARkISP1::logPrefix() const
{ {
return "rkisp1"; return "rkisp1";
@ -185,6 +195,11 @@ int IPARkISP1::start()
return 0; return 0;
} }
void IPARkISP1::stop()
{
context_.frameContexts.clear();
}
/** /**
* \todo The RkISP1 pipeline currently provides an empty IPACameraSensorInfo * \todo The RkISP1 pipeline currently provides an empty IPACameraSensorInfo
* if the connected sensor does not provide enough information to properly * if the connected sensor does not provide enough information to properly
@ -222,8 +237,10 @@ int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,
<< "Exposure: " << minExposure << "-" << maxExposure << "Exposure: " << minExposure << "-" << maxExposure
<< " Gain: " << minGain << "-" << maxGain; << " Gain: " << minGain << "-" << maxGain;
/* Clean context at configuration */ /* Clear the IPA context before the streaming session. */
context_ = {}; context_.configuration = {};
context_.activeState = {};
context_.frameContexts.clear();
/* Set the hardware revision for the algorithms. */ /* Set the hardware revision for the algorithms. */
context_.configuration.hw.revision = hwRevision_; context_.configuration.hw.revision = hwRevision_;
@ -286,8 +303,7 @@ void IPARkISP1::unmapBuffers(const std::vector<unsigned int> &ids)
void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls) void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls)
{ {
/* \todo Obtain the frame context to pass to process from the FCQueue */ IPAFrameContext &frameContext = context_.frameContexts.alloc(frame);
IPAFrameContext frameContext;
for (auto const &algo : algorithms()) for (auto const &algo : algorithms())
algo->queueRequest(context_, frame, frameContext, controls); algo->queueRequest(context_, frame, frameContext, controls);
@ -295,8 +311,7 @@ void IPARkISP1::queueRequest(const uint32_t frame, const ControlList &controls)
void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId) void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
{ {
/* \todo Obtain the frame context to pass to process from the FCQueue */ IPAFrameContext &frameContext = context_.frameContexts.get(frame);
IPAFrameContext frameContext;
rkisp1_params_cfg *params = rkisp1_params_cfg *params =
reinterpret_cast<rkisp1_params_cfg *>( reinterpret_cast<rkisp1_params_cfg *>(
@ -315,6 +330,8 @@ void IPARkISP1::fillParamsBuffer(const uint32_t frame, const uint32_t bufferId)
void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId, void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId,
const ControlList &sensorControls) const ControlList &sensorControls)
{ {
IPAFrameContext &frameContext = context_.frameContexts.get(frame);
const rkisp1_stat_buffer *stats = const rkisp1_stat_buffer *stats =
reinterpret_cast<rkisp1_stat_buffer *>( reinterpret_cast<rkisp1_stat_buffer *>(
mappedBuffers_.at(bufferId).planes()[0].data()); mappedBuffers_.at(bufferId).planes()[0].data());
@ -326,9 +343,6 @@ void IPARkISP1::processStatsBuffer(const uint32_t frame, const uint32_t bufferId
unsigned int aeState = 0; unsigned int aeState = 0;
/* \todo Obtain the frame context to pass to process from the FCQueue */
IPAFrameContext frameContext;
for (auto const &algo : algorithms()) for (auto const &algo : algorithms())
algo->process(context_, frame, frameContext, stats); algo->process(context_, frame, frameContext, stats);