From patchwork Tue Nov 22 15:42:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 17842 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 82DD4BDE6B for ; Tue, 22 Nov 2022 15:42:39 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id D353163314; Tue, 22 Nov 2022 16:42:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1669131758; bh=VnUo6kCCRKEqYN+ZlEwVYVpfFfj6zlK6VXBZiizwvFU=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hB2wXHIInCsdU5qzIFh5ZCOnBzimaITHyiWKN2+ImewvSx0BIPxHiufIWOqpYUaNH iBMJgOh3JErjGLTLw1FKiUrmvObIWKutOFNO++ZOstonWpDvtmuW3Uxiowf5XKkfUK c/IRTCEAEkI7zgUmQktm4vizLurTVDhdn3eOK2+E3dl41EL+HZZgIbLbReyQ9cY/07 ItnhDGYUvmAjSV2ojcrtbIW25ebVpTfMS2tF79Q37AfowfZmHZ1s06N/h+o/QjKutu 6Wht8HnqeT6Bm1jPWLCUB75PnKakMWdKwqr7NSdbjgNDdu69BSKwG8FTsExj1z6tsX Vs2RdBNFG4rKg== Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 823FC603CE for ; Tue, 22 Nov 2022 16:42:37 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="o1NVh39u"; dkim-atps=neutral Received: by mail-wm1-x32b.google.com with SMTP id a11-20020a05600c2d4b00b003cf6f5fd9f1so11590540wmg.2 for ; Tue, 22 Nov 2022 07:42:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yyKJhSfXr3vsy3OPJjCtXMhON7f6tNpE+h1u8tDWUx4=; b=o1NVh39uUknh7Ho3otY0Ma7smEEQZF6qR2uQV1Xa0XJRy4nWPg1cPv8l3PnobgdGxI /IfC5ZwWYnWM4j5+E4nPSRSsbzJ0dlgqhsgeAw6nUgu0r4bXA0ay+9mMBpOkUF5wF42F U6sPgbzvsYGZA9vrbSymTdaCYJapMDC/k+gC3VDjdeKgkT9aPRhfCnQRnY1rfQEl2wzC yyC/XCAppfbjP5/sSZCprJIjhueP4UPSrfB/kQGxhFZLtq9zpqAVGYbBMzXT2i0ZBEXU 4ixsX55MjdDVXrvhWDhqLRYZhL4h/9DbR0YuPPSE5cy/myWNO0ydaqf1KwKN4LuWK4R/ so8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yyKJhSfXr3vsy3OPJjCtXMhON7f6tNpE+h1u8tDWUx4=; b=ojF1B8Q8cxviNndkWH6XmmR9PKQMB3QAQhbCEkHTXIq0fXOfAph8l+e3b6TS9/9I7w k8jz/SWHeA3FdaG4ZnbZ/MuPsMa4afx0r0TzXWlGuyrJDEh0rhnEs/dwD54vHZQNT6P9 b3O8GRtW2dzNiVuxlGe72DGfNEmCWFgvEwTvTKpMIKQbM6XO2H3pri2Rq4tCKE2cJC2M VVYuB7bwDL2QRIk6aSdY7LPDdnxNkPzWkYLjkbsqMp8QUbMFRp1OGZy4a4g1dxBkunJb WOfaGv8OJ0hib0Nyja1i0aM82nIHhXZU3+MfdeKxW+TMQlUQNm5cXBJfWBTVNzvsBnM6 gb7A== X-Gm-Message-State: ANoB5pkYfYsvEvWiSD8cUFjzXU/HQ9Y+TQv/E/WVo0XsXxi/zdnAwCK9 dScHTlTgdUWCw3IwtoJV/aq5m6wRDCbl9Q== X-Google-Smtp-Source: AA0mqf7+GnzN3OfftLKU1qxTbg1qdsTy1v4dqu+hjIRnQa5hJFcw7MpnJwXXsAhqQTEprVmMbOeGZA== X-Received: by 2002:a05:600c:35c7:b0:3cf:7dc1:f432 with SMTP id r7-20020a05600c35c700b003cf7dc1f432mr19779217wmq.148.1669131756773; Tue, 22 Nov 2022 07:42:36 -0800 (PST) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id x9-20020a5d6509000000b0023c8026841csm14359349wru.23.2022.11.22.07.42.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 07:42:36 -0800 (PST) To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Nov 2022 15:42:35 +0000 Message-Id: <20221122154235.4319-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1] pipeline: raspberrypi: Remove enum BuffferMask from the mojom interface 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: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The BufferMask enum provides a way of identifying which stream a frame buffer belongs to. This enum is defined in the raspberrypi.mojom interface file. However, the IPA does not need these enum definitions to mmap buffers that it uses. Move this enum out of the raspberrypi.mojom interface file and put it into the RPi namespace visible only to the pipeline handler. This removes the need to include the auto-generated IPA interface header in the RPi::Stream definition. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart Reviewed-by: David Plowman --- include/libcamera/ipa/raspberrypi.mojom | 8 -------- src/ipa/raspberrypi/raspberrypi.cpp | 6 +++--- .../pipeline/raspberrypi/raspberrypi.cpp | 20 +++++++++---------- .../pipeline/raspberrypi/rpi_stream.cpp | 6 ++---- .../pipeline/raspberrypi/rpi_stream.h | 13 +++++++++--- 5 files changed, 25 insertions(+), 28 deletions(-) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index 40f78d9e3b3f..d53644fe296c 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -8,14 +8,6 @@ module ipa.RPi; import "include/libcamera/ipa/core.mojom"; -enum BufferMask { - MaskID = 0x00ffff, - MaskStats = 0x010000, - MaskEmbeddedData = 0x020000, - MaskBayerData = 0x040000, - MaskExternalBuffer = 0x100000, -}; - /* Size of the LS grid allocation. */ const uint32 MaxLsGridSize = 0x8000; diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index beb076dc4909..4e10c57d7f87 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -515,7 +515,7 @@ void IPARPi::signalStatReady(uint32_t bufferId) reportMetadata(); - statsMetadataComplete.emit(bufferId & MaskID, libcameraMetadata_); + statsMetadataComplete.emit(bufferId, libcameraMetadata_); } void IPARPi::signalQueueRequest(const ControlList &controls) @@ -534,7 +534,7 @@ void IPARPi::signalIspPrepare(const ISPConfig &data) frameCount_++; /* Ready to push the input buffer into the ISP. */ - runIsp.emit(data.bayerBufferId & MaskID); + runIsp.emit(data.bayerBufferId); } void IPARPi::reportMetadata() @@ -1001,7 +1001,7 @@ void IPARPi::queueRequest(const ControlList &controls) void IPARPi::returnEmbeddedBuffer(unsigned int bufferId) { - embeddedComplete.emit(bufferId & MaskID); + embeddedComplete.emit(bufferId); } void IPARPi::prepareISP(const ISPConfig &data) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 087c71b65700..0e0b71945640 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -1484,10 +1484,10 @@ int PipelineHandlerRPi::prepareBuffers(Camera *camera) * Pass the stats and embedded data buffers to the IPA. No other * buffers need to be passed. */ - mapBuffers(camera, data->isp_[Isp::Stats].getBuffers(), ipa::RPi::MaskStats); + mapBuffers(camera, data->isp_[Isp::Stats].getBuffers(), RPi::MaskStats); if (data->sensorMetadata_) mapBuffers(camera, data->unicam_[Unicam::Embedded].getBuffers(), - ipa::RPi::MaskEmbeddedData); + RPi::MaskEmbeddedData); return 0; } @@ -1727,7 +1727,7 @@ void RPiCameraData::statsMetadataComplete(uint32_t bufferId, const ControlList & if (!isRunning()) return; - FrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(bufferId); + FrameBuffer *buffer = isp_[Isp::Stats].getBuffers().at(bufferId & RPi::MaskID); handleStreamBuffer(buffer, &isp_[Isp::Stats]); @@ -1763,9 +1763,9 @@ void RPiCameraData::runIsp(uint32_t bufferId) if (!isRunning()) return; - FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bufferId); + FrameBuffer *buffer = unicam_[Unicam::Image].getBuffers().at(bufferId & RPi::MaskID); - LOG(RPI, Debug) << "Input re-queue to ISP, buffer id " << bufferId + LOG(RPI, Debug) << "Input re-queue to ISP, buffer id " << (bufferId & RPi::MaskID) << ", timestamp: " << buffer->metadata().timestamp; isp_[Isp::Input].queueBuffer(buffer); @@ -1778,7 +1778,7 @@ void RPiCameraData::embeddedComplete(uint32_t bufferId) if (!isRunning()) return; - FrameBuffer *buffer = unicam_[Unicam::Embedded].getBuffers().at(bufferId); + FrameBuffer *buffer = unicam_[Unicam::Embedded].getBuffers().at(bufferId & RPi::MaskID); handleStreamBuffer(buffer, &unicam_[Unicam::Embedded]); handleState(); } @@ -1931,7 +1931,7 @@ void RPiCameraData::ispOutputDequeue(FrameBuffer *buffer) * application until after the IPA signals so. */ if (stream == &isp_[Isp::Stats]) { - ipa_->signalStatReady(ipa::RPi::MaskStats | static_cast(index)); + ipa_->signalStatReady(RPi::MaskStats | static_cast(index)); } else { /* Any other ISP output can be handed back to the application now. */ handleStreamBuffer(buffer, stream); @@ -2006,7 +2006,7 @@ void RPiCameraData::handleExternalBuffer(FrameBuffer *buffer, RPi::Stream *strea { unsigned int id = stream->getBufferId(buffer); - if (!(id & ipa::RPi::MaskExternalBuffer)) + if (!(id & RPi::MaskExternalBuffer)) return; /* Stop the Stream object from tracking the buffer. */ @@ -2174,13 +2174,13 @@ void RPiCameraData::tryRunPipeline() << " Bayer buffer id: " << bayerId; ipa::RPi::ISPConfig ispPrepare; - ispPrepare.bayerBufferId = ipa::RPi::MaskBayerData | bayerId; + ispPrepare.bayerBufferId = RPi::MaskBayerData | bayerId; ispPrepare.controls = std::move(bayerFrame.controls); if (embeddedBuffer) { unsigned int embeddedId = unicam_[Unicam::Embedded].getBufferId(embeddedBuffer); - ispPrepare.embeddedBufferId = ipa::RPi::MaskEmbeddedData | embeddedId; + ispPrepare.embeddedBufferId = RPi::MaskEmbeddedData | embeddedId; ispPrepare.embeddedBufferPresent = true; LOG(RPI, Debug) << "Signalling signalIspPrepare:" diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp index 79f7be130ed4..2bb10f25d6ca 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.cpp @@ -8,8 +8,6 @@ #include -#include - namespace libcamera { LOG_DEFINE_CATEGORY(RPISTREAM) @@ -74,7 +72,7 @@ int Stream::getBufferId(FrameBuffer *buffer) const void Stream::setExternalBuffer(FrameBuffer *buffer) { - bufferMap_.emplace(ipa::RPi::MaskExternalBuffer | id_.get(), buffer); + bufferMap_.emplace(BufferMask::MaskExternalBuffer | id_.get(), buffer); } void Stream::removeExternalBuffer(FrameBuffer *buffer) @@ -82,7 +80,7 @@ void Stream::removeExternalBuffer(FrameBuffer *buffer) int id = getBufferId(buffer); /* Ensure we have this buffer in the stream, and it is marked external. */ - ASSERT(id != -1 && (id & ipa::RPi::MaskExternalBuffer)); + ASSERT(id != -1 && (id & BufferMask::MaskExternalBuffer)); bufferMap_.erase(id); } diff --git a/src/libcamera/pipeline/raspberrypi/rpi_stream.h b/src/libcamera/pipeline/raspberrypi/rpi_stream.h index 3c0b5c8ebab4..b8bd79cf1535 100644 --- a/src/libcamera/pipeline/raspberrypi/rpi_stream.h +++ b/src/libcamera/pipeline/raspberrypi/rpi_stream.h @@ -12,7 +12,6 @@ #include #include -#include #include #include "libcamera/internal/v4l2_videodevice.h" @@ -23,6 +22,14 @@ namespace RPi { using BufferMap = std::unordered_map; +enum BufferMask { + MaskID = 0x00ffff, + MaskStats = 0x010000, + MaskEmbeddedData = 0x020000, + MaskBayerData = 0x040000, + MaskExternalBuffer = 0x100000, +}; + /* * Device stream abstraction for either an internal or external stream. * Used for both Unicam and the ISP. @@ -31,13 +38,13 @@ class Stream : public libcamera::Stream { public: Stream() - : id_(ipa::RPi::MaskID) + : id_(BufferMask::MaskID) { } Stream(const char *name, MediaEntity *dev, bool importOnly = false) : external_(false), importOnly_(importOnly), name_(name), - dev_(std::make_unique(dev)), id_(ipa::RPi::MaskID) + dev_(std::make_unique(dev)), id_(BufferMask::MaskID) { }