[libcamera-devel] libcamera: media_device: Use Loggable interface

Message ID 20200217234841.16390-1-kieran.bingham@ideasonboard.com
State Accepted
Commit b0f1307fcfbb95519cdf19ac63dfd650d3fe5256
Headers show
Series
  • [libcamera-devel] libcamera: media_device: Use Loggable interface
Related show

Commit Message

Kieran Bingham Feb. 17, 2020, 11:48 p.m. UTC
Extend MediaDevice to inherit from the Loggable interface to support a
logPrefix which presents the device node path, and the driver name.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 src/libcamera/include/media_device.h | 6 +++++-
 src/libcamera/media_device.cpp       | 5 +++++
 2 files changed, 10 insertions(+), 1 deletion(-)

Comments

Kieran Bingham Feb. 18, 2020, 12:02 a.m. UTC | #1
On 17/02/2020 23:48, Kieran Bingham wrote:
> Extend MediaDevice to inherit from the Loggable interface to support a
> logPrefix which presents the device node path, and the driver name.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---

To clarify the change made by this patch:

This patch changes the output from:

> [57:36:02.635288057] [17731] DEBUG MediaDevice media_device.cpp:793 Debayer A[1] -> Scaler[0]: 0
> [57:36:02.635365812] [17731] DEBUG MediaDevice media_device.cpp:793 Debayer B[1] -> Scaler[0]: 0
> [57:36:02.635402682] [17731] DEBUG MediaDevice media_device.cpp:793 RGB/YUV Input[0] -> Scaler[0]: 0
> [57:36:02.635454420] [17731] DEBUG MediaDevice media_device.cpp:793 Debayer B[1] -> Scaler[0]: 1

to

> [57:34:39.915968711] [17239]  WARN VIMC vimc.cpp:372 no matching IPA found
> [57:34:39.916110489] [17239] DEBUG MediaDevice media_device.cpp:798 /dev/media3[vimc]: Debayer A[1] -> Scaler[0]: 0
> [57:34:39.916156966] [17239] DEBUG MediaDevice media_device.cpp:798 /dev/media3[vimc]: Debayer B[1] -> Scaler[0]: 0
> [57:34:39.916184364] [17239] DEBUG MediaDevice media_device.cpp:798 /dev/media3[vimc]: RGB/YUV Input[0] -> Scaler[0]: 0
> [57:34:39.916226427] [17239] DEBUG MediaDevice media_device.cpp:798 /dev/media3[vimc]: Debayer B[1] -> Scaler[0]: 1

--
Kieran

