audio: meson: fix spdif buffer size and optimizing copy
authorXing Wang <xing.wang@amlogic.com>
Mon, 23 Apr 2018 10:55:34 +0000 (18:55 +0800)
committerYixun Lan <yixun.lan@amlogic.com>
Wed, 25 Apr 2018 11:17:17 +0000 (04:17 -0700)
PD#164044: audio: meson: fix spdif buffer size and optimizing copy

Change-Id: Ib734b39db7334a332924dd9e100be1d2f865df31
Signed-off-by: Xing Wang <xing.wang@amlogic.com>
sound/soc/amlogic/meson/audio_hw.c
sound/soc/amlogic/meson/i2s.c

index 1132c5d..e23ebe9 100644 (file)
@@ -130,10 +130,12 @@ bool is_audbuf_gate_rm(void)
        return aml_chipinfo.audbuf_gate_rm;
 }
 
+#ifdef CONFIG_AMLOGIC_SND_SPLIT_MODE
 static bool is_split_fully_support(void)
 {
        return aml_chipinfo.split_complete;
 }
+#endif
 
 static bool is_spdif_pao_support(void)
 {
@@ -237,8 +239,8 @@ void audio_set_aiubuf(u32 addr, u32 size, unsigned int channel,
 void audio_set_958outbuf(u32 addr, u32 size, int flag)
 {
 #ifdef CONFIG_AMLOGIC_SND_SPLIT_MODE
-       aml_aiu_write(AIU_MEM_IEC958_START_PTR, addr & 0xffffff00);
-       aml_aiu_write(AIU_MEM_IEC958_RD_PTR, addr & 0xffffff00);
+       aml_aiu_write(AIU_MEM_IEC958_START_PTR, addr & 0xffffffff);
+       aml_aiu_write(AIU_MEM_IEC958_RD_PTR, addr & 0xffffffff);
 #else
        aml_aiu_write(AIU_MEM_IEC958_START_PTR, addr & 0xffffffc0);
        aml_aiu_write(AIU_MEM_IEC958_RD_PTR, addr & 0xffffffc0);
@@ -247,8 +249,8 @@ void audio_set_958outbuf(u32 addr, u32 size, int flag)
                /* this is for 16bit 2 channel */
 #ifdef CONFIG_AMLOGIC_SND_SPLIT_MODE
                aml_aiu_write(AIU_MEM_IEC958_END_PTR,
-                              (addr & 0xffffff00) +
-                              (size & 0xffffff00) - 256);
+                              (addr & 0xffffffff) +
+                              (size & 0xffffffff) - 1);
 #else
                aml_aiu_write(AIU_MEM_IEC958_END_PTR,
                               (addr & 0xffffffc0) +
@@ -258,8 +260,8 @@ void audio_set_958outbuf(u32 addr, u32 size, int flag)
                /* this is for RAW mode */
 #ifdef CONFIG_AMLOGIC_SND_SPLIT_MODE
                aml_aiu_write(AIU_MEM_IEC958_END_PTR,
-                                       (addr & 0xffffff00) +
-                                       (size & 0xffffff00) - 256);
+                                       (addr & 0xffffffff) +
+                                       (size & 0xffffffff) - 1);
 #else
                aml_aiu_write(AIU_MEM_IEC958_END_PTR,
                               (addr & 0xffffffc0) +
index 19cfab1..af1dcbd 100644 (file)
@@ -755,27 +755,27 @@ static int aml_i2s_copy_playback(struct snd_pcm_runtime *runtime, int channel,
        struct aml_runtime_data *prtd = runtime->private_data;
        struct snd_dma_buffer *buffer = &substream->dma_buffer;
        struct aml_audio_buffer *tmp_buf = buffer->private_data;
-       void *ubuf = tmp_buf->buffer_start;
        struct audio_stream *s = &prtd->s;
        struct device *dev = substream->pcm->card->dev;
 #ifndef CONFIG_AMLOGIC_SND_SPLIT_MODE
+       void *ubuf = tmp_buf->buffer_start;
        int i = 0, j = 0;
        int align = runtime->channels * 32;
        int cached_len = tmp_buf->cached_len;
        char *cache_buffer_bytes = tmp_buf->cache_buffer_bytes;
 #endif
-
        n = frames_to_bytes(runtime, count);
        if (n > tmp_buf->buffer_size) {
                dev_err(dev, "FATAL_ERR:UserData/%d > buffer_size/%d\n",
                                n, tmp_buf->buffer_size);
                return -EFAULT;
        }
+
+#ifndef CONFIG_AMLOGIC_SND_SPLIT_MODE
        res = copy_from_user(ubuf, buf, n);
        if (res)
                return -EFAULT;
 
-#ifndef CONFIG_AMLOGIC_SND_SPLIT_MODE
        /*mask align byte(64 or 256)*/
        if ((cached_len != 0 || (n % align) != 0)) {
                int byte_size = n;
@@ -824,7 +824,9 @@ static int aml_i2s_copy_playback(struct snd_pcm_runtime *runtime, int channel,
 
        if (access_ok(VERIFY_READ, buf, frames_to_bytes(runtime, count))) {
 #ifdef CONFIG_AMLOGIC_SND_SPLIT_MODE
-               memcpy(hwbuf, ubuf, n);
+               res = copy_from_user(hwbuf, buf, n);
+               if (res)
+                       return -EFAULT;
 #else
                if (runtime->format == SNDRV_PCM_FORMAT_S16_LE) {
                        int16_t *tfrom, *to;