[{"id":2842,"web_url":"https://patchwork.libcamera.org/comment/2842/","msgid":"<20191009092350.6vdwtg6q7jb4tvg7@uno.localdomain>","date":"2019-10-09T09:23:50","subject":"Re: [libcamera-devel] [PATCH 8/9] libcamera: v4l2_controls: Remove\n\tV4L2ControlInfo type field","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Tue, Oct 08, 2019 at 01:46:41AM +0300, Laurent Pinchart wrote:\n> The V4L2ControlInfo type field stores the V4L2 control type. It partly\n> duplicates the V4L2ControlInfo id().type() that stores the corresponding\n> libcamera control type. The two fields are not strictly identical, but\n> having two types doesn't provide us with any extra value. As this is\n> confusing, remove the V4L2ControlInfo type field.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n\n\n> ---\n>  src/libcamera/include/v4l2_controls.h |  2 --\n>  src/libcamera/v4l2_controls.cpp       |  7 -------\n>  src/libcamera/v4l2_device.cpp         | 10 +++++-----\n>  3 files changed, 5 insertions(+), 14 deletions(-)\n>\n> diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\n> index 1d85ecf9864a..133ab9ec208b 100644\n> --- a/src/libcamera/include/v4l2_controls.h\n> +++ b/src/libcamera/include/v4l2_controls.h\n> @@ -31,14 +31,12 @@ public:\n>  \tV4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl);\n>\n>  \tconst ControlId &id() const { return id_; }\n> -\tunsigned int type() const { return type_; }\n\nHave you considered\n\tunsigned int type() const { return id_.type(); }\n?\n\nEither ways:\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n\n>  \tsize_t size() const { return size_; }\n>\n>  \tconst ControlRange &range() const { return range_; }\n>\n>  private:\n>  \tV4L2ControlId id_;\n> -\tunsigned int type_;\n>  \tsize_t size_;\n>\n>  \tControlRange range_;\n> diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\n> index 98b2b3fe9d0a..d3f94709e821 100644\n> --- a/src/libcamera/v4l2_controls.cpp\n> +++ b/src/libcamera/v4l2_controls.cpp\n> @@ -127,7 +127,6 @@ V4L2ControlId::V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl)\n>  V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n>  \t: id_(ctrl)\n>  {\n> -\ttype_ = ctrl.type;\n>  \tsize_ = ctrl.elem_size * ctrl.elems;\n>\n>  \tif (ctrl.type == V4L2_CTRL_TYPE_INTEGER64)\n> @@ -144,12 +143,6 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n>   * \\return The V4L2 control ID\n>   */\n>\n> -/**\n> - * \\fn V4L2ControlInfo::type()\n> - * \\brief Retrieve the control type as defined by V4L2_CTRL_TYPE_*\n> - * \\return The V4L2 control type\n> - */\n> -\n>  /**\n>   * \\fn V4L2ControlInfo::size()\n>   * \\brief Retrieve the control value data size (in bytes)\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 50616571dcef..b64e5068a671 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -269,8 +269,8 @@ int V4L2Device::setControls(ControlList *ctrls)\n>\n>  \t\t/* Set the v4l2_ext_control value for the write operation. */\n>  \t\tconst ControlValue &value = ctrl.second;\n> -\t\tswitch (info->type()) {\n> -\t\tcase V4L2_CTRL_TYPE_INTEGER64:\n> +\t\tswitch (info->id().type()) {\n> +\t\tcase ControlTypeInteger64:\n>  \t\t\tv4l2Ctrls[i].value64 = value.get<int64_t>();\n>  \t\t\tbreak;\n>  \t\tdefault:\n> @@ -278,7 +278,7 @@ int V4L2Device::setControls(ControlList *ctrls)\n>  \t\t\t * \\todo To be changed when support for string and\n>  \t\t\t * compound controls will be added.\n>  \t\t\t */\n> -\t\t\tv4l2Ctrls[i].value64 = value.get<int32_t>();\n> +\t\t\tv4l2Ctrls[i].value = value.get<int32_t>();\n>  \t\t\tbreak;\n>  \t\t}\n>\n> @@ -402,8 +402,8 @@ void V4L2Device::updateControls(ControlList *ctrls,\n>  \t\tconst V4L2ControlInfo *info = controlInfo[i];\n>  \t\tControlValue &value = ctrl.second;\n>\n> -\t\tswitch (info->type()) {\n> -\t\tcase V4L2_CTRL_TYPE_INTEGER64:\n> +\t\tswitch (info->id().type()) {\n> +\t\tcase ControlTypeInteger64:\n>  \t\t\tvalue.set<int64_t>(v4l2Ctrl->value64);\n>  \t\t\tbreak;\n>  \t\tdefault:\n> --\n> Regards,\n>\n> Laurent Pinchart\n>\n> _______________________________________________\n> libcamera-devel mailing list\n> libcamera-devel@lists.libcamera.org\n> https://lists.libcamera.org/listinfo/libcamera-devel","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B0ABA6157B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Oct 2019 11:22:04 +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 relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 4641240013;\n\tWed,  9 Oct 2019 09:22:04 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Wed, 9 Oct 2019 11:23:50 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191009092350.6vdwtg6q7jb4tvg7@uno.localdomain>","References":"<20191007224642.6597-1-laurent.pinchart@ideasonboard.com>\n\t<20191007224642.6597-9-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"sltazipjwkk2tawc\"","Content-Disposition":"inline","In-Reply-To":"<20191007224642.6597-9-laurent.pinchart@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH 8/9] libcamera: v4l2_controls: Remove\n\tV4L2ControlInfo type field","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":"Wed, 09 Oct 2019 09:22:04 -0000"}},{"id":2845,"web_url":"https://patchwork.libcamera.org/comment/2845/","msgid":"<20191009094136.GJ22998@pendragon.ideasonboard.com>","date":"2019-10-09T09:41:36","subject":"Re: [libcamera-devel] [PATCH 8/9] libcamera: v4l2_controls: Remove\n\tV4L2ControlInfo type field","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn Wed, Oct 09, 2019 at 11:23:50AM +0200, Jacopo Mondi wrote:\n> On Tue, Oct 08, 2019 at 01:46:41AM +0300, Laurent Pinchart wrote:\n> > The V4L2ControlInfo type field stores the V4L2 control type. It partly\n> > duplicates the V4L2ControlInfo id().type() that stores the corresponding\n> > libcamera control type. The two fields are not strictly identical, but\n> > having two types doesn't provide us with any extra value. As this is\n> > confusing, remove the V4L2ControlInfo type field.\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/libcamera/include/v4l2_controls.h |  2 --\n> >  src/libcamera/v4l2_controls.cpp       |  7 -------\n> >  src/libcamera/v4l2_device.cpp         | 10 +++++-----\n> >  3 files changed, 5 insertions(+), 14 deletions(-)\n> >\n> > diff --git a/src/libcamera/include/v4l2_controls.h b/src/libcamera/include/v4l2_controls.h\n> > index 1d85ecf9864a..133ab9ec208b 100644\n> > --- a/src/libcamera/include/v4l2_controls.h\n> > +++ b/src/libcamera/include/v4l2_controls.h\n> > @@ -31,14 +31,12 @@ public:\n> >  \tV4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl);\n> >\n> >  \tconst ControlId &id() const { return id_; }\n> > -\tunsigned int type() const { return type_; }\n> \n> Have you considered\n> \tunsigned int type() const { return id_.type(); }\n> ?\n\nI think that would be the worst of both worlds :-) If the type can be\nretrieved from id(), I don't think we should create an alias here. It\nwould be slightly shorter for callers, but quite confusing I think as a\ntype() method on a V4L2ControlInfo can be expected to return the V4L2\ncontrol type.\n\n> Either ways:\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> >  \tsize_t size() const { return size_; }\n> >\n> >  \tconst ControlRange &range() const { return range_; }\n> >\n> >  private:\n> >  \tV4L2ControlId id_;\n> > -\tunsigned int type_;\n> >  \tsize_t size_;\n> >\n> >  \tControlRange range_;\n> > diff --git a/src/libcamera/v4l2_controls.cpp b/src/libcamera/v4l2_controls.cpp\n> > index 98b2b3fe9d0a..d3f94709e821 100644\n> > --- a/src/libcamera/v4l2_controls.cpp\n> > +++ b/src/libcamera/v4l2_controls.cpp\n> > @@ -127,7 +127,6 @@ V4L2ControlId::V4L2ControlId(const struct v4l2_query_ext_ctrl &ctrl)\n> >  V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n> >  \t: id_(ctrl)\n> >  {\n> > -\ttype_ = ctrl.type;\n> >  \tsize_ = ctrl.elem_size * ctrl.elems;\n> >\n> >  \tif (ctrl.type == V4L2_CTRL_TYPE_INTEGER64)\n> > @@ -144,12 +143,6 @@ V4L2ControlInfo::V4L2ControlInfo(const struct v4l2_query_ext_ctrl &ctrl)\n> >   * \\return The V4L2 control ID\n> >   */\n> >\n> > -/**\n> > - * \\fn V4L2ControlInfo::type()\n> > - * \\brief Retrieve the control type as defined by V4L2_CTRL_TYPE_*\n> > - * \\return The V4L2 control type\n> > - */\n> > -\n> >  /**\n> >   * \\fn V4L2ControlInfo::size()\n> >   * \\brief Retrieve the control value data size (in bytes)\n> > diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> > index 50616571dcef..b64e5068a671 100644\n> > --- a/src/libcamera/v4l2_device.cpp\n> > +++ b/src/libcamera/v4l2_device.cpp\n> > @@ -269,8 +269,8 @@ int V4L2Device::setControls(ControlList *ctrls)\n> >\n> >  \t\t/* Set the v4l2_ext_control value for the write operation. */\n> >  \t\tconst ControlValue &value = ctrl.second;\n> > -\t\tswitch (info->type()) {\n> > -\t\tcase V4L2_CTRL_TYPE_INTEGER64:\n> > +\t\tswitch (info->id().type()) {\n> > +\t\tcase ControlTypeInteger64:\n> >  \t\t\tv4l2Ctrls[i].value64 = value.get<int64_t>();\n> >  \t\t\tbreak;\n> >  \t\tdefault:\n> > @@ -278,7 +278,7 @@ int V4L2Device::setControls(ControlList *ctrls)\n> >  \t\t\t * \\todo To be changed when support for string and\n> >  \t\t\t * compound controls will be added.\n> >  \t\t\t */\n> > -\t\t\tv4l2Ctrls[i].value64 = value.get<int32_t>();\n> > +\t\t\tv4l2Ctrls[i].value = value.get<int32_t>();\n> >  \t\t\tbreak;\n> >  \t\t}\n> >\n> > @@ -402,8 +402,8 @@ void V4L2Device::updateControls(ControlList *ctrls,\n> >  \t\tconst V4L2ControlInfo *info = controlInfo[i];\n> >  \t\tControlValue &value = ctrl.second;\n> >\n> > -\t\tswitch (info->type()) {\n> > -\t\tcase V4L2_CTRL_TYPE_INTEGER64:\n> > +\t\tswitch (info->id().type()) {\n> > +\t\tcase ControlTypeInteger64:\n> >  \t\t\tvalue.set<int64_t>(v4l2Ctrl->value64);\n> >  \t\t\tbreak;\n> >  \t\tdefault:","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 701FC6157B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  9 Oct 2019 11:41:39 +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 763224FF;\n\tWed,  9 Oct 2019 11:41:38 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570614099;\n\tbh=beneu/vrKaOIpHy6WeA0HJMp1PPP1ee9INWLULYbYOA=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=IBhPORPl5P4xL2y+0d/D3XeC3Y/9NkUGNMFwDh9kLsVLGX7qxpyBAOBj4Km33ppTU\n\tXSHjNPO5xVNH3oqklygCLr6LrXrl9nreNv5tigWjZC9S26H05arNXsiSvakex7H8uk\n\t1Q7pGvhddFNxNQYP2iEuJnH0V07B2nRGdlZ4g730=","Date":"Wed, 9 Oct 2019 12:41:36 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20191009094136.GJ22998@pendragon.ideasonboard.com>","References":"<20191007224642.6597-1-laurent.pinchart@ideasonboard.com>\n\t<20191007224642.6597-9-laurent.pinchart@ideasonboard.com>\n\t<20191009092350.6vdwtg6q7jb4tvg7@uno.localdomain>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20191009092350.6vdwtg6q7jb4tvg7@uno.localdomain>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 8/9] libcamera: v4l2_controls: Remove\n\tV4L2ControlInfo type field","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":"Wed, 09 Oct 2019 09:41:39 -0000"}}]