>  src/libcamera/include/media_device.h | 6 +++++-
>  src/libcamera/media_device.cpp       | 5 +++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
> index 7b88e2875d59..44a59e70139e 100644
> --- a/src/libcamera/include/media_device.h
> +++ b/src/libcamera/include/media_device.h
> @@ -16,11 +16,12 @@
>  
>  #include <libcamera/signal.h>
>  
> +#include "log.h"
>  #include "media_object.h"
>  
>  namespace libcamera {
>  
> -class MediaDevice
> +class MediaDevice : protected Loggable
>  {
>  public:
>  	MediaDevice(const std::string &deviceNode);
> @@ -52,6 +53,9 @@ public:
>  
>  	Signal<MediaDevice *> disconnected;
>  
> +protected:
> +	std::string logPrefix() const;
> +
>  private:
>  	std::string driver_;
>  	std::string deviceNode_;
> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
> index e1ae34f88455..fad475b9ac76 100644
> --- a/src/libcamera/media_device.cpp
> +++ b/src/libcamera/media_device.cpp
> @@ -74,6 +74,11 @@ MediaDevice::~MediaDevice()
>  	clear();
>  }
>  
> +std::string MediaDevice::logPrefix() const
> +{
> +	return deviceNode() + "[" + driver() + "]";
> +}
> +
>  /**
>   * \brief Claim a device for exclusive use
>   *
>
Laurent Pinchart Feb. 18, 2020, 12:07 a.m. UTC | #2
Hi Kieran,

Thank you for the patch.

On Mon, Feb 17, 2020 at 11:48:41PM +0000, Kieran Bingham wrote:
> Extend MediaDevice to inherit from the Loggable interface to support a
> logPrefix which presents the device node path, and the driver name.
> 
> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  src/libcamera/include/media_device.h | 6 +++++-
>  src/libcamera/media_device.cpp       | 5 +++++
>  2 files changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
> index 7b88e2875d59..44a59e70139e 100644
> --- a/src/libcamera/include/media_device.h
> +++ b/src/libcamera/include/media_device.h
> @@ -16,11 +16,12 @@
>  
>  #include <libcamera/signal.h>
>  
> +#include "log.h"
>  #include "media_object.h"
>  
>  namespace libcamera {
>  
> -class MediaDevice
> +class MediaDevice : protected Loggable
>  {
>  public:
>  	MediaDevice(const std::string &deviceNode);
> @@ -52,6 +53,9 @@ public:
>  
>  	Signal<MediaDevice *> disconnected;
>  
> +protected:
> +	std::string logPrefix() const;
> +
>  private:
>  	std::string driver_;
>  	std::string deviceNode_;
> diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
> index e1ae34f88455..fad475b9ac76 100644
> --- a/src/libcamera/media_device.cpp
> +++ b/src/libcamera/media_device.cpp
> @@ -74,6 +74,11 @@ MediaDevice::~MediaDevice()
>  	clear();
>  }
>  
> +std::string MediaDevice::logPrefix() const
> +{
> +	return deviceNode() + "[" + driver() + "]";

Before MediaDevice::populate is called, this will print "/dev/mediaX[]".
I suppose that's not a problem.

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> +}
> +
>  /**
>   * \brief Claim a device for exclusive use
>   *
Niklas Söderlund Feb. 18, 2020, 8:15 p.m. UTC | #3
Hi Kieran,

Thanks for your work.

On 2020-02-18 02:07:51 +0200, Laurent Pinchart wrote:
> Hi Kieran,
> 
> Thank you for the patch.
> 
> On Mon, Feb 17, 2020 at 11:48:41PM +0000, Kieran Bingham wrote:
> > Extend MediaDevice to inherit from the Loggable interface to support a
> > logPrefix which presents the device node path, and the driver name.
> > 
> > Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> > ---
> >  src/libcamera/include/media_device.h | 6 +++++-
> >  src/libcamera/media_device.cpp       | 5 +++++
> >  2 files changed, 10 insertions(+), 1 deletion(-)
> > 
> > diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
> > index 7b88e2875d59..44a59e70139e 100644
> > --- a/src/libcamera/include/media_device.h
> > +++ b/src/libcamera/include/media_device.h
> > @@ -16,11 +16,12 @@
> >  
> >  #include <libcamera/signal.h>
> >  
> > +#include "log.h"
> >  #include "media_object.h"
> >  
> >  namespace libcamera {
> >  
> > -class MediaDevice
> > +class MediaDevice : protected Loggable
> >  {
> >  public:
> >  	MediaDevice(const std::string &deviceNode);
> > @@ -52,6 +53,9 @@ public:
> >  
> >  	Signal<MediaDevice *> disconnected;
> >  
> > +protected:
> > +	std::string logPrefix() const;
> > +
> >  private:
> >  	std::string driver_;
> >  	std::string deviceNode_;
> > diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
> > index e1ae34f88455..fad475b9ac76 100644
> > --- a/src/libcamera/media_device.cpp
> > +++ b/src/libcamera/media_device.cpp
> > @@ -74,6 +74,11 @@ MediaDevice::~MediaDevice()
> >  	clear();
> >  }
> >  
> > +std::string MediaDevice::logPrefix() const
> > +{
> > +	return deviceNode() + "[" + driver() + "]";
> 
> Before MediaDevice::populate is called, this will print "/dev/mediaX[]".
> I suppose that's not a problem.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

I think it's not a problem and I like the added information added to 
logs from this change.

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> 
> > +}
> > +
> >  /**
> >   * \brief Claim a device for exclusive use
> >   *
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/libcamera/include/media_device.h b/src/libcamera/include/media_device.h
index 7b88e2875d59..44a59e70139e 100644
--- a/src/libcamera/include/media_device.h
+++ b/src/libcamera/include/media_device.h
@@ -16,11 +16,12 @@ 
 
 #include <libcamera/signal.h>
 
+#include "log.h"
 #include "media_object.h"
 
 namespace libcamera {
 
-class MediaDevice
+class MediaDevice : protected Loggable
 {
 public:
 	MediaDevice(const std::string &deviceNode);
@@ -52,6 +53,9 @@  public:
 
 	Signal<MediaDevice *> disconnected;
 
+protected:
+	std::string logPrefix() const;
+
 private:
 	std::string driver_;
 	std::string deviceNode_;
diff --git a/src/libcamera/media_device.cpp b/src/libcamera/media_device.cpp
index e1ae34f88455..fad475b9ac76 100644
--- a/src/libcamera/media_device.cpp
+++ b/src/libcamera/media_device.cpp
@@ -74,6 +74,11 @@  MediaDevice::~MediaDevice()
 	clear();
 }
 
+std::string MediaDevice::logPrefix() const
+{
+	return deviceNode() + "[" + driver() + "]";
+}
+
 /**
  * \brief Claim a device for exclusive use
  *