| 1 |
|
| 2 |
|
| 3 |
#include <acpi/acpi_device.h> |
| 4 |
#include <acpi/acpigen.h> |
| 5 |
#include <device/device.h> |
| 6 |
|
| 7 |
#include "chip.h" |
| 8 |
|
| 9 |
static const char *get_spkr_tplg_str(enum _spkr_tplg tplg) |
| 10 |
{ |
| 11 |
switch (tplg) { |
| 12 |
case max98373: return "max98373"; |
| 13 |
case max98373_ssp2: return "max98373-ssp2"; |
| 14 |
case max98360a: return "max98360a"; |
| 15 |
case max98357a: return "max98357a"; |
| 16 |
case max98357a_tdm: return "max98357a-tdm"; |
| 17 |
case max98390: return "max98390"; |
| 18 |
case rt1011: return "rt1011"; |
| 19 |
case rt1015: return "rt1015"; |
| 20 |
case rt1019: return "rt1019"; |
| 21 |
case rt5650_sp: return "rt5650"; |
| 22 |
default: return "default"; |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
static const char *get_jack_tplg_str(enum _jack_tplg tplg) |
| 27 |
{ |
| 28 |
switch (tplg) { |
| 29 |
case cs42l42: return "cs42l42"; |
| 30 |
case da7219: return "da7219"; |
| 31 |
case nau8825: return "nau8825"; |
| 32 |
case rt5650_hp: return "rt5650"; |
| 33 |
case rt5682: return "rt5682"; |
| 34 |
default: return "default"; |
| 35 |
} |
| 36 |
} |
| 37 |
|
| 38 |
static const char *get_mic_tplg_str(enum _mic_tplg tplg) |
| 39 |
{ |
| 40 |
switch (tplg) { |
| 41 |
case _1ch: return "1ch"; |
| 42 |
case _2ch_pdm0: return "2ch-pdm0"; |
| 43 |
case _2ch_pdm1: return "2ch-pdm1"; |
| 44 |
case _4ch: return "4ch"; |
| 45 |
default: return "default"; |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
static void sof_fill_ssdt_generator(const struct device *dev) |
| 50 |
{ |
| 51 |
struct drivers_sof_config *config = dev->chip_info; |
| 52 |
const char *scope = acpi_device_scope(dev); |
| 53 |
struct acpi_dp *dsd; |
| 54 |
|
| 55 |
if (!dev->enabled || !config || !scope) |
| 56 |
return; |
| 57 |
|
| 58 |
|
| 59 |
acpigen_write_scope(scope); |
| 60 |
|
| 61 |
|
| 62 |
dsd = acpi_dp_new_table("_DSD"); |
| 63 |
acpi_dp_add_string(dsd, "speaker-tplg", |
| 64 |
get_spkr_tplg_str(config->spkr_tplg)); |
| 65 |
acpi_dp_add_string(dsd, "hp-tplg", |
| 66 |
get_jack_tplg_str(config->jack_tplg)); |
| 67 |
acpi_dp_add_string(dsd, "mic-tplg", |
| 68 |
get_mic_tplg_str(config->mic_tplg)); |
| 69 |
acpi_dp_write(dsd); |
| 70 |
acpigen_pop_len(); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
static struct device_operations sof_ops = { |
| 75 |
.read_resources = noop_read_resources, |
| 76 |
.set_resources = noop_set_resources, |
| 77 |
.acpi_fill_ssdt = sof_fill_ssdt_generator, |
| 78 |
}; |
| 79 |
|
| 80 |
static void sof_enable(struct device *dev) |
| 81 |
{ |
| 82 |
dev->ops = &sof_ops; |
| 83 |
} |
| 84 |
|
| 85 |
struct chip_operations drivers_sof_ops = { |
| 86 |
.name = "SOF", |
| 87 |
.enable_dev = sof_enable |
| 88 |
}; |