From patchwork Tue Aug 20 16:23: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: 20975 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 727D7C323E for ; Tue, 20 Aug 2024 17:22:35 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C3046633FA; Tue, 20 Aug 2024 19:22:34 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bHWZZm6o"; dkim-atps=neutral Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 809F7633D5 for ; Tue, 20 Aug 2024 19:22:21 +0200 (CEST) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-428243f928cso46685215e9.3 for ; Tue, 20 Aug 2024 10:22:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1724174541; x=1724779341; 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=TsnaMW9RnciKwlBvDg1jm/k8oS0941yZ3v5QaArfrqE=; b=bHWZZm6o/oN6PcmIrTXRZDiB9qwshSK46yPBcW1XqkDwP6mNr2FejLSb56RJkBCU9I NLIS/EqtODWUCpfBeVqE3xX3G6/W88sAwv5h1XQxT17dFrvxBM4Q/5W2keJqhDdzXVeX 6I1pAQ48WfmV/8Gt+hgKHB0QDpm0AqjjA7+rA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724174541; x=1724779341; 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=TsnaMW9RnciKwlBvDg1jm/k8oS0941yZ3v5QaArfrqE=; b=BUwiYBVWUDpctfmeSoKfuWplOTIe3QMHQLzF/sWUs8nygvjCYshRR7I6F7f8Ca1hYY clG7xESyWCA4zNZPto0+xIg11XER8UMgK5MR1yMzbx+qduT2DQFOWFnotU9p8OFOvq0B 2DB0F3Z7wLwbwUCmN0QX1/qN8ASOhN5DF4VM+vOTGZWPbetKgD5kssgeWEM2wI55vzFm hUKfk3HsaMDbs86UdcgaERRVlCOa+ZaIKEBC2bJ3rUq0jhQoih1r0inquL1rKRKs1P8B UY3tlPCrrC+3aZFvTLJPOSUrfNnu2csv/93o9mILTPcprjXU+IOf1eZDAjP9P/ijojDy G9GQ== X-Gm-Message-State: AOJu0YzutWQgIIyV+0wcBvpVZwEm1ug8fpf2w9KVYlqAabT2YPUd9jbP sZnZNlhqkoRDOpa+Y2EOwjMxBioTLtvCYlBFBCsbwfxKsHmvG/E5RKwooRxtjAZzXaEaDAuzm2Y 1h33ifFI= X-Google-Smtp-Source: AGHT+IGUQ126/tskHXTdmzT8XnEC3ItBHDOwWkqMxcNYRe0QlAQgMnJdRJg2T+Eqq4/g+hJ9JZXxSw== X-Received: by 2002:a05:600c:46c4:b0:428:16a0:1c3d with SMTP id 5b1f17b1804b1-42abd2282c3mr558915e9.19.1724174540789; Tue, 20 Aug 2024 10:22:20 -0700 (PDT) Received: from chenghaoyang-germany.c.googlers.com.com (161.126.77.34.bc.googleusercontent.com. [34.77.126.161]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42ab6e90db5sm30328575e9.0.2024.08.20.10.22.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2024 10:22:19 -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 v9 8/8] libcamera: software_isp: Refactor SoftwareIsp to use DmaBufAllocator::exportBuffers Date: Tue, 20 Aug 2024 16:23:39 +0000 Message-ID: <20240820172202.526547-9-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.0.184.g6999bdac58-goog In-Reply-To: <20240820172202.526547-1-chenghaoyang@google.com> References: <20240820172202.526547-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 | 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 c8748d888..35077feb2 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); } /**