soc-dapm.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * linux/sound/soc-dapm.h -- ALSA SoC Dynamic Audio Power Management
  4. *
  5. * Author: Liam Girdwood
  6. * Created: Aug 11th 2005
  7. * Copyright: Wolfson Microelectronics. PLC.
  8. */
  9. #ifndef __LINUX_SND_SOC_DAPM_H
  10. #define __LINUX_SND_SOC_DAPM_H
  11. #include <linux/types.h>
  12. #include <sound/control.h>
  13. #include <sound/soc-topology.h>
  14. #include <sound/asoc.h>
  15. struct device;
  16. struct snd_pcm_substream;
  17. struct snd_soc_pcm_runtime;
  18. struct soc_enum;
  19. /* widget has no PM register bit */
  20. #define SND_SOC_NOPM -1
  21. /*
  22. * SoC dynamic audio power management
  23. *
  24. * We can have up to 4 power domains
  25. * 1. Codec domain - VREF, VMID
  26. * Usually controlled at codec probe/remove, although can be set
  27. * at stream time if power is not needed for sidetone, etc.
  28. * 2. Platform/Machine domain - physically connected inputs and outputs
  29. * Is platform/machine and user action specific, is set in the machine
  30. * driver and by userspace e.g when HP are inserted
  31. * 3. Path domain - Internal codec path mixers
  32. * Are automatically set when mixer and mux settings are
  33. * changed by the user.
  34. * 4. Stream domain - DAC's and ADC's.
  35. * Enabled when stream playback/capture is started.
  36. */
  37. /* codec domain */
  38. #define SND_SOC_DAPM_VMID(wname) \
  39. (struct snd_soc_dapm_widget) { \
  40. .id = snd_soc_dapm_vmid, .name = wname, .kcontrol_news = NULL, \
  41. .num_kcontrols = 0}
  42. /* platform domain */
  43. #define SND_SOC_DAPM_SIGGEN(wname) \
  44. (struct snd_soc_dapm_widget) { \
  45. .id = snd_soc_dapm_siggen, .name = wname, .kcontrol_news = NULL, \
  46. .num_kcontrols = 0, .reg = SND_SOC_NOPM }
  47. #define SND_SOC_DAPM_SINK(wname) \
  48. (struct snd_soc_dapm_widget) { \
  49. .id = snd_soc_dapm_sink, .name = wname, .kcontrol_news = NULL, \
  50. .num_kcontrols = 0, .reg = SND_SOC_NOPM }
  51. #define SND_SOC_DAPM_INPUT(wname) \
  52. (struct snd_soc_dapm_widget) { \
  53. .id = snd_soc_dapm_input, .name = wname, .kcontrol_news = NULL, \
  54. .num_kcontrols = 0, .reg = SND_SOC_NOPM }
  55. #define SND_SOC_DAPM_OUTPUT(wname) \
  56. (struct snd_soc_dapm_widget) { \
  57. .id = snd_soc_dapm_output, .name = wname, .kcontrol_news = NULL, \
  58. .num_kcontrols = 0, .reg = SND_SOC_NOPM }
  59. #define SND_SOC_DAPM_MIC(wname, wevent) \
  60. (struct snd_soc_dapm_widget) { \
  61. .id = snd_soc_dapm_mic, .name = wname, .kcontrol_news = NULL, \
  62. .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
  63. .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD}
  64. #define SND_SOC_DAPM_HP(wname, wevent) \
  65. (struct snd_soc_dapm_widget) { \
  66. .id = snd_soc_dapm_hp, .name = wname, .kcontrol_news = NULL, \
  67. .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
  68. .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
  69. #define SND_SOC_DAPM_SPK(wname, wevent) \
  70. (struct snd_soc_dapm_widget) { \
  71. .id = snd_soc_dapm_spk, .name = wname, .kcontrol_news = NULL, \
  72. .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
  73. .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
  74. #define SND_SOC_DAPM_LINE(wname, wevent) \
  75. (struct snd_soc_dapm_widget) { \
  76. .id = snd_soc_dapm_line, .name = wname, .kcontrol_news = NULL, \
  77. .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
  78. .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMD}
  79. #define SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert) \
  80. .reg = wreg, .mask = 1, .shift = wshift, \
  81. .on_val = winvert ? 0 : 1, .off_val = winvert ? 1 : 0
  82. /* path domain */
  83. #define SND_SOC_DAPM_PGA(wname, wreg, wshift, winvert,\
  84. wcontrols, wncontrols) \
  85. (struct snd_soc_dapm_widget) { \
  86. .id = snd_soc_dapm_pga, .name = wname, \
  87. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  88. .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
  89. #define SND_SOC_DAPM_OUT_DRV(wname, wreg, wshift, winvert,\
  90. wcontrols, wncontrols) \
  91. (struct snd_soc_dapm_widget) { \
  92. .id = snd_soc_dapm_out_drv, .name = wname, \
  93. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  94. .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
  95. #define SND_SOC_DAPM_MIXER(wname, wreg, wshift, winvert, \
  96. wcontrols, wncontrols)\
  97. (struct snd_soc_dapm_widget) { \
  98. .id = snd_soc_dapm_mixer, .name = wname, \
  99. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  100. .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
  101. #define SND_SOC_DAPM_MIXER_NAMED_CTL(wname, wreg, wshift, winvert, \
  102. wcontrols, wncontrols)\
  103. (struct snd_soc_dapm_widget) { \
  104. .id = snd_soc_dapm_mixer_named_ctl, .name = wname, \
  105. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  106. .kcontrol_news = wcontrols, .num_kcontrols = wncontrols}
  107. /* DEPRECATED: use SND_SOC_DAPM_SUPPLY */
  108. #define SND_SOC_DAPM_MICBIAS(wname, wreg, wshift, winvert) \
  109. (struct snd_soc_dapm_widget) { \
  110. .id = snd_soc_dapm_micbias, .name = wname, \
  111. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  112. .kcontrol_news = NULL, .num_kcontrols = 0}
  113. #define SND_SOC_DAPM_SWITCH(wname, wreg, wshift, winvert, wcontrols) \
  114. (struct snd_soc_dapm_widget) { \
  115. .id = snd_soc_dapm_switch, .name = wname, \
  116. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  117. .kcontrol_news = wcontrols, .num_kcontrols = 1}
  118. #define SND_SOC_DAPM_MUX(wname, wreg, wshift, winvert, wcontrols) \
  119. (struct snd_soc_dapm_widget) { \
  120. .id = snd_soc_dapm_mux, .name = wname, \
  121. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  122. .kcontrol_news = wcontrols, .num_kcontrols = 1}
  123. #define SND_SOC_DAPM_DEMUX(wname, wreg, wshift, winvert, wcontrols) \
  124. (struct snd_soc_dapm_widget) { \
  125. .id = snd_soc_dapm_demux, .name = wname, \
  126. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  127. .kcontrol_news = wcontrols, .num_kcontrols = 1}
  128. /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
  129. #define SOC_PGA_ARRAY(wname, wreg, wshift, winvert,\
  130. wcontrols) \
  131. (struct snd_soc_dapm_widget) { \
  132. .id = snd_soc_dapm_pga, .name = wname, \
  133. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  134. .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
  135. #define SOC_MIXER_ARRAY(wname, wreg, wshift, winvert, \
  136. wcontrols)\
  137. (struct snd_soc_dapm_widget) { \
  138. .id = snd_soc_dapm_mixer, .name = wname, \
  139. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  140. .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
  141. #define SOC_MIXER_NAMED_CTL_ARRAY(wname, wreg, wshift, winvert, \
  142. wcontrols)\
  143. (struct snd_soc_dapm_widget) { \
  144. .id = snd_soc_dapm_mixer_named_ctl, .name = wname, \
  145. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  146. .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols)}
  147. /* path domain with event - event handler must return 0 for success */
  148. #define SND_SOC_DAPM_PGA_E(wname, wreg, wshift, winvert, wcontrols, \
  149. wncontrols, wevent, wflags) \
  150. (struct snd_soc_dapm_widget) { \
  151. .id = snd_soc_dapm_pga, .name = wname, \
  152. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  153. .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
  154. .event = wevent, .event_flags = wflags}
  155. #define SND_SOC_DAPM_OUT_DRV_E(wname, wreg, wshift, winvert, wcontrols, \
  156. wncontrols, wevent, wflags) \
  157. (struct snd_soc_dapm_widget) { \
  158. .id = snd_soc_dapm_out_drv, .name = wname, \
  159. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  160. .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
  161. .event = wevent, .event_flags = wflags}
  162. #define SND_SOC_DAPM_MIXER_E(wname, wreg, wshift, winvert, wcontrols, \
  163. wncontrols, wevent, wflags) \
  164. (struct snd_soc_dapm_widget) { \
  165. .id = snd_soc_dapm_mixer, .name = wname, \
  166. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  167. .kcontrol_news = wcontrols, .num_kcontrols = wncontrols, \
  168. .event = wevent, .event_flags = wflags}
  169. #define SND_SOC_DAPM_MIXER_NAMED_CTL_E(wname, wreg, wshift, winvert, \
  170. wcontrols, wncontrols, wevent, wflags) \
  171. (struct snd_soc_dapm_widget) { \
  172. .id = snd_soc_dapm_mixer, .name = wname, \
  173. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  174. .kcontrol_news = wcontrols, \
  175. .num_kcontrols = wncontrols, .event = wevent, .event_flags = wflags}
  176. #define SND_SOC_DAPM_SWITCH_E(wname, wreg, wshift, winvert, wcontrols, \
  177. wevent, wflags) \
  178. (struct snd_soc_dapm_widget) { \
  179. .id = snd_soc_dapm_switch, .name = wname, \
  180. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  181. .kcontrol_news = wcontrols, .num_kcontrols = 1, \
  182. .event = wevent, .event_flags = wflags}
  183. #define SND_SOC_DAPM_MUX_E(wname, wreg, wshift, winvert, wcontrols, \
  184. wevent, wflags) \
  185. (struct snd_soc_dapm_widget) { \
  186. .id = snd_soc_dapm_mux, .name = wname, \
  187. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  188. .kcontrol_news = wcontrols, .num_kcontrols = 1, \
  189. .event = wevent, .event_flags = wflags}
  190. /* additional sequencing control within an event type */
  191. #define SND_SOC_DAPM_PGA_S(wname, wsubseq, wreg, wshift, winvert, \
  192. wevent, wflags) \
  193. (struct snd_soc_dapm_widget) { \
  194. .id = snd_soc_dapm_pga, .name = wname, \
  195. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  196. .event = wevent, .event_flags = wflags, \
  197. .subseq = wsubseq}
  198. #define SND_SOC_DAPM_SUPPLY_S(wname, wsubseq, wreg, wshift, winvert, wevent, \
  199. wflags) \
  200. (struct snd_soc_dapm_widget) { \
  201. .id = snd_soc_dapm_supply, .name = wname, \
  202. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  203. .event = wevent, .event_flags = wflags, .subseq = wsubseq}
  204. /* Simplified versions of above macros, assuming wncontrols = ARRAY_SIZE(wcontrols) */
  205. #define SOC_PGA_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
  206. wevent, wflags) \
  207. (struct snd_soc_dapm_widget) { \
  208. .id = snd_soc_dapm_pga, .name = wname, \
  209. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  210. .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
  211. .event = wevent, .event_flags = wflags}
  212. #define SOC_MIXER_E_ARRAY(wname, wreg, wshift, winvert, wcontrols, \
  213. wevent, wflags) \
  214. (struct snd_soc_dapm_widget) { \
  215. .id = snd_soc_dapm_mixer, .name = wname, \
  216. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  217. .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
  218. .event = wevent, .event_flags = wflags}
  219. #define SOC_MIXER_NAMED_CTL_E_ARRAY(wname, wreg, wshift, winvert, \
  220. wcontrols, wevent, wflags) \
  221. (struct snd_soc_dapm_widget) { \
  222. .id = snd_soc_dapm_mixer, .name = wname, \
  223. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  224. .kcontrol_news = wcontrols, .num_kcontrols = ARRAY_SIZE(wcontrols), \
  225. .event = wevent, .event_flags = wflags}
  226. /* events that are pre and post DAPM */
  227. #define SND_SOC_DAPM_PRE(wname, wevent) \
  228. (struct snd_soc_dapm_widget) { \
  229. .id = snd_soc_dapm_pre, .name = wname, .kcontrol_news = NULL, \
  230. .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
  231. .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_PRE_PMD}
  232. #define SND_SOC_DAPM_POST(wname, wevent) \
  233. (struct snd_soc_dapm_widget) { \
  234. .id = snd_soc_dapm_post, .name = wname, .kcontrol_news = NULL, \
  235. .num_kcontrols = 0, .reg = SND_SOC_NOPM, .event = wevent, \
  236. .event_flags = SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD}
  237. /* stream domain */
  238. #define SND_SOC_DAPM_AIF_IN(wname, stname, wchan, wreg, wshift, winvert) \
  239. (struct snd_soc_dapm_widget) { \
  240. .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \
  241. .channel = wchan, SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), }
  242. #define SND_SOC_DAPM_AIF_IN_E(wname, stname, wchan, wreg, wshift, winvert, \
  243. wevent, wflags) \
  244. (struct snd_soc_dapm_widget) { \
  245. .id = snd_soc_dapm_aif_in, .name = wname, .sname = stname, \
  246. .channel = wchan, SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  247. .event = wevent, .event_flags = wflags }
  248. #define SND_SOC_DAPM_AIF_OUT(wname, stname, wchan, wreg, wshift, winvert) \
  249. (struct snd_soc_dapm_widget) { \
  250. .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \
  251. .channel = wchan, SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), }
  252. #define SND_SOC_DAPM_AIF_OUT_E(wname, stname, wchan, wreg, wshift, winvert, \
  253. wevent, wflags) \
  254. (struct snd_soc_dapm_widget) { \
  255. .id = snd_soc_dapm_aif_out, .name = wname, .sname = stname, \
  256. .channel = wchan, SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  257. .event = wevent, .event_flags = wflags }
  258. #define SND_SOC_DAPM_DAC(wname, stname, wreg, wshift, winvert) \
  259. (struct snd_soc_dapm_widget) { \
  260. .id = snd_soc_dapm_dac, .name = wname, .sname = stname, \
  261. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert) }
  262. #define SND_SOC_DAPM_DAC_E(wname, stname, wreg, wshift, winvert, \
  263. wevent, wflags) \
  264. (struct snd_soc_dapm_widget) { \
  265. .id = snd_soc_dapm_dac, .name = wname, .sname = stname, \
  266. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  267. .event = wevent, .event_flags = wflags}
  268. #define SND_SOC_DAPM_ADC(wname, stname, wreg, wshift, winvert) \
  269. (struct snd_soc_dapm_widget) { \
  270. .id = snd_soc_dapm_adc, .name = wname, .sname = stname, \
  271. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), }
  272. #define SND_SOC_DAPM_ADC_E(wname, stname, wreg, wshift, winvert, \
  273. wevent, wflags) \
  274. (struct snd_soc_dapm_widget) { \
  275. .id = snd_soc_dapm_adc, .name = wname, .sname = stname, \
  276. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  277. .event = wevent, .event_flags = wflags}
  278. #define SND_SOC_DAPM_CLOCK_SUPPLY(wname) \
  279. (struct snd_soc_dapm_widget) { \
  280. .id = snd_soc_dapm_clock_supply, .name = wname, \
  281. .reg = SND_SOC_NOPM, .event = dapm_clock_event, \
  282. .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD }
  283. /* generic widgets */
  284. #define SND_SOC_DAPM_REG(wid, wname, wreg, wshift, wmask, won_val, woff_val) \
  285. (struct snd_soc_dapm_widget) { \
  286. .id = wid, .name = wname, .kcontrol_news = NULL, .num_kcontrols = 0, \
  287. .reg = wreg, .shift = wshift, .mask = wmask, \
  288. .on_val = won_val, .off_val = woff_val, }
  289. #define SND_SOC_DAPM_SUPPLY(wname, wreg, wshift, winvert, wevent, wflags) \
  290. (struct snd_soc_dapm_widget) { \
  291. .id = snd_soc_dapm_supply, .name = wname, \
  292. SND_SOC_DAPM_INIT_REG_VAL(wreg, wshift, winvert), \
  293. .event = wevent, .event_flags = wflags}
  294. #define SND_SOC_DAPM_REGULATOR_SUPPLY(wname, wdelay, wflags) \
  295. (struct snd_soc_dapm_widget) { \
  296. .id = snd_soc_dapm_regulator_supply, .name = wname, \
  297. .reg = SND_SOC_NOPM, .shift = wdelay, .event = dapm_regulator_event, \
  298. .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD, \
  299. .on_val = wflags}
  300. #define SND_SOC_DAPM_PINCTRL(wname, active, sleep) \
  301. (struct snd_soc_dapm_widget) { \
  302. .id = snd_soc_dapm_pinctrl, .name = wname, \
  303. .priv = (&(struct snd_soc_dapm_pinctrl_priv) \
  304. { .active_state = active, .sleep_state = sleep,}), \
  305. .reg = SND_SOC_NOPM, .event = dapm_pinctrl_event, \
  306. .event_flags = SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD }
  307. /* dapm kcontrol types */
  308. #define SOC_DAPM_DOUBLE(xname, reg, lshift, rshift, max, invert) \
  309. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  310. .info = snd_soc_info_volsw, \
  311. .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
  312. .private_value = SOC_DOUBLE_VALUE(reg, lshift, rshift, max, invert, 0) }
  313. #define SOC_DAPM_DOUBLE_R(xname, lreg, rreg, shift, max, invert) \
  314. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  315. .info = snd_soc_info_volsw, \
  316. .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
  317. .private_value = SOC_DOUBLE_R_VALUE(lreg, rreg, shift, max, invert) }
  318. #define SOC_DAPM_SINGLE(xname, reg, shift, max, invert) \
  319. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  320. .info = snd_soc_info_volsw, \
  321. .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
  322. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
  323. #define SOC_DAPM_SINGLE_AUTODISABLE(xname, reg, shift, max, invert) \
  324. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  325. .info = snd_soc_info_volsw, \
  326. .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
  327. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) }
  328. #define SOC_DAPM_SINGLE_VIRT(xname, max) \
  329. SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0)
  330. #define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
  331. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  332. .info = snd_soc_info_volsw, \
  333. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  334. .tlv.p = (tlv_array), \
  335. .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
  336. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
  337. #define SOC_DAPM_SINGLE_TLV_AUTODISABLE(xname, reg, shift, max, invert, tlv_array) \
  338. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  339. .info = snd_soc_info_volsw, \
  340. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  341. .tlv.p = (tlv_array), \
  342. .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \
  343. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) }
  344. #define SOC_DAPM_SINGLE_TLV_VIRT(xname, max, tlv_array) \
  345. SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0, tlv_array)
  346. #define SOC_DAPM_ENUM(xname, xenum) \
  347. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  348. .info = snd_soc_info_enum_double, \
  349. .get = snd_soc_dapm_get_enum_double, \
  350. .put = snd_soc_dapm_put_enum_double, \
  351. .private_value = (unsigned long)&xenum }
  352. #define SOC_DAPM_ENUM_EXT(xname, xenum, xget, xput) \
  353. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  354. .info = snd_soc_info_enum_double, \
  355. .get = xget, \
  356. .put = xput, \
  357. .private_value = (unsigned long)&xenum }
  358. #define SOC_DAPM_PIN_SWITCH(xname) \
  359. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname " Switch", \
  360. .info = snd_soc_dapm_info_pin_switch, \
  361. .get = snd_soc_dapm_get_pin_switch, \
  362. .put = snd_soc_dapm_put_pin_switch, \
  363. .private_value = (unsigned long)xname }
  364. /* dapm stream operations */
  365. #define SND_SOC_DAPM_STREAM_NOP 0x0
  366. #define SND_SOC_DAPM_STREAM_START 0x1
  367. #define SND_SOC_DAPM_STREAM_STOP 0x2
  368. #define SND_SOC_DAPM_STREAM_SUSPEND 0x4
  369. #define SND_SOC_DAPM_STREAM_RESUME 0x8
  370. #define SND_SOC_DAPM_STREAM_PAUSE_PUSH 0x10
  371. #define SND_SOC_DAPM_STREAM_PAUSE_RELEASE 0x20
  372. /* dapm event types */
  373. #define SND_SOC_DAPM_PRE_PMU 0x1 /* before widget power up */
  374. #define SND_SOC_DAPM_POST_PMU 0x2 /* after widget power up */
  375. #define SND_SOC_DAPM_PRE_PMD 0x4 /* before widget power down */
  376. #define SND_SOC_DAPM_POST_PMD 0x8 /* after widget power down */
  377. #define SND_SOC_DAPM_PRE_REG 0x10 /* before audio path setup */
  378. #define SND_SOC_DAPM_POST_REG 0x20 /* after audio path setup */
  379. #define SND_SOC_DAPM_WILL_PMU 0x40 /* called at start of sequence */
  380. #define SND_SOC_DAPM_WILL_PMD 0x80 /* called at start of sequence */
  381. #define SND_SOC_DAPM_PRE_POST_PMD (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD)
  382. #define SND_SOC_DAPM_PRE_POST_PMU (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU)
  383. /* convenience event type detection */
  384. #define SND_SOC_DAPM_EVENT_ON(e) (e & (SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU))
  385. #define SND_SOC_DAPM_EVENT_OFF(e) (e & (SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMD))
  386. /* regulator widget flags */
  387. #define SND_SOC_DAPM_REGULATOR_BYPASS 0x1 /* bypass when disabled */
  388. struct snd_soc_dapm_widget;
  389. enum snd_soc_dapm_type;
  390. struct snd_soc_dapm_path;
  391. struct snd_soc_dapm_pin;
  392. struct snd_soc_dapm_route;
  393. struct snd_soc_dapm_context;
  394. struct regulator;
  395. struct snd_soc_dapm_widget_list;
  396. struct snd_soc_dapm_update;
  397. enum snd_soc_dapm_direction;
  398. /*
  399. * Bias levels
  400. *
  401. * @ON: Bias is fully on for audio playback and capture operations.
  402. * @PREPARE: Prepare for audio operations. Called before DAPM switching for
  403. * stream start and stop operations.
  404. * @STANDBY: Low power standby state when no playback/capture operations are
  405. * in progress. NOTE: The transition time between STANDBY and ON
  406. * should be as fast as possible and no longer than 10ms.
  407. * @OFF: Power Off. No restrictions on transition times.
  408. */
  409. enum snd_soc_bias_level {
  410. SND_SOC_BIAS_OFF = 0,
  411. SND_SOC_BIAS_STANDBY = 1,
  412. SND_SOC_BIAS_PREPARE = 2,
  413. SND_SOC_BIAS_ON = 3,
  414. };
  415. int dapm_regulator_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event);
  416. int dapm_clock_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event);
  417. int dapm_pinctrl_event(struct snd_soc_dapm_widget *w, struct snd_kcontrol *kcontrol, int event);
  418. /* dapm controls */
  419. int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
  420. int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol);
  421. int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol,
  422. struct snd_ctl_elem_value *ucontrol);
  423. int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol,
  424. struct snd_ctl_elem_value *ucontrol);
  425. int snd_soc_dapm_info_pin_switch(struct snd_kcontrol *kcontrol,
  426. struct snd_ctl_elem_info *uinfo);
  427. int snd_soc_dapm_get_pin_switch(struct snd_kcontrol *kcontrol,
  428. struct snd_ctl_elem_value *uncontrol);
  429. int snd_soc_dapm_put_pin_switch(struct snd_kcontrol *kcontrol,
  430. struct snd_ctl_elem_value *uncontrol);
  431. int snd_soc_dapm_new_controls(struct snd_soc_dapm_context *dapm,
  432. const struct snd_soc_dapm_widget *widget, unsigned int num);
  433. struct snd_soc_dapm_widget *snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm,
  434. const struct snd_soc_dapm_widget *widget);
  435. struct snd_soc_dapm_widget *snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm,
  436. const struct snd_soc_dapm_widget *widget);
  437. int snd_soc_dapm_new_dai_widgets(struct snd_soc_dapm_context *dapm, struct snd_soc_dai *dai);
  438. void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w);
  439. int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card);
  440. void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card);
  441. int snd_soc_dapm_update_dai(struct snd_pcm_substream *substream,
  442. struct snd_pcm_hw_params *params, struct snd_soc_dai *dai);
  443. int snd_soc_dapm_widget_name_cmp(struct snd_soc_dapm_widget *widget, const char *s);
  444. /* dapm path setup */
  445. int snd_soc_dapm_new_widgets(struct snd_soc_card *card);
  446. void snd_soc_dapm_free(struct snd_soc_dapm_context *dapm);
  447. void snd_soc_dapm_init(struct snd_soc_dapm_context *dapm,
  448. struct snd_soc_card *card, struct snd_soc_component *component);
  449. int snd_soc_dapm_add_routes(struct snd_soc_dapm_context *dapm,
  450. const struct snd_soc_dapm_route *route, int num);
  451. int snd_soc_dapm_del_routes(struct snd_soc_dapm_context *dapm,
  452. const struct snd_soc_dapm_route *route, int num);
  453. int snd_soc_dapm_weak_routes(struct snd_soc_dapm_context *dapm,
  454. const struct snd_soc_dapm_route *route, int num);
  455. void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w);
  456. /* dapm events */
  457. void snd_soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, int event);
  458. void snd_soc_dapm_stream_stop(struct snd_soc_pcm_runtime *rtd, int stream);
  459. void snd_soc_dapm_shutdown(struct snd_soc_card *card);
  460. /* external DAPM widget events */
  461. int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm,
  462. struct snd_kcontrol *kcontrol, int connect, struct snd_soc_dapm_update *update);
  463. int snd_soc_dapm_mux_update_power(struct snd_soc_dapm_context *dapm,
  464. struct snd_kcontrol *kcontrol, int mux, struct soc_enum *e,
  465. struct snd_soc_dapm_update *update);
  466. /* dapm sys fs - used by the core */
  467. extern struct attribute *soc_dapm_dev_attrs[];
  468. void snd_soc_dapm_debugfs_init(struct snd_soc_dapm_context *dapm, struct dentry *parent);
  469. /* dapm audio pin control and status */
  470. int snd_soc_dapm_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin);
  471. int snd_soc_dapm_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, const char *pin);
  472. int snd_soc_dapm_disable_pin(struct snd_soc_dapm_context *dapm, const char *pin);
  473. int snd_soc_dapm_disable_pin_unlocked(struct snd_soc_dapm_context *dapm, const char *pin);
  474. int snd_soc_dapm_nc_pin(struct snd_soc_dapm_context *dapm, const char *pin);
  475. int snd_soc_dapm_nc_pin_unlocked(struct snd_soc_dapm_context *dapm, const char *pin);
  476. int snd_soc_dapm_get_pin_status(struct snd_soc_dapm_context *dapm, const char *pin);
  477. int snd_soc_dapm_sync(struct snd_soc_dapm_context *dapm);
  478. int snd_soc_dapm_sync_unlocked(struct snd_soc_dapm_context *dapm);
  479. int snd_soc_dapm_force_enable_pin(struct snd_soc_dapm_context *dapm, const char *pin);
  480. int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, const char *pin);
  481. int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, const char *pin);
  482. unsigned int dapm_kcontrol_get_value(const struct snd_kcontrol *kcontrol);
  483. /* Mostly internal - should not normally be used */
  484. void dapm_mark_endpoints_dirty(struct snd_soc_card *card);
  485. /* dapm path query */
  486. int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream,
  487. struct snd_soc_dapm_widget_list **list,
  488. bool (*custom_stop_condition)(struct snd_soc_dapm_widget *, enum snd_soc_dapm_direction));
  489. void snd_soc_dapm_dai_free_widgets(struct snd_soc_dapm_widget_list **list);
  490. struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm(struct snd_kcontrol *kcontrol);
  491. struct snd_soc_dapm_widget *snd_soc_dapm_kcontrol_widget(struct snd_kcontrol *kcontrol);
  492. int snd_soc_dapm_force_bias_level(struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level);
  493. /* dapm widget types */
  494. enum snd_soc_dapm_type {
  495. snd_soc_dapm_input = 0, /* input pin */
  496. snd_soc_dapm_output, /* output pin */
  497. snd_soc_dapm_mux, /* selects 1 analog signal from many inputs */
  498. snd_soc_dapm_demux, /* connects the input to one of multiple outputs */
  499. snd_soc_dapm_mixer, /* mixes several analog signals together */
  500. snd_soc_dapm_mixer_named_ctl, /* mixer with named controls */
  501. snd_soc_dapm_pga, /* programmable gain/attenuation (volume) */
  502. snd_soc_dapm_out_drv, /* output driver */
  503. snd_soc_dapm_adc, /* analog to digital converter */
  504. snd_soc_dapm_dac, /* digital to analog converter */
  505. snd_soc_dapm_micbias, /* microphone bias (power) - DEPRECATED: use snd_soc_dapm_supply */
  506. snd_soc_dapm_mic, /* microphone */
  507. snd_soc_dapm_hp, /* headphones */
  508. snd_soc_dapm_spk, /* speaker */
  509. snd_soc_dapm_line, /* line input/output */
  510. snd_soc_dapm_switch, /* analog switch */
  511. snd_soc_dapm_vmid, /* codec bias/vmid - to minimise pops */
  512. snd_soc_dapm_pre, /* machine specific pre widget - exec first */
  513. snd_soc_dapm_post, /* machine specific post widget - exec last */
  514. snd_soc_dapm_supply, /* power/clock supply */
  515. snd_soc_dapm_pinctrl, /* pinctrl */
  516. snd_soc_dapm_regulator_supply, /* external regulator */
  517. snd_soc_dapm_clock_supply, /* external clock */
  518. snd_soc_dapm_aif_in, /* audio interface input */
  519. snd_soc_dapm_aif_out, /* audio interface output */
  520. snd_soc_dapm_siggen, /* signal generator */
  521. snd_soc_dapm_sink,
  522. snd_soc_dapm_dai_in, /* link to DAI structure */
  523. snd_soc_dapm_dai_out,
  524. snd_soc_dapm_dai_link, /* link between two DAI structures */
  525. snd_soc_dapm_kcontrol, /* Auto-disabled kcontrol */
  526. snd_soc_dapm_buffer, /* DSP/CODEC internal buffer */
  527. snd_soc_dapm_scheduler, /* DSP/CODEC internal scheduler */
  528. snd_soc_dapm_effect, /* DSP/CODEC effect component */
  529. snd_soc_dapm_src, /* DSP/CODEC SRC component */
  530. snd_soc_dapm_asrc, /* DSP/CODEC ASRC component */
  531. snd_soc_dapm_encoder, /* FW/SW audio encoder component */
  532. snd_soc_dapm_decoder, /* FW/SW audio decoder component */
  533. /* Don't edit below this line */
  534. SND_SOC_DAPM_TYPE_COUNT
  535. };
  536. /*
  537. * DAPM audio route definition.
  538. *
  539. * Defines an audio route originating at source via control and finishing
  540. * at sink.
  541. */
  542. struct snd_soc_dapm_route {
  543. const char *sink;
  544. const char *control;
  545. const char *source;
  546. /* Note: currently only supported for links where source is a supply */
  547. int (*connected)(struct snd_soc_dapm_widget *source,
  548. struct snd_soc_dapm_widget *sink);
  549. struct snd_soc_dobj dobj;
  550. };
  551. /* dapm audio path between two widgets */
  552. struct snd_soc_dapm_path {
  553. const char *name;
  554. /*
  555. * source (input) and sink (output) widgets
  556. * The union is for convience, since it is a lot nicer to type
  557. * p->source, rather than p->node[SND_SOC_DAPM_DIR_IN]
  558. */
  559. union {
  560. struct {
  561. struct snd_soc_dapm_widget *source;
  562. struct snd_soc_dapm_widget *sink;
  563. };
  564. struct snd_soc_dapm_widget *node[2];
  565. };
  566. /* status */
  567. u32 connect:1; /* source and sink widgets are connected */
  568. u32 walking:1; /* path is in the process of being walked */
  569. u32 weak:1; /* path ignored for power management */
  570. u32 is_supply:1; /* At least one of the connected widgets is a supply */
  571. int (*connected)(struct snd_soc_dapm_widget *source,
  572. struct snd_soc_dapm_widget *sink);
  573. struct list_head list_node[2];
  574. struct list_head list_kcontrol;
  575. struct list_head list;
  576. };
  577. /* dapm widget */
  578. struct snd_soc_dapm_widget {
  579. enum snd_soc_dapm_type id;
  580. const char *name; /* widget name */
  581. const char *sname; /* stream name */
  582. struct list_head list;
  583. struct snd_soc_dapm_context *dapm;
  584. void *priv; /* widget specific data */
  585. struct regulator *regulator; /* attached regulator */
  586. struct pinctrl *pinctrl; /* attached pinctrl */
  587. /* dapm control */
  588. int reg; /* negative reg = no direct dapm */
  589. unsigned char shift; /* bits to shift */
  590. unsigned int mask; /* non-shifted mask */
  591. unsigned int on_val; /* on state value */
  592. unsigned int off_val; /* off state value */
  593. unsigned char power:1; /* block power status */
  594. unsigned char active:1; /* active stream on DAC, ADC's */
  595. unsigned char connected:1; /* connected codec pin */
  596. unsigned char new:1; /* cnew complete */
  597. unsigned char force:1; /* force state */
  598. unsigned char ignore_suspend:1; /* kept enabled over suspend */
  599. unsigned char new_power:1; /* power from this run */
  600. unsigned char power_checked:1; /* power checked this run */
  601. unsigned char is_supply:1; /* Widget is a supply type widget */
  602. unsigned char is_ep:2; /* Widget is a endpoint type widget */
  603. unsigned char no_wname_in_kcontrol_name:1; /* No widget name prefix in kcontrol name */
  604. int subseq; /* sort within widget type */
  605. int (*power_check)(struct snd_soc_dapm_widget *w);
  606. /* external events */
  607. unsigned short event_flags; /* flags to specify event types */
  608. int (*event)(struct snd_soc_dapm_widget*, struct snd_kcontrol *, int);
  609. /* kcontrols that relate to this widget */
  610. int num_kcontrols;
  611. const struct snd_kcontrol_new *kcontrol_news;
  612. struct snd_kcontrol **kcontrols;
  613. struct snd_soc_dobj dobj;
  614. /* widget input and output edges */
  615. struct list_head edges[2];
  616. /* used during DAPM updates */
  617. struct list_head work_list;
  618. struct list_head power_list;
  619. struct list_head dirty;
  620. int endpoints[2];
  621. struct clk *clk;
  622. int channel;
  623. };
  624. struct snd_soc_dapm_update {
  625. struct snd_kcontrol *kcontrol;
  626. int reg;
  627. int mask;
  628. int val;
  629. int reg2;
  630. int mask2;
  631. int val2;
  632. bool has_second_set;
  633. };
  634. /* DAPM context */
  635. struct snd_soc_dapm_context {
  636. enum snd_soc_bias_level bias_level;
  637. /* bit field */
  638. unsigned int idle_bias_off:1; /* Use BIAS_OFF instead of STANDBY */
  639. unsigned int suspend_bias_off:1; /* Use BIAS_OFF in suspend if the DAPM is idle */
  640. struct device *dev; /* from parent - for debug */
  641. struct snd_soc_component *component; /* parent component */
  642. struct snd_soc_card *card; /* parent card */
  643. /* used during DAPM updates */
  644. enum snd_soc_bias_level target_bias_level;
  645. struct list_head list;
  646. struct snd_soc_dapm_widget *wcache_sink;
  647. struct snd_soc_dapm_widget *wcache_source;
  648. #ifdef CONFIG_DEBUG_FS
  649. struct dentry *debugfs_dapm;
  650. #endif
  651. };
  652. /* A list of widgets associated with an object, typically a snd_kcontrol */
  653. struct snd_soc_dapm_widget_list {
  654. int num_widgets;
  655. struct snd_soc_dapm_widget *widgets[] __counted_by(num_widgets);
  656. };
  657. #define for_each_dapm_widgets(list, i, widget) \
  658. for ((i) = 0; \
  659. (i) < list->num_widgets && (widget = list->widgets[i]); \
  660. (i)++)
  661. struct snd_soc_dapm_stats {
  662. int power_checks;
  663. int path_checks;
  664. int neighbour_checks;
  665. };
  666. struct snd_soc_dapm_pinctrl_priv {
  667. const char *active_state;
  668. const char *sleep_state;
  669. };
  670. /**
  671. * snd_soc_dapm_init_bias_level() - Initialize DAPM bias level
  672. * @dapm: The DAPM context to initialize
  673. * @level: The DAPM level to initialize to
  674. *
  675. * This function only sets the driver internal state of the DAPM level and will
  676. * not modify the state of the device. Hence it should not be used during normal
  677. * operation, but only to synchronize the internal state to the device state.
  678. * E.g. during driver probe to set the DAPM level to the one corresponding with
  679. * the power-on reset state of the device.
  680. *
  681. * To change the DAPM state of the device use snd_soc_dapm_set_bias_level().
  682. */
  683. static inline void snd_soc_dapm_init_bias_level(
  684. struct snd_soc_dapm_context *dapm, enum snd_soc_bias_level level)
  685. {
  686. dapm->bias_level = level;
  687. }
  688. /**
  689. * snd_soc_dapm_get_bias_level() - Get current DAPM bias level
  690. * @dapm: The context for which to get the bias level
  691. *
  692. * Returns: The current bias level of the passed DAPM context.
  693. */
  694. static inline enum snd_soc_bias_level snd_soc_dapm_get_bias_level(
  695. struct snd_soc_dapm_context *dapm)
  696. {
  697. return dapm->bias_level;
  698. }
  699. enum snd_soc_dapm_direction {
  700. SND_SOC_DAPM_DIR_IN,
  701. SND_SOC_DAPM_DIR_OUT
  702. };
  703. #define SND_SOC_DAPM_DIR_TO_EP(x) BIT(x)
  704. #define SND_SOC_DAPM_EP_SOURCE SND_SOC_DAPM_DIR_TO_EP(SND_SOC_DAPM_DIR_IN)
  705. #define SND_SOC_DAPM_EP_SINK SND_SOC_DAPM_DIR_TO_EP(SND_SOC_DAPM_DIR_OUT)
  706. /**
  707. * snd_soc_dapm_widget_for_each_path - Iterates over all paths in the
  708. * specified direction of a widget
  709. * @w: The widget
  710. * @dir: Whether to iterate over the paths where the specified widget is the
  711. * incoming or outgoing widgets
  712. * @p: The path iterator variable
  713. */
  714. #define snd_soc_dapm_widget_for_each_path(w, dir, p) \
  715. list_for_each_entry(p, &w->edges[dir], list_node[dir])
  716. /**
  717. * snd_soc_dapm_widget_for_each_path_safe - Iterates over all paths in the
  718. * specified direction of a widget
  719. * @w: The widget
  720. * @dir: Whether to iterate over the paths where the specified widget is the
  721. * incoming or outgoing widgets
  722. * @p: The path iterator variable
  723. * @next_p: Temporary storage for the next path
  724. *
  725. * This function works like snd_soc_dapm_widget_for_each_path, expect that
  726. * it is safe to remove the current path from the list while iterating
  727. */
  728. #define snd_soc_dapm_widget_for_each_path_safe(w, dir, p, next_p) \
  729. list_for_each_entry_safe(p, next_p, &w->edges[dir], list_node[dir])
  730. /**
  731. * snd_soc_dapm_widget_for_each_sink_path - Iterates over all paths leaving a
  732. * widget
  733. * @w: The widget
  734. * @p: The path iterator variable
  735. */
  736. #define snd_soc_dapm_widget_for_each_sink_path(w, p) \
  737. snd_soc_dapm_widget_for_each_path(w, SND_SOC_DAPM_DIR_IN, p)
  738. /**
  739. * snd_soc_dapm_widget_for_each_source_path - Iterates over all paths leading to
  740. * a widget
  741. * @w: The widget
  742. * @p: The path iterator variable
  743. */
  744. #define snd_soc_dapm_widget_for_each_source_path(w, p) \
  745. snd_soc_dapm_widget_for_each_path(w, SND_SOC_DAPM_DIR_OUT, p)
  746. #endif