From patchwork Fri May 27 09:34:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 16069 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 0CACBC3256 for ; Fri, 27 May 2022 09:35:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5EBC465636; Fri, 27 May 2022 11:35:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653644101; bh=7CYHVaZYnY+zkqAW+k//gmQdHxECnDVyIDvHzRif/ok=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=RLTQA09/XuZTJLeP4WUDAvUuXTC8XhSFASNeCea/mgKWaCDKT6yFPDwjqMPkHxbZ2 incBjBk8/LlHc8w+mSto/Q07BvxsPVtHoC6RWI6okiMoHg5rVpq2n+6AKWKBt6ziuu YLKWp20Fy/pvIOE1orcD4A8X6l8D9UCBHCWAZgVexdW+7Eu6uqq+Ca7zqoe8bUoUpq 1+7sppjM5MK8COU6jm4uUBp92bOTS5o7UIMjOx0H+cLgrQ26GccgmqsmnbZlACi9bo pqr8VbNWmLaCr/nv9rdQrbHPBK+YSMg30IRQ9JgtS9amr0kQ2KsPOFR6T8Sten7AuR JqpUWd7lgbtPA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 247D9633A1 for ; Fri, 27 May 2022 11:34:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="ks08j0rE"; dkim-atps=neutral Received: from pyrite.rasen.tech (softbank036240126034.bbtec.net [36.240.126.34]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 69E5932A; Fri, 27 May 2022 11:34:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653644098; bh=7CYHVaZYnY+zkqAW+k//gmQdHxECnDVyIDvHzRif/ok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ks08j0rE0AEE3qYXTsgJp6fdwjijQR2J1fX1sI3GbmNIydlKKAPaT7CesdOhVi1VG 38DE62107YiSQKHVdsNdTPiaZDpivuCC4l9J5og8fpaQkQsnDL0OWCApRy3FSe9KWR FOpLzjFyVedS23CoggKnj2vw9TY2zcGIuw+MizC8= To: libcamera-devel@lists.libcamera.org Date: Fri, 27 May 2022 18:34:39 +0900 Message-Id: <20220527093440.953377-5-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220527093440.953377-1-paul.elder@ideasonboard.com> References: <20220527093440.953377-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/5] android: camera_device: Use YUV post-processor 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: , X-Patchwork-Original-From: Paul Elder via libcamera-devel From: Paul Elder Reply-To: Paul Elder Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Hirokazu Honda When creating the list of StreamConfiguration to be requested to the camera, map NV12 streams of equal size and format together, so that they will be generated by using the YUV post-processor. Signed-off-by: Hirokazu Honda Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/android/camera_device.cpp | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 95c14f60..9ee34b93 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -605,14 +605,40 @@ int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list) continue; } + /* + * While gralloc usage flags are supposed to report usage + * patterns to select a suitable buffer allocation strategy, in + * practice they're also used to make other decisions, such as + * selecting the actual format for the IMPLEMENTATION_DEFINED + * HAL pixel format. To avoid issues, we thus have to set the + * GRALLOC_USAGE_HW_CAMERA_WRITE flag unconditionally, even for + * streams that will be produced in software. + */ + stream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE; + + /* + * If a CameraStream with the same size and format of the + * current stream has already been requested, associate the two. + */ + auto iter = std::find_if( + streamConfigs.begin(), streamConfigs.end(), + [&size, &format](const Camera3StreamConfig &streamConfig) { + return streamConfig.config.size == size && + streamConfig.config.pixelFormat == format; + }); + if (iter != streamConfigs.end()) { + /* Add usage to copy the buffer in streams[0] to stream. */ + iter->streams[0].stream->usage |= GRALLOC_USAGE_SW_READ_OFTEN; + stream->usage |= GRALLOC_USAGE_SW_WRITE_OFTEN; + iter->streams.push_back({ stream, CameraStream::Type::Mapped }); + continue; + } + Camera3StreamConfig streamConfig; streamConfig.streams = { { stream, CameraStream::Type::Direct } }; streamConfig.config.size = size; streamConfig.config.pixelFormat = format; streamConfigs.push_back(std::move(streamConfig)); - - /* This stream will be produced by hardware. */ - stream->usage |= GRALLOC_USAGE_HW_CAMERA_WRITE; } /* Now handle the MJPEG streams, adding a new stream if required. */