Linux Media Controller development
 help / color / mirror / Atom feed
* [PATCH v3] platform/x86: int3472: Use actual clock frequency for DSM method
@ 2026-11-25  9:09 Sergey Lebedev
  2026-11-25 11:16 ` Hans de Goede
  0 siblings, 1 reply; 2+ messages in thread
From: Sergey Lebedev @ 2026-11-25  9:09 UTC (permalink / raw)
  To: Daniel Scally, Sakari Ailus
  Cc: Hao Yao, Hans de Goede, Ilpo Järvinen, Bingbu Cao,
	Fernando Rimoli, platform-driver-x86, linux-media, linux-kernel

From: Hao Yao <hao.yao@intel.com>

The third argument (args[2]) to the _DSM method was hardcoded to 1,
which selects 19.2MHz. A sensor whose SSDB asks for 24MHz therefore
runs from 19.2MHz, and everything it derives from its clock runs at
four fifths of the expected rate.

Pass the frequency from the SSDB instead, with 19.2MHz as the default.
1 selects 19.2MHz everywhere, but the value for 24MHz depends on the
platform. Where the frequency field is one bit wide (Tiger Lake, Jasper
Lake, Alder Lake, Raptor Lake) it is 0, and 3 would also set the clock's
enable bit again when the clock is turned off. From Meteor Lake on the
field is two bits wide and it is 3; 0 and 2 leave the clock unchanged
there, as measured with an oscilloscope.

Fixes: e4543de8b6ff ("platform/x86: int3472: Evaluate device's _DSM method to control imaging clock")
Signed-off-by: Hao Yao <hao.yao@intel.com>
[Sergey: pick the 24MHz value per platform]
Signed-off-by: Sergey Lebedev <lsa.uz@pm.me>
---
v3, sent by me as offered in the v2 thread, with Hao as the author:
- The 24MHz value is chosen per platform. On a Surface Pro 9 (Alder
  Lake) Fernando Rimoli measured that 3 gives 19.2MHz and 0 gives 24MHz
  [1]. coreboot's camera_clock_ctl.asl has a one-bit frequency field for
  Tiger Lake, Jasper Lake and Alder Lake (which covers Raptor Lake) and
  a two-bit one for Meteor Lake, Panther Lake and Nova Lake.
- The Fixes: tag and the note on 0 and 2 that Ilpo asked for.
- v2's Reviewed-by and Acked-by tags dropped, since the code changed.

Tested on a Surface Pro 11 (Lunar Lake), with the module built from
Ubuntu's 7.0 source, where this file is the same as in media-committers
next. The VD55G0, whose SSDB asks for 24MHz, streams at 59.14 fps as
its controls give, against 47.29 fps without the patch. The two 19.2MHz
sensors are unchanged. The Alder Lake branch has not run as posted.

v2: https://lore.kernel.org/all/20251208035122.2147678-1-hao.yao@intel.com/
[1] https://lore.kernel.org/all/20261026111012.33347-1-fernandorimoli11@gmail.com/

Tool use, per Documentation/process/generated-content.rst (Assisted-by
tags in commits were dropped in 7.4-rc1):

* My contributions to this series were prepared with Claude Code
  (claude-opus-5-5); work by others in it is their own.
* This replaces any Assisted-by tags in earlier versions.

 .../x86/intel/int3472/clk_and_regulator.c     | 39 ++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
index 9e052b164a1..47dc23c5184 100644
--- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c
+++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
@@ -10,6 +10,9 @@
 #include <linux/regulator/driver.h>
 #include <linux/slab.h>
 
+#include <asm/cpu_device_id.h>
+#include <asm/intel-family.h>
+
 /*
  * 82c0d13a-78c5-4244-9bb1-eb8b539a8d11
  * This _DSM GUID allows controlling the sensor clk when it is not controlled
@@ -19,6 +22,40 @@ static const guid_t img_clk_guid =
 	GUID_INIT(0x82c0d13a, 0x78c5, 0x4244,
 		  0x9b, 0xb1, 0xeb, 0x8b, 0x53, 0x9a, 0x8d, 0x11);
 
+/*
+ * The third argument to the _DSM method selects the clock frequency. 1 is
+ * 19.2MHz everywhere. 24MHz is 0 where the frequency field is one bit wide
+ * (Tiger Lake, Jasper Lake, Alder Lake, Raptor Lake) and 3 where it is two
+ * bits wide (Meteor Lake and later).
+ */
+#define INT3472_DSM_CLK_FREQ_19M2	1
+#define INT3472_DSM_CLK_FREQ_24M	3
+#define INT3472_DSM_CLK_FREQ_24M_1BIT	0
+
+static const struct x86_cpu_id int3472_dsm_clk_freq_1bit_ids[] = {
+	X86_MATCH_VFM(INTEL_TIGERLAKE_L, NULL),
+	X86_MATCH_VFM(INTEL_TIGERLAKE, NULL),
+	X86_MATCH_VFM(INTEL_ATOM_TREMONT_L, NULL),
+	X86_MATCH_VFM(INTEL_ALDERLAKE, NULL),
+	X86_MATCH_VFM(INTEL_ALDERLAKE_L, NULL),
+	X86_MATCH_VFM(INTEL_ATOM_GRACEMONT, NULL),
+	X86_MATCH_VFM(INTEL_RAPTORLAKE, NULL),
+	X86_MATCH_VFM(INTEL_RAPTORLAKE_P, NULL),
+	X86_MATCH_VFM(INTEL_RAPTORLAKE_S, NULL),
+	{}
+};
+
+static u32 skl_int3472_dsm_clk_freq(struct int3472_clock *clk)
+{
+	if (clk->frequency != 24000000)
+		return INT3472_DSM_CLK_FREQ_19M2;
+
+	if (x86_match_cpu(int3472_dsm_clk_freq_1bit_ids))
+		return INT3472_DSM_CLK_FREQ_24M_1BIT;
+
+	return INT3472_DSM_CLK_FREQ_24M;
+}
+
 static void skl_int3472_enable_clk(struct int3472_clock *clk, int enable)
 {
 	struct int3472_discrete_device *int3472 = to_int3472_device(clk);
@@ -35,7 +72,7 @@ static void skl_int3472_enable_clk(struct int3472_clock *clk, int enable)
 	args[1].integer.type = ACPI_TYPE_INTEGER;
 	args[1].integer.value = enable;
 	args[2].integer.type = ACPI_TYPE_INTEGER;
-	args[2].integer.value = 1;
+	args[2].integer.value = skl_int3472_dsm_clk_freq(clk);
 
 	argv4.type = ACPI_TYPE_PACKAGE;
 	argv4.package.count = 3;
-- 
2.54.0



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] platform/x86: int3472: Use actual clock frequency for DSM method
  2026-11-25  9:09 [PATCH v3] platform/x86: int3472: Use actual clock frequency for DSM method Sergey Lebedev
@ 2026-11-25 11:16 ` Hans de Goede
  0 siblings, 0 replies; 2+ messages in thread
