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) From patchwork Tue Jul 25 08:55:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18884 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 7E0B5C324E for ; Tue, 25 Jul 2023 08:56:15 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DEE89628CE; 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=1690275373; bh=sEo5i0JBMJK+CMRdb03BizI4iYWkNP6Ms99xtpH7EB0=; 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=m8nTHmnn1UosHVsEKQK5wurNdnKOLE2D3xMbNZkK0OqEprWBdgI3F4AWMsLafys5P Z8jqz8eF01yvxhLWMq0dJSJfZgqET3f372PDZ0PozGion5HJKqFCK95edfQWO/Gv8S g/QW01Qfb5gG6+O/oiMwHguxSLCiNh7QaKVodoJkBzwNwqO9mjwJ+pQT3TZ7LtvsFY lfsNMLX8m0H8tsJhsGXBNJh1smOh7kjOV60+853QAMXRZDFqyUV1J0dZgFaMtfKHhf WP4ZcB6IE7ZuIvjqa4cpFkUG/jPVlW22f0kZLPpH87RTd5FUyEcaQSmweqpbmPHwyH CZ9L/RpWz1oQg== 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 6E4BB628BD 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="i4D0388w"; dkim-atps=neutral Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fd190065a8so52802085e9.3 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=1690275369; x=1690880169; 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=Pd2kEij9VjyHTUoVWggtxO435U70d2fcStdok+PbzcU=; b=i4D0388w4DkzOX+eTwo7VHSfBJZrRArg43MzSud+oFuO6Q368uCq221PpaumB7EBaJ hcNi9KxoDPerCstcB0zWb1KIXO2gaPHzJYKanKPAuU/yRn+bHmysJcjJFSPIE/1p4DG3 RqKuMkShp0ulPzEQincL7M06Cv8H6GmlpfLT7WnIh2pvp9S5PHgr0io9wChJeCiZ7Fot 4jIOQwACyldpriDyIO3/macr1IZ2C0cnXvU+z6YzxRWbgXHGCfeAMGl6NvbcxN+i95zR c6cODcvwKbxun1HzdMONfnQwNYUCFcggzkc47HJpD/fLaTRXrAsOKRm4ZWMqCOW1F+N/ Wp1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690275369; x=1690880169; 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=Pd2kEij9VjyHTUoVWggtxO435U70d2fcStdok+PbzcU=; b=TvnMoVsXeaev4e1djzGF3h24qyqS7pMh0ST/q6Zqct2x1nNw/oIVT2rY0G7RcJkJJu FZXm8jp0e5ouHDJxP1DQMKzkL+s/rPHd/2ayNABsmz88v4z9ozR0MOgfQLLGulHi+jzw wMV2/HSA9ZDsUURzMiPMWjznONTtkZWT/v3nviCFnfDFZI/LUENLWaRP3vJNvWqE39lo j/PbaSC4qsDiIuKpVWjykx1H0EunD0uZLEQQYL4u5+hJ/uH2m2WcTszTlYofEue/DXHv rn+1hRayPxxCtAnVdfxt1lZA1PIpvMvjBwop3g5f1fUg9zr9hs4RYDxdwhtcUjRsYH7A lnoA== X-Gm-Message-State: ABy/qLZL2aiXwJNd1KAEg8vWxfmVQjQQ9jfX4NFWDNevCrB4zrwqda0j 2j0HlQQrJ9gaO12zcaj/XlKqt5qZBAfcQ6lYJpWQVg== X-Google-Smtp-Source: APBJJlHepyjHyPbMZfI44y5ht2zOB0CPPBWbAuDKkFIBE54Gw4XpNY8IAIkIzGHRkHToFSaG2rqbFg== X-Received: by 2002:adf:f04e:0:b0:317:5e5e:60e0 with SMTP id t14-20020adff04e000000b003175e5e60e0mr4725830wro.28.1690275368889; 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.08 (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:38 +0100 Message-Id: <20230725085540.24863-3-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 2/4] pipeline: rpi: Remove additional external dma buf handling logic 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" There is no need to distinguish between dma bufs allocated outside of libcamera and internally allocated buffers. As such, remove all the special case handling of such buffers. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- .../pipeline/rpi/common/pipeline_base.cpp | 16 ---------------- .../pipeline/rpi/common/pipeline_base.h | 1 - src/libcamera/pipeline/rpi/common/rpi_stream.cpp | 11 +---------- src/libcamera/pipeline/rpi/common/rpi_stream.h | 2 -- 4 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index 179a5b81a516..f244edc68a85 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -1391,11 +1391,6 @@ void CameraData::handleStreamBuffer(FrameBuffer *buffer, RPi::Stream *stream) */ Request *request = requestQueue_.empty() ? nullptr : requestQueue_.front(); if (!dropFrameCount_ && request && request->findBuffer(stream) == buffer) { - /* - * Check if this is an externally provided buffer, and if - * so, we must stop tracking it in the pipeline handler. - */ - handleExternalBuffer(buffer, stream); /* * Tag the buffer as completed, returning it to the * application. @@ -1435,17 +1430,6 @@ void CameraData::handleState() } } -void CameraData::handleExternalBuffer(FrameBuffer *buffer, RPi::Stream *stream) -{ - unsigned int id = stream->getBufferId(buffer); - - if (!(id & MaskExternalBuffer)) - return; - - /* Stop the Stream object from tracking the buffer. */ - stream->removeExternalBuffer(buffer); -} - void CameraData::checkRequestCompleted() { bool requestCompleted = false; diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.h b/src/libcamera/pipeline/rpi/common/pipeline_base.h index f648e81054bb..8ee20a1b6d9b 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.h +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.h @@ -193,7 +193,6 @@ protected: unsigned int ispOutputTotal_; private: - void handleExternalBuffer(FrameBuffer *buffer, Stream *stream); void checkRequestCompleted(); }; diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp index e9ad1e6f0848..74b5abf447c7 100644 --- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp @@ -78,16 +78,7 @@ unsigned int Stream::getBufferId(FrameBuffer *buffer) const void Stream::setExternalBuffer(FrameBuffer *buffer) { - bufferMap_.emplace(BufferMask::MaskExternalBuffer | id_.get(), buffer); -} - -void Stream::removeExternalBuffer(FrameBuffer *buffer) -{ - unsigned int id = getBufferId(buffer); - - /* Ensure we have this buffer in the stream, and it is marked external. */ - ASSERT(id & BufferMask::MaskExternalBuffer); - bufferMap_.erase(id); + bufferMap_.emplace(id_.get(), buffer); } int Stream::prepareBuffers(unsigned int count) diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h index 6edd304bdfe2..ca591f99cc45 100644 --- a/src/libcamera/pipeline/rpi/common/rpi_stream.h +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h @@ -28,7 +28,6 @@ enum BufferMask { MaskStats = 0x010000, MaskEmbeddedData = 0x020000, MaskBayerData = 0x040000, - MaskExternalBuffer = 0x100000, }; /* @@ -78,7 +77,6 @@ public: unsigned int getBufferId(FrameBuffer *buffer) const; void setExternalBuffer(FrameBuffer *buffer); - void removeExternalBuffer(FrameBuffer *buffer); int prepareBuffers(unsigned int count); int queueBuffer(FrameBuffer *buffer); From patchwork Tue Jul 25 08:55:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18885 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 2E4A8BDB13 for ; Tue, 25 Jul 2023 08:56:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 679B7628C7; Tue, 25 Jul 2023 10:56:14 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1690275374; bh=1fnLpr1wa84MpD0IMDou9Rq/4rFrHRBJBNExdpYPyao=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=oC4S3EG4NWUWjxGysTO38suIJzlF11jtLboTw8DqAyHspFydfBB1A/gA7uemZKo/I WLY2adtjnwmvnNCN7RiHfji2WjcRIKlvd7nfnGK3JKwtsEqPLBfb3yp2vdT/vVZYhO uWjD/O+I+slBnKG92/M6rqT9JJub0+DMC8zL94sBnco9fgyQIVqeXKVZu3iirmk+v7 dQjWnjVE5N4SoK21b1GfPQ4n+9qgsA4QoA5hsJafXCH/k2IZL2T1AVl3h9frm6RnAw jM+QfXbvPNttQOqAEJl2Qr3nszs4HMsDImQbnO4VHNMotx4N8qkfYxWsszFkWDaLSo CBCdu6Kv35A5w== 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 10200628C2 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="gUWOVwa7"; dkim-atps=neutral Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-3172144c084so4870565f8f.1 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=1690275369; x=1690880169; 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=afYDoMhDTlrP7nKJ5B2hFBGcqavnrUzYmRNnMdv926w=; b=gUWOVwa7qw4z1QrPq49CcZj/cKqYKq3pUFCPJzzXP8aeVyffDs08RlC67iDJI4stgA DSGcQXR/8pDsy37Jm2u+Aujx1ER2EsRLu2TIzG7bwbTBFitb4p1xM74FMudg+FTYAKA1 jIbpdWdbFiEE4FxhUc4DW1LxIeMCIgY25SaIPjSbEVV/+OSqEwlSttcKPcarW2o1VBNn lhPUOexTtv8kvfESLl2riA98GVcOuwN97BUAu1x32fzRoxmJ18m+9UUM2m6ffYu/TfJO tO3L/65uJkYxOWOckDL21bGBWvOB6jcgEh0Wq4e6dkEYJp74xP0buL6NeXPHWKvOsVdW 9Rgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690275369; x=1690880169; 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=afYDoMhDTlrP7nKJ5B2hFBGcqavnrUzYmRNnMdv926w=; b=NIK/rGesX7ajygQVmsd3ikgBmY33QFe0MIXnRDcVodrFDkt3AayqvMi3UcbDkLepY6 wZlusvbzjPAXAIpegmKAMhZ/z28UQhwExcNvHcLPiNWTSivFLVYpn1oAtuQJbGxRtpji ERjW1RpiaWs3vTCgcRGVvcQZWEVjLwHiwMkOxLJkStvsJfloGymZKcGoomsWpmGGwLEa AGZ6SA6p+PJKh12XtrXaMhVmkmn4keqXiQcmrbMssbe757i255+DByHFKiAjItsSQ3NB b2qXq/NFLZxDpu3wajJ1PIuh/VR3HxjrrsPvXqw82cV4FgzST6rPalgoX1I3rxESoiFD fZiA== X-Gm-Message-State: ABy/qLbdcOEDLqKIb4dvbAcvJjTuRtH+NsHL9acXY/qX4w8mvAmMhM0o KtI0XhiwxXhopasVtj2kzQSkzGTNk/vcRp1gGEgWDA== X-Google-Smtp-Source: APBJJlHR5VouFhGzZU7N0gSuABr7Gyth/eOiwHVSvNqmih/oLr4OtcOTT2YqoDllTkcqTS5lzvfwmw== X-Received: by 2002:adf:de0b:0:b0:317:6edb:6138 with SMTP id b11-20020adfde0b000000b003176edb6138mr591310wrm.62.1690275369492; Tue, 25 Jul 2023 01:56:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:56:09 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 25 Jul 2023 09:55:39 +0100 Message-Id: <20230725085540.24863-4-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 3/4] pipeline: rpi: Rename RPi::Stream::setExternalBuffer() 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 Cc: Jacopo Mondi Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Since we don't distinguish between externally and internally allocated dma bufs, rename this function to setExportedBuffer() to clearer on its function. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Kieran Bingham --- src/libcamera/pipeline/rpi/common/pipeline_base.cpp | 2 +- src/libcamera/pipeline/rpi/common/rpi_stream.cpp | 2 +- src/libcamera/pipeline/rpi/common/rpi_stream.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp index f244edc68a85..fc0c0ec3c53c 100644 --- a/src/libcamera/pipeline/rpi/common/pipeline_base.cpp +++ b/src/libcamera/pipeline/rpi/common/pipeline_base.cpp @@ -764,7 +764,7 @@ int PipelineHandlerBase::queueRequestDevice(Camera *camera, Request *request) * outside the v4l2 device. Store it in the stream buffer list * so we can track it. */ - stream->setExternalBuffer(buffer); + stream->setExportedBuffer(buffer); } /* diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp index 74b5abf447c7..e1858c731f57 100644 --- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp @@ -76,7 +76,7 @@ unsigned int Stream::getBufferId(FrameBuffer *buffer) const return it->first; } -void Stream::setExternalBuffer(FrameBuffer *buffer) +void Stream::setExportedBuffer(FrameBuffer *buffer) { bufferMap_.emplace(id_.get(), buffer); } diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h index ca591f99cc45..d1289c4679b9 100644 --- a/src/libcamera/pipeline/rpi/common/rpi_stream.h +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h @@ -76,7 +76,7 @@ public: const BufferMap &getBuffers() const; unsigned int getBufferId(FrameBuffer *buffer) const; - void setExternalBuffer(FrameBuffer *buffer); + void setExportedBuffer(FrameBuffer *buffer); int prepareBuffers(unsigned int count); int queueBuffer(FrameBuffer *buffer); From patchwork Tue Jul 25 08:55:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18886 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 9AAADC32AA for ; Tue, 25 Jul 2023 08:56:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2EC92628C3; Tue, 25 Jul 2023 10:56:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1690275377; bh=w52ZtUyaSnM/AlMnx815Cq3YiwqKNeCY+/KXe/MWJ3s=; 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=Lsj06N7WZ7jaTDPbK6hcnTVbIXiHHBxMRqaNxODTxue8E01Nm0NXSVx82LfcrO+PU CCOkHpVShqaRf0EXzNfCH1pMhhyX8e7nJONQXbhCcLTB0+WRJeoIdq4ycfwa9ppFZh OKQ8Wu/qqmwQGMUWKfKeJEyqVADJnsM1bFr7mthkzFYueMQiuuK/Yjj3MPAi5hjnid 1QvbGPj1+APKfrNxODHu8BEzVtUZ8+fTuXXUwPEpBCdd0castRV9ZN6eng/HcJAYeo PxBvWDVQjv+kW5iIVIWGmhKWNvvB2O0x/YbqH3r1ncbesT9Y45DpQ6fvIUQLgcXuWY jSy28VxrJPljA== Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EEA4C628C4 for ; Tue, 25 Jul 2023 10:56:10 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="n04gQI+O"; dkim-atps=neutral Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-31751d7d96eso1951497f8f.1 for ; Tue, 25 Jul 2023 01:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1690275370; x=1690880170; 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=dzH3CkVjx/MaO3z1Pv7TXEpYfMeVEJrxvRrRlFyI6JY=; b=n04gQI+ORdyM5ddgdQ/7ZLG+/Qj2MvRv1hbgrhLUrQcyuiXGGcgoyPjQqrAvPpNnHd HHmrIm8Us4RrTmiY4Eif6CVfNQ37j5EC+leJ6PjI1C+mwIcqV+GR+GRE4LECphjUCKFd UsBHZWYqa6EOuO1D+d3FtLZFtHPBkRJNn1DC1C++l1ktiSUtsBEa4DmfKbE0VhQ9Z6s3 QhIpp5iTDILUYQFHlOATEDZBpbQvFYdgjkf6NJwZcUsre5GvFf1k0eLdE508QOBk1MNV iv6FQpp7YOSW7kKge3ZL+wIzUOxoPbUSLAOegWalb3wijwd6/HwnuMIZq8W3os7lO5a2 3/Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690275370; x=1690880170; 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=dzH3CkVjx/MaO3z1Pv7TXEpYfMeVEJrxvRrRlFyI6JY=; b=MRDlfj6gmjWkr0T7WviAZaD9sczzX8876v3V0XVNhSrbfJIw0ghl1mum/Hal7WM9Oy yaWNDRVhvyj3HTR1uC2QRgQRFJ60r1aL/mxfqauuvFuBI8etEjPvBjOlGvsqrt2fY0OL baediVsPfkXgB2kfaQ2lDp1/sns92BLiWX5TdKu5iTpl2fd7lGii/OV2OeEw8n3Oz0oX Ew+/SKpt345LtwYl3+VKD/fePqa0wxzPghIAg75D2nAQQF1wYs+5U1GesRu0nNcRaaAz AgMzOhdEl3BhYxL5pveFVG7YGreWupytZnQ+3R2EFvt40A09JFawgCLCF06OtQNhNjoO 8LNQ== X-Gm-Message-State: ABy/qLb2Dd2HxPnRFXfpWBVUmkhwOGb1EcRtdvCE9wAL7RTS9y40Ahrq b+OeJIUfTBZhiZ0ue0gDeHT1McNg7CqkaANW+6XYzA== X-Google-Smtp-Source: APBJJlGgoolnbcpiXwFze5KxCb7yyxjvh3je4xVFwCoX2poOzSPXeuPHv1Mbn5EZC3Zg5be/0tH0sA== X-Received: by 2002:adf:e64f:0:b0:317:58a8:bb4 with SMTP id b15-20020adfe64f000000b0031758a80bb4mr4629534wrn.40.1690275370109; Tue, 25 Jul 2023 01:56:10 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 01:56:09 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 25 Jul 2023 09:55:40 +0100 Message-Id: <20230725085540.24863-5-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 4/4] pipeline: rpi: Simplify buffer id generation 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" Replace the buffer id generation in RPi::Stream with a simple integer counter since ids don't get recycled any more. Signed-off-by: Naushir Patuck Reviewed-by: Jacopo Mondi Reviewed-by: Kieran Bingham --- .../pipeline/rpi/common/rpi_stream.cpp | 9 ++-- .../pipeline/rpi/common/rpi_stream.h | 44 ++----------------- 2 files changed, 6 insertions(+), 47 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp index e1858c731f57..d1310635c091 100644 --- a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp @@ -53,7 +53,7 @@ void Stream::resetBuffers() void Stream::setExportedBuffers(std::vector> *buffers) { for (auto const &buffer : *buffers) - bufferMap_.emplace(id_.get(), buffer.get()); + bufferMap_.emplace(++id_, buffer.get()); } const BufferMap &Stream::getBuffers() const @@ -78,7 +78,7 @@ unsigned int Stream::getBufferId(FrameBuffer *buffer) const void Stream::setExportedBuffer(FrameBuffer *buffer) { - bufferMap_.emplace(id_.get(), buffer); + bufferMap_.emplace(++id_, buffer); } int Stream::prepareBuffers(unsigned int count) @@ -149,9 +149,6 @@ void Stream::returnBuffer(FrameBuffer *buffer) /* Push this buffer back into the queue to be used again. */ availableBuffers_.push(buffer); - /* Allow the buffer id to be reused. */ - id_.release(getBufferId(buffer)); - /* * Do we have any Request buffers that are waiting to be queued? * If so, do it now as availableBuffers_ will not be empty. @@ -210,7 +207,7 @@ void Stream::clearBuffers() requestBuffers_ = std::queue{}; internalBuffers_.clear(); bufferMap_.clear(); - id_.reset(); + id_ = 0; } int Stream::queueToDevice(FrameBuffer *buffer) diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.h b/src/libcamera/pipeline/rpi/common/rpi_stream.h index d1289c4679b9..889b499782a4 100644 --- a/src/libcamera/pipeline/rpi/common/rpi_stream.h +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h @@ -54,13 +54,13 @@ public: using StreamFlags = Flags; Stream() - : flags_(StreamFlag::None), id_(BufferMask::MaskID) + : flags_(StreamFlag::None), id_(0) { } Stream(const char *name, MediaEntity *dev, StreamFlags flags = StreamFlag::None) : flags_(flags), name_(name), - dev_(std::make_unique(dev)), id_(BufferMask::MaskID) + dev_(std::make_unique(dev)), id_(0) { } @@ -86,44 +86,6 @@ public: void releaseBuffers(); private: - class IdGenerator - { - public: - IdGenerator(unsigned int max) - : max_(max), id_(0) - { - } - - unsigned int get() - { - unsigned int id; - if (!recycle_.empty()) { - id = recycle_.front(); - recycle_.pop(); - } else { - id = ++id_; - ASSERT(id_ <= max_); - } - return id; - } - - void release(unsigned int id) - { - recycle_.push(id); - } - - void reset() - { - id_ = 0; - recycle_ = {}; - } - - private: - unsigned int max_; - unsigned int id_; - std::queue recycle_; - }; - void clearBuffers(); int queueToDevice(FrameBuffer *buffer); @@ -136,7 +98,7 @@ private: std::unique_ptr dev_; /* Tracks a unique id key for the bufferMap_ */ - IdGenerator id_; + unsigned int id_; /* All frame buffers associated with this device stream. */ BufferMap bufferMap_;