From patchwork Thu Jul 2 21:36:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8558 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 20C24BE905 for ; Thu, 2 Jul 2020 21:37:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3922860CAE; Thu, 2 Jul 2020 23:37:05 +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="J/U30J7Y"; 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 D580F60C57 for ; Thu, 2 Jul 2020 23:37:03 +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 78DA59CB; 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=1593725823; bh=nL5+T7KPz0mehrsJeDuwJ9jTjqay9rR1PgfhEJM22NQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=J/U30J7YsLxzqp7LVnVVAYIM9eJnl8HUcPnlRjWGZ8w8xlrRHUAVIEaa5pVEblVTw IhAVuLv5AocerSHxiLVmRsIjm8CWn8EVqCoATFBnoBvSOaq55XudkUVqkzeE4kAyqB sLRf1+ZX6wQ8Tgl+JDDjgKad/6ZBgCQU8h5OkOHo= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:36:48 +0100 Message-Id: <20200702213654.2129054-4-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 3/9] android: camera_device: Support multiple stream configurations 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" Create an initial Camera Configuration using an empty role set, and populate the StreamConfigurations manually from each of the streams given by the Android camera3_stream_configuration_t stream_list. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- src/android/camera_device.cpp | 51 +++++++++++++++++------------------ 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index b9031ff0c2a4..03dcdd520794 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -942,6 +942,16 @@ PixelFormat CameraDevice::toPixelFormat(int format) */ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) { + /* + * Generate an empty configuration, and construct a StreamConfiguration + * for each camera3_stream to add to it. + */ + config_ = camera_->generateConfiguration(); + if (!config_) { + LOG(HAL, Error) << "Failed to generate camera configuration"; + return -EINVAL; + } + for (unsigned int i = 0; i < stream_list->num_streams; ++i) { camera3_stream_t *stream = stream_list->streams[i]; @@ -953,35 +963,18 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) << ", height: " << stream->height << ", format: " << utils::hex(stream->format) << " (" << format.toString() << ")"; - } - /* Only one stream is supported. */ - if (stream_list->num_streams != 1) { - LOG(HAL, Error) << "Only one stream supported"; - return -EINVAL; - } - camera3_stream_t *camera3Stream = stream_list->streams[0]; + if (!format.isValid()) + return -EINVAL; - /* Translate Android format code to libcamera pixel format. */ - PixelFormat format = toPixelFormat(camera3Stream->format); - if (!format.isValid()) - return -EINVAL; + StreamConfiguration streamConfiguration; - /* - * Hardcode viewfinder role, replacing the generated configuration - * parameters with the ones requested by the Android framework. - */ - StreamRoles roles = { StreamRole::Viewfinder }; - config_ = camera_->generateConfiguration(roles); - if (!config_ || config_->empty()) { - LOG(HAL, Error) << "Failed to generate camera configuration"; - return -EINVAL; - } + streamConfiguration.size.width = stream->width; + streamConfiguration.size.height = stream->height; + streamConfiguration.pixelFormat = format; - StreamConfiguration *streamConfiguration = &config_->at(0); - streamConfiguration->size.width = camera3Stream->width; - streamConfiguration->size.height = camera3Stream->height; - streamConfiguration->pixelFormat = format; + config_->addConfiguration(streamConfiguration); + } switch (config_->validate()) { case CameraConfiguration::Valid: @@ -996,7 +989,13 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) return -EINVAL; } - camera3Stream->max_buffers = streamConfiguration->bufferCount; + for (unsigned int i = 0; i < stream_list->num_streams; ++i) { + camera3_stream_t *stream = stream_list->streams[i]; + StreamConfiguration &streamConfiguration = config_->at(i); + + /* Use the bufferCount confirmed by the validation process. */ + stream->max_buffers = streamConfiguration.bufferCount; + } /* * Once the CameraConfiguration has been adjusted/validated