[libcamera-devel,v7,2/8] libcamera: camera: Reset basefield to decimal

Message ID 20190419101839.10337-3-jacopo@jmondi.org
State Superseded
Headers show
Series
  • libcamera: ipu3: Multiple streams support
Related show

Commit Message

Jacopo Mondi April 19, 2019, 10:18 a.m. UTC
When logging the camera configuration, the same ostringstream instance
is used to assemble a message describing configuration of all the
configured streams.

After the first stream configuration has been assembled, the use of
std::hex modifies the ostringstream basefield, causing all successive
integers values inserted in the stream to be expressed as hexadecimals.

Fix that by resetting the stream's basefield to decimal, before
assembling a stream configuration description.

Before this patch:
INFO Camera camera.cpp:615  (0) 640x480-0x3231564e (1) 140xa0-0x3231564e
After this patch:
INFO Camera camera.cpp:616  (0) 640x480-0x3231564e (1) 320x160-0x3231564e

Fixes: 9c9078133216 ("libcamera: camera: Log requested configuration in configureStreams()")
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/libcamera/camera.cpp | 1 +
 1 file changed, 1 insertion(+)

Comments

Laurent Pinchart April 19, 2019, 10:46 a.m. UTC | #1
Hi Jacopo,

Thank you for the patch.

On Fri, Apr 19, 2019 at 12:18:33PM +0200, Jacopo Mondi wrote:
> When logging the camera configuration, the same ostringstream instance
> is used to assemble a message describing configuration of all the
> configured streams.
> 
> After the first stream configuration has been assembled, the use of
> std::hex modifies the ostringstream basefield, causing all successive
> integers values inserted in the stream to be expressed as hexadecimals.
> 
> Fix that by resetting the stream's basefield to decimal, before
> assembling a stream configuration description.
> 
> Before this patch:
> INFO Camera camera.cpp:615  (0) 640x480-0x3231564e (1) 140xa0-0x3231564e
> After this patch:
> INFO Camera camera.cpp:616  (0) 640x480-0x3231564e (1) 320x160-0x3231564e
> 
> Fixes: 9c9078133216 ("libcamera: camera: Log requested configuration in configureStreams()")
> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>

Sorry for breaking it, and thank you for the fix.

> ---
>  src/libcamera/camera.cpp | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index bd381fa1cb56..4af3780d305e 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
> @@ -605,6 +605,7 @@ int Camera::configureStreams(const CameraConfiguration &config)
>  			return -EINVAL;
>  
>  		const StreamConfiguration &cfg = config[stream];
> +		msg << std::dec;
>  		msg << " (" << index << ") " << cfg.width << "x"

You could combine those two lines, they fit in 80 characters.

		msg << std::dec << " (" << index << ") " << cfg.width << "x"

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

>  		    << cfg.height << "-0x" << std::hex << std::setfill('0')
>  		    << std::setw(8) << cfg.pixelFormat;

Patch

diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index bd381fa1cb56..4af3780d305e 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -605,6 +605,7 @@  int Camera::configureStreams(const CameraConfiguration &config)
 			return -EINVAL;
 
 		const StreamConfiguration &cfg = config[stream];
+		msg << std::dec;
 		msg << " (" << index << ") " << cfg.width << "x"
 		    << cfg.height << "-0x" << std::hex << std::setfill('0')
 		    << std::setw(8) << cfg.pixelFormat;