From patchwork Mon Jul 26 15:30:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 13120 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 C0F56C322C for ; Mon, 26 Jul 2021 15:30:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 70B81687C4; Mon, 26 Jul 2021 17:30:20 +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 1D3F9687B7 for ; Mon, 26 Jul 2021 17:30:18 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 317321C0002; Mon, 26 Jul 2021 15:30:17 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 26 Jul 2021 17:30:58 +0200 Message-Id: <20210726153100.27856-2-jacopo@jmondi.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153100.27856-1-jacopo@jmondi.org> References: <20210726153100.27856-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] android: capabilities: Use a throw-away config for YUV stream building 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" When building the list of supported YUV streams in getYUVResolutions() the CameraConfiguration provided by the caller as first parameters is used. As the CameraConfiguration will be later actually applied to the Camera, avoid any possible overlap of the configuration parameters by using a throw-away CameraConfiguration generated for the Viewfinder stream role in getYUVResolutions(). It's also nicer to avoid having two functions with a similar purpose such as getYUVResolutions() and getRawResolutions() with different parameter lists, as the presence of a CameraConfiguration as first parameter might be confusing to the reader. Signed-off-by: Jacopo Mondi Reviewed-by: Laurent Pinchart Reviewed-by: Umang Jain --- src/android/camera_capabilities.cpp | 10 +++++----- src/android/camera_capabilities.h | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 6b5edb66fad2..6543c2bbc6c3 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -138,13 +138,14 @@ int CameraCapabilities::initialize(std::shared_ptr camera, return initializeStaticMetadata(); } -std::vector CameraCapabilities::getYUVResolutions(CameraConfiguration *cameraConfig, - const PixelFormat &pixelFormat, +std::vector CameraCapabilities::getYUVResolutions(const PixelFormat &pixelFormat, const std::vector &resolutions) { std::vector supportedResolutions; - + std::unique_ptr cameraConfig = + camera_->generateConfiguration({ StreamRole::Viewfinder }); StreamConfiguration &cfg = cameraConfig->at(0); + for (const Size &res : resolutions) { cfg.pixelFormat = pixelFormat; cfg.size = res; @@ -324,8 +325,7 @@ int CameraCapabilities::initializeStreamConfigurations() if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) resolutions = getRawResolutions(mappedFormat); else - resolutions = getYUVResolutions(cameraConfig.get(), - mappedFormat, + resolutions = getYUVResolutions(mappedFormat, cameraResolutions); for (const Size &res : resolutions) { diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h index 4f5be82595d6..e72bf084cd65 100644 --- a/src/android/camera_capabilities.h +++ b/src/android/camera_capabilities.h @@ -43,8 +43,7 @@ private: }; std::vector - getYUVResolutions(libcamera::CameraConfiguration *cameraConfig, - const libcamera::PixelFormat &pixelFormat, + getYUVResolutions(const libcamera::PixelFormat &pixelFormat, const std::vector &resolutions); std::vector getRawResolutions(const libcamera::PixelFormat &pixelFormat); From patchwork Mon Jul 26 15:30:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 13121 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 62636C322C for ; Mon, 26 Jul 2021 15:30:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DB725687C3; Mon, 26 Jul 2021 17:30:21 +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 678A5687AF for ; Mon, 26 Jul 2021 17:30:19 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 42C2A1C000D; Mon, 26 Jul 2021 15:30:18 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 26 Jul 2021 17:30:59 +0200 Message-Id: <20210726153100.27856-3-jacopo@jmondi.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153100.27856-1-jacopo@jmondi.org> References: <20210726153100.27856-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/3] android: capabilties: Rationalize get[YUV|Raw]Resolution names 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" The getYUVResolutions() and getRawResolutions() functions are called from the initializeStreamConfigurations() function, which is called by initialize(). Rationalize the function naming scheme by renaming the two functions to initializeYUVResolutions() and initializeRawResolution(). Cosmetic change only. Signed-off-by: Jacopo Mondi Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- src/android/camera_capabilities.cpp | 14 ++++++++------ src/android/camera_capabilities.h | 6 +++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 6543c2bbc6c3..15e54192adff 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -138,8 +138,9 @@ int CameraCapabilities::initialize(std::shared_ptr camera, return initializeStaticMetadata(); } -std::vector CameraCapabilities::getYUVResolutions(const PixelFormat &pixelFormat, - const std::vector &resolutions) +std::vector +CameraCapabilities::initializeYUVResolutions(const PixelFormat &pixelFormat, + const std::vector &resolutions) { std::vector supportedResolutions; std::unique_ptr cameraConfig = @@ -164,7 +165,8 @@ std::vector CameraCapabilities::getYUVResolutions(const PixelFormat &pixel return supportedResolutions; } -std::vector CameraCapabilities::getRawResolutions(const libcamera::PixelFormat &pixelFormat) +std::vector +CameraCapabilities::initializeRawResolutions(const libcamera::PixelFormat &pixelFormat) { std::unique_ptr cameraConfig = camera_->generateConfiguration({ StreamRole::Raw }); @@ -323,10 +325,10 @@ int CameraCapabilities::initializeStreamConfigurations() std::vector resolutions; const PixelFormatInfo &info = PixelFormatInfo::info(mappedFormat); if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) - resolutions = getRawResolutions(mappedFormat); + resolutions = initializeRawResolutions(mappedFormat); else - resolutions = getYUVResolutions(mappedFormat, - cameraResolutions); + resolutions = initializeYUVResolutions(mappedFormat, + cameraResolutions); for (const Size &res : resolutions) { streamConfigurations_.push_back({ res, androidFormat }); diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h index e72bf084cd65..e7aa46c0a689 100644 --- a/src/android/camera_capabilities.h +++ b/src/android/camera_capabilities.h @@ -43,10 +43,10 @@ private: }; std::vector - getYUVResolutions(const libcamera::PixelFormat &pixelFormat, - const std::vector &resolutions); + initializeYUVResolutions(const libcamera::PixelFormat &pixelFormat, + const std::vector &resolutions); std::vector - getRawResolutions(const libcamera::PixelFormat &pixelFormat); + initializeRawResolutions(const libcamera::PixelFormat &pixelFormat); int initializeStreamConfigurations(); int initializeStaticMetadata(); From patchwork Mon Jul 26 15:31:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 13122 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 7C312C322D for ; Mon, 26 Jul 2021 15:30:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 05959687C8; Mon, 26 Jul 2021 17:30:22 +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 CFF61687BA for ; Mon, 26 Jul 2021 17:30:19 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 36F9E1C0011; Mon, 26 Jul 2021 15:30:19 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Mon, 26 Jul 2021 17:31:00 +0200 Message-Id: <20210726153100.27856-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210726153100.27856-1-jacopo@jmondi.org> References: <20210726153100.27856-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] android: capabilities: Centralize RAW support check 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" The validation of RAW stream support is performed in two different places: - At initializeStreamConfigurations() time, by verifying that the libcamera format associated with HAL_PIXEL_FORMAT_BLOB is a Raw format and ensuring the Camera successfully validates it - As initializeStaticMetadata() time by generating a CameraConfiguration for the Raw stream role and ensuring it is a Raw format with a 16 bit depth The first check is used to build the list of supported Raw stream resolutions. The latter is used to register the ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW capability. As building the list of supported Raw streams doesn't serve any purpose if the RAW capability is not registered, centralize the Raw format support verification at initializeStreamConfigurations() time by ensuring the supported format is a Raw one with a 16 bit depth. Signed-off-by: Jacopo Mondi Reviewed-by: Umang Jain --- src/android/camera_capabilities.cpp | 25 ++++++++++--------------- src/android/camera_capabilities.h | 1 + 2 files changed, 11 insertions(+), 15 deletions(-) -- 2.32.0 diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 15e54192adff..12ffda2ee0b2 100644 --- a/src/android/camera_capabilities.cpp +++ b/src/android/camera_capabilities.cpp @@ -122,6 +122,7 @@ int CameraCapabilities::initialize(std::shared_ptr camera, camera_ = camera; orientation_ = orientation; facing_ = facing; + rawStreamAvailable_ = false; /* Acquire the camera and initialize available stream configurations. */ int ret = camera_->acquire(); @@ -324,11 +325,16 @@ int CameraCapabilities::initializeStreamConfigurations() std::vector resolutions; const PixelFormatInfo &info = PixelFormatInfo::info(mappedFormat); - if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) + if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) { + if (info.bitsPerPixel != 16) + continue; + + rawStreamAvailable_ = true; resolutions = initializeRawResolutions(mappedFormat); - else + } else { resolutions = initializeYUVResolutions(mappedFormat, cameraResolutions); + } for (const Size &res : resolutions) { streamConfigurations_.push_back({ res, androidFormat }); @@ -866,22 +872,11 @@ int CameraCapabilities::initializeStaticMetadata() }; /* Report if camera supports RAW. */ - bool rawStreamAvailable = false; - std::unique_ptr cameraConfig = - camera_->generateConfiguration({ StreamRole::Raw }); - if (cameraConfig && !cameraConfig->empty()) { - const PixelFormatInfo &info = - PixelFormatInfo::info(cameraConfig->at(0).pixelFormat); - /* Only advertise RAW support if RAW16 is possible. */ - if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW && - info.bitsPerPixel == 16) { - rawStreamAvailable = true; + if (rawStreamAvailable_) availableCapabilities.push_back(ANDROID_REQUEST_AVAILABLE_CAPABILITIES_RAW); - } - } /* Number of { RAW, YUV, JPEG } supported output streams */ - int32_t numOutStreams[] = { rawStreamAvailable, 2, 1 }; + int32_t numOutStreams[] = { rawStreamAvailable_, 2, 1 }; staticMetadata_->addEntry(ANDROID_REQUEST_MAX_NUM_OUTPUT_STREAMS, numOutStreams); diff --git a/src/android/camera_capabilities.h b/src/android/camera_capabilities.h index e7aa46c0a689..42a976d3b482 100644 --- a/src/android/camera_capabilities.h +++ b/src/android/camera_capabilities.h @@ -55,6 +55,7 @@ private: int facing_; int orientation_; + bool rawStreamAvailable_; std::vector streamConfigurations_; std::map formatsMap_;