{"id":15548,"url":"https://patchwork.libcamera.org/api/patches/15548/?format=json","web_url":"https://patchwork.libcamera.org/patch/15548/","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":"<20220325090903.880311-6-naush@raspberrypi.com>","date":"2022-03-25T09:09:00","name":"[libcamera-devel,v5,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/15548/mbox/","series":[{"id":2999,"url":"https://patchwork.libcamera.org/api/series/2999/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2999","date":"2022-03-25T09:08:55","name":"Raspberry Pi: Efficient start/stop/start sequences","version":5,"mbox":"https://patchwork.libcamera.org/series/2999/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/15548/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/15548/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 35145C3264\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 25 Mar 2022 09:09:17 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E65CD604D5;\n\tFri, 25 Mar 2022 10:09:16 +0100 (CET)","from mail-wm1-x331.google.com (mail-wm1-x331.google.com\n\t[IPv6:2a00:1450:4864:20::331])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5483B604C4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Mar 2022 10:09:13 +0100 (CET)","by mail-wm1-x331.google.com with SMTP id\n\t123-20020a1c1981000000b0038b3616a71aso3978129wmz.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 25 Mar 2022 02:09:13 -0700 (PDT)","from naush-laptop.pitowers.org\n\t([2a00:1098:3142:14:478c:773f:4734:d0bc])\n\tby smtp.gmail.com with ESMTPSA id\n\tc4-20020a056000184400b0020584c40778sm4915297wri.103.2022.03.25.02.09.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 25 Mar 2022 02:09:10 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1648199356;\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=kFzx16KZsedb0ZrJUb8cfN6fuqHFZm/TMwlnm95pdFYRVXGtG4y2WcvGxM6IvIBoE\n\t+CMHrIb8AKDxrBlGxA47LmUOTxuP0NA+lz8F90H0h+1bsLemBVfkeaKYoraY/7tgf5\n\tZqALzUoENQ26DlrHJwYW7jAULpSHpTjIEeijn9QH7d9UeqcjR8XaYqFwOtpZp2sggS\n\t0AFu0CO1/SeBZPY1LhYb/eWoO3I04KeTPF8O3PwO0eGPrSLr3p0QhEIGRcWkqhM/Xd\n\tqby6toK8ea5z3xyY0wJqoYrY44DFUIM1sk5I2roF8QhRAJSa5Rj3CyVJ8NGa/tPRdv\n\tXNvsi312FoazQ==","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=AbJ3m93GA5nk2+YsiFwIjZ/1U568mSHusvwYIfcCfRiCX7vVCdD4hJEuvmGD7M5txU\n\tNN94uMqwzmT6Dq364ftTHVb6axOIi7NdM05hDFDSqpkUI6aQ4WU5ciKYv08Lf2c9TlZ3\n\tbUJsWbrlG84DwnOqeEXq7aRrjOaWr4m5RfGtazJEbiGm067VYdda/AiPX5bSLZj1hItk\n\tEOJ/tSt7jCEkJrU+5O5DcRgP97bYRDeDGIsm0cYEMvA+iu43VnQ/aQNHf6EfS7mjSnJ5\n\tkFSnRNpNrOtSzzwFIsisN8fCLGdy1GTF6vOxvNzthXLa1QEXzoS2eDiMqlb83xaxUZBg\n\tUkhg=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"AbJ3m93G\"; 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=Z1f9kB0ujk/4mW8PgCijuDdWe4y6mQ3Kt9uFCuI0XUdR1t08JXPI3no4WuMEaUBWh7\n\tSKbWsdgkhxERc8AvLtPJgyhDPeNLL+z8DFXtx9Y0y/m0XCM4sA84Xievq7fqf6Ashtwm\n\ttuMLtzCjPtVWveen64t4ykF1Shpz+PC20azNHpbG96LdlZTij8sWKHfd1IqPEb7wz+5U\n\tFy/3Gct/dPa7L5HEh/14rmIOccH/z6QDrrnyrEul2+lzdqXs/TYBHsqGneV9GM1F7G6X\n\tu9lc1jKsoDQVsOp6Omg2wuQBIrv6MoEOI9SY5rdrYU9dcdy95scQMj/sYH5AKjX1gUm8\n\tg3fw==","X-Gm-Message-State":"AOAM533RxWc+MjWYqy7HRe7QBX5oJ84wTgV2AwI2E71HtwRMaQORztXp\n\t3mjud4I5WrwYJBoRoHAZoL8mqVw6G0KFEQ==","X-Google-Smtp-Source":"ABdhPJwuqOZX3XP0sqWj806E6cukTxPXpZqiP2OSaRphETaABQu1kkSiIxJNfr1xDeX38hBiuJjkGA==","X-Received":"by 2002:a05:600c:3512:b0:38c:be56:fc9c with SMTP id\n\th18-20020a05600c351200b0038cbe56fc9cmr15376466wmq.197.1648199351119; \n\tFri, 25 Mar 2022 02:09:11 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 25 Mar 2022 09:09:00 +0000","Message-Id":"<20220325090903.880311-6-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220325090903.880311-1-naush@raspberrypi.com>","References":"<20220325090903.880311-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 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","v5","5/8"]}