[{"id":11281,"web_url":"https://patchwork.libcamera.org/comment/11281/","msgid":"<20200709131448.GI3875643@oden.dyn.berto.se>","date":"2020-07-09T13:14:48","subject":"Re: [libcamera-devel] [PATCH v2 04/20] libcamera: ipu3: cio2:\n\tReport format 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-09 10:41:12 +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 | 40 ++++++++++++++++++++++++++++\n>  src/libcamera/pipeline/ipu3/cio2.h   |  5 ++++\n>  2 files changed, 45 insertions(+)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> index f5a01dd3ec1f..525513317604 100644\n> --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> @@ -9,6 +9,7 @@\n>  \n>  #include <linux/media-bus-format.h>\n>  \n> +#include <libcamera/geometry.h>\n>  #include <libcamera/formats.h>\n>  #include <libcamera/stream.h>\n>  \n> @@ -43,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\nIn practice would this function not always return a vector with a single \nelement? As the CIO2 only supports the IPU3 specific memory layout that \nuses 10-bits samples. That means the only difference between the \nsupported formats is the RGB mask of the sensor. The sensor can not \nchange its RGB mask (right?).\n\n> +{\n> +\tif (!sensor_)\n> +\t\treturn {};\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 (!sensor_)\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> diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\n> index 4fd949f8e513..f905d97fa79d 100644\n> --- a/src/libcamera/pipeline/ipu3/cio2.h\n> +++ b/src/libcamera/pipeline/ipu3/cio2.h\n> @@ -20,7 +20,9 @@ namespace libcamera {\n>  class CameraSensor;\n>  class FrameBuffer;\n>  class MediaDevice;\n> +class PixelFormat;\n>  class Request;\n> +class SizeRange;\n>  class V4L2Subdevice;\n>  struct Size;\n>  struct StreamConfiguration;\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> -- \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 90762BD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  9 Jul 2020 13:14:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 290DF61210;\n\tThu,  9 Jul 2020 15:14:51 +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 3923261184\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  9 Jul 2020 15:14:50 +0200 (CEST)","by mail-lj1-x241.google.com with SMTP id d17so2341950ljl.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 09 Jul 2020 06:14: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\to1sm909862lfi.92.2020.07.09.06.14.48\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 09 Jul 2020 06:14:48 -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=\"seVTTWUg\"; 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=ZwSgqJ4XCNr79eGwxbY04+afrsWgbB/n2f8WuEjs2/Y=;\n\tb=seVTTWUg+p6auIviu3e4oF/jRGYCCAark9ygtNMk6Ot1sPD/SRqJxC4IMcq7Z+fXJY\n\tZXte/SLZWkN3RQ3vQOJUIfTVUr65CyGcp7LXjmXagBg9d7GTdRBX2CRoqohrrMah90Qp\n\tWhxSl9aO+swp5Jvlgg66neV1TbmyTgXXUgRJZbJcEmvMmFPDKb12lGulNBzM4OdHK1r1\n\tt6BIRQdRGovgz909yZX6hBNXjMfEDbN3SA0Ou/Fr0feKO5LsPzgD/TNx5KGWFcpiIjd1\n\tO3nYvD6326NTGOvlHT9ufRE/KMEXAQiYlMIr9GtTNp0xy7WkTIbnYBjb0YPglGYCyTs0\n\tyypA==","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=ZwSgqJ4XCNr79eGwxbY04+afrsWgbB/n2f8WuEjs2/Y=;\n\tb=OwaWhHg17RefPgM22ObYQWjwfhHEDvzI6Tab6eiZOPUvnnghKXL3CljraWbkh0vqid\n\tF73AnZqQiyBY7Z3EMF7DJy7SeyXL1SO/xd1ZKRuFu+GyjMTOGxd5dudbtHEyjrV4QNkw\n\t3oXTjmapbuozJnpVzEvxJqefWPvUuZ8l/pGrRiaMq3VOL1etk4jf0yoybFR8ZzQU96v6\n\tvshO03y2k0On6ga9qjv/k7Vg9p/BM3rI4ysF8j5i86/DujhhpuH6iNMWMqDGjvIOCNbT\n\tMS3FoT3AFmKUaOOoYKGVGz2CPN9HSeUicWYPILFLMdGv/1VCm+fOtsdxK4jNOrFuiyFv\n\toJ5g==","X-Gm-Message-State":"AOAM533o8uYhcED3bLP+s6ecnYGuo/sXyvU59lL8GznS2+uitjbJvr+Z\n\tO0qPBm84Jh20cIXbpyVBv1e7djDsNKU=","X-Google-Smtp-Source":"ABdhPJyPO+eDQte9Z841XCx1RTldGJNtw5eCdAVGU9w/Wqzf/Ti+fHEJDsxL3DpFmF7XReRGnCEyNQ==","X-Received":"by 2002:a05:651c:1117:: with SMTP id\n\td23mr37998013ljo.277.1594300489566; \n\tThu, 09 Jul 2020 06:14:49 -0700 (PDT)","Date":"Thu, 9 Jul 2020 15:14:48 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Jacopo Mondi <jacopo@jmondi.org>","Message-ID":"<20200709131448.GI3875643@oden.dyn.berto.se>","References":"<20200709084128.5316-1-jacopo@jmondi.org>\n\t<20200709084128.5316-5-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200709084128.5316-5-jacopo@jmondi.org>","Subject":"Re: [libcamera-devel] [PATCH v2 04/20] libcamera: ipu3: cio2:\n\tReport format 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":11304,"web_url":"https://patchwork.libcamera.org/comment/11304/","msgid":"<20200710070603.wmlw6z7azzwrsqwi@uno.localdomain>","date":"2020-07-10T07:06:03","subject":"Re: [libcamera-devel] [PATCH v2 04/20] libcamera: ipu3: cio2:\n\tReport format 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 Thu, Jul 09, 2020 at 03:14:48PM +0200, Niklas Söderlund wrote:\n> Hi Jacopo,\n>\n> Thanks for your work.\n>\n> On 2020-07-09 10:41:12 +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 | 40 ++++++++++++++++++++++++++++\n> >  src/libcamera/pipeline/ipu3/cio2.h   |  5 ++++\n> >  2 files changed, 45 insertions(+)\n> >\n> > diff --git a/src/libcamera/pipeline/ipu3/cio2.cpp b/src/libcamera/pipeline/ipu3/cio2.cpp\n> > index f5a01dd3ec1f..525513317604 100644\n> > --- a/src/libcamera/pipeline/ipu3/cio2.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/cio2.cpp\n> > @@ -9,6 +9,7 @@\n> >\n> >  #include <linux/media-bus-format.h>\n> >\n> > +#include <libcamera/geometry.h>\n> >  #include <libcamera/formats.h>\n> >  #include <libcamera/stream.h>\n> >\n> > @@ -43,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> In practice would this function not always return a vector with a single\n> element? As the CIO2 only supports the IPU3 specific memory layout that\n> uses 10-bits samples. That means the only difference between the\n> supported formats is the RGB mask of the sensor. The sensor can not\n> change its RGB mask (right?).\n\nWith RGB mask do you mean the color components order ? ie. SGBRG vs\nSBGGR ?\n\nIn that case, the components order might be changed by applying a\nvertical (horizontal too?) flip. Some sensor driver 'move' the\nselection area one colum to the left/top to maintain the field of view\ncausing the bayer patter order to be changed.\n\nIn example, from imx219 driver\n        /*\n         * The supported formats.\n         * This table MUST contain 4 entries per format, to cover the various flip\n         * combinations in the order\n         * - no flip\n         * - h flip\n         * - v flip\n         * - h&v flips\n         */\n        static const u32 codes[] = {\n                MEDIA_BUS_FMT_SRGGB10_1X10,\n                MEDIA_BUS_FMT_SGRBG10_1X10,\n                MEDIA_BUS_FMT_SGBRG10_1X10,\n                MEDIA_BUS_FMT_SBGGR10_1X10,\n\n                MEDIA_BUS_FMT_SRGGB8_1X8,\n                MEDIA_BUS_FMT_SGRBG8_1X8,\n                MEDIA_BUS_FMT_SGBRG8_1X8,\n                MEDIA_BUS_FMT_SBGGR8_1X8,\n        };\n\nI also presume some sensor allows you to contol the bayer components\nordering by moving the selection rectangle, without having to flip.\n\nIn any case, multiple RAW bayer formats might be reported by the\nsensor, so there's no guarantee the vector will have a single entry.\n\nThanks\n  j\n\n>\n> > +{\n> > +\tif (!sensor_)\n> > +\t\treturn {};\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 (!sensor_)\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> > diff --git a/src/libcamera/pipeline/ipu3/cio2.h b/src/libcamera/pipeline/ipu3/cio2.h\n> > index 4fd949f8e513..f905d97fa79d 100644\n> > --- a/src/libcamera/pipeline/ipu3/cio2.h\n> > +++ b/src/libcamera/pipeline/ipu3/cio2.h\n> > @@ -20,7 +20,9 @@ namespace libcamera {\n> >  class CameraSensor;\n> >  class FrameBuffer;\n> >  class MediaDevice;\n> > +class PixelFormat;\n> >  class Request;\n> > +class SizeRange;\n> >  class V4L2Subdevice;\n> >  struct Size;\n> >  struct StreamConfiguration;\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> > --\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 6FC92BD792\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 10 Jul 2020 07:02:31 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0C07161392;\n\tFri, 10 Jul 2020 09:02:31 +0200 (CEST)","from relay11.mail.gandi.net (relay11.mail.gandi.net\n\t[217.70.178.231])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 152EA603A9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 10 Jul 2020 09:02:30 +0200 (CEST)","from uno.localdomain (host-95-245-128-189.retail.telecomitalia.it\n\t[95.245.128.189]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay11.mail.gandi.net (Postfix) with ESMTPSA id 2B490100002;\n\tFri, 10 Jul 2020 07:02:28 +0000 (UTC)"],"Date":"Fri, 10 Jul 2020 09:06:03 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Message-ID":"<20200710070603.wmlw6z7azzwrsqwi@uno.localdomain>","References":"<20200709084128.5316-1-jacopo@jmondi.org>\n\t<20200709084128.5316-5-jacopo@jmondi.org>\n\t<20200709131448.GI3875643@oden.dyn.berto.se>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200709131448.GI3875643@oden.dyn.berto.se>","Subject":"Re: [libcamera-devel] [PATCH v2 04/20] libcamera: ipu3: cio2:\n\tReport format 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>"}}]