summaryrefslogtreecommitdiff
path: root/sound/soc/mxs/mxs-pcm.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/mxs/mxs-pcm.c')
-rw-r--r--sound/soc/mxs/mxs-pcm.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/sound/soc/mxs/mxs-pcm.c b/sound/soc/mxs/mxs-pcm.c
index db3214624c4b..965bbbadafea 100644
--- a/sound/soc/mxs/mxs-pcm.c
+++ b/sound/soc/mxs/mxs-pcm.c
@@ -351,15 +351,21 @@ static int mcs_pcm_copy(struct snd_pcm_substream *substream, int channel,
char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff);
unsigned long count = frames_to_bytes(runtime, frames);
- /* For S/PDIF 24-bit playback, fix the buffer. Code taken
- from snd_pcm_lib_write_transfer() in sound/core/pcm_lib.c */
- if ((prtd->params->dma_ch == MXS_DMA_CHANNEL_AHB_APBX_SPDIF) &&
- ((prtd->format == SNDRV_PCM_FORMAT_S24_LE)
- || (prtd->format == SNDRV_PCM_FORMAT_S20_3LE))) {
- if (copy_from_user(hwbuf + 1, buf, count - 1))
- return -EFAULT;
+ /* For S/PDIF 24-bit playback, fix the buffer. Code taken from
+ snd_pcm_lib_write_transfer() and snd_pcm_lib_read_transfer()
+ in sound/core/pcm_lib.c */
+ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
+ if ((prtd->params->dma_ch == MXS_DMA_CHANNEL_AHB_APBX_SPDIF) &&
+ ((prtd->format == SNDRV_PCM_FORMAT_S24_LE)
+ || (prtd->format == SNDRV_PCM_FORMAT_S20_3LE))) {
+ if (copy_from_user(hwbuf + 1, buf, count - 1))
+ return -EFAULT;
+ } else {
+ if (copy_from_user(hwbuf, buf, count))
+ return -EFAULT;
+ }
} else {
- if (copy_from_user(hwbuf, buf, count))
+ if (copy_to_user(buf, hwbuf, count))
return -EFAULT;
}