Message ID | 20211129114453.3186042-4-hiroh@chromium.org |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Hiro, Thank you for the patch. On Mon, Nov 29, 2021 at 08:44:45PM +0900, Hirokazu Honda wrote: > std::mutex and std::unique_lcok are used in v4l2 directory, > mixing Mutex and MutexLocker. This consolidates them to Mutex > and MutexLocker. > > This also fixes vidoc_dqbuf argument to take Mutex instead of > MutexLocker. > > Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > src/v4l2/v4l2_camera.h | 2 +- > src/v4l2/v4l2_camera_proxy.cpp | 8 ++++---- > src/v4l2/v4l2_camera_proxy.h | 4 +++- > 3 files changed, 8 insertions(+), 6 deletions(-) > > diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h > index 4afbb331..2f6fcb3c 100644 > --- a/src/v4l2/v4l2_camera.h > +++ b/src/v4l2/v4l2_camera.h > @@ -71,7 +71,7 @@ private: > > bool isRunning_; > > - std::mutex bufferLock_; > + libcamera::Mutex bufferLock_; > libcamera::FrameBufferAllocator *bufferAllocator_; > > std::vector<std::unique_ptr<libcamera::Request>> requestPool_; > diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp > index 3610e63c..79bc880d 100644 > --- a/src/v4l2/v4l2_camera_proxy.cpp > +++ b/src/v4l2/v4l2_camera_proxy.cpp > @@ -575,7 +575,7 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg) > } > > int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, > - MutexLocker *locker) > + Mutex *lock) > { > LOG(V4L2Compat, Debug) << "Servicing vidioc_dqbuf fd = " << file->efd(); > > @@ -593,9 +593,9 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, > return -EINVAL; > > if (!file->nonBlocking()) { > - locker->unlock(); > + lock->unlock(); > vcam_->waitForBufferAvailable(); > - locker->lock(); > + lock->lock(); > } else if (!vcam_->isBufferAvailable()) > return -EAGAIN; > > @@ -753,7 +753,7 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar > ret = vidioc_qbuf(file, static_cast<struct v4l2_buffer *>(arg)); > break; > case VIDIOC_DQBUF: > - ret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &locker); > + ret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &proxyMutex_); > break; > case VIDIOC_STREAMON: > ret = vidioc_streamon(file, static_cast<int *>(arg)); > diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h > index fccec241..040954dd 100644 > --- a/src/v4l2/v4l2_camera_proxy.h > +++ b/src/v4l2/v4l2_camera_proxy.h > @@ -14,6 +14,8 @@ > #include <sys/types.h> > #include <vector> > > +#include <libcamera/base/thread.h> > + > #include <libcamera/camera.h> > > #include "v4l2_camera.h" > @@ -57,7 +59,7 @@ private: > int vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *arg); > int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg); > int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, > - libcamera::MutexLocker *locker); > + libcamera::Mutex *lock); > int vidioc_streamon(V4L2CameraFile *file, int *arg); > int vidioc_streamoff(V4L2CameraFile *file, int *arg); >
diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h index 4afbb331..2f6fcb3c 100644 --- a/src/v4l2/v4l2_camera.h +++ b/src/v4l2/v4l2_camera.h @@ -71,7 +71,7 @@ private: bool isRunning_; - std::mutex bufferLock_; + libcamera::Mutex bufferLock_; libcamera::FrameBufferAllocator *bufferAllocator_; std::vector<std::unique_ptr<libcamera::Request>> requestPool_; diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 3610e63c..79bc880d 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -575,7 +575,7 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg) } int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, - MutexLocker *locker) + Mutex *lock) { LOG(V4L2Compat, Debug) << "Servicing vidioc_dqbuf fd = " << file->efd(); @@ -593,9 +593,9 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, return -EINVAL; if (!file->nonBlocking()) { - locker->unlock(); + lock->unlock(); vcam_->waitForBufferAvailable(); - locker->lock(); + lock->lock(); } else if (!vcam_->isBufferAvailable()) return -EAGAIN; @@ -753,7 +753,7 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar ret = vidioc_qbuf(file, static_cast<struct v4l2_buffer *>(arg)); break; case VIDIOC_DQBUF: - ret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &locker); + ret = vidioc_dqbuf(file, static_cast<struct v4l2_buffer *>(arg), &proxyMutex_); break; case VIDIOC_STREAMON: ret = vidioc_streamon(file, static_cast<int *>(arg)); diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h index fccec241..040954dd 100644 --- a/src/v4l2/v4l2_camera_proxy.h +++ b/src/v4l2/v4l2_camera_proxy.h @@ -14,6 +14,8 @@ #include <sys/types.h> #include <vector> +#include <libcamera/base/thread.h> + #include <libcamera/camera.h> #include "v4l2_camera.h" @@ -57,7 +59,7 @@ private: int vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *arg); int vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg); int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, - libcamera::MutexLocker *locker); + libcamera::Mutex *lock); int vidioc_streamon(V4L2CameraFile *file, int *arg); int vidioc_streamoff(V4L2CameraFile *file, int *arg);
std::mutex and std::unique_lcok are used in v4l2 directory, mixing Mutex and MutexLocker. This consolidates them to Mutex and MutexLocker. This also fixes vidoc_dqbuf argument to take Mutex instead of MutexLocker. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> --- src/v4l2/v4l2_camera.h | 2 +- src/v4l2/v4l2_camera_proxy.cpp | 8 ++++---- src/v4l2/v4l2_camera_proxy.h | 4 +++- 3 files changed, 8 insertions(+), 6 deletions(-)