From patchwork Thu Jul 2 21:36:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 8562 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 28C3CBE905 for ; Thu, 2 Jul 2020 21:37:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E816360CB7; Thu, 2 Jul 2020 23:37:08 +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="UAkwL3fi"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3F1E760CAF for ; Thu, 2 Jul 2020 23:37:05 +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 D3E0A9CB; Thu, 2 Jul 2020 23:37:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593725825; bh=uxsftKNYobZPWTrZy4j2iN75Q+Y0qnB/6+Skua9w3SE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UAkwL3fidyylK2YtCeN/2Jm8uZ4LdoBrYhfgeJYSnEjfZDYKemU/6G1BvUO5jAdvN dW/SaxSAr2lEGUsOGVOlUGjPDa6dMsz4VkL8VKDmly6SaiTvNN6jfNKhVncCsaoM0T tlQvczikKm1+g8QHfWB737GAVPPik33z5NuW3Vvs= From: Kieran Bingham To: libcamera devel Date: Thu, 2 Jul 2020 22:36:52 +0100 Message-Id: <20200702213654.2129054-8-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 7/9] android: camera_device: Add buffers for each stream to Requests 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" Construct a FrameBuffer for every buffer given in the camera3Request and add it to the libcamera Request on the appropriate stream. The correct stream is obtained from the private data of the camera3_stream associated with the camera3_buffer. Comments regarding supporting only one buffer are now removed. Signed-off-by: Kieran Bingham Reviewed-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 38 ++++++++++++++--------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index fc3962dac230..eea8c8c50352 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -977,6 +977,7 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) /* Maintain internal state of all stream mappings. */ streams_[i].androidStream = stream; + stream->priv = static_cast(&streams_[i]); StreamConfiguration streamConfiguration; @@ -1045,9 +1046,6 @@ static FrameBuffer *newFrameBuffer(const buffer_handle_t camera3buffer) int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Request) { - StreamConfiguration *streamConfiguration = &config_->at(0); - Stream *stream = streamConfiguration->stream(); - if (camera3Request->num_output_buffers != 1) { LOG(HAL, Error) << "Invalid number of output buffers: " << camera3Request->num_output_buffers; @@ -1085,30 +1083,28 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques camera_->createRequest(reinterpret_cast(descriptor)); for (unsigned int i = 0; i < descriptor->numBuffers; ++i) { + CameraStream *cameraStream = static_cast(camera3Buffers[i].stream->priv); + /* * Keep track of which stream the request belongs to and store * the native buffer handles. - * - * \todo Currently we only support one capture buffer. Copy - * all of them to be ready once we'll support more. */ descriptor->buffers[i].stream = camera3Buffers[i].stream; descriptor->buffers[i].buffer = camera3Buffers[i].buffer; - } - /* - * Create a libcamera buffer using the dmabuf descriptors of the first - * and (currently) only supported request buffer. - */ - FrameBuffer *buffer = newFrameBuffer(*camera3Buffers[0].buffer); - if (!buffer) { - LOG(HAL, Error) << "Failed to create buffer"; - delete request; - delete descriptor; - return -ENOMEM; - } + FrameBuffer *buffer = newFrameBuffer(*camera3Buffers[0].buffer); + if (!buffer) { + LOG(HAL, Error) << "Failed to create buffer"; + delete request; + delete descriptor; + return -ENOMEM; + } + + StreamConfiguration *streamConfiguration = &config_->at(cameraStream->libcameraIndex); + Stream *stream = streamConfiguration->stream(); - request->addBuffer(stream, buffer); + request->addBuffer(stream, buffer); + } int ret = camera_->queueRequest(request); if (ret) { @@ -1142,10 +1138,6 @@ void CameraDevice::requestComplete(Request *request) captureResult.frame_number = descriptor->frameNumber; captureResult.num_output_buffers = descriptor->numBuffers; for (unsigned int i = 0; i < descriptor->numBuffers; ++i) { - /* - * \todo Currently we only support one capture buffer. Prepare - * all of them to be ready once we'll support more. - */ descriptor->buffers[i].acquire_fence = -1; descriptor->buffers[i].release_fence = -1; descriptor->buffers[i].status = status;