{"id":9784,"url":"https://patchwork.libcamera.org/api/patches/9784/?format=json","web_url":"https://patchwork.libcamera.org/patch/9784/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200924091927.116385-5-naush@raspberrypi.com>","date":"2020-09-24T09:19:27","name":"[libcamera-devel,4/4] ipa: raspberrypi: Tidy up variable names to be consistent","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"5d161c7444b65787ee42ee0ed4b7dca0959317e7","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9784/mbox/","series":[{"id":1318,"url":"https://patchwork.libcamera.org/api/series/1318/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1318","date":"2020-09-24T09:19:23","name":"Code tidy-ups","version":1,"mbox":"https://patchwork.libcamera.org/series/1318/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9784/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9784/checks/","tags":{},"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 90CF4C3B5B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 24 Sep 2020 09:19:40 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5B66062FFC;\n\tThu, 24 Sep 2020 11:19:40 +0200 (CEST)","from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com\n\t[IPv6:2a00:1450:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5929762FFD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Sep 2020 11:19:36 +0200 (CEST)","by mail-wr1-x42d.google.com with SMTP id w5so2961882wrp.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 24 Sep 2020 02:19:36 -0700 (PDT)","from naushir-VirtualBox.pitowers.org\n\t([2a00:1098:3142:14:a00:27ff:fe4d:f6a2])\n\tby smtp.gmail.com with ESMTPSA id\n\tw81sm2689324wmg.47.2020.09.24.02.19.34\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 24 Sep 2020 02:19:34 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=raspberrypi.com header.i=@raspberrypi.com\n\theader.b=\"r5Akqugs\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=f2SCp859SUFGddPc18D80RHCEM+3vlv3akelisZtHlM=;\n\tb=r5AkqugsVEchGTrIxtTe+cOUH9sPN7y988F53tjUBNiymE/TlPPejgaqBAiDhaL1g7\n\tgBBv+fNTmLr+7hd7ojKxHT5uZQUHas6n75mWUEnGCBIjD81zQPXiWcU8BGBCsEalA0Y/\n\tjvBo/rvrv86Idj3YEYPPqk6O5oWsdZyWdxDoGYpvNVsp5/4ItCdGWCAhALUIvsId6h8G\n\twvKWInKFb84wcd/9QNP6LWwHVSuZ6HRH1bogpDP2uw44nMZF8se9jVRFYEYCm3H1ixRx\n\tM/uoMyz3ne3528rrwf4KOTs7F7RYlEjUE8fibmvX8z5/savULUuSlyTSL50kCGxhNa3V\n\tSfjA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=f2SCp859SUFGddPc18D80RHCEM+3vlv3akelisZtHlM=;\n\tb=Ql6F8ddulBfLyk0XNO4+6B7wqaknIxkxcajHn8V7Q7rACe1m4/QyTw0A70w5FCI0e8\n\tldnPKSytiUQEo8nWBSSveG/0qrIBPCuJzkAP8QUv+CUxdfvWfdjzH/WwrUcwIu0qUBH3\n\tIoYRUo0c6ZHvifY3+dMPtMHZjfpaWLWfC4HOr+gKunaSuwD8rZLmI+9vDb+Tmn2yPjmv\n\tC44MAoX2pFJFAVSphYS9JwEJr7xlRu2RKeRjf1N88vXIDRAasifJbxH9gXZvuCocCReA\n\traJAZTNXTLXnbJ3/XXX4VngRMqc+PpaDsID+Nd+vTUcw3Lhg0TeSL2BiPjpiB9kf9aEO\n\t/3Ng==","X-Gm-Message-State":"AOAM531Smb+rj5r1Pa7TxTRZe8c+T14vOTSj5F2ur6OEBm6hlHoA91kb\n\t/UR4INXTaAzmbaGcL6OXycsWETEkZNvH3w==","X-Google-Smtp-Source":"ABdhPJx7e5frugFDrunAIIPQqoAyggglE2OqvmaPQt4oBywUljPLDhWbnDryYCd9LkQV4jIyII3cGA==","X-Received":"by 2002:adf:83c3:: with SMTP id 61mr3900639wre.287.1600939175217;\n\tThu, 24 Sep 2020 02:19:35 -0700 (PDT)","From":"Naushir Patuck <naush@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 24 Sep 2020 10:19:27 +0100","Message-Id":"<20200924091927.116385-5-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20200924091927.116385-1-naush@raspberrypi.com>","References":"<20200924091927.116385-1-naush@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 4/4] ipa: raspberrypi: Tidy up variable\n\tnames to be consistent","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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Change variable names to camel case to be consistent with the rest of\nthe source files. Remove #define consts and replace with constexpr.\nAdd some newlines to make the code more readable.\n\nThere are no functional changes in this commit.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nAcked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n include/libcamera/ipa/raspberrypi.h           |   2 +-\n src/ipa/raspberrypi/raspberrypi.cpp           | 191 +++++++++---------\n .../pipeline/raspberrypi/raspberrypi.cpp      |   2 +-\n 3 files changed, 100 insertions(+), 95 deletions(-)","diff":"diff --git a/include/libcamera/ipa/raspberrypi.h b/include/libcamera/ipa/raspberrypi.h\nindex c9d4aa81..b3041591 100644\n--- a/include/libcamera/ipa/raspberrypi.h\n+++ b/include/libcamera/ipa/raspberrypi.h\n@@ -41,7 +41,7 @@ enum BufferMask {\n };\n \n /* Size of the LS grid allocation. */\n-#define MAX_LS_GRID_SIZE (32 << 10)\n+static constexpr unsigned int MaxLsGridSize = 32 << 10;\n \n /* List of controls handled by the Raspberry Pi IPA */\n static const ControlInfoMap Controls = {\ndiff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp\nindex 0c0dc743..304b0185 100644\n--- a/src/ipa/raspberrypi/raspberrypi.cpp\n+++ b/src/ipa/raspberrypi/raspberrypi.cpp\n@@ -55,8 +55,8 @@\n namespace libcamera {\n \n /* Configure the sensor with these values initially. */\n-#define DEFAULT_ANALOGUE_GAIN 1.0\n-#define DEFAULT_EXPOSURE_TIME 20000\n+constexpr double DefaultAnalogueGain = 1.0;\n+constexpr unsigned int DefaultExposureTime = 20000;\n \n LOG_DEFINE_CATEGORY(IPARPI)\n \n@@ -65,7 +65,7 @@ class IPARPi : public IPAInterface\n public:\n \tIPARPi()\n \t\t: lastMode_({}), controller_(), controllerInit_(false),\n-\t\t  frame_count_(0), check_count_(0), mistrust_count_(0),\n+\t\t  frameCount_(0), checkCount_(0), mistrustCount_(0),\n \t\t  lsTable_(nullptr)\n \t{\n \t}\n@@ -73,7 +73,7 @@ public:\n \t~IPARPi()\n \t{\n \t\tif (lsTable_)\n-\t\t\tmunmap(lsTable_, MAX_LS_GRID_SIZE);\n+\t\t\tmunmap(lsTable_, RPi::MaxLsGridSize);\n \t}\n \n \tint init(const IPASettings &settings) override;\n@@ -108,13 +108,13 @@ private:\n \tvoid applySharpen(const struct SharpenStatus *sharpenStatus, ControlList &ctrls);\n \tvoid applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls);\n \tvoid applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls);\n-\tvoid resampleTable(uint16_t dest[], double const src[12][16], int dest_w, int dest_h);\n+\tvoid resampleTable(uint16_t dest[], double const src[12][16], int destW, int destH);\n \n \tstd::map<unsigned int, FrameBuffer> buffers_;\n \tstd::map<unsigned int, void *> buffersMemory_;\n \n-\tControlInfoMap unicam_ctrls_;\n-\tControlInfoMap isp_ctrls_;\n+\tControlInfoMap unicamCtrls_;\n+\tControlInfoMap ispCtrls_;\n \tControlList libcameraMetadata_;\n \n \t/* IPA configuration. */\n@@ -134,11 +134,14 @@ private:\n \t * We count frames to decide if the frame must be hidden (e.g. from\n \t * display) or mistrusted (i.e. not given to the control algos).\n \t */\n-\tuint64_t frame_count_;\n+\tuint64_t frameCount_;\n+\n \t/* For checking the sequencing of Prepare/Process calls. */\n-\tuint64_t check_count_;\n+\tuint64_t checkCount_;\n+\n \t/* How many frames we should avoid running control algos on. */\n-\tunsigned int mistrust_count_;\n+\tunsigned int mistrustCount_;\n+\n \t/* LS table allocation passed in from the pipeline handler. */\n \tFileDescriptor lsTableHandle_;\n \tvoid *lsTable_;\n@@ -199,8 +202,9 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \n \tresult->operation = 0;\n \n-\tunicam_ctrls_ = entityControls.at(0);\n-\tisp_ctrls_ = entityControls.at(1);\n+\tunicamCtrls_ = entityControls.at(0);\n+\tispCtrls_ = entityControls.at(1);\n+\n \t/* Setup a metadata ControlList to output metadata. */\n \tlibcameraMetadata_ = ControlList(controls::controls);\n \n@@ -212,6 +216,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \tstd::string cameraName(sensorInfo.model);\n \tif (!helper_) {\n \t\thelper_ = std::unique_ptr<RPiController::CamHelper>(RPiController::CamHelper::Create(cameraName));\n+\n \t\t/*\n \t\t * Pass out the sensor config to the pipeline handler in order\n \t\t * to setup the staggered writer class.\n@@ -238,22 +243,22 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \t *\"mistrusted\", which depends on whether this is a startup from cold,\n \t * or merely a mode switch in a running system.\n \t */\n-\tframe_count_ = 0;\n-\tcheck_count_ = 0;\n-\tunsigned int drop_frame = 0;\n+\tframeCount_ = 0;\n+\tcheckCount_ = 0;\n+\tunsigned int dropFrame = 0;\n \tif (controllerInit_) {\n-\t\tdrop_frame = helper_->HideFramesModeSwitch();\n-\t\tmistrust_count_ = helper_->MistrustFramesModeSwitch();\n+\t\tdropFrame = helper_->HideFramesModeSwitch();\n+\t\tmistrustCount_ = helper_->MistrustFramesModeSwitch();\n \t} else {\n-\t\tdrop_frame = helper_->HideFramesStartup();\n-\t\tmistrust_count_ = helper_->MistrustFramesStartup();\n+\t\tdropFrame = helper_->HideFramesStartup();\n+\t\tmistrustCount_ = helper_->MistrustFramesStartup();\n \t}\n \n-\tresult->data.push_back(drop_frame);\n+\tresult->data.push_back(dropFrame);\n \tresult->operation |= RPi::IPA_CONFIG_DROP_FRAMES;\n \n-\tstruct AgcStatus agcStatus;\n \t/* These zero values mean not program anything (unless overwritten). */\n+\tstruct AgcStatus agcStatus;\n \tagcStatus.shutter_time = 0.0;\n \tagcStatus.analogue_gain = 0.0;\n \n@@ -264,8 +269,8 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \t\tcontrollerInit_ = true;\n \n \t\t/* Supply initial values for gain and exposure. */\n-\t\tagcStatus.shutter_time = DEFAULT_EXPOSURE_TIME;\n-\t\tagcStatus.analogue_gain = DEFAULT_ANALOGUE_GAIN;\n+\t\tagcStatus.shutter_time = DefaultExposureTime;\n+\t\tagcStatus.analogue_gain = DefaultAnalogueGain;\n \t}\n \n \tRPiController::Metadata metadata;\n@@ -274,7 +279,7 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \t/* SwitchMode may supply updated exposure/gain values to use. */\n \tmetadata.Get(\"agc.status\", agcStatus);\n \tif (agcStatus.shutter_time != 0.0 && agcStatus.analogue_gain != 0.0) {\n-\t\tControlList ctrls(unicam_ctrls_);\n+\t\tControlList ctrls(unicamCtrls_);\n \t\tapplyAGC(&agcStatus, ctrls);\n \t\tresult->controls.push_back(ctrls);\n \n@@ -287,14 +292,14 @@ void IPARPi::configure(const CameraSensorInfo &sensorInfo,\n \tif (ipaConfig.operation & RPi::IPA_CONFIG_LS_TABLE) {\n \t\t/* Remove any previous table, if there was one. */\n \t\tif (lsTable_) {\n-\t\t\tmunmap(lsTable_, MAX_LS_GRID_SIZE);\n+\t\t\tmunmap(lsTable_, RPi::MaxLsGridSize);\n \t\t\tlsTable_ = nullptr;\n \t\t}\n \n \t\t/* Map the LS table buffer into user space. */\n \t\tlsTableHandle_ = FileDescriptor(ipaConfig.data[0]);\n \t\tif (lsTableHandle_.isValid()) {\n-\t\t\tlsTable_ = mmap(nullptr, MAX_LS_GRID_SIZE, PROT_READ | PROT_WRITE,\n+\t\t\tlsTable_ = mmap(nullptr, RPi::MaxLsGridSize, PROT_READ | PROT_WRITE,\n \t\t\t\t\tMAP_SHARED, lsTableHandle_.fd(), 0);\n \n \t\t\tif (lsTable_ == MAP_FAILED) {\n@@ -343,9 +348,9 @@ void IPARPi::processEvent(const IPAOperationData &event)\n \tcase RPi::IPA_EVENT_SIGNAL_STAT_READY: {\n \t\tunsigned int bufferId = event.data[0];\n \n-\t\tif (++check_count_ != frame_count_) /* assert here? */\n+\t\tif (++checkCount_ != frameCount_) /* assert here? */\n \t\t\tLOG(IPARPI, Error) << \"WARNING: Prepare/Process mismatch!!!\";\n-\t\tif (frame_count_ > mistrust_count_)\n+\t\tif (frameCount_ > mistrustCount_)\n \t\t\tprocessStats(bufferId);\n \n \t\treportMetadata();\n@@ -368,7 +373,7 @@ void IPARPi::processEvent(const IPAOperationData &event)\n \t\t * they are \"unreliable\".\n \t\t */\n \t\tprepareISP(embeddedbufferId);\n-\t\tframe_count_++;\n+\t\tframeCount_++;\n \n \t\t/* Ready to push the input buffer into the ISP. */\n \t\tIPAOperationData op;\n@@ -398,7 +403,6 @@ void IPARPi::reportMetadata()\n \t * processed can be extracted and placed into the libcamera metadata\n \t * buffer, where an application could query it.\n \t */\n-\n \tDeviceStatus *deviceStatus = rpiMetadata_.GetLocked<DeviceStatus>(\"device.status\");\n \tif (deviceStatus) {\n \t\tlibcameraMetadata_.set(controls::ExposureTime, deviceStatus->shutter_speed);\n@@ -453,7 +457,6 @@ void IPARPi::reportMetadata()\n  * we use to identify different modes. Unfortunately, the conversion tables\n  * must be kept up-to-date by hand.\n  */\n-\n static const std::map<int32_t, std::string> MeteringModeTable = {\n \t{ controls::MeteringCentreWeighted, \"centre-weighted\" },\n \t{ controls::MeteringSpot, \"spot\" },\n@@ -511,8 +514,10 @@ void IPARPi::queueRequest(const ControlList &controls)\n \t\t\tRPiController::AgcAlgorithm *agc = dynamic_cast<RPiController::AgcAlgorithm *>(\n \t\t\t\tcontroller_.GetAlgorithm(\"agc\"));\n \t\t\tASSERT(agc);\n+\n \t\t\t/* This expects units of micro-seconds. */\n \t\t\tagc->SetFixedShutter(ctrl.second.get<int32_t>());\n+\n \t\t\t/* For the manual values to take effect, AGC must be unpaused. */\n \t\t\tif (agc->IsPaused())\n \t\t\t\tagc->Resume();\n@@ -526,6 +531,7 @@ void IPARPi::queueRequest(const ControlList &controls)\n \t\t\t\tcontroller_.GetAlgorithm(\"agc\"));\n \t\t\tASSERT(agc);\n \t\t\tagc->SetFixedAnalogueGain(ctrl.second.get<float>());\n+\n \t\t\t/* For the manual values to take effect, AGC must be unpaused. */\n \t\t\tif (agc->IsPaused())\n \t\t\t\tagc->Resume();\n@@ -713,7 +719,7 @@ void IPARPi::prepareISP(unsigned int bufferId)\n \treturnEmbeddedBuffer(bufferId);\n \n \tif (success) {\n-\t\tControlList ctrls(isp_ctrls_);\n+\t\tControlList ctrls(ispCtrls_);\n \n \t\trpiMetadata_.Clear();\n \t\trpiMetadata_.Set(\"device.status\", deviceStatus);\n@@ -785,19 +791,19 @@ bool IPARPi::parseEmbeddedData(unsigned int bufferId, struct DeviceStatus &devic\n \tif (status != RPiController::MdParser::Status::OK) {\n \t\tLOG(IPARPI, Error) << \"Embedded Buffer parsing failed, error \" << status;\n \t} else {\n-\t\tuint32_t exposure_lines, gain_code;\n-\t\tif (helper_->Parser().GetExposureLines(exposure_lines) != RPiController::MdParser::Status::OK) {\n+\t\tuint32_t exposureLines, gainCode;\n+\t\tif (helper_->Parser().GetExposureLines(exposureLines) != RPiController::MdParser::Status::OK) {\n \t\t\tLOG(IPARPI, Error) << \"Exposure time failed\";\n \t\t\treturn false;\n \t\t}\n \n-\t\tdeviceStatus.shutter_speed = helper_->Exposure(exposure_lines);\n-\t\tif (helper_->Parser().GetGainCode(gain_code) != RPiController::MdParser::Status::OK) {\n+\t\tdeviceStatus.shutter_speed = helper_->Exposure(exposureLines);\n+\t\tif (helper_->Parser().GetGainCode(gainCode) != RPiController::MdParser::Status::OK) {\n \t\t\tLOG(IPARPI, Error) << \"Gain failed\";\n \t\t\treturn false;\n \t\t}\n \n-\t\tdeviceStatus.analogue_gain = helper_->Gain(gain_code);\n+\t\tdeviceStatus.analogue_gain = helper_->Gain(gainCode);\n \t\tLOG(IPARPI, Debug) << \"Metadata - Exposure : \"\n \t\t\t\t   << deviceStatus.shutter_speed << \" Gain : \"\n \t\t\t\t   << deviceStatus.analogue_gain;\n@@ -820,7 +826,7 @@ void IPARPi::processStats(unsigned int bufferId)\n \n \tstruct AgcStatus agcStatus;\n \tif (rpiMetadata_.Get(\"agc.status\", agcStatus) == 0) {\n-\t\tControlList ctrls(unicam_ctrls_);\n+\t\tControlList ctrls(unicamCtrls_);\n \t\tapplyAGC(&agcStatus, ctrls);\n \n \t\tIPAOperationData op;\n@@ -832,14 +838,14 @@ void IPARPi::processStats(unsigned int bufferId)\n \n void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls)\n {\n-\tconst auto gainR = isp_ctrls_.find(V4L2_CID_RED_BALANCE);\n-\tif (gainR == isp_ctrls_.end()) {\n+\tconst auto gainR = ispCtrls_.find(V4L2_CID_RED_BALANCE);\n+\tif (gainR == ispCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find red gain control\";\n \t\treturn;\n \t}\n \n-\tconst auto gainB = isp_ctrls_.find(V4L2_CID_BLUE_BALANCE);\n-\tif (gainB == isp_ctrls_.end()) {\n+\tconst auto gainB = ispCtrls_.find(V4L2_CID_BLUE_BALANCE);\n+\tif (gainB == ispCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find blue gain control\";\n \t\treturn;\n \t}\n@@ -855,31 +861,31 @@ void IPARPi::applyAWB(const struct AwbStatus *awbStatus, ControlList &ctrls)\n \n void IPARPi::applyAGC(const struct AgcStatus *agcStatus, ControlList &ctrls)\n {\n-\tint32_t gain_code = helper_->GainCode(agcStatus->analogue_gain);\n-\tint32_t exposure_lines = helper_->ExposureLines(agcStatus->shutter_time);\n+\tint32_t gainCode = helper_->GainCode(agcStatus->analogue_gain);\n+\tint32_t exposureLines = helper_->ExposureLines(agcStatus->shutter_time);\n \n-\tif (unicam_ctrls_.find(V4L2_CID_ANALOGUE_GAIN) == unicam_ctrls_.end()) {\n+\tif (unicamCtrls_.find(V4L2_CID_ANALOGUE_GAIN) == unicamCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find analogue gain control\";\n \t\treturn;\n \t}\n \n-\tif (unicam_ctrls_.find(V4L2_CID_EXPOSURE) == unicam_ctrls_.end()) {\n+\tif (unicamCtrls_.find(V4L2_CID_EXPOSURE) == unicamCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find exposure control\";\n \t\treturn;\n \t}\n \n \tLOG(IPARPI, Debug) << \"Applying AGC Exposure: \" << agcStatus->shutter_time\n-\t\t\t   << \" (Shutter lines: \" << exposure_lines << \") Gain: \"\n+\t\t\t   << \" (Shutter lines: \" << exposureLines << \") Gain: \"\n \t\t\t   << agcStatus->analogue_gain << \" (Gain Code: \"\n-\t\t\t   << gain_code << \")\";\n+\t\t\t   << gainCode << \")\";\n \n-\tctrls.set(V4L2_CID_ANALOGUE_GAIN, gain_code);\n-\tctrls.set(V4L2_CID_EXPOSURE, exposure_lines);\n+\tctrls.set(V4L2_CID_ANALOGUE_GAIN, gainCode);\n+\tctrls.set(V4L2_CID_EXPOSURE, exposureLines);\n }\n \n void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls)\n {\n-\tif (isp_ctrls_.find(V4L2_CID_DIGITAL_GAIN) == isp_ctrls_.end()) {\n+\tif (ispCtrls_.find(V4L2_CID_DIGITAL_GAIN) == ispCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find digital gain control\";\n \t\treturn;\n \t}\n@@ -890,7 +896,7 @@ void IPARPi::applyDG(const struct AgcStatus *dgStatus, ControlList &ctrls)\n \n void IPARPi::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls)\n {\n-\tif (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_CC_MATRIX) == isp_ctrls_.end()) {\n+\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_CC_MATRIX) == ispCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find CCM control\";\n \t\treturn;\n \t}\n@@ -911,7 +917,7 @@ void IPARPi::applyCCM(const struct CcmStatus *ccmStatus, ControlList &ctrls)\n \n void IPARPi::applyGamma(const struct ContrastStatus *contrastStatus, ControlList &ctrls)\n {\n-\tif (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_GAMMA) == isp_ctrls_.end()) {\n+\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_GAMMA) == ispCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find Gamma control\";\n \t\treturn;\n \t}\n@@ -930,7 +936,7 @@ void IPARPi::applyGamma(const struct ContrastStatus *contrastStatus, ControlList\n \n void IPARPi::applyBlackLevel(const struct BlackLevelStatus *blackLevelStatus, ControlList &ctrls)\n {\n-\tif (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL) == isp_ctrls_.end()) {\n+\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_BLACK_LEVEL) == ispCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find black level control\";\n \t\treturn;\n \t}\n@@ -948,7 +954,7 @@ void IPARPi::applyBlackLevel(const struct BlackLevelStatus *blackLevelStatus, Co\n \n void IPARPi::applyGEQ(const struct GeqStatus *geqStatus, ControlList &ctrls)\n {\n-\tif (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_GEQ) == isp_ctrls_.end()) {\n+\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_GEQ) == ispCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find geq control\";\n \t\treturn;\n \t}\n@@ -966,7 +972,7 @@ void IPARPi::applyGEQ(const struct GeqStatus *geqStatus, ControlList &ctrls)\n \n void IPARPi::applyDenoise(const struct SdnStatus *denoiseStatus, ControlList &ctrls)\n {\n-\tif (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_DENOISE) == isp_ctrls_.end()) {\n+\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_DENOISE) == ispCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find denoise control\";\n \t\treturn;\n \t}\n@@ -986,7 +992,7 @@ void IPARPi::applyDenoise(const struct SdnStatus *denoiseStatus, ControlList &ct\n \n void IPARPi::applySharpen(const struct SharpenStatus *sharpenStatus, ControlList &ctrls)\n {\n-\tif (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_SHARPEN) == isp_ctrls_.end()) {\n+\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_SHARPEN) == ispCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find sharpen control\";\n \t\treturn;\n \t}\n@@ -1007,7 +1013,7 @@ void IPARPi::applySharpen(const struct SharpenStatus *sharpenStatus, ControlList\n \n void IPARPi::applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls)\n {\n-\tif (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_DPC) == isp_ctrls_.end()) {\n+\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_DPC) == ispCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find DPC control\";\n \t\treturn;\n \t}\n@@ -1023,7 +1029,7 @@ void IPARPi::applyDPC(const struct DpcStatus *dpcStatus, ControlList &ctrls)\n \n void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls)\n {\n-\tif (isp_ctrls_.find(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING) == isp_ctrls_.end()) {\n+\tif (ispCtrls_.find(V4L2_CID_USER_BCM2835_ISP_LENS_SHADING) == ispCtrls_.end()) {\n \t\tLOG(IPARPI, Error) << \"Can't find LS control\";\n \t\treturn;\n \t}\n@@ -1032,18 +1038,18 @@ void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls)\n \t * Program lens shading tables into pipeline.\n \t * Choose smallest cell size that won't exceed 63x48 cells.\n \t */\n-\tconst int cell_sizes[] = { 16, 32, 64, 128, 256 };\n-\tunsigned int num_cells = ARRAY_SIZE(cell_sizes);\n-\tunsigned int i, w, h, cell_size;\n-\tfor (i = 0; i < num_cells; i++) {\n-\t\tcell_size = cell_sizes[i];\n-\t\tw = (mode_.width + cell_size - 1) / cell_size;\n-\t\th = (mode_.height + cell_size - 1) / cell_size;\n+\tconst int cellSizes[] = { 16, 32, 64, 128, 256 };\n+\tunsigned int numCells = ARRAY_SIZE(cellSizes);\n+\tunsigned int i, w, h, cellSize;\n+\tfor (i = 0; i < numCells; i++) {\n+\t\tcellSize = cellSizes[i];\n+\t\tw = (mode_.width + cellSize - 1) / cellSize;\n+\t\th = (mode_.height + cellSize - 1) / cellSize;\n \t\tif (w < 64 && h <= 48)\n \t\t\tbreak;\n \t}\n \n-\tif (i == num_cells) {\n+\tif (i == numCells) {\n \t\tLOG(IPARPI, Error) << \"Cannot find cell size\";\n \t\treturn;\n \t}\n@@ -1052,7 +1058,7 @@ void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls)\n \tw++, h++;\n \tbcm2835_isp_lens_shading ls = {\n \t\t.enabled = 1,\n-\t\t.grid_cell_size = cell_size,\n+\t\t.grid_cell_size = cellSize,\n \t\t.grid_width = w,\n \t\t.grid_stride = w,\n \t\t.grid_height = h,\n@@ -1062,7 +1068,7 @@ void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls)\n \t\t.gain_format = GAIN_FORMAT_U4P10\n \t};\n \n-\tif (!lsTable_ || w * h * 4 * sizeof(uint16_t) > MAX_LS_GRID_SIZE) {\n+\tif (!lsTable_ || w * h * 4 * sizeof(uint16_t) > RPi::MaxLsGridSize) {\n \t\tLOG(IPARPI, Error) << \"Do not have a correctly allocate lens shading table!\";\n \t\treturn;\n \t}\n@@ -1083,41 +1089,41 @@ void IPARPi::applyLS(const struct AlscStatus *lsStatus, ControlList &ctrls)\n }\n \n /*\n- * Resamples a 16x12 table with central sampling to dest_w x dest_h with corner\n+ * Resamples a 16x12 table with central sampling to destW x destH with corner\n  * sampling.\n  */\n void IPARPi::resampleTable(uint16_t dest[], double const src[12][16],\n-\t\t\t   int dest_w, int dest_h)\n+\t\t\t   int destW, int destH)\n {\n \t/*\n \t * Precalculate and cache the x sampling locations and phases to\n \t * save recomputing them on every row.\n \t */\n-\tassert(dest_w > 1 && dest_h > 1 && dest_w <= 64);\n-\tint x_lo[64], x_hi[64];\n+\tassert(destW > 1 && destH > 1 && destW <= 64);\n+\tint xLo[64], xHi[64];\n \tdouble xf[64];\n-\tdouble x = -0.5, x_inc = 16.0 / (dest_w - 1);\n-\tfor (int i = 0; i < dest_w; i++, x += x_inc) {\n-\t\tx_lo[i] = floor(x);\n-\t\txf[i] = x - x_lo[i];\n-\t\tx_hi[i] = x_lo[i] < 15 ? x_lo[i] + 1 : 15;\n-\t\tx_lo[i] = x_lo[i] > 0 ? x_lo[i] : 0;\n+\tdouble x = -0.5, xInc = 16.0 / (destW - 1);\n+\tfor (int i = 0; i < destW; i++, x += xInc) {\n+\t\txLo[i] = floor(x);\n+\t\txf[i] = x - xLo[i];\n+\t\txHi[i] = xLo[i] < 15 ? xLo[i] + 1 : 15;\n+\t\txLo[i] = xLo[i] > 0 ? xLo[i] : 0;\n \t}\n \n \t/* Now march over the output table generating the new values. */\n-\tdouble y = -0.5, y_inc = 12.0 / (dest_h - 1);\n-\tfor (int j = 0; j < dest_h; j++, y += y_inc) {\n-\t\tint y_lo = floor(y);\n-\t\tdouble yf = y - y_lo;\n-\t\tint y_hi = y_lo < 11 ? y_lo + 1 : 11;\n-\t\ty_lo = y_lo > 0 ? y_lo : 0;\n-\t\tdouble const *row_above = src[y_lo];\n-\t\tdouble const *row_below = src[y_hi];\n-\t\tfor (int i = 0; i < dest_w; i++) {\n-\t\t\tdouble above = row_above[x_lo[i]] * (1 - xf[i])\n-\t\t\t\t     + row_above[x_hi[i]] * xf[i];\n-\t\t\tdouble below = row_below[x_lo[i]] * (1 - xf[i])\n-\t\t\t\t     + row_below[x_hi[i]] * xf[i];\n+\tdouble y = -0.5, yInc = 12.0 / (destH - 1);\n+\tfor (int j = 0; j < destH; j++, y += yInc) {\n+\t\tint yLo = floor(y);\n+\t\tdouble yf = y - yLo;\n+\t\tint yHi = yLo < 11 ? yLo + 1 : 11;\n+\t\tyLo = yLo > 0 ? yLo : 0;\n+\t\tdouble const *rowAbove = src[yLo];\n+\t\tdouble const *rowBelow = src[yHi];\n+\t\tfor (int i = 0; i < destW; i++) {\n+\t\t\tdouble above = rowAbove[xLo[i]] * (1 - xf[i])\n+\t\t\t\t     + rowAbove[xHi[i]] * xf[i];\n+\t\t\tdouble below = rowBelow[xLo[i]] * (1 - xf[i])\n+\t\t\t\t     + rowBelow[xHi[i]] * xf[i];\n \t\t\tint result = floor(1024 * (above * (1 - yf) + below * yf) + .5);\n \t\t\t*(dest++) = result > 16383 ? 16383 : result; /* want u4.10 */\n \t\t}\n@@ -1127,7 +1133,6 @@ void IPARPi::resampleTable(uint16_t dest[], double const src[12][16],\n /*\n  * External IPA module interface\n  */\n-\n extern \"C\" {\n const struct IPAModuleInfo ipaModuleInfo = {\n \tIPA_MODULE_API_VERSION,\ndiff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\nindex 35dbe0fb..8d40b0ed 100644\n--- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n+++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp\n@@ -1012,7 +1012,7 @@ int RPiCameraData::configureIPA()\n \n \t/* Allocate the lens shading table via dmaHeap and pass to the IPA. */\n \tif (!lsTable_.isValid()) {\n-\t\tlsTable_ = dmaHeap_.alloc(\"ls_grid\", MAX_LS_GRID_SIZE);\n+\t\tlsTable_ = dmaHeap_.alloc(\"ls_grid\", RPi::MaxLsGridSize);\n \t\tif (!lsTable_.isValid())\n \t\t\treturn -ENOMEM;\n \n","prefixes":["libcamera-devel","4/4"]}