From patchwork Wed Jul 16 14:20:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 23825 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 55190C32C8 for ; Wed, 16 Jul 2025 14:20:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D00C368F81; Wed, 16 Jul 2025 16:20:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=igalia.com header.i=@igalia.com header.b="O9cJCLtD"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A6F8268F6E for ; Wed, 16 Jul 2025 16:20:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=9OZ41oDWYbu+b0piOe7uvPxGpJtW+hbDuA3SKY1xXSI=; b=O9cJCLtDDlk4NBJ2kfXVqxQSJ/ k31RTHgRVeMlEeoAFoE5VEQgNdFESlOlVC+6Bm1tWs7e0dd/PAHGzhMJS3mg1mn1ZwAyIjbXlwnot X/rk8jEQZsXCy8OjysTjXaJSqpduhuBhUTvWEla4KshhRtCHOyHZWxzVqn4DnGWjzxRIGLnzWFrtG eVW5pTWnaRUjapDQRZ7oIJuYZu/yDDEBIS0D7sVN3Gx2A0rmQDrh2HcyLoefX3/VTHryKNbPMc67z CJcp40UA6lC4DNQBYaLOZQpF3iGyGk6DnOdkD/GJIh7x/F+GFveag31qIhCU6iycO2WAzXLjCewZC fEvG7hFA==; Received: from [49.36.69.57] (helo=uajain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1uc2zi-00HLf5-Nn; Wed, 16 Jul 2025 16:20:27 +0200 From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Robert Mader , Umang Jain Subject: [RFC PATCH 4/6] libcamera: simple: Validate raw streams if requested Date: Wed, 16 Jul 2025 19:50:24 +0530 Message-ID: <20250716142027.236277-5-uajain@igalia.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250716142027.236277-1-uajain@igalia.com> References: <20250716142027.236277-1-uajain@igalia.com> MIME-Version: 1.0 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" Validate the raw streams if requested in the camera configuration. Initially check for a raw stream request and find a [format, size] that can satisfy that. Adjust the raw stream accordingly to the pipeline configuration (pipeConfig_), if necessary. Signed-off-by: Umang Jain --- src/libcamera/pipeline/simple/simple.cpp | 44 +++++++++++++++++------- 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index d6c92391..1dccfbb1 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1147,19 +1147,24 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() /* * Find the best configuration for the pipeline using a heuristic. - * First select the pixel format based on the streams (which are - * considered ordered from highest to lowest priority). Default to the - * first pipeline configuration if no streams request a supported pixel - * format. + * First select the pixel format based on the raw streams followed by + * non-raw streams (which are considered ordered from highest to lowest + * priority). Default to the first pipeline configuration if no streams + * request a supported pixel format. */ const std::vector *configs = &data_->formats_.begin()->second; - for (const StreamConfiguration &cfg : config_) { - auto it = data_->formats_.find(cfg.pixelFormat); - if (it != data_->formats_.end()) { - configs = &it->second; - break; + auto rawIter = data_->formats_.find(requestedRawFormat); + if (rawIter != data_->formats_.end()) { + configs = &rawIter->second; + } else { + for (const StreamConfiguration &cfg : config_) { + auto it = data_->formats_.find(cfg.pixelFormat); + if (it != data_->formats_.end()) { + configs = &it->second; + break; + } } } @@ -1218,8 +1223,23 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() for (unsigned int i = 0; i < config_.size(); ++i) { StreamConfiguration &cfg = config_[i]; + const bool raw = isFormatRaw(cfg.pixelFormat); + + /* Adjust the raw pixel format and size. */ + if (raw) { + if (cfg.pixelFormat != pipeConfig_->captureFormat || + cfg.size != pipeConfig_->captureSize) { + cfg.pixelFormat = pipeConfig_->captureFormat; + cfg.size = pipeConfig_->captureSize; + + LOG(SimplePipeline, Debug) + << "Adjusting raw stream to " + << cfg.toString(); + status = Adjusted; + } + } - /* Adjust the pixel format and size. */ + /* Adjust the non-raw pixel format and size. */ auto it = std::find(pipeConfig_->outputFormats.begin(), pipeConfig_->outputFormats.end(), cfg.pixelFormat); @@ -1227,13 +1247,13 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() it = pipeConfig_->outputFormats.begin(); PixelFormat pixelFormat = *it; - if (cfg.pixelFormat != pixelFormat) { + if (!raw && cfg.pixelFormat != pixelFormat) { LOG(SimplePipeline, Debug) << "Adjusting pixel format"; cfg.pixelFormat = pixelFormat; status = Adjusted; } - if (!pipeConfig_->outputSizes.contains(cfg.size)) { + if (!raw && !pipeConfig_->outputSizes.contains(cfg.size)) { Size adjustedSize = pipeConfig_->captureSize; /* * The converter (when present) may not be able to output