{"id":11131,"url":"https://patchwork.libcamera.org/api/1.1/patches/11131/?format=json","web_url":"https://patchwork.libcamera.org/patch/11131/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20210204093457.6879-2-david.plowman@raspberrypi.com>","date":"2021-02-04T09:34:51","name":"[libcamera-devel,1/7] ipa: raspberrypi: AWB: Remove unnecessary locking for AWB settings","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"eb4b7307711f48dcc0bb60474e23697c4c32e7d8","submitter":{"id":42,"url":"https://patchwork.libcamera.org/api/1.1/people/42/?format=json","name":"David Plowman","email":"david.plowman@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11131/mbox/","series":[{"id":1649,"url":"https://patchwork.libcamera.org/api/1.1/series/1649/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1649","date":"2021-02-04T09:34:50","name":"Raspberry Pi IPA maintenance","version":1,"mbox":"https://patchwork.libcamera.org/series/1649/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11131/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11131/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 EEB19BD162\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  4 Feb 2021 09:35:05 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3CD0861402;\n\tThu,  4 Feb 2021 10:35:04 +0100 (CET)","from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com\n\t[IPv6:2a00:1450:4864:20::32e])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 84ED760107\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  4 Feb 2021 10:35:02 +0100 (CET)","by mail-wm1-x32e.google.com with SMTP id f16so2475453wmq.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 04 Feb 2021 01:35:02 -0800 (PST)","from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\tg16sm5280580wmi.30.2021.02.04.01.35.01\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 04 Feb 2021 01:35:01 -0800 (PST)"],"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=\"e6cAFuvy\"; 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=I7i7fBZpiVuIH5sFk+yyLknlBa9tcpZHROKD240TfvU=;\n\tb=e6cAFuvyHAK0LRHwNPMYqkiK3o6Shr8/6/j/1Go/bMTy0upWIcC3WsCSGEH63BBRhk\n\tyidwGnaSpqRS5+fBLwVxxLQtW/vFJmKZlq+w2rGVmLR0RxfanrOrgbNblEIDFZ1V/xgx\n\te7GU0d+Ohp5PH0ESzADZ6hrwnLPaxDekMjabfK2IddzmJIuujHBePkzWFLyPB/VydX51\n\tpPOf0R+lvMcc3nEdjc6kD/QsxsYanRiu04Ty2WJhbNVLUaFGwlgb3WrS4dDSjZQkUvUS\n\tQS3RQDjWFoD8novVtCKgkf13M/Vs+Zm/b3QsFAuMFSZbnetZcC3g3nvOk5HwZEYQnEry\n\thG3A==","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=I7i7fBZpiVuIH5sFk+yyLknlBa9tcpZHROKD240TfvU=;\n\tb=t4aSm8g9kYo/NcgXb6F9HgwEtCXRFIOgrynBoa//YMFUkKhT9/Pej7Atth6fiu5/jR\n\tl/kIe+NiTGqr4TvwqccLlBgRhkEfivBIotyCDmP5H/nvKA29dsxoyBk/RKdR5gTUuID7\n\tIk9JgHqS4uvgDCkWZJ8Zqs5sCf+7XfAu501h8DOCLX5igle3gDbzdfW/bGtPubSGeEM7\n\toLVB6s9cErBR3yINiyGwp5qsOlbqhOQ4elWqzZ4FtTbnz+qNJotUZ7L5Nuo3pLPsnkcn\n\tEWRU6v9cPInYzae10X0EbxtQKOItLOiB/Wzp3RhMyqhXGyMGaV2nhc2abj18HOSdC+8y\n\tPiGA==","X-Gm-Message-State":"AOAM5315Brzq0I14riaGaKd7clh/z9P8s5KpqFLLwGSs9DvbrRbccV4q\n\t+CEVrejLD0i62rTMxt9F2Smo340tNADlxWrT","X-Google-Smtp-Source":"ABdhPJzM2fvNWcUF2McMbZO8DufnLBkRT1tAp3qNJpA+ApqaZ9354WuQjZ8dLfAcjCejUZWJumw9qw==","X-Received":"by 2002:a1c:2501:: with SMTP id l1mr6541055wml.41.1612431301911; \n\tThu, 04 Feb 2021 01:35:01 -0800 (PST)","From":"David Plowman <david.plowman@raspberrypi.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu,  4 Feb 2021 09:34:51 +0000","Message-Id":"<20210204093457.6879-2-david.plowman@raspberrypi.com>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20210204093457.6879-1-david.plowman@raspberrypi.com>","References":"<20210204093457.6879-1-david.plowman@raspberrypi.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH 1/7] ipa: raspberrypi: AWB: Remove\n\tunnecessary locking for AWB settings","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":"AWB settings get updated synchronously with the main thread, so the\nsettings_mutex_ and associated locking can be removed.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/rpi/awb.cpp | 18 +++++-------------\n src/ipa/raspberrypi/controller/rpi/awb.hpp |  4 +---\n 2 files changed, 6 insertions(+), 16 deletions(-)","diff":"diff --git a/src/ipa/raspberrypi/controller/rpi/awb.cpp b/src/ipa/raspberrypi/controller/rpi/awb.cpp\nindex 62337b13..dabab726 100644\n--- a/src/ipa/raspberrypi/controller/rpi/awb.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/awb.cpp\n@@ -185,13 +185,11 @@ unsigned int Awb::GetConvergenceFrames() const\n \n void Awb::SetMode(std::string const &mode_name)\n {\n-\tstd::unique_lock<std::mutex> lock(settings_mutex_);\n \tmode_name_ = mode_name;\n }\n \n void Awb::SetManualGains(double manual_r, double manual_b)\n {\n-\tstd::unique_lock<std::mutex> lock(settings_mutex_);\n \t// If any of these are 0.0, we swich back to auto.\n \tmanual_r_ = manual_r;\n \tmanual_b_ = manual_b;\n@@ -229,14 +227,13 @@ void Awb::fetchAsyncResults()\n \tsync_results_ = async_results_;\n }\n \n-void Awb::restartAsync(StatisticsPtr &stats, std::string const &mode_name,\n-\t\t       double lux)\n+void Awb::restartAsync(StatisticsPtr &stats, double lux)\n {\n \tLOG(RPiAwb, Debug) << \"Starting AWB calculation\";\n \t// this makes a new reference which belongs to the asynchronous thread\n \tstatistics_ = stats;\n \t// store the mode as it could technically change\n-\tauto m = config_.modes.find(mode_name);\n+\tauto m = config_.modes.find(mode_name_);\n \tmode_ = m != config_.modes.end()\n \t\t\t? &m->second\n \t\t\t: (mode_ == nullptr ? config_.default_mode : mode_);\n@@ -244,8 +241,8 @@ void Awb::restartAsync(StatisticsPtr &stats, std::string const &mode_name,\n \tframe_phase_ = 0;\n \tasync_start_ = true;\n \tasync_started_ = true;\n-\tsize_t len = mode_name.copy(async_results_.mode,\n-\t\t\t\t    sizeof(async_results_.mode) - 1);\n+\tsize_t len = mode_name_.copy(async_results_.mode,\n+\t\t\t\t     sizeof(async_results_.mode) - 1);\n \tasync_results_.mode[len] = '\\0';\n \tasync_signal_.notify_one();\n }\n@@ -294,11 +291,6 @@ void Awb::Process(StatisticsPtr &stats, Metadata *image_metadata)\n \tif (frame_phase_ >= (int)config_.frame_period ||\n \t    frame_count2_ < (int)config_.startup_frames) {\n \t\t// Update any settings and any image metadata that we need.\n-\t\tstd::string mode_name;\n-\t\t{\n-\t\t\tstd::unique_lock<std::mutex> lock(settings_mutex_);\n-\t\t\tmode_name = mode_name_;\n-\t\t}\n \t\tstruct LuxStatus lux_status = {};\n \t\tlux_status.lux = 400; // in case no metadata\n \t\tif (image_metadata->Get(\"lux.status\", lux_status) != 0)\n@@ -307,7 +299,7 @@ void Awb::Process(StatisticsPtr &stats, Metadata *image_metadata)\n \n \t\tstd::unique_lock<std::mutex> lock(mutex_);\n \t\tif (async_started_ == false)\n-\t\t\trestartAsync(stats, mode_name, lux_status.lux);\n+\t\t\trestartAsync(stats, lux_status.lux);\n \t}\n }\n \ndiff --git a/src/ipa/raspberrypi/controller/rpi/awb.hpp b/src/ipa/raspberrypi/controller/rpi/awb.hpp\nindex 83b81498..1b39ab4b 100644\n--- a/src/ipa/raspberrypi/controller/rpi/awb.hpp\n+++ b/src/ipa/raspberrypi/controller/rpi/awb.hpp\n@@ -134,11 +134,9 @@ private:\n \tAwbStatus sync_results_;\n \tAwbStatus prev_sync_results_;\n \tstd::string mode_name_;\n-\tstd::mutex settings_mutex_;\n \t// The following are for the asynchronous thread to use, though the main\n \t// thread can set/reset them if the async thread is known to be idle:\n-\tvoid restartAsync(StatisticsPtr &stats, std::string const &mode_name,\n-\t\t\t  double lux);\n+\tvoid restartAsync(StatisticsPtr &stats, double lux);\n \t// copy out the results from the async thread so that it can be restarted\n \tvoid fetchAsyncResults();\n \tStatisticsPtr statistics_;\n","prefixes":["libcamera-devel","1/7"]}