{"id":15502,"url":"https://patchwork.libcamera.org/api/patches/15502/?format=json","web_url":"https://patchwork.libcamera.org/patch/15502/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220322092257.2713521-6-naush@raspberrypi.com>","date":"2022-03-22T09:22:54","name":"[libcamera-devel,v4,5/8] libcamera: v4l2_videodevice: Better tracking of the device state","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"50a66aae867b71fcf6b05f89d2f7648b8098e446","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/15502/mbox/","series":[{"id":2982,"url":"https://patchwork.libcamera.org/api/series/2982/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2982","date":"2022-03-22T09:22:49","name":"Raspberry Pi: Efficient start/stop/start sequences","version":4,"mbox":"https://patchwork.libcamera.org/series/2982/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15502/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15502/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 183CAC3265\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 22 Mar 2022 09:23:09 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8BFB5632E8;\n\tTue, 22 Mar 2022 10:23:08 +0100 (CET)","from mail-wm1-x334.google.com (mail-wm1-x334.google.com\n\t[IPv6:2a00:1450:4864:20::334])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 179CF60397\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Mar 2022 10:23:05 +0100 (CET)","by mail-wm1-x334.google.com with SMTP id\n\t123-20020a1c1981000000b0038b3616a71aso922684wmz.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 22 Mar 2022 02:23:05 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:9e9a:99af:e5a6:319b])\n\tby smtp.gmail.com with ESMTPSA id\n\tr14-20020a05600c35ce00b0038c9f469979sm1471695wmq.40.2022.03.22.02.23.03\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tTue, 22 Mar 2022 02:23:03 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1647940988;\n\tbh=Q3pB5gwKJwI3YcvZWJDX8RjHEP1L+Gzz2Qm7b36XTW0=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=I6Z759dPxn0L64vbO7ZU++9WmX/4j/z/5QdQcUh7rSUzJ3/+ER013uZi9gFod+hXs\n\t75enmAD99hIsTdFarKtNF+buxEtYTHstHAqoEebIdjugykb92X5bF5W8sa6GAcVT8O\n\tmk3/z8SLwB4pKqB2fO0CNa6kiIWkKhONKV8KsuBpYK0a27lM0uxTm5s3Q6Azzx2UoY\n\tayiQmBAo3ALLhlI+CA3JchpJlBLCQujmy1Z0WIUZXNK8ah+yyfknYWcquXeW87Vjxe\n\tZfFPj1fw2M0x402wskW3M/ei7h34V0iEx418fQr0Dsudgdlp4XDeg2IFT0qfN3KiKC\n\tQz+nJgtvmK+LQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=HWiqsZ82lu+4g9I2xyM3lrW/napbwZNOsGa/P4WcuqY=;\n\tb=hCv/Y/cbVnBqkVk4fyaNFcvOfSIVI+4guz4LNUmxE/hObeOryN+NuAucpKqZzpoBSa\n\ta8GnNt2f8fXL5GMuGl6+UuEaaaOHUXHtN+m7nmEJNBlzmbruE1+uHH/YAWR0TOloDEzK\n\tZPbe9N1AWIllSQE5hta0sLZi4Fvx5OWl4rFECkSY6x7HXsobX9Le+NCYGbipaMWl65P3\n\tE5dlWCmg+DE4WfPf1cmVz+GjByrD3eQEo74t49e0kMPUG1IfGZB0GgB6iU9X+nVPavMY\n\t9FVorm5xf3qDIC2K9u5SB2WEgq1macQiA/jXBms3wIl3YJ5j9GUyyQlz7NoaMZ1Lreea\n\tcb2w=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"hCv/Y/cb\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=HWiqsZ82lu+4g9I2xyM3lrW/napbwZNOsGa/P4WcuqY=;\n\tb=X7XXkyBrWTklEp57/wSskD5yajuPwvGmovMQ5ONB5rfawllu/5nw8dquzjnQuks589\n\tK4T7dlFGUVsiz18KsvwmVYCVGDTnNh5hq8R5V/4kx6qsFRL+mxIT59E4a7uoJ1q++Rtb\n\tBeIKRoh6o9azTJzsK75uKzu7a0qn+Q1InIcpQeq3B7s71/O2BfDm1dhr3vxmMX8auuED\n\tOPXMYnwbJkgeEi+bXbd1fEyM9k5mO2NQMUVbS4LuJEBGnh0JSvBl3VCJDRr5yR/gxyO5\n\tmt5ohGadQr+cP5TL+XWJSW1avTjhX1ji2uAqqhw7ghTADTac98oow2UDvTlQNH14cVWU\n\tMwmQ==","X-Gm-Message-State":"AOAM530PETB6R7JogS9G+Gx/LX/1xfu19rylVIVAXub4T3+QarArV838\n\tBHxfFwgiO/EBhAL2cczLP9qu9OMzY5234A==","X-Google-Smtp-Source":"ABdhPJym4Qvu7hMr/AfuxW3JNkBcpMKeNTgYPmWIoiIozTZLTBxOKrtK6/7zAMKnkTJKlmmRsCZ3iw==","X-Received":"by 2002:a5d:6d05:0:b0:203:781d:3f7b with SMTP id\n\te5-20020a5d6d05000000b00203781d3f7bmr21167021wrq.442.1647940984288; \n\tTue, 22 Mar 2022 02:23:04 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Tue, 22 Mar 2022 09:22:54 +0000","Message-Id":"<20220322092257.2713521-6-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220322092257.2713521-1-naush@raspberrypi.com>","References":"<20220322092257.2713521-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 5/8] libcamera: v4l2_videodevice:\n\tBetter tracking of the device state","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Replace the existing streaming_ state variable with an enum to track the\nfollowing three state: Streaming, Stopping, and Stopped. The alternate states\nwill be used in a subsequent commit.\n\nSigned-off-by: Naushir Patuck <naush@raspberrypi.com>\n---\n include/libcamera/internal/v4l2_videodevice.h |  3 ++-\n src/libcamera/v4l2_videodevice.cpp            | 10 ++++++----\n 2 files changed, 8 insertions(+), 5 deletions(-)","diff":"diff --git a/include/libcamera/internal/v4l2_videodevice.h b/include/libcamera/internal/v4l2_videodevice.h\nindex 2d2ccc477c91..32e022543385 100644\n--- a/include/libcamera/internal/v4l2_videodevice.h\n+++ b/include/libcamera/internal/v4l2_videodevice.h\n@@ -258,7 +258,8 @@ private:\n \n \tEventNotifier *fdBufferNotifier_;\n \n-\tbool streaming_;\n+\tenum class State { Streaming, Stopping, Stopped };\n+\tState state_;\n };\n \n class V4L2M2MDevice\ndiff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\nindex 5f36ee20710d..9cea6a608660 100644\n--- a/src/libcamera/v4l2_videodevice.cpp\n+++ b/src/libcamera/v4l2_videodevice.cpp\n@@ -507,7 +507,7 @@ const std::string V4L2DeviceFormat::toString() const\n  */\n V4L2VideoDevice::V4L2VideoDevice(const std::string &deviceNode)\n \t: V4L2Device(deviceNode), formatInfo_(nullptr), cache_(nullptr),\n-\t  fdBufferNotifier_(nullptr), streaming_(false)\n+\t  fdBufferNotifier_(nullptr), state_(State::Stopped)\n {\n \t/*\n \t * We default to an MMAP based CAPTURE video device, however this will\n@@ -1796,7 +1796,7 @@ int V4L2VideoDevice::streamOn()\n \t\treturn ret;\n \t}\n \n-\tstreaming_ = true;\n+\tstate_ = State::Streaming;\n \n \treturn 0;\n }\n@@ -1818,7 +1818,7 @@ int V4L2VideoDevice::streamOff()\n {\n \tint ret;\n \n-\tif (!streaming_ && queuedBuffers_.empty())\n+\tif (state_ != State::Streaming && queuedBuffers_.empty())\n \t\treturn 0;\n \n \tret = ioctl(VIDIOC_STREAMOFF, &bufferType_);\n@@ -1828,6 +1828,8 @@ int V4L2VideoDevice::streamOff()\n \t\treturn ret;\n \t}\n \n+\tstate_ = State::Stopping;\n+\n \t/* Send back all queued buffers. */\n \tfor (auto it : queuedBuffers_) {\n \t\tFrameBuffer *buffer = it.second;\n@@ -1838,7 +1840,7 @@ int V4L2VideoDevice::streamOff()\n \n \tqueuedBuffers_.clear();\n \tfdBufferNotifier_->setEnabled(false);\n-\tstreaming_ = false;\n+\tstate_ = State::Stopped;\n \n \treturn 0;\n }\n","prefixes":["libcamera-devel","v4","5/8"]}