From patchwork Tue Sep 10 04:40:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21213 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 1C9F3C3259 for ; Tue, 10 Sep 2024 04:49:01 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 86FB663506; Tue, 10 Sep 2024 06:49:00 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="JEfP4meY"; dkim-atps=neutral Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A83AB63504 for ; Tue, 10 Sep 2024 06:48:53 +0200 (CEST) Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-718d985b6bbso3322523b3a.2 for ; Mon, 09 Sep 2024 21:48:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725943732; x=1726548532; 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=Nd5Nqz3r9Z4samEGwXO+wdTcH/8P3Q2sO625ziMx2LY=; b=JEfP4meYK5ZWnV3c7xjdkrnliEJHM1xIz5OhkaSsWDpOD0eT/PcWymR/KvLCMMCGU+ x05N1F3III//95V1HPoA+ZedLkb+CBFVVoiwSmkA0y4Zf5FspbfozVMIf3dap9MeHI/y lf+T6LXrGq3/GK6oU3uWzDwMQtrgjZGEtbqac= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725943732; x=1726548532; 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=Nd5Nqz3r9Z4samEGwXO+wdTcH/8P3Q2sO625ziMx2LY=; b=Y9VQygKIxw9Uda8XwSvorA35ei2Ov5o3OIhQ/7u3+oH2SyFTF2WjhwOdkFtKmsyIy2 gL+iLPvDdJ990JIo107z0lLfuU9TkslSXSR2x3NsD014mNc9QhDklN8KZuyZ0ohWXmgm amoo+KuYs+KOXW1Kzpu1MVDj+1oy2y+ESKlCIzpwj0VC+SVAJE+jD8rO3Pg4E0m29dIq Rb24TWHfxZdrUG0aFYpvWY4PLhgxdMrULt04p2g720DfcU9VlAEIuaUQdrAClnQbL7DC aT53D1wWRSrzRoZd+hyLRZm6ql62GGF/2t/qpnCMTbOEAXk/xKNuc8HJNJ6U7aeB6/bi 68jg== X-Gm-Message-State: AOJu0Yy+X7yPgLU6NctaAJHOWSKzhlSKS9WJSQoWaCZyt002HklSure0 DFTXvrsen899Kflav4TG/xjgHDp6Eub4F0294Sf9kO9O6RICi5C4YaBam3534kjR9Zq9pG7cxRE = X-Google-Smtp-Source: AGHT+IH7VTMz3yJfR6awFkIWo4j6JUGLC67x0aMNNuoRjzBrg4ORVvhtSq4PKx/pUp8Uk/jGfAsb8w== X-Received: by 2002:a05:6a00:9492:b0:717:9483:5887 with SMTP id d2e1a72fcca58-718d5e18c86mr14069916b3a.8.1725943731564; Mon, 09 Sep 2024 21:48:51 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (0.223.81.34.bc.googleusercontent.com. [34.81.223.0]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71909092522sm530734b3a.111.2024.09.09.21.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 21:48:51 -0700 (PDT) From: Harvey Yang X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Harvey Yang , Milan Zamazal , Kieran Bingham Subject: [PATCH v12 7/7] libcamera: software_isp: Refactor SoftwareIsp to use DmaBufAllocator::exportBuffers Date: Tue, 10 Sep 2024 04:40:20 +0000 Message-ID: <20240910044834.2477701-8-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240910044834.2477701-1-chenghaoyang@google.com> References: <20240910044834.2477701-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 Reviewed-by: Kieran Bingham --- src/libcamera/software_isp/software_isp.cpp | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/src/libcamera/software_isp/software_isp.cpp b/src/libcamera/software_isp/software_isp.cpp index 1140372c..3455f13a 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -255,25 +255,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))); - } - - return count; + return dmaHeap_.exportBuffers(count, { debayer_->frameSize() }, buffers); } /**