[{"id":5300,"web_url":"https://patchwork.libcamera.org/comment/5300/","msgid":"<20200620020403.GX5823@pendragon.ideasonboard.com>","date":"2020-06-20T02:04:03","subject":"Re: [libcamera-devel] [PATCH v2 11/17] v4l2: v4l2_camera_proxy:\n\tReset buffer flags on reqbufs 0","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Fri, Jun 19, 2020 at 02:41:17PM +0900, Paul Elder wrote:\n> VIDIOC_REQBUFS with count = 0 should also exhibit the same effects as\n> VIDIOC_STREAMOFF if the stream is on.\n\nThat's what the V4L2 spec says, but it doesn't seem to correspond to the\nvb2 implementation. Does v4l2-compliance check for this ? Otherwise I\nthink you should instead return -EBUSY is vcam_->isRunning().\n\n> Mainly, the queued and done flags\n> need to be cleared. Do these in the handler for VIDIOC_REQBUFS.\n\nThis however is needed, if buffer have been queued without calling\nstreamon, then they should be returned to the dequeued state.\n\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> \n> ---\n> Changes in v2:\n> - call only the necessary components, instead of\n>   V4L2CameraProxy::vidioc_streamoff\n\nUnless I'm mistaken regarding the discrepancy between the spec and the\nimplementation, freeBuffers() shouldn't call vcam_->streamOff(). The\nfunction would then only do\n\n\tvcam_->freeBuffers();\n\tbufferCount_ = 0;\n\nand could be inlined in its caller.\n\n> ---\n>  src/v4l2/v4l2_camera_proxy.cpp | 5 +++++\n>  1 file changed, 5 insertions(+)\n> \n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index 4d37662..ea9222e 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -467,6 +467,11 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *cf, struct v4l2_requestbuffe\n>  \tmemset(arg->reserved, 0, sizeof(arg->reserved));\n>  \n>  \tif (arg->count == 0) {\n> +\t\tif (vcam_->isRunning()) {\n> +\t\t\tfor (struct v4l2_buffer &buf : buffers_)\n> +\t\t\t\tbuf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);\n> +\t\t}\n> +\n>  \t\tunlock(cf);\n>  \t\treturn freeBuffers();\n>  \t}","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 0827460710\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 20 Jun 2020 04:04:28 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 73B68552;\n\tSat, 20 Jun 2020 04:04:27 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"sTjfmSn4\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592618667;\n\tbh=Li5P84T9VP4kz2V1mqlRPGvqwFwN3PLl4DHMpm+h0kA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=sTjfmSn4PggBHCp1kEjW/a2VgKx2+aAdIxZvYWwXfTBKfVXkLUR81TdmU/54BcHCn\n\t/M80J8mBWgUJCcP41j5JI3FVumLH0fPPH838m+nQ+LuMEOJCzjVV/65d5gLPfdsOXd\n\tyoye97M7T1POauNoTiTStz1fP/lfOCq4hdHINIGM=","Date":"Sat, 20 Jun 2020 05:04:03 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Paul Elder <paul.elder@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200620020403.GX5823@pendragon.ideasonboard.com>","References":"<20200619054123.19052-1-paul.elder@ideasonboard.com>\n\t<20200619054123.19052-12-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200619054123.19052-12-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 11/17] v4l2: v4l2_camera_proxy:\n\tReset buffer flags on reqbufs 0","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":"Sat, 20 Jun 2020 02:04:28 -0000"}},{"id":5345,"web_url":"https://patchwork.libcamera.org/comment/5345/","msgid":"<20200623065631.GD2843@jade.amanokami.net>","date":"2020-06-23T06:56:31","subject":"Re: [libcamera-devel] [PATCH v2 11/17] v4l2: v4l2_camera_proxy:\n\tReset buffer flags on reqbufs 0","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/people/17/","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"content":"Hi Laurent,\n\nThank you for the review.\n\nOn Sat, Jun 20, 2020 at 05:04:03AM +0300, Laurent Pinchart wrote:\n> Hi Paul,\n> \n> Thank you for the patch.\n> \n> On Fri, Jun 19, 2020 at 02:41:17PM +0900, Paul Elder wrote:\n> > VIDIOC_REQBUFS with count = 0 should also exhibit the same effects as\n> > VIDIOC_STREAMOFF if the stream is on.\n> \n> That's what the V4L2 spec says, but it doesn't seem to correspond to the\n> vb2 implementation. Does v4l2-compliance check for this ? Otherwise I\n> think you should instead return -EBUSY is vcam_->isRunning().\n\nI see. More things that need to be fixed in the V4L2 spec :/\nLooks it seems that v4l2-compliance doesn't care. I returned EBUSY for\nreqbufs 0 when streaming (without clearing the buffer flags) and\nv4l2-compliance didn't complain. It also didn't complain with what I had\nhere, though.\n\n> > Mainly, the queued and done flags\n> > need to be cleared. Do these in the handler for VIDIOC_REQBUFS.\n> \n> This however is needed, if buffer have been queued without calling\n> streamon, then they should be returned to the dequeued state.\n\nack\n\n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > \n> > ---\n> > Changes in v2:\n> > - call only the necessary components, instead of\n> >   V4L2CameraProxy::vidioc_streamoff\n> \n> Unless I'm mistaken regarding the discrepancy between the spec and the\n> implementation, freeBuffers() shouldn't call vcam_->streamOff(). The\n> function would then only do\n> \n> \tvcam_->freeBuffers();\n> \tbufferCount_ = 0;\n> \n> and could be inlined in its caller.\n\nWell it's called in a couple of places (both in reqbufs, for count = 0\nand > 0) so I think I'll keep it.\n\n> > ---\n> >  src/v4l2/v4l2_camera_proxy.cpp | 5 +++++\n> >  1 file changed, 5 insertions(+)\n> > \n> > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> > index 4d37662..ea9222e 100644\n> > --- a/src/v4l2/v4l2_camera_proxy.cpp\n> > +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> > @@ -467,6 +467,11 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *cf, struct v4l2_requestbuffe\n> >  \tmemset(arg->reserved, 0, sizeof(arg->reserved));\n> >  \n> >  \tif (arg->count == 0) {\n> > +\t\tif (vcam_->isRunning()) {\n> > +\t\t\tfor (struct v4l2_buffer &buf : buffers_)\n> > +\t\t\t\tbuf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);\n> > +\t\t}\n> > +\n> >  \t\tunlock(cf);\n> >  \t\treturn freeBuffers();\n> >  \t}\n\n\nThanks,\n\nPaul","headers":{"Return-Path":"<paul.elder@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 B1F26603B8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 23 Jun 2020 08:56:41 +0200 (CEST)","from jade.amanokami.net (unknown\n\t[IPv6:2400:4051:61:600:8147:f2a2:a8c6:9087])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 25A242A9;\n\tTue, 23 Jun 2020 08:56:39 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"AmQYKMIQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1592895401;\n\tbh=n/ECKqblI3u+87yZqYAYkjZ4arcwDBzb+iYrZSRdbw4=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=AmQYKMIQavkQhqty1Zb2cipUGyllAq+Fx1VOgAi1TDM99w4+jzAXxIf/fxQkoRXvb\n\t8b+L+pQ13tHyxlnoaU5tyJFwZTxVy4rTPCz5rPm3GCfdP3WqUM24B4W9jsRnyQta+g\n\tmVfc7K78u9pUZa8frhrZRzm4y3ltSbk033LPvFJ0=","Date":"Tue, 23 Jun 2020 15:56:31 +0900","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200623065631.GD2843@jade.amanokami.net>","References":"<20200619054123.19052-1-paul.elder@ideasonboard.com>\n\t<20200619054123.19052-12-paul.elder@ideasonboard.com>\n\t<20200620020403.GX5823@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20200620020403.GX5823@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 11/17] v4l2: v4l2_camera_proxy:\n\tReset buffer flags on reqbufs 0","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":"Tue, 23 Jun 2020 06:56:41 -0000"}}]