From patchwork Tue Jun 17 07:31:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 897832 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 365001C7017; Tue, 17 Jun 2025 07:31:42 +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=1750145503; cv=none; b=nabDwQNXcJpvvtTQxKw9ndRSK4SSaCcaOOJ9xUMwdTAypYUk7wSBh7aw51Fcy8BFO5pUz4/GOaE5WqLAxV1gC/1CyGVBHeUjFe8J2rPNjabnmGJuAlK8Dd7F8DCWYeqP7WqfP6W7S59FFmI+07KpYja/03a/Q74lC055k3e/8HM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750145503; c=relaxed/simple; bh=0nzpfTzsTCcWDqac7ZTk2BZgJrXNm8rZpSw6OMimBsU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fi+GWsUCsG5g7dpXq8wuOE6Vd0Y4sdnJYbQOy2oUJwznG3h5kjAtdy9u8MidAKlQH5Ttw4Jx/JXp2QpccYDr74/6S/SYEtr+B3C/KY5nE92h3nfeJg7vM+MNHBxQdlitBV+KbDj6Grl5bRvEGbz8/SFr7ZzMuPymoSI3Tcq0BYs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=VZYe2P2c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="VZYe2P2c" Received: by smtp.kernel.org (Postfix) with ESMTPS id BE962C4CEEE; Tue, 17 Jun 2025 07:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1750145502; bh=0nzpfTzsTCcWDqac7ZTk2BZgJrXNm8rZpSw6OMimBsU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VZYe2P2c9nRVPwi4sQS7LrTIF+Z8CEa62BbeXRIHmLdXkkZM7rtnuTy8x/NKk3yyg 0yQKRsBOEDXdIYoXiNGkeJ66Ip8XHDmdk3jF0/YmXvy5IRLDeLz2jmolhM19W5Lj70 Spx2CU6BRV63DRHt6SMpBKwHNodpvN86eXoWRWGs= 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 A2290C71155; Tue, 17 Jun 2025 07:31:42 +0000 (UTC) From: Richard Leitner Date: Tue, 17 Jun 2025 09:31:35 +0200 Subject: [PATCH v5 01/10] 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: <20250617-ov9282-flash-strobe-v5-1-9762da74d065@linux.dev> References: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@linux.dev> In-Reply-To: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@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=1750145501; l=1793; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=0nzpfTzsTCcWDqac7ZTk2BZgJrXNm8rZpSw6OMimBsU=; b=wpZpWeC5n9BpiJxIykqqP21yGU7SfQez/GtwiE9pwmPFtM8egKR3TrSk80LMBIBck+v27JtVL XY95kdiDh1zBpbKyK28QbruxN13uQhUw2Z2dhtbBtMTeb4HX2bjFYGB 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 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 Tue Jun 17 07:31:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 897833 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 33912136A; Tue, 17 Jun 2025 07:31:42 +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=1750145503; cv=none; b=nZg0rMwE9KWxWsbmbqtR4Lq0yQWMD9eFp1lp+SNZzecCDiPTguNp0rfDcj2UyvRILg6JfyKf+XDzfZPTymSQ91qQa1fXXdN4lj/iIFMvOeih0qhUXgvYhCnAVeXZB27+DxDCauP+T+9gZL6IKLlcx02z7LKIagJXou2rGGvYAzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750145503; c=relaxed/simple; bh=FrCl/fSGFBnOk0+MAcM+KHDO4zcSf1DpGTy1y8P+ack=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lAm7NvX4rFXyKaoLNJJIwUUfxBqeUlCpSKO3nlS245207heUe83GMcM8l2Pp0QSBSxNxwd+uheND5HWQIhDD58pieaq7IAJpNImCcYbF6ccLtosjoyaviwoPRZK9DlhgV/sOSvvKohEwDHrLNL8C/ELg7Lm1xVWJhtbwMbbDgMI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=0c1nJcL6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="0c1nJcL6" Received: by smtp.kernel.org (Postfix) with ESMTPS id C42FCC4AF0B; Tue, 17 Jun 2025 07:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1750145502; bh=FrCl/fSGFBnOk0+MAcM+KHDO4zcSf1DpGTy1y8P+ack=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=0c1nJcL69M6vekzc5cJBP1WmMzNxszsUzMx9ymqObEkRfWBo8L2B2UONgojLRZjN+ IAKXuXX5G7M/jagiHzT74yVwktqiO4GcSt9fAfiR3Amsw7M9aZeAKOTeIUmF+wkoid nW2NubFhcGmzAzytAngNhr96D83TRDpEzNENHQ40= 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 B1E69C71157; Tue, 17 Jun 2025 07:31:42 +0000 (UTC) From: Richard Leitner Date: Tue, 17 Jun 2025 09:31:36 +0200 Subject: [PATCH v5 02/10] 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: <20250617-ov9282-flash-strobe-v5-2-9762da74d065@linux.dev> References: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@linux.dev> In-Reply-To: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@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=1750145501; l=2303; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=FrCl/fSGFBnOk0+MAcM+KHDO4zcSf1DpGTy1y8P+ack=; b=3UFNRqcZuesqNlodPeYt8efWwjzdPgRjCVXwRt/jIpJBrLTp9ghLKj6Wf9kqDIIYXrsUjEqZy Rz92q8lYGiSC1l1yvAJh2SwGAKIGx/nzJJZeSn3Pi/6+Wxkko2LY2Xy 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 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..69b6c2026e0ad905aaebcdabe1e7002fc48f9e2c 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 Tue Jun 17 07:31:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 897831 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 66D631DF269; Tue, 17 Jun 2025 07:31:43 +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=1750145503; cv=none; b=l8/or2e0SSTNq+0bb8X5tzI9nmU/AsZzmZlabnijfvi+JrwscYBwropb7uC/Rx8FNURKooNr3jdp9/qsMZlxbdFYTSzjjvGmltlBWyjNvIYwWQR8c0YE/H2YJc1LCzbSU+EW9HgX42wOB5Y/MzsMF4SGT81L9Wnt2SaM2PURMC8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750145503; c=relaxed/simple; bh=8XoXfLI3glbsttjIv49MTkNU8w73Ts/XjbKrGmMzkd0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VgqQw9wyIQoKpz45eYMxibWGAVt0fV3/OMKVUfDVhsGf/I+zT3IfMfRZY/Hwtq4IPh7sx/+7pikWhlfq7mMwiyKT6rrYZNGC/BBO4vsiqKdUYgnDqnTCXq0DyZ79jzNxzfzd7H1wGvOQpxKVesKAohfYGbhTP0mdRtLNPFxL1eU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=PL9s16Jj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="PL9s16Jj" Received: by smtp.kernel.org (Postfix) with ESMTPS id D1744C4CEF0; Tue, 17 Jun 2025 07:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1750145502; bh=8XoXfLI3glbsttjIv49MTkNU8w73Ts/XjbKrGmMzkd0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PL9s16JjyRvKIYWjase40Bs4Ka11Fm5EgK28szx2xE+e8KLno+2E5XiCx1W60ogRo 4NKwALHMGsq9W0k4iUZAVdlH/dtX2DAQrP/+GiQfpEAZgl5u+Giv0secRCH5FTj5J9 /Mvtl06RKApT1DA0qb5VmkQAwNKT6JMA7FB9gt+s= 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 C28BEC71136; Tue, 17 Jun 2025 07:31:42 +0000 (UTC) From: Richard Leitner Date: Tue, 17 Jun 2025 09:31:37 +0200 Subject: [PATCH v5 03/10] media: v4l2-flash: fix flash_timeout comment Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250617-ov9282-flash-strobe-v5-3-9762da74d065@linux.dev> References: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@linux.dev> In-Reply-To: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@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=1750145501; l=878; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=8XoXfLI3glbsttjIv49MTkNU8w73Ts/XjbKrGmMzkd0=; b=nPouAY8N5zq1XIMQ6rZ1Q6GzebMfWi0D9HB7LZ8Xg6r4imr5Qm6mrjxTs9/UdOwDbDXkp1HJu W2Ze+5AQ3w7Ax3ibt1oJ/EgVjSr7MfgqeyTvsYMveLRaGLiDCNQ1LyF 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 The comment for the flash_timeout setter mentioned it is the "flash duration". Fix this by changing it to "flash timeout". Signed-off-by: Richard Leitner --- include/linux/led-class-flash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h index 21ec856c36bc67decda46aa8ff1c040ffdcf1181..775a96217518936633541c7a5d394502dbf04f83 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -197,7 +197,7 @@ int led_update_flash_brightness(struct led_classdev_flash *fled_cdev); * @fled_cdev: the flash LED to set * @timeout: the flash timeout to set it to * - * Set the flash strobe duration. + * Set the flash strobe timeout. * * Returns: 0 on success or negative error value on failure */ From patchwork Tue Jun 17 07:31:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 897829 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 8A4D828DB52; Tue, 17 Jun 2025 07:31:43 +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=1750145503; cv=none; b=SXLRlgS0wnsgK9cCh54rQTmOZFoCxPTH2nkIBAKhbcVlL73UACHUf5lCmFfVNLC8fOuSO0Nc9ytoHUuF3M5KwARFi4VzR1Ei19AVaPs31iadih7/06uVqj+Hmgt7i6Bn26I7BiYcd3r7+9eRVYCaSI6vuRd7q56gLg+bsrt/S7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750145503; 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=LE2uA8Qfbf5vAX+IurIPSN5GmzQT4/clF/4r7r8XG9HLjhJ5y9QWnndEtdFwoxOml6urwUcphpjGSKy0ZylXn4dZNrXTNo4TvFZNXfvI9APnIQWzvY7gU06q3WkzafF/dpd2fbu/ctZgCe/x3THpS26oyW1E9De+mei2qz2mvyU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=u+C33yKj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="u+C33yKj" Received: by smtp.kernel.org (Postfix) with ESMTPS id EC810C4CEFA; Tue, 17 Jun 2025 07:31:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1750145503; bh=FNa/xvakH+OMufv25Oa47P8olVqt6It8kjPg/VhP/1A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=u+C33yKjXOjHiWhPF2bwaYwZp2z6MwnkTJqtd2RbK5L4K/xKxXO7IJSNvUyeo9gnB ix5wZQkm0clWeWiZN1egHGOT+0ogiHJToOJW25QHABZcju+keO/CW6dNhiuRWBKoXd Pk3GnzZFuolqXz55q3Il8rlAsYeyPTiV6xygXbhY= 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 E3A58C71157; Tue, 17 Jun 2025 07:31:42 +0000 (UTC) From: Richard Leitner Date: Tue, 17 Jun 2025 09:31:39 +0200 Subject: [PATCH v5 05/10] 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: <20250617-ov9282-flash-strobe-v5-5-9762da74d065@linux.dev> References: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@linux.dev> In-Reply-To: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@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=1750145501; l=2191; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=FNa/xvakH+OMufv25Oa47P8olVqt6It8kjPg/VhP/1A=; b=uUHWJ+/yb+PEiHD9pRblZN7qf/jGLbObljhh9njTTbUrU1jtNojkc0ELLkEDGzT8KfWB2yLiO H9L+gNjKJLOBAleI3wzW224Y0zaf/P1/kqeHcew5Bq2WhAS12C8w71g 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 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 Tue Jun 17 07:31:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 897830 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 7253122AE45; Tue, 17 Jun 2025 07:31:43 +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=1750145503; cv=none; b=mjUIAR6MY8nO1vnpMPR5QbiTmHQgOPsT9eMlvJTWBH8o4KJxRV1A/xst8cJlXSypziywkMu7imw7BJ73Rfatg0Chgyzejkg/rAifoQZSSRzsQr8s/GoU5p/xnl9wk/zuf0mr1QNEgB/+8SiTOkhyZlgL60U9rvWkAq7ifjeFpks= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750145503; c=relaxed/simple; bh=N7cxIQN6Xv0wE74O59AbStDajdQPgGvjHQmafDljbdA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=niJDWPs7wZcpQ1nuJhQaDUI1bvInk8UFSqNMTHUeqWAldgPIL8LcFDOeKDc4ZMfStbv+mDxfEXbNkp74Lz6iu4eC1Rh3TYOLkI5vvEvCbx7X1g7Kjby4GL4CjrTGJyEXP/t5DMNKUKWYAoEoTTbZ6AR5pK9QR0qW1iTwLK5t7I4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vmCdZZjj; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vmCdZZjj" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3EAB7C4CEFD; Tue, 17 Jun 2025 07:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1750145503; bh=N7cxIQN6Xv0wE74O59AbStDajdQPgGvjHQmafDljbdA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=vmCdZZjjdAzVlYw533oEp5gac8Ump7xyp7z3f9MKg0ZhOZaavqzGcFwQTj265M47L 43sRFUtjpIf1qVQZGx1mYJf5QKrDxJq2jhcsVR+nROhoE2umufCWOq2y0eZklU1tbv PZXd91H+q9/2oKmxwp/Yijoq3onr6F/O7voT2JTQ= 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 36663C7115D; Tue, 17 Jun 2025 07:31:43 +0000 (UTC) From: Richard Leitner Date: Tue, 17 Jun 2025 09:31:43 +0200 Subject: [PATCH v5 09/10] 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: <20250617-ov9282-flash-strobe-v5-9-9762da74d065@linux.dev> References: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@linux.dev> In-Reply-To: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@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=1750145501; l=3551; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=N7cxIQN6Xv0wE74O59AbStDajdQPgGvjHQmafDljbdA=; b=fdl3inKMgvhpPI2PHcHHcZ8fsLbLgLfEVPSeMsJSf3g4eiVUNuxskBMPTvq2B/NeOcFvLBRj3 hLw+H2YEYrkCHiyK6zg/wYqY7Q9eNfw7rwtdb7yt7vFQ2lcX10EObt7 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 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 2d77b9108bcd2499a40418919e260e7d53a9a64e..1f4bca29cd793e99c473aff9c8b7e200e3d598bc 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_led_mode(struct ov9282 *ov9282, int mode) 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 Tue Jun 17 07:31:44 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Leitner X-Patchwork-Id: 897828 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 72697288C06; Tue, 17 Jun 2025 07:31:43 +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=1750145503; cv=none; b=oBpBfYUo49QxrVkwEWu2x4LGiJGhv2LSEkbdO7sYMLk1K2R4RSbE4EJYgJLkPbhHcuok5eKCHZntLIG+J/K5N0kF1E5TTj97H1p6DlpF5lJ+EzHSEPptL/T/wIwYWB55eLgrndxUbLxmRd/O4kmxalnK7AeV3sR5Ut6tc6agJ0I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750145503; c=relaxed/simple; bh=u0EumBQgKw9tRo8pqtn52kIAYiMwEBU7JZR3hZra7Is=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=lCn1RcX2mpUAWtDVH1hghcXSLi1SQbInjnL/J23QoWF1WlZSotoVnVWfE/q7khFis/SJNlC7JJSkB0SSBSPw0Tx5Q43TbMHzTEKWdVFwekD27rGOy1cViEpm8ADk2gy1bXS1RkM2y1tnNMz8TmVn7Yj5Q5NrJe7mAgqhnLD9RlQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=XCGFuS5h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="XCGFuS5h" Received: by smtp.kernel.org (Postfix) with ESMTPS id 4CB2BC113CF; Tue, 17 Jun 2025 07:31:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1750145503; bh=u0EumBQgKw9tRo8pqtn52kIAYiMwEBU7JZR3hZra7Is=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=XCGFuS5hBYCwlYFw1Y3fgv0PsACKMp9WD4NnXUCS1RsgSXzDBxUA4qC/yXGYronur F2Iv82L2Bx8Kd+0ECt5jGSoCiWd+XuCzYpe/dwWu7Tw6/TMssq1S8JG8S8JMNkSlUZ KmNSh8dEXjBYsSCPwKb354KaZp+t/fiS8kXsFBf8= 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 43077C7115E; Tue, 17 Jun 2025 07:31:43 +0000 (UTC) From: Richard Leitner Date: Tue, 17 Jun 2025 09:31:44 +0200 Subject: [PATCH v5 10/10] 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: <20250617-ov9282-flash-strobe-v5-10-9762da74d065@linux.dev> References: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@linux.dev> In-Reply-To: <20250617-ov9282-flash-strobe-v5-0-9762da74d065@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=1750145501; l=3576; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=u0EumBQgKw9tRo8pqtn52kIAYiMwEBU7JZR3hZra7Is=; b=/smZRi59dZATDPo+9atyjcxBHAC0WosfiTD+9aXjXRMdnnm1P/xAhwInYBkmUB2XwJY2lsD8N TSgOKWvD3ITDu4IYepSKddgDmHRuP6Nb/bDtec4ci3t8gbHUQ1AwmxM 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 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 1f4bca29cd793e99c473aff9c8b7e200e3d598bc..2fd0d63b8071d434c05a98f4d0169c4fb83f7cfe 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 µs), 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; @@ -1495,8 +1514,11 @@ static int ov9282_init_controls(struct ov9282 *ov9282) (1 << V4L2_FLASH_LED_MODE_TORCH), V4L2_FLASH_LED_MODE_NONE); - 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,