{"id":12434,"url":"https://patchwork.libcamera.org/api/patches/12434/?format=json","web_url":"https://patchwork.libcamera.org/patch/12434/","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":"<20210527052843.4186119-1-hiroh@chromium.org>","date":"2021-05-27T05:28:43","name":"[libcamera-devel,v2] libcamera: V4L2Device: Remove the controls order assumption in updateControls()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"064d64f62c4d2ad17a329f9316d877d1a28d6510","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/12434/mbox/","series":[{"id":2077,"url":"https://patchwork.libcamera.org/api/series/2077/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2077","date":"2021-05-27T05:28:43","name":"[libcamera-devel,v2] libcamera: V4L2Device: Remove the controls order assumption in updateControls()","version":2,"mbox":"https://patchwork.libcamera.org/series/2077/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/12434/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/12434/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 78CEDC3203\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 27 May 2021 05:28:53 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DF1DE68924;\n\tThu, 27 May 2021 07:28:52 +0200 (CEST)","from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com\n\t[IPv6:2607:f8b0:4864:20::42d])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 965106891F\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 27 May 2021 07:28:51 +0200 (CEST)","by mail-pf1-x42d.google.com with SMTP id c12so2766135pfl.3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 26 May 2021 22:28:51 -0700 (PDT)","from hiroh2.tok.corp.google.com\n\t([2401:fa00:8f:2:7911:c925:fd13:bd2d])\n\tby smtp.gmail.com with ESMTPSA id\n\t69sm793095pfx.115.2021.05.26.22.28.47\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 26 May 2021 22:28:48 -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=\"grj9HwcT\"; 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=3RNOBCzj/WX3Lfoq/wSyxU1XdjGgeNyVTqIHwAxqQqk=;\n\tb=grj9HwcTjmB8LWJ/kNK5fBEhrlHaRwM7OCG70hOPmQANmsdI63PsK/2FHKK/63JN6s\n\tXsutEqHheyKeN3DeYEH5Q5+wnapwMVPgSPCizjxuCoyDmo+Q3JBkbNmZihZR59R1hXWA\n\t9uMSwqj6Ha71o0JS0EThtXGsmh3UV/eCFyZEI=","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=3RNOBCzj/WX3Lfoq/wSyxU1XdjGgeNyVTqIHwAxqQqk=;\n\tb=JNkCInRHLZ79R5dkdZdIfQY+3eFBJdH4U1YV/J8EWEOuLq5U+Pdb64ecpYH0h5K95Z\n\tbeICyXa8R+imepK/fg+2qy+9Yn/z0xQ/W6GvXs51akheMwydoW6UaMIk01EX8bo+trLu\n\tltuOioFzItuo0HYo8QJ5FvV6P4WPS9D2fMb5F/iuXF5uZYQfVAa/RGCDz03BhENULkPI\n\tlMTXWP2mYGvemwUE+++yIqiuAokLZlATE0DaIiRlPCQvLXlS4LnfS+4GCI8TXq9pK6e9\n\tPV9faXkuYfidfJ1o4OD1V0oDgwTgI2LqG5bDibgL3Eh8lwCStPE0IZ7xRfH7CDdf+oBN\n\tnr+Q==","X-Gm-Message-State":"AOAM533ucOzIF2dz38+CASbfrnqH3MWYWcmbZb4NMbZgysbkJVxyALtC\n\tKBK2MN0bS9LjAQj/8evuwcKqVwfFo8k17g==","X-Google-Smtp-Source":"ABdhPJwVH3r8WI/T72znypx0/cXBvL/+/W0bHUv73OMW51kNYiYB3ngD2I4CgJCxF4bh838ZlJ6qvQ==","X-Received":"by 2002:a62:2fc6:0:b029:28e:854b:20b3 with SMTP id\n\tv189-20020a622fc60000b029028e854b20b3mr2127093pfv.0.1622093329369; \n\tWed, 26 May 2021 22:28:49 -0700 (PDT)","From":"Hirokazu Honda <hiroh@chromium.org>","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 27 May 2021 14:28:43 +0900","Message-Id":"<20210527052843.4186119-1-hiroh@chromium.org>","X-Mailer":"git-send-email 2.31.1.818.g46aad6cb9e-goog","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v2] 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>","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 are in the same order. It is dependent on the\ncaller implementation though. This changes updateControls()\nimplementation so that it works without the assumption.\n\nSigned-off-by: Hirokazu Honda <hiroh@chromium.org>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n src/libcamera/v4l2_device.cpp | 24 ++++++++----------------\n 1 file changed, 8 insertions(+), 16 deletions(-)","diff":"diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp\nindex caafbc2d..b39c6266 100644\n--- a/src/libcamera/v4l2_device.cpp\n+++ b/src/libcamera/v4l2_device.cpp\n@@ -244,12 +244,6 @@ 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@@ -623,19 +617,17 @@ void V4L2Device::updateControlInfo()\n void V4L2Device::updateControls(ControlList *ctrls,\n \t\t\t\tSpan<const v4l2_ext_control> v4l2Ctrls)\n {\n-\tunsigned int i = 0;\n-\tfor (auto &ctrl : *ctrls) {\n-\t\tif (i == v4l2Ctrls.size())\n-\t\t\tbreak;\n+\tfor (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) {\n+\t\tconst unsigned int id = v4l2Ctrl.id;\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+\t\tControlValue value = ctrls->get(id);\n \n \t\tconst auto iter = controls_.find(id);\n+\t\tASSERT(iter != controls_.end());\n+\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@@ -650,11 +642,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","v2"]}