From patchwork Mon Nov 29 11:44:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14839 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 8BA48BF415 for ; Mon, 29 Nov 2021 11:45:10 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 423C2605B4; Mon, 29 Nov 2021 12:45:10 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Nojlp41L"; dkim-atps=neutral Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A35A2605A6 for ; Mon, 29 Nov 2021 12:45:06 +0100 (CET) Received: by mail-pj1-x1036.google.com with SMTP id w33-20020a17090a6ba400b001a722a06212so11621069pjj.0 for ; Mon, 29 Nov 2021 03:45:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZOAZZb3YEiRY/bi7D7SmcCZ54QwiXVWiBu6nuv2zOfg=; b=Nojlp41LO/UwoDV0m0INyo9FzDa8ZUrYGF8/RBX6Pku7dftWW7nY7rjeCBWL+ftfyY ZQJQ1BYX4bxK5wRvdSJoKzwj51cgweSu7+y2rATUr7p8a6JgjKBi8vJZSIH58mVqJ8bI yRGyea0GfVdZ6aITs9e5NakLMeBP7WWOrP2Uc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZOAZZb3YEiRY/bi7D7SmcCZ54QwiXVWiBu6nuv2zOfg=; b=ZvrvlSxx2FEvckiLmX4PEjeo/CyXtPgj944r1cHqmF7ch13apfVoAb6ENL4rprrS/Q MAv42+8SGlNqlDquDW9hGoY8ZqekhJpWMKD6UGsDshf/5gqImHN0vM6EB6NXK2lmPdM8 uy4qTfQ2ljCK8b/BCp4RFy1jQDExvwLnRQBMgBGHfqY2v7O0L488XaxLoV9ZrLvM4Miy OQehIz0ZsJB5MhJCSi4C3hta075n5xo/qxEZZvpoCb2iuQg5xS2OPj1BQhEeflphygHk KraCsfZOscUNAdMU5xGApeyrNlhQSuil+9/OaXMOENEtj/yem77nzpCdc/+LzfJ2e2Fz cgmQ== X-Gm-Message-State: AOAM530uZBika6Aaso1JOax40/h4r2OUPbE3mg5jIhdLmzSvhQ6yYXeg Ug5lxxYii51bSLD5FnXoRTlfn/9EdWKiQg== X-Google-Smtp-Source: ABdhPJwWuf7K2R2hv6ebF74r+AjOno81sAEV5VbaGuvyKOZwlVCvL5VE2ssgK5LFe0t6Psj2WyW3tQ== X-Received: by 2002:a17:902:d2cd:b0:141:fbe2:b658 with SMTP id n13-20020a170902d2cd00b00141fbe2b658mr59418906plc.49.1638186305025; Mon, 29 Nov 2021 03:45:05 -0800 (PST) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:f254:cda9:46e8:17b7]) by smtp.gmail.com with ESMTPSA id hg4sm17951966pjb.1.2021.11.29.03.45.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Nov 2021 03:45:04 -0800 (PST) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Mon, 29 Nov 2021 20:44:45 +0900 Message-Id: <20211129114453.3186042-4-hiroh@chromium.org> X-Mailer: git-send-email 2.34.0.rc2.393.gf8c9666880-goog In-Reply-To: <20211129114453.3186042-1-hiroh@chromium.org> References: <20211129114453.3186042-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 03/11] v4l2: Consolidate mutex classes to Mutex and MutexLocker 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Laurent Pinchart --- 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> 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(arg)); break; case VIDIOC_DQBUF: - ret = vidioc_dqbuf(file, static_cast(arg), &locker); + ret = vidioc_dqbuf(file, static_cast(arg), &proxyMutex_); break; case VIDIOC_STREAMON: ret = vidioc_streamon(file, static_cast(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 #include +#include + #include #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);