From patchwork Tue Nov 15 13:08:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xavier Roumegue X-Patchwork-Id: 17803 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 67DAFBE08B for ; Tue, 15 Nov 2022 13:09:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B0F3E63088; Tue, 15 Nov 2022 14:09:17 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1668517757; bh=xMZTyU7GIQskVoyBvJ1i7zMkm6C4dEjFmBlWGBsiXQY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=RyKcQUs+9rNZs2P31YXDsdpPMcl67yN7iJGLW5gVfQLGBxYFesV0f0P0iH1cUSlog 3WkclMF64eHmK45Rzs8ck+1aAw4VruA3xonk7LF+U3/5KpjZ5fRk3ZqOE4UKwvOZ8k RHqjbmvknEv64LVGk800+V7A10WRo6LjKnkx29XItKZLwYcbmTane9MkZKa7DU7+Nq cbnqPdjEaI9VByoxkI37zZgsK1mF/hpWWBXxKP3wA/u8FvppG0KT+lcWe3K0UN1kFJ KrwrUtgcBObQkKxvOzOVBEoPF3mrgU7p5QTR6GEabl8Bf/iR+4ZC9OD2H70q1bYkLQ UGwCD3yhi7U8g== Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-ve1eur01on060a.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe1f::60a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CF47E63079 for ; Tue, 15 Nov 2022 14:09:15 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="I94oEov/"; dkim-atps=neutral ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZsCWc6mWq4u8N+mHWxposWowrhETA7KASGH80P9XILggwdqj6YA6Eg4Om6sDcS50J0/ZB/WAaT8MqFwjr13eZyKNNFNTCNrvfWm6ZOf/VyBq2E009yacVrkvG7ntFl1yREe6FkwpHU0myh8zMbhut0qRZVV1/p66GyxtXK+dWpEiFb+lXGmlZskzhwwQadi1FTFRA1EpRsptBFok6JnhjA7+l06LlcQTB7WhG8Ehb+4bMAaNos5rP3NgRFHd7YEf2KJuzuR/P+kiGudwW2y+4150T6NQQUFplwO293S9cweULhEaViIeZRyCxgJEypwVNpYB8XORKnvDB7VHwXMrXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=CxqssoK8KoPZH/NNSQYwf78OynqnL2pBUNvmyN5E8Gs=; b=j8Ny60/kaZELz7m+CUFPbSr23yEZJUVhQy5TPa3mzBsM+c7UPqPIdI1bX7CuwasY7sfOEGOH3q7Knm7wqa/OBplTpABnz0DtzZaSoPu1QA84c8h6wSCwS4jFfhFEoaX8g1aHixZvNWPa4RfAIpJoLIzsgf3N/CR8rA/1BBwhSSQtb45+kwRhNZggUEHqIuilADqe1Hi2G8H0fPuVRXre/SmEhKgKAzg5HaGGg11/0xg+bfTLVwEA8pGnwADkE6aijXyfwj4OOLytzQk7/dj89jQe0vAmHJWhQ97fflIKVywnjyC93H7xRcu/iA35hr4sZwTFQDKHOnnDrQ1Lz1tcyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=CxqssoK8KoPZH/NNSQYwf78OynqnL2pBUNvmyN5E8Gs=; b=I94oEov/hvRih/LWyOeqQR6I2OcacBQMikscV6ygHP0wroX2vUQk6F5LHSYd5KW4yptfdu1YwLzKB0KDyPySaf/34Nb+KQTI/FdI+SeWnD88vag3yNu8gRg6r6ZtSFxifJCDapBf/SAlT1MHAwcrt9dxgLz4uRo9OkBVG3LO0No= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) by DB8PR04MB7017.eurprd04.prod.outlook.com (2603:10a6:10:123::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Tue, 15 Nov 2022 13:09:13 +0000 Received: from PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::14d3:8e4:cf07:810d]) by PAXPR04MB8703.eurprd04.prod.outlook.com ([fe80::14d3:8e4:cf07:810d%3]) with mapi id 15.20.5813.018; Tue, 15 Nov 2022 13:09:13 +0000 To: laurent.pinchart@ideasonboard.com Date: Tue, 15 Nov 2022 14:08:48 +0100 Message-Id: <20221115130848.1887943-1-xavier.roumegue@oss.nxp.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: References: X-ClientProxiedBy: PR2P264CA0015.FRAP264.PROD.OUTLOOK.COM (2603:10a6:101::27) To PAXPR04MB8703.eurprd04.prod.outlook.com (2603:10a6:102:21e::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB8703:EE_|DB8PR04MB7017:EE_ X-MS-Office365-Filtering-Correlation-Id: d5efacbc-1a27-4051-683c-08dac70a9772 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Ef+aWlRCQ/tuFKTGNYfilbERsNwxTPtAGVOFCbgB3LSFauUcxe0s5q7fRQXx3N9x9vV63oIovWXfiBF1nHjwz7Yj4ekcStKEJJVIMfcKiPGDdc7LAtZVSH1yNyRaWkdt19iSSo+iLQuckGiYZ1d+eMfIpJ7rdvFW9GkXELI1vqMfFVe6gvLEB0GUATj19SMYgdlsK2BkvmFKK8K7NsyzoCLDMsrOF4SzWhb1faIqsj41GmDmukSDAQR/BYfWqau6QFOzT24J6GHjgvz+CoXsZuHlE0DoxrMWRxUV8Vo0z7ZcDOGiFTJ1JhN8eCpQEv2jC9SV/XLAoePwR3SgYHBLphm4gFWdnqeixzyyBdhJ8CWGgMwRl6K4x3JvZaCgr2jOVib6CoTs2z/swyCltkoGVnP53AEPcls/2p4MXog1HaauOmx/uI1O6e/t0HHqBLA6D1OqdzTQRC1djuAKecFu4cGCz7mWeNko2f2bhlkcinZKDSQTBtXFD8YoTTJHmEZXpmru29OlVw+O3v/lQO8mPgseqa/bKVjub/bARY+PW+DPCF4zaRT6EJ3lwp239qvMT4zbjd0cuC6L6RezmrPXqKF2PNC2z86J7mHxLBbpjQ6Ujwuk4ePpb44VJ/6TtMvsW4OteWLGl4+cKEnF/gEVr33Xd6XtmZahxFvtmbbmSbI9myQlwkuw77jFsAcwT2wJ+91aPaC7tMJ+XImUlfr0hA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB8703.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(346002)(366004)(376002)(39860400002)(136003)(396003)(451199015)(478600001)(6666004)(6486002)(6916009)(4326008)(316002)(6512007)(19627235002)(52116002)(2616005)(66556008)(66476007)(186003)(8936002)(41300700001)(1076003)(8676002)(5660300002)(44832011)(66946007)(2906002)(6506007)(38100700002)(83380400001)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: b5cuKps9/ALP5fq3iMuc7zrd4uNXG7eC0TWyyAnL5yruprdptZoAZJ9BGB4L3+AgIRuGM23P7Kf9ZU8WRGRCxD6PUZ5xkM8dd3FZZfUviEw1Gp1t8giBf8kdcOcfroajn+qHnQmZ/4FV1n/oXpldEp5UAfgVoDCYJcNecR4EA/J/XJnt3IJbftPK6O81HP1pDG4S7/OhV93pBvrJ57n6EY2bap6JFxZQW4qLJOMbTuETnKxzQg7BdA4mdyaj01TRWRgqPO8+ZJsy4SvQYClc9Rh/2IhsGen0sz+yGu3E3G9gQ/S80TW0B9YIQo8DvYOUrQg5tX+kmOJXThQ92aYGjAbjd6eqA0a87mjSO1sjP8blPotXdtIlc8LFMssiauRcuuKZiA77QnRl+iVrqKPsg0TnhXBA9wZAfBKmx/umUkEZ8fOmLgqsGpPbZcV9cbYSZhiIZEqLMXa2NvrS+7DMfrBq4ODCYhcnCa9GtHKeF6kYqZ/7EP2ThWyy/URV5ZUetGudu4SaOyY3JS8CY51bG+1jAcVuTNi7UO3VBvgWADE6MkJWvsGRAV2Pf5r7A/sQVqdC7rBjaSlnypJUx/aP4GJp8vB4dYnldAhFGK2EoC+KBi8kyfNcDbJR6XG8XhIvyBCyX67DLEDt3P2WP136wwKdzlOj91HQOgPek/SRGjXCMyHDsw0jgS7ES1Y9nrP0cXvqDoLtUAUeWGAIlHaQzR8v7z6I0w9HRudvtYCYmUg7OIyLnm4JjqNkf0wixbH9+WbXgWJ3MTgJ0RKLMMIpkqWVzkz1bRgFgPMFagRbtSVgFjP0TGTrjxB6IaeGZ9hC7mHlZw2tBbt7SKqUnD9pH3sHAcmCP5zJvYHubA8b41y/McHcJrCVaZr4Tqk/WJ+boxwIdoqSgyQW06ycXb2jVFhs1o8Gt3BlgQOiof8p/U6MtYTmRHgJ4syDR3U/H8mc+HSXPRcwxbY0r703iCGidDZy9x7Tx241hfayvH1AhHUixi+rD7iv096RF6kA8/NiMf7nYhuIwfcXcdlON2mD6kjHsdG9F6sSC3xbkigI1by84W/R7QrP1EGEnARj+8zcLVCKoeecykbUz78Jz1N5PpP3pwbgZZ9nLhHUFvaB8mT0ayG66kTsalJJjPRWAfBi6kTWBsTEgIZK7Pxse7B8kvtf5uF3oF5KIXMh9F0QviQDG522BhR8qzkx/dO4lDMjG3HamcYrTSPc6QuowaNvRl2RZXe7Nr1RZ+AZum9q6hYgr9X3b0nLYH4fP4LCNmRCmErK082VRStW48FVhbLyGhcmX3umf/M9q3Np67UCO9EB6N79coRbGGHmAl2KYs5tea39lE5pmkhI0ZYM7XwomO1Gd2/u2vBb1UVDJcOtHl/7M1OtajKGP0VkPwUqHH2EunuwmVs2ek03IckvpB1crxDNITZrAphtBqaK7Wg3SCF/HddVhHkmBO5v3RD2TiGtTNKea1VTHg7AnPHxlw9qUYtj777hGJlNuAx63p4hpec/HwaSLF+0eVxKSNiBDOGE1ilDpgTfYe7ZAKks+KL7zgu6/XKCpDkuJZ54b4OiB2+bz2Ty0gFtTugZnEl5PNKfwTH7CsMAoWUWkWEPVQcI3OyQDyuinjxhev5o+hYQ5dMPZMDFVhFKZfXen4T2iPyYTOh89HC1brb41NIzgSC3wQ== X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d5efacbc-1a27-4051-683c-08dac70a9772 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB8703.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2022 13:09:13.2222 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nd2ADDT5JiftsaPI1ArJkiRuFm6xxE7DVOsfKP2cuLUPqLo0JPmLE4lBtHmxs4rts8Lzl8+lP/UchFj4XTd8Xw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7017 Subject: [libcamera-devel] [PATCH] libcamera: v4l2_device: Add support for V4L2_CTRL_TYPE_U32 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: , X-Patchwork-Original-From: Xavier Roumegue via libcamera-devel From: Xavier Roumegue Reply-To: Xavier Roumegue Cc: libcamera-devel@lists.libcamera.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Support for the U16 and U32 compound control types is missing. U16 will require a new libcamera control type, but U32 maps to the existing ControlTypeInteger32 and can be added easily. Signed-off-by: Xavier Roumegue --- include/libcamera/controls.h | 5 +++++ src/libcamera/v4l2_device.cpp | 32 ++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/include/libcamera/controls.h b/include/libcamera/controls.h index cf942055..2039fb1f 100644 --- a/include/libcamera/controls.h +++ b/include/libcamera/controls.h @@ -62,6 +62,11 @@ struct control_type { static constexpr ControlType value = ControlTypeInteger32; }; +template<> +struct control_type { + static constexpr ControlType value = ControlTypeInteger32; +}; + template<> struct control_type { static constexpr ControlType value = ControlTypeInteger64; diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index c17b323f..01dfb379 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -204,12 +204,26 @@ ControlList V4L2Device::getControls(const std::vector &ids) v4l2Ctrl.id = id; if (info.flags & V4L2_CTRL_FLAG_HAS_PAYLOAD) { - ControlType type; + ControlValue &value = ctrl.second; switch (info.type) { - case V4L2_CTRL_TYPE_U8: - type = ControlTypeByte; + case V4L2_CTRL_TYPE_U8: { + value.reserve(ControlTypeByte, true, info.elems); + Span data = value.data(); + v4l2Ctrl.p_u8 = data.data(); + v4l2Ctrl.size = data.size_bytes(); + break; + } + + case V4L2_CTRL_TYPE_U32: { + value.reserve(ControlTypeInteger32, true, info.elems); + Span data( + reinterpret_cast(value.data().data()), + info.elems); + v4l2Ctrl.p_u32 = data.data(); + v4l2Ctrl.size = data.size_bytes(); break; + } default: LOG(V4L2, Error) @@ -218,12 +232,7 @@ ControlList V4L2Device::getControls(const std::vector &ids) return {}; } - ControlValue &value = ctrl.second; - value.reserve(type, true, info.elems); - Span data = value.data(); - v4l2Ctrl.p_u8 = data.data(); - v4l2Ctrl.size = data.size(); } } @@ -490,6 +499,7 @@ ControlType V4L2Device::v4l2CtrlType(uint32_t ctrlType) return ControlTypeBool; case V4L2_CTRL_TYPE_INTEGER: + case V4L2_CTRL_TYPE_U32: return ControlTypeInteger32; case V4L2_CTRL_TYPE_INTEGER64: @@ -551,6 +561,11 @@ ControlInfo V4L2Device::v4l2ControlInfo(const v4l2_query_ext_ctrl &ctrl) case V4L2_CTRL_TYPE_MENU: return v4l2MenuControlInfo(ctrl); + case V4L2_CTRL_TYPE_U32: + return ControlInfo(static_cast(ctrl.minimum), + static_cast(ctrl.maximum), + static_cast(ctrl.default_value)); + default: return ControlInfo(static_cast(ctrl.minimum), static_cast(ctrl.maximum), @@ -615,6 +630,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: