From patchwork Tue Dec 28 21:59:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 15231 X-Patchwork-Delegate: laurent.pinchart@ideasonboard.com 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 30A4FBF415 for ; Tue, 28 Dec 2021 22:00:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BD8446090D; Tue, 28 Dec 2021 23:00:06 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hQjJkXpt"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A93786091A for ; Tue, 28 Dec 2021 22:59:59 +0100 (CET) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4727A895 for ; Tue, 28 Dec 2021 22:59:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1640728799; bh=eJoX2ye7HNkZYahMKX0B6FF8m61c0oNmmEEPOXFp4y0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hQjJkXpt0FIH0LHAot91yXdx7mDCHlOezfyUgHnSUJ55lmgB9AMkp6aSA0bpGlYr/ SxqYpYdlZC24xBFe6/9zfIFEdivuJjtg6sOW7zU/LhzmxjEM7BcLt6Lz6DZykbcwTr e+f87psVpj2UF6/p1orazXYGHxobiNPPPmbVQ4w0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 28 Dec 2021 23:59:51 +0200 Message-Id: <20211228215951.32396-6-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211228215951.32396-1-laurent.pinchart@ideasonboard.com> References: <20211228215951.32396-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1 5/5] v4l2: v4l2_camera_proxy: Use file description in debug messages 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" Debug messages in V4L2CameraProxy print the numerical file descriptor, which isn't very human-friendly. Replace it with the V4L2CameraFile description that includes the full path. While at it, refactor the messages to use __func__ instead of manually copying function names. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/v4l2/v4l2_camera_proxy.cpp | 74 ++++++++++++++++++++------------ src/v4l2/v4l2_camera_proxy.h | 7 +-- src/v4l2/v4l2_compat_manager.cpp | 5 ++- 3 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/v4l2/v4l2_camera_proxy.cpp b/src/v4l2/v4l2_camera_proxy.cpp index 80e6624bc9b7..5ccf40b9692c 100644 --- a/src/v4l2/v4l2_camera_proxy.cpp +++ b/src/v4l2/v4l2_camera_proxy.cpp @@ -46,7 +46,8 @@ V4L2CameraProxy::V4L2CameraProxy(unsigned int index, int V4L2CameraProxy::open(V4L2CameraFile *file) { - LOG(V4L2Compat, Debug) << "Servicing open fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; MutexLocker locker(proxyMutex_); @@ -80,7 +81,8 @@ int V4L2CameraProxy::open(V4L2CameraFile *file) void V4L2CameraProxy::close(V4L2CameraFile *file) { - LOG(V4L2Compat, Debug) << "Servicing close fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; MutexLocker locker(proxyMutex_); @@ -94,10 +96,11 @@ void V4L2CameraProxy::close(V4L2CameraFile *file) vcam_->close(); } -void *V4L2CameraProxy::mmap(void *addr, size_t length, int prot, int flags, - off64_t offset) +void *V4L2CameraProxy::mmap(V4L2CameraFile *file, void *addr, size_t length, + int prot, int flags, off64_t offset) { - LOG(V4L2Compat, Debug) << "Servicing mmap"; + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; MutexLocker locker(proxyMutex_); @@ -131,9 +134,10 @@ void *V4L2CameraProxy::mmap(void *addr, size_t length, int prot, int flags, return map; } -int V4L2CameraProxy::munmap(void *addr, size_t length) +int V4L2CameraProxy::munmap(V4L2CameraFile *file, void *addr, size_t length) { - LOG(V4L2Compat, Debug) << "Servicing munmap"; + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; MutexLocker locker(proxyMutex_); @@ -233,9 +237,10 @@ void V4L2CameraProxy::updateBuffers() } } -int V4L2CameraProxy::vidioc_querycap(struct v4l2_capability *arg) +int V4L2CameraProxy::vidioc_querycap(V4L2CameraFile *file, struct v4l2_capability *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_querycap"; + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; *arg = capabilities_; @@ -244,7 +249,8 @@ int V4L2CameraProxy::vidioc_querycap(struct v4l2_capability *arg) int V4L2CameraProxy::vidioc_enum_framesizes(V4L2CameraFile *file, struct v4l2_frmsizeenum *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_enum_framesizes fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; V4L2PixelFormat v4l2Format = V4L2PixelFormat(arg->pixel_format); PixelFormat format = v4l2Format.toPixelFormat(); @@ -267,7 +273,8 @@ int V4L2CameraProxy::vidioc_enum_framesizes(V4L2CameraFile *file, struct v4l2_fr int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_enum_fmt fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; if (!validateBufferType(arg->type) || arg->index >= streamConfig_.formats().pixelformats().size()) @@ -288,7 +295,8 @@ int V4L2CameraProxy::vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc * int V4L2CameraProxy::vidioc_g_fmt(V4L2CameraFile *file, struct v4l2_format *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_g_fmt fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; if (!validateBufferType(arg->type)) return -EINVAL; @@ -331,7 +339,8 @@ int V4L2CameraProxy::tryFormat(struct v4l2_format *arg) int V4L2CameraProxy::vidioc_s_fmt(V4L2CameraFile *file, struct v4l2_format *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_s_fmt fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; if (!validateBufferType(arg->type)) return -EINVAL; @@ -361,7 +370,8 @@ int V4L2CameraProxy::vidioc_s_fmt(V4L2CameraFile *file, struct v4l2_format *arg) int V4L2CameraProxy::vidioc_try_fmt(V4L2CameraFile *file, struct v4l2_format *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_try_fmt fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; if (!validateBufferType(arg->type)) return -EINVAL; @@ -384,7 +394,8 @@ enum v4l2_priority V4L2CameraProxy::maxPriority() int V4L2CameraProxy::vidioc_g_priority(V4L2CameraFile *file, enum v4l2_priority *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_g_priority fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; *arg = maxPriority(); @@ -394,7 +405,7 @@ int V4L2CameraProxy::vidioc_g_priority(V4L2CameraFile *file, enum v4l2_priority int V4L2CameraProxy::vidioc_s_priority(V4L2CameraFile *file, enum v4l2_priority *arg) { LOG(V4L2Compat, Debug) - << "Servicing vidioc_s_priority fd = " << file->efd(); + << "[" << file->description() << "] " << __func__ << "()"; if (*arg > V4L2_PRIORITY_RECORD) return -EINVAL; @@ -409,7 +420,8 @@ int V4L2CameraProxy::vidioc_s_priority(V4L2CameraFile *file, enum v4l2_priority int V4L2CameraProxy::vidioc_enuminput(V4L2CameraFile *file, struct v4l2_input *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_enuminput fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; if (arg->index != 0) return -EINVAL; @@ -426,7 +438,8 @@ int V4L2CameraProxy::vidioc_enuminput(V4L2CameraFile *file, struct v4l2_input *a int V4L2CameraProxy::vidioc_g_input(V4L2CameraFile *file, int *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_g_input fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; *arg = 0; @@ -435,7 +448,8 @@ int V4L2CameraProxy::vidioc_g_input(V4L2CameraFile *file, int *arg) int V4L2CameraProxy::vidioc_s_input(V4L2CameraFile *file, int *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_s_input fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; if (*arg != 0) return -EINVAL; @@ -452,7 +466,8 @@ void V4L2CameraProxy::freeBuffers() int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuffers *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_reqbufs fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; if (!validateBufferType(arg->type) || !validateMemoryType(arg->memory)) @@ -526,7 +541,8 @@ int V4L2CameraProxy::vidioc_reqbufs(V4L2CameraFile *file, struct v4l2_requestbuf int V4L2CameraProxy::vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_querybuf fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; if (arg->index >= bufferCount_) return -EINVAL; @@ -544,8 +560,9 @@ int V4L2CameraProxy::vidioc_querybuf(V4L2CameraFile *file, struct v4l2_buffer *a int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_qbuf, index = " - << arg->index << " fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ + << "(index=" << arg->index << ")"; if (arg->index >= bufferCount_) return -EINVAL; @@ -575,7 +592,8 @@ int V4L2CameraProxy::vidioc_qbuf(V4L2CameraFile *file, struct v4l2_buffer *arg) int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, Mutex *lock) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_dqbuf fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; if (arg->index >= bufferCount_) return -EINVAL; @@ -624,7 +642,8 @@ int V4L2CameraProxy::vidioc_dqbuf(V4L2CameraFile *file, struct v4l2_buffer *arg, int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_streamon fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; if (bufferCount_ == 0) return -EINVAL; @@ -648,7 +667,8 @@ int V4L2CameraProxy::vidioc_streamon(V4L2CameraFile *file, int *arg) int V4L2CameraProxy::vidioc_streamoff(V4L2CameraFile *file, int *arg) { - LOG(V4L2Compat, Debug) << "Servicing vidioc_streamoff fd = " << file->efd(); + LOG(V4L2Compat, Debug) + << "[" << file->description() << "] " << __func__ << "()"; if (!validateBufferType(*arg)) return -EINVAL; @@ -709,7 +729,7 @@ int V4L2CameraProxy::ioctl(V4L2CameraFile *file, unsigned long request, void *ar int ret; switch (request) { case VIDIOC_QUERYCAP: - ret = vidioc_querycap(static_cast(arg)); + ret = vidioc_querycap(file, static_cast(arg)); break; case VIDIOC_ENUM_FRAMESIZES: ret = vidioc_enum_framesizes(file, static_cast(arg)); diff --git a/src/v4l2/v4l2_camera_proxy.h b/src/v4l2/v4l2_camera_proxy.h index fa0a49e0439b..08f0295a92dd 100644 --- a/src/v4l2/v4l2_camera_proxy.h +++ b/src/v4l2/v4l2_camera_proxy.h @@ -29,8 +29,9 @@ public: int open(V4L2CameraFile *file); void close(V4L2CameraFile *file); - void *mmap(void *addr, size_t length, int prot, int flags, off64_t offset); - int munmap(void *addr, size_t length); + void *mmap(V4L2CameraFile *file, void *addr, size_t length, int prot, + int flags, off64_t offset); + int munmap(V4L2CameraFile *file, void *addr, size_t length); int ioctl(V4L2CameraFile *file, unsigned long request, void *arg); @@ -44,7 +45,7 @@ private: void updateBuffers(); void freeBuffers(); - int vidioc_querycap(struct v4l2_capability *arg); + int vidioc_querycap(V4L2CameraFile *file, struct v4l2_capability *arg); int vidioc_enum_framesizes(V4L2CameraFile *file, struct v4l2_frmsizeenum *arg); int vidioc_enum_fmt(V4L2CameraFile *file, struct v4l2_fmtdesc *arg); int vidioc_g_fmt(V4L2CameraFile *file, struct v4l2_format *arg); diff --git a/src/v4l2/v4l2_compat_manager.cpp b/src/v4l2/v4l2_compat_manager.cpp index ded568beb60e..0f7575c54b22 100644 --- a/src/v4l2/v4l2_compat_manager.cpp +++ b/src/v4l2/v4l2_compat_manager.cpp @@ -194,7 +194,8 @@ void *V4L2CompatManager::mmap(void *addr, size_t length, int prot, int flags, if (!file) return fops_.mmap(addr, length, prot, flags, fd, offset); - void *map = file->proxy()->mmap(addr, length, prot, flags, offset); + void *map = file->proxy()->mmap(file.get(), addr, length, prot, flags, + offset); if (map == MAP_FAILED) return map; @@ -210,7 +211,7 @@ int V4L2CompatManager::munmap(void *addr, size_t length) V4L2CameraFile *file = device->second.get(); - int ret = file->proxy()->munmap(addr, length); + int ret = file->proxy()->munmap(file, addr, length); if (ret < 0) return ret;