* [PATCH v2 00/48] media: Add a helper for obtaining the clock producer
@ 2025-06-26 13:33 Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 01/48] media: v4l2-common: " Mehdi Djait
` (47 more replies)
0 siblings, 48 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:33 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media
Hello everyone,
Here is my v2 for the new helper v4l2_devm_sensor_clk_get()
I took this opportunity to make all the drivers that I touched with this
series return dev_err_probe() when the helper fails: the complete list
is below in the HISTORY. I noticed some odd drivers:
drivers/media/i2c/s5k5baf.c -> always returns -EPROBE_DEFER if getting the clock fails
drivers/media/i2c/mt9t112.c -> this drivers seems to be implementing
the behaviour of devm_clk_get_optional() while using devm_clk_get():
remove it from the list of changed drivers ?
drivers/media/i2c/ov8856.c -> getting the clock, setting the rate,
getting the optional gpio and the regulator_bulk is only when the fwnode
is NOT acpi.
Any testing of the patches is GREATLY APPRECIATED!
Especially the two drivers with the special ACPI case:
1) OV8865
2) OV2680
Background
----------
A reference to the clock producer is not available to the kernel
in ACPI-based platforms but the sensor drivers still need them.
devm_clk_get() will return an error and the probe function will fail.
Solution
--------
Introduce a generic helper for v4l2 sensor drivers on both DT- and ACPI-based
platforms.
This helper behaves the same as clk_get_optional() except where there is
no clock producer like in ACPI-based platforms.
For ACPI-based platforms the function will read the "clock-frequency"
ACPI _DSD property and register a fixed frequency clock with the frequency
indicated in the property.
Solution for special ACPI case
------------------------------
This function also handles the special ACPI-based system case where:
1) The clock-frequency _DSD property is present.
2) A reference to the clock producer is present, where the clock is provided
by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
In this case try to set the clock-frequency value to the provided clock.
History
-------
v1 -> v2:
- Added a check to !of_node instead of acpi_node as !of_node will cover
both acpi nodes and software nodes (currently used by AMD camera setup)
Changed the following drivers to use dev_err_probe() when the helper
fails:
s5k6a3.c
s5c73m3/s5c73m3-core.c
mt9m001.c
mt9m111.c
mt9p031.c
mt9m114.c
mt9v032.c
mt9v111.c
ov2659.c
ov2685.c
ov5640.c
ov5647.c
ov5648.c
ov5695.c
ov6650.c
ov7740.c
ov9282.c
ov9640.c
ov9650.c
imx412.c
imx335.c
hi846.c
et8ek8/et8ek8_driver.c
ar0521.c
Suggested by Laurent:
- changed clk_get_optional() to devm_clk_get() in the commit msg
and kernel-doc of the helper function
- improved the kernel-doc of the function
- added forward declaration of struct clk in include/media/v4l2-common.h
- changed the Documentation in the [PATCH 02/48]
- dropped the comment in ov2680.c
- removed the following drivers that are not camera sensors:
ds90ub913: Video Serializer
ds90ub960: Video Deserializer
st-mipid02: CSI-2 to PARALLEL bridge
tc358743: HDMI to CSI-2 bridge
tc358746: PARALLEL to CSI-2 bridge
thp7312: External Camera ISP
Suggested by Sakari:
- added the handling for when devm_clk_get_optional() returns
-EPROBE_DEFER
- added handling for when devm_clk_get_optional() returns
-EINVAL. The helper will return -EPROBE_DEFER signaling that
some software components are still needed before the sensor
driver can get probed (e.g. int3472 or the AMD ISP)
Suggested by Michael Riesch:
- made the imx415 clock name NULL
Link v1: https://lore.kernel.org/linux-media/cover.1750352394.git.mehdi.djait@linux.intel.com/
RFC History
-----------
RFC v4 -> RFC v5:
Suggested by Arnd Bergmann:
- removed IS_REACHABLE(CONFIG_COMMON_CLK). IS_REACHABLE() is actually
discouraged [1]. COFIG_COMMON_CLK is a bool, so IS_ENABLED() will be the
right solution here
Suggested by Hans de Goede:
- added handling for the special ACPI-based system case, where
both a reference to the clock-provider and the _DSD
clock-frequency are present.
- updated the function's kernel-doc and the commit msg
to mention this special case.
Link RFC v4: https://lore.kernel.org/linux-media/20250321130329.342236-1-mehdi.djait@linux.intel.com/
[1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/Documentation/kbuild/kconfig-language.rst?h=next-20250513&id=700bd25bd4f47a0f4e02e0a25dde05f1a6b16eea
RFC v3 -> RFC v4:
Suggested by Laurent:
- removed the #ifdef to use IS_REACHABLE(CONFIG_COMMON_CLK)
- changed to kasprintf() to allocate the clk name when id is NULL and
used the __free(kfree) scope-based cleanup helper when
defining the variable to hold the allocated name
Link v3: https://lore.kernel.org/linux-media/20250321093814.18159-1-mehdi.djait@linux.intel.com/
RFC v2 -> RFC v3:
- Added #ifdef CONFIG_COMMON_CLK for the ACPI case
Link v2: https://lore.kernel.org/linux-media/20250310122305.209534-1-mehdi.djait@linux.intel.com/
RFC v1 -> RFC v2:
Suggested by Sakari:
- removed clk_name
- removed the IS_ERR() check
- improved the kernel-doc comment and commit msg
Link v1: https://lore.kernel.org/linux-media/20250227092643.113939-1-mehdi.djait@linux.intel.com
Mehdi Djait (48):
media: v4l2-common: Add a helper for obtaining the clock producer
Documentation: media: camera-sensor: Mention
v4l2_devm_sensor_clk_get() for obtaining the clock
media: i2c: ar0521: Use the v4l2 helper for obtaining the clock
media: i2c: et8ek8: Use the v4l2 helper for obtaining the clock
media: i2c: gc05a2: Use the v4l2 helper for obtaining the clock
media: i2c: gc08a3: Use the v4l2 helper for obtaining the clock
media: i2c: gc2145: Use the v4l2 helper for obtaining the clock
media: i2c: hi846: Use the v4l2 helper for obtaining the clock
media: i2c: imx214: Use the v4l2 helper for obtaining the clock
media: i2c: imx219: Use the v4l2 helper for obtaining the clock
media: i2c: imx283: Use the v4l2 helper for obtaining the clock
media: i2c: imx290: Use the v4l2 helper for obtaining the clock
media: i2c: imx296: Use the v4l2 helper for obtaining the clock
media: i2c: imx334: Use the v4l2 helper for obtaining the clock
media: i2c: imx335: Use the v4l2 helper for obtaining the clock
media: i2c: imx412: Use the v4l2 helper for obtaining the clock
media: i2c: imx415: Use the v4l2 helper for obtaining the clock
media: i2c: mt9m001: Use the v4l2 helper for obtaining the clock
media: i2c: mt9m111: Use the v4l2 helper for obtaining the clock
media: i2c: mt9m114: Use the v4l2 helper for obtaining the clock
media: i2c: mt9p031: Use the v4l2 helper for obtaining the clock
media: i2c: mt9t112: Use the v4l2 helper for obtaining the clock
media: i2c: mt9v032: Use the v4l2 helper for obtaining the clock
media: i2c: mt9v111: Use the v4l2 helper for obtaining the clock
media: i2c: ov02a10: Use the v4l2 helper for obtaining the clock
media: i2c: ov2659: Use the v4l2 helper for obtaining the clock
media: i2c: ov2685: Use the v4l2 helper for obtaining the clock
media: i2c: ov5640: Use the v4l2 helper for obtaining the clock
media: i2c: ov5645: Use the v4l2 helper for obtaining the clock
media: i2c: ov5647: Use the v4l2 helper for obtaining the clock
media: i2c: ov5648: Use the v4l2 helper for obtaining the clock
media: i2c: ov5695: Use the v4l2 helper for obtaining the clock
media: i2c: ov64a40: Use the v4l2 helper for obtaining the clock
media: i2c: ov6650: Use the v4l2 helper for obtaining the clock
media: i2c: ov7740: Use the v4l2 helper for obtaining the clock
media: i2c: ov8856: Use the v4l2 helper for obtaining the clock
media: i2c: ov8858: Use the v4l2 helper for obtaining the clock
media: i2c: ov8865: Use the v4l2 helper for obtaining the clock
media: i2c: ov9282: Use the v4l2 helper for obtaining the clock
media: i2c: ov9640: Use the v4l2 helper for obtaining the clock
media: i2c: ov9650: Use the v4l2 helper for obtaining the clock
media: i2c: s5c73m3: Use the v4l2 helper for obtaining the clock
media: i2c: s5k5baf: Use the v4l2 helper for obtaining the clock
media: i2c: s5k6a3: Use the v4l2 helper for obtaining the clock
media: i2c: vd55g1: Use the v4l2 helper for obtaining the clock
media: i2c: vd56g3: Use the v4l2 helper for obtaining the clock
media: i2c: vgxy61: Use the v4l2 helper for obtaining the clock
media: i2c: ov2680: Use the v4l2 helper for obtaining the clock
.../driver-api/media/camera-sensor.rst | 24 ++++++---
drivers/media/i2c/ar0521.c | 9 ++--
drivers/media/i2c/et8ek8/et8ek8_driver.c | 9 ++--
drivers/media/i2c/gc05a2.c | 2 +-
drivers/media/i2c/gc08a3.c | 2 +-
drivers/media/i2c/gc2145.c | 2 +-
drivers/media/i2c/hi846.c | 11 ++--
drivers/media/i2c/imx214.c | 2 +-
drivers/media/i2c/imx219.c | 2 +-
drivers/media/i2c/imx283.c | 5 +-
drivers/media/i2c/imx290.c | 2 +-
drivers/media/i2c/imx296.c | 2 +-
drivers/media/i2c/imx334.c | 2 +-
drivers/media/i2c/imx335.c | 9 ++--
drivers/media/i2c/imx412.c | 9 ++--
drivers/media/i2c/imx415.c | 2 +-
drivers/media/i2c/mt9m001.c | 5 +-
drivers/media/i2c/mt9m111.c | 5 +-
drivers/media/i2c/mt9m114.c | 6 +--
drivers/media/i2c/mt9p031.c | 5 +-
drivers/media/i2c/mt9t112.c | 11 ++--
drivers/media/i2c/mt9v032.c | 5 +-
drivers/media/i2c/mt9v111.c | 5 +-
drivers/media/i2c/ov02a10.c | 2 +-
drivers/media/i2c/ov2659.c | 5 +-
drivers/media/i2c/ov2680.c | 29 +----------
drivers/media/i2c/ov2685.c | 10 ++--
drivers/media/i2c/ov5640.c | 9 ++--
drivers/media/i2c/ov5645.c | 2 +-
drivers/media/i2c/ov5647.c | 9 ++--
drivers/media/i2c/ov5648.c | 6 +--
drivers/media/i2c/ov5695.c | 10 ++--
drivers/media/i2c/ov64a40.c | 2 +-
drivers/media/i2c/ov6650.c | 10 ++--
drivers/media/i2c/ov7740.c | 11 ++--
drivers/media/i2c/ov8856.c | 10 ++--
drivers/media/i2c/ov8858.c | 2 +-
drivers/media/i2c/ov8865.c | 36 ++-----------
drivers/media/i2c/ov9282.c | 9 ++--
drivers/media/i2c/ov9640.c | 5 +-
drivers/media/i2c/ov9650.c | 5 +-
drivers/media/i2c/s5c73m3/s5c73m3-core.c | 6 ++-
drivers/media/i2c/s5k5baf.c | 2 +-
drivers/media/i2c/s5k6a3.c | 5 +-
drivers/media/i2c/vd55g1.c | 2 +-
drivers/media/i2c/vd56g3.c | 2 +-
drivers/media/i2c/vgxy61.c | 10 ++--
drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++
include/media/v4l2-common.h | 27 ++++++++++
49 files changed, 223 insertions(+), 191 deletions(-)
--
2.49.0
^ permalink raw reply [flat|nested] 72+ messages in thread
* [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
@ 2025-06-26 13:33 ` Mehdi Djait
2025-06-27 7:12 ` Sakari Ailus
` (2 more replies)
2025-06-26 13:33 ` [PATCH v2 02/48] Documentation: media: camera-sensor: Mention v4l2_devm_sensor_clk_get() for obtaining the clock Mehdi Djait
` (46 subsequent siblings)
47 siblings, 3 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:33 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
This helper behaves the same as devm_clk_get() except where there is
no clock producer like in ACPI-based platforms.
For ACPI-based platforms the function will read the "clock-frequency"
ACPI _DSD property and register a fixed frequency clock with the frequency
indicated in the property.
This function also handles the special ACPI-based system case where:
The clock-frequency _DSD property is present.
A reference to the clock producer is present, where the clock is provided
by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
In this case try to set the clock-frequency value to the provided clock.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
include/media/v4l2-common.h | 27 ++++++++++++++
2 files changed, 79 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index bd160a8c9efe..ac98895b0394 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -34,6 +34,9 @@
* Added Gerd Knorrs v4l1 enhancements (Justin Schoeman)
*/
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/clk-provider.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
@@ -673,3 +676,52 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
return 0;
}
EXPORT_SYMBOL_GPL(v4l2_link_freq_to_bitmap);
+
+struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id)
+{
+ const char *clk_id __free(kfree) = NULL;
+ struct clk_hw *clk_hw;
+ struct clk *clk;
+ bool of_node;
+ u32 rate;
+ int ret;
+
+ clk = devm_clk_get_optional(dev, id);
+ ret = device_property_read_u32(dev, "clock-frequency", &rate);
+ of_node = is_of_node(dev_fwnode(dev));
+
+ if (clk) {
+ if (!ret && !of_node) {
+ ret = clk_set_rate(clk, rate);
+ if (ret) {
+ dev_err(dev, "Failed to set clock rate: %u\n",
+ rate);
+ return ERR_PTR(ret);
+ }
+ }
+ return clk;
+ }
+
+ if (PTR_ERR(clk) == -EPROBE_DEFER)
+ return ERR_PTR(-EPROBE_DEFER);
+
+ if (!IS_ENABLED(CONFIG_COMMON_CLK) || of_node)
+ return ERR_PTR(-ENOENT);
+
+ if (ret)
+ return ERR_PTR(ret == -EINVAL ? -EPROBE_DEFER : ret);
+
+ if (!id) {
+ clk_id = kasprintf(GFP_KERNEL, "clk-%s", dev_name(dev));
+ if (!clk_id)
+ return ERR_PTR(-ENOMEM);
+ id = clk_id;
+ }
+
+ clk_hw = devm_clk_hw_register_fixed_rate(dev, id, NULL, 0, rate);
+ if (IS_ERR(clk_hw))
+ return ERR_CAST(clk_hw);
+
+ return clk_hw->clk;
+}
+EXPORT_SYMBOL_GPL(devm_v4l2_sensor_clk_get);
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 0a43f56578bc..1c79ca4d5c73 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
struct v4l2_device;
struct v4l2_subdev;
struct v4l2_subdev_ops;
+struct clk;
/* I2C Helper functions */
#include <linux/i2c.h>
@@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
unsigned int num_of_driver_link_freqs,
unsigned long *bitmap);
+/**
+ * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
+ * for a camera sensor.
+ *
+ * @dev: device for v4l2 sensor clock "consumer"
+ * @id: clock consumer ID
+ *
+ * This function behaves the same way as devm_clk_get() except where there
+ * is no clock producer like in ACPI-based platforms.
+ *
+ * For ACPI-based platforms, the function will read the "clock-frequency"
+ * ACPI _DSD property and register a fixed-clock with the frequency indicated
+ * in the property.
+ *
+ * This function also handles the special ACPI-based system case where:
+ *
+ * * The clock-frequency _DSD property is present.
+ * * A reference to the clock producer is present, where the clock is provided
+ * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
+ *
+ * In this case try to set the clock-frequency value to the provided clock.
+ *
+ * Returns a pointer to a struct clk on success or an error pointer on failure.
+ */
+struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id);
+
static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf)
{
/*
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 02/48] Documentation: media: camera-sensor: Mention v4l2_devm_sensor_clk_get() for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 01/48] media: v4l2-common: " Mehdi Djait
@ 2025-06-26 13:33 ` Mehdi Djait
2025-07-01 11:03 ` Laurent Pinchart
2025-06-26 13:33 ` [PATCH v2 03/48] media: i2c: ar0521: Use the v4l2 helper " Mehdi Djait
` (45 subsequent siblings)
47 siblings, 1 reply; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:33 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
Add the new v4l2 helper devm_v4l2_sensor_clk_get() to Documentation. the
helper works on both DT- and ACPI-based platforms to retrieve a
reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Co-developed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
.../driver-api/media/camera-sensor.rst | 24 +++++++++++++------
1 file changed, 17 insertions(+), 7 deletions(-)
diff --git a/Documentation/driver-api/media/camera-sensor.rst b/Documentation/driver-api/media/camera-sensor.rst
index c290833165e6..94bd1dae82d5 100644
--- a/Documentation/driver-api/media/camera-sensor.rst
+++ b/Documentation/driver-api/media/camera-sensor.rst
@@ -29,21 +29,31 @@ used in the system. Using another frequency may cause harmful effects
elsewhere. Therefore only the pre-determined frequencies are configurable by the
user.
+The external clock frequency shall be retrieved by obtaining the external clock
+using the ``devm_v4l2_sensor_clk_get()`` helper function, and then getting its
+frequency with ``clk_get_rate()``. Usage of the helper function guarantees
+correct behaviour regardless of whether the sensor is integrated in a DT-based
+or ACPI-based system.
+
ACPI
~~~~
-Read the ``clock-frequency`` _DSD property to denote the frequency. The driver
-can rely on this frequency being used.
+ACPI-based systems typically don't register the sensor external clock with the
+kernel, but specify the external clock frequency in the ``clock-frequency``
+_DSD property. The ``devm_v4l2_sensor_clk_get()`` helper creates and returns a
+fixed clock set at that rate.
Devicetree
~~~~~~~~~~
-The preferred way to achieve this is using ``assigned-clocks``,
-``assigned-clock-parents`` and ``assigned-clock-rates`` properties. See the
-`clock device tree bindings
+Devicetree-based systems declare the sensor external clock in the device tree
+and reference it from the sensor node. The preferred way to select the external
+clock frequency is to use the ``assigned-clocks``, ``assigned-clock-parents``
+and ``assigned-clock-rates`` properties in the sensor node to set the clock
+rate. See the `clock device tree bindings
<https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/clock/clock.yaml>`_
-for more information. The driver then gets the frequency using
-``clk_get_rate()``.
+for more information. The ``devm_v4l2_sensor_clk_get()`` helper retrieves and
+returns that clock.
This approach has the drawback that there's no guarantee that the frequency
hasn't been modified directly or indirectly by another driver, or supported by
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 03/48] media: i2c: ar0521: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 01/48] media: v4l2-common: " Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 02/48] Documentation: media: camera-sensor: Mention v4l2_devm_sensor_clk_get() for obtaining the clock Mehdi Djait
@ 2025-06-26 13:33 ` Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 04/48] media: i2c: et8ek8: " Mehdi Djait
` (44 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:33 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper devm_v4l2_sensor_clk_get()
that works on both DT- and ACPI-based platforms to retrieve a reference to
the clock producer from firmware.
Acked-By: Krzysztof Hałasa <khalasa@piap.pl>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ar0521.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/ar0521.c b/drivers/media/i2c/ar0521.c
index 24873149096c..939bf590d4b2 100644
--- a/drivers/media/i2c/ar0521.c
+++ b/drivers/media/i2c/ar0521.c
@@ -1077,11 +1077,10 @@ static int ar0521_probe(struct i2c_client *client)
}
/* Get master clock (extclk) */
- sensor->extclk = devm_clk_get(dev, "extclk");
- if (IS_ERR(sensor->extclk)) {
- dev_err(dev, "failed to get extclk\n");
- return PTR_ERR(sensor->extclk);
- }
+ sensor->extclk = devm_v4l2_sensor_clk_get(dev, "extclk");
+ if (IS_ERR(sensor->extclk))
+ return dev_err_probe(dev, PTR_ERR(sensor->extclk),
+ "failed to get extclk\n");
sensor->extclk_freq = clk_get_rate(sensor->extclk);
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 04/48] media: i2c: et8ek8: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (2 preceding siblings ...)
2025-06-26 13:33 ` [PATCH v2 03/48] media: i2c: ar0521: Use the v4l2 helper " Mehdi Djait
@ 2025-06-26 13:33 ` Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 05/48] media: i2c: gc05a2: " Mehdi Djait
` (43 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:33 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/et8ek8/et8ek8_driver.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/et8ek8/et8ek8_driver.c b/drivers/media/i2c/et8ek8/et8ek8_driver.c
index 7519863d77b1..4787b2c430f8 100644
--- a/drivers/media/i2c/et8ek8/et8ek8_driver.c
+++ b/drivers/media/i2c/et8ek8/et8ek8_driver.c
@@ -1433,11 +1433,10 @@ static int et8ek8_probe(struct i2c_client *client)
return PTR_ERR(sensor->vana);
}
- sensor->ext_clk = devm_clk_get(dev, NULL);
- if (IS_ERR(sensor->ext_clk)) {
- dev_err(&client->dev, "could not get clock\n");
- return PTR_ERR(sensor->ext_clk);
- }
+ sensor->ext_clk = devm_v4l2_sensor_clk_get(dev, NULL);
+ if (IS_ERR(sensor->ext_clk))
+ return dev_err_probe(&client->dev, PTR_ERR(sensor->ext_clk),
+ "could not get clock\n");
ret = of_property_read_u32(dev->of_node, "clock-frequency",
&sensor->xclk_freq);
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 05/48] media: i2c: gc05a2: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (3 preceding siblings ...)
2025-06-26 13:33 ` [PATCH v2 04/48] media: i2c: et8ek8: " Mehdi Djait
@ 2025-06-26 13:33 ` Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 06/48] media: i2c: gc08a3: " Mehdi Djait
` (42 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:33 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/gc05a2.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/gc05a2.c b/drivers/media/i2c/gc05a2.c
index 3f7f3d5abeeb..4dadd25e6c90 100644
--- a/drivers/media/i2c/gc05a2.c
+++ b/drivers/media/i2c/gc05a2.c
@@ -1235,7 +1235,7 @@ static int gc05a2_probe(struct i2c_client *client)
return dev_err_probe(dev, PTR_ERR(gc05a2->regmap),
"failed to init CCI\n");
- gc05a2->xclk = devm_clk_get(dev, NULL);
+ gc05a2->xclk = devm_v4l2_sensor_clk_get(dev, NULL);
if (IS_ERR(gc05a2->xclk))
return dev_err_probe(dev, PTR_ERR(gc05a2->xclk),
"failed to get xclk\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 06/48] media: i2c: gc08a3: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (4 preceding siblings ...)
2025-06-26 13:33 ` [PATCH v2 05/48] media: i2c: gc05a2: " Mehdi Djait
@ 2025-06-26 13:33 ` Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 07/48] media: i2c: gc2145: " Mehdi Djait
` (41 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:33 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/gc08a3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/gc08a3.c b/drivers/media/i2c/gc08a3.c
index 938709a677b6..5d38dfa9878e 100644
--- a/drivers/media/i2c/gc08a3.c
+++ b/drivers/media/i2c/gc08a3.c
@@ -1199,7 +1199,7 @@ static int gc08a3_probe(struct i2c_client *client)
return dev_err_probe(dev, PTR_ERR(gc08a3->regmap),
"failed to init CCI\n");
- gc08a3->xclk = devm_clk_get(dev, NULL);
+ gc08a3->xclk = devm_v4l2_sensor_clk_get(dev, NULL);
if (IS_ERR(gc08a3->xclk))
return dev_err_probe(dev, PTR_ERR(gc08a3->xclk),
"failed to get xclk\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 07/48] media: i2c: gc2145: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (5 preceding siblings ...)
2025-06-26 13:33 ` [PATCH v2 06/48] media: i2c: gc08a3: " Mehdi Djait
@ 2025-06-26 13:33 ` Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 08/48] media: i2c: hi846: " Mehdi Djait
` (40 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:33 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/gc2145.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/gc2145.c b/drivers/media/i2c/gc2145.c
index ba02161d46e7..52d9387559c9 100644
--- a/drivers/media/i2c/gc2145.c
+++ b/drivers/media/i2c/gc2145.c
@@ -1334,7 +1334,7 @@ static int gc2145_probe(struct i2c_client *client)
return -EINVAL;
/* Get system clock (xclk) */
- gc2145->xclk = devm_clk_get(dev, NULL);
+ gc2145->xclk = devm_v4l2_sensor_clk_get(dev, NULL);
if (IS_ERR(gc2145->xclk))
return dev_err_probe(dev, PTR_ERR(gc2145->xclk),
"failed to get xclk\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 08/48] media: i2c: hi846: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (6 preceding siblings ...)
2025-06-26 13:33 ` [PATCH v2 07/48] media: i2c: gc2145: " Mehdi Djait
@ 2025-06-26 13:33 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 09/48] media: i2c: imx214: " Mehdi Djait
` (39 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:33 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/hi846.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/media/i2c/hi846.c b/drivers/media/i2c/hi846.c
index 172772decd3d..a3f77b8434ca 100644
--- a/drivers/media/i2c/hi846.c
+++ b/drivers/media/i2c/hi846.c
@@ -2052,12 +2052,11 @@ static int hi846_probe(struct i2c_client *client)
return ret;
}
- hi846->clock = devm_clk_get(&client->dev, NULL);
- if (IS_ERR(hi846->clock)) {
- dev_err(&client->dev, "failed to get clock: %pe\n",
- hi846->clock);
- return PTR_ERR(hi846->clock);
- }
+ hi846->clock = devm_v4l2_sensor_clk_get(&client->dev, NULL);
+ if (IS_ERR(hi846->clock))
+ return dev_err_probe(&client->dev, PTR_ERR(hi846->clock),
+ "failed to get clock: %pe\n",
+ hi846->clock);
mclk_freq = clk_get_rate(hi846->clock);
if (mclk_freq != 25000000)
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 09/48] media: i2c: imx214: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (7 preceding siblings ...)
2025-06-26 13:33 ` [PATCH v2 08/48] media: i2c: hi846: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 10/48] media: i2c: imx219: " Mehdi Djait
` (38 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/imx214.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/imx214.c b/drivers/media/i2c/imx214.c
index dd7bc45523d8..73e7bc2f85c0 100644
--- a/drivers/media/i2c/imx214.c
+++ b/drivers/media/i2c/imx214.c
@@ -1271,7 +1271,7 @@ static int imx214_probe(struct i2c_client *client)
imx214->dev = dev;
- imx214->xclk = devm_clk_get(dev, NULL);
+ imx214->xclk = devm_v4l2_sensor_clk_get(dev, NULL);
if (IS_ERR(imx214->xclk))
return dev_err_probe(dev, PTR_ERR(imx214->xclk),
"failed to get xclk\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 10/48] media: i2c: imx219: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (8 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 09/48] media: i2c: imx214: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 11/48] media: i2c: imx283: " Mehdi Djait
` (37 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/imx219.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/imx219.c b/drivers/media/i2c/imx219.c
index 3b4f68543342..bb7808515178 100644
--- a/drivers/media/i2c/imx219.c
+++ b/drivers/media/i2c/imx219.c
@@ -1188,7 +1188,7 @@ static int imx219_probe(struct i2c_client *client)
"failed to initialize CCI\n");
/* Get system clock (xclk) */
- imx219->xclk = devm_clk_get(dev, NULL);
+ imx219->xclk = devm_v4l2_sensor_clk_get(dev, NULL);
if (IS_ERR(imx219->xclk))
return dev_err_probe(dev, PTR_ERR(imx219->xclk),
"failed to get xclk\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 11/48] media: i2c: imx283: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (9 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 10/48] media: i2c: imx219: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 12/48] media: i2c: imx290: " Mehdi Djait
` (36 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/imx283.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/imx283.c b/drivers/media/i2c/imx283.c
index da618c8cbadc..8bff5bf4df12 100644
--- a/drivers/media/i2c/imx283.c
+++ b/drivers/media/i2c/imx283.c
@@ -1462,11 +1462,10 @@ static int imx283_probe(struct i2c_client *client)
}
/* Get system clock (xclk) */
- imx283->xclk = devm_clk_get(imx283->dev, NULL);
- if (IS_ERR(imx283->xclk)) {
+ imx283->xclk = devm_v4l2_sensor_clk_get(imx283->dev, NULL);
+ if (IS_ERR(imx283->xclk))
return dev_err_probe(imx283->dev, PTR_ERR(imx283->xclk),
"failed to get xclk\n");
- }
xclk_freq = clk_get_rate(imx283->xclk);
for (i = 0; i < ARRAY_SIZE(imx283_frequencies); i++) {
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 12/48] media: i2c: imx290: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (10 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 11/48] media: i2c: imx283: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 13/48] media: i2c: imx296: " Mehdi Djait
` (35 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/imx290.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/imx290.c b/drivers/media/i2c/imx290.c
index fbf7eba3d71d..759df6eb8545 100644
--- a/drivers/media/i2c/imx290.c
+++ b/drivers/media/i2c/imx290.c
@@ -1600,7 +1600,7 @@ static int imx290_probe(struct i2c_client *client)
return ret;
/* Acquire resources. */
- imx290->xclk = devm_clk_get(dev, "xclk");
+ imx290->xclk = devm_v4l2_sensor_clk_get(dev, "xclk");
if (IS_ERR(imx290->xclk))
return dev_err_probe(dev, PTR_ERR(imx290->xclk),
"Could not get xclk\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 13/48] media: i2c: imx296: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (11 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 12/48] media: i2c: imx290: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 14/48] media: i2c: imx334: " Mehdi Djait
` (34 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/imx296.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/imx296.c b/drivers/media/i2c/imx296.c
index f3bec16b527c..3795b75a4397 100644
--- a/drivers/media/i2c/imx296.c
+++ b/drivers/media/i2c/imx296.c
@@ -1044,7 +1044,7 @@ static int imx296_probe(struct i2c_client *client)
return dev_err_probe(sensor->dev, PTR_ERR(sensor->reset),
"failed to get reset GPIO\n");
- sensor->clk = devm_clk_get(sensor->dev, "inck");
+ sensor->clk = devm_v4l2_sensor_clk_get(sensor->dev, "inck");
if (IS_ERR(sensor->clk))
return dev_err_probe(sensor->dev, PTR_ERR(sensor->clk),
"failed to get clock\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 14/48] media: i2c: imx334: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (12 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 13/48] media: i2c: imx296: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 15/48] media: i2c: imx335: " Mehdi Djait
` (33 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/imx334.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/imx334.c b/drivers/media/i2c/imx334.c
index 846b9928d4e8..7a9b14d102c9 100644
--- a/drivers/media/i2c/imx334.c
+++ b/drivers/media/i2c/imx334.c
@@ -997,7 +997,7 @@ static int imx334_parse_hw_config(struct imx334 *imx334)
"failed to get reset gpio\n");
/* Get sensor input clock */
- imx334->inclk = devm_clk_get(imx334->dev, NULL);
+ imx334->inclk = devm_v4l2_sensor_clk_get(imx334->dev, NULL);
if (IS_ERR(imx334->inclk))
return dev_err_probe(imx334->dev, PTR_ERR(imx334->inclk),
"could not get inclk\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 15/48] media: i2c: imx335: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (13 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 14/48] media: i2c: imx334: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 16/48] media: i2c: imx412: " Mehdi Djait
` (32 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/imx335.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/imx335.c b/drivers/media/i2c/imx335.c
index 9b4db4cd4929..c043df2f15fb 100644
--- a/drivers/media/i2c/imx335.c
+++ b/drivers/media/i2c/imx335.c
@@ -1026,11 +1026,10 @@ static int imx335_parse_hw_config(struct imx335 *imx335)
}
/* Get sensor input clock */
- imx335->inclk = devm_clk_get(imx335->dev, NULL);
- if (IS_ERR(imx335->inclk)) {
- dev_err(imx335->dev, "could not get inclk\n");
- return PTR_ERR(imx335->inclk);
- }
+ imx335->inclk = devm_v4l2_sensor_clk_get(imx335->dev, NULL);
+ if (IS_ERR(imx335->inclk))
+ return dev_err_probe(imx335->dev, PTR_ERR(imx335->inclk),
+ "could not get inclk\n");
rate = clk_get_rate(imx335->inclk);
if (rate != IMX335_INCLK_RATE) {
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 16/48] media: i2c: imx412: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (14 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 15/48] media: i2c: imx335: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 17/48] media: i2c: imx415: " Mehdi Djait
` (31 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/imx412.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/imx412.c b/drivers/media/i2c/imx412.c
index c74097a59c42..7bbd639a9ddf 100644
--- a/drivers/media/i2c/imx412.c
+++ b/drivers/media/i2c/imx412.c
@@ -933,11 +933,10 @@ static int imx412_parse_hw_config(struct imx412 *imx412)
}
/* Get sensor input clock */
- imx412->inclk = devm_clk_get(imx412->dev, NULL);
- if (IS_ERR(imx412->inclk)) {
- dev_err(imx412->dev, "could not get inclk\n");
- return PTR_ERR(imx412->inclk);
- }
+ imx412->inclk = devm_v4l2_sensor_clk_get(imx412->dev, NULL);
+ if (IS_ERR(imx412->inclk))
+ return dev_err_probe(imx412->dev, PTR_ERR(imx412->inclk),
+ "could not get inclk\n");
rate = clk_get_rate(imx412->inclk);
if (rate != IMX412_INCLK_RATE) {
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 17/48] media: i2c: imx415: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (15 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 16/48] media: i2c: imx412: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:41 ` Michael Riesch
2025-06-26 13:34 ` [PATCH v2 18/48] media: i2c: mt9m001: " Mehdi Djait
` (30 subsequent siblings)
47 siblings, 1 reply; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/imx415.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/imx415.c b/drivers/media/i2c/imx415.c
index 9f37779bd611..2e206a671ed3 100644
--- a/drivers/media/i2c/imx415.c
+++ b/drivers/media/i2c/imx415.c
@@ -1251,7 +1251,7 @@ static int imx415_parse_hw_config(struct imx415 *sensor)
return dev_err_probe(sensor->dev, PTR_ERR(sensor->reset),
"failed to get reset GPIO\n");
- sensor->clk = devm_clk_get(sensor->dev, "inck");
+ sensor->clk = devm_v4l2_sensor_clk_get(sensor->dev, NULL);
if (IS_ERR(sensor->clk))
return dev_err_probe(sensor->dev, PTR_ERR(sensor->clk),
"failed to get clock\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 18/48] media: i2c: mt9m001: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (16 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 17/48] media: i2c: imx415: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 19/48] media: i2c: mt9m111: " Mehdi Djait
` (29 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/mt9m001.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/mt9m001.c b/drivers/media/i2c/mt9m001.c
index 12d3e86bdc0f..7a6114d18dfc 100644
--- a/drivers/media/i2c/mt9m001.c
+++ b/drivers/media/i2c/mt9m001.c
@@ -743,9 +743,10 @@ static int mt9m001_probe(struct i2c_client *client)
if (!mt9m001)
return -ENOMEM;
- mt9m001->clk = devm_clk_get(&client->dev, NULL);
+ mt9m001->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
if (IS_ERR(mt9m001->clk))
- return PTR_ERR(mt9m001->clk);
+ return dev_err_probe(&client->dev, PTR_ERR(mt9m001->clk),
+ "failed to get the clock\n");
mt9m001->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby",
GPIOD_OUT_LOW);
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 19/48] media: i2c: mt9m111: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (17 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 18/48] media: i2c: mt9m001: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 20/48] media: i2c: mt9m114: " Mehdi Djait
` (28 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/mt9m111.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/mt9m111.c b/drivers/media/i2c/mt9m111.c
index 9aa5dcda3805..05dcf37c6f01 100644
--- a/drivers/media/i2c/mt9m111.c
+++ b/drivers/media/i2c/mt9m111.c
@@ -1279,9 +1279,10 @@ static int mt9m111_probe(struct i2c_client *client)
return ret;
}
- mt9m111->clk = devm_clk_get(&client->dev, "mclk");
+ mt9m111->clk = devm_v4l2_sensor_clk_get(&client->dev, "mclk");
if (IS_ERR(mt9m111->clk))
- return PTR_ERR(mt9m111->clk);
+ return dev_err_probe(&client->dev, PTR_ERR(mt9m111->clk),
+ "failed to get mclk\n");
mt9m111->regulator = devm_regulator_get(&client->dev, "vdd");
if (IS_ERR(mt9m111->regulator)) {
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 20/48] media: i2c: mt9m114: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (18 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 19/48] media: i2c: mt9m111: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 21/48] media: i2c: mt9p031: " Mehdi Djait
` (27 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/mt9m114.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/mt9m114.c b/drivers/media/i2c/mt9m114.c
index 5f0b0ad8f885..f12d330c0a78 100644
--- a/drivers/media/i2c/mt9m114.c
+++ b/drivers/media/i2c/mt9m114.c
@@ -2360,10 +2360,10 @@ static int mt9m114_probe(struct i2c_client *client)
return ret;
/* Acquire clocks, GPIOs and regulators. */
- sensor->clk = devm_clk_get(dev, NULL);
+ sensor->clk = devm_v4l2_sensor_clk_get(dev, NULL);
if (IS_ERR(sensor->clk)) {
- ret = PTR_ERR(sensor->clk);
- dev_err_probe(dev, ret, "Failed to get clock\n");
+ ret = dev_err_probe(dev, PTR_ERR(sensor->clk),
+ "Failed to get clock\n");
goto error_ep_free;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 21/48] media: i2c: mt9p031: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (19 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 20/48] media: i2c: mt9m114: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 22/48] media: i2c: mt9t112: " Mehdi Djait
` (26 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/mt9p031.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/mt9p031.c b/drivers/media/i2c/mt9p031.c
index 4ef5fb06131d..4df8f2be15f3 100644
--- a/drivers/media/i2c/mt9p031.c
+++ b/drivers/media/i2c/mt9p031.c
@@ -233,9 +233,10 @@ static int mt9p031_clk_setup(struct mt9p031 *mt9p031)
unsigned long ext_freq;
int ret;
- mt9p031->clk = devm_clk_get(&client->dev, NULL);
+ mt9p031->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
if (IS_ERR(mt9p031->clk))
- return PTR_ERR(mt9p031->clk);
+ return dev_err_probe(&client->dev, PTR_ERR(mt9p031->clk),
+ "failed to get the clock\n");
ret = clk_set_rate(mt9p031->clk, mt9p031->ext_freq);
if (ret < 0)
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 22/48] media: i2c: mt9t112: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (20 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 21/48] media: i2c: mt9p031: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 23/48] media: i2c: mt9v032: " Mehdi Djait
` (25 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/mt9t112.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/media/i2c/mt9t112.c b/drivers/media/i2c/mt9t112.c
index 878dff9b7577..2d2c840fc002 100644
--- a/drivers/media/i2c/mt9t112.c
+++ b/drivers/media/i2c/mt9t112.c
@@ -1078,13 +1078,12 @@ static int mt9t112_probe(struct i2c_client *client)
v4l2_i2c_subdev_init(&priv->subdev, client, &mt9t112_subdev_ops);
- priv->clk = devm_clk_get(&client->dev, "extclk");
- if (PTR_ERR(priv->clk) == -ENOENT) {
+ priv->clk = devm_v4l2_sensor_clk_get(&client->dev, "extclk");
+ if (PTR_ERR(priv->clk) == -ENOENT)
priv->clk = NULL;
- } else if (IS_ERR(priv->clk)) {
- dev_err(&client->dev, "Unable to get clock \"extclk\"\n");
- return PTR_ERR(priv->clk);
- }
+ else if (IS_ERR(priv->clk))
+ return dev_err_probe(&client->dev, PTR_ERR(priv->clk),
+ "Unable to get clock \"extclk\"\n");
priv->standby_gpio = devm_gpiod_get_optional(&client->dev, "standby",
GPIOD_OUT_HIGH);
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 23/48] media: i2c: mt9v032: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (21 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 22/48] media: i2c: mt9t112: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 24/48] media: i2c: mt9v111: " Mehdi Djait
` (24 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/mt9v032.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c
index 302120ff125e..9f4b4cb9853e 100644
--- a/drivers/media/i2c/mt9v032.c
+++ b/drivers/media/i2c/mt9v032.c
@@ -1058,9 +1058,10 @@ static int mt9v032_probe(struct i2c_client *client)
if (IS_ERR(mt9v032->regmap))
return PTR_ERR(mt9v032->regmap);
- mt9v032->clk = devm_clk_get(&client->dev, NULL);
+ mt9v032->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
if (IS_ERR(mt9v032->clk))
- return PTR_ERR(mt9v032->clk);
+ return dev_err_probe(&client->dev, PTR_ERR(mt9v032->clk),
+ "failed to get the clock\n");
mt9v032->reset_gpio = devm_gpiod_get_optional(&client->dev, "reset",
GPIOD_OUT_HIGH);
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 24/48] media: i2c: mt9v111: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (22 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 23/48] media: i2c: mt9v032: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 25/48] media: i2c: ov02a10: " Mehdi Djait
` (23 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/mt9v111.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/mt9v111.c b/drivers/media/i2c/mt9v111.c
index 723fe138e7bc..6aa80b504168 100644
--- a/drivers/media/i2c/mt9v111.c
+++ b/drivers/media/i2c/mt9v111.c
@@ -1129,9 +1129,10 @@ static int mt9v111_probe(struct i2c_client *client)
mt9v111->dev = &client->dev;
mt9v111->client = client;
- mt9v111->clk = devm_clk_get(&client->dev, NULL);
+ mt9v111->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
if (IS_ERR(mt9v111->clk))
- return PTR_ERR(mt9v111->clk);
+ return dev_err_probe(&client->dev, PTR_ERR(mt9v111->clk),
+ "failed to get the clock\n");
mt9v111->sysclk = clk_get_rate(mt9v111->clk);
if (mt9v111->sysclk > MT9V111_MAX_CLKIN)
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 25/48] media: i2c: ov02a10: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (23 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 24/48] media: i2c: mt9v111: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 26/48] media: i2c: ov2659: " Mehdi Djait
` (22 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov02a10.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov02a10.c b/drivers/media/i2c/ov02a10.c
index 6c30e1a0d814..74fc0687c849 100644
--- a/drivers/media/i2c/ov02a10.c
+++ b/drivers/media/i2c/ov02a10.c
@@ -885,7 +885,7 @@ static int ov02a10_probe(struct i2c_client *client)
ov02a10->fmt.code = MEDIA_BUS_FMT_SRGGB10_1X10;
}
- ov02a10->eclk = devm_clk_get(dev, "eclk");
+ ov02a10->eclk = devm_v4l2_sensor_clk_get(dev, "eclk");
if (IS_ERR(ov02a10->eclk))
return dev_err_probe(dev, PTR_ERR(ov02a10->eclk),
"failed to get eclk\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 26/48] media: i2c: ov2659: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (24 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 25/48] media: i2c: ov02a10: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 27/48] media: i2c: ov2685: " Mehdi Djait
` (21 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov2659.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/ov2659.c b/drivers/media/i2c/ov2659.c
index 06b7896c3eaf..79d7f760f6dc 100644
--- a/drivers/media/i2c/ov2659.c
+++ b/drivers/media/i2c/ov2659.c
@@ -1437,9 +1437,10 @@ static int ov2659_probe(struct i2c_client *client)
ov2659->pdata = pdata;
ov2659->client = client;
- ov2659->clk = devm_clk_get(&client->dev, "xvclk");
+ ov2659->clk = devm_v4l2_sensor_clk_get(&client->dev, "xvclk");
if (IS_ERR(ov2659->clk))
- return PTR_ERR(ov2659->clk);
+ return dev_err_probe(&client->dev, PTR_ERR(ov2659->clk),
+ "failed to get xvclk\n");
ov2659->xvclk_frequency = clk_get_rate(ov2659->clk);
if (ov2659->xvclk_frequency < 6000000 ||
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 27/48] media: i2c: ov2685: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (25 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 26/48] media: i2c: ov2659: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 28/48] media: i2c: ov5640: " Mehdi Djait
` (20 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov2685.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/ov2685.c b/drivers/media/i2c/ov2685.c
index 9b8481b8dcd4..c435799514b9 100644
--- a/drivers/media/i2c/ov2685.c
+++ b/drivers/media/i2c/ov2685.c
@@ -783,11 +783,11 @@ static int ov2685_probe(struct i2c_client *client)
ov2685->client = client;
ov2685->cur_mode = &supported_modes[0];
- ov2685->xvclk = devm_clk_get(dev, "xvclk");
- if (IS_ERR(ov2685->xvclk)) {
- dev_err(dev, "Failed to get xvclk\n");
- return -EINVAL;
- }
+ ov2685->xvclk = devm_v4l2_sensor_clk_get(dev, "xvclk");
+ if (IS_ERR(ov2685->xvclk))
+ return dev_err_probe(dev, PTR_ERR(ov2685->xvclk),
+ "Failed to get xvclk\n");
+
ret = clk_set_rate(ov2685->xvclk, OV2685_XVCLK_FREQ);
if (ret < 0) {
dev_err(dev, "Failed to set xvclk rate (24MHz)\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 28/48] media: i2c: ov5640: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (26 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 27/48] media: i2c: ov2685: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 29/48] media: i2c: ov5645: " Mehdi Djait
` (19 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov5640.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 0dae0438aa80..08ca366a22d7 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -3898,11 +3898,10 @@ static int ov5640_probe(struct i2c_client *client)
ov5640_dvp_default_fmt;
/* get system clock (xclk) */
- sensor->xclk = devm_clk_get(dev, "xclk");
- if (IS_ERR(sensor->xclk)) {
- dev_err(dev, "failed to get xclk\n");
- return PTR_ERR(sensor->xclk);
- }
+ sensor->xclk = devm_v4l2_sensor_clk_get(dev, "xclk");
+ if (IS_ERR(sensor->xclk))
+ return dev_err_probe(dev, PTR_ERR(sensor->xclk),
+ "failed to get xclk\n");
sensor->xclk_freq = clk_get_rate(sensor->xclk);
if (sensor->xclk_freq < OV5640_XCLK_MIN ||
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 29/48] media: i2c: ov5645: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (27 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 28/48] media: i2c: ov5640: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 30/48] media: i2c: ov5647: " Mehdi Djait
` (18 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov5645.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov5645.c b/drivers/media/i2c/ov5645.c
index 004d0ee5c3f5..70b4cdb1b9af 100644
--- a/drivers/media/i2c/ov5645.c
+++ b/drivers/media/i2c/ov5645.c
@@ -1044,7 +1044,7 @@ static int ov5645_probe(struct i2c_client *client)
"invalid bus type, must be CSI2\n");
/* get system clock (xclk) */
- ov5645->xclk = devm_clk_get(dev, NULL);
+ ov5645->xclk = devm_v4l2_sensor_clk_get(dev, NULL);
if (IS_ERR(ov5645->xclk))
return dev_err_probe(dev, PTR_ERR(ov5645->xclk),
"could not get xclk");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 30/48] media: i2c: ov5647: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (28 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 29/48] media: i2c: ov5645: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 31/48] media: i2c: ov5648: " Mehdi Djait
` (17 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov5647.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/ov5647.c b/drivers/media/i2c/ov5647.c
index a727beb9d57e..e193fef4fced 100644
--- a/drivers/media/i2c/ov5647.c
+++ b/drivers/media/i2c/ov5647.c
@@ -1398,11 +1398,10 @@ static int ov5647_probe(struct i2c_client *client)
}
}
- sensor->xclk = devm_clk_get(dev, NULL);
- if (IS_ERR(sensor->xclk)) {
- dev_err(dev, "could not get xclk");
- return PTR_ERR(sensor->xclk);
- }
+ sensor->xclk = devm_v4l2_sensor_clk_get(dev, NULL);
+ if (IS_ERR(sensor->xclk))
+ return dev_err_probe(dev, PTR_ERR(sensor->xclk),
+ "could not get xclk\n");
xclk_freq = clk_get_rate(sensor->xclk);
if (xclk_freq != 25000000) {
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 31/48] media: i2c: ov5648: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (29 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 30/48] media: i2c: ov5647: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 32/48] media: i2c: ov5695: " Mehdi Djait
` (16 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov5648.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/ov5648.c b/drivers/media/i2c/ov5648.c
index 4b86d2631bd1..8a3190bf73da 100644
--- a/drivers/media/i2c/ov5648.c
+++ b/drivers/media/i2c/ov5648.c
@@ -2521,10 +2521,10 @@ static int ov5648_probe(struct i2c_client *client)
/* External Clock */
- sensor->xvclk = devm_clk_get(dev, NULL);
+ sensor->xvclk = devm_v4l2_sensor_clk_get(dev, NULL);
if (IS_ERR(sensor->xvclk)) {
- dev_err(dev, "failed to get external clock\n");
- ret = PTR_ERR(sensor->xvclk);
+ ret = dev_err_probe(dev, PTR_ERR(sensor->xvclk),
+ "failed to get external clock\n");
goto error_endpoint;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 32/48] media: i2c: ov5695: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (30 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 31/48] media: i2c: ov5648: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 33/48] media: i2c: ov64a40: " Mehdi Djait
` (15 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov5695.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/ov5695.c b/drivers/media/i2c/ov5695.c
index 663eccdfea6a..fe7ad7b2c05a 100644
--- a/drivers/media/i2c/ov5695.c
+++ b/drivers/media/i2c/ov5695.c
@@ -1264,11 +1264,11 @@ static int ov5695_probe(struct i2c_client *client)
ov5695->client = client;
ov5695->cur_mode = &supported_modes[0];
- ov5695->xvclk = devm_clk_get(dev, "xvclk");
- if (IS_ERR(ov5695->xvclk)) {
- dev_err(dev, "Failed to get xvclk\n");
- return -EINVAL;
- }
+ ov5695->xvclk = devm_v4l2_sensor_clk_get(dev, "xvclk");
+ if (IS_ERR(ov5695->xvclk))
+ return dev_err_probe(dev, PTR_ERR(ov5695->xvclk),
+ "Failed to get xvclk\n");
+
ret = clk_set_rate(ov5695->xvclk, OV5695_XVCLK_FREQ);
if (ret < 0) {
dev_err(dev, "Failed to set xvclk rate (24MHz)\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 33/48] media: i2c: ov64a40: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (31 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 32/48] media: i2c: ov5695: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 34/48] media: i2c: ov6650: " Mehdi Djait
` (14 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov64a40.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov64a40.c b/drivers/media/i2c/ov64a40.c
index a5da4fe47e0b..d7a13e855a41 100644
--- a/drivers/media/i2c/ov64a40.c
+++ b/drivers/media/i2c/ov64a40.c
@@ -3550,7 +3550,7 @@ static int ov64a40_probe(struct i2c_client *client)
return PTR_ERR(ov64a40->cci);
}
- ov64a40->xclk = devm_clk_get(&client->dev, NULL);
+ ov64a40->xclk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
if (IS_ERR(ov64a40->xclk))
return dev_err_probe(&client->dev, PTR_ERR(ov64a40->xclk),
"Failed to get clock\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 34/48] media: i2c: ov6650: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (32 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 33/48] media: i2c: ov64a40: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 35/48] media: i2c: ov7740: " Mehdi Djait
` (13 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov6650.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
index 9c7627161142..3e37a6436aeb 100644
--- a/drivers/media/i2c/ov6650.c
+++ b/drivers/media/i2c/ov6650.c
@@ -898,12 +898,10 @@ static int ov6650_video_probe(struct v4l2_subdev *sd)
u8 pidh, pidl, midh, midl;
int i, ret = 0;
- priv->clk = devm_clk_get(&client->dev, NULL);
- if (IS_ERR(priv->clk)) {
- ret = PTR_ERR(priv->clk);
- dev_err(&client->dev, "clk request err: %d\n", ret);
- return ret;
- }
+ priv->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
+ if (IS_ERR(priv->clk))
+ return dev_err_probe(&client->dev, PTR_ERR(priv->clk),
+ "clk request err\n");
rate = clk_get_rate(priv->clk);
for (i = 0; rate && i < ARRAY_SIZE(ov6650_xclk); i++) {
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 35/48] media: i2c: ov7740: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (33 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 34/48] media: i2c: ov6650: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 36/48] media: i2c: ov8856: " Mehdi Djait
` (12 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov7740.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/drivers/media/i2c/ov7740.c b/drivers/media/i2c/ov7740.c
index 1f1c0de8e510..632fb80469be 100644
--- a/drivers/media/i2c/ov7740.c
+++ b/drivers/media/i2c/ov7740.c
@@ -1036,13 +1036,10 @@ static int ov7740_probe(struct i2c_client *client)
if (!ov7740)
return -ENOMEM;
- ov7740->xvclk = devm_clk_get(&client->dev, "xvclk");
- if (IS_ERR(ov7740->xvclk)) {
- ret = PTR_ERR(ov7740->xvclk);
- dev_err(&client->dev,
- "OV7740: fail to get xvclk: %d\n", ret);
- return ret;
- }
+ ov7740->xvclk = devm_v4l2_sensor_clk_get(&client->dev, "xvclk");
+ if (IS_ERR(ov7740->xvclk))
+ return dev_err_probe(&client->dev, PTR_ERR(ov7740->xvclk),
+ "OV7740: fail to get xvclk\n");
ret = ov7740_probe_dt(client, ov7740);
if (ret)
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 36/48] media: i2c: ov8856: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (34 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 35/48] media: i2c: ov7740: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 37/48] media: i2c: ov8858: " Mehdi Djait
` (11 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov8856.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/media/i2c/ov8856.c b/drivers/media/i2c/ov8856.c
index 4b6874d2a104..b85051f053ff 100644
--- a/drivers/media/i2c/ov8856.c
+++ b/drivers/media/i2c/ov8856.c
@@ -2274,12 +2274,10 @@ static int ov8856_get_hwcfg(struct ov8856 *ov8856, struct device *dev)
return ret;
if (!is_acpi_node(fwnode)) {
- ov8856->xvclk = devm_clk_get(dev, "xvclk");
- if (IS_ERR(ov8856->xvclk)) {
- dev_err_probe(dev, PTR_ERR(ov8856->xvclk),
- "could not get xvclk clock\n");
- return PTR_ERR(ov8856->xvclk);
- }
+ ov8856->xvclk = devm_v4l2_sensor_clk_get(dev, "xvclk");
+ if (IS_ERR(ov8856->xvclk))
+ return dev_err_probe(dev, PTR_ERR(ov8856->xvclk),
+ "could not get xvclk clock\n");
clk_set_rate(ov8856->xvclk, xvclk_rate);
xvclk_rate = clk_get_rate(ov8856->xvclk);
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 37/48] media: i2c: ov8858: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (35 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 36/48] media: i2c: ov8856: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 38/48] media: i2c: ov8865: " Mehdi Djait
` (10 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov8858.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/ov8858.c b/drivers/media/i2c/ov8858.c
index 95f9ae794846..c1c6bea8a68b 100644
--- a/drivers/media/i2c/ov8858.c
+++ b/drivers/media/i2c/ov8858.c
@@ -1877,7 +1877,7 @@ static int ov8858_probe(struct i2c_client *client)
if (!ov8858)
return -ENOMEM;
- ov8858->xvclk = devm_clk_get(dev, "xvclk");
+ ov8858->xvclk = devm_v4l2_sensor_clk_get(dev, "xvclk");
if (IS_ERR(ov8858->xvclk))
return dev_err_probe(dev, PTR_ERR(ov8858->xvclk),
"Failed to get xvclk\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 38/48] media: i2c: ov8865: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (36 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 37/48] media: i2c: ov8858: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 39/48] media: i2c: ov9282: " Mehdi Djait
` (9 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov8865.c | 36 +++++-------------------------------
1 file changed, 5 insertions(+), 31 deletions(-)
diff --git a/drivers/media/i2c/ov8865.c b/drivers/media/i2c/ov8865.c
index 95ffe7536aa6..a5ea26337a76 100644
--- a/drivers/media/i2c/ov8865.c
+++ b/drivers/media/i2c/ov8865.c
@@ -2956,7 +2956,6 @@ static int ov8865_probe(struct i2c_client *client)
struct ov8865_sensor *sensor;
struct v4l2_subdev *subdev;
struct media_pad *pad;
- unsigned int rate = 0;
unsigned int i;
int ret;
@@ -3019,39 +3018,14 @@ static int ov8865_probe(struct i2c_client *client)
/* External Clock */
- sensor->extclk = devm_clk_get(dev, NULL);
- if (PTR_ERR(sensor->extclk) == -ENOENT) {
- dev_info(dev, "no external clock found, continuing...\n");
- sensor->extclk = NULL;
- } else if (IS_ERR(sensor->extclk)) {
- dev_err(dev, "failed to get external clock\n");
- ret = PTR_ERR(sensor->extclk);
+ sensor->extclk = devm_v4l2_sensor_clk_get(dev, NULL);
+ if (IS_ERR(sensor->extclk)) {
+ ret = dev_err_probe(dev, PTR_ERR(sensor->extclk),
+ "failed to get external clock\n");
goto error_endpoint;
}
- /*
- * We could have either a 24MHz or 19.2MHz clock rate from either dt or
- * ACPI...but we also need to support the weird IPU3 case which will
- * have an external clock AND a clock-frequency property. Check for the
- * clock-frequency property and if found, set that rate if we managed
- * to acquire a clock. This should cover the ACPI case. If the system
- * uses devicetree then the configured rate should already be set, so
- * we can just read it.
- */
- ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency",
- &rate);
- if (!ret && sensor->extclk) {
- ret = clk_set_rate(sensor->extclk, rate);
- if (ret) {
- dev_err_probe(dev, ret, "failed to set clock rate\n");
- goto error_endpoint;
- }
- } else if (ret && !sensor->extclk) {
- dev_err_probe(dev, ret, "invalid clock config\n");
- goto error_endpoint;
- }
-
- sensor->extclk_rate = rate ? rate : clk_get_rate(sensor->extclk);
+ sensor->extclk_rate = clk_get_rate(sensor->extclk);
for (i = 0; i < ARRAY_SIZE(supported_extclk_rates); i++) {
if (sensor->extclk_rate == supported_extclk_rates[i])
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 39/48] media: i2c: ov9282: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (37 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 38/48] media: i2c: ov8865: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 40/48] media: i2c: ov9640: " Mehdi Djait
` (8 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov9282.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/ov9282.c b/drivers/media/i2c/ov9282.c
index c882a021cf18..a9f6176e9729 100644
--- a/drivers/media/i2c/ov9282.c
+++ b/drivers/media/i2c/ov9282.c
@@ -1135,11 +1135,10 @@ static int ov9282_parse_hw_config(struct ov9282 *ov9282)
}
/* Get sensor input clock */
- ov9282->inclk = devm_clk_get(ov9282->dev, NULL);
- if (IS_ERR(ov9282->inclk)) {
- dev_err(ov9282->dev, "could not get inclk");
- return PTR_ERR(ov9282->inclk);
- }
+ ov9282->inclk = devm_v4l2_sensor_clk_get(ov9282->dev, NULL);
+ if (IS_ERR(ov9282->inclk))
+ return dev_err_probe(ov9282->dev, PTR_ERR(ov9282->inclk),
+ "could not get inclk\n");
ret = ov9282_configure_regulators(ov9282);
if (ret)
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 40/48] media: i2c: ov9640: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (38 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 39/48] media: i2c: ov9282: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 41/48] media: i2c: ov9650: " Mehdi Djait
` (7 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov9640.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/ov9640.c b/drivers/media/i2c/ov9640.c
index 01dbc0ba89c8..2190c52b1433 100644
--- a/drivers/media/i2c/ov9640.c
+++ b/drivers/media/i2c/ov9640.c
@@ -718,9 +718,10 @@ static int ov9640_probe(struct i2c_client *client)
priv->subdev.ctrl_handler = &priv->hdl;
- priv->clk = devm_clk_get(&client->dev, "mclk");
+ priv->clk = devm_v4l2_sensor_clk_get(&client->dev, "mclk");
if (IS_ERR(priv->clk)) {
- ret = PTR_ERR(priv->clk);
+ ret = dev_err_probe(&client->dev, PTR_ERR(priv->clk),
+ "failed to get mclk\n");
goto ectrlinit;
}
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 41/48] media: i2c: ov9650: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (39 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 40/48] media: i2c: ov9640: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 42/48] media: i2c: s5c73m3: " Mehdi Djait
` (6 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov9650.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/ov9650.c b/drivers/media/i2c/ov9650.c
index 026ea34d6291..c94e8fe29f22 100644
--- a/drivers/media/i2c/ov9650.c
+++ b/drivers/media/i2c/ov9650.c
@@ -1494,9 +1494,10 @@ static int ov965x_probe(struct i2c_client *client)
}
if (dev_fwnode(&client->dev)) {
- ov965x->clk = devm_clk_get(&client->dev, NULL);
+ ov965x->clk = devm_v4l2_sensor_clk_get(&client->dev, NULL);
if (IS_ERR(ov965x->clk))
- return PTR_ERR(ov965x->clk);
+ return dev_err_probe(&client->dev, PTR_ERR(ov965x->clk),
+ "failed to get the clock\n");
ov965x->mclk_frequency = clk_get_rate(ov965x->clk);
ret = ov965x_configure_gpios(ov965x);
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 42/48] media: i2c: s5c73m3: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (40 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 41/48] media: i2c: ov9650: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 43/48] media: i2c: s5k5baf: " Mehdi Djait
` (5 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/s5c73m3/s5c73m3-core.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/s5c73m3/s5c73m3-core.c b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
index 7716dfe2b8c9..088184da5dea 100644
--- a/drivers/media/i2c/s5c73m3/s5c73m3-core.c
+++ b/drivers/media/i2c/s5c73m3/s5c73m3-core.c
@@ -1556,9 +1556,11 @@ static int s5c73m3_get_dt_data(struct s5c73m3 *state)
if (!node)
return -EINVAL;
- state->clock = devm_clk_get(dev, S5C73M3_CLK_NAME);
+ state->clock = devm_v4l2_sensor_clk_get(dev, S5C73M3_CLK_NAME);
if (IS_ERR(state->clock))
- return PTR_ERR(state->clock);
+ return dev_err_probe(dev, PTR_ERR(state->clock),
+ "Failed to get the clock %s\n",
+ S5C73M3_CLK_NAME);
if (of_property_read_u32(node, "clock-frequency",
&state->mclk_frequency)) {
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 43/48] media: i2c: s5k5baf: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (41 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 42/48] media: i2c: s5c73m3: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 44/48] media: i2c: s5k6a3: " Mehdi Djait
` (4 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/s5k5baf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c
index 24f399cd2124..01d37f49e5ad 100644
--- a/drivers/media/i2c/s5k5baf.c
+++ b/drivers/media/i2c/s5k5baf.c
@@ -1967,7 +1967,7 @@ static int s5k5baf_probe(struct i2c_client *c)
if (ret < 0)
goto err_me;
- state->clock = devm_clk_get(state->sd.dev, S5K5BAF_CLK_NAME);
+ state->clock = devm_v4l2_sensor_clk_get(state->sd.dev, S5K5BAF_CLK_NAME);
if (IS_ERR(state->clock)) {
ret = -EPROBE_DEFER;
goto err_me;
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 44/48] media: i2c: s5k6a3: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (42 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 43/48] media: i2c: s5k5baf: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 45/48] media: i2c: vd55g1: " Mehdi Djait
` (3 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/s5k6a3.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/media/i2c/s5k6a3.c b/drivers/media/i2c/s5k6a3.c
index 0c2674115b7b..4bf5f122b113 100644
--- a/drivers/media/i2c/s5k6a3.c
+++ b/drivers/media/i2c/s5k6a3.c
@@ -292,9 +292,10 @@ static int s5k6a3_probe(struct i2c_client *client)
mutex_init(&sensor->lock);
sensor->dev = dev;
- sensor->clock = devm_clk_get(sensor->dev, S5K6A3_CLK_NAME);
+ sensor->clock = devm_v4l2_sensor_clk_get(sensor->dev, S5K6A3_CLK_NAME);
if (IS_ERR(sensor->clock))
- return PTR_ERR(sensor->clock);
+ return dev_err_probe(sensor->dev, PTR_ERR(sensor->clock),
+ "failed to get extclk\n");
sensor->gpio_reset = devm_gpiod_get(dev, NULL, GPIOD_OUT_HIGH);
ret = PTR_ERR_OR_ZERO(sensor->gpio_reset);
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 45/48] media: i2c: vd55g1: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (43 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 44/48] media: i2c: s5k6a3: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 46/48] media: i2c: vd56g3: " Mehdi Djait
` (2 subsequent siblings)
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/vd55g1.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/vd55g1.c b/drivers/media/i2c/vd55g1.c
index 25e2fc88a036..693db225e04d 100644
--- a/drivers/media/i2c/vd55g1.c
+++ b/drivers/media/i2c/vd55g1.c
@@ -1863,7 +1863,7 @@ static int vd55g1_probe(struct i2c_client *client)
if (ret)
return dev_err_probe(dev, ret, "Failed to get regulators\n");
- sensor->xclk = devm_clk_get(dev, NULL);
+ sensor->xclk = devm_v4l2_sensor_clk_get(dev, NULL);
if (IS_ERR(sensor->xclk))
return dev_err_probe(dev, PTR_ERR(sensor->xclk),
"Failed to get xclk\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 46/48] media: i2c: vd56g3: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (44 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 45/48] media: i2c: vd55g1: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 47/48] media: i2c: vgxy61: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 48/48] media: i2c: ov2680: " Mehdi Djait
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/vd56g3.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/i2c/vd56g3.c b/drivers/media/i2c/vd56g3.c
index 5d951ad0b478..ac3e868dbb43 100644
--- a/drivers/media/i2c/vd56g3.c
+++ b/drivers/media/i2c/vd56g3.c
@@ -1474,7 +1474,7 @@ static int vd56g3_probe(struct i2c_client *client)
if (ret)
return dev_err_probe(dev, ret, "Failed to get regulators\n");
- sensor->xclk = devm_clk_get(dev, NULL);
+ sensor->xclk = devm_v4l2_sensor_clk_get(dev, NULL);
if (IS_ERR(sensor->xclk))
return dev_err_probe(dev, PTR_ERR(sensor->xclk),
"Failed to get xclk\n");
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 47/48] media: i2c: vgxy61: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (45 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 46/48] media: i2c: vd56g3: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 48/48] media: i2c: ov2680: " Mehdi Djait
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
devm_clk_get() fails on ACPI-based platforms, where firmware does not
provide a direct reference to the clock producer.
Replace devm_clk_get() with the new v4l2 helper
devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/vgxy61.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/media/i2c/vgxy61.c b/drivers/media/i2c/vgxy61.c
index 5b0479f3a3c0..3d001e0b646b 100644
--- a/drivers/media/i2c/vgxy61.c
+++ b/drivers/media/i2c/vgxy61.c
@@ -1761,11 +1761,11 @@ static int vgxy61_probe(struct i2c_client *client)
return ret;
}
- sensor->xclk = devm_clk_get(dev, NULL);
- if (IS_ERR(sensor->xclk)) {
- dev_err(dev, "failed to get xclk\n");
- return PTR_ERR(sensor->xclk);
- }
+ sensor->xclk = devm_v4l2_sensor_clk_get(dev, NULL);
+ if (IS_ERR(sensor->xclk))
+ return dev_err_probe(dev, PTR_ERR(sensor->xclk),
+ "failed to get xclk\n");
+
sensor->clk_freq = clk_get_rate(sensor->xclk);
if (sensor->clk_freq < 6 * HZ_PER_MHZ ||
sensor->clk_freq > 27 * HZ_PER_MHZ) {
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* [PATCH v2 48/48] media: i2c: ov2680: Use the v4l2 helper for obtaining the clock
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
` (46 preceding siblings ...)
2025-06-26 13:34 ` [PATCH v2 47/48] media: i2c: vgxy61: " Mehdi Djait
@ 2025-06-26 13:34 ` Mehdi Djait
47 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-06-26 13:34 UTC (permalink / raw)
To: laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
mehdi.djait, michael.riesch, naush, nicholas, nicolas.dufresne,
paul.elder, dan.scally, pavel, rashanmu, ribalda, slongerbeam,
tomi.valkeinen, umang.jain, linux-media, Lad Prabhakar
Use the new v4l2 helper devm_v4l2_sensor_clk_get() that works on both
DT- and ACPI-based platforms to retrieve a reference to the clock
producer from firmware.
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/i2c/ov2680.c | 29 ++---------------------------
1 file changed, 2 insertions(+), 27 deletions(-)
diff --git a/drivers/media/i2c/ov2680.c b/drivers/media/i2c/ov2680.c
index 7237fb27ecd0..78e63bd1b35b 100644
--- a/drivers/media/i2c/ov2680.c
+++ b/drivers/media/i2c/ov2680.c
@@ -1079,7 +1079,6 @@ static int ov2680_parse_dt(struct ov2680_dev *sensor)
struct device *dev = sensor->dev;
struct fwnode_handle *ep_fwnode;
struct gpio_desc *gpio;
- unsigned int rate = 0;
int i, ret;
/*
@@ -1114,38 +1113,14 @@ static int ov2680_parse_dt(struct ov2680_dev *sensor)
sensor->pwdn_gpio = gpio;
- sensor->xvclk = devm_clk_get_optional(dev, "xvclk");
+ sensor->xvclk = devm_v4l2_sensor_clk_get(dev, "xvclk");
if (IS_ERR(sensor->xvclk)) {
ret = dev_err_probe(dev, PTR_ERR(sensor->xvclk),
"xvclk clock missing or invalid\n");
goto out_free_bus_cfg;
}
- /*
- * We could have either a 24MHz or 19.2MHz clock rate from either DT or
- * ACPI... but we also need to support the weird IPU3 case which will
- * have an external clock AND a clock-frequency property. Check for the
- * clock-frequency property and if found, set that rate if we managed
- * to acquire a clock. This should cover the ACPI case. If the system
- * uses devicetree then the configured rate should already be set, so
- * we can just read it.
- */
- ret = fwnode_property_read_u32(dev_fwnode(dev), "clock-frequency",
- &rate);
- if (ret && !sensor->xvclk) {
- dev_err_probe(dev, ret, "invalid clock config\n");
- goto out_free_bus_cfg;
- }
-
- if (!ret && sensor->xvclk) {
- ret = clk_set_rate(sensor->xvclk, rate);
- if (ret) {
- dev_err_probe(dev, ret, "failed to set clock rate\n");
- goto out_free_bus_cfg;
- }
- }
-
- sensor->xvclk_freq = rate ?: clk_get_rate(sensor->xvclk);
+ sensor->xvclk_freq = clk_get_rate(sensor->xvclk);
for (i = 0; i < ARRAY_SIZE(ov2680_xvclk_freqs); i++) {
if (sensor->xvclk_freq == ov2680_xvclk_freqs[i])
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* Re: [PATCH v2 17/48] media: i2c: imx415: Use the v4l2 helper for obtaining the clock
2025-06-26 13:34 ` [PATCH v2 17/48] media: i2c: imx415: " Mehdi Djait
@ 2025-06-26 13:41 ` Michael Riesch
0 siblings, 0 replies; 72+ messages in thread
From: Michael Riesch @ 2025-06-26 13:41 UTC (permalink / raw)
To: Mehdi Djait, laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
naush, nicholas, nicolas.dufresne, paul.elder, dan.scally, pavel,
rashanmu, ribalda, slongerbeam, tomi.valkeinen, umang.jain,
linux-media, Lad Prabhakar
Hi Mehdi,
Thanks for doing this!
On 6/26/25 15:34, Mehdi Djait wrote:
> devm_clk_get() fails on ACPI-based platforms, where firmware does not
> provide a direct reference to the clock producer.
>
> Replace devm_clk_get() with the new v4l2 helper
> devm_v4l2_sensor_clk_get() that works on both DT- and ACPI-based
> platforms to retrieve a reference to the clock producer from firmware.
>
> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Michael Riesch <michael.riesch@collabora.com>
> Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> ---
> drivers/media/i2c/imx415.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/i2c/imx415.c b/drivers/media/i2c/imx415.c
> index 9f37779bd611..2e206a671ed3 100644
> --- a/drivers/media/i2c/imx415.c
> +++ b/drivers/media/i2c/imx415.c
> @@ -1251,7 +1251,7 @@ static int imx415_parse_hw_config(struct imx415 *sensor)
> return dev_err_probe(sensor->dev, PTR_ERR(sensor->reset),
> "failed to get reset GPIO\n");
>
> - sensor->clk = devm_clk_get(sensor->dev, "inck");
> + sensor->clk = devm_v4l2_sensor_clk_get(sensor->dev, NULL);
> if (IS_ERR(sensor->clk))
> return dev_err_probe(sensor->dev, PTR_ERR(sensor->clk),
> "failed to get clock\n");
Thanks and best regards,
Michael
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-06-26 13:33 ` [PATCH v2 01/48] media: v4l2-common: " Mehdi Djait
@ 2025-06-27 7:12 ` Sakari Ailus
2025-07-01 9:51 ` Mehdi Djait
2025-07-06 0:30 ` Laurent Pinchart
2025-08-13 10:15 ` [PATCH v2 01/48] " Hans Verkuil
2 siblings, 1 reply; 72+ messages in thread
From: Sakari Ailus @ 2025-06-27 7:12 UTC (permalink / raw)
To: Mehdi Djait
Cc: laurent.pinchart, stanislaw.gruszka, hdegoede, arnd, alain.volmat,
andrzej.hajda, benjamin.mugnier, dave.stevenson, hansg, hverkuil,
jacopo.mondi, kieran.bingham, khalasa, mani, m.felsch,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, umang.jain, linux-media,
Lad Prabhakar
Hi Mehdi,
On Thu, Jun 26, 2025 at 03:33:52PM +0200, Mehdi Djait wrote:
> Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> platforms to retrieve a reference to the clock producer from firmware.
>
> This helper behaves the same as devm_clk_get() except where there is
> no clock producer like in ACPI-based platforms.
>
> For ACPI-based platforms the function will read the "clock-frequency"
> ACPI _DSD property and register a fixed frequency clock with the frequency
> indicated in the property.
>
> This function also handles the special ACPI-based system case where:
> The clock-frequency _DSD property is present.
> A reference to the clock producer is present, where the clock is provided
> by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
Missing leading dot. You could also rewrap this paragraph, using longer
lines up to 75 characters.
If there's not going to be further versions of the patch, I'll just rewrap
this while applying.
> In this case try to set the clock-frequency value to the provided clock.
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> ---
> drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
> include/media/v4l2-common.h | 27 ++++++++++++++
> 2 files changed, 79 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index bd160a8c9efe..ac98895b0394 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -34,6 +34,9 @@
> * Added Gerd Knorrs v4l1 enhancements (Justin Schoeman)
> */
>
> +#include <linux/clk.h>
> +#include <linux/clkdev.h>
> +#include <linux/clk-provider.h>
> #include <linux/module.h>
> #include <linux/types.h>
> #include <linux/kernel.h>
> @@ -673,3 +676,52 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> return 0;
> }
> EXPORT_SYMBOL_GPL(v4l2_link_freq_to_bitmap);
> +
> +struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id)
> +{
> + const char *clk_id __free(kfree) = NULL;
> + struct clk_hw *clk_hw;
> + struct clk *clk;
> + bool of_node;
> + u32 rate;
> + int ret;
> +
> + clk = devm_clk_get_optional(dev, id);
> + ret = device_property_read_u32(dev, "clock-frequency", &rate);
> + of_node = is_of_node(dev_fwnode(dev));
> +
> + if (clk) {
> + if (!ret && !of_node) {
> + ret = clk_set_rate(clk, rate);
> + if (ret) {
> + dev_err(dev, "Failed to set clock rate: %u\n",
> + rate);
> + return ERR_PTR(ret);
> + }
> + }
> + return clk;
> + }
> +
> + if (PTR_ERR(clk) == -EPROBE_DEFER)
> + return ERR_PTR(-EPROBE_DEFER);
> +
> + if (!IS_ENABLED(CONFIG_COMMON_CLK) || of_node)
> + return ERR_PTR(-ENOENT);
> +
> + if (ret)
> + return ERR_PTR(ret == -EINVAL ? -EPROBE_DEFER : ret);
> +
> + if (!id) {
> + clk_id = kasprintf(GFP_KERNEL, "clk-%s", dev_name(dev));
> + if (!clk_id)
> + return ERR_PTR(-ENOMEM);
> + id = clk_id;
> + }
> +
> + clk_hw = devm_clk_hw_register_fixed_rate(dev, id, NULL, 0, rate);
> + if (IS_ERR(clk_hw))
> + return ERR_CAST(clk_hw);
> +
> + return clk_hw->clk;
> +}
> +EXPORT_SYMBOL_GPL(devm_v4l2_sensor_clk_get);
> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> index 0a43f56578bc..1c79ca4d5c73 100644
> --- a/include/media/v4l2-common.h
> +++ b/include/media/v4l2-common.h
> @@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
> struct v4l2_device;
> struct v4l2_subdev;
> struct v4l2_subdev_ops;
> +struct clk;
>
> /* I2C Helper functions */
> #include <linux/i2c.h>
> @@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> unsigned int num_of_driver_link_freqs,
> unsigned long *bitmap);
>
> +/**
> + * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
> + * for a camera sensor.
> + *
> + * @dev: device for v4l2 sensor clock "consumer"
> + * @id: clock consumer ID
> + *
> + * This function behaves the same way as devm_clk_get() except where there
> + * is no clock producer like in ACPI-based platforms.
> + *
> + * For ACPI-based platforms, the function will read the "clock-frequency"
> + * ACPI _DSD property and register a fixed-clock with the frequency indicated
> + * in the property.
> + *
> + * This function also handles the special ACPI-based system case where:
> + *
> + * * The clock-frequency _DSD property is present.
> + * * A reference to the clock producer is present, where the clock is provided
> + * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> + *
> + * In this case try to set the clock-frequency value to the provided clock.
> + *
> + * Returns a pointer to a struct clk on success or an error pointer on failure.
> + */
> +struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id);
> +
> static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf)
> {
> /*
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-06-27 7:12 ` Sakari Ailus
@ 2025-07-01 9:51 ` Mehdi Djait
2025-07-01 10:03 ` Sakari Ailus
0 siblings, 1 reply; 72+ messages in thread
From: Mehdi Djait @ 2025-07-01 9:51 UTC (permalink / raw)
To: Sakari Ailus
Cc: laurent.pinchart, stanislaw.gruszka, hdegoede, arnd, alain.volmat,
andrzej.hajda, benjamin.mugnier, dave.stevenson, hansg, hverkuil,
jacopo.mondi, kieran.bingham, khalasa, mani, m.felsch,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, umang.jain, linux-media,
Lad Prabhakar
Hi Sakari,
On Fri, Jun 27, 2025 at 07:12:04AM +0000, Sakari Ailus wrote:
> Hi Mehdi,
>
> On Thu, Jun 26, 2025 at 03:33:52PM +0200, Mehdi Djait wrote:
> > Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> > platforms to retrieve a reference to the clock producer from firmware.
> >
> > This helper behaves the same as devm_clk_get() except where there is
> > no clock producer like in ACPI-based platforms.
> >
> > For ACPI-based platforms the function will read the "clock-frequency"
> > ACPI _DSD property and register a fixed frequency clock with the frequency
> > indicated in the property.
> >
> > This function also handles the special ACPI-based system case where:
> > The clock-frequency _DSD property is present.
> > A reference to the clock producer is present, where the clock is provided
> > by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
>
> Missing leading dot. You could also rewrap this paragraph, using longer
> lines up to 75 characters.
>
> If there's not going to be further versions of the patch, I'll just rewrap
> this while applying.
Two things before applying:
- A missing Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
for the Documentation patch -> [PATCH 02/48]
- We still need to agree on how to proceed for the sensor drivers I mentioned
in the cover Letter:
1) drivers/media/i2c/s5k5baf.c
Always returns -EPROBE_DEFER if getting the clock fails ?!
2) drivers/media/i2c/mt9t112.c
This drivers seems to be implementing the behaviour of
devm_clk_get_optional() while using devm_clk_get(): remove it from the
list of changed drivers ?
3) drivers/media/i2c/ov8856.c
Getting the clock, setting the rate, getting the optional gpio and the
regulator_bulk is only when the fwnode is NOT acpi.
--
Kind Regards
Mehdi Djait
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-07-01 9:51 ` Mehdi Djait
@ 2025-07-01 10:03 ` Sakari Ailus
2025-07-01 10:47 ` Jacopo Mondi
0 siblings, 1 reply; 72+ messages in thread
From: Sakari Ailus @ 2025-07-01 10:03 UTC (permalink / raw)
To: Mehdi Djait
Cc: laurent.pinchart, stanislaw.gruszka, hdegoede, arnd, alain.volmat,
andrzej.hajda, benjamin.mugnier, dave.stevenson, hansg, hverkuil,
jacopo.mondi, kieran.bingham, khalasa, mani, m.felsch,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, umang.jain, linux-media,
Lad Prabhakar
Hi Mehdi,
On Tue, Jul 01, 2025 at 11:51:02AM +0200, Mehdi Djait wrote:
> Hi Sakari,
>
> On Fri, Jun 27, 2025 at 07:12:04AM +0000, Sakari Ailus wrote:
> > Hi Mehdi,
> >
> > On Thu, Jun 26, 2025 at 03:33:52PM +0200, Mehdi Djait wrote:
> > > Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> > > platforms to retrieve a reference to the clock producer from firmware.
> > >
> > > This helper behaves the same as devm_clk_get() except where there is
> > > no clock producer like in ACPI-based platforms.
> > >
> > > For ACPI-based platforms the function will read the "clock-frequency"
> > > ACPI _DSD property and register a fixed frequency clock with the frequency
> > > indicated in the property.
> > >
> > > This function also handles the special ACPI-based system case where:
> > > The clock-frequency _DSD property is present.
> > > A reference to the clock producer is present, where the clock is provided
> > > by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> >
> > Missing leading dot. You could also rewrap this paragraph, using longer
> > lines up to 75 characters.
> >
> > If there's not going to be further versions of the patch, I'll just rewrap
> > this while applying.
>
> Two things before applying:
>
> - A missing Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> for the Documentation patch -> [PATCH 02/48]
Is Co-developed-by: also relevant?
>
> - We still need to agree on how to proceed for the sensor drivers I mentioned
> in the cover Letter:
>
> 1) drivers/media/i2c/s5k5baf.c
> Always returns -EPROBE_DEFER if getting the clock fails ?!
This can be fixed later on IMO.
>
> 2) drivers/media/i2c/mt9t112.c
> This drivers seems to be implementing the behaviour of
> devm_clk_get_optional() while using devm_clk_get(): remove it from the
> list of changed drivers ?
There are no DT bindings. I wonder if this is still relevant. Maybe Jacopo
has an idea?
>
> 3) drivers/media/i2c/ov8856.c
> Getting the clock, setting the rate, getting the optional gpio and the
> regulator_bulk is only when the fwnode is NOT acpi.
Isn't this a similar case than the other sensor (which I can't remember
anymore), where effectively the rate set couldn't be different than the
clock already had?
I think this also could be handled after this set.
--
Kind regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-07-01 10:03 ` Sakari Ailus
@ 2025-07-01 10:47 ` Jacopo Mondi
2025-07-01 11:17 ` Laurent Pinchart
0 siblings, 1 reply; 72+ messages in thread
From: Jacopo Mondi @ 2025-07-01 10:47 UTC (permalink / raw)
To: Sakari Ailus
Cc: Mehdi Djait, laurent.pinchart, stanislaw.gruszka, hdegoede, arnd,
alain.volmat, andrzej.hajda, benjamin.mugnier, dave.stevenson,
hansg, hverkuil, jacopo.mondi, kieran.bingham, khalasa, mani,
m.felsch, matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, umang.jain, linux-media,
Lad Prabhakar
Hi Sakari, Mehdi,
On Tue, Jul 01, 2025 at 01:03:27PM +0300, Sakari Ailus wrote:
> Hi Mehdi,
>
> On Tue, Jul 01, 2025 at 11:51:02AM +0200, Mehdi Djait wrote:
> > Hi Sakari,
> >
> > On Fri, Jun 27, 2025 at 07:12:04AM +0000, Sakari Ailus wrote:
> > > Hi Mehdi,
> > >
> > > On Thu, Jun 26, 2025 at 03:33:52PM +0200, Mehdi Djait wrote:
> > > > Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> > > > platforms to retrieve a reference to the clock producer from firmware.
> > > >
> > > > This helper behaves the same as devm_clk_get() except where there is
> > > > no clock producer like in ACPI-based platforms.
> > > >
> > > > For ACPI-based platforms the function will read the "clock-frequency"
> > > > ACPI _DSD property and register a fixed frequency clock with the frequency
> > > > indicated in the property.
> > > >
> > > > This function also handles the special ACPI-based system case where:
> > > > The clock-frequency _DSD property is present.
> > > > A reference to the clock producer is present, where the clock is provided
> > > > by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> > >
> > > Missing leading dot. You could also rewrap this paragraph, using longer
> > > lines up to 75 characters.
> > >
> > > If there's not going to be further versions of the patch, I'll just rewrap
> > > this while applying.
> >
> > Two things before applying:
> >
> > - A missing Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > for the Documentation patch -> [PATCH 02/48]
>
> Is Co-developed-by: also relevant?
>
> >
> > - We still need to agree on how to proceed for the sensor drivers I mentioned
> > in the cover Letter:
> >
> > 1) drivers/media/i2c/s5k5baf.c
> > Always returns -EPROBE_DEFER if getting the clock fails ?!
>
> This can be fixed later on IMO.
>
> >
> > 2) drivers/media/i2c/mt9t112.c
> > This drivers seems to be implementing the behaviour of
> > devm_clk_get_optional() while using devm_clk_get(): remove it from the
> > list of changed drivers ?
>
> There are no DT bindings. I wonder if this is still relevant. Maybe Jacopo
> has an idea?
Not really, the driver has been ported to be a regular i2c driver from
its soc-camera-based legacy implementation but has seen basically no
development since then, if not for sub-system wide changes or odd fixes.
Looking at the implementatio, the driver indeed seems to implement what
_optional() does already, so it might be more opportune to convert it
to _optional() first maybe ? However in my understanding your patch
doesn't change the current behaviour, doesn't it ? In this case I think
you can go ahead.
Thanks
j
>
> >
> > 3) drivers/media/i2c/ov8856.c
> > Getting the clock, setting the rate, getting the optional gpio and the
> > regulator_bulk is only when the fwnode is NOT acpi.
>
> Isn't this a similar case than the other sensor (which I can't remember
> anymore), where effectively the rate set couldn't be different than the
> clock already had?
>
> I think this also could be handled after this set.
>
> --
> Kind regards,
>
> Sakari Ailus
>
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 02/48] Documentation: media: camera-sensor: Mention v4l2_devm_sensor_clk_get() for obtaining the clock
2025-06-26 13:33 ` [PATCH v2 02/48] Documentation: media: camera-sensor: Mention v4l2_devm_sensor_clk_get() for obtaining the clock Mehdi Djait
@ 2025-07-01 11:03 ` Laurent Pinchart
0 siblings, 0 replies; 72+ messages in thread
From: Laurent Pinchart @ 2025-07-01 11:03 UTC (permalink / raw)
To: Mehdi Djait
Cc: sakari.ailus, stanislaw.gruszka, hdegoede, arnd, alain.volmat,
andrzej.hajda, benjamin.mugnier, dave.stevenson, hansg, hverkuil,
jacopo.mondi, kieran.bingham, khalasa, mani, m.felsch,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, umang.jain, linux-media,
Lad Prabhakar
On Thu, Jun 26, 2025 at 03:33:53PM +0200, Mehdi Djait wrote:
> Add the new v4l2 helper devm_v4l2_sensor_clk_get() to Documentation. the
> helper works on both DT- and ACPI-based platforms to retrieve a
> reference to the clock producer from firmware.
>
> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Co-developed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> ---
> .../driver-api/media/camera-sensor.rst | 24 +++++++++++++------
> 1 file changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/Documentation/driver-api/media/camera-sensor.rst b/Documentation/driver-api/media/camera-sensor.rst
> index c290833165e6..94bd1dae82d5 100644
> --- a/Documentation/driver-api/media/camera-sensor.rst
> +++ b/Documentation/driver-api/media/camera-sensor.rst
> @@ -29,21 +29,31 @@ used in the system. Using another frequency may cause harmful effects
> elsewhere. Therefore only the pre-determined frequencies are configurable by the
> user.
>
> +The external clock frequency shall be retrieved by obtaining the external clock
> +using the ``devm_v4l2_sensor_clk_get()`` helper function, and then getting its
> +frequency with ``clk_get_rate()``. Usage of the helper function guarantees
> +correct behaviour regardless of whether the sensor is integrated in a DT-based
> +or ACPI-based system.
> +
> ACPI
> ~~~~
>
> -Read the ``clock-frequency`` _DSD property to denote the frequency. The driver
> -can rely on this frequency being used.
> +ACPI-based systems typically don't register the sensor external clock with the
> +kernel, but specify the external clock frequency in the ``clock-frequency``
> +_DSD property. The ``devm_v4l2_sensor_clk_get()`` helper creates and returns a
> +fixed clock set at that rate.
>
> Devicetree
> ~~~~~~~~~~
>
> -The preferred way to achieve this is using ``assigned-clocks``,
> -``assigned-clock-parents`` and ``assigned-clock-rates`` properties. See the
> -`clock device tree bindings
> +Devicetree-based systems declare the sensor external clock in the device tree
> +and reference it from the sensor node. The preferred way to select the external
> +clock frequency is to use the ``assigned-clocks``, ``assigned-clock-parents``
> +and ``assigned-clock-rates`` properties in the sensor node to set the clock
> +rate. See the `clock device tree bindings
> <https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/clock/clock.yaml>`_
> -for more information. The driver then gets the frequency using
> -``clk_get_rate()``.
> +for more information. The ``devm_v4l2_sensor_clk_get()`` helper retrieves and
> +returns that clock.
>
> This approach has the drawback that there's no guarantee that the frequency
> hasn't been modified directly or indirectly by another driver, or supported by
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-07-01 10:47 ` Jacopo Mondi
@ 2025-07-01 11:17 ` Laurent Pinchart
2025-07-01 11:46 ` Mehdi Djait
0 siblings, 1 reply; 72+ messages in thread
From: Laurent Pinchart @ 2025-07-01 11:17 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Sakari Ailus, Mehdi Djait, stanislaw.gruszka, hdegoede, arnd,
alain.volmat, andrzej.hajda, benjamin.mugnier, dave.stevenson,
hansg, hverkuil, kieran.bingham, khalasa, mani, m.felsch,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, umang.jain, linux-media,
Lad Prabhakar
On Tue, Jul 01, 2025 at 12:47:16PM +0200, Jacopo Mondi wrote:
> On Tue, Jul 01, 2025 at 01:03:27PM +0300, Sakari Ailus wrote:
> > On Tue, Jul 01, 2025 at 11:51:02AM +0200, Mehdi Djait wrote:
> > > On Fri, Jun 27, 2025 at 07:12:04AM +0000, Sakari Ailus wrote:
> > > > On Thu, Jun 26, 2025 at 03:33:52PM +0200, Mehdi Djait wrote:
> > > > > Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> > > > > platforms to retrieve a reference to the clock producer from firmware.
> > > > >
> > > > > This helper behaves the same as devm_clk_get() except where there is
> > > > > no clock producer like in ACPI-based platforms.
> > > > >
> > > > > For ACPI-based platforms the function will read the "clock-frequency"
> > > > > ACPI _DSD property and register a fixed frequency clock with the frequency
> > > > > indicated in the property.
> > > > >
> > > > > This function also handles the special ACPI-based system case where:
> > > > > The clock-frequency _DSD property is present.
> > > > > A reference to the clock producer is present, where the clock is provided
> > > > > by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> > > >
> > > > Missing leading dot. You could also rewrap this paragraph, using longer
> > > > lines up to 75 characters.
> > > >
> > > > If there's not going to be further versions of the patch, I'll just rewrap
> > > > this while applying.
> > >
> > > Two things before applying:
> > >
> > > - A missing Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > for the Documentation patch -> [PATCH 02/48]
Fixed.
> > Is Co-developed-by: also relevant?
> >
> > > - We still need to agree on how to proceed for the sensor drivers I mentioned
> > > in the cover Letter:
> > >
> > > 1) drivers/media/i2c/s5k5baf.c
> > > Always returns -EPROBE_DEFER if getting the clock fails ?!
> >
> > This can be fixed later on IMO.
Agreed.
> > >
> > > 2) drivers/media/i2c/mt9t112.c
> > > This drivers seems to be implementing the behaviour of
> > > devm_clk_get_optional() while using devm_clk_get(): remove it from the
> > > list of changed drivers ?
> >
> > There are no DT bindings. I wonder if this is still relevant. Maybe Jacopo
> > has an idea?
>
> Not really, the driver has been ported to be a regular i2c driver from
> its soc-camera-based legacy implementation but has seen basically no
> development since then, if not for sub-system wide changes or odd fixes.
>
> Looking at the implementatio, the driver indeed seems to implement what
> _optional() does already, so it might be more opportune to convert it
> to _optional() first maybe ? However in my understanding your patch
> doesn't change the current behaviour, doesn't it ? In this case I think
> you can go ahead.
Agreed too.
> > > 3) drivers/media/i2c/ov8856.c
> > > Getting the clock, setting the rate, getting the optional gpio and the
> > > regulator_bulk is only when the fwnode is NOT acpi.
> >
> > Isn't this a similar case than the other sensor (which I can't remember
> > anymore), where effectively the rate set couldn't be different than the
> > clock already had?
> >
> > I think this also could be handled after this set.
Ideally we should stop setting the rate and simplify the driver, but we
have to be careful about regressions. I agree with Sakari, we can
address this later.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-07-01 11:17 ` Laurent Pinchart
@ 2025-07-01 11:46 ` Mehdi Djait
0 siblings, 0 replies; 72+ messages in thread
From: Mehdi Djait @ 2025-07-01 11:46 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Jacopo Mondi, Sakari Ailus, stanislaw.gruszka, hdegoede, arnd,
alain.volmat, andrzej.hajda, benjamin.mugnier, dave.stevenson,
hansg, hverkuil, kieran.bingham, khalasa, mani, m.felsch,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, umang.jain, linux-media,
Lad Prabhakar
Hello everyone,
On Tue, Jul 01, 2025 at 02:17:42PM +0300, Laurent Pinchart wrote:
> On Tue, Jul 01, 2025 at 12:47:16PM +0200, Jacopo Mondi wrote:
> > On Tue, Jul 01, 2025 at 01:03:27PM +0300, Sakari Ailus wrote:
> > > On Tue, Jul 01, 2025 at 11:51:02AM +0200, Mehdi Djait wrote:
> > > > On Fri, Jun 27, 2025 at 07:12:04AM +0000, Sakari Ailus wrote:
> > > > > On Thu, Jun 26, 2025 at 03:33:52PM +0200, Mehdi Djait wrote:
> > > > > > Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> > > > > > platforms to retrieve a reference to the clock producer from firmware.
> > > > > >
> > > > > > This helper behaves the same as devm_clk_get() except where there is
> > > > > > no clock producer like in ACPI-based platforms.
> > > > > >
> > > > > > For ACPI-based platforms the function will read the "clock-frequency"
> > > > > > ACPI _DSD property and register a fixed frequency clock with the frequency
> > > > > > indicated in the property.
> > > > > >
> > > > > > This function also handles the special ACPI-based system case where:
> > > > > > The clock-frequency _DSD property is present.
> > > > > > A reference to the clock producer is present, where the clock is provided
> > > > > > by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> > > > >
> > > > > Missing leading dot. You could also rewrap this paragraph, using longer
> > > > > lines up to 75 characters.
> > > > >
> > > > > If there's not going to be further versions of the patch, I'll just rewrap
> > > > > this while applying.
> > > >
> > > > Two things before applying:
> > > >
> > > > - A missing Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > > for the Documentation patch -> [PATCH 02/48]
>
> Fixed.
Thanks!
>
> > > Is Co-developed-by: also relevant?
> > >
Yes it is relevant for that patch.
> > > > - We still need to agree on how to proceed for the sensor drivers I mentioned
> > > > in the cover Letter:
> > > >
> > > > 1) drivers/media/i2c/s5k5baf.c
> > > > Always returns -EPROBE_DEFER if getting the clock fails ?!
> > >
> > > This can be fixed later on IMO.
>
> Agreed.
>
> > > >
> > > > 2) drivers/media/i2c/mt9t112.c
> > > > This drivers seems to be implementing the behaviour of
> > > > devm_clk_get_optional() while using devm_clk_get(): remove it from the
> > > > list of changed drivers ?
> > >
> > > There are no DT bindings. I wonder if this is still relevant. Maybe Jacopo
> > > has an idea?
> >
> > Not really, the driver has been ported to be a regular i2c driver from
> > its soc-camera-based legacy implementation but has seen basically no
> > development since then, if not for sub-system wide changes or odd fixes.
> >
> > Looking at the implementatio, the driver indeed seems to implement what
> > _optional() does already, so it might be more opportune to convert it
> > to _optional() first maybe ? However in my understanding your patch
> > doesn't change the current behaviour, doesn't it ? In this case I think
> > you can go ahead.
>
> Agreed too.
>
> > > > 3) drivers/media/i2c/ov8856.c
> > > > Getting the clock, setting the rate, getting the optional gpio and the
> > > > regulator_bulk is only when the fwnode is NOT acpi.
> > >
> > > Isn't this a similar case than the other sensor (which I can't remember
> > > anymore), where effectively the rate set couldn't be different than the
> > > clock already had?
> > >
> > > I think this also could be handled after this set.
>
> Ideally we should stop setting the rate and simplify the driver, but we
> have to be careful about regressions. I agree with Sakari, we can
> address this later.
>
Ok, good to know.
Thank you everyone for the reviews!
--
Kind Regards
Mehdi Djait
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-06-26 13:33 ` [PATCH v2 01/48] media: v4l2-common: " Mehdi Djait
2025-06-27 7:12 ` Sakari Ailus
@ 2025-07-06 0:30 ` Laurent Pinchart
2025-07-07 14:30 ` Mehdi Djait
2025-08-13 10:15 ` [PATCH v2 01/48] " Hans Verkuil
2 siblings, 1 reply; 72+ messages in thread
From: Laurent Pinchart @ 2025-07-06 0:30 UTC (permalink / raw)
To: Mehdi Djait
Cc: sakari.ailus, stanislaw.gruszka, hdegoede, arnd, alain.volmat,
andrzej.hajda, benjamin.mugnier, dave.stevenson, hansg, hverkuil,
jacopo.mondi, kieran.bingham, khalasa, mani, m.felsch,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, umang.jain, linux-media,
Lad Prabhakar
Hi Mehdi,
One more comment.
On Thu, Jun 26, 2025 at 03:33:52PM +0200, Mehdi Djait wrote:
> Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> platforms to retrieve a reference to the clock producer from firmware.
>
> This helper behaves the same as devm_clk_get() except where there is
> no clock producer like in ACPI-based platforms.
>
> For ACPI-based platforms the function will read the "clock-frequency"
> ACPI _DSD property and register a fixed frequency clock with the frequency
> indicated in the property.
>
> This function also handles the special ACPI-based system case where:
> The clock-frequency _DSD property is present.
> A reference to the clock producer is present, where the clock is provided
> by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> In this case try to set the clock-frequency value to the provided clock.
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> ---
> drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
> include/media/v4l2-common.h | 27 ++++++++++++++
> 2 files changed, 79 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> index bd160a8c9efe..ac98895b0394 100644
> --- a/drivers/media/v4l2-core/v4l2-common.c
> +++ b/drivers/media/v4l2-core/v4l2-common.c
> @@ -34,6 +34,9 @@
> * Added Gerd Knorrs v4l1 enhancements (Justin Schoeman)
> */
>
> +#include <linux/clk.h>
> +#include <linux/clkdev.h>
> +#include <linux/clk-provider.h>
> #include <linux/module.h>
> #include <linux/types.h>
> #include <linux/kernel.h>
> @@ -673,3 +676,52 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> return 0;
> }
> EXPORT_SYMBOL_GPL(v4l2_link_freq_to_bitmap);
> +
> +struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id)
> +{
> + const char *clk_id __free(kfree) = NULL;
> + struct clk_hw *clk_hw;
> + struct clk *clk;
> + bool of_node;
> + u32 rate;
> + int ret;
> +
> + clk = devm_clk_get_optional(dev, id);
Shouldn't your return here if there's an error ?
if (IS_ERR(clk))
return clk;
because ...
> + ret = device_property_read_u32(dev, "clock-frequency", &rate);
> + of_node = is_of_node(dev_fwnode(dev));
> +
> + if (clk) {
> + if (!ret && !of_node) {
> + ret = clk_set_rate(clk, rate);
... here clk_set_rate() will dereference clk and crash if it's an error
pointer ...
> + if (ret) {
> + dev_err(dev, "Failed to set clock rate: %u\n",
> + rate);
> + return ERR_PTR(ret);
> + }
> + }
> + return clk;
> + }
> +
> + if (PTR_ERR(clk) == -EPROBE_DEFER)
> + return ERR_PTR(-EPROBE_DEFER);
... and this will never be reached.
> +
> + if (!IS_ENABLED(CONFIG_COMMON_CLK) || of_node)
> + return ERR_PTR(-ENOENT);
> +
> + if (ret)
> + return ERR_PTR(ret == -EINVAL ? -EPROBE_DEFER : ret);
> +
> + if (!id) {
> + clk_id = kasprintf(GFP_KERNEL, "clk-%s", dev_name(dev));
> + if (!clk_id)
> + return ERR_PTR(-ENOMEM);
> + id = clk_id;
> + }
> +
> + clk_hw = devm_clk_hw_register_fixed_rate(dev, id, NULL, 0, rate);
> + if (IS_ERR(clk_hw))
> + return ERR_CAST(clk_hw);
> +
> + return clk_hw->clk;
> +}
> +EXPORT_SYMBOL_GPL(devm_v4l2_sensor_clk_get);
> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> index 0a43f56578bc..1c79ca4d5c73 100644
> --- a/include/media/v4l2-common.h
> +++ b/include/media/v4l2-common.h
> @@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
> struct v4l2_device;
> struct v4l2_subdev;
> struct v4l2_subdev_ops;
> +struct clk;
Please keep forward declarations sorted.
You don't need to resubmit the whole series for this, but it would be
useful if you could retest it, and then send a new version of just this
patch.
>
> /* I2C Helper functions */
> #include <linux/i2c.h>
> @@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> unsigned int num_of_driver_link_freqs,
> unsigned long *bitmap);
>
> +/**
> + * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
> + * for a camera sensor.
> + *
> + * @dev: device for v4l2 sensor clock "consumer"
> + * @id: clock consumer ID
> + *
> + * This function behaves the same way as devm_clk_get() except where there
> + * is no clock producer like in ACPI-based platforms.
> + *
> + * For ACPI-based platforms, the function will read the "clock-frequency"
> + * ACPI _DSD property and register a fixed-clock with the frequency indicated
> + * in the property.
> + *
> + * This function also handles the special ACPI-based system case where:
> + *
> + * * The clock-frequency _DSD property is present.
> + * * A reference to the clock producer is present, where the clock is provided
> + * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> + *
> + * In this case try to set the clock-frequency value to the provided clock.
> + *
> + * Returns a pointer to a struct clk on success or an error pointer on failure.
> + */
> +struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id);
> +
> static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf)
> {
> /*
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-07-06 0:30 ` Laurent Pinchart
@ 2025-07-07 14:30 ` Mehdi Djait
2025-07-07 14:32 ` [PATCH v3] " Mehdi Djait
0 siblings, 1 reply; 72+ messages in thread
From: Mehdi Djait @ 2025-07-07 14:30 UTC (permalink / raw)
To: Laurent Pinchart
Cc: sakari.ailus, stanislaw.gruszka, hdegoede, arnd, alain.volmat,
andrzej.hajda, benjamin.mugnier, dave.stevenson, hansg, hverkuil,
jacopo.mondi, kieran.bingham, khalasa, mani, m.felsch,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, umang.jain, linux-media,
Lad Prabhakar
Hi Laurent,
Thank you for the review!
On Sun, Jul 06, 2025 at 03:30:27AM +0300, Laurent Pinchart wrote:
> Hi Mehdi,
>
> One more comment.
>
> On Thu, Jun 26, 2025 at 03:33:52PM +0200, Mehdi Djait wrote:
> > Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> > platforms to retrieve a reference to the clock producer from firmware.
> >
> > This helper behaves the same as devm_clk_get() except where there is
> > no clock producer like in ACPI-based platforms.
> >
> > For ACPI-based platforms the function will read the "clock-frequency"
> > ACPI _DSD property and register a fixed frequency clock with the frequency
> > indicated in the property.
> >
> > This function also handles the special ACPI-based system case where:
> > The clock-frequency _DSD property is present.
> > A reference to the clock producer is present, where the clock is provided
> > by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> > In this case try to set the clock-frequency value to the provided clock.
> >
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> > ---
> > drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
> > include/media/v4l2-common.h | 27 ++++++++++++++
> > 2 files changed, 79 insertions(+)
> >
> > diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> > index bd160a8c9efe..ac98895b0394 100644
> > --- a/drivers/media/v4l2-core/v4l2-common.c
> > +++ b/drivers/media/v4l2-core/v4l2-common.c
> > @@ -34,6 +34,9 @@
> > * Added Gerd Knorrs v4l1 enhancements (Justin Schoeman)
> > */
> >
> > +#include <linux/clk.h>
> > +#include <linux/clkdev.h>
> > +#include <linux/clk-provider.h>
> > #include <linux/module.h>
> > #include <linux/types.h>
> > #include <linux/kernel.h>
> > @@ -673,3 +676,52 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> > return 0;
> > }
> > EXPORT_SYMBOL_GPL(v4l2_link_freq_to_bitmap);
> > +
> > +struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id)
> > +{
> > + const char *clk_id __free(kfree) = NULL;
> > + struct clk_hw *clk_hw;
> > + struct clk *clk;
> > + bool of_node;
> > + u32 rate;
> > + int ret;
> > +
> > + clk = devm_clk_get_optional(dev, id);
>
> Shouldn't your return here if there's an error ?
>
> if (IS_ERR(clk))
> return clk;
>
> because ...
>
> > + ret = device_property_read_u32(dev, "clock-frequency", &rate);
> > + of_node = is_of_node(dev_fwnode(dev));
> > +
> > + if (clk) {
> > + if (!ret && !of_node) {
> > + ret = clk_set_rate(clk, rate);
>
> ... here clk_set_rate() will dereference clk and crash if it's an error
> pointer ...
>
Ack.
> > + if (ret) {
> > + dev_err(dev, "Failed to set clock rate: %u\n",
> > + rate);
> > + return ERR_PTR(ret);
> > + }
> > + }
> > + return clk;
> > + }
> > +
> > + if (PTR_ERR(clk) == -EPROBE_DEFER)
> > + return ERR_PTR(-EPROBE_DEFER);
>
> ... and this will never be reached.
>
Ack.
> > +
> > + if (!IS_ENABLED(CONFIG_COMMON_CLK) || of_node)
> > + return ERR_PTR(-ENOENT);
> > +
> > + if (ret)
> > + return ERR_PTR(ret == -EINVAL ? -EPROBE_DEFER : ret);
> > +
> > + if (!id) {
> > + clk_id = kasprintf(GFP_KERNEL, "clk-%s", dev_name(dev));
> > + if (!clk_id)
> > + return ERR_PTR(-ENOMEM);
> > + id = clk_id;
> > + }
> > +
> > + clk_hw = devm_clk_hw_register_fixed_rate(dev, id, NULL, 0, rate);
> > + if (IS_ERR(clk_hw))
> > + return ERR_CAST(clk_hw);
> > +
> > + return clk_hw->clk;
> > +}
> > +EXPORT_SYMBOL_GPL(devm_v4l2_sensor_clk_get);
> > diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> > index 0a43f56578bc..1c79ca4d5c73 100644
> > --- a/include/media/v4l2-common.h
> > +++ b/include/media/v4l2-common.h
> > @@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
> > struct v4l2_device;
> > struct v4l2_subdev;
> > struct v4l2_subdev_ops;
> > +struct clk;
>
> Please keep forward declarations sorted.
>
> You don't need to resubmit the whole series for this, but it would be
> useful if you could retest it, and then send a new version of just this
> patch.
You are totally right about the comment.
@Sakari: I will send the patch as a reply to this, I went ahead and
added the missing leading dots you mentioned in your reply. Tell me if
this okay for you when you pick up the patches or should I send you the
complete v3 ?
--
Kind Regards
Mehdi Djait
^ permalink raw reply [flat|nested] 72+ messages in thread
* [PATCH v3] media: v4l2-common: Add a helper for obtaining the clock producer
2025-07-07 14:30 ` Mehdi Djait
@ 2025-07-07 14:32 ` Mehdi Djait
2025-07-07 21:55 ` Sakari Ailus
0 siblings, 1 reply; 72+ messages in thread
From: Mehdi Djait @ 2025-07-07 14:32 UTC (permalink / raw)
To: mehdi.djait
Cc: alain.volmat, andrzej.hajda, arnd, benjamin.mugnier, dan.scally,
dave.stevenson, hansg, hdegoede, hverkuil, jacopo.mondi, khalasa,
kieran.bingham, laurent.pinchart, linux-media, m.felsch, mani,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, pavel, prabhakar.mahadev-lad.rj,
rashanmu, ribalda, sakari.ailus, slongerbeam, stanislaw.gruszka,
tomi.valkeinen
Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
platforms to retrieve a reference to the clock producer from firmware.
This helper behaves the same as devm_clk_get() except where there is
no clock producer like in ACPI-based platforms.
For ACPI-based platforms the function will read the "clock-frequency"
ACPI _DSD property and register a fixed frequency clock with the frequency
indicated in the property.
This function also handles the special ACPI-based system case where:
. The clock-frequency _DSD property is present.
. A reference to the clock producer is present, where the clock is provided
by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
In this case try to set the clock-frequency value to the provided clock.
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
---
drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
include/media/v4l2-common.h | 27 ++++++++++++++
2 files changed, 79 insertions(+)
diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
index bd160a8c9efe..fedb21a74671 100644
--- a/drivers/media/v4l2-core/v4l2-common.c
+++ b/drivers/media/v4l2-core/v4l2-common.c
@@ -34,6 +34,9 @@
* Added Gerd Knorrs v4l1 enhancements (Justin Schoeman)
*/
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <linux/clk-provider.h>
#include <linux/module.h>
#include <linux/types.h>
#include <linux/kernel.h>
@@ -673,3 +676,52 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
return 0;
}
EXPORT_SYMBOL_GPL(v4l2_link_freq_to_bitmap);
+
+struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id)
+{
+ const char *clk_id __free(kfree) = NULL;
+ struct clk_hw *clk_hw;
+ struct clk *clk;
+ bool of_node;
+ u32 rate;
+ int ret;
+
+ clk = devm_clk_get_optional(dev, id);
+ if (IS_ERR(clk))
+ return clk;
+
+ ret = device_property_read_u32(dev, "clock-frequency", &rate);
+ of_node = is_of_node(dev_fwnode(dev));
+
+ if (clk) {
+ if (!ret && !of_node) {
+ ret = clk_set_rate(clk, rate);
+ if (ret) {
+ dev_err(dev, "Failed to set clock rate: %u\n",
+ rate);
+ return ERR_PTR(ret);
+ }
+ }
+ return clk;
+ }
+
+ if (!IS_ENABLED(CONFIG_COMMON_CLK) || of_node)
+ return ERR_PTR(-ENOENT);
+
+ if (ret)
+ return ERR_PTR(ret == -EINVAL ? -EPROBE_DEFER : ret);
+
+ if (!id) {
+ clk_id = kasprintf(GFP_KERNEL, "clk-%s", dev_name(dev));
+ if (!clk_id)
+ return ERR_PTR(-ENOMEM);
+ id = clk_id;
+ }
+
+ clk_hw = devm_clk_hw_register_fixed_rate(dev, id, NULL, 0, rate);
+ if (IS_ERR(clk_hw))
+ return ERR_CAST(clk_hw);
+
+ return clk_hw->clk;
+}
+EXPORT_SYMBOL_GPL(devm_v4l2_sensor_clk_get);
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 0a43f56578bc..9d6c236e8f14 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -97,6 +97,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
/* ------------------------------------------------------------------------- */
+struct clk;
struct v4l2_device;
struct v4l2_subdev;
struct v4l2_subdev_ops;
@@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
unsigned int num_of_driver_link_freqs,
unsigned long *bitmap);
+/**
+ * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
+ * for a camera sensor.
+ *
+ * @dev: device for v4l2 sensor clock "consumer"
+ * @id: clock consumer ID
+ *
+ * This function behaves the same way as devm_clk_get() except where there
+ * is no clock producer like in ACPI-based platforms.
+ *
+ * For ACPI-based platforms, the function will read the "clock-frequency"
+ * ACPI _DSD property and register a fixed-clock with the frequency indicated
+ * in the property.
+ *
+ * This function also handles the special ACPI-based system case where:
+ *
+ * * The clock-frequency _DSD property is present.
+ * * A reference to the clock producer is present, where the clock is provided
+ * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
+ *
+ * In this case try to set the clock-frequency value to the provided clock.
+ *
+ * Returns a pointer to a struct clk on success or an error pointer on failure.
+ */
+struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id);
+
static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf)
{
/*
--
2.49.0
^ permalink raw reply related [flat|nested] 72+ messages in thread
* Re: [PATCH v3] media: v4l2-common: Add a helper for obtaining the clock producer
2025-07-07 14:32 ` [PATCH v3] " Mehdi Djait
@ 2025-07-07 21:55 ` Sakari Ailus
0 siblings, 0 replies; 72+ messages in thread
From: Sakari Ailus @ 2025-07-07 21:55 UTC (permalink / raw)
To: Mehdi Djait
Cc: alain.volmat, andrzej.hajda, arnd, benjamin.mugnier, dan.scally,
dave.stevenson, hansg, hdegoede, hverkuil, jacopo.mondi, khalasa,
kieran.bingham, laurent.pinchart, linux-media, m.felsch, mani,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, pavel, prabhakar.mahadev-lad.rj,
rashanmu, ribalda, slongerbeam, stanislaw.gruszka, tomi.valkeinen
Hi Mehdi,
On Mon, Jul 07, 2025 at 04:32:53PM +0200, Mehdi Djait wrote:
> Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> platforms to retrieve a reference to the clock producer from firmware.
>
> This helper behaves the same as devm_clk_get() except where there is
> no clock producer like in ACPI-based platforms.
>
> For ACPI-based platforms the function will read the "clock-frequency"
> ACPI _DSD property and register a fixed frequency clock with the frequency
> indicated in the property.
>
> This function also handles the special ACPI-based system case where:
> . The clock-frequency _DSD property is present.
> . A reference to the clock producer is present, where the clock is provided
> by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> In this case try to set the clock-frequency value to the provided clock.
How about adding
select COMMON_CLK if ACPI && !HAVE_LEGACY_CLK
to menuconfig VIDEO_CAMERA_SENSOR, in order to ensure COMMON_CLK is enabled
on ACPI platforms where it becomes a necessity for sensors?
This should probably be a new patch?
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-06-26 13:33 ` [PATCH v2 01/48] media: v4l2-common: " Mehdi Djait
2025-06-27 7:12 ` Sakari Ailus
2025-07-06 0:30 ` Laurent Pinchart
@ 2025-08-13 10:15 ` Hans Verkuil
2025-08-13 12:59 ` Sakari Ailus
2 siblings, 1 reply; 72+ messages in thread
From: Hans Verkuil @ 2025-08-13 10:15 UTC (permalink / raw)
To: Mehdi Djait, laurent.pinchart, sakari.ailus
Cc: stanislaw.gruszka, hdegoede, arnd, alain.volmat, andrzej.hajda,
benjamin.mugnier, dave.stevenson, hansg, hverkuil, jacopo.mondi,
kieran.bingham, khalasa, mani, m.felsch, matthias.fend, mchehab,
michael.riesch, naush, nicholas, nicolas.dufresne, paul.elder,
dan.scally, pavel, rashanmu, ribalda, slongerbeam, tomi.valkeinen,
umang.jain, linux-media, Lad Prabhakar
Hi Mehdi, Sakari, Laurent,
On 26/06/2025 15:33, Mehdi Djait wrote:
> Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> platforms to retrieve a reference to the clock producer from firmware.
>
> This helper behaves the same as devm_clk_get() except where there is
> no clock producer like in ACPI-based platforms.
>
> For ACPI-based platforms the function will read the "clock-frequency"
> ACPI _DSD property and register a fixed frequency clock with the frequency
> indicated in the property.
>
> This function also handles the special ACPI-based system case where:
> The clock-frequency _DSD property is present.
> A reference to the clock producer is present, where the clock is provided
> by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> In this case try to set the clock-frequency value to the provided clock.
On irc I wondered about the name of the new function since it is sensor
specific, and if it can also be used for e.g. video receivers, then it
should be renamed to something more generic.
According to Laurent there is no ACPI standard for video receivers, so
that's the reason this is sensor specific.
I'd like to see that documented in this patch. Either in the commit log,
or, preferred, in the header in the function description.
I made a suggestion below.
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> ---
> drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
> include/media/v4l2-common.h | 27 ++++++++++++++
> 2 files changed, 79 insertions(+)
>
> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
<snip>
> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> index 0a43f56578bc..1c79ca4d5c73 100644
> --- a/include/media/v4l2-common.h
> +++ b/include/media/v4l2-common.h
> @@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
> struct v4l2_device;
> struct v4l2_subdev;
> struct v4l2_subdev_ops;
> +struct clk;
>
> /* I2C Helper functions */
> #include <linux/i2c.h>
> @@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> unsigned int num_of_driver_link_freqs,
> unsigned long *bitmap);
>
> +/**
> + * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
> + * for a camera sensor.
> + *
> + * @dev: device for v4l2 sensor clock "consumer"
> + * @id: clock consumer ID
> + *
> + * This function behaves the same way as devm_clk_get() except where there
> + * is no clock producer like in ACPI-based platforms.
> + *
> + * For ACPI-based platforms, the function will read the "clock-frequency"
> + * ACPI _DSD property and register a fixed-clock with the frequency indicated
> + * in the property.
> + *
> + * This function also handles the special ACPI-based system case where:
> + *
> + * * The clock-frequency _DSD property is present.
> + * * A reference to the clock producer is present, where the clock is provided
> + * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> + *
> + * In this case try to set the clock-frequency value to the provided clock.
*
* While ACPI has standardized sensor support, there is no standard support for
* e.g. video receivers. So this function is specific to sensors, hence the
* chosen function name.
Better suggestions are welcome.
If it is just adding a paragraph, then I can just add that manually. If the change
is more involved, then a v2.1 for just this patch should be posted.
Other than this, the series looks good.
Regards,
Hans
> + *
> + * Returns a pointer to a struct clk on success or an error pointer on failure.
> + */
> +struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id);
> +
> static inline u64 v4l2_buffer_get_timestamp(const struct v4l2_buffer *buf)
> {
> /*
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-08-13 10:15 ` [PATCH v2 01/48] " Hans Verkuil
@ 2025-08-13 12:59 ` Sakari Ailus
2025-08-13 13:08 ` Laurent Pinchart
0 siblings, 1 reply; 72+ messages in thread
From: Sakari Ailus @ 2025-08-13 12:59 UTC (permalink / raw)
To: Hans Verkuil
Cc: Mehdi Djait, laurent.pinchart, sakari.ailus, stanislaw.gruszka,
hdegoede, arnd, alain.volmat, andrzej.hajda, benjamin.mugnier,
dave.stevenson, hansg, hverkuil, jacopo.mondi, kieran.bingham,
khalasa, mani, m.felsch, matthias.fend, mchehab, michael.riesch,
naush, nicholas, nicolas.dufresne, paul.elder, dan.scally, pavel,
rashanmu, ribalda, slongerbeam, tomi.valkeinen, umang.jain,
linux-media, Lad Prabhakar
Hi Hans,
On Wed, Aug 13, 2025 at 12:15:29PM +0200, Hans Verkuil wrote:
> Hi Mehdi, Sakari, Laurent,
>
> On 26/06/2025 15:33, Mehdi Djait wrote:
> > Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> > platforms to retrieve a reference to the clock producer from firmware.
> >
> > This helper behaves the same as devm_clk_get() except where there is
> > no clock producer like in ACPI-based platforms.
> >
> > For ACPI-based platforms the function will read the "clock-frequency"
> > ACPI _DSD property and register a fixed frequency clock with the frequency
> > indicated in the property.
> >
> > This function also handles the special ACPI-based system case where:
> > The clock-frequency _DSD property is present.
> > A reference to the clock producer is present, where the clock is provided
> > by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> > In this case try to set the clock-frequency value to the provided clock.
>
> On irc I wondered about the name of the new function since it is sensor
> specific, and if it can also be used for e.g. video receivers, then it
> should be renamed to something more generic.
>
> According to Laurent there is no ACPI standard for video receivers, so
> that's the reason this is sensor specific.
>
> I'd like to see that documented in this patch. Either in the commit log,
> or, preferred, in the header in the function description.
Given this patch has been around for quite some time and I've sent a PR on
it, I'd prefer to proceed with the current PR. I'm fine with adding more
documentation though if you think we should do that.
>
> I made a suggestion below.
>
> >
> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> > ---
> > drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
> > include/media/v4l2-common.h | 27 ++++++++++++++
> > 2 files changed, 79 insertions(+)
> >
> > diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
>
> <snip>
>
> > diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> > index 0a43f56578bc..1c79ca4d5c73 100644
> > --- a/include/media/v4l2-common.h
> > +++ b/include/media/v4l2-common.h
> > @@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
> > struct v4l2_device;
> > struct v4l2_subdev;
> > struct v4l2_subdev_ops;
> > +struct clk;
> >
> > /* I2C Helper functions */
> > #include <linux/i2c.h>
> > @@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> > unsigned int num_of_driver_link_freqs,
> > unsigned long *bitmap);
> >
> > +/**
> > + * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
> > + * for a camera sensor.
> > + *
> > + * @dev: device for v4l2 sensor clock "consumer"
> > + * @id: clock consumer ID
> > + *
> > + * This function behaves the same way as devm_clk_get() except where there
> > + * is no clock producer like in ACPI-based platforms.
> > + *
> > + * For ACPI-based platforms, the function will read the "clock-frequency"
> > + * ACPI _DSD property and register a fixed-clock with the frequency indicated
> > + * in the property.
> > + *
> > + * This function also handles the special ACPI-based system case where:
> > + *
> > + * * The clock-frequency _DSD property is present.
> > + * * A reference to the clock producer is present, where the clock is provided
> > + * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> > + *
> > + * In this case try to set the clock-frequency value to the provided clock.
>
> *
> * While ACPI has standardized sensor support, there is no standard support for
> * e.g. video receivers. So this function is specific to sensors, hence the
> * chosen function name.
>
> Better suggestions are welcome.
ACPI itself does not standardise camera sensor support. What driver authors
should know indeed is that this function provides a clock that can be at
least queried for frequency, independently of how that clock is controlled
or how its frequency is configured.
How about:
* This function may be used in camera sensor drivers only.
>
> If it is just adding a paragraph, then I can just add that manually. If the change
> is more involved, then a v2.1 for just this patch should be posted.
>
> Other than this, the series looks good.
--
Kind regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-08-13 12:59 ` Sakari Ailus
@ 2025-08-13 13:08 ` Laurent Pinchart
2025-08-13 13:22 ` Sakari Ailus
2025-08-13 13:23 ` Hans Verkuil
0 siblings, 2 replies; 72+ messages in thread
From: Laurent Pinchart @ 2025-08-13 13:08 UTC (permalink / raw)
To: Sakari Ailus
Cc: Hans Verkuil, Mehdi Djait, sakari.ailus, stanislaw.gruszka,
hdegoede, arnd, alain.volmat, andrzej.hajda, benjamin.mugnier,
dave.stevenson, hansg, hverkuil, jacopo.mondi, kieran.bingham,
khalasa, mani, m.felsch, matthias.fend, mchehab, michael.riesch,
naush, nicholas, nicolas.dufresne, paul.elder, dan.scally, pavel,
rashanmu, ribalda, slongerbeam, tomi.valkeinen, umang.jain,
linux-media, Lad Prabhakar
On Wed, Aug 13, 2025 at 12:59:36PM +0000, Sakari Ailus wrote:
> On Wed, Aug 13, 2025 at 12:15:29PM +0200, Hans Verkuil wrote:
> > On 26/06/2025 15:33, Mehdi Djait wrote:
> > > Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> > > platforms to retrieve a reference to the clock producer from firmware.
> > >
> > > This helper behaves the same as devm_clk_get() except where there is
> > > no clock producer like in ACPI-based platforms.
> > >
> > > For ACPI-based platforms the function will read the "clock-frequency"
> > > ACPI _DSD property and register a fixed frequency clock with the frequency
> > > indicated in the property.
> > >
> > > This function also handles the special ACPI-based system case where:
> > > The clock-frequency _DSD property is present.
> > > A reference to the clock producer is present, where the clock is provided
> > > by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> > > In this case try to set the clock-frequency value to the provided clock.
> >
> > On irc I wondered about the name of the new function since it is sensor
> > specific, and if it can also be used for e.g. video receivers, then it
> > should be renamed to something more generic.
> >
> > According to Laurent there is no ACPI standard for video receivers, so
> > that's the reason this is sensor specific.
> >
> > I'd like to see that documented in this patch. Either in the commit log,
> > or, preferred, in the header in the function description.
>
> Given this patch has been around for quite some time and I've sent a PR on
> it, I'd prefer to proceed with the current PR. I'm fine with adding more
> documentation though if you think we should do that.
How about a separate patch that Hans can merge just on top of your PR ?
Could you send one ?
> > I made a suggestion below.
> >
> > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> > > ---
> > > drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
> > > include/media/v4l2-common.h | 27 ++++++++++++++
> > > 2 files changed, 79 insertions(+)
> > >
> > > diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> >
> > <snip>
> >
> > > diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> > > index 0a43f56578bc..1c79ca4d5c73 100644
> > > --- a/include/media/v4l2-common.h
> > > +++ b/include/media/v4l2-common.h
> > > @@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
> > > struct v4l2_device;
> > > struct v4l2_subdev;
> > > struct v4l2_subdev_ops;
> > > +struct clk;
> > >
> > > /* I2C Helper functions */
> > > #include <linux/i2c.h>
> > > @@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> > > unsigned int num_of_driver_link_freqs,
> > > unsigned long *bitmap);
> > >
> > > +/**
> > > + * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
> > > + * for a camera sensor.
> > > + *
> > > + * @dev: device for v4l2 sensor clock "consumer"
> > > + * @id: clock consumer ID
> > > + *
> > > + * This function behaves the same way as devm_clk_get() except where there
> > > + * is no clock producer like in ACPI-based platforms.
> > > + *
> > > + * For ACPI-based platforms, the function will read the "clock-frequency"
> > > + * ACPI _DSD property and register a fixed-clock with the frequency indicated
> > > + * in the property.
> > > + *
> > > + * This function also handles the special ACPI-based system case where:
> > > + *
> > > + * * The clock-frequency _DSD property is present.
> > > + * * A reference to the clock producer is present, where the clock is provided
> > > + * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> > > + *
> > > + * In this case try to set the clock-frequency value to the provided clock.
> >
> > *
> > * While ACPI has standardized sensor support, there is no standard support for
> > * e.g. video receivers. So this function is specific to sensors, hence the
> > * chosen function name.
> >
> > Better suggestions are welcome.
>
> ACPI itself does not standardise camera sensor support. What driver authors
But there's a de facto standard that makes this helper function
suitable, isn't there ?
> should know indeed is that this function provides a clock that can be at
> least queried for frequency, independently of how that clock is controlled
> or how its frequency is configured.
>
> How about:
>
> * This function may be used in camera sensor drivers only.
>
> > If it is just adding a paragraph, then I can just add that manually. If the change
> > is more involved, then a v2.1 for just this patch should be posted.
> >
> > Other than this, the series looks good.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-08-13 13:08 ` Laurent Pinchart
@ 2025-08-13 13:22 ` Sakari Ailus
2025-08-13 13:23 ` Hans Verkuil
1 sibling, 0 replies; 72+ messages in thread
From: Sakari Ailus @ 2025-08-13 13:22 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Hans Verkuil, Mehdi Djait, sakari.ailus, stanislaw.gruszka,
hdegoede, arnd, alain.volmat, andrzej.hajda, benjamin.mugnier,
dave.stevenson, hansg, hverkuil, jacopo.mondi, kieran.bingham,
khalasa, mani, m.felsch, matthias.fend, mchehab, michael.riesch,
naush, nicholas, nicolas.dufresne, paul.elder, dan.scally, pavel,
rashanmu, ribalda, slongerbeam, tomi.valkeinen, umang.jain,
linux-media, Lad Prabhakar
Hi Laurent,
On Wed, Aug 13, 2025 at 04:08:31PM +0300, Laurent Pinchart wrote:
> On Wed, Aug 13, 2025 at 12:59:36PM +0000, Sakari Ailus wrote:
> > On Wed, Aug 13, 2025 at 12:15:29PM +0200, Hans Verkuil wrote:
> > > On 26/06/2025 15:33, Mehdi Djait wrote:
> > > > Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> > > > platforms to retrieve a reference to the clock producer from firmware.
> > > >
> > > > This helper behaves the same as devm_clk_get() except where there is
> > > > no clock producer like in ACPI-based platforms.
> > > >
> > > > For ACPI-based platforms the function will read the "clock-frequency"
> > > > ACPI _DSD property and register a fixed frequency clock with the frequency
> > > > indicated in the property.
> > > >
> > > > This function also handles the special ACPI-based system case where:
> > > > The clock-frequency _DSD property is present.
> > > > A reference to the clock producer is present, where the clock is provided
> > > > by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> > > > In this case try to set the clock-frequency value to the provided clock.
> > >
> > > On irc I wondered about the name of the new function since it is sensor
> > > specific, and if it can also be used for e.g. video receivers, then it
> > > should be renamed to something more generic.
> > >
> > > According to Laurent there is no ACPI standard for video receivers, so
> > > that's the reason this is sensor specific.
> > >
> > > I'd like to see that documented in this patch. Either in the commit log,
> > > or, preferred, in the header in the function description.
> >
> > Given this patch has been around for quite some time and I've sent a PR on
> > it, I'd prefer to proceed with the current PR. I'm fine with adding more
> > documentation though if you think we should do that.
>
> How about a separate patch that Hans can merge just on top of your PR ?
> Could you send one ?
Sure. Let's try to agree on what it should contain. :-)
>
> > > I made a suggestion below.
> > >
> > > > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> > > > Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> > > > ---
> > > > drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
> > > > include/media/v4l2-common.h | 27 ++++++++++++++
> > > > 2 files changed, 79 insertions(+)
> > > >
> > > > diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> > >
> > > <snip>
> > >
> > > > diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> > > > index 0a43f56578bc..1c79ca4d5c73 100644
> > > > --- a/include/media/v4l2-common.h
> > > > +++ b/include/media/v4l2-common.h
> > > > @@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
> > > > struct v4l2_device;
> > > > struct v4l2_subdev;
> > > > struct v4l2_subdev_ops;
> > > > +struct clk;
> > > >
> > > > /* I2C Helper functions */
> > > > #include <linux/i2c.h>
> > > > @@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> > > > unsigned int num_of_driver_link_freqs,
> > > > unsigned long *bitmap);
> > > >
> > > > +/**
> > > > + * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
> > > > + * for a camera sensor.
> > > > + *
> > > > + * @dev: device for v4l2 sensor clock "consumer"
> > > > + * @id: clock consumer ID
> > > > + *
> > > > + * This function behaves the same way as devm_clk_get() except where there
> > > > + * is no clock producer like in ACPI-based platforms.
> > > > + *
> > > > + * For ACPI-based platforms, the function will read the "clock-frequency"
> > > > + * ACPI _DSD property and register a fixed-clock with the frequency indicated
> > > > + * in the property.
> > > > + *
> > > > + * This function also handles the special ACPI-based system case where:
> > > > + *
> > > > + * * The clock-frequency _DSD property is present.
> > > > + * * A reference to the clock producer is present, where the clock is provided
> > > > + * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> > > > + *
> > > > + * In this case try to set the clock-frequency value to the provided clock.
> > >
> > > *
> > > * While ACPI has standardized sensor support, there is no standard support for
> > > * e.g. video receivers. So this function is specific to sensors, hence the
> > > * chosen function name.
> > >
> > > Better suggestions are welcome.
> >
> > ACPI itself does not standardise camera sensor support. What driver authors
>
> But there's a de facto standard that makes this helper function
> suitable, isn't there ?
In this context DisCo for Imaging and Intel Windows ACPI camera description
are worth mentioning. I wouldn't call the latter a "standard" though. But
it doesn't matter whether it is or not, all the caller needs to know is
that the function returns a usable clock.
>
> > should know indeed is that this function provides a clock that can be at
> > least queried for frequency, independently of how that clock is controlled
> > or how its frequency is configured.
> >
> > How about:
> >
> > * This function may be used in camera sensor drivers only.
> >
> > > If it is just adding a paragraph, then I can just add that manually. If the change
> > > is more involved, then a v2.1 for just this patch should be posted.
> > >
> > > Other than this, the series looks good.
>
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-08-13 13:08 ` Laurent Pinchart
2025-08-13 13:22 ` Sakari Ailus
@ 2025-08-13 13:23 ` Hans Verkuil
2025-08-13 14:49 ` Sakari Ailus
1 sibling, 1 reply; 72+ messages in thread
From: Hans Verkuil @ 2025-08-13 13:23 UTC (permalink / raw)
To: Laurent Pinchart, Sakari Ailus
Cc: Mehdi Djait, sakari.ailus, stanislaw.gruszka, hdegoede, arnd,
alain.volmat, andrzej.hajda, benjamin.mugnier, dave.stevenson,
hansg, hverkuil, jacopo.mondi, kieran.bingham, khalasa, mani,
m.felsch, matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, umang.jain, linux-media,
Lad Prabhakar
On 13/08/2025 15:08, Laurent Pinchart wrote:
> On Wed, Aug 13, 2025 at 12:59:36PM +0000, Sakari Ailus wrote:
>> On Wed, Aug 13, 2025 at 12:15:29PM +0200, Hans Verkuil wrote:
>>> On 26/06/2025 15:33, Mehdi Djait wrote:
>>>> Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
>>>> platforms to retrieve a reference to the clock producer from firmware.
>>>>
>>>> This helper behaves the same as devm_clk_get() except where there is
>>>> no clock producer like in ACPI-based platforms.
>>>>
>>>> For ACPI-based platforms the function will read the "clock-frequency"
>>>> ACPI _DSD property and register a fixed frequency clock with the frequency
>>>> indicated in the property.
>>>>
>>>> This function also handles the special ACPI-based system case where:
>>>> The clock-frequency _DSD property is present.
>>>> A reference to the clock producer is present, where the clock is provided
>>>> by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
>>>> In this case try to set the clock-frequency value to the provided clock.
>>>
>>> On irc I wondered about the name of the new function since it is sensor
>>> specific, and if it can also be used for e.g. video receivers, then it
>>> should be renamed to something more generic.
>>>
>>> According to Laurent there is no ACPI standard for video receivers, so
>>> that's the reason this is sensor specific.
>>>
>>> I'd like to see that documented in this patch. Either in the commit log,
>>> or, preferred, in the header in the function description.
>>
>> Given this patch has been around for quite some time and I've sent a PR on
>> it, I'd prefer to proceed with the current PR. I'm fine with adding more
>> documentation though if you think we should do that.
>
> How about a separate patch that Hans can merge just on top of your PR ?
> Could you send one ?
I'd like to have the rationale of why this is a sensor-only function documented.
If I wondered about that, then someone else will likely have the same question.
>
>>> I made a suggestion below.
>>>
>>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>>> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>>>> Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
>>>> ---
>>>> drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
>>>> include/media/v4l2-common.h | 27 ++++++++++++++
>>>> 2 files changed, 79 insertions(+)
>>>>
>>>> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
>>>
>>> <snip>
>>>
>>>> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
>>>> index 0a43f56578bc..1c79ca4d5c73 100644
>>>> --- a/include/media/v4l2-common.h
>>>> +++ b/include/media/v4l2-common.h
>>>> @@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
>>>> struct v4l2_device;
>>>> struct v4l2_subdev;
>>>> struct v4l2_subdev_ops;
>>>> +struct clk;
>>>>
>>>> /* I2C Helper functions */
>>>> #include <linux/i2c.h>
>>>> @@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
>>>> unsigned int num_of_driver_link_freqs,
>>>> unsigned long *bitmap);
>>>>
>>>> +/**
>>>> + * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
>>>> + * for a camera sensor.
>>>> + *
>>>> + * @dev: device for v4l2 sensor clock "consumer"
>>>> + * @id: clock consumer ID
>>>> + *
>>>> + * This function behaves the same way as devm_clk_get() except where there
>>>> + * is no clock producer like in ACPI-based platforms.
>>>> + *
>>>> + * For ACPI-based platforms, the function will read the "clock-frequency"
>>>> + * ACPI _DSD property and register a fixed-clock with the frequency indicated
>>>> + * in the property.
>>>> + *
>>>> + * This function also handles the special ACPI-based system case where:
>>>> + *
>>>> + * * The clock-frequency _DSD property is present.
>>>> + * * A reference to the clock producer is present, where the clock is provided
>>>> + * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
>>>> + *
>>>> + * In this case try to set the clock-frequency value to the provided clock.
>>>
>>> *
>>> * While ACPI has standardized sensor support, there is no standard support for
>>> * e.g. video receivers. So this function is specific to sensors, hence the
>>> * chosen function name.
>>>
>>> Better suggestions are welcome.
>>
>> ACPI itself does not standardise camera sensor support. What driver authors
>
> But there's a de facto standard that makes this helper function
> suitable, isn't there ?
>
>> should know indeed is that this function provides a clock that can be at
>> least queried for frequency, independently of how that clock is controlled
>> or how its frequency is configured.
>>
>> How about:
>>
>> * This function may be used in camera sensor drivers only.
That just restates what is also in the function name. It's the 'why' that I'd
like to know. Even if you simply don't know if this will work for non-sensor
driver, just stating that will help.
Regards,
Hans
>>
>>> If it is just adding a paragraph, then I can just add that manually. If the change
>>> is more involved, then a v2.1 for just this patch should be posted.
>>>
>>> Other than this, the series looks good.
>
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-08-13 13:23 ` Hans Verkuil
@ 2025-08-13 14:49 ` Sakari Ailus
2025-08-13 15:14 ` Hans Verkuil
0 siblings, 1 reply; 72+ messages in thread
From: Sakari Ailus @ 2025-08-13 14:49 UTC (permalink / raw)
To: Hans Verkuil
Cc: Laurent Pinchart, Sakari Ailus, Mehdi Djait, stanislaw.gruszka,
hdegoede, arnd, alain.volmat, andrzej.hajda, benjamin.mugnier,
dave.stevenson, hansg, hverkuil, jacopo.mondi, kieran.bingham,
khalasa, mani, m.felsch, matthias.fend, mchehab, michael.riesch,
naush, nicholas, nicolas.dufresne, paul.elder, dan.scally, pavel,
rashanmu, ribalda, slongerbeam, tomi.valkeinen, umang.jain,
linux-media, Lad Prabhakar
Hi Hans,
On Wed, Aug 13, 2025 at 03:23:18PM +0200, Hans Verkuil wrote:
> On 13/08/2025 15:08, Laurent Pinchart wrote:
> > On Wed, Aug 13, 2025 at 12:59:36PM +0000, Sakari Ailus wrote:
> >> On Wed, Aug 13, 2025 at 12:15:29PM +0200, Hans Verkuil wrote:
> >>> On 26/06/2025 15:33, Mehdi Djait wrote:
> >>>> Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> >>>> platforms to retrieve a reference to the clock producer from firmware.
> >>>>
> >>>> This helper behaves the same as devm_clk_get() except where there is
> >>>> no clock producer like in ACPI-based platforms.
> >>>>
> >>>> For ACPI-based platforms the function will read the "clock-frequency"
> >>>> ACPI _DSD property and register a fixed frequency clock with the frequency
> >>>> indicated in the property.
> >>>>
> >>>> This function also handles the special ACPI-based system case where:
> >>>> The clock-frequency _DSD property is present.
> >>>> A reference to the clock producer is present, where the clock is provided
> >>>> by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> >>>> In this case try to set the clock-frequency value to the provided clock.
> >>>
> >>> On irc I wondered about the name of the new function since it is sensor
> >>> specific, and if it can also be used for e.g. video receivers, then it
> >>> should be renamed to something more generic.
> >>>
> >>> According to Laurent there is no ACPI standard for video receivers, so
> >>> that's the reason this is sensor specific.
> >>>
> >>> I'd like to see that documented in this patch. Either in the commit log,
> >>> or, preferred, in the header in the function description.
> >>
> >> Given this patch has been around for quite some time and I've sent a PR on
> >> it, I'd prefer to proceed with the current PR. I'm fine with adding more
> >> documentation though if you think we should do that.
> >
> > How about a separate patch that Hans can merge just on top of your PR ?
> > Could you send one ?
>
> I'd like to have the rationale of why this is a sensor-only function
> documented. If I wondered about that, then someone else will likely have
> the same question.
>
> >
> >>> I made a suggestion below.
> >>>
> >>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>>> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >>>> Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> >>>> ---
> >>>> drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
> >>>> include/media/v4l2-common.h | 27 ++++++++++++++
> >>>> 2 files changed, 79 insertions(+)
> >>>>
> >>>> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> >>>
> >>> <snip>
> >>>
> >>>> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> >>>> index 0a43f56578bc..1c79ca4d5c73 100644
> >>>> --- a/include/media/v4l2-common.h
> >>>> +++ b/include/media/v4l2-common.h
> >>>> @@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
> >>>> struct v4l2_device;
> >>>> struct v4l2_subdev;
> >>>> struct v4l2_subdev_ops;
> >>>> +struct clk;
> >>>>
> >>>> /* I2C Helper functions */
> >>>> #include <linux/i2c.h>
> >>>> @@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> >>>> unsigned int num_of_driver_link_freqs,
> >>>> unsigned long *bitmap);
> >>>>
> >>>> +/**
> >>>> + * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
> >>>> + * for a camera sensor.
> >>>> + *
> >>>> + * @dev: device for v4l2 sensor clock "consumer"
> >>>> + * @id: clock consumer ID
> >>>> + *
> >>>> + * This function behaves the same way as devm_clk_get() except where there
> >>>> + * is no clock producer like in ACPI-based platforms.
> >>>> + *
> >>>> + * For ACPI-based platforms, the function will read the "clock-frequency"
> >>>> + * ACPI _DSD property and register a fixed-clock with the frequency indicated
> >>>> + * in the property.
> >>>> + *
> >>>> + * This function also handles the special ACPI-based system case where:
> >>>> + *
> >>>> + * * The clock-frequency _DSD property is present.
> >>>> + * * A reference to the clock producer is present, where the clock is provided
> >>>> + * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> >>>> + *
> >>>> + * In this case try to set the clock-frequency value to the provided clock.
> >>>
> >>> *
> >>> * While ACPI has standardized sensor support, there is no standard support for
> >>> * e.g. video receivers. So this function is specific to sensors, hence the
> >>> * chosen function name.
> >>>
> >>> Better suggestions are welcome.
> >>
> >> ACPI itself does not standardise camera sensor support. What driver authors
> >
> > But there's a de facto standard that makes this helper function
> > suitable, isn't there ?
> >
> >> should know indeed is that this function provides a clock that can be at
> >> least queried for frequency, independently of how that clock is controlled
> >> or how its frequency is configured.
> >>
> >> How about:
> >>
> >> * This function may be used in camera sensor drivers only.
>
> That just restates what is also in the function name. It's the 'why' that I'd
> like to know. Even if you simply don't know if this will work for non-sensor
> driver, just stating that will help.
As I replied on #linux-media:
devm_v4l2_sensor_clk_get() in practice provides a clock to camera sensors
which is what they need; other types of devices generally don't care much
about clocks. Why camera sensors are special is that they have a PLL and a
CSI-2 RX the configuration of which depend on the external clock.
Is something like this what you're looking for, or something more
elaborate? There are different ways the clock can be obtained but I'm not
sure we'll need to go to that in the function documentation.
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-08-13 14:49 ` Sakari Ailus
@ 2025-08-13 15:14 ` Hans Verkuil
2025-08-13 19:45 ` Sakari Ailus
2025-08-14 13:50 ` [PATCH 1/1] media: v4l2-common: Improve devm_v4l2_sensor_clk_get() documentation Sakari Ailus
0 siblings, 2 replies; 72+ messages in thread
From: Hans Verkuil @ 2025-08-13 15:14 UTC (permalink / raw)
To: Sakari Ailus
Cc: Laurent Pinchart, Sakari Ailus, Mehdi Djait, stanislaw.gruszka,
hdegoede, arnd, alain.volmat, andrzej.hajda, benjamin.mugnier,
dave.stevenson, hansg, jacopo.mondi, kieran.bingham, khalasa,
mani, m.felsch, matthias.fend, mchehab, michael.riesch, naush,
nicholas, nicolas.dufresne, paul.elder, dan.scally, pavel,
rashanmu, ribalda, slongerbeam, tomi.valkeinen, umang.jain,
linux-media, Lad Prabhakar
On 13/08/2025 16:49, Sakari Ailus wrote:
> Hi Hans,
>
> On Wed, Aug 13, 2025 at 03:23:18PM +0200, Hans Verkuil wrote:
>> On 13/08/2025 15:08, Laurent Pinchart wrote:
>>> On Wed, Aug 13, 2025 at 12:59:36PM +0000, Sakari Ailus wrote:
>>>> On Wed, Aug 13, 2025 at 12:15:29PM +0200, Hans Verkuil wrote:
>>>>> On 26/06/2025 15:33, Mehdi Djait wrote:
>>>>>> Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
>>>>>> platforms to retrieve a reference to the clock producer from firmware.
>>>>>>
>>>>>> This helper behaves the same as devm_clk_get() except where there is
>>>>>> no clock producer like in ACPI-based platforms.
>>>>>>
>>>>>> For ACPI-based platforms the function will read the "clock-frequency"
>>>>>> ACPI _DSD property and register a fixed frequency clock with the frequency
>>>>>> indicated in the property.
>>>>>>
>>>>>> This function also handles the special ACPI-based system case where:
>>>>>> The clock-frequency _DSD property is present.
>>>>>> A reference to the clock producer is present, where the clock is provided
>>>>>> by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
>>>>>> In this case try to set the clock-frequency value to the provided clock.
>>>>>
>>>>> On irc I wondered about the name of the new function since it is sensor
>>>>> specific, and if it can also be used for e.g. video receivers, then it
>>>>> should be renamed to something more generic.
>>>>>
>>>>> According to Laurent there is no ACPI standard for video receivers, so
>>>>> that's the reason this is sensor specific.
>>>>>
>>>>> I'd like to see that documented in this patch. Either in the commit log,
>>>>> or, preferred, in the header in the function description.
>>>>
>>>> Given this patch has been around for quite some time and I've sent a PR on
>>>> it, I'd prefer to proceed with the current PR. I'm fine with adding more
>>>> documentation though if you think we should do that.
>>>
>>> How about a separate patch that Hans can merge just on top of your PR ?
>>> Could you send one ?
>>
>> I'd like to have the rationale of why this is a sensor-only function
>> documented. If I wondered about that, then someone else will likely have
>> the same question.
>>
>>>
>>>>> I made a suggestion below.
>>>>>
>>>>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>>>>>> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>>>>>> Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
>>>>>> ---
>>>>>> drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
>>>>>> include/media/v4l2-common.h | 27 ++++++++++++++
>>>>>> 2 files changed, 79 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
>>>>>
>>>>> <snip>
>>>>>
>>>>>> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
>>>>>> index 0a43f56578bc..1c79ca4d5c73 100644
>>>>>> --- a/include/media/v4l2-common.h
>>>>>> +++ b/include/media/v4l2-common.h
>>>>>> @@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
>>>>>> struct v4l2_device;
>>>>>> struct v4l2_subdev;
>>>>>> struct v4l2_subdev_ops;
>>>>>> +struct clk;
>>>>>>
>>>>>> /* I2C Helper functions */
>>>>>> #include <linux/i2c.h>
>>>>>> @@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
>>>>>> unsigned int num_of_driver_link_freqs,
>>>>>> unsigned long *bitmap);
>>>>>>
>>>>>> +/**
>>>>>> + * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
>>>>>> + * for a camera sensor.
>>>>>> + *
>>>>>> + * @dev: device for v4l2 sensor clock "consumer"
>>>>>> + * @id: clock consumer ID
>>>>>> + *
>>>>>> + * This function behaves the same way as devm_clk_get() except where there
>>>>>> + * is no clock producer like in ACPI-based platforms.
>>>>>> + *
>>>>>> + * For ACPI-based platforms, the function will read the "clock-frequency"
>>>>>> + * ACPI _DSD property and register a fixed-clock with the frequency indicated
>>>>>> + * in the property.
>>>>>> + *
>>>>>> + * This function also handles the special ACPI-based system case where:
>>>>>> + *
>>>>>> + * * The clock-frequency _DSD property is present.
>>>>>> + * * A reference to the clock producer is present, where the clock is provided
>>>>>> + * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
>>>>>> + *
>>>>>> + * In this case try to set the clock-frequency value to the provided clock.
>>>>>
>>>>> *
>>>>> * While ACPI has standardized sensor support, there is no standard support for
>>>>> * e.g. video receivers. So this function is specific to sensors, hence the
>>>>> * chosen function name.
>>>>>
>>>>> Better suggestions are welcome.
>>>>
>>>> ACPI itself does not standardise camera sensor support. What driver authors
>>>
>>> But there's a de facto standard that makes this helper function
>>> suitable, isn't there ?
>>>
>>>> should know indeed is that this function provides a clock that can be at
>>>> least queried for frequency, independently of how that clock is controlled
>>>> or how its frequency is configured.
>>>>
>>>> How about:
>>>>
>>>> * This function may be used in camera sensor drivers only.
>>
>> That just restates what is also in the function name. It's the 'why' that I'd
>> like to know. Even if you simply don't know if this will work for non-sensor
>> driver, just stating that will help.
>
> As I replied on #linux-media:
>
> devm_v4l2_sensor_clk_get() in practice provides a clock to camera sensors
> which is what they need; other types of devices generally don't care much
> about clocks. Why camera sensors are special is that they have a PLL and a
> CSI-2 RX the configuration of which depend on the external clock.
>
> Is something like this what you're looking for, or something more
> elaborate? There are different ways the clock can be obtained but I'm not
> sure we'll need to go to that in the function documentation.
>
Yes, that's sufficient. If you can make a patch adding that, then I'll add it
to the PR. No need to make a new PR for this, I can just add it myself.
Regards,
Hans
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH v2 01/48] media: v4l2-common: Add a helper for obtaining the clock producer
2025-08-13 15:14 ` Hans Verkuil
@ 2025-08-13 19:45 ` Sakari Ailus
2025-08-14 13:50 ` [PATCH 1/1] media: v4l2-common: Improve devm_v4l2_sensor_clk_get() documentation Sakari Ailus
1 sibling, 0 replies; 72+ messages in thread
From: Sakari Ailus @ 2025-08-13 19:45 UTC (permalink / raw)
To: Hans Verkuil
Cc: Sakari Ailus, Laurent Pinchart, Mehdi Djait, stanislaw.gruszka,
hdegoede, arnd, alain.volmat, andrzej.hajda, benjamin.mugnier,
dave.stevenson, hansg, jacopo.mondi, kieran.bingham, khalasa,
mani, m.felsch, matthias.fend, mchehab, michael.riesch, naush,
nicholas, nicolas.dufresne, paul.elder, dan.scally, pavel,
rashanmu, ribalda, slongerbeam, tomi.valkeinen, umang.jain,
linux-media, Lad Prabhakar
Hi Hans,
On Wed, Aug 13, 2025 at 05:14:42PM +0200, Hans Verkuil wrote:
> On 13/08/2025 16:49, Sakari Ailus wrote:
> > Hi Hans,
> >
> > On Wed, Aug 13, 2025 at 03:23:18PM +0200, Hans Verkuil wrote:
> >> On 13/08/2025 15:08, Laurent Pinchart wrote:
> >>> On Wed, Aug 13, 2025 at 12:59:36PM +0000, Sakari Ailus wrote:
> >>>> On Wed, Aug 13, 2025 at 12:15:29PM +0200, Hans Verkuil wrote:
> >>>>> On 26/06/2025 15:33, Mehdi Djait wrote:
> >>>>>> Introduce a helper for v4l2 sensor drivers on both DT- and ACPI-based
> >>>>>> platforms to retrieve a reference to the clock producer from firmware.
> >>>>>>
> >>>>>> This helper behaves the same as devm_clk_get() except where there is
> >>>>>> no clock producer like in ACPI-based platforms.
> >>>>>>
> >>>>>> For ACPI-based platforms the function will read the "clock-frequency"
> >>>>>> ACPI _DSD property and register a fixed frequency clock with the frequency
> >>>>>> indicated in the property.
> >>>>>>
> >>>>>> This function also handles the special ACPI-based system case where:
> >>>>>> The clock-frequency _DSD property is present.
> >>>>>> A reference to the clock producer is present, where the clock is provided
> >>>>>> by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> >>>>>> In this case try to set the clock-frequency value to the provided clock.
> >>>>>
> >>>>> On irc I wondered about the name of the new function since it is sensor
> >>>>> specific, and if it can also be used for e.g. video receivers, then it
> >>>>> should be renamed to something more generic.
> >>>>>
> >>>>> According to Laurent there is no ACPI standard for video receivers, so
> >>>>> that's the reason this is sensor specific.
> >>>>>
> >>>>> I'd like to see that documented in this patch. Either in the commit log,
> >>>>> or, preferred, in the header in the function description.
> >>>>
> >>>> Given this patch has been around for quite some time and I've sent a PR on
> >>>> it, I'd prefer to proceed with the current PR. I'm fine with adding more
> >>>> documentation though if you think we should do that.
> >>>
> >>> How about a separate patch that Hans can merge just on top of your PR ?
> >>> Could you send one ?
> >>
> >> I'd like to have the rationale of why this is a sensor-only function
> >> documented. If I wondered about that, then someone else will likely have
> >> the same question.
> >>
> >>>
> >>>>> I made a suggestion below.
> >>>>>
> >>>>>> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> >>>>>> Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> >>>>>> Signed-off-by: Mehdi Djait <mehdi.djait@linux.intel.com>
> >>>>>> ---
> >>>>>> drivers/media/v4l2-core/v4l2-common.c | 52 +++++++++++++++++++++++++++
> >>>>>> include/media/v4l2-common.h | 27 ++++++++++++++
> >>>>>> 2 files changed, 79 insertions(+)
> >>>>>>
> >>>>>> diff --git a/drivers/media/v4l2-core/v4l2-common.c b/drivers/media/v4l2-core/v4l2-common.c
> >>>>>
> >>>>> <snip>
> >>>>>
> >>>>>> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> >>>>>> index 0a43f56578bc..1c79ca4d5c73 100644
> >>>>>> --- a/include/media/v4l2-common.h
> >>>>>> +++ b/include/media/v4l2-common.h
> >>>>>> @@ -100,6 +100,7 @@ int v4l2_ctrl_query_fill(struct v4l2_queryctrl *qctrl,
> >>>>>> struct v4l2_device;
> >>>>>> struct v4l2_subdev;
> >>>>>> struct v4l2_subdev_ops;
> >>>>>> +struct clk;
> >>>>>>
> >>>>>> /* I2C Helper functions */
> >>>>>> #include <linux/i2c.h>
> >>>>>> @@ -620,6 +621,32 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> >>>>>> unsigned int num_of_driver_link_freqs,
> >>>>>> unsigned long *bitmap);
> >>>>>>
> >>>>>> +/**
> >>>>>> + * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
> >>>>>> + * for a camera sensor.
> >>>>>> + *
> >>>>>> + * @dev: device for v4l2 sensor clock "consumer"
> >>>>>> + * @id: clock consumer ID
> >>>>>> + *
> >>>>>> + * This function behaves the same way as devm_clk_get() except where there
> >>>>>> + * is no clock producer like in ACPI-based platforms.
> >>>>>> + *
> >>>>>> + * For ACPI-based platforms, the function will read the "clock-frequency"
> >>>>>> + * ACPI _DSD property and register a fixed-clock with the frequency indicated
> >>>>>> + * in the property.
> >>>>>> + *
> >>>>>> + * This function also handles the special ACPI-based system case where:
> >>>>>> + *
> >>>>>> + * * The clock-frequency _DSD property is present.
> >>>>>> + * * A reference to the clock producer is present, where the clock is provided
> >>>>>> + * by a camera sensor PMIC driver (e.g. int3472/tps68470.c)
> >>>>>> + *
> >>>>>> + * In this case try to set the clock-frequency value to the provided clock.
> >>>>>
> >>>>> *
> >>>>> * While ACPI has standardized sensor support, there is no standard support for
> >>>>> * e.g. video receivers. So this function is specific to sensors, hence the
> >>>>> * chosen function name.
> >>>>>
> >>>>> Better suggestions are welcome.
> >>>>
> >>>> ACPI itself does not standardise camera sensor support. What driver authors
> >>>
> >>> But there's a de facto standard that makes this helper function
> >>> suitable, isn't there ?
> >>>
> >>>> should know indeed is that this function provides a clock that can be at
> >>>> least queried for frequency, independently of how that clock is controlled
> >>>> or how its frequency is configured.
> >>>>
> >>>> How about:
> >>>>
> >>>> * This function may be used in camera sensor drivers only.
> >>
> >> That just restates what is also in the function name. It's the 'why' that I'd
> >> like to know. Even if you simply don't know if this will work for non-sensor
> >> driver, just stating that will help.
> >
> > As I replied on #linux-media:
> >
> > devm_v4l2_sensor_clk_get() in practice provides a clock to camera sensors
> > which is what they need; other types of devices generally don't care much
> > about clocks. Why camera sensors are special is that they have a PLL and a
> > CSI-2 RX the configuration of which depend on the external clock.
> >
> > Is something like this what you're looking for, or something more
> > elaborate? There are different ways the clock can be obtained but I'm not
> > sure we'll need to go to that in the function documentation.
> >
>
> Yes, that's sufficient. If you can make a patch adding that, then I'll add it
> to the PR. No need to make a new PR for this, I can just add it myself.
Ack, Ḯ'll post the patch tomorrow.
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 72+ messages in thread
* [PATCH 1/1] media: v4l2-common: Improve devm_v4l2_sensor_clk_get() documentation
2025-08-13 15:14 ` Hans Verkuil
2025-08-13 19:45 ` Sakari Ailus
@ 2025-08-14 13:50 ` Sakari Ailus
2025-08-15 6:00 ` Mehdi Djait
1 sibling, 1 reply; 72+ messages in thread
From: Sakari Ailus @ 2025-08-14 13:50 UTC (permalink / raw)
To: Hans Verkuil
Cc: Laurent Pinchart, Mehdi Djait, hdegoede, arnd, alain.volmat,
andrzej.hajda, benjamin.mugnier, dave.stevenson, hansg,
jacopo.mondi, kieran.bingham, khalasa, mani, m.felsch,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, linux-media, Lad Prabhakar
Remove the extra leading period and provide more elaborate explanation for
why devm_v4l2_sensor_clk_get() is only allowed to be used on camera sensor
devices.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
include/media/v4l2-common.h | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
index 9d6c236e8f14..39dd0c78d70f 100644
--- a/include/media/v4l2-common.h
+++ b/include/media/v4l2-common.h
@@ -623,7 +623,7 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
/**
* devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
- * for a camera sensor.
+ * for a camera sensor
*
* @dev: device for v4l2 sensor clock "consumer"
* @id: clock consumer ID
@@ -643,6 +643,14 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
*
* In this case try to set the clock-frequency value to the provided clock.
*
+ * As the name indicates, this function may only be used on camera sensor
+ * devices. This is because generally only camera sensors do need a clock to
+ * query the frequency from, due to the requirement to configure the PLL for a
+ * given CSI-2 interface frequency where the sensor's external clock frequency
+ * is a factor. Additionally, the clock frequency tends to be available on ACPI
+ * firmware based systems for camera sensors specifically (if e.g. DisCo for
+ * Imaging compliant).
+ *
* Returns a pointer to a struct clk on success or an error pointer on failure.
*/
struct clk *devm_v4l2_sensor_clk_get(struct device *dev, const char *id);
--
2.39.5
^ permalink raw reply related [flat|nested] 72+ messages in thread
* Re: [PATCH 1/1] media: v4l2-common: Improve devm_v4l2_sensor_clk_get() documentation
2025-08-14 13:50 ` [PATCH 1/1] media: v4l2-common: Improve devm_v4l2_sensor_clk_get() documentation Sakari Ailus
@ 2025-08-15 6:00 ` Mehdi Djait
2025-08-15 8:53 ` Sakari Ailus
0 siblings, 1 reply; 72+ messages in thread
From: Mehdi Djait @ 2025-08-15 6:00 UTC (permalink / raw)
To: Sakari Ailus
Cc: Hans Verkuil, Laurent Pinchart, hdegoede, arnd, alain.volmat,
andrzej.hajda, benjamin.mugnier, dave.stevenson, hansg,
jacopo.mondi, kieran.bingham, khalasa, mani, m.felsch,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, linux-media, Lad Prabhakar
Hi Sakari,
Thank you for the patch!
On Thu, Aug 14, 2025 at 04:50:07PM +0300, Sakari Ailus wrote:
> Remove the extra leading period and provide more elaborate explanation for
> why devm_v4l2_sensor_clk_get() is only allowed to be used on camera sensor
> devices.
>
> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> include/media/v4l2-common.h | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> index 9d6c236e8f14..39dd0c78d70f 100644
> --- a/include/media/v4l2-common.h
> +++ b/include/media/v4l2-common.h
> @@ -623,7 +623,7 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
>
> /**
> * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
> - * for a camera sensor.
> + * for a camera sensor
> *
> * @dev: device for v4l2 sensor clock "consumer"
> * @id: clock consumer ID
> @@ -643,6 +643,14 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> *
> * In this case try to set the clock-frequency value to the provided clock.
> *
> + * As the name indicates, this function may only be used on camera sensor
> + * devices. This is because generally only camera sensors do need a clock to
> + * query the frequency from, due to the requirement to configure the PLL for a
> + * given CSI-2 interface frequency where the sensor's external clock frequency
> + * is a factor. Additionally, the clock frequency tends to be available on ACPI
> + * firmware based systems for camera sensors specifically (if e.g. DisCo for
> + * Imaging compliant).
> + *
I don't know about the last sentence about ACPI. Does it help explain
why this helper is intended only for camera sensors ?
--
Kind Regards
Mehdi Djait
^ permalink raw reply [flat|nested] 72+ messages in thread
* Re: [PATCH 1/1] media: v4l2-common: Improve devm_v4l2_sensor_clk_get() documentation
2025-08-15 6:00 ` Mehdi Djait
@ 2025-08-15 8:53 ` Sakari Ailus
0 siblings, 0 replies; 72+ messages in thread
From: Sakari Ailus @ 2025-08-15 8:53 UTC (permalink / raw)
To: Mehdi Djait
Cc: Hans Verkuil, Laurent Pinchart, hdegoede, arnd, alain.volmat,
andrzej.hajda, benjamin.mugnier, dave.stevenson, hansg,
jacopo.mondi, kieran.bingham, khalasa, mani, m.felsch,
matthias.fend, mchehab, michael.riesch, naush, nicholas,
nicolas.dufresne, paul.elder, dan.scally, pavel, rashanmu,
ribalda, slongerbeam, tomi.valkeinen, linux-media, Lad Prabhakar
Hi Mehdi,
On Fri, Aug 15, 2025 at 08:00:06AM +0200, Mehdi Djait wrote:
> Hi Sakari,
>
> Thank you for the patch!
>
> On Thu, Aug 14, 2025 at 04:50:07PM +0300, Sakari Ailus wrote:
> > Remove the extra leading period and provide more elaborate explanation for
> > why devm_v4l2_sensor_clk_get() is only allowed to be used on camera sensor
> > devices.
> >
> > Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> > ---
> > include/media/v4l2-common.h | 10 +++++++++-
> > 1 file changed, 9 insertions(+), 1 deletion(-)
> >
> > diff --git a/include/media/v4l2-common.h b/include/media/v4l2-common.h
> > index 9d6c236e8f14..39dd0c78d70f 100644
> > --- a/include/media/v4l2-common.h
> > +++ b/include/media/v4l2-common.h
> > @@ -623,7 +623,7 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> >
> > /**
> > * devm_v4l2_sensor_clk_get - lookup and obtain a reference to a clock producer
> > - * for a camera sensor.
> > + * for a camera sensor
> > *
> > * @dev: device for v4l2 sensor clock "consumer"
> > * @id: clock consumer ID
> > @@ -643,6 +643,14 @@ int v4l2_link_freq_to_bitmap(struct device *dev, const u64 *fw_link_freqs,
> > *
> > * In this case try to set the clock-frequency value to the provided clock.
> > *
> > + * As the name indicates, this function may only be used on camera sensor
> > + * devices. This is because generally only camera sensors do need a clock to
> > + * query the frequency from, due to the requirement to configure the PLL for a
> > + * given CSI-2 interface frequency where the sensor's external clock frequency
> > + * is a factor. Additionally, the clock frequency tends to be available on ACPI
> > + * firmware based systems for camera sensors specifically (if e.g. DisCo for
> > + * Imaging compliant).
> > + *
>
> I don't know about the last sentence about ACPI. Does it help explain
> why this helper is intended only for camera sensors ?
There couldn't be a generic function to do this due to how the firmware is
implemented, that's because I think it's relevant.
I think we could later on support ACPI clock input resource descriptors but
I'd wait for actual use first -- or DisCo for Imaging update advocating
them instead of the clock-frequency property. In ACPI clock handling in
general takes place through power resources so unless drivers are
interested in a particular frequency, there's no need to provide that. Of
course some cases could be up to a debate at least to some degree.
--
Regards,
Sakari Ailus
^ permalink raw reply [flat|nested] 72+ messages in thread
end of thread, other threads:[~2025-08-15 8:54 UTC | newest]
Thread overview: 72+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-26 13:33 [PATCH v2 00/48] media: Add a helper for obtaining the clock producer Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 01/48] media: v4l2-common: " Mehdi Djait
2025-06-27 7:12 ` Sakari Ailus
2025-07-01 9:51 ` Mehdi Djait
2025-07-01 10:03 ` Sakari Ailus
2025-07-01 10:47 ` Jacopo Mondi
2025-07-01 11:17 ` Laurent Pinchart
2025-07-01 11:46 ` Mehdi Djait
2025-07-06 0:30 ` Laurent Pinchart
2025-07-07 14:30 ` Mehdi Djait
2025-07-07 14:32 ` [PATCH v3] " Mehdi Djait
2025-07-07 21:55 ` Sakari Ailus
2025-08-13 10:15 ` [PATCH v2 01/48] " Hans Verkuil
2025-08-13 12:59 ` Sakari Ailus
2025-08-13 13:08 ` Laurent Pinchart
2025-08-13 13:22 ` Sakari Ailus
2025-08-13 13:23 ` Hans Verkuil
2025-08-13 14:49 ` Sakari Ailus
2025-08-13 15:14 ` Hans Verkuil
2025-08-13 19:45 ` Sakari Ailus
2025-08-14 13:50 ` [PATCH 1/1] media: v4l2-common: Improve devm_v4l2_sensor_clk_get() documentation Sakari Ailus
2025-08-15 6:00 ` Mehdi Djait
2025-08-15 8:53 ` Sakari Ailus
2025-06-26 13:33 ` [PATCH v2 02/48] Documentation: media: camera-sensor: Mention v4l2_devm_sensor_clk_get() for obtaining the clock Mehdi Djait
2025-07-01 11:03 ` Laurent Pinchart
2025-06-26 13:33 ` [PATCH v2 03/48] media: i2c: ar0521: Use the v4l2 helper " Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 04/48] media: i2c: et8ek8: " Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 05/48] media: i2c: gc05a2: " Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 06/48] media: i2c: gc08a3: " Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 07/48] media: i2c: gc2145: " Mehdi Djait
2025-06-26 13:33 ` [PATCH v2 08/48] media: i2c: hi846: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 09/48] media: i2c: imx214: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 10/48] media: i2c: imx219: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 11/48] media: i2c: imx283: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 12/48] media: i2c: imx290: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 13/48] media: i2c: imx296: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 14/48] media: i2c: imx334: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 15/48] media: i2c: imx335: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 16/48] media: i2c: imx412: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 17/48] media: i2c: imx415: " Mehdi Djait
2025-06-26 13:41 ` Michael Riesch
2025-06-26 13:34 ` [PATCH v2 18/48] media: i2c: mt9m001: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 19/48] media: i2c: mt9m111: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 20/48] media: i2c: mt9m114: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 21/48] media: i2c: mt9p031: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 22/48] media: i2c: mt9t112: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 23/48] media: i2c: mt9v032: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 24/48] media: i2c: mt9v111: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 25/48] media: i2c: ov02a10: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 26/48] media: i2c: ov2659: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 27/48] media: i2c: ov2685: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 28/48] media: i2c: ov5640: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 29/48] media: i2c: ov5645: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 30/48] media: i2c: ov5647: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 31/48] media: i2c: ov5648: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 32/48] media: i2c: ov5695: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 33/48] media: i2c: ov64a40: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 34/48] media: i2c: ov6650: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 35/48] media: i2c: ov7740: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 36/48] media: i2c: ov8856: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 37/48] media: i2c: ov8858: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 38/48] media: i2c: ov8865: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 39/48] media: i2c: ov9282: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 40/48] media: i2c: ov9640: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 41/48] media: i2c: ov9650: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 42/48] media: i2c: s5c73m3: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 43/48] media: i2c: s5k5baf: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 44/48] media: i2c: s5k6a3: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 45/48] media: i2c: vd55g1: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 46/48] media: i2c: vd56g3: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 47/48] media: i2c: vgxy61: " Mehdi Djait
2025-06-26 13:34 ` [PATCH v2 48/48] media: i2c: ov2680: " Mehdi Djait
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).