summaryrefslogtreecommitdiffstats
path: root/sound/soc/intel/common/soc-acpi-intel-sdca-quirks.c
blob: e62ef81214ffe5c98496f86cb77813acf6350456 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// SPDX-License-Identifier: GPL-2.0-only
/*
 * soc-acpi-intel-sdca-quirks.c - tables and support for SDCA quirks
 *
 * Copyright (c) 2024, Intel Corporation.
 *
 */

#include <linux/dmi.h>
#include <linux/soundwire/sdw_intel.h>
#include <sound/sdca.h>
#include <sound/soc-acpi.h>
#include "soc-acpi-intel-sdca-quirks.h"

/*
 * Pretend machine quirk. The argument type is not the traditional
 * 'struct snd_soc_acpi_mach' pointer but instead the sdw_intel_ctx
 * which contains the peripheral information required for the
 * SoundWire/SDCA filter on the SMART_MIC setup and interface
 * revision. When the return value is false, the entry in the
 * 'snd_soc_acpi_mach' table needs to be skipped.
 */
bool snd_soc_acpi_intel_sdca_is_device_rt712_vb(void *arg)
{
	struct sdw_intel_ctx *ctx = arg;
	int i;

	if (!ctx)
		return false;

	for (i = 0; i < ctx->peripherals->num_peripherals; i++) {
		if (sdca_device_quirk_match(ctx->peripherals->array[i],
					    SDCA_QUIRKS_RT712_VB))
			return true;
	}

	return false;
}
EXPORT_SYMBOL_NS(snd_soc_acpi_intel_sdca_is_device_rt712_vb, "SND_SOC_ACPI_INTEL_SDCA_QUIRKS");

static const struct dmi_system_id function_topology_quirk_table[] = {
	{
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Google"),
		},
	},
	{}
};

bool snd_soc_acpi_intel_no_function_topology(void *arg)
{
	return !!dmi_check_system(function_topology_quirk_table);
}
EXPORT_SYMBOL_NS(snd_soc_acpi_intel_no_function_topology, "SND_SOC_ACPI_INTEL_SDCA_QUIRKS");

static const struct dmi_system_id force_function_topology_quirk_table[] = {
	{
		.matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
			DMI_MATCH(DMI_PRODUCT_NAME, "83R0"),
		},
	},
	{}
};

bool snd_soc_acpi_intel_force_function_topology(void *arg)
{
	return !dmi_check_system(force_function_topology_quirk_table);
}
EXPORT_SYMBOL_NS(snd_soc_acpi_intel_force_function_topology, "SND_SOC_ACPI_INTEL_SDCA_QUIRKS");

bool snd_soc_acpi_intel_rt712_vb_no_function_topology(void *arg)
{
	return snd_soc_acpi_intel_sdca_is_device_rt712_vb(arg) &&
	       snd_soc_acpi_intel_no_function_topology(arg);
}
EXPORT_SYMBOL_NS(snd_soc_acpi_intel_rt712_vb_no_function_topology,
		 "SND_SOC_ACPI_INTEL_SDCA_QUIRKS");

MODULE_DESCRIPTION("ASoC ACPI Intel SDCA quirks");
MODULE_LICENSE("GPL");
MODULE_IMPORT_NS("SND_SOC_SDCA");