Pierre-Louis Bossart | 7feb2f7 | 2017-10-12 18:49:38 -0500 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2013-15, Intel Corporation. All rights reserved. |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License version |
| 6 | * 2 as published by the Free Software Foundation. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef __LINUX_SND_SOC_ACPI_H |
| 16 | #define __LINUX_SND_SOC_ACPI_H |
| 17 | |
| 18 | #include <linux/stddef.h> |
| 19 | #include <linux/acpi.h> |
| 20 | |
| 21 | struct snd_soc_acpi_package_context { |
| 22 | char *name; /* package name */ |
| 23 | int length; /* number of elements */ |
| 24 | struct acpi_buffer *format; |
| 25 | struct acpi_buffer *state; |
| 26 | bool data_valid; |
| 27 | }; |
| 28 | |
| 29 | #if IS_ENABLED(CONFIG_ACPI) |
| 30 | /* translation fron HID to I2C name, needed for DAI codec_name */ |
| 31 | const char *snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN]); |
| 32 | bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN], |
| 33 | struct snd_soc_acpi_package_context *ctx); |
| 34 | #else |
| 35 | static inline const char * |
| 36 | snd_soc_acpi_find_name_from_hid(const u8 hid[ACPI_ID_LEN]) |
| 37 | { |
| 38 | return NULL; |
| 39 | } |
| 40 | static inline bool |
| 41 | snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN], |
| 42 | struct snd_soc_acpi_package_context *ctx) |
| 43 | { |
| 44 | return false; |
| 45 | } |
| 46 | #endif |
| 47 | |
| 48 | /* acpi match */ |
| 49 | struct snd_soc_acpi_mach * |
| 50 | snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines); |
| 51 | |
| 52 | /* acpi check hid */ |
| 53 | bool snd_soc_acpi_check_hid(const u8 hid[ACPI_ID_LEN]); |
| 54 | |
| 55 | /** |
| 56 | * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are |
| 57 | * related to the hardware, except for the firmware and topology file names. |
| 58 | * |
| 59 | * @id: ACPI ID (usually the codec's) used to find a matching machine driver. |
| 60 | * @drv_name: machine driver name |
| 61 | * @fw_filename: firmware file name. |
| 62 | * @board: board name |
| 63 | * @machine_quirk: pointer to quirk, usually based on DMI information when |
| 64 | * ACPI ID alone is not sufficient, wrong or misleading |
| 65 | * @quirk_data: data used to uniquely identify a machine, usually a list of |
| 66 | * audio codecs whose presence if checked with ACPI |
| 67 | * @pdata: intended for platform data or machine specific-ops. This structure |
| 68 | * is not constant since this field may be updated at run-time |
| 69 | */ |
| 70 | /* Descriptor for SST ASoC machine driver */ |
| 71 | struct snd_soc_acpi_mach { |
| 72 | const u8 id[ACPI_ID_LEN]; |
| 73 | const char *drv_name; |
| 74 | const char *fw_filename; |
| 75 | const char *board; |
| 76 | struct snd_soc_acpi_mach * (*machine_quirk)(void *arg); |
| 77 | const void *quirk_data; |
| 78 | void *pdata; |
| 79 | }; |
| 80 | |
| 81 | #define SND_SOC_ACPI_MAX_CODECS 3 |
| 82 | |
| 83 | /** |
| 84 | * struct snd_soc_acpi_codecs: Structure to hold secondary codec information |
| 85 | * apart from the matched one, this data will be passed to the quirk function |
| 86 | * to match with the ACPI detected devices |
| 87 | * |
| 88 | * @num_codecs: number of secondary codecs used in the platform |
| 89 | * @codecs: holds the codec IDs |
| 90 | * |
| 91 | */ |
| 92 | struct snd_soc_acpi_codecs { |
| 93 | int num_codecs; |
| 94 | u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN]; |
| 95 | }; |
| 96 | |
| 97 | /* check all codecs */ |
| 98 | struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg); |
| 99 | |
| 100 | #endif |