summaryrefslogtreecommitdiff
path: root/src/ipa/rkisp1/rkisp1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ipa/rkisp1/rkisp1.cpp')
-rw-r--r--src/ipa/rkisp1/rkisp1.cpp114
1 files changed, 65 insertions, 49 deletions
diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp
index 07d7f1b2..b881d42e 100644
--- a/src/ipa/rkisp1/rkisp1.cpp
+++ b/src/ipa/rkisp1/rkisp1.cpp
@@ -15,39 +15,34 @@
#include <linux/rkisp1-config.h>
#include <linux/v4l2-controls.h>
-#include <libcamera/buffer.h>
+#include <libcamera/base/log.h>
+
#include <libcamera/control_ids.h>
+#include <libcamera/framebuffer.h>
#include <libcamera/ipa/ipa_interface.h>
#include <libcamera/ipa/ipa_module_info.h>
-#include <libcamera/ipa/rkisp1.h>
+#include <libcamera/ipa/rkisp1_ipa_interface.h>
#include <libcamera/request.h>
-#include <libipa/ipa_interface_wrapper.h>
-
-#include "libcamera/internal/log.h"
-
namespace libcamera {
LOG_DEFINE_CATEGORY(IPARkISP1)
-class IPARkISP1 : public IPAInterface
+namespace ipa::rkisp1 {
+
+class IPARkISP1 : public IPARkISP1Interface
{
public:
- int init([[maybe_unused]] const IPASettings &settings) override
- {
- return 0;
- }
- int start() override { return 0; }
+ int init(unsigned int hwRevision) override;
+ int start() override;
void stop() override {}
- void configure(const CameraSensorInfo &info,
- const std::map<unsigned int, IPAStream> &streamConfig,
- const std::map<unsigned int, const ControlInfoMap &> &entityControls,
- const IPAOperationData &ipaConfig,
- IPAOperationData *response) override;
+ int configure(const IPACameraSensorInfo &info,
+ const std::map<uint32_t, IPAStream> &streamConfig,
+ const std::map<uint32_t, ControlInfoMap> &entityControls) override;
void mapBuffers(const std::vector<IPABuffer> &buffers) override;
void unmapBuffers(const std::vector<unsigned int> &ids) override;
- void processEvent(const IPAOperationData &event) override;
+ void processEvent(const RkISP1Event &event) override;
private:
void queueRequest(unsigned int frame, rkisp1_params_cfg *params,
@@ -73,33 +68,52 @@ private:
uint32_t maxGain_;
};
+int IPARkISP1::init(unsigned int hwRevision)
+{
+ /* \todo Add support for other revisions */
+ if (hwRevision != RKISP1_V10) {
+ LOG(IPARkISP1, Error)
+ << "Hardware revision " << hwRevision
+ << " is currently not supported";
+ return -ENODEV;
+ }
+
+ LOG(IPARkISP1, Debug) << "Hardware revision is " << hwRevision;
+ return 0;
+}
+
+int IPARkISP1::start()
+{
+ setControls(0);
+
+ return 0;
+}
+
/**
- * \todo The RkISP1 pipeline currently provides an empty CameraSensorInfo
+ * \todo The RkISP1 pipeline currently provides an empty IPACameraSensorInfo
* if the connected sensor does not provide enough information to properly
* assemble one. Make sure the reported sensor information are relevant
* before accessing them.
*/
-void IPARkISP1::configure([[maybe_unused]] const CameraSensorInfo &info,
- [[maybe_unused]] const std::map<unsigned int, IPAStream> &streamConfig,
- const std::map<unsigned int, const ControlInfoMap &> &entityControls,
- [[maybe_unused]] const IPAOperationData &ipaConfig,
- [[maybe_unused]] IPAOperationData *result)
+int IPARkISP1::configure([[maybe_unused]] const IPACameraSensorInfo &info,
+ [[maybe_unused]] const std::map<uint32_t, IPAStream> &streamConfig,
+ const std::map<uint32_t, ControlInfoMap> &entityControls)
{
if (entityControls.empty())
- return;
+ return -EINVAL;
ctrls_ = entityControls.at(0);
const auto itExp = ctrls_.find(V4L2_CID_EXPOSURE);
if (itExp == ctrls_.end()) {
LOG(IPARkISP1, Error) << "Can't find exposure control";
- return;
+ return -EINVAL;
}
const auto itGain = ctrls_.find(V4L2_CID_ANALOGUE_GAIN);
if (itGain == ctrls_.end()) {
LOG(IPARkISP1, Error) << "Can't find gain control";
- return;
+ return -EINVAL;
}
autoExposure_ = true;
@@ -116,7 +130,7 @@ void IPARkISP1::configure([[maybe_unused]] const CameraSensorInfo &info,
<< "Exposure: " << minExposure_ << "-" << maxExposure_
<< " Gain: " << minGain_ << "-" << maxGain_;
- setControls(0);
+ return 0;
}
void IPARkISP1::mapBuffers(const std::vector<IPABuffer> &buffers)
@@ -159,12 +173,12 @@ void IPARkISP1::unmapBuffers(const std::vector<unsigned int> &ids)
}
}
-void IPARkISP1::processEvent(const IPAOperationData &event)
+void IPARkISP1::processEvent(const RkISP1Event &event)
{
- switch (event.operation) {
- case RKISP1_IPA_EVENT_SIGNAL_STAT_BUFFER: {
- unsigned int frame = event.data[0];
- unsigned int bufferId = event.data[1];
+ switch (event.op) {
+ case EventSignalStatBuffer: {
+ unsigned int frame = event.frame;
+ unsigned int bufferId = event.bufferId;
const rkisp1_stat_buffer *stats =
static_cast<rkisp1_stat_buffer *>(buffersMemory_[bufferId]);
@@ -172,18 +186,18 @@ void IPARkISP1::processEvent(const IPAOperationData &event)
updateStatistics(frame, stats);
break;
}
- case RKISP1_IPA_EVENT_QUEUE_REQUEST: {
- unsigned int frame = event.data[0];
- unsigned int bufferId = event.data[1];
+ case EventQueueRequest: {
+ unsigned int frame = event.frame;
+ unsigned int bufferId = event.bufferId;
rkisp1_params_cfg *params =
static_cast<rkisp1_params_cfg *>(buffersMemory_[bufferId]);
- queueRequest(frame, params, event.controls[0]);
+ queueRequest(frame, params, event.controls);
break;
}
default:
- LOG(IPARkISP1, Error) << "Unknown event " << event.operation;
+ LOG(IPARkISP1, Error) << "Unknown event " << event.op;
break;
}
}
@@ -203,8 +217,8 @@ void IPARkISP1::queueRequest(unsigned int frame, rkisp1_params_cfg *params,
params->module_en_update = RKISP1_CIF_ISP_MODULE_AEC;
}
- IPAOperationData op;
- op.operation = RKISP1_IPA_ACTION_PARAM_FILLED;
+ RkISP1Action op;
+ op.op = ActionParamFilled;
queueFrameAction.emit(frame, op);
}
@@ -222,7 +236,7 @@ void IPARkISP1::updateStatistics(unsigned int frame,
unsigned int value = 0;
unsigned int num = 0;
- for (int i = 0; i < RKISP1_CIF_ISP_AE_MEAN_MAX; i++) {
+ for (int i = 0; i < RKISP1_CIF_ISP_AE_MEAN_MAX_V10; i++) {
if (ae->exp_mean[i] <= 15)
continue;
@@ -256,13 +270,13 @@ void IPARkISP1::updateStatistics(unsigned int frame,
void IPARkISP1::setControls(unsigned int frame)
{
- IPAOperationData op;
- op.operation = RKISP1_IPA_ACTION_V4L2_SET;
+ RkISP1Action op;
+ op.op = ActionV4L2Set;
ControlList ctrls(ctrls_);
ctrls.set(V4L2_CID_EXPOSURE, static_cast<int32_t>(exposure_));
ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast<int32_t>(gain_));
- op.controls.push_back(ctrls);
+ op.controls = ctrls;
queueFrameAction.emit(frame, op);
}
@@ -274,13 +288,15 @@ void IPARkISP1::metadataReady(unsigned int frame, unsigned int aeState)
if (aeState)
ctrls.set(controls::AeLocked, aeState == 2);
- IPAOperationData op;
- op.operation = RKISP1_IPA_ACTION_METADATA;
- op.controls.push_back(ctrls);
+ RkISP1Action op;
+ op.op = ActionMetadata;
+ op.controls = ctrls;
queueFrameAction.emit(frame, op);
}
+} /* namespace ipa::rkisp1 */
+
/*
* External IPA module interface
*/
@@ -293,9 +309,9 @@ const struct IPAModuleInfo ipaModuleInfo = {
"rkisp1",
};
-struct ipa_context *ipaCreate()
+IPAInterface *ipaCreate()
{
- return new IPAInterfaceWrapper(std::make_unique<IPARkISP1>());
+ return new ipa::rkisp1::IPARkISP1();
}
}