<div dir="ltr"><div dir="ltr">Hi Laurent, thanks for reverting.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 25, 2021 at 6:03 PM Jacopo Mondi <<a href="mailto:jacopo@jmondi.org">jacopo@jmondi.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Laurent,<br>
<br>
On Tue, May 25, 2021 at 11:55:28AM +0300, Laurent Pinchart wrote:<br>
> This reverts commit 34bee5e84ecba01e0ded5cacbc46c277c5a0edba.<br>
><br>
> The commit introduced a breakage in the master branch, reported by<br>
> linux-surface users already. Let's revert it while discussing the<br>
> propert fix.<br>
<br>
I see a potential fix on the list but for now let's unblock users fast<br>
Acked-by: Jacopo Mondi <<a href="mailto:jacopo@jmondi.org" target="_blank">jacopo@jmondi.org</a>><br>
<br></blockquote><div><br></div><div>Acked-by: Hirokazu Honda <<a href="mailto:hiroh@chromium.org">hiroh@chromium.org</a>></div><div><br></div><div>Thanks a lot,</div><div>-Hiro </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Thanks<br>
   j<br>
<br>
><br>
> Signed-off-by: Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank">laurent.pinchart@ideasonboard.com</a>><br>
> ---<br>
>  src/libcamera/v4l2_device.cpp | 26 +++++++++++++++++++-------<br>
>  1 file changed, 19 insertions(+), 7 deletions(-)<br>
><br>
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp<br>
> index 7f7e5b8fdf09..caafbc2d16bb 100644<br>
> --- a/src/libcamera/v4l2_device.cpp<br>
> +++ b/src/libcamera/v4l2_device.cpp<br>
> @@ -244,6 +244,12 @@ ControlList V4L2Device::getControls(const std::vector<uint32_t> &ids)<br>
><br>
>       ControlList ctrls{ controls_ };<br>
><br>
> +     /*<br>
> +      * Start by filling the ControlList. This can't be combined with filling<br>
> +      * v4l2Ctrls, as updateControls() relies on both containers having the<br>
> +      * same order, and the control list is based on a map, which is not<br>
> +      * sorted by insertion order.<br>
> +      */<br>
>       for (uint32_t id : ids) {<br>
>               const auto iter = controls_.find(id);<br>
>               if (iter == controls_.end()) {<br>
> @@ -617,13 +623,19 @@ void V4L2Device::updateControlInfo()<br>
>  void V4L2Device::updateControls(ControlList *ctrls,<br>
>                               Span<const v4l2_ext_control> v4l2Ctrls)<br>
>  {<br>
> -     for (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) {<br>
> -             const unsigned int id = v4l2Ctrl.id;<br>
> +     unsigned int i = 0;<br>
> +     for (auto &ctrl : *ctrls) {<br>
> +             if (i == v4l2Ctrls.size())<br>
> +                     break;<br>
><br>
> -             ControlValue value = ctrls->get(id);<br>
> -             switch (value.type()) {<br>
> +             const struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i];<br>
> +             unsigned int id = ctrl.first;<br>
> +             ControlValue &value = ctrl.second;<br>
> +<br>
> +             const auto iter = controls_.find(id);<br>
> +             switch (iter->first->type()) {<br>
>               case ControlTypeInteger64:<br>
> -                     value.set<int64_t>(v4l2Ctrl.value64);<br>
> +                     value.set<int64_t>(v4l2Ctrl->value64);<br>
>                       break;<br>
><br>
>               case ControlTypeByte:<br>
> @@ -638,11 +650,11 @@ void V4L2Device::updateControls(ControlList *ctrls,<br>
>                        * \todo To be changed when support for string controls<br>
>                        * will be added.<br>
>                        */<br>
> -                     value.set<int32_t>(v4l2Ctrl.value);<br>
> +                     value.set<int32_t>(v4l2Ctrl->value);<br>
>                       break;<br>
>               }<br>
><br>
> -             ctrls->set(id, value);<br>
> +             i++;<br>
>       }<br>
>  }<br>
><br>
> --<br>
> Regards,<br>
><br>
> Laurent Pinchart<br>
><br>
</blockquote></div></div>