From patchwork Tue Aug 4 21:47:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 9201 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 B5C5DBD87A for ; Tue, 4 Aug 2020 21:47:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 864366054A; Tue, 4 Aug 2020 23:47:24 +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="B6iGX808"; 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 B219560550 for ; Tue, 4 Aug 2020 23:47:19 +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 302C4D37; Tue, 4 Aug 2020 23:47:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1596577639; bh=ujCUR6FrvnfglleLoNuAc0BOQuUW+UBhQt5qrF8eDOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B6iGX808CL9zbAW6TZ4TRvfyMOfttfS9BPrhn/ki/FjZA5/P5w8fUNj5KrWdFj/Em JA4Ye5Da1wmiW9q85+jBh7kl5Sr09RTrJk8ph6zmI21AGZgAfkSg1HryyXGFUyf76W PkPVydmbw4kJHrUaMQ55pgBlMqUeKVSzdfWEV2Aw= From: Kieran Bingham To: libcamera devel Date: Tue, 4 Aug 2020 22:47:06 +0100 Message-Id: <20200804214711.177645-9-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200804214711.177645-1-kieran.bingham@ideasonboard.com> References: <20200804214711.177645-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 08/13] 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. Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham --- src/android/camera_device.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index e4dce680d46f..087e226f5a82 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1082,9 +1082,20 @@ 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++) { + /* Skip unused planes. */ + if (camera3buffer->data[i] == -1) + break; + FrameBuffer::Plane plane; plane.fd = FileDescriptor(camera3buffer->data[i]); + if (!plane.fd.isValid()) { + LOG(HAL, Error) << "Failed to obtain FileDescriptor (" + << camera3buffer->data[i] << ") " + << " on plane " << i; + 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