soc.h 36 KB

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