From patchwork Fri Apr 23 09:36: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: 12097 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 3A408BDB15 for ; Fri, 23 Apr 2021 09:38:02 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B1B246887B; Fri, 23 Apr 2021 11:38:01 +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="IFuCvSzl"; dkim-atps=neutral Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id B5A6068877 for ; Fri, 23 Apr 2021 11:37:59 +0200 (CEST) Received: by mail-pg1-x533.google.com with SMTP id b17so34824854pgh.7 for ; Fri, 23 Apr 2021 02:37:59 -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=o3KaVkmOW7yQ2PRBDDrr/MSJU0RRor10z7001foGA3U=; b=IFuCvSzlSuzLcs6YD/wJBmO+WDKcMpyGxubv7rWat5YrTb/eqdpVIzylU0fSTxJoYU mfIawNaX7NlvnCZDSkArTusE6qcogixNpFNYUkgc0yMUX6AfLjs80o63hjYokh4js8QI UBA85Jd7tLHtK4igxjwVjTdfUFsNVv63RXtCI= 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=o3KaVkmOW7yQ2PRBDDrr/MSJU0RRor10z7001foGA3U=; b=T3xI+iwfWgG7noheOlJSScqis2G4C+759y3x4DBhHgCVQ7SnYmpK8/tgnZn+zeEx+a nrp9kEgpDUb8Svlm8srlqCCSha/9S1jj/AUXVW6OpGu6EZIChuotpFiuIXI4jLi4lJU7 Kozl3UugD2ADKHclfA+s6/GJuKYEFErnia/VYkcWlzhACsXQXDlnMm13Qp7rMp/abND2 g6Y9q+UArZ2Kzy1j9w/jAA0D7Ku/EQIyJItZ6WwgliSquLTPeriAa6Alc7InW8txA6B1 tNMxXcY2qzIxljRkwWphEzgy+aag77lezF8u1V2z2iT9nfFDJpD6RYsnstADNgBeeeHS F8bw== X-Gm-Message-State: AOAM530Dqf5f7h1D1GWxJ3Mi5mZOWXN8GODS5A/jdLOMGtYALbbr7HEY VtTLp7Vz6/5+0ikCtDsIQqToyNqotnGqeg== X-Google-Smtp-Source: ABdhPJwn4QFpBQQGCsblpYKZ7NPwve/iehWsWcTAv6E5kaEqBRzl0ZMTKaaa+IOWcGjcIHVZ0xGlTA== X-Received: by 2002:a62:8485:0:b029:1fc:d912:67d6 with SMTP id k127-20020a6284850000b02901fcd91267d6mr2961376pfd.80.1619170678186; Fri, 23 Apr 2021 02:37:58 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:8537:2d4f:8d35:5777]) by smtp.gmail.com with ESMTPSA id z5sm4273660pff.191.2021.04.23.02.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Apr 2021 02:37:57 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Fri, 23 Apr 2021 18:36:53 +0900 Message-Id: <20210423093653.1726488-4-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210423093653.1726488-1-hiroh@chromium.org> References: <20210423093653.1726488-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 4/4] libcamera: V4L2Device: Use Span 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 libcamera::Span. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- include/libcamera/internal/v4l2_device.h | 4 ++-- src/libcamera/v4l2_device.cpp | 11 ++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/include/libcamera/internal/v4l2_device.h b/include/libcamera/internal/v4l2_device.h index d006bf68..087f07e7 100644 --- a/include/libcamera/internal/v4l2_device.h +++ b/include/libcamera/internal/v4l2_device.h @@ -14,6 +14,7 @@ #include #include +#include #include "libcamera/internal/log.h" #include "libcamera/internal/v4l2_controls.h" @@ -55,8 +56,7 @@ protected: private: void listControls(); void updateControls(ControlList *ctrls, - const struct v4l2_ext_control *v4l2Ctrls, - unsigned int count); + Span v4l2Ctrls); void eventAvailable(EventNotifier *notifier); diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 4522268d..954060f4 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -246,7 +246,7 @@ ControlList V4L2Device::getControls(const std::vector &ids) v4l2Ctrls.resize(errorIdx); } - updateControls(&ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); + updateControls(&ctrls, v4l2Ctrls); return ctrls; } @@ -345,7 +345,7 @@ int V4L2Device::setControls(ControlList *ctrls) ret = errorIdx; } - updateControls(ctrls, v4l2Ctrls.data(), v4l2Ctrls.size()); + updateControls(ctrls, v4l2Ctrls); return ret; } @@ -509,14 +509,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) + Span 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; ControlValue value = ctrls->get(id);