From patchwork Mon Aug 16 04:31:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13364 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 1309FBD87D for ; Mon, 16 Aug 2021 04:31:59 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C10F9688A2; Mon, 16 Aug 2021 06:31:58 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="kTaa8Zct"; dkim-atps=neutral Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EE37A688E4 for ; Mon, 16 Aug 2021 06:31:56 +0200 (CEST) Received: by mail-pj1-x1029.google.com with SMTP id cp15-20020a17090afb8fb029017891959dcbso30406266pjb.2 for ; Sun, 15 Aug 2021 21:31:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Pu6I4Bte51NOKNhfGBLmMoWxaLd3FC64fN/DTIH0QsA=; b=kTaa8ZctmPKR/W9VWIgHqvSDzOpALbYFkTgGGcMv39etthYUAHsHpjA1fpMj07NHt0 1GA04kOyJv29IamgSz3X2ab9oa0YmzW3U12lV6mdQm8cQqQH60rUARbLsJs03n+RLPaJ jyT+t4/9CtrhENkNoF7oSUwpzUxJpqnk8FqCc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Pu6I4Bte51NOKNhfGBLmMoWxaLd3FC64fN/DTIH0QsA=; b=UQCMtNr05jIvwXESJRvHEbrnGqcWuAWxwCsJ7awSIgIZpkQBsNkbFif291FbaP3dg0 GItd7X1ozVttICDO2008gkK6aM5fpZHd4Bwg8t1JwzBQZBHDBD0L+0Lxd8E2LSV/y2ZR ZQ9KBQzBRAsv6dT6zDzcSzFPERkfmX9ri4+iiqIwmXe9NHjhoG47is8PTHEH9uAOaTnI 6aIVtV3RzHCg9r5c5cvuQKdx1b2UTzkIk7stWw9bT88+Cz9nDjbwvt7ma97B/Adq3twp yb7nl1hMD/G2HRMXa/IQSHMfaGOjSeoIWm/zaKvPX0QDlDjUhPnJxi9QRis7jcb6uMJR RaBQ== X-Gm-Message-State: AOAM5317DYOg3vuF7XxyCGN0ZTSL5vywjGnyarc0oJN9lB61cAVAYooJ YK/mt0Pmvm+m2S1t7WctZrYkiKz1SF/e9Q== X-Google-Smtp-Source: ABdhPJz2C1OXnaPOqwCP9lJ9my4yYnhkAZxHIdtFeIWkoKHIbfePJC5r4FZzWU8FBSj4JIuuNDvQ3g== X-Received: by 2002:a63:e74b:: with SMTP id j11mr5175990pgk.322.1629088315251; Sun, 15 Aug 2021 21:31:55 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:6f5f:1479:a6ab:4229]) by smtp.gmail.com with ESMTPSA id u10sm2767417pgj.48.2021.08.15.21.31.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Aug 2021 21:31:54 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 16 Aug 2021 13:31:34 +0900 Message-Id: <20210816043138.957984-7-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.rc1.237.g0d66db33f3-goog In-Reply-To: <20210816043138.957984-1-hiroh@chromium.org> References: <20210816043138.957984-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 06/10] qcam: main_window: Use offset mapping FrameBuffer 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" FrameBuffer::Plane has offset info now. This uses the offset in mapping FrameBuffer in MainWindow. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- src/qcam/main_window.cpp | 15 ++++++++++----- src/qcam/main_window.h | 1 + 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 39d034de..f815d281 100644 --- a/src/qcam/main_window.cpp +++ b/src/qcam/main_window.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -472,9 +473,11 @@ int MainWindow::startCapture() for (const std::unique_ptr &buffer : allocator_->buffers(stream)) { /* Map memory buffers and cache the mappings. */ const FrameBuffer::Plane &plane = buffer->planes().front(); - void *memory = mmap(NULL, plane.length, PROT_READ, MAP_SHARED, + size_t length = lseek(plane.fd.fd(), 0, SEEK_END); + void *memory = mmap(NULL, length, PROT_READ, MAP_SHARED, plane.fd.fd(), 0); - mappedBuffers_[buffer.get()] = { memory, plane.length }; + mappedBuffers_[buffer.get()] = { memory, length }; + planeData_[buffer.get()] = { static_cast(memory) + plane.offset, plane.length }; /* Store buffers on the free list. */ freeBuffers_[stream].enqueue(buffer.get()); @@ -541,6 +544,7 @@ error: munmap(buffer.memory, buffer.size); } mappedBuffers_.clear(); + planeData_.clear(); freeBuffers_.clear(); @@ -577,6 +581,7 @@ void MainWindow::stopCapture() munmap(buffer.memory, buffer.size); } mappedBuffers_.clear(); + planeData_.clear(); requests_.clear(); freeQueue_.clear(); @@ -673,10 +678,10 @@ void MainWindow::processRaw(FrameBuffer *buffer, "DNG Files (*.dng)"); if (!filename.isEmpty()) { - const MappedBuffer &mapped = mappedBuffers_[buffer]; + void *memory = planeData_[buffer].memory; DNGWriter::write(filename.toStdString().c_str(), camera_.get(), rawStream_->configuration(), metadata, buffer, - mapped.memory); + memory); } #endif @@ -753,7 +758,7 @@ void MainWindow::processViewfinder(FrameBuffer *buffer) << "fps:" << Qt::fixed << qSetRealNumberPrecision(2) << fps; /* Render the frame on the viewfinder. */ - viewfinder_->render(buffer, &mappedBuffers_[buffer]); + viewfinder_->render(buffer, &planeData_[buffer]); } void MainWindow::queueRequest(FrameBuffer *buffer) diff --git a/src/qcam/main_window.h b/src/qcam/main_window.h index 85d56ce4..d7ea994c 100644 --- a/src/qcam/main_window.h +++ b/src/qcam/main_window.h @@ -107,6 +107,7 @@ private: std::unique_ptr config_; std::map mappedBuffers_; + std::map planeData_; /* Capture state, buffers queue and statistics */ bool isCapturing_;