]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - include/sound/soc-acpi.h
Merge branch 'fixes-rc1' into fixes
[mirror_ubuntu-jammy-kernel.git] / include / sound / soc-acpi.h
CommitLineData
e149ca29 1/* SPDX-License-Identifier: GPL-2.0-only
7feb2f78 2 *
7730bb13 3 * Copyright (C) 2013-15, Intel Corporation. All rights reserved.
7feb2f78
PLB
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>
845ab400 11#include <linux/mod_devicetable.h>
7feb2f78
PLB
12
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
2be2d579
PLB
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
7feb2f78 24#if IS_ENABLED(CONFIG_ACPI)
5e484ec1
PLB
25/* acpi match */
26struct snd_soc_acpi_mach *
27snd_soc_acpi_find_machine(struct snd_soc_acpi_mach *machines);
28
7feb2f78
PLB
29bool snd_soc_acpi_find_package_from_hid(const u8 hid[ACPI_ID_LEN],
30 struct snd_soc_acpi_package_context *ctx);
5e484ec1
PLB
31
32/* check all codecs */
33struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg);
34
7feb2f78 35#else
5e484ec1
PLB
36/* 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
7feb2f78
PLB
43static 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}
7feb2f78 49
5e484ec1
PLB
50/* check all codecs */
51static inline struct snd_soc_acpi_mach *snd_soc_acpi_codec_list(void *arg)
52{
53 return NULL;
54}
55#endif
7feb2f78 56
8679284b
PLB
57/**
58 * snd_soc_acpi_mach_params: interface for machine driver configuration
59 *
60 * @acpi_ipc_irq_index: used for BYT-CR detection
135ab457 61 * @platform: string used for HDAudio codec support
8679284b 62 * @codec_mask: used for HDAudio support
7de9a47c 63 * @common_hdmi_codec_drv: use commom HDAudio HDMI codec driver
efb6f315
PLB
64 * @link_mask: links enabled on the board
65 * @links: array of link _ADR descriptors, null terminated
ca6a0122
PLB
66 * @num_dai_drivers: number of elements in @dai_drivers
67 * @dai_drivers: pointer to dai_drivers, used e.g. in nocodec mode
8679284b
PLB
68 */
69struct snd_soc_acpi_mach_params {
70 u32 acpi_ipc_irq_index;
71 const char *platform;
72 u32 codec_mask;
b92826fa 73 u32 dmic_num;
7de9a47c 74 bool common_hdmi_codec_drv;
efb6f315
PLB
75 u32 link_mask;
76 const struct snd_soc_acpi_link_adr *links;
ca6a0122
PLB
77 u32 num_dai_drivers;
78 struct snd_soc_dai_driver *dai_drivers;
efb6f315
PLB
79};
80
81/**
004bd416
PLB
82 * snd_soc_acpi_endpoint - endpoint descriptor
83 * @num: endpoint number (mandatory, unique per device)
84 * @aggregated: 0 (independent) or 1 (logically grouped)
85 * @group_position: zero-based order (only when @aggregated is 1)
86 * @group_id: platform-unique group identifier (only when @aggregrated is 1)
87 */
88struct snd_soc_acpi_endpoint {
89 u8 num;
90 u8 aggregated;
91 u8 group_position;
92 u8 group_id;
93};
94
95/**
96 * snd_soc_acpi_adr_device - descriptor for _ADR-enumerated device
97 * @adr: 64 bit ACPI _ADR value
98 * @num_endpoints: number of endpoints for this device
99 * @endpoints: array of endpoints
f9380830 100 * @name_prefix: string used for codec controls
004bd416
PLB
101 */
102struct snd_soc_acpi_adr_device {
103 const u64 adr;
104 const u8 num_endpoints;
105 const struct snd_soc_acpi_endpoint *endpoints;
f9380830 106 const char *name_prefix;
004bd416
PLB
107};
108
109/**
110 * snd_soc_acpi_link_adr - ACPI-based list of _ADR enumerated devices
efb6f315 111 * @mask: one bit set indicates the link this list applies to
004bd416
PLB
112 * @num_adr: ARRAY_SIZE of devices
113 * @adr_d: array of devices
114 *
115 * The number of devices per link can be more than 1, e.g. in SoundWire
116 * multi-drop configurations.
efb6f315
PLB
117 */
118
119struct snd_soc_acpi_link_adr {
120 const u32 mask;
121 const u32 num_adr;
004bd416 122 const struct snd_soc_acpi_adr_device *adr_d;
8679284b
PLB
123};
124
7feb2f78
PLB
125/**
126 * snd_soc_acpi_mach: ACPI-based machine descriptor. Most of the fields are
127 * related to the hardware, except for the firmware and topology file names.
976b5a0e
PLB
128 * A platform supported by legacy and Sound Open Firmware (SOF) would expose
129 * all firmware/topology related fields.
7feb2f78
PLB
130 *
131 * @id: ACPI ID (usually the codec's) used to find a matching machine driver.
af78cec4 132 * @link_mask: describes required board layout, e.g. for SoundWire.
efb6f315 133 * @links: array of link _ADR descriptors, null terminated.
7feb2f78 134 * @drv_name: machine driver name
976b5a0e 135 * @fw_filename: firmware file name. Used when SOF is not enabled.
7feb2f78
PLB
136 * @board: board name
137 * @machine_quirk: pointer to quirk, usually based on DMI information when
138 * ACPI ID alone is not sufficient, wrong or misleading
139 * @quirk_data: data used to uniquely identify a machine, usually a list of
140 * audio codecs whose presence if checked with ACPI
141 * @pdata: intended for platform data or machine specific-ops. This structure
142 * is not constant since this field may be updated at run-time
976b5a0e
PLB
143 * @sof_fw_filename: Sound Open Firmware file name, if enabled
144 * @sof_tplg_filename: Sound Open Firmware topology file name, if enabled
7feb2f78
PLB
145 */
146/* Descriptor for SST ASoC machine driver */
147struct snd_soc_acpi_mach {
148 const u8 id[ACPI_ID_LEN];
af78cec4 149 const u32 link_mask;
efb6f315 150 const struct snd_soc_acpi_link_adr *links;
7feb2f78
PLB
151 const char *drv_name;
152 const char *fw_filename;
153 const char *board;
154 struct snd_soc_acpi_mach * (*machine_quirk)(void *arg);
155 const void *quirk_data;
156 void *pdata;
8679284b 157 struct snd_soc_acpi_mach_params mach_params;
976b5a0e
PLB
158 const char *sof_fw_filename;
159 const char *sof_tplg_filename;
7feb2f78
PLB
160};
161
162#define SND_SOC_ACPI_MAX_CODECS 3
163
164/**
165 * struct snd_soc_acpi_codecs: Structure to hold secondary codec information
166 * apart from the matched one, this data will be passed to the quirk function
167 * to match with the ACPI detected devices
168 *
169 * @num_codecs: number of secondary codecs used in the platform
170 * @codecs: holds the codec IDs
171 *
172 */
173struct snd_soc_acpi_codecs {
174 int num_codecs;
175 u8 codecs[SND_SOC_ACPI_MAX_CODECS][ACPI_ID_LEN];
176};
177
644eebdb
PLB
178static inline bool snd_soc_acpi_sof_parent(struct device *dev)
179{
180 return dev->parent && dev->parent->driver && dev->parent->driver->name &&
c7929b15 181 !strncmp(dev->parent->driver->name, "sof-audio-acpi", strlen("sof-audio-acpi"));
644eebdb
PLB
182}
183
7feb2f78 184#endif