[{"id":1473,"web_url":"https://patchwork.libcamera.org/comment/1473/","msgid":"<20190419085039.j5tqb6pxhsbtsz4a@uno.localdomain>","date":"2019-04-19T08:50:39","subject":"Re: [libcamera-devel] [PATCH 2/3] libcamera: stream: Add and use\n\ttoString() method to StreamConfiguration","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Thu, Apr 18, 2019 at 06:44:52PM +0300, Laurent Pinchart wrote:\n> Add a toString() method to the StreamConfiguration class, and replace\n> all manually coded implementations through the source code.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  include/libcamera/stream.h               |  4 ++++\n>  src/libcamera/camera.cpp                 |  4 +---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp     |  5 +----\n>  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 14 ++++----------\n>  src/libcamera/stream.cpp                 | 19 +++++++++++++++++++\n>  5 files changed, 29 insertions(+), 17 deletions(-)\n>\n> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\n> index 8a47930f8614..3caaefc9f8e9 100644\n> --- a/include/libcamera/stream.h\n> +++ b/include/libcamera/stream.h\n> @@ -7,6 +7,8 @@\n>  #ifndef __LIBCAMERA_STREAM_H__\n>  #define __LIBCAMERA_STREAM_H__\n>\n> +#include <string>\n> +\n>  #include <libcamera/buffer.h>\n>  #include <libcamera/geometry.h>\n>\n> @@ -20,6 +22,8 @@ struct StreamConfiguration {\n>  \tunsigned int pixelFormat;\n>\n>  \tunsigned int bufferCount;\n> +\n> +\tstd::string toString() const;\n>  };\n>\n>  class StreamUsage\n> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> index 69406b515700..a52769626446 100644\n> --- a/src/libcamera/camera.cpp\n> +++ b/src/libcamera/camera.cpp\n> @@ -596,9 +596,7 @@ int Camera::configureStreams(const CameraConfiguration &config)\n>  \t\t\treturn -EINVAL;\n>\n>  \t\tconst StreamConfiguration &cfg = config[stream];\n> -\t\tmsg << \" (\" << index << \") \" << cfg.width << \"x\"\n> -\t\t    << cfg.height << \"-0x\" << std::hex << std::setfill('0')\n> -\t\t    << std::setw(8) << cfg.pixelFormat;\n> +\t\tmsg << \" (\" << index << \") \" << cfg.toString();\n>\n>  \t\tindex++;\n>  \t}\n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 405d6548fd01..7443224d4f45 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -224,10 +224,7 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera,\n>  \tconfig->pixelFormat = V4L2_PIX_FMT_NV12;\n>  \tconfig->bufferCount = IPU3_BUFFER_COUNT;\n>\n> -\tLOG(IPU3, Debug)\n> -\t\t<< \"Stream format set to \" << config->width << \"x\"\n> -\t\t<< config->height << \"-0x\" << std::hex << std::setfill('0')\n> -\t\t<< std::setw(8) << config->pixelFormat;\n> +\tLOG(IPU3, Debug) << \"Stream format set to \" << config->toString();\n>\n>  \treturn configs;\n>  }\n> diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> index 8ed0ba84780a..d21c6266c6ba 100644\n> --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> @@ -124,10 +124,7 @@ CameraConfiguration PipelineHandlerRkISP1::streamConfiguration(Camera *camera,\n>\n>  \tconfigs[&data->stream_] = config;\n>\n> -\tLOG(RkISP1, Debug)\n> -\t\t<< \"Stream format set to \" << config.width << \"x\"\n> -\t\t<< config.height << \"-0x\" << std::hex << std::setfill('0')\n> -\t\t<< std::setw(8) << config.pixelFormat;\n> +\tLOG(RkISP1, Debug) << \"Stream format set to \" << config.toString();\n>\n>  \treturn configs;\n>  }\n> @@ -223,7 +220,7 @@ int PipelineHandlerRkISP1::configureStreams(Camera *camera,\n>  \tV4L2DeviceFormat outputFormat = {};\n>  \toutputFormat.width = cfg.width;\n>  \toutputFormat.height = cfg.height;\n> -\toutputFormat.fourcc = V4L2_PIX_FMT_NV12;\n> +\toutputFormat.fourcc = cfg.pixelFormat;\n>  \toutputFormat.planesCount = 2;\n>\n>  \tret = video_->setFormat(&outputFormat);\n> @@ -232,12 +229,9 @@ int PipelineHandlerRkISP1::configureStreams(Camera *camera,\n>\n>  \tif (outputFormat.width != cfg.width ||\n>  \t    outputFormat.height != cfg.height ||\n> -\t    outputFormat.fourcc != V4L2_PIX_FMT_NV12) {\n> +\t    outputFormat.fourcc != cfg.pixelFormat) {\n\nThis and the above hunk seems to be unrelated to this patch to me...\n\n>  \t\tLOG(RkISP1, Error)\n> -\t\t\t<< \"Unable to configure capture in \" << cfg.width\n> -\t\t\t<< \"x\" << cfg.height << \"-0x\"\n> -\t\t\t<< std::hex << std::setfill('0') << std::setw(8)\n> -\t\t\t<< V4L2_PIX_FMT_NV12;\n> +\t\t\t<< \"Unable to configure capture in \" << cfg.toString();\n>  \t\treturn -EINVAL;\n>  \t}\n>\n> diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\n> index d4ef506cea95..06db9797ff7e 100644\n> --- a/src/libcamera/stream.cpp\n> +++ b/src/libcamera/stream.cpp\n> @@ -5,6 +5,9 @@\n>   * stream.cpp - Video stream for a Camera\n>   */\n>\n> +#include <iomanip>\n> +#include <sstream>\n> +\n>  #include <libcamera/stream.h>\n>\n>  /**\n> @@ -55,6 +58,22 @@ namespace libcamera {\n>   * format described in V4L2 using the V4L2_PIX_FMT_* definitions.\n>   */\n>\n> +/**\n> + * \\brief Assemble and return a string describing the configuration\n> + *\n> + * \\return A string describing the StreamConfiguration\n> + */\n> +std::string StreamConfiguration::toString() const\n> +{\n> +\tstd::stringstream ss;\n> +\n> +\tss.fill(0);\n> +\tss << width << \"x\" << height << \"-0x\" << std::hex\n> +\t   << std::setw(8) << pixelFormat;\n> +\n> +\treturn ss.str();\n> +}\n> +\n\nIn the struct declaration the toString() method comes after the\nbufferCount member, if we want to follow the declaration order.\n\nApart from that:\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\n>  /**\n>   * \\var StreamConfiguration::bufferCount\n>   * \\brief Requested number of buffers to allocate for the stream\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net\n\t[217.70.183.198])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 11F3860DB4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Apr 2019 10:49:46 +0200 (CEST)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 8B5AEC000F;\n\tFri, 19 Apr 2019 08:49:45 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Fri, 19 Apr 2019 10:50:39 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190419085039.j5tqb6pxhsbtsz4a@uno.localdomain>","References":"<20190418154453.20142-1-laurent.pinchart@ideasonboard.com>\n\t<20190418154453.20142-2-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"u57vn5exiqhr27dz\"","Content-Disposition":"inline","In-Reply-To":"<20190418154453.20142-2-laurent.pinchart@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH 2/3] libcamera: stream: Add and use\n\ttoString() method to StreamConfiguration","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 19 Apr 2019 08:49:46 -0000"}},{"id":1480,"web_url":"https://patchwork.libcamera.org/comment/1480/","msgid":"<20190419102408.GC4788@pendragon.ideasonboard.com>","date":"2019-04-19T10:24:08","subject":"Re: [libcamera-devel] [PATCH 2/3] libcamera: stream: Add and use\n\ttoString() method to StreamConfiguration","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Fri, Apr 19, 2019 at 10:50:39AM +0200, Jacopo Mondi wrote:\n> On Thu, Apr 18, 2019 at 06:44:52PM +0300, Laurent Pinchart wrote:\n> > Add a toString() method to the StreamConfiguration class, and replace\n> > all manually coded implementations through the source code.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  include/libcamera/stream.h               |  4 ++++\n> >  src/libcamera/camera.cpp                 |  4 +---\n> >  src/libcamera/pipeline/ipu3/ipu3.cpp     |  5 +----\n> >  src/libcamera/pipeline/rkisp1/rkisp1.cpp | 14 ++++----------\n> >  src/libcamera/stream.cpp                 | 19 +++++++++++++++++++\n> >  5 files changed, 29 insertions(+), 17 deletions(-)\n> >\n> > diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h\n> > index 8a47930f8614..3caaefc9f8e9 100644\n> > --- a/include/libcamera/stream.h\n> > +++ b/include/libcamera/stream.h\n> > @@ -7,6 +7,8 @@\n> >  #ifndef __LIBCAMERA_STREAM_H__\n> >  #define __LIBCAMERA_STREAM_H__\n> >\n> > +#include <string>\n> > +\n> >  #include <libcamera/buffer.h>\n> >  #include <libcamera/geometry.h>\n> >\n> > @@ -20,6 +22,8 @@ struct StreamConfiguration {\n> >  \tunsigned int pixelFormat;\n> >\n> >  \tunsigned int bufferCount;\n> > +\n> > +\tstd::string toString() const;\n> >  };\n> >\n> >  class StreamUsage\n> > diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp\n> > index 69406b515700..a52769626446 100644\n> > --- a/src/libcamera/camera.cpp\n> > +++ b/src/libcamera/camera.cpp\n> > @@ -596,9 +596,7 @@ int Camera::configureStreams(const CameraConfiguration &config)\n> >  \t\t\treturn -EINVAL;\n> >\n> >  \t\tconst StreamConfiguration &cfg = config[stream];\n> > -\t\tmsg << \" (\" << index << \") \" << cfg.width << \"x\"\n> > -\t\t    << cfg.height << \"-0x\" << std::hex << std::setfill('0')\n> > -\t\t    << std::setw(8) << cfg.pixelFormat;\n> > +\t\tmsg << \" (\" << index << \") \" << cfg.toString();\n> >\n> >  \t\tindex++;\n> >  \t}\n> > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > index 405d6548fd01..7443224d4f45 100644\n> > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > @@ -224,10 +224,7 @@ PipelineHandlerIPU3::streamConfiguration(Camera *camera,\n> >  \tconfig->pixelFormat = V4L2_PIX_FMT_NV12;\n> >  \tconfig->bufferCount = IPU3_BUFFER_COUNT;\n> >\n> > -\tLOG(IPU3, Debug)\n> > -\t\t<< \"Stream format set to \" << config->width << \"x\"\n> > -\t\t<< config->height << \"-0x\" << std::hex << std::setfill('0')\n> > -\t\t<< std::setw(8) << config->pixelFormat;\n> > +\tLOG(IPU3, Debug) << \"Stream format set to \" << config->toString();\n> >\n> >  \treturn configs;\n> >  }\n> > diff --git a/src/libcamera/pipeline/rkisp1/rkisp1.cpp b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > index 8ed0ba84780a..d21c6266c6ba 100644\n> > --- a/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > +++ b/src/libcamera/pipeline/rkisp1/rkisp1.cpp\n> > @@ -124,10 +124,7 @@ CameraConfiguration PipelineHandlerRkISP1::streamConfiguration(Camera *camera,\n> >\n> >  \tconfigs[&data->stream_] = config;\n> >\n> > -\tLOG(RkISP1, Debug)\n> > -\t\t<< \"Stream format set to \" << config.width << \"x\"\n> > -\t\t<< config.height << \"-0x\" << std::hex << std::setfill('0')\n> > -\t\t<< std::setw(8) << config.pixelFormat;\n> > +\tLOG(RkISP1, Debug) << \"Stream format set to \" << config.toString();\n> >\n> >  \treturn configs;\n> >  }\n> > @@ -223,7 +220,7 @@ int PipelineHandlerRkISP1::configureStreams(Camera *camera,\n> >  \tV4L2DeviceFormat outputFormat = {};\n> >  \toutputFormat.width = cfg.width;\n> >  \toutputFormat.height = cfg.height;\n> > -\toutputFormat.fourcc = V4L2_PIX_FMT_NV12;\n> > +\toutputFormat.fourcc = cfg.pixelFormat;\n> >  \toutputFormat.planesCount = 2;\n> >\n> >  \tret = video_->setFormat(&outputFormat);\n> > @@ -232,12 +229,9 @@ int PipelineHandlerRkISP1::configureStreams(Camera *camera,\n> >\n> >  \tif (outputFormat.width != cfg.width ||\n> >  \t    outputFormat.height != cfg.height ||\n> > -\t    outputFormat.fourcc != V4L2_PIX_FMT_NV12) {\n> > +\t    outputFormat.fourcc != cfg.pixelFormat) {\n> \n> This and the above hunk seems to be unrelated to this patch to me...\n\nI included them here to match the log message, but you're right, they're\nworth a separate patch. I'll fix that.\n\n> >  \t\tLOG(RkISP1, Error)\n> > -\t\t\t<< \"Unable to configure capture in \" << cfg.width\n> > -\t\t\t<< \"x\" << cfg.height << \"-0x\"\n> > -\t\t\t<< std::hex << std::setfill('0') << std::setw(8)\n> > -\t\t\t<< V4L2_PIX_FMT_NV12;\n> > +\t\t\t<< \"Unable to configure capture in \" << cfg.toString();\n> >  \t\treturn -EINVAL;\n> >  \t}\n> >\n> > diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp\n> > index d4ef506cea95..06db9797ff7e 100644\n> > --- a/src/libcamera/stream.cpp\n> > +++ b/src/libcamera/stream.cpp\n> > @@ -5,6 +5,9 @@\n> >   * stream.cpp - Video stream for a Camera\n> >   */\n> >\n> > +#include <iomanip>\n> > +#include <sstream>\n> > +\n> >  #include <libcamera/stream.h>\n> >\n> >  /**\n> > @@ -55,6 +58,22 @@ namespace libcamera {\n> >   * format described in V4L2 using the V4L2_PIX_FMT_* definitions.\n> >   */\n> >\n> > +/**\n> > + * \\brief Assemble and return a string describing the configuration\n> > + *\n> > + * \\return A string describing the StreamConfiguration\n> > + */\n> > +std::string StreamConfiguration::toString() const\n> > +{\n> > +\tstd::stringstream ss;\n> > +\n> > +\tss.fill(0);\n> > +\tss << width << \"x\" << height << \"-0x\" << std::hex\n> > +\t   << std::setw(8) << pixelFormat;\n> > +\n> > +\treturn ss.str();\n> > +}\n> > +\n> \n> In the struct declaration the toString() method comes after the\n> bufferCount member, if we want to follow the declaration order.\n\nOops, I'll fix that.\n\n> Apart from that:\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> >  /**\n> >   * \\var StreamConfiguration::bufferCount\n> >   * \\brief Requested number of buffers to allocate for the stream","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BC20D60004\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Apr 2019 12:24:26 +0200 (CEST)","from pendragon.ideasonboard.com (unknown\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9D08031A;\n\tFri, 19 Apr 2019 12:24:25 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1555669465;\n\tbh=EepRR6IFROdwi6adw4w4HIcEgVTDO32f2/2Zjhr4ilE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=wBPuy3EAKk8OCA2yI/9a8ECzK7MHYxG7syFIsRPWsCiIERqG1G+Y90/gcHcau0Tem\n\tR9bvMDoivI/F1suouY0koOt91+lG3VuMmDibarZHeMuovFC0Bm1cYuxXihe2H7HVlh\n\t6oBUpdJjVhHHZKChqWZmvHNjZZlQ22bznhTyYQzw=","Date":"Fri, 19 Apr 2019 13:24:08 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190419102408.GC4788@pendragon.ideasonboard.com>","References":"<20190418154453.20142-1-laurent.pinchart@ideasonboard.com>\n\t<20190418154453.20142-2-laurent.pinchart@ideasonboard.com>\n\t<20190419085039.j5tqb6pxhsbtsz4a@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190419085039.j5tqb6pxhsbtsz4a@uno.localdomain>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 2/3] libcamera: stream: Add and use\n\ttoString() method to StreamConfiguration","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Fri, 19 Apr 2019 10:24:27 -0000"}}]