From patchwork Sat Sep 12 10:11:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 9585 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 7C3DEC3B5B for ; Sat, 12 Sep 2020 10:08:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 51D8F62DB4; Sat, 12 Sep 2020 12:08:04 +0200 (CEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 023A962C8C for ; Sat, 12 Sep 2020 12:08:03 +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 relay8-d.mail.gandi.net (Postfix) with ESMTPSA id B4AE81BF206; Sat, 12 Sep 2020 10:08:00 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Sat, 12 Sep 2020 12:11:24 +0200 Message-Id: <20200912101129.12625-6-jacopo@jmondi.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200912101129.12625-1-jacopo@jmondi.org> References: <20200912101129.12625-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 05/10] 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. Reviewed-by: Hirokazu Honda Reviewed-by: Niklas Söderlund Acked-by: Laurent Pinchart Reviewed-by: Kieran Bingham Signed-off-by: Jacopo Mondi --- 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 0386287dc39d..0608d026e4b0 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -314,6 +314,17 @@ std::vector CameraDevice::getYUVResolutions(CameraConfiguration *cameraCon return supportedResolutions; } +std::vector CameraDevice::getRawResolutions(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 @@ -458,9 +469,15 @@ int CameraDevice::initializeStreamConfigurations() << camera3Format.name << " to " << mappedFormat.toString(); - std::vector resolutions = getYUVResolutions(cameraConfig.get(), - mappedFormat, - cameraResolutions); + std::vector resolutions; + const PixelFormatInfo &info = PixelFormatInfo::info(mappedFormat); + if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) + resolutions = getRawResolutions(mappedFormat); + else + resolutions = getYUVResolutions(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 1ff43327bab1..c0732fb8ed7f 100644 --- a/src/android/camera_device.h +++ b/src/android/camera_device.h @@ -97,6 +97,8 @@ private: getYUVResolutions(libcamera::CameraConfiguration *cameraConfig, const libcamera::PixelFormat &pixelFormat, const std::vector &resolutions); + std::vector + getRawResolutions(const libcamera::PixelFormat &pixelFormat); std::tuple calculateStaticMetadataSize(); libcamera::FrameBuffer *createFrameBuffer(const buffer_handle_t camera3buffer);