From patchwork Tue Jul 25 08:55:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18883 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 A605DBDB13 for ; Tue, 25 Jul 2023 08:56:13 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 415C9628C9; Tue, 25 Jul 2023 10:56:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1690275372; bh=ndwGG39Zi/V4yxjywlwnNVk3qm5qDJ4+3Q6rmZjUI1w=; 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=NGuwR2VuCqMBEd6bBVMZyVlk5U7TZlGaA6X07/DW7+RIZANO4gIIk6dWCrJuNSwvv 8r1Cu348hdQLWA2o+Hix/D+jZM7beQg4M7vEH1YL7L1rLdcjgG9mQIh/kn3w2AjgE2 vlESi7FCAu0Saa0PbyG//V+huTT2NzNrmQDJ2qYi+CpWZ+mD4NQ8DRDcIV40umlxXl pEw9yrLZh+b1j7VjndaiwVfRqMbCff74j1YiRKF3GftYZ4i5qU2C/ss+vbwGGwMLKY Rtyb0k5Zckgp18eBFzvKsMMU9xqWENNTpyzvwKcL/pjdrIq/f3m9Dyqew+y8LTaZhJ F+dKd5GvaR2Wg== Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E9F1600F7 for ; Tue, 25 Jul 2023 10:56:09 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="t234JUu7"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-307d58b3efbso3979651f8f.0 for ; Tue, 25 Jul 2023 01:56:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1690275368; x=1690880168; 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=i0qfxmPM4aPbKwF9/i7e0Pipi64he2NaFnBbAWHpLMg=; b=t234JUu7TL+1bEeaieC+sbjjqwb5kHSTZkhxqc0oBTI/ZmVFajc7X9uEVhc+HS8s2H 7yZNZ0wiJxaq56m3LZHXMrBSJaJ0SKEyh2qDVAyzthsjb0UuyLJI9VU9LZTwnZ23nb8B LdxCMMfzRY/AYV5LplfMAT63djhBQE0mKVBcKWGoDcpCZzuk7+nBspiMZmnJZW7ZIm36 eHP8UZN2Rlqn8SZaflZ4LJVxFLPus7UVJfD1luaVQ7zLi0MFE3h8nrGMNzxpEPT6sydv eBfhP/otpgnUwy8G12rG8OjuvQaPikGM7lyxAGl1Yc5Tz7xCk2HB2qPt99oIYvstQxXd ryAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690275368; x=1690880168; 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=i0qfxmPM4aPbKwF9/i7e0Pipi64he2NaFnBbAWHpLMg=; b=kvaqhcIeIJKydx4saa4/53+0pxZGO/j9Lt9DPJopyS6tOJ3gNp9gkaIpr4P+LaN5v8 Bj72uXkCTjEscSP26y8uuciv33zuHJ1frZkDlPeRX0DD5IdfivHFhyqjP5atDhMNO4Jz Tbbmjg3z1/mROnhGsHrwFP/g9e9fRabnttNXh9Dh2F2gsANq9KLqoOofzAQHzmadnsI6 u1iXwh+Y0SG3FeRaLdQwFlPTzeoj4wUB5o/+JCnh673pOSZqWoCzhiNerx7r/tALja2B oKG6ltaVDa22uo4BiPZ0/670jje8ScgsDRcJjJLgMerW16JFQpUQ8UM5v9aCeYMjKq1U LHlw== X-Gm-Message-State: ABy/qLbyCR9gBmxeqYX43WXOnrs1CxOFXBWVIbHqOFfa7yH3fM7hs8EL FQZ1dBtlJU2fmZKvgwd/Pa//1bcIb3dvMJGbGj+Elg== X-Google-Smtp-Source: APBJJlGzHBdSKbGoKLpbBOy4nOsxFY4/MQkqUbp0y99ZZd6QeicipK/y0WLukUU88gYln/IXh0qWaA== X-Received: by 2002:a5d:6244:0:b0:311:142d:5d97 with SMTP id m4-20020a5d6244000000b00311142d5d97mr8394773wrv.31.1690275368352; Tue, 25 Jul 2023 01:56:08 -0700 (PDT) Received: from localhost.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id l7-20020adfe587000000b0030c4d8930b1sm1951225wrm.91.2023.07.25.01.56.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:56:08 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 25 Jul 2023 09:55:37 +0100 Message-Id: <20230725085540.24863-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230725085540.24863-1-naush@raspberrypi.com> References: <20230725085540.24863-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 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 Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- .../pipeline/rpi/common/rpi_stream.cpp | 33 +++++-------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp index c158843cb0ed..e9ad1e6f0848 100644 --- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp @@ -95,34 +95,17 @@ 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(); - } + /* 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)