From patchwork Thu Aug 29 19:47:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21055 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 03916C323E for ; Thu, 29 Aug 2024 19:57:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6552E634DD; Thu, 29 Aug 2024 21:57:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="jVrTQgtA"; dkim-atps=neutral Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 85FB3634C8 for ; Thu, 29 Aug 2024 21:57:12 +0200 (CEST) Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-428178fc07eso8860405e9.3 for ; Thu, 29 Aug 2024 12:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1724961432; x=1725566232; 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=OlGML7j698JA+GNnOHiuVJg0H9KbzljNqElhQR8sHZI=; b=jVrTQgtAHthQ1/P7MPx/CqSR3ulzKaJe6xC/y4CWIzjb3lkU8yKuEslOUlUz+Q64NR NK5CVsIWEpdyRpYuwZ1ahQ3ixisqIXfUV4lr4Fqa+uCTM+vuzjoajjsoIawcnpF6HjNy g03et6v5lgYhawqr9wPk5zln/sRmR8fQoYGUg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724961432; x=1725566232; 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=OlGML7j698JA+GNnOHiuVJg0H9KbzljNqElhQR8sHZI=; b=OH7WGWOlL664schGz4HzPsf3Da2dxVh4EHBrEGi9M4IjdqWT2rXkV2NixxQDYL4aLS 9nXpnazq/nc7P7nybYfMp+lpd4nqxKlfFEQ9wxNnKaMYoTprhYABUxCBevKPWG/DLWrv 8ilQ7BKAtmK5JUe6Dg6hOkA0WhfgoQMgI5qEJ7Z37omyS09P1qiutUoAF25KRM7sKgBu z3BWI3MNfHyoge9SaNAKWgqyMndCaooHcPNNjuiVOoI5huU6RbLMXh79bf/RxzBnaKoh U/wKrCP3P526Zy47Mjpy6nGv/Gd4jwgKkEZHHbO9FX0fiu2HxgE2cQU3L9q/GtkCZe8C B15A== X-Gm-Message-State: AOJu0Yzw6vMzy8b7Fpv5Ty2Dfmb6ZrbBUClafgPq15pazTB+4iOFl5bd VGlznM4MBHvJ6FUmrE2eoIfhPdpCxQ05iyvBiyCflkgzxdYH5qrcaog1q8tDckatvyGjoe4TFwg Pww== X-Google-Smtp-Source: AGHT+IHD/0QRG6hwOUzthlgTth5XOn29XO9d+FgYVvmVxjVsWgFolx5rfLxGzNdAJk+iiPEaDqYHpw== X-Received: by 2002:a7b:c449:0:b0:42b:aecb:d280 with SMTP id 5b1f17b1804b1-42bb27a1021mr33170805e9.27.1724961431808; Thu, 29 Aug 2024 12:57:11 -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-42ba7b4271fsm54602805e9.29.2024.08.29.12.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Aug 2024 12:57:11 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang , Harvey Yang , Milan Zamazal Subject: [PATCH v10 7/7] libcamera: software_isp: Refactor SoftwareIsp to use DmaBufAllocator::exportBuffers Date: Thu, 29 Aug 2024 19:47:46 +0000 Message-ID: <20240829195703.1456614-8-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.46.0.469.g59c65b2a67-goog In-Reply-To: <20240829195703.1456614-1-chenghaoyang@chromium.org> References: <20240829195703.1456614-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" From: Harvey Yang 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 1140372ce..3455f13aa 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); } /**