[{"id":1186,"web_url":"https://patchwork.libcamera.org/comment/1186/","msgid":"<20190402104945.GJ23466@bigcity.dyn.berto.se>","date":"2019-04-02T10:49:45","subject":"Re: [libcamera-devel] [PATCH v5 01/19] libcamera: formats: Add\n\ttoString() methods","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Jacopo,\n\nThanks for your work.\n\nOn 2019-03-26 09:38:44 +0100, Jacopo Mondi wrote:\n> Add toString() helpers to pretty print out a V4L2Device or V4L2Subdevice\n> format.\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\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 889c63b3fb63..93d81517fedb 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;\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..cf873487b22c 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\n> +\t   << std::setw(4) << mbus_code;\n> +\n> +\treturn ss.str();\n> +}\n> +\n>  /**\n>   * \\class V4L2Subdevice\n>   * \\brief A V4L2 subdevice as exposed by the Linux kernel\n> -- \n> 2.21.0\n> \n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x242.google.com (mail-lj1-x242.google.com\n\t[IPv6:2a00:1450:4864:20::242])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 39899600FB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 12:49:47 +0200 (CEST)","by mail-lj1-x242.google.com with SMTP id f23so11135450ljc.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 02 Apr 2019 03:49:47 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tk5sm2648890lja.78.2019.04.02.03.49.45\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 02 Apr 2019 03:49:45 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=tUmoDIPu50YXnd/wXeQgpNzveHQmXgONxgknQHR1l7o=;\n\tb=DCf989bQ31+bCp+EcGSQ8n04TZ/49tejAbTxgdoyQ4RpEmFRlneDYr9bW1X0SJ4UKt\n\t80Qaa9vhYodXp6BtImdMOwHEjL1obVH+cgMyCYe3RsgQ0mQcueqRjc25RWqenaQKW3EG\n\t0ep74l0GHG2JjJc7PHqSptrf6u77UFVui/hgneli6XoqTbmJHnvOeVPHPcbuAYwoDJHM\n\tDuBI79xhNccWcj+C8/MUQ/AyLu0LaUad0vpCziLz2Ri8uYYGdxv7Av0/dM3uXP6y3aoT\n\t02FsNfRegOCnZTPLtrpIw3JGbSx7OmcbSSoIjuOA5x9mOheuiV10r0BjUMMr8PGLmU4H\n\tbCog==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=tUmoDIPu50YXnd/wXeQgpNzveHQmXgONxgknQHR1l7o=;\n\tb=QJb1ejZSpJkU6S9c0GmGszvrUixbWsCa3m+ko6ncW42C0rDwYWBEepw+V5RpNLzfmR\n\tZQmAPx+nz487eK5UMozPX67+0AEbxW63jp8rBCgV3+GGMbP+fWGZusUEhNDZYXiedoTW\n\tFbPITGv9dd0oIm0bbgb7lUIRpIacFiMPPBqfKIMom4giQc4jklu0wy/VfsggB0c1cOI4\n\t0lF1Tp2WMiU8QZAW8bFVT28Qcg+Gr/qRUwA4+iP6tKeMYWlNeeDFNYcZMuBwwfREjX59\n\tg9PpyUKgMl7cUP6RdB9iOTOwHQGPrIRTyLNy+LCFDM87/azqQAFxVfNzcnSXvcOPc2CL\n\tlgPg==","X-Gm-Message-State":"APjAAAWqSvA6EUVsoOkxn12spvnU+yGxcBRiRKcZk32U4RooHjH7mK0L\n\t72KJARgawhGI37U17bLkEYcBA/F/UfM=","X-Google-Smtp-Source":"APXvYqz5h5RoSPP/tCkLAyQ+0VJYTE9WY+rV7UzvlGydSJuYmbXS41+/4/V89K7q1OjA6PO3ngrjvQ==","X-Received":"by 2002:a2e:8192:: with SMTP id e18mr38160548ljg.6.1554202186370;\n\tTue, 02 Apr 2019 03:49:46 -0700 (PDT)","Date":"Tue, 2 Apr 2019 12:49:45 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190402104945.GJ23466@bigcity.dyn.berto.se>","References":"<20190326083902.26121-1-jacopo@jmondi.org>\n\t<20190326083902.26121-2-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190326083902.26121-2-jacopo@jmondi.org>","User-Agent":"Mutt/1.11.3 (2019-02-01)","Subject":"Re: [libcamera-devel] [PATCH v5 01/19] 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, 02 Apr 2019 10:49:47 -0000"}}]