Message ID | 20211005073114.3997303-5-hiroh@chromium.org |
---|---|
State | Accepted |
Headers | show |
Series |
|
Related | show |
Hi Hiro, Thank you for the patch. On Tue, Oct 05, 2021 at 04:31:12PM +0900, Hirokazu Honda wrote: > "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 <hiroh@chromium.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > 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 <libcamera/framebuffer.h> > #include <libcamera/framebuffer_allocator.h> > > -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> camera); > + V4L2Camera(std::shared_ptr<libcamera::Camera> camera); > ~V4L2Camera(); > > - int open(StreamConfiguration *streamConfig); > + int open(libcamera::StreamConfiguration *streamConfig); > void close(); > void bind(int efd); > void unbind(); > > std::vector<Buffer> 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> camera_; > - std::unique_ptr<CameraConfiguration> config_; > + std::shared_ptr<libcamera::Camera> camera_; > + std::unique_ptr<libcamera::CameraConfiguration> config_; > > bool isRunning_; > > std::mutex bufferLock_; > - FrameBufferAllocator *bufferAllocator_; > + libcamera::FrameBufferAllocator *bufferAllocator_; > > - std::vector<std::unique_ptr<Request>> requestPool_; > + std::vector<std::unique_ptr<libcamera::Request>> requestPool_; > > - std::deque<Request *> pendingRequests_; > + std::deque<libcamera::Request *> pendingRequests_; > std::deque<std::unique_ptr<Buffer>> 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> camera); > + V4L2CameraProxy(unsigned int index, std::shared_ptr<libcamera::Camera> 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> camera); > + void setFmtFromConfig(const libcamera::StreamConfiguration &streamConfig); > + void querycap(std::shared_ptr<libcamera::Camera> 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<std::unique_ptr<V4L2CameraProxy>> proxies_; > std::map<int, std::shared_ptr<V4L2CameraFile>> files_;
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 <libcamera/framebuffer.h> #include <libcamera/framebuffer_allocator.h> -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> camera); + V4L2Camera(std::shared_ptr<libcamera::Camera> camera); ~V4L2Camera(); - int open(StreamConfiguration *streamConfig); + int open(libcamera::StreamConfiguration *streamConfig); void close(); void bind(int efd); void unbind(); std::vector<Buffer> 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> camera_; - std::unique_ptr<CameraConfiguration> config_; + std::shared_ptr<libcamera::Camera> camera_; + std::unique_ptr<libcamera::CameraConfiguration> config_; bool isRunning_; std::mutex bufferLock_; - FrameBufferAllocator *bufferAllocator_; + libcamera::FrameBufferAllocator *bufferAllocator_; - std::vector<std::unique_ptr<Request>> requestPool_; + std::vector<std::unique_ptr<libcamera::Request>> requestPool_; - std::deque<Request *> pendingRequests_; + std::deque<libcamera::Request *> pendingRequests_; std::deque<std::unique_ptr<Buffer>> 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> camera); + V4L2CameraProxy(unsigned int index, std::shared_ptr<libcamera::Camera> 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> camera); + void setFmtFromConfig(const libcamera::StreamConfiguration &streamConfig); + void querycap(std::shared_ptr<libcamera::Camera> 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<std::unique_ptr<V4L2CameraProxy>> proxies_; std::map<int, std::shared_ptr<V4L2CameraFile>> files_;
"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 <hiroh@chromium.org> --- 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(-)