From patchwork Mon Aug 23 13:12:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 13449 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 13496BD87C for ; Mon, 23 Aug 2021 13:12:47 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BB6966891A; Mon, 23 Aug 2021 15:12:46 +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="g7cclLPo"; dkim-atps=neutral Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A000568918 for ; Mon, 23 Aug 2021 15:12:45 +0200 (CEST) Received: by mail-pf1-x433.google.com with SMTP id y11so15319164pfl.13 for ; Mon, 23 Aug 2021 06:12:45 -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=D+2/XZSMz8xxue+lGeQLRASpDn2Szc61kzLG/Z4POt0=; b=g7cclLPomXzVGrExzEjHWx1TWn+SSW2Aq0BeN5atqtSsg0r2v53IDzOn9JAt4fFSrh 9+WaU+Y509G98IV2RHZKtzsiXlH3wwUBoecxo3vAYIhH5xY9oVcOGbGell8GmliwJgac aSNb+wzPbJY9ETxRT6NP7Jze/B59KKDacz6Hg= 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=D+2/XZSMz8xxue+lGeQLRASpDn2Szc61kzLG/Z4POt0=; b=KZ8Vni+iq0syU9JgiRtCJNc11gzcb9bc4MkNtxdXyzxLCOQATGWYmHlg24eq8rKNL1 u41rKp9q29EKaZgcXQI7c2EpcTa7uIHIAmbV9lmD+own9lplYTIiUsXY2xEPZ9jQh2Q+ EXqXYfMG5GPrzrEs/SuuI2F/Cy2L0TKloCqBvrpIMovzANqSCRydcsv2QvflDwO+OBJR Dx8UgFbY0oAflRxtafSLTa7CwWfY0WC+ccC8y7a3qba9naiVACdtr/4P22+ezw0xpO6b l1J2C23frKWXb8wnHiBDYQvM/gj/HDYE9ing3fmb76JyCzdJrJxg9AGqg6bpr3HBbc8S ZTtA== X-Gm-Message-State: AOAM530M9CY89ks6yXTATXUzuIAcTKhovwQsxqBZU+MwazXO4sobvddo lpZwkWg4FVV6a/g+oeB3GN8SF04f0SXwVg== X-Google-Smtp-Source: ABdhPJzidXNiHBtPAz92qAvlFjUqwSUnNF05NP/tQcpLJmeWg6+pr45t+CurtCdzjZ2+0TV49k6EQg== X-Received: by 2002:a63:4a18:: with SMTP id x24mr28136404pga.209.1629724363520; Mon, 23 Aug 2021 06:12:43 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:184e:5d20:8fcb:dfcd]) by smtp.gmail.com with ESMTPSA id j4sm18596891pgi.6.2021.08.23.06.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 06:12:43 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 23 Aug 2021 22:12:17 +0900 Message-Id: <20210823131221.1034059-7-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.rc2.250.ged5fa647cd-goog In-Reply-To: <20210823131221.1034059-1-hiroh@chromium.org> References: <20210823131221.1034059-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 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 | 16 +++++++++++----- src/qcam/main_window.h | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp index 39d034de..7fdec4a8 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,12 @@ 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 +545,7 @@ error: munmap(buffer.memory, buffer.size); } mappedBuffers_.clear(); + planeData_.clear(); freeBuffers_.clear(); @@ -577,6 +582,7 @@ void MainWindow::stopCapture() munmap(buffer.memory, buffer.size); } mappedBuffers_.clear(); + planeData_.clear(); requests_.clear(); freeQueue_.clear(); @@ -673,10 +679,10 @@ void MainWindow::processRaw(FrameBuffer *buffer, "DNG Files (*.dng)"); if (!filename.isEmpty()) { - const MappedBuffer &mapped = mappedBuffers_[buffer]; + void *memory = planeData_[buffer].data(); DNGWriter::write(filename.toStdString().c_str(), camera_.get(), rawStream_->configuration(), metadata, buffer, - mapped.memory); + memory); } #endif @@ -753,7 +759,7 @@ void MainWindow::processViewfinder(FrameBuffer *buffer) << "fps:" << Qt::fixed << qSetRealNumberPrecision(2) << fps; /* Render the frame on the viewfinder. */ - viewfinder_->render(buffer, &mappedBuffers_[buffer]); + // HACK HACK HACK 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..f35cce36 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_;