soc.h 18 KB

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