From patchwork Tue Jun 23 19:08:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 4189 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 99E98609A5 for ; Tue, 23 Jun 2020 21:09:38 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Sr52AgkZ"; 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 0274E2A9; Tue, 23 Jun 2020 21:09:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1592939378; bh=Yyj4xtvYW+wee9Xuq3BHsxeamh1FqaAfROOsLOxumEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sr52AgkZNdJ/6cgyz0IJXVTiDAvRESHUwVlwCOzDoijEQuF7plT6Egdv1tqYkLSKM ln5b6K1T5U4/UAJmAbKX95mUuAr7exyzeekpdCg5rsN4qS70NSKCEylBUuRWpZdo+J 0IDoPJXAejVNrFBZ/1T5aI9AzfRg0taiSvSd79ew= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 24 Jun 2020 04:08:29 +0900 Message-Id: <20200623190836.53446-16-paul.elder@ideasonboard.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623190836.53446-1-paul.elder@ideasonboard.com> References: <20200623190836.53446-1-paul.elder@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 15/22] v4l2: v4l2_camera_proxy: Reset buffer flags on reqbufs 0 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: Tue, 23 Jun 2020 19:09:38 -0000 Clear the queued and done buffer flags on VIDIOC_REQBUFS with count = 0 if the stream is not on. If the stream is on and reqbufs is called with count = 0, return -EBUSY. Note that this is contrary to what the V4L2 docs say (reqbufs 0 when streaming should also streamoff), but it is how the V4L2 implementation works. v4l2-compliance doesn't seem to care either way, however, so we cater to the implementation. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v3: - don't streamoff in reqbufs 0; return -EBUSY instead Changes in v2: - call only the necessary components, instead of V4L2CameraProxy::vidioc_streamoff --- src/v4l2/v4l2_camera_proxy.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 06fef21..fa58585 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -444,11 +444,6 @@ int V4L2CameraProxy::freeBuffers() { LOG(V4L2Compat, Debug) << "Freeing libcamera bufs"; - int ret = vcam_->streamOff(); - if (ret < 0) { - LOG(V4L2Compat, Error) << "Failed to stop stream"; - return ret; - } vcam_->freeBuffers(); bufferCount_ = 0; @@ -476,6 +471,12 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf memset(arg->reserved, 0, sizeof(arg->reserved)); if (arg->count == 0) { + if (vcam_->isRunning()) + return -EBUSY; + + for (struct v4l2_buffer &buf : buffers_) + buf.flags &= ~(V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_DONE); + release(file); return freeBuffers(); }