From patchwork Wed Dec 10 00:31:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25397 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 D6650BD1F1 for ; Wed, 10 Dec 2025 00:32:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 950616141A; Wed, 10 Dec 2025 01:32:01 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="QWQVdNFk"; dkim-atps=neutral Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 79C3E61418 for ; Wed, 10 Dec 2025 01:31:59 +0100 (CET) Received: by mail-pj1-x102e.google.com with SMTP id 98e67ed59e1d1-349ae58a7baso2885610a91.0 for ; Tue, 09 Dec 2025 16:31:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326718; x=1765931518; 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=QWQVdNFkLz0Vyy3xRGzF3ALeQfJEiy7uXpD9atSs0plWLv6TpHHDNAi5kDGR8dc/fd sDxPGUn6JPG3L9FhMeLdjLgfaIvom/nvhTy+SRlx3QJJ4fpRtqTo9J+RTMQIS4slQSnB 9PCpUSwM+fhOUqwcIcQATtiYgY+z6wpcyZ2XkZocBD2kQweOqtrejOfh82pUmEXUm016 QWRb7Ev4mbzfPQRMnZp+Tn556RzZcW1wbJYOPR1GtgGD7h4Gwgr927R9DxplHXZAJEOV odhcr8w8QUt8w/7SWuw7iHGywW6N3JjcWc9GqXwW/OcE/RCogDBd5DmKgtQ8AW8+aSGG S5Dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326718; x=1765931518; 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=a+KNGahOgQYgsHkCdSmKuVBmQV1OVeeOCDUiPFMkwYgPCVHy50c9IV+amxBkTSpGjp UeshOrc0UM9XUOCS95Ic0VMxvUSDwkCrLaTnKZvXOzkx3GM+2IcDTNu/CSXD5te1D5eB vEUYHiC3K6QoL7eoA0tXt0JcVPbJeCkXp1zGze6i/unw2m/SQI56cPFYoXlOflkoIU/c 4bV9Kr49NwiNATcKMcZU4A6lSRrPqPmcNX41U85Mgah6Mf6PNi054h9535i7BK90t9fE bpp7vxgerJS1WT4EB4ooOjUmOfZ0MHXZqL506kPkVWQ/37slioQHkFuWlYayLpy10mNG qkhg== X-Gm-Message-State: AOJu0YxvrilzUVOKBOOD5O9fNYPXCDo0Y0hSGC3EQFLrTrb4CpdAfVMp pQdusMVwBl4vhP5ZzPULzKTZb0JQ+VsB6Y2YuuoqB8TE0KguILKfu47rFdmZI0++Dnd1o4s/Ayp dG0Xl X-Gm-Gg: AY/fxX4ZPa2jWFvPq3CK3D/gFxNa6URFhPRwn17qGbXAygMnHnMCDX3omj6idthOYUf caH0y9aVplorTuDzeJub1/6fWcomXgoc6SRksZeV4Xkl90frKIFUErpRlyySGlixHw7kEylgo/Y VR7KMflnQBBGJU7eo9cKC5uqgInDHhCT9NRgLl7HRQujgRFzwSSXmCLFNph4v7BGe/HOGyrKVbZ GeZ37Od2iWN8c2J4HL4j0mZMvcJkSC2WWgbzrtLzY0W4lAzOGYWZHjdBOPSi8fKOvVqbHtWZr23 gucrPH4Z3aNFPxenJ1jtRoHJf/JRh626vRrwmub9lNZWvrdPp2Gm+Ai0Sf5uB4XBvpraAqEI6i0 aPUHlMdlOKR9GRmCl6gGBzBZxWdV+v8Nde4zAKIOtD7UVVyjm23xo2YiTJ6lFeTxMp7M4BoZYQY 29H4FlmVqj0zZW4BL6+k9lXVmfOgBW0kOXQ6qhfJO4XFTh4k18jQ4CHpmFqL+jjP/E X-Google-Smtp-Source: AGHT+IGX3+xjm6f+Y+L9lxhnJNRh6+VgOLsbjUpFVPFk3A9JhKG35KDCoEOz6dyUHYoQmOg1PQOe9w== X-Received: by 2002:a17:90b:278c:b0:33b:bf8d:6172 with SMTP id 98e67ed59e1d1-34a7289e93emr532240a91.34.1765326717637; Tue, 09 Dec 2025 16:31:57 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.31.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:31: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 v4 01/20] libcamera: shaders: Move GL shader programs to src/libcamera/assets/shader Date: Wed, 10 Dec 2025 00:31:18 +0000 Message-ID: <20251210003139.43606-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25398 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 7254ABD1F1 for ; Wed, 10 Dec 2025 00:32:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2C6FD61422; Wed, 10 Dec 2025 01:32:04 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="P6TkjOng"; dkim-atps=neutral Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C824C61420 for ; Wed, 10 Dec 2025 01:32:01 +0100 (CET) Received: by mail-pg1-x535.google.com with SMTP id 41be03b00d2f7-bfb84c2fe5eso151207a12.1 for ; Tue, 09 Dec 2025 16:32:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326720; x=1765931520; 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=P6TkjOngt0SWGlwnBgViSpGhYxuUkmAmITAo0nZq3MTCL4i6jjVyWfOBhZkvwLZ7Ll 6d3XTr46K+HrwEtZktjgSnggUOuworFI6LySb1sp0fV2GPd6GF1zE03LygMWmxnmYwxf 3FLA1CmN1EV6yP1kdaWiQr2ZxJLVhQWtPp009bpJosbrQQLs2mwKv4SWn5iPuviK+5Db aohqe8AE5XDqFsukxky41tDffWaRiglrHVyGHYBxvW5fQQZhcCZJRoVG9o7jUewBeRbA 3SjnuP1s3dXB4tCNQrZ+dbPnelOHldVwyCt9rxEJTRyZyi52c2aGm5ScBDHmBKw+zhDJ 6a8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326720; x=1765931520; 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=NRpM0I+aK8lUhtrZlLQD50rJP+RFg2/IaDhBAA1LF5sc+RYimXIE7XM1NTcAuzITa6 SBArf4nzOUBwMMziJsGkDPoTdFZGVj9XmeAGTfik8Y6it7w/n5aj9Yksuib68sei/Z9G H3SzMNmHtPGJovuuDJAa6+y4OdCKTHXrDrxkc8uzPvP1uMEIIN7NrNnut/NG5dZsrwIS oqrMOy7fyBF0CrrzA8AWOVm67YswOZnES5nZOc1YFDMBQLICevhpF5KpRtzxH8+uds1e yacr0aWM19gijDccMEt6CFQlT7TGRenjW73awHMuZ2wmUMMC5/24nJaV9H42xAZ71fjz e2HA== X-Gm-Message-State: AOJu0Yw7BKADJkkUmjbvLkRK8OFSUBnFbtlTQhKE2P6j0SnA/Iia1pzn HctcXxoQ64ahVeEaFBOIdJMH5ZnVpzTZxEKqMh0BvtbW+13z0okLvGoRkpWuzf8SRyIFJg+c0Uc cTa8f X-Gm-Gg: AY/fxX5jwPeiP48jzsy+oRDvHry7+j38FJNp2SB9yzSdHh6NWOb2hsqe/9wwKZ7JP9A LZvgA2QGDAN8DYrV9/2hxnOKPJAcDGn32POOJPwEWCa8u+Wjpi/UeTs9/x6fxCY8a9zdPnu85QW 3S5uEzu5+8viXyKX/flm6ZNjIP4AZAjs/zmNBkX14QzDpeHtydxEjisPajrZJn6Rrxw4XOGNBtj k+Cuzu5OZUNZ+kQFgvOEEbyXQourPpwPibHeerIdGHZAR6n1NXxgjpG593Fb/buUbzZtKa7jW7q NG0zDdA5lf570polkgbgHthbjGoWOjhiUo72EZ28rSD7VfR1hcYR5DUqYbFGwlQ4BYZu1BCLGB4 gQfHYCvbr5nGnJ8QEY6+Jwa1uf7BW2QrkH9jqg9GdeUcTtmCXZlUUhSMye2S1fvmVw9FZbkzknj aOmNcX8Q6oSjr81IohA56b0g8H6Ex0LhuAEjbQ9GjDg27dH5+M9ZjGOEMa1Wianq2u X-Google-Smtp-Source: AGHT+IHRWEobcGDc/UcJdAC4T7BSAjc56jau7ocAjiT/9SrRaogXhAfSQbvfGIYXfcTw1oZbZPVhpg== X-Received: by 2002:a17:90b:17d0:b0:32e:2fa7:fe6b with SMTP id 98e67ed59e1d1-34a728ea521mr529512a91.14.1765326720030; Tue, 09 Dec 2025 16:32:00 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.31.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:31:59 -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 v4 02/20] utils: gen-shader-headers: Add a utility to generate headers from shaders Date: Wed, 10 Dec 2025 00:31:19 +0000 Message-ID: <20251210003139.43606-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25399 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 3BBDEBD1F1 for ; Wed, 10 Dec 2025 00:32:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E586661431; Wed, 10 Dec 2025 01:32:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="eq2SQbn3"; 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 E1F7361418 for ; Wed, 10 Dec 2025 01:32:04 +0100 (CET) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-7bc248dc16aso5237637b3a.0 for ; Tue, 09 Dec 2025 16:32:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326723; x=1765931523; 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=eq2SQbn3TbNT+Z318qnFRr2tynSPpImCD0C21cVlegguZaGj75SJQ4743T6Zne4Igs HeWZRVcsgXztpu9+X688y8LbdMKBF1vr7J6Hy2WF7Xw3YlhBxzuUogR9t7KChRxpIP8+ +GYX3nxRyJl5VaFyKu9LVHk63xwKbcdhX0BYbLAv2OfgGQf2WITBURDQIWfcm58H7cda ITjZ2sykvQxvmGPIX7R567veM+FiC/YZFIJJ7Bo2kaWCuFECsoufJvv5Ro4p0a3j45GV cfOhndLG3Cuvjh2ISBqG4MLRAE/V71cQhPO2hHMy51vGsR/sSaTIzsweHXqeNvjo0avC vC4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326723; x=1765931523; 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=jDgO+Y72/La1bxUEK0du6B6iEjZo6K2QY2XJAGTSCNC7i9XhP5q0sAs4TwY0Xqoz3V 3KWt0S1g/GJRqAfPp78tCpLzAP7Qg3z/UYtBvDsf19IjgiqAvFDbFZ9aX6NL2qR7No1h Ft1/PBzOl5/J6SHTOj/sSTO+SJ2Q/gUEMWQwes/KAimh0EVm9McIjEvfvDTPPjp1UUvh sgCWsnGekvwHFu9GMDsW8i8zxgbRBFgV91MErFk+Rg5j0Qnjf57gfuJiRgzBJ7naaAQi 0w3eyDHt5vLnZFtb1wc2w9UNfRKwsjoMV6TOJcrxldFbNMBBlT0VE7B/pfs8arAH73bK hoRg== X-Gm-Message-State: AOJu0YyhGdG0nq58d9WXbIspypVD+QMN1GWixGW38kZUS43D/2uZzwsq 4DFCSnVFe59bYdXPDYCRF3dFDtBhOh3450PnJGITWZANaIKQ3kqPIPtqROD5B81TaD2DW+EUeu7 c2Ko6 X-Gm-Gg: ASbGnctLPSmklSgGsNRZbxv1Bu/9NyGs2baWDWBup9fz7/i+u++laR+//pPpFVP8ZNk xPx8JSuXkbIlPh4YwC3KCtUa9fOp+RB0vnqcNDkfkS42Tfxs5i0xB7tUjHAQZQOmDIUkHfFIT+p c473U04KiKax/KoIR0JxqwSqdau+P+h3ZiUAZJgiNx+g+GLC7hkIYX+k1o3wswn1gU6Nlw//ohy XKXiwPp/s4XtqJxriR/NeJkSTPLJSXWrkv/v8E+F75DBiqbcJ/8kAc2uzQIqfMwSGz82Qx5JQ60 FXSpMfzLkOxM0bCgaPGidrFKlBid7QFbnzPcokVE3mEmr2NJCWnZvZW+/IUJ8DFqB4uuDSkxjik 4UYnGgOB1VSOO4bcH1FzdUFP6iood8OL4qyLhjI6A+mpl+L9YCfmfBTv3w0OpojdAL3QoQcoZId 7cwvODVa3ixIVoaHZCAIDSY7wAryQWAp8rGkIBxRy7P947uPnEtItzFak5HnO3vSo1 X-Google-Smtp-Source: AGHT+IGqBDXNQUpVt5Ff8KdBg0FCL2vHzXfc9btu3an/SoSjVtOmnrl07d/UW/p9v7lnpyXqLoeNGQ== X-Received: by 2002:a05:6a20:3ca7:b0:342:873d:7e62 with SMTP id adf61e73a8af0-366e110193bmr448726637.29.1765326723080; Tue, 09 Dec 2025 16:32:03 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:02 -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 v4 03/20] meson: Automatically generate glsl_shaders.h from specified shader programs Date: Wed, 10 Dec 2025 00:31:20 +0000 Message-ID: <20251210003139.43606-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25400 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 C8F90BD1F1 for ; Wed, 10 Dec 2025 00:32:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9083F6142A; Wed, 10 Dec 2025 01:32:09 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="qvUcFVZi"; 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 892F66141A for ; Wed, 10 Dec 2025 01:32:07 +0100 (CET) Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-7aab7623f42so7461339b3a.2 for ; Tue, 09 Dec 2025 16:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326726; x=1765931526; 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=qvUcFVZiePfLNqkdBo6i/PumFT54eAAoRWSHCsV5c39gf2yXBEOJ1UgW/cyYHWbJZf 6lm+jsmvITmmB+DGgyZEb31tHt32mmBTjlG0v9XN2/7UFyni78bDnw4oo2m3jOhT4moS 1jvZQgCacdZOYeUsxIWYG+47I1Xn9OfaeQ+myl/bk0MAaaE2b1btDIs8QP3o+CGnnOTE bWrimlPrMu7L3eLRWhnLunHRNAC/3B8zaBzBucj5kFjY7FHbM8DbmZcbouV1314B0Bdy 63CwlxyarkIMltBCq8D9pFBJ6yxn5JYusbG1Z1dv4vNLqMUrXlINdYTg7g7t08XzG3bm uSng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326726; x=1765931526; 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=C8y7N+h2kpSd3jXfMXdATyX8PMayo5yVeT7PHVC2tdWA62FUvJfNW/gyv6yZ9pZXB/ IAYx0isSzMl489BYAsUfNQj5Gl/KX9lVchc2Iku2+ZE4fkb3PeP3JMpILb6iXhBtb/Iy kGdD+5ErAr9/AP+YAg3l5t8EhsN63q8zUfbNG9ZnLKOgkPIKTbo2hBgLvtPdbNmU+hal LBT3krmqhYhnhcAu0bZNubm7K5g/4sb05Do4RGfVgpQlVcHwZq6ILpB+1AMuseof1Qz/ Tg203Iv/iddso6yymhfwB0n2pA6hTTtndu6dHLEeAgA80I+zm0/WtZzYhGT5TMAiAXFj QnYg== X-Gm-Message-State: AOJu0Yw/NOBSBhONxAx6P2s57zPiLv0mXz9JgVWeWj4hO7fZTJsV3a9V V5w5TMutL+BC4iivl8ukQOMfiT1ujDRurCG+xKQnrUM7XZvD+4ZXyY3vBEU7Xu17D1mAKkzHb9f a2Lm2 X-Gm-Gg: ASbGncvW0gjnYrDBgHYo3SvzUD6eN5UQ3dM6Yl0nR42llZOJUt4cs7B1/tPGr3kQhXh AhtsBGqVU7OLJsrKmHZmy2YX5T+LNOMmujOUvrtnrFH39vzsgtB2lgH37yhP81hLzA2cc3I0FDF rhTR9Igg4k97i6qq49YMaSvqsVcKwKc8CcbJAwEzqhg7sZ+Xnu9IHJuGg2sHM7wLMsWQr7wtUOm BkM+RFsxun4vqdrOUnUKkieEj/X4lhGSwZei4i73wAtksPYMnMmn9xdzx4HwuhgOIh69FzyI/aB 4P3+qLALZi6kVEjbDG1Q+XJF2J2J+UL/muy+0474xf/xpXWShokHjQsPHQkGp5HAYYPnXUwyT4T DMcrCNoFH7kYOOz7PgWily13owm309Mn4wAues7qO6ywkuZ56xrKhujHWm7/ovClStL0SudePie avN38o0b483j+onDF0pcHA+boPSVq77UwyUEw75TC16icdd/vGdbUxizXd4r+fZMSb X-Google-Smtp-Source: AGHT+IHamcf1+KG0Au74QzpcXxJRzK0Co2CE7uzjTF67yN0XdR5gf+UZPQpdO74DV2d1yhqoO+1scA== X-Received: by 2002:a05:6a20:6a05:b0:351:9401:c2b0 with SMTP id adf61e73a8af0-366e0deaf38mr449374637.31.1765326725885; Tue, 09 Dec 2025 16:32:05 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:05 -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 v4 04/20] libcamera: swstats_cpu: Update statsProcessFn() / processLine0() documentation Date: Wed, 10 Dec 2025 00:31:21 +0000 Message-ID: <20251210003139.43606-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25401 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 6BBAFBD1F1 for ; Wed, 10 Dec 2025 00:32:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1D9506142A; Wed, 10 Dec 2025 01:32:12 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XYPFq7/T"; dkim-atps=neutral Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 45B156141A for ; Wed, 10 Dec 2025 01:32:10 +0100 (CET) Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-34372216275so6276704a91.2 for ; Tue, 09 Dec 2025 16:32:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326729; x=1765931529; 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=XYPFq7/TKt6oXUyD+KJ+i1YTnMHirbQ84z8aWQt/ToLPr13hG2tgaauGnmpK9xunOo 73U4FL06sUklQ7VPuz99n0SqkAo2IU8F5j+9PiA0GZgWG9axjmYwTUegEC1MYwfYfjHo UD97I5CmWvUMA8m3sKddOzAJVRBtB5G0ZdS5sGoOkTEt2x7oOifWYP9oRe2ooDrWOl+E S7x/O/2KfYL35KLO9dG+luo13Wgqccz3HVF8cwlTr98kMYFVRsfU6+xjh8V+a1tHYd7h 15ZMA4vF8JycgAjFJdNZ74i2vQzRHmSYQ81jFLGhBPdZ/GYcqtpmHc2El5GBCTfFh5qz yuCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326729; x=1765931529; 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=Eua9sTuy+ZLvokxOVv3ymKI4BG3O86cYtKUCFSeAuXlEQG043razz+LtkVsCxfCja8 uV2lnZbfXFH4wb5RE1h+ZipE7p6xbiiAT1DIKxVbk77J2FUnZKVh+YPjEbRvK9ZBsAlW Tj4q+Wl7/70jzGLZBkK6yTfVsI43zJ77iFOd+Q20jnLfx4nFMK0c/1E2rvMsHaZlNXjY qJckq+UYXy+7c1MFYevOd8SkQMtWnyCSlroKQq/Q9s1bCuRi7j+K/Q4gdpVHYEeUn1lo sYIYOIu8nNEGY08+sRpAmZJfkWEurccj5lprBBeu5caog5qF3i72+C5nnKA5VWjVOF0+ NN3Q== X-Gm-Message-State: AOJu0Yx6lF1cK2VCwDXCfmkgo1wpmbfaBJecb9Zykd72HZcpippiA/Ni pS2gGZZzs7JXw29WSaEUo36r8WywzgPs1E+A5mh004++5A6OTw/CGrgGpCi8zInvMNkzLvhBa7v 3fVfD X-Gm-Gg: AY/fxX61wc0MSUXruRuOys2omBHgX4KqAtStA3U8qmH0Y2foxDjuFif0wcfE/Ue/Quu irBFNysXf2YM5fbc7O2c203zW6SbdidB1eE7xc9kTrvZ9MxywBLHIx8r2Q1WXbXKfEbkCuHz7Cc RXpwskJj4Zyuj+ZmXpDR2H9p4Oe7ywHaLtVhZXurte2h/ejap9lmB9IIAw/XkF94yvmPeA7TJBz 2Q15z8oXckD7o0sz41PJyL0sbv0X5YveClXwUSHC6RNvod9vLvrej5seog3XMMcny8Gy4YNLsDE MsDrnm3DpwlJEasXA6OTIc+uZETzg1YLAuYOvAg6RTEuN4HSxOtNTfLBufgJQVpisA01SbR978s Pil1f3ShhZ8W0qGn8BmtQc2If1iJ6bqduTL6sFpPNIOYB6GgIROKGdiqqViIEkh0bvmTfTA7C1H 2SDUQNGpyyyD6TmW5x4odJ4FxxH7wMq3M1nU83p8aSWav7KGNDFa5NvGEe3s8BBQ+8 X-Google-Smtp-Source: AGHT+IFxis0e8OYaWjXTar8q2nm8yyQkhWAI8+KsuHvFTK7Qw2pkUOMLWC71CU+Uskp1ViEpLtybSA== X-Received: by 2002:a17:90b:1d8e:b0:343:c3d1:8bb1 with SMTP id 98e67ed59e1d1-34a7284b8d7mr490153a91.28.1765326728564; Tue, 09 Dec 2025 16:32:08 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:08 -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 v4 05/20] libcamera: swstats_cpu: Drop patternSize_ documentation Date: Wed, 10 Dec 2025 00:31:22 +0000 Message-ID: <20251210003139.43606-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25402 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 F3E2BBD1F1 for ; Wed, 10 Dec 2025 00:32:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A867361440; Wed, 10 Dec 2025 01:32:14 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="WMbYbEJ6"; dkim-atps=neutral Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 184476141A for ; Wed, 10 Dec 2025 01:32:13 +0100 (CET) Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-341988c720aso4842138a91.3 for ; Tue, 09 Dec 2025 16:32:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326731; x=1765931531; 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=WMbYbEJ6ziZVeDaRVesFzgf6OMiW4hALKFxPB2bMg/tioNfS4GRSjFUH1JxF58tTn+ 8yen5uRnPYH3sIRiCQx3XX1AY3tjS5hObuaHvaPelSDOxpaCblSwojEGjD16A4bQMR0a br8UON0vzVTtrK6H0QK+/BHgOBfeuvPpAdGLeMr9TbfbOJu3pN875eG4Kzj+3QqAGI5/ +rUCPvW+pyQW6wr4rEq1TYhjfS1F0eW6de2y/T4qXQdkpo7nHLeYmHMPv4L9d1UcYiBE LQn5U4yFhbtYEspJKfXf0j5YBUrzCIVpVGc/827gwvWEPTtxmRFTfwRaDsr/e3UTikz/ i/Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326731; x=1765931531; 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=fVA41FYJTpJ297Yi31kUughJuG/XhRwPfn8H1jdMKbqHZhiRQjUPykqQiqaPi3DnIM snHfhBqPTGPkz7qfa4W4W0XyMDX6Uy9YKoXRjhFwr5w9KJoPUlhWt1VRgdq6mDy0P7ry 6lB1NLbMsQ/4YigSTZEEfGmiDywiyFU2eyQ6a4T06DuD44gLTMHLfTa/eD8zBm/AHSVk e+6Kqy/+2sFcfAjxJlTsLA5hbBfkOEFQGsCWgZxfSo6vOjxvLf4OT6FGHrH76i6Kcu/N zMzntKxKZWAlrBTNWmfJXbEm2Ijt/8DBwkBhy/h8KlXVdLCEsrmyTESuOHhmTru970yA o5Og== X-Gm-Message-State: AOJu0YzW/jiGfRpV0/Vdh0xzu+TK3E+1welFGWS+kpiehlA4W4FkFa3p ujtP0xmyUNHSbWRYpWKI47kdBa/s8sqrJon2QJSiEjm0vrEqh+n0z0la9Xxkk7LpKTydHs3piOY 020Qe X-Gm-Gg: AY/fxX6MmMkwl8ExS8Aj/lWT+e83IiBCLXzhByBGfdrvUBwgrFlvi/SGVvZmWmFj6qF uvXmnv5qR1Vl6BdhEb8O9Ud18nFfLO/GqpjPtG7DRYKGxR+NzLUHZZyceZuleyEmKJrBbIGZSym B4DkvYegf9XHMi0pQXs8pzUInRF4O10gyQG3gqAKGtoCpuUkLiFII6b5dsNInQRIAI3Hj/PlAwI qwzhyUBftKLy9QWRFqhZ2uKzC78Bah+KHGd+Aa4kaJYEhZfmKX45cqtaXon+1FoQcK3gG+g7T/S qF3Lt6ar0NUUIXX0fjTq3cbLJX66+X4QEkcxCYmLqjGOI/bgqW5Js+293LgB22g9jXy4ALvj6Sj ok6JtnKCEzgwGrxZanntYW6WiF8drb6M1tXw/wXZ6Ax5yH0lKzNBEWfK96Yew/4GSTTRKXuo2uE wi6kQIrunpBhqTh6nnLx/U9shPdNKheecbD2iF1aTNrxPbEXRlFNMqwuitrSR0pD7v X-Google-Smtp-Source: AGHT+IG0hfOt6xVZC9SlZEyVpyddh/1LH9L1mSMflHSWFxM91tBb5GRac+E0sr/a7p68Kg+86jQemQ== X-Received: by 2002:a17:90a:ec8b:b0:340:e529:5572 with SMTP id 98e67ed59e1d1-34a727baf4amr519871a91.8.1765326731262; Tue, 09 Dec 2025 16:32:11 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:10 -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 v4 06/20] libcamera: swstats_cpu: Move header to libcamera/internal/software_isp Date: Wed, 10 Dec 2025 00:31:23 +0000 Message-ID: <20251210003139.43606-7-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25403 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 94DD8BD1F1 for ; Wed, 10 Dec 2025 00:32:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5927A6143D; Wed, 10 Dec 2025 01:32:17 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="dxfwUT5K"; dkim-atps=neutral Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 416E26142A for ; Wed, 10 Dec 2025 01:32:16 +0100 (CET) Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-343806688c5so5084700a91.0 for ; Tue, 09 Dec 2025 16:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326735; x=1765931535; 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=dxfwUT5KvYlG/X6LGId5XPhHakZztExv9yPfOGKM50lxYtZTLsPaiOqITWX46ESk1f lDpu/NquLvWWZF1ZXBItqU1xok/10CEmkqMoJ/E4K9vOKXfZfQWNncPizBbkeNLHMjj+ 3dPUVhCf9/FAQ+GhsytPCoUgvw4ivmBODF1VRZqaVeyFCqiqcqYLMeFNAvQeJW706Dn6 nNsyxju5eZsmJ1tW7DCLN52rYwN9e67zNIa9oETthHQVVdW/HGaAQFOaTehNGSzGwi7a gYVZ+a60ckKaSmIsqa4lbJLFlsmYvakgjQ1G+ZEiGUuCIMg7C3BVyFhgRovyt08uCFGx dSKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326735; x=1765931535; 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=qpevKxPUxxlDrY0RUqg5k5RE/EydPmehPC91jOZeIIrHBpkpj6DQKsljjF1FXbWOIw DaxRKtZkAJX1tnqcUKm8KIIfbvQvLe/RDPRBC6zSabEAuct8CI81Om8KezEnZUhDDamy 40MxMXFTs8yDGnaiuRX1UnQQpeDrZr8DYdzHxpSbJ27HuROZcfeZVBEHsaVZQxmc+VGn MRNXh0xkomPKMGMXb/WuKgtDd4h3mJbC+t494CKaff1OKnTAtmsIsh0sAh/qoNQZkmwA +WoL4L4K0MQexgmrehdditCW/wRfuVwKmFUPYVFH/Tisufa0ToRnE51+iwSZMOySB7I1 xYDw== X-Gm-Message-State: AOJu0YxX09wZnTOcSaKMg08vTvNLfdVFZstfQzUSikgV8zw12RuJ+o/T +wYF9xqXC0nfI2Wi/F8/8qk+WFDIlEEAKtlhGfGsaUTmrNJT4W053qtrHreQB9EzfNXt/JqjgrO 6ssGW X-Gm-Gg: AY/fxX72o6dVQxNdpYiHHy2EoRTVeuksDCgwQ7ybhHAhoRudVN3nIYvHdg7kkcpMcXv wv4A2tj8652lZC4WFLz7l+r160t9B4Gl2warY1kPQN1kdVWd48sOxweslE0Y3NZTHWwE7jbIpuy ITR4y6YeJFABtVmrY23AzCMrhpY1wr00UGhyGDzMwShRJ/YyBiv/9QiBZ8t6dZ9KiW2UEDI2Peo d2P7/zYVr/xw8q33IMHyOTwLzH4DmgF+V77yNTQ2Y74WdIcq7wq1Efm8ob/t9Gktnm4gMd0Rlog Jj92UjTeEvA+mxfunYC8zt2BEDr7OdgwkIdf9OFrcVrmxw+TyQHHUyF9rVHaTJDHM4F+JTFW0Qc ZajDjPP/vHRtCSMTb4zY0T8HBucPyUFXVnBAxwPwD0sb37QlGgQfje9l3mYsBa5+6UT0EKXpt15 qY5QoXp1s4xE2cBX7Uth6Uxcdr1HKK8L1tYFiK4nIkuFpeQjGUXYoXMKktnKO7V+Hb X-Google-Smtp-Source: AGHT+IF+AI42JB2cf4l/k1dHq4hmvztuZKHFOEdpUey0UO1JIkYsx7aE9VfSSCJkz2qnTRWbGKsbkQ== X-Received: by 2002:a17:90b:584f:b0:340:f40c:169c with SMTP id 98e67ed59e1d1-34a72887e16mr429095a91.32.1765326734497; Tue, 09 Dec 2025 16:32:14 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:13 -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 v4 07/20] libcamera: software_isp: Move benchmark code to its own class Date: Wed, 10 Dec 2025 00:31:24 +0000 Message-ID: <20251210003139.43606-8-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25404 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 34903BD1F1 for ; Wed, 10 Dec 2025 00:32:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DEB796143D; Wed, 10 Dec 2025 01:32:20 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="zf1yMxU7"; dkim-atps=neutral Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E38C06142A for ; Wed, 10 Dec 2025 01:32:18 +0100 (CET) Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-343514c7854so180144a91.1 for ; Tue, 09 Dec 2025 16:32:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326737; x=1765931537; 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=zf1yMxU7HGX+0U2oxQM3zFrMb98Ap9UciDan+a/Jv7/Y5XXm/EWPm4x1+YKkTUB19X 93/2KEPeyatYG4tIRK7BUtIuktTO1DuzSqnWRtsNKJknK+pduADGnCIfWXsPhVBCtNzO BIImsLPqM3cwJh4LXIcgP2cMXEAfHWFFjsa5Qi0DwkftjGh2RbNVWj1g57cVFtdKo2Cc /f5Xc9IYKoZJgaFfEa5N1uMzq2wA/e8yodCpW07DoChVc4K4JTPDrF7Ui5JqemlPNTlB nrMeFV0CiHmrd3Jf10L8om/kEZYk62OugD5ySy3/PjycSvF7EGk5FU0DTT8wQlUS1MPK OtiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326737; x=1765931537; 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=UQAJpsvb/buFRrXW8aO11p+6mwLCpowZQdL/c8EkhL5NWAf0tnXBoClO3pib+mVQDb qz9KtaxukTLqWHbJqCKng9NNDHEUNIFwZ+plVHO36DYhofR3I6NagGAQRhmJAzd6lcFo YwnTD108Ww0ec5ZEGdZj4+/2PDmpLFhp/wzBudVQ+hsVDSUWIMfZ158iuO94OptwwFrR hDd/EKrijnIYZQAaU8N9PNPFHgT5h7ylc7oD1eK3xJDZp722w+fJaThwVMwLLupeQbEU CmVvvk8lW7MGjlvqge7OJxf8jQCaA/QQbjbfwffvqZD1meCyQ9OjnNt7qUadYVeLKkDH ElMA== X-Gm-Message-State: AOJu0YxGfqx00EducNmbUGK8UAjSLkLJj4o6fU+3q7GgoxdxpZZ2jZWx FtQ/g0zEY6iHhWL0NRwooa6kfNczIKVyOgkf80nSi230vwPwPtq3Ctc2qbQC51hlAoMtJ5GWsyz blHWV X-Gm-Gg: AY/fxX5iJSZxsGqpa1zq1OjYPcjh4otVcPKR9f8pS6vni0Nz8basKSgEWXVptgNNmxs o+7twyX3OVQv4Yjv6Tzmlz4xiNobnnjClaEgGfO6mhSHinbmPw+41dDASoOLURD8mjKcMH6EDJA OJJ9RIPozzAcpZh/OSfow5k14ZrMgaOCA7IyQPXCVohwRTQCvBnIv+1bFuiZ1HLkGKrKBeqk3+g UQh8BD9zg0Aqko8JDwcZ8OrNJNFrhdjG1nXyzuuUGvNqkzs8U7/87HVDrfMGoZuPrRGzdvELqJW gtuKrIIADyHZRr+6lKD3HFPPy4BxGYtXWXsL52DJBmqOdELaKgAasynlDa52vhd9Zuurs3pfGN2 FpGHxoG/EbRt4KP/9iqIUrRBejZxqMiBsHReEHTtZ03dfsBYc7C9cXhFJyqjeOUNLPtTOcnaFZr xQsMP8ucUBGrhsLW0posqs4uD1Vs3IMym30fRzsQNE7a/lpHb5hZZ2IECEs0B8G7bB X-Google-Smtp-Source: AGHT+IFKNZiqjjyeqToULgHNenvAI23o6yXjUG+lj6msTTZFOxDQUZjBLP6WLO//3/y62mcxx1ouzg== X-Received: by 2002:a17:90b:1645:b0:343:e692:f8d7 with SMTP id 98e67ed59e1d1-34a728d5782mr521146a91.11.1765326737174; Tue, 09 Dec 2025 16:32:17 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:16 -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 v4 08/20] libcamera: swstats_cpu: Add processFrame() method Date: Wed, 10 Dec 2025 00:31:25 +0000 Message-ID: <20251210003139.43606-9-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31:26 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: 25405 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 C91BCBD1F1 for ; Wed, 10 Dec 2025 00:32:23 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8691D61449; Wed, 10 Dec 2025 01:32:23 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Fokd8gJp"; dkim-atps=neutral Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C59F161431 for ; Wed, 10 Dec 2025 01:32:21 +0100 (CET) Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-3437af8444cso5652153a91.2 for ; Tue, 09 Dec 2025 16:32:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326740; x=1765931540; 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=Fokd8gJpYvQr3TU0Wd66kUYqus3CqOO+txm71xynUirGMXDkaXk1W7+y0dcNQ+AX1/ PxzJV1VxDPDOs6Rz8gRr/P8oh4d3nbdG0wRO5pXSocYyJMAfrkQ+PhBNzMHK/Xv52SWV nk5XYVp4ndiSKnSAenA42/u80UVaGxHK3D+MrAGcffdTLGMJf/LulnLMRwVYAyNnc730 s3M5xZpmtHVODDpvenjwVVrozZjlxyAYnnW5tGhWZSWuWJM79Zznh5U64ObywDFXZguk qOzctj1OJbTQqdJMb8piKWu9weU1s9qn7SD17fnsMDrUy4ZN9ZiRjf8nD9sXtv7l+7q+ 7frg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326740; x=1765931540; 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=BsD6OvSNwLCbBrauyyXJ1DfLg9ueh7JSwQnZbor+5XeGxpzDwmdZ2RAIs8UiPdcCol SHlrQEAYCA32SJd/++M4TqK3p/tMsfR85QwdC/VXYR8NO997dC1AvWPemMDhYbfWANCe 8rSfl/XIR2RKUWMtJWQhmUdNO26CagIwAGGO9nBprZso1z3hLk0UX8K54bMArRjmUITg xNrnV9BE0z0x5Oq3WPzGsGMdHow3ghHyGrza8Nw/refKQX88qpJdvp+ZY7ZeucsjOAlE EbYnh1h4kIDiVBnGtWeOdCOVn0aIbO602BhWkPYvuMB9iNQOi+Qc5yqdoGAYiU8EtJAk /dEw== X-Gm-Message-State: AOJu0YxsfjTvKVK7m3xn4rNtUyryfZPk048i0D7WGV0zLpwNE3oDEIYT 1D0+i8cAJhPrDXwJJvON0tqLqB5UA8/M/XmLhcwEmsZYAqPqGfivOecj7dkNI6qOvnoaWwMwPsy 1nEjW X-Gm-Gg: AY/fxX4hobuijqWylieC1RdWybNP1XpAFdz92LC/opQtX4NUN8mlFb6ij071XzfPMWv qxjn/KLykHudkG1LCLRqQQBiGgxOowkYTOoRcwTNe5VwUwW8HgMs/TY9VQcYOO7/fl/N4w86d9x n2IfzxlRpr63821WCxO1HfWGXYZwenGPUyy2lpw6FYiW5SLp6j/Jbusom6l8SNFmDmE4uLOMTeq iE+cT47GW9AeAp4r8J0DR9MZzRB/48x3u4tZm6GwSwEQr2RJo6J+9v/YoaN72H/yapbMlX86zTS j2xOx2wKONnWL0vWhANEZYRMTOg6Sy9TThB8UzPftic5BBwH+rrf5ZjBPWaGj9FAwN5UOXwSLCf 8CPiaQIq1gAvVGuXxNnQpIyy7NMSom9MQ1qcGLCP5utg3Mh6qrsyc0WP34L18/GxeY0O1j2xXkM XW/Bo0sRbB8m51ml0mwFibmivmBMMMl/UO0wo+bxqOFsa9UHTq/NIRee6y7qnGkJQY X-Google-Smtp-Source: AGHT+IHFSqHo3G6LfFmF5pBWolbgfn3289sJKSlcTdun/KmTG0R0kJlhyVme83RQk05OAf4rOLd7Jw== X-Received: by 2002:a17:90a:d44d:b0:341:8ca8:ae64 with SMTP id 98e67ed59e1d1-34a7289e773mr495612a91.35.1765326739967; Tue, 09 Dec 2025 16:32:19 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:19 -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 v4 09/20] libcamera: software_isp: Move useful items from DebayerCpu to Debayer base class Date: Wed, 10 Dec 2025 00:31:26 +0000 Message-ID: <20251210003139.43606-10-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31: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: 25406 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 92226BD1F1 for ; Wed, 10 Dec 2025 00:32:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3A82461440; Wed, 10 Dec 2025 01:32:27 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="i8WWyzvv"; dkim-atps=neutral Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8961361440 for ; Wed, 10 Dec 2025 01:32:24 +0100 (CET) Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-34a4078f669so1884839a91.1 for ; Tue, 09 Dec 2025 16:32:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326743; x=1765931543; 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=i8WWyzvvopEgmPr21fKyyJ5jkEirQbW5u2FLYibu60XJ4OXhsXdpl+CkFcx0K0CvWi sa90f7aLnuG46tcURQyuw8ZEMZwgc7clH+W4iMt1zse0Vo9v3Tl3Pq3m8XnEK4jEZK1m zefJuCfS72BrCKbbs3WH8X5xZFvo40csENNtexFDQWWsfHgjuh3yKD6hfEtIAdlblzGQ nc/ciwTC6Gp5pPUmYkOLO3E7agD4NSKJXHHuvF5RStHtBOuY7wGXPYo4Fab/EG8Ba8jE epqNL9UgxM9yskkv+e6SpxjM77Ot0PBHldFTQuIAwDPY8Bt8VZsNrsdl8GFHoHk1DRey WBNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326743; x=1765931543; 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=Q9Slq77U9dY10w/BD+oeB0qo8VncvaUY9uiPBQyz/orhhr7b1+hvpcq9OlOL++v76f hNMYEddkJfGD4GIGs3F8770GEnd/7tXAPCaNlWrRi9JOyPceC6oBcXerlcIrMTs+/t08 qWFLQ7QZ1YMu3fzeqT8T377/KmWItEI/bLBf27MGWrRi2xNcYVRn6LNFIXQFaS8ywzto ajV3RzSSDj3hJ4a0bnnlqoDWp/YizKz3OrIPX3DF2ekeLyt1vIpsX0xHyrEuVX7ubF3f dlYjLg+NntavjynBmIgNnOva9TzPH/OJ0RI06vRMVHeoAxIfL7YSDqZLQjD7DPGtggkv ZwlQ== X-Gm-Message-State: AOJu0YxYeqlSR4K7O1LQMTbXpXdMndtRDCIlSOjreQem0OOBMy4kx6/i l/brqK/saQEOB67pbktQrtU9M0wEZ0rpegnn4S8tL8ODUGp4ToAhnlKdKN+gMiU4j5yg4XqG//a t3CmW X-Gm-Gg: AY/fxX5d+DeUn5Xyj9MpiA1ZSpADihFXGdfQdMVemR1g0+GLS5PkDtbbcuhwrwgEQfU HnO7FTbWUbxhcjmaHJK3ff8l3lGxM6ebBGcpJDhuNtwxeSXQijFPqNCEP+7XWs6y6S2ngCreGm8 AXS+lUc7YOzUesh5HSkRY/t3Cx4bjrMLPe0/FXTwmp/ZxY5rtB4atGP5pxv+EMtaHLC+OEWrUOt xLladF2I+0ICylgQIKpF4VK40COjOh5Qn+W6ptBpaVacH+u+/YrCikKxmJz/+MT0Q6pdw7Nx41n sKei53Cl1rwrY4xXN/i5ASHF1TJg0Zduf6p6uj+uqMCxf6URo/C/SR2p+rZbn7TwJtzUrSlQyMj Bnd5mXwFjlH+mVCknb2UJQ5pY+XpdJgoQDYDtpBVxRtfiT/MJeX1BNrpBlb0gAdDUA/x1o4G6Xe yUBm3kGlz+D1Ov9iCa/B0HYcChvnMO6UevpiF7VUPamlQSW66ygvDI8v4usPiPVNZBdnejx52a+ ps= X-Google-Smtp-Source: AGHT+IFVa4xUbYp1E2+SS8o4xvaEu3X8wDTAtQMN4cpw6Z8awnzTFunJQvgS4EULItKO0tbiWFkL+w== X-Received: by 2002:a17:90b:1d02:b0:343:6108:1706 with SMTP id 98e67ed59e1d1-34a728c6d92mr511419a91.17.1765326742745; Tue, 09 Dec 2025 16:32:22 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:22 -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 v4 10/20] libcamera: software_isp: Move Bayer params init from DebayerCpu to Debayer Date: Wed, 10 Dec 2025 00:31:27 +0000 Message-ID: <20251210003139.43606-11-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31: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: 25407 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 180ECBD1F1 for ; Wed, 10 Dec 2025 00:32:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CE70461450; Wed, 10 Dec 2025 01:32:28 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="OtZ7+GoK"; dkim-atps=neutral Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F0D5F61450 for ; Wed, 10 Dec 2025 01:32:26 +0100 (CET) Received: by mail-pj1-x1030.google.com with SMTP id 98e67ed59e1d1-340ba29d518so4100522a91.3 for ; Tue, 09 Dec 2025 16:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326745; x=1765931545; 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=OtZ7+GoKJJTucO12XIPWPjnOhnwfac8xglOW9lsY7ebj49RvV82+0fLXgDp86R24kx yQKR3r+7pmSNZv9oAuAAFb4s0Ek0kCKIloSV7G63gWME4txgR6Nq5PeiU191yCT4lpsL 9KR2rGjGyqpz9cfdS8xOG4uSDQvkhH1iFMGwYvIKPQY7WQcjtgM91kFZuLAoH9MX1Wdj 2F6konzv1Us80bhIp3pruhUSb5Ai0akWFqaJDXwqqE1yHgyErhwOsV5xVn6G4/FdL5+a NI3B0tgpWqlwYzupNuf4jzMomQXxtPexXIYrTMVjRVQ0mJquIi/OD1J2CD8J3SUJOjU+ aPLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326745; x=1765931545; 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=pTNozqNvZ5brEbhHg6Ztzwb7Qwi2ulHJtagt6+3OxafYAth03Z+duQT4+sCT7xKb/U 6DIffqsk/vctrWNKcDqMGnZxnC3NTM1p8AsNNBLa5LdS+F537XXLkfm91fTCzK/PZjv6 9bGdt7UXwUeTTrSOG6EYGCgkiMbtavwJpjpuGba8wesHwY4WoFxSId6LQvcJS2cqPWR+ I8+xu0+3re4ILpmwuxObgL+Rc0EMjOIlaDKvGAlxUA7Uuk1YEPYP8LcVGNfHPlEr0n6z RAnIwh0w6GKCHjdIWHBib44bzyr062kjOXLnirKclkMIjrnkmYVvt+/OIFJz33eOvDKN 3zYA== X-Gm-Message-State: AOJu0YyYTsEUHsZI4SQoo1GorJn0vpJVGQA1r/9l91ssPd8FOvTihM1Q D92fpJrVvLLiLHCqzclKypRp9iJQfSJibA4u0nkzoXrxdmg3i5RN1RcPJhi3yEwgWDv9prQw60s wjcPF X-Gm-Gg: AY/fxX7WxELnKLvsyzf/HdaaxkWRMGgjMFSM1/wgZ4RazdXdyPBCurB1ezGpJ/ZPOsN Hhd6boV3SBycQ/2iSI3BpoYOUXS5DPsUnqq/ikhUvXGdvhA+CLxXENE07HwMtIefREEzefdWkmU kgBD/thSkdFqEFxu+ueWRz9oLsQOl+0ETYuAhuTdrT/CWeIkxQ1otnuSx2tbJCi6MtJNOh4S8PP gNA8gGYjVgLQDLCWxNOIq7Ja4uASruj0xl2bZS8GWnkPb7s2DdgzWCuwK9to6eFH1A7vmGsKHky sr0ef4Xf3aVTMj6QUWyt7FocFApocdhE2E0sMbAcje0PrvURvl0ZytsAUuJ+SaLo2yXZDltHFDc RvfO8Tsbrl6mTt5ZaF8MhdFyjEumuKDAFP2bSFVDj9mVcrLzdUUNkKqQ4F1BnVgMw31G7fwdwjx PEuQOeizAPwAJiyJufwMzs5IUfpDtdqsMfx4Q0ii+AeBUt2U9PZJxclztZkYfJ/5vPbVk0MjplE qg= X-Google-Smtp-Source: AGHT+IEcbSoPTewzFYSYS2yxh+MQ7so0+W1Mg/l1AndVOaKsI4MoMrOEIneRPupbHpQ/yd6rub6oxg== X-Received: by 2002:a17:90b:2d4d:b0:349:3fe6:ab8b with SMTP id 98e67ed59e1d1-34a7289e99amr440696a91.36.1765326745140; Tue, 09 Dec 2025 16:32:25 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:24 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Kieran Bingham , Milan Zamazal Subject: [PATCH v4 11/20] libcamera: software_isp: Move param select code to Debayer base class Date: Wed, 10 Dec 2025 00:31:28 +0000 Message-ID: <20251210003139.43606-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31: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: 25408 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 D6B8EBD1F1 for ; Wed, 10 Dec 2025 00:32:30 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8C3C361459; Wed, 10 Dec 2025 01:32:30 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="rXhmr9tf"; dkim-atps=neutral Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 405BE61463 for ; Wed, 10 Dec 2025 01:32:29 +0100 (CET) Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-349bb6f9c86so4125317a91.0 for ; Tue, 09 Dec 2025 16:32:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326748; x=1765931548; 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=rXhmr9tf8E/pSsHfJ3Id7S0EGWWtp4txxgBQIRy6o/h1wBIQXI0KNeQ5Txlzz/Muc/ NtvtBG50fYFqjuh0aItONmtry6hSRHXHJCw5cp5JIqadfB39Xl6+CjNkmOD16wtC0v4y zaui12ymTdWJDrFvMVF95+/A+uqaSE77ULhg1MTXWosILIXGbngGfRoZbADAecpZYb+T niKyEeMwkHboo4dgMP2732LJonNyWBrHDR4zvMfD8A9fWUvgeXRQeK6yOL+TfmkHOEZs /+JTI+Hc6OtzMv53gDfHk8XPkWHNXY1V+De3oSdbEIamL8Lr8KYWqjINDVVGDa63SBhF +neQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326748; x=1765931548; 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=HQ7bpjahrR1Qlypa3wC6R2SeW0S6u1KO9DOjkeOREYWIngK9X6QjprGzLdTbOrRacu 2Nve1AcmnjzCJYw0qC/LIkhnzUeVIfDJP//m+RJMAbxWt6ZH8CGE4jlIbH97ehNYIsF1 6ryhh0+Q2n1datwvHSrrYBGDC0jwChPXMW+jJG0gMtlQ5XppD/nc4naLetxKyWR9lqsD lPLJGc19ym9dvlqHFQx10+YmtTVZ3bpOkf/NHLdfmvyB0CJrkC6PawZOHRK6hA1KdRvr krfHomUNR4y5iw3ovw/2GcUMfAa3rF4s82EPKCVDMnHNtmOa7gy3BLQ2zxYy7OD8HKjl pnHg== X-Gm-Message-State: AOJu0Yyq7rTPM6tUiWWD5sXGaU5sF9SjvGymXtdNpGzp4YUvUMiUh1bv yTBc6cFYvZ6+I38ItBNWfEcYghdh9SQLVxi2xrIaAKUizuI5i8ynlxoPXfSn6A1FgOq/1/DBNMs +IlRc X-Gm-Gg: AY/fxX7fjLAsFUpREhiIoqubR5/JC/ac9530JSYemgWE7HRocZXEcqns0DJ0twIE2Uf QmXRe88MkreQ6Jw3mhzHMBleD/AkSI3BZdYFVWCkWhjZ6hSiOpCQyVVYfTilTJHuai+kPbPvWkL y7P1pwpl878SPbqjqjJj9mDAuVW2lVKsV7t6pzEOR+G++85TrEkkoh4/krQVVQWYLp1g3o4YOfK 6gDRCcxJAEYMm2JwZsuWVBpbEbgV8xiDXXq49JIRBlU7KmzvTjcWcQCgx/46+aYEJoBFqvRV0zY Pmj4vYLPp2H5avNYbvwcDhyeS6I0yJDxUGU8OzX3xIvkUnV3MyCeP6qjQmZi5OmMTzWp2UuWgvf 64rEKmNupSit8XIf30YtbvFnGcBoAWgP+ndNBCbhIe6LdRlgw7S2P6qgAaV762rE3bNrX9z9QXK qsr4Jc49ocdsdP/2MttASRcHqFWf8FcF7gYhwRh/EQdPLbVczQM818S3kLtORCihy7 X-Google-Smtp-Source: AGHT+IFBSZuem/9P6oNQJf4PI2elXEXmtwkEiTH8ZciZrQ6B2JM+JcIMw4ldJGcOf7/DgKktLs2ytQ== X-Received: by 2002:a17:90b:3d06:b0:33b:ba55:f5eb with SMTP id 98e67ed59e1d1-34a727ee9eamr540281a91.1.1765326747648; Tue, 09 Dec 2025 16:32:27 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:27 -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 v4 12/20] libcamera: software_isp: Move DMA Sync code to Debayer base class Date: Wed, 10 Dec 2025 00:31:29 +0000 Message-ID: <20251210003139.43606-13-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31: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: 25409 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 8F5B2BD1F1 for ; Wed, 10 Dec 2025 00:32:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 58B5761440; Wed, 10 Dec 2025 01:32:34 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="fcrmwljK"; 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 106B161440 for ; Wed, 10 Dec 2025 01:32:32 +0100 (CET) Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-7bb710d1d1dso9835503b3a.1 for ; Tue, 09 Dec 2025 16:32:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326750; x=1765931550; 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=fcrmwljKvbPc07hCSe8GLT4xGUkRLzP9o3dvlVAlwlJBACgl7M3xgruKt5C7h3wkci MAqI6go69+RpiFgLA8yC0Bzt+dSoT1YrA36W7z9Qx0nfWgeq2Yvn9vyyfQF36DoYhB6p zXllZDu1T1nFEc62dtWm61OER9Vhp3NYX91nZNuan5mKVEiMnT33rp4UX1SpZ3AZsfLm Xj+UV8Yc4/MqgMB/6oPoORQr5hgo5POSg8yQ3izEBg1eriKZiN2QFYiF1uchkewugr65 F9RZJDv/I34S3yb7k5iwIniblLN5dYJ8/cNNGK2suVKeTOlgEhumEEjms7f0Y0NoW+FP /JrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326750; x=1765931550; 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=WLMG6oqYwHOQabU0yYZFsRKoHLxm/2zDG0+Q1NinwwPtByKGaPcKdSjhDWhpbHWq/i Jx1CZeKpOi+dAs8K4eZQ9nraHN7Yz4Gha3tIhCZf/1tYpJtKXicJbRxImGsSlhNKGXQy wqEt6voIHPqrg1lMfk23NpgFyyhOI6QVBQNNoCKJH/LMCBvaYo0p5YwkLJENcyeDxEy7 +ZIAe6clrk7JMlHopSGuOqMQZMrSDuS6WonKIcnhYnDNA7M+uNO00CigkilMJoNpRpy0 31k2uKOtYadHJbrLxa6xrNxwRT0TDeZHoO1cpV6N0tT65t3+XvArIchRv6/9BVpvk1ll /TJg== X-Gm-Message-State: AOJu0Ywn51iKb5dMF4PjDlUGsUt5GsK8ts136YpEFfUMfG0t4JZNOw4j QU59FIpuiebVQZVemHesnhKhC/5w3k/n92f3HPO0/0OD63YFdVtifu8Jn3IdBtSgRWJH0JWyaka RlS+6 X-Gm-Gg: ASbGnctnC6D7Ih385u18Pd1I9ag7HmYpS82itUxr3KGDAnr9jzLgLKDHXL/WbKX6j/n ZcT9F6uxkZM5R1ohYWfWJBw7+L1nN/Yw0n4gF5BC/OWRRlhtX3iBR6rBg6jJPkC4FzR34L/zdyK r3EaZgIho3wnTXbEQ4NmoZLpV4GQyysGnVxOwiyUP/cA4l9ZjbJlGyY5v67zLaw0yVRAByzIYXs CFmB2Auuzz1dG66Jm3L003RkouehZcBlCegLJ0DDFmRwynAfqmP0Pm56Pxz9Ys9uxau00F4pkf6 A9CqQzPvSzfaaDz+0pNph0hi0P9jAf/gLW9I9wYmmHgrW45CxXondv/wXzGuhjWRRDhTDtJ1GQy Id2X449sjrucyrCcIf8avAO8HD80WJHi+k/NQ9qveE32sUw0pndnLEFgSUGa6vnk1+uJJVAPk8p 5h2BCkx7sm1wX8wnNjaFQcN7IgQkXajXYoDcTi5muWTlk7AxK+2T7oxGj5qLg8rJAB X-Google-Smtp-Source: AGHT+IGKx1qi/wEHeP1G1K/SbzYebMbCKQ9EOziGrQDB7xHsypg8TkCpybXOeoh1cG+Q2qqti7/UTA== X-Received: by 2002:a05:6a20:12c1:b0:34e:7bef:e820 with SMTP id adf61e73a8af0-366e28890f5mr499598637.41.1765326750358; Tue, 09 Dec 2025 16:32:30 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:29 -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 v4 13/20] libcamera: software_isp: Make output DMA sync contingent Date: Wed, 10 Dec 2025 00:31:30 +0000 Message-ID: <20251210003139.43606-14-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31: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: 25410 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 311FBBD1F1 for ; Wed, 10 Dec 2025 00:32:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D7A3D61461; Wed, 10 Dec 2025 01:32:35 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="A1zVkhnm"; dkim-atps=neutral Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7597961450 for ; Wed, 10 Dec 2025 01:32:34 +0100 (CET) Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-34381ec9197so5394920a91.1 for ; Tue, 09 Dec 2025 16:32:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326753; x=1765931553; 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=A1zVkhnmQ2Gr4sOBJPvWyhwR+HwP48pCrocImppfIHqbKWwilXdbtW4cVc7mqOua8R cQw7toevKdyBQisZsrGX2zXevMZJQT9xdC+0Y/wxu3Eh5lYFm6yF4Z2UgyfdNiwhVXgT KEd+ZNQq3OcWdBEItqpY/HlYZzvVbEB+lZfx6hVaGuSVRwnEjVbKwcecZnNcvgKbxWEl NcN4M2wmZhiFVtSNOsBjoKAuKLAvq8PycLflrZF0keNvLXqZ1yPcoRG8JfZlJB02KuI5 WXiAL7RBQYZzaMbHIVhfPJK/9QB/kWhhmN10V0fNfStBS15omRUI4CDQNHKsGY6kIunI 1ozg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326753; x=1765931553; 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=wRFNllz6Aue0uPcTTo69G57nS6SYDd4M5ayv6/6OfGEyylrIbEWJHEWkXSt/vOyYg+ lJHjzaocpTnuVQ+EUJdTKTB7303Nvw3l1VuF85HTClXPANvhsx3XTU2zBTQN0uYLwF6q 2Xt1tMAGzm30YEG2f4TOcS9Rc111IorVZ5MxnWXBK5rSQ5ZQxStxm65iK96aNX/Kv50U UPOeUzfhINsnudR9/MAcEEZFE6gUca0v1ufrhgOtJuu3vPPuZ6In8ZliAUirFONL/dQy LZCs+PYfTEFXsu+4ZMims5eWP0uFE7qQ9mVzmcJ5+ZFIZSk/B7ScNfab4FQsGzgxgsoq ichA== X-Gm-Message-State: AOJu0YxVPRfc44/aZB7Sh3wjE/drcP4kH2zK7Qr8frH3RaPrjMGAmlEN NaxGYqy8BXnejuuzpSNpoxMSW2Z1iZ7VOnGu45CdOtkKXk7zG/6LJ1ax4fiUam9ihAwf0GM3l7S +3bxP X-Gm-Gg: AY/fxX7W8PfdO8ZGZ8cVbePt/YvWxJfeVjXMrQh/F48lMuQazpxOINxB3j/zaS26v8m YerTXWWopj36gA/nBRZwyyPf3pK9OGeDzsMzAkkZORnl+Qze/QibAlxwTYIi/r34Avm4vIdjVMW wQIbrWZlhKR0vtS8hC7hB3mJy7h9n6kmMgAszlD91GHzujaIJOuF7yofEe7PNiFttJJpEpa6nXP tSIVFd+GWqMeWVFGSxiOCoUPbO6XX2zzAnGlJxWEPdGAfl2cbdg/FAfys0UyW/L/+i/J1DM3WBE 7VqeOMNbj79zqNzmHrMj7kgxACjsRKyFNqkouNL/lAVx9JTuhl+CPlG2+T7UaqeQZ9zZSsnYxVi z/bdPvpL5s9NrcoxfkOh4muluT0inaVdsC7uGuy0vL1dpz64WdNSdTLJW9n3YMvO92FufMYAIBT GdAiGzQw/mGXB2aVZr0PQHgIErIKuJ5Z5d0EvrrgC1+mI4tpbtq9T8NCJSmuhZh16NFh5PNCfZ8 2Q= X-Google-Smtp-Source: AGHT+IF1tFzK5Os+YFOI7Vcab+ZiSBCt58wtaoBjC9UBqh4MX63VyBGBudb9ZEOTtORZwRYELj2rjw== X-Received: by 2002:a17:90b:5823:b0:33f:ebc2:643 with SMTP id 98e67ed59e1d1-34a728a7f64mr514786a91.23.1765326752770; Tue, 09 Dec 2025 16:32:32 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:32 -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 v4 14/20] libcamera: software_isp: Move isStandardBayerOrder to base class Date: Wed, 10 Dec 2025 00:31:31 +0000 Message-ID: <20251210003139.43606-15-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31: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: 25411 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 A8AF4BD1F1 for ; Wed, 10 Dec 2025 00:32:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6D60C6145F; Wed, 10 Dec 2025 01:32:38 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="GtkkB4k2"; dkim-atps=neutral Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A4EAC6144C for ; Wed, 10 Dec 2025 01:32:36 +0100 (CET) Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-340c39ee02dso5040258a91.1 for ; Tue, 09 Dec 2025 16:32:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326755; x=1765931555; 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=5TmeYZw4sP3gvIeKkN5VVzOzrCwOWv0nwPHkPwkgQcc=; b=GtkkB4k2XrIibGZjyHh5iRGjJpKBM4mcKTLM76K4voDJn5u7b6/2uyGw56YgeRE4QM 0ObXGeULJPP6dallunelZ1zrpt0bhKK5fPcoKu5ZSpgxFC8j5mZIWhXjsiaUwhXjMjpD c5w5TuPjih7Y3DODrwNON1y4o/9mLcWvA1yI/z89CPdifdgLaJP5CX8vg4LZtfUR5qPf FWM7mDKNgcpkz81a6FQJnvKMcNDt0WPTBu/SxtjJsqXQTaqgaGZHF2Cdxa0YhnwT2Uf0 HnsUDVNyyI1cHmxI+kvMSVidXTmUGwGcoiol9hANG0ogn8srex5czC4za0PkO837JTDc 1HlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326755; x=1765931555; 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=5TmeYZw4sP3gvIeKkN5VVzOzrCwOWv0nwPHkPwkgQcc=; b=Vfp5mBKUnScs/oljkK4MGqiC6KV7T/HIBuRROjoi469x/0E4Hjj5Gunj7cuvTLnMV+ OjAn4gNboK3ZV69l3WWBw2L6QdzCF+djziMEVU77tCtW34fVhBvQueL7Rbd9UcXUD1iD x9l1rV2kMM7qXSeaT8ezUK4XG+DOKezK1ZcByFoq12r3n3VKr2kVicHmYZXoRCqxv0VM 6KtvnHnrWAKDH/8N03WeHbPFH1V/EWjFCOYto1mVPtWHrvOoNL0DLLqCs3XQ/RrkHoaX w3ZhYpS8KpK2lFEXpkfcfZA5Ogk+Hme30ArL6cseSRDS0bMhEb5hDsFhgrFXI4hTlykd i83g== X-Gm-Message-State: AOJu0YwTijBtbEcQK3KVwQtftR5gpSwpOHD0CSGVrkDKlDhnhhPpabwf kGLaSp0by7IzNcgCYU2EFoUGBLbnDoKVSm4wHzQegJuCzSNtqsZt4+CgueG6gyEtQPo8Ze9cGie UHXxD X-Gm-Gg: AY/fxX7POt9dtwz62FSUMzTvkNpjbPO0UhbVuUryY7au+H7QN48x9eJi0Y615+EwiWw qKDUvTv+8dmZUXfBU4jYsXcAxNQXARTvskf+DUt/0JveEMKEi6DXVNkltxmM3riET9osKuRfSnr 3DBnCFbzNlZVnZJDPoT+qBCLINrxoY7RSxXH/PleruWAW7KcxjBU7jZ39ebH59snoUhVkHKeBnG BggAZLSy51qTAYcz1cGvh2Q9JXT6S9jbzmNLwnm6qHnbvIihnk/hms3fMwEOUzsMH2mEvEIDdft yBDOTRF5dkJZmctF/YZu9RyKg79hYh40uLURwKPclbP/ex00j183E1Z+5A/2pLimcKopq965pcB 0petyycCpOTplMo3+TMcjrCIlUub72zNv0owhPmR2+3ieDkCyX09swDjHwDjpQyKohpssMF7BcF IjAcLE1qIdFINyzdoXUDoCX8GRSC7OsFEpErW7haZ9LdltPDmS/lW48JhunUDMAR2F X-Google-Smtp-Source: AGHT+IF2YvXThUQpzYSn1BpTMUGc+R2eL3OazSbVEyE1Pe0wxk0g+GR1mLpLqYr+Cr/3QApxXqAPow== X-Received: by 2002:a17:90a:dfc6:b0:349:3fe8:e7df with SMTP id 98e67ed59e1d1-34a72874747mr501225a91.22.1765326754886; Tue, 09 Dec 2025 16:32:34 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:34 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue Subject: [PATCH v4 15/20] libcamera: software_isp: debayer: Introduce a start() / stop() methods to the debayer object Date: Wed, 10 Dec 2025 00:31:32 +0000 Message-ID: <20251210003139.43606-16-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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. In order to do this we need to extend 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. [bod: Made method blocking not queued per Robert's bugfixes] Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.cpp | 18 ++++++++++++++++++ src/libcamera/software_isp/debayer.h | 2 ++ src/libcamera/software_isp/software_isp.cpp | 8 ++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 1d135b278..32a2c8378 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -336,6 +336,24 @@ Debayer::~Debayer() * debayer processing. */ +/** + * \fn int Debayer::start() + * \brief Execute a start signal in the debayer object from workerthread context. + * + * In the DebayerCPU case this is an empty stub function but + * for the GPU case this does something useful. The stub here is to + * ensure the right version of the virtual gets called. + */ + +/** + * \fn void Debayer::stop() + * \brief Stop the debayering process and perform cleanup + * + * In the DebayerCPU case this is an empty stub function but + * for the GPU case this does something useful. The stub here is to + * ensure the right version of the virtual gets called. + */ + /** * \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 Wed Dec 10 00:31: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: 25412 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 3EEA8BD1F1 for ; Wed, 10 Dec 2025 00:32:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E80CC6145F; Wed, 10 Dec 2025 01:32:40 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="bZNGlaYe"; dkim-atps=neutral Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E61FB61450 for ; Wed, 10 Dec 2025 01:32:38 +0100 (CET) Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-343dfb673a8so6335009a91.0 for ; Tue, 09 Dec 2025 16:32:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326757; x=1765931557; 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=bZNGlaYe83XDuyn2+h6mDw40pa7r+jRwzZJgR+8ZQ4SOJDrsAugypfFn1FPImgcNGJ mw4ov1HeYHlxhVj9joxiGSiMvNrejQh6i8Jy88SYpBKgXiMfWqmGF771eIrd9BOVcEFf 7fvqX2/OILKeZ1qB6EGKoEiuVBXKMQF9s7BLp2sjr/MQIRPCNXmAzoR/16ZFir//lyW4 mGVbFxfniTkVv+98Cl1GnZqUodIbMQJ91AggaCaHL1Hu5IxY186+poqRst3Br4fsX+7+ fjK+BJzwfYH6a7L1v51jvCdwabynnDmH2ruxx2Yso2yC7TJCZbVIGe3Lub13Miy5XfVv uTbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326757; x=1765931557; 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=bIaVnnQ+MEaHzC5yUNRZb5yksnLzrB9TRmyyN9GMTfjoYiMQfnZ8PZcH64uBCWIQEr nG5hIL6vtiJGhEJoxFZOkzln6x1tyCuS+fxmX8eaS69pln6NQ4fVxyCAPl+i48w/pow3 qV/bypmRDSB+QZMSPc+T+9QezeNR/WkCiI+c0J27tu51EGQcQnvzdzURyRuIeBv2f2rk hWlPgBwjduht/zHIC/eDC6QZU9P4aLV/OKvxmIJM6zoVDBBJbrPZ6uTw+CQFkfBV/qQ5 IWfwKf+IW4TD4ByHnl6qyQiAXy3EwzGisM1ku0hHgNZMU0U+pK+9JhUZm5JkdzC8EhdQ PDIw== X-Gm-Message-State: AOJu0YxMSlYWyF9dQvvGb/BuIo7pJkLwm72ooczwXuEHyx/UEX1HybN3 Z/HxahA6o/m0BQ0Ximm1J4tWTynako/ax3wGK7MVfru0xHHTwDKN5zT5YIUuAYLeBidNHc+JWYB j9tRc X-Gm-Gg: AY/fxX42Hq4fYpw/P1Y5zA/mc6mAQb99MgSvtL27asasm4RTUd1Q+0olbNHdD84CnE3 K7JDjeeuomOtnyEGxVEs+SIJRhIQWKjW3PAcEmJT/zt6NFFWfOkz+cwVl2dBPbZU76QDkI5GQWS 3RhLnu+MqrjoSkrwgRqEn0+0wcVXaPEfhyKkMyJJ8ERe+Dvr41WlbpRWxgSV+8dorXPus7YFLxW 7sOgvYa9qnyH7QW52oKizTu6oVsKwmckq+ioYtLZgO5X1ZwzSlNVw1thlTrElXON3vnic2iAsra HWuf77H0DpYb7w7Mma2/3lf8SA/yIArzMxMk3DvL+S/SKQdY4jx2BOMaaw1O0Mhnn2t2yLOZFHW 07z32mRVZCI3fXwWEVBIvUM+lSJ0Kl4w3AZOLNz7F6OfD77Dk/hBdMdre+z5x6ObKoR3M2yxTcy tJfABxVa3Dfiggd66gHW72I/uXdUjeNjdUZFE+6Ql2KrRtQcSrdy8bUpyDC74Ap/to X-Google-Smtp-Source: AGHT+IF5FbmLerbJDwuDom+J2hLRXmYO6e2U51570nu+Ud3t5HAruhuaKAu3T84AIzb43Dnz2HSHlA== X-Received: by 2002:a17:90a:d44d:b0:341:8ca8:ae64 with SMTP id 98e67ed59e1d1-34a7289e773mr496227a91.35.1765326757254; Tue, 09 Dec 2025 16:32:37 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:36 -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 v4 16/20] libcamera: software_isp: debayer: Make the debayer_ object of type class Debayer not DebayerCpu Date: Wed, 10 Dec 2025 00:31:33 +0000 Message-ID: <20251210003139.43606-17-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 Wed Dec 10 00:31:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25413 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 DFBADBD1F1 for ; Wed, 10 Dec 2025 00:32:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9CDEF61471; Wed, 10 Dec 2025 01:32:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="tcJfGFsp"; dkim-atps=neutral Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 40D3360C8A for ; Wed, 10 Dec 2025 01:32:41 +0100 (CET) Received: by mail-pj1-x102f.google.com with SMTP id 98e67ed59e1d1-3438231df5fso7847703a91.2 for ; Tue, 09 Dec 2025 16:32:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326760; x=1765931560; 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=tX8SQUKwoSIuWZvIfVWFvgmrgrfM2uE6n18+JCpQbRw=; b=tcJfGFsp8Os5D2HaxxC4ss8TLcZLu0aCTYE8vZc2HyBux9ZrlStfZp0AGTqeC4He4W jUiVn3zMa7i0rT8MBs9TpiBa/yZgaeeVunJpEOSoqs04a0eyT8oceZxLFMDr/Dcn1Zx1 zAHpzVt0lWcJ51V9OVykVNqHZiQBmHZmWqaZihjggYdhIrYNH1Fq4xiXk6+l+G9lD9Bb XVu/++eL7AB28G+YPFpLyepMq44Q/8igb5jP42Du3Lllx085xFwLbjgvwIs7wMfBI23h Ls/JMtKFaWfE6Q0WdnQ6LrO4ksokRyC+rsCcmCZqZQ6s0J5AvksJu5hTb0sRreelnUYt O9zA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326760; x=1765931560; 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=tX8SQUKwoSIuWZvIfVWFvgmrgrfM2uE6n18+JCpQbRw=; b=cPiVkBgiuDVLZyEIf0CquRQ8g6ABB33EpUIe5oV6DUvB14+PKkBj//SDBo0BiF7VsV ri47AdTzIFPojWMP/0deRGlT/Co0G9LGcL9jRGK2xa4OaWL33186TozONxgJaTo0bGUg YM5J1p2ESrqhntJJ0a0C8JhhUDdKnv8loTk4ABAguosB2kTzQN0LH6osgSGvA4hxEj4i KSqieZ4n/O61wfV23TYFXeFlnucergq4BXurYw05XGz2XGlqdWz2/kITf10cqdmg8Q1s n8WLsCGiOuRfVG9RnjLGVqG9RRbacblxGmvNjYDTFHU9nPmnawIJZEDTFPCOf5+Q/N5q pJmg== X-Gm-Message-State: AOJu0YyKGdK++dVaYze+bQcQecIUf/XqR6UWpRSGv148AqeBUR4Tzxdr pbecOvA+ry7ct5UH6vxTiYeCp1RUrDxzoTZYVxgxQl08RBgWusjyHljtUCtiYciWfgkY14bvzkU wwk0L X-Gm-Gg: AY/fxX7p3MYMj9elLs1qq3cSFq0L4uG7NcgTQPqHQ/Xo6WKjhX4vrP0JOhq3+MoPTwD S041m4gjMsJVs1LV+DpCFZLNPoUAU8/nj5gvMZLL6F2XOnscpCV+zyjcyXghQauRyeIlo7bQIiY JZqvS4v2kXJXvlcyLNGX5hF5MYAhEiilGuxNoIbfByuEf41ZP7aceRJx6jBJUKp0eepBdEsYgrx TPevS9R7ahrxZPVixD/zuP5xDn+6gYa5g77Hq44zi830zIL3GlAyrLpDY5kQOqpUTu8CIAt2d34 PQojm0RKewqBfEW1DF5EuYjlTVRrq8fuctqUMSYIqgQ8qFkp4YFM6J08gHKpGDUTtbQWX5tJ2Wf OQzR6Ln6bkT0xSYQOBQlZLweyQMk2WpLLWyxILrVCV7X4YyHGYSuW4+IXyZWrM+OwuxwPhbec7w WARpN+s6NnnegEhM6JygR/vnWqPkD3fX3CLPAIo4WbTG7aNTwX9dQVDW7+g3yzW34d X-Google-Smtp-Source: AGHT+IGXrRgjpH6gEJvCo0otHHWRX6LXwao91E6dI4V5Q3WICcV8krrwXBPtldhZ6Np9kizCRkzTzg== X-Received: by 2002:a17:90b:2f84:b0:341:d326:7354 with SMTP id 98e67ed59e1d1-34a7288c11fmr574054a91.37.1765326759570; Tue, 09 Dec 2025 16:32:39 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:39 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Kieran Bingham Subject: [PATCH v4 17/20] libcamera: software_isp: lut: Make CCM available in debayer params Date: Wed, 10 Dec 2025 00:31:34 +0000 Message-ID: <20251210003139.43606-18-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 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 32a2c8378..0ee23f36c 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 Wed Dec 10 00:31: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: 25414 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 71FCDBD1F1 for ; Wed, 10 Dec 2025 00:32:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 225936146D; Wed, 10 Dec 2025 01:32:46 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="yhfqAPYj"; dkim-atps=neutral Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D1C2760C8A for ; Wed, 10 Dec 2025 01:32:43 +0100 (CET) Received: by mail-pj1-x1029.google.com with SMTP id 98e67ed59e1d1-34374febdefso6438861a91.0 for ; Tue, 09 Dec 2025 16:32:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326762; x=1765931562; 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=Kru8M1HJGgHeXu29L+zRVlgMziV5HaccffXT1tFN0HU=; b=yhfqAPYjDEYOt7M9bsaFvy0lRIfiRgSs8n9beDGy4StoxqfUaCtifhxAI46HGMd7bP SRI67W859Y3Jbgea9urSY0deP22R+8dlw6OO5qAkXrYN/HUsUYCgYbdcoQGw3IMjlN20 6RM82FvVyitILWyVvOyqmaGKcJ/XNcdYgD/GpeQtcYFJ4ZasMxyc0RNmIw5igDFplV7h vusZkNgfYbXw/n2+WxKEzDrkWUD1azaqVRyHpCSTKm/kttYhxPKRCNUeqBc1n40RIcp7 i6R+Q/Nu1NNKdPissCX5EiROrDif8x7i8NA9nopi/0HiNvw1reDx+wk0T3SuZpJ0P5Yt dAVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326762; x=1765931562; 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=Kru8M1HJGgHeXu29L+zRVlgMziV5HaccffXT1tFN0HU=; b=ehL4dFNe6omcj8QMkmvqootugb3YISltEEACYqVYJFNJzxIEGTj8conWNo8+F7uWZR irqWb9ASTKwIK0ssiUUJZFGeKNKc95KfA842HQQddF5xJ4ekj8bbfMTJGdswzQHel3xS buEdyEklEOrxNqJtg6YgfSIPZ2IJxJgYOVbGyU30I7aHizLiXO15La74ey6KP6NYrdvf USLIUG4Ql0vKh5TeZ9oavgEd8JVu5mrzKkSUi7WE4NnKnleJaq1GL7uBRZi0QTFYbwi6 APualawX1YYGQgUgClX7D2Ng24JQ1BmhjXMYzBAoX7UYKn9aVt4Rpbs59QWz1x+mcX3O QAPQ== X-Gm-Message-State: AOJu0YwFvpgEv9ZYjryDQsb2eRrzDMixBxabMENXfUv9itPr+rg4cIoZ hHthEoUduNG83TAC85CATLjvjerdqUTFOs07p23+UnDUqAcngWvntBt00/TvWypqb5Qk26yV2TZ 8zdEc X-Gm-Gg: AY/fxX4BZqkqX9y0R1nehGkm3MypXvOhkEPqLxgKRRwhSRXkJS2j/gZKGSqg6mpe/6F y3A66TpEmRMg0HPvfh/zOtDw3jqXHTOuvakvTKId17ICusJPdHBVMXBZYkvwTjKhetj+LBi0mT4 6aB6VMGJiy5hvkt5UisXBLaNDp0Z5OmkyuED0O9nKmtfhSPFrLqbCpAghn/zB5XKK2JJV72K1h1 9N1BeNGDVBZkNe5mMfxbxXBlxLHXkE8y/71F7+x8f3WCh4X+sedAoEjGR0RHY4PSNs8v1/9ESKu KJVg5t+MOuoHt/9Febs43XngIZHAvfXZyXnzctROc1OF6yKu8Zj53Fpu3WKkexgRkaUTkj38kdp QYVq47PAo5xQ3ZRv1U/qqIkd8lngXiR8o4dZOU+Agh03Oubjmb5OstGLuo7W1Zbl56ep0tgyfFY CwuzRypxXhcdaULON0+fPI7/Sr8n42zgxSLU34CZ7orhUakOGU+EvvcHF7rz01xgLU X-Google-Smtp-Source: AGHT+IHCNvs/v7Pq1S4v6HwvljFJyjYcIidV9rnvz0A48/opndAVgHAD+kOXLfny76fELl8V6FTPYw== X-Received: by 2002:a17:90b:4d:b0:341:719b:768e with SMTP id 98e67ed59e1d1-34a72890df4mr486861a91.2.1765326762110; Tue, 09 Dec 2025 16:32:42 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:41 -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 v4 18/20] libcamera: software_isp: blacklevel: Make black level available in debayer params Date: Wed, 10 Dec 2025 00:31:35 +0000 Message-ID: <20251210003139.43606-19-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 0ee23f36c..34460f316 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 Wed Dec 10 00:31: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: 25415 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 DCD81C326B for ; Wed, 10 Dec 2025 00:32:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9C0616147B; Wed, 10 Dec 2025 01:32:47 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="SGYYOy9i"; dkim-atps=neutral Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 399F661475 for ; Wed, 10 Dec 2025 01:32:46 +0100 (CET) Received: by mail-pj1-x1033.google.com with SMTP id 98e67ed59e1d1-3436d6ca17bso6257843a91.3 for ; Tue, 09 Dec 2025 16:32:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326765; x=1765931565; 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=BO1WtgKOG/1zSyyE29t2Y9M/8GgNCuKl/Tzsg9gDYHU=; b=SGYYOy9ip9iTWAK++x49ID/tr6Ew2csSaMJC2uXY4rtn5YlRMFDbtscSfAv4eJ8CxP XsOzdU03pKvCfUIZgvMYDMkog3OyQtuQctFcnsx5Pa4fnVNoywioTuqVSHB17m09fT2h OqOiitZzRlirRRtdFtoAdsGwJj04lqGKrpOOhu7PKSUc+rKhoW/EQHLmkG6BTRBHJ4zD TcCXK8NMfHDVNzsgIC4OsB+gEUUTMZg8DUFgSKMGMqEaQURYiMVvF0HZWZyRdKsFQOH0 eTlsEgJFL4NmQGUPPY6hpE4mcrW3Qn6kERqgioJsLkGi2N3xFwoRBKrhufhIv8ZZ9sqD BHCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326765; x=1765931565; 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=BO1WtgKOG/1zSyyE29t2Y9M/8GgNCuKl/Tzsg9gDYHU=; b=DkAAPNboPIGiM5TA1j0Zdm8DaN/XTidGD4Qs1DT9zLArIMX/lVr1U28o1HST3jOU6w Zbqq32z2i6lOGjZkE5TdqQbpg2SQNoT/ssIot0CtFg1/ff+UfIeXWTqTxlKyeuD/RinF sJaoyVJo4Eq0Ej/tsIMLhcy86t4AJNRqUnHxpyFUWZ+sx58xRtf+xZcWsZhpkBubRwP6 ibEUAWrw7FFLo3KW9ep63m2a+B2cigbLpzPUZbVZyajz6InKASh4JURL+bEl/mY/2lwA uPeFagTF7LIGAzjBZ4ZIpNiJ5YZQBK+alfcIXdbpwJInBdteN1s6h+6TO/ys8fP3WgF/ vx8w== X-Gm-Message-State: AOJu0YxRAfPMFUMs6hkXEne+5Q9uncLnFDii89JSjORqHE34Ql7ZvD49 31wqQiGSj5XULJOtc3UGgftoQsixbhTBBpxcHaMEfsv8RHldk9ZL9HTL39b1FZ9k0OqOlET7tmM yggZm X-Gm-Gg: AY/fxX6a8AAOeOaM2B0BV52MqWrkWzJzSkjUQ0zTfTdgDBjsSOJy8WXbv5SB8Eaimdi LRa83nB1oA9XATxc1dEQB1J+Z+oiedYkBx/eCZw51PX4SGQLK85dyWin8itOur04aqRYLswMvcc dsf2xvE4mwp6ux8M8mt/n2muyzbV7Md4Gb8Mxg8RiZCnIH/cVWp4JGvoPdzALLQHD/c+/P1vAi0 iq4tJ2cbRYf4ENATTW51+IimK4Cpaj1gZ/as1QYW/V59FUnB2fapyQoOygXpV3wlSFDUigmBv7K j9hKADl7UEqnC5m4xsBJv3oWbDT+xBKcRFs642peKaHqHJb8E3xwWCJm4W3jts9SME5J3T7s2N8 i/vhgiWC8AECZ04TkwFTo/BqXV57Yffqug4kGXd+8RxVUg+/0NHj3eMgLJpq37IogpBG9ysT7bv zuAJSTKRj8fls/UpwsbZYQhzBjoRhJFAbpdmeQL0+Hg2H9kXtSuWAK/LmDgZ2kgpG6 X-Google-Smtp-Source: AGHT+IEylds9U/fO0HwSA4zl24D8CIfjunI4S3rvmKfZ6ki8UlfyfD9t3qGYX0GavYKXfC7f+Ybd5g== X-Received: by 2002:a17:90b:1346:b0:340:c261:f9db with SMTP id 98e67ed59e1d1-34a7281a399mr493483a91.10.1765326764578; Tue, 09 Dec 2025 16:32:44 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:44 -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 v4 19/20] libcamera: software_isp: lut: Make gamma from lut.cpp available in debayer params Date: Wed, 10 Dec 2025 00:31:36 +0000 Message-ID: <20251210003139.43606-20-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 34460f316..8e7eac793 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 Wed Dec 10 00:31: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: 25416 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 8E260BD1F1 for ; Wed, 10 Dec 2025 00:32:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 53D6C61485; Wed, 10 Dec 2025 01:32:50 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="ewZfHASo"; dkim-atps=neutral Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9A57060C8A for ; Wed, 10 Dec 2025 01:32:48 +0100 (CET) Received: by mail-pj1-x102d.google.com with SMTP id 98e67ed59e1d1-343dd5aa6e7so6873330a91.0 for ; Tue, 09 Dec 2025 16:32:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1765326767; x=1765931567; 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=M/bJYdbFWv8CRdhs1pvqnvqUFQsR3FnLTvxzEDq9+0g=; b=ewZfHASoVorfMRWVbUU2ykMhssJKaLyixGPuOtKlaBV4j23Swwy/om5dowZgNLUuMT xTciU7tAm6OBStGlt0o+WLx7ZNk9WE+YMHItQPIlwN5SvK5QbdPWwcbRZ+jmqDiojxyL VTMuxnjEF9uAG5faYqehnCiX/+NGTdjMJRIzPh/WS/CQJOR8pqN80xLr4whL5KoUzDDW qIFN9MVwWeXmb8Kci7gyVX28fgcAt5mH9rQMv4XVDymuMeCN3h+dRd45OYr/xjpS69r6 lII6pYxL5ODtRxFFF3I7WofQOrTgEz4KPfCmliiracCgOTxSPqPyQPw7+k5a7dXslZoT K7Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765326767; x=1765931567; 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=M/bJYdbFWv8CRdhs1pvqnvqUFQsR3FnLTvxzEDq9+0g=; b=QRD4BUNjQGse25tU0pI30drjv75GfY5a+rwUH5i0T8q0UCIXXlPgGzNhOiX1ZuLqji Y6pyrXlMPmeQRLfQaCh00k7JXS89OfrlyQxAJ2GPX5kOxF4SW0yj6/SXrnR8NNbr61Wd Hg3fh0wAEPAAg8M3XIYoipyXru/afqgxrFYtqUGsusCTa1Ofn7ITp4FY+ROtbvfuLvRX Fm4YtzafSrff0UDD+B7wKw4ObCDh4EB23mknZeY4dpXTG0X4qr3Pd1vGXK5qkTeSG8Sm XsUB7D/fkfdntbNBgwnbmblblE29cBktvOd3MGGHWBUG8ieLtrQUWfCEEpyx70AjlyAe FnEQ== X-Gm-Message-State: AOJu0YypZshxfIfX1Cm7AmACGPEjWuckjKoM+7ywkdzNp/U8OuSXYQjH 0iIc1tLKjAEQLgDMoYBZsAuzaCqgp8v7XL9JPem39CVdI56g3Vz6k7cGRrQvQoV9Hm7e4wDt5nz LLPaA X-Gm-Gg: AY/fxX4CZ+LttOv+rp9zqf6SwMwcTyCqalC8KEPiPrBEptf0ukIUQuaHOIAcXX7kpHu ew92N8iAuZqNFh8a9kNJaHl3f9c1mk/+8BHgxLsGv7jIdiTfhab3fJKjw1jdMc90VntZi7+NrvQ IjC35lamp9Sa2zVuurvewLyrIsvOollpWNHQoYM58YRvKv2d9dAEtKiY8Qpn7iU168PTu+Fjq84 L9XagQWi9hjmRtWfhTE34vy1kDDKou01ARDPOpPd0ge37Vzel6ZhDSfWDdkX+K8f6x4i/fNvp4i mjPCtQITcGx54GIU1FbePiF13a0F9WdRnGuH5IXTGQgTaTz4KiwovM0yicymjwiQ5KA0dpyI2gy FWtFqg7EjFP8gHnHJDMrG/cZj09g7sX3O4edWIlllQn2+kNy9jDy1REXS+dI228Lq0XqReT5Taf 7OcUfqipJaAlBgTDLRZ3FDMafay18wy+kS2TRjPI0SZRXl7KN+GkhDK3HQ+MTrAMPEx2tghxTGG BQ= X-Google-Smtp-Source: AGHT+IFWsnz4N2kI1Awyitx42U2EQa70WHGGuE2zsxjB9mH/K0Y5pq6Amyn1M/4Io3aRGYsYSfHPKQ== X-Received: by 2002:a17:90b:3902:b0:329:ca48:7090 with SMTP id 98e67ed59e1d1-34a72896510mr519811a91.37.1765326766929; Tue, 09 Dec 2025 16:32:46 -0800 (PST) Received: from inspiron14p-linux (p96936b06.osaknt01.ap.so-net.ne.jp. [150.147.107.6]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34a70427ea6sm566580a91.3.2025.12.09.16.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 16:32:46 -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 v4 20/20] libcamera: software_isp: lut: Make contrast available in debayer params Date: Wed, 10 Dec 2025 00:31:37 +0000 Message-ID: <20251210003139.43606-21-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20251210003139.43606-1-bryan.odonoghue@linaro.org> References: <20251210003139.43606-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 8e7eac793..63a61daf9 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