soc.h 51 KB

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