soc.h 52 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527
  1. /* SPDX-License-Identifier: GPL-2.0
  2. *
  3. * linux/sound/soc.h -- ALSA SoC Layer
  4. *
  5. * Author: Liam Girdwood
  6. * Created: Aug 11th 2005
  7. * Copyright: Wolfson Microelectronics. PLC.
  8. */
  9. #ifndef __LINUX_SND_SOC_H
  10. #define __LINUX_SND_SOC_H
  11. #include <linux/of.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/types.h>
  14. #include <linux/notifier.h>
  15. #include <linux/workqueue.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/kernel.h>
  18. #include <linux/regmap.h>
  19. #include <linux/log2.h>
  20. #include <sound/core.h>
  21. #include <sound/pcm.h>
  22. #include <sound/compress_driver.h>
  23. #include <sound/control.h>
  24. #include <sound/ac97_codec.h>
  25. /*
  26. * Convenience kcontrol builders
  27. */
  28. #define SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, xmax, xinvert, xautodisable) \
  29. ((unsigned long)&(struct soc_mixer_control) \
  30. {.reg = xreg, .rreg = xreg, .shift = shift_left, \
  31. .rshift = shift_right, .max = xmax, .platform_max = xmax, \
  32. .invert = xinvert, .autodisable = xautodisable})
  33. #define SOC_DOUBLE_S_VALUE(xreg, shift_left, shift_right, xmin, xmax, xsign_bit, xinvert, xautodisable) \
  34. ((unsigned long)&(struct soc_mixer_control) \
  35. {.reg = xreg, .rreg = xreg, .shift = shift_left, \
  36. .rshift = shift_right, .min = xmin, .max = xmax, .platform_max = xmax, \
  37. .sign_bit = xsign_bit, .invert = xinvert, .autodisable = xautodisable})
  38. #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, xautodisable) \
  39. SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert, xautodisable)
  40. #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
  41. ((unsigned long)&(struct soc_mixer_control) \
  42. {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert})
  43. #define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
  44. ((unsigned long)&(struct soc_mixer_control) \
  45. {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
  46. .max = xmax, .platform_max = xmax, .invert = xinvert})
  47. #define SOC_DOUBLE_R_S_VALUE(xlreg, xrreg, xshift, xmin, xmax, xsign_bit, xinvert) \
  48. ((unsigned long)&(struct soc_mixer_control) \
  49. {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
  50. .max = xmax, .min = xmin, .platform_max = xmax, .sign_bit = xsign_bit, \
  51. .invert = xinvert})
  52. #define SOC_DOUBLE_R_RANGE_VALUE(xlreg, xrreg, xshift, xmin, xmax, xinvert) \
  53. ((unsigned long)&(struct soc_mixer_control) \
  54. {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
  55. .min = xmin, .max = xmax, .platform_max = xmax, .invert = xinvert})
  56. #define SOC_SINGLE(xname, reg, shift, max, invert) \
  57. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  58. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
  59. .put = snd_soc_put_volsw, \
  60. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
  61. #define SOC_SINGLE_RANGE(xname, xreg, xshift, xmin, xmax, xinvert) \
  62. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  63. .info = snd_soc_info_volsw_range, .get = snd_soc_get_volsw_range, \
  64. .put = snd_soc_put_volsw_range, \
  65. .private_value = (unsigned long)&(struct soc_mixer_control) \
  66. {.reg = xreg, .rreg = xreg, .shift = xshift, \
  67. .rshift = xshift, .min = xmin, .max = xmax, \
  68. .platform_max = xmax, .invert = xinvert} }
  69. #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
  70. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  71. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  72. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  73. .tlv.p = (tlv_array), \
  74. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
  75. .put = snd_soc_put_volsw, \
  76. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) }
  77. #define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
  78. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  79. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  80. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  81. .tlv.p = (tlv_array),\
  82. .info = snd_soc_info_volsw_sx, \
  83. .get = snd_soc_get_volsw_sx,\
  84. .put = snd_soc_put_volsw_sx, \
  85. .private_value = (unsigned long)&(struct soc_mixer_control) \
  86. {.reg = xreg, .rreg = xreg, \
  87. .shift = xshift, .rshift = xshift, \
  88. .max = xmax, .min = xmin} }
  89. #define SOC_SINGLE_RANGE_TLV(xname, xreg, xshift, xmin, xmax, xinvert, tlv_array) \
  90. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  91. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  92. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  93. .tlv.p = (tlv_array), \
  94. .info = snd_soc_info_volsw_range, \
  95. .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
  96. .private_value = (unsigned long)&(struct soc_mixer_control) \
  97. {.reg = xreg, .rreg = xreg, .shift = xshift, \
  98. .rshift = xshift, .min = xmin, .max = xmax, \
  99. .platform_max = xmax, .invert = xinvert} }
  100. #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
  101. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  102. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
  103. .put = snd_soc_put_volsw, \
  104. .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
  105. max, invert, 0) }
  106. #define SOC_DOUBLE_STS(xname, reg, shift_left, shift_right, max, invert) \
  107. { \
  108. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  109. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
  110. .access = SNDRV_CTL_ELEM_ACCESS_READ | \
  111. SNDRV_CTL_ELEM_ACCESS_VOLATILE, \
  112. .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
  113. max, invert, 0) }
  114. #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
  115. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  116. .info = snd_soc_info_volsw, \
  117. .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
  118. .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
  119. xmax, xinvert) }
  120. #define SOC_DOUBLE_R_RANGE(xname, reg_left, reg_right, xshift, xmin, \
  121. xmax, xinvert) \
  122. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  123. .info = snd_soc_info_volsw_range, \
  124. .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
  125. .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
  126. xshift, xmin, xmax, xinvert) }
  127. #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
  128. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  129. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  130. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  131. .tlv.p = (tlv_array), \
  132. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
  133. .put = snd_soc_put_volsw, \
  134. .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
  135. max, invert, 0) }
  136. #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
  137. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  138. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  139. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  140. .tlv.p = (tlv_array), \
  141. .info = snd_soc_info_volsw, \
  142. .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
  143. .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
  144. xmax, xinvert) }
  145. #define SOC_DOUBLE_R_RANGE_TLV(xname, reg_left, reg_right, xshift, xmin, \
  146. xmax, xinvert, tlv_array) \
  147. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  148. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  149. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  150. .tlv.p = (tlv_array), \
  151. .info = snd_soc_info_volsw_range, \
  152. .get = snd_soc_get_volsw_range, .put = snd_soc_put_volsw_range, \
  153. .private_value = SOC_DOUBLE_R_RANGE_VALUE(reg_left, reg_right, \
  154. xshift, xmin, xmax, xinvert) }
  155. #define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
  156. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  157. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  158. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  159. .tlv.p = (tlv_array), \
  160. .info = snd_soc_info_volsw_sx, \
  161. .get = snd_soc_get_volsw_sx, \
  162. .put = snd_soc_put_volsw_sx, \
  163. .private_value = (unsigned long)&(struct soc_mixer_control) \
  164. {.reg = xreg, .rreg = xrreg, \
  165. .shift = xshift, .rshift = xshift, \
  166. .max = xmax, .min = xmin} }
  167. #define SOC_DOUBLE_R_S_TLV(xname, reg_left, reg_right, xshift, xmin, xmax, xsign_bit, xinvert, tlv_array) \
  168. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  169. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  170. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  171. .tlv.p = (tlv_array), \
  172. .info = snd_soc_info_volsw, \
  173. .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
  174. .private_value = SOC_DOUBLE_R_S_VALUE(reg_left, reg_right, xshift, \
  175. xmin, xmax, xsign_bit, xinvert) }
  176. #define SOC_SINGLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
  177. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  178. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  179. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  180. .tlv.p = (tlv_array), \
  181. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
  182. .put = snd_soc_put_volsw, \
  183. .private_value = (unsigned long)&(struct soc_mixer_control) \
  184. {.reg = xreg, .rreg = xreg, \
  185. .min = xmin, .max = xmax, .platform_max = xmax, \
  186. .sign_bit = 7,} }
  187. #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
  188. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  189. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  190. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  191. .tlv.p = (tlv_array), \
  192. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
  193. .put = snd_soc_put_volsw, \
  194. .private_value = SOC_DOUBLE_S_VALUE(xreg, 0, 8, xmin, xmax, 7, 0, 0) }
  195. #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xitems, xtexts) \
  196. { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
  197. .items = xitems, .texts = xtexts, \
  198. .mask = xitems ? roundup_pow_of_two(xitems) - 1 : 0}
  199. #define SOC_ENUM_SINGLE(xreg, xshift, xitems, xtexts) \
  200. SOC_ENUM_DOUBLE(xreg, xshift, xshift, xitems, xtexts)
  201. #define SOC_ENUM_SINGLE_EXT(xitems, xtexts) \
  202. { .items = xitems, .texts = xtexts }
  203. #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xitems, xtexts, xvalues) \
  204. { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
  205. .mask = xmask, .items = xitems, .texts = xtexts, .values = xvalues}
  206. #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
  207. SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xitems, xtexts, xvalues)
  208. #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, xshift, xmask, xitems, xtexts, xvalues) \
  209. { .reg = xreg, .shift_l = xshift, .shift_r = xshift, \
  210. .mask = xmask, .items = xitems, .texts = xtexts, \
  211. .values = xvalues, .autodisable = 1}
  212. #define SOC_ENUM_SINGLE_VIRT(xitems, xtexts) \
  213. SOC_ENUM_SINGLE(SND_SOC_NOPM, 0, xitems, xtexts)
  214. #define SOC_ENUM(xname, xenum) \
  215. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
  216. .info = snd_soc_info_enum_double, \
  217. .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
  218. .private_value = (unsigned long)&xenum }
  219. #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
  220. xhandler_get, xhandler_put) \
  221. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  222. .info = snd_soc_info_volsw, \
  223. .get = xhandler_get, .put = xhandler_put, \
  224. .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
  225. #define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
  226. xhandler_get, xhandler_put) \
  227. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  228. .info = snd_soc_info_volsw, \
  229. .get = xhandler_get, .put = xhandler_put, \
  230. .private_value = \
  231. SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert, 0) }
  232. #define SOC_DOUBLE_R_EXT(xname, reg_left, reg_right, xshift, xmax, xinvert,\
  233. xhandler_get, xhandler_put) \
  234. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  235. .info = snd_soc_info_volsw, \
  236. .get = xhandler_get, .put = xhandler_put, \
  237. .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
  238. xmax, xinvert) }
  239. #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
  240. xhandler_get, xhandler_put, tlv_array) \
  241. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  242. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  243. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  244. .tlv.p = (tlv_array), \
  245. .info = snd_soc_info_volsw, \
  246. .get = xhandler_get, .put = xhandler_put, \
  247. .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert, 0) }
  248. #define SOC_SINGLE_RANGE_EXT_TLV(xname, xreg, xshift, xmin, xmax, xinvert, \
  249. xhandler_get, xhandler_put, tlv_array) \
  250. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  251. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  252. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  253. .tlv.p = (tlv_array), \
  254. .info = snd_soc_info_volsw_range, \
  255. .get = xhandler_get, .put = xhandler_put, \
  256. .private_value = (unsigned long)&(struct soc_mixer_control) \
  257. {.reg = xreg, .rreg = xreg, .shift = xshift, \
  258. .rshift = xshift, .min = xmin, .max = xmax, \
  259. .platform_max = xmax, .invert = xinvert} }
  260. #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
  261. xhandler_get, xhandler_put, tlv_array) \
  262. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  263. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  264. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  265. .tlv.p = (tlv_array), \
  266. .info = snd_soc_info_volsw, \
  267. .get = xhandler_get, .put = xhandler_put, \
  268. .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
  269. xmax, xinvert, 0) }
  270. #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
  271. xhandler_get, xhandler_put, tlv_array) \
  272. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  273. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  274. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  275. .tlv.p = (tlv_array), \
  276. .info = snd_soc_info_volsw, \
  277. .get = xhandler_get, .put = xhandler_put, \
  278. .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
  279. xmax, xinvert) }
  280. #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
  281. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  282. .info = snd_soc_info_bool_ext, \
  283. .get = xhandler_get, .put = xhandler_put, \
  284. .private_value = xdata }
  285. #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
  286. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  287. .info = snd_soc_info_enum_double, \
  288. .get = xhandler_get, .put = xhandler_put, \
  289. .private_value = (unsigned long)&xenum }
  290. #define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
  291. SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put)
  292. #define SND_SOC_BYTES(xname, xbase, xregs) \
  293. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  294. .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
  295. .put = snd_soc_bytes_put, .private_value = \
  296. ((unsigned long)&(struct soc_bytes) \
  297. {.base = xbase, .num_regs = xregs }) }
  298. #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask) \
  299. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  300. .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
  301. .put = snd_soc_bytes_put, .private_value = \
  302. ((unsigned long)&(struct soc_bytes) \
  303. {.base = xbase, .num_regs = xregs, \
  304. .mask = xmask }) }
  305. /*
  306. * SND_SOC_BYTES_EXT is deprecated, please USE SND_SOC_BYTES_TLV instead
  307. */
  308. #define SND_SOC_BYTES_EXT(xname, xcount, xhandler_get, xhandler_put) \
  309. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  310. .info = snd_soc_bytes_info_ext, \
  311. .get = xhandler_get, .put = xhandler_put, \
  312. .private_value = (unsigned long)&(struct soc_bytes_ext) \
  313. {.max = xcount} }
  314. #define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \
  315. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  316. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \
  317. SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \
  318. .tlv.c = (snd_soc_bytes_tlv_callback), \
  319. .info = snd_soc_bytes_info_ext, \
  320. .private_value = (unsigned long)&(struct soc_bytes_ext) \
  321. {.max = xcount, .get = xhandler_get, .put = xhandler_put, } }
  322. #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
  323. xmin, xmax, xinvert) \
  324. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  325. .info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
  326. .put = snd_soc_put_xr_sx, \
  327. .private_value = (unsigned long)&(struct soc_mreg_control) \
  328. {.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
  329. .invert = xinvert, .min = xmin, .max = xmax} }
  330. #define SOC_SINGLE_STROBE(xname, xreg, xshift, xinvert) \
  331. SOC_SINGLE_EXT(xname, xreg, xshift, 1, xinvert, \
  332. snd_soc_get_strobe, snd_soc_put_strobe)
  333. /*
  334. * Simplified versions of above macros, declaring a struct and calculating
  335. * ARRAY_SIZE internally
  336. */
  337. #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
  338. const struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
  339. ARRAY_SIZE(xtexts), xtexts)
  340. #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
  341. SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
  342. #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
  343. const struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
  344. #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
  345. const struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
  346. ARRAY_SIZE(xtexts), xtexts, xvalues)
  347. #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
  348. SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
  349. #define SOC_VALUE_ENUM_SINGLE_AUTODISABLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
  350. const struct soc_enum name = SOC_VALUE_ENUM_SINGLE_AUTODISABLE(xreg, \
  351. xshift, xmask, ARRAY_SIZE(xtexts), xtexts, xvalues)
  352. #define SOC_ENUM_SINGLE_VIRT_DECL(name, xtexts) \
  353. const struct soc_enum name = SOC_ENUM_SINGLE_VIRT(ARRAY_SIZE(xtexts), xtexts)
  354. /*
  355. * Component probe and remove ordering levels for components with runtime
  356. * dependencies.
  357. */
  358. #define SND_SOC_COMP_ORDER_FIRST -2
  359. #define SND_SOC_COMP_ORDER_EARLY -1
  360. #define SND_SOC_COMP_ORDER_NORMAL 0
  361. #define SND_SOC_COMP_ORDER_LATE 1
  362. #define SND_SOC_COMP_ORDER_LAST 2
  363. /*
  364. * Bias levels
  365. *
  366. * @ON: Bias is fully on for audio playback and capture operations.
  367. * @PREPARE: Prepare for audio operations. Called before DAPM switching for
  368. * stream start and stop operations.
  369. * @STANDBY: Low power standby state when no playback/capture operations are
  370. * in progress. NOTE: The transition time between STANDBY and ON
  371. * should be as fast as possible and no longer than 10ms.
  372. * @OFF: Power Off. No restrictions on transition times.
  373. */
  374. enum snd_soc_bias_level {
  375. SND_SOC_BIAS_OFF = 0,
  376. SND_SOC_BIAS_STANDBY = 1,
  377. SND_SOC_BIAS_PREPARE = 2,
  378. SND_SOC_BIAS_ON = 3,
  379. };
  380. struct device_node;
  381. struct snd_jack;
  382. struct snd_soc_card;
  383. struct snd_soc_pcm_stream;
  384. struct snd_soc_ops;
  385. struct snd_soc_pcm_runtime;
  386. struct snd_soc_dai;
  387. struct snd_soc_dai_driver;
  388. struct snd_soc_dai_link;
  389. struct snd_soc_component;
  390. struct snd_soc_component_driver;
  391. struct soc_enum;
  392. struct snd_soc_jack;
  393. struct snd_soc_jack_zone;
  394. struct snd_soc_jack_pin;
  395. #include <sound/soc-dapm.h>
  396. #include <sound/soc-dpcm.h>
  397. #include <sound/soc-topology.h>
  398. struct snd_soc_jack_gpio;
  399. typedef int (*hw_write_t)(void *,const char* ,int);
  400. enum snd_soc_pcm_subclass {
  401. SND_SOC_PCM_CLASS_PCM = 0,
  402. SND_SOC_PCM_CLASS_BE = 1,
  403. };
  404. enum snd_soc_card_subclass {
  405. SND_SOC_CARD_CLASS_INIT = 0,
  406. SND_SOC_CARD_CLASS_RUNTIME = 1,
  407. };
  408. int snd_soc_register_card(struct snd_soc_card *card);
  409. int snd_soc_unregister_card(struct snd_soc_card *card);
  410. int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card);
  411. #ifdef CONFIG_PM_SLEEP
  412. int snd_soc_suspend(struct device *dev);
  413. int snd_soc_resume(struct device *dev);
  414. #else
  415. static inline int snd_soc_suspend(struct device *dev)
  416. {
  417. return 0;
  418. }
  419. static inline int snd_soc_resume(struct device *dev)
  420. {
  421. return 0;
  422. }
  423. #endif
  424. int snd_soc_poweroff(struct device *dev);
  425. int snd_soc_add_component(struct device *dev,
  426. struct snd_soc_component *component,
  427. const struct snd_soc_component_driver *component_driver,
  428. struct snd_soc_dai_driver *dai_drv,
  429. int num_dai);
  430. int snd_soc_register_component(struct device *dev,
  431. const struct snd_soc_component_driver *component_driver,
  432. struct snd_soc_dai_driver *dai_drv, int num_dai);
  433. int devm_snd_soc_register_component(struct device *dev,
  434. const struct snd_soc_component_driver *component_driver,
  435. struct snd_soc_dai_driver *dai_drv, int num_dai);
  436. void snd_soc_unregister_component(struct device *dev);
  437. struct snd_soc_component *snd_soc_lookup_component(struct device *dev,
  438. const char *driver_name);
  439. int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
  440. #ifdef CONFIG_SND_SOC_COMPRESS
  441. int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num);
  442. #else
  443. static inline int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
  444. {
  445. return 0;
  446. }
  447. #endif
  448. void snd_soc_disconnect_sync(struct device *dev);
  449. struct snd_pcm_substream *snd_soc_get_dai_substream(struct snd_soc_card *card,
  450. const char *dai_link, int stream);
  451. struct snd_soc_pcm_runtime *snd_soc_get_pcm_runtime(struct snd_soc_card *card,
  452. const char *dai_link);
  453. bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd);
  454. void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream);
  455. void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream);
  456. int snd_soc_runtime_set_dai_fmt(struct snd_soc_pcm_runtime *rtd,
  457. unsigned int dai_fmt);
  458. #ifdef CONFIG_DMI
  459. int snd_soc_set_dmi_name(struct snd_soc_card *card, const char *flavour);
  460. #else
  461. static inline int snd_soc_set_dmi_name(struct snd_soc_card *card,
  462. const char *flavour)
  463. {
  464. return 0;
  465. }
  466. #endif
  467. /* Utility functions to get clock rates from various things */
  468. int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
  469. int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
  470. int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
  471. int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
  472. /* set runtime hw params */
  473. int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
  474. const struct snd_pcm_hardware *hw);
  475. int soc_dai_hw_params(struct snd_pcm_substream *substream,
  476. struct snd_pcm_hw_params *params,
  477. struct snd_soc_dai *dai);
  478. /* Jack reporting */
  479. int snd_soc_card_jack_new(struct snd_soc_card *card, const char *id, int type,
  480. struct snd_soc_jack *jack, struct snd_soc_jack_pin *pins,
  481. unsigned int num_pins);
  482. void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
  483. int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
  484. struct snd_soc_jack_pin *pins);
  485. void snd_soc_jack_notifier_register(struct snd_soc_jack *jack,
  486. struct notifier_block *nb);
  487. void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
  488. struct notifier_block *nb);
  489. int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count,
  490. struct snd_soc_jack_zone *zones);
  491. int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage);
  492. #ifdef CONFIG_GPIOLIB
  493. int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
  494. struct snd_soc_jack_gpio *gpios);
  495. int snd_soc_jack_add_gpiods(struct device *gpiod_dev,
  496. struct snd_soc_jack *jack,
  497. int count, struct snd_soc_jack_gpio *gpios);
  498. void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
  499. struct snd_soc_jack_gpio *gpios);
  500. #else
  501. static inline int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
  502. struct snd_soc_jack_gpio *gpios)
  503. {
  504. return 0;
  505. }
  506. static inline int snd_soc_jack_add_gpiods(struct device *gpiod_dev,
  507. struct snd_soc_jack *jack,
  508. int count,
  509. struct snd_soc_jack_gpio *gpios)
  510. {
  511. return 0;
  512. }
  513. static inline void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
  514. struct snd_soc_jack_gpio *gpios)
  515. {
  516. }
  517. #endif
  518. struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
  519. struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
  520. unsigned int id, unsigned int id_mask);
  521. void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
  522. #ifdef CONFIG_SND_SOC_AC97_BUS
  523. int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops);
  524. int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
  525. struct platform_device *pdev);
  526. extern struct snd_ac97_bus_ops *soc_ac97_ops;
  527. #else
  528. static inline int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
  529. struct platform_device *pdev)
  530. {
  531. return 0;
  532. }
  533. static inline int snd_soc_set_ac97_ops(struct snd_ac97_bus_ops *ops)
  534. {
  535. return 0;
  536. }
  537. #endif
  538. /*
  539. *Controls
  540. */
  541. struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
  542. void *data, const char *long_name,
  543. const char *prefix);
  544. struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card,
  545. const char *name);
  546. int snd_soc_add_component_controls(struct snd_soc_component *component,
  547. const struct snd_kcontrol_new *controls, unsigned int num_controls);
  548. int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
  549. const struct snd_kcontrol_new *controls, int num_controls);
  550. int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
  551. const struct snd_kcontrol_new *controls, int num_controls);
  552. int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
  553. struct snd_ctl_elem_info *uinfo);
  554. int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
  555. struct snd_ctl_elem_value *ucontrol);
  556. int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
  557. struct snd_ctl_elem_value *ucontrol);
  558. int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
  559. struct snd_ctl_elem_info *uinfo);
  560. int snd_soc_info_volsw_sx(struct snd_kcontrol *kcontrol,
  561. struct snd_ctl_elem_info *uinfo);
  562. #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
  563. int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
  564. struct snd_ctl_elem_value *ucontrol);
  565. int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
  566. struct snd_ctl_elem_value *ucontrol);
  567. #define snd_soc_get_volsw_2r snd_soc_get_volsw
  568. #define snd_soc_put_volsw_2r snd_soc_put_volsw
  569. int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
  570. struct snd_ctl_elem_value *ucontrol);
  571. int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
  572. struct snd_ctl_elem_value *ucontrol);
  573. int snd_soc_info_volsw_range(struct snd_kcontrol *kcontrol,
  574. struct snd_ctl_elem_info *uinfo);
  575. int snd_soc_put_volsw_range(struct snd_kcontrol *kcontrol,
  576. struct snd_ctl_elem_value *ucontrol);
  577. int snd_soc_get_volsw_range(struct snd_kcontrol *kcontrol,
  578. struct snd_ctl_elem_value *ucontrol);
  579. int snd_soc_limit_volume(struct snd_soc_card *card,
  580. const char *name, int max);
  581. int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
  582. struct snd_ctl_elem_info *uinfo);
  583. int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
  584. struct snd_ctl_elem_value *ucontrol);
  585. int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
  586. struct snd_ctl_elem_value *ucontrol);
  587. int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol,
  588. struct snd_ctl_elem_info *ucontrol);
  589. int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag,
  590. unsigned int size, unsigned int __user *tlv);
  591. int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
  592. struct snd_ctl_elem_info *uinfo);
  593. int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
  594. struct snd_ctl_elem_value *ucontrol);
  595. int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
  596. struct snd_ctl_elem_value *ucontrol);
  597. int snd_soc_get_strobe(struct snd_kcontrol *kcontrol,
  598. struct snd_ctl_elem_value *ucontrol);
  599. int snd_soc_put_strobe(struct snd_kcontrol *kcontrol,
  600. struct snd_ctl_elem_value *ucontrol);
  601. /**
  602. * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
  603. *
  604. * @pin: name of the pin to update
  605. * @mask: bits to check for in reported jack status
  606. * @invert: if non-zero then pin is enabled when status is not reported
  607. * @list: internal list entry
  608. */
  609. struct snd_soc_jack_pin {
  610. struct list_head list;
  611. const char *pin;
  612. int mask;
  613. bool invert;
  614. };
  615. /**
  616. * struct snd_soc_jack_zone - Describes voltage zones of jack detection
  617. *
  618. * @min_mv: start voltage in mv
  619. * @max_mv: end voltage in mv
  620. * @jack_type: type of jack that is expected for this voltage
  621. * @debounce_time: debounce_time for jack, codec driver should wait for this
  622. * duration before reading the adc for voltages
  623. * @list: internal list entry
  624. */
  625. struct snd_soc_jack_zone {
  626. unsigned int min_mv;
  627. unsigned int max_mv;
  628. unsigned int jack_type;
  629. unsigned int debounce_time;
  630. struct list_head list;
  631. };
  632. /**
  633. * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection
  634. *
  635. * @gpio: legacy gpio number
  636. * @idx: gpio descriptor index within the function of the GPIO
  637. * consumer device
  638. * @gpiod_dev: GPIO consumer device
  639. * @name: gpio name. Also as connection ID for the GPIO consumer
  640. * device function name lookup
  641. * @report: value to report when jack detected
  642. * @invert: report presence in low state
  643. * @debounce_time: debounce time in ms
  644. * @wake: enable as wake source
  645. * @jack_status_check: callback function which overrides the detection
  646. * to provide more complex checks (eg, reading an
  647. * ADC).
  648. */
  649. struct snd_soc_jack_gpio {
  650. unsigned int gpio;
  651. unsigned int idx;
  652. struct device *gpiod_dev;
  653. const char *name;
  654. int report;
  655. int invert;
  656. int debounce_time;
  657. bool wake;
  658. /* private: */
  659. struct snd_soc_jack *jack;
  660. struct delayed_work work;
  661. struct notifier_block pm_notifier;
  662. struct gpio_desc *desc;
  663. void *data;
  664. /* public: */
  665. int (*jack_status_check)(void *data);
  666. };
  667. struct snd_soc_jack {
  668. struct mutex mutex;
  669. struct snd_jack *jack;
  670. struct snd_soc_card *card;
  671. struct list_head pins;
  672. int status;
  673. struct blocking_notifier_head notifier;
  674. struct list_head jack_zones;
  675. };
  676. /* SoC PCM stream information */
  677. struct snd_soc_pcm_stream {
  678. const char *stream_name;
  679. u64 formats; /* SNDRV_PCM_FMTBIT_* */
  680. unsigned int rates; /* SNDRV_PCM_RATE_* */
  681. unsigned int rate_min; /* min rate */
  682. unsigned int rate_max; /* max rate */
  683. unsigned int channels_min; /* min channels */
  684. unsigned int channels_max; /* max channels */
  685. unsigned int sig_bits; /* number of bits of content */
  686. };
  687. /* SoC audio ops */
  688. struct snd_soc_ops {
  689. int (*startup)(struct snd_pcm_substream *);
  690. void (*shutdown)(struct snd_pcm_substream *);
  691. int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
  692. int (*hw_free)(struct snd_pcm_substream *);
  693. int (*prepare)(struct snd_pcm_substream *);
  694. int (*trigger)(struct snd_pcm_substream *, int);
  695. };
  696. struct snd_soc_compr_ops {
  697. int (*startup)(struct snd_compr_stream *);
  698. void (*shutdown)(struct snd_compr_stream *);
  699. int (*set_params)(struct snd_compr_stream *);
  700. int (*trigger)(struct snd_compr_stream *);
  701. };
  702. /* component interface */
  703. struct snd_soc_component_driver {
  704. const char *name;
  705. /* Default control and setup, added after probe() is run */
  706. const struct snd_kcontrol_new *controls;
  707. unsigned int num_controls;
  708. const struct snd_soc_dapm_widget *dapm_widgets;
  709. unsigned int num_dapm_widgets;
  710. const struct snd_soc_dapm_route *dapm_routes;
  711. unsigned int num_dapm_routes;
  712. int (*probe)(struct snd_soc_component *);
  713. void (*remove)(struct snd_soc_component *);
  714. int (*suspend)(struct snd_soc_component *);
  715. int (*resume)(struct snd_soc_component *);
  716. unsigned int (*read)(struct snd_soc_component *, unsigned int);
  717. int (*write)(struct snd_soc_component *, unsigned int, unsigned int);
  718. /* pcm creation and destruction */
  719. int (*pcm_new)(struct snd_soc_pcm_runtime *);
  720. void (*pcm_free)(struct snd_pcm *);
  721. /* component wide operations */
  722. int (*set_sysclk)(struct snd_soc_component *component,
  723. int clk_id, int source, unsigned int freq, int dir);
  724. int (*set_pll)(struct snd_soc_component *component, int pll_id,
  725. int source, unsigned int freq_in, unsigned int freq_out);
  726. int (*set_jack)(struct snd_soc_component *component,
  727. struct snd_soc_jack *jack, void *data);
  728. /* DT */
  729. int (*of_xlate_dai_name)(struct snd_soc_component *component,
  730. struct of_phandle_args *args,
  731. const char **dai_name);
  732. int (*of_xlate_dai_id)(struct snd_soc_component *comment,
  733. struct device_node *endpoint);
  734. void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type,
  735. int subseq);
  736. int (*stream_event)(struct snd_soc_component *, int event);
  737. int (*set_bias_level)(struct snd_soc_component *component,
  738. enum snd_soc_bias_level level);
  739. const struct snd_pcm_ops *ops;
  740. const struct snd_compr_ops *compr_ops;
  741. /* probe ordering - for components with runtime dependencies */
  742. int probe_order;
  743. int remove_order;
  744. /* bits */
  745. unsigned int idle_bias_on:1;
  746. unsigned int suspend_bias_off:1;
  747. unsigned int use_pmdown_time:1; /* care pmdown_time at stop */
  748. unsigned int endianness:1;
  749. unsigned int non_legacy_dai_naming:1;
  750. /* this component uses topology and ignore machine driver FEs */
  751. const char *ignore_machine;
  752. const char *topology_name_prefix;
  753. int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
  754. struct snd_pcm_hw_params *params);
  755. bool use_dai_pcm_id; /* use the DAI link PCM ID as PCM device number */
  756. int be_pcm_base; /* base device ID for all BE PCMs */
  757. short reg_word_size;
  758. const struct reg_default *reg_cache_default;
  759. unsigned int reg_cache_size;
  760. };
  761. struct snd_soc_component {
  762. const char *name;
  763. int id;
  764. const char *name_prefix;
  765. struct device *dev;
  766. struct snd_soc_card *card;
  767. unsigned int active;
  768. unsigned int suspended:1; /* is in suspend PM state */
  769. struct list_head list;
  770. struct list_head card_aux_list; /* for auxiliary bound components */
  771. struct list_head card_list;
  772. const struct snd_soc_component_driver *driver;
  773. struct list_head dai_list;
  774. int num_dai;
  775. struct regmap *regmap;
  776. int val_bytes;
  777. struct mutex io_mutex;
  778. /* attached dynamic objects */
  779. struct list_head dobj_list;
  780. /*
  781. * DO NOT use any of the fields below in drivers, they are temporary and
  782. * are going to be removed again soon. If you use them in driver code the
  783. * driver will be marked as BROKEN when these fields are removed.
  784. */
  785. /* Don't use these, use snd_soc_component_get_dapm() */
  786. struct snd_soc_dapm_context dapm;
  787. /* machine specific init */
  788. int (*init)(struct snd_soc_component *component);
  789. #ifdef CONFIG_DEBUG_FS
  790. struct dentry *debugfs_root;
  791. const char *debugfs_prefix;
  792. #endif
  793. };
  794. struct snd_soc_rtdcom_list {
  795. struct snd_soc_component *component;
  796. struct list_head list; /* rtd::component_list */
  797. };
  798. struct snd_soc_component*
  799. snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
  800. const char *driver_name);
  801. #define for_each_rtdcom(rtd, rtdcom) \
  802. list_for_each_entry(rtdcom, &(rtd)->component_list, list)
  803. #define for_each_rtdcom_safe(rtd, rtdcom1, rtdcom2) \
  804. list_for_each_entry_safe(rtdcom1, rtdcom2, &(rtd)->component_list, list)
  805. struct snd_soc_dai_link_component {
  806. const char *name;
  807. struct device_node *of_node;
  808. const char *dai_name;
  809. };
  810. struct snd_soc_dai_link {
  811. /* config - must be set by machine driver */
  812. const char *name; /* Codec name */
  813. const char *stream_name; /* Stream name */
  814. /*
  815. * You MAY specify the link's CPU-side device, either by device name,
  816. * or by DT/OF node, but not both. If this information is omitted,
  817. * the CPU-side DAI is matched using .cpu_dai_name only, which hence
  818. * must be globally unique. These fields are currently typically used
  819. * only for codec to codec links, or systems using device tree.
  820. */
  821. const char *cpu_name;
  822. struct device_node *cpu_of_node;
  823. /*
  824. * You MAY specify the DAI name of the CPU DAI. If this information is
  825. * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
  826. * only, which only works well when that device exposes a single DAI.
  827. */
  828. const char *cpu_dai_name;
  829. /*
  830. * You MUST specify the link's codec, either by device name, or by
  831. * DT/OF node, but not both.
  832. */
  833. const char *codec_name;
  834. struct device_node *codec_of_node;
  835. /* You MUST specify the DAI name within the codec */
  836. const char *codec_dai_name;
  837. struct snd_soc_dai_link_component *codecs;
  838. unsigned int num_codecs;
  839. /*
  840. * You MAY specify the link's platform/PCM/DMA driver, either by
  841. * device name, or by DT/OF node, but not both. Some forms of link
  842. * do not need a platform.
  843. */
  844. const char *platform_name;
  845. struct device_node *platform_of_node;
  846. int id; /* optional ID for machine driver link identification */
  847. const struct snd_soc_pcm_stream *params;
  848. unsigned int num_params;
  849. unsigned int dai_fmt; /* format to set on init */
  850. enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
  851. /* codec/machine specific init - e.g. add machine controls */
  852. int (*init)(struct snd_soc_pcm_runtime *rtd);
  853. /* optional hw_params re-writing for BE and FE sync */
  854. int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
  855. struct snd_pcm_hw_params *params);
  856. /* machine stream operations */
  857. const struct snd_soc_ops *ops;
  858. const struct snd_soc_compr_ops *compr_ops;
  859. /* Mark this pcm with non atomic ops */
  860. bool nonatomic;
  861. /* For unidirectional dai links */
  862. unsigned int playback_only:1;
  863. unsigned int capture_only:1;
  864. /* Keep DAI active over suspend */
  865. unsigned int ignore_suspend:1;
  866. /* Symmetry requirements */
  867. unsigned int symmetric_rates:1;
  868. unsigned int symmetric_channels:1;
  869. unsigned int symmetric_samplebits:1;
  870. /* Do not create a PCM for this DAI link (Backend link) */
  871. unsigned int no_pcm:1;
  872. /* This DAI link can route to other DAI links at runtime (Frontend)*/
  873. unsigned int dynamic:1;
  874. /* DPCM capture and Playback support */
  875. unsigned int dpcm_capture:1;
  876. unsigned int dpcm_playback:1;
  877. /* DPCM used FE & BE merged format */
  878. unsigned int dpcm_merged_format:1;
  879. /* DPCM used FE & BE merged channel */
  880. unsigned int dpcm_merged_chan:1;
  881. /* DPCM used FE & BE merged rate */
  882. unsigned int dpcm_merged_rate:1;
  883. /* pmdown_time is ignored at stop */
  884. unsigned int ignore_pmdown_time:1;
  885. /* Do not create a PCM for this DAI link (Backend link) */
  886. unsigned int ignore:1;
  887. struct list_head list; /* DAI link list of the soc card */
  888. struct snd_soc_dobj dobj; /* For topology */
  889. };
  890. struct snd_soc_codec_conf {
  891. /*
  892. * specify device either by device name, or by
  893. * DT/OF node, but not both.
  894. */
  895. const char *dev_name;
  896. struct device_node *of_node;
  897. /*
  898. * optional map of kcontrol, widget and path name prefixes that are
  899. * associated per device
  900. */
  901. const char *name_prefix;
  902. };
  903. struct snd_soc_aux_dev {
  904. const char *name; /* Codec name */
  905. /*
  906. * specify multi-codec either by device name, or by
  907. * DT/OF node, but not both.
  908. */
  909. const char *codec_name;
  910. struct device_node *codec_of_node;
  911. /* codec/machine specific init - e.g. add machine controls */
  912. int (*init)(struct snd_soc_component *component);
  913. };
  914. /* SoC card */
  915. struct snd_soc_card {
  916. const char *name;
  917. const char *long_name;
  918. const char *driver_name;
  919. char dmi_longname[80];
  920. char topology_shortname[32];
  921. struct device *dev;
  922. struct snd_card *snd_card;
  923. struct module *owner;
  924. struct mutex mutex;
  925. struct mutex dapm_mutex;
  926. bool instantiated;
  927. bool topology_shortname_created;
  928. int (*probe)(struct snd_soc_card *card);
  929. int (*late_probe)(struct snd_soc_card *card);
  930. int (*remove)(struct snd_soc_card *card);
  931. /* the pre and post PM functions are used to do any PM work before and
  932. * after the codec and DAI's do any PM work. */
  933. int (*suspend_pre)(struct snd_soc_card *card);
  934. int (*suspend_post)(struct snd_soc_card *card);
  935. int (*resume_pre)(struct snd_soc_card *card);
  936. int (*resume_post)(struct snd_soc_card *card);
  937. /* callbacks */
  938. int (*set_bias_level)(struct snd_soc_card *,
  939. struct snd_soc_dapm_context *dapm,
  940. enum snd_soc_bias_level level);
  941. int (*set_bias_level_post)(struct snd_soc_card *,
  942. struct snd_soc_dapm_context *dapm,
  943. enum snd_soc_bias_level level);
  944. int (*add_dai_link)(struct snd_soc_card *,
  945. struct snd_soc_dai_link *link);
  946. void (*remove_dai_link)(struct snd_soc_card *,
  947. struct snd_soc_dai_link *link);
  948. long pmdown_time;
  949. /* CPU <--> Codec DAI links */
  950. struct snd_soc_dai_link *dai_link; /* predefined links only */
  951. int num_links; /* predefined links only */
  952. struct list_head dai_link_list; /* all links */
  953. int num_dai_links;
  954. struct list_head rtd_list;
  955. int num_rtd;
  956. /* optional codec specific configuration */
  957. struct snd_soc_codec_conf *codec_conf;
  958. int num_configs;
  959. /*
  960. * optional auxiliary devices such as amplifiers or codecs with DAI
  961. * link unused
  962. */
  963. struct snd_soc_aux_dev *aux_dev;
  964. int num_aux_devs;
  965. struct list_head aux_comp_list;
  966. const struct snd_kcontrol_new *controls;
  967. int num_controls;
  968. /*
  969. * Card-specific routes and widgets.
  970. * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
  971. */
  972. const struct snd_soc_dapm_widget *dapm_widgets;
  973. int num_dapm_widgets;
  974. const struct snd_soc_dapm_route *dapm_routes;
  975. int num_dapm_routes;
  976. const struct snd_soc_dapm_widget *of_dapm_widgets;
  977. int num_of_dapm_widgets;
  978. const struct snd_soc_dapm_route *of_dapm_routes;
  979. int num_of_dapm_routes;
  980. bool fully_routed;
  981. struct work_struct deferred_resume_work;
  982. /* lists of probed devices belonging to this card */
  983. struct list_head component_dev_list;
  984. struct list_head widgets;
  985. struct list_head paths;
  986. struct list_head dapm_list;
  987. struct list_head dapm_dirty;
  988. /* attached dynamic objects */
  989. struct list_head dobj_list;
  990. /* Generic DAPM context for the card */
  991. struct snd_soc_dapm_context dapm;
  992. struct snd_soc_dapm_stats dapm_stats;
  993. struct snd_soc_dapm_update *update;
  994. #ifdef CONFIG_DEBUG_FS
  995. struct dentry *debugfs_card_root;
  996. struct dentry *debugfs_pop_time;
  997. #endif
  998. u32 pop_time;
  999. void *drvdata;
  1000. };
  1001. /* SoC machine DAI configuration, glues a codec and cpu DAI together */
  1002. struct snd_soc_pcm_runtime {
  1003. struct device *dev;
  1004. struct snd_soc_card *card;
  1005. struct snd_soc_dai_link *dai_link;
  1006. struct mutex pcm_mutex;
  1007. enum snd_soc_pcm_subclass pcm_subclass;
  1008. struct snd_pcm_ops ops;
  1009. /* Dynamic PCM BE runtime data */
  1010. struct snd_soc_dpcm_runtime dpcm[2];
  1011. int fe_compr;
  1012. long pmdown_time;
  1013. /* runtime devices */
  1014. struct snd_pcm *pcm;
  1015. struct snd_compr *compr;
  1016. struct snd_soc_dai *codec_dai;
  1017. struct snd_soc_dai *cpu_dai;
  1018. struct snd_soc_dai **codec_dais;
  1019. unsigned int num_codecs;
  1020. struct delayed_work delayed_work;
  1021. #ifdef CONFIG_DEBUG_FS
  1022. struct dentry *debugfs_dpcm_root;
  1023. #endif
  1024. unsigned int num; /* 0-based and monotonic increasing */
  1025. struct list_head list; /* rtd list of the soc card */
  1026. struct list_head component_list; /* list of connected components */
  1027. /* bit field */
  1028. unsigned int dev_registered:1;
  1029. unsigned int pop_wait:1;
  1030. };
  1031. /* mixer control */
  1032. struct soc_mixer_control {
  1033. int min, max, platform_max;
  1034. int reg, rreg;
  1035. unsigned int shift, rshift;
  1036. unsigned int sign_bit;
  1037. unsigned int invert:1;
  1038. unsigned int autodisable:1;
  1039. struct snd_soc_dobj dobj;
  1040. };
  1041. struct soc_bytes {
  1042. int base;
  1043. int num_regs;
  1044. u32 mask;
  1045. };
  1046. struct soc_bytes_ext {
  1047. int max;
  1048. struct snd_soc_dobj dobj;
  1049. /* used for TLV byte control */
  1050. int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
  1051. unsigned int size);
  1052. int (*put)(struct snd_kcontrol *kcontrol, const unsigned int __user *bytes,
  1053. unsigned int size);
  1054. };
  1055. /* multi register control */
  1056. struct soc_mreg_control {
  1057. long min, max;
  1058. unsigned int regbase, regcount, nbits, invert;
  1059. };
  1060. /* enumerated kcontrol */
  1061. struct soc_enum {
  1062. int reg;
  1063. unsigned char shift_l;
  1064. unsigned char shift_r;
  1065. unsigned int items;
  1066. unsigned int mask;
  1067. const char * const *texts;
  1068. const unsigned int *values;
  1069. unsigned int autodisable:1;
  1070. struct snd_soc_dobj dobj;
  1071. };
  1072. /**
  1073. * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
  1074. * embedded in
  1075. * @dapm: The DAPM context to cast to the component
  1076. *
  1077. * This function must only be used on DAPM contexts that are known to be part of
  1078. * a component (e.g. in a component driver). Otherwise the behavior is
  1079. * undefined.
  1080. */
  1081. static inline struct snd_soc_component *snd_soc_dapm_to_component(
  1082. struct snd_soc_dapm_context *dapm)
  1083. {
  1084. return container_of(dapm, struct snd_soc_component, dapm);
  1085. }
  1086. /**
  1087. * snd_soc_component_get_dapm() - Returns the DAPM context associated with a
  1088. * component
  1089. * @component: The component for which to get the DAPM context
  1090. */
  1091. static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
  1092. struct snd_soc_component *component)
  1093. {
  1094. return &component->dapm;
  1095. }
  1096. /**
  1097. * snd_soc_component_init_bias_level() - Initialize COMPONENT DAPM bias level
  1098. * @component: The COMPONENT for which to initialize the DAPM bias level
  1099. * @level: The DAPM level to initialize to
  1100. *
  1101. * Initializes the COMPONENT DAPM bias level. See snd_soc_dapm_init_bias_level().
  1102. */
  1103. static inline void
  1104. snd_soc_component_init_bias_level(struct snd_soc_component *component,
  1105. enum snd_soc_bias_level level)
  1106. {
  1107. snd_soc_dapm_init_bias_level(
  1108. snd_soc_component_get_dapm(component), level);
  1109. }
  1110. /**
  1111. * snd_soc_component_get_bias_level() - Get current COMPONENT DAPM bias level
  1112. * @component: The COMPONENT for which to get the DAPM bias level
  1113. *
  1114. * Returns: The current DAPM bias level of the COMPONENT.
  1115. */
  1116. static inline enum snd_soc_bias_level
  1117. snd_soc_component_get_bias_level(struct snd_soc_component *component)
  1118. {
  1119. return snd_soc_dapm_get_bias_level(
  1120. snd_soc_component_get_dapm(component));
  1121. }
  1122. /**
  1123. * snd_soc_component_force_bias_level() - Set the COMPONENT DAPM bias level
  1124. * @component: The COMPONENT for which to set the level
  1125. * @level: The level to set to
  1126. *
  1127. * Forces the COMPONENT bias level to a specific state. See
  1128. * snd_soc_dapm_force_bias_level().
  1129. */
  1130. static inline int
  1131. snd_soc_component_force_bias_level(struct snd_soc_component *component,
  1132. enum snd_soc_bias_level level)
  1133. {
  1134. return snd_soc_dapm_force_bias_level(
  1135. snd_soc_component_get_dapm(component),
  1136. level);
  1137. }
  1138. /**
  1139. * snd_soc_dapm_kcontrol_component() - Returns the component associated to a kcontrol
  1140. * @kcontrol: The kcontrol
  1141. *
  1142. * This function must only be used on DAPM contexts that are known to be part of
  1143. * a COMPONENT (e.g. in a COMPONENT driver). Otherwise the behavior is undefined.
  1144. */
  1145. static inline struct snd_soc_component *snd_soc_dapm_kcontrol_component(
  1146. struct snd_kcontrol *kcontrol)
  1147. {
  1148. return snd_soc_dapm_to_component(snd_soc_dapm_kcontrol_dapm(kcontrol));
  1149. }
  1150. /**
  1151. * snd_soc_component_cache_sync() - Sync the register cache with the hardware
  1152. * @component: COMPONENT to sync
  1153. *
  1154. * Note: This function will call regcache_sync()
  1155. */
  1156. static inline int snd_soc_component_cache_sync(
  1157. struct snd_soc_component *component)
  1158. {
  1159. return regcache_sync(component->regmap);
  1160. }
  1161. /* component IO */
  1162. int snd_soc_component_read(struct snd_soc_component *component,
  1163. unsigned int reg, unsigned int *val);
  1164. unsigned int snd_soc_component_read32(struct snd_soc_component *component,
  1165. unsigned int reg);
  1166. int snd_soc_component_write(struct snd_soc_component *component,
  1167. unsigned int reg, unsigned int val);
  1168. int snd_soc_component_update_bits(struct snd_soc_component *component,
  1169. unsigned int reg, unsigned int mask, unsigned int val);
  1170. int snd_soc_component_update_bits_async(struct snd_soc_component *component,
  1171. unsigned int reg, unsigned int mask, unsigned int val);
  1172. void snd_soc_component_async_complete(struct snd_soc_component *component);
  1173. int snd_soc_component_test_bits(struct snd_soc_component *component,
  1174. unsigned int reg, unsigned int mask, unsigned int value);
  1175. /* component wide operations */
  1176. int snd_soc_component_set_sysclk(struct snd_soc_component *component,
  1177. int clk_id, int source, unsigned int freq, int dir);
  1178. int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
  1179. int source, unsigned int freq_in,
  1180. unsigned int freq_out);
  1181. int snd_soc_component_set_jack(struct snd_soc_component *component,
  1182. struct snd_soc_jack *jack, void *data);
  1183. #ifdef CONFIG_REGMAP
  1184. void snd_soc_component_init_regmap(struct snd_soc_component *component,
  1185. struct regmap *regmap);
  1186. void snd_soc_component_exit_regmap(struct snd_soc_component *component);
  1187. #endif
  1188. /* device driver data */
  1189. static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
  1190. void *data)
  1191. {
  1192. card->drvdata = data;
  1193. }
  1194. static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
  1195. {
  1196. return card->drvdata;
  1197. }
  1198. static inline void snd_soc_component_set_drvdata(struct snd_soc_component *c,
  1199. void *data)
  1200. {
  1201. dev_set_drvdata(c->dev, data);
  1202. }
  1203. static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c)
  1204. {
  1205. return dev_get_drvdata(c->dev);
  1206. }
  1207. static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
  1208. {
  1209. INIT_LIST_HEAD(&card->widgets);
  1210. INIT_LIST_HEAD(&card->paths);
  1211. INIT_LIST_HEAD(&card->dapm_list);
  1212. INIT_LIST_HEAD(&card->aux_comp_list);
  1213. INIT_LIST_HEAD(&card->component_dev_list);
  1214. }
  1215. static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
  1216. {
  1217. if (mc->reg == mc->rreg && mc->shift == mc->rshift)
  1218. return 0;
  1219. /*
  1220. * mc->reg == mc->rreg && mc->shift != mc->rshift, or
  1221. * mc->reg != mc->rreg means that the control is
  1222. * stereo (bits in one register or in two registers)
  1223. */
  1224. return 1;
  1225. }
  1226. static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
  1227. unsigned int val)
  1228. {
  1229. unsigned int i;
  1230. if (!e->values)
  1231. return val;
  1232. for (i = 0; i < e->items; i++)
  1233. if (val == e->values[i])
  1234. return i;
  1235. return 0;
  1236. }
  1237. static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
  1238. unsigned int item)
  1239. {
  1240. if (!e->values)
  1241. return item;
  1242. return e->values[item];
  1243. }
  1244. static inline bool snd_soc_component_is_active(
  1245. struct snd_soc_component *component)
  1246. {
  1247. return component->active != 0;
  1248. }
  1249. /**
  1250. * snd_soc_kcontrol_component() - Returns the component that registered the
  1251. * control
  1252. * @kcontrol: The control for which to get the component
  1253. *
  1254. * Note: This function will work correctly if the control has been registered
  1255. * for a component. With snd_soc_add_codec_controls() or via table based
  1256. * setup for either a CODEC or component driver. Otherwise the behavior is
  1257. * undefined.
  1258. */
  1259. static inline struct snd_soc_component *snd_soc_kcontrol_component(
  1260. struct snd_kcontrol *kcontrol)
  1261. {
  1262. return snd_kcontrol_chip(kcontrol);
  1263. }
  1264. int snd_soc_util_init(void);
  1265. void snd_soc_util_exit(void);
  1266. int snd_soc_of_parse_card_name(struct snd_soc_card *card,
  1267. const char *propname);
  1268. int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
  1269. const char *propname);
  1270. int snd_soc_of_get_slot_mask(struct device_node *np,
  1271. const char *prop_name,
  1272. unsigned int *mask);
  1273. int snd_soc_of_parse_tdm_slot(struct device_node *np,
  1274. unsigned int *tx_mask,
  1275. unsigned int *rx_mask,
  1276. unsigned int *slots,
  1277. unsigned int *slot_width);
  1278. void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
  1279. struct snd_soc_codec_conf *codec_conf,
  1280. struct device_node *of_node,
  1281. const char *propname);
  1282. int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
  1283. const char *propname);
  1284. unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
  1285. const char *prefix,
  1286. struct device_node **bitclkmaster,
  1287. struct device_node **framemaster);
  1288. int snd_soc_get_dai_id(struct device_node *ep);
  1289. int snd_soc_get_dai_name(struct of_phandle_args *args,
  1290. const char **dai_name);
  1291. int snd_soc_of_get_dai_name(struct device_node *of_node,
  1292. const char **dai_name);
  1293. int snd_soc_of_get_dai_link_codecs(struct device *dev,
  1294. struct device_node *of_node,
  1295. struct snd_soc_dai_link *dai_link);
  1296. void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
  1297. int snd_soc_add_dai_link(struct snd_soc_card *card,
  1298. struct snd_soc_dai_link *dai_link);
  1299. void snd_soc_remove_dai_link(struct snd_soc_card *card,
  1300. struct snd_soc_dai_link *dai_link);
  1301. struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,
  1302. int id, const char *name,
  1303. const char *stream_name);
  1304. int snd_soc_register_dai(struct snd_soc_component *component,
  1305. struct snd_soc_dai_driver *dai_drv);
  1306. struct snd_soc_dai *snd_soc_find_dai(
  1307. const struct snd_soc_dai_link_component *dlc);
  1308. #include <sound/soc-dai.h>
  1309. static inline
  1310. struct snd_soc_dai *snd_soc_card_get_codec_dai(struct snd_soc_card *card,
  1311. const char *dai_name)
  1312. {
  1313. struct snd_soc_pcm_runtime *rtd;
  1314. list_for_each_entry(rtd, &card->rtd_list, list) {
  1315. if (!strcmp(rtd->codec_dai->name, dai_name))
  1316. return rtd->codec_dai;
  1317. }
  1318. return NULL;
  1319. }
  1320. #ifdef CONFIG_DEBUG_FS
  1321. extern struct dentry *snd_soc_debugfs_root;
  1322. #endif
  1323. extern const struct dev_pm_ops snd_soc_pm_ops;
  1324. /* Helper functions */
  1325. static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm)
  1326. {
  1327. mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
  1328. }
  1329. static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
  1330. {
  1331. mutex_unlock(&dapm->card->dapm_mutex);
  1332. }
  1333. int snd_soc_component_enable_pin(struct snd_soc_component *component,
  1334. const char *pin);
  1335. int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
  1336. const char *pin);
  1337. int snd_soc_component_disable_pin(struct snd_soc_component *component,
  1338. const char *pin);
  1339. int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
  1340. const char *pin);
  1341. int snd_soc_component_nc_pin(struct snd_soc_component *component,
  1342. const char *pin);
  1343. int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
  1344. const char *pin);
  1345. int snd_soc_component_get_pin_status(struct snd_soc_component *component,
  1346. const char *pin);
  1347. int snd_soc_component_force_enable_pin(struct snd_soc_component *component,
  1348. const char *pin);
  1349. int snd_soc_component_force_enable_pin_unlocked(
  1350. struct snd_soc_component *component,
  1351. const char *pin);
  1352. #endif