From: Hans de Goede @ 2026-11-25 11:16 UTC (permalink / raw)
  To: Sergey Lebedev, Daniel Scally, Sakari Ailus
  Cc: Hao Yao, Ilpo Järvinen, Bingbu Cao, Fernando Rimoli,
	platform-driver-x86, linux-media, linux-kernel

Hi,

On 25-Nov-26 10:09, Sergey Lebedev wrote:
> From: Hao Yao <hao.yao@intel.com>
> 
> The third argument (args[2]) to the _DSM method was hardcoded to 1,
> which selects 19.2MHz. A sensor whose SSDB asks for 24MHz therefore
> runs from 19.2MHz, and everything it derives from its clock runs at
> four fifths of the expected rate.
> 
> Pass the frequency from the SSDB instead, with 19.2MHz as the default.
> 1 selects 19.2MHz everywhere, but the value for 24MHz depends on the
> platform. Where the frequency field is one bit wide (Tiger Lake, Jasper
> Lake, Alder Lake, Raptor Lake) it is 0, and 3 would also set the clock's
> enable bit again when the clock is turned off. From Meteor Lake on the
> field is two bits wide and it is 3; 0 and 2 leave the clock unchanged
> there, as measured with an oscilloscope.
> 
> Fixes: e4543de8b6ff ("platform/x86: int3472: Evaluate device's _DSM method to control imaging clock")
> Signed-off-by: Hao Yao <hao.yao@intel.com>
> [Sergey: pick the 24MHz value per platform]
> Signed-off-by: Sergey Lebedev <lsa.uz@pm.me>

Thanks, patch looks good to me:

Reviewed-by: Hans de Goede <johannes.goede@oss.qualcomm.com>

Regards,

Hans



