[libcamera-devel,03/11] libcamera: camera: Log requested configuration in configureStreams()

Message ID 20190415165700.22970-4-laurent.pinchart@ideasonboard.com
State Superseded
Headers show
Series
  • Rockchip ISP pipeline handler
Related show

Commit Message

Laurent Pinchart April 15, 2019, 4:56 p.m. UTC
The IPU3 pipeline handler logs the requested configuration in its
configureStreams() handler. This is useful for other pipeline handlers
as well, move it to the Camera class.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/libcamera/camera.cpp             | 14 ++++++++++++++
 src/libcamera/pipeline/ipu3/ipu3.cpp |  6 ------
 2 files changed, 14 insertions(+), 6 deletions(-)

Comments

Niklas Söderlund April 15, 2019, 8:23 p.m. UTC | #1
Hi Laurent,

Thanks for your patch.

On 2019-04-15 19:56:52 +0300, Laurent Pinchart wrote:
> The IPU3 pipeline handler logs the requested configuration in its
> configureStreams() handler. This is useful for other pipeline handlers
> as well, move it to the Camera class.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/camera.cpp             | 14 ++++++++++++++
>  src/libcamera/pipeline/ipu3/ipu3.cpp |  6 ------
>  2 files changed, 14 insertions(+), 6 deletions(-)
> 
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index bdf14b31d8ee..55f724a8db17 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -5,6 +5,8 @@
>   * camera.cpp - Camera device
>   */
>  
> +#include <iomanip>
> +
>  #include <libcamera/camera.h>
>  #include <libcamera/request.h>
>  #include <libcamera/stream.h>
> @@ -595,11 +597,23 @@ int Camera::configureStreams(const CameraConfiguration &config)
>  		return -EINVAL;
>  	}
>  
> +	std::ostringstream msg("configuring streams:");

Neat, I did not know of ostingstream and have used stringstream in the 
cam utility. Maybe that should be changed at some point.

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

