From patchwork Mon Jul 6 23:02:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8663 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 6FEFEBD792 for ; Mon, 6 Jul 2020 23:02:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2E011603AD; Tue, 7 Jul 2020 01:02:50 +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="B1Mk8mUH"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F731603AD for ; Tue, 7 Jul 2020 01:02:47 +0200 (CEST) Received: from Q.local (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BA9D0AC6; Tue, 7 Jul 2020 01:02:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1594076567; bh=Ptc5zwAay6Z3ejmiQwbWhpduyqCOONZtcScINP8ZE9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B1Mk8mUHAdOmqrH5B/HW1IwIAbDpxrIPUmuOwi0ocQz+lWb+yR0lgURe3+nuxX6ZH xOWgiYJzYQg2ERZ1HHyI66CLJHZ2rypE3YsiIQVUhdiXicWKWdi81pThXH1iVapxZK MIoUyUqnDLEj6YvrnoKmxZEJ8Rj5qpTWRfcevzRI= From: Kieran Bingham To: libcamera devel Date: Tue, 7 Jul 2020 00:02:35 +0100 Message-Id: <20200706230240.2482100-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200706230240.2482100-1-kieran.bingham@ideasonboard.com> References: <20200706230240.2482100-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 3/8] 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