From patchwork Sat Mar 13 10:27:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11574 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 4C492BD80C for ; Sat, 13 Mar 2021 10:27:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E25A168C6C; Sat, 13 Mar 2021 11:27:48 +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="SjoeGLZO"; dkim-atps=neutral Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 35ADC602E3 for ; Sat, 13 Mar 2021 11:27:48 +0100 (CET) Received: by mail-wm1-x332.google.com with SMTP id r15-20020a05600c35cfb029010e639ca09eso17258787wmq.1 for ; Sat, 13 Mar 2021 02:27:48 -0800 (PST) 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=M+FmiV1+Z+NI3asFb2J1an453JDSYe2mOftFh6wRtHU=; b=SjoeGLZOGOt8g6nVByTNGe+XqeK29RvlNpp8eVkajpi+cTN7MNkfpNVLjyHtJAUxAz KGMQo+hUuBtbAxMVLTYOyCeF1tylJJPOc5mLchFPmwT2vxQNZ+b4O488Cxip4Qw+4seW ZBzs7AbMM2yy7YCFfwH9GW8Zj6MXGOkEnCWaF01zqErtEZHv+LddQltKJ0bfZ2AJ6k9b 8oi5Z3qESR/lk0pvTVW4i5pfrtRx1dTTSJDK75P0sfoXitUyZWUKk+zqbyexpS2GE4i7 sIdm7//svmNJ9TqYtUhazD1tbjTcntDPFuPYyUCqTmSf4FG/oT6iUutFPdy+kLPi2IUm zEBg== 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=M+FmiV1+Z+NI3asFb2J1an453JDSYe2mOftFh6wRtHU=; b=Gv/COPsfqfHJjtd+F+YZiPfrlWGrsORszvBiPorg2vMQ8BXaaugtSrWM0oOLYY04/4 dYiZf7nL/uCNfY5ysgFl+XNf9vxbr7KQ/XdS8uFSFadLneV31j1UqhXUnay/eDtBAaLS QDkN4+GD0E5Tvut3OP3umVWAER9P4w0L49GCflFJdx5VuEAJg+o44XfrjPeQ4H0UnuxT DFiHEMA6l2SV6vjysAzCff5+NVDbJ+MN5mmyBjbOzn1XcT+0ljDUQ1BcEH3PO8IdGF2l dIkqI4IqaiuqftBw2BgbQe6wcqr+AZQ8svD0GGUH6E/srZtGklm3yVzG0c4ldx6q6rrn sXfg== X-Gm-Message-State: AOAM5337ZMgy2FRKw0i07FMX5cH1yKpjq/Hi6+WcpPO5CEKmamsElnvD d7BthwMKmvVfn0jImYqJVFs2oNcXnKvdrA== X-Google-Smtp-Source: ABdhPJy8qprzO55afWvrlyCqA+NHCFh2D2o+L7IMCjLvHSn7BZtudejWSuJhMA+qYCYN4RS8Lydrpw== X-Received: by 2002:a1c:32ca:: with SMTP id y193mr17071556wmy.56.1615631267405; Sat, 13 Mar 2021 02:27:47 -0800 (PST) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id g5sm11760178wrq.30.2021.03.13.02.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Mar 2021 02:27:47 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Sat, 13 Mar 2021 10:27:40 +0000 Message-Id: <20210313102741.2890809-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210313102741.2890809-1-naush@raspberrypi.com> References: <20210313102741.2890809-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] pipeline: raspberrypi: Avoid multiple opens of Unicam 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" It is possible for the application to call pipeline_handler::configure() multiple times, which would attempt to open the Unicam embedded data node on every call. This would cause a warning message as the node would have already been opened. Avoid this by tracking if the node has previously been opened. Note that this is a temporary fix since the open call for the Unicam embedded data node will be moved from pipeline_handler::configure() to pipeline_handler::match(). Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- src/libcamera/pipeline/raspberrypi/raspberrypi.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 41f1cbffa931..9847e926b048 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), state_(State::Stopped), + : CameraData(pipe), embeddedNodeOpened_(false), state_(State::Stopped), supportsFlips_(false), flipsAlterBayerOrder_(false), updateScalerCrop_(true), dropFrameCount_(0), ispOutputCount_(0) { @@ -183,6 +183,7 @@ public: std::unique_ptr delayedCtrls_; bool sensorMetadata_; + bool embeddedNodeOpened_; /* * All the functions in this class are called from a single calling @@ -726,8 +727,13 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) 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."; - data->unicam_[Unicam::Embedded].dev()->open(); ret = data->unicam_[Unicam::Embedded].dev()->setFormat(&format); if (ret) { LOG(RPI, Error) << "Failed to set format on Unicam embedded: " From patchwork Sat Mar 13 10:27:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 11575 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 381F0BD80C for ; Sat, 13 Mar 2021 10:27:51 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E42D868C6F; Sat, 13 Mar 2021 11:27:50 +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="BEMguwvJ"; dkim-atps=neutral Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id DD40568C6B for ; Sat, 13 Mar 2021 11:27:48 +0100 (CET) Received: by mail-wr1-x432.google.com with SMTP id u16so6147174wrt.1 for ; Sat, 13 Mar 2021 02:27:48 -0800 (PST) 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=oGXfsRkbz8HkDNI8+Qu7uF2j02Mpg1d79eTG83Gb1KI=; b=BEMguwvJpelShv0GkytsQTdDw96i1y9+mrsHDG5pwubNVqn741NAy0bE1jvMt8CnJW jNijz58Q10SzB+pyZVcrmK0FpIOfAZubF1Amk7GmGZkejfWVQAmw5Y79u6+GIyY6bBaU Yd9Lop2PPHbOwWTxo1B4YFOwwFB8BFkXBZ/vsap98WneR7Bi3hXdi1tT8VVTrZcdsdRW Xrcz+K50M7xclt7qnb14+YMWumpKveIDmhYRirRnk1vKFdGmdVH+kp2qO/BSK31gYoRI 4dTgOhw6g+yPSPp/t28/fj2gugczD4ilhaFUv1CXdu82uwdcKf08f0OX+JKXJiTZdAD2 +LQA== 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=oGXfsRkbz8HkDNI8+Qu7uF2j02Mpg1d79eTG83Gb1KI=; b=QR6E21jPBRJE8QdZMpb8tdqQc+ETE2+v8TzlCEXMT1WZRZW301Z2hMX9A8oI/YIaP2 0ERHdnONSN9RjKboKJEWfio1SEtd4EVT/B9d+InuruZ71bP4mMyz8e7YRlAHHmUnhL28 Ll9SQesP3NaYAQ57hpD6PzMhxwAWXq2n3rNxDX9vJ2TLhvJwBW3/8VMi+jUHm9n/glFK lj5IP9r0/160W7raSKMcyzP3WFGdO34olpuUh0klU/zsP24ZCV9UM3i25gk1UGLTs6Uk qBu8cZFw4Co+7uQmYG80cyTi+K1Vo8031SzlnyYkPlLGRl/vvAvdcKTWgew/qWSEMUbE VnNg== X-Gm-Message-State: AOAM533k9/wydpePUi6i2EDhjIY47pxBBMxujo9STfEUDjmB/Ew/3QtT /VcojccaTjNYnCFUD1aMPrA3D4JmK99KYg== X-Google-Smtp-Source: ABdhPJzzLvymkPIVelHR0yCQfg+8JE1y3WmgEpq2/0sNU0qBiyeuEqPKD34Rs0x9MN6CFc52ys70CA== X-Received: by 2002:adf:e60a:: with SMTP id p10mr18596622wrm.291.1615631268268; Sat, 13 Mar 2021 02:27:48 -0800 (PST) Received: from naush-laptop.patuck.local ([88.97.76.4]) by smtp.gmail.com with ESMTPSA id g5sm11760178wrq.30.2021.03.13.02.27.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 13 Mar 2021 02:27:47 -0800 (PST) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Sat, 13 Mar 2021 10:27:41 +0000 Message-Id: <20210313102741.2890809-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210313102741.2890809-1-naush@raspberrypi.com> References: <20210313102741.2890809-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] pipeline: raspberrypi: Use a default format for ISP::Output0 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" If the ISP::Output1 stream has not been configured, we must enable it with a default format and resolution for internal use. This is to allow the pipeline handler data flow to be consistent, and allow the IPA to receive statistics for the frame. Signed-off-by: Naushir Patuck Reviewed-by: Laurent Pinchart --- .../pipeline/raspberrypi/raspberrypi.cpp | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index 9847e926b048..5cc04ce4eb92 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -625,7 +625,7 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) * StreamConfiguration appropriately. */ V4L2DeviceFormat format; - bool output1Set = false; + bool output0Set = false, output1Set = false; for (unsigned i = 0; i < config->size(); i++) { StreamConfiguration &cfg = config->at(i); @@ -662,6 +662,34 @@ int PipelineHandlerRPi::configure(Camera *camera, CameraConfiguration *config) if (i != maxIndex) output1Set = true; + else + output0Set = true; + } + + /* + * If ISP::Output0 stream has not been configured by the application, + * we must allow the hardware to generate an output so that the data + * flow in the pipeline handler remains consistent, and we still generate + * statistics for the IPA to use. So enable the output at a very low + * resolution for internal use. + * + * \todo Allow the pipeline to work correctly without Output0 and only + * statistics coming from the hardware. + */ + if (!output0Set) { + maxSize = Size(320, 240); + format = {}; + format.size = maxSize; + format.fourcc = V4L2PixelFormat::fromPixelFormat(formats::YUV420, false); + ret = data->isp_[Isp::Output0].dev()->setFormat(&format); + if (ret) { + LOG(RPI, Error) << "Failed to set default format on ISP Output0: " + << ret; + return -EINVAL; + } + + LOG(RPI, Debug) << "Defaulting ISP Output0 format to " + << format.toString(); } /*