From patchwork Fri Jan 24 21:57:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22640 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 31D75BD78E for ; Fri, 24 Jan 2025 21:58:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CD7DD68561; Fri, 24 Jan 2025 22:58:33 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="fs05nu2h"; 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 8165568557 for ; Fri, 24 Jan 2025 22:58:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755910; 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: in-reply-to:in-reply-to:references:references; bh=TnlAtkDT63vSKs1/JVhFOfLW1cXnIYwGIT/DR9knAc4=; b=fs05nu2h+jTIxD2mJ8K9txxpd5IpF2YW9u+HbpalKggCFCwchd2MXESJBu/oGSEUzkeBJy e0BadTZVY7VRU17oRVEY3KACSsg9NAwVjpTPayeqGKe6VTIjSLQ4JRMPl582zg1VYZ7riL s1Pd8dJNzqYnqJwfYBO7kCK5zSyY0yQ= 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-421-ycPVPeH4N7OK_8teTfPi5Q-1; Fri, 24 Jan 2025 16:58:28 -0500 X-MC-Unique: ycPVPeH4N7OK_8teTfPi5Q-1 X-Mimecast-MFC-AGG-ID: ycPVPeH4N7OK_8teTfPi5Q Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 1DB7D19560B2 for ; Fri, 24 Jan 2025 21:58:28 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id EAE69180035D; Fri, 24 Jan 2025 21:58:26 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 01/13] libcamera: software_isp: Move a non-loop condition out of the loop Date: Fri, 24 Jan 2025 22:57:52 +0100 Message-ID: <20250124215806.158024-2-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: aUqC2gOclA7y6Ft3Yai8mpv1xlcLOq946DFh1SzNDrY_1737755908 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" The check for the number of outputs is done in a loop over the outputs. It should be moved out of the loop as it's not loop specific and is just repeated there. This is a cosmetic change not changing any functionality. Signed-off-by: Milan Zamazal Reviewed-by: Laurent Pinchart --- src/libcamera/software_isp/software_isp.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 2bea64d9..67b27727 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -290,13 +290,12 @@ int SoftwareIsp::queueBuffers(uint32_t frame, FrameBuffer *input, */ if (outputs.empty()) return -EINVAL; + if (outputs.size() != 1) /* only single stream atm */ + return -EINVAL; - for (auto [stream, buffer] : outputs) { + for (auto [stream, buffer] : outputs) if (!buffer) return -EINVAL; - if (outputs.size() != 1) /* only single stream atm */ - return -EINVAL; - } for (auto iter = outputs.begin(); iter != outputs.end(); iter++) process(frame, input, iter->second); From patchwork Fri Jan 24 21:57:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22641 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 C4FCCBD78E for ; Fri, 24 Jan 2025 21:58:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 44A8368564; Fri, 24 Jan 2025 22:58:37 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="AdqlTcgz"; 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 6306068559 for ; Fri, 24 Jan 2025 22:58:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755912; 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: in-reply-to:in-reply-to:references:references; bh=WGX6GD2cAr9nlaG+lwkbVwl+BBa/f+38muiF3/p/ftI=; b=AdqlTcgzmxM+2WADrUxZMbNg5JjXGiUGTJ8HH+FWqLKirvOJGjhiU/kEIRPHyh3gvg5EmO x/BaStVX04KXuOirfwzi23w7SLNGwcITBQXchQqk5qaawIJ6HTqXGNdDkJu9Tg/RZRRx2N oTHr075/qgu9yaLBbayn4nNT53rFAVU= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-379-aKVJsm59M_ii3TYh1DTD2A-1; Fri, 24 Jan 2025 16:58:30 -0500 X-MC-Unique: aKVJsm59M_ii3TYh1DTD2A-1 X-Mimecast-MFC-AGG-ID: aKVJsm59M_ii3TYh1DTD2A Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D94DF180034F for ; Fri, 24 Jan 2025 21:58:29 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id BF5E21800348; Fri, 24 Jan 2025 21:58:28 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 02/13] libcamera: simple: Increase the default number of streams to 2 Date: Fri, 24 Jan 2025 22:57:53 +0100 Message-ID: <20250124215806.158024-3-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: NOBTBfJCurXe-oLoRA4vMteTAxMS5DfLw5gu42RR5_E_1737755910 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" In order to allow providing a raw stream together with a processed stream, we need two streams. If only one stream is eventually requested, it doesn't harm to allocate two. This is a hack for the lack of a better easy option. The number of streams is determined as a camera property in the pipeline matching. The actual number of streams needed (one or two) is determined only when examining roles in SimplePipelineHandler::generateConfiguration. It's not obvious what to do better about the number of the streams. It seems that hardware pipelines utilize separate hardware streams while with software ISP we have only a single input for multiple outputs. A fixed number of streams also doesn't scale but is good enough for our current use case, which is supporting a single processed + a single raw stream, not more. Signed-off-by: Milan Zamazal --- src/libcamera/pipeline/simple/simple.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 8ac24e6e..6e9bc630 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1549,7 +1549,12 @@ int SimplePipelineHandler::resetRoutingTable(V4L2Subdevice *subdev) bool SimplePipelineHandler::match(DeviceEnumerator *enumerator) { const SimplePipelineInfo *info = nullptr; - unsigned int numStreams = 1; + /* + * Let's allocate two streams, for processed + raw streams. + * It's OK if there is only a single stream. + * TODO: This should be more flexible. + */ + unsigned int numStreams = 2; MediaDevice *media; for (const SimplePipelineInfo &inf : supportedDevices) { From patchwork Fri Jan 24 21:57:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22642 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 406D5BD78E for ; Fri, 24 Jan 2025 21:58:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CDAA86855F; Fri, 24 Jan 2025 22:58:39 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="IK0SiQGm"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3ABFB6855F for ; Fri, 24 Jan 2025 22:58:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755913; 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: in-reply-to:in-reply-to:references:references; bh=mUcRycCaCnNZu76AweWdRzH2/YrkoDlX5MLDSt6j0Hs=; b=IK0SiQGmOqbReWc+ko+f94+OLgUCu0m8O4udoSy0IidN3uyX4VrqPx1m2/nbJO61+hHuoD h7Bn3Goq3l9TZkPIevlKbJYay/WCVX6PxTbrFyFkG4DCgv7gLXGvV+uQPntjdPQMvyRlGt MUt06OhuyOmU+t7kAbc5z8gtnA4mMHY= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-614-2x2o4rxyMHWCcmigIOrZ6w-1; Fri, 24 Jan 2025 16:58:32 -0500 X-MC-Unique: 2x2o4rxyMHWCcmigIOrZ6w-1 X-Mimecast-MFC-AGG-ID: 2x2o4rxyMHWCcmigIOrZ6w Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 92828180034F for ; Fri, 24 Jan 2025 21:58:31 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 77C91180035D; Fri, 24 Jan 2025 21:58:30 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 03/13] libcamera: simple: Don't use raw output formats with conversions Date: Fri, 24 Jan 2025 22:57:54 +0100 Message-ID: <20250124215806.158024-4-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: qqalu-1o6ZRECYyG-8-pVXh89uaireqghIvxd6S0HMM_1737755911 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" In order to support raw streams, we need to add raw formats to software ISP configurations. In this preparatory patch, the raw formats are excluded from software ISP output configurations. Signed-off-by: Milan Zamazal --- src/libcamera/pipeline/simple/simple.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 6e9bc630..06df909b 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -209,6 +210,12 @@ static const SimplePipelineInfo supportedDevices[] = { { "sun6i-csi", {}, false }, }; +bool isRawFormat(const PixelFormat &format) +{ + return libcamera::PixelFormatInfo::info(format).colourEncoding == + libcamera::PixelFormatInfo::ColourEncodingRAW; +} + } /* namespace */ class SimpleCameraData : public Camera::Private @@ -1284,7 +1291,8 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) cfg.setStream(&data->streams_[i]); - if (data->useConversion_) + if (data->useConversion_ && + (!data->swIsp_ || !isRawFormat(cfg.pixelFormat))) outputCfgs.push_back(cfg); } From patchwork Fri Jan 24 21:57:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22643 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 DFFDAC322E for ; Fri, 24 Jan 2025 21:58:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B8F126856A; Fri, 24 Jan 2025 22:58:40 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="UlxL4y6j"; 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 F2B3F6855F for ; Fri, 24 Jan 2025 22:58:36 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755916; 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: in-reply-to:in-reply-to:references:references; bh=Zz46ARXrMy+iXL3UExR/gCA/Cf3Ddr7e7iZ8u3v4/b8=; b=UlxL4y6jj7DLKtQaAOcD0BVL0zs2Drad9hSVyRfWNo4t42gjYmBadFlJSYXIETuewkMm8L qX2OV5OCifU3YNC+gHllzSftNrX4SVm7g2QyGq35PPDKpS0KQPjvYeV/YO2GDaRMB8dzPi hU6B5Zjo2DM3hs8hapb+fuzPWN4s+7Q= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-802ezCsIPfiJwlaHp-86zQ-1; Fri, 24 Jan 2025 16:58:34 -0500 X-MC-Unique: 802ezCsIPfiJwlaHp-86zQ-1 X-Mimecast-MFC-AGG-ID: 802ezCsIPfiJwlaHp-86zQ Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6AF78180034F for ; Fri, 24 Jan 2025 21:58:33 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2EA681800344; Fri, 24 Jan 2025 21:58:31 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 04/13] libcamera: simple: Add plain output configurations to software ISP Date: Fri, 24 Jan 2025 22:57:55 +0100 Message-ID: <20250124215806.158024-5-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 56680BkD5zIunCMShLnJPBM0XciFdSoq91c9VOQHl78_1737755913 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" When software ISP is active, only software ISP adjusted output configurations are considered. We want to support raw streams together with software ISP and for that purpose, we need to track also unmodified configurations. A flag is added to SimpleCameraData::Configuration indicating whether it's for software ISP. Configurations for unmodified output sizes and formats are added now whether software ISP is active or not. We later filter formats and output sizes for particular stream configuration according to the new configuration flag. This is just preparation and raw output is still not supported; for this reason, we just look whether software ISP is active; this will be changed in followup patches. Signed-off-by: Milan Zamazal --- src/libcamera/pipeline/simple/simple.cpp | 30 ++++++++++++++---------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 06df909b..71853bb2 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -273,6 +273,7 @@ public: Size captureSize; std::vector outputFormats; SizeRange outputSizes; + bool swisp; }; std::vector streams_; @@ -654,19 +655,24 @@ void SimpleCameraData::tryPipeline(unsigned int code, const Size &size) config.sensorSize = size; config.captureFormat = pixelFormat; config.captureSize = format.size; + config.swisp = false; if (converter_) { config.outputFormats = converter_->formats(pixelFormat); config.outputSizes = converter_->sizes(format.size); - } else if (swIsp_) { - config.outputFormats = swIsp_->formats(pixelFormat); - config.outputSizes = swIsp_->sizes(pixelFormat, format.size); - if (config.outputFormats.empty()) { - /* Do not use swIsp for unsupported pixelFormat's. */ - config.outputFormats = { pixelFormat }; - config.outputSizes = config.captureSize; - } } else { + if (swIsp_) { + Configuration swispConfig = config; + swispConfig.outputFormats = swIsp_->formats(pixelFormat); + swispConfig.outputSizes = swIsp_->sizes(pixelFormat, format.size); + if (swispConfig.outputFormats.empty()) { + /* Do not use swIsp for unsupported pixelFormat's. */ + swispConfig.outputFormats = { pixelFormat }; + swispConfig.outputSizes = swispConfig.captureSize; + } + swispConfig.swisp = true; + configs_.push_back(swispConfig); + } config.outputFormats = { pixelFormat }; config.outputSizes = config.captureSize; } @@ -1185,10 +1191,10 @@ 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 SimpleCameraData::Configuration &cfg : data->configs_) + if (static_cast(data->swIsp_) == cfg.swisp) + for (PixelFormat format : cfg.outputFormats) + formats[format].push_back(cfg.outputSizes); /* Sort the sizes and merge any consecutive overlapping ranges. */ for (auto &[format, sizes] : formats) { From patchwork Fri Jan 24 21:57:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22644 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 90414C3317 for ; Fri, 24 Jan 2025 21:58:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8048268560; Fri, 24 Jan 2025 22:58:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="Q/JeOuDh"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B176368560 for ; Fri, 24 Jan 2025 22:58:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755917; 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: in-reply-to:in-reply-to:references:references; bh=izIxPbn8+fS35F2ms6tpqwo/+LWXW4Gb6klTsUUpRTU=; b=Q/JeOuDht1r0H43RZvCd02IrPMtlnEox6F4VOq2Xfdj99I4hNwpZLv7zBx9v1X/Oh7c0K/ o2XRdokb/7khQNV1LrkYBHmcfBjDVu11RODfsVKdSjfMfE0I9MUotKIpgxNC3hBx+/smSP 5lQtecOJhQocKSVnd/gahkvnPGX/GEc= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-240-YWY5XBKeMuuL5IygUwxiCg-1; Fri, 24 Jan 2025 16:58:36 -0500 X-MC-Unique: YWY5XBKeMuuL5IygUwxiCg-1 X-Mimecast-MFC-AGG-ID: YWY5XBKeMuuL5IygUwxiCg Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 32DBF1801F1D for ; Fri, 24 Jan 2025 21:58:35 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 10A0C1800344; Fri, 24 Jan 2025 21:58:33 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 05/13] libcamera: simple: Identify requested stream roles Date: Fri, 24 Jan 2025 22:57:56 +0100 Message-ID: <20250124215806.158024-6-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: yt1JyQhbHigENc9WdN6F2cW7vCbP7zgvOvOydQ49ZQU_1737755915 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" Currently, raw streams don't work in the simple pipeline and the requested stream roles are ignored. In order to support raw streams, we now track in SimpleCameraData whether raw and/or software ISP processed streams are requested. We also check that at most one raw stream is requested, there is no reason to have more. That information will be used in the followup patches. Signed-off-by: Milan Zamazal --- src/libcamera/pipeline/simple/simple.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 71853bb2..e6bbff5d 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -298,6 +298,8 @@ public: }; std::queue conversionQueue_; bool useConversion_; + bool swispRequested_; + bool rawRequested_; std::unique_ptr converter_; std::unique_ptr swIsp_; @@ -1188,6 +1190,22 @@ SimplePipelineHandler::generateConfiguration(Camera *camera, SpanswispRequested_ = false; + data->rawRequested_ = false; + if (data->swIsp_) { + for (auto &role : roles) + if (role == StreamRole::Raw) { + if (data->rawRequested_) { + LOG(SimplePipeline, Error) + << "Can't capture multiple raw streams"; + return nullptr; + } + data->rawRequested_ = true; + } else { + data->swispRequested_ = true; + } + } + /* Create the formats map. */ std::map> formats; From patchwork Fri Jan 24 21:57:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22645 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 0A63BBD78E for ; Fri, 24 Jan 2025 21:58:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6DA6F6856E; Fri, 24 Jan 2025 22:58:48 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="QrxoAcEP"; 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 5DA1268557 for ; Fri, 24 Jan 2025 22:58:40 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755919; 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: in-reply-to:in-reply-to:references:references; bh=VwI+G1adUdpE+lrmwxXmKBxPrBsN1UpAAMBa7aV5AOY=; b=QrxoAcEPyKNm5+TbLD6Eore5L8bckBO2ot1BQ6q033lF3zXTgDRJg5V3gN0bAHXT92TsVb i4R2kKee68CJpoeIgxNllajnUTvmKJMu+PCNo7b/NLq3/RWh8s/d3GqWrh847T79TrzTp5 mITQyiUax6vb7ieqAokRYsDdJEfxrf0= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-321-6yxzLxdUPg-0OR-ceXG3Jw-1; Fri, 24 Jan 2025 16:58:37 -0500 X-MC-Unique: 6yxzLxdUPg-0OR-ceXG3Jw-1 X-Mimecast-MFC-AGG-ID: 6yxzLxdUPg-0OR-ceXG3Jw Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id EA03E1801F0E for ; Fri, 24 Jan 2025 21:58:36 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D65CC1800344; Fri, 24 Jan 2025 21:58:35 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 06/13] libcamera: simple: Protect against null maxPipeConfig Date: Fri, 24 Jan 2025 22:57:57 +0100 Message-ID: <20250124215806.158024-7-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ylXTJo2kWLstyYMBgWHRV_lAnBR6d7JS6TnycWUh15k_1737755917 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" SimpleCameraData::pipeConfig_ is set to the determined maxPipeConfig if no better configuration is found. In the current code, maxPipeConfig should be always set. But it may be easy to miss that requirement and end up with null maxPipeConfig on contingent code changes. Let's add a check for nullptr to prevent segmentation fault surprises. It doesn't harm. Signed-off-by: Milan Zamazal --- src/libcamera/pipeline/simple/simple.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index e6bbff5d..300ebbc0 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1078,8 +1078,13 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() } /* If no configuration was large enough, select the largest one. */ - if (!pipeConfig_) + if (!pipeConfig_) { + if (!maxPipeConfig) { + LOG(SimplePipeline, Error) << "No valid configuration found"; + return Invalid; + } pipeConfig_ = maxPipeConfig; + } LOG(SimplePipeline, Debug) << "Picked " From patchwork Fri Jan 24 21:57:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22646 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 6576AC322E for ; Fri, 24 Jan 2025 21:58:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D66556856F; Fri, 24 Jan 2025 22:58:49 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="a3f7byDR"; 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 9313868566 for ; Fri, 24 Jan 2025 22:58:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755920; 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: in-reply-to:in-reply-to:references:references; bh=hxkwqm2DwyvoW4n6WNg+fr6+/JngK4l8jPqp3i7Cc2g=; b=a3f7byDRIHkeEWKwQPxkTZJA93fxwn/4tSYJNUymJhD46cR/SFdQaXA8LaSyeO8rM7y+Qg B3p73WR50M/uX3cLBjRFRq7O1WesqiCKBVdLd16cFul0BEkWtO4YHm1zo1h10ae8MFkmww F9jaQcYMw5hSQwM+FKp713Ko92SqM3g= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-695-8LlmnVsSNFqas74KJIz0hQ-1; Fri, 24 Jan 2025 16:58:39 -0500 X-MC-Unique: 8LlmnVsSNFqas74KJIz0hQ-1 X-Mimecast-MFC-AGG-ID: 8LlmnVsSNFqas74KJIz0hQ Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 65A8918009B8 for ; Fri, 24 Jan 2025 21:58:38 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 665061800344; Fri, 24 Jan 2025 21:58:37 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 07/13] libcamera: simple: Consider raw output configurations Date: Fri, 24 Jan 2025 22:57:58 +0100 Message-ID: <20250124215806.158024-8-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: e2RD9TCakXfdQvhduY1qPciIw7Za1HF2PXocTJO6tS8_1737755918 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" If there is no software ISP, all the output formats and sizes are relevant. If there is software ISP, take only software ISP configurations if there is no raw stream and only raw configurations (otherwise it wouldn't be possible to produce a correct passthrough output) if there is a raw stream. TODO: This change looks dubious but it works. Some form of filtering is definitely needed otherwise the followup overlap check leads to mess and incorrect output. Signed-off-by: Milan Zamazal --- src/libcamera/pipeline/simple/simple.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 300ebbc0..87a2043f 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1215,7 +1215,7 @@ SimplePipelineHandler::generateConfiguration(Camera *camera, Span> formats; for (const SimpleCameraData::Configuration &cfg : data->configs_) - if (static_cast(data->swIsp_) == cfg.swisp) + if (!data->swIsp_ || data->rawRequested_ != cfg.swisp) for (PixelFormat format : cfg.outputFormats) formats[format].push_back(cfg.outputSizes); From patchwork Fri Jan 24 21:57:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22647 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 ECC64BD78E for ; Fri, 24 Jan 2025 21:58:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 14C0A6856E; Fri, 24 Jan 2025 22:58:51 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="O+i1cG0/"; 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 26E576856D for ; Fri, 24 Jan 2025 22:58:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755923; 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: in-reply-to:in-reply-to:references:references; bh=QzXrvRvq0gETsT/aE6TGKpFDvf1zyuilwiuvEJuWHJY=; b=O+i1cG0/l1n+TSACAJORz3XV79WpAPe0GqyRaI9ogK7gYxpQJ+FHiKHqBzayB8+vYOyVgC vrU4oA3uT61etbVoMI+GDZuJ8LKoworNpd7YUI9DRvUj17zHGmd0uvc46f5mwhYJmEWvBo FfKtpbks83JSMgcc8buHIikMs2mlNdc= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-55--_4ILZHBNQuxKSt4NA0W_Q-1; Fri, 24 Jan 2025 16:58:41 -0500 X-MC-Unique: -_4ILZHBNQuxKSt4NA0W_Q-1 X-Mimecast-MFC-AGG-ID: -_4ILZHBNQuxKSt4NA0W_Q Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 9452F18009D9 for ; Fri, 24 Jan 2025 21:58:40 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E7EC11800358; Fri, 24 Jan 2025 21:58:38 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 08/13] libcamera: simple: Handle adjusted and raw configurations separately Date: Fri, 24 Jan 2025 22:57:59 +0100 Message-ID: <20250124215806.158024-9-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: dwzFz4kU25h9FciPU8ds-yigCD8_lBN5iOuUiDBmxG4_1737755920 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" When using software ISP to produce both a processed and a raw stream at the same time, we have to deal with two different output formats. When generating stream configurations, consider only raw formats for raw streams. Also, mark raw configurations using StreamConfiguration::colorSpace value, which is the only available place in StreamConfiguration for the purpose. When validating stream configurations, use separate check for sizes to produce raw and processed pipe configurations. Later, use the corresponding pipe configurations for raw and processed stream configurations. Signed-off-by: Milan Zamazal --- src/libcamera/pipeline/simple/simple.cpp | 90 ++++++++++++++++++++---- 1 file changed, 77 insertions(+), 13 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index 87a2043f..beb11069 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 @@ -1062,7 +1063,9 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() * without upscaling. */ const SimpleCameraData::Configuration *maxPipeConfig = nullptr; + const SimpleCameraData::Configuration *maxPipeConfigRaw = nullptr; pipeConfig_ = nullptr; + const SimpleCameraData::Configuration *pipeConfigRaw = nullptr; for (const SimpleCameraData::Configuration *pipeConfig : *configs) { const Size &size = pipeConfig->captureSize; @@ -1075,6 +1078,17 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() if (!maxPipeConfig || maxPipeConfig->captureSize < size) maxPipeConfig = pipeConfig; + + if (!pipeConfig->swisp) { + if (size.width >= maxStreamSize.width && + size.height >= maxStreamSize.height) { + if (!pipeConfigRaw || size < pipeConfigRaw->captureSize) + pipeConfigRaw = pipeConfig; + } + + if (!maxPipeConfigRaw || maxPipeConfigRaw->captureSize < size) + maxPipeConfigRaw = pipeConfig; + } } /* If no configuration was large enough, select the largest one. */ @@ -1085,6 +1099,13 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() } pipeConfig_ = maxPipeConfig; } + if (data_->rawRequested_ && !pipeConfigRaw) { + if (!maxPipeConfigRaw) { + LOG(SimplePipeline, Error) << "No valid configuration for raw found"; + return Invalid; + } + pipeConfigRaw = maxPipeConfigRaw; + } LOG(SimplePipeline, Debug) << "Picked " @@ -1092,6 +1113,14 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() << " -> " << pipeConfig_->captureSize << "-" << pipeConfig_->captureFormat << " for max stream size " << maxStreamSize; + if (pipeConfigRaw) { + LOG(SimplePipeline, Info) + << "Picked raw " + << V4L2SubdeviceFormat{ pipeConfigRaw->code, pipeConfigRaw->sensorSize, {} } + << " -> " << pipeConfigRaw->captureSize + << "-" << pipeConfigRaw->captureFormat + << " for max stream size " << maxStreamSize; + } /* * Adjust the requested streams. @@ -1110,31 +1139,50 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() for (unsigned int i = 0; i < config_.size(); ++i) { StreamConfiguration &cfg = config_[i]; + const SimpleCameraData::Configuration *pipeConfig = + (cfg.colorSpace == ColorSpace::Raw ? pipeConfigRaw : pipeConfig_); + if (!pipeConfig) + continue; /* Adjust the pixel format and size. */ - auto it = std::find(pipeConfig_->outputFormats.begin(), - pipeConfig_->outputFormats.end(), + auto it = std::find(pipeConfig->outputFormats.begin(), + pipeConfig->outputFormats.end(), cfg.pixelFormat); - if (it == pipeConfig_->outputFormats.end()) - it = pipeConfig_->outputFormats.begin(); + if (it == pipeConfig->outputFormats.end()) + it = pipeConfig->outputFormats.begin(); PixelFormat pixelFormat = *it; if (cfg.pixelFormat != pixelFormat) { + if (isRawFormat(pixelFormat)) { + LOG(SimplePipeline, Error) + << "Cannot convert pixel format with raw output (from " + << cfg.pixelFormat << " to " + << pixelFormat << ")"; + return Invalid; + } LOG(SimplePipeline, Debug) << "Adjusting pixel format"; cfg.pixelFormat = pixelFormat; status = Adjusted; } - if (!pipeConfig_->outputSizes.contains(cfg.size)) { - Size adjustedSize = pipeConfig_->captureSize; + if (!pipeConfig->outputSizes.contains(cfg.size)) { + Size adjustedSize = pipeConfig->captureSize; /* * The converter (when present) may not be able to output * a size identical to its input size. The capture size is thus * not guaranteed to be a valid output size. In such cases, use * the smaller valid output size closest to the requested. */ - if (!pipeConfig_->outputSizes.contains(adjustedSize)) - adjustedSize = adjustSize(cfg.size, pipeConfig_->outputSizes); + if (!pipeConfig->outputSizes.contains(adjustedSize)) { + if (isRawFormat(pixelFormat)) { + LOG(SimplePipeline, Error) + << "Cannot adjust output size with raw output (from " + << cfg.pixelFormat << " to " + << pixelFormat << ")"; + return Invalid; + } + adjustedSize = adjustSize(cfg.size, pipeConfig->outputSizes); + } LOG(SimplePipeline, Debug) << "Adjusting size from " << cfg.size << " to " << adjustedSize; @@ -1143,8 +1191,8 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() } /* \todo Create a libcamera core class to group format and size */ - if (cfg.pixelFormat != pipeConfig_->captureFormat || - cfg.size != pipeConfig_->captureSize) + if (cfg.pixelFormat != pipeConfig->captureFormat || + cfg.size != pipeConfig->captureSize) needConversion_ = true; /* Set the stride, frameSize and bufferCount. */ @@ -1246,10 +1294,26 @@ SimplePipelineHandler::generateConfiguration(Camera *camera, Spanfirst; - cfg.size = formats.begin()->second[0].max; + if (role == StreamRole::Raw) { + bool found = false; + for (auto &[format, sizes] : formats) + if (isRawFormat(format)) { + cfg.pixelFormat = format; + cfg.size = sizes[0].max; + found = true; + break; + } + if (!found) { + LOG(SimplePipeline, Error) << "Raw stream requested but no raw format found "; + return nullptr; + } + cfg.colorSpace = ColorSpace::Raw; + } else { + cfg.pixelFormat = formats.begin()->first; + cfg.size = formats.begin()->second[0].max; + } config->addConfiguration(cfg); } From patchwork Fri Jan 24 21:58:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22648 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 19BEFC3317 for ; Fri, 24 Jan 2025 21:58:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 82FCE6856F; Fri, 24 Jan 2025 22:58:53 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="eC1lZ65V"; 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 8B26968560 for ; Fri, 24 Jan 2025 22:58:45 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755924; 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: in-reply-to:in-reply-to:references:references; bh=zuI3BxRYUL0cX+3pihOg5wk5W8vNyJc2b3IfyyVC/vY=; b=eC1lZ65V8Y5ZfRZVxgdO7raUQc9CL7jXgVw0Fzt772wMBxZNcFBhqNA2HINWarMX6PINE1 aDBq2L24OAORY/6sg9dIYRhMJj5Bpsa3m8Yn++lJ/FDPDblZJWla575lOtb6jnqG+2XYG7 ngyAMQ8VDnpogFiFCOXS7YKeaGb9Ce0= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-307-qVfvcLaVOLyb-yZ6VZMEmA-1; Fri, 24 Jan 2025 16:58:43 -0500 X-MC-Unique: qVfvcLaVOLyb-yZ6VZMEmA-1 X-Mimecast-MFC-AGG-ID: qVfvcLaVOLyb-yZ6VZMEmA Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6E0971801F14 for ; Fri, 24 Jan 2025 21:58:42 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 317DA1800344; Fri, 24 Jan 2025 21:58:40 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 09/13] libcamera: simple: Don't use conversion with an added raw stream Date: Fri, 24 Jan 2025 22:58:00 +0100 Message-ID: <20250124215806.158024-10-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 7U2dKJt7N08gZ6GPJ2DuRE3wVYK_3MqZ053Cwd7uBeo_1737755922 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" When a raw stream is requested, either alone or together with a processed stream, it can be produced without conversion. Let's amend the corresponding check on the number of configurations accordingly. Signed-off-by: Milan Zamazal --- src/libcamera/pipeline/simple/simple.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index beb11069..edf08666 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1135,7 +1135,7 @@ CameraConfiguration::Status SimpleCameraConfiguration::validate() * require any conversion, similar to raw capture use cases). This is * left as a future improvement. */ - needConversion_ = config_.size() > 1; + needConversion_ = config_.size() > 1 + (data_->rawRequested_ ? 1 : 0); for (unsigned int i = 0; i < config_.size(); ++i) { StreamConfiguration &cfg = config_[i]; From patchwork Fri Jan 24 21:58:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22649 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 6410CC3318 for ; Fri, 24 Jan 2025 21:58:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 90D5168574; Fri, 24 Jan 2025 22:58:54 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="EWBI36wF"; 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 61E4B68566 for ; Fri, 24 Jan 2025 22:58:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755926; 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: in-reply-to:in-reply-to:references:references; bh=eByf0H1h1y8yWpRpZaZ3V/+eufydfV6gXozyz6269h4=; b=EWBI36wFDFdV9bT7hY2Xotw82j2RLVarMCsuPMhcQXyPJtYcA7Om+yWbLaxJaMxfW832/r ccA8YV8ApoRe6yabQDAtjgQA+3or/K/fPhvCuLVlsityPA5qVkxjxtCbp19UNVq74UXFgi 7UVHbaRABmWfZMaCLqDWrn5MdZQeZF0= 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-539-7Q6Pqx_6PE2orGeH4WCKJg-1; Fri, 24 Jan 2025 16:58:45 -0500 X-MC-Unique: 7Q6Pqx_6PE2orGeH4WCKJg-1 X-Mimecast-MFC-AGG-ID: 7Q6Pqx_6PE2orGeH4WCKJg Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 4E49019560B0 for ; Fri, 24 Jan 2025 21:58:44 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0B2951800348; Fri, 24 Jan 2025 21:58:42 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 10/13] libcamera: simple: Make raw streams working Date: Fri, 24 Jan 2025 22:58:01 +0100 Message-ID: <20250124215806.158024-11-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MMW8pWA3VwwNif1Ejwb41b1qIkiZ7ZyykdMv35j5ww0_1737755924 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" When a raw stream is requested, whether alone or together with a processed stream, its buffers must be handled outside the software ISP machinery. They serve as input buffers, even when a processed stream is produced. At most one raw stream and at most one processed stream are supported and can be combined. An example of producing both raw and processed files using `cam' application: cam -c1 -C100 -s role=raw,width=1920,height=1080,pixelformat=SRGGB8 -s role=viewfinder,width=1920,height=1080,pixelformat=RGB888 -Ffile# This is the final step to make raw streams working. Signed-off-by: Milan Zamazal --- src/libcamera/pipeline/simple/simple.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index edf08666..23456cbf 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -824,7 +824,8 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer) * buffer for capture (unless the stream is being stopped), and * complete the request with all the user-facing buffers. */ - if (buffer->metadata().status != FrameMetadata::FrameCancelled) + if (buffer->metadata().status != FrameMetadata::FrameCancelled && + !rawRequested_) video_->queueBuffer(buffer); if (conversionQueue_.empty()) @@ -870,13 +871,14 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer) */ if (useConversion_) { if (conversionQueue_.empty()) { - video_->queueBuffer(buffer); + if (!rawRequested_) + video_->queueBuffer(buffer); return; } if (converter_) converter_->queueBuffers(buffer, conversionQueue_.front().outputs); - else + else if (swispRequested_) /* * request->sequence() cannot be retrieved from `buffer' inside * queueBuffers because unique_ptr's make buffer->request() invalid @@ -886,6 +888,8 @@ void SimpleCameraData::imageBufferReady(FrameBuffer *buffer) conversionQueue_.front().outputs); conversionQueue_.pop(); + if (rawRequested_) + pipe->completeBuffer(request, buffer); return; } @@ -905,7 +909,8 @@ void SimpleCameraData::clearIncompleteRequests() void SimpleCameraData::conversionInputDone(FrameBuffer *buffer) { /* Queue the input buffer back for capture. */ - video_->queueBuffer(buffer); + if (!rawRequested_) + video_->queueBuffer(buffer); } void SimpleCameraData::conversionOutputDone(FrameBuffer *buffer) @@ -1450,7 +1455,7 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL return -EBUSY; } - if (data->useConversion_) { + if (data->useConversion_ && !data->rawRequested_) { /* * When using the converter allocate a fixed number of internal * buffers. @@ -1458,7 +1463,7 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL ret = video->allocateBuffers(kNumInternalBuffers, &data->conversionBuffers_); } else { - /* Otherwise, prepare for using buffers from the only stream. */ + /* Otherwise, prepare for using buffers from the only or raw stream. */ Stream *stream = &data->streams_[0]; ret = video->importBuffers(stream->configuration().bufferCount); } @@ -1489,8 +1494,9 @@ int SimplePipelineHandler::start(Camera *camera, [[maybe_unused]] const ControlL } /* Queue all internal buffers for capture. */ - for (std::unique_ptr &buffer : data->conversionBuffers_) - video->queueBuffer(buffer.get()); + if (!data->rawRequested_) + for (std::unique_ptr &buffer : data->conversionBuffers_) + video->queueBuffer(buffer.get()); } return 0; @@ -1532,7 +1538,7 @@ int SimplePipelineHandler::queueRequestDevice(Camera *camera, Request *request) * queue, it will be handed to the converter in the capture * completion handler. */ - if (data->useConversion_) { + if (data->useConversion_ && !isRawFormat(stream->configuration().pixelFormat)) { buffers.emplace(stream, buffer); } else { ret = data->video_->queueBuffer(buffer); From patchwork Fri Jan 24 21:58:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22650 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 E2603C3319 for ; Fri, 24 Jan 2025 21:58:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EF96968570; Fri, 24 Jan 2025 22:58:55 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="PO6vvsJ/"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1527368570 for ; Fri, 24 Jan 2025 22:58:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755929; 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: in-reply-to:in-reply-to:references:references; bh=N6GxpBlKdCyszf0pHCU4cziDuXHXEmVNDzCjqyhnaEU=; b=PO6vvsJ/szOWji/71QIihccuPDU0UxWSgECiRAzxLg8P+tBxDFD0EttvhdGg4EE8sYQGhQ 0qeniV5saQmfzt5pOlbyPkgl1Bb/yyA5XBPnmCvxM1IB3FV33UhjJGDgAiVbdbzfJhYHUL VzssYO0f518E04b3JqU/SDdd2Q6YTQM= 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-102-0S1zZX0RNDuDUSGmnOLxCg-1; Fri, 24 Jan 2025 16:58:47 -0500 X-MC-Unique: 0S1zZX0RNDuDUSGmnOLxCg-1 X-Mimecast-MFC-AGG-ID: 0S1zZX0RNDuDUSGmnOLxCg Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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 0AE9019560B0 for ; Fri, 24 Jan 2025 21:58:46 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D9A3E1800348; Fri, 24 Jan 2025 21:58:44 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 11/13] apps: ppm_writer: Add a missing include Date: Fri, 24 Jan 2025 22:58:02 +0100 Message-ID: <20250124215806.158024-12-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: lpLUNJ5zAG6b_ez3KFMhMWGlCDq7PonS3_scH5PzGZw_1737755926 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" should be included in the ppm writer, as the source of the error code constants used there. Signed-off-by: Milan Zamazal Reviewed-by: Laurent Pinchart --- src/apps/common/ppm_writer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/apps/common/ppm_writer.cpp b/src/apps/common/ppm_writer.cpp index d6c8641d..2e9378aa 100644 --- a/src/apps/common/ppm_writer.cpp +++ b/src/apps/common/ppm_writer.cpp @@ -7,6 +7,7 @@ #include "ppm_writer.h" +#include #include #include From patchwork Fri Jan 24 21:58:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22651 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 D8474BD78E for ; Fri, 24 Jan 2025 21:59:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 672356857B; Fri, 24 Jan 2025 22:59:00 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="WP1GZGJ2"; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1DF6C68573 for ; Fri, 24 Jan 2025 22:58:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755930; 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: in-reply-to:in-reply-to:references:references; bh=Oup9EkCW8txjzvZhDFrT3P7CbR8CfzPHfc31GtirLO8=; b=WP1GZGJ2jdaKQxBKIC4Vp4oBOAXCTLXy4WU/CJBSqCbKd93kLJ63zVbt4NwlvPj4xX9E1y nmpgtc5IhbE7Qux86e822njTl2dZFoOc06Ic6DSbhdG2kQHxpPO3IPsUgsqv/YNzP65Lj+ s7rH8XjJw4JDjnZtdj5+2fx1+ihWPcI= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-472-bGPOFFHZMAWCd3c98dZ3Jg-1; Fri, 24 Jan 2025 16:58:48 -0500 X-MC-Unique: bGPOFFHZMAWCd3c98dZ3Jg-1 X-Mimecast-MFC-AGG-ID: bGPOFFHZMAWCd3c98dZ3Jg Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id ACC67180034D for ; Fri, 24 Jan 2025 21:58:47 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9A5071800344; Fri, 24 Jan 2025 21:58:46 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 12/13] apps: ppm_writer: Return EIO on I/O errors Date: Fri, 24 Jan 2025 22:58:03 +0100 Message-ID: <20250124215806.158024-13-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: kFnXOlazXIKGSyPENYrHwd5bKY1YwQgEVWo_Xt-JKqg_1737755927 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" EINVAL should be returned only when the requested format is unsupported. On errors when writing the data, let's return EIO, which is the closest description of the situation when we don't inspect it more. Signed-off-by: Milan Zamazal Reviewed-by: Laurent Pinchart --- src/apps/common/ppm_writer.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/apps/common/ppm_writer.cpp b/src/apps/common/ppm_writer.cpp index 2e9378aa..368de8bf 100644 --- a/src/apps/common/ppm_writer.cpp +++ b/src/apps/common/ppm_writer.cpp @@ -29,7 +29,7 @@ int PPMWriter::write(const char *filename, std::ofstream output(filename, std::ios::binary); if (!output) { std::cerr << "Failed to open ppm file: " << filename << std::endl; - return -EINVAL; + return -EIO; } output << "P6" << std::endl @@ -37,7 +37,7 @@ int PPMWriter::write(const char *filename, << "255" << std::endl; if (!output) { std::cerr << "Failed to write the file header" << std::endl; - return -EINVAL; + return -EIO; } const unsigned int rowLength = config.size.width * 3; @@ -46,7 +46,7 @@ int PPMWriter::write(const char *filename, output.write(row, rowLength); if (!output) { std::cerr << "Failed to write image data at row " << y << std::endl; - return -EINVAL; + return -EIO; } } From patchwork Fri Jan 24 21:58:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Zamazal X-Patchwork-Id: 22652 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 9C641C322E for ; Fri, 24 Jan 2025 21:59:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2A8056856F; Fri, 24 Jan 2025 22:59:02 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="JG376bKE"; 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 2A50E6857A for ; Fri, 24 Jan 2025 22:58:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737755933; 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: in-reply-to:in-reply-to:references:references; bh=lwce1DZOVj1hcy0X3NaOakK2sv5Id5eOhgvaBoGXNb0=; b=JG376bKEIO8hl+cFZJbq6iD5U+O+YMv4ZNmFbxqzlwmQd/tcR1V03M2QN9lw2bZleki5/6 /BYF9aDXzwEPkrHANLC5K2C7pHwTjXUfJcZ35mpJtvdWF2wG222pPRxCVspSpr+2+BhZ0Z CKEYJbK5WZH3NBpoJPwoEADjbFtaa2E= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-359-bdL8TsYyMpGnKEch5v0Nzg-1; Fri, 24 Jan 2025 16:58:50 -0500 X-MC-Unique: bdL8TsYyMpGnKEch5v0Nzg-1 X-Mimecast-MFC-AGG-ID: bdL8TsYyMpGnKEch5v0Nzg Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7EF6F1801F11 for ; Fri, 24 Jan 2025 21:58:49 +0000 (UTC) Received: from mzamazal-thinkpadp1gen3.tpbc.com (unknown [10.39.192.49]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2ADCF1800358; Fri, 24 Jan 2025 21:58:47 +0000 (UTC) From: Milan Zamazal To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [RFC PATCH v2 13/13] apps: cam: Write raw file if PPM cannot be written Date: Fri, 24 Jan 2025 22:58:04 +0100 Message-ID: <20250124215806.158024-14-mzamazal@redhat.com> In-Reply-To: <20250124215806.158024-1-mzamazal@redhat.com> References: <20250124215806.158024-1-mzamazal@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ZDXTlqgnUaUC4iUHfmq8WDcEiU3tmTouZPkjzIrtl7o_1737755929 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" `cam' application can be requested to write its output as a PPM file. However, this is supported only for certain formats (only BGR888 currently). If the output format cannot be written, `cam' reports an error and doesn't write anything. This is all right with a single stream input but impractical with multiple streams of different output formats (e.g. a processed stream + a raw stream) where some of them can be written in the supported format while the other not. In such a case, it's better to write the supported formats as PPM files and the unsupported formats as raw files, with the corresponding warning on stderr. `.raw' extension is added to the file name in such a case to make clear it's not a PPM file. This is a sort of hack but serves the purpose for the moment. Signed-off-by: Milan Zamazal --- src/apps/cam/file_sink.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/apps/cam/file_sink.cpp b/src/apps/cam/file_sink.cpp index 76e21db9..1a866137 100644 --- a/src/apps/cam/file_sink.cpp +++ b/src/apps/cam/file_sink.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -133,11 +134,16 @@ void FileSink::writeBuffer(const Stream *stream, FrameBuffer *buffer, if (fileType_ == FileType::Ppm) { ret = PPMWriter::write(filename.c_str(), stream->configuration(), image->data(0)); - if (ret < 0) - std::cerr << "failed to write PPM file `" << filename - << "'" << std::endl; - - return; + if (ret == -EINVAL) { + filename += ".raw"; + std::cerr << "cannot write file in PPM format, writing `" + << filename << "' instead" << std::endl; + } else { + if (ret < 0) + std::cerr << "failed to write PPM file `" << filename + << "'" << std::endl; + return; + } } fd = open(filename.c_str(), O_CREAT | O_WRONLY |