Show a patch.

GET /api/1.1/patches/10461/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 10461,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/10461/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/10461/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api",
        "name": "libcamera",
        "link_name": "libcamera",
        "list_id": "libcamera_core",
        "list_email": "libcamera-devel@lists.libcamera.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": ""
    },
    "msgid": "<20201123073804.3125-3-david.plowman@raspberrypi.com>",
    "date": "2020-11-23T07:37:56",
    "name": "[libcamera-devel,v2,02/10] libcamera: ipa: raspberrypi: agc: Remove unnecessary locking",
    "commit_ref": "42f4e313afb592b28ff1506dfe6edd3afcb1f49b",
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "7c2d5d86a935f9142954fade4e0287179a3c9eff",
    "submitter": {
        "id": 42,
        "url": "https://patchwork.libcamera.org/api/1.1/people/42/?format=api",
        "name": "David Plowman",
        "email": "david.plowman@raspberrypi.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/10461/mbox/",
    "series": [
        {
            "id": 1475,
            "url": "https://patchwork.libcamera.org/api/1.1/series/1475/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1475",
            "date": "2020-11-23T07:37:54",
            "name": "Raspberry Pi AGC",
            "version": 2,
            "mbox": "https://patchwork.libcamera.org/series/1475/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/10461/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/10461/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 CB33ABE08A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Nov 2020 07:38:34 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3D26F63344;\n\tMon, 23 Nov 2020 08:38:34 +0100 (CET)",
            "from mail-wr1-x436.google.com (mail-wr1-x436.google.com\n\t[IPv6:2a00:1450:4864:20::436])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 55B5760332\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 23 Nov 2020 08:38:32 +0100 (CET)",
            "by mail-wr1-x436.google.com with SMTP id b6so17594950wrt.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 22 Nov 2020 23:38:32 -0800 (PST)",
            "from pi4-davidp.lan (plowpeople3.plus.com. [80.229.223.72])\n\tby smtp.gmail.com with ESMTPSA id\n\th15sm17841822wrw.15.2020.11.22.23.38.30\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tSun, 22 Nov 2020 23:38:31 -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=\"iXiHAFTC\"; 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=ZHnJxWPMbxEB7oCKged3AtYHg1uDAslixQCdBCXVkrU=;\n\tb=iXiHAFTCy8uEyPgsrLqsVMEcoB4tF5aNhQREWnXrJFdxV+LbkyT8kmJGUBJJaAQhwy\n\tVuiMaetnmTlHfPfBx0kRg/CYGA7A4W8XIn+S/7RkXgmigQH1AAUMjWuWyZ1xRigS47q5\n\thbqLH3hSYbDcdM9cEHChv2o3l1LyMhpBhlYMjYjhXui4ScFF8czqPIKErqMaMcVoB5ZP\n\tH2K3SVGvZh/pBtP0L8FJyyt2hoMQI/JuafoA1xjA0i/v8q9Y5p6bjlXVHk2bpzq0jMZH\n\tPru7ySUeT9ykHAGJHRqfKcgCEH5kGbldA/DUa7aydGgl8rNB5eYt/sSgXmM/7NuskHsZ\n\tiiEQ==",
        "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=ZHnJxWPMbxEB7oCKged3AtYHg1uDAslixQCdBCXVkrU=;\n\tb=Ry98rNv1wpxYXHiZXuQf2k9Ha7KD1WjCVAxfYcXs41IsIpXDOr8qSHYnAKJh+DY/gG\n\tjFKP4g5KHBgm5JGxxK44mGWa9L3DXp+zwX4TD2mdk/MeDiObD7G5UnKEMCUSIZEi0GXv\n\tBF2KJqqPDappuRLOjHbAvuazB8P3nLffnsjUDv3fmZtqgpWZ3Uwc4GeZ9SRh1TIbsxvP\n\t+Rrlq1RU+JYc4NLUZ3jdunR34RkiRIC/m8SCyKVKL+/4JnpXrYzYf/XOu2I+sx7GSkgD\n\tCIvlzKeCJiYDoY4wJZj9WzTY4lL2Y5JJiTfDCKkgUkKmPsN8uIlCBEV9e7KfdEzu5t0i\n\t25/A==",
        "X-Gm-Message-State": "AOAM533N/TULYAzoADg3SyQHR7ovxL5CkndUmF9GMHUJn/EJ+TG2AXPh\n\t1ntGD4NEy3cOc1z9tHZv9UcMS2474WHo8dmf",
        "X-Google-Smtp-Source": "ABdhPJzAUFAkk4ZqE+eza0Iz6gx3shiBrAzh/r/GR7FLS2HvvF7uf+U4FPUFSydfJzeSJlFt2lObXw==",
        "X-Received": "by 2002:a05:6000:108:: with SMTP id\n\to8mr28194536wrx.337.1606117111649; \n\tSun, 22 Nov 2020 23:38:31 -0800 (PST)",
        "From": "David Plowman <david.plowman@raspberrypi.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Mon, 23 Nov 2020 07:37:56 +0000",
        "Message-Id": "<20201123073804.3125-3-david.plowman@raspberrypi.com>",
        "X-Mailer": "git-send-email 2.20.1",
        "In-Reply-To": "<20201123073804.3125-1-david.plowman@raspberrypi.com>",
        "References": "<20201123073804.3125-1-david.plowman@raspberrypi.com>",
        "MIME-Version": "1.0",
        "Subject": "[libcamera-devel] [PATCH v2 02/10] libcamera: ipa: raspberrypi:\n\tagc: Remove unnecessary locking",
        "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": "On the libcamera/VC4 platform the AGC Prepare/Process methods, and any\nchanges to the AGC settings, run synchronously - so a number of\nmutexes and copies are unnecessary and can be removed.\n\nSigned-off-by: David Plowman <david.plowman@raspberrypi.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\n---\n src/ipa/raspberrypi/controller/rpi/agc.cpp | 98 ++++++++--------------\n src/ipa/raspberrypi/controller/rpi/agc.hpp |  5 +-\n 2 files changed, 36 insertions(+), 67 deletions(-)",
    "diff": "diff --git a/src/ipa/raspberrypi/controller/rpi/agc.cpp b/src/ipa/raspberrypi/controller/rpi/agc.cpp\nindex 8079345b..0a67f456 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.cpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.cpp\n@@ -160,7 +160,6 @@ Agc::Agc(Controller *controller)\n \tstatus_.total_exposure_value = 0.0;\n \tstatus_.target_exposure_value = 0.0;\n \tstatus_.locked = false;\n-\toutput_status_ = status_;\n }\n \n char const *Agc::Name() const\n@@ -185,43 +184,36 @@ void Agc::Read(boost::property_tree::ptree const &params)\n \n void Agc::SetEv(double ev)\n {\n-\tstd::unique_lock<std::mutex> lock(settings_mutex_);\n \tev_ = ev;\n }\n \n void Agc::SetFlickerPeriod(double flicker_period)\n {\n-\tstd::unique_lock<std::mutex> lock(settings_mutex_);\n \tflicker_period_ = flicker_period;\n }\n \n void Agc::SetFixedShutter(double fixed_shutter)\n {\n-\tstd::unique_lock<std::mutex> lock(settings_mutex_);\n \tfixed_shutter_ = fixed_shutter;\n }\n \n void Agc::SetFixedAnalogueGain(double fixed_analogue_gain)\n {\n-\tstd::unique_lock<std::mutex> lock(settings_mutex_);\n \tfixed_analogue_gain_ = fixed_analogue_gain;\n }\n \n void Agc::SetMeteringMode(std::string const &metering_mode_name)\n {\n-\tstd::unique_lock<std::mutex> lock(settings_mutex_);\n \tmetering_mode_name_ = metering_mode_name;\n }\n \n void Agc::SetExposureMode(std::string const &exposure_mode_name)\n {\n-\tstd::unique_lock<std::mutex> lock(settings_mutex_);\n \texposure_mode_name_ = exposure_mode_name;\n }\n \n void Agc::SetConstraintMode(std::string const &constraint_mode_name)\n {\n-\tstd::unique_lock<std::mutex> lock(settings_mutex_);\n \tconstraint_mode_name_ = constraint_mode_name;\n }\n \n@@ -240,14 +232,9 @@ void Agc::SwitchMode([[maybe_unused]] CameraMode const &camera_mode,\n \n void Agc::Prepare(Metadata *image_metadata)\n {\n-\tAgcStatus status;\n-\t{\n-\t\tstd::unique_lock<std::mutex> lock(output_mutex_);\n-\t\tstatus = output_status_;\n-\t}\n \tint lock_count = lock_count_;\n \tlock_count_ = 0;\n-\tstatus.digital_gain = 1.0;\n+\tstatus_.digital_gain = 1.0;\n \tif (status_.total_exposure_value) {\n \t\t// Process has run, so we have meaningful values.\n \t\tDeviceStatus device_status;\n@@ -255,48 +242,45 @@ void Agc::Prepare(Metadata *image_metadata)\n \t\t\tdouble actual_exposure = device_status.shutter_speed *\n \t\t\t\t\t\t device_status.analogue_gain;\n \t\t\tif (actual_exposure) {\n-\t\t\t\tstatus.digital_gain =\n+\t\t\t\tstatus_.digital_gain =\n \t\t\t\t\tstatus_.total_exposure_value /\n \t\t\t\t\tactual_exposure;\n \t\t\t\tLOG(RPiAgc, Debug) << \"Want total exposure \" << status_.total_exposure_value;\n \t\t\t\t// Never ask for a gain < 1.0, and also impose\n \t\t\t\t// some upper limit. Make it customisable?\n-\t\t\t\tstatus.digital_gain = std::max(\n+\t\t\t\tstatus_.digital_gain = std::max(\n \t\t\t\t\t1.0,\n-\t\t\t\t\tstd::min(status.digital_gain, 4.0));\n+\t\t\t\t\tstd::min(status_.digital_gain, 4.0));\n \t\t\t\tLOG(RPiAgc, Debug) << \"Actual exposure \" << actual_exposure;\n-\t\t\t\tLOG(RPiAgc, Debug) << \"Use digital_gain \" << status.digital_gain;\n-\t\t\t\tLOG(RPiAgc, Debug) << \"Effective exposure \" << actual_exposure * status.digital_gain;\n+\t\t\t\tLOG(RPiAgc, Debug) << \"Use digital_gain \" << status_.digital_gain;\n+\t\t\t\tLOG(RPiAgc, Debug) << \"Effective exposure \" << actual_exposure * status_.digital_gain;\n \t\t\t\t// Decide whether AEC/AGC has converged.\n \t\t\t\t// Insist AGC is steady for MAX_LOCK_COUNT\n \t\t\t\t// frames before we say we are \"locked\".\n \t\t\t\t// (The hard-coded constants may need to\n \t\t\t\t// become customisable.)\n-\t\t\t\tif (status.target_exposure_value) {\n+\t\t\t\tif (status_.target_exposure_value) {\n #define MAX_LOCK_COUNT 3\n-\t\t\t\t\tdouble err = 0.10 * status.target_exposure_value + 200;\n+\t\t\t\t\tdouble err = 0.10 * status_.target_exposure_value + 200;\n \t\t\t\t\tif (actual_exposure <\n-\t\t\t\t\t    status.target_exposure_value + err\n-\t\t\t\t\t    && actual_exposure >\n-\t\t\t\t\t    status.target_exposure_value - err)\n+\t\t\t\t\t\t    status_.target_exposure_value + err &&\n+\t\t\t\t\t    actual_exposure >\n+\t\t\t\t\t\t    status_.target_exposure_value - err)\n \t\t\t\t\t\tlock_count_ =\n \t\t\t\t\t\t\tstd::min(lock_count + 1,\n-\t\t\t\t\t\t\t       MAX_LOCK_COUNT);\n+\t\t\t\t\t\t\t\t MAX_LOCK_COUNT);\n \t\t\t\t\telse if (actual_exposure <\n-\t\t\t\t\t\t status.target_exposure_value\n-\t\t\t\t\t\t + 1.5 * err &&\n+\t\t\t\t\t\t\t status_.target_exposure_value + 1.5 * err &&\n \t\t\t\t\t\t actual_exposure >\n-\t\t\t\t\t\t status.target_exposure_value\n-\t\t\t\t\t\t - 1.5 * err)\n+\t\t\t\t\t\t\t status_.target_exposure_value - 1.5 * err)\n \t\t\t\t\t\tlock_count_ = lock_count;\n \t\t\t\t\tLOG(RPiAgc, Debug) << \"Lock count: \" << lock_count_;\n \t\t\t\t}\n \t\t\t}\n \t\t} else\n \t\t\tLOG(RPiAgc, Debug) << Name() << \": no device metadata\";\n-\t\tstatus.locked = lock_count_ >= MAX_LOCK_COUNT;\n-\t\t//printf(\"%s\\n\", status.locked ? \"+++++++++\" : \"-\");\n-\t\timage_metadata->Set(\"agc.status\", status);\n+\t\tstatus_.locked = lock_count_ >= MAX_LOCK_COUNT;\n+\t\timage_metadata->Set(\"agc.status\", status_);\n \t}\n }\n \n@@ -335,55 +319,47 @@ static void copy_string(std::string const &s, char *d, size_t size)\n void Agc::housekeepConfig()\n {\n \t// First fetch all the up-to-date settings, so no one else has to do it.\n-\tstd::string new_exposure_mode_name, new_constraint_mode_name,\n-\t\tnew_metering_mode_name;\n-\t{\n-\t\tstd::unique_lock<std::mutex> lock(settings_mutex_);\n-\t\tnew_metering_mode_name = metering_mode_name_;\n-\t\tnew_exposure_mode_name = exposure_mode_name_;\n-\t\tnew_constraint_mode_name = constraint_mode_name_;\n-\t\tstatus_.ev = ev_;\n-\t\tstatus_.fixed_shutter = fixed_shutter_;\n-\t\tstatus_.fixed_analogue_gain = fixed_analogue_gain_;\n-\t\tstatus_.flicker_period = flicker_period_;\n-\t}\n+\tstatus_.ev = ev_;\n+\tstatus_.fixed_shutter = fixed_shutter_;\n+\tstatus_.fixed_analogue_gain = fixed_analogue_gain_;\n+\tstatus_.flicker_period = flicker_period_;\n \tLOG(RPiAgc, Debug) << \"ev \" << status_.ev << \" fixed_shutter \"\n \t\t\t   << status_.fixed_shutter << \" fixed_analogue_gain \"\n \t\t\t   << status_.fixed_analogue_gain;\n \t// Make sure the \"mode\" pointers point to the up-to-date things, if\n \t// they've changed.\n-\tif (strcmp(new_metering_mode_name.c_str(), status_.metering_mode)) {\n-\t\tauto it = config_.metering_modes.find(new_metering_mode_name);\n+\tif (strcmp(metering_mode_name_.c_str(), status_.metering_mode)) {\n+\t\tauto it = config_.metering_modes.find(metering_mode_name_);\n \t\tif (it == config_.metering_modes.end())\n \t\t\tthrow std::runtime_error(\"Agc: no metering mode \" +\n-\t\t\t\t\t\t new_metering_mode_name);\n+\t\t\t\t\t\t metering_mode_name_);\n \t\tmetering_mode_ = &it->second;\n-\t\tcopy_string(new_metering_mode_name, status_.metering_mode,\n+\t\tcopy_string(metering_mode_name_, status_.metering_mode,\n \t\t\t    sizeof(status_.metering_mode));\n \t}\n-\tif (strcmp(new_exposure_mode_name.c_str(), status_.exposure_mode)) {\n-\t\tauto it = config_.exposure_modes.find(new_exposure_mode_name);\n+\tif (strcmp(exposure_mode_name_.c_str(), status_.exposure_mode)) {\n+\t\tauto it = config_.exposure_modes.find(exposure_mode_name_);\n \t\tif (it == config_.exposure_modes.end())\n \t\t\tthrow std::runtime_error(\"Agc: no exposure profile \" +\n-\t\t\t\t\t\t new_exposure_mode_name);\n+\t\t\t\t\t\t exposure_mode_name_);\n \t\texposure_mode_ = &it->second;\n-\t\tcopy_string(new_exposure_mode_name, status_.exposure_mode,\n+\t\tcopy_string(exposure_mode_name_, status_.exposure_mode,\n \t\t\t    sizeof(status_.exposure_mode));\n \t}\n-\tif (strcmp(new_constraint_mode_name.c_str(), status_.constraint_mode)) {\n+\tif (strcmp(constraint_mode_name_.c_str(), status_.constraint_mode)) {\n \t\tauto it =\n-\t\t\tconfig_.constraint_modes.find(new_constraint_mode_name);\n+\t\t\tconfig_.constraint_modes.find(constraint_mode_name_);\n \t\tif (it == config_.constraint_modes.end())\n \t\t\tthrow std::runtime_error(\"Agc: no constraint list \" +\n-\t\t\t\t\t\t new_constraint_mode_name);\n+\t\t\t\t\t\t constraint_mode_name_);\n \t\tconstraint_mode_ = &it->second;\n-\t\tcopy_string(new_constraint_mode_name, status_.constraint_mode,\n+\t\tcopy_string(constraint_mode_name_, status_.constraint_mode,\n \t\t\t    sizeof(status_.constraint_mode));\n \t}\n \tLOG(RPiAgc, Debug) << \"exposure_mode \"\n-\t\t\t   << new_exposure_mode_name << \" constraint_mode \"\n-\t\t\t   << new_constraint_mode_name << \" metering_mode \"\n-\t\t\t   << new_metering_mode_name;\n+\t\t\t   << exposure_mode_name_ << \" constraint_mode \"\n+\t\t\t   << constraint_mode_name_ << \" metering_mode \"\n+\t\t\t   << metering_mode_name_;\n }\n \n void Agc::fetchCurrentExposure(Metadata *image_metadata)\n@@ -638,10 +614,6 @@ void Agc::writeAndFinish(Metadata *image_metadata, bool desaturate)\n \tstatus_.target_exposure_value = desaturate ? 0 : target_.total_exposure_no_dg;\n \tstatus_.shutter_time = filtered_.shutter;\n \tstatus_.analogue_gain = filtered_.analogue_gain;\n-\t{\n-\t\tstd::unique_lock<std::mutex> lock(output_mutex_);\n-\t\toutput_status_ = status_;\n-\t}\n \t// Write to metadata as well, in case anyone wants to update the camera\n \t// immediately.\n \timage_metadata->Set(\"agc.status\", status_);\ndiff --git a/src/ipa/raspberrypi/controller/rpi/agc.hpp b/src/ipa/raspberrypi/controller/rpi/agc.hpp\nindex ba7ae092..5a02df4e 100644\n--- a/src/ipa/raspberrypi/controller/rpi/agc.hpp\n+++ b/src/ipa/raspberrypi/controller/rpi/agc.hpp\n@@ -106,12 +106,9 @@ private:\n \tExposureValues current_;  // values for the current frame\n \tExposureValues target_;   // calculate the values we want here\n \tExposureValues filtered_; // these values are filtered towards target\n-\tAgcStatus status_;        // to \"latch\" settings so they can't change\n-\tAgcStatus output_status_; // the status we will write out\n-\tstd::mutex output_mutex_;\n+\tAgcStatus status_;\n \tint lock_count_;\n \t// Below here the \"settings\" that applications can change.\n-\tstd::mutex settings_mutex_;\n \tstd::string metering_mode_name_;\n \tstd::string exposure_mode_name_;\n \tstd::string constraint_mode_name_;\n",
    "prefixes": [
        "libcamera-devel",
        "v2",
        "02/10"
    ]
}