From patchwork Wed Jun 11 01:32:11 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: 23507 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 D563CC3240 for ; Wed, 11 Jun 2025 01:33:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 58D1268DB4; Wed, 11 Jun 2025 03:33:01 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="DxItX6e+"; dkim-atps=neutral Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E4FF668DB2 for ; Wed, 11 Jun 2025 03:32:58 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3a507e88b0aso5459926f8f.1 for ; Tue, 10 Jun 2025 18:32:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605578; x=1750210378; 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=81Ng/LIxFB09YHT8LrVidJKxmT29lxMXyQw7vM5fRDM=; b=DxItX6e+kr2d2hyJLwSE2C7xca5sR6dPTJpYzIobkwghYUx0UC1JA8XZx+X4GA8ekw e6BvI3mRKa1aOMODepDSoa7wJY/Jx/guHSKDfHehlIzbx7ox5dbLmoR16+znyh0qbMcG firtKu/gjnxn3UnerD7wG1Ed5ffJ1532o8Z3CqhrSPtTVr289Uwep8ZY/R2B4vc8ung1 mH2N2XsXWnGZXpYrLMQkeXyBoIRqt/Ai8AcSYV4786OJCiAO7YYQcN1OeAqHDlG/XyFT 6904+/xtnorf+l27d0OW9ST1LAGztePhH2lUr0HLfFpVqu2hAETam9wKqrhFSX5u805r KYVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605578; x=1750210378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=81Ng/LIxFB09YHT8LrVidJKxmT29lxMXyQw7vM5fRDM=; b=n5SneyPus/9wDiGnFtX1ah+hU+08sz3cQY3peY2dQhZ0GEEpMo8VhT+j8gAtqkGrMU bxqkGqucMdCLKjj9swEoQriqGGjDcarO2bLHQGwk44J0HNp5BcMDQxUA88WNAEE9NaJd i0i8tPH6ZdQJW3EvESHBajzUkTa9EO3Xcosa/unMXj4gnbgeUXzEY4+TBQ5T/JLIOPwE bWDzxasNpMJSpLjW22ARzYpmxDrJ90cDmq7DjQ4WhMz8tKuXjwlxoXQfu7I88YSIRIcH B29jw9hBK2V2061wgtSbh5z5gxjeaKRyTmRHm7WwdbGOwtvf1yqBdFiKPWRhOMYV0p97 5EVQ== X-Gm-Message-State: AOJu0YxNb89dGdkz3eJZzvuG2bZMlIZS/f75VKfZ8l6OO8nSCLsNKF6+ VypPWFNzpq6xWhpPraW6N88YBn2FKgOmnIABAscWKxqp4Ry5ID8sLmagtleQzcZr8i9MBIC8r0H DhgP31Ho= X-Gm-Gg: ASbGncvVhqhIWyiMbqjNeyuLb1impkBNg1HNca17nNRN/c4irY/v0cEhMjvu5mqPcaR k9Qef8anHmO1lSINgmLAKd7v8Od2m1bDiNTGqg+7FzHH8i11HqPP1cvXCp83yJQewYwupvNO5L8 3WkZMb+kmZMcUXODGDWHYyYlXleslQHi+/RBb7m4jQYqHaPGiTGQXM1b3E/yLLaIdsrTyxL+zOf 9pJXgFuW8ZJNNf0QL9zy69gsqrDkOmF+jup4laBvcOYPVBkITePdpn4+dU7IThNJss6afkIMyza 2Z3cP4+oZnRg+KIMDZtFXqYIS5+eyWVi86QaSKPRpfZ5CZ5U5fUAoOWHh7kBk5BKI+Rbe5enHKu NDWUWCy68kziowqA7aaM6l08jEcdscLcXFVANhi+XRQ== X-Google-Smtp-Source: AGHT+IHhXOpdsjY3UkRy751yLw8C9SSSiEEGYuX280Z7091lif4Za7c5nj07iA/r6OQfXSoutZs9qw== X-Received: by 2002:a05:6000:2411:b0:3a4:eed7:15f2 with SMTP id ffacd0b85a97d-3a558aec634mr656421f8f.43.1749605578273; Tue, 10 Jun 2025 18:32:58 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.32.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:32:57 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Hans de Goede , Kieran Bingham , Milan Zamazal , Bryan O'Donoghue Subject: [PATCH 01/35] libcamera: swstats_cpu: Update statsProcessFn() / processLine0() documentation Date: Wed, 11 Jun 2025 02:32:11 +0100 Message-ID: <20250611013245.133785-2-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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 | 27 +++++++++++----------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/libcamera/software_isp/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index c520c806..a9a3e77a 100644 --- a/src/libcamera/software_isp/swstats_cpu.cpp +++ b/src/libcamera/software_isp/swstats_cpu.cpp @@ -71,6 +71,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. */ /** @@ -89,20 +102,6 @@ namespace libcamera { * \brief Signals that the statistics are ready */ -/** - * \typedef SwStatsCpu::statsProcessFn - * \brief Called when there is data to get statistics from - * \param[in] src The input data - * - * These functions take an array of (patternSize_.height + 1) src - * pointers each pointing to a line in the source image. The middle - * element of the array will point 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 documentation of DebayerCpu::debayerFn for more details. - */ - /** * \var unsigned int SwStatsCpu::ySkipMask_ * \brief Skip lines where this bitmask is set in y From patchwork Wed Jun 11 01:32:12 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: 23508 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 79DD4BDE6B for ; Wed, 11 Jun 2025 01:33:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E2D1568DC4; Wed, 11 Jun 2025 03:33:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="tiE1OPAx"; dkim-atps=neutral Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E002368DC1 for ; Wed, 11 Jun 2025 03:33:03 +0200 (CEST) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-442f9043f56so35111155e9.0 for ; Tue, 10 Jun 2025 18:33:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605583; x=1750210383; 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=smZwtpbTz29j4hcPfA9P6oUHmTi9LVToPOlGCRTmB7Y=; b=tiE1OPAxuUH0PcJP+w6lNKSKzysS5pzNZ6zMftNgKoNwOUHGTWlXpsrhFGES6UKnPa JpIqv5hEj59NRN7I2caQJ23KeBq87VVuBHkGNE4qV1mFv7BhvJeXJEcXIdxbH6n/9e8P e/Sc8J28v/2sJZwKGEUlUHhim/TzBymGsT3z///2V9AxBgEG7YikvZZTyFzCtn4kAXST myIYt7See2XcDIHtiY8h5LhaGjdt669mgkebAo4qrA29YynepsPjc2Ta43iF1QfBtDfV ZjIhLh4WqEQxxL00EI5bPNG3PfxandJx8viBoqSfv+nvyc5Tu0F6NOOMDXIfsMMhLepk 2LQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605583; x=1750210383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=smZwtpbTz29j4hcPfA9P6oUHmTi9LVToPOlGCRTmB7Y=; b=AOtHL8CaL+X6t/Hh3hfYVWh2sxf8xOnFGeWUdnjC1KGbeFtBQIct7dmMq4sZoVPrDV ncLsUFhrs2Q7MFdG4VKcI/288X4PNou+6h3yv+R6giy0XfMVJAsX7cnvEvcTKA5Oi7SP 5rtecsE9f66GvQHPNzIkCIC6ypadyHWf0PuZu+Pb7hSasjKs1UJ7PnPi85vJJ80oYjaB EJxOUU2JVwHohed5BNVZn3Hkt52RBFuBZHZ8o2kctwSIsr53YsWPvwvuBZrc6bcKnQIQ P3CvAKBUWkbqpFuJiAm8hKO5/5e7PHSNvbMQaWSHlhfeVNwhYJVZ2UZpraEZ730wRx1I wtng== X-Gm-Message-State: AOJu0YxwNjB3dHeEVF0Da7do4XkKwLbtj2xRZsJYLahZE2U4S59vpljx w/Kzs07rFvIMdk8uOdlRBsGsnt3Y1foZaitmL16AxbGh3EMqlHylf1UXgzt9evQnAH+D0V18ZW2 JcMGkQ5Y= X-Gm-Gg: ASbGncshgeyTruTUbLg+xb0YuBxyj/L15BWhdAf/Bdw0kLYbxv+OKa/IhKTMtOkb+p0 /RSYn1mjLOKnohEVrCZSHtQfu3uiwHxF1J3Oc+HhWCQhNSvVXrh1Qina39W8XSK79O8NvujySC8 JmV4qY1YA0V3GK61DTnQltLlxLyaDpQHQBYjbHV+0WH2kI01HqYwe7p7/RYN5ets13fIgkg2gNv GMunrQvQIMnGhYcqfBPg0KV1nqfx+kHx89uSbwQKbLfNkeago5JP7GCyeUUfLHAq5y0CGCrbx4H fCP3IaeMxDROHEJY8PYjzmTgU3yFxs51rC209cJke10Cf8LL7F/juDP0jzNiX4yg07MMtNsAfWZ +26RVMLi+llmUUDqIH38gt1TPDp0DOr8vpSMBDai58Q== X-Google-Smtp-Source: AGHT+IH+VgSDXGeT5oVvvQndVYrMYU3vpEC7jcxBca/+Y6iTCr5FVINIddpYAOHssZuYA28v/rFbbw== X-Received: by 2002:a05:600c:a318:b0:44a:775d:b5e8 with SMTP id 5b1f17b1804b1-45324abda5emr4300245e9.1.1749605583271; Tue, 10 Jun 2025 18:33:03 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:02 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Hans de Goede , Kieran Bingham , Milan Zamazal , Bryan O'Donoghue Subject: [PATCH 02/35] libcamera: swstats_cpu: Drop patternSize_ documentation Date: Wed, 11 Jun 2025 02:32:12 +0100 Message-ID: <20250611013245.133785-3-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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 a9a3e77a..5e4246a9 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 */ @@ -112,13 +114,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 Jun 11 01:32:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23509 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 81B6AC3240 for ; Wed, 11 Jun 2025 01:33:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F30D368DC7; Wed, 11 Jun 2025 03:33:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="WULPefFA"; dkim-atps=neutral Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 42ECD68DC1 for ; Wed, 11 Jun 2025 03:33:08 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3a503d9ef59so5107691f8f.3 for ; Tue, 10 Jun 2025 18:33:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605587; x=1750210387; 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=L/duYbXv1BA3H2N9W3j9KShAgwApfhVdHPX7dEdaCvk=; b=WULPefFAPe0ySUKSNwZknHQkGRcVmwGmTnkyI+BGvcypEkPdD70QYwPPIfPmZ1Ueji nGO8Jj8d3KQ12NJu4dwED1dOmFRn1dm8/2LPQdMnkAZozt+apbgqiEogqmgpxie1HpiE 7CxpZdDU0BSaY6ZrcPQDXD3jeWvVRHYnsf1Vq/S92oub8dq2jQAMD6DLB3ctlkkl9sGa ES4po0l9DoauOpvibgjfh3Two1etYH4QgJi20GQ5y90nxV5D635n5keMi5lJAk3JLwSI 4eoN17Y0WH/OVQHVFCFUdmYkWD603IN8/nP4EVxa5HzWYe0gDYqI+lCRXqpOolGS1EjF vt/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605587; x=1750210387; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L/duYbXv1BA3H2N9W3j9KShAgwApfhVdHPX7dEdaCvk=; b=w2VCXwEhdf95XkgaT1Ytilf4ur6aaXhTqjt7rE1LSZq4TUL/HrtbBN7s3f7Z+5GE7A oGm82Prl803eII2cpvB3u/soX4Ks8hxcJ4gxMMFtq5WMZLN8WseCTFUpr1YUPO8OwhDA oyjvxcMmiwQY0bWI5q/Wdkx1NnnhT4n9vbEivVa+9r5EW9A2xpKolgi6NW3HdIfdd26R W//v85snkwbZriRjl/Qn4t0QEkZ/eYVA26uzQyas3Pogqq7S6zT/Bj/DPPR6zA2zNLRr TOt0Tiy0yd2ee0+J278sPW28AgV+l6GTGHlHFclfPRa9MlAmzqNLY2YyGzbYmeZLnxVB hv/Q== X-Gm-Message-State: AOJu0YwkPTEvpBJKvaNjy/enxxyzHfWA1NHNbAfJGDOlNeXwIC4qnbd+ OeIXoGgbhrBFgj2i85/yPCHIse5OEQ+69XhG6LsVQWy1IFbs6mrLW8WfuKzsDWQia7fgcHqCysG 64o0L4Wg= X-Gm-Gg: ASbGncv4PR2Gy+xmWZftMdydhhe7Poso5u4FHsKcCVV6yLAC5/k2jtnF9+QmeDKv6Oc g2Y2fBTJEEImDXfryMNOeQ5x6T14K9zuezaCqeN+rqy3O2xJ2oZnBKzEgP4RRynjng4Uwe1bxf/ TKV8mkRrJd/VTZPXm36OlZuk+LMnbAKzjhIoOoiyzT21vZysL2DTNqk3KL40sbo03XtivTLCo7P jNs0z+H3PY31haMXMzTlze0ZnpymbVEbnMDmF5OSfL1TbF5MFVb4zhPmVvrajyhd22w6PlEPJy4 GmBPAnFljTLZsyMYhM81s4n7QxsSo1bafhsCc10YKemYaLEBRV0bAPMCxlC91wmW70eYD6tOJE7 SBrA8TeBJBuSUQ6Hef1WnR0wxU8z773aeQjBxkcv03Q== X-Google-Smtp-Source: AGHT+IFf7JJfUTZPHZ/wA1YedgM42Yg2oErmEEiVKYHmZ2EwY18CUq9lq78BKRolruQaH4oAnoK7MA== X-Received: by 2002:a05:6000:2006:b0:3a4:d8f2:d9d with SMTP id ffacd0b85a97d-3a55881dafbmr820700f8f.38.1749605587627; Tue, 10 Jun 2025 18:33:07 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:06 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Hans de Goede , Milan Zamazal , Kieran Bingham , Bryan O'Donoghue Subject: [PATCH 03/35] libcamera: swstats_cpu: Move header to libcamera/internal/software_isp Date: Wed, 11 Jun 2025 02:32:13 +0100 Message-ID: <20250611013245.133785-4-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Hans de Goede Move the swstats_cpu.h file to include/libcamera/internal/software_isp/ so that it can be used outside the src/libcamera/software_isp/ directory. Reviewed-by: Milan Zamazal Reviewed-by: Kieran Bingham Signed-off-by: Hans de Goede Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/software_isp/meson.build | 1 + .../libcamera/internal}/software_isp/swstats_cpu.h | 0 src/libcamera/software_isp/debayer_cpu.h | 2 +- src/libcamera/software_isp/swstats_cpu.cpp | 2 +- 4 files changed, 3 insertions(+), 2 deletions(-) rename {src/libcamera => include/libcamera/internal}/software_isp/swstats_cpu.h (100%) diff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build index 508ddddc..ea3f3f1c 100644 --- a/include/libcamera/internal/software_isp/meson.build +++ b/include/libcamera/internal/software_isp/meson.build @@ -4,4 +4,5 @@ libcamera_internal_headers += files([ 'debayer_params.h', 'software_isp.h', 'swisp_stats.h', + 'swstats_cpu.h', ]) diff --git a/src/libcamera/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h similarity index 100% rename from src/libcamera/software_isp/swstats_cpu.h rename to include/libcamera/internal/software_isp/swstats_cpu.h diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index 926195e9..89a89893 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -18,9 +18,9 @@ #include #include "libcamera/internal/bayer_format.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 5e4246a9..aa5654dc 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 Jun 11 01:32:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23510 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 91B73C3324 for ; Wed, 11 Jun 2025 01:33:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2780C68DBD; Wed, 11 Jun 2025 03:33:14 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="hSvov2um"; dkim-atps=neutral Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7BE1268DC3 for ; Wed, 11 Jun 2025 03:33:12 +0200 (CEST) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3a522224582so3747629f8f.3 for ; Tue, 10 Jun 2025 18:33:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605592; x=1750210392; 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=6ZXBan3FwbSk2Nm4RT9dBvDX34LkuEvl73zB9SkoswY=; b=hSvov2umOVaV99r7UsafNZe5/DvFtxXcU2vSLh5Icm4nzlYmWYsa3Y9aclaTIbDbPK 1S+4kwR+nvDkeSOXSCo1VjQSkQ2JBsujqGEcGGsfZX79vYZn8Qw/Ui3BDXnkqzF2/6ub DRxBdGSY+TZL7P/nX4CgSRpCD+XkcJ31jDIYBgbKIWbFgYsoG3S6+d0hTB/oRo8uT8Jn tWewBnjOUoirJESUUyXnwR2tzmL2xNz3qgHmi1vNi/ODNObQZwnnXIsMlkF+WivRgct/ ki2KHVFEneyeId5eNUcrHtGhkkMjwBsBYEFMWPWGJo4jWK38cgsRbf5pBM76irgYm/wk FvPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605592; x=1750210392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6ZXBan3FwbSk2Nm4RT9dBvDX34LkuEvl73zB9SkoswY=; b=F0pjXpCr1o5CDPFXNZ4wh6/DDnMHaFPMHE9/Sadmp4r0bQmuUU9VZFJ8C+qBZR2t1T PWO9SEaZQQv50rXRpBkh8UhrkU8s7CB6d4/tLqEW+BkOXVfqHhtoTyYs6m/FZcGvC/hF 6153O87kYEvYxup5GXWTTtScX6H942v29azq9qhvPpCnvr6IB1UbOyNwDtiPm68Kzthf OXjR2J85leDAEuAk8lrV81YaOtm0Ziaxjt4kHjimDp7LpzmlTD81K1NjiwuVOx7C3KRQ P3aijSMQol05+kT8w1TmYS2XwpsujUBi/ivV9yydxuG/8oOKuOUnTADAefjaObFPLtb0 bw5g== X-Gm-Message-State: AOJu0Yy4ELw3Yf7grq5ZV89WCd8ltzJr1q1j3OleyeLfq34UHubqVecR f8fhyeg5TxkWwDdP/TJMCRjKt/JBLJMraAPpxaajxOjvBGIWfEaTPRKvmJNSmGHFvrlARV8FQGG KYhIv8cI= X-Gm-Gg: ASbGncvicX88Hn/yQBaU1kBWeXLyjQ5RkaudYQ7UOK8RuMONFIvoyhAACZbAXEClD4k quXt469j+jYxZkl8p1aG7CBuRbURGT4VYkYO7dNSV5AaVG1lxKWsmUFtsj6A5H6kipom0MC4rfP izaLK5raUhQh9e7IX+dQ/BGbSmuHVyORCa1IDimmfTWuA+x8dBw12Lp07l12S6WTE9p73oTrcgc 46bq3hbayHxHd8LF/V4GzcaFn7isHwa+HO04Zn8SAOyheezZA+OMZotn9JmIi5S9+2XgKoAI9GC E7ThNsRDrlPoCoRLEVwmRss/GRW+NIdAgH8Hw6uFM9g4HI5+b3FNe1qJ9F4VOCmH3TpptRYqgiq BkJmGZmLdDC2/zI2AyvIasMl4P/4sQPfk6sJtXVbt0A== X-Google-Smtp-Source: AGHT+IFS3Gg902FhBlh8vQnpHTi6KmXmH+HxaJEfioPW0HjqZciOQjIdzixjfPrGEUtsNyYTiJcf5A== X-Received: by 2002:a05:6000:1886:b0:3a5:2653:7322 with SMTP id ffacd0b85a97d-3a558691999mr782157f8f.3.1749605591808; Tue, 10 Jun 2025 18:33:11 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:11 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Hans de Goede , Kieran Bingham , Milan Zamazal , Bryan O'Donoghue Subject: [PATCH 04/35] libcamera: software_isp: Move benchmark code to its own class Date: Wed, 11 Jun 2025 02:32:14 +0100 Message-ID: <20250611013245.133785-5-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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 Signed-off-by: Bryan O'Donoghue --- .../internal/software_isp/benchmark.h | 36 +++++++ .../internal/software_isp/meson.build | 1 + src/libcamera/software_isp/benchmark.cpp | 93 +++++++++++++++++++ src/libcamera/software_isp/debayer_cpu.cpp | 36 +------ src/libcamera/software_isp/debayer_cpu.h | 7 +- src/libcamera/software_isp/meson.build | 1 + 6 files changed, 135 insertions(+), 39 deletions(-) create mode 100644 include/libcamera/internal/software_isp/benchmark.h create mode 100644 src/libcamera/software_isp/benchmark.cpp diff --git a/include/libcamera/internal/software_isp/benchmark.h b/include/libcamera/internal/software_isp/benchmark.h new file mode 100644 index 00000000..8af25015 --- /dev/null +++ b/include/libcamera/internal/software_isp/benchmark.h @@ -0,0 +1,36 @@ +/* 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 + +namespace libcamera { + +class Benchmark +{ +public: + Benchmark(); + ~Benchmark(); + + void startFrame(void); + void finishFrame(void); + +private: + unsigned int measuredFrames_; + int64_t frameProcessTime_; + timespec frameStartTime_; + /* Skip 30 frames for things to stabilize then measure 30 frames */ + static constexpr unsigned int kFramesToSkip = 30; + static constexpr unsigned int kLastFrameToMeasure = 60; +}; + +} /* namespace libcamera */ diff --git a/include/libcamera/internal/software_isp/meson.build b/include/libcamera/internal/software_isp/meson.build index ea3f3f1c..df7c3b97 100644 --- a/include/libcamera/internal/software_isp/meson.build +++ b/include/libcamera/internal/software_isp/meson.build @@ -1,6 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 libcamera_internal_headers += files([ + 'benchmark.h', 'debayer_params.h', 'software_isp.h', 'swisp_stats.h', diff --git a/src/libcamera/software_isp/benchmark.cpp b/src/libcamera/software_isp/benchmark.cpp new file mode 100644 index 00000000..b3da3c41 --- /dev/null +++ b/src/libcamera/software_isp/benchmark.cpp @@ -0,0 +1,93 @@ +/* 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() + : measuredFrames_(0), frameProcessTime_(0) +{ +} + +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) +{ + if (measuredFrames_ >= Benchmark::kLastFrameToMeasure) + return; + + 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 (measuredFrames_ >= Benchmark::kLastFrameToMeasure) + return; + + measuredFrames_++; + + if (measuredFrames_ <= Benchmark::kFramesToSkip) + return; + + timespec frameEndTime = {}; + clock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime); + frameProcessTime_ += timeDiff(frameEndTime, frameStartTime_); + + if (measuredFrames_ == Benchmark::kLastFrameToMeasure) { + const unsigned int measuredFrames = Benchmark::kLastFrameToMeasure - + Benchmark::kFramesToSkip; + LOG(Benchmark, Info) + << "Processed " << measuredFrames + << " frames in " << frameProcessTime_ / 1000 << "us, " + << frameProcessTime_ / (1000 * measuredFrames) + << " us/frame"; + } +} + +} /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 66f6038c..8d30bf4a 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -554,9 +554,6 @@ int DebayerCpu::configure(const StreamConfiguration &inputCfg, lineBuffers_[i].resize(lineBufferLength_); } - measuredFrames_ = 0; - frameProcessTime_ = 0; - return 0; } @@ -746,24 +743,9 @@ void DebayerCpu::process4(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; - - if (measuredFrames_ < DebayerCpu::kLastFrameToMeasure) { - frameStartTime = {}; - clock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime); - } + bench_.startFrame(); std::vector dmaSyncers; for (const FrameBuffer::Plane &plane : input->planes()) @@ -817,21 +799,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output dmaSyncers.clear(); /* Measure before emitting signals */ - if (measuredFrames_ < DebayerCpu::kLastFrameToMeasure && - ++measuredFrames_ > DebayerCpu::kFramesToSkip) { - timespec frameEndTime = {}; - clock_gettime(CLOCK_MONOTONIC_RAW, &frameEndTime); - frameProcessTime_ += timeDiff(frameEndTime, frameStartTime); - if (measuredFrames_ == DebayerCpu::kLastFrameToMeasure) { - const unsigned int measuredFrames = DebayerCpu::kLastFrameToMeasure - - DebayerCpu::kFramesToSkip; - LOG(Debayer, Info) - << "Processed " << measuredFrames - << " frames in " << frameProcessTime_ / 1000 << "us, " - << frameProcessTime_ / (1000 * measuredFrames) - << " 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 89a89893..182607cd 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/software_isp/swstats_cpu.h" @@ -160,11 +161,7 @@ private: unsigned int xShift_; /* Offset of 0/1 applied to window_.x */ bool enableInputMemcpy_; bool swapRedBlueGains_; - unsigned int measuredFrames_; - int64_t frameProcessTime_; - /* Skip 30 frames for things to stabilize then measure 30 frames */ - static constexpr unsigned int kFramesToSkip = 30; - static constexpr unsigned int kLastFrameToMeasure = 60; + Benchmark bench_; }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build index aac7eda7..59fa5f02 100644 --- a/src/libcamera/software_isp/meson.build +++ b/src/libcamera/software_isp/meson.build @@ -8,6 +8,7 @@ if not softisp_enabled endif libcamera_internal_sources += files([ + 'benchmark.cpp', 'debayer.cpp', 'debayer_cpu.cpp', 'software_isp.cpp', From patchwork Wed Jun 11 01:32:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23511 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 45CE9BDE6B for ; Wed, 11 Jun 2025 01:33:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 861DD68DC9; Wed, 11 Jun 2025 03:33:18 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Y5j/eX2E"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 98CA368DC3 for ; Wed, 11 Jun 2025 03:33:16 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-45300c82c1cso12448265e9.3 for ; Tue, 10 Jun 2025 18:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605596; x=1750210396; 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=m1BLltBsmdQhPvHqn+5sDHtKgqD170z2rc524w52XgE=; b=Y5j/eX2EeDA8igfTsXOYnFAvXsrRVH4fxjWZdwgBcrD5+vr6CL5C2l+KlWhgUqcUax GE4bEs27OuCgttqiu9BrePb+Jj+IG9wkwDiev5ddooF0krMVggbdDxyo1AYt0LAg2vFg W1uuNty+wlYjhYe7YZD2Q5HUDxxofRv6Hpi+6jJaNkJsXlDaZb6kNHywmNIMZPB7kVfp d1S9nzYztPbIzw33a/2g+0QMyDkTBMaljJHUrtss9wsQt66C2vUbdwJzwO7QjlpeS1bG 6X0Wa4Bq0uEMNiElKR+ZOTwUD4PCYDUTvI5nXS3nHGYX/E+cgHw3qMOTLiWMI/QvepoO yH4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605596; x=1750210396; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m1BLltBsmdQhPvHqn+5sDHtKgqD170z2rc524w52XgE=; b=NDQY3rcEfB2eBbpkNnK8d/aiyZeccdQedz8iQXFeb1zcEIMsMUn/1FLbLtxfWxAlUu iby4+SvKEwZLVRqoQ4IDA98lFijoR9+SmmaNgZhMo+oCjs8JBL3qNyXj0lwmthaCDbe+ RNGZqfyC0IT3rwuQEez9skoFEPsw6i5FXZ4mexcJL30CAJfEX00xzOojOv9ck5YjwZOt IzDkxRUmLIpj9St97IfAEc4gAnNejLLX4wI7frykrnf8wo5raLFdYy7478q7xS4wnq0b x0F7XDgUNPQb8lcnO5HD3ZehfODmU35ntW4DYYj2pKEmpSSvTPX+Ijag9lkmVF7nAVOh d2oA== X-Gm-Message-State: AOJu0YxNOKhB376PN5Tb5AELnvwBoZO5lRhburXKPlkqbp+s7Rv5YJwq VFq6oSW0Dm4K/T8pWAxszu3HBI6f8vxw/63g8dNpj6oX6kgHBkuMrJpOHHIMH+7Qrvtso4ZQFQq QtpQSfEk= X-Gm-Gg: ASbGnct4aHhWXntiEUKBP4ARKo78/TXnfd0M/p/o0NjLaBrVloOEbW5a8OKK7r1Rapj 0uXuDC+7LJNEvkE1MKWpdTskP/tpYM3t5tauhKxNooMlVnmNRlX4zn8vLNi+1W9yL8ogc30Jg/A ks+/lAJfU9KnkpSZ1Cr0erVDXlFjRixMYYlv4PgomcewQ3aGJs2KoUl7JCQVlMqNcQ2zvS1nqrf 2h2rQPOOqrISp0fTqi6PSIzn7T7f2Fs2/H70LlKkgrxEal7X+gpmh5GYz6PTgqdoy7Jlyqy6hhA Yz9z0dnuZVp3H7Z7rR4xb7J8t9vd0yMJZekRHwUFLKbt7ZwRohth9Gyo7gY5XhtMQBWF6eidBIb Tx3KrH8UcJl/9FFUWaRqwRfy5FG2mGq58Qt3yPOwNLxASBWf1sPFB X-Google-Smtp-Source: AGHT+IHBNIkT76W547r/SoPZrG8WOAN7YjiFswyXT4vhEJ6KqEO+2ALh+5EfbuWiaQOtE0ThdRffSA== X-Received: by 2002:a05:600c:3e85:b0:43c:f629:66f4 with SMTP id 5b1f17b1804b1-45324cfb301mr7135975e9.0.1749605595892; Tue, 10 Jun 2025 18:33:15 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:15 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Hans de Goede , Milan Zamazal , Bryan O'Donoghue Subject: [PATCH 05/35] libcamera: swstats_cpu: Add processFrame() method Date: Wed, 11 Jun 2025 02:32:15 +0100 Message-ID: <20250611013245.133785-6-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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 Signed-off-by: Bryan O'Donoghue --- .../internal/software_isp/swstats_cpu.h | 12 +++++ src/libcamera/software_isp/swstats_cpu.cpp | 51 +++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/include/libcamera/internal/software_isp/swstats_cpu.h b/include/libcamera/internal/software_isp/swstats_cpu.h index 26a2f462..fa47cec9 100644 --- a/include/libcamera/internal/software_isp/swstats_cpu.h +++ b/include/libcamera/internal/software_isp/swstats_cpu.h @@ -18,12 +18,16 @@ #include #include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/framebuffer.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 @@ -42,6 +46,7 @@ public: void setWindow(const Rectangle &window); void startFrame(); void finishFrame(uint32_t frame, uint32_t bufferId); + void processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input); void processLine0(unsigned int y, const uint8_t *src[]) { @@ -65,6 +70,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 */ @@ -77,6 +83,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_; @@ -89,9 +99,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/swstats_cpu.cpp b/src/libcamera/software_isp/swstats_cpu.cpp index aa5654dc..1ff15f5b 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 { @@ -360,11 +361,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; @@ -385,6 +389,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: @@ -425,4 +430,50 @@ void SwStatsCpu::setWindow(const Rectangle &window) window_.height &= ~(patternSize_.height - 1); } +void SwStatsCpu::processBayerFrame2(MappedFrameBuffer &in) +{ + const uint8_t *src = in.planes()[0].data(); + const uint8_t *linePointers[3]; + + /* Adjust src for starting at window_.y */ + src += window_.y * stride_; + + for (unsigned int y = 0; y < window_.height; y += 2) { + if (y & ySkipMask_) { + src += stride_ * 2; + continue; + } + + /* linePointers[0] is not used by any stats0_ functions */ + linePointers[1] = src; + linePointers[2] = src + stride_; + (this->*stats0_)(linePointers); + src += stride_ * 2; + } +} + +/** + * \brief Calculate statistics for a frame in one go + * \param[in] frame The frame number + * \param[in] bufferId ID of the statistics buffer + * \param[in] input The frame to process + * + * This may only be called after a successful setWindow() call. + */ +void SwStatsCpu::processFrame(uint32_t frame, uint32_t bufferId, FrameBuffer *input) +{ + bench_.startFrame(); + startFrame(); + + 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 Jun 11 01:32:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23512 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 EB316C3325 for ; Wed, 11 Jun 2025 01:33:21 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 5265668DC9; Wed, 11 Jun 2025 03:33:21 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="iyifTSOI"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CCFCA68DC7 for ; Wed, 11 Jun 2025 03:33:19 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-450d668c2a1so2743055e9.0 for ; Tue, 10 Jun 2025 18:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605599; x=1750210399; 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=W0pfBXv31rt/MAhEDKy2JxEhp6GyXlamvo6kDQ0eDWo=; b=iyifTSOIHSRCO3sXfQzzXLufoKJ7Sv2L3NE+h1K0WU7RsBiJ/xWvaEu9xL7rg8EZ+Z Fy+w7hxnamjU6BGF9JT4Se8v0NV2hi+JuZC9YTaRAegL+TUZQDKFqFtYge5C/trYx7oV 1lwttI1B9RC8Ve/jLBJqVitnNIF0VCR423CLDL5YoyIkvuJRPtTTLsZRuh8aEwR1Gz5c MD6DYyKlGaRcmFzalHj8A1nDB5jJYpIdHyurzBhYmjO40MbYjcac8Z+DyjFBtpodlo87 e0itbsLQHRE97yUfquq9Jed0nrX+hx3IzhKNL3iXtkmtEN6sJZkEWV5vA7MGAvLOfT4a R/GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605599; x=1750210399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W0pfBXv31rt/MAhEDKy2JxEhp6GyXlamvo6kDQ0eDWo=; b=rPGjDe8f3lPQw+nQlLfevn7e+TgoygJFyoubUOkHZvD8kMW2B2VlqNUTcG1ud+BKug TnUZnnCe82Rbbw7QDRULybN3oR7uTa3LfGXW1tG99E0HCOVBueqMI+o8DfWfd/z28Y4u 6ujRzsSBJ9YZ9YRNbMs/frS5OB23G+qdEC7K72rlTZnYNgoeE+QgC3VTfIe8jR7CNSGy kVA/kaxo5b2rVjkU8patgCslzAo1GPbGJqu8wLCDp9gcmwuHZQ/rlWdbG9VKXcSIsmAT 3w2r8PXW7EffMAKBD2uSK79xS/RAX2Y7nix1F1WVq0HdrPIFCM8hUFDijK7MZ04u5mQh 520A== X-Gm-Message-State: AOJu0YxgweNgwmaEHUjAzQZ9lorUD08OnLsqA8QXHGlfA6S3IInMPOSX 0unLaq0KmDFmvgD8yntNFZ2f6cbEUvhaIk8nbMVUAdpkA0ZwVnyuSsadkZKGTv1Z92mK+Ng+8xa gOtHHXJ0= X-Gm-Gg: ASbGncvqfxhAXI8Ix6qcQ9tCuvURPaC1Ibib5bTRI0pZn1peTq9xSQtlhVwCB24eot6 azn4RIG3jb7Xr5gvmXPKbP6TQhgZwXugsInOhgwHoFzLmGQoG+LwUnH2TSCfz7nqWA4HJSTRHEg cWQ5ZNJeFUuG9Wc2pbo/RUlRqZQ7VbhRElMjZ0OE1szidTGFhGnChVcofGZ4audT/rwPLgdQHK6 79whfW5eN79kU8W92uKQDgFCk6CIU6+2g56PXzn06hVl7+nafpyVfF8aZPzzvJfjWnk9+VRVkPR rsR8ZW9PO9tp+8vlmqZAZG6lRXotxpHcSucU9BGCkxORGOfw1tb2vyqWm6i+b8/wmClu19YlKHR 8/sDEQSXMehhdcmp4eNVJvtwSKfM8zEaKVmF9cUKmdQ== X-Google-Smtp-Source: AGHT+IEDqTkXfLg+rPexjiflqWfA8Y2jX9lsRejIopkA1TlHfjD0BjquWrXqazQktLCvdbSG+OJd9w== X-Received: by 2002:a05:600c:c4a4:b0:442:f4a3:a2c0 with SMTP id 5b1f17b1804b1-453241fb4camr14524605e9.13.1749605599203; Tue, 10 Jun 2025 18:33:19 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:18 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 06/35] libcamera: MappedFrameBuffer: Latch a pointer to the framebuffer Date: Wed, 11 Jun 2025 02:32:16 +0100 Message-ID: <20250611013245.133785-7-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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" Take a pointer to the given framebuffer as a private member for further use in later patches. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/mapped_framebuffer.h | 3 +++ src/libcamera/mapped_framebuffer.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/include/libcamera/internal/mapped_framebuffer.h b/include/libcamera/internal/mapped_framebuffer.h index 6aaabf50..75ac2c8f 100644 --- a/include/libcamera/internal/mapped_framebuffer.h +++ b/include/libcamera/internal/mapped_framebuffer.h @@ -55,6 +55,9 @@ public: using MapFlags = Flags; MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags); + +private: + const FrameBuffer *buffer_; }; LIBCAMERA_FLAGS_ENABLE_OPERATORS(MappedFrameBuffer::MapFlag) diff --git a/src/libcamera/mapped_framebuffer.cpp b/src/libcamera/mapped_framebuffer.cpp index f54bbf21..f5ee770c 100644 --- a/src/libcamera/mapped_framebuffer.cpp +++ b/src/libcamera/mapped_framebuffer.cpp @@ -238,6 +238,8 @@ MappedFrameBuffer::MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags) planes_.emplace_back(info.address + plane.offset, plane.length); } + + buffer_ = buffer; } } /* namespace libcamera */ From patchwork Wed Jun 11 01:32:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23513 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 B430DC3240 for ; Wed, 11 Jun 2025 01:33:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 436F268DCE; Wed, 11 Jun 2025 03:33:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="YDi4+18p"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7319D68DC7 for ; Wed, 11 Jun 2025 03:33:22 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-43edecbfb94so73698915e9.1 for ; Tue, 10 Jun 2025 18:33:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605602; x=1750210402; 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=6KiB9ywII9IRXnqC57gNGQqpupTJTpps3EfWunIFuPk=; b=YDi4+18phhX9mkXb/aXPo0QBS4lVbYp2kdf1eM3OzQjBa0+JO86EO9Xl/whRHRSchq 19qI/qyIJhHm1AaQ5QLoyJTyHgnW1s7bAAQafog8EtLGCjAkbXCbTi8hVvZvwuruMhgs q71GQhRn4TcgI7GQ4aVkdo4k+deK1v/CCeSZB+ChfPOzdBtdvp3S29bDERQvZaxPYrz6 f/F1L0O5hw3AvCZoL9hweszH6qpdMdgLkwc9C90N6nphhO52eX4UqcGpaYFSDfWvPuW7 tKaYGJTnVer9r79SSCVKhKBzViHOKJwgx6gkTt2NCQj5B7JG/pihE/+5gTTKXhfVsWEx nXZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605602; x=1750210402; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6KiB9ywII9IRXnqC57gNGQqpupTJTpps3EfWunIFuPk=; b=dpMECGqpQoGvoryZnIabsBL5u3niiQsXo0Q3WTZMIKLkfJiTxsqA7BPdFbokmRmE3y 9+kCpsYBsDP3yn2SBvC3kShBWqy7gKjrI2/zt9QPhOMbN8KesSURYEYi0nofwe9+oXNg zV0C/DV+3FSujH/Ee+Q768XDtFEpmsNkQZat2lyxYVUj1ft74+8PqFvWWI+5u7FKXh3l zlKDEU4nYnR+kot2gX8SeanWWZWbLVQzqPaCM5e4DkMZxTvJHf80w2PrAljp689GQYSI ZwN5pW8EEEP2kSM3nIyAffqhWYsoADfGGhNuxhPnFUPnEgyPTu9w/rOJQ0j3bhmkdx1q JC4Q== X-Gm-Message-State: AOJu0YzeNWMAIrkNtK4vUpkPIc6WOZagAJjGgtk4DwKm1qKL4dtWyfl0 TCLkfMkMVCI0HnkPpz2WmqeRL/ctPhkBoAoCa6l09GtTOfXBRFAac8+ijdeFAMHW8j+m6njAr+h kiNHApyE= X-Gm-Gg: ASbGnctbw8aR/IY2bYTJasr/TpaZed9V7EkKCdlKMShXna1qqapsVAftx7MdprizruI /LA1tq3jzfg48HN68BQMCmfGsM28DVawkFRCOTkY8QW0Y6V+Mr9hMPkm613SwcM0VlAjq5rrU05 +JHz8gN6w1rFEyXir68hMD8KIh7/v/j8644Xm53Whth96+3BsHrDXDrXiCG9TfWEA78mSFSiRl4 h7/mrXAycOoLxcBvdENGboHf6qYX/py/fB6S4YoucqNbHnoqDCI5x3QY3FPfRUTQrWqX85gSdfW nUfVFaVSQ95pROIQ0ag3gYpjK+et30rV3oTm63dTk46chQP4L1gXjAt/JfvTteLuMtmDEusj/Fq YAj6B2rYMVy5J6SPFTxT8kYjGpqAH7FWxy6n0RetF2l9JDKkbct5K X-Google-Smtp-Source: AGHT+IHG6o1lWgKjFkO65nblYC4PBeJ+oTxVgOtKzceZofNTsuR8EJP7WC81gyuvynQ6g/3WQUu3dg== X-Received: by 2002:a05:600c:1986:b0:43c:fda5:41e9 with SMTP id 5b1f17b1804b1-453248f424amr9771575e9.31.1749605601733; Tue, 10 Jun 2025 18:33:21 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:21 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 07/35] libcamera: MappedFrameBuffer: Add MappedFrameBuffer::getPlaneFD() Date: Wed, 11 Jun 2025 02:32:17 +0100 Message-ID: <20250611013245.133785-8-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add MappedFrameBuffer::getPlaneFD() which takes a plane index and returns the file descriptor associated with it. This fd will be used to feed into eglCreateImageKHR for both texture creation on upload and directly render-to-texture where the texture buffer comes from the fd given to eglCreateImageKHR. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/mapped_framebuffer.h | 1 + src/libcamera/mapped_framebuffer.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/libcamera/internal/mapped_framebuffer.h b/include/libcamera/internal/mapped_framebuffer.h index 75ac2c8f..9a5355c7 100644 --- a/include/libcamera/internal/mapped_framebuffer.h +++ b/include/libcamera/internal/mapped_framebuffer.h @@ -55,6 +55,7 @@ public: using MapFlags = Flags; MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags); + int getPlaneFD(int plane); private: const FrameBuffer *buffer_; diff --git a/src/libcamera/mapped_framebuffer.cpp b/src/libcamera/mapped_framebuffer.cpp index f5ee770c..d5f347d4 100644 --- a/src/libcamera/mapped_framebuffer.cpp +++ b/src/libcamera/mapped_framebuffer.cpp @@ -242,4 +242,9 @@ MappedFrameBuffer::MappedFrameBuffer(const FrameBuffer *buffer, MapFlags flags) buffer_ = buffer; } +int MappedFrameBuffer::getPlaneFD(int plane) +{ + return buffer_->planes()[plane].fd.get(); +} + } /* namespace libcamera */ From patchwork Wed Jun 11 01:32: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: 23514 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 21315C3326 for ; Wed, 11 Jun 2025 01:33:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8D56268DD2; Wed, 11 Jun 2025 03:33:27 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="iU/7qkHQ"; dkim-atps=neutral Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 81EA768DCA for ; Wed, 11 Jun 2025 03:33:25 +0200 (CEST) Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-43edecbfb94so73699135e9.1 for ; Tue, 10 Jun 2025 18:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605604; x=1750210404; 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=1JOyJ0DIm6FCLhp4r1H55WC7og1e2fTC9EjR+qyZDhw=; b=iU/7qkHQYUG7PoqOeUpFFNm0Cb2eQRd6MP9x/Aj09t6oNsJqSkA3/Lniiq9IuhseA8 avM8MjbykgBfgubzy/tZW/vZQhPn4bJkV3gGbrmDdksPGPoQrlOopzTfQGrcYDTSq+Vg KhOnY09lQOAvYrhqbzS5h8dCwlwMDgbYFbVU6WEcWz7tHG4ff0OroPdlk9QkLB/Z2cTm 7tPpXkDVWz11CNjrYr7i5VUrkEhVqlO+NC7vKn8hHUhBpMUr7MyIfuixtNluzWuGR9Ao 9cBIv8o5GCfMrh7laUEHTzXHwGXAFbwwGMFHDaulrugdXILpuSWbmMrOc7YqTDQzLgWk kUpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605604; x=1750210404; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1JOyJ0DIm6FCLhp4r1H55WC7og1e2fTC9EjR+qyZDhw=; b=WRI2EoI2wqhtQqEV5rhRxFBjfSmtmIe8vQxFuWl5iH2AHCFfTNVlUEg2RDo7nD5czL +6JTZKodWVOvqrDysg7bPwVaJMkUjeVeRcmaQAi9vaDUFHX4EGIzNuWH5uVg3BszYyc+ mnn2q0Z7JPlroN2FuHGI1aOPJXV6kfxc+QKj61wQAP1iZGGcfxUaUjLh8qz+AyT44b3t +dkWHEQm/IBgFgq86v5o4uTB+wTIpwZm5kS4j/HjO2C6++i9dcl5EOJUb1ugQ/sTlfn6 GppgGGb2FxzXfIM3bHlEjzcC6r/YH8Xj+4ImunmKiF644g/u1mdn9lrGsvAzKcuOFda5 DDlA== X-Gm-Message-State: AOJu0YywPM1cM7PF1EFKJJsyflwbbx7mQgk40WBHj8l3sXHYDA/CwtoG XyQkQyZN7CmowKj/TuDsNzDgrkvurlaL0+4nEy5R0L8u8TAHk1jdLz6OKhh7C7tIR6OP8SLYSmG Im+Tu/H4= X-Gm-Gg: ASbGncutoqrZsOkU/K3JttQeIZgtGS6bB93Aeu7d/xIUR5NH1mIHK1YK4UPCTjs+ZAZ ZFsqOFaF6B+mseM3iAoZP+Iei9bbbP09LgoJb1S0MjmvDv9wjbRwhDT9bEsRIatdykQtQtS/kWM m0zDtnW45Wy+M8koTEPsHE+qf6Iv4Q/dV//687utfZbsOnO+UZHE/jRjMxZ35E3hQxrBNGiPyy5 un9H0USbKeY1lPj2P2aVCFabfhrTY3pKJM/aXbqFy2c904Ext/JeFlKuSQaYhLIFGbq/mG8T14O 5fle6HtR59bkY3hbY77nqL+5Zcyw+gxCoyuTlvVrDrM5yOSVL6arxcI5MkJ6DCVgRMkIuvmnngd jmSk0uH2wQqYBdmDd5JiJi9rWDUX3xg8Ou58rJQt2Lw== X-Google-Smtp-Source: AGHT+IGym948NlpHWXWR8q20L4SDDBsI7bA0Pbfsm3lLFFNZnxE5m3nod3wJoQc0Oj6p8tOe2UI3Ig== X-Received: by 2002:a5d:584b:0:b0:3a5:3bdd:6cfe with SMTP id ffacd0b85a97d-3a5587fb627mr851880f8f.26.1749605604324; Tue, 10 Jun 2025 18:33:24 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:23 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 08/35] libcamera: software_isp: Move useful items from DebayerCpu to Debayer base class Date: Wed, 11 Jun 2025 02:32:18 +0100 Message-ID: <20250611013245.133785-9-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.h | 33 ++++++++++++++++++++++- src/libcamera/software_isp/debayer_cpu.h | 34 +----------------------- 2 files changed, 33 insertions(+), 34 deletions(-) diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index ba033d44..45da822a 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -14,11 +14,13 @@ #include #include +#include #include #include #include +#include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/software_isp/debayer_params.h" namespace libcamera { @@ -27,7 +29,7 @@ class FrameBuffer; LOG_DECLARE_CATEGORY(Debayer) -class Debayer +class Debayer : public Object { public: virtual ~Debayer() = 0; @@ -45,9 +47,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; /* 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; + }; + + 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.h b/src/libcamera/software_isp/debayer_cpu.h index 182607cd..0b4b16e1 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -17,7 +17,6 @@ #include -#include "libcamera/internal/software_isp/benchmark.h" #include "libcamera/internal/bayer_format.h" #include "libcamera/internal/software_isp/swstats_cpu.h" @@ -25,7 +24,7 @@ namespace libcamera { -class DebayerCpu : public Debayer, public Object +class DebayerCpu : public Debayer { public: DebayerCpu(std::unique_ptr stats); @@ -48,13 +47,6 @@ public: */ const SharedFD &getStatsFD() { return stats_->getStatsFD(); } - /** - * \brief Get the output frame size - * - * \return The output frame size - */ - unsigned int frameSize() { return outputConfig_.frameSize; } - private: /** * \brief Called to debayer 1 line of Bayer input data to output format @@ -111,19 +103,6 @@ private: template void debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]); - struct DebayerInputConfig { - Size patternSize; - unsigned int bpp; /* Memory used per pixel, not precision */ - unsigned int stride; - std::vector outputFormats; - }; - - struct DebayerOutputConfig { - unsigned int bpp; /* Memory used per pixel, not precision */ - unsigned int stride; - unsigned int frameSize; - }; - int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config); int setupStandardBayerOrder(BayerFormat::Order order); @@ -139,20 +118,11 @@ private: /* Max. supported Bayer pattern height is 4, debayering this requires 5 lines */ static constexpr unsigned int kMaxLineBuffers = 5; - DebayerParams::LookupTable red_; - DebayerParams::LookupTable green_; - DebayerParams::LookupTable blue_; - DebayerParams::CcmLookupTable redCcm_; - DebayerParams::CcmLookupTable greenCcm_; - DebayerParams::CcmLookupTable blueCcm_; - DebayerParams::LookupTable gammaLut_; debayerFn debayer0_; debayerFn debayer1_; debayerFn debayer2_; debayerFn debayer3_; Rectangle window_; - DebayerInputConfig inputConfig_; - DebayerOutputConfig outputConfig_; std::unique_ptr stats_; std::vector lineBuffers_[kMaxLineBuffers]; unsigned int lineBufferLength_; @@ -160,8 +130,6 @@ private: unsigned int lineBufferIndex_; unsigned int xShift_; /* Offset of 0/1 applied to window_.x */ bool enableInputMemcpy_; - bool swapRedBlueGains_; - Benchmark bench_; }; } /* namespace libcamera */ From patchwork Wed Jun 11 01:32: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: 23515 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 146E3C3324 for ; Wed, 11 Jun 2025 01:33:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id AD79568DD0; Wed, 11 Jun 2025 03:33:30 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="azb/5Mdi"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7367E68DD1 for ; Wed, 11 Jun 2025 03:33:27 +0200 (CEST) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3a503d9ef59so5107789f8f.3 for ; Tue, 10 Jun 2025 18:33:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605607; x=1750210407; 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=MnMhF/Y9/Rt41akuVWJPY/Wx/I+HkuTsZYCBn4kRXXw=; b=azb/5MdiG1QgwEY9nf3pUHiduUYRzk/goEEPKrwJfwIMqSAalrV2o434Coi03+WWPK sVaJ65GU8B1ebxp2/RxccCGXhe6wXqyDIVW6dKmtzITODUCEXJBr3GixYhDWHOwEDzfV MR9R+IOrP4rRxGmEhZSBQyiXWQcU2tgGZly34HDHrAMdagjm2cVx14iUQGRd9/qG4DER u2riStg6PDFXlCTq+xcXhb2UDSxtNiRJWuDfrei4OZXpGdxY5nRpFK8wuAo2PZfIDJPn 35+UEmBJGMC8sknelwLa/dSv1ipV42KIIHRwpg+g2n9ePRtR2tkXJxFbVFonCrfsS1TS ipGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605607; x=1750210407; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MnMhF/Y9/Rt41akuVWJPY/Wx/I+HkuTsZYCBn4kRXXw=; b=cMGxwIdcyAbcl9aRD7ljvuFOQbS+35lF2Sis27WKvrXiKS5LA3cC09Ssw9JhKEqsOc t5YSIajMmN4LDVtpxFpbrE/CE3K4L8drHyuttdea++gUyXdIFJis7FP610BL5NsbJuH1 mfoTodukasTnMQ/f5WIlOfN8QZuGF2CjVPREDk9ofX3Iu2M6SgmVBWwf5T6COYa65Dd7 BOYYcV1cgjhaXPCGwqyAM0AMbKJKYWBjE6KxLwd2QjTWO/AxVdxn0bvoTGOxw8kPw3i9 C5oAmz0wct8qgbTRIl0un8urhmHa2QvjxQ8EEPwznjgwTAEKnMjWxFDG4CI4b/CVaqrQ X+cw== X-Gm-Message-State: AOJu0YyStGF3jMwgYQ4I5q2AjwuW/7Hw5oJ+PDry35bcW7ftwJTvLMJO zQsSu3HqD3CzrbA5MtBawzmOgIX75Wppn8SodDlXuBwSr/ozpSgNWYUHpsbGAkyt0WaLydCIwtm gpjro2xE= X-Gm-Gg: ASbGncvvfkyzzXh8YoDvc4eDb1ACH54hnYBEwXMJjNFjDe6DqG/5KQrE/0ljdaLDicl WeP3b3Y0F1bmssaq7OFfVXvIaw/EoKTZ2GjjkQM6wRgWlmEKcoU7kBj0bFXltTPTD6PR4II3p1f UGgB0VWngFxMPdEdaw71ZNXcwpg1M+6Wgu8loCXdkDFRHklnc5TQdjFiwJnIBJNffNkDawQRobx fGdgmmhF1Uxqo29UIIcRThwgqbWFNs0/fNtwGRRhiduh7jrJoEuSy91R8oenb15IWR6DvzwSSjE r6Yj+ODHR+UVnDP8Jvsn+Z8j536VusxExP6/1ZWCoKkbDBtlZYhWWdsos6DfMZcVQ1hXophtwiV q2qFNq2o9TDV+hoKPfp+aEdiSUO1Nbf5pinHwWcMLuw== X-Google-Smtp-Source: AGHT+IHjk69XazhQiHZBnggSa2PkcljqojJYjG6+qhg8ENnPUiVkeN8WuTou7kLmgB5t6YyhFk63wQ== X-Received: by 2002:a05:6000:2307:b0:3a4:e480:b5df with SMTP id ffacd0b85a97d-3a558a1aee6mr786163f8f.44.1749605606811; Tue, 10 Jun 2025 18:33:26 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:26 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 09/35] libcamera: software_isp: Move Bayer parans init from DebayerCpu to Debayer Date: Wed, 11 Jun 2025 02:32:19 +0100 Message-ID: <20250611013245.133785-10-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Move the initialisation of Bayer params and CCM to a new constructor in the Debayer class. Ensure we call the base class constructor from DebayerCpu's constructor in the expected constructor order Debayer then DebayerCpu. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.cpp | 11 +++++++++++ src/libcamera/software_isp/debayer.h | 1 + src/libcamera/software_isp/debayer_cpu.cpp | 10 +--------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index e9e18c48..29fdcbbf 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -103,6 +103,17 @@ namespace libcamera { LOG_DEFINE_CATEGORY(Debayer) +Debayer::Debayer() +{ + /* 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 45da822a..01b6e916 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -32,6 +32,7 @@ LOG_DECLARE_CATEGORY(Debayer) class Debayer : public Object { public: + Debayer(); 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 8d30bf4a..13db8a8c 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -40,7 +40,7 @@ namespace libcamera { * \param[in] stats Pointer to the stats object to use */ DebayerCpu::DebayerCpu(std::unique_ptr stats) - : stats_(std::move(stats)) + : Debayer(), stats_(std::move(stats)) { /* * Reading from uncached buffers may be very slow. @@ -51,14 +51,6 @@ DebayerCpu::DebayerCpu(std::unique_ptr stats) * future. */ enableInputMemcpy_ = 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 Jun 11 01:32: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: 23516 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 60CD1C3327 for ; Wed, 11 Jun 2025 01:33:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CED3A68DCE; Wed, 11 Jun 2025 03:33:32 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="v+pfrmHa"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 06FAF68DD0 for ; Wed, 11 Jun 2025 03:33:30 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-450ccda1a6eso56809745e9.2 for ; Tue, 10 Jun 2025 18:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605609; x=1750210409; 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=9PVu7x00JvXUNXl45gheWNt7X7t7eecspR+1Or+mgZ8=; b=v+pfrmHa0yl8WJ0hwuUFpkHITr9LfGcDU+Ninvz90xjdbDaBAmgi3VGSzM5FJx+8iu 6SascQO0M84HEQnJOvLGBR2hYqIRbmX2VZgTwu2ZhJOef9ESFxg136Gp+Ep1CMoKU/FR tgrYUzxuk5zV+TmXpbEjnuWHllUvcIODPzumr4r0gbqv2v+RMmH8e68YdWQX7NaXkaLy sRZ93/fL63JOBV6GntEl18DNJ8Givny1e7pqCou//nQc41PFBfwfdqheVircDQ0xmHQl hTcgs31CFhMjvI2lkyAlNKpruQoccK3qLtcliIirbWkI/HJm/RcXI5xfuX7/tu2bmbYA 2KOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605609; x=1750210409; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9PVu7x00JvXUNXl45gheWNt7X7t7eecspR+1Or+mgZ8=; b=g9KlqQ0gkt6QPXkxXb3hTmb5SvOHY2aUV7mLTYnD/pGRZpg1vadZEvDHEYFFbhNOMi 8oV2zMKDdq7wLaM4uImEQvDep1Qo6he+JjWl+EaDoqjsg8U4UvKImFJxGX7nkM4jzu0F lBRUqA66PB/6+p6JK5q0G2Maf2VNoMQzcNOPG8BXRCW3ng4l8fww2XxBqOlz2LzkZxde z2o5pMsW0+Imyfw1Gv5UdcKuRzMYoV7bhX72P/INomY4wHqgnz8yWwcWwR4Am1JYdmS4 sXIDcNi+9YyJQfc7PfluTZCLrd7J4IIynX+tXilnPxHAo/rWX92j3dzTje8JX0zqKiYl FBFw== X-Gm-Message-State: AOJu0YxoEtgpNSdWLPOKo0Gyj9YN3L0gmA5zoJ8IFwZ7AbVMN7PpHHC1 BHThuUKIY43t0Qg+Dk4MkGWRDRysu/p0zVmgk/MhGPkA7rFJdMV8yZcPI2A99janNCCgWfoHiha 2gXIi+oE= X-Gm-Gg: ASbGncs51d654lEl8xUUmTgjpfZyE9D1l/WmdvLob+RxXAlmUmjYiEyDH/ueLc5vLEt 0JWzZGAbUNC3hf6Debu9C1uy1MmTYeYpdpPdGxUNDLuckY26KYc0EOuejxupA9JrJwapEpkLkrI vAQKVbA/PhM+34RsrSV8XvxgEvLAawV6vl0mbLaA6SrWqOKZWtZIaBc4NXIX7Irhj3Yzg4CXu3n xv3wupff72i+x+4EUZ5Hyz3AxF283fEvEn8m+R1FYoEzIgY2qJTvN7H2M6BWvnE+Hi++/+s81zI W1YJzUw+GddeYj5In4FF2fcEOoZWfQN6qJ2I8GHN0ZYE2dRPzMuO1qOhxCaExjBt6tRp7KqqxUC ARf8Wj5t+aBIYnav/jZu275pvyQCwduYAAXRRL6pawg== X-Google-Smtp-Source: AGHT+IH1pjZUNAWQum5V8DLvmjxoGKt/RBAENA6acO4UcvGrZYV0esNj4/K6d9O75I0FJ7DNEV12RQ== X-Received: by 2002:a05:600c:6986:b0:439:9424:1b70 with SMTP id 5b1f17b1804b1-45324f6a144mr6240575e9.30.1749605609353; Tue, 10 Jun 2025 18:33:29 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:28 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 10/35] libcamera: software_isp: Move param select code to Debayer base class Date: Wed, 11 Jun 2025 02:32:20 +0100 Message-ID: <20250611013245.133785-11-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Move the parameter selection code into the Debayer base class in-order to facilitate reuse of the lookup tables in the eGL shaders. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.cpp | 40 ++++++++++++++++++++++ src/libcamera/software_isp/debayer.h | 5 +++ src/libcamera/software_isp/debayer_cpu.cpp | 29 +++------------- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 29fdcbbf..75e4bffa 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -187,4 +187,44 @@ Debayer::~Debayer() * \brief Signals when the output buffer is ready */ +/** + * \fn void Debayer::setParams(DebayerParams ¶ms) + * \brief Select the bayer params to use for the next frame debayer + * \param[in] params The parameters to be used in debayering + */ +void Debayer::setParams(DebayerParams ¶ms) +{ + green_ = params.green; + greenCcm_ = params.greenCcm; + if (swapRedBlueGains_) { + red_ = params.blue; + blue_ = params.red; + redCcm_ = params.blueCcm; + blueCcm_ = params.redCcm; + for (unsigned int i = 0; i < 256; i++) { + std::swap(redCcm_[i].r, redCcm_[i].b); + std::swap(blueCcm_[i].r, blueCcm_[i].b); + } + } else { + red_ = params.red; + blue_ = params.blue; + redCcm_ = params.redCcm; + blueCcm_ = params.blueCcm; + } + gammaLut_ = params.gammaLut; +} + +/** + * \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 01b6e916..0af66b55 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/software_isp/benchmark.h" #include "libcamera/internal/software_isp/debayer_params.h" @@ -82,6 +83,10 @@ public: private: virtual Size patternSize(PixelFormat inputFormat) = 0; + +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 13db8a8c..4ef573a3 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/mapped_framebuffer.h" @@ -740,30 +739,10 @@ 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); - - green_ = params.green; - greenCcm_ = params.greenCcm; - if (swapRedBlueGains_) { - red_ = params.blue; - blue_ = params.red; - redCcm_ = params.blueCcm; - blueCcm_ = params.redCcm; - for (unsigned int i = 0; i < 256; i++) { - std::swap(redCcm_[i].r, redCcm_[i].b); - std::swap(blueCcm_[i].r, blueCcm_[i].b); - } - } else { - red_ = params.red; - blue_ = params.blue; - redCcm_ = params.redCcm; - blueCcm_ = params.blueCcm; - } - gammaLut_ = params.gammaLut; + + dmaSyncBegin(dmaSyncers, input, output); + + setParams(params); /* Copy metadata from the input buffer */ FrameMetadata &metadata = output->_d()->metadata(); From patchwork Wed Jun 11 01:32: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: 23517 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 40849BDE6B for ; Wed, 11 Jun 2025 01:33:36 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C5A9568DD4; Wed, 11 Jun 2025 03:33:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="a2vbkabs"; dkim-atps=neutral Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2F08E68DB2 for ; Wed, 11 Jun 2025 03:33:33 +0200 (CEST) Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-3a522224582so3747717f8f.3 for ; Tue, 10 Jun 2025 18:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605612; x=1750210412; 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=JjePieBz4pX5XcPOXe5ZT860B9wWo/28zhPisqyyZdY=; b=a2vbkabs2PZVH9kjsGXB3Zy5KqSHDLHMVlYiXGv117ygxQ+RX5FcdJhR/2usRRakAt 8sJ0/7I02tvtOeyFUrxoIgZy8O+8lbr0bv0VE0/tLvPUC5I7Bu05jWkRFOhZZvaHmEG5 YPr6b8A2jj4wgrxrCDTeiqI0nT34KQ4RgQV792rEjTrPYKyngX7Hm0n45wHeoh6VNEwQ NFoVxyswDgxLVAp591ehGbo0r+dhRNPVyJb+3Q7G66NFRnhE4+frFVJLfmJ34+mB/hPB Y52O+0rCm2L1f6hVQ5dmjDfWYzGYQo6Dldhw5TQwW6VN6CXNHmVITWkWIXtgAU6IYS+v U+vQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605612; x=1750210412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JjePieBz4pX5XcPOXe5ZT860B9wWo/28zhPisqyyZdY=; b=gNIsQsyH/T27M4fUDzZwv0QNJeRDgSw/y9X6MvcyDaXIs+OSdwlPob6nZrJZfNxZVG Q5p5tn9rqqwrBnVCWiNhJWp5XPWxcieHEn952OXhB+HmJjVKyN+pnxd93+Mx3phuT/1N Fd1kolpTvur5KDkDq+1LaWcf5ucNpo2CtZLSqfqCDLmVt7HRmEAJ9C6fFl2Wuqh0GaAC EIu6tNFJBLiyubsAN34sNseGjRdZPec6Yf7rGBmgWXhjcYl/gfsk3CmRpaBwRbrv4Uvj 3QhWQPcOXnmhhkvVDaERALISrdkM6s1c6tPZXQrrm7Mr0rj4ndWVZw+a4iscRVPa+nZU Mj1w== X-Gm-Message-State: AOJu0YxKL7IUyXr6GZTCuWIiWRWZaEvWXhjs/1eYcIV1HLhGH8sBSgR1 gZFT9Nr453XL0UV2+SUWKxEfd4bokpEAKAuyNuAYoC78BmvjM6CZwn54iOW5m30vH6sICBdUpaC HF0GtTFw= X-Gm-Gg: ASbGncuVSUYK/EMqLVQ/DKssBj1s3uSTYre/uPdNhC+NvYjwpJ4Jiazti4sL3rBAH1v dwmMenwAv2oTIcILDQHy3OGRPJjd9KSeN+uH31Ido/eZKUhTQdSFcaYxJcqIsHfYi+VkXYxzjHq 9w7yCWh19doI9mqNJyopFXz30D2+FWJu5HsmnhwXvykczfMjk9hkOnGq8fXfPDbQ4Ip3vItrzZ3 p1NipXSTDfd4ZFBZdATkghq+/sfZbcGfl951fCjIs8dMdtfOmyljtJBPz6Li1PHVemixvye4Ld8 hz9DxmOY9K16jeNEGH5uoIgvaJMQHfplqiFZ9xwFjQMy8C2hmKjNajOB84nrpx14qpAwY+tFxY0 Oj5gBs0AssOcURF1oTsrpN7i+HnYXmCnbXApvwMTU6g== X-Google-Smtp-Source: AGHT+IHCga1USqrL90WhvME1stAfaKs8vsA1Lh9cd7Emy1+37z8kfvzdg8QqGVlX5lNe8yeJl5J80Q== X-Received: by 2002:a5d:64e4:0:b0:3a5:39a0:2309 with SMTP id ffacd0b85a97d-3a5587ffd85mr812425f8f.55.1749605612500; Tue, 10 Jun 2025 18:33:32 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:32 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 11/35] libcamera: software_isp: Move isStandardBayerOrder to base class Date: Wed, 11 Jun 2025 02:32:21 +0100 Message-ID: <20250611013245.133785-12-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" isStandardBayerOrder is useful to both CPU and GPU debayer logic and reusable as-is for both. Move to shared location in base class. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.cpp | 10 ++++++++++ src/libcamera/software_isp/debayer.h | 2 ++ src/libcamera/software_isp/debayer_cpu.cpp | 6 ------ src/libcamera/software_isp/debayer_cpu.h | 1 - 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp index 75e4bffa..d0e17d20 100644 --- a/src/libcamera/software_isp/debayer.cpp +++ b/src/libcamera/software_isp/debayer.cpp @@ -227,4 +227,14 @@ void Debayer::dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *inpu dmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write); } +/** + * \fn void Debayer::isStandardBayerOrder(BayerFormat::Order order) + * \brief Common method to validate standard Bayer order + */ +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 0af66b55..214bcdd3 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/software_isp/benchmark.h" #include "libcamera/internal/software_isp/debayer_params.h" @@ -87,6 +88,7 @@ private: protected: void setParams(DebayerParams ¶ms); void dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output); + bool isStandardBayerOrder(BayerFormat::Order order); }; } /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index 4ef573a3..e5649284 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -282,12 +282,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 diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index 0b4b16e1..a043a954 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -17,7 +17,6 @@ #include -#include "libcamera/internal/bayer_format.h" #include "libcamera/internal/software_isp/swstats_cpu.h" #include "debayer.h" From patchwork Wed Jun 11 01:32: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: 23518 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 AE7EEC3328 for ; Wed, 11 Jun 2025 01:33:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2276568DD1; Wed, 11 Jun 2025 03:33:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Yaii2vC0"; dkim-atps=neutral Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D991E68DD7 for ; Wed, 11 Jun 2025 03:33:35 +0200 (CEST) Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-4508287895dso2307325e9.1 for ; Tue, 10 Jun 2025 18:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605615; x=1750210415; 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=wJmpJgXrFEG5KEN1zSnXvlqRixc3EGKyYYkVA8Fbs4k=; b=Yaii2vC0X+c9Nj1ZS3kyd2tljheXQL+05HgXcw9hirnFOvC2YjRIsfOzGU6fiLYAVW HRffkgNEbZklt1ZKTEQ3EEufNn72uOZdV+Ou+rum/03TsYElNuO/z7HA4JvjvG8rxF/y U78i7mVQPK7Fow9NbC97k2eIydD0GjKSNEkA5m4e+PZ2KG1xNPLm3rLw3agtayAL3Mo4 bBbxdIeIEk1D9vABn2SHBqdoA8GYgGehoc5Lr4Wi5XbZCctX61BvWKeTkxy3+iPE1WpI fj02dCSI1PHd6gcxW+3QI7SuWJrR2t1c0ccrP+G0bD+W+nMWrfj4bdn+tXq2yFkekVIo hpXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605615; x=1750210415; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wJmpJgXrFEG5KEN1zSnXvlqRixc3EGKyYYkVA8Fbs4k=; b=mlZeO3ECSBI6O/KVKl9myZrWjI82xM6VuWflHn1ucuGc+pKZhoNt+mgM13iFKLztkg 60j6c1oFm/VrS0KBfFMgMdmxp7OdL6PX/Itg+Ut63sCwa5HFK1wdzt5Bv+LLqEoO34+b jKbUFj3sioSIv7HixqNryfaZfG7fSvegZor6cnjl84Ymt54W9wANIyxH2wOIEn4ZVumK HWZTIAsFALrmmhukddoYbh8TKFnuW21lljpM571cbwuiCRsFtoTGnR56qie9zlbtzEHF wvFkg4C0k13r9flA0fTYrPe0A/O/SyxkdplQrkPMDtdSu1uYAeUivjRdtkujxxjQTpwP QE1g== X-Gm-Message-State: AOJu0YzIh5YaoD3JeqHn/Zd2qLe32JWxjU2/nBjj5DPj6en2rG6foJ6p vt+qZ6WkyrlXDVArV8pxqv8psJr76yvVOSa49OhzqfUHhhF76n/dVyhybH1O950IAcu6yj5lUio Z3SHa7R0= X-Gm-Gg: ASbGnctB9ZdAtXCV+QHMf0vd/aKcbw+DVqChAzGcQa4saSrDalXYwZAQtFXNrv2n83s Gxxin+JJxryBtVSTk2/0aHu6Hlrnh0UXWbAuZSu0Zlg6WOGQsWbX8JlqOrDiU9ADJk76ceRgC3I L64vUQPO9RnkahkFwZD+4IsJmyf4r8Uc5ICCKJS21HTiO5fRDQNXYsOlGmno1IuvjUCuH8utQHf r8dQ6bZA4ABL5o8eBZ82MHTcOKaredQWEOLpWod5wAmb3rqo2OD04fnc+5cbeWoYED8wYiRODjA dqNosGMtseuudh3jTXLULMEaFjWR2rxmarXBtPv1tXUPuf5JirzDYLvgrO4ErUrwrCMh+QCHx7p y4BZbHSrdjzmeZhhxvTO3omEQs7pW/+3btKgX/DP00w== X-Google-Smtp-Source: AGHT+IFX33Ge+A79gy1L3x3sARL5/59K/DSecbNM4W/0WwlBDjTHvkWhoHdPaZHXe9qQWTrCSyknUg== X-Received: by 2002:a05:600c:1d0a:b0:44a:b468:87b1 with SMTP id 5b1f17b1804b1-453240bf6d3mr12061455e9.4.1749605615215; Tue, 10 Jun 2025 18:33:35 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:34 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 12/35] libcamera: software_isp: Start the ISP thread in configure Date: Wed, 11 Jun 2025 02:32:22 +0100 Message-ID: <20250611013245.133785-13-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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" OpenGL is not thread-safe and in fact associates invisible handles with the threadid of the calling context. As a result we need to make configure() and process() in SoftISP execute on the same thread. Move start thread into configure() as a first step towards this. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/software_isp.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 28e2a360..7bee8f06 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -159,8 +159,6 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, metadataReady.emit(frame, metadata); }); ipa_->setSensorControls.connect(this, &SoftwareIsp::setSensorCtrls); - - debayer_->moveToThread(&ispWorkerThread_); } SoftwareIsp::~SoftwareIsp() @@ -262,6 +260,9 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg, if (ret < 0) return ret; + debayer_->moveToThread(&ispWorkerThread_); + ispWorkerThread_.start(); + return debayer_->configure(inputCfg, outputCfgs, ccmEnabled_); } @@ -343,7 +344,6 @@ int SoftwareIsp::start() if (ret) return ret; - ispWorkerThread_.start(); return 0; } From patchwork Wed Jun 11 01:32: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: 23519 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 5E42EC3325 for ; Wed, 11 Jun 2025 01:33:41 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DA9D468DDC; Wed, 11 Jun 2025 03:33:40 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="RUGbdXj6"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A38468DC9 for ; Wed, 11 Jun 2025 03:33:38 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-43edecbfb46so51410865e9.0 for ; Tue, 10 Jun 2025 18:33:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605618; x=1750210418; 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=GKpObFN+EgBcQyqBbRGy4fFnCArup6QMMSIFijPSPfA=; b=RUGbdXj6qrDIj7nS+t8duxhwURkuyTq2by7gx0TkHofGyiW8DDZRYUMHj/vGy1izzk LZTd9wMg/OLqKfeV3mmXRKVYwju8gZy/xYWOw2p3EH+v7oUtYyR40JIyGWRrlwsVifQk tPC5MEof30KXvkfnFgjFXVMr/HXm/UZN3//nOdUZCZR1bJ/JFFg/zHajdg4idCkHh7/N iHnwEhq5zE4wnj1Ny4K54fehn83cbF2N41yVJBM0UDGSF1B6U+avVuJI/bOVkVdew4sH 6ueJpA1OI9hBuK9FeBWX/poMhLPPbKaKUk/xzbzJZ4G1l0Uyxzks53jjXDaZLs5EYjiH NQ9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605618; x=1750210418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GKpObFN+EgBcQyqBbRGy4fFnCArup6QMMSIFijPSPfA=; b=bDZvuA9METq+tOxGjngc2k3FhoPJ1NRnuMKQMdQEXOblbCbgD8wnQQ7nRDu+CZJNaQ ac+aIPAPgahw+OWSQOecxnQOk8eif7g5WU0+vwp2v7BOzzN7k/YGdCAsBf1ZSJbJkIh7 plEOy9w9LrHl7klN69+qzB3h2BQ+fyrJFi3jhrZfPn+NLRDk8olsqUwZcWQRExyS+xgx coFXDZeYtYLvqmItiSRn313BGTLz/qdyTfhYrLKe+5MKEREJ3Ltf03zwX1XEqzE0RtDq 9r5qCzDgELr+dD5xuuaN7V/+69Xy0nfxS3UpBIV6AlZNck3NYyG54IYQ+mn4u1SuAOO4 GI6w== X-Gm-Message-State: AOJu0YzO1h5D0pQOMNapVZMvY6iJkICQuMWMbwGizcpik1uzY9PAzNvC U4luJ2COOVZ9IYuqKYO9iuCui8QLPgpC9cUOqzStceJFRNdbiy/tyXgLzmvS5cXBiw0O0HqOT7L fOiZmUAY= X-Gm-Gg: ASbGnct0gHCgkhqvm1T5ZethbqY8OUL38QZO610F6/tl9UiTK1bmRgV4wAmrd/8sPXt p5KbihQNuO9MNsz35k03tQEGcRBgvRovQ5oaOKSg0GoZ5IsA8+JcOYQy6k33WzAev6APJVVkACq 2eWa289vUiRYhBb+5XFHZKEqhYCNi1RYuiz6Pna7NhH2lecuAfs54teh+4cta5R3hsMnmgUdrCf NruH5iiD+7H6QO2pqxLuHg78eqcOh/CiDV76vAlPiL8V8al4D9Tqa+vsUX29VzxJTCyl+5cdvPh yagJ2D1HPpa2gP4+J/AFVh2rj9d1Prb7VA64CFb5dP15qyPzeWgad3MtCCrdsZ7uhZJ3Cs5AV1Z 2WWAtBQEO1bOWTLsWJdOvn2NthlQ/MpvitLo3Oaf4cQ== X-Google-Smtp-Source: AGHT+IE9p03Zk5THt1Eqr79NheVJlXFqjchU2l+c3hdHz65PA6lX0ZVL/vV1CrDTr7MsN0KHrW49Mg== X-Received: by 2002:a05:600c:83c6:b0:450:d5a5:e6c5 with SMTP id 5b1f17b1804b1-45324f4906dmr5725615e9.26.1749605617844; Tue, 10 Jun 2025 18:33:37 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:37 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 13/35] libcamera: software_isp: Move configure to worker thread Date: Wed, 11 Jun 2025 02:32:23 +0100 Message-ID: <20250611013245.133785-14-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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" OpenGL requires both configure() and process() to operate on the same thread. As preparation for that, move current CPU configure into the WorkerThread with a ConnectionTypeBlocking invocation of &DebayerCpu::configure. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/software_isp.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 7bee8f06..e8fa8a17 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -263,7 +263,15 @@ int SoftwareIsp::configure(const StreamConfiguration &inputCfg, debayer_->moveToThread(&ispWorkerThread_); ispWorkerThread_.start(); - return debayer_->configure(inputCfg, outputCfgs, ccmEnabled_); + ret = debayer_->invokeMethod(&Debayer::configure, + ConnectionTypeBlocking, inputCfg, + outputCfgs, ccmEnabled_); + if (ret) { + ispWorkerThread_.exit(); + ispWorkerThread_.wait(); + } + + return ret; } /** @@ -386,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 Jun 11 01:32: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: 23520 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 97BB1C3329 for ; Wed, 11 Jun 2025 01:33:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0254568DE0; Wed, 11 Jun 2025 03:33:43 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="oUWaLRyJ"; dkim-atps=neutral Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 32F2568DD7 for ; Wed, 11 Jun 2025 03:33:41 +0200 (CEST) Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3a52874d593so5840172f8f.0 for ; Tue, 10 Jun 2025 18:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605620; x=1750210420; 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=s22tvATEek2jn56FeC27txLuiJp6vxiU1oIGShzPMbs=; b=oUWaLRyJ9Fn0+RgznnST24t6s4viBXFaPEGy72q8D14K32f8rY5rTxisvUxdQc7TnP XFqslR1855rYTB6FkBXDc0RvE80nLA4vC948fgn4CBbh5ogfc7PyeUHq0RvEKAmx9gMU 3eID6mn4A6Zeko8OeCcu6NLMaV5/8ZJoiuqF46xe5uV9eXBNNEcDtFW9HDkJtRnJPbZB CE6T1rwLlJ+pNiVW3abAvqFmLmzvodSwPovEQn85VAQYAvFW5236ShmUPqmK4smMFa+6 sQt4xs7+vua6YmeWvfEH5BYZKhkBUq1eHB2I+hnYjZgQ69oWUAb4IjErnjLhMuSnwBe1 xseQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605620; x=1750210420; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=s22tvATEek2jn56FeC27txLuiJp6vxiU1oIGShzPMbs=; b=ECthVNfVwCdoC310oHffLK9GhNN6FB7IIva/eUOJzOBuLfYVbviQrzkackHcRVCL9c tfHxwoJKPAQV3lJHPHxVLOXLzxq/lKPGF0HQBFsBswV8NUZlzKskCu5DW03YY70cEFrm RqpzWa+3zBBcgZhGqMWEkJ18SJyl/ZsCxc+N2X/328BRpuaiunOAEXTM4+Oqs9IDIdXn hr+sDXMHQn8KTpc2N/Nm/7QC8GKqCuBqzG4PdTadHBWNoMvX2Hukr3KDGugHLK8rCGRS SWW/lg1Od6wIzyXT/rcMflXLh/O4YdbMWE6y/ybgRuDa8Z+oC4qRGzC8JSTmRWxmsYWZ dX8g== X-Gm-Message-State: AOJu0Ywy4RTV7CYvYQOUb4yk79ohb91xKq2cwASacn3HyV3PKR226jav sUUFDCJKXreCXKt9uRL9vey+gNgMyKhr80RG3CmFH5riaWlMn0cdkF+mT1ymY4+jShLZ+wKMqw+ YrCR21Q0= X-Gm-Gg: ASbGncsnU5HZsnJnBHu3pDnIkwz77DgtXacco318TlEEputHjIwfkxD5s8zFyfHomLI Q/HZiKCjHEbmSy2X1HAOq6c3zebV6/rv/bAFvjtBNxBxEMgSZexuV75Xlb7iTZWpPxfx3nbGOBR TTDImhDLZMDy+Pd+uW4O+GeEzdQoAGslR3791IiNvYILAoPTDKzJ7j2TOIm7MkQJCZWrIjM7rkN jrXErZas26tbhgvpM0Ve4oENsNq/o06xb7kwyB2S6Joalc8ze5oKaBftpaR5Ivx/DSpS3VR5hKQ fnRSeWCt1B5pZyO2LrAkRIYPY9W5gpi909hWIcLOcNZNWyZNmLFZu71pp9gLQeNFVXJrco18Thi n/lCITAVUjqzSletL/7MdvStzyb1/RQYrYvQU2UaR7g== X-Google-Smtp-Source: AGHT+IEIkwl/z/05CLCXhSFAjr7aozLOF6FCRRNNpg7OliIdNNPS6drV0ADoJjJRWB4FGUGGVrlYsQ== X-Received: by 2002:a5d:584d:0:b0:3a5:2ec5:35a3 with SMTP id ffacd0b85a97d-3a558aeca7cmr722591f8f.45.1749605620499; Tue, 10 Jun 2025 18:33:40 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:39 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 14/35] libcamera: software_isp: debayer: Make the debayer_ object of type class Debayer not DebayerCpu Date: Wed, 11 Jun 2025 02:32:24 +0100 Message-ID: <20250611013245.133785-15-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Make the type of object Debayer not DebayerCpu thus allowing us to assign the object to either DebayerCpu or DebayerEGL. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/software_isp/software_isp.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/libcamera/internal/software_isp/software_isp.h b/include/libcamera/internal/software_isp/software_isp.h index 78624659..ad89c9b3 100644 --- a/include/libcamera/internal/software_isp/software_isp.h +++ b/include/libcamera/internal/software_isp/software_isp.h @@ -37,7 +37,7 @@ namespace libcamera { -class DebayerCpu; +class Debayer; class FrameBuffer; class PixelFormat; class Stream; @@ -94,8 +94,7 @@ private: void statsReady(uint32_t frame, uint32_t bufferId); void inputReady(FrameBuffer *input); void outputReady(FrameBuffer *output); - - std::unique_ptr debayer_; + std::unique_ptr debayer_; Thread ispWorkerThread_; SharedMemObject sharedParams_; DebayerParams debayerParams_; From patchwork Wed Jun 11 01:32: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: 23521 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 2C52FC332A for ; Wed, 11 Jun 2025 01:33:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 52C4E68DE2; Wed, 11 Jun 2025 03:33:46 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="khRc6Ur9"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A330568DDB for ; Wed, 11 Jun 2025 03:33:43 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-43cfe63c592so69818325e9.2 for ; Tue, 10 Jun 2025 18:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605623; x=1750210423; 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=VlZsLSCI0eHbsP358YG7f0fZQe0fXQgP3U2V4cVsdEM=; b=khRc6Ur9DsSW4/OdElX+7SjuZ4S+TjsANsUEJHWoJunj8WUXeIWMY4ANY18XQhZI+m D8IxkalQgEMAmK1k8RJuxP8D1OuWgJqg0COTtD+UJiinFArzhhQPcWWYPv33Bv393fpW 2SHwlWc67259L4QQcGyGRKjRFLzQGeWatJb29S1TFxfbQcSUzb2JbGqvJCTb1WakEFg6 LBrGPBRJMqgC1wIbpldrbVyAsWIOfWNEeabv7q3KBOV70f+Z54gNxdaejmkEPEkH3e1i 7iWyUfDmXnVu3jm8CTy16jkXuXlb03sWNvrpoJUCkJo3XQa7FzIhaWcFfWwGtjE2oBCV VvrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605623; x=1750210423; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VlZsLSCI0eHbsP358YG7f0fZQe0fXQgP3U2V4cVsdEM=; b=GDDYLsQhyzqG+Pye05b4zu/41L14nFzliAybeGD0Yl24gJMz+mnDNGpw2t1DLYFQ9G bTD2d2sgKyyvUq/9Ln4qjZxKEZ+gKslZPNvy7GY/DhlEyvzefxuKJXjTgN7brAcNWiia /fOh6ueT47j1zlYmS4BJ/5kEp1Jo6kXcAlfSnS99HXJCEnIEl1OTJApgckTv1GbmPYC6 ewnfyX9cpC8dfur2Qzke2U9R173dGlzRRwrbjOQwoC+JT5QD0ifd6oFI1Tiy+HFyPhUK i52q1APghq/aRjvpQlcLsshrKYM1lV3fjNKQRWi5/XK4gCUq7+ZeuquY3ws5CqjhvdyM 8w3A== X-Gm-Message-State: AOJu0Yx1edJZxvEJh5Lc+ss2BATVuxspb/vDBUXJCERHC0luMATYP5j9 kvhu1eAJS6sSws4J262KblHmCoGGfukv1uGn9hzSCXSozXaI0GIwVpwsGwfGAvb/mLi4nCTut2f kpCthL88= X-Gm-Gg: ASbGncsbINaaad1LZHGfohcT3ieBTK0gEwl3ApLkf6O64++fhiYHLrUt18foh6zSsqz yXdsH27Yd1QZJZ03O0QHwjcgsMLiU5O3isnsjB5SY1z7DgWtS1ttUgpmPU32eKiVAKlugH9qnip RqwSdf3R5unYywxFc1rXyDL2MgqWL7o04Lw8U3zrrRVTptkDvhb3MluoKwZbasDyin4taLb+u7h k8BZVOiOCS2zUbhqdir8s8P79PSYBN/7Fq/vErT2Mw73bsSVWLo3mey6bO7B6f3+KgdyLltAsPg gML3qL6UIRWxoBk+wqkQPHyZWsB1460fkyjlt5CwyYbnyTRrNgPQuw+0eOO/9Hc8YFmT2AtNkc6 eF00iiHACAcEsetdJUGBiXA85RAIm83FQ4Dp92s72FQ== X-Google-Smtp-Source: AGHT+IEg2JpVH6FuD177YRJ21nHPTfoUW9hOUK7KvF/qaNQVnzahkE26wnDzvvB8fmag8s5AjS+uJQ== X-Received: by 2002:a5d:4563:0:b0:3a5:25e4:264f with SMTP id ffacd0b85a97d-3a55881dbcfmr690702f8f.31.1749605623040; Tue, 10 Jun 2025 18:33:43 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:42 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 15/35] libcamera: software_isp: debayer: Extend DebayerParams struct to hold a copy of per-frame CCM values Date: Wed, 11 Jun 2025 02:32:25 +0100 Message-ID: <20250611013245.133785-16-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add an element to the DebayerParams structure to capture the calculated CCM. This allows us to pass the CCM into the eGL Debayer shader later on. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/software_isp/debayer_params.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/libcamera/internal/software_isp/debayer_params.h b/include/libcamera/internal/software_isp/debayer_params.h index 217cd5d9..56803195 100644 --- a/include/libcamera/internal/software_isp/debayer_params.h +++ b/include/libcamera/internal/software_isp/debayer_params.h @@ -13,6 +13,8 @@ #include #include +#include "libcamera/internal/matrix.h" + namespace libcamera { struct DebayerParams { @@ -49,6 +51,11 @@ struct DebayerParams { CcmLookupTable greenCcm; CcmLookupTable blueCcm; LookupTable gammaLut; + + /* + * Per frame CCM values as calcualted by the IPA + */ + Matrix ccm; }; } /* namespace libcamera */ From patchwork Wed Jun 11 01:32:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23522 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 CEE58C3240 for ; Wed, 11 Jun 2025 01:33:49 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 76B8B68DE6; Wed, 11 Jun 2025 03:33:49 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="mcriM+C1"; dkim-atps=neutral Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 83A8D68DE3 for ; Wed, 11 Jun 2025 03:33:46 +0200 (CEST) Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3a3798794d3so5248175f8f.1 for ; Tue, 10 Jun 2025 18:33:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605626; x=1750210426; 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=ad4DFb+tDm+2Co7srTTrLGrL0wSemjiSTQC9DUdMUhc=; b=mcriM+C10YE8StMLfvC8zXm6Zv78dCQdiABNY9r4l7MiDdS4lqks48ysedAR/Tf/oo aZSzy+DrwhiQgqIrK+B7wUifLgmAw2oP0ooegCqnZluZu5+BsMkl6LNX7O64XxjpQENo zHCaWagmBXtTSASal+TJf3Z38JLHfFT1gpg6a8klEN4YAfGHicfheqk75URg6HUKHE+e nrXrWpHl+iK5Oti4LsLcps+cpY9C2W7Pp1d7HeTu5+OyxfoCauT0E+aKMqzl8D8XRuxo RZiO45barShdV3WO7+8d/kmU225oHS6WvfBPl/47gf/n5/Zyb2ARn7rALWLRtMlJwpHt 2Y/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605626; x=1750210426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ad4DFb+tDm+2Co7srTTrLGrL0wSemjiSTQC9DUdMUhc=; b=Ag3YUZqhpsykMkWEoMTCR7V2rjxMX4SO84Eb1rwmJ5oFjQGTpl6XeLZ4ZQ6U5OdTD6 mMVcJdv25YPMPc5woJ4mJQ4+FcrBJsJ4IvYjtSScW+Lp2+kKVU0/aIJ8RNAHYbYNdUGq tnNDzaR1sLFNmrizhNMB2Z+SFLhDCPrcw7PDLl8zZXnYX38DojAQ955zlMBO77+TXy97 Fw6ycEpojdti3oZ1Cr3Efj2GBJzE0JlZJqcAGE+VU4UPQ7z7u2e+0Ods3Y+ZToZY+Xhv I50CVFdzlEd4mz0v+2jl4wh938Wnr/q0sShW7wHgMRh1DphahollVl/plFbRFG/Kw85Z /xKA== X-Gm-Message-State: AOJu0YwU1u1za/5qu2ib55U+fpKRo2VwNBn8I139b30cH5Ml0Rb2oLf9 b67cEVpMpjdgYK8Bvuydc17MqR4Ai8JC/+INjwbua3jHuuMLkZEH25HR7WJCQRTE2bhLJBWeVUw ZqxSvOLE= X-Gm-Gg: ASbGncuZtGrJUarMs/7XW8WV5PyKnnT22z74Fbt5C5n3MYZTPnCIjWOGFIXjBgtvuXs aE6fS1eR21TlzUbn2Dm1/fVQd1UeLcs7HLOHzq82ZxFVjEYjrZ0Xc93V7Hq72yQxCzVi5CSdAE+ oIPzRJukCfaurMOfretDlx/e736LaPYJLLVO2CiIeV0cCPfvlN5Byu6M5zarFEbxNaVk+ucpBG5 ksg2P/3TZA3XoO2XwrGJDvlmvsd6TAx9aOdM0MPGtZqIkj237iu79J9f7ZwHES8LM/B3sc3+e6u /o5ZLpmAdI8w3UXfk57L+Y6Rj+reMVmZWJ++TZ0QhLtIHk7ZVnU5TzT7TTPs/aR/C0zIVXQw8Gb XtR1fr3k9MiXpmenuu8/4dmH8y9ZbPr5N1FTN7vmNNA== X-Google-Smtp-Source: AGHT+IHKovHoglk/9DGxY3x351SvOB/nsx+2XSDGXKRe+PbgWyn6baAchDk0r2ZhRa5rpPNtpl9s0g== X-Received: by 2002:a5d:5f46:0:b0:3a4:e629:6504 with SMTP id ffacd0b85a97d-3a558a1af24mr715262f8f.49.1749605625615; Tue, 10 Jun 2025 18:33:45 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:45 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 16/35] libcamera: shaders: Move GL shader programs to src/libcamera/assets/shader Date: Wed, 11 Jun 2025 02:32:26 +0100 Message-ID: <20250611013245.133785-17-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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 GL shaders to src/libcamera/assets/shader to allow for reuse of these inside of the SoftISP. Signed-off-by: Bryan O'Donoghue --- .../libcamera/internal/shaders}/RGB.frag | 0 .../internal/shaders}/YUV_2_planes.frag | 0 .../internal/shaders}/YUV_3_planes.frag | 0 .../internal/shaders}/YUV_packed.frag | 0 .../internal/shaders}/bayer_1x_packed.frag | 0 .../libcamera/internal/shaders}/bayer_8.frag | 0 .../libcamera/internal/shaders}/bayer_8.vert | 0 .../libcamera/internal/shaders}/identity.vert | 0 src/apps/qcam/assets/shader/shaders.qrc | 16 ++--- src/apps/qcam/viewfinder_gl.cpp | 70 +++++++++---------- 10 files changed, 43 insertions(+), 43 deletions(-) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/RGB.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/YUV_2_planes.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/YUV_3_planes.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/YUV_packed.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/bayer_1x_packed.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/bayer_8.frag (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/bayer_8.vert (100%) rename {src/apps/qcam/assets/shader => include/libcamera/internal/shaders}/identity.vert (100%) diff --git a/src/apps/qcam/assets/shader/RGB.frag b/include/libcamera/internal/shaders/RGB.frag similarity index 100% rename from src/apps/qcam/assets/shader/RGB.frag rename to include/libcamera/internal/shaders/RGB.frag diff --git a/src/apps/qcam/assets/shader/YUV_2_planes.frag b/include/libcamera/internal/shaders/YUV_2_planes.frag similarity index 100% rename from src/apps/qcam/assets/shader/YUV_2_planes.frag rename to include/libcamera/internal/shaders/YUV_2_planes.frag diff --git a/src/apps/qcam/assets/shader/YUV_3_planes.frag b/include/libcamera/internal/shaders/YUV_3_planes.frag similarity index 100% rename from src/apps/qcam/assets/shader/YUV_3_planes.frag rename to include/libcamera/internal/shaders/YUV_3_planes.frag diff --git a/src/apps/qcam/assets/shader/YUV_packed.frag b/include/libcamera/internal/shaders/YUV_packed.frag similarity index 100% rename from src/apps/qcam/assets/shader/YUV_packed.frag rename to include/libcamera/internal/shaders/YUV_packed.frag diff --git a/src/apps/qcam/assets/shader/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag similarity index 100% rename from src/apps/qcam/assets/shader/bayer_1x_packed.frag rename to include/libcamera/internal/shaders/bayer_1x_packed.frag diff --git a/src/apps/qcam/assets/shader/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag similarity index 100% rename from src/apps/qcam/assets/shader/bayer_8.frag rename to include/libcamera/internal/shaders/bayer_8.frag diff --git a/src/apps/qcam/assets/shader/bayer_8.vert b/include/libcamera/internal/shaders/bayer_8.vert similarity index 100% rename from src/apps/qcam/assets/shader/bayer_8.vert rename to include/libcamera/internal/shaders/bayer_8.vert diff --git a/src/apps/qcam/assets/shader/identity.vert b/include/libcamera/internal/shaders/identity.vert similarity index 100% rename from src/apps/qcam/assets/shader/identity.vert rename to include/libcamera/internal/shaders/identity.vert diff --git a/src/apps/qcam/assets/shader/shaders.qrc b/src/apps/qcam/assets/shader/shaders.qrc index 96c709f9..04f9d706 100644 --- a/src/apps/qcam/assets/shader/shaders.qrc +++ b/src/apps/qcam/assets/shader/shaders.qrc @@ -1,13 +1,13 @@ - RGB.frag - YUV_2_planes.frag - YUV_3_planes.frag - YUV_packed.frag - bayer_1x_packed.frag - bayer_8.frag - bayer_8.vert - identity.vert + ../../../../../include/libcamera/internal/shaders/RGB.frag + ../../../../../include/libcamera/internal/shaders/YUV_2_planes.frag + ../../../../../include/libcamera/internal/shaders/YUV_3_planes.frag + ../../../../../include/libcamera/internal/shaders/YUV_packed.frag + ../../../../../include/libcamera/internal/shaders/bayer_1x_packed.frag + ../../../../../include/libcamera/internal/shaders/bayer_8.frag + ../../../../../include/libcamera/internal/shaders/bayer_8.vert + ../../../../../include/libcamera/internal/shaders/identity.vert diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp index f31956ff..70f60065 100644 --- a/src/apps/qcam/viewfinder_gl.cpp +++ b/src/apps/qcam/viewfinder_gl.cpp @@ -141,7 +141,7 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format) textureMinMagFilters_ = GL_LINEAR; /* Use identity.vert as the default vertex shader. */ - vertexShaderFile_ = ":identity.vert"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/identity.vert"; fragmentShaderDefines_.clear(); @@ -150,170 +150,170 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format) horzSubSample_ = 2; vertSubSample_ = 2; fragmentShaderDefines_.append("#define YUV_PATTERN_UV"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::NV21: horzSubSample_ = 2; vertSubSample_ = 2; fragmentShaderDefines_.append("#define YUV_PATTERN_VU"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::NV16: horzSubSample_ = 2; vertSubSample_ = 1; fragmentShaderDefines_.append("#define YUV_PATTERN_UV"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::NV61: horzSubSample_ = 2; vertSubSample_ = 1; fragmentShaderDefines_.append("#define YUV_PATTERN_VU"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::NV24: horzSubSample_ = 1; vertSubSample_ = 1; fragmentShaderDefines_.append("#define YUV_PATTERN_UV"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::NV42: horzSubSample_ = 1; vertSubSample_ = 1; fragmentShaderDefines_.append("#define YUV_PATTERN_VU"); - fragmentShaderFile_ = ":YUV_2_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_2_planes.frag"; break; case libcamera::formats::YUV420: horzSubSample_ = 2; vertSubSample_ = 2; - fragmentShaderFile_ = ":YUV_3_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_3_planes.frag"; break; case libcamera::formats::YVU420: horzSubSample_ = 2; vertSubSample_ = 2; - fragmentShaderFile_ = ":YUV_3_planes.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_3_planes.frag"; break; case libcamera::formats::UYVY: fragmentShaderDefines_.append("#define YUV_PATTERN_UYVY"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_packed.frag"; break; case libcamera::formats::VYUY: fragmentShaderDefines_.append("#define YUV_PATTERN_VYUY"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_packed.frag"; break; case libcamera::formats::YUYV: fragmentShaderDefines_.append("#define YUV_PATTERN_YUYV"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_packed.frag"; break; case libcamera::formats::YVYU: fragmentShaderDefines_.append("#define YUV_PATTERN_YVYU"); - fragmentShaderFile_ = ":YUV_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/YUV_packed.frag"; break; case libcamera::formats::ABGR8888: fragmentShaderDefines_.append("#define RGB_PATTERN rgb"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::ARGB8888: fragmentShaderDefines_.append("#define RGB_PATTERN bgr"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::BGRA8888: fragmentShaderDefines_.append("#define RGB_PATTERN gba"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::RGBA8888: fragmentShaderDefines_.append("#define RGB_PATTERN abg"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::BGR888: fragmentShaderDefines_.append("#define RGB_PATTERN rgb"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::RGB888: fragmentShaderDefines_.append("#define RGB_PATTERN bgr"); - fragmentShaderFile_ = ":RGB.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/RGB.frag"; break; case libcamera::formats::SBGGR8: firstRed_.setX(1.0); firstRed_.setY(1.0); - vertexShaderFile_ = ":bayer_8.vert"; - fragmentShaderFile_ = ":bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGBRG8: firstRed_.setX(0.0); firstRed_.setY(1.0); - vertexShaderFile_ = ":bayer_8.vert"; - fragmentShaderFile_ = ":bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGRBG8: firstRed_.setX(1.0); firstRed_.setY(0.0); - vertexShaderFile_ = ":bayer_8.vert"; - fragmentShaderFile_ = ":bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SRGGB8: firstRed_.setX(0.0); firstRed_.setY(0.0); - vertexShaderFile_ = ":bayer_8.vert"; - fragmentShaderFile_ = ":bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SBGGR10_CSI2P: firstRed_.setX(1.0); firstRed_.setY(1.0); fragmentShaderDefines_.append("#define RAW10P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGBRG10_CSI2P: firstRed_.setX(0.0); firstRed_.setY(1.0); fragmentShaderDefines_.append("#define RAW10P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGRBG10_CSI2P: firstRed_.setX(1.0); firstRed_.setY(0.0); fragmentShaderDefines_.append("#define RAW10P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SRGGB10_CSI2P: firstRed_.setX(0.0); firstRed_.setY(0.0); fragmentShaderDefines_.append("#define RAW10P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SBGGR12_CSI2P: firstRed_.setX(1.0); firstRed_.setY(1.0); fragmentShaderDefines_.append("#define RAW12P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGBRG12_CSI2P: firstRed_.setX(0.0); firstRed_.setY(1.0); fragmentShaderDefines_.append("#define RAW12P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGRBG12_CSI2P: firstRed_.setX(1.0); firstRed_.setY(0.0); fragmentShaderDefines_.append("#define RAW12P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SRGGB12_CSI2P: firstRed_.setX(0.0); firstRed_.setY(0.0); fragmentShaderDefines_.append("#define RAW12P"); - fragmentShaderFile_ = ":bayer_1x_packed.frag"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_1x_packed.frag"; textureMinMagFilters_ = GL_NEAREST; break; default: From patchwork Wed Jun 11 01:32: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: 23523 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 458F9C332B for ; Wed, 11 Jun 2025 01:33:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3AD3068DE9; Wed, 11 Jun 2025 03:33:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="kL9YGQPY"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B898868DDE for ; Wed, 11 Jun 2025 03:33:48 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-442e9c00bf4so50646485e9.3 for ; Tue, 10 Jun 2025 18:33:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605628; x=1750210428; 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=Bu8bAsFBaqMQEQkx5cdIdQP+OHMD0PNQhcyagmWH6gY=; b=kL9YGQPYYWoYWQSY4vCW9PxNdikT8cZP6Lkz1+8R+ItQbymxoSXw1f8C27Sxl1PyL3 eSYjKT08OAGg1e5U3AInF6ErL31AE0OSAm427HppqQE7OZtJyvK04aCr3DSBlLkoTFtf ptCUf+fdy78/suTWN6JFgThgEbtWz1eHLG7M2adON5Rv1UtfsWbUIQFK/X+B0VCYhCnc A1G780KWrBzUQsw3hKvVHZp9xDJXlPTzbFjOFKcY2cBxLkcHolRqHjOY2/fPyVsv5NPZ D+g7A76mji7dXqv0JL4feRXTyh9nfjkwWhgWVRQeC/Tf+gfhgkx79F6xQqdTcaI+eS3W bnLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605628; x=1750210428; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bu8bAsFBaqMQEQkx5cdIdQP+OHMD0PNQhcyagmWH6gY=; b=eZZg0rTrr9XZPkKqlvTd4BRquDvAC86LatSDq0tWVb8O/c6Gtye8i1fjXS0xXaona6 as11YxZrYPf3ZpRBvojj4HRZfOcwyUYa38JFj3RlbrMUo/qlK2oO9WyRDZPQwMijEW+i KnlFhZ8CHawyDojB4PRWVmSBJv04+h0on2wkvJzhzz8v7ZkdSfPnR5kKBwwl8uo6QVD7 xxx4QiRpe9hXqWXSnHYKywLaqZBDO0DuktVNVtlmENvqvao51TMngz6YPnnm3kNIOXqk rPZnQQHN55T5kosIv1VDT1BWdAhkKdcCMMPQbMqFNYWYHBx6898TGwG4mhI9QO1pAqbT maRQ== X-Gm-Message-State: AOJu0Yx7poepn8yT5nUiemScE7vvl81OV/VNU7Idlte0Fz8iOnk23aEq FQhbdSTIL1JOisNE7h6hEnres1s2Gu0Q0KxsCutu0NdNheeCOmKl+KKIELVsPWK5GsowOT3fhEO +tDq0aIs= X-Gm-Gg: ASbGncvlRBXsnfshwRcE/eMiHXerd0OoNpYEbnMGeAdRzJcfMaecC4OHogE4FO50h9I a9QVTxbEu5fEy0QQbE692+0qFJ0kTiSvZmy4tjD/m6CYK/WFKKk21EmEa95lGNMMegM5F83c9k7 yF0MK6q3Y+CVPs+p2XlSkM0xlf4a123LeNY7GYtn7zAIxWIY90hNcqjRIKrlIba/v6T5ERRlQyp 2JsQyD4Z6gHVnc7nP8UF5Q5QtfOdEMSXFQ3OhwdS8aXvxnzlj5ONmwEx+2rF43En0KPD0so6nqt h/CVc+iT70HiMytThrah3nSxwuL5IzrYvO95uqpwrBuwX3kvnImFf9Y3s69sbruJIMv964gSbWf 8VEMn2H2/HmsyaOu62+JUz4nni8cHdKJiAjaoeU2ahQ== X-Google-Smtp-Source: AGHT+IFimr21puVb8EtyrS/3T/KgKyIGY6mdse51NaZlDl4KrAuCpEUEBSONu/zpV6ioIKdUvGiSnQ== X-Received: by 2002:a05:600c:3f0e:b0:43d:9d5:474d with SMTP id 5b1f17b1804b1-45324d04de8mr8549755e9.0.1749605628104; Tue, 10 Jun 2025 18:33:48 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:47 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 17/35] utils: gen-shader-headers: Add a utility to generate headers from shaders Date: Wed, 11 Jun 2025 02:32:27 +0100 Message-ID: <20250611013245.133785-18-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Two simple script to generate a header that contains GLSL shaders translated to C arrays. Signed-off-by: Bryan O'Donoghue --- utils/gen-shader-header.py | 38 ++++++++++++++++++++++++++++++++ utils/gen-shader-headers.sh | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100755 utils/gen-shader-header.py create mode 100755 utils/gen-shader-headers.sh diff --git a/utils/gen-shader-header.py b/utils/gen-shader-header.py new file mode 100755 index 00000000..6668e648 --- /dev/null +++ b/utils/gen-shader-header.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (C) 2025, Bryan O'Donoghue. +# +# Author: Bryan O'Donoghue +# +# A python script which takes a list of shader files and converts into a C +# header. +# +import sys + +try: + with open(sys.argv[2]) as file: + data = file.read() + data_len = len(data) + + name = sys.argv[1].replace(".", "_") + name_len = name + "_len" + + j = 0 + print("unsigned char", name, "[] = {") + for ch in data: + print(f"0x{ord(ch):02x}, ", end="") + j = j + 1 + if j == 16: + print() + j = 0 + if j != 0: + print() + print("};") + + print() + print(f"const unsigned int {name_len}={data_len};") + +except FileNotFoundError: + print(f"File {sys.argv[2]} not found", file=sys.stderr) +except IOError: + print(f"Unable to read {sys.argv[2]}", file=sys.stderr) diff --git a/utils/gen-shader-headers.sh b/utils/gen-shader-headers.sh new file mode 100755 index 00000000..ca4f19f0 --- /dev/null +++ b/utils/gen-shader-headers.sh @@ -0,0 +1,44 @@ +#!/bin/sh +set -x + +if [ $# -lt 4 ]; then + echo "Invalid arg count must be >= 5" + exit 1 +fi +src_dir="$1"; shift +build_dir="$1"; shift +build_path=$build_dir/"$1"; shift + +cat < "$build_path" +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* This file is auto-generated, do not edit! */ +/* + * Copyright (C) 2025, Linaro Ltd. + * + */ + +#pragma once + +EOF + +cat <> "$build_path" +/* + * List the names of the shaders at the top of + * header for readability's sake + * +EOF + +for file in "$@"; do + echo "file is $file" + name=$(basename "$build_dir/$file" | tr '.' '_') + echo " * unsigned char $name;" >> "$build_path" +done + +echo "*/" >> "$build_path" + +echo "/* Hex encoded shader data */" >> "$build_path" +for file in "$@"; do + name=$(basename "$build_dir/$file") + "$src_dir/utils/gen-shader-header.py" "$name" "$build_dir/$file" >> "$build_path" + echo >> "$build_path" +done From patchwork Wed Jun 11 01:32: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: 23524 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 86C06C332C for ; Wed, 11 Jun 2025 01:33:55 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1652868DDC; Wed, 11 Jun 2025 03:33:55 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Tq1KFvPA"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6233268DD4 for ; Wed, 11 Jun 2025 03:33:51 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-451e2f0d9c2so3219735e9.1 for ; Tue, 10 Jun 2025 18:33:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605631; x=1750210431; 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=TvNGubUkRMki02NFiKmKim9ORLxISkAfK1S9L+RNjSI=; b=Tq1KFvPAdoNW1TtuZ6A/MsSg3X5jvjyZ6X+ELd4fM8ZFVNumk7obCrca240Yv4vtj7 2VYP4+Z3fgDsddiUPyvX/gAoWJx6KYKjM8Kd9fVy3mzU9RI+thnBgYw8FfcuZ03mFkh7 v51wIqDqmrOG6YR1hx3SN6Fx8SYUnbpIEM5+FQ8cqIIrbo0WsPkTU/CkQPRio5UkvBgK JOirywgWu9qqtBru7ptf42y02iGWbDLW/7EO6EI7izVxjYdUWTTCObxlGFsb0HQxmOdZ kNTvNKNBvHquomZfzKZvR3V9+SAC/zIyQzc5hkAPhuoC58iuM7Et0AvRF5A6+72eDvIW Zwxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605631; x=1750210431; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TvNGubUkRMki02NFiKmKim9ORLxISkAfK1S9L+RNjSI=; b=tlOXhdVB+zqkHzAHFefX42osJo9Ww0ONv+T4WZPHd73EYbplaO0gqEJ0gzxTVWMKyx wAaLJU9FwvsVq85kjP0IQR6twV+uMG3o2EyBAEbdzWxg3/FvzWOHfej4RPXHjBsh7PxR gv2sqR22ZucSrnaDBrdH2qBd2uUqmsv9Nf4CyFR1V5YJ7X2lJJ0nrjaIkge9ds38BpM3 iOhtkBG+QFssThFvnkpdUdoyiGsZeBMUaBzW+44+v77OPZQHhpyxe+IMxfHlkw2NJCbN kL9gjSpFlHaRDwn1DmGD/Jze6nHwaF0xfhi7zD5F6YHjDZ1WNKQqhjaJpVo0XEEMerK9 9jLQ== X-Gm-Message-State: AOJu0YzTpU4GHcXkgDguPiJe4qY3/HSOvCX0fWlrAzlL1R2U5e1dIlEr w5PDqYKWiNhyxa6dXSvq/VET1JVm7+Tk/KK6UanC5y2wRx179iPvzB34mdj4TPbtZA0ZqMBEA9Z vbp/UoMI= X-Gm-Gg: ASbGncs8tmuwyHtT3jhbUJs2cwXKXTfs3cI+gDCayDahqVM9EoXzA+b3C1bZwIF+E6e F2YmwImYVdaOfkBWAbclzNBMG/vnxuEHrhoFsB74PbIo50yXFgT/oBmp82kfGErpAMbmHFX36s+ DlhLmHKj4l1rbJLclHP5UZl7COpkZWQ7LwXcQELMHRi6b2NMcKHPD59eZTzNZsI4OJzNTjSOchi ncBmIWpeJ/QT8IrEOB+iBVZy2BiuPcjwlJU0lNLcOm+6+B6SPRqFKIYw4FKDF5ihC5y6JTbqr// 7blymPdoA4O4JlXG+fReDTu8JR58wSnSCZq8FKefWl/O/KNI5errNvKHovUi47u87AIZGNjfTUh yI6p8BWWw3uJzdgPgkRBD8kyLAJaCSGwuU+YQR5TV4/ppPkDrugX4 X-Google-Smtp-Source: AGHT+IGZoH9kNWwMCaOexy/Rmh4o/e2LXN3kRGanD7TQlX8pA+/kh8eYPmVfAS1BaxOZPBBorGQ3AQ== X-Received: by 2002:a05:600c:3496:b0:43b:c6a7:ac60 with SMTP id 5b1f17b1804b1-453242f49c0mr11339335e9.10.1749605630680; Tue, 10 Jun 2025 18:33:50 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:50 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 18/35] meson: Automatically generate glsl_shaders.h from specified shader programs Date: Wed, 11 Jun 2025 02:32:28 +0100 Message-ID: <20250611013245.133785-19-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Encode the bayer shader files into a header as part of the build process. Qcam already compiles the shader files down into a QT resource file which it references internally. In order to share the debayering shader programs outside of qcam create a generic header which both qcam and libcamera can operate from. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/meson.build | 10 ++++++++++ include/libcamera/internal/shaders/meson.build | 10 ++++++++++ utils/meson.build | 2 ++ 3 files changed, 22 insertions(+) create mode 100644 include/libcamera/internal/shaders/meson.build diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index 33f318b2..c0b593bf 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -1,6 +1,7 @@ # SPDX-License-Identifier: CC0-1.0 subdir('tracepoints') +subdir('shaders') libcamera_internal_headers = files([ 'bayer_format.h', @@ -57,5 +58,14 @@ tracepoints_h = custom_target( libcamera_internal_headers += tracepoints_h +libcamera_shader_headers = custom_target( + 'gen-shader-headers', + input : [shader_files], + output : 'glsl_shaders.h', + command : [gen_shader_headers, meson.project_source_root(), meson.project_build_root(), '@OUTPUT@', '@INPUT@'], +) + +libcamera_internal_headers += libcamera_shader_headers + subdir('converter') subdir('software_isp') diff --git a/include/libcamera/internal/shaders/meson.build b/include/libcamera/internal/shaders/meson.build new file mode 100644 index 00000000..386b342d --- /dev/null +++ b/include/libcamera/internal/shaders/meson.build @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: CC0-1.0 + +# List of shader files to convert to header hex +# for the purposes of inclusion in OpenGL debayering +shader_files = files([ + 'bayer_1x_packed.frag', + 'bayer_8.frag', + 'bayer_8.vert', + 'identity.vert', +]) diff --git a/utils/meson.build b/utils/meson.build index 95d657ac..3deed8ad 100644 --- a/utils/meson.build +++ b/utils/meson.build @@ -3,5 +3,7 @@ subdir('codegen') subdir('ipu3') +gen_shader_headers = files('gen-shader-headers.sh') + ## Module signing gen_ipa_priv_key = files('gen-ipa-priv-key.sh') From patchwork Wed Jun 11 01:32: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: 23525 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 D7CFFC3326 for ; Wed, 11 Jun 2025 01:33:56 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6EA2668DE2; Wed, 11 Jun 2025 03:33:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="a3co4uxJ"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CFCAA68DD4 for ; Wed, 11 Jun 2025 03:33:53 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4531e146a24so9702735e9.0 for ; Tue, 10 Jun 2025 18:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605633; x=1750210433; 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=eKYgK1WfN5ePoqdc0nHiHli5OuTT0JnN7h99qCjPS28=; b=a3co4uxJEWOJr4o3ltUzbeVhxy2zXqkb11wj6HoYYlMy14DKbMKPCsPZh1f6FVJ09X 9J2gRTVcYxcBeVG2Wj6hoVPmGqVgCguMicNUgSCsbMwT3vepMHStONbd1xnTdzWC5ZtI EwjH1b4Sv2Z/X0326DG37Uk2D8A3g1A6nllmkWvmaUkZFVx9qI/7Pun3pNafWuQpyqgT MeEvfxsC3hQG9CAxolHe4rerTFIVhrdXCrNbfz2sP2Iqj50pP3i3vewKtwUDMS9mhFfr fPWkicyhGZa0vyl5c9hFfkLDySTWi95ESjnTZQUktdccqjw7yo2GuIcnCP9F5N0aSIgr vyoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605633; x=1750210433; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eKYgK1WfN5ePoqdc0nHiHli5OuTT0JnN7h99qCjPS28=; b=eTKyjP7f2x8E04TfNZ1y/udyv4E3l7JjBEj5+/SVWisBCjyUeerKfdwmExHCifUzII /ccWx7/vijgGrpX1g4zTsw4s5k+kI9l3vCbI6QItw7EvLMpUF4olXMGsDYoZuHsefwQz kmn7RYCMts0MF8q+H1eOu13ZuOrLQMB3US4yc6d9aR2M7ND1fcdyUOVWiiK158tE/UnY Jy4RFW7lgrg8t1kO5W9r1WUF6aNLnGSHGpa7mUvpf5Is2JNCPR8B6Ebpq+RqgVQTtczQ aLu62rfrnfIDN00P5Yjn9fEphC+aFKR+ll7Ryx9K/oaPBKkMBkZIkqiwecQb+5tpU/F3 VkVw== X-Gm-Message-State: AOJu0YxpZhhkWHQoRrsrtsh73bk8X/L3QkDblQulhrWYimtrP7ZFFHQY wCNEPxdZAWIrHjspCCDoSHSrzTrK8TFRC67pd+K8Wo2Yh5jPCVdI/dh/Bcw3oA3t3HoIPulBsAe pCntdcbU= X-Gm-Gg: ASbGncseZS2mrqZpqo9kdY0FO3m76LjQ4/AJmfVruxqalk9wcrsgCXQP3XpcAcuNRgl QutvmsxcIj+7ixeJVvHptNtJAm6tpFIx29JVPAXtLaBSNmzzMzXtZokFN3KoCjshYfQWwmyvZaZ Kj5LLE21A/OnDx1xHH0AxfXGh2F9ujgXXLRpzWjX9GqRFkWapkyrzQwjrWQx3Q+IoVjr61EWY0f ciD5XqFo+E9gCdR+80rSWP3ZMnwim7uwwWU5lsfJebA2nyy+2bwGm/liXTWMzeDu0ytZPKT8L2g DfAFPT0lLloCFXMCIYNvDOOMhDNV0soAQWqMFNyhpuxam70CeyF9Min9x5UbV2G8e4FYPu87THf TZiUqcV/xfIqBR3UoCdOh9W9vRZVJNMSVp1X2sx08dg== X-Google-Smtp-Source: AGHT+IH4sxxVhXJp+vX7Vp0cDt3oPyvpWfSCb49R5uKKc2j2UH8qUFvJCHzC3zOs5A1oeT7ejVk+fw== X-Received: by 2002:a05:600c:6087:b0:442:f956:53f9 with SMTP id 5b1f17b1804b1-453248be49emr10321235e9.18.1749605633191; Tue, 10 Jun 2025 18:33:53 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:52 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 19/35] libcamera: software_isp: ccm: Populate CCM table to Debayer params structure Date: Wed, 11 Jun 2025 02:32:29 +0100 Message-ID: <20250611013245.133785-20-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Populate the DebayerParams CCM table during ccm::prepare(). A copy is made of the CCM into the DebayerParams structure. Signed-off-by: Bryan O'Donoghue --- src/ipa/simple/algorithms/ccm.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/ipa/simple/algorithms/ccm.cpp b/src/ipa/simple/algorithms/ccm.cpp index 0a98406c..cb023878 100644 --- a/src/ipa/simple/algorithms/ccm.cpp +++ b/src/ipa/simple/algorithms/ccm.cpp @@ -14,6 +14,7 @@ #include #include "libcamera/internal/matrix.h" +#include "libcamera/internal/software_isp/debayer_params.h" namespace { @@ -84,7 +85,7 @@ void Ccm::applySaturation(Matrix &ccm, float saturation) } void Ccm::prepare(IPAContext &context, const uint32_t frame, - IPAFrameContext &frameContext, [[maybe_unused]] DebayerParams *params) + IPAFrameContext &frameContext, DebayerParams *params) { auto &saturation = context.activeState.knobs.saturation; @@ -108,6 +109,7 @@ void Ccm::prepare(IPAContext &context, const uint32_t frame, context.activeState.ccm.ccm = ccm; frameContext.ccm.ccm = ccm; frameContext.saturation = saturation; + params->ccm = ccm; context.activeState.ccm.changed = true; } From patchwork Wed Jun 11 01:32: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: 23526 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 1C39AC332D for ; Wed, 11 Jun 2025 01:34:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 92C7468DB4; Wed, 11 Jun 2025 03:34:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="taoQ1GsB"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3426668DE0 for ; Wed, 11 Jun 2025 03:33:57 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-451d3f72391so78653615e9.3 for ; Tue, 10 Jun 2025 18:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605636; x=1750210436; 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=fG3uKUiGO5dBKo4QNdD4AfdVef55fyidXJo0XY2syC4=; b=taoQ1GsBxd6dWXdbydCGhDaqX3LOh9SMksK7a/Dc8Wxfffx+b+SQtcc/1SSBqpmZYW XiPYL6zuH12x096fki+ZQEQ6P3CzqH9TpBrHomPK7xcrdGw+/wD63ZlmTTlE1Em8Eq7S 4FqPglFPbcVz4K17cDF1cuGcIljFKv2dYkqDrjcqHUXLxj4hdzXCg0xwgL5EoYFGB9W2 JzFRrhWgBfgK8dAYKIOjgPnD+SS3+EX5PtMpEfZUv82JRKNWDRoCXll8hUzRD4hhIj9L bRSgDL+y2e8EPOV1vQ9oA0JFEPXeGaOEG9eoRF4g4SCdszcbr+35K6ZFO3aWZ0XBRWsZ kXeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605636; x=1750210436; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fG3uKUiGO5dBKo4QNdD4AfdVef55fyidXJo0XY2syC4=; b=oZPj8ocnSZZHNkAVMX7HGLdPug2+krwj7kokuoauQ/zSf4rTNETFvYkuO/bWo1ew6V ZS/8FnWtU2Z7JFWCLnnOy1PRrNghDFwe3hjhcLom8tf8lR4TvBQ10XaxzXOnlD+9dqQ5 HbY/+cxzQTGt4YPSpfDpV20mCBvecUbEd5WoPfNGlRFswm9BE0ltJyNiixPYqJfKO7pv mE6b4TuPiXpFN1XTFccshEq8aDVDgFvMcAFdsij/9U7M1byhhu1+epzRPnXmwKOlhw0U REZfD+9zOB1JpFws5DX8+gOYA7pATAoqqC8yL4hhVgyp1Ujo33kM51eluNS9pW5gmcEr Np6A== X-Gm-Message-State: AOJu0Yx3tWbhUz0CRh1xyV/XgIo8MTUohs6IzX7qHF3PFR08Yf2VjoeY QgXueg6V1+mEYy3Db01nOXopbPUuTcJ9+2uolhIuJOeWgQNnLuC/csSNcZohtNG7KG7u5q1CNdi LIfionXU= X-Gm-Gg: ASbGnctcnIF/xK2XwNL6GVrs6D0iD3f9YdcXsHVrHX9GYDVeCn73WILEGH5zFqEKwze oQC53hemWSNtvfxycf86gwLRuulENIMnOcLg3Upw/O+SGDgUjJ5r/kIJxisMPPSFvuES+KvZ5gu 4VnKXP/pH0KlyaAXrgsQxHD2MFZe4/vuKcABdd2ZHJ7SarxaVTH38cwYTwrnnk/rbFK2lqm/egW vVk/+Pe8Ef9vLjxuje7oaXCIbKclLuw9SfiGcVAHASgFKnfZRMX66cjEQPrSn6KdZLDGjnQ4fWI iNV8Na1AvyckrVPNFXzgxnHA+DDpNgZZ23lL+QzvBgetczrTK/LaQQDFH9lk6XCUJOgYdJzixOI 8Ex4TMATbUrHoT0OKBrsboC9GvBck7x9XYK9jA8vUWw== X-Google-Smtp-Source: AGHT+IHHiTRTMu1jn2wW+MsR9qqKT1cs9Ze9bcd/bjQ1tDTUIveVj9QHXO2PVYhF679uuvOkwBDzBw== X-Received: by 2002:a05:6000:401e:b0:3a0:9dfc:da4 with SMTP id ffacd0b85a97d-3a558aeca6emr767130f8f.42.1749605636492; Tue, 10 Jun 2025 18:33:56 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:55 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 20/35] libcamera: software_isp: lut: Make gain corrected CCM in lut.cpp available in debayer params Date: Wed, 11 Jun 2025 02:32:30 +0100 Message-ID: <20250611013245.133785-21-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" There is another CCM calculated in this algorithm callback, this time based on the LUT. Signed-off-by: Bryan O'Donoghue --- src/ipa/simple/algorithms/lut.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ipa/simple/algorithms/lut.cpp b/src/ipa/simple/algorithms/lut.cpp index d1d5f727..a161adb1 100644 --- a/src/ipa/simple/algorithms/lut.cpp +++ b/src/ipa/simple/algorithms/lut.cpp @@ -126,6 +126,7 @@ void Lut::prepare(IPAContext &context, auto &red = params->redCcm; auto &green = params->greenCcm; auto &blue = params->blueCcm; + params->ccm = ccm; for (unsigned int i = 0; i < DebayerParams::kRGBLookupSize; i++) { red[i].r = ccmValue(i, ccm[0][0]); red[i].g = ccmValue(i, ccm[1][0]); From patchwork Wed Jun 11 01:32: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: 23527 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 A5641C332E for ; Wed, 11 Jun 2025 01:34:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9B33468DE8; Wed, 11 Jun 2025 03:34:02 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="sfXQIYHe"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3EEE168DDC for ; Wed, 11 Jun 2025 03:34:00 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-43edecbfb94so73702195e9.1 for ; Tue, 10 Jun 2025 18:34:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605639; x=1750210439; 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=Z2sgjAf/EwAQKD9LSQAsz8mndmwtt3Mb1vEfn9JsBDg=; b=sfXQIYHeyiZ19y84beByW9wVjXIStbFfx6pQbLo+C7k67rKjqgxPmPfdlSYuls78Xm tk8T1S9hp7slKcLLsJoZkmuEGQMACdFpQM2cw3rVBaVaECS3n7x4V80fL48lSQquIbrT QJgyMO+cF1wDjGCu8UEEniAo7wYKtJYNrLoH7OKn+zzPGzXkSTJGr6eneKPKTskXeSk4 WoudHZnRdRT9wPoadxhtZG5i/Rg/7m6aYbXSRGTHLFnOKFjjFT0eU5gZFNI6kBoKPGju UIHgmQSCx9q0XTPbtVTF9j8kw7KOGne4LFN89FNR0CpcaL1eLi8evozHbI6Dpqlg9RL8 lOag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605639; x=1750210439; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Z2sgjAf/EwAQKD9LSQAsz8mndmwtt3Mb1vEfn9JsBDg=; b=ASFi4lXle4ig2aNMDgifIURw0UwnEmP06dLmIofrQU3tuV30u/jVuICAkvvYIUfyqy NQ2KXxpB9fdeCNusbWi/UrZcnU2yyMjrkKXDYLr0paLn4UfnVRndEjwPiLBHu9HthYli PKQyt6ikMJBWkO3ovgl40qPkAzXjgeoOiN8zBauhPgAoD9NQyFO7O5/6F4HMbszbfb9r 1F6AAgKBUccCCxnNdJyxyEKsQvVLAWNaxUU+wCjVm0k3tBK+Yh3aw2ma+dDBcapLZnWM vR76gDMmYcE/GRTbjFePNm1Bww2KzljRhX0NlFkehCJOcOdmnhF2oTDwIBOZLuHPAu+f QGzw== X-Gm-Message-State: AOJu0Yy5PE1SwDD5t1be9g7xE9Tf0blK1AUGmyZcU8maOm3E6hGsAREu WGbXr4CNTR5yayb1p8ECjyzuuusxc5Sw1gfpWOXeDLadouJ5OnN2SljNH3LnQZV/hihpt7x/OzH Y/uhePIc= X-Gm-Gg: ASbGncsvTkv4hODFjoMWmhBNebHvagxcDAQrx7hBhHBCI9NuZ5DVlAhCe9DF2K1Ccih VjhoalCWbSlflq8wZHx7lpxw+/MaQIHlIk23ZV6G4nJPKaL0WNNkvY484DXI+EjeQUUrUGbwBBy 0BnDaocxqUMIyWJAPEtzVt60ZXIbUZclKcSNeiNJYwMsYsN41vpMWIzNkzWtwJOlzqNN/pcCyd4 +MA6M8I8mWc+tqBRTbtu4yniinpzjBFM9tsdIvEhr/ADdLEYDBAPC5saWqVqV0ZejOCQJ10CnQE entC2XmB5+SGUv0rhVVv+nYU7U6EbfGbb6XrMZVsYM2bKzYJTJY252vASrX1Wb3lg/HBNeD5eMn Z08EBW+iIFJLLdFbQY7tz7hv/iD9lFDgi16OJy7wAqA== X-Google-Smtp-Source: AGHT+IEAB4AVvfYSnon/TOzXtlv+LWRuNAYkH6sNmYSwpzAT2yCPTVuiSqVdbnjBhcY2VQ1xmPh/nw== X-Received: by 2002:a05:600c:4e4b:b0:453:9bf:6f7c with SMTP id 5b1f17b1804b1-453248837fcmr9267265e9.9.1749605639516; Tue, 10 Jun 2025 18:33:59 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:33:59 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 21/35] libcamera: software_isp: gbm: Add in a GBM helper class for GPU surface access Date: Wed, 11 Jun 2025 02:32:31 +0100 Message-ID: <20250611013245.133785-22-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" A helper class to interact with GBM. This will allow us to specify the internal storage format of the CPU when making a texture for the Debayer vertext/fragment shaders and thus ensure we receive an uncompressed and untiled output buffer. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/gbm.h | 55 ++++++++++ include/libcamera/internal/meson.build | 1 + src/libcamera/gbm.cpp | 137 +++++++++++++++++++++++++ src/libcamera/meson.build | 11 ++ 4 files changed, 204 insertions(+) create mode 100644 include/libcamera/internal/gbm.h create mode 100644 src/libcamera/gbm.cpp diff --git a/include/libcamera/internal/gbm.h b/include/libcamera/internal/gbm.h new file mode 100644 index 00000000..a5486cc9 --- /dev/null +++ b/include/libcamera/internal/gbm.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Linaro Ltd. + * + * Authors: + * Bryan O'Donoghue + * + * gbm.h - Helper class for managing GBM interactions. + */ + +#pragma once + +#include + +#include + +#include + +namespace libcamera { + +LOG_DECLARE_CATEGORY(GBM) + +class GBM +{ +public: + GBM(); + ~GBM(); + + int initSurface(uint32_t width, uint32_t height); + int mapSurface(); + int getFrameBufferData(uint8_t *data_out, size_t data_len); + struct gbm_device *getDevice() { return gbm_device_; } + struct gbm_surface *getSurface() { return gbm_surface_; } + uint32_t getFrameSize() { return framesize_; } + uint32_t getStride() { return stride_; } + PixelFormat getPixelFormat() { return format_; } + +private: + int fd_; + struct gbm_device *gbm_device_; + struct gbm_surface *gbm_surface_; + + struct gbm_bo *gbm_bo_; + uint32_t width_; + uint32_t height_; + uint32_t stride_; + uint32_t offset_; + uint32_t framesize_; + void *map_; + int bo_fd_; + + PixelFormat format_; +}; + +} // namespace libcamera diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index c0b593bf..4a2919f6 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -23,6 +23,7 @@ libcamera_internal_headers = files([ 'dma_buf_allocator.h', 'formats.h', 'framebuffer.h', + 'gbm.h', 'ipa_data_serializer.h', 'ipa_manager.h', 'ipa_module.h', diff --git a/src/libcamera/gbm.cpp b/src/libcamera/gbm.cpp new file mode 100644 index 00000000..43032093 --- /dev/null +++ b/src/libcamera/gbm.cpp @@ -0,0 +1,137 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Linaro Ltd. + * + * Authors: + * Bryan O'Donoghue + * + * egl.cpp - Helper class for managing GBM interactions. + */ + +#include "libcamera/internal/gbm.h" + +#include +#include +#include +#include + +#include +#include + +namespace libcamera { + +LOG_DEFINE_CATEGORY(GBM) + +GBM::GBM() +{ + fd_ = 0; +} + +GBM::~GBM() +{ + if (gbm_surface_) + gbm_surface_destroy(gbm_surface_); + + if (gbm_device_) + gbm_device_destroy(gbm_device_); + + if (fd_ >= 0) + close(fd_); +} + +// this should probably go into its own class to deal with the +// allocation and deletion of frambuffers attached to GBM devices/objects +int GBM::initSurface(uint32_t width, uint32_t height) +{ + const char *dri_node = "/dev/dri/renderD128"; //TODO: get from an env or config setting + + fd_ = open(dri_node, O_RDWR | O_CLOEXEC); //TODO: CLOEXEC ? + if (fd_ < 0) { + LOG(GBM, Error) << "Open " << dri_node << " fail " << fd_; + return fd_; + } + + gbm_device_ = gbm_create_device(fd_); + if (!gbm_device_) { + LOG(GBM, Error) << "gbm_crate_device fail"; + goto fail; + } + + // GBM_FORMAT_RGBA8888 is not supported mesa::src/gbm/dri/gbm_dri.c::gbm_dri_visuals_table[] + // This means we need to choose XRGB8888 or ARGB8888 as the raw buffer format + gbm_surface_ = gbm_surface_create(gbm_device_, width, height, GBM_FORMAT_ARGB8888, + GBM_BO_USE_RENDERING | GBM_BO_USE_LINEAR); + if (!gbm_surface_) { + LOG(GBM, Error) << "Unable to create linear gbm surface"; + goto fail; + } + + format_ = libcamera::formats::ARGB8888; + + return 0; +fail: + return -ENODEV; +} + +int GBM::mapSurface() +{ + gbm_bo_ = gbm_surface_lock_front_buffer(gbm_surface_); + if (!gbm_bo_) { + LOG(GBM, Error) << "GBM input buffer object create fail"; + return -ENODEV; + } + gbm_surface_release_buffer(gbm_surface_, gbm_bo_); + + bo_fd_ = gbm_bo_get_fd(gbm_bo_); + + if (!bo_fd_) { + gbm_surface_release_buffer(gbm_surface_, gbm_bo_); + LOG(GBM, Error) << "Unable to get fd for bo: " << bo_fd_; + return -ENODEV; + } + + stride_ = gbm_bo_get_stride(gbm_bo_); + width_ = gbm_bo_get_width(gbm_bo_); + height_ = gbm_bo_get_height(gbm_bo_); + offset_ = gbm_bo_get_offset(gbm_bo_, 0); + framesize_ = height_ * stride_; + + map_ = mmap(NULL, height_ * stride_, PROT_READ, MAP_SHARED, bo_fd_, 0); + if (map_ == MAP_FAILED) { + LOG(GBM, Error) << "mmap gbm_bo_ fail"; + return -ENODEV; + } + + LOG(GBM, Debug) << " stride " << stride_ + << " width " << width_ + << " height " << height_ + << " offset " << offset_ + << " framesize " << framesize_; + + return 0; +} + +int GBM::getFrameBufferData(uint8_t *data, size_t data_len) +{ + struct dma_buf_sync sync; + + gbm_surface_lock_front_buffer(gbm_surface_); + + sync.flags = DMA_BUF_SYNC_START | DMA_BUF_SYNC_READ; + ioctl(bo_fd_, DMA_BUF_IOCTL_SYNC, &sync); + + if (data_len > framesize_) { + LOG(GBM, Error) << "Invalid read size " << data_len << " max is " << framesize_; + return -EINVAL; + } + + memcpy(data, map_, data_len); + + sync.flags = DMA_BUF_SYNC_END | DMA_BUF_SYNC_READ; + ioctl(bo_fd_, DMA_BUF_IOCTL_SYNC, &sync); + + gbm_surface_release_buffer(gbm_surface_, gbm_bo_); + + return 0; +} +} //namespace libcamera diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 202db1ef..0d004694 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -67,6 +67,16 @@ libcamera_deps = [] libatomic = cc.find_library('atomic', required : false) libthreads = dependency('threads') +libgbm = cc.find_library('gbm', required: false) +gbm_works = cc.check_header('gbm.h', required: false) + +if libgbm.found() and gbm_works + config_h.set('HAVE_GBM', 1) + libcamera_internal_sources += files([ + 'gbm.cpp', + ]) +endif + subdir('base') subdir('converter') subdir('ipa') @@ -188,6 +198,7 @@ libcamera_deps += [ libcamera_base_private, libcrypto, libdl, + libgbm, liblttng, libudev, libyaml, From patchwork Wed Jun 11 01:32: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: 23528 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 ED978C3324 for ; Wed, 11 Jun 2025 01:34:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6FF5B68DEA; Wed, 11 Jun 2025 03:34:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="dAbi5i2s"; dkim-atps=neutral Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 28E8D68DEA for ; Wed, 11 Jun 2025 03:34:03 +0200 (CEST) Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3a36748920cso5320897f8f.2 for ; Tue, 10 Jun 2025 18:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605642; x=1750210442; 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=99qn9WGfY/kxTzG1oS2F/mp2QfKpxkgqdCbbyzFP2lQ=; b=dAbi5i2splf9WxL+7ZfnhNmmx2z+/krSIfLfb2tcHhnjt8ZFwt1UiD8t9uGA894ZJk SoTA1P+NEeo5/76gsVYhmEwSHW9U76bkVKSZpPIC08HJ1dloBe33Y2DyMJ+PghaKvSDt VZRngB8ZX6PQTf+116W/VZEZKsxlJxSVwycv/LHZyuonA2yeaTLtFChUIHt51JcWDhB1 Pm4puIpp909Q9tqPmjtv96uxKbhj9r87icIqB7vUImpbKiRpJ0HuEAb30jaWYOLN2VfZ NfQLoYaULi1C8cVffARL+tqwKYS5yN9OKBqo1aUvpMvFUNF4UT+2uGC/ZQPLC3ngnLFj +NRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605642; x=1750210442; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=99qn9WGfY/kxTzG1oS2F/mp2QfKpxkgqdCbbyzFP2lQ=; b=ND/3OAP6VIeLvI6QyFcEbWlFTxtsYk1qKPRAPS6ZH+mqNLgi2p4JJwV+X6zfgc8Cr/ Y08a6r4m2wjODDTg3JHZhwKpw7gLePG/qa+QsigNBvBeggPhiTYCuId9BJThbqz8UDZ8 n12Kz6oADvtkq+0uc5NgCr/DQbMEiMPcI6c9j3l3t4C8x39dEFGuP5luVTZAVm3iRbv2 AtJvjT51GaidquF+6SqQVU/TQOQStw1hJjQ00dPwD8Up4+LgRonKM0AM8QUCLN3SKz3Q X3GLnImhpYIUfswnFG1JD91RjczcCgucc6JicyRCjX3OrnvgYsSWX8tw2FkSLWFKmCqM Lu2g== X-Gm-Message-State: AOJu0YxLejuK2CRb+LCylMb2lLmyxZ+E7sNbOKZG0J/nzWmzDmt75/rS sGA9MtTaR+Wh27OG05eFmN+rBEerG543ED05hewR32wtlhw3lx7epfvQWdl6A1cyyYDNsIVEZlu kSAteG+o= X-Gm-Gg: ASbGncumMjuUrB8NBFefKleXr/i+nhTaCrzKo/aku+ixxTpqH5SZO8/OL8Okc8PPODa szmrwhmAz/kMJJ4UlgX3XgSp66rM8onbiYztXrtfZUJpMK657NDJqDlM2bgvugBBa8QVN4QgeK3 2X27VVZzGXTfSMO/wrha6ZPFTmjrolIawzciRjNcNs1C05IfTUAiNN2oN3lsAw4FI1Mc7R6X+gM g1ehIdxE6SIQUl6DNZs/yNhfgssvYu9H5enMoYaOcyWvp+H6lWjA7+McYakptPaqTzhrg9VATKR 8pJD0ayk4b73rTWEGNCx3KOT71iXQVEh9u/XzYaUr5tpqhUoMVK1ZOuVGXQ+iEbLHKAj+jNkaty SAuFH75Wo8kF04oSD3czyCgf+ZKUxMfoA61/Pk1Pl7A== X-Google-Smtp-Source: AGHT+IEhHUCDRxXBK0rdkwqKey8ikfykCu8V9QIxbP0g4O9CVY6CFvsjRUz6D5NpIgaF604Pc93DKg== X-Received: by 2002:a05:6000:188b:b0:3a4:e6c6:b8bf with SMTP id ffacd0b85a97d-3a558af94cdmr670065f8f.52.1749605642099; Tue, 10 Jun 2025 18:34:02 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.33.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:01 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 22/35] libcamera: software_isp: egl: Introduce an eGL base helper class Date: Wed, 11 Jun 2025 02:32:32 +0100 Message-ID: <20250611013245.133785-23-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Introduce an eGL base helper class which provides an eGL context based on a passed width and height. The initGLContext function could be overloaded to provide an interface to a real display. A set of helper functions is provided to compile and link GLSL shaders. linkShaderProgram currently compiles vertex/fragment pairs but could be overloaded or passed a parameter to link a compute shader instead. Breaking the eGL interface away from debayering - allows to use the eGL context inside of a dma-buf heap cleanly, reuse that context inside of a debayer layer and conceivably reuse the context in a multi-stage shader pass. Small note the image_attrs[] array doesn't pass checkstyle.py however the elements of the array are in pairs. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/egl.h | 110 +++++++++ src/libcamera/egl.cpp | 369 +++++++++++++++++++++++++++++++ src/libcamera/meson.build | 23 ++ 3 files changed, 502 insertions(+) create mode 100644 include/libcamera/internal/egl.h create mode 100644 src/libcamera/egl.cpp diff --git a/include/libcamera/internal/egl.h b/include/libcamera/internal/egl.h new file mode 100644 index 00000000..04d637d8 --- /dev/null +++ b/include/libcamera/internal/egl.h @@ -0,0 +1,110 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Linaro Ltd. + * + * Authors: + * Bryan O'Donoghue + * + * egl_context.cpp - Helper class for managing eGL interactions. + */ + +#pragma once + +#include + +#include + +#include "libcamera/internal/gbm.h" + +#define EGL_EGLEXT_PROTOTYPES +#include +#include +#define GL_GLEXT_PROTOTYPES +#include +#include + +namespace libcamera { + +LOG_DECLARE_CATEGORY(eGL) + +class eGLImage +{ +public: + eGLImage(uint32_t width, uint32_t height, uint32_t bpp, GLenum texture_unit, uint32_t texture_unit_uniform_id) + { + image_ = EGL_NO_IMAGE_KHR; + width_ = width; + height_ = height; + bpp_ = bpp; + stride_ = width_ * bpp_ / 4; + framesize_ = stride_ * height_; + texture_unit_ = texture_unit; + texture_unit_uniform_id_ = texture_unit_uniform_id; + + glGenTextures(1, &texture_); + } + + ~eGLImage() + { + glDeleteTextures(1, &texture_); + } + + uint32_t width_; + uint32_t height_; + uint32_t stride_; + uint32_t offset_; + uint32_t framesize_; + uint32_t bpp_; + uint32_t texture_unit_uniform_id_; + GLenum texture_unit_; + GLuint texture_; + EGLImageKHR image_; +}; + +class eGL +{ +public: + eGL(); + ~eGL(); + + int initEGLContext(GBM *gbmContext); + int createDMABufTexture2D(eGLImage *eglImage, int fd); + void destroyDMABufTexture(eGLImage *eglImage); + void createTexture2D(eGLImage *eglImage, GLint format, uint32_t width, uint32_t height, void *data); + void createTexture1D(eGLImage *eglImage, GLint format, uint32_t width, void *data); + + void pushEnv(std::vector &shaderEnv, const char *str); + void makeCurrent(); + void swapBuffers(); + + int compileVertexShader(GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + std::vector shaderEnv); + int compileFragmentShader(GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + std::vector shaderEnv); + int linkProgram(GLuint &programIdd, GLuint fragmentshaderId, GLuint vertexshaderId); + void dumpShaderSource(GLuint shaderId); + void useProgram(GLuint programId); + +private: + int fd_; + + EGLDisplay display_; + EGLContext context_; + EGLSurface surface_; + + int compileShader(int shaderType, GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + std::vector shaderEnv); + + PFNEGLEXPORTDMABUFIMAGEMESAPROC eglExportDMABUFImageMESA; + PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; + + PFNEGLCREATEIMAGEKHRPROC eglCreateImageKHR; + PFNEGLDESTROYIMAGEKHRPROC eglDestroyImageKHR; + + PFNEGLCLIENTWAITSYNCKHRPROC eglClientWaitSyncKHR; + PFNEGLCREATESYNCKHRPROC eglCreateSyncKHR; +}; +} //namespace libcamera diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp new file mode 100644 index 00000000..89ece148 --- /dev/null +++ b/src/libcamera/egl.cpp @@ -0,0 +1,369 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Linaro Ltd. + * + * Authors: + * Bryan O'Donoghue + * + * egl.cpp - Helper class for managing eGL interactions. + */ + +#include "libcamera/internal/egl.h" + +#include +#include +#include +#include + +#include +#include + +namespace libcamera { + +LOG_DEFINE_CATEGORY(eGL) + +eGL::eGL() +{ +} + +eGL::~eGL() +{ +} + +// Create linear image attached to previous BO object +int eGL::createDMABufTexture2D(eGLImage *eglImage, int fd) +{ + int ret = 0; + + eglImage->stride_ = eglImage->width_ * eglImage->height_; + eglImage->offset_ = 0; + eglImage->framesize_ = eglImage->height_ * eglImage->stride_; + + LOG(eGL, Info) + << " stride " << eglImage->stride_ << " width " << eglImage->width_ << " height " << eglImage->height_ << " offset " << eglImage->offset_ << " framesize " << eglImage->framesize_; + + // TODO: use the dma buf handle from udma heap here directly + // should work for both input and output with fencing + EGLint image_attrs[] = { + EGL_WIDTH, (EGLint)eglImage->width_, + EGL_HEIGHT, (EGLint)eglImage->height_, + EGL_LINUX_DRM_FOURCC_EXT, (int)GBM_FORMAT_ARGB8888, + EGL_DMA_BUF_PLANE0_FD_EXT, fd, + EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0, + EGL_DMA_BUF_PLANE0_PITCH_EXT, (EGLint)eglImage->framesize_, + EGL_NONE, EGL_NONE, /* modifier lo */ + EGL_NONE, EGL_NONE, /* modifier hi */ + EGL_NONE, + }; + + eglImage->image_ = eglCreateImageKHR(display_, EGL_NO_CONTEXT, + EGL_LINUX_DMA_BUF_EXT, + NULL, image_attrs); + + if (eglImage->image_ == EGL_NO_IMAGE_KHR) { + LOG(eGL, Error) << "eglCreateImageKHR fail"; + ret = -ENODEV; + goto done; + } + + // Generate texture, bind, associate image to texture, configure, unbind + glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, eglImage->image_); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + +done: + return ret; +} + +void eGL::destroyDMABufTexture(eGLImage *eglImage) +{ + eglDestroyImage(display_, eglImage->image_); +} + +// +// Generate a 2D texture from an input buffer directly +void eGL::createTexture2D(eGLImage *eglImage, uint32_t width, uint32_t height, void *data) +{ + glActiveTexture(eglImage->texture_unit_); + glBindTexture(GL_TEXTURE_2D, eglImage->texture_); + + // Generate texture, bind, associate image to texture, configure, unbind + glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); + + // Nearest filtering + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + + // Wrap to edge to avoid edge artifacts + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); +} + +int eGL::initEGLContext(GBM *gbmContext) +{ + EGLint configAttribs[] = { + EGL_RED_SIZE, 8, + EGL_GREEN_SIZE, 8, + EGL_BLUE_SIZE, 8, + EGL_ALPHA_SIZE, 8, + EGL_SURFACE_TYPE, EGL_WINDOW_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_NONE + }; + + EGLint contextAttribs[] = { + EGL_CONTEXT_MAJOR_VERSION, 2, + EGL_NONE + }; + + EGLint numConfigs; + EGLConfig config; + EGLint major; + EGLint minor; + + if (!eglBindAPI(EGL_OPENGL_ES_API)) { + LOG(eGL, Error) << "API bind fail"; + goto fail; + } + + //TODO: use optional eglGetPlatformDisplayEXT ? + display_ = eglGetDisplay(gbmContext->getDevice()); + if (display_ == EGL_NO_DISPLAY) { + LOG(eGL, Error) << "Unable to get EGL display"; + goto fail; + } + + if (eglInitialize(display_, &major, &minor) != EGL_TRUE) { + LOG(eGL, Error) << "eglInitialize fail"; + goto fail; + } + + LOG(eGL, Info) << "EGL: version " << major << "." << minor; + LOG(eGL, Info) << "EGL: EGL_VERSION: " << eglQueryString(display_, EGL_VERSION); + LOG(eGL, Info) << "EGL: EGL_VENDOR: " << eglQueryString(display_, EGL_VENDOR); + LOG(eGL, Info) << "EGL: EGL_CLIENT_APIS: " << eglQueryString(display_, EGL_CLIENT_APIS); + LOG(eGL, Info) << "EGL: EGL_EXTENSIONS: " << eglQueryString(display_, EGL_EXTENSIONS); + + //TODO: interrogate strings to make sure we aren't hooking unsupported functions + // and remember to error out if a function we depend on isn't found. + // we don't use these functions right now but expect to for DMA backed + // texture generation and render-to-texture. One thing we can do is differentiate + // between DMA and non-DMA texture generation based on the presence of these functions + // In reality most - all ? - mesa implementations have these extensions so + // probably no fallback will be required + eglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)eglGetProcAddress("eglCreateImageKHR"); + if (!eglCreateImageKHR) + LOG(eGL, Warning) << "eglCreateImageKHR not found"; + + eglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)eglGetProcAddress("eglDestroyImageKHR"); + if (!eglDestroyImageKHR) + LOG(eGL, Warning) << "eglDestroyImageKHR not found"; + + eglExportDMABUFImageMESA = (PFNEGLEXPORTDMABUFIMAGEMESAPROC)eglGetProcAddress("eglExportDMABUFImageMESA"); + if (!eglExportDMABUFImageMESA) + LOG(eGL, Warning) << "eglExportDMABUFImageMESA not found"; + + glEGLImageTargetTexture2DOES = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress("glEGLImageTargetTexture2DOES"); + if (!glEGLImageTargetTexture2DOES) + LOG(eGL, Warning) << "glEGLImageTargetTexture2DOES not found"; + + eglClientWaitSyncKHR = (PFNEGLCLIENTWAITSYNCKHRPROC)eglGetProcAddress("eglClientWaitSyncKHR"); + if (!eglClientWaitSyncKHR) + LOG(eGL, Warning) << "eglClientWaitSyncKHR not found"; + + eglCreateSyncKHR = (PFNEGLCREATESYNCKHRPROC)eglGetProcAddress("eglCreateSyncKHR"); + if (!eglCreateSyncKHR) + LOG(eGL, Warning) << "eglCreateSyncKHR not found"; + + if (eglChooseConfig(display_, configAttribs, &config, 1, &numConfigs) != EGL_TRUE) { + LOG(eGL, Error) << "eglChooseConfig fail"; + goto fail; + } + + context_ = eglCreateContext(display_, config, EGL_NO_CONTEXT, contextAttribs); + if (context_ == EGL_NO_CONTEXT) { + LOG(eGL, Error) << "eglContext returned EGL_NO_CONTEXT"; + goto fail; + } + + surface_ = eglCreateWindowSurface(display_, config, + (EGLNativeWindowType)gbmContext->getSurface(), + NULL); + if (surface_ == EGL_NO_SURFACE) { + LOG(eGL, Error) << "eglCreateWindowSurface fail"; + goto fail; + } + + makeCurrent(); + swapBuffers(); + + return 0; +fail: + + return -ENODEV; +} + +void eGL::makeCurrent(void) +{ + if (eglMakeCurrent(display_, surface_, surface_, context_) != EGL_TRUE) { + LOG(eGL, Error) << "eglMakeCurrent fail"; + } +} + +void eGL::swapBuffers(void) +{ + if (eglSwapBuffers(display_, surface_) != EGL_TRUE) { + LOG(eGL, Error) << "eglSwapBuffers fail"; + } +} + +void eGL::useProgram(GLuint programId) +{ + glUseProgram(programId); +} + +void eGL::pushEnv(std::vector &shaderEnv, const char *str) +{ + std::string addStr = str; + + addStr.push_back('\n'); + shaderEnv.push_back(addStr); +} + +int eGL::compileVertexShader(GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + std::vector shaderEnv) +{ + return compileShader(GL_VERTEX_SHADER, shaderId, shaderData, shaderDataLen, shaderEnv); +} + +int eGL::compileFragmentShader(GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + std::vector shaderEnv) +{ + return compileShader(GL_FRAGMENT_SHADER, shaderId, shaderData, shaderDataLen, shaderEnv); +} + +int eGL::compileShader(int shaderType, GLuint &shaderId, unsigned char *shaderData, + unsigned int shaderDataLen, + std::vector shaderEnv) +{ + GLchar **shaderSourceData; + GLint *shaderDataLengths; + GLint success; + GLsizei count; + size_t i; + + count = 1 + shaderEnv.size(); + shaderSourceData = new GLchar *[count]; + shaderDataLengths = new GLint[count]; + + // Prefix defines before main body of shader + for (i = 0; i < shaderEnv.size(); i++) { + shaderSourceData[i] = (GLchar *)shaderEnv[i].c_str(); + shaderDataLengths[i] = shaderEnv[i].length(); + } + + // Now the main body of the shader program + shaderSourceData[i] = (GLchar *)shaderData; + shaderDataLengths[i] = shaderDataLen; + + // And create the shader + shaderId = glCreateShader(shaderType); + glShaderSource(shaderId, count, shaderSourceData, shaderDataLengths); + glCompileShader(shaderId); + + // Check status + glGetShaderiv(shaderId, GL_COMPILE_STATUS, &success); + if (success == GL_FALSE) { + GLint sizeLog = 0; + GLchar *infoLog; + + glGetShaderiv(shaderId, GL_INFO_LOG_LENGTH, &sizeLog); + infoLog = new GLchar[sizeLog]; + + glGetShaderInfoLog(shaderId, sizeLog, &sizeLog, infoLog); + LOG(eGL, Error) << infoLog; + + delete[] infoLog; + } + + delete[] shaderSourceData; + delete[] shaderDataLengths; + + return !(success == GL_TRUE); +} + +void eGL::dumpShaderSource(GLuint shaderId) +{ + GLint shaderLength = 0; + GLchar *shaderSource; + + glGetShaderiv(shaderId, GL_SHADER_SOURCE_LENGTH, &shaderLength); + + LOG(eGL, Debug) << "Shader length is " << shaderLength; + + if (shaderLength > 0) { + shaderSource = new GLchar[shaderLength]; + if (!shaderSource) + return; + + glGetShaderSource(shaderId, shaderLength, &shaderLength, shaderSource); + if (shaderLength) { + LOG(eGL, Debug) << "Shader source = " << shaderSource; + } + delete[] shaderSource; + } +} + +int eGL::linkProgram(GLuint &programId, GLuint vertexshaderId, GLuint fragmentshaderId) +{ + GLint success; + GLenum err; + + programId = glCreateProgram(); + if (!programId) + goto fail; + + glAttachShader(programId, vertexshaderId); + if ((err = glGetError()) != GL_NO_ERROR) { + LOG(eGL, Error) << "Attach compute vertex shader fail"; + goto fail; + } + + glAttachShader(programId, fragmentshaderId); + if ((err = glGetError()) != GL_NO_ERROR) { + LOG(eGL, Error) << "Attach compute vertex shader fail"; + goto fail; + } + + glLinkProgram(programId); + if ((err = glGetError()) != GL_NO_ERROR) { + LOG(eGL, Error) << "Link program fail"; + goto fail; + } + + glDetachShader(programId, fragmentshaderId); + glDetachShader(programId, vertexshaderId); + + // Check status + glGetProgramiv(programId, GL_LINK_STATUS, &success); + if (success == GL_FALSE) { + GLint sizeLog = 0; + GLchar *infoLog; + + glGetProgramiv(programId, GL_INFO_LOG_LENGTH, &sizeLog); + infoLog = new GLchar[sizeLog]; + + glGetProgramInfoLog(programId, sizeLog, &sizeLog, infoLog); + LOG(eGL, Error) << infoLog; + + delete[] infoLog; + goto fail; + } + + return 0; +fail: + return -ENODEV; +} +} // namespace libcamera diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 0d004694..491eb734 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -77,6 +77,27 @@ if libgbm.found() and gbm_works ]) endif +libegl = cc.find_library('EGL', required : false) +libglesv2 = cc.find_library('GLESv2', required : false) +mesa_works = cc.check_header('EGL/egl.h', required: false) + +if libegl.found() and mesa_works + config_h.set('HAVE_LIBEGL', 1) +endif + +if libglesv2.found() and mesa_works + config_h.set('HAVE_GLESV2', 1) +endif + +if mesa_works and gbm_works + libcamera_internal_sources += files([ + 'egl.cpp', + ]) + gles_headless_enabled = true +else + gles_headless_enabled = false +endif + subdir('base') subdir('converter') subdir('ipa') @@ -198,7 +219,9 @@ libcamera_deps += [ libcamera_base_private, libcrypto, libdl, + libegl, libgbm, + libglesv2, liblttng, libudev, libyaml, From patchwork Wed Jun 11 01:32: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: 23529 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 1C44FC3327 for ; Wed, 11 Jun 2025 01:34:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1136E68DE8; Wed, 11 Jun 2025 03:34:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XviWcG+t"; dkim-atps=neutral Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B8F1668DDC for ; Wed, 11 Jun 2025 03:34:05 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-451d6ade159so52325025e9.1 for ; Tue, 10 Jun 2025 18:34:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605645; x=1750210445; 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=cbeLiX9T9eWhRxg9hz31JNa42SKGxGnkWbDuxjfPeW8=; b=XviWcG+tlCKJMh6n7/V+rDmE9FBRQU61q2JIlcst3R/0/spsUuHDxJqfOSaklWN7Z0 AMWWFEea4jytnKnPu5wSoIzUqIPSe94UIo8YfbPpD2ZddX3KMT+W+bNPdo4x0jZ0ClMJ hSAKnIwS00W2TmG2GbhG016PNzaiAhPF0QdEFQSmD0AWGFmBn1EMyoRPrAl9PFtzaQq9 e7i0E1ZOlJlERnlZvJgnOvySRSATo5IzCJ2Jf6+vS2clnb9aN/WNxi6yYCb/s9a5bQi3 jj/AnQWNF5450IKFrXAT7SHMrFERQIt+Z7kBB9u5IYymnhe0ntlIdcnT6z+kl9fPB+ce SeWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605645; x=1750210445; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cbeLiX9T9eWhRxg9hz31JNa42SKGxGnkWbDuxjfPeW8=; b=IoVEvpxMUGsSTgoqBMKRMSdTWkjxq2JldkvKsP+79Q+akNeAnv+R2QhavvPNeilm3J F8U7yrMf4ubVYT7QqcGr0DlWD32ONWETr+Xd5d5qlGvHdkekYV+joEnPAMYcuJhnsv16 /UT4zxiLirji76c75xSazMoZdaV+14CmxVTRs601sRjfzsBsBWXjlUJHsmDwUI6tmob8 XS+jkGzyTnztromOUtIqspVoJXVMoecjX4LUir8SAGwuJBmghpUqXD4ffCHBtBeViJfK uYoOz/ZUtjECMGAM4PYKuy58ysIJrn3zzxetTH9cMPGPIZGk9bSrEO9gRbFnTMqO5wDb 8/gg== X-Gm-Message-State: AOJu0Ywo71bQgzPS0zrwsQfvkVuffk/KCvvP6lEM5WSb1HzsfwskhKsf ISndxctLeFsx0En9PQkQ34/do1iT5+WRXYxJWthBeRHQgkDteYAjRG07rXa36/J2kqTYwg6SCoI OdggRkoA= X-Gm-Gg: ASbGncuBWWW86VP/y+QFLzSCQrzyjUxVBdLm7t/vmdPqF619Jn1ZyYRSRC5tPGy9Wwu Lw/ttFFHgmHJ34EA2MPBDM4mEuJ1OdXw9J7AsT6szrqFq0379HgDOqsTb026xny0fi+p0wn8KUd yKnIR6tRH6ABFBLfZExriFh3Ub4LGAvEyB+PaDS8taADDweGKPh2wZ4PnxGAI2qWn+Ecij9ZvQP bWXTDf7s4ApjWf5iXuuvwfkDQ0ejPoevifWAPBNQFhMi//EWtquArV2rCClhQZYhLdI8LcoUgY2 Fve+hfsSq48QgYvVwMltWaTrBWbHpXpiPfiqFPrXO4gjHJpqZrSDZyJ7hBW1bKmm0Z5SIanqKqo tSTzO2CSubQ01R9ZU+w6//Cv5VNcvRx+OF2p2hPg9qg== X-Google-Smtp-Source: AGHT+IGmuXq2a199kSr/EN0+RFjLmqzX6THHny4qqEuwdRT71SNSoMaCl6TGWmoQ6WxH+yqDNvrFLw== X-Received: by 2002:a05:600c:35c9:b0:440:61eb:2ce5 with SMTP id 5b1f17b1804b1-453248c7edfmr9793225e9.17.1749605644845; Tue, 10 Jun 2025 18:34:04 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:04 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 23/35] libcamera: software_isp: debayer_egl: Add an eGL debayer class Date: Wed, 11 Jun 2025 02:32:33 +0100 Message-ID: <20250611013245.133785-24-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a class to run the existing glsl debayer shaders on a GBM surface. Signed-off-by: Bryan O'Donoghue libcamera: software_isp: debayer_egl: Extend logic to enable application of softISP RGB debayer params The existing SoftISP calculates RGB gain values as a lookup table of 256 values which shifts for each frame depending on the required correction. We can pass the required tables into the debayer shaders as textures, one texture for R, G and B respectively. The debayer shader will do its debayer interpolation and then if the appropriate define is specified use the calculated R, G and B values as indexes into our bayer colour gain table. Signed-off-by: Bryan O'Donoghue --- src/libcamera/egl.cpp | 4 +- src/libcamera/software_isp/debayer_egl.cpp | 587 +++++++++++++++++++++ src/libcamera/software_isp/debayer_egl.h | 164 ++++++ src/libcamera/software_isp/meson.build | 8 + 4 files changed, 761 insertions(+), 2 deletions(-) create mode 100644 src/libcamera/software_isp/debayer_egl.cpp create mode 100644 src/libcamera/software_isp/debayer_egl.h diff --git a/src/libcamera/egl.cpp b/src/libcamera/egl.cpp index 89ece148..c6b0f9a5 100644 --- a/src/libcamera/egl.cpp +++ b/src/libcamera/egl.cpp @@ -82,13 +82,13 @@ void eGL::destroyDMABufTexture(eGLImage *eglImage) // // Generate a 2D texture from an input buffer directly -void eGL::createTexture2D(eGLImage *eglImage, uint32_t width, uint32_t height, void *data) +void eGL::createTexture2D(eGLImage *eglImage, GLint format, uint32_t width, uint32_t height, void *data) { glActiveTexture(eglImage->texture_unit_); glBindTexture(GL_TEXTURE_2D, eglImage->texture_); // Generate texture, bind, associate image to texture, configure, unbind - glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, data); + glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, format, GL_UNSIGNED_BYTE, data); // Nearest filtering glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp new file mode 100644 index 00000000..3fb15511 --- /dev/null +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -0,0 +1,587 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2024, Linaro Ltd. + * + * Authors: + * Bryan O'Donoghue + * + * debayer_cpu.cpp - EGL based debayering class + */ + +#include +#include +#include + +#include + +#include "libcamera/internal/glsl_shaders.h" +#include "debayer_egl.h" + +namespace libcamera { + +DebayerEGL::DebayerEGL(std::unique_ptr stats) + : Debayer(), stats_(std::move(stats)) +{ + eglImageBayerIn_ = eglImageRedLookup_ = eglImageBlueLookup_ = eglImageGreenLookup_ = NULL; +} + +DebayerEGL::~DebayerEGL() +{ + if (eglImageBlueLookup_) + delete eglImageBlueLookup_; + + if (eglImageGreenLookup_) + delete eglImageGreenLookup_; + + if (eglImageRedLookup_) + delete eglImageRedLookup_; + + if (eglImageBayerIn_) + delete eglImageBayerIn_; +} + +int DebayerEGL::getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config) +{ + BayerFormat bayerFormat = + BayerFormat::fromPixelFormat(inputFormat); + + if ((bayerFormat.bitDepth == 8 || bayerFormat.bitDepth == 10) && + bayerFormat.packing == BayerFormat::Packing::None && + isStandardBayerOrder(bayerFormat.order)) { + config.bpp = (bayerFormat.bitDepth + 7) & ~7; + config.patternSize.width = 2; + config.patternSize.height = 2; + config.outputFormats = std::vector({ formats::XRGB8888, + formats::ARGB8888, + formats::XBGR8888, + formats::ABGR8888 }); + return 0; + } + + if (bayerFormat.bitDepth == 10 && + bayerFormat.packing == BayerFormat::Packing::CSI2 && + isStandardBayerOrder(bayerFormat.order)) { + config.bpp = 10; + config.patternSize.width = 4; /* 5 bytes per *4* pixels */ + config.patternSize.height = 2; + config.outputFormats = std::vector({ formats::XRGB8888, + formats::ARGB8888, + formats::XBGR8888, + formats::ABGR8888 }); + return 0; + } + + LOG(Debayer, Info) + << "Unsupported input format " << inputFormat.toString(); + return -EINVAL; +} + +int DebayerEGL::getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config) +{ + if (outputFormat == formats::XRGB8888 || outputFormat == formats::ARGB8888 || + outputFormat == formats::XBGR8888 || outputFormat == formats::ABGR8888) { + config.bpp = 32; + return 0; + } + + LOG(Debayer, Error) + << "Unsupported output format " << outputFormat.toString(); + + return -EINVAL; +} + +int DebayerEGL::getShaderVariableLocations(void) +{ + attributeVertex_ = glGetAttribLocation(programId_, "vertexIn"); + attributeTexture_ = glGetAttribLocation(programId_, "textureIn"); + + textureUniformBayerDataIn_ = glGetUniformLocation(programId_, "tex_y"); + textureUniformRedLookupDataIn_ = glGetUniformLocation(programId_, "red_param"); + textureUniformGreenLookupDataIn_ = glGetUniformLocation(programId_, "green_param"); + textureUniformBlueLookupDataIn_ = glGetUniformLocation(programId_, "blue_param"); + + textureUniformStep_ = glGetUniformLocation(programId_, "tex_step"); + textureUniformSize_ = glGetUniformLocation(programId_, "tex_size"); + textureUniformStrideFactor_ = glGetUniformLocation(programId_, "stride_factor"); + textureUniformBayerFirstRed_ = glGetUniformLocation(programId_, "tex_bayer_first_red"); + textureUniformProjMatrix_ = glGetUniformLocation(programId_, "proj_matrix"); + + LOG(Debayer, Debug) << "vertexIn " << attributeVertex_ << " textureIn " << attributeTexture_ + << " tex_y " << textureUniformBayerDataIn_ + << " red_param " << textureUniformRedLookupDataIn_ + << " green_param " << textureUniformGreenLookupDataIn_ + << " blue_param " << textureUniformBlueLookupDataIn_ + << " tex_step " << textureUniformStep_ + << " tex_size " << textureUniformSize_ + << " stride_factor " << textureUniformStrideFactor_ + << " tex_bayer_first_red " << textureUniformBayerFirstRed_ + << " proj_matrix " << textureUniformProjMatrix_; + return 0; +} + +int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputFormat) +{ + std::vector shaderEnv; + unsigned int fragmentShaderDataLen; + unsigned char *fragmentShaderData; + unsigned int vertexShaderDataLen; + unsigned char *vertexShaderData; + GLenum err; + + // Target gles 100 glsl requires "#version x" as first directive in shader + egl_.pushEnv(shaderEnv, "#version 100"); + + // Specify GL_OES_EGL_image_external + egl_.pushEnv(shaderEnv, "#extension GL_OES_EGL_image_external: enable"); + + // Tell shaders how to re-order output taking account of how the + // pixels are actually stored by GBM + switch (outputFormat) { + case formats::ARGB8888: + case formats::XRGB8888: + break; + case formats::ABGR8888: + case formats::XBGR8888: + egl_.pushEnv(shaderEnv, "#define SWAP_BLUE"); + break; + default: + goto invalid_fmt; + } + + // Pixel location parameters + switch (inputFormat) { + case libcamera::formats::SBGGR8: + case libcamera::formats::SBGGR10_CSI2P: + case libcamera::formats::SBGGR12_CSI2P: + firstRed_x_ = 1.0; + firstRed_y_ = 1.0; + break; + case libcamera::formats::SGBRG8: + case libcamera::formats::SGBRG10_CSI2P: + case libcamera::formats::SGBRG12_CSI2P: + firstRed_x_ = 0.0; + firstRed_y_ = 1.0; + break; + case libcamera::formats::SGRBG8: + case libcamera::formats::SGRBG10_CSI2P: + case libcamera::formats::SGRBG12_CSI2P: + firstRed_x_ = 1.0; + firstRed_y_ = 0.0; + break; + case libcamera::formats::SRGGB8: + case libcamera::formats::SRGGB10_CSI2P: + case libcamera::formats::SRGGB12_CSI2P: + firstRed_x_ = 0.0; + firstRed_y_ = 0.0; + break; + default: + goto invalid_fmt; + break; + }; + + // Shader selection + switch (inputFormat) { + case libcamera::formats::SBGGR8: + case libcamera::formats::SGBRG8: + case libcamera::formats::SGRBG8: + case libcamera::formats::SRGGB8: + fragmentShaderData = bayer_8_frag; + fragmentShaderDataLen = bayer_8_frag_len; + vertexShaderData = bayer_8_vert; + vertexShaderDataLen = bayer_8_vert_len; + break; + case libcamera::formats::SBGGR10_CSI2P: + case libcamera::formats::SGBRG10_CSI2P: + case libcamera::formats::SGRBG10_CSI2P: + case libcamera::formats::SRGGB10_CSI2P: + egl_.pushEnv(shaderEnv, "#define RAW10P"); + fragmentShaderData = bayer_1x_packed_frag; + fragmentShaderDataLen = bayer_1x_packed_frag_len; + vertexShaderData = identity_vert; + vertexShaderDataLen = identity_vert_len; + break; + case libcamera::formats::SBGGR12_CSI2P: + case libcamera::formats::SGBRG12_CSI2P: + case libcamera::formats::SGRBG12_CSI2P: + case libcamera::formats::SRGGB12_CSI2P: + egl_.pushEnv(shaderEnv, "#define RAW12P"); + fragmentShaderData = bayer_1x_packed_frag; + fragmentShaderDataLen = bayer_1x_packed_frag_len; + vertexShaderData = identity_vert; + vertexShaderDataLen = identity_vert_len; + break; + default: + goto invalid_fmt; + break; + }; + + // Flag to shaders that we have parameter gain tables + egl_.pushEnv(shaderEnv, "#define APPLY_RGB_PARAMETERS"); + + if (egl_.compileVertexShader(vertexShaderId_, vertexShaderData, vertexShaderDataLen, shaderEnv)) + goto compile_fail; + + if (egl_.compileFragmentShader(fragmentShaderId_, fragmentShaderData, fragmentShaderDataLen, shaderEnv)) + goto compile_fail; + + if (egl_.linkProgram(programId_, vertexShaderId_, fragmentShaderId_)) + goto link_fail; + + egl_.dumpShaderSource(vertexShaderId_); + egl_.dumpShaderSource(fragmentShaderId_); + + /* Ensure we set the programId_ */ + egl_.useProgram(programId_); + err = glGetError(); + if (err != GL_NO_ERROR) + goto program_fail; + + if (getShaderVariableLocations()) + goto parameters_fail; + + return 0; + +parameters_fail: + LOG(Debayer, Error) << "Program parameters fail"; + return -ENODEV; + +program_fail: + LOG(Debayer, Error) << "Use program error " << err; + return -ENODEV; + +link_fail: + LOG(Debayer, Error) << "Linking program fail"; + return -ENODEV; + +compile_fail: + LOG(Debayer, Error) << "Compile debayer shaders fail"; + return -ENODEV; + +invalid_fmt: + LOG(Debayer, Error) << "Unsupported input output format combination"; + return -EINVAL; +} + +int DebayerEGL::configure(const StreamConfiguration &inputCfg, + const std::vector> &outputCfgs, + bool ccmEnabled) +{ + if (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0) + return -EINVAL; + + if (stats_->configure(inputCfg) != 0) + return -EINVAL; + + const Size &stats_pattern_size = stats_->patternSize(); + if (inputConfig_.patternSize.width != stats_pattern_size.width || + inputConfig_.patternSize.height != stats_pattern_size.height) { + LOG(Debayer, Error) + << "mismatching stats and debayer pattern sizes for " + << inputCfg.pixelFormat.toString(); + return -EINVAL; + } + + inputConfig_.stride = inputCfg.stride; + width_ = inputCfg.size.width; + height_ = inputCfg.size.height; + ccmEnabled_ = ccmEnabled = false; + + if (outputCfgs.size() != 1) { + LOG(Debayer, Error) + << "Unsupported number of output streams: " + << outputCfgs.size(); + return -EINVAL; + } + + LOG(Debayer, Info) << "Input size " << inputCfg.size << " stride " << inputCfg.stride; + + if (gbmSurface_.initSurface(inputCfg.size.width, inputCfg.size.height)) + return -ENODEV; + + if (egl_.initEGLContext(&gbmSurface_)) + return -ENODEV; + + glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureImageUnits); + LOG(Debayer, Debug) << "Fragment shader maximum texture units " << maxTextureImageUnits; + + if (maxTextureImageUnits < DEBAYER_EGL_MIN_SIMPLE_RGB_GAIN_TEXTURE_UNITS) { + LOG(Debayer, Error) << "Fragment shader texture unit count " << maxTextureImageUnits + << " required minimum for RGB gain table lookup " << DEBAYER_EGL_MIN_SIMPLE_RGB_GAIN_TEXTURE_UNITS + << " try using an identity CCM "; + return -ENODEV; + } + // Raw bayer input as texture + eglImageBayerIn_ = new eGLImage(width_, height_, 32, GL_TEXTURE0, 0); + if (!eglImageBayerIn_) + return -ENOMEM; + + /// RGB correction tables as 2d textures + // eGL doesn't support glTexImage1D so we do a little hack with 2D to compensate + eglImageRedLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE1, 1); + if (!eglImageRedLookup_) + return -ENOMEM; + + eglImageGreenLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE2, 2); + if (!eglImageGreenLookup_) + return -ENOMEM; + + eglImageBlueLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE3, 3); + if (!eglImageBlueLookup_) + return -ENOMEM; + + // Create a single BO (calling gbm_surface_lock_front_buffer() again before gbm_surface_release_buffer() would create another BO) + if (gbmSurface_.mapSurface()) + return -ENODEV; + + StreamConfiguration &outputCfg = outputCfgs[0]; + SizeRange outSizeRange = sizes(inputCfg.pixelFormat, inputCfg.size); + + outputConfig_.stride = gbmSurface_.getStride(); + outputConfig_.frameSize = gbmSurface_.getFrameSize(); + + LOG(Debayer, Debug) << "Overriding stream config stride " + << outputCfg.stride << " with GBM surface stride " + << outputConfig_.stride; + outputCfg.stride = outputConfig_.stride; + + if (!outSizeRange.contains(outputCfg.size) || outputConfig_.stride != outputCfg.stride) { + LOG(Debayer, Error) + << "Invalid output size/stride: " + << "\n " << outputCfg.size << " (" << outSizeRange << ")" + << "\n " << outputCfg.stride << " (" << outputConfig_.stride << ")"; + return -EINVAL; + } + + window_.x = ((inputCfg.size.width - outputCfg.size.width) / 2) & + ~(inputConfig_.patternSize.width - 1); + window_.y = ((inputCfg.size.height - outputCfg.size.height) / 2) & + ~(inputConfig_.patternSize.height - 1); + window_.width = outputCfg.size.width; + window_.height = outputCfg.size.height; + + /* Don't pass x,y since process() already adjusts src before passing it */ + stats_->setWindow(Rectangle(window_.size())); + + LOG(Debayer, Debug) << "Input width " << inputCfg.size.width << " height " << inputCfg.size.height; + LOG(Debayer, Debug) << "Output width " << outputCfg.size.width << " height " << outputCfg.size.height; + LOG(Debayer, Debug) << "Output stride " << outputCfg.size.width << " height " << outputCfg.size.height; + + if (initBayerShaders(inputCfg.pixelFormat, outputCfg.pixelFormat)) + return -EINVAL; + + return 0; +} + +Size DebayerEGL::patternSize(PixelFormat inputFormat) +{ + DebayerEGL::DebayerInputConfig config; + + if (getInputConfig(inputFormat, config) != 0) + return {}; + + return config.patternSize; +} + +std::vector DebayerEGL::formats(PixelFormat inputFormat) +{ + DebayerEGL::DebayerInputConfig config; + + if (getInputConfig(inputFormat, config) != 0) + return std::vector(); + + return config.outputFormats; +} + +std::tuple +DebayerEGL::strideAndFrameSize(const PixelFormat &outputFormat, const Size &size) +{ + DebayerEGL::DebayerOutputConfig config; + + if (getOutputConfig(outputFormat, config) != 0) + return std::make_tuple(0, 0); + + /* round up to multiple of 8 for 64 bits alignment */ + unsigned int stride = (size.width * config.bpp / 8 + 7) & ~7; + + return std::make_tuple(stride, stride * size.height); +} + +void DebayerEGL::setShaderVariableValues(void) +{ + /* + * Raw Bayer 8-bit, and packed raw Bayer 10-bit/12-bit formats + * are stored in a GL_LUMINANCE texture. The texture width is + * equal to the stride. + */ + GLfloat firstRed[] = { firstRed_x_, firstRed_y_ }; + GLfloat imgSize[] = { (GLfloat)width_, + (GLfloat)height_ }; + GLfloat Step[] = { 1.0f / (inputConfig_.stride - 1), + 1.0f / (height_ - 1) }; + GLfloat Stride = 1.0f; + GLfloat projIdentityMatrix[] = { + 1, 0, 0, 0, + 0, 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + }; + + // vertexIn - bayer_8.vert + glEnableVertexAttribArray(attributeVertex_); + glVertexAttribPointer(attributeVertex_, 2, GL_FLOAT, GL_TRUE, + 2 * sizeof(GLfloat), vcoordinates); + + // textureIn - bayer_8.vert + glEnableVertexAttribArray(attributeTexture_); + glVertexAttribPointer(attributeTexture_, 2, GL_FLOAT, GL_TRUE, + 2 * sizeof(GLfloat), tcoordinates); + + // Set the sampler2D to the respective texture unit for each texutre + // To simultaneously sample multiple textures we need to use multiple + // texture units + glUniform1i(textureUniformBayerDataIn_, eglImageBayerIn_->texture_unit_uniform_id_); + glUniform1i(textureUniformRedLookupDataIn_, eglImageRedLookup_->texture_unit_uniform_id_); + glUniform1i(textureUniformGreenLookupDataIn_, eglImageGreenLookup_->texture_unit_uniform_id_); + glUniform1i(textureUniformBlueLookupDataIn_, eglImageBlueLookup_->texture_unit_uniform_id_); + + // These values are: + // firstRed = tex_bayer_first_red - bayer_8.vert + // imgSize = tex_size - bayer_8.vert + // step = tex_step - bayer_8.vert + // Stride = stride_factor identity.vert + // textureUniformProjMatri = No scaling + glUniform2fv(textureUniformBayerFirstRed_, 1, firstRed); + glUniform2fv(textureUniformSize_, 1, imgSize); + glUniform2fv(textureUniformStep_, 1, Step); + glUniform1f(textureUniformStrideFactor_, Stride); + glUniformMatrix4fv(textureUniformProjMatrix_, 1, + GL_FALSE, projIdentityMatrix); + + LOG(Debayer, Debug) << "vertexIn " << attributeVertex_ << " textureIn " << attributeTexture_ + << " tex_y " << textureUniformBayerDataIn_ + << " red_param " << textureUniformRedLookupDataIn_ + << " green_param " << textureUniformGreenLookupDataIn_ + << " blue_param " << textureUniformBlueLookupDataIn_ + << " tex_step " << textureUniformStep_ + << " tex_size " << textureUniformSize_ + << " stride_factor " << textureUniformStrideFactor_ + << " tex_bayer_first_red " << textureUniformBayerFirstRed_; + + LOG (Debayer, Debug) << "textureUniformY_ = 0 " << + " firstRed.x " << firstRed[0] << + " firstRed.y " << firstRed[1] << + " textureUniformSize_.width " << imgSize[0] << " " + " textureUniformSize_.height " << imgSize[1] << + " textureUniformStep_.x " << Step[0] << + " textureUniformStep_.y " << Step[1] << + " textureUniformStrideFactor_ " << Stride << + " textureUniformProjMatrix_ " << textureUniformProjMatrix_; + return; +} + +void DebayerEGL::debayerGPU(MappedFrameBuffer &in, MappedFrameBuffer &out, DebayerParams ¶ms) +{ + LOG(Debayer, Debug) + << "Input height " << height_ + << " width " << width_ + << " fd " << in.getPlaneFD(0); + + // eGL context switch + egl_.makeCurrent(); + + // Greate a standard texture + // we will replace this with the DMA version at some point + egl_.createTexture2D(eglImageBayerIn_, inputConfig_.stride, height_, in.planes()[0].data()); + + // Populate bayer parameters + egl_.createTexture2D(eglImageRedLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.red); + egl_.createTexture2D(eglImageGreenLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.green); + egl_.createTexture2D(eglImageBlueLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.blue); + + // Setup the scene + setShaderVariableValues(); + glViewport(0, 0, width_, height_); + glClear(GL_COLOR_BUFFER_BIT); + glDisable(GL_BLEND); + + // Draw the scene + glDrawArrays(GL_TRIANGLE_FAN, 0, DEBAYER_OPENGL_COORDS); + + // eglclientWaitScynKhr / eglwaitsynckr ? + egl_.swapBuffers(); + + // Copy from the output GBM buffer to our output plane + // once we get render to texture working the + // explicit lock ioctl, memcpy and unlock ioctl won't be required + gbmSurface_.getFrameBufferData(out.planes()[0].data(), out.planes()[0].size()); +} + +void DebayerEGL::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params) +{ + bench_.startFrame(); + + std::vector dmaSyncers; + + dmaSyncBegin(dmaSyncers, input, output); + + setParams(params); + + /* Copy metadata from the input buffer */ + FrameMetadata &metadata = output->_d()->metadata(); + metadata.status = input->metadata().status; + metadata.sequence = input->metadata().sequence; + metadata.timestamp = input->metadata().timestamp; + + MappedFrameBuffer in(input, MappedFrameBuffer::MapFlag::Read); + MappedFrameBuffer out(output, MappedFrameBuffer::MapFlag::Write); + if (!in.isValid() || !out.isValid()) { + LOG(Debayer, Error) << "mmap-ing buffer(s) failed"; + metadata.status = FrameMetadata::FrameError; + return; + } + + debayerGPU(in, out, params); + + dmaSyncers.clear(); + + bench_.finishFrame(); + + metadata.planes()[0].bytesused = out.planes()[0].size(); + + // Calculate stats for the whole frame + stats_->processFrame(frame, 0, input); + + outputBufferReady.emit(output); + inputBufferReady.emit(input); +} + +SizeRange DebayerEGL::sizes(PixelFormat inputFormat, const Size &inputSize) +{ + Size patternSize = this->patternSize(inputFormat); + unsigned int borderHeight = patternSize.height; + + if (patternSize.isNull()) + return {}; + + /* No need for top/bottom border with a pattern height of 2 */ + if (patternSize.height == 2) + borderHeight = 0; + + /* + * For debayer interpolation a border is kept around the entire image + * and the minimum output size is pattern-height x pattern-width. + */ + if (inputSize.width < (3 * patternSize.width) || + inputSize.height < (2 * borderHeight + patternSize.height)) { + LOG(Debayer, Warning) + << "Input format size too small: " << inputSize.toString(); + return {}; + } + + return SizeRange(Size(patternSize.width, patternSize.height), + Size((inputSize.width - 2 * patternSize.width) & ~(patternSize.width - 1), + (inputSize.height - 2 * borderHeight) & ~(patternSize.height - 1)), + patternSize.width, patternSize.height); +} + +} /* namespace libcamera */ diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h new file mode 100644 index 00000000..c0fc220f --- /dev/null +++ b/src/libcamera/software_isp/debayer_egl.h @@ -0,0 +1,164 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2025, Bryan O'Donoghue. + * + * Authors: + * Bryan O'Donoghue + * + * debayer_opengl.h - EGL debayer header + */ + +#pragma once + +#include +#include +#include + +#define GL_GLEXT_PROTOTYPES +#define EGL_EGLEXT_PROTOTYPES +#include +#include +#include + +#include + +#include "debayer.h" + +#include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/egl.h" +#include "libcamera/internal/framebuffer.h" +#include "libcamera/internal/mapped_framebuffer.h" +#include "libcamera/internal/software_isp/benchmark.h" +#include "libcamera/internal/software_isp/swstats_cpu.h" + +namespace libcamera { + +#define DEBAYER_EGL_MIN_SIMPLE_RGB_GAIN_TEXTURE_UNITS 4 +#define DEBAYER_OPENGL_COORDS 4 + +/** + * \class DebayerEGL + * \brief Class for debayering using an EGL Shader + * + * Implements an EGL shader based debayering solution. + */ +class DebayerEGL : public Debayer +{ +public: + /** + * \brief Constructs a DebayerEGL object. + * \param[in] stats Pointer to the stats object to use. + */ + DebayerEGL(std::unique_ptr stats); + ~DebayerEGL(); + + /* + * Setup the Debayer object according to the passed in parameters. + * Return 0 on success, a negative errno value on failure + * (unsupported parameters). + */ + int configure(const StreamConfiguration &inputCfg, + const std::vector> &outputCfgs, + bool ccmEnabled); + + /* + * Get width and height at which the bayer-pattern repeats. + * Return pattern-size or an empty Size for an unsupported inputFormat. + */ + Size patternSize(PixelFormat inputFormat); + + std::vector formats(PixelFormat input); + std::tuple strideAndFrameSize(const PixelFormat &outputFormat, const Size &size); + + void process(uint32_t frame, FrameBuffer *input, FrameBuffer *output, DebayerParams params); + + /** + * \brief Get the file descriptor for the statistics. + * + * \return the file descriptor pointing to the statistics. + */ + const SharedFD &getStatsFD() { return stats_->getStatsFD(); } + + /** + * \brief Get the output frame size. + * + * \return The output frame size. + */ + unsigned int frameSize() { return outputConfig_.frameSize; } + + SizeRange sizes(PixelFormat inputFormat, const Size &inputSize); + +private: + static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); + static int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config); + int setupStandardBayerOrder(BayerFormat::Order order); + void pushEnv(std::vector &shaderEnv, const char *str); + int initBayerShaders(PixelFormat inputFormat, PixelFormat outputFormat); + int initEGLContext(); + int generateTextures(); + int compileShaderProgram(GLuint &shaderId, GLenum shaderType, + unsigned char *shaderData, int shaderDataLen, + std::vector shaderEnv); + int linkShaderProgram(void); + int getShaderVariableLocations(); + void setShaderVariableValues(void); + void configureTexture(GLuint &texture); + void debayerGPU(MappedFrameBuffer &in, MappedFrameBuffer &out, DebayerParams ¶ms); + + // Shader program identifiers + GLuint vertexShaderId_; + GLuint fragmentShaderId_; + GLuint programId_; + enum { + BAYER_INPUT_INDEX = 0, + BAYER_OUTPUT_INDEX, + BAYER_BUF_NUM, + }; + + // Pointer to object representing input texture + eGLImage *eglImageBayerIn_; + + eGLImage *eglImageRedLookup_; + eGLImage *eglImageGreenLookup_; + eGLImage *eglImageBlueLookup_; + + // Shader parameters + float firstRed_x_; + float firstRed_y_; + GLint attributeVertex_; + GLint attributeTexture_; + GLint textureUniformStep_; + GLint textureUniformSize_; + GLint textureUniformStrideFactor_; + GLint textureUniformBayerFirstRed_; + GLint textureUniformProjMatrix_; + + GLint textureUniformBayerDataIn_; + GLint textureUniformRedLookupDataIn_; + GLint textureUniformGreenLookupDataIn_; + GLint textureUniformBlueLookupDataIn_; + + Rectangle window_; + std::unique_ptr stats_; + eGL egl_; + GBM gbmSurface_; + uint32_t width_; + uint32_t height_; + bool ccmEnabled_; + + GLfloat vcoordinates[DEBAYER_OPENGL_COORDS][2] = { + { -1.0f, -1.0f }, + { -1.0f, +1.0f }, + { +1.0f, +1.0f }, + { +1.0f, -1.0f }, + }; + + GLfloat tcoordinates[DEBAYER_OPENGL_COORDS][2] = { + { 0.0f, 1.0f }, + { 0.0f, 0.0f }, + { 1.0f, 0.0f }, + { 1.0f, 1.0f }, + }; +}; + +} /* namespace libcamera */ diff --git a/src/libcamera/software_isp/meson.build b/src/libcamera/software_isp/meson.build index 59fa5f02..c61ac7d5 100644 --- a/src/libcamera/software_isp/meson.build +++ b/src/libcamera/software_isp/meson.build @@ -2,6 +2,7 @@ softisp_enabled = pipelines.contains('simple') summary({'SoftISP support' : softisp_enabled}, section : 'Configuration') +summary({'SoftISP GPU acceleration' : gles_headless_enabled}, section : 'Configuration') if not softisp_enabled subdir_done() @@ -14,3 +15,10 @@ libcamera_internal_sources += files([ 'software_isp.cpp', 'swstats_cpu.cpp', ]) + +if softisp_enabled and gles_headless_enabled + config_h.set('HAVE_DEBAYER_EGL', 1) + libcamera_internal_sources += files([ + 'debayer_egl.cpp', + ]) +endif From patchwork Wed Jun 11 01:32: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: 23530 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 29B55C332F for ; Wed, 11 Jun 2025 01:34:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C976868DED; Wed, 11 Jun 2025 03:34:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="lLudW9Dz"; dkim-atps=neutral Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0AE6F68DE6 for ; Wed, 11 Jun 2025 03:34:08 +0200 (CEST) Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-3a54690d369so2526618f8f.3 for ; Tue, 10 Jun 2025 18:34:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605647; x=1750210447; 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=nN7QQs29c7ZiuR6fFmq8f7fL7inu3gEud9GNwcrxGBU=; b=lLudW9DzfhvKX9v9Bqg7UJ0wg0ekrtzm25FaTy9uTaGS7cTTI9RnFcUTXzwEGgoLzH +NTGAe1vW3mRHf/ffth5Z6mKKxU/qj3OXdRBlzIs40WxATEKQHqkSUyAleOmlqJiGfGr ZChV06ljma7wDrk8IQO9F+y/VO7511Jl/aPMDCelFhzM0KNFxyL6MlLFB3fq6ZaPH5lE erRNzMau8DR3thB6xnILl9QyhSMJLB2fCfYKvf9lWk2oUPyKHQtnelp54GDtLl1pnjUD n6J4MsTRavNpvQckMo2TTZWnOZb1MYhKyyiYxGtOiZecgsw7G6fkZUP7dPmjiCxkI1IB l9Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605647; x=1750210447; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nN7QQs29c7ZiuR6fFmq8f7fL7inu3gEud9GNwcrxGBU=; b=uXC5yU40SiN9EPs5onMedTrT3cVyw6W3rhtoXR3ArFH7Cew1lL+q9vuvrHN77UJVF7 eVLjgklkDgo48zENXXJN8AXNptcSkzlmzkd0GCEaIbaziFsUBI5rkFSzbN55zI1hKjGU XdiYO27ys/UaA0hH+Q0wByAfZG5XmzKGuE/PRLxqEr4KsWR8Qip6U9sMGocCRRa8xydb DDgXOUkpOtYvde5RT5+HBX0/uEUPVZ0fOBBBgl3AR6EAzp7a313SOIdG5Gohz7+cU5oj vV4m7OoCJpLPXd+HvWun87OlXQQ2bP2aum9fOWKX0A1GraGKdrevFvN9nBxm4o6rme3Z R0cA== X-Gm-Message-State: AOJu0YwT2YTQ0c3S6OWtJrNjfCusGND4Ly/+dpGrkYFj9Jc0uTCVPDZF /d7Ci2uZY2TjYYtd8VeXqAyI6Gf/YGNGV1c5LV0cBHIAjKlam9j+S20FGi8Mnz2ebtXbE4smTMj XkDPKQMI= X-Gm-Gg: ASbGnctS4sitFH27HI+f1icRg+BnjyogIhhml6ubMIfX869maGfcAKjpEdBKeXwCrZy WKruGS96YuMoZStVkdIwqt466Glx8Cnzm055I/8vK3Wumn+3imCuMCy7897rVpdBWkxxBfoQnEF nhHLEMfcqBel6oe73Tr+KM8IbrZj+7ElDWsZyolb0vzjycfaXvzzIVf0wuyNv2ulqdNVludjUo3 ZVH+AqUB0QT1qEk6yj2RfJNJdirNbrn23dd0AJk5wCco9ll64MKTuDA6M4/yOxl4wpw47l3iaf2 udYt41+M2IvqFclon4qeDvHOWyLSxfclr3J5ymxi0gdi0tzlS/0QlkhuiIj22fi6SEM22IMlzWs Wbl/Byqsx0GnlumPoJB8c4KJYyHOjkUnf8pbJngTlBykNiV2HK9eu X-Google-Smtp-Source: AGHT+IG7txomHBd4bLRRUyKtkH+QlcXafsKUElr9vUw1lgKNjvJlhLMqfOsLDPbd0zEwq5Dz5UNZnQ== X-Received: by 2002:a05:6000:144f:b0:3a5:1471:d89b with SMTP id ffacd0b85a97d-3a558a426c7mr854224f8f.53.1749605647406; Tue, 10 Jun 2025 18:34:07 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:06 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 24/35] libcamera: software_isp: debayer_egl: Make DebayerEGL an environment option Date: Wed, 11 Jun 2025 02:32:34 +0100 Message-ID: <20250611013245.133785-25-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" If GPUISP support is available make it so an environment variable can switch it on. Given we don't have full feature parity with CPUISP just yet on pixel format output, we should default to CPUISP mode giving the user the option to switch on GPUISP by setting LIBCAMERA_SOFTISP_MODE=gpu Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/software_isp.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index e8fa8a17..ff4471c0 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -15,6 +15,7 @@ #include #include +#include #include #include @@ -25,6 +26,9 @@ #include "libcamera/internal/software_isp/debayer_params.h" #include "debayer_cpu.h" +#if HAVE_DEBAYER_EGL +#include "debayer_egl.h" +#endif /** * \file software_isp.cpp @@ -114,7 +118,20 @@ SoftwareIsp::SoftwareIsp(PipelineHandler *pipe, const CameraSensor *sensor, } stats->statsReady.connect(this, &SoftwareIsp::statsReady); - debayer_ = std::make_unique(std::move(stats)); +#if HAVE_DEBAYER_EGL + const char *softISPMode = utils::secure_getenv("LIBCAMERA_SOFTISP_MODE"); + + if (softISPMode && !strcmp(softISPMode, "gpu")) + debayer_ = std::make_unique(std::move(stats)); +#endif + if (!debayer_) + debayer_ = std::make_unique(std::move(stats)); + + if (!debayer_) { + LOG(SoftwareIsp, Error) << "Failed to create Debayer object"; + return; + } + debayer_->inputBufferReady.connect(this, &SoftwareIsp::inputReady); debayer_->outputBufferReady.connect(this, &SoftwareIsp::outputReady); From patchwork Wed Jun 11 01:32: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: 23531 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 44B53C3330 for ; Wed, 11 Jun 2025 01:34:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id CD9C768DF0; Wed, 11 Jun 2025 03:34:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="XN8ghr73"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id E509768DBD for ; Wed, 11 Jun 2025 03:34:10 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-450cfb6a794so39717245e9.1 for ; Tue, 10 Jun 2025 18:34:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605650; x=1750210450; 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=pgxhz6GMo/Uz+bg1jme6l3ObzPAtkWH3ImPuJmWGaLM=; b=XN8ghr73/06hzpAQ6xWdnyhInVJ3027L7+rRQ7oaWpi7bU+zDKHQECr98YPWkZ9Akg xmtUL1ZXw0HP9sQ0m1HZwBRznerAtz0/oUPPp4j7pJaCi3ys/kqhJVj7XhTxv3alAsBf dUNfzwK35YLblLm02MQaCYCEFwMNyZLH+TmKGMP16VWnlOvGOO4BYhNQZI1Tvi1jc7Zb TZK7cUsvKW94er4THxv7j8giV51YEq1TXoypxS11xpXBpKOdSIwxXBfbAowvdYqr9EgW aavWLBnyW/XZq1BZ5vtw7K+CLR8pXpDAUYE9KmQ9On3o49DPZR5g8aZe0l5DB5mDmZZa dvfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605650; x=1750210450; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pgxhz6GMo/Uz+bg1jme6l3ObzPAtkWH3ImPuJmWGaLM=; b=K7sGs3fEL0Yl/fdsNd8dKnlTu3IWwye8EuQOmgQlcQ5symEgpnxhI8XSTLDN79jG2t NcxzjApKBJHnWb/BUrUrX+FiDI/2ORkgCtxHUz4DiObwZhtNfB/JTgF3L3lLOPMlgHay DM8KWahU/dxqeGOzocyO8TNSeOqy7SJ5W5eTT22JM4PLr41xWcgYJysOPxjk9EAti0Z1 wZunXAowR8+gBVKSsxngG9l0+q7pCJcV90YCaaUz85Bl1Yo5uHagtfLcFNzDIQIKwZro 8R7VP7FR3gQY2Oj9Lu5DZEts/ZCi4yl6woYneHZOcBAJwEVbwq8rsIiApmEZh1PzCFFj +cUg== X-Gm-Message-State: AOJu0YzJy+J+ugw4Dk8qYhPG/5IKrtvZeLXep/9XKGjjDj1qqMuRd31g Aag5U6eTksBK2M+rBX8+HCJu76W0/gTXaYN0Xk7nGa2XR3GzH9Q1S60BgcqYUcVf9+8YGkSk086 ylA6husc= X-Gm-Gg: ASbGnctKSoVtPkZoinrJW4d5vVmBRVruOelIW9u5+1taRO2sY2V79+ELVEQMa3NQVtR o1Vqa5Do55oeMgpk5TcRjeNO3HN1c4UqKAkxHVQmDKO7VHgvGr6CwXslLJHoQ2NnwYiYSosNiqm C79vVZz7n2iz4DyxhgYGHBIjqTXI2JNwzqGHulF4Q/L6rRqC1G34rAbmZNEGen5t48ZEt1YBvqg tRZi2+jWfYCeOXcr9RuL6Dq/wpUMwVmlLI693w9ZnPEVsOAPKRHfiGTG6BCpFe8bg+WUUw9132R 2Fqcu68nHLuUnrspPsQ3wRS5Xi9sOqNSB17SugFWx/MaDnMwj6DKeekgS6Q492KUcz/6N55XKeu h0DGHSP+In/BRGWycWq3KjlQtfczlvWB3dUAp04hGgBZlvon7hxW2 X-Google-Smtp-Source: AGHT+IHAeQVTih220wDwDwuZDwTwvKPsNjxkcqrCwSYrrZ2XDCt5bV2PiUppGXUGRbDMgDTUIFDYQA== X-Received: by 2002:a05:600c:630f:b0:442:d9f2:ded8 with SMTP id 5b1f17b1804b1-45324882060mr10318085e9.15.1749605649984; Tue, 10 Jun 2025 18:34:09 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:09 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 25/35] libcamera: shaders: Use highp not mediump for float precision Date: Wed, 11 Jun 2025 02:32:35 +0100 Message-ID: <20250611013245.133785-26-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" We get better sample resolution with highp instead of mediump. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/shaders/RGB.frag | 2 +- include/libcamera/internal/shaders/YUV_2_planes.frag | 2 +- include/libcamera/internal/shaders/YUV_3_planes.frag | 2 +- include/libcamera/internal/shaders/YUV_packed.frag | 2 +- include/libcamera/internal/shaders/bayer_1x_packed.frag | 2 +- include/libcamera/internal/shaders/bayer_8.frag | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/libcamera/internal/shaders/RGB.frag b/include/libcamera/internal/shaders/RGB.frag index 4c374ac9..72439589 100644 --- a/include/libcamera/internal/shaders/RGB.frag +++ b/include/libcamera/internal/shaders/RGB.frag @@ -6,7 +6,7 @@ */ #ifdef GL_ES -precision mediump float; +precision highp float; #endif varying vec2 textureOut; diff --git a/include/libcamera/internal/shaders/YUV_2_planes.frag b/include/libcamera/internal/shaders/YUV_2_planes.frag index 1d5d1206..d286f117 100644 --- a/include/libcamera/internal/shaders/YUV_2_planes.frag +++ b/include/libcamera/internal/shaders/YUV_2_planes.frag @@ -6,7 +6,7 @@ */ #ifdef GL_ES -precision mediump float; +precision highp float; #endif varying vec2 textureOut; diff --git a/include/libcamera/internal/shaders/YUV_3_planes.frag b/include/libcamera/internal/shaders/YUV_3_planes.frag index 8f788e90..8e3e0b4a 100644 --- a/include/libcamera/internal/shaders/YUV_3_planes.frag +++ b/include/libcamera/internal/shaders/YUV_3_planes.frag @@ -6,7 +6,7 @@ */ #ifdef GL_ES -precision mediump float; +precision highp float; #endif varying vec2 textureOut; diff --git a/include/libcamera/internal/shaders/YUV_packed.frag b/include/libcamera/internal/shaders/YUV_packed.frag index b9ef9d41..3c9e3e39 100644 --- a/include/libcamera/internal/shaders/YUV_packed.frag +++ b/include/libcamera/internal/shaders/YUV_packed.frag @@ -6,7 +6,7 @@ */ #ifdef GL_ES -precision mediump float; +precision highp float; #endif varying vec2 textureOut; diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag index f53f5575..19b13ad0 100644 --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag @@ -20,7 +20,7 @@ */ #ifdef GL_ES -precision mediump float; +precision highp float; #endif /* diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag index 7e35ca88..aa7a1b00 100644 --- a/include/libcamera/internal/shaders/bayer_8.frag +++ b/include/libcamera/internal/shaders/bayer_8.frag @@ -16,7 +16,7 @@ Copyright (C) 2021, Linaro //Pixel Shader #ifdef GL_ES -precision mediump float; +precision highp float; #endif /** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/ From patchwork Wed Jun 11 01:32: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: 23532 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 E8FEBC3331 for ; Wed, 11 Jun 2025 01:34:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D043C68DF2; Wed, 11 Jun 2025 03:34:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="g4T9lbaZ"; dkim-atps=neutral Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6C0B768DEF for ; Wed, 11 Jun 2025 03:34:13 +0200 (CEST) Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-450cf214200so56603065e9.1 for ; Tue, 10 Jun 2025 18:34:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605653; x=1750210453; 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=kou1M46O9tnzkm45TzkfsVRpNX7itRxzavLfzZx/hkQ=; b=g4T9lbaZ/vYURQCL1Gn1cjvRNhEChTRH/J0vZE6IWCvR5V9LiNAXcijAf7CaQUeGtK H+yJtC0jOUnBEx5ies/IewD4Uo3Jnpd0uA1cpi5uhLL1eN25g1bwwrbS8IxL3LIk6vtq AHFGwpqKmoW9eh1BAIlgNDXWRlX7MC8MFObBUIV2TR/12o874GCGkfFzEi24QGjoYmmG sZj9Ax7QUeNbBrb6sNngh4ZMOsYiigyJEfzk25L+uaHGTrQWFO2zmwIUbJXGePnf5lBB XoMsg2t/V32suGYGhApbJ54cE6NrUQEfeVDJK/ULIlLC67vZgBt0yczMSdbdimt1r3h9 nG1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605653; x=1750210453; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kou1M46O9tnzkm45TzkfsVRpNX7itRxzavLfzZx/hkQ=; b=KnZSljZighBmtTy2kKhGZ3/TPpvgZZoh2K4m4dmFj0Q6Y/SPEIJjien1L8slGn1C5m YGcrriUYodocga2Va2WT6u8E+2tjK3bFKQa+yftsLQOajDqJ3x3LP5h9nXqaElmpoVYJ 07eefPu6dsIeoG1BQ6+QcJ17olAED9Xjq7GXxbzUI/wzoCn+KNvmNT/NNfuM6mmpXVtq sprEgC7Gg6mdsgrUFQuOo784/34jSBU4sBVR2xPkWpv4e1r9/EuIfF32QnLkKVWdOrfb L111nkF8/Ir0aZSJ9D6mBa4IiHIKDpsPvrVuw1e9+bgHAMLdXpIM55EU/OH8eNfeqlFs LOow== X-Gm-Message-State: AOJu0Yx1GfCKZywA3NEztvtrOdPEkcX/PrmATYRIElAO2f3t/PRc189Z aXlL1BTZIXG2UTO0LJE4j2ZuUlxDEN4RT9oEKdjSlBOzfV3l5YPyide9vDG99SWb0/lTiQq2g7+ vrJyOdxo= X-Gm-Gg: ASbGnct1+V4c0WGGYKJBS66O+y2oQvmrBXKodyV2KcfANQD1jg/WKib0U2VbYjA/lk2 Z8r6GfxE4fbcjPMFea/uK0VNrNiHGVhwXUJvEaUTAopNLbyl7BwP9LZdoXuk7bOvg4Hm/06E8Wh 6RibNcYVwjtbFgMWHWc4ItM1My/Vp44CdA2kgYTJN0IrAbp5Dp/QUYkxCVZo3NX4ER6n2tpoSwG Nc4tiSUPO8Q0hb5XtuPdDsB/yWUpKDod6HpJK41Gbx2wI9hiFMLIceC6VbWJaxs65nT/kbV8Xoi ZDJStHm2dBCFxoQaCSy3/T/eAaO8VEpjKlNmE6dj9lzYYDQVdJfTO1fsez3pF2DntGToiCIwHr8 J8/kcO/KZUkPcFSTYATxErv8Kmncj2sVDq2sLAIH/aA== X-Google-Smtp-Source: AGHT+IE4aFfPCQTf035R8DBlYuxane9r27Xpk0diUUUxTvhvjyo/QIKBTm1B37uCXcX3SvRLnuDDlA== X-Received: by 2002:a05:600c:8b13:b0:450:d3b9:4bac with SMTP id 5b1f17b1804b1-45324f4f377mr4999125e9.28.1749605652599; Tue, 10 Jun 2025 18:34:12 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:12 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 26/35] libcamera: shaders: Extend debayer shaders to apply RGB gain values on output Date: Wed, 11 Jun 2025 02:32:36 +0100 Message-ID: <20250611013245.133785-27-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Extend out the bayer fragment shaders to take 3 x 256 byte inputs as textures from the CPU. We then use an index to the table to recover the colour-corrected values provided by the SoftIPA thread. Signed-off-by: Bryan O'Donoghue --- .../internal/shaders/bayer_1x_packed.frag | 56 ++++++++++++++++ .../libcamera/internal/shaders/bayer_8.frag | 62 ++++++++++++++++- src/libcamera/software_isp/debayer_egl.cpp | 67 +++++++++++++------ src/libcamera/software_isp/debayer_egl.h | 7 +- 4 files changed, 169 insertions(+), 23 deletions(-) diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag index 19b13ad0..90bd6457 100644 --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag @@ -65,6 +65,10 @@ uniform vec2 tex_step; uniform vec2 tex_bayer_first_red; uniform sampler2D tex_y; +uniform sampler2D red_param; +uniform sampler2D green_param; +uniform sampler2D blue_param; +uniform mat3 ccm; void main(void) { @@ -212,5 +216,57 @@ void main(void) vec3(patterns.y, C, patterns.x) : vec3(patterns.wz, C)); +#if defined(APPLY_CCM_PARAMETERS) + /* + * CCM is a 3x3 in the format + * + * +--------------+----------------+---------------+ + * | RedRedGain | RedGreenGain | RedBlueGain | + * +--------------+----------------+---------------+ + * | GreenRedGain | GreenGreenGain | GreenBlueGain | + * +--------------+----------------+---------------+ + * | BlueRedGain | BlueGreenGain | BlueBlueGain | + * +--------------+----------------+---------------+ + * + * Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin + * Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin + * Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin + * + * We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm); + * + * CPU + * float ccm [] = { + * RedRedGain, RedGreenGain, RedBlueGain, + * GreenRedGain, GreenGreenGain, GreenBlueGain, + * BlueRedGain, BlueGreenGain, BlueBlueGain, + * }; + * + * GPU + * ccm = { + * RedRedGain, GreenRedGain, BlueRedGain, + * RedGreenGain, GreenGreenGain, BlueGreenGain, + * RedBlueGain, GreenBlueGain, BlueBlueGain, + * } + * + * However the indexing for the mat data-type is column major hence + * ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain + * + */ + float rin, gin, bin; + rin = rgb.r; + gin = rgb.g; + bin = rgb.b; + + rgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]); + rgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]); + rgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]); + +#elif defined(APPLY_RGB_PARAMETERS) + /* Apply bayer params */ + rgb.r = texture2D(red_param, vec2(rgb.r, 0.5)).r; + rgb.g = texture2D(green_param, vec2(rgb.g, 0.5)).g; + rgb.b = texture2D(blue_param, vec2(rgb.b, 0.5)).b; +#endif + gl_FragColor = vec4(rgb, 1.0); } diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag index aa7a1b00..5955c2ea 100644 --- a/include/libcamera/internal/shaders/bayer_8.frag +++ b/include/libcamera/internal/shaders/bayer_8.frag @@ -21,11 +21,17 @@ precision highp float; /** Monochrome RGBA or GL_LUMINANCE Bayer encoded texture.*/ uniform sampler2D tex_y; +uniform sampler2D red_param; +uniform sampler2D green_param; +uniform sampler2D blue_param; varying vec4 center; varying vec4 yCoord; varying vec4 xCoord; +uniform mat3 ccm; void main(void) { + vec3 rgb; + #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r float C = texture2D(tex_y, center.xy).r; // ( 0, 0) @@ -97,11 +103,65 @@ void main(void) { PATTERN.xw += kB.xw * B; PATTERN.xz += kF.xz * F; - gl_FragColor.rgb = (alternate.y == 0.0) ? + rgb = (alternate.y == 0.0) ? ((alternate.x == 0.0) ? vec3(C, PATTERN.xy) : vec3(PATTERN.z, C, PATTERN.w)) : ((alternate.x == 0.0) ? vec3(PATTERN.w, C, PATTERN.z) : vec3(PATTERN.yx, C)); + +#if defined(APPLY_CCM_PARAMETERS) + /* + * CCM is a 3x3 in the format + * + * +--------------+----------------+---------------+ + * | RedRedGain | RedGreenGain | RedBlueGain | + * +--------------+----------------+---------------+ + * | GreenRedGain | GreenGreenGain | GreenBlueGain | + * +--------------+----------------+---------------+ + * | BlueRedGain | BlueGreenGain | BlueBlueGain | + * +--------------+----------------+---------------+ + * + * Rout = RedRedGain * Rin + RedGreenGain * Gin + RedBlueGain * Bin + * Gout = GreenRedGain * Rin + GreenGreenGain * Gin + GreenBlueGain * Bin + * Bout = BlueRedGain * Rin + BlueGreenGain * Gin + BlueBlueGain * Bin + * + * We upload to the GPU without transposition glUniformMatrix3f(.., .., GL_FALSE, ccm); + * + * CPU + * float ccm [] = { + * RedRedGain, RedGreenGain, RedBlueGain, + * GreenRedGain, GreenGreenGain, GreenBlueGain, + * BlueRedGain, BlueGreenGain, BlueBlueGain, + * }; + * + * GPU + * ccm = { + * RedRedGain, GreenRedGain, BlueRedGain, + * RedGreenGain, GreenGreenGain, BlueGreenGain, + * RedBlueGain, GreenBlueGain, BlueBlueGain, + * } + * + * However the indexing for the mat data-type is column major hence + * ccm[0][0] = RedRedGain, ccm[0][1] = RedGreenGain, ccm[0][2] = RedBlueGain + * + */ + float rin, gin, bin; + rin = rgb.r; + gin = rgb.g; + bin = rgb.b; + + rgb.r = (rin * ccm[0][0]) + (gin * ccm[0][1]) + (bin * ccm[0][2]); + rgb.g = (rin * ccm[1][0]) + (gin * ccm[1][1]) + (bin * ccm[1][2]); + rgb.b = (rin * ccm[2][0]) + (gin * ccm[2][1]) + (bin * ccm[2][2]); + +#elif defined(APPLY_RGB_PARAMETERS) + /* Apply bayer params */ + rgb.r = texture2D(red_param, vec2(rgb.r, 0.5)).r; + rgb.g = texture2D(red_param, vec2(rgb.g, 0.5)).g; + rgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b; +#endif + + gl_FragColor.rgb = rgb; } diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 3fb15511..824cd6d3 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -99,6 +99,7 @@ int DebayerEGL::getShaderVariableLocations(void) textureUniformRedLookupDataIn_ = glGetUniformLocation(programId_, "red_param"); textureUniformGreenLookupDataIn_ = glGetUniformLocation(programId_, "green_param"); textureUniformBlueLookupDataIn_ = glGetUniformLocation(programId_, "blue_param"); + ccmUniformDataIn_ = glGetUniformLocation(programId_, "ccm"); textureUniformStep_ = glGetUniformLocation(programId_, "tex_step"); textureUniformSize_ = glGetUniformLocation(programId_, "tex_size"); @@ -111,6 +112,7 @@ int DebayerEGL::getShaderVariableLocations(void) << " red_param " << textureUniformRedLookupDataIn_ << " green_param " << textureUniformGreenLookupDataIn_ << " blue_param " << textureUniformBlueLookupDataIn_ + << " ccm " << ccmUniformDataIn_ << " tex_step " << textureUniformStep_ << " tex_size " << textureUniformSize_ << " stride_factor " << textureUniformStrideFactor_ @@ -215,8 +217,13 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm break; }; - // Flag to shaders that we have parameter gain tables - egl_.pushEnv(shaderEnv, "#define APPLY_RGB_PARAMETERS"); + if (ccmEnabled_) { + // Run the CCM if available + egl_.pushEnv(shaderEnv, "#define APPLY_CCM_PARAMETERS"); + } else { + // Flag to shaders that we have parameter gain tables + egl_.pushEnv(shaderEnv, "#define APPLY_RGB_PARAMETERS"); + } if (egl_.compileVertexShader(vertexShaderId_, vertexShaderData, vertexShaderDataLen, shaderEnv)) goto compile_fail; @@ -266,6 +273,8 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, const std::vector> &outputCfgs, bool ccmEnabled) { + GLint maxTextureImageUnits; + if (getInputConfig(inputCfg.pixelFormat, inputConfig_) != 0) return -EINVAL; @@ -284,7 +293,7 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, inputConfig_.stride = inputCfg.stride; width_ = inputCfg.size.width; height_ = inputCfg.size.height; - ccmEnabled_ = ccmEnabled = false; + ccmEnabled_ = ccmEnabled = true; if (outputCfgs.size() != 1) { LOG(Debayer, Error) @@ -304,30 +313,35 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &maxTextureImageUnits); LOG(Debayer, Debug) << "Fragment shader maximum texture units " << maxTextureImageUnits; - if (maxTextureImageUnits < DEBAYER_EGL_MIN_SIMPLE_RGB_GAIN_TEXTURE_UNITS) { + if (!ccmEnabled && maxTextureImageUnits < DEBAYER_EGL_MIN_SIMPLE_RGB_GAIN_TEXTURE_UNITS) { LOG(Debayer, Error) << "Fragment shader texture unit count " << maxTextureImageUnits << " required minimum for RGB gain table lookup " << DEBAYER_EGL_MIN_SIMPLE_RGB_GAIN_TEXTURE_UNITS << " try using an identity CCM "; return -ENODEV; } + // Raw bayer input as texture eglImageBayerIn_ = new eGLImage(width_, height_, 32, GL_TEXTURE0, 0); if (!eglImageBayerIn_) return -ENOMEM; - /// RGB correction tables as 2d textures - // eGL doesn't support glTexImage1D so we do a little hack with 2D to compensate - eglImageRedLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE1, 1); - if (!eglImageRedLookup_) - return -ENOMEM; + // Only do the RGB lookup table textures if CCM is disabled + if (!ccmEnabled_) { - eglImageGreenLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE2, 2); - if (!eglImageGreenLookup_) - return -ENOMEM; + /// RGB correction tables as 2d textures + // eGL doesn't support glTexImage1D so we do a little hack with 2D to compensate + eglImageRedLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE1, 1); + if (!eglImageRedLookup_) + return -ENOMEM; - eglImageBlueLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE3, 3); - if (!eglImageBlueLookup_) - return -ENOMEM; + eglImageGreenLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE2, 2); + if (!eglImageGreenLookup_) + return -ENOMEM; + + eglImageBlueLookup_ = new eGLImage(DebayerParams::kRGBLookupSize, 1, 32, GL_TEXTURE3, 3); + if (!eglImageBlueLookup_) + return -ENOMEM; + } // Create a single BO (calling gbm_surface_lock_front_buffer() again before gbm_surface_release_buffer() would create another BO) if (gbmSurface_.mapSurface()) @@ -440,9 +454,11 @@ void DebayerEGL::setShaderVariableValues(void) // To simultaneously sample multiple textures we need to use multiple // texture units glUniform1i(textureUniformBayerDataIn_, eglImageBayerIn_->texture_unit_uniform_id_); - glUniform1i(textureUniformRedLookupDataIn_, eglImageRedLookup_->texture_unit_uniform_id_); - glUniform1i(textureUniformGreenLookupDataIn_, eglImageGreenLookup_->texture_unit_uniform_id_); - glUniform1i(textureUniformBlueLookupDataIn_, eglImageBlueLookup_->texture_unit_uniform_id_); + if (!ccmEnabled_) { + glUniform1i(textureUniformRedLookupDataIn_, eglImageRedLookup_->texture_unit_uniform_id_); + glUniform1i(textureUniformGreenLookupDataIn_, eglImageGreenLookup_->texture_unit_uniform_id_); + glUniform1i(textureUniformBlueLookupDataIn_, eglImageBlueLookup_->texture_unit_uniform_id_); + } // These values are: // firstRed = tex_bayer_first_red - bayer_8.vert @@ -494,9 +510,18 @@ void DebayerEGL::debayerGPU(MappedFrameBuffer &in, MappedFrameBuffer &out, Debay egl_.createTexture2D(eglImageBayerIn_, inputConfig_.stride, height_, in.planes()[0].data()); // Populate bayer parameters - egl_.createTexture2D(eglImageRedLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.red); - egl_.createTexture2D(eglImageGreenLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.green); - egl_.createTexture2D(eglImageBlueLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.blue); + if (ccmEnabled_) { + GLfloat ccm[] = { + 1, 0, 0, + 0, 1, 0, + 0, 0, 1, + }; + glUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm); + } else { + egl_.createTexture2D(eglImageRedLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.red); + egl_.createTexture2D(eglImageGreenLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.green); + egl_.createTexture2D(eglImageBlueLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.blue); + } // Setup the scene setShaderVariableValues(); diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index c0fc220f..94bc6fc4 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -134,17 +134,22 @@ private: GLint textureUniformProjMatrix_; GLint textureUniformBayerDataIn_; + + // These textures will either point to simple RGB gains or to CCM lookup tables GLint textureUniformRedLookupDataIn_; GLint textureUniformGreenLookupDataIn_; GLint textureUniformBlueLookupDataIn_; + // Represent per-frame CCM as a uniform vector of floats 3 x 3 + GLint ccmUniformDataIn_; + bool ccmEnabled_; + Rectangle window_; std::unique_ptr stats_; eGL egl_; GBM gbmSurface_; uint32_t width_; uint32_t height_; - bool ccmEnabled_; GLfloat vcoordinates[DEBAYER_OPENGL_COORDS][2] = { { -1.0f, -1.0f }, From patchwork Wed Jun 11 01:32: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: 23533 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 24D16BDE6B for ; Wed, 11 Jun 2025 01:34:20 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9395968DF4; Wed, 11 Jun 2025 03:34:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="VegyqQd4"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 33F9768DBD for ; Wed, 11 Jun 2025 03:34:16 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-450cb2ddd46so36245245e9.2 for ; Tue, 10 Jun 2025 18:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605655; x=1750210455; 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=Y+rhqXuB1F9aT3Pl3A23g+gsKVe9C5G7edD32dZ1KTo=; b=VegyqQd4MAZpSIt+CFVsIHEfxr1IfvBaOleCgG76DbDWQJF2nXJT5P8jdwQkSYhYaA 2Kk+mmu3jCio9lcGSgltWXKD6wF+/ShX1ClqtXI1fy2Pj7Rf+R095v5QR3MNSKTRf2sB LtmFcSRCrPKphZgXYBIx8poE1/Yd0H078vhNRIv2n3gMZfzcvL3+4jJyH6i/ychezjEL FsGG0dF2WSjMLbNY/i41yMIMYOpKsIkMtpSVBzLw5RoYv9ATCmYzY1iJo9TY0869E9zf iqlu0D7vGCSWu+v5/0llKqt6ffhbOMXcpLsWvt8Q+k6zJz/n6XUFMRuZGDXV9xqpol+8 iZiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605655; x=1750210455; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y+rhqXuB1F9aT3Pl3A23g+gsKVe9C5G7edD32dZ1KTo=; b=qktWHcMeJ2aQyN5bD68PU8lPeYQQP109MXkUYzDMOV26t0bT86NDsCFw09qi1egSJB 4qdX/+okjucMoIDq6oQIdgjAEQxlmplbk0GDZvUGUjONiGLTZ04h+6dxvKauo19xQ8xw EK8r1al16hfnandKTvCwcyoTRxFqObIz3FkP9LleAAEBqDw5z4ZktFd+X+FqeYGvZtgY E9ScN0KGEQyK19Cg+hEO8Iwb+8DHMhnNMBmEpEgLzrJjzCgQRepU6SbCjzUUTcPK8pEb Dqk1bPgxVz+90okyO4H3DtcGvyk1GpY5tuC+hSGL3AOqw8RkT/ZcpZ2nk6v6CmpDdlSV iERQ== X-Gm-Message-State: AOJu0Yx9ITe09AP4HH/dRmot67sstYXy7r9mlBYUb4DNqJ+RhqIFFab4 fnt+UbBCMPd8sCmXl/BInwcNT1XKkjbzQfH8HLapJyDU/0EfKaGffQRQNh2X4xnEnsIpbI8vbDM K1R5MPiE= X-Gm-Gg: ASbGnctPqZ8Diw1YLf/poBXn+c6fVtpZjBALK9T5ccZS/nvroyf8UgucHvJMWGe7TWb p4h07Lt7pLnfS7de2UQYplKwJe7eBSg1yHIru9RHnpWsu5ax+NCdHvDI7vUWCm9tEwRCwycaUyb jAVNnBzALMtkkU3WbJ1bV2tBsi8j5MjMEd18BAjcD6+xlFPvfHMfg4D8uwhwn+8+dGPJQaqoDzy QhBLfQXTvdhBsBCojrXboS201pi1tNVECXRdt+Mj4KtvOC7wB9ydmuYzYCNxuFS5s9QrIOH+a8/ qefUJ1vWDvVZVKic7T3m1XvD2FSggvZuGuyf0YBiux9PTlMCHhJgDHAlhJdvivlfHITa9/6HiaP mnlZI8kEscy4XdJX8HEN3MEqxHRXx8D2DVNs0WcLBhg== X-Google-Smtp-Source: AGHT+IFltwPxkkKbGEd3eZMG1+KWhnD+YsKhPkr40/sW/fULcqx4Z/8yWVH3E4tdgsj2riTkTP/XLg== X-Received: by 2002:a05:6000:2087:b0:3a5:52cc:346e with SMTP id ffacd0b85a97d-3a55868917fmr783441f8f.6.1749605655527; Tue, 10 Jun 2025 18:34:15 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:15 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 27/35] libcamera: software_isp: debayer_egl: Convert from identity CCM to CCM calculated by SoftIPA Date: Wed, 11 Jun 2025 02:32:37 +0100 Message-ID: <20250611013245.133785-28-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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" Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer_egl.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 824cd6d3..b30d2107 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -293,7 +293,7 @@ int DebayerEGL::configure(const StreamConfiguration &inputCfg, inputConfig_.stride = inputCfg.stride; width_ = inputCfg.size.width; height_ = inputCfg.size.height; - ccmEnabled_ = ccmEnabled = true; + ccmEnabled_ = ccmEnabled; if (outputCfgs.size() != 1) { LOG(Debayer, Error) @@ -511,10 +511,10 @@ void DebayerEGL::debayerGPU(MappedFrameBuffer &in, MappedFrameBuffer &out, Debay // Populate bayer parameters if (ccmEnabled_) { - GLfloat ccm[] = { - 1, 0, 0, - 0, 1, 0, - 0, 0, 1, + GLfloat ccm[9] = { + params.ccm[0][0], params.ccm[0][1], params.ccm[0][2], + params.ccm[1][0], params.ccm[1][1], params.ccm[1][2], + params.ccm[2][0], params.ccm[2][1], params.ccm[2][2], }; glUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm); } else { From patchwork Wed Jun 11 01:32:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23534 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 77D49C3332 for ; Wed, 11 Jun 2025 01:34:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 07AD168DF4; Wed, 11 Jun 2025 03:34:22 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="tCuQ2Jqr"; dkim-atps=neutral Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 7730168DEF for ; Wed, 11 Jun 2025 03:34:19 +0200 (CEST) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3a50fc7ac4dso3926632f8f.0 for ; Tue, 10 Jun 2025 18:34:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605659; x=1750210459; 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=T2Bb42Ct//oamvKx7NfMLsy+xIfa5EBVp7DJRfAUVfM=; b=tCuQ2Jqr5FoKFxh8t3JH8vxr6coLYyC49ihQvqEefqTDNMMce+gjPsQgrsmtLhT2xi E1qCWdLGwnF1X9dmdSLlUP4EkdUcjKxoSXLjW9/20/gbO169evSx5CMEIRKWRKmEUFTd /Yb1MljsDsTomMDUVd+u7BauNwFItBf1N8NS/dchROJQg2rPr46ZSroE50fk+Io9f/t6 eoQrb/p+BPxtLpMR/Iapr5/E3PMfIq4qUtGoI2b5vtO/2BrRK6NeMG0S9fgmIeMUzxhJ sC7Xs8V9uW+hyxAy3g4/pvmcF5S3bWMhcYMI5j8Oqm3iAO/o1G1Ez2U2w28twp6nce8A fp/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605659; x=1750210459; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T2Bb42Ct//oamvKx7NfMLsy+xIfa5EBVp7DJRfAUVfM=; b=hMlQWnaRFe8MlzP3hqf6U7AK9EQyRZeL3CRARIB5cfi8xwYmLkZ+mY9S8tTSh78CPU rklhRh+0ds2gZCdrOC+dwMq1f2unrdnED+cTFIXubzE7aWSiqmTnA+aE6Wcfy6/TLGHH 3JaedPVaAbmkutw9VwfC+JBq9CRcMa6UHs7PEr3zqa1TvLn9xG3XUAjlrZQ8pwiG+piF fdHwSU8auYa0igXO/jTNSw2I0O4oOMzx6s0P8+bM2e/0Lyh+yaIeDTpzZ8wnx+RQ7x+0 cLW2Yn6bLsbg7XqTwHT3tKMQSZtGDugFdd7DWNFxF12qGonpHe8yQ+08i7Ls9QV9m3DX PyXg== X-Gm-Message-State: AOJu0YyYnL+Rt32vMOH4O5E6g0ydCr5Q7Sc1ZQTjOV/CSpn/uLObqHir dmixtXvKkEsAsVFigrfvltAAtVjqN7MBTq27PkqebVC59wkhxEGzSLgAxp7IwSPYC12DKWXjDwV WVLP5QiU= X-Gm-Gg: ASbGncvpXoa+t71BMEjH0GrwIS/BCGjky4TwMK5P4P6/sYhB8ecggnk1P0ikvQ8hulG 10yrijitO7CL6cQFA7wDQeh8/pxupZqSSdUxKhPLYv/jQMQl9yfCmgwn7vuTbl+6RO1K46hcuUn vNe4bmxdod5mWHqyNQllTkFiACQXhmGHFLgtjGGxzoThEdmGvcM8JGRLE1B+rqsKVPO2Db2gF9F tKM7ZWAIq+kpMXsHPR4fdj7kG6l2avROfcP9XFTiUbAVOKuLMTRyBXgPx3aDylMi05N8Q+rPSYs lMlMJZ5cjvGhRBV9Xw2tX4E2hspDkhduMeifDEsIEi4NHK/qJkm0YNoJaPnZnfdzTLuAKai8Rvs 1G9FT5dM2iMNKRh7ps1Xi4nHiVMBhdLzHqFTKboOTPn98BntUl60/ X-Google-Smtp-Source: AGHT+IGnU1D+m5ML/ZW8wtSHxfl718uecFMAOLD4OOJ1PGYN6BN1XgrfEzu+69vkv040szh6quaXBQ== X-Received: by 2002:a05:6000:2586:b0:3a5:2ec5:35ba with SMTP id ffacd0b85a97d-3a5586cb195mr678373f8f.30.1749605658797; Tue, 10 Jun 2025 18:34:18 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:18 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 28/35] libcamera: software_isp: Switch on uncalibrated CCM to validate eGLDebayer Date: Wed, 11 Jun 2025 02:32:38 +0100 Message-ID: <20250611013245.133785-29-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-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" Signed-off-by: Bryan O'Donoghue --- src/ipa/simple/data/uncalibrated.yaml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ipa/simple/data/uncalibrated.yaml b/src/ipa/simple/data/uncalibrated.yaml index 5508e668..8b6df9af 100644 --- a/src/ipa/simple/data/uncalibrated.yaml +++ b/src/ipa/simple/data/uncalibrated.yaml @@ -8,12 +8,12 @@ algorithms: # Color correction matrices can be defined here. The CCM algorithm # has a significant performance impact, and should only be enabled # if tuned. - # - Ccm: - # ccms: - # - ct: 6500 - # ccm: [ 1, 0, 0, - # 0, 1, 0, - # 0, 0, 1] + - Ccm: + ccms: + - ct: 6500 + ccm: [ 1, 0, 0, + 0, 1, 0, + 0, 0, 1] - Lut: - Agc: ... From patchwork Wed Jun 11 01:32:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23535 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 9FC28C3328 for ; Wed, 11 Jun 2025 01:34:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DECCF68DF7; Wed, 11 Jun 2025 03:34:25 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="IPPem9La"; dkim-atps=neutral Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A86F368DEF for ; Wed, 11 Jun 2025 03:34:22 +0200 (CEST) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3a53ee6fcd5so2060212f8f.1 for ; Tue, 10 Jun 2025 18:34:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605662; x=1750210462; 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=fjTCVnpgaeN5Pd7/KDLE2tTkBIpKnCeK9mmZnZSfpiQ=; b=IPPem9LaxRN6Y7TNioS4ymJO/mMHYcNDddqo87Yk/q/gHBTlUTu+Rumk/F6daRWMQ+ CaIiK6IRjhWIeETQWNWoB1rIiHOZP9iv43bL84pJIWSjuCXSiYfT9wfy4I9J8XCP4n6m b/VwQsQgVQjNjtt9FfVvnyyj6YjPNxxg3m2I3TZK60LFgIojGc55TABMMVOL7tlqR/z9 +e7KPLNW+VU+T7NKLhhBxSKd5ZIjDxQNtpLwCvCC+kPYQYJq76PN40L+aqNnGDwFYjSl tQ3cuYFxIBusEpdrjGTQ7SzL21DabzmGeOZkE8f6EeYJ1iBd+y6s5dEhlaOgq55Foqyz VFwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605662; x=1750210462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fjTCVnpgaeN5Pd7/KDLE2tTkBIpKnCeK9mmZnZSfpiQ=; b=CY8+/S7+8/zpYTGxfywEqtr9MDGyJl+3vWb/Y0Nki4CkG0uaL1XxysCAsmSDWi9uv0 K1sBj476T26mpvfAik/Wgsq5lZQD71jhHAyxqzOu04z5RbTADz3N9aEcV170snP6pVqu hXfLBhqCNlfnRLwW07SeSSHi0E6XzKOGCpxKozvLJ62rns2G5vDU9PzWvEIc7tJuxuqH uN86LMi7w+ONTzYs9oBsfkXuevlqdqNGfup5shCu1WOyN6+8wJatBgd2hFzT55jIMQPe +dM4UKGHPFHvcpsvGpBO/I33Pi+Ll3npu+Y9NGM/Tnzg/D6kVsET+sJ1iUyQE/ii/btU 77ow== X-Gm-Message-State: AOJu0YxNLZM/V/0UezYNlaTUD2EtdAKdnIrqrKqX3vrrxYeHucGJ4osb Np7/4nCVFOqIH5chK5lDMxyTpQR+58R0Qh/3tLefRZ2gLbCIwHnml+cpzsKDFv/NLI2F63QWqpV FC8LF6lE= X-Gm-Gg: ASbGncsgXhbJ01I7d/eFNtEhwYpPljhXNvWky6GEtaeIWvavoCPX/VeWnUHf+DwlGAs hn7qmyt6SyBPI2bDHGyQlxzgb41YJBQqUWTFDp0FPmwtREcIg7sjj6jtNlbco5Kr6GXRGpRoUke Fs3fZYBc9hDnnNFseYdvU6qVvJ77oxFDllvX8b7j/q6oZmrmh+zYGdpSSFTu0jcskQVcIRD31kn zR0JzEk1+NDHVKSv2i4nZFgo/vg8U4kONKzIoCqudX7IolOhCNnxmDuHH0g92IlmoeOxneVvhh/ ZQrMIWV2gKSRnpR8454G5dMyM84zN4texrvVVuFube0CaFtUTPPeh+xW5A8ZiFezTxwRkjuPuJv cJbemW+4I6FZBCbYggtNgM+WTxOxbruQcv18WUqDMzYxAZ40er/jE X-Google-Smtp-Source: AGHT+IG2rjiXk2qKrZCFfmsmcw+qcYKxLSRQ2H1vC59BeZ0pldJjiu1uiFTt5L0ottv2N24TTbfQGA== X-Received: by 2002:a05:6000:250e:b0:3a4:f6b7:8b07 with SMTP id ffacd0b85a97d-3a558aff7a7mr702747f8f.48.1749605662032; Tue, 10 Jun 2025 18:34:22 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:20 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 29/35] libcamera: software_isp: Make isStandardBayerOrder static Date: Wed, 11 Jun 2025 02:32:39 +0100 Message-ID: <20250611013245.133785-30-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Make this member function static so that it may be called from static members of derived classes. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h index 214bcdd3..3893318b 100644 --- a/src/libcamera/software_isp/debayer.h +++ b/src/libcamera/software_isp/debayer.h @@ -88,7 +88,7 @@ private: protected: void setParams(DebayerParams ¶ms); void dmaSyncBegin(std::vector &dmaSyncers, FrameBuffer *input, FrameBuffer *output); - bool isStandardBayerOrder(BayerFormat::Order order); + static bool isStandardBayerOrder(BayerFormat::Order order); }; } /* namespace libcamera */ From patchwork Wed Jun 11 01:32:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23536 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 D8ED1C3333 for ; Wed, 11 Jun 2025 01:34:28 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 53BBE68DF8; Wed, 11 Jun 2025 03:34:28 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Vv6Q3INo"; dkim-atps=neutral Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3773568DF0 for ; Wed, 11 Jun 2025 03:34:25 +0200 (CEST) Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-3a4f78ebec8so3674210f8f.0 for ; Tue, 10 Jun 2025 18:34:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605664; x=1750210464; 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=HI49pYUXinc5VYst8KgNjwxFTmCviwBQg1gk8SwGa4M=; b=Vv6Q3INovc2VD+fZdN7w0NjpZzc6/xxIfgTfchnkb03o7Ozk8Ui9UodftqsqUYqf+U /cD8gCJBTjGpVMuy4oRXjfrJnidx6DR4hh0/i3KvWGhDzyVl/qG4WX5xWhFqquB/1fCM ui4s2xfO6Xz1qxTnZG4qqOn7zSt3EfGFQMB1PMEEBazDJMPt82yCTHdiTLf30+64MlwG 00VptdnWLGiXyLGgyCumyvN7QnSk5RKZG3aGyv1CIQNCeEHaionkxUWORpt8saIQc8yt B+z/+2ffHvl80H1uz8rdidlAI/rI2yStM8RsyvjHUbUVbGUu2/hJjFCL9pOCXn+xZc2a qdeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605664; x=1750210464; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HI49pYUXinc5VYst8KgNjwxFTmCviwBQg1gk8SwGa4M=; b=CR3ZWYjh3gUzmczwOhOsRdk0T7kraFbRnEE7NWeSE6ahlXN9Jsqm63We5KYwVgBCJy 2QTIVxo4l82Z9GAzy1v/Tsaf0kNtje7diipDd+5nGbUowKtcjilrWZcalmw8fDnS5IJM icPBEq0zIDYYi9e4UqiNk3ZCzxf3Zb7RcFY8CtWCvwtLdf3d8E2CVsQF+xVSHXkWlvUP nj1IaBNT8CMN2bvW/ccIhUdFnfEUIb83cE17ilI3u1Vr8q82t01uqurHSIDN+GpF5LbV rB03FzJ9gSdDvjZYtLhz7Jm6P8+J/jIPUsJrWKOJ0ZypJ6wyKXW2CCy0m25jc8dC6etG DNFQ== X-Gm-Message-State: AOJu0YzJbmeEbPnVSzRZXNVD/jscQR5oztIhOn/jYzOLerv8x9AReuS6 e8/ddYPU5yuSZeUGH2+fyZyX5kRBH3taBueZVHMFzcRqWoGj5A7KVIzIsN6YUCJfAnZG3i2XL+X YHGsMYk4= X-Gm-Gg: ASbGncuPKuif2MJ8uxysg0M8eMcaoaoXi6HMLh5PR/XPdtJfcZWsJt6IlaFlP3iqQp9 0wvVUvR0dk4g0AzT6VUQBnHqFZL+s2HFdkkr8rBanyes4uJOw+ET76+5jpIU7CCXOF872M2hdee rx9bVsKzaD5HZPwETCsoJWzot2+ggCDReqrw/YTfvqH+hrep2ErKupD+aU36kN1/o42kJAyk9R/ QJXU8uguXguPxeEhmUUsBDYPTOYsnkGKX8by7mHRtnI6734mbqBCXhee03VnvcKD4sMPgOKeilh LJI6G5hRYsnPArfi1rJ88IEbaTE1PPWcCuqhMdi+Ipi1xm8sOzD1fw/sT18xAyCy2yV727DhS74 dm7up2IrJ2RRgNh+E1BPGl+sTcI3Sw0XKNoNkk9ZWccsdW6aDQAyu X-Google-Smtp-Source: AGHT+IFNonVCs10alOBA/xOndvNC/XdHixkaWZP8bBP6SF/LUlu+yLaKuB81KvQen6zSInKa8o4cTA== X-Received: by 2002:a05:6000:4025:b0:3a4:f723:3e73 with SMTP id ffacd0b85a97d-3a558aad7b3mr698227f8f.16.1749605664601; Tue, 10 Jun 2025 18:34:24 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:24 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 30/35] libcamera: software_isp: debayer_cpu: Make getInputConfig and getOutputConfig static Date: Wed, 11 Jun 2025 02:32:40 +0100 Message-ID: <20250611013245.133785-31-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Make getInputConfig and getOutputConfig static so as to allow for interrogation of the supported pixel formats prior to object instantiation. Do this so as to allow the higher level logic make an informed choice between CPU and GPU ISP based on which pixel formats are supported. Curretnly CPU ISP supports more diverse input and output schemes. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/debayer_cpu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcamera/software_isp/debayer_cpu.h b/src/libcamera/software_isp/debayer_cpu.h index a043a954..999e3421 100644 --- a/src/libcamera/software_isp/debayer_cpu.h +++ b/src/libcamera/software_isp/debayer_cpu.h @@ -102,8 +102,8 @@ private: template void debayer10P_RGRG_BGR888(uint8_t *dst, const uint8_t *src[]); - int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); - int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config); + static int getInputConfig(PixelFormat inputFormat, DebayerInputConfig &config); + static int getOutputConfig(PixelFormat outputFormat, DebayerOutputConfig &config); int setupStandardBayerOrder(BayerFormat::Order order); int setDebayerFunctions(PixelFormat inputFormat, PixelFormat outputFormat, From patchwork Wed Jun 11 01:32:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23537 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 DEE8CC3334 for ; Wed, 11 Jun 2025 01:34:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 56E7C68DCA; Wed, 11 Jun 2025 03:34:31 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="OpQN7zJ6"; dkim-atps=neutral Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 690A368DFA for ; Wed, 11 Jun 2025 03:34:28 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-43edecbfb46so51413495e9.0 for ; Tue, 10 Jun 2025 18:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605668; x=1750210468; 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=3H9DGvojUoUk5Y3iEb9uuLwH3EKoTXsq6B1yGjTZ7oo=; b=OpQN7zJ6oIxWpsFXX8QtyOyNy/CUsN9lHBuFyoxt6t9mDsE1ApaOBWF/+prLbuaUiB wYkd/PjJdnxE+b2QIB4Axcx5dEw7QVxpOj8u5ElV6lrELXsHqZeWPcOawsyF6BLB8khU BKY4lg+KcuC4qTtsdXZNxs0hycig3NUkKLPJwsRHYRphWGmPpMz6MRjZwiNa3v3nc9R2 VFQcPfQdNlqqtD1J6REuyCuyqPhgQNkI5tPI4Oi/3prYSYgi8ibLLulU/yu+31PwjC5r l4ILxPjF9uEGRRKEQH7OnDR1+wnwC/yfKv7ACdwxIHxtjM4IKvqDaF3DfkQOIo36C/05 lA4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605668; x=1750210468; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3H9DGvojUoUk5Y3iEb9uuLwH3EKoTXsq6B1yGjTZ7oo=; b=DO0mnUgJGt50jIVicvm/a8FnZCyPNywotmKZOx3S2P3Cw2hAnCtQ99+LF+6Ww7Tb3/ 1PZ2fXFPcBIKx0VZKaSbX+TjLB2q4HkoVzA6KjxeiTU9UuxM0e2QW7n1HigNaYnqoaxO iSEuo9oJCgMABGwVw2TnrEOTU1GTX/W6F8FpWbdbON6HhY74+Yzz7vnw0Fm0e1oXZcJZ S1ZPjkUObjaa2i4wVDdJ943fDMt21zkm8suotJNE6qRGBToH57Wr9viV2k7Wcp+WMNpO dKuu1cdg3JCcyVDDsLr6PuHSe0UTF6Jo5oNJdtnTzHY/xeRtgQRowRXVloupmkzFc53N 4cgg== X-Gm-Message-State: AOJu0Yw8HfjmyGyvL1K0xUH4O4WNoqUe+tXIGMbeC/kJd+vK2fecg13q nDoSq3aWx9GocXolQlOCIt5WFYxdpadtYobEgHx16B59kuz6zrcvFnTXoOCMKKWkQqn+2pGuObE A3NmqMM4= X-Gm-Gg: ASbGncsMvddBYzEFHw9KWN9cGPHZreLAQuV8TDJTJ2f4v1R2u7/CrcVNTCUnaP34ERv WFtT0XE4FhOoNveXG/SLdJJzNzLjx1ouedWBfQv1fOy9Uwh4PguhOB2e6Z6R5Bk9+vkAviYccrC q3cRq/KCmWWe2kN3q9ppKy9we0hL1ldWnRj+VJkVIdMeeDvKQ0BBkLahR8FrHuFyspZqJ5VsMdV CrwvBWmveLFWNmj+DlD6wwp+2QoqDL4DBp1dhbtqEcP86u/rZ5PA7dBC13utwsEr7+bpzvEBvab VnwOkVrrjWoKE1ISqMJkV+UqegIim84jgL+2gGnKInO++L4Ql0tSCOtPQiWAByBRCpdgD47qzsr tH4QwsjP6P+CNVMoMpHBQPpKlwb6s/ICmYTj4HJMkpQ== X-Google-Smtp-Source: AGHT+IELh4LjuV6Y6UU0QJ5FVZOa8NqfSBPQSUHfJRNQNJY/uDLfeYZlOMMqs53qRcX1Dl5gXmbylg== X-Received: by 2002:a05:600c:4f41:b0:453:6ca:16a6 with SMTP id 5b1f17b1804b1-45324edf307mr7946645e9.10.1749605667801; Tue, 10 Jun 2025 18:34:27 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:27 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 31/35] libcamera: shaders: Extend bayer shaders to support swapping R and B on output Date: Wed, 11 Jun 2025 02:32:41 +0100 Message-ID: <20250611013245.133785-32-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" We can easily facilitate swapping R and B on output. Pivot on an environment define for this purpose. Signed-off-by: Bryan O'Donoghue --- include/libcamera/internal/shaders/bayer_1x_packed.frag | 4 ++++ include/libcamera/internal/shaders/bayer_8.frag | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/libcamera/internal/shaders/bayer_1x_packed.frag b/include/libcamera/internal/shaders/bayer_1x_packed.frag index 90bd6457..c0632eb1 100644 --- a/include/libcamera/internal/shaders/bayer_1x_packed.frag +++ b/include/libcamera/internal/shaders/bayer_1x_packed.frag @@ -268,5 +268,9 @@ void main(void) rgb.b = texture2D(blue_param, vec2(rgb.b, 0.5)).b; #endif +#if defined (SWAP_BLUE) + gl_FragColor = vec4(rgb.bgr, 1.0); +#else gl_FragColor = vec4(rgb, 1.0); +#endif } diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag index 5955c2ea..74ce1509 100644 --- a/include/libcamera/internal/shaders/bayer_8.frag +++ b/include/libcamera/internal/shaders/bayer_8.frag @@ -163,5 +163,9 @@ void main(void) { rgb.b = texture2D(red_param, vec2(rgb.b, 0.5)).b; #endif - gl_FragColor.rgb = rgb; +#if defined (SWAP_BLUE) + gl_FragColor = vec4(rgb.bgr, 1.0); +#else + gl_FragColor = vec4(rgb, 1.0); +#endif } From patchwork Wed Jun 11 01:32:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23538 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 DE7F9C3325 for ; Wed, 11 Jun 2025 01:34:34 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6192568DFB; Wed, 11 Jun 2025 03:34:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Glk39CmF"; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 57FDA68DFA for ; Wed, 11 Jun 2025 03:34:32 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-451d6ade159so52326435e9.1 for ; Tue, 10 Jun 2025 18:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605672; x=1750210472; 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=UpTmWd8hRPOTTl1Zn7CO833uoJq0hIJmPFpjlTRP34c=; b=Glk39CmFCNtZlxwuVdV8l8OZv3xcVMyNIgA1S19ioxyHj2YnvU3m2+Dtg5ALZTnK8A 6bmfN+QY/H9P44M+V40h16oZTbObV6YJ0e484Za7bJz6odQrVbYSDqPgsrFOBBV7B0He Uc1RphVnEDTRWLIcJoTrnNiy7FESL3YRafDGEcWCoRMJimP39u6EyKyXR4GnJJvD8ZuM 3jYcGOGw/jm1LzGGAJxcmFjBYIpEVyMuPaxtt/sjbU/Mohafv9OfGsMLcYCs66IonTkz eATlEA0NVNCQmyFLzV/SJp4rAcLEYbImECAegTLlGVTKclOyUbm/K6SW21YcWuXJBHLo KNCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605672; x=1750210472; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UpTmWd8hRPOTTl1Zn7CO833uoJq0hIJmPFpjlTRP34c=; b=PV43oDg1rN6sTOzekgLJj0uuRD8w2pIxzueSwl+l+x+LDtn/hCW2s7vg5IcwdQum7E rNaSiSOgam+bXSgM/NDVIuhMIxici83hgwsUNPlXWhRYpC+JwJxXbBHQQpTKZdPILeBk N2ZXdnWLMcisEJbuGcnTOP8NO3Edvz/TJOOghVeIf3zXF1d44wXdRvStVmYptFPFVrgp 4ynA2Gkc+nY6bngGtG55uqYiofXYEzAj6+cc6lyo4ZctOfI0vwhLRnDS1LuWz1c2hN9f 1UsnLCWLEqmkcjQ+BHHJ+z98PDt6ViGqu0swq98G6wc4Qpb20+B1Rt3aToBnBdSqPhLk baSg== X-Gm-Message-State: AOJu0YwbumClZEMNsJ2A/a8FB2VdkGNvr6gjiCNUkRoFIlCl8VNUmhk1 CAG2Hi7A4v/7aJbDlaFY8TxkuV60cZNMyn5L0QLynsrax6QVSB5JJJjAd1plV+Wg8dzjF+0zvRO CVwhI9cM= X-Gm-Gg: ASbGncsDJ8mbfNTe/kDbMj0YGvdkJ4ONclJ55Ux/9CVqWQSujCYCexiOaXrUhByzplH pgNoFwsr+tkqPkuH+/0ZBqUdi+BXA9m/vmBQXYs+fgs4Tis8WRHHklQ58wVQaljH6Enu1lKiADI sugHYz0lJ4nFadIAI88tTQhl87+J8tvHfympK519tb/HvGns3frzKZHFtsydwugvoYES3oO9Iw0 vWNx8HF2k0jl4uNQQf88XCbd9W7mrg4dkdVGmtfAOxNDoqLkf2YWKy/MpZsbvr4BCD2jnPj4SOv QbioY6BtMqZiI1pqZjwt0pZfM7Hq6Fi6U3GdorK5PRwtDXPm1k6YNIHpSQP+vND6x463XHAa6t2 ECjtK/dmqVK1FN1aWyPIThsLASq3L+WXOJgSREeFMLw== X-Google-Smtp-Source: AGHT+IF57xJsyb8PP2X+NVStRNReaAyK1c5hTIA0OotLoIoZ7SHYs6w4lvE3tRjzwA7v49IQ8AFoYA== X-Received: by 2002:a05:600c:5289:b0:442:f4a3:8c5c with SMTP id 5b1f17b1804b1-453248813e0mr11682935e9.10.1749605671625; Tue, 10 Jun 2025 18:34:31 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:30 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal Subject: [PATCH 32/35] libcamera: shaders: Fix neighbouring positions in 8-bit debayering Date: Wed, 11 Jun 2025 02:32:42 +0100 Message-ID: <20250611013245.133785-33-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Milan Zamazal When accessing a texture position in a shader, the pixel with the nearest centre to the specified texture coordinates (as mandated by specifying GL_NEAREST parameter) is taken. The current vertex shader determines the positions of the neighbouring pixels by adding the provided texture steps to the exact centre pixel coordinates. But this places the computed coordinates, from the point of view of GL_NEAREST, exactly between the pixels and is thus prone to floating point inaccuracies. Wrong neighbouring pixel coordinates may be used, resulting in artefacts in the output image. Let's fix the problem by shifting the initial coordinates a bit from the pixel border. Signed-off-by: Milan Zamazal --- include/libcamera/internal/shaders/bayer_8.vert | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/libcamera/internal/shaders/bayer_8.vert b/include/libcamera/internal/shaders/bayer_8.vert index fb5109ee..fc1cf89f 100644 --- a/include/libcamera/internal/shaders/bayer_8.vert +++ b/include/libcamera/internal/shaders/bayer_8.vert @@ -44,10 +44,10 @@ void main(void) { center.xy = textureIn; center.zw = textureIn * tex_size + tex_bayer_first_red; - xCoord = center.x + vec4(-2.0 * tex_step.x, - -tex_step.x, tex_step.x, 2.0 * tex_step.x); - yCoord = center.y + vec4(-2.0 * tex_step.y, - -tex_step.y, tex_step.y, 2.0 * tex_step.y); + xCoord = center.x + 0.1 * tex_step.x + + vec4(-2.0 * tex_step.x, -tex_step.x, tex_step.x, 2.0 * tex_step.x); + yCoord = center.y + 0.1 * tex_step.y + + vec4(-2.0 * tex_step.y, -tex_step.y, tex_step.y, 2.0 * tex_step.y); gl_Position = proj_matrix * vertexIn; } From patchwork Wed Jun 11 01:32:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23539 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 5024FC3329 for ; Wed, 11 Jun 2025 01:34:40 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7EDAD68DFE; Wed, 11 Jun 2025 03:34:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="oXancp/e"; dkim-atps=neutral Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D6DFE68DFB for ; Wed, 11 Jun 2025 03:34:36 +0200 (CEST) Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-441ab63a415so63502735e9.3 for ; Tue, 10 Jun 2025 18:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605676; x=1750210476; 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=IhTu7mdgMev/e/IpYBpbMZAEkHJmFS1pXA/lABpS35g=; b=oXancp/eIq3LVsk85GUQUNwhGeg6A+eTwAn/3BhwD9a8QvuCZZ6C83Q6BPgcAfELyb VHBVA6vtU8MXP92Nw/0DNC3bbIpNVwn5Dn7u+XSd6ruhUKmTdtspuXA1aN3fzL/gRand bsF5XhsH4V13WgMHld/fDBjtaazMp1axZAylPKVkH03kh4Q/dja6/StD1g3bppPFwldM LW19Y/tsA9ClY79abFH/cSmQK50QRyEuqOVa40ithixEPY+H4lg5FNDqO35mQhXgW4QE W5u6nyHYVyOJ/Be0d0ZlTSSbOipPei/Mbgf+bhN6zq2NWwOH3RiQZ/3htdUXTfTCod/A TZbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605676; x=1750210476; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IhTu7mdgMev/e/IpYBpbMZAEkHJmFS1pXA/lABpS35g=; b=HBLCkbZrZNPwu8xJqVwaQMuVmOuduCmUqYxHqbXE/ZPNBdKH3e5bxaILBpt4GP3w4a 73wexi3Ebrkn+OLRdqrKAmWzid5Ci/bdfRwGDCxepJUYINc+iDZYYjLRun6ZdurCydOw FSHAwr8LHK/hySxwjKGh6JGkCwJTQQARFJp05Q0A/ejGmqrkBortt7rwfsVCUd9257sq 7k9X3idm4NJ+E6OtFY4Ofmp32kvwtXejG94U/5tkdTUCbiLDBcLLPtLDCAQ4KmP0DTbY 9Jh/zDmOz5pTGBZRRz8rxT824hdloCru2bXhk2r2a3b6MSTZKbeKcibHtXgDtRuBToI4 yfEQ== X-Gm-Message-State: AOJu0YymvOE1TSHCKUiiy8cms4e/AhMi90+5L5To0EAc27NktA7r1irL XGOYww55dHZAXWSKoxzVodurMS1yyofD5OVxXzd4CZ7iBmO8Cmud2fBbL04Ih0rYvXOHwp0wB8W JsBJOhQs= X-Gm-Gg: ASbGncvLafIx7nnEJyG90qNxS9lCS6MUgcG3QToflQl6f8KUS6kmX82e9ceD3lskMDS TN2x+W4X5IgjCSY4X8Zr9R6O/sFCxnlBDbg1SY7U879klcaBrCZnQfe5cn2ADW1vv61/z/1Jfwi uDczqQCkpX3fkt9AcUI7MCUjJCtGBJ2P8Lf6H4p2pny0LWcU83a0Pe6BEeGSM5hgPdXT12mf/2u teMX6c9DS6rc2549kKw36g7ZmfT6g0OxjVWWq0QEUVrpDUg5y5+QcmcKq1oclg9j2yXBHRm5Yyc 6Tr4FL9HHyDhigqNhMk094sDiQYZW3CuUXiMYFRWj5wjBkyTelFxBKRJx7BnCnsiLur6GDNWFUq Rcolht1nkbo3orLbY/XmHK2hBJxwFU1fCfwDgkF+gaA== X-Google-Smtp-Source: AGHT+IHlnsui8rdDPd5HazGwud6/iw05I3aHfIw4O7HRFeHrsxjaBJDVHt8KdXT8ycyFSdNq/dG4nw== X-Received: by 2002:a05:600c:64c5:b0:450:cff7:62f9 with SMTP id 5b1f17b1804b1-453248c3bdamr7902115e9.22.1749605676007; Tue, 10 Jun 2025 18:34:36 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:34 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Bryan O'Donoghue Subject: [PATCH 33/35] libcamera: software_isp: GPU support for unpacked 10/12-bit formats Date: Wed, 11 Jun 2025 02:32:43 +0100 Message-ID: <20250611013245.133785-34-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Milan Zamazal The GPU processing supports 8-bit sensor formats and 10/12-bit packed formats. Support for 10/12-bit unpacked formats is missing, let's add it. 10/12-bit unpacked formats use two adjacent bytes to store the value. This means the 8-bit shaders can be used if we can modify them for additional support of 16-bit addressing. This requires the following modifications: - Using GL_RG (two bytes per pixel) instead of GL_LUMINANCE (one byte per pixel) as the texture format for the given input formats. - Setting the texture width to the number of pixels rather than the number of bytes. - Making the definition of `fetch' macro variable, according to the pixel format. - Using only `fetch' for accessing the texture. Signed-off-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue Reviewed-by: Bryan O'Donoghue --- .../libcamera/internal/shaders/bayer_8.frag | 10 +++- src/libcamera/software_isp/debayer_egl.cpp | 46 +++++++++++++------ src/libcamera/software_isp/debayer_egl.h | 2 + 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_8.frag index 74ce1509..78c2609c 100644 --- a/include/libcamera/internal/shaders/bayer_8.frag +++ b/include/libcamera/internal/shaders/bayer_8.frag @@ -32,9 +32,17 @@ uniform mat3 ccm; void main(void) { vec3 rgb; + #if defined(RAW10P) + #define pixel(p) p.r / 4.0 + p.g * 64.0 + #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y))) + #elif defined(RAW12P) + #define pixel(p) p.r / 16.0 + p.g * 16.0 + #define fetch(x, y) pixel(texture2D(tex_y, vec2(x, y))) + #else #define fetch(x, y) texture2D(tex_y, vec2(x, y)).r + #endif - float C = texture2D(tex_y, center.xy).r; // ( 0, 0) + float C = fetch(center.x, center.y); // ( 0, 0) const vec4 kC = vec4( 4.0, 6.0, 5.0, 5.0) / 8.0; // Determine which of four types of pixels we are on. diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index b30d2107..71742d84 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -151,6 +151,8 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm } // Pixel location parameters + glFormat_ = GL_LUMINANCE; + bytesPerPixel_ = 1; switch (inputFormat) { case libcamera::formats::SBGGR8: case libcamera::formats::SBGGR10_CSI2P: @@ -197,20 +199,38 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm case libcamera::formats::SGRBG10_CSI2P: case libcamera::formats::SRGGB10_CSI2P: egl_.pushEnv(shaderEnv, "#define RAW10P"); - fragmentShaderData = bayer_1x_packed_frag; - fragmentShaderDataLen = bayer_1x_packed_frag_len; - vertexShaderData = identity_vert; - vertexShaderDataLen = identity_vert_len; + if (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) { + fragmentShaderData = bayer_8_frag; + fragmentShaderDataLen = bayer_8_frag_len; + vertexShaderData = bayer_8_vert; + vertexShaderDataLen = bayer_8_vert_len; + glFormat_ = GL_RG; + bytesPerPixel_ = 2; + } else { + fragmentShaderData = bayer_1x_packed_frag; + fragmentShaderDataLen = bayer_1x_packed_frag_len; + vertexShaderData = identity_vert; + vertexShaderDataLen = identity_vert_len; + } break; case libcamera::formats::SBGGR12_CSI2P: case libcamera::formats::SGBRG12_CSI2P: case libcamera::formats::SGRBG12_CSI2P: case libcamera::formats::SRGGB12_CSI2P: egl_.pushEnv(shaderEnv, "#define RAW12P"); - fragmentShaderData = bayer_1x_packed_frag; - fragmentShaderDataLen = bayer_1x_packed_frag_len; - vertexShaderData = identity_vert; - vertexShaderDataLen = identity_vert_len; + if (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) { + fragmentShaderData = bayer_8_frag; + fragmentShaderDataLen = bayer_8_frag_len; + vertexShaderData = bayer_8_vert; + vertexShaderDataLen = bayer_8_vert_len; + glFormat_ = GL_RG; + bytesPerPixel_ = 2; + } else { + fragmentShaderData = bayer_1x_packed_frag; + fragmentShaderDataLen = bayer_1x_packed_frag_len; + vertexShaderData = identity_vert; + vertexShaderDataLen = identity_vert_len; + } break; default: goto invalid_fmt; @@ -430,7 +450,7 @@ void DebayerEGL::setShaderVariableValues(void) GLfloat firstRed[] = { firstRed_x_, firstRed_y_ }; GLfloat imgSize[] = { (GLfloat)width_, (GLfloat)height_ }; - GLfloat Step[] = { 1.0f / (inputConfig_.stride - 1), + GLfloat Step[] = { static_cast(bytesPerPixel_) / (inputConfig_.stride - 1), 1.0f / (height_ - 1) }; GLfloat Stride = 1.0f; GLfloat projIdentityMatrix[] = { @@ -507,7 +527,7 @@ void DebayerEGL::debayerGPU(MappedFrameBuffer &in, MappedFrameBuffer &out, Debay // Greate a standard texture // we will replace this with the DMA version at some point - egl_.createTexture2D(eglImageBayerIn_, inputConfig_.stride, height_, in.planes()[0].data()); + egl_.createTexture2D(eglImageBayerIn_, glFormat_, inputConfig_.stride / bytesPerPixel_, height_, in.planes()[0].data()); // Populate bayer parameters if (ccmEnabled_) { @@ -518,9 +538,9 @@ void DebayerEGL::debayerGPU(MappedFrameBuffer &in, MappedFrameBuffer &out, Debay }; glUniformMatrix3fv(ccmUniformDataIn_, 1, GL_FALSE, ccm); } else { - egl_.createTexture2D(eglImageRedLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.red); - egl_.createTexture2D(eglImageGreenLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.green); - egl_.createTexture2D(eglImageBlueLookup_, DebayerParams::kRGBLookupSize, 1, ¶ms.blue); + egl_.createTexture2D(eglImageRedLookup_, GL_LUMINANCE, DebayerParams::kRGBLookupSize, 1, ¶ms.red); + egl_.createTexture2D(eglImageGreenLookup_, GL_LUMINANCE, DebayerParams::kRGBLookupSize, 1, ¶ms.green); + egl_.createTexture2D(eglImageBlueLookup_, GL_LUMINANCE, DebayerParams::kRGBLookupSize, 1, ¶ms.blue); } // Setup the scene diff --git a/src/libcamera/software_isp/debayer_egl.h b/src/libcamera/software_isp/debayer_egl.h index 94bc6fc4..56f5434a 100644 --- a/src/libcamera/software_isp/debayer_egl.h +++ b/src/libcamera/software_isp/debayer_egl.h @@ -150,6 +150,8 @@ private: GBM gbmSurface_; uint32_t width_; uint32_t height_; + GLint glFormat_; + unsigned int bytesPerPixel_; GLfloat vcoordinates[DEBAYER_OPENGL_COORDS][2] = { { -1.0f, -1.0f }, From patchwork Wed Jun 11 01:32:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23540 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 6255EC332A for ; Wed, 11 Jun 2025 01:34:43 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id F34AE68E01; Wed, 11 Jun 2025 03:34:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="EqqfoiM2"; dkim-atps=neutral Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8DE4B68DFF for ; Wed, 11 Jun 2025 03:34:39 +0200 (CEST) Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4530921461aso26487835e9.0 for ; Tue, 10 Jun 2025 18:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605679; x=1750210479; 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=zJCYQUQNddeKnCWxfHEDrxIHP9gpUnE73ekiVXEWSuY=; b=EqqfoiM2zINbqpG1wqxnQkSwrQWl8bpHJNO+3vgzCETke8XbIZ7iO8uv/upFl+aoyx GIi9TRIcyJ+GocgJ1FwogUxG9TDy7FvHXhynmbOuzZ/27RYNah1pp1kfiTjw52Nr9HON QtVVkhzmYihH7VEnxt+AbVnv3T8phWSVpGcGoItIdguIRSdTyxkiq6PJiVKWS544LgSy W/wOCPjwI8xlaLn/R5MWtWFbQDuzCcUwPkCVQXUO8qTYdfKJrhW6uxIv0tn/23gsfq7V Kr5wl84Cfzu0/OYOYCkQScz702ZBm4d/u36D4R2poMa+T/udcONy7bbC6nFB53nJMz8y AWbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605679; x=1750210479; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zJCYQUQNddeKnCWxfHEDrxIHP9gpUnE73ekiVXEWSuY=; b=Xzk6qQwY1lyapDd2iOHsos8NCd/Fmx7kR6fSnC4EMslx8XW02jQ5xwqC4E0NtjFV40 2oknYdV2ElPA+KPz+CULbOvpXYIiMPUVFjjzDvSRniSJU3crPTgNWTa4mb7nJEeahknE PJI0x36UL4acjaEpPXviqFDTlQpV6YiF/PC9ojGeDfnVmwG9wVNn1Bc/NGmiSzo6ZOdI CuPZIF4SBvY0XMuEK/MygCWDKvOXZkczFbtPv+DgRmmmo8GpJWMqWi1F8oiQT87YEpOJ GH7P8xQBGQaWVNrb7Rd7/nfocF41mRohJP63UMQxPD1sROsVNAGiRs7NAk8jxxnD6DFl CZIA== X-Gm-Message-State: AOJu0Yzbf1iYlf9te1ihT0ANK7nAvs08JFSoh4WFk0LvIn/MRDou5eY3 ngu2FE+IPoJ+EZyx5gbZ05uMVXbKTFEXFos3nPaNoxiP6hE7Dh1/5qNHMICsw5IMt82ishQMI4t VrYMOqcM= X-Gm-Gg: ASbGncuLhATE+WwCI0DGNuGAzzTdDsK0JJtYhJZHjKvCpUJzaG3t+IFZVgHhVW+goy7 dIS792wQdGzewjz5iKOv7YwTTFgqTR5gjpo46ZaUwQMxMBzzg/QZz4yJr5HsDR7PW1jdOLJ3abX djc184Yixv68MwfNmU8r63jjAZkfqgFdYHOKZ4UWmSr3+kaYuY7fyOaeLBW8NmxNXG31nmVXv72 tl/RiDKZkEOe5g9OUhQ2qPO/K9P809wAuYXL583pRWCq7oZ4uM44yuSkzeBLAOs8Pz5dt0YDhsf anVqZA2HJ4HOv4io/rlgADVGycOkColvzPLpw44eMOS2Lq3TLffbUJ0m9RG0W85/HBZyQ59Zi40 SvM1TFrrRDgVPLdNqJC2pW68ngfr/bA4FikOL6hmvHA== X-Google-Smtp-Source: AGHT+IFeFZH+bOIAHxkzAGZj3/R5Su7LWc1dRTHOeF4q6cSRfXWXYY3/eHmaM6QFkoQ/hR+U9amG7w== X-Received: by 2002:a05:600c:154c:b0:43c:ec4c:25b4 with SMTP id 5b1f17b1804b1-453248b0ee1mr10811865e9.10.1749605678863; Tue, 10 Jun 2025 18:34:38 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:38 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Milan Zamazal , Bryan O'Donoghue Subject: [PATCH 34/35] libcamera: shaders: Rename bayer_8 to bayer_unpacked Date: Wed, 11 Jun 2025 02:32:44 +0100 Message-ID: <20250611013245.133785-35-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Milan Zamazal bayer_8.* shaders are now used for all unpacked sensor data formats, regardless of the pixel bit width. Let's rename the "8-bit" shaders to avoid confusion. Signed-off-by: Milan Zamazal Signed-off-by: Bryan O'Donoghue Reviewed-by: Bryan O'Donoghue --- .../{bayer_8.frag => bayer_unpacked.frag} | 0 .../{bayer_8.vert => bayer_unpacked.vert} | 0 .../libcamera/internal/shaders/meson.build | 4 ++-- src/apps/qcam/assets/shader/shaders.qrc | 4 ++-- src/apps/qcam/viewfinder_gl.cpp | 16 ++++++------- src/libcamera/software_isp/debayer_egl.cpp | 24 +++++++++---------- 6 files changed, 24 insertions(+), 24 deletions(-) rename include/libcamera/internal/shaders/{bayer_8.frag => bayer_unpacked.frag} (100%) rename include/libcamera/internal/shaders/{bayer_8.vert => bayer_unpacked.vert} (100%) diff --git a/include/libcamera/internal/shaders/bayer_8.frag b/include/libcamera/internal/shaders/bayer_unpacked.frag similarity index 100% rename from include/libcamera/internal/shaders/bayer_8.frag rename to include/libcamera/internal/shaders/bayer_unpacked.frag diff --git a/include/libcamera/internal/shaders/bayer_8.vert b/include/libcamera/internal/shaders/bayer_unpacked.vert similarity index 100% rename from include/libcamera/internal/shaders/bayer_8.vert rename to include/libcamera/internal/shaders/bayer_unpacked.vert diff --git a/include/libcamera/internal/shaders/meson.build b/include/libcamera/internal/shaders/meson.build index 386b342d..dd441a57 100644 --- a/include/libcamera/internal/shaders/meson.build +++ b/include/libcamera/internal/shaders/meson.build @@ -4,7 +4,7 @@ # for the purposes of inclusion in OpenGL debayering shader_files = files([ 'bayer_1x_packed.frag', - 'bayer_8.frag', - 'bayer_8.vert', + 'bayer_unpacked.frag', + 'bayer_unpacked.vert', 'identity.vert', ]) diff --git a/src/apps/qcam/assets/shader/shaders.qrc b/src/apps/qcam/assets/shader/shaders.qrc index 04f9d706..32dfa51b 100644 --- a/src/apps/qcam/assets/shader/shaders.qrc +++ b/src/apps/qcam/assets/shader/shaders.qrc @@ -6,8 +6,8 @@ ../../../../../include/libcamera/internal/shaders/YUV_3_planes.frag ../../../../../include/libcamera/internal/shaders/YUV_packed.frag ../../../../../include/libcamera/internal/shaders/bayer_1x_packed.frag - ../../../../../include/libcamera/internal/shaders/bayer_8.frag - ../../../../../include/libcamera/internal/shaders/bayer_8.vert + ../../../../../include/libcamera/internal/shaders/bayer_unpacked.frag + ../../../../../include/libcamera/internal/shaders/bayer_unpacked.vert ../../../../../include/libcamera/internal/shaders/identity.vert diff --git a/src/apps/qcam/viewfinder_gl.cpp b/src/apps/qcam/viewfinder_gl.cpp index 70f60065..95965ab7 100644 --- a/src/apps/qcam/viewfinder_gl.cpp +++ b/src/apps/qcam/viewfinder_gl.cpp @@ -235,29 +235,29 @@ bool ViewFinderGL::selectFormat(const libcamera::PixelFormat &format) case libcamera::formats::SBGGR8: firstRed_.setX(1.0); firstRed_.setY(1.0); - vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; - fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGBRG8: firstRed_.setX(0.0); firstRed_.setY(1.0); - vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; - fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SGRBG8: firstRed_.setX(1.0); firstRed_.setY(0.0); - vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; - fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SRGGB8: firstRed_.setX(0.0); firstRed_.setY(0.0); - vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.vert"; - fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_8.frag"; + vertexShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.vert"; + fragmentShaderFile_ = ":include/libcamera/internal/shaders/bayer_unpacked.frag"; textureMinMagFilters_ = GL_NEAREST; break; case libcamera::formats::SBGGR10_CSI2P: diff --git a/src/libcamera/software_isp/debayer_egl.cpp b/src/libcamera/software_isp/debayer_egl.cpp index 71742d84..9ec96660 100644 --- a/src/libcamera/software_isp/debayer_egl.cpp +++ b/src/libcamera/software_isp/debayer_egl.cpp @@ -189,10 +189,10 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm case libcamera::formats::SGBRG8: case libcamera::formats::SGRBG8: case libcamera::formats::SRGGB8: - fragmentShaderData = bayer_8_frag; - fragmentShaderDataLen = bayer_8_frag_len; - vertexShaderData = bayer_8_vert; - vertexShaderDataLen = bayer_8_vert_len; + fragmentShaderData = bayer_unpacked_frag; + fragmentShaderDataLen = bayer_unpacked_frag_len; + vertexShaderData = bayer_unpacked_vert; + vertexShaderDataLen = bayer_unpacked_vert_len; break; case libcamera::formats::SBGGR10_CSI2P: case libcamera::formats::SGBRG10_CSI2P: @@ -200,10 +200,10 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm case libcamera::formats::SRGGB10_CSI2P: egl_.pushEnv(shaderEnv, "#define RAW10P"); if (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) { - fragmentShaderData = bayer_8_frag; - fragmentShaderDataLen = bayer_8_frag_len; - vertexShaderData = bayer_8_vert; - vertexShaderDataLen = bayer_8_vert_len; + fragmentShaderData = bayer_unpacked_frag; + fragmentShaderDataLen = bayer_unpacked_frag_len; + vertexShaderData = bayer_unpacked_vert; + vertexShaderDataLen = bayer_unpacked_vert_len; glFormat_ = GL_RG; bytesPerPixel_ = 2; } else { @@ -219,10 +219,10 @@ int DebayerEGL::initBayerShaders(PixelFormat inputFormat, PixelFormat outputForm case libcamera::formats::SRGGB12_CSI2P: egl_.pushEnv(shaderEnv, "#define RAW12P"); if (BayerFormat::fromPixelFormat(inputFormat).packing == BayerFormat::Packing::None) { - fragmentShaderData = bayer_8_frag; - fragmentShaderDataLen = bayer_8_frag_len; - vertexShaderData = bayer_8_vert; - vertexShaderDataLen = bayer_8_vert_len; + fragmentShaderData = bayer_unpacked_frag; + fragmentShaderDataLen = bayer_unpacked_frag_len; + vertexShaderData = bayer_unpacked_vert; + vertexShaderDataLen = bayer_unpacked_vert_len; glFormat_ = GL_RG; bytesPerPixel_ = 2; } else { From patchwork Wed Jun 11 01:32:45 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan O'Donoghue X-Patchwork-Id: 23541 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 596EDC3335 for ; Wed, 11 Jun 2025 01:34:45 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D179E68E03; Wed, 11 Jun 2025 03:34:44 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="W5UyCopA"; dkim-atps=neutral Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0E6A668DFD for ; Wed, 11 Jun 2025 03:34:42 +0200 (CEST) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-43cfe63c592so69825475e9.2 for ; Tue, 10 Jun 2025 18:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1749605681; x=1750210481; 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=0m12xjA1BCDmYO4m2lL9R9mWTByBEaOo21WJw27iUYo=; b=W5UyCopAG3UQFjDfbglkRtdO9IQY6u9edbWIr3MMMI8MveCjpccJ8x2kHOcznJAQuA p/3sRgjxUHXivqGnDH0NTA8weLCe4qoO9442Ak7x7fmNfKNKg7NWjnxhxldPOn35bzJi VuJqHTqI0ADcBII/02QeKDnK8O4leHVhlvM1bA0fTPmxKzhRi/5RjIrf+D40g4RRx8/Y usybb2v5b0m26IVf3az1n545qhOJX++L0hh3BrMWp3U2CBbsoRfYsZtNui0O14/hENyp 1R4wjfa+WoOkOFvzO+UAvSJXQ65/n4kGZzj4o7VL+ITt7q62dnbOx6IDSKyatl+CZW5l rPCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749605681; x=1750210481; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0m12xjA1BCDmYO4m2lL9R9mWTByBEaOo21WJw27iUYo=; b=Zn5KvWG+ed7VfGinwwj42pPzfiQNmYuePRoaiyaHxhojP1HtLPQYkE+x1+IHDHvIQ+ fgtO5fGmf0brEsyHNWkPLuvs+ihMR3t8UwEF1qkRXVLM9XX7T6IJoR/QZ+nK5soZX4+1 ipzfWgObket/792WPQwUW8YuAniFCAoPdjI9rxRAQiFJQyO06uAVOen4l4FZggVpvTMC Tky/I35IaVr5lwIrFA8Pjfq+besc+6C3znBsxfXELRceznQ0BFp6DpSgON2O3uYouhvY Fw4Ug+ELNUFXJC6cQCzMKOCcRfML5IuxHcTprk5RdeOx4gkdSQz7MgAwjDPrQdGK0rnV XR8A== X-Gm-Message-State: AOJu0YykypGaT+zIpwS3uMB3z9FnBfnk/i2Fnj+bXz7XAiWpNk0o31cf GSMvrOJD5QZu9N3q7QKbfTdsaTx9fMggWKMi1vU3bAX7uP65EjLN+t35zMcTMizRP3AiOW4TNRV PxGhyXGo= X-Gm-Gg: ASbGncuO8dotg0XUpem8hQDP5XFvMrunwRUZc7t/TMAxynwjSegpk/nQ16jpwpnO/Yz CpAZEuqV5fjjVVZK/VpnP4BAcZOK6wou9Y83l7gyC4Jx38thucnj/Uq8X68qzcEOI4YFC/ar0v1 PxxlT9PFd/gyy20yAZBo4YFx0RFcn4wHFhgemcQWo0ynOBmliK+yLpIXAZrPFPvDgBgt8+s3ffO pRdM5gE53GZLo7NDnwV4VvR7OHOWKBzgXAlqdpLordv7olfhZ6EJrcmPDzfUG8mLd75nsIE8x6U iudENW84z5qpJo3STbW8PrM1lRJjKGQFaVg7pWezTL/peBqPszW0hhhdjn85ZTiHxQJ5IcfGzpO //+DSyl+5ZUUEOTD5bnGweOm/lYhLT2dfo1QnCMrhOA== X-Google-Smtp-Source: AGHT+IFNp0Sjvcl8jPoLVZmh7Sst78F3yLOfgBT480EJV5km6K6+s1njWkZ5YChVHD4PZMxnqdO2Gg== X-Received: by 2002:a05:600c:3b93:b0:439:643a:c8d5 with SMTP id 5b1f17b1804b1-453247f88a8mr11495815e9.0.1749605681310; Tue, 10 Jun 2025 18:34:41 -0700 (PDT) Received: from inspiron14p-linux.ht.home (188-141-3-146.dynamic.upc.ie. [188.141.3.146]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4532514138asm5680625e9.3.2025.06.10.18.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jun 2025 18:34:40 -0700 (PDT) From: Bryan O'Donoghue To: libcamera-devel@lists.libcamera.org Cc: Bryan O'Donoghue Subject: [PATCH 35/35] libcamera: software_isp: Add a gpuisp todo list Date: Wed, 11 Jun 2025 02:32:45 +0100 Message-ID: <20250611013245.133785-36-bryan.odonoghue@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250611013245.133785-1-bryan.odonoghue@linaro.org> References: <20250611013245.133785-1-bryan.odonoghue@linaro.org> MIME-Version: 1.0 X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" List the series of things to do in GPU ISP in perceived order of difficulty. Signed-off-by: Bryan O'Donoghue --- src/libcamera/software_isp/gpuisp-todo.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/libcamera/software_isp/gpuisp-todo.txt diff --git a/src/libcamera/software_isp/gpuisp-todo.txt b/src/libcamera/software_isp/gpuisp-todo.txt new file mode 100644 index 00000000..0ff82f81 --- /dev/null +++ b/src/libcamera/software_isp/gpuisp-todo.txt @@ -0,0 +1,42 @@ +List the TODOs in perceived order of ease. + +24 bit output support: + - Take the BPP we already capture and get a 24 bit GBM surface + - Pass a compile-time parameter to the shaders to tell them to do + gl_FragColor = rgb not gl_FragColor = rgba + +Make GPUISP default: + - Right now the environment variable allows over-riding to swtich + from CPU to GPU. + - Once we support 24 BPP output on GPUISP we will have the same + pixel format support as CPU and can set the default to GPU without + regressing functionality + +glTexture1D: + - Initial code was developed for < GLES 2.O but since we have fixed + on GLES >= 2.0 this means we can use glTexture1D + - Provided this is so amend the shaders to do val = texture(x, y, 0); + not texture(x, y, 0.5) the 0.5 is because of using glTexture2D + +Surfaceless GBM: + - We get a GBM surface and then have to swap buffers + If we rework for surfaceless GBM and EGL then the swap buffer can + be dropped. + +dma-buf texture upload: + - Currently we pass the input buffer to glCreateTexture2D. + We should be able to make the upload of the input buffer go faster + by using eglCreateImageKHR and enumerated the dma-buf contents. + +Render-to-texture: + - Right now we render to the GBM provided surface framebuffer + and then memcpy from that buffer to the target output buffer. + This necessitates flushing the cache on the target buffer in + addition to the memcpy(). + - Render-to-texture where we generate the target framebuffer + directly from a dma-buf handle will mitigate the memcpy() phase. + - It should be the case then that the consumer of the output buffer + i.e. the thing that's not libcamera is responsible to flush the cache + if-and-only-if that user writes to the buffer. + - We need to flush the cache on the buffer because we are memcpying() to it. +