[libcamera-devel] [PATCH 2/2] libcamera: v4l2_videodevice: Print fd value in log prefix

Kieran Bingham kieran.bingham at ideasonboard.com
Wed Mar 3 17:41:47 CET 2021


On 03/03/2021 16:37, Laurent Pinchart wrote:
> 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.

An example of how the change looks in the output might have been nice here.

It looks like it goes from

[out] or [cap]
 to
[234:out] or [234:cap]

Which is fine by me, and gives each context a unique reference.

We could choose to do that only on M2M nodes if those are the only ones
that are possible to open multiple times ... but maybe that's overkill
and would require more processing in this code path.

Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>

> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
>  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]");
>  }
>  
>  /**
> 

-- 
Regards
--
Kieran


More information about the libcamera-devel mailing list