From patchwork Fri Oct 11 17:55:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21595 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 F3944C326B for ; Fri, 11 Oct 2024 17:57:05 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1688965388; Fri, 11 Oct 2024 19:57:04 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="YkbS3lKW"; dkim-atps=neutral Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 5684F65383 for ; Fri, 11 Oct 2024 19:57:01 +0200 (CEST) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-20b7259be6fso24808085ad.0 for ; Fri, 11 Oct 2024 10:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728669419; x=1729274219; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mmDThpciV/k1pBewkba7V92lzxFvadVrPr43Qa8Sabo=; b=YkbS3lKWCqBbTVHa1/Qp+oOUsyNNhG+6EizJB5j7uEhXbyld3bRktwOEpQQVv9AbxQ 6hWtGHo16FZq2ejei/1CzJ07xKRRx0+icSwnfCTSxIaYtF4JUhV9C7VEoWcdF/b4QkBN +E/E+R1BlU0BxSB/+hx689N9lZqdFAykZjids= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728669419; x=1729274219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mmDThpciV/k1pBewkba7V92lzxFvadVrPr43Qa8Sabo=; b=n1dCGfxV5dW1TWHt9kn7K/qhGhAYP34MpBn46twa2dl0ikTIj0/3rbhRTu7h038uKz feTBxnLOnr737/vJy9oNCkSVRfWk/SE0ekgENe2xjV+xqIjrSvf+NFN2F1ZacGVMeaYB xABS8o7ExrypeFvrUz4KzhNMoPf720ha7MsMjBQcYIuevU2zCq6lJKy0fOxIGkJv1y63 lqYVf5MteuU3BMg97Xur1IewgECV5NzHLIY+MF/ALalAdN/5iVOJWqxSPKQTlz5Ntq0B Nsx5R7zPIEn7hTA2995fSf1JccY3qLf5kJH9zohVEWWQd3ydfrtaCWQE9GY2gEriuvFs rtlg== X-Gm-Message-State: AOJu0Yzj2ySneA28vSTpnFhNjEUv4Giw2ed3ZXngFZR99DU0UAgkAHqz aLBUzEim6T/gVGNytyb5cNiJwz8BekYXDRKn5rcD2klwKtt7L3a7vglWkMrjC3sQWNLlG1hNtSY = X-Google-Smtp-Source: AGHT+IGcR060EsR0IALdCs35Z+O+iz9qpFuHhOyTob/TJ+Jo8P5ZdA1QjzDKiPJeh+Omk4INqm/U/w== X-Received: by 2002:a17:903:186:b0:20b:b238:9d25 with SMTP id d9443c01a7336-20ca169e7aamr49931745ad.38.1728669419345; Fri, 11 Oct 2024 10:56:59 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (199.211.81.34.bc.googleusercontent.com. [34.81.211.199]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8c36d74bsm25855175ad.305.2024.10.11.10.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 10:56:59 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Yudhistira Erlandinata , Yudhistira Erlandinata , Harvey Yang Subject: [PATCH 1/2] libcamera: Allow enumerating u32 control type Date: Fri, 11 Oct 2024 17:55:11 +0000 Message-ID: <20241011175653.3530945-2-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241011175653.3530945-1-chenghaoyang@chromium.org> References: <20241011175653.3530945-1-chenghaoyang@chromium.org> MIME-Version: 1.0 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" From: Yudhistira Erlandinata Only allowing V4L2_CTRL_TYPE_U32 control type to be listed in the V4L2Device::controls_, so it can be used together with function V4L2Device::setExtControl. Like many other control types, this type is still not supported in the V4L2Device::getControls and V4L2Device::setControls. Signed-off-by: Yudhistira Erlandinata Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang --- include/libcamera/controls.h | 6 ++++++ src/libcamera/controls.cpp | 12 ++++++++++-- src/libcamera/v4l2_device.cpp | 16 +++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index ca60bbaca..25f68040d 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -29,6 +29,7 @@ enum ControlType { ControlTypeNone, ControlTypeBool, ControlTypeByte, + ControlTypeUnsigned32, ControlTypeInteger32, ControlTypeInteger64, ControlTypeFloat, @@ -62,6 +63,11 @@ struct control_type { static constexpr std::size_t size = 0; }; +template<> +struct control_type { + static constexpr ControlType value = ControlTypeUnsigned32; +}; + template<> struct control_type { static constexpr ControlType value = ControlTypeInteger32; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 62185d643..8ae295191 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -54,6 +54,7 @@ static constexpr size_t ControlValueSize[] = { [ControlTypeNone] = 0, [ControlTypeBool] = sizeof(bool), [ControlTypeByte] = sizeof(uint8_t), + [ControlTypeUnsigned32] = sizeof(uint32_t), [ControlTypeInteger32] = sizeof(int32_t), [ControlTypeInteger64] = sizeof(int64_t), [ControlTypeFloat] = sizeof(float), @@ -74,10 +75,12 @@ static constexpr size_t ControlValueSize[] = { * The control stores a boolean value * \var ControlTypeByte * The control stores a byte value as an unsigned 8-bit integer + * \var ControlTypeUnsigned32 + * The control stores an unsigned 32-bit integer value * \var ControlTypeInteger32 - * The control stores a 32-bit integer value + * The control stores a signed 32-bit integer value * \var ControlTypeInteger64 - * The control stores a 64-bit integer value + * The control stores a signed 64-bit integer value * \var ControlTypeFloat * The control stores a 32-bit floating point value * \var ControlTypeString @@ -230,6 +233,11 @@ std::string ControlValue::toString() const str += std::to_string(*value); break; } + case ControlTypeUnsigned32: { + const uint32_t *value = reinterpret_cast(data); + str += std::to_string(*value); + break; + } case ControlTypeInteger32: { const int32_t *value = reinterpret_cast(data); str += std::to_string(*value); diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index 68add4f2e..f3454ba24 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -17,11 +18,14 @@ #include #include +#include #include #include #include +#include + #include "libcamera/internal/formats.h" #include "libcamera/internal/sysfs.h" @@ -488,6 +492,9 @@ ControlType V4L2Device::v4l2CtrlType(uint32_t ctrlType) case V4L2_CTRL_TYPE_BOOLEAN: return ControlTypeBool; + case V4L2_CTRL_TYPE_U32: + return ControlTypeUnsigned32; + case V4L2_CTRL_TYPE_INTEGER: return ControlTypeInteger32; @@ -536,6 +543,11 @@ std::optional V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl static_cast(ctrl.maximum), static_cast(ctrl.default_value)); + case V4L2_CTRL_TYPE_U32: + return ControlInfo(static_cast(ctrl.minimum), + static_cast(ctrl.maximum), + static_cast(ctrl.default_value)); + case V4L2_CTRL_TYPE_BOOLEAN: return ControlInfo(static_cast(ctrl.minimum), static_cast(ctrl.maximum), @@ -622,12 +634,14 @@ void V4L2Device::listControls() case V4L2_CTRL_TYPE_BITMASK: case V4L2_CTRL_TYPE_INTEGER_MENU: case V4L2_CTRL_TYPE_U8: + case V4L2_CTRL_TYPE_U32: break; /* \todo Support other control types. */ default: LOG(V4L2, Debug) << "Control " << utils::hex(ctrl.id) - << " has unsupported type " << ctrl.type; + << " has unsupported type " << ctrl.type + << ". Name: " << ctrl.name; continue; } From patchwork Fri Oct 11 17:55:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21596 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 A585DC32F1 for ; Fri, 11 Oct 2024 17:57:07 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 46BE36538D; Fri, 11 Oct 2024 19:57:07 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Sk4vh6OZ"; dkim-atps=neutral Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id AF2206537D for ; Fri, 11 Oct 2024 19:57:02 +0200 (CEST) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-20caccadbeeso7226875ad.2 for ; Fri, 11 Oct 2024 10:57:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1728669421; x=1729274221; darn=lists.libcamera.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U4EwM6KdWdGgdmknArb6Ok1ElhSNCrsZazTt++T7H4M=; b=Sk4vh6OZDZrrMWZP+Iv+3mjY90RSt8VXDQ/NZ/UuyNn5j6mKAWzuiJBUNEIjWVp7Vh ybHrl6VsPZeB2eeJW+RsLlcj2uMjjNmlKIZ0pp4cwAOeajbILj8XG5KRU9Y5BI8zbebx xW5AqadQUB6I48baIfpsZ9hCGN+FOcHmTttDI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728669421; x=1729274221; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U4EwM6KdWdGgdmknArb6Ok1ElhSNCrsZazTt++T7H4M=; b=QjNg2CdJVCREfMAADL93zqMlzFVNPeiwUVkB5VY1r6jW37ao5BCJGUvbnO2J1NXISr m3TV/cssihnb1bpb9IF5+BRgJxCvOxRIVDfxDwK+8c7tRCL44t3lE7M0Nx1DtLeMgJNY X3ixZhYi1RMlncUmXXmgE4lX27pLI15VQBpaHyTtQtkrLJ3VLLAetgdcpFdejjC5RgPF Sssx9jvNkhR0ieWjozk2PcsrTRAvjmj5ZNc7nnElmAFXRS5xS0tTpLsbDZIAytJsPNdp yxwuoBiOPvHDFzQECMUGrOGEMI7+Qj2+nx4bLzr3Zx1Hs1Ngf+TnrfWTeO3d/O2UdTaM HNmA== X-Gm-Message-State: AOJu0YzmczUl8kZVv6+k3g7bezdzY6w8JhTkETp5ElvbIwQnlsxm8RyQ +pYZRUvyZV2sYebSXbH1N1DMtQ25CojvF13KL/95hQm2gJOt9Ai52jeWT3794MfYqCpgGHsVDEU = X-Google-Smtp-Source: AGHT+IFeLhowiDXqtFKx1jLlmrvbPjMSskNgjpOMlaya0HovLx92p48UouvSactfzCwvq3r/S6UyPg== X-Received: by 2002:a17:903:24b:b0:20c:7bee:a7d3 with SMTP id d9443c01a7336-20ca16d2d99mr34987065ad.50.1728669420836; Fri, 11 Oct 2024 10:57:00 -0700 (PDT) Received: from chenghaoyang-low.c.googlers.com.com (199.211.81.34.bc.googleusercontent.com. [34.81.211.199]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8c36d74bsm25855175ad.305.2024.10.11.10.56.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 10:57:00 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Yudhistira Erlandinata , Yudhistira Erlandinata , Harvey Yang Subject: [PATCH 2/2] libcamera: Add Unsigned 16-bits Control Type Date: Fri, 11 Oct 2024 17:55:12 +0000 Message-ID: <20241011175653.3530945-3-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.rc1.288.g06298d1525-goog In-Reply-To: <20241011175653.3530945-1-chenghaoyang@chromium.org> References: <20241011175653.3530945-1-chenghaoyang@chromium.org> MIME-Version: 1.0 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" From: Yudhistira Erlandinata Some camera metadata is of length 16-bits, for example JPEG metadata headers. Signed-off-by: Yudhistira Erlandinata Co-developed-by: Harvey Yang Signed-off-by: Harvey Yang --- include/libcamera/controls.h | 6 ++++++ src/libcamera/controls.cpp | 8 ++++++++ src/libcamera/v4l2_device.cpp | 9 +++++++++ 3 files changed, 23 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 25f68040d..1987ca5f5 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -29,6 +29,7 @@ enum ControlType { ControlTypeNone, ControlTypeBool, ControlTypeByte, + ControlTypeUnsigned16, ControlTypeUnsigned32, ControlTypeInteger32, ControlTypeInteger64, @@ -63,6 +64,11 @@ struct control_type { static constexpr std::size_t size = 0; }; +template<> +struct control_type { + static constexpr ControlType value = ControlTypeUnsigned16; +}; + template<> struct control_type { static constexpr ControlType value = ControlTypeUnsigned32; diff --git a/src/libcamera/controls.cpp b/src/libcamera/controls.cpp index 8ae295191..3a840bb22 100644 --- a/src/libcamera/controls.cpp +++ b/src/libcamera/controls.cpp @@ -54,6 +54,7 @@ static constexpr size_t ControlValueSize[] = { [ControlTypeNone] = 0, [ControlTypeBool] = sizeof(bool), [ControlTypeByte] = sizeof(uint8_t), + [ControlTypeUnsigned16] = sizeof(uint16_t), [ControlTypeUnsigned32] = sizeof(uint32_t), [ControlTypeInteger32] = sizeof(int32_t), [ControlTypeInteger64] = sizeof(int64_t), @@ -75,6 +76,8 @@ static constexpr size_t ControlValueSize[] = { * The control stores a boolean value * \var ControlTypeByte * The control stores a byte value as an unsigned 8-bit integer + * \var ControlTypeUnsigned16 + * The control stores an unsigned 16-bit integer value * \var ControlTypeUnsigned32 * The control stores an unsigned 32-bit integer value * \var ControlTypeInteger32 @@ -233,6 +236,11 @@ std::string ControlValue::toString() const str += std::to_string(*value); break; } + case ControlTypeUnsigned16: { + const uint16_t *value = reinterpret_cast(data); + str += std::to_string(*value); + break; + } case ControlTypeUnsigned32: { const uint32_t *value = reinterpret_cast(data); str += std::to_string(*value); diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index f3454ba24..cb7327171 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -492,6 +492,9 @@ ControlType V4L2Device::v4l2CtrlType(uint32_t ctrlType) case V4L2_CTRL_TYPE_BOOLEAN: return ControlTypeBool; + case V4L2_CTRL_TYPE_U16: + return ControlTypeUnsigned16; + case V4L2_CTRL_TYPE_U32: return ControlTypeUnsigned32; @@ -543,6 +546,11 @@ std::optional V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl static_cast(ctrl.maximum), static_cast(ctrl.default_value)); + case V4L2_CTRL_TYPE_U16: + return ControlInfo(static_cast(ctrl.minimum), + static_cast(ctrl.maximum), + static_cast(ctrl.default_value)); + case V4L2_CTRL_TYPE_U32: return ControlInfo(static_cast(ctrl.minimum), static_cast(ctrl.maximum), @@ -634,6 +642,7 @@ void V4L2Device::listControls() case V4L2_CTRL_TYPE_BITMASK: case V4L2_CTRL_TYPE_INTEGER_MENU: case V4L2_CTRL_TYPE_U8: + case V4L2_CTRL_TYPE_U16: case V4L2_CTRL_TYPE_U32: break; /* \todo Support other control types. */