From patchwork Thu Jul 2 21:36:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8556 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 E9FDBBE905 for ; Thu, 2 Jul 2020 21:37:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9CF2C60C56; Thu, 2 Jul 2020 23:37:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="g1a+7qly"; dkim-atps=neutral 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 2D87E603B4 for ; Thu, 2 Jul 2020 23:37:03 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B1B5CA2D; Thu, 2 Jul 2020 23:37:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593725822; bh=ZfLLGz9HxSw+6HxX7yndm4O7hI1oXiMwIW6km/OxJ6A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g1a+7qlyDJ3DZhfiJoBQqJeDdLTjt2x/s1rbY/F9LqDXfdwpQ/MGstQpU2viFBeTj 0l15v6QmluH4ApXL6H36FGVXy1Sbcdigm6bOj5c716PDuF6WgndsglQbJOw0gtrcSP UnyFPs6rFROw0GfKgEqxFPEfIiBM6h18xcxmlads= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:36:46 +0100 Message-Id: <20200702213654.2129054-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> References: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/9] libcamera: camera: Allow unspecified roles for generateConfiguration 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" Providing an empty set of roles is permitted to generate an empty configuration from the pipeline handlers. Overload the generateConfiguration() function such that not specifying a roles parameter will use an empty set, and return an empty configuration. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- include/libcamera/camera.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h index 9c0e58f7864b..4d1a4a9f52ec 100644 --- a/include/libcamera/camera.h +++ b/include/libcamera/camera.h @@ -89,7 +89,7 @@ public: const ControlList &properties(); const std::set &streams() const; - std::unique_ptr generateConfiguration(const StreamRoles &roles); + std::unique_ptr generateConfiguration(const StreamRoles &roles = {}); int configure(CameraConfiguration *config); Request *createRequest(uint64_t cookie = 0); From patchwork Thu Jul 2 21:36:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8557 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 A2FF3BE905 for ; Thu, 2 Jul 2020 21:37:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E6CD060C5F; Thu, 2 Jul 2020 23:37:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="eEDMjPyP"; dkim-atps=neutral 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 853FE603B4 for ; Thu, 2 Jul 2020 23:37:03 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 1A8BC1450; Thu, 2 Jul 2020 23:37:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593725823; bh=pB8gB3p33/S767U5XwhzEKogsxp22y/BIZvakHD4YAY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eEDMjPyPVsScyQDzk2NCUaPzi/IoXXA3CJ/fzUy1OnHEUMvuRGoSEJWuw7r0LyvSu zIWIPdM4vR1rzjk4ZAcUPyerPvSfQyDbauWu/kLeH6fkLYCD17ZWYuaoLwmqahKWVR LLkFtQfuh0NvgYBzGe1qYBOb2oIQAgnJan2PV4Ss= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:36:47 +0100 Message-Id: <20200702213654.2129054-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> References: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/9] android: camera_device: Provide a toPixelFormat helper 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" Rather than converting pixelformats through the map, and then dereferencing the iterator later, create a helper to explicitly return a PixelFormat type. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/android/camera_device.cpp | 28 ++++++++++++++++++++-------- src/android/camera_device.h | 1 + 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index f788c11e7254..b9031ff0c2a4 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -923,6 +923,19 @@ const camera_metadata_t *CameraDevice::constructDefaultRequestSettings(int type) return requestTemplate->get(); } +PixelFormat CameraDevice::toPixelFormat(int format) +{ + /* Translate Android format code to libcamera pixel format. */ + auto it = formatsMap_.find(format); + if (it == formatsMap_.end()) { + LOG(HAL, Error) << "Requested format " << utils::hex(format) + << " not supported"; + return PixelFormat(); + } + + return it->second; +} + /* * Inspect the stream_list to produce a list of StreamConfiguration to * be use to configure the Camera. @@ -932,11 +945,14 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) for (unsigned int i = 0; i < stream_list->num_streams; ++i) { camera3_stream_t *stream = stream_list->streams[i]; + PixelFormat format = toPixelFormat(stream->format); + LOG(HAL, Info) << "Stream #" << i << ", direction: " << stream->stream_type << ", width: " << stream->width << ", height: " << stream->height - << ", format: " << utils::hex(stream->format); + << ", format: " << utils::hex(stream->format) + << " (" << format.toString() << ")"; } /* Only one stream is supported. */ @@ -947,13 +963,9 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) camera3_stream_t *camera3Stream = stream_list->streams[0]; /* Translate Android format code to libcamera pixel format. */ - auto it = formatsMap_.find(camera3Stream->format); - if (it == formatsMap_.end()) { - LOG(HAL, Error) << "Requested format " - << utils::hex(camera3Stream->format) - << " not supported"; + PixelFormat format = toPixelFormat(camera3Stream->format); + if (!format.isValid()) return -EINVAL; - } /* * Hardcode viewfinder role, replacing the generated configuration @@ -969,7 +981,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) StreamConfiguration *streamConfiguration = &config_->at(0); streamConfiguration->size.width = camera3Stream->width; streamConfiguration->size.height = camera3Stream->height; - streamConfiguration->pixelFormat = it->second; + streamConfiguration->pixelFormat = format; switch (config_->validate()) { case CameraConfiguration::Valid: diff --git a/src/android/camera_device.h b/src/android/camera_device.h index ed11410a5577..5bd6cf416156 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -72,6 +72,7 @@ private: std::tuple calculateStaticMetadataSize(); void notifyShutter(uint32_t frameNumber, uint64_t timestamp); void notifyError(uint32_t frameNumber, camera3_stream_t *stream); + libcamera::PixelFormat toPixelFormat(int format); std::unique_ptr getResultMetadata(int frame_number, int64_t timestamp); From patchwork Thu Jul 2 21:36:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8558 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 20C24BE905 for ; Thu, 2 Jul 2020 21:37:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3922860CAE; Thu, 2 Jul 2020 23:37:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="J/U30J7Y"; dkim-atps=neutral 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 D580F60C57 for ; Thu, 2 Jul 2020 23:37:03 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 78DA59CB; Thu, 2 Jul 2020 23:37:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593725823; bh=nL5+T7KPz0mehrsJeDuwJ9jTjqay9rR1PgfhEJM22NQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J/U30J7YsLxzqp7LVnVVAYIM9eJnl8HUcPnlRjWGZ8w8xlrRHUAVIEaa5pVEblVTw IhAVuLv5AocerSHxiLVmRsIjm8CWn8EVqCoATFBnoBvSOaq55XudkUVqkzeE4kAyqB sLRf1+ZX6wQ8Tgl+JDDjgKad/6ZBgCQU8h5OkOHo= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:36:48 +0100 Message-Id: <20200702213654.2129054-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> References: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/9] android: camera_device: Support multiple stream configurations 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" Create an initial Camera Configuration using an empty role set, and populate the StreamConfigurations manually from each of the streams given by the Android camera3_stream_configuration_t stream_list. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/android/camera_device.cpp | 51 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index b9031ff0c2a4..03dcdd520794 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -942,6 +942,16 @@ PixelFormat CameraDevice::toPixelFormat(int format) */ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) { + /* + * Generate an empty configuration, and construct a StreamConfiguration + * for each camera3_stream to add to it. + */ + config_ = camera_->generateConfiguration(); + if (!config_) { + LOG(HAL, Error) << "Failed to generate camera configuration"; + return -EINVAL; + } + for (unsigned int i = 0; i < stream_list->num_streams; ++i) { camera3_stream_t *stream = stream_list->streams[i]; @@ -953,35 +963,18 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) << ", height: " << stream->height << ", format: " << utils::hex(stream->format) << " (" << format.toString() << ")"; - } - /* Only one stream is supported. */ - if (stream_list->num_streams != 1) { - LOG(HAL, Error) << "Only one stream supported"; - return -EINVAL; - } - camera3_stream_t *camera3Stream = stream_list->streams[0]; + if (!format.isValid()) + return -EINVAL; - /* Translate Android format code to libcamera pixel format. */ - PixelFormat format = toPixelFormat(camera3Stream->format); - if (!format.isValid()) - return -EINVAL; + StreamConfiguration streamConfiguration; - /* - * Hardcode viewfinder role, replacing the generated configuration - * parameters with the ones requested by the Android framework. - */ - StreamRoles roles = { StreamRole::Viewfinder }; - config_ = camera_->generateConfiguration(roles); - if (!config_ || config_->empty()) { - LOG(HAL, Error) << "Failed to generate camera configuration"; - return -EINVAL; - } + streamConfiguration.size.width = stream->width; + streamConfiguration.size.height = stream->height; + streamConfiguration.pixelFormat = format; - StreamConfiguration *streamConfiguration = &config_->at(0); - streamConfiguration->size.width = camera3Stream->width; - streamConfiguration->size.height = camera3Stream->height; - streamConfiguration->pixelFormat = format; + config_->addConfiguration(streamConfiguration); + } switch (config_->validate()) { case CameraConfiguration::Valid: @@ -996,7 +989,13 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) return -EINVAL; } - camera3Stream->max_buffers = streamConfiguration->bufferCount; + for (unsigned int i = 0; i < stream_list->num_streams; ++i) { + camera3_stream_t *stream = stream_list->streams[i]; + StreamConfiguration &streamConfiguration = config_->at(i); + + /* Use the bufferCount confirmed by the validation process. */ + stream->max_buffers = streamConfiguration.bufferCount; + } /* * Once the CameraConfiguration has been adjusted/validated From patchwork Thu Jul 2 21:36:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8559 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 D023ABE905 for ; Thu, 2 Jul 2020 21:37:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9AB8F60C64; Thu, 2 Jul 2020 23:37:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="MC+mCxVZ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 40307603B4 for ; Thu, 2 Jul 2020 23:37:04 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CE16FA2D; Thu, 2 Jul 2020 23:37:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593725824; bh=5uAYqUB/sM2KTBrinUCWupfRoKYYXBMp40afSc/pyTQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MC+mCxVZN4g4kHI/Oq8syp03iaHXYPzjTB1szcbQeKoGqJQc2gfKnyW+jmcceCJVB GfyRcDzWViub1B7INqvF/osTwosk5Xgx2yrlhmg8kz4kJVkxBTcRMRv8nab6+oF5XN lq1/327XwuiR7fuYXubIoaSPpEPIENxuONrk05Bk= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:36:49 +0100 Message-Id: <20200702213654.2129054-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> References: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/9] android: camera_device: Simplify FrameBuffer construction from a buffer_handle_t 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" Move the code which constructs a FrameBuffer from the Android buffer handle to it's own function to simplify the code flow and readability. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/android/camera_device.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 03dcdd520794..78ecfd7c2ee2 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1011,6 +1011,24 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) return 0; } +static FrameBuffer *newFrameBuffer(const buffer_handle_t camera3buffer) +{ + std::vector planes; + for (unsigned int i = 0; i < 3; i++) { + FrameBuffer::Plane plane; + plane.fd = FileDescriptor(camera3buffer->data[i]); + /* + * Setting length to zero here is OK as the length is only used + * to map the memory of the plane. Libcamera do not need to poke + * at the memory content queued by the HAL. + */ + plane.length = 0; + planes.push_back(std::move(plane)); + } + + return new FrameBuffer(std::move(planes)); +} + int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request) { StreamConfiguration *streamConfiguration = &config_->at(0); @@ -1064,22 +1082,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques * Create a libcamera buffer using the dmabuf descriptors of the first * and (currently) only supported request buffer. */ - const buffer_handle_t camera3Handle = *camera3Buffers[0].buffer; - - std::vector planes; - for (int i = 0; i < 3; i++) { - FrameBuffer::Plane plane; - plane.fd = FileDescriptor(camera3Handle->data[i]); - /* - * Setting length to zero here is OK as the length is only used - * to map the memory of the plane. Libcamera do not need to poke - * at the memory content queued by the HAL. - */ - plane.length = 0; - planes.push_back(std::move(plane)); - } - - FrameBuffer *buffer = new FrameBuffer(std::move(planes)); + FrameBuffer *buffer = newFrameBuffer(*camera3Buffers[0].buffer); if (!buffer) { LOG(HAL, Error) << "Failed to create buffer"; delete descriptor; From patchwork Thu Jul 2 21:36:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8560 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 7986FBE905 for ; Thu, 2 Jul 2020 21:37:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4863160C57; Thu, 2 Jul 2020 23:37:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="v+w1wkpd"; dkim-atps=neutral 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 8D6EC60C58 for ; Thu, 2 Jul 2020 23:37:04 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2C0AC9CB; Thu, 2 Jul 2020 23:37:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593725824; bh=JMgP2MZf0CHb9eeIgmjhXUqe432wOspAy6t0ZnhiOMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v+w1wkpdDdAiX6fcl0Yokf7JUK7gJGlKESvaDsom0NKx6Odbork69tE1lV8/GfExj D0bqpkBFZyhZla3qoeUzX2d7yiF9hBOmVqDdLY+wWIhMvpf04ClngGTxXyImZyJ8hb Vo4K3HLv5Vmd/GrK/IkyaTSqv1SqjYdlNv2LSAMo= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:36:50 +0100 Message-Id: <20200702213654.2129054-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> References: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 5/9] android: camera_device: Create the Request and Camera3RequestDescriptor together 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" Move the construction of the Request higher in the code flow so that multiple buffers and streams can be added where required. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- src/android/camera_device.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 78ecfd7c2ee2..77083219d8a1 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1066,6 +1066,10 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques Camera3RequestDescriptor *descriptor = new Camera3RequestDescriptor(camera3Request->frame_number, camera3Request->num_output_buffers); + + Request *request = + camera_->createRequest(reinterpret_cast(descriptor)); + for (unsigned int i = 0; i < descriptor->numBuffers; ++i) { /* * Keep track of which stream the request belongs to and store @@ -1085,12 +1089,11 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques FrameBuffer *buffer = newFrameBuffer(*camera3Buffers[0].buffer); if (!buffer) { LOG(HAL, Error) << "Failed to create buffer"; + delete request; delete descriptor; return -ENOMEM; } - Request *request = - camera_->createRequest(reinterpret_cast(descriptor)); request->addBuffer(stream, buffer); int ret = camera_->queueRequest(request); From patchwork Thu Jul 2 21:36:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8561 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 CBAE0C2E69 for ; Thu, 2 Jul 2020 21:37:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9251B60C63; Thu, 2 Jul 2020 23:37:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="EKeQA02J"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E763B60C6A for ; Thu, 2 Jul 2020 23:37:04 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 7F48DA2D; Thu, 2 Jul 2020 23:37:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593725824; bh=Op3xfPmu9zC9viajyJSuhKh+b37hgQTgD9fe6U1V+4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EKeQA02Jv8awaLnj9yhcfCCDE99YS3ySxMNQcNpgMWP8lBsxmKLPCAgRDpISInu0Y CW8Oys5xocdnFkHEUSV+zmIAu7h+PYNMzSVYr3BnPQI9npKLLh+S5apEbKXMHOMKkj aYn8bHxSzAAkMZEBN/t1maVEL6WHISy6pGM3O2uU= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:36:51 +0100 Message-Id: <20200702213654.2129054-7-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> References: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 6/9] android: camera_device: Maintain a vector of CameraStream 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" Introduce a vector storing a CameraStream to track and maintain state between an Android stream (camera3_stream_t) and a libcamera Stream. Only the index of the libcamera stream is stored, to facilitate identifying the correct index for both the StreamConfiguration and Stream vectors. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 18 ++++++++++++++++-- src/android/camera_device.h | 6 ++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 77083219d8a1..fc3962dac230 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -952,6 +952,14 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) return -EINVAL; } + streams_.reserve(stream_list->num_streams); + + /* + * Track actually created streams, as there may not be a 1:1 mapping of + * camera3 streams to libcamera streams. + */ + unsigned int streamIndex = 0; + for (unsigned int i = 0; i < stream_list->num_streams; ++i) { camera3_stream_t *stream = stream_list->streams[i]; @@ -967,6 +975,9 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) if (!format.isValid()) return -EINVAL; + /* Maintain internal state of all stream mappings. */ + streams_[i].androidStream = stream; + StreamConfiguration streamConfiguration; streamConfiguration.size.width = stream->width; @@ -974,6 +985,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) streamConfiguration.pixelFormat = format; config_->addConfiguration(streamConfiguration); + streams_[i].libcameraIndex = streamIndex++; } switch (config_->validate()) { @@ -991,10 +1003,12 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) for (unsigned int i = 0; i < stream_list->num_streams; ++i) { camera3_stream_t *stream = stream_list->streams[i]; - StreamConfiguration &streamConfiguration = config_->at(i); + CameraStream *cameraStream = &streams_[i]; + + StreamConfiguration &cfg = config_->at(cameraStream->libcameraIndex); /* Use the bufferCount confirmed by the validation process. */ - stream->max_buffers = streamConfiguration.bufferCount; + stream->max_buffers = cfg.bufferCount; } /* diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 5bd6cf416156..275760f0aa26 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -25,6 +25,11 @@ class CameraMetadata; +struct CameraStream { + camera3_stream *androidStream; + unsigned int libcameraIndex; +}; + class CameraDevice : protected libcamera::Loggable { public: @@ -89,6 +94,7 @@ private: std::vector streamConfigurations_; std::map formatsMap_; + std::vector streams_; int facing_; int orientation_; From patchwork Thu Jul 2 21:36:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8562 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 28C3CBE905 for ; Thu, 2 Jul 2020 21:37:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E816360CB7; Thu, 2 Jul 2020 23:37:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="UAkwL3fi"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F1E760CAF for ; Thu, 2 Jul 2020 23:37:05 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D3E0A9CB; Thu, 2 Jul 2020 23:37:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593725825; bh=uxsftKNYobZPWTrZy4j2iN75Q+Y0qnB/6+Skua9w3SE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UAkwL3fidyylK2YtCeN/2Jm8uZ4LdoBrYhfgeJYSnEjfZDYKemU/6G1BvUO5jAdvN dW/SaxSAr2lEGUsOGVOlUGjPDa6dMsz4VkL8VKDmly6SaiTvNN6jfNKhVncCsaoM0T tlQvczikKm1+g8QHfWB737GAVPPik33z5NuW3Vvs= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:36:52 +0100 Message-Id: <20200702213654.2129054-8-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> References: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 7/9] android: camera_device: Add buffers for each stream to Requests 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" Construct a FrameBuffer for every buffer given in the camera3Request and add it to the libcamera Request on the appropriate stream. The correct stream is obtained from the private data of the camera3_stream associated with the camera3_buffer. Comments regarding supporting only one buffer are now removed. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 38 ++++++++++++++--------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index fc3962dac230..eea8c8c50352 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -977,6 +977,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) /* Maintain internal state of all stream mappings. */ streams_[i].androidStream = stream; + stream->priv = static_cast(&streams_[i]); StreamConfiguration streamConfiguration; @@ -1045,9 +1046,6 @@ static FrameBuffer *newFrameBuffer(const buffer_handle_t camera3buffer) int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request) { - StreamConfiguration *streamConfiguration = &config_->at(0); - Stream *stream = streamConfiguration->stream(); - if (camera3Request->num_output_buffers != 1) { LOG(HAL, Error) << "Invalid number of output buffers: " << camera3Request->num_output_buffers; @@ -1085,30 +1083,28 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques camera_->createRequest(reinterpret_cast(descriptor)); for (unsigned int i = 0; i < descriptor->numBuffers; ++i) { + CameraStream *cameraStream = static_cast(camera3Buffers[i].stream->priv); + /* * Keep track of which stream the request belongs to and store * the native buffer handles. - * - * \todo Currently we only support one capture buffer. Copy - * all of them to be ready once we'll support more. */ descriptor->buffers[i].stream = camera3Buffers[i].stream; descriptor->buffers[i].buffer = camera3Buffers[i].buffer; - } - /* - * Create a libcamera buffer using the dmabuf descriptors of the first - * and (currently) only supported request buffer. - */ - FrameBuffer *buffer = newFrameBuffer(*camera3Buffers[0].buffer); - if (!buffer) { - LOG(HAL, Error) << "Failed to create buffer"; - delete request; - delete descriptor; - return -ENOMEM; - } + FrameBuffer *buffer = newFrameBuffer(*camera3Buffers[0].buffer); + if (!buffer) { + LOG(HAL, Error) << "Failed to create buffer"; + delete request; + delete descriptor; + return -ENOMEM; + } + + StreamConfiguration *streamConfiguration = &config_->at(cameraStream->libcameraIndex); + Stream *stream = streamConfiguration->stream(); - request->addBuffer(stream, buffer); + request->addBuffer(stream, buffer); + } int ret = camera_->queueRequest(request); if (ret) { @@ -1142,10 +1138,6 @@ void CameraDevice::requestComplete(Request *request) captureResult.frame_number = descriptor->frameNumber; captureResult.num_output_buffers = descriptor->numBuffers; for (unsigned int i = 0; i < descriptor->numBuffers; ++i) { - /* - * \todo Currently we only support one capture buffer. Prepare - * all of them to be ready once we'll support more. - */ descriptor->buffers[i].acquire_fence = -1; descriptor->buffers[i].release_fence = -1; descriptor->buffers[i].status = status; From patchwork Thu Jul 2 21:36:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8563 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 77121BE905 for ; Thu, 2 Jul 2020 21:37:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 454F860CBC; Thu, 2 Jul 2020 23:37:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="qpjMbeT7"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 930B060C59 for ; Thu, 2 Jul 2020 23:37:05 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 3321FA2D; Thu, 2 Jul 2020 23:37:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593725825; bh=I1wp9s75ueoou49UbaFzesjuDck3Y2J7kqNLX/OAk2s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qpjMbeT7xn/zLzPJ4doX95htUIwMBc3vQLk7VadDLk4B8VjOxnb6WradC29MUMgm2 JZo00WwordyGxXsdaGGP1CdDnu+rdSqyFARFF4RWdQVTR10ng8hRtBktamsux3gkp+ ERQy8N11c5TfTZ9ADl4++YEKESvRnZEqfGrf2QBE= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:36:53 +0100 Message-Id: <20200702213654.2129054-9-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> References: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 8/9] android: camera_device: Remove single buffer restriction. 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" A capture request is no longer limited to a single output buffer. Remove the limitation, but (for now) keep the check to ensure that at least one buffer is always provided. This 'should never happen' so could be a LOG(Fatal) or removed. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- 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 eea8c8c50352..4681fd8af90b 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1046,7 +1046,7 @@ static FrameBuffer *newFrameBuffer(const buffer_handle_t camera3buffer) int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request) { - if (camera3Request->num_output_buffers != 1) { + if (camera3Request->num_output_buffers < 1) { LOG(HAL, Error) << "Invalid number of output buffers: " << camera3Request->num_output_buffers; return -EINVAL; From patchwork Thu Jul 2 21:36:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8564 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 DD510BE905 for ; Thu, 2 Jul 2020 21:37:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9E0F860C59; Thu, 2 Jul 2020 23:37:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="PfmaNaLe"; dkim-atps=neutral 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 EFB6460C64 for ; Thu, 2 Jul 2020 23:37:05 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 876049CB; Thu, 2 Jul 2020 23:37:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593725825; bh=p3mmoYXL1A+kaLsOv4/KaDG50/FQkOc3w+uf8npORwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PfmaNaLefmAZwCPvIS9kPCm7F4msXFTq7pxfyy4beiB3LP0NHO8fAUFw08S8W6IEC x+ZGK8rMVQ4OdrK57oPKB+KCToF+8aZJ2lyk7ZlLDeD+G0ezITqUPuzOTyRnFVScge wEN+xT6VmMF2k6T5RJSSUjPYtcBzJtw5S24YmP3o= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:36:54 +0100 Message-Id: <20200702213654.2129054-10-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> References: <20200702213654.2129054-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 9/9] android: camera_device: Report an error in notifyError() 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" If an error is generated, try to be verbose about it in the libcamera logs. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- src/android/camera_device.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 4681fd8af90b..5a3b4dfae6a0 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1192,6 +1192,9 @@ void CameraDevice::notifyError(uint32_t frameNumber, camera3_stream_t *stream) { camera3_notify_msg_t notify = {}; + LOG(HAL, Error) << "Error occured on frame " << frameNumber + << toPixelFormat(stream->format); + notify.type = CAMERA3_MSG_ERROR; notify.message.error.error_stream = stream; notify.message.error.frame_number = frameNumber;