From patchwork Tue Jul 27 11:05:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 13128 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 43D13C322C for ; Tue, 27 Jul 2021 11:04:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0854F687C7; Tue, 27 Jul 2021 13:04:41 +0200 (CEST) Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A2B73687CB for ; Tue, 27 Jul 2021 13:04:37 +0200 (CEST) Received: (Authenticated sender: jacopo@jmondi.org) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id DA14B20003; Tue, 27 Jul 2021 11:04:36 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 27 Jul 2021 13:05:19 +0200 Message-Id: <20210727110519.11587-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210727110519.11587-1-jacopo@jmondi.org> References: <20210727110519.11587-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 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 Reviewed-by: Laurent Pinchart --- src/android/camera_capabilities.cpp | 37 +++++++++++++++++------------ src/android/camera_capabilities.h | 1 + 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/android/camera_capabilities.cpp b/src/android/camera_capabilities.cpp index 15e54192adff..709bfb2a4a19 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,28 @@ int CameraCapabilities::initializeStreamConfigurations() std::vector resolutions; const PixelFormatInfo &info = PixelFormatInfo::info(mappedFormat); - if (info.colourEncoding == PixelFormatInfo::ColourEncodingRAW) + switch (info.colourEncoding) { + case PixelFormatInfo::ColourEncodingRAW: + if (info.bitsPerPixel != 16) + continue; + + rawStreamAvailable_ = true; resolutions = initializeRawResolutions(mappedFormat); - else + break; + + case PixelFormatInfo::ColourEncodingYUV: + case PixelFormatInfo::ColourEncodingRGB: + /* + * We support enumerating RGB streams here to allow + * mapping IMPLEMENTATION_DEFINED format to RGB. + */ resolutions = initializeYUVResolutions(mappedFormat, cameraResolutions); + break; + + default: + continue; + } for (const Size &res : resolutions) { streamConfigurations_.push_back({ res, androidFormat }); @@ -866,22 +884,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_;