From nobody Thu Dec 18 08:37:13 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 E1E7F2236E3; Tue, 9 Dec 2025 22:44:51 +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=1765320292; cv=none; b=ilI1h/PTYi2thZ2TFePRmCG81JlFTSOAFxkBRE62zt9LXZIlYj7lRf70oLj2jsEJZNWmC9UvU8ZcVPoquZTntPEyLfVyzWEpjmlp0FYVAiAhE+wojWZJNtqEA/bA6LUrfxJc47DR63tsD4rKn9YG7mbkve6QEMmtJc6BA+1KS+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765320292; c=relaxed/simple; bh=UANwLOgcj9WwONW3K+0Sy55FYPHJ20LKps0TM9A7gAM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=meHaqvQH5z1qA0+eOpQxTeKCjiH6vtSmXNlKjornqcBK4PBt8N34VuZQBDSpfOvCnQncF7kXZx7GuGgZQziKS0RjE22YwoZMabNH+B/X3QP40cD6Bb1ne8vYpchta7ylma/e6UrDTQTYe7BS/RpOx3LfuPOvacxka2s0waxWd9g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=NGjp4Tvs; 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="NGjp4Tvs" Received: by smtp.kernel.org (Postfix) with ESMTPS id 9FCDEC116B1; Tue, 9 Dec 2025 22:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1765320291; bh=UANwLOgcj9WwONW3K+0Sy55FYPHJ20LKps0TM9A7gAM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=NGjp4TvsbcJEjq1WwMrgwzoSy4StB6d/TtBOiq/bWVaOXJEDUun/uglnLfrLbznC8 /k/Y7bJ6W3tAr5Mep7oV8XSytYHVcF5p/k22Fiv/r30Dabn5Tb39rxVFW6bytKYTs2 5WgznrQsKg//u9qXi12WnPUbVrbBozcOVNMbzKLc= 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 8D8F9D3B9A4; Tue, 9 Dec 2025 22:44:51 +0000 (UTC) From: Richard Leitner Date: Tue, 09 Dec 2025 23:44:36 +0100 Subject: [PATCH v10 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: <20251209-ov9282-flash-strobe-v10-1-0117cab82e2d@linux.dev> References: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@linux.dev> In-Reply-To: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@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=1765320290; l=1820; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=UANwLOgcj9WwONW3K+0Sy55FYPHJ20LKps0TM9A7gAM=; b=90c+MeYUo+cxxo48yiJUmMrs5kCI6EIBoKt4A5H+otNxAzgIZY4S4KVO1Qyk+TB30lJOwFMKu dZ988WtoH1KD+Q6hPxe01+a5Jl/WrDz517Q//GjUHiKQjFvIKDEnDtz 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 ad41f65374e23..4848423205ff7 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 2d30107e047ee..9830833b48a52 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 Thu Dec 18 08:37:13 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 26B052ECE9D; Tue, 9 Dec 2025 22:44:51 +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=1765320292; cv=none; b=QkkcL8s9VkXloJ0Vhs6NBcyWO1Q10OtLGLZeEQeeA4IvvglgdaCQ1F2hOSzlCre5koGJYMV6yQRyGTb8Y8cuyKLGrejKQk0XY3Acj6ZEeEOvyinJzR8Qgn6KlioFZFadSxBcELGZSqkfpPigPpeC8F5go4j95ipMuMo3vdgzJMU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765320292; c=relaxed/simple; bh=NcaeZW4e+lsXcDe5hqIbtTdEyfKMzNjpGnhp1vovOxM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=R4w59v0+xMtXO4O0sZ0pv6rVP9YJWo5fB0en3vgx17u7hKgtX2hjYYY5eg9NJEqYhjU+oj/B02u1xO6kqEWeEyK5Kj9uFavIw8tad+nCrnPLMFOemP0DJpgm43yvk9bsO5aA2+kCVAG0+lyfkbkJvMBNMdGEDe0thiILofaKGvE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=TbBb3oWH; 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="TbBb3oWH" Received: by smtp.kernel.org (Postfix) with ESMTPS id AF516C19424; Tue, 9 Dec 2025 22:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1765320291; bh=NcaeZW4e+lsXcDe5hqIbtTdEyfKMzNjpGnhp1vovOxM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TbBb3oWHAhhsMpiTLOV6Rcs7jNZoYVLefwgb+zgjjTDm6iUk0s6wB0ty2G7EFxfEv UWfyMlSEkvPDz9Hykeq/dNUJfJ3nInSf/GUqzsLZtP1uZDVmR3Ypb1/ND3GWDl687D ZDJjGnHT/o+M3Tv4aRlTlKeq9+frz+bE7I3AvhqY= 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 9FDF7D3B982; Tue, 9 Dec 2025 22:44:51 +0000 (UTC) From: Richard Leitner Date: Tue, 09 Dec 2025 23:44:37 +0100 Subject: [PATCH v10 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: <20251209-ov9282-flash-strobe-v10-2-0117cab82e2d@linux.dev> References: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@linux.dev> In-Reply-To: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@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=1765320290; l=1947; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=NcaeZW4e+lsXcDe5hqIbtTdEyfKMzNjpGnhp1vovOxM=; b=5rJ+2YO21XNdLRU2oLJ9WRbWJ6FJ0jiE2cSfJwKQEtRLv56slooLnQ1Mu6dBbcxvTDyHShU47 i902FFZWDEeCwPggkkR1sFZkQBoSXeOoQ01G29CnP81hoIDgK+WqJ6w 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 4848423205ff7..765aeeec84fe5 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 9830833b48a52..32ba3b5fb1dd5 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 Thu Dec 18 08:37:13 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 26A8F2EC54A; Tue, 9 Dec 2025 22:44:51 +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=1765320292; cv=none; b=ZO8qhfo29KBFgg9Qx4NTFn9qldnE2fgaXeOME6LUpEzBNYG3yU6eNM281Oib7ZSvwluhv2jO/p78eeEk3wTIE5QHxCeg2MSKR62sk6w/C73h/QazZDgeCitiFUMfkOk92DAmCBwtGb/McyGXF8262yJnIsSvLVHhsZEJ4chtSqw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765320292; c=relaxed/simple; bh=yRfk/k98fKVjF+oHG+UiWlyx+HP+Q2RBdionlRvUcH8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Wc05KEKj4zEFJJ9sAMB54JCGPnwqhRpr+4AVw/nNsUvqDSg+U+sv3W+LVTsIqgqmhnWnrittYpa4T481mxNT3dVgVdWWNnTjtMQ4e1bUD4+f7f66PwGiOrhjalTrBNvu7aBRkh024nLHmNeYTSAYpovWQq+1ZxjD5mDqeLxTS84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=SU8k0VAI; 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="SU8k0VAI" Received: by smtp.kernel.org (Postfix) with ESMTPS id BCA3AC19425; Tue, 9 Dec 2025 22:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1765320291; bh=yRfk/k98fKVjF+oHG+UiWlyx+HP+Q2RBdionlRvUcH8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SU8k0VAI2O8jJjRDvllAX5pALhyxWIfOtuyXYInrnNKPm9+jbnvPLdgifETveLW+U HB7nZufwtbGTMXRmoPibAe13KxVnO74j6Kok1VAI9DfSFFehL+oabSpTU/Wj3QYDtW yIPrgSTIo/pRjxvRT8yM5UDeZcJGdmKTPM3MWZ4g= 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 B2F34D3B9AA; Tue, 9 Dec 2025 22:44:51 +0000 (UTC) From: Richard Leitner Date: Tue, 09 Dec 2025 23:44:38 +0100 Subject: [PATCH v10 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: <20251209-ov9282-flash-strobe-v10-3-0117cab82e2d@linux.dev> References: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@linux.dev> In-Reply-To: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@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=1765320290; l=3445; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=yRfk/k98fKVjF+oHG+UiWlyx+HP+Q2RBdionlRvUcH8=; b=uLLfwgOs6nP1LBJz2zpEUpNEu5VZGCQDQVavqwycYWwLJLm7XgfA0+ExEL2Im6fIIZv23oLMr 4gF5voILNjiBRpREmO0SLRd6ZeQUlcTvOOn7B4Nzrq6pU5lzTM2bIGw 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 d22c5efb806a1..7cf0d33e79ff0 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 Thu Dec 18 08:37:13 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 3758C2ED165; Tue, 9 Dec 2025 22:44:52 +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=1765320292; cv=none; b=jf1mb8PvRQoQ8VbnA/QdLVDAkC/SnZJZJ2Crbv+UCVe0qJkD6r7+sWzjEhWHUodOfLUin09reQM0brKaA60Dfo/nbqrK8YUxpN+zuAPN+OGSdkbIHEV0aZPsLeZqxUlVxpf7sFPFNAY2SV/3P4ehRJXGxK9+wq3PEdHhHF3iodM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765320292; c=relaxed/simple; bh=VmrcdnXikQqKSpyLnki4cBWvMBCS/8zd9ZSCDjF2qaM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PyYRL91tvFBsjleizBTJaRb0xB1tpsRzLzeDVBZfphnCPQ/AGntMSTgaUShqk/RabVb6FGX02y2UdfuZWJsNtm/+LVTgItCfIEYLGJexAxaK0rMV9tgrVDHM2r9rL3eFmTTMRYHs1XoNcRJH+9ivk2hc7iQ3xvBhT48rNSV7wdg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=gybPw9YW; 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="gybPw9YW" Received: by smtp.kernel.org (Postfix) with ESMTPS id CF29BC2BC87; Tue, 9 Dec 2025 22:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1765320291; bh=VmrcdnXikQqKSpyLnki4cBWvMBCS/8zd9ZSCDjF2qaM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gybPw9YW9E0a4PhYLOLF1yxYuecJIdpbXTmlTHZtg6/NZhgV5XA0FNTTUyLJILOoK 6tyvO2WvBVfP2NiZsYqqRokXj4eb44alXzm6b70oYRw3wK2hBHu8eIfCm5An7c8hTA 9SLOTGKoSP1u/9yamtp6JCgs13uBArtDyHqj7yIw= 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 C61CED3B998; Tue, 9 Dec 2025 22:44:51 +0000 (UTC) From: Richard Leitner Date: Tue, 09 Dec 2025 23:44:39 +0100 Subject: [PATCH v10 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: <20251209-ov9282-flash-strobe-v10-4-0117cab82e2d@linux.dev> References: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@linux.dev> In-Reply-To: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@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=1765320290; l=2137; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=VmrcdnXikQqKSpyLnki4cBWvMBCS/8zd9ZSCDjF2qaM=; b=bpwdRl8/NSpXnwdI6l6O8sCigu7E30m5R0ybJVkSP61UVGE+nxBJih1OwOJJT4kUSMwOSrQ6o KM+Xn6dpLWGAsYyNYKDxRsm4G4o3kPRewAzKKg3mC3a394iaQ9mqtpL 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 a9f6176e9729d..e67cff6c30ffa 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 Thu Dec 18 08:37:13 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 5E4E92F0686; Tue, 9 Dec 2025 22:44:52 +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=1765320292; cv=none; b=r3BBq5E6Vm0T4cjZplnt4barFc5a4ygHyDHjZam97Z9pUdjZe45lITiPOHNecLbHwYQk+VCB9Yo6j3/j4ZYoYdh0PjAc+WKu8P7SsVKUnBzjeomHLbcRNWIAh11roOiGxWBXoTtCu1nPmOjwYjItIsT98qFzotVrnMNB8PTlAzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765320292; c=relaxed/simple; bh=ygvVtpR0X7zyUAS2i7/ot2H6udVXFUOAiwzQzpah+74=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iL/CvYUKT+e+oV50wjjmOSmHweDr0OC32an59Z+7aeLSJsSpmUys6RdbHaaVSKs1R/x159bllPthD8k8NvstB0SOrqklbjTtm9dfktzParDpJuU5dUsnbZfTfUEyX/4uc+Rz5wdJlVn4SAcldWjfB/MbDpHy64bwT2JVf3GRnn8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=qyBro07O; 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="qyBro07O" Received: by smtp.kernel.org (Postfix) with ESMTPS id E238BC19423; Tue, 9 Dec 2025 22:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1765320291; bh=ygvVtpR0X7zyUAS2i7/ot2H6udVXFUOAiwzQzpah+74=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qyBro07O1MkwlO2LlL/rCTcrIn4+6IkFP6ifYiSg03I/6opq0waBaG8jmpk5NiSr1 KZLrxepImOLgm8F7srFxf+Yl7rQ/YWhuzQD0PSmVeWoSfC75hsM6cFiKvGRJsoOPDn Kt5/ikJ0+V97boolLLWwS2NYBCOJORHnGRgRt6sM= 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 D8DCED3B9AB; Tue, 9 Dec 2025 22:44:51 +0000 (UTC) From: Richard Leitner Date: Tue, 09 Dec 2025 23:44:40 +0100 Subject: [PATCH v10 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: <20251209-ov9282-flash-strobe-v10-5-0117cab82e2d@linux.dev> References: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@linux.dev> In-Reply-To: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@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=1765320290; l=2317; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=ygvVtpR0X7zyUAS2i7/ot2H6udVXFUOAiwzQzpah+74=; b=on0jrDyM3MHEBRW5S8YwXhXht9WNphiLjiq0nvc6skvbGxozGglTUzgL7vgDLsHDknT5N2ED0 xwkk/nHMz/ACmXpF4Vu6BeBoPwe3+6NV75NjEwsrsnuZxb3CdgfjcRR 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 e67cff6c30ffa..6afce803a049d 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 Thu Dec 18 08:37:13 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 4D4722EFD8A; Tue, 9 Dec 2025 22:44:52 +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=1765320292; cv=none; b=Nck7nDnSVTWDFlOwEl68vcRxttXVAtkEIvawG+o2CkRRszFtc1h2yz5gdVJST0Nye+WracA00B3pmAuQo2WJmtvl5EEN/iHEOpLKeNRMsQZqzPGm+o5qdvegKh49X37jJJm1U/EeAmrMc3KWLlHW7wykv8OhG3tPhrEsX55Ur3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765320292; c=relaxed/simple; bh=ql9elevyOa14jUq8mUYlt9RSPi/+CkHVrpCz7LqekyU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=nSZDvnlTdyOE4i65+NgmbvUNd2TjVCJD+g+I3Zmy4bmO0WTn1NfTDKwV7r3rB0ldXYF+PWLwR0k1QPaMvIck2m0H4XFCIk2nnZ9hTfcYj1cLKRKNLh1qRfX5fXrr2D9MIhIcsOHnJqqUD6VgqlsAF5kPNeIyHsL/7BQvILpyc/4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=tkUTCku4; 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="tkUTCku4" Received: by smtp.kernel.org (Postfix) with ESMTPS id 03F7EC2BC86; Tue, 9 Dec 2025 22:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1765320292; bh=ql9elevyOa14jUq8mUYlt9RSPi/+CkHVrpCz7LqekyU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tkUTCku4zgdlpeLi6Yk9XwpizqOKpO1ajRmuHhFiY77YUIWnh2iem9MA76XUa1f8A I0ARWNxqF6rf6PhT6oJD139L/oj9avazTpcSNDelTfLpy4t88Ojz8i/lhb6jg5fXDb 7f7R76347HgIv+dAMhu9TiQlSGt3nCN2dTYLmSoY= 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 EB43DD3B9A4; Tue, 9 Dec 2025 22:44:51 +0000 (UTC) From: Richard Leitner Date: Tue, 09 Dec 2025 23:44:41 +0100 Subject: [PATCH v10 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: <20251209-ov9282-flash-strobe-v10-6-0117cab82e2d@linux.dev> References: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@linux.dev> In-Reply-To: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@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=1765320290; l=3706; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=ql9elevyOa14jUq8mUYlt9RSPi/+CkHVrpCz7LqekyU=; b=7zJ17msfNyBOkCo7lYPVkSr5Nf6V8EdjwObQINRDVpUOP4W38Pjfo72g5cfRxvjliwV8uv6zb SDZMSdfnnBaBqrvkmMTwlrwhJITdIPbgXbCOpMM6siYWmAePZTAMs7P 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 | 46 ++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 6afce803a049d..790d421157e54 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,40 @@ 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); + if (ret) + return ret; + + ret =3D ov9282_write_reg(ov9282, OV9282_REG_STROBE_FRAME_SPAN + 1, 1, + (val >> 16) & 0xff); + if (ret) + return ret; + + ret =3D ov9282_write_reg(ov9282, OV9282_REG_STROBE_FRAME_SPAN + 2, 1, + (val >> 8) & 0xff); + if (ret) + return ret; + + 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 +794,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 +1386,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 +1455,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 Thu Dec 18 08:37:13 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 5E4772F0678; Tue, 9 Dec 2025 22:44:52 +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=1765320292; cv=none; b=RMdrjYpbFn36sPE62epur0f5QxYQABvM8os8d1In8+AL45h116uvgZ7JXqJOwClxCAkN6mFOnNHzQ3eHz3vl4D+bffje0GVKKaxsCVa5v3Uw3cLURwoK5exjWrqwgIUJ6czsK2QXF7ruJjQry9KhuIw0zUPgfOpRoqd3uw9Oqfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765320292; c=relaxed/simple; bh=jWwqpd7yB+Zf99f0iolQPDAOHTF2P4bty1r/d+o0QaA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=t6RM/iK+nXTUATxfnHDFnKoXBPoXZ0BDqL3vdsvMTqQto/WG42LixRnhy3y+gIjiClKQDDrfuff+CvjLboeabbGIIPw/dlttnMPBs6TzmOilAYN3HRwfKWC7Yllil8Ay6sEh5mXhWAquBgHJjmGKDDySzSBXVFh1B0YyQMQRtDg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=u5uJ7N8p; 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="u5uJ7N8p" Received: by smtp.kernel.org (Postfix) with ESMTPS id 1369DC113D0; Tue, 9 Dec 2025 22:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1765320292; bh=jWwqpd7yB+Zf99f0iolQPDAOHTF2P4bty1r/d+o0QaA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=u5uJ7N8pq7tnI2tHxVWCltfibx0HK7uvOtMwgenZIjtII3keh9hr8PQ1QnGyxGY/6 CTMGrqfz9CzGJLUGrk6+JEVmy/ZfPlfXj5cnIKlp4Mned8pwcGsdX9+xhwz6kGP5/Q 7q8sJ23rHUG3cUOyR8tPjj/veIyRD2GxXd0ZlAtY= 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 0CFB5D3B9AA; Tue, 9 Dec 2025 22:44:52 +0000 (UTC) From: Richard Leitner Date: Tue, 09 Dec 2025 23:44:42 +0100 Subject: [PATCH v10 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: <20251209-ov9282-flash-strobe-v10-7-0117cab82e2d@linux.dev> References: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@linux.dev> In-Reply-To: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@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=1765320290; l=3726; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=jWwqpd7yB+Zf99f0iolQPDAOHTF2P4bty1r/d+o0QaA=; b=VsOIi3v+zyiG1c2HOH/rzXYv3TZg74kMGWq0MbE67LiYgAyt0HdSAId+8w2YyLRS+R1vHBUk/ dTIOD/a0Y0VA+ZSvW0o8mv8C7K9aiDU0WzLdDVoJCf5mhRX0rwIFALg 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 790d421157e54..4c25b3e11afc0 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); @@ -807,9 +829,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 Thu Dec 18 08:37:13 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 4D4022EF677; Tue, 9 Dec 2025 22:44:52 +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=1765320292; cv=none; b=qOTtysBGld4uJZzvn4IyT0CSYoOVwUCF1uUWgKxHn58srJkj8IGYo1hu9qxxAysBaRrTVixNV9BdAsx6xgW4rfUlj/IKcMwFAEf4/RGaGUFauDsKxIWwwbyZFdSakh3B2Tqe7u/BwYEqmW+BnNKtu+s5W4dU5yuTNwX1KCNhAxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765320292; c=relaxed/simple; bh=UuMoLuJfdLps8yqouK7Hr1rJGUdmAkEs+vLHfq0hc7Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Yvztt+m4nYfIlKoBaBs8c+41t8vZWOH9T9HnTIee8FyPMDXzoJXFM7+8ckQABzXv0wt0jZN8FoMKuUmZslb3hWkQE+GfcJ8cCeG/qOnZNVn+SeKC9YITEd4/7mXTNtZ6BAApt8uMJFL+ehXKoxdjUFxFMPtxGiRBoJI029Hoo6s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=K9HqtCqm; 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="K9HqtCqm" Received: by smtp.kernel.org (Postfix) with ESMTPS id 26F18C2BCAF; Tue, 9 Dec 2025 22:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1765320292; bh=UuMoLuJfdLps8yqouK7Hr1rJGUdmAkEs+vLHfq0hc7Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=K9HqtCqmmVkEds6XoIFBbFm9xPEfet3QnXguGVkC88mtAATSSHFUie5KDUkuMQUsl MBq9EySvK9USS0KYFAsXhow0ZAQaMVgb2NjbChhQHKNSMmeb5w8zO46ZfIsjAeX0QM VxreOAoHn5k4zZe7VDretrdShNQEYxA1JTVR4rOY= 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 1D7A2D3B982; Tue, 9 Dec 2025 22:44:52 +0000 (UTC) From: Richard Leitner Date: Tue, 09 Dec 2025 23:44:43 +0100 Subject: [PATCH v10 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: <20251209-ov9282-flash-strobe-v10-8-0117cab82e2d@linux.dev> References: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@linux.dev> In-Reply-To: <20251209-ov9282-flash-strobe-v10-0-0117cab82e2d@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=1765320290; l=3532; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=UuMoLuJfdLps8yqouK7Hr1rJGUdmAkEs+vLHfq0hc7Y=; b=xkRjGS9K8gG09Vv6NDV9eTBhCgVNEu1GVB3fW3OZ4aSA2rm6J2QmAng/3oYCICBHLlkbGZYUY OCpmNKcZg+ZCXLN+0A9TmxN6U3sdECEgFKmYqBppFkrtrg6SB//EBRd 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 4c25b3e11afc0..cb8f6696d2783 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); @@ -1432,6 +1450,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 @@ -1504,8 +1523,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