[{"id":4156,"web_url":"https://patchwork.libcamera.org/comment/4156/","msgid":"<20200320213027.GR5193@pendragon.ideasonboard.com>","date":"2020-03-20T21:30:27","subject":"Re: [libcamera-devel] [PATCH 08/11] licamera: v4l2_device: Support\n\treading U8 array controls","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 Mon, Mar 09, 2020 at 05:24:11PM +0100, Jacopo Mondi wrote:\n> Add support to retrieve the value of array controls of type\n> V4L2_CTRL_TYPE_U8.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  src/libcamera/v4l2_device.cpp | 26 ++++++++++++++++++++++++++\n>  1 file changed, 26 insertions(+)\n> \n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 950e6286b84d..464df6a1fe18 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -185,6 +185,22 @@ int V4L2Device::getControls(ControlList *ctrls)\n>  \t\t\treturn -EINVAL;\n>  \t\t}\n>  \n> +\t\tconst struct v4l2_query_ext_ctrl &info = ctrlsInfo_[id];\n> +\t\tif (info.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD) {\n> +\t\t\tif (info.type != V4L2_CTRL_TYPE_U8) {\n> +\t\t\t\t/*\n> +\t\t\t\t * \\todo Fail loudly to notify support for\n> +\t\t\t\t * other array control types is not implemented.\n> +\t\t\t\t */\n> +\t\t\t\tLOG(V4L2, Error) << \"Unsupported type\";\n> +\t\t\t\treturn -EINVAL;\n> +\t\t\t}\n> +\n> +\t\t\tsize_t sizeBytes = info.elems * info.elem_size;\n> +\t\t\tv4l2Ctrls[i].p_u8 = new uint8_t[sizeBytes];\n> +\t\t\tv4l2Ctrls[i].size = sizeBytes;\n\nHaving to allocate extra memory here isn't very nice :-S I think that we\nshould try to instead write directly in the ControlValue data,\nespecially given that the updateControls() function should lose handling\nof the V4L2_CTRL_TYPE_U8 type as explained in the review of patch 07/11.\nI have a patch to implement this in ControlValue, I'll send it.\n\n> +\t\t}\n> +\n>  \t\tv4l2Ctrls[i].id = id;\n>  \t\ti++;\n>  \t}\n> @@ -214,6 +230,16 @@ int V4L2Device::getControls(ControlList *ctrls)\n>  \n>  \tupdateControls(ctrls, v4l2Ctrls, count);\n>  \n> +\t/* Release memory reserved for array controls. */\n> +\tfor (unsigned int i = 0; i < count; i++) {\n> +\t\tunsigned int id = v4l2Ctrls[i].id;\n> +\t\tconst struct v4l2_query_ext_ctrl &info = ctrlsInfo_[id];\n> +\n> +\t\t/* \\todo Adjust to support more array control types. */\n> +\t\tif (info.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD)\n> +\t\t\tdelete[] v4l2Ctrls[i].p_u8;\n> +\t}\n> +\n>  \treturn ret;\n>  }\n>","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 C389C60416\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Mar 2020 22:30:33 +0100 (CET)","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 36400504;\n\tFri, 20 Mar 2020 22:30:33 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584739833;\n\tbh=B8+nr3/5TvrhDx6pyTAn/wsEEfXMUcwKbscfMs0rbrg=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=FMqnllHEVypKuaDbU3oa6dmaTGHPQzGgrMb1SSdGXVY9lyaNTAmvk4/45K6p4Kj0+\n\tsXZqTAwKpwtKg3oSwjQG27GJnRSxKklwGS/ptDm0+XGevPkoMzuSNCyHDXCMgpx+QG\n\tdNVanvapg3FNp8ivVbcdte3mOYefv/ufUXI4wUNc=","Date":"Fri, 20 Mar 2020 23:30:27 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200320213027.GR5193@pendragon.ideasonboard.com>","References":"<20200309162414.720306-1-jacopo@jmondi.org>\n\t<20200309162414.720306-9-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200309162414.720306-9-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 08/11] licamera: v4l2_device: Support\n\treading U8 array controls","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>","X-List-Received-Date":"Fri, 20 Mar 2020 21:30:34 -0000"}},{"id":4157,"web_url":"https://patchwork.libcamera.org/comment/4157/","msgid":"<20200320213057.GS5193@pendragon.ideasonboard.com>","date":"2020-03-20T21:30:57","subject":"Re: [libcamera-devel] [PATCH 08/11] licamera: v4l2_device: Support\n\treading U8 array controls","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"And s/libcamera/libcamera/ in the subject line.\n\nOn Fri, Mar 20, 2020 at 11:30:27PM +0200, Laurent Pinchart wrote:\n> On Mon, Mar 09, 2020 at 05:24:11PM +0100, Jacopo Mondi wrote:\n> > Add support to retrieve the value of array controls of type\n> > V4L2_CTRL_TYPE_U8.\n> > \n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  src/libcamera/v4l2_device.cpp | 26 ++++++++++++++++++++++++++\n> >  1 file changed, 26 insertions(+)\n> > \n> > diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> > index 950e6286b84d..464df6a1fe18 100644\n> > --- a/src/libcamera/v4l2_device.cpp\n> > +++ b/src/libcamera/v4l2_device.cpp\n> > @@ -185,6 +185,22 @@ int V4L2Device::getControls(ControlList *ctrls)\n> >  \t\t\treturn -EINVAL;\n> >  \t\t}\n> >  \n> > +\t\tconst struct v4l2_query_ext_ctrl &info = ctrlsInfo_[id];\n> > +\t\tif (info.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD) {\n> > +\t\t\tif (info.type != V4L2_CTRL_TYPE_U8) {\n> > +\t\t\t\t/*\n> > +\t\t\t\t * \\todo Fail loudly to notify support for\n> > +\t\t\t\t * other array control types is not implemented.\n> > +\t\t\t\t */\n> > +\t\t\t\tLOG(V4L2, Error) << \"Unsupported type\";\n> > +\t\t\t\treturn -EINVAL;\n> > +\t\t\t}\n> > +\n> > +\t\t\tsize_t sizeBytes = info.elems * info.elem_size;\n> > +\t\t\tv4l2Ctrls[i].p_u8 = new uint8_t[sizeBytes];\n> > +\t\t\tv4l2Ctrls[i].size = sizeBytes;\n> \n> Having to allocate extra memory here isn't very nice :-S I think that we\n> should try to instead write directly in the ControlValue data,\n> especially given that the updateControls() function should lose handling\n> of the V4L2_CTRL_TYPE_U8 type as explained in the review of patch 07/11.\n> I have a patch to implement this in ControlValue, I'll send it.\n> \n> > +\t\t}\n> > +\n> >  \t\tv4l2Ctrls[i].id = id;\n> >  \t\ti++;\n> >  \t}\n> > @@ -214,6 +230,16 @@ int V4L2Device::getControls(ControlList *ctrls)\n> >  \n> >  \tupdateControls(ctrls, v4l2Ctrls, count);\n> >  \n> > +\t/* Release memory reserved for array controls. */\n> > +\tfor (unsigned int i = 0; i < count; i++) {\n> > +\t\tunsigned int id = v4l2Ctrls[i].id;\n> > +\t\tconst struct v4l2_query_ext_ctrl &info = ctrlsInfo_[id];\n> > +\n> > +\t\t/* \\todo Adjust to support more array control types. */\n> > +\t\tif (info.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD)\n> > +\t\t\tdelete[] v4l2Ctrls[i].p_u8;\n> > +\t}\n> > +\n> >  \treturn ret;\n> >  }\n> >","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 5F75560416\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 20 Mar 2020 22:31:04 +0100 (CET)","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 E796E504;\n\tFri, 20 Mar 2020 22:31:03 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1584739864;\n\tbh=zx8rpgZZj3j/K/ttgIkGtkqdr2cUjwr918hzT3qTmjk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=bba5YGL+4Eip4lrx7m4IpjeTRCcQRFPkoFLYpSjH0XIMM3B3WWDHcF2smBG2mh1a0\n\tv+3AWkEgtETxr1TgELR/RGMEQxDOYIpFE6YzVJ6KjXXs4H5yMOOyRL+4hgTWH6OkOh\n\tiaYEyUsRkpWIQL6SN/Y5AzU0j8YcrKvUsffuzc5Q=","Date":"Fri, 20 Mar 2020 23:30:57 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20200320213057.GS5193@pendragon.ideasonboard.com>","References":"<20200309162414.720306-1-jacopo@jmondi.org>\n\t<20200309162414.720306-9-jacopo@jmondi.org>\n\t<20200320213027.GR5193@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20200320213027.GR5193@pendragon.ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 08/11] licamera: v4l2_device: Support\n\treading U8 array controls","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>","X-List-Received-Date":"Fri, 20 Mar 2020 21:31:04 -0000"}}]