From patchwork Wed Jul 9 13:42:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 23777 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 A8313C3237 for ; Wed, 9 Jul 2025 13:42:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BB40A68EF0; Wed, 9 Jul 2025 15:42:35 +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="lXuRiVdW"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AA47E68EE6 for ; Wed, 9 Jul 2025 15:42:33 +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=GP02ZgzYBE2h2EZSxYTzFWAa8vs7oQblL4ui9wHK5+0=; b=lXuRiVdWU7CRsknhkmzN8FhEkl 5HFbiHkGumDGNGTqkIy+AKXIB3Lvp0KRpyXk/RGeGft+JuXf8D7x6EkDRUP9zBATRvBJBZK4+LB+H 1v3w31zCnbClr8TjMz3CNO1L2qaZGZJvbYqv2f+pZYLbs5jEzmtCWzrQLsCh6/CEUwN8wojRpnFgf xSMLTBJcO6iRC+QPaIGWXS0j5UBqMJ7Wjz7viBq8XgWQ5zsybuvlR6L2XC7VKErwIK7TtPKT/dlqf qZXhOb/u287haiG7qYH/I8MlNzApBjmHjatMQcT2iwYx8ty8GTPDqhI470ovBV08dW+28PR0o93qu 1qIvalKA==; Received: from [49.36.71.19] (helo=uajain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1uZV4C-00EUOy-HK; Wed, 09 Jul 2025 15:42:33 +0200 From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Umang Jain Subject: [PATCH 1/2] libcamera: simple: Detect Bayer pattern change during configure() Date: Wed, 9 Jul 2025 19:12:28 +0530 Message-ID: <20250709134229.135949-2-uajain@igalia.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250709134229.135949-1-uajain@igalia.com> References: <20250709134229.135949-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" Bayer pattern on the sensor can change while configuring it with the intended capture format. This is due to the transform being applied on the sensor which supports [v/h]flips. During configure(), the simple pipeline handler does not detect any bayer pattern changes that can arise due to the transformations being applied via SimpleCameraData:setupFormats(). In such cases, the video node will be configured in-correctly, without realising the bayer pattern has changed on the sensor, for the given capture format. This patch detects the bayer pattern change after the sensor has been configured and retrieves the corresponding V4L2 pixel format to correctly configure the video node. Signed-off-by: Umang Jain --- src/libcamera/pipeline/simple/simple.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index efb07051..e2a48724 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -1353,8 +1353,20 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c) if (ret < 0) return ret; - /* Configure the video node. */ - V4L2PixelFormat videoFormat = video->toV4L2PixelFormat(pipeConfig->captureFormat); + /* Configure the video node, taking into account any Bayer pattern change. */ + V4L2PixelFormat videoFormat; + if (format.code == pipeConfig->code) { + videoFormat = video->toV4L2PixelFormat(pipeConfig->captureFormat); + } else { + /* + * Bayer pattern has changed because of the transform that was applied on + * the sensor. Get the V4L2PixelFormat corresponding to the configured Bayer + * pattern. + */ + BayerFormat cfgBayer = BayerFormat::fromPixelFormat(pipeConfig->captureFormat); + cfgBayer.order = data->sensor_->bayerOrder(config->combinedTransform()); + videoFormat = cfgBayer.toV4L2PixelFormat(); + } V4L2DeviceFormat captureFormat; captureFormat.fourcc = videoFormat; From patchwork Wed Jul 9 13:42:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 23778 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 8C0D9C3237 for ; Wed, 9 Jul 2025 13:42:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 48D2768EF3; Wed, 9 Jul 2025 15:42:39 +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="LM61/ppk"; dkim-atps=neutral Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7367B68EE6 for ; Wed, 9 Jul 2025 15:42:35 +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=qCBWRt4aRmwzAIOEFaLxtvUNgQLjVQjXt+NVj+eIrNM=; b=LM61/ppk853Q7LqbwTNGC3Iwjh ABnv4zDe6+uQOYyQ3tkkyaUpKhfR8OFJlaniu66Eac15BbxDrrKJGHVEgfu2rTbYdreHyCalL8vxL KxxdLNgAh//ay1ra3oz2GBpRlepepZGFRP2+OVdhifS1VfGaiWwGl+nWcz850Tylfq30lKc0UDaSE 9KPgni+h2PzIChMdapxxEiMKt0QzGE+FSZ3DmULdCm5BwAaNqqBfYhyAyjAdd27p4stVaN7dTd05M 9BBH6QKjI1U9YqqojvhGGLgWiteNiMlrqT9GD5Rnb9KXrfSI8/6/e16djIyW0LIBFntcZ8rAxtQAa JFb2NmUw==; Received: from [49.36.71.19] (helo=uajain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1uZV4E-00EUOy-9X; Wed, 09 Jul 2025 15:42:34 +0200 From: Umang Jain To: libcamera-devel@lists.libcamera.org Cc: Umang Jain Subject: [PATCH 2/2] libcamera: simple: Support RPi's unicam CSI-2 receiver Date: Wed, 9 Jul 2025 19:12:29 +0530 Message-ID: <20250709134229.135949-3-uajain@igalia.com> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250709134229.135949-1-uajain@igalia.com> References: <20250709134229.135949-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" This patch enables RaspberryPi's unicam CSI-2 receiver to be able to function and capture images via the simple pipeline handler along with SoftISP. Unicam CSI-2 supports capture in both packed and unpacked pixel formats. Currently, the unicam video node is configured to use the unpacked formats for streaming with simple pipeline handler. Signed-off-by: Umang Jain Tested-by: Umang Jain # RPi-3B + IMX219 --- src/libcamera/pipeline/simple/simple.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp index e2a48724..60034395 100644 --- a/src/libcamera/pipeline/simple/simple.cpp +++ b/src/libcamera/pipeline/simple/simple.cpp @@ -257,6 +257,7 @@ static const SimplePipelineInfo supportedDevices[] = { { "mxc-isi", {}, false }, { "qcom-camss", {}, true }, { "sun6i-csi", {}, false }, + { "unicam", {}, true }, }; } /* namespace */