From patchwork Tue Feb 16 08:53:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11302 X-Patchwork-Delegate: niklas.soderlund@ragnatech.se Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 637ECBD1EF for ; Tue, 16 Feb 2021 08:53:53 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8EE0D637E5; Tue, 16 Feb 2021 09:53:52 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="B/1e6Lvu"; dkim-atps=neutral Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CDD38637C9 for ; Tue, 16 Feb 2021 09:53:49 +0100 (CET) Received: by mail-wm1-x331.google.com with SMTP id l17so8458946wmq.2 for ; Tue, 16 Feb 2021 00:53:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pE0pD3Pm7d1Q+xfAn0kd1mKoyC0oxhMkAlASrfwQPfc=; b=B/1e6Lvu616sIYfhsWZWjt/kiSbd/z/Sud8k2zKOQ18AM0uIr2vRCz9ClDpN8NuefG lvqEl2xFuqoTmTNJVRrYlv5YhqjvgkKCov0lFt2Ogj7PMifgMrgWce7/5c1YkLpOaovK 0Y1CYLUs+OcDG+R/tl+wP4FIGdAD1T8Av/rj5DZEoUYtqijqyjQPNkRrK2Pe7KAC6xAX tZlP1Pmoz5kmwUwHzCLt/56CzJ4OcBU+KqBnVpQl6uze5d7lIyjfWO4k8gJVgyjvn2lb rvqyQG8IF99n82TxmwUlfA+/3o7JNImtik79I5qGNS7CzixJUQQpDI48CoyvHQj4hsMb Kgqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pE0pD3Pm7d1Q+xfAn0kd1mKoyC0oxhMkAlASrfwQPfc=; b=GJNfpiqse/BBXpE2JKP5M32KhbG7EQheGvy1Yxtc4AIWbf/Vy/T5n9M5yhHUhVa5LZ A8qiSStYljdLYPjZA9BoWaMrWxNaDc4rYcc23mocuViC/sbkroIOny1B3n74PNwKvXuN s3zth23CIE0fqf/bjb+lCLp1sGOPw8RnHZlW/HcfSjJ6Fj/cry15mx0bbShMJ1/79hrK XWKPPjME+u+XpW49Iju2BegGmL9rePq4YYmS5vm4GC9Cz2S68est6wQy9ZIymWsjcQjn XMOw73IUCEzV5flltYZevLLpgDAgojjNq1voFxNxyXfUP8Sw6TDX2HeBSOFgZUcyDJ51 TmJw== X-Gm-Message-State: AOAM5301ckPbhnmDJxDfDdYesFZfjInDhBmGBlh+z9ifgmL9WaYRr4dt HtzKG+Ma7MedWAo4fv4sDObygfpdLz8yJkF8 X-Google-Smtp-Source: ABdhPJz8qxlmY2Cu9+Vg9cssBPKOkEnwlvgkvN0yVIuvP3ldG8NqhwD5VlhIlvURHEbovldkGNIIEQ== X-Received: by 2002:a05:600c:4788:: with SMTP id k8mr2330641wmo.138.1613465629171; Tue, 16 Feb 2021 00:53:49 -0800 (PST) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id e1sm9300369wrd.44.2021.02.16.00.53.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Feb 2021 00:53:48 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 16 Feb 2021 08:53:40 +0000 Message-Id: <20210216085342.1012717-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210216085342.1012717-1-naush@raspberrypi.com> References: <20210216085342.1012717-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/5] libcamera: delayed_controls: Remove unneeded write when starting up X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" On DelayedControls::reset(), the values retrieved from the sensor device were added to the queues with the updated flag set to true. This would cause the helper to write out the value to the device again on the first DelayedControls::applyControls() call. This is unnecessary, as the controls written are identical to what is stored in the device driver. Fix this by explicitly setting the update flag to false in DelayedControls::reset() when adding the controls to the queue. Additionally, use the Info() constructor when adding items to the queue for consistency. Signed-off-by: Naushir Patuck Fixes: 3d4b7b005911 ("libcamera: delayed_controls: Add helper for controls that apply with a delay") --- include/libcamera/internal/delayed_controls.h | 4 ++-- src/libcamera/delayed_controls.cpp | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/libcamera/internal/delayed_controls.h b/include/libcamera/internal/delayed_controls.h index 564d9f2e2440..2a6a912bde10 100644 --- a/include/libcamera/internal/delayed_controls.h +++ b/include/libcamera/internal/delayed_controls.h @@ -43,8 +43,8 @@ private: { } - Info(const ControlValue &v) - : ControlValue(v), updated(true) + Info(const ControlValue &v, bool updated_ = true) + : ControlValue(v), updated(updated_) { } diff --git a/src/libcamera/delayed_controls.cpp b/src/libcamera/delayed_controls.cpp index 3ed1dfebd035..21dc3e164fe9 100644 --- a/src/libcamera/delayed_controls.cpp +++ b/src/libcamera/delayed_controls.cpp @@ -111,7 +111,11 @@ void DelayedControls::reset() values_.clear(); for (const auto &ctrl : controls) { const ControlId *id = device_->controls().idmap().at(ctrl.first); - values_[id][0] = Info(ctrl.second); + /* + * Do not mark this control value as updated, it does not need + * to be written to to device on startup. + */ + values_[id][0] = Info(ctrl.second, false); } } @@ -126,11 +130,10 @@ void DelayedControls::reset() */ bool DelayedControls::push(const ControlList &controls) { - /* Copy state from previous frame. */ + /* Copy state from previous frame and clear the updated flag */ for (auto &ctrl : values_) { Info &info = ctrl.second[queueCount_]; - info = values_[ctrl.first][queueCount_ - 1]; - info.updated = false; + info = Info(values_[ctrl.first][queueCount_ - 1], false); } /* Update with new controls. */ @@ -150,8 +153,7 @@ bool DelayedControls::push(const ControlList &controls) Info &info = values_[id][queueCount_]; - info = control.second; - info.updated = true; + info = Info(control.second); LOG(DelayedControls, Debug) << "Queuing " << id->name()