From patchwork Mon Jul 20 22:42:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8899 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 1CB24C2E67 for ; Mon, 20 Jul 2020 22:42:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DC799607CB; Tue, 21 Jul 2020 00:42:45 +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="qqekhroF"; 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 7CF6B6081E for ; Tue, 21 Jul 2020 00:42:39 +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 10C8EA49; Tue, 21 Jul 2020 00:42:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1595284959; bh=R+cpnFHtqQo7aKOYXlpN0kq0AcvZ7mdtSsLO3YpKlpE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qqekhroFRxLkckpLWE31ZppSeCaFApZTFq9FGxPfICjR013mgLJ8NXhBmSXAezV1q x973iSP1Ji3jP4NMhgg+lIPlzrglMsPyJU+jh1bdeWQv6dQC03jUzPm5SuPT5hL3qH /O6xI9NVwhITFX1KKy38ooBiJXD+7781NTHsLldg= From: Kieran Bingham To: libcamera devel Date: Mon, 20 Jul 2020 23:42:31 +0100 Message-Id: <20200720224232.153717-8-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200720224232.153717-1-kieran.bingham@ideasonboard.com> References: <20200720224232.153717-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 7/8] 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 --- I like this one ;-) We need to know the plane lengths for software streams now, but the correct way to get this would be to talk to the gralloc allocator. This would mean pulling in various extra cros-specific libraries, where instead we can query the size of the dmabuf by getting the offset when we SEEK_END. src/android/camera_device.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 538b8ab5da03..6212ccdd61ec 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1045,12 +1045,18 @@ FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer continue; } - /* - * 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) { + /* + * A zero length plane is not fatal unless the + * FrameBuffer is used for a software stream, libcamera + * itself will not access the internal frame content. + */ + LOG(HAL, Error) << "Failed to query plane length"; + length = 0; + } + + plane.length = length; planes.push_back(std::move(plane)); }