platform/x86: int3472: Use actual clock frequency for DSM method
PATCH v3 1/1 platform/x86: int3472: Use actual clock frequency for DSM method
From: Hao Yao <[email protected]>
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.
---
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/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/
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(-)
drivers/platform/x86/intel/int3472/clk_and_regulator.c +38 -1
@@ -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 ;
Signature · 1 line
2.54.0
Hi,
Quoted 15 lines · Sergey Lebedev
From: Hao Yao <[email protected]>
The third argument (args[2]) to the
_DSMmethod 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.
Quoted 4 lines
Fixes e4543de8b6ff ("platform/x86: int3472: Evaluate device's _DSM method to control imaging clock")Signed-off-by Hao Yao <[email protected]>[Sergey: pick the 24MHz value per platform]Signed-off-by Sergey Lebedev <[email protected]>
Thanks, patch looks good to me:
Regards,
Hans
Quoted 93 lines
---
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/[email protected]/
[1] https://lore.kernel.org/all/[email protected]/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(-)drivers/platform/x86/intel/int3472/clk_and_regulator.c +38
-1@@ -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 ;
Sakari Ailus
maintainerHi Hans, Sergey,
Quoted 18 lines · Hans de Goede
Hi,
Quoted 15 lines · Sergey Lebedev
From: Hao Yao <[email protected]>
The third argument (args[2]) to the
_DSMmethod 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.
Quoted 8 lines
Quoted 4 lines
Fixes e4543de8b6ff ("platform/x86: int3472: Evaluate device's _DSM method to control imaging clock")Signed-off-by Hao Yao <[email protected]>[Sergey: pick the 24MHz value per platform]Signed-off-by Sergey Lebedev <[email protected]>Thanks, patch looks good to me:
Reviewed-by Hans de Goede <[email protected]>
Thanks. I'll add Cc: stable when applying this, too.
Signature · 3 lines
Regards, Sakari Ailus