From patchwork Fri Nov 21 16:30:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 25150 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 E77E5C3333 for ; Fri, 21 Nov 2025 16:30:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B21CE60AA0; Fri, 21 Nov 2025 17:30:35 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="hkPnhQmP"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CCED760805 for ; Fri, 21 Nov 2025 17:30:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763742632; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=4VrvobwgQXBg6CcAMlkWqBBp1AXK6P0HrvfdEZ2inN8=; b=hkPnhQmPeemj4CodyZuUaQWBsUBRtCsc2L4W7y3eI2MOjvQzCEmeRTp9lxTRpLqml9sGfH 7ZntROWHSOb4jJB2E0oHV4gCyqSs43+rbaPTtJbLLsJ5zB7a4fhM7qwjJBMcqswXBzUyIU 8B7mXN5TdYD7k88Ry+Lmpb56m24BA1U= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-31-2FvTxiTWN7Sb9NT0BQ-Log-1; Fri, 21 Nov 2025 11:30:26 -0500 X-MC-Unique: 2FvTxiTWN7Sb9NT0BQ-Log-1 X-Mimecast-MFC-AGG-ID: 2FvTxiTWN7Sb9NT0BQ-Log_1763742624 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B332F195DE7F; Fri, 21 Nov 2025 16:30:22 +0000 (UTC) Received: from mzamazal-thinkpadp1gen7.tpbc.com (unknown [10.44.32.212]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BD53818009A4; Fri, 21 Nov 2025 16:30:19 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Kieran Bingham , Laurent Pinchart , =?utf-8?b?QmFybmFiw6FzIFDFkWN6?= =?utf-8?q?e?= , Paul Elder , Umang Jain , Isaac Scott Subject: [PATCH v2] libcamera: software_isp: Assign colour spaces in configurations Date: Fri, 21 Nov 2025 17:30:16 +0100 Message-ID: <20251121163016.94159-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: vGkd_GB4hkuTPbaQDWfRSzGJA-Fp2FvEPHg3YyRfGgk_1763742624 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true 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" StreamConfiguration's should have colorSpace set. This is not the case in the simple pipeline. Let's set it there. This also fixes a crash in `cam' due to accessing an unset colorSpace. We set the colour spaces according to the pixel format. This is not completely correct because pixel formats and colour spaces are different, although not completely independent, things. But for the lack of a better practical option to determine the colour space, we use this. Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/294 Reviewed-by: Isaac Scott Signed-off-by: Milan Zamazal Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/simple/simple.cpp | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 118b4186c..c0d938cf0 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -36,6 +37,7 @@ #include "libcamera/internal/converter.h" #include "libcamera/internal/delayed_controls.h" #include "libcamera/internal/device_enumerator.h" +#include "libcamera/internal/formats.h" #include "libcamera/internal/global_configuration.h" #include "libcamera/internal/media_device.h" #include "libcamera/internal/pipeline_handler.h" @@ -1227,6 +1229,44 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() status = Adjusted; } + /* + * Best effort to fix the color space. If the color space is not set, + * set it according to the pixel format, which may not be correct (pixel + * formats and color spaces are different things, although somewhat + * related) but we don't have a better option at the moment. Then in any + * case, perform the standard pixel format based color space adjustment. + */ + if (!cfg.colorSpace) { + const PixelFormatInfo &info = PixelFormatInfo::info(pixelFormat); + switch (info.colourEncoding) { + case PixelFormatInfo::ColourEncodingRGB: + cfg.colorSpace = ColorSpace::Srgb; + break; + case PixelFormatInfo::ColourEncodingYUV: + cfg.colorSpace = ColorSpace::Sycc; + break; + default: + cfg.colorSpace = ColorSpace::Raw; + } + LOG(SimplePipeline, Debug) + << "Unspecified color space set to " + << cfg.colorSpace.value().toString(); + /* + * Adjust the assigned color space to make sure everything is OK. + * Since this is assigning an unspecified color space rather than + * adjusting a requested one, changes here shouldn't set the status + * to Adjusted. + */ + cfg.colorSpace->adjust(pixelFormat); + } else { + if (cfg.colorSpace->adjust(pixelFormat)) { + LOG(SimplePipeline, Debug) + << "Color space adjusted to " + << cfg.colorSpace.value().toString(); + status = Adjusted; + } + } + if (!pipeConfig_->outputSizes.contains(cfg.size)) { Size adjustedSize = pipeConfig_->captureSize; /*