From patchwork Tue Mar 9 06:38:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11527 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 2A162BD1F1 for ; Tue, 9 Mar 2021 06:38:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 50AA768AA3; Tue, 9 Mar 2021 07:38:39 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D0C116051F for ; Tue, 9 Mar 2021 07:38:37 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 9D9041F45216 From: Dafna Hirschfeld To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Mar 2021 07:38:27 +0100 Message-Id: <20210309063829.8710-2-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210309063829.8710-1-dafna.hirschfeld@collabora.com> References: <20210309063829.8710-1-dafna.hirschfeld@collabora.com> Subject: [libcamera-devel] [PATCH v3 1/3] libcamera: media_device: add hwRevision method 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: , Cc: kernel@collabora.com MIME-Version: 1.0 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a method 'hwRevision' to return the info.hw_version reported by the driver. Signed-off-by: Dafna Hirschfeld Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- include/libcamera/internal/media_device.h | 2 ++ src/libcamera/media_device.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/include/libcamera/internal/media_device.h b/include/libcamera/internal/media_device.h index d0459cde..c3292508 100644 --- a/include/libcamera/internal/media_device.h +++ b/include/libcamera/internal/media_device.h @@ -41,6 +41,7 @@ public: const std::string deviceNode() const { return deviceNode_; } const std::string model() const { return model_; } unsigned int version() const { return version_; } + unsigned int hwRevision() const { return hwRevision_; } const std::vector &entities() const { return entities_; } MediaEntity *getEntityByName(const std::string &name) const; @@ -79,6 +80,7 @@ private: std::string deviceNode_; std::string model_; unsigned int version_; + unsigned int hwRevision_; int fd_; bool valid_; diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp index 8987de12..3c8ccd81 100644 --- a/src/libcamera/media_device.cpp +++ b/src/libcamera/media_device.cpp @@ -231,6 +231,7 @@ int MediaDevice::populate() driver_ = info.driver; model_ = info.model; version_ = info.media_version; + hwRevision_ = info.hw_revision; /* * Keep calling G_TOPOLOGY until the version number stays stable. @@ -323,6 +324,15 @@ done: * \return The MediaDevice API version */ +/** + * \fn MediaDevice::hwRevision() + * \brief Retrieve the media device hardware revision + * + * The hardware revision is in a driver-specific format. + * + * \return The MediaDevice API hardware revision + */ + /** * \fn MediaDevice::entities() * \brief Retrieve the list of entities in the media graph From patchwork Tue Mar 9 06:38:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11529 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 7A9F4BD1F1 for ; Tue, 9 Mar 2021 06:38:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 39F6D68AAA; Tue, 9 Mar 2021 07:38:42 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 73B5A68AA5 for ; Tue, 9 Mar 2021 07:38:39 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id 165061F45217 From: Dafna Hirschfeld To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Mar 2021 07:38:28 +0100 Message-Id: <20210309063829.8710-3-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210309063829.8710-1-dafna.hirschfeld@collabora.com> References: <20210309063829.8710-1-dafna.hirschfeld@collabora.com> Subject: [libcamera-devel] [PATCH v3 2/3] src: rkisp1: return error from ipa's configure method if it fails 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: , Cc: kernel@collabora.com MIME-Version: 1.0 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The IPA of rkisp1 relies on some of the camera's controls. Therefore it can't work if those controls are not given. Return -EINVAL from 'configure' in that case. Also return error from the pipeline's 'configure' method if the IPA configure fails. Signed-off-by: Dafna Hirschfeld Reviewed-by: Paul Elder Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/rkisp1.mojom | 2 +- src/ipa/rkisp1/rkisp1.cpp | 11 ++++++----- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 7 +++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index 9270f9c7..95fa0d93 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -31,7 +31,7 @@ interface IPARkISP1Interface { configure(CameraSensorInfo sensorInfo, map streamConfig, - map entityControls) => (); + map entityControls) => (int32 ret); mapBuffers(array buffers); unmapBuffers(array ids); diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index f11aeb40..0b0f31e4 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -38,7 +38,7 @@ public: int start() override { return 0; } void stop() override {} - void configure(const CameraSensorInfo &info, + int configure(const CameraSensorInfo &info, const std::map &streamConfig, const std::map &entityControls) override; void mapBuffers(const std::vector &buffers) override; @@ -75,25 +75,25 @@ private: * assemble one. Make sure the reported sensor information are relevant * before accessing them. */ -void IPARkISP1::configure([[maybe_unused]] const CameraSensorInfo &info, +int IPARkISP1::configure([[maybe_unused]] const CameraSensorInfo &info, [[maybe_unused]] const std::map &streamConfig, const std::map &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; @@ -111,6 +111,7 @@ void IPARkISP1::configure([[maybe_unused]] const CameraSensorInfo &info, << " Gain: " << minGain_ << "-" << maxGain_; setControls(0); + return 0; } void IPARkISP1::mapBuffers(const std::vector &buffers) diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 538c0139..34814f62 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -653,8 +653,11 @@ int PipelineHandlerRkISP1::configure(Camera *camera, CameraConfiguration *c) std::map entityControls; entityControls.emplace(0, data->sensor_->controls()); - data->ipa_->configure(sensorInfo, streamConfig, entityControls); - + ret = data->ipa_->configure(sensorInfo, streamConfig, entityControls); + if (ret) { + LOG(RkISP1, Error) << "failed configuring IPA (" << ret << ")"; + return ret; + } return 0; } From patchwork Tue Mar 9 06:38:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dafna Hirschfeld X-Patchwork-Id: 11530 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 004B6BD80E for ; Tue, 9 Mar 2021 06:38:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9B9FD68AAC; Tue, 9 Mar 2021 07:38:42 +0100 (CET) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9347C68AA7 for ; Tue, 9 Mar 2021 07:38:39 +0100 (CET) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: dafna) with ESMTPSA id B8B881F4521B From: Dafna Hirschfeld To: libcamera-devel@lists.libcamera.org Date: Tue, 9 Mar 2021 07:38:29 +0100 Message-Id: <20210309063829.8710-4-dafna.hirschfeld@collabora.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210309063829.8710-1-dafna.hirschfeld@collabora.com> References: <20210309063829.8710-1-dafna.hirschfeld@collabora.com> Subject: [libcamera-devel] [PATCH v3 3/3] ipa: rkisp1: fail on init if hw revision is not RKISP1_V10 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: , Cc: kernel@collabora.com MIME-Version: 1.0 Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In kernel 5.11 the rkisp1 uapi had changed to support different hardware revisions. Currently only revision 10 is supported by the rkisp1 IPA and therefore 'init' should fail if the revision is not 10. Signed-off-by: Dafna Hirschfeld Reviewed-by: Laurent Pinchart --- include/libcamera/ipa/rkisp1.mojom | 2 +- src/ipa/rkisp1/rkisp1.cpp | 17 +++++++++++++---- src/libcamera/pipeline/rkisp1/rkisp1.cpp | 10 ++++------ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/include/libcamera/ipa/rkisp1.mojom b/include/libcamera/ipa/rkisp1.mojom index 95fa0d93..29f726e1 100644 --- a/include/libcamera/ipa/rkisp1.mojom +++ b/include/libcamera/ipa/rkisp1.mojom @@ -25,7 +25,7 @@ struct RkISP1Action { }; interface IPARkISP1Interface { - init(IPASettings settings) => (int32 ret); + init(uint32 hwRevision) => (int32 ret); start() => (int32 ret); stop(); diff --git a/src/ipa/rkisp1/rkisp1.cpp b/src/ipa/rkisp1/rkisp1.cpp index 0b0f31e4..197c2389 100644 --- a/src/ipa/rkisp1/rkisp1.cpp +++ b/src/ipa/rkisp1/rkisp1.cpp @@ -31,10 +31,7 @@ LOG_DEFINE_CATEGORY(IPARkISP1) class IPARkISP1 : public ipa::rkisp1::IPARkISP1Interface { public: - int init([[maybe_unused]] const IPASettings &settings) override - { - return 0; - } + int init(unsigned int hwRevision) override; int start() override { return 0; } void stop() override {} @@ -69,6 +66,18 @@ private: uint32_t maxGain_; }; +int IPARkISP1::init(unsigned int hwRevision) +{ + /* todo add support for other revisions */ + if (hwRevision != RKISP1_V10) { + LOG(IPARkISP1, Error) << "Hardware version " << hwRevision << + " is currently not supported"; + return -ENODEV; + } + LOG(IPARkISP1, Info) << "Hardware revision is " << hwRevision; + return 0; +} +; /** * \todo The RkISP1 pipeline currently provides an empty CameraSensorInfo * if the connected sensor does not provide enough information to properly diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp index 34814f62..24c622a8 100644 --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp @@ -85,7 +85,7 @@ public: { } - int loadIPA(); + int loadIPA(unsigned int hwRevision); Stream mainPathStream_; Stream selfPathStream_; @@ -300,7 +300,7 @@ RkISP1FrameInfo *RkISP1Frames::find(Request *request) return nullptr; } -int RkISP1CameraData::loadIPA() +int RkISP1CameraData::loadIPA(unsigned int hwRevision) { ipa_ = IPAManager::createIPA(pipe_, 1, 1); if (!ipa_) @@ -309,9 +309,7 @@ int RkISP1CameraData::loadIPA() ipa_->queueFrameAction.connect(this, &RkISP1CameraData::queueFrameAction); - ipa_->init(IPASettings{}); - - return 0; + return ipa_->init(hwRevision); } void RkISP1CameraData::queueFrameAction(unsigned int frame, @@ -952,7 +950,7 @@ int PipelineHandlerRkISP1::createCamera(MediaEntity *sensor) isp_->frameStart.connect(data->delayedCtrls_.get(), &DelayedControls::applyControls); - ret = data->loadIPA(); + ret = data->loadIPA(media_->hwRevision()); if (ret) return ret;