From patchwork Wed Jun 24 14:52:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 8419 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 94888609C5 for ; Wed, 24 Jun 2020 16:54:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="DueO6vjJ"; dkim-atps=neutral Received: from jade.rasen.tech (unknown [IPv6:2400:4051:61:600:8147:f2a2:a8c6:9087]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id E908F2A8; Wed, 24 Jun 2020 16:54:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593010445; bh=rqiojEVYnxD2uLtrdleH9sNQB/HOT8ls2RMDcSFoO8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DueO6vjJVAZw/kjWgqFcx3ptpt56hLETtPp1rp61LrnspegsM9DoXSyn45OqiPyuN JDL164D5CfyxpJzPb9zGxoea2eLs0wx5kNCYtIiEBRQFcGMeD7VfWrPTGG8VQPQxRe tE4p9pYuEtfccLZDsSDGlzQfKwHFIO5mZ0RJii4w= From: Paul Elder 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 Subject: [libcamera-devel] [PATCH v4 21/22] v4l2: v4l2_camera_proxy: Fix buffer flags related to queueing X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Jun 2020 14:54:05 -0000 Fix buffer flags related to queueing and dequeueing: - don't allow a buffer with the same index that is already in the queue to be enqueued again - don't clear the done flag upon qbuf - do clear the done flag upon dqbuf - set the flags in V4L2CameraProxy's internal buffers, and not just in the buffers returned from qbuf Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v4: - fix the V4L2_BUF_FLAG_DONE flag properly - clear in dqbuf, set in updateBuffers (latter is already there) Changes in v3: - remove "set the mapped flag on enqueueing" - clean up some logic - expand commit message very slightly New in v2 - split from "Fix v4l2-compliance streaming tests" --- src/v4l2/v4l2_camera_proxy.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index d5c146f..3b7a6f4 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -567,6 +567,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg) if (arg->index >= bufferCount_) return -EINVAL; + if (buffers_[arg->index].flags & V4L2_BUF_FLAG_QUEUED) + return -EINVAL; + if (!hasOwnership(file)) return -EBUSY; @@ -579,8 +582,9 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg) if (ret < 0) return ret; - arg->flags |= V4L2_BUF_FLAG_QUEUED; - arg->flags &= ~V4L2_BUF_FLAG_DONE; + buffers_[arg->index].flags |= V4L2_BUF_FLAG_QUEUED; + + arg->flags = buffers_[arg->index].flags; return ret; } @@ -618,7 +622,7 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg) struct v4l2_buffer &buf = buffers_[currentBuf_]; - buf.flags &= ~V4L2_BUF_FLAG_QUEUED; + buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE); buf.length = sizeimage_; *arg = buf;