From patchwork Tue Sep 22 09:50:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 9694 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 07C27C3B5B for ; Tue, 22 Sep 2020 09:50:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D692062FD8; Tue, 22 Sep 2020 11:50:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="HNJTogZS"; dkim-atps=neutral Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8819862FAD for ; Tue, 22 Sep 2020 11:50:32 +0200 (CEST) Received: by mail-wr1-x431.google.com with SMTP id a17so16297564wrn.6 for ; Tue, 22 Sep 2020 02:50:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JNhjNwAAOx0BvLaR6PdAoOduJ+KycefW1eswWQRArUk=; b=HNJTogZS3fIUiHPuPAM0JIg/8yuYMbymA8PE4DT8iH5UpYX1MLzHhBhhFz84JBhu3V D0J/r2qTspLDLrLLdE2kFtV2TBdDtIhQ5OqolOIysk03M50B9HoMkTxkENDBna13D2gP eiAKl92CViryATZ57ZsNU4kVSPtZ1sNGieDqEZ+V3B9CtKD02KQJg0yLe9toUTuTk/r6 krdAcyf6TyUGEiGyiTO8Tm6K5p4l/fV1jKm8F+cYr2JfCkMbMt8GfD75fLVNL3kbUTy6 2Z+BrH1fMILUJ2fuqXg2iHzaoxSIUXmpinFyRjti3Z63SQiqSH6tbRb2k0Ceo9SxfAvC WS/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JNhjNwAAOx0BvLaR6PdAoOduJ+KycefW1eswWQRArUk=; b=Gq47yXEvXkW3Kf9XFyWcrC5vSm/NX5Ir6ZuB25zap7nYJK4zz2Rjt9avLIJt8b0lpM rMdI/b5dS1TRwDV9TlrqIP4N5Jor8biq6oWzqwWpc+ZanG7sWIR0VmFBO7lFT55ykHOD g+ig18lgilAOKoQA9VVndfxuHLA8cRxI3EtNDJqPh+XHf9nft9J16SCpfSicUwlTKE3o aLiY8ao+ujAiFZOdsfXiSX5hUH3DAm+GlBePjzFP1AAnOQE9fqOxrkUqupYG/CZB/PK9 /iFU3ug2JJo8Nxhl0pAcJqCy7jfqPRITsjgNgZKW04c+6F0wAmYpqcKErwOTYcAj/agS aiqQ== X-Gm-Message-State: AOAM5324o5tgKGHtpSqg7cYj8/pGdrjK6dWFr9ahTtNCm66DFNDGoTCS rOVrVvRPMWi98M6BWXtP2RV+ahbFW24mvA== X-Google-Smtp-Source: ABdhPJylMo6Sa6BOa61swAe37fNfYTCHCfWzX4iy4ZddNCAcWtxG0rcb4j6TnLfeCQ7ms3k2KxN3/w== X-Received: by 2002:adf:f4c6:: with SMTP id h6mr4330817wrp.310.1600768231630; Tue, 22 Sep 2020 02:50:31 -0700 (PDT) Received: from naushir-VirtualBox.pitowers.org ([2a00:1098:3142:14:a00:27ff:fe4d:f6a2]) by smtp.gmail.com with ESMTPSA id h204sm3776187wmf.35.2020.09.22.02.50.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 02:50:30 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Sep 2020 10:50:15 +0100 Message-Id: <20200922095018.68434-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922095018.68434-1-naush@raspberrypi.com> References: <20200922095018.68434-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/4] pipeline: raspberrypi: Move RPiStream and RPiDevice to its own namespace 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" Rename RpiStream -> RPi::Stream and RPiDevice -> RPi::Device. There are no functional changes in this commit. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- .../pipeline/raspberrypi/raspberrypi.cpp | 42 +++++++++---------- .../pipeline/raspberrypi/rpi_stream.cpp | 34 +++++++-------- .../pipeline/raspberrypi/rpi_stream.h | 16 +++---- 3 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 50f07182..5ed74d51 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -150,16 +150,16 @@ public: void ispOutputDequeue(FrameBuffer *buffer); void clearIncompleteRequests(); - void handleStreamBuffer(FrameBuffer *buffer, RPi::RPiStream *stream); - void handleExternalBuffer(FrameBuffer *buffer, RPi::RPiStream *stream); + void handleStreamBuffer(FrameBuffer *buffer, RPi::Stream *stream); + void handleExternalBuffer(FrameBuffer *buffer, RPi::Stream *stream); void handleState(); CameraSensor *sensor_; /* Array of Unicam and ISP device streams and associated buffers/streams. */ - RPi::RPiDevice unicam_; - RPi::RPiDevice isp_; + RPi::Device unicam_; + RPi::Device isp_; /* The vector below is just for convenience when iterating over all streams. */ - std::vector streams_; + std::vector streams_; /* Stores the ids of the buffers mapped in the IPA. */ std::unordered_set ipaBuffers_; @@ -189,7 +189,7 @@ private: void tryRunPipeline(); void tryFlushQueues(); FrameBuffer *updateQueue(std::queue &q, uint64_t timestamp, - RPi::RPiStream *stream); + RPi::Stream *stream); unsigned int ispOutputCount_; }; @@ -618,7 +618,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) int PipelineHandlerRPi::exportFrameBuffers([[maybe_unused]] Camera *camera, Stream *stream, std::vector> *buffers) { - RPi::RPiStream *s = static_cast(stream); + RPi::Stream *s = static_cast(stream); unsigned int count = stream->configuration().bufferCount; int ret = s->dev()->exportBuffers(count, buffers); @@ -787,14 +787,14 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) return false; /* Locate and open the unicam video streams. */ - data->unicam_[Unicam::Embedded] = RPi::RPiStream("Unicam Embedded", unicam_->getEntityByName("unicam-embedded")); - data->unicam_[Unicam::Image] = RPi::RPiStream("Unicam Image", unicam_->getEntityByName("unicam-image")); + data->unicam_[Unicam::Embedded] = RPi::Stream("Unicam Embedded", unicam_->getEntityByName("unicam-embedded")); + data->unicam_[Unicam::Image] = RPi::Stream("Unicam Image", unicam_->getEntityByName("unicam-image")); /* Tag the ISP input stream as an import stream. */ - data->isp_[Isp::Input] = RPi::RPiStream("ISP Input", isp_->getEntityByName("bcm2835-isp0-output0"), true); - data->isp_[Isp::Output0] = RPi::RPiStream("ISP Output0", isp_->getEntityByName("bcm2835-isp0-capture1")); - data->isp_[Isp::Output1] = RPi::RPiStream("ISP Output1", isp_->getEntityByName("bcm2835-isp0-capture2")); - data->isp_[Isp::Stats] = RPi::RPiStream("ISP Stats", isp_->getEntityByName("bcm2835-isp0-capture3")); + data->isp_[Isp::Input] = RPi::Stream("ISP Input", isp_->getEntityByName("bcm2835-isp0-output0"), true); + data->isp_[Isp::Output0] = RPi::Stream("ISP Output0", isp_->getEntityByName("bcm2835-isp0-capture1")); + data->isp_[Isp::Output1] = RPi::Stream("ISP Output1", isp_->getEntityByName("bcm2835-isp0-capture2")); + data->isp_[Isp::Stats] = RPi::Stream("ISP Stats", isp_->getEntityByName("bcm2835-isp0-capture3")); /* This is just for convenience so that we can easily iterate over all streams. */ for (auto &stream : data->unicam_) @@ -912,7 +912,7 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) */ unsigned int maxBuffers = 0; for (const Stream *s : camera->streams()) - if (static_cast(s)->isExternal()) + if (static_cast(s)->isExternal()) maxBuffers = std::max(maxBuffers, s->configuration().bufferCount); for (auto const stream : data->streams_) { @@ -1133,13 +1133,13 @@ done: void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) { - RPi::RPiStream *stream = nullptr; + RPi::Stream *stream = nullptr; int index; if (state_ == State::Stopped) return; - for (RPi::RPiStream &s : unicam_) { + for (RPi::Stream &s : unicam_) { index = s.getBufferId(buffer); if (index != -1) { stream = &s; @@ -1201,13 +1201,13 @@ void RPiCameraData::ispInputDequeue(FrameBuffer *buffer) void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer) { - RPi::RPiStream *stream = nullptr; + RPi::Stream *stream = nullptr; int index; if (state_ == State::Stopped) return; - for (RPi::RPiStream &s : isp_) { + for (RPi::Stream &s : isp_) { index = s.getBufferId(buffer); if (index != -1) { stream = &s; @@ -1297,7 +1297,7 @@ void RPiCameraData::clearIncompleteRequests() } } -void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, RPi::RPiStream *stream) +void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, RPi::Stream *stream) { if (stream->isExternal()) { /* @@ -1330,7 +1330,7 @@ void RPiCameraData::handleStreamBuffer(FrameBuffer *buffer, RPi::RPiStream *stre } } -void RPiCameraData::handleExternalBuffer(FrameBuffer *buffer, RPi::RPiStream *stream) +void RPiCameraData::handleExternalBuffer(FrameBuffer *buffer, RPi::Stream *stream) { unsigned int id = stream->getBufferId(buffer); @@ -1510,7 +1510,7 @@ void RPiCameraData::tryFlushQueues() } FrameBuffer *RPiCameraData::updateQueue(std::queue &q, uint64_t timestamp, - RPi::RPiStream *stream) + RPi::Stream *stream) { /* * If the unicam streams are external (both have be to the same), then we diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp index 2dcf96ca..3ee859e9 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp @@ -14,46 +14,46 @@ LOG_DEFINE_CATEGORY(RPISTREAM) namespace RPi { -V4L2VideoDevice *RPiStream::dev() const +V4L2VideoDevice *Stream::dev() const { return dev_.get(); } -std::string RPiStream::name() const +std::string Stream::name() const { return name_; } -void RPiStream::reset() +void Stream::reset() { external_ = false; clearBuffers(); } -void RPiStream::setExternal(bool external) +void Stream::setExternal(bool external) { /* Import streams cannot be external. */ ASSERT(!external || !importOnly_); external_ = external; } -bool RPiStream::isExternal() const +bool Stream::isExternal() const { return external_; } -void RPiStream::setExportedBuffers(std::vector> *buffers) +void Stream::setExportedBuffers(std::vector> *buffers) { for (auto const &buffer : *buffers) bufferMap_.emplace(id_.get(), buffer.get()); } -const BufferMap &RPiStream::getBuffers() const +const BufferMap &Stream::getBuffers() const { return bufferMap_; } -int RPiStream::getBufferId(FrameBuffer *buffer) const +int Stream::getBufferId(FrameBuffer *buffer) const { if (importOnly_) return -1; @@ -68,12 +68,12 @@ int RPiStream::getBufferId(FrameBuffer *buffer) const return it->first; } -void RPiStream::setExternalBuffer(FrameBuffer *buffer) +void Stream::setExternalBuffer(FrameBuffer *buffer) { bufferMap_.emplace(RPiBufferMask::EXTERNAL_BUFFER | id_.get(), buffer); } -void RPiStream::removeExternalBuffer(FrameBuffer *buffer) +void Stream::removeExternalBuffer(FrameBuffer *buffer) { int id = getBufferId(buffer); @@ -82,7 +82,7 @@ void RPiStream::removeExternalBuffer(FrameBuffer *buffer) bufferMap_.erase(id); } -int RPiStream::prepareBuffers(unsigned int count) +int Stream::prepareBuffers(unsigned int count) { int ret; @@ -108,7 +108,7 @@ int RPiStream::prepareBuffers(unsigned int count) return dev_->importBuffers(count); } -int RPiStream::queueBuffer(FrameBuffer *buffer) +int Stream::queueBuffer(FrameBuffer *buffer) { /* * A nullptr buffer implies an external stream, but no external @@ -147,7 +147,7 @@ int RPiStream::queueBuffer(FrameBuffer *buffer) return 0; } -void RPiStream::returnBuffer(FrameBuffer *buffer) +void Stream::returnBuffer(FrameBuffer *buffer) { /* This can only be called for external streams. */ ASSERT(external_); @@ -186,7 +186,7 @@ void RPiStream::returnBuffer(FrameBuffer *buffer) } } -int RPiStream::queueAllBuffers() +int Stream::queueAllBuffers() { int ret; @@ -204,13 +204,13 @@ int RPiStream::queueAllBuffers() return 0; } -void RPiStream::releaseBuffers() +void Stream::releaseBuffers() { dev_->releaseBuffers(); clearBuffers(); } -void RPiStream::clearBuffers() +void Stream::clearBuffers() { availableBuffers_ = std::queue{}; requestBuffers_ = std::queue{}; @@ -219,7 +219,7 @@ void RPiStream::clearBuffers() id_.reset(); } -int RPiStream::queueToDevice(FrameBuffer *buffer) +int Stream::queueToDevice(FrameBuffer *buffer) { LOG(RPISTREAM, Debug) << "Queuing buffer " << getBufferId(buffer) << " for " << name_; diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.h b/src/libcamera/pipeline/raspberrypi/rpi_stream.h index a2c21bcd..cb097e1c 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.h +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.h @@ -27,15 +27,15 @@ using BufferMap = std::unordered_map; * Device stream abstraction for either an internal or external stream. * Used for both Unicam and the ISP. */ -class RPiStream : public Stream +class Stream : public libcamera::Stream { public: - RPiStream() + Stream() : id_(RPiBufferMask::ID) { } - RPiStream(const char *name, MediaEntity *dev, bool importOnly = false) + Stream(const char *name, MediaEntity *dev, bool importOnly = false) : external_(false), importOnly_(importOnly), name_(name), dev_(std::make_unique(dev)), id_(RPiBufferMask::ID) { @@ -155,7 +155,7 @@ private: * streams indexed with an enum class. */ template -class RPiDevice : public std::array +class Device : public std::array { private: constexpr auto index(E e) const noexcept @@ -163,13 +163,13 @@ private: return static_cast>(e); } public: - RPiStream &operator[](E e) + Stream &operator[](E e) { - return std::array::operator[](index(e)); + return std::array::operator[](index(e)); } - const RPiStream &operator[](E e) const + const Stream &operator[](E e) const { - return std::array::operator[](index(e)); + return std::array::operator[](index(e)); } };