From patchwork Wed Mar 3 16:37:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11478 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 C4AA7BD1F1 for ; Wed, 3 Mar 2021 16:37:48 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8D8E168A92; Wed, 3 Mar 2021 17:37:48 +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="LvCnK2PV"; 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 7FBDE68A7E for ; Wed, 3 Mar 2021 17:37:47 +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 13A868CA for ; Wed, 3 Mar 2021 17:37:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1614789467; bh=0054k6DZd6EEbq+ffJKDi2PcJkRjtjUaxwC8WaTh30U=; h=From:To:Subject:Date:From; b=LvCnK2PVcQI2z7uhUKjHV740EZfzyhNVfhXgNG8uDjvcxBXs/Rc28ZJGNKo6aXJGY MFDE5FZJUTNxT/3h5/Bfk+kC4XgRxGUGmVSXnKdFd3qlNRztFuOWnU2EkNWcVK+h2q cajxoBjZVy4Mp7kyw6jLEB/6ckQRRZHYsbOJod74= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Mar 2021 18:37:14 +0200 Message-Id: <20210303163715.21730-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] libcamera: v4l2_device: Make fd() function const 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" There are use cases for getting the file descriptor of a const V4L2Device instance, for instance to print it in a log. Make the function const. There's little risk of abuse here (as in code then performing operations on the file descriptors that conceptually modify the V4L2 device), as the fd() function is protected. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- include/libcamera/internal/v4l2_device.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index c56a950ee4f9..d006bf684335 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -50,7 +50,7 @@ protected: int ioctl(unsigned long request, void *argp); - int fd() { return fd_; } + int fd() const { return fd_; } private: void listControls(); From patchwork Wed Mar 3 16:37:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 11479 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 25BC9BD1F1 for ; Wed, 3 Mar 2021 16:37:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E690A68A91; Wed, 3 Mar 2021 17:37:49 +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="HXAIZWk0"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0625868A7E for ; Wed, 3 Mar 2021 17:37:48 +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 9D4D48CA for ; Wed, 3 Mar 2021 17:37:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1614789467; bh=aTtXIZ/K/23lEG8EDI0IPPWGNHKBYILwBVB6wSM5kCI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=HXAIZWk0424Nk/3aOCe+veloMI/JUbhbt8t+omZpobftdHAlrb7r8mBC8iXvunODx 7Qz81QTldoAjDtASEnxcttOF0rVEn8nDKGWbu/AtvDk3uJHXvlpn/E2l6ViANZPnP/ yIfuOrV243V12wSYEIStUxisxLfgPb5BIi1KaSp8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 3 Mar 2021 18:37:15 +0200 Message-Id: <20210303163715.21730-2-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210303163715.21730-1-laurent.pinchart@ideasonboard.com> References: <20210303163715.21730-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] libcamera: v4l2_videodevice: Print fd value in log prefix 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" When opening a V4L2VideoDevice multiple times, for instance to run multiple jobs on a M2M device, it's useful to attribute log messages to a particular instance. Include the device fd in the log prefix. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Paul Elder --- src/libcamera/v4l2_videodevice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp index c77e1aff7978..cb52d4cea3f6 100644 --- a/src/libcamera/v4l2_videodevice.cpp +++ b/src/libcamera/v4l2_videodevice.cpp @@ -711,7 +711,8 @@ void V4L2VideoDevice::close() std::string V4L2VideoDevice::logPrefix() const { - return deviceNode() + (V4L2_TYPE_IS_OUTPUT(bufferType_) ? "[out]" : "[cap]"); + return deviceNode() + "[" + std::to_string(fd()) + + (V4L2_TYPE_IS_OUTPUT(bufferType_) ? ":out]" : ":cap]"); } /**