From 02d8a6ee770d5aaebe82290be249192abb6e4808 Mon Sep 17 00:00:00 2001 From: Alan Tull Date: Tue, 6 Apr 2010 08:57:13 -0500 Subject: ENGR00122231 mxs: support read in mxs_pcm_copy to fix record Record was broken by the patch that fixed 24 bit S/PDIF. Signed-off-by: Alan Tull --- sound/soc/mxs/mxs-pcm.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'sound') 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; } -- cgit v1.2.3