From patchwork Sat Sep 7 14:28:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cheng-Hao Yang X-Patchwork-Id: 21199 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 030DDC324C for ; Sat, 7 Sep 2024 14:31:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E096263504; Sat, 7 Sep 2024 16:31:37 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="KNaC4HGa"; dkim-atps=neutral Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 425F7634EE for ; Sat, 7 Sep 2024 16:31:30 +0200 (CEST) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-2055a3f80a4so22202305ad.2 for ; Sat, 07 Sep 2024 07:31:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1725719488; x=1726324288; 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=uFCyayGX03aYOPVPXaPrf192CZnV0LxtxK3RtRGtom8=; b=KNaC4HGawqqV5OlX1YjdoZo2gPaGUtiowq9XKWkaBkHkZVQZYM3vtc6qQJr6du3mEi c3+mVlnSzhIjxLtdh9lzc05T5wx77sGggmFkwmJ10OEDGERyme7I62R0KDbJhIwYBiG+ /0+dmr3i7U265OU17DEsp3vOct6m4nZVSmNhs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725719488; x=1726324288; 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=uFCyayGX03aYOPVPXaPrf192CZnV0LxtxK3RtRGtom8=; b=NQ8MkYAgpm03Y/sPyxdF87xCfQDaAeVQo2N9FIrzPF9zObcI8ShEd0xzz1F3kZ/+wp 5acFF9bjqQJWnm+79t5wrbzKmmfiwHuABBhOFoE0U6yJfSS2pad4NFnm94OpblYihErk gY0JzdEZTmaS9yRYPYwHZXuO8RPxX1rRgkIKNZRyE/ndBcgU6esVGrUW34UQrGsDuPeJ On7of8iCGDt9v+6yKjfUM5dUEpNNesdW6cz6BPW5g5mDJZiI14sW1PsJXSAehGdwNesn OgZx1rrZx23z/YbBj27zXBqPVfXNt+0ex9R24JbGVfRrfElyEpPaj7gpP1dPEkYmiuHY 4RkQ== X-Gm-Message-State: AOJu0YyEIiSoDWcdzpyWQjF/Cb6u9a/i1GnlCvD49vkaLNvwqyiLSufu /TDdYr57Z1dyKkuoOzGqcV7PByXr1x76cqQiHojlR4d4wR84e78RGjZ+qas2EHLxVE9o7umHNOi 9xQ== X-Google-Smtp-Source: AGHT+IFnSJDdKSGFKgr0Z/nK4wzh6QgHgVNo8Z+Bez3TwS226gXxSaUXwVexzgUOmlpPZK0PXYeifA== X-Received: by 2002:a17:902:e885:b0:206:d69d:9ca6 with SMTP id d9443c01a7336-206f04e1af6mr80070055ad.10.1725719488076; Sat, 07 Sep 2024 07:31:28 -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 d9443c01a7336-20710e33974sm9208935ad.104.2024.09.07.07.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Sep 2024 07:31:27 -0700 (PDT) From: Harvey Yang X-Google-Original-From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Harvey Yang , Milan Zamazal Subject: [PATCH v11 7/7] libcamera: software_isp: Refactor SoftwareIsp to use DmaBufAllocator::exportBuffers Date: Sat, 7 Sep 2024 14:28:32 +0000 Message-ID: <20240907143110.2210711-8-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240907143110.2210711-1-chenghaoyang@google.com> References: <20240907143110.2210711-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); } /**