From patchwork Wed Apr 28 07:36:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 12125 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 7D391BDE44 for ; Wed, 28 Apr 2021 07:36:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3C621688B7; Wed, 28 Apr 2021 09:36:31 +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="cGAGn60S"; dkim-atps=neutral Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9CC1C688B7 for ; Wed, 28 Apr 2021 09:36:27 +0200 (CEST) Received: by mail-pg1-x52d.google.com with SMTP id j189so393972pgd.13 for ; Wed, 28 Apr 2021 00:36:27 -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=8J7xgT7XcjyRvJF6TvsJde5q9/7S/xA8Yce3qGUryO8=; b=cGAGn60SCs/jq0inT/o8ab7uvWuEQrVyMtVfKCOgBEXtW7jdbfYcxqnUTK5IDqvBPf VPVAFnyhuIwWEux9fzT9VG1tR7vggALbVO16jDRCaH+Wru8q+oepduTsz3XQzhIMVjZb evGEL9EnxFRr+EUod5FbILRYx1D9cd3LOoDmo= 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=8J7xgT7XcjyRvJF6TvsJde5q9/7S/xA8Yce3qGUryO8=; b=WTAkPzSbzAcK4ZQG6pdQ/xlz+5J0Fs3gcKahSGBzWsGx1Kr+IC6fMcvj5DGoqNrMMb laLBPl+VSQjkXnw/h+iCZsMgZ25IUOtyaEddFQnSHg9GWtFy0zr1SHzVH+eKASa5iIdw yqIhWjdc8miEt7/rrgUkes7Q0ATHW561Oh1F/y/QojFeBQrefcbI7/ToMpTARNTidkxK TrxQnAsNR+chZeXDqTfIb9WXRtMy1F8/hPtfABYGIZuZMtFj1IiRMssXnvulZVpdeBPg Q4TYGEc4TuExsi+agJJWSzBWApA1uaLO7Gp6OpT1bblN3NR3M2QxLQOAjpbUUPQWk96P 2aXQ== X-Gm-Message-State: AOAM533O0ba5JsM+Pz5NRrHdW+Nrx7Ui31w6IjY7QkalcsBBNTUZhoXp sxVGMc+PNiRrvLN8eIwMGrd2P1oWwOvZyg== X-Google-Smtp-Source: ABdhPJzTuCHTTqkzNKlnVV3JvwG0H7S7oCwJNUJ8aWZBxE74avvsSsHFXWRQ8c/3vfEYE9Er7YeVZA== X-Received: by 2002:a63:6b4a:: with SMTP id g71mr25681145pgc.274.1619595385911; Wed, 28 Apr 2021 00:36:25 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:489:a5f4:117:7d51]) by smtp.gmail.com with ESMTPSA id m11sm1661265pgs.4.2021.04.28.00.36.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Apr 2021 00:36:25 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Wed, 28 Apr 2021 16:36:12 +0900 Message-Id: <20210428073617.373422-3-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.498.g6c1eba8ee3d-goog In-Reply-To: <20210428073617.373422-1-hiroh@chromium.org> References: <20210428073617.373422-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/7] libcamera: controls: Add extra control values to ControlInfo 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 v4l2 menu contains not only index (int32_t) but also either name (string) or value (int64_t). To support it keeping ControlValue simple, this adds the extra ControlValues to ControlInfo. With the ControlInfo, indeices are stored in ControlInfo::values, and names (or values) are stored in ControlInfo::extraValues. Signed-off-by: Hirokazu Honda --- include/libcamera/controls.h | 5 +++++ src/libcamera/controls.cpp | 22 ++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 1a5690a5..a8deb16a 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -271,11 +271,15 @@ public: const ControlValue &def = 0); explicit ControlInfo(Span values, const ControlValue &def = {}); + explicit ControlInfo(Span values, + Span extraValues, + const ControlValue &def = {}); const ControlValue &min() const { return min_; } const ControlValue &max() const { return max_; } const ControlValue &def() const { return def_; } const std::vector &values() const { return values_; } + const std::vector &extraValues() const { return extraValues_; } std::string toString() const; @@ -294,6 +298,7 @@ private: ControlValue max_; ControlValue def_; std::vector values_; + std::vector extraValues_; }; using ControlIdMap = std::unordered_map; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index c58ed394..e2e8619a 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -513,6 +513,28 @@ ControlInfo::ControlInfo(Span values, values_.push_back(value); } +/** + * \brief Construct a ControlInfo from the list of valid values and extra values + * \param[in] values The control valid values + * \param[in] extraValues The control valid extra values associated with \a values + * \param[in] def The control default value + * + * Construct a ControlInfo from a list of valid values and extra values. The + * ControlInfo minimum and maximum values are set to the first and last members + * of the values list respectively. The default value is set to \a def if + * provided, or to the minimum value otherwise. The extra values are associated + * with \a values and in the same order as \a values. + * + */ +ControlInfo::ControlInfo(Span values, + Span extraValues, + const ControlValue &def) + : ControlInfo(values, def) +{ + for (const ControlValue &extraValue : extraValues) + extraValues_.push_back(extraValue); +} + /** * \fn ControlInfo::min() * \brief Retrieve the minimum value of the control