From patchwork Tue Nov 12 09:56:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21876 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 B0AE9C3259 for ; Tue, 12 Nov 2024 10:01:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6A6C1657E0; Tue, 12 Nov 2024 11:01:02 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Ge6qavCP"; dkim-atps=neutral Received: from mail-il1-x12a.google.com (mail-il1-x12a.google.com [IPv6:2607:f8b0:4864:20::12a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 667E665474 for ; Tue, 12 Nov 2024 11:01:00 +0100 (CET) Received: by mail-il1-x12a.google.com with SMTP id e9e14a558f8ab-3a6c1cfcb91so22990425ab.0 for ; Tue, 12 Nov 2024 02:01:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1731405659; x=1732010459; 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=ETSnPQEUGsC+Ye+ja0ckktThpUHtsZEYfIELXy3ebhU=; b=Ge6qavCPjyf/8LLFBcV0WQM0XZhaD1dEDGFHiQmviWkFtkLCs1oKUSpD4vH5BUpvJC 7OwYBukjD37ALrea1xuCSfbOQNrlKrnuhWr/yvWkHpybCNylV+IVK7ABN24ZK17z//RU WFiKnzYyG/gMk05S1Hz82vwzKo9tShfZGth/I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731405659; x=1732010459; 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=ETSnPQEUGsC+Ye+ja0ckktThpUHtsZEYfIELXy3ebhU=; b=g3BxPP51yjD6XyvL556XBPMrH+kJCvKFHUWmj1PyAhyOwVrj03JFkEXhxhcWwUvxDz 7XLsA9LIp8rg55fhAvblLGUyDcOF7TLiWV0e7FQwPkEaZY6s1qT2PH1qo7xH3O3aE5kV 8HbH9xELuk4No1qaySFC7FI+MOQuiBu+ZAvkscufmS2U0AhDVP/+EakwFSWXFqQa14NN HAijZglExPPHpbXxkVV52u16f3WbNqPcDqVvTlfQGvQNPJrovymOKX7oysC2qxKTQoX4 dKpZTXr2OLPNC5bkEthHUE27ztzZyfyZJUzqoTWBBfqjvWead0Oka9e9kZfuOKhYQqIS 1HrQ== X-Gm-Message-State: AOJu0YzvJVZdrTnH5joicB3tL8GhknMY3XV+3ptyoI81Sq50n/cg3NYO fZNAJea6V9E87iZwp2Ft7T2SBOPmGb82CRquS2Xh7nHSbYBBSjULrLQATqbqAwFKXxgaNNMBMOE = X-Google-Smtp-Source: AGHT+IHUMM/pkYrfVh69h2zB9MI1iJfRjfSNnvif7oDKQZzxqMNL51QFDbokSawwGxyCzXPcJsc/4A== X-Received: by 2002:a05:6e02:1568:b0:3a3:4175:79da with SMTP id e9e14a558f8ab-3a70c827cb2mr21152985ab.13.1731405658775; Tue, 12 Nov 2024 02:00:58 -0800 (PST) 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 41be03b00d2f7-7f41f644214sm10157673a12.58.2024.11.12.02.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Nov 2024 02:00:58 -0800 (PST) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Harvey Yang Subject: [PATCH 2/2] debayer_cpu: Replace syncing DMABUFs with DmaSyncer Date: Tue, 12 Nov 2024 09:56:55 +0000 Message-ID: <20241112100051.4071443-3-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.277.g8800431eea-goog In-Reply-To: <20241112100051.4071443-1-chenghaoyang@chromium.org> References: <20241112100051.4071443-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" As there's an existing helper class DmaSyncer that makes synchronizing DMABUFs more easily, this patch removes the self-defined function and reuse DmaSyncer. Signed-off-by: Harvey Yang Reviewed-by: Milan Zamazal --- src/libcamera/software_isp/debayer_cpu.cpp | 29 ++++++---------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/libcamera/software_isp/debayer_cpu.cpp b/src/libcamera/software_isp/debayer_cpu.cpp index cf5ecdf7a..852e14f20 100644 --- a/src/libcamera/software_isp/debayer_cpu.cpp +++ b/src/libcamera/software_isp/debayer_cpu.cpp @@ -20,6 +20,7 @@ #include #include "libcamera/internal/bayer_format.h" +#include "libcamera/internal/dma_buf_allocator.h" #include "libcamera/internal/framebuffer.h" #include "libcamera/internal/mapped_framebuffer.h" @@ -722,23 +723,6 @@ void DebayerCpu::process4(const uint8_t *src, uint8_t *dst) namespace { -void syncBufferForCPU(FrameBuffer *buffer, uint64_t syncFlags) -{ - for (const FrameBuffer::Plane &plane : buffer->planes()) { - const int fd = plane.fd.get(); - struct dma_buf_sync sync = { syncFlags }; - int ret; - - ret = ioctl(fd, DMA_BUF_IOCTL_SYNC, &sync); - if (ret < 0) { - ret = errno; - LOG(Debayer, Error) - << "Syncing buffer FD " << fd << " with flags " - << syncFlags << " failed: " << strerror(ret); - } - } -} - inline int64_t timeDiff(timespec &after, timespec &before) { return (after.tv_sec - before.tv_sec) * 1000000000LL + @@ -756,8 +740,12 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output clock_gettime(CLOCK_MONOTONIC_RAW, &frameStartTime); } - syncBufferForCPU(input, DMA_BUF_SYNC_START | DMA_BUF_SYNC_READ); - syncBufferForCPU(output, DMA_BUF_SYNC_START | DMA_BUF_SYNC_WRITE); + std::vector dmaSyncers; + for (const FrameBuffer::Plane &plane : input->planes()) + dmaSyncers.emplace_back(plane.fd.get(), DmaBufAllocator::SyncType::Read); + + for (const FrameBuffer::Plane &plane : output->planes()) + dmaSyncers.emplace_back(plane.fd.get(), DmaBufAllocator::SyncType::Write); green_ = params.green; red_ = swapRedBlueGains_ ? params.blue : params.red; @@ -786,8 +774,7 @@ void DebayerCpu::process(uint32_t frame, FrameBuffer *input, FrameBuffer *output metadata.planes()[0].bytesused = out.planes()[0].size(); - syncBufferForCPU(output, DMA_BUF_SYNC_END | DMA_BUF_SYNC_WRITE); - syncBufferForCPU(input, DMA_BUF_SYNC_END | DMA_BUF_SYNC_READ); + dmaSyncers.clear(); /* Measure before emitting signals */ if (measuredFrames_ < DebayerCpu::kLastFrameToMeasure &&