[{"id":23799,"web_url":"https://patchwork.libcamera.org/comment/23799/","msgid":"<YsdODtMSMLd406xQ@pendragon.ideasonboard.com>","date":"2022-07-07T21:20:14","subject":"Re: [libcamera-devel] [PATCH 2/4] libcamera: v4l2_pixelformat: Use\n\tmultiplanar if single is unavailable","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nThank you for the patch.\n\nOn Fri, Jul 08, 2022 at 12:03:08AM +0900, Paul Elder via libcamera-devel wrote:\n> Some formats, such as YVU422 (but *not* YUV422), YUV444, and YVU444,\n> have only a multiplanar v4l2 format and no singleplanar format. When\n> using V4L2PixelFormat::fromPixelFormat() to convert a libcamera format\n> to V4L2PixelFormat, the default is to fetch the singleplanar format, and\n> for those three formats an invalid format will be returned. The caller\n> shouldn't be expected to check first if it should request the\n> singleplanar or multiplanar version (that's the whole point of\n> V4L2PixelFormat::fromPixelFormat()), so the solution that this patch\n> implements is if fetching singleplanar/multiplanar fails, try fetching\n> the other one.\n> \n> The side effect is that as most formats have only singleplanar v4l2\n> format and no multiplanar format, if a multiplanar format is request for\n> these formats then the singleplanar one will be automatically returned.\n> Since currently all callers of V4L2PixelFormat::fromPixelFormat() use\n> the default singleplanar call, it is reasoned that this is not an issue.\n\nJacopo is planning to rework this to add JPEG support in addition to\nMJPEG, with a mechanism that should address your problem in a better way\n(taking into account the formats actually supported by the device). We\ncould merge this as a quick workaround, but if there's no urgency, I'd\nwait for Jacopo's patch.\n\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n>  src/libcamera/v4l2_pixelformat.cpp | 9 ++++++++-\n>  1 file changed, 8 insertions(+), 1 deletion(-)\n> \n> diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\n> index 58fc4e9d..0d2bc350 100644\n> --- a/src/libcamera/v4l2_pixelformat.cpp\n> +++ b/src/libcamera/v4l2_pixelformat.cpp\n> @@ -321,7 +321,14 @@ V4L2PixelFormat V4L2PixelFormat::fromPixelFormat(const PixelFormat &pixelFormat,\n>  \tif (!info.isValid())\n>  \t\treturn V4L2PixelFormat();\n>  \n> -\treturn multiplanar ? info.v4l2Formats.multi : info.v4l2Formats.single;\n> +\tV4L2PixelFormat ret = multiplanar ? info.v4l2Formats.multi\n> +\t\t\t\t\t  : info.v4l2Formats.single;\n> +\t/* Try the other of multi/single if the proper one doesn't exist */\n> +\tif (!ret.isValid())\n> +\t\tret = multiplanar ? info.v4l2Formats.single\n> +\t\t\t\t  : info.v4l2Formats.multi;\n> +\n> +\treturn ret;\n>  }\n>  \n>  /**","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 BEE73BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu,  7 Jul 2022 21:20:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 2F78A6043F;\n\tThu,  7 Jul 2022 23:20:43 +0200 (CEST)","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 7BFF260400\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu,  7 Jul 2022 23:20:41 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B18F2D01;\n\tThu,  7 Jul 2022 23:20:40 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657228843;\n\tbh=HSAPa36ZAWaG1MSPo3ZBs++mF8qGXWdXenj6d8CnZ3Q=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=WszOAWNVqyX2zVyEhCxEXdaMK8f9N0RRbj25lTuhQHz3VKKRGI+oFfsQHrwo0QyGH\n\tKYndOST4wZGaMUnemJnANIpVhuS62ZsY8ty+MyFB7ZO2HO68aywqFKNuGT0VtLO9dE\n\tDCuBmWCqp9qp5P+wJGZc84MFWObwAYOT1bKBE2ovRtwU5DY5a/5RSz8y6jqXr+ykgu\n\tgMit/LDecZuSM2873OgWlfe+MXL60p0JxIuUi5yxBkqJBpbKvzd45ZyL/saTb2v+K3\n\tZMcLNIHBwwYBwby60ThF4EpD8CWgIgutMSTI/XSBb0HKc59ZoDl2EhXy9pUUEVkLSe\n\tx6zed30iT+M9Q==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1657228840;\n\tbh=HSAPa36ZAWaG1MSPo3ZBs++mF8qGXWdXenj6d8CnZ3Q=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=gFUrgD0+WpO1qhw2sQdbVQN4cPQopyib/MTYPpqdR6lCTygSdomxSY8A4ykCX3w60\n\txZfYAG0ePCsn1C6LYIpJ8gFY/rEhrANwD7dkK+PVQjt9GStCgqL6eRbLHLolNFuzX+\n\tpmW0ZRANAGF4q5nPmu0/mrW0iuehVO9YwzJDjxEQ="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"gFUrgD0+\"; dkim-atps=neutral","Date":"Fri, 8 Jul 2022 00:20:14 +0300","To":"Paul Elder <paul.elder@ideasonboard.com>","Message-ID":"<YsdODtMSMLd406xQ@pendragon.ideasonboard.com>","References":"<20220707150310.3645858-1-paul.elder@ideasonboard.com>\n\t<20220707150310.3645858-3-paul.elder@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220707150310.3645858-3-paul.elder@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/4] libcamera: v4l2_pixelformat: Use\n\tmultiplanar if single is unavailable","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":23934,"web_url":"https://patchwork.libcamera.org/comment/23934/","msgid":"<20220715125042.GH3411283@pyrite.rasen.tech>","date":"2022-07-15T12:50:42","subject":"Re: [libcamera-devel] [PATCH 2/4] libcamera: v4l2_pixelformat: Use\n\tmultiplanar if single is unavailable","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"On Fri, Jul 08, 2022 at 12:20:14AM +0300, Laurent Pinchart wrote:\n> Hi Paul,\n> \n> Thank you for the patch.\n> \n> On Fri, Jul 08, 2022 at 12:03:08AM +0900, Paul Elder via libcamera-devel wrote:\n> > Some formats, such as YVU422 (but *not* YUV422), YUV444, and YVU444,\n> > have only a multiplanar v4l2 format and no singleplanar format. When\n> > using V4L2PixelFormat::fromPixelFormat() to convert a libcamera format\n> > to V4L2PixelFormat, the default is to fetch the singleplanar format, and\n> > for those three formats an invalid format will be returned. The caller\n> > shouldn't be expected to check first if it should request the\n> > singleplanar or multiplanar version (that's the whole point of\n> > V4L2PixelFormat::fromPixelFormat()), so the solution that this patch\n> > implements is if fetching singleplanar/multiplanar fails, try fetching\n> > the other one.\n> > \n> > The side effect is that as most formats have only singleplanar v4l2\n> > format and no multiplanar format, if a multiplanar format is request for\n> > these formats then the singleplanar one will be automatically returned.\n> > Since currently all callers of V4L2PixelFormat::fromPixelFormat() use\n> > the default singleplanar call, it is reasoned that this is not an issue.\n> \n> Jacopo is planning to rework this to add JPEG support in addition to\n> MJPEG, with a mechanism that should address your problem in a better way\n> (taking into account the formats actually supported by the device). We\n> could merge this as a quick workaround, but if there's no urgency, I'd\n> wait for Jacopo's patch.\n\nYeah I guess we could wait then.\n\nI'll change the next patch to just YUV422 then.\n\n\nPaul\n\n> \n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > ---\n> >  src/libcamera/v4l2_pixelformat.cpp | 9 ++++++++-\n> >  1 file changed, 8 insertions(+), 1 deletion(-)\n> > \n> > diff --git a/src/libcamera/v4l2_pixelformat.cpp b/src/libcamera/v4l2_pixelformat.cpp\n> > index 58fc4e9d..0d2bc350 100644\n> > --- a/src/libcamera/v4l2_pixelformat.cpp\n> > +++ b/src/libcamera/v4l2_pixelformat.cpp\n> > @@ -321,7 +321,14 @@ V4L2PixelFormat V4L2PixelFormat::fromPixelFormat(const PixelFormat &pixelFormat,\n> >  \tif (!info.isValid())\n> >  \t\treturn V4L2PixelFormat();\n> >  \n> > -\treturn multiplanar ? info.v4l2Formats.multi : info.v4l2Formats.single;\n> > +\tV4L2PixelFormat ret = multiplanar ? info.v4l2Formats.multi\n> > +\t\t\t\t\t  : info.v4l2Formats.single;\n> > +\t/* Try the other of multi/single if the proper one doesn't exist */\n> > +\tif (!ret.isValid())\n> > +\t\tret = multiplanar ? info.v4l2Formats.single\n> > +\t\t\t\t  : info.v4l2Formats.multi;\n> > +\n> > +\treturn ret;\n> >  }\n> >  \n> >  /**","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 5276EBD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 15 Jul 2022 12:50:54 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id BE0116330E;\n\tFri, 15 Jul 2022 14:50:53 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id A209B6330A\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 15 Jul 2022 14:50:51 +0200 (CEST)","from pyrite.rasen.tech (softbank036240121080.bbtec.net\n\t[36.240.121.80])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A0521993;\n\tFri, 15 Jul 2022 14:50:49 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657889453;\n\tbh=+W2HBf11wyj2vjo938WHPO/nLa/59iBFMow2xIES7OA=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=1/RwKH8oUYQ+kU38eCez+eqE8PwkAF23gi1T2q4IA5g25lC2D+LHC33gPZVYG4cpt\n\t6l51ekh9KQH3f3fNNV8aBphKJX369r7LeQ6KTJSeVwRKQBQppRj2R1D2SBwwwd+0En\n\taFn9cbh86b/PwucZvAaYc7I4kKzxy2nGKZYzd1h27JsNmjkBusiHHZggrAhD8UVyeJ\n\t/tqN9HrDAqKb8idK8kIAxwF9Z5xiAYSdnzQAj6vPh5ZaCJkJGS5pXZWodWI6do3x8u\n\t4eQm0gJHKfLz5tardXKRpbnhed2POFcSofvl7f4O4aPW74L8A5Tk00Qoc+QSViml/k\n\tZosIEDYgp9u7A==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1657889451;\n\tbh=+W2HBf11wyj2vjo938WHPO/nLa/59iBFMow2xIES7OA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=SOEZ7VBhHCNUUVrozmNvqjr7eanmUwgnGzmUWTp8H8c9uPV6JhSdZ01//2ocLbPRI\n\tiIsyv8fVyniflDQBcKEApiniYP/cshjbUUBfslDf2e9IN8HSl9IIl1AlsOtK2G+iJF\n\tol8JuVJp6in67XIPFb6EtjGpu0sjEYKxBp5JEThw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"SOEZ7VBh\"; dkim-atps=neutral","Date":"Fri, 15 Jul 2022 21:50:42 +0900","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220715125042.GH3411283@pyrite.rasen.tech>","References":"<20220707150310.3645858-1-paul.elder@ideasonboard.com>\n\t<20220707150310.3645858-3-paul.elder@ideasonboard.com>\n\t<YsdODtMSMLd406xQ@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<YsdODtMSMLd406xQ@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH 2/4] libcamera: v4l2_pixelformat: Use\n\tmultiplanar if single is unavailable","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>","From":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]