From patchwork Thu Nov 18 16:42:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14636 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 4A4F9BDB1C for ; Thu, 18 Nov 2021 16:43:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 012476036F; Thu, 18 Nov 2021 17:43:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Y5PIHFv6"; dkim-atps=neutral Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C02C160233 for ; Thu, 18 Nov 2021 17:43:19 +0100 (CET) Received: by mail-wm1-x32e.google.com with SMTP id k37-20020a05600c1ca500b00330cb84834fso8151130wms.2 for ; Thu, 18 Nov 2021 08:43:19 -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=Rd0ZYP3R2ExXSyLPu0gR7tKlyuF07AGNiEMxwDJFFy4=; b=Y5PIHFv6Vg4rHZ9oQgNPuNn38s7ZS01Td+8iqx1v+l7Rzd41dZe0A8oEoUYwoR+OfR CYbuuIQzaby4PsfSQCxX0l4EOb8U6i40wtuKgunLmIh03+Ai700lWUrqnbq72ygO3zbk dgxQLUH+3qqVo1LREQIVdFI2r9YgbGKGkHk/lpMuQwtvuH3AeFogElEO6Iit71xW/no4 auuCafkU3b4l/GaRlxY6q1By0ndAs+6sT3sr0WS6uvQ+Vw6fT3VHCA/hIiMRkX7kpEKm b+A5lO6vnks26pr/QuukWBboRkfRCB4tEgNakaWsHc+ccDa334AtT2ie6HkQD4GC1cW2 T0Fw== 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=Rd0ZYP3R2ExXSyLPu0gR7tKlyuF07AGNiEMxwDJFFy4=; b=lfkap8RwFVPEKzFXPWP0LCPybMdkI2Zqb/LE1moKOUWqGYLca3Wd7ocgdLxUn11a2c owgoGR/uIOIBv2OcbiVbIcJSAJz2T2J0eUIwBHKPCDpnqpyJF4DFdVv0NZFNFE9sIJb4 rstTL8IeBRD4irTCzCng5VWpPGhiF+5RuXOFsegxJrM2bFdBRh2ZVZ7tTxVWXJoIqQvY lsU/hLRD77DDRUswGtgBUMMLMV7CS0f37tp8QALBpj5jODXpbKj0yicfDiuWLfVn+OKI OFAPV7XVp3XVh+0rpddQLH3F7xVTxPyodnKKBDJXCQ+BGmLYmubnXiouHa6ueYtIuvND 59+w== X-Gm-Message-State: AOAM530++msI+gQORxhK/Wef/r+tSqBxqixosVA5UlvqcdERMXxLB+zy 8l5WYiSJZUiBxs/VLW0NVU76WKNmG4SaCzHq X-Google-Smtp-Source: ABdhPJx5/LQ7rzHxECuU1BF/J0FmzWC4LG6nnVhfOkymWczmuhswXlq5LWHTEachqgK6VIaolPowkg== X-Received: by 2002:a7b:c08a:: with SMTP id r10mr11385519wmh.184.1637253799274; Thu, 18 Nov 2021 08:43:19 -0800 (PST) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:328d:499d:f54a:e461]) by smtp.gmail.com with ESMTPSA id a1sm496246wri.89.2021.11.18.08.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Nov 2021 08:43:16 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Thu, 18 Nov 2021 16:42:15 +0000 Message-Id: <20211118164216.2669449-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211118164216.2669449-1-naush@raspberrypi.com> References: <20211118164216.2669449-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/4] pipeline: raspberrypi: Increase the V4L2BufferCache slot allocations 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" If a stream is marked as external, double the number of V4L2BufferCache slots that are allocated. This is to account for additional buffers that may be allocated directly by the application. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham Reviewed-by: Umang Jain Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/raspberrypi/rpi_stream.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp index b3265d0e8aab..bab80d25ad1a 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp @@ -107,6 +107,17 @@ int Stream::prepareBuffers(unsigned int count) count = bufferMap_.size(); } + /* + * 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. + * + * \todo Find a better heuristic, or, even better, an exact solution to + * this issue. + */ + if (isExternal()) + count = count * 2; + return dev_->importBuffers(count); }