aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorCharles Keepax <ckeepax@opensource.wolfsonmicro.com>2013-04-18 06:02:08 -0400
committerTakashi Iwai <tiwai@suse.de>2013-04-21 03:53:18 -0400
commit49bb6402f1aa1effa9d9c5df39d91a86ca8fd736 (patch)
tree8d61083d6ec99266b14e409e077f40a040b96316 /sound
parent4daf891cdea2eb63b51cb35a3ac12706f8c50156 (diff)
ALSA: compress_core: Add support for capture streams
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.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c
index 52ca4cce1462..52a276510b18 100644
--- a/sound/core/compress_offload.c
+++ b/sound/core/compress_offload.c
@@ -296,7 +296,41 @@ static ssize_t snd_compr_write(struct file *f, const char __user *buf,
296static ssize_t snd_compr_read(struct file *f, char __user *buf, 296static ssize_t snd_compr_read(struct file *f, char __user *buf,
297 size_t count, loff_t *offset) 297 size_t count, loff_t *offset)
298{ 298{
299 return -ENXIO; 299 struct snd_compr_file *data = f->private_data;
300 struct snd_compr_stream *stream;
301 size_t avail;
302 int retval;
303
304 if (snd_BUG_ON(!data))
305 return -EFAULT;
306
307 stream = &data->stream;
308 mutex_lock(&stream->device->lock);
309
310 /* read is allowed when stream is running */
311 if (stream->runtime->state != SNDRV_PCM_STATE_RUNNING) {
312 retval = -EBADFD;
313 goto out;
314 }
315
316 avail = snd_compr_get_avail(stream);
317 pr_debug("avail returned %ld\n", (unsigned long)avail);
318 /* calculate how much we can read from buffer */
319 if (avail > count)
320 avail = count;
321
322 if (stream->ops->copy) {
323 retval = stream->ops->copy(stream, buf, avail);
324 } else {
325 retval = -ENXIO;
326 goto out;
327 }
328 if (retval > 0)
329 stream->runtime->total_bytes_transferred += retval;
330
331out:
332 mutex_unlock(&stream->device->lock);
333 return retval;
300} 334}
301 335
302static int snd_compr_mmap(struct file *f, struct vm_area_struct *vma) 336static int snd_compr_mmap(struct file *f, struct vm_area_struct *vma)
@@ -481,9 +515,14 @@ snd_compr_set_params(struct snd_compr_stream *stream, unsigned long arg)
481 retval = stream->ops->set_params(stream, params); 515 retval = stream->ops->set_params(stream, params);
482 if (retval) 516 if (retval)
483 goto out; 517 goto out;
484 stream->runtime->state = SNDRV_PCM_STATE_SETUP; 518
485 stream->metadata_set = false; 519 stream->metadata_set = false;
486 stream->next_track = false; 520 stream->next_track = false;
521
522 if (stream->direction == SND_COMPRESS_PLAYBACK)
523 stream->runtime->state = SNDRV_PCM_STATE_SETUP;
524 else
525 stream->runtime->state = SNDRV_PCM_STATE_PREPARED;
487 } else { 526 } else {
488 return -EPERM; 527 return -EPERM;
489 } 528 }