[v2,5/5] libcamera: v4l2_subdevice: Make log prefix similar to V4L2VideoDevice
diff mbox series

Message ID 20260910160309.940584-5-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • [v2,1/5] libcamera: v4l2_videodevice: V4L2DeviceFormat: Expand formatting
Related show

Commit Message

Barnabás Pőcze Sept. 10, 2026, 4:03 p.m. UTC
Make the log prefix of `V4L2Subdevice` more similar to that of
`V4L2VideoDevice`. Specifically, add the path of the device and the
file descriptor to the log prefix.

Having the path in the log message helps debugging if the device needs
to be inspected by e.g. {v4l2,media}-ctl. The file descriptor is added
for consistency with `V4L2VideoDevice`.

Example:

  DEBUG V4L2 v4l2_device.cpp:741 /dev/v4l-subdev5[19:'imx708']: Control: Exposure (0x00980911)

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 src/libcamera/v4l2_subdevice.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Kieran Bingham Sept. 10, 2026, 4:19 p.m. UTC | #1
Quoting Barnabás Pőcze (2026-09-10 17:03:09)
> Make the log prefix of `V4L2Subdevice` more similar to that of
> `V4L2VideoDevice`. Specifically, add the path of the device and the
> file descriptor to the log prefix.
> 
> Having the path in the log message helps debugging if the device needs
> to be inspected by e.g. {v4l2,media}-ctl. The file descriptor is added
> for consistency with `V4L2VideoDevice`.
> 
> Example:
> 
>   DEBUG V4L2 v4l2_device.cpp:741 /dev/v4l-subdev5[19:'imx708']: Control: Exposure (0x00980911)
> 
> Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>

I've wanted this before [0] so:

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

[0] https://patchwork.libcamera.org/patch/12207/

Back then Laurent suggested "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 would happily see the entity
name on V4L2Device as well.

--
Kieran



> ---
>  src/libcamera/v4l2_subdevice.cpp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
> index 511cc12e2f..fd5fb51bbf 100644
> --- a/src/libcamera/v4l2_subdevice.cpp
> +++ b/src/libcamera/v4l2_subdevice.cpp
> @@ -1786,7 +1786,8 @@ V4L2Subdevice::fromEntityName(const MediaDevice *media,
>  
>  std::string V4L2Subdevice::logPrefix() const
>  {
> -       return "'" + entity_->name() + "'";
> +       return deviceNode() + '[' + std::to_string(fd()) +
> +               ":'" + entity_->name() + "']";
>  }
>  
>  std::vector<unsigned int> V4L2Subdevice::enumPadCodes(const Stream &stream)
> -- 
> 2.55.0
>

Patch
diff mbox series

diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp
index 511cc12e2f..fd5fb51bbf 100644
--- a/src/libcamera/v4l2_subdevice.cpp
+++ b/src/libcamera/v4l2_subdevice.cpp
@@ -1786,7 +1786,8 @@  V4L2Subdevice::fromEntityName(const MediaDevice *media,
 
 std::string V4L2Subdevice::logPrefix() const
 {
-	return "'" + entity_->name() + "'";
+	return deviceNode() + '[' + std::to_string(fd()) +
+		":'" + entity_->name() + "']";
 }
 
 std::vector<unsigned int> V4L2Subdevice::enumPadCodes(const Stream &stream)