[{"id":11048,"web_url":"https://patchwork.libcamera.org/comment/11048/","msgid":"<20200701162349.GE2399385@oden.dyn.berto.se>","date":"2020-07-01T16:23:49","subject":"Re: [libcamera-devel] [PATCH 03/15] libcamera: ipu3: cio2: Report\n\tformat and sizes","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 2020-07-01 14:30:24 +0200, Jacopo Mondi wrote:\n> Add two methods to the CIO2Device class to retrieve all the supported\n> PixelFormats and sizes.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/pipeline/ipu3/cio2.cpp | 43 +++++++++++++++++++++++++++-\n>  src/libcamera/pipeline/ipu3/cio2.h   |  7 +++++\n>  2 files changed, 49 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> index 2ec8fcb42d92..b34194c5097f 100644\n> --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> @@ -33,7 +33,7 @@ static const std::map<uint32_t, PixelFormat> mbusCodesToPixelFormat = {\n>  } /* namespace */\n>  \n>  CIO2Device::CIO2Device()\n> -\t: sensor_(nullptr), csi2_(nullptr), output_(nullptr)\n> +\t: sensor_(nullptr), csi2_(nullptr), output_(nullptr), initialized_(false)\n>  {\n>  }\n>  \n> @@ -44,6 +44,45 @@ CIO2Device::~CIO2Device()\n>  \tdelete sensor_;\n>  }\n>  \n> +/**\n> + * \\brief Retrieve the list of supported PixelFormats\n> + *\n> + * Retrieve the list of supported pixel formats by matching the sensor produced\n> + * media bus codes with the formats supported by the CIO2 unit.\n> + *\n> + * \\return The list of supported PixelFormat\n> + */\n> +std::vector<PixelFormat> CIO2Device::formats() const\n> +{\n> +\tif (!initialized_)\n> +\t\treturn {};\n\nWould it not be neater to check if sensor_ is null or not?\n\n> +\n> +\tstd::vector<PixelFormat> formats;\n> +\tfor (unsigned int code : sensor_->mbusCodes()) {\n> +\t\tauto it = mbusCodesToPixelFormat.find(code);\n> +\t\tif (it != mbusCodesToPixelFormat.end())\n> +\t\t\tformats.push_back(it->second);\n> +\t}\n> +\n> +\treturn formats;\n> +}\n> +\n> +/**\n> + * \\brief Retrieve the list of supported size ranges\n> + * \\return The list of supported SizeRange\n> + */\n> +std::vector<SizeRange> CIO2Device::sizes() const\n> +{\n> +\tif (!initialized_)\n> +\t\treturn {};\n> +\n> +\tstd::vector<SizeRange> sizes;\n> +\tfor (const Size &size : sensor_->sizes())\n> +\t\tsizes.emplace_back(size, size);\n> +\n> +\treturn sizes;\n> +}\n> +\n>  /**\n>   * \\brief Initialize components of the CIO2 device with \\a index\n>   * \\param[in] media The CIO2 media device\n> @@ -127,6 +166,8 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>  \n>  \toutput_->bufferReady.connect(this, &CIO2Device::cio2BufferReady);\n>  \n> +\tinitialized_ = true;\n> +\n>  \treturn 0;\n>  }\n>  \n> diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\n> index dc764b101f11..7e793e8450f5 100644\n> --- a/src/libcamera/pipeline/ipu3/cio2.h\n> +++ b/src/libcamera/pipeline/ipu3/cio2.h\n> @@ -18,7 +18,9 @@ namespace libcamera {\n>  class CameraSensor;\n>  class FrameBuffer;\n>  class MediaDevice;\n> +class PixelFormat;\n>  class Request;\n> +class SizeRange;\n>  class V4L2DeviceFormat;\n>  class V4L2Subdevice;\n>  class V4L2VideoDevice;\n> @@ -33,6 +35,9 @@ public:\n>  \tCIO2Device();\n>  \t~CIO2Device();\n>  \n> +\tstd::vector<PixelFormat> formats() const;\n> +\tstd::vector<SizeRange> sizes() const;\n> +\n>  \tint init(const MediaDevice *media, unsigned int index);\n>  \tint configure(const Size &size, V4L2DeviceFormat *outputFormat);\n>  \n> @@ -61,6 +66,8 @@ private:\n>  \n>  \tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n>  \tstd::queue<FrameBuffer *> availableBuffers_;\n> +\n> +\tbool initialized_;\n>  };\n>  \n>  } /* namespace libcamera */\n> -- \n> 2.27.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":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id BA104BE905\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  1 Jul 2020 16:23:52 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 89F3660C53;\n\tWed,  1 Jul 2020 18:23:52 +0200 (CEST)","from mail-lj1-x241.google.com (mail-lj1-x241.google.com\n\t[IPv6:2a00:1450:4864:20::241])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D8095609A9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  1 Jul 2020 18:23:50 +0200 (CEST)","by mail-lj1-x241.google.com with SMTP id s1so27866521ljo.0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 01 Jul 2020 09:23:50 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tn25sm1312466lji.28.2020.07.01.09.23.49\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 01 Jul 2020 09:23:49 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"Zm7AhYuC\"; dkim-atps=neutral","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\tbh=jupdqJLwDbSG3cD31Gu7qKB4wqBg7xLz+l45fWOyXoI=;\n\tb=Zm7AhYuC+dhejc6T56R3mEiq0aQmKLWXXD0PmYdMz6ROQ6soBl4gMwnSGYnIzEGmht\n\tEWy/2t7tFo1mrGzkgMBI4I/lNJE/SGmyg4NSN1ZJCcqxkb5SN/x/jCOs/Cge1SR8bOD6\n\t3OxNxtmeciaq3hTLOcBj0droD2+umxP3/JYVAVhOXFbSxc1Q2oXAuoBCA6nmHri5hEOc\n\t1MKUawkLcJgYHGktf5tSslnMakRyKff5xSnpd++apCh0PSsU7jcrka8uNQj0IPDt7yUt\n\t4NBK6FPIXMqtb2bAbWCwhE1qCwtZB+PKa+jh3WbJfMzgax3jc39gjQ7DJUliEWoDgiEy\n\tKLWg==","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;\n\tbh=jupdqJLwDbSG3cD31Gu7qKB4wqBg7xLz+l45fWOyXoI=;\n\tb=HiKCqg7d5CWkGufF2E5yIlI6U2uiavYE3z0s7qEeLfaKoS980lfdQaVj1Hpk+qbDKf\n\tzFVzkNSFF9fg8SmFT5JtGJphN++iHVtQcl4hconMdwJtAqa/ki3ztzI7kvzrW1f4xsRR\n\tsphYUj6qlOhbrsHKXRWeLssV5/dKTMaiSVXLHxC8mIcgn94WjkEWEbfocbS9wt/d7jQE\n\t5ZNJyCT7mCr44SGtXqAQ42OrGc2n7GP/1pyuDaaHDSxQuIUyc56ApE07r8sNZJzwFJT0\n\t8XbmvECIy/AznP0GZsSh1vcyDr7csZjG9DiWOuVmGhV/MMj9JahTgdoraGp5I/TCQUZz\n\tZqhg==","X-Gm-Message-State":"AOAM53324DZVZ41O/VadWKhRgBZg9AIt02wdU4l/ZGryDlz8qHU3QIIl\n\tWatPk8B2mMWIJp34EN9WaIEGrw==","X-Google-Smtp-Source":"ABdhPJx2bLUbseT24UHccTqAHzl4CBN7iIL9RHcDeByLqaW/AtWDfw2XgIKMq4sAwK0eDwUwGY4WDg==","X-Received":"by 2002:a2e:9cd8:: with SMTP id\n\tg24mr14335916ljj.245.1593620630246; \n\tWed, 01 Jul 2020 09:23:50 -0700 (PDT)","Date":"Wed, 1 Jul 2020 18:23:49 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200701162349.GE2399385@oden.dyn.berto.se>","References":"<20200701123036.51922-1-jacopo@jmondi.org>\n\t<20200701123036.51922-4-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200701123036.51922-4-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH 03/15] libcamera: ipu3: cio2: Report\n\tformat and sizes","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11065,"web_url":"https://patchwork.libcamera.org/comment/11065/","msgid":"<20200702073419.jy5dqdx2uaoex4cn@uno.localdomain>","date":"2020-07-02T07:34:19","subject":"Re: [libcamera-devel] [PATCH 03/15] libcamera: ipu3: cio2: Report\n\tformat and sizes","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Niklas,\n\nOn Wed, Jul 01, 2020 at 06:23:49PM +0200, Niklas Söderlund wrote:\n> Hi Jacopo,\n>\n> Thanks for your work.\n>\n> On 2020-07-01 14:30:24 +0200, Jacopo Mondi wrote:\n> > Add two methods to the CIO2Device class to retrieve all the supported\n> > PixelFormats and sizes.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  src/libcamera/pipeline/ipu3/cio2.cpp | 43 +++++++++++++++++++++++++++-\n> >  src/libcamera/pipeline/ipu3/cio2.h   |  7 +++++\n> >  2 files changed, 49 insertions(+), 1 deletion(-)\n> >\n> > diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> > index 2ec8fcb42d92..b34194c5097f 100644\n> > --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> > @@ -33,7 +33,7 @@ static const std::map<uint32_t, PixelFormat> mbusCodesToPixelFormat = {\n> >  } /* namespace */\n> >\n> >  CIO2Device::CIO2Device()\n> > -\t: sensor_(nullptr), csi2_(nullptr), output_(nullptr)\n> > +\t: sensor_(nullptr), csi2_(nullptr), output_(nullptr), initialized_(false)\n> >  {\n> >  }\n> >\n> > @@ -44,6 +44,45 @@ CIO2Device::~CIO2Device()\n> >  \tdelete sensor_;\n> >  }\n> >\n> > +/**\n> > + * \\brief Retrieve the list of supported PixelFormats\n> > + *\n> > + * Retrieve the list of supported pixel formats by matching the sensor produced\n> > + * media bus codes with the formats supported by the CIO2 unit.\n> > + *\n> > + * \\return The list of supported PixelFormat\n> > + */\n> > +std::vector<PixelFormat> CIO2Device::formats() const\n> > +{\n> > +\tif (!initialized_)\n> > +\t\treturn {};\n>\n> Would it not be neater to check if sensor_ is null or not?\n>\n\nAh yes, it would, and it would save the initialized_ flag.\nThanks for suggestion.\n\n> > +\n> > +\tstd::vector<PixelFormat> formats;\n> > +\tfor (unsigned int code : sensor_->mbusCodes()) {\n> > +\t\tauto it = mbusCodesToPixelFormat.find(code);\n> > +\t\tif (it != mbusCodesToPixelFormat.end())\n> > +\t\t\tformats.push_back(it->second);\n> > +\t}\n> > +\n> > +\treturn formats;\n> > +}\n> > +\n> > +/**\n> > + * \\brief Retrieve the list of supported size ranges\n> > + * \\return The list of supported SizeRange\n> > + */\n> > +std::vector<SizeRange> CIO2Device::sizes() const\n> > +{\n> > +\tif (!initialized_)\n> > +\t\treturn {};\n> > +\n> > +\tstd::vector<SizeRange> sizes;\n> > +\tfor (const Size &size : sensor_->sizes())\n> > +\t\tsizes.emplace_back(size, size);\n> > +\n> > +\treturn sizes;\n> > +}\n> > +\n> >  /**\n> >   * \\brief Initialize components of the CIO2 device with \\a index\n> >   * \\param[in] media The CIO2 media device\n> > @@ -127,6 +166,8 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n> >\n> >  \toutput_->bufferReady.connect(this, &CIO2Device::cio2BufferReady);\n> >\n> > +\tinitialized_ = true;\n> > +\n> >  \treturn 0;\n> >  }\n> >\n> > diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\n> > index dc764b101f11..7e793e8450f5 100644\n> > --- a/src/libcamera/pipeline/ipu3/cio2.h\n> > +++ b/src/libcamera/pipeline/ipu3/cio2.h\n> > @@ -18,7 +18,9 @@ namespace libcamera {\n> >  class CameraSensor;\n> >  class FrameBuffer;\n> >  class MediaDevice;\n> > +class PixelFormat;\n> >  class Request;\n> > +class SizeRange;\n> >  class V4L2DeviceFormat;\n> >  class V4L2Subdevice;\n> >  class V4L2VideoDevice;\n> > @@ -33,6 +35,9 @@ public:\n> >  \tCIO2Device();\n> >  \t~CIO2Device();\n> >\n> > +\tstd::vector<PixelFormat> formats() const;\n> > +\tstd::vector<SizeRange> sizes() const;\n> > +\n> >  \tint init(const MediaDevice *media, unsigned int index);\n> >  \tint configure(const Size &size, V4L2DeviceFormat *outputFormat);\n> >\n> > @@ -61,6 +66,8 @@ private:\n> >\n> >  \tstd::vector<std::unique_ptr<FrameBuffer>> buffers_;\n> >  \tstd::queue<FrameBuffer *> availableBuffers_;\n> > +\n> > +\tbool initialized_;\n> >  };\n> >\n> >  } /* namespace libcamera */\n> > --\n> > 2.27.0\n> >\n> > _______________________________________________\n> > libcamera-devel mailing list\n> > libcamera-devel@lists.libcamera.org\n> > https://lists.libcamera.org/listinfo/libcamera-devel\n>\n> --\n> Regards,\n> Niklas Söderlund","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id B140DBE905\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  2 Jul 2020 07:30:49 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8C19360C56;\n\tThu,  2 Jul 2020 09:30:49 +0200 (CEST)","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 5F620603AE\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  2 Jul 2020 09:30:48 +0200 (CEST)","from uno.localdomain (93-34-118-233.ip49.fastwebnet.it\n\t[93.34.118.233]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 7B787C000C;\n\tThu,  2 Jul 2020 07:30:47 +0000 (UTC)"],"X-Originating-IP":"93.34.118.233","Date":"Thu, 2 Jul 2020 09:34:19 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Message-ID":"<20200702073419.jy5dqdx2uaoex4cn@uno.localdomain>","References":"<20200701123036.51922-1-jacopo@jmondi.org>\n\t<20200701123036.51922-4-jacopo@jmondi.org>\n\t<20200701162349.GE2399385@oden.dyn.berto.se>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200701162349.GE2399385@oden.dyn.berto.se>","Subject":"Re: [libcamera-devel] [PATCH 03/15] libcamera: ipu3: cio2: Report\n\tformat and sizes","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]