From nobody Tue Dec 2 01:51:43 2025 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 3ACF236C598; Thu, 20 Nov 2025 17:04:30 +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=1763658270; cv=none; b=W2LbgLOI0+wyk+L7LGkyQCxBlpc9MPJ5NY3JXIyUaD5VE9FXkANwTD4YnQGdTiq2yx/sgaod40f/PGl0DfKTqwVCoJNYEQtpFr9NPXVF0pj7dgyi94MhJLEgtCzLBuLB3YmtARxbPbr8/nDbztWrs2rRvGfXWOsdak7ZkIkkNTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763658270; c=relaxed/simple; bh=HEPG8i7Tu7I33PPWqSL35rVstPZw+8wnVPXzsGuFHqQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jinNNy+yWLtBlhgcAh/iY05xQrZI+H2urYyr9qZo68Iq0aD/C1TnbqNx2rwLzN4l4RVwZCgalHM7gRvSvsrARXrYzZUzVK3fY+5xIJqxF4pIJABC8Jga7/ErLYZRs8XKey69O6ln1LkMaoRClltd5QIkfN/60dNhkqqG1mE6svM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=DmbZOjnF; 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="DmbZOjnF" Received: by smtp.kernel.org (Postfix) with ESMTPS id DB88CC116D0; Thu, 20 Nov 2025 17:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1763658269; bh=HEPG8i7Tu7I33PPWqSL35rVstPZw+8wnVPXzsGuFHqQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=DmbZOjnFJ2fDfXnabx2NZ3yVS8zCdY1/v2RhFCUyLf2sVPk+Wrf+nCO5mSP5Lx2kY 3uOLqmeSHuEfLcARtvk4ZCWERTH108dpi0SkEuHrn4VZPcNV6kArA59HdYxwPV/fWP hGK7WCgcXkMRyq/Hv3qglJxhIc7ij7T041qDTQwk= 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 CB39FCF9C6B; Thu, 20 Nov 2025 17:04:29 +0000 (UTC) From: Richard Leitner Date: Thu, 20 Nov 2025 18:04:21 +0100 Subject: [PATCH v9 1/8] media: v4l: ctrls: add a control for flash/strobe duration Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251120-ov9282-flash-strobe-v9-1-6c9e3a4301d7@linux.dev> References: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> In-Reply-To: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner , Hans Verkuil X-Mailer: b4 0.15-dev-a3fc8 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763658268; l=1816; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=HEPG8i7Tu7I33PPWqSL35rVstPZw+8wnVPXzsGuFHqQ=; b=vXyGWnjzJkMlgTI3oqAKHnjRXvlVzfTEJT9UrS31rdViQSzfhnfI64gPpfKZeKniqhDBfbHrk Dhkh3VxxH45AMtPqFEIpTAxhFmWLxzuiJqU9WRmLxjV9KvnNPJbItHL 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 V4L2_CID_FLASH_DURATION control to set the duration of a flash/strobe pulse. This controls the length of the flash/strobe pulse output by device (typically a camera sensor) and connected to the flash controller. This is different to the V4L2_CID_FLASH_TIMEOUT control, which is implemented by the flash controller and defines a limit after which the flash is "forcefully" turned off again. Reviewed-by: Laurent Pinchart 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 ad41f65374e2..4848423205ff 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"; =20 /* 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-c= ontrols.h index 2d30107e047e..9830833b48a5 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -1186,6 +1186,7 @@ enum v4l2_flash_strobe_source { =20 #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) =20 =20 /* JPEG-class control IDs */ --=20 2.47.3 From nobody Tue Dec 2 01:51:43 2025 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 4609336C5B6; Thu, 20 Nov 2025 17:04:30 +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=1763658270; cv=none; b=nDctknwSQM/A5IBPtaOymxlhsJHPCV+yFe2xN5dJsFnlhmENAJJrJ7G+iCEbsFLY7mBbj9ot912BUzH9WK7f2flBM8MitNMzeAa44o+2I/FtewF/a0aVJv8nQT3+dFJpGi/R1e4vl2W5A1FeHpM2yCub4F4zow4NoteUA2hnhX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763658270; c=relaxed/simple; bh=r9LSzB2+m6DYjPhPVqKQHwnITLhhUoOIPWpu3AmSZHE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=F2j8CVBqgpUB8IV2iVfDD5E+UOTtTbickyviKkCj/ppRKmKSkoX191vMgpPQcVx3o1w04sEtDHqnrHqSwCYsjq8IPziAb+4EuPV1uXu+PpPkAStHjXBL8PRe0utNCNofRUv2lplWVq7VgIbpfkYLK1zKWewY3CTyrqpxrdu8WeY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=QQ2AM6NN; 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="QQ2AM6NN" Received: by smtp.kernel.org (Postfix) with ESMTPS id EE6CDC19424; Thu, 20 Nov 2025 17:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1763658270; bh=r9LSzB2+m6DYjPhPVqKQHwnITLhhUoOIPWpu3AmSZHE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QQ2AM6NNRv5ApsCoolMsTkRZCRIh6if5GmZsZnkpBLV858ah3qucocroB3TPf6sh/ m3WUM0vhAnk+MM6WYkqlNtVRPzyLes6VvrBWD6Hl3kM81tdfs5zBFxSidLSYywqNAC BodS3u3o5uSr0YzEkHpawpQ+ErMpYi1ByoC1QWuo= 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 DA27ACF9C6F; Thu, 20 Nov 2025 17:04:29 +0000 (UTC) From: Richard Leitner Date: Thu, 20 Nov 2025 18:04:22 +0100 Subject: [PATCH v9 2/8] media: v4l: ctrls: add a control for enabling strobe output Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251120-ov9282-flash-strobe-v9-2-6c9e3a4301d7@linux.dev> References: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> In-Reply-To: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner , Hans Verkuil X-Mailer: b4 0.15-dev-a3fc8 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763658268; l=1943; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=r9LSzB2+m6DYjPhPVqKQHwnITLhhUoOIPWpu3AmSZHE=; b=vVduCP2GrEj9Xu48yWI19MF94mSvAD595kXmNQ0A7p62vrS9yWjuJzYiweZ4KX2KV64kcfCZ9 CCja6JnQIRjABHStF0AwrxOOrKtOs9ADqZew/Wb4imdsRDODtT5qL/E 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_STROBE_OE 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 4848423205ff..765aeeec84fe 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_STROBE_OE: return "Strobe Output Enable"; =20 /* 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 v= 4l2_ctrl_type *type, case V4L2_CID_FLASH_STROBE_STATUS: case V4L2_CID_FLASH_CHARGE: case V4L2_CID_FLASH_READY: + case V4L2_CID_FLASH_STROBE_OE: 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-c= ontrols.h index 9830833b48a5..32ba3b5fb1dd 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -1187,6 +1187,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_STROBE_OE (V4L2_CID_FLASH_CLASS_BASE + 14) =20 =20 /* JPEG-class control IDs */ --=20 2.47.3 From nobody Tue Dec 2 01:51:43 2025 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 626B636C5B8; Thu, 20 Nov 2025 17:04:30 +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=1763658270; cv=none; b=QcCMxZL6amNMDFhfnvAxrLd2rkGNE8pe0NpgpToTbDOyjHQRjDCX3VuNFV2f4y83IKCOQmYX6NIU1DvlWuFkEqjlJZXNbb3GCMCzKQbP651gPIQGLLiDA3ab65ukB3RaIV0lr2bdnlBzP2FV+OWs90z8SDJso7h6QZN8SBQauDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763658270; c=relaxed/simple; bh=tBekpthiQ63+sVQeAxYqbIcCsnnV2MHwSMvelKk34hk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=jSaHQl/9A8vX00rNiw+VCrTF5MmmQyxoaxYQ2a9Y7Qzm6igEsABst2euQ6TcHxaExDnlF8aU65TvR9FrNXUicsvAwE5pp5eWEKvCsghQWuQpuhz6IzhXbzFm3JT3zXl2TVG1ydGon+vV5QfnDEooAOk1qSZTLb8WyMctsdJy27A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=xDwB1pAz; 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="xDwB1pAz" Received: by smtp.kernel.org (Postfix) with ESMTPS id 015DAC19423; Thu, 20 Nov 2025 17:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1763658270; bh=tBekpthiQ63+sVQeAxYqbIcCsnnV2MHwSMvelKk34hk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=xDwB1pAzVWOp0Iu3B26ifqSwOlL1Tn7cLp/JJTKwapRsuqVC7Ggx/BSwpsHSFMD5S LRfY2j2JUDN31fwmjvw6LUG/PR3vznsg9IUzl3WYT63pnD8GomYVTwlPhTbzOxOepE 7ZhGqMehkjqgLsK2NT25FH6bllYRXI0ksLTKRp00= 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 E7D9CCF9C67; Thu, 20 Nov 2025 17:04:29 +0000 (UTC) From: Richard Leitner Date: Thu, 20 Nov 2025 18:04:23 +0100 Subject: [PATCH v9 3/8] Documentation: uAPI: media: add V4L2_CID_FLASH_{DURATION,STROBE_OE} Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251120-ov9282-flash-strobe-v9-3-6c9e3a4301d7@linux.dev> References: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> In-Reply-To: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner , Hans Verkuil X-Mailer: b4 0.15-dev-a3fc8 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763658268; l=3443; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=tBekpthiQ63+sVQeAxYqbIcCsnnV2MHwSMvelKk34hk=; b=PrF3n1h9n7HI1En9GXwytLNh/GG8DiYMLV9mlLVe8MGCr3t0l5rPgsFe6WiYT1je1/pATjoQo rMADjuvZ4L+AiKM9fcNjuIUr+xssPToHDu7ZY04ydl7RyqDiphXC88J 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 the new strobe duration and hardware strobe output enable to v4l uAPI documentation. Additionally add labels for cross-referencing v4l controls. Signed-off-by: Richard Leitner --- .../userspace-api/media/v4l/ext-ctrls-flash.rst | 42 ++++++++++++++++++= ++++ 1 file changed, 42 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst b/Do= cumentation/userspace-api/media/v4l/ext-ctrls-flash.rst index d22c5efb806a..7cf0d33e79ff 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst @@ -57,6 +57,8 @@ Flash Control IDs ``V4L2_CID_FLASH_CLASS (class)`` The FLASH class descriptor. =20 +.. _v4l2-cid-flash-led-mode: + ``V4L2_CID_FLASH_LED_MODE (menu)`` Defines the mode of the flash LED, the high-power white LED attached to the flash controller. Setting this control may not be possible in @@ -80,6 +82,8 @@ Flash Control IDs =20 =20 =20 +.. _v4l2-cid-flash-strobe-source: + ``V4L2_CID_FLASH_STROBE_SOURCE (menu)`` Defines the source of the flash LED strobe. =20 @@ -96,6 +100,12 @@ Flash Control IDs - The flash strobe is triggered by an external source. Typically this is a sensor, which makes it possible to synchronise the flash strobe start to exposure start. + This method of controlling flash LED strobe has two additional + prerequisites: the strobe source's :ref:`strobe output + ` must be enabled (if available) + and the flash controller's :ref:`flash LED mode + ` must be set to + ``V4L2_FLASH_LED_MODE_FLASH``. =20 =20 =20 @@ -186,3 +196,35 @@ 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: + +``V4L2_CID_FLASH_DURATION (integer)`` + Duration of the flash strobe pulse generated by the strobe source, when + using external strobe. This control shall be implemented by the device + generating the hardware flash strobe signal, typically a camera sensor, + connected to a flash controller. + + The flash controllers :ref:`strobe source ` + must be configured to ``V4L2_FLASH_STROBE_SOURCE_EXTERNAL`` for this + mode of operation. For more details please also take a look at the + documentation there. + + The unit should be microseconds (=C2=B5s) if possible. + +.. _v4l2-cid-flash-strobe-oe: + +``V4L2_CID_FLASH_STROBE_OE (boolean)`` + Enables the output of a hardware strobe signal from the strobe source, + when using external strobe. This control shall be implemented by the d= evice + generating the hardware flash strobe signal, typically a camera sensor, + connected to a flash controller. + + Provided the signal generating device driver supports it, the length o= f the + strobe signal can be configured by adjusting its + :ref:`flash duration `. + + The flash controllers :ref:`strobe source ` + must be configured to ``V4L2_FLASH_STROBE_SOURCE_EXTERNAL`` for this + mode of operation. For more details please also take a look at the + documentation there. --=20 2.47.3 From nobody Tue Dec 2 01:51:43 2025 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 6262133C19E; Thu, 20 Nov 2025 17:04:30 +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=1763658270; cv=none; b=QkOh0KxqE7BlhlA68ltObXK1Fy3rvOOSV225jKKFkKtl55nLIqgMQIhq2smD5mGbqxVFpGdROElvwHFa4cUHzY499gm4kRKuCvJES1IrAvIZg35Srlq2VyTZeWmF3BGzOdPfvFmdymyWRzMNcPl1gFY4lZXDOOcjvQKjoRbl7wE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763658270; c=relaxed/simple; bh=9v4+dv39d0N137tk5o+zSa4BYkpVhhMeNIOdncb3etE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PH5jLWQP6NajJTqDM/mG93fxr2o0TaWpsnExTB7ISoyZY/1B2IK4o/hM9qbzzMTe2aKG2GyvoUR4f4Lt3PHv1goNeL33qFifilX1gJtdlwA/Vspo9LiMYaaQpGobnNKYr/a5Lqa8QntvhHgBhr7F9dKe8bzdNtaJKPcvZ+LJYPk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ed6Gyp41; 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="ed6Gyp41" Received: by smtp.kernel.org (Postfix) with ESMTPS id 0B1B0C2BC9E; Thu, 20 Nov 2025 17:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1763658270; bh=9v4+dv39d0N137tk5o+zSa4BYkpVhhMeNIOdncb3etE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ed6Gyp417FLaCPPmBx79vdgxyHpHeyNhHUOAqwHPzo3O8BQCQNBNvoW/9dyGcW/vK 9yfTUv9Ywt7aAa65OI8uRtYcSvzYI50qlXB5FYzgzC26POR16HTbeCOuPeq/+3j3HX M85jw/+0H2bDYzvm4WU32j3agWYd5JqDvggx3wBY= 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 02DEDCF9C72; Thu, 20 Nov 2025 17:04:30 +0000 (UTC) From: Richard Leitner Date: Thu, 20 Nov 2025 18:04:24 +0100 Subject: [PATCH v9 4/8] media: i2c: ov9282: add output enable register definitions Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251120-ov9282-flash-strobe-v9-4-6c9e3a4301d7@linux.dev> References: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> In-Reply-To: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner , Hans Verkuil X-Mailer: b4 0.15-dev-a3fc8 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763658268; l=2135; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=9v4+dv39d0N137tk5o+zSa4BYkpVhhMeNIOdncb3etE=; b=XH2DmoHBE34RUeqgE96SJEBnOASiqIqOxI2l0gGAwf1WzYvTiyDVuXY/lNXYZt1l8WvXddzDn /ubgcgQeHVMDASWTEIi2YpMniNHWC3P5oBnIk+4Hhj+DotJM14FVhnl 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 a9f6176e9729..e67cff6c30ff 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 =20 +/* 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[] =3D { {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}, --=20 2.47.3 From nobody Tue Dec 2 01:51:43 2025 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 9683836CE14; Thu, 20 Nov 2025 17:04:30 +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=1763658270; cv=none; b=MmS8NWrIVCNvLQjLwUzSqK2vR/hGgCUYYDDMPiBXC/uT4SXm2v8QltTKIVUFIYeMf6ziGKkrLEI+m3ti7hjlJn/m48j4NY5VnYFAZzdrknNxIec+cEQIngZP7AuEMong1p7xS6yLyoi1KwIYJxVkDV3kclLSZJmkd7IytgIEneQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763658270; c=relaxed/simple; bh=nTMOUodaz/NXhF4L146vsKpXqIbsHlK/9A+E95H6+W8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RroAHK46Q6wkmN5n51n7kE56OLN+5tIeu02N2aRQS+pkkogxQBr8ZMgLl9YC6QxU5HGY89W/xpZG9Ti9HmYLihOjI3J42hR/j3bPrLDQR3pJ9TEj8aP9Z+I3BQQoI3nm5raZMd5T0hMAuRF/rEKUK9DYk4hVnHT3WBYSOclVQjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=UPeZXQ/I; 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="UPeZXQ/I" Received: by smtp.kernel.org (Postfix) with ESMTPS id 18DEFC2BCB1; Thu, 20 Nov 2025 17:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1763658270; bh=nTMOUodaz/NXhF4L146vsKpXqIbsHlK/9A+E95H6+W8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UPeZXQ/Ie7dawUwYl2DbX4e8OXa4Qc3hg8G6IUUSKb1JmERE3YqQx/2xS5hi3zUaO rzF2szYu98U912HcBkz2D4ZNco2+IKhBOXGLN7P3lnJ0JRjf2yVhL2YFxPe3aSMnEV OrriGGh7ZIh9AeoQqjPVjTxaYXkDO1SU72cQ2PW8= 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 11496CF9C71; Thu, 20 Nov 2025 17:04:30 +0000 (UTC) From: Richard Leitner Date: Thu, 20 Nov 2025 18:04:25 +0100 Subject: [PATCH v9 5/8] media: i2c: ov9282: add strobe output enable v4l2 control Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251120-ov9282-flash-strobe-v9-5-6c9e3a4301d7@linux.dev> References: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> In-Reply-To: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner , Hans Verkuil X-Mailer: b4 0.15-dev-a3fc8 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763658268; l=2315; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=nTMOUodaz/NXhF4L146vsKpXqIbsHlK/9A+E95H6+W8=; b=2b0xkeVfzf3ElTahX4TWTx/S2S5AgXb0c+L82SUCB76PxTy44j6SCPYHnWAsmIQnuLIVI3CEx tTLZzgKL5/MCwU/m9s8U8bCn22anRVUZmGcVpH5V02x+MXpE6jbSN99 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 V4L2_CID_FLASH_STROBE_OE 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 | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index e67cff6c30ff..6afce803a049 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); } =20 +static int ov9282_set_ctrl_flash_strobe_oe(struct ov9282 *ov9282, bool ena= ble) +{ + u32 current_val; + int ret; + + ret =3D ov9282_read_reg(ov9282, OV9282_REG_OUTPUT_ENABLE6, 1, ¤t_va= l); + if (ret) + return ret; + + if (enable) + current_val |=3D OV9282_OUTPUT_ENABLE6_STROBE; + else + current_val &=3D ~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 =3D ov9282_write_reg(ov9282, OV9282_REG_TIMING_HTS, 2, (ctrl->val + ov9282->cur_mode->width) >> 1); break; + case V4L2_CID_FLASH_STROBE_OE: + ret =3D ov9282_set_ctrl_flash_strobe_oe(ov9282, ctrl->val); + break; default: dev_err(ov9282->dev, "Invalid control %d", ctrl->id); ret =3D -EINVAL; @@ -1325,7 +1345,7 @@ static int ov9282_init_controls(struct ov9282 *ov9282) u32 lpfr; int ret; =20 - ret =3D v4l2_ctrl_handler_init(ctrl_hdlr, 10); + ret =3D v4l2_ctrl_handler_init(ctrl_hdlr, 11); if (ret) return ret; =20 @@ -1390,6 +1410,10 @@ static int ov9282_init_controls(struct ov9282 *ov928= 2) OV9282_TIMING_HTS_MAX - mode->width, 1, hblank_min); =20 + /* Flash/Strobe controls */ + v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, + V4L2_CID_FLASH_STROBE_OE, 0, 1, 1, 0); + ret =3D v4l2_fwnode_device_parse(ov9282->dev, &props); if (!ret) { /* Failure sets ctrl_hdlr->error, which we check afterwards anyway */ --=20 2.47.3 From nobody Tue Dec 2 01:51:43 2025 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 9692E36CE15; Thu, 20 Nov 2025 17:04:30 +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=1763658270; cv=none; b=gZaBtzmHyjAKfsKwDutGKMyGOL+iISHBT30hZMb9FFsk1lE4OGtSxYnXWnupzMVtEso0OsTFibTsde6Y3tQxdR2Pzce3mgUughKRhOhuUKEVeL0sk255lYybhTVmZdj2mMI/8LgOGMX+fqVVJNDxaXg9XpCZ/VlhG0Se/jDp89M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763658270; c=relaxed/simple; bh=WdjWzcmOaYcxgKjt3rSXqMILwpTVd4F8Ojpz58xzqvY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W0PUmY03d0+9uyuD7lOy6NDnVYhBra6Pkjp3MiKz1VEF4E1W3ZakL4Eor7QCBmcBEsTZvgycbcLpOleXkXwW6vXWHQ695BvDnqxY6KkekZ8pEyYZnJTX0Rs9auuYLzySoU/t9Z4kReRTi23kTuZnMwFvu/2/Z1PMc+4XGnfN2GQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=Opi25cHh; 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="Opi25cHh" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2AA4BC2BC87; Thu, 20 Nov 2025 17:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1763658270; bh=WdjWzcmOaYcxgKjt3rSXqMILwpTVd4F8Ojpz58xzqvY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Opi25cHhU79MFNH8epaxsRcN626Wl6SJ9RqCbkbK4mD8zwJK4gyFHUOVoh/EGgeef OTHjy651ObpBX8gcGGI51FVu0iHSd+PEjfnSsEhpmKypFiJ6AAMWSFV9V25qDZ3lBe wtw1BfZADpSWt496Jifwy2h37AE07+n/cjeTcjPM= 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 2032DCF9C73; Thu, 20 Nov 2025 17:04:30 +0000 (UTC) From: Richard Leitner Date: Thu, 20 Nov 2025 18:04:26 +0100 Subject: [PATCH v9 6/8] media: i2c: ov9282: add strobe_duration v4l2 control Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251120-ov9282-flash-strobe-v9-6-6c9e3a4301d7@linux.dev> References: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> In-Reply-To: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner , Hans Verkuil X-Mailer: b4 0.15-dev-a3fc8 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763658268; l=3587; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=WdjWzcmOaYcxgKjt3rSXqMILwpTVd4F8Ojpz58xzqvY=; b=fJ7DsoCKK4+iWnkhg7xR5umGFPSdfeqlAh9xrCBtfRzw0pXlyX2YBlOpPI21Wx340MlDo8y1I EKBKJlMdYikDttE10++J5GXXmRf4aZHRzuNO2qTGl3dkVvWAJQoe2ek 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 V4L2_CID_FLASH_DURATION support using the "strobe_frame_span" feature of the sensor. This is implemented by transforming the given =C2=B5s 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 | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 6afce803a049..26296dc1d1b9 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) =20 +/* Flash/Strobe control registers */ +#define OV9282_REG_STROBE_FRAME_SPAN 0x3925 +#define OV9282_STROBE_FRAME_SPAN_DEFAULT 0x0000001a + /* Input clock rate */ #define OV9282_INCLK_RATE 24000000 =20 @@ -687,6 +691,31 @@ static int ov9282_set_ctrl_flash_strobe_oe(struct ov92= 82 *ov9282, bool enable) return ov9282_write_reg(ov9282, OV9282_REG_OUTPUT_ENABLE6, 1, current_val= ); } =20 +static int ov9282_set_ctrl_flash_duration(struct ov9282 *ov9282, u32 value) +{ + int ret; + /* + * Calculate "strobe_frame_span" increments from a given value (=C2=B5s). + * 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 =3D value * 192 / (ov9282->cur_mode->width + ov9282->hblank_ctrl-= >val); + + ret =3D ov9282_write_reg(ov9282, OV9282_REG_STROBE_FRAME_SPAN, 1, + (val >> 24) & 0xff); + ret |=3D ov9282_write_reg(ov9282, OV9282_REG_STROBE_FRAME_SPAN + 1, 1, + (val >> 16) & 0xff); + ret |=3D ov9282_write_reg(ov9282, OV9282_REG_STROBE_FRAME_SPAN + 2, 1, + (val >> 8) & 0xff); + ret |=3D ov9282_write_reg(ov9282, OV9282_REG_STROBE_FRAME_SPAN + 3, 1, + val & 0xff); + return ret; +} + /** * ov9282_set_ctrl() - Set subdevice control * @ctrl: pointer to v4l2_ctrl structure @@ -756,6 +785,9 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_FLASH_STROBE_OE: ret =3D ov9282_set_ctrl_flash_strobe_oe(ov9282, ctrl->val); break; + case V4L2_CID_FLASH_DURATION: + ret =3D ov9282_set_ctrl_flash_duration(ov9282, ctrl->val); + break; default: dev_err(ov9282->dev, "Invalid control %d", ctrl->id); ret =3D -EINVAL; @@ -1345,7 +1377,7 @@ static int ov9282_init_controls(struct ov9282 *ov9282) u32 lpfr; int ret; =20 - ret =3D v4l2_ctrl_handler_init(ctrl_hdlr, 11); + ret =3D v4l2_ctrl_handler_init(ctrl_hdlr, 12); if (ret) return ret; =20 @@ -1414,6 +1446,9 @@ static int ov9282_init_controls(struct ov9282 *ov9282) v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_STROBE_OE, 0, 1, 1, 0); =20 + v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_DURATION, + 0, 13900, 1, 8); + ret =3D v4l2_fwnode_device_parse(ov9282->dev, &props); if (!ret) { /* Failure sets ctrl_hdlr->error, which we check afterwards anyway */ --=20 2.47.3 From nobody Tue Dec 2 01:51:43 2025 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 9678936CE10; Thu, 20 Nov 2025 17:04:30 +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=1763658270; cv=none; b=R5xQFahbg1egJH1EyBLEYdqURDlDRlnmc0RbXlUI+or2KRzIDZYc27/4aMd0GQEZ15R8R8GtOpZgKI16P2YToaPv7RkBlZKTSF5L5jO4PgttXkrFYAPXu0bnuP8rB5aFkEUMnS4HJOJLyYTYC4xUkQRvlJWl0BZg3OXbrq9G61w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763658270; c=relaxed/simple; bh=/QE3iIievH2JfYAOnD9AGXz516t94bu88M9zf7e76u8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HDerR9PqsDUnh8H0+ZHzQT30wSk9kb7a/IWrSHSm1lkiTf8WfkSDlhiTBpHYoSwARJk5K2MGAoSQubpai3E6+TDv945pvY1RO+p55ZiFdhduOe/DsSRnE6B5MFgOEuKJzKdvJV5dKATrwd3/WNOQa7NItbf2FnFyB9uzoyTXKUA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=h+f48USO; 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="h+f48USO" Received: by smtp.kernel.org (Postfix) with ESMTPS id 3709BC19421; Thu, 20 Nov 2025 17:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1763658270; bh=/QE3iIievH2JfYAOnD9AGXz516t94bu88M9zf7e76u8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=h+f48USONloultW8TGoY0RJFm6wwMXKTPK2+L4myvHc5iSG0L4vznWkLYGJ2ojYZi qg1498yi73X3Im0FXlpxpUJQGLggLTIepF00nZ6t8kEA+bsno0haR7QuLlVRL5+0Lc UF2uDV8kJ/wMpaDIGnNcjdHE+LxMUQK5lEqRnSPg= 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 2DC47CF9C6F; Thu, 20 Nov 2025 17:04:30 +0000 (UTC) From: Richard Leitner Date: Thu, 20 Nov 2025 18:04:27 +0100 Subject: [PATCH v9 7/8] media: i2c: ov9282: implement try_ctrl for strobe_duration Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251120-ov9282-flash-strobe-v9-7-6c9e3a4301d7@linux.dev> References: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> In-Reply-To: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner , Hans Verkuil X-Mailer: b4 0.15-dev-a3fc8 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763658268; l=3724; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=/QE3iIievH2JfYAOnD9AGXz516t94bu88M9zf7e76u8=; b=IenrCX+qe6VwATgYXmlAB2f+uwXpAmN7+tpKaZeFDEFs4FT1PqjK8LTmMJUUnyZ+gtsU+VKaY +iIy981Qxu8CrtK6lYtzDUidEzugT3/DZKprz6cKv+GfHJwD86yD1IN 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 =C2=B5s strobe duration for the given value and returns it back to the caller. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 55 ++++++++++++++++++++++++++++++++++++++++++= +--- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 26296dc1d1b9..823fde579e07 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -128,6 +129,8 @@ #define OV9282_REG_MIN 0x00 #define OV9282_REG_MAX 0xfffff =20 +#define OV9282_STROBE_SPAN_FACTOR 192 + static const char * const ov9282_supply_names[] =3D { "avdd", /* Analog power */ "dovdd", /* Digital I/O power */ @@ -691,9 +694,8 @@ static int ov9282_set_ctrl_flash_strobe_oe(struct ov928= 2 *ov9282, bool enable) return ov9282_write_reg(ov9282, OV9282_REG_OUTPUT_ENABLE6, 1, current_val= ); } =20 -static int ov9282_set_ctrl_flash_duration(struct ov9282 *ov9282, u32 value) +static u32 ov9282_us_to_flash_duration(struct ov9282 *ov9282, u32 value) { - int ret; /* * Calculate "strobe_frame_span" increments from a given value (=C2=B5s). * This is quite tricky as "The step width of shift and span is @@ -703,7 +705,27 @@ static int ov9282_set_ctrl_flash_duration(struct ov928= 2 *ov9282, u32 value) * The formula below is interpolated from different modes/framerates * and should work quite well for most settings. */ - u32 val =3D value * 192 / (ov9282->cur_mode->width + ov9282->hblank_ctrl-= >val); + u32 frame_width =3D 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) +{ + /* + * Calculate back to microseconds from "strobe_frame_span" increments. + * As the calculation in ov9282_us_to_flash_duration uses an integer + * divison round up here. + */ + u32 frame_width =3D ov9282->cur_mode->width + ov9282->hblank_ctrl->val; + + return DIV_ROUND_UP(value * frame_width, OV9282_STROBE_SPAN_FACTOR); +} + +static int ov9282_set_ctrl_flash_duration(struct ov9282 *ov9282, u32 value) +{ + int ret; + u32 val =3D ov9282_us_to_flash_duration(ov9282, value); =20 ret =3D ov9282_write_reg(ov9282, OV9282_REG_STROBE_FRAME_SPAN, 1, (val >> 24) & 0xff); @@ -798,9 +820,36 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) return ret; } =20 +static int ov9282_try_ctrl(struct v4l2_ctrl *ctrl) +{ + struct ov9282 *ov9282 =3D + container_of_const(ctrl->handler, struct ov9282, ctrl_handler); + + if (ctrl->id =3D=3D V4L2_CID_FLASH_DURATION) { + u32 us =3D ctrl->val; + u32 fd =3D ov9282_us_to_flash_duration(ov9282, us); + + /* get nearest strobe_duration value */ + u32 us0 =3D ov9282_flash_duration_to_us(ov9282, fd); + u32 us1 =3D ov9282_flash_duration_to_us(ov9282, fd + 1); + + if (abs(us1 - us) < abs(us - us0)) + ctrl->val =3D us1; + else + ctrl->val =3D us0; + + if (us !=3D 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 =3D { .s_ctrl =3D ov9282_set_ctrl, + .try_ctrl =3D ov9282_try_ctrl, }; =20 /** --=20 2.47.3 From nobody Tue Dec 2 01:51:43 2025 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 966A536CE09; Thu, 20 Nov 2025 17:04:30 +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=1763658270; cv=none; b=PEqF7VPoQtQ/D6AP/SGJ95MXNC/REcMpFn+5xhz0sjZaWQMIUK4G0WMKY81J2fyb3QhdfcPppzXo0jZSHf2egg1NvY344VK5vCQBEgbbB0/gvbcUhfia3fUXeIAyztHoQkzGybd8vqXL+vT30yz8nuerzBg+1BDeexPLBVvqM+E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763658270; c=relaxed/simple; bh=cMhXmygdZf3b3AgzDH9NcbI8NnOSqpVAq9jj95gyvyo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PEI6nKT5z+BYcclEZRQ5MkxVpnnFHE6vGO8nWfX6QAu093XDvqzfduCQ1dUKpHtSGGpnTe6m7v+uwyPkVnQFPgsTzpDpEYloHyAuGAvCDGJFl+fRhgMZmolBLEW5yPYMPcBdIhVNOjl9lU/tGzqdsQ8wRh7JJJ7HTa9uW2MGWbI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=utzYGQLe; 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="utzYGQLe" Received: by smtp.kernel.org (Postfix) with ESMTPS id 44188C4AF0B; Thu, 20 Nov 2025 17:04:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1763658270; bh=cMhXmygdZf3b3AgzDH9NcbI8NnOSqpVAq9jj95gyvyo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=utzYGQLeeTgpbxZyUm7zv7MNN29MeJaYaecc/9gOeixWGdpTR90Ba0BbGE/2gVwhI 0Xj1+4L9H7parTn4K15Xop8No5e4mzjTCJhTotdGjncgTKQSIIKibY3sLzqm1zwi1u eb63XyavldhAPSBA8Idjk2HJZqS5FlxnOsrRx6sc= 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 3C07CCF9C72; Thu, 20 Nov 2025 17:04:30 +0000 (UTC) From: Richard Leitner Date: Thu, 20 Nov 2025 18:04:28 +0100 Subject: [PATCH v9 8/8] media: i2c: ov9282: dynamic flash_duration maximum Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251120-ov9282-flash-strobe-v9-8-6c9e3a4301d7@linux.dev> References: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> In-Reply-To: <20251120-ov9282-flash-strobe-v9-0-6c9e3a4301d7@linux.dev> To: Sakari Ailus , Dave Stevenson , Mauro Carvalho Chehab , Lee Jones , Pavel Machek , Laurent Pinchart Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-leds@vger.kernel.org, Richard Leitner , Hans Verkuil X-Mailer: b4 0.15-dev-a3fc8 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763658268; l=3530; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=cMhXmygdZf3b3AgzDH9NcbI8NnOSqpVAq9jj95gyvyo=; b=ASi/PHKnG/Uq4cD9JkIM5gYB9bcvH64WBXzx+H7fM6dd/c0Xrqrcfk16qCQ7bNOTmJq/v5TPL ZKqbcb0WsejDQ5ehs/7qaDCpXNz/FPJqbvwPMo6O93bNrG1hPUTyTLH 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 823fde579e07..33404630cc0c 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -199,6 +199,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 @@ -221,6 +222,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; @@ -612,6 +614,15 @@ static int ov9282_update_controls(struct ov9282 *ov928= 2, mode->vblank_max, 1, mode->vblank); } =20 +static u32 ov9282_exposure_to_us(struct ov9282 *ov9282, u32 exposure) +{ + /* calculate exposure time in =C2=B5s */ + u32 frame_width =3D ov9282->cur_mode->width + ov9282->hblank_ctrl->val; + u32 trow_us =3D frame_width / (ov9282->pixel_rate->val / 1000000UL); + + return exposure * trow_us; +} + /** * ov9282_update_exp_gain() - Set updated exposure and gain * @ov9282: pointer to ov9282 device @@ -623,9 +634,10 @@ static int ov9282_update_controls(struct ov9282 *ov928= 2, static int ov9282_update_exp_gain(struct ov9282 *ov9282, u32 exposure, u32= gain) { int ret; + u32 exposure_us =3D ov9282_exposure_to_us(ov9282, exposure); =20 - 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); =20 ret =3D ov9282_write_reg(ov9282, OV9282_REG_HOLD, 1, 1); if (ret) @@ -636,6 +648,12 @@ static int ov9282_update_exp_gain(struct ov9282 *ov928= 2, u32 exposure, u32 gain) goto error_release_group_hold; =20 ret =3D ov9282_write_reg(ov9282, OV9282_REG_AGAIN, 1, gain); + if (ret) + goto error_release_group_hold; + + ret =3D __v4l2_ctrl_modify_range(ov9282->flash_duration, + 0, exposure_us, 1, + OV9282_STROBE_FRAME_SPAN_DEFAULT); =20 error_release_group_hold: ov9282_write_reg(ov9282, OV9282_REG_HOLD, 1, 0); @@ -1423,6 +1441,7 @@ static int ov9282_init_controls(struct ov9282 *ov9282) const struct ov9282_mode *mode =3D ov9282->cur_mode; struct v4l2_fwnode_device_properties props; u32 hblank_min; + u32 exposure_us; u32 lpfr; int ret; =20 @@ -1495,8 +1514,11 @@ static int ov9282_init_controls(struct ov9282 *ov928= 2) v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_STROBE_OE, 0, 1, 1, 0); =20 - v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_DURATION, - 0, 13900, 1, 8); + exposure_us =3D ov9282_exposure_to_us(ov9282, OV9282_EXPOSURE_DEFAULT); + ov9282->flash_duration =3D v4l2_ctrl_new_std(ctrl_hdlr, + &ov9282_ctrl_ops, V4L2_CID_FLASH_DURATION, + 0, exposure_us, + 1, OV9282_STROBE_FRAME_SPAN_DEFAULT); =20 ret =3D v4l2_fwnode_device_parse(ov9282->dev, &props); if (!ret) { --=20 2.47.3