<div dir="ltr"><div dir="ltr">Hi Laurent,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, May 25, 2021 at 8:52 AM Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com">laurent.pinchart@ideasonboard.com</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 Hiro,<br>
<br>
Thank you for the patch. I'm going through the patchwork backlog and<br>
realized I had forgotten about this one. Sorry about that.<br>
<br>
On Tue, Apr 27, 2021 at 10:21:50AM +0900, Hirokazu Honda wrote:<br>
> The original updateControls() has the assumption that ctrls and<br>
> v4l2Ctrls lists are in the same order. It is dependent on the<br>
> caller implementation though. This changes updateControls()<br>
> implementation so that it works without the assumption.<br>
> <br>
> Signed-off-by: Hirokazu Honda <<a href="mailto:hiroh@chromium.org" target="_blank">hiroh@chromium.org</a>><br>
<br>
Reviewed-by: Laurent Pinchart <<a href="mailto:laurent.pinchart@ideasonboard.com" target="_blank">laurent.pinchart@ideasonboard.com</a>><br>
<br>
Will push shortly once the tests pass.<br>
<br></blockquote><div><br></div><div>I am sorry I noticed the patch has a bug. Somehow I haven't caught it. </div><div>I submit a fix patch for review. <a href="https://patchwork.libcamera.org/patch/12396/">https://patchwork.libcamera.org/patch/12396/</a><br></div><div><br></div><div>-Hiro</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
> ---<br>
> src/libcamera/v4l2_device.cpp | 26 +++++++-------------------<br>
> 1 file changed, 7 insertions(+), 19 deletions(-)<br>
> <br>
> diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp<br>
> index 397029ac..64501523 100644<br>
> --- a/src/libcamera/v4l2_device.cpp<br>
> +++ b/src/libcamera/v4l2_device.cpp<br>
> @@ -178,12 +178,6 @@ 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>
> @@ -520,19 +514,13 @@ void V4L2Device::listControls()<br>
> void V4L2Device::updateControls(ControlList *ctrls,<br>
> Span<const v4l2_ext_control> v4l2Ctrls)<br>
> {<br>
> - unsigned int i = 0;<br>
> - for (auto &ctrl : *ctrls) {<br>
> - if (i == v4l2Ctrls.size())<br>
> - break;<br>
> + for (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) {<br>
> + const unsigned int id = v4l2Ctrl.id;<br>
> <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>
> + ControlValue value = ctrls->get(id);<br>
> + switch (value.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>
> @@ -547,11 +535,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>
> - i++;<br>
> + ctrls->set(id, value);<br>
> }<br>
> }<br>
> <br>
<br>
-- <br>
Regards,<br>
<br>
Laurent Pinchart<br>
</blockquote></div></div>