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;