From patchwork Tue Oct 5 07:31:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 14048 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 B55BCBDC71 for ; Tue, 5 Oct 2021 07:31:33 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 828A5691C7; Tue, 5 Oct 2021 09:31:33 +0200 (CEST) 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="HFfNMO3h"; dkim-atps=neutral Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id EB9F0684C6 for ; Tue, 5 Oct 2021 09:31:31 +0200 (CEST) Received: by mail-pl1-x630.google.com with SMTP id j15so1709411plh.7 for ; Tue, 05 Oct 2021 00:31:31 -0700 (PDT) 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=J5SlXD3J2Y+dGvxWPtVdYv9GYq+6is/z72T8ERv6K90=; b=HFfNMO3hr3NEWOXKhknOJQSnIAyghm+k4IpkPzbeBzIlwh+6xK2cBtAmZoH3A23Mx3 AkpBXTyuUsGd02vHkrkPahwBZJhr6JwRHhieN2Ul6W6eXi4Gj2IjJ1itBhSb3/ptAbgO k5lgGiWo0YiA5mH4E5C1divfXLzWYEsovmhy0= 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=J5SlXD3J2Y+dGvxWPtVdYv9GYq+6is/z72T8ERv6K90=; b=JFaEtkfSzKVINz4rihvZQWSfidx4nFLixMjufI8VtquKeiNVzOkxPYXHrKjecV4vYb 1w2SbpFEr75V6kHZogss7FT+vYcNvqdSbb+ARaPN9bufVQf+ZldRjlvZ3YTQolCF4GCG 4RBfP+MTvb+Iw9idT/taoiuOkkmUvRvOoT2pwjWrmnamknUKsihLhw0RfG4sw43MP0V5 RIjPHumjRIcjuJ/SxMQD7WofrvYPZyUA9fUyAxCuUa/kDGVqNmPuqPTiZgqlIF15LDZi AsfRknm7DAdm9jCJiskcuzEZqAXJlwqQUyZ0PgIr3aWVKBIVB4dAPyKG0+Kvqcq9HFKV 1gEA== X-Gm-Message-State: AOAM530ZSmTSlyPmDCi3jQZFzcNZNqPN39KjrNWhGMpm2pYGDLf4Vv6u zB/IDZpWUTsLsUmsVvXZd3QQ20Epn4DHnQ== X-Google-Smtp-Source: ABdhPJweZVbj9q8tbAuRww8ZtZ2Z/hBh6HQByBrpYTYTAeqg1bGOV8zNe+dQ9Zipx+/GEq5ICleRyA== X-Received: by 2002:a17:903:230c:b0:13e:d84d:e66 with SMTP id d12-20020a170903230c00b0013ed84d0e66mr3966280plh.25.1633419090231; Tue, 05 Oct 2021 00:31:30 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:203:debc:d0db:3bd8:f961]) by smtp.gmail.com with ESMTPSA id o14sm16761812pfh.145.2021.10.05.00.31.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Oct 2021 00:31:29 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 5 Oct 2021 16:31:12 +0900 Message-Id: <20211005073114.3997303-5-hiroh@chromium.org> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog In-Reply-To: <20211005073114.3997303-1-hiroh@chromium.org> References: <20211005073114.3997303-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH 4/6] v4l2: Remove using namespace in header files 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" "using namespace" in a header file propagates the namespace to the files including the header file. So it should be avoided. This removes "using namespace" in header files in v4l2. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart --- src/v4l2/v4l2_camera.h | 37 +++++++++++++++++----------------- src/v4l2/v4l2_camera_proxy.h | 15 +++++++------- src/v4l2/v4l2_compat_manager.h | 4 +--- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/v4l2/v4l2_camera.h b/src/v4l2/v4l2_camera.h index a095f4e2..e81996f2 100644 --- a/src/v4l2/v4l2_camera.h +++ b/src/v4l2/v4l2_camera.h @@ -19,41 +19,40 @@ #include #include -using namespace libcamera; - class V4L2Camera { public: struct Buffer { - Buffer(unsigned int index, const FrameMetadata &data) + Buffer(unsigned int index, const libcamera::FrameMetadata &data) : index_(index), data_(data) { } unsigned int index_; - FrameMetadata data_; + libcamera::FrameMetadata data_; }; - V4L2Camera(std::shared_ptr camera); + V4L2Camera(std::shared_ptr camera); ~V4L2Camera(); - int open(StreamConfiguration *streamConfig); + int open(libcamera::StreamConfiguration *streamConfig); void close(); void bind(int efd); void unbind(); std::vector completedBuffers(); - int configure(StreamConfiguration *streamConfigOut, - const Size &size, const PixelFormat &pixelformat, + int configure(libcamera::StreamConfiguration *streamConfigOut, + const libcamera::Size &size, + const libcamera::PixelFormat &pixelformat, unsigned int bufferCount); - int validateConfiguration(const PixelFormat &pixelformat, - const Size &size, - StreamConfiguration *streamConfigOut); + int validateConfiguration(const libcamera::PixelFormat &pixelformat, + const libcamera::Size &size, + libcamera::StreamConfiguration *streamConfigOut); int allocBuffers(unsigned int count); void freeBuffers(); - FileDescriptor getBufferFd(unsigned int index); + libcamera::FileDescriptor getBufferFd(unsigned int index); int streamOn(); int streamOff(); @@ -66,24 +65,24 @@ public: bool isRunning(); private: - void requestComplete(Request *request); + void requestComplete(libcamera::Request *request); - std::shared_ptr camera_; - std::unique_ptr config_; + std::shared_ptr camera_; + std::unique_ptr config_; bool isRunning_; std::mutex bufferLock_; - FrameBufferAllocator *bufferAllocator_; + libcamera::FrameBufferAllocator *bufferAllocator_; - std::vector> requestPool_; + std::vector> requestPool_; - std::deque pendingRequests_; + std::deque pendingRequests_; std::deque> completedBuffers_; int efd_; - Mutex bufferMutex_; + libcamera::Mutex bufferMutex_; std::condition_variable bufferCV_; unsigned int bufferAvailableCount_; }; diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h index f1a8b61c..56a45bb7 100644 --- a/src/v4l2/v4l2_camera_proxy.h +++ b/src/v4l2/v4l2_camera_proxy.h @@ -19,14 +19,12 @@ #include "v4l2_camera.h" -using namespace libcamera; - class V4L2CameraFile; class V4L2CameraProxy { public: - V4L2CameraProxy(unsigned int index, std::shared_ptr camera); + V4L2CameraProxy(unsigned int index, std::shared_ptr camera); int open(V4L2CameraFile *file); void close(V4L2CameraFile *file); @@ -38,8 +36,8 @@ public: private: bool validateBufferType(uint32_t type); bool validateMemoryType(uint32_t memory); - void setFmtFromConfig(const StreamConfiguration &streamConfig); - void querycap(std::shared_ptr camera); + void setFmtFromConfig(const libcamera::StreamConfiguration &streamConfig); + void querycap(std::shared_ptr camera); int tryFormat(struct v4l2_format *arg); enum v4l2_priority maxPriority(); void updateBuffers(); @@ -59,7 +57,8 @@ private: int vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuffers *arg); 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, MutexLocker *locker); + int vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, + libcamera::MutexLocker *locker); int vidioc_streamon(V4L2CameraFile *file, int *arg); int vidioc_streamoff(V4L2CameraFile *file, int *arg); @@ -72,7 +71,7 @@ private: unsigned int refcount_; unsigned int index_; - StreamConfiguration streamConfig_; + libcamera::StreamConfiguration streamConfig_; unsigned int bufferCount_; unsigned int currentBuf_; unsigned int sizeimage_; @@ -99,7 +98,7 @@ private: V4L2CameraFile *owner_; /* This mutex is to serialize access to the proxy. */ - Mutex proxyMutex_; + libcamera::Mutex proxyMutex_; }; #endif /* __V4L2_CAMERA_PROXY_H__ */ diff --git a/src/v4l2/v4l2_compat_manager.h b/src/v4l2/v4l2_compat_manager.h index 1ec46162..b11698cc 100644 --- a/src/v4l2/v4l2_compat_manager.h +++ b/src/v4l2/v4l2_compat_manager.h @@ -18,8 +18,6 @@ #include "v4l2_camera_proxy.h" -using namespace libcamera; - class V4L2CompatManager { public: @@ -64,7 +62,7 @@ private: FileOperations fops_; - CameraManager *cm_; + libcamera::CameraManager *cm_; std::vector> proxies_; std::map> files_;