From patchwork Tue Mar 22 13:16: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: 15509 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 C88A8C0F1B for ; Tue, 22 Mar 2022 13:16:46 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 85FBB604DB; Tue, 22 Mar 2022 14:16:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1647955006; bh=SRHd8zX2rGP5uypPrEvgme6+IFfRAI8ytSzNdhWjXDU=; 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=D5qzvjP6uOl583JNYA/E3nICiCPFvW01Ew0nW34BrlaLI7xUrBNB4FXP5B1OLyTOt TpsJsL7dUiXMdCwi4UnpMNOTGzBrYXP56PACqc9ekX1qLQVomdu1h3J5QwbU55Qnfg tOxlUNV0Wk7g7AH2gDg0zijTS/wJHjGYTlQ+NQb5h4fvsL/MmaQG8mjzWr27RQ0uCn MQOp4bsyc6HrlUgFRMyL6cHt+6Hv0cj2GZDE+mDEydiqSSb6vkdMqj6kITFFyHEN40 uMywRtJvUOx1HGrv5Zir2O/2TsWkdxL1Tckr2hYxnHCGPnvhHO/Dxd3OcH/04O9xyx Q14OmBadrkUxw== Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 77414604E8 for ; Tue, 22 Mar 2022 14:16:41 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Bvu3mWU9"; dkim-atps=neutral Received: by mail-wm1-x333.google.com with SMTP id bi13-20020a05600c3d8d00b0038c2c33d8f3so2431665wmb.4 for ; Tue, 22 Mar 2022 06:16:41 -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=tgA21Uc9i7A/Vd4j8bEgnI9K63bVJqGeeiMn4t/Uurs=; b=Bvu3mWU9RKcLvF9hkwFGQi3koH+ZoCIfbYAblzfJ2VHgDX7ekNcxYuSKLVIJwfWqyb pog/NsbBWwoDv0KOah+7yQbIziKfypTIA0PqRxLWuLM/4jVuNiE54y8hR0suOrpfa8zf QpA0TpywAY9H0Ik49RbNy39NMDYKSxnnU54ZsSLd1oyI9JgjPAjEYxZK3UGh8T0HBAix ijiYq76rm62YIbJ29P5vO/RYcNDOdDNIfXNWT3z8hZlImdYwkRdMoVoQZiAqoKmcsX0i Qo3+ry5i/7Q0pHhnIcAPKss9SggMahbo0S7w0H84Ly9P3N8fUuNpUIBo5GM/cEGDbSu3 DdxQ== 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=tgA21Uc9i7A/Vd4j8bEgnI9K63bVJqGeeiMn4t/Uurs=; b=r7+cVDqJbWaUif04VNSXnZtZSxzqV/Cwq2fA/khPQIY9YOBJXcSU0/FTFOh2l8e7Zf NPOMvD7CyvHGr7H5q8mkAz0JAxF1i9iWms9rZUq+ymtTYKmYzYLnKDY4B/hp+LvATGop JpfXx0gWPy/xSE018h3bEtjksZYylgfiyJ1PPoPOAp/TweMGSP3PhjXWjZTXPryI8k6h K+NZnrEUIab6A2d7DfaKNQb9dTKoVHGDIlIhjmkxrFYodVI0BSgBQNegWlKFGvq+E9Li pxfjTDglqTCzMxMkjL9dh9GSFtVCupeLPnEYoD0lpvV6FkAPTctdKWMnmzI1LibRrgfc un1A== X-Gm-Message-State: AOAM533yBcnOfMbeew9MlVMX4lxHhZa2vSHlnXPBWZP/COJ9dvtOWlaA D4UGCiMy104R8nHyXxFUgdjGFfUvmZ2Kpw== X-Google-Smtp-Source: ABdhPJxKY8R0YQ6OafX9uarK9lQ5wWJVLxv+YBh6Y18/S0oFmklCel0XNLDZcMJ409In0f8GKnqcZg== X-Received: by 2002:adf:e6ce:0:b0:203:d9cb:a1b4 with SMTP id y14-20020adfe6ce000000b00203d9cba1b4mr22731083wrm.140.1647955000933; Tue, 22 Mar 2022 06:16:40 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:9e9a:99af:e5a6:319b]) by smtp.gmail.com with ESMTPSA id n14-20020a7bcbce000000b0038c7776a300sm2293478wmi.0.2022.03.22.06.16.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Mar 2022 06:16:40 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Mar 2022 13:16:35 +0000 Message-Id: <20220322131635.2869526-4-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220322131635.2869526-1-naush@raspberrypi.com> References: <20220322131635.2869526-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 3/3] 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 fd8fecb07f81..675f9ba1b350 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..50b39f1adf93 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -45,6 +45,8 @@ #include "dma_heaps.h" #include "rpi_stream.h" +using namespace std::literals::chrono_literals; + namespace libcamera { LOG_DEFINE_CATEGORY(RPI) @@ -202,6 +204,7 @@ public: void setIspControls(const ControlList &controls); void setDelayedControls(const ControlList &controls); void setSensorControls(ControlList &controls); + void unicamTimeout(V4L2VideoDevice *dev); /* bufferComplete signal handlers. */ void unicamBufferDequeue(FrameBuffer *buffer); @@ -1032,6 +1035,12 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) } } + /* Set the dequeue timeout to 2x the maximum possible frame duration. */ + utils::Duration duration = startConfig.maxSensorFrameLengthMs * 2 * 1ms; + data->unicam_[Unicam::Image].dev()->setDequeueTimeout(duration); + data->unicam_[Unicam::Image].dev()->dequeueTimeout.connect(data, &RPiCameraData::unicamTimeout); + LOG(RPI, Debug) << "Setting sensor timeout to " << duration; + return 0; } @@ -1040,6 +1049,7 @@ void PipelineHandlerRPi::stopDevice(Camera *camera) RPiCameraData *data = cameraData(camera); data->state_ = RPiCameraData::State::Stopped; + data->unicam_[Unicam::Image].dev()->dequeueTimeout.disconnect(); /* Disable SOF event generation. */ data->unicam_[Unicam::Image].dev()->setFrameStartEnabled(false); @@ -1757,6 +1767,11 @@ void RPiCameraData::setSensorControls(ControlList &controls) sensor_->setControls(&controls); } +void RPiCameraData::unicamTimeout([[maybe_unused]] V4L2VideoDevice *dev) +{ + LOG(RPI, Fatal) << "Unicam has timed out!"; +} + void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) { RPi::Stream *stream = nullptr;