[libcamera-devel] libcamera: v4l2_subdevice: Report subdev device node on logs
diff mbox series

Message ID 20210506120523.969609-1-kieran.bingham@ideasonboard.com
State New
Delegated to: Kieran Bingham
Headers show
Series
  • [libcamera-devel] libcamera: v4l2_subdevice: Report subdev device node on logs
Related show

Commit Message

Kieran Bingham May 6, 2021, 12:05 p.m. UTC
The V4L2 Video device logs the deviceNode() as part of it's logging
prefix, but the Subdevices have not been updated in the same way.

There have been several occasions while debugging remotely, where users
would benefit from knowing which subdevice node is referenced by the
CameraSensor in the messages being printed, and adding it aligns the
output of the Video class with the Subdevice class.

This patch adds the /dev/v4l-subdev1 style string to the log message as
demonstrated here (from a fictitious additional log message):

[88:39:36.684494647] [969224]  INFO V4L2 v4l2_subdevice.cpp:436 /dev/v4l-subdev1: 'Sensor B': Setting Format
[88:36:13.308244848] [968664] DEBUG V4L2 v4l2_videodevice.cpp:1450 /dev/video6[22:cap]: Queueing buffer 0

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---

Yes, this makes the lines longer ;-( which makes me a little sad, but
aligns the two V4L2 types, and helps users find their device nodes when
needed/debugging...

 src/libcamera/v4l2_subdevice.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Pinchart May 6, 2021, 12:53 p.m. UTC | #1
On Thu, May 06, 2021 at 01:05:23PM +0100, Kieran Bingham wrote:
> The V4L2 Video device logs the deviceNode() as part of it's logging
> prefix, but the Subdevices have not been updated in the same way.
> 
> There have been several occasions while debugging remotely, where users
> would benefit from knowing which subdevice node is referenced by the
> CameraSensor in the messages being printed, and adding it aligns the
> output of the Video class with the Subdevice class.
> 
> This patch adds the /dev/v4l-subdev1 style string to the log message as
> demonstrated here (from a fictitious additional log message):
> 
> [88:39:36.684494647] [969224]  INFO V4L2 v4l2_subdevice.cpp:436 /dev/v4l-subdev1: 'Sensor B': Setting Format
> [88:36:13.308244848] [968664] DEBUG V4L2 v4l2_videodevice.cpp:1450 /dev/video6[22:cap]: Queueing buffer 0
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
> 
> Yes, this makes the lines longer ;-( which makes me a little sad, but
> aligns the two V4L2 types, and helps users find their device nodes when
> needed/debugging...

I have the same concern :-/ Aligning V4L2Subdevice and V4L2VideoDevice
isn't really a goal in my opinion, what matters is printing the most
useful information. If that differs between the two classes, so be it.
Note that if you really wanted to unify them, you'd have to add the
entity name to video nodes, as well as the file descriptor number to
subdevs.

I don't have a very strong opinion here, but I wonder if we could print
the video node and entity name at open time, and only the entity name in
other places ?

>  src/libcamera/v4l2_subdevice.cpp | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> index 721ff5a92a2b..fd464b0481aa 100644
> --- a/src/libcamera/v4l2_subdevice.cpp
> +++ b/src/libcamera/v4l2_subdevice.cpp
> @@ -461,7 +461,7 @@ V4L2Subdevice::fromEntityName(const MediaDevice *media,
>  
>  std::string V4L2Subdevice::logPrefix() const
>  {
> -	return "'" + entity_->name() + "'";
> +	return deviceNode() + ": '" + entity_->name() + "'";
>  }
>  
>  std::vector<unsigned int> V4L2Subdevice::enumPadCodes(unsigned int pad)

Patch
diff mbox series

diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index 721ff5a92a2b..fd464b0481aa 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -461,7 +461,7 @@  V4L2Subdevice::fromEntityName(const MediaDevice *media,
 
 std::string V4L2Subdevice::logPrefix() const
 {
-	return "'" + entity_->name() + "'";
+	return deviceNode() + ": '" + entity_->name() + "'";
 }
 
 std::vector<unsigned int> V4L2Subdevice::enumPadCodes(unsigned int pad)