From patchwork Thu Dec 11 23:22:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25495 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 57931C3257 for ; Thu, 11 Dec 2025 23:23:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19FC66161E; Fri, 12 Dec 2025 00: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="nq5dIWP1"; dkim-atps=neutral Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 85F5961613 for ; Fri, 12 Dec 2025 00:23:10 +0100 (CET) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-7aae5f2633dso649662b3a.3 for ; Thu, 11 Dec 2025 15:23:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495389; x=1766100189; 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=fH5YADHFATwkgnLtBqb6UHEbVI3OB8Ih24Dm6yp1+5I=; b=nq5dIWP12LE2kGf0tefJo509YC6YzknNmEqeOzuRQGIr5CXCTGxvvMonREreOk5C1a FZMU69oB//HOLr9PmSop2/Sg8kOcWXjB/PJrPAG8FdmRkXkc/3BXlWm1zpfI7+xAEaIU Nw0WDZH1NP4y++Dnuwrc6qkIbn5f+Q4TscwWk9XRSmvPcMF+OUWWY+rXg8A/i92G/b8w wP1F4J+5O9zFnKFrlH3VQtnE7j6txcuiN8KM7rRED30z3RnfiZJ3pQItUmqPfP3c3NBc pYjZJqpfgwbh8I5w7KVNoBRwYmDdDxrmgxqTigIm4qdEXXajq0Cj1PLiAwzAdxc752iu pxNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495389; x=1766100189; 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=fH5YADHFATwkgnLtBqb6UHEbVI3OB8Ih24Dm6yp1+5I=; b=ZVi61vSoND2Rd5Gr2OH7hK0JX2+J2cf7cajehPlaqp2a3A63EEdrd0aiTnXvDwzrrx C4M/DeDI8OI0dA6dYsmsxJi81iRnY8Jgjurw9m2/mKcPKy8ea+1R4fVBOIWudPGdFZmI JvxsdeKoPJRn73lzyz9SLRNKe/qW0x9rVMdj0rPHtH4KsY2W8BWKyfzGERBBQeew/Hni f68yHJKKxEQhnfg33V4Uqovmj+I6KJwv3//Cqmu2aHAgGd9FbvMrp3eGYrLp5bP4LD9o 5hC3jfsb6RNPRedu4xhjCwa8431Q2LS+/ckXxY/ivc0TeFmjLPSH/RjG/Xcr03tI6lve 5qIQ== X-Gm-Message-State: AOJu0Yw3I2aaT2QZD4/egMHox35pCk1UrTvdblPEfHiKKL/0tdQR3cr9 /JflTEWzOq+BBgz7A7tJABimXWBlrXpTZLC3Y77Yw55m311FkrLuHQI/3NvvxdhBLL28+POqoQi Ij/vK X-Gm-Gg: AY/fxX4SsAhsTJ0PKL4n0qDxOrrx16qMxZNpXSose/uk8yLBBsWxd0GpCNQO9P30Asz G7cmlhjrWQmqhSVB2VZJf8GeRP8vu875q1Rc1dcro9UDtLfkCKw9+c1PdP1NzNfPY6P62wpeFbI Kt/tAmsC47kvPyS6DAd7uLBw+DajKufAFUt2pMqE6KcJ4ZbIsaD9eyaY+YwkOu8rfPEDdjD2psy 7NAI9EYtwfIS+oHo7fAMQh12DOW3k8LG5C32zLnFP1Ak9INFUSkiwlnHDc1AAGy3m120QNSh9A4 mgC0TmP++4BEGjo02x3dSultN6dYTwRIA2oRtb8uDaMwz8vM5cPg6YQkTaHgeP/08LuktM4DENk 0g0V2MAio5rmvbhiiu17VE9AQ+AWg9hLlFy0lJk+U57o78mezg5lQ6hV+6jtob06pp1RiF5Bz8M pvgdvjkvX1ZzXsiaDQLvcva+UtK+PsqiHvvqQPSYlFHqLP88IH3h0BG+IKjWLUcw== X-Google-Smtp-Source: AGHT+IFhTkDzQu8H7ry1FF5ptKW4WrAQUjAW8wo8pu8y8VvHDnwctFH86t3n/J4pCli/9LY0L8Jqgw== X-Received: by 2002:a05:6a20:3d0b:b0:366:14ac:e210 with SMTP id adf61e73a8af0-369b767fc1cmr91212637.78.1765495388756; Thu, 11 Dec 2025 15:23:08 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:08 -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 v5 01/20] libcamera: shaders: Move GL shader programs to src/libcamera/assets/shader Date: Thu, 11 Dec 2025 23:22:26 +0000 Message-ID: <20251211232246.31330-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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/qcam/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 Dec 11 23:22:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25496 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 00345C3257 for ; Thu, 11 Dec 2025 23:23:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AF3E661624; Fri, 12 Dec 2025 00: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="A/9hcjI+"; dkim-atps=neutral Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 92CA461613 for ; Fri, 12 Dec 2025 00:23:16 +0100 (CET) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-7b9215e55e6so446153b3a.2 for ; Thu, 11 Dec 2025 15:23:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495395; x=1766100195; 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=tzLWYj/4uneBvx5zEyrPndszFCBrsmGlpqApy0qMaaw=; b=A/9hcjI+Y/Ogo9xTir6FysON635A6+QxSHabtX5Ftgo8Ft60TmDO5qv2scCzeXYPxW 4HoipYBYHtpBPcRCCNyCpKTkRMQgKJ1Ltw6Zd4hSgdIzHIOvuSUEdaxbFt9RJQ//NUFv ZFnrQ9JCFqOrJvIUM5IIimygbQSa7Yr4lXmINWkk6aBqz9fh2LANKWG0cdnVf1+dJt+0 YqP+PwjTkUCiuD+xo15NfKi2iIClsphoIXt0ckUeg+uxwXmehydKJthAVTKPfUcPodoc VHSbqg8JtsJvhWmrC+GayK4i5X1dC+arjnoAbu9Tig5lE7BfiFyKfJip+sy7ry+DHw63 OtAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495395; x=1766100195; 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=tzLWYj/4uneBvx5zEyrPndszFCBrsmGlpqApy0qMaaw=; b=HpUu4LAK6L2SVquWAaEqXVvr/gYPYd09u1iUXvMVK5k2CpMszAX1ogV4p5oBqQvtTa O5ZYCkZhQy93RmpdvVfOpq92TO57LiTa17i4bzx+4y4P8f+7uE/NB+ZaKecvfHYIeZKI aa/Yde5jDnVX1KUc4X6AjeId8DY8ufC4fXx4ZslAvBNS2CXEsKsGO+irwq2s1qMK1LGq /hYWge4j+By7TKdIy7vgtBKK1vaQE9kBK31kvO++FffYez0nOB5hDQPAdy/RiXMl6+tN EidPV2VZgS19w3d7MVuZj60fTYQY45hdwWoxvO0pWZ8WdHCLbBeZcd6ebOUSl3zPT+4f 1i5g== X-Gm-Message-State: AOJu0YyWIAUiR8hsaoC2HM0yySFZMx5HiCrKQmeUS6igugC2347ffVm7 rrgTLMxbe8TMSMHI2j3wKkfhA45Ht5IAw/VImCgPzTsqxQDRwrPrhu01/yQQFMrOUGEvK9Ju1o/ gyxwZ X-Gm-Gg: AY/fxX71vDeNINQsp4QgSNN90ODG3wnHxJCxifNT2wbc7CmkLVDzjckwYYRTbXwVL+i W4Qrw8BCTotQQd4Zi36qbIvgve9mvHSD6OUFeRnjP7fmeXHEWLmOJ6uh5gnuvr4xR+Qvg0uNdTb 3uUn/vVyo53wC1Edy7BvCrNDyWb//BvKdiqum7OwCsEl06HljslhgG7Zj6hZk3vBCpfnSeQTpSD NLR1bchYFdoL4na+3TOL0blKxhr2ginPNOzjSYpuxANsg9IilqIc0qM2YLTkrep2EZlEnjAAx8a K1aCptKfNSuRFd6S35c3vv709fluNtASC8j9tYC+J9tf5xGdtSzRsEdHNxTiOAzup1DyFd6GHxn KFlxYw0jji8fENcwmX82gPAOcarQOq+3eJSQGLL+2RiJ6zKhIbD7Mh5crjt2cOp7J0lvmshIQet 7NEaHvDkDC3hNm27tGRMSDVBnXW476EQlanUYwtiac8u2iT5k/qtodj4FFtuoa5DKSliK6Ahae X-Google-Smtp-Source: AGHT+IEHRz9YkcQVv7M1I0Pn9+jJ/V5LMOQf2MWUdT2p0QYgnOIQRGq3AXE9K+gXJBHE3KyRwQQsOA== X-Received: by 2002:a05:6a00:4c19:b0:7e8:4587:e8bb with SMTP id d2e1a72fcca58-7f66988e600mr170594b3a.46.1765495394944; Thu, 11 Dec 2025 15:23:14 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:14 -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 v5 02/20] utils: gen-shader-headers: Add a utility to generate headers from shaders Date: Thu, 11 Dec 2025 23:22:27 +0000 Message-ID: <20251211232246.31330-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Reviewed-by: Milan Zamazal 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..745852b4c --- /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], "rb") as file: + data = file.read() + data_len = len(data) + + name = sys.argv[1].replace(".", "_") + name_len = name + "_len" + + j = 0 + print("unsigned char const", name, "[] = {") + for ch in data: + print(f"0x{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 Dec 11 23:22:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25497 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 CAB3EC3257 for ; Thu, 11 Dec 2025 23:23:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7BAB16162B; Fri, 12 Dec 2025 00: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="SUW4lDOO"; dkim-atps=neutral Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CB07F6161D for ; Fri, 12 Dec 2025 00:23:20 +0100 (CET) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-7aad4823079so605521b3a.0 for ; Thu, 11 Dec 2025 15:23:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495399; x=1766100199; 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=pQX41AGsNI0QCoqx36ezoVqFb8YAenUUt7bw97cItvQ=; b=SUW4lDOOjV60pZ0hOaq32pl6+5gm+E0BbLb9vHhs6AncLzT28Gtchx4hyqTeRpmfRF v7svnqEywVXTAvw+1oEgiOxPqkWIpJZcgyREdOQ8t8WCXB8YttIvhNxHI+FVBtnvO+79 8/1o26YXt3Y+dp5J4/dvg0zr6b2AL312FKcI0/15Z59tMcU+93JuvjxRHFECtisJqtvJ EXMX9Y2E7EPod3Tv/TQn8VAHpfcfBYrQ4R3W2LrBxkom0C2mTZkXViM6DZG81FVauUIz 4f0gstSw9wk/xNCUA2xPpADiZ0UcA5vMMgsWueo/X5njIDfK3D7o3HwBlFOPxa6hrgnI oQKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495399; x=1766100199; 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=pQX41AGsNI0QCoqx36ezoVqFb8YAenUUt7bw97cItvQ=; b=paBr95IxyhKPJJRhdA0ZyqZUkJcRxo6wW399ZZjq9wUbnsXQLj+ar7ZBAJ2IDsSgP4 fiPy7r55YbsXUQFF9k5i2Sk20QunKqjbqbUom5lnOa+WQJt0tgKu46yLH2TxY6HwXPkX G61+ymYzJ0FoiDW/c8Cz7TgosPSnhXCq08oBNquZtDBDQVByZra4HyUM6tpSR1TpkYvL naJCQdiLYRSd4PuoVxiZESCcj4/NZUpnoZawvw3in3GUDJTyJ0tQiWtBtCB5B9MtLS9w LetZhxdktb6fQymfNF829HNyQl639AKc0MLHEl3DtExqVGTPfZZdBeOy52t4G30o3rGE AiAw== X-Gm-Message-State: AOJu0YzodrkRyJUhFUoR754ZIZ0oDrv8vu/Rn3OCKw/mfw8Ig3H2tCFc j9I3PXLZPhKw6gjC7S2I8KIdHzD3y7/d+l1qb3IPsR6sGxY/7LvtBBayQ4hhRc2p9I8S8ApwDov /CCCP X-Gm-Gg: AY/fxX4TLhukCLgTtAS03ufIdOrDtJ7lO8SwxtAnAWXWDtnBVPINfzDeYqS1t4DBinh /7O7EUTZbEKF6V9fjWb8bVIOkwHMifbqePuSiXRCPNLvJUj8mN7Yq08EdOrhfh0iJKkJwa9Kbop zrMn1yZ0IncRU4Q8YrcV42DXKOrTh/tELjMntT+QBmenCQXjH7q+nU+ZSPLabxRJV8rLrNnBH5a 9HlZzMzE74D/I80dJimyc6zzOu1a7aABiAx4ztW03/8rt8R4bmA3lqNGhVK1yqgWeYkPNxM8TGp a95OJO8T3eWvP7AmrDTfbA3bWETuetdj2EQeYMc4LNzMkw5vm0JF9zQSTYKHJuX5D6Jhr6+FcBy OQQlvDmb6y70DQWUcGvyTHD3UmW1BXrP75Z6NqH1LdQ7MvMAXoyFSgEj5/Lna2aRNRjrbLBnWp+ SHByc9c0xTQcCZYlA4VUPc6pv8LJt/LvD1dYPmgBTGVJOfOH5eJSHbpcyOBZhSfg== X-Google-Smtp-Source: AGHT+IGI8ur9dGb+G09c5GWu15KRXefG9xW53I1tqXAJ5q9mYUuAmK9ROY1rUruq5VftY5cUzgLD4A== X-Received: by 2002:a05:6a00:414c:b0:7e8:4471:8db with SMTP id d2e1a72fcca58-7f66a07d105mr171733b3a.60.1765495399145; Thu, 11 Dec 2025 15:23:19 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:18 -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 v5 03/20] meson: Automatically generate glsl_shaders.h from specified shader programs Date: Thu, 11 Dec 2025 23:22:28 +0000 Message-ID: <20251211232246.31330-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Reviewed-by: Milan Zamazal 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 Dec 11 23:22:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25498 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 AA4A6C3257 for ; Thu, 11 Dec 2025 23:23:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5D7AC61637; Fri, 12 Dec 2025 00:23:27 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="GVcw8yVd"; dkim-atps=neutral Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E57DA6161D for ; Fri, 12 Dec 2025 00:23:24 +0100 (CET) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-7b80fed1505so656035b3a.3 for ; Thu, 11 Dec 2025 15:23:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495403; x=1766100203; 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=e99H68rU1D/gDXlHtAR7K7/NWQaghQ9EtXGEFE+XesQ=; b=GVcw8yVdpohm8lfKJ5UDw4cK/zp8PtEPTsn6GUDeMuenqphorqYyyjMSVTxd978Z04 O1DvJRIOa5QND8/wHVg6wf/ZT8H1KfumuK0UnowbSQ63Fl1aEbB2MtuEnIyvh3ZzUeov InDEHotc1HhFtRfebIxzdk5aYiArjb15vU0L0juOmty3dGnHLGelsI6GuuX42IY4Bu4Q 0hmVo2/KXFFOf19mRiCSbG5o9X8wRhag9yE8fodLHSRAuy4MKBWnf781e3r0HewhOfbv GPKi7w+TmXPpyeq7nDjYrfnZOP8WTK85abhZsmEZ2M+WvTkBdM8ILd5oJGlg0yv9IP6Y jH7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495403; x=1766100203; 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=e99H68rU1D/gDXlHtAR7K7/NWQaghQ9EtXGEFE+XesQ=; b=UexgQoQU+IzKdc2R00GR5CO7fhUbdanCr2ezWQ2wgFR3UuSbryrwGZXn0ndYJj9uwZ vxXy/qxVHrv2OvvvHX5yqCxv53rAqFC6IV1qNHun4xnBM07uXzBuTKJY2pAiu6rTiJSD IwvWFoAWO6aSvDUrlbWYVcYyBhIDDJa2/hFKxZbARBG+vlUClPE1/shKZwZZk3pGklI3 9RZEyNX0qalTRDfNQA0MpMFoLwX2B942U/lDMHq6SgcOP/Dwy+bGovD+O/Y0vL8+sc02 sKlR56mPVmcYP18jsV7SJ8jj0jjt1oxy4veEMaCv6EFCuA602gc6tw5m0JBElzYoxSKe vxGA== X-Gm-Message-State: AOJu0YznCy0wRYxIBGOwhq1L5of7rvdPFmgBtqtXLPPbgoA9dKI97IYT beVPCHpw6MqWZt13iOVD+2yDXGShFPZKgT0uyxkpBY9xhqFJY48hizlgaAJ1qlK35oTBA1bmvVy j+tXX X-Gm-Gg: AY/fxX65pFLO27Q1e1RRth/S0rwx7Dwbp3IIFB+/uOroTeQmcF+R7njptu6SyojCu7c BeA0ZLUM8E8Si0iXcrzRfHm1RR2jIRr6Dse48tyBRGzbIZuuhXHK46VbHb8TS339/qDuyy+qOJ7 ntCvWzVxCzWynrwdDOh7TxIXiqImAkZeOQDyEZ4YO2gnabZYWL5uQb2DfOrLC+FbGk8YQdsTYFb LwhTJGXhzfCzRPO63bKBuZhJvOX1F8E7bPLkXr7hzknZMYkjDIAFh4WKN0sV1oyW3wmtI09I3UG A2H0hlRcTByX8Nq+irD8g4U1xelF36xIOLydpEEK2DE/QH30dsrqfNcuBnwX27MBdRM+TX5bhPm y6UKZhFXsVSx0nFoi3ZFLoH5mVCsPICuIRbex1BkTHy5/jFWBkjVvqMj3vzfLqfLE9AIbxeY7MT ChFPsdXtd9soc+eA3CSDQkNw9cbchTTUMQIQHajPDUdPk4zvj9wcD4cpdfyV81uA== X-Google-Smtp-Source: AGHT+IFiec5oEEvEfUj1RZUnJlTxKxDVikT7B3LBP4du6RHD9E1dha9fz+8wulg/8T3WheLS0DlSsg== X-Received: by 2002:a05:6a00:2c94:b0:7f0:5721:a41b with SMTP id d2e1a72fcca58-7f667d1feb9mr165536b3a.30.1765495403327; Thu, 11 Dec 2025 15:23:23 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:22 -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 v5 04/20] libcamera: swstats_cpu: Update statsProcessFn() / processLine0() documentation Date: Thu, 11 Dec 2025 23:22:29 +0000 Message-ID: <20251211232246.31330-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Dec 11 23:22:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25499 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 4ABE0C3257 for ; Thu, 11 Dec 2025 23:23:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 043E761643; Fri, 12 Dec 2025 00:23:31 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="D+P7FXHY"; dkim-atps=neutral Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 51BE961624 for ; Fri, 12 Dec 2025 00:23:29 +0100 (CET) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-7bf0ad0cb87so775939b3a.2 for ; Thu, 11 Dec 2025 15:23:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495408; x=1766100208; 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=KNhdXYMCXvgUlmVf+twHe8rkAmqCTfmIboT5GgzpZy8=; b=D+P7FXHYXc6zQ2G34+i1560BqFLkAk8yDEhAcGE1PZpv89XhHyGe3UdNJIIsrANqd1 dkr40FiRS2xyWluirvCVtTv8rUB4mlbcN0JvyW2ctFjC3VGRCsNHq8EuaR2WOFEJEOZ2 xy8RhxDozYGDT5j7UcHNUGDAcA+52Goz5OlA98oVwbQsDIuVMtTGA7WfVawoPqVtsiHP K76ff+i340+xesY2G8xO2pgyU911az3eji8DJWkkoBcTyoaNGMyeh5vzeBviikORl/De 5zAnwAYAY8wCfAcu0CYWLKRgG3KZTMEWvMwsZevElC2tPGeFs51ZTneDbdD3OqERns5/ fuhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495408; x=1766100208; 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=KNhdXYMCXvgUlmVf+twHe8rkAmqCTfmIboT5GgzpZy8=; b=NUMsKzPXmpher7zh1FPA+FiNlcc67Y8eKl0hDZLfszZzngt7chdUO8EwfA5i7cGm5B JUGJ6z3urPe1y1fSNtibX+XN0qKoJ98ad7qWZ5qGLuXimw2OrlpxIBmUXxktTjZ+L/OP 4bPBqkt9A+obAUMQ0e4dgHOaani7seOLWVQkxMa901lKwLYEdykPXEY4EAeckuyXb9L0 MO70ow7AkKpk3GZw7JdWMrMr0mHxDF4/sFpU2zBpdJROyIZ01vp5sj6nPNpbDsDt9AT/ D+JpBWW17UgTXP2NXv8zkX6PwO7m2nXhEn5Cg6EBX0l4jy/3foNcE95uVQhYbXbrqOzm 8i7g== X-Gm-Message-State: AOJu0Yw/n0bXz04JTYH3cWWOOWHvl7SLYUJhLtNA5C8avrKOJ5bepUug bRiKt3KdQ6kHzuZXKUnMTGSG8tEAGZcXoEBlh6anFlWzWHxPVS/n9cyTEViXKhRIOpCiH6XGkZ6 Do3fo X-Gm-Gg: AY/fxX68qHLq2I3/E1Mbk6F9wWmOJqafRkf1UAfe6LLeDi4G5XKG+41pL4nRURs+550 nPvqF3qVB15FWKEJ+6lwKZ8x50SZNnVESOGDE2ZJQRwbtF+hGACQKkQd8c3WVfWe+TSe441+UP0 IT5TuoIuuOD4GlbKBxKVNFlhhAgZLPBuMJY2NA7xLE5wgil7KA1egUCJj3AweTdIkAZ50oVFSaK /UcWqW0shCD6SvVvzKwWrMRPOefCQlDjpqKt4F+QZlRIMwrWNZtUrn0iwGYPsZdpblAHGbZtqud 3TleRH/c+5zvxhu65Rtj3z8cWYTe0qA2mXKiSM49zsfh8lPruQGarmQidny76adborKsAGZXdA3 Gv2zh0iSusvJKakQq1melwoXRwa/MWaBUl6uIrQxcZu4K8QfOcUdsxzhoWFQVqjSkSLIIbijVow 1q8p6dO5GQImh5AcJMga+ZiYbacYLPAFe1BsF8LPGZjaqeWuqqYQc+bILxtbtqHg== X-Google-Smtp-Source: AGHT+IFjEMSfksX8YOUokIGNJI4d0X+ICu4z2N5KEoe9QVsLJbdkPPdNUntGIyU22MkijuNMjn96Vg== X-Received: by 2002:a05:6a00:4216:b0:7e8:43f5:bd27 with SMTP id d2e1a72fcca58-7f669c81ff2mr178725b3a.60.1765495407640; Thu, 11 Dec 2025 15:23:27 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:27 -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 v5 05/20] libcamera: swstats_cpu: Drop patternSize_ documentation Date: Thu, 11 Dec 2025 23:22:30 +0000 Message-ID: <20251211232246.31330-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Dec 11 23:22:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25500 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 CF28AC3257 for ; Thu, 11 Dec 2025 23:23:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7B32561634; Fri, 12 Dec 2025 00: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="h/6wY3Ty"; dkim-atps=neutral Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 97C9A6162E for ; Fri, 12 Dec 2025 00:23:33 +0100 (CET) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-7f0db5700b2so569792b3a.0 for ; Thu, 11 Dec 2025 15:23:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495412; x=1766100212; 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=qhu6ljAZBcMcHeBpfyYPkJ64VVf1ScQqCoYCholms4U=; b=h/6wY3Tysl5KwrcHObAW0LWimt9MLbkQCC/2IwUSaZF6Dm/F1MF4Sd0Oc7qtfDwfVP LYH2tqV8yuS9Bum6Dq7yb82ajMQ+xVh5Xll0MT3ELt/Dy0Qtf87fMLu6Ik0MpxzH0D5H 7sK32k/hkhNw5wwqGXTbPYBI48hscUNxnvHvy5ra3/hE6QH7NDUnBGA4MkLe2eOMzYvA 2Ye7MoX2tjSGd+tJGAl/UDcSDhacswjKhmSGLdpZS/E7d9lyOBphqyIyLRy2G2SBjJAP /IAN30vEJkY5rgj7cadkc7Th1Wifw1jr4xzxPdBcZ7WnIt3c4IAmR6TDUf/8r1m65usc Bglg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495412; x=1766100212; 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=qhu6ljAZBcMcHeBpfyYPkJ64VVf1ScQqCoYCholms4U=; b=uTThv5TC+cJV9bAEMNkMorv8qzDoj05x+Xk+chcWKbU0DajH/PQWV0qHTdmSoliY6n tuak2kiPKabj2/lLq4quc3l8VXLDEH2vvgzlIENIzK2sGIDJXE59ZdDL7EXKnIyhBQDL 0Osx/ystDtx3WZiMUPOczYxjKrH7wjmPn15wLaeTc34dbjXmbiJeHx2+Lcju8nhILuHs OYREFo84zDQwaB0MW40eyw2CY3Ye6G60RMlyNZg2QRVQG3Om3/FS2wG4cBCyxPjhtBRi EtcKfPRMkCKylp+ODMfXsStuL1D9DNp82Bnm4yElj/5Fb5/OwtqiVMBVDkh5JQJHAgRE e0Sg== X-Gm-Message-State: AOJu0Yx4aMGgtdI9hHBsPv2i8c1I28tiKcqjsTQYmbqMaCjMInelROHZ CUHB7lsrDCCrRimuVp7LhEO8eA6yu7whVwe+0uuDIwtmTxVnwmsy7mgoZkbEx23fM5AzJhtWu3+ 09OU6 X-Gm-Gg: AY/fxX79Tvm179SDSWzTVn+bPs8P4dlaBg71N6nfS1NvlmJ6xP2ngwoD3fzZJU+2wkb /7WM7FeoUKsVQd8c77cfIYflaqxtXZJnQT9p04gp88CHHM5JZ+RE01oGvL75srQmiU+lqpv8Dya SOIUAAnI8CO3P35qs7JL2FA8FBOK2Z2rUfDBy9LMM+/4rXqwO9Wuq8uc4UUZalHVikmSC3IknzU /5Pmqj99bSp2UEBPgJb6oRoXkNFSRY3zm8Zed/Ga74lERsWw/M7PqwokXjqFCDpEZvRZX3pPqM0 PHRfjHxI0z9aHES9cYoaz2IHIFK5fC0mLaGuF53A/cT5gBdL9n6PXUf8bO4IXi1fllXMEPRu50m KSKl29uqPmRtccQ38pFs8WT/38lsO/un4a5iqAwxihN1UZrKTljHmtfsb+dPj4petVypwvNk8Nq qYtOuXxbOzf3+7pG62VkgwAMb2+P/5hZQYm/ZD/k+WQvXLsD3DSzicp+WmOoKttQ== X-Google-Smtp-Source: AGHT+IFXQC7Vqk464NoHUefqVR350DPTyteISckTy0/nwHwaiEhE/nmdTYGlbm8JVaajRRDD5Fh/UA== X-Received: by 2002:a05:6a00:6c95:b0:7ac:6c3e:e918 with SMTP id d2e1a72fcca58-7f667446ce0mr168999b3a.11.1765495411962; Thu, 11 Dec 2025 15:23:31 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:31 -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 v5 06/20] libcamera: swstats_cpu: Move header to libcamera/internal/software_isp Date: Thu, 11 Dec 2025 23:22:31 +0000 Message-ID: <20251211232246.31330-7-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Dec 11 23:22:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25501 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 52487C3257 for ; Thu, 11 Dec 2025 23:23:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1F1CE61643; Fri, 12 Dec 2025 00: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="pFVETq9Z"; dkim-atps=neutral Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C04506162E for ; Fri, 12 Dec 2025 00:23:37 +0100 (CET) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-7ade456b6abso498248b3a.3 for ; Thu, 11 Dec 2025 15:23:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495416; x=1766100216; 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=yyoWJ0Rzqed6amy1jTZnt8wvjKyWv6LvwRUBP/6g4Vc=; b=pFVETq9ZUY1ZCsVxxPv//3v8ywHNkah/2vvxPc9SmJsBfW46jnvKNEZu/0n6I/qspQ k977NrhG7rXs7tdHgCmQ4vM0el8f1HDBYIZr3kYFd1FAl9gipvO2LKMF9QnS3y73RbGl F+RBM5Y1qvSu9+ruBu+j7oegO9Zj8+YQVfaw/OR8EokqfQ9aPccDUgpjuOSLXaOh+IKt nb35R6nFszFAGlp4lHpFS5ASdwtuHzcSkaLlo566nHsrlF95kkqY8aEuTucj0C2+op23 eAAYA+lO/Q9phtPOlpVMVAI1jHRKl95hz6REg+WUfSGHwYtj6p3BYgs+/Gu0Clklnq0t LdRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495416; x=1766100216; 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=yyoWJ0Rzqed6amy1jTZnt8wvjKyWv6LvwRUBP/6g4Vc=; b=RsaYpgz6L+i8mR31HELuU4w5o8zuGBgzC9FaFgDLGU6b/dqfciYQ4r7ZDAauVWWvoE BUNzFFi1W1iekqsLgkaOXlSXIzwX71U2xEHTj9RWsIzaC1O73mTia9YOf8S5ZZTpoUHn 1e4sfSWYIj4LaikzOghqcvDfpcKJoeWacwgJQdsA5holFw5Wq1KOjEJrjDj6QrrgbJMm lM1RbsYLFSeRdYIostdsrYZ+kfxbkQrCUQK5U9pP3KzJlFO3EyTfU+oi3r6iSGNmsWKu LeqpCwRBr3HWkhPFb7ga0aJKI1tg5sJ1Tz9I4+U2LouP3olqCexiew+nmcSqW20nnsbe owtw== X-Gm-Message-State: AOJu0YwJZwpFVwH+d/AGCViX8mKyeSer4/7PySkRqASYjlxeQuVksWx+ gFopuji2GCK0rWuW5Z2nNQnImj4TSmymaYO6WkqF8vRj1achi4sUwhMgtN0/u0NA61wRflkn9J5 yu22n X-Gm-Gg: AY/fxX5MECzUT04Ekk0u1LDPYdKpv92UDoGa/ApzKTzxHzZ+z7/o7CDUModVhX690fg sGp6TmeyGMoJIQ2yO8UIj+5QIoiHZ5Plg9HOlnsaw7lUqTeIR9I3lKsu57qpeTsGJ3WImZZRNu7 OetpXQMaq6GVpNbH3MrKMkiTm7BljRnAi08lYdOOLFoQnaoU/6Ehwvz2eg2SbKpRDSVP+o2FKN0 cBuIbgYo5qx5HeT0Z7FxWKj0NSAy5MKKV84D6As0Td++4xhWGmD7F9cUWwK5VEjlmWn5p18lCw+ mqJd7ONVw9KP2z6HoOv2Y4TQvj4ksahdCEO/UmT6EkCfHHquujevSrbsMSBbaduImP1rzp4DrYj SSGGMLCkpw8kPWBokR76EZzznbXMarzXUDgEjDMPSW6/8rnO5kJnzNHGiY04ilFwHNT3CcvOCcF HJ+EyK4JxHEDa6cq0qYwjQj7Q1gfJZctRMDbb1MHZ3ArY7qiJzpTZZmwigAdHmjw== X-Google-Smtp-Source: AGHT+IGbE1aZD3b8OZ3QcYgnlyk0aKGnmJvYcOviuY7pnbknc8oKcXDIT1qMeiVLq3A42cpApSppvw== X-Received: by 2002:a05:6a00:1d9d:b0:7e8:4471:8d0 with SMTP id d2e1a72fcca58-7f669a93165mr161366b3a.49.1765495416130; Thu, 11 Dec 2025 15:23:36 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:35 -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 v5 07/20] libcamera: software_isp: Move benchmark code to its own class Date: Thu, 11 Dec 2025 23:22:32 +0000 Message-ID: <20251211232246.31330-8-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Dec 11 23: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: 25502 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 19DF8C3257 for ; Thu, 11 Dec 2025 23:23:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C2BEA61643; Fri, 12 Dec 2025 00:23:43 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rX/xDdPK"; dkim-atps=neutral Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3D0356162E for ; Fri, 12 Dec 2025 00:23:42 +0100 (CET) Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-7f0da2dfeaeso633707b3a.1 for ; Thu, 11 Dec 2025 15:23:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495421; x=1766100221; 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=nLU/ifYTrqqo3T8wLQWtPEibbZ9LrJLctjntqk+s2D8=; b=rX/xDdPKEg8mrROTHWEvBGcr3/9KNfYsTZGx0Jo5S40rx6bF/ITEO4lm1qKoQqcqyP 7G9INJUhCuixkorq8RyeheskQKm6n2Tjg6k6x/UdXCsCbYN/AVI/A+bcxGsZwxbCCamR tOppxdCcumQxVBNb3IXksO5a9u5Jxgn0BzktWI1nSnhogImBKOrnClmiceAxbWVLzm9j 3DMFeZUAuCg7AmLirqu8t9k+zv6Mx8swZowYm3xBfYRXbPKUSvVK5ciH4P3uQDcXLE6L RWiP4vDTgDDfBFdoUQSXKUnbdF7cudcWxgS3dYIoDGD7T9yotRfgCn7dw+CURzoTHAeE bmsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495421; x=1766100221; 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=nLU/ifYTrqqo3T8wLQWtPEibbZ9LrJLctjntqk+s2D8=; b=UemcExRGrFUaLkDond/ne5L9o/FzJZNh0cDjHvcsSxhdmc0mHPCq6j3yOUHIiGAbnI BZU+4Y6Uu0v7j2ldvEx3QEfy9DFK6W0GU7jj8wRr85fAEdCzCcemvyOEWlX3tZG7w47v DLdoW7b0nfxPPFchZ7QGqljCCVOG95WAQuzVyhAbxQqLEMlU92BpzG09NsP5Me0w9vjI oEFs3ocEa9rkcktZG+Vae7RDUpYkmhj0JEdqGNSwJOmgRMLUr2vP9E0ScXrWXvsdsNY5 72Q32J6CJxb8iFu2pB6E4lD52K7LrS7+FkyKCFujVqRELoBsl9DcQiT5dFQ18ibibD6T WuYw== X-Gm-Message-State: AOJu0YwTssS6qKPXErQjQN3I4H09SDgiDmwBrsnWPt1PvBNp/3aOy4bE CA7sf28qRp17EsGUBSYhhhhE6uTb4OGgOzE7LMxZHw8KhNxXb1DKYthu5J28c4QYgHQCImMQCs2 yEwGH X-Gm-Gg: AY/fxX6hFiJb0tSHLr81c5eLIva8tnCCg9FLr7ayNyhvxFAhXdHVFQ3+3MdNpX0O1kP UURHmqoBVsSMrJgfLixbY7Ic0XYF1omdBEP87nsywQ3gE5LhSbTh5gojW6hQXjuhtYDd0ZE1d8Y DNgrTUAHwn0r3iC/GvoU9okOjNSZQksmMIicpEpNkNGv9YiCB3hqaAt/0kQpO1E6sIheaGRghcV aQB+Gjhccej+VqwNKGTI/JBuRG+EKv9g2E7V8+QHQzl3rptUSpaGT5sc8kCUx1Z/lYcVLcbzRY9 7tdBEc21vBDNyRZLXOVcXNYptZSn6QkP50Z+Mdp4M/umaSczUskvsgCbav2NJdWnqLoKZsYsBkD qZ2MsuXqI3jBMcwOH5m1CGeg5xMmFu63qy/4mJDZTB7G/06vxKqT+03EN1eoGImCrMu/dnitVio 0qWqRpsL7smfdcZNyim/0vT2KHkoMp89r3UylqYepPEK7tMo6suHi1202l8AitQg== X-Google-Smtp-Source: AGHT+IEvBQbmM6eRPphwMlpTmWpX1R3vUzsHVtvyDwxY4xtNqZEVsH6HYGIbavW9Yy8LNgJWAsk+ng== X-Received: by 2002:a05:6a00:1d07:b0:7e8:43f5:bd11 with SMTP id d2e1a72fcca58-7f6691b144cmr167504b3a.38.1765495420544; Thu, 11 Dec 2025 15:23:40 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:39 -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 v5 08/20] libcamera: swstats_cpu: Add processFrame() method Date: Thu, 11 Dec 2025 23:22:33 +0000 Message-ID: <20251211232246.31330-9-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Dec 11 23:22:34 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: 25503 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 D611FC3257 for ; Thu, 11 Dec 2025 23:23:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 97AED61660; Fri, 12 Dec 2025 00:23:47 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ty5+1nOS"; dkim-atps=neutral Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4C55F6162E for ; Fri, 12 Dec 2025 00:23:45 +0100 (CET) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-7b9c17dd591so544341b3a.3 for ; Thu, 11 Dec 2025 15:23:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495423; x=1766100223; 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=uNA5N28ijjnRUrjL2lur7P+7SWkYcDAcfVtdT1cafQs=; b=ty5+1nOS6U1LS4TuVZWP5haPaob51hqGH6/mKwmA1FXetbPYUZqyQk4XICw2nJRhhe umscplV7NM9cFrgj1XpqczeJ2PYgkZ9u3BzyaEh7kDYomt2CxE9CS2RBDKfW9Zy5wTU7 9BVcWGMt+D3L2GH9VKEF6FSBA1ys5PI4Ugt1BqY8SOIIEFZAwA/27fJoTXOXzXRwTXC/ vxMZ5hmVO2CkjHccM7UMnfuFMpx32sJG1dxDPP76KZDDpINZEwJarsvTtX7jjDPsvEt6 E6I8sZQbJIij75aqTFPzpuZsdniq2D89JQJjeF3WJBdxUS9ESw52x15sS7/rroMtdsZq 1+1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495423; x=1766100223; 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=uNA5N28ijjnRUrjL2lur7P+7SWkYcDAcfVtdT1cafQs=; b=Fb+i3glXoz4rrFqxJY5whZ3n+KhmOjditU3QRcDr5Cflhny12eaJjDAe1iZrD762LP +rt7cqBFHnblIQF1yDpcyAjQaPtw0xrk2p6ZNCVP3X/i16AjPJlAcgLB991e0GtkkG2d zgZeL9DdFvqHac29JgHuLs9GkPZyNwLEQP4ueT0p/vAqY8qBkol+pQOVmgg0rrJNtMwF NXiYxmECiIpAR/mnOCH/bFJzezEN/wqH73M++FvXv1WxwhN4FZShzJ/KRZoeDuZoV73T RmtGzzEeVjhBDn0IurDv7V/zTjqbfLMP+i0cP2F1a0DweszagIFWhjI6YH4h4OXIE6Lj 7gdg== X-Gm-Message-State: AOJu0Yyh46/F+o63nVi+T1WT7DysYgNPdUT+A/oScn+HRUalL75274ed fqWnbHBYPEb7tisvilmKzLTBmLSX3lbbPin66iCd7B2Ia/G22RSTPTSh4GHqTQrA8YFTWn3Ifq6 GQ5GJ X-Gm-Gg: AY/fxX45DQ5O15TMUB7NK6EL87uzQr00X2G6qitvU8vfinknOm5/LDN9jskKSWXZrvb amUlrSJV8Q+hHuSIarCSN2WxBgMRLBVkPMYW2K2JD4Xumz1ezfLd6KXUGBHVRXJLS+c6bPoR14Z 5PA9veWT+0gFS3jRJRZTco9ort0jkhgUynCdoUWoFUY8ViwCdtICLhML+Yl5Ezt7tkIkdL3hIP6 Xdl7/p1t1EuGvxBJvjCoROkgBaoHpS1r2FWWRGOkpbx24pkS1Llt9U7qMAU+NMfVtoGMNEyEMgV xbgtoEVAj/ET2sJEJj8Xi8tq6MvV8vukPYDJXYQ9Ow6Ku++Mqm20HR2NsjtIaVOJAiNLfrw731C 4thpNnhiN155xy25disUFMkYEjyEQIeXSBj8Oy0Umt/1O4corFUC23a7csw5Rzha41wmxBeKjp6 v3ReeLqR33HrP1bhkSE6BW6VIjUKQ8rjGSwtaoFtrFQQ7OZgRcC/BZ8icJDbFfIA== X-Google-Smtp-Source: AGHT+IF9InpvdehS+4ootBTy4wfK8KCi0Rabl4mjOWTucU78erIWQVHzEVO7+yBpzuiJapCwh9xnzg== X-Received: by 2002:a05:6a00:90a5:b0:7f6:4a1f:68a9 with SMTP id d2e1a72fcca58-7f667b241fbmr219351b3a.23.1765495423138; Thu, 11 Dec 2025 15:23:43 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15: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 v5 09/20] libcamera: software_isp: Move useful items from DebayerCpu to Debayer base class Date: Thu, 11 Dec 2025 23:22:34 +0000 Message-ID: <20251211232246.31330-10-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Reviewed-by: Milan Zamazal 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 Dec 11 23: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: 25504 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 8A818C3257 for ; Thu, 11 Dec 2025 23:23:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4F86161657; Fri, 12 Dec 2025 00:23:50 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="DuCYtJuk"; dkim-atps=neutral Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 24EDB61643 for ; Fri, 12 Dec 2025 00:23:48 +0100 (CET) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-7b89c1ce9easo757377b3a.2 for ; Thu, 11 Dec 2025 15:23:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495426; x=1766100226; 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=KQPTsn/KLpLpdnxwrT8L2zFzJbbxCaiz8WDvZQ7olVM=; b=DuCYtJukqfMFLd5Ed2zcN2VEbokvbcgQQN6xotBIU1nVAScVrdwMkJ2JSkt2Y/tQ1I 5GfKtuQNS0j4iHBemntA6h3Z4zaW+k84o40FfwrnVoYFA3Mrl5S913J7hmltT42dm1wU sm7H55GoTJPYdNXNGQRNQanSKd7OUxWSAPGIFg9dShtqHP1mGWNBezs0xT0zgUC7SpQn VUrf9pjzAaLgJvsu+2Lc4h9SvISL2LCKmHz1VMV0nE3BgW5gBZDlT+Z/4cFkxsBJ3XG5 K9hBmY7FVDxGQlM3P6As3L7lCOkR1rBIXOYteeuQfvTfL+0rOh4+0xMjXINL+SAN2rDl NEqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495426; x=1766100226; 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=KQPTsn/KLpLpdnxwrT8L2zFzJbbxCaiz8WDvZQ7olVM=; b=X6NhUrNrGbQt6I5jLPVB2aiJHOlXAvIrYbnZKIo6O9CzOBSD4Swzegl4TwGIirPYAZ qBdQK2Sp0UYj0Oh0QWuzfhne52/E7qw0ESyIvWdEtsJwmOcv9OsxUgIghVcmn1XB02re ZI4KaAZI3qVtrKdB3CaoxB6jp7sr1/lfzSYfAv7eL4YKFCOvBxLhBcOB5pRwX9m5ZudG vbPKrDlhLBHc+OauybSwDDMzNu9GHunv8cFVCOxCtPATATM2og5NfJQmMxh0GUvxv8O9 JCiDj1xReFgWmakKhIVIFlPn4pCfCIjYhE2ycI4F4Ueq0ISaRQVzScJ7IeIerunE8e3+ 6/TA== X-Gm-Message-State: AOJu0YyvP/5jDHdHm6NenVMI05HE5erCBHBDiRjOxkMbEg84EYkcviuM ETjfHVrzEz+nntVhVFDiBHy9KHJ+Vru2Yp0pjUZcRZcOXXksJc+o8YeaAzVp/zI2uPsSh/6ENJl CynuM X-Gm-Gg: AY/fxX4XUznrwB4EdPeFwPCgjEvH/mmuC/ZA2k4lovl4YOHapmK8UE+amLopI15t/DZ qri+rcqwUZRKoGmwlqb3YDE1R3jPCOFsU7OS6MBPgxVoC0Z6P7BFubC29xi39SoOeTw9WG3CKTT wy2ea9L4bh/vJk9sIE9SAtXPC/r59o+Pi88V+IeZla1aQi50IQfAIqKI+7CSL7kdIb0qhia8z5Q oV+XHEzkV/LR4ahfC0Gs9EWcisKXnGiLBUbFDdfnInI+h+svPMMgZPwCjCT0/M2tEvTfQ0f32PV 1YEjsuCw3PxfLkKkslpHHtpN4X8kOEin35j434Y8UZ4tsp6UHyQIXD9UO5BqJx5DIbkuo93yS9V by/dsDAjV9o53tienBJvpA6CjCoIv552XHXueLr9ggwDXb/KcIYInJ+V/D8KQhvLRpOyXZzfTmt FJ3rvnkd1Y6Ryia/wwTiT2ZAvwY1r88A5PmJwjT1bplkBUzoDHZ24/yZU/aSfc3Q== X-Google-Smtp-Source: AGHT+IH1C7OmG0P59HYn7vAi4jppeVQSDclMjaJ/6VXFcIK/IEHidBzZUeelguZe4U9Fqd5Zq6i71w== X-Received: by 2002:a05:6a00:8c11:b0:7e1:b7ba:d5a2 with SMTP id d2e1a72fcca58-7f664c09e44mr224853b3a.0.1765495426422; Thu, 11 Dec 2025 15:23:46 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:46 -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 v5 10/20] libcamera: software_isp: Move Bayer params init from DebayerCpu to Debayer Date: Thu, 11 Dec 2025 23:22:35 +0000 Message-ID: <20251211232246.31330-11-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Dec 11 23: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: 25505 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 27765C3257 for ; Thu, 11 Dec 2025 23:23:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E01C561657; Fri, 12 Dec 2025 00: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="WzpWbXaL"; dkim-atps=neutral Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C0A3961643 for ; Fri, 12 Dec 2025 00:23:51 +0100 (CET) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-7e1651ae0d5so553664b3a.1 for ; Thu, 11 Dec 2025 15:23:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495430; x=1766100230; 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=eHob+j+mTcN+DmZI0Jjd1599ddaYfYHVsPKAaDomjAg=; b=WzpWbXaLQf1wF6iqvUsNWjw+mul9uKuVWPg0+7wpQXIHhLMjjZQxMnBrMoYqKeXOSN JHffpFV9t3LQ5olHzV1A2/hkTSdW/fPCpJ5iAC09HDHJdKGtFqIVxKs2SbG04d8/DjrD ZbFIITGe4vegsl+AkHjTQb2jANLY3JpLlyVAll/zbpheqLDP9mknFncZaBDQ85gAuvYH pUC2vkhvpWPU4/TWOoeDPjmE/vUbRlNRHSzH/rM9crzu7L6Gnb7XGBv51AG8a4znraou Qibixn8ULdxuyEGjqzPksNCF61dL2ZUxmLdo2/91zNgQwRgo6wxwmL8s9TEuz5yLveFK sj+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495430; x=1766100230; 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=eHob+j+mTcN+DmZI0Jjd1599ddaYfYHVsPKAaDomjAg=; b=nb+6usxl+/+reAyOMSS5MYMUvTMbHRgJVmbxbExunInd58IbUdKi9813cXq95giiQx tjy78lzWMx0TeWRA9Om+xy5oG4HG3BydnEYD4fpLQoKtI4NFZ7vVAe8MI7KnAzugv3M+ wL+tOZiajMWPdvlUSAXpVETQGZPfFdMAsZ1b0wt6vcUDI1Kivre40z5maGR+f+qDyah6 A8Nde8QZgni8dDdO1FBjuS2btLXZh/Q4jrLIHRfvEd8Wm3c8oO8niyiBj5+51IHj9Jza +NC7V0fzdsFQBKvlbdtam/eOU9/oW7VW6kEfF8272kk1t26TYkcmZ61NO1pINIHb6Yyi v01w== X-Gm-Message-State: AOJu0YxJcPAWooZSb3nMyOwGzBn57iVhpWtApn+ft1Hwj6ui2HOCrioV qI27lpSRNLXbgljw7B2a/rhhyRHcKPYS/MUeECsWemXtn2ixFE3SqC72uUbsmZXabAStiw14prw PKFKm X-Gm-Gg: AY/fxX4iWdwryprNpj/hoOglAJ3zxziueAdYc216JDf69mcXNZHBIIe+C1yRK7Xig7Z XDGpMBp/qfXARD5qLJ/txZEgY/BeUL8h1+/Nspsfva68Dq4K+9rbYELKHB64i1gDLYTCTnSuAAQ S5pwtWEVh47em10O4oDAgHYz/mADrjKSZPPkJfkpj+45kAd3TUD3DWGZ2FP/ZE+Kx6wEOl91QNZ XIT6QgQLqi28QJ63HeBgT295s2c0VfXUNSy2SOaBk+AzXbNPma9pHqKYxpORDryF/LKVTCk7AN6 7JgCSD/uB2KiGAyo/m8VRB/s405sHErUPTxJAuEkY8FPI8a4yo3nXvrfEjFw65ktFM+bvsitPtP aYVHGnJjhX8W1AXaunPgB8HcW7cfM8C6/ZT2hVnUBNCyfKPeG4Tyr9Uj/myDNTj/XMjrr4FopBs h1Kd1NHkAqtnrks/Isp3e2kUGxOvQHtpJYLLUFFW2YuQfpU9O+1arf/1V+cIitsA== X-Google-Smtp-Source: AGHT+IGs4w9m1qhROws1gi5EVLMT+1KVu4HMMa7RPzVhS7CDdJS/owF5sdiwfcR8BZEwbB+W3j5wAg== X-Received: by 2002:a05:6a00:f04:b0:7e8:4587:e8b2 with SMTP id d2e1a72fcca58-7f6693a692emr146536b3a.37.1765495430072; Thu, 11 Dec 2025 15:23:50 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:49 -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 v5 11/20] libcamera: software_isp: Move param select code to Debayer base class Date: Thu, 11 Dec 2025 23:22:36 +0000 Message-ID: <20251211232246.31330-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Dec 11 23: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: 25506 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 E6270C3257 for ; Thu, 11 Dec 2025 23:23:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9C1A961657; Fri, 12 Dec 2025 00:23:56 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="arqnvWFg"; dkim-atps=neutral Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0463E6161F for ; Fri, 12 Dec 2025 00:23:55 +0100 (CET) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-7aae5f2633dso650162b3a.3 for ; Thu, 11 Dec 2025 15:23:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495433; x=1766100233; 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=Bh1xFO5NOzK/gF5i4+/9KWqgioiivN0r41v6p9dQA20=; b=arqnvWFghaomREy7RMeMwEcLiwoVe3TiQNxLjXQZfbOc4cx/TO4WaYJIppVah6ogbQ m/sQNDZATqI8ZVnACJauFpbyVFWmsY4lLkSLhDVzogogSLwLYf06/+40TV6C1zUKWnPN hTh2unPu/0AGdLyWQjiwojQsSOwUxRQXQ5KTGUXW2Znxqwq13j2Sf8UOTRR4VfyPpOn1 Vjd6kvpLw3WVbkplSbhAtuLvQSxtH+ECWypHcu+fyEUrIb+YwRUU56cYromTSoi7j9lV NXm230E7UTfF57JBENqz76XPc7P4xB1ROd2Wltqrb70VTf1Vvtb6E4ua9sAO8UYPmLmb 2m0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495433; x=1766100233; 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=Bh1xFO5NOzK/gF5i4+/9KWqgioiivN0r41v6p9dQA20=; b=BVNb3lBnOGwcaxTt0hmIgWSjcYvnBTlebaaxvB5y8Us6LLDBMXKzEacMTt6NlbDIGs rQxvI2dhXuXACenQwSh/6SCsVohz+Q3bozKHtDxq9HO8DnbZT846iwNawN50fDAtN2Za 3liUqk8WOrquk78OLk4GPwF1HsS90nH0DPMMyjKRmkdz5LCxOBH2dCFVUrwUR1K9OTNm f90R4MdBxNAH2VfafQC48D4PjeQHPjSiqlHH04kqKjHita+vVZW/h30f1qqqPyCH6S6K r8xBql8O60GdKMjQAj4pbAvmTAN/+2US+LHevjqO58vh9ALZ74527LDY7UdJrHis+cxs /6Zg== X-Gm-Message-State: AOJu0YzJhJpfSd+m7PyTN4J3RDE0HtWnGGgQ0pi783yO3juG+edN6XK5 rqMX22CLFR3qQ6A2e8XAGH9bvka4snPEgI9WGmiC2UHhgC7HdYBgYukN7VL016AQVcnS9/dQUsk 5+QmS X-Gm-Gg: AY/fxX5HgDYp0zTeFikmxIBCwTFOafAxVxlP/O5vGAv6M5BAI6bQ0yJ4uDJ/n+t7gfQ W0z2iFqrYMILn7tUIMFYWPZJ7PnjIUKBPWXNIsDsGT44I3qfmFB+WLQ5IwUYDBWbgDgMl5NWCBp HpD69YnQbbtqRGLqO4kdxsi9gaVJxBT+kurMmU3xuk9YwSy76zvxCx6/W2d5Hus31H0wV/+E5HM Gs+klIZVAvu/kIhVpLvYNxlgEZ8xRRpyWq78vEF6+xvo8WPXty1nt5nSG+Nj/kBfaLG1cGBWcGv 6bByt4nsTdYSGzdDcsdqugfR9snQwMEqI/H2PnSQLRjgohJ23ze6TP0/xvOD0/VzakO+4vsCZu6 mlke3ikE1nqWQXLwHupCI2A2NEpB0ZsdIHngnbujvk27l8yaw/TW61n8hZHG0fhMliFLLRFk6iE F7wcPEPtVS43dcPY9ZI7eur2s8vHjt6vY0f4W/DC+9aboNRqwidz9ma6n1gorzuA== X-Google-Smtp-Source: AGHT+IGvneHnhLXx596/tqyjM6fgI+db4l9CJ5WYRhMZZNJfZNN75JWqZcgcVFlFC3hzUgrKnv8sRw== X-Received: by 2002:a05:6a00:4108:b0:7bf:1a4b:1675 with SMTP id d2e1a72fcca58-7f66fde0b3cmr150029b3a.28.1765495433389; Thu, 11 Dec 2025 15:23:53 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:53 -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 v5 12/20] libcamera: software_isp: Move DMA Sync code to Debayer base class Date: Thu, 11 Dec 2025 23:22:37 +0000 Message-ID: <20251211232246.31330-13-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Dec 11 23: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: 25507 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 6A3DDC3257 for ; Thu, 11 Dec 2025 23:23:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1F6126167F; Fri, 12 Dec 2025 00:23:59 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Kxj5/KAU"; dkim-atps=neutral Received: from mail-pf1-x42e.google.com (mail-pf1-x42e.google.com [IPv6:2607:f8b0:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 947336161F for ; Fri, 12 Dec 2025 00:23:57 +0100 (CET) Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-7b75e366866so307277b3a.2 for ; Thu, 11 Dec 2025 15:23:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495436; x=1766100236; 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=Kob/ToaFoFnln8JxOvYeUhkJB1Nasllbl3ZD4CR3Ky8=; b=Kxj5/KAUauQQa79W8UDzHdA0G9tcvmBOM/2ZKp/L2+XEh1jEGQ1F+snbXyiB69glTY wrIJygPGA2eJq2m3OI9GoFNPghlWAxdAvIr5owQvZGCILEMK3ZR7lNeZUHQmNFlH16Rh VsxrfdTDIMonJIMrPnKV9wqJcv2xGsf8EgJAqJTFWVenz9/e+qaJipYFS0NcDPDV32PM mA5FygV+nwF4GLviguEJylfIG87PpZqOYppHL1/67rRaK75841zxmNmxgH88maTM4+pg iE7FvGAAwfiLqQn0ANzqqGJ+I1yg8OYQTe5dF9377TQj6W/EacYpP1ocWxl9ljp9dot8 ZOvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495436; x=1766100236; 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=Kob/ToaFoFnln8JxOvYeUhkJB1Nasllbl3ZD4CR3Ky8=; b=S9df/NSldcfNEtCUiMONzL3T7RewM0VwBvseBcp49LxZeCVdDEvWuk0xeEOvmyP5YL ml6JcEcbNfaHlUtKXVwlUnl/XjpogYMXL+kDMNnUwJEh0GbSjtg6oEUUuKgX/CWQqz+O ks+3qwHR4V4ZMqRmg8sdC+6DvEJANurVW2TFfUGTXOtJ9dlTKXd4gnSEcH/1t5DS3nMi Pe/3B51/k1oYI+9tNlow+UAF9YePcFkX9Apq8m5412jfjhbz0VZYE3GicEkzpM8ChjGR JlBPJzKZHYoE0WiRuqMUhlXCe/aH5+4kCyEx/pn09mog8oCfAGUpO5XcPiwyWRBrk0hX oreQ== X-Gm-Message-State: AOJu0YzoCX2aWMUI48s3FqFAiDV6NlQrFlZUgnelASIktWNgGFIQeCNW pnfqs/Ze3gtB0zy/ShXh7gZ8hB5vHtj+T2GdHU0fxyNfuusiC7HtpuckWuHWy2Kc9LSEeJ6pquK qQhGE X-Gm-Gg: AY/fxX76zPcr5LWrdEeDz1GLofi9SB58EBs3qJYUavYzMqHMJLmf8FtO5lzU9x3Ig8F rk3VeE+mS5BUnFkKCyOti3jEGeenI/VLRSNwzE1AxOWP9/9ERS/7fxB0IwtVSb+whAb+Qwm+04V NH6hX57HWi0ccuEYK1D2WiGtcMyq3h0C/AExmT1HykLFkT7JrgW+SuLdMm9KSdrd2Lv9hlYRA/J 8r3dDmcqZwWXk3dVpoAGKt76Bl+OSH0WktI9ZFOubk7T/qftd4ASm52qcvumakjmsiVoW+WxoRb 4md5pijIF8f7neNGGSVoY4CKZ7B1fCFCXUmDi9kKBwZf4qQt5Nk8x2DQWadLXljVTS8gk7x8nBW Hr2uLBFDx0bD7A30RsDNTqJMWVJaxN8ejFmLI/WkRD1oYVC6OuE1vdJ4LCiWalJN1cl86Ipcwx4 Dq6tu9G/eopK5p1iqo+BEJ/gmkLrfiADpbP7/6xE89JspPc3ObsgXfQj/vHFk88g== X-Google-Smtp-Source: AGHT+IHXz7vuiSrRIIvh5j+XYczkt99ttvYM0FytZpzHWXsuIKX/+6mUc14tZuoTOQFQxDbzH3LCww== X-Received: by 2002:a05:6a00:299b:b0:7e8:43f5:bd47 with SMTP id d2e1a72fcca58-7f669799514mr167517b3a.51.1765495435929; Thu, 11 Dec 2025 15:23:55 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:55 -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 v5 13/20] libcamera: software_isp: Make output DMA sync contingent Date: Thu, 11 Dec 2025 23:22:38 +0000 Message-ID: <20251211232246.31330-14-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Dec 11 23: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: 25508 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 EF009C3257 for ; Thu, 11 Dec 2025 23:24:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A641661657; Fri, 12 Dec 2025 00:24:01 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="jlNbcsFC"; dkim-atps=neutral Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E31BE61657 for ; Fri, 12 Dec 2025 00:23:59 +0100 (CET) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-7bc248dc16aso566414b3a.0 for ; Thu, 11 Dec 2025 15:23:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495438; x=1766100238; 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=PYxXfqRVTKkcbydoq54khVfP7mMuF5TcbppUiqX56+k=; b=jlNbcsFCDaUxN3a/LhFrFPrbVCE3hRmDXeORWhSNBX4oUOUL27Xp+cHcnRBZ28nMN/ c61pTBLNJxY+EpjyLLVWQ4ZdA+jH9JBMfDJ8BfkgCT04zfEcqCt5JtkPm5dK2UPUrFof uYWyy7dZP4dZZKdtg2G8UcXFnLrbexh/Pg3zGv/CxU07NcTLNfChdqnLmipX9359vrAQ 1yi8NeBO09GXVSspaWl/DR+coiHIfA9nPQnujeo0RdFKqmWRFiHh2pBmUtEU9lgatB5r HnglrIAlKcuF456A2szpWKHhx4008s05mFZfX2vQNt4vaa/i5nlgqwqINOX59AkPBx/U /RVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495438; x=1766100238; 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=PYxXfqRVTKkcbydoq54khVfP7mMuF5TcbppUiqX56+k=; b=NiVOflKxS6L2qlUWle0yQoaODfemQ4jNXmQgRHiU6IYnw6Fa1glzOEAYf9zZL4gcke kWFyddKvFPpjSbDXpTtEuuMYxD/XsVd3RoF6y2M+UNfs3eKtai1rsyY+InNYkNSJG+Ue TEMRh3rbYDAc7uxmlmvlUb/q675026vMfqOW6Bca8+grX1vDKCYmQwF+m8u5zOpZx0/D 5oF6jy2kFzxcOhSlKEj7xBoMenaKyH3sFjXR9Qk02rie3eJnxACakO2kshX7TLly7rvM aOSXkwNgp3z1Qt5/IZlunwgXhb0MBRlO5UgNzgeUNqYr5ZKIUCHC9OpYBUbxgSNk7Tat 7fJw== X-Gm-Message-State: AOJu0Yy5VRHFXkiwwdL2Z/fkjtcr6CCVVmFSvveaeFN/KxCgkdsGVI35 pWIQUtR+I6YoHiPa461aJDj8zA7preNDfBOMyb4xAaV9aHSDCxO5ZOtar8g/za7CX8bUIlwJ9tv 0WaNd X-Gm-Gg: AY/fxX6kvHjvIocnfpJg2Mm8KtmtRVVTDxBlTu9cN9Zi2w+DXyBp3ba7jJ5sbQDaNa+ aqGZMNxbVYLeTQHWmCi9EAXy7m+05/E6FEMYsGh/52OuYpOp2RiFjAenXbxrxsaeJGk9wc817vi OL8z0YZ659+VREhdEAPCAhCa7tI8DOKXWi8bzk6EUXdwkXaWBPrEfCX2Zqf8UJRxkoHI0RCcSLZ DRBic3vbbNKAth1UCnImPJd2WbKn1Ly0Z4JC9MxaUToOp5u7H+Qm8bnG7PvpOqE4Fawl6xfRYTk wI6kLLzl6zg3rW/vH62gvoN8HHLkWe3LAGJJBk3XCCc/O5UbF6lSqjfP9qlaCJHq/fhy2AyHq52 LZhNWj+sWLLdYbNGeL9ZHDp0ylOZ944+GdBzLOaLtmxZ2qkdgyJJ9cM6nxHl9YxjbtLvsKkphbd ONEhSiLJfwbxE/MfAylGNPK4DI6wxsLLZX8YY779rDy2ig+R5oZofK3Cu7Tb8eyg== X-Google-Smtp-Source: AGHT+IHHsg32XA/0J0TloJh3W9EZdtYKmawcrzFppeNyaiJ+XomULhKAyAecM5PHRPsiwBgR5uhwsA== X-Received: by 2002:a05:6a00:1d9e:b0:7ba:153f:5a40 with SMTP id d2e1a72fcca58-7f667546c25mr174953b3a.9.1765495438287; Thu, 11 Dec 2025 15:23:58 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:57 -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 v5 14/20] libcamera: software_isp: Move isStandardBayerOrder to base class Date: Thu, 11 Dec 2025 23:22:39 +0000 Message-ID: <20251211232246.31330-15-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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..ff4a92c15 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); + static 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 Dec 11 23: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: 25509 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 956B8C3257 for ; Thu, 11 Dec 2025 23:24:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 49B9A61666; Fri, 12 Dec 2025 00:24:04 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="lIk0WZjy"; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B7B9C61667 for ; Fri, 12 Dec 2025 00:24:01 +0100 (CET) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-7f0da2dfeaeso633955b3a.1 for ; Thu, 11 Dec 2025 15:24:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495440; x=1766100240; 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=O+dY2RuVzMDdp5pZPZTVyABA7WROMIfBWzHUoeyG3aU=; b=lIk0WZjyapKIj5qeQ4OuP2astua+hdy/0THniCT11Ml5uMJBEnkrQnv8SMIaYz52F1 JMGBPbav4JTJZUABzRZl26zZZ57M/2Kvn2GKMRdW1EaV8nt3pO2hlexE6K51kcyTQkYb Sco4TQFVHQl3COfLIBRx+GsEL4WDPK/RX/G55eljBqNGlRQ/Rga/4R4eaV/mzxV6x2uK O7h9RcuC1VqNoRG/+sqKnyQhhZ52jOZes2SMJaqCR++sq3D3Gyze8qnyZYVu4QZZAcKt nx+lYr0wyz/nghMGPs9+b++c4WGCZKhbCh0poQupyaCajjF/epiZ3ekp/OOCSJu3fdki jh9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495440; x=1766100240; 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=O+dY2RuVzMDdp5pZPZTVyABA7WROMIfBWzHUoeyG3aU=; b=v6qRfVy/KQoSQIWeD/wn28VJabosdyr+KkvH2PuuO5TeR5T3+Ar1ozqD6Fu30rmqnc ATPYm8gEKdbB8qo+D8uvNVPT7E3lY1aVdEnPUEdlyyhOSobGkhAXijwWb1RWy++Ag3qK 9vTc2ohGGlUXappbaMiUYyYgsIssKbXdSeMJLc86gBHbtmjSrpU/hEUxOONxZu0jNil6 n2k0O88Z2+6gRVZbvm2o44ITL7ck7G6+f0ccGLny/tiIM8fZXUsFUPi8gJVlJZYOhMZY I89JGmRgy2J4mzNiz0WjO+iv3H+Jx6IT9KzPg3cXfYESnWPp/2d8KEBBcTB03ZSDZsAg CFzw== X-Gm-Message-State: AOJu0Ywp7hbJ1HGjUauWdVugJb6NNChdoXgzwAsompqHnnj6pLklEYcY 6e9LI2/FSrnLWpLASMTD3i5xrZ16wlkJ7F1B7w2U96KJNs+Os2vHvMnfAivbSlKOqLxzc2I+p3g iEIXC X-Gm-Gg: AY/fxX5+LLvpfLxEp4BfSOYowtg9JcjZ/UZsI9qclCtugfC71Bpf6XXEsug8FmNhadd RgaDyswTYREG//FgotlLo19mKoegtB16JvpySvWC2/w8sqHtxM/gKzNbzchGDdPMyVk/odcEcEu c932vfUy1iU5160a5RW8Sg0Bxt1H0D9p7SQZfh0jfRJe1OIY9cjD+Xo6Q4E9nbiIvIbrhm24FRr tcbLZ+TE1yNnYhXV9gwiPYNHfRTBvRfGzhvLdvLVBk7gLcH+Hd/uZjHMtZ/CLSaEQ8DQw3BUflW c7u3qU5tkOjKTH6/0YMt/Uv9q+ddM4oCnO0C8beqk/1HPGzzh68e38LStME1rPZ8NWLPd/rNbbq af4sRbBnXw6EqTPdomLf8Zuq0naMCIKBS8TPlvczYD6OdpYzRnY8gkuyyUxIuAQV5Dnv2XQohRA ssAmV0J8ku4ZSumFZgsLqmDdJVwZJSVT0HwigrF3f2/Te233zMa1+43MqpJ+QEoQ== X-Google-Smtp-Source: AGHT+IEc9ed/SU6SGbtCStX1wCyfnaKXg/3TdyRUVNJ8Hr6odvAyqhrjP1xek/YRdCG9tk8kMJnRoQ== X-Received: by 2002:a05:6a00:6c90:b0:7e8:43f5:bd1e with SMTP id d2e1a72fcca58-7f66969f9f4mr182935b3a.51.1765495440069; Thu, 11 Dec 2025 15:24:00 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:23:59 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v5 15/20] libcamera: software_isp: debayer: Introduce a start() / stop() methods to the debayer object Date: Thu, 11 Dec 2025 23:22:40 +0000 Message-ID: <20251211232246.31330-16-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" In order to initialise and deinitialise gpuisp we need to be able to setup EGL in the same thread as Debayer::process() happens in. This requires extending the Debayer object to provide start and stop methods which are triggered through invokeMethod in the same way as process() is. Introduce start() and stop() methods to the Debayer class. Trigger those methods as described above via invokeMethod. The debayer_egl class will take care of initialising and de-initialising as necessary. Debayer CPU sees no functional change. Per feedback from Barnabas the stop method using blocking synchronisation and thus we drop ispWorkerThread_.removeMessages(). [bod: Made method blocking not queued per Robert's bugfixes] Signed-off-by: Bryan O'Donoghue Reviewed-by: Milan Zamazal --- src/libcamera/software_isp/debayer.cpp | 25 +++++++++++++++++++++ src/libcamera/software_isp/debayer.h | 2 ++ src/libcamera/software_isp/software_isp.cpp | 8 +++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 1d135b278..8b4b6cd74 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -336,6 +336,31 @@ Debayer::~Debayer() * debayer processing. */ +/** + * \fn int Debayer::start() + * \brief Execute a start signal in the debayer object from workerthread context. + * + * The start() method is invoked so that a Debayer object can initialise + * internal variables or data. It is called from the software_isp::start + * method. + * + * This method is particularly useful with DebayerEGL as it allows for the + * initialisation of the EGL stack after configure in a thread-safe manner. + */ + +/** + * \fn void Debayer::stop() + * \brief Stop the debayering process and perform cleanup + * + * The stop() method is invoked as the logically corollary of start(). + * Debayer::stop() will be called by software_isp::stop() allowing for any + * cleanup which should happend with stop(). + * + * The stop method similar to start() is useful for DebayerEGL as it allows + * for cleanup of EGL context and/or data that happens in + * DebayerEGL::start. + */ + /** * \fn void Debayer::setParams(DebayerParams ¶ms) * \brief Select the bayer params to use for the next frame debayer diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index ff4a92c15..5c0cb3914 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -48,6 +48,8 @@ public: strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) = 0; virtual void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) = 0; + virtual int start() { return 0; } + virtual void stop() { } virtual SizeRange sizes(PixelFormat inputFormat, const Size &inputSize) = 0; diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 928a2520c..7c9ad9160 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -347,7 +347,9 @@ int SoftwareIsp::start() return ret; ispWorkerThread_.start(); - return 0; + + return debayer_->invokeMethod(&DebayerCpu::start, + ConnectionTypeBlocking); } /** @@ -358,9 +360,11 @@ int SoftwareIsp::start() */ void SoftwareIsp::stop() { + debayer_->invokeMethod(&DebayerCpu::stop, + ConnectionTypeBlocking); + ispWorkerThread_.exit(); ispWorkerThread_.wait(); - ispWorkerThread_.removeMessages(debayer_.get()); Thread::current()->dispatchMessages(Message::Type::InvokeMessage, this); From patchwork Thu Dec 11 23:22:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25510 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 35B9AC3257 for ; Thu, 11 Dec 2025 23:24:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EDD5A61667; Fri, 12 Dec 2025 00:24:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="c+4/aKfw"; dkim-atps=neutral Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 84A7761623 for ; Fri, 12 Dec 2025 00:24:05 +0100 (CET) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-7bab7c997eeso761970b3a.0 for ; Thu, 11 Dec 2025 15:24:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495444; x=1766100244; 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=+PkMvzCnM9G5wbdm2DgdHRiNaN/qiCPxWjNd922vzx0=; b=c+4/aKfwKrQM95lt53CoN3/b3+6OLtnQvyxdTi/oMiawFt1pdeIgdCLOs8qTZgW8Uh bSQJSqeFltQLa64osxe8b46vilBMkreNhS6mgy2Wk1wBRLNvsRel+tq4YvBwUxQQY8ML n/lpWcxHCuTnvai3wkjQ8dRdSZGy8Xniq6kP5nC9n4wmQINiKH5RMGAATw6c8ZyJivbW fu4pWbV4ygTI1wno4yZWad1nO8IVz/mZkmfUWgGrY+PLiDc1KRXhf90wZcSb5GbasKSZ d2yqDktDNpGozIsfTPoUBC7hKIEQn+acD4GZ3fiAzBcls/VuNknr6vuwEzS0i5ULn3C2 Ho9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495444; x=1766100244; 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=+PkMvzCnM9G5wbdm2DgdHRiNaN/qiCPxWjNd922vzx0=; b=o7Rbglaa9GmhaauETrFoE/+0VSF9pBDpF2T+IpDIlcvJPNVfYCN3LFzwJWCK5vW2vg yL6ofHMQEB4+U8Dcj1bjJBX+CBrVGIjmrlpEuMM+oIJbLwiSSFBOqwZWioQyoQD+gLW4 qurmN1HNPnVBsZZGDwcIkEyQdE/D3OJw5NoM9fHfHQXsFiqzu8MqmhxbZ2DR8Zv3QZ11 kPAGs23SvkDijuupT0iHbf34uRGz/buCIzMsymvNvnrVbCcQ9U/RRv56x+xsx2auXWM4 R/YAhtGOm84cRpfTlz1LrI7IxWXYna6xNVlL0SVS7ltnxIGfFY//or4WU73DRGN8Azfj kt7g== X-Gm-Message-State: AOJu0YyzyNtQQISgnEmfz04I2S89ebhqKruD5vjNeD/bUQvHgg0Jq/Xy rNMwBhQmfKerI54J3iaH1mWjVijvyX+HM2dXHQ2jRVCv0jCCpCzHsSXbeXBxkQrIF9IGGVkjIL3 cNitY X-Gm-Gg: AY/fxX7Xd1MZE0axF++oo70rRuPKQ6kU8DBrai4zyuiOsajX7pAUn9J74TMx8uJb99I VJ6ln4UZzxmLbCULg4Y0PDPoYrsGZUCj+PNVZ1+CCZaV5YkFXsAxjfQ80gcG7MFt4GPJ9lI0GIK ZnRWQ1XBPl42NOFGdS56GVzfZUhRUulua923/2L12P7haPh9h4ynbTDIu8hAhGKary5j8g4Sus2 qguSEYGMJpqcnd5/TisT1zJjjHt2Hk8jR4fVptEUDUB4Sp4VfOsQl6NjN7ZfbziFlf4g0IoYFvd KuktN2eiiVq1+s5HL8Gq6pEood/e1WSsBfBP7k9QIh5luqByUnV4ryGslIAy2JoP/mKZfrCwKuV 85WtkCLz/zY7w2UJ7RuM2jAlenP0FfFK1jZFt4K2gH2eHM2HOBnW6aRObUiUvQls8mbfHtZXp7U yFeh+p9zzj3vhKThYKCJ26j9TPjO9jdtO6VBt8wHnpyc1N14iNyAlT0x+ZxM+Byw== X-Google-Smtp-Source: AGHT+IER8oGAiRxKjIB+zvgd3sYh4rV/lz7tmlNDxB2LkBQFQQQF6epwLuP5xbRlhYWZz9H7Kn+dBA== X-Received: by 2002:a05:6a00:300d:b0:7e8:4471:ae74 with SMTP id d2e1a72fcca58-7f669e80288mr174678b3a.64.1765495443835; Thu, 11 Dec 2025 15:24:03 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.24.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:24:03 -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 v5 16/20] libcamera: software_isp: debayer: Make the debayer_ object of type class Debayer not DebayerCpu Date: Thu, 11 Dec 2025 23:22:41 +0000 Message-ID: <20251211232246.31330-17-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 ++--- src/libcamera/software_isp/software_isp.cpp | 6 +++--- 2 files changed, 5 insertions(+), 6 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_; diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 7c9ad9160..b31a374d8 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -348,7 +348,7 @@ int SoftwareIsp::start() ispWorkerThread_.start(); - return debayer_->invokeMethod(&DebayerCpu::start, + return debayer_->invokeMethod(&Debayer::start, ConnectionTypeBlocking); } @@ -360,7 +360,7 @@ int SoftwareIsp::start() */ void SoftwareIsp::stop() { - debayer_->invokeMethod(&DebayerCpu::stop, + debayer_->invokeMethod(&Debayer::stop, ConnectionTypeBlocking); ispWorkerThread_.exit(); @@ -394,7 +394,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 Dec 11 23: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: 25511 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 0459FC3257 for ; Thu, 11 Dec 2025 23:24:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B17236166F; Fri, 12 Dec 2025 00:24:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="evehav43"; dkim-atps=neutral Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C3E8661623 for ; Fri, 12 Dec 2025 00:24:08 +0100 (CET) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-7e1651ae0d5so553792b3a.1 for ; Thu, 11 Dec 2025 15:24:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495447; x=1766100247; 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=rnjAQII4Af7HGPERJUrMBWaxv6dQNSLGtLqN0TNNsL4=; b=evehav43uNg4e7xUo/EmZhYH2SudISZJU++6o5sHQLUD/776UUhzO0ZFZmohdMMf25 coYi7OFsNZ8zFqvLmly8tdSAymbMDReMzUW1tw0x8ZREnH/d1V1rAVfSRIzGEDZE2zbZ t2LGgFtYzAV3Ge8MT5qSyjZggrNOHh5tWY3uprtLphoOeAB96JvWT/oAL3BWEM9owAuf ugPcR8WeC+n26WJGO7OJtutVGaKh+/YtALKdrd8YfudgX1shFTFN3ZUACtQ0KVQ9w8G2 MWR6E2MYX7SUJ/TbamjYL7vZW1MnuNVrO+x3ueA+u9nmSqxDBDyiGwynXJu2dLM7pdjY K6Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495447; x=1766100247; 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=rnjAQII4Af7HGPERJUrMBWaxv6dQNSLGtLqN0TNNsL4=; b=xUKXqUx3rQWyrZ3ViGTT8OSAjqmMMPex1Y/T1ZHbuWiFa+la1e5GHxfWXVYGnL1qNI drBZTgeJa/XaAL6+tRcsaEjD3vr+Osp5gDaMg3NVXSB2rpJjFtJHE2T68jZCKFcEZZ04 b4hFS+YnIg/DrJwWQbRMuJFf/HdLJzLOdue657/Ci3JaP6SfnzoiS2yZp3lMhVu6lKY9 ra9Ye1jIdYwOMhX3ljjY2Rhm7OCKKIClz4qnm/fowJvlfKb+C/VevT8ysd2O1bHIvdW0 B7O0DSSE9DNs9T4uun53cruy/okgGeFUOaiQ6IRDflXiwlM+dmVETgQGJy8W9vGQWlbq 0IzQ== X-Gm-Message-State: AOJu0Yy/+2q+T6vYsGBJuF/M/rQbagEltIQ48hj2h7Fty89tEFaKssa4 +qSB0fhVDqAe82u+Otph3SPnae7QEr7bfH/9CQJMCal7l43yDuikgl8Jvf7x9IhmYBiUF4KmtcK whWxd X-Gm-Gg: AY/fxX7c/00JTwSF8Tq8ikTZIljKGBFnlCRW98+hMMFuPA9BCv8GIj9ehuVX3b+3ySW D6wC7RhUEDP0vOs9jiEMzOxxxmaoe40mVMDGpNICp+czwEF907k7ln1deTnmsLp4anzWb8GsWgu 6ZIL74Ze6B+OpHXsgbmvVrvtzEyTZI4ci1amMNyAwCMMhOknnRyECuFuknF2QCEOFIB/xEsp12M p27UoPG62aD5mL7Y9uZM6gVBidBvdG6BuDM004EAYhLXAPA1RkLTFMptfJSg2s1y5VVDnanAast W4T80eanMVUfdT1e8vrZR7phg7xr9aP6UqHWk3S3T4f9cJ4i116SxwKiKxzRlJJMKe+r4xOgkg4 BEfAV1DsJy2g1783TMQGKBuFflfJaflDx7Qi6hKl6fNszZqroGjfLeRBb9j00s/sZN+MP1srqMi MJdauweTVWtTUWZzNoCpz0V6ctLgmNXL+in6wzRoaBjdl2EigXiUPBrZJShTOs3A== X-Google-Smtp-Source: AGHT+IGrSnpSrZTBc63v9u7rHJgnOzg38QSplE3h/Z3NeDVzGQvLwTKOn6j6XBAFFOEZCshVqXP0aA== X-Received: by 2002:a05:6a00:4192:b0:7e8:4587:e8d0 with SMTP id d2e1a72fcca58-7f66a06b248mr183467b3a.67.1765495447176; Thu, 11 Dec 2025 15:24:07 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.24.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:24:06 -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 v5 17/20] libcamera: software_isp: lut: Make CCM available in debayer params Date: Thu, 11 Dec 2025 23:22:42 +0000 Message-ID: <20251211232246.31330-18-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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. Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- 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 8b4b6cd74..4464bffb4 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 Dec 11 23: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: 25512 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 79D13C3257 for ; Thu, 11 Dec 2025 23:24:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2F38061852; Fri, 12 Dec 2025 00:24:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="n6tiY7GW"; dkim-atps=neutral Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B227C61623 for ; Fri, 12 Dec 2025 00:24:11 +0100 (CET) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-7ade456b6abso498546b3a.3 for ; Thu, 11 Dec 2025 15:24:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495450; x=1766100250; 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=LYX+U/etjfgPjb5J00CQm3DyC6598qa27lMCRWvT06k=; b=n6tiY7GWNBETfta95D6uMNrYLdQjyKxKl6INdtW3F3J0k5KTB3q5OL09u9E8oVjhue e+W9an7mmqKyBKUwpcejikVvR1DKz4jAaNcriuepHe4716iZnhGUKg9kwdkLX/szpxVv vkcod/CStBfQ7qCfhWalvX0kU+YrmIoJ6GiWsmPQseJBjDv4vIE6sWyZSag5UPOb7qLK Yn6N+npACQ1RapVM2K91DNMN4kx044o/H1q1ASv/WiAfi3kaPjAGzNb3XfZIWxz67A0g Rb8amataYYNkyq+LdY+sGXq5SumbPEc/mHFesCaVl409euqaIA6KUleg1UiWkcdWyV8b eeDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495450; x=1766100250; 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=LYX+U/etjfgPjb5J00CQm3DyC6598qa27lMCRWvT06k=; b=iHxkkspnXIw8Bk3C2r5J1Lq48kgNG45m5fA/9oAz5jND4O8E4Fx3op245b03/cVCLv MGYo4M3eoMHpTzjdRW17qsV1QgylTqUf0HTz+ncswGcry9C7hGpRIk+vah5DHBhKvq3K nO1Ppjq9UNE8gyARB1HSFxqddXWA9HS9mJ5Nh6O3Xay55E6/9xMS3zBjetw5CH+oh9/t UlbuAhTUnkKnlfQYP8gB7Lv/Rfi4OxlZG0A7Kp/sH5J/kPGZa103jG8NOHTNODS2BY8N MCfhi0VZWo65u2S8vQzgwJEv/QY+eoYU8AQAZY0RObu1rgl9SMbguCC7iBKsxi248VXf hSmA== X-Gm-Message-State: AOJu0YweiDWdLxEDR5cUoulkrmqXEQIlWmWfV3/kW1vCNyB5XEmhnZVW Q+zorFXp5xaoivV7Vk10cADOsjmo+IGSicS9Z6FKwzYv5oYmvZj2wLBZI0aDgrt+HYGUU0O/lw2 URm3c X-Gm-Gg: AY/fxX7Wh4UiR+lCsztKi0/53K5YL4yENSjuFGNydZJvo7VwjzDM2bleuut48uHMrYI FClIRDWa55ImL63S/RbHrWApNfhu4+R7mlMfRHf7zYnXzmdTdCxK6vZapDQZXOJ62KWfUA3/Jxl kKHrWjIjtJUCBzJerUtIF4fHFbjRdpe59ItwZ+M55S1+dkQUeyc4mFEhK6iCvDkpeIJJMvyotQZ 7z19EoZoIizpL9VksQgxQTjiG/cVc8zJ5XzWYhOzdwKlwUS/RIB9PBXe82BQPkVJiLOuk647FTi hTParqRLFHOHpX3QbLZkWSpPj/fknhMCrBLCoRo93RlA/GdwKSxG71Y6jcJ0PYe6LXU0N2v5exE 21+e3cD57BnSOXKLScq6uNich1hehVnmekMWk3hanIp/iWHg36Y4V9hBdzjCkNRYqHtH2O8OolV Uv1DzOQQTp9H1rKAw/avwMn4GSxpxeAgOdB0vUf2c2dgzEqSv5ZVqEabUA0yEIJg== X-Google-Smtp-Source: AGHT+IEf1aOxJOLB6XqeoyViZ65eKpYpAtLtLakcyfHMawTnOlvKpxY386a/BiGGEtwmdefhrHn7jg== X-Received: by 2002:a05:6a21:32a3:b0:353:6c3b:d92a with SMTP id adf61e73a8af0-369ad3fcd7fmr212079637.15.1765495450112; Thu, 11 Dec 2025 15:24:10 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.24.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:24:09 -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 v5 18/20] libcamera: software_isp: blacklevel: Make black level available in debayer params Date: Thu, 11 Dec 2025 23:22:43 +0000 Message-ID: <20251211232246.31330-19-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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. Reviewed-by: Kieran Bingham Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue --- 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 4464bffb4..7334ea197 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 Dec 11 23: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: 25513 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 4C685C3257 for ; Thu, 11 Dec 2025 23:24:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 02CB661698; Fri, 12 Dec 2025 00:24:18 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="gmVi/gSP"; dkim-atps=neutral Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B222A61623 for ; Fri, 12 Dec 2025 00:24:16 +0100 (CET) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-7b22ffa2a88so659098b3a.1 for ; Thu, 11 Dec 2025 15:24:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495455; x=1766100255; 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=1/Ms2jejD2I8EStEsni5WUE0UOgduJv8CLqlNoVAcNM=; b=gmVi/gSPGUEnD5J3QO2z/YLI10yk3DJ8me6apPDa8i3ojz/5Mp5zQMORYiFl0tupYO OGG1DSMXsllTHzPuSbqoqzIWfgJrPrm57W5Gl/mZglaR4vR1RLRXuwUb5qgahbsU796X 84QSjv8SFhaogxPrBWgQuvd8LOTfnLoZv60rDjaSMtASAkNl3s2a3uP2lKNocafLf2fB /q2e9iB3N1v6IzV8b/ILLsJtHrItoKR4GyfrkF0ZUS6umB8Sa/nM1K98SKsn8w8jvhaq qPVMAqLMnwcQRgF3BOd4oXhglXMBXyqRrT75t/X/J6jeDVijgi4cC1zxGTA5vBdJV5q7 RAZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495455; x=1766100255; 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=1/Ms2jejD2I8EStEsni5WUE0UOgduJv8CLqlNoVAcNM=; b=HgcGoJi68g1uOM0aoz8h9mvN2GjksG1g++6RD4Sgivo3ZNwwurxzu7x7IR16RdH9bU ENGYCGKLWtP/+LpDpIkiRucVFQqu+I4k2zAOV9AMl6DnEnH66vgm5BequkHd66K97SIA bh167ord7I6DsSB59FNRjfsl1ZfclIfoS1DViNubDmqab2coaByMGx1XR3bxL+Ibzqjk aNfl5pvi3RbdvHbn5GhwOpyFS+hpCovFCDl+BYsjI8jw3o1Cc2ysYbdQZevopScU04Nk tVqYpjEDDRYQsJrPN63lNrGvFsPdPkT15hDBhe8wbyfUvtv9/WxRQMVmCYnX4j3r/aW+ Vdgw== X-Gm-Message-State: AOJu0YxCLJ/o9emhRjE1ynY2Q4O7ca8dQbZqo2QXgkKy7yO2X9vpo0Rx RUxGg6EG4OPhSkHNjAm+wXSHUmgokBA3ARbAzjlNysXw4uGscQAwpKFtc4Zrj7FyX7sL1+h8ubB OURVW X-Gm-Gg: AY/fxX79GCR/Wym/O/ZXZP13QlYHWoNZACmA2RNPob37s2H0MrXF5JNjjSDyKIrM54z s2kwGfiBu4uCbwgLdZFJoR+XxrNT3/44ly7ZPxNR9wT3VYkcERV7e+h7HHW+KMssfVqrhHTx/qO f3HB39LB/PT/QqruagQLQsSU0B9D3ypyApP2hFyCHDqZdV4xu0/ZEOrde0WoomdMtBpml+yJ6hI XV1Lr9dralSpiKKbhcckn2uJ1ml/z4H3GdhQvNpI6FDDVq4BhAuX88p4cyonxLQBonpDl5ZpGxQ Y9rosPUi48de2JzQlFmmD8M6DXsLRgfX2M9SrrxeisqGcm2alKcg4Umd5UefW29wUGVqEKZDf2T GdikGFF4veDa+BbRcMo0Qv1jv54y/P4xYcLgWyYMj2Kzg8MW3VUkctSGv2YrcoB0UBusqWRkr5t Gf6ITB4WEA4Emj2X4g2uGw8KXM9SvYIONnLqkr9/Pf/2gRtSQj503BVQsI3edvK6dX+Hl0hFMx X-Google-Smtp-Source: AGHT+IEm1nYyD1B2mSKAmnwW2T8bDF7qTl6Px6NhFXL7cDsGKTNIapHQDhC+dE2Y6Fz5Y6oXGBRTwA== X-Received: by 2002:a05:6a00:b904:b0:7e8:4471:ae78 with SMTP id d2e1a72fcca58-7f66a07dac3mr165930b3a.68.1765495455073; Thu, 11 Dec 2025 15:24:15 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:24:14 -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 v5 19/20] libcamera: software_isp: lut: Make gamma from lut.cpp available in debayer params Date: Thu, 11 Dec 2025 23:22:44 +0000 Message-ID: <20251211232246.31330-20-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Reviewed-by: Kieran Bingham Signed-off-by: Bryan O'Donoghue --- 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 7334ea197..b3615b32b 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 Dec 11 23: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: 25514 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 BF996C3257 for ; Thu, 11 Dec 2025 23:24:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7BE6C616AB; Fri, 12 Dec 2025 00:24:21 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="HEYDkPdS"; dkim-atps=neutral Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6511861623 for ; Fri, 12 Dec 2025 00:24:19 +0100 (CET) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-7aa2170adf9so564782b3a.0 for ; Thu, 11 Dec 2025 15:24:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765495458; x=1766100258; 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=rcK4g8w70ZrNIJtUf3jJQYX0oOGoIStom0aO1MEkaxk=; b=HEYDkPdS3oFWzY6eVtASaWmEV6/86HiYeIfhAkWgajzJGKCoeFP6NFl/LeHVsJLQQv BBdh3ussAI443plOpgdQaanrwyw0st0/nxLOJT3eigG4JOxpCIlY3baj++8F/+KIiMT7 QF2ZwOArc2BKnud59TeuXbK8gT7mKCbaRgvunZx8EfxrQSXz5Lc3syqppSDc447nqXH1 bj4APDGiwQa/k3P6mu/o8ymfUIJsPpf+9yB2pF0LWhPF0O+GBWsvXZfl6Svl5M68b50X FrDzsBFTlz4UfZ/DCOFUJT4aDOqxVPcKbMv+3mgi+HmfzLKsfFZtlnCfcr5j0KNjX/HK CEUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765495458; x=1766100258; 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=rcK4g8w70ZrNIJtUf3jJQYX0oOGoIStom0aO1MEkaxk=; b=a0sxG3uBMiMqfnId93EV8ET22AwJFabQkqiMpwWf85jgYH+PANBNaJsoJJVnQcALd3 o8+Y1Vm1FS0qztsDZaJgWj7tNdhzlpo+sazZRZH+Jo9Fzyzncjd9UmqgDAyOkOj1L6j9 N9ZN9hofbE16LPh+lbayLT4C4Mw/aQsI3ENGQW3ZNEYRFve8tEHO0r+OB/r+02OKMGIM zDrmOHII+5wbw+BcUE/Br8JMtwImUXrXIUi8mawbFbRu28aGSun0VN02HpkMiFhI6afE myXBtED36M+lSglQ/6kEAKVDvDEgnbANJVzQlu5GV1JKhanec4rIgBA+OhLhba3Nr4q4 5g7w== X-Gm-Message-State: AOJu0Yz/myop2+X0ar2nufENBPK9aLDUzMu0nqJxTunb6sUbciVxBm6n kmZuuwicQ6/W0Ke5jBRM5HDSQmE+Q/soCbgCG527xjV7ky7UPYBN13TqG86Jkbl9IGNGz7m/Ikp TBRkt X-Gm-Gg: AY/fxX4VTi2WCBGTsETc42FTjl2GR2J+m67qKjJbBUCgT5uOXJu19dkYSdq3NCe7cw7 QWHwUYDsQnJ04gPf41KSNjNazhBrx2tt35pCtmHEoMy37s5H9mULSLwAxiYkFnd500oTnwJPo4y mUHfDrAWRsWkp9WQHq50CnOVGv2PrgX5qjXaQ2txYW9++QEDhveQTssr9bJ/OxQfYKbPfvl4Fi7 +MKL55AM4tdijpfF3L/szxyMffhm3vLRTjUxxbWX7NGt2TmDixcPw1eLWt4bc5BIUIgw0a4vFMX mhVlNbgoYlQlmH3oeLBpgP7noBTy2PbkShS4oefklB1xEGsiFWMvaasu6v7Ub3KfPv4iFMv0Yle 2efpSGAD7X2DirY4RE1PczPpVFTw6Xp6X1H4W+BSW9tOupDFpT2knOSHQ+eFQkt7oXvs+daSa3w PDpIZpXkaeOPzs3jBXJFXxytkyB00x+kR4VHSlYLSs3JcY6dpum7rbBKRhpFaOAA== X-Google-Smtp-Source: AGHT+IEgYOM/qqkIbnrVqlL4hRP4YxhD3ycJ03XZJgc1WaVZDRloWeQI7UUtflkrfMzCS0zmpl0sdg== X-Received: by 2002:a05:6a00:368c:b0:7e8:43f5:bd36 with SMTP id d2e1a72fcca58-7f6692aaca9mr203827b3a.34.1765495457774; Thu, 11 Dec 2025 15:24:17 -0800 (PST) Received: from inspiron14p-linux (M106185144161.v4.enabler.ne.jp. [106.185.144.161]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7f4c4ab52aasm3399933b3a.38.2025.12.11.15.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Dec 2025 15:24:17 -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 v5 20/20] libcamera: software_isp: lut: Make contrast available in debayer params Date: Thu, 11 Dec 2025 23:22:45 +0000 Message-ID: <20251211232246.31330-21-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251211232246.31330-1-bryan.odonoghue@linaro.org> References: <20251211232246.31330-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 Reviewed-by: Kieran Bingham Signed-off-by: Bryan O'Donoghue --- 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 b3615b32b..b5b99d390 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