This file contains two types of quirks, both checking DMI for
machine-specific strings and returning machine data for a matching entry.
The first one, `cht_quirk`, is used to override the default entry for an
existing ACPI codec node if the node's info is invalid. It returns either
the matched machine data or the default entry if no match is found.
The second one, `cht_yt3_quirk_cb`, is used for devices (originally the
Lenovo Yoga Tab 3 Pro) without a valid codec DSDT entry. It is bound to
the SST ACPI node and returns either the matched machine data or NULL if
no match is found.
To allow adding new machine entries to the second case and to use a single
DMI match entry for both cases (for example, if two variants of one device
exist: one with a valid ACPI entry and one without, like the Lenovo Yoga
Book YB1-X91 and YB1-X90 - Windows and Android versions), reorganize
these quirks functions to use the same approach: machine data is set in
the matched dmi_system_id entry as driver_data field.
Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com>
---
sound/soc/intel/common/soc-acpi-intel-cht-match.c | 100 +++++++++-------------
1 file changed, 42 insertions(+), 58 deletions(-)
diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
index e4c3492a0c28..57097c1d011e 100644
--- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c
@@ -9,47 +9,63 @@
#include <sound/soc-acpi.h>
#include <sound/soc-acpi-intel-match.h>
-static unsigned long cht_machine_id;
-
-#define CHT_SURFACE_MACH 1
+static struct snd_soc_acpi_mach cht_surface_mach = {
+ .id = "10EC5640",
+ .drv_name = "cht-bsw-rt5645",
+ .fw_filename = "intel/fw_sst_22a8.bin",
+ .board = "cht-bsw",
+ .sof_tplg_filename = "sof-cht-rt5645.tplg",
+};
-static int cht_surface_quirk_cb(const struct dmi_system_id *id)
-{
- cht_machine_id = CHT_SURFACE_MACH;
- return 1;
-}
+static struct snd_soc_acpi_mach cht_lenovo_yoga_tab3_x90_mach = {
+ .id = "10WM5102",
+ .drv_name = "bytcr_wm5102",
+ .fw_filename = "intel/fw_sst_22a8.bin",
+ .board = "bytcr_wm5102",
+ .sof_tplg_filename = "sof-cht-wm5102.tplg",
+};
static const struct dmi_system_id cht_table[] = {
{
- .callback = cht_surface_quirk_cb,
+ .driver_data = (void *)&cht_surface_mach,
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
DMI_MATCH(DMI_PRODUCT_NAME, "Surface 3"),
},
},
+ {
+ /*
+ * The Lenovo Yoga Tab 3 Pro YT3-X90, with Android factory OS
+ * has a buggy DSDT with the codec not being listed at all.
+ */
+ .driver_data = (void *)&cht_lenovo_yoga_tab3_x90_mach,
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
+ DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"),
+ },
+ },
{ }
};
-static struct snd_soc_acpi_mach cht_surface_mach = {
- .id = "10EC5640",
- .drv_name = "cht-bsw-rt5645",
- .fw_filename = "intel/fw_sst_22a8.bin",
- .board = "cht-bsw",
- .sof_tplg_filename = "sof-cht-rt5645.tplg",
-};
-
static struct snd_soc_acpi_mach *cht_quirk(void *arg)
{
struct snd_soc_acpi_mach *mach = arg;
+ const struct dmi_system_id *match;
- dmi_check_system(cht_table);
-
- if (cht_machine_id == CHT_SURFACE_MACH)
- return &cht_surface_mach;
+ match = dmi_first_match(cht_table);
+ if (match)
+ return (struct snd_soc_acpi_mach *)match->driver_data;
else
return mach;
}
+static struct snd_soc_acpi_mach *cht_quirk_nocodec(void *arg)
+{
+ struct snd_soc_acpi_mach *mach = cht_quirk(arg);
+
+ return mach == arg ? NULL : mach;
+}
+
/*
* Some tablets with Android factory OS have buggy DSDTs with an ESSX8316 device
* in the ACPI tables. While they are not using an ESS8316 codec. These DSDTs
@@ -75,38 +91,6 @@ static struct snd_soc_acpi_mach *cht_ess8316_quirk(void *arg)
return arg;
}
-/*
- * The Lenovo Yoga Tab 3 Pro YT3-X90, with Android factory OS has a buggy DSDT
- * with the coded not being listed at all.
- */
-static const struct dmi_system_id lenovo_yoga_tab3_x90[] = {
- {
- /* Lenovo Yoga Tab 3 Pro YT3-X90, codec missing from DSDT */
- .matches = {
- DMI_MATCH(DMI_SYS_VENDOR, "Intel Corporation"),
- DMI_MATCH(DMI_PRODUCT_VERSION, "Blade3-10A-001"),
- },
- },
- { }
-};
-
-static struct snd_soc_acpi_mach cht_lenovo_yoga_tab3_x90_mach = {
- .id = "10WM5102",
- .drv_name = "bytcr_wm5102",
- .fw_filename = "intel/fw_sst_22a8.bin",
- .board = "bytcr_wm5102",
- .sof_tplg_filename = "sof-cht-wm5102.tplg",
-};
-
-static struct snd_soc_acpi_mach *lenovo_yt3_x90_quirk(void *arg)
-{
- if (dmi_check_system(lenovo_yoga_tab3_x90))
- return &cht_lenovo_yoga_tab3_x90_mach;
-
- /* Skip wildcard match snd_soc_acpi_intel_cherrytrail_machines[] entry */
- return NULL;
-}
-
static const struct snd_soc_acpi_codecs rt5640_comp_ids = {
.num_codecs = 2,
.codecs = { "10EC5640", "10EC3276" },
@@ -208,14 +192,14 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cherrytrail_machines[] = {
.sof_tplg_filename = "sof-cht-src-50khz-pcm512x.tplg",
},
/*
- * Special case for the Lenovo Yoga Tab 3 Pro YT3-X90 where the DSDT
- * misses the codec. Match on the SST id instead, lenovo_yt3_x90_quirk()
- * will return a YT3 specific mach or NULL when called on other hw,
- * skipping this entry.
+ * Special case for devices where the DSDT misses the codec. Match on
+ * the SST id instead, cht_quirk_nocodec() will return a
+ * device-specific mach for matched device or NULL when called on other
+ * hw, skipping this entry.
*/
{
.id = "808622A8",
- .machine_quirk = lenovo_yt3_x90_quirk,
+ .machine_quirk = cht_quirk_nocodec,
},
#if IS_ENABLED(CONFIG_SND_SOC_INTEL_BYT_CHT_NOCODEC_MACH)
--
2.51.0
On 01/03/2026 23:33, Yauhen Kharuzhy wrote: > This file contains two types of quirks, both checking DMI for > machine-specific strings and returning machine data for a matching entry. > > The first one, `cht_quirk`, is used to override the default entry for an > existing ACPI codec node if the node's info is invalid. It returns either > the matched machine data or the default entry if no match is found. > > The second one, `cht_yt3_quirk_cb`, is used for devices (originally the > Lenovo Yoga Tab 3 Pro) without a valid codec DSDT entry. It is bound to > the SST ACPI node and returns either the matched machine data or NULL if > no match is found. > > To allow adding new machine entries to the second case and to use a single > DMI match entry for both cases (for example, if two variants of one device > exist: one with a valid ACPI entry and one without, like the Lenovo Yoga > Book YB1-X91 and YB1-X90 - Windows and Android versions), reorganize > these quirks functions to use the same approach: machine data is set in > the matched dmi_system_id entry as driver_data field. > > Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com> > --- > sound/soc/intel/common/soc-acpi-intel-cht-match.c | 100 +++++++++------------- > 1 file changed, 42 insertions(+), 58 deletions(-) > > diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c > index e4c3492a0c28..57097c1d011e 100644 > --- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c > +++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c > > +static struct snd_soc_acpi_mach *cht_quirk_nocodec(void *arg) This is confusing, why it is _nocodec? cht_quirk_strict() or something might be better? -- Péter
On Mon, Mar 02, 2026 at 05:54:05PM +0200, Péter Ujfalusi wrote: > > > On 01/03/2026 23:33, Yauhen Kharuzhy wrote: > > This file contains two types of quirks, both checking DMI for > > machine-specific strings and returning machine data for a matching entry. > > > > The first one, `cht_quirk`, is used to override the default entry for an > > existing ACPI codec node if the node's info is invalid. It returns either > > the matched machine data or the default entry if no match is found. > > > > The second one, `cht_yt3_quirk_cb`, is used for devices (originally the > > Lenovo Yoga Tab 3 Pro) without a valid codec DSDT entry. It is bound to > > the SST ACPI node and returns either the matched machine data or NULL if > > no match is found. > > > > To allow adding new machine entries to the second case and to use a single > > DMI match entry for both cases (for example, if two variants of one device > > exist: one with a valid ACPI entry and one without, like the Lenovo Yoga > > Book YB1-X91 and YB1-X90 - Windows and Android versions), reorganize > > these quirks functions to use the same approach: machine data is set in > > the matched dmi_system_id entry as driver_data field. > > > > Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com> > > --- > > sound/soc/intel/common/soc-acpi-intel-cht-match.c | 100 +++++++++------------- > > 1 file changed, 42 insertions(+), 58 deletions(-) > > > > diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c > > index e4c3492a0c28..57097c1d011e 100644 > > --- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c > > +++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c > > > > > +static struct snd_soc_acpi_mach *cht_quirk_nocodec(void *arg) > > This is confusing, why it is _nocodec? > cht_quirk_strict() or something might be better? Something like "a quirk for machines without of codec definition in the ACPI DSDT". But yes, it is confusing because we have separated "nocodec" entry in the table. I just couldn't think of anything better. 'strict' doesn't seem to reflect the meaning for my opinion also. > > -- > Péter > -- Yauhen Kharuzhy
On 03/03/2026 00:33, Yauhen Kharuzhy wrote: > On Mon, Mar 02, 2026 at 05:54:05PM +0200, Péter Ujfalusi wrote: >> >> >> On 01/03/2026 23:33, Yauhen Kharuzhy wrote: >>> This file contains two types of quirks, both checking DMI for >>> machine-specific strings and returning machine data for a matching entry. >>> >>> The first one, `cht_quirk`, is used to override the default entry for an >>> existing ACPI codec node if the node's info is invalid. It returns either >>> the matched machine data or the default entry if no match is found. >>> >>> The second one, `cht_yt3_quirk_cb`, is used for devices (originally the >>> Lenovo Yoga Tab 3 Pro) without a valid codec DSDT entry. It is bound to >>> the SST ACPI node and returns either the matched machine data or NULL if >>> no match is found. >>> >>> To allow adding new machine entries to the second case and to use a single >>> DMI match entry for both cases (for example, if two variants of one device >>> exist: one with a valid ACPI entry and one without, like the Lenovo Yoga >>> Book YB1-X91 and YB1-X90 - Windows and Android versions), reorganize >>> these quirks functions to use the same approach: machine data is set in >>> the matched dmi_system_id entry as driver_data field. >>> >>> Signed-off-by: Yauhen Kharuzhy <jekhor@gmail.com> >>> --- >>> sound/soc/intel/common/soc-acpi-intel-cht-match.c | 100 +++++++++------------- >>> 1 file changed, 42 insertions(+), 58 deletions(-) >>> >>> diff --git a/sound/soc/intel/common/soc-acpi-intel-cht-match.c b/sound/soc/intel/common/soc-acpi-intel-cht-match.c >>> index e4c3492a0c28..57097c1d011e 100644 >>> --- a/sound/soc/intel/common/soc-acpi-intel-cht-match.c >>> +++ b/sound/soc/intel/common/soc-acpi-intel-cht-match.c >> >>> >>> +static struct snd_soc_acpi_mach *cht_quirk_nocodec(void *arg) >> >> This is confusing, why it is _nocodec? >> cht_quirk_strict() or something might be better? > > Something like "a quirk for machines without of codec definition in the > ACPI DSDT". But yes, it is confusing because we have separated "nocodec" entry > in the table. I just couldn't think of anything better. 'strict' doesn't > seem to reflect the meaning for my opinion also. I see, the strict came to mind to imply that it will only return with a match if there is a match, otherwise it will return NULL. No fallback to default (or self match), only a strict match is allowed. cht_match_only_quirk(), cht_no_fallback_quirk() ? I'm extremely bad at naming.. > > >> >> -- >> Péter >> > -- Péter
© 2016 - 2026 Red Hat, Inc.