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