From patchwork Thu Mar 24 09:34:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15531 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 14311BD80A for ; Thu, 24 Mar 2022 09:34:16 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7D3D4604C5; Thu, 24 Mar 2022 10:34:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648114455; bh=cvsUhuGJdi2+O8B/WNlehg1JM8ArO7iMbY7zdhfE6Aw=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=XGVQpMA4SUWCF0Z/z6lNF6V5eLqJ/y7syFAv0eeXtatRIuXcxoisp6lV36dv2cfML DyNrjHXeXa5BhwWw44zFyoAPyjcTWgrjpIjUc7PlUQxJWAMV6LLLARN31U81YPI2Dc 9GQn1kvbqug+BCfqJbdB0d8+foHf/KzvjqGHhLRXbAofTvEs1/L9Z/IgGOD60/lvLv X5f7AbS5f8/DwZ8YMhR16ZHy7u2v4MeWJjtHMMIzwjXtMod9OrPh0dOGJssA6tRqfd rHr5jaDN3JitSIZxtHxPWw99pyVkC/sON80LBTaifmuxnAYq0ccLZhMl1oCcJXpDGE 46dQWwoA8Z55A== Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E707601F5 for ; Thu, 24 Mar 2022 10:34:13 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="mhnNwlId"; dkim-atps=neutral Received: by mail-wr1-x42d.google.com with SMTP id u3so5752972wrg.3 for ; Thu, 24 Mar 2022 02:34:13 -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=J177DCPIrCbnU3M3SWgf1jMhEAT05MNMBbvF1zi1x+I=; b=mhnNwlIdzUzDEWS0nZSddNYhMm33dq0QmJgi7sZrs9U4ubo1VjHrT2lhnXaeq+289h YpjTrceag+BjUPvnjzdN1dSPpcF+cga2xikmSUqFBclDrrYXRLxO9mKvihqRXqs7VpdV tTgfcXXgjpKFxY4EWwrZuycKlc9bnfY2CwoQThUqp0omeLtNLcedAgPNqWbNVPZwFgif gDdx+VErpITX2oo0nyBjoP02CQw+V6BpEJWuMe+43MxYvg+krIm7a/KLZMvnjEhmdXe6 +OPgnn7SLJrxrNek2hdLwE7WF1KuU1VD+TMmmM4vW1jR3rjVh8DxLp2TeTa+Eb2ENVrC TF/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=J177DCPIrCbnU3M3SWgf1jMhEAT05MNMBbvF1zi1x+I=; b=6VZZMteu7qG8vdjwMxw04V1l49iYMK1uyY2cH/jaEicw+KFuz/AhLL/i23mkRfMq4n cCppmLF2tMKHrla1X4tbUrF54PF7FCb1dDACK3GQsM7x5aFpivVBlGBZCTTFv792kJKs lrM5Td1DnW1pHMFleZbJ8z/1LpnzOzXWHSR1wKyw+K0AvIO3ZDgoGtTl8Exlf18odf0Z Bv/F2IpVe1Y2gChFna/QlMNz2thLaupWB3AIsQN+qGBDVxK+++9jK285Bc1DQtJNAzL+ VAi+V6I2n/OqkQV+hY/sE4gnW5Id7dfE7+MU+KbHrb7PPZwZVISCXpQCioi3z5wMFJqK 9loA== X-Gm-Message-State: AOAM531ID6P3Jq5DBcI/srDkqg9n47B4VkGkCZimbUqRfGIlxa2vX3Wv uCIk/dA5JGMO6hqyYkoKx/dojZiVmSAACQ== X-Google-Smtp-Source: ABdhPJxLXGjFXdUAXtuOVL84sBS6K8T1G4N36p+Oo3NtIKZqCPDVw8CCa93j/D97LWP0zolBYLvMaw== X-Received: by 2002:a05:6000:1547:b0:204:213:ae28 with SMTP id 7-20020a056000154700b002040213ae28mr3786796wry.114.1648114452617; Thu, 24 Mar 2022 02:34:12 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:18f1:1b78:a3ab:7eda]) by smtp.gmail.com with ESMTPSA id v15-20020a056000144f00b002057eac999fsm2243889wrx.76.2022.03.24.02.34.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 02:34:12 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 24 Mar 2022 09:34:09 +0000 Message-Id: <20220324093409.29247-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220324093409.29247-1-naush@raspberrypi.com> References: <20220324093409.29247-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/2] pipeline: raspberrypi: Add a Unicam dequeue timeout 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" Enable the V4L2VideoDevice dequeue timeout for the Unicam Image node, and connect the timeout signal to a slot in the pipeline handler. This slot will log a fatal error message informing the user of a possible hardware stall. The timeout is calculated as 2x the maximum frame length possible for a given mode, returned by the IPA. Signed-off-by: Naushir Patuck --- include/libcamera/ipa/raspberrypi.mojom | 1 + src/ipa/raspberrypi/raspberrypi.cpp | 2 ++ .../pipeline/raspberrypi/raspberrypi.cpp | 15 +++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/include/libcamera/ipa/raspberrypi.mojom b/include/libcamera/ipa/raspberrypi.mojom index acd3cafe6c91..5a228b75cd2f 100644 --- a/include/libcamera/ipa/raspberrypi.mojom +++ b/include/libcamera/ipa/raspberrypi.mojom @@ -41,6 +41,7 @@ struct IPAConfig { struct StartConfig { libcamera.ControlList controls; int32 dropFrameCount; + uint32 maxSensorFrameLengthMs; }; interface IPARPiInterface { diff --git a/src/ipa/raspberrypi/raspberrypi.cpp b/src/ipa/raspberrypi/raspberrypi.cpp index 1bf4e270b062..89767a9db471 100644 --- a/src/ipa/raspberrypi/raspberrypi.cpp +++ b/src/ipa/raspberrypi/raspberrypi.cpp @@ -280,6 +280,8 @@ void IPARPi::start(const ControlList &controls, ipa::RPi::StartConfig *startConf } startConfig->dropFrameCount = dropFrameCount_; + const Duration maxSensorFrameDuration = mode_.max_frame_length * mode_.line_length; + startConfig->maxSensorFrameLengthMs = maxSensorFrameDuration.get(); firstStart_ = false; lastRunTimestamp_ = 0; diff --git a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp index c2230199fed7..58b1179c4294 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -202,6 +202,7 @@ public: void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls); void setSensorControls(ControlList &controls); + void unicamTimeout(); /* bufferComplete signal handlers. */ void unicamBufferDequeue(FrameBuffer *buffer); @@ -1032,6 +1033,11 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) } } + /* Set the dequeue timeout to 2x the maximum possible frame duration. */ + std::chrono::milliseconds msec(startConfig.maxSensorFrameLengthMs * 2); + data->unicam_[Unicam::Image].dev()->setDequeueTimeout(msec); + LOG(RPI, Debug) << "Setting Unicam timeout to " << msec << " ms."; + return 0; } @@ -1176,6 +1182,7 @@ int PipelineHandlerRPi::registerCamera(MediaDevice *unicam, MediaDevice *isp, Me data->isp_[Isp::Stats] = RPi::Stream("ISP Stats", ispCapture3); /* Wire up all the buffer connections. */ + data->unicam_[Unicam::Image].dev()->dequeueTimeout.connect(data.get(), &RPiCameraData::unicamTimeout); data->unicam_[Unicam::Image].dev()->frameStart.connect(data.get(), &RPiCameraData::frameStarted); data->unicam_[Unicam::Image].dev()->bufferReady.connect(data.get(), &RPiCameraData::unicamBufferDequeue); data->isp_[Isp::Input].dev()->bufferReady.connect(data.get(), &RPiCameraData::ispInputDequeue); @@ -1757,6 +1764,14 @@ void RPiCameraData::setSensorControls(ControlList &controls) sensor_->setControls(&controls); } +void RPiCameraData::unicamTimeout() +{ + LOG(RPI, Error) + << "Unicam has timed out!\n" + "Please check that your camera sensor connector is attached securely.\n" + "Alternatively, try another cable and/or sensor."; +} + void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) { RPi::Stream *stream = nullptr;