[{"id":1166,"web_url":"https://patchwork.libcamera.org/comment/1166/","msgid":"<20190402072717.GC4805@pendragon.ideasonboard.com>","date":"2019-04-02T07:27:17","subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera sizes","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 26, 2019 at 09:38:51AM +0100, Jacopo Mondi wrote:\n> When creating a camera, make sure a the image sensor provides images in\n> a format compatible with IPU3 CIO2 unit requirements and cache the\n> minimum and maximum camera sizes.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 56 +++++++++++++++++++++++++++-\n>  1 file changed, 54 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 55489c31df2d..d42c81273cc6 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -8,11 +8,14 @@\n>  #include <memory>\n>  #include <vector>\n>  \n> +#include <linux/media-bus-format.h>\n> +\n>  #include <libcamera/camera.h>\n>  #include <libcamera/request.h>\n>  #include <libcamera/stream.h>\n>  \n>  #include \"device_enumerator.h\"\n> +#include \"geometry.h\"\n>  #include \"log.h\"\n>  #include \"media_device.h\"\n>  #include \"pipeline_handler.h\"\n> @@ -24,6 +27,22 @@ namespace libcamera {\n>  \n>  LOG_DEFINE_CATEGORY(IPU3)\n>  \n> +static int mediaBusToCIO2Format(unsigned int code)\n> +{\n> +\tswitch (code) {\n> +\tcase MEDIA_BUS_FMT_SBGGR10_1X10:\n> +\t\treturn V4L2_PIX_FMT_IPU3_SBGGR10;\n> +\tcase MEDIA_BUS_FMT_SGBRG10_1X10:\n> +\t\treturn V4L2_PIX_FMT_IPU3_SGBRG10;\n> +\tcase MEDIA_BUS_FMT_SGRBG10_1X10:\n> +\t\treturn V4L2_PIX_FMT_IPU3_SGRBG10;\n> +\tcase MEDIA_BUS_FMT_SRGGB10_1X10:\n> +\t\treturn V4L2_PIX_FMT_IPU3_SRGGB10;\n> +\tdefault:\n> +\t\treturn -EINVAL;\n> +\t}\n> +}\n> +\n>  class PipelineHandlerIPU3 : public PipelineHandler\n>  {\n>  public:\n> @@ -70,6 +89,9 @@ private:\n>  \t\tV4L2Subdevice *sensor_;\n>  \n>  \t\tStream stream_;\n> +\n> +\t\t/* Maximum sizes and the mbus code used to produce them. */\n> +\t\tstd::pair<unsigned int, SizeRange> maxSizes_;\n\nThe use of std::pair here makes the code below use .first and .second,\nwhich are not very readable. I think it would be better to store the\npixel format and max size in two separate fields, of unsigned int and\nSizeRange types respectively. Or, now that I think about it, as you only\ncare about the maximum size, maybe adding a Size structure to geometry.h\nwould be a good idea.\n\n>  \t};\n>  \n>  \tIPU3CameraData *cameraData(const Camera *camera)\n> @@ -404,18 +426,48 @@ void PipelineHandlerIPU3::registerCameras()\n>  \t\tif (ret)\n>  \t\t\tcontinue;\n>  \n> -\t\tdata->cio2_->bufferReady.connect(data.get(), &IPU3CameraData::bufferReady);\n> -\n> +\t\t/*\n> +\t\t * Make sure the sensor produces at least one image format\n> +\t\t * compatible with IPU3 CIO2 requirements and cache the camera\n> +\t\t * maximum sizes.\n> +\t\t */\n>  \t\tdata->sensor_ = new V4L2Subdevice(sensor);\n>  \t\tret = data->sensor_->open();\n>  \t\tif (ret)\n>  \t\t\tcontinue;\n>  \n> +\t\tfor (auto it : data->sensor_->formats(0)) {\n> +\t\t\tint mbusCode = mediaBusToCIO2Format(it.first);\n> +\t\t\tif (mbusCode < 0)\n> +\t\t\t\tcontinue;\n> +\n> +\t\t\tfor (const SizeRange &size : it.second) {\n> +\t\t\t\tSizeRange &maxSize = data->maxSizes_.second;\n> +\n> +\t\t\t\tif (maxSize.maxWidth < size.maxWidth &&\n> +\t\t\t\t    maxSize.maxHeight < size.maxHeight) {\n> +\t\t\t\t\tmaxSize.maxWidth = size.maxWidth;\n> +\t\t\t\t\tmaxSize.maxHeight = size.maxHeight;\n> +\t\t\t\t\tdata->maxSizes_.first = mbusCode;\n> +\t\t\t\t}\n> +\t\t\t}\n> +\t\t}\n\nOne blank line ?\n\n> +\t\tif (data->maxSizes_.second.maxWidth == 0) {\n> +\t\t\tLOG(IPU3, Info)\n> +\t\t\t\t<< \"Sensor '\" << data->sensor_->entityName()\n> +\t\t\t\t<< \"' detected, but no supported image format \"\n> +\t\t\t\t<< \" found: skip camera creation\";\n> +\t\t\tcontinue;\n> +\t\t}\n> +\n>  \t\tdata->csi2_ = new V4L2Subdevice(csi2);\n>  \t\tret = data->csi2_->open();\n>  \t\tif (ret)\n>  \t\t\tcontinue;\n>  \n> +\t\tdata->cio2_->bufferReady.connect(data.get(),\n> +\t\t\t\t\t\t &IPU3CameraData::bufferReady);\n> +\n\nThis seems unrelated to this patch, is it needed ?\n\n>  \t\tregisterCamera(std::move(camera), std::move(data));\n>  \n>  \t\tLOG(IPU3, Info)","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 123C060DB3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 09:27:28 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 8767B2F9;\n\tTue,  2 Apr 2019 09:27:27 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1554190047;\n\tbh=DNXjGeWIcQuVsrKzMtuTPg/FDP6EcHTXPmYTZNemisw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=EUlv5ZQuJVIhOnYSafOa8nuakKh9hC4pONVFOGkR/dJe6r88MOZAADdREEbVIDtv3\n\tk1vw7yoPZH/tMLhlHpZ+luvSUPXa5cnwDSnsg8hA5nMxy47iUxbjXClvH05juuKlQ+\n\tgTG2z60Mx1BeX2yXaYqfR94MIMwrRZIHE2eaCfvg=","Date":"Tue, 2 Apr 2019 10:27:17 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190402072717.GC4805@pendragon.ideasonboard.com>","References":"<20190326083902.26121-1-jacopo@jmondi.org>\n\t<20190326083902.26121-9-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190326083902.26121-9-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera sizes","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 07:27:28 -0000"}},{"id":1172,"web_url":"https://patchwork.libcamera.org/comment/1172/","msgid":"<20190402082607.ju3dmke3zqv3m7rv@uno.localdomain>","date":"2019-04-02T08:26:07","subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera sizes","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Tue, Apr 02, 2019 at 10:27:17AM +0300, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> Thank you for the patch.\n>\n> On Tue, Mar 26, 2019 at 09:38:51AM +0100, Jacopo Mondi wrote:\n> > When creating a camera, make sure a the image sensor provides images in\n> > a format compatible with IPU3 CIO2 unit requirements and cache the\n> > minimum and maximum camera sizes.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  src/libcamera/pipeline/ipu3/ipu3.cpp | 56 +++++++++++++++++++++++++++-\n> >  1 file changed, 54 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > index 55489c31df2d..d42c81273cc6 100644\n> > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > @@ -8,11 +8,14 @@\n> >  #include <memory>\n> >  #include <vector>\n> >\n> > +#include <linux/media-bus-format.h>\n> > +\n> >  #include <libcamera/camera.h>\n> >  #include <libcamera/request.h>\n> >  #include <libcamera/stream.h>\n> >\n> >  #include \"device_enumerator.h\"\n> > +#include \"geometry.h\"\n> >  #include \"log.h\"\n> >  #include \"media_device.h\"\n> >  #include \"pipeline_handler.h\"\n> > @@ -24,6 +27,22 @@ namespace libcamera {\n> >\n> >  LOG_DEFINE_CATEGORY(IPU3)\n> >\n> > +static int mediaBusToCIO2Format(unsigned int code)\n> > +{\n> > +\tswitch (code) {\n> > +\tcase MEDIA_BUS_FMT_SBGGR10_1X10:\n> > +\t\treturn V4L2_PIX_FMT_IPU3_SBGGR10;\n> > +\tcase MEDIA_BUS_FMT_SGBRG10_1X10:\n> > +\t\treturn V4L2_PIX_FMT_IPU3_SGBRG10;\n> > +\tcase MEDIA_BUS_FMT_SGRBG10_1X10:\n> > +\t\treturn V4L2_PIX_FMT_IPU3_SGRBG10;\n> > +\tcase MEDIA_BUS_FMT_SRGGB10_1X10:\n> > +\t\treturn V4L2_PIX_FMT_IPU3_SRGGB10;\n> > +\tdefault:\n> > +\t\treturn -EINVAL;\n> > +\t}\n> > +}\n> > +\n> >  class PipelineHandlerIPU3 : public PipelineHandler\n> >  {\n> >  public:\n> > @@ -70,6 +89,9 @@ private:\n> >  \t\tV4L2Subdevice *sensor_;\n> >\n> >  \t\tStream stream_;\n> > +\n> > +\t\t/* Maximum sizes and the mbus code used to produce them. */\n> > +\t\tstd::pair<unsigned int, SizeRange> maxSizes_;\n>\n> The use of std::pair here makes the code below use .first and .second,\n> which are not very readable. I think it would be better to store the\n> pixel format and max size in two separate fields, of unsigned int and\n> SizeRange types respectively. Or, now that I think about it, as you only\n> care about the maximum size, maybe adding a Size structure to geometry.h\n> would be a good idea.\n>\n\nI see... I'll ponder about it. Adding new stuff it's always a burden\nbecause of documentation and such, but I get your point...\n\n> >  \t};\n> >\n> >  \tIPU3CameraData *cameraData(const Camera *camera)\n> > @@ -404,18 +426,48 @@ void PipelineHandlerIPU3::registerCameras()\n> >  \t\tif (ret)\n> >  \t\t\tcontinue;\n> >\n> > -\t\tdata->cio2_->bufferReady.connect(data.get(), &IPU3CameraData::bufferReady);\n> > -\n> > +\t\t/*\n> > +\t\t * Make sure the sensor produces at least one image format\n> > +\t\t * compatible with IPU3 CIO2 requirements and cache the camera\n> > +\t\t * maximum sizes.\n> > +\t\t */\n> >  \t\tdata->sensor_ = new V4L2Subdevice(sensor);\n> >  \t\tret = data->sensor_->open();\n> >  \t\tif (ret)\n> >  \t\t\tcontinue;\n> >\n> > +\t\tfor (auto it : data->sensor_->formats(0)) {\n> > +\t\t\tint mbusCode = mediaBusToCIO2Format(it.first);\n> > +\t\t\tif (mbusCode < 0)\n> > +\t\t\t\tcontinue;\n> > +\n> > +\t\t\tfor (const SizeRange &size : it.second) {\n> > +\t\t\t\tSizeRange &maxSize = data->maxSizes_.second;\n> > +\n> > +\t\t\t\tif (maxSize.maxWidth < size.maxWidth &&\n> > +\t\t\t\t    maxSize.maxHeight < size.maxHeight) {\n> > +\t\t\t\t\tmaxSize.maxWidth = size.maxWidth;\n> > +\t\t\t\t\tmaxSize.maxHeight = size.maxHeight;\n> > +\t\t\t\t\tdata->maxSizes_.first = mbusCode;\n> > +\t\t\t\t}\n> > +\t\t\t}\n> > +\t\t}\n>\n> One blank line ?\n\nNot sure, as this is an error condition, I like it better without an\nempty line.\n\n>\n> > +\t\tif (data->maxSizes_.second.maxWidth == 0) {\n> > +\t\t\tLOG(IPU3, Info)\n> > +\t\t\t\t<< \"Sensor '\" << data->sensor_->entityName()\n> > +\t\t\t\t<< \"' detected, but no supported image format \"\n> > +\t\t\t\t<< \" found: skip camera creation\";\n> > +\t\t\tcontinue;\n> > +\t\t}\n> > +\n> >  \t\tdata->csi2_ = new V4L2Subdevice(csi2);\n> >  \t\tret = data->csi2_->open();\n> >  \t\tif (ret)\n> >  \t\t\tcontinue;\n> >\n> > +\t\tdata->cio2_->bufferReady.connect(data.get(),\n> > +\t\t\t\t\t\t &IPU3CameraData::bufferReady);\n> > +\n>\n> This seems unrelated to this patch, is it needed ?\n\nplease see:\n > > -           data->cio2_->bufferReady.connect(data.get(), &IPU3CameraData::bufferReady);\n\nA few lines above here.\n\nThanks\n  j\n\n>\n> >  \t\tregisterCamera(std::move(camera), std::move(data));\n> >\n> >  \t\tLOG(IPU3, Info)\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","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 DC91560DB3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 10:25:22 +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 5AE811C000F;\n\tTue,  2 Apr 2019 08:25:22 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Tue, 2 Apr 2019 10:26:07 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190402082607.ju3dmke3zqv3m7rv@uno.localdomain>","References":"<20190326083902.26121-1-jacopo@jmondi.org>\n\t<20190326083902.26121-9-jacopo@jmondi.org>\n\t<20190402072717.GC4805@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"do4nsg3v756bhyau\"","Content-Disposition":"inline","In-Reply-To":"<20190402072717.GC4805@pendragon.ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera sizes","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 08:25:23 -0000"}},{"id":1176,"web_url":"https://patchwork.libcamera.org/comment/1176/","msgid":"<20190402091159.GF4805@pendragon.ideasonboard.com>","date":"2019-04-02T09:11:59","subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera sizes","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Tue, Apr 02, 2019 at 10:26:07AM +0200, Jacopo Mondi wrote:\n> On Tue, Apr 02, 2019 at 10:27:17AM +0300, Laurent Pinchart wrote:\n> > On Tue, Mar 26, 2019 at 09:38:51AM +0100, Jacopo Mondi wrote:\n> >> When creating a camera, make sure a the image sensor provides images in\n> >> a format compatible with IPU3 CIO2 unit requirements and cache the\n> >> minimum and maximum camera sizes.\n> >>\n> >> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> >> ---\n> >>  src/libcamera/pipeline/ipu3/ipu3.cpp | 56 +++++++++++++++++++++++++++-\n> >>  1 file changed, 54 insertions(+), 2 deletions(-)\n> >>\n> >> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> >> index 55489c31df2d..d42c81273cc6 100644\n> >> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> >> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> >> @@ -8,11 +8,14 @@\n> >>  #include <memory>\n> >>  #include <vector>\n> >>\n> >> +#include <linux/media-bus-format.h>\n> >> +\n> >>  #include <libcamera/camera.h>\n> >>  #include <libcamera/request.h>\n> >>  #include <libcamera/stream.h>\n> >>\n> >>  #include \"device_enumerator.h\"\n> >> +#include \"geometry.h\"\n> >>  #include \"log.h\"\n> >>  #include \"media_device.h\"\n> >>  #include \"pipeline_handler.h\"\n> >> @@ -24,6 +27,22 @@ namespace libcamera {\n> >>\n> >>  LOG_DEFINE_CATEGORY(IPU3)\n> >>\n> >> +static int mediaBusToCIO2Format(unsigned int code)\n> >> +{\n> >> +\tswitch (code) {\n> >> +\tcase MEDIA_BUS_FMT_SBGGR10_1X10:\n> >> +\t\treturn V4L2_PIX_FMT_IPU3_SBGGR10;\n> >> +\tcase MEDIA_BUS_FMT_SGBRG10_1X10:\n> >> +\t\treturn V4L2_PIX_FMT_IPU3_SGBRG10;\n> >> +\tcase MEDIA_BUS_FMT_SGRBG10_1X10:\n> >> +\t\treturn V4L2_PIX_FMT_IPU3_SGRBG10;\n> >> +\tcase MEDIA_BUS_FMT_SRGGB10_1X10:\n> >> +\t\treturn V4L2_PIX_FMT_IPU3_SRGGB10;\n> >> +\tdefault:\n> >> +\t\treturn -EINVAL;\n> >> +\t}\n> >> +}\n> >> +\n> >>  class PipelineHandlerIPU3 : public PipelineHandler\n> >>  {\n> >>  public:\n> >> @@ -70,6 +89,9 @@ private:\n> >>  \t\tV4L2Subdevice *sensor_;\n> >>\n> >>  \t\tStream stream_;\n> >> +\n> >> +\t\t/* Maximum sizes and the mbus code used to produce them. */\n> >> +\t\tstd::pair<unsigned int, SizeRange> maxSizes_;\n> >\n> > The use of std::pair here makes the code below use .first and .second,\n> > which are not very readable. I think it would be better to store the\n> > pixel format and max size in two separate fields, of unsigned int and\n> > SizeRange types respectively. Or, now that I think about it, as you only\n> > care about the maximum size, maybe adding a Size structure to geometry.h\n> > would be a good idea.\n> >\n> \n> I see... I'll ponder about it. Adding new stuff it's always a burden\n> because of documentation and such, but I get your point...\n\nI know it can be a bit painful :-( A Size structure should hopefully be\nsimple though.\n\n> >>  \t};\n> >>\n> >>  \tIPU3CameraData *cameraData(const Camera *camera)\n> >> @@ -404,18 +426,48 @@ void PipelineHandlerIPU3::registerCameras()\n> >>  \t\tif (ret)\n> >>  \t\t\tcontinue;\n> >>\n> >> -\t\tdata->cio2_->bufferReady.connect(data.get(), &IPU3CameraData::bufferReady);\n> >> -\n> >> +\t\t/*\n> >> +\t\t * Make sure the sensor produces at least one image format\n> >> +\t\t * compatible with IPU3 CIO2 requirements and cache the camera\n> >> +\t\t * maximum sizes.\n> >> +\t\t */\n> >>  \t\tdata->sensor_ = new V4L2Subdevice(sensor);\n> >>  \t\tret = data->sensor_->open();\n> >>  \t\tif (ret)\n> >>  \t\t\tcontinue;\n> >>\n> >> +\t\tfor (auto it : data->sensor_->formats(0)) {\n> >> +\t\t\tint mbusCode = mediaBusToCIO2Format(it.first);\n> >> +\t\t\tif (mbusCode < 0)\n> >> +\t\t\t\tcontinue;\n> >> +\n> >> +\t\t\tfor (const SizeRange &size : it.second) {\n> >> +\t\t\t\tSizeRange &maxSize = data->maxSizes_.second;\n> >> +\n> >> +\t\t\t\tif (maxSize.maxWidth < size.maxWidth &&\n> >> +\t\t\t\t    maxSize.maxHeight < size.maxHeight) {\n> >> +\t\t\t\t\tmaxSize.maxWidth = size.maxWidth;\n> >> +\t\t\t\t\tmaxSize.maxHeight = size.maxHeight;\n> >> +\t\t\t\t\tdata->maxSizes_.first = mbusCode;\n> >> +\t\t\t\t}\n> >> +\t\t\t}\n> >> +\t\t}\n> >\n> > One blank line ?\n> \n> Not sure, as this is an error condition, I like it better without an\n> empty line.\n\nThere are generally empty lines after a for loop of if block, but it's\nyour code :-)\n\n> >> +\t\tif (data->maxSizes_.second.maxWidth == 0) {\n> >> +\t\t\tLOG(IPU3, Info)\n> >> +\t\t\t\t<< \"Sensor '\" << data->sensor_->entityName()\n> >> +\t\t\t\t<< \"' detected, but no supported image format \"\n> >> +\t\t\t\t<< \" found: skip camera creation\";\n> >> +\t\t\tcontinue;\n> >> +\t\t}\n> >> +\n> >>  \t\tdata->csi2_ = new V4L2Subdevice(csi2);\n> >>  \t\tret = data->csi2_->open();\n> >>  \t\tif (ret)\n> >>  \t\t\tcontinue;\n> >>\n> >> +\t\tdata->cio2_->bufferReady.connect(data.get(),\n> >> +\t\t\t\t\t\t &IPU3CameraData::bufferReady);\n> >> +\n> >\n> > This seems unrelated to this patch, is it needed ?\n> \n> please see:\n> >> -           data->cio2_->bufferReady.connect(data.get(), &IPU3CameraData::bufferReady);\n> \n> A few lines above here.\n\nI know, what I meant is that moving the code seems unrelated, as you\ndon't touch it (apart from wrapping the line).\n\n> >>  \t\tregisterCamera(std::move(camera), std::move(data));\n> >>\n> >>  \t\tLOG(IPU3, Info)","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 3398B600FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 11:12:11 +0200 (CEST)","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 16BD02F9;\n\tTue,  2 Apr 2019 11:12:09 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1554196330;\n\tbh=ZGq41aR8rPpl5SkNpqEWzwaYMXIX6+6E0vBqL9LM+I0=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Oj3t4zHhxUSWlOKTtt+vo9sMrZSgHkmgaJe1HzjgdA9pGxcR9aedfH+wRX34Hv84p\n\t2kzndfOCUmhleLOC8xzcNmynoWN+sVS7aKssrZXWvD1Sx1q8KCJHG83k3QRxtfq0We\n\tL9oYyWPd7hRhP4SdO9FdZtG8K5Vadmta8izldmAE=","Date":"Tue, 2 Apr 2019 12:11:59 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190402091159.GF4805@pendragon.ideasonboard.com>","References":"<20190326083902.26121-1-jacopo@jmondi.org>\n\t<20190326083902.26121-9-jacopo@jmondi.org>\n\t<20190402072717.GC4805@pendragon.ideasonboard.com>\n\t<20190402082607.ju3dmke3zqv3m7rv@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190402082607.ju3dmke3zqv3m7rv@uno.localdomain>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera sizes","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 09:12:11 -0000"}},{"id":1177,"web_url":"https://patchwork.libcamera.org/comment/1177/","msgid":"<20190402092330.jyddb6h23xzpelj5@uno.localdomain>","date":"2019-04-02T09:23:30","subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera sizes","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Tue, Apr 02, 2019 at 12:11:59PM +0300, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> On Tue, Apr 02, 2019 at 10:26:07AM +0200, Jacopo Mondi wrote:\n> > On Tue, Apr 02, 2019 at 10:27:17AM +0300, Laurent Pinchart wrote:\n> > > On Tue, Mar 26, 2019 at 09:38:51AM +0100, Jacopo Mondi wrote:\n> > >> When creating a camera, make sure a the image sensor provides images in\n> > >> a format compatible with IPU3 CIO2 unit requirements and cache the\n> > >> minimum and maximum camera sizes.\n> > >>\n> > >> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > >> ---\n> > >>  src/libcamera/pipeline/ipu3/ipu3.cpp | 56 +++++++++++++++++++++++++++-\n> > >>  1 file changed, 54 insertions(+), 2 deletions(-)\n> > >>\n> > >> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > >> index 55489c31df2d..d42c81273cc6 100644\n> > >> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > >> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > >> @@ -8,11 +8,14 @@\n> > >>  #include <memory>\n> > >>  #include <vector>\n> > >>\n> > >> +#include <linux/media-bus-format.h>\n> > >> +\n> > >>  #include <libcamera/camera.h>\n> > >>  #include <libcamera/request.h>\n> > >>  #include <libcamera/stream.h>\n> > >>\n> > >>  #include \"device_enumerator.h\"\n> > >> +#include \"geometry.h\"\n> > >>  #include \"log.h\"\n> > >>  #include \"media_device.h\"\n> > >>  #include \"pipeline_handler.h\"\n> > >> @@ -24,6 +27,22 @@ namespace libcamera {\n> > >>\n> > >>  LOG_DEFINE_CATEGORY(IPU3)\n> > >>\n> > >> +static int mediaBusToCIO2Format(unsigned int code)\n> > >> +{\n> > >> +\tswitch (code) {\n> > >> +\tcase MEDIA_BUS_FMT_SBGGR10_1X10:\n> > >> +\t\treturn V4L2_PIX_FMT_IPU3_SBGGR10;\n> > >> +\tcase MEDIA_BUS_FMT_SGBRG10_1X10:\n> > >> +\t\treturn V4L2_PIX_FMT_IPU3_SGBRG10;\n> > >> +\tcase MEDIA_BUS_FMT_SGRBG10_1X10:\n> > >> +\t\treturn V4L2_PIX_FMT_IPU3_SGRBG10;\n> > >> +\tcase MEDIA_BUS_FMT_SRGGB10_1X10:\n> > >> +\t\treturn V4L2_PIX_FMT_IPU3_SRGGB10;\n> > >> +\tdefault:\n> > >> +\t\treturn -EINVAL;\n> > >> +\t}\n> > >> +}\n> > >> +\n> > >>  class PipelineHandlerIPU3 : public PipelineHandler\n> > >>  {\n> > >>  public:\n> > >> @@ -70,6 +89,9 @@ private:\n> > >>  \t\tV4L2Subdevice *sensor_;\n> > >>\n> > >>  \t\tStream stream_;\n> > >> +\n> > >> +\t\t/* Maximum sizes and the mbus code used to produce them. */\n> > >> +\t\tstd::pair<unsigned int, SizeRange> maxSizes_;\n> > >\n> > > The use of std::pair here makes the code below use .first and .second,\n> > > which are not very readable. I think it would be better to store the\n> > > pixel format and max size in two separate fields, of unsigned int and\n> > > SizeRange types respectively. Or, now that I think about it, as you only\n> > > care about the maximum size, maybe adding a Size structure to geometry.h\n> > > would be a good idea.\n> > >\n> >\n> > I see... I'll ponder about it. Adding new stuff it's always a burden\n> > because of documentation and such, but I get your point...\n>\n> I know it can be a bit painful :-( A Size structure should hopefully be\n> simple though.\n>\n> > >>  \t};\n> > >>\n> > >>  \tIPU3CameraData *cameraData(const Camera *camera)\n> > >> @@ -404,18 +426,48 @@ void PipelineHandlerIPU3::registerCameras()\n> > >>  \t\tif (ret)\n> > >>  \t\t\tcontinue;\n> > >>\n> > >> -\t\tdata->cio2_->bufferReady.connect(data.get(), &IPU3CameraData::bufferReady);\n> > >> -\n> > >> +\t\t/*\n> > >> +\t\t * Make sure the sensor produces at least one image format\n> > >> +\t\t * compatible with IPU3 CIO2 requirements and cache the camera\n> > >> +\t\t * maximum sizes.\n> > >> +\t\t */\n> > >>  \t\tdata->sensor_ = new V4L2Subdevice(sensor);\n> > >>  \t\tret = data->sensor_->open();\n> > >>  \t\tif (ret)\n> > >>  \t\t\tcontinue;\n> > >>\n> > >> +\t\tfor (auto it : data->sensor_->formats(0)) {\n> > >> +\t\t\tint mbusCode = mediaBusToCIO2Format(it.first);\n> > >> +\t\t\tif (mbusCode < 0)\n> > >> +\t\t\t\tcontinue;\n> > >> +\n> > >> +\t\t\tfor (const SizeRange &size : it.second) {\n> > >> +\t\t\t\tSizeRange &maxSize = data->maxSizes_.second;\n> > >> +\n> > >> +\t\t\t\tif (maxSize.maxWidth < size.maxWidth &&\n> > >> +\t\t\t\t    maxSize.maxHeight < size.maxHeight) {\n> > >> +\t\t\t\t\tmaxSize.maxWidth = size.maxWidth;\n> > >> +\t\t\t\t\tmaxSize.maxHeight = size.maxHeight;\n> > >> +\t\t\t\t\tdata->maxSizes_.first = mbusCode;\n> > >> +\t\t\t\t}\n> > >> +\t\t\t}\n> > >> +\t\t}\n> > >\n> > > One blank line ?\n> >\n> > Not sure, as this is an error condition, I like it better without an\n> > empty line.\n>\n> There are generally empty lines after a for loop of if block, but it's\n> your code :-)\n>\n> > >> +\t\tif (data->maxSizes_.second.maxWidth == 0) {\n> > >> +\t\t\tLOG(IPU3, Info)\n> > >> +\t\t\t\t<< \"Sensor '\" << data->sensor_->entityName()\n> > >> +\t\t\t\t<< \"' detected, but no supported image format \"\n> > >> +\t\t\t\t<< \" found: skip camera creation\";\n> > >> +\t\t\tcontinue;\n> > >> +\t\t}\n> > >> +\n> > >>  \t\tdata->csi2_ = new V4L2Subdevice(csi2);\n> > >>  \t\tret = data->csi2_->open();\n> > >>  \t\tif (ret)\n> > >>  \t\t\tcontinue;\n> > >>\n> > >> +\t\tdata->cio2_->bufferReady.connect(data.get(),\n> > >> +\t\t\t\t\t\t &IPU3CameraData::bufferReady);\n> > >> +\n> > >\n> > > This seems unrelated to this patch, is it needed ?\n> >\n> > please see:\n> > >> -           data->cio2_->bufferReady.connect(data.get(), &IPU3CameraData::bufferReady);\n> >\n> > A few lines above here.\n>\n> I know, what I meant is that moving the code seems unrelated, as you\n> don't touch it (apart from wrapping the line).\n>\n\nAh, got it. I moved it here because I want to connect the signal only\nafter we have successfully validated the sensor provided formats\n(introduced in this patch), so I don't think it's unrelated, isn't it?\n\nThanks\n  j\n\n> > >>  \t\tregisterCamera(std::move(camera), std::move(data));\n> > >>\n> > >>  \t\tLOG(IPU3, Info)\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net\n\t[217.70.183.193])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 836BD600FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 11:22:45 +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 relay1-d.mail.gandi.net (Postfix) with ESMTPSA id 0D6C1240019;\n\tTue,  2 Apr 2019 09:22:44 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Tue, 2 Apr 2019 11:23:30 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190402092330.jyddb6h23xzpelj5@uno.localdomain>","References":"<20190326083902.26121-1-jacopo@jmondi.org>\n\t<20190326083902.26121-9-jacopo@jmondi.org>\n\t<20190402072717.GC4805@pendragon.ideasonboard.com>\n\t<20190402082607.ju3dmke3zqv3m7rv@uno.localdomain>\n\t<20190402091159.GF4805@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"avwjeg6ftzccghpy\"","Content-Disposition":"inline","In-Reply-To":"<20190402091159.GF4805@pendragon.ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera sizes","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 09:22:45 -0000"}},{"id":1179,"web_url":"https://patchwork.libcamera.org/comment/1179/","msgid":"<20190402092725.GH4805@pendragon.ideasonboard.com>","date":"2019-04-02T09:27:25","subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera sizes","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Tue, Apr 02, 2019 at 11:23:30AM +0200, Jacopo Mondi wrote:\n> On Tue, Apr 02, 2019 at 12:11:59PM +0300, Laurent Pinchart wrote:\n> > On Tue, Apr 02, 2019 at 10:26:07AM +0200, Jacopo Mondi wrote:\n> >> On Tue, Apr 02, 2019 at 10:27:17AM +0300, Laurent Pinchart wrote:\n> >>> On Tue, Mar 26, 2019 at 09:38:51AM +0100, Jacopo Mondi wrote:\n> >>>> When creating a camera, make sure a the image sensor provides images in\n> >>>> a format compatible with IPU3 CIO2 unit requirements and cache the\n> >>>> minimum and maximum camera sizes.\n> >>>>\n> >>>> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> >>>> ---\n> >>>>  src/libcamera/pipeline/ipu3/ipu3.cpp | 56 +++++++++++++++++++++++++++-\n> >>>>  1 file changed, 54 insertions(+), 2 deletions(-)\n> >>>>\n> >>>> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> >>>> index 55489c31df2d..d42c81273cc6 100644\n> >>>> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> >>>> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> >>>> @@ -8,11 +8,14 @@\n> >>>>  #include <memory>\n> >>>>  #include <vector>\n> >>>>\n> >>>> +#include <linux/media-bus-format.h>\n> >>>> +\n> >>>>  #include <libcamera/camera.h>\n> >>>>  #include <libcamera/request.h>\n> >>>>  #include <libcamera/stream.h>\n> >>>>\n> >>>>  #include \"device_enumerator.h\"\n> >>>> +#include \"geometry.h\"\n> >>>>  #include \"log.h\"\n> >>>>  #include \"media_device.h\"\n> >>>>  #include \"pipeline_handler.h\"\n> >>>> @@ -24,6 +27,22 @@ namespace libcamera {\n> >>>>\n> >>>>  LOG_DEFINE_CATEGORY(IPU3)\n> >>>>\n> >>>> +static int mediaBusToCIO2Format(unsigned int code)\n> >>>> +{\n> >>>> +\tswitch (code) {\n> >>>> +\tcase MEDIA_BUS_FMT_SBGGR10_1X10:\n> >>>> +\t\treturn V4L2_PIX_FMT_IPU3_SBGGR10;\n> >>>> +\tcase MEDIA_BUS_FMT_SGBRG10_1X10:\n> >>>> +\t\treturn V4L2_PIX_FMT_IPU3_SGBRG10;\n> >>>> +\tcase MEDIA_BUS_FMT_SGRBG10_1X10:\n> >>>> +\t\treturn V4L2_PIX_FMT_IPU3_SGRBG10;\n> >>>> +\tcase MEDIA_BUS_FMT_SRGGB10_1X10:\n> >>>> +\t\treturn V4L2_PIX_FMT_IPU3_SRGGB10;\n> >>>> +\tdefault:\n> >>>> +\t\treturn -EINVAL;\n> >>>> +\t}\n> >>>> +}\n> >>>> +\n> >>>>  class PipelineHandlerIPU3 : public PipelineHandler\n> >>>>  {\n> >>>>  public:\n> >>>> @@ -70,6 +89,9 @@ private:\n> >>>>  \t\tV4L2Subdevice *sensor_;\n> >>>>\n> >>>>  \t\tStream stream_;\n> >>>> +\n> >>>> +\t\t/* Maximum sizes and the mbus code used to produce them. */\n> >>>> +\t\tstd::pair<unsigned int, SizeRange> maxSizes_;\n> >>>\n> >>> The use of std::pair here makes the code below use .first and .second,\n> >>> which are not very readable. I think it would be better to store the\n> >>> pixel format and max size in two separate fields, of unsigned int and\n> >>> SizeRange types respectively. Or, now that I think about it, as you only\n> >>> care about the maximum size, maybe adding a Size structure to geometry.h\n> >>> would be a good idea.\n> >>>\n> >>\n> >> I see... I'll ponder about it. Adding new stuff it's always a burden\n> >> because of documentation and such, but I get your point...\n> >\n> > I know it can be a bit painful :-( A Size structure should hopefully be\n> > simple though.\n> >\n> >>>>  \t};\n> >>>>\n> >>>>  \tIPU3CameraData *cameraData(const Camera *camera)\n> >>>> @@ -404,18 +426,48 @@ void PipelineHandlerIPU3::registerCameras()\n> >>>>  \t\tif (ret)\n> >>>>  \t\t\tcontinue;\n> >>>>\n> >>>> -\t\tdata->cio2_->bufferReady.connect(data.get(), &IPU3CameraData::bufferReady);\n> >>>> -\n> >>>> +\t\t/*\n> >>>> +\t\t * Make sure the sensor produces at least one image format\n> >>>> +\t\t * compatible with IPU3 CIO2 requirements and cache the camera\n> >>>> +\t\t * maximum sizes.\n> >>>> +\t\t */\n> >>>>  \t\tdata->sensor_ = new V4L2Subdevice(sensor);\n> >>>>  \t\tret = data->sensor_->open();\n> >>>>  \t\tif (ret)\n> >>>>  \t\t\tcontinue;\n> >>>>\n> >>>> +\t\tfor (auto it : data->sensor_->formats(0)) {\n> >>>> +\t\t\tint mbusCode = mediaBusToCIO2Format(it.first);\n> >>>> +\t\t\tif (mbusCode < 0)\n> >>>> +\t\t\t\tcontinue;\n> >>>> +\n> >>>> +\t\t\tfor (const SizeRange &size : it.second) {\n> >>>> +\t\t\t\tSizeRange &maxSize = data->maxSizes_.second;\n> >>>> +\n> >>>> +\t\t\t\tif (maxSize.maxWidth < size.maxWidth &&\n> >>>> +\t\t\t\t    maxSize.maxHeight < size.maxHeight) {\n> >>>> +\t\t\t\t\tmaxSize.maxWidth = size.maxWidth;\n> >>>> +\t\t\t\t\tmaxSize.maxHeight = size.maxHeight;\n> >>>> +\t\t\t\t\tdata->maxSizes_.first = mbusCode;\n> >>>> +\t\t\t\t}\n> >>>> +\t\t\t}\n> >>>> +\t\t}\n> >>>\n> >>> One blank line ?\n> >>\n> >> Not sure, as this is an error condition, I like it better without an\n> >> empty line.\n> >\n> > There are generally empty lines after a for loop of if block, but it's\n> > your code :-)\n> >\n> >>>> +\t\tif (data->maxSizes_.second.maxWidth == 0) {\n> >>>> +\t\t\tLOG(IPU3, Info)\n> >>>> +\t\t\t\t<< \"Sensor '\" << data->sensor_->entityName()\n> >>>> +\t\t\t\t<< \"' detected, but no supported image format \"\n> >>>> +\t\t\t\t<< \" found: skip camera creation\";\n> >>>> +\t\t\tcontinue;\n> >>>> +\t\t}\n> >>>> +\n> >>>>  \t\tdata->csi2_ = new V4L2Subdevice(csi2);\n> >>>>  \t\tret = data->csi2_->open();\n> >>>>  \t\tif (ret)\n> >>>>  \t\t\tcontinue;\n> >>>>\n> >>>> +\t\tdata->cio2_->bufferReady.connect(data.get(),\n> >>>> +\t\t\t\t\t\t &IPU3CameraData::bufferReady);\n> >>>> +\n> >>>\n> >>> This seems unrelated to this patch, is it needed ?\n> >>\n> >> please see:\n> >> \n> >>>> -           data->cio2_->bufferReady.connect(data.get(), &IPU3CameraData::bufferReady);\n> >>\n> >> A few lines above here.\n> >\n> > I know, what I meant is that moving the code seems unrelated, as you\n> > don't touch it (apart from wrapping the line).\n> >\n> \n> Ah, got it. I moved it here because I want to connect the signal only\n> after we have successfully validated the sensor provided formats\n> (introduced in this patch), so I don't think it's unrelated, isn't it?\n\nMy point is that there's no strict need to connect the signal only after\nvalidating the sensor formats. It's no big deal though.\n\n> >>>>  \t\tregisterCamera(std::move(camera), std::move(data));\n> >>>>\n> >>>>  \t\tLOG(IPU3, Info)","headers":{"Return-Path":"<laurent.pinchart@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 BF6EC600FD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 11:27:36 +0200 (CEST)","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 46E902F9;\n\tTue,  2 Apr 2019 11:27:36 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1554197256;\n\tbh=fN4hz2+VZ672KhWm3P7nd+eOcgSDXcmtd+Ob3IwA/yg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=kAYH62B5kPqPdcIeWISEr6h6JeQQ1r0F1Ot1Ok1qpz9gPdrG4qfXnOhCOQqrg1wyA\n\tfAfOcUlW5qhvAMB3lkQnem5QwCXs+a7zwkXBtEkfAL33QaBPYn+fXOdTsaugoZCmQ6\n\tQo+eA+kQdEE5+6JeuVpAjL6Ng6lS8gUoNSAn384k=","Date":"Tue, 2 Apr 2019 12:27:25 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190402092725.GH4805@pendragon.ideasonboard.com>","References":"<20190326083902.26121-1-jacopo@jmondi.org>\n\t<20190326083902.26121-9-jacopo@jmondi.org>\n\t<20190402072717.GC4805@pendragon.ideasonboard.com>\n\t<20190402082607.ju3dmke3zqv3m7rv@uno.localdomain>\n\t<20190402091159.GF4805@pendragon.ideasonboard.com>\n\t<20190402092330.jyddb6h23xzpelj5@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190402092330.jyddb6h23xzpelj5@uno.localdomain>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera sizes","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 09:27:37 -0000"}},{"id":1192,"web_url":"https://patchwork.libcamera.org/comment/1192/","msgid":"<20190402110848.GL23466@bigcity.dyn.berto.se>","date":"2019-04-02T11:08:48","subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera 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 2019-03-26 09:38:51 +0100, Jacopo Mondi wrote:\n> When creating a camera, make sure a the image sensor provides images in\n> a format compatible with IPU3 CIO2 unit requirements and cache the\n> minimum and maximum camera sizes.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 56 +++++++++++++++++++++++++++-\n>  1 file changed, 54 insertions(+), 2 deletions(-)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index 55489c31df2d..d42c81273cc6 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -8,11 +8,14 @@\n>  #include <memory>\n>  #include <vector>\n>  \n> +#include <linux/media-bus-format.h>\n> +\n>  #include <libcamera/camera.h>\n>  #include <libcamera/request.h>\n>  #include <libcamera/stream.h>\n>  \n>  #include \"device_enumerator.h\"\n> +#include \"geometry.h\"\n>  #include \"log.h\"\n>  #include \"media_device.h\"\n>  #include \"pipeline_handler.h\"\n> @@ -24,6 +27,22 @@ namespace libcamera {\n>  \n>  LOG_DEFINE_CATEGORY(IPU3)\n>  \n> +static int mediaBusToCIO2Format(unsigned int code)\n> +{\n> +\tswitch (code) {\n> +\tcase MEDIA_BUS_FMT_SBGGR10_1X10:\n> +\t\treturn V4L2_PIX_FMT_IPU3_SBGGR10;\n> +\tcase MEDIA_BUS_FMT_SGBRG10_1X10:\n> +\t\treturn V4L2_PIX_FMT_IPU3_SGBRG10;\n> +\tcase MEDIA_BUS_FMT_SGRBG10_1X10:\n> +\t\treturn V4L2_PIX_FMT_IPU3_SGRBG10;\n> +\tcase MEDIA_BUS_FMT_SRGGB10_1X10:\n> +\t\treturn V4L2_PIX_FMT_IPU3_SRGGB10;\n> +\tdefault:\n> +\t\treturn -EINVAL;\n> +\t}\n> +}\n> +\n>  class PipelineHandlerIPU3 : public PipelineHandler\n>  {\n>  public:\n> @@ -70,6 +89,9 @@ private:\n>  \t\tV4L2Subdevice *sensor_;\n>  \n>  \t\tStream stream_;\n> +\n> +\t\t/* Maximum sizes and the mbus code used to produce them. */\n> +\t\tstd::pair<unsigned int, SizeRange> maxSizes_;\n>  \t};\n>  \n>  \tIPU3CameraData *cameraData(const Camera *camera)\n> @@ -404,18 +426,48 @@ void PipelineHandlerIPU3::registerCameras()\n>  \t\tif (ret)\n>  \t\t\tcontinue;\n>  \n> -\t\tdata->cio2_->bufferReady.connect(data.get(), &IPU3CameraData::bufferReady);\n> -\n> +\t\t/*\n> +\t\t * Make sure the sensor produces at least one image format\n> +\t\t * compatible with IPU3 CIO2 requirements and cache the camera\n> +\t\t * maximum sizes.\n> +\t\t */\n>  \t\tdata->sensor_ = new V4L2Subdevice(sensor);\n>  \t\tret = data->sensor_->open();\n>  \t\tif (ret)\n>  \t\t\tcontinue;\n>  \n> +\t\tfor (auto it : data->sensor_->formats(0)) {\n> +\t\t\tint mbusCode = mediaBusToCIO2Format(it.first);\n> +\t\t\tif (mbusCode < 0)\n> +\t\t\t\tcontinue;\n> +\n> +\t\t\tfor (const SizeRange &size : it.second) {\n> +\t\t\t\tSizeRange &maxSize = data->maxSizes_.second;\n> +\n> +\t\t\t\tif (maxSize.maxWidth < size.maxWidth &&\n> +\t\t\t\t    maxSize.maxHeight < size.maxHeight) {\n> +\t\t\t\t\tmaxSize.maxWidth = size.maxWidth;\n> +\t\t\t\t\tmaxSize.maxHeight = size.maxHeight;\n> +\t\t\t\t\tdata->maxSizes_.first = mbusCode;\n> +\t\t\t\t}\n> +\t\t\t}\n> +\t\t}\n> +\t\tif (data->maxSizes_.second.maxWidth == 0) {\n> +\t\t\tLOG(IPU3, Info)\n> +\t\t\t\t<< \"Sensor '\" << data->sensor_->entityName()\n> +\t\t\t\t<< \"' detected, but no supported image format \"\n> +\t\t\t\t<< \" found: skip camera creation\";\n> +\t\t\tcontinue;\n> +\t\t}\n> +\n\nNit-pick: I would break this out into a cacheSizes() function as \nregisterCameras() is becoming rather large. Nothing I will press tho.\n\n>  \t\tdata->csi2_ = new V4L2Subdevice(csi2);\n>  \t\tret = data->csi2_->open();\n>  \t\tif (ret)\n>  \t\t\tcontinue;\n>  \n> +\t\tdata->cio2_->bufferReady.connect(data.get(),\n> +\t\t\t\t\t\t &IPU3CameraData::bufferReady);\n> +\n>  \t\tregisterCamera(std::move(camera), std::move(data));\n>  \n>  \t\tLOG(IPU3, Info)\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-x22d.google.com (mail-lj1-x22d.google.com\n\t[IPv6:2a00:1450:4864:20::22d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8247B60DB3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 13:08:50 +0200 (CEST)","by mail-lj1-x22d.google.com with SMTP id r24so11202530ljg.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 02 Apr 2019 04:08:50 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tm1sm2609621lfh.36.2019.04.02.04.08.48\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 02 Apr 2019 04:08:48 -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=HL07Sz2jW+yYvjFYFhM2yoQmwsIZmlHvqgY+4TCgeZY=;\n\tb=WdRlcT414+Z6IHpflMeCeeDS35KBEcrS3dyfXvtorA9mhrbGW5dWKLjRVMMdUoq0HG\n\tXCpntXmHMkV9814SVv/DRUJShTm1ISoNNKp5WnhJbEPOMc+FpR+PS71AtaBwOAv9cRFh\n\tvvcLKKp7eL/cxsCvz53RhXBg0q3wvCE8pioxkJXK3cn5caKZISbfOblUO9kA7dwtdVF9\n\tqNpVSOg2XCAMfsrcMFjhzSb+AaT8aQIL6FaQycFaLfe1ma85zLt8ZOD0GTSQxcbC3SzX\n\tlDA8lhGRptpfR1tZGY5j0z6KoDXlmIn3Zo1G6A0l3BNHSXGbvsrbNpzb1kGRcVG9Rvlv\n\tiAEw==","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=HL07Sz2jW+yYvjFYFhM2yoQmwsIZmlHvqgY+4TCgeZY=;\n\tb=ktrB7ouf8nAebl2f2R868B6sZuKNoFYMXwwRE1fCzIgAwTrlE8/UIpnnf7pSBnrTn5\n\tvMNaHGgt/x8D412ldt8swgbLt/m22pOrEczyUX5Fh3rWVoOByVxArSnJlMaqLsoeqLoY\n\tl9wJSXYTxZeLdhkgTrJFVKnINvvvUqXcPgMJ/O0SQPcsnxP8hrwtJXaWaIsH7qjkINRF\n\t1nrjNbpi4yfjCGcostZ7iAVfvWnytnbGqeXps+nMEIASTOmW349u2Z5QV94ONbJdoiVx\n\tbyk/BNy3dEzIlYRxVbYLzN8Uy17f+KOKbtTUV/ldJi+yIs3KROlOhFPsjDqBes7aX//s\n\tfptA==","X-Gm-Message-State":"APjAAAUNbMiCVMIApr5Br28EkXGHMA7l0Sh7PkMhzKeBQhUOOnZcEMvc\n\tWMG8PnW+4e6WSGCrYFC02KIaWg==","X-Google-Smtp-Source":"APXvYqzfPTMdWImyj0fDDL3l4gXrN84Hm4ftQx9Mpvc1S2/aYCpe/UDucKMwFHAGaqklw6jRqVTLaA==","X-Received":"by 2002:a05:651c:157:: with SMTP id\n\tc23mr11326469ljd.151.1554203329835; \n\tTue, 02 Apr 2019 04:08:49 -0700 (PDT)","Date":"Tue, 2 Apr 2019 13:08:48 +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":"<20190402110848.GL23466@bigcity.dyn.berto.se>","References":"<20190326083902.26121-1-jacopo@jmondi.org>\n\t<20190326083902.26121-9-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-9-jacopo@jmondi.org>","User-Agent":"Mutt/1.11.3 (2019-02-01)","Subject":"Re: [libcamera-devel] [PATCH v5 08/19] libcamera: ipu3: Cache the\n\tcamera sizes","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 11:08:50 -0000"}}]