From patchwork Fri Jul 21 09:37:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18858 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 B9BC8BDC71 for ; Fri, 21 Jul 2023 09:38:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D6BED628C7; Fri, 21 Jul 2023 11:37:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1689932279; bh=+1abu2ZKXVHcKBycKbIcq2Dj3X4qqFlh1KD19PfbJzs=; 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=PUPLmqMMoYAlIoNqbUHRiSS+3mEtGxc+kGeb8IoBcRYQtdGLCJU9IN0UYaAiiM6h2 7zF0X/HHh2tjrgKzZ8wxaBNz134s31fN/dUEOzgGIgiRQu9FOFg9LJj/Ul2rVQRjsg BMsvXsK2Hgb7MetKG0mOIUG/L7+Of4W081XuUpz83jP/mlFGzQGhKcrjZMv412Wz+h vakIBAqiSnOONCmarxUxcQSXmwwG9H0CfrGSNQbiWpoxBNFp8nPz5xtRSLq5ySZBCS hh86e6tFV6QBRzG4fNeTaALAzWcAORgxWclYbajlLCljiUQBut4AKRA0ikvwPwADTW rRk+YeCMGbUiQ== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 343DB628BC for ; Fri, 21 Jul 2023 11:37:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="CmkVxbI1"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-3fbc244d307so15121305e9.1 for ; Fri, 21 Jul 2023 02:37:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1689932277; x=1690537077; 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=iEcMesmSrHM3jxC8V6CtQRJa/y3x1n2+cCaiHMom00k=; b=CmkVxbI1cCZQu6TXHvplhKxgvL2OJ+soWcLmRucShi4ygXHBWHpIopEhOO65dIk01U ApCfLHZai3aQyPqBLe3vk/7cfKTCL6PEWtTrV6JvrVLhELWrwaUJSUMRSFgSY/3QVPXz d1+1Bl2DWlMTDbrKsihG1jW/ZibmjOQRKsFSmLxutYtdkDnHw/PZFF7JFB9p3ERL26c6 QfD7C6NGb/LnnMIMEuRYbepnflkiCAhvwd7XOc/Go1A5xTklTIT9hj+YJm0WbXrW0AkI 3PbLq53+6uTFE0J7m5dnttp8oweIRIT9yKn/AAqmAB15K6JTsWjOZttrnW3T3h15Z+6n +3Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689932277; x=1690537077; 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=iEcMesmSrHM3jxC8V6CtQRJa/y3x1n2+cCaiHMom00k=; b=HU8VQ72Y9jtdiO8t2XTSL7vO/i0SUSczNUSDiKtAB2+jG3H1Q5BvCu9qmU2KZPfQ4n cA6akGHDUiuic5nj2V8Yq4GZWoxUBsi+0OnHsmAYK4UsfJ+2J64lrv9/fKatCOBm+TB6 nuMr/Z+3vbYBb8PjIkhaebvpo3fKjIvncrfExb3yaHcH2r4DPOngxyovi99yaJdz458d Q5/+G2AmCR8UW7ubPkjNAVo1TTX65l+0UNgiv8eQ90uiQ9SdmkvkeFllesHbUQoyJ2GT PgFll9/Reb7zrphpyP9AMKi+SaO92SZlDm8FEqIcEvP4dNSh91xwvs+ALayDIV1C+6Gl 9yTw== X-Gm-Message-State: ABy/qLYnPZ2M2ZN1BMt9UKSq1hJeejek4xYYqtWwGdUa4NzPBbKrG8D7 G9rH2uDpv6kyKTAJK/S9TkjtBsdluo/1yCGXLDUS+Q== X-Google-Smtp-Source: APBJJlF6zvUJkBUpYYyVDeUsUCLiMt0Kp7qs6TeNsCzg9uizOhas7jlg7Hnt5QNyWH+qWTKCTq0AnQ== X-Received: by 2002:a1c:7c0b:0:b0:3fb:9ea6:7a73 with SMTP id x11-20020a1c7c0b000000b003fb9ea67a73mr1038405wmc.23.1689932277448; Fri, 21 Jul 2023 02:37:57 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id n12-20020a5d6b8c000000b003143c6e09ccsm3674663wrx.16.2023.07.21.02.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 02:37:57 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 21 Jul 2023 10:37:56 +0100 Message-Id: <20230721093759.27700-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230721093759.27700-1-naush@raspberrypi.com> References: <20230721093759.27700-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 1/4] pipeline: rpi: Increase buffer import count to 32 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" Hardcode the maximum number of buffers imported to the V4L2 video device to 32. This only has a minor disadvantage of over-allocating cache slots and V4L2 buffer indexes, but does allow more headroom for using dma buffers allocated from outside of libcamera. Signed-off-by: Naushir Patuck --- .../pipeline/rpi/common/rpi_stream.cpp | 35 +++++-------------- 1 file changed, 9 insertions(+), 26 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp index c158843cb0ed..1d05c5acc0d9 100644 --- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp @@ -94,35 +94,18 @@ int Stream::prepareBuffers(unsigned int count) { int ret; - if (!(flags_ & StreamFlag::ImportOnly)) { - if (count) { - /* Export some frame buffers for internal use. */ - ret = dev_->exportBuffers(count, &internalBuffers_); - if (ret < 0) - return ret; - - /* Add these exported buffers to the internal/external buffer list. */ - setExportedBuffers(&internalBuffers_); - resetBuffers(); - } + if (!(flags_ & StreamFlag::ImportOnly) && count) { + /* Export some frame buffers for internal use. */ + ret = dev_->exportBuffers(count, &internalBuffers_); + if (ret < 0) + return ret; - /* We must import all internal/external exported buffers. */ - count = bufferMap_.size(); + /* Add these exported buffers to the internal/external buffer list. */ + setExportedBuffers(&internalBuffers_); + resetBuffers(); } - /* - * If this is an external stream, we must allocate slots for buffers that - * might be externally allocated. We have no indication of how many buffers - * may be used, so this might overallocate slots in the buffer cache. - * Similarly, if this stream is only importing buffers, we do the same. - * - * \todo Find a better heuristic, or, even better, an exact solution to - * this issue. - */ - if ((flags_ & StreamFlag::External) || (flags_ & StreamFlag::ImportOnly)) - count = count * 2; - - return dev_->importBuffers(count); + return dev_->importBuffers(32); } int Stream::queueBuffer(FrameBuffer *buffer)