> +	unsigned int index = 0;
> +
>  	for (Stream *stream : config) {
>  		if (streams_.find(stream) == streams_.end())
>  			return -EINVAL;
> +
> +		const StreamConfiguration &cfg = config[stream];
> +		msg << " (" << index << ") " << cfg.width << "x"
> +		    << cfg.height << "-0x" << std::hex << std::setfill('0')
> +		    << std::setw(8) << cfg.pixelFormat;
> +
> +		index++;
>  	}
>  
> +	LOG(Camera, Info) << msg.str();
> +
>  	ret = pipe_->configureStreams(this, config);
>  	if (ret)
>  		return ret;
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index ca09da753b90..ff72be14d696 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -242,12 +242,6 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,
>  	ImgUDevice *imgu = data->imgu_;
>  	int ret;
>  
> -	LOG(IPU3, Info)
> -		<< "Requested image format " << cfg.width << "x"
> -		<< cfg.height << "-0x" << std::hex << std::setfill('0')
> -		<< std::setw(8) << cfg.pixelFormat << " on camera '"
> -		<< camera->name() << "'";
> -
>  	/*
>  	 * Verify that the requested size respects the IPU3 alignement
>  	 * requirements (the image width shall be a multiple of 8 pixels and
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Jacopo Mondi April 16, 2019, 2:57 p.m. UTC | #2
Hi Laurent,

On Mon, Apr 15, 2019 at 07:56:52PM +0300, Laurent Pinchart wrote:
> The IPU3 pipeline handler logs the requested configuration in its
> configureStreams() handler. This is useful for other pipeline handlers
> as well, move it to the Camera class.
>
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
>  src/libcamera/camera.cpp             | 14 ++++++++++++++
>  src/libcamera/pipeline/ipu3/ipu3.cpp |  6 ------
>  2 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index bdf14b31d8ee..55f724a8db17 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -5,6 +5,8 @@
>   * camera.cpp - Camera device
>   */
>
> +#include <iomanip>
> +
>  #include <libcamera/camera.h>
>  #include <libcamera/request.h>
>  #include <libcamera/stream.h>
> @@ -595,11 +597,23 @@ int Camera::configureStreams(const CameraConfiguration &config)
>  		return -EINVAL;
>  	}
>
> +	std::ostringstream msg("configuring streams:");
> +	unsigned int index = 0;
> +
>  	for (Stream *stream : config) {
>  		if (streams_.find(stream) == streams_.end())
>  			return -EINVAL;
> +
> +		const StreamConfiguration &cfg = config[stream];
> +		msg << " (" << index << ") " << cfg.width << "x"
> +		    << cfg.height << "-0x" << std::hex << std::setfill('0')
> +		    << std::setw(8) << cfg.pixelFormat;

std::endl at the end?

Apart from that:
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

Thanks
  j

> +
> +		index++;
>  	}
>
> +	LOG(Camera, Info) << msg.str();
> +
>  	ret = pipe_->configureStreams(this, config);
>  	if (ret)
>  		return ret;
> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> index ca09da753b90..ff72be14d696 100644
> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> @@ -242,12 +242,6 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,
>  	ImgUDevice *imgu = data->imgu_;
>  	int ret;
>
> -	LOG(IPU3, Info)
> -		<< "Requested image format " << cfg.width << "x"
> -		<< cfg.height << "-0x" << std::hex << std::setfill('0')
> -		<< std::setw(8) << cfg.pixelFormat << " on camera '"
> -		<< camera->name() << "'";
> -
>  	/*
>  	 * Verify that the requested size respects the IPU3 alignement
>  	 * requirements (the image width shall be a multiple of 8 pixels and
> --
> Regards,
>
> Laurent Pinchart
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart April 16, 2019, 4:56 p.m. UTC | #3
Hi Jacopo,

On Tue, Apr 16, 2019 at 04:57:03PM +0200, Jacopo Mondi wrote:
> On Mon, Apr 15, 2019 at 07:56:52PM +0300, Laurent Pinchart wrote:
> > The IPU3 pipeline handler logs the requested configuration in its
> > configureStreams() handler. This is useful for other pipeline handlers
> > as well, move it to the Camera class.
> >
> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > ---
> >  src/libcamera/camera.cpp             | 14 ++++++++++++++
> >  src/libcamera/pipeline/ipu3/ipu3.cpp |  6 ------
> >  2 files changed, 14 insertions(+), 6 deletions(-)
> >
> > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> > index bdf14b31d8ee..55f724a8db17 100644
> > --- a/src/libcamera/camera.cpp
> > +++ b/src/libcamera/camera.cpp
> > @@ -5,6 +5,8 @@
> >   * camera.cpp - Camera device
> >   */
> >
> > +#include <iomanip>
> > +
> >  #include <libcamera/camera.h>
> >  #include <libcamera/request.h>
> >  #include <libcamera/stream.h>
> > @@ -595,11 +597,23 @@ int Camera::configureStreams(const CameraConfiguration &config)
> >  		return -EINVAL;
> >  	}
> >
> > +	std::ostringstream msg("configuring streams:");
> > +	unsigned int index = 0;
> > +
> >  	for (Stream *stream : config) {
> >  		if (streams_.find(stream) == streams_.end())
> >  			return -EINVAL;
> > +
> > +		const StreamConfiguration &cfg = config[stream];
> > +		msg << " (" << index << ") " << cfg.width << "x"
> > +		    << cfg.height << "-0x" << std::hex << std::setfill('0')
> > +		    << std::setw(8) << cfg.pixelFormat;
> 
> std::endl at the end?

I don't think that's needed, as the message is then output by a single
LOG() call, which adds the std::endl. My goal was to print this on a
single line. Do you think it should be split to multiple lines ?

> Apart from that:
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> 
> > +
> > +		index++;
> >  	}
> >
> > +	LOG(Camera, Info) << msg.str();
> > +
> >  	ret = pipe_->configureStreams(this, config);
> >  	if (ret)
> >  		return ret;
> > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> > index ca09da753b90..ff72be14d696 100644
> > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> > @@ -242,12 +242,6 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,
> >  	ImgUDevice *imgu = data->imgu_;
> >  	int ret;
> >
> > -	LOG(IPU3, Info)
> > -		<< "Requested image format " << cfg.width << "x"
> > -		<< cfg.height << "-0x" << std::hex << std::setfill('0')
> > -		<< std::setw(8) << cfg.pixelFormat << " on camera '"
> > -		<< camera->name() << "'";
> > -
> >  	/*
> >  	 * Verify that the requested size respects the IPU3 alignement
> >  	 * requirements (the image width shall be a multiple of 8 pixels and
Jacopo Mondi April 17, 2019, 7:32 a.m. UTC | #4
HI Laurent,

On Tue, Apr 16, 2019 at 07:56:21PM +0300, Laurent Pinchart wrote:
> Hi Jacopo,
>
> On Tue, Apr 16, 2019 at 04:57:03PM +0200, Jacopo Mondi wrote:
> > On Mon, Apr 15, 2019 at 07:56:52PM +0300, Laurent Pinchart wrote:
> > > The IPU3 pipeline handler logs the requested configuration in its
> > > configureStreams() handler. This is useful for other pipeline handlers
> > > as well, move it to the Camera class.
> > >
> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > ---
> > >  src/libcamera/camera.cpp             | 14 ++++++++++++++
> > >  src/libcamera/pipeline/ipu3/ipu3.cpp |  6 ------
> > >  2 files changed, 14 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> > > index bdf14b31d8ee..55f724a8db17 100644
> > > --- a/src/libcamera/camera.cpp
> > > +++ b/src/libcamera/camera.cpp
> > > @@ -5,6 +5,8 @@
> > >   * camera.cpp - Camera device
> > >   */
> > >
> > > +#include <iomanip>
> > > +
> > >  #include <libcamera/camera.h>
> > >  #include <libcamera/request.h>
> > >  #include <libcamera/stream.h>
> > > @@ -595,11 +597,23 @@ int Camera::configureStreams(const CameraConfiguration &config)
> > >  		return -EINVAL;
> > >  	}
> > >
> > > +	std::ostringstream msg("configuring streams:");
> > > +	unsigned int index = 0;
> > > +
> > >  	for (Stream *stream : config) {
> > >  		if (streams_.find(stream) == streams_.end())
> > >  			return -EINVAL;
> > > +
> > > +		const StreamConfiguration &cfg = config[stream];
> > > +		msg << " (" << index << ") " << cfg.width << "x"
> > > +		    << cfg.height << "-0x" << std::hex << std::setfill('0')
> > > +		    << std::setw(8) << cfg.pixelFormat;
> >
> > std::endl at the end?
>
> I don't think that's needed, as the message is then output by a single
> LOG() call, which adds the std::endl. My goal was to print this on a
> single line. Do you think it should be split to multiple lines ?

With a single stream is fine, with multiple streams I think it should
be on two different lines. Or have you considered the multiple streams
case and judge they fit on a single line?

Thanks
  j

>
> > Apart from that:
> > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> >
> > > +
> > > +		index++;
> > >  	}
> > >
> > > +	LOG(Camera, Info) << msg.str();
> > > +
> > >  	ret = pipe_->configureStreams(this, config);
> > >  	if (ret)
> > >  		return ret;
> > > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> > > index ca09da753b90..ff72be14d696 100644
> > > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> > > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> > > @@ -242,12 +242,6 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,
> > >  	ImgUDevice *imgu = data->imgu_;
> > >  	int ret;
> > >
> > > -	LOG(IPU3, Info)
> > > -		<< "Requested image format " << cfg.width << "x"
> > > -		<< cfg.height << "-0x" << std::hex << std::setfill('0')
> > > -		<< std::setw(8) << cfg.pixelFormat << " on camera '"
> > > -		<< camera->name() << "'";
> > > -
> > >  	/*
> > >  	 * Verify that the requested size respects the IPU3 alignement
> > >  	 * requirements (the image width shall be a multiple of 8 pixels and
>
> --
> Regards,
>
> Laurent Pinchart
Laurent Pinchart April 17, 2019, 9:02 a.m. UTC | #5
Hi Jacopo,

On Wed, Apr 17, 2019 at 09:32:56AM +0200, Jacopo Mondi wrote:
> On Tue, Apr 16, 2019 at 07:56:21PM +0300, Laurent Pinchart wrote:
> > On Tue, Apr 16, 2019 at 04:57:03PM +0200, Jacopo Mondi wrote:
> >> On Mon, Apr 15, 2019 at 07:56:52PM +0300, Laurent Pinchart wrote:
> >>> The IPU3 pipeline handler logs the requested configuration in its
> >>> configureStreams() handler. This is useful for other pipeline handlers
> >>> as well, move it to the Camera class.
> >>>
> >>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>> ---
> >>>  src/libcamera/camera.cpp             | 14 ++++++++++++++
> >>>  src/libcamera/pipeline/ipu3/ipu3.cpp |  6 ------
> >>>  2 files changed, 14 insertions(+), 6 deletions(-)
> >>>
> >>> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> >>> index bdf14b31d8ee..55f724a8db17 100644
> >>> --- a/src/libcamera/camera.cpp
> >>> +++ b/src/libcamera/camera.cpp
> >>> @@ -5,6 +5,8 @@
> >>>   * camera.cpp - Camera device
> >>>   */
> >>>
> >>> +#include <iomanip>
> >>> +
> >>>  #include <libcamera/camera.h>
> >>>  #include <libcamera/request.h>
> >>>  #include <libcamera/stream.h>
> >>> @@ -595,11 +597,23 @@ int Camera::configureStreams(const CameraConfiguration &config)
> >>>  		return -EINVAL;
> >>>  	}
> >>>
> >>> +	std::ostringstream msg("configuring streams:");
> >>> +	unsigned int index = 0;
> >>> +
> >>>  	for (Stream *stream : config) {
> >>>  		if (streams_.find(stream) == streams_.end())
> >>>  			return -EINVAL;
> >>> +
> >>> +		const StreamConfiguration &cfg = config[stream];
> >>> +		msg << " (" << index << ") " << cfg.width << "x"
> >>> +		    << cfg.height << "-0x" << std::hex << std::setfill('0')
> >>> +		    << std::setw(8) << cfg.pixelFormat;
> >>
> >> std::endl at the end?
> >
> > I don't think that's needed, as the message is then output by a single
> > LOG() call, which adds the std::endl. My goal was to print this on a
> > single line. Do you think it should be split to multiple lines ?
> 
> With a single stream is fine, with multiple streams I think it should
> be on two different lines. Or have you considered the multiple streams
> case and judge they fit on a single line?

I wrote this specifically for multiple streams to be logged on a single
line. It could however be reconsidered.

> >> Apart from that:
> >> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> >>
> >>> +
> >>> +		index++;
> >>>  	}
> >>>
> >>> +	LOG(Camera, Info) << msg.str();
> >>> +
> >>>  	ret = pipe_->configureStreams(this, config);
> >>>  	if (ret)
> >>>  		return ret;
> >>> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> >>> index ca09da753b90..ff72be14d696 100644
> >>> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> >>> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> >>> @@ -242,12 +242,6 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,
> >>>  	ImgUDevice *imgu = data->imgu_;
> >>>  	int ret;
> >>>
> >>> -	LOG(IPU3, Info)
> >>> -		<< "Requested image format " << cfg.width << "x"
> >>> -		<< cfg.height << "-0x" << std::hex << std::setfill('0')
> >>> -		<< std::setw(8) << cfg.pixelFormat << " on camera '"
> >>> -		<< camera->name() << "'";
> >>> -
> >>>  	/*
> >>>  	 * Verify that the requested size respects the IPU3 alignement
> >>>  	 * requirements (the image width shall be a multiple of 8 pixels and
Niklas Söderlund April 17, 2019, 9:11 a.m. UTC | #6
Hi,

On 2019-04-17 12:02:45 +0300, Laurent Pinchart wrote:
> Hi Jacopo,
> 
> On Wed, Apr 17, 2019 at 09:32:56AM +0200, Jacopo Mondi wrote:
> > On Tue, Apr 16, 2019 at 07:56:21PM +0300, Laurent Pinchart wrote:
> > > On Tue, Apr 16, 2019 at 04:57:03PM +0200, Jacopo Mondi wrote:
> > >> On Mon, Apr 15, 2019 at 07:56:52PM +0300, Laurent Pinchart wrote:
> > >>> The IPU3 pipeline handler logs the requested configuration in its
> > >>> configureStreams() handler. This is useful for other pipeline handlers
> > >>> as well, move it to the Camera class.
> > >>>
> > >>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > >>> ---
> > >>>  src/libcamera/camera.cpp             | 14 ++++++++++++++
> > >>>  src/libcamera/pipeline/ipu3/ipu3.cpp |  6 ------
> > >>>  2 files changed, 14 insertions(+), 6 deletions(-)
> > >>>
> > >>> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> > >>> index bdf14b31d8ee..55f724a8db17 100644
> > >>> --- a/src/libcamera/camera.cpp
> > >>> +++ b/src/libcamera/camera.cpp
> > >>> @@ -5,6 +5,8 @@
> > >>>   * camera.cpp - Camera device
> > >>>   */
> > >>>
> > >>> +#include <iomanip>
> > >>> +
> > >>>  #include <libcamera/camera.h>
> > >>>  #include <libcamera/request.h>
> > >>>  #include <libcamera/stream.h>
> > >>> @@ -595,11 +597,23 @@ int Camera::configureStreams(const CameraConfiguration &config)
> > >>>  		return -EINVAL;
> > >>>  	}
> > >>>
> > >>> +	std::ostringstream msg("configuring streams:");
> > >>> +	unsigned int index = 0;
> > >>> +
> > >>>  	for (Stream *stream : config) {
> > >>>  		if (streams_.find(stream) == streams_.end())
> > >>>  			return -EINVAL;
> > >>> +
> > >>> +		const StreamConfiguration &cfg = config[stream];
> > >>> +		msg << " (" << index << ") " << cfg.width << "x"
> > >>> +		    << cfg.height << "-0x" << std::hex << std::setfill('0')
> > >>> +		    << std::setw(8) << cfg.pixelFormat;
> > >>
> > >> std::endl at the end?
> > >
> > > I don't think that's needed, as the message is then output by a single
> > > LOG() call, which adds the std::endl. My goal was to print this on a
> > > single line. Do you think it should be split to multiple lines ?
> > 
> > With a single stream is fine, with multiple streams I think it should
> > be on two different lines. Or have you considered the multiple streams
> > case and judge they fit on a single line?
> 
> I wrote this specifically for multiple streams to be logged on a single
> line. It could however be reconsidered.

I like bike shedding!

I think it should be a single line, this is for the log. Better to group 
things on the same line, even if it turns out to be a long line.

> 
> > >> Apart from that:
> > >> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> > >>
> > >>> +
> > >>> +		index++;
> > >>>  	}
> > >>>
> > >>> +	LOG(Camera, Info) << msg.str();
> > >>> +
> > >>>  	ret = pipe_->configureStreams(this, config);
> > >>>  	if (ret)
> > >>>  		return ret;
> > >>> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> > >>> index ca09da753b90..ff72be14d696 100644
> > >>> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> > >>> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> > >>> @@ -242,12 +242,6 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,
> > >>>  	ImgUDevice *imgu = data->imgu_;
> > >>>  	int ret;
> > >>>
> > >>> -	LOG(IPU3, Info)
> > >>> -		<< "Requested image format " << cfg.width << "x"
> > >>> -		<< cfg.height << "-0x" << std::hex << std::setfill('0')
> > >>> -		<< std::setw(8) << cfg.pixelFormat << " on camera '"
> > >>> -		<< camera->name() << "'";
> > >>> -
> > >>>  	/*
> > >>>  	 * Verify that the requested size respects the IPU3 alignement
> > >>>  	 * requirements (the image width shall be a multiple of 8 pixels and
> 
> -- 
> Regards,
> 
> Laurent Pinchart
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart April 17, 2019, 9:50 a.m. UTC | #7
On Wed, Apr 17, 2019 at 11:11:37AM +0200, Niklas Söderlund wrote:
> On 2019-04-17 12:02:45 +0300, Laurent Pinchart wrote:
> > On Wed, Apr 17, 2019 at 09:32:56AM +0200, Jacopo Mondi wrote:
> >> On Tue, Apr 16, 2019 at 07:56:21PM +0300, Laurent Pinchart wrote:
> >>> On Tue, Apr 16, 2019 at 04:57:03PM +0200, Jacopo Mondi wrote:
> >>>> On Mon, Apr 15, 2019 at 07:56:52PM +0300, Laurent Pinchart wrote:
> >>>>> The IPU3 pipeline handler logs the requested configuration in its
> >>>>> configureStreams() handler. This is useful for other pipeline handlers
> >>>>> as well, move it to the Camera class.
> >>>>>
> >>>>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>>>> ---
> >>>>>  src/libcamera/camera.cpp             | 14 ++++++++++++++
> >>>>>  src/libcamera/pipeline/ipu3/ipu3.cpp |  6 ------
> >>>>>  2 files changed, 14 insertions(+), 6 deletions(-)
> >>>>>
> >>>>> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> >>>>> index bdf14b31d8ee..55f724a8db17 100644
> >>>>> --- a/src/libcamera/camera.cpp
> >>>>> +++ b/src/libcamera/camera.cpp
> >>>>> @@ -5,6 +5,8 @@
> >>>>>   * camera.cpp - Camera device
> >>>>>   */
> >>>>>
> >>>>> +#include <iomanip>
> >>>>> +
> >>>>>  #include <libcamera/camera.h>
> >>>>>  #include <libcamera/request.h>
> >>>>>  #include <libcamera/stream.h>
> >>>>> @@ -595,11 +597,23 @@ int Camera::configureStreams(const CameraConfiguration &config)
> >>>>>  		return -EINVAL;
> >>>>>  	}
> >>>>>
> >>>>> +	std::ostringstream msg("configuring streams:");
> >>>>> +	unsigned int index = 0;
> >>>>> +
> >>>>>  	for (Stream *stream : config) {
> >>>>>  		if (streams_.find(stream) == streams_.end())
> >>>>>  			return -EINVAL;
> >>>>> +
> >>>>> +		const StreamConfiguration &cfg = config[stream];
> >>>>> +		msg << " (" << index << ") " << cfg.width << "x"
> >>>>> +		    << cfg.height << "-0x" << std::hex << std::setfill('0')
> >>>>> +		    << std::setw(8) << cfg.pixelFormat;
> >>>>
> >>>> std::endl at the end?
> >>>
> >>> I don't think that's needed, as the message is then output by a single
> >>> LOG() call, which adds the std::endl. My goal was to print this on a
> >>> single line. Do you think it should be split to multiple lines ?
> >> 
> >> With a single stream is fine, with multiple streams I think it should
> >> be on two different lines. Or have you considered the multiple streams
> >> case and judge they fit on a single line?
> > 
> > I wrote this specifically for multiple streams to be logged on a single
> > line. It could however be reconsidered.
> 
> I like bike shedding!
> 
> I think it should be a single line, this is for the log. Better to group 
> things on the same line, even if it turns out to be a long line.

Pros: easier to parse for machines.
Cons: slightly more difficult to read for humans.

> >>>> Apart from that:
> >>>> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
> >>>>
> >>>>> +
> >>>>> +		index++;
> >>>>>  	}
> >>>>>
> >>>>> +	LOG(Camera, Info) << msg.str();
> >>>>> +
> >>>>>  	ret = pipe_->configureStreams(this, config);
> >>>>>  	if (ret)
> >>>>>  		return ret;
> >>>>> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
> >>>>> index ca09da753b90..ff72be14d696 100644
> >>>>> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp
> >>>>> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
> >>>>> @@ -242,12 +242,6 @@ int PipelineHandlerIPU3::configureStreams(Camera *camera,
> >>>>>  	ImgUDevice *imgu = data->imgu_;
> >>>>>  	int ret;
> >>>>>
> >>>>> -	LOG(IPU3, Info)
> >>>>> -		<< "Requested image format " << cfg.width << "x"
> >>>>> -		<< cfg.height << "-0x" << std::hex << std::setfill('0')
> >>>>> -		<< std::setw(8) << cfg.pixelFormat << " on camera '"
> >>>>> -		<< camera->name() << "'";
> >>>>> -
> >>>>>  	/*
> >>>>>  	 * Verify that the requested size respects the IPU3 alignement
> >>>>>  	 * requirements (the image width shall be a multiple of 8 pixels and

Patch

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index bdf14b31d8ee..55f724a8db17 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -5,6 +5,8 @@ 
  * camera.cpp - Camera device
  */
 
+#include <iomanip>
+
 #include <libcamera/camera.h>
 #include <libcamera/request.h>
 #include <libcamera/stream.h>
@@ -595,11 +597,23 @@  int Camera::configureStreams(const CameraConfiguration &config)
 		return -EINVAL;
 	}
 
