soc.h 36 KB

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