diff options
author | Charles Keepax <ckeepax@opensource.wolfsonmicro.com> | 2013-04-18 06:03:46 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2013-04-21 03:54:11 -0400 |
commit | f0283b58d01d36910fcd195d1fc365a3356b2be0 (patch) | |
tree | 77e12a473efd6837bdaa239ec81d2be85ff2afd2 /sound | |
parent | ccf17b13ca615a044c980f1e9a94a07b3f99926d (diff) |
ALSA: compress_core: Rework writes to use cumulative values
This patch reworks the writes to use cumulative values thus making the
app_pointer unecessary and removing it.
Only tested as far as build.
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.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 36d7688fe69a..7941ace78283 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c | |||
@@ -28,11 +28,13 @@ | |||
28 | #include <linux/file.h> | 28 | #include <linux/file.h> |
29 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
30 | #include <linux/list.h> | 30 | #include <linux/list.h> |
31 | #include <linux/math64.h> | ||
31 | #include <linux/mm.h> | 32 | #include <linux/mm.h> |
32 | #include <linux/mutex.h> | 33 | #include <linux/mutex.h> |
33 | #include <linux/poll.h> | 34 | #include <linux/poll.h> |
34 | #include <linux/slab.h> | 35 | #include <linux/slab.h> |
35 | #include <linux/sched.h> | 36 | #include <linux/sched.h> |
37 | #include <linux/types.h> | ||
36 | #include <linux/uio.h> | 38 | #include <linux/uio.h> |
37 | #include <linux/uaccess.h> | 39 | #include <linux/uaccess.h> |
38 | #include <linux/module.h> | 40 | #include <linux/module.h> |
@@ -223,21 +225,24 @@ static int snd_compr_write_data(struct snd_compr_stream *stream, | |||
223 | void *dstn; | 225 | void *dstn; |
224 | size_t copy; | 226 | size_t copy; |
225 | struct snd_compr_runtime *runtime = stream->runtime; | 227 | struct snd_compr_runtime *runtime = stream->runtime; |
228 | /* 64-bit Modulus */ | ||
229 | u64 app_pointer = div64_u64(runtime->total_bytes_available, | ||
230 | runtime->buffer_size); | ||
231 | app_pointer = runtime->total_bytes_available - | ||
232 | (app_pointer * runtime->buffer_size); | ||
226 | 233 | ||
227 | dstn = runtime->buffer + runtime->app_pointer; | 234 | dstn = runtime->buffer + app_pointer; |
228 | pr_debug("copying %ld at %lld\n", | 235 | pr_debug("copying %ld at %lld\n", |
229 | (unsigned long)count, runtime->app_pointer); | 236 | (unsigned long)count, app_pointer); |
230 | if (count < runtime->buffer_size - runtime->app_pointer) { | 237 | if (count < runtime->buffer_size - app_pointer) { |
231 | if (copy_from_user(dstn, buf, count)) | 238 | if (copy_from_user(dstn, buf, count)) |
232 | return -EFAULT; | 239 | return -EFAULT; |
233 | runtime->app_pointer += count; | ||
234 | } else { | 240 | } else { |
235 | copy = runtime->buffer_size - runtime->app_pointer; | 241 | copy = runtime->buffer_size - app_pointer; |
236 | if (copy_from_user(dstn, buf, copy)) | 242 | if (copy_from_user(dstn, buf, copy)) |
237 | return -EFAULT; | 243 | return -EFAULT; |
238 | if (copy_from_user(runtime->buffer, buf + copy, count - copy)) | 244 | if (copy_from_user(runtime->buffer, buf + copy, count - copy)) |
239 | return -EFAULT; | 245 | return -EFAULT; |
240 | runtime->app_pointer = count - copy; | ||
241 | } | 246 | } |
242 | /* if DSP cares, let it know data has been written */ | 247 | /* if DSP cares, let it know data has been written */ |
243 | if (stream->ops->ack) | 248 | if (stream->ops->ack) |
@@ -656,7 +661,6 @@ static int snd_compr_stop(struct snd_compr_stream *stream) | |||
656 | if (!retval) { | 661 | if (!retval) { |
657 | stream->runtime->state = SNDRV_PCM_STATE_SETUP; | 662 | stream->runtime->state = SNDRV_PCM_STATE_SETUP; |
658 | wake_up(&stream->runtime->sleep); | 663 | wake_up(&stream->runtime->sleep); |
659 | stream->runtime->app_pointer = 0; | ||
660 | stream->runtime->total_bytes_available = 0; | 664 | stream->runtime->total_bytes_available = 0; |
661 | stream->runtime->total_bytes_transferred = 0; | 665 | stream->runtime->total_bytes_transferred = 0; |
662 | } | 666 | } |