From patchwork Wed Jul 16 09:06:51 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 115831 Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uby6z-0006zW-0W for patchwork@linuxtv.org; Wed, 16 Jul 2025 09:07:40 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 8449F1A60B9F for ; Wed, 16 Jul 2025 09:07:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3874D2F003E; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="fSk538Rj" X-Original-To: linux-media@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B64A528B4EA; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656848; cv=none; b=Aq8gble+1IdnDL/hktQC3AATUCJqYgsbppPQJ7K6MhLeeMh+BeNKI63qqGoiALlYJaPAuczsCBcHkLXkFgXZOl+aqrHxNxzALU9jwxXLJCkRgHWequeBeR3PhbsqG5MjJbuKbP+O7eJzAT//c/AjMYPEtDZSdp02rLqyP7MHE1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656848; c=relaxed/simple; bh=0nzpfTzsTCcWDqac7ZTk2BZgJrXNm8rZpSw6OMimBsU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oOwLcWkNFn0a6QooU6tRjILEpmfPoTQxmcycT8hYFFbY7DDimDKqD5hJNmr6FMZKref1bPGbaNBt+eHC6qIveqw1HH9dsxMwqI7o/clt9I2Z7iPfj3p4I/kXRkt20fDR9x1EnuKf9BHOaIYZKaxp2XgLDeHyyMTtMIErNdgGTMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=fSk538Rj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 7918EC4CEF6; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1752656848; bh=0nzpfTzsTCcWDqac7ZTk2BZgJrXNm8rZpSw6OMimBsU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=fSk538RjF1tdMUKROR4uR9mlhUsyT5498o8kra2auofzQ6ZRisTe/+VxI80lgLCnx hWfvmDCUmlfe2hLr8tPKtnVqBzfo1FEihl0DiFy+feVn6+5lEc9rGSwwf/s+uSj8kW 6AD0qo0p0ngwjNHriq2WEHAZXcABnOfAq+DVO0Ig= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A22CC83F1B; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) From: Richard Leitner Date: Wed, 16 Jul 2025 11:06:51 +0200 Subject: [PATCH v6 01/11] media: v4l: ctrls: add a control for flash/strobe duration Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250716-ov9282-flash-strobe-v6-1-934f12aeff33@linux.dev> References: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> In-Reply-To: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752656846; l=1793; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=0nzpfTzsTCcWDqac7ZTk2BZgJrXNm8rZpSw6OMimBsU=; b=juVuqNIAo95NqjiFbbrFMnZ7vfSLwdFTjoEXauwNrnReH8hzs5zm81UCZqvsU0wZTMTNuMenP nHLOY3zROL0Df6VkWil8eQbY0Bkq0Hm2DeAj5PEhE0Mup8nqKbWOtML X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Add a control V4L2_CID_FLASH_DURATION to set the duration of a flash/strobe pulse. This is different to the V4L2_CID_FLASH_TIMEOUT control, as the timeout defines a limit after which the flash is "forcefully" turned off again. On the other hand the new V4L2_CID_FLASH_DURATION is the desired length of the flash/strobe pulse. Signed-off-by: Richard Leitner --- drivers/media/v4l2-core/v4l2-ctrls-defs.c | 1 + include/uapi/linux/v4l2-controls.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c index 1ea52011247accc51d0261f56eab1cf13c0624a0..f9ed7273a9f3eafe01c31b638e1c8d9fcf5424af 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -1135,6 +1135,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_FLASH_FAULT: return "Faults"; case V4L2_CID_FLASH_CHARGE: return "Charge"; case V4L2_CID_FLASH_READY: return "Ready to Strobe"; + case V4L2_CID_FLASH_DURATION: return "Strobe Duration"; /* JPEG encoder controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 72e32814ea83dee5f1202c1249eac7cf3b85a22a..72c6bd26e2dfa23a0224e745e5cd07c9fca0c8b5 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -1180,6 +1180,7 @@ enum v4l2_flash_strobe_source { #define V4L2_CID_FLASH_CHARGE (V4L2_CID_FLASH_CLASS_BASE + 11) #define V4L2_CID_FLASH_READY (V4L2_CID_FLASH_CLASS_BASE + 12) +#define V4L2_CID_FLASH_DURATION (V4L2_CID_FLASH_CLASS_BASE + 13) /* JPEG-class control IDs */ From patchwork Wed Jul 16 09:06:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 115834 Received: from ny.mirrors.kernel.org ([147.75.199.223]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uby75-0006zy-0J for patchwork@linuxtv.org; Wed, 16 Jul 2025 09:07:43 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 87DCC16D107 for ; Wed, 16 Jul 2025 09:07:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 723E62F0E58; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="jlbVdEv2" X-Original-To: linux-media@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E4C42F002A; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; cv=none; b=jHoTgZESjzjTTawAAE0c1aSSyoH02mMNjRJvCM9V6Wx3eqlQuAbasL73LIXJh1tzTGPNWSlRuxML5BmbD2R9CrqTKMQqlu7E+KIayC0bk2IRfbpp2oar+dqUWb6FonmqsJaeWbkPGhKqrP7xHEKk3h4KFExk++LtE/B6bVMBZxU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; c=relaxed/simple; bh=gr3klb2qn/si0DKlrwgsy7RcVLdFswJfwWGpC4vYwHU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=qSWZSTJqNn1bjwHZ6HPGGINixhptYisU4Wy/cNMDRKmrqt6KIBhdhSKDsSJDXdSBh8d4oqQhcVFzBYS9Jkz167CA/OYZSDTzDlEOudiCkIstaWzwmIlkPi0DEMgGx+goeVye++goJeCH3sKvgGJn6te+9MmT6AqFBZ7/ee1JVyQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=jlbVdEv2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 87DA3C4CEF7; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1752656848; bh=gr3klb2qn/si0DKlrwgsy7RcVLdFswJfwWGpC4vYwHU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=jlbVdEv23bSJIVPXAiYmoDhI54KK8+I2HlyNp0ibloUXltnAfpfZQggo1lu7PCGHf xyw2LiSIWNTUohp4rH+ys+wFczuTvESuRqW7FPSs/b8Eg051UtbT1H34LmBu7zgk5P RzJlCFNYfzrLj+29AOORWhdO6mwi6o1+Hb5WHC48= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AB58C83F34; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) From: Richard Leitner Date: Wed, 16 Jul 2025 11:06:52 +0200 Subject: [PATCH v6 02/11] media: v4l2-flash: add support for flash/strobe duration Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250716-ov9282-flash-strobe-v6-2-934f12aeff33@linux.dev> References: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> In-Reply-To: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752656846; l=2308; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=gr3klb2qn/si0DKlrwgsy7RcVLdFswJfwWGpC4vYwHU=; b=px+x9vE68LStX/ralvumHYmo9bqPNJpgMqwVzRd1Y2yGTgcdLwXo5m//qJDFo25dv5XhLFm+D vMbnpH40fLNBCN2hOb+RbWApZIL3U1KQRlobj4tQayhty5JNWxKd4tC X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Add support for the new V4L2_CID_FLASH_DURATION control to the v4l2 flash led class. Signed-off-by: Richard Leitner --- drivers/media/v4l2-core/v4l2-flash-led-class.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c index 355595a0fefac72c2f6941a30fa430d37dbdccfe..875d56d7190592c1e5ab7acd617b76dcec8792da 100644 --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c @@ -29,6 +29,7 @@ enum ctrl_init_data_id { INDICATOR_INTENSITY, FLASH_TIMEOUT, STROBE_SOURCE, + FLASH_DURATION, /* * Only above values are applicable to * the 'ctrls' array in the struct v4l2_flash. @@ -298,6 +299,12 @@ static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c) * microamperes for flash intensity units. */ return led_set_flash_brightness(fled_cdev, c->val); + case V4L2_CID_FLASH_DURATION: + /* + * No conversion is needed as LED Flash class also uses + * microseconds for flash duration units. + */ + return led_set_flash_duration(fled_cdev, c->val); } return -EINVAL; @@ -424,6 +431,14 @@ static void __fill_ctrl_init_data(struct v4l2_flash *v4l2_flash, ctrl_cfg->flags = V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_EXECUTE_ON_WRITE; } + + /* Init FLASH_DURATION ctrl data */ + if (has_flash_op(fled_cdev, duration_set)) { + ctrl_init_data[FLASH_DURATION].cid = V4L2_CID_FLASH_DURATION; + ctrl_cfg = &ctrl_init_data[FLASH_DURATION].config; + __lfs_to_v4l2_ctrl_config(&fled_cdev->duration, ctrl_cfg); + ctrl_cfg->id = V4L2_CID_FLASH_DURATION; + } } static int v4l2_flash_init_controls(struct v4l2_flash *v4l2_flash, @@ -543,6 +558,16 @@ static int __sync_device_with_v4l2_controls(struct v4l2_flash *v4l2_flash) return ret; } + if (ctrls[FLASH_DURATION]) { + if (WARN_ON_ONCE(!fled_cdev)) + return -EINVAL; + + ret = led_set_flash_duration(fled_cdev, + ctrls[FLASH_DURATION]->val); + if (ret < 0) + return ret; + } + /* * For some hardware arrangements setting strobe source may affect * torch mode. Synchronize strobe source setting only if not in torch From patchwork Wed Jul 16 09:06:53 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 115837 Received: from sv.mirrors.kernel.org ([139.178.88.99]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uby78-00070F-29 for patchwork@linuxtv.org; Wed, 16 Jul 2025 09:07:47 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 566A75068EE for ; Wed, 16 Jul 2025 09:07:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 871702F1989; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="0S1Fz9NH" X-Original-To: linux-media@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B3DA2F0032; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; cv=none; b=OGemERFYV7LrSiqHsvXT2YpViKl4eDAUZxXP3kGDIMlkK6jpBi/8RvAsI2Ec2qarCmHudZqMz0kh6WTlN8RixTb2DHc9NFtGlN5iTQSkyKfpE1NUjmSDdMfW5jdfkBRQOF6tQ91UeD9nHzoH0T3sy2M3QMqLC8MqoObbTywLH98= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; c=relaxed/simple; bh=16N0ehkJWytFD5jx5wDbSTZhtNf5Qf6vx2SOhlkAC1Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=E+WckFBXlEYPnKYPGq2BQq1rB4aTpzPn7Q0W1eWxdnkh316HONFSWffrGZe0uG4aRYSLHhthpalm6wgP/QRDvyAbbaeyZh3gouSPzzXGPgSekRTpYROjCdb08ieEeWFjPnaxSWfdUxj4HXhI8d7V5xHMu9EhL7uR7a/qZhhddrw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=0S1Fz9NH; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 97079C4CEFA; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1752656848; bh=16N0ehkJWytFD5jx5wDbSTZhtNf5Qf6vx2SOhlkAC1Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=0S1Fz9NHLreNHMsFQDPbmEBVA5WiLozPhsHxP0glzMPazWaNz5wXMjDk42fxpQLCt sogQb3JKjsPkgYMzv1L9Cbqko989YCGZuVN13cVhqmEmyXV/07WrOTBjZC51G/2Swn uldOAe0QvUmiYtWkaNlhkkMXw82UG9hV+r/F922A= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CF15C83F27; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) From: Richard Leitner Date: Wed, 16 Jul 2025 11:06:53 +0200 Subject: [PATCH v6 03/11] Documentation: uAPI: media: add V4L2_CID_FLASH_DURATION Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250716-ov9282-flash-strobe-v6-3-934f12aeff33@linux.dev> References: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> In-Reply-To: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752656846; l=1038; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=16N0ehkJWytFD5jx5wDbSTZhtNf5Qf6vx2SOhlkAC1Y=; b=2B+Gv74UFX6PUNRdjV6Z/Z0kllFK3uFqjwXKDUIOQCbtS3bPR0LdlL/ZRpjHItIASDRwNLXP9 RL9uD5DshvrCRQ3+h4tuT4V23mMa/ovMX2Mp8VY8mhyG+ESXmW/IDR7 X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Add the new strobe_duration control to v4l uAPI documentation. Signed-off-by: Richard Leitner --- Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst index d22c5efb806a183a3ad67ec3e6550b002a51659a..03a58ef94be7c870f55d5a9bb09503995dbfb402 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst @@ -186,3 +186,8 @@ Flash Control IDs charged before strobing. LED flashes often require a cooldown period after strobe during which another strobe will not be possible. This is a read-only control. + +``V4L2_CID_FLASH_DURATION (integer)`` + Duration the flash should be on when the flash LED is in flash mode + (V4L2_FLASH_LED_MODE_FLASH). The unit should be microseconds (µs) + if possible. From patchwork Wed Jul 16 09:06:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 115840 Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uby78-00070E-2o for patchwork@linuxtv.org; Wed, 16 Jul 2025 09:07:48 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 2D8411A60C42 for ; Wed, 16 Jul 2025 09:08:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 849732F1983; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="XvrZaWUy" X-Original-To: linux-media@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29D642F002E; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; cv=none; b=hQXjk/ukS85O9NyD2XIeforjYo9jDHo459BE51WgD4evM+hwK6h4Jr4wCJvrlIKaH5t9mTO18Zd2dgth9ejaLZe9s4AQsuOfCE3gqCAZz6N3eNpB+Og4JP10YaSwUmYe2JdidpNrBv2ZGccbx0bwElSCZ6gxyNmwxnTjkHHquxM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; c=relaxed/simple; bh=+3yfsgI+RLqnieyZVNdemukQE4ylJowi0on/ywo/VYE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IKTUo6xfJNPuGroDGOZrs3CQB8swNX1oPWXUUcU9CMXEH+zDBCyswOBB7IzqEniChx7dbRvCGARKTDs4N6CUGay7+8gJJaedspRpsl4XPRVfrbXp9EMWmN6yWgqsix7BUkOd+bKFZC0veer0uR9HNBBffh9axz6gk/4khSaMUUI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=XvrZaWUy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id A651DC4CEFF; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1752656848; bh=+3yfsgI+RLqnieyZVNdemukQE4ylJowi0on/ywo/VYE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XvrZaWUySVdLJ9Fgs+5B9HOTQV97MH3oyHFk42hHZI1ItQmdAkeTApEPo2IkQ4Ug/ T/GgVAnerd276owyN4pOr8+ZMlytCFbYnBtQmVKDz1R3JQxxy0ueTA8qqbxqgcNeKb whST2OYx0be+IPprfnk1U5Cu31Ewrj2QR0vVWDgA= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BCFAC83F22; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) From: Richard Leitner Date: Wed, 16 Jul 2025 11:06:54 +0200 Subject: [PATCH v6 04/11] media: v4l: ctrls: add a control for enabling hw strobe signal Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250716-ov9282-flash-strobe-v6-4-934f12aeff33@linux.dev> References: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> In-Reply-To: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752656846; l=2084; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=+3yfsgI+RLqnieyZVNdemukQE4ylJowi0on/ywo/VYE=; b=9JLb25GYJCpdRkX12l+TSBfT4FDrm9DsPLtQqGsFQjGUtvDvf0cWjAkaFN2zsAit1TcoQYgID wSnEbm5q+cBDeKgTGp2H2pYpSyJUKUFx+hwiCZr8ZpPcx65gjhqxo0Y X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Add a control V4L2_CID_FLASH_HW_STROBE_SIGNAL to en- or disable the strobe output of v4l2 devices (most likely sensors). Signed-off-by: Richard Leitner --- drivers/media/v4l2-core/v4l2-ctrls-defs.c | 2 ++ include/uapi/linux/v4l2-controls.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2-core/v4l2-ctrls-defs.c index f9ed7273a9f3eafe01c31b638e1c8d9fcf5424af..e13214ca362b9bdd2302118963008b04fcad8d4c 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls-defs.c +++ b/drivers/media/v4l2-core/v4l2-ctrls-defs.c @@ -1136,6 +1136,7 @@ const char *v4l2_ctrl_get_name(u32 id) case V4L2_CID_FLASH_CHARGE: return "Charge"; case V4L2_CID_FLASH_READY: return "Ready to Strobe"; case V4L2_CID_FLASH_DURATION: return "Strobe Duration"; + case V4L2_CID_FLASH_HW_STROBE_SIGNAL: return "Hardware Strobe Signal"; /* JPEG encoder controls */ /* Keep the order of the 'case's the same as in v4l2-controls.h! */ @@ -1282,6 +1283,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type, case V4L2_CID_FLASH_STROBE_STATUS: case V4L2_CID_FLASH_CHARGE: case V4L2_CID_FLASH_READY: + case V4L2_CID_FLASH_HW_STROBE_SIGNAL: case V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER: case V4L2_CID_MPEG_VIDEO_DECODER_SLICE_INTERFACE: case V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE: diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h index 72c6bd26e2dfa23a0224e745e5cd07c9fca0c8b5..ad693870bef951df168f43d50c3e9d4255deed91 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -1181,6 +1181,7 @@ enum v4l2_flash_strobe_source { #define V4L2_CID_FLASH_CHARGE (V4L2_CID_FLASH_CLASS_BASE + 11) #define V4L2_CID_FLASH_READY (V4L2_CID_FLASH_CLASS_BASE + 12) #define V4L2_CID_FLASH_DURATION (V4L2_CID_FLASH_CLASS_BASE + 13) +#define V4L2_CID_FLASH_HW_STROBE_SIGNAL (V4L2_CID_FLASH_CLASS_BASE + 14) /* JPEG-class control IDs */ From patchwork Wed Jul 16 09:06:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 115846 Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uby7V-00071B-1t for patchwork@linuxtv.org; Wed, 16 Jul 2025 09:08:14 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 707B31A60BDC for ; Wed, 16 Jul 2025 09:08:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B6532F2376; Wed, 16 Jul 2025 09:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="e+UQZq50" X-Original-To: linux-media@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42F1C2F0043; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; cv=none; b=KVPPLAIi91TQpN/OB4bg1pIo9ftQBHAJX22Le0I0tzrMk1gZg5H15vYctY8Q5UsWEhuGsHXjwOPZIPG5rzAiC+h9mOg2CUNY5W2/k4ldYZXwZ9hsYY8cVhoG/AIS/O7cnj0R6AH64LQmFf1K/vdQQRgunfMysX+44y0JSVSFrEo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; c=relaxed/simple; bh=lJUA/HTTIB5OPd67y2vtLKCQ0ts0kps9jsdTJGZwJyk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JMDM0Y69t1aBHrMfLeMSm/Y26fs8AtgIPbyQ/EeRSRQjcMbNnnY/fszZ2ZohUND3iR3js6cUQn/bIu1hXucMi8lZLkGHHf8cSatdyLCSsqJc1/95rShk/p75cKd19H7pIY+wIiQbZqj4QgY4fIu+bt+SGBfNxQYpc4SsZMth72w= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=e+UQZq50; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id B79C6C113D0; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1752656848; bh=lJUA/HTTIB5OPd67y2vtLKCQ0ts0kps9jsdTJGZwJyk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=e+UQZq503SrHrerIHJeO14RQVxMPFxeSfQ+OMMBuOAsoHn5NlQvMxWjWwVktagrRU cg+ztK8a6GevrOZgviSJT3++n5ayUY+O7WOSafrP67geUvhiyVXDEzTD9iK3qXLis8 OWz/cx+puPPJhhkjKP4QL7ByPrtYX9vidKZBES9g= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADA34C83F35; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) From: Richard Leitner Date: Wed, 16 Jul 2025 11:06:55 +0200 Subject: [PATCH v6 05/11] Documentation: uAPI: media: add V4L2_CID_FLASH_HW_STROBE_SIGNAL Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250716-ov9282-flash-strobe-v6-5-934f12aeff33@linux.dev> References: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> In-Reply-To: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752656846; l=1182; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=lJUA/HTTIB5OPd67y2vtLKCQ0ts0kps9jsdTJGZwJyk=; b=fgleXUKtAWZqXdfokkA0eBdArbpobxJ1udxoGb1AqOJYHsBbOpTldfB36V1u4A7tSEODoDGeR OxvfJ0g4Z9wCGcPDWTfYitJ/ReFtGYA6NMO3BnyPiGb3R1j8VzgoVDJ X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Add new hardware strobe signal control to v4l uAPI documentation. Signed-off-by: Richard Leitner --- Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst b/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst index 03a58ef94be7c870f55d5a9bb09503995dbfb402..af43e7329cb77cf952b8996cd8c5384eae08c3fc 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst @@ -191,3 +191,9 @@ Flash Control IDs Duration the flash should be on when the flash LED is in flash mode (V4L2_FLASH_LED_MODE_FLASH). The unit should be microseconds (µs) if possible. + +``V4L2_CID_FLASH_HW_STROBE_SIGNAL (boolean)`` + Enable or disable the output of a hardware strobe signal. This is typically + set on a sensor that provides a hardware strobe output which is connected + to a flash device/LEDs. The flash device should then be configured to use + an external strobe source (V4L2_FLASH_STROBE_SOURCE_EXTERNAL). From patchwork Wed Jul 16 09:06:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 115849 X-Patchwork-Delegate: sakari.ailus@iki.fi Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uby7W-00071E-05 for patchwork@linuxtv.org; Wed, 16 Jul 2025 09:08:15 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id EA0E51A60DF3 for ; Wed, 16 Jul 2025 09:08:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B5D12F2375; Wed, 16 Jul 2025 09:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="Pd/m3w8X" X-Original-To: linux-media@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4189E2F0042; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; cv=none; b=K5mWo/nLXgMEcKHqczjiFWQQCAC0YGU1OukgPU0DjBiW1DYDvu4/EnitQgjU2fnFnEAC21LV5b/F9UBXAalhCkDNTsMUDuadSdPL2m708VvNUI1YV061Ge3kI5aKkyirorywvvDfoydsUgHv+t4/e9MFyxR0Hsvk5iGZ6C7bZyk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; c=relaxed/simple; bh=FNa/xvakH+OMufv25Oa47P8olVqt6It8kjPg/VhP/1A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LxHFB523G4a1zRDoOWg90/jCCxAz19orWuiRrBngwBWILbYt4bV6fk40sdGk/O0lAw+efHbP7w3VmizUp+yEN7tAdg3ECVQG/s2arbg40zvN1pREjhYnTyiP6hzzmWT5WLuVJozh2Rk9sHvL85Crd7G5LR0VurX1/7iBHrgyiEI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Pd/m3w8X; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id C5AEAC4CEFE; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1752656848; bh=FNa/xvakH+OMufv25Oa47P8olVqt6It8kjPg/VhP/1A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Pd/m3w8XL6R1MUdvL0LHz+/o0u+iKeJ6t4fXd+Gp2Rg7jTWOhYEL6NY74gdcHk6Ap 6IYVsQ+ZbwHeMf+KuBh680j2Z+OVzf7FJyPFe9vFAcw/40jCZXYEwkyl83Vzb/GAv7 quPouWbUSPhK87sz0xsHc2QWxXTKNZr2GtwZVtzM= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD5D3C83F34; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) From: Richard Leitner Date: Wed, 16 Jul 2025 11:06:56 +0200 Subject: [PATCH v6 06/11] media: i2c: ov9282: add output enable register definitions Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250716-ov9282-flash-strobe-v6-6-934f12aeff33@linux.dev> References: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> In-Reply-To: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752656846; l=2191; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=FNa/xvakH+OMufv25Oa47P8olVqt6It8kjPg/VhP/1A=; b=xZS61+beaIFH4Qq2Mq9HlpOKOK5Q//6l5S7jfEfueRw9Ikg5s8PNmlcroyHIho4BQkuWYcayS 59OmBp9E/pKAEUA8PmGrU1Blah32e8PgO+M3rT9yH5ug3d/gLjVpzFR X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Add #define's for the output enable registers (0x3004, 0x3005, 0x3006), also known as SC_CTRL_04, SC_CTRL_05, SC_CTRL_04. Use those register definitions instead of the raw values in the `common_regs` struct. All values are based on the OV9281 datasheet v1.53 (january 2019). Reviewed-by: Dave Stevenson Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index c882a021cf18852237bf9b9524d3de0c5b48cbcb..f42e0d439753e74d14e3a3592029e48f49234927 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -37,6 +37,29 @@ #define OV9282_REG_ID 0x300a #define OV9282_ID 0x9281 +/* Output enable registers */ +#define OV9282_REG_OUTPUT_ENABLE4 0x3004 +#define OV9282_OUTPUT_ENABLE4_GPIO2 BIT(1) +#define OV9282_OUTPUT_ENABLE4_D9 BIT(0) + +#define OV9282_REG_OUTPUT_ENABLE5 0x3005 +#define OV9282_OUTPUT_ENABLE5_D8 BIT(7) +#define OV9282_OUTPUT_ENABLE5_D7 BIT(6) +#define OV9282_OUTPUT_ENABLE5_D6 BIT(5) +#define OV9282_OUTPUT_ENABLE5_D5 BIT(4) +#define OV9282_OUTPUT_ENABLE5_D4 BIT(3) +#define OV9282_OUTPUT_ENABLE5_D3 BIT(2) +#define OV9282_OUTPUT_ENABLE5_D2 BIT(1) +#define OV9282_OUTPUT_ENABLE5_D1 BIT(0) + +#define OV9282_REG_OUTPUT_ENABLE6 0x3006 +#define OV9282_OUTPUT_ENABLE6_D0 BIT(7) +#define OV9282_OUTPUT_ENABLE6_PCLK BIT(6) +#define OV9282_OUTPUT_ENABLE6_HREF BIT(5) +#define OV9282_OUTPUT_ENABLE6_STROBE BIT(3) +#define OV9282_OUTPUT_ENABLE6_ILPWM BIT(2) +#define OV9282_OUTPUT_ENABLE6_VSYNC BIT(1) + /* Exposure control */ #define OV9282_REG_EXPOSURE 0x3500 #define OV9282_EXPOSURE_MIN 1 @@ -213,9 +236,9 @@ static const struct ov9282_reg common_regs[] = { {0x0302, 0x32}, {0x030e, 0x02}, {0x3001, 0x00}, - {0x3004, 0x00}, - {0x3005, 0x00}, - {0x3006, 0x04}, + {OV9282_REG_OUTPUT_ENABLE4, 0x00}, + {OV9282_REG_OUTPUT_ENABLE5, 0x00}, + {OV9282_REG_OUTPUT_ENABLE6, OV9282_OUTPUT_ENABLE6_ILPWM}, {0x3011, 0x0a}, {0x3013, 0x18}, {0x301c, 0xf0}, From patchwork Wed Jul 16 09:06:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 115852 X-Patchwork-Delegate: sakari.ailus@iki.fi Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uby7a-00071P-1I for patchwork@linuxtv.org; Wed, 16 Jul 2025 09:08:15 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 769641A60E03 for ; Wed, 16 Jul 2025 09:08:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 740292F270F; Wed, 16 Jul 2025 09:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="aYNAT7Hd" X-Original-To: linux-media@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 601912F0C4E; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; cv=none; b=RIbutoHt71j84PiU7wvM4lFJt7za2FBwdDw7xIRrcEXYJHgwaH7MoDvVPfHcPvVrnASu3JeDIiICFEyCDtmkaBsROPQkyDT3qHJ6D+OSMhBfC6H73s3ziXpc+jcOn5e03oAqP5frS8iOHLa9wolHNSYy4VdOzGQ/3ZIR3307boQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; c=relaxed/simple; bh=DVb2HLHwrfJtO//bc3VRsb0hyCqNgQp8x5qpbcne0Ys=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WEcEZJe9HX8/q4FXpGdd9n7qAzTN5ImliRqM/pqRZhV08q+HCprExkHoNjy96D97oc3uyyAhCURST/EOrhJ8q9rjuKfA55FLiBHIOo5q2mPb9XY5kETed1VdWLADms5Ss5zUWD47/tPMNRlY1wMy+R89QMH+lDsrq/BujVZn31Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=aYNAT7Hd; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id D2413C16AAE; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1752656848; bh=DVb2HLHwrfJtO//bc3VRsb0hyCqNgQp8x5qpbcne0Ys=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=aYNAT7HdBIJ9Eqm3dfqnoX/Vj6+m4tmDH3Ey38n+w2iSeKrmWXdTRr+LzwNP2CVZG DyvsaRgsjgj+Tm96WhFsk3uxWJv8GO2xpjvw1zmUY/36LiPd8SLT+eSesjsFSMM+UO ljQvcNeJunuI4WdjmyOlK9Pk+5afyJnmNViDdEJA= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB090C83F22; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) From: Richard Leitner Date: Wed, 16 Jul 2025 11:06:57 +0200 Subject: [PATCH v6 07/11] media: i2c: ov9282: add hardware strobe signal v4l2 control Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250716-ov9282-flash-strobe-v6-7-934f12aeff33@linux.dev> References: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> In-Reply-To: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752656846; l=2400; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=DVb2HLHwrfJtO//bc3VRsb0hyCqNgQp8x5qpbcne0Ys=; b=CzubrJjchnVd3ZCU9hzZoOlBznhvp21S3RgWbc16NuHqX2ukGjo78RjhO56KctJormFevOb6c hm8SDwa3NGDD1FhaxFjys5T8huUD4Tu+C1vLSncY70bX6SHuu9quMPW X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Add V4L2_CID_FLASH_HW_STROBE_SIGNAL enable/disable support using the "strobe output enable" feature of the sensor. All values are based on the OV9281 datasheet v1.53 (january 2019) and tested using an ov9281 VisionComponents module. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index f42e0d439753e74d14e3a3592029e48f49234927..ff0f69f0dc3a2d0518806b9ea65c1b520b5c55fb 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -670,6 +670,23 @@ static int ov9282_set_ctrl_vflip(struct ov9282 *ov9282, int value) current_val); } +static int ov9282_set_ctrl_flash_hw_strobe_signal(struct ov9282 *ov9282, bool enable) +{ + u32 current_val; + int ret = ov9282_read_reg(ov9282, OV9282_REG_OUTPUT_ENABLE6, 1, + ¤t_val); + if (ret) + return ret; + + if (enable) + current_val |= OV9282_OUTPUT_ENABLE6_STROBE; + else + current_val &= ~OV9282_OUTPUT_ENABLE6_STROBE; + + return ov9282_write_reg(ov9282, OV9282_REG_OUTPUT_ENABLE6, 1, + current_val); +} + /** * ov9282_set_ctrl() - Set subdevice control * @ctrl: pointer to v4l2_ctrl structure @@ -736,6 +753,9 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) ret = ov9282_write_reg(ov9282, OV9282_REG_TIMING_HTS, 2, (ctrl->val + ov9282->cur_mode->width) >> 1); break; + case V4L2_CID_FLASH_HW_STROBE_SIGNAL: + ret = ov9282_set_ctrl_flash_hw_strobe_signal(ov9282, ctrl->val); + break; default: dev_err(ov9282->dev, "Invalid control %d", ctrl->id); ret = -EINVAL; @@ -1326,7 +1346,7 @@ static int ov9282_init_controls(struct ov9282 *ov9282) u32 lpfr; int ret; - ret = v4l2_ctrl_handler_init(ctrl_hdlr, 10); + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 11); if (ret) return ret; @@ -1391,6 +1411,9 @@ static int ov9282_init_controls(struct ov9282 *ov9282) OV9282_TIMING_HTS_MAX - mode->width, 1, hblank_min); + /* Flash/Strobe controls */ + v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_HW_STROBE_SIGNAL, 0, 1, 1, 0); + ret = v4l2_fwnode_device_parse(ov9282->dev, &props); if (!ret) { /* Failure sets ctrl_hdlr->error, which we check afterwards anyway */ From patchwork Wed Jul 16 09:06:58 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 115855 X-Patchwork-Delegate: sakari.ailus@iki.fi Received: from ny.mirrors.kernel.org ([147.75.199.223]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uby7a-00071O-0N for patchwork@linuxtv.org; Wed, 16 Jul 2025 09:08:16 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7BAFA1716FC for ; Wed, 16 Jul 2025 09:08:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 708362F2709; Wed, 16 Jul 2025 09:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="VBEWO04E" X-Original-To: linux-media@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 615992F0C78; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; cv=none; b=it6yH3Iv6aB/krz1yO9wn6cEEM4D7v6daUonqLJZEEvz2BrSGIKETSXEQ/WEAPjxggN4s+v66xWUuV9d2SM9pMU7GvzWPBP3/putESXTRZHq9ytjtVZViJtcNe3FUMHcYxFFojjc42wzHx6p6xOEV5BeHz4qz03UrHed/8u2ZZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; c=relaxed/simple; bh=zHiadu/PJkoFNn6YwHGG0Az+tad6OHewe3uLyIg6GGY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=KwGXt4Or4M2LbBrlI/xGOoBDGji4tG8wPrKYq1RgDWcDn7n7b01SgmhmG5T8ekyjurWuNEkQ9hOWDiw0QgTTKfVCb7AR7vg1eKGysTzb6cYDUUo1aniFaKR6iICnTRE9D8j3RHS5xWz5966zpPAZKT3OfOagXHG+uIRmdX0SPwQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=VBEWO04E; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id E0CD3C116B1; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1752656848; bh=zHiadu/PJkoFNn6YwHGG0Az+tad6OHewe3uLyIg6GGY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VBEWO04Eei3rOgdkp0Ont0lqxoDh6fUZZ5q14K+dzMzSXut85u4uGumxXdai8vu6H YIDhrOSepfyvzrfw/LG8potW3LgW5UYOHUE8u0wfDjlXGaYBYKOkj1auScIXdCWvhY CC3APXTMAgUzdiX+/YYx0HEW8kZ22lKgmi616s94= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA263C83F1B; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) From: Richard Leitner Date: Wed, 16 Jul 2025 11:06:58 +0200 Subject: [PATCH v6 08/11] media: i2c: ov9282: add strobe_duration v4l2 control Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250716-ov9282-flash-strobe-v6-8-934f12aeff33@linux.dev> References: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> In-Reply-To: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752656846; l=3529; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=zHiadu/PJkoFNn6YwHGG0Az+tad6OHewe3uLyIg6GGY=; b=5x8wEvBlJrMpU4Dvl76SKrtJ5vNHFGanJ9RAixuL8pYgJqHP5IwhivQuV6TmUxMHHr0CTnQ0x hJ/Q4wAQCUiD5dskb70SVsYLDYEfyH1vfCR+8zcEmv4Z8y+Uzp80X9D X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no Add V4L2_CID_FLASH_DURATION support using the "strobe_frame_span" feature of the sensor. This is implemented by transforming the given µs value by an interpolated formula to a "span step width" value and writing it to register PWM_CTRL_25, PWM_CTRL_26, PWM_CTRL_27, PWM_CTRL_28 (0x3925, 0x3926, 0x3927, 0x3928). The maximum control value is set to the period of the current default framerate. All register values are based on the OV9281 datasheet v1.53 (jan 2019) and tested using an ov9281 VisionComponents module. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index ff0f69f0dc3a2d0518806b9ea65c1b520b5c55fb..c405e3411daf37cf98d5af3535702f8321394af5 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -97,6 +97,10 @@ #define OV9282_REG_MIPI_CTRL00 0x4800 #define OV9282_GATED_CLOCK BIT(5) +/* Flash/Strobe control registers */ +#define OV9282_REG_FLASH_DURATION 0x3925 +#define OV9282_FLASH_DURATION_DEFAULT 0x0000001a + /* Input clock rate */ #define OV9282_INCLK_RATE 24000000 @@ -687,6 +691,25 @@ static int ov9282_set_ctrl_flash_hw_strobe_signal(struct ov9282 *ov9282, bool en current_val); } +static int ov9282_set_ctrl_flash_duration(struct ov9282 *ov9282, u32 value) +{ + /* + * Calculate "strobe_frame_span" increments from a given value (µs). + * This is quite tricky as "The step width of shift and span is + * programmable under system clock domain.", but it's not documented + * how to program this step width (at least in the datasheet available + * to the author at time of writing). + * The formula below is interpolated from different modes/framerates + * and should work quite well for most settings. + */ + u32 val = value * 192 / (ov9282->cur_mode->width + ov9282->hblank_ctrl->val); + + ov9282_write_reg(ov9282, OV9282_REG_FLASH_DURATION, 1, (val >> 24) & 0xff); + ov9282_write_reg(ov9282, OV9282_REG_FLASH_DURATION + 1, 1, (val >> 16) & 0xff); + ov9282_write_reg(ov9282, OV9282_REG_FLASH_DURATION + 2, 1, (val >> 8) & 0xff); + return ov9282_write_reg(ov9282, OV9282_REG_FLASH_DURATION + 3, 1, val & 0xff); +} + /** * ov9282_set_ctrl() - Set subdevice control * @ctrl: pointer to v4l2_ctrl structure @@ -756,6 +779,9 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_FLASH_HW_STROBE_SIGNAL: ret = ov9282_set_ctrl_flash_hw_strobe_signal(ov9282, ctrl->val); break; + case V4L2_CID_FLASH_DURATION: + ret = ov9282_set_ctrl_flash_duration(ov9282, ctrl->val); + break; default: dev_err(ov9282->dev, "Invalid control %d", ctrl->id); ret = -EINVAL; @@ -1346,7 +1372,7 @@ static int ov9282_init_controls(struct ov9282 *ov9282) u32 lpfr; int ret; - ret = v4l2_ctrl_handler_init(ctrl_hdlr, 11); + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 12); if (ret) return ret; @@ -1414,6 +1440,9 @@ static int ov9282_init_controls(struct ov9282 *ov9282) /* Flash/Strobe controls */ v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_HW_STROBE_SIGNAL, 0, 1, 1, 0); + v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_DURATION, + 0, 13900, 1, 8); + ret = v4l2_fwnode_device_parse(ov9282->dev, &props); if (!ret) { /* Failure sets ctrl_hdlr->error, which we check afterwards anyway */ From patchwork Wed Jul 16 09:06:59 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 115861 X-Patchwork-Delegate: sakari.ailus@iki.fi Received: from sv.mirrors.kernel.org ([139.178.88.99]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uby7f-00072P-0y for patchwork@linuxtv.org; Wed, 16 Jul 2025 09:08:19 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id AF2EE506DF6 for ; Wed, 16 Jul 2025 09:07:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4CA572F237C; Wed, 16 Jul 2025 09:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="mMCC6+cQ" X-Original-To: linux-media@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57C512F0C42; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; cv=none; b=kn14dmvGmJFgYLCrx8hM+GNEFd7S+Zd34+PCsfwFxsdkHdhCNyKESPF9u0ys1PccvwrALZyA2uQzvHah/DcFOUslidR23quupyNJVTv7o0U8C7EHiDY+stCpCF4fq2jWsy2OswDrsfzKCzrC6faTsQ8iWPjaPbaDCKX71BAQSe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; c=relaxed/simple; bh=2+Ajed5E1fXJz3nZ8NS8d6YJI4WoVgJl21IHABX6Yk4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=rUS7QBl09b3EUqyUD38iVnj+BdZ7j+BUO+740kU/D4Lm9ewN3g1VxfVDfMFr2fYzpxZLA0HrYjJCrD/k/CeEdNzpwsV/DLdFR1skjmciHaFzaZst0bSwAnQJHnBRssTc3GItQs2083po8tDFMdCj6f/vxWKNNp8NftMROB7V3w4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=mMCC6+cQ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id EF811C19423; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1752656849; bh=2+Ajed5E1fXJz3nZ8NS8d6YJI4WoVgJl21IHABX6Yk4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=mMCC6+cQ1AWxdD6Z1u0VbU3T+hB+KF3na4v6uikrebHkUYC846mF33RdEu7zjsR7e nxUWMlBVpo3fHxD9TpR4myGn0jIAhKaEH7lrDPGWk5uLaqBV+YUHc9TdkJj1kEbEM/ JV+7qmr/QdanDlRxiALbTNfWhSsDVrp7bIZ+YmCU= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E92CAC83F27; Wed, 16 Jul 2025 09:07:28 +0000 (UTC) From: Richard Leitner Date: Wed, 16 Jul 2025 11:06:59 +0200 Subject: [PATCH v6 09/11] media: i2c: ov9282: add strobe_source v4l2 control Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250716-ov9282-flash-strobe-v6-9-934f12aeff33@linux.dev> References: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> In-Reply-To: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752656846; l=1686; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=2+Ajed5E1fXJz3nZ8NS8d6YJI4WoVgJl21IHABX6Yk4=; b=SBTlZgEpfezcgQEPk2xrbfseZKqRbyiQhjvk6aOeAEGZ+SF4bpGFYtLJzfughFQMW3ApHmkp0 agZN2zfdanjBgHQjkb2KLiYK3lRAdZHdCODPJh/uBuVQqzxNISJeS7u X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no Add read-only V4L2_CID_FLASH_STROBE_SOURCE control. Its value is fixed to V4L2_FLASH_STROBE_SOURCE_EXTERNAL as the camera sensor triggers the strobe based on its register settings. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index c405e3411daf37cf98d5af3535702f8321394af5..9efc82a1929a76c6fb245e7dbfb5276a133d1c5d 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -1368,11 +1368,12 @@ static int ov9282_init_controls(struct ov9282 *ov9282) struct v4l2_ctrl_handler *ctrl_hdlr = &ov9282->ctrl_handler; const struct ov9282_mode *mode = ov9282->cur_mode; struct v4l2_fwnode_device_properties props; + struct v4l2_ctrl *ctrl; u32 hblank_min; u32 lpfr; int ret; - ret = v4l2_ctrl_handler_init(ctrl_hdlr, 12); + ret = v4l2_ctrl_handler_init(ctrl_hdlr, 13); if (ret) return ret; @@ -1443,6 +1444,14 @@ static int ov9282_init_controls(struct ov9282 *ov9282) v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_DURATION, 0, 13900, 1, 8); + ctrl = v4l2_ctrl_new_std_menu(ctrl_hdlr, &ov9282_ctrl_ops, + V4L2_CID_FLASH_STROBE_SOURCE, + V4L2_FLASH_STROBE_SOURCE_EXTERNAL, + ~(1 << V4L2_FLASH_STROBE_SOURCE_EXTERNAL), + V4L2_FLASH_STROBE_SOURCE_EXTERNAL); + if (ctrl) + ctrl->flags |= V4L2_CTRL_FLAG_READ_ONLY; + ret = v4l2_fwnode_device_parse(ov9282->dev, &props); if (!ret) { /* Failure sets ctrl_hdlr->error, which we check afterwards anyway */ From patchwork Wed Jul 16 09:07:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 115858 X-Patchwork-Delegate: sakari.ailus@iki.fi Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uby7d-000725-2i for patchwork@linuxtv.org; Wed, 16 Jul 2025 09:08:19 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5DC3F1A60E3E for ; Wed, 16 Jul 2025 09:08:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D3092F2718; Wed, 16 Jul 2025 09:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vT/J8cOT" X-Original-To: linux-media@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6FB702F0E55; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; cv=none; b=oPy8LJ+IcMkZdYW26JR09cAwusblSw9DZQ8jMKfIpg3ZUNFmCjTdKT4nlXH75xa4nP/NaAqjteJwx09xfTX16QwkPSbr1aqsGLN5WKsEa+H6W4XKl1N52KfXgCVMKnuygIGBxR4CRrxEOl2AAfOY//0rziDmlTD9J+NXUuNRxG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; c=relaxed/simple; bh=zpPHdpszebqthTo574ANivruP/PT3WTF/uH/e9F0K+Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uui2jML8myorhvW7lHberTRNTRDQ7N+DAgRurDQE81orN6HoKpQ7ADXefyAW2S/LsM/3vpVW+/zRfV60R9XxWWdlSwiJjiPS1/LJuJQfKSfyNUfZ80B3Wmjn5uEj1Ekki5phdrHgtNeo1u4U6GC3JGvpIkSbyCGbdLIBufVta/o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vT/J8cOT; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 0B0E8C4CEF6; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1752656849; bh=zpPHdpszebqthTo574ANivruP/PT3WTF/uH/e9F0K+Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=vT/J8cOT+JNtUVIbNyxar/K9EZifT4sFZN9UD71d20F7zLtFFPQSkrfO1goUoB7hB 4etOeaOl1E9wCWy/FU1GDV833fgDrswhZfk70+fVJ8vYaWYpoGiKcFxUtJvsu21wpF 1KiEwe3fhWfVBeEny8/eawedrT1GM8tLp8WmIF1w= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 05146C83F34; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) From: Richard Leitner Date: Wed, 16 Jul 2025 11:07:00 +0200 Subject: [PATCH v6 10/11] media: i2c: ov9282: implement try_ctrl for strobe_duration Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250716-ov9282-flash-strobe-v6-10-934f12aeff33@linux.dev> References: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> In-Reply-To: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752656846; l=3557; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=zpPHdpszebqthTo574ANivruP/PT3WTF/uH/e9F0K+Q=; b=Fsa9/j05Zmy7liPoe6CfjaQSR1rWDhQWXqxWq5SFQgRYIppoyU1Mrpga6ULa2A3X1C5ehpdfj qF+2mjSpqgfCSCJc+mIhMarCFZDYb4XQAhTr+On2mJLAXQumDrRSalG X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no As the granularity of the hardware supported values is lower than the control value, implement a try_ctrl() function for V4L2_CID_FLASH_DURATION. This function calculates the nearest possible µs strobe duration for the given value and returns it back to the caller. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 54 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 9efc82a1929a76c6fb245e7dbfb5276a133d1c5d..b104ae77f00e9e7777342e48b7bf3caa6d297f69 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -128,6 +128,8 @@ #define OV9282_REG_MIN 0x00 #define OV9282_REG_MAX 0xfffff +#define OV9282_STROBE_SPAN_FACTOR 192 + static const char * const ov9282_supply_names[] = { "avdd", /* Analog power */ "dovdd", /* Digital I/O power */ @@ -691,7 +693,7 @@ static int ov9282_set_ctrl_flash_hw_strobe_signal(struct ov9282 *ov9282, bool en current_val); } -static int ov9282_set_ctrl_flash_duration(struct ov9282 *ov9282, u32 value) +static u32 ov9282_us_to_flash_duration(struct ov9282 *ov9282, u32 value) { /* * Calculate "strobe_frame_span" increments from a given value (µs). @@ -702,7 +704,27 @@ static int ov9282_set_ctrl_flash_duration(struct ov9282 *ov9282, u32 value) * The formula below is interpolated from different modes/framerates * and should work quite well for most settings. */ - u32 val = value * 192 / (ov9282->cur_mode->width + ov9282->hblank_ctrl->val); + u32 frame_width = ov9282->cur_mode->width + ov9282->hblank_ctrl->val; + + return value * OV9282_STROBE_SPAN_FACTOR / frame_width; +} + +static u32 ov9282_flash_duration_to_us(struct ov9282 *ov9282, u32 value) +{ + /* + * As the calculation in ov9282_us_to_flash_duration uses an integer + * divison calculate in ns here to get more precision. Then check if + * we need to compensate that divison by incrementing the µs result. + */ + u32 frame_width = ov9282->cur_mode->width + ov9282->hblank_ctrl->val; + u64 ns = value * 1000 * frame_width / OV9282_STROBE_SPAN_FACTOR; + + return DIV_ROUND_UP(ns, 1000); +} + +static int ov9282_set_ctrl_flash_duration(struct ov9282 *ov9282, u32 value) +{ + u32 val = ov9282_us_to_flash_duration(ov9282, value); ov9282_write_reg(ov9282, OV9282_REG_FLASH_DURATION, 1, (val >> 24) & 0xff); ov9282_write_reg(ov9282, OV9282_REG_FLASH_DURATION + 1, 1, (val >> 16) & 0xff); @@ -792,9 +814,37 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) return ret; } +static int ov9282_try_ctrl(struct v4l2_ctrl *ctrl) +{ + struct ov9282 *ov9282 = + container_of(ctrl->handler, struct ov9282, ctrl_handler); + + if (ctrl->id == V4L2_CID_FLASH_DURATION) { + u32 fd = ov9282_us_to_flash_duration(ov9282, ctrl->val); + u32 us = ctrl->val; + + /* get nearest strobe_duration value */ + u32 us0 = ov9282_flash_duration_to_us(ov9282, fd); + u32 us1 = ov9282_flash_duration_to_us(ov9282, (fd + 1)); + + if (abs(us1 - us) < abs(us - us0)) + ctrl->val = us1; + else + ctrl->val = us0; + + if (us != ctrl->val) { + dev_dbg(ov9282->dev, "using next valid strobe_duration %u instead of %u\n", + ctrl->val, us); + } + } + + return 0; +} + /* V4l2 subdevice control ops*/ static const struct v4l2_ctrl_ops ov9282_ctrl_ops = { .s_ctrl = ov9282_set_ctrl, + .try_ctrl = ov9282_try_ctrl, }; /** From patchwork Wed Jul 16 09:07:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 115843 X-Patchwork-Delegate: sakari.ailus@iki.fi Received: from am.mirrors.kernel.org ([147.75.80.249]) by linuxtv.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uby7V-00071F-3C for patchwork@linuxtv.org; Wed, 16 Jul 2025 09:08:14 +0000 Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4CBC51A60CFF for ; Wed, 16 Jul 2025 09:08:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BE8E2F237A; Wed, 16 Jul 2025 09:07:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="FnlcVqaj" X-Original-To: linux-media@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57B812F0C40; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; cv=none; b=nmphx3vGV7gAyFuvTw2kEKIjj6ayxtnbTMai64LwTCHQHCgEDoeSs8fX4K4cfHj+jlMAPMDcPzqug9C9kW4v2khQHJ9CCYg3OFrzL4oLmJH4OVaVnZmQyhdfRWDdD8WfsQiAaQlQqu+6K7iUMRc5Is0bJsXNtt0RlreBH4Ti40w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752656849; c=relaxed/simple; bh=I5haGetjk5CR5fMUuZoz3rwX2PVyWVsn8Vb9i7Affcg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bgXXL6By1bVZHudevf8uedPBzU7peLicJX2Kq31RA1AlFv6Nrs27iHKjKl0jtgsXoawI9heO6TojIwd2y49gVHAVt+hgD3qWV8V0E0O+FpwDUq8/7Vb1SdJ0hJ1dpgUU5ZbmlU0zvg4rshcDeOPU1CYXB44zyHQ7GCu+1NDErTw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=FnlcVqaj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 1B0F6C4CEF9; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1752656849; bh=I5haGetjk5CR5fMUuZoz3rwX2PVyWVsn8Vb9i7Affcg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=FnlcVqajhbuAD3G6jgcUACAEXfKn4/lUKua0aAPT4nQrPcaqRe1488aQByWg91sKq SNZDMwRVR4zitQNWIpvfjhJBbVggObd2A7gPASoG+WBiQ7OlfiS3RXx5yc202g6P8Z rRQhFQhVuQ+e0O63c+clEMLdfHahpWV6UV8+yft4= Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 153D2C83F22; Wed, 16 Jul 2025 09:07:29 +0000 (UTC) From: Richard Leitner Date: Wed, 16 Jul 2025 11:07:01 +0200 Subject: [PATCH v6 11/11] media: i2c: ov9282: dynamic flash_duration maximum Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250716-ov9282-flash-strobe-v6-11-934f12aeff33@linux.dev> References: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> In-Reply-To: <20250716-ov9282-flash-strobe-v6-0-934f12aeff33@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: Hans Verkuil , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1752656846; l=3617; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=I5haGetjk5CR5fMUuZoz3rwX2PVyWVsn8Vb9i7Affcg=; b=VB1tzvKw7r+KAkKWuxzY3h7EKOJfEH0R4/CayW98olpyAwCNKSdi8lRLtPjbL1FnDnYtAmLN5 Y4gOIfsP120CCzm+SHFgBvZ7SgQLQiywUYomdPDt7oPY4iQyooczujA X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 X-LSpam-Score: -8.6 (--------) X-LSpam-Report: No, score=-8.6 required=5.0 tests=ARC_SIGNED=0.001,ARC_VALID=-0.1,BAYES_00=-1.9,DKIM_SIGNED=0.1,DKIM_VALID=-0.1,DKIM_VALID_AU=-0.1,DMARC_PASS=-0.001,HEADER_FROM_DIFFERENT_DOMAINS=0.5,MAILING_LIST_MULTI=-1,RCVD_IN_DNSWL_MED=-2.3,RCVD_IN_VALIDITY_CERTIFIED=-3,RCVD_IN_VALIDITY_RPBL=1.31,RCVD_IN_VALIDITY_SAFE=-2,SPF_HELO_NONE=0.001,SPF_PASS=-0.001 autolearn=ham autolearn_force=no This patch sets the current exposure time as maximum for the flash_duration control. As Flash/Strobes which are longer than the exposure time have no effect. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index b104ae77f00e9e7777342e48b7bf3caa6d297f69..3253d9f271cb3caef6d85837ebec4f5beb466a4d 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -198,6 +198,7 @@ struct ov9282_mode { * @exp_ctrl: Pointer to exposure control * @again_ctrl: Pointer to analog gain control * @pixel_rate: Pointer to pixel rate control + * @flash_duration: Pointer to flash duration control * @vblank: Vertical blanking in lines * @noncontinuous_clock: Selection of CSI2 noncontinuous clock mode * @cur_mode: Pointer to current selected sensor mode @@ -220,6 +221,7 @@ struct ov9282 { struct v4l2_ctrl *again_ctrl; }; struct v4l2_ctrl *pixel_rate; + struct v4l2_ctrl *flash_duration; u32 vblank; bool noncontinuous_clock; const struct ov9282_mode *cur_mode; @@ -611,6 +613,15 @@ static int ov9282_update_controls(struct ov9282 *ov9282, mode->vblank_max, 1, mode->vblank); } +static u32 ov9282_exposure_to_us(struct ov9282 *ov9282, u32 exposure) +{ + /* calculate exposure time in µs */ + u32 frame_width = ov9282->cur_mode->width + ov9282->hblank_ctrl->val; + u32 trow_us = (frame_width * 1000000UL) / ov9282->pixel_rate->val; + + return exposure * trow_us; +} + /** * ov9282_update_exp_gain() - Set updated exposure and gain * @ov9282: pointer to ov9282 device @@ -622,9 +633,10 @@ static int ov9282_update_controls(struct ov9282 *ov9282, static int ov9282_update_exp_gain(struct ov9282 *ov9282, u32 exposure, u32 gain) { int ret; + u32 exposure_us = ov9282_exposure_to_us(ov9282, exposure); - dev_dbg(ov9282->dev, "Set exp %u, analog gain %u", - exposure, gain); + dev_dbg(ov9282->dev, "Set exp %u (~%u us), analog gain %u", + exposure, exposure_us, gain); ret = ov9282_write_reg(ov9282, OV9282_REG_HOLD, 1, 1); if (ret) @@ -635,6 +647,12 @@ static int ov9282_update_exp_gain(struct ov9282 *ov9282, u32 exposure, u32 gain) goto error_release_group_hold; ret = ov9282_write_reg(ov9282, OV9282_REG_AGAIN, 1, gain); + if (ret) + goto error_release_group_hold; + + ret = __v4l2_ctrl_modify_range(ov9282->flash_duration, + 0, exposure_us, 1, + OV9282_FLASH_DURATION_DEFAULT); error_release_group_hold: ov9282_write_reg(ov9282, OV9282_REG_HOLD, 1, 0); @@ -1420,6 +1438,7 @@ static int ov9282_init_controls(struct ov9282 *ov9282) struct v4l2_fwnode_device_properties props; struct v4l2_ctrl *ctrl; u32 hblank_min; + u32 exposure_us; u32 lpfr; int ret; @@ -1491,8 +1510,11 @@ static int ov9282_init_controls(struct ov9282 *ov9282) /* Flash/Strobe controls */ v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_HW_STROBE_SIGNAL, 0, 1, 1, 0); - v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_DURATION, - 0, 13900, 1, 8); + exposure_us = ov9282_exposure_to_us(ov9282, OV9282_EXPOSURE_DEFAULT); + ov9282->flash_duration = v4l2_ctrl_new_std(ctrl_hdlr, + &ov9282_ctrl_ops, V4L2_CID_FLASH_DURATION, + 0, exposure_us, + 1, OV9282_FLASH_DURATION_DEFAULT); ctrl = v4l2_ctrl_new_std_menu(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_STROBE_SOURCE,