From patchwork Fri Jul 3 12:39:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8586 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 78F4CC2E69 for ; Fri, 3 Jul 2020 12:39:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A10F60CBA; Fri, 3 Jul 2020 14:39:30 +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="BGTTUla0"; 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 5948760C5F for ; Fri, 3 Jul 2020 14:39:26 +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 E743F296; Fri, 3 Jul 2020 14:39:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593779966; bh=xnbIs5VkNj6GWzGNYlUluZA8eoRrCVakgkVJxU2wTM0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BGTTUla0dGEsidEOt+lROEl5pYId3CQuX8HXiYi4OLoCdM3aX0ib7hEXggWI+kI7L pDCwkRRRB3lbIWKejyCwwlrfq9AmhZqyGXJwJXWiBMhA14Qzobk6v7qAE1bdjgNPjI fqw2fsQ3O86on0zbg3ymIlnIyh5jWHx/zuiXozxo= From: Kieran Bingham To: libcamera devel Date: Fri, 3 Jul 2020 13:39:17 +0100 Message-Id: <20200703123919.2223048-7-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200703123919.2223048-1-kieran.bingham@ideasonboard.com> References: <20200703123919.2223048-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 6/8] android: camera_device: Maintain a vector of CameraStream 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" Introduce a vector storing a CameraStream to track and maintain state between an Android stream (camera3_stream_t) and a libcamera Stream. Only the index of the libcamera stream is stored, to facilitate identifying the correct index for both the StreamConfiguration and Stream vectors. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund Reviewed-by: Jacopo Mondi --- src/android/camera_device.cpp | 22 ++++++++++++++++++++-- src/android/camera_device.h | 10 ++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 4e77a92dbea5..28334751a26e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -952,6 +952,20 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) return -EINVAL; } + /* + * Clear and remove any existing configuration from previous calls, and + * ensure the required entries are available without further + * re-allcoation. + */ + streams_.clear(); + streams_.reserve(stream_list->num_streams); + + /* + * Track actually created streams, as there may not be a 1:1 mapping of + * camera3 streams to libcamera streams. + */ + unsigned int streamIndex = 0; + for (unsigned int i = 0; i < stream_list->num_streams; ++i) { camera3_stream_t *stream = stream_list->streams[i]; @@ -974,6 +988,9 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) streamConfiguration.pixelFormat = format; config_->addConfiguration(streamConfiguration); + + /* Maintain internal state of all stream mappings. */ + streams_[i].index = streamIndex++; } switch (config_->validate()) { @@ -991,10 +1008,11 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) for (unsigned int i = 0; i < stream_list->num_streams; ++i) { camera3_stream_t *stream = stream_list->streams[i]; - StreamConfiguration &streamConfiguration = config_->at(i); + CameraStream *cameraStream = &streams_[i]; + StreamConfiguration &cfg = config_->at(cameraStream->index); /* Use the bufferCount confirmed by the validation process. */ - stream->max_buffers = streamConfiguration.bufferCount; + stream->max_buffers = cfg.bufferCount; } /* diff --git a/src/android/camera_device.h b/src/android/camera_device.h index d7834d94f439..8e306c1f6d8b 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -25,6 +25,15 @@ class CameraMetadata; +struct CameraStream { + /* + * The index represents the index for libcamera stream parameters. This + * will differ from any index of the halStream, particularly for HAL + * only streams such as MJPEG. + */ + unsigned int index; +}; + class CameraDevice : protected libcamera::Loggable { public: @@ -90,6 +99,7 @@ private: std::vector streamConfigurations_; std::map formatsMap_; + std::vector streams_; int facing_; int orientation_;