From patchwork Tue Nov 15 09:07:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17796 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 DD54EC3285 for ; Tue, 15 Nov 2022 09:08:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BB0AE63079; Tue, 15 Nov 2022 10:08:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1668503286; bh=J6cFEdUNUolwDllVMsFx8kpijHwSyHWPGi/UH1SmfYc=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=VdyriAh3jmQ+xXDmyTW3AgLE9BKC3E/d8baelRuGPaZzWH8dzJVJW+IZJ55cp0nhA IK9Uaumh2OPOEgSU2RB5lZKmnHXd2vZ2z0U+9x/BaVtY2bHuNk37pbEc1VwW9U2lmX jvfjngL+17Qq9TdwrRIk4/6+88hm8nT73vO5t88NKRRBPGIvFfNBlujGn6HVImGAYn mxMdm93pGpmBpEW/mN5kytdOWCdGL61+LwtVVJQlrFqLgrf6OH56Ji7wyBGDA155ew QkD51c/0UoUzPhyxMwr751K/3icDgJYZmuX+ZI37/J/toEPaz6ozuBk3hPxueeCVMJ uwCh7CEItlO2Q== Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C69726307F for ; Tue, 15 Nov 2022 10:08:03 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="p1fT+sUh"; dkim-atps=neutral Received: by mail-wr1-x42c.google.com with SMTP id j15so23120810wrq.3 for ; Tue, 15 Nov 2022 01:08:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=g4e6aCLgztXw7aLK8j8CpH1wz8V389BXNzUdmUAx/Uc=; b=p1fT+sUheMGfIcnAhb/GLseNdTIb/BAU3YFN4b3+O8vhHXl1+P0O6+7YbzFyi6/lW3 e8rrTnwfhROiWCZdDjfE9eyV6qfQ3rbCVouli5mkVaVSAZ6dAFfztW+B/wBnKZioVtV3 BbEoPJCNkRAF/cBQjMC2OlilhiU3u7pem4VcBwBHr7tKh5GZuvSwmSQQGSBCVMq2Ggi2 qr78HJMQgSmSLTWSdqUw04qYm7HwIQaLVpZ8qrv/DqSEMRhdDLc8IvlEyLf1Uc3GDI+O TXqxdjTWQ2jpVThAIWRWMpLw6dOifAvrA6/QW5aFOGQI68W/HxQRy7S2IIvtVY/Aynsi Gn1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=g4e6aCLgztXw7aLK8j8CpH1wz8V389BXNzUdmUAx/Uc=; b=crSqkokpVF5kv983a8uPyAFeIrvM1Sx9Kl2Aydfw2deDkTJOwhc+VZKEucm0LlvklC o8BpH9gz+WM1N66Jxty/KFqavdCii3i7GCKuBLw+GtmZLTqu4hg3hPAN58y7CPE57JyF gGVcfQk8lUtfiANoxxlezdz5o20jPBUhS1ZTdBO0gq+XhQEuFZK01Hdz54SGBjVq92RD v0fxs6NBNQIpjwEx5QBgto5X0KmRBRkiFjlU2xdFIim0X6Y73yaSbtPYPKNucLEyTLDW jsSqWJbA1VVGPrAn79LQ4yKsXzj8B4avUVgu4otdhxiLk3MQtlZJw6IzKES4np+TKwrd R6Eg== X-Gm-Message-State: ANoB5pnVJa/4KhFsewhBUVjfp5zOnrOIcD1lrnTZJdsuUT8QhbA76qlk egHStDxlQs/2G+16jN0eOByRGbgNlc4Rhg== X-Google-Smtp-Source: AA0mqf6ZYqbkIJk5ZZrmR2pjvprAbUPtQ8LKypPIy98Ri6o5erjlK0iSv9jX6F+Ej5FilvqyoGo3QQ== X-Received: by 2002:adf:ff85:0:b0:235:c5de:75c3 with SMTP id j5-20020adfff85000000b00235c5de75c3mr9782712wrr.285.1668503283260; Tue, 15 Nov 2022 01:08:03 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id p25-20020a05600c1d9900b003c64c186206sm15143696wms.16.2022.11.15.01.08.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Nov 2022 01:08:02 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 15 Nov 2022 09:07:51 +0000 Message-Id: <20221115090755.2921-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221115090755.2921-1-naush@raspberrypi.com> References: <20221115090755.2921-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 4/8] pipeline: raspberrypi: delayed_controls: Add user cookie to DelayedControls 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Allow the caller to provide a cookie value to DelayedControls::reset and DelayedControls::push. This cookie value is returned from DelayedControls::get for the frame that has the control values applied to it. The cookie value is useful in tracking when a set of controls has been applied to a frame. In a subsequent commit, it will be used by the Raspberry Pi IPA to track the IPA context used when setting the control values. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman --- .../pipeline/raspberrypi/delayed_controls.cpp | 14 ++++++++------ .../pipeline/raspberrypi/delayed_controls.h | 8 +++++--- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 6 +++--- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/delayed_controls.cpp b/src/libcamera/pipeline/raspberrypi/delayed_controls.cpp index 867e3866cc46..3db92e7d24fb 100644 --- a/src/libcamera/pipeline/raspberrypi/delayed_controls.cpp +++ b/src/libcamera/pipeline/raspberrypi/delayed_controls.cpp @@ -108,7 +108,7 @@ DelayedControls::DelayedControls(V4L2Device *device, maxDelay_ = std::max(maxDelay_, controlParams_[id].delay); } - reset(); + reset(0); } /** @@ -117,10 +117,11 @@ DelayedControls::DelayedControls(V4L2Device *device, * Resets the state machine to a starting position based on control values * retrieved from the device. */ -void DelayedControls::reset() +void DelayedControls::reset(unsigned int cookie) { queueCount_ = 1; writeCount_ = 0; + cookies_[0] = cookie; /* Retrieve control as reported by the device. */ std::vector ids; @@ -150,7 +151,7 @@ void DelayedControls::reset() * * \returns true if \a controls are accepted, or false otherwise */ -bool DelayedControls::push(const ControlList &controls) +bool DelayedControls::push(const ControlList &controls, const unsigned int cookie) { /* Copy state from previous frame. */ for (auto &ctrl : values_) { @@ -184,6 +185,7 @@ bool DelayedControls::push(const ControlList &controls) << " at index " << queueCount_; } + cookies_[queueCount_] = cookie; queueCount_++; return true; @@ -204,7 +206,7 @@ bool DelayedControls::push(const ControlList &controls) * * \return The controls at \a sequence number */ -ControlList DelayedControls::get(uint32_t sequence) +std::pair DelayedControls::get(uint32_t sequence) { unsigned int index = std::max(0, sequence - maxDelay_); @@ -221,7 +223,7 @@ ControlList DelayedControls::get(uint32_t sequence) << " at index " << index; } - return out; + return { out, cookies_[index] }; } /** @@ -280,7 +282,7 @@ void DelayedControls::applyControls(uint32_t sequence) while (writeCount_ > queueCount_) { LOG(RPiDelayedControls, Debug) << "Queue is empty, auto queue no-op."; - push({}); + push({}, cookies_[queueCount_ - 1]); } device_->setControls(&out); diff --git a/src/libcamera/pipeline/raspberrypi/delayed_controls.h b/src/libcamera/pipeline/raspberrypi/delayed_controls.h index 238b86ab6cb4..61f755f0fddd 100644 --- a/src/libcamera/pipeline/raspberrypi/delayed_controls.h +++ b/src/libcamera/pipeline/raspberrypi/delayed_controls.h @@ -11,6 +11,7 @@ #include #include +#include #include @@ -31,10 +32,10 @@ public: DelayedControls(V4L2Device *device, const std::unordered_map &controlParams); - void reset(); + void reset(unsigned int cookie); - bool push(const ControlList &controls); - ControlList get(uint32_t sequence); + bool push(const ControlList &controls, unsigned int cookie); + std::pair get(uint32_t sequence); void applyControls(uint32_t sequence); @@ -78,6 +79,7 @@ private: uint32_t queueCount_; uint32_t writeCount_; std::unordered_map> values_; + RingBuffer cookies_; }; } /* namespace RPi */ diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index f3be4ee3b730..2c12ed1fba95 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1064,7 +1064,7 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) * Reset the delayed controls with the gain and exposure values set by * the IPA. */ - data->delayedCtrls_->reset(); + data->delayedCtrls_->reset(0); data->state_ = RPiCameraData::State::Idle; @@ -1794,7 +1794,7 @@ void RPiCameraData::setIspControls(const ControlList &controls) void RPiCameraData::setDelayedControls(const ControlList &controls) { - if (!delayedCtrls_->push(controls)) + if (!delayedCtrls_->push(controls, 0)) LOG(RPI, Error) << "V4L2 DelayedControl set failed"; handleState(); } @@ -1867,7 +1867,7 @@ void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) * Lookup the sensor controls used for this frame sequence from * DelayedControl and queue them along with the frame buffer. */ - ControlList ctrl = delayedCtrls_->get(buffer->metadata().sequence); + auto [ctrl, cookie] = delayedCtrls_->get(buffer->metadata().sequence); /* * Add the frame timestamp to the ControlList for the IPA to use * as it does not receive the FrameBuffer object.