[{"id":1217,"web_url":"https://patchwork.libcamera.org/comment/1217/","msgid":"<20190402172235.GN4805@pendragon.ideasonboard.com>","date":"2019-04-02T17:22:35","subject":"Re: [libcamera-devel] [PATCH v7 04/13] libcamera: ipu3: Cache the\n\tsensor 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, Apr 02, 2019 at 07:13:00PM +0200, Jacopo Mondi wrote:\n> Cache the sensor maximum size and the media bus code used to produce\n> it.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 47 ++++++++++++++++++++++++++++\n>  1 file changed, 47 insertions(+)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index a870b325f4b3..1e315048738b 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -8,6 +8,8 @@\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> @@ -24,6 +26,22 @@ namespace libcamera {\n>  \n>  LOG_DEFINE_CATEGORY(IPU3)\n>  \n> +static int mediaBusToCIO2Format(unsigned int code)\n\nI wonder why I hadn't thought about this before, would it make sense to\nmove this function to the CIO2Device class, make it static, and rename\nit to mediaBusToPixelFormat (or just mediaBusToFormat) ?\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\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 CIO2Device\n>  {\n>  public:\n> @@ -44,6 +62,10 @@ public:\n>  \tV4L2Device *output_;\n>  \tV4L2Subdevice *csi2_;\n>  \tV4L2Subdevice *sensor_;\n> +\n> +\t/* Maximum sizes and the mbus code used to produce them. */\n> +\tunsigned int mbusCode_;\n> +\tSize maxSize_;\n>  };\n>  \n>  class PipelineHandlerIPU3 : public PipelineHandler\n> @@ -442,6 +464,10 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>  \t\treturn ret;\n>  \n>  \t/*\n> +\t * Now that we're sure a sensor subdevice is connected, make sure it\n> +\t * produces at least one image format compatible with CIO2 requirements\n> +\t * and cache the camera maximum size.\n> +\t *\n>  \t * \\todo Define when to open and close video device nodes, as they\n>  \t * might impact on power consumption.\n>  \t */\n> @@ -450,6 +476,27 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> +\tfor (auto it : sensor_->formats(0)) {\n> +\t\tint mbusCode = mediaBusToCIO2Format(it.first);\n> +\t\tif (mbusCode < 0)\n> +\t\t\tcontinue;\n> +\n> +\t\tfor (const SizeRange &size : it.second) {\n> +\t\t\tif (maxSize_.width < size.maxWidth &&\n> +\t\t\t    maxSize_.height < size.maxHeight) {\n> +\t\t\t\tmaxSize_.width = size.maxWidth;\n> +\t\t\t\tmaxSize_.height = size.maxHeight;\n> +\t\t\t\tmbusCode_ = mbusCode;\n> +\t\t\t}\n> +\t\t}\n> +\t}\n> +\tif (maxSize_.width == 0) {\n> +\t\tLOG(IPU3, Info) << \"Sensor '\" << sensor_->entityName()\n> +\t\t\t\t<< \"' detected, but no supported image format \"\n> +\t\t\t\t<< \" found: skip camera creation\";\n> +\t\treturn -ENODEV;\n> +\t}\n> +\n>  \tcsi2_ = new V4L2Subdevice(csi2Entity);\n>  \tret = csi2_->open();\n>  \tif (ret)","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 04862610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 19:22:46 +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 73FE72F9;\n\tTue,  2 Apr 2019 19:22:46 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1554225766;\n\tbh=HpIShPQjY2th4AEua5Sl79pk6MkmSIsdWD4EsR0w6Q8=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=TR8DJZWWSncNfU5731qB4zfn8hRe38V1kNaJwRG0pxf6W7LzYw5ubRB920H2DK9gb\n\t+Se4r6HcOGx7Y8hJVG8Lgw6ZCyXSre05IOMl7wrpLGxhSbp32TOfKvbX1QikiCgJDk\n\tj1zkScfm7bJ86x5E03g2dzVdSspNPqsytk3gUDJs=","Date":"Tue, 2 Apr 2019 20:22:35 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190402172235.GN4805@pendragon.ideasonboard.com>","References":"<20190402171309.6447-1-jacopo@jmondi.org>\n\t<20190402171309.6447-5-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190402171309.6447-5-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v7 04/13] libcamera: ipu3: Cache the\n\tsensor 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 17:22:47 -0000"}},{"id":1218,"web_url":"https://patchwork.libcamera.org/comment/1218/","msgid":"<20190402172929.swz5apo2zqahypn7@uno.localdomain>","date":"2019-04-02T17:29:29","subject":"Re: [libcamera-devel] [PATCH v7 04/13] libcamera: ipu3: Cache the\n\tsensor 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 08:22:35PM +0300, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> Thank you for the patch.\n>\n> On Tue, Apr 02, 2019 at 07:13:00PM +0200, Jacopo Mondi wrote:\n> > Cache the sensor maximum size and the media bus code used to produce\n> > it.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  src/libcamera/pipeline/ipu3/ipu3.cpp | 47 ++++++++++++++++++++++++++++\n> >  1 file changed, 47 insertions(+)\n> >\n> > diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > index a870b325f4b3..1e315048738b 100644\n> > --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> > @@ -8,6 +8,8 @@\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> > @@ -24,6 +26,22 @@ namespace libcamera {\n> >\n> >  LOG_DEFINE_CATEGORY(IPU3)\n> >\n> > +static int mediaBusToCIO2Format(unsigned int code)\n>\n> I wonder why I hadn't thought about this before, would it make sense to\n> move this function to the CIO2Device class, make it static, and rename\n> it to mediaBusToPixelFormat (or just mediaBusToFormat) ?\n>\n\nIt might make sense, I guess.\n\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n\nWith or without the above change?\n\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 CIO2Device\n> >  {\n> >  public:\n> > @@ -44,6 +62,10 @@ public:\n> >  \tV4L2Device *output_;\n> >  \tV4L2Subdevice *csi2_;\n> >  \tV4L2Subdevice *sensor_;\n> > +\n> > +\t/* Maximum sizes and the mbus code used to produce them. */\n> > +\tunsigned int mbusCode_;\n> > +\tSize maxSize_;\n> >  };\n> >\n> >  class PipelineHandlerIPU3 : public PipelineHandler\n> > @@ -442,6 +464,10 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n> >  \t\treturn ret;\n> >\n> >  \t/*\n> > +\t * Now that we're sure a sensor subdevice is connected, make sure it\n> > +\t * produces at least one image format compatible with CIO2 requirements\n> > +\t * and cache the camera maximum size.\n> > +\t *\n> >  \t * \\todo Define when to open and close video device nodes, as they\n> >  \t * might impact on power consumption.\n> >  \t */\n> > @@ -450,6 +476,27 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n> >  \tif (ret)\n> >  \t\treturn ret;\n> >\n> > +\tfor (auto it : sensor_->formats(0)) {\n> > +\t\tint mbusCode = mediaBusToCIO2Format(it.first);\n> > +\t\tif (mbusCode < 0)\n> > +\t\t\tcontinue;\n> > +\n> > +\t\tfor (const SizeRange &size : it.second) {\n> > +\t\t\tif (maxSize_.width < size.maxWidth &&\n> > +\t\t\t    maxSize_.height < size.maxHeight) {\n> > +\t\t\t\tmaxSize_.width = size.maxWidth;\n> > +\t\t\t\tmaxSize_.height = size.maxHeight;\n> > +\t\t\t\tmbusCode_ = mbusCode;\n> > +\t\t\t}\n> > +\t\t}\n> > +\t}\n> > +\tif (maxSize_.width == 0) {\n> > +\t\tLOG(IPU3, Info) << \"Sensor '\" << sensor_->entityName()\n> > +\t\t\t\t<< \"' detected, but no supported image format \"\n> > +\t\t\t\t<< \" found: skip camera creation\";\n> > +\t\treturn -ENODEV;\n> > +\t}\n> > +\n> >  \tcsi2_ = new V4L2Subdevice(csi2Entity);\n> >  \tret = csi2_->open();\n> >  \tif (ret)\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["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 3CE62610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 19:28: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 relay6-d.mail.gandi.net (Postfix) with ESMTPSA id B4436C0011;\n\tTue,  2 Apr 2019 17:28:44 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Tue, 2 Apr 2019 19:29:29 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190402172929.swz5apo2zqahypn7@uno.localdomain>","References":"<20190402171309.6447-1-jacopo@jmondi.org>\n\t<20190402171309.6447-5-jacopo@jmondi.org>\n\t<20190402172235.GN4805@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"lb57birse7p3it4y\"","Content-Disposition":"inline","In-Reply-To":"<20190402172235.GN4805@pendragon.ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v7 04/13] libcamera: ipu3: Cache the\n\tsensor 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 17:28:45 -0000"}},{"id":1220,"web_url":"https://patchwork.libcamera.org/comment/1220/","msgid":"<20190402173337.GP4805@pendragon.ideasonboard.com>","date":"2019-04-02T17:33:37","subject":"Re: [libcamera-devel] [PATCH v7 04/13] libcamera: ipu3: Cache the\n\tsensor 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 07:29:29PM +0200, Jacopo Mondi wrote:\n> On Tue, Apr 02, 2019 at 08:22:35PM +0300, Laurent Pinchart wrote:\n> > On Tue, Apr 02, 2019 at 07:13:00PM +0200, Jacopo Mondi wrote:\n> >> Cache the sensor maximum size and the media bus code used to produce\n> >> it.\n> >>\n> >> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> >> ---\n> >>  src/libcamera/pipeline/ipu3/ipu3.cpp | 47 ++++++++++++++++++++++++++++\n> >>  1 file changed, 47 insertions(+)\n> >>\n> >> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> >> index a870b325f4b3..1e315048738b 100644\n> >> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> >> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> >> @@ -8,6 +8,8 @@\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> >> @@ -24,6 +26,22 @@ namespace libcamera {\n> >>\n> >>  LOG_DEFINE_CATEGORY(IPU3)\n> >>\n> >> +static int mediaBusToCIO2Format(unsigned int code)\n> >\n> > I wonder why I hadn't thought about this before, would it make sense to\n> > move this function to the CIO2Device class, make it static, and rename\n> > it to mediaBusToPixelFormat (or just mediaBusToFormat) ?\n> \n> It might make sense, I guess.\n> \n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> With or without the above change?\n\nEither, but if you can make the change it's even better :-)\n\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 CIO2Device\n> >>  {\n> >>  public:\n> >> @@ -44,6 +62,10 @@ public:\n> >>  \tV4L2Device *output_;\n> >>  \tV4L2Subdevice *csi2_;\n> >>  \tV4L2Subdevice *sensor_;\n> >> +\n> >> +\t/* Maximum sizes and the mbus code used to produce them. */\n> >> +\tunsigned int mbusCode_;\n> >> +\tSize maxSize_;\n> >>  };\n> >>\n> >>  class PipelineHandlerIPU3 : public PipelineHandler\n> >> @@ -442,6 +464,10 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n> >>  \t\treturn ret;\n> >>\n> >>  \t/*\n> >> +\t * Now that we're sure a sensor subdevice is connected, make sure it\n> >> +\t * produces at least one image format compatible with CIO2 requirements\n> >> +\t * and cache the camera maximum size.\n> >> +\t *\n> >>  \t * \\todo Define when to open and close video device nodes, as they\n> >>  \t * might impact on power consumption.\n> >>  \t */\n> >> @@ -450,6 +476,27 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n> >>  \tif (ret)\n> >>  \t\treturn ret;\n> >>\n> >> +\tfor (auto it : sensor_->formats(0)) {\n> >> +\t\tint mbusCode = mediaBusToCIO2Format(it.first);\n> >> +\t\tif (mbusCode < 0)\n> >> +\t\t\tcontinue;\n> >> +\n> >> +\t\tfor (const SizeRange &size : it.second) {\n> >> +\t\t\tif (maxSize_.width < size.maxWidth &&\n> >> +\t\t\t    maxSize_.height < size.maxHeight) {\n> >> +\t\t\t\tmaxSize_.width = size.maxWidth;\n> >> +\t\t\t\tmaxSize_.height = size.maxHeight;\n> >> +\t\t\t\tmbusCode_ = mbusCode;\n> >> +\t\t\t}\n> >> +\t\t}\n> >> +\t}\n> >> +\tif (maxSize_.width == 0) {\n> >> +\t\tLOG(IPU3, Info) << \"Sensor '\" << sensor_->entityName()\n> >> +\t\t\t\t<< \"' detected, but no supported image format \"\n> >> +\t\t\t\t<< \" found: skip camera creation\";\n> >> +\t\treturn -ENODEV;\n> >> +\t}\n> >> +\n> >>  \tcsi2_ = new V4L2Subdevice(csi2Entity);\n> >>  \tret = csi2_->open();\n> >>  \tif (ret)","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 22CE8610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 19:33:48 +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 A49B22F9;\n\tTue,  2 Apr 2019 19:33:47 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1554226427;\n\tbh=82xHK6UgfZc+zumRc8lkHHj313lk9KC8XH83WuJTB8U=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=NfEyM6eVWuloU73Gs//SP7GIKJZfPbIGl2lIU19mxyxocEBJtUpTr6X/tlTPBbG0Y\n\t7dqv/Hzfghs6DeHJLx+VCnMI4nypjwMfVdPK+32lWbnry2BcLTBENZBB4Xu3pPtckZ\n\t2RftonQIk/Jri4t1aj+iYZaf0aQtaQsk76VxA/m4=","Date":"Tue, 2 Apr 2019 20:33:37 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190402173337.GP4805@pendragon.ideasonboard.com>","References":"<20190402171309.6447-1-jacopo@jmondi.org>\n\t<20190402171309.6447-5-jacopo@jmondi.org>\n\t<20190402172235.GN4805@pendragon.ideasonboard.com>\n\t<20190402172929.swz5apo2zqahypn7@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190402172929.swz5apo2zqahypn7@uno.localdomain>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v7 04/13] libcamera: ipu3: Cache the\n\tsensor 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 17:33:48 -0000"}},{"id":1227,"web_url":"https://patchwork.libcamera.org/comment/1227/","msgid":"<20190402181436.GB23466@bigcity.dyn.berto.se>","date":"2019-04-02T18:14:36","subject":"Re: [libcamera-devel] [PATCH v7 04/13] libcamera: ipu3: Cache the\n\tsensor 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 patch.\n\nOn 2019-04-02 19:13:00 +0200, Jacopo Mondi wrote:\n> Cache the sensor maximum size and the media bus code used to produce\n> it.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n\nWith or without addressing Laurents comment about moving \nmediaBusToCIO2Format(),\n\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nI actually prefer it the way it is, a file local static helper function, \nbut I don't feel strongly about it :-)\n\n> ---\n>  src/libcamera/pipeline/ipu3/ipu3.cpp | 47 ++++++++++++++++++++++++++++\n>  1 file changed, 47 insertions(+)\n> \n> diff --git a/src/libcamera/pipeline/ipu3/ipu3.cpp b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> index a870b325f4b3..1e315048738b 100644\n> --- a/src/libcamera/pipeline/ipu3/ipu3.cpp\n> +++ b/src/libcamera/pipeline/ipu3/ipu3.cpp\n> @@ -8,6 +8,8 @@\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> @@ -24,6 +26,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 CIO2Device\n>  {\n>  public:\n> @@ -44,6 +62,10 @@ public:\n>  \tV4L2Device *output_;\n>  \tV4L2Subdevice *csi2_;\n>  \tV4L2Subdevice *sensor_;\n> +\n> +\t/* Maximum sizes and the mbus code used to produce them. */\n> +\tunsigned int mbusCode_;\n> +\tSize maxSize_;\n>  };\n>  \n>  class PipelineHandlerIPU3 : public PipelineHandler\n> @@ -442,6 +464,10 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>  \t\treturn ret;\n>  \n>  \t/*\n> +\t * Now that we're sure a sensor subdevice is connected, make sure it\n> +\t * produces at least one image format compatible with CIO2 requirements\n> +\t * and cache the camera maximum size.\n> +\t *\n>  \t * \\todo Define when to open and close video device nodes, as they\n>  \t * might impact on power consumption.\n>  \t */\n> @@ -450,6 +476,27 @@ int CIO2Device::init(const MediaDevice *media, unsigned int index)\n>  \tif (ret)\n>  \t\treturn ret;\n>  \n> +\tfor (auto it : sensor_->formats(0)) {\n> +\t\tint mbusCode = mediaBusToCIO2Format(it.first);\n> +\t\tif (mbusCode < 0)\n> +\t\t\tcontinue;\n> +\n> +\t\tfor (const SizeRange &size : it.second) {\n> +\t\t\tif (maxSize_.width < size.maxWidth &&\n> +\t\t\t    maxSize_.height < size.maxHeight) {\n> +\t\t\t\tmaxSize_.width = size.maxWidth;\n> +\t\t\t\tmaxSize_.height = size.maxHeight;\n> +\t\t\t\tmbusCode_ = mbusCode;\n> +\t\t\t}\n> +\t\t}\n> +\t}\n> +\tif (maxSize_.width == 0) {\n> +\t\tLOG(IPU3, Info) << \"Sensor '\" << sensor_->entityName()\n> +\t\t\t\t<< \"' detected, but no supported image format \"\n> +\t\t\t\t<< \" found: skip camera creation\";\n> +\t\treturn -ENODEV;\n> +\t}\n> +\n>  \tcsi2_ = new V4L2Subdevice(csi2Entity);\n>  \tret = csi2_->open();\n>  \tif (ret)\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 C92EE610B6\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue,  2 Apr 2019 20:14:38 +0200 (CEST)","by mail-lf1-x141.google.com with SMTP id r25so9705309lfn.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 02 Apr 2019 11:14:38 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\tf25sm2058999lfk.69.2019.04.02.11.14.37\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tTue, 02 Apr 2019 11:14:37 -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=JosyjV814fQ7FiQPFtEtZBvsfNXTskuHp83QRZj/BA8=;\n\tb=DC3c2f6hjhL8z/ns1sKSgBRdqELMGHR7NqGMTBxgn+v8+iCHXr3xsKY5s1cS1+UXXm\n\tGgd0L6LIAi+4qMVscHMpVFefrdxjSgycKz5NfDThMZVSQQOeiDqir9sODatBWWyrBqdB\n\tQ2OP/E15xHVSRkhuq3QLKkwIhwhXHVvP/JzoqVDEmsvY79ioS0NXaZYzAT3ZG7uOmzzG\n\t5gVnkedMpM6H7LPR31YtTH2lRBtyVy0Zlv64jdj6jenvYeevMIl6a3asrfly88DNF5Rm\n\tithZyRg1WjxVbIUPM/wCJOP8gWx04LO0hDb7c+LLkCIAhiprD4HFtyyyQ2ApnyTPM0Ld\n\tUjgQ==","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=JosyjV814fQ7FiQPFtEtZBvsfNXTskuHp83QRZj/BA8=;\n\tb=awouGmuIXgGc/kJYVl4BnmNyoSeOAJ5j5dwMgPxr5JfAikkJ6AHffgOA5bdbazs66L\n\tUUEPl9/nyuqd5ob5Klj1axuB4csPGHhxW9fQkIgW1wg55YPSDmme2Ozp8oIO18ya7sfG\n\tta7/TkZLCMJWm4GMFGpMNYeMN89BoOEYlvXjnHMjkiXAMTjZpoTPCdlYdgmxJ+B6Es55\n\tSxUAOD75FOd5hwr+u1TMbnL5V4o7vLxe4CnndQ/Jy28nRfgKyqQ9Al2+bM9q5OB6QOhh\n\tW4/eLO77fbMd/v1u0Nak2m7lBMNXhstumtOd0g9kP900LCdQ36RJIm9WMuxX97cc7eW2\n\tTYNA==","X-Gm-Message-State":"APjAAAUWoXD6xEU9AVXyql7Bjdp3JZmCtrpusivcMA9sziQAfYf025al\n\tVlYVizPYwLhEnck8qFaXqNha9XPz3V8=","X-Google-Smtp-Source":"APXvYqxdCJtzedU6rXVQF1A+5lOBeqKXs02Qg6Lpr9oCR8emVZav/kTraR0r4kQyFliFhZ92N0Ws9w==","X-Received":"by 2002:ac2:5966:: with SMTP id h6mr24543398lfp.86.1554228878037;\n\tTue, 02 Apr 2019 11:14:38 -0700 (PDT)","Date":"Tue, 2 Apr 2019 20:14:36 +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":"<20190402181436.GB23466@bigcity.dyn.berto.se>","References":"<20190402171309.6447-1-jacopo@jmondi.org>\n\t<20190402171309.6447-5-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":"<20190402171309.6447-5-jacopo@jmondi.org>","User-Agent":"Mutt/1.11.3 (2019-02-01)","Subject":"Re: [libcamera-devel] [PATCH v7 04/13] libcamera: ipu3: Cache the\n\tsensor 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 18:14:39 -0000"}}]