From patchwork Wed Sep 9 15:54:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 9563 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 8F7D9BDB1D for ; Wed, 9 Sep 2020 15:51:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6D1E762D70; Wed, 9 Sep 2020 17:51:26 +0200 (CEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B7EE62D62 for ; Wed, 9 Sep 2020 17:51:24 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 357361BF20E; Wed, 9 Sep 2020 15:51:23 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 9 Sep 2020 17:54:55 +0200 Message-Id: <20200909155457.153907-7-jacopo@jmondi.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200909155457.153907-1-jacopo@jmondi.org> References: <20200909155457.153907-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 6/8] android: camera_device: Allocate buffer pool 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: hanlinchen@chromium.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" CameraStream instances that are not directly mapped to application facing Android streams need memory to be reserved in libcamera on their behalf. After the libcamera::Camera has been configured, reserve memory for the CameraStream isntances that need a pool of libcamera allocated buffers. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/android/camera_device.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index d35c6b93b654..a7cb1be03b9a 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1329,6 +1329,26 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) return ret; } + /* + * Allocate buffers in libcamera for stream not directly mapped to + * Android streams. + */ + for (unsigned int i = 0; i < stream_list->num_streams; ++i) { + camera3_stream_t *camera3Stream = stream_list->streams[i]; + CameraStream *cameraStream = static_cast(camera3Stream->priv); + StreamConfiguration &cfg = config_->at(cameraStream->index()); + + if (cameraStream->type() != CameraStream::Type::Internal) + continue; + + int ret = allocator_.allocate(cfg.stream()); + if (ret < 0) { + LOG(HAL, Error) + << "Failed to allocate buffers for stream " << i; + return ret; + } + } + return 0; }