From 92f16104bf83f260098e5cbaa9295211a9560efe Mon Sep 17 00:00:00 2001 From: Xing Wang Date: Sun, 8 Apr 2018 22:03:48 +0800 Subject: [PATCH] audio: meson: fix i2s/spdif buffer for split mode when bootup to play PD#162285: audio: meson: fix i2s/spdif buffer for split mode when bootup to play Change-Id: I730993dd183cee40c92d232414d6752f75cb2b06 Signed-off-by: Xing Wang --- sound/soc/amlogic/meson/audio_hw.c | 16 ++++++++++------ sound/soc/amlogic/meson/audio_hw.h | 6 ++++++ sound/soc/amlogic/meson/meson.c | 10 +++++++--- sound/soc/amlogic/meson/spdif_dai.c | 9 ++++++--- 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/sound/soc/amlogic/meson/audio_hw.c b/sound/soc/amlogic/meson/audio_hw.c index 260155dbc460..1132c5da3a42 100644 --- a/sound/soc/amlogic/meson/audio_hw.c +++ b/sound/soc/amlogic/meson/audio_hw.c @@ -236,15 +236,19 @@ 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); +#else aml_aiu_write(AIU_MEM_IEC958_START_PTR, addr & 0xffffffc0); - aml_aiu_write(AIU_MEM_IEC958_RD_PTR, - addr & 0xffffffc0); + aml_aiu_write(AIU_MEM_IEC958_RD_PTR, addr & 0xffffffc0); +#endif if (flag == 0) { /* this is for 16bit 2 channel */ #ifdef CONFIG_AMLOGIC_SND_SPLIT_MODE aml_aiu_write(AIU_MEM_IEC958_END_PTR, - (addr & 0xffffffc0) + - (size & 0xffffffc0) - 8); + (addr & 0xffffff00) + + (size & 0xffffff00) - 256); #else aml_aiu_write(AIU_MEM_IEC958_END_PTR, (addr & 0xffffffc0) + @@ -254,8 +258,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 & 0xffffffc0) + - (size & 0xffffffc0) - 8); + (addr & 0xffffff00) + + (size & 0xffffff00) - 256); #else aml_aiu_write(AIU_MEM_IEC958_END_PTR, (addr & 0xffffffc0) + diff --git a/sound/soc/amlogic/meson/audio_hw.h b/sound/soc/amlogic/meson/audio_hw.h index d8c8471afea9..bd7d3f3e7670 100644 --- a/sound/soc/amlogic/meson/audio_hw.h +++ b/sound/soc/amlogic/meson/audio_hw.h @@ -135,6 +135,12 @@ enum { #define AUDIO_ALGOUT_DAC_FORMAT_DSP 0 #define AUDIO_ALGOUT_DAC_FORMAT_LEFT_JUSTIFY 1 +#ifdef CONFIG_AMLOGIC_SND_SPLIT_MODE +#define DEFAULT_PLAYBACK_SIZE 256 +#else +#define DEFAULT_PLAYBACK_SIZE 64 +#endif + extern unsigned int IEC958_MODE; extern unsigned int I2S_MODE; extern unsigned int audio_in_source; diff --git a/sound/soc/amlogic/meson/meson.c b/sound/soc/amlogic/meson/meson.c index ce3d5b4e1411..af81e4e48969 100644 --- a/sound/soc/amlogic/meson/meson.c +++ b/sound/soc/amlogic/meson/meson.c @@ -55,9 +55,11 @@ #define DRV_NAME "aml_meson_snd_card" -static int i2sbuf[32 + 16]; +static int i2sbuf[DEFAULT_PLAYBACK_SIZE]; static void aml_i2s_play(void) { + int size = DEFAULT_PLAYBACK_SIZE; + audio_util_set_i2s_format(AUDIO_ALGOUT_DAC_FORMAT_DSP); #ifdef CONFIG_AMLOGIC_SND_SPLIT_MODE audio_set_i2s_mode(AIU_I2S_MODE_PCM16, 2); @@ -65,8 +67,10 @@ static void aml_i2s_play(void) audio_set_i2s_mode(AIU_I2S_MODE_PCM16); #endif memset(i2sbuf, 0, sizeof(i2sbuf)); - audio_set_aiubuf((virt_to_phys(i2sbuf) + 63) & (~63), 128, 2, - SNDRV_PCM_FORMAT_S16_LE); + audio_set_aiubuf((virt_to_phys(i2sbuf) + + (DEFAULT_PLAYBACK_SIZE - 1)) + & (~(DEFAULT_PLAYBACK_SIZE - 1)), + size, 2, SNDRV_PCM_FORMAT_S16_LE); audio_out_i2s_enable(1); } diff --git a/sound/soc/amlogic/meson/spdif_dai.c b/sound/soc/amlogic/meson/spdif_dai.c index b2bdaeecdd3a..074ac1492eb0 100644 --- a/sound/soc/amlogic/meson/spdif_dai.c +++ b/sound/soc/amlogic/meson/spdif_dai.c @@ -97,11 +97,12 @@ void aml_spdif_play(int samesrc) { if (!is_meson_tv_chipset()) { uint div = 0; - static int iec958buf[32 + 16]; + static int iec958buf[DEFAULT_PLAYBACK_SIZE]; struct _aiu_958_raw_setting_t set; struct _aiu_958_channel_status_t chstat; struct snd_pcm_substream substream; struct snd_pcm_runtime runtime; + int size = DEFAULT_PLAYBACK_SIZE; substream.runtime = &runtime; runtime.rate = 48000; @@ -141,8 +142,10 @@ void aml_spdif_play(int samesrc) /*clear the same source function as new raw data output */ audio_i2s_958_same_source(samesrc); memset(iec958buf, 0, sizeof(iec958buf)); - audio_set_958outbuf((virt_to_phys(iec958buf) + 63) & (~63), - 128, 0); + audio_set_958outbuf((virt_to_phys(iec958buf) + + (DEFAULT_PLAYBACK_SIZE - 1)) + & (~(DEFAULT_PLAYBACK_SIZE - 1)), + size, 0); audio_set_958_mode(AIU_958_MODE_PCM16, &set); aout_notifier_call_chain(AOUT_EVENT_IEC_60958_PCM, &substream); audio_hw_958_enable(1);