From patchwork Mon Jul 20 22:42:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8898 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 AF0DCC0109 for ; Mon, 20 Jul 2020 22:42:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7C3CF6073C; 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="DNA/6x/m"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2FBDA607CB 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 AE2C09E7; Tue, 21 Jul 2020 00:42:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1595284958; bh=A9/O4GRyE6wLJVHxigPTzDQbLMi/FtROcKcri04dwk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DNA/6x/mAiqmqozP5YYAI9+DfeMZywiWx4zsIyMxtNqD3lpe/07JZcG1kD6IGkOgG 0Lzg7JkZxRqOZP4G/peo6UepXEvSWrLURJtGxDchbItmZBHRBV8G9QjE5WbmmYq/Qb fQCP981v+jOB558F+JkDSSFs3cuQskVt+0eEGFBk= From: Kieran Bingham To: libcamera devel Date: Mon, 20 Jul 2020 23:42:30 +0100 Message-Id: <20200720224232.153717-7-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 6/8] android: camera_device: Only construct required planes 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" The camera3buffer describes the number of filedescriptors given. Don't try to construct more planes than that. Signed-off-by: Kieran Bingham --- We always try to create 3 planes, and we never check if the FileDescriptor is valid. Instead, use the numFds provided by the camera3buffer, but check to see if the FileDescriptor was valid before adding the plane to the FrameBuffer. I have a further check in a later patch which skips planes where the camera3buffer->data[i] is already set to -1, so we know it's invalid, and this removes the warning below, leaving us with two planes created for all buffers tested using the Camera app. src/android/camera_device.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index e5c50084e590..538b8ab5da03 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1033,9 +1033,18 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) FrameBuffer *CameraDevice::createFrameBuffer(const buffer_handle_t camera3buffer) { std::vector planes; - for (unsigned int i = 0; i < 3; i++) { + for (int i = 0; i < camera3buffer->numFds; i++) { FrameBuffer::Plane plane; plane.fd = FileDescriptor(camera3buffer->data[i]); + + /* numFds is seemingly always 4... */ + if (!plane.fd.isValid()) { + LOG(HAL, Debug) << "Created an invalid plane... (" + << camera3buffer->data[i] << ") " + << i << "/" << camera3buffer->numFds; + 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