[{"id":34481,"web_url":"https://patchwork.libcamera.org/comment/34481/","msgid":"<85sejzk0xq.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","date":"2025-06-16T18:15:29","subject":"Re: [PATCH 10/35] libcamera: software_isp: Move param select code\n\tto Debayer base class","submitter":{"id":177,"url":"https://patchwork.libcamera.org/api/people/177/","name":"Milan Zamazal","email":"mzamazal@redhat.com"},"content":"Hi Bryan,\n\nBryan O'Donoghue <bryan.odonoghue@linaro.org> writes:\n\n> Move the parameter selection code into the Debayer base class in-order to\n> facilitate reuse of the lookup tables in the eGL shaders.\n>\n> Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>\n> ---\n>  src/libcamera/software_isp/debayer.cpp     | 40 ++++++++++++++++++++++\n>  src/libcamera/software_isp/debayer.h       |  5 +++\n>  src/libcamera/software_isp/debayer_cpu.cpp | 29 +++-------------\n>  3 files changed, 49 insertions(+), 25 deletions(-)\n>\n> diff --git a/src/libcamera/software_isp/debayer.cpp b/src/libcamera/software_isp/debayer.cpp\n> index 29fdcbbf..75e4bffa 100644\n> --- a/src/libcamera/software_isp/debayer.cpp\n> +++ b/src/libcamera/software_isp/debayer.cpp\n> @@ -187,4 +187,44 @@ Debayer::~Debayer()\n>   * \\brief Signals when the output buffer is ready\n>   */\n>  \n> +/**\n> + * \\fn void Debayer::setParams(DebayerParams &params)\n> + * \\brief Select the bayer params to use for the next frame debayer\n> + * \\param[in] params The parameters to be used in debayering\n> + */\n> +void Debayer::setParams(DebayerParams &params)\n> +{\n> +\tgreen_ = params.green;\n> +\tgreenCcm_ = params.greenCcm;\n> +\tif (swapRedBlueGains_) {\n> +\t\tred_ = params.blue;\n> +\t\tblue_ = params.red;\n> +\t\tredCcm_ = params.blueCcm;\n> +\t\tblueCcm_ = params.redCcm;\n> +\t\tfor (unsigned int i = 0; i < 256; i++) {\n> +\t\t\tstd::swap(redCcm_[i].r, redCcm_[i].b);\n> +\t\t\tstd::swap(blueCcm_[i].r, blueCcm_[i].b);\n> +\t\t}\n> +\t} else {\n> +\t\tred_ = params.red;\n> +\t\tblue_ = params.blue;\n> +\t\tredCcm_ = params.redCcm;\n> +\t\tblueCcm_ = params.blueCcm;\n> +\t}\n> +\tgammaLut_ = params.gammaLut;\n> +}\n> +\n> +/**\n> + * \\fn void Debayer::dmaSyncBegin(DebayerParams &params)\n> + * \\brief Common CPU/GPU Dma Sync Buffer begin\n> + */\n> +void Debayer::dmaSyncBegin(std::vector<DmaSyncer> &dmaSyncers, FrameBuffer *input, FrameBuffer *output)\n\nIs this related to parameter setting in any way?\n\n> +{\n> +\tfor (const FrameBuffer::Plane &plane : input->planes())\n> +\t\tdmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read);\n> +\n> +\tfor (const FrameBuffer::Plane &plane : output->planes())\n> +\t\tdmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write);\n> +}\n> +\n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/software_isp/debayer.h b/src/libcamera/software_isp/debayer.h\n> index 01b6e916..0af66b55 100644\n> --- a/src/libcamera/software_isp/debayer.h\n> +++ b/src/libcamera/software_isp/debayer.h\n> @@ -20,6 +20,7 @@\n>  #include <libcamera/geometry.h>\n>  #include <libcamera/stream.h>\n>  \n> +#include \"libcamera/internal/dma_buf_allocator.h\"\n>  #include \"libcamera/internal/software_isp/benchmark.h\"\n>  #include \"libcamera/internal/software_isp/debayer_params.h\"\n>  \n> @@ -82,6 +83,10 @@ public:\n>  \n>  private:\n>  \tvirtual Size patternSize(PixelFormat inputFormat) = 0;\n> +\n> +protected:\n> +\tvoid setParams(DebayerParams &params);\n> +\tvoid dmaSyncBegin(std::vector<DmaSyncer> &dmaSyncers, FrameBuffer *input, FrameBuffer *output);\n>  };\n>  \n>  } /* namespace libcamera */\n> diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp\n> index 13db8a8c..4ef573a3 100644\n> --- a/src/libcamera/software_isp/debayer_cpu.cpp\n> +++ b/src/libcamera/software_isp/debayer_cpu.cpp\n> @@ -22,7 +22,6 @@\n>  #include <libcamera/formats.h>\n>  \n>  #include \"libcamera/internal/bayer_format.h\"\n> -#include \"libcamera/internal/dma_buf_allocator.h\"\n>  #include \"libcamera/internal/framebuffer.h\"\n>  #include \"libcamera/internal/mapped_framebuffer.h\"\n>  \n> @@ -740,30 +739,10 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output\n>  \tbench_.startFrame();\n>  \n>  \tstd::vector<DmaSyncer> dmaSyncers;\n> -\tfor (const FrameBuffer::Plane &plane : input->planes())\n> -\t\tdmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Read);\n> -\n> -\tfor (const FrameBuffer::Plane &plane : output->planes())\n> -\t\tdmaSyncers.emplace_back(plane.fd, DmaSyncer::SyncType::Write);\n> -\n> -\tgreen_ = params.green;\n> -\tgreenCcm_ = params.greenCcm;\n> -\tif (swapRedBlueGains_) {\n> -\t\tred_ = params.blue;\n> -\t\tblue_ = params.red;\n> -\t\tredCcm_ = params.blueCcm;\n> -\t\tblueCcm_ = params.redCcm;\n> -\t\tfor (unsigned int i = 0; i < 256; i++) {\n> -\t\t\tstd::swap(redCcm_[i].r, redCcm_[i].b);\n> -\t\t\tstd::swap(blueCcm_[i].r, blueCcm_[i].b);\n> -\t\t}\n> -\t} else {\n> -\t\tred_ = params.red;\n> -\t\tblue_ = params.blue;\n> -\t\tredCcm_ = params.redCcm;\n> -\t\tblueCcm_ = params.blueCcm;\n> -\t}\n> -\tgammaLut_ = params.gammaLut;\n> +\n> +\tdmaSyncBegin(dmaSyncers, input, output);\n> +\n> +\tsetParams(params);\n>  \n>  \t/* Copy metadata from the input buffer */\n>  \tFrameMetadata &metadata = output->_d()->metadata();","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 9CC71C3237\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 16 Jun 2025 18:15:37 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A213568DCF;\n\tMon, 16 Jun 2025 20:15:36 +0200 (CEST)","from us-smtp-delivery-124.mimecast.com\n\t(us-smtp-delivery-124.mimecast.com [170.10.133.124])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D777068DC0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Jun 2025 20:15:34 +0200 (CEST)","from mail-wm1-f70.google.com (mail-wm1-f70.google.com\n\t[209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS\n\t(version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n\tus-mta-436-5fOspAHiMS6Jytmj4T7xGw-1; Mon, 16 Jun 2025 14:15:32 -0400","by mail-wm1-f70.google.com with SMTP id\n\t5b1f17b1804b1-451dda846a0so36800615e9.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 16 Jun 2025 11:15:32 -0700 (PDT)","from mzamazal-thinkpadp1gen7.tpbc.csb\n\t(ip-77-48-47-2.net.vodafone.cz. [77.48.47.2])\n\tby smtp.gmail.com with ESMTPSA id\n\t5b1f17b1804b1-4532e24155bsm149757015e9.17.2025.06.16.11.15.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 16 Jun 2025 11:15:29 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=redhat.com header.i=@redhat.com\n\theader.b=\"NuHybWr7\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n\ts=mimecast20190719; t=1750097733;\n\th=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n\tto:to:cc:cc:mime-version:mime-version:content-type:content-type:\n\tin-reply-to:in-reply-to:references:references;\n\tbh=zgVDAr7rfJJJmh4xo+jS5z19AY25wdeL3WUC6pwJxss=;\n\tb=NuHybWr7qjFaCoEJW6VH/9QgNHmOCuOkBcbMz/r0x2XzoRTVXjzz7vnT4ccHMjY/25E4WM\n\tu5LfPhWA2Xr2r75zSDrND2v7thGNedGQs9lLct+ZROOcOg58fp34+dqJHIP/YIowGkYfnh\n\t/s8S59b+ms1/BdAUsnzm9CrPNsOgIWg=","X-MC-Unique":"5fOspAHiMS6Jytmj4T7xGw-1","X-Mimecast-MFC-AGG-ID":"5fOspAHiMS6Jytmj4T7xGw_1750097731","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20230601; t=1750097731; x=1750702531;\n\th=mime-version:user-agent:message-id:date:references:in-reply-to\n\t:subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date\n\t:message-id:reply-to;\n\tbh=zgVDAr7rfJJJmh4xo+jS5z19AY25wdeL3WUC6pwJxss=;\n\tb=kcv3a257l8aOBto7Y2WmFZyUbLFs0PtVyZri0ToiL9J+XRvI8uKWLQfgkjuyTTQEHA\n\t3PQ2nC6z7Xwt0PpfWgsj45Y5cOvv5We0M0gNQQTpyg9b5CRaMZ5Dk5JPFGsiB0P8s1ai\n\t4YKmejF2psmS9YEGVSubc4wdYGb48gMv1geNAo+4df0YOsS+cadLXAWbZyZ3Y2C0h4YE\n\tH4fZsvvI21zqRQvz4JQpgiV7NTpvW2k2iviNmMfNr/+mMd1pkyT+dCCOfvLTpYh/E8HJ\n\tfWUMNA+7/OyXL19WCnf7rUxjivbmoY4PZWm8Eczc/TMoTd0BinKzVLOTFgpolgVd/X01\n\tcdAg==","X-Gm-Message-State":"AOJu0YzZc3BwuLLbltPiqOoV/R3/LSshs67gTLhZH8fnnL8/N0BVH/1P\n\ta/habYptHFbirQPtbZRlholAw5hetoQiM5OsQSXtAdaTupX2J4LtTox8S0IQzs495NgQ3T0CDSq\n\tz3tQsA0mzwNPukD9UHK/7tlEIMV8TY73UZ9Cu08eeqdQ9lXu0SKzHJYmBDDJMPaFIOlbfM8uTkP\n\tHZMtRrkL/9UCT/VZhj49xi0mAMutYaZr41p3ky71NKKefvgqRFGRQO6uZ4lU4=","X-Gm-Gg":"ASbGncvPnyVgIAN5Xsr1u+doqdN7pn+IAGDBJ6OThl/1UZQwsXmdOam86hhWKd8kzxu\n\trs3cLr5wrEEA7uhF/JJ1x1DTDmcicn7ILDVWcr+FOzeItj8GX9MJGGHB9sH5uWJ41kgkgS85Omb\n\tTyeohKqhSMV2V/7zUh4Xp9oZSyel+Af1BC2uf6oG0MiYKNgtTy10xbugi4Max+FPn+F+W/VpzGM\n\twokLEcUs7XYDWkx1i0abQgbXSUDeADqsx04lBQ5AJGZmrb+fmzSSTT2c4zazyvsP4UPaEGFL4g+\n\tKc2UGwt/L/vmSNYRATXMBdEltau4BoRmtLmE2RqHUqG2tidRnhaC8RN2Xpal+3Ms6YK9t3BkQrw\n\t=","X-Received":["by 2002:a05:600c:a02:b0:450:cde3:f266 with SMTP id\n\t5b1f17b1804b1-4533caaee87mr84201395e9.22.1750097730666; \n\tMon, 16 Jun 2025 11:15:30 -0700 (PDT)","by 2002:a05:600c:a02:b0:450:cde3:f266 with SMTP id\n\t5b1f17b1804b1-4533caaee87mr84201165e9.22.1750097730234; \n\tMon, 16 Jun 2025 11:15:30 -0700 (PDT)"],"X-Google-Smtp-Source":"AGHT+IFqI2VsGoTK4Sqxl+i90gDV1+CzEDdrr4H7Ap2k0VRo4mfDxlxVWrJckum2uBttD6GU6TaxVA==","From":"Milan Zamazal <mzamazal@redhat.com>","To":"Bryan O'Donoghue <bryan.odonoghue@linaro.org>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH 10/35] libcamera: software_isp: Move param select code\n\tto Debayer base class","In-Reply-To":"<20250611013245.133785-11-bryan.odonoghue@linaro.org> (Bryan\n\tO'Donoghue's message of \"Wed, 11 Jun 2025 02:32:20 +0100\")","References":"<20250611013245.133785-1-bryan.odonoghue@linaro.org>\n\t<20250611013245.133785-11-bryan.odonoghue@linaro.org>","Date":"Mon, 16 Jun 2025 20:15:29 +0200","Message-ID":"<85sejzk0xq.fsf@mzamazal-thinkpadp1gen7.tpbc.csb>","User-Agent":"Gnus/5.13 (Gnus v5.13)","MIME-Version":"1.0","X-Mimecast-Spam-Score":"0","X-Mimecast-MFC-PROC-ID":"0g0hEsT5X2zC53tRtICG8zNDqjVDTgBv0QvtiqO8VVI_1750097731","X-Mimecast-Originator":"redhat.com","Content-Type":"text/plain","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]