From patchwork Tue Oct 22 09:56:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21733 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 4B332C3272 for ; Tue, 22 Oct 2024 09:57:50 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 08AF16539A; Tue, 22 Oct 2024 11:57:50 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="P90WrqgK"; dkim-atps=neutral Received: from mail-oi1-x235.google.com (mail-oi1-x235.google.com [IPv6:2607:f8b0:4864:20::235]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A253965398 for ; Tue, 22 Oct 2024 11:57:46 +0200 (CEST) Received: by mail-oi1-x235.google.com with SMTP id 5614622812f47-3e5f6e44727so3274954b6e.0 for ; Tue, 22 Oct 2024 02:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729591065; x=1730195865; 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=6e/jEup68LFG04U/y9rrob+KzgCI02Y705nbOYdfQH8=; b=P90WrqgKYTqm8GJlPfaU744Uhqgk2McOoEtQWFX1oyptTw/NyvjRY/N8REaNQ2MSue WudTvbuYN7xNSIxvVBQTBF9gexHjygdsR6mEFp1YpC0xOnD8df66Omx58VVorjwFKM7z sYbbbWlsfmSLL0rotzMuqjHcqxVVl9tkoTcWo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591065; x=1730195865; 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=6e/jEup68LFG04U/y9rrob+KzgCI02Y705nbOYdfQH8=; b=AxSomzrjWnDDiuUmitxnaWIkk0pHHZ/4QWjx3YEECANuiS7JxqNrEZCs3MHl9NG5K2 ZLIbZji9zSKM2Pzy68K+dJ6XP7hkLhKtKUtwFiz6tdP3EDTzJ3p1/Vr6TlK9+TN25Waz DoM4MmHQszgr0xvPimH/0GDGgDRlN0gWJWFlXL4ZTF4SlVnASfqjoTKgVrHzh0cbzrJd rXGB7Ia34zEnW8R5lXgfYwZA96NSWkEgHaQzImcbLm633UyOIvuASla6sPjeDkJWmrap QGYH6jakvVeP4YnPazFem44iU+O2Bu5cgYnlBRwc46yjZYilcGp08IoXrAPok9RFJP30 9QGA== X-Gm-Message-State: AOJu0YxWqEQLndKEthPFFFjd05pwRW0gajMepBKGF9hMT+fKWLZCl4da DHqGvMEBZnDzJz/rpYg53KY1iuwPpgfnw7/NKkWdVcmT02Ri2+OkLw8VgmwIc+LjvkGfs6RnQ4k = X-Google-Smtp-Source: AGHT+IEvzRuyE4plKBTiHE227TaJWykocuD0695iYYFAXduXhu7LhXsSrL3OLpumchotOOT0hSvqzA== X-Received: by 2002:a05:6808:1a16:b0:3e3:cd42:58b0 with SMTP id 5614622812f47-3e602da21f6mr10643736b6e.43.1729591064938; Tue, 22 Oct 2024 02:57:44 -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 41be03b00d2f7-7eaeabb9e6fsm4614282a12.66.2024.10.22.02.57.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 02:57:44 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Yudhistira Erlandinata , Harvey Yang Subject: [PATCH v2 1/2] libcamera: Allow enumerating u32 control type Date: Tue, 22 Oct 2024 09:56:04 +0000 Message-ID: <20241022095737.4127210-2-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog In-Reply-To: <20241022095737.4127210-1-chenghaoyang@chromium.org> References: <20241022095737.4127210-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 | 7 +++++++ src/libcamera/controls.cpp | 12 ++++++++++-- src/libcamera/v4l2_device.cpp | 13 +++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index ca60bbaca..6da8ad2c3 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,12 @@ struct control_type { static constexpr std::size_t size = 0; }; +template<> +struct control_type { + static constexpr ControlType value = ControlTypeUnsigned32; + static constexpr std::size_t size = 0; +}; + 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..0ba8dcfa0 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,6 +634,7 @@ 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: From patchwork Tue Oct 22 09:56:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Yang X-Patchwork-Id: 21734 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 18FCDC3272 for ; Tue, 22 Oct 2024 09:57:54 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id A2AE865398; Tue, 22 Oct 2024 11:57:53 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="WwBcqwWb"; dkim-atps=neutral Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3EF056538B for ; Tue, 22 Oct 2024 11:57:49 +0200 (CEST) Received: by mail-oi1-x22d.google.com with SMTP id 5614622812f47-3e5f86e59f1so2461950b6e.1 for ; Tue, 22 Oct 2024 02:57:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1729591068; x=1730195868; 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=h2/Q5hwH59FK3yFBhQBoLSB5gH0qRMHNdLiESlpoNW0=; b=WwBcqwWbCvrpHg0Gc6d5l9kmm8/vCwmpcr0hWn1R9jHJrbvrzl0OCd/wXr+zvd53uG DRYWssx1M3a8u38hVZuYmBVgYyFKeLa/BmVOflz+PISJC7excW24jMQV6myvNau5+nPQ ybYZIVUP7hbcvKpxawAjafu13YT/JcTOazL10= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729591068; x=1730195868; 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=h2/Q5hwH59FK3yFBhQBoLSB5gH0qRMHNdLiESlpoNW0=; b=WksrlGfMxMLNLL2x6aQA05N3/ozcLMrrJpoyydw7l6LIrWk7DsQlviqp9BytAYJWbi ywnzAJfozPn33zC7uC8yRY9YaQBX4py6hZw0UO9BZb2YuaV3S3BUzAh66j4MKOfNEEgf 1ObVla4Ivs9EFM/Bi7HeM8GblU5SUwhl5ySc1DeBUw44OL51YQlbA+G+HuL6rq5Y3+lY IjaaZXSA5gFPRhaPI3DJftCkioY28GLNdhKuZYgzVxBHY8SZee0C667Na6+SArxJyfKG ngrE2qZkxoQrit1q0FcQSMGjM0ulxRr4d/sLSWTXo2MZNulsn7bRSDItTIcCBraAnUEM pMvA== X-Gm-Message-State: AOJu0YwGrfiAzi+rDfYiGR4wXD1ye53+CgCT5vnWMVtlq0PHQ4T2p+od xNOzool9WrzBB3xIsMEOOwIJ+kZx+Bp0fD2inLLE4MMMhQ9Pkit6dWXxXDWELJqgCAJVPvMEcEo = X-Google-Smtp-Source: AGHT+IFCk/Me+ANxGqXbc3X1P1ND7aYAfWuDEnd/RIJIObenHJQTD1io0U1F+Us2tp/x9GbcHHJEzg== X-Received: by 2002:a05:6808:2112:b0:3e3:e67f:5d3a with SMTP id 5614622812f47-3e61d03a7dbmr1952685b6e.45.1729591067688; Tue, 22 Oct 2024 02:57:47 -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 41be03b00d2f7-7eaeabb9e6fsm4614282a12.66.2024.10.22.02.57.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2024 02:57:47 -0700 (PDT) From: Harvey Yang To: libcamera-devel@lists.libcamera.org Cc: Yudhistira Erlandinata , Harvey Yang Subject: [PATCH v2 2/2] libcamera: Add Unsigned 16-bits Control Type Date: Tue, 22 Oct 2024 09:56:05 +0000 Message-ID: <20241022095737.4127210-3-chenghaoyang@chromium.org> X-Mailer: git-send-email 2.47.0.105.g07ac214952-goog In-Reply-To: <20241022095737.4127210-1-chenghaoyang@chromium.org> References: <20241022095737.4127210-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 | 7 +++++++ src/libcamera/controls.cpp | 8 ++++++++ src/libcamera/v4l2_device.cpp | 9 +++++++++ 3 files changed, 24 insertions(+) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index 6da8ad2c3..162115bb5 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,12 @@ struct control_type { static constexpr std::size_t size = 0; }; +template<> +struct control_type { + static constexpr ControlType value = ControlTypeUnsigned16; + static constexpr std::size_t size = 0; +}; + 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 0ba8dcfa0..f1b5a25a0 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. */