From patchwork Tue Sep 8 13:41:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 9536 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 6F6B0BDB1D for ; Tue, 8 Sep 2020 13:38:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4505A62C5E; Tue, 8 Sep 2020 15:38:13 +0200 (CEST) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D98E06056C for ; Tue, 8 Sep 2020 15:38:11 +0200 (CEST) X-Originating-IP: 2.224.242.101 Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 651841C0002; Tue, 8 Sep 2020 13:38:10 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 8 Sep 2020 15:41:36 +0200 Message-Id: <20200908134142.27470-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200908134142.27470-1-jacopo@jmondi.org> References: <20200908134142.27470-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 05/11] android: camera_device: Generate RAW resolutions 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: , Cc: hanlinchen@chromium.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The resolutions supported for the RAW formats cannot be tested from a list of known sizes like the processed ones. This is mainly due to the fact RAW streams are produced by capturing frames at the CSI-2 receiver output and their size corresponds to the sensor's native sizes. In order to obtain the RAW frame size generate a temporary CameraConfiguration for the Role::StillCaptureRAW role and inspect the map of StreamFormats returned by the pipeline handler. Acked-by: Laurent Pinchart Reviewed-by: Kieran Bingham Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund Reviewed-by: Hirokazu Honda --- src/android/camera_device.cpp | 23 ++++++++++++++++++++--- src/android/camera_device.h | 2 ++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp index 9d460906ab08..5f4b95987615 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -313,6 +313,17 @@ std::vector CameraDevice::filterYUVResolutions(CameraConfiguration *camera return supportedResolutions; } +std::vector CameraDevice::filterRawResolutions(const libcamera::PixelFormat &pixelFormat) +{ + std::unique_ptr cameraConfig = + camera_->generateConfiguration({ StillCaptureRaw }); + StreamConfiguration &cfg = cameraConfig->at(0); + const StreamFormats &formats = cfg.formats(); + std::vector supportedResolutions = formats.sizes(pixelFormat); + + return supportedResolutions; +} + /* * Initialize the format conversion map to translate from Android format * identifier to libcamera pixel formats and fill in the list of supported @@ -457,9 +468,15 @@ int CameraDevice::initializeStreamConfigurations() << camera3Format.name << " to " << mappedFormat.toString(); - std::vector resolutions = filterYUVResolutions(cameraConfig.get(), - mappedFormat, - cameraResolutions); + std::vector resolutions; + const PixelFormatInfo &info = PixelFormatInfo::info(mappedFormat); + if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) + resolutions = filterRawResolutions(mappedFormat); + else + resolutions = filterYUVResolutions(cameraConfig.get(), + mappedFormat, + cameraResolutions); + for (const Size &res : resolutions) { streamConfigurations_.push_back({ res, androidFormat }); diff --git a/src/android/camera_device.h b/src/android/camera_device.h index 359a163ebab9..dc0ee664d443 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -97,6 +97,8 @@ private: filterYUVResolutions(libcamera::CameraConfiguration *cameraConfig, const libcamera::PixelFormat &pixelFormat, const std::vector &resolutions); + std::vector + filterRawResolutions(const libcamera::PixelFormat &pixelFormat); std::tuple calculateStaticMetadataSize(); libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);