[{"id":2962,"web_url":"https://patchwork.libcamera.org/comment/2962/","msgid":"<20191025231248.GD17290@pendragon.ideasonboard.com>","date":"2019-10-25T23:12:48","subject":"Re: [libcamera-devel] [PATCH] libcamera: v4l2_videodevice: Track\n\tstreaming state","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nThank you for the patch.\n\nOn Fri, Oct 25, 2019 at 03:13:27PM +0100, Kieran Bingham wrote:\n> Track the state of streamon/streamoff calls to simplify error paths.\n> \n> Ensuring that streamOff() can be called on non-streaming streams\n> facilitates simpler error code paths, where a set of devices can all\n> call streamOff regardless of their initialisation state.\n> \n> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n> \n> Since RFC:\n>  - Rebased to master.\n> \n>  src/libcamera/include/v4l2_videodevice.h |  2 ++\n>  src/libcamera/v4l2_videodevice.cpp       | 10 +++++++++-\n>  2 files changed, 11 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\n> index 4b8cf9394eb9..caf36bf9c1aa 100644\n> --- a/src/libcamera/include/v4l2_videodevice.h\n> +++ b/src/libcamera/include/v4l2_videodevice.h\n> @@ -187,6 +187,8 @@ private:\n>  \tstd::map<unsigned int, Buffer *> queuedBuffers_;\n>  \n>  \tEventNotifier *fdEvent_;\n> +\n> +\tbool streaming_;\n>  };\n>  \n>  class V4L2M2MDevice\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 208ab54199b1..c0b3a79f76da 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -272,7 +272,8 @@ const std::string V4L2DeviceFormat::toString() const\n>   * \\param[in] deviceNode The file-system path to the video device node\n>   */\n>  V4L2VideoDevice::V4L2VideoDevice(const std::string &deviceNode)\n> -\t: V4L2Device(deviceNode), bufferPool_(nullptr), fdEvent_(nullptr)\n> +\t: V4L2Device(deviceNode), bufferPool_(nullptr), fdEvent_(nullptr),\n> +\t  streaming_(false)\n>  {\n>  \t/*\n>  \t * We default to an MMAP based CAPTURE video device, however this will\n> @@ -1173,6 +1174,8 @@ int V4L2VideoDevice::streamOn()\n>  \t\treturn ret;\n>  \t}\n>  \n> +\tstreaming_ = true;\n> +\n>  \treturn 0;\n>  }\n>  \n> @@ -1190,6 +1193,9 @@ int V4L2VideoDevice::streamOff()\n>  {\n>  \tint ret;\n>  \n> +\tif (!streaming_)\n> +\t\treturn 0;\n> +\n\nI forgot to mention that previously, I think the documentation should be\nupdated to state that stopping an already stopped device is a no-op.\nWith that,\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  \tret = ioctl(VIDIOC_STREAMOFF, &bufferType_);\n>  \tif (ret < 0) {\n>  \t\tLOG(V4L2, Error)\n> @@ -1210,6 +1216,8 @@ int V4L2VideoDevice::streamOff()\n>  \tqueuedBuffers_.clear();\n>  \tfdEvent_->setEnabled(false);\n>  \n> +\tstreaming_ = false;\n> +\n>  \treturn 0;\n>  }\n>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DF60161500\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 26 Oct 2019 01:12:56 +0200 (CEST)","from pendragon.ideasonboard.com (143.121.2.93.rev.sfr.net\n\t[93.2.121.143])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4426E2F7;\n\tSat, 26 Oct 2019 01:12:56 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1572045176;\n\tbh=6aqeCGICocWeA4v3iXeYVb+NCgnnOQDf167ngvIzSs8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=J66jpMHPYF6dZK6HcmA7pznsgU9Hd55ek4D0Flsa3QxLrck7HrtUu5UpGrBvX6G9M\n\tmTfSuTzG1QuGeT5uNSwKouVdwrkMrwfFd3T9NMt/QeyRpewFFtqXFwGIfvshQpnRqF\n\tnFTJnTizGjbnkYwfr9eDTgBEjurfd90okJ5hOzOk=","Date":"Sat, 26 Oct 2019 02:12:48 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Message-ID":"<20191025231248.GD17290@pendragon.ideasonboard.com>","References":"<20191025141327.2803-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20191025141327.2803-1-kieran.bingham@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH] libcamera: v4l2_videodevice: Track\n\tstreaming 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>","X-List-Received-Date":"Fri, 25 Oct 2019 23:12:57 -0000"}},{"id":2975,"web_url":"https://patchwork.libcamera.org/comment/2975/","msgid":"<20191028104835.GB20198@bigcity.dyn.berto.se>","date":"2019-10-28T10:48:35","subject":"Re: [libcamera-devel] [PATCH] libcamera: v4l2_videodevice: Track\n\tstreaming state","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Kieran,\n\nThanks for your work.\n\nOn 2019-10-25 15:13:27 +0100, Kieran Bingham wrote:\n> Track the state of streamon/streamoff calls to simplify error paths.\n> \n> Ensuring that streamOff() can be called on non-streaming streams\n> facilitates simpler error code paths, where a set of devices can all\n> call streamOff regardless of their initialisation state.\n> \n> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\nWith Laurent's comment about documenting the new behavior of streamOff() \naddressed,\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\n> ---\n> \n> Since RFC:\n>  - Rebased to master.\n> \n>  src/libcamera/include/v4l2_videodevice.h |  2 ++\n>  src/libcamera/v4l2_videodevice.cpp       | 10 +++++++++-\n>  2 files changed, 11 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/include/v4l2_videodevice.h b/src/libcamera/include/v4l2_videodevice.h\n> index 4b8cf9394eb9..caf36bf9c1aa 100644\n> --- a/src/libcamera/include/v4l2_videodevice.h\n> +++ b/src/libcamera/include/v4l2_videodevice.h\n> @@ -187,6 +187,8 @@ private:\n>  \tstd::map<unsigned int, Buffer *> queuedBuffers_;\n>  \n>  \tEventNotifier *fdEvent_;\n> +\n> +\tbool streaming_;\n>  };\n>  \n>  class V4L2M2MDevice\n> diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp\n> index 208ab54199b1..c0b3a79f76da 100644\n> --- a/src/libcamera/v4l2_videodevice.cpp\n> +++ b/src/libcamera/v4l2_videodevice.cpp\n> @@ -272,7 +272,8 @@ const std::string V4L2DeviceFormat::toString() const\n>   * \\param[in] deviceNode The file-system path to the video device node\n>   */\n>  V4L2VideoDevice::V4L2VideoDevice(const std::string &deviceNode)\n> -\t: V4L2Device(deviceNode), bufferPool_(nullptr), fdEvent_(nullptr)\n> +\t: V4L2Device(deviceNode), bufferPool_(nullptr), fdEvent_(nullptr),\n> +\t  streaming_(false)\n>  {\n>  \t/*\n>  \t * We default to an MMAP based CAPTURE video device, however this will\n> @@ -1173,6 +1174,8 @@ int V4L2VideoDevice::streamOn()\n>  \t\treturn ret;\n>  \t}\n>  \n> +\tstreaming_ = true;\n> +\n>  \treturn 0;\n>  }\n>  \n> @@ -1190,6 +1193,9 @@ int V4L2VideoDevice::streamOff()\n>  {\n>  \tint ret;\n>  \n> +\tif (!streaming_)\n> +\t\treturn 0;\n> +\n>  \tret = ioctl(VIDIOC_STREAMOFF, &bufferType_);\n>  \tif (ret < 0) {\n>  \t\tLOG(V4L2, Error)\n> @@ -1210,6 +1216,8 @@ int V4L2VideoDevice::streamOff()\n>  \tqueuedBuffers_.clear();\n>  \tfdEvent_->setEnabled(false);\n>  \n> +\tstreaming_ = false;\n> +\n>  \treturn 0;\n>  }\n>  \n> -- \n> 2.20.1\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x241.google.com (mail-lj1-x241.google.com\n\t[IPv6:2a00:1450:4864:20::241])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4F4AD6017E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2019 11:48:37 +0100 (CET)","by mail-lj1-x241.google.com with SMTP id u22so10765882lji.7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 28 Oct 2019 03:48:37 -0700 (PDT)","from localhost (h-93-159.A463.priv.bahnhof.se. [46.59.93.159])\n\tby smtp.gmail.com with ESMTPSA id\n\tk10sm4958298lfo.76.2019.10.28.03.48.35\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tMon, 28 Oct 2019 03:48:35 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=s0KYTtCzw08/i0ZGNmIGL3MFHx7qDp5QRxJrOtQFKwE=;\n\tb=fBpNada5EDpzQsP2J6b6tHLdhGsZxGCD4w0gWpVZ+H9vFm9uCFicYFb0YzPblmqtGa\n\tKdqeHn3qHi2k0QPQgHGaH0T20fHdV5IUHchcenBiuG8gTjePHuHzf2/zVUh9a9mrPQZU\n\tdz7a956Z8bEbXlwCidqN0yxl1ON52Y9chglRNird0w+D7/tSKf8EqEcpDOeTl9eX7IsD\n\tJeur2vkKTVb3ys3FURY9WxGeLHKk4Y3zazTTTvQzU3PFnnbICN5ErDZnvb9gMyQb2Dj0\n\teL4UYHeobAFljW0fz7gRCssYitnJM3pM4Me8gR+H5tk3cBfQ0bx7peHux3G393tmD0dc\n\tb1UQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=s0KYTtCzw08/i0ZGNmIGL3MFHx7qDp5QRxJrOtQFKwE=;\n\tb=pPES1L2KJO+p/y9mducHZE5J3yvkKVcUMtjf/Gyi+TIp+6hskRlT2CJoljxzri50Uu\n\t/8YYYyroGGFgtB3P1tO9Dp9Op7KkfmRXqSYMzyXOKdEg15xRqG1RruTGDU4V8eqj/Ea2\n\tPsO/5N/zVvizB0vVWKQHHI9Zca7Lx4oViKtT8dkiaZXQ3dZMDrpvbySXJU4N3hfEzrGZ\n\tBYrndc4zxd3qBZA2djo0iCvKo0Ee5w7aD90AqY+WbvcA/9MGx9YAtZWEhjElEqh2JWk2\n\tHhaYKERpgrM73F+7jdrj74jGBoaOIOz83jq+fEDgtGhW0/tVebBqQURPrcVfjTN30YbD\n\tyhhA==","X-Gm-Message-State":"APjAAAWC4Nigv+jlxY4uSF1ZJy1qye4U1HFR0V4rro7WzAX74+vEQFsQ\n\t6sr4eZeVUv4okJXDoYOzPXpGvBiFE6Q=","X-Google-Smtp-Source":"APXvYqwKF/x0pc2RHaAhK1lp3uC51XXDNv9bkHHCJ+/3xtC974omdckvuiVGoGstCFNZqYtC7IZSyw==","X-Received":"by 2002:a2e:b0c9:: with SMTP id g9mr11164222ljl.95.1572259716603;\n\tMon, 28 Oct 2019 03:48:36 -0700 (PDT)","Date":"Mon, 28 Oct 2019 11:48:35 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"LibCamera Devel <libcamera-devel@lists.libcamera.org>","Message-ID":"<20191028104835.GB20198@bigcity.dyn.berto.se>","References":"<20191025141327.2803-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20191025141327.2803-1-kieran.bingham@ideasonboard.com>","User-Agent":"Mutt/1.12.1 (2019-06-15)","Subject":"Re: [libcamera-devel] [PATCH] libcamera: v4l2_videodevice: Track\n\tstreaming 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>","X-List-Received-Date":"Mon, 28 Oct 2019 10:48:37 -0000"}}]