From patchwork Mon Aug 5 13:48:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 20785 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 23129BE173 for ; Mon, 5 Aug 2024 13:51:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 659D86338B; Mon, 5 Aug 2024 15:51:26 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="VzEQ7AXP"; 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 44D9763393 for ; Mon, 5 Aug 2024 15:51:11 +0200 (CEST) Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4281faefea9so60109815e9.2 for ; Mon, 05 Aug 2024 06:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1722865870; x=1723470670; darn=lists.libcamera.org; 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=J7IKhIlglq5fF7Qqiclshc+16FynHBayTS4RmODBsG4=; b=VzEQ7AXPQwrqRzj3zRGV+Bb6WcSoK9E91H35cDiI6Bt09SjYQJYJDktcei+CcCmKdF zRU2RFACeZ6s0/yJUXAvmSCyd+CcBCHvloHww58VP3e8JRY64mCXsKGCaXZjbYbey5R3 X5T+KiFyGpIDDpkBzkiWWO2sBoq9rnhrxZUsk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722865870; x=1723470670; 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=J7IKhIlglq5fF7Qqiclshc+16FynHBayTS4RmODBsG4=; b=MoYyHOfpp6y0mKsZgkXj/Xci2jw0DA/fuLk+TIvBiET83qOTqdgk8G5tczfsRf/Jqk Vg3XYBpR0SuqNpiIV8Qe7i9y5ZbNK3dLQxrK59PTNYP+8hdVOfSYnioQipiWkiJ+uq6c 0Did8yB/q6upn/u8aRWPuoOFTnUovaX49qHI8bwCcV/AQcGoLAJEv6qIj+IehSxl7XGB EExxEvAzkCwgM8k7z8OxF+/pB6Ka0/vEP/yqIlZeiSqeh7pWIEzPKPLsAA4z9sSDrDVv A/2qzP42UXDsaPYXgAYSZO1lDvKReae9pbYw1SrvbLp8aQtDbPrAZ6TP8DoNVCdTMts7 5jtQ== X-Gm-Message-State: AOJu0YwuZ5OdOgPZpXiLwqIYRrh/+IxWVNJn+0aMhrvY32kf6TX236wd yKzM9tvCUIv1KTWcPlBPqGuozSVu4Zok3l1eyxTtwHhSutFuTQd37mwHb2AImP3Bz6/kJgn5R6I f5c/UV+A= X-Google-Smtp-Source: AGHT+IG1F+T6ylHDWzslnfgfAb31rW2OIpk+c/uowHVHGW+hAghORSlcgB97cpGAQ5rQGKu6OMjRKg== X-Received: by 2002:a05:600c:1546:b0:426:5f0b:a49b with SMTP id 5b1f17b1804b1-428e6b7c1aemr87442205e9.23.1722865870522; Mon, 05 Aug 2024 06:51:10 -0700 (PDT) Received: from chenghaoyang-germany.c.googlers.com.com (49.222.77.34.bc.googleusercontent.com. [34.77.222.49]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-428e8d6555fsm137146675e9.26.2024.08.05.06.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Aug 2024 06:51:10 -0700 (PDT) From: Harvey Yang X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Harvey Yang Subject: [PATCH v8 8/8] libcamera: software_isp: Refactor SoftwareIsp to use DmaBufAllocator::exportBuffers Date: Mon, 5 Aug 2024 13:48:39 +0000 Message-ID: <20240805135104.139932-9-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.0.rc2.264.g509ed76dc8-goog In-Reply-To: <20240805135104.139932-1-chenghaoyang@google.com> References: <20240805135104.139932-1-chenghaoyang@google.com> MIME-Version: 1.0 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" As the helper function DmaBufAllocator::exportBuffers is added, we can avoid some code duplication in SoftwareIsp as well. Signed-off-by: Harvey Yang Reviewed-by: Milan Zamazal --- src/libcamera/software_isp/software_isp.cpp | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index c8748d88..5240eb3f 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -256,23 +256,7 @@ int SoftwareIsp::exportBuffers(const Stream *stream, unsigned int count, if (stream == nullptr) return -EINVAL; - for (unsigned int i = 0; i < count; i++) { - const std::string name = "frame-" + std::to_string(i); - const size_t frameSize = debayer_->frameSize(); - - FrameBuffer::Plane outPlane; - outPlane.fd = SharedFD(dmaHeap_.alloc(name.c_str(), frameSize)); - if (!outPlane.fd.isValid()) { - LOG(SoftwareIsp, Error) - << "failed to allocate a dma_buf"; - return -ENOMEM; - } - outPlane.offset = 0; - outPlane.length = frameSize; - - std::vector planes{ outPlane }; - buffers->emplace_back(std::make_unique(std::move(planes))); - } + dmaHeap_.exportBuffers(count, { debayer_->frameSize() }, buffers); return count; }