From patchwork Wed Jun 24 14:52:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 8413 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B3519609C5 for ; Wed, 24 Jun 2020 16:53:51 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="bnndQHaz"; 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 CA5902A8; Wed, 24 Jun 2020 16:53:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1593010431; bh=kLZGupO242hvH2AcNydhWhWZII+Zp57aGQ/nzI8zmao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bnndQHazS0Mb7ZRAbWpb/iJm6i1NAIoSsOyAsTGP3mjEuBQzMWZzJt/Hm4zE7tdsO OgOJMh5iK9SvzfzjpemSVNOr8OULZ1OCliQex/so640zV4MqO7sedckh6kWNu+yZ0e ALu0NRtxXbFIvp76b2sLNu3/f6CQp23iEbKwWaOQ= From: Paul Elder To: libcamera-devel@lists.libcamera.org Date: Wed, 24 Jun 2020 23:52:49 +0900 Message-Id: <20200624145256.48266-16-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 15/22] v4l2: v4l2_camera_proxy: Clear internal buffer vector 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: Wed, 24 Jun 2020 14:53:52 -0000 If VIDIOC_REQBUFS with count = 0 is called when the stream is not on, clear the proxy's internal vector of buffer. If the stream is on when reqbufs 0 is called, 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, and no longer call streamoff on reqbufs 0. Signed-off-by: Paul Elder Reviewed-by: Laurent Pinchart --- Changes in v4: - instead of resetting flags, clear the buffer vector in the proxy 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 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 7b269a5..9965a53 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -445,11 +445,8 @@ void V4L2CameraProxy::freeBuffers() { LOG(V4L2Compat, Debug) << "Freeing libcamera bufs"; - int ret = vcam_->streamOff(); - if (ret < 0) - LOG(V4L2Compat, Error) << "Failed to stop stream"; - vcam_->freeBuffers(); + buffers_.clear(); bufferCount_ = 0; } @@ -473,6 +470,9 @@ 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; + freeBuffers(); release(file);