From patchwork Thu May 5 08:48:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 15782 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 049FCC0F2A for ; Thu, 5 May 2022 08:48:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 25CA0604A2; Thu, 5 May 2022 10:48:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1651740512; bh=Nh9CViZESi3ZWpsw7UqYSp6wFdravTGRij9KX+92sTY=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mOxCKNPY9UR70ElDTVL/NG+f0MhG3koOgNL9YaJSVNDBpjtzz2uedLXVx82h0j97c YpJmgLZ3dbDh1RE9edlfaeW0B/Uyz+FyRne2OOrqWGqvQyyM9UBV0Qq0UD8aGoN7KD IoWigc4t5OR92/uc4zVDKTB+Do71iQGCqL5iE6io1z9U6o1qgJqrloHOUExtH387+N EFSOxrgXYt5qplKv0WpkUKYJwlezCrhc6SYYlWL9sjfrRa/XjbdXS+v7fDnL2cyhpr c106GlCDJEpPOKvoZcPrJG/Aq82SdCEoYLRpQqP3OFcLdu7v7FwgJ7igfNHQZyz95J yxnWAheVrMrvg== Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8B032604A2 for ; Thu, 5 May 2022 10:48:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="fhdHeOkV"; dkim-atps=neutral Received: by mail-wm1-x332.google.com with SMTP id bg25so2207172wmb.4 for ; Thu, 05 May 2022 01:48:29 -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:mime-version :content-transfer-encoding; bh=1XQYtPnGMekwManzDNKOC0qUk7neUy1qkELL9SJUG1I=; b=fhdHeOkVzsubcPNNQ2sJJbEGoTR7bcnK5qM7fKWPYB6hk0jfrgpeMmz9lkrKf4b8D0 KhVVH/aLAU/1LQmJ9vQzYGJ/zohP/BRT8oTa85FsO+rHNebTSd352tFp9syiM5+Yzzac XhK6dxHa0OFTf88pRsg7+PmcG4lf7jqMzMFTG972nwaDSHmTPs3P2qC4qDicBlYGkDHo d2+nNLnGdBvbUfQcy8pm48VWoHiiqnAJ2C4HdmvyjpKHbOUsVUKQpQvkz3HJU0PpuN8h bp3Fvb4kXwHfgwktcSZSyahh0OP0P1JSjool9f4fPZwOEr0tnRxlFfDQLUDsMGuMm1BS Ftxw== 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:mime-version :content-transfer-encoding; bh=1XQYtPnGMekwManzDNKOC0qUk7neUy1qkELL9SJUG1I=; b=gc0fQiya2jKJjUiFiRYFhI+AcpT1Be7jg9J2E5PUOWnmqizTBq6aP9rAeWFTgzKTfQ FYrYSG9O7hH4MOzikdZ8/liUWHG27FDSKg7VN+Gx0FjHqWvyy6KBO35QDNS36x1n40de QHpc5myM0UpdH2CRM7NispcD0MlSH9TtHEkchlooLsKV3KnZZgfK+nIAt+/f4FYSRnx/ ZA9kZtGsjUNrcL8rFdmxSz/MILqmp6ikVaNoXfDhcGJTVbOcJSxVtdXvSOEI8fIaDlAV AxLcW4SH3hN1EAjbT7Tl7EtsBSBbMO5MvIzPZxq/vjWf3RlmqLkhmMd+C0905L+YqCYq EYhg== X-Gm-Message-State: AOAM533YBoUKCtez+eVcPaa4QGh3bmSCi56hZvH2q/CYbdB/cuVeeWCP GZNW5kLZekCFZzMUVFIIcf09gDJWPEcTtw== X-Google-Smtp-Source: ABdhPJwr32upuyitT9NI39NtCKBntxEAS9vIJswwfRpHrbnnLp0IK8CQHWQIRQf2p9TSNgSAYWNRZg== X-Received: by 2002:a05:600c:24a:b0:394:4ce6:57db with SMTP id 10-20020a05600c024a00b003944ce657dbmr3476136wmj.193.1651740508834; Thu, 05 May 2022 01:48:28 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:5723:5bb6:c5c7:3c86]) by smtp.gmail.com with ESMTPSA id c17-20020a056000105100b0020c5253d8ccsm704209wrx.24.2022.05.05.01.48.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 May 2022 01:48:28 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Thu, 5 May 2022 09:48:24 +0100 Message-Id: <20220505084824.4104296-1-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1] v4l2_videodevice: Disable the watchdog timer when no buffers are queued 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" Only enable/reset the watchdog timer when there are buffers queued in the V4L2 device. Otherwise, we may trigger spurious warnings when the watchdog times out even if there are no buffers queued in the device. Signed-off-by: Naushir Patuck Reviewed-by: Kieran Bingham Tested-by: David Plowman Reviewed-by: Laurent Pinchart --- src/libcamera/v4l2_videodevice.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index 5b4637b1a39e..430715afd554 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -1662,8 +1662,11 @@ int V4L2VideoDevice::queueBuffer(FrameBuffer *buffer) return ret; } - if (queuedBuffers_.empty()) + if (queuedBuffers_.empty()) { fdBufferNotifier_->setEnabled(true); + if (watchdogDuration_) + watchdog_.start(std::chrono::duration_cast(watchdogDuration_)); + } queuedBuffers_[buf.index] = buffer; @@ -1742,16 +1745,21 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer() return nullptr; } - if (watchdogDuration_.count()) - watchdog_.start(std::chrono::duration_cast(watchdogDuration_)); - cache_->put(buf.index); FrameBuffer *buffer = it->second; queuedBuffers_.erase(it); - if (queuedBuffers_.empty()) + if (queuedBuffers_.empty()) { fdBufferNotifier_->setEnabled(false); + watchdog_.stop(); + } else if (watchdogDuration_) { + /* + * Restart the watchdog timer if there are buffers still queued + * in the device. + */ + watchdog_.start(std::chrono::duration_cast(watchdogDuration_)); + } buffer->metadata_.status = buf.flags & V4L2_BUF_FLAG_ERROR ? FrameMetadata::FrameError @@ -1847,7 +1855,7 @@ int V4L2VideoDevice::streamOn() } state_ = State::Streaming; - if (watchdogDuration_.count()) + if (watchdogDuration_ && !queuedBuffers_.empty()) watchdog_.start(std::chrono::duration_cast(watchdogDuration_)); return 0; @@ -1924,7 +1932,7 @@ void V4L2VideoDevice::setDequeueTimeout(utils::Duration timeout) watchdogDuration_ = timeout; watchdog_.stop(); - if (watchdogDuration_.count() && state_ == State::Streaming) + if (watchdogDuration_ && state_ == State::Streaming && !queuedBuffers_.empty()) watchdog_.start(std::chrono::duration_cast(timeout)); }