[{"id":21394,"web_url":"https://patchwork.libcamera.org/comment/21394/","msgid":"<YaWjWLNzWyrXh70g@pendragon.ideasonboard.com>","date":"2021-11-30T04:06:48","subject":"Re: [libcamera-devel] [PATCH v2 03/11] v4l2: Consolidate mutex\n\tclasses to Mutex and MutexLocker","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Hiro,\n\nThank you for the patch.\n\nOn Mon, Nov 29, 2021 at 08:44:45PM +0900, Hirokazu Honda wrote:\n> std::mutex and std::unique_lcok are used in v4l2 directory,\n> mixing Mutex and MutexLocker. This consolidates them to Mutex\n> and MutexLocker.\n> \n> This also fixes vidoc_dqbuf argument to take Mutex instead of\n> MutexLocker.\n> \n> Signed-off-by: Hirokazu Honda <hiroh@chromium.org>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/v4l2/v4l2_camera.h         | 2 +-\n>  src/v4l2/v4l2_camera_proxy.cpp | 8 ++++----\n>  src/v4l2/v4l2_camera_proxy.h   | 4 +++-\n>  3 files changed, 8 insertions(+), 6 deletions(-)\n> \n> diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h\n> index 4afbb331..2f6fcb3c 100644\n> --- a/src/v4l2/v4l2_camera.h\n> +++ b/src/v4l2/v4l2_camera.h\n> @@ -71,7 +71,7 @@ private:\n>  \n>  \tbool isRunning_;\n>  \n> -\tstd::mutex bufferLock_;\n> +\tlibcamera::Mutex bufferLock_;\n>  \tlibcamera::FrameBufferAllocator *bufferAllocator_;\n>  \n>  \tstd::vector<std::unique_ptr<libcamera::Request>> requestPool_;\n> diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp\n> index 3610e63c..79bc880d 100644\n> --- a/src/v4l2/v4l2_camera_proxy.cpp\n> +++ b/src/v4l2/v4l2_camera_proxy.cpp\n> @@ -575,7 +575,7 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg)\n>  }\n>  \n>  int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> -\t\t\t\t  MutexLocker *locker)\n> +\t\t\t\t  Mutex *lock)\n>  {\n>  \tLOG(V4L2Compat, Debug) << \"Servicing vidioc_dqbuf fd = \" << file->efd();\n>  \n> @@ -593,9 +593,9 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n>  \t\treturn -EINVAL;\n>  \n>  \tif (!file->nonBlocking()) {\n> -\t\tlocker->unlock();\n> +\t\tlock->unlock();\n>  \t\tvcam_->waitForBufferAvailable();\n> -\t\tlocker->lock();\n> +\t\tlock->lock();\n>  \t} else if (!vcam_->isBufferAvailable())\n>  \t\treturn -EAGAIN;\n>  \n> @@ -753,7 +753,7 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar\n>  \t\tret = vidioc_qbuf(file, static_cast<struct v4l2_buffer *>(arg));\n>  \t\tbreak;\n>  \tcase VIDIOC_DQBUF:\n> -\t\tret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &locker);\n> +\t\tret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &proxyMutex_);\n>  \t\tbreak;\n>  \tcase VIDIOC_STREAMON:\n>  \t\tret = vidioc_streamon(file, static_cast<int *>(arg));\n> diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h\n> index fccec241..040954dd 100644\n> --- a/src/v4l2/v4l2_camera_proxy.h\n> +++ b/src/v4l2/v4l2_camera_proxy.h\n> @@ -14,6 +14,8 @@\n>  #include <sys/types.h>\n>  #include <vector>\n>  \n> +#include <libcamera/base/thread.h>\n> +\n>  #include <libcamera/camera.h>\n>  \n>  #include \"v4l2_camera.h\"\n> @@ -57,7 +59,7 @@ private:\n>  \tint vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n>  \tint vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg);\n>  \tint vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg,\n> -\t\t\t libcamera::MutexLocker *locker);\n> +\t\t\t libcamera::Mutex *lock);\n>  \tint vidioc_streamon(V4L2CameraFile *file, int *arg);\n>  \tint vidioc_streamoff(V4L2CameraFile *file, int *arg);\n>","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 8294FBDB13\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 30 Nov 2021 04:07:14 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3BD96605B4;\n\tTue, 30 Nov 2021 05:07:14 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D3CA6604FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 30 Nov 2021 05:07:12 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6A5148F0;\n\tTue, 30 Nov 2021 05:07:12 +0100 (CET)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"O01xl6Wz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1638245232;\n\tbh=yHMe7miXkethZs7HRKzDCHgjJ+0OXKRF8y1XP4ETFZc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=O01xl6Wz3obHi9+TuxhWbtPTPUKGcVo7uCHr2iIIlyri6eMcIjpE5X4843vRYQzSo\n\t3WWcA5ZSrfTBfEwAeDQlDKDB5h64DhwDRftIwwTHg7KP/2dpA0sOcLfFZy3L9XJmok\n\tDQqfyQesOU2Ikyl0+6I9QcONym2y+1RbBV8tbFF0=","Date":"Tue, 30 Nov 2021 06:06:48 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Hirokazu Honda <hiroh@chromium.org>","Message-ID":"<YaWjWLNzWyrXh70g@pendragon.ideasonboard.com>","References":"<20211129114453.3186042-1-hiroh@chromium.org>\n\t<20211129114453.3186042-4-hiroh@chromium.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20211129114453.3186042-4-hiroh@chromium.org>","Subject":"Re: [libcamera-devel] [PATCH v2 03/11] v4l2: Consolidate mutex\n\tclasses to Mutex and MutexLocker","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]