From patchwork Thu Sep 24 09:19:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 9781 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 43D48C3B5B for ; Thu, 24 Sep 2020 09:19:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0DCDA62FFB; Thu, 24 Sep 2020 11:19:36 +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="lkfM5qGt"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE37862FD2 for ; Thu, 24 Sep 2020 11:19:32 +0200 (CEST) Received: by mail-wr1-x42d.google.com with SMTP id z1so2996904wrt.3 for ; Thu, 24 Sep 2020 02:19: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=0S30In/5NRUCT+HJyBd2LgxQpoRUdTA5xnKpz8J3KS8=; b=lkfM5qGtGet6Z/xrvuJDmlvEAOF7khJnN5ccjITd0/W3RUrc0GxCJ/dYlXLJuIctUK 24yrm8sI2/6qC7suSCX8JDXE9V9ttDAavWDAWg1oPCLkK0WXTlEz8/C+OkHHkVz8GLWE GEFh3vmriyhtr4AEUGbDkhY66LYa4GJSuwf0A1WVRqcVPYkNEA+TAHGznUuWzdZu+ivE kk1RCGqW8ytsoINzYcKLjvgyBLJPcVCfZt1E/lJLFUg71itYQeJTJKlU2RfYLtOA6Os7 iZPRKEeRdfieVaepcN6ALrN0WeXWUlwFbN4Vl6O8b/nL21zmeWygJzndLFYZb8zoKmy+ Mm8w== 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=0S30In/5NRUCT+HJyBd2LgxQpoRUdTA5xnKpz8J3KS8=; b=kWYZWd86bUXPncQHvaL3quc1fTbU+W5OIQQp4qyOcFmAM9LrSPMBfxIKcreTaQkD0h Oh7P6bhdoF1FuFeNh0r4MB+m6sMVM1zBN58FAlZKnEmngI7VEWdoL5YA2rl6fy+ncMRl cT6BanJeOr+3/fq8Upz6Ege79Q1ZMHcly2W5JWET7vO/2++BQM1rBW2td/OTnfXfZmoV TFhWultEdqiwOp9i9GIu1kZv49zAhCiFOYoEzYLNypcExZjQCsCcDp3TGPwg+WrD0eQO 74/6mtnd31Y5F9vJhgVkcFdOZ+VIU625aS0166ZBjyP3kNUVfRYL3P5e4CROXqRnIDTK Lm6g== X-Gm-Message-State: AOAM532WiXPzoKNvlRfflKBYWczWJw++LtOJbyRjP/tR96qjlwgTIDSM RcAxu8SHvLV2p3Litu7fwfx8PMntYyZcoA== X-Google-Smtp-Source: ABdhPJwLF9KW2e1sPyNanGPRrlE3ALmnD0COxcrbzL7QU/WfzgNZD3lurgS4+QwoKN32JYYROpDpJA== X-Received: by 2002:adf:90a2:: with SMTP id i31mr4394359wri.276.1600939171965; Thu, 24 Sep 2020 02:19:31 -0700 (PDT) Received: from naushir-VirtualBox.pitowers.org ([2a00:1098:3142:14:a00:27ff:fe4d:f6a2]) by smtp.gmail.com with ESMTPSA id w81sm2689324wmg.47.2020.09.24.02.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Sep 2020 02:19:31 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Sep 2020 10:19:24 +0100 Message-Id: <20200924091927.116385-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200924091927.116385-1-naush@raspberrypi.com> References: <20200924091927.116385-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/4] pipeline: raspberrypi: Rename RPi::RPiStream and RPi::RPiDevice 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 RPi::RPiStream -> RPi::Stream and RPi::RPiDevice -> RPi::Device. There are no functional changes in this commit. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham Acked-by: Laurent Pinchart --- .../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)); } };