From nobody Tue Dec 16 02:24:44 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 95E2D1D5149; Fri, 14 Mar 2025 08:50:05 +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=1741942205; cv=none; b=O3R17gmwDUgtlXSC1/GQlNY5sHd4wNKS6er77S8YMrbvmD+H2S5u6P3KYOWnpeMA3kwrhyywOvBOcstx8g8IlShI3bMX5+LKv9O+LWOuJavDKxdIitFFHteNXXMRZr0jG4j4r25aYVz68I96cIwYY5p1ujm77lfC+TbPYQgyIRM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741942205; c=relaxed/simple; bh=7Wa0VBhegKQxMT3McKkSxf40miWJulhfAtbtVLQyTlI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mydo9kUWPQjkNuGC3UPZR7du21WUQ2a9P8RY3sKyVac8yHO5VsNNEPm0EEGSUPzueIklOzd/fW6wnxLR+ouJV7wG4IAT2QCplO2VTYf15y1e2uc1qjOBYqEmp1fmgvW5EQtunPaCpHmOMGD8GRw65NafhO1ob4CvMaUhi0L8Z4o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=C6V9cafQ; 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="C6V9cafQ" Received: by smtp.kernel.org (Postfix) with ESMTPS id 25040C4CEE3; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1741942205; bh=7Wa0VBhegKQxMT3McKkSxf40miWJulhfAtbtVLQyTlI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=C6V9cafQfb3ysQvBN6ARgvQsRHF6V6Kw2g8EfcndO5sz5HO1Ff+Hr5VoDW6Sg5nu4 0S9aRNN4ZGItuGDP8ci64RJLkeEbGoEfJOcXj0dloGFBzBnWOqVsmn62yi7dFSGmLA c2xF4uYYV8Brq5YS221fGIF3HNmTVHY+U/wo6rnU= 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 0D6F9C35FF1; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) From: Richard Leitner Date: Fri, 14 Mar 2025 09:49:55 +0100 Subject: [PATCH v2 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: <20250314-ov9282-flash-strobe-v2-1-14d7a281342d@linux.dev> References: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@linux.dev> In-Reply-To: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1741942203; l=1792; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=7Wa0VBhegKQxMT3McKkSxf40miWJulhfAtbtVLQyTlI=; b=mrnCjztFt4S0tdo2//Owp7ioS+OjiVRZnM+l/XPDyRbp5uGLKuWPEDY+S5ze0E8BAy6vaiIbZ PRLmkeg4lXIAPY+tON/0iDpnHOTaIuJ6AJfSTcnRbmbCp6CvgNPccaP X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 Add a control V4L2_CID_FLASH_DURATION to set the duration of a flash/strobe pulse. This is different to the V4L2_CID_FLASH_TIMEOUT control, as the timeout defines a limit after which the flash is "forcefully" turned off again. On the other hand the new V4L2_CID_FLASH_DURATION is the desired length of the flash/strobe pulse Signed-off-by: Richard Leitner --- drivers/media/v4l2-core/v4l2-ctrls-defs.c | 1 + include/uapi/linux/v4l2-controls.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/media/v4l2-core/v4l2-ctrls-defs.c b/drivers/media/v4l2= -core/v4l2-ctrls-defs.c index 1ea52011247accc51d0261f56eab1cf13c0624a0..f9ed7273a9f3eafe01c31b638e1= c8d9fcf5424af 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 974fd254e57309e6def95b4a4f8e4de13a3972a7..80050cadb8377e3070ebbadc493= fcd08b2c12c0b 100644 --- a/include/uapi/linux/v4l2-controls.h +++ b/include/uapi/linux/v4l2-controls.h @@ -1173,6 +1173,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.2 From nobody Tue Dec 16 02:24:44 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 76392192D6B; Fri, 14 Mar 2025 08:50:05 +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=1741942205; cv=none; b=hhQYwltgMyLdhvBtMB2kLKLv+JVofR4Vz9QpU26SO29TP59VQyr7aq3/ahlmcvzcW+3Cpcim4D1Mdu1oraBcgCP+tUT5X2yW87W3FtOs/ZHSvEp+Imjf5QK9n/WJJLTd70Qzf3oZdnx+F+94Mo1r/iNgHs5EBK7ZSgEyjZ1yt38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741942205; c=relaxed/simple; bh=LVdkx1HHnCgF9PxdCqbpp0HAodzXvbi8+XOQgquqxWI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PFDUNGeLUpWISnYxntoUudKopQEDOI4IC6Vw068QKnnRN9u57Gpr1DPh0wQAymvAgPPSRyCUJeDdpdkIGXn7Kq47IUm4gAz+FIjcEHCPQNoDu6LSZq0XeVvQXgqgYJnz3sPI3gDvT0fjvaZreWaa5BsonfmSVXoXLPYqvwYteh8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=c2TFpzEW; 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="c2TFpzEW" Received: by smtp.kernel.org (Postfix) with ESMTPS id 2CF7FC4CEEC; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1741942205; bh=LVdkx1HHnCgF9PxdCqbpp0HAodzXvbi8+XOQgquqxWI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=c2TFpzEWgV8S/3f05pw7yugAlBsi7Rv43PYboTGk/KZ0zpYBNFIlPGm+mnN4soim/ kguSMs538tuAMdfmizPkxtu9MVLNhAwBv7Nd+v4Izn1lA1gIFCB33XhithA6k94iL6 CNI8bNBeqy/rw9QTG9lycR/3UG6fmTgz8hcWB/mM= 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 20975C282EC; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) From: Richard Leitner Date: Fri, 14 Mar 2025 09:49:56 +0100 Subject: [PATCH v2 2/8] media: v4l2-flash: add support for flash/stobe 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: <20250314-ov9282-flash-strobe-v2-2-14d7a281342d@linux.dev> References: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@linux.dev> In-Reply-To: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1741942203; l=4241; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=LVdkx1HHnCgF9PxdCqbpp0HAodzXvbi8+XOQgquqxWI=; b=T1N5UmGtWggEUhkBBhtxOf4UrOFcr+ii4LAMLTErvZNeQNiORQpROhK5RQ3cEdsBBUMhe747v KEdPSOnnljvCi26vO01sRUdQVDkVNPTuf7ehSGa+OGdlM0bq25ye3+K X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 Add support for the new V4L2_CID_FLASH_DURATION control to the v4l2 led flash class. Signed-off-by: Richard Leitner --- drivers/leds/led-class-flash.c | 15 +++++++++++++++ drivers/media/v4l2-core/v4l2-flash-led-class.c | 13 +++++++++++++ include/linux/led-class-flash.h | 16 ++++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/drivers/leds/led-class-flash.c b/drivers/leds/led-class-flash.c index f4e26ce84862c05092a9598e63ed301967852f13..165035a8826ca7d44a5cd265a51= 30a76c6e94347 100644 --- a/drivers/leds/led-class-flash.c +++ b/drivers/leds/led-class-flash.c @@ -440,6 +440,21 @@ int led_update_flash_brightness(struct led_classdev_fl= ash *fled_cdev) } EXPORT_SYMBOL_GPL(led_update_flash_brightness); =20 +int led_set_flash_duration(struct led_classdev_flash *fled_cdev, u32 durat= ion) +{ + struct led_classdev *led_cdev =3D &fled_cdev->led_cdev; + struct led_flash_setting *s =3D &fled_cdev->duration; + + s->val =3D duration; + led_clamp_align(s); + + if (!(led_cdev->flags & LED_SUSPENDED)) + return call_flash_op(fled_cdev, duration_set, s->val); + + return 0; +} +EXPORT_SYMBOL_GPL(led_set_flash_duration); + MODULE_AUTHOR("Jacek Anaszewski "); MODULE_DESCRIPTION("LED Flash class interface"); MODULE_LICENSE("GPL v2"); diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media= /v4l2-core/v4l2-flash-led-class.c index 355595a0fefac72c2f6941a30fa430d37dbdccfe..963b549480f6eb3b9eb0d80696a= 764de7ffcc1a2 100644 --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c @@ -298,6 +298,12 @@ static int v4l2_flash_s_ctrl(struct v4l2_ctrl *c) * microamperes for flash intensity units. */ return led_set_flash_brightness(fled_cdev, c->val); + case V4L2_CID_FLASH_DURATION: + /* + * No conversion is needed as LED Flash class also uses + * microseconds for flash duration units. + */ + return led_set_flash_duration(fled_cdev, c->val); } =20 return -EINVAL; @@ -424,6 +430,13 @@ static void __fill_ctrl_init_data(struct v4l2_flash *v= 4l2_flash, ctrl_cfg->flags =3D V4L2_CTRL_FLAG_VOLATILE | V4L2_CTRL_FLAG_EXECUTE_ON_WRITE; } + + /* Init FLASH_DURATION ctrl data */ + if (has_flash_op(fled_cdev, timeout_set)) { + ctrl_init_data[FLASH_DURATION].cid =3D V4L2_CID_FLASH_DURATION; + ctrl_cfg =3D &ctrl_init_data[FLASH_DURATION].config; + __lfs_to_v4l2_ctrl_config(&fled_cdev->duration, ctrl_cfg); + ctrl_cfg->id =3D V4L2_CID_FLASH_DURATION; } =20 static int v4l2_flash_init_controls(struct v4l2_flash *v4l2_flash, diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flas= h.h index 36df927ec4b7dcaf9074c6ef32ac8ce83a87a79d..21ec856c36bc67decda46aa8ff1= c040ffdcf1181 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -45,6 +45,8 @@ struct led_flash_ops { int (*timeout_set)(struct led_classdev_flash *fled_cdev, u32 timeout); /* get the flash LED fault */ int (*fault_get)(struct led_classdev_flash *fled_cdev, u32 *fault); + /* set flash duration */ + int (*duration_set)(struct led_classdev_flash *fled_cdev, u32 duration); }; =20 /* @@ -75,6 +77,9 @@ struct led_classdev_flash { /* flash timeout value in microseconds along with its constraints */ struct led_flash_setting timeout; =20 + /* flash timeout value in microseconds along with its constraints */ + struct led_flash_setting duration; + /* LED Flash class sysfs groups */ const struct attribute_group *sysfs_groups[LED_FLASH_SYSFS_GROUPS_SIZE]; }; @@ -209,4 +214,15 @@ int led_set_flash_timeout(struct led_classdev_flash *f= led_cdev, u32 timeout); */ int led_get_flash_fault(struct led_classdev_flash *fled_cdev, u32 *fault); =20 +/** + * led_set_flash_duration - set flash LED duration + * @fled_cdev: the flash LED to set + * @timeout: the flash duration to set it to + * + * Set the flash strobe duration. + * + * Returns: 0 on success or negative error value on failure + */ +int led_set_flash_duration(struct led_classdev_flash *fled_cdev, u32 durat= ion); + #endif /* __LINUX_FLASH_LEDS_H_INCLUDED */ --=20 2.47.2 From nobody Tue Dec 16 02:24:44 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 95D681C863D; Fri, 14 Mar 2025 08:50:05 +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=1741942205; cv=none; b=iewsSsHmVIk6KaNZLULBBqAdr6oj89Xohn55pLF0yJEGdX6sXU85JeO/a+ae4F2qo92Gg/ZfIHpudYOiULZwJPIZ2SuzHGuayaM+pfXnzgT4HRAChI/6tKH1WsWAn8m8c61ce+It6Kgx+U5eqIFTMTY50mZ20OaV8vNHBofdXqI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741942205; c=relaxed/simple; bh=8XoXfLI3glbsttjIv49MTkNU8w73Ts/XjbKrGmMzkd0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dDmXU/5fRVjMha/0PFI3pDoLRZUss96gcykusbxNKc9KCsr82xtzgD3wKVRAp2xiy5Tg3b/hIBAkZczOXR1VKVbsYrwv+BTYvg0ttdFYTCbfRg/dfl6F21dZ8Xd86xlRI+yeli8r9Tjet/riRvo2rssEr+p3zeqXAPFIIteBY6c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=0WT5bSfo; 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="0WT5bSfo" Received: by smtp.kernel.org (Postfix) with ESMTPS id 425CAC4CEF0; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1741942205; bh=8XoXfLI3glbsttjIv49MTkNU8w73Ts/XjbKrGmMzkd0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=0WT5bSfoIWPxDCpD8kyeIwFBHlv3tMWwOFEOA0iIO5uWxI+iohSgbSmVDTKLdio9h kukBAzBpJBpkiYv9veH4lYBVWur/QWHIk4/EJVlBHsNzxy9gfk+04zWnYMzmnILSzf iKKNCM6tzUeSH6BFgnKkviNf9aihhhp+5sj6s6oc= 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 35601C28B2F; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) From: Richard Leitner Date: Fri, 14 Mar 2025 09:49:57 +0100 Subject: [PATCH v2 3/8] media: v4l2-flash: fix flash_timeout comment 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: <20250314-ov9282-flash-strobe-v2-3-14d7a281342d@linux.dev> References: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@linux.dev> In-Reply-To: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1741942203; l=878; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=8XoXfLI3glbsttjIv49MTkNU8w73Ts/XjbKrGmMzkd0=; b=YAuvxJYLMgYdFE3YQnHK45vsJdZYwF8OsncSzUcOKxHZc/FLTZYTLZbuGP4HTq9O/Qtl33kgB Iz7MZpZ+nkYA0ft1JRvYE1mV+pu+FJmThb9GuRjpxMwQBiybe4eMO3B X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 The comment for the flash_timeout setter mentioned it is the "flash duration". Fix this by changing it to "flash timeout". Signed-off-by: Richard Leitner --- include/linux/led-class-flash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flas= h.h index 21ec856c36bc67decda46aa8ff1c040ffdcf1181..775a96217518936633541c7a5d3= 94502dbf04f83 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -197,7 +197,7 @@ int led_update_flash_brightness(struct led_classdev_fla= sh *fled_cdev); * @fled_cdev: the flash LED to set * @timeout: the flash timeout to set it to * - * Set the flash strobe duration. + * Set the flash strobe timeout. * * Returns: 0 on success or negative error value on failure */ --=20 2.47.2 From nobody Tue Dec 16 02:24:44 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 BB2111D63D3; Fri, 14 Mar 2025 08:50:05 +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=1741942205; cv=none; b=F+cLq3K2PfHH4OlAzbQ5Iwl+JxVbd4TiLlwSv6uuYWv5ug0Si3U/pf7WKcRJC6bU1gipYXNEe5csq+TSYc83X6Vp2BCty9qcAMCi+RQ1OvehkRIAcS8IEEjnSi36LZq4buhuvIiZ0hLhYxB2Va7pKnGYNey1S6p5lm6T43XT78U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741942205; c=relaxed/simple; bh=16N0ehkJWytFD5jx5wDbSTZhtNf5Qf6vx2SOhlkAC1Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=iq6z8vmCUDrYEFAq1mz3HI+VTkEYN+6nZ05NUguG0j4wFZELr8LLRBTZLtZLRAn7yUCbeo/FujWro+KvWSSHfcldyGo1DHoOnWkzDusG8OMPus9vNz2ALY0rY2mZsKfK6UaHLGKl5RzvO655VdZKa/FKrcn8Qh/EVOFsoDlbhx4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=ExnRBqEl; 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="ExnRBqEl" Received: by smtp.kernel.org (Postfix) with ESMTPS id 5072AC4CEF1; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1741942205; bh=16N0ehkJWytFD5jx5wDbSTZhtNf5Qf6vx2SOhlkAC1Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=ExnRBqElfp7Q+Hz/hU4B2hH52eYctSP6RRNBeLiih82Xm5AL9MkickCcMwuUQyjua 7P8ONumkOJkRPz490Roc99dl+4CkauaxkqhGpLYaSP+Dub2ZOzW8zYjYpjM0LMCF22 l7e6RfaBDrqIz0FC61Ac3CFvVC70PILD+Qi08Lh0= 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 46290C35FF6; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) From: Richard Leitner Date: Fri, 14 Mar 2025 09:49:58 +0100 Subject: [PATCH v2 4/8] Documentation: uAPI: media: add V4L2_CID_FLASH_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: <20250314-ov9282-flash-strobe-v2-4-14d7a281342d@linux.dev> References: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@linux.dev> In-Reply-To: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1741942203; l=1038; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=16N0ehkJWytFD5jx5wDbSTZhtNf5Qf6vx2SOhlkAC1Y=; b=rYZXVUqgHQMZYjS6f4BgCjAXopqcphD3BKyHdNDVfTBxmt1eilUnuk68mmJqtbtSEw326OBtC 6pNM0zOgllUDI0eHayqXHkPaZwIngG4oKfxNEHlDnog2306MLiKNX9B 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 control to v4l uAPI documentation. Signed-off-by: Richard Leitner --- Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst b/Do= cumentation/userspace-api/media/v4l/ext-ctrls-flash.rst index d22c5efb806a183a3ad67ec3e6550b002a51659a..03a58ef94be7c870f55d5a9bb09= 503995dbfb402 100644 --- a/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst +++ b/Documentation/userspace-api/media/v4l/ext-ctrls-flash.rst @@ -186,3 +186,8 @@ Flash Control IDs charged before strobing. LED flashes often require a cooldown period after strobe during which another strobe will not be possible. This is a read-only control. + +``V4L2_CID_FLASH_DURATION (integer)`` + Duration the flash should be on when the flash LED is in flash mode + (V4L2_FLASH_LED_MODE_FLASH). The unit should be microseconds (=C2=B5s) + if possible. --=20 2.47.2 From nobody Tue Dec 16 02:24:44 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 C18261D6DB4; Fri, 14 Mar 2025 08:50:05 +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=1741942205; cv=none; b=RclqzHSGtuoBhQjRMOOoWoiHhPkpUIFkm4D3cegXFVPEyVcvtAD3JSdNUYIWq8iiWt40oqtrE77aeVcdgDwz7REqPfq3x+B4+Y920unw1T86mz/YJF/yd5AlVNhXA+nGCKulvu7ZnZt3+4XhRbJ+yfCXwuuOglGUJGfrQf/DXac= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741942205; c=relaxed/simple; bh=FNa/xvakH+OMufv25Oa47P8olVqt6It8kjPg/VhP/1A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WiTvPvW+/2NPvDlppv3xPNN1CmZEEO5m2cEdiLxCFGU5nYPNvibTW0cCiczqLL3HxOPZFN7xXtelE1yrlv6l10kfzL2GsnQaZQ9d7u/s9goFfw+Za6AuQXZw+ZlsjdMtpV9iIr3ucitCvZHzBR+wM+zvX509TpJdMAFuWe5+7zA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=UxyQG2Kt; 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="UxyQG2Kt" Received: by smtp.kernel.org (Postfix) with ESMTPS id 5CE85C4CEF6; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1741942205; bh=FNa/xvakH+OMufv25Oa47P8olVqt6It8kjPg/VhP/1A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=UxyQG2KtkEKofoTxC10jsYpQrDNLRiiOuJzMYFwwlsz8VR7f6v2J6zbEaF54Vl5wS LLJw9G/cLW8ne7jpg5cwRiA3mzsh7dFaTqPHXBUqS5OPRJ8+ss5UW8fiR3ENQ1Debh dzUA0xlfFO4/hNk8Wscgx8c/TYNTyMUyqvpLSyH4= 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 55580C282EC; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) From: Richard Leitner Date: Fri, 14 Mar 2025 09:49:59 +0100 Subject: [PATCH v2 5/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: <20250314-ov9282-flash-strobe-v2-5-14d7a281342d@linux.dev> References: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@linux.dev> In-Reply-To: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1741942203; l=2191; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=FNa/xvakH+OMufv25Oa47P8olVqt6It8kjPg/VhP/1A=; b=AB/IxOU5F+ww4uQk2mmxHclTCRXFyPOKPmjoisGe9pyf3IcCCMLMoT6mgqVc/1y9uPnWC8Xxs OtTidj6ZF6KC1Cn5W+QIydyymG22QHHpX7gs9nL1TBhyN6gvGAvMIB3 X-Developer-Key: i=richard.leitner@linux.dev; a=ed25519; pk=8hZNyyyQFqZ5ruVJsSGBSPIrmJpfDm5HwHU4QVOP1Pk= X-Endpoint-Received: by B4 Relay for richard.leitner@linux.dev/20250225 with auth_id=350 Add #define's for the output enable registers (0x3004, 0x3005, 0x3006), also known as SC_CTRL_04, SC_CTRL_05, SC_CTRL_04. Use those register definitions instead of the raw values in the `common_regs` struct. All values are based on the OV9281 datasheet v1.53 (january 2019). Reviewed-by: Dave Stevenson Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index c882a021cf18852237bf9b9524d3de0c5b48cbcb..f42e0d439753e74d14e3a359202= 9e48f49234927 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.2 From nobody Tue Dec 16 02:24:44 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 CF5051D86C6; Fri, 14 Mar 2025 08:50:05 +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=1741942205; cv=none; b=KIte9kEwnOF7cRtSGBboQCRnjZ7xH4EpifHm2kwriTwZFdqXsmdkDMC5UiaSshbqPuqQ5ac9AEJV33yiY22MWC/jM/dqKi2QwHAzwJxxm3863j4aKqAYmKPDduxA79Hvse02lBVsXEiqv1H60L8HzJZHFQKV+vEt4psK7aYbhOM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741942205; c=relaxed/simple; bh=oKJQ5VQHM2+qB3rpr3DelVSUTCUoAL8/eslJyAU327k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Gq27mMrt7Fw831b/jpcX6K45hMVithUB5Jp2RM07eZgm3Fy1gIIWKqDTLab/cFCv8J9b9o5uEIIwFN0pEfxhoWaMSbM43b7hjD8/7lBPEFr8MyC9GltL5U7xYgWNx68TmyfAMvZ8OapXAIrfD6g//nNoZRbQUhATtTa6AOlk/G0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=n3tUD1yT; 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="n3tUD1yT" Received: by smtp.kernel.org (Postfix) with ESMTPS id 704B2C4CEFB; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1741942205; bh=oKJQ5VQHM2+qB3rpr3DelVSUTCUoAL8/eslJyAU327k=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=n3tUD1yTJlA34hDF0izudeDHU6Iz9Abf7QyVBJYtdS8ovsjNd3M5awEZkcSotGZly HssR1TLlTspD27EGcSD9WDljXbXNzNTqoNLJ0eADvZRdORPxSFcz2yxtQqWdUbB0xd HCKx6VTEOPs43+YSoJ57wWUTOihT/JF95kY6mgzc= 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 679F1C28B2F; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) From: Richard Leitner Date: Fri, 14 Mar 2025 09:50:00 +0100 Subject: [PATCH v2 6/8] media: i2c: ov9282: add led_mode 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: <20250314-ov9282-flash-strobe-v2-6-14d7a281342d@linux.dev> References: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@linux.dev> In-Reply-To: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1741942203; l=2413; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=oKJQ5VQHM2+qB3rpr3DelVSUTCUoAL8/eslJyAU327k=; b=qE9sn41pFd6jSVN+OVl8ug3yNScB3kECOuSZte7+tdCE8+RwjKnIARoxCvY69mCltfTDal3v0 78F8xm0ylNKC8YYr/pBDyKDP0NaK6uarxkrZ8zFDyIbQw/1Fsv+cUNb 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_LED_MODE support using the "strobe output enable" feature of the sensor. This implements following modes: - V4L2_FLASH_LED_MODE_NONE, which disables the strobe output - V4L2_FLASH_LED_MODE_FLASH, which enables the strobe output 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 | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index f42e0d439753e74d14e3a3592029e48f49234927..35edbe1e0efb61a0e03da0ed817= c4c4ec0ae9c35 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_led_mode(struct ov9282 *ov9282, int mode) +{ + u32 current_val; + int ret =3D ov9282_read_reg(ov9282, OV9282_REG_OUTPUT_ENABLE6, 1, + ¤t_val); + if (ret) + return ret; + + if (mode =3D=3D V4L2_FLASH_LED_MODE_FLASH) + 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_LED_MODE: + ret =3D ov9282_set_ctrl_flash_led_mode(ov9282, ctrl->val); + break; default: dev_err(ov9282->dev, "Invalid control %d", ctrl->id); ret =3D -EINVAL; @@ -1391,6 +1411,13 @@ 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_menu(ctrl_hdlr, &ov9282_ctrl_ops, + V4L2_CID_FLASH_LED_MODE, + V4L2_FLASH_LED_MODE_TORCH, + (1 << V4L2_FLASH_LED_MODE_TORCH), + V4L2_FLASH_LED_MODE_NONE); + ret =3D v4l2_fwnode_device_parse(ov9282->dev, &props); if (!ret) { /* Failure sets ctrl_hdlr->error, which we check afterwards anyway */ --=20 2.47.2 From nobody Tue Dec 16 02:24:44 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 D54081DA617; Fri, 14 Mar 2025 08:50:05 +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=1741942205; cv=none; b=a9kPYQTGnYQkpBDf5+z+UUSJW0c9lJFEWeI6IpovaAie1eoJ8T7Icc0FijGHytBXmi4QbNV5bE3LIOW0xNv945+KEj1hdBq+YExSSlrxHVK97fELPUDzmo4BXv+SHL5xM/4lozFeJecTA1unc4jEtTxaTojNUaENXQ9bz7Yk5tY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741942205; c=relaxed/simple; bh=KqwmKaB6GKLqmk1IDrdd2LBBIit07TUTil2D5DQEQVI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=QAZPuka21IAb6MTUruuuGi4iIRVDkCgbVPFrTOOVRJUI0QEmwgXTqYHY7V8Fd5BH+PZs99yoa87rIW1Xctkr1eGInsr90c9XQYy1uJMoVXWwV28M77yUjVbYc3AcgCliyquS1wPjAGxR6XxxNcwzPnkm/FIWDJm0MAtnJPLnDtk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=PRBiqxNe; 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="PRBiqxNe" Received: by smtp.kernel.org (Postfix) with ESMTPS id 80241C4CEFC; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1741942205; bh=KqwmKaB6GKLqmk1IDrdd2LBBIit07TUTil2D5DQEQVI=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=PRBiqxNeB7ZIqzndluOiN3na/dlyPg1N2eCc+g23/Bxli7BQSDXRMgHLPPI0rEB+H UC9vQetTazozeAN+kXcUAXYNpfJ8erz6J+hZn74aHHS9/h9DJk04bF3E8dlabxqeDO W9oq7nphIz1V78YSsExThecphNRNK3mqDqBwfDzY= 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 77E77C35FF1; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) From: Richard Leitner Date: Fri, 14 Mar 2025 09:50:01 +0100 Subject: [PATCH v2 7/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: <20250314-ov9282-flash-strobe-v2-7-14d7a281342d@linux.dev> References: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@linux.dev> In-Reply-To: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1741942203; l=3208; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=KqwmKaB6GKLqmk1IDrdd2LBBIit07TUTil2D5DQEQVI=; b=ilxyija4MDSeWzG29NgAwG52QMV/nZM4mpqApTz3OHly/n3EUrJQa3vGHQ5VmdLe2VngOjJ09 U2+Qb+FDXH5B1vBNqvJiZf2tS0MoF3+npXFSjm4cLkLtFWc/aHwKEOM 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 | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 35edbe1e0efb61a0e03da0ed817c4c4ec0ae9c35..5ddbfc51586111fbd2e17b739fb= 3d28bfb0aee1e 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_FLASH_DURATION 0x3925 +#define OV9282_FLASH_DURATION_DEFAULT 0x0000001A + /* Input clock rate */ #define OV9282_INCLK_RATE 24000000 =20 @@ -687,6 +691,24 @@ static int ov9282_set_ctrl_flash_led_mode(struct ov928= 2 *ov9282, int mode) current_val); } =20 +static int ov9282_set_ctrl_flash_duration(struct ov9282 *ov9282, int value) +{ + /* 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); + + ov9282_write_reg(ov9282, OV9282_REG_FLASH_DURATION, 1, (val >> 24) & 0xff= ); + ov9282_write_reg(ov9282, OV9282_REG_FLASH_DURATION + 1, 1, (val >> 16) & = 0xff); + ov9282_write_reg(ov9282, OV9282_REG_FLASH_DURATION + 2, 1, (val >> 8) & 0= xff); + return ov9282_write_reg(ov9282, OV9282_REG_FLASH_DURATION + 3, 1, val & 0= xff); +} + /** * ov9282_set_ctrl() - Set subdevice control * @ctrl: pointer to v4l2_ctrl structure @@ -756,6 +778,9 @@ static int ov9282_set_ctrl(struct v4l2_ctrl *ctrl) case V4L2_CID_FLASH_LED_MODE: ret =3D ov9282_set_ctrl_flash_led_mode(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; @@ -1418,6 +1443,9 @@ static int ov9282_init_controls(struct ov9282 *ov9282) (1 << V4L2_FLASH_LED_MODE_TORCH), V4L2_FLASH_LED_MODE_NONE); =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.2 From nobody Tue Dec 16 02:24:44 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 F198A1DC988; Fri, 14 Mar 2025 08:50:05 +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=1741942206; cv=none; b=ApVuZJN0WYoOncDw/m+qDA8d3G2mUufI1V+KSel2Ix38SYBzeKGr1+jWlctfkksb/sc3+hq5dhwyXjojhlWE3NtRk8KTsT6c2PDUsfEEkZF6bXsU2yR764+wQgwklvoE5CW2HyBB4b/QuaHX291+mqBPFtnyodtNHQefu5nrEpA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741942206; c=relaxed/simple; bh=XEA7eOKnFQPnS5jigwSOQXrETAAO0hBpVmtM8cu5xnQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=agyURClo17LwCg3uy3peGA/7q61FK43Occ4QHgtRF3X0YykYWAw6vbZUxi2cWojosYKtcK/fC8gWb+vg4q5eWkzPYvle+iNQGRpuxtHmYRvcObnzaYCTMYJxwNi3AhVl8c7nNaTz3vNnZEcdeT4vINkAHeT5BI1d2AYvbi4Fm7k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=VVBUYMpt; 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="VVBUYMpt" Received: by smtp.kernel.org (Postfix) with ESMTPS id 93B59C4CEEB; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux.dev; s=korg; t=1741942205; bh=XEA7eOKnFQPnS5jigwSOQXrETAAO0hBpVmtM8cu5xnQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=VVBUYMpt5s8GEwvk0DnS0uiM3Lp1rhpRxIIKPz9ZnONyXvQtta3iuZ8/W+rhzfRpD LfOuRFLUrzPxb6yxYPBcS/Dl2rKzUXodKMhfv5mrZcCBFzh/X4zU/vyHZZRBIGi1bo Jw9+tGSiC5XiiA2ZXZgFXxfFG4TflAssJLUd4RFI= 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 8B203C28B2F; Fri, 14 Mar 2025 08:50:05 +0000 (UTC) From: Richard Leitner Date: Fri, 14 Mar 2025 09:50:02 +0100 Subject: [PATCH v2 8/8] media: i2c: ov9282: add strobe_source 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: <20250314-ov9282-flash-strobe-v2-8-14d7a281342d@linux.dev> References: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@linux.dev> In-Reply-To: <20250314-ov9282-flash-strobe-v2-0-14d7a281342d@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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1741942203; l=1520; i=richard.leitner@linux.dev; s=20250225; h=from:subject:message-id; bh=XEA7eOKnFQPnS5jigwSOQXrETAAO0hBpVmtM8cu5xnQ=; b=YKAovdSG7xyrxaD5Lcmaq5kxWRhcXg06FWd4Q4S0qFjVtu9cbN9aX1l4Iv9fXAZrTLiMRHe6O PAwSH+3BanZA2Z6cLMIBpo+AjSxsyEXl8mvanmiprO5/W0u1mTfYya2 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 read-only V4L2_CID_FLASH_STROBE_SOURCE control. Its value is fixed to V4L2_FLASH_STROBE_SOURCE_EXTERNAL as the camera sensor triggers the strobe based on its register settings. Signed-off-by: Richard Leitner --- drivers/media/i2c/ov9282.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c index 5ddbfc51586111fbd2e17b739fb3d28bfb0aee1e..34ea903a18dadeeebd497a4a885= 8abf12b598717 100644 --- a/drivers/media/i2c/ov9282.c +++ b/drivers/media/i2c/ov9282.c @@ -1367,6 +1367,7 @@ static int ov9282_init_controls(struct ov9282 *ov9282) struct v4l2_ctrl_handler *ctrl_hdlr =3D &ov9282->ctrl_handler; const struct ov9282_mode *mode =3D ov9282->cur_mode; struct v4l2_fwnode_device_properties props; + struct v4l2_ctrl *ctrl; u32 hblank_min; u32 lpfr; int ret; @@ -1446,6 +1447,13 @@ static int ov9282_init_controls(struct ov9282 *ov928= 2) v4l2_ctrl_new_std(ctrl_hdlr, &ov9282_ctrl_ops, V4L2_CID_FLASH_DURATION, 0, 13900, 1, 8); =20 + ctrl =3D v4l2_ctrl_new_std_menu(ctrl_hdlr, &ov9282_ctrl_ops, + V4L2_CID_FLASH_STROBE_SOURCE, + V4L2_FLASH_STROBE_SOURCE_EXTERNAL, + ~(1 << V4L2_FLASH_STROBE_SOURCE_EXTERNAL), + V4L2_FLASH_STROBE_SOURCE_EXTERNAL); + ctrl->flags |=3D V4L2_CTRL_FLAG_READ_ONLY; + ret =3D v4l2_fwnode_device_parse(ov9282->dev, &props); if (!ret) { /* Failure sets ctrl_hdlr->error, which we check afterwards anyway */ --=20 2.47.2