soc.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535
  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_SINGLE_BOOL_EXT(xname, xdata, xhandler_get, xhandler_put) \
  136. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  137. .info = snd_soc_info_bool_ext, \
  138. .get = xhandler_get, .put = xhandler_put, \
  139. .private_value = xdata }
  140. #define SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \
  141. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \
  142. .info = snd_soc_info_enum_ext, \
  143. .get = xhandler_get, .put = xhandler_put, \
  144. .private_value = (unsigned long)&xenum }
  145. /*
  146. * Bias levels
  147. *
  148. * @ON: Bias is fully on for audio playback and capture operations.
  149. * @PREPARE: Prepare for audio operations. Called before DAPM switching for
  150. * stream start and stop operations.
  151. * @STANDBY: Low power standby state when no playback/capture operations are
  152. * in progress. NOTE: The transition time between STANDBY and ON
  153. * should be as fast as possible and no longer than 10ms.
  154. * @OFF: Power Off. No restrictions on transition times.
  155. */
  156. enum snd_soc_bias_level {
  157. SND_SOC_BIAS_ON,
  158. SND_SOC_BIAS_PREPARE,
  159. SND_SOC_BIAS_STANDBY,
  160. SND_SOC_BIAS_OFF,
  161. };
  162. struct snd_jack;
  163. struct snd_soc_card;
  164. struct snd_soc_device;
  165. struct snd_soc_pcm_stream;
  166. struct snd_soc_ops;
  167. struct snd_soc_dai_mode;
  168. struct snd_soc_pcm_runtime;
  169. struct snd_soc_dai;
  170. struct snd_soc_platform;
  171. struct snd_soc_codec;
  172. struct soc_enum;
  173. struct snd_soc_ac97_ops;
  174. struct snd_soc_jack;
  175. struct snd_soc_jack_pin;
  176. #ifdef CONFIG_GPIOLIB
  177. struct snd_soc_jack_gpio;
  178. #endif
  179. typedef int (*hw_write_t)(void *,const char* ,int);
  180. typedef int (*hw_read_t)(void *,char* ,int);
  181. extern struct snd_ac97_bus_ops soc_ac97_ops;
  182. enum snd_soc_control_type {
  183. SND_SOC_CUSTOM,
  184. SND_SOC_I2C,
  185. SND_SOC_SPI,
  186. };
  187. int snd_soc_register_platform(struct snd_soc_platform *platform);
  188. void snd_soc_unregister_platform(struct snd_soc_platform *platform);
  189. int snd_soc_register_codec(struct snd_soc_codec *codec);
  190. void snd_soc_unregister_codec(struct snd_soc_codec *codec);
  191. int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, int reg);
  192. int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec,
  193. int addr_bits, int data_bits,
  194. enum snd_soc_control_type control);
  195. #ifdef CONFIG_PM
  196. int snd_soc_suspend_device(struct device *dev);
  197. int snd_soc_resume_device(struct device *dev);
  198. #endif
  199. /* pcm <-> DAI connect */
  200. void snd_soc_free_pcms(struct snd_soc_device *socdev);
  201. int snd_soc_new_pcms(struct snd_soc_device *socdev, int idx, const char *xid);
  202. int snd_soc_init_card(struct snd_soc_device *socdev);
  203. /* set runtime hw params */
  204. int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream,
  205. const struct snd_pcm_hardware *hw);
  206. /* Jack reporting */
  207. int snd_soc_jack_new(struct snd_soc_card *card, const char *id, int type,
  208. struct snd_soc_jack *jack);
  209. void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask);
  210. int snd_soc_jack_add_pins(struct snd_soc_jack *jack, int count,
  211. struct snd_soc_jack_pin *pins);
  212. #ifdef CONFIG_GPIOLIB
  213. int snd_soc_jack_add_gpios(struct snd_soc_jack *jack, int count,
  214. struct snd_soc_jack_gpio *gpios);
  215. void snd_soc_jack_free_gpios(struct snd_soc_jack *jack, int count,
  216. struct snd_soc_jack_gpio *gpios);
  217. #endif
  218. /* codec register bit access */
  219. int snd_soc_update_bits(struct snd_soc_codec *codec, unsigned short reg,
  220. unsigned int mask, unsigned int value);
  221. int snd_soc_test_bits(struct snd_soc_codec *codec, unsigned short reg,
  222. unsigned int mask, unsigned int value);
  223. int snd_soc_new_ac97_codec(struct snd_soc_codec *codec,
  224. struct snd_ac97_bus_ops *ops, int num);
  225. void snd_soc_free_ac97_codec(struct snd_soc_codec *codec);
  226. /*
  227. *Controls
  228. */
  229. struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template,
  230. void *data, char *long_name);
  231. int snd_soc_add_controls(struct snd_soc_codec *codec,
  232. const struct snd_kcontrol_new *controls, int num_controls);
  233. int snd_soc_info_enum_double(struct snd_kcontrol *kcontrol,
  234. struct snd_ctl_elem_info *uinfo);
  235. int snd_soc_info_enum_ext(struct snd_kcontrol *kcontrol,
  236. struct snd_ctl_elem_info *uinfo);
  237. int snd_soc_get_enum_double(struct snd_kcontrol *kcontrol,
  238. struct snd_ctl_elem_value *ucontrol);
  239. int snd_soc_put_enum_double(struct snd_kcontrol *kcontrol,
  240. struct snd_ctl_elem_value *ucontrol);
  241. int snd_soc_get_value_enum_double(struct snd_kcontrol *kcontrol,
  242. struct snd_ctl_elem_value *ucontrol);
  243. int snd_soc_put_value_enum_double(struct snd_kcontrol *kcontrol,
  244. struct snd_ctl_elem_value *ucontrol);
  245. int snd_soc_info_volsw(struct snd_kcontrol *kcontrol,
  246. struct snd_ctl_elem_info *uinfo);
  247. int snd_soc_info_volsw_ext(struct snd_kcontrol *kcontrol,
  248. struct snd_ctl_elem_info *uinfo);
  249. #define snd_soc_info_bool_ext snd_ctl_boolean_mono_info
  250. int snd_soc_get_volsw(struct snd_kcontrol *kcontrol,
  251. struct snd_ctl_elem_value *ucontrol);
  252. int snd_soc_put_volsw(struct snd_kcontrol *kcontrol,
  253. struct snd_ctl_elem_value *ucontrol);
  254. int snd_soc_info_volsw_2r(struct snd_kcontrol *kcontrol,
  255. struct snd_ctl_elem_info *uinfo);
  256. int snd_soc_get_volsw_2r(struct snd_kcontrol *kcontrol,
  257. struct snd_ctl_elem_value *ucontrol);
  258. int snd_soc_put_volsw_2r(struct snd_kcontrol *kcontrol,
  259. struct snd_ctl_elem_value *ucontrol);
  260. int snd_soc_info_volsw_s8(struct snd_kcontrol *kcontrol,
  261. struct snd_ctl_elem_info *uinfo);
  262. int snd_soc_get_volsw_s8(struct snd_kcontrol *kcontrol,
  263. struct snd_ctl_elem_value *ucontrol);
  264. int snd_soc_put_volsw_s8(struct snd_kcontrol *kcontrol,
  265. struct snd_ctl_elem_value *ucontrol);
  266. /**
  267. * struct snd_soc_jack_pin - Describes a pin to update based on jack detection
  268. *
  269. * @pin: name of the pin to update
  270. * @mask: bits to check for in reported jack status
  271. * @invert: if non-zero then pin is enabled when status is not reported
  272. */
  273. struct snd_soc_jack_pin {
  274. struct list_head list;
  275. const char *pin;
  276. int mask;
  277. bool invert;
  278. };
  279. /**
  280. * struct snd_soc_jack_gpio - Describes a gpio pin for jack detection
  281. *
  282. * @gpio: gpio number
  283. * @name: gpio name
  284. * @report: value to report when jack detected
  285. * @invert: report presence in low state
  286. * @debouce_time: debouce time in ms
  287. */
  288. #ifdef CONFIG_GPIOLIB
  289. struct snd_soc_jack_gpio {
  290. unsigned int gpio;
  291. const char *name;
  292. int report;
  293. int invert;
  294. int debounce_time;
  295. struct snd_soc_jack *jack;
  296. struct work_struct work;
  297. };
  298. #endif
  299. struct snd_soc_jack {
  300. struct snd_jack *jack;
  301. struct snd_soc_card *card;
  302. struct list_head pins;
  303. int status;
  304. };
  305. /* SoC PCM stream information */
  306. struct snd_soc_pcm_stream {
  307. char *stream_name;
  308. u64 formats; /* SNDRV_PCM_FMTBIT_* */
  309. unsigned int rates; /* SNDRV_PCM_RATE_* */
  310. unsigned int rate_min; /* min rate */
  311. unsigned int rate_max; /* max rate */
  312. unsigned int channels_min; /* min channels */
  313. unsigned int channels_max; /* max channels */
  314. unsigned int active:1; /* stream is in use */
  315. };
  316. /* SoC audio ops */
  317. struct snd_soc_ops {
  318. int (*startup)(struct snd_pcm_substream *);
  319. void (*shutdown)(struct snd_pcm_substream *);
  320. int (*hw_params)(struct snd_pcm_substream *, struct snd_pcm_hw_params *);
  321. int (*hw_free)(struct snd_pcm_substream *);
  322. int (*prepare)(struct snd_pcm_substream *);
  323. int (*trigger)(struct snd_pcm_substream *, int);
  324. };
  325. /* SoC Audio Codec */
  326. struct snd_soc_codec {
  327. char *name;
  328. struct module *owner;
  329. struct mutex mutex;
  330. struct device *dev;
  331. struct snd_soc_device *socdev;
  332. struct list_head list;
  333. /* callbacks */
  334. int (*set_bias_level)(struct snd_soc_codec *,
  335. enum snd_soc_bias_level level);
  336. /* runtime */
  337. struct snd_card *card;
  338. struct snd_ac97 *ac97; /* for ad-hoc ac97 devices */
  339. unsigned int active;
  340. unsigned int pcm_devs;
  341. void *private_data;
  342. /* codec IO */
  343. void *control_data; /* codec control (i2c/3wire) data */
  344. unsigned int (*read)(struct snd_soc_codec *, unsigned int);
  345. int (*write)(struct snd_soc_codec *, unsigned int, unsigned int);
  346. int (*display_register)(struct snd_soc_codec *, char *,
  347. size_t, unsigned int);
  348. int (*volatile_register)(unsigned int);
  349. hw_write_t hw_write;
  350. hw_read_t hw_read;
  351. void *reg_cache;
  352. short reg_cache_size;
  353. short reg_cache_step;
  354. /* dapm */
  355. u32 pop_time;
  356. struct list_head dapm_widgets;
  357. struct list_head dapm_paths;
  358. enum snd_soc_bias_level bias_level;
  359. enum snd_soc_bias_level suspend_bias_level;
  360. struct delayed_work delayed_work;
  361. /* codec DAI's */
  362. struct snd_soc_dai *dai;
  363. unsigned int num_dai;
  364. #ifdef CONFIG_DEBUG_FS
  365. struct dentry *debugfs_reg;
  366. struct dentry *debugfs_pop_time;
  367. #endif
  368. };
  369. /* codec device */
  370. struct snd_soc_codec_device {
  371. int (*probe)(struct platform_device *pdev);
  372. int (*remove)(struct platform_device *pdev);
  373. int (*suspend)(struct platform_device *pdev, pm_message_t state);
  374. int (*resume)(struct platform_device *pdev);
  375. };
  376. /* SoC platform interface */
  377. struct snd_soc_platform {
  378. char *name;
  379. struct list_head list;
  380. int (*probe)(struct platform_device *pdev);
  381. int (*remove)(struct platform_device *pdev);
  382. int (*suspend)(struct snd_soc_dai *dai);
  383. int (*resume)(struct snd_soc_dai *dai);
  384. /* pcm creation and destruction */
  385. int (*pcm_new)(struct snd_card *, struct snd_soc_dai *,
  386. struct snd_pcm *);
  387. void (*pcm_free)(struct snd_pcm *);
  388. /* platform stream ops */
  389. struct snd_pcm_ops *pcm_ops;
  390. };
  391. /* SoC machine DAI configuration, glues a codec and cpu DAI together */
  392. struct snd_soc_dai_link {
  393. char *name; /* Codec name */
  394. char *stream_name; /* Stream name */
  395. /* DAI */
  396. struct snd_soc_dai *codec_dai;
  397. struct snd_soc_dai *cpu_dai;
  398. /* machine stream operations */
  399. struct snd_soc_ops *ops;
  400. /* codec/machine specific init - e.g. add machine controls */
  401. int (*init)(struct snd_soc_codec *codec);
  402. /* Symmetry requirements */
  403. unsigned int symmetric_rates:1;
  404. /* Symmetry data - only valid if symmetry is being enforced */
  405. unsigned int rate;
  406. /* DAI pcm */
  407. struct snd_pcm *pcm;
  408. };
  409. /* SoC card */
  410. struct snd_soc_card {
  411. char *name;
  412. struct device *dev;
  413. struct list_head list;
  414. int instantiated;
  415. int (*probe)(struct platform_device *pdev);
  416. int (*remove)(struct platform_device *pdev);
  417. /* the pre and post PM functions are used to do any PM work before and
  418. * after the codec and DAI's do any PM work. */
  419. int (*suspend_pre)(struct platform_device *pdev, pm_message_t state);
  420. int (*suspend_post)(struct platform_device *pdev, pm_message_t state);
  421. int (*resume_pre)(struct platform_device *pdev);
  422. int (*resume_post)(struct platform_device *pdev);
  423. /* callbacks */
  424. int (*set_bias_level)(struct snd_soc_card *,
  425. enum snd_soc_bias_level level);
  426. /* CPU <--> Codec DAI links */
  427. struct snd_soc_dai_link *dai_link;
  428. int num_links;
  429. struct snd_soc_device *socdev;
  430. struct snd_soc_codec *codec;
  431. struct snd_soc_platform *platform;
  432. struct delayed_work delayed_work;
  433. struct work_struct deferred_resume_work;
  434. };
  435. /* SoC Device - the audio subsystem */
  436. struct snd_soc_device {
  437. struct device *dev;
  438. struct snd_soc_card *card;
  439. struct snd_soc_codec_device *codec_dev;
  440. void *codec_data;
  441. };
  442. /* runtime channel data */
  443. struct snd_soc_pcm_runtime {
  444. struct snd_soc_dai_link *dai;
  445. struct snd_soc_device *socdev;
  446. };
  447. /* mixer control */
  448. struct soc_mixer_control {
  449. int min, max;
  450. unsigned int reg, rreg, shift, rshift, invert;
  451. };
  452. /* enumerated kcontrol */
  453. struct soc_enum {
  454. unsigned short reg;
  455. unsigned short reg2;
  456. unsigned char shift_l;
  457. unsigned char shift_r;
  458. unsigned int max;
  459. unsigned int mask;
  460. const char **texts;
  461. const unsigned int *values;
  462. void *dapm;
  463. };
  464. /* codec IO */
  465. static inline unsigned int snd_soc_read(struct snd_soc_codec *codec,
  466. unsigned int reg)
  467. {
  468. return codec->read(codec, reg);
  469. }
  470. static inline unsigned int snd_soc_write(struct snd_soc_codec *codec,
  471. unsigned int reg, unsigned int val)
  472. {
  473. return codec->write(codec, reg, val);
  474. }
  475. #include <sound/soc-dai.h>
  476. #endif