[{"id":30999,"web_url":"https://patchwork.libcamera.org/comment/30999/","msgid":"<20240830233631.GB3811@pendragon.ideasonboard.com>","date":"2024-08-30T23:36:31","subject":"Re: [PATCH v2 04/20] libcamera: ipu3: Formatting improvements","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Milan,\n\nThank you for the patch.\n\nOn Fri, Aug 30, 2024 at 05:27:01PM +0200, Milan Zamazal wrote:\n> The LSP autoformatter doesn't like some of the current formatting, let's\n> make it happy.\n> \n> Signed-off-by: Milan Zamazal <mzamazal@redhat.com>\n> ---\n>  src/ipa/ipu3/algorithms/agc.cpp      | 31 ++++++++++-----------\n>  src/ipa/ipu3/algorithms/blc.cpp      |  4 +--\n>  src/ipa/ipu3/ipu3.cpp                | 11 ++++----\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 40 +++++++++++++++-------------\n>  4 files changed, 45 insertions(+), 41 deletions(-)\n> \n> diff --git a/src/ipa/ipu3/algorithms/agc.cpp b/src/ipa/ipu3/algorithms/agc.cpp\n> index 3378c4fd..548b64a4 100644\n> --- a/src/ipa/ipu3/algorithms/agc.cpp\n> +++ b/src/ipa/ipu3/algorithms/agc.cpp\n> @@ -14,6 +14,7 @@\n>  #include <libcamera/base/utils.h>\n>  \n>  #include <libcamera/control_ids.h>\n> +\n\nAck.\n\n>  #include <libcamera/ipa/core_ipa_interface.h>\n>  \n>  #include \"libipa/histogram.h\"\n> @@ -136,11 +137,9 @@ Histogram Agc::parseStatistics(const ipu3_uapi_stats_3a *stats,\n>  \t\t\t\treinterpret_cast<const ipu3_uapi_awb_set_item *>(\n>  \t\t\t\t\t&stats->awb_raw_buffer.meta_data[cellPosition]);\n>  \n> -\t\t\trgbTriples_.push_back({\n> -\t\t\t\tcell->R_avg,\n> -\t\t\t\t(cell->Gr_avg + cell->Gb_avg) / 2,\n> -\t\t\t\tcell->B_avg\n> -\t\t\t});\n> +\t\t\trgbTriples_.push_back({ cell->R_avg,\n> +\t\t\t\t\t\t(cell->Gr_avg + cell->Gb_avg) / 2,\n> +\t\t\t\t\t\tcell->B_avg });\n\nI think this hinders readability.\n\n>  \n>  \t\t\t/*\n>  \t\t\t * Store the average green value to estimate the\n> @@ -184,9 +183,10 @@ double Agc::estimateLuminance(double gain) const\n>  \t\tblueSum += std::min(std::get<2>(rgbTriples_[i]) * gain, 255.0);\n>  \t}\n>  \n> -\tdouble ySum = redSum * rGain_ * 0.299\n> -\t\t    + greenSum * gGain_ * 0.587\n> -\t\t    + blueSum * bGain_ * 0.114;\n> +\tdouble ySum =\n> +\t\tredSum * rGain_ * 0.299 +\n> +\t\tgreenSum * gGain_ * 0.587 +\n> +\t\tblueSum * bGain_ * 0.114;\n\nDitto.\n\n>  \n>  \treturn ySum / (bdsGrid_.height * bdsGrid_.width) / 255;\n>  }\n> @@ -216,8 +216,8 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>  \t * The Agc algorithm needs to know the effective exposure value that was\n>  \t * applied to the sensor when the statistics were collected.\n>  \t */\n> -\tutils::Duration exposureTime = context.configuration.sensor.lineDuration\n> -\t\t\t\t     * frameContext.sensor.exposure;\n> +\tutils::Duration exposureTime =\n> +\t\tcontext.configuration.sensor.lineDuration * frameContext.sensor.exposure;\n\nDitto.\n\n>  \tdouble analogueGain = frameContext.sensor.gain;\n>  \tutils::Duration effectiveExposureValue = exposureTime * analogueGain;\n>  \n> @@ -241,12 +241,13 @@ void Agc::process(IPAContext &context, [[maybe_unused]] const uint32_t frame,\n>  \tmetadata.set(controls::ExposureTime, exposureTime.get<std::micro>());\n>  \n>  \t/* \\todo Use VBlank value calculated from each frame exposure. */\n> -\tuint32_t vTotal = context.configuration.sensor.size.height\n> -\t\t\t+ context.configuration.sensor.defVBlank;\n> -\tutils::Duration frameDuration = context.configuration.sensor.lineDuration\n> -\t\t\t\t      * vTotal;\n> +\tuint32_t vTotal =\n> +\t\tcontext.configuration.sensor.size.height +\n> +\t\tcontext.configuration.sensor.defVBlank;\n> +\tutils::Duration frameDuration =\n> +\t\tcontext.configuration.sensor.lineDuration *\n> +\t\tvTotal;\n\nDitto.\n\n>  \tmetadata.set(controls::FrameDuration, frameDuration.get<std::micro>());\n> -\n\nAck.\n\n>  }\n>  \n>  REGISTER_IPA_ALGORITHM(Agc, \"Agc\")\n> diff --git a/src/ipa/ipu3/algorithms/blc.cpp b/src/ipa/ipu3/algorithms/blc.cpp\n> index fa4b9272..35748fb2 100644\n> --- a/src/ipa/ipu3/algorithms/blc.cpp\n> +++ b/src/ipa/ipu3/algorithms/blc.cpp\n> @@ -55,8 +55,8 @@ void BlackLevelCorrection::prepare([[maybe_unused]] IPAContext &context,\n>  \t * tuning processes. This is a first rough approximation.\n>  \t */\n>  \tparams->obgrid_param.gr = 64;\n> -\tparams->obgrid_param.r  = 64;\n> -\tparams->obgrid_param.b  = 64;\n> +\tparams->obgrid_param.r = 64;\n> +\tparams->obgrid_param.b = 64;\n\nNot strong opinion.\n\n>  \tparams->obgrid_param.gb = 64;\n>  \n>  \t/* Enable the custom black level correction processing */\n> diff --git a/src/ipa/ipu3/ipu3.cpp b/src/ipa/ipu3/ipu3.cpp\n> index 656c51fc..e6b2b5bb 100644\n> --- a/src/ipa/ipu3/ipu3.cpp\n> +++ b/src/ipa/ipu3/ipu3.cpp\n> @@ -24,10 +24,11 @@\n>  \n>  #include <libcamera/control_ids.h>\n>  #include <libcamera/framebuffer.h>\n> +#include <libcamera/request.h>\n> +\n>  #include <libcamera/ipa/ipa_interface.h>\n>  #include <libcamera/ipa/ipa_module_info.h>\n>  #include <libcamera/ipa/ipu3_ipa_interface.h>\n> -#include <libcamera/request.h>\n\nAck.\n\n>  \n>  #include \"libcamera/internal/mapped_framebuffer.h\"\n>  #include \"libcamera/internal/yaml_parser.h\"\n> @@ -308,8 +309,8 @@ int IPAIPU3::init(const IPASettings &settings,\n>  \n>  \t/* Clean context */\n>  \tcontext_.configuration = {};\n> -\tcontext_.configuration.sensor.lineDuration = sensorInfo.minLineLength\n> -\t\t\t\t\t\t   * 1.0s / sensorInfo.pixelRate;\n> +\tcontext_.configuration.sensor.lineDuration =\n> +\t\tsensorInfo.minLineLength * 1.0s / sensorInfo.pixelRate;\n\nI'd keep the existing formatting but I'm OK either way.\n\n>  \n>  \t/* Load the tuning data file. */\n>  \tFile file(settings.configurationFile);\n> @@ -472,8 +473,8 @@ int IPAIPU3::configure(const IPAConfigInfo &configInfo,\n>  \tcontext_.frameContexts.clear();\n>  \n>  \t/* Initialise the sensor configuration. */\n> -\tcontext_.configuration.sensor.lineDuration = sensorInfo_.minLineLength\n> -\t\t\t\t\t\t   * 1.0s / sensorInfo_.pixelRate;\n> +\tcontext_.configuration.sensor.lineDuration =\n> +\t\tsensorInfo_.minLineLength * 1.0s / sensorInfo_.pixelRate;\n\nDitto.\n\n>  \tcontext_.configuration.sensor.size = sensorInfo_.outputSize;\n>  \n>  \t/*\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 29172f34..6b4fe486 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -18,12 +18,13 @@\n>  #include <libcamera/camera.h>\n>  #include <libcamera/control_ids.h>\n>  #include <libcamera/formats.h>\n> -#include <libcamera/ipa/ipu3_ipa_interface.h>\n> -#include <libcamera/ipa/ipu3_ipa_proxy.h>\n>  #include <libcamera/property_ids.h>\n>  #include <libcamera/request.h>\n>  #include <libcamera/stream.h>\n>  \n> +#include <libcamera/ipa/ipu3_ipa_interface.h>\n> +#include <libcamera/ipa/ipu3_ipa_proxy.h>\n> +\n\nAck.\n\n>  #include \"libcamera/internal/camera.h\"\n>  #include \"libcamera/internal/camera_lens.h\"\n>  #include \"libcamera/internal/camera_sensor.h\"\n> @@ -417,9 +418,9 @@ PipelineHandlerIPU3::generateConfiguration(Camera *camera, Span<const StreamRole\n>  \t\t\t * in validate()\n>  \t\t\t */\n>  \t\t\tsize = sensorResolution.boundedTo(ImgUDevice::kOutputMaxSize)\n> -\t\t\t\t\t       .shrunkBy({ 1, 1 })\n> -\t\t\t\t\t       .alignedDownTo(ImgUDevice::kOutputMarginWidth,\n> -\t\t\t\t\t\t\t      ImgUDevice::kOutputMarginHeight);\n> +\t\t\t\t       .shrunkBy({ 1, 1 })\n> +\t\t\t\t       .alignedDownTo(ImgUDevice::kOutputMarginWidth,\n> +\t\t\t\t\t\t      ImgUDevice::kOutputMarginHeight);\n\nNack.\n\n>  \t\t\tpixelFormat = formats::NV12;\n>  \t\t\tbufferCount = IPU3CameraConfiguration::kBufferCount;\n>  \t\t\tstreamFormats[pixelFormat] = { { ImgUDevice::kOutputMinSize, size } };\n> @@ -447,8 +448,8 @@ PipelineHandlerIPU3::generateConfiguration(Camera *camera, Span<const StreamRole\n>  \t\t\t * to the ImgU output constraints.\n>  \t\t\t */\n>  \t\t\tsize = sensorResolution.boundedTo(kViewfinderSize)\n> -\t\t\t\t\t       .alignedDownTo(ImgUDevice::kOutputAlignWidth,\n> -\t\t\t\t\t\t\t      ImgUDevice::kOutputAlignHeight);\n> +\t\t\t\t       .alignedDownTo(ImgUDevice::kOutputAlignWidth,\n> +\t\t\t\t\t\t      ImgUDevice::kOutputAlignHeight);\n\nNack.\n\n>  \t\t\tpixelFormat = formats::NV12;\n>  \t\t\tbufferCount = IPU3CameraConfiguration::kBufferCount;\n>  \t\t\tstreamFormats[pixelFormat] = { { ImgUDevice::kOutputMinSize, size } };\n> @@ -991,18 +992,19 @@ int PipelineHandlerIPU3::updateControls(IPU3CameraData *data)\n>  \t */\n>  \n>  \t/* The strictly smaller size than the sensor resolution, aligned to margins. */\n> -\tSize minSize = sensor->resolution().shrunkBy({ 1, 1 })\n> -\t\t\t\t\t   .alignedDownTo(ImgUDevice::kOutputMarginWidth,\n> -\t\t\t\t\t\t\t  ImgUDevice::kOutputMarginHeight);\n> +\tSize minSize = sensor->resolution()\n> +\t\t\t       .shrunkBy({ 1, 1 })\n> +\t\t\t       .alignedDownTo(ImgUDevice::kOutputMarginWidth,\n> +\t\t\t\t\t      ImgUDevice::kOutputMarginHeight);\n\nI don't like this one much.\n\n>  \n>  \t/*\n>  \t * Either the smallest margin-aligned size larger than the viewfinder\n>  \t * size or the adjusted sensor resolution.\n>  \t */\n>  \tminSize = kViewfinderSize.grownBy({ 1, 1 })\n> -\t\t\t\t .alignedUpTo(ImgUDevice::kOutputMarginWidth,\n> -\t\t\t\t\t      ImgUDevice::kOutputMarginHeight)\n> -\t\t\t\t .boundedTo(minSize);\n> +\t\t\t  .alignedUpTo(ImgUDevice::kOutputMarginWidth,\n> +\t\t\t\t       ImgUDevice::kOutputMarginHeight)\n> +\t\t\t  .boundedTo(minSize);\n\nNack.\n\n>  \n>  \t/*\n>  \t * Re-scale in the sensor's native coordinates. Report (0,0) as\n> @@ -1116,19 +1118,19 @@ int PipelineHandlerIPU3::registerCameras()\n>  \t\t * returned through the ImgU main and secondary outputs.\n>  \t\t */\n>  \t\tdata->cio2_.bufferReady().connect(data.get(),\n> -\t\t\t\t\t&IPU3CameraData::cio2BufferReady);\n> +\t\t\t\t\t\t  &IPU3CameraData::cio2BufferReady);\n\nAck for the rest.\n\n>  \t\tdata->cio2_.bufferAvailable.connect(\n>  \t\t\tdata.get(), &IPU3CameraData::queuePendingRequests);\n>  \t\tdata->imgu_->input_->bufferReady.connect(&data->cio2_,\n> -\t\t\t\t\t&CIO2Device::tryReturnBuffer);\n> +\t\t\t\t\t\t\t &CIO2Device::tryReturnBuffer);\n>  \t\tdata->imgu_->output_->bufferReady.connect(data.get(),\n> -\t\t\t\t\t&IPU3CameraData::imguOutputBufferReady);\n> +\t\t\t\t\t\t\t  &IPU3CameraData::imguOutputBufferReady);\n>  \t\tdata->imgu_->viewfinder_->bufferReady.connect(data.get(),\n> -\t\t\t\t\t&IPU3CameraData::imguOutputBufferReady);\n> +\t\t\t\t\t\t\t      &IPU3CameraData::imguOutputBufferReady);\n>  \t\tdata->imgu_->param_->bufferReady.connect(data.get(),\n> -\t\t\t\t\t&IPU3CameraData::paramBufferReady);\n> +\t\t\t\t\t\t\t &IPU3CameraData::paramBufferReady);\n>  \t\tdata->imgu_->stat_->bufferReady.connect(data.get(),\n> -\t\t\t\t\t&IPU3CameraData::statBufferReady);\n> +\t\t\t\t\t\t\t&IPU3CameraData::statBufferReady);\n>  \n>  \t\t/* Create and register the Camera instance. */\n>  \t\tconst std::string &cameraId = cio2->sensor()->id();","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 C38B3C323E\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 30 Aug 2024 23:37:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id A325663466;\n\tSat, 31 Aug 2024 01:37:04 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B232B6341E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 31 Aug 2024 01:37:03 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id CECD574C;\n\tSat, 31 Aug 2024 01:35:53 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"VBDQb9XF\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1725060954;\n\tbh=qXCRs3Ddxyz+8vtNSRuKxYUAKByRBHAk7vwVGTS2TLA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VBDQb9XF00nxzH5YYLEHaBA+sd2WcVlg35Q6RAbmnmpgpxBhQ4UcoVdBqjB2kPzg1\n\trbVKXan37f/2VqQ3Y5F0xTSH5n5baAlMtnkV8a/TsbAGKfxtRvGtI0pUZVsZWsl037\n\tFUbwId66aX9J/bK6ZPj5fz7jVFMGZN/nskh5Oj1Y=","Date":"Sat, 31 Aug 2024 02:36:31 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Milan Zamazal <mzamazal@redhat.com>","Cc":"libcamera-devel@lists.libcamera.org","Subject":"Re: [PATCH v2 04/20] libcamera: ipu3: Formatting improvements","Message-ID":"<20240830233631.GB3811@pendragon.ideasonboard.com>","References":"<20240830152721.1420313-1-mzamazal@redhat.com>\n\t<20240830152721.1420313-5-mzamazal@redhat.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20240830152721.1420313-5-mzamazal@redhat.com>","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>"}}]