From patchwork Tue Apr 13 07:50:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hirokazu Honda X-Patchwork-Id: 11900 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 CDE5EBD224 for ; Tue, 13 Apr 2021 07:50:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 9297468804; Tue, 13 Apr 2021 09:50:27 +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="ExghdpUA"; dkim-atps=neutral Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 45856687F3 for ; Tue, 13 Apr 2021 09:50:26 +0200 (CEST) Received: by mail-pf1-x42f.google.com with SMTP id w8so7427029pfn.9 for ; Tue, 13 Apr 2021 00:50:26 -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=MDvFpdtStUN6KFcq+Pbwh/UcIbxE1T9/3tNXLwDD1Sc=; b=ExghdpUAqBshvvZyhOwBt0o0Ilca544OdfveolXroT35xXHq2I0lp8dY+b8/Idbgqw eiSm/+3autIU893Tk4nolvJDEaRY386qwPAwRk9lMRU5vH/BzJLLMKC4y2fhYTHSdH8s w8FkQ9CbOhc+MoJkcUh5RCuFfH7XvKnbZeCEg= 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=MDvFpdtStUN6KFcq+Pbwh/UcIbxE1T9/3tNXLwDD1Sc=; b=e+DRfD2L5vw9bf+0BE+g7h1tiG0l6HKy6LthgrjwlePeR57rjATAy8qgTdt1aClSun bneXKEaQ4JW4oE/mbhXMF52rCFvW/dH/f2e1Vqx7idzr+Dr9jX4qHBkAM93MyaVt+xw5 aYnyJpLTLIiD1saeoIPM6DUA5rXlwfevmb6eaCy6bm3C2XRLAr0YFvmJclE/p31uRuLH R7b/I5jDNVu2TP9u811E6bcBhFnpGQwNubRPSCDrLZE/HYJ6IgFBedrsltX1N3VIrSMi cE3ukDkPXtBaHfEYKyIAD4VIecsF9nzm6WEtuJs6u8L8+0tw08nsRRT3xKl+OQQgh+sm +Ahg== X-Gm-Message-State: AOAM530DZU4cFfuZ8JT9Zz/VANUcWROSltgOgz9Bl1pcaNsgUPWRmW9K +A1LZkyw0Ks9kiwZE8xXcubASteNE91zRQ== X-Google-Smtp-Source: ABdhPJz7LsD22I5o7pWwbY9Yw8XRjwHMNr3Ogp0Vb3MQ+5xTZlEgP3n1PKLNiXtcmq7pw/6evc8tOg== X-Received: by 2002:a05:6a00:15c6:b029:24e:9dd1:8813 with SMTP id o6-20020a056a0015c6b029024e9dd18813mr5720881pfu.80.1618300224648; Tue, 13 Apr 2021 00:50:24 -0700 (PDT) Received: from hiroh2.tok.corp.google.com ([2401:fa00:8f:2:84f5:7981:dfbe:8f02]) by smtp.gmail.com with ESMTPSA id n25sm11525125pff.154.2021.04.13.00.50.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 00:50:24 -0700 (PDT) From: Hirokazu Honda To: libcamera-devel@lists.libcamera.org Date: Tue, 13 Apr 2021 16:50:09 +0900 Message-Id: <20210413075013.3069213-2-hiroh@chromium.org> X-Mailer: git-send-email 2.31.1.295.g9ea45b61b8-goog In-Reply-To: <20210413075013.3069213-1-hiroh@chromium.org> References: <20210413075013.3069213-1-hiroh@chromium.org> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC PATCH v2 1/5] libcamera: Controls: Add ControlTypeMenu 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: , Cc: jmondi@jacopo.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" This adds control type for v4l2 menu. Signed-off-by: Hirokazu Honda --- include/libcamera/controls.h | 28 ++++++++++++++++++++++++++++ src/libcamera/controls.cpp | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 1a5690a5..357819e7 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -9,6 +9,7 @@ #define __LIBCAMERA_CONTROLS_H__ #include +#include #include #include #include @@ -32,6 +33,28 @@ enum ControlType { ControlTypeString, ControlTypeRectangle, ControlTypeSize, + ControlTypeMenu, +}; + +struct ControlMenu { + uint32_t index; + bool isName = false; + + union { + char name[28]; + int64_t value; + }; + + std::string toString() const + { + std::stringstream ss; + ss << "index: " << index; + if (isName) + ss << "name: " << name; + else + ss << "value: " << value; + return ss.str(); + } }; namespace details { @@ -85,6 +108,11 @@ struct control_type { static constexpr ControlType value = ControlTypeSize; }; +template<> +struct control_type { + static constexpr ControlType value = ControlTypeMenu; +}; + template struct control_type> : public control_type> { }; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index c58ed394..8ab5ac92 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -60,6 +60,7 @@ static constexpr size_t ControlValueSize[] = { [ControlTypeString] = sizeof(char), [ControlTypeRectangle] = sizeof(Rectangle), [ControlTypeSize] = sizeof(Size), + [ControlTypeMenu] = sizeof(ControlMenu), }; } /* namespace */ @@ -254,6 +255,12 @@ std::string ControlValue::toString() const str += value->toString(); break; } + case ControlTypeMenu: { + const ControlMenu *value = + reinterpret_cast(data); + str += value->toString(); + break; + } case ControlTypeNone: case ControlTypeString: break;