soc.h 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544
  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. #ifdef CONFIG_SND_SOC_AC97_BUS
  519. struct snd_ac97 *snd_soc_alloc_ac97_component(struct snd_soc_component *component);
  520. struct snd_ac97 *snd_soc_new_ac97_component(struct snd_soc_component *component,
  521. unsigned int id, unsigned int id_mask);
  522. void snd_soc_free_ac97_component(struct snd_ac97 *ac97);
  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. };
  758. struct snd_soc_component {
  759. const char *name;
  760. int id;
  761. const char *name_prefix;
  762. struct device *dev;
  763. struct snd_soc_card *card;
  764. unsigned int active;
  765. unsigned int suspended:1; /* is in suspend PM state */
  766. struct list_head list;
  767. struct list_head card_aux_list; /* for auxiliary bound components */
  768. struct list_head card_list;
  769. const struct snd_soc_component_driver *driver;
  770. struct list_head dai_list;
  771. int num_dai;
  772. struct regmap *regmap;
  773. int val_bytes;
  774. struct mutex io_mutex;
  775. /* attached dynamic objects */
  776. struct list_head dobj_list;
  777. /*
  778. * DO NOT use any of the fields below in drivers, they are temporary and
  779. * are going to be removed again soon. If you use them in driver code the
  780. * driver will be marked as BROKEN when these fields are removed.
  781. */
  782. /* Don't use these, use snd_soc_component_get_dapm() */
  783. struct snd_soc_dapm_context dapm;
  784. /* machine specific init */
  785. int (*init)(struct snd_soc_component *component);
  786. #ifdef CONFIG_DEBUG_FS
  787. struct dentry *debugfs_root;
  788. const char *debugfs_prefix;
  789. #endif
  790. };
  791. struct snd_soc_rtdcom_list {
  792. struct snd_soc_component *component;
  793. struct list_head list; /* rtd::component_list */
  794. };
  795. struct snd_soc_component*
  796. snd_soc_rtdcom_lookup(struct snd_soc_pcm_runtime *rtd,
  797. const char *driver_name);
  798. #define for_each_rtdcom(rtd, rtdcom) \
  799. list_for_each_entry(rtdcom, &(rtd)->component_list, list)
  800. #define for_each_rtdcom_safe(rtd, rtdcom1, rtdcom2) \
  801. list_for_each_entry_safe(rtdcom1, rtdcom2, &(rtd)->component_list, list)
  802. struct snd_soc_dai_link_component {
  803. const char *name;
  804. struct device_node *of_node;
  805. const char *dai_name;
  806. };
  807. struct snd_soc_dai_link {
  808. /* config - must be set by machine driver */
  809. const char *name; /* Codec name */
  810. const char *stream_name; /* Stream name */
  811. /*
  812. * You MAY specify the link's CPU-side device, either by device name,
  813. * or by DT/OF node, but not both. If this information is omitted,
  814. * the CPU-side DAI is matched using .cpu_dai_name only, which hence
  815. * must be globally unique. These fields are currently typically used
  816. * only for codec to codec links, or systems using device tree.
  817. */
  818. const char *cpu_name;
  819. struct device_node *cpu_of_node;
  820. /*
  821. * You MAY specify the DAI name of the CPU DAI. If this information is
  822. * omitted, the CPU-side DAI is matched using .cpu_name/.cpu_of_node
  823. * only, which only works well when that device exposes a single DAI.
  824. */
  825. const char *cpu_dai_name;
  826. /*
  827. * You MUST specify the link's codec, either by device name, or by
  828. * DT/OF node, but not both.
  829. */
  830. const char *codec_name;
  831. struct device_node *codec_of_node;
  832. /* You MUST specify the DAI name within the codec */
  833. const char *codec_dai_name;
  834. struct snd_soc_dai_link_component *codecs;
  835. unsigned int num_codecs;
  836. /*
  837. * You MAY specify the link's platform/PCM/DMA driver, either by
  838. * device name, or by DT/OF node, but not both. Some forms of link
  839. * do not need a platform.
  840. */
  841. const char *platform_name;
  842. struct device_node *platform_of_node;
  843. struct snd_soc_dai_link_component *platform;
  844. int id; /* optional ID for machine driver link identification */
  845. const struct snd_soc_pcm_stream *params;
  846. unsigned int num_params;
  847. unsigned int dai_fmt; /* format to set on init */
  848. enum snd_soc_dpcm_trigger trigger[2]; /* trigger type for DPCM */
  849. /* codec/machine specific init - e.g. add machine controls */
  850. int (*init)(struct snd_soc_pcm_runtime *rtd);
  851. /* optional hw_params re-writing for BE and FE sync */
  852. int (*be_hw_params_fixup)(struct snd_soc_pcm_runtime *rtd,
  853. struct snd_pcm_hw_params *params);
  854. /* machine stream operations */
  855. const struct snd_soc_ops *ops;
  856. const struct snd_soc_compr_ops *compr_ops;
  857. /* Mark this pcm with non atomic ops */
  858. bool nonatomic;
  859. /* For unidirectional dai links */
  860. unsigned int playback_only:1;
  861. unsigned int capture_only:1;
  862. /* Keep DAI active over suspend */
  863. unsigned int ignore_suspend:1;
  864. /* Symmetry requirements */
  865. unsigned int symmetric_rates:1;
  866. unsigned int symmetric_channels:1;
  867. unsigned int symmetric_samplebits:1;
  868. /* Do not create a PCM for this DAI link (Backend link) */
  869. unsigned int no_pcm:1;
  870. /* This DAI link can route to other DAI links at runtime (Frontend)*/
  871. unsigned int dynamic:1;
  872. /* DPCM capture and Playback support */
  873. unsigned int dpcm_capture:1;
  874. unsigned int dpcm_playback:1;
  875. /* DPCM used FE & BE merged format */
  876. unsigned int dpcm_merged_format:1;
  877. /* DPCM used FE & BE merged channel */
  878. unsigned int dpcm_merged_chan:1;
  879. /* DPCM used FE & BE merged rate */
  880. unsigned int dpcm_merged_rate:1;
  881. /* pmdown_time is ignored at stop */
  882. unsigned int ignore_pmdown_time:1;
  883. /* Do not create a PCM for this DAI link (Backend link) */
  884. unsigned int ignore:1;
  885. struct list_head list; /* DAI link list of the soc card */
  886. struct snd_soc_dobj dobj; /* For topology */
  887. };
  888. #define for_each_link_codecs(link, i, codec) \
  889. for ((i) = 0; \
  890. ((i) < link->num_codecs) && ((codec) = &link->codecs[i]); \
  891. (i)++)
  892. struct snd_soc_codec_conf {
  893. /*
  894. * specify device either by device name, or by
  895. * DT/OF node, but not both.
  896. */
  897. const char *dev_name;
  898. struct device_node *of_node;
  899. /*
  900. * optional map of kcontrol, widget and path name prefixes that are
  901. * associated per device
  902. */
  903. const char *name_prefix;
  904. };
  905. struct snd_soc_aux_dev {
  906. const char *name; /* Codec name */
  907. /*
  908. * specify multi-codec either by device name, or by
  909. * DT/OF node, but not both.
  910. */
  911. const char *codec_name;
  912. struct device_node *codec_of_node;
  913. /* codec/machine specific init - e.g. add machine controls */
  914. int (*init)(struct snd_soc_component *component);
  915. };
  916. /* SoC card */
  917. struct snd_soc_card {
  918. const char *name;
  919. const char *long_name;
  920. const char *driver_name;
  921. char dmi_longname[80];
  922. char topology_shortname[32];
  923. struct device *dev;
  924. struct snd_card *snd_card;
  925. struct module *owner;
  926. struct mutex mutex;
  927. struct mutex dapm_mutex;
  928. bool instantiated;
  929. bool topology_shortname_created;
  930. int (*probe)(struct snd_soc_card *card);
  931. int (*late_probe)(struct snd_soc_card *card);
  932. int (*remove)(struct snd_soc_card *card);
  933. /* the pre and post PM functions are used to do any PM work before and
  934. * after the codec and DAI's do any PM work. */
  935. int (*suspend_pre)(struct snd_soc_card *card);
  936. int (*suspend_post)(struct snd_soc_card *card);
  937. int (*resume_pre)(struct snd_soc_card *card);
  938. int (*resume_post)(struct snd_soc_card *card);
  939. /* callbacks */
  940. int (*set_bias_level)(struct snd_soc_card *,
  941. struct snd_soc_dapm_context *dapm,
  942. enum snd_soc_bias_level level);
  943. int (*set_bias_level_post)(struct snd_soc_card *,
  944. struct snd_soc_dapm_context *dapm,
  945. enum snd_soc_bias_level level);
  946. int (*add_dai_link)(struct snd_soc_card *,
  947. struct snd_soc_dai_link *link);
  948. void (*remove_dai_link)(struct snd_soc_card *,
  949. struct snd_soc_dai_link *link);
  950. long pmdown_time;
  951. /* CPU <--> Codec DAI links */
  952. struct snd_soc_dai_link *dai_link; /* predefined links only */
  953. int num_links; /* predefined links only */
  954. struct list_head dai_link_list; /* all links */
  955. struct list_head rtd_list;
  956. int num_rtd;
  957. /* optional codec specific configuration */
  958. struct snd_soc_codec_conf *codec_conf;
  959. int num_configs;
  960. /*
  961. * optional auxiliary devices such as amplifiers or codecs with DAI
  962. * link unused
  963. */
  964. struct snd_soc_aux_dev *aux_dev;
  965. int num_aux_devs;
  966. struct list_head aux_comp_list;
  967. const struct snd_kcontrol_new *controls;
  968. int num_controls;
  969. /*
  970. * Card-specific routes and widgets.
  971. * Note: of_dapm_xxx for Device Tree; Otherwise for driver build-in.
  972. */
  973. const struct snd_soc_dapm_widget *dapm_widgets;
  974. int num_dapm_widgets;
  975. const struct snd_soc_dapm_route *dapm_routes;
  976. int num_dapm_routes;
  977. const struct snd_soc_dapm_widget *of_dapm_widgets;
  978. int num_of_dapm_widgets;
  979. const struct snd_soc_dapm_route *of_dapm_routes;
  980. int num_of_dapm_routes;
  981. bool fully_routed;
  982. struct work_struct deferred_resume_work;
  983. /* lists of probed devices belonging to this card */
  984. struct list_head component_dev_list;
  985. struct list_head list;
  986. struct list_head widgets;
  987. struct list_head paths;
  988. struct list_head dapm_list;
  989. struct list_head dapm_dirty;
  990. /* attached dynamic objects */
  991. struct list_head dobj_list;
  992. /* Generic DAPM context for the card */
  993. struct snd_soc_dapm_context dapm;
  994. struct snd_soc_dapm_stats dapm_stats;
  995. struct snd_soc_dapm_update *update;
  996. #ifdef CONFIG_DEBUG_FS
  997. struct dentry *debugfs_card_root;
  998. struct dentry *debugfs_pop_time;
  999. #endif
  1000. u32 pop_time;
  1001. void *drvdata;
  1002. };
  1003. #define for_each_card_prelinks(card, i, link) \
  1004. for ((i) = 0; \
  1005. ((i) < (card)->num_links) && ((link) = &(card)->dai_link[i]); \
  1006. (i)++)
  1007. /* SoC machine DAI configuration, glues a codec and cpu DAI together */
  1008. struct snd_soc_pcm_runtime {
  1009. struct device *dev;
  1010. struct snd_soc_card *card;
  1011. struct snd_soc_dai_link *dai_link;
  1012. struct mutex pcm_mutex;
  1013. enum snd_soc_pcm_subclass pcm_subclass;
  1014. struct snd_pcm_ops ops;
  1015. unsigned int params_select; /* currently selected param for dai link */
  1016. /* Dynamic PCM BE runtime data */
  1017. struct snd_soc_dpcm_runtime dpcm[2];
  1018. int fe_compr;
  1019. long pmdown_time;
  1020. /* runtime devices */
  1021. struct snd_pcm *pcm;
  1022. struct snd_compr *compr;
  1023. struct snd_soc_dai *codec_dai;
  1024. struct snd_soc_dai *cpu_dai;
  1025. struct snd_soc_dai **codec_dais;
  1026. unsigned int num_codecs;
  1027. struct delayed_work delayed_work;
  1028. #ifdef CONFIG_DEBUG_FS
  1029. struct dentry *debugfs_dpcm_root;
  1030. #endif
  1031. unsigned int num; /* 0-based and monotonic increasing */
  1032. struct list_head list; /* rtd list of the soc card */
  1033. struct list_head component_list; /* list of connected components */
  1034. /* bit field */
  1035. unsigned int dev_registered:1;
  1036. unsigned int pop_wait:1;
  1037. };
  1038. #define for_each_rtd_codec_dai(rtd, i, dai)\
  1039. for ((i) = 0; \
  1040. ((i) < rtd->num_codecs) && ((dai) = rtd->codec_dais[i]); \
  1041. (i)++)
  1042. #define for_each_rtd_codec_dai_rollback(rtd, i, dai) \
  1043. for (; ((i--) >= 0) && ((dai) = rtd->codec_dais[i]);)
  1044. /* mixer control */
  1045. struct soc_mixer_control {
  1046. int min, max, platform_max;
  1047. int reg, rreg;
  1048. unsigned int shift, rshift;
  1049. unsigned int sign_bit;
  1050. unsigned int invert:1;
  1051. unsigned int autodisable:1;
  1052. struct snd_soc_dobj dobj;
  1053. };
  1054. struct soc_bytes {
  1055. int base;
  1056. int num_regs;
  1057. u32 mask;
  1058. };
  1059. struct soc_bytes_ext {
  1060. int max;
  1061. struct snd_soc_dobj dobj;
  1062. /* used for TLV byte control */
  1063. int (*get)(struct snd_kcontrol *kcontrol, unsigned int __user *bytes,
  1064. unsigned int size);
  1065. int (*put)(struct snd_kcontrol *kcontrol, const unsigned int __user *bytes,
  1066. unsigned int size);
  1067. };
  1068. /* multi register control */
  1069. struct soc_mreg_control {
  1070. long min, max;
  1071. unsigned int regbase, regcount, nbits, invert;
  1072. };
  1073. /* enumerated kcontrol */
  1074. struct soc_enum {
  1075. int reg;
  1076. unsigned char shift_l;
  1077. unsigned char shift_r;
  1078. unsigned int items;
  1079. unsigned int mask;
  1080. const char * const *texts;
  1081. const unsigned int *values;
  1082. unsigned int autodisable:1;
  1083. struct snd_soc_dobj dobj;
  1084. };
  1085. /**
  1086. * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is
  1087. * embedded in
  1088. * @dapm: The DAPM context to cast to the component
  1089. *
  1090. * This function must only be used on DAPM contexts that are known to be part of
  1091. * a component (e.g. in a component driver). Otherwise the behavior is
  1092. * undefined.
  1093. */
  1094. static inline struct snd_soc_component *snd_soc_dapm_to_component(
  1095. struct snd_soc_dapm_context *dapm)
  1096. {
  1097. return container_of(dapm, struct snd_soc_component, dapm);
  1098. }
  1099. /**
  1100. * snd_soc_component_get_dapm() - Returns the DAPM context associated with a
  1101. * component
  1102. * @component: The component for which to get the DAPM context
  1103. */
  1104. static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm(
  1105. struct snd_soc_component *component)
  1106. {
  1107. return &component->dapm;
  1108. }
  1109. /**
  1110. * snd_soc_component_init_bias_level() - Initialize COMPONENT DAPM bias level
  1111. * @component: The COMPONENT for which to initialize the DAPM bias level
  1112. * @level: The DAPM level to initialize to
  1113. *
  1114. * Initializes the COMPONENT DAPM bias level. See snd_soc_dapm_init_bias_level().
  1115. */
  1116. static inline void
  1117. snd_soc_component_init_bias_level(struct snd_soc_component *component,
  1118. enum snd_soc_bias_level level)
  1119. {
  1120. snd_soc_dapm_init_bias_level(
  1121. snd_soc_component_get_dapm(component), level);
  1122. }
  1123. /**
  1124. * snd_soc_component_get_bias_level() - Get current COMPONENT DAPM bias level
  1125. * @component: The COMPONENT for which to get the DAPM bias level
  1126. *
  1127. * Returns: The current DAPM bias level of the COMPONENT.
  1128. */
  1129. static inline enum snd_soc_bias_level
  1130. snd_soc_component_get_bias_level(struct snd_soc_component *component)
  1131. {
  1132. return snd_soc_dapm_get_bias_level(
  1133. snd_soc_component_get_dapm(component));
  1134. }
  1135. /**
  1136. * snd_soc_component_force_bias_level() - Set the COMPONENT DAPM bias level
  1137. * @component: The COMPONENT for which to set the level
  1138. * @level: The level to set to
  1139. *
  1140. * Forces the COMPONENT bias level to a specific state. See
  1141. * snd_soc_dapm_force_bias_level().
  1142. */
  1143. static inline int
  1144. snd_soc_component_force_bias_level(struct snd_soc_component *component,
  1145. enum snd_soc_bias_level level)
  1146. {
  1147. return snd_soc_dapm_force_bias_level(
  1148. snd_soc_component_get_dapm(component),
  1149. level);
  1150. }
  1151. /**
  1152. * snd_soc_dapm_kcontrol_component() - Returns the component associated to a kcontrol
  1153. * @kcontrol: The kcontrol
  1154. *
  1155. * This function must only be used on DAPM contexts that are known to be part of
  1156. * a COMPONENT (e.g. in a COMPONENT driver). Otherwise the behavior is undefined.
  1157. */
  1158. static inline struct snd_soc_component *snd_soc_dapm_kcontrol_component(
  1159. struct snd_kcontrol *kcontrol)
  1160. {
  1161. return snd_soc_dapm_to_component(snd_soc_dapm_kcontrol_dapm(kcontrol));
  1162. }
  1163. /**
  1164. * snd_soc_component_cache_sync() - Sync the register cache with the hardware
  1165. * @component: COMPONENT to sync
  1166. *
  1167. * Note: This function will call regcache_sync()
  1168. */
  1169. static inline int snd_soc_component_cache_sync(
  1170. struct snd_soc_component *component)
  1171. {
  1172. return regcache_sync(component->regmap);
  1173. }
  1174. /* component IO */
  1175. int snd_soc_component_read(struct snd_soc_component *component,
  1176. unsigned int reg, unsigned int *val);
  1177. unsigned int snd_soc_component_read32(struct snd_soc_component *component,
  1178. unsigned int reg);
  1179. int snd_soc_component_write(struct snd_soc_component *component,
  1180. unsigned int reg, unsigned int val);
  1181. int snd_soc_component_update_bits(struct snd_soc_component *component,
  1182. unsigned int reg, unsigned int mask, unsigned int val);
  1183. int snd_soc_component_update_bits_async(struct snd_soc_component *component,
  1184. unsigned int reg, unsigned int mask, unsigned int val);
  1185. void snd_soc_component_async_complete(struct snd_soc_component *component);
  1186. int snd_soc_component_test_bits(struct snd_soc_component *component,
  1187. unsigned int reg, unsigned int mask, unsigned int value);
  1188. /* component wide operations */
  1189. int snd_soc_component_set_sysclk(struct snd_soc_component *component,
  1190. int clk_id, int source, unsigned int freq, int dir);
  1191. int snd_soc_component_set_pll(struct snd_soc_component *component, int pll_id,
  1192. int source, unsigned int freq_in,
  1193. unsigned int freq_out);
  1194. int snd_soc_component_set_jack(struct snd_soc_component *component,
  1195. struct snd_soc_jack *jack, void *data);
  1196. #ifdef CONFIG_REGMAP
  1197. void snd_soc_component_init_regmap(struct snd_soc_component *component,
  1198. struct regmap *regmap);
  1199. void snd_soc_component_exit_regmap(struct snd_soc_component *component);
  1200. #endif
  1201. /* device driver data */
  1202. static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
  1203. void *data)
  1204. {
  1205. card->drvdata = data;
  1206. }
  1207. static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
  1208. {
  1209. return card->drvdata;
  1210. }
  1211. static inline void snd_soc_component_set_drvdata(struct snd_soc_component *c,
  1212. void *data)
  1213. {
  1214. dev_set_drvdata(c->dev, data);
  1215. }
  1216. static inline void *snd_soc_component_get_drvdata(struct snd_soc_component *c)
  1217. {
  1218. return dev_get_drvdata(c->dev);
  1219. }
  1220. static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
  1221. {
  1222. INIT_LIST_HEAD(&card->widgets);
  1223. INIT_LIST_HEAD(&card->paths);
  1224. INIT_LIST_HEAD(&card->dapm_list);
  1225. INIT_LIST_HEAD(&card->aux_comp_list);
  1226. INIT_LIST_HEAD(&card->component_dev_list);
  1227. INIT_LIST_HEAD(&card->list);
  1228. }
  1229. static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
  1230. {
  1231. if (mc->reg == mc->rreg && mc->shift == mc->rshift)
  1232. return 0;
  1233. /*
  1234. * mc->reg == mc->rreg && mc->shift != mc->rshift, or
  1235. * mc->reg != mc->rreg means that the control is
  1236. * stereo (bits in one register or in two registers)
  1237. */
  1238. return 1;
  1239. }
  1240. static inline unsigned int snd_soc_enum_val_to_item(struct soc_enum *e,
  1241. unsigned int val)
  1242. {
  1243. unsigned int i;
  1244. if (!e->values)
  1245. return val;
  1246. for (i = 0; i < e->items; i++)
  1247. if (val == e->values[i])
  1248. return i;
  1249. return 0;
  1250. }
  1251. static inline unsigned int snd_soc_enum_item_to_val(struct soc_enum *e,
  1252. unsigned int item)
  1253. {
  1254. if (!e->values)
  1255. return item;
  1256. return e->values[item];
  1257. }
  1258. static inline bool snd_soc_component_is_active(
  1259. struct snd_soc_component *component)
  1260. {
  1261. return component->active != 0;
  1262. }
  1263. /**
  1264. * snd_soc_kcontrol_component() - Returns the component that registered the
  1265. * control
  1266. * @kcontrol: The control for which to get the component
  1267. *
  1268. * Note: This function will work correctly if the control has been registered
  1269. * for a component. With snd_soc_add_codec_controls() or via table based
  1270. * setup for either a CODEC or component driver. Otherwise the behavior is
  1271. * undefined.
  1272. */
  1273. static inline struct snd_soc_component *snd_soc_kcontrol_component(
  1274. struct snd_kcontrol *kcontrol)
  1275. {
  1276. return snd_kcontrol_chip(kcontrol);
  1277. }
  1278. int snd_soc_util_init(void);
  1279. void snd_soc_util_exit(void);
  1280. int snd_soc_of_parse_card_name(struct snd_soc_card *card,
  1281. const char *propname);
  1282. int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
  1283. const char *propname);
  1284. int snd_soc_of_get_slot_mask(struct device_node *np,
  1285. const char *prop_name,
  1286. unsigned int *mask);
  1287. int snd_soc_of_parse_tdm_slot(struct device_node *np,
  1288. unsigned int *tx_mask,
  1289. unsigned int *rx_mask,
  1290. unsigned int *slots,
  1291. unsigned int *slot_width);
  1292. void snd_soc_of_parse_audio_prefix(struct snd_soc_card *card,
  1293. struct snd_soc_codec_conf *codec_conf,
  1294. struct device_node *of_node,
  1295. const char *propname);
  1296. int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
  1297. const char *propname);
  1298. unsigned int snd_soc_of_parse_daifmt(struct device_node *np,
  1299. const char *prefix,
  1300. struct device_node **bitclkmaster,
  1301. struct device_node **framemaster);
  1302. int snd_soc_get_dai_id(struct device_node *ep);
  1303. int snd_soc_get_dai_name(struct of_phandle_args *args,
  1304. const char **dai_name);
  1305. int snd_soc_of_get_dai_name(struct device_node *of_node,
  1306. const char **dai_name);
  1307. int snd_soc_of_get_dai_link_codecs(struct device *dev,
  1308. struct device_node *of_node,
  1309. struct snd_soc_dai_link *dai_link);
  1310. void snd_soc_of_put_dai_link_codecs(struct snd_soc_dai_link *dai_link);
  1311. int snd_soc_add_dai_link(struct snd_soc_card *card,
  1312. struct snd_soc_dai_link *dai_link);
  1313. void snd_soc_remove_dai_link(struct snd_soc_card *card,
  1314. struct snd_soc_dai_link *dai_link);
  1315. struct snd_soc_dai_link *snd_soc_find_dai_link(struct snd_soc_card *card,
  1316. int id, const char *name,
  1317. const char *stream_name);
  1318. int snd_soc_register_dai(struct snd_soc_component *component,
  1319. struct snd_soc_dai_driver *dai_drv);
  1320. struct snd_soc_dai *snd_soc_find_dai(
  1321. const struct snd_soc_dai_link_component *dlc);
  1322. #include <sound/soc-dai.h>
  1323. static inline
  1324. struct snd_soc_dai *snd_soc_card_get_codec_dai(struct snd_soc_card *card,
  1325. const char *dai_name)
  1326. {
  1327. struct snd_soc_pcm_runtime *rtd;
  1328. list_for_each_entry(rtd, &card->rtd_list, list) {
  1329. if (!strcmp(rtd->codec_dai->name, dai_name))
  1330. return rtd->codec_dai;
  1331. }
  1332. return NULL;
  1333. }
  1334. #ifdef CONFIG_DEBUG_FS
  1335. extern struct dentry *snd_soc_debugfs_root;
  1336. #endif
  1337. extern const struct dev_pm_ops snd_soc_pm_ops;
  1338. /* Helper functions */
  1339. static inline void snd_soc_dapm_mutex_lock(struct snd_soc_dapm_context *dapm)
  1340. {
  1341. mutex_lock_nested(&dapm->card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME);
  1342. }
  1343. static inline void snd_soc_dapm_mutex_unlock(struct snd_soc_dapm_context *dapm)
  1344. {
  1345. mutex_unlock(&dapm->card->dapm_mutex);
  1346. }
  1347. int snd_soc_component_enable_pin(struct snd_soc_component *component,
  1348. const char *pin);
  1349. int snd_soc_component_enable_pin_unlocked(struct snd_soc_component *component,
  1350. const char *pin);
  1351. int snd_soc_component_disable_pin(struct snd_soc_component *component,
  1352. const char *pin);
  1353. int snd_soc_component_disable_pin_unlocked(struct snd_soc_component *component,
  1354. const char *pin);
  1355. int snd_soc_component_nc_pin(struct snd_soc_component *component,
  1356. const char *pin);
  1357. int snd_soc_component_nc_pin_unlocked(struct snd_soc_component *component,
  1358. const char *pin);
  1359. int snd_soc_component_get_pin_status(struct snd_soc_component *component,
  1360. const char *pin);
  1361. int snd_soc_component_force_enable_pin(struct snd_soc_component *component,
  1362. const char *pin);
  1363. int snd_soc_component_force_enable_pin_unlocked(
  1364. struct snd_soc_component *component,
  1365. const char *pin);
  1366. #endif