{"id":11934,"url":"https://patchwork.libcamera.org/api/patches/11934/?format=json","web_url":"https://patchwork.libcamera.org/patch/11934/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210415043625.3346627-1-hiroh@chromium.org>","date":"2021-04-15T04:36:25","name":"[libcamera-devel] libcamera: V4L2Device: Remove the controls order assumption in updateControls()","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"1ed6156b0dabc16f134c8e883f4470ab72bf04cb","submitter":{"id":63,"url":"https://patchwork.libcamera.org/api/people/63/?format=json","name":"Hirokazu Honda","email":"hiroh@chromium.org"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/11934/mbox/","series":[{"id":1931,"url":"https://patchwork.libcamera.org/api/series/1931/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1931","date":"2021-04-15T04:36:25","name":"[libcamera-devel] libcamera: V4L2Device: Remove the controls order assumption in updateControls()","version":1,"mbox":"https://patchwork.libcamera.org/series/1931/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/11934/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/11934/checks/","tags":{},"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 F2409BD224\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 15 Apr 2021 04:36:34 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4E5F56880A;\n\tThu, 15 Apr 2021 06:36:34 +0200 (CEST)","from mail-pf1-x434.google.com (mail-pf1-x434.google.com\n\t[IPv6:2607:f8b0:4864:20::434])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 9E368602C7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Apr 2021 06:36:32 +0200 (CEST)","by mail-pf1-x434.google.com with SMTP id b26so10084807pfr.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 14 Apr 2021 21:36:32 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:84f5:7981:dfbe:8f02])\n\tby smtp.gmail.com with ESMTPSA id 1sm343824pjx.46.2021.04.14.21.36.29\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 14 Apr 2021 21:36:30 -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=\"cBq1E+Dz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org;\n\ts=google; h=from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=zFtD9rQf8Iv6NHghLu1cUepALcYmYwlxAOla1nag0lQ=;\n\tb=cBq1E+DzNv3MTzTcf01WrjNLpSyT3/feaz0PxubN9pbdYEuh+bhaStTRaCEDMukb5P\n\tumERmO91krxiSxWi1tIBg1FRSrUrMCKuwindafmsvTktWunVHrinyobHWgca2noEKIsM\n\tZlW7bE3K8RXfeWXSlMI7kdC9URdtBuCuVJhY4=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version\n\t:content-transfer-encoding;\n\tbh=zFtD9rQf8Iv6NHghLu1cUepALcYmYwlxAOla1nag0lQ=;\n\tb=Geu4MFJkiHF3r4KCAn8moEButcDNsVClkBrsrTsqCH5OjMY34hPbKRr6FlTaygT3t0\n\tOq5ImKt8H6u32F+jJJ5jhSrpOehVrizmimkVBcJx/sneKlEq5cK74uylliYYCn5d90Ax\n\ttGtgtfGvZXfeZqX9GPWyit0LezrQQdzy+Ma97QP2LjPANuC6JUi1uRIIY3I/5DVwNjon\n\twF3R4EumT3HqxZeWtYs4ngX1W+1AF5rgl4f2xGwBpRzNB59Z0xYifX+PLSTmfyZa4C/A\n\tQbRShn6SrOvkFNCaCxjpHI9rEIvIZELmgA+1P6gnjKl6+9m+Ak2kXRInPQTbPYmIMHiQ\n\t666A==","X-Gm-Message-State":"AOAM532Xv9QaKwh2IZOjjfiPA41BE3UjY71yRqYI8oarn8A+EAeGu/Bl\n\tg4UhszcWfiOxa6Td9soM9N7gqotIrKo/pA==","X-Google-Smtp-Source":"ABdhPJw97WyWjJGZf55okuon5U2fV6kX367UgACLbnrpNx5S5M/heOb0vV05ZpRC2EZVZPwfWg96BA==","X-Received":"by 2002:a62:8f4a:0:b029:20a:448e:7018 with SMTP id\n\tn71-20020a628f4a0000b029020a448e7018mr1419543pfd.62.1618461390633; \n\tWed, 14 Apr 2021 21:36:30 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 15 Apr 2021 13:36:25 +0900","Message-Id":"<20210415043625.3346627-1-hiroh@chromium.org>","X-Mailer":"git-send-email 2.31.1.368.gbe11c130af-goog","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH] libcamera: V4L2Device: Remove the\n\tcontrols 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>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The original updateControls() has the assumption that ctrls and\nv4l2Ctrls lists in the same order. It is dependent on the caller\nimplementation though. This changes updateControls()\nimplementation so that it works without the assumption.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\n---\n src/libcamera/v4l2_device.cpp | 26 +++++++++++++-------------\n 1 file changed, 13 insertions(+), 13 deletions(-)","diff":"diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex d4a9bb75..8fd79934 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -525,19 +525,19 @@ void V4L2Device::updateControls(ControlList *ctrls,\n \t\t\t\tconst struct v4l2_ext_control *v4l2Ctrls,\n \t\t\t\tunsigned int count)\n {\n-\tunsigned int i = 0;\n-\tfor (auto &ctrl : *ctrls) {\n-\t\tif (i == count)\n-\t\t\tbreak;\n-\n-\t\tconst struct v4l2_ext_control *v4l2Ctrl = &v4l2Ctrls[i];\n-\t\tunsigned int id = ctrl.first;\n-\t\tControlValue &value = ctrl.second;\n+\tfor (unsigned int i = 0; i < count; i++) {\n+\t\tconst struct v4l2_ext_control &v4l2Ctrl = v4l2Ctrls[i];\n+\t\tconst unsigned int id = v4l2Ctrl.id;\n+\t\tif (!ctrls->contains(id)) {\n+\t\t\tLOG(V4L2, Error) << \"ControlList doesn't contain id: \"\n+\t\t\t\t\t << id;\n+\t\t\treturn;\n+\t\t}\n \n-\t\tconst auto iter = controls_.find(id);\n-\t\tswitch (iter->first->type()) {\n+\t\tControlValue value = ctrls->get(id);\n+\t\tswitch (value.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@@ -552,11 +552,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\ti++;\n+\t\tctrls->set(id, value);\n \t}\n }\n \n","prefixes":["libcamera-devel"]}