From patchwork Wed Oct 15 01:22:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24646 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 224EEBF415 for ; Wed, 15 Oct 2025 01:23:00 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0B4FA605FF; Wed, 15 Oct 2025 03:22:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="j/ZS9yP2"; dkim-atps=neutral Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B738605FF for ; Wed, 15 Oct 2025 03:22:56 +0200 (CEST) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-639e1e8c8c8so11576775a12.1 for ; Tue, 14 Oct 2025 18:22:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491376; x=1761096176; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fcVSCDVF1qmulua/u7n81HY/nPAQ/niQa3u5U+TwAAY=; b=j/ZS9yP2GJGHP7DeJXfNcqgUCnw3aAIFQrGQvRCm77LCeO3Ozk7MRm4b89UPwkTiO6 lf7u3zwWdWxZkis2aDeYPsfsm+3dCOV5KacGbe3j40WeJbDTIpFUAl44bw+atwh8LBCw OXCCRoR+NdgYB0QMh0P6NfDBwWSvLOSrxar2qvI5iRxmGCHN821IannyMSjqCco1Al7+ D8eUrC5iktudKTu8iqO0IZ3IN0hfHayI3p7BNWJBvW2vKd5EJv4kTf68k+k5X3eQ7aMW KGDR+HDnrCOaIIiNEA8rLpLcfO3sdJskOWK9SCYtwxp8E+lNvjeIgjHvtEUmN70cX9EL 6mbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491376; x=1761096176; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fcVSCDVF1qmulua/u7n81HY/nPAQ/niQa3u5U+TwAAY=; b=YM8UZ/jxFHgSTbsEr1D0Mf+Sv4/kpKNOXiiaKDQnAMR3vkUNLgy4nCfyzt0MGUYl9a vU7lHqIRGxOvVyNCKI5Ko6xbhYBKGPox/0sgvXPDAC9qfCbzLOsaWnvO0g6/VE7zAvp0 SUDED4KWfb333jrgLoYHbJvRlgL+fewj80eoYAKtjVy6Puvr5TQvNcieXcs1121cynGZ W9gYmpi5Vc29NIH30IDZdsgzPlcozWEOvH6+BspUYnLJ62OkQaSpYcl20KO9sI6OGmza LxZ50MyLr49UL4qyWE8BKJBbW0kdo9z7XmB5vc/ngVQAkiLUdDuQKzfe0rtVnZJHYbUE /NAw== X-Gm-Message-State: AOJu0YxiW0bClP0uhqoMRJqaGlZrafNZ+BCOezqdl2jMGGDI62MAFH4q 4SpgNGVKoK1gUfB31JxN7SHjKY7bg8L930MhPpSnUN0oPmlW7kYGKWLMMshbNRaVPFPMQzYVutc An9j7 X-Gm-Gg: ASbGncv4z0ecATJua/HpqIYeTuM3f2oqrCyPzI19ldZrqTk/y8NrI1/+PABgWeYd1zE xU6SN4zWEo4x/XJCKoE1+qlnc8lqv0utdZlnNXjpdDN3VOMbVZl2kHvleE8jiuxJb3VINKreHZb QIspacsN+Yuihclkcz/9qonzCK9z/kNlfhBFEI2cA9ZqURUMwonYKTGfdmSVQcfv2LBvcn6jSqw N0LcvF/eUPLumB+vBLRAhvpxJihXni7bQ02awg+lZS/fJvEJOz0c6YoMI59PVpfKYO74BAPubsC ohmz7CyqfLjIlhdNLguiqEQeYae8d0ZSBoeI9bnHlNrAZlMd+hJsN+rG1xf0uDtpRqzkILcXt2E zDOKH2DYriOIzn0g6zdbhSTegawMAPahDvMx6Z2oTkNXx1vBS1sNQk7s8jCQcT2LpQbEuII+sO3 rErQAdkMkEfMDBh25ZMJ161WL8eahfddz95Qs8yAOy X-Google-Smtp-Source: AGHT+IEYac9azZhcmZBgUweB/Kwi74Y0eXxhdLRj3xW7QhUJ1IFgZ+Ch085errhm+Ix3FzW0vkKhcQ== X-Received: by 2002:a17:906:f599:b0:b18:63b8:c508 with SMTP id a640c23a62f3a-b50ac5d079cmr2555813166b.44.1760491375758; Tue, 14 Oct 2025 18:22:55 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:22:55 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 01/39] libcamera: shaders: Move GL shader programs to src/libcamera/assets/shader Date: Wed, 15 Oct 2025 02:22:13 +0100 Message-ID: <20251015012251.17508-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Moving the vertex and fragment shaders to src/libcamera/assets/shader to allow for reuse of these inside of the SoftISP. A comment has been added to src/apps/qcom/meson.build to force a rebuild. Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal --- .../libcamera/internal/shaders}/RGB.frag | 0 .../internal/shaders}/YUV_2_planes.frag | 0 .../internal/shaders}/YUV_3_planes.frag | 0 .../internal/shaders}/YUV_packed.frag | 0 .../internal/shaders}/bayer_1x_packed.frag | 0 .../libcamera/internal/shaders}/bayer_8.frag | 0 .../libcamera/internal/shaders}/bayer_8.vert | 0 .../libcamera/internal/shaders}/identity.vert | 0 src/apps/qcam/assets/shader/shaders.qrc | 16 ++--- src/apps/qcam/meson.build | 3 + src/apps/qcam/viewfinder_gl.cpp | 70 +++++++++---------- 11 files changed, 46 insertions(+), 43 deletions(-) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/RGB.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/YUV_2_planes.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/YUV_3_planes.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/YUV_packed.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/bayer_1x_packed.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/bayer_8.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/bayer_8.vert (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/identity.vert (100%) diff --git a/src/apps/qcam/assets/shader/RGB.frag b/include/libcamera/internal/shaders/RGB.frag similarity index 100% rename from src/apps/qcam/assets/shader/RGB.frag rename to include/libcamera/internal/shaders/RGB.frag diff --git a/src/apps/qcam/assets/shader/YUV_2_planes.frag b/include/libcamera/internal/shaders/YUV_2_planes.frag similarity index 100% rename from src/apps/qcam/assets/shader/YUV_2_planes.frag rename to include/libcamera/internal/shaders/YUV_2_planes.frag diff --git a/src/apps/qcam/assets/shader/YUV_3_planes.frag b/include/libcamera/internal/shaders/YUV_3_planes.frag similarity index 100% rename from src/apps/qcam/assets/shader/YUV_3_planes.frag rename to include/libcamera/internal/shaders/YUV_3_planes.frag diff --git a/src/apps/qcam/assets/shader/YUV_packed.frag b/include/libcamera/internal/shaders/YUV_packed.frag similarity index 100% rename from src/apps/qcam/assets/shader/YUV_packed.frag rename to include/libcamera/internal/shaders/YUV_packed.frag diff --git a/src/apps/qcam/assets/shader/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag similarity index 100% rename from src/apps/qcam/assets/shader/bayer_1x_packed.frag rename to include/libcamera/internal/shaders/bayer_1x_packed.frag diff --git a/src/apps/qcam/assets/shader/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag similarity index 100% rename from src/apps/qcam/assets/shader/bayer_8.frag rename to include/libcamera/internal/shaders/bayer_8.frag diff --git a/src/apps/qcam/assets/shader/bayer_8.vert b/include/libcamera/internal/shaders/bayer_8.vert similarity index 100% rename from src/apps/qcam/assets/shader/bayer_8.vert rename to include/libcamera/internal/shaders/bayer_8.vert diff --git a/src/apps/qcam/assets/shader/identity.vert b/include/libcamera/internal/shaders/identity.vert similarity index 100% rename from src/apps/qcam/assets/shader/identity.vert rename to include/libcamera/internal/shaders/identity.vert diff --git a/src/apps/qcam/assets/shader/shaders.qrc b/src/apps/qcam/assets/shader/shaders.qrc index 96c709f9..04f9d706 100644 --- a/src/apps/qcam/assets/shader/shaders.qrc +++ b/src/apps/qcam/assets/shader/shaders.qrc @@ -1,13 +1,13 @@ - RGB.frag - YUV_2_planes.frag - YUV_3_planes.frag - YUV_packed.frag - bayer_1x_packed.frag - bayer_8.frag - bayer_8.vert - identity.vert + ../../../../../include/libcamera/internal/shaders/RGB.frag + ../../../../../include/libcamera/internal/shaders/YUV_2_planes.frag + ../../../../../include/libcamera/internal/shaders/YUV_3_planes.frag + ../../../../../include/libcamera/internal/shaders/YUV_packed.frag + ../../../../../include/libcamera/internal/shaders/bayer_1x_packed.frag + ../../../../../include/libcamera/internal/shaders/bayer_8.frag + ../../../../../include/libcamera/internal/shaders/bayer_8.vert + ../../../../../include/libcamera/internal/shaders/identity.vert diff --git a/src/apps/qcam/meson.build b/src/apps/qcam/meson.build index 9ca047b0..33600095 100644 --- a/src/apps/qcam/meson.build +++ b/src/apps/qcam/meson.build @@ -64,3 +64,6 @@ qcam = executable('qcam', qcam_sources, resources, qt6_dep, ], cpp_args : qt6_cpp_args) + +# Note: qt6.preprocess does not automatically rebuild when the +# qcam_resources dependency chain is updated. diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp index f31956ff..70f60065 100644 --- a/src/apps/qcam/viewfinder_gl.cpp +++ b/src/apps/qcam/viewfinder_gl.cpp @@ -141,7 +141,7 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format) textureMinMagFilters_ = GL_LINEAR; /* Use identity.vert as the default vertex shader. */ - vertexShaderFile_ = ":identity.vert"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/identity.vert"; fragmentShaderDefines_.clear(); @@ -150,170 +150,170 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format) horzSubSample_ = 2; vertSubSample_ = 2; fragmentShaderDefines_.append("#define YUV_PATTERN_UV"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::NV21: horzSubSample_ = 2; vertSubSample_ = 2; fragmentShaderDefines_.append("#define YUV_PATTERN_VU"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::NV16: horzSubSample_ = 2; vertSubSample_ = 1; fragmentShaderDefines_.append("#define YUV_PATTERN_UV"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::NV61: horzSubSample_ = 2; vertSubSample_ = 1; fragmentShaderDefines_.append("#define YUV_PATTERN_VU"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::NV24: horzSubSample_ = 1; vertSubSample_ = 1; fragmentShaderDefines_.append("#define YUV_PATTERN_UV"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::NV42: horzSubSample_ = 1; vertSubSample_ = 1; fragmentShaderDefines_.append("#define YUV_PATTERN_VU"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::YUV420: horzSubSample_ = 2; vertSubSample_ = 2; - fragmentShaderFile_ = ":YUV_3_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_3_planes.frag"; break; case libcamera::formats::YVU420: horzSubSample_ = 2; vertSubSample_ = 2; - fragmentShaderFile_ = ":YUV_3_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_3_planes.frag"; break; case libcamera::formats::UYVY: fragmentShaderDefines_.append("#define YUV_PATTERN_UYVY"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_packed.frag"; break; case libcamera::formats::VYUY: fragmentShaderDefines_.append("#define YUV_PATTERN_VYUY"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_packed.frag"; break; case libcamera::formats::YUYV: fragmentShaderDefines_.append("#define YUV_PATTERN_YUYV"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_packed.frag"; break; case libcamera::formats::YVYU: fragmentShaderDefines_.append("#define YUV_PATTERN_YVYU"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_packed.frag"; break; case libcamera::formats::ABGR8888: fragmentShaderDefines_.append("#define RGB_PATTERN rgb"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::ARGB8888: fragmentShaderDefines_.append("#define RGB_PATTERN bgr"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::BGRA8888: fragmentShaderDefines_.append("#define RGB_PATTERN gba"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::RGBA8888: fragmentShaderDefines_.append("#define RGB_PATTERN abg"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::BGR888: fragmentShaderDefines_.append("#define RGB_PATTERN rgb"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::RGB888: fragmentShaderDefines_.append("#define RGB_PATTERN bgr"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::SBGGR8: firstRed_.setX(1.0); firstRed_.setY(1.0); - vertexShaderFile_ = ":bayer_8.vert"; - fragmentShaderFile_ = ":bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGBRG8: firstRed_.setX(0.0); firstRed_.setY(1.0); - vertexShaderFile_ = ":bayer_8.vert"; - fragmentShaderFile_ = ":bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGRBG8: firstRed_.setX(1.0); firstRed_.setY(0.0); - vertexShaderFile_ = ":bayer_8.vert"; - fragmentShaderFile_ = ":bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SRGGB8: firstRed_.setX(0.0); firstRed_.setY(0.0); - vertexShaderFile_ = ":bayer_8.vert"; - fragmentShaderFile_ = ":bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SBGGR10_CSI2P: firstRed_.setX(1.0); firstRed_.setY(1.0); fragmentShaderDefines_.append("#define RAW10P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGBRG10_CSI2P: firstRed_.setX(0.0); firstRed_.setY(1.0); fragmentShaderDefines_.append("#define RAW10P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGRBG10_CSI2P: firstRed_.setX(1.0); firstRed_.setY(0.0); fragmentShaderDefines_.append("#define RAW10P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SRGGB10_CSI2P: firstRed_.setX(0.0); firstRed_.setY(0.0); fragmentShaderDefines_.append("#define RAW10P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SBGGR12_CSI2P: firstRed_.setX(1.0); firstRed_.setY(1.0); fragmentShaderDefines_.append("#define RAW12P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGBRG12_CSI2P: firstRed_.setX(0.0); firstRed_.setY(1.0); fragmentShaderDefines_.append("#define RAW12P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGRBG12_CSI2P: firstRed_.setX(1.0); firstRed_.setY(0.0); fragmentShaderDefines_.append("#define RAW12P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SRGGB12_CSI2P: firstRed_.setX(0.0); firstRed_.setY(0.0); fragmentShaderDefines_.append("#define RAW12P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; default: From patchwork Wed Oct 15 01:22:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24647 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 C3525C3264 for ; Wed, 15 Oct 2025 01:23:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C0D7D6060F; Wed, 15 Oct 2025 03:22:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="SYhWRjwU"; dkim-atps=neutral Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D41C060607 for ; Wed, 15 Oct 2025 03:22:57 +0200 (CEST) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-b3e234fcd4bso979181066b.3 for ; Tue, 14 Oct 2025 18:22:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491377; x=1761096177; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=E0I6fpsyuvLC5j5cYAtQaKP7gWF3/fw1mtSWmqaMPpk=; b=SYhWRjwU5GnralHZMqSwSeluT9X2METGkxyltB3oUtC0fN/53moc+S2fO4Xrr5LHM9 tyEFZwp9Dph92cqpxIH+7AryXkrr2UeMehsZgr9bWi2aRFBZiE2+ugQy3Mi6ty7nSZdJ ZktUlBeL3UnINstQTXE2L1ck+AC7TFUhp1mdrKke6F4WPZV+kwscENahd/ATwp7v67a8 tpNd+EOZRxBRlJar03bhAcyFDODdk2Xd4kvqFFGa0tnjqGhFu7NcFsLlhFfyH4TaecWZ tcmupsmMNqX2yQFsA8PMnMqK2lBz0ER5q3/2+R580L2XwO22tHoNMS6YfVd7OMK6vfGg 6IKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491377; x=1761096177; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=E0I6fpsyuvLC5j5cYAtQaKP7gWF3/fw1mtSWmqaMPpk=; b=h3f1vYvzXGJwzrk5wmzKb+o+jpMb1uAhdXuW5YAg7R2LZT4GF966wD4BX4tpe5g/PH goMCOCKRJPKF8OSIFLpaEB5Voe0d3gzT9c6MCtTV9sh2O7Js3u8Ib01CnA8b3hNMHyZR 2tD8zQaffubOmFmzTlfFwoQaL/mkWLPYFlIsTUKqSvuRytNBKQmLYrHYHeK95S7lDyCa KnDgNjdY/YTwdji9I7LIcteulyEsXPjbPnVWKn91ZIHgLHwTr/TZFcYqnILgyvJqrO82 3UoLPs1XPhb/DWX0Lo4Tkd5m+6pWdssWND1mMLjBoIsA1/Xu4Wty/z1x8CqIH3I0A/6b tUjg== X-Gm-Message-State: AOJu0YyUldmHYjKSAXznLDDIAKyfDoXOKRyvryMacmef1ZeCRAjyKmJQ +T+LaXp5vBnj/Z+QdOMNSSyzC7dZ1NP2qozzDEQOXesnqCdi/z8H0C0bQXN9aw0lH5+76DNeFJv NCAr+ X-Gm-Gg: ASbGncvVhzZLkRlUMrLtPMUeE+uIWlA5NgmAoHNlNLOYIsY+KvjS31PmUrX/6FPxdT0 IJ8ZUKinrn9hbQ2pfAWN9pcYQyd0q7EkWU+i97Nd6UNbpad0kcoNEEMuBPm3WGwSNbTe/d2bHcn mhRCaojZ2NjJxbbEBmCeQLuVzQLWLDofKm8MOtqLsR6ZfpJkUiJxErRkD2d+2aUkH7QWGgtYqSN nnfOKV9rQwHNHqOgye19s3jQ+6BgE3Knid2+WzzX+LAaKkIFG9z9jMuNJBtEFb8IduFlnlRm1qa LGowHPUzbMKTOOPl2w94PYA5U9Pa1jg/JOkn1sYYe6OvlmzQEcQpQImMqxtdYyTkLdjDfIRLMWl UB293YX/Q/8xXY9oaEeTpEtScq7CRCKk93Y+UEV5tawLR4ACOiGQ6KfpNlfPUKSkryUzvba602A xyAhHCxTv8FpJWOd4XhDMIRdgxvRbouQ== X-Google-Smtp-Source: AGHT+IEmygicqZQs2B4rDcyQ4/Mg9shrxCvPjJIcpzLhQeAsTl3qan8vinx1vX/P1/0SO9BfBnJ3Mg== X-Received: by 2002:a17:907:c03:b0:b46:31be:e8ea with SMTP id a640c23a62f3a-b50a76da212mr2724915466b.0.1760491376823; Tue, 14 Oct 2025 18:22:56 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.22.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:22:56 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 02/39] utils: gen-shader-headers: Add a utility to generate headers from shaders Date: Wed, 15 Oct 2025 02:22:14 +0100 Message-ID: <20251015012251.17508-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Two simple script to generate a header that contains GLSL shaders translated to C arrays. Signed-off-by: Bryan O'Donoghue Acked-by: Kieran Bingham --- utils/gen-shader-header.py | 38 ++++++++++++++++++++++++++++++++ utils/gen-shader-headers.sh | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100755 utils/gen-shader-header.py create mode 100755 utils/gen-shader-headers.sh diff --git a/utils/gen-shader-header.py b/utils/gen-shader-header.py new file mode 100755 index 00000000..6668e648 --- /dev/null +++ b/utils/gen-shader-header.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2025, Bryan O'Donoghue. +# +# Author: Bryan O'Donoghue +# +# A python script which takes a list of shader files and converts into a C +# header. +# +import sys + +try: + with open(sys.argv[2]) as file: + data = file.read() + data_len = len(data) + + name = sys.argv[1].replace(".", "_") + name_len = name + "_len" + + j = 0 + print("unsigned char", name, "[] = {") + for ch in data: + print(f"0x{ord(ch):02x}, ", end="") + j = j + 1 + if j == 16: + print() + j = 0 + if j != 0: + print() + print("};") + + print() + print(f"const unsigned int {name_len}={data_len};") + +except FileNotFoundError: + print(f"File {sys.argv[2]} not found", file=sys.stderr) +except IOError: + print(f"Unable to read {sys.argv[2]}", file=sys.stderr) diff --git a/utils/gen-shader-headers.sh b/utils/gen-shader-headers.sh new file mode 100755 index 00000000..ca4f19f0 --- /dev/null +++ b/utils/gen-shader-headers.sh @@ -0,0 +1,44 @@ +#!/bin/sh +set -x + +if [ $# -lt 4 ]; then + echo "Invalid arg count must be >= 5" + exit 1 +fi +src_dir="$1"; shift +build_dir="$1"; shift +build_path=$build_dir/"$1"; shift + +cat < "$build_path" +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* This file is auto-generated, do not edit! */ +/* + * Copyright (C) 2025, Linaro Ltd. + * + */ + +#pragma once + +EOF + +cat <> "$build_path" +/* + * List the names of the shaders at the top of + * header for readability's sake + * +EOF + +for file in "$@"; do + echo "file is $file" + name=$(basename "$build_dir/$file" | tr '.' '_') + echo " * unsigned char $name;" >> "$build_path" +done + +echo "*/" >> "$build_path" + +echo "/* Hex encoded shader data */" >> "$build_path" +for file in "$@"; do + name=$(basename "$build_dir/$file") + "$src_dir/utils/gen-shader-header.py" "$name" "$build_dir/$file" >> "$build_path" + echo >> "$build_path" +done From patchwork Wed Oct 15 01:22:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24648 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 66E26BF415 for ; Wed, 15 Oct 2025 01:23:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EBE246061B; Wed, 15 Oct 2025 03:23:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="McnJEI2Q"; dkim-atps=neutral Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EA68260612 for ; Wed, 15 Oct 2025 03:22:58 +0200 (CEST) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-b3e7cc84b82so1125051866b.0 for ; Tue, 14 Oct 2025 18:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491378; x=1761096178; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=q2bD5pT1oq/3EFruAOUxznBdV/GzEfzx1ttQIm2/ez4=; b=McnJEI2QrmkAmvUxEaA5VvRkrt/iOWl4iTDV3Mr38fz4klcVMjIxX8E+92j5TEiwnH vgtFAfwSuR1TcsJQbMj/p2g6MbyVUsUhB3z2ySoU5+k0API3v5k1nU7xZtmGVsjTUcBk 3JLXoCZIKql3eQcAVXKaOYRNmT3ICpjL64VNPdMcMTIX/IG994ICVpr4g+JTVw2Gv2zQ r4LRUi6hI1/h4PfqAT9YZMPE0PIUZrkQK+su5t07QiPIMEoWwPKU+I0e/Pe6APHGaXoG tj73u/wnrAl2gv5dD+8LRSLDRtTwIB6Brg1YXLz5CMQ/FPRshHec42rASKCzAZpjULST wcGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491378; x=1761096178; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=q2bD5pT1oq/3EFruAOUxznBdV/GzEfzx1ttQIm2/ez4=; b=KG94euhjcVHGlBPgCMQA4pZq7aByHKFBqbAR/Mid0DGhaGitghcjs8n1UjhhFXDn4y O8LA7i7+WsR7yM6zEDzDHaGAmu3BCYufcbfr2ZdDK+UMFynvElzJxpmyVjja3crsBsmk r4CbTQhM+Iv5WzMcNzuoLtPov8KyCST5TkZZfSerMqsUp/hlUJsPvEB17mt27i3Sup27 Ao03wgAuVmc4foTD0fKbD9yN2u/scAaEwqjPahAB8UpmBtb9YCVUrFvPB7ztT3KMKghc vU6qCXR15mex0xO3A1/5V9YE/IQj/POpeSvxXpzCtv+7MyhfpnkPqM+DrrOtpzY7/tmt gnRw== X-Gm-Message-State: AOJu0Ywf8ODuGbAHimL90HfujDwNCGpMiGShdN58QsbjGcg+1R8DWxNL vJjGxbdlH+vVxt6Hsn2c0m09Wpw0lijYmIugVFIViDQEdTOM5WjhhXKC0Kq8cOuXzIXfqAlyvf9 RWiNz X-Gm-Gg: ASbGncsM+CjmJZKF+J5gZQcLWiCghTXNchTqjrSXSMoWBJMkbdN3nFXkPtoTEwnzqrI XZJ2roH94DAWynTObt9YOj3d5fjChBbW9GhSV/5Lqhk4vrb/j6igW8Mn0EU3KgEIbJuQ1BrW6vg zLhYQRM98asEo+Yl3qdFP/inByuc7sZ/eL2W9odmUsstzUhfHVcD89d0HIsVtvkV/+VjXgAbx0T GTvSY3CaqwssQ2gbEZ5f0s1TFcc5gAIQfRAi5xYd/C9zSle7GNAylwLJARJnUCgBFesJl+tHq9f iM7aeUNX7U60SBZZAi90NN2GfRngbGV87xO9h6ku1CJLQzCpjuYijMdPtLkRzbOH0Bmk1kUCIrC 3qqXgMygFwTpMdrh+FkzzkXzec/C80Q1JlFb+cQhoMW+mBm7WGN1ORg3x7wRnJOXVd0khoA8/Ra 30Q0nHVBaAIvXlwCR7ux4cJT1Bk0Sk58YmRhPF1Eo4 X-Google-Smtp-Source: AGHT+IFZz5lJd6euy3TnflC5ZVAEsQhnCfBC97wYwlXekMmDxhI9I5S/w44ec74+B/bTRLXKUbJbAg== X-Received: by 2002:a17:907:7f93:b0:b04:b446:355 with SMTP id a640c23a62f3a-b50aca01315mr2754993666b.59.1760491377773; Tue, 14 Oct 2025 18:22:57 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.22.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:22:57 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 03/39] meson: Automatically generate glsl_shaders.h from specified shader programs Date: Wed, 15 Oct 2025 02:22:15 +0100 Message-ID: <20251015012251.17508-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Encode the bayer shader files into a header as part of the build process. Qcam already compiles the shader files down into a QT resource file which it references internally. In order to share the debayering shader programs outside of qcam create a generic header which both qcam and libcamera can operate from. Signed-off-by: Bryan O'Donoghue Acked-by: Kieran Bingham --- include/libcamera/internal/meson.build | 10 ++++++++++ include/libcamera/internal/shaders/meson.build | 10 ++++++++++ utils/meson.build | 2 ++ 3 files changed, 22 insertions(+) create mode 100644 include/libcamera/internal/shaders/meson.build diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index 45c299f6..ecb7c9fa 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -1,6 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 subdir('tracepoints') +subdir('shaders') libcamera_internal_headers = files([ 'bayer_format.h', @@ -59,5 +60,14 @@ tracepoints_h = custom_target( libcamera_internal_headers += tracepoints_h +libcamera_shader_headers = custom_target( + 'gen-shader-headers', + input : [shader_files], + output : 'glsl_shaders.h', + command : [gen_shader_headers, meson.project_source_root(), meson.project_build_root(), '@OUTPUT@', '@INPUT@'], +) + +libcamera_internal_headers += libcamera_shader_headers + subdir('converter') subdir('software_isp') diff --git a/include/libcamera/internal/shaders/meson.build b/include/libcamera/internal/shaders/meson.build new file mode 100644 index 00000000..386b342d --- /dev/null +++ b/include/libcamera/internal/shaders/meson.build @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: CC0-1.0 + +# List of shader files to convert to header hex +# for the purposes of inclusion in OpenGL debayering +shader_files = files([ + 'bayer_1x_packed.frag', + 'bayer_8.frag', + 'bayer_8.vert', + 'identity.vert', +]) diff --git a/utils/meson.build b/utils/meson.build index 95d657ac..3deed8ad 100644 --- a/utils/meson.build +++ b/utils/meson.build @@ -3,5 +3,7 @@ subdir('codegen') subdir('ipu3') +gen_shader_headers = files('gen-shader-headers.sh') + ## Module signing gen_ipa_priv_key = files('gen-ipa-priv-key.sh') From patchwork Wed Oct 15 01:22:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24649 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 78758C3331 for ; Wed, 15 Oct 2025 01:23:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CA48C605FF; Wed, 15 Oct 2025 03:23:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="fZe0xwMW"; dkim-atps=neutral Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7F76D6060A for ; Wed, 15 Oct 2025 03:22:59 +0200 (CEST) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-b3ee18913c0so965005166b.3 for ; Tue, 14 Oct 2025 18:22:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491379; x=1761096179; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Iq/QQZnzG0Y02cPlHt1zWbTY7RnwaVpFXzmCvziIA+w=; b=fZe0xwMWMGo8C6oUdOa/l40J7hzAs5KkvvyTHKyCzyNo9TyJZQLY+n6yj6a716qGE2 BuU4aOvwbIxALS9ZpisJtT9QYM67bcOgFIQQnXWwnfhUlHHFc/PU5MAFC820QofLouuk 6/2xdPiunkrMKbpi+T2OmULkB1wpKO2v0JOYC1UrGV2yeo77y6iUhK0FxzMsdywhRiR1 OYVMJ/ti/E6Q7xADyN8ZpWb23QTbkLISevHgt2Ius2TFqA568xwVnv8FOpPsqj63fKwT gjmPfzgyqUzj8OEJ/vfsEAGY5jbWFgWGqTc1KOVVWTy5U8DYLb8Kecgr2Rcy69vE90m5 Ak8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491379; x=1761096179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Iq/QQZnzG0Y02cPlHt1zWbTY7RnwaVpFXzmCvziIA+w=; b=luaSZO7i69z7xAIgqiLLUdLuWB8VJHn56dC9W5dD9ZjKoGWJAvDaUwbiioTNdwghr5 1wbwxhh5NGXPUMrZjJ2lQjkgDrFhUq7zl+G+X9Pg4bDSHfwNYRz9QDeZ3GHlKRxtleuW M/GkrAe1EA+vC537PtoCOPivMrNJXeulhAriZ+dDxK+dbuYNG6pcmsFKy/0H30Dn5/Sd ipb9YCV4Z/zV9Z8Qdq9qYiJR8eEDhlx0UDA6XF40i1DEUQ9PZuVlEQcKQcIXfdFd2Lo1 ZJ2vvpnBeqO7yumnJYedRi39n9t2o08xVDQrymmag7mhTiomCT0DsSbkWXbB8iro17O0 pYFg== X-Gm-Message-State: AOJu0YziFSph9pxJwuGk2iDr0kHFIMzzejNNS4skoR48ud2cc0jF0rKX mTTdIB3OvIMyd6EHI8qERQmWLpBZP0hM+PP4W3Oi4MTnnOmo8Uyu30Vgzt477Ao7zevNogG2V9T Q/wYb X-Gm-Gg: ASbGncvWKj/T7YdUE4f8X+ySdMkjXkdVqlH0+2Lw7fPITalHt4T8Wr8jJZZUO4sNtqD hAtTzcbR2ax1Z3ZNQVauW66/RF0T3YoqB3e2Ivzf0rEPmpMy3zQlm+Js/7B1hidcQbPZ/Bb7uoy 5Uzpu6h7BqsmeQxbTQZYccfAm786cvWcuoLToYtq6qBjIR4bIuIKJrgYGctWrHt3GGFt0FLkORB EQgC5v6mwW5bjEcqMVdNf9YsDkKgQzTUUxtrROxSQo88ZcaQ3VyOGAH0kX8w2tbnuI1Ctm8iy6P cji+b2UB4n91/9E6D8nW1jkA3Hn7+07pRPG89GQ2+GCrZ+BtvqvzLq04i1uBrMBPePd68wThC54 CtMfqIDpbb0FD0eBnQ4zX+1QQDULr1s7TozifJIlkcZmzy40CrOrFaDRXXoER4PACVr3EoXEoqP 7EdJExu78YURVPkn8+eHfA31yJe3X7gOhtXuWKhahK X-Google-Smtp-Source: AGHT+IFV7v50DkMRAyePLHrzpFA9FM4KFCTak0EP0i1/fA8DD4uhz+zlRSUno72VWuZKT5drN37Svw== X-Received: by 2002:a17:906:fa0e:b0:b55:a883:63c4 with SMTP id a640c23a62f3a-b55a8841f25mr1816867066b.10.1760491378718; Tue, 14 Oct 2025 18:22:58 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.22.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:22:58 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie, Kieran Bingham Subject: [PATCH v3 04/39] libcamera: swstats_cpu: Update statsProcessFn() / processLine0() documentation Date: Wed, 15 Oct 2025 02:22:16 +0100 Message-ID: <20251015012251.17508-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" From: Hans de Goede Update the documentation of the statsProcessFn() / processLine0() src[] pointer argument to take into account that swstats_cpu may also be used with planar input data or with non Bayer single plane input data. The statsProcessFn typedef is private, so no documentation is generated for it. Move the new updated src[] pointer argument documentation to processLine0() so that it gets included in the generated docs. Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Signed-off-by: Hans de Goede Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/swstats_cpu.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index 4f7bdd23..9c03338a 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -72,6 +72,19 @@ namespace libcamera { * patternSize height == 1. * It'll process line 0 and 1 for input formats with patternSize height >= 2. * This function may only be called after a successful setWindow() call. + * + * This function takes an array of src pointers each pointing to a line in + * the source image. + * + * Bayer input data requires (patternSize_.height + 1) src pointers, with + * the middle element of the array pointing to the actual line being processed. + * Earlier element(s) will point to the previous line(s) and later element(s) + * to the next line(s). See the DebayerCpu::debayerFn documentation for details. + * + * Planar input data requires a src pointer for each plane, with src[0] pointing + * to the line in plane 0, etc. + * + * For non Bayer single plane input data only a single src pointer is required. */ /** From patchwork Wed Oct 15 01:22:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24650 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 D74F6BF415 for ; Wed, 15 Oct 2025 01:23:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6236D60624; Wed, 15 Oct 2025 03:23:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="GubyPR05"; dkim-atps=neutral Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 684AE60618 for ; Wed, 15 Oct 2025 03:23:00 +0200 (CEST) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-b463f986f80so340232266b.2 for ; Tue, 14 Oct 2025 18:23:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491380; x=1761096180; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6QhKm2HbNzOXoZbqp3cnze1QGBGffOYanYP1Eb/65tU=; b=GubyPR05EA4lthA4rapZ93Fzk1C0r1/GKCajHXePo3WlY3JZz7pLe/OmdwcPnI1AU3 3ZsfFvbNHiJ1D6wZlao+Q0XNYiNJEE3pNtIwDEMu9pXhPcRQ7SNLbcvqqE7DGdSUyjhO IUMNeqSNqsTu03WzG4uCqxy3oJR5+6Gd79Kd9OMdOvdI+Rh+20tY4+ehS30kG66itTE+ yebxvAwTfjcIyEa5Vlga1BH40tV6lXez8lbnI8FTJZWRyHCp3nxF5Bv27iuWRx+I1HuJ 9B6Slu/VE6/YAG+UQuHt9XFpWDFHC3qDXJfJardx1UrmDPksp8on0EcGGhI3j8vImvgb MswQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491380; x=1761096180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6QhKm2HbNzOXoZbqp3cnze1QGBGffOYanYP1Eb/65tU=; b=NqOnR8UjVXovhIPSP7fHzZi/v5dc9Jabd7cqc3LhlFvVRbJhyCFiX1rBA9BCV7UE02 Z+h2BpMlKv+/kcitR4zaB0G0VStQGspNYwBG0UPm1DZFLwuKqcznPZAEAHWLaqGDG3HK 3xIPuw46chC6KBZWrF/5oq+05nyidqjnjdOCctaNIJpfB5jeyn5mNdLcKEiuW241lYUf Zl9vMkFAbG+WUD4QDhEnPHv9vmDoOPBaQYVw2P8970R0eeAFnn+W4ut3rdqLoyFVBkYF njT9aX9BQJ9rJOeJEMOPfTuI6NSeO6azjjz3yss/qiiMoZIAGkpZ8RjrOGfk+cDiu1OB rkGA== X-Gm-Message-State: AOJu0YxBM6FjHTZQ87G1JQtamLudW3hGZvgNgJvgvwGNvexG7xfbYcmW RydAgzlsuwS4XJgkpmcUOkPNgNEizq8oYcgmb+r+9FIm/Kq2ESpe4IBzXlEuTqjv0z0As5AWyM1 g95or X-Gm-Gg: ASbGncv7AX/Zg3HOTAKe7AuaP2JoMYKZRVFFW2ASuO1Dp1k+Y5oOb3Qaye6Ldih6bqc BNIfGI8eh9gPbjkTQSYWaMvPA5PgpaxLSXQDnSFjV7FJhJosSTl0z++do+YjCiwQsQGHGYvNI8t AWZ1t+3wrXpmSGhGW5IeXNXrqpS13xPYjY/Owso5m7fvaWdHfmtVcZEPWxQWPns7wzhgJuA9jwg SD0lLeR07oCUNlPbJ+ekY9ueBkBq/uNYqymnZc8PFhzb/Fm05Vv4L2hloWftREYXa3iRlWUCYos bGUkRmLnf1vbr19xDVwQDYmz06HQYX1HnsBbJqRhmuRjKCYWByReuPw4iVoxMkS9ybZi60svR57 Pp1Ddfk4xkqhaEjAOGkMVHuZd5X9NZVNlY5CSI0EEQ58/RWbK8wjqVctiCpkE/ntKxeN+2LUHSw u4nXVToZQXKlGz8tEICmFZMcoFkFpXjw== X-Google-Smtp-Source: AGHT+IFS120a3oecR3DnXjXtC/4G2k1I4w8Ht5m/mUsjhFMwk29YYLs2dy/QJFz6v6xyJ/LwhcH2jA== X-Received: by 2002:a17:907:72c6:b0:b45:b078:c52d with SMTP id a640c23a62f3a-b50abaa439emr2803285066b.35.1760491379668; Tue, 14 Oct 2025 18:22:59 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.22.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:22:59 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie, Kieran Bingham Subject: [PATCH v3 05/39] libcamera: swstats_cpu: Drop patternSize_ documentation Date: Wed, 15 Oct 2025 02:22:17 +0100 Message-ID: <20251015012251.17508-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" From: Hans de Goede patternSize_ is a private variable and its meaning is already documented in the patternSize() getter documentation. Move the list of valid sizes to the patternSize() getter documentation and drop the patternSize_ documentation. While at it also add 1x1 as valid size for use with future support of single plane non Bayer input data. Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Signed-off-by: Hans de Goede Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/swstats_cpu.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index 9c03338a..1b33ffa7 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -58,6 +58,8 @@ namespace libcamera { * also indicates if processLine2() should be called or not. * This may only be called after a successful configure() call. * + * Valid sizes are: 1x1, 2x2, 4x2 or 4x4. + * * \return The pattern size */ @@ -133,13 +135,6 @@ namespace libcamera { * \brief Statistics window, set by setWindow(), used every line */ -/** - * \var Size SwStatsCpu::patternSize_ - * \brief The size of the bayer pattern - * - * Valid sizes are: 2x2, 4x2 or 4x4. - */ - /** * \var unsigned int SwStatsCpu::xShift_ * \brief The offset of x, applied to window_.x for bayer variants From patchwork Wed Oct 15 01:22:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24651 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 AAE11C3264 for ; Wed, 15 Oct 2025 01:23:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5911F60615; Wed, 15 Oct 2025 03:23:08 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="zMgs/uxJ"; dkim-atps=neutral Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6FCF060609 for ; Wed, 15 Oct 2025 03:23:01 +0200 (CEST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-b3d50882cc2so1116953966b.2 for ; Tue, 14 Oct 2025 18:23:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491381; x=1761096181; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=fMgE7+8U5Npv3E1fx1DNI5sebBAbDc9Ao7uNF2FproY=; b=zMgs/uxJoXVFHZSgAg6dDUQqguw+qSUZaIfylSeXQcOUHIabJkbPjRYiqbNaJ9lJWZ aW683Ke1hVKjTUj5x2/fjWM5G0pIveM6euxEn+B0y7O6BfXicjvuGsBw7lr/MRJgJ4cG yoU4zf8Gvr5oa1cyhXeGDLLHiR/4nKQTXsNYvpYCOG25gOCnteCde8DE9qcsEIp+olXO m8KxcWSr4gBbNJAb+VqpKU5zEhQI2HAT+sg+Ew562F7zjDCojCCuiNpfIJPToN1chGhH ORKpLQxS5yfQ9YkOiEhdVSNcYCN9VTp8NLp5uEWOKYUsmZmwoBfduT96xyWxBw+x5j3G 56Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491381; x=1761096181; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fMgE7+8U5Npv3E1fx1DNI5sebBAbDc9Ao7uNF2FproY=; b=dJb7jLXYAW18rzDcLEXUaBqahY7pdkb9/m3ydvZybmhL2N3Z58HluK1FL+V2da1A+v +/suD+ZrI+vjKvIBjRDR45KTAINSUV750Mq8u67Sy4weBM4YlDvIkpIbMDRtztV7+afF cDUYEefh0GJvAQeCxILY6cn0jVPkYw4SaKHzPdpOEV3HQlaEq62m9ETIPsN8tAgRB50v 3o62bpfsnffFwFZ0Jv30N2eTpBkWtEQHjm67qA3S8M8PV05Q9Il4ahZxcc4pfFFDbHyS 53nOVSUj0BjQetuF5tkcOWIDz+rnKizLFIy8XzCOUR3mIeZo/EGUe0Xlt9g4dC9qLGKM xG6A== X-Gm-Message-State: AOJu0YzCHSwTG1lf3wy1nlQ8+0m14qZnU6khv7vE07CvIp2QcFJudD/2 NvAMnMBmonbAJdbHkni8aI6y6lKtNdM/zaQ6aX5NtIMj5HaokZQ1y9TdQ3yGInkBwVogXlh3rjM cnMZ9 X-Gm-Gg: ASbGncs6m9yQo8Z1Dd9kn3+aYGv3Y9Y+HXAxGYmxDyQDR6ZGVk5cIZ2cRsLQObMWvFY 0xreM5ZywBzUIUQKcW4n6/xYgtLxyvSs/d4aCdSggpz9JxBfc3cJwhp+HTFMc/VIDOVJlZtE6oI b9x4F95bREM5MT+LT7bUcTKVWrzlW8MecG8Jj8NSwHdfK26TXmtNkojxlEpl9AnDGsfu1fyq3QK EBGuHUG1lVwL7w6L8yd0UIFTEJw/f73GUvKOi7Tue/0RY0hNeJWgpDKgbGHKbDhpAHVumvFqDQE 5pMBukyquJTg/HUI699DGlCuKHC3FJpGJeug0/SOn+g7EJFRIx4K1vdAypmzK9WWjsb9VPAr/xq SG9T46CGLip7KjaRzar7Rozz9KVWkVqH65h9hIDB/9VLcAGEWdemVxgl3j9+ubDk8qsDXaQSCx/ hrUG/CQnyAFTqAYEoigagNkndXcLJsnA== X-Google-Smtp-Source: AGHT+IH6iuIkdswA+GTaULPvX+70X3GMBpNL0JZ0FmnDpSLo5BDKK14xS4OelHq8DIuHRNJEubeCSA== X-Received: by 2002:a17:907:1c23:b0:b3f:f207:b748 with SMTP id a640c23a62f3a-b50aa48d5e2mr2711962066b.10.1760491380652; Tue, 14 Oct 2025 18:23:00 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:00 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie, Kieran Bingham Subject: [PATCH v3 06/39] libcamera: swstats_cpu: Move header to libcamera/internal/software_isp Date: Wed, 15 Oct 2025 02:22:18 +0100 Message-ID: <20251015012251.17508-7-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" From: Hans de Goede Move the swstats_cpu.h file to include/libcamera/internal/software_isp/ so that it can be used outside the src/libcamera/software_isp/ directory. Reviewed-by: Milan Zamazal Reviewed-by: Kieran Bingham Signed-off-by: Hans de Goede Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/software_isp/meson.build | 1 + .../libcamera/internal}/software_isp/swstats_cpu.h | 0 src/libcamera/software_isp/debayer_cpu.h | 2 +- src/libcamera/software_isp/swstats_cpu.cpp | 2 +- 4 files changed, 3 insertions(+), 2 deletions(-) rename {src/libcamera => include/libcamera/internal}/software_isp/swstats_cpu.h (100%) diff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build index 508ddddc..ea3f3f1c 100644 --- a/include/libcamera/internal/software_isp/meson.build +++ b/include/libcamera/internal/software_isp/meson.build @@ -4,4 +4,5 @@ libcamera_internal_headers += files([ 'debayer_params.h', 'software_isp.h', 'swisp_stats.h', + 'swstats_cpu.h', ]) diff --git a/src/libcamera/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h similarity index 100% rename from src/libcamera/software_isp/swstats_cpu.h rename to include/libcamera/internal/software_isp/swstats_cpu.h diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index 03e0d784..1cd411f2 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -19,9 +19,9 @@ #include "libcamera/internal/bayer_format.h" #include "libcamera/internal/global_configuration.h" +#include "libcamera/internal/software_isp/swstats_cpu.h" #include "debayer.h" -#include "swstats_cpu.h" namespace libcamera { diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index 1b33ffa7..55e764b0 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -9,7 +9,7 @@ * CPU based software statistics implementation */ -#include "swstats_cpu.h" +#include "libcamera/internal/software_isp/swstats_cpu.h" #include From patchwork Wed Oct 15 01:22:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24652 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 60F5ABF415 for ; Wed, 15 Oct 2025 01:23:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B76E260629; Wed, 15 Oct 2025 03:23:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="M1VKP047"; dkim-atps=neutral Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 519DA6060D for ; Wed, 15 Oct 2025 03:23:02 +0200 (CEST) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-639e1e8c8c8so11576871a12.1 for ; Tue, 14 Oct 2025 18:23:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491381; x=1761096181; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/6kxvdjX0tzQocqho+X4IStbtmMCRaS8dOxX+24Nfqs=; b=M1VKP0470f+vSrNR2NwHZraXKEd9y8+NNPawXAld27aIfFj8q8MmZbpFVtKtsFextd Ruuwz1CWx0DuKV8CSxi0IjJOv3n2VsOMtCmeiurKogjm8Rj66UQPKCAvglJJCWgn0Ih5 BDgopB11v3u8GiVsnqWzUNg4Phs/BHF9n6AGe1Rp8iN3dTnQrUU4bT859PsnqI+34rST RadUBPQOZ1CQ+eKxKziqmlFovx1HmZQSUX66HcVYSSmHWZGIEeT/dFoIsBRyWZpcsjpw EMqv6gSM/mHDzinbj2o1EHEC15/QbxDBUEy70mbsrMO1/m1p4hvQoQZUUJ5AU6SyWCDW +olQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491381; x=1761096181; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/6kxvdjX0tzQocqho+X4IStbtmMCRaS8dOxX+24Nfqs=; b=HuIkiiNf2iIyoZEB9HGdlt34zwHc1z4g/xZR0oXa0MAJvJnK6W3qHZXSoGCu3Wi2aI JFO5qndriYsPaxJnq8QsvQLSmdUbG9t6P7xeOnDMCfeZkA8PC7MCEN7nNkVDBu0Rqdma ANPLMtiCzCcczlIpdi/5yFepl7vrEVNlapGRf5n4H7T9DNLpfxdY+M5DtH48PgoMo6Kt Sb8UhIZGoPEYw5m6C8xhqvUAJRAisB6bD++USeV7rBomS6Or7pJ1BE18G/zhnaI4FLJG Smx2A5Y8aA6Yi4XzITHx2OJBmiEULj9hjazRR8/Ht19f72zxXMD1uz04i9S3JYXErhhB GAzw== X-Gm-Message-State: AOJu0YxlDuACY83nuKZ2oVsJZJjAiApHtk8B/nUNgEO8VicPBMj0nZfS lBZRmYqWszsM8Wu1urkjTTN3XwSWJfI5P5E7b3sZnHbSXnBUtB0uYH5kowsCtABpQRf/jyfCSkR Vp7Ic X-Gm-Gg: ASbGncugovpiTVyA9lvByiVI9jz6LOUeCD2axUvdfKisCHoqDnRcbBcH4tgwiBfmkdG fbVxiAU3TaGHHGwcYLZST79MNzSAduEyS/loZogNBiF/CTOkyfnVUx/S4NbPcdVH2B9tfOAVgGD vuu3Q7EI6DZshFzt3tarBbi61ZSTSfLkHJDvhgQOHiXEv0rjUR+E2NYa5eoqwqU6kC97aFDmmuO ccC511H7L2C/AGtgB6xfXjdkpjxpDC23dnKnyAja8IzrbBf3FWHY2UTGjX99JpDF3L29FDH5rBT fZKUQIi6lLDaeG8FKFqrFkVyx0wCUmBArhPtPKL/fU1+rYKir6ILRHnhDRb6a1TqPodhRYXO3KX FPwhEHHRptYCE5uwDsipVGjSLWcXvYTsWUzAsZLo+gtEZbpQdYQ+RQfDdotFO1pOu1xIJERIZ3H x/Xr+WkxlzduNSutgQD/M0jtEopB9uCweJ8pbI7QffSBiwCh0w40c= X-Google-Smtp-Source: AGHT+IELNu+IiopqU3iaNpdKTzn30axZoWZEswTys8EWxKhMAUQT2Qu4Tork4aafL+h+jABUCwmldA== X-Received: by 2002:a17:907:d86:b0:b40:8954:a8a9 with SMTP id a640c23a62f3a-b50ac0cc32amr2727847366b.34.1760491381586; Tue, 14 Oct 2025 18:23:01 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:01 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie, Kieran Bingham Subject: [PATCH v3 07/39] libcamera: software_isp: Move benchmark code to its own class Date: Wed, 15 Oct 2025 02:22:19 +0100 Message-ID: <20251015012251.17508-8-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" From: Hans de Goede Move the code for the builtin benchmark to its own small Benchmark class. Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Signed-off-by: Hans de Goede [bod: Fixed up some drift in this patch since initial propostion] Signed-off-by: Bryan O'Donoghue --- .../internal/software_isp/benchmark.h | 39 ++++++++ .../internal/software_isp/meson.build | 1 + src/libcamera/software_isp/benchmark.cpp | 92 +++++++++++++++++++ src/libcamera/software_isp/debayer_cpu.cpp | 45 +-------- src/libcamera/software_isp/debayer_cpu.h | 6 +- src/libcamera/software_isp/meson.build | 1 + 6 files changed, 138 insertions(+), 46 deletions(-) create mode 100644 include/libcamera/internal/software_isp/benchmark.h create mode 100644 src/libcamera/software_isp/benchmark.cpp diff --git a/include/libcamera/internal/software_isp/benchmark.h b/include/libcamera/internal/software_isp/benchmark.h new file mode 100644 index 00000000..0680d6cd --- /dev/null +++ b/include/libcamera/internal/software_isp/benchmark.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Red Hat Inc. + * + * Authors: + * Hans de Goede + * + * Simple builtin benchmark to measure software ISP processing times + */ + +#pragma once + +#include +#include +#include +#include "libcamera/internal/global_configuration.h" + +namespace libcamera { + +class Benchmark +{ +public: + Benchmark(const GlobalConfiguration &configuration); + ~Benchmark(); + + void startFrame(void); + void finishFrame(void); + +private: + timespec frameStartTime_; + bool measure; + /* Skip 30 frames for things to stabilize then measure 30 frames */ + unsigned int encounteredFrames_ = 0; + int64_t frameProcessTime_ = 0; + unsigned int skipBeforeMeasure_ = 30; + unsigned int framesToMeasure_ = 30; +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build index ea3f3f1c..df7c3b97 100644 --- a/include/libcamera/internal/software_isp/meson.build +++ b/include/libcamera/internal/software_isp/meson.build @@ -1,6 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 libcamera_internal_headers += files([ + 'benchmark.h', 'debayer_params.h', 'software_isp.h', 'swisp_stats.h', diff --git a/src/libcamera/software_isp/benchmark.cpp b/src/libcamera/software_isp/benchmark.cpp new file mode 100644 index 00000000..1a00ae56 --- /dev/null +++ b/src/libcamera/software_isp/benchmark.cpp @@ -0,0 +1,92 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Red Hat Inc. + * + * Authors: + * Hans de Goede + * + * Simple builtin benchmark to measure software ISP processing times + */ + +#include "libcamera/internal/software_isp/benchmark.h" + +#include + +namespace libcamera { + +LOG_DEFINE_CATEGORY(Benchmark) + +/** + * \class Benchmark + * \brief Simple builtin benchmark + * + * Simple builtin benchmark to measure software ISP processing times. + */ + +/** + * \brief Constructs a Benchmark object + */ +Benchmark::Benchmark(const GlobalConfiguration &configuration) +{ + skipBeforeMeasure_ = configuration.option( + { "software_isp", "measure", "skip" }) + .value_or(skipBeforeMeasure_); + framesToMeasure_ = configuration.option( + { "software_isp", "measure", "number" }) + .value_or(framesToMeasure_); +} + +Benchmark::~Benchmark() +{ +} + +static inline int64_t timeDiff(timespec &after, timespec &before) +{ + return (after.tv_sec - before.tv_sec) * 1000000000LL + + (int64_t)after.tv_nsec - (int64_t)before.tv_nsec; +} + +/** + * \brief Start measuring process time for a single frame + * + * Call this function before processing frame data to start measuring + * the process time for a frame. + */ +void Benchmark::startFrame(void) +{ + measure = framesToMeasure_ > 0 && + encounteredFrames_ < skipBeforeMeasure_ + framesToMeasure_ && + ++encounteredFrames_ > skipBeforeMeasure_; + + if (measure) { + frameStartTime_ = {}; + clock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime_); + } +} + +/** + * \brief Finish measuring process time for a single frame + * + * Call this function after processing frame data to finish measuring + * the process time for a frame. + * + * This function will log frame processing time information after + * Benchmark::kLastFrameToMeasure frames have been processed. + */ +void Benchmark::finishFrame(void) +{ + if (measure) { + timespec frameEndTime = {}; + clock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime); + frameProcessTime_ += timeDiff(frameEndTime, frameStartTime_); + if (encounteredFrames_ == skipBeforeMeasure_ + framesToMeasure_) { + LOG(Benchmark, Info) + << "Processed " << framesToMeasure_ + << " frames in " << frameProcessTime_ / 1000 << "us, " + << frameProcessTime_ / (1000 * framesToMeasure_) + << " us/frame"; + } + } +} + +} /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index c2fb11ba..df77deb6 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -42,7 +42,7 @@ namespace libcamera { * \param[in] configuration The global configuration */ DebayerCpu::DebayerCpu(std::unique_ptr stats, const GlobalConfiguration &configuration) - : stats_(std::move(stats)) + : stats_(std::move(stats)), bench_(configuration) { /* * Reading from uncached buffers may be very slow. @@ -58,13 +58,6 @@ DebayerCpu::DebayerCpu(std::unique_ptr stats, const GlobalConfigurat enableInputMemcpy_ = configuration.option({ "software_isp", "copy_input_buffer" }).value_or(true); - skipBeforeMeasure_ = configuration.option( - { "software_isp", "measure", "skip" }) - .value_or(skipBeforeMeasure_); - framesToMeasure_ = configuration.option( - { "software_isp", "measure", "number" }) - .value_or(framesToMeasure_); - /* Initialize color lookup tables */ for (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) { red_[i] = green_[i] = blue_[i] = i; @@ -571,9 +564,6 @@ int DebayerCpu::configure(const StreamConfiguration &inputCfg, lineBuffers_[i].resize(lineBufferLength_); } - encounteredFrames_ = 0; - frameProcessTime_ = 0; - return 0; } @@ -765,27 +755,9 @@ void DebayerCpu::process4(uint32_t frame, const uint8_t *src, uint8_t *dst) } } -namespace { - -inline int64_t timeDiff(timespec &after, timespec &before) -{ - return (after.tv_sec - before.tv_sec) * 1000000000LL + - (int64_t)after.tv_nsec - (int64_t)before.tv_nsec; -} - -} /* namespace */ - void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) { - timespec frameStartTime; - - bool measure = framesToMeasure_ > 0 && - encounteredFrames_ < skipBeforeMeasure_ + framesToMeasure_ && - ++encounteredFrames_ > skipBeforeMeasure_; - if (measure) { - frameStartTime = {}; - clock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime); - } + bench_.startFrame(); std::vector dmaSyncers; for (const FrameBuffer::Plane &plane : input->planes()) @@ -839,18 +811,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output dmaSyncers.clear(); /* Measure before emitting signals */ - if (measure) { - timespec frameEndTime = {}; - clock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime); - frameProcessTime_ += timeDiff(frameEndTime, frameStartTime); - if (encounteredFrames_ == skipBeforeMeasure_ + framesToMeasure_) { - LOG(Debayer, Info) - << "Processed " << framesToMeasure_ - << " frames in " << frameProcessTime_ / 1000 << "us, " - << frameProcessTime_ / (1000 * framesToMeasure_) - << " us/frame"; - } - } + bench_.finishFrame(); /* * Buffer ids are currently not used, so pass zeros as its parameter. diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index 1cd411f2..aff32491 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -17,6 +17,7 @@ #include +#include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/bayer_format.h" #include "libcamera/internal/global_configuration.h" #include "libcamera/internal/software_isp/swstats_cpu.h" @@ -161,10 +162,7 @@ private: unsigned int xShift_; /* Offset of 0/1 applied to window_.x */ bool enableInputMemcpy_; bool swapRedBlueGains_; - unsigned int encounteredFrames_; - int64_t frameProcessTime_; - unsigned int skipBeforeMeasure_ = 30; - unsigned int framesToMeasure_ = 30; + Benchmark bench_; }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build index aac7eda7..59fa5f02 100644 --- a/src/libcamera/software_isp/meson.build +++ b/src/libcamera/software_isp/meson.build @@ -8,6 +8,7 @@ if not softisp_enabled endif libcamera_internal_sources += files([ + 'benchmark.cpp', 'debayer.cpp', 'debayer_cpu.cpp', 'software_isp.cpp', From patchwork Wed Oct 15 01:22:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24653 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 B6B4DC3331 for ; Wed, 15 Oct 2025 01:23:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2E9F66062B; Wed, 15 Oct 2025 03:23:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="nCJz3kWw"; dkim-atps=neutral Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 644DF60612 for ; Wed, 15 Oct 2025 03:23:03 +0200 (CEST) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-afcb7ae6ed0so1019340966b.3 for ; Tue, 14 Oct 2025 18:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491383; x=1761096183; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K3FoQV7xQAgIgQqS1yVdt6nWFXu6g4HjccATVbBtrDE=; b=nCJz3kWwMt90XTKCh0VTvIRxwNAoT7zbHlJw3tZtbvm3RnMHdF9xD3Whje/HupUkKv yDCNGQd+5z0zk0Qmriij4ndVp+HXZexNwvOiU6CzYwHYlXu6BgFTrCetbRzzu+1GclKN bTEcCwR1tB1VGm+UTqCH1WyUPy3YiTMK0SWdma0CLnrG2mT9gow6lKNTviGOow3zI2WF qSYUR7Vw8+0xFg0KXDX9EyavmMWCsWxgIARxf1lhtvRMg8hTfDgWI1aGBjF+gQCnOWps yplpQLZXVqWI9e4iSWzguPbXLFKdwsi/o8tVFwVfpFSR0YCythToNSPvQVPUci8guSCq trjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491383; x=1761096183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K3FoQV7xQAgIgQqS1yVdt6nWFXu6g4HjccATVbBtrDE=; b=c359c78raLj48SA62F7KBdkEpkUxBFLWm0Chusy9G2sP2k0Ql9bFN7jw+RhzM6TP0f +P/ZsQ7O0RNxxo4er/33S4z9z8YnsGBH5MdSK/nUams7pwsATWn9HVzbva7+89jHNLYy BK0BiO8dUZGTLEBfeWZiTH0CfObz3qncDr9ytsXN0TDqb83JXolHn4Urlwq0XWS8buC3 Q8PkRh04lcxeB1bZlcbk2RSEbvf0PQJzm/CgJehByFzucY7TCaVexEph9CPurb7XzeYW Dn9qXAvAc6xovyH0vH74pBGwKghYVuYeaMyAnA5ZG28zkmn44GZ6lgJMFb5a2KAdQSoE hIMw== X-Gm-Message-State: AOJu0YwRPOn8QziUMs4y1rTGdIVLAByYgsv/410JrJxWZv1der0n/1F7 RB2TkjCh3J5APrjnK9njvyzmTfRLZiKDVmQPl8yGBe/059I/S0eCrMHrj26qfVos3HNdwe+m2ch V3J0z X-Gm-Gg: ASbGnctl1dgbNmULZSJj89kPxA78vlBhKWerruWFfyptEUH2kCfzXYFkGE7zEd1tk+x 2lNVaTb47eOALcJz2tJ+WzRQ3jELCUdVLyrphffk0exAsfOWDdNLJSRTK5l8i2BJdKW6GfAk16O EoYJZkXwG2TjduFymoOVJ78ggMBRxqezXHav1aWeDOgbyNMFipTz6Y86fU+Gef+dZ2H47X+pnHn FwYmqEnl2y3e+87/nEV12gdtBCM2kIwXbYG8KdSkZ+I4+4M6ub6Umh8/jHBl2/whER2sBq4OSCa gTA6mZ7o7uQjJVcE4koRrgrewGi8ww48T8HPCwwrNuJXBHayyh5wjSYdP5uSEdPdapP9otnWJHh udnXMH16scU/XWTRf3jts6nHsaxg9fjSfOpxsQ8wZZB158lEfMDxcUkZoVs41/dn0rQnPQw1lkx lXBMmaQuKSSVCH+jNpAEwvBOM+YyXO1BwwPMN/tJE+ X-Google-Smtp-Source: AGHT+IFu7TXzYDOw5vPrHJev2fFl+vpINNy7wwph4Z68XiLd0VEdVFPLowVBtVpLhfdcK9U+KCTQxg== X-Received: by 2002:a17:907:c06:b0:b3d:cc4a:a2fa with SMTP id a640c23a62f3a-b50ac1cc3afmr2492271066b.36.1760491382516; Tue, 14 Oct 2025 18:23:02 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:02 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 08/39] libcamera: swstats_cpu: Add processFrame() method Date: Wed, 15 Oct 2025 02:22:20 +0100 Message-ID: <20251015012251.17508-9-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" From: Hans de Goede Add a method to the SwstatsCpu class to process a whole Framebuffer in one go, rather then line by line. This is useful for gathering stats when debayering is not necessary or is not done on the CPU. Reviewed-by: Milan Zamazal Signed-off-by: Hans de Goede [bod: various rebase spalts fixed] Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- .../internal/software_isp/swstats_cpu.h | 15 ++++- src/libcamera/software_isp/software_isp.cpp | 5 +- src/libcamera/software_isp/swstats_cpu.cpp | 55 ++++++++++++++++++- 3 files changed, 70 insertions(+), 5 deletions(-) diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h index fae575f8..64b3e23f 100644 --- a/include/libcamera/internal/software_isp/swstats_cpu.h +++ b/include/libcamera/internal/software_isp/swstats_cpu.h @@ -18,18 +18,23 @@ #include #include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/framebuffer.h" +#include "libcamera/internal/global_configuration.h" #include "libcamera/internal/shared_mem_object.h" #include "libcamera/internal/software_isp/swisp_stats.h" +#include "benchmark.h" + namespace libcamera { class PixelFormat; +class MappedFrameBuffer; struct StreamConfiguration; class SwStatsCpu { public: - SwStatsCpu(); + SwStatsCpu(const GlobalConfiguration &configuration); ~SwStatsCpu() = default; /* @@ -50,6 +55,7 @@ public: void setWindow(const Rectangle &window); void startFrame(uint32_t frame); void finishFrame(uint32_t frame, uint32_t bufferId); + void processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input); void processLine0(uint32_t frame, unsigned int y, const uint8_t *src[]) { @@ -79,6 +85,7 @@ public: private: using statsProcessFn = void (SwStatsCpu::*)(const uint8_t *src[]); + using processFrameFn = void (SwStatsCpu::*)(MappedFrameBuffer &in); int setupStandardBayerOrder(BayerFormat::Order order); /* Bayer 8 bpp unpacked */ @@ -91,6 +98,10 @@ private: void statsBGGR10PLine0(const uint8_t *src[]); void statsGBRG10PLine0(const uint8_t *src[]); + void processBayerFrame2(MappedFrameBuffer &in); + + processFrameFn processFrame_; + /* Variables set by configure(), used every line */ statsProcessFn stats0_; statsProcessFn stats2_; @@ -103,9 +114,11 @@ private: Size patternSize_; unsigned int xShift_; + unsigned int stride_; SharedMemObject sharedStats_; SwIspStats stats_; + Benchmark bench_; }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index b7651b7d..6f1f88fe 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -107,14 +107,15 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, return; } - auto stats = std::make_unique(); + const GlobalConfiguration &configuration = pipe->cameraManager()->_d()->configuration(); + + auto stats = std::make_unique(configuration); if (!stats->isValid()) { LOG(SoftwareIsp, Error) << "Failed to create SwStatsCpu object"; return; } stats->statsReady.connect(this, &SoftwareIsp::statsReady); - const GlobalConfiguration &configuration = pipe->cameraManager()->_d()->configuration(); debayer_ = std::make_unique(std::move(stats), configuration); debayer_->inputBufferReady.connect(this, &SoftwareIsp::inputReady); debayer_->outputBufferReady.connect(this, &SoftwareIsp::outputReady); diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index 55e764b0..48d12c51 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -16,6 +16,7 @@ #include #include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/mapped_framebuffer.h" namespace libcamera { @@ -144,8 +145,8 @@ namespace libcamera { LOG_DEFINE_CATEGORY(SwStatsCpu) -SwStatsCpu::SwStatsCpu() - : sharedStats_("softIsp_stats") +SwStatsCpu::SwStatsCpu(const GlobalConfiguration &configuration) + : sharedStats_("softIsp_stats"), bench_(configuration) { if (!sharedStats_) LOG(SwStatsCpu, Error) @@ -386,11 +387,14 @@ int SwStatsCpu::setupStandardBayerOrder(BayerFormat::Order order) */ int SwStatsCpu::configure(const StreamConfiguration &inputCfg) { + stride_ = inputCfg.stride; + BayerFormat bayerFormat = BayerFormat::fromPixelFormat(inputCfg.pixelFormat); if (bayerFormat.packing == BayerFormat::Packing::None && setupStandardBayerOrder(bayerFormat.order) == 0) { + processFrame_ = &SwStatsCpu::processBayerFrame2; switch (bayerFormat.bitDepth) { case 8: stats0_ = &SwStatsCpu::statsBGGR8Line0; @@ -411,6 +415,7 @@ int SwStatsCpu::configure(const StreamConfiguration &inputCfg) /* Skip every 3th and 4th line, sample every other 2x2 block */ ySkipMask_ = 0x02; xShift_ = 0; + processFrame_ = &SwStatsCpu::processBayerFrame2; switch (bayerFormat.order) { case BayerFormat::BGGR: @@ -475,4 +480,50 @@ void SwStatsCpu::setWindow(const Rectangle &window) window_.height &= ~(patternSize_.height - 1); } +void SwStatsCpu::processBayerFrame2(MappedFrameBuffer &in) +{ + const uint8_t *src = in.planes()[0].data(); + const uint8_t *linePointers[3]; + + /* Adjust src for starting at window_.y */ + src += window_.y * stride_; + + for (unsigned int y = 0; y < window_.height; y += 2) { + if (y & ySkipMask_) { + src += stride_ * 2; + continue; + } + + /* linePointers[0] is not used by any stats0_ functions */ + linePointers[1] = src; + linePointers[2] = src + stride_; + (this->*stats0_)(linePointers); + src += stride_ * 2; + } +} + +/** + * \brief Calculate statistics for a frame in one go + * \param[in] frame The frame number + * \param[in] bufferId ID of the statistics buffer + * \param[in] input The frame to process + * + * This may only be called after a successful setWindow() call. + */ +void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input) +{ + bench_.startFrame(); + startFrame(frame); + + MappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read); + if (!in.isValid()) { + LOG(SwStatsCpu, Error) << "mmap-ing buffer(s) failed"; + return; + } + + (this->*processFrame_)(in); + finishFrame(frame, bufferId); + bench_.finishFrame(); +} + } /* namespace libcamera */ From patchwork Wed Oct 15 01:22:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24654 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 DED39BF415 for ; Wed, 15 Oct 2025 01:23:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 480CB60622; Wed, 15 Oct 2025 03:23:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Lm7RcUaU"; dkim-atps=neutral Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D71D60618 for ; Wed, 15 Oct 2025 03:23:04 +0200 (CEST) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-b40f11a1027so1073899066b.2 for ; Tue, 14 Oct 2025 18:23:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491383; x=1761096183; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3ome6wJLZjqhmaYsCAuXqPUDJjo8qNs2C5lFy+zKkTE=; b=Lm7RcUaUwvpmuNB+o7/ZuQiNuiiXUzftaQ4LIDuXjdvh5z6o488Yai98btBfEDYU2L EdDEiSwitUWuVYYscBArXRAKB1Mp7jyZ7Uwl7fZDB9GwI7sNCu4LDVV6cXgHldrb1sad ih5uuzigH9ntvdrKW5PMaltZ4X7NQPU/+MXGLunibAvAmxMifRaJt64+Ah3XDJ1rgGw1 qdJdVmVVB9u4NtDaqQNktKvZ6COnM4Ys1uanRcn32dUWXhsy8/oiGHxaBvMU7bjpgJdT DPQh+1Z4aLR++r7h4Z8GpeEkGuw59GpsQQi9ykFTfsN5gV/xLe2MWZP8zFAsZwhkNBJ6 VV1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491383; x=1761096183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3ome6wJLZjqhmaYsCAuXqPUDJjo8qNs2C5lFy+zKkTE=; b=xSuFSdSSDG4ex3I/XiXEryBD3MNMx9TapmfyNHzYv4pA1rfGvNIKMSMZEPbns59IAd rLHxiMSqS1TOXQDcazeBeqqGjaRAsvcCdwgn76Di59TMcoco2PwW2nO5bE+zBCYUcdXX 0hxerUJQi/kkv3lS4CC1rEkgtBgE9w3yQdGVDI4d9uD8gaeNlXfX1kApv2dpl1KQSRJ3 9NDBE8Ovexi7PwTWhj8QtSR2/p6zlE5nhbP/Gga2Bsd8R06sXxQf7zzixptsnfJ9fC7j u1P7qh93IZRAE3aCDmbv2uYHXmzf5VRL+tTB60qjpin5a4fyjk7nrXrv/uJFe9sjfjiq Fdpw== X-Gm-Message-State: AOJu0YytI/uZHKDzXSj/CsgC5NlmZ6HdLQgL+FsrA7r6Ds4i4SANpLN5 UP+x31iBhiPFOwmJ+TP09LG8aBVQf3Wb4FBEjiIm2wRJtIcs8tCZK7RdX1yNIEZtyqvh9kx9IMa ScuPD X-Gm-Gg: ASbGncsYYMeoGzbmtV5MGBApauDR3dtOFKXu/PmtruaTlIIlERmnn+cZTnWrUz+3zcA pt0/lg4mXxr+QMKTfT1fFfv0WvWdv5sh0zog5FzzX6YJw6wLXqIU4Qxp2dB1TFGZmrhSYILIFjX jRIdkzWrTbT6yDg/TDVCnRZYKi9NQMpy2jsIMxV2S9w+WjwvB+Fd7So3JqTd8wxkF25k3HGjVtf nzaFkkKic+Lh0Ol8YXYbrE/Vbb9/4NnVPLT21SlQgJr2AwxnYcxYWaekV4/j94Gs2zRWmCXPlNp GYxoWO8rYwJ0+h9l/srLQRIykB5rh4nt8jIiu6xDcbsLS65kAL88yeib4Bq7JsCZ6nBB5qtfyuj XXlipQXjJJ7KL8k7wK/0qEIl/NpsrM26egiN7ka59/yyWXdraD+SqZxRA/id3PhOFhg9JiFeaFq 0eGTXXsGGg3Jy2bhVJszEmD3aOR/QAfe6d80KthSlj X-Google-Smtp-Source: AGHT+IFmbV75YWgYP1Snbyr6pOFAXRm/0v9qTOz/dXXNUUtfTCfRYD9tOCS1lhudIxriMMetwv88Bw== X-Received: by 2002:a17:907:7292:b0:b50:891f:66b3 with SMTP id a640c23a62f3a-b50aca0b669mr2544259966b.64.1760491383451; Tue, 14 Oct 2025 18:23:03 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:03 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 09/39] libcamera: software_isp: Move useful items from DebayerCpu to Debayer base class Date: Wed, 15 Oct 2025 02:22:21 +0100 Message-ID: <20251015012251.17508-10-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" The DebayerCpu class has a number of variables, embedded structures and methods which are useful to DebayerGpu implementation. Move relevant variables and methods to base class. Since we want to call setParams() from the GPUISP and reuse the code in the existing CPUISP as a first step, we need to move all of the dependent variables in DebayerCPU to the Debayer base class including LookupTable and redCcm_. The DebayerEGL class will ultimately be able to consume both the CCM and non-CCM data. Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- src/libcamera/software_isp/debayer.h | 45 +++++++++++++++++++++- src/libcamera/software_isp/debayer_cpu.cpp | 2 +- src/libcamera/software_isp/debayer_cpu.h | 35 +---------------- 3 files changed, 46 insertions(+), 36 deletions(-) diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index ba033d44..1b195d29 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -14,11 +14,14 @@ #include #include +#include #include #include #include +#include "libcamera/internal/global_configuration.h" +#include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/software_isp/debayer_params.h" namespace libcamera { @@ -27,9 +30,10 @@ class FrameBuffer; LOG_DECLARE_CATEGORY(Debayer) -class Debayer +class Debayer : public Object { public: + Debayer (const GlobalConfiguration &configuration) : bench_(configuration) {}; virtual ~Debayer() = 0; virtual int configure(const StreamConfiguration &inputCfg, @@ -45,8 +49,47 @@ public: virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0; + virtual const SharedFD &getStatsFD() = 0; + + unsigned int frameSize() { return outputConfig_.frameSize; } + Signal inputBufferReady; Signal outputBufferReady; + + /** + * struct DebayerInputConfig + * + * Structure to describe the incoming Bayer parameters. + */ + struct DebayerInputConfig { + Size patternSize; + unsigned int bpp; /* Memory used per pixel, not precision */ + unsigned int stride; + std::vector outputFormats; + }; + + /** + * struct DebayerOutputConfig + * + * Structure to describe the output pattern requested to the Debayer logic. + */ + struct DebayerOutputConfig { + unsigned int bpp; /* Memory used per pixel, not precision */ + unsigned int stride; + unsigned int frameSize; + }; + + DebayerInputConfig inputConfig_; + DebayerOutputConfig outputConfig_; + DebayerParams::LookupTable red_; + DebayerParams::LookupTable green_; + DebayerParams::LookupTable blue_; + DebayerParams::CcmLookupTable redCcm_; + DebayerParams::CcmLookupTable greenCcm_; + DebayerParams::CcmLookupTable blueCcm_; + DebayerParams::LookupTable gammaLut_; + bool swapRedBlueGains_; + Benchmark bench_; private: virtual Size patternSize(PixelFormat inputFormat) = 0; diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index df77deb6..612f01a6 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -42,7 +42,7 @@ namespace libcamera { * \param[in] configuration The global configuration */ DebayerCpu::DebayerCpu(std::unique_ptr stats, const GlobalConfiguration &configuration) - : stats_(std::move(stats)), bench_(configuration) + : Debayer(configuration), stats_(std::move(stats)) { /* * Reading from uncached buffers may be very slow. diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index aff32491..ff72eaba 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -17,16 +17,14 @@ #include -#include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/bayer_format.h" -#include "libcamera/internal/global_configuration.h" #include "libcamera/internal/software_isp/swstats_cpu.h" #include "debayer.h" namespace libcamera { -class DebayerCpu : public Debayer, public Object +class DebayerCpu : public Debayer { public: DebayerCpu(std::unique_ptr stats, const GlobalConfiguration &configuration); @@ -49,13 +47,6 @@ public: */ const SharedFD &getStatsFD() { return stats_->getStatsFD(); } - /** - * \brief Get the output frame size - * - * \return The output frame size - */ - unsigned int frameSize() { return outputConfig_.frameSize; } - private: /** * \brief Called to debayer 1 line of Bayer input data to output format @@ -112,19 +103,6 @@ private: template void debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]); - struct DebayerInputConfig { - Size patternSize; - unsigned int bpp; /* Memory used per pixel, not precision */ - unsigned int stride; - std::vector outputFormats; - }; - - struct DebayerOutputConfig { - unsigned int bpp; /* Memory used per pixel, not precision */ - unsigned int stride; - unsigned int frameSize; - }; - int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config); int setupStandardBayerOrder(BayerFormat::Order order); @@ -140,20 +118,11 @@ private: /* Max. supported Bayer pattern height is 4, debayering this requires 5 lines */ static constexpr unsigned int kMaxLineBuffers = 5; - DebayerParams::LookupTable red_; - DebayerParams::LookupTable green_; - DebayerParams::LookupTable blue_; - DebayerParams::CcmLookupTable redCcm_; - DebayerParams::CcmLookupTable greenCcm_; - DebayerParams::CcmLookupTable blueCcm_; - DebayerParams::LookupTable gammaLut_; debayerFn debayer0_; debayerFn debayer1_; debayerFn debayer2_; debayerFn debayer3_; Rectangle window_; - DebayerInputConfig inputConfig_; - DebayerOutputConfig outputConfig_; std::unique_ptr stats_; std::vector lineBuffers_[kMaxLineBuffers]; unsigned int lineBufferLength_; @@ -161,8 +130,6 @@ private: unsigned int lineBufferIndex_; unsigned int xShift_; /* Offset of 0/1 applied to window_.x */ bool enableInputMemcpy_; - bool swapRedBlueGains_; - Benchmark bench_; }; } /* namespace libcamera */ From patchwork Wed Oct 15 01:22:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24655 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 79D67C3264 for ; Wed, 15 Oct 2025 01:23:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2A01460624; Wed, 15 Oct 2025 03:23:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="HYd2z6Rj"; dkim-atps=neutral Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2DBDD60615 for ; Wed, 15 Oct 2025 03:23:05 +0200 (CEST) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-b07d4d24d09so477426466b.2 for ; Tue, 14 Oct 2025 18:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491384; x=1761096184; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=rj1Q9DVnuRBHPeor/fvWxLXblC1U/WJh3SPsduMY8kI=; b=HYd2z6Rj9dg6tjjBTZQgCyCcrCl+vUV4+1Jst9qIEuhW3rjYsPlMES2J+AKaV4mMds Z2wsTFmFivz2Q2J+8+Qmz//oe/wIPi2RpHf7Ah6GCQrIs5GxgWca7yup/anJL22TjSrI 68ypY7+6n07+QiGdCNMo64vJO+17ZtonI+zmxkyZuz2JuaVdMULfZ8aV57EXlkXoskhD TMwFbYH//oUcgOImTBGX4g2FS+Lcjr7wkOxK5gQS2/K8ilmNNk1CpL5Yepyi67nCYelM cPhvaKMD5/9nmt6E1uBM5l9XuPPSH89Pw2hDchMRUkb7Mbg/5+Y9C7BYS7XLmINzU+vO ogUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491384; x=1761096184; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rj1Q9DVnuRBHPeor/fvWxLXblC1U/WJh3SPsduMY8kI=; b=CLmwR9j+i5Dpnv7zqhV2+WdrBYxOuGWZ8WnNOICIWQZ/zHTIGNdYtvcPnfWi4KG97S qUbU0MukqYZ/mu2Q0rtol7XcoBP8G8gCg8tLoEvg2hzOf3K2Sv0X1r4kl/RS09fu8sp/ 9id7eGnooy3jBN1WWWsvSG6J+q2aCTqz5UjMgTRAyIlqPbV4xI7nhuVrI5K7AZz7hkZR BP09XBCh65vLODpyyl/28ekNTOpkt7JK9zrY1zgYdKHKMcC3eVn+tuWFSowvmkGVgtxH NwBf7sjQImcU7ByNo7ixqtN9UACoIy3QgSkMe8QCAbdSnl7in+JhfX66CyU4Ib0WKx42 AaVQ== X-Gm-Message-State: AOJu0YwvYGXPyvehn4SdxE+oxEj4dQePKFAkbr2UGM4PjKjM8WLT2iHQ 7Vp5bsPs7fbPHdyj2zjJn2bZC1d49qGCP+CTCWC3Ls0OldPWjgSEscZYJ3oD8bqAcYZqpf52t9C 3HD+q X-Gm-Gg: ASbGncs+rCrWnfiJPUhw74gm94Mf8VvVBCdhpO+5bxTO+Z5b39doQauLQLzzOBBRY1J OnIoe8RRRyUAYw6WSvJxocV7W4lr4hZEQ7ANIlUyJN70OoWQ4I5HoGqxR2IIMXbGWZ72VEuGmmV bzqDDgCK+Z6duZhnJ1HhbVAlCfNO3R2bMgTrkLNsIyJsalfbw/PHX0bCHnhX8E7fSZ8hDtTTSGK 0T30pLfhyzdQTChlOxf/5t3JGleqsJx7fktAOhWFixDcuaT10PwIalxIITIlFxRNlkg3L7xNZfn zadcfbb5JJl4La/KQZ3TljnxzkaMAjYGkGrszMAcGyydrIiu2sfVLdzrBzF/E6qTIFz9d8WjTxt A56PSyTdTZKQcFY+MLwKmyWzmh9yuoRdpumcJ90ENgwoeQ5ixY2W9VMl4R7KFIbVKQ69Qvvf+Rw rTCJqiVAHejaDFtBmvqoDV/7SW41BaVoZWFxq8DhcR X-Google-Smtp-Source: AGHT+IHMnOB1soD11NbYfr07bmRyMLyRTuZeh7yKeF0kPhDyO8bj7qHInhjKGXJcDhvE8F5Pc45XQA== X-Received: by 2002:a17:906:c10e:b0:b04:2533:e8dd with SMTP id a640c23a62f3a-b50acb0cc4cmr2742600166b.60.1760491384451; Tue, 14 Oct 2025 18:23:04 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:03 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 10/39] libcamera: software_isp: Move Bayer params init from DebayerCpu to Debayer Date: Wed, 15 Oct 2025 02:22:22 +0100 Message-ID: <20251015012251.17508-11-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Move the initialisation of Bayer params and CCM to a new constructor in the Debayer class. Ensure we call the base class constructor from DebayerCpu's constructor in the expected constructor order Debayer then DebayerCpu. Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal --- src/libcamera/software_isp/debayer.cpp | 11 +++++++++++ src/libcamera/software_isp/debayer.h | 2 +- src/libcamera/software_isp/debayer_cpu.cpp | 8 -------- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index e9e18c48..937d5e2e 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -103,6 +103,17 @@ namespace libcamera { LOG_DEFINE_CATEGORY(Debayer) +Debayer::Debayer(const GlobalConfiguration &configuration) : bench_(configuration) +{ + /* Initialize color lookup tables */ + for (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) { + red_[i] = green_[i] = blue_[i] = i; + redCcm_[i] = { static_cast(i), 0, 0 }; + greenCcm_[i] = { 0, static_cast(i), 0 }; + blueCcm_[i] = { 0, 0, static_cast(i) }; + } +} + Debayer::~Debayer() { } diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index 1b195d29..2cbf0823 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -33,7 +33,7 @@ LOG_DECLARE_CATEGORY(Debayer) class Debayer : public Object { public: - Debayer (const GlobalConfiguration &configuration) : bench_(configuration) {}; + Debayer (const GlobalConfiguration &configuration); virtual ~Debayer() = 0; virtual int configure(const StreamConfiguration &inputCfg, diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 612f01a6..42a0f374 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -57,14 +57,6 @@ DebayerCpu::DebayerCpu(std::unique_ptr stats, const GlobalConfigurat */ enableInputMemcpy_ = configuration.option({ "software_isp", "copy_input_buffer" }).value_or(true); - - /* Initialize color lookup tables */ - for (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) { - red_[i] = green_[i] = blue_[i] = i; - redCcm_[i] = { static_cast(i), 0, 0 }; - greenCcm_[i] = { 0, static_cast(i), 0 }; - blueCcm_[i] = { 0, 0, static_cast(i) }; - } } DebayerCpu::~DebayerCpu() = default; From patchwork Wed Oct 15 01:22:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24656 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 80303C3331 for ; Wed, 15 Oct 2025 01:23:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0F4986061D; Wed, 15 Oct 2025 03:23:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="AwPr4qEC"; dkim-atps=neutral Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1303060622 for ; Wed, 15 Oct 2025 03:23:06 +0200 (CEST) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-b3f5e0e2bf7so1113267166b.3 for ; Tue, 14 Oct 2025 18:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491385; x=1761096185; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FfMDGj8P0x7z1LvkPhcFidNlN8u1agxdsMEloe1hujg=; b=AwPr4qECFBQ78mGqmarLNLW1X1gOPlbFEu4m/Y6T3yiui/pedZD5z7pynHeHpMpy4I 3drfhWwLOaPyrAd+PlaVlRVYZOrFZPRkNk6KAnjFpyIFcDcm1gTXmmiGGEV6et5mPLHN pXYT1VJEf8rXN/FWr8KmopHQ5Dj1XUKXiZabgaCy1YUAlnaDpxQA8pxgYqSzuDmSbhyv ckHQyvBUecC2V4Pcgjgq+mCF4LGecG6lcj23te++lwcAp9QpK9aLM8ru3672e3F5Crzp XVdOQjTvhliSslseidybo8MCNpaKqL0JYTZS95qGM28ix8qdAOPo8hhCz7DJhqsKNnOt ZjfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491385; x=1761096185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FfMDGj8P0x7z1LvkPhcFidNlN8u1agxdsMEloe1hujg=; b=UI6wNY6RZAHf30IEuAnffQX8h/ux3Sf0QEUNrVPesjxXSGwVx0Fi71KHxg17ICDC+x xcDbZHqjauAVcPnkSmM4IlxjIrmolgovvLbiDHVLlytk+HRMlU2fXz7legteW7vzV7sH hWBACOSQyBM579ORpcTXX8WDLsi9LdeaWQTdQ6aN/kMXgj6gJKgBItzd33q6lFSMVGZ4 txWAUa74jYET1GMIAAK/rv5BYIWMI3qy79Xo9VwB8zzAhYqd2maxTcuEX3GIXJhWyoVN GBgoLYILH7lGZIWEjJOVWjcaCz2n2Tb8nV5KeUsnwKvl338KQ2/bn7TdIpRAv8HEWRhd rrfw== X-Gm-Message-State: AOJu0YxCCk3+/kIymkDRrXrqzouAM1wcSByUB+zpH8ChNZprdE2swWtT ro62DlX+ZrlDnXv4mPXNkJqmOLTvNOUNFsXHuA7qvV2EHuqBU4WSeJVylv6z+5v6kiCWyMLXPG7 idLLr X-Gm-Gg: ASbGnctTTyn9JRRN3irE821Dvc30zpZlvVV5WOl0CJ4BHZ4XMGW5Em6FWDJaf1rBgE5 PIucEG3dF1QeaA/6Lxy/tLYEfUgHCI9dPHxym91ZqrUYU9D4RJ0Tt5aXD4ana2FxSLKOffwd9bL /Yi9lUtovhY7CZGbD4a7XXfiFJgd5YvRCQzBnhUq0zhsMagdETI4w1iAkZBkPOUfMeRwL81Jt6U x8bW6W2f1cWOJNTggzYzOmQsBe0zcuj6hq4PyROLslppbGSMZpOc6XjCu0i0vmeWiwfQPRUGQnj y6nxeD4RKM+hoh89gMh7I6N+b3co52LaKhDryPdkroJEB8w/M6X+FP5PWljM03kBWiDRng1vkEO +FgpZwaidCRx4k9sBq4LJLEG9K00tcAqSLG35dR5fckSpX9GfQDflMVdyKLCN6pCqmHekVWC5l8 eHp3w5Q3rPBUgY4Sa5ut9Bmt9B6nAiQh5r9VYpv0Hl X-Google-Smtp-Source: AGHT+IEdriDcKM4RN1llZOayHWGsZIX6OrNV5NzV2kfdl2PFxSWnluIcPy9vFpV2AwikpZThgJ+Vvw== X-Received: by 2002:a17:907:72d3:b0:b4f:4940:6a23 with SMTP id a640c23a62f3a-b50aa899e80mr2831672766b.24.1760491385306; Tue, 14 Oct 2025 18:23:05 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:04 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 11/39] libcamera: software_isp: Move param select code to Debayer base class Date: Wed, 15 Oct 2025 02:22:23 +0100 Message-ID: <20251015012251.17508-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Move the parameter selection code into the Debayer base class in-order to facilitate reuse of the lookup tables in the eGL shaders. Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal --- src/libcamera/software_isp/debayer.cpp | 27 ++++++++++++++++++++++ src/libcamera/software_isp/debayer.h | 3 +++ src/libcamera/software_isp/debayer_cpu.cpp | 19 +-------------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 937d5e2e..cf74b92b 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -187,4 +187,31 @@ Debayer::~Debayer() * \brief Signals when the output buffer is ready */ +/** + * \fn void Debayer::setParams(DebayerParams ¶ms) + * \brief Select the bayer params to use for the next frame debayer + * \param[in] params The parameters to be used in debayering + */ +void Debayer::setParams(DebayerParams ¶ms) +{ + green_ = params.green; + greenCcm_ = params.greenCcm; + if (swapRedBlueGains_) { + red_ = params.blue; + blue_ = params.red; + redCcm_ = params.blueCcm; + blueCcm_ = params.redCcm; + for (unsigned int i = 0; i < 256; i++) { + std::swap(redCcm_[i].r, redCcm_[i].b); + std::swap(blueCcm_[i].r, blueCcm_[i].b); + } + } else { + red_ = params.red; + blue_ = params.blue; + redCcm_ = params.redCcm; + blueCcm_ = params.blueCcm; + } + gammaLut_ = params.gammaLut; +} + } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index 2cbf0823..c04c289d 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -93,6 +93,9 @@ public: private: virtual Size patternSize(PixelFormat inputFormat) = 0; + +protected: + void setParams(DebayerParams ¶ms); }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 42a0f374..6be5cdbd 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -758,24 +758,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output for (const FrameBuffer::Plane &plane : output->planes()) dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write); - green_ = params.green; - greenCcm_ = params.greenCcm; - if (swapRedBlueGains_) { - red_ = params.blue; - blue_ = params.red; - redCcm_ = params.blueCcm; - blueCcm_ = params.redCcm; - for (unsigned int i = 0; i < 256; i++) { - std::swap(redCcm_[i].r, redCcm_[i].b); - std::swap(blueCcm_[i].r, blueCcm_[i].b); - } - } else { - red_ = params.red; - blue_ = params.blue; - redCcm_ = params.redCcm; - blueCcm_ = params.blueCcm; - } - gammaLut_ = params.gammaLut; + setParams(params); /* Copy metadata from the input buffer */ FrameMetadata &metadata = output->_d()->metadata(); From patchwork Wed Oct 15 01:22:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24657 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 7B23FBF415 for ; Wed, 15 Oct 2025 01:23:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E1C9D60632; Wed, 15 Oct 2025 03:23:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Bik/fmAP"; dkim-atps=neutral Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 00FEC6061D for ; Wed, 15 Oct 2025 03:23:07 +0200 (CEST) Received: by mail-ed1-x52b.google.com with SMTP id 4fb4d7f45d1cf-63babfdb52cso4419460a12.3 for ; Tue, 14 Oct 2025 18:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491386; x=1761096186; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WKIwKbS/EjWJeU3jpVyRd0DduiSXuAV1yXbTpM8/ki4=; b=Bik/fmAP+HB3nHUoMS7mom/lqWcDIH4lXt/t6SivO+9xhy6+1HHWWdg6P6aEbYSjpZ t8n8GUSMt8rjWXuwaDJ5XJt+JgOTSmvxJFFWMpa2pYGXnWidDoO3sl8eyBFnHDtz/nx4 WOFvG9j5gPTx+xEf4WlsXxDvmwnO432KZWFiCzuuzjhF5FEZE6FaepzDAW2HuY0b3Xkh eTF21ngU8NjybvqAHUpYNs6azcrpWdhztQGi85nAow3qxrOY8SkzhDF00aJIDfLcWxjC xcFNx8/cSPbXGiOzTchbHf5hY6+JXZIHbrzmh7sa4qSxlG9bjyOEBefrJZuj2G2GVVwl fHDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491386; x=1761096186; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WKIwKbS/EjWJeU3jpVyRd0DduiSXuAV1yXbTpM8/ki4=; b=WZaAZSgF3eVXd9YlZvljJCLHfcw/82uWAYs6y89gb6j+A/T6YfL8FtV0s4BXSgisOF Hflm4RTKJQ/bzZvBxZYRn5yfXRdBiDAFJVrqltJx9OoHa2YGu4smjNkcnmE0qKrsXpru U2Nbu5IsgWayzoTkJTmkm6csiVmpu7fUjiqH6t8OBkpHbqanv/oEZx/nl7nu+pyoLiWb BtrMhYgFcNIoGp3X4GehiaBA+J94npDt+EoVdQe1pt7huLsmH1kOOGnzpv1qkH6eNedf /IrdIiXyzQo2c/tAn0DRlmQfDJBhUZbKuH9NajzaCz6gcbrcRK5/UWIku1ZT23TSMwaK 0/FA== X-Gm-Message-State: AOJu0YyHXY62fsmgSPeGggAFhUm+dOTD8eWyXGVapPv4l0zaBtzpPuRm vVezHmSCD4vKzwsjeZJAd/YepSJ/+ebHhy1nizpi+vB6qWRavDQSS8wRrCenbnzsHPHnKfH8VVm ZWaGR X-Gm-Gg: ASbGncsCjGT7ubkg4n2tIL0J0ufMFN2tfWAHQ5Zh7UQ9WDZ5sMnj4u7HZ2X7wq+NDr/ ohvzWbdBRtb9hofNSJWCpgF27RL1pQgitbG2KOoqWlPkBUfr40+j25mhnwg44amKwt+VsBPenmN CtCuttNuiTORvGgb7d9vCouhd7hMuxLWV6Z8Gqarf2Yqme/oLZiTVmA8WH5DQm9dV6nAiQyTfth IABUyCO7lBqclrbo7oBqIqKabzDOpZ9q4TCrWXP2a+alxkJVhmH4UH7Ul/NRHnsdBBROn6ufKXg 8HRe7sIt5SvH066bmA1mFvONC5yziBuQIqffkYP0lm2lhd1+FJmjpQWf1lBnhczZqb052jyBNda FwK08gkcYRXvSzOyqwDww734DPukFtF7pQmX7w31MH3nPKeeHiNUm+Px5/rjUmmAfu0zND4fr5Z dmhz7e6f0Iceg1EvwAxMbIg8JLzwIYVg== X-Google-Smtp-Source: AGHT+IENxzjapHIHlyqqztQrZzyYkGp3ZfsjUoIDsLUtcaaZ7se0ufJdtMJkcsnix54aL5YligUDhQ== X-Received: by 2002:a17:906:4789:b0:b3e:f028:2d57 with SMTP id a640c23a62f3a-b50acc3132amr3152829166b.57.1760491386279; Tue, 14 Oct 2025 18:23:06 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:05 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 12/39] libcamera: software_isp: Move DMA Sync code to Debayer base class Date: Wed, 15 Oct 2025 02:22:24 +0100 Message-ID: <20251015012251.17508-13-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" We can reuse the DMA Sync code in the GPUISP. Move the code we need to the base class. Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- src/libcamera/software_isp/debayer.cpp | 13 +++++++++++++ src/libcamera/software_isp/debayer.h | 2 ++ src/libcamera/software_isp/debayer_cpu.cpp | 6 +----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index cf74b92b..847067aa 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -214,4 +214,17 @@ void Debayer::setParams(DebayerParams ¶ms) gammaLut_ = params.gammaLut; } +/** + * \fn void Debayer::dmaSyncBegin(DebayerParams ¶ms) + * \brief Common CPU/GPU Dma Sync Buffer begin + */ +void Debayer::dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output) +{ + for (const FrameBuffer::Plane &plane : input->planes()) + dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read); + + for (const FrameBuffer::Plane &plane : output->planes()) + dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write); +} + } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index c04c289d..98d88fb3 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -20,6 +20,7 @@ #include #include +#include "libcamera/internal/dma_buf_allocator.h" #include "libcamera/internal/global_configuration.h" #include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/software_isp/debayer_params.h" @@ -96,6 +97,7 @@ private: protected: void setParams(DebayerParams ¶ms); + void dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output); }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 6be5cdbd..8f1b4e53 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -22,7 +22,6 @@ #include #include "libcamera/internal/bayer_format.h" -#include "libcamera/internal/dma_buf_allocator.h" #include "libcamera/internal/framebuffer.h" #include "libcamera/internal/global_configuration.h" #include "libcamera/internal/mapped_framebuffer.h" @@ -752,11 +751,8 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output bench_.startFrame(); std::vector dmaSyncers; - for (const FrameBuffer::Plane &plane : input->planes()) - dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read); - for (const FrameBuffer::Plane &plane : output->planes()) - dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write); + dmaSyncBegin(dmaSyncers, input, output); setParams(params); From patchwork Wed Oct 15 01:22:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24658 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 7EB7BC3332 for ; Wed, 15 Oct 2025 01:23:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 265CA60628; Wed, 15 Oct 2025 03:23:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ejfU1W1M"; dkim-atps=neutral Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A733960623 for ; Wed, 15 Oct 2025 03:23:08 +0200 (CEST) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b3ee18913c0so965014666b.3 for ; Tue, 14 Oct 2025 18:23:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491388; x=1761096188; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=X8BVCiPsJ20OX+RnXwnsSBdZMAPl34rKU86maQCSeW8=; b=ejfU1W1M/9pERQ11XOjaGMik5kYIUJBzDewTrM4h1noTNJbS+1RuyeTCj1kSZcr/9z 29GVpImqM6iMeUnzRrtow/05xhmBm70WFXDT54hmUvRf1QzQAYbW02rKg/2J+XHuwe+k T4mBNy9voTnjqs9j6/Y1y9PglVIs4OfjPDAogjMZNuzZXTyF18AJG00a6R0RDpZ4uc0L 1YiYqRy/Q4BBh+h1DdDbsWEDYT+jw6gWxGPKsnaefYfdqXNzbTg+P76rkviCZ/PomcvQ qvDDOER272UHI26jqjDKOo1W4bMelJC9tYWnu+2Wp2fPWZVWqlKynynGQmunoMbk0Dk6 zQ5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491388; x=1761096188; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=X8BVCiPsJ20OX+RnXwnsSBdZMAPl34rKU86maQCSeW8=; b=B36fP/hYT8U2uzulLkfwPiZPFWGWDnQ0+p00BvkIoDUbntwURV7QpWWcNIoAbS604+ 9Lw/Ksk/iQKxA2lmig8F6WvCKHSijxMWhFJAPntTmPtbiVtz8aKIoqt+fbpLqE1NvPcp YUaOuXw0wwDih2KlEhjfDi/PnE2iKWudxLiQ29wQqGRJxsxvJ2ua4uVrSqCsZO5Aq4e1 cJD4H2G1Y3NW49sxzArfjB3YO2ZlnAJBgL8ZaI47c/lJluOwD6rkKmtLkfDU3JAyZ8Vd E9s9zTEpew6f2vRV9zPHCu4xNNQoZMlHChUTpUvgFbamKwhW+Hvn9OB8UQgyJjV6BYwO BgpQ== X-Gm-Message-State: AOJu0Yx+DJnzx0XhdJ+F+5W4lSKAq5EP/B0K6eyJ4dLfyokXxzgqQmUL sG670Oc4dpvnBXIpOymVJqtvJESCfNGanCATASuZ9vej+njBJvXxGEVkoVN5QPil/z3nhKJ0gct J2VlE X-Gm-Gg: ASbGnctMg95wQM58LiEA9S0py9F6rpV8Kb7AAa2PnXPZyaIWkWo0haeib1bwOaKWU7y j7GsGKpZmGvb33gztmfkEgw+6Moso+YOsLllZNztS/X5yI+5AnlKJJgWVBNCHc+ybDlnYxj0J6l PeNdEJ24txsSGfxHhILqcQhtTJXG2CKe2qnxp1ty4MliyHVCDutAKPDsEXg1LQvnG85oslB5dfA vYznpP2lNikDBJ2RDMwuVjK3FQ6GOspryWdhzBe16xRX6f1S3OiHjB0tG40j6BHw2Dii+RSl5W+ SFinhTPuv63CaNMUSAcXcX2EvtSKiTRhXYNaDDcRDMFhP7ifzShATOoDecsFxz8Nt3YpXdGDW2P N/+DgBVBtrzNMm5gdjrPbLU/Xy2l9p4+DkZJlBxwdbuUpFhU0vXURhyLn8rFMd5Ty+jGfPeYn27 2o70FUmt9+R3NIkt9YLw4mO7IGfHUECnLstQG4+eDI X-Google-Smtp-Source: AGHT+IFwl/PRrmj32I33SAQDCfAv33qd36LXUt5m8+CiEiErR8C1iWDyb7pV6Ix70JVs1HGjr3D2GA== X-Received: by 2002:a17:907:7f8a:b0:b40:448d:cdb0 with SMTP id a640c23a62f3a-b50aba9f873mr2792191566b.41.1760491387938; Tue, 14 Oct 2025 18:23:07 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:06 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie, Robert Mader Subject: [PATCH v3 13/39] libcamera: software_isp: Make output DMA sync contingent Date: Wed, 15 Oct 2025 02:22:25 +0100 Message-ID: <20251015012251.17508-14-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" The DMA sync output buffer from the GPU need only have its cache invalidated if the CPU is going to modify the buffer. Right now this is not required for gpuisp so only act on the output buffer if it is non-null. Suggested-by: Robert Mader Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal --- src/libcamera/software_isp/debayer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 847067aa..96737c45 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -223,8 +223,10 @@ void Debayer::dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *inpu for (const FrameBuffer::Plane &plane : input->planes()) dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read); - for (const FrameBuffer::Plane &plane : output->planes()) - dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write); + if (output) { + for (const FrameBuffer::Plane &plane : output->planes()) + dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write); + } } } /* namespace libcamera */ From patchwork Wed Oct 15 01:22:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24659 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 8BBD9C3264 for ; Wed, 15 Oct 2025 01:23:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 348D56063A; Wed, 15 Oct 2025 03:23:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="t6g+Z1Mw"; dkim-atps=neutral Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 25422605FF for ; Wed, 15 Oct 2025 03:23:10 +0200 (CEST) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-b3d5088259eso883467566b.1 for ; Tue, 14 Oct 2025 18:23:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491389; x=1761096189; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=v0b7JxJB6O3gPrxcbAeOh02oDu6uU929TeOiKkmwuWo=; b=t6g+Z1MwISnFX/SwiWOghL2LkVpu7B5WHwQoF63rzRngSOT88fgZazSwMexoX8Xe6s l/dMFy8nRCAubSl5i3nGpycVgPi/T+Mn89ZQZ6Y1ePYr7XRQE2Ltr+Gz+xqoLyI5uq3K NcYOxIEJfZKd+yPxNay7r4T0HkEFy1sTe/Y4+ocvFKPvMi91M1JQbKD4s5ibsEgD8b7/ Fe6/MM/TdqJUFFe172bM2LsTmXcXNYIeLfj8x9obNv1SGX6wwz77VkwzkKK2Yzm1a/an hYhGh/RrfI8QBFS2CrGeWqiFRW5fZN1xyLiWD5mkIlz4QnC+aBbVmIbgzjXwFMTMu3bP YPig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491389; x=1761096189; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v0b7JxJB6O3gPrxcbAeOh02oDu6uU929TeOiKkmwuWo=; b=C6H72zwultTv0Hazps6OwOBcrdwmEjRUfU4k0GAx/p5kr/IkHJFPiEnEKGNAa3+YxR I4uwQ743ZQ5xMaRRzAdNs6dstKwNTIfxzXwCpN+cosMh5Xyo+UAOQHTl46txtHC4ttm1 uuV7VRaQ6y/ns4EecBFHOV4rXCSGtldMJreMEoLj5Jrzuq3kfoh3I3V3FSLBYRkBteZT 7Dke2E0mV7J0buYOFznAfDLNOYj9u84FFUov+BRWjxmy0RfJUqmgXMyGrGRLD6Xlh2uR 1aON8Mql0VTv0QfyCQWF9vk+Kn8jsOZoiB+zSjfxzloAYJKByKpO7SpHWHrmwDZoQBDc 7mjA== X-Gm-Message-State: AOJu0YwksJn7NC7Fh0Py6ikN9xWtmyWZdL5wX0JfSKADzlwQh94Q3ZIq AcRsC92xh8p/JUUAAIiqIMMdyyWAKlqfj/IQgU1m0YivGHdj+qir6L0b2zZ9vgEfj5PKyO1bs4w 1/YI5 X-Gm-Gg: ASbGncuf2i/8jQAgrMTBFZHzs8SwsBrS8vg8L+PPfTZPcr+nsAiFvOfztowpn7+UhqJ Gz+Jy7qtyI1NI0UUKE7NQ2TDFSW0Zq9wgGRKeFCf8qNG1JvO7KWENMHY3ROZ7mbWcJPFZL1OiPv 2Iele5f18lCHL6FLg5tXabyd9YDktEjMpQwZcR+BgfHTt68JKAhXvbiFwiC6YkqsL+1sStwDjFd Y5WA4jrPKIWt259VEWOKsPznZtgQHAO8kOrhkprPcsgabdqEb/7CZ5O5muoZu3/1kSmQtAKh6fP 808B3pcxICrb4Tg/FhZJYcmHk8MpDyr8Uxk+k5vsiyH4qGzGQJ6YwozrjQ2K6k2OUjg9yIh23zi JbuO+6dDCxScABK3GI0HbA2aqVWluLcxCeOnLiJ+5fuSlZ4JIVkZO7MXOenyFMSDCG9APkPsVXD LCsfqg9j38tdxLsc5ve/BHwxwgbkp8FOV/iq302/yK X-Google-Smtp-Source: AGHT+IEtRU/iWYLtTdyCFbjTNZ0VDQupR+yAGpOi3k5WUtUlqiabZz6RBSIXnJ5KZdMnPFRLT1bf3w== X-Received: by 2002:a17:907:3d89:b0:b3e:f89e:9840 with SMTP id a640c23a62f3a-b50aa9a1e57mr2836400366b.20.1760491388895; Tue, 14 Oct 2025 18:23:08 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:08 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 14/39] libcamera: software_isp: Move isStandardBayerOrder to base class Date: Wed, 15 Oct 2025 02:22:26 +0100 Message-ID: <20251015012251.17508-15-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" isStandardBayerOrder is useful to both CPU and GPU debayer logic and reusable as-is for both. Move to shared location in base class. Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal --- src/libcamera/software_isp/debayer.cpp | 10 ++++++++++ src/libcamera/software_isp/debayer.h | 2 ++ src/libcamera/software_isp/debayer_cpu.cpp | 6 ------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 96737c45..db225ed6 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -229,4 +229,14 @@ void Debayer::dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *inpu } } +/** + * \fn void Debayer::isStandardBayerOrder(BayerFormat::Order order) + * \brief Common method to validate standard 2x2 Bayer pattern of 2 Green, 1 Blue, 1 Red pixels. + */ +bool Debayer::isStandardBayerOrder(BayerFormat::Order order) +{ + return order == BayerFormat::BGGR || order == BayerFormat::GBRG || + order == BayerFormat::GRBG || order == BayerFormat::RGGB; +} + } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index 98d88fb3..c5eb0d38 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -20,6 +20,7 @@ #include #include +#include "libcamera/internal/bayer_format.h" #include "libcamera/internal/dma_buf_allocator.h" #include "libcamera/internal/global_configuration.h" #include "libcamera/internal/software_isp/benchmark.h" @@ -98,6 +99,7 @@ private: protected: void setParams(DebayerParams ¶ms); void dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output); + bool isStandardBayerOrder(BayerFormat::Order order); }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 8f1b4e53..00738c56 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -288,12 +288,6 @@ void DebayerCpu::debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]) } } -static bool isStandardBayerOrder(BayerFormat::Order order) -{ - return order == BayerFormat::BGGR || order == BayerFormat::GBRG || - order == BayerFormat::GRBG || order == BayerFormat::RGGB; -} - /* * Setup the Debayer object according to the passed in parameters. * Return 0 on success, a negative errno value on failure From patchwork Wed Oct 15 01:22:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24660 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 008AAC3331 for ; Wed, 15 Oct 2025 01:23:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8141360641; Wed, 15 Oct 2025 03:23:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="yM7UjF9D"; dkim-atps=neutral Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D2F160617 for ; Wed, 15 Oct 2025 03:23:11 +0200 (CEST) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b3e9d633b78so100388166b.1 for ; Tue, 14 Oct 2025 18:23:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491390; x=1761096190; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=r1DkagOG3edPpf2lxaQBxOkTweGIjpitNTyvx3GYFSQ=; b=yM7UjF9DTD+RF0johEItrOgsYvah8Q6bWXA2Ud7ToD+FLqy6/aFUF1yBQhs8EcI+jN GJpA/rha4c5iw16teJpU0vNiX2Ac1WXc9u4/pwH2PmJBm8Pft3+hMBpkAp8Hb4tkZQxP IQ3oUYRb0s0IcctZOD69N+FAmtbv1F9vbtYL4VViH07uCw4EoOmH6Yc4Qe8yUkNjTIsV zdjkyZGiYWFUXSQrPn6gz348Y+x1B2oY28ugDF+YRK1kE8C14AOJtz+Mt1MarNLaJPeb Tme3CQIhE5O6IWkl9sQfGY7uOix8D6Z7B9jBHaRCgLPXCDpBfF0mgYWOVwPSk7JFZEkg +L6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491390; x=1761096190; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=r1DkagOG3edPpf2lxaQBxOkTweGIjpitNTyvx3GYFSQ=; b=CRd1urECmVUaECEcw+xcrYOlMuhkQQbShnw34ztaJ38WxE76cKktSLIruS3ynfif9k UyXhgopRpdvN35bsnU0iNTGDyD4JvOpEK5wqUuS+78eGKkVIUsVEMcajc8WT2G46Fz+9 QfPNNW/lp1H+/9vgjF9D5lckHD6/W7Vz/c/Sy+F/49oA5WuBDgFWBoduYaUwOcEGttt2 uqugm0Vp4Mxktrvpd67FZNWvHXzXk4LWOsOXO+O0NYLczEi7Zet4bDaBHs/4k/Chyx9J hjeRsfXYP++lB303zo5e+fLlogbRsin7sBsXuOWaM8HawrRDFHq9HyrKBToL67mK2Z9X 9gyg== X-Gm-Message-State: AOJu0YzDPz4mvtdTYKqJVtyrwqLnSQKXb2UcrP797/kex02loM/qCePs J/j9SNI3OHd0dA4baLxGH1PK7dO9/eFqSrh2LIfSAVFIDaYgQrLxha5OeWdYwVS8YqP5YcEhYlB s1ki+ X-Gm-Gg: ASbGnctl1uUSBQtyJ/HId+4ERgvaXZtxHoCXl/PZS+nXt/HwTYr1pa44M9T7/yq0fN0 HOmX1NQWmGp/OH/D+w0dIcBQaKGNWdNiqP2LNJLGmAm5MFbDykucjbRiXNDZXTCFGeaMnvMVU28 IOkD8zv9tEz9ut/lPFmSAa5FxrS/cQuP9lsKvNrzoQV8f3BJ6yQLtABXJ20hJVwK278N8p+Qj6N v0pWIN8+t5oDiyiKt+iVvcQqno/BJu9H9PIepKy8Fhk6/Sy7GzfZbGyngXcFKjoioq4506ZW0ju MQCObMZ5CFsesvN2VScEzXnzlolX2ivxZPWy+OLqaE/ley+kHXk1anWA1JGSRy8HFExjCk2fus1 QmjjzmRThOi/QNms9iGPO0yYMVAsFXwXE2A4WWWJJYXc40GWjabt6NX34sqUFXuSLnica7X9Izv fn/Ni5wV4kGH/Qgar9amI/WwMiMVrnV2UvP7/yd1e2 X-Google-Smtp-Source: AGHT+IEBppBTA4ym/A77919M0hmOYL6U1wW6yhW/HlNxg+WCs4hCTgHC/l7IGzUL320BcnjGykI6WA== X-Received: by 2002:a17:907:7213:b0:b38:49a6:583a with SMTP id a640c23a62f3a-b50bf2bcc2amr2702182766b.23.1760491390314; Tue, 14 Oct 2025 18:23:10 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:09 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie, Robert Mader Subject: [PATCH v3 15/39] libcamera: software_isp: Start the ISP thread in configure Date: Wed, 15 Oct 2025 02:22:27 +0100 Message-ID: <20251015012251.17508-16-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" EGL is not thread-safe and in fact associates invisible handles with the threadid of the calling context. As a result we need to make Deabyer::configure() and Debayer::process() in SoftISP execute on the same thread. When we call Debayer::configure() in the egl class this will setup and egl context for us which is associated with the calling thread context. Hence when Debayer::process(); runs it must run in the same thread as Debayer::configure() or the hidden Gegl context handles will not point to the same place. Move start thread into configure() as a first step towards this. Co-developed-by: Robert Mader Signed-off-by: Robert Mader Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/software_isp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 6f1f88fe..500858ab 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -264,6 +264,8 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg, if (ret < 0) return ret; + ispWorkerThread_.start(); + return debayer_->configure(inputCfg, outputCfgs, ccmEnabled_); } @@ -345,7 +347,6 @@ int SoftwareIsp::start() if (ret) return ret; - ispWorkerThread_.start(); return 0; } From patchwork Wed Oct 15 01:22:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24661 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 08A1CC3333 for ; Wed, 15 Oct 2025 01:23:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6FEE260651; Wed, 15 Oct 2025 03:23:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="anWPih9n"; dkim-atps=neutral Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 087F960620 for ; Wed, 15 Oct 2025 03:23:12 +0200 (CEST) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-b457d93c155so936404566b.1 for ; Tue, 14 Oct 2025 18:23:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491391; x=1761096191; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7OmT6mS4N4Yc2DUHOdjqndL86dhxexJ/+HXKOIxa6QI=; b=anWPih9nDanXcCV/kF446YmYWNne/i9FV324nTFuyXjRs67+Jl+nlcSJdK5LioqOiK N1qQcYyKToBT8fNvDMM0BHmqSEMihpEOZO3zR2FBzJLLvIQgZDUcsHk2BA+DC8jEuhlk 8zA8Bwsp174/HMTnv8l9mA5UEz0O3v+etQZxmY39sil+GlSL1CCyy6Qrc35J+gWF1AlC EYuuK5mco5+/T32iPu/hJgfwx54Nia5j5ekEsN7OZRKvr2e0BE7qitPVVfsRH2T/Ju/p XeogKZ8kMnxPGMBLmaoEcFH6yznGduSbhuSGMI7blSXPjjNAp5doYZq31vq3AQ9+Bh+2 EFsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491391; x=1761096191; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7OmT6mS4N4Yc2DUHOdjqndL86dhxexJ/+HXKOIxa6QI=; b=uVNhR3ztFTLnd1k1qqqYgzaWPPe+t6KH6wJi4Jazs7KWIzVVAiADGl+t7Poe8rZEgp L3xZ58TIj53iSOL5A5B6TYBi05jN9daywBhF0cGKtAsbtpvpBwyE9p9Lr3/DhcmVFf4I ipECPuIVjmL21b/xfgiTSypUlVtFTOdqtLjp3yoYZ879Ji2pfYhh95f1a/cIvcDk3fWf imkdcf8ZP3mousQoBgKXPJhadTcZmnoXJeZF+IqYWbS2TUJwdDVHX2m2Nabrv55NJUC3 AelBa2dvCEg0IfAVYgljPcldkBskCtTf7Y+d2Q+tUwFKZOc3xir3JiUdNRcMo+MRCdB2 /JiA== X-Gm-Message-State: AOJu0YwY9iIuJnDltbh9ZDr/NHMZfXad9m7agi3lJyx2BLGgRuiWcgJv XZRc4ccVWyhvOOBPtitUik8A6/hceA0uv/jIYzeoilEUmGaD5q7uXUDmRH33vQyy1PK+SawjR0y qXYyj X-Gm-Gg: ASbGncvkAZijf6Ruj0gjj3fM4qpRixiG6aSXTy0X2+8KcnYguhwYxjM6nTANgu+FEWz BcHBMef1z2QZwS4w9pcqlk2wLC1TTmDqZfLDXPxcYOnjgKiYC1sNc5b/QHr/0SoXO0YbmzevO/A krRJO6vlJ6SlsbLEUrGmDiJett+/hqyhctypnC4WodMr5MAzl28h4kqMiuM4UVxYM/pWJNlWTK1 SWGDawAd3MdJui+EdakauWICGixcPpswtLDtRx8aVGNZ1hjLg4yYcXorXYqrXkM3pBcnoxtDP2+ WE3IUyUjrj1gLKu1PDvDrpGlUCcVIc+0nn2v3C7RMARHDNSL1mJYEhtbVnm1AhZLBXjHAnQRnbL Rh1eq9kKRvT6oNsQLcjLDgSE1eT0LM2c6Ey1j5oLR9rp2+KcM9Oc/JP5s4AOktirxSzUfQYcjoJ xgFuz5oCoCuL3X8ZXMfoPVZZULF2o2mfz2kknKIwO4 X-Google-Smtp-Source: AGHT+IHweHJZPJ0VYMMh5jPx1WD09ivFRx8vrxC8VbNMMhM5YP0tgXmcPOp2/RRElqcVJt8wJ190Bg== X-Received: by 2002:a17:907:3e22:b0:b3e:b226:5bad with SMTP id a640c23a62f3a-b50a9a6d8a3mr2754453866b.8.1760491391273; Tue, 14 Oct 2025 18:23:11 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:10 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 16/39] libcamera: software_isp: Move configure to worker thread Date: Wed, 15 Oct 2025 02:22:28 +0100 Message-ID: <20251015012251.17508-17-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" EGL requires both configure() and process() to operate on the same thread. As preparation for that, move current CPU configure into the WorkerThread with a ConnectionTypeBlocking invocation of &DebayerCpu::configure. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/software_isp.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 500858ab..df72b1c3 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -266,7 +266,15 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg, ispWorkerThread_.start(); - return debayer_->configure(inputCfg, outputCfgs, ccmEnabled_); + ret = debayer_->invokeMethod(&Debayer::configure, + ConnectionTypeBlocking, inputCfg, + outputCfgs, ccmEnabled_); + if (ret) { + ispWorkerThread_.exit(); + ispWorkerThread_.wait(); + } + + return ret; } /** @@ -389,7 +397,7 @@ void SoftwareIsp::stop() void SoftwareIsp::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output) { ipa_->computeParams(frame); - debayer_->invokeMethod(&DebayerCpu::process, + debayer_->invokeMethod(&Debayer::process, ConnectionTypeQueued, frame, input, output, debayerParams_); } From patchwork Wed Oct 15 01:22:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24662 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 8883CBF415 for ; Wed, 15 Oct 2025 01:23:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 16BC56061B; Wed, 15 Oct 2025 03:23:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="FsBCF5en"; dkim-atps=neutral Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0116E60636 for ; Wed, 15 Oct 2025 03:23:12 +0200 (CEST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-b3e9d633b78so100390966b.1 for ; Tue, 14 Oct 2025 18:23:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491392; x=1761096192; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nzYcGC8P1W/pT0pkA1CSGdjHK8QskZtM5GZ9o2I7j1c=; b=FsBCF5enO7nUg8Ql6RuYGpVSJIIdeTPuxBp2gIMijhshX9iXHjPBwulkKsghBgHFAw 1zrKu5OmEUW3kpAcvW9bLzeRIqzfLnaa4SzM0V1og2kzoAU48taTCtfv6R1SNo3BD7Uw R5Vrlag6xUwLvo1di3Mv+v10xbsBSgGk3j2dCI+2KPuNHJVZPENKCKrjXRcJzn2SG05d P9hWQsZParNM+eUChW8g/a1lYNcsFltddcU73SoRssENMuutGgVmabHsouPUu+ePvQSD 1Pd86yOrjkGSXHMq9j0OQcV4WvTJavgvyXz9pGye1zCa69oYy1kfiI8F4N7HPrkEJgrA X/0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491392; x=1761096192; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nzYcGC8P1W/pT0pkA1CSGdjHK8QskZtM5GZ9o2I7j1c=; b=JHTeU/Ryp8RGOMt1EnXG52uuNvdTUwE0xPaG3KK4ncFHjvFr2WAhKm+E010W0WIPvS Cg7F09ZyfN06pl+cLlwnNSJsv55JEIGqoonRk37ijfVye8a6bM0Tq8Yf5zmZ36MYVQH+ aBF1hJzkDVzvEwXHdhD9qB1abYbhtE+0wYLSECqg7BNSISD0AJhEbkDX42MgkIXN63lH 4lSXuKA233HZaLZ/5R3w1X6+EwiKuhDWXEUAD2hudR+IgwXrZCMdyOHDRPg8EIIVn5MH CrQu4MoZ+v1JaIo2kfbYMd+tlmX8nRkfFIYuTBIBB1aVdytBqUc+g14UkmaLTG8zs6C7 mEQA== X-Gm-Message-State: AOJu0Yy5eQLbtvmXCx5dqY2hxEKRSgT5mGP0pZadriqFABrwmsAD9MWy VMC3K7PzdoCrF8sR2/hd4/ygjnTUV9BNeNYivAOzcSeB8qnwbLXjr5eYgCHjWJyy9Dzp6vdr8Vj VwwU3 X-Gm-Gg: ASbGnctZiWg9qjSK2nyAo1nfwxi+lp2/hdBjLOt0AFpip29V9w+fUFwPU+rff4XEn7R alSUFektMj70cTglQeO2rXqTu+mMXwYsPoQg8mRks2OZL6VYNCukTWl2sHcutN7kmoz36ciaMh+ sCmzRRJHFRLXzKK0ahWJFvMp+JG9oUejs3CP3gSgy6UkeRLBWQFT3c5eXdYcM9NUVxd6VMb6lEW eQL0uO56qeIvGh0i7+kYzDlp4pQwoWKSLq9GWrgg61T1ktos4a0IIc1iJqXBKKGl2i+DkMOH7nO e6fE98Q/NW8QFh6Sb0BDYHEZ318mdTiWeE/pTeijMzLywSigtz1XXWVBVzMrWxbBCOyMBv6aROs DOyVGKtR716xIZrbaK43A2qdHWDaSVZwyPIwspF7lrycncT/QfCB/44Bx92eHsc5g6en4i17Y+C 61cTGSEeOLfvKF0/l2YEiA0+RqrDi42Q== X-Google-Smtp-Source: AGHT+IE4p+t9O7MfxjJYoQNAX2ZG8+MWgUqY/6x7pjcrghcyNrwk19gnPvqzqtxiBkGvIck9P9NF4w== X-Received: by 2002:a17:907:7ea4:b0:b07:87f1:fc42 with SMTP id a640c23a62f3a-b50bedbed8bmr3355808466b.16.1760491392172; Tue, 14 Oct 2025 18:23:12 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:11 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 17/39] libcamera: software_isp: debayer: Make the debayer_ object of type class Debayer not DebayerCpu Date: Wed, 15 Oct 2025 02:22:29 +0100 Message-ID: <20251015012251.17508-18-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Make the type of object Debayer not DebayerCpu thus allowing us to assign the object to either DebayerCpu or DebayerEGL. Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal --- include/libcamera/internal/software_isp/software_isp.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index 78624659..ad89c9b3 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -37,7 +37,7 @@ namespace libcamera { -class DebayerCpu; +class Debayer; class FrameBuffer; class PixelFormat; class Stream; @@ -94,8 +94,7 @@ private: void statsReady(uint32_t frame, uint32_t bufferId); void inputReady(FrameBuffer *input); void outputReady(FrameBuffer *output); - - std::unique_ptr debayer_; + std::unique_ptr debayer_; Thread ispWorkerThread_; SharedMemObject sharedParams_; DebayerParams debayerParams_; From patchwork Wed Oct 15 01:22:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24663 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 0300DC3332 for ; Wed, 15 Oct 2025 01:23:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 611F06064E; Wed, 15 Oct 2025 03:23:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="W66EphNg"; dkim-atps=neutral Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DAFA060637 for ; Wed, 15 Oct 2025 03:23:13 +0200 (CEST) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-b3c2c748bc8so861289266b.2 for ; Tue, 14 Oct 2025 18:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491393; x=1761096193; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7VylC0Pj9hF3uzfbXgbdY4KAaZJ9ni0tnMpPWJG5Yjo=; b=W66EphNglBsBYWlUUwyyfxwKxaz4XPHruLP2HQKtTjuUfN7YUekFtGp5hopADOyPqR CfyS4phveMOINouk9rDBGYt0aUxY1Evw1gPGbVh/nNsSu99NdOC+sN0r9o+j5KlFUPqH LIcQJbp4BFfNGnUoDgPEicj/BCIVtlsF9bMDOSI7pHQPVEb7NjFCw/KsaRLhuRRF3K0p Xy7981HIDjAtZjH7aHY5mqSK4PM3/tZ/zd/AP1jCoGyAZHM+GSXOarE0bH5xyNXdfqGQ wIcdw0J/dv3cYewSvnAttd+BJH4thvtdPqcwIGuFPeEPelBzhu3VmzedLwXC3eYhPbsn aSTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491393; x=1761096193; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7VylC0Pj9hF3uzfbXgbdY4KAaZJ9ni0tnMpPWJG5Yjo=; b=wbGHm+BkuTB8VATxnvv8aFeeZx3MZaYtYa7haf4FU5vNRQyijZ2vkiYZzdEfMqIJ1J qEkkgrRUjKWN8nQuYrz7KZ4oaSgMztJhjNDIdjIlGrhjC57emfS3GCC2Jgkm2vzLqPA4 6NXHPfjnBEsw2G7i5X020aaPovBvvTmq5akK3zjl5Hz6EnbGHm/PGffxDtr4v2N6LQDs X7jHNUR+gyldNo7JDF9/BsdJE3f0iugDH2VY1hIZ7gIXWCjI5AozEFlARcEXLT4cXQeU Dn2Q7otxuwHt3/TF+kc8tGWUOD8412Ebr0UNFYKjZg/zK3DUuZEMGqXJsXtmqIyOJvvP NCgw== X-Gm-Message-State: AOJu0YyqvGcbgZrhwGNKAU/p/KpyBsFMVPEIVJcNtItjqgWyrHPVZQDN TzD87nNdl1827+hlW9mqm60dnAj2CjzznqrP9y2mQ2NjVqaPDyjW56YtfSIdq/oLDv17C+rjN+2 WyAnT X-Gm-Gg: ASbGnctzEgqe+11yj+oNsHX2cpoRaVijJZwkuJwGgoccHw95TM4DuVEzqFWiP8Gtz2S GgzZ3b0GMUyleHLIBP1yBXx8JC8MukJBpo8gRtfaQocqdelv4+C74ioe8Nb39dCF6/O14KwTMc7 m5hmNMmqvdMqQcPBFZ4Dd4mEZDi2oMeCT9G5PMlPovtiYiULxJGuTMf/xZEHBJqvebfYBb6IZSh xfiRlBnFR2L1n2jTRWI+g/yekaCDTXHNetzsh4HLeZvF3dEy+Eg3+BOJV539XiTka0LXQD2bmUo 8MieP1pP3IBAVGFVv00rocRBJ9Fpt35VIJ2OjzgVCUvQBUn9TtFRxUX8LxqiSApQ2mnzoPCsKnh QXB8Xxv5B8xmW3wARkvT19QzouOgagTm425A/XkPFFqCL1hUiG+dDVnE6NHNalPPeF/8ftx4ohh 399Am4SgWtnV/rGQCxV4R5iBjt4mykwx3ofEbO7K// X-Google-Smtp-Source: AGHT+IEwps0RudDqvNIThqZ9YZtlZ91bUk5gs1m0+6jVWHr8sQFeX7o20/5mWBH/sorSI8YPHaVMdQ== X-Received: by 2002:a17:907:d1d:b0:b50:34b6:621e with SMTP id a640c23a62f3a-b50a70cb821mr2668823066b.0.1760491393121; Tue, 14 Oct 2025 18:23:13 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:12 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 18/39] libcamera: software_isp: debayer: Extend DebayerParams struct to hold a copy of per-frame CCM values Date: Wed, 15 Oct 2025 02:22:30 +0100 Message-ID: <20251015012251.17508-19-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add an element to the DebayerParams structure to capture the calculated CCM. This allows us to pass the CCM into the eGL Debayer shader later on. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/software_isp/debayer_params.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h index 217cd5d9..56803195 100644 --- a/include/libcamera/internal/software_isp/debayer_params.h +++ b/include/libcamera/internal/software_isp/debayer_params.h @@ -13,6 +13,8 @@ #include #include +#include "libcamera/internal/matrix.h" + namespace libcamera { struct DebayerParams { @@ -49,6 +51,11 @@ struct DebayerParams { CcmLookupTable greenCcm; CcmLookupTable blueCcm; LookupTable gammaLut; + + /* + * Per frame CCM values as calcualted by the IPA + */ + Matrix ccm; }; } /* namespace libcamera */ From patchwork Wed Oct 15 01:22:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24664 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 8DE26C3264 for ; Wed, 15 Oct 2025 01:23:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F3F4960660; Wed, 15 Oct 2025 03:23:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rLMlGpxF"; dkim-atps=neutral Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A9D0260638 for ; Wed, 15 Oct 2025 03:23:14 +0200 (CEST) Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-634cef434beso712917a12.1 for ; Tue, 14 Oct 2025 18:23:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491394; x=1761096194; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TiqkPZNwtW3nPq5BU9gpzzFfSJ7E+z5La9IMK2toPeI=; b=rLMlGpxFAfjWTKulE+PK9RE/HoQjxdmKC3G8LDSk4MB2U7PS69BrLbXlozER/i84og 4UeotBlVljRwxF9qB3yWHklKB/9bLhA89crCR68wpXUvhLULuAdW2ECmpmuTbX6YiTy7 /npE5mH3jENTAYNYJgqmHgobyEVPQUR1ll7/p+vwW49d+VTtLjHp52NUi/zfAQkVHDJF 31wHEC94dNt9r9q0cFs2//4bHdX4qtJA26vrOAUNmN3jvUl3fKL6l774ZWoCJklNXSrf i3lGHybxhUdgQooY6QBR8Azz9SGHe4tSdZTI5L/IdGkqOJpH+nvb1yFNK2i+VhmOh2Rf XYAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491394; x=1761096194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TiqkPZNwtW3nPq5BU9gpzzFfSJ7E+z5La9IMK2toPeI=; b=ok8gN/X4AJ6mrT0koErxjZF9hN939yi4gP+6xzcdOoU8porQ3xPYWWeSrqLHGEgYcO UCdTOUV3AvFoyTX07wBMRNyf5hbVGF71hH1I9PsEYfOzgL9UJ3Wcw7EzSrAtqdNhAEtv 9+aKEYp0OVOqpWT/rKATFIbnur0p8+eIvYQ/QZMdOrnIntaqB9hDR2b/jnNU9fVm+fmZ VonLusDrDEpLTa5StQ0r1ajZRXLmZQqX+lc0tKqvp3ADLx3Wn6KMlNN5fvofb8m0J8ww oh6dn3LG0fxWGWYB9xCivxP9yf4EJYHzCU1BKznYtHz9o5VRzp2ewuaLp2io1qGXYByp DBoA== X-Gm-Message-State: AOJu0YwVP3utzhMN1YNEW3wxcNaeAr/Es7wkGn+yZoUqVtcr4NIM149Y i4aVS7a+N2OQKTevb8hIb/XM/9beagPRxv5X+w0bVgeKK6IvQsTplNSBkF33nUM4QqJpckplMQO C5HRB X-Gm-Gg: ASbGncvA2f79WEq7rQwNxTR2X76uBTAfEQhul8LyyBX5MtduRM0M8s1vW5HG0qJeWrL jnrMDB1o37VvRcq3fT4hT9OTTXU6fS8xBAtf1qfkUq1lKIlegqgN2vipiwsikvBKZvz8PTK5NTK qn9i95eJ92sFSgsmJt7QVBC2nLZmuFxJo5Y3W4I0cfcussIPfcfvsWffwqsCqBNn7f4vf8XXcag QmSc0wQzu3x6Eo71NU7hRQOPE+g1bOe+ALd/pxOs1AjLhElk3v6nlndC8R0hfeGxDs5imaf9128 kW3/8DUbw7vKdeBELi2SytudFeKzjfvhfTLHa66heV7TVYtVuoyxszzolkMwswRm4qVmmIi7EEC 9ZpxFQnadj3gAPsDzUCWegXHlx0Ggg9TrZ9CKb43oN6+HqtYIMVTJMNg8lv7E0xh2YupEseKvqQ g+rET6+5KKkub4sETzxZUSjOib17Iblg== X-Google-Smtp-Source: AGHT+IFVSDw+oBIcCFKM5BG4XeXSTU0o6+tbzxRUiIopudKYzndp/87g4pCoJXM5Y+p69p0WXEBg4g== X-Received: by 2002:a17:906:36d5:b0:b4f:644c:8873 with SMTP id a640c23a62f3a-b4f644caaabmr2820138666b.2.1760491393962; Tue, 14 Oct 2025 18:23:13 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:13 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 19/39] libcamera: software_isp: debayer: Extend DebayerParams to hold a copy of per-frame AWB values Date: Wed, 15 Oct 2025 02:22:31 +0100 Message-ID: <20251015012251.17508-20-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a vector to allow the AWB gains calculated in the IPA to be fed back into the Debayer shaders. Signed-off-by: Bryan O'Donoghue Reviewed-by: Milan Zamazal --- include/libcamera/internal/software_isp/debayer_params.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h index 56803195..9d0a852d 100644 --- a/include/libcamera/internal/software_isp/debayer_params.h +++ b/include/libcamera/internal/software_isp/debayer_params.h @@ -14,6 +14,7 @@ #include #include "libcamera/internal/matrix.h" +#include "libcamera/internal/vector.h" namespace libcamera { @@ -56,6 +57,11 @@ struct DebayerParams { * Per frame CCM values as calcualted by the IPA */ Matrix ccm; + + /* + * Per frame awb gains calculated by the IPA + */ + RGB gains; }; } /* namespace libcamera */ From patchwork Wed Oct 15 01:22:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24665 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 4780EC3331 for ; Wed, 15 Oct 2025 01:23:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B853E6064F; Wed, 15 Oct 2025 03:23:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="WQvXGJwR"; dkim-atps=neutral Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 833016062E for ; Wed, 15 Oct 2025 03:23:15 +0200 (CEST) Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-b457d93c155so936408466b.1 for ; Tue, 14 Oct 2025 18:23:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491395; x=1761096195; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EtuzlS89J7v9+K50cAFFyOxzlYC9+JcdH7asTL6ajb4=; b=WQvXGJwRsfhV1/4cCJRadopsnd1Y3OLY+tKzKmL9VmMHVo6eyd911IFFFwgaE2S/9P n+jXlt9OQAfOhxn9KG9LrbW1T6HcGWn2l6ixYx57MFpngo5ulnn3ilaVHUZEPXfoaMCX ukAM7P8DrpJWbb1CINZdypygqoIyQSsHf+6bQTzXZ2D6QlKDnXHq4dTaiT1Mi6IkFwrw oCK2ddFUf//EoZw8bSXt8Lp2KFy3T6JBVCXjssyzjDEmrFXNC6wYyOdVt0rUzhvkm/vV S2MOFbjq9KQGFfJP2/MFYtSvlsIGNS0twIKL9FVPneCpiUkaVXhpvcpDo0EX2C4dkcw4 qdgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491395; x=1761096195; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EtuzlS89J7v9+K50cAFFyOxzlYC9+JcdH7asTL6ajb4=; b=LxeYpIyHI++gzE2aQMhF5R0NO8ek3hHiWoHxBDcewHHF+E7yMIFlE69HskOEISVBFO w3JN7NvDAIE+TtasYq17sNuaMIsO1QnwJM92PjrAVPF4MzBByzQRxy9fYr8l6pXD/h/S 3j/xufqhmxFoApmX765sNd86cmPjj0YVZgVy2TofJLUuAIbo0l0Q2+kqH15xHLo9Z3JZ 8hG4Y10dJ/TD7VIFWOaFrMyft02QS32Lnw23gkb3BxHBJNFrE2pIzqmxYmVw7brtb8bD C2i55HsmpVg7MvwHnDe71ctJhkIU8vtWR+itAd3EIq0Ah6tlc0fdWGrQzJhI6nyGYAYG CyQQ== X-Gm-Message-State: AOJu0Yx+eWFhWNxqEMxZysoDGSnTQY6PX6L1yovAVidRTTFLRHE16HW3 g+IfiXW83aFfCuID8KGtajtB6o7KkPUCarTK4tEQeWIhtF9W9u+1LtjH9yUFApSOZCKUe8ApvbH xy7Np X-Gm-Gg: ASbGncsk06wxgCaym9OaWFNU+x1q4FRqJINFINztCgJtKB3gijSi9f/TJMQZzKmuFhW aulzzqhTCdJHGDNbTCIemiEa0wIzItBenmiBL36TgcPaUnysGplHYrwyM22HalBZawRf78z3zDT fQpCI1WHQa19vD/nhI5XMu7kXtRxiWylMHrn1ASSb5GBQsVa7PzUS7ZAZVEJjB/nk+Eo3ibXjMa cBbXRNDEkmTurogvhHiP4UAKsgh/7QWfkgh93/ZTRAtU7seSAFj1Dq0l4EqoS32jAb9mnocSxId nf0nlAL5UpyGL3K+9lkQifIKAQf5tAEE6lN1RUKI0onkjH2SbANtFIDB5QasUmu0M8kvY9Ou2Oy mKneSbxxp0lu3Rij3Nt3KKDeA1Gm5Sy8Wwgge5NoW2+1U+UZ4SkxN9c9rPRGZ2zkdbm1/rUzxO5 iwiq9mMjoe58QJd/XCjR5O13guma8FZw7TmUebwj0g X-Google-Smtp-Source: AGHT+IG19uvMl078D5vmFKMN1GoZg3YjClRb2WlJ0RXqQNF2J9Up2/s5Vj/PEdBQXpX+Ta9Vv0wdTg== X-Received: by 2002:a17:907:2d26:b0:b32:8943:786f with SMTP id a640c23a62f3a-b50ac4d6253mr2854908866b.58.1760491394864; Tue, 14 Oct 2025 18:23:14 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:14 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 20/39] libcamera: software_isp: awb Populate AWB gains to Debayer params structure Date: Wed, 15 Oct 2025 02:22:32 +0100 Message-ID: <20251015012251.17508-21-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Populate the white-balance gains table in awb::prepare(). A copy is made of the gains in the DebayerParams structure. Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal --- src/ipa/simple/algorithms/awb.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ipa/simple/algorithms/awb.cpp b/src/ipa/simple/algorithms/awb.cpp index cf78e980..3c4e5d09 100644 --- a/src/ipa/simple/algorithms/awb.cpp +++ b/src/ipa/simple/algorithms/awb.cpp @@ -38,12 +38,14 @@ int Awb::configure(IPAContext &context, void Awb::prepare(IPAContext &context, [[maybe_unused]] const uint32_t frame, IPAFrameContext &frameContext, - [[maybe_unused]] DebayerParams *params) + DebayerParams *params) { auto &gains = context.activeState.awb.gains; /* Just report, the gains are applied in LUT algorithm. */ frameContext.gains.red = gains.r(); frameContext.gains.blue = gains.b(); + /* Latch the AWB gains so GPUISP can consume them. */ + params->gains = gains; } void Awb::process(IPAContext &context, From patchwork Wed Oct 15 01:22:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24666 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 41C55C3333 for ; Wed, 15 Oct 2025 01:23:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DB4D360650; Wed, 15 Oct 2025 03:23:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="MVkb1HL1"; dkim-atps=neutral Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 73CE160631 for ; Wed, 15 Oct 2025 03:23:16 +0200 (CEST) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b48d8deafaeso1242407466b.1 for ; Tue, 14 Oct 2025 18:23:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491396; x=1761096196; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6Peo5/k8P8OiLfg/4ofwrT2kHhOPQ2yyIlXqRLA27yY=; b=MVkb1HL1Y7byLthH0cCT23XHze4vqmlQZ4os2zQyI3mb/RLrTZ/RnqsItE4BNyWEmc 10nPzxqiTZGlwphDFf8TuAIEHej6EL9leohGOkZ1W5Hh+fYaRhM3iYDFn/sQ25PfG4WE EEzBfFt7jUkUC7ZtGBdY+Hol/2xE72wnQr2h8ZRZu/hpMww+XrKDRHzjhqM8IQD7wkcE L9Mk+PHTLLp9RG91BjbDAqME41kRCEXpeRmgCM/H5hL/fsUoVdk+7G+BMwh5SBOO74e0 ppJx9vzS/L8v8rMZy4errolAO2Vd5ICbf60zjBlYTGjNi+tRApoEkMznTXno4rTSUv+S Dotw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491396; x=1761096196; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6Peo5/k8P8OiLfg/4ofwrT2kHhOPQ2yyIlXqRLA27yY=; b=ILsb2RF9XE1E2mcP7JQM0Z0dRzaqu5ppILtna3uw2kp/ZmHJLZ/pXudZVZTmr+rlXf PLXT6LDrGL1MA52axkDXtp7HQtYwhTxQ4iiQ/ebx53Hoefc7YbHWa5k9o0+VKKKJnERk suwElseND4A6HdwBvj28bVH6KQgl/WxV6b4O7iJmAwo9sP+x243gC8QYvMKnpJjt1WLq 55K1ES8tThmmKTMEf5logVyUS1WosNXtCQVoj+iVkMm/RJXLi61gp0JJr0CyOZH/F9qC xM43IBVoZBBobhnLidBranhuaLblTFRrj8uKpyLIucgYE0yGEvludbbTcfaASFlDoBZZ jDJg== X-Gm-Message-State: AOJu0Yyds4aPhWY62Jo7Cty2Hw/3Pfy4zo0Sexw+w2reWo+Vx84nc4sL xLbfGq2MDeuFGcbu69fV3grz2RZljM3wIeAMhpHw8HownwZAF+hC9/WucS13w1BKfkZDZbvjSN/ pFy4d X-Gm-Gg: ASbGnct8OCmP+jsj2ecixddGaYC+F6XgrqCXQ0YNXP9r9KZDV1R3afqWNMxvmkXcXgS EALXUJ2npzAVU/MuqObzUQtIyx0+nGq+06nSy1FY+87Cr0Tj+mwnVwFVy18GVpAdbODYpTDAOiG 3iprA9t0bO+WWa3n6PByHJmM9HEmB1xg87Ubkz7LwaVJfGhm1ZEMGDyn3FiNQuCVQW0VqhB+Dv6 3HtSBBn0w11jXDQ9G1y89OdqJzD1AB+nt2hH85pajTTTiiOYZOiTO3CA5KPEvT6SJV0LI0EA/aS x7bwDAeI3YuHHQKTubk6ryxmGPINb8TlLeyoPuf1bfG8fnZJayleeB7rXDVPeoagZ2vS7TcG+GP bvGJ+iNIW3jGj3NRCDlkB0y1Imiw2r2NEO67iv4fMINMBhvJcjq6ricxH9nlGpoiSYUzG3PAY/u 9E1g54EM75Nyo8XEbcYGc4md78jpEmsA== X-Google-Smtp-Source: AGHT+IFeQd6HKRU1a49yLU6jNq4p8+hRum+XXgRWl85j5r5nBNhZSm0J0G9C7/GFNC/tKf0odw6O4A== X-Received: by 2002:a17:907:94c8:b0:b47:de64:df1b with SMTP id a640c23a62f3a-b50abfd6d92mr2822960266b.39.1760491395799; Tue, 14 Oct 2025 18:23:15 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:15 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 21/39] libcamera: software_isp: ccm: Populate CCM table to Debayer params structure Date: Wed, 15 Oct 2025 02:22:33 +0100 Message-ID: <20251015012251.17508-22-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Populate the DebayerParams CCM table during ccm::prepare(). A copy is made of the CCM into the DebayerParams structure. Signed-off-by: Bryan O'Donoghue Reviewed-by: Milan Zamazal --- src/ipa/simple/algorithms/ccm.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ipa/simple/algorithms/ccm.cpp b/src/ipa/simple/algorithms/ccm.cpp index 0a98406c..cb023878 100644 --- a/src/ipa/simple/algorithms/ccm.cpp +++ b/src/ipa/simple/algorithms/ccm.cpp @@ -14,6 +14,7 @@ #include #include "libcamera/internal/matrix.h" +#include "libcamera/internal/software_isp/debayer_params.h" namespace { @@ -84,7 +85,7 @@ void Ccm::applySaturation(Matrix &ccm, float saturation) } void Ccm::prepare(IPAContext &context, const uint32_t frame, - IPAFrameContext &frameContext, [[maybe_unused]] DebayerParams *params) + IPAFrameContext &frameContext, DebayerParams *params) { auto &saturation = context.activeState.knobs.saturation; @@ -108,6 +109,7 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame, context.activeState.ccm.ccm = ccm; frameContext.ccm.ccm = ccm; frameContext.saturation = saturation; + params->ccm = ccm; context.activeState.ccm.changed = true; } From patchwork Wed Oct 15 01:22:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24667 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 78A35C3334 for ; Wed, 15 Oct 2025 01:23:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E314560654; Wed, 15 Oct 2025 03:23:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="eBekZxVF"; dkim-atps=neutral Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A11C060626 for ; Wed, 15 Oct 2025 03:23:17 +0200 (CEST) Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-63b9da57cecso5187733a12.0 for ; Tue, 14 Oct 2025 18:23:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491397; x=1761096197; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TcjrI2pwXI63DofETtDiLdp+t1mdKMGi9/omHCjy1Os=; b=eBekZxVF510LuS8z4/4PVRserTpqdxmUlBeVXs6u7xAjhFkeqDic+6pJXLb0TQ2zKT IE9o0cV0BlmhBJ3HhUIBsB+yIAutUISgHuqjVnUdmECYw2krgfKhTScYtvHiosr54Wdi ZgYVeB4VSLyO8yiHaDSJbYTuDCJFL4v+wLrJXJ5iQhA608tntRTW0SInIRBIP3tneH61 9yCQQQ+Mh0ZSW2tXdTtLZi/02hD/QglPkOfcMpSugmC2Lb2qPfcXi6YgWf0EsEi52yp9 c3w3MRWXCRPegSQhjwgxb2cR37vSJ67mvnJBedjBhU+yCU/DFXyuXzTfkiRnXWKRjUQS IyqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491397; x=1761096197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TcjrI2pwXI63DofETtDiLdp+t1mdKMGi9/omHCjy1Os=; b=dhrxFfWYG8BrsoSh/wDIBZcYRGW1/NQqIxLowkm20yF30C25KofKOlTE0qWWSg0xwo bT/5tu3q5vF+dLwED9L9KaX93tpA9pJPForJvKJ12jt/QNMbzSbco8q+KxsSHI1y9sAV TnYhAxkgRQm69DzI5pwjkjxfOoTX8YLR40ubjesYUQamsKs6qF4Ev7CgAjFkOZeXj/Iv VfXwJnwGJ4VxeRmFQj6hWMgLe4s/WxbCYerXfCKuT7F49zdHBp5bWVRC9ZDihtA4pkZu ndGVi/12zuFaiZOizKCbH07Pj9qa1bHZuaGzSPu7XxR/C3t7fClbLZy9t+ioh59MvUaU X/zg== X-Gm-Message-State: AOJu0YxAUkdwmDlBL666QEIBJ77t/jSw73sSmra+2mvfMF/s2mOTvLRh WaLs7lVDJ7nZjQooOPJavovuny4PzUvfqH2az+hiJhREwbKz6PnFfHYwegNWh5HbpbYhGfHzH0x RpSFM X-Gm-Gg: ASbGncustIXdmZNX8zpFO855ZDObj4YGQrvX7mDy8hZ/UZaXz2sCwFW7n6zgUkE3qYw e0CJxxkdvlhahQjifK3jSqXFCgv8jMU3KORZjv5h3mzMFBtjot0lIeIZ4ki+Yiua+1SCv/FEGBi KpVoPa+FZqa6aN76pFW6RulV42jwq/E24jl+iPiWhgWQ3KVDqQKppMWCU+gdkSh0Kwl2Ps2xEyK 1qJfaxaAu3NXMO9tATrwxK1s6XwMXiw5vqPHMC/Ffj9Q2iHshjOqeYeu4NbXxpwUqs3Q7Gm6hoa ch3FjfJa9mHI78FgGEXTL7bXvboCbHsomHO7Y36IboUYNxfVTym+2K4qcl0nMBRbRgH9/NLxd+O r0SK7mMIBvmmf0USHSiw+NDt1g53yDPHJhYLTam8QvkUlMWsNkX2foRg/yOa68EMZ1TdPXZbD9C OFqyasgpiKRqKTcUZidz8m0727aHaOag== X-Google-Smtp-Source: AGHT+IEJioIdjnrx0V+L342PmGSB6hPcUzAql28Sl5XMO2Le0FyjbgD7NcMhc0qd6fitrz8IKmp1lQ== X-Received: by 2002:a17:907:26c5:b0:b3b:f19:ac7c with SMTP id a640c23a62f3a-b50aba9e59bmr2630102466b.36.1760491396758; Tue, 14 Oct 2025 18:23:16 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:16 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 22/39] libcamera: software_isp: debayer: Introduce a stop() callback to the debayer object Date: Wed, 15 Oct 2025 02:22:34 +0100 Message-ID: <20251015012251.17508-23-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" The eGL class wants to be able to teardown its sync_ data member properly but, doing so in the destructor means we can't make the eGL context current and thus can't tear down the sync primitive properly. Introduce a stop() method to the debayer class which triggers from the softisp's stop method, allowing a controlled and appropriate tear-down of debayer-egl and egl class related data well before the destructors get invoked. Signed-off-by: Bryan O'Donoghue Reviewed-by: Milan Zamazal --- src/libcamera/software_isp/debayer.h | 1 + src/libcamera/software_isp/debayer_cpu.h | 1 + src/libcamera/software_isp/software_isp.cpp | 3 +++ 3 files changed, 5 insertions(+) diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index c5eb0d38..8fa281c7 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -48,6 +48,7 @@ public: strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0; virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0; + virtual void stop() = 0; virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0; diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index ff72eaba..3cc07028 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -38,6 +38,7 @@ public: std::tuple strideAndFrameSize(const PixelFormat &outputFormat, const Size &size); void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params); + void stop() {} SizeRange sizes(PixelFormat inputFormat, const Size &inputSize); /** diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index df72b1c3..1f984a52 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -366,6 +366,9 @@ int SoftwareIsp::start() */ void SoftwareIsp::stop() { + debayer_->invokeMethod(&Debayer::stop, + ConnectionTypeQueued); + ispWorkerThread_.exit(); ispWorkerThread_.wait(); From patchwork Wed Oct 15 01:22:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24668 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 F4227BF415 for ; Wed, 15 Oct 2025 01:23:32 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8B6CB60666; Wed, 15 Oct 2025 03:23:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="vSUbjGyJ"; dkim-atps=neutral Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 864D06063E for ; Wed, 15 Oct 2025 03:23:18 +0200 (CEST) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-b50206773adso82483366b.0 for ; Tue, 14 Oct 2025 18:23:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491398; x=1761096198; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Aqq6LHOCkGfG64+N5wgUWRxmVTPdl1G4BX/+cVigltc=; b=vSUbjGyJbkhryZ0WCw+piL228EraWQCS++rEew8fzJR1DoziQvieyCZE2T7bI4Qm1g hd8DPjeKSpheiJwlvmHAZ3J0bhIOwTmWcnN/YVV7FhOsTdETaCUrudfhCNkOz+3budqa iflFX5P/Gd6MtqqQhAzhoaIDPFRGM0OWVoXWMKvHEN0ylh2dYmxjh8hzMXcB7ILnYYgR NZsJuGJ22JYYdbZ3/Mg1Zj0N/IPgPwOozNNGYLv6j4OFs2rxKhmdz30MX5PRyjfu6HIQ 4JtsYlDKBqRfRH3nkUm1YI4PfXPG8UUFMxy491NcbuufT6j7TgXDdT583htc/6Wm/IKl IaKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491398; x=1761096198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Aqq6LHOCkGfG64+N5wgUWRxmVTPdl1G4BX/+cVigltc=; b=ZFxVDnENm7qfXgEymKfJJpDjcVpkEQNYYCjqgPPs7gr52H8s/x3iDLBuCkydBRXsuO pYwoye9+BSAcOLAowMykG5VTClloT9ikRGM+nc5T/ihJA7sKork06HG8pS8yCO7fBX8e frpwcE4fwZyR6Z8nYO2FpNmes6vc8Bn+O7+wcQ+PCYgVGiIhS9T4SMDcG3RfpTwCiSb8 wtMYPErlDDGruFithpdl9Vwhjal6RUD/TDLcvCyTMvuN519ZfrSgdkNf4rNiBREzJYop 7cjB7IafaChw9YsV7BzB0oSbk/VeN+LQe5AvwiashE9MzZzaw3wXIfuD7XdDgPeMx0t3 vKOA== X-Gm-Message-State: AOJu0YzNnTigWTxmoI6fyTFHe5gsyq2MJaj8iJOx32icNcyzCVhdaQjz VAKv+7fibZsulYYuyhbm4aS7zXxj4Sg1UBqQwOeI6rl6WU/Sk4eY4fCscxt/D2qQ6b0cqk4/HaA hHuqJ X-Gm-Gg: ASbGncuqERf6/d+oMMUKyzDWf/LH6dK/TPgM7d3q9BSkoBxpQNWa4wlHAUZVyNXaRAG vuhIk5/n8Vjx03RWAT15EyFsM8hMVd7tWMrLI0wmqbzto7jL6wOvLaTkfWxUV4J2ec1ZatZA8v4 sfN0N9SAK3bn+DPr7KdAFo7J8vuYV2SUWDSLxdcfTr2jbSXUNcKD1c1nBCqORVMSURWrI9VDGzh SW/TWOsOAmqxxuKKVCiz6yZGI1C6vC8St12X6ZFA0mQNDHudzxKYJ5I3gW6ydzsQ1e3TrIGURQw eX+XTePbCPGlhZcPhnYs2all452/srXjEJTF7lVU3wdxdLkcC61LjuBdAQ6Trsjv3RUu7GsX394 WtzeyxTgV1lIVh7FBITdDTstPZF1EEQ0tBHJBVqor7/3MWTUf7So7s8lnkNQC3lqYgd1r8h4yg8 j6oFikkzivTvLycvyEwzzurOKH8s3IUg== X-Google-Smtp-Source: AGHT+IHNGutLlvB9MNHFVfGkXNU0mWi/wv+OZKFFk7gQ8BjSoLWpexbzVSbX4GDrbdDO3e6Y275pEw== X-Received: by 2002:a17:907:c717:b0:b4c:629b:aa67 with SMTP id a640c23a62f3a-b4f43730a1dmr3177790166b.32.1760491397733; Tue, 14 Oct 2025 18:23:17 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:17 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 23/39] libcamera: software_isp: lut: Make gain corrected CCM in lut.cpp available in debayer params Date: Wed, 15 Oct 2025 02:22:35 +0100 Message-ID: <20251015012251.17508-24-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" There is another CCM calculated in this algorithm callback, this time based on the LUT. Signed-off-by: Bryan O'Donoghue --- src/ipa/simple/algorithms/lut.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp index d1d5f727..a161adb1 100644 --- a/src/ipa/simple/algorithms/lut.cpp +++ b/src/ipa/simple/algorithms/lut.cpp @@ -126,6 +126,7 @@ void Lut::prepare(IPAContext &context, auto &red = params->redCcm; auto &green = params->greenCcm; auto &blue = params->blueCcm; + params->ccm = ccm; for (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) { red[i].r = ccmValue(i, ccm[0][0]); red[i].g = ccmValue(i, ccm[1][0]); From patchwork Wed Oct 15 01:22:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24669 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 EB84AC3332 for ; Wed, 15 Oct 2025 01:23:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7D30D60658; Wed, 15 Oct 2025 03:23:33 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YOR57/OP"; dkim-atps=neutral Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 97E0C60642 for ; Wed, 15 Oct 2025 03:23:19 +0200 (CEST) Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-b40f11a1027so1073927766b.2 for ; Tue, 14 Oct 2025 18:23:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491399; x=1761096199; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=466aSq4HGB3YriCFxyHHrht3jJTico5gS2hMItA4Sxs=; b=YOR57/OP6fsh6ODo+R4tAtLonc7RqsBSH4Ohv7EteHo4IfEZcyhZki61AnlKKH3cmE gh/pTfRa8VBGkZ31yQ/hqojIMTsB33vEBLiL02OQueY/NQF9afM2jEK/tovFxX0foXlk Z93liycGu/I8RRGGcwETT19Wk3c1tC1HY+MW7uOxSDD3/TOwLdb4srYpwD1pUvAFSZnj et490l7uqM7ICv3Q7CdXE8GtjwlAu+4z4UJsRAP+A76+1MaiCgjMavUI/ACNWEAeJR/X G1F5BGLTNvWVnMTOaE+OCuG2ZOAQvkwE1asXnR65d9eHvLAYUoICVw4y2LB6CfinV6k4 RofA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491399; x=1761096199; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=466aSq4HGB3YriCFxyHHrht3jJTico5gS2hMItA4Sxs=; b=VqqZPYTpqe7naUR6X9BgjVIYBuonKdavuciOqqKgcSeXyOG7YSiqF52pyFGY09CfAz 4iBan3QzlvZj1VoYuZy3wY19nQSIqjDROoZTto5OPZ/v60iZzLm9wsWcCnV42jqDvMJV JnYSOvfFKGAAa/pdki3nkEpP6VtfJEqBQbggxnK8IZEsNkbp7kRrgS7gQYRAFn01N/uS ztn3BENnhmi5i9Ytm/LOivi8QE3w2pzIaHYGc+icbF4KgN2431am0+EB6svvIu4ChR1K VokCzLraO822UW/S/MWOFkPRZK673knQKqQ5P889oZe9xNmVhi2LqoCXdEKWghQ1Gyds 8dSg== X-Gm-Message-State: AOJu0YxeQ1jXPNAqgx+5HNvGsgWk2o/G1pTX6rk9stRAqLdLEMb2iHV5 JghvqhajvGBT6f25rsJfsEg8FpUSbgw1b8GxxK+1CDxY5xosMQ1IxmUvOi4GoHaKxSTOczv49rS 2g2qW X-Gm-Gg: ASbGncsW8LODTOTnlr+Hcq1JDXNUMN4znjC+lwXls65g5UfFmhm2siamB3EpENCl2Mi dAar4pzH97kmi/bMDbzwgGFZH91h9PBzJqxlWu9vhKh3tN7hTe3E3hRBDHLVKHWveOHKmgLI6Fg OHDc61nBv7PeXIwUB01c+UJDOkjacOXd/bVQ7KBTEFflSUWoqofSoCfvA+ykjhAvb5zwVXmbUak HP/jp8572ZyYeyXlxg/2mifruZzhKyw50700IrX6aoajF2zaxtiXvra1S/8W2uMa4Ed0tyTRQek WtmOqNhPOF78VfS4wxUMb8aNFHduyI817RZatjRW5m66Dg3PFjYw2NRdOHiC5v1bSxizbakCcS+ 3cD+m0ZahzLUa37dHaz9rVzIe4Qkv0CiB+1iw7fGyYqtkTu/xMLmxdZH1yqkrsjLnm9vOXMm165 tRohNhlZGe7ho2QRhbLGzjVCbbL9+5bpzQ+P/m1M5B X-Google-Smtp-Source: AGHT+IEbLFo+23cBv+hIoNUpyjs+8eeeCLt8ATt4ow+5eACfYZZEALSAOinpb0sN9oPf5cpHWXlC7w== X-Received: by 2002:a17:907:6e88:b0:b3d:35f6:e3cf with SMTP id a640c23a62f3a-b50aca0070cmr2883767666b.60.1760491398673; Tue, 14 Oct 2025 18:23:18 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:18 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 24/39] libcamera: software_isp: gbm: Add in a GBM helper class for GPU surface access Date: Wed, 15 Oct 2025 02:22:36 +0100 Message-ID: <20251015012251.17508-25-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" A helper class to interact with GBM. This will allow us to specify the internal storage format of the CPU when making a texture for the Debayer vertext/fragment shaders and thus ensure we receive an uncompressed and untiled output buffer. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/gbm.h | 43 ++++++++++++++++++ include/libcamera/internal/meson.build | 1 + src/libcamera/gbm.cpp | 61 ++++++++++++++++++++++++++ src/libcamera/meson.build | 11 +++++ 4 files changed, 116 insertions(+) create mode 100644 include/libcamera/internal/gbm.h create mode 100644 src/libcamera/gbm.cpp diff --git a/include/libcamera/internal/gbm.h b/include/libcamera/internal/gbm.h new file mode 100644 index 00000000..41b5e00f --- /dev/null +++ b/include/libcamera/internal/gbm.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Linaro Ltd. + * + * Authors: + * Bryan O'Donoghue + * + * gbm.h - Helper class for managing GBM interactions. + */ + +#pragma once + +#include + +#include + +#include + +namespace libcamera { + +LOG_DECLARE_CATEGORY(GBM) + +/** + * \brief Helper class for managing GBM interactions + * + */ +class GBM +{ +public: + GBM(); + ~GBM(); + + int createDevice(); + struct gbm_device *getDevice() { return gbm_device_; } + PixelFormat getPixelFormat() { return format_; } + +private: + int fd_; + struct gbm_device *gbm_device_; + PixelFormat format_; +}; + +} // namespace libcamera diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index ecb7c9fa..01a36595 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -24,6 +24,7 @@ libcamera_internal_headers = files([ 'dma_buf_allocator.h', 'formats.h', 'framebuffer.h', + 'gbm.h', 'global_configuration.h', 'ipa_data_serializer.h', 'ipa_manager.h', diff --git a/src/libcamera/gbm.cpp b/src/libcamera/gbm.cpp new file mode 100644 index 00000000..caf9ca1c --- /dev/null +++ b/src/libcamera/gbm.cpp @@ -0,0 +1,61 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Linaro Ltd. + * + * Authors: + * Bryan O'Donoghue + * + * egl.cpp - Helper class for managing GBM interactions. + */ + +#include "libcamera/internal/gbm.h" + +#include +#include +#include +#include + +#include +#include + +namespace libcamera { + +LOG_DEFINE_CATEGORY(GBM) + +GBM::GBM() +{ + fd_ = 0; +} + +GBM::~GBM() +{ + if (gbm_device_) + gbm_device_destroy(gbm_device_); + + if (fd_ >= 0) + close(fd_); +} + +int GBM::createDevice() +{ + const char *dri_node = "/dev/dri/renderD128"; //TODO: get from an env or config setting + + fd_ = open(dri_node, O_RDWR | O_CLOEXEC); + if (fd_ < 0) { + LOG(GBM, Error) << "Open " << dri_node << " fail " << fd_; + return fd_; + } + + gbm_device_ = gbm_create_device(fd_); + if (!gbm_device_) { + LOG(GBM, Error) << "gbm_crate_device fail"; + goto fail; + } + + format_ = libcamera::formats::ARGB8888; + + return 0; +fail: + return -ENODEV; +} +} //namespace libcamera diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 5b9b86f2..fe60c875 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -69,6 +69,16 @@ libcamera_deps = [] libatomic = cc.find_library('atomic', required : false) libthreads = dependency('threads') +libgbm = cc.find_library('gbm', required: false) +gbm_works = cc.check_header('gbm.h', required: false) + +if libgbm.found() and gbm_works + config_h.set('HAVE_GBM', 1) + libcamera_internal_sources += files([ + 'gbm.cpp', + ]) +endif + subdir('base') subdir('converter') subdir('ipa') @@ -176,6 +186,7 @@ libcamera_deps += [ libcamera_base_private, libcrypto, libdl, + libgbm, liblttng, libudev, libyaml, From patchwork Wed Oct 15 01:22:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24670 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 3DD78C3264 for ; Wed, 15 Oct 2025 01:23:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6C2E86066D; Wed, 15 Oct 2025 03:23:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="V7i+sEMV"; dkim-atps=neutral Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8B07360617 for ; Wed, 15 Oct 2025 03:23:20 +0200 (CEST) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-634b774f135so9595957a12.2 for ; Tue, 14 Oct 2025 18:23:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491400; x=1761096200; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=d8eHUt2DWon0EYsU6g3OzoaNiV9g7qrwYZpX9M8fVWQ=; b=V7i+sEMVOm/OquBj3YcOM5frY58f/JYl2n7qd5xILt8K0DlwgQoPh64MYg4zZWzSiU a47ePP5eSZ/J+vAu4QuZo3xXgkhI7LdjPcOxs2jHlfEdmuvQZAMxtKT/qWnW0O43OekY ekkg2ddqnl4S+MWnMVcL7NP1FbqphQSTsgaL9XPDlUS/nRMPdwyytQol3abEffH8LANE 5few8qO01f6zoNH/QiXKelhT20fj0c3HjqKFPQKMT4qps5Vx/pofqIAZWH1AY3+POQHE YZmZThha5hM96Vwjozk6rL0YOqhxbg24ELXUNbGtQsFYb0rvbIhCkkQY6Js/X+uDRmFQ HmoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491400; x=1761096200; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=d8eHUt2DWon0EYsU6g3OzoaNiV9g7qrwYZpX9M8fVWQ=; b=qWqafBSYZI41xWAsXFT7xeBm4Tnm8OMqmt0THFbsHIQcl6DTn5LlL0b/+UXqBYqFhD DkIAJ1tckOVcU4lnFQb6UiGaIovqME0G44RQmUWmjTJNo116oMEzk9Fj1lCJ2s0r58oB p/S0dFphLTMsa/UBedldUw5fAz9YAtz/18Z1g58C/hRIsbwZJqicJ71+kzOyU9dyWxoz xVmHBItvbHI7CNylAoICKjdOIpssqPCt1SKXd1K6Wu6b6dyeonJ5vCo1Z2Fe2GaQ5Yk7 EbahyOB1uQ3T1JwaPIXZ8OnhGMAB0invq6lMygWtK8Lu+WJpJnlhrQsvLMwqMsjb6pDe qaKQ== X-Gm-Message-State: AOJu0YxpFprOqfx6MQuPyze34pjuXmdDRxwJU2dxdiy2w69HRFkJ2sQM V9qPuOw7b3evjr6rDRvAkK13n4u9EQ0VjCacbPutDjMBySzIDi2oyQ7oFx4P+bkhAp4fLLnNHVG FtM54 X-Gm-Gg: ASbGncuzVgvuvuEj2z68GI0nJTFrCyT9CNjC9f8atOtTloFLGyUdD+Yu3QH/MuLs8fy cF5pYfrl7sEmQCZUFqZGd2jEyk4BJhT4qsmXh+OgVgiQGCfJUfMYY4ST9CVE5w3O5KfytINmx0i KnvnS0D560xiy6iVGRkoWHH0uGpW2XwaEjLuCojaDmKsGBNPsjLSg04p7vUhIR+/SmaBfgUDMuO GsSxUXFS3i3FlzN6/VMFrYcgKM1Vx5VdeYxTKAJe497WD8b4XPY/PeLMae9bE4CF90w50qm6Yb7 VEIIDMFWAT287S0eOcsUfwp8TtayTmQp0JnFeWqWkI2ube6RcVif4dsRt4ot5EpXRaPfJ0uHq6I RiDW2Gy2A9mLgSPuMgBJ8R0wdZ7V1MoYPHsfivlgGg2/uehc0yUYQjC/Zg7nGl4P6gtNR/oEEw/ yHcEyKf/uArEJ5yT3BIEsfyyHXc2GQudr/csTrfm95 X-Google-Smtp-Source: AGHT+IGUuraU9FQ2DjgOKjoPctmnqIqFHfwEs+cMKHpaLhKUcpGjtaZC0vy9RGlP32R330hZfv+p5g== X-Received: by 2002:a17:906:6a25:b0:b2c:dc13:89e3 with SMTP id a640c23a62f3a-b50acc32fd2mr2968085866b.59.1760491399859; Tue, 14 Oct 2025 18:23:19 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:19 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 25/39] libcamera: software_isp: Make isStandardBayerOrder static Date: Wed, 15 Oct 2025 02:22:37 +0100 Message-ID: <20251015012251.17508-26-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Make this member function static so that it may be called from static members of derived classes. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index 8fa281c7..a88f352b 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -100,7 +100,7 @@ private: protected: void setParams(DebayerParams ¶ms); void dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output); - bool isStandardBayerOrder(BayerFormat::Order order); + static bool isStandardBayerOrder(BayerFormat::Order order); }; } /* namespace libcamera */ From patchwork Wed Oct 15 01:22:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24671 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 9CB0AC3335 for ; Wed, 15 Oct 2025 01:23:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 326E96066A; Wed, 15 Oct 2025 03:23:36 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="DasP0w70"; dkim-atps=neutral Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0A0686064C for ; Wed, 15 Oct 2025 03:23:22 +0200 (CEST) Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-63b9da57cecso5187805a12.0 for ; Tue, 14 Oct 2025 18:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491401; x=1761096201; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XOWqBm0QMLRhHmCkYqOM/ZUTCSHw7t28B8nnYsbLPSM=; b=DasP0w706aTApLuQybNcm7hXHGlnDBIePz0tbGj0xd3RoFV74UKTeruZxEeU6bDLoo tjAOQFxq+F+MtAV3r5kxN0Fl3x7fYaxR7iTGy6go3C3AhFjaUfqCYIvfveyT7wf1++V8 mLtDWPS4mljGBEyTRIOVL3APGxpB6bydbxaxawkMB0vhf+UVlWIEutn/FSKabliJI7fV mTJ9Xzoq/Ffx1icrcI0yaqNjItQsTcXQkAfV2UoCZeKb9o9pVB9F/jyMPsz6wsigUK4L QuTmwUVSxbPEpByADKKOUc7RqWJeUEA8oypTPj2It0wriVLutz5/6iwvPGRoWHPAMgDc lh/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491401; x=1761096201; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XOWqBm0QMLRhHmCkYqOM/ZUTCSHw7t28B8nnYsbLPSM=; b=uClnkPvSWmcTWsOwSuKTi3dYzPadQujsoADNqhgr632sEQaq3iNRjxzcnrpWUD0Evd cqnj5gjSNAaGfqJoIVGh1KIHm+jh2SLJUuloh0acXZjFJGKZ+pE0hb+ndxpdU1rjc5sP TMx3Zbisb1AlZ76oWWWUWBduGPglBc2RLSNte15eURVFfROhmaFD4aqZmIUxP0lY2WXC blIj8pqYx9xji09gv5UiICCNNHDN8jocWmznPkOBCmPsEYsdYd7fNTEZGrDpSxd917dS U7HfwNvjC/t5S2Nl7FkxSp06WGG0/7ESZqXoD09boXii2veefEAinM8EPn7/j+brYJZe VZng== X-Gm-Message-State: AOJu0YzDTOhgkrTt5Iq9WwJ/n4ACV9+8Xry+oiQo/jGStthiRjpVl36l abI62IhqGLHuSErIl+jOt3z1RjQk4bxqGfdkaB6yuOiKBu0+PRGLyZne1fvWn7WNESOKaq1jRvs HdyUw X-Gm-Gg: ASbGnctHxhDcftjT58lC+ld+4peVMVIY/mKmUixZpJNfzQO4A3gy5CwSn30LlU3gXPC cgG0RUxpxgtnxiglRk5/WGKjIspb7/j122InvBDsx4BAMr2a+DzEMR6iu/+t9/79HAz21axTTHp Ama9DydaSWoWJtFcwPUbpbLupa2fczqvJ/vnqJylQ8NlrcpkKOHWrLeMJ7hfT/u9k0p+1/2Eta6 uPQhAdbRdu7UnU3oeQLn/z4sfpyw0kUztcNEY66JVDdE7oqy658ocsyLL0vKcvHBOqLi5nNeelu r9sBfa3/AmOVjd5491Q83dnVJvBQ29oJ7QBoIPZpnFWApbjUyc5MK3FYbkhZL3+Tla8nX2IYuqH Tcz2r7ww7D0mJRURUOLGIRSuFIwwEuOpFyEZgdQZ19wc68urN2/ujBziKyDSY9VoJOMWU6kK96v kf+u+SIRc2/ihyKD86HKmqVle15cOUOz5dqOGAnnB4 X-Google-Smtp-Source: AGHT+IGwUXmzAwFdMIWczlXZk4awLtk3PyKvkmAqvBR31K9nXxhbK5ZhK78OpsJUwonwSH8+40mGgA== X-Received: by 2002:a17:906:ef02:b0:b3f:f66b:268a with SMTP id a640c23a62f3a-b50aa08ef47mr3037260466b.19.1760491401199; Tue, 14 Oct 2025 18:23:21 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:20 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 26/39] libcamera: software_isp: egl: Introduce an eGL base helper class Date: Wed, 15 Oct 2025 02:22:38 +0100 Message-ID: <20251015012251.17508-27-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Introduce an eGL base helper class which provides an eGL context based on a passed width and height. The initGLContext function could be overloaded to provide an interface to a real display. A set of helper functions is provided to compile and link GLSL shaders. linkShaderProgram currently compiles vertex/fragment pairs but could be overloaded or passed a parameter to link a compute shader instead. Breaking the eGL interface away from debayering - allows to use the eGL context inside of a dma-buf heap cleanly, reuse that context inside of a debayer layer and conceivably reuse the context in a multi-stage shader pass. Small note the image_attrs[] array doesn't pass checkstyle.py however the elements of the array are in pairs. Signed-off-by: Bryan O'Donoghue Acked-by: Kieran Bingham --- include/libcamera/internal/egl.h | 162 ++++++++++++ src/libcamera/egl.cpp | 435 +++++++++++++++++++++++++++++++ src/libcamera/meson.build | 23 ++ 3 files changed, 620 insertions(+) create mode 100644 include/libcamera/internal/egl.h create mode 100644 src/libcamera/egl.cpp diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h new file mode 100644 index 00000000..3021578b --- /dev/null +++ b/include/libcamera/internal/egl.h @@ -0,0 +1,162 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Linaro Ltd. + * + * Authors: + * Bryan O'Donoghue + * + * egl_context.cpp - Helper class for managing eGL interactions. + */ + +#pragma once + +#include +#include + +#include + +#include "libcamera/base/utils.h" +#include "libcamera/internal/gbm.h" + +#define EGL_EGLEXT_PROTOTYPES +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include + +namespace libcamera { + +LOG_DECLARE_CATEGORY(eGL) + +/** + * \brief Helper class for an eGLImage. + * + * There are a few handles, descriptors and routines that it makes sense to + * aggregate together. For example generating a GL texture and + * frame-buffer-object and being about to assocate that with the + * texture_uniform_id for a given shader. + * + */ +class eGLImage +{ +public: + eGLImage(uint32_t width, uint32_t height, uint32_t bpp, uint32_t stride, GLenum texture_unit, uint32_t texture_unit_uniform_id) + { + init(width, height, bpp, stride, texture_unit, texture_unit_uniform_id); + } + + eGLImage(uint32_t width, uint32_t height, uint32_t bpp, GLenum texture_unit, uint32_t texture_unit_uniform_id) + { + uint32_t stride = libcamera::utils::alignUp(width * bpp, 256); + + init(width, height, bpp, stride, texture_unit, texture_unit_uniform_id); + } + + ~eGLImage() + { + glDeleteFramebuffers(1, &fbo_); + glDeleteTextures(1, &texture_); + } + + uint32_t width_; + uint32_t height_; + uint32_t stride_; + uint32_t offset_; + uint32_t framesize_; + uint32_t bpp_; + uint32_t texture_unit_uniform_id_; + GLenum texture_unit_; + GLuint texture_; + GLuint fbo_; + EGLImageKHR image_; + +private: + LIBCAMERA_DISABLE_COPY_AND_MOVE(eGLImage) + + void init(uint32_t width, uint32_t height, uint32_t bpp, uint32_t stride, GLenum texture_unit, uint32_t texture_unit_uniform_id) + { + image_ = EGL_NO_IMAGE_KHR; + width_ = width; + height_ = height; + bpp_ = bpp; + stride_ = stride; + framesize_ = stride_ * height_; + texture_unit_ = texture_unit; + texture_unit_uniform_id_ = texture_unit_uniform_id; + + glGenTextures(1, &texture_); + glGenFramebuffers(1, &fbo_); + } +}; + +/** + * \brief The main eGL object + * + * This class buries away eGL specific setup and manipulation. + * + * Setting up the eGL context. + * Getting function pointers. + * Generating an eGL program from environment variables. + * Link that program. + * Generating textures for upload. + * Render to texture for output. + * + */ +class eGL +{ +public: + eGL(); + ~eGL(); + + int initEGLContext(GBM *gbmContext); + void cleanUp(); + int createInputDMABufTexture2D(eGLImage *eglImage, int fd); + int createOutputDMABufTexture2D(eGLImage *eglImage, int fd); + void destroyDMABufTexture(eGLImage *eglImage); + void createTexture2D(eGLImage *eglImage, GLint format, uint32_t width, uint32_t height, void *data); + void createTexture1D(eGLImage *eglImage, GLint format, uint32_t width, void *data); + + void pushEnv(std::vector &shaderEnv, const char *str); + void makeCurrent(); + + int compileVertexShader(GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + Span shaderEnv); + int compileFragmentShader(GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + Span shaderEnv); + int linkProgram(GLuint &programId, GLuint fragmentshaderId, GLuint vertexshaderId); + void dumpShaderSource(GLuint shaderId); + void useProgram(GLuint programId); + void deleteProgram(GLuint programId); + int syncOutput(); + +private: + LIBCAMERA_DISABLE_COPY_AND_MOVE(eGL) + + int fd_; + pid_t tid_; + + EGLDisplay display_; + EGLContext context_; + EGLSurface surface_; + EGLSyncKHR sync_; + + int compileShader(int shaderType, GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + Span shaderEnv); + + int createDMABufTexture2D(eGLImage *eglImage, int fd, bool output); + + PFNEGLEXPORTDMABUFIMAGEMESAPROC eglExportDMABUFImageMESA; + PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; + + PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; + PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; + + PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR; + PFNEGLDESTROYSYNCKHRPROC eglDestroySyncKHR; + PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR; +}; +} //namespace libcamera diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp new file mode 100644 index 00000000..d5cb2df5 --- /dev/null +++ b/src/libcamera/egl.cpp @@ -0,0 +1,435 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Linaro Ltd. + * + * Authors: + * Bryan O'Donoghue + * + * egl.cpp - Helper class for managing eGL interactions. + */ + +#include "libcamera/base/thread.h" +#include "libcamera/internal/egl.h" + +#include +#include +#include +#include + +#include +#include +#include + +namespace libcamera { + +LOG_DEFINE_CATEGORY(eGL) + +eGL::eGL() +{ + context_ = EGL_NO_CONTEXT; + surface_ = EGL_NO_SURFACE; + display_ = EGL_NO_DISPLAY; +} + +eGL::~eGL() +{ + if (context_ != EGL_NO_CONTEXT) + eglDestroyContext(display_, context_); + + if (surface_ != EGL_NO_SURFACE) + eglDestroySurface(display_, surface_); + +} + +int eGL::syncOutput(void) +{ + ASSERT(tid_ == Thread::currentId()); + + glFlush(); + eglClientWaitSyncKHR(display_, sync_, 0, EGL_FOREVER_KHR); + + return 0; +} + +// Create linear image attached to previous BO object +int eGL::createDMABufTexture2D(eGLImage *eglImage, int fd, bool output) +{ + int ret = 0; + + ASSERT(tid_ == Thread::currentId()); + + // clang-format off + EGLint image_attrs[] = { + EGL_WIDTH, (EGLint)eglImage->width_, + EGL_HEIGHT, (EGLint)eglImage->height_, + EGL_LINUX_DRM_FOURCC_EXT, DRM_FORMAT_ARGB8888, + EGL_DMA_BUF_PLANE0_FD_EXT, fd, + EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, + EGL_DMA_BUF_PLANE0_PITCH_EXT, (EGLint)eglImage->stride_, + EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT, 0, + EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT, 0, + EGL_NONE, + }; + // clang-format on + + eglImage->image_ = eglCreateImageKHR(display_, EGL_NO_CONTEXT, + EGL_LINUX_DMA_BUF_EXT, + NULL, image_attrs); + + if (eglImage->image_ == EGL_NO_IMAGE_KHR) { + LOG(eGL, Error) << "eglCreateImageKHR fail"; + ret = -ENODEV; + goto done; + } + + // Bind texture unit and texture + glActiveTexture(eglImage->texture_unit_); + glBindTexture(GL_TEXTURE_2D, eglImage->texture_); + + // Generate texture with filter semantics + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage->image_); + + // Nearest filtering + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + // Wrap to edge to avoid edge artifacts + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + if (output) { + // Generate a framebuffer from our texture direct to dma-buf handle buffer + glBindFramebuffer(GL_FRAMEBUFFER, eglImage->fbo_); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, eglImage->texture_, 0); + + GLenum err = glCheckFramebufferStatus(GL_FRAMEBUFFER); + if (err!= GL_FRAMEBUFFER_COMPLETE) { + LOG(eGL, Error) << "glFrameBufferTexture2D error " << err; + ret = -ENODEV; + goto done; + } + } +done: + return ret; +} + +int eGL::createInputDMABufTexture2D(eGLImage *eglImage, int fd) +{ + ASSERT(tid_ == Thread::currentId()); + + return createDMABufTexture2D(eglImage, fd, false); +} +int eGL::createOutputDMABufTexture2D(eGLImage *eglImage, int fd) +{ + ASSERT(tid_ == Thread::currentId()); + + return createDMABufTexture2D(eglImage, fd, true); +} + +void eGL::destroyDMABufTexture(eGLImage *eglImage) +{ + eglDestroyImage(display_, eglImage->image_); +} + +// Generate a 2D texture from an input buffer directly +void eGL::createTexture2D(eGLImage *eglImage, GLint format, uint32_t width, uint32_t height, void *data) +{ + ASSERT(tid_ == Thread::currentId()); + + glActiveTexture(eglImage->texture_unit_); + glBindTexture(GL_TEXTURE_2D, eglImage->texture_); + + // Generate texture, bind, associate image to texture, configure, unbind + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data); + + // Nearest filtering + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + // Wrap to edge to avoid edge artifacts + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + +int eGL::initEGLContext(GBM *gbmContext) +{ + EGLint configAttribs[] = { + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_NONE + }; + + EGLint contextAttribs[] = { + EGL_CONTEXT_MAJOR_VERSION, 2, + EGL_NONE + }; + + EGLint numConfigs; + EGLConfig config; + EGLint major; + EGLint minor; + + if (!eglBindAPI(EGL_OPENGL_ES_API)) { + LOG(eGL, Error) << "API bind fail"; + goto fail; + } + + display_ = eglGetDisplay(gbmContext->getDevice()); + if (display_ == EGL_NO_DISPLAY) { + LOG(eGL, Error) << "Unable to get EGL display"; + goto fail; + } + + if (eglInitialize(display_, &major, &minor) != EGL_TRUE) { + LOG(eGL, Error) << "eglInitialize fail"; + goto fail; + } + + LOG(eGL, Info) << "EGL: version " << major << "." << minor; + LOG(eGL, Info) << "EGL: EGL_VERSION: " << eglQueryString(display_, EGL_VERSION); + LOG(eGL, Info) << "EGL: EGL_VENDOR: " << eglQueryString(display_, EGL_VENDOR); + LOG(eGL, Info) << "EGL: EGL_CLIENT_APIS: " << eglQueryString(display_, EGL_CLIENT_APIS); + LOG(eGL, Info) << "EGL: EGL_EXTENSIONS: " << eglQueryString(display_, EGL_EXTENSIONS); + + eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); + if (!eglCreateImageKHR) { + LOG(eGL, Error) << "eglCreateImageKHR not found"; + goto fail; + } + + eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); + if (!eglDestroyImageKHR) { + LOG(eGL, Error) << "eglDestroyImageKHR not found"; + goto fail; + } + + glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); + if (!glEGLImageTargetTexture2DOES) { + LOG(eGL, Error) << "glEGLImageTargetTexture2DOES not found"; + goto fail; + } + + eglCreateSyncKHR = (PFNEGLCREATESYNCKHRPROC)eglGetProcAddress("eglCreateSyncKHR"); + if (!eglCreateSyncKHR) { + LOG(eGL, Error) << "eglCreateSyncKHR not found"; + goto fail; + } + + eglDestroySyncKHR = (PFNEGLDESTROYSYNCKHRPROC)eglGetProcAddress("eglDestroySyncKHR"); + if (!eglDestroySyncKHR) { + LOG(eGL, Error) << "eglDestroySyncKHR not found"; + goto fail; + } + + eglClientWaitSyncKHR = (PFNEGLCLIENTWAITSYNCKHRPROC)eglGetProcAddress("eglClientWaitSyncKHR"); + if (!eglClientWaitSyncKHR) { + LOG(eGL, Error) << "eglClientWaitSyncKHR not found"; + goto fail; + } + + if (eglChooseConfig(display_, configAttribs, &config, 1, &numConfigs) != EGL_TRUE) { + LOG(eGL, Error) << "eglChooseConfig fail"; + goto fail; + } + + context_ = eglCreateContext(display_, config, EGL_NO_CONTEXT, contextAttribs); + if (context_ == EGL_NO_CONTEXT) { + LOG(eGL, Error) << "eglContext returned EGL_NO_CONTEXT"; + goto fail; + } + + tid_ = Thread::currentId(); + + makeCurrent(); + + sync_ = eglCreateSyncKHR(display_, EGL_SYNC_FENCE_KHR, NULL); + if (sync_ == EGL_NO_SYNC_KHR) { + LOG(eGL, Error) << "eglCreateSyncKHR fail"; + goto fail; + } + + return 0; +fail: + + return -ENODEV; +} + +void eGL::cleanUp(void) +{ + ASSERT(tid_ == Thread::currentId()); + + if (sync_) { + makeCurrent(); + eglDestroySyncKHR(display_, sync_); + } + +} + +void eGL::makeCurrent(void) +{ + ASSERT(tid_ == Thread::currentId()); + + if (eglMakeCurrent(display_, EGL_NO_SURFACE, EGL_NO_SURFACE, context_) != EGL_TRUE) { + LOG(eGL, Error) << "eglMakeCurrent fail"; + } +} + +void eGL::useProgram(GLuint programId) +{ + ASSERT(tid_ == Thread::currentId()); + + glUseProgram(programId); +} + +void eGL::deleteProgram(GLuint programId) +{ + ASSERT(tid_ == Thread::currentId()); + + glDeleteProgram(programId); +} + +void eGL::pushEnv(std::vector &shaderEnv, const char *str) +{ + std::string addStr = str; + + addStr.push_back('\n'); + shaderEnv.push_back(std::move(addStr)); +} + +int eGL::compileVertexShader(GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + Span shaderEnv) +{ + return compileShader(GL_VERTEX_SHADER, shaderId, shaderData, shaderDataLen, shaderEnv); +} + +int eGL::compileFragmentShader(GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + Span shaderEnv) +{ + return compileShader(GL_FRAGMENT_SHADER, shaderId, shaderData, shaderDataLen, shaderEnv); +} + +int eGL::compileShader(int shaderType, GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + Span shaderEnv) +{ + GLint success; + size_t i; + + ASSERT(tid_ == Thread::currentId()); + + auto count = 1 + shaderEnv.size(); + auto shaderSourceData = std::make_unique(count); + auto shaderDataLengths = std::make_unique(count); + + // Prefix defines before main body of shader + for (i = 0; i < shaderEnv.size(); i++) { + shaderSourceData[i] = shaderEnv[i].c_str(); + shaderDataLengths[i] = shaderEnv[i].length(); + } + + // Now the main body of the shader program + shaderSourceData[i] = reinterpret_cast(shaderData); + shaderDataLengths[i] = shaderDataLen; + + // And create the shader + shaderId = glCreateShader(shaderType); + glShaderSource(shaderId, count, shaderSourceData.get(), shaderDataLengths.get()); + glCompileShader(shaderId); + + // Check status + glGetShaderiv(shaderId, GL_COMPILE_STATUS, &success); + if (success == GL_FALSE) { + GLint sizeLog = 0; + + glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &sizeLog); + auto infoLog = std::make_unique(sizeLog); + + glGetShaderInfoLog(shaderId, sizeLog, &sizeLog, infoLog.get()); + LOG(eGL, Error) << infoLog.get(); + } + + return !(success == GL_TRUE); +} + +void eGL::dumpShaderSource(GLuint shaderId) +{ + GLint shaderLength = 0; + + ASSERT(tid_ == Thread::currentId()); + + glGetShaderiv(shaderId, GL_SHADER_SOURCE_LENGTH, &shaderLength); + + LOG(eGL, Debug) << "Shader length is " << shaderLength; + + if (shaderLength > 0) { + auto shaderSource = std::make_unique(shaderLength); + + glGetShaderSource(shaderId, shaderLength, &shaderLength, shaderSource.get()); + if (shaderLength) { + LOG(eGL, Debug) << "Shader source = " << shaderSource.get(); + } + } +} + +int eGL::linkProgram(GLuint &programId, GLuint vertexshaderId, GLuint fragmentshaderId) +{ + GLint success; + GLenum err; + + ASSERT(tid_ == Thread::currentId()); + + programId = glCreateProgram(); + if (!programId) + goto fail; + + glAttachShader(programId, vertexshaderId); + if ((err = glGetError()) != GL_NO_ERROR) { + LOG(eGL, Error) << "Attach compute vertex shader fail"; + goto fail; + } + + glAttachShader(programId, fragmentshaderId); + if ((err = glGetError()) != GL_NO_ERROR) { + LOG(eGL, Error) << "Attach compute vertex shader fail"; + goto fail; + } + + glLinkProgram(programId); + if ((err = glGetError()) != GL_NO_ERROR) { + LOG(eGL, Error) << "Link program fail"; + goto fail; + } + + glDetachShader(programId, fragmentshaderId); + glDetachShader(programId, vertexshaderId); + + // Check status + glGetProgramiv(programId, GL_LINK_STATUS, &success); + if (success == GL_FALSE) { + GLint sizeLog = 0; + GLchar *infoLog; + + glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &sizeLog); + infoLog = new GLchar[sizeLog]; + + glGetProgramInfoLog(programId, sizeLog, &sizeLog, infoLog); + LOG(eGL, Error) << infoLog; + + delete[] infoLog; + goto fail; + } + + return 0; +fail: + if (programId) + glDeleteProgram(programId); + + return -ENODEV; +} +} // namespace libcamera diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index fe60c875..b7be38a8 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -79,6 +79,27 @@ if libgbm.found() and gbm_works ]) endif +libegl = cc.find_library('EGL', required : false) +libglesv2 = cc.find_library('GLESv2', required : false) +mesa_works = cc.check_header('EGL/egl.h', required: false) + +if libegl.found() and mesa_works + config_h.set('HAVE_LIBEGL', 1) +endif + +if libglesv2.found() and mesa_works + config_h.set('HAVE_GLESV2', 1) +endif + +if mesa_works and gbm_works + libcamera_internal_sources += files([ + 'egl.cpp', + ]) + gles_headless_enabled = true +else + gles_headless_enabled = false +endif + subdir('base') subdir('converter') subdir('ipa') @@ -186,7 +207,9 @@ libcamera_deps += [ libcamera_base_private, libcrypto, libdl, + libegl, libgbm, + libglesv2, liblttng, libudev, libyaml, From patchwork Wed Oct 15 01:22:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24672 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 1497BC3331 for ; Wed, 15 Oct 2025 01:23:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 93FAD6063E; Wed, 15 Oct 2025 03:23:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="cAghXbyb"; dkim-atps=neutral Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D929560646 for ; Wed, 15 Oct 2025 03:23:22 +0200 (CEST) Received: by mail-ej1-x630.google.com with SMTP id a640c23a62f3a-b5a8184144dso331942966b.1 for ; Tue, 14 Oct 2025 18:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491402; x=1761096202; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cRVEHiEipQ6SvLkbWQz7JxYpu6YoVwpwlf26Fgb4Ok4=; b=cAghXbybVOjiARJYDXzLUK6HhgyfEaNPl79RTMyYQD48RqCy+Ban5QAYE6DL3gtzef XWBUoNnHO8441OyVnEZqjFbGvWiLwRGfXoRruEZFSpIapvzoJ8Iv8YtiP0Zn9eBhUkmU /Ag3je40QueVMg07Y47M9n89YMcthKWsiDUGh72vzm5IKEF3KxNU4v66mWEkGf5on5L3 c40zOdRSmC2lTCT/e89TbCwYphyxa84iQyUehq+5hWy9bG81R3TWhlZw7gy2zSV5Wc7K vNoa4oQtIGeFpJyFro+NIebBWT0/Hp1jlcSw87CZb9A0EWwtgVMRA3GjypjcA/vGohJv 4K/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491402; x=1761096202; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cRVEHiEipQ6SvLkbWQz7JxYpu6YoVwpwlf26Fgb4Ok4=; b=tNejZXNqsEjukjDOACOgipKR0GxfQOdmr7vK08WIpaiPPvLg5Y3GOebB1k59jz+lzs k47HEGKfDz3vPffhqgL9ZXXlAdht6xdaJPuXpgVxBh+9B+J8qsvK/gMncMcY/M+NYLZ/ xVZX/Mu1PtCzHBsL75Yg0/WWrp7m38pj6i+4AQTIqIBrlkGznEUYDWZqa0CEcEmHxNgn 9QcBJMBkl1SM25ku93vMnjmRBbATUKDUFkb6FSvXorZLmKyDZxMyTh91ZnIARZoPuqdq EhTD8kU0uSAx8DYPAL239P4FbUGFyNQFbyRuqrFukkI8xEyXfQgAMf/IuSivT9fr6xmZ AoFQ== X-Gm-Message-State: AOJu0Ywx2B8DW38EKTYkxC6+688fvcH+DxoDg7mHjIG3xCWl5a7/nbBj 80PmmVdIffwlyDrEJJA2rhJDJuEavjiWUEzYN6YmQ2mWfTl/cxth7XVpQNE1yFMBCv3VNsXGrEn 3VjYp X-Gm-Gg: ASbGnctaHZz+ffyT73/3JK0j+FOXZdMsxB8ksgmXgabJ4ulxm/5kM2lyDlP8ce2rpRg jFUBo/yFJ8JHVUB7D3xes5EmDic2h5QfrL/ph5D/Fh3VsE8WvEsYM/nJj8NEK2+8rNq8DVU3shz dfWPILA6+CNgA8XDihm2jLYmv1gO5Q/BSCLTUKxgdM5AW27TeoDYToqL1nhynL/NdT5Dsj7AjrF CD6dP/zouQF566SxSkyVloIRnR2JlJaZqW2Btd3s+jfrkvZMyfp6I0fqzZMDT8+TyDPXdE2BmmP Piy3xe7rWHl82jdJiUpbmgFQd8QVc7Cwzf1TTN+EdI0FmME3y5SOnGYeHugJllN2BTS8qBFmnzg bx9a9hygrxh482v8DhK9BLabUfqFI1ZwYu8xo9Vaj0sg7uz+EkTfhl5NZOczYZ4LkynYgKao46D 46jNbG97RwI7FwYuERLYstVeESQybtew== X-Google-Smtp-Source: AGHT+IEBfgYNNf/Ho6kVraoSYcIxbAZ4znSAoOR5FV3Ef+EGq1LYYlpP143JvZ1qE8RNV6+TEZaZtw== X-Received: by 2002:a17:907:6d25:b0:b40:52:19c2 with SMTP id a640c23a62f3a-b50aaa9c937mr2825866366b.20.1760491402094; Tue, 14 Oct 2025 18:23:22 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:21 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 27/39] libcamera: shaders: Rename bayer_8 to bayer_unpacked Date: Wed, 15 Oct 2025 02:22:39 +0100 Message-ID: <20251015012251.17508-28-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" From: Milan Zamazal bayer_8.* shaders are now used for all unpacked sensor data formats, regardless of the pixel bit width. Let's rename the "8-bit" shaders to avoid confusion. Signed-off-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- .../{bayer_8.frag => bayer_unpacked.frag} | 0 .../{bayer_8.vert => bayer_unpacked.vert} | 0 include/libcamera/internal/shaders/meson.build | 4 ++-- src/apps/qcam/assets/shader/shaders.qrc | 4 ++-- src/apps/qcam/viewfinder_gl.cpp | 16 ++++++++-------- 5 files changed, 12 insertions(+), 12 deletions(-) rename include/libcamera/internal/shaders/{bayer_8.frag => bayer_unpacked.frag} (100%) rename include/libcamera/internal/shaders/{bayer_8.vert => bayer_unpacked.vert} (100%) diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag similarity index 100% rename from include/libcamera/internal/shaders/bayer_8.frag rename to include/libcamera/internal/shaders/bayer_unpacked.frag diff --git a/include/libcamera/internal/shaders/bayer_8.vert b/include/libcamera/internal/shaders/bayer_unpacked.vert similarity index 100% rename from include/libcamera/internal/shaders/bayer_8.vert rename to include/libcamera/internal/shaders/bayer_unpacked.vert diff --git a/include/libcamera/internal/shaders/meson.build b/include/libcamera/internal/shaders/meson.build index 386b342d..dd441a57 100644 --- a/include/libcamera/internal/shaders/meson.build +++ b/include/libcamera/internal/shaders/meson.build @@ -4,7 +4,7 @@ # for the purposes of inclusion in OpenGL debayering shader_files = files([ 'bayer_1x_packed.frag', - 'bayer_8.frag', - 'bayer_8.vert', + 'bayer_unpacked.frag', + 'bayer_unpacked.vert', 'identity.vert', ]) diff --git a/src/apps/qcam/assets/shader/shaders.qrc b/src/apps/qcam/assets/shader/shaders.qrc index 04f9d706..32dfa51b 100644 --- a/src/apps/qcam/assets/shader/shaders.qrc +++ b/src/apps/qcam/assets/shader/shaders.qrc @@ -6,8 +6,8 @@ ../../../../../include/libcamera/internal/shaders/YUV_3_planes.frag ../../../../../include/libcamera/internal/shaders/YUV_packed.frag ../../../../../include/libcamera/internal/shaders/bayer_1x_packed.frag - ../../../../../include/libcamera/internal/shaders/bayer_8.frag - ../../../../../include/libcamera/internal/shaders/bayer_8.vert + ../../../../../include/libcamera/internal/shaders/bayer_unpacked.frag + ../../../../../include/libcamera/internal/shaders/bayer_unpacked.vert ../../../../../include/libcamera/internal/shaders/identity.vert diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp index 70f60065..95965ab7 100644 --- a/src/apps/qcam/viewfinder_gl.cpp +++ b/src/apps/qcam/viewfinder_gl.cpp @@ -235,29 +235,29 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format) case libcamera::formats::SBGGR8: firstRed_.setX(1.0); firstRed_.setY(1.0); - vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; - fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGBRG8: firstRed_.setX(0.0); firstRed_.setY(1.0); - vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; - fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGRBG8: firstRed_.setX(1.0); firstRed_.setY(0.0); - vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; - fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SRGGB8: firstRed_.setX(0.0); firstRed_.setY(0.0); - vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; - fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SBGGR10_CSI2P: From patchwork Wed Oct 15 01:22:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24673 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 C463CC3333 for ; Wed, 15 Oct 2025 01:23:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5C1086066F; Wed, 15 Oct 2025 03:23:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="eS964H8E"; dkim-atps=neutral Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E4DFD60645 for ; Wed, 15 Oct 2025 03:23:23 +0200 (CEST) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-63bc12a5608so3493505a12.0 for ; Tue, 14 Oct 2025 18:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491403; x=1761096203; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cUJFqDYki3YK+OJOP8bMQTtCqTPkXZk+/ynvLttZF9w=; b=eS964H8EYu44WC6Zy83SQPahoeuDNj3I7NL7bOa9mz8zGmXWewzr8hW9M+NjJ/EW4c 7l7+mzJ561/wkRP9kpPFZkOjXsHiOIbzGGEyjHFFBM9jFt2ramj9+JLYZkEtjU+OiASv a0gj5GiHyCRFAPd3uvam5D18hWJrKM8pqhk0PwEQ5M1S8hyS2peWQXkw7WTUqnO8iwjx HptT1ZQbqlkg12SX33rhdiaqEQ9M7RlWLYP1P1xnXvbv1jsgHyYM7LlBCw9aPnrNjMNm TRLFfisem6GOlRCSp93cSEDoEqxnZYue6BDaEa47fEyY8yMkNSlkLqpdMcfSeYrfK/8I OlLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491403; x=1761096203; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cUJFqDYki3YK+OJOP8bMQTtCqTPkXZk+/ynvLttZF9w=; b=STuTw+75DoInmC8KK7vBmj/9f6L/NFAGu8XubkyptcMQ2L6yLzmBusPsnxpnmVKsS8 fwKClx4L1FcERExRIqpq28S/awmCoSMRdqHc0FXjlbM8QMER7E+Ot/MvupOdI0I6MjwJ 8iJGejNaSVhwCXUbJrzEuNMikHkrU87M5HmSEApYMU0xI7y8LWjFJ04UO+QGKCv/GCUo Zg98HH8saCHL9ScIrX9yvIqfqeWu6OD6iJSqzTyfo71K3bnprMmEdGRBzmNkygwAs9X5 9SZEGYtoYxBpyryU6TfCo+3oUxAWMpP7AT+Plyt+eN2sZG4m2p2wGsIPqngXgdCe3sER 49og== X-Gm-Message-State: AOJu0Yx73lwz9mWNDS6YE9XI+KDPihNmCH1kd2WK+aPl2H4v1xBTck9g +MNo3IlwtEl9/t+12MayDvo7C+Q8r4K7FNvJgFdc7CuwtFl5IvFl9qlRkDlcXCyiisR6oo0jHuH rtg/R X-Gm-Gg: ASbGncsauuvzb+FX8PCnVvYvJ+zsyqGJxFwECodJ0VhVuHwaUCy7Y7x0BtyU26TFuIj 3ycfVV2n9Ll0AVuV6VgaPw6jZyok4aHH8cQbUWCjjgte0H8m0rIcHjjjnNXSi1/jWVd+yu3Imhg BTFZcqD4QCBOv+IYFfFQp1xfCkHzJ9k9F5fWDAJIpxAygWNH9Z8RSsdAFVBg+0IotNFeZ97mtLh hfHPjFVmpl1bEJL7wOZistXqFpC5DqFiDOVg20w5ofsLgmHqp7HVEnKaOLE1Kw4Z0HI9m5SybnO 87lGcx0z8EmJGDc0v77bV3HPwcTMX+63L/tnT++FSGFF3ESaymQmBGST61MgYvH67nIdcGM5Gl3 ej5EKnpJRqutlI/Xn5eIv7wW7SA/Qo2aX57ULNwvqdP3u1g20KMOZUSSJJZH+b0bON90UVpO54q ZzQ7O/81ra9/mbPJEe/bRjTTgSrfU05A== X-Google-Smtp-Source: AGHT+IFSMbKpMbjpGdMVpH2uytKNLVHQzenA1MeNQFgBcbhGDEMycMaQkuaQmwP+XhsaszSS3BN3hw== X-Received: by 2002:a17:906:4fc3:b0:b41:12bf:e3aa with SMTP id a640c23a62f3a-b50aab9c91dmr2937146466b.16.1760491403108; Tue, 14 Oct 2025 18:23:23 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:22 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 28/39] libcamera: shaders: Use highp not mediump for float precision Date: Wed, 15 Oct 2025 02:22:40 +0100 Message-ID: <20251015012251.17508-29-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" We get better sample resolution with highp instead of mediump. Signed-off-by: Bryan O'Donoghue Acked-by: Kieran Bingham --- include/libcamera/internal/shaders/RGB.frag | 2 +- include/libcamera/internal/shaders/YUV_2_planes.frag | 2 +- include/libcamera/internal/shaders/YUV_3_planes.frag | 2 +- include/libcamera/internal/shaders/YUV_packed.frag | 2 +- include/libcamera/internal/shaders/bayer_1x_packed.frag | 2 +- include/libcamera/internal/shaders/bayer_unpacked.frag | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/shaders/RGB.frag b/include/libcamera/internal/shaders/RGB.frag index 4c374ac9..72439589 100644 --- a/include/libcamera/internal/shaders/RGB.frag +++ b/include/libcamera/internal/shaders/RGB.frag @@ -6,7 +6,7 @@ */ #ifdef GL_ES -precision mediump float; +precision highp float; #endif varying vec2 textureOut; diff --git a/include/libcamera/internal/shaders/YUV_2_planes.frag b/include/libcamera/internal/shaders/YUV_2_planes.frag index 1d5d1206..d286f117 100644 --- a/include/libcamera/internal/shaders/YUV_2_planes.frag +++ b/include/libcamera/internal/shaders/YUV_2_planes.frag @@ -6,7 +6,7 @@ */ #ifdef GL_ES -precision mediump float; +precision highp float; #endif varying vec2 textureOut; diff --git a/include/libcamera/internal/shaders/YUV_3_planes.frag b/include/libcamera/internal/shaders/YUV_3_planes.frag index 8f788e90..8e3e0b4a 100644 --- a/include/libcamera/internal/shaders/YUV_3_planes.frag +++ b/include/libcamera/internal/shaders/YUV_3_planes.frag @@ -6,7 +6,7 @@ */ #ifdef GL_ES -precision mediump float; +precision highp float; #endif varying vec2 textureOut; diff --git a/include/libcamera/internal/shaders/YUV_packed.frag b/include/libcamera/internal/shaders/YUV_packed.frag index b9ef9d41..3c9e3e39 100644 --- a/include/libcamera/internal/shaders/YUV_packed.frag +++ b/include/libcamera/internal/shaders/YUV_packed.frag @@ -6,7 +6,7 @@ */ #ifdef GL_ES -precision mediump float; +precision highp float; #endif varying vec2 textureOut; diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag index f53f5575..19b13ad0 100644 --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag @@ -20,7 +20,7 @@ */ #ifdef GL_ES -precision mediump float; +precision highp float; #endif /* diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag index 7e35ca88..aa7a1b00 100644 --- a/include/libcamera/internal/shaders/bayer_unpacked.frag +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag @@ -16,7 +16,7 @@ Copyright (C) 2021, Linaro //Pixel Shader #ifdef GL_ES -precision mediump float; +precision highp float; #endif /** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/ From patchwork Wed Oct 15 01:22:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24674 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 33674C3334 for ; Wed, 15 Oct 2025 01:23:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 932D960686; Wed, 15 Oct 2025 03:23:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="OZ2d4EmQ"; dkim-atps=neutral Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D611560626 for ; Wed, 15 Oct 2025 03:23:24 +0200 (CEST) Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-b4aed12cea3so947566766b.1 for ; Tue, 14 Oct 2025 18:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491404; x=1761096204; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3sraFz/ECz/08gX1UxD7qCQLpBOGxyxdQpxiRp03TY8=; b=OZ2d4EmQIeZUTnxdSmZc0bpalXJvXMjGMWVsx2DvAqf2ic5Ee8pbJ8/NLMzY0J3H5C hJVWQbWDgySNNf7m8uTHbp/OfOWCH/eJ71S4l8+Q4c6UmS17SOGA6isZ8M2lbbqBWbTX M3Ifl3SA1a3MkKpKZ9BjzxWKsGqI9MbIQyi6B0fz7ZAVuk6oRdt3mJJmEUxQkX2MGkvT gXlR3v7pOUf2hcH5BTpXKe4fcLDz4Ba3lr0VvQoANDehUWcpJHWfYGntHsgQgcSVXXxP 6TjeBJHWP8dRlsN0rlUCe3GgMh2IfGpHYfuTLuHZRuwFx5xYfEHG5jdht1bftIaZ1mRm 5yww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491404; x=1761096204; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3sraFz/ECz/08gX1UxD7qCQLpBOGxyxdQpxiRp03TY8=; b=Sh5recVQss2rUpA8pqQYbd5VhbUwO/i7MwFJALAU38EtgSkZSnj9GmKSka29IUmuve UMnIKDVGcxOQHAcdJ6NcioWx2k/gDGLhhmXiE8/M2UIECPAY8FOpvYScPeoDg6tNObz5 wDDpqTMhLa2P5sDXNAiWwinkLuUUkOAt87zwSSr04OVgxY6SdKpcCUceqycjjWcACheh 6A2ErW/9V4udTHZmxhuVATH8JNt5X4flKoNbTeY/waLivHIXHAYnGHkvgluZ2f9KBHPy oFnTgDVuKeTHtFYUbJHjE+6scPZkoM0IBt052Y4VmsXKzJoyk96wKm+7AS98tK8NB3vo AxnQ== X-Gm-Message-State: AOJu0Yz6JnPe+bVH8wU93RtJLRFfGrGhfk/4/Cq0apNhG94rxosncWcu atnw0cVVhsv+GFy4GEzx9pQDWWDWv4Yg57wzHrr9xI7RyWXTqnCn4wJFFJImh+KaQv2L0FKJGYF nsBEx X-Gm-Gg: ASbGncu/n+rtZEkQMbRJUUF6YefQrjh4MroaKadkOE4Y5JBiyr8xqxjPABGfQ+IHsam 8YSH/0DWOgUW1vMwrGA7eEWwMwEuSqvCy15mTmYK0552xiV34reuJNTsPusq1dJrkmFytDO+FP9 GnRFxArFeZbVLxlKMPGBv3JsoY6ZKOcvsh2TRee7sHz3hcPSLny3F9Ru1IMahsCqzk5FoEWpT5k xABbmtPg7cIoPL5/FIKTZGAfzv59OMQjl7nDr20m71nDt7J4r3lKrzvAOJ7JkQaiIY40wII2FDI u4jkzobhx4thPDzVrB4ngDjpnhnjUeWDcpRhG+Vfpg99X2vbKr5kly3r9f0sK0Av4QcKvDBStkd h0os8AOhOeZ9abXFi0cCg4rLKlMsZiIKDYc3U2yGxz5+Vw0MFkFkAqy5YbHXS+BHfFe1CTBMfWG JPnq7wOueY5Jt0r57ffy4/CszpKQeomdeCRQ+DeVQN X-Google-Smtp-Source: AGHT+IGKEo/LXzvl1qrZ5I8z5+saAM5ZJ/Yjlnw0Ds112IFVoUeE20d9QlJrzLNmjBZiiew/0TIeFg== X-Received: by 2002:a17:907:da2:b0:b3c:de0e:7091 with SMTP id a640c23a62f3a-b50aa28f291mr2863547266b.8.1760491404045; Tue, 14 Oct 2025 18:23:24 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:23 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 29/39] libcamera: shaders: Extend debayer shaders to apply RGB gain values on output Date: Wed, 15 Oct 2025 02:22:41 +0100 Message-ID: <20251015012251.17508-30-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Extend out the bayer fragment shaders to take 3 x 256 byte inputs as textures from the CPU. We then use an index to the table to recover the colour-corrected values provided by the SoftIPA thread. Signed-off-by: Bryan O'Donoghue Reviewed-by: Milan Zamazal --- .../internal/shaders/bayer_1x_packed.frag | 56 +++++++++++++++++ .../internal/shaders/bayer_unpacked.frag | 62 ++++++++++++++++++- 2 files changed, 117 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag index 19b13ad0..90bd6457 100644 --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag @@ -65,6 +65,10 @@ uniform vec2 tex_step; uniform vec2 tex_bayer_first_red; uniform sampler2D tex_y; +uniform sampler2D red_param; +uniform sampler2D green_param; +uniform sampler2D blue_param; +uniform mat3 ccm; void main(void) { @@ -212,5 +216,57 @@ void main(void) vec3(patterns.y, C, patterns.x) : vec3(patterns.wz, C)); +#if defined(APPLY_CCM_PARAMETERS) + /* + * CCM is a 3x3 in the format + * + * +--------------+----------------+---------------+ + * | RedRedGain | RedGreenGain | RedBlueGain | + * +--------------+----------------+---------------+ + * | GreenRedGain | GreenGreenGain | GreenBlueGain | + * +--------------+----------------+---------------+ + * | BlueRedGain | BlueGreenGain | BlueBlueGain | + * +--------------+----------------+---------------+ + * + * Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin + * Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin + * Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin + * + * We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm); + * + * CPU + * float ccm [] = { + * RedRedGain, RedGreenGain, RedBlueGain, + * GreenRedGain, GreenGreenGain, GreenBlueGain, + * BlueRedGain, BlueGreenGain, BlueBlueGain, + * }; + * + * GPU + * ccm = { + * RedRedGain, GreenRedGain, BlueRedGain, + * RedGreenGain, GreenGreenGain, BlueGreenGain, + * RedBlueGain, GreenBlueGain, BlueBlueGain, + * } + * + * However the indexing for the mat data-type is column major hence + * ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain + * + */ + float rin, gin, bin; + rin = rgb.r; + gin = rgb.g; + bin = rgb.b; + + rgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]); + rgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]); + rgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]); + +#elif defined(APPLY_RGB_PARAMETERS) + /* Apply bayer params */ + rgb.r = texture2D(red_param, vec2(rgb.r, 0.5)).r; + rgb.g = texture2D(green_param, vec2(rgb.g, 0.5)).g; + rgb.b = texture2D(blue_param, vec2(rgb.b, 0.5)).b; +#endif + gl_FragColor = vec4(rgb, 1.0); } diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag index aa7a1b00..5955c2ea 100644 --- a/include/libcamera/internal/shaders/bayer_unpacked.frag +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag @@ -21,11 +21,17 @@ precision highp float; /** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/ uniform sampler2D tex_y; +uniform sampler2D red_param; +uniform sampler2D green_param; +uniform sampler2D blue_param; varying vec4 center; varying vec4 yCoord; varying vec4 xCoord; +uniform mat3 ccm; void main(void) { + vec3 rgb; + #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r float C = texture2D(tex_y, center.xy).r; // ( 0, 0) @@ -97,11 +103,65 @@ void main(void) { PATTERN.xw += kB.xw * B; PATTERN.xz += kF.xz * F; - gl_FragColor.rgb = (alternate.y == 0.0) ? + rgb = (alternate.y == 0.0) ? ((alternate.x == 0.0) ? vec3(C, PATTERN.xy) : vec3(PATTERN.z, C, PATTERN.w)) : ((alternate.x == 0.0) ? vec3(PATTERN.w, C, PATTERN.z) : vec3(PATTERN.yx, C)); + +#if defined(APPLY_CCM_PARAMETERS) + /* + * CCM is a 3x3 in the format + * + * +--------------+----------------+---------------+ + * | RedRedGain | RedGreenGain | RedBlueGain | + * +--------------+----------------+---------------+ + * | GreenRedGain | GreenGreenGain | GreenBlueGain | + * +--------------+----------------+---------------+ + * | BlueRedGain | BlueGreenGain | BlueBlueGain | + * +--------------+----------------+---------------+ + * + * Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin + * Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin + * Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin + * + * We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm); + * + * CPU + * float ccm [] = { + * RedRedGain, RedGreenGain, RedBlueGain, + * GreenRedGain, GreenGreenGain, GreenBlueGain, + * BlueRedGain, BlueGreenGain, BlueBlueGain, + * }; + * + * GPU + * ccm = { + * RedRedGain, GreenRedGain, BlueRedGain, + * RedGreenGain, GreenGreenGain, BlueGreenGain, + * RedBlueGain, GreenBlueGain, BlueBlueGain, + * } + * + * However the indexing for the mat data-type is column major hence + * ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain + * + */ + float rin, gin, bin; + rin = rgb.r; + gin = rgb.g; + bin = rgb.b; + + rgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]); + rgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]); + rgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]); + +#elif defined(APPLY_RGB_PARAMETERS) + /* Apply bayer params */ + rgb.r = texture2D(red_param, vec2(rgb.r, 0.5)).r; + rgb.g = texture2D(red_param, vec2(rgb.g, 0.5)).g; + rgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b; +#endif + + gl_FragColor.rgb = rgb; } From patchwork Wed Oct 15 01:22:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24675 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 5B830C3336 for ; Wed, 15 Oct 2025 01:23:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E6BA460675; Wed, 15 Oct 2025 03:23:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="dpNMUCDJ"; dkim-atps=neutral Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DC5A26063E for ; Wed, 15 Oct 2025 03:23:25 +0200 (CEST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b456d2dc440so958991066b.0 for ; Tue, 14 Oct 2025 18:23:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491405; x=1761096205; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vlxxasN0ecjXETyHLhtP9Pf8S9g55SSgsBs4xwRJHHw=; b=dpNMUCDJSqZtl/3cRwVcmJSqUksp5HRgqV6pbvIs8DcCxR0JMV1OxrIqkJaeUNCgoy YPqY+LSiRcJ+dDfY4XBBMFdkFSM1h82wHet5fuVi3KqbRxHKNQUJNkORT1eVRASRnawW 7qnzXk0igkSC00kC8feYf4JBSC2UQI47l8wYj4QgrYg9uo2LlGHaetrHrcG056nZgjPD N2o8ilnGd36QV2kZkDlg6H681yxZb7+KgUFDOyUKMxJ5pt/jo4exeVFf+7KJDsJOOW8C 0httu2yHVcFwlsuXI+zkmQdWG38kZwOkn63w8P8BHhjojw4qrvL8lofvpPOyTdkY3mHH fHgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491405; x=1761096205; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vlxxasN0ecjXETyHLhtP9Pf8S9g55SSgsBs4xwRJHHw=; b=bMkpKvQVYlj1PIYo86PBqQsg/Jcm4PVrEvUxYuBLiooxeXrZCu30oqethuo5I7F/BM NRwuQ/FfXoU21urhfkm5PrCvGxkt4VQ9KHMxXIDzpsXtL9HH8BUXGbC4H7T83jv0H10f /UzH5aHHiEA6xrFpna//saZSPsfOoUgfzIzlbOvRkxqAfMXDm7upx86QqFt+3VDl8/mr ilP0SwjuVacmBcfY4wzwjBevvOFShG/xzu+rxAydT5tqa3vY5bWm9JLkdiEpyP4uyrvf wYCLXS8qHzK6l4MdsnabBCTBZ6g3bOh7AdMwujd0wZTqYiRN7gfsMXdDQEnoeIYcZLpM h7cg== X-Gm-Message-State: AOJu0YwvXR+bBFcEU3b9/yAT0sTFrhwjauZ8EfclGp7ar0RtF5b+tgeM kdsHY3II6bYKo0IAPf+dEBFjs2UynOaMNmxVofewH0peJLXyJBFw5lmUAkyC9UpD4x91q5kamM/ lEyuP X-Gm-Gg: ASbGncvw1HpoZEo6Q64tj+l3CzoJad0x5Q1bcyxiNDRCrWV/7xoyOW1uCUxqvdE5BWC FKk9RszjTs3ztmjbL0OdUw0rsODvyk0Emas2CwGNWeNBDT9gd/JZRqloiD/UYOB2oUsqYwOk42g iuk4BEfqR3/ZVoFxyU+7jY+nJcdydTGdLfgviHqr72bOXh+9xxWI1xw50xjUUo1ijJZb2PzXtJw XZoa/NCYBqFI3PWY2nuIF3DBi2gqRBOUM1D4QVBnBAVobRdz71mGVeo1lVwCeSiGPrXa+/IhcE+ kTlvR87LTRzEq7CKquetvadVQD8cjaGr65qSDCY5pD4/aOCyOJyP20M5zYV93CZB7w2GrlTvoYa AglflD6jjdSjZ8h1kBMfL0uXQyoID7KtOs4GjG69mNk0h8CFXYZkWzYgYxeQhRdjQFPzlFHR1NB kWf4d4h5hvNgvNJZfuKMB7UH8n8BrOkCtbo23RS18/ X-Google-Smtp-Source: AGHT+IFBUJTiB1Z3S/Crac+zc8WhPxXUZ0v2LfqkzpKPezrNPgq6WOdPcTS0ZGL0dFbn85J5FyYfFA== X-Received: by 2002:a17:907:7f0e:b0:b3f:33f6:fb57 with SMTP id a640c23a62f3a-b50a9d59a3bmr2596712266b.9.1760491405031; Tue, 14 Oct 2025 18:23:25 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:24 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 30/39] libcamera: shaders: Extend bayer shaders to support swapping R and B on output Date: Wed, 15 Oct 2025 02:22:42 +0100 Message-ID: <20251015012251.17508-31-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" We can easily facilitate swapping R and B on output. Pivot on an environment define for this purpose. Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue Acked-by: Kieran Bingham --- include/libcamera/internal/shaders/bayer_1x_packed.frag | 4 ++++ include/libcamera/internal/shaders/bayer_unpacked.frag | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag index 90bd6457..c0632eb1 100644 --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag @@ -268,5 +268,9 @@ void main(void) rgb.b = texture2D(blue_param, vec2(rgb.b, 0.5)).b; #endif +#if defined (SWAP_BLUE) + gl_FragColor = vec4(rgb.bgr, 1.0); +#else gl_FragColor = vec4(rgb, 1.0); +#endif } diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag index 5955c2ea..74ce1509 100644 --- a/include/libcamera/internal/shaders/bayer_unpacked.frag +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag @@ -163,5 +163,9 @@ void main(void) { rgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b; #endif - gl_FragColor.rgb = rgb; +#if defined (SWAP_BLUE) + gl_FragColor = vec4(rgb.bgr, 1.0); +#else + gl_FragColor = vec4(rgb, 1.0); +#endif } From patchwork Wed Oct 15 01:22:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24676 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 A0609BF415 for ; Wed, 15 Oct 2025 01:23:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0F7156067F; Wed, 15 Oct 2025 03:23:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="NagJ5X/M"; dkim-atps=neutral Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DDAFF60648 for ; Wed, 15 Oct 2025 03:23:26 +0200 (CEST) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-b403bb7843eso1253493166b.3 for ; Tue, 14 Oct 2025 18:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491406; x=1761096206; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3pLj5P6YPZYgBGgXFC8NMxiBkk93rrF9W+BqVEKVjMU=; b=NagJ5X/MG0kR8fwnmhFSZ/ha5G15EHSKDvZZYG1PcdBnwPiaGFBf1mxgx8pXccuGQ+ raw1aRRwTi4xbWUFkw1SAqk8y2kssj1sfhz/YZvvmUnpvLco8PRBXi9AMyzXyYvIxLwr WnUIjIP+XFsctGOfqOC17LspzJ9RuleiWXPjcd9Klfpmc5lKc0BeYbUSPAVtsoDzF6Zj W1j37FaGMnaCOdhEcESmzCD9/E0Mbu9FswTShWUnjmsJBobAYLg6r9ikWtvw7yT948ih kg/oNdA61lH1kstcfYF2xUPc1fIWq3eU258tdq1jwaRV39gj/suk4Davb3dEFO9XtUz1 7loA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491406; x=1761096206; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3pLj5P6YPZYgBGgXFC8NMxiBkk93rrF9W+BqVEKVjMU=; b=OwOO+/eYGiLpvlLTkucPVJXSlL+8je0xzjB0Xv1Ii5XJIH4mD7JXgq9wjapKtplQl0 8CTWz9q0MhbbHdhMCGfm5BJKQp4KlmPzC3jwEW7xctpgs0AUvQ76ssZsJa/9cOwMZg5S t5j4jxqn8Mqcd1IagfQ8S0SZRiKTWfbCO0vAXXaHyW3rzgQEAHYF2e84DIZQv2NcN/Pk KFxzgnIjUFNHG+mEQPRVbo9z+fOIXQuMcGZ6zc666+J6QXiy8Bramc6i99J9stR7GGCq Qnr2lb0DZlsd3VlhjHZwkDisno3BWMATcdcXjgUIWmfAEXpvRfekZfF5J+NsFZLFRw+w 7ZbQ== X-Gm-Message-State: AOJu0YzdHq3KbkLDmSakwFD25c/bnAUCbn4hOwlQObMyCwH5V6s3L2/s 730rOQJnWPVphhM4PIUaXs5Ht0CayYVVsnhBSHaIec8dZ84NMqvMT/7x+l3TqeqN6UwAn1PzBW/ y0ssn X-Gm-Gg: ASbGncujXLIrjhMkSVpNSU1gOTKBd9eezmMvrhi7ro1o5cOOLbmwqkFDrl/WTTDbA8z /9oaQnlJZl2YUnn2RZ3l53JcHpSuwBqB5CUSezEULUERHNGFdpqONSzy6Y/3X+UXAo+HgfEx7hA qbjdMwxQyQtBMVz31O+M9SI2Ev3wtEDBBWDv9gKC6tEfFmo6z32QW702hDw5+tiPQ3ohLqfDlqN jzmyr+XB4qhKoZQz9khpnQzWv1Iu4MSNO2o+nW+mGZEDa38Xc5tvxV3hDkpIuSqT/LwYnpLDtdh 3tgAEEbaGzFwcGV+js97pDbEn0DDAwCFcnDzuPZBmBzpdrAvE8wBzwg7CmruvaW3xtLpQ31Gl+m bDvoMAkBPmjDoVLXKzyt9fzBxLMh0G1pqJ1LHCsXZ0Froi/vISs0eE++kPelKALz9/raKDctXJr GR3Ob67S0aF1A85TZ2ZLrM3gFZNjEAl6hMVnGwtSAQ X-Google-Smtp-Source: AGHT+IFifMKAX2rD3sBzL7INia4PQrpoG4UoWxv/0uLFcpQHI3ea7BAml0xfEZUJkhOQJH6cGBDZ8A== X-Received: by 2002:a17:907:1c0f:b0:b4b:dd7e:65f2 with SMTP id a640c23a62f3a-b50aa48d34fmr2549706366b.5.1760491406039; Tue, 14 Oct 2025 18:23:26 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:25 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 31/39] libcamera: shaders: Fix neighbouring positions in 8-bit debayering Date: Wed, 15 Oct 2025 02:22:43 +0100 Message-ID: <20251015012251.17508-32-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" From: Milan Zamazal When accessing a texture position in a shader, the pixel with the nearest centre to the specified texture coordinates (as mandated by specifying GL_NEAREST parameter) is taken. The current vertex shader determines the positions of the neighbouring pixels by adding the provided texture steps to the exact centre pixel coordinates. But this places the computed coordinates, from the point of view of GL_NEAREST, exactly between the pixels and is thus prone to floating point inaccuracies. Wrong neighbouring pixel coordinates may be used, resulting in artefacts in the output image. Let's fix the problem by shifting the initial coordinates a bit from the pixel border. Signed-off-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/shaders/bayer_unpacked.vert | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/shaders/bayer_unpacked.vert b/include/libcamera/internal/shaders/bayer_unpacked.vert index fb5109ee..fc1cf89f 100644 --- a/include/libcamera/internal/shaders/bayer_unpacked.vert +++ b/include/libcamera/internal/shaders/bayer_unpacked.vert @@ -44,10 +44,10 @@ void main(void) { center.xy = textureIn; center.zw = textureIn * tex_size + tex_bayer_first_red; - xCoord = center.x + vec4(-2.0 * tex_step.x, - -tex_step.x, tex_step.x, 2.0 * tex_step.x); - yCoord = center.y + vec4(-2.0 * tex_step.y, - -tex_step.y, tex_step.y, 2.0 * tex_step.y); + xCoord = center.x + 0.1 * tex_step.x + + vec4(-2.0 * tex_step.x, -tex_step.x, tex_step.x, 2.0 * tex_step.x); + yCoord = center.y + 0.1 * tex_step.y + + vec4(-2.0 * tex_step.y, -tex_step.y, tex_step.y, 2.0 * tex_step.y); gl_Position = proj_matrix * vertexIn; } From patchwork Wed Oct 15 01:22:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24677 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 A8093C3332 for ; Wed, 15 Oct 2025 01:23:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4823560678; Wed, 15 Oct 2025 03:23:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="pZzSoDx0"; dkim-atps=neutral Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BEA9F60624 for ; Wed, 15 Oct 2025 03:23:27 +0200 (CEST) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-b456d2dc440so958993966b.0 for ; Tue, 14 Oct 2025 18:23:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491407; x=1761096207; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0a0SpIVpVr0hxUQRveXDMZ3Mx6oPKpjRyYRzS2puLKY=; b=pZzSoDx0so0FL1yCVECyJp5egkJjG/0w6yRtlulRXXq4vbZyE+Bn3RhjHDpi5kgn5b jH8ANKXPOdBmcg22zp1zrdSmylsV6Y1Yih+QL5MsqLqn2Z4+6XECnnTlwO/ADP+HC1yE Ahci/bM4p0hwRXyZJPrpTXYrjyxHHCdiOXEKxmTCiCwBEsc4ju95TisQPzDizKOoKr+/ vg3NzIhQD6mkyABFeGOANxBD83eTn3LdVGRfLUaZC4nOywunzqkZTLZZgO9Agi+jy5We uBqlTv0Y4uANeCXuthTy6w7SSXY51CUj/CMLGNKW663rKQgH9ntOfR6bd+pLAUTmBZAB x0Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491407; x=1761096207; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0a0SpIVpVr0hxUQRveXDMZ3Mx6oPKpjRyYRzS2puLKY=; b=g6GYbzbAEPeElS+1qs0l70JOuJKEfI2RFN9kdnN2Dm/u2DUtA75/MyIGkGuDpZErYF 9AtZM3Ke2y01R0R1Eg1EebX7ybItvl15XGC4AfM483ejRrYmu6n9fEUmd/NOpaZCACic ShPVa2VnBMC6v+cWDsioYbp3Ug5Vpo+oHPekZhaDYH9PUWcDA9u33N3j6ORkzECsJxMe peaPR5WAxLij789UpniOhB9te6n3e+QnQCfwDDbBMLV0dF00q6hYbEs0T5ET07iCI9qL PKwbNaYThoJzDtsFVXLaC0J/Ze2VFASw0qscOU9404BxW/0DGqECv2m+Sf26U3kFpxIx tzKQ== X-Gm-Message-State: AOJu0YxKLJZOBbJgXHItaeh5r1OnGU1qCi9LUKHfE3fXADZVSvGvJlZg Dtxf8CjdywRNfQ2zeIXFt71g2WOS4/4BqkuS51yr4IkkiO4T0U72vBozk3w3MQThCf8S2W6q1Nm c1tXW X-Gm-Gg: ASbGncs1vKT99mo8YjBfqhkFbQnUii6bkGqxa1+GMZ7xbkJ30r4NFDfHOoTGH/H5bz4 aijGKFGs5oI2jXUmohrIrPkS0r1C9BaCZopQ/g4SZ2nS175G1o0ezR/hpqbyul1lAbAgNDCeDfG S9IGsuRNaBsmxpVUqywlC5d3/DevZqxKS6c2tyS/2Q0qzcSHjnpY2a/1BUgACBo/42hvjK/DTt4 uf1Z3QNzrGqnmLTv10iEMEAF6ssxENMNc0JMGXOsiIAhF84vOHsX2wc6LJM69UH5MstRttXbbPs iVd5499ddrrc7CnevJreIZ056CdKfF7uQo2nDFC1rrlzqd3b0Of9Cfeuuvc0WT84SOEiPjJGZ/F +RvvfcgmRTXsnPfsrvuR5Ibat8j2Np/aPEAqxXkew4oXZmdeoExuiD87RoHAN4t4KhpN65KqAk1 pCGCJc3WYtZrFjy0QAtiXEHy7k0vcwhw== X-Google-Smtp-Source: AGHT+IHdlDXjXzQs5aEAuJWNVhsBqkg1ZbzKVlpdEnbxEExsFRmVqMlLLMs3Xwt24QjGrgqax/ENYg== X-Received: by 2002:a17:906:c105:b0:b3e:907c:9e26 with SMTP id a640c23a62f3a-b50ac5cfaf7mr2798052766b.59.1760491406997; Tue, 14 Oct 2025 18:23:26 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:26 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 32/39] libcamera: shaders: Add support for Auto White Balance gains Date: Wed, 15 Oct 2025 02:22:44 +0100 Message-ID: <20251015012251.17508-33-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add the ability to apply a vec3 AWB array against the demosaiced data prior to application of colour correction data. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/shaders/bayer_1x_packed.frag | 6 ++++++ include/libcamera/internal/shaders/bayer_unpacked.frag | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag index c0632eb1..8b35dd63 100644 --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag @@ -69,6 +69,7 @@ uniform sampler2D red_param; uniform sampler2D green_param; uniform sampler2D blue_param; uniform mat3 ccm; +uniform vec3 awb; void main(void) { @@ -216,6 +217,11 @@ void main(void) vec3(patterns.y, C, patterns.x) : vec3(patterns.wz, C)); + /* Apply white balance before colour correction matrix */ + rgb.r = rgb.r * awb.r; + rgb.g = rgb.g * awb.g; + rgb.b = rgb.b * awb.b; + #if defined(APPLY_CCM_PARAMETERS) /* * CCM is a 3x3 in the format diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag index 74ce1509..37bd4812 100644 --- a/include/libcamera/internal/shaders/bayer_unpacked.frag +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag @@ -28,6 +28,7 @@ varying vec4 center; varying vec4 yCoord; varying vec4 xCoord; uniform mat3 ccm; +uniform vec3 awb; void main(void) { vec3 rgb; @@ -111,6 +112,11 @@ void main(void) { vec3(PATTERN.w, C, PATTERN.z) : vec3(PATTERN.yx, C)); + /* Apply white balance before colour correction matrix */ + rgb.r = rgb.r * awb.r; + rgb.g = rgb.g * awb.g; + rgb.b = rgb.b * awb.b; + #if defined(APPLY_CCM_PARAMETERS) /* * CCM is a 3x3 in the format From patchwork Wed Oct 15 01:22:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24678 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 E08EEC3264 for ; Wed, 15 Oct 2025 01:23:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7A54D6068A; Wed, 15 Oct 2025 03:23:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="uhccCtUO"; dkim-atps=neutral Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7113960642 for ; Wed, 15 Oct 2025 03:23:29 +0200 (CEST) Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-b3ee18913c0so965038166b.3 for ; Tue, 14 Oct 2025 18:23:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491409; x=1761096209; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lMGBpzK3OkJtSdvUuSipgHSU+9RjPOhaix3e0An8lZU=; b=uhccCtUOq5Thr4f4SoX37syfJhwSYXClnjlTsq8UvSlivd8Sq/VBvVUPWmVw2NuSvM HqKujD6XSDIjju5zHprQ7Gz7kxeCOf8Ll+06BD9tQIfI9KcJKm7P7xn6KN4VsWWJeA/z VID7gQh91uv/A7LfBmVUm7wi6TRnVF2xPW3SyOZshR/h0BksTQh2xDgJ/tyMV9OH7ieK vdE13DECBIWqrcvsq8QX5TWFmMXv9Km2Ke7e2OHV9vAqeW0oZRZ1IS95Ecp32/laehGe 69nB/iK4wa1/vi+FMkTFfHIVNiU2DCudDwEDvdoiIs6ReQgZXzpAM0YmAn07eiFlGVIy 2Grg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491409; x=1761096209; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lMGBpzK3OkJtSdvUuSipgHSU+9RjPOhaix3e0An8lZU=; b=P5w9Y4OxFSbaEqwcn0Z/dlOA7fbii55pqDbeS82RNkaQUxpD/l2p4ZWGh3WpB50+cF BiSak2eXaPfQSTKY5UaLrLUaRFHtcoEExcSJ9TWMyNP9qFsXrxE9a+HOb9p5wKCJnYOd sxpo/stTT9VayTaoDsJPzKgMWtcaEIPp4Oz2otoY1/Za9bsaRF3L8CY7nD8YbBp62lWu ZOSj8isVCItM0P6iwdQ794IWMSGnHR/Q02g4zqrkw/fGlLJ6E/pZ699IGWtFAvgJKaO3 J0l+LCiMWjBv3neljIPL8PE1phMhsrS+cfOwZB0Ui/GeBAtdonzfvILzCUza7pwmh6oG 8rJg== X-Gm-Message-State: AOJu0Yx1uD1ss4LG/U/t2yuZB67iyX7rQJlEbAh1aRmn0ANaXPFo5vwM PzhqQRjCUCPN36ncyc+zWAtsn/uaQL3cOCRj0EeFdpkEPMaA19PWrrhkLdegyzK7iUOTMOaSFib 5MGVR X-Gm-Gg: ASbGnct0fF1wIq+sDjbwzrlssKCWfxQfhWNIQ7HAPMrRpAkRcV4wg6NMrWRWebqsICq manbhHpMfkUPV30Zrw1U3mji5j/xCy4scPriNjX9czR5whTZveDAoRH1xUHQ64sUB3DA/MGqiV4 NLnHUlrsIGVm6hii3rF4tNd1VbOG8tzoc6P4Lhamu3phRTmFuc/rVAS//1ZwKRVY4sCqRPmMkYJ KI7sTv+aLPbMACaVyI9GEZpj799sdQXorO59DIjTUeORBq7Cn51ycPySM7enBBBoi/eeftHMvD5 QQTJ5EtX9vYRU+4ytYNXlNHyqA7o82CQLIVamwsWc1/j/x5eJUtMuir/v96YGvQFMbSMoPLOHnR lnFzm0ajAIChiRsYFWS7/4M0ERZkblRA4PPZGshuGJPeJzBkkjtUbZlB0/DTIoxQBxo/3A9OKn5 fSEfDMNczk4now4VS0Omc6LkKA53QoS4G5lJf8Lm8r X-Google-Smtp-Source: AGHT+IF0D67yUzB9S/l0/zdiASAjK8lOXrfwJ6WtzOMN5pGn/zj25JlSuUX0c1xlChAtCNJDkxb3Iw== X-Received: by 2002:a17:907:9486:b0:b2d:a873:38d with SMTP id a640c23a62f3a-b50abed1b44mr3023818066b.43.1760491408540; Tue, 14 Oct 2025 18:23:28 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:27 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 33/39] libcamera: software_isp: debayer_egl: Add an eGL debayer class Date: Wed, 15 Oct 2025 02:22:45 +0100 Message-ID: <20251015012251.17508-34-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a class to run the existing glsl debayer shaders on a GBM surface. Signed-off-by: Bryan O'Donoghue libcamera: software_isp: debayer_egl: Extend logic to enable application of softISP RGB debayer params The existing SoftISP calculates RGB gain values as a lookup table of 256 values which shifts for each frame depending on the required correction. We can pass the required tables into the debayer shaders as textures, one texture for R, G and B respectively. The debayer shader will do its debayer interpolation and then if the appropriate define is specified use the calculated R, G and B values as indexes into our bayer colour gain table. Signed-off-by: Bryan O'Donoghue Acked-by: Kieran Bingham --- src/libcamera/software_isp/debayer_egl.cpp | 648 +++++++++++++++++++++ src/libcamera/software_isp/debayer_egl.h | 174 ++++++ src/libcamera/software_isp/meson.build | 8 + 3 files changed, 830 insertions(+) create mode 100644 src/libcamera/software_isp/debayer_egl.cpp create mode 100644 src/libcamera/software_isp/debayer_egl.h diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp new file mode 100644 index 00000000..a24dd067 --- /dev/null +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -0,0 +1,648 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Linaro Ltd. + * + * Authors: + * Bryan O'Donoghue + * + * debayer_cpu.cpp - EGL based debayering class + */ + +#include +#include +#include + +#include + +#include "libcamera/base/utils.h" +#include "libcamera/internal/glsl_shaders.h" +#include "debayer_egl.h" + +namespace libcamera { + +DebayerEGL::DebayerEGL(std::unique_ptr stats, const GlobalConfiguration &configuration) + : Debayer(configuration), stats_(std::move(stats)) +{ + eglImageBayerIn_ = eglImageBayerOut_= eglImageRedLookup_ = eglImageBlueLookup_ = eglImageGreenLookup_ = NULL; +} + +DebayerEGL::~DebayerEGL() +{ + if (eglImageBlueLookup_) + delete eglImageBlueLookup_; + + if (eglImageGreenLookup_) + delete eglImageGreenLookup_; + + if (eglImageRedLookup_) + delete eglImageRedLookup_; + + if (eglImageBayerOut_) + delete eglImageBayerOut_; + + if (eglImageBayerIn_) + delete eglImageBayerIn_; +} + +int DebayerEGL::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config) +{ + BayerFormat bayerFormat = + BayerFormat::fromPixelFormat(inputFormat); + + if ((bayerFormat.bitDepth == 8 || bayerFormat.bitDepth == 10) && + bayerFormat.packing == BayerFormat::Packing::None && + isStandardBayerOrder(bayerFormat.order)) { + config.bpp = (bayerFormat.bitDepth + 7) & ~7; + config.patternSize.width = 2; + config.patternSize.height = 2; + config.outputFormats = std::vector({ formats::XRGB8888, + formats::ARGB8888, + formats::XBGR8888, + formats::ABGR8888 }); + return 0; + } + + if (bayerFormat.bitDepth == 10 && + bayerFormat.packing == BayerFormat::Packing::CSI2 && + isStandardBayerOrder(bayerFormat.order)) { + config.bpp = 10; + config.patternSize.width = 4; /* 5 bytes per *4* pixels */ + config.patternSize.height = 2; + config.outputFormats = std::vector({ formats::XRGB8888, + formats::ARGB8888, + formats::XBGR8888, + formats::ABGR8888 }); + return 0; + } + + LOG(Debayer, Error) + << "Unsupported input format " << inputFormat.toString(); + + return -EINVAL; +} + +int DebayerEGL::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config) +{ + if (outputFormat == formats::XRGB8888 || outputFormat == formats::ARGB8888 || + outputFormat == formats::XBGR8888 || outputFormat == formats::ABGR8888) { + config.bpp = 32; + return 0; + } + + LOG(Debayer, Error) + << "Unsupported output format " << outputFormat.toString(); + + return -EINVAL; +} + +int DebayerEGL::getShaderVariableLocations(void) +{ + attributeVertex_ = glGetAttribLocation(programId_, "vertexIn"); + attributeTexture_ = glGetAttribLocation(programId_, "textureIn"); + + textureUniformBayerDataIn_ = glGetUniformLocation(programId_, "tex_y"); + textureUniformRedLookupDataIn_ = glGetUniformLocation(programId_, "red_param"); + textureUniformGreenLookupDataIn_ = glGetUniformLocation(programId_, "green_param"); + textureUniformBlueLookupDataIn_ = glGetUniformLocation(programId_, "blue_param"); + ccmUniformDataIn_ = glGetUniformLocation(programId_, "ccm"); + awbUniformDataIn_ = glGetUniformLocation(programId_, "awb"); + + textureUniformStep_ = glGetUniformLocation(programId_, "tex_step"); + textureUniformSize_ = glGetUniformLocation(programId_, "tex_size"); + textureUniformStrideFactor_ = glGetUniformLocation(programId_, "stride_factor"); + textureUniformBayerFirstRed_ = glGetUniformLocation(programId_, "tex_bayer_first_red"); + textureUniformProjMatrix_ = glGetUniformLocation(programId_, "proj_matrix"); + + LOG(Debayer, Debug) << "vertexIn " << attributeVertex_ << " textureIn " << attributeTexture_ + << " tex_y " << textureUniformBayerDataIn_ + << " red_param " << textureUniformRedLookupDataIn_ + << " green_param " << textureUniformGreenLookupDataIn_ + << " blue_param " << textureUniformBlueLookupDataIn_ + << " ccm " << ccmUniformDataIn_ + << " awb " << awbUniformDataIn_ + << " tex_step " << textureUniformStep_ + << " tex_size " << textureUniformSize_ + << " stride_factor " << textureUniformStrideFactor_ + << " tex_bayer_first_red " << textureUniformBayerFirstRed_ + << " proj_matrix " << textureUniformProjMatrix_; + return 0; +} + +int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputFormat) +{ + std::vector shaderEnv; + unsigned int fragmentShaderDataLen; + unsigned char *fragmentShaderData; + unsigned int vertexShaderDataLen; + unsigned char *vertexShaderData; + GLenum err; + + // Target gles 100 glsl requires "#version x" as first directive in shader + egl_.pushEnv(shaderEnv, "#version 100"); + + // Specify GL_OES_EGL_image_external + egl_.pushEnv(shaderEnv, "#extension GL_OES_EGL_image_external: enable"); + + // Tell shaders how to re-order output taking account of how the + // pixels are actually stored by GBM + switch (outputFormat) { + case formats::ARGB8888: + case formats::XRGB8888: + break; + case formats::ABGR8888: + case formats::XBGR8888: + egl_.pushEnv(shaderEnv, "#define SWAP_BLUE"); + break; + default: + goto invalid_fmt; + } + + // Pixel location parameters + glFormat_ = GL_LUMINANCE; + bytesPerPixel_ = 1; + switch (inputFormat) { + case libcamera::formats::SBGGR8: + case libcamera::formats::SBGGR10_CSI2P: + case libcamera::formats::SBGGR12_CSI2P: + firstRed_x_ = 1.0; + firstRed_y_ = 1.0; + break; + case libcamera::formats::SGBRG8: + case libcamera::formats::SGBRG10_CSI2P: + case libcamera::formats::SGBRG12_CSI2P: + firstRed_x_ = 0.0; + firstRed_y_ = 1.0; + break; + case libcamera::formats::SGRBG8: + case libcamera::formats::SGRBG10_CSI2P: + case libcamera::formats::SGRBG12_CSI2P: + firstRed_x_ = 1.0; + firstRed_y_ = 0.0; + break; + case libcamera::formats::SRGGB8: + case libcamera::formats::SRGGB10_CSI2P: + case libcamera::formats::SRGGB12_CSI2P: + firstRed_x_ = 0.0; + firstRed_y_ = 0.0; + break; + default: + goto invalid_fmt; + break; + }; + + // Shader selection + switch (inputFormat) { + case libcamera::formats::SBGGR8: + case libcamera::formats::SGBRG8: + case libcamera::formats::SGRBG8: + case libcamera::formats::SRGGB8: + fragmentShaderData = bayer_unpacked_frag; + fragmentShaderDataLen = bayer_unpacked_frag_len; + vertexShaderData = bayer_unpacked_vert; + vertexShaderDataLen = bayer_unpacked_vert_len; + break; + case libcamera::formats::SBGGR10_CSI2P: + case libcamera::formats::SGBRG10_CSI2P: + case libcamera::formats::SGRBG10_CSI2P: + case libcamera::formats::SRGGB10_CSI2P: + egl_.pushEnv(shaderEnv, "#define RAW10P"); + if (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) { + fragmentShaderData = bayer_unpacked_frag; + fragmentShaderDataLen = bayer_unpacked_frag_len; + vertexShaderData = bayer_unpacked_vert; + vertexShaderDataLen = bayer_unpacked_vert_len; + glFormat_ = GL_RG; + bytesPerPixel_ = 2; + } else { + fragmentShaderData = bayer_1x_packed_frag; + fragmentShaderDataLen = bayer_1x_packed_frag_len; + vertexShaderData = identity_vert; + vertexShaderDataLen = identity_vert_len; + } + break; + case libcamera::formats::SBGGR12_CSI2P: + case libcamera::formats::SGBRG12_CSI2P: + case libcamera::formats::SGRBG12_CSI2P: + case libcamera::formats::SRGGB12_CSI2P: + egl_.pushEnv(shaderEnv, "#define RAW12P"); + if (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) { + fragmentShaderData = bayer_unpacked_frag; + fragmentShaderDataLen = bayer_unpacked_frag_len; + vertexShaderData = bayer_unpacked_vert; + vertexShaderDataLen = bayer_unpacked_vert_len; + glFormat_ = GL_RG; + bytesPerPixel_ = 2; + } else { + fragmentShaderData = bayer_1x_packed_frag; + fragmentShaderDataLen = bayer_1x_packed_frag_len; + vertexShaderData = identity_vert; + vertexShaderDataLen = identity_vert_len; + } + break; + default: + goto invalid_fmt; + break; + }; + + if (ccmEnabled_) { + // Run the CCM if available + egl_.pushEnv(shaderEnv, "#define APPLY_CCM_PARAMETERS"); + } else { + // Flag to shaders that we have parameter gain tables + egl_.pushEnv(shaderEnv, "#define APPLY_RGB_PARAMETERS"); + } + + if (egl_.compileVertexShader(vertexShaderId_, vertexShaderData, vertexShaderDataLen, shaderEnv)) + goto compile_fail; + + if (egl_.compileFragmentShader(fragmentShaderId_, fragmentShaderData, fragmentShaderDataLen, shaderEnv)) + goto compile_fail; + + if (egl_.linkProgram(programId_, vertexShaderId_, fragmentShaderId_)) + goto link_fail; + + egl_.dumpShaderSource(vertexShaderId_); + egl_.dumpShaderSource(fragmentShaderId_); + + /* Ensure we set the programId_ */ + egl_.useProgram(programId_); + err = glGetError(); + if (err != GL_NO_ERROR) + goto program_fail; + + if (getShaderVariableLocations()) + goto parameters_fail; + + return 0; + +parameters_fail: + LOG(Debayer, Error) << "Program parameters fail"; + return -ENODEV; + +program_fail: + LOG(Debayer, Error) << "Use program error " << err; + return -ENODEV; + +link_fail: + LOG(Debayer, Error) << "Linking program fail"; + return -ENODEV; + +compile_fail: + LOG(Debayer, Error) << "Compile debayer shaders fail"; + return -ENODEV; + +invalid_fmt: + LOG(Debayer, Error) << "Unsupported input output format combination"; + return -EINVAL; +} + +int DebayerEGL::configure(const StreamConfiguration &inputCfg, + const std::vector> &outputCfgs, + bool ccmEnabled) +{ + GLint maxTextureImageUnits; + + if (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0) + return -EINVAL; + + if (stats_->configure(inputCfg) != 0) + return -EINVAL; + + const Size &stats_pattern_size = stats_->patternSize(); + if (inputConfig_.patternSize.width != stats_pattern_size.width || + inputConfig_.patternSize.height != stats_pattern_size.height) { + LOG(Debayer, Error) + << "mismatching stats and debayer pattern sizes for " + << inputCfg.pixelFormat.toString(); + return -EINVAL; + } + + inputConfig_.stride = inputCfg.stride; + width_ = inputCfg.size.width; + height_ = inputCfg.size.height; + ccmEnabled_ = ccmEnabled; + + if (outputCfgs.size() != 1) { + LOG(Debayer, Error) + << "Unsupported number of output streams: " + << outputCfgs.size(); + return -EINVAL; + } + + if (gbmSurface_.createDevice()) + return -ENODEV; + + if (egl_.initEGLContext(&gbmSurface_)) + return -ENODEV; + + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureImageUnits); + + LOG(Debayer, Debug) << "Available fragment shader texture units " << maxTextureImageUnits; + + if (!ccmEnabled && maxTextureImageUnits < DEBAYER_EGL_MIN_SIMPLE_RGB_GAIN_TEXTURE_UNITS) { + LOG(Debayer, Error) << "Fragment shader texture unit count " << maxTextureImageUnits + << " required minimum for RGB gain table lookup " << DEBAYER_EGL_MIN_SIMPLE_RGB_GAIN_TEXTURE_UNITS + << " try using an identity CCM "; + return -ENODEV; + } + + StreamConfiguration &outputCfg = outputCfgs[0]; + SizeRange outSizeRange = sizes(inputCfg.pixelFormat, inputCfg.size); + std::tie(outputConfig_.stride, outputConfig_.frameSize) = + strideAndFrameSize(outputCfg.pixelFormat, outputCfg.size); + + if (!outSizeRange.contains(outputCfg.size) || outputConfig_.stride != outputCfg.stride) { + LOG(Debayer, Error) + << "Invalid output size/stride: " + << "\n " << outputCfg.size << " (" << outSizeRange << ")" + << "\n " << outputCfg.stride << " (" << outputConfig_.stride << ")"; + return -EINVAL; + } + + window_.x = ((inputCfg.size.width - outputCfg.size.width) / 2) & + ~(inputConfig_.patternSize.width - 1); + window_.y = ((inputCfg.size.height - outputCfg.size.height) / 2) & + ~(inputConfig_.patternSize.height - 1); + window_.width = outputCfg.size.width; + window_.height = outputCfg.size.height; + + /* + * Don't pass x,y from window_ since process() already adjusts for it. + * But crop the window to 2/3 of its width and height for speedup. + */ + stats_->setWindow(Rectangle(window_.size())); + + // Raw bayer input as texture + eglImageBayerIn_ = new eGLImage(width_, height_, 32, GL_TEXTURE0, 0); + if (!eglImageBayerIn_) + return -ENOMEM; + + // Only do the RGB lookup table textures if CCM is disabled + if (!ccmEnabled_) { + + /// RGB correction tables as 2d textures + // eGL doesn't support glTexImage1D so we do a little hack with 2D to compensate + eglImageRedLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE1, 1); + if (!eglImageRedLookup_) + return -ENOMEM; + + eglImageGreenLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE2, 2); + if (!eglImageGreenLookup_) + return -ENOMEM; + + eglImageBlueLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE3, 3); + if (!eglImageBlueLookup_) + return -ENOMEM; + } + + eglImageBayerOut_ = new eGLImage(outputCfg.size.width, outputCfg.size.height, 32, outputCfg.stride, GL_TEXTURE4, 4); + if (!eglImageBayerOut_) + return -ENOMEM; + + if (initBayerShaders(inputCfg.pixelFormat, outputCfg.pixelFormat)) + return -EINVAL; + + return 0; +} + +Size DebayerEGL::patternSize(PixelFormat inputFormat) +{ + DebayerEGL::DebayerInputConfig config; + + if (getInputConfig(inputFormat, config) != 0) + return {}; + + return config.patternSize; +} + +std::vector DebayerEGL::formats(PixelFormat inputFormat) +{ + DebayerEGL::DebayerInputConfig config; + + if (getInputConfig(inputFormat, config) != 0) + return std::vector(); + + return config.outputFormats; +} + +std::tuple +DebayerEGL::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) +{ + DebayerEGL::DebayerOutputConfig config; + + if (getOutputConfig(outputFormat, config) != 0) + return std::make_tuple(0, 0); + + /* Align stride to 256 bytes as a generic GPU memory access alignment */ + unsigned int stride = libcamera::utils::alignUp(size.width * config.bpp / 8, 256); + + return std::make_tuple(stride, stride * size.height); +} + +void DebayerEGL::setShaderVariableValues(DebayerParams ¶ms) +{ + /* + * Raw Bayer 8-bit, and packed raw Bayer 10-bit/12-bit formats + * are stored in a GL_LUMINANCE texture. The texture width is + * equal to the stride. + */ + GLfloat firstRed[] = { firstRed_x_, firstRed_y_ }; + GLfloat imgSize[] = { (GLfloat)width_, + (GLfloat)height_ }; + GLfloat Step[] = { static_cast(bytesPerPixel_) / (inputConfig_.stride - 1), + 1.0f / (height_ - 1) }; + GLfloat Stride = 1.0f; + GLfloat projIdentityMatrix[] = { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + }; + + // vertexIn - bayer_8.vert + glEnableVertexAttribArray(attributeVertex_); + glVertexAttribPointer(attributeVertex_, 2, GL_FLOAT, GL_TRUE, + 2 * sizeof(GLfloat), vcoordinates); + + // textureIn - bayer_8.vert + glEnableVertexAttribArray(attributeTexture_); + glVertexAttribPointer(attributeTexture_, 2, GL_FLOAT, GL_TRUE, + 2 * sizeof(GLfloat), tcoordinates); + + // Set the sampler2D to the respective texture unit for each texutre + // To simultaneously sample multiple textures we need to use multiple + // texture units + glUniform1i(textureUniformBayerDataIn_, eglImageBayerIn_->texture_unit_uniform_id_); + + // These values are: + // firstRed = tex_bayer_first_red - bayer_8.vert + // imgSize = tex_size - bayer_8.vert + // step = tex_step - bayer_8.vert + // Stride = stride_factor identity.vert + // textureUniformProjMatri = No scaling + glUniform2fv(textureUniformBayerFirstRed_, 1, firstRed); + glUniform2fv(textureUniformSize_, 1, imgSize); + glUniform2fv(textureUniformStep_, 1, Step); + glUniform1f(textureUniformStrideFactor_, Stride); + glUniformMatrix4fv(textureUniformProjMatrix_, 1, + GL_FALSE, projIdentityMatrix); + + LOG(Debayer, Debug) << "vertexIn " << attributeVertex_ << " textureIn " << attributeTexture_ + << " tex_y " << textureUniformBayerDataIn_ + << " red_param " << textureUniformRedLookupDataIn_ + << " green_param " << textureUniformGreenLookupDataIn_ + << " blue_param " << textureUniformBlueLookupDataIn_ + << " tex_step " << textureUniformStep_ + << " tex_size " << textureUniformSize_ + << " stride_factor " << textureUniformStrideFactor_ + << " tex_bayer_first_red " << textureUniformBayerFirstRed_; + + LOG (Debayer, Debug) << "textureUniformY_ = 0 " + << " firstRed.x " << firstRed[0] + << " firstRed.y " << firstRed[1] + << " textureUniformSize_.width " << imgSize[0] + << " textureUniformSize_.height " << imgSize[1] + << " textureUniformStep_.x " << Step[0] + << " textureUniformStep_.y " << Step[1] + << " textureUniformStrideFactor_ " << Stride + << " textureUniformProjMatrix_ " << textureUniformProjMatrix_; + + if (!ccmEnabled_) { + glUniform1i(textureUniformRedLookupDataIn_, eglImageRedLookup_->texture_unit_uniform_id_); + glUniform1i(textureUniformGreenLookupDataIn_, eglImageGreenLookup_->texture_unit_uniform_id_); + glUniform1i(textureUniformBlueLookupDataIn_, eglImageBlueLookup_->texture_unit_uniform_id_); + + egl_.createTexture2D(eglImageRedLookup_, GL_LUMINANCE, DebayerParams::kRGBLookupSize, 1, ¶ms.red); + egl_.createTexture2D(eglImageGreenLookup_, GL_LUMINANCE, DebayerParams::kRGBLookupSize, 1, ¶ms.green); + egl_.createTexture2D(eglImageBlueLookup_, GL_LUMINANCE, DebayerParams::kRGBLookupSize, 1, ¶ms.blue); + + LOG (Debayer, Debug) << "textureUniformRedLookupDataIn_ " << textureUniformRedLookupDataIn_ + << " textureUniformGreenLookupDataIn_ " << textureUniformGreenLookupDataIn_ + << " textureUniformBlueLookupDataIn_ " << textureUniformBlueLookupDataIn_; + } else { + GLfloat ccm[9] = { + params.ccm[0][0], params.ccm[0][1], params.ccm[0][2], + params.ccm[1][0], params.ccm[1][1], params.ccm[1][2], + params.ccm[2][0], params.ccm[2][1], params.ccm[2][2], + }; + glUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm); + LOG (Debayer, Debug) << " ccmUniformDataIn_ " << ccmUniformDataIn_ << " data " << params.ccm; + } + + /* Apply the IPA calculated AWB */ + glUniform3f(awbUniformDataIn_, params.gains[0], params.gains[1], params.gains[2]); + LOG (Debayer, Debug) << " awbUniformDataIn_ " << awbUniformDataIn_ << " data " << params.gains; + + return; +} + +int DebayerEGL::debayerGPU(MappedFrameBuffer &in, int out_fd, DebayerParams ¶ms) +{ + /* eGL context switch */ + egl_.makeCurrent(); + + /* Greate a standard texture input */ + egl_.createTexture2D(eglImageBayerIn_, glFormat_, inputConfig_.stride / bytesPerPixel_, height_, in.planes()[0].data()); + + /* Generate the output render framebuffer as render to texture */ + egl_.createOutputDMABufTexture2D(eglImageBayerOut_, out_fd); + + + + setShaderVariableValues(params); + glViewport(0, 0, width_, height_); + glClear(GL_COLOR_BUFFER_BIT); + glDrawArrays(GL_TRIANGLE_FAN, 0, DEBAYER_OPENGL_COORDS); + + GLenum err = glGetError(); + if (err != GL_NO_ERROR) { + LOG(eGL, Error) << "Drawing scene fail " << err; + return -ENODEV; + } else { + egl_.syncOutput(); + } + + return 0; +} + +void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) +{ + bench_.startFrame(); + + std::vector dmaSyncers; + + setParams(params); + + /* Copy metadata from the input buffer */ + FrameMetadata &metadata = output->_d()->metadata(); + metadata.status = input->metadata().status; + metadata.sequence = input->metadata().sequence; + metadata.timestamp = input->metadata().timestamp; + + MappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read); + MappedFrameBuffer out(output, MappedFrameBuffer::MapFlag::Write); + if (!in.isValid() || !out.isValid()) { + LOG(Debayer, Error) << "mmap-ing buffer(s) failed"; + goto error; + } + + if (debayerGPU(in, output->planes()[0].fd.get(), params)) { + LOG(Debayer, Error) << "debayerGPU failed"; + goto error; + } + + bench_.finishFrame(); + + metadata.planes()[0].bytesused = out.planes()[0].size(); + + /* Calculate stats for the whole frame */ + dmaSyncBegin(dmaSyncers, input, nullptr); + stats_->processFrame(frame, 0, input); + dmaSyncers.clear(); + + outputBufferReady.emit(output); + inputBufferReady.emit(input); + + return; + +error: + bench_.finishFrame(); + metadata.status = FrameMetadata::FrameError; + return; +} + +void DebayerEGL::stop() +{ + egl_.cleanUp(); +} + +SizeRange DebayerEGL::sizes(PixelFormat inputFormat, const Size &inputSize) +{ + Size patternSize = this->patternSize(inputFormat); + unsigned int borderHeight = patternSize.height; + + if (patternSize.isNull()) + return {}; + + /* No need for top/bottom border with a pattern height of 2 */ + if (patternSize.height == 2) + borderHeight = 0; + + /* + * For debayer interpolation a border is kept around the entire image + * and the minimum output size is pattern-height x pattern-width. + */ + if (inputSize.width < (3 * patternSize.width) || + inputSize.height < (2 * borderHeight + patternSize.height)) { + LOG(Debayer, Warning) + << "Input format size too small: " << inputSize.toString(); + return {}; + } + + return SizeRange(Size(patternSize.width, patternSize.height), + Size((inputSize.width - 2 * patternSize.width) & ~(patternSize.width - 1), + (inputSize.height - 2 * borderHeight) & ~(patternSize.height - 1)), + patternSize.width, patternSize.height); +} + +} /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h new file mode 100644 index 00000000..500dea27 --- /dev/null +++ b/src/libcamera/software_isp/debayer_egl.h @@ -0,0 +1,174 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2025, Bryan O'Donoghue. + * + * Authors: + * Bryan O'Donoghue + * + * debayer_opengl.h - EGL debayer header + */ + +#pragma once + +#include +#include +#include + +#define GL_GLEXT_PROTOTYPES +#define EGL_EGLEXT_PROTOTYPES +#include +#include +#include + +#include + +#include "debayer.h" + +#include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/egl.h" +#include "libcamera/internal/framebuffer.h" +#include "libcamera/internal/mapped_framebuffer.h" +#include "libcamera/internal/software_isp/benchmark.h" +#include "libcamera/internal/software_isp/swstats_cpu.h" + +namespace libcamera { + +#define DEBAYER_EGL_MIN_SIMPLE_RGB_GAIN_TEXTURE_UNITS 4 +#define DEBAYER_OPENGL_COORDS 4 + +/** + * \class DebayerEGL + * \brief Class for debayering using an EGL Shader + * + * Implements an EGL shader based debayering solution. + */ +class DebayerEGL : public Debayer +{ +public: + /** + * \brief Constructs a DebayerEGL object. + * \param[in] stats Pointer to the stats object to use. + */ + DebayerEGL(std::unique_ptr stats, const GlobalConfiguration &configuration); + ~DebayerEGL(); + + /* + * Setup the Debayer object according to the passed in parameters. + * Return 0 on success, a negative errno value on failure + * (unsupported parameters). + */ + int configure(const StreamConfiguration &inputCfg, + const std::vector> &outputCfgs, + bool ccmEnabled); + + /* + * Get width and height at which the bayer-pattern repeats. + * Return pattern-size or an empty Size for an unsupported inputFormat. + */ + Size patternSize(PixelFormat inputFormat); + + std::vector formats(PixelFormat input); + std::tuple strideAndFrameSize(const PixelFormat &outputFormat, const Size &size); + + void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params); + void stop(); + + /** + * \brief Get the file descriptor for the statistics. + * + * \return the file descriptor pointing to the statistics. + */ + const SharedFD &getStatsFD() { return stats_->getStatsFD(); } + + /** + * \brief Get the output frame size. + * + * \return The output frame size. + */ + unsigned int frameSize() { return outputConfig_.frameSize; } + + SizeRange sizes(PixelFormat inputFormat, const Size &inputSize); + +private: + static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); + static int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config); + int setupStandardBayerOrder(BayerFormat::Order order); + void pushEnv(std::vector &shaderEnv, const char *str); + int initBayerShaders(PixelFormat inputFormat, PixelFormat outputFormat); + int initEGLContext(); + int generateTextures(); + int compileShaderProgram(GLuint &shaderId, GLenum shaderType, + unsigned char *shaderData, int shaderDataLen, + std::vector shaderEnv); + int linkShaderProgram(void); + int getShaderVariableLocations(); + void setShaderVariableValues(DebayerParams ¶ms); + void configureTexture(GLuint &texture); + int debayerGPU(MappedFrameBuffer &in, int out_fd, DebayerParams ¶ms); + + // Shader program identifiers + GLuint vertexShaderId_; + GLuint fragmentShaderId_; + GLuint programId_; + enum { + BAYER_INPUT_INDEX = 0, + BAYER_OUTPUT_INDEX, + BAYER_BUF_NUM, + }; + + // Pointer to object representing input texture + eGLImage *eglImageBayerIn_; + eGLImage *eglImageBayerOut_; + + eGLImage *eglImageRedLookup_; + eGLImage *eglImageGreenLookup_; + eGLImage *eglImageBlueLookup_; + + // Shader parameters + float firstRed_x_; + float firstRed_y_; + GLint attributeVertex_; + GLint attributeTexture_; + GLint textureUniformStep_; + GLint textureUniformSize_; + GLint textureUniformStrideFactor_; + GLint textureUniformBayerFirstRed_; + GLint textureUniformProjMatrix_; + + GLint textureUniformBayerDataIn_; + + // These textures will either point to simple RGB gains or to CCM lookup tables + GLint textureUniformRedLookupDataIn_; + GLint textureUniformGreenLookupDataIn_; + GLint textureUniformBlueLookupDataIn_; + + // Represent per-frame CCM as a uniform vector of floats 3 x 3 + GLint ccmUniformDataIn_; + bool ccmEnabled_; + + // Auto white Balance + GLint awbUniformDataIn_; + + Rectangle window_; + std::unique_ptr stats_; + eGL egl_; + GBM gbmSurface_; + uint32_t width_; + uint32_t height_; + GLint glFormat_; + unsigned int bytesPerPixel_; + GLfloat vcoordinates[DEBAYER_OPENGL_COORDS][2] = { + { -1.0f, -1.0f }, + { -1.0f, +1.0f }, + { +1.0f, +1.0f }, + { +1.0f, -1.0f }, + }; + GLfloat tcoordinates[DEBAYER_OPENGL_COORDS][2] = { + { 0.0f, 0.0f }, + { 0.0f, 1.0f }, + { 1.0f, 1.0f }, + { 1.0f, 0.0f }, + }; +}; + +} /* namespace libcamera */ diff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build index 59fa5f02..c61ac7d5 100644 --- a/src/libcamera/software_isp/meson.build +++ b/src/libcamera/software_isp/meson.build @@ -2,6 +2,7 @@ softisp_enabled = pipelines.contains('simple') summary({'SoftISP support' : softisp_enabled}, section : 'Configuration') +summary({'SoftISP GPU acceleration' : gles_headless_enabled}, section : 'Configuration') if not softisp_enabled subdir_done() @@ -14,3 +15,10 @@ libcamera_internal_sources += files([ 'software_isp.cpp', 'swstats_cpu.cpp', ]) + +if softisp_enabled and gles_headless_enabled + config_h.set('HAVE_DEBAYER_EGL', 1) + libcamera_internal_sources += files([ + 'debayer_egl.cpp', + ]) +endif From patchwork Wed Oct 15 01:22:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24679 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 B8DACC3337 for ; Wed, 15 Oct 2025 01:23:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 56DB260673; Wed, 15 Oct 2025 03:23:45 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Z+bb/sCS"; dkim-atps=neutral Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4EA476065F for ; Wed, 15 Oct 2025 03:23:30 +0200 (CEST) Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-b4c89df6145so1000294766b.3 for ; Tue, 14 Oct 2025 18:23:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491409; x=1761096209; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2hWNmonLsbnIURkJ1OnH3mTtHEsLYl31d2EH9MrI6dA=; b=Z+bb/sCSIMz+ACH0RBF4Ce48FS5Lm2dLMbnIZMkRyIu79ZwJMnmy8yryD9tKH/O5Y0 edBJtM/64aIentj+enXBoAmF7Js0EpF74anGtqeEyLGugVarulIFd/g0nE6ACgWJp33/ 4DOT9imuczuLN1jcmt5lyTLl+SfjgEcOR42kMonrIwb9JAeqA1c28zm9/ZpjLjCRZ+zQ hBmBOiukWdbThlpf1Kiv2Ez2TddIEglwxkzwS3v/LqHwlWSI8JoEI670jf4JhMwModob 34iYDKxd/MUFK83f/tsxm+7ZtRhr4vThdSctiz+4xeSuQ7FY5VsMf8xOKjuvcZ/f39UB +1jA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491409; x=1761096209; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2hWNmonLsbnIURkJ1OnH3mTtHEsLYl31d2EH9MrI6dA=; b=IQrMIsxkeurF7Ore1c3wsdxoAXHr+O1UOfvQuxmjqZsgZA6cG3zytYifRvFGM4TlG0 M5NosrBAoOHYZXLLfJcpnx/whcZ7ntmKUzExq1fcs/vlXWOytjdDADJ2xt66XfJSF6rk aF7kNx0H8IithH3mvC8xmd1tfg9ZRItCE1DzpaBmLMrk0QfLNTaMC6iw00g/R3wy9WeZ pySgL3SwwG5hY+JZrx3mwGhYIqF/RRdu03ErIaEDBa9Gx0QXYP67AF+N1uLYmXU+c2oM y7n2awTG89W5ZnqJ0Q+dWiqxI6Bca9ktA9qbSizf//B4tUj42dW8dvHnJU8a6iz8woUe XRHw== X-Gm-Message-State: AOJu0YzPTocrgkXOV5GxAc4IStN4k68TiVliPqTgpvg7J2FZ0iHSV6w9 jIHoCY84GqgzazPulHm46+h/GP8qjyIhFCMVSJaIvTVnjMv4m2zQmaFP9cOXyG44t2PIVLVt/Sm F0Sa8 X-Gm-Gg: ASbGnctNPimlK8kBMlvG3fbY8NOeDnWXAt/MCATv2m40b5RLxwPArTiSEUolhsAP213 RP/pTX2+pm+OeFS8JcpZO16q/2+eL1SXa+Z1HkFDC3D8HOHSEAafWGxaOWAJcfs4Ttk5JtWOIba eu9+vK+MVnL0O4Sys2mXgh7QC4tyIJCsKTvMl/1DCrGuNB6K37HhdP5w9DbdOPceunt6EepzxSo 47Yj477Iew16imiLlcof1aga8GX6vg5Fl13lpp1RQSPsSh3bWus3e9fUkxyRtHbKd3X078Y5c2c P4cyQyQjo82AYR7FAOi/nvF+MaiKqzQaR1ek/BocTmXl2EZa3qlrcCrF4PtKw4LOPlwm1r08nTb 656LPgwXc3vzS0Wm1LkVV2K5Epi7C8UklR4HG2gn1Dc7tJOid5Z4G21PzHqo/QeqfoWRUcvlEMz Y94UEmsH+FWh5uXaaGocAHbFW8YFrzjQ== X-Google-Smtp-Source: AGHT+IHM+Q4nN2PMqJLg61wbdtIRkJDVYEEsQszxnCuCtmHf0j70BnSCovsHkpblOm4AONa6TcSTkg== X-Received: by 2002:a17:907:3daa:b0:b3f:b7ca:26c5 with SMTP id a640c23a62f3a-b50acc201a5mr2942307166b.59.1760491409532; Tue, 14 Oct 2025 18:23:29 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:29 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 34/39] libcamera: software_isp: debayer_egl: Make DebayerEGL an environment option Date: Wed, 15 Oct 2025 02:22:46 +0100 Message-ID: <20251015012251.17508-35-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" If GPUISP support is available make it so an environment variable can switch it on. Given we don't have full feature parity with CPUISP just yet on pixel format output, we should default to CPUISP mode giving the user the option to switch on GPUISP by setting LIBCAMERA_SOFTISP_MODE=gpu Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/software_isp.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 1f984a52..869f7320 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -25,6 +26,9 @@ #include "libcamera/internal/software_isp/debayer_params.h" #include "debayer_cpu.h" +#if HAVE_DEBAYER_EGL +#include "debayer_egl.h" +#endif /** * \file software_isp.cpp @@ -116,7 +120,20 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, } stats->statsReady.connect(this, &SoftwareIsp::statsReady); - debayer_ = std::make_unique(std::move(stats), configuration); +#if HAVE_DEBAYER_EGL + const char *softISPMode = utils::secure_getenv("LIBCAMERA_SOFTISP_MODE"); + + if (softISPMode && !strcmp(softISPMode, "gpu")) + debayer_ = std::make_unique(std::move(stats), configuration); +#endif + if (!debayer_) + debayer_ = std::make_unique(std::move(stats), configuration); + + if (!debayer_) { + LOG(SoftwareIsp, Error) << "Failed to create Debayer object"; + return; + } + debayer_->inputBufferReady.connect(this, &SoftwareIsp::inputReady); debayer_->outputBufferReady.connect(this, &SoftwareIsp::outputReady); From patchwork Wed Oct 15 01:22:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24680 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 79570C3338 for ; Wed, 15 Oct 2025 01:23:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 077D860685; Wed, 15 Oct 2025 03:23:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="WX4v6XQe"; dkim-atps=neutral Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 521CA6066B for ; Wed, 15 Oct 2025 03:23:31 +0200 (CEST) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b54f55a290cso845497766b.2 for ; Tue, 14 Oct 2025 18:23:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491410; x=1761096210; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jGlXm/7XgWsn9FwtAXFr/l1QF6QrEX1+nuiuAdNesgo=; b=WX4v6XQeCmI7CY5heHP43qv6gmgcXwkZatENA7d2vz8N3vMj/SJit0zLSsu+CMX3I/ 2uBu8OxtiE7edw4wgfldtUQ/u3vlVG+UoYw76Px0L0X/1001dEH97h/YlL/bc057qTWT P0A2Qzw6B6qEMDmCJsEN3wyRrAX6hC4UpYK75CwAYRNaWFIfveQd3L+hE1PUyYJT9ZT/ cztxM4G+pvCwOxRfZSvHyBLhGtS4CT7Ad0PHAxsSbi5LAmnYxFVAEqGLl9Vltl8iL/Vp Gdo58fckSNYjOKXmu+8uHGYxNvbwv+EpVzihyhqaRfNFl5uUElGXvwz2Rm1E98d1zxh4 tV5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491410; x=1761096210; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jGlXm/7XgWsn9FwtAXFr/l1QF6QrEX1+nuiuAdNesgo=; b=TjM6vC91GCPtxHOjReFQCy1jr7Pxu6varIXp0HtOhYLcYQTs3SMb1T0v99D9i7lJnm L5PhxUwq1V4qM8y78OuOYmxGfrIvq2qXsbE78p/YTioc33xHCsGSWq8u2C0sAbKS/Dqc rlytRTVvF9BCQwCA7sASnkah1B9UR2xPpNuPouTgq2RwD0KorKTpa0YELEK4pmhJ7Jvm IG4MOZ2Am2wrySlVTxbd13ICoDq8y2MIALGZb2tWCiwVF+SYl24q0ggTQDMRXNx9iLGv 214F1h8Fsuol3PHwfs4xP47O3w0B+QEli2MLvTtVHx/kcJRc0hhLCvTLsoqGz8RfkZJd JFzg== X-Gm-Message-State: AOJu0Ywp4FUoo6zfPhi+wEtdsdH0ejZ9IvBUDQIXrs8uhEHFsVP4+btS 1oc2pdvjADXEstlWLiUWh/EE/1UIZ7rGSSLx3Rbq/f3dV6xRnXO+fFsppwbVCtWb1T4Lhu1wdWE bEOeB X-Gm-Gg: ASbGnctG5XWfCDXF+AXlpthG6iFzfpmkm6LoAWtNbaT2qV7tDuLvLGikbU6fPf73lu4 t79hRtwX6BqzI9Kh7S9Xe+HmOImNFyy5fimDZpxOLjgjisfF0/vSH/st0o2CJorDhvWaGtyBIrQ syi9sLOAHUNuvjAxqNaQxMFw6LlNpzuyH1iy9ae40Jzjz3flWtv7vuBzrE6ktbuVpQDM4dpqqky QYijToi6J0BzVe+iIZw5PH6xCirxqvyh0XOCeI9HYi+hgkoC0YtBgAcVg2GGQclBRI+zrCalqI5 3TvOdLKzIoC7xADJiocbLpgtxusD8zuUsh8mFUN/L0GHDCab/Jqu7HPdy90UcUquU96NddT4+fU IvYFEdE6xvP5aUwzvXQxFsuQiVz7uvJH1MdHMTmchmLvyWlumDtOI3M6wRW7mLsdN4/1e8sQrfu F+McgtO3DFp+5QVzGUj+dVLsX2I5mdaprQdReAZvSV X-Google-Smtp-Source: AGHT+IHdeDat27yR3zphe4/V6yOpdb41J/6Ex/FZv/iL2MhCxG0ItMnBMVag3P/4R2w3XxgHcMau2Q== X-Received: by 2002:a17:907:94c3:b0:b3e:d492:d7b8 with SMTP id a640c23a62f3a-b50acc1aa45mr2470377066b.64.1760491410524; Tue, 14 Oct 2025 18:23:30 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:30 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 35/39] libcamera: software_isp: debayer_egl: Make gpuisp default softisp mode Date: Wed, 15 Oct 2025 02:22:47 +0100 Message-ID: <20251015012251.17508-36-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" In some cases the GPU can deliver 15x performance in Debayer with the CCM on, reference hardware Qualcomm RB5 with IMX512 sensor. Given this large performance difference it makes sense to make GPUISP the default for the Software ISP. If LIBCAMERA_SOFTISP_MODE is omitted gpu will be the default. If libcamera is compiled without gpuisp support, CPU Debayer will be used. It is still possible to select CPU mode with LIBCAMERA_SOFISP_MODE=cpu. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/software_isp.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 869f7320..1b4a29fd 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -120,10 +120,17 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, } stats->statsReady.connect(this, &SoftwareIsp::statsReady); -#if HAVE_DEBAYER_EGL const char *softISPMode = utils::secure_getenv("LIBCAMERA_SOFTISP_MODE"); + if (softISPMode) { + if (strcmp(softISPMode, "gpu") && strcmp(softISPMode, "cpu")) { + LOG(SoftwareIsp, Error) << "LIBCAMERA_SOFISP_MODE " << softISPMode << " invalid. " + << "must be \"cpu\" or \"gpu\""; + return; + } + } - if (softISPMode && !strcmp(softISPMode, "gpu")) +#if HAVE_DEBAYER_EGL + if (!softISPMode || !strcmp(softISPMode, "gpu")) debayer_ = std::make_unique(std::move(stats), configuration); #endif if (!debayer_) From patchwork Wed Oct 15 01:22:48 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24681 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 24D78C3335 for ; Wed, 15 Oct 2025 01:23:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BC0EB60674; Wed, 15 Oct 2025 03:23:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="fkqad5xC"; dkim-atps=neutral Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 377036065E for ; Wed, 15 Oct 2025 03:23:32 +0200 (CEST) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-b40f11a1027so1073948866b.2 for ; Tue, 14 Oct 2025 18:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491411; x=1761096211; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SHxYNwZ2SuJenQQzjJu+qFVpF7ezbdEtz2sX66kqCZc=; b=fkqad5xC8m+Cl2ByzVYRa6PIbQZLhrTukdY5h9v4BoqHfnH350X1w4UBpTuShzFDkZ 38xwxP897ww71ANLXI40slyMUl5e14dcJD8pub0pWzHcEJaO77T7rHI0ZRQlPb14DaRY 1s6Pot6fEtc/HoJjwop5EV8Hj7H2hW6Y/zGG0Xc9jpMo2Sxi9SseGeI7dW3IYo6Yve1A dsrwLLib7/TNRkm840HJjQSisWT8q5+j0duR7irZ41R7ignSp0/NB6vdbzAjA6O6G0xx 163Ykc6SkLQhHoJh1ZHXZJPZlb9CLPq/9XZ6pCKMthArMGFqMb5wjRbW+FjnSlRYbZHG QgtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491411; x=1761096211; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SHxYNwZ2SuJenQQzjJu+qFVpF7ezbdEtz2sX66kqCZc=; b=jL/f7bpHnyVqkrVX5QwznheLooH/4utdaRfxxHl6IHwIw125t0RdG8fTYwu3aj7L5E c62IEwT5HtRTo2g4sdBtNXYIHjUdQ+2IlJxGBjF2cTOC7VuzkmUi/39Ugaoo1jp4wLJm GgbDaRw9buIJPICsgI9w2gkKXvzdJd4sDoeWwqz4Rhot9FDPdxQ2sc5VCrw3l2pQzI2X mcGaKRmtCviHUrDNywVHZij/uhG/TU2IWfj4ueOROVh5VUHKc9I5BqI9RWw488GPV2Y5 ksw4siY4CzM/kiSF1dfdo1S8s8Q54XlnEoTjzHZI0cGDUyd/DAFrUYA7n00T9L8kJctA Vp9Q== X-Gm-Message-State: AOJu0YxaIIOoysZSKnFZAjg7/wE00I9786tluCrAYVf7Uf3UbFlxGGCi RCQYIB8ypTWQgn9o4bQPvw1t9N/4w1YDX0Aja07TCJlgmSJViNZxl8GY6vCTHlh7+jhzvjqt3eb cxzcS X-Gm-Gg: ASbGncsvBhMeTWPBus9fQS09WwM5dpwAY2WbzpMCVBZ4b2C2lwKDW6EPOM5ZonCp2gI Nv79YXHLfkRe6ykPsoXYZ+FtGFH+5P/iKdy1Npx6DE2Cjy0H8D9FrmzBIpgNZEZODqlX7Z9pkat dUn3dXSCGHy8x1G6MCHe6RwBOiynTRteHZu0pZBQmRF+PHzEmpMknPaYCjw9bDWHPgrOp8bdQdq NRCIJgHz7yaCcIdkE6ef0qNeVHV+QqXY6113lmmCi1WfPEYup666unqoUVkeNWpI8G1p38RS8M8 TsxPJp35KcHbCA/D7wUaRk61CqH0H+YJU8607ZLSb2tM1tp0I7hhHUPQUbfQ9BEUTvd+Y1QLkwj cXFETJ0qk59QAOvf8SXNYBQXVYqkdr0ZVXTDInvU4kYb9Bsc0fSVcdApL7Mou6gg+BE0bea7y39 uObCoE7pW+ZMdnIrox8IImc2CbFmaEqA== X-Google-Smtp-Source: AGHT+IGJfmhdfQEhgLU1OY5TEEzCtyvhMs2+JGdJAc+VfqH52sUXeBqZIsBWkphcNFd+oLtGs2mIdQ== X-Received: by 2002:a17:906:c149:b0:b45:60ad:daf1 with SMTP id a640c23a62f3a-b50aa8a92e3mr2597436466b.22.1760491411537; Tue, 14 Oct 2025 18:23:31 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:31 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 36/39] libcamera: software_isp: debayer_cpu: Make getInputConfig and getOutputConfig static Date: Wed, 15 Oct 2025 02:22:48 +0100 Message-ID: <20251015012251.17508-37-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" Make getInputConfig and getOutputConfig static so as to allow for interrogation of the supported pixel formats prior to object instantiation. Do this so as to allow the higher level logic make an informed choice between CPU and GPU ISP based on which pixel formats are supported. Curretnly CPU ISP supports more diverse input and output schemes. Signed-off-by: Bryan O'Donoghue Acked-by: Kieran Bingham --- src/libcamera/software_isp/debayer_cpu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index 3cc07028..3bf34ac3 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -104,8 +104,8 @@ private: template void debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]); - int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); - int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config); + static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); + static int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config); int setupStandardBayerOrder(BayerFormat::Order order); int setDebayerFunctions(PixelFormat inputFormat, PixelFormat outputFormat, From patchwork Wed Oct 15 01:22:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24682 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 E2DE6C3339 for ; Wed, 15 Oct 2025 01:23:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7480D6061B; Wed, 15 Oct 2025 03:23:47 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="wi5ldj7U"; dkim-atps=neutral Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 437F560669 for ; Wed, 15 Oct 2025 03:23:33 +0200 (CEST) Received: by mail-ej1-x62a.google.com with SMTP id a640c23a62f3a-b5b823b4f3dso221355466b.3 for ; Tue, 14 Oct 2025 18:23:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491412; x=1761096212; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NQ8UK1PjcLrLcomgawtJFUp2Hb3suu4LRcvqz99T9V8=; b=wi5ldj7UEShuXRKXHaxGWPKpaQNCRKrq3UpDTsRo/SxnuvuX85CwGBPbwnkUAN7Gye lExbm0y6g3H4iSXdKpRuaJj5wG50qJ6Hn1TyLWz9eA/gIKq/JNaMdsMs4WwBByFRp2XL w/NokGQ1Cjpmnb09l6B1lD1kxmltJzuVwrWMnap23dGcGWI8EfGnsEXIRQO8aP4B3KoM FYUH3vielwm+FIuv7fvnJZVH8HNJ8r02Er5JkTiuhvP6u7SniUErz59s2gXETShYRKNX uakfG9fCcPFsPGMLsA78DxiOLi/nbfisaWXg2oNlheT/jeMa7R486hEPGacPaXe0atOc wvEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491412; x=1761096212; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NQ8UK1PjcLrLcomgawtJFUp2Hb3suu4LRcvqz99T9V8=; b=ZgaTDEBHF2K/OU0XhO5Grch8hGEqbuNotB9MVyRxqyR01Pkwm83SrKFj7eWHPxItiS YuEXwr7RKUdQI2sbjEoknNru/zyDPzyfuJ/ET1MxVziDaMMzvFrkjd0eQLRI2ynaQkpd J4E4SkxfZrxAM5scop26CO3Qi3SwkgHdqH9RbfgqO/J/NKh0xftGmbfygI4zUdfis6Bs v5lDGb+PONnNI4wdnaq1RomDUW22hnxbu/IxDasMnIySgGB95xlSginq+ZN7R21jWFOC YaTQ/2aSUD+b1prEO+U+4SFBnR8ianaZmbh5nSsdIW4sajgeqpDDFoBdWAN3bBHuhnqp +OCQ== X-Gm-Message-State: AOJu0YzIjSRpoxmsPr/xSnloPmitAVsh2EBrxBlJQ5mVNbS1A+uedQfp DEf3yCLvrtCxjuWevzr1pg7Bo8H7mztnTh+bkrDvkSTyo4qpVk8z1Pe77MFKovsk9e3z9pKjDAi 68ah0 X-Gm-Gg: ASbGncszwA8ofw8BZ6ZIBq0T6XJRmf5V+BbUk8WV16T3AhHO9fEtAL92fBJrpzGWo00 /xaeVj3maLX/umkMnFPLM1fY/WeORMknX9Rq7JcqekjiCf2lnVLB2HheHPYEOYJgBmPYrp3NOVV FN4fVKsoZdKFBmCwIV38t+OH448669jZuzc8054ukBKTPqL2EZR4uQR8QAmBKfBuctkouYC/cyB sMsN4gVvVGrT30zdC4uZeW11p09K5b2edo0pHrent3JKryUO39f5Kb6UbV8a9OqHx3VbQQVGMTG 2Xeh/1K3+zbaf6ASXypZXtCbaATWYCSig/Nl74G/XmRAPIz7nkPc9iG3A5eyYBJEeepi3Jgk3Jv c3mNfUBqv9meBRdJc7zqgmvltpjre0/qLsb9mwlu+8BIomz1I8FZX5ckF3K4gjlmyYsTp4kXNyC X6Tt3mS/Gs3HHKBjrj645pHWqwogyLFmYe1sbmF1Vk X-Google-Smtp-Source: AGHT+IFrpSsZ0pU24nYtdv3hSFExslCTaQRNZ5yqdg/9R2QOQ8kbMRql7mgUiHEgG8qbKiYcPjiuUQ== X-Received: by 2002:a17:906:6a1d:b0:b30:2f6b:448f with SMTP id a640c23a62f3a-b50aa8a8f8fmr3060657966b.25.1760491412481; Tue, 14 Oct 2025 18:23:32 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:32 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 37/39] libcamera: software_isp: GPU support for unpacked 10/12-bit formats Date: Wed, 15 Oct 2025 02:22:49 +0100 Message-ID: <20251015012251.17508-38-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" From: Milan Zamazal The GPU processing supports 8-bit sensor formats and 10/12-bit packed formats. Support for 10/12-bit unpacked formats is missing, let's add it. 10/12-bit unpacked formats use two adjacent bytes to store the value. This means the 8-bit shaders can be used if we can modify them for additional support of 16-bit addressing. This requires the following modifications: - Using GL_RG (two bytes per pixel) instead of GL_LUMINANCE (one byte per pixel) as the texture format for the given input formats. - Setting the texture width to the number of pixels rather than the number of bytes. - Making the definition of `fetch' macro variable, according to the pixel format. - Using only `fetch' for accessing the texture. Signed-off-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/shaders/bayer_unpacked.frag | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/shaders/bayer_unpacked.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag index 37bd4812..96a6d554 100644 --- a/include/libcamera/internal/shaders/bayer_unpacked.frag +++ b/include/libcamera/internal/shaders/bayer_unpacked.frag @@ -33,9 +33,17 @@ uniform vec3 awb; void main(void) { vec3 rgb; + #if defined(RAW10P) + #define pixel(p) p.r / 4.0 + p.g * 64.0 + #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y))) + #elif defined(RAW12P) + #define pixel(p) p.r / 16.0 + p.g * 16.0 + #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y))) + #else #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r + #endif - float C = texture2D(tex_y, center.xy).r; // ( 0, 0) + float C = fetch(center.x, center.y); // ( 0, 0) const vec4 kC = vec4( 4.0, 6.0, 5.0, 5.0) / 8.0; // Determine which of four types of pixels we are on. From patchwork Wed Oct 15 01:22:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24683 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 C90F1C333A for ; Wed, 15 Oct 2025 01:23:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7B48560688; Wed, 15 Oct 2025 03:23:48 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="b0i54axK"; dkim-atps=neutral Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 1E71A6066E for ; Wed, 15 Oct 2025 03:23:34 +0200 (CEST) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-b3f5e0e2bf7so1113307166b.3 for ; Tue, 14 Oct 2025 18:23:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491413; x=1761096213; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FoDv6D1uk0rJTj9Z4cxY9IqyJOF3dmyO7LI4K4orjsA=; b=b0i54axKFluDuypgEMKYBYyDGgQpMXm22J5ObfILi38mAJFZQgRYIwEUvZEWcvURkb TJ9QJsph8saYDQdQLdIAq0E7anrz/YxIpq/MJRnMqX+RsdU4ZBexqfkGgdQdV1YVXuN1 Fq6Sek8OmyyzJXLuMYf97Ioanc86KrpPBEBylKFSCTRX3H6DeATLQmTIdIqZgVOdbNPZ rEHYAyCKJGOFt+/dwUul/QLYf00tUZaWMK3aVFp9YUKz9j4y+j5StOEqcHiIPyGcQ5u2 A+9Pz/9390/2SLiPNY34dfesCmYltbOIB2dL0pydBW0ZhDcXGiEHMEwobB5gr0zqYhtg O06A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491413; x=1761096213; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FoDv6D1uk0rJTj9Z4cxY9IqyJOF3dmyO7LI4K4orjsA=; b=A4vxP36CAn4FI68rg/QOzoAlW7h4YvZ9YyeHW/JLaBl+ngjKFOWBMWFCs/XxpE6qvS MMG4QTqkcti0jV7NjJpv19WfFLOOOVEkZBoCCn47IfzOZs2x4jrPOKZ+iY50ob4fZS+K PXcu2G9gi+vREcbo17laTdTjOXiSJ9gBKHp8iypuaU74V0cVWCiMQ+ODyz6HWWtp9FVJ 8107SW//IlR+4K325175He9U1dju4oqaQ6L1IZgKbOHfOHm7VOsEag0cj1UapK9BBUrT GYTzHzqK/FbMySAcKz6jpAC/dLXprtmmkFJo5PgMq+I6v4JjKY38eVAOQwSwqnzehDGa LXlw== X-Gm-Message-State: AOJu0YxfjgnmxJpGa0RPyHgUsmC/NsEuHCbSrImK3SpRItsweRn9F43Y ReGUzpchTa4pBP0vbrFktE/jZ1BFdrmrLvexRbyXzJS+FRba+HSwxDltPS4aYmswe0UOGD2kEab zJNbs X-Gm-Gg: ASbGncuSfUJNw/8rn8jl5fW0icFPhd4ae48JqcMD2Dg926JPAaQxRnyEXEjCPJqfUsG y3IZUyMUagOl7VtvWTRyzi8CHRDUIdwWc7QhbH1vy6YOP3LMq/GmalQGl9LyN3owfFB7nKvv0Ca wT10wqYqlZpJzkvmGH+wo4enq1arNuVS3hP66bXX+hzXwEYhbuWSODZfXDESKdAAYcVUS0u/j4Q xJqf+EEQfpObHWuMeQGiwHI3cp6zN3TeFSlr8v6WJi9YA+bGvB6F2C7dvp2nuruQh7Hdr0yutkI r7WbOqE5KEgCSHIh6SWGFLBqE4HzTRXmSLTey/x6xWdFoC5hI1CRwUNHffSuBzAxKQipYycu3kW 06eh6MrXPBPm9LqDPLZw6CjXKnV8Zuz1QtVsiVyD4hCDGsmOajkfFQqSwXtprOgQRrWzHgACJVh g73Bna/k913sf5/PB6JuhqQH8uh606QQ== X-Google-Smtp-Source: AGHT+IFDlQA/5KDkoK6PjQQH24l1X8S855cOzc3WKox/csYxBG9bdYCtrMb9WcC1DKPr8gwqNOJkLw== X-Received: by 2002:a17:907:1b1a:b0:b5c:831d:3f2 with SMTP id a640c23a62f3a-b5c831d049dmr219519566b.48.1760491413431; Tue, 14 Oct 2025 18:23:33 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:33 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 38/39] libcamera: software_isp: Switch on uncalibrated CCM to validate eGLDebayer Date: Wed, 15 Oct 2025 02:22:50 +0100 Message-ID: <20251015012251.17508-39-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" As a validation step switch on uncalibrated CCM. Signed-off-by: Bryan O'Donoghue --- src/ipa/simple/data/uncalibrated.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ipa/simple/data/uncalibrated.yaml b/src/ipa/simple/data/uncalibrated.yaml index 5508e668..8b6df9af 100644 --- a/src/ipa/simple/data/uncalibrated.yaml +++ b/src/ipa/simple/data/uncalibrated.yaml @@ -8,12 +8,12 @@ algorithms: # Color correction matrices can be defined here. The CCM algorithm # has a significant performance impact, and should only be enabled # if tuned. - # - Ccm: - # ccms: - # - ct: 6500 - # ccm: [ 1, 0, 0, - # 0, 1, 0, - # 0, 0, 1] + - Ccm: + ccms: + - ct: 6500 + ccm: [ 1, 0, 0, + 0, 1, 0, + 0, 0, 1] - Lut: - Agc: ... From patchwork Wed Oct 15 01:22:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 24684 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 96ACDC3331 for ; Wed, 15 Oct 2025 01:23:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0ECDD60693; Wed, 15 Oct 2025 03:23:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="xrsXp1TH"; dkim-atps=neutral Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 40EE460677 for ; Wed, 15 Oct 2025 03:23:35 +0200 (CEST) Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-b48d8deafaeso1242439466b.1 for ; Tue, 14 Oct 2025 18:23:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1760491414; x=1761096214; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vWBqVaFe6+Z55hicVVGDke3oD9foA7KiH/lYfdfC2lw=; b=xrsXp1THbMSb4H/MpIJLQS4sRmGDNXANlYFOpQYDl19MEKi0WqwaBavljdD8Ru9rd7 LoJGCPsyldlf2oDpc3b15QTUrd69rPoYNMO37hOyU9iTs3SFKhHJlH3rFER3Sa1DF/PE M+eX0vvC7kYR6re1capm/uWY9djhHoEpfeC5V2dtxYBlCafCYcc//r4OKdI2xyyvvItX SpJO/1RQjDRZifWB4sx+uQ+6WHAjfPt9e6mxaMRgIJbY1aknN/OI22kqG+S1i+0aGLZo KZGtfCNFzyAAi7AQTqFqy0kXawJDx3wtesrZy2iMguwd62Z8lU5D8GoOpLcD+aUn0uFw NPGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760491414; x=1761096214; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vWBqVaFe6+Z55hicVVGDke3oD9foA7KiH/lYfdfC2lw=; b=QFtW5hl7fTMQuaXe3zYGBFVjjf62YHApzVRqfmniSp+heLXBIhqjqpu/8dt2WXA6+D XYhns+1CkOV8zhGv/zjWyI6jLpQPokcP2c47IxEWdj/bTa6AHwVl3qIDPJkvoekCXm51 2qyhEbqTcYK20y8hXlrbwvxseO0ITxbQBS6eK98FfRKQsqRE8snGkikV7rqz3UfNQzD+ x/UWSpY4cSR7Cw24eyUz5pkxFPXimc1Ic7mICa1QEbbpNTyXjtQYXRWg1NOzv/GUp+Wn DU70g0ZSb73gqeJ9JIf4Oq/uz2beKqB7sYLEjVa9RltefMEWj0uTWThAhPdK4olJtfuq 2fTw== X-Gm-Message-State: AOJu0YyMgYWTu3VNpxzR2gSbvQ6AM8OABqnwBRLkK33LAMx4LM8fwp65 IW1j85sV754VJJ9a6pXLl6rk5yRbQol7duFvM2eaG0Bm/4vxKjgPIiAsPOEgwPDpZIyWXQaieNs PE8oo X-Gm-Gg: ASbGnctL8AArHkZDLp9SKRW0yGl8A17BffvchQmWgHwuM9tx0EHgWOBR7E+5pyslVmi eks4+U7Q0LcZU1ojHOd6ahJm1bqgYwynI4Y4sCjv6bOTtOLnaiDfTB3/Q+8fVKLlaU6UPqjsuyk zkFAdiKrdyEW6kbA01gpA/8ACxz2AYy1SdvOIrs/ZkGtobqymQXiYzhZL/OTQncC1Q1sjKZksqJ klviaKnlTEIvSgvtlpZ2LyVCFhP7ISNv/YzFKDJm5aKk1WDCkpQrhxLsPrIVox2uiAsz6WYPlas m/9oQUnBr1DZnsoTl7+ZD4Vj/hvwawIx6/pyAJJBbRb7GtNE/tJMyTqmheTwHf1UDgIGwcQJNCj 96PazAPy3RKBIKBA28vJLQ1bEAs1FHRtLMyH9ywE/SsYTI7ZcSGTYHwglRL+tOyk2ropR2Q2E87 cwestSTaHiRtCY1UnM3W/YpxmcH/YajtbDpCsJu230 X-Google-Smtp-Source: AGHT+IEQU46biLgCtkvKLNH2VkF99O8caZLeOx8kDAz3Q/h7/6hShQeungPCg8sMoyi9Hr//2LpDxA== X-Received: by 2002:a17:906:7949:b0:b04:25e6:2dbe with SMTP id a640c23a62f3a-b50acb0bdc5mr2844157566b.63.1760491414429; Tue, 14 Oct 2025 18:23:34 -0700 (PDT) Received: from inspiron14p-linux.nxsw.local (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b5ccd7b202dsm98348466b.82.2025.10.14.18.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Oct 2025 18:23:33 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: hdegoede@redhat.com, mzamazal@redhat.com, bryan.odonoghue@linaro.org, bod.linux@nxsw.ie Subject: [PATCH v3 39/39] libcamera: software_isp: Add a gpuisp todo list Date: Wed, 15 Oct 2025 02:22:51 +0100 Message-ID: <20251015012251.17508-40-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251015012251.17508-1-bryan.odonoghue@linaro.org> References: <20251015012251.17508-1-bryan.odonoghue@linaro.org> 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" List the series of things to do in GPU ISP in perceived order of difficulty. Signed-off-by: Bryan O'Donoghue Acked-by: Kieran Bingham --- src/libcamera/software_isp/gpuisp-todo.txt | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 src/libcamera/software_isp/gpuisp-todo.txt diff --git a/src/libcamera/software_isp/gpuisp-todo.txt b/src/libcamera/software_isp/gpuisp-todo.txt new file mode 100644 index 00000000..768dcc32 --- /dev/null +++ b/src/libcamera/software_isp/gpuisp-todo.txt @@ -0,0 +1,83 @@ +List the TODOs in perceived order of ease. + +Version 3: +Use dma-buf handle to generate upload texture: + - eglCreateImageKHR can be used to generate the upload texture i.e. + to feed the bayer data into the GPU. + +Denoising: + - As below still TBD + +Dead pixel correction: + - As below still TBD + +Lense shading correction: + - This is WIP but as yet still TBD + +Lense flare correction: + - Not WIP still TBD + +processFrame() to run in its own thread: + - processFrame() runs in the context of the Debayer::process() + thread. Robert Mader suggested and it seems like a good + suggestion too to run processFrame() in its own thread. + +Version 2: +Make GPUISP default: + - Right now the environment variable allows over-riding to swtich + from CPU to GPU. + - Once we support 24 BPP output on GPUISP we will have the same + pixel format support as CPU and can set the default to GPU without + regressing functionality + +glTexture1D: + - Initial code was developed for < GLES 2.O but since we have fixed + on GLES >= 2.0 this means we can use glTexture1D + - Provided this is so amend the shaders to do val = texture(x, y, 0); + not texture(x, y, 0.5) the 0.5 is because of using glTexture2D + +Denoising: + - Run a denoise algorithm in the shaders + - Supply a control to influence the noise-floor ? + +Dead pixel correction: + - Add logic to correct dead pixels in the fragment shaders + +Version 1: +24 bit output support: + - Take the BPP we already capture and get a 24 bit GBM surface + - Pass a compile-time parameter to the shaders to tell them to do + gl_FragColor = rgb not gl_FragColor = rgba + - Version 2: + This is not possible. + gl_FragColor expects vec4 not vec3 on the output. + If you really want RGB888 run cpuisp. + +Surfaceless GBM: + - We get a GBM surface and then have to swap buffers + If we rework for surfaceless GBM and EGL then the swap buffer can + be dropped. + - Version 2: + Complete GBM surface removed, memcpy() phase removed also + +dma-buf texture upload: + - Currently we pass the input buffer to glCreateTexture2D. + We should be able to make the upload of the input buffer go faster + by using eglCreateImageKHR and enumerated the dma-buf contents. + - Version 2: + Complete sm8250 test platform shows 20x performance increase + with CCM. + +Render-to-texture: + - Right now we render to the GBM provided surface framebuffer + and then memcpy from that buffer to the target output buffer. + This necessitates flushing the cache on the target buffer in + addition to the memcpy(). + - Render-to-texture where we generate the target framebuffer + directly from a dma-buf handle will mitigate the memcpy() phase. + - It should be the case then that the consumer of the output buffer + i.e. the thing that's not libcamera is responsible to flush the cache + if-and-only-if that user writes to the buffer. + - We need to flush the cache on the buffer because we are memcpying() to it. + - Version 2: + Done in version 2