From patchwork Thu Nov 27 02: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: 25215 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 EF0B5C3260 for ; Thu, 27 Nov 2025 02:23:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 99B6660AA0; Thu, 27 Nov 2025 03:23:09 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="RsV6h7I5"; dkim-atps=neutral Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 49F3A609D8 for ; Thu, 27 Nov 2025 03:23:07 +0100 (CET) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-477ba2c1ca2so3579665e9.2 for ; Wed, 26 Nov 2025 18:23:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210186; x=1764814986; 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=9KHFiP4cV6wRbI+z6ftJt00yOHyrmxg5/3kJMxm0k7Y=; b=RsV6h7I5DD/Vuucwztxt5+V4EPYoMeawquJMHIDKX9rvmJEMEgQMe64rheDKknMvBy Zgyr4A/sgMiLXb3y55GM6ttapyC/y+naQNmAhprdsN26h8Jxaq8gieKspcOlW+/JP65G eNwi03eEoc/IhtlmsbocFFxdU+NlmQyYnWM66mGO9H+UgCWZS+q14l+XpikF94sUFl73 PCF1vF1OQGwXwA9hnTJp58liqIZWojB+hvUi6U3yfbYjjSwPRtdGjgBkypS/zsovedAW wQltuFE8l70FU1+V9mTyYX0W5J6osBU3IB5kYz8iN0U2MigfOMfe3ZPE4vIfoh439FY3 XKCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210186; x=1764814986; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=9KHFiP4cV6wRbI+z6ftJt00yOHyrmxg5/3kJMxm0k7Y=; b=mgqIopwdhq6qrhXN01NIacc4xSBGYOeZ0xUZVQzOqeyIwQNXlPXw7f+fFpliKTi9do PE3/pow/xhRprif+j4oxJMnoAIAgmwAdchf9iE9pVwRVkzWssJsZtIsMzRwzEMsmRrRV svxZlKm2kJ2YQzoJnBcnyXWzNsDanlsOP6LzcfED2W80wiFEOq80cvRh7mUOnlrzOTvR l/0JSsBUE8LPpsgc/qc3wOEz8n/FFs/nZ0bZOOBksiwYAKMFAZZEGc3/krHOIE+qZ4A4 Q/rVDAH2bF50DQCN/zmRLdNlrOiM5wPRS2foY0+DP/a0XGquapyubD74hk5tFigG8BdH US5g== X-Gm-Message-State: AOJu0YwgReI48NMyx4kZS20mvWS3+TmtV3iMbzYiDDo346LQohGmPZ0r Lk99TpajjEIWtM0D+74U9gsoX2lsCTKkJWIeI2LW3QmevD58bmwyLIrDZXyHHmq4WQLqwkBLNot ryhEjSI8= X-Gm-Gg: ASbGncvPKsmhSqlgp8SgQgAN5fUfWhrCbzauIAsaM45pDx6SVr0XbrnRJ8ovBJsflgg uhO1oMP4Zqk+LugGFIxDr3yEnZpXUyVr01O1MOZW3zF39bik0MCbyMS4NbrSH3N/0ZFMGkGYLDl TGZ4S+qodO9A4FBO1RKXo/JmKiOgccbmleTexm1/4KbWkADZegOpXr2QeDubebRud77/mk4LrBW D2boRaeCc68T6AVKnf5+rgQ7RqXB4civeJV+n7MeTcOJFYRK1wpe2vgHDJB7+RIC+90ZiyJ1ujy bX/LwyROo1JxE7lU+SeJ4GENF+GFSJiXrYiwJ1a1IC98MJbhO2tMilg/xIUhrkhPBy+dGgKXroz /R6RWGqTWJcU2ISYDw0hccTt8PyFx2zh1sCHTlFjhHtPO82JP1d2RLZqqLFh1wR6c01Y3JzzlKv 1OX/1vASuO5ua4iiScGmr2FiW7/zg8Gumf8QqX/5clau6l0gEP1FTGf/gLXfTAq/sInOI= X-Google-Smtp-Source: AGHT+IHP+s45lQVi3LRHhVqATRyj41MY6R5jTIlhrNEWinuRg/MAKbehzpSLssndtXv1IO1q6iYAxg== X-Received: by 2002:a05:600c:c48e:b0:477:28c1:26ce with SMTP id 5b1f17b1804b1-47904acef1dmr83076085e9.7.1764210186582; Wed, 26 Nov 2025 18:23:06 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:04 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Kieran Bingham , Milan Zamazal Subject: [PATCH v2 01/22] libcamera: shaders: Move GL shader programs to src/libcamera/assets/shader Date: Thu, 27 Nov 2025 02:22:33 +0000 Message-ID: <20251127022256.178929-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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/shaders 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. Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- src/apps/qcam/assets/shader/shaders.qrc | 16 ++--- src/apps/qcam/meson.build | 3 + src/apps/qcam/viewfinder_gl.cpp | 70 +++++++++---------- .../shader => libcamera/shaders}/RGB.frag | 0 .../shaders}/YUV_2_planes.frag | 0 .../shaders}/YUV_3_planes.frag | 0 .../shaders}/YUV_packed.frag | 0 .../shaders}/bayer_1x_packed.frag | 0 .../shader => libcamera/shaders}/bayer_8.frag | 0 .../shader => libcamera/shaders}/bayer_8.vert | 0 .../shaders}/identity.vert | 0 11 files changed, 46 insertions(+), 43 deletions(-) rename src/{apps/qcam/assets/shader => libcamera/shaders}/RGB.frag (100%) rename src/{apps/qcam/assets/shader => libcamera/shaders}/YUV_2_planes.frag (100%) rename src/{apps/qcam/assets/shader => libcamera/shaders}/YUV_3_planes.frag (100%) rename src/{apps/qcam/assets/shader => libcamera/shaders}/YUV_packed.frag (100%) rename src/{apps/qcam/assets/shader => libcamera/shaders}/bayer_1x_packed.frag (100%) rename src/{apps/qcam/assets/shader => libcamera/shaders}/bayer_8.frag (100%) rename src/{apps/qcam/assets/shader => libcamera/shaders}/bayer_8.vert (100%) rename src/{apps/qcam/assets/shader => libcamera/shaders}/identity.vert (100%) diff --git a/src/apps/qcam/assets/shader/shaders.qrc b/src/apps/qcam/assets/shader/shaders.qrc index 96c709f92..7369cdbe8 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 + ../../../../../src/libcamera/shaders/RGB.frag + ../../../../../src/libcamera/shaders/YUV_2_planes.frag + ../../../../../src/libcamera/shaders/YUV_3_planes.frag + ../../../../../src/libcamera/shaders/YUV_packed.frag + ../../../../../src/libcamera/shaders/bayer_1x_packed.frag + ../../../../../src/libcamera/shaders/bayer_8.frag + ../../../../../src/libcamera/shaders/bayer_8.vert + ../../../../../src/libcamera/shaders/identity.vert diff --git a/src/apps/qcam/meson.build b/src/apps/qcam/meson.build index 9ca047b0f..33600095f 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 f31956ff0..1554c94d5 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_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/shaders/YUV_2_planes.frag"; break; case libcamera::formats::YUV420: horzSubSample_ = 2; vertSubSample_ = 2; - fragmentShaderFile_ = ":YUV_3_planes.frag"; + fragmentShaderFile_ = ":src/libcamera/shaders/YUV_3_planes.frag"; break; case libcamera::formats::YVU420: horzSubSample_ = 2; vertSubSample_ = 2; - fragmentShaderFile_ = ":YUV_3_planes.frag"; + fragmentShaderFile_ = ":src/libcamera/shaders/YUV_3_planes.frag"; break; case libcamera::formats::UYVY: fragmentShaderDefines_.append("#define YUV_PATTERN_UYVY"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":src/libcamera/shaders/YUV_packed.frag"; break; case libcamera::formats::VYUY: fragmentShaderDefines_.append("#define YUV_PATTERN_VYUY"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":src/libcamera/shaders/YUV_packed.frag"; break; case libcamera::formats::YUYV: fragmentShaderDefines_.append("#define YUV_PATTERN_YUYV"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":src/libcamera/shaders/YUV_packed.frag"; break; case libcamera::formats::YVYU: fragmentShaderDefines_.append("#define YUV_PATTERN_YVYU"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":src/libcamera/shaders/YUV_packed.frag"; break; case libcamera::formats::ABGR8888: fragmentShaderDefines_.append("#define RGB_PATTERN rgb"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":src/libcamera/shaders/RGB.frag"; break; case libcamera::formats::ARGB8888: fragmentShaderDefines_.append("#define RGB_PATTERN bgr"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":src/libcamera/shaders/RGB.frag"; break; case libcamera::formats::BGRA8888: fragmentShaderDefines_.append("#define RGB_PATTERN gba"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":src/libcamera/shaders/RGB.frag"; break; case libcamera::formats::RGBA8888: fragmentShaderDefines_.append("#define RGB_PATTERN abg"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":src/libcamera/shaders/RGB.frag"; break; case libcamera::formats::BGR888: fragmentShaderDefines_.append("#define RGB_PATTERN rgb"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":src/libcamera/shaders/RGB.frag"; break; case libcamera::formats::RGB888: fragmentShaderDefines_.append("#define RGB_PATTERN bgr"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":src/libcamera/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_ = ":src/libcamera/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":src/libcamera/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_ = ":src/libcamera/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":src/libcamera/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_ = ":src/libcamera/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":src/libcamera/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_ = ":src/libcamera/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/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_ = ":src/libcamera/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; default: diff --git a/src/apps/qcam/assets/shader/RGB.frag b/src/libcamera/shaders/RGB.frag similarity index 100% rename from src/apps/qcam/assets/shader/RGB.frag rename to src/libcamera/shaders/RGB.frag diff --git a/src/apps/qcam/assets/shader/YUV_2_planes.frag b/src/libcamera/shaders/YUV_2_planes.frag similarity index 100% rename from src/apps/qcam/assets/shader/YUV_2_planes.frag rename to src/libcamera/shaders/YUV_2_planes.frag diff --git a/src/apps/qcam/assets/shader/YUV_3_planes.frag b/src/libcamera/shaders/YUV_3_planes.frag similarity index 100% rename from src/apps/qcam/assets/shader/YUV_3_planes.frag rename to src/libcamera/shaders/YUV_3_planes.frag diff --git a/src/apps/qcam/assets/shader/YUV_packed.frag b/src/libcamera/shaders/YUV_packed.frag similarity index 100% rename from src/apps/qcam/assets/shader/YUV_packed.frag rename to src/libcamera/shaders/YUV_packed.frag diff --git a/src/apps/qcam/assets/shader/bayer_1x_packed.frag b/src/libcamera/shaders/bayer_1x_packed.frag similarity index 100% rename from src/apps/qcam/assets/shader/bayer_1x_packed.frag rename to src/libcamera/shaders/bayer_1x_packed.frag diff --git a/src/apps/qcam/assets/shader/bayer_8.frag b/src/libcamera/shaders/bayer_8.frag similarity index 100% rename from src/apps/qcam/assets/shader/bayer_8.frag rename to src/libcamera/shaders/bayer_8.frag diff --git a/src/apps/qcam/assets/shader/bayer_8.vert b/src/libcamera/shaders/bayer_8.vert similarity index 100% rename from src/apps/qcam/assets/shader/bayer_8.vert rename to src/libcamera/shaders/bayer_8.vert diff --git a/src/apps/qcam/assets/shader/identity.vert b/src/libcamera/shaders/identity.vert similarity index 100% rename from src/apps/qcam/assets/shader/identity.vert rename to src/libcamera/shaders/identity.vert From patchwork Thu Nov 27 02: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: 25216 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 0307FC3260 for ; Thu, 27 Nov 2025 02:23:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B3CE860AA3; Thu, 27 Nov 2025 03:23:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="o6w3dVk8"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A14DB609E0 for ; Thu, 27 Nov 2025 03:23:08 +0100 (CET) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-477bf34f5f5so1993785e9.0 for ; Wed, 26 Nov 2025 18:23:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210188; x=1764814988; 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=uyC98X/XHaAyWYIaQyyLtwB29WLvfE+rI98R7oKQJ7g=; b=o6w3dVk8Y5COPUFcCDWixtS3NUOoJwZQMaRB6MDN42Iky0ZUejdQbR6O3pscJ0yHOm 6fUltxiCX8wEJ7LFH8XBdIfo/IJTYp6D4hhiPhQyAGU+b2UqaJ7oy5VQLJAcJrh5XF2E i/gun8bbXJ1ajC388x5dk6Q5+BZJuT5oqOTi6V/GOvQs+PtgZxWeXy3PdPQhA6kj4uQ+ 6hJ+DktL+5L7Ljk3Nb/jKD7HE/DwI/llKnr/QHDXmAUlbZ8Bwl/odkSUz9xWjZttVF13 0k76uZEOPdXjww4jQg1toZqvMZS7UM7rxWcTNeVVBJgtNvrst0bhPl5HjePTSmCZLQZE 5Scw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210188; x=1764814988; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=uyC98X/XHaAyWYIaQyyLtwB29WLvfE+rI98R7oKQJ7g=; b=IkCJp3jC2swBwDtpqqYq6iKoWbO55V71uSIxHGKkV4XmD1xpkfKQCBfz8Yi6AqK0UT icUm0qwxELhR2oDQgr1yl/XFJH3hS/XpJr4i9i+rH/7bmDqhqipAZkNVqUroSowjaBtg 2WJgwCqTvIG143Oe/IXScLMpxoy+c5S2Tp1nfUqUa0sYbwJvOR14kJNMy0YGFRsn+s0P 5lwCyJ/aDYqmdoLHwuUMpvdrqzqLDqMdSt1njHRvwspOKibkjDS1fFQvGnLnP6krL3mL DyEfNawgzajjd2Em3omw47NsT63+aCxC/WK2v3Im2CppXYBgdSXwCvoqB747uBJtT3VV RsxQ== X-Gm-Message-State: AOJu0YxErqBMUCw7CxmvAKpPcHF3FQuvBAWchD9A96ecpt3KJq/yTU/j si6lGNieT+T+L7Xpej6Ymp63qEBBkn5HSw2BsQmXPfgT1slmbz/CMKWWW/QOVHceUQlbmsgncee dQEPj5HQ= X-Gm-Gg: ASbGncv3ZPT0c3Bqb9xwmlGsyP5L+IDh/dbXAX0f02cMQ3pAmPv/VNs1QxcgueWrqaH hRGmDPH4xxSvBQ7NMEuxD3J4eNuV/FHjmqWLSm+hEglFW1vHFpkZwpnIMdMYMOVmdjuvdtyFbT8 HImNQuoLgQJrAs5k82BbVLXEwn4DlwLJxjryleTn2sdugzs7MSPU8zFQXau1akSKYLReSf5wMJv wJP0/hz/Cpupa8RXWZLy2C2Ju6W8zPzjD2Wdy1jrHTXcjG4faP6a+77DOS6aix4oWHTsTcAJ7QG xxqNhqcp/z+S5NApvNNkDZvwVyJOvheV68NWrXRSH6W2ubpvRYBvb0ZqkrUnhKgCG0VgEWYYVj7 wkbBoCu4Bq2ZeKZd2821G45W3peULC7EHz+bVh1xr+PH5dBbMQL8UwVqINGiGWiR1ExlhQoYWoJ MI+UhdrgONyKT5EQ7qcXBRoht/p41xV0zWejAYmgiWFeNHklLtG3PHWMFrZ37v4zLQCzE= X-Google-Smtp-Source: AGHT+IHTGtwXx09/kvhaqmu1L22ZFwtFr3LbaGgboPRLcTfUTs0flmY04A2zwG3fTs5u30TFeUlFDg== X-Received: by 2002:a05:600c:354c:b0:477:a977:b8c2 with SMTP id 5b1f17b1804b1-47904ae7322mr87633155e9.13.1764210188037; Wed, 26 Nov 2025 18:23:08 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:07 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Kieran Bingham Subject: [PATCH v2 02/22] utils: gen-shader-headers: Add a utility to generate headers from shaders Date: Thu, 27 Nov 2025 02:22:34 +0000 Message-ID: <20251127022256.178929-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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. Acked-by: Kieran Bingham Signed-off-by: Bryan O'Donoghue --- utils/gen-shader-header.py | 37 +++++++++++++++++++++++++ utils/gen-shader-headers.sh | 55 +++++++++++++++++++++++++++++++++++++ 2 files changed, 92 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 000000000..731a63b41 --- /dev/null +++ b/utils/gen-shader-header.py @@ -0,0 +1,37 @@ +#!/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 each of them +# 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) % 16 + if j == 0: + print() + 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 000000000..81bf1584c --- /dev/null +++ b/utils/gen-shader-headers.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +set -e + +usage() { + echo "Usage: $0 [shader_file2 ...]" + echo + echo "Generates a C header file containing hex-encoded shader data." + echo + echo "Arguments:" + echo " src_dir Path to the base of the source directory" + echo " build_dir Directory where shader files are located and header will be written" + echo " output_header_name Name of the generated header file (relative to build_dir)" + echo " shader_file(s) One or more shader files to embed in the header" + exit 1 +} + +if [ $# -lt 4 ]; then + echo "Error: Invalid argument count." + usage +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! */ + +#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 + name=$(basename "$build_dir/$file" | tr '.' '_') + echo "[SHADER-GEN] $name" + 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 Thu Nov 27 02: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: 25217 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 E3BA6C32DE for ; Thu, 27 Nov 2025 02:23:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 18AE360AA6; Thu, 27 Nov 2025 03:23:14 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="bmSd9sPi"; dkim-atps=neutral Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 004C460AA6 for ; Thu, 27 Nov 2025 03:23:09 +0100 (CET) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-47789cd2083so1244515e9.2 for ; Wed, 26 Nov 2025 18:23:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210189; x=1764814989; 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=Tf4iz5iEYQ1oR7Y+wuSf5rxUztQz2jgouqu9GnH0HVI=; b=bmSd9sPie8FVuBAEliu+bdSuDudlYKGeP2r5KJeXhklxOnoiT6Zl7VeSxF8fpg0aR8 8/dYaRba2oMbtMWjgpVxEWf6xuIf1gDh4af6rHdSMKSfiZrqJxJFgEph0rx88EHVljiE iDNOGZ5M0HvtX7J6gAGY8Sg86I5KCLj0MZHq8ioPyF6MF5LrLkX+KIRTfHWwx5PvGAtt kS2PAXasQutNQ5xNyJlQMPq6bp7D96BEp4hE0wYHUCQmn/AwyU6dQqYq3Qx3Yb8Xbb20 63rTbReyK5NfsM3BpBYXgtvZPIyU/kvTjWe9RuN3XA9qfd0Cy5y3tClPGrjepUtAdtIn TShA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210189; x=1764814989; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Tf4iz5iEYQ1oR7Y+wuSf5rxUztQz2jgouqu9GnH0HVI=; b=AcnJnXAHXMmgCF/rjXy9+WYveHlb1LP6bae6jUvZmiR620EvR2AQ1ua1Y1D3tTH1zi 9kw82gNG7VbOsM9bmJYGEYHDaC/zVTWbeZpLOB77Itx+9oTKMzOA6OeDMxrC8rX05V7E PTfTIlsF8lnIJ8vZKlkm5pXJzChUWU0IWVDpXYyBFkEc3kjsGn/fh2W4IGd+szNIvV05 vSrv+lvyVchTbwUh36l4d2Sg8LDD7004y0us2TSfXoW9eiUSIdFtx1t60M2eOn8DZcWi Wx/tRA56vpN5W7IdAydlZ5SXL2NeFL96ipz2MY9V+A054PB2ALnA0/4IAqYjZX4kFEs8 YnEA== X-Gm-Message-State: AOJu0YyYl5AXZUqNJaEw71x00myeivmPbLJFcZCHFPLFv7N34bVIYmhQ +/HxXPvYqfGoXeHBIl9EeBV3uwL19WhICRDhuwh/i2p7DBJ/3EI17k5jvjkFHoHKBNRsTKXDyyA 2p9+TrbI= X-Gm-Gg: ASbGncuZqp37hQYozgKss9Ou7ospzr6M3E4SK1GxPuUCIUUE/nkS99iU/ztlgOgYBb/ Iuj70V0CF9OWhmnoMGJ4Ej8WXFGOSL3JbYSGr9oOZmTbcndrBwFnSpe3Iyei+jLHjQV7I4UGG+s MY256QC11pNFENIhlyvBjMWdg8PNkKjVLYog0KVmz0NgZJhRPKfS+vwL9RXH270JVt4QH1n6Ai9 WoG7qswx5uIwpXkSp4conxDCW0XaAI0OyQgbLVceWE9MWpu4c8b+rGmzGW26fSwKcwg5mamYlPW PV3aYXF3ySMZ0Ay8/fzDlKt9HaL6/sGg0LUXmTI4aFxP48ds9yrh5qt9jau2l/ebW/OI2NeR0SQ Gy4wuXevMrAPGvD86VclKJZMB2W2M5UNNrupibQwWffCq48CuVhT/AoAqaSb2Sbh/iS2P/yD3V7 kVGvg/mZT9l21ED1sIXCg9ZkWZBFe39XhJ5xH9Izd/JxHg2/uaRqxsBfyMYE0dztskyqU= X-Google-Smtp-Source: AGHT+IHkhqhf4+Pz+N2NY5qxP1ZbpX2Zo5ycIkowSHr6A6BMxoiu0QO/n1k4hAqFrhs4ZipdWGi+9w== X-Received: by 2002:a05:600c:3b08:b0:477:214f:bd95 with SMTP id 5b1f17b1804b1-477c114df06mr209302975e9.23.1764210189144; Wed, 26 Nov 2025 18:23:09 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:08 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Kieran Bingham Subject: [PATCH v2 03/22] meson: Automatically generate glsl_shaders.h from specified shader programs Date: Thu, 27 Nov 2025 02:22:35 +0000 Message-ID: <20251127022256.178929-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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. Acked-by: Kieran Bingham Signed-off-by: Bryan O'Donoghue --- src/libcamera/meson.build | 11 +++++++++++ src/libcamera/shaders/meson.build | 10 ++++++++++ utils/meson.build | 2 ++ 3 files changed, 23 insertions(+) create mode 100644 src/libcamera/shaders/meson.build diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 34e20f557..90d434a5a 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -76,6 +76,7 @@ subdir('ipa') subdir('pipeline') subdir('proxy') subdir('sensor') +subdir('shaders') subdir('software_isp') libdl = dependency('dl') @@ -182,6 +183,16 @@ libcamera_deps += [ libyaml, ] +# Generate headers from shaders +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 + # We add '/' to the build_rpath as a 'safe' path to act as a boolean flag. # The build_rpath is stripped at install time by meson, so we determine at # runtime if the library is running from an installed location by checking diff --git a/src/libcamera/shaders/meson.build b/src/libcamera/shaders/meson.build new file mode 100644 index 000000000..386b342d0 --- /dev/null +++ b/src/libcamera/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 95d657ac9..3deed8ad4 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 Thu Nov 27 02: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: 25218 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 8B043C3260 for ; Thu, 27 Nov 2025 02:23:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DBA6060AA3; Thu, 27 Nov 2025 03:23:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="vSeHKphW"; dkim-atps=neutral Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6E934609E0 for ; Thu, 27 Nov 2025 03:23:11 +0100 (CET) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-477b91680f8so2521685e9.0 for ; Wed, 26 Nov 2025 18:23:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210191; x=1764814991; 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=BYLFp48Jtlh28DV0l7WkmFCL3lrDfDHVbIKL8htzT4E=; b=vSeHKphWtBjwqNtxLIGKXnm9wfqSmDElHzmWyKjB3iKQhucA/WBBdhR3GtCYYdWTYJ Fk6NS6W183UHV3qZgmb8pfD/H2w60mdSdoymGczROk4aIDzX5ZFxBE7Z/3q2pJwq9yex i2KV1uJJau0A2JxOJHSXE+AqW1PUz6TaqaybbcOwY6kKoJ7vczftPErLWsH2nd0E6fe+ flwyQls7x390DFZY8dQ/Jc1LSsFLnDeJhv8K5RUoxNs14CCuhM1w0yGGXXGqfPyZzlbn Nla5r6gXm2R7k4/1hNraBZ9FAayMT5CM52/4P+o1JxJk6MjB1ZJ4bUIr0VeNNZlzRX1R PuTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210191; x=1764814991; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=BYLFp48Jtlh28DV0l7WkmFCL3lrDfDHVbIKL8htzT4E=; b=gsM9W0SY3AtFDcwV3XlBUtVZEcJnV5VLwlZfeSrtkPN0EwREFQC0K+SSENavdFHOmT Y7LRAxS8fERpt4hz+cbAAcy5e6cQkB9ST6tP4QefJb6m/1TXoSioJANYRgprujm0GRK1 /edEtVUruBAt1ZP9dE3zoKv5s9zVAGPAybmqQbOaW+nCNU+lxMPmWUuu4Qa9xdEltcPa LXL6xA2RNp5Ra5ELRIAUTg1N3D89qN7mXc86Hp8JHeiu0ANpjSBXJJiq1/g/2q/5LAD8 T7dhSJVRQRGvUlSE0lws+LK9hXeRpIubkRdbZXmdGhIOU6w+qsCe/8CEKnuBypYwymdD dLUg== X-Gm-Message-State: AOJu0YxiQ/FpiOJKJudJx8Q+DOkljD+q4j7uT2fPBNJ7ZnuIohleflS9 W8PwmP0gEk3u0dfnEqY0/es0MoVrQ+O4/OWE0SGQILZNEjlTlztCvdn6SPmmwEDQXvJGwQdfLVz m3uFAk8I= X-Gm-Gg: ASbGnctBj0GIiLZr1K3pZKT5EpivwjNU+7VcHbgDKTkjzX7Av9Xc76/7xDx2IZ/+Xii YjCTW1m+LeBRo91YXB4sq1mD6ee6tPql6DjPf9HNOyg7JZmSOOQ7QvxvOcdZzv1V3fNThPU+kbs 9jWCY73px1tjZmkS2q/OTz9zPLqt0pKsm/4seBnF0ZFSa4h/JSp7iGH/FaEXJ6cfXK05PCquEnl KxyENCRv1QFDLXxIOIZAlFEhzSYniPEIDL9G+LGnyMIk2+EzeNAS9Hi0ZLY0m7eVV4XOIrJe3s2 gQCAyx639AmgizWnzXpM2VHEVs9XXS3UakjBoBQRbJ1l6CMJZyodvxn7ilKVbgFkNm5qyg3c04s 2k3G3ouhnw0Ru8WRz4De6qXohznUPWyVLF2A2csNj5ANa83ymhNqoR34PIyR1t5JfwRv4f03uFN THOc7poZqG3XWrOlKW33Twu5nSW8J9Q3Xh35JafoT3H8/JhTxOdhb7ymAoR5lvz1IFq5Y= X-Google-Smtp-Source: AGHT+IHBz/3vtDnicqmetnkw42IdBF/8X5r27QL4RKG7YlAjPxsNYcs713zTv/NMssvNTVejPGNxKQ== X-Received: by 2002:a05:600c:3ba1:b0:475:dd89:acb with SMTP id 5b1f17b1804b1-477c11160cdmr221865095e9.22.1764210190788; Wed, 26 Nov 2025 18:23:10 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:10 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Hans de Goede , Kieran Bingham , Milan Zamazal , Bryan O'Donoghue Subject: [PATCH v2 04/22] libcamera: swstats_cpu: Update statsProcessFn() / processLine0() documentation Date: Thu, 27 Nov 2025 02:22:36 +0000 Message-ID: <20251127022256.178929-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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 4f7bdd231..9c03338a0 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 Thu Nov 27 02: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: 25219 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 45F5FC32DE for ; Thu, 27 Nov 2025 02:23:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E322A60AA9; Thu, 27 Nov 2025 03:23:17 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="b3FKNia/"; dkim-atps=neutral Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5CB6860AA9 for ; Thu, 27 Nov 2025 03:23:14 +0100 (CET) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-47775fb6c56so2184105e9.1 for ; Wed, 26 Nov 2025 18:23:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210193; x=1764814993; 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=J/rNUy6IT8Dq/gobx75Pygy+h2VMr98GtCcoWBBrzZU=; b=b3FKNia/pTL8Gzzs3m6538qLSVZViF3rBTyjAJNBXrWpzc4ir5Lo2bLxgw9o6PkuZ+ qXLZy8Mu3hJEfswJwEH6xr9aC6GmTPlSIUOckP6dI+uh+c/oLNMEH8HkDvi6X0bmZPHq ax8HwH14llrsfYK6NO6aBEY6FxCYRyFVs0FuBY3ue+roekO+t0kr2oFasCg6HDSeY6Ko Nbb2TgiQJe/3BWB6LRKWvorbgnBTyUOJp2hrmFT6Yia7gxIeAP9DauBSkO3jIncF93yd vp64cWx2lwM6WhQ+gSdnzBXH6MYluNxb6i79WMAPqUQdyB4V8g+Kb1IVKoCXDcB7Tc7j OVbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210193; x=1764814993; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=J/rNUy6IT8Dq/gobx75Pygy+h2VMr98GtCcoWBBrzZU=; b=a4jNbat7gkavwi8g+Whti/bF5EquB7N6QzPyVt/gWpF3GrPqIt7nf9vaRNcyxEEl5J ndgRJ28Nv0MVEo+gHVp3zvb+GbNv0Wauy6T6WiZzRhFYBOWz5O1wdBd4bzM3JIdcWiyi +ubfhM3sBmIQuvgn8zBtjmkZ3pJr/qyr6hpvP5gijwFXH5gQkNSh1ClltqUkRLkc6VHX 9Pbw2icet6BWvkKmuRG4D88VsJpNDLpa0tu6TgM9HLTXdEe8v935mEWtCxE9DdkYDTZE Rp5b5TnT6tuPkckst8jkl+03AGVfuPEJ7/+CPE+k0tPgqn8n4T40wxI7Q+1YTcxuwZqk I47Q== X-Gm-Message-State: AOJu0YzgLtr6Xqq+d39uZR1i35NC+Ogjhcd9PmHVs/6jsznulYGBjD+x uhsk3/fzmCZIjRxy+eSzqXDqnt6ZJv8AKmPSSPjBGP2DCby6Y+iy3AV2xsjxPCUbWXpj4iik1p0 hr3kXbDs= X-Gm-Gg: ASbGncvbJE9seKIIm00DJOHoFVKzxJo6+kU/tEpp2z5y7TpkciMvB+AadPXxLoWKSD4 owt7sNrL3l5o22VXLQzSNki/yIU+szidb09ANS2MUdYiHfdBHIeMmlDeRs2twPazGkr/UHJA81+ ZdPx1ilryK2qXByma2tQVQ21D4zp5pZAQBsszbRx8V5B/qfdP4tP0OJ1hR+yB443/JVFcLpTahR zLzFexMnAnCXecNkc5WKZ32eH7WvmmA8BYOUhjxrxKBDPl6pzipUOuMfKf5xioQznKQ5aerfpR6 eI9fW70JlVBuAZqjDy2Ks1p3eWOYzgfHcsxCZVLfelPbJw9/w6OcUZct4BZ0TqQcV8/bEo6I86E 7KbPwmVz8WajbDGTZ6dBkrDRZW9XGWNwY9spF7H//e2h/s6bgiU7M5nx8Fa80hePytd403pr64D ZLPyGl0g+K66RN2eTJIgBh+qCk8MO/YI5aumYAQNQWo10EgMaEErY7x+akt9PAd3Mc160= X-Google-Smtp-Source: AGHT+IG+4HDeeBVqUG2ryDEThUnIMvZatnZ5f5PM9BLVIoidVrjQyXDW4ExQUOkiA7TrK1Buyc0pDg== X-Received: by 2002:a05:600c:35c6:b0:477:a36f:1a57 with SMTP id 5b1f17b1804b1-47904acae1fmr99492535e9.3.1764210193528; Wed, 26 Nov 2025 18:23:13 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:12 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Hans de Goede , Kieran Bingham , Milan Zamazal , Bryan O'Donoghue Subject: [PATCH v2 05/22] libcamera: swstats_cpu: Drop patternSize_ documentation Date: Thu, 27 Nov 2025 02:22:37 +0000 Message-ID: <20251127022256.178929-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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 9c03338a0..1b33ffa71 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 Thu Nov 27 02: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: 25220 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 34435C3260 for ; Thu, 27 Nov 2025 02:23:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B45FB60AA8; Thu, 27 Nov 2025 03:23:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="VUxyWih1"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2DA3860AAE for ; Thu, 27 Nov 2025 03:23:16 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-477aa218f20so1673925e9.0 for ; Wed, 26 Nov 2025 18:23:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210195; x=1764814995; 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=POEtUhiKDMucv1U75gLO1B2WYaDcFKD6qvD9bzHNOGM=; b=VUxyWih1qjzSxx2B9p3mtnAX+yEQcLuWcYbQd5pyTKEb8LiS/2G2i0xKGSwbsT80rk RsJRPrO2M8Uq77RBqrCmDZS01YA/v+a9UNZvJdWigaG9PF6ZFM3XwFs24YoIfZFFpd+Z gh1L8ujfrdt5x3UjwOlX1pFbECRdakn8fF+2AYFVDDfwMe7ErN2PDCkr+oFIlaw2DZtb 10H2iZecW19jsSob5kUy5vCVf0KPINqTSzwiTSTYIP0l3HHX5pRbD1fK2bmAM6W8VESc LpMxI7I3O8OZwDdw6HEyh8MckUGY7dVes84G9qxAINd1G2frnFQvJOMBZE43YbX4PM9T U3XQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210195; x=1764814995; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=POEtUhiKDMucv1U75gLO1B2WYaDcFKD6qvD9bzHNOGM=; b=U//n+ZxEACaxUnlIPUxmv+eMon1/N2NM1/U17wa6KFB0EyXdisN1PKh4RR+ic5tOZL EUZZewT0rjsAb6po02pWE0wE5KMjxhFOrdVR8R91QWqgBO/oJZuM98GTM/Bx9PAb336u j1yW1rax8l5UuSd4IACogHIX6IcL08JEsZXathvpGmaFybhsim+Q5wavxRYpKUn/eKjF 7b7z/1xP2PAqzD+ABL50+03b+Ah4hh7gUJiLTD0sr9r6j+8sPYFEvNDjbJdkr9d3w++s y+BthldE0e+aZDotq9uR8znyMbU6r0NVGguMJG0MwGvpkkGW4dHKQnktkyuxRnqQgcKh 7sBw== X-Gm-Message-State: AOJu0YzmYG7kteMlzvJ9IymuX70K+LFvrAAriHzx/eHWqoVL7HsDM+kR K2suFnBoHWb+fittH6AkHZXRmYsZVgArCBr2Gqr7Rmb1cAwW2yI3rL0bZapB5meJodLj0aiXtrb AcAlO/aQ= X-Gm-Gg: ASbGncsG3NSjXddyUjSYzN8vqoVto3pZle8XKXgouNHju3c+T71KiChtMZzxyW4heDI kN9pnFvE60GnLgTiJds6W3qxL9E6e32c+h0sLwjmzxCMtTRRC9aywizhmMUAKX+doQJgUq7Ru/v I9TS4UscJ5HbRT4+e6xkK+dLZI/BJ4JBChgXXO4H8vePc2J1CjkZ0ea5xuSEKdUgZxJ9Cs5yEz8 o2fPMMBsv20ddfPgmBAFFaAeTIZ5zCh0lktEo5WkZzWFr8yoYs8ZFgYaqhBAWTzMz6ZKdnLosA6 o97UuWWyiwHPUHxwmt4ekQ6UzBdB0cR5B/oyP1h8XLzlJMGLnH4ni/l27q+VLley8FRN9X811Zy zWH8D64zSBKvPvL6D4nV3atp1O0SCtaObL5LYIh+v8e+fGbrCJR9aTNLsmMf+P+BOH8PGmWPNbI GatRyEdyWs+6fF8a4vO3ltIFk5fTWY7TD3tCBXOTtNILKnX1vH2QbW6c17nNkHxxWCC/O6fOCzv cPQSA== X-Google-Smtp-Source: AGHT+IHFmQJXOwiv4Q4DtBecYvf9T95NFc4MY6cHvIOM/k/OgZd+K/2iGrzV4txRcVLTmMtgsys4Tg== X-Received: by 2002:a05:600c:358d:b0:477:55c9:c3ea with SMTP id 5b1f17b1804b1-477c01f0b32mr217320835e9.35.1764210195532; Wed, 26 Nov 2025 18:23:15 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:14 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Hans de Goede , Milan Zamazal , Kieran Bingham , Bryan O'Donoghue Subject: [PATCH v2 06/22] libcamera: swstats_cpu: Move header to libcamera/internal/software_isp Date: Thu, 27 Nov 2025 02:22:38 +0000 Message-ID: <20251127022256.178929-7-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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 508ddddca..ea3f3f1c1 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 03e0d7843..1cd411f26 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 1b33ffa71..55e764b0a 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 Thu Nov 27 02: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: 25221 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 1B27BC3260 for ; Thu, 27 Nov 2025 02:23:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B009060AA9; Thu, 27 Nov 2025 03:23:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="oBnt5cj+"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 58CC460A9D for ; Thu, 27 Nov 2025 03:23:19 +0100 (CET) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-477a2ab455fso2940405e9.3 for ; Wed, 26 Nov 2025 18:23:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210199; x=1764814999; 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=ghAief1BczG8dBZtklHiLxUtm0S3sgE9QT1CVt2nttY=; b=oBnt5cj+H5I232IFRbAC8HqDUdBRVXAF4iHeeSKe4iQkUzFHU+ZlL1DZbJ6j7+ppUs z5GnJj+IdlmszfhKqzoStW1FbY0d0ViGjsFWG9YEUylR9u6OiNbqyZV2CbFNxIFAhYCt wBbnMRGQr1zi4gNYRvcrrXBUE09dCpHkZzLFApyHg4u9JmOL9Eq5g+y7DBKY3uivqvQM 7o9tLFDkqM46IfG2unGmttNtHJMIn6yvChczAUQzYLngEwF9QomFWqwrP51BZ1Ci5+pT aH9fkLbd43zwBH54zMadyXylIVBm5klbCjU/QoPhpNx8M2I6lsVcvGGpsjBDVf47Fc2O QQ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210199; x=1764814999; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ghAief1BczG8dBZtklHiLxUtm0S3sgE9QT1CVt2nttY=; b=KhWHPlqlYZjIP0CzowqATZXGrESuuE+u7vNHw6Ms0YJ+teyBKo6jh+zKr07SMQL5pW e+XkgWZG29y0BL2roiZl93yhKK2j9rn0KQCvp5sB+PRpWaKO1QzR2f7xVfNUSbHp6Rs3 4GntlNIbHa1RfTWyuSHYkxJaCzAObvxRYjDeHmFwi7E72hRgyW6NpfoBxwl8AMDwnGya vyiWqUg+wfq+UD49TKcEftIB3k8BVs50H9Xht1dj94rkLShKhNxmuJI1CVLXFGTQD4+2 nBPaQKhUNAVoBGHwSlL7aRrbVNCEVE7NB7pxG3IPgLai5jJtG0gj7n5yCwqvLRGhP5Om qyhQ== X-Gm-Message-State: AOJu0YyNcOSVFtRpRiEzJp3Z9mVWKHlS41vKLTHW1fZO+KePBPPMxcNk 85uuMMEUK1C8EggYW6uWwaJmr/7u1m6iTJ7LuQAJ4vbW8xNaaj4LJOV8Vyn5M1oQJ7yfV7icjH9 bGChhv3g= X-Gm-Gg: ASbGnculTzYBBmyyUBugQaObGm6eESKaq/r3PdmJxeuR6L8BT9cJGopbkxxenoBpO91 qGl0niTr5KzFyMlAw7iIgHfplcM0958d4ic46xNi6Jbza+AA4Kf//Wl144WrsIkn4L2Et07ur5V qx7SNjRffOxybrg4afYHYmVkjyR2q1Bl/sqPURkHCR//npZP8qDJD4Tb3qO/d9vU4nYFsfB512h oEn2Prpy4s2849H1A37R5T7pnx31/0JnNEV8uk55TmKzlfR7342NxrFx6WQi7ZQyadRm+pp2sm5 VfhF0LezmjVDorzXMwpeM3++Bg+AlicQe8Y52/Xe3LB0U5D1u5WvGYUvhLcd/jEfZQXimA0c8/m SJR4q632u3I/Zj7zgleuCUqbZjYHUFdHfkxYdXycR5dz43D6c/e596dE6BCrZDxooq/gYw80fT+ vSNp3iOTXUZYyJKz2D13NcsONdeOygDRvZwtF32kSCsci73YdtLlccXrbmGMQLReoIkAE= X-Google-Smtp-Source: AGHT+IGpqWkgYJ279IAcLHPS8Dd6KRGh5emfjUUCY0Q3U2V2wzisj4t2/8V0Pxk4U7EJiN9jiqepcg== X-Received: by 2002:a05:600c:474a:b0:477:b0b9:3137 with SMTP id 5b1f17b1804b1-477c10c8886mr221386165e9.1.1764210198591; Wed, 26 Nov 2025 18:23:18 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:17 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Hans de Goede , Kieran Bingham , Milan Zamazal , Bryan O'Donoghue Subject: [PATCH v2 07/22] libcamera: software_isp: Move benchmark code to its own class Date: Thu, 27 Nov 2025 02:22:39 +0000 Message-ID: <20251127022256.178929-8-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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 000000000..0680d6cd9 --- /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 ea3f3f1c1..df7c3b97d 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 000000000..1a00ae569 --- /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 67a303c65..b92c6a904 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()) @@ -840,18 +812,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 1cd411f26..aff32491e 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 aac7eda7b..59fa5f02a 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 Thu Nov 27 02: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: 25222 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 28006C3260 for ; Thu, 27 Nov 2025 02:23:25 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BFB3760AB3; Thu, 27 Nov 2025 03:23:24 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="u73BjTwB"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DDDDC609DE for ; Thu, 27 Nov 2025 03:23:21 +0100 (CET) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-477b198f4bcso1688635e9.3 for ; Wed, 26 Nov 2025 18:23:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210201; x=1764815001; 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=A9hMkgjtaaGL70LDUYBXAqBqbvWKiYH7aLBkdndlC9Q=; b=u73BjTwBbiOSpQUpDRTBccAZ11l3PbZa7ni3GR8RefCHevzETztXw/Int2FDsdrbiG DmIF//nTBBS1+d4FtmKeb8h/5UJsskW9JRPoyJWG5KTtnWlgzWxStKs1MKRZJos0wXap dGP+yhVPCnAsqi/Buj1n8ikDZNUbzMWgjpcVrzQsq7VC16b2PAToFe++bpPQvZ+Li5wo 2RiwpXdMLirhbLm2SUElOBM7S7D2G5BqDiexsaRbYtxEzTf2SNB8y/G1UA5x3YxnpmoW J2BIatzCw8+ulyQBqoENigyBIRb6h8SwqyQPHr+YBknuq4AfUxVS0fQlYzQPjpLm6PQt hJNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210201; x=1764815001; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=A9hMkgjtaaGL70LDUYBXAqBqbvWKiYH7aLBkdndlC9Q=; b=Pga976cad6RY6PFqUeR35RLJe4XEWeUm1iLUbD70MwfRyQYdphwIH83nvBgUt728mJ 2BC1Wz43WnU/yjzgpF3HeKBtzTBwIIzJsLtN6mLxbLi/jpBuEQjQX7WrlOpq0YIFNPKd qGl249J5IHE6Ia26S/BRtgmLrA4bY9Ob6eqonHkD0NFDH3F4rMdc40ILyCOYFc4oBK80 veLQsIBxW3STeatmapfDWfB83VJgtbTOlq1WP5Q1IU++kvuRCOrrmJrnPCEA3tJcMeJZ OOg0sYVX2YIUbs9/Fap0fT+EJ+ajbXuUbLWRszLMic3eSX97JuMHw0RtJkqsWPwL95Y0 kndQ== X-Gm-Message-State: AOJu0YxOHbW6pXwRj9vmwR9EgWYk9Zi2UjTo6hdcP76NkpYk5q2x9yLR 8DxeGU2GJHunBpYX2QG9gurMLp3sRsP4g6iumsxUUGw/LDfcFvDudXtBN4siGqOB5pg1mAZfnEu fLS3+JcA= X-Gm-Gg: ASbGnctzHd4W9ymudStcrQ0xAF9yYlGgwAUcXqbh52zdbT+ARmByECGkO3E3klyE30D OGnbNNNzi3mYHUiIB+Wkv6pXxGfkCJMnK24ukMdFxaa5RNBjkK8O0nU7NL/NGtgrCtvdB/aQWCV d+/6XIjMSG6rBl+nmF1MV0YopxPIVITcACjvfBaBdL1+l1/10fP0SwboY259ocLN5+67q+QC8Cx 72Xr9N0XWwNv9qXha7yK+rMHT+RoWtyPCb4QrV+ChNVd6COn9KI6KF7E+OolzmN4s+CvcNR4szp pKDgdsu78D0leFKhrNXOXuI5pVlfgXaIxvWtiTzLnAxR7N4+L9sFqVpcZ3bC7NIOXvDoEzLHZjY p46Ie5MnTvqm9EE89QynbT1qBuhG4/kY0RIRF5iEP2KInynkm7MZL2nv8PyECUfd+jDcjehz8kj PVzZq9nq8ll9WXpazvaRTNONrcsQTYkcp+2J2IbOY7YF3hXFZ6Qqv3/WXtRMnp64SLvHs= X-Google-Smtp-Source: AGHT+IElCx5uzIUcxPxm6/XJmlolZJ83ntm3mRPL5g7cgwhhAMYJMmYcLAO08dTIfLU6gXA8y4vhjg== X-Received: by 2002:a05:600c:1c88:b0:477:9cdb:e337 with SMTP id 5b1f17b1804b1-477c0165badmr250069365e9.7.1764210201190; Wed, 26 Nov 2025 18:23:21 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:20 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Hans de Goede , Milan Zamazal , Kieran Bingham , Bryan O'Donoghue Subject: [PATCH v2 08/22] libcamera: swstats_cpu: Add processFrame() method Date: Thu, 27 Nov 2025 02:22:40 +0000 Message-ID: <20251127022256.178929-9-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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 splats fixed] [bod: Added constructor Doxygen header] [bod: Squashed a fix from Hans to calculate stats on every 4th frame] Reviewed-by: Kieran Bingham Signed-off-by: Bryan O'Donoghue --- .../internal/software_isp/swstats_cpu.h | 15 +++- src/libcamera/software_isp/software_isp.cpp | 5 +- src/libcamera/software_isp/swstats_cpu.cpp | 69 ++++++++++++++++++- 3 files changed, 84 insertions(+), 5 deletions(-) diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h index fae575f85..64b3e23f5 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 341c0352c..928a2520c 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -108,14 +108,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 55e764b0a..c931edb41 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 { @@ -34,6 +35,15 @@ namespace libcamera { * instead of processing the whole frame. */ +/** + * \fn SwStatsCpu::SwStatsCpu(const GlobalConfiguration &configuration) + * \brief Construct a SwStatsCpu object + * \param[in] configuration Global configuration reference + * + * Creates a SwStatsCpu object and initialises shared memory for statistics + * exchange. + */ + /** * \fn bool SwStatsCpu::isValid() const * \brief Gets whether the statistics object is valid @@ -144,8 +154,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 +396,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 +424,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 +489,55 @@ 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) +{ + if (frame % kStatPerNumFrames) { + finishFrame(frame, bufferId); + return; + } + + 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 Thu Nov 27 02:22:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25223 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 3874AC32DE for ; Thu, 27 Nov 2025 02:23:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CC86A60AB5; Thu, 27 Nov 2025 03:23:26 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="uafm4k9j"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 628EF60A9E for ; Thu, 27 Nov 2025 03:23:24 +0100 (CET) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-47789cd2083so1244905e9.2 for ; Wed, 26 Nov 2025 18:23:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210204; x=1764815004; 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=xct2DeCKpVaCKpyr73/2/r0NH1wGrT5ujJTl4HH6e1M=; b=uafm4k9juJJGjMVcFiRPGYh7+8X59gjvqCMSX/ejvQ2IBS5OPIDlcGeCrIFLj5jQZ3 DABA4UGm3z+VI68SZVSP3z7RPRK1DQfD/0umK81cEDg8IsKulUFfTpfYBQlCy6woKcGL VreTR3xJb9AintfO4tvX3mIt0yDlSU5GW2LNijXaYPqFNIwXGgD0C/aFRuu5LFohAXi5 qrfgLvPygKnL7Ciicx8+g8lUAZ3BIiGqExXbW3joqpjNai/W9hSiKJED2byOBx0Q6gOV Rt5EqQa5oOQl+sNacZ1/7Z3fcVfjsl1mO7vTEKpmaGMzfyitb5pElHvIwDjDvpIrN3Fc ulQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210204; x=1764815004; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=xct2DeCKpVaCKpyr73/2/r0NH1wGrT5ujJTl4HH6e1M=; b=lmcQpuazU39YPdYZ/zGgnA4lhRNRswzHKea5M4Y3Wca85I5DqN7YmIq+Sgxn34RwJ8 E4xh9y3QSo2zDMy9C36zCUfYbIQnNlr0WgJ9rLgwFoBgDW5PongQrT334CCrz1FwUWm6 sIDn0V6X7/loyiUtrBUdBB/3hTyUY/sdyt9DWnxT/wyIiKEEBD96bki+qQFiw85MVzDN VyIEd4luWnZqrIprCqtQrC0B81ECfiw56BVXVUSoy50r3U/3PlLlZl51vR1b1U0D1YbP 38RO/bL4dXhiYMaEHzmypQlDaJp2yFm1djIdpF12hDUDOJso/A2n0BqJA+tIDllUCPgw jAPA== X-Gm-Message-State: AOJu0Yw1JyZQOQgHgaQkaTZw3nIUMHJFoK86Vb0AkfP2lBhTOV+xoZju TqoEncbXaVOyVEnkO8afUUzXYNswecVK7/daIduY85T6RIKMK6lOOeMHg4LrmMO6ZPHJJQye5nk 5/KB2nZk= X-Gm-Gg: ASbGnctSNN3cRuWDxna+LXmyJ7ip4mdAq0/qzZZYFR9y1rzvA7dBC2g82mvPHGdYVbX gAlad0MRgYq3yYgYUaQ83fD1eI1q7HT+pM+XLdW4Oca2JwwIjKdIKmuRSwzZx2F5L6lFTMQTk4w 4QOebk3m5XWldnsGpkAJBriqRlxR7FZuylHJSiwnApFBvIPeBesDuWHiG6gvH7KZaf0OH3A8/ji x7vGUWRybMlkKwo466ErY647Z958huHtu715GQRmKwZRpBnfWUK/2VwuJPXBygQNkxY/+YW3Wx7 tjUn2U5gAlqEj3e0s8k+T2sPxJUaqbDiTcpW9pioekcnKMRwwGUp4XzTB67rtLel1tkQJ7oLEGb aybt3DLxT12qdy8VPoMg8sn54F/rBZakEsclKK3m2pPtpRm3d5iaUQyvwoB4SeCtMZqM5vG0WtH 7O1NQ+h4e6RTFbEbGBgc1m94UwzreFMSkaeZ+qieh6cYFjZpd39xp144ASGVd1WnRMWS2WTJMdQ INENA== X-Google-Smtp-Source: AGHT+IGI/hc0K7DjMIv7Rj8hgK9OB7/DWKVJ4oL06AL+b/ZYJU1Du03P3SO2XaCw3jH1qeNayv0U/Q== X-Received: by 2002:a05:600c:4443:b0:477:af74:ed64 with SMTP id 5b1f17b1804b1-477c114f00amr215909755e9.27.1764210203735; Wed, 26 Nov 2025 18:23:23 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:22 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Kieran Bingham Subject: [PATCH v2 09/22] libcamera: software_isp: Move useful items from DebayerCpu to Debayer base class Date: Thu, 27 Nov 2025 02:22:41 +0000 Message-ID: <20251127022256.178929-10-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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. Reviewed-by: Kieran Bingham Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.cpp | 149 +++++++++++++++++++++ src/libcamera/software_isp/debayer.h | 35 ++++- src/libcamera/software_isp/debayer_cpu.cpp | 2 +- src/libcamera/software_isp/debayer_cpu.h | 41 +----- 4 files changed, 185 insertions(+), 42 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index e9e18c488..1e3f08673 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -18,6 +18,12 @@ namespace libcamera { * \brief Struct to hold the debayer parameters. */ +/** + * \fn Debayer::Debayer(const GlobalConfiguration &configuration) + * \brief Construct a Debayer object + * \param[in] configuration Global configuration reference + */ + /** * \var DebayerParams::kRGBLookupSize * \brief Size of a color lookup table @@ -167,6 +173,24 @@ Debayer::~Debayer() */ /** + * \fn const SharedFD &Debayer::getStatsFD() + * \brief Get the file descriptor for the statistics. + * + * This file descriptor provides access to the output statistics buffer + * associated with the current debayering process. + * + * \return The file descriptor pointing to the statistics data. + */ + +/** + * \fn unsigned int Debayer::frameSize() + * \brief Get the output frame size. + * + * \return The total output frame size in bytes as configured for the + * current stream. + */ + + /** * \var Signal Debayer::inputBufferReady * \brief Signals when the input buffer is ready */ @@ -176,4 +200,129 @@ Debayer::~Debayer() * \brief Signals when the output buffer is ready */ +/** + * \struct Debayer::DebayerInputConfig + * \brief Structure describing the incoming Bayer parameters. + * + * The DebayerInputConfig structure defines the characteristics of the raw + * Bayer frame being processed, including: + * - The Bayer pattern dimensions (\ref patternSize) + * - Memory layout parameters such as stride and bytes per pixel (\ref bpp) + * - A list of supported output pixel formats. + * + * \var Debayer::DebayerInputConfig::patternSize + * Size of the Bayer pattern in pixels. For standard Bayer formats such as + * BGGR, GRBG, GBRG, and RGGB, this is typically 2×2 pixels. + * + * \var Debayer::DebayerInputConfig::bpp + * Number of bytes used per pixel in memory. This reflects storage size, + * not precision. + * + * \var Debayer::DebayerInputConfig::stride + * Line stride in bytes for the Bayer input frame. + * + * \var Debayer::DebayerInputConfig::outputFormats + * List of pixel formats supported as output for this input configuration. + */ + +/** + * \struct Debayer::DebayerOutputConfig + * \brief Structure describing the output frame configuration. + * + * Defines how the output of the debayer process is laid out in memory. + * It includes per-pixel size, stride, and total frame size. + * + * \var Debayer::DebayerOutputConfig::bpp + * Bytes used per pixel in the output format. + * + * \var Debayer::DebayerOutputConfig::stride + * Line stride in bytes for the output frame. + * + * \var Debayer::DebayerOutputConfig::frameSize + * Total frame size in bytes for the output buffer. + */ + +/** + * \var Debayer::inputConfig_ + * \brief Input configuration parameters for the current debayer operation. + * + * Holds metadata describing the incoming Bayer image layout, including + * pattern size, bytes per pixel, stride, and supported output formats. + * Populated during configuration. + */ + +/** + * \var Debayer::outputConfig_ + * \brief Output configuration data for the debayered frame. + * + * Contains bytes per pixel, stride, and total frame size for the + * output image buffer. Set during stream configuration. + */ + +/** + * \var Debayer::red_ + * \brief Lookup table for red channel gain and correction values. + * + * This table provides precomputed per-pixel or per-intensity + * correction values for the red color channel used during debayering. + */ + +/** + * \var Debayer::green_ + * \brief Lookup table for green channel gain and correction values. + * + * This table provides precomputed per-pixel or per-intensity + * correction values for the green color channel used during debayering. + */ + +/** + * \var Debayer::blue_ + * \brief Lookup table for blue channel gain and correction values. + * + * This table provides precomputed per-pixel or per-intensity + * correction values for the blue color channel used during debayering. + */ + +/** + * \var Debayer::redCcm_ + * \brief Red channel Color Correction Matrix (CCM) lookup table. + * + * Contains coefficients for green channel color correction. + */ + +/** + * \var Debayer::greenCcm_ + * \brief Green channel Color Correction Matrix (CCM) lookup table. + * + * Contains coefficients for green channel color correction. + */ + +/** + * \var Debayer::blueCcm_ + * \brief Blue channel Color Correction Matrix (CCM) lookup table. + * + * Contains coefficients for blue channel color correction. + */ + +/** + * \var Debayer::gammaLut_ + * \brief Gamma correction lookup table. + */ + +/** + * \var Debayer::swapRedBlueGains_ + * \brief Flag indicating whether red and blue channel gains should be swapped. + * + * Used when the Bayer pattern order indicates that red/blue color channels are + * reversed. + */ + +/** + * \var Debayer::bench_ + * \brief Benchmarking utility instance for performance measurements. + * + * Used internally to track timing and performance metrics during + * debayer processing. + */ + } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index ba033d440..b562985a6 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,9 +49,38 @@ 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 { + Size patternSize; + unsigned int bpp; + unsigned int stride; + std::vector outputFormats; + }; + + struct DebayerOutputConfig { + unsigned int bpp; + 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 b92c6a904..e55599f09 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 aff32491e..ecc4f9dd0 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); @@ -41,21 +39,8 @@ public: strideAndFrameSize(const PixelFormat &outputFormat, const Size &size); void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params); SizeRange sizes(PixelFormat inputFormat, const Size &inputSize); - - /** - * \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; } - private: /** * \brief Called to debayer 1 line of Bayer input data to output format @@ -112,19 +97,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 +112,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 +124,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 Thu Nov 27 02: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: 25224 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 071E6C3260 for ; Thu, 27 Nov 2025 02:23:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A256360AB8; Thu, 27 Nov 2025 03:23:29 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="z5AMNo66"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B83EB609DE for ; Thu, 27 Nov 2025 03:23:25 +0100 (CET) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-477a1c28778so3189665e9.3 for ; Wed, 26 Nov 2025 18:23:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210205; x=1764815005; 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=rHp1ZpmpNd8F5seragsp7cEDNOHsYn8jNKQx3PfPjQs=; b=z5AMNo66mduPq1jHzSld5DGGqfkcpBjt0Qwtp9RkSHbtJJ9iVhWvQSlX0mVRS9enqP yxSzlnPMO6vZ+LTeaVDp4NoREEog2tAg02FCT36hiNKKR0saUlpYemrTllvXJHJgPO2x Ejf2yje+bWSSmRBCDTxbJ2GFF+xk0ywXM3kkftXfZu+VcE9/V7FGp83VGe0McvGrho0Z IrpB/e9LpzsrZXcb7njxeryFJKsigCNqwjMp0M4F07PbFpxADleh8gYQsfYukN2kw+bc +wJQNuyGRrsGDp7f49fV/PEi9YLzXN9BZgWWcmO/S38/P9RGe+99EYegfv796nIe2FB7 DZYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210205; x=1764815005; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=rHp1ZpmpNd8F5seragsp7cEDNOHsYn8jNKQx3PfPjQs=; b=FwIGvmB3zgkCgc64vmcQbnaZbmefPQk1CLtkgftwPS3hZw4bEwEpZrSgJnWiAQ02ws gBnQPQwHzeEhHJTixkKI8T7Df8ipa1Vy/vU9rDP9QQkS1Dj3Bi82DNveSghuQM2pbNfr RvAjFZ3C8GYpXGn+jLOgOLahtuOdkHckogXtNnOKvC+OKeoJ7AeFPIMu05sp0fqZfvT/ 4jpwWDu7yIxcEKRWzOihN5WsE2cSF6jAYevOXKIEbhK6xldQCh/h7zBv/JrZci3dhJTj m1IeWHo2G3sapgAAcW+QPBaYHcjfLMEWpKxi3P6LJZ2m6C0sq+iN3+VNaiabHM+YzZBb fZHQ== X-Gm-Message-State: AOJu0YwMQ2Y3eVrjGvEZMAwyJ+olbXkEoLM87vjA0tQzouXT6Xxa82CH Ay6lJlPnKrcII9moSjQeqjVQY9Fuu/gFapA1QvSwQrzqrd1Onrfs07JcKdCSo5dPVbxoBYx+CfE pswS0c7s= X-Gm-Gg: ASbGncucpM8mu/qcR70oMCkX3nJuAhfy7kG4MS/9z89FrKom5cKY57caj0nKvyFRr9C iwvo2FexIBg1GGyRo2D5R7WhkxsoYwxMhbcsZPlnm1D8zrxKi3kDENULzbNQCHSvx94xROWELOh OHclnrN98UQ+6kpeyV6tKuCficnSHIzhBgCOOnXhjNQQ+Mtz/KbmAwGgWJYZpqSTOHfwB28+XLN uRXBXz9v0onyuJmwfx1PuKikyajByt0ni8keSRcpsvNAU5zjAH/LGB/AJlwFX+bTIRthIiGMMek EWTi2se64KKn67MctDBIErFr0mW+2B1ybgqH7J7tjlavFRte6auWYuwkq1owggmur+nbletgqoQ LWbANWQTSBsiL8UMaWuPkgMxEaBiGeqDmhypT02sl1/vNrS6FsVXeaG04tvC6lev9XNY1nxY7qM 5OPh8rK3Z0HnhJu/amBvWdsWW/K+RSrZv2AZ6oE7YivvX4EQWYMzbhjFw5h+nlIcPsv8odthddC NRvtA== X-Google-Smtp-Source: AGHT+IFm3ugUOAuGXQVG7PI6CM//mxD2RbLwgIvj23fQw3ZTih/B4/N/T6qqDuitUveFarYzsfXUoA== X-Received: by 2002:a05:600c:4591:b0:475:e067:f23d with SMTP id 5b1f17b1804b1-47904b1fac9mr80618965e9.25.1764210205083; Wed, 26 Nov 2025 18:23:25 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:24 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Kieran Bingham , Milan Zamazal Subject: [PATCH v2 10/22] libcamera: software_isp: Move Bayer params init from DebayerCpu to Debayer Date: Thu, 27 Nov 2025 02:22:42 +0000 Message-ID: <20251127022256.178929-11-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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. Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- 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 1e3f08673..8cadfaadc 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -109,6 +109,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 b562985a6..f4373ddeb 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 e55599f09..8f42d706b 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 Thu Nov 27 02: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: 25225 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 140F7C32DE for ; Thu, 27 Nov 2025 02:23:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8895560AB3; Thu, 27 Nov 2025 03:23:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jlAzLN9a"; dkim-atps=neutral Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D8CC8609DE for ; Thu, 27 Nov 2025 03:23:27 +0100 (CET) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4779a637712so1750725e9.1 for ; Wed, 26 Nov 2025 18:23:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210207; x=1764815007; 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=bm3VvIoYtilkRcrlkHwpUjR5oXGGomKqNNLnlTko1eo=; b=jlAzLN9acVCnUfe8841H8sYcF2aeAVgo3jbuiLRVa7PzUm8UNmYSXkmqK73NgRWcV3 WaGJXqJIIgf1wCMari4fOm/WRFmKU/l5QGXgg7PqNq8ZLQ+de+hOMRg1t1F1mVnFwg7+ kTUjMVK3Gw6rrzXkVn3oIN7wHxWmcYr6OiUV1eA7XfoYa2dTlEPqCNBNxMT/g4ydkaTI y9AeaIf3BWK1dwng92p7tAQbTYMEIK7uOFpb6Dk1nCgBtQxpbC33BQEEg1k8EAre9PyJ 6AsJ/obm7aR6UwlqF43ACm0+3Ug5zDbR2Ri/yMLeN3vS42dGAdRhege526HIZjRflr9a u9BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210207; x=1764815007; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=bm3VvIoYtilkRcrlkHwpUjR5oXGGomKqNNLnlTko1eo=; b=l9oeurKlmt4iu3jggV2Nq9hHyM4LdsL+GW0DmPv809+ibrQcM1N1IBIwC8DU5HZecT j477oUVdlSi3jluBkeMTHWe62uGI9TmUkL6IpP8alcxGaDFNh79N5x9AzYB+01lWY/I9 CwkzEw0UaK8IwjW+2xdgMzBkef5MTlaMfBLW7LGJZS/5XeGZEG2XEj6dfFdxVun03hl+ wS9D787zOQqqhlLhdDKqpif+mXv7PYtrDy9eKEL1oYPBQouBOHyMeBG9QhqfK4XB6HHJ nvMzchAt1ESAgd1gUIEZmZY49RtQ+9qrrDtsCWXvN6CInnio64/5nZ5KN2LllsiW4jrF SSuA== X-Gm-Message-State: AOJu0Ywd8VP/7GT6mGAie4dflAgP24zvsQ/lDc0ND14eySFD6nz7gAcl 9v6jcLdv+Z9H/fsslmOCBgEs5yJCnKZRSrA+NMZYaPiTelkicog9dZOF71FIuOCd12x6Pmol+Jv ezXRk2qo= X-Gm-Gg: ASbGncv6e1K8qt/vvUu92oKRptUZNavZOcIR4DTBIlxCZmTKzyEgRKy/TD5SK5zGRzW 8K/iLQUXxMto1afbE2uaW3aB3NQVURnJLOAmxcq3IiCEZq7p4NNI3DlX4RKcWMnNIwrRR+dUKWY r+NlgoY4a5Es4aLY7lICLX/3vHssbmAl7REhr7ol+xg4rdRkz2hOxOmDYFjQFoi/3FcJjcU9YO7 pwm+ehWvVAKZvooOA4q0dFdAZ90HC6OifxEfk8dEcvfXHcmKaeHj+fDfz+cdXEguVtDiJ0Z71q0 Nz0KNg1EJ78UleJVHDTTbYsOCcYZ0m1/f8f3IPqlNRMx452Cv+GTP4RpsoV6hMUpt7yZHPngAuh iUyGLdSjMkECCpx3XEigFwe0Jqa5IYAvaUEYpBVj+FqvIAlkWtWBdmDXRdMrPn5ixkI6Lrn35IO XNnnDZRiM65c4dvHalDvloPYHb97Y+aY5BaOU+9Q49pytlYenvgpG6QEe0oRRtamqMsHU= X-Google-Smtp-Source: AGHT+IHUIbsxLRKbPJXH8ntpEMQFKbJjN3FBt5OHbba4Qd7y0U6mD/tVB631aZ5vTxvsEiWYmlPBQg== X-Received: by 2002:a05:600c:4e87:b0:46d:a04:50c6 with SMTP id 5b1f17b1804b1-477c01ebc76mr208671775e9.30.1764210207264; Wed, 26 Nov 2025 18:23:27 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:26 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Kieran Bingham , Milan Zamazal Subject: [PATCH v2 11/22] libcamera: software_isp: Move param select code to Debayer base class Date: Thu, 27 Nov 2025 02:22:43 +0000 Message-ID: <20251127022256.178929-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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. Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.cpp | 28 ++++++++++++++++++++++ src/libcamera/software_isp/debayer.h | 3 +++ src/libcamera/software_isp/debayer_cpu.cpp | 20 +--------------- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 8cadfaadc..cea30af67 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -336,4 +336,32 @@ Debayer::~Debayer() * debayer processing. */ +/** + * \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(greenCcm_[i].r, greenCcm_[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 f4373ddeb..6903caae8 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -83,6 +83,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 8f42d706b..6be5cdbd5 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -758,25 +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(greenCcm_[i].r, greenCcm_[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 Thu Nov 27 02: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: 25226 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 29F56C3260 for ; Thu, 27 Nov 2025 02:23:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C099460AB8; Thu, 27 Nov 2025 03:23:32 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="phwsoRtw"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 503E8609E0 for ; Thu, 27 Nov 2025 03:23:30 +0100 (CET) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-477b1cc8fb4so1601975e9.1 for ; Wed, 26 Nov 2025 18:23:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210210; x=1764815010; 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=FxhcasCeQZyIjm4rZ1EZcRl2EhvSjHrBdXO0dhQMDwQ=; b=phwsoRtwxMdBgUjIAgdFtPl7pcTHXnQDqPH0sdqvwoUno82zjGjrwPpdYrriNI94WE 0BddhYIkHN6yD3z9NUMRfCbcHhMhOD4MeUAo+5vb31n0l8H38Zg/xminv8dakSBMzeXg MUU5DXWWIvneKKSJqobDODg+GhRhP7yerfOL/gTMYpW3IvRhkbXLPQ3gVV3vjjDHPhw7 lPMHZv+ov1ABbh0aQr0mRTAS++4FdS2q0TavsHJGUevEgdcsCCIT6hWD6RXISFAsEtUi gav03RHp49ytRczkrPiBApR71xNM9+nGdL5bV6D5MhBICJ3bDaUdsKFngXlcPSsqs3HS ZT/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210210; x=1764815010; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=FxhcasCeQZyIjm4rZ1EZcRl2EhvSjHrBdXO0dhQMDwQ=; b=NRmIRXRg4sJ9E0Ft7Aj8DbUkzHYaI+s0xpUK6/FICYJ6BVPo67NkLfeUtU6rCIpFnr yaD/HtAwQ+GVzHq2+aJWFM4dSSzCPxD0GBP2aMUR5uVrXHyAKIIa+fnhNqqeQsAF7slW fPhU3Mv3kGWIXhwKEkuonTnNR9nVFcrHzJhrW7OU36OxVS5/780btxiwBEaupIxfiUIm gBiV6D5qoHWiwAaNEvrvfb40G74OSKgNh12iKrblG5fxbhii3UvNwjOcMO52ALHnaEx2 5xJTosuA5zLqiOPxaOpnEDkG1x662Vf3KnCYWswVGk8eJlQgkRGHiSoKTDYPo9vh4UOe SGFA== X-Gm-Message-State: AOJu0Yxda+gqfEqdC8L/NMP0yNPUNmTK/+qgXfVEJeDLOmLm3sq/zQ0L AJmJ10VEsZDi3DmlMorKZHz2yDhu6fcjlAON+3ai2rggVOipAMUYhrLVgzkeTC4dMyJiIAEEEsD XWSrq2OM= X-Gm-Gg: ASbGncvXPLmAIelWop2IW8JFMWmQxwxJmFzmryTJJrfqxcAJqBxpCtMqtptUpX+xuzu GyoTJ+ecwyZPUZJLPgTb8pPzwJkdYTusUvyjCTJNIAQTo8Y3T+NGOQ9mC0pOB+GqghAs7qbfeG7 ZT8qL3fhyk6nyDey2sJizh9tTIippCYkLdiDuHYzqz/fFHp78/t6yPl5Cjg7p4jKH4buHXuofym Rk3BSpsZ5fj30x7FhNwwNV0k+hxNHs0WKVghx3/R1+8+0YYUygF8Uq/PCqIi6ZV5AG+Rm/lz0H3 N0ZUnxpwJLsVcKwoIozNWtLqlET7W8qMpnIY0cPaqdggF7B5kV207LskdeJjYY72vP2tTNSYAKp MQv7vOKnZUFQmakFZsk4UooxK4yxRtT3ktrT0SRUoV8sdEqLVue3u0LFVL26Xcr2fy5/w9roEqV B+6FEqQMWoqRxUEB4EZckIOH+UZA2P1u5TdKgF3T2+CiW0a1TP/wiXkdBfzOoOaax/MRs= X-Google-Smtp-Source: AGHT+IGmXcU0S1DIAOSz/y67/itjsd2YKozqbxgiJcSS5mKbezUQDAnp/wtLNx9XCfDK/OH1JXxWcQ== X-Received: by 2002:a05:600c:c8c:b0:471:d2f:7987 with SMTP id 5b1f17b1804b1-47904b23c04mr76789345e9.26.1764210209717; Wed, 26 Nov 2025 18:23:29 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:29 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Milan Zamazal , Kieran Bingham Subject: [PATCH v2 12/22] libcamera: software_isp: Move DMA Sync code to Debayer base class Date: Thu, 27 Nov 2025 02:22:44 +0000 Message-ID: <20251127022256.178929-13-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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 Reviewed-by: Kieran Bingham Signed-off-by: Bryan O'Donoghue --- 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 cea30af67..544921656 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -364,4 +364,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 6903caae8..d2893d81b 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" @@ -86,6 +87,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 6be5cdbd5..8f1b4e53d 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 Thu Nov 27 02: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: 25227 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 DE587C32DE for ; Thu, 27 Nov 2025 02:23:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 787E260AB8; Thu, 27 Nov 2025 03:23:35 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="aYOMmWPj"; dkim-atps=neutral Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 95746609E0 for ; Thu, 27 Nov 2025 03:23:33 +0100 (CET) Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-477a219dbcaso2549635e9.3 for ; Wed, 26 Nov 2025 18:23:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210213; x=1764815013; 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=nJt84EldY/UglCQL1W1m2dIaAxw2bYU8OhkHNUoIlY0=; b=aYOMmWPjpFQFY/bbvfR8oVCsV408MCM1vdXs0tcaI0CZ81ulxMvG/RDtckZXm6wU1E WBvqwODAVPCx/XNulbQriYkOYFN1BWbwX3ZxcJd05EROF2WaJLVt9MYlwLmOyq56XybW e17lutM66yTQpSd4dGTEeOJW8k6m7Dz2evRstUDNgZm2CykPT+QDp4SHnXDFxplSW3tp BY5eNfztGShNZ75Za6OM0ZD9cyWZ+KZ7wQuu1CCYZP5PWW1CCvxb8kG0VNzZyidLcreO 1gBSvbuvc08jnK2aGXe6oEBnXDIZtTg1AJU2WveEGmh0KfoeK7az7pqoC0c3og9xj7mW bArg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210213; x=1764815013; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=nJt84EldY/UglCQL1W1m2dIaAxw2bYU8OhkHNUoIlY0=; b=Y5AL6fuCIg2WDu0lYBAXXOqXVZoPGOEwXqBx4qlIZZtRoX5rcBGW11or8yQ7Z7rug2 kZNYOAYPETDFc+hHsbuzWXkHUv4QmHSf/DEdUv3JLOEoC9g/7AehZ4pDQ1UYbA/gCDb0 /lUfGgaQek+JNNV/6l+gMVpyY/vdk70wpcpDkBWdsHGqWurxLNKFfws6dol45GmbWEBI m7DPpnbnqbuZodSaEvxIuM/37NwTaQ2iPD9glvl63jnXs/+jBO5NhIz3RoPTPI3SA6XL p4rz637auMTFRBPFv7FgeEM1TzmBpoE34tR+o28RyJU6AGgrarMpCl5BYPOEevXdQy1H j/Rg== X-Gm-Message-State: AOJu0YxlxirZpFnazSKJSFBaSvIZxQf4LDunEN3eYBXIdLgLJg7nbRfi JZhY04TsjQi340Ha+Nlh49AxHrl2ZNUpWksBCqKLD7tf0qvgZpyX/KwvdGQcS8TCIbEeF3UuiCb 2A8Nsnyk= X-Gm-Gg: ASbGncso30sSZx1+pcDo+PV/pIjljQ3xftaLP1D5FwCYzzDOxmv+YRy2R5BpxETkKBp k0FsTxIO/O08LpcfgTw05rqsPf3Q6+MtxLyoofpvPQnMfQdTyH5LUWEnjS1uBLmQH6P7E/4+5lJ TRFSot8Ti+kQcuSPt9GTsIXgJ2F3S2zMlNe9M9icFs55VVeOgzuaaaX59CnjG4GbPcOgb566kJ8 w0mpU1x9Ynt60camrQauQLVSUStrr/87KcdLdRra3RxfhtmeIYRxIWvd7JGWn9a3TInbk/moEeV rod1B96XcRJYgrnfmvlhuJ0mf1cqvjfARqIWxAAqJdPntSdd4F6QkqCt++JlGVB8cma1pGcdAdI hO+yt/CNb+vdX3Z8z7ZMTVk+3Us7I8Vzvb8oQVMuW7dUYlCOBYwiRi2calQ1KlOHEcujSX7Q2ww 1fk+KY8hNjisQvS/FdKaLxmEVrc1EbfN5060PnT0u5a2Ev5Zxm8b7sY0rkmSIANippLUM= X-Google-Smtp-Source: AGHT+IElLYWnFlCgIxzJ2WoVQbAGqyXQi48Ct4FYTWjmDHdZOg06nVgE1hHY0vX/ZAKm03gmVS7HRw== X-Received: by 2002:a05:600c:3b09:b0:471:13fa:1b84 with SMTP id 5b1f17b1804b1-477c0185bc8mr249147045e9.12.1764210212913; Wed, 26 Nov 2025 18:23:32 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:31 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Robert Mader , Kieran Bingham , Milan Zamazal Subject: [PATCH v2 13/22] libcamera: software_isp: Make output DMA sync contingent Date: Thu, 27 Nov 2025 02:22:45 +0000 Message-ID: <20251127022256.178929-14-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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 Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- 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 544921656..158128f30 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -373,8 +373,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 Thu Nov 27 02: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: 25228 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 7A20DC3260 for ; Thu, 27 Nov 2025 02:23:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1DA6D60AC8; Thu, 27 Nov 2025 03:23:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="gNYOAPIF"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 31F4D60AA2 for ; Thu, 27 Nov 2025 03:23:36 +0100 (CET) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-477b1cc8fb4so1602185e9.1 for ; Wed, 26 Nov 2025 18:23:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210215; x=1764815015; 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=jCaLe3/UWqLlNrzkfiMHL8sWpJisLkNSLQveLCRiGQI=; b=gNYOAPIFIDOiBLVCX6VYAvl+4NU8sXP6sUxsb1oJxn0bhKEk94BcCqioNH4l0aNXYk k/IY0LdMj+L4lf1TqmH9IfHuf6g+Rapw3WTRVDbEzd4VqCDsGqlk7SlgCoWqyuv/Jknz 9bqFfpnPfePZHem89IXiKkXjLb69wzSQqUAdm1X/6+h3F3WpaSl4MicPgJ8rJGJFgcja A7nCwWdKjYZsmC3M1Ovp4kBEyl64F5g+AGaBCMizrDRR2OSjCd9dyRJk8bjRLaJUV/1T b+Sm/k2SvXpqrWfUCLmy5zbUsb7mfm8Ke+zityfZRqOPex54OKp467qhVr14EO/Gs9mf FKzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210215; x=1764815015; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jCaLe3/UWqLlNrzkfiMHL8sWpJisLkNSLQveLCRiGQI=; b=tYgPthMaDcikk4UGICLbp/MR/3FDFfbC23EvZb31aF0dECJ3/amlQEYKPXiiSPZO4n Ype1qN/QfN0sFfov081YRMqjhXOzbH7qFJAfXVZoRjvb9+eUE8J1Yj5z/wTtNjlIWbyC xH7Daswmv1wNMJIaA8KiMvN7q7Dj2IUkR4JuT8gmgiNqp7n8iV9pBYRkEggl8gxReAoh LyHaGMqyGvIkH/rdvWkzrihXzFFzxoDEQnNF42qXL3FpcDFd4NNuiOYmPEmyp+KL3TaJ GfCbAltG4rd0OpdIgUBZaaxc77IqGIPN39dz2gTambz5OEFYXeF2nqCb/5isWYvCKKMS 1MjA== X-Gm-Message-State: AOJu0YywsXmJtr5F61lSHsdOHA8w6ZIOP3OiZF47cTVuyN3zxyjci8w0 TyvUYEASFWAVLbKErOZw9/GToASygNPeliAswiBCyByLyJXRitbQIlPrUtDnXov1/BD5zA/pxcQ vOALmnmM= X-Gm-Gg: ASbGnctYbV0lrjZt92O0+G2YjxOLMpV8/R07GZQiKRTH88lvLTthWnAWgxemjk/NmdR mZXeinJQXBuQ1U0lOIGgitHolvr/rAkzTBWqK7N2JmbKiC9Hjijs+C6/ez6ZvyxeM8h1777Indg nBLY0N42RZWK0P0059Wi91bLBPeFyrsHbopYjocAEz0GJmbohU4X/QjYeJTcYGYksPTDpyc0r/p stN7/LYkc3ZpLdnXz0sa//WM7qzsGK8v0isYn/SP29zp/ec8yYiuI0tvALqzlUNfJBz6wQlmbIR yeGMaeLS3ht9pYxxNkzPFUTvJE14KwNABZgkcrFpdf3qXdsNAk40Lgrh8h5KVUCq5CiJufBLrAu U6Dro4yjhqyPBKts9FQ7GsaAk/qN/41T8RpmmH6neOJOUOCO/zQjT+nukOqpVmMHfzOBCpvnhdv UKo59MV0n63r+pZL5YE5ZS6eGDrsY9XvzWfciz0S7ZsVfZKsPT1nNzU65e+6cV6TCIp4mSQ6yx/ mIT4w== X-Google-Smtp-Source: AGHT+IGY9uxppccb10Nkpqyh5YN5+IsTQsreC8A5gA9I6JHljIx5+3CPzOfT78PgPrpCfCkDW+Ke8g== X-Received: by 2002:a05:600c:4443:b0:46e:53cb:9e7f with SMTP id 5b1f17b1804b1-47904b103e2mr90365565e9.18.1764210215495; Wed, 26 Nov 2025 18:23:35 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:34 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Kieran Bingham , Milan Zamazal Subject: [PATCH v2 14/22] libcamera: software_isp: Move isStandardBayerOrder to base class Date: Thu, 27 Nov 2025 02:22:46 +0000 Message-ID: <20251127022256.178929-15-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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. Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- 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 158128f30..1d135b278 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -379,4 +379,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 d2893d81b..451c1c9ac 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" @@ -88,6 +89,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 8f1b4e53d..00738c56b 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 Thu Nov 27 02: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: 25229 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 32A38C3260 for ; Thu, 27 Nov 2025 02:23:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D656460AD2; Thu, 27 Nov 2025 03:23:39 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="A9xC+dQo"; dkim-atps=neutral Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8ECED60AA3 for ; Thu, 27 Nov 2025 03:23:37 +0100 (CET) Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-477a2ab455fso2941725e9.3 for ; Wed, 26 Nov 2025 18:23:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210217; x=1764815017; 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=0FUA8kH36pvKSfSDc4qeO8M3Vhl+74knCB5rIoM7BX0=; b=A9xC+dQozvbrpzXsyAcNh/gUWCffMhaHJlaoMsaXU5KZLa9eQqbe06PrDNoNz4zLTK VpL4m/OZXyAERMtJmDVAuDbGf5LlSfrRYhpQ3T8VJYrleIC1QeYlaGASc4hN7DAbsUvc RiH/7RxnMHJB1WfOI+fycmXFqH+0P0emLkva0E1tkR145MCMJnNQa1iKViaUjD9pXNsz 5iscxetofMpxADHxQyxAfR8qhCgOzsn46Dr3MCX+Xy474eSsadPeUniOUkQIF0aXH5nO rY3QSbeuQqKkvcBdKIG1gYWGiodPuOyTuAkc89b8xW9Md0nHB5KOqDC3z9yDNBUej9U5 Ra+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210217; x=1764815017; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=0FUA8kH36pvKSfSDc4qeO8M3Vhl+74knCB5rIoM7BX0=; b=pYHHE9zfip/yaD0dC3tuJNbBccrAv1inXNyyJPeDX3JU4z1pzAMDC0wDd46FQfFVwF 6/aaeaEKBuo70sqh0LRt/P5ouPMVmLJXxB/HF8j2lcYnsFfh7EhGBzOgeSiy94b2z2FA 20LU03mcL7J+QjGp59s6WzDvCa9Rh5c8MC6d7SW3QkpTmyxzh25szPrMj6j6mzK4Jiux L2Iqe3/B1j/mnpZltpuiTlmaYVsk1oSqpXzhvxVVTbNVOPLnxxNYx8JU/CpJiN/FblXh +P1oB+Fsv0rlRRmoDnaFTcvxI4vdHDtHbBs0LTUo0xrHt/66lKpNtrmyNnh2zuZURDKb zKFQ== X-Gm-Message-State: AOJu0Yz26NTMtL7CSmkCgoSPb6ZmQ40aeyY/Yp68wQOvqvPoj5VKG3h4 lPpBaWERrMosBqWZv3rcWRy8g/+iXADZrj1lTmHhw18mtg3G25p/8StLGnV1epj75+SQ480TzXc vGo/xj+4= X-Gm-Gg: ASbGncsTPoSa1gbaoL+Hsr9IuJUjW7kjdaMeagrrcJAwWo0gPfHmuTY8OWMcJQ8AEy2 3KDPfdnH9+Ybzda7YaoKI0NxxQeucAuNCGtkMXoI33l2tBTCxGSbC+8LTo7G35Qv20GHrrEX2Fj oj8z3E6lMp/xH/1bebsWa2jpU5MDJOVIlXf7D5KUyHFOGh2Gnw4e+/Kb9X/TsU7nwupICuYSsfo gS+nb+UFXQ8yoqIhghnoj1UHvunuIrkRF9eD4ttp8r8xxr7ZGt0MFs+H5XDXn8xk4KBDL1ZWieq gwHafud3OoR53aHPzSkVzfowCd6Ps6dHCXUSyn/uzMgwYlmXDr13L2NDdDj66nCNQ63JdCta2/k DMwxTQcq/Y+0DYdlPPwTkKodXIef434W5izcWuLeIXSHdClwGf0g+1xCujNXQP8XGKavLgxSbQJ 9BRWy5P3VxsIB0AIo76Xaij4Fp9+IcvgPdi/6Abeo8uPkw03n6D1GlS301+nCbLFJ6hvU= X-Google-Smtp-Source: AGHT+IHbonNS6BrdZt7W27wiLka/XPeOw0PAfe9byA2FgpSbXzuJVW1AdGr6rL9zLJ2sRGT9kCEWVA== X-Received: by 2002:a05:600c:4591:b0:477:b642:9dbf with SMTP id 5b1f17b1804b1-477c1132adbmr212090575e9.32.1764210216983; Wed, 26 Nov 2025 18:23:36 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:35 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Robert Mader Subject: [PATCH v2 15/22] libcamera: software_isp: Start the ISP thread in configure Date: Thu, 27 Nov 2025 02:22:47 +0000 Message-ID: <20251127022256.178929-16-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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 Reviewed-by: Kieran Bingham --- 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 928a2520c..afa4eb7a8 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -265,6 +265,8 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg, if (ret < 0) return ret; + ispWorkerThread_.start(); + return debayer_->configure(inputCfg, outputCfgs, ccmEnabled_); } @@ -346,7 +348,6 @@ int SoftwareIsp::start() if (ret) return ret; - ispWorkerThread_.start(); return 0; } From patchwork Thu Nov 27 02: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: 25230 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 5DE10C3260 for ; Thu, 27 Nov 2025 02:23:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EEC6A60AB8; Thu, 27 Nov 2025 03:23:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="clo4I6Y4"; dkim-atps=neutral Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3FA9460B0C for ; Thu, 27 Nov 2025 03:23:40 +0100 (CET) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-47796a837c7so1830055e9.0 for ; Wed, 26 Nov 2025 18:23:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210219; x=1764815019; 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=KaV04Bxgis4mNG/lyi1+ASdW7XQgEYuf59tHgnfd3u4=; b=clo4I6Y4BDoxDZZmAxAHG7dYmVjnJm4pH0IrLGrM+jCHo676n/DKOC2COLF1tbf4JX ApfMDa/kvZkb3hIFvJzCmVNBLAgievdLF8dd+dTDfq6VSRma7sa8uPw+LD436ngfRF5Y rYB/dEg3y4mU2IG8f/hCjo2+kmglv/Ja2goL5UZI3RGzuhVgLji1QWuLyIqbgXct3f13 nVbhRAav1pq3/Y245VVAzgzd6RFTRmJWh91fqqsyfsQJN9JhpvBJBCeSfMBaQKjYjk80 uT3PdT3yx55e71lDNYwHyWra1rVK5T2K3wze8QG4Td25OaVKbfW1ZHjfCc0F5PoUFV+8 n33A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210219; x=1764815019; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=KaV04Bxgis4mNG/lyi1+ASdW7XQgEYuf59tHgnfd3u4=; b=mC1OwVAkTtksOEEc82L9a5nQgTNB/Cii4ePzJwzZbUh18bRCJvUTJF9k9Hw019BMKf i1zz+6lfcUtTWlozIlB+kh2RNFZ+2Ul2Fm6yQbU3B5y8opNmRHuMvjCqOdqH3V7iHW2A BBrfISxsoMXyrS19XG2eQyoqZRd6VR2EOF3LMWPBgDvjIETKaarVHDId38dlw0bV2kqx u23kQ2+rHNFTXflckfCyu8fzT2ZJJ0q3F/UcVyQjzspou34d3Y5xYEliGUjFZhybe0s4 VOUePSdZ5LRD4xA0T+8ydqvhdWTA8wCeFYnvsQtyEcJa1c2BwiQBN9/KIbQdgZjwahjy jmpg== X-Gm-Message-State: AOJu0YwBk0Gr9bSLowiIsXHz+7tJZRJbGYj8bz9KnDmpKDcXb8n2Kgos CoS9xhBaa4uWwjAqeWXn8aI+GN82SG3ihItFEX88Dbhz7YIGkP74KwlrIZc6GJMntee8XUxwtvx JhhOssVM= X-Gm-Gg: ASbGncuelcbvqrF6Fb1Yhzc5O2UyzHsFOAcNtjpzCkrmtCO1pBdqLnnGcMUGzUXJtyg L2sZBFCD7uh8IX+jdDesGqNyQWbatNZMHGkP+flnk0PC+J/DpiSdPMeuy8xpYgzfm3HWvpY4eNd xLdjkhvPwfi3SfxE7NbC/e789/FkJInY0JLpux8rnCEoGRvm+FNE0eYCQdCp/HzHsI2fRc6/zVU wwD7M2UCB/baHlzl+CF2IlMiIL82ZEaDgWQ07L7WIxhAMOp31IQVRQRCB62+tyse3vojM4RWEYy K9/c1GQgYcjCtSfyveXzPRbCDX4aYYD2fC3FNeJv5Le0Lb+h9iJmZFJPxlpDQNh2dzlH1cyzVrU uKDfq9hHpgvFywd8CLFdFbP5jzc4gfSvtgG58WhJrIg33f/jsNooqq470MvAsmeX9834Il3eu51 A2dtz5SR+qRd1M41p+/82V+ONnFa6F54ziP4vMKh/r5qXLbdgqdlnPA6ojjr61RFyob6EOY2PDm o/ghQ== X-Google-Smtp-Source: AGHT+IFxfXemKPKV8Ky1eqwQJwLKv4dkS1/38hWFaF7bDg6K7T5lKkrdQ2CcB6p0trHJxmtManFyXg== X-Received: by 2002:a05:600c:3146:b0:477:df7:b020 with SMTP id 5b1f17b1804b1-477c01b2211mr216527785e9.18.1764210219597; Wed, 26 Nov 2025 18:23:39 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:38 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v2 16/22] libcamera: software_isp: Move configure to worker thread Date: Thu, 27 Nov 2025 02:22:48 +0000 Message-ID: <20251127022256.178929-17-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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 Reviewed-by: Kieran Bingham --- 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 afa4eb7a8..4c232339b 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -267,7 +267,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; } /** @@ -391,7 +399,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 Thu Nov 27 02: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: 25231 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 1CD9DC3260 for ; Thu, 27 Nov 2025 02:23:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C2CA860B2F; Thu, 27 Nov 2025 03:23:45 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="GBhld6OY"; dkim-atps=neutral Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2D08D60AC5 for ; Thu, 27 Nov 2025 03:23:42 +0100 (CET) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-477632d9326so1652895e9.1 for ; Wed, 26 Nov 2025 18:23:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210221; x=1764815021; 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=B9KW+pVIFbG1cr3wsRdFTzVVgHUhwNDNjNTuP9XwgZ8=; b=GBhld6OYadgyjT7lAmatR9mU4+V+KEpiCDu7M7IlAN+2N7Ueu5x8Sg/obO5hzz1V5k IvIGBKwLgQbGeyArkTR6Ce+17eiKCTLXtGzjeuE/VyW0crnPvz3Vxsu5FLcC8bgTw/u+ 9S6wLBiAOi/2yVqZLeveveEtCfAZp9MJm3n2tN6YyMsjPQim8K3kJfoDLuCzstbRKo+Y jwMA4C4ZoAanbE9hIly3UtGd41lTTx8JHdiij1jtnVHhNOPezaC1g5JOngr5/VT++TFS 93OPdwxvnwfwLnx1rn7I0ayNfPtXZMMuNWT6BRZuU1KOuDcJba3fPPVoK4YVHBWouHsa 75WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210221; x=1764815021; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=B9KW+pVIFbG1cr3wsRdFTzVVgHUhwNDNjNTuP9XwgZ8=; b=KmvAbUet9ANqKJULrOQO0dqe537c7PE/2RDEk3WLbmBtnXMY2p5RPVPxgush2BeJF7 A7CC+k+l0ac9Snl3gGWcHihv37SLaOP43xBpYcpo+ZNqDwO7Z1pfs5HaSvdm3/sO8FIk lSgaK5xab60kL0HSSFnNGS4orT8BRQGJLvHJyIAvglWuH6zjL1wis5s/iCgM0NAul25P mJmy/LmInKdI9vnzd1mrEvSwKzMSYc2lywvvW6gk0YciPj4SXrjwHmgZ/49ImPKAQVvN 8/hXt7Q7E4q+WmCsll01xUgG5WKW2xZ0zEEjm5qCoj/AiNa2ufBe+GO9G7JI0DFpjvrE sPqg== X-Gm-Message-State: AOJu0YxDJAbDPRiiQmg8rmvg46WalCdi1qQp0MPF/49XyfnMga/4M+3K ccvI1fKqHnHiWv0gRWyuIgWR132CFDqsfJBitwjKGRtDpHtiYblwoamy+FAa8pr/X7w4UmQmTF7 4yXuszi0= X-Gm-Gg: ASbGncsuWVLcSLcnvBlTzoQf+F956uwygP0LnUhYDYN7tyJEJ13ylOpo0SnO+eMNMz+ /9qjBPDD8d7xfVi1gTT/sFNhUdGU+DEaiD1tOLl6B9SlopRIkIWcy1l+KflMV6usaKlcLZKzCE8 gMn9myphuG8mFqUkPrESCKgO5yLNn6g0Zd2/MJLguXeAUoMuAXaygIb1HPSMdkqDFCIglSKZsUh 901Ey7gx9ME1zqvqB2XrM/qspEiLMWUpa5nV4WP+riA69Pt3Ej0OpA52cGR+0HCrsyFBQItT6Du STmyrCeblqpXo7ibKdrQT6HiYK0NYWesSumBjkx3aTdMynASiAMUgPetljqfYge45wMPy3D0HDx R7del69k06th8KEIXJc6oip8ZbJteTe18ikrvK7OQXia/auKQM3Zo1RZv3Th3Ob1tN2YMJZ6b1a kqNYX/ZVYDH0haVNEdMiGSK7v9o986zE3dk0icd4Hq5epiaHrBtynmRPOZcDaU1fV5ElE= X-Google-Smtp-Source: AGHT+IFluLnn0M1BNwxleHGMBuC7MZO/4YoU/9raAp8G+PvU9fziFn7xpy/Di0FoxYq7tfXORjK0Xw== X-Received: by 2002:a05:600c:4e88:b0:46e:7247:cbc0 with SMTP id 5b1f17b1804b1-477c01d4af2mr218994195e9.18.1764210221492; Wed, 26 Nov 2025 18:23:41 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:41 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Milan Zamazal Subject: [PATCH v2 17/22] libcamera: software_isp: debayer: Introduce a stop() callback to the debayer object Date: Thu, 27 Nov 2025 02:22:49 +0000 Message-ID: <20251127022256.178929-18-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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. Reviewed-by: Milan Zamazal [bod: Made method blocking not queued per Robert's bugfixes] Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- src/libcamera/software_isp/debayer.h | 1 + src/libcamera/software_isp/debayer_cpu.cpp | 10 ++++++++++ src/libcamera/software_isp/debayer_cpu.h | 1 + src/libcamera/software_isp/software_isp.cpp | 3 +++ 4 files changed, 15 insertions(+) diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index 451c1c9ac..088b062c0 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.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 00738c56b..28fb8ca50 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -788,6 +788,16 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output inputBufferReady.emit(input); } +/** + * \fn void Debayer::stop() + * \brief Stop the debayering process and perform cleanup + * + * In the DebayerCPU case this is an empty stub function but + * for the GPU case this does something useful. The stub here is to + * ensure the right version of the virtual gets called. + */ +void DebayerCpu::stop() {} + SizeRange DebayerCpu::sizes(PixelFormat inputFormat, const Size &inputSize) { Size patternSize = this->patternSize(inputFormat); diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index ecc4f9dd0..2d385cf01 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); const SharedFD &getStatsFD() { return stats_->getStatsFD(); } diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 4c232339b..aa4a40cb6 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -367,6 +367,9 @@ int SoftwareIsp::start() */ void SoftwareIsp::stop() { + debayer_->invokeMethod(&Debayer::stop, + ConnectionTypeBlocking); + ispWorkerThread_.exit(); ispWorkerThread_.wait(); ispWorkerThread_.removeMessages(debayer_.get()); From patchwork Thu Nov 27 02: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: 25232 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 20A2CC32DE for ; Thu, 27 Nov 2025 02:23:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AD7D560AB8; Thu, 27 Nov 2025 03:23:46 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rkJuXdtU"; dkim-atps=neutral Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BC3C260AA8 for ; Thu, 27 Nov 2025 03:23:43 +0100 (CET) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-47775fb6cb4so1770915e9.0 for ; Wed, 26 Nov 2025 18:23:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210223; x=1764815023; 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=iRXr4nHEuISqL9vL3N0Wmx/RaPbrgqdaQeOrOOYFO6Q=; b=rkJuXdtUPBYL0OBdJnW0Ex/JhREJbYaYo5sdp/+ZflPHxGdGhtc4NcBILDwTN6mnu7 rMPyKVTrIfEgbA73l2jl9JNWdGqKAaBCzrNDfqIbkmBrseQOaYULQQdOXT2ddSMLyIGn wKe6IlWqWv0nErlP9e44xSZoUXlQl05wkbyrtWQq9Lfv0bcFtEsjtNMnGV7cF2gV+Ezu FDuMWb7M3anuXsLgLELtJ9HhKtNXZ6Stkl2yxO5oOWe8fU7s3iTguS7GpGRnGLgyH99H 9JgMhAzjCWTfUzLfbNBfg+l/XU5knjptLijUXaE5ldhkYhZKBoPkCTx2JpFGLu3gcjQH 0YXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210223; x=1764815023; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=iRXr4nHEuISqL9vL3N0Wmx/RaPbrgqdaQeOrOOYFO6Q=; b=J4F9H6LJ2aq7YJ3xqUG4F5UxssJ0pWtIFeGlDEXq36tbHWJWE4T7FNZvnAsMptIdzI Ec6F8WT8SlIusq9yeq4NBw1x0JWal/wbWw4KQ0AScuNnUknYRQGNVXurMW7epvM6duv6 EuPCX7ZbeJ0BekNBDld3me/TavyEbInwymzXRlHQxT7fJEtHsnXC6JJQ4ZqsFxIDy8rt OI7cUNAR3uDmI3iCZFnnsvTVDg0nfbtkHLj1rEhzT6pFlexarGAdYtdLUMsmne4SDfX8 03HSA6AFX0zfpXnEfnIxgdshfx8e6MgguzwXzIqP7N8j/02aY32XP/Vm9Fvd8yo0+sZj NT3w== X-Gm-Message-State: AOJu0Yw4VHQXIvqYPXUcbagWLVeXJQaxNNgbVaU9OdoUirAycE4Yz7g7 XEldrmbKSqGMeZ0IkUdgA2PHaYPoVghAFdYJnqmo5JcOOwMte6LgneGEAlKMKteO7Y6dSWUc5vS MZ13RAdo= X-Gm-Gg: ASbGncss0qisePyJxHquscpVm/GYrwn/ttLyGg/mu/MHURDfCf6yw5RpSU+tbQfq7qv HR8VF8b8aiSpaxgFSJ6WrL3ZhfgPPyIBJESyLqO9x4BEL2rlDKSpi0b1quKS5itqRKz+GJT4CdA YyzVt3zgz8SxshqvxABHD4KFolMdGgUPK0iB9hU4P/p25dsTfEXKCC12PDHOJAEEqsRr2LxqUqU otlCYrwEzZYhLAuZaCKkZ61VXcKwv44f6A0+C8+qn4l1RRKQlmInXykW6uj9EK6LvWSoiuItOaE a4X3eBdpiWE+0LUUzLmmDLtuzx8pUAQCFMkbdzS6Vkx8pnbZbSgF8h0OEcC9BUhr4TpNQAm92w7 zGGzoizXxonYoNfJ4rGFAi1d3dRbeDk2Q7pocJkCJkVywdzCk54B3RdXzqO2Ff6619ug4csEOPf lN6uG0JEex/2sX108qbBmId1NK2+qBFaWyEXEYPAHWRk5O1L3GS8madcEesd/lsN71KmI= X-Google-Smtp-Source: AGHT+IGWu1cOwU73XZXMvIkMoWqEa+lVdqNSbDRw2DCzjmuCcLe2/1ITBRqi5rcYjnCDCRctppW+hQ== X-Received: by 2002:a05:600c:840f:b0:477:632a:fd67 with SMTP id 5b1f17b1804b1-477c10d6d13mr241086015e9.12.1764210223132; Wed, 26 Nov 2025 18:23:43 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:42 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Kieran Bingham , Milan Zamazal Subject: [PATCH v2 18/22] libcamera: software_isp: debayer: Make the debayer_ object of type class Debayer not DebayerCpu Date: Thu, 27 Nov 2025 02:22:50 +0000 Message-ID: <20251127022256.178929-19-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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. Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- 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 786246592..ad89c9b3c 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 Thu Nov 27 02: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: 25233 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 725C3C3260 for ; Thu, 27 Nov 2025 02:23:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 12FA760B36; Thu, 27 Nov 2025 03:23:49 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="NVoJeHjF"; dkim-atps=neutral Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 40F3360AB3 for ; Thu, 27 Nov 2025 03:23:45 +0100 (CET) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-47775fb6cb4so1770975e9.0 for ; Wed, 26 Nov 2025 18:23:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210224; x=1764815024; 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=nQ95/jmePJyWEIfQTGXeTeGzLrO6Eq0ZC4qHC+vGgRQ=; b=NVoJeHjFaJFFXUwsPXxmNajZaV/SGpID7J93jjCgRJ84w8LFRg3GDYAc1BZHwQ9ZI6 dNFlGdsSnzAWDuX9vsNoLvINyJBR35g3tJwofUzaUDsNn8h6160X24JH6ZFUO456DHXu DBHMnxQZw2bt+COUAn8CJ7VXNkxAnLepDXldMeXc7pQqU8iRHTUce6OjRh3vJ2jxl07U EYrPaybsbbGkUjRXgDZEgo3+H04zDs+NoxYkvK7qRV5m02QXaY/AX0myOEoRsha81JUx waYru4Fg1kodhBV6sEEqldoa7+bq/szPII01FoNtq23xDR/qcvsXBss/hvNpzS3xNtvA YswQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210224; x=1764815024; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=nQ95/jmePJyWEIfQTGXeTeGzLrO6Eq0ZC4qHC+vGgRQ=; b=r/zhya2bV9UfeoeKDfN+yaGMEGIkLcnsYUKmPhnhzxCU4OEB6TfKFEErcpDAi4h+FF jIv8TyjEooR5U88/HizNOOGzWwKv8BmTME8QWB6S5qDleBaoTG7h/GFjVaLWo/k4x21r T9VY7d9iIN/0TvlzzcWVNhPeNqHyP0GPOYbC5Xswt7qVGVDzDtI1Sq1takNfzjTCo039 K7Es9Zj4Z6QRbIvb4WEzoLqGGAkHjjjv9rQYEIENPMaflGZzGPYXCXwI3ihaVgvyw1oC JptCQSWT6Ivffme1gz84VdUC347FAVbLe6tXgenenBGRC/RZNxUS86zKDhaIU9Zi4Xjh 8Qgw== X-Gm-Message-State: AOJu0YwSMjnn87DF2h1nzPSGFKEsmRrNd4mY0AXP2F20u/ZVjHViKlSR NqZBeUj60dIIP+21se2ETnVVlX4jw4EHiLiDtB/4mFgcN4FvhNmCkchiRNi8jWgTOx7a0BMQkbQ 6wKAHEtc= X-Gm-Gg: ASbGnct3YXES0WDTbG3I/On9nB/Mlh/S4onXqjHemFYIUQm6iMKrhegcFbvOrOZnRFC Mx6eJoDvTWz+bS/IYfrF/J6zKaa24wvuoN/vblnGoKlxqZ6zshSsz5bhMC3rG1nUwN4rAlTaCeP eoLjae5X0TjDbwelMweJreHMWmDT9Gf8pTCqe2KC1rlC4TVmnrRNgalR4RCE0Bes+zqHhzOHc5V etk7bYqTRWzqYoI4d4FUIQIYugAy0w2zYsJaecPywjnv73JI2MTxEIbksywPDf2/SDWBgD6yenX +/DQ5IBu4+rm9IxMxhsvoMq3MK0KMJ0D9aGRBYPZLWpyGG7IdcbyHJwdPR2flEizZhYDxlTBYIJ oMRz/2fiJaYgDnB1niziRqaY5oyA/no7f+JtcDj5LlHUhYEV+OIS9H4d3ql3YOL7EY5ZLQEE0eV TFTDvzcxpWkbyiF9g1LlXjrxNcW26X1/Uo4VscKjDz1N1SyHamyoTFKtZnQVBwcppWXjk= X-Google-Smtp-Source: AGHT+IFf2+wvGsKy4b0ndvv87M45heVdDxn3DjIqh4IVhxQbVQ2UvkwDQbVAtnbDhAPg8ZChYbvv2Q== X-Received: by 2002:a05:600c:198e:b0:46e:33b2:c8da with SMTP id 5b1f17b1804b1-477c1133927mr218326255e9.32.1764210224591; Wed, 26 Nov 2025 18:23:44 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:43 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v2 19/22] libcamera: software_isp: lut: Make CCM available in debayer params Date: Thu, 27 Nov 2025 02:22:51 +0000 Message-ID: <20251127022256.178929-20-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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" Provide the CCM calculated in LUT to the debayer params structure for consumption in the debayer shaders. Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- include/libcamera/internal/software_isp/debayer_params.h | 7 +++++++ src/ipa/simple/algorithms/lut.cpp | 1 + src/libcamera/software_isp/debayer.cpp | 5 +++++ 3 files changed, 13 insertions(+) diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h index 217cd5d92..4b203e211 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 corrections as calculated by the IPA + */ + Matrix ccm; }; } /* namespace libcamera */ diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp index d4a79e101..49482d711 100644 --- a/src/ipa/simple/algorithms/lut.cpp +++ b/src/ipa/simple/algorithms/lut.cpp @@ -133,6 +133,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]); diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 1d135b278..4ec76dce6 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -100,6 +100,11 @@ namespace libcamera { * \brief Gamma lookup table used with color correction matrix */ + /** + * \var DebayerParams::ccm + * \brief Per frame colour correction matrix for GPUISP + */ + /** * \class Debayer * \brief Base debayering class From patchwork Thu Nov 27 02:22:52 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: 25234 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 2EAB9C32DE for ; Thu, 27 Nov 2025 02:23:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BFC4D60BDD; Thu, 27 Nov 2025 03:23:51 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="BmWJE3aZ"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6FAF460AA8 for ; Thu, 27 Nov 2025 03:23:47 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-4775e891b5eso1094725e9.2 for ; Wed, 26 Nov 2025 18:23:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210227; x=1764815027; 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=e5IU9i/UgAS6xhFOaLC/MXSw7l83fQor9ApmWEKFJl4=; b=BmWJE3aZrZQdFASXWKt/M3gCMwNFa0G31mPxLvoKwdatdOY2xEUkfxKUxXMQc3c2aX 9JKIYczGtwxgLKr0Dsfn8mA4ca2S8unGvcR8AClhYjvYRmbA64vKpB7QT26JGmTjmIH3 EqZUrGFzIYkq6Yj4Dpw5aZ1QmmTqJMkvBo/VbOpBZzj6I/o+74e2UL0ZoLR79SlbSzAZ mt7UGrf/Emd1WSgRZ/sDnNkb8vecTymUdgZvgTOKdwdcU24/V/IvvWnlztMu9P3VGgvX FOGgosw/Z+jY9R72qcugJ+eO3xLddb4eFEuLh7H42da6QHnjJq/I5nxAQpytHsh5mxFN LdWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210227; x=1764815027; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=e5IU9i/UgAS6xhFOaLC/MXSw7l83fQor9ApmWEKFJl4=; b=dWENTCG1rO7kMsxxtLt5coRa10y9l7dGHqlB92/fdbX06zENEl2Bmna3iM/hSGpdPa GYvipDHDS/GQl6NU40S2XBMJhXZLbC6OADiUowVc/kwN2EaWSLYks16gRBVhN0BXnmck 0QpDppHJFgRX9cS3EsyaptQbE5Zquv9P3eHa8P17DDnB7QLjxE27HKxWtuJEY5j7L27N zhWdwVnXpOrx7MP6c3NqHV9lvVR1uG62JiqxvIjb3PHQa7miQWxmurJZGl0eN04AygYH VbXD5IBEv4HJB4QEvZ3bDxbMCL5eNcosjKjHI/JsVFqPVkKE/uN2OyHQ6Ar9xxl1jqf5 XNNQ== X-Gm-Message-State: AOJu0YxVF7X7abin1Em8UaZYp6yoZHxdwYwtkvzWHnFupHpu7V+Kfbeu pJnPATrNUuGnAYkLG+y/RZq2cccwaDkjuma9uGrx+YMptvl2s0d9G48lC1yph9Z6T5py40gtlv2 8vtHGWD4= X-Gm-Gg: ASbGncswPO9IhyVPtq5vc8yGMUvFTNnmUFJPSm/HOEU7KMwVURHwzsw0Eh4+mnNlp8A 3y5bwrWJ0rV+C5JYiTpXcNfJ6WsQDWaqg0rxfh3BedhfXBsf2jwK0gl/GFtSndfljunxamamMcH Ab6DTgI7HQri3rLBIo+WwxvCE82T0nOogqvAHzu4yEdNWPtU2nG/V8DSPTaQyWV+2rXpFHg7ht7 aKvVLDEA5T2Io1dUZiTTqyXdxaWPr+ZPwlwXmr3zQYQ/re0YOi/IPobNM4hRBYf+/typX1bORHU AbI6AApcmMLxMBe0WiStCc1/AMg3JF9y7rB5RyE6SsY9pGbNK9WVCGmIPAHBxYO9sh/X6LS1U+B 90dwKewePm/BExGZ2h4G+plZcWBmFIw3XwlITkiFXj26gadrkNC2h7PDuyaLx9miP+5swRgsC3F Y0MVSNdVQoiCdyZ2kOEWC6pcO/d6WDESswSGkyUdORhQ7gy4VteVzRQg39AJOrKwfKTTw= X-Google-Smtp-Source: AGHT+IGfnY0V0bfGPHWJnzu6fefqZioIyHSjqL5g8TeGvlMRYc0njvLh8FdFeLCWhT31yRy4sCm11g== X-Received: by 2002:a05:600c:1ca0:b0:477:75eb:a643 with SMTP id 5b1f17b1804b1-477c0165b4emr254780965e9.4.1764210226757; Wed, 26 Nov 2025 18:23:46 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:45 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v2 20/22] libcamera: software_isp: blacklevel: Make black level available in debayer params Date: Thu, 27 Nov 2025 02:22:52 +0000 Message-ID: <20251127022256.178929-21-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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 black level gain in blacklevel::prepare(). A copy is made of the gain value in the DebayerParams structure. Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- include/libcamera/internal/software_isp/debayer_params.h | 2 ++ src/ipa/simple/algorithms/blc.cpp | 9 +++++++++ src/ipa/simple/algorithms/blc.h | 4 ++++ src/libcamera/software_isp/debayer.cpp | 5 +++++ 4 files changed, 20 insertions(+) diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h index 4b203e211..5a0d9438f 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,7 @@ struct DebayerParams { * Per frame corrections as calculated by the IPA */ Matrix ccm; + RGB blackLevel; }; } /* namespace libcamera */ diff --git a/src/ipa/simple/algorithms/blc.cpp b/src/ipa/simple/algorithms/blc.cpp index 370385afc..464e43c27 100644 --- a/src/ipa/simple/algorithms/blc.cpp +++ b/src/ipa/simple/algorithms/blc.cpp @@ -47,6 +47,15 @@ int BlackLevel::configure(IPAContext &context, return 0; } +void BlackLevel::prepare(IPAContext &context, + [[maybe_unused]] const uint32_t frame, + [[maybe_unused]] IPAFrameContext &frameContext, + DebayerParams *params) +{ + /* Latch the blacklevel gain so GPUISP can apply. */ + params->blackLevel = RGB(context.activeState.blc.level / 255.0f); +} + void BlackLevel::process(IPAContext &context, [[maybe_unused]] const uint32_t frame, IPAFrameContext &frameContext, diff --git a/src/ipa/simple/algorithms/blc.h b/src/ipa/simple/algorithms/blc.h index db9e6d639..a5592d087 100644 --- a/src/ipa/simple/algorithms/blc.h +++ b/src/ipa/simple/algorithms/blc.h @@ -24,6 +24,10 @@ public: int init(IPAContext &context, const YamlObject &tuningData) override; int configure(IPAContext &context, const IPAConfigInfo &configInfo) override; + void prepare(IPAContext &context, + const uint32_t frame, + IPAFrameContext &frameContext, + DebayerParams *params) override; void process(IPAContext &context, const uint32_t frame, IPAFrameContext &frameContext, const SwIspStats *stats, diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 4ec76dce6..1034912e7 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -105,6 +105,11 @@ namespace libcamera { * \brief Per frame colour correction matrix for GPUISP */ +/** + * \var DebayerParams::blackLevel + * \brief Blacklevel gains for the GPUISP + */ + /** * \class Debayer * \brief Base debayering class From patchwork Thu Nov 27 02:22:53 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: 25235 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 0ACF7C3260 for ; Thu, 27 Nov 2025 02:23:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B6C1C60B37; Thu, 27 Nov 2025 03:23:52 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="eP/IYhlM"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 87FF460B2F for ; Thu, 27 Nov 2025 03:23:48 +0100 (CET) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-47774d3536dso2787165e9.0 for ; Wed, 26 Nov 2025 18:23:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210228; x=1764815028; 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=I8jixvijd6gJLN+QzpL1b1w727QQZ88ZES2h9Mcjbmo=; b=eP/IYhlMzocDjxBGFH4R7PC3DeMsllYvA0+kON4gYtfgaQauBuXKwLmcObwz/8eUf8 k+/A8nB+9DkJ49LWsBmbnDgfBa5K1Vleq4EPQyi+R2+NLGus+USswrDpYdHtv+BpDnY1 a2jTMBLnbfY2MO/iq5xL0240hArSXOB3dQOouTRoasifbsHvEO/5McmKmej5ww8Yy59b IRHttd/zN9hLimQugOn0XO2VR0f6pbV5dLag4jib9GyPmEPNFQ6eKx+XC2Cfgr4JKSEe y0AZk6HbQcwYloWK25eIAms4jrsCFPOxzI3ePLV9V6COVYOd8DUuDfr3q/sR1NfE1YvW oddA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210228; x=1764815028; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=I8jixvijd6gJLN+QzpL1b1w727QQZ88ZES2h9Mcjbmo=; b=YddmhZdWiA7UAzwN953HZijZwmU6dECPoc/u6fUzsvFuX5cuWOqOMQ1I6JqF9TnWjg BJVgf8+Oc24pFizhDWlbzjVilG5kYkrNbHdu2Vp6W6/YPqPeIvjav4RJBjwwicvoZcBc PDUvVTxh+lV/q++IechqiR3QVKbvz0+BnQkkNhjDF3gf575YpuKazkiufID8nNThQZGy mVjMutLyyq/i/IJE+RGPDfA5rbrHKv5K6Ao/L8dLNJOUuqJ0qDVUjY4ugAheT0v4fMK1 4KlbQj/Y8edg9b5NDGDAEOuM7RF1tFlFPcFPRXMbSRje+Yxnu83JRfGIviZFK0kpR+Jw 69Gg== X-Gm-Message-State: AOJu0Yz3g6oUF4aHmpsU3ZFZuyzp0lUsuJLEh+YlriZ6saoVL3IEUTuJ xuNwlzZ4oCQp2Y80gsq2RiHULwI806TStKDEASz2Uas0kghUi6GSUfunA0qtxkSVeRHLV9sWiJ+ wjh6cjJQ= X-Gm-Gg: ASbGncte4ppeLXmmvUzPE8KpGfB8qDEIQLu2LgjVCN/Z/dzOVeYmi5HOKFmYMMxOzUk RhWDkrVodtFSOXTuTdJyfY6qmaWTraec1sCXuU3/rrlbi13REyjEJ4QR+A1hiw9IKRk/u698kjy ZraBO5DZOjZpqlbQaD6MACFE+78S9AtF/Ph6lnMsFqDMlj94nxcvLpVIs2WsLWIb0I0mMB+bNBS Qgt8m6lkItX1LiSCcpVrOjzQK0mQvvh+lDD7t3X+U4hxQgQz7Aj/DKnZAX+8FCJgFeRSoBmdHoD S57unN2eAgXt85mK+O1OJCcgDUrIxchTiu8hn1om1cjzC+ECiPA5EHnj1MhEAVW8r9rBZxLD6La xQr/JBKO/gUfM3ZkemTkRI9WSsy9V86rC18DZ5rfhNwOtWz+xFitXMPE+mF+VZyLTRPBVIC78rs JZA7G+RJrUBJZyu+/DkbUTauSxyWp9n74qGnsqzSoZcdqhY1OzF9knrZh0slWqpp6LnUM= X-Google-Smtp-Source: AGHT+IEzzJOoT/BNeqJ1COeUoWLOThiDZAq87waMjXYINNIB5nsBh3V8JBlvLUqXuG7PUFhFrKGkQQ== X-Received: by 2002:a05:600c:314d:b0:477:9890:9ab8 with SMTP id 5b1f17b1804b1-477c04c3593mr215473345e9.3.1764210227921; Wed, 26 Nov 2025 18:23:47 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:47 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Milan Zamazal Subject: [PATCH v2 21/22] libcamera: software_isp: lut: Make gamma from lut.cpp available in debayer params Date: Thu, 27 Nov 2025 02:22:53 +0000 Message-ID: <20251127022256.178929-22-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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" Provide the gamma used in IPA to Bayer parameters. We will pass Gamma into the shader via a uniform and can then tweak that value from outside at will. Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- include/libcamera/internal/software_isp/debayer_params.h | 1 + src/ipa/simple/algorithms/lut.cpp | 2 ++ src/libcamera/software_isp/debayer.cpp | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h index 5a0d9438f..d5dad1a98 100644 --- a/include/libcamera/internal/software_isp/debayer_params.h +++ b/include/libcamera/internal/software_isp/debayer_params.h @@ -58,6 +58,7 @@ struct DebayerParams { */ Matrix ccm; RGB blackLevel; + float gamma; }; } /* namespace libcamera */ diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp index 49482d711..ea5a86b20 100644 --- a/src/ipa/simple/algorithms/lut.cpp +++ b/src/ipa/simple/algorithms/lut.cpp @@ -147,6 +147,8 @@ void Lut::prepare(IPAContext &context, params->gammaLut[i] = gammaTable[i / div]; } } + + params->gamma = context.configuration.gamma; } void Lut::process([[maybe_unused]] IPAContext &context, diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 1034912e7..8bcbd5dde 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -110,6 +110,11 @@ namespace libcamera { * \brief Blacklevel gains for the GPUISP */ +/** + * \var DebayerParams::gamma + * \brief Gamma value for the GPUISP + */ + /** * \class Debayer * \brief Base debayering class From patchwork Thu Nov 27 02:22:54 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: 25236 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 D409DC32DE for ; Thu, 27 Nov 2025 02:23:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 85F3B60BDD; Thu, 27 Nov 2025 03:23:54 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Sjus5DFw"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A94EF60AB3 for ; Thu, 27 Nov 2025 03:23:50 +0100 (CET) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-477a2ab455fso2942555e9.3 for ; Wed, 26 Nov 2025 18:23:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764210230; x=1764815030; 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=TAFofCRjRwju8c6LgHdbB3OSOLTvh/yl77wh8eBrJ3s=; b=Sjus5DFwKBwBQbULyOn6wIb762HxrLwg5+cbSGKaT/BZ3P82sG2U6UEDX15GLU0bE2 M5qDDpP7S57f2D+RkSeGUxEPhcTgl/N+248YN2nE8x6mSbnGpEUX2tfnviWAWebgyytS PfRK2S5BlNbM0CkBjeg1zqic0kxrxjS63Uh5xJdXGadizCiwSJUNpehTSztndPURmXz7 OkdUrOmZu+SJXvVvfoK9yLpyDPKSHx2KP3gKo0htvD2XGw9rzZdgX4IrMORU8lWUjcki hpZ5YsAkDv/Vpj+5SRqETWDE26QcO3f4SEmVKBdIFU7zDTw+MGp90nbTaJJS4XfEiRnZ amRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764210230; x=1764815030; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=TAFofCRjRwju8c6LgHdbB3OSOLTvh/yl77wh8eBrJ3s=; b=bkm+6tned8O7OTdiR/nSLgccuczJA5lVyaHoJmXgM1YQaxicMFjyUyI8FcVz7DsrR4 2oM3fyZvlrXPBR0hlBXSk+35aOjDnQfPnQJoUSZdYKIklQdtx7EZsActPMO4XyqeujJa gHseZko5de1gBcJwFBUkSPviQm9UHI1bgfHG89aqc8ibRrzta6otnjIQ3lHud6zitq0D Rgupob5m6X3zYwR1oB8dwNmjnWZDsnS6kb/4Fr0kaicQbOMojKEAL1DqbmIKf46HMv/W 0Lkk0/8lUjZwZuD/DDNcVtpONL9anqM2iznKpMHDlA9uSwrtaN5+hhSjQbj5nOXuT0Ys QEAA== X-Gm-Message-State: AOJu0YxMwkXh1Lrn4Zl/DU3oZRTg9b0sbdTY1PYtDCMUV7+zUFAlajxB E+Azt/11uvkAnGXLjgUIEM77qYldh3XsNE6azZf0VHEV83tCBST6MvwNWOagNOZ7NflnDneM+NO 1YVfpyBk= X-Gm-Gg: ASbGncupcMFoIkgZ8U+COlp66vgngTEX4mTWM5YqUEr+LdCg4NuXmOj3VTJLRXBr6zs k7ZjYkG0OY1lcnKYjoQR8ByzX/TMPljbHuObeMV/H8pxOQKXvHjLww3sUDrWrZ+b5+GhpMGnqEQ 1QLQDm75WcJkQQibIHqAopp/chfAi/Lul6rN7cipRJfpX417THWcBWIjdzgQZHiJ8B0Qr1owfv4 nPMsPRXO8QOSijRNChC0AjY1NjhGciB5KJdYqIkTyL4HNSR9m85skqulb+bL0hhhp8lIbxrywhY wNt8EoxXwkmFv5hoFvdlWn98Blf9i/PvLerSjZJmOS2HlrdN5ITs/9J/K8pAqhvUmtNK5fZpXrf BeUMb9+OeMLUul6D4lHeI77M/SjbLRBVen/KLHdylDqOKb5Ylfs5kB2ZCDX11vVgAxVqgojJDTV BFqaUBhU3hwfihRFkd3gA+8cIc9O5b9q25JtX6S1gPF3jzqBWR2OP1MZGmbH6+B9qc4hM= X-Google-Smtp-Source: AGHT+IHErMILY2dosC1BTv2NfRqYlEeafYQ2eiwRfkTKwGTVtuL20SiTvnt123GTLBv4SH+3VIWfXQ== X-Received: by 2002:a05:600c:1ca4:b0:45d:f83b:96aa with SMTP id 5b1f17b1804b1-477c10c92d8mr257620405e9.7.1764210230019; Wed, 26 Nov 2025 18:23:50 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790b0e21e8sm71549495e9.15.2025.11.26.18.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 18:23:48 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Milan Zamazal Subject: [PATCH v2 22/22] libcamera: software_isp: lut: Make contrast available in debayer params Date: Thu, 27 Nov 2025 02:22:54 +0000 Message-ID: <20251127022256.178929-23-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251127022256.178929-1-bryan.odonoghue@linaro.org> References: <20251127022256.178929-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" Provide the contrast used in IPA to Bayer parameters. Similar to the calculated Gamma value we will pass this value into the debayer fragment shader for further consumption. Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- include/libcamera/internal/software_isp/debayer_params.h | 1 + src/ipa/simple/algorithms/lut.cpp | 1 + src/libcamera/software_isp/debayer.cpp | 5 +++++ 3 files changed, 7 insertions(+) diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h index d5dad1a98..8033f7d5b 100644 --- a/include/libcamera/internal/software_isp/debayer_params.h +++ b/include/libcamera/internal/software_isp/debayer_params.h @@ -59,6 +59,7 @@ struct DebayerParams { Matrix ccm; RGB blackLevel; float gamma; + float contrast; }; } /* namespace libcamera */ diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp index ea5a86b20..9aaab54f1 100644 --- a/src/ipa/simple/algorithms/lut.cpp +++ b/src/ipa/simple/algorithms/lut.cpp @@ -149,6 +149,7 @@ void Lut::prepare(IPAContext &context, } params->gamma = context.configuration.gamma; + params->contrast = context.activeState.gamma.contrast; } void Lut::process([[maybe_unused]] IPAContext &context, diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 8bcbd5dde..f0307549b 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -115,6 +115,11 @@ namespace libcamera { * \brief Gamma value for the GPUISP */ +/** + * \var DebayerParams::contrast + * \brief Contrast value for GPUISP + */ + /** * \class Debayer * \brief Base debayering class