From patchwork Tue Mar 23 14:36:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11669 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 9E2A8C32E5 for ; Tue, 23 Mar 2021 14:36:22 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 50DBD68D71; Tue, 23 Mar 2021 15:36:22 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="V0M4kLaS"; dkim-atps=neutral Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4081768D58 for ; Tue, 23 Mar 2021 15:36:19 +0100 (CET) Received: by mail-ed1-x52c.google.com with SMTP id bx7so23698146edb.12 for ; Tue, 23 Mar 2021 07:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=TqSX6AeFx6Ofk9lAqOuURZEnd2MT/7YTuqLSvTiTddg=; b=V0M4kLaSi8lLelB4h9+J7RkbOtT8elaVVa7AASHrE2shQeb+uLEcqfPDTag/KtOX8O IyfwJMvaE+jUKUX9+6T8gluv9mZG4XPK8ItL0HRa52rB2bg6xbKZ/oRW6Zpzke3mrnFz /Ur1bL47e8ERAhfq1JTZ4VyKm96qgCr+KWqxhvppAm7xCYe4rGckeTm5R4ZuBWhvYjEG Po2FeIvpEHBDH60zlL5Y38Aa6AN3SLkLkfLLOLX62+peThzAxfcEtNlwPYnlWhBDWvkF zpube2IKtgJOOERrjt7YpWeiZLCuDcuRRMwxr2yjDIjW0iGmQV6+c+m4aD+2bjiij5KC Musg== 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=TqSX6AeFx6Ofk9lAqOuURZEnd2MT/7YTuqLSvTiTddg=; b=SkZr7XSTt6yloqWNGFhcKDBLa8dWgkD1hT4CgT4sle0QFe+CYlWn+YXpUaEUVpnVCg giqlicOf+saWN9AroMS8NEAPmTg4OTA6oxhK9nTDVPpBGp7cz9REEmSMz76tU/YeBkC2 wxXAhIK+uwMOyAsUU+09USjiaLvcE+HeHUD8JJVtnQ/UxUw9iPCPcPKE19h3LMWnlAxA PQwCHAN0JhpBwMjt9DefMJFnVi4tbZNwwZ8+CoY7jd4qc3JiUB0zpZIZpl4lE0KwkHn7 0wgFqsLXz3kpGlsP5utQOyipA0K3B0GQ2Gv1dYxnNtoDFO2y/9kE++YKvuoiLEhjzT88 rEUA== X-Gm-Message-State: AOAM533tZzqRCnqWBcGzekX+wTIIDcw7PG0OZbl8woiC1MuxiRYX/kdF SIVOb35R6FHdI0ja1IKe83Tk0Bkimz3Udg== X-Google-Smtp-Source: ABdhPJzUg1yz/oU+9NldiTmmVQwAOYbpUjrhekEZhROtkn+hgkdyjo6BlX0LU0DdAPJYyyxiwpbcEQ== X-Received: by 2002:a05:6402:1d33:: with SMTP id dh19mr4867192edb.362.1616510178628; Tue, 23 Mar 2021 07:36:18 -0700 (PDT) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id n6sm11282430eji.37.2021.03.23.07.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Mar 2021 07:36:18 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 23 Mar 2021 14:36:06 +0000 Message-Id: <20210323143610.787760-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323143610.787760-1-naush@raspberrypi.com> References: <20210323143610.787760-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/7] pipeline: raspberrypi: Conditionally open the embedded data node 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" Conditionally open the embedded data node in pipeline_handler::match() based on whether the ipa::init() result reports if the sensor supports embedded data or not. Signed-off-by: Naushir Patuck Tested-by: David Plowman Reviewed-by: Laurent Pinchart --- .../pipeline/raspberrypi/raspberrypi.cpp | 59 ++++++++----------- 1 file changed, 23 insertions(+), 36 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index ce1994186d66..ed8cc4ead771 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -138,7 +138,7 @@ class RPiCameraData : public CameraData { public: RPiCameraData(PipelineHandler *pipe) - : CameraData(pipe), embeddedNodeOpened_(false), state_(State::Stopped), + : CameraData(pipe), state_(State::Stopped), supportsFlips_(false), flipsAlterBayerOrder_(false), updateScalerCrop_(true), dropFrameCount_(0), ispOutputCount_(0) { @@ -183,7 +183,6 @@ public: std::unique_ptr delayedCtrls_; bool sensorMetadata_; - bool embeddedNodeOpened_; /* * All the functions in this class are called from a single calling @@ -749,19 +748,13 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) LOG(RPI, Error) << "Failed to configure the IPA: " << ret; /* - * The IPA will set data->sensorMetadata_ to true if embedded data is - * supported on this sensor. If so, open the Unicam embedded data - * node and configure the output format. + * Configure the Unicam embedded data output format only if the sensor + * supports it. */ if (data->sensorMetadata_) { format = {}; format.fourcc = V4L2PixelFormat(V4L2_META_FMT_SENSOR_DATA); - if (!data->embeddedNodeOpened_) { - data->unicam_[Unicam::Embedded].dev()->open(); - data->embeddedNodeOpened_ = true; - } - LOG(RPI, Debug) << "Setting embedded data format."; ret = data->unicam_[Unicam::Embedded].dev()->setFormat(&format); if (ret) { @@ -778,14 +771,6 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) */ if (rawStream) data->unicam_[Unicam::Embedded].setExternal(true); - } else { - /* - * No embedded data present, so we do not want to iterate over - * the embedded data stream when starting and stopping. - */ - data->streams_.erase(std::remove(data->streams_.begin(), data->streams_.end(), - &data->unicam_[Unicam::Embedded]), - data->streams_.end()); } /* @@ -989,24 +974,6 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) data->isp_[Isp::Output1] = RPi::Stream("ISP Output1", isp_->getEntityByName("bcm2835-isp0-capture2")); data->isp_[Isp::Stats] = RPi::Stream("ISP Stats", isp_->getEntityByName("bcm2835-isp0-capture3")); - /* This is just for convenience so that we can easily iterate over all streams. */ - for (auto &stream : data->unicam_) - data->streams_.push_back(&stream); - for (auto &stream : data->isp_) - data->streams_.push_back(&stream); - - /* - * Open all Unicam and ISP streams. The exception is the embedded data - * stream, which only gets opened if the IPA reports that the sensor - * supports embedded data. This happens in RPiCameraData::configureIPA(). - */ - for (auto const stream : data->streams_) { - if (stream != &data->unicam_[Unicam::Embedded]) { - if (stream->dev()->open()) - return false; - } - } - /* Wire up all the buffer connections. */ data->unicam_[Unicam::Image].dev()->frameStart.connect(data.get(), &RPiCameraData::frameStarted); data->unicam_[Unicam::Image].dev()->bufferReady.connect(data.get(), &RPiCameraData::unicamBufferDequeue); @@ -1036,6 +1003,26 @@ bool PipelineHandlerRPi::match(DeviceEnumerator *enumerator) return false; } + /* + * Open all Unicam and ISP streams. The exception is the embedded data + * stream, which only gets opened below if the IPA reports that the sensor + * supports embedded data. + * + * The below grouping is just for convenience so that we can easily + * iterate over all streams in one go. + */ + data->streams_.push_back(&data->unicam_[Unicam::Image]); + if (sensorConfig.sensorMetadata) + data->streams_.push_back(&data->unicam_[Unicam::Embedded]); + + for (auto &stream : data->isp_) + data->streams_.push_back(&stream); + + for (auto stream : data->streams_) { + if (stream->dev()->open()) + return false; + } + /* * Setup our delayed control writer with the sensor default * gain and exposure delays. Mark VBLANK for priority write.