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) From patchwork Fri Jul 21 09:37:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18859 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 C877BC324D for ; Fri, 21 Jul 2023 09:38:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 74B8F628CC; Fri, 21 Jul 2023 11:38:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1689932280; bh=ZCEj8eCKrQ8JXb2Rw4TILkI/lSwlca9GoIGypk5f+SQ=; 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=ffVCsFTsdgclhmfuicygCwqjPY7JtmPUeBcHYPva1qZNbH8dGAOcjqRCLC6w8kKoh jROlyAWOACU8b3F264kYNz9OammJS2Ze2jyNn074JYjoY79CJ8EWZJ9coUySDGpLkX Iu5y/wXY3FfHvXyMJHK55l9bXQV0NRN2PcuvoO6I0ecwG4nf8+t2PGdTfnpBhlexAz qVD1QGQqQZtrb8572INMhF7xVqlsQf5XQ4PJp/K4ALs+Vg8896hwWwdc0tnF5RSwTl nlzFOEp5rExEucE5+eY3jvz/0/B/wuHsYWUF/YYjT4yDyKgGN0JFi1PX0z1bOhl8s5 xxGnjXIr7hKYw== Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CC133628BC 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="gO7rvBqH"; dkim-atps=neutral Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fbea14706eso14796945e9.2 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=1689932278; x=1690537078; 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=iJOXQNSIm0Lr1/Voilx0gzPy85rkKkpt1G8dmzJGcVs=; b=gO7rvBqHGF6IVV5E7FomxdtAv0YMn3wv/IZsEmE4USdshv4dZljwWvbPciettim+vo K/WKdpVttQDuDCm0cYc14DHYwq0gbe/s1T3xwB+5tvCnPLTRT2IORTC9ajCc5k0tOyEG aJOr/lNhT9bmkWEnqcCYmgKuInojxhif78fvXcI8iuxzGjYom6hY7k2Cz/rg6AlefcVy KFKgSnKDT0URG1ql0NjiXBrsb9lZpauDKYQLf3B/RD7TLDcIXYQmErt8Z3EPpWvXlNhh Rb8bYf8zSv9ZY/9K88hQ7h9KlffDj6Xun9d4ExsosJ3Gr5r4nLsWAiHQ1molUb4lI6fR NEGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689932278; x=1690537078; 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=iJOXQNSIm0Lr1/Voilx0gzPy85rkKkpt1G8dmzJGcVs=; b=TKoiZk+7ayqcIRNAnK9e/qF3tPgogPxKJUvTFwGHiD60mpQXwdtP1mUQMSMliSxLX4 GnZWX15UBVW3Arzj9De0dFWDTrObKRxRl7EtAhW8rADYG/uBfV/rxaOliKLt+0v+/6vb ZUpgGdi+zBN7PTNsmCPHezs/GCQuCwvoXIUPfaOC7lvocGmWnqgmToRarLLIubxIE0ER KpesmV9lwDmWED9nPFx9Bh065z6LeIqj6ovFGQFimyxamTULlUFoy8tS+btlu0KRhece 9pWo9pSrrSvk42rpVwGqBPLPyMNl+OSu09gNJcqXynpmRbLxKtcElwxBp5wgygXUqD6D OHmg== X-Gm-Message-State: ABy/qLZQaH8W2LrlE8sniDSoV9HA/hLn4X+s23RqIXdEaBrR51kdZjXh T/i6gCaRhayvwP32VhNZ0cN0QBZAUjuQRkg2aC/FHA== X-Google-Smtp-Source: APBJJlGx/TZ7sKPjJGlJcnUYS9cgDpV0l0NnB48HFqqIyNF/HNuYelwrIfrKR+5EAZ1BEL5U4AZMYw== X-Received: by 2002:a05:600c:22c3:b0:3fb:4149:b816 with SMTP id 3-20020a05600c22c300b003fb4149b816mr966696wmg.8.1689932278303; Fri, 21 Jul 2023 02:37:58 -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.57 (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:57 +0100 Message-Id: <20230721093759.27700-3-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 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 --- .../pipeline/rpi/common/pipeline_base.cpp | 16 ---------------- src/libcamera/pipeline/rpi/common/rpi_stream.cpp | 11 +---------- src/libcamera/pipeline/rpi/common/rpi_stream.h | 2 -- 3 files changed, 1 insertion(+), 28 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/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp index 1d05c5acc0d9..07b8de6875fe 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 Fri Jul 21 09:37:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18860 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 74C60C32AA for ; Fri, 21 Jul 2023 09:38:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 956F0628CE; Fri, 21 Jul 2023 11:38:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1689932283; bh=yItyVuO2VDL507HlcVK+PBcaMIE7vWWz+HZ9prCd06M=; 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=A5Mk1vbhh0YJt8z0qEixNedSQH8kPSnT2q3Gt7DH+xeniAHBU2tBt42W6eGOM2T4c DgvGHKlBs2lgzyU2APA+HTm0+WKqmiUMRfMvAGMV/Ch0vLMgNqqcKfFA7M5RoP2aWj 85z+iErym3v2TYaQ3RSeQdvXrQ84NeY4MN5f/msNjQ8J737sDhs4ICLuWt6276HKcH pWKpqsmvASqI64g92W2LCMFQv6U8JPv8pThir8PTh3hyGHolgxGRR09BkFthLbtdFt 7FONqvdq57YxFmBxRWcTh1pV1JTQ8VffxjNGBScSyd6dvVi352Vh27LPmf+Jit1voa MbnOdUua73+DA== 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 B0E31628C6 for ; Fri, 21 Jul 2023 11:37:59 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="V+WCoVVU"; dkim-atps=neutral Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3fbc77e76abso14448605e9.1 for ; Fri, 21 Jul 2023 02:37:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1689932279; x=1690537079; 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=3uFxpASj7huUvtuSvmY8zK0VJmpliDDCi26iSvJYNH4=; b=V+WCoVVUSBQLU74Kf75rQIIkZpssXtnlvbmMCTPNyDNd0GFOH6SfxyRmTdM+yfJSXE EhtfaUHOffrnwuTI4uz7z0EY/+aiN+Ov2rwPcpZteDKmEwzysOSUw4EITJnxAKJylfPq uMpsxeYziPn+CS1nmYQYvnqE0EX2PCy8lz23VQ5yVCm9jAhQim057X2kk/bYbXxVdYK9 xAP0X3kc/4hHV+BaOxv14xzDCQ8pudSiS8rkxFssakvz/gA5aeB5pcxlqYlKXRkSQ6Ww REnrbo2BBUL1orck3xIQe0pWFXP3iW2nIJ08jdEaottQuMViqcFKU3XPTxfOa2XDt2Cz dJnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689932279; x=1690537079; 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=3uFxpASj7huUvtuSvmY8zK0VJmpliDDCi26iSvJYNH4=; b=BHyhcEOSlqK+nky7m0+Kdd81oIgYEi14u6NmF2+2WxQcrZ9Da6FO9ZcfkiiLWLitSl jrABE97Q1rxsHDE8uGMcuv0OzaK5VCeEuCArUtGn/bhou8PSXFThhjkFVB9wkpzxqHDb JfXQ/AO8V3s/CxtRIGVerCk+5imAfD+gIPdz+9MmH4OdHhQjW+VlenwLRIaPRzX0aix1 Y1vttLkerxbdZIVwInB9EOc4E9zt9TD7mF4RQ4XFkz8fT3GZQU+BxZmnZjWc+9rKZuYq ZXoB12y1B2/4htZUDOkIeG2xArnROs46KmTuPQHiKCdtYdz199UpmLxpn8U9nmnvLL9L 7vCA== X-Gm-Message-State: ABy/qLYuO50Y/+v5tpL9Mdfu/93jHQtaSZW5Jhq/IeKPBxqYpYo/CYBJ mmAYclfBRLwQTzoNIHToZHIaEdjUn0gfMRnkZKgZnw== X-Google-Smtp-Source: APBJJlHyTYqlbPymtkX7Yy86CSsyPtyb9Ks+S4IMOR8Js/Bbxzpk5vMQcdbzxCKr5JyZvsqsb7OH5A== X-Received: by 2002:a05:600c:d7:b0:3fc:1a6:7764 with SMTP id u23-20020a05600c00d700b003fc01a67764mr946751wmm.16.1689932278929; Fri, 21 Jul 2023 02:37:58 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 02:37:58 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 21 Jul 2023 10:37:58 +0100 Message-Id: <20230721093759.27700-4-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 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 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 --- 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 07b8de6875fe..e24531e171c8 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 Fri Jul 21 09:37:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 18861 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 7CEF8BDC71 for ; Fri, 21 Jul 2023 09:38:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2F9CF628BD; Fri, 21 Jul 2023 11:38:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1689932285; bh=3CbGSLrQmTwZnhFjxxJdZwHpkN2gVzhIXN1IK7P3A70=; 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=pDhgGCCgY97rBf2PWOgADBx+KeqyWfImWae2C+slnvBO2hiNxvNKzRB9cWwKGMSET DsE6gHE7pppZoPpj+H5lDd6MKa8rihmRNBpJlrC6k+TTADILI1DdtGZsDPf/toucFN 68CEXyW08ArQF2D2QklURletiM3bV4GOlwpta1+nX2Nca9Pcpks81HGjnY2aq32Sio HMbpsMCVRVmN3OCvGd/HDbkWYLTPSmB22+e+idIv3uKUPi/ItohA7vzllYAPpTe6Ix lF7qTxKACgqNUmiWE3psWV4nA6pNEUB1YTZKi+yZKVoJhGZgJzMZ1Y4m51ncIhG/7u yse+0R8/AAiJQ== Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5868B628C4 for ; Fri, 21 Jul 2023 11:38:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="mqRKKbGB"; dkim-atps=neutral Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-3141fa31c2bso1280390f8f.2 for ; Fri, 21 Jul 2023 02:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; t=1689932280; x=1690537080; 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=DXvCa+21v7+8EeLNesmlzeQop9M4JkysDUnJt+FZOOI=; b=mqRKKbGB4v543xessxaFNytREX8e9lWKGA1XiDFMuG8atuH+2AMxmIS+5uiU0Pv0ef bhRkH5oGfmoDICP0sSyv5toGZ3BYXjWpp2CYoQTFlp/wyviSUP4RjGkMyHYGLxDKcaeF yHc/BcKX3CT1clgJfbvrsA2BYDsDQWvxfaS8qWwFq54Ho624+q9TCZ2lvZgDfW8ITiy/ vYKS6etFlPEPtFlLNXyEyjWEvHRvTuFX1GCFmiGficp2KEMIrVEykaXze92NRZ7gRZYm /Y/hoaLl0yeseQskIUOw3jFsjGKptzcsWNyUSjbp/EnNvz+s5BxPSmTDy4G1eVwIwdyY r5WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689932280; x=1690537080; 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=DXvCa+21v7+8EeLNesmlzeQop9M4JkysDUnJt+FZOOI=; b=eiyWIb5shejm41in3N3nafIqs+F5ShwgU3LmmjJv5vKXQdFY+GzHHOEM8GVzPb47Jo wdprtQhkMXnPJ330eVQB/2eKkcXdLN7zZdonaepWFoukoQvCM6sheY0iSR7M15Encl1s DHwk4wL4LGTGXELUSqDAaU6CeaQLbyAK8RIG46LvCN5VhT4YlqBgfD0iNu7Sf/4ig0lL 8i6dBwVJuwTPnfkMP6/90cGA4VjfiitihuVYerc7JaB1OSrXzJa3gu43aaZgIoQ4zZVb euc3gR9FYhoRTBj7MwrKNSkgbMhiPtl+uLr32SAksm3sluDIHeLRuJxaRps/xHsRroaj Ioyg== X-Gm-Message-State: ABy/qLaNULKyRnFPzQypkvtcgeT2GtX3q/fq/xI5k9lNliDEuGT2epYb fZ9eD37bzp4CP7xIJUk0VBB7KpEQweDzgM1yubWANA== X-Google-Smtp-Source: APBJJlElhkt/xCcR8mbw9LEJE6ILFrT0G1U1Bt1jN1UmjrWq7EWnunvPFo0ozCy6ikNXWLFuYBCpxQ== X-Received: by 2002:a5d:4b42:0:b0:315:ade6:a52d with SMTP id w2-20020a5d4b42000000b00315ade6a52dmr944574wrs.19.1689932279768; Fri, 21 Jul 2023 02:37:59 -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.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 02:37:59 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Fri, 21 Jul 2023 10:37:59 +0100 Message-Id: <20230721093759.27700-5-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 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 --- .../pipeline/rpi/common/rpi_stream.cpp | 9 ++-- .../pipeline/rpi/common/rpi_stream.h | 42 +------------------ 2 files changed, 5 insertions(+), 46 deletions(-) diff --git a/src/libcamera/pipeline/rpi/common/rpi_stream.cpp b/src/libcamera/pipeline/rpi/common/rpi_stream.cpp index e24531e171c8..d32163d3fc0f 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..cc5d3f4afad4 100644 --- a/src/libcamera/pipeline/rpi/common/rpi_stream.h +++ b/src/libcamera/pipeline/rpi/common/rpi_stream.h @@ -60,7 +60,7 @@ public: 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_;