blob: a217a87cae86fb1aa1c34bf55a2bb28ac12aae31 [file] [log] [blame]
Kuninori Morimoto7730bb12018-07-02 06:24:04 +00001/* SPDX-License-Identifier: GPL-2.0
2 *
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -05003 * Copyright (C) 2013-15, Intel Corporation. All rights reserved.
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -05004 */
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 Bossart845ab402018-01-04 16:35:52 -060011#include <linux/mod_devicetable.h>
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050012
13struct 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 Bossart2be2d572018-01-11 13:52:09 -060021/* 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 Bossart7feb2f72017-10-12 18:49:38 -050024#if IS_ENABLED(CONFIG_ACPI)
Pierre-Louis Bossart5e484ec2019-01-25 14:16:17 -060025/* acpi match */
26struct snd_soc_acpi_mach *
27snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines);
28
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050029bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
30 struct snd_soc_acpi_package_context *ctx);
Pierre-Louis Bossart5e484ec2019-01-25 14:16:17 -060031
32/* check all codecs */
33struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg);
34
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050035#else
Pierre-Louis Bossart5e484ec2019-01-25 14:16:17 -060036/* acpi match */
37static inline struct snd_soc_acpi_mach *
38snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines)
39{
40 return NULL;
41}
42
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050043static inline bool
44snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
45 struct snd_soc_acpi_package_context *ctx)
46{
47 return false;
48}
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050049
Pierre-Louis Bossart5e484ec2019-01-25 14:16:17 -060050/* check all codecs */
51static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg)
52{
53 return NULL;
54}
55#endif
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050056
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050057/**
Pierre-Louis Bossart86792842018-11-01 16:34:48 -050058 * snd_soc_acpi_mach_params: interface for machine driver configuration
59 *
60 * @acpi_ipc_irq_index: used for BYT-CR detection
61 * @platform: string used for HDaudio codec support
62 * @codec_mask: used for HDAudio support
Kai Vehmanen7de9a472019-10-29 15:40:11 +020063 * @common_hdmi_codec_drv: use commom HDAudio HDMI codec driver
Pierre-Louis Bossartefb6f312020-01-10 16:25:25 -060064 * @link_mask: links enabled on the board
65 * @links: array of link _ADR descriptors, null terminated
Pierre-Louis Bossart86792842018-11-01 16:34:48 -050066 */
67struct snd_soc_acpi_mach_params {
68 u32 acpi_ipc_irq_index;
69 const char *platform;
70 u32 codec_mask;
Pierre-Louis Bossartb92826f2018-11-16 18:47:05 -060071 u32 dmic_num;
Kai Vehmanen7de9a472019-10-29 15:40:11 +020072 bool common_hdmi_codec_drv;
Pierre-Louis Bossartefb6f312020-01-10 16:25:25 -060073 u32 link_mask;
74 const struct snd_soc_acpi_link_adr *links;
75};
76
77/**
78 * snd_soc_acpi_link_adr: ACPI-based list of _ADR, with a variable
79 * number of devices per link
80 *
81 * @mask: one bit set indicates the link this list applies to
82 * @num_adr: ARRAY_SIZE of adr
83 * @adr: array of _ADR (represented as u64).
84 */
85
86struct snd_soc_acpi_link_adr {
87 const u32 mask;
88 const u32 num_adr;
89 const u64 *adr;
Pierre-Louis Bossart86792842018-11-01 16:34:48 -050090};
91
92/**
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050093 * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are
94 * related to the hardware, except for the firmware and topology file names.
Pierre-Louis Bossart976b5a02017-10-12 18:49:40 -050095 * A platform supported by legacy and Sound Open Firmware (SOF) would expose
96 * all firmware/topology related fields.
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -050097 *
98 * @id: ACPI ID (usually the codec's) used to find a matching machine driver.
Pierre-Louis Bossartaf78cec2019-09-16 16:42:40 -050099 * @link_mask: describes required board layout, e.g. for SoundWire.
Pierre-Louis Bossartefb6f312020-01-10 16:25:25 -0600100 * @links: array of link _ADR descriptors, null terminated.
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -0500101 * @drv_name: machine driver name
Pierre-Louis Bossart976b5a02017-10-12 18:49:40 -0500102 * @fw_filename: firmware file name. Used when SOF is not enabled.
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -0500103 * @board: board name
104 * @machine_quirk: pointer to quirk, usually based on DMI information when
105 * ACPI ID alone is not sufficient, wrong or misleading
106 * @quirk_data: data used to uniquely identify a machine, usually a list of
107 * audio codecs whose presence if checked with ACPI
108 * @pdata: intended for platform data or machine specific-ops. This structure
109 * is not constant since this field may be updated at run-time
Pierre-Louis Bossart976b5a02017-10-12 18:49:40 -0500110 * @sof_fw_filename: Sound Open Firmware file name, if enabled
111 * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -0500112 */
113/* Descriptor for SST ASoC machine driver */
114struct snd_soc_acpi_mach {
115 const u8 id[ACPI_ID_LEN];
Pierre-Louis Bossartaf78cec2019-09-16 16:42:40 -0500116 const u32 link_mask;
Pierre-Louis Bossartefb6f312020-01-10 16:25:25 -0600117 const struct snd_soc_acpi_link_adr *links;
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -0500118 const char *drv_name;
119 const char *fw_filename;
120 const char *board;
121 struct snd_soc_acpi_mach * (*machine_quirk)(void *arg);
122 const void *quirk_data;
123 void *pdata;
Pierre-Louis Bossart86792842018-11-01 16:34:48 -0500124 struct snd_soc_acpi_mach_params mach_params;
Pierre-Louis Bossart976b5a02017-10-12 18:49:40 -0500125 const char *sof_fw_filename;
126 const char *sof_tplg_filename;
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -0500127};
128
129#define SND_SOC_ACPI_MAX_CODECS 3
130
131/**
132 * struct snd_soc_acpi_codecs: Structure to hold secondary codec information
133 * apart from the matched one, this data will be passed to the quirk function
134 * to match with the ACPI detected devices
135 *
136 * @num_codecs: number of secondary codecs used in the platform
137 * @codecs: holds the codec IDs
138 *
139 */
140struct snd_soc_acpi_codecs {
141 int num_codecs;
142 u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN];
143};
144
Pierre-Louis Bossart7feb2f72017-10-12 18:49:38 -0500145#endif