From patchwork Mon Sep 30 06:29:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21421 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 C17CAC3257 for ; Mon, 30 Sep 2024 06:34:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 2473C63518; Mon, 30 Sep 2024 08:34:19 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="QO//nQc+"; dkim-atps=neutral Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4AC046351A for ; Mon, 30 Sep 2024 08:34:03 +0200 (CEST) Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-7179069d029so2803730b3a.2 for ; Sun, 29 Sep 2024 23:34:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1727678040; x=1728282840; 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=QO//nQc+PGqX4GZ8UdPZsrNJEFIU69mFjDKYhZodW3BVt4iFY3GHm+Q+Q/1nTQbner vlNNqUTahsmSUhGmpHGWBnMUwZhLE6FlvollOfePhDPGmVD5biJeVzlT1+QKX8x96cxh OwsSztIhJM6W4M13qoIvCXNiKRWqAw94EtO+c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727678040; x=1728282840; 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=lL7NW8MuX2scde1GByD48ORnBpj1vYthmODjqaS3DwwWc21Ai6ZtCq8UBOc/ExfqqN 6DofAc6kq5N91eRDqlHhfhViLzkHgDL+bIWtb+3bZkJn1zAQAoKfbGEvYXo5dTV0s/C2 fpZylh12rDpAKGu9U5AB7DPSpXKeCOAT40H4H4EUjRDq/AbBt3oRW1bqgldHhXJv7EZa +XzzDGl3ncPe5C9L87BCe5X5wmzgIh0clZgrNfeMr2btNPaRO5R3tft/urCdJomU5pV+ JR4SLfc2H+BR9CuUbcQnrnjZAtx5ZIekAdqCMfPWc1bY1ipY1PkfCSFinI0+RnM8uf90 UUlg== X-Gm-Message-State: AOJu0YxQdmePePqRevlqD8Ool8GXGTjWLW9Q+w3HuajgsmaMF13BLLHS WVMQU52jEXjTUrQ9tK3/xBeBOxDPgfzm/nFKAIrArufPgMzmLgfJUWKtcWJvVft/YWDZJoyR8H4 = X-Google-Smtp-Source: AGHT+IH9C5HYiRDO8u5uOFieQ/GKCoYmbpYsHp57ZgxaMzkutq+0/ChroRieW/JboAY+1Vzr21A36w== X-Received: by 2002:a05:6a00:181d:b0:717:8eca:95 with SMTP id d2e1a72fcca58-71b2604919emr19214639b3a.17.1727678040438; Sun, 29 Sep 2024 23:34:00 -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 d2e1a72fcca58-71b265166e2sm5487671b3a.131.2024.09.29.23.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2024 23:33:59 -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 v14 7/7] libcamera: software_isp: Refactor SoftwareIsp to use DmaBufAllocator::exportBuffers Date: Mon, 30 Sep 2024 06:29:48 +0000 Message-ID: <20240930063342.3014837-8-chenghaoyang@google.com> X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog In-Reply-To: <20240930063342.3014837-1-chenghaoyang@google.com> References: <20240930063342.3014837-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); } /**