Kuninori Morimoto | 7730bb1 | 2018-07-02 06:24:04 +0000 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 |
| 2 | * |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 3 | * Copyright (C) 2013-15, Intel Corporation. All rights reserved. |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef __LINUX_SND_SOC_ACPI_H |
| 7 | #define __LINUX_SND_SOC_ACPI_H |
| 8 | |
| 9 | #include <linux/stddef.h> |
| 10 | #include <linux/acpi.h> |
Pierre-Louis Bossart | 845ab40 | 2018-01-04 16:35:52 -0600 | [diff] [blame] | 11 | #include <linux/mod_devicetable.h> |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 12 | |
| 13 | struct snd_soc_acpi_package_context { |
| 14 | char *name; /* package name */ |
| 15 | int length; /* number of elements */ |
| 16 | struct acpi_buffer *format; |
| 17 | struct acpi_buffer *state; |
| 18 | bool data_valid; |
| 19 | }; |
| 20 | |
Pierre-Louis Bossart | 2be2d57 | 2018-01-11 13:52:09 -0600 | [diff] [blame] | 21 | /* codec name is used in DAIs is i2c-<HID>:00 with HID being 8 chars */ |
| 22 | #define SND_ACPI_I2C_ID_LEN (4 + ACPI_ID_LEN + 3 + 1) |
| 23 | |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 24 | #if IS_ENABLED(CONFIG_ACPI) |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 25 | bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN], |
| 26 | struct snd_soc_acpi_package_context *ctx); |
| 27 | #else |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 28 | static inline bool |
| 29 | snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN], |
| 30 | struct snd_soc_acpi_package_context *ctx) |
| 31 | { |
| 32 | return false; |
| 33 | } |
| 34 | #endif |
| 35 | |
| 36 | /* acpi match */ |
| 37 | struct snd_soc_acpi_mach * |
| 38 | snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines); |
| 39 | |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 40 | /** |
| 41 | * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are |
| 42 | * related to the hardware, except for the firmware and topology file names. |
Pierre-Louis Bossart | 976b5a0 | 2017-10-12 18:49:40 -0500 | [diff] [blame] | 43 | * A platform supported by legacy and Sound Open Firmware (SOF) would expose |
| 44 | * all firmware/topology related fields. |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 45 | * |
| 46 | * @id: ACPI ID (usually the codec's) used to find a matching machine driver. |
| 47 | * @drv_name: machine driver name |
Pierre-Louis Bossart | 976b5a0 | 2017-10-12 18:49:40 -0500 | [diff] [blame] | 48 | * @fw_filename: firmware file name. Used when SOF is not enabled. |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 49 | * @board: board name |
| 50 | * @machine_quirk: pointer to quirk, usually based on DMI information when |
| 51 | * ACPI ID alone is not sufficient, wrong or misleading |
| 52 | * @quirk_data: data used to uniquely identify a machine, usually a list of |
| 53 | * audio codecs whose presence if checked with ACPI |
| 54 | * @pdata: intended for platform data or machine specific-ops. This structure |
| 55 | * is not constant since this field may be updated at run-time |
Pierre-Louis Bossart | 976b5a0 | 2017-10-12 18:49:40 -0500 | [diff] [blame] | 56 | * @sof_fw_filename: Sound Open Firmware file name, if enabled |
| 57 | * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled |
| 58 | * @asoc_plat_name: ASoC platform name, used for binding machine drivers |
| 59 | * if non NULL |
| 60 | * @new_mach_data: machine driver private data fixup |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 61 | */ |
| 62 | /* Descriptor for SST ASoC machine driver */ |
| 63 | struct snd_soc_acpi_mach { |
| 64 | const u8 id[ACPI_ID_LEN]; |
| 65 | const char *drv_name; |
| 66 | const char *fw_filename; |
| 67 | const char *board; |
| 68 | struct snd_soc_acpi_mach * (*machine_quirk)(void *arg); |
| 69 | const void *quirk_data; |
| 70 | void *pdata; |
Pierre-Louis Bossart | 976b5a0 | 2017-10-12 18:49:40 -0500 | [diff] [blame] | 71 | const char *sof_fw_filename; |
| 72 | const char *sof_tplg_filename; |
| 73 | const char *asoc_plat_name; |
| 74 | struct platform_device * (*new_mach_data)(void *pdata); |
Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame] | 75 | }; |
| 76 | |
| 77 | #define SND_SOC_ACPI_MAX_CODECS 3 |
| 78 | |
| 79 | /** |
| 80 | * struct snd_soc_acpi_codecs: Structure to hold secondary codec information |
| 81 | * apart from the matched one, this data will be passed to the quirk function |
| 82 | * to match with the ACPI detected devices |
| 83 | * |
| 84 | * @num_codecs: number of secondary codecs used in the platform |
| 85 | * @codecs: holds the codec IDs |
| 86 | * |
| 87 | */ |
| 88 | struct snd_soc_acpi_codecs { |
| 89 | int num_codecs; |
| 90 | u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN]; |
| 91 | }; |
| 92 | |
| 93 | /* check all codecs */ |
| 94 | struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg); |
| 95 | |
| 96 | #endif |