soc.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  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/workqueue.h>
  17. #include <linux/interrupt.h>
  18. #include <linux/kernel.h>
  19. #include <sound/core.h>
  20. #include <sound/pcm.h>
  21. #include <sound/control.h>
  22. #include <sound/ac97_codec.h>
  23. /*
  24. * Convenience kcontrol builders
  25. */
  26. #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \
  27. ((unsigned long)&(struct soc_mixer_control) \
  28. {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \
  29. .invert = xinvert})
  30. #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
  31. ((unsigned long)&(struct soc_mixer_control) \
  32. {.reg = xreg, .max = xmax, .invert = xinvert})
  33. #define SOC_SINGLE(xname, reg, shift, max, invert) \
  34. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  35. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
  36. .put = snd_soc_put_volsw, \
  37. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
  38. #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
  39. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  40. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  41. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  42. .tlv.p = (tlv_array), \
  43. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
  44. .put = snd_soc_put_volsw, \
  45. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
  46. #define SOC_DOUBLE(xname, xreg, shift_left, shift_right, xmax, xinvert) \
  47. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  48. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
  49. .put = snd_soc_put_volsw, \
  50. .private_value = (unsigned long)&(struct soc_mixer_control) \
  51. {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
  52. .max = xmax, .invert = xinvert} }
  53. #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
  54. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  55. .info = snd_soc_info_volsw_2r, \
  56. .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
  57. .private_value = (unsigned long)&(struct soc_mixer_control) \
  58. {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
  59. .max = xmax, .invert = xinvert} }
  60. #define SOC_DOUBLE_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert, tlv_array) \
  61. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  62. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  63. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  64. .tlv.p = (tlv_array), \
  65. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
  66. .put = snd_soc_put_volsw, \
  67. .private_value = (unsigned long)&(struct soc_mixer_control) \
  68. {.reg = xreg, .shift = shift_left, .rshift = shift_right,\
  69. .max = xmax, .invert = xinvert} }
  70. #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
  71. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  72. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  73. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  74. .tlv.p = (tlv_array), \
  75. .info = snd_soc_info_volsw_2r, \
  76. .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
  77. .private_value = (unsigned long)&(struct soc_mixer_control) \
  78. {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
  79. .max = xmax, .invert = xinvert} }
  80. #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, tlv_array) \
  81. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  82. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  83. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  84. .tlv.p = (tlv_array), \
  85. .info = snd_soc_info_volsw_s8, .get = snd_soc_get_volsw_s8, \
  86. .put = snd_soc_put_volsw_s8, \
  87. .private_value = (unsigned long)&(struct soc_mixer_control) \
  88. {.reg = xreg, .min = xmin, .max = xmax} }
  89. #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \
  90. { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
  91. .max = xmax, .texts = xtexts }
  92. #define SOC_ENUM_SINGLE(xreg, xshift, xmax, xtexts) \
  93. SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmax, xtexts)
  94. #define SOC_ENUM_SINGLE_EXT(xmax, xtexts) \
  95. { .max = xmax, .texts = xtexts }
  96. #define SOC_VALUE_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmask, xmax, xtexts, xvalues) \
  97. { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
  98. .mask = xmask, .max = xmax, .texts = xtexts, .values = xvalues}
  99. #define SOC_VALUE_ENUM_SINGLE(xreg, xshift, xmask, xmax, xtexts, xvalues) \
  100. SOC_VALUE_ENUM_DOUBLE(xreg, xshift, xshift, xmask, xmax, xtexts, xvalues)
  101. #define SOC_ENUM(xname, xenum) \
  102. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
  103. .info = snd_soc_info_enum_double, \
  104. .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
  105. .private_value = (unsigned long)&xenum }
  106. #define SOC_VALUE_ENUM(xname, xenum) \
  107. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
  108. .info = snd_soc_info_enum_double, \
  109. .get = snd_soc_get_value_enum_double, \
  110. .put = snd_soc_put_value_enum_double, \
  111. .private_value = (unsigned long)&xenum }
  112. #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
  113. xhandler_get, xhandler_put) \
  114. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  115. .info = snd_soc_info_volsw, \
  116. .get = xhandler_get, .put = xhandler_put, \
  117. .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) }
  118. #define SOC_DOUBLE_EXT(xname, xreg, shift_left, shift_right, xmax, xinvert,\
  119. xhandler_get, xhandler_put) \
  120. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  121. .info = snd_soc_info_volsw, \
  122. .get = xhandler_get, .put = xhandler_put, \
  123. .private_value = (unsigned long)&(struct soc_mixer_control) \
  124. {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
  125. .max = xmax, .invert = xinvert} }
  126. #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
  127. xhandler_get, xhandler_put, tlv_array) \
  128. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  129. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  130. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  131. .tlv.p = (tlv_array), \
  132. .info = snd_soc_info_volsw, \
  133. .get = xhandler_get, .put = xhandler_put, \
  134. .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) }
  135. #define SOC_DOUBLE_EXT_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert,\
  136. xhandler_get, xhandler_put, tlv_array) \
  137. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  138. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  139. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  140. .tlv.p = (tlv_array), \
  141. .info = snd_soc_info_volsw, \
  142. .get = xhandler_get, .put = xhandler_put, \
  143. .private_value = (unsigned long)&(struct soc_mixer_control) \
  144. {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
  145. .max = xmax, .invert = xinvert} }
  146. #define SOC_DOUBLE_R_EXT_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert,\
  147. xhandler_get, xhandler_put, tlv_array) \
  148. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  149. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ | \
  150. SNDRV_CTL_ELEM_ACCESS_READWRITE, \
  151. .tlv.p = (tlv_array), \
  152. .info = snd_soc_info_volsw_2r, \
  153. .get = xhandler_get, .put = xhandler_put, \
  154. .private_value = (unsigned long)&(struct soc_mixer_control) \
  155. {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
  156. .max = xmax, .invert = xinvert} }
  157. #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
  158. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  159. .info = snd_soc_info_bool_ext, \
  160. .get = xhandler_get, .put = xhandler_put, \
  161. .private_value = xdata }
  162. #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
  163. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  164. .info = snd_soc_info_enum_ext, \
  165. .get = xhandler_get, .put = xhandler_put, \
  166. .private_value = (unsigned long)&xenum }
  167. /*
  168. * Bias levels
  169. *
  170. * @ON: Bias is fully on for audio playback and capture operations.
  171. * @PREPARE: Prepare for audio operations. Called before DAPM switching for
  172. * stream start and stop operations.
  173. * @STANDBY: Low power standby state when no playback/capture operations are
  174. * in progress. NOTE: The transition time between STANDBY and ON
  175. * should be as fast as possible and no longer than 10ms.
  176. * @OFF: Power Off. No restrictions on transition times.
  177. */
  178. enum snd_soc_bias_level {
  179. SND_SOC_BIAS_ON,
  180. SND_SOC_BIAS_PREPARE,
  181. SND_SOC_BIAS_STANDBY,
  182. SND_SOC_BIAS_OFF,
  183. };
  184. struct snd_jack;
  185. struct snd_soc_card;
  186. struct snd_soc_device;
  187. struct snd_soc_pcm_stream;
  188. struct snd_soc_ops;
  189. struct snd_soc_dai_mode;
  190. struct snd_soc_pcm_runtime;
  191. struct snd_soc_dai;
  192. struct snd_soc_platform;
  193. struct snd_soc_codec;
  194. struct soc_enum;
  195. struct snd_soc_ac97_ops;
  196. struct snd_soc_jack;
  197. struct snd_soc_jack_pin;
  198. #ifdef CONFIG_GPIOLIB
  199. struct snd_soc_jack_gpio;
  200. #endif
  201. typedef int (*hw_write_t)(void *,const char* ,int);
  202. extern struct snd_ac97_bus_ops soc_ac97_ops;
  203. enum snd_soc_control_type {
  204. SND_SOC_CUSTOM,
  205. SND_SOC_I2C,
  206. SND_SOC_SPI,
  207. };
  208. int snd_soc_register_platform(struct snd_soc_platform *platform);
  209. void snd_soc_unregister_platform(struct snd_soc_platform *platform);
  210. int snd_soc_register_codec(struct snd_soc_codec *codec);
  211. void snd_soc_unregister_codec(struct snd_soc_codec *codec);
  212. int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg);
  213. int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
  214. int addr_bits, int data_bits,
  215. enum snd_soc_control_type control);
  216. #ifdef CONFIG_PM
  217. int snd_soc_suspend_device(struct device *dev);
  218. int snd_soc_resume_device(struct device *dev);
  219. #endif
  220. /* pcm <-> DAI connect */
  221. void snd_soc_free_pcms(struct snd_soc_device *socdev);
  222. int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
  223. int snd_soc_init_card(struct snd_soc_device *socdev);
  224. /* set runtime hw params */
  225. int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
  226. const struct snd_pcm_hardware *hw);
  227. /* Jack reporting */
  228. int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type,
  229. struct snd_soc_jack *jack);
  230. void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
  231. int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
  232. struct snd_soc_jack_pin *pins);
  233. #ifdef CONFIG_GPIOLIB
  234. int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
  235. struct snd_soc_jack_gpio *gpios);
  236. void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
  237. struct snd_soc_jack_gpio *gpios);
  238. #endif
  239. /* codec register bit access */
  240. int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
  241. unsigned int mask, unsigned int value);
  242. int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
  243. unsigned int mask, unsigned int value);
  244. int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
  245. struct snd_ac97_bus_ops *ops, int num);
  246. void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
  247. /*
  248. *Controls
  249. */
  250. struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
  251. void *data, char *long_name);
  252. int snd_soc_add_controls(struct snd_soc_codec *codec,
  253. const struct snd_kcontrol_new *controls, int num_controls);
  254. int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
  255. struct snd_ctl_elem_info *uinfo);
  256. int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
  257. struct snd_ctl_elem_info *uinfo);
  258. int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
  259. struct snd_ctl_elem_value *ucontrol);
  260. int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
  261. struct snd_ctl_elem_value *ucontrol);
  262. int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
  263. struct snd_ctl_elem_value *ucontrol);
  264. int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
  265. struct snd_ctl_elem_value *ucontrol);
  266. int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
  267. struct snd_ctl_elem_info *uinfo);
  268. int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
  269. struct snd_ctl_elem_info *uinfo);
  270. #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
  271. int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
  272. struct snd_ctl_elem_value *ucontrol);
  273. int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
  274. struct snd_ctl_elem_value *ucontrol);
  275. int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
  276. struct snd_ctl_elem_info *uinfo);
  277. int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
  278. struct snd_ctl_elem_value *ucontrol);
  279. int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
  280. struct snd_ctl_elem_value *ucontrol);
  281. int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
  282. struct snd_ctl_elem_info *uinfo);
  283. int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
  284. struct snd_ctl_elem_value *ucontrol);
  285. int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
  286. struct snd_ctl_elem_value *ucontrol);
  287. /**
  288. * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
  289. *
  290. * @pin: name of the pin to update
  291. * @mask: bits to check for in reported jack status
  292. * @invert: if non-zero then pin is enabled when status is not reported
  293. */
  294. struct snd_soc_jack_pin {
  295. struct list_head list;
  296. const char *pin;
  297. int mask;
  298. bool invert;
  299. };
  300. /**
  301. * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection
  302. *
  303. * @gpio: gpio number
  304. * @name: gpio name
  305. * @report: value to report when jack detected
  306. * @invert: report presence in low state
  307. * @debouce_time: debouce time in ms
  308. */
  309. #ifdef CONFIG_GPIOLIB
  310. struct snd_soc_jack_gpio {
  311. unsigned int gpio;
  312. const char *name;
  313. int report;
  314. int invert;
  315. int debounce_time;
  316. struct snd_soc_jack *jack;
  317. struct work_struct work;
  318. };
  319. #endif
  320. struct snd_soc_jack {
  321. struct snd_jack *jack;
  322. struct snd_soc_card *card;
  323. struct list_head pins;
  324. int status;
  325. };
  326. /* SoC PCM stream information */
  327. struct snd_soc_pcm_stream {
  328. char *stream_name;
  329. u64 formats; /* SNDRV_PCM_FMTBIT_* */
  330. unsigned int rates; /* SNDRV_PCM_RATE_* */
  331. unsigned int rate_min; /* min rate */
  332. unsigned int rate_max; /* max rate */
  333. unsigned int channels_min; /* min channels */
  334. unsigned int channels_max; /* max channels */
  335. unsigned int active:1; /* stream is in use */
  336. };
  337. /* SoC audio ops */
  338. struct snd_soc_ops {
  339. int (*startup)(struct snd_pcm_substream *);
  340. void (*shutdown)(struct snd_pcm_substream *);
  341. int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
  342. int (*hw_free)(struct snd_pcm_substream *);
  343. int (*prepare)(struct snd_pcm_substream *);
  344. int (*trigger)(struct snd_pcm_substream *, int);
  345. };
  346. /* SoC Audio Codec */
  347. struct snd_soc_codec {
  348. char *name;
  349. struct module *owner;
  350. struct mutex mutex;
  351. struct device *dev;
  352. struct snd_soc_device *socdev;
  353. struct list_head list;
  354. /* callbacks */
  355. int (*set_bias_level)(struct snd_soc_codec *,
  356. enum snd_soc_bias_level level);
  357. /* runtime */
  358. struct snd_card *card;
  359. struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
  360. unsigned int active;
  361. unsigned int pcm_devs;
  362. void *private_data;
  363. /* codec IO */
  364. void *control_data; /* codec control (i2c/3wire) data */
  365. unsigned int (*read)(struct snd_soc_codec *, unsigned int);
  366. int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
  367. int (*display_register)(struct snd_soc_codec *, char *,
  368. size_t, unsigned int);
  369. int (*volatile_register)(unsigned int);
  370. int (*readable_register)(unsigned int);
  371. hw_write_t hw_write;
  372. unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int);
  373. void *reg_cache;
  374. short reg_cache_size;
  375. short reg_cache_step;
  376. /* dapm */
  377. u32 pop_time;
  378. struct list_head dapm_widgets;
  379. struct list_head dapm_paths;
  380. enum snd_soc_bias_level bias_level;
  381. enum snd_soc_bias_level suspend_bias_level;
  382. struct delayed_work delayed_work;
  383. /* codec DAI's */
  384. struct snd_soc_dai *dai;
  385. unsigned int num_dai;
  386. #ifdef CONFIG_DEBUG_FS
  387. struct dentry *debugfs_reg;
  388. struct dentry *debugfs_pop_time;
  389. struct dentry *debugfs_dapm;
  390. #endif
  391. };
  392. /* codec device */
  393. struct snd_soc_codec_device {
  394. int (*probe)(struct platform_device *pdev);
  395. int (*remove)(struct platform_device *pdev);
  396. int (*suspend)(struct platform_device *pdev, pm_message_t state);
  397. int (*resume)(struct platform_device *pdev);
  398. };
  399. /* SoC platform interface */
  400. struct snd_soc_platform {
  401. char *name;
  402. struct list_head list;
  403. int (*probe)(struct platform_device *pdev);
  404. int (*remove)(struct platform_device *pdev);
  405. int (*suspend)(struct snd_soc_dai *dai);
  406. int (*resume)(struct snd_soc_dai *dai);
  407. /* pcm creation and destruction */
  408. int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
  409. struct snd_pcm *);
  410. void (*pcm_free)(struct snd_pcm *);
  411. /* platform stream ops */
  412. struct snd_pcm_ops *pcm_ops;
  413. };
  414. /* SoC machine DAI configuration, glues a codec and cpu DAI together */
  415. struct snd_soc_dai_link {
  416. char *name; /* Codec name */
  417. char *stream_name; /* Stream name */
  418. /* DAI */
  419. struct snd_soc_dai *codec_dai;
  420. struct snd_soc_dai *cpu_dai;
  421. /* machine stream operations */
  422. struct snd_soc_ops *ops;
  423. /* codec/machine specific init - e.g. add machine controls */
  424. int (*init)(struct snd_soc_codec *codec);
  425. /* Symmetry requirements */
  426. unsigned int symmetric_rates:1;
  427. /* Symmetry data - only valid if symmetry is being enforced */
  428. unsigned int rate;
  429. /* DAI pcm */
  430. struct snd_pcm *pcm;
  431. };
  432. /* SoC card */
  433. struct snd_soc_card {
  434. char *name;
  435. struct device *dev;
  436. struct list_head list;
  437. int instantiated;
  438. int (*probe)(struct platform_device *pdev);
  439. int (*remove)(struct platform_device *pdev);
  440. /* the pre and post PM functions are used to do any PM work before and
  441. * after the codec and DAI's do any PM work. */
  442. int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
  443. int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
  444. int (*resume_pre)(struct platform_device *pdev);
  445. int (*resume_post)(struct platform_device *pdev);
  446. /* callbacks */
  447. int (*set_bias_level)(struct snd_soc_card *,
  448. enum snd_soc_bias_level level);
  449. /* CPU <--> Codec DAI links */
  450. struct snd_soc_dai_link *dai_link;
  451. int num_links;
  452. struct snd_soc_device *socdev;
  453. struct snd_soc_codec *codec;
  454. struct snd_soc_platform *platform;
  455. struct delayed_work delayed_work;
  456. struct work_struct deferred_resume_work;
  457. };
  458. /* SoC Device - the audio subsystem */
  459. struct snd_soc_device {
  460. struct device *dev;
  461. struct snd_soc_card *card;
  462. struct snd_soc_codec_device *codec_dev;
  463. void *codec_data;
  464. };
  465. /* runtime channel data */
  466. struct snd_soc_pcm_runtime {
  467. struct snd_soc_dai_link *dai;
  468. struct snd_soc_device *socdev;
  469. };
  470. /* mixer control */
  471. struct soc_mixer_control {
  472. int min, max;
  473. unsigned int reg, rreg, shift, rshift, invert;
  474. };
  475. /* enumerated kcontrol */
  476. struct soc_enum {
  477. unsigned short reg;
  478. unsigned short reg2;
  479. unsigned char shift_l;
  480. unsigned char shift_r;
  481. unsigned int max;
  482. unsigned int mask;
  483. const char **texts;
  484. const unsigned int *values;
  485. void *dapm;
  486. };
  487. /* codec IO */
  488. static inline unsigned int snd_soc_read(struct snd_soc_codec *codec,
  489. unsigned int reg)
  490. {
  491. return codec->read(codec, reg);
  492. }
  493. static inline unsigned int snd_soc_write(struct snd_soc_codec *codec,
  494. unsigned int reg, unsigned int val)
  495. {
  496. return codec->write(codec, reg, val);
  497. }
  498. #include <sound/soc-dai.h>
  499. #endif