From patchwork Mon Mar 7 12:46:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15430 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 B3F4FBF415 for ; Mon, 7 Mar 2022 12:46:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7340B611AA; Mon, 7 Mar 2022 13:46:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1646657206; bh=89vP4h/0JGP1S0biwi5aT70xvGgC0Q2ql9qcMP/BapY=; 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=h8OxAXJwRq67UePrkE4bBHAiqVMKdhM2eQ6qvogfTJ79oiMnxSXsZQfAils37JpGU 3sSOJwKO24cOImlxr6wbPpCS3BhJX6mEoaEDlDlTQyCmk4W0LztLNLvFHH3aJeh/1V LuKGN/oUKHJJGjsdxbNITpg0Yf9UU1tipqFJuGBueO94cS7UPMxv3FvP8zR2c8CSAr gc5NQCd4j0H0ltJfjRqZJf62Mj5njYAibfA3aI57BAiVX4uY/c8E/x3deS9Up2V0yo XybJgnQHSXKqGM1c54ikaFVyLO2cC78ztemPgJcYWygmSKwHXGySbeFnaSx/ZKN3Zr voWxc+LT1kYrQ== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DCC9361187 for ; Mon, 7 Mar 2022 13:46:42 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="X7sGvniJ"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id p9so23068375wra.12 for ; Mon, 07 Mar 2022 04:46:42 -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=Bnmw6O5W7PZnoxsUF508AY4VM/IN+j4579ahBbZHVc4=; b=X7sGvniJQC59sOcX5aWGyi89Nu7r4sryVVMxgqb0K3flEntjvDwBsSDd9avP7emSLT 3+JEDwrASHeruiViHvp9FsrrLpDbBPZgRSuoQMKpisfpdj+rKA0iSOLfhN3TcJEHQ+fV w3zpxqy3khFq4Gs+vUgxCMWOv0dMJGDqapWXr44mSh+A7ZycSMmRUZPOPFGZTUp8vMvF FdYxbSTKMB4nwDFJiRa3Qv1z9OuTLXZXvT1t7HbhVJ1gx1AdEn8AvZzFq1aJJCNF5Dp6 jBlppHrfba6ta2x90VLKdULmHtjgwxWMIi+DC7O8Xz45zOdDjoli+sInfBPyuhSEtdDU 5maA== 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=Bnmw6O5W7PZnoxsUF508AY4VM/IN+j4579ahBbZHVc4=; b=MN0fph7RRN2/4tnfE1hHO2tpvBLnWE4RDAjJL1ssmGD4LLVi30DEYBZEJuh6e/FIrL 4qKoTAlmMF7A3rKRguvQkiXd6ZKcVDpdl7980B+wBdHjPHpSua+Zeo6Jl9LrTMS+ukGB NXOIeb2RGV+UQzBa449Quabf8lkyJ99sllLMT5zFxqvhfPJrsWidh0HS1nlHT/LHMA5V 62h2dUOp7UH+BRFuo84jvWJrsELAxzxhv3iCN2b2dvYf1sP8i/K8FOHqTdsp0O8p5xTM gbaMTDvqzl1C0TFttD4wx4FiEkiTXHHHR2p1ZfaequEDiXSup0JF3FO5HrbSQMawCyon 8FjA== X-Gm-Message-State: AOAM533YHcmT0ucYuaspiCvvFNqXtM8y6QGq5sCGzVRibv93uXFB67vD VFYRGvj653ACnmZkdci0QbASR15jLR1QYg== X-Google-Smtp-Source: ABdhPJzMzJSUhF8aji/7BJMx93k19GwQSj9pfAaGoeIVLu2gjPM+Ix3Jxil3zwtidUp+j+IW8tulIg== X-Received: by 2002:adf:f48e:0:b0:1f0:636a:1bbd with SMTP id l14-20020adff48e000000b001f0636a1bbdmr8472956wro.580.1646657202339; Mon, 07 Mar 2022 04:46:42 -0800 (PST) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:c644:e9b3:de0b:54c5]) by smtp.gmail.com with ESMTPSA id z6-20020a1cf406000000b0037c4e2d3baesm19759582wma.19.2022.03.07.04.46.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 04:46:41 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Mon, 7 Mar 2022 12:46:32 +0000 Message-Id: <20220307124633.115452-6-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220307124633.115452-1-naush@raspberrypi.com> References: <20220307124633.115452-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 5/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. This reset() 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 | 5 ++++- src/libcamera/pipeline/raspberrypi/rpi_stream.cpp | 11 +++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index b17ffa235ac7..193361686d3c 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -692,7 +692,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) /* Start by freeing all buffers and resetting 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; @@ -985,6 +985,9 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) RPiCameraData *data = cameraData(camera); int ret; + for (auto const stream : data->streams_) + stream->reset(); + if (data->reconfigured_) { /* Allocate buffers for internal pipeline usage. */ ret = prepareBuffers(camera); diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp index f446e1ce66c7..0840ec4f54a0 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp @@ -28,8 +28,10 @@ std::string Stream::name() const void Stream::reset() { - 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()); + reset(); } /* We must import all internal/external exported buffers. */