From patchwork Fri Oct 2 14:31:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 9938 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 458A9C3B5C for ; Fri, 2 Oct 2020 14:33:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 07BFD63BEB; Fri, 2 Oct 2020 16:33:20 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="gD32idcq"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9D97463B98 for ; Fri, 2 Oct 2020 16:33:18 +0200 (CEST) Received: from pyrite.rasen.tech (unknown [IPv6:2400:4051:61:600:2c71:1b79:d06d:5032]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D533D528; Fri, 2 Oct 2020 16:33:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1601649198; bh=Gqh9QvK3Bz3MWys9flkv82+i8FHoEgR802cEUCwnb7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gD32idcqsmpIHPXPF0/8Q57jT1QhQEKZTzoqCS8TFEznMdQJKGSQdc+hdRUG7zvDf itvBPP1NBYH6E3vlnnUrLETlJ9aMI44rvlTYAtNh7fExsYE0Ll60hnErwBb/AB73VR 2fG4i5DZ24yAG/RbUQG4jU1wW22D8HVEUQ5uUl7k= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Fri, 2 Oct 2020 23:31:46 +0900 Message-Id: <20201002143154.468162-31-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201002143154.468162-1-paul.elder@ideasonboard.com> References: <20201002143154.468162-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 30/38] libcamera: pipeline, ipa: rkisp1: Support the new IPC mechanism X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add support to the rkisp1 pipeline handler and IPA for the new IPC mechanism. Signed-off-by: Paul Elder --- Changes in v3: - change namespacing of base ControlInfoMap structure New in v2 --- include/libcamera/ipa/meson.build | 1 + include/libcamera/ipa/rkisp1.h | 18 ++++---- include/libcamera/ipa/rkisp1.mojom | 42 +++++++++++++++++++ src/ipa/rkisp1/meson.build | 2 +- src/ipa/rkisp1/rkisp1.cpp | 53 +++++++++++------------- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 44 +++++++++++--------- 6 files changed, 104 insertions(+), 56 deletions(-) create mode 100644 include/libcamera/ipa/rkisp1.mojom diff --git a/include/libcamera/ipa/meson.build b/include/libcamera/ipa/meson.build index 886908ad..32f9e321 100644 --- a/include/libcamera/ipa/meson.build +++ b/include/libcamera/ipa/meson.build @@ -26,6 +26,7 @@ ipa_mojom_core = custom_target(core_mojom_file.split('.')[0] + '_mojom_module', ipa_mojom_files = [ 'raspberrypi.mojom', + 'rkisp1.mojom', 'vimc.mojom', ] diff --git a/include/libcamera/ipa/rkisp1.h b/include/libcamera/ipa/rkisp1.h index 4fe0482b..bbe6e95e 100644 --- a/include/libcamera/ipa/rkisp1.h +++ b/include/libcamera/ipa/rkisp1.h @@ -7,12 +7,16 @@ #ifndef __LIBCAMERA_IPA_INTERFACE_RKISP1_H__ #define __LIBCAMERA_IPA_INTERFACE_RKISP1_H__ -enum RkISP1Operations { - RKISP1_IPA_ACTION_V4L2_SET = 1, - RKISP1_IPA_ACTION_PARAM_FILLED = 2, - RKISP1_IPA_ACTION_METADATA = 3, - RKISP1_IPA_EVENT_SIGNAL_STAT_BUFFER = 4, - RKISP1_IPA_EVENT_QUEUE_REQUEST = 5, -}; +#include + +namespace libcamera { + +namespace RkISP1 { + +static ControlInfoMap Controls; + +} + +} /* namespace libcamera */ #endif /* __LIBCAMERA_IPA_INTERFACE_RKISP1_H__ */ diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom new file mode 100644 index 00000000..df76ee6f --- /dev/null +++ b/include/libcamera/ipa/rkisp1.mojom @@ -0,0 +1,42 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ + +import "include/libcamera/ipa/core.mojom"; + +interface IPARkISP1Interface { + init(IPASettings settings) => (int32 ret); + start() => (int32 ret); + stop(); + + configure(CameraSensorInfo sensorInfo, + map streamConfig, + map entityControls) => (); + + mapBuffers(array buffers); + unmapBuffers(array ids); + + [async] processEvent(RkISP1Event ev); +}; + +interface IPARkISP1CallbackInterface { + queueFrameAction(uint32 frame, RkISP1Action action); +}; + +enum RkISP1Operations { + RKISP1_IPA_ACTION_V4L2_SET, + RKISP1_IPA_ACTION_PARAM_FILLED, + RKISP1_IPA_ACTION_METADATA, + RKISP1_IPA_EVENT_SIGNAL_STAT_BUFFER, + RKISP1_IPA_EVENT_QUEUE_REQUEST, +}; + +struct RkISP1Event { + RkISP1Operations op; + uint32 frame; + uint32 bufferId; + ControlList controls; +}; + +struct RkISP1Action { + RkISP1Operations op; + ControlList controls; +}; diff --git a/src/ipa/rkisp1/meson.build b/src/ipa/rkisp1/meson.build index ed9a6b6b..30953c13 100644 --- a/src/ipa/rkisp1/meson.build +++ b/src/ipa/rkisp1/meson.build @@ -3,7 +3,7 @@ ipa_name = 'ipa_rkisp1' mod = shared_module(ipa_name, - 'rkisp1.cpp', + ['rkisp1.cpp', libcamera_generated_headers], name_prefix : '', include_directories : [ipa_includes, libipa_includes], dependencies : libcamera_dep, diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 07d7f1b2..4fec397b 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -30,7 +31,7 @@ namespace libcamera { LOG_DEFINE_CATEGORY(IPARkISP1) -class IPARkISP1 : public IPAInterface +class IPARkISP1 : public IPARkISP1Interface { public: int init([[maybe_unused]] const IPASettings &settings) override @@ -41,13 +42,11 @@ public: void stop() override {} void configure(const CameraSensorInfo &info, - const std::map &streamConfig, - const std::map &entityControls, - const IPAOperationData &ipaConfig, - IPAOperationData *response) override; + const std::map &streamConfig, + const std::map &entityControls) override; void mapBuffers(const std::vector &buffers) override; void unmapBuffers(const std::vector &ids) override; - void processEvent(const IPAOperationData &event) override; + void processEvent(const RkISP1Event &event) override; private: void queueRequest(unsigned int frame, rkisp1_params_cfg *params, @@ -80,10 +79,8 @@ private: * before accessing them. */ void IPARkISP1::configure([[maybe_unused]] const CameraSensorInfo &info, - [[maybe_unused]] const std::map &streamConfig, - const std::map &entityControls, - [[maybe_unused]] const IPAOperationData &ipaConfig, - [[maybe_unused]] IPAOperationData *result) + [[maybe_unused]] const std::map &streamConfig, + const std::map &entityControls) { if (entityControls.empty()) return; @@ -159,12 +156,12 @@ void IPARkISP1::unmapBuffers(const std::vector &ids) } } -void IPARkISP1::processEvent(const IPAOperationData &event) +void IPARkISP1::processEvent(const RkISP1Event &event) { - switch (event.operation) { + switch (event.op_) { case RKISP1_IPA_EVENT_SIGNAL_STAT_BUFFER: { - unsigned int frame = event.data[0]; - unsigned int bufferId = event.data[1]; + unsigned int frame = event.frame_; + unsigned int bufferId = event.bufferId_; const rkisp1_stat_buffer *stats = static_cast(buffersMemory_[bufferId]); @@ -173,17 +170,17 @@ void IPARkISP1::processEvent(const IPAOperationData &event) break; } case RKISP1_IPA_EVENT_QUEUE_REQUEST: { - unsigned int frame = event.data[0]; - unsigned int bufferId = event.data[1]; + unsigned int frame = event.frame_; + unsigned int bufferId = event.bufferId_; rkisp1_params_cfg *params = static_cast(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 +200,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_ = RKISP1_IPA_ACTION_PARAM_FILLED; queueFrameAction.emit(frame, op); } @@ -256,13 +253,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_ = RKISP1_IPA_ACTION_V4L2_SET; ControlList ctrls(ctrls_); ctrls.set(V4L2_CID_EXPOSURE, static_cast(exposure_)); ctrls.set(V4L2_CID_ANALOGUE_GAIN, static_cast(gain_)); - op.controls.push_back(ctrls); + op.controls_ = ctrls; queueFrameAction.emit(frame, op); } @@ -274,9 +271,9 @@ 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_ = RKISP1_IPA_ACTION_METADATA; + op.controls_ = ctrls; queueFrameAction.emit(frame, op); } @@ -293,9 +290,9 @@ const struct IPAModuleInfo ipaModuleInfo = { "rkisp1", }; -struct ipa_context *ipaCreate() +IPAInterface *ipaCreate() { - return new IPAInterfaceWrapper(std::make_unique()); + return new IPARkISP1(); } } diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index aec590ff..74812302 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -19,6 +19,8 @@ #include #include #include +#include +#include #include #include @@ -144,9 +146,11 @@ public: RkISP1MainPath *mainPath_; RkISP1SelfPath *selfPath_; + std::unique_ptr ipa_; + private: void queueFrameAction(unsigned int frame, - const IPAOperationData &action); + const RkISP1Action &action); void metadataReady(unsigned int frame, const ControlList &metadata); }; @@ -412,7 +416,7 @@ private: int RkISP1CameraData::loadIPA() { - ipa_ = IPAManager::createIPA(pipe_, 1, 1); + ipa_ = IPAManager::createIPA(pipe_, 1, 1); if (!ipa_) return -ENOENT; @@ -425,11 +429,11 @@ int RkISP1CameraData::loadIPA() } void RkISP1CameraData::queueFrameAction(unsigned int frame, - const IPAOperationData &action) + const RkISP1Action &action) { - switch (action.operation) { + switch (action.op_) { case RKISP1_IPA_ACTION_V4L2_SET: { - const ControlList &controls = action.controls[0]; + const ControlList &controls = action.controls_; timeline_.scheduleAction(std::make_unique(frame, sensor_, controls)); @@ -442,10 +446,10 @@ void RkISP1CameraData::queueFrameAction(unsigned int frame, break; } case RKISP1_IPA_ACTION_METADATA: - metadataReady(frame, action.controls[0]); + metadataReady(frame, action.controls_); break; default: - LOG(RkISP1, Error) << "Unknown action " << action.operation; + LOG(RkISP1, Error) << "Unknown action " << action.op_; break; } } @@ -908,12 +912,10 @@ int PipelineHandlerRkISP1::start(Camera *camera) ret = 0; } - std::map entityControls; + std::map entityControls; entityControls.emplace(0, data->sensor_->controls()); - IPAOperationData ipaConfig; - data->ipa_->configure(sensorInfo, streamConfig, entityControls, - ipaConfig, nullptr); + data->ipa_->configure(sensorInfo, streamConfig, entityControls); return ret; } @@ -955,11 +957,12 @@ int PipelineHandlerRkISP1::queueRequestDevice(Camera *camera, Request *request) if (!info) return -ENOENT; - IPAOperationData op; - op.operation = RKISP1_IPA_EVENT_QUEUE_REQUEST; - op.data = { data->frame_, info->paramBuffer->cookie() }; - op.controls = { request->controls() }; - data->ipa_->processEvent(op); + RkISP1Event ev; + ev.op_ = RKISP1_IPA_EVENT_QUEUE_REQUEST; + ev.frame_ = data->frame_; + ev.bufferId_ = info->paramBuffer->cookie(); + ev.controls_ = request->controls(); + data->ipa_->processEvent(ev); data->timeline_.scheduleAction(std::make_unique(data->frame_, data, @@ -1178,10 +1181,11 @@ void PipelineHandlerRkISP1::statReady(FrameBuffer *buffer) if (data->frame_ <= buffer->metadata().sequence) data->frame_ = buffer->metadata().sequence + 1; - IPAOperationData op; - op.operation = RKISP1_IPA_EVENT_SIGNAL_STAT_BUFFER; - op.data = { info->frame, info->statBuffer->cookie() }; - data->ipa_->processEvent(op); + RkISP1Event ev; + ev.op_ = RKISP1_IPA_EVENT_SIGNAL_STAT_BUFFER; + ev.frame_ = info->frame; + ev.bufferId_ = info->statBuffer->cookie(); + data->ipa_->processEvent(ev); } REGISTER_PIPELINE_HANDLER(PipelineHandlerRkISP1);