From patchwork Tue Mar 29 11:29:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15582 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 BBC66C3265 for ; Tue, 29 Mar 2022 11:29:38 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 938F665631; Tue, 29 Mar 2022 13:29:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1648553377; bh=mjbznzRxFUAL8z7yRVPduBNyO7b2NUX6pOgQk8ld8OU=; 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=13pi91tlXlKEge/MQgkRfNx+0cjpGtHWhNzZxMYnphcycEO0L6UwVwNYYIw33T7Og yyARuu2jz2iJbjuk9V9PFLAzMES6utGc5krg1zEJOE1P/+Ym4w5LWshDorha9BYqG2 r9CTlg7kN16Pe8yDEYZZS1gdTA8isqxCKPccrtQD3ppoQ45A7HTjU6KZ9Fj7fOfNLp MidXtReJsYdrJTgHMypklETv3IO1Hd1enXyU2ww+xJ4FCN7yDfiN4NL6Ksry2861qq lGRFv+SJAS56V3X/vXVpcoguaf5571zziXs/0FMVWDGHfmRpDa0Cj58R6/W1GO4Rdk A4DeKfHpAO7Dg== Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B508460135 for ; Tue, 29 Mar 2022 13:29:35 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="r/s6RgHX"; dkim-atps=neutral Received: by mail-wr1-x42f.google.com with SMTP id m30so24360592wrb.1 for ; Tue, 29 Mar 2022 04:29:35 -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=PMJdW2rucqrbrTu3le2vUiYbMO1fA9w3WTWdb1FkfOY=; b=r/s6RgHX1z4RBEmejda9XqRlzC95Ai63VYHEuFiTatG9ezXwYORE3u4HquTsZGBtDt I9ggDH/WiIE4Jb8ykdgfPRCNQcBXH4kuQeFQS1og8sWsZIW2eXX5SFhCr6deGdYEeuHm fZDRbN6o4vsMJ4jr/JcdS7l90WRIdDl8z7JmGUNDLdLpda/L9Z8CEBy3LUtJY3I2Ypds Zqh0uz4v8xS71dRr1eirBEJ8SO6OFXwVwzzcNnhKM56FjHk7Ro8raC3pHi1qUM+x0mqo KfRsxg8UJIxMZZ2EMpg5wNGYzoFyBLdFaT3mwiJeLA+S0+GUpgnRsqrJRnl8HGY2vxLe rbkQ== 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=PMJdW2rucqrbrTu3le2vUiYbMO1fA9w3WTWdb1FkfOY=; b=vEvOo8RHhYq0MRdQKp7kraxMeP4GUIscKvkty3VIMZhgDX+ao+NDRVd8xxX9YMpdwP iUZQ9LnUeERQKMDVSJlw1ILBsCLShKQzbYmkQIQPHNbFw/ZwEvlZqje8cZ/bx0di+GDL tGa7gn8Sq6vEkWbMxFLxVEC+hBEZ/E62GmhSnoZuqAuQ+2yhE0e2rYIzEZfu93M+vPcs Oso37Fp+968mF79wjUGam/IjuDTvNUIkiOdKcUOuSD6+myuqJ+UsZMbwsDOTC/SUWy5G e3bgfq9vRqDZD6WhGBG9zEmBuBfUXkf93ZVM1+1xk1FOw+M9OGXpCS7cV7TEKxGlU2ed rrOg== X-Gm-Message-State: AOAM530fVV4CZh38QbBA06q8U+6fH11akGC+K/gsL5EKlU5/YPZjjeK5 ufPktUjkeAoawBaSGdWKK6yeoP7HIfw+xQ== X-Google-Smtp-Source: ABdhPJycWBY8s48ViGs+xuPO0oCpSRjOwvn7TXz+Gg1TQZaYQH9/eSmDHgDZjN4O5ozEeP7fGhZScQ== X-Received: by 2002:a5d:6e0c:0:b0:1ef:7cbb:a5aa with SMTP id h12-20020a5d6e0c000000b001ef7cbba5aamr30300155wrz.5.1648553374832; Tue, 29 Mar 2022 04:29:34 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:e34f:94fd:5684:9ead]) by smtp.gmail.com with ESMTPSA id bi20-20020a05600c3d9400b0038cfe80eeddsm1767436wmb.29.2022.03.29.04.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Mar 2022 04:29:34 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Tue, 29 Mar 2022 12:29:28 +0100 Message-Id: <20220329112929.465434-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220329112929.465434-1-naush@raspberrypi.com> References: <20220329112929.465434-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/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 Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- 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 8fd79be67988..93931aaf3b55 100644 --- a/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp +++ b/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp @@ -208,6 +208,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); @@ -1050,6 +1051,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; } @@ -1192,6 +1198,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); @@ -1773,6 +1780,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;