From patchwork Mon Oct 5 10:46:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 9960 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 36B75C3B5F for ; Mon, 5 Oct 2020 10:47:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 02CB463C1F; Mon, 5 Oct 2020 12:47:44 +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="phrqZ+Gk"; 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 B9E4163C08 for ; Mon, 5 Oct 2020 12:47:38 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4D994A31; Mon, 5 Oct 2020 12:47:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1601894858; bh=UYKI8QlWPGQWBii1RikJ8CsvwuSY1PSlV+0b+XZHnJE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=phrqZ+Gkq6X2jh5T/sHhUTBinVlYgPp5El9SvmZBUQLRVhZgjyBwy8s3UQX/XEStc km4uxQXapyMx0MjWZ1mrD4v4RAeZpaQ4OsCa3Al+RZZl1iMnH1kdgdn5+IBiW3Kuxg ZOrmpU8xtUZr0mkeqgPra4Nl30V1qOeA8pgR04Jg= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Mon, 5 Oct 2020 13:46:47 +0300 Message-Id: <20201005104649.10812-14-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20201005104649.10812-1-laurent.pinchart@ideasonboard.com> References: <20201005104649.10812-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 13/15] android: camera_device: Use CameraStream buffers 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" From: Jacopo Mondi Now that CameraStream that require internal buffer allocation have been instrumented with a FrameBuffer pool, use them to create intermediate buffers in the CameraDevice. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/android/camera_device.cpp | 50 ++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 62307726aea9..186c9f724c3e 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -1390,24 +1390,47 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques descriptor->buffers[i].stream = camera3Buffers[i].stream; descriptor->buffers[i].buffer = camera3Buffers[i].buffer; - /* Software streams are handled after hardware streams complete. */ - if (cameraStream->outputFormat() == HAL_PIXEL_FORMAT_BLOB) - continue; - /* - * Create a libcamera buffer using the dmabuf descriptors of - * the camera3Buffer for each stream. The FrameBuffer is - * directly associated with the Camera3RequestDescriptor for - * lifetime management only. + * Inspect the camera stream type, create buffers opportunely + * and add them to the Request if required. */ - FrameBuffer *buffer = createFrameBuffer(*camera3Buffers[i].buffer); + FrameBuffer *buffer; + switch (cameraStream->type()) { + case CameraStream::Type::Mapped: + /* + * Mapped streams don't need buffers added to the + * Request. + */ + continue; + + case CameraStream::Type::Direct: + /* + * Create a libcamera buffer using the dmabuf + * descriptors of the camera3Buffer for each stream and + * associate it with the Camera3RequestDescriptor for + * lifetime management only. + */ + buffer = createFrameBuffer(*camera3Buffers[i].buffer); + descriptor->frameBuffers.emplace_back(buffer); + break; + + case CameraStream::Type::Internal: + /* + * Get the frame buffer from the CameraStream internal + * buffer pool. + * + * The buffer has to be returned to the CameraStream + * once it has been processed. + */ + buffer = cameraStream->getBuffer(); + break; + } if (!buffer) { LOG(HAL, Error) << "Failed to create buffer"; delete request; delete descriptor; return -ENOMEM; } - descriptor->frameBuffers.emplace_back(buffer); request->addBuffer(cameraStream->stream(), buffer); } @@ -1479,6 +1502,13 @@ void CameraDevice::requestComplete(Request *request) status = CAMERA3_BUFFER_STATUS_ERROR; continue; } + + /* + * Return the FrameBuffer to the CameraStream now that we're + * done processing it. + */ + if (cameraStream->type() == CameraStream::Type::Internal) + cameraStream->putBuffer(buffer); } /* Prepare to call back the Android camera stack. */