From patchwork Thu Sep 26 16:29:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21391 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 52E6DC3257 for ; Thu, 26 Sep 2024 16:32:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B8A9F63518; Thu, 26 Sep 2024 18:32:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YDu0xi4U"; dkim-atps=neutral Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9B9136351B for ; Thu, 26 Sep 2024 18:31:59 +0200 (CEST) Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-2059204f448so11345675ad.0 for ; Thu, 26 Sep 2024 09:31:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1727368318; x=1727973118; 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=J+YuiKlLl25i31fSj+za+H/da90SiNNuNEdDtImyhDk=; b=YDu0xi4UuciynYSDEh+aK5/nmadBsBE0o90WcfVcdz7a5ETs/oxlAH6AC43RukitJZ tQFAYPJ9AOgUuG78un5gQMRHB0W8S1IuS/XBd3R3D32QWv8CHUhice5koZ0UIeBSlsrt UUQrZOnRs0OLQcfk5jzZHaR9lZNCv4YMpSvJg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727368318; x=1727973118; 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=J+YuiKlLl25i31fSj+za+H/da90SiNNuNEdDtImyhDk=; b=jT4j99RYHSmJPUZRriQNiYZRAUHS3KKIxGjWfu1OhW3nJq3EfwRUKIZY6rASaC/doO nN8r3y1/+9jpYMptdVCOyObSQLB3nzwgJ/eYCE4j3sXNwMJqeGNHQvO9FoxgIAuScLyp Wo1/1b5e5BkwlxS4PobR3qtyu4MvyhpFr97nkrMEnxPS6LPtajBAugknoVTTM2GY5dae mDgeEmkFmyu1lOsMjTbQfrJ1N+hCfUNHkNFzu+SQbdK5irUAec0KTp05ctNduDYrDaaU PSYLwlhY50TIcfXnGhu1TnX20Qqn2a0c+kuZ+jDnwvcBRLXa2vMv+YYKqphOf0eyaT6Q AHhg== X-Gm-Message-State: AOJu0YxBFfwGKQ2U5kF6wkP17GJCxfnsAkSRSkRCDSl4/MjRHbntEa1T mCyC8fIRl+k5vXcm3W9dx9cicoyjDA6vb6/RnYiOISQcPMMnDIjz2v/PWvsbw5iDIkY6ANz6XMo = X-Google-Smtp-Source: AGHT+IFYhib904kxbtcU20JEhDcXxIAUTu4gRGw9QDzUOyHzVp/3z2E4tvgJCCwnyO/v2F8uXDHIoQ== X-Received: by 2002:a17:902:db12:b0:206:998d:6ea0 with SMTP id d9443c01a7336-20b37489283mr4159965ad.33.1727368317814; Thu, 26 Sep 2024 09:31:57 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (208.158.221.35.bc.googleusercontent.com. [35.221.158.208]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37e20dffsm469035ad.170.2024.09.26.09.31.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Sep 2024 09:31:57 -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 v13 7/7] libcamera: software_isp: Refactor SoftwareIsp to use DmaBufAllocator::exportBuffers Date: Thu, 26 Sep 2024 16:29:56 +0000 Message-ID: <20240926163141.1593026-8-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog In-Reply-To: <20240926163141.1593026-1-chenghaoyang@google.com> References: <20240926163141.1593026-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); } /**