diff options
author | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-02-01 13:46:10 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2010-02-03 13:03:37 -0500 |
commit | 8c961bcca1d10be4f2c06375eb561679167653a0 (patch) | |
tree | 568e0371807f25bf09d5948db1b798eb1ec49e01 /sound | |
parent | 0f69d9782c6e6a7b0e60113a850845bc642c3f4e (diff) |
ASoC: Allow CODECs to ask soc-cache to suppress physical writes
Currently the soc-cache code will always write to the device, meaning
that we need the device to be powered and active at pretty much all
times the system is active. Allowing cache only writes lays some
groundwork for future enhancements to allow devices to be put into a
full off state when the audio subsystem is idle.
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Acked-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound')
-rw-r--r-- | sound/soc/soc-cache.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index 097e33510a7a..84b6916db87d 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c | |||
@@ -38,6 +38,10 @@ static int snd_soc_4_12_write(struct snd_soc_codec *codec, unsigned int reg, | |||
38 | 38 | ||
39 | if (reg < codec->reg_cache_size) | 39 | if (reg < codec->reg_cache_size) |
40 | cache[reg] = value; | 40 | cache[reg] = value; |
41 | |||
42 | if (codec->cache_only) | ||
43 | return 0; | ||
44 | |||
41 | ret = codec->hw_write(codec->control_data, data, 2); | 45 | ret = codec->hw_write(codec->control_data, data, 2); |
42 | if (ret == 2) | 46 | if (ret == 2) |
43 | return 0; | 47 | return 0; |
@@ -100,6 +104,10 @@ static int snd_soc_7_9_write(struct snd_soc_codec *codec, unsigned int reg, | |||
100 | 104 | ||
101 | if (reg < codec->reg_cache_size) | 105 | if (reg < codec->reg_cache_size) |
102 | cache[reg] = value; | 106 | cache[reg] = value; |
107 | |||
108 | if (codec->cache_only) | ||
109 | return 0; | ||
110 | |||
103 | ret = codec->hw_write(codec->control_data, data, 2); | 111 | ret = codec->hw_write(codec->control_data, data, 2); |
104 | if (ret == 2) | 112 | if (ret == 2) |
105 | return 0; | 113 | return 0; |
@@ -153,6 +161,9 @@ static int snd_soc_8_8_write(struct snd_soc_codec *codec, unsigned int reg, | |||
153 | if (reg < codec->reg_cache_size) | 161 | if (reg < codec->reg_cache_size) |
154 | cache[reg] = value; | 162 | cache[reg] = value; |
155 | 163 | ||
164 | if (codec->cache_only) | ||
165 | return 0; | ||
166 | |||
156 | if (codec->hw_write(codec->control_data, data, 2) == 2) | 167 | if (codec->hw_write(codec->control_data, data, 2) == 2) |
157 | return 0; | 168 | return 0; |
158 | else | 169 | else |
@@ -181,6 +192,9 @@ static int snd_soc_8_16_write(struct snd_soc_codec *codec, unsigned int reg, | |||
181 | if (!snd_soc_codec_volatile_register(codec, reg)) | 192 | if (!snd_soc_codec_volatile_register(codec, reg)) |
182 | reg_cache[reg] = value; | 193 | reg_cache[reg] = value; |
183 | 194 | ||
195 | if (codec->cache_only) | ||
196 | return 0; | ||
197 | |||
184 | if (codec->hw_write(codec->control_data, data, 3) == 3) | 198 | if (codec->hw_write(codec->control_data, data, 3) == 3) |
185 | return 0; | 199 | return 0; |
186 | else | 200 | else |
@@ -193,10 +207,14 @@ static unsigned int snd_soc_8_16_read(struct snd_soc_codec *codec, | |||
193 | u16 *cache = codec->reg_cache; | 207 | u16 *cache = codec->reg_cache; |
194 | 208 | ||
195 | if (reg >= codec->reg_cache_size || | 209 | if (reg >= codec->reg_cache_size || |
196 | snd_soc_codec_volatile_register(codec, reg)) | 210 | snd_soc_codec_volatile_register(codec, reg)) { |
211 | if (codec->cache_only) | ||
212 | return -EINVAL; | ||
213 | |||
197 | return codec->hw_read(codec, reg); | 214 | return codec->hw_read(codec, reg); |
198 | else | 215 | } else { |
199 | return cache[reg]; | 216 | return cache[reg]; |
217 | } | ||
200 | } | 218 | } |
201 | 219 | ||
202 | #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) | 220 | #if defined(CONFIG_I2C) || (defined(CONFIG_I2C_MODULE) && defined(MODULE)) |
@@ -294,6 +312,10 @@ static int snd_soc_16_8_write(struct snd_soc_codec *codec, unsigned int reg, | |||
294 | reg &= 0xff; | 312 | reg &= 0xff; |
295 | if (reg < codec->reg_cache_size) | 313 | if (reg < codec->reg_cache_size) |
296 | cache[reg] = value; | 314 | cache[reg] = value; |
315 | |||
316 | if (codec->cache_only) | ||
317 | return 0; | ||
318 | |||
297 | ret = codec->hw_write(codec->control_data, data, 3); | 319 | ret = codec->hw_write(codec->control_data, data, 3); |
298 | if (ret == 3) | 320 | if (ret == 3) |
299 | return 0; | 321 | return 0; |