soc.h 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059
  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/platform_device.h>
  15. #include <linux/types.h>
  16. #include <linux/notifier.h>
  17. #include <linux/workqueue.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/kernel.h>
  20. #include <linux/regmap.h>
  21. #include <sound/core.h>
  22. #include <sound/pcm.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) \
  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})
  33. #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \
  34. SOC_DOUBLE_VALUE(xreg, xshift, xshift, xmax, xinvert)
  35. #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
  36. ((unsigned long)&(struct soc_mixer_control) \
  37. {.reg = xreg, .max = xmax, .platform_max = xmax, .invert = xinvert})
  38. #define SOC_DOUBLE_R_VALUE(xlreg, xrreg, xshift, xmax, xinvert) \
  39. ((unsigned long)&(struct soc_mixer_control) \
  40. {.reg = xlreg, .rreg = xrreg, .shift = xshift, .rshift = xshift, \
  41. .max = xmax, .platform_max = xmax, .invert = xinvert})
  42. #define SOC_SINGLE(xname, reg, shift, max, invert) \
  43. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  44. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
  45. .put = snd_soc_put_volsw, \
  46. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
  47. #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
  48. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  49. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  50. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  51. .tlv.p = (tlv_array), \
  52. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
  53. .put = snd_soc_put_volsw, \
  54. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
  55. #define SOC_SINGLE_SX_TLV(xname, xreg, xshift, xmin, xmax, tlv_array) \
  56. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  57. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  58. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  59. .tlv.p = (tlv_array),\
  60. .info = snd_soc_info_volsw, \
  61. .get = snd_soc_get_volsw_sx,\
  62. .put = snd_soc_put_volsw_sx, \
  63. .private_value = (unsigned long)&(struct soc_mixer_control) \
  64. {.reg = xreg, .rreg = xreg, \
  65. .shift = xshift, .rshift = xshift, \
  66. .max = xmax, .min = xmin} }
  67. #define SOC_DOUBLE(xname, reg, shift_left, shift_right, max, invert) \
  68. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  69. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
  70. .put = snd_soc_put_volsw, \
  71. .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
  72. max, invert) }
  73. #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
  74. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  75. .info = snd_soc_info_volsw, \
  76. .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
  77. .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
  78. xmax, xinvert) }
  79. #define SOC_DOUBLE_TLV(xname, reg, shift_left, shift_right, max, invert, tlv_array) \
  80. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  81. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  82. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  83. .tlv.p = (tlv_array), \
  84. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
  85. .put = snd_soc_put_volsw, \
  86. .private_value = SOC_DOUBLE_VALUE(reg, shift_left, shift_right, \
  87. max, invert) }
  88. #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
  89. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  90. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  91. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  92. .tlv.p = (tlv_array), \
  93. .info = snd_soc_info_volsw, \
  94. .get = snd_soc_get_volsw, .put = snd_soc_put_volsw, \
  95. .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
  96. xmax, xinvert) }
  97. #define SOC_DOUBLE_R_SX_TLV(xname, xreg, xrreg, xshift, xmin, xmax, tlv_array) \
  98. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  99. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  100. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  101. .tlv.p = (tlv_array), \
  102. .info = snd_soc_info_volsw, \
  103. .get = snd_soc_get_volsw_sx, \
  104. .put = snd_soc_put_volsw_sx, \
  105. .private_value = (unsigned long)&(struct soc_mixer_control) \
  106. {.reg = xreg, .rreg = xrreg, \
  107. .shift = xshift, .rshift = xshift, \
  108. .max = xmax, .min = xmin} }
  109. #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
  110. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  111. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  112. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  113. .tlv.p = (tlv_array), \
  114. .info = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \
  115. .put = snd_soc_put_volsw_s8, \
  116. .private_value = (unsigned long)&(struct soc_mixer_control) \
  117. {.reg = xreg, .min = xmin, .max = xmax, \
  118. .platform_max = xmax} }
  119. #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \
  120. { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
  121. .max = xmax, .texts = xtexts }
  122. #define SOC_ENUM_SINGLE(xreg, xshift, xmax, xtexts) \
  123. SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmax, xtexts)
  124. #define SOC_ENUM_SINGLE_EXT(xmax, xtexts) \
  125. { .max = xmax, .texts = xtexts }
  126. #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xmax, xtexts, xvalues) \
  127. { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
  128. .mask = xmask, .max = xmax, .texts = xtexts, .values = xvalues}
  129. #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xmax, xtexts, xvalues) \
  130. SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xmax, xtexts, xvalues)
  131. #define SOC_ENUM(xname, xenum) \
  132. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
  133. .info = snd_soc_info_enum_double, \
  134. .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
  135. .private_value = (unsigned long)&xenum }
  136. #define SOC_VALUE_ENUM(xname, xenum) \
  137. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
  138. .info = snd_soc_info_enum_double, \
  139. .get = snd_soc_get_value_enum_double, \
  140. .put = snd_soc_put_value_enum_double, \
  141. .private_value = (unsigned long)&xenum }
  142. #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
  143. xhandler_get, xhandler_put) \
  144. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  145. .info = snd_soc_info_volsw, \
  146. .get = xhandler_get, .put = xhandler_put, \
  147. .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) }
  148. #define SOC_DOUBLE_EXT(xname, reg, shift_left, shift_right, max, invert,\
  149. xhandler_get, xhandler_put) \
  150. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  151. .info = snd_soc_info_volsw, \
  152. .get = xhandler_get, .put = xhandler_put, \
  153. .private_value = \
  154. SOC_DOUBLE_VALUE(reg, shift_left, shift_right, max, invert) }
  155. #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
  156. xhandler_get, xhandler_put, tlv_array) \
  157. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  158. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  159. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  160. .tlv.p = (tlv_array), \
  161. .info = snd_soc_info_volsw, \
  162. .get = xhandler_get, .put = xhandler_put, \
  163. .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) }
  164. #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
  165. xhandler_get, xhandler_put, tlv_array) \
  166. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  167. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  168. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  169. .tlv.p = (tlv_array), \
  170. .info = snd_soc_info_volsw, \
  171. .get = xhandler_get, .put = xhandler_put, \
  172. .private_value = SOC_DOUBLE_VALUE(xreg, shift_left, shift_right, \
  173. xmax, xinvert) }
  174. #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
  175. xhandler_get, xhandler_put, tlv_array) \
  176. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  177. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  178. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  179. .tlv.p = (tlv_array), \
  180. .info = snd_soc_info_volsw, \
  181. .get = xhandler_get, .put = xhandler_put, \
  182. .private_value = SOC_DOUBLE_R_VALUE(reg_left, reg_right, xshift, \
  183. xmax, xinvert) }
  184. #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
  185. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  186. .info = snd_soc_info_bool_ext, \
  187. .get = xhandler_get, .put = xhandler_put, \
  188. .private_value = xdata }
  189. #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
  190. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  191. .info = snd_soc_info_enum_ext, \
  192. .get = xhandler_get, .put = xhandler_put, \
  193. .private_value = (unsigned long)&xenum }
  194. #define SND_SOC_BYTES(xname, xbase, xregs) \
  195. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  196. .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
  197. .put = snd_soc_bytes_put, .private_value = \
  198. ((unsigned long)&(struct soc_bytes) \
  199. {.base = xbase, .num_regs = xregs }) }
  200. #define SND_SOC_BYTES_MASK(xname, xbase, xregs, xmask) \
  201. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  202. .info = snd_soc_bytes_info, .get = snd_soc_bytes_get, \
  203. .put = snd_soc_bytes_put, .private_value = \
  204. ((unsigned long)&(struct soc_bytes) \
  205. {.base = xbase, .num_regs = xregs, \
  206. .mask = xmask }) }
  207. #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \
  208. xmin, xmax, xinvert) \
  209. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  210. .info = snd_soc_info_xr_sx, .get = snd_soc_get_xr_sx, \
  211. .put = snd_soc_put_xr_sx, \
  212. .private_value = (unsigned long)&(struct soc_mreg_control) \
  213. {.regbase = xregbase, .regcount = xregcount, .nbits = xnbits, \
  214. .invert = xinvert, .min = xmin, .max = xmax} }
  215. /*
  216. * Simplified versions of above macros, declaring a struct and calculating
  217. * ARRAY_SIZE internally
  218. */
  219. #define SOC_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xtexts) \
  220. struct soc_enum name = SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, \
  221. ARRAY_SIZE(xtexts), xtexts)
  222. #define SOC_ENUM_SINGLE_DECL(name, xreg, xshift, xtexts) \
  223. SOC_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xtexts)
  224. #define SOC_ENUM_SINGLE_EXT_DECL(name, xtexts) \
  225. struct soc_enum name = SOC_ENUM_SINGLE_EXT(ARRAY_SIZE(xtexts), xtexts)
  226. #define SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift_l, xshift_r, xmask, xtexts, xvalues) \
  227. struct soc_enum name = SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, \
  228. ARRAY_SIZE(xtexts), xtexts, xvalues)
  229. #define SOC_VALUE_ENUM_SINGLE_DECL(name, xreg, xshift, xmask, xtexts, xvalues) \
  230. SOC_VALUE_ENUM_DOUBLE_DECL(name, xreg, xshift, xshift, xmask, xtexts, xvalues)
  231. /*
  232. * Component probe and remove ordering levels for components with runtime
  233. * dependencies.
  234. */
  235. #define SND_SOC_COMP_ORDER_FIRST -2
  236. #define SND_SOC_COMP_ORDER_EARLY -1
  237. #define SND_SOC_COMP_ORDER_NORMAL 0
  238. #define SND_SOC_COMP_ORDER_LATE 1
  239. #define SND_SOC_COMP_ORDER_LAST 2
  240. /*
  241. * Bias levels
  242. *
  243. * @ON: Bias is fully on for audio playback and capture operations.
  244. * @PREPARE: Prepare for audio operations. Called before DAPM switching for
  245. * stream start and stop operations.
  246. * @STANDBY: Low power standby state when no playback/capture operations are
  247. * in progress. NOTE: The transition time between STANDBY and ON
  248. * should be as fast as possible and no longer than 10ms.
  249. * @OFF: Power Off. No restrictions on transition times.
  250. */
  251. enum snd_soc_bias_level {
  252. SND_SOC_BIAS_OFF = 0,
  253. SND_SOC_BIAS_STANDBY = 1,
  254. SND_SOC_BIAS_PREPARE = 2,
  255. SND_SOC_BIAS_ON = 3,
  256. };
  257. struct device_node;
  258. struct snd_jack;
  259. struct snd_soc_card;
  260. struct snd_soc_pcm_stream;
  261. struct snd_soc_ops;
  262. struct snd_soc_pcm_runtime;
  263. struct snd_soc_dai;
  264. struct snd_soc_dai_driver;
  265. struct snd_soc_platform;
  266. struct snd_soc_dai_link;
  267. struct snd_soc_platform_driver;
  268. struct snd_soc_codec;
  269. struct snd_soc_codec_driver;
  270. struct soc_enum;
  271. struct snd_soc_jack;
  272. struct snd_soc_jack_zone;
  273. struct snd_soc_jack_pin;
  274. struct snd_soc_cache_ops;
  275. #include <sound/soc-dapm.h>
  276. #ifdef CONFIG_GPIOLIB
  277. struct snd_soc_jack_gpio;
  278. #endif
  279. typedef int (*hw_write_t)(void *,const char* ,int);
  280. extern struct snd_ac97_bus_ops soc_ac97_ops;
  281. enum snd_soc_control_type {
  282. SND_SOC_I2C = 1,
  283. SND_SOC_SPI,
  284. SND_SOC_REGMAP,
  285. };
  286. enum snd_soc_compress_type {
  287. SND_SOC_FLAT_COMPRESSION = 1,
  288. };
  289. enum snd_soc_pcm_subclass {
  290. SND_SOC_PCM_CLASS_PCM = 0,
  291. SND_SOC_PCM_CLASS_BE = 1,
  292. };
  293. enum snd_soc_card_subclass {
  294. SND_SOC_CARD_CLASS_INIT = 0,
  295. SND_SOC_CARD_CLASS_RUNTIME = 1,
  296. };
  297. int snd_soc_codec_set_sysclk(struct snd_soc_codec *codec, int clk_id,
  298. int source, unsigned int freq, int dir);
  299. int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source,
  300. unsigned int freq_in, unsigned int freq_out);
  301. int snd_soc_register_card(struct snd_soc_card *card);
  302. int snd_soc_unregister_card(struct snd_soc_card *card);
  303. int snd_soc_suspend(struct device *dev);
  304. int snd_soc_resume(struct device *dev);
  305. int snd_soc_poweroff(struct device *dev);
  306. int snd_soc_register_platform(struct device *dev,
  307. struct snd_soc_platform_driver *platform_drv);
  308. void snd_soc_unregister_platform(struct device *dev);
  309. int snd_soc_register_codec(struct device *dev,
  310. const struct snd_soc_codec_driver *codec_drv,
  311. struct snd_soc_dai_driver *dai_drv, int num_dai);
  312. void snd_soc_unregister_codec(struct device *dev);
  313. int snd_soc_codec_volatile_register(struct snd_soc_codec *codec,
  314. unsigned int reg);
  315. int snd_soc_codec_readable_register(struct snd_soc_codec *codec,
  316. unsigned int reg);
  317. int snd_soc_codec_writable_register(struct snd_soc_codec *codec,
  318. unsigned int reg);
  319. int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
  320. int addr_bits, int data_bits,
  321. enum snd_soc_control_type control);
  322. int snd_soc_cache_sync(struct snd_soc_codec *codec);
  323. int snd_soc_cache_init(struct snd_soc_codec *codec);
  324. int snd_soc_cache_exit(struct snd_soc_codec *codec);
  325. int snd_soc_cache_write(struct snd_soc_codec *codec,
  326. unsigned int reg, unsigned int value);
  327. int snd_soc_cache_read(struct snd_soc_codec *codec,
  328. unsigned int reg, unsigned int *value);
  329. int snd_soc_default_volatile_register(struct snd_soc_codec *codec,
  330. unsigned int reg);
  331. int snd_soc_default_readable_register(struct snd_soc_codec *codec,
  332. unsigned int reg);
  333. int snd_soc_default_writable_register(struct snd_soc_codec *codec,
  334. unsigned int reg);
  335. int snd_soc_platform_read(struct snd_soc_platform *platform,
  336. unsigned int reg);
  337. int snd_soc_platform_write(struct snd_soc_platform *platform,
  338. unsigned int reg, unsigned int val);
  339. int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num);
  340. /* Utility functions to get clock rates from various things */
  341. int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
  342. int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
  343. int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
  344. int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
  345. /* set runtime hw params */
  346. int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
  347. const struct snd_pcm_hardware *hw);
  348. /* Jack reporting */
  349. int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type,
  350. struct snd_soc_jack *jack);
  351. void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
  352. int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
  353. struct snd_soc_jack_pin *pins);
  354. void snd_soc_jack_notifier_register(struct snd_soc_jack *jack,
  355. struct notifier_block *nb);
  356. void snd_soc_jack_notifier_unregister(struct snd_soc_jack *jack,
  357. struct notifier_block *nb);
  358. int snd_soc_jack_add_zones(struct snd_soc_jack *jack, int count,
  359. struct snd_soc_jack_zone *zones);
  360. int snd_soc_jack_get_type(struct snd_soc_jack *jack, int micbias_voltage);
  361. #ifdef CONFIG_GPIOLIB
  362. int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
  363. struct snd_soc_jack_gpio *gpios);
  364. void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
  365. struct snd_soc_jack_gpio *gpios);
  366. #endif
  367. /* codec register bit access */
  368. int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
  369. unsigned int mask, unsigned int value);
  370. int snd_soc_update_bits_locked(struct snd_soc_codec *codec,
  371. unsigned short reg, unsigned int mask,
  372. unsigned int value);
  373. int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
  374. unsigned int mask, unsigned int value);
  375. int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
  376. struct snd_ac97_bus_ops *ops, int num);
  377. void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
  378. /*
  379. *Controls
  380. */
  381. struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
  382. void *data, const char *long_name,
  383. const char *prefix);
  384. int snd_soc_add_codec_controls(struct snd_soc_codec *codec,
  385. const struct snd_kcontrol_new *controls, int num_controls);
  386. int snd_soc_add_platform_controls(struct snd_soc_platform *platform,
  387. const struct snd_kcontrol_new *controls, int num_controls);
  388. int snd_soc_add_card_controls(struct snd_soc_card *soc_card,
  389. const struct snd_kcontrol_new *controls, int num_controls);
  390. int snd_soc_add_dai_controls(struct snd_soc_dai *dai,
  391. const struct snd_kcontrol_new *controls, int num_controls);
  392. int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
  393. struct snd_ctl_elem_info *uinfo);
  394. int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
  395. struct snd_ctl_elem_info *uinfo);
  396. int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
  397. struct snd_ctl_elem_value *ucontrol);
  398. int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
  399. struct snd_ctl_elem_value *ucontrol);
  400. int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
  401. struct snd_ctl_elem_value *ucontrol);
  402. int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
  403. struct snd_ctl_elem_value *ucontrol);
  404. int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
  405. struct snd_ctl_elem_info *uinfo);
  406. int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
  407. struct snd_ctl_elem_info *uinfo);
  408. #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
  409. int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
  410. struct snd_ctl_elem_value *ucontrol);
  411. int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
  412. struct snd_ctl_elem_value *ucontrol);
  413. #define snd_soc_get_volsw_2r snd_soc_get_volsw
  414. #define snd_soc_put_volsw_2r snd_soc_put_volsw
  415. int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol,
  416. struct snd_ctl_elem_value *ucontrol);
  417. int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol,
  418. struct snd_ctl_elem_value *ucontrol);
  419. int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
  420. struct snd_ctl_elem_info *uinfo);
  421. int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
  422. struct snd_ctl_elem_value *ucontrol);
  423. int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
  424. struct snd_ctl_elem_value *ucontrol);
  425. int snd_soc_limit_volume(struct snd_soc_codec *codec,
  426. const char *name, int max);
  427. int snd_soc_bytes_info(struct snd_kcontrol *kcontrol,
  428. struct snd_ctl_elem_info *uinfo);
  429. int snd_soc_bytes_get(struct snd_kcontrol *kcontrol,
  430. struct snd_ctl_elem_value *ucontrol);
  431. int snd_soc_bytes_put(struct snd_kcontrol *kcontrol,
  432. struct snd_ctl_elem_value *ucontrol);
  433. int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol,
  434. struct snd_ctl_elem_info *uinfo);
  435. int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol,
  436. struct snd_ctl_elem_value *ucontrol);
  437. int snd_soc_put_xr_sx(struct snd_kcontrol *kcontrol,
  438. struct snd_ctl_elem_value *ucontrol);
  439. /**
  440. * struct snd_soc_reg_access - Describes whether a given register is
  441. * readable, writable or volatile.
  442. *
  443. * @reg: the register number
  444. * @read: whether this register is readable
  445. * @write: whether this register is writable
  446. * @vol: whether this register is volatile
  447. */
  448. struct snd_soc_reg_access {
  449. u16 reg;
  450. u16 read;
  451. u16 write;
  452. u16 vol;
  453. };
  454. /**
  455. * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
  456. *
  457. * @pin: name of the pin to update
  458. * @mask: bits to check for in reported jack status
  459. * @invert: if non-zero then pin is enabled when status is not reported
  460. */
  461. struct snd_soc_jack_pin {
  462. struct list_head list;
  463. const char *pin;
  464. int mask;
  465. bool invert;
  466. };
  467. /**
  468. * struct snd_soc_jack_zone - Describes voltage zones of jack detection
  469. *
  470. * @min_mv: start voltage in mv
  471. * @max_mv: end voltage in mv
  472. * @jack_type: type of jack that is expected for this voltage
  473. * @debounce_time: debounce_time for jack, codec driver should wait for this
  474. * duration before reading the adc for voltages
  475. * @:list: list container
  476. */
  477. struct snd_soc_jack_zone {
  478. unsigned int min_mv;
  479. unsigned int max_mv;
  480. unsigned int jack_type;
  481. unsigned int debounce_time;
  482. struct list_head list;
  483. };
  484. /**
  485. * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection
  486. *
  487. * @gpio: gpio number
  488. * @name: gpio name
  489. * @report: value to report when jack detected
  490. * @invert: report presence in low state
  491. * @debouce_time: debouce time in ms
  492. * @wake: enable as wake source
  493. * @jack_status_check: callback function which overrides the detection
  494. * to provide more complex checks (eg, reading an
  495. * ADC).
  496. */
  497. #ifdef CONFIG_GPIOLIB
  498. struct snd_soc_jack_gpio {
  499. unsigned int gpio;
  500. const char *name;
  501. int report;
  502. int invert;
  503. int debounce_time;
  504. bool wake;
  505. struct snd_soc_jack *jack;
  506. struct delayed_work work;
  507. int (*jack_status_check)(void);
  508. };
  509. #endif
  510. struct snd_soc_jack {
  511. struct mutex mutex;
  512. struct snd_jack *jack;
  513. struct snd_soc_codec *codec;
  514. struct list_head pins;
  515. int status;
  516. struct blocking_notifier_head notifier;
  517. struct list_head jack_zones;
  518. };
  519. /* SoC PCM stream information */
  520. struct snd_soc_pcm_stream {
  521. const char *stream_name;
  522. u64 formats; /* SNDRV_PCM_FMTBIT_* */
  523. unsigned int rates; /* SNDRV_PCM_RATE_* */
  524. unsigned int rate_min; /* min rate */
  525. unsigned int rate_max; /* max rate */
  526. unsigned int channels_min; /* min channels */
  527. unsigned int channels_max; /* max channels */
  528. unsigned int sig_bits; /* number of bits of content */
  529. };
  530. /* SoC audio ops */
  531. struct snd_soc_ops {
  532. int (*startup)(struct snd_pcm_substream *);
  533. void (*shutdown)(struct snd_pcm_substream *);
  534. int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
  535. int (*hw_free)(struct snd_pcm_substream *);
  536. int (*prepare)(struct snd_pcm_substream *);
  537. int (*trigger)(struct snd_pcm_substream *, int);
  538. };
  539. /* SoC cache ops */
  540. struct snd_soc_cache_ops {
  541. const char *name;
  542. enum snd_soc_compress_type id;
  543. int (*init)(struct snd_soc_codec *codec);
  544. int (*exit)(struct snd_soc_codec *codec);
  545. int (*read)(struct snd_soc_codec *codec, unsigned int reg,
  546. unsigned int *value);
  547. int (*write)(struct snd_soc_codec *codec, unsigned int reg,
  548. unsigned int value);
  549. int (*sync)(struct snd_soc_codec *codec);
  550. };
  551. /* SoC Audio Codec device */
  552. struct snd_soc_codec {
  553. const char *name;
  554. const char *name_prefix;
  555. int id;
  556. struct device *dev;
  557. const struct snd_soc_codec_driver *driver;
  558. struct mutex mutex;
  559. struct snd_soc_card *card;
  560. struct list_head list;
  561. struct list_head card_list;
  562. int num_dai;
  563. enum snd_soc_compress_type compress_type;
  564. size_t reg_size; /* reg_cache_size * reg_word_size */
  565. int (*volatile_register)(struct snd_soc_codec *, unsigned int);
  566. int (*readable_register)(struct snd_soc_codec *, unsigned int);
  567. int (*writable_register)(struct snd_soc_codec *, unsigned int);
  568. /* runtime */
  569. struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
  570. unsigned int active;
  571. unsigned int cache_bypass:1; /* Suppress access to the cache */
  572. unsigned int suspended:1; /* Codec is in suspend PM state */
  573. unsigned int probed:1; /* Codec has been probed */
  574. unsigned int ac97_registered:1; /* Codec has been AC97 registered */
  575. unsigned int ac97_created:1; /* Codec has been created by SoC */
  576. unsigned int sysfs_registered:1; /* codec has been sysfs registered */
  577. unsigned int cache_init:1; /* codec cache has been initialized */
  578. unsigned int using_regmap:1; /* using regmap access */
  579. u32 cache_only; /* Suppress writes to hardware */
  580. u32 cache_sync; /* Cache needs to be synced to hardware */
  581. /* codec IO */
  582. void *control_data; /* codec control (i2c/3wire) data */
  583. enum snd_soc_control_type control_type;
  584. hw_write_t hw_write;
  585. unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int);
  586. unsigned int (*read)(struct snd_soc_codec *, unsigned int);
  587. int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
  588. int (*bulk_write_raw)(struct snd_soc_codec *, unsigned int, const void *, size_t);
  589. void *reg_cache;
  590. const void *reg_def_copy;
  591. const struct snd_soc_cache_ops *cache_ops;
  592. struct mutex cache_rw_mutex;
  593. int val_bytes;
  594. /* dapm */
  595. struct snd_soc_dapm_context dapm;
  596. unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */
  597. #ifdef CONFIG_DEBUG_FS
  598. struct dentry *debugfs_codec_root;
  599. struct dentry *debugfs_reg;
  600. struct dentry *debugfs_dapm;
  601. #endif
  602. };
  603. /* codec driver */
  604. struct snd_soc_codec_driver {
  605. /* driver ops */
  606. int (*probe)(struct snd_soc_codec *);
  607. int (*remove)(struct snd_soc_codec *);
  608. int (*suspend)(struct snd_soc_codec *);
  609. int (*resume)(struct snd_soc_codec *);
  610. /* Default control and setup, added after probe() is run */
  611. const struct snd_kcontrol_new *controls;
  612. int num_controls;
  613. const struct snd_soc_dapm_widget *dapm_widgets;
  614. int num_dapm_widgets;
  615. const struct snd_soc_dapm_route *dapm_routes;
  616. int num_dapm_routes;
  617. /* codec wide operations */
  618. int (*set_sysclk)(struct snd_soc_codec *codec,
  619. int clk_id, int source, unsigned int freq, int dir);
  620. int (*set_pll)(struct snd_soc_codec *codec, int pll_id, int source,
  621. unsigned int freq_in, unsigned int freq_out);
  622. /* codec IO */
  623. unsigned int (*read)(struct snd_soc_codec *, unsigned int);
  624. int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
  625. int (*display_register)(struct snd_soc_codec *, char *,
  626. size_t, unsigned int);
  627. int (*volatile_register)(struct snd_soc_codec *, unsigned int);
  628. int (*readable_register)(struct snd_soc_codec *, unsigned int);
  629. int (*writable_register)(struct snd_soc_codec *, unsigned int);
  630. unsigned int reg_cache_size;
  631. short reg_cache_step;
  632. short reg_word_size;
  633. const void *reg_cache_default;
  634. short reg_access_size;
  635. const struct snd_soc_reg_access *reg_access_default;
  636. enum snd_soc_compress_type compress_type;
  637. /* codec bias level */
  638. int (*set_bias_level)(struct snd_soc_codec *,
  639. enum snd_soc_bias_level level);
  640. bool idle_bias_off;
  641. void (*seq_notifier)(struct snd_soc_dapm_context *,
  642. enum snd_soc_dapm_type, int);
  643. /* codec stream completion event */
  644. int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
  645. bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */
  646. /* probe ordering - for components with runtime dependencies */
  647. int probe_order;
  648. int remove_order;
  649. };
  650. /* SoC platform interface */
  651. struct snd_soc_platform_driver {
  652. int (*probe)(struct snd_soc_platform *);
  653. int (*remove)(struct snd_soc_platform *);
  654. int (*suspend)(struct snd_soc_dai *dai);
  655. int (*resume)(struct snd_soc_dai *dai);
  656. /* pcm creation and destruction */
  657. int (*pcm_new)(struct snd_soc_pcm_runtime *);
  658. void (*pcm_free)(struct snd_pcm *);
  659. /* Default control and setup, added after probe() is run */
  660. const struct snd_kcontrol_new *controls;
  661. int num_controls;
  662. const struct snd_soc_dapm_widget *dapm_widgets;
  663. int num_dapm_widgets;
  664. const struct snd_soc_dapm_route *dapm_routes;
  665. int num_dapm_routes;
  666. /*
  667. * For platform caused delay reporting.
  668. * Optional.
  669. */
  670. snd_pcm_sframes_t (*delay)(struct snd_pcm_substream *,
  671. struct snd_soc_dai *);
  672. /* platform stream ops */
  673. struct snd_pcm_ops *ops;
  674. /* platform stream completion event */
  675. int (*stream_event)(struct snd_soc_dapm_context *dapm, int event);
  676. /* probe ordering - for components with runtime dependencies */
  677. int probe_order;
  678. int remove_order;
  679. /* platform IO - used for platform DAPM */
  680. unsigned int (*read)(struct snd_soc_platform *, unsigned int);
  681. int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
  682. };
  683. struct snd_soc_platform {
  684. const char *name;
  685. int id;
  686. struct device *dev;
  687. struct snd_soc_platform_driver *driver;
  688. struct mutex mutex;
  689. unsigned int suspended:1; /* platform is suspended */
  690. unsigned int probed:1;
  691. struct snd_soc_card *card;
  692. struct list_head list;
  693. struct list_head card_list;
  694. struct snd_soc_dapm_context dapm;
  695. #ifdef CONFIG_DEBUG_FS
  696. struct dentry *debugfs_platform_root;
  697. struct dentry *debugfs_dapm;
  698. #endif
  699. };
  700. struct snd_soc_dai_link {
  701. /* config - must be set by machine driver */
  702. const char *name; /* Codec name */
  703. const char *stream_name; /* Stream name */
  704. const char *codec_name; /* for multi-codec */
  705. const struct device_node *codec_of_node;
  706. const char *platform_name; /* for multi-platform */
  707. const struct device_node *platform_of_node;
  708. const char *cpu_dai_name;
  709. const struct device_node *cpu_dai_of_node;
  710. const char *codec_dai_name;
  711. const struct snd_soc_pcm_stream *params;
  712. unsigned int dai_fmt; /* format to set on init */
  713. /* Keep DAI active over suspend */
  714. unsigned int ignore_suspend:1;
  715. /* Symmetry requirements */
  716. unsigned int symmetric_rates:1;
  717. /* pmdown_time is ignored at stop */
  718. unsigned int ignore_pmdown_time:1;
  719. /* codec/machine specific init - e.g. add machine controls */
  720. int (*init)(struct snd_soc_pcm_runtime *rtd);
  721. /* machine stream operations */
  722. struct snd_soc_ops *ops;
  723. };
  724. struct snd_soc_codec_conf {
  725. const char *dev_name;
  726. /*
  727. * optional map of kcontrol, widget and path name prefixes that are
  728. * associated per device
  729. */
  730. const char *name_prefix;
  731. /*
  732. * set this to the desired compression type if you want to
  733. * override the one supplied in codec->driver->compress_type
  734. */
  735. enum snd_soc_compress_type compress_type;
  736. };
  737. struct snd_soc_aux_dev {
  738. const char *name; /* Codec name */
  739. const char *codec_name; /* for multi-codec */
  740. /* codec/machine specific init - e.g. add machine controls */
  741. int (*init)(struct snd_soc_dapm_context *dapm);
  742. };
  743. /* SoC card */
  744. struct snd_soc_card {
  745. const char *name;
  746. const char *long_name;
  747. const char *driver_name;
  748. struct device *dev;
  749. struct snd_card *snd_card;
  750. struct module *owner;
  751. struct list_head list;
  752. struct mutex mutex;
  753. struct mutex dapm_mutex;
  754. bool instantiated;
  755. int (*probe)(struct snd_soc_card *card);
  756. int (*late_probe)(struct snd_soc_card *card);
  757. int (*remove)(struct snd_soc_card *card);
  758. /* the pre and post PM functions are used to do any PM work before and
  759. * after the codec and DAI's do any PM work. */
  760. int (*suspend_pre)(struct snd_soc_card *card);
  761. int (*suspend_post)(struct snd_soc_card *card);
  762. int (*resume_pre)(struct snd_soc_card *card);
  763. int (*resume_post)(struct snd_soc_card *card);
  764. /* callbacks */
  765. int (*set_bias_level)(struct snd_soc_card *,
  766. struct snd_soc_dapm_context *dapm,
  767. enum snd_soc_bias_level level);
  768. int (*set_bias_level_post)(struct snd_soc_card *,
  769. struct snd_soc_dapm_context *dapm,
  770. enum snd_soc_bias_level level);
  771. long pmdown_time;
  772. /* CPU <--> Codec DAI links */
  773. struct snd_soc_dai_link *dai_link;
  774. int num_links;
  775. struct snd_soc_pcm_runtime *rtd;
  776. int num_rtd;
  777. /* optional codec specific configuration */
  778. struct snd_soc_codec_conf *codec_conf;
  779. int num_configs;
  780. /*
  781. * optional auxiliary devices such as amplifiers or codecs with DAI
  782. * link unused
  783. */
  784. struct snd_soc_aux_dev *aux_dev;
  785. int num_aux_devs;
  786. struct snd_soc_pcm_runtime *rtd_aux;
  787. int num_aux_rtd;
  788. const struct snd_kcontrol_new *controls;
  789. int num_controls;
  790. /*
  791. * Card-specific routes and widgets.
  792. */
  793. const struct snd_soc_dapm_widget *dapm_widgets;
  794. int num_dapm_widgets;
  795. const struct snd_soc_dapm_route *dapm_routes;
  796. int num_dapm_routes;
  797. bool fully_routed;
  798. struct work_struct deferred_resume_work;
  799. /* lists of probed devices belonging to this card */
  800. struct list_head codec_dev_list;
  801. struct list_head platform_dev_list;
  802. struct list_head dai_dev_list;
  803. struct list_head widgets;
  804. struct list_head paths;
  805. struct list_head dapm_list;
  806. struct list_head dapm_dirty;
  807. /* Generic DAPM context for the card */
  808. struct snd_soc_dapm_context dapm;
  809. struct snd_soc_dapm_stats dapm_stats;
  810. #ifdef CONFIG_DEBUG_FS
  811. struct dentry *debugfs_card_root;
  812. struct dentry *debugfs_pop_time;
  813. #endif
  814. u32 pop_time;
  815. void *drvdata;
  816. };
  817. /* SoC machine DAI configuration, glues a codec and cpu DAI together */
  818. struct snd_soc_pcm_runtime {
  819. struct device *dev;
  820. struct snd_soc_card *card;
  821. struct snd_soc_dai_link *dai_link;
  822. struct mutex pcm_mutex;
  823. enum snd_soc_pcm_subclass pcm_subclass;
  824. struct snd_pcm_ops ops;
  825. unsigned int dev_registered:1;
  826. long pmdown_time;
  827. /* runtime devices */
  828. struct snd_pcm *pcm;
  829. struct snd_soc_codec *codec;
  830. struct snd_soc_platform *platform;
  831. struct snd_soc_dai *codec_dai;
  832. struct snd_soc_dai *cpu_dai;
  833. struct delayed_work delayed_work;
  834. };
  835. /* mixer control */
  836. struct soc_mixer_control {
  837. int min, max, platform_max;
  838. unsigned int reg, rreg, shift, rshift, invert;
  839. };
  840. struct soc_bytes {
  841. int base;
  842. int num_regs;
  843. u32 mask;
  844. };
  845. /* multi register control */
  846. struct soc_mreg_control {
  847. long min, max;
  848. unsigned int regbase, regcount, nbits, invert;
  849. };
  850. /* enumerated kcontrol */
  851. struct soc_enum {
  852. unsigned short reg;
  853. unsigned short reg2;
  854. unsigned char shift_l;
  855. unsigned char shift_r;
  856. unsigned int max;
  857. unsigned int mask;
  858. const char * const *texts;
  859. const unsigned int *values;
  860. void *dapm;
  861. };
  862. /* codec IO */
  863. unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg);
  864. unsigned int snd_soc_write(struct snd_soc_codec *codec,
  865. unsigned int reg, unsigned int val);
  866. unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec,
  867. unsigned int reg, const void *data, size_t len);
  868. /* device driver data */
  869. static inline void snd_soc_card_set_drvdata(struct snd_soc_card *card,
  870. void *data)
  871. {
  872. card->drvdata = data;
  873. }
  874. static inline void *snd_soc_card_get_drvdata(struct snd_soc_card *card)
  875. {
  876. return card->drvdata;
  877. }
  878. static inline void snd_soc_codec_set_drvdata(struct snd_soc_codec *codec,
  879. void *data)
  880. {
  881. dev_set_drvdata(codec->dev, data);
  882. }
  883. static inline void *snd_soc_codec_get_drvdata(struct snd_soc_codec *codec)
  884. {
  885. return dev_get_drvdata(codec->dev);
  886. }
  887. static inline void snd_soc_platform_set_drvdata(struct snd_soc_platform *platform,
  888. void *data)
  889. {
  890. dev_set_drvdata(platform->dev, data);
  891. }
  892. static inline void *snd_soc_platform_get_drvdata(struct snd_soc_platform *platform)
  893. {
  894. return dev_get_drvdata(platform->dev);
  895. }
  896. static inline void snd_soc_pcm_set_drvdata(struct snd_soc_pcm_runtime *rtd,
  897. void *data)
  898. {
  899. dev_set_drvdata(rtd->dev, data);
  900. }
  901. static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd)
  902. {
  903. return dev_get_drvdata(rtd->dev);
  904. }
  905. static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card)
  906. {
  907. INIT_LIST_HEAD(&card->dai_dev_list);
  908. INIT_LIST_HEAD(&card->codec_dev_list);
  909. INIT_LIST_HEAD(&card->platform_dev_list);
  910. INIT_LIST_HEAD(&card->widgets);
  911. INIT_LIST_HEAD(&card->paths);
  912. INIT_LIST_HEAD(&card->dapm_list);
  913. }
  914. static inline bool snd_soc_volsw_is_stereo(struct soc_mixer_control *mc)
  915. {
  916. if (mc->reg == mc->rreg && mc->shift == mc->rshift)
  917. return 0;
  918. /*
  919. * mc->reg == mc->rreg && mc->shift != mc->rshift, or
  920. * mc->reg != mc->rreg means that the control is
  921. * stereo (bits in one register or in two registers)
  922. */
  923. return 1;
  924. }
  925. int snd_soc_util_init(void);
  926. void snd_soc_util_exit(void);
  927. int snd_soc_of_parse_card_name(struct snd_soc_card *card,
  928. const char *propname);
  929. int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
  930. const char *propname);
  931. #include <sound/soc-dai.h>
  932. #ifdef CONFIG_DEBUG_FS
  933. extern struct dentry *snd_soc_debugfs_root;
  934. #endif
  935. extern const struct dev_pm_ops snd_soc_pm_ops;
  936. #endif