{"id":8419,"url":"https://patchwork.libcamera.org/api/1.1/patches/8419/?format=json","web_url":"https://patchwork.libcamera.org/patch/8419/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/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":"<20200624145256.48266-22-paul.elder@ideasonboard.com>","date":"2020-06-24T14:52:55","name":"[libcamera-devel,v4,21/22] v4l2: v4l2_camera_proxy: Fix buffer flags related to queueing","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"b3168d4be33c1c442666b0d7cf25688800834617","submitter":{"id":17,"url":"https://patchwork.libcamera.org/api/1.1/people/17/?format=json","name":"Paul Elder","email":"paul.elder@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8419/mbox/","series":[{"id":1041,"url":"https://patchwork.libcamera.org/api/1.1/series/1041/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1041","date":"2020-06-24T14:52:34","name":"Support v4l2-compliance","version":4,"mbox":"https://patchwork.libcamera.org/series/1041/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8419/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8419/checks/","tags":{},"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 94888609C5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 24 Jun 2020 16:54:05 +0200 (CEST)","from jade.rasen.tech (unknown\n\t[IPv6:2400:4051:61:600:8147:f2a2:a8c6:9087])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E908F2A8;\n\tWed, 24 Jun 2020 16:54:03 +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=\"DueO6vjJ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1593010445;\n\tbh=rqiojEVYnxD2uLtrdleH9sNQB/HOT8ls2RMDcSFoO8Q=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=DueO6vjJVAZw/kjWgqFcx3ptpt56hLETtPp1rp61LrnspegsM9DoXSyn45OqiPyuN\n\tJDL164D5CfyxpJzPb9zGxoea2eLs0wx5kNCYtIiEBRQFcGMeD7VfWrPTGG8VQPQxRe\n\ttE4p9pYuEtfccLZDsSDGlzQfKwHFIO5mZ0RJii4w=","From":"Paul Elder <paul.elder@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 24 Jun 2020 23:52:55 +0900","Message-Id":"<20200624145256.48266-22-paul.elder@ideasonboard.com>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200624145256.48266-1-paul.elder@ideasonboard.com>","References":"<20200624145256.48266-1-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v4 21/22] v4l2: v4l2_camera_proxy: Fix\n\tbuffer flags related to queueing","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":"Wed, 24 Jun 2020 14:54:05 -0000"},"content":"Fix buffer flags related to queueing and dequeueing:\n- don't allow a buffer with the same index that is already in the queue\n  to be enqueued again\n- don't clear the done flag upon qbuf\n- do clear the done flag upon dqbuf\n- set the flags in V4L2CameraProxy's internal buffers, and not just in\n  the buffers returned from qbuf\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n---\nChanges in v4:\n- fix the V4L2_BUF_FLAG_DONE flag properly\n  - clear in dqbuf, set in updateBuffers (latter is already there)\n\nChanges in v3:\n- remove \"set the mapped flag on enqueueing\"\n- clean up some logic\n- expand commit message very slightly\n\nNew in v2\n- split from \"Fix v4l2-compliance streaming tests\"\n---\n src/v4l2/v4l2_camera_proxy.cpp | 10 +++++++---\n 1 file changed, 7 insertions(+), 3 deletions(-)","diff":"diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\nindex d5c146f..3b7a6f4 100644\n--- a/src/v4l2/v4l2_camera_proxy.cpp\n+++ b/src/v4l2/v4l2_camera_proxy.cpp\n@@ -567,6 +567,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)\n \tif (arg->index >= bufferCount_)\n \t\treturn -EINVAL;\n \n+\tif (buffers_[arg->index].flags & V4L2_BUF_FLAG_QUEUED)\n+\t\treturn -EINVAL;\n+\n \tif (!hasOwnership(file))\n \t\treturn -EBUSY;\n \n@@ -579,8 +582,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)\n \tif (ret < 0)\n \t\treturn ret;\n \n-\targ->flags |= V4L2_BUF_FLAG_QUEUED;\n-\targ->flags &= ~V4L2_BUF_FLAG_DONE;\n+\tbuffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED;\n+\n+\targ->flags = buffers_[arg->index].flags;\n \n \treturn ret;\n }\n@@ -618,7 +622,7 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)\n \n \tstruct v4l2_buffer &buf = buffers_[currentBuf_];\n \n-\tbuf.flags &= ~V4L2_BUF_FLAG_QUEUED;\n+\tbuf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE);\n \tbuf.length = sizeimage_;\n \t*arg = buf;\n \n","prefixes":["libcamera-devel","v4","21/22"]}