From patchwork Mon Mar 7 12:46:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15428 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 C57C5C3261 for ; Mon, 7 Mar 2022 12:46:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 87F796118E; Mon, 7 Mar 2022 13:46:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1646657204; bh=Ny4pRakMea6WwmHE/ip3My7NZuljg35QW0IflMAlaAY=; 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=02JSk1F/C/0yJgsBzLhmaJAYiZpUrPzqw8bidVHACk2YUPmgxhgrlmx/6A3XfIsFn 4ft1p1q1t8Rjt6wsHp3mPDU79pj+WN0aGZXeMFUF1M1FZ17enHHDW2eIKJOAnvVTd4 p7sBivsl70qXcI8BdCLP6DH9IbFprJQ6zyl4/vCwsyJLLG8Zagd2fnAQwhF2Ljm9tE sACN+qgwAg7nmr1KABihebxZUzDDZNMUrg5LtynySm2oOqsYiY1FoboSJxZmaGsTMq e+zKYj1auhdMQ91bBxpxFYovLK5VheroIcfV41jp30QhjswQhyPVfLqGG65y610Zx1 tjJqBIuzcTm2w== Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 69E2F6118D for ; Mon, 7 Mar 2022 13:46:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="gJbUeA8a"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id m42-20020a05600c3b2a00b00382ab337e14so10083243wms.3 for ; Mon, 07 Mar 2022 04:46:41 -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=hlaMJcXVUCEb9tdJXTlISVfKaEdBnc5bcEQgwsCnoqA=; b=gJbUeA8aBoq0NPOhNRuKUyKjHEJUt19Lb+xzjzROFNTlIBgvC0nDy+ZYWgBOWhSnSD JacqFvXM4fogQti7l/gGYpNtySSqzuLxk7GqubBsAm9JhOnNhPoUW1qSoelj69S2++ax N37xxqLyePtrUmjmGSdD2cFxgwobTtg3/NCrKWALYZmFfbgEJDRyHOZc1Jry328SZN5L s07nEIfCuk1JyjNLGyH1nd6i47lr+8y5ReI11K6cDU0DCu5ZTJSwzyeimVzb8C3K5Y6F hF06l4ulaOVdmG8fm7b7lgWDsyz0XhDwl4aDXMXhO172uIYKWFSklXwd05RUv/0o/bBe 63Cw== 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=hlaMJcXVUCEb9tdJXTlISVfKaEdBnc5bcEQgwsCnoqA=; b=JsCVZVFScwcutrkTt8a8os1wOJ5larIrPB54d/4+IG22Kx/q99y8mmcPDkGKvFyE1e IWwA9lMOQ6klLHx2I7mCQBnxnvERLou2y0RSaCV8TKMQNKkbleTq51ud/IcduzOnsu+/ HCwyXpRuYkJliW5ismhjksE3q5Dnx79LIlCHzfRucvWTUkmrmzPLL2rQZ45YdesOx2C1 udf4a/D8JQWz9FGx/+Nm/6wL2WccrgypYLzUHR4HI4nZv6Quq6+9m1/EhuHqZ+wiudfh IXOct6gXeJ8vlEfd8VsGaru8pdXwqT0mtliU+QLmU1yVrJR98dV/zyE/PIFxFVQN6J8g qf8A== X-Gm-Message-State: AOAM533Z8QglRa78M3YPE6wDY64L7YvxAWiQNefy2FjCVpgnNMrb9Z3Z 5ptQrTy3kLj1bsasjeH3lYCbezeE5G04PA== X-Google-Smtp-Source: ABdhPJzqOd1E3i6pfIhSxg1uBHCV03uLDuc0Re2ZmlJTJbVZE432npcqjvmy091n9tCGw/5VXWfKLA== X-Received: by 2002:a7b:c19a:0:b0:381:8495:9dd with SMTP id y26-20020a7bc19a000000b00381849509ddmr18282751wmi.33.1646657200753; Mon, 07 Mar 2022 04:46:40 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Mar 2022 04:46:40 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Mon, 7 Mar 2022 12:46:30 +0000 Message-Id: <20220307124633.115452-4-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 3/6] pipeline: raspberrypi: Free buffers in the RPiCamera destructor and re-configure 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" Currently, all framebuffer allocations get freed and cleared on a stop in PipelineHandlerRPi::stopDevice(). If PipelineHandlerRPi::start() is then called without an intermediate PipelineHandlerRPi::configure(), it will re-allocate and prepare all the buffers again, which is unnecessary. Fix this by not freeing the buffer in PipelineHandlerRPi::stopDevice(), but insted doing it in PipelineHandlerRPi::configure(), as the buffers might have to be resized. Signed-off-by: Naushir Patuck Reviewed-by: David Plowman Tested-by: David Plowman --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 3781e4e0e3c4..8bb9fc429912 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -189,6 +189,11 @@ public: { } + ~RPiCameraData() + { + freeBuffers(); + } + void freeBuffers(); void frameStarted(uint32_t sequence); @@ -681,7 +686,8 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) RPiCameraData *data = cameraData(camera); int ret; - /* Start by resetting the Unicam and ISP stream states. */ + /* Start by freeing all buffers and resetting the Unicam and ISP stream states. */ + data->freeBuffers(); for (auto const stream : data->streams_) stream->reset(); @@ -1048,8 +1054,6 @@ void PipelineHandlerRPi::stopDevice(Camera *camera) /* Stop the IPA. */ data->ipa_->stop(); - - data->freeBuffers(); } int PipelineHandlerRPi::queueRequestDevice(Camera *camera, Request *request)