From patchwork Tue Oct 22 07:43:43 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: 21731 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 41CC1C3272 for ; Tue, 22 Oct 2024 07:46:12 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 47050653A1; Tue, 22 Oct 2024 09:46:11 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Uby7vJZC"; dkim-atps=neutral Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B52456539F for ; Tue, 22 Oct 2024 09:46:04 +0200 (CEST) Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-71e467c3996so3415802b3a.2 for ; Tue, 22 Oct 2024 00:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729583163; x=1730187963; 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=HrmXusUJJiZzQBUgzs8QoLmpgKh+y0IJMlqn1YYNqmA=; b=Uby7vJZC6/q+xx9RsxS/i6wWiP/FmNjfRxX/0ss07tgxSWPYRx8w+HrODbka98frCN c1s03H9tUSUV3oDzNlrsxuzbvyWwMjoP3SqkcSdnwfl3XZufGrjh1iEN87qR8m+prdqj GvXE0k7oO0GYPBwlVT0SBEKznKRVvwFzy05I0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729583163; x=1730187963; 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=HrmXusUJJiZzQBUgzs8QoLmpgKh+y0IJMlqn1YYNqmA=; b=c0L0TiAG6dDXhKKku1poHfMPsTBiGSuwN3c9ocFigiytJV6ZQIlRHuiQrcEcQNcMDl ULFwoBOVoAIpSEKteE5+J5FEVsNlrfcTt797YSao/R0nvRKwbNnCxO9OKM9f8N2j1Q5K 8bCUYDgLeDkROM2FHrgKcf+bnhZwrfUFYQlI1dheA0OAgQXR0Y/DDksE6RhBYGrvtoX3 QIjKHkO9+hdi3Zubr82HGHnUVac+u4Z1bjUQsX7WnXnZL8VAf0wfgc0C57WM/hdYox2U Fs2amZQNyeFimmQZSiggTNLWb/AqHfUWIPqqP68kjGQ+WuM8KaytU/uV619F5ld2fNXR i6XA== X-Gm-Message-State: AOJu0YwPjHRV7geMASLZLpU1br752OA4FkBrlsUFHFLybUGGTm1Jm8cP A4S/O5FFXKhBbrMtu0bYH8XiM8FcsQT/JDfSYqpj/zkG7WY9l3FA7laUG3RVOVnze2ppTg6uEvw = X-Google-Smtp-Source: AGHT+IEZkbQX0NLERwh56u1tGvlCUkwNp53bwoslZ32UF56MVq5FwQ9ORJzs4Tp/aQ64ELHxTfsTzg== X-Received: by 2002:a05:6a21:e8d:b0:1d9:6a6b:faf4 with SMTP id adf61e73a8af0-1d96a6bfb3fmr2910487637.15.1729583162982; Tue, 22 Oct 2024 00:46:02 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (27.247.221.35.bc.googleusercontent.com. [35.221.247.27]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ec13d75aesm4091024b3a.124.2024.10.22.00.46.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 00:46:02 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Milan Zamazal , Kieran Bingham Subject: [PATCH v16 7/7] libcamera: software_isp: Refactor SoftwareIsp to use DmaBufAllocator::exportBuffers Date: Tue, 22 Oct 2024 07:43:43 +0000 Message-ID: <20241022074544.3790451-8-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog In-Reply-To: <20241022074544.3790451-1-chenghaoyang@chromium.org> References: <20241022074544.3790451-1-chenghaoyang@chromium.org> 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 47677784d..5f58e5e40 100644 --- a/src/libcamera/software_isp/software_isp.cpp +++ b/src/libcamera/software_isp/software_isp.cpp @@ -256,25 +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))); - } - - return count; + return dmaHeap_.exportBuffers(count, { debayer_->frameSize() }, buffers); } /**