From patchwork Tue Apr 25 09:45:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Riesch X-Patchwork-Id: 677457 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB31BC77B61 for ; Tue, 25 Apr 2023 09:45:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233613AbjDYJpj (ORCPT ); Tue, 25 Apr 2023 05:45:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233704AbjDYJpc (ORCPT ); Tue, 25 Apr 2023 05:45:32 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2078.outbound.protection.outlook.com [40.107.21.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 045EE5FE0; Tue, 25 Apr 2023 02:45:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TYnO6QQivTGNifrhYRHyBF3V1GuF95LDT1kZi2TNJMwpyhiPrl8UqBFlZL9xkKu6GPYZzHtRKxtVzYSQjUWmai7a+/GpMWQO2bjs12DivOguNJJ9z9EoXwhcKVKaA0aMTM9zh/QOfUDUGbv9ea/nihnBLitpdllSCv3DFLVPrx5A2/lbN9OI0HYrUb6/+gZ49upkIR1PDPo2GHwBWLDcUvvsoQOAEMHHopWXGmq/mbWZxfnWfxaQNP3PlnKRZsNtpyt9ch66YNDQ5+euHbEROmxCdgNf4CEr85gdOIM8x94qfVVhfPRmZrTBl2kaVKElG6RxZvmO4e8N4OghEblGpA== 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=eLuld8DVZQUl9JD96D4KgwpO+GrK8L1VnMH9Vmashgs=; b=O0WtZoFrTFLpLnaf/uRLqA7jclSQ78Efw2Bqt2QnYjnns46YNkFJON0eTbnLfpCLJBxGuVrUpoGPZbVLGJ7/6t/lt82pzMNr42R3pt58Qpynw/i3ojePgDnzybGcdAmhztRA5aKaT3jwyyVbFHJRCRbrDJ9E+PWqvrWjpdFHI0vSBMumhwKNcwAahplBKWhrEA/4y4C313ZUj6d0E28dAeIcI1R2WlyV3YcZlqgl0QaVF83S8BlLdxOVvfiTuofNW7TAjCX62VE9uwLdcCqSv76gIh6HPpln5HANfCxCoi8IBQ8qbyAs1iTOlr7fNutDg6TfhEJKtRgBH6MPqU8QMg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eLuld8DVZQUl9JD96D4KgwpO+GrK8L1VnMH9Vmashgs=; b=lmrNszoFMKjBRS+Ae5fm1mtwYRAcI9a3p0f8BespJ7GkiCMrHzs7GSKpTjEBDaXEagOa4Q1XI+OcD2gBPoLFxCHhBoL0d2M0f6Ys1x6u3ZOAQfwplasDgf7xN8tuLj78SjZKLhhf8gnkPasBllHRoX4q8EocAojNdF8d+ryVB5Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=wolfvision.net; Received: from GV1SPRMB0046.eurprd08.prod.outlook.com (2603:10a6:150:84::17) by DU0PR08MB7995.eurprd08.prod.outlook.com (2603:10a6:10:3e2::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6319.33; Tue, 25 Apr 2023 09:45:25 +0000 Received: from GV1SPRMB0046.eurprd08.prod.outlook.com ([fe80::3734:409a:8031:4f54]) by GV1SPRMB0046.eurprd08.prod.outlook.com ([fe80::3734:409a:8031:4f54%3]) with mapi id 15.20.6319.034; Tue, 25 Apr 2023 09:45:25 +0000 From: Michael Riesch Date: Tue, 25 Apr 2023 11:45:13 +0200 Subject: [PATCH RFC v2 3/6] media: v4l2-ctrls: add lens group status controls for zoom and focus Message-Id: <20230406-feature-controls-lens-v2-3-faa8ad2bc404@wolfvision.net> References: <20230406-feature-controls-lens-v2-0-faa8ad2bc404@wolfvision.net> In-Reply-To: <20230406-feature-controls-lens-v2-0-faa8ad2bc404@wolfvision.net> To: Mauro Carvalho Chehab Cc: libcamera-devel@lists.libcamera.org, Laurent Pinchart , Sakari Ailus , Hans Verkuil , Matthias Fend , Dave Stevenson , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Riesch X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1682415922; l=5400; i=michael.riesch@wolfvision.net; s=20230425; h=from:subject:message-id; bh=jTe/P0FictDH0WXUKp4+aPsn/OR0dr8kofVL2EiodPU=; b=q+A4kfSu5mcb74thT71W0+NUs8JKLAvBQnN4oe+mwNlYiI9s0a5IS8ab/NrMWzdGOWMGIOtQm jYP3VNmdccTB+y15tld68yx3ooPyKxoPA6VxIYpNm+B3DQ1gJJN6TaW X-Developer-Key: i=michael.riesch@wolfvision.net; a=ed25519; pk=1QQdXA2QbwdxaQn/VQK0hz04C8IBYhDowbK0hlNU4Ng= X-ClientProxiedBy: VI1PR0802CA0032.eurprd08.prod.outlook.com (2603:10a6:800:a9::18) To GV1SPRMB0046.eurprd08.prod.outlook.com (2603:10a6:150:84::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1SPRMB0046:EE_|DU0PR08MB7995:EE_ X-MS-Office365-Filtering-Correlation-Id: c9bbbe5b-b84d-4d9e-12df-08db4571cb9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uCeHmzylZzfasjO4Jxrz/E1vxsIZsEQJdCArZxUNgdZ1pJUPT2qKcn2d5B0pa0ZjwCulumhU/7lIIOkT7OylzKvxDyhdIXjRlTDydTHQpO46WrtXyIttEtgbXIgyGk0zBU+VbxRPxgaIPgvTLYcaoIIuYOrHJcvHfuvydZLR5q8+bOSmpT/I8hvv4x9A1lOoxTzF2JIRpYYPDWSoDH/fdm+7fn4+QIC2EgbqLpeABfKGtAr8CVToHO9udlu+pdH7PRYMYOeWsM6O0wNXlS1Au48/1nSCfYULB/dz5qXji/j82ugHujPqFVOrGzvl+PEOo1NzVQj46Pkf8xDzJdaZgxST9ugh3p5zg+XYdDa0utL93bUoRY/ObPq22ko7kK8GrE156Y0OxUgcj0xxcM9+5CLIrNdwTrBHdVYHteu3hbeT/Xft2i/OuXcQaYkCpwTAi8+kdkwYMGXhXyCJu02T/NkTjLeY2fd5r+7bPI98ykqcS3/DxpmDjmy/lb7dPW5uXRT54R7quEvZ5jwqC1XU5MxCWkZBXXOACK20MFS2Cl+5VpUy/70bCOS5G8VKVx/mAA5eUAz4SKHLpMHPjPhDfS7cGogpJ9dJ6pIz2wlmvQKeGqZTRdPtLIVTxvkeVTRD X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:GV1SPRMB0046.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(376002)(136003)(396003)(366004)(39850400004)(346002)(451199021)(38350700002)(38100700002)(6506007)(6512007)(26005)(186003)(8936002)(2616005)(83380400001)(107886003)(44832011)(2906002)(8676002)(5660300002)(36756003)(478600001)(54906003)(6486002)(52116002)(316002)(6666004)(4326008)(6916009)(66556008)(41300700001)(66946007)(86362001)(66476007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?t5a23Tbe589dDKR6RSgmcK913Y/t?= =?utf-8?q?n4BOqX7/Z8DZYoq1voYl1sewwTr+yTHvo4V2ODGsrMHIyjguvk42/dqDXx0CBBviq?= =?utf-8?q?WOPoEgNUx5SlrgSjVgSb1njk41G0iPJgEKONJ4Z+vIve9L2/ObhYySsoAyCeOZmsz?= =?utf-8?q?GKbkZd5vkgxmRaTkV/Ii1SUN/Y+QwUvJQ79vf4hn+26UPgAsyAV3jjeFMlIkWEJvH?= =?utf-8?q?x543jIWwk60GLitYJsuonhDLLH9aGor3Zv9jNHhpD22KoS42vVEzLGKcB4fUYSSHm?= =?utf-8?q?+RjQRLAfVsz84UESG/3M/D8eCzmsN42IGuEzx04V5QUjwWf8i0wmfthpbmtFaslFk?= =?utf-8?q?mFEcDC8GttWUlG6MJGfspe/gH1MQ2AIZ5nKvLl6WApJV14zg56GQnLAnrv/dg8FFI?= =?utf-8?q?8soQdZW79h8X2nBSzsTS4S/oh+vV72H0Kb7TOwsuXEHrsi9myxVboSOitFC/tPaxs?= =?utf-8?q?3IzXbfCCglQVTv9XwXu0r5C1CNtKocRieXVQQHK0ThRw9FgZtktxCUkGrbEVKQldv?= =?utf-8?q?tnFzXt+NXODHih4u2DO+rmqVQZLbwrVEU2KRl/YEqqdCJiRa1bb/shACVX38QnqjB?= =?utf-8?q?srWXlLfrHwHpmel2OOmizx7yu2y+L54+kiY5lZa90+oVtjwEv6IRJDSRlSr5PQJbk?= =?utf-8?q?hFbAQGKAWXc6e73Qv340/S0IgR9O7mtmS7AUv9Gk+k9xJQtHCUiidCZVLC1KI8KSF?= =?utf-8?q?uxgvSOmX5x+v4vMfa3k+m9ebl9hX+1Xmz3bp0+MKxPwStrEzdwqhmztLkkqdh+MzS?= =?utf-8?q?mKM+GK1kr8pTer7GkU5bYE3SH/ZuAvSqx7gNphpzJRZRXMV28v+rvN5QIVV5xKrlA?= =?utf-8?q?7ec8bd1VizAJJ4RLNAGTCa3QPvJN9iUKpXUJHJcn8E+AeDO0UnL7yKMcQmTnJKTi1?= =?utf-8?q?uGYHbDixwbL4GnAIJg3rzk6/w4H5M8cc1AZfQgNy76eq94uOGiBC8pzbr26xWSFtz?= =?utf-8?q?+9aYgd4xj9L1fu1fJ/QZMirP6vlO5fm9Sqx3V1A4mvnC1W1jaEM4xrWsNNjsOTJya?= =?utf-8?q?WjbLJ9K2c+PxVK7ivUCfHaCrry9IQZmVpV2TrwcYfRJ9AQmk2qXSvcRBclogSvBZW?= =?utf-8?q?tj/Jp43UaHnDWD5pl7blYsx1RihiXgxX9DAOrzonT7AzHAYDEYRStUp12FAdZC+6Z?= =?utf-8?q?ZW2F3SoukjLr8t93SxChSTVuEXV0XgrMz5dNnGZ6Lt1PyDpfK56astlTqWqB1SFcz?= =?utf-8?q?lnFGwbvvtr3tnoJyuONX29NA3PiykPXtR0e4f9xSOOaRY1nTqaQ1RZ1b+ihvAPEyI?= =?utf-8?q?jfSztXHgO0Ycb5JRqloS8/rs7UbMpUHQCmU91KQynYSbo9GFhxcyplg8G9D0wkQ02?= =?utf-8?q?OcRX909vMHrrZavQPRDifOoW4l26InbMncyI6o3tSEL1dhP8PGVxcf6XEIVLsmeIe?= =?utf-8?q?3pIO7bFbFi8lDSDBnNh9P0P2bLf8r/4KORZrzUJczhDoguUId3uZkTrmLHluYg48Y?= =?utf-8?q?EHH1uTe02Og9fU4wj0Dc0fph7rwQkjQ+eu6UPgpQOZojoKs3b8+US39B4O3qXQ2dc?= =?utf-8?q?CRPQRjTglyNbfXQTWhWf5wfx7Gy+8ULJcg=3D=3D?= X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: c9bbbe5b-b84d-4d9e-12df-08db4571cb9c X-MS-Exchange-CrossTenant-AuthSource: GV1SPRMB0046.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2023 09:45:25.4366 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: iBtpHv1xbmlZF57ajBLFX6fQh5kB4SJyuslA6EDvQY0EoCKob87W/Cq83ZqLjBoGFgcsop658jp/A2wJj8qgmXcsxaZHeU+j8+M1kBZd4Mk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7995 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Add the controls V4L2_CID_{FOCUS,ZOOM}_{CURRENT,STATUS} that report the current position and status, respectively, of the zoom lens group and the focus lens group. Signed-off-by: Michael Riesch --- .../userspace-api/media/v4l/ext-ctrls-camera.rst | 46 ++++++++++++++++++++++ drivers/media/v4l2-core/v4l2-ctrls-defs.c | 10 +++++ include/uapi/linux/v4l2-controls.h | 9 +++++ 3 files changed, 65 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst index 42cf4c3cda0c..3ea4175f9619 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-camera.rst @@ -150,6 +150,29 @@ enum v4l2_exposure_metering - write-only control. It should be implemented only if the device cannot handle absolute values. +``V4L2_CID_FOCUS_CURRENT (integer)`` + The current position of the focal point. The unit is undefined. Larger + values indicate that the focus is closer to the camera, smaller values + indicate that the focus is closer to infinity. This is a read-only control. + +``V4L2_CID_FOCUS_STATUS (bitmask)`` + The status of the focus lens group. The possible flags are described in + the table below. This is a read-only control. + +.. tabularcolumns:: |p{6.8cm}|p{10.7cm}| + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + + * - ``V4L2_LENS_STATUS_IDLE`` + - Focus lens group is at rest. + * - ``V4L2_LENS_STATUS_BUSY`` + - Focus lens group is moving. + * - ``V4L2_LENS_STATUS_FAILED`` + - Focus lens group has failed to reach its target position. The driver + will not transition from this state until another action is performed + by an application. ``V4L2_CID_FOCUS_AUTO (boolean)`` Enables continuous automatic focus adjustments. The effect of manual @@ -241,6 +264,29 @@ enum v4l2_auto_focus_range - movement. A negative value moves the zoom lens group towards the wide-angle direction. The zoom speed unit is driver-specific. +``V4L2_CID_ZOOM_CURRENT (integer)`` + The current objective lens focal length. The unit is undefined and + its value should be a positive integer. This is a read-only control. + +``V4L2_CID_ZOOM_STATUS (bitmask)`` + The status of the zoom lens group. The possible flags are described in + the table below. This is a read-only control. + +.. tabularcolumns:: |p{6.8cm}|p{10.7cm}| + +.. flat-table:: + :header-rows: 0 + :stub-columns: 0 + + * - ``V4L2_LENS_STATUS_IDLE`` + - Zoom lens group is at rest. + * - ``V4L2_LENS_STATUS_BUSY`` + - Zoom lens group is moving. + * - ``V4L2_LENS_STATUS_FAILED`` + - Zoom lens group has failed to reach its target position. The driver will + not transition from this state until another action is performed by an + application. + ``V4L2_CID_IRIS_ABSOLUTE (integer)`` This control sets the camera's aperture to the specified value. The unit is undefined. Larger values open the iris wider, smaller values diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c index 564fedee2c88..794ef3ab0c02 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -1044,6 +1044,10 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_CAMERA_ORIENTATION: return "Camera Orientation"; case V4L2_CID_CAMERA_SENSOR_ROTATION: return "Camera Sensor Rotation"; case V4L2_CID_HDR_SENSOR_MODE: return "HDR Sensor Mode"; + case V4L2_CID_FOCUS_CURRENT: return "Focus, Current"; + case V4L2_CID_FOCUS_STATUS: return "Focus, Status"; + case V4L2_CID_ZOOM_CURRENT: return "Zoom, Current"; + case V4L2_CID_ZOOM_STATUS: return "Zoom, Status"; /* FM Radio Modulator controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ @@ -1593,6 +1597,12 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, *flags |= V4L2_CTRL_FLAG_WRITE_ONLY | V4L2_CTRL_FLAG_EXECUTE_ON_WRITE; break; + case V4L2_CID_FOCUS_CURRENT: + case V4L2_CID_FOCUS_STATUS: + case V4L2_CID_ZOOM_CURRENT: + case V4L2_CID_ZOOM_STATUS: + *flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_VOLATILE; + break; case V4L2_CID_FLASH_STROBE_STATUS: case V4L2_CID_AUTO_FOCUS_STATUS: case V4L2_CID_FLASH_READY: diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 5e80daa4ffe0..793ee8c65e87 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -993,6 +993,15 @@ enum v4l2_auto_focus_range { #define V4L2_CID_HDR_SENSOR_MODE (V4L2_CID_CAMERA_CLASS_BASE+36) +#define V4L2_LENS_STATUS_IDLE (0 << 0) +#define V4L2_LENS_STATUS_BUSY (1 << 0) +#define V4L2_LENS_STATUS_FAILED (1 << 2) + +#define V4L2_CID_FOCUS_CURRENT (V4L2_CID_CAMERA_CLASS_BASE+37) +#define V4L2_CID_FOCUS_STATUS (V4L2_CID_CAMERA_CLASS_BASE+38) +#define V4L2_CID_ZOOM_CURRENT (V4L2_CID_CAMERA_CLASS_BASE+39) +#define V4L2_CID_ZOOM_STATUS (V4L2_CID_CAMERA_CLASS_BASE+40) + /* FM Modulator class control IDs */ #define V4L2_CID_FM_TX_CLASS_BASE (V4L2_CTRL_CLASS_FM_TX | 0x900)