From patchwork Tue Jan 6 17:00:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 25657 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 576DABDCC0 for ; Tue, 6 Jan 2026 17:01:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9518361FD9; Tue, 6 Jan 2026 18:01:11 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="raR2DRGP"; dkim-atps=neutral Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3206E61F9F for ; Tue, 6 Jan 2026 18:01:09 +0100 (CET) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-42e2ba54a6fso452635f8f.3 for ; Tue, 06 Jan 2026 09:01:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1767718868; x=1768323668; 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=Wt8h+ZjhgdR+OdkPLA1nogPcLvDpX9IavMvjc6CFwXo=; b=raR2DRGPCouq37rrYrtY3f6+YvIAJYadRjLy+llo3sHVjW6ts0UiyrxGhKKu6BKpEK sBxPKZuMEyclEEtkTFbHTpZHzkLqN8p7s1TlGoVLzjzIDEPZJ3yieGqZSu6HQS7fPiJt aPjC7Hz/1DgcoD6ADnC9I9wQ6OfopvQ38GcRVGe3x/m6ME6cF4PoDQ8A34Nf/ftWk5T2 dWIrg7pv3+xFVqQoaPY/0L0dWqZ1cedTIUp5rYf5SW0pudQqQdLaDYJdEghQCqcOhjSO vhapXokKBV2WPEhO/9kb7ZLOcU9BQbErRQJ1o4ofSH6qmiW4EfnC41B9XUCoLNrTym6v L6fA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767718868; x=1768323668; 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=Wt8h+ZjhgdR+OdkPLA1nogPcLvDpX9IavMvjc6CFwXo=; b=ijBYGMyTsRQNm1/S7KxLCg0PdIFM7MhcynYmo5dPr5rtIA9WZ2YN5w286GgPcdiA7+ qU+y9ifICjbG1zmxSEBj/ZlFzdC3PyPEFWCot+zox4XdJSAlv2G7DY39R1J7ZH8NufnT ZQ/eq6ZJjkBurt8tOYKjuEmrd4fe/ELUqfkpOtpLG+47FujWJakqFvuQk7dWd/MFWFJa VdERCMJqccOAcG7Qaoh3pAme13GNaW34++eHur8H0m6QzleykA+APCXKXrkFEVYPJNw+ xQg+3GQidPKzjU5NcF8J/CIqlE0FF7z3Wy/jwx2FIFAtY3yvhxX+2HhitaLV9+HGYoY+ a69Q== X-Gm-Message-State: AOJu0YydD8KQqcbJmkOcz2nRHyB9TXtvBQnQyCdXF8gZlskuYA2QgS0I aBfUyY73ZBpnBQo0ezbSvV7TKFet34FWtswGIPy/ccmkdVPKGwuPKbZVx6szlPAgE5vVoEXCChY 6O2RcY/M= X-Gm-Gg: AY/fxX4TfFKg1P/No0ZpNHBvcI3F/n/KYafzpABZTAKAElQcj/2MHI0FAJWwJ5wiIxr gfi1ewWuLFrK1xbCAgIhWxOFv1ZkZ943VzULUGSVb4Ls7NUc5cKxGVcZUarN1afzBg7HABqRtTp 0zMAnCmdm8fnclnQRYRt6cAgVJz4vxnsE1T62dKyi3FdIViiVVlo/Oy026/2UZ3j0XKlWnwOn0/ TAth17dlv+RRAI9zRf73NOzyW/onyyfzTq93RElN34EeuvO6lO4iruH7Op6aPgrUV4fF8OhT766 D06fatHi2384EI4cIQW9CfXx1Nk3CE54QgHlyFmV9QeRgqckqxWHS0A+ZD8DTayyrMlj4HORGh2 V62MK/L72vR8RBifLZwHNN+uAhi/06O06YPaIoGWo0MkM+Wn6XlZeP22jFMTke6LB0+9B6LnyLz TZS95uiY3hP0Fl85FJ4Ev/D3G3lmuuhRVCM3pEL073jAeh7nl7zm2re4W67agjf8z1z0A= X-Google-Smtp-Source: AGHT+IGuwNlFxtJKT0LojJ9vOaxxwb0+S+2F6+M8PX1Ci2e27XJ+frMVK0BNWv704U/WwbR1hT7CtQ== X-Received: by 2002:a5d:5d11:0:b0:42f:bab5:953d with SMTP id ffacd0b85a97d-432bca50238mr5046775f8f.47.1767718867673; Tue, 06 Jan 2026 09:01:07 -0800 (PST) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-432bd0dadcfsm5515322f8f.3.2026.01.06.09.01.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Jan 2026 09:01:07 -0800 (PST) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: pavel@ucw.cz, Bryan O'Donoghue , Milan Zamazal Subject: [PATCH v11 04/24] qcam: viewfinder_gl: Set no-op Bayer shader values Date: Tue, 6 Jan 2026 17:00:39 +0000 Message-ID: <20260106170059.56193-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260106170059.56193-1-bryan.odonoghue@linaro.org> References: <20260106170059.56193-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 qcam viewfinder_gl to set default Bayer values so that the shaders can be used in their original mode without conditional compilation. Set an identity CCM, identity Black Level and set Gamma and Contrast to 1.0f respectively. Once this change is made we can use the Bayer shaders in their original format in qcam with raw streams. Reviewed-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue Reviewed-by: Kieran Bingham --- src/apps/qcam/viewfinder_gl.cpp | 26 ++++++++++++++++++++++++++ src/apps/qcam/viewfinder_gl.h | 12 ++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp index 1554c94d5..0d06122f6 100644 --- a/src/apps/qcam/viewfinder_gl.cpp +++ b/src/apps/qcam/viewfinder_gl.cpp @@ -473,6 +473,10 @@ bool ViewFinderGL::createFragmentShader() textureUniformSize_ = shaderProgram_.uniformLocation("tex_size"); textureUniformStrideFactor_ = shaderProgram_.uniformLocation("stride_factor"); textureUniformBayerFirstRed_ = shaderProgram_.uniformLocation("tex_bayer_first_red"); + ccmUniformDataIn_ = shaderProgram_.uniformLocation("ccm"); + blackLevelUniformDataIn_ = shaderProgram_.uniformLocation("blacklevel"); + gammaUniformDataIn_ = shaderProgram_.uniformLocation("gamma"); + contrastExpUniformDataIn_ = shaderProgram_.uniformLocation("contrastExp"); /* Create the textures. */ for (std::unique_ptr &texture : textures_) { @@ -542,6 +546,16 @@ void ViewFinderGL::doRender() /* Stride of the first plane, in pixels. */ unsigned int stridePixels; + /* Identity CCM */ + float ccm[] = { 1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 0.0f, + 0.0f, 0.0f, 1.0f }; + + QMatrix3x3 qCcmMat(ccm); + + /* Black Level */ + QVector3D qBlackLevelVec(0.0f, 0.0f, 0.0f); + switch (format_) { case libcamera::formats::NV12: case libcamera::formats::NV21: @@ -788,6 +802,18 @@ void ViewFinderGL::doRender() * the generic stride factor to 1.0. */ stridePixels = size_.width(); + + /* Colour Correction Matrix */ + shaderProgram_.setUniformValue(ccmUniformDataIn_, qCcmMat); + + /* Black Level */ + shaderProgram_.setUniformValue(blackLevelUniformDataIn_, qBlackLevelVec); + + /* Gamma */ + shaderProgram_.setUniformValue(gammaUniformDataIn_, 1.0f); + + /* Contrast */ + shaderProgram_.setUniformValue(contrastExpUniformDataIn_, 1.0f); break; default: diff --git a/src/apps/qcam/viewfinder_gl.h b/src/apps/qcam/viewfinder_gl.h index 23c657bcf..1aa85e4fc 100644 --- a/src/apps/qcam/viewfinder_gl.h +++ b/src/apps/qcam/viewfinder_gl.h @@ -103,5 +103,17 @@ private: GLuint textureUniformBayerFirstRed_; QPointF firstRed_; + /* Represent per-frame CCM as a uniform vector of floats 3 x 3 */ + GLint ccmUniformDataIn_; + + /* Black Level compensation */ + GLint blackLevelUniformDataIn_; + + /* Gamma */ + GLint gammaUniformDataIn_; + + /* Contrast */ + GLint contrastExpUniformDataIn_; + QMutex mutex_; /* Prevent concurrent access to image_ */ };