From patchwork Wed Jul 16 14:20:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 23824 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 52E76C3237 for ; Wed, 16 Jul 2025 14:20:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 20EED68F7F; Wed, 16 Jul 2025 16:20:30 +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="LzcNZuJM"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 51B5068F61 for ; Wed, 16 Jul 2025 16:20:26 +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=etVhYdqh6LyXoRuJ2CwOvKldi5x18r3Wrrk+FbwMZFk=; b=LzcNZuJMJTiW7zjcHtEmQ1MC3h ZvLtbuBDIdAtuYWtzkmk8kmXwkeLvyJGkXc2o5oHu8/Jwa7yVfOwO56IBUTtY35W6+4Hw124u32oZ KoEahgjAvrPWqsCDCEnKLclzn5wCM0J4pCnI6p4zBiajCjaw2ke2KZTHpmwCGFjqectWhXa8lstvZ Q+PEoU78t8yzXOgE6bHdgtqrpgCvjPKJRLN4nCNGYQfEzw35T/wQUIDYgPXknC9IguBSBUO7tKVS8 B1ZgEW1lNCmMMrO99+G5JSpeuL2dg4p9vgAPdMfCQMq0cDQ6kvk6CUTE/oguH5VrXTCAJ0rdRg9uV 9OTauKWg==; 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 1uc2zh-00HLf5-Di; Wed, 16 Jul 2025 16:20:25 +0200 From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Robert Mader , Umang Jain Subject: [RFC PATCH 3/6] libcamera: simple: Support StreamRole::Raw in generateConfiguration() Date: Wed, 16 Jul 2025 19:50:23 +0530 Message-ID: <20250716142027.236277-4-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" Add stream role support for raw stream in generateConfiguration. If multiple raw streams are requested, make sure to invalidate them accordingly in validate(). Currently, only one raw stream per camera configuration is allowed. In order to get access to the raw formats supported by the sensor, one would require to iterate over SimpleCameraData::formats_ map in generateConfiguration(). This map not only include output configuration pixel formats but also the raw format configuration that can be produced (for raw roles). Signed-off-by: Umang Jain --- src/libcamera/pipeline/simple/simple.cpp | 50 ++++++++++++++++++++---- 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index cadc1117..d6c92391 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1128,6 +1128,23 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() LOG(SimplePipeline, Debug) << "Largest stream size is " << maxStreamSize; + /* Cap the number of raw stream configuration */ + unsigned int rawCount = 0; + PixelFormat requestedRawFormat; + for (const StreamConfiguration &cfg : config_) { + if (!isFormatRaw(cfg.pixelFormat)) + continue; + requestedRawFormat = cfg.pixelFormat; + rawCount++; + } + + if (rawCount > 1) { + LOG(SimplePipeline, Error) + << "Camera configuration with " + << rawCount << " raw streams not supported"; + return Invalid; + } + /* * Find the best configuration for the pipeline using a heuristic. * First select the pixel format based on the streams (which are @@ -1289,9 +1306,9 @@ SimplePipelineHandler::generateConfiguration(Camera *camera, Span> formats; - for (const SimpleCameraData::Configuration &cfg : data->configs_) { - for (PixelFormat format : cfg.outputFormats) - formats[format].push_back(cfg.outputSizes); + for (const auto &it : data->formats_) { + for (const SimpleCameraData::Configuration *cfg : it.second) + formats[it.first].push_back(cfg->outputSizes); } /* Sort the sizes and merge any consecutive overlapping ranges. */ @@ -1317,14 +1334,33 @@ SimplePipelineHandler::generateConfiguration(Camera *camera, Spanfirst; - cfg.size = formats.begin()->second[0].max; + + switch (role) { + case StreamRole::Raw: + for (auto &[format, sizes] : formats) { + if (!isFormatRaw(format)) + continue; + cfg.pixelFormat = format; + cfg.size = sizes.back().max; + cfg.colorSpace = ColorSpace::Raw; + break; + } + break; + default: + for (auto &[format, sizes] : formats) { + if (isFormatRaw(format)) + continue; + cfg.pixelFormat = format; + cfg.size = sizes[0].max; + } + } config->addConfiguration(cfg); }