soc.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545
  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 <sound/core.h>
  18. #include <sound/pcm.h>
  19. #include <sound/control.h>
  20. #include <sound/ac97_codec.h>
  21. #define SND_SOC_VERSION "0.13.2"
  22. /*
  23. * Convenience kcontrol builders
  24. */
  25. #define SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) \
  26. ((unsigned long)&(struct soc_mixer_control) \
  27. {.reg = xreg, .shift = xshift, .rshift = xshift, .max = xmax, \
  28. .invert = xinvert})
  29. #define SOC_SINGLE_VALUE_EXT(xreg, xmax, xinvert) \
  30. ((unsigned long)&(struct soc_mixer_control) \
  31. {.reg = xreg, .max = xmax, .invert = xinvert})
  32. #define SOC_SINGLE(xname, reg, shift, max, invert) \
  33. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  34. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
  35. .put = snd_soc_put_volsw, \
  36. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
  37. #define SOC_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \
  38. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  39. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  40. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  41. .tlv.p = (tlv_array), \
  42. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw,\
  43. .put = snd_soc_put_volsw, \
  44. .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert) }
  45. #define SOC_DOUBLE(xname, xreg, shift_left, shift_right, xmax, xinvert) \
  46. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  47. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
  48. .put = snd_soc_put_volsw, \
  49. .private_value = (unsigned long)&(struct soc_mixer_control) \
  50. {.reg = xreg, .shift = shift_left, .rshift = shift_right, \
  51. .max = xmax, .invert = xinvert} }
  52. #define SOC_DOUBLE_R(xname, reg_left, reg_right, xshift, xmax, xinvert) \
  53. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \
  54. .info = snd_soc_info_volsw_2r, \
  55. .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
  56. .private_value = (unsigned long)&(struct soc_mixer_control) \
  57. {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
  58. .max = xmax, .invert = xinvert} }
  59. #define SOC_DOUBLE_TLV(xname, xreg, shift_left, shift_right, xmax, xinvert, tlv_array) \
  60. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  61. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  62. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  63. .tlv.p = (tlv_array), \
  64. .info = snd_soc_info_volsw, .get = snd_soc_get_volsw, \
  65. .put = snd_soc_put_volsw, \
  66. .private_value = (unsigned long)&(struct soc_mixer_control) \
  67. {.reg = xreg, .shift = shift_left, .rshift = shift_right,\
  68. .max = xmax, .invert = xinvert} }
  69. #define SOC_DOUBLE_R_TLV(xname, reg_left, reg_right, xshift, xmax, xinvert, tlv_array) \
  70. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname),\
  71. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  72. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  73. .tlv.p = (tlv_array), \
  74. .info = snd_soc_info_volsw_2r, \
  75. .get = snd_soc_get_volsw_2r, .put = snd_soc_put_volsw_2r, \
  76. .private_value = (unsigned long)&(struct soc_mixer_control) \
  77. {.reg = reg_left, .rreg = reg_right, .shift = xshift, \
  78. .max = xmax, .invert = xinvert} }
  79. #define SOC_DOUBLE_S8_TLV(xname, xreg, xmin, xmax, 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_s8, .get = snd_soc_get_volsw_s8, \
  85. .put = snd_soc_put_volsw_s8, \
  86. .private_value = (unsigned long)&(struct soc_mixer_control) \
  87. {.reg = xreg, .min = xmin, .max = xmax} }
  88. #define SOC_ENUM_DOUBLE(xreg, xshift_l, xshift_r, xmax, xtexts) \
  89. { .reg = xreg, .shift_l = xshift_l, .shift_r = xshift_r, \
  90. .max = xmax, .texts = xtexts }
  91. #define SOC_ENUM_SINGLE(xreg, xshift, xmax, xtexts) \
  92. SOC_ENUM_DOUBLE(xreg, xshift, xshift, xmax, xtexts)
  93. #define SOC_ENUM_SINGLE_EXT(xmax, xtexts) \
  94. { .max = xmax, .texts = xtexts }
  95. #define SOC_ENUM(xname, xenum) \
  96. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname,\
  97. .info = snd_soc_info_enum_double, \
  98. .get = snd_soc_get_enum_double, .put = snd_soc_put_enum_double, \
  99. .private_value = (unsigned long)&xenum }
  100. #define SOC_SINGLE_EXT(xname, xreg, xshift, xmax, xinvert,\
  101. xhandler_get, xhandler_put) \
  102. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  103. .info = snd_soc_info_volsw, \
  104. .get = xhandler_get, .put = xhandler_put, \
  105. .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) }
  106. #define SOC_SINGLE_EXT_TLV(xname, xreg, xshift, xmax, xinvert,\
  107. xhandler_get, xhandler_put, tlv_array) \
  108. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  109. .access = SNDRV_CTL_ELEM_ACCESS_TLV_READ |\
  110. SNDRV_CTL_ELEM_ACCESS_READWRITE,\
  111. .tlv.p = (tlv_array), \
  112. .info = snd_soc_info_volsw, \
  113. .get = xhandler_get, .put = xhandler_put, \
  114. .private_value = SOC_SINGLE_VALUE(xreg, xshift, xmax, xinvert) }
  115. #define SOC_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
  116. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  117. .info = snd_soc_info_bool_ext, \
  118. .get = xhandler_get, .put = xhandler_put, \
  119. .private_value = xdata }
  120. #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
  121. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  122. .info = snd_soc_info_enum_ext, \
  123. .get = xhandler_get, .put = xhandler_put, \
  124. .private_value = (unsigned long)&xenum }
  125. /*
  126. * Bias levels
  127. *
  128. * @ON: Bias is fully on for audio playback and capture operations.
  129. * @PREPARE: Prepare for audio operations. Called before DAPM switching for
  130. * stream start and stop operations.
  131. * @STANDBY: Low power standby state when no playback/capture operations are
  132. * in progress. NOTE: The transition time between STANDBY and ON
  133. * should be as fast as possible and no longer than 10ms.
  134. * @OFF: Power Off. No restrictions on transition times.
  135. */
  136. enum snd_soc_bias_level {
  137. SND_SOC_BIAS_ON,
  138. SND_SOC_BIAS_PREPARE,
  139. SND_SOC_BIAS_STANDBY,
  140. SND_SOC_BIAS_OFF,
  141. };
  142. /*
  143. * Digital Audio Interface (DAI) types
  144. */
  145. #define SND_SOC_DAI_AC97 0x1
  146. #define SND_SOC_DAI_I2S 0x2
  147. #define SND_SOC_DAI_PCM 0x4
  148. #define SND_SOC_DAI_AC97_BUS 0x8 /* for custom i.e. non ac97_codec.c */
  149. /*
  150. * DAI hardware audio formats
  151. */
  152. #define SND_SOC_DAIFMT_I2S 0 /* I2S mode */
  153. #define SND_SOC_DAIFMT_RIGHT_J 1 /* Right justified mode */
  154. #define SND_SOC_DAIFMT_LEFT_J 2 /* Left Justified mode */
  155. #define SND_SOC_DAIFMT_DSP_A 3 /* L data msb after FRM or LRC */
  156. #define SND_SOC_DAIFMT_DSP_B 4 /* L data msb during FRM or LRC */
  157. #define SND_SOC_DAIFMT_AC97 5 /* AC97 */
  158. #define SND_SOC_DAIFMT_MSB SND_SOC_DAIFMT_LEFT_J
  159. #define SND_SOC_DAIFMT_LSB SND_SOC_DAIFMT_RIGHT_J
  160. /*
  161. * DAI Gating
  162. */
  163. #define SND_SOC_DAIFMT_CONT (0 << 4) /* continuous clock */
  164. #define SND_SOC_DAIFMT_GATED (1 << 4) /* clock is gated when not Tx/Rx */
  165. /*
  166. * DAI Sync
  167. * Synchronous LR (Left Right) clocks and Frame signals.
  168. */
  169. #define SND_SOC_DAIFMT_SYNC (0 << 5) /* Tx FRM = Rx FRM */
  170. #define SND_SOC_DAIFMT_ASYNC (1 << 5) /* Tx FRM ~ Rx FRM */
  171. /*
  172. * TDM
  173. */
  174. #define SND_SOC_DAIFMT_TDM (1 << 6)
  175. /*
  176. * DAI hardware signal inversions
  177. */
  178. #define SND_SOC_DAIFMT_NB_NF (0 << 8) /* normal bclk + frm */
  179. #define SND_SOC_DAIFMT_NB_IF (1 << 8) /* normal bclk + inv frm */
  180. #define SND_SOC_DAIFMT_IB_NF (2 << 8) /* invert bclk + nor frm */
  181. #define SND_SOC_DAIFMT_IB_IF (3 << 8) /* invert bclk + frm */
  182. /*
  183. * DAI hardware clock masters
  184. * This is wrt the codec, the inverse is true for the interface
  185. * i.e. if the codec is clk and frm master then the interface is
  186. * clk and frame slave.
  187. */
  188. #define SND_SOC_DAIFMT_CBM_CFM (0 << 12) /* codec clk & frm master */
  189. #define SND_SOC_DAIFMT_CBS_CFM (1 << 12) /* codec clk slave & frm master */
  190. #define SND_SOC_DAIFMT_CBM_CFS (2 << 12) /* codec clk master & frame slave */
  191. #define SND_SOC_DAIFMT_CBS_CFS (3 << 12) /* codec clk & frm slave */
  192. #define SND_SOC_DAIFMT_FORMAT_MASK 0x000f
  193. #define SND_SOC_DAIFMT_CLOCK_MASK 0x00f0
  194. #define SND_SOC_DAIFMT_INV_MASK 0x0f00
  195. #define SND_SOC_DAIFMT_MASTER_MASK 0xf000
  196. /*
  197. * Master Clock Directions
  198. */
  199. #define SND_SOC_CLOCK_IN 0
  200. #define SND_SOC_CLOCK_OUT 1
  201. /*
  202. * AC97 codec ID's bitmask
  203. */
  204. #define SND_SOC_DAI_AC97_ID0 (1 << 0)
  205. #define SND_SOC_DAI_AC97_ID1 (1 << 1)
  206. #define SND_SOC_DAI_AC97_ID2 (1 << 2)
  207. #define SND_SOC_DAI_AC97_ID3 (1 << 3)
  208. struct snd_soc_device;
  209. struct snd_soc_pcm_stream;
  210. struct snd_soc_ops;
  211. struct snd_soc_dai_mode;
  212. struct snd_soc_pcm_runtime;
  213. struct snd_soc_dai;
  214. struct snd_soc_codec;
  215. struct snd_soc_machine_config;
  216. struct soc_enum;
  217. struct snd_soc_ac97_ops;
  218. struct snd_soc_clock_info;
  219. typedef int (*hw_write_t)(void *,const char* ,int);
  220. typedef int (*hw_read_t)(void *,char* ,int);
  221. extern struct snd_ac97_bus_ops soc_ac97_ops;
  222. /* pcm <-> DAI connect */
  223. void snd_soc_free_pcms(struct snd_soc_device *socdev);
  224. int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
  225. int snd_soc_register_card(struct snd_soc_device *socdev);
  226. /* set runtime hw params */
  227. int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
  228. const struct snd_pcm_hardware *hw);
  229. /* codec IO */
  230. #define snd_soc_read(codec, reg) codec->read(codec, reg)
  231. #define snd_soc_write(codec, reg, value) codec->write(codec, reg, value)
  232. /* codec register bit access */
  233. int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
  234. unsigned short mask, unsigned short value);
  235. int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
  236. unsigned short mask, unsigned short value);
  237. int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
  238. struct snd_ac97_bus_ops *ops, int num);
  239. void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
  240. /* Digital Audio Interface clocking API.*/
  241. int snd_soc_dai_set_sysclk(struct snd_soc_dai *dai, int clk_id,
  242. unsigned int freq, int dir);
  243. int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai,
  244. int div_id, int div);
  245. int snd_soc_dai_set_pll(struct snd_soc_dai *dai,
  246. int pll_id, unsigned int freq_in, unsigned int freq_out);
  247. /* Digital Audio interface formatting */
  248. int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt);
  249. int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai,
  250. unsigned int mask, int slots);
  251. int snd_soc_dai_set_tristate(struct snd_soc_dai *dai, int tristate);
  252. /* Digital Audio Interface mute */
  253. int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute);
  254. /*
  255. *Controls
  256. */
  257. struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
  258. void *data, char *long_name);
  259. int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
  260. struct snd_ctl_elem_info *uinfo);
  261. int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
  262. struct snd_ctl_elem_info *uinfo);
  263. int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
  264. struct snd_ctl_elem_value *ucontrol);
  265. int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
  266. struct snd_ctl_elem_value *ucontrol);
  267. int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
  268. struct snd_ctl_elem_info *uinfo);
  269. int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
  270. struct snd_ctl_elem_info *uinfo);
  271. #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
  272. int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
  273. struct snd_ctl_elem_value *ucontrol);
  274. int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
  275. struct snd_ctl_elem_value *ucontrol);
  276. int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
  277. struct snd_ctl_elem_info *uinfo);
  278. int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
  279. struct snd_ctl_elem_value *ucontrol);
  280. int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
  281. struct snd_ctl_elem_value *ucontrol);
  282. int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
  283. struct snd_ctl_elem_info *uinfo);
  284. int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
  285. struct snd_ctl_elem_value *ucontrol);
  286. int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
  287. struct snd_ctl_elem_value *ucontrol);
  288. /* SoC PCM stream information */
  289. struct snd_soc_pcm_stream {
  290. char *stream_name;
  291. u64 formats; /* SNDRV_PCM_FMTBIT_* */
  292. unsigned int rates; /* SNDRV_PCM_RATE_* */
  293. unsigned int rate_min; /* min rate */
  294. unsigned int rate_max; /* max rate */
  295. unsigned int channels_min; /* min channels */
  296. unsigned int channels_max; /* max channels */
  297. unsigned int active:1; /* stream is in use */
  298. };
  299. /* SoC audio ops */
  300. struct snd_soc_ops {
  301. int (*startup)(struct snd_pcm_substream *);
  302. void (*shutdown)(struct snd_pcm_substream *);
  303. int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
  304. int (*hw_free)(struct snd_pcm_substream *);
  305. int (*prepare)(struct snd_pcm_substream *);
  306. int (*trigger)(struct snd_pcm_substream *, int);
  307. };
  308. /* ASoC DAI ops */
  309. struct snd_soc_dai_ops {
  310. /* DAI clocking configuration */
  311. int (*set_sysclk)(struct snd_soc_dai *dai,
  312. int clk_id, unsigned int freq, int dir);
  313. int (*set_pll)(struct snd_soc_dai *dai,
  314. int pll_id, unsigned int freq_in, unsigned int freq_out);
  315. int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div);
  316. /* DAI format configuration */
  317. int (*set_fmt)(struct snd_soc_dai *dai, unsigned int fmt);
  318. int (*set_tdm_slot)(struct snd_soc_dai *dai,
  319. unsigned int mask, int slots);
  320. int (*set_tristate)(struct snd_soc_dai *dai, int tristate);
  321. /* digital mute */
  322. int (*digital_mute)(struct snd_soc_dai *dai, int mute);
  323. };
  324. /* SoC DAI (Digital Audio Interface) */
  325. struct snd_soc_dai {
  326. /* DAI description */
  327. char *name;
  328. unsigned int id;
  329. unsigned char type;
  330. /* DAI callbacks */
  331. int (*probe)(struct platform_device *pdev,
  332. struct snd_soc_dai *dai);
  333. void (*remove)(struct platform_device *pdev,
  334. struct snd_soc_dai *dai);
  335. int (*suspend)(struct platform_device *pdev,
  336. struct snd_soc_dai *dai);
  337. int (*resume)(struct platform_device *pdev,
  338. struct snd_soc_dai *dai);
  339. /* ops */
  340. struct snd_soc_ops ops;
  341. struct snd_soc_dai_ops dai_ops;
  342. /* DAI capabilities */
  343. struct snd_soc_pcm_stream capture;
  344. struct snd_soc_pcm_stream playback;
  345. /* DAI runtime info */
  346. struct snd_pcm_runtime *runtime;
  347. struct snd_soc_codec *codec;
  348. unsigned int active;
  349. unsigned char pop_wait:1;
  350. void *dma_data;
  351. /* DAI private data */
  352. void *private_data;
  353. };
  354. /* SoC Audio Codec */
  355. struct snd_soc_codec {
  356. char *name;
  357. struct module *owner;
  358. struct mutex mutex;
  359. /* callbacks */
  360. int (*set_bias_level)(struct snd_soc_codec *,
  361. enum snd_soc_bias_level level);
  362. /* runtime */
  363. struct snd_card *card;
  364. struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
  365. unsigned int active;
  366. unsigned int pcm_devs;
  367. void *private_data;
  368. /* codec IO */
  369. void *control_data; /* codec control (i2c/3wire) data */
  370. unsigned int (*read)(struct snd_soc_codec *, unsigned int);
  371. int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
  372. int (*display_register)(struct snd_soc_codec *, char *,
  373. size_t, unsigned int);
  374. hw_write_t hw_write;
  375. hw_read_t hw_read;
  376. void *reg_cache;
  377. short reg_cache_size;
  378. short reg_cache_step;
  379. /* dapm */
  380. struct list_head dapm_widgets;
  381. struct list_head dapm_paths;
  382. enum snd_soc_bias_level bias_level;
  383. enum snd_soc_bias_level suspend_bias_level;
  384. struct delayed_work delayed_work;
  385. /* codec DAI's */
  386. struct snd_soc_dai *dai;
  387. unsigned int num_dai;
  388. };
  389. /* codec device */
  390. struct snd_soc_codec_device {
  391. int (*probe)(struct platform_device *pdev);
  392. int (*remove)(struct platform_device *pdev);
  393. int (*suspend)(struct platform_device *pdev, pm_message_t state);
  394. int (*resume)(struct platform_device *pdev);
  395. };
  396. /* SoC platform interface */
  397. struct snd_soc_platform {
  398. char *name;
  399. int (*probe)(struct platform_device *pdev);
  400. int (*remove)(struct platform_device *pdev);
  401. int (*suspend)(struct platform_device *pdev,
  402. struct snd_soc_dai *dai);
  403. int (*resume)(struct platform_device *pdev,
  404. struct snd_soc_dai *dai);
  405. /* pcm creation and destruction */
  406. int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
  407. struct snd_pcm *);
  408. void (*pcm_free)(struct snd_pcm *);
  409. /* platform stream ops */
  410. struct snd_pcm_ops *pcm_ops;
  411. };
  412. /* SoC machine DAI configuration, glues a codec and cpu DAI together */
  413. struct snd_soc_dai_link {
  414. char *name; /* Codec name */
  415. char *stream_name; /* Stream name */
  416. /* DAI */
  417. struct snd_soc_dai *codec_dai;
  418. struct snd_soc_dai *cpu_dai;
  419. /* machine stream operations */
  420. struct snd_soc_ops *ops;
  421. /* codec/machine specific init - e.g. add machine controls */
  422. int (*init)(struct snd_soc_codec *codec);
  423. /* DAI pcm */
  424. struct snd_pcm *pcm;
  425. };
  426. /* SoC machine */
  427. struct snd_soc_machine {
  428. char *name;
  429. int (*probe)(struct platform_device *pdev);
  430. int (*remove)(struct platform_device *pdev);
  431. /* the pre and post PM functions are used to do any PM work before and
  432. * after the codec and DAI's do any PM work. */
  433. int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
  434. int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
  435. int (*resume_pre)(struct platform_device *pdev);
  436. int (*resume_post)(struct platform_device *pdev);
  437. /* callbacks */
  438. int (*set_bias_level)(struct snd_soc_machine *,
  439. enum snd_soc_bias_level level);
  440. /* CPU <--> Codec DAI links */
  441. struct snd_soc_dai_link *dai_link;
  442. int num_links;
  443. };
  444. /* SoC Device - the audio subsystem */
  445. struct snd_soc_device {
  446. struct device *dev;
  447. struct snd_soc_machine *machine;
  448. struct snd_soc_platform *platform;
  449. struct snd_soc_codec *codec;
  450. struct snd_soc_codec_device *codec_dev;
  451. struct delayed_work delayed_work;
  452. struct work_struct deferred_resume_work;
  453. void *codec_data;
  454. };
  455. /* runtime channel data */
  456. struct snd_soc_pcm_runtime {
  457. struct snd_soc_dai_link *dai;
  458. struct snd_soc_device *socdev;
  459. };
  460. /* mixer control */
  461. struct soc_mixer_control {
  462. int min, max;
  463. unsigned int reg, rreg, shift, rshift, invert;
  464. };
  465. /* enumerated kcontrol */
  466. struct soc_enum {
  467. unsigned short reg;
  468. unsigned short reg2;
  469. unsigned char shift_l;
  470. unsigned char shift_r;
  471. unsigned int max;
  472. const char **texts;
  473. void *dapm;
  474. };
  475. #endif