From patchwork Mon Aug 3 16:18:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 9148 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 79730BD86F for ; Mon, 3 Aug 2020 16:18:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3810361ACF; Mon, 3 Aug 2020 18:18:29 +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="odc+9DN3"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE863619CD for ; Mon, 3 Aug 2020 18:18:25 +0200 (CEST) Received: from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 73308DA7; Mon, 3 Aug 2020 18:18:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1596471505; bh=sGlt204RW56KeyLzNgiOWi8anTYrFWhaP7mkErKGcMU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=odc+9DN3AXwFJ1Lmrn++LVQzJ/eXfJR4JheMqdPDLX9INjsDd3X1Teb/spcplJqCV WVcj+K/axBEVlqgMjWo5tlmgZr2IhOr2+dXDU3E0w7XXucwNbH3YM25E81WcuRQHyi fW8p+7VSAOwK4tjmcULyUhBxb6U0LWez8zU7uKeQ= From: Kieran Bingham To: libcamera devel Date: Mon, 3 Aug 2020 17:18:12 +0100 Message-Id: <20200803161816.107113-9-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200803161816.107113-1-kieran.bingham@ideasonboard.com> References: <20200803161816.107113-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 08/12] android: camera_device: Query plane length 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" Use lseek to query the length of planes where possible rather than leaving the plane.length as zero, which prevents mapping buffers for software processing. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v2: - no longer support an invalid plane length. --- src/android/camera_device.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 78b0246e40f0..9f3f3315aed4 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1036,12 +1036,13 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer break; } - /* - * 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; + off_t length = lseek(plane.fd.fd(), 0, SEEK_END); + if (length == -1) { + LOG(HAL, Error) << "Failed to query plane length"; + break; + } + + plane.length = length; planes.push_back(std::move(plane)); }