From patchwork Thu Apr 15 04:48:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11935 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 46561BD1F6 for ; Thu, 15 Apr 2021 04:49:03 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0885468812; Thu, 15 Apr 2021 06:49:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="mtyr7Fdz"; dkim-atps=neutral Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 77C56602C7 for ; Thu, 15 Apr 2021 06:49:01 +0200 (CEST) Received: by mail-pf1-x430.google.com with SMTP id o123so15246847pfb.4 for ; Wed, 14 Apr 2021 21:49:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3Vo+IG2mc7UoxNBnK/5Lk1VvKmbhE/s7kiIKI3T0kTA=; b=mtyr7FdzwcBqxljMtY1WtMzHsyaXcxpz1/kJB3T+vH5y1z5xzuedoRdZA00RhJs+e6 32aGoS9HGAjWXObmZo/zFYjxKT+srUroSktUyd+6cbfEkRSImF4/3VT6RHh6CNUd4Dcv AsTgFQVk+vPEAkAkvlqkGEYx0f7tbic25ZOxA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3Vo+IG2mc7UoxNBnK/5Lk1VvKmbhE/s7kiIKI3T0kTA=; b=MxUI4rblzt4ZE04LZLMfAyjBRK3/F2ia4gn8UXBDk4YX1Ke3xg8vMc0PezB81wZhVY 0DNURwVNNxTz7J0SSjF4ZlO+908cU0asty7//076L3symfsyMQDg0wcSyuKF90HnTsIj G3Rzxh3vadMSj+9e3aB1vuV0oWr7KtjxB42FQ9lAi3jhT0QIdvCXVMu+0QxLJ5nMmdIA pd3zahzTDjdKfQ3QEIf/tKiLKHjn7geX7x96mVb1HeA0v1fx8d/tnkjPs3vMZ69Tsb+a TrtmEiKn0sDMES7GaW6cg7HhFMj9r79T4WUeewD7qe2vS4ofK7Tb/Qmr+URHNiyTw0+u 07/w== X-Gm-Message-State: AOAM532kWcXKl8ru+U/yyHCbXLkklro6+/SeQzu6xyCZvO3yA4p/K7es Wb2QlCME2apjOIZg1NMQs1lqjeIIiOBxCw== X-Google-Smtp-Source: ABdhPJy9AMgc8HpJ4pXYSCZIXI1nyLWuuIvTFU82yMPp4EnwECOQcgmgbAAQqyEhpatgU4CPE/tjUw== X-Received: by 2002:a63:64c6:: with SMTP id y189mr1757127pgb.267.1618462139961; Wed, 14 Apr 2021 21:48:59 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:84f5:7981:dfbe:8f02]) by smtp.gmail.com with ESMTPSA id kk6sm833885pjb.51.2021.04.14.21.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 21:48:59 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 15 Apr 2021 13:48:52 +0900 Message-Id: <20210415044854.3348529-1-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 1/3] libcamera: V4L2Device: Use std::vector for v4l2_ext_control in getControls() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The original code uses Variable-Length-Array, which is not officially supported in C++. This replaces the array with std::vector. Signed-off-by: Hirokazu Honda --- src/libcamera/v4l2_device.cpp | 43 ++++++++++++++++------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 8fd79934..ee8c3fed 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -173,8 +173,7 @@ void V4L2Device::close() */ ControlList V4L2Device::getControls(const std::vector &ids) { - unsigned int count = ids.size(); - if (count == 0) + if (ids.empty()) return {}; ControlList ctrls; @@ -196,22 +195,25 @@ ControlList V4L2Device::getControls(const std::vector &ids) ctrls.set(id, {}); } - struct v4l2_ext_control v4l2Ctrls[count]; - memset(v4l2Ctrls, 0, sizeof(v4l2Ctrls)); - - unsigned int i = 0; + std::vector v4l2Ctrls; + v4l2Ctrls.reserve(ctrls.size()); for (auto &ctrl : ctrls) { unsigned int id = ctrl.first; const struct v4l2_query_ext_ctrl &info = controlInfo_[id]; + v4l2_ext_control v4l2Ctrl; + memset(&v4l2Ctrl, 0, sizeof(v4l2Ctrl)); if (info.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD) { - ControlType type; + ControlValue &value = ctrl.second; switch (info.type) { - case V4L2_CTRL_TYPE_U8: - type = ControlTypeByte; + case V4L2_CTRL_TYPE_U8: { + value.reserve(ControlTypeByte, true, info.elems); + Span data = value.data(); + v4l2Ctrl.p_u8 = data.data(); + v4l2Ctrl.size = data.size(); break; - + } default: LOG(V4L2, Error) << "Unsupported payload control type " @@ -219,29 +221,23 @@ ControlList V4L2Device::getControls(const std::vector &ids) return {}; } - ControlValue &value = ctrl.second; - value.reserve(type, true, info.elems); - Span data = value.data(); - - v4l2Ctrls[i].p_u8 = data.data(); - v4l2Ctrls[i].size = data.size(); } - v4l2Ctrls[i].id = id; - i++; + v4l2Ctrl.id = id; + v4l2Ctrls.push_back(std::move(v4l2Ctrl)); } struct v4l2_ext_controls v4l2ExtCtrls = {}; v4l2ExtCtrls.which = V4L2_CTRL_WHICH_CUR_VAL; - v4l2ExtCtrls.controls = v4l2Ctrls; - v4l2ExtCtrls.count = count; + v4l2ExtCtrls.controls = v4l2Ctrls.data(); + v4l2ExtCtrls.count = v4l2Ctrls.size(); int ret = ioctl(VIDIOC_G_EXT_CTRLS, &v4l2ExtCtrls); if (ret) { unsigned int errorIdx = v4l2ExtCtrls.error_idx; /* Generic validation error. */ - if (errorIdx == 0 || errorIdx >= count) { + if (errorIdx == 0 || errorIdx >= v4l2Ctrls.size()) { LOG(V4L2, Error) << "Unable to read controls: " << strerror(-ret); return {}; @@ -250,10 +246,11 @@ ControlList V4L2Device::getControls(const std::vector &ids) /* A specific control failed. */ LOG(V4L2, Error) << "Unable to read control " << errorIdx << ": " << strerror(-ret); - count = errorIdx - 1; + + v4l2Ctrls.resize(errorIdx); } - updateControls(&ctrls, v4l2Ctrls, count); + updateControls(&ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); return ctrls; } From patchwork Thu Apr 15 04:48:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11936 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id B20DFBD1F6 for ; Thu, 15 Apr 2021 04:49:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 6C3E468814; Thu, 15 Apr 2021 06:49:05 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="bpgO+2H2"; dkim-atps=neutral Received: from mail-pf1-x429.google.com (mail-pf1-x429.google.com [IPv6:2607:f8b0:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3596A68814 for ; Thu, 15 Apr 2021 06:49:03 +0200 (CEST) Received: by mail-pf1-x429.google.com with SMTP id m11so15242451pfc.11 for ; Wed, 14 Apr 2021 21:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jzU+t2VtUvITwWtQsOaCsPBaqFBObZhQtYelVEN5WCw=; b=bpgO+2H2QxOqqB64loOTmElJphOLgQk2guJ2Mb+IrBsmUF38hZP88xADX6N8zhAJSK 2L+QJ4p/sDZRabQsiTLyzW7icy6Fsult+RcCgoHUD1Ii/hpKCR48CIavdXriSxUp6NC/ gB8JlRJhdKNGbz6gh1aqs3tIWz66ywn977j90= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jzU+t2VtUvITwWtQsOaCsPBaqFBObZhQtYelVEN5WCw=; b=Fg+EQfNU94WF+0CZIm2t8NzSosCohrB8O2vPTYzfhbL4e4gOQsjJ46SCo+3XMMycvF +Ao7Qy+gTTtg/vuu0fLwx0A1sGzp6Qaw7t1S8Hqfb6OiLGEX1waAHWKidH7UlCT7L7tM zXpWCIzXmrAUTVNqeAGpUAKAP02AUYUcRqDvh8rPBvM8WIcQy0yLpfP7UZg/GzxNXStY 7Tux3HX+AwqxAv2APEk0dtzYhmAu7eIBqrCsEYoo/TpIi2fnJrYkkiypOkioMw6zFRYp rBseToDlSBVzvzDxuo2L6b6AjimBeN42GzzYXf85i2F2HE2FaS8FkLGmzdxmpXdnWLLf qSJQ== X-Gm-Message-State: AOAM531AArly0OYt7P+vdL65qHmwDxHk2lcRzim+lNTfzTswo+Oqi4FL FsdDIB0i9gJt/xwkO1LHIQ1zBuGuel73Dw== X-Google-Smtp-Source: ABdhPJyvRSZ4px7Pkddp/prvYVb3ST1ijNo0dXsno0B46xuhzvotiqRvFUZWFRmYt+krCmtUkI5Mcg== X-Received: by 2002:a63:da04:: with SMTP id c4mr1764209pgh.144.1618462141661; Wed, 14 Apr 2021 21:49:01 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:84f5:7981:dfbe:8f02]) by smtp.gmail.com with ESMTPSA id kk6sm833885pjb.51.2021.04.14.21.49.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 21:49:01 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 15 Apr 2021 13:48:53 +0900 Message-Id: <20210415044854.3348529-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog In-Reply-To: <20210415044854.3348529-1-hiroh@chromium.org> References: <20210415044854.3348529-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 2/3] libcamera: V4L2Device: Use std::vector for v4l2_ext_control in setControls() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The original code uses Variable-Length-Array, which is not officially supported in C++. This replaces the array with std::vector. Signed-off-by: Hirokazu Honda Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- src/libcamera/v4l2_device.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index ee8c3fed..5ec1b10e 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -279,12 +279,11 @@ ControlList V4L2Device::getControls(const std::vector &ids) */ int V4L2Device::setControls(ControlList *ctrls) { - unsigned int count = ctrls->size(); - if (count == 0) + if (ctrls->empty()) return 0; - struct v4l2_ext_control v4l2Ctrls[count]; - memset(v4l2Ctrls, 0, sizeof(v4l2Ctrls)); + std::vector v4l2Ctrls(ctrls->size()); + memset(v4l2Ctrls.data(), 0, v4l2Ctrls.size()); unsigned int i = 0; for (auto &ctrl : *ctrls) { @@ -295,14 +294,14 @@ int V4L2Device::setControls(ControlList *ctrls) << "Control " << utils::hex(id) << " not found"; return -EINVAL; } - - v4l2Ctrls[i].id = id; + v4l2_ext_control &v4l2Ctrl = v4l2Ctrls[i++]; + v4l2Ctrl.id = id; /* Set the v4l2_ext_control value for the write operation. */ ControlValue &value = ctrl.second; switch (iter->first->type()) { case ControlTypeInteger64: - v4l2Ctrls[i].value64 = value.get(); + v4l2Ctrl.value64 = value.get(); break; case ControlTypeByte: { @@ -314,32 +313,30 @@ int V4L2Device::setControls(ControlList *ctrls) } Span data = value.data(); - v4l2Ctrls[i].p_u8 = data.data(); - v4l2Ctrls[i].size = data.size(); + v4l2Ctrl.p_u8 = data.data(); + v4l2Ctrl.size = data.size(); break; } default: /* \todo To be changed to support strings. */ - v4l2Ctrls[i].value = value.get(); + v4l2Ctrl.value = value.get(); break; } - - i++; } struct v4l2_ext_controls v4l2ExtCtrls = {}; v4l2ExtCtrls.which = V4L2_CTRL_WHICH_CUR_VAL; - v4l2ExtCtrls.controls = v4l2Ctrls; - v4l2ExtCtrls.count = count; + v4l2ExtCtrls.controls = v4l2Ctrls.data(); + v4l2ExtCtrls.count = v4l2Ctrls.size(); int ret = ioctl(VIDIOC_S_EXT_CTRLS, &v4l2ExtCtrls); if (ret) { unsigned int errorIdx = v4l2ExtCtrls.error_idx; /* Generic validation error. */ - if (errorIdx == 0 || errorIdx >= count) { + if (errorIdx == 0 || errorIdx >= v4l2Ctrls.size()) { LOG(V4L2, Error) << "Unable to set controls: " << strerror(-ret); return -EINVAL; @@ -348,11 +345,12 @@ int V4L2Device::setControls(ControlList *ctrls) /* A specific control failed. */ LOG(V4L2, Error) << "Unable to set control " << errorIdx << ": " << strerror(-ret); - count = errorIdx - 1; + + v4l2Ctrls.resize(errorIdx); ret = errorIdx; } - updateControls(ctrls, v4l2Ctrls, count); + updateControls(ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); return ret; } From patchwork Thu Apr 15 04:48:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11937 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 87144BD1F6 for ; Thu, 15 Apr 2021 04:49:06 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 088A26881D; Thu, 15 Apr 2021 06:49:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="j/cHkXR7"; dkim-atps=neutral Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8ECBF602C7 for ; Thu, 15 Apr 2021 06:49:04 +0200 (CEST) Received: by mail-pf1-x42b.google.com with SMTP id m11so15242484pfc.11 for ; Wed, 14 Apr 2021 21:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gWtprvFvs554lUgEhHva3qqaLvBV08DOn0Hn5nAhrtQ=; b=j/cHkXR7Kr4syRej+OwNICulx2RKVACiH4Sh8FSP+U1KrnGKR5pY/8kQ7kDeZ3F3Uw T0TCzLrdMCGDtrGz9j6PIWtPBawAz7EJ6RvRsqSXvJKsmGOHeplwAVoNeAbaOnJ/wHhq 5w5+WEK8XFmuLBMXv03IG0cO7oIFTcUBO6zNQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gWtprvFvs554lUgEhHva3qqaLvBV08DOn0Hn5nAhrtQ=; b=VgbJ+e3YUcBBFmscsBFtr6IFKJ6Ec6X7xcgeK8KngD/fHgF1RFX4Scq7ApCV3p0rCf lmSVl5/7aurga6bMP3yjNqHkSbNbR67MGXs4xDO4//vHu/tg8Jm2grY+zI2Y6POeDdxg nbZVkfiVEpg66H9/pEL3d9dgpQOrwBaunuhbusvYtbdTPoJo17769NfSZvL1OWPtGBnI ErOOixsaZo9CBW/e+LsHJAqM4mcrD9Jyw2bWMnL/4reaieuec7oemSUUWci6gsYgqJIZ ebRP4/GRhV1DbktjDLH3ZWtXhNxB84onGaAH2orsR28ERi5cJoKtQvjqNoVsveE9Luk7 7NHA== X-Gm-Message-State: AOAM532kJEUuzHvQy9nbeBZz1Cn320w6rDX0fWRO0jJJJai9BXP99vwX Rk/Icq32qF8IYezjQJcDW5jk1YyPkrSdoQ== X-Google-Smtp-Source: ABdhPJxGzXZ7LJAQgIC1/4US3Uz0pPVOjqdomQmOvT/ndNVenGd9UmxU17lnm6XJiD9ZLlkY/TlrAg== X-Received: by 2002:a63:1b5e:: with SMTP id b30mr1770458pgm.254.1618462143098; Wed, 14 Apr 2021 21:49:03 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:84f5:7981:dfbe:8f02]) by smtp.gmail.com with ESMTPSA id kk6sm833885pjb.51.2021.04.14.21.49.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Apr 2021 21:49:02 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Thu, 15 Apr 2021 13:48:54 +0900 Message-Id: <20210415044854.3348529-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.368.gbe11c130af-goog In-Reply-To: <20210415044854.3348529-1-hiroh@chromium.org> References: <20210415044854.3348529-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v2 3/3] libcamera: V4L2Device: Use std::vector in updateControls() X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" V4L2Device::updateControls() takes two arguments, raw array and its size, for the v4l2_ext_control values. This replaces it with std::vector. Signed-off-by: Hirokazu Honda --- include/libcamera/internal/v4l2_device.h | 3 +-- src/libcamera/v4l2_device.cpp | 11 ++++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index d006bf68..4cce3840 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -55,8 +55,7 @@ protected: private: void listControls(); void updateControls(ControlList *ctrls, - const struct v4l2_ext_control *v4l2Ctrls, - unsigned int count); + const std::vector &v4l2Ctrls); void eventAvailable(EventNotifier *notifier); diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 5ec1b10e..217a39e3 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -250,7 +250,7 @@ ControlList V4L2Device::getControls(const std::vector &ids) v4l2Ctrls.resize(errorIdx); } - updateControls(&ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); + updateControls(&ctrls, v4l2Ctrls); return ctrls; } @@ -350,7 +350,7 @@ int V4L2Device::setControls(ControlList *ctrls) ret = errorIdx; } - updateControls(ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); + updateControls(ctrls, v4l2Ctrls); return ret; } @@ -514,14 +514,11 @@ void V4L2Device::listControls() * values in \a v4l2Ctrls * \param[inout] ctrls List of V4L2 controls to update * \param[in] v4l2Ctrls List of V4L2 extended controls as returned by the driver - * \param[in] count The number of controls to update */ void V4L2Device::updateControls(ControlList *ctrls, - const struct v4l2_ext_control *v4l2Ctrls, - unsigned int count) + const std::vector &v4l2Ctrls) { - for (unsigned int i = 0; i < count; i++) { - const struct v4l2_ext_control &v4l2Ctrl = v4l2Ctrls[i]; + for (const v4l2_ext_control &v4l2Ctrl : v4l2Ctrls) { const unsigned int id = v4l2Ctrl.id; if (!ctrls->contains(id)) { LOG(V4L2, Error) << "ControlList doesn't contain id: "