From patchwork Fri May 27 09:34:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 16066 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 B2628BD161 for ; Fri, 27 May 2022 09:34:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 12BD8633A1; Fri, 27 May 2022 11:34:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653644096; bh=KxO/2uimKBM3LYo5hU7ddWIH7jib6xtDBlgFtCwVJsU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=VWyjsTG6DJzA1MNkH+4rnARAY0nn0jPxHehETilcR0neSkdNoWWKSTSYtWNCYj2dQ 1UgMeNdLppy+VrLuLxyBSuTdGpsqnkeArvqtUCov6Vu6CC9uDprpmSDVAbXkt16d2C 73Yn/jccAzO6Dfo1q1QlJtC6U1MXEbYG+V6kcjq0XkzRCcGTodvVKl1qdr1ZdOHvOM 7A0Ay1MCrhHkqglkGm76UX/X1iecWcri0xQJheKDecAktCwbFzMe4fVI5VYBMYXpf0 mIvnQCxqM61o2xqmLr2JPkyDb6wDwuCLn2wf1jyncaA1JNN1LSolUUC+kLB5Vg85BV 56t81XDKK0/pw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D2657633A0 for ; Fri, 27 May 2022 11:34:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ItOYIBHp"; dkim-atps=neutral Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 5403E31A; Fri, 27 May 2022 11:34:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653644093; bh=KxO/2uimKBM3LYo5hU7ddWIH7jib6xtDBlgFtCwVJsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ItOYIBHp2MV8LvuDpdgEFEW7P3sBMTpHeYXzN9mIGABCqz05R0q11rZa2md7rS1A5 cZg/gs9lIF3XK+HArDKMqdTXzkptwIzfpzCn9DGVTCMaK/+TvJ2pjqf15sabsAqoVQ llR4OAjzBM+MwaCY1fJ77MQG0EzZi5UbqyWpr0/E= To: libcamera-devel@lists.libcamera.org Date: Fri, 27 May 2022 18:34:36 +0900 Message-Id: <20220527093440.953377-2-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527093440.953377-1-paul.elder@ideasonboard.com> References: <20220527093440.953377-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/5] android: camera_stream: Add sourceStream 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Hirokazu Honda Add to the CameraStream class a sourceStream field, which for streams of type Mapped contains a reference to the stream which produces the actual image data. The sourceStream of mapped streams will be used in later patches to make sure for each Mapped stream at least one libcamera::Stream is queued to the libcamera::Camera. Signed-off-by: Hirokazu Honda Signed-off-by: Jacopo Mondi Signed-off-by: Paul Elder Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- Changes in v2: - fix whitespace --- src/android/camera_device.cpp | 8 +++++++- src/android/camera_stream.cpp | 6 ++++-- src/android/camera_stream.h | 6 +++++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 8e804d4d..20599665 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -681,10 +681,16 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) for (const auto &streamConfig : streamConfigs) { config->addConfiguration(streamConfig.config); + CameraStream *sourceStream = nullptr; for (auto &stream : streamConfig.streams) { streams_.emplace_back(this, config.get(), stream.type, - stream.stream, config->size() - 1); + stream.stream, sourceStream, + config->size() - 1); stream.stream->priv = static_cast(&streams_.back()); + + /* Mapped streams are always associated with a Direct one. */ + if (stream.type == CameraStream::Type::Direct) + sourceStream = &streams_.back(); } } diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 94f1884c..154e088e 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -52,9 +52,11 @@ LOG_DECLARE_CATEGORY(HAL) CameraStream::CameraStream(CameraDevice *const cameraDevice, CameraConfiguration *config, Type type, - camera3_stream_t *camera3Stream, unsigned int index) + camera3_stream_t *camera3Stream, + CameraStream *const sourceStream, unsigned int index) : cameraDevice_(cameraDevice), config_(config), type_(type), - camera3Stream_(camera3Stream), index_(index) + camera3Stream_(camera3Stream), sourceStream_(sourceStream), + index_(index) { } diff --git a/src/android/camera_stream.h b/src/android/camera_stream.h index f9504462..4c5078b2 100644 --- a/src/android/camera_stream.h +++ b/src/android/camera_stream.h @@ -114,7 +114,9 @@ public: }; CameraStream(CameraDevice *const cameraDevice, libcamera::CameraConfiguration *config, Type type, - camera3_stream_t *camera3Stream, unsigned int index); + camera3_stream_t *camera3Stream, + CameraStream *const sourceStream, + unsigned int index); CameraStream(CameraStream &&other); ~CameraStream(); @@ -122,6 +124,7 @@ public: camera3_stream_t *camera3Stream() const { return camera3Stream_; } const libcamera::StreamConfiguration &configuration() const; libcamera::Stream *stream() const; + CameraStream *sourceStream() const { return sourceStream_; } int configure(); int process(Camera3RequestDescriptor::StreamBuffer *streamBuffer); @@ -167,6 +170,7 @@ private: const libcamera::CameraConfiguration *config_; const Type type_; camera3_stream_t *camera3Stream_; + CameraStream *const sourceStream_; const unsigned int index_; std::unique_ptr allocator_; From patchwork Fri May 27 09:34:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 16067 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 BBD86BD161 for ; Fri, 27 May 2022 09:34:58 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 71C0865632; Fri, 27 May 2022 11:34:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653644098; bh=ULliZzK0z4aEUbrgLmQxpYAzNul4FcvsIHrG/SSsrkA=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=JbLh8dDZfI/YBe23ut+j5Jr678Iw3WSAwpxiQdYICVRhciXqout1o60xtghpGDno5 0xx+7aMLsJjWaWBlZqmiJoQ4sWofOwaxBs72XbwefTxjS5fCxuvWrgeCpL9JD0zvpD xHwaPgkvPD66deEFlwjaO0lQ962CJIjAn7n6wXDAad8GwZ+d16Yoeqwy/oiwwfjl4Z XjwnVW2ag5RLuL3doj3OW2E5/xBn57Mdy+FeBKN2Hn3FhhZFWQg/mdELLAXA3ui6YA MIPL70hpW/foBgdsGODhApPstUx+4PFWyi02Cr9YFRLB0gXfCUj+I2lbLWd83S4ymv nMxIVEK2x14nQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0848D60415 for ; Fri, 27 May 2022 11:34:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="imdz+dB3"; dkim-atps=neutral Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id A489632A; Fri, 27 May 2022 11:34:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653644094; bh=ULliZzK0z4aEUbrgLmQxpYAzNul4FcvsIHrG/SSsrkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=imdz+dB327Xq9is2baKdIH49f8jrHkJGvQs9y0rWOgbQlHt/OGl/u4NtVROgFuo90 jZou7VGfGzSe5W1QLQkQ/tSR+tf4cOwZHitDqQRyqxfBpU4k7tu+Yfx/nnmdA+PzV5 hTtuI7KFm2oVvVTwlJ9OeSYLpRWDDLhKvfqwd7Sc= To: libcamera-devel@lists.libcamera.org Date: Fri, 27 May 2022 18:34:37 +0900 Message-Id: <20220527093440.953377-3-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527093440.953377-1-paul.elder@ideasonboard.com> References: <20220527093440.953377-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/5] android: camera_stream: Create allocator unconditionally 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Jacopo Mondi With the introduction of PlatformBufferAllocator all CameraStream can be used to allocate buffers on-demand. Create CameraStream::allocator_ and the associated mutex for all types of stream. Signed-off-by: Jacopo Mondi Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- No change in v2 If we want to make CameraStream::mutex_ into non-pointer (as Hiro suggested), it should be done on top. Do we want to do that? (I suppose it doesn't affect this patch itself) --- src/android/camera_stream.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/android/camera_stream.cpp b/src/android/camera_stream.cpp index 154e088e..045e6006 100644 --- a/src/android/camera_stream.cpp +++ b/src/android/camera_stream.cpp @@ -128,10 +128,8 @@ int CameraStream::configure() worker_->start(); } - if (type_ == Type::Internal) { - allocator_ = std::make_unique(cameraDevice_); - mutex_ = std::make_unique(); - } + allocator_ = std::make_unique(cameraDevice_); + mutex_ = std::make_unique(); camera3Stream_->max_buffers = configuration().bufferCount; From patchwork Fri May 27 09:34:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 16068 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 BA5A9BD161 for ; Fri, 27 May 2022 09:35:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6D5DA65634; Fri, 27 May 2022 11:35:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653644100; bh=ZeOGn5mw6G0hlgpBAD5YHgN1dG0X6mM4ZNfUvj8r45Q=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=WrVCVp0Tu3jkoZ+M/VCd/1y3JHGiEQhAFIOYdhijJ9w/7wE9geqttxZsyUss9jGNa QNQbjdhkTrI4PPzQnxSVvQggZPtVm7xOHwbG1YUyahQUQH4UVZofgS3E8BoWfbyzAX h75jz40niOIiDtW71LEQ0fHFmsONtaQMLXs+WvTmDjpgZKQMaSeZMIiTLbD7jbqtUi A6JSeGyZJbqO7vHOfzXmA6MlN0kdos7Xow8ZUi9qHy5p3I7+0Fdc2+W38iL/Xx0j8A GWp276wL5jMtnUjxjx7U4UcN6ub/Y4jviSxFNLBqbBg6PipnQDgbMyRukTcG0H0LrS S6ecR6BZi5gPw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0119F65631 for ; Fri, 27 May 2022 11:34:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="IrMBW7Kc"; dkim-atps=neutral Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 664CB32A; Fri, 27 May 2022 11:34:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653644096; bh=ZeOGn5mw6G0hlgpBAD5YHgN1dG0X6mM4ZNfUvj8r45Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IrMBW7KcejgDTWp4WO5cyBF+w6NKKcW1hjRGIvEl9ewry8nA/TOZR8/NR6Kugde3U 9FOrdsBRR9H/bw1AsBSLM91HWmt6q0kup1A4rGFWFhzfiZ0fA9jB4zsv2czBHH87eT Om/4qFIopM3WxspYKLxG0iyawPwo41Xrd6KMHRhY= To: libcamera-devel@lists.libcamera.org Date: Fri, 27 May 2022 18:34:38 +0900 Message-Id: <20220527093440.953377-4-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527093440.953377-1-paul.elder@ideasonboard.com> References: <20220527093440.953377-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/5] android: camera_device: Postpone mapped streams handling 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Jacopo Mondi Mapped streams are generated by post-processing and always require a source buffer from where to process image data from. In case a Mapped stream is requested but its source stream is not, it is required to allocate a buffer on the fly and add it to the libcamera::Request. Make sure a source stream is available for all mapped streams, and if that's not the case, add a dedicated buffer to the request for that purpose. Signed-off-by: Jacopo Mondi Signed-off-by: Paul Elder Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- Changes in v2: - cosmetic changes in code - fix typo in the commit message --- src/android/camera_device.cpp | 80 +++++++++++++++++++++++++++++++---- 1 file changed, 72 insertions(+), 8 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 20599665..95c14f60 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -923,6 +924,32 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques LOG(HAL, Debug) << "Queueing request " << descriptor->request_->cookie() << " with " << descriptor->buffers_.size() << " streams"; + /* + * Collect the CameraStream associated to each requested capture stream. + * Since requestedStreams is an std:set<>, no duplications can happen. + */ + std::set requestedStreams; + for (const auto &[i, buffer] : utils::enumerate(descriptor->buffers_)) { + CameraStream *cameraStream = buffer.stream; + + switch (cameraStream->type()) { + case CameraStream::Type::Mapped: + requestedStreams.insert(cameraStream->sourceStream()); + break; + + case CameraStream::Type::Direct: + case CameraStream::Type::Internal: + requestedStreams.insert(cameraStream); + break; + } + } + + /* + * Process all the Direct and Internal streams, for which the CameraStream + * they refer to is the one that points to the right libcamera::Stream. + * + * Streams of type Mapped will be handled later. + */ for (const auto &[i, buffer] : utils::enumerate(descriptor->buffers_)) { CameraStream *cameraStream = buffer.stream; camera3_stream_t *camera3Stream = cameraStream->camera3Stream(); @@ -945,14 +972,6 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques switch (cameraStream->type()) { case CameraStream::Type::Mapped: - /* - * Mapped streams don't need buffers added to the - * Request. - */ - LOG(HAL, Debug) << ss.str() << " (mapped)"; - - descriptor->pendingStreamsToProcess_.insert( - { cameraStream, &buffer }); continue; case CameraStream::Type::Direct: @@ -996,6 +1015,51 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques auto fence = std::make_unique(std::move(acquireFence)); descriptor->request_->addBuffer(cameraStream->stream(), frameBuffer, std::move(fence)); + + requestedStreams.erase(cameraStream); + } + + /* + * Now handle the Mapped streams. If no buffer has been added for them + * as their corresponding direct source stream has not been requested, + * add it here. + */ + for (const auto &[i, buffer] : utils::enumerate(descriptor->buffers_)) { + CameraStream *cameraStream = buffer.stream; + camera3_stream_t *camera3Stream = cameraStream->camera3Stream(); + + if (cameraStream->type() != CameraStream::Type::Mapped) + continue; + + LOG(HAL, Debug) << i << " - (" << camera3Stream->width << "x" + << camera3Stream->height << ")" + << "[" << utils::hex(camera3Stream->format) << "] -> " + << "(" << cameraStream->configuration().size.toString() << ")[" + << cameraStream->configuration().pixelFormat.toString() << "]" + << " (mapped)"; + + MutexLocker lock(descriptor->streamsProcessMutex_); + descriptor->pendingStreamsToProcess_.insert({ cameraStream, &buffer }); + + /* + * Make sure the CameraStream this stream is mapped on has been + * added to the request. + */ + CameraStream *sourceStream = cameraStream->sourceStream(); + if (requestedStreams.find(sourceStream) == requestedStreams.end()) + continue; + + /* + * If that's not the case, we need to add a buffer to the request + * for this stream. + */ + FrameBuffer *frameBuffer = cameraStream->getBuffer(); + buffer.internalBuffer = frameBuffer; + + descriptor->request_->addBuffer(sourceStream->stream(), + frameBuffer, nullptr); + + requestedStreams.erase(sourceStream); } /* From patchwork Fri May 27 09:34:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 16069 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 0CACBC3256 for ; Fri, 27 May 2022 09:35:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5EBC465636; Fri, 27 May 2022 11:35:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653644101; bh=7CYHVaZYnY+zkqAW+k//gmQdHxECnDVyIDvHzRif/ok=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RLTQA09/XuZTJLeP4WUDAvUuXTC8XhSFASNeCea/mgKWaCDKT6yFPDwjqMPkHxbZ2 incBjBk8/LlHc8w+mSto/Q07BvxsPVtHoC6RWI6okiMoHg5rVpq2n+6AKWKBt6ziuu YLKWp20Fy/pvIOE1orcD4A8X6l8D9UCBHCWAZgVexdW+7Eu6uqq+Ca7zqoe8bUoUpq 1+7sppjM5MK8COU6jm4uUBp92bOTS5o7UIMjOx0H+cLgrQ26GccgmqsmnbZlACi9bo pqr8VbNWmLaCr/nv9rdQrbHPBK+YSMg30IRQ9JgtS9amr0kQ2KsPOFR6T8Sten7AuR JqpUWd7lgbtPA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 247D9633A1 for ; Fri, 27 May 2022 11:34:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ks08j0rE"; dkim-atps=neutral Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 69E5932A; Fri, 27 May 2022 11:34:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653644098; bh=7CYHVaZYnY+zkqAW+k//gmQdHxECnDVyIDvHzRif/ok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ks08j0rE0AEE3qYXTsgJp6fdwjijQR2J1fX1sI3GbmNIydlKKAPaT7CesdOhVi1VG 38DE62107YiSQKHVdsNdTPiaZDpivuCC4l9J5og8fpaQkQsnDL0OWCApRy3FSe9KWR FOpLzjFyVedS23CoggKnj2vw9TY2zcGIuw+MizC8= To: libcamera-devel@lists.libcamera.org Date: Fri, 27 May 2022 18:34:39 +0900 Message-Id: <20220527093440.953377-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527093440.953377-1-paul.elder@ideasonboard.com> References: <20220527093440.953377-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/5] android: camera_device: Use YUV post-processor 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Hirokazu Honda When creating the list of StreamConfiguration to be requested to the camera, map NV12 streams of equal size and format together, so that they will be generated by using the YUV post-processor. Signed-off-by: Hirokazu Honda Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/android/camera_device.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 95c14f60..9ee34b93 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -605,14 +605,40 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) continue; } + /* + * While gralloc usage flags are supposed to report usage + * patterns to select a suitable buffer allocation strategy, in + * practice they're also used to make other decisions, such as + * selecting the actual format for the IMPLEMENTATION_DEFINED + * HAL pixel format. To avoid issues, we thus have to set the + * GRALLOC_USAGE_HW_CAMERA_WRITE flag unconditionally, even for + * streams that will be produced in software. + */ + stream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE; + + /* + * If a CameraStream with the same size and format of the + * current stream has already been requested, associate the two. + */ + auto iter = std::find_if( + streamConfigs.begin(), streamConfigs.end(), + [&size, &format](const Camera3StreamConfig &streamConfig) { + return streamConfig.config.size == size && + streamConfig.config.pixelFormat == format; + }); + if (iter != streamConfigs.end()) { + /* Add usage to copy the buffer in streams[0] to stream. */ + iter->streams[0].stream->usage |= GRALLOC_USAGE_SW_READ_OFTEN; + stream->usage |= GRALLOC_USAGE_SW_WRITE_OFTEN; + iter->streams.push_back({ stream, CameraStream::Type::Mapped }); + continue; + } + Camera3StreamConfig streamConfig; streamConfig.streams = { { stream, CameraStream::Type::Direct } }; streamConfig.config.size = size; streamConfig.config.pixelFormat = format; streamConfigs.push_back(std::move(streamConfig)); - - /* This stream will be produced by hardware. */ - stream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE; } /* Now handle the MJPEG streams, adding a new stream if required. */ From patchwork Fri May 27 09:34:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 16070 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 D38EEBD161 for ; Fri, 27 May 2022 09:35:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9B47265634; Fri, 27 May 2022 11:35:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653644104; bh=0BZicPyxMBeyivBumWFrMPChHa1PrWSpE0d1yA43m5M=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=YMC+fhMMD5pM3nLLwqc4m7H/LME8mqbobTXWO5D6ddRKlHCvLdXwwG+Q6gfkn+DGM v8amjSmoK7QxygrEtQWf7hPv5zugL7REtskLqPWLaHOcO6UicYGATFZEEgDUqsP54/ u4+eBZDX2q4GnjkAIJhOHSJ/9QMZHnsUc7Hppv9+AOReY6GpRqIgVc0mxdE0nSkKCx CpH1MlSFuc/pRW41BuodCcOL7TihPkmfiRt8gPxg9ncVbMMa2ZtCiwV3ep+rVAnqQ+ FpufqxRWuP/pQzx+vi1CBirIYSzaaDivrY0a3tjEHNDJLn08au9hC3mXTqwF8+ySoC xbIcsxbDQMoeg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6385A65637 for ; Fri, 27 May 2022 11:35:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FnlRa58H"; dkim-atps=neutral Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 6EE4532A; Fri, 27 May 2022 11:34:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653644101; bh=0BZicPyxMBeyivBumWFrMPChHa1PrWSpE0d1yA43m5M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FnlRa58HoAUMzq44I6VbC5zp9OUfCowYFz6TYrYIsD/7cXD4ZKHXrTxdsCdTwaMpa YfHa84WPRLPgrGarQYOG/za/Vnr8koezPs2X7W1nweRk1MREy1KOSBXVVxgkH7nf1/ YluGGUMuoI7bjd5fY+R0eGB0D8gFHOYh2bF6B1pU= To: libcamera-devel@lists.libcamera.org Date: Fri, 27 May 2022 18:34:40 +0900 Message-Id: <20220527093440.953377-6-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527093440.953377-1-paul.elder@ideasonboard.com> References: <20220527093440.953377-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/5] android: camera_device: Print the correct number of completed streams 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Jacopo Mondi When a request completes, a debug message is generated to help identify the request and the number of streams it contains. The printed number of streams is however the number of output buffers requested by the camera framework, not the number of streams generated by libcamera. In facts, some output buffers are generated by post-processing, and not directly from the camera. As the debug message prints the libcamera identifier for the Request, it is more logical to print the number of streams generated by the camera instead of the total number of streams. Reviewed-by: Hirokazu Honda Reviewed-by: Paul Elder Signed-off-by: Jacopo Mondi Signed-off-by: Paul Elder Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- Changes in v2: - fix typo in commit message --- src/android/camera_device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 9ee34b93..dfff8ec4 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1194,7 +1194,7 @@ void CameraDevice::requestComplete(Request *request) notifyShutter(descriptor->frameNumber_, sensorTimestamp); LOG(HAL, Debug) << "Request " << request->cookie() << " completed with " - << descriptor->buffers_.size() << " streams"; + << descriptor->request_->buffers().size() << " streams"; /* * Generate the metadata associated with the captured buffers.