[{"id":1895,"web_url":"https://patchwork.libcamera.org/comment/1895/","msgid":"<20190613170939.w3lagto7hi5tfkwr@uno.localdomain>","date":"2019-06-13T17:09:39","subject":"Re: [libcamera-devel] [PATCH v2 15/16] cam: Add --info option to\n\tprint information about stream(s)","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Wed, Jun 12, 2019 at 02:43:58AM +0200, Niklas Söderlund wrote:\n> Add a new option to the cam tool that prints information about the\n> configuration supplied by the user. If the option is specified,\n> information about the configuration is printed after the configuration\n> has been verified possibly adjusted by the camera.\n>\n\nSorry, I don't get it, how is cam supposed to be launched to print the\nstream informations?\n\nJust running\n$ cam -I\nsegfaults for me...\n\nI tried passing a few arguments, like some permutation of the\nfollowing:\n$ ./src/cam/cam -I width=1920,height=1080,role=viewfinder\nbut I still get a segfault...\n\nWhat am I doing wrong?\n\n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  src/cam/info.cpp    | 37 +++++++++++++++++++++++++++++++++++++\n>  src/cam/info.h      | 14 ++++++++++++++\n>  src/cam/main.cpp    |  6 ++++++\n>  src/cam/main.h      |  1 +\n>  src/cam/meson.build |  1 +\n>  5 files changed, 59 insertions(+)\n>  create mode 100644 src/cam/info.cpp\n>  create mode 100644 src/cam/info.h\n>\n> diff --git a/src/cam/info.cpp b/src/cam/info.cpp\n> new file mode 100644\n> index 0000000000000000..fe32ceb614e85794\n> --- /dev/null\n> +++ b/src/cam/info.cpp\n> @@ -0,0 +1,37 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * info.cpp - Display stream information\n> + */\n> +\n> +#include <iomanip>\n> +#include <iostream>\n> +\n> +#include \"info.h\"\n> +\n> +using namespace libcamera;\n> +\n> +int infoConfiguration(const libcamera::CameraConfiguration &config)\n> +{\n> +\tunsigned int index = 0;\n> +\tfor (const StreamConfiguration &cfg : config) {\n> +\t\tstd::cout << index << \": \" << cfg.toString() << std::endl;\n> +\n> +\t\tconst StreamFormats &formats = cfg.formats();\n> +\t\tfor (unsigned int pixelformat : formats.pixelformats()) {\n> +\t\t\tstd::cout << \" * Pixelformat: 0x\" << std::hex\n> +\t\t\t\t  << std::setw(8) << pixelformat << \" \"\n> +\t\t\t\t  << formats.range(pixelformat).toString()\n> +\t\t\t\t  << std::endl;\n> +\n> +\t\t\tfor (const Size &size : formats.sizes(pixelformat))\n> +\t\t\t\tstd::cout << \"  - \" << size.toString()\n> +\t\t\t\t\t  << std::endl;\n> +\t\t}\n> +\n> +\t\tindex++;\n> +\t}\n> +\n> +\treturn 0;\n> +}\n> diff --git a/src/cam/info.h b/src/cam/info.h\n> new file mode 100644\n> index 0000000000000000..d4b4fc7e73d261b6\n> --- /dev/null\n> +++ b/src/cam/info.h\n> @@ -0,0 +1,14 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * info.h - Displat stream information\n\ndisplay\n\n> + */\n> +#ifndef __CAM_INFO_H__\n> +#define __CAM_INFO_H__\n> +\n> +#include <libcamera/camera.h>\n> +\n> +int infoConfiguration(const libcamera::CameraConfiguration &config);\n> +\n> +#endif /* __CAM_INFO_H__ */\n> diff --git a/src/cam/main.cpp b/src/cam/main.cpp\n> index 191fef3a3c8a2b64..c0a5601316d1959d 100644\n> --- a/src/cam/main.cpp\n> +++ b/src/cam/main.cpp\n> @@ -13,6 +13,7 @@\n>\n>  #include \"capture.h\"\n>  #include \"event_loop.h\"\n> +#include \"info.h\"\n>  #include \"main.h\"\n>  #include \"options.h\"\n>\n> @@ -162,6 +163,8 @@ int CamApp::parseOptions(int argc, char *argv[])\n>  \t\t\t \"Set configuration of a camera stream\", \"stream\", true);\n>  \tparser.addOption(OptHelp, OptionNone, \"Display this help message\",\n>  \t\t\t \"help\");\n> +\tparser.addOption(OptInfo, OptionNone,\n> +\t\t\t \"Display information about stream(s)\", \"info\");\n>  \tparser.addOption(OptList, OptionNone, \"List all cameras\", \"list\");\n>\n>  \toptions_ = parser.parse(argc, argv);\n> @@ -259,6 +262,9 @@ int CamApp::run()\n>  \t\t\tstd::cout << \"- \" << cam->name() << std::endl;\n>  \t}\n>\n> +\tif (options_.isSet(OptInfo))\n> +\t\tinfoConfiguration(*config_.get());\n> +\n>  \tif (options_.isSet(OptCapture)) {\n>  \t\tCapture capture(camera_.get(), config_.get());\n>  \t\treturn capture.run(loop_, options_);\n> diff --git a/src/cam/main.h b/src/cam/main.h\n> index fff81b1f6c860b57..0997476bb335e446 100644\n> --- a/src/cam/main.h\n> +++ b/src/cam/main.h\n> @@ -12,6 +12,7 @@ enum {\n>  \tOptCapture = 'C',\n>  \tOptFile = 'F',\n>  \tOptHelp = 'h',\n> +\tOptInfo = 'I',\n>  \tOptList = 'l',\n>  \tOptStream = 's',\n>  };\n> diff --git a/src/cam/meson.build b/src/cam/meson.build\n> index 478346c59590631d..ee5b28421e4c1235 100644\n> --- a/src/cam/meson.build\n> +++ b/src/cam/meson.build\n> @@ -2,6 +2,7 @@ cam_sources = files([\n>      'buffer_writer.cpp',\n>      'capture.cpp',\n>      'event_loop.cpp',\n> +    'info.cpp',\n>      'main.cpp',\n>      'options.cpp',\n>  ])\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":"<jacopo@jmondi.org>","Received":["from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net\n\t[217.70.183.197])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BE50761B11\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Jun 2019 19:08:26 +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 relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 08D951C0008;\n\tThu, 13 Jun 2019 17:08:25 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Thu, 13 Jun 2019 19:09:39 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190613170939.w3lagto7hi5tfkwr@uno.localdomain>","References":"<20190612004359.15772-1-niklas.soderlund@ragnatech.se>\n\t<20190612004359.15772-16-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"aufcirdz62hhcnhq\"","Content-Disposition":"inline","In-Reply-To":"<20190612004359.15772-16-niklas.soderlund@ragnatech.se>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v2 15/16] cam: Add --info option to\n\tprint information about stream(s)","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, 13 Jun 2019 17:08:26 -0000"}},{"id":1899,"web_url":"https://patchwork.libcamera.org/comment/1899/","msgid":"<20190616131956.GD20468@bigcity.dyn.berto.se>","date":"2019-06-16T13:19:56","subject":"Re: [libcamera-devel] [PATCH v2 15/16] cam: Add --info option to\n\tprint information about stream(s)","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 feedback and great catch.\n\nOn 2019-06-13 19:09:39 +0200, Jacopo Mondi wrote:\n> Hi Niklas,\n> \n> On Wed, Jun 12, 2019 at 02:43:58AM +0200, Niklas Söderlund wrote:\n> > Add a new option to the cam tool that prints information about the\n> > configuration supplied by the user. If the option is specified,\n> > information about the configuration is printed after the configuration\n> > has been verified possibly adjusted by the camera.\n> >\n> \n> Sorry, I don't get it, how is cam supposed to be launched to print the\n> stream informations?\n> \n> Just running\n> $ cam -I\n> segfaults for me...\n> \n> I tried passing a few arguments, like some permutation of the\n> following:\n> $ ./src/cam/cam -I width=1920,height=1080,role=viewfinder\n> but I still get a segfault...\n\nThe idea is to print information about a camera\n\n    $ ./cam -c \"Venus USB2.0 Camera: Venus USB2\" -I\n    [123:40:14.524077360]   ERR IPAManager ipa_manager.cpp:96 Invalid path /usr/local/lib/libcamera for IPA modules: No such file or directory\n    [123:40:14.524167583]  WARN VIMC vimc.cpp:258 no matching IPA found\n    Using camera Venus USB2.0 Camera: Venus USB2\n    0: 1600x1200-0x47504a4d\n     * Pixelformat: 0x47504a4d (160x120)-(1600x1200)/(+0,+0)\n      - 160x120\n      - 176x144\n      - 320x240\n      - 352x288\n      - 640x480\n      - 800x600\n      - 1280x960\n      - 1280x1024\n      - 1600x1200\n     * Pixelformat: 0x56595559 (160x120)-(1600x1200)/(+0,+0)\n      - 160x120\n      - 176x144\n      - 320x240\n      - 352x288\n      - 640x480\n      - 800x600\n      - 1280x960\n      - 1280x1024\n      - 1600x120\n\nBut you finding this segfault was really nice, I will fix it for v3.\n\n> \n> What am I doing wrong?\n> \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> >  src/cam/info.cpp    | 37 +++++++++++++++++++++++++++++++++++++\n> >  src/cam/info.h      | 14 ++++++++++++++\n> >  src/cam/main.cpp    |  6 ++++++\n> >  src/cam/main.h      |  1 +\n> >  src/cam/meson.build |  1 +\n> >  5 files changed, 59 insertions(+)\n> >  create mode 100644 src/cam/info.cpp\n> >  create mode 100644 src/cam/info.h\n> >\n> > diff --git a/src/cam/info.cpp b/src/cam/info.cpp\n> > new file mode 100644\n> > index 0000000000000000..fe32ceb614e85794\n> > --- /dev/null\n> > +++ b/src/cam/info.cpp\n> > @@ -0,0 +1,37 @@\n> > +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> > +/*\n> > + * Copyright (C) 2019, Google Inc.\n> > + *\n> > + * info.cpp - Display stream information\n> > + */\n> > +\n> > +#include <iomanip>\n> > +#include <iostream>\n> > +\n> > +#include \"info.h\"\n> > +\n> > +using namespace libcamera;\n> > +\n> > +int infoConfiguration(const libcamera::CameraConfiguration &config)\n> > +{\n> > +\tunsigned int index = 0;\n> > +\tfor (const StreamConfiguration &cfg : config) {\n> > +\t\tstd::cout << index << \": \" << cfg.toString() << std::endl;\n> > +\n> > +\t\tconst StreamFormats &formats = cfg.formats();\n> > +\t\tfor (unsigned int pixelformat : formats.pixelformats()) {\n> > +\t\t\tstd::cout << \" * Pixelformat: 0x\" << std::hex\n> > +\t\t\t\t  << std::setw(8) << pixelformat << \" \"\n> > +\t\t\t\t  << formats.range(pixelformat).toString()\n> > +\t\t\t\t  << std::endl;\n> > +\n> > +\t\t\tfor (const Size &size : formats.sizes(pixelformat))\n> > +\t\t\t\tstd::cout << \"  - \" << size.toString()\n> > +\t\t\t\t\t  << std::endl;\n> > +\t\t}\n> > +\n> > +\t\tindex++;\n> > +\t}\n> > +\n> > +\treturn 0;\n> > +}\n> > diff --git a/src/cam/info.h b/src/cam/info.h\n> > new file mode 100644\n> > index 0000000000000000..d4b4fc7e73d261b6\n> > --- /dev/null\n> > +++ b/src/cam/info.h\n> > @@ -0,0 +1,14 @@\n> > +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> > +/*\n> > + * Copyright (C) 2019, Google Inc.\n> > + *\n> > + * info.h - Displat stream information\n> \n> display\n> \n> > + */\n> > +#ifndef __CAM_INFO_H__\n> > +#define __CAM_INFO_H__\n> > +\n> > +#include <libcamera/camera.h>\n> > +\n> > +int infoConfiguration(const libcamera::CameraConfiguration &config);\n> > +\n> > +#endif /* __CAM_INFO_H__ */\n> > diff --git a/src/cam/main.cpp b/src/cam/main.cpp\n> > index 191fef3a3c8a2b64..c0a5601316d1959d 100644\n> > --- a/src/cam/main.cpp\n> > +++ b/src/cam/main.cpp\n> > @@ -13,6 +13,7 @@\n> >\n> >  #include \"capture.h\"\n> >  #include \"event_loop.h\"\n> > +#include \"info.h\"\n> >  #include \"main.h\"\n> >  #include \"options.h\"\n> >\n> > @@ -162,6 +163,8 @@ int CamApp::parseOptions(int argc, char *argv[])\n> >  \t\t\t \"Set configuration of a camera stream\", \"stream\", true);\n> >  \tparser.addOption(OptHelp, OptionNone, \"Display this help message\",\n> >  \t\t\t \"help\");\n> > +\tparser.addOption(OptInfo, OptionNone,\n> > +\t\t\t \"Display information about stream(s)\", \"info\");\n> >  \tparser.addOption(OptList, OptionNone, \"List all cameras\", \"list\");\n> >\n> >  \toptions_ = parser.parse(argc, argv);\n> > @@ -259,6 +262,9 @@ int CamApp::run()\n> >  \t\t\tstd::cout << \"- \" << cam->name() << std::endl;\n> >  \t}\n> >\n> > +\tif (options_.isSet(OptInfo))\n> > +\t\tinfoConfiguration(*config_.get());\n> > +\n> >  \tif (options_.isSet(OptCapture)) {\n> >  \t\tCapture capture(camera_.get(), config_.get());\n> >  \t\treturn capture.run(loop_, options_);\n> > diff --git a/src/cam/main.h b/src/cam/main.h\n> > index fff81b1f6c860b57..0997476bb335e446 100644\n> > --- a/src/cam/main.h\n> > +++ b/src/cam/main.h\n> > @@ -12,6 +12,7 @@ enum {\n> >  \tOptCapture = 'C',\n> >  \tOptFile = 'F',\n> >  \tOptHelp = 'h',\n> > +\tOptInfo = 'I',\n> >  \tOptList = 'l',\n> >  \tOptStream = 's',\n> >  };\n> > diff --git a/src/cam/meson.build b/src/cam/meson.build\n> > index 478346c59590631d..ee5b28421e4c1235 100644\n> > --- a/src/cam/meson.build\n> > +++ b/src/cam/meson.build\n> > @@ -2,6 +2,7 @@ cam_sources = files([\n> >      'buffer_writer.cpp',\n> >      'capture.cpp',\n> >      'event_loop.cpp',\n> > +    'info.cpp',\n> >      'main.cpp',\n> >      'options.cpp',\n> >  ])\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-lf1-x141.google.com (mail-lf1-x141.google.com\n\t[IPv6:2a00:1450:4864:20::141])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9DAD56471B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 16 Jun 2019 15:19:58 +0200 (CEST)","by mail-lf1-x141.google.com with SMTP id b11so4630252lfa.5\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 16 Jun 2019 06:19:58 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tu18sm1617431ljj.32.2019.06.16.06.19.57\n\t(version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256);\n\tSun, 16 Jun 2019 06:19:57 -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=tR7mYb76RH6UeNEYT+AAnGVGwAtPHYxzzKtbfdL5wUY=;\n\tb=ShNaHCwev1szQtMN+Xd26dML/RoiS7GueJD82v9/STi5Jp6Kgg82EWYO1+t14LtTTp\n\tZ0v0HH4HhGhUTHYzaspCzQIuQapjOdwW5eSmknIQEgtUXmDl3o96yaR/weInPtQaMEXi\n\tO7VyC/MVvJwY4KM5IrZvPL3MYHM2sWU704hqT5aBw4bCGs66L6OWo9QwuuZBCNuLKZS9\n\toHL/yhtkUS/27KGlx0H9QWEe+FwcKIO4r0mLaCuw+laW6F9u/3gFd6ZZWuZCifwa0HmF\n\tIQpuLkkycVBqMzdCyTKHBhRk1IT7zfIN6gv4AAB9wb6xJBmE7KRPcn61M0S7mtRZXoaC\n\t6Suw==","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=tR7mYb76RH6UeNEYT+AAnGVGwAtPHYxzzKtbfdL5wUY=;\n\tb=rQnG4ORLUB2bb2NZIA3o/7xmCNwyD2x5Fd3TasUABytpJIRsNBNrcqO657mAUFg/BY\n\tQTfEDZJZC6SnXL7yqRydXmuBFTHObsqacqWi1GoqId2i0OtAviUhj8RP0F/2fj+bX1AA\n\tCFeuMI02Ykfvtc+FJSlfvxqUQx7+O8ihAqvGZ7oz2pTTugvxBbKoQMpwUJ1XzgmHur6L\n\tvtJGQn0MzngPSM4DSjZaqccxgZ9E/jelDdNiKu4mDmxvU2TGiiyhEjabKkAwzk14MaMQ\n\t/EIrOH+b9MnfyHaipaFfW69+p8Bg5wvsixwD0OIJdB0YBbUn0il1UwwG0L85tCZ+EzRy\n\ty3WA==","X-Gm-Message-State":"APjAAAUEG5Yo2waNY0C0NuIVvmowMqofWJvuazrDxFCn/1iwdwcqeQsJ\n\tGzoTppLNijY2X2COuLaOWZ14OQ==","X-Google-Smtp-Source":"APXvYqwLpj1keS5YjCPDSLeq4LqaK0GWcIGxnlSKW8wH/I9DjxZTrVp7FkY+51+OcptN98GqCsdF0A==","X-Received":"by 2002:ac2:46f9:: with SMTP id\n\tq25mr56783746lfo.181.1560691198078; \n\tSun, 16 Jun 2019 06:19:58 -0700 (PDT)","Date":"Sun, 16 Jun 2019 15:19:56 +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":"<20190616131956.GD20468@bigcity.dyn.berto.se>","References":"<20190612004359.15772-1-niklas.soderlund@ragnatech.se>\n\t<20190612004359.15772-16-niklas.soderlund@ragnatech.se>\n\t<20190613170939.w3lagto7hi5tfkwr@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190613170939.w3lagto7hi5tfkwr@uno.localdomain>","User-Agent":"Mutt/1.12.0 (2019-05-25)","Subject":"Re: [libcamera-devel] [PATCH v2 15/16] cam: Add --info option to\n\tprint information about stream(s)","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":"Sun, 16 Jun 2019 13:19:58 -0000"}}]