From patchwork Fri Mar 25 09:08:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15545 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 4E653C0F1B for ; Fri, 25 Mar 2022 09:09:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EE7AD604EA; Fri, 25 Mar 2022 10:09:12 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648199353; bh=LAyJvKIGT2q0yec59HHtU1koPIGLOBZBSrRmPJWFo0Y=; 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=HuQdvgV7GFOII407ml0X0rFA7273Sj2YVeJLG/n2W+tB4wdIgNjHAeOkyHc1SFHOZ PvAsTmqcsK6Tckrbr46356W1zxZJGFQyJSPxGlnFCWDtGkbhb+qvQoPCZ7b/FdjZfG +rPBy8/47uWucNLGLrU4ti0xkGZ4r4VjjO6GzkFXraBUt1f3NyJmoQczAi7K5YB+4q 9KvPFF3C+BTD9Eyvj4OjUJMRMIRWLSrA//wK6nKYl79sEWKgx4/EVynNJemN1pK3ar Rc+5lg9mh9nXh1jSz3EyJuf6uHJ6sjOH23u2jSsvP+kEnF98zTV49I1rF71krbp+C2 f10rKulzQOtnw== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 70A7660136 for ; Fri, 25 Mar 2022 10:09:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="NOl8nIL7"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id r64so4075225wmr.4 for ; Fri, 25 Mar 2022 02:09:10 -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=y+AU3uHdQY363TBVi7RlIPz9CMOUvtyCfstDvCKShdo=; b=NOl8nIL7fd8pgPaD0niAYHEeYWSc2nFhKsdGhOI+jy14v/fKVNwUDrdRMdDvXk0x0g Tqgz+Ogzs4TUYJlzLRTAiFgk00SC/rE2vauCXrAxjA9QeF6M7L88VkMFMnN9892ott0B R1Jy+1A2w25jwAXJ8ZGohAgkup5UMpfjjOyJzZ86hdKfPU0nCFwxqtR3Su3wps5Z1TVN NI3aY0rf+oJXp2PsOPMi/nfBZnw50Cjhp0pJulVyxUmx4Es+qypV7oau2YqSdVWiDV0i gn54qsZ3wjSLyzagCORU8lgZCUlpe1Qm6l5fjq0xOo30Sqtp6q85A1iihPJFMu9cyiAN C0eQ== 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=y+AU3uHdQY363TBVi7RlIPz9CMOUvtyCfstDvCKShdo=; b=qF79z5ISDUyXXB1yrhkKRyVEvhNIh22bqRJlzj9aEnO+HCfpJ4G2Xy+Ly1zkPK7YcH 67xfRPncWYkjrIzFbmVA/9r/tqDrgEYK11gRst0KV873bll81RomvwbtpLm4055ryp5l Jal07dddz2TVXfIGU/Ev5Z0Z/woYC7mRJFG23j7jLqPKcgsF5jWSVdC5H/KhDZAEYjW7 ZX3O4yObAug2tX7FW4MXMXwU1zGNd0V7gj0uWi1+dhMdESGf+sdtlMu/iOnpgaYBNzUC G8hd6kKQ3I0YNAODrb2fiNYDbRN3IqMPVfr2A3mfSjKzrM2hAIU2IVGqtC1YSUjFRDH+ 3OoQ== X-Gm-Message-State: AOAM530nME803Aha6JTfcdC0eEULQL8hvLzZ2PsZhNTtEaxPm5zGqYG4 ILoOWMZIlG0j+gi0QlK+S2dzOLzIknn0ZA== X-Google-Smtp-Source: ABdhPJwQoYPJtTVaL9zTYPGZzjdigSLYXMsY9RhoW3HPV3AcM0R6ZOImel1cNxvT4EOk0pZTf7dp6Q== X-Received: by 2002:a05:600c:20a:b0:38c:95bf:3289 with SMTP id 10-20020a05600c020a00b0038c95bf3289mr18266049wmi.134.1648199349926; Fri, 25 Mar 2022 02:09:09 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:478c:773f:4734:d0bc]) by smtp.gmail.com with ESMTPSA id c4-20020a056000184400b0020584c40778sm4915297wri.103.2022.03.25.02.09.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 02:09:09 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 25 Mar 2022 09:08:59 +0000 Message-Id: <20220325090903.880311-5-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220325090903.880311-1-naush@raspberrypi.com> References: <20220325090903.880311-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 4/8] 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 Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 5 ++++- src/libcamera/pipeline/raspberrypi/rpi_stream.cpp | 13 ++++++------- src/libcamera/pipeline/raspberrypi/rpi_stream.h | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 92043962494b..8fd79be67988 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->buffersAllocated_) { /* 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..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;