[{"id":17228,"web_url":"https://patchwork.libcamera.org/comment/17228/","msgid":"<20210525090428.i2bzigm4vumjzmpr@uno.localdomain>","date":"2021-05-25T09:04:28","subject":"Re: [libcamera-devel] [PATCH] Revert \"libcamera: V4L2Device: Remove\n\tthe controls order assumption in updateControls()\"","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Tue, May 25, 2021 at 11:55:28AM +0300, Laurent Pinchart wrote:\n> This reverts commit 34bee5e84ecba01e0ded5cacbc46c277c5a0edba.\n>\n> The commit introduced a breakage in the master branch, reported by\n> linux-surface users already. Let's revert it while discussing the\n> propert fix.\n\nI see a potential fix on the list but for now let's unblock users fast\nAcked-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n   j\n\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/libcamera/v4l2_device.cpp | 26 +++++++++++++++++++-------\n>  1 file changed, 19 insertions(+), 7 deletions(-)\n>\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 7f7e5b8fdf09..caafbc2d16bb 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -244,6 +244,12 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)\n>\n>  \tControlList ctrls{ controls_ };\n>\n> +\t/*\n> +\t * Start by filling the ControlList. This can't be combined with filling\n> +\t * v4l2Ctrls, as updateControls() relies on both containers having the\n> +\t * same order, and the control list is based on a map, which is not\n> +\t * sorted by insertion order.\n> +\t */\n>  \tfor (uint32_t id : ids) {\n>  \t\tconst auto iter = controls_.find(id);\n>  \t\tif (iter == controls_.end()) {\n> @@ -617,13 +623,19 @@ void V4L2Device::updateControlInfo()\n>  void V4L2Device::updateControls(ControlList *ctrls,\n>  \t\t\t\tSpan<const v4l2_ext_control> v4l2Ctrls)\n>  {\n> -\tfor (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) {\n> -\t\tconst unsigned int id = v4l2Ctrl.id;\n> +\tunsigned int i = 0;\n> +\tfor (auto &ctrl : *ctrls) {\n> +\t\tif (i == v4l2Ctrls.size())\n> +\t\t\tbreak;\n>\n> -\t\tControlValue value = ctrls->get(id);\n> -\t\tswitch (value.type()) {\n> +\t\tconst struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i];\n> +\t\tunsigned int id = ctrl.first;\n> +\t\tControlValue &value = ctrl.second;\n> +\n> +\t\tconst auto iter = controls_.find(id);\n> +\t\tswitch (iter->first->type()) {\n>  \t\tcase ControlTypeInteger64:\n> -\t\t\tvalue.set<int64_t>(v4l2Ctrl.value64);\n> +\t\t\tvalue.set<int64_t>(v4l2Ctrl->value64);\n>  \t\t\tbreak;\n>\n>  \t\tcase ControlTypeByte:\n> @@ -638,11 +650,11 @@ void V4L2Device::updateControls(ControlList *ctrls,\n>  \t\t\t * \\todo To be changed when support for string controls\n>  \t\t\t * will be added.\n>  \t\t\t */\n> -\t\t\tvalue.set<int32_t>(v4l2Ctrl.value);\n> +\t\t\tvalue.set<int32_t>(v4l2Ctrl->value);\n>  \t\t\tbreak;\n>  \t\t}\n>\n> -\t\tctrls->set(id, value);\n> +\t\ti++;\n>  \t}\n>  }\n>\n> --\n> Regards,\n>\n> Laurent Pinchart\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 3ED0DC3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 May 2021 09:03:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 09E8768921;\n\tTue, 25 May 2021 11:03:45 +0200 (CEST)","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 EC463602AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 May 2021 11:03:42 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 5DDD01C000A;\n\tTue, 25 May 2021 09:03:42 +0000 (UTC)"],"Date":"Tue, 25 May 2021 11:04:28 +0200","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20210525090428.i2bzigm4vumjzmpr@uno.localdomain>","References":"<20210525085528.11477-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20210525085528.11477-1-laurent.pinchart@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH] Revert \"libcamera: V4L2Device: Remove\n\tthe controls order assumption in updateControls()\"","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17229,"web_url":"https://patchwork.libcamera.org/comment/17229/","msgid":"<CAO5uPHNEkrrOZ-EPtzWAEC5GdnvienMSinJwL6wg15rhVCGjNA@mail.gmail.com>","date":"2021-05-25T09:04:50","subject":"Re: [libcamera-devel] [PATCH] Revert \"libcamera: V4L2Device: Remove\n\tthe controls order assumption in updateControls()\"","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"content":"Hi Laurent, thanks for reverting.\n\nOn Tue, May 25, 2021 at 6:03 PM Jacopo Mondi <jacopo@jmondi.org> wrote:\n\n> Hi Laurent,\n>\n> On Tue, May 25, 2021 at 11:55:28AM +0300, Laurent Pinchart wrote:\n> > This reverts commit 34bee5e84ecba01e0ded5cacbc46c277c5a0edba.\n> >\n> > The commit introduced a breakage in the master branch, reported by\n> > linux-surface users already. Let's revert it while discussing the\n> > propert fix.\n>\n> I see a potential fix on the list but for now let's unblock users fast\n> Acked-by: Jacopo Mondi <jacopo@jmondi.org>\n>\n>\nAcked-by: Hirokazu Honda <hiroh@chromium.org>\n\nThanks a lot,\n-Hiro\n\n> Thanks\n>    j\n>\n> >\n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  src/libcamera/v4l2_device.cpp | 26 +++++++++++++++++++-------\n> >  1 file changed, 19 insertions(+), 7 deletions(-)\n> >\n> > diff --git a/src/libcamera/v4l2_device.cpp\n> b/src/libcamera/v4l2_device.cpp\n> > index 7f7e5b8fdf09..caafbc2d16bb 100644\n> > --- a/src/libcamera/v4l2_device.cpp\n> > +++ b/src/libcamera/v4l2_device.cpp\n> > @@ -244,6 +244,12 @@ ControlList V4L2Device::getControls(const\n> std::vector<uint32_t> &ids)\n> >\n> >       ControlList ctrls{ controls_ };\n> >\n> > +     /*\n> > +      * Start by filling the ControlList. This can't be combined with\n> filling\n> > +      * v4l2Ctrls, as updateControls() relies on both containers having\n> the\n> > +      * same order, and the control list is based on a map, which is not\n> > +      * sorted by insertion order.\n> > +      */\n> >       for (uint32_t id : ids) {\n> >               const auto iter = controls_.find(id);\n> >               if (iter == controls_.end()) {\n> > @@ -617,13 +623,19 @@ void V4L2Device::updateControlInfo()\n> >  void V4L2Device::updateControls(ControlList *ctrls,\n> >                               Span<const v4l2_ext_control> v4l2Ctrls)\n> >  {\n> > -     for (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) {\n> > -             const unsigned int id = v4l2Ctrl.id;\n> > +     unsigned int i = 0;\n> > +     for (auto &ctrl : *ctrls) {\n> > +             if (i == v4l2Ctrls.size())\n> > +                     break;\n> >\n> > -             ControlValue value = ctrls->get(id);\n> > -             switch (value.type()) {\n> > +             const struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i];\n> > +             unsigned int id = ctrl.first;\n> > +             ControlValue &value = ctrl.second;\n> > +\n> > +             const auto iter = controls_.find(id);\n> > +             switch (iter->first->type()) {\n> >               case ControlTypeInteger64:\n> > -                     value.set<int64_t>(v4l2Ctrl.value64);\n> > +                     value.set<int64_t>(v4l2Ctrl->value64);\n> >                       break;\n> >\n> >               case ControlTypeByte:\n> > @@ -638,11 +650,11 @@ void V4L2Device::updateControls(ControlList *ctrls,\n> >                        * \\todo To be changed when support for string\n> controls\n> >                        * will be added.\n> >                        */\n> > -                     value.set<int32_t>(v4l2Ctrl.value);\n> > +                     value.set<int32_t>(v4l2Ctrl->value);\n> >                       break;\n> >               }\n> >\n> > -             ctrls->set(id, value);\n> > +             i++;\n> >       }\n> >  }\n> >\n> > --\n> > Regards,\n> >\n> > Laurent Pinchart\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 B9C17C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 May 2021 09:05:03 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 6AB4068921;\n\tTue, 25 May 2021 11:05:03 +0200 (CEST)","from mail-ed1-x534.google.com (mail-ed1-x534.google.com\n\t[IPv6:2a00:1450:4864:20::534])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8E166602AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 May 2021 11:05:02 +0200 (CEST)","by mail-ed1-x534.google.com with SMTP id r11so35182753edt.13\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 May 2021 02:05:02 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=chromium.org header.i=@chromium.org\n\theader.b=\"Ke8Oxz9g\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; \n\th=mime-version:references:in-reply-to:from:date:message-id:subject:to\n\t:cc; bh=okYRa6kvRXTehEU3x5gM2OtOme4YX+WyD4dpIOhZzsE=;\n\tb=Ke8Oxz9goVHyujkWaQUvgkFlei2dRv3B5gKG3l9X+jTn1smm4NeYNWdrz0NDdgVM4u\n\thF44aQjL9coklZDtKbXfQnVodE1P2em2sppOJLbnmy0kBFbyltU5dMGcnVrTAqwcfBhN\n\tFe7O+DdFFMdQ6JMEXc83acDbTDuAqiI3q+i5Y=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:references:in-reply-to:from:date\n\t:message-id:subject:to:cc;\n\tbh=okYRa6kvRXTehEU3x5gM2OtOme4YX+WyD4dpIOhZzsE=;\n\tb=iQ8U4NMHNljG5WDzdEFPvPQBQC8gzPfejJHFlkq/HlrbJ9O9BqlOdCec6y78uFqkiD\n\tna2dJOnuBulvWURfnPneGjf4GSRsV68EYXxywZRqzTPKJdVXjs8k9aqL5+BhJr0tU4mZ\n\tANPA8SJC6VeUAYRbyYmyAD/z22gJcjCX7EBIa8PUaYbSZMAjvFGrht0dtkpaE0iway6v\n\tsX2gpSwYI8qq4q69RuDCZtNA8wcNlDz8AiSaWXYQj1Tii0W44DG5p0Lvfwf3t1QocZD5\n\tNPDI63xf5guUJHjMetL2v7OiRdPh2HOJ8dYV6FTiPRqJn1fxZ+Gk9HP23eny23OIbTzw\n\trx5Q==","X-Gm-Message-State":"AOAM533yNsSdwzF/qypyijmvGlgiQ6TMtuNCeb2wnK2AWTLzNm4avrNK\n\t1XyN2dgJe7Wfsrz5RR8J/f6ji+Vq22cSfuRckXDF3Q==","X-Google-Smtp-Source":"ABdhPJxMw1vJSBgMRjiMqudx6cBL0/67AU9nzFBgdMMmFd8Wvqlgx3ls0fGp9QTD5mvjT0hfTUHL2FdwxdTkdD1wj3U=","X-Received":"by 2002:a05:6402:95d:: with SMTP id\n\th29mr28566245edz.233.1621933502261; \n\tTue, 25 May 2021 02:05:02 -0700 (PDT)","MIME-Version":"1.0","References":"<20210525085528.11477-1-laurent.pinchart@ideasonboard.com>\n\t<20210525090428.i2bzigm4vumjzmpr@uno.localdomain>","In-Reply-To":"<20210525090428.i2bzigm4vumjzmpr@uno.localdomain>","From":"Hirokazu Honda <hiroh@chromium.org>","Date":"Tue, 25 May 2021 18:04:50 +0900","Message-ID":"<CAO5uPHNEkrrOZ-EPtzWAEC5GdnvienMSinJwL6wg15rhVCGjNA@mail.gmail.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Content-Type":"multipart/alternative; boundary=\"000000000000407e2405c323d223\"","Subject":"Re: [libcamera-devel] [PATCH] Revert \"libcamera: V4L2Device: Remove\n\tthe controls order assumption in updateControls()\"","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>","Cc":"libcamera devel <libcamera-devel@lists.libcamera.org>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17230,"web_url":"https://patchwork.libcamera.org/comment/17230/","msgid":"<7844b104-79eb-98e0-8e4f-fd04cc5eb4c0@ideasonboard.com>","date":"2021-05-25T09:05:40","subject":"Re: [libcamera-devel] [PATCH] Revert \"libcamera: V4L2Device: Remove\n\tthe controls order assumption in updateControls()\"","submitter":{"id":75,"url":"https://patchwork.libcamera.org/api/people/75/","name":"Jean-Michel Hautbois","email":"jeanmichel.hautbois@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 25/05/2021 11:04, Jacopo Mondi wrote:\n> Hi Laurent,\n> \n> On Tue, May 25, 2021 at 11:55:28AM +0300, Laurent Pinchart wrote:\n>> This reverts commit 34bee5e84ecba01e0ded5cacbc46c277c5a0edba.\n>>\n>> The commit introduced a breakage in the master branch, reported by\n>> linux-surface users already. Let's revert it while discussing the\n>> propert fix.\n> \n> I see a potential fix on the list but for now let's unblock users fast\n> Acked-by: Jacopo Mondi <jacopo@jmondi.org>\n> \n> Thanks\n>    j\n> \n>>\n>> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nThis is indeed a blocker on master, so:\nReviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>\n>> ---\n>>  src/libcamera/v4l2_device.cpp | 26 +++++++++++++++++++-------\n>>  1 file changed, 19 insertions(+), 7 deletions(-)\n>>\n>> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n>> index 7f7e5b8fdf09..caafbc2d16bb 100644\n>> --- a/src/libcamera/v4l2_device.cpp\n>> +++ b/src/libcamera/v4l2_device.cpp\n>> @@ -244,6 +244,12 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)\n>>\n>>  \tControlList ctrls{ controls_ };\n>>\n>> +\t/*\n>> +\t * Start by filling the ControlList. This can't be combined with filling\n>> +\t * v4l2Ctrls, as updateControls() relies on both containers having the\n>> +\t * same order, and the control list is based on a map, which is not\n>> +\t * sorted by insertion order.\n>> +\t */\n>>  \tfor (uint32_t id : ids) {\n>>  \t\tconst auto iter = controls_.find(id);\n>>  \t\tif (iter == controls_.end()) {\n>> @@ -617,13 +623,19 @@ void V4L2Device::updateControlInfo()\n>>  void V4L2Device::updateControls(ControlList *ctrls,\n>>  \t\t\t\tSpan<const v4l2_ext_control> v4l2Ctrls)\n>>  {\n>> -\tfor (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) {\n>> -\t\tconst unsigned int id = v4l2Ctrl.id;\n>> +\tunsigned int i = 0;\n>> +\tfor (auto &ctrl : *ctrls) {\n>> +\t\tif (i == v4l2Ctrls.size())\n>> +\t\t\tbreak;\n>>\n>> -\t\tControlValue value = ctrls->get(id);\n>> -\t\tswitch (value.type()) {\n>> +\t\tconst struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i];\n>> +\t\tunsigned int id = ctrl.first;\n>> +\t\tControlValue &value = ctrl.second;\n>> +\n>> +\t\tconst auto iter = controls_.find(id);\n>> +\t\tswitch (iter->first->type()) {\n>>  \t\tcase ControlTypeInteger64:\n>> -\t\t\tvalue.set<int64_t>(v4l2Ctrl.value64);\n>> +\t\t\tvalue.set<int64_t>(v4l2Ctrl->value64);\n>>  \t\t\tbreak;\n>>\n>>  \t\tcase ControlTypeByte:\n>> @@ -638,11 +650,11 @@ void V4L2Device::updateControls(ControlList *ctrls,\n>>  \t\t\t * \\todo To be changed when support for string controls\n>>  \t\t\t * will be added.\n>>  \t\t\t */\n>> -\t\t\tvalue.set<int32_t>(v4l2Ctrl.value);\n>> +\t\t\tvalue.set<int32_t>(v4l2Ctrl->value);\n>>  \t\t\tbreak;\n>>  \t\t}\n>>\n>> -\t\tctrls->set(id, value);\n>> +\t\ti++;\n>>  \t}\n>>  }\n>>\n>> --\n>> Regards,\n>>\n>> Laurent Pinchart\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 7984FC3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 May 2021 09:05:43 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 37D346891F;\n\tTue, 25 May 2021 11:05:43 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 14937602AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 May 2021 11:05:41 +0200 (CEST)","from tatooine.ideasonboard.com (unknown\n\t[IPv6:2a01:e0a:169:7140:eb61:5650:2f70:81a7])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id BCDD6344;\n\tTue, 25 May 2021 11:05:40 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"tnq0HNF4\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1621933540;\n\tbh=Wbk3OgMUlpyof+Jiruo42ItUKjMYKBZ6uJRWVCLxT5I=;\n\th=Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=tnq0HNF4BHTVbRdtj3OcYZqmIUIoA3fM8CDY5vwSC+Oux0BRU1RCyIBaUsYyMQanW\n\t4ETrEo2tmim+uBQrXOGTB3OLGiz9+B+Evklwf4a+c3gbNGj7E8TG53oSA+cKVIDD3L\n\tHYS3EZjEXA1uv4l9HCGRxdPthN7wvrgCKTy5umtA=","To":"Jacopo Mondi <jacopo@jmondi.org>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>","References":"<20210525085528.11477-1-laurent.pinchart@ideasonboard.com>\n\t<20210525090428.i2bzigm4vumjzmpr@uno.localdomain>","From":"Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>","Message-ID":"<7844b104-79eb-98e0-8e4f-fd04cc5eb4c0@ideasonboard.com>","Date":"Tue, 25 May 2021 11:05:40 +0200","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.8.1","MIME-Version":"1.0","In-Reply-To":"<20210525090428.i2bzigm4vumjzmpr@uno.localdomain>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-US","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH] Revert \"libcamera: V4L2Device: Remove\n\tthe controls order assumption in updateControls()\"","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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":17232,"web_url":"https://patchwork.libcamera.org/comment/17232/","msgid":"<07bca95d-c862-3f6f-3e68-deeef2fd954d@ideasonboard.com>","date":"2021-05-25T09:07:09","subject":"Re: [libcamera-devel] [PATCH] Revert \"libcamera: V4L2Device: Remove\n\tthe controls order assumption in updateControls()\"","submitter":{"id":86,"url":"https://patchwork.libcamera.org/api/people/86/","name":"Umang Jain","email":"umang.jain@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 5/25/21 2:25 PM, Laurent Pinchart wrote:\n> This reverts commit 34bee5e84ecba01e0ded5cacbc46c277c5a0edba.\n>\n> The commit introduced a breakage in the master branch, reported by\n> linux-surface users already. Let's revert it while discussing the\n> propert fix.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nI started facing\n\ncam: \n../../../../../tmp/portage/media-libs/libcamera-9999/work/libcamera-9999/include/libcamera/controls.h:150: \nT libcamera::ControlValue::get() const [T = long]: Assertion `type_ == \ndetails::control_type<std::remove_cv_t<T>>::value' failed.\nAborted (core dumped)\n\ntoday morning, under the impression it was due to my local changes for \nIPA controls on nautilus. So, applying this revert solves the issue on \nmy end.\n\nTested-by: Umang Jain <umang.jain@ideasonboard.com>\n> ---\n>   src/libcamera/v4l2_device.cpp | 26 +++++++++++++++++++-------\n>   1 file changed, 19 insertions(+), 7 deletions(-)\n>\n> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\n> index 7f7e5b8fdf09..caafbc2d16bb 100644\n> --- a/src/libcamera/v4l2_device.cpp\n> +++ b/src/libcamera/v4l2_device.cpp\n> @@ -244,6 +244,12 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)\n>   \n>   \tControlList ctrls{ controls_ };\n>   \n> +\t/*\n> +\t * Start by filling the ControlList. This can't be combined with filling\n> +\t * v4l2Ctrls, as updateControls() relies on both containers having the\n> +\t * same order, and the control list is based on a map, which is not\n> +\t * sorted by insertion order.\n> +\t */\n>   \tfor (uint32_t id : ids) {\n>   \t\tconst auto iter = controls_.find(id);\n>   \t\tif (iter == controls_.end()) {\n> @@ -617,13 +623,19 @@ void V4L2Device::updateControlInfo()\n>   void V4L2Device::updateControls(ControlList *ctrls,\n>   \t\t\t\tSpan<const v4l2_ext_control> v4l2Ctrls)\n>   {\n> -\tfor (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) {\n> -\t\tconst unsigned int id = v4l2Ctrl.id;\n> +\tunsigned int i = 0;\n> +\tfor (auto &ctrl : *ctrls) {\n> +\t\tif (i == v4l2Ctrls.size())\n> +\t\t\tbreak;\n>   \n> -\t\tControlValue value = ctrls->get(id);\n> -\t\tswitch (value.type()) {\n> +\t\tconst struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i];\n> +\t\tunsigned int id = ctrl.first;\n> +\t\tControlValue &value = ctrl.second;\n> +\n> +\t\tconst auto iter = controls_.find(id);\n> +\t\tswitch (iter->first->type()) {\n>   \t\tcase ControlTypeInteger64:\n> -\t\t\tvalue.set<int64_t>(v4l2Ctrl.value64);\n> +\t\t\tvalue.set<int64_t>(v4l2Ctrl->value64);\n>   \t\t\tbreak;\n>   \n>   \t\tcase ControlTypeByte:\n> @@ -638,11 +650,11 @@ void V4L2Device::updateControls(ControlList *ctrls,\n>   \t\t\t * \\todo To be changed when support for string controls\n>   \t\t\t * will be added.\n>   \t\t\t */\n> -\t\t\tvalue.set<int32_t>(v4l2Ctrl.value);\n> +\t\t\tvalue.set<int32_t>(v4l2Ctrl->value);\n>   \t\t\tbreak;\n>   \t\t}\n>   \n> -\t\tctrls->set(id, value);\n> +\t\ti++;\n>   \t}\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 C869FC3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 25 May 2021 09:07:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8514B6891F;\n\tTue, 25 May 2021 11:07:16 +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 2592E602AF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 25 May 2021 11:07:16 +0200 (CEST)","from localhost.localdomain (unknown [103.251.226.203])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 0E471344;\n\tTue, 25 May 2021 11:07:14 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"sdgaW39j\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1621933635;\n\tbh=xPZWJRo8OmKyp/ADdlcy1tblQERuoKW5GxFEe0Saxb0=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=sdgaW39jVbnqMYoT8EQLgffN6sQ3CVLia799dbHxcOcJw2Tg4RWjEogx7QWe1WU7t\n\tDERKaKSTIIaFLHc2ma5qG9YLPalQlfxzlf+xK1P38/d1RJPxjWFUCIKYG4Mk3/8Hjl\n\t7G+xTFWn40HQP9Lge/28D7ZjpfgFw2ntsR8JK7e8=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210525085528.11477-1-laurent.pinchart@ideasonboard.com>","From":"Umang Jain <umang.jain@ideasonboard.com>","Message-ID":"<07bca95d-c862-3f6f-3e68-deeef2fd954d@ideasonboard.com>","Date":"Tue, 25 May 2021 14:37:09 +0530","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101\n\tThunderbird/68.11.0","MIME-Version":"1.0","In-Reply-To":"<20210525085528.11477-1-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8; format=flowed","Content-Transfer-Encoding":"7bit","Content-Language":"en-US","Subject":"Re: [libcamera-devel] [PATCH] Revert \"libcamera: V4L2Device: Remove\n\tthe controls order assumption in updateControls()\"","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]