Linux Audio

Check our new training course

Loading...
v6.8
  1/* SPDX-License-Identifier: GPL-2.0-only
  2 *
  3 * Copyright (C) 2013-15, Intel Corporation. All rights reserved.
  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>
 11#include <linux/mod_devicetable.h>
 12#include <linux/soundwire/sdw.h>
 13
 14struct snd_soc_acpi_package_context {
 15	char *name;           /* package name */
 16	int length;           /* number of elements */
 17	struct acpi_buffer *format;
 18	struct acpi_buffer *state;
 19	bool data_valid;
 20};
 21
 22/* codec name is used in DAIs is i2c-<HID>:00 with HID being 8 chars */
 23#define SND_ACPI_I2C_ID_LEN (4 + ACPI_ID_LEN + 3 + 1)
 24
 25#if IS_ENABLED(CONFIG_ACPI)
 26/* acpi match */
 27struct snd_soc_acpi_mach *
 28snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines);
 29
 30bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
 31				    struct snd_soc_acpi_package_context *ctx);
 32
 33/* check all codecs */
 34struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg);
 35
 36#else
 37/* acpi match */
 38static inline struct snd_soc_acpi_mach *
 39snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines)
 40{
 41	return NULL;
 42}
 43
 44static inline bool
 45snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
 46				   struct snd_soc_acpi_package_context *ctx)
 47{
 48	return false;
 49}
 50
 51/* check all codecs */
 52static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg)
 53{
 54	return NULL;
 55}
 56#endif
 57
 58/**
 59 * snd_soc_acpi_mach_params: interface for machine driver configuration
 60 *
 61 * @acpi_ipc_irq_index: used for BYT-CR detection
 62 * @platform: string used for HDAudio codec support
 63 * @codec_mask: used for HDAudio support
 64 * @dmic_num: number of SoC- or chipset-attached PDM digital microphones
 65 * @common_hdmi_codec_drv: use commom HDAudio HDMI codec driver
 66 * @link_mask: SoundWire links enabled on the board
 67 * @links: array of SoundWire link _ADR descriptors, null terminated
 68 * @i2s_link_mask: I2S/TDM links enabled on the board
 69 * @num_dai_drivers: number of elements in @dai_drivers
 70 * @dai_drivers: pointer to dai_drivers, used e.g. in nocodec mode
 71 * @subsystem_vendor: optional PCI SSID vendor value
 72 * @subsystem_device: optional PCI SSID device value
 
 73 * @subsystem_id_set: true if a value has been written to
 74 *		      subsystem_vendor and subsystem_device.
 
 75 */
 76struct snd_soc_acpi_mach_params {
 77	u32 acpi_ipc_irq_index;
 78	const char *platform;
 79	u32 codec_mask;
 80	u32 dmic_num;
 81	bool common_hdmi_codec_drv;
 82	u32 link_mask;
 83	const struct snd_soc_acpi_link_adr *links;
 84	u32 i2s_link_mask;
 85	u32 num_dai_drivers;
 86	struct snd_soc_dai_driver *dai_drivers;
 87	unsigned short subsystem_vendor;
 88	unsigned short subsystem_device;
 
 89	bool subsystem_id_set;
 
 90};
 91
 92/**
 93 * snd_soc_acpi_endpoint - endpoint descriptor
 94 * @num: endpoint number (mandatory, unique per device)
 95 * @aggregated: 0 (independent) or 1 (logically grouped)
 96 * @group_position: zero-based order (only when @aggregated is 1)
 97 * @group_id: platform-unique group identifier (only when @aggregrated is 1)
 98 */
 99struct snd_soc_acpi_endpoint {
100	u8 num;
101	u8 aggregated;
102	u8 group_position;
103	u8 group_id;
104};
105
106/**
107 * snd_soc_acpi_adr_device - descriptor for _ADR-enumerated device
108 * @adr: 64 bit ACPI _ADR value
109 * @num_endpoints: number of endpoints for this device
110 * @endpoints: array of endpoints
111 * @name_prefix: string used for codec controls
112 */
113struct snd_soc_acpi_adr_device {
114	const u64 adr;
115	const u8 num_endpoints;
116	const struct snd_soc_acpi_endpoint *endpoints;
117	const char *name_prefix;
118};
119
120/**
121 * snd_soc_acpi_link_adr - ACPI-based list of _ADR enumerated devices
122 * @mask: one bit set indicates the link this list applies to
123 * @num_adr: ARRAY_SIZE of devices
124 * @adr_d: array of devices
125 *
126 * The number of devices per link can be more than 1, e.g. in SoundWire
127 * multi-drop configurations.
128 */
129
130struct snd_soc_acpi_link_adr {
131	const u32 mask;
132	const u32 num_adr;
133	const struct snd_soc_acpi_adr_device *adr_d;
134};
135
136/*
137 * when set the topology uses the -ssp<N> suffix, where N is determined based on
138 * BIOS or DMI information
139 */
140#define SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER BIT(0)
141
142/*
143 * when more than one SSP is reported in the link mask, use the most significant.
144 * This choice was found to be valid on platforms with ES8336 codecs.
145 */
146#define SND_SOC_ACPI_TPLG_INTEL_SSP_MSB BIT(1)
147
148/*
149 * when set the topology uses the -dmic<N>ch suffix, where N is determined based on
150 * BIOS or DMI information
151 */
152#define SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER BIT(2)
153
 
 
 
 
 
 
 
 
 
 
 
 
154/**
155 * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are
156 * related to the hardware, except for the firmware and topology file names.
157 * A platform supported by legacy and Sound Open Firmware (SOF) would expose
158 * all firmware/topology related fields.
159 *
160 * @id: ACPI ID (usually the codec's) used to find a matching machine driver.
161 * @uid: ACPI Unique ID, can be used to disambiguate matches.
162 * @comp_ids: list of compatible audio codecs using the same machine driver,
163 * firmware and topology
164 * @link_mask: describes required board layout, e.g. for SoundWire.
165 * @links: array of link _ADR descriptors, null terminated.
166 * @drv_name: machine driver name
167 * @fw_filename: firmware file name. Used when SOF is not enabled.
168 * @tplg_filename: topology file name. Used when SOF is not enabled.
169 * @board: board name
170 * @machine_quirk: pointer to quirk, usually based on DMI information when
171 * ACPI ID alone is not sufficient, wrong or misleading
172 * @quirk_data: data used to uniquely identify a machine, usually a list of
173 * audio codecs whose presence if checked with ACPI
 
 
 
 
174 * @pdata: intended for platform data or machine specific-ops. This structure
175 *  is not constant since this field may be updated at run-time
176 * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled
177 * @tplg_quirk_mask: quirks to select different topology files dynamically
178 */
179/* Descriptor for SST ASoC machine driver */
180struct snd_soc_acpi_mach {
181	u8 id[ACPI_ID_LEN];
182	const char *uid;
183	const struct snd_soc_acpi_codecs *comp_ids;
184	const u32 link_mask;
185	const struct snd_soc_acpi_link_adr *links;
186	const char *drv_name;
187	const char *fw_filename;
188	const char *tplg_filename;
189	const char *board;
190	struct snd_soc_acpi_mach * (*machine_quirk)(void *arg);
191	const void *quirk_data;
 
192	void *pdata;
193	struct snd_soc_acpi_mach_params mach_params;
194	const char *sof_tplg_filename;
195	const u32 tplg_quirk_mask;
196};
197
198#define SND_SOC_ACPI_MAX_CODECS 3
199
200/**
201 * struct snd_soc_acpi_codecs: Structure to hold secondary codec information
202 * apart from the matched one, this data will be passed to the quirk function
203 * to match with the ACPI detected devices
204 *
205 * @num_codecs: number of secondary codecs used in the platform
206 * @codecs: holds the codec IDs
207 *
208 */
209struct snd_soc_acpi_codecs {
210	int num_codecs;
211	u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN];
212};
213
214static inline bool snd_soc_acpi_sof_parent(struct device *dev)
215{
216	return dev->parent && dev->parent->driver && dev->parent->driver->name &&
217		!strncmp(dev->parent->driver->name, "sof-audio-acpi", strlen("sof-audio-acpi"));
218}
219
220bool snd_soc_acpi_sdw_link_slaves_found(struct device *dev,
221					const struct snd_soc_acpi_link_adr *link,
222					struct sdw_extended_slave_id *ids,
223					int num_slaves);
224
225#endif
v6.13.7
  1/* SPDX-License-Identifier: GPL-2.0-only
  2 *
  3 * Copyright (C) 2013-15, Intel Corporation
  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>
 11#include <linux/mod_devicetable.h>
 12#include <linux/soundwire/sdw.h>
 13
 14struct snd_soc_acpi_package_context {
 15	char *name;           /* package name */
 16	int length;           /* number of elements */
 17	struct acpi_buffer *format;
 18	struct acpi_buffer *state;
 19	bool data_valid;
 20};
 21
 22/* codec name is used in DAIs is i2c-<HID>:00 with HID being 8 chars */
 23#define SND_ACPI_I2C_ID_LEN (4 + ACPI_ID_LEN + 3 + 1)
 24
 25#if IS_ENABLED(CONFIG_ACPI)
 26/* acpi match */
 27struct snd_soc_acpi_mach *
 28snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines);
 29
 30bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
 31				    struct snd_soc_acpi_package_context *ctx);
 32
 33/* check all codecs */
 34struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg);
 35
 36#else
 37/* acpi match */
 38static inline struct snd_soc_acpi_mach *
 39snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines)
 40{
 41	return NULL;
 42}
 43
 44static inline bool
 45snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
 46				   struct snd_soc_acpi_package_context *ctx)
 47{
 48	return false;
 49}
 50
 51/* check all codecs */
 52static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg)
 53{
 54	return NULL;
 55}
 56#endif
 57
 58/**
 59 * snd_soc_acpi_mach_params: interface for machine driver configuration
 60 *
 61 * @acpi_ipc_irq_index: used for BYT-CR detection
 62 * @platform: string used for HDAudio codec support
 63 * @codec_mask: used for HDAudio support
 64 * @dmic_num: number of SoC- or chipset-attached PDM digital microphones
 
 65 * @link_mask: SoundWire links enabled on the board
 66 * @links: array of SoundWire link _ADR descriptors, null terminated
 67 * @i2s_link_mask: I2S/TDM links enabled on the board
 68 * @num_dai_drivers: number of elements in @dai_drivers
 69 * @dai_drivers: pointer to dai_drivers, used e.g. in nocodec mode
 70 * @subsystem_vendor: optional PCI SSID vendor value
 71 * @subsystem_device: optional PCI SSID device value
 72 * @subsystem_rev: optional PCI SSID revision value
 73 * @subsystem_id_set: true if a value has been written to
 74 *		      subsystem_vendor and subsystem_device.
 75 * @bt_link_mask: BT offload link enabled on the board
 76 */
 77struct snd_soc_acpi_mach_params {
 78	u32 acpi_ipc_irq_index;
 79	const char *platform;
 80	u32 codec_mask;
 81	u32 dmic_num;
 
 82	u32 link_mask;
 83	const struct snd_soc_acpi_link_adr *links;
 84	u32 i2s_link_mask;
 85	u32 num_dai_drivers;
 86	struct snd_soc_dai_driver *dai_drivers;
 87	unsigned short subsystem_vendor;
 88	unsigned short subsystem_device;
 89	unsigned short subsystem_rev;
 90	bool subsystem_id_set;
 91	u32 bt_link_mask;
 92};
 93
 94/**
 95 * snd_soc_acpi_endpoint - endpoint descriptor
 96 * @num: endpoint number (mandatory, unique per device)
 97 * @aggregated: 0 (independent) or 1 (logically grouped)
 98 * @group_position: zero-based order (only when @aggregated is 1)
 99 * @group_id: platform-unique group identifier (only when @aggregrated is 1)
100 */
101struct snd_soc_acpi_endpoint {
102	u8 num;
103	u8 aggregated;
104	u8 group_position;
105	u8 group_id;
106};
107
108/**
109 * snd_soc_acpi_adr_device - descriptor for _ADR-enumerated device
110 * @adr: 64 bit ACPI _ADR value
111 * @num_endpoints: number of endpoints for this device
112 * @endpoints: array of endpoints
113 * @name_prefix: string used for codec controls
114 */
115struct snd_soc_acpi_adr_device {
116	const u64 adr;
117	const u8 num_endpoints;
118	const struct snd_soc_acpi_endpoint *endpoints;
119	const char *name_prefix;
120};
121
122/**
123 * snd_soc_acpi_link_adr - ACPI-based list of _ADR enumerated devices
124 * @mask: one bit set indicates the link this list applies to
125 * @num_adr: ARRAY_SIZE of devices
126 * @adr_d: array of devices
127 *
128 * The number of devices per link can be more than 1, e.g. in SoundWire
129 * multi-drop configurations.
130 */
131
132struct snd_soc_acpi_link_adr {
133	const u32 mask;
134	const u32 num_adr;
135	const struct snd_soc_acpi_adr_device *adr_d;
136};
137
138/*
139 * when set the topology uses the -ssp<N> suffix, where N is determined based on
140 * BIOS or DMI information
141 */
142#define SND_SOC_ACPI_TPLG_INTEL_SSP_NUMBER BIT(0)
143
144/*
145 * when more than one SSP is reported in the link mask, use the most significant.
146 * This choice was found to be valid on platforms with ES8336 codecs.
147 */
148#define SND_SOC_ACPI_TPLG_INTEL_SSP_MSB BIT(1)
149
150/*
151 * when set the topology uses the -dmic<N>ch suffix, where N is determined based on
152 * BIOS or DMI information
153 */
154#define SND_SOC_ACPI_TPLG_INTEL_DMIC_NUMBER BIT(2)
155
156/*
157 * when set the speaker amplifier name suffix (i.e. "-max98360a") will be
158 * appended to topology file name
159 */
160#define SND_SOC_ACPI_TPLG_INTEL_AMP_NAME BIT(3)
161
162/*
163 * when set the headphone codec name suffix (i.e. "-rt5682") will be appended to
164 * topology file name
165 */
166#define SND_SOC_ACPI_TPLG_INTEL_CODEC_NAME BIT(4)
167
168/**
169 * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are
170 * related to the hardware, except for the firmware and topology file names.
171 * A platform supported by legacy and Sound Open Firmware (SOF) would expose
172 * all firmware/topology related fields.
173 *
174 * @id: ACPI ID (usually the codec's) used to find a matching machine driver.
175 * @uid: ACPI Unique ID, can be used to disambiguate matches.
176 * @comp_ids: list of compatible audio codecs using the same machine driver,
177 * firmware and topology
178 * @link_mask: describes required board layout, e.g. for SoundWire.
179 * @links: array of link _ADR descriptors, null terminated.
180 * @drv_name: machine driver name
181 * @fw_filename: firmware file name. Used when SOF is not enabled.
182 * @tplg_filename: topology file name. Used when SOF is not enabled.
183 * @board: board name
184 * @machine_quirk: pointer to quirk, usually based on DMI information when
185 * ACPI ID alone is not sufficient, wrong or misleading
186 * @quirk_data: data used to uniquely identify a machine, usually a list of
187 * audio codecs whose presence if checked with ACPI
188 * @machine_check: pointer to quirk function. The functionality is similar to
189 * the use of @machine_quirk, except that the return value is a boolean: the intent
190 * is to skip a machine if the additional hardware/firmware verification invalidates
191 * the initial selection in the snd_soc_acpi_mach table.
192 * @pdata: intended for platform data or machine specific-ops. This structure
193 *  is not constant since this field may be updated at run-time
194 * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled
195 * @tplg_quirk_mask: quirks to select different topology files dynamically
196 */
197/* Descriptor for SST ASoC machine driver */
198struct snd_soc_acpi_mach {
199	u8 id[ACPI_ID_LEN];
200	const char *uid;
201	const struct snd_soc_acpi_codecs *comp_ids;
202	const u32 link_mask;
203	const struct snd_soc_acpi_link_adr *links;
204	const char *drv_name;
205	const char *fw_filename;
206	const char *tplg_filename;
207	const char *board;
208	struct snd_soc_acpi_mach * (*machine_quirk)(void *arg);
209	const void *quirk_data;
210	bool (*machine_check)(void *arg);
211	void *pdata;
212	struct snd_soc_acpi_mach_params mach_params;
213	const char *sof_tplg_filename;
214	const u32 tplg_quirk_mask;
215};
216
217#define SND_SOC_ACPI_MAX_CODECS 3
218
219/**
220 * struct snd_soc_acpi_codecs: Structure to hold secondary codec information
221 * apart from the matched one, this data will be passed to the quirk function
222 * to match with the ACPI detected devices
223 *
224 * @num_codecs: number of secondary codecs used in the platform
225 * @codecs: holds the codec IDs
226 *
227 */
228struct snd_soc_acpi_codecs {
229	int num_codecs;
230	u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN];
231};
232
233static inline bool snd_soc_acpi_sof_parent(struct device *dev)
234{
235	return dev->parent && dev->parent->driver && dev->parent->driver->name &&
236		!strncmp(dev->parent->driver->name, "sof-audio-acpi", strlen("sof-audio-acpi"));
237}
238
239bool snd_soc_acpi_sdw_link_slaves_found(struct device *dev,
240					const struct snd_soc_acpi_link_adr *link,
241					struct sdw_peripherals *peripherals);
 
242
243#endif