aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2013-04-18 05:59:23 -0400
committerTakashi Iwai <tiwai@suse.de>2013-04-21 03:52:23 -0400
commit4c28e32d6c4da1d2bc92d3062690e770c18493e6 (patch)
treebf310ae5beff3de311f5fe50e55f29d70869884f /sound
parent8dd2b66d1a961231685a3bfe5937c85d846fbf5d (diff)
ALSA: compress_core: Update calc_avail to use cumulative values
The app_pointer is managed locally by the compress core for memory mapped DSPs but for DSPs that are not memory mapped this would have to be manually updated from within the DSP driver itself, which is hardly very idiomatic. This patch switches to using the cumulative values to calculate the available buffer space because these are already gracefully passed out of the DSP driver to the compress core and otherwise should be functionally equivalent. Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com> Signed-off-by: Richard Fitzgerald <rf@opensource.wolfsonmicro.com> Acked-by: Vinod Koul <vinod.koul@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/core/compress_offload.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index c84abc886e90..27bd81ad2841 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -160,8 +160,6 @@ static int snd_compr_update_tstamp(struct snd_compr_stream *stream,
160static size_t snd_compr_calc_avail(struct snd_compr_stream *stream, 160static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
161 struct snd_compr_avail *avail) 161 struct snd_compr_avail *avail)
162{ 162{
163 long avail_calc; /*this needs to be signed variable */
164
165 memset(avail, 0, sizeof(*avail)); 163 memset(avail, 0, sizeof(*avail));
166 snd_compr_update_tstamp(stream, &avail->tstamp); 164 snd_compr_update_tstamp(stream, &avail->tstamp);
167 /* Still need to return avail even if tstamp can't be filled in */ 165 /* Still need to return avail even if tstamp can't be filled in */
@@ -184,22 +182,11 @@ static size_t snd_compr_calc_avail(struct snd_compr_stream *stream,
184 return stream->runtime->buffer_size; 182 return stream->runtime->buffer_size;
185 } 183 }
186 184
187 /* FIXME: this routine isn't consistent, in one test we use 185 avail->avail = stream->runtime->buffer_size -
188 * cumulative values and in the other byte offsets. Do we 186 (stream->runtime->total_bytes_available -
189 * really need the byte offsets if the cumulative values have 187 stream->runtime->total_bytes_transferred);
190 * been updated? In the PCM interface app_ptr and hw_ptr are 188 pr_debug("ret avail as %lld\n", avail->avail);
191 * already cumulative */ 189 return avail->avail;
192
193 avail_calc = stream->runtime->buffer_size -
194 (stream->runtime->app_pointer - stream->runtime->hw_pointer);
195 pr_debug("calc avail as %ld, app_ptr %lld, hw+ptr %lld\n", avail_calc,
196 stream->runtime->app_pointer,
197 stream->runtime->hw_pointer);
198 if (avail_calc >= stream->runtime->buffer_size)
199 avail_calc -= stream->runtime->buffer_size;
200 pr_debug("ret avail as %ld\n", avail_calc);
201 avail->avail = avail_calc;
202 return avail_calc;
203} 190}
204 191
205static inline size_t snd_compr_get_avail(struct snd_compr_stream *stream) 192static inline size_t snd_compr_get_avail(struct snd_compr_stream *stream)