From patchwork Thu Mar 17 14:08:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15474 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 EDED8C3263 for ; Thu, 17 Mar 2022 14:08:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 77382604E8; Thu, 17 Mar 2022 15:08:39 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1647526119; bh=hmW0dmL2Wn0CwrkkMd1DI57vr+ZJMXzXlvy1PzDbD2M=; 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=VU7SDRnYwnINcmLUPw9O34c915MF35hvMcRwjPvx35W7eE2xELFU3LklCIcfGnu08 zHfltfcPx8FJoZWcFn19nbE4MCe7A5BCmV1yIMzpZMWLl/TxNgQPuUBBh6LLCbUjeq JoUpKhqisWPBcv7/MqUehK2dI6tbmkXCQZosLDFnSqnO0lMkl39suvY1BnBSq4IrYJ j4cXp7eNM8eXkPZjrgRFEtsjR5X+A8MOvgG4x3NKMQdanXgyGSBKGSbRo/qaD7nprq 5PtLLc+D1w7Y2Rp4C8hbde6JgCOZPX6H+5wuV8eu3N+CX1asiRyN+wMwxOn6BiVESj 4/gYOKC3TiruA== 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 6E82A610F8 for ; Thu, 17 Mar 2022 15:08:36 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="tPeplFVy"; dkim-atps=neutral Received: by mail-wm1-x331.google.com with SMTP id 7-20020a05600c228700b00385fd860f49so3262812wmf.0 for ; Thu, 17 Mar 2022 07:08:36 -0700 (PDT) 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=uTP8kcdMePVoTNBWCwW1qpevafEXXGJwaf+aCHPyhj0=; b=tPeplFVy3Dm0HbpxESiFay7gTZm1DVaO00pIaL3H1vMjpfe9voFgaiN4JQx8M7NcC4 LZ/gE8AkexvTKgKug710HxU3uxrbeVu9Khtly6FTe5MLzUlPrsjidRKPKSFfS/raMUnE i53jwmfxqm+Z0q6iLAtVFQVa2qzmU9sX5Q/3VRdwjLKnSRiWRndc7Ns2gD0Qa0hxj1ya XA4+ADBSYpnN3Z1+rU3kK8iywbRCht8st60DWPWK//1jlmuhjxKK3WsCnJR3AgxxgVu1 W2I6ZMbUP8p2IJOzFyh63sE5/2gVV7eBAxBMCDwnUTgPDUcgCF7efcD4BvoJAae/ueYq w3fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uTP8kcdMePVoTNBWCwW1qpevafEXXGJwaf+aCHPyhj0=; b=2AzuaWkMNYjtAxEgZxh7y2FMS9NctH1lipz40ndg9mwMG5ady8N30PO4nduF7Z3hBd b/unR7UaAx0MF9g1R+ELb2e3F1qmdss+EMXPJwp86O+ijZOvWZvHvemagST9Ly1gZ2I2 +4jbIjoXOpt6N1XwGb4lZR/Q9Y1BZw6Si1ITYfeC/5FR9hGzXiWqKS/3L4BXZtUpXyW9 fq/M6FkLG3NNwdPi6/hnUEvidsVRvLX+M0h5xUl6z98H3wdOd+D2ER6rKTuRmD8/ojwp 9MW9pcn3uNj092QvVu+ZbPGoDyh7zN8BCpnLo0qbOAc2GQe/Ba/VYuTzbfITXbfrtHPX zT5A== X-Gm-Message-State: AOAM533wvm5A6o/hV4akHQCo4RwOyEal2krzIdTEL0oQcalAP+AebyJH g4trFYDXUjJEJfcyaYU/okJXciS1RzcMCg== X-Google-Smtp-Source: ABdhPJxHq7Cq670cMcskQR2Hmxa0NyPC+qGQLOAFUNN0E39WdSYXqo8BN0MXjsmhdzjl95uX8mvWSA== X-Received: by 2002:a1c:f018:0:b0:37b:c13c:3128 with SMTP id a24-20020a1cf018000000b0037bc13c3128mr11577599wmb.157.1647526115869; Thu, 17 Mar 2022 07:08:35 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:371b:8e01:111f:5322]) by smtp.gmail.com with ESMTPSA id z5-20020a05600c0a0500b0037fa93193a8sm5287831wmp.44.2022.03.17.07.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Mar 2022 07:08:35 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 17 Mar 2022 14:08:25 +0000 Message-Id: <20220317140827.1835029-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220317140827.1835029-1-naush@raspberrypi.com> References: <20220317140827.1835029-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 4/6] pipeline: raspberrypi: Repurpose RPi::Stream::reset() 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" The original use of RPi::Stream::reset() was to clear the external flag state and free/clear out the framebuffers for the stream. However, the latter is now done through PipelineHandlerRPi::configure(). Rework PipelineHandlerRPi::configure() to call RPi::Stream::setExternal() instead of RPi::Stream::reset() to achieve the same thing. Repurpose RPi::Stream::reset() to instead reset the state of the buffer handling logic, where all internally allocated buffers are put back into the queue of available buffers. As such, rename the function to RPi::Stream::resetbuffers() This resetbuffers() is now called from PipelineHandlerRPi::start(), allowing the pipeline handler to correctly deal with start()/stop()/start() sequences and reusing the buffers allocated on the first start(). Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Tested-by: David Plowman --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 7 +++++-- src/libcamera/pipeline/raspberrypi/rpi_stream.cpp | 13 ++++++------- src/libcamera/pipeline/raspberrypi/rpi_stream.h | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 082273828894..d3212b193ced 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -693,7 +693,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) /* Start by freeing all buffers and reset the Unicam and ISP stream states. */ data->freeBuffers(); for (auto const stream : data->streams_) - stream->reset(); + stream->setExternal(false); BayerFormat::Packing packing = BayerFormat::Packing::CSI2; Size maxSize, sensorSize; @@ -991,6 +991,9 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) RPiCameraData *data = cameraData(camera); int ret; + for (auto const stream : data->streams_) + stream->resetBuffers(); + if (data->reallocate_) { /* Allocate buffers for internal pipeline usage. */ ret = prepareBuffers(camera); @@ -1031,7 +1034,7 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) data->unicam_[Unicam::Image].dev()->setFrameStartEnabled(true); /* - * Reset the delayed controls with the gain and exposure values set by + * resetBuffers the delayed controls with the gain and exposure values set by * the IPA. */ data->delayedCtrls_->reset(); diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp index f446e1ce66c7..7a93efaa29da 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp @@ -26,10 +26,12 @@ std::string Stream::name() const return name_; } -void Stream::reset() +void Stream::resetBuffers() { - external_ = false; - clearBuffers(); + /* Add all internal buffers to the queue of usable buffers. */ + availableBuffers_ = {}; + for (auto const &buffer : internalBuffers_) + availableBuffers_.push(buffer.get()); } void Stream::setExternal(bool external) @@ -97,10 +99,7 @@ int Stream::prepareBuffers(unsigned int count) /* Add these exported buffers to the internal/external buffer list. */ setExportedBuffers(&internalBuffers_); - - /* Add these buffers to the queue of internal usable buffers. */ - for (auto const &buffer : internalBuffers_) - availableBuffers_.push(buffer.get()); + resetBuffers(); } /* We must import all internal/external exported buffers. */ diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.h b/src/libcamera/pipeline/raspberrypi/rpi_stream.h index d6f49d34f8c8..c37f7e82eef6 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.h +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.h @@ -45,7 +45,7 @@ public: V4L2VideoDevice *dev() const; std::string name() const; bool isImporter() const; - void reset(); + void resetBuffers(); void setExternal(bool external); bool isExternal() const;