From patchwork Fri Oct 4 09:59:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21509 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 C67B1C3263 for ; Fri, 4 Oct 2024 10:00:17 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C341163532; Fri, 4 Oct 2024 12:00:16 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="is5ll8ZR"; dkim-atps=neutral Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B468065365 for ; Fri, 4 Oct 2024 12:00:05 +0200 (CEST) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-71957eb256bso1735957b3a.3 for ; Fri, 04 Oct 2024 03:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728036004; x=1728640804; 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=7oxGveuNcRHzMqD3QAv03hUxkHXc5hzggXnXt3vxi9U=; b=is5ll8ZRtrAWWJZFQjWMx5GfbdbbmoqdvKqXfTFt5ErWVpQFo/8+bRmYKBreLiShLl WsjbpCojqpCAWDXi0pjQyKiOZCFEIKdIOMO+JhAGlY6tnC68NjFJrGbEyDQq9TRgBw9v mrw7e+EjDdSC6vLfi9tQdj0w1MpDhOobZuZd0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728036004; x=1728640804; 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=7oxGveuNcRHzMqD3QAv03hUxkHXc5hzggXnXt3vxi9U=; b=oGxZaeTklu3z5+8Rc1VFu4ZFmDmxORL99gVzX0IYrkVNebb3g2jyUb/YOMJaEf5LyX fkpmoLI8t75I55v+Ny+at/2RtYz23CzsDs1sN/mTqSeyLTgnrIM8WXjZZ+wc3BX3aKhE C1Yo1D0ohnbkkTz+6FZdgMm+DmzcMSd8pJrNNqWHgkk8bhGkf7u9p29vKLITt4ldh7tD tcUZE96IPLRlGxSe/nWUI7tYnvQUpiq2j6wgIzYq1vKx52dfvQ1omkkwqt8K+nsvzVYw /8shO3mI6ccr1PpjctvFXl5Ou9RW68lfKgGMFvMmWTV+OHYVjTw+F7T44/giTUcA107D f4SQ== X-Gm-Message-State: AOJu0YxRUCVYVhYvcFd4pYEk43hDWu2jWDPm1My/cgYb4yZyirReBCFK lFXKVAivrFBrZOARpcsYIF/6MfPtEp+E3K4gvawGIepziasrdxg3apHon5EEcA3bmwBmZiWBJjO CSA== X-Google-Smtp-Source: AGHT+IE/QAeFepXHyLksF+1w/7Ao0UB453htpLXPllqzyD+nIPErNIP5r5mU6wiZ06csS63ODlNhcA== X-Received: by 2002:a05:6a00:c94:b0:71d:d1b4:b454 with SMTP id d2e1a72fcca58-71de23a95bemr3084145b3a.2.1728036003508; Fri, 04 Oct 2024 03:00:03 -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-71ded2ad931sm316911b3a.41.2024.10.04.03.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Oct 2024 03:00:03 -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 15 7/7] libcamera: software_isp: Refactor SoftwareIsp to use DmaBufAllocator::exportBuffers Date: Fri, 4 Oct 2024 09:59:20 +0000 Message-ID: <20241004095946.264537-8-chenghaoyang@google.com> X-Mailer: git-send-email 2.47.0.rc0.187.ge670bccf7e-goog In-Reply-To: <20241004095946.264537-1-chenghaoyang@google.com> References: <20241004095946.264537-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 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); } /**