xref: /linux/include/sound/hda-mlink.h (revision f3caa0b02455409eec4673ddd8df72d8bcad4e98)
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /*
3  * This file is provided under a dual BSD/GPLv2 license.  When using or
4  * redistributing this file, you may do so under either license.
5  *
6  * Copyright(c) 2022-2023 Intel Corporation
7  */
8 
9 struct hdac_bus;
10 struct hdac_ext_link;
11 
12 /**
13  * enum hda_bus_ml_link_type - mlink link type, used by SOF link DMA
14  *	allocator constraints (see struct sof_intel_hda_dev).
15  *
16  * @HDA_BUS_ML_LINK_HDA:  non-alt link, i.e. HDA codec or iDisp
17  * @HDA_BUS_ML_LINK_SDW:  alt link, SoundWire
18  * @HDA_BUS_ML_LINK_UAOL: alt link, USB Audio Offload
19  * @HDA_BUS_ML_LINK_OTHER: alt link, SSP or DMIC
20  */
21 enum hda_bus_ml_link_type {
22 	HDA_BUS_ML_LINK_HDA,
23 	HDA_BUS_ML_LINK_SDW,
24 	HDA_BUS_ML_LINK_UAOL,
25 	HDA_BUS_ML_LINK_OTHER,
26 };
27 
28 #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_MLINK)
29 
30 int hda_bus_ml_init(struct hdac_bus *bus);
31 void hda_bus_ml_free(struct hdac_bus *bus);
32 
33 int hdac_bus_eml_get_count(struct hdac_bus *bus, bool alt, int elid);
34 void hdac_bus_eml_enable_interrupt_unlocked(struct hdac_bus *bus, bool alt, int elid, bool enable);
35 void hdac_bus_eml_enable_interrupt(struct hdac_bus *bus, bool alt, int elid, bool enable);
36 bool hdac_bus_eml_check_interrupt(struct hdac_bus *bus, bool alt, int elid);
37 
38 int hdac_bus_eml_set_syncprd_unlocked(struct hdac_bus *bus, bool alt, int elid, u32 syncprd);
39 int hdac_bus_eml_sdw_set_syncprd_unlocked(struct hdac_bus *bus, u32 syncprd);
40 
41 int hdac_bus_eml_wait_syncpu_unlocked(struct hdac_bus *bus, bool alt, int elid);
42 int hdac_bus_eml_sdw_wait_syncpu_unlocked(struct hdac_bus *bus);
43 
44 void hdac_bus_eml_sync_arm_unlocked(struct hdac_bus *bus, bool alt, int elid, int sublink);
45 void hdac_bus_eml_sdw_sync_arm_unlocked(struct hdac_bus *bus, int sublink);
46 
47 int hdac_bus_eml_sync_go_unlocked(struct hdac_bus *bus, bool alt, int elid);
48 int hdac_bus_eml_sdw_sync_go_unlocked(struct hdac_bus *bus);
49 
50 bool hdac_bus_eml_check_cmdsync_unlocked(struct hdac_bus *bus, bool alt, int elid);
51 bool hdac_bus_eml_sdw_check_cmdsync_unlocked(struct hdac_bus *bus);
52 
53 int hdac_bus_eml_power_up(struct hdac_bus *bus, bool alt, int elid, int sublink);
54 int hdac_bus_eml_power_up_unlocked(struct hdac_bus *bus, bool alt, int elid, int sublink);
55 
56 int hdac_bus_eml_power_down(struct hdac_bus *bus, bool alt, int elid, int sublink);
57 int hdac_bus_eml_power_down_unlocked(struct hdac_bus *bus, bool alt, int elid, int sublink);
58 
59 int hdac_bus_eml_sdw_power_up_unlocked(struct hdac_bus *bus, int sublink);
60 int hdac_bus_eml_sdw_power_down_unlocked(struct hdac_bus *bus, int sublink);
61 
62 int hdac_bus_eml_sdw_get_lsdiid_unlocked(struct hdac_bus *bus, int sublink, u16 *lsdiid);
63 int hdac_bus_eml_sdw_set_lsdiid(struct hdac_bus *bus, int sublink, int dev_num);
64 
65 int hdac_bus_eml_sdw_map_stream_ch(struct hdac_bus *bus, int sublink, int y,
66 				   int channel_mask, int stream_id, int dir);
67 
68 void hda_bus_ml_reset_losidv(struct hdac_bus *bus);
69 int hda_bus_ml_resume(struct hdac_bus *bus);
70 int hda_bus_ml_suspend(struct hdac_bus *bus);
71 
72 enum hda_bus_ml_link_type hda_bus_ml_link_get_type(struct hdac_ext_link *hlink);
73 
74 struct hdac_ext_link *hdac_bus_eml_ssp_get_hlink(struct hdac_bus *bus);
75 struct hdac_ext_link *hdac_bus_eml_dmic_get_hlink(struct hdac_bus *bus);
76 struct hdac_ext_link *hdac_bus_eml_sdw_get_hlink(struct hdac_bus *bus);
77 
78 struct mutex *hdac_bus_eml_get_mutex(struct hdac_bus *bus, bool alt, int elid);
79 
80 void hdac_bus_eml_enable_offload(struct hdac_bus *bus, bool alt, int elid, bool enable);
81 
82 /* microphone privacy specific function supported by ACE3+ architecture */
83 void hdac_bus_eml_set_mic_privacy_mask(struct hdac_bus *bus, bool alt, int elid,
84 				       unsigned long mask);
85 bool hdac_bus_eml_is_mic_privacy_changed(struct hdac_bus *bus, bool alt, int elid);
86 bool hdac_bus_eml_get_mic_privacy_state(struct hdac_bus *bus, bool alt, int elid);
87 
88 #else
89 
90 static inline int
91 hda_bus_ml_init(struct hdac_bus *bus) { return 0; }
92 
93 static inline void hda_bus_ml_free(struct hdac_bus *bus) { }
94 
95 static inline int
96 hdac_bus_eml_get_count(struct hdac_bus *bus, bool alt, int elid) { return 0; }
97 
98 static inline void
99 hdac_bus_eml_enable_interrupt_unlocked(struct hdac_bus *bus, bool alt, int elid, bool enable) { }
100 
101 static inline void
102 hdac_bus_eml_enable_interrupt(struct hdac_bus *bus, bool alt, int elid, bool enable) { }
103 
104 static inline bool
105 hdac_bus_eml_check_interrupt(struct hdac_bus *bus, bool alt, int elid) { return false; }
106 
107 static inline int
108 hdac_bus_eml_set_syncprd_unlocked(struct hdac_bus *bus, bool alt, int elid, u32 syncprd)
109 {
110 	return 0;
111 }
112 
113 static inline int
114 hdac_bus_eml_sdw_set_syncprd_unlocked(struct hdac_bus *bus, u32 syncprd)
115 {
116 	return 0;
117 }
118 
119 static inline int
120 hdac_bus_eml_wait_syncpu_unlocked(struct hdac_bus *bus, bool alt, int elid)
121 {
122 	return 0;
123 }
124 
125 static inline int
126 hdac_bus_eml_sdw_wait_syncpu_unlocked(struct hdac_bus *bus) { return 0; }
127 
128 static inline void
129 hdac_bus_eml_sync_arm_unlocked(struct hdac_bus *bus, bool alt, int elid, int sublink) { }
130 
131 static inline void
132 hdac_bus_eml_sdw_sync_arm_unlocked(struct hdac_bus *bus, int sublink) { }
133 
134 static inline int
135 hdac_bus_eml_sync_go_unlocked(struct hdac_bus *bus, bool alt, int elid) { return 0; }
136 
137 static inline int
138 hdac_bus_eml_sdw_sync_go_unlocked(struct hdac_bus *bus) { return 0; }
139 
140 static inline bool
141 hdac_bus_eml_check_cmdsync_unlocked(struct hdac_bus *bus, bool alt, int elid) { return false; }
142 
143 static inline bool
144 hdac_bus_eml_sdw_check_cmdsync_unlocked(struct hdac_bus *bus) { return false; }
145 
146 static inline int
147 hdac_bus_eml_power_up(struct hdac_bus *bus, bool alt, int elid, int sublink)
148 {
149 	return 0;
150 }
151 
152 static inline int
153 hdac_bus_eml_power_up_unlocked(struct hdac_bus *bus, bool alt, int elid, int sublink)
154 {
155 	return 0;
156 }
157 
158 static inline int
159 hdac_bus_eml_power_down(struct hdac_bus *bus, bool alt, int elid, int sublink)
160 {
161 	return 0;
162 }
163 
164 static inline int
165 hdac_bus_eml_power_down_unlocked(struct hdac_bus *bus, bool alt, int elid, int sublink)
166 {
167 	return 0;
168 }
169 
170 static inline int
171 hdac_bus_eml_sdw_power_up_unlocked(struct hdac_bus *bus, int sublink) { return 0; }
172 
173 static inline int
174 hdac_bus_eml_sdw_power_down_unlocked(struct hdac_bus *bus, int sublink) { return 0; }
175 
176 static inline int
177 hdac_bus_eml_sdw_get_lsdiid_unlocked(struct hdac_bus *bus, int sublink, u16 *lsdiid) { return 0; }
178 
179 static inline int
180 hdac_bus_eml_sdw_set_lsdiid(struct hdac_bus *bus, int sublink, int dev_num) { return 0; }
181 
182 static inline int
183 hdac_bus_eml_sdw_map_stream_ch(struct hdac_bus *bus, int sublink, int y,
184 			       int channel_mask, int stream_id, int dir)
185 {
186 	return 0;
187 }
188 
189 static inline void hda_bus_ml_reset_losidv(struct hdac_bus *bus) { }
190 static inline int hda_bus_ml_resume(struct hdac_bus *bus) { return 0; }
191 static inline int hda_bus_ml_suspend(struct hdac_bus *bus) { return 0; }
192 
193 static inline enum hda_bus_ml_link_type
194 hda_bus_ml_link_get_type(struct hdac_ext_link *hlink) { return HDA_BUS_ML_LINK_HDA; }
195 
196 static inline struct hdac_ext_link *
197 hdac_bus_eml_ssp_get_hlink(struct hdac_bus *bus) { return NULL; }
198 
199 static inline struct hdac_ext_link *
200 hdac_bus_eml_dmic_get_hlink(struct hdac_bus *bus) { return NULL; }
201 
202 static inline struct hdac_ext_link *
203 hdac_bus_eml_sdw_get_hlink(struct hdac_bus *bus) { return NULL; }
204 
205 static inline struct mutex *
206 hdac_bus_eml_get_mutex(struct hdac_bus *bus, bool alt, int elid) { return NULL; }
207 
208 static inline void
209 hdac_bus_eml_enable_offload(struct hdac_bus *bus, bool alt, int elid, bool enable)
210 {
211 }
212 
213 static inline void
214 hdac_bus_eml_set_mic_privacy_mask(struct hdac_bus *bus, bool alt, int elid,
215 				  unsigned long mask)
216 {
217 }
218 
219 static inline bool
220 hdac_bus_eml_is_mic_privacy_changed(struct hdac_bus *bus, bool alt, int elid)
221 {
222 	return false;
223 }
224 
225 static inline bool
226 hdac_bus_eml_get_mic_privacy_state(struct hdac_bus *bus, bool alt, int elid)
227 {
228 	return false;
229 }
230 
231 #endif /* CONFIG_SND_SOC_SOF_HDA_MLINK */
232