From patchwork Wed Apr 6 07:58:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15624 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 15B80C3260 for ; Wed, 6 Apr 2022 07:59:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B97B76564D; Wed, 6 Apr 2022 09:59:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1649231949; bh=YfHkyuISdtpEFUz72XKQw2qLvqSSTFQnKC1b5Clku8o=; 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=eNidMTe+2SurCyhRescJ3eOtlg/2WZR5FqNG4B/b9SpEYMFEkdS2JpJGs1vVLvwZr R8OIBwsapcNfhuM6wm2AASbizjJ6e3v0MsjO81xsw4urtPYHBVkwpSNKPxdAzhu9nZ P6R7UZeGlz7lZ9ZWEogBOyuDea8iNe5WY5COd63Hqq2kyScf0WfiH+RYUHLYSqes5E KZH+0LAu9X3+8tkwRWHoF19HvF8X04ufSJ2mDDxJMkQ4BzjereGkIaz+G2C0SU5L2t wkAHiYnRpSMp5agX2jh4+jT+ygzs3RJw2KCCI3WZKIiIesceM2uCmGmFMKwRKs9G8j fiVuHZ32EOiVw== Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id BCD6665643 for ; Wed, 6 Apr 2022 09:59:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="AdmdVrAq"; dkim-atps=neutral Received: by mail-wr1-x430.google.com with SMTP id d29so1892794wra.10 for ; Wed, 06 Apr 2022 00:59:06 -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=n+SfiTLIZkbs8xSe1U6Qik4cd6Yqni5HDX2QUf9j1F4=; b=AdmdVrAq5m/5p0SeTRTsF+MIRDLTZINN4j9966/ZzsBbzAPHRp9xFaqwZGUZ6fKsnh oknRVLDmvF4xtQMgeLvc7/UmJ35V1/GZccacKr0qcSTXpiPS9KrTan4oGyrN0YYJt+Wo Vcq6CGPvYru80pG1GPBeeBT41482R+N0t3HhexEixSdvWIGpkKe3iVRvZGfW+fcwIUSJ vNiwH/DFfBVkhHINABfiwYllHO9fXStiExwlrcapr7cX4lnymrkiAX1IjbLqaYMYQKOF ATo8MtPaPprk9eBtrHHfeGQR8h9ZnWUsw99EMJrDq094Z/4FaHYJ0KZSyro9WEQtkeq8 MjAQ== 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=n+SfiTLIZkbs8xSe1U6Qik4cd6Yqni5HDX2QUf9j1F4=; b=4k/yxdiFO7D3VrrxqmuatO6iDI5H9VWmEWp+y+jzXMlWytpVeqTLQXGuVSHUJcJh8B t+XXe12zC3CmPuZj0xkdDj2uItwEyDlCfG6AtNRjdlS7dEJseH0Jt2XL4CIFoXfgOerk +mlGsyAesFbDxGmZMzm6USF4YBo92/8t+hT7JJtyGHZGQ5SqAvxK4sGS2GQeDbLz+9v/ BOGBlErErHno9AP61hIrP5NNi3eT6p3p9G3REvfkKaSKb/HRXhGXj0Y4YxdtBHse/ifg 0v5jHDBpUvCkeedtqEXsL7/57nBsxPMB08qB5XTgHnjL8kiXLyR8OOtOVD9CKdpJ5L20 gjjA== X-Gm-Message-State: AOAM532iu/LV90YpNbGrHH+N2hXMo58oRuhJtPiBRIfX23RPjp5kD/sl 5c7M9U4HiXmOvVFekBMjH272oLa7j1Oljw== X-Google-Smtp-Source: ABdhPJw7FXdXEMlMzYDUfZY9IlTY7x3dkz2KVE+kU+7j5OuIEXuarcN3THftm7+s86gTIukCjIVKtQ== X-Received: by 2002:adf:f60a:0:b0:206:1201:e223 with SMTP id t10-20020adff60a000000b002061201e223mr5580212wrp.712.1649231946069; Wed, 06 Apr 2022 00:59:06 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:eedb:32e2:e3d4:3bfa]) by smtp.gmail.com with ESMTPSA id 14-20020a056000154e00b00203f8adde0csm17235503wry.32.2022.04.06.00.59.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 00:59:05 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Apr 2022 08:58:58 +0100 Message-Id: <20220406075859.3857121-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220406075859.3857121-1-naush@raspberrypi.com> References: <20220406075859.3857121-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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" From: Naushir Patuck via 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 | 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..98c463e39548 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,10 @@ int PipelineHandlerRPi::start(Camera *camera, const ControlList *controls) } } + /* Set the dequeue timeout to 2x the maximum possible frame duration. */ + utils::duration timeout(2 * startConfig.maxSensorFrameLengthMs * 1ms); + data->unicam_[Unicam::Image].dev()->setDequeueTimeout(timeout); + return 0; } @@ -1192,6 +1199,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 +1781,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;