+	std::ostringstream msg("configuring streams:");
+	unsigned int index = 0;
+
 	for (Stream *stream : config) {
 		if (streams_.find(stream) == streams_.end())
 			return -EINVAL;
+
+		const StreamConfiguration &cfg = config[stream];
+		msg << " (" << index << ") " << cfg.width << "x"
+		    << cfg.height << "-0x" << std::hex << std::setfill('0')
+		    << std::setw(8) << cfg.pixelFormat;
+
+		index++;
 	}
 
+	LOG(Camera, Info) << msg.str();
+
 	ret = pipe_->configureStreams(this, config);
 	if (ret)
 		return ret;
diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp
index ca09da753b90..ff72be14d696 100644
--- a/src/libcamera/pipeline/ipu3/ipu3.cpp
+++ b/src/libcamera/pipeline/ipu3/ipu3.cpp
@@ -242,12 +242,6 @@  int PipelineHandlerIPU3::configureStreams(Camera *camera,
 	ImgUDevice *imgu = data->imgu_;
 	int ret;
 
-	LOG(IPU3, Info)
-		<< "Requested image format " << cfg.width << "x"
-		<< cfg.height << "-0x" << std::hex << std::setfill('0')
-		<< std::setw(8) << cfg.pixelFormat << " on camera '"
-		<< camera->name() << "'";
-
 	/*
 	 * Verify that the requested size respects the IPU3 alignement
 	 * requirements (the image width shall be a multiple of 8 pixels and