samples: intel_s1000: audio buffers in lpsram

Place audio buffers in LPSRAM using linker section attribute
for the 2-way audio sample application

Signed-off-by: Sathish Kuttan <sathish.k.kuttan@intel.com>
This commit is contained in:
Sathish Kuttan 2019-06-09 16:39:27 -07:00 committed by Anas Nashif
parent 32b89b9841
commit 9d5a63b9c1
1 changed files with 5 additions and 19 deletions

View File

@ -18,9 +18,6 @@ LOG_MODULE_REGISTER(audio_io);
#include <audio/dmic.h>
#include "audio_core.h"
#define LP_SRAM_BASE 0xBE800000
#define LP_SRAM_SIZE (16 << 10)
#define DMIC_DEV_NAME "PDM"
#define SPK_OUT_DEV_NAME "I2S_1"
#define HOST_INOUT_DEV_NAME "I2S_2"
@ -46,22 +43,11 @@ LOG_MODULE_REGISTER(audio_io);
static void audio_drv_thread(void *unused1, void *unused2, void *unused3);
static struct _audio_buffers {
__attribute__((section(".dma_buffers"))) static struct {
s32_t host_inout[HOST_INOUT_BUF_COUNT][HOST_FRAME_SAMPLES];
s32_t spk_out[SPK_OUT_BUF_COUNT][SPK_FRAME_SAMPLES];
s32_t mic_in[MIC_IN_BUF_COUNT][MIC_FRAME_SAMPLES];
} *audio_buffers = (struct _audio_buffers *)LP_SRAM_BASE;
#define HOST_AUDIO_BUF_SIZE (HOST_INOUT_BUF_COUNT * HOST_FRAME_SAMPLES)
#define MIC_IN_BUF_SIZE (MIC_IN_BUF_COUNT * MIC_FRAME_SAMPLES)
#define SPK_OUT_BUF_SIZE (SPK_OUT_BUF_COUNT * SPK_FRAME_SAMPLES)
#define PERIPH_AUDIO_BUF_SIZE (SPK_OUT_BUF_SIZE + MIC_IN_BUF_SIZE)
#define TOTAL_AUDIO_BUF_SIZE (PERIPH_AUDIO_BUF_SIZE + HOST_AUDIO_BUF_SIZE)
#if (TOTAL_AUDIO_BUF_SIZE > LP_SRAM_SIZE)
#error "Audio Buffers exceed LP_SRAM_SIZE"
#endif
} audio_buffers;
static struct device *codec_dev;
static struct device *i2s_spk_out_dev;
@ -239,7 +225,7 @@ static void audio_driver_config_host_streams(void)
i2s_cfg.mem_slab = &host_inout_mem_slab;
i2s_cfg.timeout = K_NO_WAIT;
k_mem_slab_init(&host_inout_mem_slab, &audio_buffers->host_inout[0][0],
k_mem_slab_init(&host_inout_mem_slab, &audio_buffers.host_inout[0][0],
HOST_FRAME_BYTES, HOST_INOUT_BUF_COUNT);
/* Configure host input/output I2S */
@ -298,7 +284,7 @@ static void audio_driver_config_periph_streams(void)
},
};
k_mem_slab_init(&mic_in_mem_slab, &audio_buffers->mic_in[0][0],
k_mem_slab_init(&mic_in_mem_slab, &audio_buffers.mic_in[0][0],
MIC_FRAME_BYTES, MIC_IN_BUF_COUNT);
dmic_device = device_get_binding(DMIC_DEV_NAME);
if (!dmic_device) {
@ -332,7 +318,7 @@ static void audio_driver_config_periph_streams(void)
i2s_cfg.block_size = SPK_FRAME_BYTES;
i2s_cfg.mem_slab = &spk_out_mem_slab;
i2s_cfg.timeout = K_NO_WAIT;
k_mem_slab_init(&spk_out_mem_slab, &audio_buffers->spk_out[0][0],
k_mem_slab_init(&spk_out_mem_slab, &audio_buffers.spk_out[0][0],
SPK_FRAME_BYTES, SPK_OUT_BUF_COUNT);
ret = i2s_configure(i2s_spk_out_dev, I2S_DIR_TX, &i2s_cfg);