From patchwork Wed Apr 6 12:35:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15632 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 26A38C0F1B for ; Wed, 6 Apr 2022 12:36:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 632576564C; Wed, 6 Apr 2022 14:36:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1649248564; bh=Z37E5czrIxS96iACdLcn9YE3Yf7nsd/gVZv1kceH06E=; 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=zG5PbzLIcSog+kbsclKnq4naIq2eiayWLmnuUhLEMrRl+prNUnLN8+9YWjkhaFNAf 5sqkQBnB0Io+88pF1JzVYnjMLu5+OpqAXLNxw6xCm8YZWqkRNiHnJ+0vc1/KuaKiVh HfdppLT3Mo+x2b6ZYnyMdGdnRjEQmW8Lw3l4FHk1H+GZZ85cyG5jjSkgxuFSngRRLe mP8d7dYfH7t6wbQLjaJy4h/cuLNgIl2nhAdfIaP7zMogyt+56hrTDiCWWokSxxjP/w 3Po52ryCgsXbghocMbjc4C1hUe6xlM1LVW0CJOCd0w2ZJacjmdOQgpgaSxlqDEW0sz p52jnOHF23iQw== Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0D7126563F for ; Wed, 6 Apr 2022 14:36:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="d/w9tiHw"; dkim-atps=neutral Received: by mail-wr1-x433.google.com with SMTP id m30so3036114wrb.1 for ; Wed, 06 Apr 2022 05:36:03 -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=SfEznbmp787RA8aq2UHbqCWXXr1yMkSr3uFtkGUjOHE=; b=d/w9tiHwgP2fJ0pxkZkA31T/RT2X5NciOfmc/uhek1pr9MAB47qPyFCss2lQl5wJD4 xPYXdHaA63edTwbC2nhiwv2xEGjXeaALi9VPA0PxWMwAG5SG3/jvX2uTzxQEixm0QWiZ gKvhY3/RYfgNPDDJ+OBOk/DfSTOoRSCLsB5CoB/3EGT8z50oAOgIuAym9+IwrT5dvq6B GBU6+wBfRG1YvbfDppjnuS1si0kAzDQgv0i+jD8YqfB3kyO8CQh1tG5KF3ccz8cV4cFt n1wEgaLHxvsZijOe2bJiUF/vX6Y/DDdnVcVMkvqPgq94vMPVcNV9OXh6mxTXRdKTyUps eL1g== 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=SfEznbmp787RA8aq2UHbqCWXXr1yMkSr3uFtkGUjOHE=; b=7AchjltM/y8QrdTN73hxK3GjBUQQcVmoz5jPTXcEgUp41WC6o4+yFkRPmVOLc6rxpb Um03xBB/k/w23jIvtE3b8qr04rzNOd+4P7aLrefnksS5M3/i8gZKIoltFrpqqeAuIZhq lYvWmA/JxUYswSGAT4PhB4CH73PLchwbH8oQmXUVsbAsGl7KDV1DTaSehxWEqkmUvs2f ACtMkV4ffUg0IR68smC5tiF1a+D89I0ZMYKroYJpVch5i5oSsk5X/4vAyrKWB2K5wnP1 TfLKo8AI3+XqI9qqw0nExYnMzd4KviMH3h0POELU8cbHuDr0vMSMkmWvdqGMhGsbpNY9 ugxA== X-Gm-Message-State: AOAM533rk7i9U9E4QfQ2Kl1WxP8WfrcxpzRax8O61uQ0kxh0WltXeQ1W 6YIeaTjhyQ0faYCU1JXw26UeeoNJTrXscw== X-Google-Smtp-Source: ABdhPJwf/Qn01fMIcwmZCLZbzf/umDyeb6QidGgFctauHT0x37lFblji5SYXrpdTyLwLzj1JbNbWjA== X-Received: by 2002:adf:f74a:0:b0:206:1767:129 with SMTP id z10-20020adff74a000000b0020617670129mr3852440wrp.87.1649248562545; Wed, 06 Apr 2022 05:36:02 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:8464:e7f5:f44c:ee9f]) by smtp.gmail.com with ESMTPSA id p8-20020a5d59a8000000b00204178688d3sm16712490wrr.100.2022.04.06.05.36.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 05:36:01 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Apr 2022 13:35:53 +0100 Message-Id: <20220406123554.4042163-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220406123554.4042163-1-naush@raspberrypi.com> References: <20220406123554.4042163-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 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 an 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 | 19 +++++++++++++++++++ 3 files changed, 22 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..d6148724bdd5 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::chrono_literals; + namespace libcamera { LOG_DEFINE_CATEGORY(RPI) @@ -208,6 +210,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 +1053,14 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) } } + /* + * Set the dequeue timeout to the larger of 2x the maximum possible + * frame duration or 1 second. + */ + utils::Duration timeout = + std::max(1s, 2 * startConfig.maxSensorFrameLengthMs * 1ms); + data->unicam_[Unicam::Image].dev()->setDequeueTimeout(timeout); + return 0; } @@ -1192,6 +1203,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 +1785,13 @@ void RPiCameraData::setSensorControls(ControlList &controls) sensor_->setControls(&controls); } +void RPiCameraData::unicamTimeout() +{ + LOG(RPI, Error) << "Unicam has timed out!"; + LOG(RPI, Error) << "Please check that your camera sensor connector is attached securely."; + LOG(RPI, Error) << "Alternatively, try another cable and/or sensor."; +} + void RPiCameraData::unicamBufferDequeue(FrameBuffer *buffer) { RPi::Stream *stream = nullptr;