soc.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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. /* pcm <-> DAI connect */
  217. void snd_soc_free_pcms(struct snd_soc_device *socdev);
  218. int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
  219. /* Utility functions to get clock rates from various things */
  220. int snd_soc_calc_frame_size(int sample_size, int channels, int tdm_slots);
  221. int snd_soc_params_to_frame_size(struct snd_pcm_hw_params *params);
  222. int snd_soc_calc_bclk(int fs, int sample_size, int channels, int tdm_slots);
  223. int snd_soc_params_to_bclk(struct snd_pcm_hw_params *parms);
  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. int (*jack_status_check)(void);
  319. };
  320. #endif
  321. struct snd_soc_jack {
  322. struct snd_jack *jack;
  323. struct snd_soc_card *card;
  324. struct list_head pins;
  325. int status;
  326. };
  327. /* SoC PCM stream information */
  328. struct snd_soc_pcm_stream {
  329. char *stream_name;
  330. u64 formats; /* SNDRV_PCM_FMTBIT_* */
  331. unsigned int rates; /* SNDRV_PCM_RATE_* */
  332. unsigned int rate_min; /* min rate */
  333. unsigned int rate_max; /* max rate */
  334. unsigned int channels_min; /* min channels */
  335. unsigned int channels_max; /* max channels */
  336. unsigned int active:1; /* stream is in use */
  337. };
  338. /* SoC audio ops */
  339. struct snd_soc_ops {
  340. int (*startup)(struct snd_pcm_substream *);
  341. void (*shutdown)(struct snd_pcm_substream *);
  342. int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
  343. int (*hw_free)(struct snd_pcm_substream *);
  344. int (*prepare)(struct snd_pcm_substream *);
  345. int (*trigger)(struct snd_pcm_substream *, int);
  346. };
  347. /* SoC Audio Codec */
  348. struct snd_soc_codec {
  349. char *name;
  350. struct module *owner;
  351. struct mutex mutex;
  352. struct device *dev;
  353. struct snd_soc_device *socdev;
  354. struct list_head list;
  355. /* callbacks */
  356. int (*set_bias_level)(struct snd_soc_codec *,
  357. enum snd_soc_bias_level level);
  358. /* runtime */
  359. struct snd_card *card;
  360. struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
  361. unsigned int active;
  362. unsigned int pcm_devs;
  363. void *private_data;
  364. /* codec IO */
  365. void *control_data; /* codec control (i2c/3wire) data */
  366. unsigned int (*read)(struct snd_soc_codec *, unsigned int);
  367. int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
  368. int (*display_register)(struct snd_soc_codec *, char *,
  369. size_t, unsigned int);
  370. int (*volatile_register)(unsigned int);
  371. int (*readable_register)(unsigned int);
  372. hw_write_t hw_write;
  373. unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int);
  374. void *reg_cache;
  375. short reg_cache_size;
  376. short reg_cache_step;
  377. /* dapm */
  378. u32 pop_time;
  379. struct list_head dapm_widgets;
  380. struct list_head dapm_paths;
  381. enum snd_soc_bias_level bias_level;
  382. enum snd_soc_bias_level suspend_bias_level;
  383. struct delayed_work delayed_work;
  384. /* codec DAI's */
  385. struct snd_soc_dai *dai;
  386. unsigned int num_dai;
  387. #ifdef CONFIG_DEBUG_FS
  388. struct dentry *debugfs_codec_root;
  389. struct dentry *debugfs_reg;
  390. struct dentry *debugfs_pop_time;
  391. struct dentry *debugfs_dapm;
  392. #endif
  393. };
  394. /* codec device */
  395. struct snd_soc_codec_device {
  396. int (*probe)(struct platform_device *pdev);
  397. int (*remove)(struct platform_device *pdev);
  398. int (*suspend)(struct platform_device *pdev, pm_message_t state);
  399. int (*resume)(struct platform_device *pdev);
  400. };
  401. /* SoC platform interface */
  402. struct snd_soc_platform {
  403. char *name;
  404. struct list_head list;
  405. int (*probe)(struct platform_device *pdev);
  406. int (*remove)(struct platform_device *pdev);
  407. int (*suspend)(struct snd_soc_dai *dai);
  408. int (*resume)(struct snd_soc_dai *dai);
  409. /* pcm creation and destruction */
  410. int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
  411. struct snd_pcm *);
  412. void (*pcm_free)(struct snd_pcm *);
  413. /* platform stream ops */
  414. struct snd_pcm_ops *pcm_ops;
  415. };
  416. /* SoC machine DAI configuration, glues a codec and cpu DAI together */
  417. struct snd_soc_dai_link {
  418. char *name; /* Codec name */
  419. char *stream_name; /* Stream name */
  420. /* DAI */
  421. struct snd_soc_dai *codec_dai;
  422. struct snd_soc_dai *cpu_dai;
  423. /* machine stream operations */
  424. struct snd_soc_ops *ops;
  425. /* codec/machine specific init - e.g. add machine controls */
  426. int (*init)(struct snd_soc_codec *codec);
  427. /* Symmetry requirements */
  428. unsigned int symmetric_rates:1;
  429. /* Symmetry data - only valid if symmetry is being enforced */
  430. unsigned int rate;
  431. /* DAI pcm */
  432. struct snd_pcm *pcm;
  433. };
  434. /* SoC card */
  435. struct snd_soc_card {
  436. char *name;
  437. struct device *dev;
  438. struct list_head list;
  439. int instantiated;
  440. int (*probe)(struct platform_device *pdev);
  441. int (*remove)(struct platform_device *pdev);
  442. /* the pre and post PM functions are used to do any PM work before and
  443. * after the codec and DAI's do any PM work. */
  444. int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
  445. int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
  446. int (*resume_pre)(struct platform_device *pdev);
  447. int (*resume_post)(struct platform_device *pdev);
  448. /* callbacks */
  449. int (*set_bias_level)(struct snd_soc_card *,
  450. enum snd_soc_bias_level level);
  451. /* CPU <--> Codec DAI links */
  452. struct snd_soc_dai_link *dai_link;
  453. int num_links;
  454. struct snd_soc_device *socdev;
  455. struct snd_soc_codec *codec;
  456. struct snd_soc_platform *platform;
  457. struct delayed_work delayed_work;
  458. struct work_struct deferred_resume_work;
  459. };
  460. /* SoC Device - the audio subsystem */
  461. struct snd_soc_device {
  462. struct device *dev;
  463. struct snd_soc_card *card;
  464. struct snd_soc_codec_device *codec_dev;
  465. void *codec_data;
  466. };
  467. /* runtime channel data */
  468. struct snd_soc_pcm_runtime {
  469. struct snd_soc_dai_link *dai;
  470. struct snd_soc_device *socdev;
  471. };
  472. /* mixer control */
  473. struct soc_mixer_control {
  474. int min, max;
  475. unsigned int reg, rreg, shift, rshift, invert;
  476. };
  477. /* enumerated kcontrol */
  478. struct soc_enum {
  479. unsigned short reg;
  480. unsigned short reg2;
  481. unsigned char shift_l;
  482. unsigned char shift_r;
  483. unsigned int max;
  484. unsigned int mask;
  485. const char **texts;
  486. const unsigned int *values;
  487. void *dapm;
  488. };
  489. /* codec IO */
  490. static inline unsigned int snd_soc_read(struct snd_soc_codec *codec,
  491. unsigned int reg)
  492. {
  493. return codec->read(codec, reg);
  494. }
  495. static inline unsigned int snd_soc_write(struct snd_soc_codec *codec,
  496. unsigned int reg, unsigned int val)
  497. {
  498. return codec->write(codec, reg, val);
  499. }
  500. #include <sound/soc-dai.h>
  501. #endif