soc.h 17 KB

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