> ---
> v3, sent by me as offered in the v2 thread, with Hao as the author:
> - The 24MHz value is chosen per platform. On a Surface Pro 9 (Alder
>   Lake) Fernando Rimoli measured that 3 gives 19.2MHz and 0 gives 24MHz
>   [1]. coreboot's camera_clock_ctl.asl has a one-bit frequency field for
>   Tiger Lake, Jasper Lake and Alder Lake (which covers Raptor Lake) and
>   a two-bit one for Meteor Lake, Panther Lake and Nova Lake.
> - The Fixes: tag and the note on 0 and 2 that Ilpo asked for.
> - v2's Reviewed-by and Acked-by tags dropped, since the code changed.
> 
> Tested on a Surface Pro 11 (Lunar Lake), with the module built from
> Ubuntu's 7.0 source, where this file is the same as in media-committers
> next. The VD55G0, whose SSDB asks for 24MHz, streams at 59.14 fps as
> its controls give, against 47.29 fps without the patch. The two 19.2MHz
> sensors are unchanged. The Alder Lake branch has not run as posted.
> 
> v2: https://lore.kernel.org/all/20251208035122.2147678-1-hao.yao@intel.com/
> [1] https://lore.kernel.org/all/20261026111012.33347-1-fernandorimoli11@gmail.com/
> 
> Tool use, per Documentation/process/generated-content.rst (Assisted-by
> tags in commits were dropped in 7.4-rc1):
> 
> * My contributions to this series were prepared with Claude Code
>   (claude-opus-5-5); work by others in it is their own.
> * This replaces any Assisted-by tags in earlier versions.
> 
>  .../x86/intel/int3472/clk_and_regulator.c     | 39 ++++++++++++++++++-
>  1 file changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
> index 9e052b164a1..47dc23c5184 100644
> --- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c
> +++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c
> @@ -10,6 +10,9 @@
>  #include <linux/regulator/driver.h>
>  #include <linux/slab.h>
>  
> +#include <asm/cpu_device_id.h>
> +#include <asm/intel-family.h>
> +
>  /*
>   * 82c0d13a-78c5-4244-9bb1-eb8b539a8d11
>   * This _DSM GUID allows controlling the sensor clk when it is not controlled
> @@ -19,6 +22,40 @@ static const guid_t img_clk_guid =
>  	GUID_INIT(0x82c0d13a, 0x78c5, 0x4244,
>  		  0x9b, 0xb1, 0xeb, 0x8b, 0x53, 0x9a, 0x8d, 0x11);
>  
> +/*
> + * The third argument to the _DSM method selects the clock frequency. 1 is
> + * 19.2MHz everywhere. 24MHz is 0 where the frequency field is one bit wide
> + * (Tiger Lake, Jasper Lake, Alder Lake, Raptor Lake) and 3 where it is two
> + * bits wide (Meteor Lake and later).
> + */
> +#define INT3472_DSM_CLK_FREQ_19M2	1
> +#define INT3472_DSM_CLK_FREQ_24M	3
> +#define INT3472_DSM_CLK_FREQ_24M_1BIT	0
> +
> +static const struct x86_cpu_id int3472_dsm_clk_freq_1bit_ids[] = {
> +	X86_MATCH_VFM(INTEL_TIGERLAKE_L, NULL),
> +	X86_MATCH_VFM(INTEL_TIGERLAKE, NULL),
> +	X86_MATCH_VFM(INTEL_ATOM_TREMONT_L, NULL),
> +	X86_MATCH_VFM(INTEL_ALDERLAKE, NULL),
> +	X86_MATCH_VFM(INTEL_ALDERLAKE_L, NULL),
> +	X86_MATCH_VFM(INTEL_ATOM_GRACEMONT, NULL),
> +	X86_MATCH_VFM(INTEL_RAPTORLAKE, NULL),
> +	X86_MATCH_VFM(INTEL_RAPTORLAKE_P, NULL),
> +	X86_MATCH_VFM(INTEL_RAPTORLAKE_S, NULL),
> +	{}
> +};
> +
> +static u32 skl_int3472_dsm_clk_freq(struct int3472_clock *clk)
> +{
> +	if (clk->frequency != 24000000)
> +		return INT3472_DSM_CLK_FREQ_19M2;
> +
> +	if (x86_match_cpu(int3472_dsm_clk_freq_1bit_ids))
> +		return INT3472_DSM_CLK_FREQ_24M_1BIT;
> +
> +	return INT3472_DSM_CLK_FREQ_24M;
> +}
> +
>  static void skl_int3472_enable_clk(struct int3472_clock *clk, int enable)
>  {
>  	struct int3472_discrete_device *int3472 = to_int3472_device(clk);
> @@ -35,7 +72,7 @@ static void skl_int3472_enable_clk(struct int3472_clock *clk, int enable)
>  	args[1].integer.type = ACPI_TYPE_INTEGER;
>  	args[1].integer.value = enable;
>  	args[2].integer.type = ACPI_TYPE_INTEGER;
> -	args[2].integer.value = 1;
> +	args[2].integer.value = skl_int3472_dsm_clk_freq(clk);
>  
>  	argv4.type = ACPI_TYPE_PACKAGE;
>  	argv4.package.count = 3;


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-25 11:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  9:09 [PATCH v3] platform/x86: int3472: Use actual clock frequency for DSM method Sergey Lebedev
2026-11-25 11:16 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox