[{"id":1047,"web_url":"https://patchwork.libcamera.org/comment/1047/","msgid":"<3f10d658-82fb-76e9-d19c-3cc1142b1304@ideasonboard.com>","date":"2019-03-12T12:25:39","subject":"Re: [libcamera-devel] [PATCH v2 01/14] libcamera: formats: Add\n\ttoString() methods","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Jacopo,\n\nThis is neat, and gives us a single place to handle this formatting in a\nconsistent fashion throughout. (well single for each V4L2 type).\n\nI guess later we could use this to override the << operator too?\n\nBut that's not necessary for now.\n\nLGTM.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\nOn 12/03/2019 12:12, Jacopo Mondi wrote:\n> Add toString() helpers to pretty print out a V4L2Device or V4L2Subdevice\n> format.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/include/v4l2_device.h    |  2 ++\n>  src/libcamera/include/v4l2_subdevice.h |  2 ++\n>  src/libcamera/v4l2_device.cpp          | 18 ++++++++++++++++++\n>  src/libcamera/v4l2_subdevice.cpp       | 18 ++++++++++++++++++\n>  4 files changed, 40 insertions(+)\n> \n> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\n> index 5c379fac66dc..258deee8d461 100644\n> --- a/src/libcamera/include/v4l2_device.h\n> +++ b/src/libcamera/include/v4l2_device.h\n> @@ -100,6 +100,8 @@ public:\n>  \t\tuint32_t bpl;\n>  \t} planes[3];\n>  \tunsigned int planesCount;\n> +\n> +\tconst std::string toString() const;\n>  };\n>  \n>  class V4L2Device : protected Loggable\n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index 1cc0fab73103..700e66bcddac 100644\n> --- a/src/libcamera/include/v4l2_subdevice.h\n> +++ b/src/libcamera/include/v4l2_subdevice.h\n> @@ -21,6 +21,8 @@ struct V4L2SubdeviceFormat {\n>  \tuint32_t mbus_code;\n>  \tuint32_t width;\n>  \tuint32_t height;\n> +\n> +\tconst std::string toString() const;\n>  };\n>  \n>  class V4L2Subdevice : protected Loggable\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index a88a5f5ff036..0bdcfc1d3c8f 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -6,6 +6,8 @@\n>   */\n>  \n>  #include <fcntl.h>\n> +#include <iomanip>\n> +#include <sstream>\n>  #include <string.h>\n>  #include <sys/ioctl.h>\n>  #include <sys/mman.h>\n> @@ -223,6 +225,22 @@ LOG_DEFINE_CATEGORY(V4L2)\n>   * \\brief The number of valid data planes\n>   */\n>  \n> +/**\n> + * \\brief Assemble and return a string describing the format\n> + *\n> + * \\return A string describing the V4L2DeviceFormat\n> + */\n> +const std::string V4L2DeviceFormat::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) << fourcc << \" planes: \" << planesCount;\n> +\n> +\treturn ss.str();\n> +}\n> +\n>  /**\n>   * \\class V4L2Device\n>   * \\brief V4L2Device object and API\n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index 5f58904bf9e6..7c56ba3ba510 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -6,6 +6,8 @@\n>   */\n>  \n>  #include <fcntl.h>\n> +#include <iomanip>\n> +#include <sstream>\n>  #include <string.h>\n>  #include <sys/ioctl.h>\n>  #include <unistd.h>\n> @@ -69,6 +71,22 @@ LOG_DEFINE_CATEGORY(V4L2Subdev)\n>   * \\brief The image height in pixels\n>   */\n>  \n> +/**\n> + * \\brief Assemble and return a string describing the format\n> + *\n> + * \\return A string describing the V4L2SubdeviceFormat\n> + */\n> +const std::string V4L2SubdeviceFormat::toString() const\n> +{\n> +\tstd::stringstream ss;\n> +\n> +\tss.fill(0);\n> +\tss << width << \"x\" << height << \" - 0x\" << std::hex << std::setw(8)\n> +\t   << mbus_code;\n\nSome time later, we can convert the mbus_codes and fourcc's to strings\ntoo. But I think that's a future todo for now.\n\n\n> +\n> +\treturn ss.str();\n> +}\n> +\n>  /**\n>   * \\class V4L2Subdevice\n>   * \\brief A V4L2 subdevice as exposed by the Linux kernel\n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D39ED600FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 12 Mar 2019 13:25:43 +0100 (CET)","from [192.168.0.21]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 24A7D33C;\n\tTue, 12 Mar 2019 13:25:43 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1552393543;\n\tbh=NSdj2eIQdhjTs9DwRypB0IZOUxzB0Cf9Tig7CAdCmr0=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=AXseglfD+MRLU8lbDV09pH3dJ5TtCfINQ7QXvV1xPI/YusXIrmd7rOyyOlnKONrer\n\tnudxGF4E+ZhMCVB1Z9DTtps/e0f4IG9JPDu//Oiq7rCDQp2wTJSUhP+8Qy7Oa1gsTa\n\tlRegp9pAxHmVSwa5MPqFE1No0o7K/r8Vx3tZVkdk=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Jacopo Mondi <jacopo@jmondi.org>, libcamera-devel@lists.libcamera.org","References":"<20190312121242.2253-1-jacopo@jmondi.org>\n\t<20190312121242.2253-2-jacopo@jmondi.org>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf\n\tKr2EAbc6tgg6DkAEHJb+1okosV09+0+TXywYvtEop/WUOWQ+zo+Y/OBd+8Ptgt1pDRyOBzL8\n\tRXa8ZqRf0Mwg75D+dKntZeJHzPRJyrlfQokngAAs4PaFt6UfS+ypMAF37T6CeDArQC41V3ko\n\tlPn1yMsVD0p+6i3DPvA/GPIksDC4owjnzVX9kM8Zc5Cx+XoAN0w5Eqo4t6qEVbuettxx55gq\n\t8K8FieAjgjMSxngo/HST8TpFeqI5nVeq0/lqtBRQKumuIqDg+Bkr4L1V/PSB6XgQcOdhtd36\n\tOe9X9dXB8YSNt7VjOcO7BTmFn/Z8r92mSAfHXpb07YJWJosQOQARAQABtDBLaWVyYW4gQmlu\n\tZ2hhbSA8a2llcmFuLmJpbmdoYW1AaWRlYXNvbmJvYXJkLmNvbT6JAkAEEwEKACoCGwMFCwkI\n\tBwIGFQgJCgsCBBYCAwECHgECF4ACGQEFAlnDk/gFCQeA/YsACgkQoR5GchCkYf3X5w/9EaZ7\n\tcnUcT6dxjxrcmmMnfFPoQA1iQXr/MXQJBjFWfxRUWYzjvUJb2D/FpA8FY7y+vksoJP7pWDL7\n\tQTbksdwzag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sbsRB8KNNvVXBOVNwko86rQqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<3f10d658-82fb-76e9-d19c-3cc1142b1304@ideasonboard.com>","Date":"Tue, 12 Mar 2019 12:25:39 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.4.0","MIME-Version":"1.0","In-Reply-To":"<20190312121242.2253-2-jacopo@jmondi.org>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v2 01/14] libcamera: formats: Add\n\ttoString() methods","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":"Tue, 12 Mar 2019 12:25:44 -0000"}},{"id":1050,"web_url":"https://patchwork.libcamera.org/comment/1050/","msgid":"<20190313165917.GN4722@pendragon.ideasonboard.com>","date":"2019-03-13T16:59:17","subject":"Re: [libcamera-devel] [PATCH v2 01/14] libcamera: formats: Add\n\ttoString() methods","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Tue, Mar 12, 2019 at 01:12:29PM +0100, Jacopo Mondi wrote:\n> Add toString() helpers to pretty print out a V4L2Device or V4L2Subdevice\n> format.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/include/v4l2_device.h    |  2 ++\n>  src/libcamera/include/v4l2_subdevice.h |  2 ++\n>  src/libcamera/v4l2_device.cpp          | 18 ++++++++++++++++++\n>  src/libcamera/v4l2_subdevice.cpp       | 18 ++++++++++++++++++\n>  4 files changed, 40 insertions(+)\n> \n> diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\n> index 5c379fac66dc..258deee8d461 100644\n> --- a/src/libcamera/include/v4l2_device.h\n> +++ b/src/libcamera/include/v4l2_device.h\n> @@ -100,6 +100,8 @@ public:\n>  \t\tuint32_t bpl;\n>  \t} planes[3];\n>  \tunsigned int planesCount;\n> +\n> +\tconst std::string toString() const;\n>  };\n>  \n>  class V4L2Device : protected Loggable\n> diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> index 1cc0fab73103..700e66bcddac 100644\n> --- a/src/libcamera/include/v4l2_subdevice.h\n> +++ b/src/libcamera/include/v4l2_subdevice.h\n> @@ -21,6 +21,8 @@ struct V4L2SubdeviceFormat {\n>  \tuint32_t mbus_code;\n>  \tuint32_t width;\n>  \tuint32_t height;\n> +\n> +\tconst std::string toString() const;\n>  };\n>  \n>  class V4L2Subdevice : protected Loggable\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index a88a5f5ff036..0bdcfc1d3c8f 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -6,6 +6,8 @@\n>   */\n>  \n>  #include <fcntl.h>\n> +#include <iomanip>\n> +#include <sstream>\n>  #include <string.h>\n>  #include <sys/ioctl.h>\n>  #include <sys/mman.h>\n> @@ -223,6 +225,22 @@ LOG_DEFINE_CATEGORY(V4L2)\n>   * \\brief The number of valid data planes\n>   */\n>  \n> +/**\n> + * \\brief Assemble and return a string describing the format\n> + *\n> + * \\return A string describing the V4L2DeviceFormat\n> + */\n> +const std::string V4L2DeviceFormat::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) << fourcc << \" planes: \" << planesCount;\n\nAs we standardize on a textual representation of a format, I think we\nshould consider how it should look like. Would it make sense to avoid\nspaces, in order to use the same representation as command line\narguments to the cam tool without the need for quotes ? Do we need to\nprint the number of planes ?\n\n> +\n> +\treturn ss.str();\n> +}\n> +\n>  /**\n>   * \\class V4L2Device\n>   * \\brief V4L2Device object and API\n> diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> index 5f58904bf9e6..7c56ba3ba510 100644\n> --- a/src/libcamera/v4l2_subdevice.cpp\n> +++ b/src/libcamera/v4l2_subdevice.cpp\n> @@ -6,6 +6,8 @@\n>   */\n>  \n>  #include <fcntl.h>\n> +#include <iomanip>\n> +#include <sstream>\n>  #include <string.h>\n>  #include <sys/ioctl.h>\n>  #include <unistd.h>\n> @@ -69,6 +71,22 @@ LOG_DEFINE_CATEGORY(V4L2Subdev)\n>   * \\brief The image height in pixels\n>   */\n>  \n> +/**\n> + * \\brief Assemble and return a string describing the format\n> + *\n> + * \\return A string describing the V4L2SubdeviceFormat\n> + */\n> +const std::string V4L2SubdeviceFormat::toString() const\n> +{\n> +\tstd::stringstream ss;\n> +\n> +\tss.fill(0);\n> +\tss << width << \"x\" << height << \" - 0x\" << std::hex << std::setw(8)\n> +\t   << mbus_code;\n\nSame question here regarding spaces. And I think you can limit the\nmbus_code to 4 digits.\n\n> +\n> +\treturn ss.str();\n> +}\n> +\n>  /**\n>   * \\class V4L2Subdevice\n>   * \\brief A V4L2 subdevice as exposed by the Linux kernel","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 9518E600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 13 Mar 2019 17:59:24 +0100 (CET)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 05DB75AA;\n\tWed, 13 Mar 2019 17:59:23 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1552496364;\n\tbh=+oLsxtUsnDOP5mD7yNrSRTL291QG1l1frp0VxWE4nIQ=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=VVZGPgBBV7TYYL+reSiNa3xNuj7svT+eFiX122GolUTby3AW4QPLINMb2KzX1b/41\n\trK7Uw90W1qYsh21eSzdA/6w2Gjqw5qezvrRjx1tW7BBRd+i61bxBuc6W5DEmP7QGCE\n\tCNFxMd4o4sBhEDC1MEFo/kLCGPnKmhFirP+2js9c=","Date":"Wed, 13 Mar 2019 18:59:17 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190313165917.GN4722@pendragon.ideasonboard.com>","References":"<20190312121242.2253-1-jacopo@jmondi.org>\n\t<20190312121242.2253-2-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190312121242.2253-2-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 01/14] libcamera: formats: Add\n\ttoString() methods","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":"Wed, 13 Mar 2019 16:59:24 -0000"}},{"id":1053,"web_url":"https://patchwork.libcamera.org/comment/1053/","msgid":"<20190314092632.x67oyggvojgrcxbj@uno.localdomain>","date":"2019-03-14T09:26:32","subject":"Re: [libcamera-devel] [PATCH v2 01/14] libcamera: formats: Add\n\ttoString() methods","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"HI Laurent,\n\nOn Wed, Mar 13, 2019 at 06:59:17PM +0200, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> Thank you for the patch.\n>\n> On Tue, Mar 12, 2019 at 01:12:29PM +0100, Jacopo Mondi wrote:\n> > Add toString() helpers to pretty print out a V4L2Device or V4L2Subdevice\n> > format.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  src/libcamera/include/v4l2_device.h    |  2 ++\n> >  src/libcamera/include/v4l2_subdevice.h |  2 ++\n> >  src/libcamera/v4l2_device.cpp          | 18 ++++++++++++++++++\n> >  src/libcamera/v4l2_subdevice.cpp       | 18 ++++++++++++++++++\n> >  4 files changed, 40 insertions(+)\n> >\n> > diff --git a/src/libcamera/include/v4l2_device.h b/src/libcamera/include/v4l2_device.h\n> > index 5c379fac66dc..258deee8d461 100644\n> > --- a/src/libcamera/include/v4l2_device.h\n> > +++ b/src/libcamera/include/v4l2_device.h\n> > @@ -100,6 +100,8 @@ public:\n> >  \t\tuint32_t bpl;\n> >  \t} planes[3];\n> >  \tunsigned int planesCount;\n> > +\n> > +\tconst std::string toString() const;\n> >  };\n> >\n> >  class V4L2Device : protected Loggable\n> > diff --git a/src/libcamera/include/v4l2_subdevice.h b/src/libcamera/include/v4l2_subdevice.h\n> > index 1cc0fab73103..700e66bcddac 100644\n> > --- a/src/libcamera/include/v4l2_subdevice.h\n> > +++ b/src/libcamera/include/v4l2_subdevice.h\n> > @@ -21,6 +21,8 @@ struct V4L2SubdeviceFormat {\n> >  \tuint32_t mbus_code;\n> >  \tuint32_t width;\n> >  \tuint32_t height;\n> > +\n> > +\tconst std::string toString() const;\n> >  };\n> >\n> >  class V4L2Subdevice : protected Loggable\n> > diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> > index a88a5f5ff036..0bdcfc1d3c8f 100644\n> > --- a/src/libcamera/v4l2_device.cpp\n> > +++ b/src/libcamera/v4l2_device.cpp\n> > @@ -6,6 +6,8 @@\n> >   */\n> >\n> >  #include <fcntl.h>\n> > +#include <iomanip>\n> > +#include <sstream>\n> >  #include <string.h>\n> >  #include <sys/ioctl.h>\n> >  #include <sys/mman.h>\n> > @@ -223,6 +225,22 @@ LOG_DEFINE_CATEGORY(V4L2)\n> >   * \\brief The number of valid data planes\n> >   */\n> >\n> > +/**\n> > + * \\brief Assemble and return a string describing the format\n> > + *\n> > + * \\return A string describing the V4L2DeviceFormat\n> > + */\n> > +const std::string V4L2DeviceFormat::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) << fourcc << \" planes: \" << planesCount;\n>\n> As we standardize on a textual representation of a format, I think we\n> should consider how it should look like. Would it make sense to avoid\n> spaces, in order to use the same representation as command line\n> arguments to the cam tool without the need for quotes ? Do we need to\n> print the number of planes ?\n>\n\nHow would you re-use the argument? The cam tool options syntax is\n-f width=1920,height=1080\n\nWould you print out the format with 'width' and 'heigh' ?\n\nThanks\n  j\n\n> > +\n> > +\treturn ss.str();\n> > +}\n> > +\n> >  /**\n> >   * \\class V4L2Device\n> >   * \\brief V4L2Device object and API\n> > diff --git a/src/libcamera/v4l2_subdevice.cpp b/src/libcamera/v4l2_subdevice.cpp\n> > index 5f58904bf9e6..7c56ba3ba510 100644\n> > --- a/src/libcamera/v4l2_subdevice.cpp\n> > +++ b/src/libcamera/v4l2_subdevice.cpp\n> > @@ -6,6 +6,8 @@\n> >   */\n> >\n> >  #include <fcntl.h>\n> > +#include <iomanip>\n> > +#include <sstream>\n> >  #include <string.h>\n> >  #include <sys/ioctl.h>\n> >  #include <unistd.h>\n> > @@ -69,6 +71,22 @@ LOG_DEFINE_CATEGORY(V4L2Subdev)\n> >   * \\brief The image height in pixels\n> >   */\n> >\n> > +/**\n> > + * \\brief Assemble and return a string describing the format\n> > + *\n> > + * \\return A string describing the V4L2SubdeviceFormat\n> > + */\n> > +const std::string V4L2SubdeviceFormat::toString() const\n> > +{\n> > +\tstd::stringstream ss;\n> > +\n> > +\tss.fill(0);\n> > +\tss << width << \"x\" << height << \" - 0x\" << std::hex << std::setw(8)\n> > +\t   << mbus_code;\n>\n> Same question here regarding spaces. And I think you can limit the\n> mbus_code to 4 digits.\n>\n> > +\n> > +\treturn ss.str();\n> > +}\n> > +\n> >  /**\n> >   * \\class V4L2Subdevice\n> >   * \\brief A V4L2 subdevice as exposed by the Linux kernel\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net\n\t[217.70.183.201])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 2E90A600FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Mar 2019 10:26:00 +0100 (CET)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 8FC321BF210;\n\tThu, 14 Mar 2019 09:25:59 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Thu, 14 Mar 2019 10:26:32 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190314092632.x67oyggvojgrcxbj@uno.localdomain>","References":"<20190312121242.2253-1-jacopo@jmondi.org>\n\t<20190312121242.2253-2-jacopo@jmondi.org>\n\t<20190313165917.GN4722@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"un7tvzofos3q3kbv\"","Content-Disposition":"inline","In-Reply-To":"<20190313165917.GN4722@pendragon.ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v2 01/14] libcamera: formats: Add\n\ttoString() methods","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":"Thu, 14 Mar 2019 09:26:00 -0000"}}]