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