{"id":23848,"url":"https://patchwork.libcamera.org/api/patches/23848/?format=json","web_url":"https://patchwork.libcamera.org/patch/23848/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250718094048.59162-2-uajain@igalia.com>","date":"2025-07-18T09:40:47","name":"[v2,1/2] libcamera: simple: Detect Bayer pattern change during configure()","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"023d61491bfbbdc7f037d4e399385a186e4894d6","submitter":{"id":232,"url":"https://patchwork.libcamera.org/api/people/232/?format=json","name":"Umang Jain","email":"uajain@igalia.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23848/mbox/","series":[{"id":5297,"url":"https://patchwork.libcamera.org/api/series/5297/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5297","date":"2025-07-18T09:40:46","name":"libcamera: simple: Support RPi's unicam CSI-2 receiver","version":2,"mbox":"https://patchwork.libcamera.org/series/5297/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23848/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23848/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 088E9C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 18 Jul 2025 09:40:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5FB1068F9E;\n\tFri, 18 Jul 2025 11:40:46 +0200 (CEST)","from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 42FCB6150A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 18 Jul 2025 11:40:44 +0200 (CEST)","from [49.36.71.87] (helo=uajain) by fanzine2.igalia.com with\n\tesmtpsa \n\t(Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256)\n\t(Exim) id 1ucha7-000VuI-BD; Fri, 18 Jul 2025 11:40:43 +0200"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=igalia.com header.i=@igalia.com\n\theader.b=\"LMLl5uov\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com;\n\ts=20170329;\n\th=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:\n\tMessage-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:\n\tContent-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc\n\t:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe:\n\tList-Post:List-Owner:List-Archive;\n\tbh=XGHtG/nQ7DVVBxR7l8Xzy+qHS2F5tiwm1HHlkKBrbOc=;\n\tb=LMLl5uovHcSwexlMPgV5xsApev\n\tUmpDIJncTdCMK6b7BcfnWgapHZiEVtnbxb6EzrD4L4vE7i2x/UedLwEyTWqjmigN3UifsWSK1akqY\n\thB8l+cRpIoWlIpQDObWxSJCjxfotgzgKCU9Hmh1RwnV6BsUsbDk/r8G2nHzcq9z3PoR5MLRROzBAB\n\t/T8Qkjsrj9Bi78bAblRuklQWxZROFVrAaaYbgsmwWEnqMarPkRnL/YhjTiE3YzF+vgzjueX89aij0\n\tXP14SAlBqj3RpuqwVhgwyxCOzQgvPCscswpIYfftK7eLpYKZZr60/89h6VWGiq5q4R8UHlsr5TlIR\n\tVAYaMK9w==;","From":"Umang Jain <uajain@igalia.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Milan Zamazal <mzamazal@redhat.com>,\n\tUmang Jain <uajain@igalia.com>","Subject":"[PATCH v2 1/2] libcamera: simple: Detect Bayer pattern change during\n\tconfigure()","Date":"Fri, 18 Jul 2025 15:10:47 +0530","Message-ID":"<20250718094048.59162-2-uajain@igalia.com>","X-Mailer":"git-send-email 2.50.0","In-Reply-To":"<20250718094048.59162-1-uajain@igalia.com>","References":"<20250718094048.59162-1-uajain@igalia.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Bayer pattern on the sensor can change while configuring it with the\nintended capture format. This is due to the transform being applied on\nthe sensor which supports [v/h]flips.\n\nDuring configure(), the simple pipeline handler does not detect any\nbayer pattern changes that can arise due to the transformations being\napplied via SimpleCameraData:setupFormats(). In such cases, the video\nnode will be configured in-correctly, without realising the bayer\npattern has changed on the sensor, for the given capture format.\n\nThis patch detects the bayer pattern change after the sensor has\nbeen configured and retrieves the corresponding V4L2 pixel format\nto correctly configure the video node and the input to converter or\nSoft-ISP.\n\nSigned-off-by: Umang Jain <uajain@igalia.com>\n---\n src/libcamera/pipeline/simple/simple.cpp | 18 +++++++++++++++---\n 1 file changed, 15 insertions(+), 3 deletions(-)","diff":"diff --git a/src/libcamera/pipeline/simple/simple.cpp b/src/libcamera/pipeline/simple/simple.cpp\nindex efb07051..11d56873 100644\n--- a/src/libcamera/pipeline/simple/simple.cpp\n+++ b/src/libcamera/pipeline/simple/simple.cpp\n@@ -1353,8 +1353,20 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n \tif (ret < 0)\n \t\treturn ret;\n \n-\t/* Configure the video node. */\n-\tV4L2PixelFormat videoFormat = video->toV4L2PixelFormat(pipeConfig->captureFormat);\n+\t/* Configure the video node, taking into account any Bayer pattern change. */\n+\tV4L2PixelFormat videoFormat;\n+\tif (format.code == pipeConfig->code) {\n+\t\tvideoFormat = video->toV4L2PixelFormat(pipeConfig->captureFormat);\n+\t} else {\n+\t\t/*\n+\t\t * Bayer pattern has changed because of the transform that was applied on\n+\t\t * the sensor. Get the V4L2PixelFormat corresponding to the configured Bayer\n+\t\t * pattern.\n+\t\t */\n+\t\tBayerFormat cfgBayer = BayerFormat::fromPixelFormat(pipeConfig->captureFormat);\n+\t\tcfgBayer.order = data->sensor_->bayerOrder(config->combinedTransform());\n+\t\tvideoFormat = cfgBayer.toV4L2PixelFormat();\n+\t}\n \n \tV4L2DeviceFormat captureFormat;\n \tcaptureFormat.fourcc = videoFormat;\n@@ -1396,7 +1408,7 @@ int SimplePipelineHandler::configure(Camera *camera, CameraConfiguration *c)\n \t\treturn 0;\n \n \tStreamConfiguration inputCfg;\n-\tinputCfg.pixelFormat = pipeConfig->captureFormat;\n+\tinputCfg.pixelFormat = videoFormat.toPixelFormat();\n \tinputCfg.size = pipeConfig->captureSize;\n \tinputCfg.stride = captureFormat.planes[0].bpl;\n \tinputCfg.bufferCount = kNumInternalBuffers;\n","prefixes":["v2","1/2"]}