From 04a535d508e60e4dbfeccb07b362d8f5d4f8cbf1 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 27 Sep 2016 17:29:55 +0100 Subject: [PATCH 001/324] rimage: Initial import of rimage firmware tool. rimage converts ELF binaries to the firmware image file format understood by the kernel audio drivers. Signed-off-by: Liam Girdwood --- .gitignore | 18 +++ Makefile.am | 1 + README | 36 +++++ autogen.sh | 6 + configure.ac | 26 ++++ rimage/Makefile.am | 10 ++ rimage/baytrail.c | 250 ++++++++++++++++++++++++++++++++++ rimage/cherrytrail.c | 58 ++++++++ rimage/file_format.h | 88 ++++++++++++ rimage/flat.c | 256 +++++++++++++++++++++++++++++++++++ rimage/rimage.c | 312 ++++++++++++++++++++++++++++++++++++++++++ rimage/rimage.h | 105 +++++++++++++++ rmbox/Makefile.am | 4 + rmbox/rmbox.c | 315 +++++++++++++++++++++++++++++++++++++++++++ 14 files changed, 1485 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile.am create mode 100644 README create mode 100755 autogen.sh create mode 100644 configure.ac create mode 100644 rimage/Makefile.am create mode 100644 rimage/baytrail.c create mode 100644 rimage/cherrytrail.c create mode 100644 rimage/file_format.h create mode 100644 rimage/flat.c create mode 100644 rimage/rimage.c create mode 100644 rimage/rimage.h create mode 100644 rmbox/Makefile.am create mode 100644 rmbox/rmbox.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000000..145a58d68714 --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +*.o +*.in +autom4te* +*.Po +*.swp +Makefile +config.* +configure +depcomp +install-sh +missing +stamp-h1 +aclocal.m4 +compile +ltmain.sh +rimage/rimage +rmbox/rmbox +rwav/rwav diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 000000000000..3373168af85c --- /dev/null +++ b/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = rimage rmbox diff --git a/README b/README new file mode 100644 index 000000000000..4eca4b532177 --- /dev/null +++ b/README @@ -0,0 +1,36 @@ +Sound Open Firmware Tools +========================= + +This is a collection of open source tools used to develop open source audio +DSP firmwares for ALSA. + +Building and Installing +======================= + +./autogen.sh (only needed first time) +./configure +make +make install + + +rimage +====== + +rimage is used to convert ELF executable firmware files to the firmware file +formats used by the kernel drivers. + +e.g. + +rimage -i elf_file -o kernel_file -m machine + +rimage can also convert kernel firmware formats to flat binaries formats to +assist in debugging :- + +e.g. convert to flat binary, then ELF then dissasemble + +rimage -i /lib/firmware/intel/reef-byt.ri -o image.bin -b -m byt + +xtensa-byt-elf-objcopy -I binary -O elf32-xtensa-le -B xtensa image.bin image.bin.elf + +xtensa-byt-elf-objdump -D image.bin.elf > image.dis.txt + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 000000000000..3b379b6014f2 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,6 @@ +#!/bin/bash +libtoolize -c --force +aclocal -I m4 --install +autoconf -Wall +autoheader +automake -a --copy --foreign --add-missing diff --git a/configure.ac b/configure.ac new file mode 100644 index 000000000000..b3d4473bfc3b --- /dev/null +++ b/configure.ac @@ -0,0 +1,26 @@ + +AC_PREREQ([2.69]) +AC_INIT([rimage], [0.1]) +AM_INIT_AUTOMAKE([foreign]) +AC_CONFIG_SRCDIR([rimage/rimage.c]) +AC_CONFIG_HEADERS([config.h]) + +AC_CANONICAL_HOST + +dnl Initialize maintainer mode +AM_MAINTAINER_MODE([enable]) + +AC_PROG_CC + +AC_OUTPUT([ + Makefile + rimage/Makefile + rmbox/Makefile +]) + +echo " + +prefix: ${prefix} +Compiler: ${CC} +CFLAGS: ${CFLAGS} +" \ No newline at end of file diff --git a/rimage/Makefile.am b/rimage/Makefile.am new file mode 100644 index 000000000000..32335fe68957 --- /dev/null +++ b/rimage/Makefile.am @@ -0,0 +1,10 @@ +bin_PROGRAMS = rimage + +noinst_HEADERS = \ + rimage.h + +rimage_SOURCES = \ + cherrytrail.c \ + baytrail.c \ + flat.c \ + rimage.c \ No newline at end of file diff --git a/rimage/baytrail.c b/rimage/baytrail.c new file mode 100644 index 000000000000..0053f97dfab7 --- /dev/null +++ b/rimage/baytrail.c @@ -0,0 +1,250 @@ +/* + * ELF to firmware image creator. + * + * Copyright (c) 2015, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + + +#include +#include +#include +#include +#include + +#include "rimage.h" +#include "file_format.h" + +/* taken from the linker scripts */ +static const struct section byt_sections[] = { + {"ResetVector", 0xff2c0000, 0x2e0}, + {"ResetVector.literal", 0xff2c02e0, 0x120}, + {"WindowVectors", 0xff2c0400, 0x178}, + {"Level2InterruptVector.literal", 0xff2c0578, 0x4}, + {"Level2InterruptVector", 0xff2c057c, 0x1c}, + {"Level3InterruptVector.literal", 0xff2c0598, 0x4}, + {"Level3InterruptVector", 0xff2c059c, 0x1c}, + {"Level4InterruptVector.literal", 0xff2c05b8, 0x4}, + {"Level4InterruptVector", 0xff2c05bc, 0x1c}, + {"Level5InterruptVector.literal", 0xff2c05d8, 0x4}, + {"Level5InterruptVector", 0xff2c05dc, 0x1c}, + {"DebugInterruptVector.literal", 0xff2c05d8, 0x4}, + {"NMIExceptionVector", 0xff2c061c}, +}; + +static const enum reef_module_id modules[] = { + REEF_MODULE_BASE_FW, + REEF_MODULE_AAC_5_1, + REEF_MODULE_PCM, + REEF_MODULE_PCM_SYSTEM, + REEF_MODULE_PCM_CAPTURE, + REEF_MODULE_PCM_REFERENCE, + REEF_MODULE_BLUETOOTH_RENDER_MODULE, + REEF_MODULE_BLUETOOTH_CAPTURE_MODULE, +}; + +static int is_iram(struct image *image, Elf32_Shdr *section) +{ + const struct adsp *adsp = image->adsp; + uint32_t start, end; + + start = section->sh_addr; + end = section->sh_addr + section->sh_size; + + if (start < adsp->iram_base) + return 0; + if (start >= adsp->iram_base + adsp->iram_size) + return 0; + return 1; +} + +static int is_dram(struct image *image, Elf32_Shdr *section) +{ + const struct adsp *adsp = image->adsp; + uint32_t start, end; + + start = section->sh_addr; + end = section->sh_addr + section->sh_size; + + if (start < adsp->dram_base) + return 0; + if (start >= adsp->dram_base + adsp->dram_size) + return 0; + return 1; +} + +static int block_idx = 0; + +static int write_block(struct image *image, Elf32_Shdr *section) +{ + const struct adsp *adsp = image->adsp; + struct dma_block_info block; + size_t count; + void *buffer; + int ret; + + block.size = section->sh_size; + + if (is_iram(image, section)) { + block.type = REEF_IRAM; + block.ram_offset = section->sh_addr - adsp->iram_base; + } else if (is_dram(image, section)) { + block.type = REEF_DRAM; + block.ram_offset = section->sh_addr - adsp->dram_base; + } else { + fprintf(stderr, "error: invalid block address/size 0x%x/0x%x\n", + section->sh_addr, section->sh_size); + return -EINVAL; + } + + /* write header */ + count = fwrite(&block, sizeof(block), 1, image->out_fd); + if (count != 1) + return -errno; + + /* alloc data data */ + buffer = calloc(1, section->sh_size); + if (buffer == NULL) + return -ENOMEM; + + /* read in section data */ + ret = fseek(image->in_fd, section->sh_offset, SEEK_SET); + if (ret < 0) { + fprintf(stderr, "error: cant seek to section %d\n", ret); + goto out; + } + count = fread(buffer, 1, section->sh_size, image->in_fd); + if (count != section->sh_size) { + fprintf(stderr, "error: cant read section %d\n", -errno); + ret = -errno; + goto out; + } + + /* write out section data */ + count = fwrite(buffer, 1, section->sh_size, image->out_fd); + if (count != section->sh_size) { + fprintf(stderr, "error: cant write section %d\n", -errno); + fprintf(stderr, " foffset %d size 0x%x mem addr 0x%x\n", + section->sh_offset, section->sh_size, section->sh_addr); + ret = -errno; + goto out; + } + + if (image->verbose) { + fprintf(stdout, "block: %d\n foffset %d\n size 0x%x\n mem addr 0x%x\n", + block_idx++, section->sh_offset, section->sh_size, + section->sh_addr); + } + +out: + free(buffer); + return ret; +} + +/* used by others */ +int byt_write_modules(struct image *image) +{ + const struct adsp *adsp = image->adsp; + struct byt_module_header hdr; + Elf32_Shdr *section; + size_t count; + int i, err; + uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); + + memcpy(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE); + hdr.blocks = image->num_sections - image->num_bss; + hdr.mod_size = image->text_size + image->data_size + \ + sizeof(struct dma_block_info) * hdr.blocks; + hdr.type = REEF_MODULE_BASE_FW; + hdr.entry_point = 0;//section->sh_addr; + + count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); + if (count != 1) { + fprintf(stderr, "error: failed to write section header %d\n", i); + return -errno ; + } + + for (i = 0; i < image->hdr.e_shnum; i++) { + + section = &image->section[i]; + + /* only write valid sections */ + if (!(image->section[i].sh_flags & valid)) + continue; + + /* dont write bss */ + if (section->sh_type == SHT_NOBITS) + continue; + + err = write_block(image, section); + if (err < 0) { + fprintf(stderr, "error: failed to write section #%d\n", i); + return err; + } + } + + /* write the remaining 7 fake modules headers, to make the linux driver happy */ + hdr.mod_size = 0; + hdr.blocks = 0; + + for (i = 1; i < sizeof(modules) / sizeof(modules[0]); i++) { + hdr.type = modules[i]; + count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); + if (count != 1) { + fprintf(stderr, "error: failed to write section header %d\n", i); + return -errno ; + } + } + + return 0; +} + +/* used by others */ +int byt_write_header(struct image *image) +{ + struct fw_header hdr; + size_t count; + + memcpy(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE); + + hdr.modules = sizeof(modules) / sizeof(modules[0]); + hdr.file_format = 0; + + image->fw_size += sizeof(struct dma_block_info) * + (image->num_sections - image->num_bss); + image->fw_size += sizeof(struct byt_module_header) * hdr.modules; + hdr.file_size = image->fw_size; + + fprintf(stdout, "fw: image size %ld (0x%lx) bytes %d modules\n\n", + hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), + hdr.modules); + count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); + if (count != 1) + return -errno; + + return 0; +} + +const struct adsp byt_machine = { + .name = "byt", + .iram_base = 0xff2c0000, + .iram_size = 0x14000, + .dram_base = 0xff300000, + .dram_size = 0x28000, + .image_size = 0xff300000 - 0xff2c0000 + 0x28000, + .dram_offset = 0xff300000 - 0xff2c0000, + .machine_id = MACHINE_BAYTRAIL, + .ops = { + .write_header = byt_write_header, + .write_modules = byt_write_modules, + }, + .sections = byt_sections, +}; diff --git a/rimage/cherrytrail.c b/rimage/cherrytrail.c new file mode 100644 index 000000000000..a37a13db2353 --- /dev/null +++ b/rimage/cherrytrail.c @@ -0,0 +1,58 @@ +/* + * ELF to firmware image creator. + * + * Copyright (c) 2015, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + + +#include +#include +#include +#include +#include + +#include "rimage.h" +#include "file_format.h" + +/* TODO: need to config CHT values */ +static const struct section cht_sections[] = { + {"ResetVector", 0xff2c0000, 0x2e0}, + {"ResetVector.literal", 0xff2c02e0, 0x120}, + {"WindowVectors", 0xff2c0400, 0x178}, + {"Level2InterruptVector.literal", 0xff2c0578, 0x4}, + {"Level2InterruptVector", 0xff2c057c, 0x1c}, + {"Level3InterruptVector.literal", 0xff2c0598, 0x4}, + {"Level3InterruptVector", 0xff2c059c, 0x1c}, + {"Level4InterruptVector.literal", 0xff2c05b8, 0x4}, + {"Level4InterruptVector", 0xff2c05bc, 0x1c}, + {"Level5InterruptVector.literal", 0xff2c05d8, 0x4}, + {"Level5InterruptVector", 0xff2c05dc, 0x1c}, + {"DebugInterruptVector.literal", 0xff2c05d8, 0x4}, + {"NMIExceptionVector", 0xff2c061c}, +}; + +const struct adsp cht_machine = { + .name = "cht", + .iram_base = 0xff2c0000, + .iram_size = 0x14000, + .dram_base = 0xff300000, + .dram_size = 0x28000, + .image_size = 0xff300000 - 0xff2c0000 + 0x28000, + .dram_offset = 0xff300000 - 0xff2c0000, + .machine_id = MACHINE_CHERRYTRAIL, + .ops = { + .write_header = byt_write_header, + .write_modules = byt_write_modules, + }, + .sections = cht_sections, +}; + diff --git a/rimage/file_format.h b/rimage/file_format.h new file mode 100644 index 000000000000..941df332549f --- /dev/null +++ b/rimage/file_format.h @@ -0,0 +1,88 @@ +/* + * ELF to firmware image creator. + * + * Copyright (c) 2015, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef __FILE_FORMAT_H__ +#define __FILE_FORMAT_H__ + +#define REEF_FW_SIGNATURE_SIZE 4 +#define REEF_FW_SIGN "$SST" +#define REEF_FW_LIB_SIGN "$LIB" + +#define REEF_IRAM 1 +#define REEF_DRAM 2 +#define REEF_REGS 3 +#define REEF_CACHE 3 + +enum reef_module_id { + REEF_MODULE_BASE_FW = 0x0, + REEF_MODULE_MP3 = 0x1, + REEF_MODULE_AAC_5_1 = 0x2, + REEF_MODULE_AAC_2_0 = 0x3, + REEF_MODULE_SRC = 0x4, + REEF_MODULE_WAVES = 0x5, + REEF_MODULE_DOLBY = 0x6, + REEF_MODULE_BOOST = 0x7, + REEF_MODULE_LPAL = 0x8, + REEF_MODULE_DTS = 0x9, + REEF_MODULE_PCM_CAPTURE = 0xA, + REEF_MODULE_PCM_SYSTEM = 0xB, + REEF_MODULE_PCM_REFERENCE = 0xC, + REEF_MODULE_PCM = 0xD, + REEF_MODULE_BLUETOOTH_RENDER_MODULE = 0xE, + REEF_MODULE_BLUETOOTH_CAPTURE_MODULE = 0xF, + REEF_MAX_MODULE_ID, +}; + +struct dma_block_info { + uint32_t type; /* IRAM/DRAM */ + uint32_t size; /* Bytes */ + uint32_t ram_offset; /* Offset in I/DRAM */ + uint32_t rsvd; /* Reserved field */ +} __attribute__((packed)); + +struct fw_module_info { + uint32_t persistent_size; + uint32_t scratch_size; +} __attribute__((packed)); + +struct fw_header { + unsigned char signature[REEF_FW_SIGNATURE_SIZE]; /* FW signature */ + uint32_t file_size; /* size of fw minus this header */ + uint32_t modules; /* # of modules */ + uint32_t file_format; /* version of header format */ + uint32_t reserved[4]; +} __attribute__((packed)); + +/* ABI 0 - used by reef driver and CoE BDW/HSW firmware*/ +struct hsw_module_header { + unsigned char signature[REEF_FW_SIGNATURE_SIZE]; /* module signature */ + uint32_t mod_size; /* size of module */ + uint32_t blocks; /* # of blocks */ + uint16_t padding; + uint16_t type; /* codec type, pp lib */ + uint32_t entry_point; + struct fw_module_info info; +} __attribute__((packed)); + +/* ABI 1 - used by CoE/MCG BYT/CHT/BSW driver */ +struct byt_module_header { + unsigned char signature[REEF_FW_SIGNATURE_SIZE]; + uint32_t mod_size; /* size of module */ + uint32_t blocks; /* # of blocks */ + uint32_t type; /* codec type, pp lib */ + uint32_t entry_point; +}__attribute__((packed)); + +#endif diff --git a/rimage/flat.c b/rimage/flat.c new file mode 100644 index 000000000000..8c5d1c58b557 --- /dev/null +++ b/rimage/flat.c @@ -0,0 +1,256 @@ +/* + * ELF to firmware image creator. + * + * Copyright (c) 2015, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include + +#include "rimage.h" +#include "file_format.h" + +static int dump_section(struct image *image, struct dma_block_info *block, + void *data) +{ + const struct adsp *adsp = image->adsp; + uint32_t addr; + + switch (block->type) { + case REEF_IRAM: + addr = block->ram_offset + adsp->iram_base; + break; + case REEF_DRAM: + addr = block->ram_offset + adsp->dram_base; + break; + case REEF_CACHE: + addr = block->ram_offset + adsp->dram_base; + break; + default: + return -EINVAL; + } +} + +static int read_byt_bin_module(struct image *image, + struct byt_module_header *module) +{ + const struct adsp *adsp = image->adsp; + struct dma_block_info *block; + int count, offset; + void *data; + + block = (void *)module + sizeof(*module); + + for (count = 0; count < module->blocks; count++) { + + if (block->size <= 0) { + fprintf(stderr, "block %d size invalid\n", count); + return -EINVAL; + } + + switch (block->type) { + case REEF_IRAM: + offset = block->ram_offset + 0; + break; + case REEF_DRAM: + offset = block->ram_offset + + adsp->dram_offset; + break; + case REEF_CACHE: + offset = block->ram_offset + + adsp->dram_offset; + break; + default: + fprintf(stderr, "wrong ram type 0x%x in block0x%x\n", + block->type, count); + return -EINVAL; + } + + fprintf(stdout, "bin: block %d type %d offset 0x%x size 0x%x\n", + count, block->type, offset, block->size); + + data = (void *)block + sizeof(*block); + memcpy(image->out_buffer + offset, data, block->size); + + if (image->dump_sections) + dump_section(image, block, data); + + block = (void *)block + sizeof(*block) + block->size; + } + + return 0; +} + +static int read_bdw_bin_module(struct image *image, + struct hsw_module_header *module) +{ + const struct adsp *adsp = image->adsp; + struct dma_block_info *block; + int count, offset; + void *data; + + block = (void *)module + sizeof(*module); + + for (count = 0; count < module->blocks; count++) { + + if (block->size <= 0) { + fprintf(stderr, "block %d size invalid\n", count); + return -EINVAL; + } + + switch (block->type) { + case REEF_IRAM: + offset = block->ram_offset + 0; + break; + case REEF_DRAM: + offset = block->ram_offset + + adsp->dram_offset; + break; + case REEF_CACHE: + offset = block->ram_offset + + adsp->dram_offset; + break; + default: + fprintf(stderr, "wrong ram type 0x%x in block0x%x\n", + block->type, count); + return -EINVAL; + } + + fprintf(stdout, "bin: block %d type %d offset 0x%x size 0x%x\n", + count, block->type, offset, block->size); + + data = (void *)block + sizeof(*block); + memcpy(image->out_buffer + offset, data, block->size); + + if (image->dump_sections) + dump_section(image, block, data); + + block = (void *)block + sizeof(*block) + block->size; + } + + return 0; +} + +static int read_bin_data(struct image *image) +{ + const struct adsp *adsp = image->adsp; + struct fw_header hdr; + size_t count; + + count = fread(&hdr, sizeof(hdr), 1, image->in_fd); + if (count != 1) + return -errno; + + if (strncmp(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE)) { + fprintf(stderr, "invalid header signature: %c%c%c%c\n", + hdr.signature[0], hdr.signature[1], + hdr.signature[2], hdr.signature[3]); + return -EINVAL; + } + + image->fw_size = hdr.file_size; + image->num_modules = hdr.modules; + + fprintf(stdout, "bin: input image size %ld (0x%lx) bytes %d modules\n", + hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), + hdr.modules); + fprintf(stdout, "bin: output image size %d (0x%x) bytes\n", + adsp->image_size, + adsp->image_size); + + image->in_buffer = calloc(image->fw_size, 1); + if (image->in_buffer == NULL) + return -ENOMEM; + + count = fread(image->in_buffer, image->fw_size, 1, image->in_fd); + if (count != 1) { + free(image->in_buffer); + return -errno; + } + + image->out_buffer = calloc(adsp->image_size, 1); + if (image->out_buffer == NULL) { + free(image->in_buffer); + return -ENOMEM; + } + + return 0; +} + +int write_byt_binary_image(struct image *image) +{ + const struct adsp *adsp = image->adsp; + struct byt_module_header *module; + int ret, count; + + ret = read_bin_data(image); + if (ret < 0) + return ret; + + module = (void *)image->in_buffer; + + for (count = 0; count < image->num_modules; count++) { + + fprintf(stdout, "bin: module %d type %d blocks %d size 0x%x\n", + count, module->type, module->blocks, module->mod_size); + + ret = read_byt_bin_module(image, module); + if (ret < 0) { + fprintf(stderr, "invalid module %d\n", count); + return ret; + } + module = (void *)module + sizeof(*module) + module->mod_size; + } + + count = fwrite(image->out_buffer, adsp->image_size, 1, + image->out_fd); + if (count != adsp->image_size) + return -errno; + + return ret; +} + +int write_bdw_binary_image(struct image *image) +{ + const struct adsp *adsp = image->adsp; + struct hsw_module_header *module; + int ret, count; + + ret = read_bin_data(image); + if (ret < 0) + return ret; + + module = (void *)image->in_buffer; + + for (count = 0; count < image->num_modules; count++) { + + fprintf(stdout, "bin: module %d type %d blocks %d size 0x%x\n", + count, module->type, module->blocks, module->mod_size); + + ret = read_bdw_bin_module(image, module); + if (ret < 0) { + fprintf(stderr, "invalid module %d\n", count); + return ret; + } + module = (void *)module + sizeof(*module) + module->mod_size; + } + + count = fwrite(image->out_buffer, adsp->image_size, 1, + image->out_fd); + if (count != adsp->image_size) + return -errno; + + return ret; +} diff --git a/rimage/rimage.c b/rimage/rimage.c new file mode 100644 index 000000000000..bed6b48cd8c3 --- /dev/null +++ b/rimage/rimage.c @@ -0,0 +1,312 @@ +/* + * ELF to firmware image creator. + * + * Copyright (c) 2015, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include + +#include "rimage.h" +#include "file_format.h" + +static const struct adsp *machine[] = { + &byt_machine, + &cht_machine, +}; + +static int read_elf_sections(struct image *image) +{ + size_t count; + int i, ret; + uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); + + /* read in section header */ + ret = fseek(image->in_fd, image->hdr.e_shoff, SEEK_SET); + if (ret < 0) { + fprintf(stderr, "error: cant seek to section header %d\n", ret); + return ret; + } + + image->section = calloc(sizeof(Elf32_Shdr), image->hdr.e_shnum); + if (image->section == NULL) + return -ENOMEM; + + count = fread(image->section, sizeof(Elf32_Shdr), + image->hdr.e_shnum, image->in_fd); + if (count != image->hdr.e_shnum) { + fprintf(stderr, "error: failed to read section header %d\n", + -errno); + return -errno; + } + + for (i = 0; i < image->hdr.e_shnum; i++) { + + /* only write valid sections */ + if (!(image->section[i].sh_flags & valid)) + continue; + + switch (image->section[i].sh_type) { + case SHT_NOBITS: + /* bss */ + image->bss_size += image->section[i].sh_size; + image->num_bss++; + break; + case SHT_PROGBITS: + /* text or data */ + image->fw_size += image->section[i].sh_size; + + if (image->section[i].sh_flags & SHF_EXECINSTR) + image->text_size += image->section[i].sh_size; + else + image->data_size += image->section[i].sh_size; + break; + default: + continue; + } + + image->num_sections++; + + if (!image->verbose) + continue; + + fprintf(stdout, "section-%d: \ttype\t 0x%8.8x\n", i, + image->section[i].sh_type); + fprintf(stdout, "section-%d: \tflags\t 0x%8.8x\n", i, + image->section[i].sh_flags); + fprintf(stdout, "section-%d: \taddr\t 0x%8.8x\n", i, + image->section[i].sh_addr); + fprintf(stdout, "section-%d: \toffset\t 0x%8.8x\n", i, + image->section[i].sh_offset); + fprintf(stdout, "section-%d: \tsize\t 0x%8.8x\n", i, + image->section[i].sh_size); + fprintf(stdout, "section-%d: \tlink\t 0x%8.8x\n", i, + image->section[i].sh_link); + fprintf(stdout, "section-%d: \tinfo\t 0x%8.8x\n\n", i, + image->section[i].sh_info); + } + + return 0; +} + +static int read_elf_programs(struct image *image) +{ + size_t count; + int i, ret; + + /* read in program header */ + ret = fseek(image->in_fd, image->hdr.e_phoff, SEEK_SET); + if (ret < 0) { + fprintf(stderr, "error: cant seek to program header %d\n", ret); + return ret; + } + + image->prg = calloc(sizeof(Elf32_Phdr), image->hdr.e_phnum); + if (image->prg == NULL) + return -ENOMEM; + + count = fread(image->prg, sizeof(Elf32_Phdr), + image->hdr.e_phnum, image->in_fd); + if (count != image->hdr.e_phnum) { + fprintf(stderr, "error: failed to read program header %d\n", + -errno); + return -errno; + } + + for (i = 0; i < image->hdr.e_phnum; i++) { + + if (image->prg[i].p_filesz == 0) + continue; + + if (!image->verbose) + continue; + + fprintf(stdout, "program-%d: \ttype\t 0x%8.8x\n", i, + image->prg[i].p_type); + fprintf(stdout, "program-%d: \toffset\t 0x%8.8x\n", i, + image->prg[i].p_offset); + fprintf(stdout, "program-%d: \tvaddr\t 0x%8.8x\n", i, + image->prg[i].p_vaddr); + fprintf(stdout, "program-%d: \tpaddr\t 0x%8.8x\n", i, + image->prg[i].p_paddr); + fprintf(stdout, "program-%d: \tfsize\t 0x%8.8x\n", i, + image->prg[i].p_filesz); + fprintf(stdout, "program-%d: \tmsize\t 0x%8.8x\n", i, + image->prg[i].p_memsz); + fprintf(stdout, "program-%d: \tflags\t 0x%8.8x\n\n", i, + image->prg[i].p_flags); + } + + return 0; +} + +static int write_elf_data(struct image *image) +{ + const struct adsp *adsp = image->adsp; + int ret = 0; + size_t count; + + /* read in elf header */ + count = fread(&image->hdr, sizeof(image->hdr), 1, image->in_fd); + if (count != 1) { + fprintf(stderr, "error: failed to read elf header %d\n", + -errno); + return -errno; + } + + fprintf(stdout, "elf: \tentry point\t 0x%8.8x\n", image->hdr.e_entry); + fprintf(stdout, "elf: \tprogram offset\t 0x%8.8x\n", image->hdr.e_phoff); + fprintf(stdout, "elf: \tsection offset\t 0x%8.8x\n", image->hdr.e_shoff); + fprintf(stdout, "elf: \tprogram size\t 0x%8.8x\n", image->hdr.e_phentsize); + fprintf(stdout, "elf: \tprogram count\t 0x%8.8x\n", image->hdr.e_phnum); + fprintf(stdout, "elf: \tsection size\t 0x%8.8x\n", image->hdr.e_shentsize); + fprintf(stdout, "elf: \tsection count\t 0x%8.8x\n", image->hdr.e_shnum); + fprintf(stdout, "elf: \tstring index\t 0x%8.8x\n\n", image->hdr.e_shstrndx); + + ret = read_elf_programs(image); + if (ret < 0) { + fprintf(stderr, "error: failed to read program sections %d\n", ret); + goto out; + } + + ret = read_elf_sections(image); + if (ret < 0) { + fprintf(stderr, "error: failed to read sections %d\n", ret); + goto out; + } + + fprintf(stdout, "fw: input size %d (0x%x) bytes %d sections\n", + image->fw_size, image->fw_size, image->num_sections); + fprintf(stdout, "fw: text %d (0x%x) bytes\n" + " data %d (0x%x) bytes\n" + " bss %d (0x%x) bytes\n", + image->text_size, image->text_size, + image->data_size, image->data_size, + image->bss_size, image->bss_size); + + ret = adsp->ops.write_header(image); + if (ret < 0) { + fprintf(stderr, "error: failed to write header %d\n", ret); + goto out; + } + + ret = adsp->ops.write_modules(image); + if (ret < 0) { + fprintf(stderr, "error: failed to write modules %d\n", ret); + goto out; + } + +out: + return ret; +} + +static void usage(char *name) +{ + fprintf(stdout, "%s:\t -m machine -i infile -o outfile\n", name); + fprintf(stdout, "\t -v enable verbose output\n"); + exit(0); +} + +int main(int argc, char *argv[]) +{ + struct image image; + const char *mach = NULL; + int opt, ret, i, binary = 0; + + memset(&image, 0, sizeof(image)); + + while ((opt = getopt(argc, argv, "ho:i:m:vba:sk:")) != -1) { + switch (opt) { + case 'o': + image.out_file = optarg; + break; + case 'i': + image.in_file = optarg; + break; + case 'm': + mach = optarg; + break; + case 'v': + image.verbose = 1; + break; + case 'b': + binary = 1; + break; + case 's': + image.dump_sections = 1; + break; + case 'a': + image.abi = atoi(optarg); + break; + case 'h': + default: /* '?' */ + usage(argv[0]); + } + } + + if (image.in_file == NULL || image.out_file == NULL || mach == NULL) + usage(argv[0]); + + /* find machine */ + for (i = 0; i < ARRAY_SIZE(machine); i++) { + if (!strcmp(mach, machine[i]->name)) { + image.adsp = machine[i]; + goto found; + } + } + fprintf(stderr, "error: machine %s not found\n", mach); + fprintf(stderr, "error: available machines "); + for (i = 0; i < ARRAY_SIZE(machine); i++) + fprintf(stderr, "%s, ", machine[i]->name); + fprintf(stderr, "/n"); + + return -EINVAL; + +found: + /* open infile for reading */ + image.in_fd = fopen(image.in_file, "r"); + if (image.in_fd == NULL) { + fprintf(stderr, "error: unable to open %s for reading %d\n", + image.in_file, errno); + } + + /* open outfile for reading */ + image.out_fd = fopen(image.out_file, "w"); + if (image.out_fd == NULL) { + fprintf(stderr, "error: unable to open %s for writing %d\n", + image.out_file, errno); + } + + if (binary) { + + switch(image.adsp->machine_id) { + case MACHINE_BAYTRAIL: + ret = write_byt_binary_image(&image); + break; + default: + fprintf(stderr, "error: not supported machine for binary input!\n"); + return ret; + } + + } else + ret = write_elf_data(&image); + + /* close files */ + fclose(image.out_fd); + fclose(image.in_fd); + + return ret; +} + diff --git a/rimage/rimage.h b/rimage/rimage.h new file mode 100644 index 000000000000..2c029328ceaa --- /dev/null +++ b/rimage/rimage.h @@ -0,0 +1,105 @@ +/* + * ELF to firmware image creator. + * + * Copyright (c) 2015, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef __RIMAGE_H__ +#define __RIMAGE_H__ + +#include +#include +#include + +#include +#include +#include + +#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) + +struct adsp; +struct fw_image_manifest; + +struct image { + const char *in_file; + const char *out_file; + FILE *in_fd; + FILE *out_fd; + void *pos; + Elf32_Ehdr hdr; + Elf32_Shdr *section; + Elf32_Phdr *prg; + const struct adsp *adsp; + int abi; + int verbose; + + int num_sections; + int num_bss; + int fw_size; + int bss_size; + int text_size; + int data_size; + int file_size; + int num_modules; + + /* disa */ + void *in_buffer; + void *out_buffer; + int dump_sections; +}; + +struct section { + const char *name; + uint32_t addr; + uint32_t size; +}; + +struct adsp_ops { + /* write header or manifest */ + int (*write_header)(struct image *image); + /* write data modules */ + int (*write_modules)(struct image *image); +}; + +enum machine_id { + MACHINE_BAYTRAIL = 0, + MACHINE_CHERRYTRAIL, + MACHINE_MAX +}; + +struct adsp { + const char *name; + uint32_t iram_base; + uint32_t iram_size; + uint32_t dram_base; + uint32_t dram_size; + uint32_t image_size; + uint32_t dram_offset; + enum machine_id machine_id; + struct adsp_ops ops; + const struct section *sections; +}; + +/* headers used by multiple platforms */ +int byt_write_header(struct image *image); + +/* modules used by multiple platforms */ +int byt_write_modules(struct image *image); + +/* for disassembly */ +int write_byt_binary_image(struct image *image); + +/* supported machines */ +extern const struct adsp byt_machine; +extern const struct adsp cht_machine; + +#endif diff --git a/rmbox/Makefile.am b/rmbox/Makefile.am new file mode 100644 index 000000000000..bfeb184fde52 --- /dev/null +++ b/rmbox/Makefile.am @@ -0,0 +1,4 @@ +bin_PROGRAMS = rmbox + +rmbox_SOURCES = \ + rmbox.c \ No newline at end of file diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c new file mode 100644 index 000000000000..ff487ec9c41d --- /dev/null +++ b/rmbox/rmbox.c @@ -0,0 +1,315 @@ +/* + * mbox dump to debug log convertor. + * + * Copyright (c) 2015, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include +#include + +// TODO: include all this stuff + +#define TRACE_CLASS_IRQ (1 << 24) +#define TRACE_CLASS_IPC (2 << 24) +#define TRACE_CLASS_PIPE (3 << 24) +#define TRACE_CLASS_HOST (4 << 24) +#define TRACE_CLASS_DAI (5 << 24) +#define TRACE_CLASS_DMA (6 << 24) +#define TRACE_CLASS_SSP (7 << 24) +#define TRACE_CLASS_COMP (8 << 24) +#define TRACE_CLASS_WAIT (9 << 24) +#define TRACE_CLASS_LOCK (10 << 24) +#define TRACE_CLASS_MEM (11 << 24) +#define TRACE_CLASS_MIXER (12 << 24) + +#define MAILBOX_HOST_OFFSET 0x144000 + +#define MAILBOX_OUTBOX_OFFSET 0x0 +#define MAILBOX_OUTBOX_SIZE 0x400 +#define MAILBOX_OUTBOX_BASE \ + (MAILBOX_BASE + MAILBOX_OUTBOX_OFFSET) + +#define MAILBOX_INBOX_OFFSET MAILBOX_OUTBOX_SIZE +#define MAILBOX_INBOX_SIZE 0x400 +#define MAILBOX_INBOX_BASE \ + (MAILBOX_BASE + MAILBOX_INBOX_OFFSET) + +#define MAILBOX_EXCEPTION_OFFSET \ + (MAILBOX_INBOX_SIZE + MAILBOX_OUTBOX_SIZE) +#define MAILBOX_EXCEPTION_SIZE 0x100 +#define MAILBOX_EXCEPTION_BASE \ + (MAILBOX_BASE + MAILBOX_EXCEPTION_OFFSET) + +#define MAILBOX_DEBUG_OFFSET \ + (MAILBOX_EXCEPTION_SIZE + MAILBOX_EXCEPTION_OFFSET) +#define MAILBOX_DEBUG_SIZE 0x100 +#define MAILBOX_DEBUG_BASE \ + (MAILBOX_BASE + MAILBOX_DEBUG_OFFSET) + +#define MAILBOX_STREAM_OFFSET \ + (MAILBOX_DEBUG_SIZE + MAILBOX_DEBUG_OFFSET) +#define MAILBOX_STREAM_SIZE 0x200 +#define MAILBOX_STREAM_BASE \ + (MAILBOX_BASE + MAILBOX_STREAM_OFFSET) + +#define MAILBOX_TRACE_OFFSET \ + (MAILBOX_STREAM_SIZE + MAILBOX_STREAM_OFFSET) +#define MAILBOX_TRACE_SIZE 0x380 +#define MAILBOX_TRACE_BASE \ + (MAILBOX_BASE + MAILBOX_TRACE_OFFSET) + +#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) + +static inline char get_char(uint32_t val, int idx) +{ + char c = (val >> (idx * 8)) & 0xff; + if (c < '0' || c > 'z') + return '.'; + else + return c; +} + +static void usage(char *name) +{ + fprintf(stdout, "%s:\t -i infile -o outfile\n", name); + exit(0); +} + +static inline float to_usecs(uint32_t time) +{ + /* trace timestamp uses CPU system clock at default 25MHz ticks */ + // TODO: support variable clock rates + return (float)time / 25.0; +} + +static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp) +{ + const char *trace; + uint32_t class; + + /* timestamp or value ? */ + if ((addr % 8) == 0) { + printf("trace.io: timestamp 0x%8.8x (%2.2f us) \tdelta 0x%8.8x (%2.2f us)\t", + (uint32_t)val, to_usecs(val), + (uint32_t)val - *timestamp, to_usecs(val - *timestamp)); + *timestamp = val; + return; + } + + class = val & 0xff000000; + if (class == TRACE_CLASS_IRQ) + trace = "irq"; + else if (class == TRACE_CLASS_IPC) + trace = "ipc"; + else if (class == TRACE_CLASS_PIPE) + trace = "pipe"; + else if (class == TRACE_CLASS_HOST) + trace = "host"; + else if (class == TRACE_CLASS_DAI) + trace = "dai"; + else if (class == TRACE_CLASS_DMA) + trace = "dma"; + else if (class == TRACE_CLASS_SSP) + trace = "ssp"; + else if (class == TRACE_CLASS_COMP) + trace = "comp"; + else if (class == TRACE_CLASS_WAIT) + trace = "wait"; + else if (class == TRACE_CLASS_LOCK) + trace = "lock"; + else if (class == TRACE_CLASS_MEM) + trace = "mem"; + else if (class == TRACE_CLASS_MIXER) + trace = "mixer"; + else { + printf("value 0x%8.8x\n", (uint32_t)val); + return; + } + + printf("%s %c%c%c\n", trace, + (char)(val >> 16), (char)(val >> 8), (char)val); +} + +static void show_debug(uint32_t val, uint32_t addr) +{ + printf("debug: 0x%x (%2.2d) = \t0x%8.8x \t(%8.8d) \t|%c%c%c%c|\n", + (unsigned int)addr - MAILBOX_DEBUG_OFFSET, + ((unsigned int)addr - MAILBOX_DEBUG_OFFSET) / 4, + val, val, + get_char(val, 3), get_char(val, 2), + get_char(val, 1), get_char(val, 0)); +} + +static void show_exception(uint32_t val, uint32_t addr) +{ + printf("exp: 0x%x (%2.2d) = \t0x%8.8x \t(%8.8d) \t|%c%c%c%c|\n", + (unsigned int)addr - MAILBOX_EXCEPTION_OFFSET, + ((unsigned int)addr - MAILBOX_EXCEPTION_OFFSET) / 4, + val, val, + get_char(val, 3), get_char(val, 2), + get_char(val, 1), get_char(val, 0)); +} + +struct sst_debugfs_map { + const char *name; + uint32_t size; +}; + +static const struct sst_debugfs_map debugfs_byt[] = { + {"dmac0", 0x420}, + {"dmac1", 0x420}, + {"ssp0", 0x100}, + {"ssp1", 0x100}, + {"ssp2", 0x100}, + {"iram", 80 * 1024}, + {"dram", 160 * 1024}, + {"shim", 0x100}, + {"mbox", 0x1000}, +}; + +static int snapshot(const char *name) +{ + const char *path = "/sys/kernel/debug"; + uint32_t val, addr; + char pinname[64], poutname[64], buffer[128]; + FILE *in_fd, *out_fd; + int i, count; + + if (name == NULL) + return -EINVAL; + + for (i = 0; i < ARRAY_SIZE(debugfs_byt); i++) { + + sprintf(pinname, "%s/%s", path, debugfs_byt[i].name); + sprintf(poutname, "%s.%s.txt", name, debugfs_byt[i].name); + + /* open debugfs for reading */ + in_fd = fopen(pinname, "r"); + if (in_fd == NULL) { + fprintf(stderr, "error: unable to open %s for reading %d\n", + pinname, errno); + continue; + } + + /* open outfile for reading */ + out_fd = fopen(poutname, "w"); + if (out_fd == NULL) { + fprintf(stderr, "error: unable to open %s for writing %d\n", + poutname, errno); + fclose(in_fd); + continue; + } + + fprintf(stdout, "processing %s...\n", pinname); + addr = 0; + + while (1) { + count = fread(&val, 1, 4, in_fd); + if (count != 4) + break; + + sprintf(buffer, "0x%6.6x: 0x%8.8x\n", addr, val); + + count = fwrite(buffer, 1, strlen(buffer), out_fd); + + addr += 4; + } + + } + + return 0; +} + +int main(int argc, char *argv[]) +{ + int opt, count; + const char * out_file = NULL, *in_file = "/sys/kernel/debug/mbox"; + FILE *in_fd, *out_fd; + char c, tmp[4] = {0}; + uint32_t addr = 0, val, timestamp = 0; + + while ((opt = getopt(argc, argv, "ho:i:s:")) != -1) { + switch (opt) { + case 'o': + out_file = optarg; + break; + case 'i': + in_file = optarg; + break; + case 's': + return snapshot(optarg); + case 'h': + default: /* '?' */ + usage(argv[0]); + } + } + + if (in_file == NULL || out_file == NULL) + usage(argv[0]); + + /* open infile for reading */ + in_fd = fopen(in_file, "r"); + if (in_fd == NULL) { + fprintf(stderr, "error: unable to open %s for reading %d\n", + in_file, errno); + } + + /* open outfile for reading */ + out_fd = fopen(out_file, "w"); + if (out_fd == NULL) { + fprintf(stderr, "error: unable to open %s for writing %d\n", + out_file, errno); + } + + /* start to converting */ + fprintf(stdout, "start to converting...\n"); + while (1) { + count = fread(&tmp[0], 1, 4, in_fd); + if (count != 4) + break; + + val = *((uint32_t*)tmp); + + c = tmp[0]; + tmp[0] = tmp[3]; + tmp[3] = c; + c = tmp[1]; + tmp[1] = tmp[2]; + tmp[2] = c; + + if (addr >= MAILBOX_TRACE_OFFSET && + addr < MAILBOX_TRACE_OFFSET + MAILBOX_TRACE_SIZE) + show_trace(val, addr, ×tamp); + else if (addr >= MAILBOX_DEBUG_OFFSET && + addr < MAILBOX_DEBUG_OFFSET + MAILBOX_DEBUG_SIZE) + show_debug(val, addr); + else if (addr >= MAILBOX_EXCEPTION_OFFSET && + addr < MAILBOX_EXCEPTION_OFFSET + MAILBOX_EXCEPTION_SIZE) + show_exception(val, addr); + + count = fwrite(&tmp[0], 1, 4, out_fd); + if (count != 4) + break; + + addr += 4; + } + + /* close files */ + fclose(in_fd); + fclose(out_fd); + + fprintf(stdout, "converting finished.\n"); +} From 74512df085f2b3788247404e7167f62ed09f1f2f Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 28 Feb 2017 11:51:55 +0000 Subject: [PATCH 002/324] rmbox: add support for snapshots of HW state Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 54 ++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 29 deletions(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index ff487ec9c41d..2e0e118e9d85 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -163,21 +163,9 @@ static void show_exception(uint32_t val, uint32_t addr) get_char(val, 1), get_char(val, 0)); } -struct sst_debugfs_map { - const char *name; - uint32_t size; -}; -static const struct sst_debugfs_map debugfs_byt[] = { - {"dmac0", 0x420}, - {"dmac1", 0x420}, - {"ssp0", 0x100}, - {"ssp1", 0x100}, - {"ssp2", 0x100}, - {"iram", 80 * 1024}, - {"dram", 160 * 1024}, - {"shim", 0x100}, - {"mbox", 0x1000}, +static const char *debugfs[] = { + "dmac0","dmac1", "ssp0", "ssp1", "ssp2", "iram", "dram", "shim", "mbox" }; static int snapshot(const char *name) @@ -188,13 +176,15 @@ static int snapshot(const char *name) FILE *in_fd, *out_fd; int i, count; - if (name == NULL) + if (name == NULL) { + fprintf(stderr, "error: need snapshot name\n"); return -EINVAL; + } - for (i = 0; i < ARRAY_SIZE(debugfs_byt); i++) { + for (i = 0; i < ARRAY_SIZE(debugfs); i++) { - sprintf(pinname, "%s/%s", path, debugfs_byt[i].name); - sprintf(poutname, "%s.%s.txt", name, debugfs_byt[i].name); + sprintf(pinname, "%s/%s", path, debugfs[i]); + sprintf(poutname, "%s.%s.txt", name, debugfs[i]); /* open debugfs for reading */ in_fd = fopen(pinname, "r"); @@ -237,11 +227,11 @@ int main(int argc, char *argv[]) { int opt, count; const char * out_file = NULL, *in_file = "/sys/kernel/debug/mbox"; - FILE *in_fd, *out_fd; + FILE *in_fd = NULL, *out_fd = NULL; char c, tmp[4] = {0}; uint32_t addr = 0, val, timestamp = 0; - while ((opt = getopt(argc, argv, "ho:i:s:")) != -1) { + while ((opt = getopt(argc, argv, "ho:i:s:m:")) != -1) { switch (opt) { case 'o': out_file = optarg; @@ -257,7 +247,7 @@ int main(int argc, char *argv[]) } } - if (in_file == NULL || out_file == NULL) + if (argc > 1 && (in_file == NULL || out_file == NULL)) usage(argv[0]); /* open infile for reading */ @@ -267,15 +257,18 @@ int main(int argc, char *argv[]) in_file, errno); } - /* open outfile for reading */ + /* open outfile for writing */ + if (out_file == NULL) + goto convert; + out_fd = fopen(out_file, "w"); if (out_fd == NULL) { fprintf(stderr, "error: unable to open %s for writing %d\n", out_file, errno); } - /* start to converting */ - fprintf(stdout, "start to converting...\n"); + /* start to converting mailbox */ +convert: while (1) { count = fread(&tmp[0], 1, 4, in_fd); if (count != 4) @@ -300,16 +293,19 @@ int main(int argc, char *argv[]) addr < MAILBOX_EXCEPTION_OFFSET + MAILBOX_EXCEPTION_SIZE) show_exception(val, addr); - count = fwrite(&tmp[0], 1, 4, out_fd); - if (count != 4) - break; + if (out_fd) { + count = fwrite(&tmp[0], 1, 4, out_fd); + if (count != 4) + break; + } addr += 4; } /* close files */ fclose(in_fd); - fclose(out_fd); + if (out_fd) + fclose(out_fd); - fprintf(stdout, "converting finished.\n"); + return 0; } From b1d24346961e9f80b24fb48074e170829712b31f Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 28 Feb 2017 12:09:19 +0000 Subject: [PATCH 003/324] rmbox: use SSP 19.2M clock for trace Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 2e0e118e9d85..d2247f76284a 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -88,11 +88,11 @@ static void usage(char *name) exit(0); } -static inline float to_usecs(uint32_t time) +static inline float clk_to_usecs(uint32_t time) { - /* trace timestamp uses CPU system clock at default 25MHz ticks */ + /* trace timestamp uses SSP system clock at default 19.2MHz ticks */ // TODO: support variable clock rates - return (float)time / 25.0; + return (float)time / 19.2; } static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp) @@ -103,8 +103,8 @@ static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp) /* timestamp or value ? */ if ((addr % 8) == 0) { printf("trace.io: timestamp 0x%8.8x (%2.2f us) \tdelta 0x%8.8x (%2.2f us)\t", - (uint32_t)val, to_usecs(val), - (uint32_t)val - *timestamp, to_usecs(val - *timestamp)); + (uint32_t)val, clk_to_usecs(val), + (uint32_t)val - *timestamp, clk_to_usecs(val - *timestamp)); *timestamp = val; return; } From 072fb5c43f03a5b4f0630a1bc5d2a8db9cb38807 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 9 Jun 2017 14:24:51 +0100 Subject: [PATCH 004/324] rimage: remove flat file builder. No longer needed so can be safely removed. Signed-off-by: Liam Girdwood --- rimage/Makefile.am | 4 +- rimage/flat.c | 256 --------------------------------------------- 2 files changed, 2 insertions(+), 258 deletions(-) delete mode 100644 rimage/flat.c diff --git a/rimage/Makefile.am b/rimage/Makefile.am index 32335fe68957..0ba8ce6f4c4d 100644 --- a/rimage/Makefile.am +++ b/rimage/Makefile.am @@ -6,5 +6,5 @@ noinst_HEADERS = \ rimage_SOURCES = \ cherrytrail.c \ baytrail.c \ - flat.c \ - rimage.c \ No newline at end of file + rimage.c + diff --git a/rimage/flat.c b/rimage/flat.c deleted file mode 100644 index 8c5d1c58b557..000000000000 --- a/rimage/flat.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * ELF to firmware image creator. - * - * Copyright (c) 2015, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#include -#include -#include -#include -#include - -#include "rimage.h" -#include "file_format.h" - -static int dump_section(struct image *image, struct dma_block_info *block, - void *data) -{ - const struct adsp *adsp = image->adsp; - uint32_t addr; - - switch (block->type) { - case REEF_IRAM: - addr = block->ram_offset + adsp->iram_base; - break; - case REEF_DRAM: - addr = block->ram_offset + adsp->dram_base; - break; - case REEF_CACHE: - addr = block->ram_offset + adsp->dram_base; - break; - default: - return -EINVAL; - } -} - -static int read_byt_bin_module(struct image *image, - struct byt_module_header *module) -{ - const struct adsp *adsp = image->adsp; - struct dma_block_info *block; - int count, offset; - void *data; - - block = (void *)module + sizeof(*module); - - for (count = 0; count < module->blocks; count++) { - - if (block->size <= 0) { - fprintf(stderr, "block %d size invalid\n", count); - return -EINVAL; - } - - switch (block->type) { - case REEF_IRAM: - offset = block->ram_offset + 0; - break; - case REEF_DRAM: - offset = block->ram_offset + - adsp->dram_offset; - break; - case REEF_CACHE: - offset = block->ram_offset + - adsp->dram_offset; - break; - default: - fprintf(stderr, "wrong ram type 0x%x in block0x%x\n", - block->type, count); - return -EINVAL; - } - - fprintf(stdout, "bin: block %d type %d offset 0x%x size 0x%x\n", - count, block->type, offset, block->size); - - data = (void *)block + sizeof(*block); - memcpy(image->out_buffer + offset, data, block->size); - - if (image->dump_sections) - dump_section(image, block, data); - - block = (void *)block + sizeof(*block) + block->size; - } - - return 0; -} - -static int read_bdw_bin_module(struct image *image, - struct hsw_module_header *module) -{ - const struct adsp *adsp = image->adsp; - struct dma_block_info *block; - int count, offset; - void *data; - - block = (void *)module + sizeof(*module); - - for (count = 0; count < module->blocks; count++) { - - if (block->size <= 0) { - fprintf(stderr, "block %d size invalid\n", count); - return -EINVAL; - } - - switch (block->type) { - case REEF_IRAM: - offset = block->ram_offset + 0; - break; - case REEF_DRAM: - offset = block->ram_offset + - adsp->dram_offset; - break; - case REEF_CACHE: - offset = block->ram_offset + - adsp->dram_offset; - break; - default: - fprintf(stderr, "wrong ram type 0x%x in block0x%x\n", - block->type, count); - return -EINVAL; - } - - fprintf(stdout, "bin: block %d type %d offset 0x%x size 0x%x\n", - count, block->type, offset, block->size); - - data = (void *)block + sizeof(*block); - memcpy(image->out_buffer + offset, data, block->size); - - if (image->dump_sections) - dump_section(image, block, data); - - block = (void *)block + sizeof(*block) + block->size; - } - - return 0; -} - -static int read_bin_data(struct image *image) -{ - const struct adsp *adsp = image->adsp; - struct fw_header hdr; - size_t count; - - count = fread(&hdr, sizeof(hdr), 1, image->in_fd); - if (count != 1) - return -errno; - - if (strncmp(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE)) { - fprintf(stderr, "invalid header signature: %c%c%c%c\n", - hdr.signature[0], hdr.signature[1], - hdr.signature[2], hdr.signature[3]); - return -EINVAL; - } - - image->fw_size = hdr.file_size; - image->num_modules = hdr.modules; - - fprintf(stdout, "bin: input image size %ld (0x%lx) bytes %d modules\n", - hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), - hdr.modules); - fprintf(stdout, "bin: output image size %d (0x%x) bytes\n", - adsp->image_size, - adsp->image_size); - - image->in_buffer = calloc(image->fw_size, 1); - if (image->in_buffer == NULL) - return -ENOMEM; - - count = fread(image->in_buffer, image->fw_size, 1, image->in_fd); - if (count != 1) { - free(image->in_buffer); - return -errno; - } - - image->out_buffer = calloc(adsp->image_size, 1); - if (image->out_buffer == NULL) { - free(image->in_buffer); - return -ENOMEM; - } - - return 0; -} - -int write_byt_binary_image(struct image *image) -{ - const struct adsp *adsp = image->adsp; - struct byt_module_header *module; - int ret, count; - - ret = read_bin_data(image); - if (ret < 0) - return ret; - - module = (void *)image->in_buffer; - - for (count = 0; count < image->num_modules; count++) { - - fprintf(stdout, "bin: module %d type %d blocks %d size 0x%x\n", - count, module->type, module->blocks, module->mod_size); - - ret = read_byt_bin_module(image, module); - if (ret < 0) { - fprintf(stderr, "invalid module %d\n", count); - return ret; - } - module = (void *)module + sizeof(*module) + module->mod_size; - } - - count = fwrite(image->out_buffer, adsp->image_size, 1, - image->out_fd); - if (count != adsp->image_size) - return -errno; - - return ret; -} - -int write_bdw_binary_image(struct image *image) -{ - const struct adsp *adsp = image->adsp; - struct hsw_module_header *module; - int ret, count; - - ret = read_bin_data(image); - if (ret < 0) - return ret; - - module = (void *)image->in_buffer; - - for (count = 0; count < image->num_modules; count++) { - - fprintf(stdout, "bin: module %d type %d blocks %d size 0x%x\n", - count, module->type, module->blocks, module->mod_size); - - ret = read_bdw_bin_module(image, module); - if (ret < 0) { - fprintf(stderr, "invalid module %d\n", count); - return ret; - } - module = (void *)module + sizeof(*module) + module->mod_size; - } - - count = fwrite(image->out_buffer, adsp->image_size, 1, - image->out_fd); - if (count != adsp->image_size) - return -errno; - - return ret; -} From 03acfd640d87977a8337016002e23e19c0b08b2b Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 9 Jun 2017 14:25:36 +0100 Subject: [PATCH 005/324] rimage: update to new SOF driver file format. Support the SOF driver file format. Signed-off-by: Liam Girdwood --- rimage/baytrail.c | 73 ++++++++----------- rimage/cherrytrail.c | 9 ++- rimage/file_format.h | 166 +++++++++++++++++++++++++------------------ rimage/rimage.c | 26 +++---- rimage/rimage.h | 11 +++ 5 files changed, 151 insertions(+), 134 deletions(-) diff --git a/rimage/baytrail.c b/rimage/baytrail.c index 0053f97dfab7..12ccd2355224 100644 --- a/rimage/baytrail.c +++ b/rimage/baytrail.c @@ -40,17 +40,6 @@ static const struct section byt_sections[] = { {"NMIExceptionVector", 0xff2c061c}, }; -static const enum reef_module_id modules[] = { - REEF_MODULE_BASE_FW, - REEF_MODULE_AAC_5_1, - REEF_MODULE_PCM, - REEF_MODULE_PCM_SYSTEM, - REEF_MODULE_PCM_CAPTURE, - REEF_MODULE_PCM_REFERENCE, - REEF_MODULE_BLUETOOTH_RENDER_MODULE, - REEF_MODULE_BLUETOOTH_CAPTURE_MODULE, -}; - static int is_iram(struct image *image, Elf32_Shdr *section) { const struct adsp *adsp = image->adsp; @@ -86,7 +75,7 @@ static int block_idx = 0; static int write_block(struct image *image, Elf32_Shdr *section) { const struct adsp *adsp = image->adsp; - struct dma_block_info block; + struct snd_sof_blk_hdr block; size_t count; void *buffer; int ret; @@ -94,11 +83,13 @@ static int write_block(struct image *image, Elf32_Shdr *section) block.size = section->sh_size; if (is_iram(image, section)) { - block.type = REEF_IRAM; - block.ram_offset = section->sh_addr - adsp->iram_base; + block.type = SOF_BLK_TEXT; + block.offset = section->sh_addr - adsp->iram_base + + adsp->host_iram_offset; } else if (is_dram(image, section)) { - block.type = REEF_DRAM; - block.ram_offset = section->sh_addr - adsp->dram_base; + block.type = SOF_BLK_DATA; + block.offset = section->sh_addr - adsp->dram_base + + adsp->host_dram_offset; } else { fprintf(stderr, "error: invalid block address/size 0x%x/0x%x\n", section->sh_addr, section->sh_size); @@ -153,18 +144,18 @@ static int write_block(struct image *image, Elf32_Shdr *section) int byt_write_modules(struct image *image) { const struct adsp *adsp = image->adsp; - struct byt_module_header hdr; + struct snd_sof_mod_hdr hdr; Elf32_Shdr *section; size_t count; int i, err; uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - memcpy(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE); - hdr.blocks = image->num_sections - image->num_bss; - hdr.mod_size = image->text_size + image->data_size + \ - sizeof(struct dma_block_info) * hdr.blocks; - hdr.type = REEF_MODULE_BASE_FW; - hdr.entry_point = 0;//section->sh_addr; + fprintf(stdout, "Using BYT file format\n"); + + hdr.num_blocks = image->num_sections - image->num_bss; + hdr.size = image->text_size + image->data_size + + sizeof(struct snd_sof_blk_hdr) * hdr.num_blocks; + hdr.type = SOF_FW_BASE; count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); if (count != 1) { @@ -191,41 +182,28 @@ int byt_write_modules(struct image *image) } } - /* write the remaining 7 fake modules headers, to make the linux driver happy */ - hdr.mod_size = 0; - hdr.blocks = 0; - - for (i = 1; i < sizeof(modules) / sizeof(modules[0]); i++) { - hdr.type = modules[i]; - count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); - if (count != 1) { - fprintf(stderr, "error: failed to write section header %d\n", i); - return -errno ; - } - } - return 0; } /* used by others */ int byt_write_header(struct image *image) { - struct fw_header hdr; + struct snd_sof_fw_header hdr; size_t count; - memcpy(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE); + memcpy(hdr.sig, SND_SOF_FW_SIG, SND_SOF_FW_SIG_SIZE); - hdr.modules = sizeof(modules) / sizeof(modules[0]); - hdr.file_format = 0; + hdr.num_modules = 1; + hdr.abi = SND_SOF_FW_ABI; - image->fw_size += sizeof(struct dma_block_info) * + image->fw_size += sizeof(struct snd_sof_blk_hdr) * (image->num_sections - image->num_bss); - image->fw_size += sizeof(struct byt_module_header) * hdr.modules; + image->fw_size += sizeof(struct snd_sof_mod_hdr) * hdr.num_modules; hdr.file_size = image->fw_size; fprintf(stdout, "fw: image size %ld (0x%lx) bytes %d modules\n\n", hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), - hdr.modules); + hdr.num_modules); count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); if (count != 1) return -errno; @@ -233,14 +211,19 @@ int byt_write_header(struct image *image) return 0; } +#define IRAM_OFFSET 0x0C0000 +#define IRAM_SIZE (80 * 1024) +#define DRAM_OFFSET 0x100000 +#define DRAM_SIZE (160 * 1024) + const struct adsp byt_machine = { .name = "byt", .iram_base = 0xff2c0000, .iram_size = 0x14000, + .host_iram_offset = IRAM_OFFSET, .dram_base = 0xff300000, .dram_size = 0x28000, - .image_size = 0xff300000 - 0xff2c0000 + 0x28000, - .dram_offset = 0xff300000 - 0xff2c0000, + .host_dram_offset = DRAM_OFFSET, .machine_id = MACHINE_BAYTRAIL, .ops = { .write_header = byt_write_header, diff --git a/rimage/cherrytrail.c b/rimage/cherrytrail.c index a37a13db2353..e27bea63e565 100644 --- a/rimage/cherrytrail.c +++ b/rimage/cherrytrail.c @@ -40,14 +40,19 @@ static const struct section cht_sections[] = { {"NMIExceptionVector", 0xff2c061c}, }; +#define IRAM_OFFSET 0x0C0000 +#define IRAM_SIZE (80 * 1024) +#define DRAM_OFFSET 0x100000 +#define DRAM_SIZE (160 * 1024) + const struct adsp cht_machine = { .name = "cht", .iram_base = 0xff2c0000, .iram_size = 0x14000, + .host_iram_offset = IRAM_OFFSET, .dram_base = 0xff300000, .dram_size = 0x28000, - .image_size = 0xff300000 - 0xff2c0000 + 0x28000, - .dram_offset = 0xff300000 - 0xff2c0000, + .host_dram_offset = DRAM_OFFSET, .machine_id = MACHINE_CHERRYTRAIL, .ops = { .write_header = byt_write_header, diff --git a/rimage/file_format.h b/rimage/file_format.h index 941df332549f..c813f49c0bc2 100644 --- a/rimage/file_format.h +++ b/rimage/file_format.h @@ -1,88 +1,116 @@ /* - * ELF to firmware image creator. + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. * - * Copyright (c) 2015, Intel Corporation. + * GPL LICENSE SUMMARY * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. + * Copyright(c) 2017 Intel Corporation. All rights reserved. * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * BSD LICENSE + * + * Copyright(c) 2017 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Liam Girdwood */ -#ifndef __FILE_FORMAT_H__ -#define __FILE_FORMAT_H__ +/* + * Firmware file format . + */ -#define REEF_FW_SIGNATURE_SIZE 4 -#define REEF_FW_SIGN "$SST" -#define REEF_FW_LIB_SIGN "$LIB" +#ifndef __INCLUDE_UAPI_SOF_FW_H__ +#define __INCLUDE_UAPI_SOF_FW_H__ -#define REEF_IRAM 1 -#define REEF_DRAM 2 -#define REEF_REGS 3 -#define REEF_CACHE 3 +#define SND_SOF_FW_SIG_SIZE 4 +#define SND_SOF_FW_ABI 1 +#define SND_SOF_FW_SIG "Reef" -enum reef_module_id { - REEF_MODULE_BASE_FW = 0x0, - REEF_MODULE_MP3 = 0x1, - REEF_MODULE_AAC_5_1 = 0x2, - REEF_MODULE_AAC_2_0 = 0x3, - REEF_MODULE_SRC = 0x4, - REEF_MODULE_WAVES = 0x5, - REEF_MODULE_DOLBY = 0x6, - REEF_MODULE_BOOST = 0x7, - REEF_MODULE_LPAL = 0x8, - REEF_MODULE_DTS = 0x9, - REEF_MODULE_PCM_CAPTURE = 0xA, - REEF_MODULE_PCM_SYSTEM = 0xB, - REEF_MODULE_PCM_REFERENCE = 0xC, - REEF_MODULE_PCM = 0xD, - REEF_MODULE_BLUETOOTH_RENDER_MODULE = 0xE, - REEF_MODULE_BLUETOOTH_CAPTURE_MODULE = 0xF, - REEF_MAX_MODULE_ID, +/* + * Firmware module is made up of 1 . N blocks of different types. The + * Block header is used to determine where and how block is to be copied in the + * DSP/host memory space. + */ +enum snd_sof_fw_blk_type { + SOF_BLK_IMAGE = 0, /* whole image - parsed by ROMs */ + SOF_BLK_TEXT = 1, + SOF_BLK_DATA = 2, + SOF_BLK_CACHE = 3, + SOF_BLK_REGS = 4, + SOF_BLK_SIG = 5, + SOF_BLK_ROM = 6, + /* add new block types here */ }; -struct dma_block_info { - uint32_t type; /* IRAM/DRAM */ - uint32_t size; /* Bytes */ - uint32_t ram_offset; /* Offset in I/DRAM */ - uint32_t rsvd; /* Reserved field */ +struct snd_sof_blk_hdr { + enum snd_sof_fw_blk_type type; + uint32_t size; /* bytes minus this header */ + uint32_t offset; /* offset from base */ } __attribute__((packed)); -struct fw_module_info { - uint32_t persistent_size; - uint32_t scratch_size; -} __attribute__((packed)); +/* + * Firmware file is made up of 1 .. N different modules types. The module + * type is used to determine how to load and parse the module. + */ +enum snd_sof_fw_mod_type { + SOF_FW_BASE = 0, /* base firmware image */ + SOF_FW_MODULE = 1, /* firmware module */ +}; -struct fw_header { - unsigned char signature[REEF_FW_SIGNATURE_SIZE]; /* FW signature */ - uint32_t file_size; /* size of fw minus this header */ - uint32_t modules; /* # of modules */ - uint32_t file_format; /* version of header format */ - uint32_t reserved[4]; +struct snd_sof_mod_hdr { + enum snd_sof_fw_mod_type type; + uint32_t size; /* bytes minus this header */ + uint32_t num_blocks; /* number of blocks */ } __attribute__((packed)); -/* ABI 0 - used by reef driver and CoE BDW/HSW firmware*/ -struct hsw_module_header { - unsigned char signature[REEF_FW_SIGNATURE_SIZE]; /* module signature */ - uint32_t mod_size; /* size of module */ - uint32_t blocks; /* # of blocks */ - uint16_t padding; - uint16_t type; /* codec type, pp lib */ - uint32_t entry_point; - struct fw_module_info info; +/* + * Firmware file header. + */ +struct snd_sof_fw_header { + unsigned char sig[SND_SOF_FW_SIG_SIZE]; /* "Reef" */ + uint32_t file_size; /* size of file minus this header */ + uint32_t num_modules; /* number of modules */ + uint32_t abi; /* version of header format */ } __attribute__((packed)); -/* ABI 1 - used by CoE/MCG BYT/CHT/BSW driver */ -struct byt_module_header { - unsigned char signature[REEF_FW_SIGNATURE_SIZE]; - uint32_t mod_size; /* size of module */ - uint32_t blocks; /* # of blocks */ - uint32_t type; /* codec type, pp lib */ - uint32_t entry_point; -}__attribute__((packed)); - #endif diff --git a/rimage/rimage.c b/rimage/rimage.c index bed6b48cd8c3..0695ce34398c 100644 --- a/rimage/rimage.c +++ b/rimage/rimage.c @@ -223,9 +223,12 @@ int main(int argc, char *argv[]) { struct image image; const char *mach = NULL; - int opt, ret, i, binary = 0; + int opt, ret, i; memset(&image, 0, sizeof(image)); + image.text_start = 0xffffffff; + image.data_start = 0xffffffff; + image.bss_start = 0xffffffff; while ((opt = getopt(argc, argv, "ho:i:m:vba:sk:")) != -1) { switch (opt) { @@ -241,9 +244,6 @@ int main(int argc, char *argv[]) case 'v': image.verbose = 1; break; - case 'b': - binary = 1; - break; case 's': image.dump_sections = 1; break; @@ -282,26 +282,16 @@ int main(int argc, char *argv[]) image.in_file, errno); } - /* open outfile for reading */ + /* open outfile for writing */ + unlink(image.out_file); image.out_fd = fopen(image.out_file, "w"); if (image.out_fd == NULL) { fprintf(stderr, "error: unable to open %s for writing %d\n", image.out_file, errno); } - if (binary) { - - switch(image.adsp->machine_id) { - case MACHINE_BAYTRAIL: - ret = write_byt_binary_image(&image); - break; - default: - fprintf(stderr, "error: not supported machine for binary input!\n"); - return ret; - } - - } else - ret = write_elf_data(&image); + /* write data */ + ret = write_elf_data(&image); /* close files */ fclose(image.out_fd); diff --git a/rimage/rimage.h b/rimage/rimage.h index 2c029328ceaa..9b8200afa36d 100644 --- a/rimage/rimage.h +++ b/rimage/rimage.h @@ -50,6 +50,13 @@ struct image { int data_size; int file_size; int num_modules; + uint32_t text_start; + uint32_t text_end; + uint32_t data_start; + uint32_t data_end; + uint32_t bss_start; + uint32_t bss_end; + /* disa */ void *in_buffer; @@ -82,8 +89,12 @@ struct adsp { uint32_t iram_size; uint32_t dram_base; uint32_t dram_size; + uint32_t host_iram_offset; + uint32_t host_dram_offset; + uint32_t image_size; uint32_t dram_offset; + enum machine_id machine_id; struct adsp_ops ops; const struct section *sections; From e03147d755a8f1c9c8557fd35a7da6825676e465 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 9 Jun 2017 14:36:33 +0100 Subject: [PATCH 006/324] rmbox: add support for new trace classes. Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index d2247f76284a..6105e38e7bda 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -34,6 +34,10 @@ #define TRACE_CLASS_LOCK (10 << 24) #define TRACE_CLASS_MEM (11 << 24) #define TRACE_CLASS_MIXER (12 << 24) +#define TRACE_CLASS_BUFFER (13 << 24) +#define TRACE_CLASS_VOLUME (14 << 24) +#define TRACE_CLASS_SWITCH (15 << 24) +#define TRACE_CLASS_MUX (16 << 24) #define MAILBOX_HOST_OFFSET 0x144000 @@ -134,6 +138,14 @@ static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp) trace = "mem"; else if (class == TRACE_CLASS_MIXER) trace = "mixer"; + else if (class == TRACE_CLASS_BUFFER) + trace = "buffer"; + else if (class == TRACE_CLASS_VOLUME) + trace = "volume"; + else if (class == TRACE_CLASS_SWITCH) + trace = "switch"; + else if (class == TRACE_CLASS_MUX) + trace = "mux"; else { printf("value 0x%8.8x\n", (uint32_t)val); return; From 778d7209cbede1f67f356af3600001095129c6ad Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 9 Jun 2017 14:37:14 +0100 Subject: [PATCH 007/324] rmbox: return -EIO and bail on any file open() errors Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 6105e38e7bda..0983ca65c1e5 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -267,6 +267,7 @@ int main(int argc, char *argv[]) if (in_fd == NULL) { fprintf(stderr, "error: unable to open %s for reading %d\n", in_file, errno); + return -EIO; } /* open outfile for writing */ @@ -277,6 +278,7 @@ int main(int argc, char *argv[]) if (out_fd == NULL) { fprintf(stderr, "error: unable to open %s for writing %d\n", out_file, errno); + return -EIO; } /* start to converting mailbox */ From 1b0a663b0d2da4a99c5668aba7f3bf525e388c86 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 9 Jun 2017 14:55:36 +0100 Subject: [PATCH 008/324] rmbox: add support for different CPU clock speeds Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 0983ca65c1e5..f5e9c34a91e4 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -92,14 +92,14 @@ static void usage(char *name) exit(0); } -static inline float clk_to_usecs(uint32_t time) +static inline float to_usecs(uint32_t time, uint32_t clk) { - /* trace timestamp uses SSP system clock at default 19.2MHz ticks */ + /* trace timestamp uses CPU system clock at default 25MHz ticks */ // TODO: support variable clock rates - return (float)time / 19.2; + return (float)time / clk; } -static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp) +static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp, uint32_t clk) { const char *trace; uint32_t class; @@ -107,8 +107,8 @@ static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp) /* timestamp or value ? */ if ((addr % 8) == 0) { printf("trace.io: timestamp 0x%8.8x (%2.2f us) \tdelta 0x%8.8x (%2.2f us)\t", - (uint32_t)val, clk_to_usecs(val), - (uint32_t)val - *timestamp, clk_to_usecs(val - *timestamp)); + (uint32_t)val, to_usecs(val, clk), + (uint32_t)val - *timestamp, to_usecs(val - *timestamp, clk)); *timestamp = val; return; } @@ -238,12 +238,12 @@ static int snapshot(const char *name) int main(int argc, char *argv[]) { int opt, count; - const char * out_file = NULL, *in_file = "/sys/kernel/debug/mbox"; + const char * out_file = NULL, *in_file = "/sys/kernel/debug/sof/mbox"; FILE *in_fd = NULL, *out_fd = NULL; char c, tmp[4] = {0}; - uint32_t addr = 0, val, timestamp = 0; + uint32_t addr = 0, val, clk = 25, timestamp = 0; - while ((opt = getopt(argc, argv, "ho:i:s:m:")) != -1) { + while ((opt = getopt(argc, argv, "ho:i:s:m:c:")) != -1) { switch (opt) { case 'o': out_file = optarg; @@ -251,6 +251,9 @@ int main(int argc, char *argv[]) case 'i': in_file = optarg; break; + case 'c': + clk = atoi(optarg); + break; case 's': return snapshot(optarg); case 'h': @@ -299,7 +302,7 @@ int main(int argc, char *argv[]) if (addr >= MAILBOX_TRACE_OFFSET && addr < MAILBOX_TRACE_OFFSET + MAILBOX_TRACE_SIZE) - show_trace(val, addr, ×tamp); + show_trace(val, addr, ×tamp, clk); else if (addr >= MAILBOX_DEBUG_OFFSET && addr < MAILBOX_DEBUG_OFFSET + MAILBOX_DEBUG_SIZE) show_debug(val, addr); From 321aa0504d59b85e7dbcb60cc32ca2cd0ace2b3a Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 15 Jun 2017 14:33:39 +0100 Subject: [PATCH 009/324] rimage: show correct error on write failure. Signed-off-by: Liam Girdwood --- rimage/baytrail.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rimage/baytrail.c b/rimage/baytrail.c index 12ccd2355224..ed1c8409effe 100644 --- a/rimage/baytrail.c +++ b/rimage/baytrail.c @@ -159,7 +159,8 @@ int byt_write_modules(struct image *image) count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); if (count != 1) { - fprintf(stderr, "error: failed to write section header %d\n", i); + fprintf(stderr, "error: failed to write section header %d\n", + -errno); return -errno ; } From b424e981ec7b8fd9311d03c139609f44ee7940fe Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 15 Jun 2017 14:34:01 +0100 Subject: [PATCH 010/324] rimage: free ELF program and section allocations Signed-off-by: Liam Girdwood --- rimage/rimage.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rimage/rimage.c b/rimage/rimage.c index 0695ce34398c..af57f5a55d3c 100644 --- a/rimage/rimage.c +++ b/rimage/rimage.c @@ -208,6 +208,9 @@ static int write_elf_data(struct image *image) goto out; } + free(image->prg); + free(image->section); + out: return ret; } From 9b241ae555b770ccab6968a38bb3aef00aedb66c Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 15 Jun 2017 14:36:24 +0100 Subject: [PATCH 011/324] rmbox: make sure we close all files Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index f5e9c34a91e4..83d3c6e24c0e 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -230,6 +230,8 @@ static int snapshot(const char *name) addr += 4; } + fclose(in_fd); + fclose(out_fd); } return 0; @@ -281,6 +283,7 @@ int main(int argc, char *argv[]) if (out_fd == NULL) { fprintf(stderr, "error: unable to open %s for writing %d\n", out_file, errno); + fclose(in_fd); return -EIO; } From b8c9db4f6b102cf41f3cc569bee46f055417091a Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 6 Jul 2017 16:39:29 +0100 Subject: [PATCH 012/324] topology: Add initial SOF topology pipeline definitions Add pipeline and token definitions to allow creation of SOF topology files. The files define standard pipelines and tokens that can be reused to build machine specific topology files. Signed-off-by: Liam Girdwood --- topology/sof/pipe-dai.m4 | 24 ++++ topology/sof/pipe-low-latency-capture.m4 | 107 ++++++++++++++ topology/sof/pipe-low-latency-playback.m4 | 167 ++++++++++++++++++++++ topology/sof/pipe-pcm-media.m4 | 136 ++++++++++++++++++ topology/sof/pipe-tone.m4 | 75 ++++++++++ topology/sof/tokens.m4 | 38 +++++ 6 files changed, 547 insertions(+) create mode 100644 topology/sof/pipe-dai.m4 create mode 100644 topology/sof/pipe-low-latency-capture.m4 create mode 100644 topology/sof/pipe-low-latency-playback.m4 create mode 100644 topology/sof/pipe-pcm-media.m4 create mode 100644 topology/sof/pipe-tone.m4 create mode 100644 topology/sof/tokens.m4 diff --git a/topology/sof/pipe-dai.m4 b/topology/sof/pipe-dai.m4 new file mode 100644 index 000000000000..06ac453ea7da --- /dev/null +++ b/topology/sof/pipe-dai.m4 @@ -0,0 +1,24 @@ +# DAI connector + +# Include topology builder +include(`local.m4') + +# +# DAI definitions +# +W_DAI_OUT(DAI_SNAME, dai0p_plat_conf) +W_DAI_IN(DAI_SNAME, dai0c_plat_conf) + +#D_DAI(0, 1, 1) + +# +# Graph connections to pipelines + +SectionGraph.STR(DAI_NAME) { + index "0" + + lines [ + dapm(N_DAI_IN, OUT_BUF) + dapm(IN_BUF, N_DAI_OUT) + ] +} diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 new file mode 100644 index 000000000000..ddb5d8e4fea3 --- /dev/null +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -0,0 +1,107 @@ +# Low Latency Pipeline and PCM +# +# Pipeline Endpoints for connection are :- +# +# host PCM_C <--B5-- volume(0C) <--B4-- source DAI0 + +# Include topology builder +include(`local.m4') + +# +# Controls +# + +SectionControlMixer.STR(PCM PCM_ID Capture Volume) { + + # control belongs to this index group + index STR(PIPELINE_ID) + + # Channel register and shift for Front Left/Right + channel."FL" { + reg "0" + shift "0" + } + channel."FR" { + reg "0" + shift "1" + } + + # control uses bespoke driver get/put/info ID 0 + ops."ctl" { + info "volsw" + get "256" + put "256" + } + + # TLV 40 steps from -90dB to +20dB for 3dB + max "40" + invert "false" + tlv "vtlv_m90s3" +} + +# +# Components and Buffers +# + +W_PCM_CAPTURE(Low Latency Capture) +W_PGA(Capture Volume) +W_BUFFER(0, BUF_INT_SIZE) +W_BUFFER(1, BUF_PCM_SIZE) + +# +# Pipeline Graph +# +# host PCM <--B1-- volume( <--B0-- source DAI0 + +SectionGraph."pipe-ll-capture-PIPELINE_ID" { + index STR(PIPELINE_ID) + + lines [ + dapm(N_PCM, N_BUFFER(1)) + dapm(N_BUFFER(1), N_PGA(Capture Volume)) + dapm(N_PGA(Capture Volume), N_BUFFER(0)) + ] +} + +# +# Pipeline Configuration. +# + +W_PIPELINE(N_PGA(Capture Volume), SCHEDULE_DEADLINE, pipe_ll_schedule_plat) + +# +# PCM Configuration +# + +SectionPCMCapabilities.STR(Low Latency Capture PCM_ID) { + + formats "S24_LE,S16_LE" + rate_min "48000" + rate_max "48000" + channels_min "2" + channels_max "4" + periods_min "2" + periods_max "4" + period_size_min "192" + period_size_max "16384" + buffer_size_min "384" + buffer_size_max "65536" +} + +# PCM Low Latency Capture +SectionPCM.STR(PCM PCM_ID) { + + index STR(PIPELINE_ID) + + # used for binding to the PCM + id STR(PCM_ID) + + dai.STR(Low Latency Capture PCM_ID) { + id STR(PCM_ID) + } + + pcm."capture" { + + capabilities STR(Low Latency Capture PCM_ID) + } +} diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 new file mode 100644 index 000000000000..6604ad1bc06a --- /dev/null +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -0,0 +1,167 @@ +# Low Latency Pipeline +# +# Low Latency Playback PCM mixed into single sink pipe. +# Low latency Capture PCM. +# +# Pipeline Endpoints for connection are :- +# +# LL Playback Mixer (Mixer) +# LL Capture Volume B4 (DAI buffer) +# LL Playback Volume B3 (DAI buffer) +# +# +# host PCM_P --B0--> volume(0P) --B1--+ +# |--ll mixer(M) --B2--> volume(LL) ---B3--> sink DAI0 +# pipeline n+1 >---+ +# | +# pipeline n+2 >---+ +# | +# pipeline n+3 >---+ .....etc....more pipes can be mixed here +# + +# Include topology builder +include(`local.m4') + +# +# Controls +# + +SectionControlMixer.STR(PCM PCM_ID Playback Volume) { + + # control belongs to this index group + index STR(PIPELINE_ID) + + # Channel register and shift for Front Left/Right + channel."FL" { + reg "0" + shift "0" + } + channel."FR" { + reg "0" + shift "1" + } + + # control uses bespoke driver get/put/info ID 0 + ops."ctl" { + info "volsw" + get "256" + put "256" + } + + # TLV 32 steps from -90dB to +6dB for 3dB + max "32" + invert "false" + tlv "vtlv_m90s3" +} + +SectionControlMixer.STR(Master Playback Volume) { + + # control belongs to this index group + index STR(PIPELINE_ID) + + # Channel register and shift for Front Left/Right + channel."FL" { + reg "1" + shift "0" + } + channel."FR" { + reg "1" + shift "1" + } + + # control uses bespoke driver get/put/info ID 0 + ops."ctl" { + info "volsw" + get "256" + put "256" + } + + # TLV 32 steps from -90dB to +6dB for 3dB + max "32" + invert "false" + tlv "vtlv_m90s3" +} + +# +# Components and Buffers +# + +W_PCM_PLAYBACK(Low Latency Playback) +W_PGA(Playback Volume) +W_PGA(Mixer Volume) +W_MIXER(0) +W_BUFFER(0, BUF_PCM_SIZE) +W_BUFFER(1, BUF_INT_SIZE) +W_BUFFER(2, BUF_INT_SIZE) +W_BUFFER(3, BUF_INT_SIZE) + +# +# Pipeline Graph +# +# host PCM_P --B0--> volume(0P) --B1--+ +# |--ll mixer(M) --B2--> volume(LL) ---B3--> sink DAI0 +# pipeline n+1 >---+ +# | +# pipeline n+2 >---+ +# | +# pipeline n+3 >---+ .....etc....more pipes can be mixed here +# + +SectionGraph."pipe-ll-playback-PIPELINE_ID" { + index STR(PIPELINE_ID) + + lines [ + dapm(N_BUFFER(0), N_PCM) + dapm(N_PGA(Playback Volume), N_BUFFER(0)) + dapm(N_BUFFER(1), N_PGA(Playback Volume)) + dapm(N_MIXER(0), N_BUFFER(1)) + dapm(N_BUFFER(2), N_MIXER(0)) + dapm(N_PGA(Mixer Volume), N_BUFFER(2)) + dapm(N_BUFFER(3), N_PGA(Mixer Volume)) + ] +} + +# +# Pipeline Configuration. +# + +W_PIPELINE(N_PGA(Mixer Volume), SCHEDULE_DEADLINE, pipe_ll_schedule_plat) + +# +# PCM Configuration +# + +# PCM capabilities supported by FW +SectionPCMCapabilities.STR(Low Latency Playback PCM_ID) { + + formats "S24_LE,S16_LE" + rate_min "48000" + rate_max "48000" + channels_min "2" + channels_max "2" + periods_min "2" + periods_max "4" + period_size_min "192" + period_size_max "16384" + buffer_size_min "384" + buffer_size_max "65536" +} + +# PCM Low Latency Playback +SectionPCM.STR(PCM PCM_ID) { + + index STR(PIPELINE_ID) + + # used for binding to the PCM + id STR(PCM_ID) + + dai.STR(Low Latency Playback PCM_ID) { + id STR(PCM_ID) + } + + # Playback and Capture Configuration + pcm."playback" { + + capabilities STR(Low Latency Playback PCM_ID) + } +} diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 new file mode 100644 index 000000000000..688c81f33b96 --- /dev/null +++ b/topology/sof/pipe-pcm-media.m4 @@ -0,0 +1,136 @@ +# Low Power PCM Media Pipeline +# +# Low power PCM media playback with SRC and volume. +# +# Pipeline Endpoints for connection are :- +# +# host PCM_P --B0--> volume(0P) --B1--> SRC -- B2 --> Endpoint Pipeline +# + +# Include topology builder +include(`local.m4') + +# +# Controls +# + +SectionControlMixer.STR(PCM PCM_ID Playback Volume) { + + # control belongs to this index group + index STR(PIPELINE_ID) + + # Channel register and shift for Front Left/Right + channel."FL" { + reg "1" + shift "0" + } + channel."FR" { + reg "1" + shift "1" + } + + # control uses bespoke driver get/put/info ID 0 + ops."ctl" { + info "volsw" + get "256" + put "256" + } + + # TLV 32 steps from -90dB to +6dB for 3dB + max "32" + invert "false" + tlv "vtlv_m90s3" +} + + +# +# SRC Configuration +# + +SectionVendorTuples."media_src_tokens" { + tokens "sof_src_tokens" + + tuples."word" { + SOF_TKN_SRC_RATE_IN 16000 + SOF_TKN_SRC_RATE_IN 44100 + SOF_TKN_SRC_RATE_OUT 48000 + } +} + +SectionData."media_src_conf" { + tuples "media_src_tokens" +} + +# +# Components and Buffers +# + +W_PCM_PLAYBACK(Media Playback) +W_PGA(Playback Volume) +W_SRC(0, media_src_conf) +W_BUFFER(0, BUF_PCM_SIZE) +W_BUFFER(1, BUF_INT_SIZE) +W_BUFFER(2, BUF_INT_SIZE) + +# +# Pipeline Graph +# +# PCM --B0--> volume --B1--> SRC --> B2 --> Endpoint Pipeline +# + +SectionGraph."pipe-media-PIPELINE_ID" { + index STR(PIPELINE_ID) + + lines [ + dapm(N_BUFFER(0), Media Playback PCM_ID) + dapm(N_PGA(Playback Volume), N_BUFFER(0)) + dapm(N_BUFFER(1), N_PGA(Playback Volume)) + dapm(N_SRC(0), N_BUFFER(1)) + dapm(N_BUFFER(2), N_SRC(0)) + ] +} + +# +# Pipeline Configuration. +# + +W_PIPELINE(N_SRC(0), SCHEDULE_DEADLINE, pipe_media_schedule_plat) + +# +# PCM Configuration +# + +# PCM capabilities supported by FW + +SectionPCMCapabilities.STR(Media Playback PCM_ID) { + formats "S24_LE,S16_LE" + rate_min "8000" + rate_max "192000" + channels_min "2" + channels_max "2" + periods_min "2" + periods_max "32" + period_size_min "4096" + period_size_max "262144" + buffer_size_min "8192" + buffer_size_max "8388608" +} + +# PCM Low Latency Playback and Capture +SectionPCM.STR(PCM PCM_ID) { + + index STR(PIPELINE_ID) + + # used for binding to the PCM + id STR(PCM_ID) + + dai.STR(Media Playback PCM_ID) { + id STR(PCM_ID) + } + + # Playback and Capture Configuration + pcm."playback" { + + capabilities STR(Media Playback PCM_ID) + } +} diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 new file mode 100644 index 000000000000..24fe10fb6dd3 --- /dev/null +++ b/topology/sof/pipe-tone.m4 @@ -0,0 +1,75 @@ +# Tone Generator +# +# Multi Frequency Tone Generator. +# +# Pipeline Endpoints for connection are :- +# +# Tone --B0--> volume --B1--> Endpoint Pipeline +# + +# Include topology builder +include(`local.m4') + +# +# Controls +# + +SectionControlMixer.STR(Tone Volume PIPELINE_ID) { + + # control belongs to this index group + index STR(PIPELINE_ID) + + # Channel register and shift for Front Left/Right + channel."FL" { + reg "1" + shift "0" + } + channel."FR" { + reg "1" + shift "1" + } + + # control uses bespoke driver get/put/info ID 0 + ops."ctl" { + info "volsw" + get "256" + put "256" + } + + # TLV 32 steps from -90dB to +6dB for 3dB + max "32" + invert "false" + tlv "vtlv_m90s3" +} + +# +# Components and Buffers +# + +W_TONE(0) +W_PGA(Tone Volume) +W_BUFFER(0, BUF_INT_SIZE) +W_BUFFER(1, BUF_INT_SIZE) + + +# +# Pipeline Graph +# +# Tone --B0--> volume --B1--> Endpoint Pipeline +# + +SectionGraph."pipe-tone-PIPELINE_ID" { + index STR(PIPELINE_ID) + + lines [ + dapm(N_BUFFER(0), N_TONE(0)) + dapm(N_PGA(Tone Volume), N_BUFFER(0)) + dapm(N_BUFFER(1), N_PGA(Tone Volume)) + ] +} + +# +# Pipeline Configuration. +# + +W_PIPELINE(N_TONE(0), SCHEDULE_DEADLINE, pipe_tone_schedule_plat) diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 new file mode 100644 index 000000000000..1ec48df1638e --- /dev/null +++ b/topology/sof/tokens.m4 @@ -0,0 +1,38 @@ + +# +# SOF Tokens for differentiation. +# +# Differentiation can be done at the platform and machine level. +# +# Tokens are GUIDs + +# TODO: pre-process this with UAPI headers GNU cpp. + + +SectionVendorTokens."sof_buffer_tokens" { + SOF_TKN_BUF_SIZE "100" + SOF_TKN_BUF_PRELOAD "101" +} + +SectionVendorTokens."sof_dai_tokens" { + SOF_TKN_DAI_DMAC "151" + SOF_TKN_DAI_DMAC_CHAN "152" + SOF_TKN_DAI_DMAC_CONFIG "153" +} + +SectionVendorTokens."sof_sched_tokens" { + SOF_TKN_SCHED_DEADLINE "200" + SOF_TKN_SCHED_PRIORITY "201" + SOF_TKN_SCHED_MIPS "202" + SOF_TKN_SCHED_CORE "203" +} + +SectionVendorTokens."sof_volume_tokens" { + SOF_TKN_VOLUME_RAMP_STEP_TYPE "250" + SOF_TKN_VOLUME_RAMP_STEP_MS "251" +} + +SectionVendorTokens."sof_src_tokens" { + SOF_TKN_SRC_RATE_IN "300" + SOF_TKN_SRC_RATE_OUT "301" +} From 1c73054da6c977192af71977e92c8858d3bc7f03 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 6 Jul 2017 16:41:09 +0100 Subject: [PATCH 013/324] topology: Add DSP specific topology configuration Add initial configuration for DSP specific data. This data still requires further tuning. Signed-off-by: Liam Girdwood --- topology/dsps/bdw.m4 | 73 ++++++++++++++++++++++++++++++++++++++++++++ topology/dsps/bxt.m4 | 73 ++++++++++++++++++++++++++++++++++++++++++++ topology/dsps/byt.m4 | 73 ++++++++++++++++++++++++++++++++++++++++++++ topology/dsps/cht.m4 | 73 ++++++++++++++++++++++++++++++++++++++++++++ topology/dsps/hsw.m4 | 73 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 365 insertions(+) create mode 100644 topology/dsps/bdw.m4 create mode 100644 topology/dsps/bxt.m4 create mode 100644 topology/dsps/byt.m4 create mode 100644 topology/dsps/cht.m4 create mode 100644 topology/dsps/hsw.m4 diff --git a/topology/dsps/bdw.m4 b/topology/dsps/bdw.m4 new file mode 100644 index 000000000000..24e0156545d4 --- /dev/null +++ b/topology/dsps/bdw.m4 @@ -0,0 +1,73 @@ +# +# Broadwell differentiation for pipelines and components +# + +# Low Latency PCM Configuration +SectionVendorTuples."pipe_ll_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "0" + SOF_TKN_SCHED_MIPS "50000" + } +} + +SectionData."pipe_ll_schedule_plat" { + tuples "pipe_ll_schedule_plat_tokens" +} + +# Media PCM Configuration +SectionVendorTuples."pipe_media_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "1" + SOF_TKN_SCHED_MIPS "100000" + } +} + +SectionData."pipe_media_schedule_plat" { + tuples "pipe_media_schedule_plat_tokens" +} + +# Tone Signal Generator Configuration +SectionVendorTuples."pipe_tone_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "2" + SOF_TKN_SCHED_MIPS "200000" + } +} + +SectionData."pipe_tone_schedule_plat" { + tuples "pipe_tone_schedule_plat_tokens" +} + +# DAI0 platform playback configuration +SectionVendorTuples."dai0p_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "0" + } +} + +SectionData."dai0p_plat_conf" { + tuples "dai0p_plat_tokens" +} + +# DAI0 platform capture configuration +SectionVendorTuples."dai0c_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "1" + } +} + +SectionData."dai0c_plat_conf" { + tuples "dai0c_plat_tokens" +} diff --git a/topology/dsps/bxt.m4 b/topology/dsps/bxt.m4 new file mode 100644 index 000000000000..fe21ae8e0875 --- /dev/null +++ b/topology/dsps/bxt.m4 @@ -0,0 +1,73 @@ +# +# Broxton differentiation for pipelines and components +# + +# Low Latency PCM Configuration +SectionVendorTuples."pipe_ll_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "0" + SOF_TKN_SCHED_MIPS "50000" + } +} + +SectionData."pipe_ll_schedule_plat" { + tuples "pipe_ll_schedule_plat_tokens" +} + +# Media PCM Configuration +SectionVendorTuples."pipe_media_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "1" + SOF_TKN_SCHED_MIPS "100000" + } +} + +SectionData."pipe_media_schedule_plat" { + tuples "pipe_media_schedule_plat_tokens" +} + +# Tone Signal Generator Configuration +SectionVendorTuples."pipe_tone_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "2" + SOF_TKN_SCHED_MIPS "200000" + } +} + +SectionData."pipe_tone_schedule_plat" { + tuples "pipe_tone_schedule_plat_tokens" +} + +# DAI0 platform playback configuration +SectionVendorTuples."dai0p_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "0" + } +} + +SectionData."dai0p_plat_conf" { + tuples "dai0p_plat_tokens" +} + +# DAI0 platform capture configuration +SectionVendorTuples."dai0c_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "1" + } +} + +SectionData."dai0c_plat_conf" { + tuples "dai0c_plat_tokens" +} diff --git a/topology/dsps/byt.m4 b/topology/dsps/byt.m4 new file mode 100644 index 000000000000..8aa393085a0f --- /dev/null +++ b/topology/dsps/byt.m4 @@ -0,0 +1,73 @@ +# +# Baytrail differentiation for pipelines and components +# + +# Low Latency PCM Configuration +SectionVendorTuples."pipe_ll_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "0" + SOF_TKN_SCHED_MIPS "50000" + } +} + +SectionData."pipe_ll_schedule_plat" { + tuples "pipe_ll_schedule_plat_tokens" +} + +# Media PCM Configuration +SectionVendorTuples."pipe_media_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "1" + SOF_TKN_SCHED_MIPS "100000" + } +} + +SectionData."pipe_media_schedule_plat" { + tuples "pipe_media_schedule_plat_tokens" +} + +# Tone Signal Generator Configuration +SectionVendorTuples."pipe_tone_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "2" + SOF_TKN_SCHED_MIPS "200000" + } +} + +SectionData."pipe_tone_schedule_plat" { + tuples "pipe_tone_schedule_plat_tokens" +} + +# DAI0 platform playback configuration +SectionVendorTuples."dai0p_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "0" + } +} + +SectionData."dai0p_plat_conf" { + tuples "dai0p_plat_tokens" +} + +# DAI0 platform capture configuration +SectionVendorTuples."dai0c_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "1" + } +} + +SectionData."dai0c_plat_conf" { + tuples "dai0c_plat_tokens" +} diff --git a/topology/dsps/cht.m4 b/topology/dsps/cht.m4 new file mode 100644 index 000000000000..f6976aa0d118 --- /dev/null +++ b/topology/dsps/cht.m4 @@ -0,0 +1,73 @@ +# +# Cherrytrail differentiation for pipelines and components +# + +# Low Latency PCM Configuration +SectionVendorTuples."pipe_ll_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "0" + SOF_TKN_SCHED_MIPS "50000" + } +} + +SectionData."pipe_ll_schedule_plat" { + tuples "pipe_ll_schedule_plat_tokens" +} + +# Media PCM Configuration +SectionVendorTuples."pipe_media_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "1" + SOF_TKN_SCHED_MIPS "100000" + } +} + +SectionData."pipe_media_schedule_plat" { + tuples "pipe_media_schedule_plat_tokens" +} + +# Tone Signal Generator Configuration +SectionVendorTuples."pipe_tone_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "2" + SOF_TKN_SCHED_MIPS "200000" + } +} + +SectionData."pipe_tone_schedule_plat" { + tuples "pipe_tone_schedule_plat_tokens" +} + +# DAI0 platform playback configuration +SectionVendorTuples."dai0p_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "0" + } +} + +SectionData."dai0p_plat_conf" { + tuples "dai0p_plat_tokens" +} + +# DAI0 platform capture configuration +SectionVendorTuples."dai0c_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "1" + } +} + +SectionData."dai0c_plat_conf" { + tuples "dai0c_plat_tokens" +} diff --git a/topology/dsps/hsw.m4 b/topology/dsps/hsw.m4 new file mode 100644 index 000000000000..1c155a9d4466 --- /dev/null +++ b/topology/dsps/hsw.m4 @@ -0,0 +1,73 @@ +# +# Haswell differentiation for pipelines and components +# + +# Low Latency PCM Configuration +SectionVendorTuples."pipe_ll_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "0" + SOF_TKN_SCHED_MIPS "50000" + } +} + +SectionData."pipe_ll_schedule_plat" { + tuples "pipe_ll_schedule_plat_tokens" +} + +# Media PCM Configuration +SectionVendorTuples."pipe_media_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "1" + SOF_TKN_SCHED_MIPS "100000" + } +} + +SectionData."pipe_media_schedule_plat" { + tuples "pipe_media_schedule_plat_tokens" +} + +# Tone Signal Generator Configuration +SectionVendorTuples."pipe_tone_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_PRIORITY "2" + SOF_TKN_SCHED_MIPS "200000" + } +} + +SectionData."pipe_tone_schedule_plat" { + tuples "pipe_tone_schedule_plat_tokens" +} + +# DAI0 platform playback configuration +SectionVendorTuples."dai0p_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "0" + } +} + +SectionData."dai0p_plat_conf" { + tuples "dai0p_plat_tokens" +} + +# DAI0 platform capture configuration +SectionVendorTuples."dai0c_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "1" + } +} + +SectionData."dai0c_plat_conf" { + tuples "dai0c_plat_tokens" +} From a7a3bc4d5743808c4a99ea646a55dfe2baa2312f Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 6 Jul 2017 16:43:33 +0100 Subject: [PATCH 014/324] topology: Add M4 topology pre-processor macros Add initial macros to simplify the construction of topology components and pipelines. Signed-off-by: Liam Girdwood --- topology/m4/build.m4 | 44 ++++++++++++ topology/m4/local.m4 | 159 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 203 insertions(+) create mode 100644 topology/m4/build.m4 create mode 100644 topology/m4/local.m4 diff --git a/topology/m4/build.m4 b/topology/m4/build.m4 new file mode 100644 index 000000000000..0c40e4eedbfb --- /dev/null +++ b/topology/m4/build.m4 @@ -0,0 +1,44 @@ +#"PIPELINE_PCM_ADD(pipeline, id, pcm, pcm_buf, int_buf, frames, deadline) +define(`PIPELINE_PCM_ADD', +`undefine(`PCM_ID')' +`undefine(`PIPELINE_ID')' +`undefine(`BUF_PCM_SIZE')' +`undefine(`BUF_INT_SIZE')' +`undefine(`SCHEDULE_FRAMES')' +`undefine(`SCHEDULE_DEADLINE')' +`define(`PCM_ID', $3)' +`define(`PIPELINE_ID', $2)' +`define(`BUF_PCM_SIZE', STR($4))' +`define(`BUF_INT_SIZE', STR($5))' +`define(`SCHEDULE_FRAMES', STR($6))' +`define(`SCHEDULE_DEADLINE', STR($7))' +`include($1)' +) + +#PIPELINE_ADD(pipeline, id), int_buf, frames, deadline) +define(`PIPELINE_ADD', +`undefine(`PIPELINE_ID')' +`undefine(`BUF_INT_SIZE')' +`undefine(`SCHEDULE_FRAMES')' +`undefine(`SCHEDULE_DEADLINE')' +`define(`PIPELINE_ID', $2)' +`define(`BUF_INT_SIZE', STR($3))' +`define(`SCHEDULE_FRAMES', STR($4))' +`define(`SCHEDULE_DEADLINE', STR($5))' +`include($1)' +) + +#DAI_ADD(pipeline, dai_name, stream_name, win, wout)) +define(`DAI_ADD', +`undefine(`PIPELINE_ID')' +`undefine(`DAI_NAME')' +`undefine(`DAI_SNAME')' +`undefine(`IN_BUF')' +`undefine(`OUT_BUF')' +`define(`PIPELINE_ID', 0)' +`define(`DAI_NAME', $2)' +`define(`DAI_SNAME', $3)' +`define(`IN_BUF', $4)' +`define(`OUT_BUF', $5)' +`include($1)' +) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 new file mode 100644 index 000000000000..2408830d43ac --- /dev/null +++ b/topology/m4/local.m4 @@ -0,0 +1,159 @@ +define(`concat',`$1$2') + +define(`STR', `"'$1`"') + +#create direct DAPM/pipeline link between 2 widgets) +define(`dapm', `"$1, , $2"') + +#SRC name) +define(`N_SRC', `SRC'PIPELINE_ID`.'$1) + +#W_SRC(name, data)) +define(`W_SRC', `SectionWidget."'N_SRC($1)`" {' +` index "'PIPELINE_ID`"' +` type "src"' +` no_pm "true"' +` data [' +` "'$2`"' +` ]' +`}') + +#Buffer name) +define(`N_BUFFER', `BUF'PIPELINE_ID`.'$1) + +#W_BUFFER(name, size)) +define(`W_BUFFER', +`SectionVendorTuples."'N_BUFFER($1)`_tuples" {' +` tokens "sof_buffer_tokens"' +` tuples."word" {' +` SOF_TKN_BUF_SIZE' $2 +` }' +`}' +`SectionData."'N_BUFFER($1)`_data" {' +` tuples "'N_BUFFER($1)`_tuples"' +`}' +`SectionWidget."'N_BUFFER($1)`" {' +` index "'PIPELINE_ID`"' +` type "buffer"' +` no_pm "true"' +` data [' +` "'N_BUFFER($1)`_data"' +` ]' +`}') + +#PCM name) +define(`N_PCM', `PCM'PCM_ID) + +#W_PCM_PLAYBACK(stream)) +define(`W_PCM_PLAYBACK', `SectionWidget."'N_PCM`" {' +` index "'PIPELINE_ID`"' +` type "aif_out"' +` no_pm "true"' +` stream_name "'$1`"' +`}') + + +#W_PCM_CAPTURE(stream)) +define(`W_PCM_CAPTURE', `SectionWidget."'N_PCM`" {' +` index "'PIPELINE_ID`"' +` type "aif_out"' +` no_pm "true"' +` stream_name "'$1`"' +`}') + +#PGA name) +define(`N_PGA', `PGA'PIPELINE_ID`.'$1) + +#W_PGA(name)) +define(`W_PGA', `SectionWidget."'N_PGA($1)`" {' +` index "'PIPELINE_ID`"' +` type "pga"' +` no_pm "true"' +`}') + +#Mixer Name) +define(`N_MIXER', `MIXER'PIPELINE_ID`.'$1) + +#Pipe Buffer name in pipeline (pipeline, buffer) +define(`NPIPELINE_MIXER', `MIXER'$1`.'$2) + +#W_MIXER(name)) +define(`W_MIXER', `SectionWidget."'N_MIXER($1)`" {' +` index "'PIPELINE_ID`"' +` type "mixer"' +` no_pm "true"' +`}') + + +#Tone name) +define(`N_TONE', `TONE'PIPELINE_ID`.'$1) + +#W_TONE(name)) +define(`W_TONE', `SectionWidget."'N_TONE($1)`" {' +` index "'PIPELINE_ID`"' +` type "siggen"' +` no_pm "true"' +`}') + +#DAI name) +define(`N_DAI', DAI_NAME) +define(`N_DAI_OUT', DAI_NAME`.OUT') +define(`N_DAI_IN', DAI_NAME`.IN') + +#W_DAI_OUT(stream, data)) +define(`W_DAI_OUT', `SectionWidget."'N_DAI_OUT`" {' +` index "'PIPELINE_ID`"' +` type "dai_out"' +` no_pm "true"' +` stream_name "'$1`"' +` data [' +` "'$2`"' +` ]' +`}') + +#W_DAI_IN(stream, data)) +define(`W_DAI_IN', `SectionWidget."'N_DAI_IN`" {' +` index "'PIPELINE_ID`"' +` type "dai_in"' +` no_pm "true"' +` stream_name "'$1`"' +` data [' +` "'$2`"' +` ]' +`}') + +#Pipe Buffer name in pipeline (pipeline, buffer) +define(`NPIPELINE_BUFFER', `BUF'$1`.'$2) + +#Pipeline name) +define(`N_PIPELINE', `PIPELINE.'PIPELINE_ID) + +#W_PIPELINE(stream, deadline, platform)) +define(`W_PIPELINE', +`SectionVendorTuples."'N_PIPELINE`_tuples" {' +` tokens "sof_sched_tokens"' +` tuples."word" {' +` SOF_TKN_SCHED_DEADLINE' $2 +` }' +`}' +`SectionData."'N_PIPELINE`_data" {' +` tuples "'N_PIPELINE`_tuples"' +`}' +`SectionWidget."'N_PIPELINE`" {' +` index "'PIPELINE_ID`"' +` type "scheduler"' +` no_pm "true"' +` stream_name "'$1`"' +` data [' +` "'N_PIPELINE`_data"' +` "'$3`"' +` ]' +`}') + +#D_DAI(id, playback, capture, data)) +define(`D_DAI', `SectionDAI."'N_DAI`" {' +` index "'PIPELINE_ID`"' +` id "'$1`"' +` playback "'$2`"' +` capture "'$3`"' +`}') From e52b9dd37afc1898ced099b2f43018860654918f Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 6 Jul 2017 16:48:06 +0100 Subject: [PATCH 015/324] topology: Add initial TLV library. Add initial TLV library that can be included and re-used by pipelines. Signed-off-by: Liam Girdwood --- topology/common/tlv.m4 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 topology/common/tlv.m4 diff --git a/topology/common/tlv.m4 b/topology/common/tlv.m4 new file mode 100644 index 000000000000..e591fa8116a4 --- /dev/null +++ b/topology/common/tlv.m4 @@ -0,0 +1,14 @@ +# TLV +# +# Common TLV control ranges +# + +SectionTLV."vtlv_m90s3" { + Comment "-90dB step 3dB" + + scale { + min "-9000" + step "300" + mute "1" + } +} From dd08ed7a1927b7f31c459cb9da5341c5a87473fc Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 6 Jul 2017 16:49:37 +0100 Subject: [PATCH 016/324] topology: Add machine specific topology configurations. Add some initial machine specific topology configurations that define some simple pipelines for certain machines. Signed-off-by: Liam Girdwood --- topology/reef-apl-nocodec.m4 | 79 ++++++++++++++++++++++++++++++++++++ topology/reef-bdw-rt286.m4 | 76 ++++++++++++++++++++++++++++++++++ topology/reef-bdw-rt5640.m4 | 76 ++++++++++++++++++++++++++++++++++ topology/reef-bxt-nocodec.m4 | 77 +++++++++++++++++++++++++++++++++++ topology/reef-byt-nocodec.m4 | 77 +++++++++++++++++++++++++++++++++++ topology/reef-byt-rt5640.m4 | 77 +++++++++++++++++++++++++++++++++++ topology/reef-byt-rt5651.m4 | 76 ++++++++++++++++++++++++++++++++++ topology/reef-cht-nocodec.m4 | 77 +++++++++++++++++++++++++++++++++++ topology/reef-hsw-rt5640.m4 | 76 ++++++++++++++++++++++++++++++++++ 9 files changed, 691 insertions(+) create mode 100644 topology/reef-apl-nocodec.m4 create mode 100644 topology/reef-bdw-rt286.m4 create mode 100644 topology/reef-bdw-rt5640.m4 create mode 100644 topology/reef-bxt-nocodec.m4 create mode 100644 topology/reef-byt-nocodec.m4 create mode 100644 topology/reef-byt-rt5640.m4 create mode 100644 topology/reef-byt-rt5651.m4 create mode 100644 topology/reef-cht-nocodec.m4 create mode 100644 topology/reef-hsw-rt5640.m4 diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 new file mode 100644 index 000000000000..f1c181935f79 --- /dev/null +++ b/topology/reef-apl-nocodec.m4 @@ -0,0 +1,79 @@ +# +# Topology for generic Apollolake board with no codec. +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`dsps/bxt.m4') + +# +# Define the pipelines +# + +# Low Latency playback pipeline 1 on PCM 0 +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) + +# Low Latency capture pipeline 2 on PCM 1 +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) + +# PCM Media Playback pipeline 3 on PCM 2 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) + +# PCM Media Playback pipeline 4 on PCM 3 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) + +# Tone Playback pipeline 5 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) + + +# +# DAI configuration +# + +# SSP port 2 is our pipeline DAI +DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) + +# Connect pipelines together +SectionGraph."pipe-apl-nocodec" { + index "0" + + lines [ + # media 0 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + # media 1 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + #tone + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + ] +} + + +# +# BE configurations - overrides config in ACPI if present +# + +# BE configurations - overrides config in ACPI if present +SectionHWConfig."SSP2" { + + id "2" + format "I2S" + bclk_master "true" + bclk_freq "2400000" + mclk_freq "19200000" + fsyn_master "true" + fsync_freq "48000" + tdm_slots "2" + tdm_slot_width "25" + tx_slots "2" + rx_slots "2" +} + diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 new file mode 100644 index 000000000000..38d1c6a1a96b --- /dev/null +++ b/topology/reef-bdw-rt286.m4 @@ -0,0 +1,76 @@ +# +# Topology for generic Broadwell board with no codec. +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Broadwell DSP configuration +include(`dsps/bdw.m4') + +# +# Define the pipelines +# + +# Low Latency playback pipeline 1 on PCM 0 +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) + +# Low Latency capture pipeline 2 on PCM 1 +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) + +# PCM Media Playback pipeline 3 on PCM 2 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) + +# PCM Media Playback pipeline 4 on PCM 3 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) + +# Tone Playback pipeline 5 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) + + +# +# DAI configuration +# + +# SSP port 2 is our pipeline DAI +DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) + +# Connect pipelines together +SectionGraph."pipe-bdw-rt286" { + index "0" + + lines [ + # media 0 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + # media 1 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + #tone + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + ] +} + + +# +# BE configurations - overrides config in ACPI if present +# +SectionHWConfig."SSP0" { + + id "2" + format "I2S" + bclk_master "true" + bclk_freq "2400000" + mclk_freq "24000000" + fsyn_master "true" + fsync_freq "48000" + tdm_slots "2" + tdm_slot_width "25" + tx_slots "2" + rx_slots "2" +} diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 new file mode 100644 index 000000000000..4bdfdb4c006b --- /dev/null +++ b/topology/reef-bdw-rt5640.m4 @@ -0,0 +1,76 @@ +# +# Topology for generic Broadwell board with no codec. +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Broadwell DSP configuration +include(`dsps/bdw.m4') + +# +# Define the pipelines +# + +# Low Latency playback pipeline 1 on PCM 0 +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) + +# Low Latency capture pipeline 2 on PCM 1 +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) + +# PCM Media Playback pipeline 3 on PCM 2 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) + +# PCM Media Playback pipeline 4 on PCM 3 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) + +# Tone Playback pipeline 5 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) + + +# +# DAI configuration +# + +# SSP port 2 is our pipeline DAI +DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) + +# Connect pipelines together +SectionGraph."pipe-bdw-rt5640" { + index "0" + + lines [ + # media 0 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + # media 1 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + #tone + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + ] +} + + +# +# BE configurations - overrides config in ACPI if present +# +SectionHWConfig."SSP0" { + + id "2" + format "I2S" + bclk_master "true" + bclk_freq "2400000" + mclk_freq "24000000" + fsyn_master "true" + fsync_freq "48000" + tdm_slots "2" + tdm_slot_width "25" + tx_slots "2" + rx_slots "2" +} diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 new file mode 100644 index 000000000000..8634d3a3c7b0 --- /dev/null +++ b/topology/reef-bxt-nocodec.m4 @@ -0,0 +1,77 @@ +# +# Topology for generic Broxton board with no codec. +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Broxton DSP configuration +include(`dsps/bxt.m4') + +# +# Define the pipelines +# + +# Low Latency playback pipeline 1 on PCM 0 +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) + +# Low Latency capture pipeline 2 on PCM 1 +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) + +# PCM Media Playback pipeline 3 on PCM 2 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) + +# PCM Media Playback pipeline 4 on PCM 3 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) + +# Tone Playback pipeline 5 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) + + +# +# DAI configuration +# + +# SSP port 2 is our pipeline DAI +DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) + +# Connect pipelines together +SectionGraph."pipe-bxt-nocodec" { + index "0" + + lines [ + # media 0 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + # media 1 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + #tone + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + ] +} + + +# +# BE configurations - overrides config in ACPI if present +# +SectionHWConfig."SSP2" { + + id "2" + format "I2S" + bclk_master "true" + bclk_freq "2400000" + mclk_freq "19200000" + fsyn_master "true" + fsync_freq "48000" + tdm_slots "2" + tdm_slot_width "25" + tx_slots "2" + rx_slots "2" +} + diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 new file mode 100644 index 000000000000..14660fa95acd --- /dev/null +++ b/topology/reef-byt-nocodec.m4 @@ -0,0 +1,77 @@ +# +# Topology for generic Baytrail board with no codec. +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Define the pipelines +# + +# Low Latency playback pipeline 1 on PCM 0 +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) + +# Low Latency capture pipeline 2 on PCM 1 +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) + +# PCM Media Playback pipeline 3 on PCM 2 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) + +# PCM Media Playback pipeline 4 on PCM 3 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) + +# Tone Playback pipeline 5 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) + + +# +# DAI configuration +# + +# SSP port 2 is our pipeline DAI +DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) + +# Connect pipelines together +SectionGraph."pipe-byt-nocodec" { + index "0" + + lines [ + # media 0 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + # media 1 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + #tone + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + ] +} + + +# +# BE configurations - overrides config in ACPI if present +# +SectionHWConfig."SSP2" { + + id "2" + format "I2S" + bclk_master "true" + bclk_freq "2400000" + mclk_freq "19200000" + fsyn_master "true" + fsync_freq "48000" + tdm_slots "2" + tdm_slot_width "25" + tx_slots "2" + rx_slots "2" +} + diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 new file mode 100644 index 000000000000..90acec96a15f --- /dev/null +++ b/topology/reef-byt-rt5640.m4 @@ -0,0 +1,77 @@ +# +# Topology for generic Baytrail board with no codec. +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Define the pipelines +# + +# Low Latency playback pipeline 1 on PCM 0 +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) + +# Low Latency capture pipeline 2 on PCM 1 +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) + +# PCM Media Playback pipeline 3 on PCM 2 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) + +# PCM Media Playback pipeline 4 on PCM 3 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) + +# Tone Playback pipeline 5 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) + + +# +# DAI configuration +# + +# SSP port 2 is our pipeline DAI +DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) + +# Connect pipelines together +SectionGraph."pipe-byt-rt5640" { + index "0" + + lines [ + # media 0 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + # media 1 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + #tone + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + ] +} + + +# +# BE configurations - overrides config in ACPI if present +# +SectionHWConfig."SSP2" { + + id "2" + format "I2S" + bclk_master "true" + bclk_freq "2400000" + mclk_freq "19200000" + fsyn_master "true" + fsync_freq "48000" + tdm_slots "2" + tdm_slot_width "25" + tx_slots "2" + rx_slots "2" +} + diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 new file mode 100644 index 000000000000..e0318076a721 --- /dev/null +++ b/topology/reef-byt-rt5651.m4 @@ -0,0 +1,76 @@ +# +# Topology for generic Baytrail board with no codec. +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Define the pipelines +# + +# Low Latency playback pipeline 1 on PCM 0 +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) + +# Low Latency capture pipeline 2 on PCM 1 +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) + +# PCM Media Playback pipeline 3 on PCM 2 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) + +# PCM Media Playback pipeline 4 on PCM 3 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) + +# Tone Playback pipeline 5 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) + + +# +# DAI configuration +# + +# SSP port 2 is our pipeline DAI +DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) + +# Connect pipelines together +SectionGraph."pipe-byt-rt5651" { + index "0" + + lines [ + # media 0 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + # media 1 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + #tone + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + ] +} + + +# +# BE configurations - overrides config in ACPI if present +# +SectionHWConfig."SSP2" { + + id "2" + format "I2S" + bclk_master "true" + bclk_freq "2400000" + mclk_freq "19200000" + fsyn_master "true" + fsync_freq "48000" + tdm_slots "2" + tdm_slot_width "25" + tx_slots "2" + rx_slots "2" +} diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 new file mode 100644 index 000000000000..6ceed8edd6b4 --- /dev/null +++ b/topology/reef-cht-nocodec.m4 @@ -0,0 +1,77 @@ +# +# Topology for generic CherryTrail board with no codec. +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include CherryTrail DSP configuration +include(`dsps/cht.m4') + +# +# Define the pipelines +# + +# Low Latency playback pipeline 1 on PCM 0 +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) + +# Low Latency capture pipeline 2 on PCM 1 +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) + +# PCM Media Playback pipeline 3 on PCM 2 +#PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) + +# PCM Media Playback pipeline 4 on PCM 3 +#PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) + +# Tone Playback pipeline 5 +#PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) + + +# +# DAI configuration +# + +# SSP port 2 is our pipeline DAI +DAI_ADD(sof/pipe-dai.m4, SSP2, I2S, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) + +# Connect pipelines together +SectionGraph."pipe-cht-nocodec" { + index "0" + + lines [ + # media 0 +# dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + # media 1 +# dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + #tone +# dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + ] +} + +# +# BE configurations - overrides config in ACPI if present +# +SectionHWConfig."SSP2" { + + id "2" + format "I2S" + bclk "master" + bclk_freq "2400000" + mclk "master" + mclk_freq "19200000" + fsync "master" + fsync_freq "48000" + tdm_slots "2" + tdm_slot_width "25" + tx_slots "2" + rx_slots "2" +} + diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 new file mode 100644 index 000000000000..0648df2f7e58 --- /dev/null +++ b/topology/reef-hsw-rt5640.m4 @@ -0,0 +1,76 @@ +# +# Topology for generic Haswell board with no codec. +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Haswell DSP configuration +include(`dsps/hsw.m4') + +# +# Define the pipelines +# + +# Low Latency playback pipeline 1 on PCM 0 +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) + +# Low Latency capture pipeline 2 on PCM 1 +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) + +# PCM Media Playback pipeline 3 on PCM 2 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) + +# PCM Media Playback pipeline 4 on PCM 3 +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) + +# Tone Playback pipeline 5 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) + + +# +# DAI configuration +# + +# SSP port 2 is our pipeline DAI +DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) + +# Connect pipelines together +SectionGraph."pipe-hsw-rt5640" { + index "0" + + lines [ + # media 0 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + # media 1 + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + #tone + dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + ] +} + + +# +# BE configurations - overrides config in ACPI if present +# +SectionHWConfig."SSP0" { + + id "2" + format "I2S" + bclk_master "true" + bclk_freq "2400000" + mclk_freq "24000000" + fsyn_master "true" + fsync_freq "48000" + tdm_slots "2" + tdm_slot_width "25" + tx_slots "2" + rx_slots "2" +} From c52d42685d0d79e418664be5382f4d87941bb640 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 6 Jul 2017 16:52:14 +0100 Subject: [PATCH 017/324] topology: Add build support for topology files. Add support to build topology text files into binary files understood by the drivers. This is a two stage build, the first stage is to pre-process the files with M4 into regular alsa-conf format and the second stage is to compile with the alsa topology compiler. Signed-off-by: Liam Girdwood --- .gitignore | 3 +++ Makefile.am | 2 +- configure.ac | 3 ++- topology/Makefile.am | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 topology/Makefile.am diff --git a/.gitignore b/.gitignore index 145a58d68714..bc827b41e876 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.o *.in +*~ autom4te* *.Po *.swp @@ -16,3 +17,5 @@ ltmain.sh rimage/rimage rmbox/rmbox rwav/rwav +*.tplg +topology/*.conf diff --git a/Makefile.am b/Makefile.am index 3373168af85c..ea0128601270 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1 +1 @@ -SUBDIRS = rimage rmbox +SUBDIRS = rimage rmbox topology diff --git a/configure.ac b/configure.ac index b3d4473bfc3b..87c75194f508 100644 --- a/configure.ac +++ b/configure.ac @@ -16,6 +16,7 @@ AC_OUTPUT([ Makefile rimage/Makefile rmbox/Makefile + topology/Makefile ]) echo " @@ -23,4 +24,4 @@ echo " prefix: ${prefix} Compiler: ${CC} CFLAGS: ${CFLAGS} -" \ No newline at end of file +" diff --git a/topology/Makefile.am b/topology/Makefile.am new file mode 100644 index 000000000000..98661f7ce536 --- /dev/null +++ b/topology/Makefile.am @@ -0,0 +1,41 @@ + +# +# Dependencies +# + +DEPS = \ + dsps/*.m4 \ + common/*.m4 \ + m4/*.m4 \ + sof/*.m4 + +# +# Machines +# + +MACHINES = \ + reef-cht-nocodec.tplg \ + reef-apl-nocodec.tplg \ + reef-bxt-nocodec.tplg \ + reef-byt-nocodec.tplg \ + reef-bdw-rt286.tplg \ + reef-bdw-rt5640.tplg \ + reef-byt-rt5640.tplg \ + reef-byt-rt5651.tplg \ + reef-hsw-rt5640.tplg + +# Uncomment the following line if you want to debug conf files +.PRECIOUS: %.conf + +%.conf : %.m4 ${DEPS} + m4 -I m4 $< > $@ + +%.tplg : %.conf + alsatplg -v 1 -c $< -o $@ + +all: ${MACHINES} + +clean: + rm -f *.conf + rm -f *.tplg + From e50cccdae3afa66462e0ae8a5ae813fb4aaeff19 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 9 Aug 2017 14:36:44 +0100 Subject: [PATCH 018/324] topology: Add token support for PCMs and components buffers. Add topology tokens for PCM and buffer configuration. Signed-off-by: Liam Girdwood --- topology/sof/tokens.m4 | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index 1ec48df1638e..3902c36e3824 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -11,13 +11,14 @@ SectionVendorTokens."sof_buffer_tokens" { SOF_TKN_BUF_SIZE "100" - SOF_TKN_BUF_PRELOAD "101" } SectionVendorTokens."sof_dai_tokens" { SOF_TKN_DAI_DMAC "151" SOF_TKN_DAI_DMAC_CHAN "152" SOF_TKN_DAI_DMAC_CONFIG "153" + SOF_TKN_DAI_TYPE "154" + SOF_TKN_DAI_INDEX "155" } SectionVendorTokens."sof_sched_tokens" { @@ -25,6 +26,7 @@ SectionVendorTokens."sof_sched_tokens" { SOF_TKN_SCHED_PRIORITY "201" SOF_TKN_SCHED_MIPS "202" SOF_TKN_SCHED_CORE "203" + SOF_TKN_SCHED_FRAMES "204" } SectionVendorTokens."sof_volume_tokens" { @@ -36,3 +38,16 @@ SectionVendorTokens."sof_src_tokens" { SOF_TKN_SRC_RATE_IN "300" SOF_TKN_SRC_RATE_OUT "301" } + +SectionVendorTokens."sof_pcm_tokens" { + SOF_TKN_PCM_DMAC "351" + SOF_TKN_PCM_DMAC_CHAN "352" + SOF_TKN_PCM_DMAC_CONFIG "353" +} + +SectionVendorTokens."sof_comp_tokens" { + SOF_TKN_COMP_PERIOD_SINK_COUNT "400" + SOF_TKN_COMP_PERIOD_SOURCE_COUNT "401" + SOF_TKN_COMP_FORMAT "402" + SOF_TKN_COMP_PRELOAD_COUNT "403" +} From 31d540e413deed14e25e409bde26ca4db4104d22 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 9 Aug 2017 14:42:33 +0100 Subject: [PATCH 019/324] topology: builder: Add support pipeline scheduling to topology Allow topology pipelines to define their scheduling. Signed-off-by: Liam Girdwood --- topology/m4/build.m4 | 96 +++++++++--- topology/m4/local.m4 | 359 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 392 insertions(+), 63 deletions(-) diff --git a/topology/m4/build.m4 b/topology/m4/build.m4 index 0c40e4eedbfb..66f656254735 100644 --- a/topology/m4/build.m4 +++ b/topology/m4/build.m4 @@ -1,44 +1,100 @@ -#"PIPELINE_PCM_ADD(pipeline, id, pcm, pcm_buf, int_buf, frames, deadline) +divert(-1) + +dnl PIPELINE_PCM_ADD(pipeline, id, pcm, max channels, format, frames, deadline, priority, core) define(`PIPELINE_PCM_ADD', `undefine(`PCM_ID')' `undefine(`PIPELINE_ID')' -`undefine(`BUF_PCM_SIZE')' -`undefine(`BUF_INT_SIZE')' +`undefine(`PIPELINE_CHANNELS')' +`undefine(`PIPELINE_FORMAT')' `undefine(`SCHEDULE_FRAMES')' `undefine(`SCHEDULE_DEADLINE')' +`undefine(`SCHEDULE_PRIORITY')' +`undefine(`SCHEDULE_CORE')' +`undefine(`PIPELINE_DMAC')' +`undefine(`PIPELINE_DMAC_CHAN')' +`define(`PIPELINE_ID', $2)' `define(`PCM_ID', $3)' +`define(`PIPELINE_CHANNELS', $4)' +`define(`PIPELINE_FORMAT', $5)' +`define(`SCHEDULE_FRAMES', $6)' +`define(`SCHEDULE_DEADLINE', $7)' +`define(`SCHEDULE_PRIORITY', $8)' +`define(`SCHEDULE_CORE', $9)' +`define(`PIPELINE_DMAC', $10)' +`define(`PIPELINE_DMAC_CHAN', $11)' +`include($1)' +) + +dnl PIPELINE_PCM_DAI_ADD(pipeline, id, pcm, max channels, format, frames, +dnl deadline, priority, core, dai type, dai_index, stream_name, periods) +define(`PIPELINE_PCM_DAI_ADD', +`undefine(`PCM_ID')' +`undefine(`PIPELINE_ID')' +`undefine(`PIPELINE_CHANNELS')' +`undefine(`PIPELINE_FORMAT')' +`undefine(`SCHEDULE_FRAMES')' +`undefine(`SCHEDULE_DEADLINE')' +`undefine(`SCHEDULE_PRIORITY')' +`undefine(`SCHEDULE_CORE')' +`undefine(`PIPELINE_DMAC')' +`undefine(`PIPELINE_DMAC_CHAN')' +`undefine(`DAI_TYPE')' +`undefine(`DAI_INDEX')' +`undefine(`DAI_SNAME')' +`undefine(`DAI_PERIODS')' `define(`PIPELINE_ID', $2)' -`define(`BUF_PCM_SIZE', STR($4))' -`define(`BUF_INT_SIZE', STR($5))' -`define(`SCHEDULE_FRAMES', STR($6))' -`define(`SCHEDULE_DEADLINE', STR($7))' +`define(`PCM_ID', $3)' +`define(`PIPELINE_CHANNELS', $4)' +`define(`PIPELINE_FORMAT', $5)' +`define(`SCHEDULE_FRAMES', $6)' +`define(`SCHEDULE_DEADLINE', $7)' +`define(`SCHEDULE_PRIORITY', $8)' +`define(`SCHEDULE_CORE', $9)' +`define(`PIPELINE_DMAC', $10)' +`define(`PIPELINE_DMAC_CHAN', $11)' +`define(`DAI_TYPE', STR($12))' +`define(`DAI_INDEX', STR($13))' +`define(`DAI_SNAME', $14)' +`define(`DAI_PERIODS', $15)' +`define(`DAI_NAME', $12$13)' `include($1)' ) -#PIPELINE_ADD(pipeline, id), int_buf, frames, deadline) +dnl PIPELINE_ADD(pipeline, id, max channels, format, frames, deadline, priority, core) define(`PIPELINE_ADD', `undefine(`PIPELINE_ID')' -`undefine(`BUF_INT_SIZE')' +`undefine(`PIPELINE_CHANNELS')' +`undefine(`PIPELINE_FORMAT')' `undefine(`SCHEDULE_FRAMES')' `undefine(`SCHEDULE_DEADLINE')' +`undefine(`SCHEDULE_PRIORITY')' +`undefine(`SCHEDULE_CORE')' `define(`PIPELINE_ID', $2)' -`define(`BUF_INT_SIZE', STR($3))' -`define(`SCHEDULE_FRAMES', STR($4))' -`define(`SCHEDULE_DEADLINE', STR($5))' +`define(`PIPELINE_CHANNELS', $3)' +`define(`PIPELINE_FORMAT', $4)' +`define(`SCHEDULE_FRAMES', $5)' +`define(`SCHEDULE_DEADLINE', $6)' +`define(`SCHEDULE_PRIORITY', $7)' +`define(`SCHEDULE_CORE', $8)' `include($1)' ) -#DAI_ADD(pipeline, dai_name, stream_name, win, wout)) +dnl DAI_ADD(pipeline, dai type, dai_index, stream_name, buffer, periods) define(`DAI_ADD', `undefine(`PIPELINE_ID')' -`undefine(`DAI_NAME')' +`undefine(`DAI_TYPE')' +`undefine(`DAI_INDEX')' `undefine(`DAI_SNAME')' -`undefine(`IN_BUF')' -`undefine(`OUT_BUF')' +`undefine(`DAI_BUF')' +`undefine(`DAI_PERIODS')' `define(`PIPELINE_ID', 0)' -`define(`DAI_NAME', $2)' -`define(`DAI_SNAME', $3)' -`define(`IN_BUF', $4)' -`define(`OUT_BUF', $5)' +`define(`DAI_TYPE', STR($2))' +`define(`DAI_INDEX', STR($3))' +`define(`DAI_SNAME', $4)' +`define(`DAI_BUF', $5)' +`define(`DAI_NAME', $2$3)' +`define(`DAI_PERIODS', $6)' `include($1)' ) + +divert(0)dnl diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 2408830d43ac..a888438abd74 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -1,32 +1,57 @@ +divert(-1) + define(`concat',`$1$2') define(`STR', `"'$1`"') -#create direct DAPM/pipeline link between 2 widgets) +dnl create direct DAPM/pipeline link between 2 widgets) define(`dapm', `"$1, , $2"') -#SRC name) +dnl SRC name) define(`N_SRC', `SRC'PIPELINE_ID`.'$1) -#W_SRC(name, data)) -define(`W_SRC', `SectionWidget."'N_SRC($1)`" {' +dnl W_SRC(name, format, periods_sink, periods_source, data, preload) +define(`W_SRC', +`SectionVendorTuples."'N_SRC($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_SRC($1)`_data_w" {' +` tuples "'N_SRC($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_SRC($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_SRC($1)`_data_str" {' +` tuples "'N_SRC($1)`_tuples_str"' +`}' +`SectionWidget."'N_SRC($1)`" {' ` index "'PIPELINE_ID`"' ` type "src"' ` no_pm "true"' ` data [' +` "'N_SRC($1)`_data_w"' +` "'N_SRC($1)`_data_str"' ` "'$2`"' ` ]' `}') -#Buffer name) +dnl Buffer name) define(`N_BUFFER', `BUF'PIPELINE_ID`.'$1) -#W_BUFFER(name, size)) +dnl W_BUFFER(name, size) define(`W_BUFFER', `SectionVendorTuples."'N_BUFFER($1)`_tuples" {' ` tokens "sof_buffer_tokens"' ` tuples."word" {' -` SOF_TKN_BUF_SIZE' $2 +` SOF_TKN_BUF_SIZE' STR($2) ` }' `}' `SectionData."'N_BUFFER($1)`_data" {' @@ -41,119 +66,367 @@ define(`W_BUFFER', ` ]' `}') -#PCM name) +dnl PCM name) define(`N_PCM', `PCM'PCM_ID) -#W_PCM_PLAYBACK(stream)) -define(`W_PCM_PLAYBACK', `SectionWidget."'N_PCM`" {' +dnl W_PCM_PLAYBACK(stream, dmac, dmac_chan, periods_sink, periods_source, preload) +dnl PCM platform configuration +define(`W_PCM_PLAYBACK', +`SectionVendorTuples."'N_PCM($1)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` }' +`}' +`SectionData."'N_PCM($1)`_data_w_comp" {' +` tuples "'N_PCM($1)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_PCM($1)`_tuples" {' +` tokens "sof_pcm_tokens"' +` tuples."word" {' +` SOF_TKN_PCM_DMAC' STR($2) +` SOF_TKN_PCM_DMAC_CHAN' STR($3) +` }' +`}' +`SectionData."'N_PCM($1)`_data" {' +` tuples "'N_PCM($1)`_tuples"' +`}' +`SectionWidget."'N_PCM`" {' ` index "'PIPELINE_ID`"' ` type "aif_out"' ` no_pm "true"' ` stream_name "'$1`"' +` data [' +` "'N_PCM($1)`_data"' +` "'N_PCM($1)`_data_w_comp"' +` ]' `}') -#W_PCM_CAPTURE(stream)) -define(`W_PCM_CAPTURE', `SectionWidget."'N_PCM`" {' +dnl W_PCM_PLAYBACK(stream, dmac, dmac_chan, periods_sink, periods_source, preload) +define(`W_PCM_CAPTURE', +`SectionVendorTuples."'N_PCM($1)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` }' +`}' +`SectionData."'N_PCM($1)`_data_w_comp" {' +` tuples "'N_PCM($1)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_PCM($1)`_tuples" {' +` tokens "sof_pcm_tokens"' +` tuples."word" {' +` SOF_TKN_PCM_DMAC' STR($2) +` SOF_TKN_PCM_DMAC_CHAN' STR($3) +` }' +`}' +`SectionData."'N_PCM($1)`_data" {' +` tuples "'N_PCM($1)`_tuples"' +`}' +`SectionWidget."'N_PCM`" {' ` index "'PIPELINE_ID`"' ` type "aif_out"' ` no_pm "true"' ` stream_name "'$1`"' +` data [' +` "'N_PCM($1)`_data"' +` "'N_PCM($1)`_data_w_comp"' +` ]' `}') -#PGA name) +dnl PGA name) define(`N_PGA', `PGA'PIPELINE_ID`.'$1) -#W_PGA(name)) -define(`W_PGA', `SectionWidget."'N_PGA($1)`" {' +dnl W_PGA(name, format, periods_sink, periods_source, preload) +define(`W_PGA', +`SectionVendorTuples."'N_PGA($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_PGA($1)`_data_w" {' +` tuples "'N_PGA($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_PGA($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_PGA($1)`_data_str" {' +` tuples "'N_PGA($1)`_tuples_str"' +`}' +`SectionWidget."'N_PGA($1)`" {' ` index "'PIPELINE_ID`"' ` type "pga"' ` no_pm "true"' +` data [' +` "'N_PGA($1)`_data_w"' +` "'N_PGA($1)`_data_str"' +` ]' `}') -#Mixer Name) +dnl Mixer Name) define(`N_MIXER', `MIXER'PIPELINE_ID`.'$1) -#Pipe Buffer name in pipeline (pipeline, buffer) +dnl Pipe Buffer name in pipeline (pipeline, buffer) define(`NPIPELINE_MIXER', `MIXER'$1`.'$2) -#W_MIXER(name)) -define(`W_MIXER', `SectionWidget."'N_MIXER($1)`" {' +dnl W_MIXER(name, format, periods_sink, periods_source, preload) +define(`W_MIXER', +`SectionVendorTuples."'N_MIXER($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_MIXER($1)`_data_w" {' +` tuples "'N_MIXER($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_MIXER($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_MIXER($1)`_data_str" {' +` tuples "'N_MIXER($1)`_tuples_str"' +`}' +`SectionWidget."'N_MIXER($1)`" {' ` index "'PIPELINE_ID`"' ` type "mixer"' ` no_pm "true"' +` data [' +` "'N_MIXER($1)`_data_w"' +` "'N_MIXER($1)`_data_str"' +` ]' `}') -#Tone name) +dnl Tone name) define(`N_TONE', `TONE'PIPELINE_ID`.'$1) -#W_TONE(name)) -define(`W_TONE', `SectionWidget."'N_TONE($1)`" {' +dnl W_TONE(name, format, periods_sink, periods_source, preload) +define(`W_TONE', +`SectionVendorTuples."'N_TONE($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_TONE($1)`_data_w" {' +` tuples "'N_TONE($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_TONE($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_TONE($1)`_data_str" {' +` tuples "'N_TONE($1)`_tuples_str"' +`}' +`SectionWidget."'N_TONE($1)`" {' ` index "'PIPELINE_ID`"' ` type "siggen"' ` no_pm "true"' +` data [' +` "'N_TONE($1)`_data_w"' +` "'N_TONE($1)`_data_str"' +` ]' `}') -#DAI name) +dnl DAI name) define(`N_DAI', DAI_NAME) define(`N_DAI_OUT', DAI_NAME`.OUT') define(`N_DAI_IN', DAI_NAME`.IN') -#W_DAI_OUT(stream, data)) -define(`W_DAI_OUT', `SectionWidget."'N_DAI_OUT`" {' +dnl W_DAI_OUT(stream, type, index, data, periods_sink, periods_source, preload) +define(`W_DAI_OUT', +`SectionVendorTuples."'N_DAI_IN($1)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) +` }' +`}' +`SectionData."'N_DAI_IN($1)`_data_w_comp" {' +` tuples "'N_DAI_IN($1)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_DAI_OUT($1)`_tuples_w" {' +` tokens "sof_dai_tokens"' +` tuples."word" {' +` SOF_TKN_DAI_INDEX' $3 +` }' +`}' +`SectionData."'N_DAI_OUT($1)`_data_w" {' +` tuples "'N_DAI_OUT($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_DAI_OUT($1)`_tuples_str" {' +` tokens "sof_dai_tokens"' +` tuples."string" {' +` SOF_TKN_DAI_TYPE' $2 +` }' +`}' +`SectionData."'N_DAI_OUT($1)`_data_str" {' +` tuples "'N_DAI_OUT($1)`_tuples_str"' +`}' +`SectionWidget."'N_DAI_OUT`" {' ` index "'PIPELINE_ID`"' -` type "dai_out"' +` type "dai_in"' ` no_pm "true"' ` stream_name "'$1`"' ` data [' -` "'$2`"' +` "'N_DAI_OUT($1)`_data_w"' +` "'N_DAI_IN($1)`_data_w_comp"' +` "'N_DAI_OUT($1)`_data_str"' +` "'$4`"' ` ]' `}') -#W_DAI_IN(stream, data)) -define(`W_DAI_IN', `SectionWidget."'N_DAI_IN`" {' +dnl W_DAI_IN(stream, type, index, data, periods_sink, periods_source, preload) +define(`W_DAI_IN', +`SectionVendorTuples."'N_DAI_IN($1)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) +` }' +`}' +`SectionData."'N_DAI_IN($1)`_data_w_comp" {' +` tuples "'N_DAI_IN($1)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_DAI_IN($1)`_tuples_w" {' +` tokens "sof_dai_tokens"' +` tuples."word" {' +` SOF_TKN_DAI_INDEX' $3 +` }' +`}' +`SectionData."'N_DAI_IN($1)`_data_w" {' +` tuples "'N_DAI_IN($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_DAI_IN($1)`_tuples_str" {' +` tokens "sof_dai_tokens"' +` tuples."string" {' +` SOF_TKN_DAI_TYPE' $2 +` }' +`}' +`SectionData."'N_DAI_IN($1)`_data_str" {' +` tuples "'N_DAI_IN($1)`_tuples_str"' +`}' +`SectionWidget."'N_DAI_IN`" {' ` index "'PIPELINE_ID`"' -` type "dai_in"' +` type "dai_out"' ` no_pm "true"' ` stream_name "'$1`"' ` data [' -` "'$2`"' +` "'N_DAI_IN($1)`_data_w"' +` "'N_DAI_IN($1)`_data_w_comp"' +` "'N_DAI_IN($1)`_data_str"' +` "'$4`"' ` ]' `}') -#Pipe Buffer name in pipeline (pipeline, buffer) +dnl Pipe Buffer name in pipeline (pipeline, buffer) define(`NPIPELINE_BUFFER', `BUF'$1`.'$2) -#Pipeline name) -define(`N_PIPELINE', `PIPELINE.'PIPELINE_ID) +dnl Pipeline name) +define(`N_PIPELINE', `PIPELINE.'PIPELINE_ID`.'$1) -#W_PIPELINE(stream, deadline, platform)) +dnl W_PIPELINE(stream, deadline, priority, frames, core, platform) define(`W_PIPELINE', -`SectionVendorTuples."'N_PIPELINE`_tuples" {' +`SectionVendorTuples."'N_PIPELINE($1)`_tuples" {' ` tokens "sof_sched_tokens"' ` tuples."word" {' -` SOF_TKN_SCHED_DEADLINE' $2 +` SOF_TKN_SCHED_DEADLINE' STR($2) +` SOF_TKN_SCHED_PRIORITY' STR($3) +` SOF_TKN_SCHED_CORE' STR($5) +` SOF_TKN_SCHED_FRAMES' STR($4) ` }' `}' -`SectionData."'N_PIPELINE`_data" {' -` tuples "'N_PIPELINE`_tuples"' +`SectionData."'N_PIPELINE($1)`_data" {' +` tuples "'N_PIPELINE($1)`_tuples"' `}' -`SectionWidget."'N_PIPELINE`" {' +`SectionWidget."'N_PIPELINE($1)`" {' ` index "'PIPELINE_ID`"' ` type "scheduler"' ` no_pm "true"' ` stream_name "'$1`"' ` data [' -` "'N_PIPELINE`_data"' -` "'$3`"' +` "'N_PIPELINE($1)`_data"' +` "'$6`"' ` ]' `}') -#D_DAI(id, playback, capture, data)) +dnl D_DAI(id, playback, capture, data)) define(`D_DAI', `SectionDAI."'N_DAI`" {' ` index "'PIPELINE_ID`"' ` id "'$1`"' ` playback "'$2`"' ` capture "'$3`"' `}') + +dnl DAI_CLOCK(clock, freq, codec_master) +define(`DAI_CLOCK', + $1 STR($3) + $1_freq STR($2)) + + +dnl DAI_TDM(slots, width, tx_mask, rx_mask) +define(`DAI_TDM', +` tdm_slots 'STR($1) +` tdm_slot_width 'STR($2) +` tx_slots 'STR($3) +` rx_slots 'STR($4) +) + +dnl DAI_CONFIG(type, idx, name, sname, format, mclk, bclk, fsync, tdm) +define(`DAI_CONFIG', +`SectionHWConfig."'$1$2`" {' +`' +` id "'$2`"' +` format "'$5`"' +`' +` '$6 +` '$7 +` '$8 +` '$9 +`}' +`' +`SectionBE."'$3`" {' +` index "0"' +`' +` stream_name "'$4`"' +` hw_configs [' +` "'$1$2`"' +` ]' +`}') + +dnl COMP_SAMPLE_SIZE(FMT) +define(`COMP_SAMPLE_SIZE', +`ifelse( + $1, `s16le', `2', + $1, `s24_4le', `4', + $1, `s32le', `4', + `4')') + + +dnl COMP_BUFFER_SIZE( num_periods, sample_size, channels, fmames) +define(`COMP_BUFFER_SIZE', `eval(`$1 * $2 * $3 * $4')') + + +divert(0) dnl From 85ed032295dba08c524f013ed2fa29557fd3e649 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 9 Aug 2017 14:50:57 +0100 Subject: [PATCH 020/324] topology: dsp: Add scheduling tokens to DSP platform files. Add initial scheduling platform scheduling. TODO: fine tune the MIPS Signed-off-by: Liam Girdwood --- topology/dsps/bdw.m4 | 44 ++++++++++++++++++++++++++++++++++---------- topology/dsps/bxt.m4 | 44 ++++++++++++++++++++++++++++++++++---------- topology/dsps/byt.m4 | 44 ++++++++++++++++++++++++++++++++++---------- topology/dsps/cht.m4 | 30 ++++++++++++++++++++---------- topology/dsps/hsw.m4 | 44 ++++++++++++++++++++++++++++++++++---------- 5 files changed, 156 insertions(+), 50 deletions(-) diff --git a/topology/dsps/bdw.m4 b/topology/dsps/bdw.m4 index 24e0156545d4..428e8bb96205 100644 --- a/topology/dsps/bdw.m4 +++ b/topology/dsps/bdw.m4 @@ -7,8 +7,7 @@ SectionVendorTuples."pipe_ll_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "0" - SOF_TKN_SCHED_MIPS "50000" + SOF_TKN_SCHED_MIPS "50000" } } @@ -21,8 +20,7 @@ SectionVendorTuples."pipe_media_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "1" - SOF_TKN_SCHED_MIPS "100000" + SOF_TKN_SCHED_MIPS "100000" } } @@ -35,8 +33,7 @@ SectionVendorTuples."pipe_tone_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "2" - SOF_TKN_SCHED_MIPS "200000" + SOF_TKN_SCHED_MIPS "200000" } } @@ -49,8 +46,8 @@ SectionVendorTuples."dai0p_plat_tokens" { tokens "sof_dai_tokens" tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "0" + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "0" } } @@ -63,11 +60,38 @@ SectionVendorTuples."dai0c_plat_tokens" { tokens "sof_dai_tokens" tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "1" + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "1" } } SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } + +# PCM platform configuration +SectionVendorTuples."pcm_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC PIPELINE_DMAC + SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN + } +} + +SectionData."pcm_plat_conf" { + tuples "pcm_plat_tokens" +} + +# DAI schedule Configuration - scheduled by IRQ +SectionVendorTuples."pipe_dai_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_MIPS "5000" + } +} + +SectionData."pipe_dai_schedule_plat" { + tuples "pipe_dai_schedule_plat_tokens" +} diff --git a/topology/dsps/bxt.m4 b/topology/dsps/bxt.m4 index fe21ae8e0875..688e9fa4caa1 100644 --- a/topology/dsps/bxt.m4 +++ b/topology/dsps/bxt.m4 @@ -7,8 +7,7 @@ SectionVendorTuples."pipe_ll_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "0" - SOF_TKN_SCHED_MIPS "50000" + SOF_TKN_SCHED_MIPS "50000" } } @@ -21,8 +20,7 @@ SectionVendorTuples."pipe_media_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "1" - SOF_TKN_SCHED_MIPS "100000" + SOF_TKN_SCHED_MIPS "100000" } } @@ -35,8 +33,7 @@ SectionVendorTuples."pipe_tone_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "2" - SOF_TKN_SCHED_MIPS "200000" + SOF_TKN_SCHED_MIPS "200000" } } @@ -49,8 +46,8 @@ SectionVendorTuples."dai0p_plat_tokens" { tokens "sof_dai_tokens" tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "0" + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "0" } } @@ -63,11 +60,38 @@ SectionVendorTuples."dai0c_plat_tokens" { tokens "sof_dai_tokens" tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "1" + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "1" } } SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } + +# PCM platform configuration +SectionVendorTuples."pcm_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC PIPELINE_DMAC + SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN + } +} + +SectionData."pcm_plat_conf" { + tuples "pcm_plat_tokens" +} + +# DAI schedule Configuration - scheduled by IRQ +SectionVendorTuples."pipe_dai_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_MIPS "5000" + } +} + +SectionData."pipe_dai_schedule_plat" { + tuples "pipe_dai_schedule_plat_tokens" +} diff --git a/topology/dsps/byt.m4 b/topology/dsps/byt.m4 index 8aa393085a0f..b4defaa05456 100644 --- a/topology/dsps/byt.m4 +++ b/topology/dsps/byt.m4 @@ -7,8 +7,7 @@ SectionVendorTuples."pipe_ll_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "0" - SOF_TKN_SCHED_MIPS "50000" + SOF_TKN_SCHED_MIPS "50000" } } @@ -21,8 +20,7 @@ SectionVendorTuples."pipe_media_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "1" - SOF_TKN_SCHED_MIPS "100000" + SOF_TKN_SCHED_MIPS "100000" } } @@ -35,8 +33,7 @@ SectionVendorTuples."pipe_tone_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "2" - SOF_TKN_SCHED_MIPS "200000" + SOF_TKN_SCHED_MIPS "200000" } } @@ -49,8 +46,8 @@ SectionVendorTuples."dai0p_plat_tokens" { tokens "sof_dai_tokens" tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "0" + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "0" } } @@ -63,11 +60,38 @@ SectionVendorTuples."dai0c_plat_tokens" { tokens "sof_dai_tokens" tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "1" + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "1" } } SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } + +# PCM platform configuration +SectionVendorTuples."pcm_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC PIPELINE_DMAC + SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN + } +} + +SectionData."pcm_plat_conf" { + tuples "pcm_plat_tokens" +} + +# DAI schedule Configuration - scheduled by IRQ +SectionVendorTuples."pipe_dai_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_MIPS "5000" + } +} + +SectionData."pipe_dai_schedule_plat" { + tuples "pipe_dai_schedule_plat_tokens" +} diff --git a/topology/dsps/cht.m4 b/topology/dsps/cht.m4 index f6976aa0d118..d315b0c04051 100644 --- a/topology/dsps/cht.m4 +++ b/topology/dsps/cht.m4 @@ -7,8 +7,7 @@ SectionVendorTuples."pipe_ll_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "0" - SOF_TKN_SCHED_MIPS "50000" + SOF_TKN_SCHED_MIPS "50000" } } @@ -21,8 +20,7 @@ SectionVendorTuples."pipe_media_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "1" - SOF_TKN_SCHED_MIPS "100000" + SOF_TKN_SCHED_MIPS "100000" } } @@ -35,8 +33,7 @@ SectionVendorTuples."pipe_tone_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "2" - SOF_TKN_SCHED_MIPS "200000" + SOF_TKN_SCHED_MIPS "200000" } } @@ -49,8 +46,8 @@ SectionVendorTuples."dai0p_plat_tokens" { tokens "sof_dai_tokens" tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "0" + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "0" } } @@ -63,11 +60,24 @@ SectionVendorTuples."dai0c_plat_tokens" { tokens "sof_dai_tokens" tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "1" + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "1" } } SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } + +# DAI schedule Configuration - scheduled by IRQ +SectionVendorTuples."pipe_dai_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_MIPS "5000" + } +} + +SectionData."pipe_dai_schedule_plat" { + tuples "pipe_dai_schedule_plat_tokens" +} diff --git a/topology/dsps/hsw.m4 b/topology/dsps/hsw.m4 index 1c155a9d4466..edb417f759e7 100644 --- a/topology/dsps/hsw.m4 +++ b/topology/dsps/hsw.m4 @@ -7,8 +7,7 @@ SectionVendorTuples."pipe_ll_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "0" - SOF_TKN_SCHED_MIPS "50000" + SOF_TKN_SCHED_MIPS "50000" } } @@ -21,8 +20,7 @@ SectionVendorTuples."pipe_media_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "1" - SOF_TKN_SCHED_MIPS "100000" + SOF_TKN_SCHED_MIPS "100000" } } @@ -35,8 +33,7 @@ SectionVendorTuples."pipe_tone_schedule_plat_tokens" { tokens "sof_sched_tokens" tuples."word" { - SOF_TKN_SCHED_PRIORITY "2" - SOF_TKN_SCHED_MIPS "200000" + SOF_TKN_SCHED_MIPS "200000" } } @@ -49,8 +46,8 @@ SectionVendorTuples."dai0p_plat_tokens" { tokens "sof_dai_tokens" tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "0" + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "0" } } @@ -63,11 +60,38 @@ SectionVendorTuples."dai0c_plat_tokens" { tokens "sof_dai_tokens" tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "1" + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "1" } } SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } + +# PCM platform configuration +SectionVendorTuples."pcm_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC PIPELINE_DMAC + SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN + } +} + +SectionData."pcm_plat_conf" { + tuples "pcm_plat_tokens" +} + +# DAI schedule Configuration - scheduled by IRQ +SectionVendorTuples."pipe_dai_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_MIPS "5000" + } +} + +SectionData."pipe_dai_schedule_plat" { + tuples "pipe_dai_schedule_plat_tokens" +} From c78d832441b85947121413b0ae4d06c71d031723 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 9 Aug 2017 14:54:03 +0100 Subject: [PATCH 021/324] topology: pipeline: Update pipelines to use new tokens Update the pipelines to use the new buffer and scheduling tokens. Signed-off-by: Liam Girdwood --- topology/sof/pipe-dai-capture.m4 | 25 +++++++ topology/sof/pipe-dai-playback.m4 | 25 +++++++ topology/sof/pipe-dai.m4 | 24 ------- topology/sof/pipe-low-latency-capture.m4 | 26 +++++-- topology/sof/pipe-low-latency-playback.m4 | 39 ++++++++--- topology/sof/pipe-passthrough-playback.m4 | 84 +++++++++++++++++++++++ topology/sof/pipe-pcm-media.m4 | 33 ++++++--- topology/sof/pipe-tone.m4 | 22 ++++-- 8 files changed, 226 insertions(+), 52 deletions(-) create mode 100644 topology/sof/pipe-dai-capture.m4 create mode 100644 topology/sof/pipe-dai-playback.m4 delete mode 100644 topology/sof/pipe-dai.m4 create mode 100644 topology/sof/pipe-passthrough-playback.m4 diff --git a/topology/sof/pipe-dai-capture.m4 b/topology/sof/pipe-dai-capture.m4 new file mode 100644 index 000000000000..887cd0c6c61d --- /dev/null +++ b/topology/sof/pipe-dai-capture.m4 @@ -0,0 +1,25 @@ +# DAI Playback connector + +# Include topology builder +include(`local.m4') + +# +# DAI definitions +# +W_DAI_IN(DAI_SNAME, DAI_TYPE, DAI_INDEX, dai0c_plat_conf) + +# +# DAI pipeline - always use 0 for DAIs +# +W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_dai_schedule_plat) + +# +# Graph connections to pipelines + +SectionGraph.STR(DAI_NAME) { + index STR(PIPELINE_ID) + + lines [ + dapm(DAI_BUF, N_DAI_IN) + ] +} diff --git a/topology/sof/pipe-dai-playback.m4 b/topology/sof/pipe-dai-playback.m4 new file mode 100644 index 000000000000..f3d08c0c55ee --- /dev/null +++ b/topology/sof/pipe-dai-playback.m4 @@ -0,0 +1,25 @@ +# DAI Playback connector + +# Include topology builder +include(`local.m4') + +# +# DAI definitions +# +W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, dai0p_plat_conf) + +# +# DAI pipeline - always use 0 for DAIs +# +W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_dai_schedule_plat) + +# +# Graph connections to pipelines + +SectionGraph.STR(DAI_NAME) { + index STR(PIPELINE_ID) + + lines [ + dapm(N_DAI_OUT, DAI_BUF) + ] +} diff --git a/topology/sof/pipe-dai.m4 b/topology/sof/pipe-dai.m4 deleted file mode 100644 index 06ac453ea7da..000000000000 --- a/topology/sof/pipe-dai.m4 +++ /dev/null @@ -1,24 +0,0 @@ -# DAI connector - -# Include topology builder -include(`local.m4') - -# -# DAI definitions -# -W_DAI_OUT(DAI_SNAME, dai0p_plat_conf) -W_DAI_IN(DAI_SNAME, dai0c_plat_conf) - -#D_DAI(0, 1, 1) - -# -# Graph connections to pipelines - -SectionGraph.STR(DAI_NAME) { - index "0" - - lines [ - dapm(N_DAI_IN, OUT_BUF) - dapm(IN_BUF, N_DAI_OUT) - ] -} diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index ddb5d8e4fea3..ca9fe9ceb868 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -43,31 +43,45 @@ SectionControlMixer.STR(PCM PCM_ID Capture Volume) { # Components and Buffers # -W_PCM_CAPTURE(Low Latency Capture) -W_PGA(Capture Volume) -W_BUFFER(0, BUF_INT_SIZE) -W_BUFFER(1, BUF_PCM_SIZE) +# Host "Low Latency Capture" PCM uses pipeline DMAC and channel +# with 0 sink and 2 source periods +W_PCM_CAPTURE(Low Latency Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 0) + +# "Capture Volume" has 2 sink and source periods for host and DAI ping-pong +W_PGA(Capture Volume, PIPELINE_FORMAT, 2, 2, 0) + +# Capture Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) +W_BUFFER(1, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) # # Pipeline Graph # -# host PCM <--B1-- volume( <--B0-- source DAI0 +# host PCM <--B1-- volume <--B0-- source DAI0 SectionGraph."pipe-ll-capture-PIPELINE_ID" { index STR(PIPELINE_ID) lines [ + dapm(Low Latency Capture PCM_ID, N_PCM) dapm(N_PCM, N_BUFFER(1)) dapm(N_BUFFER(1), N_PGA(Capture Volume)) dapm(N_PGA(Capture Volume), N_BUFFER(0)) ] } +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SINK_', PIPELINE_ID), N_BUFFER(0)) + # # Pipeline Configuration. # -W_PIPELINE(N_PGA(Capture Volume), SCHEDULE_DEADLINE, pipe_ll_schedule_plat) +W_PIPELINE(N_PGA(Capture Volume), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) # # PCM Configuration diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index 6604ad1bc06a..a8e3fa55fb42 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -86,14 +86,28 @@ SectionControlMixer.STR(Master Playback Volume) { # Components and Buffers # -W_PCM_PLAYBACK(Low Latency Playback) -W_PGA(Playback Volume) -W_PGA(Mixer Volume) -W_MIXER(0) -W_BUFFER(0, BUF_PCM_SIZE) -W_BUFFER(1, BUF_INT_SIZE) -W_BUFFER(2, BUF_INT_SIZE) -W_BUFFER(3, BUF_INT_SIZE) +# Host "Low latency Playback" PCM uses pipeline DMAC and channel +# with 2 sink and 0 source periods +W_PCM_PLAYBACK(Low Latency Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) + +# "Playback Volume" has 1 sink period and 2 source periods for host ping-pong +W_PGA(Playback Volume, PIPELINE_FORMAT, 1, 2, 1) + +# "Mixer Volume" has 1 source and 2 sink periods for DAI ping-pong +W_PGA(Mixer Volume, PIPELINE_FORMAT, 2, 1, 1) + +# Mixer 0 has 1 sink and source periods. +W_MIXER(0, PIPELINE_FORMAT, 1, 1, 1) + +# Low Latency Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) +W_BUFFER(1, COMP_BUFFER_SIZE(1, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS,SCHEDULE_FRAMES)) +W_BUFFER(2, COMP_BUFFER_SIZE(1, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) +W_BUFFER(3, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) # # Pipeline Graph @@ -111,6 +125,7 @@ SectionGraph."pipe-ll-playback-PIPELINE_ID" { index STR(PIPELINE_ID) lines [ + dapm(N_PCM, Low Latency Playback PCM_ID) dapm(N_BUFFER(0), N_PCM) dapm(N_PGA(Playback Volume), N_BUFFER(0)) dapm(N_BUFFER(1), N_PGA(Playback Volume)) @@ -121,11 +136,17 @@ SectionGraph."pipe-ll-playback-PIPELINE_ID" { ] } +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(3)) +indir(`define', concat(`PIPELINE_MIXER_', PIPELINE_ID), N_MIXER(0)) + # # Pipeline Configuration. # -W_PIPELINE(N_PGA(Mixer Volume), SCHEDULE_DEADLINE, pipe_ll_schedule_plat) +W_PIPELINE(N_PGA(Mixer Volume), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) # # PCM Configuration diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 new file mode 100644 index 000000000000..1fc76c7d8efa --- /dev/null +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -0,0 +1,84 @@ +# Low Latency Passthrough Pipeline and PCM +# +# Pipeline Endpoints for connection are :- +# +# host PCM_P --> B0 --> sink DAI0 + +# Include topology builder +include(`local.m4') + + +# +# Components and Buffers +# + +# Host "Passthrough Playback" PCM uses pipeline DMAC and channel +# with 2 sink and 0 source periods +W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) + +# Capture Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + +# +# DAI definitions +# +W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, dai0p_plat_conf) + +# +# DAI pipeline - always use 0 for DAIs +# +W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_dai_schedule_plat) + +# +# Pipeline Graph +# +# host PCM <--B1-- volume <--B0-- source DAI0 + +SectionGraph."pipe-pass-playback-PIPELINE_ID" { + index STR(PIPELINE_ID) + + lines [ + dapm(N_PCM, Passthrough Playback PCM_ID) + dapm(N_BUFFER(0), N_PCM) + dapm(N_DAI_OUT, N_BUFFER(0)) + ] +} + + +# +# PCM Configuration +# + +SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { + + formats "S24_LE,S16_LE" + rate_min "48000" + rate_max "48000" + channels_min "2" + channels_max "4" + periods_min "2" + periods_max "4" + period_size_min "192" + period_size_max "16384" + buffer_size_min "384" + buffer_size_max "65536" +} + +# PCM Low Latency Capture +SectionPCM.STR(PCM PCM_ID) { + + index STR(PIPELINE_ID) + + # used for binding to the PCM + id STR(PCM_ID) + + dai.STR(Passthrough Playback PCM_ID) { + id STR(PCM_ID) + } + + pcm."playback" { + + capabilities STR(Passthrough Playback PCM_ID) + } +} diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 688c81f33b96..ac2aaa7e81d6 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -65,12 +65,23 @@ SectionData."media_src_conf" { # Components and Buffers # -W_PCM_PLAYBACK(Media Playback) -W_PGA(Playback Volume) -W_SRC(0, media_src_conf) -W_BUFFER(0, BUF_PCM_SIZE) -W_BUFFER(1, BUF_INT_SIZE) -W_BUFFER(2, BUF_INT_SIZE) +# Host "Low latency Playback" PCM uses pipeline DMAC and channel +# with 2 sink and 0 source periods +W_PCM_PLAYBACK(Media Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) + +# "Playback Volume" has 2 sink period and 2 source periods for host ping-pong +W_PGA(Playback Volume, PIPELINE_FORMAT, 2, 2, 2) + +# "SRC 0" has 2 sink and source periods. +W_SRC(0, media_src_conf, PIPELINE_FORMAT, 2, 2, 2) + +# Media Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) +W_BUFFER(1,COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) +W_BUFFER(2, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) # # Pipeline Graph @@ -82,7 +93,8 @@ SectionGraph."pipe-media-PIPELINE_ID" { index STR(PIPELINE_ID) lines [ - dapm(N_BUFFER(0), Media Playback PCM_ID) + dapm(N_PCM, Media Playback PCM_ID) + dapm(N_BUFFER(0), N_PCM) dapm(N_PGA(Playback Volume), N_BUFFER(0)) dapm(N_BUFFER(1), N_PGA(Playback Volume)) dapm(N_SRC(0), N_BUFFER(1)) @@ -90,11 +102,16 @@ SectionGraph."pipe-media-PIPELINE_ID" { ] } +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(2)) + # # Pipeline Configuration. # -W_PIPELINE(N_SRC(0), SCHEDULE_DEADLINE, pipe_media_schedule_plat) +W_PIPELINE(N_SRC(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_media_schedule_plat) # # PCM Configuration diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index 24fe10fb6dd3..386ddd344ddb 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -46,10 +46,17 @@ SectionControlMixer.STR(Tone Volume PIPELINE_ID) { # Components and Buffers # -W_TONE(0) -W_PGA(Tone Volume) -W_BUFFER(0, BUF_INT_SIZE) -W_BUFFER(1, BUF_INT_SIZE) +# "Tone 0" has 2 sink period and 0 source periods +W_TONE(0, PIPELINE_FORMAT, 2, 0, 0) + +# "Tone Volume" has 2 sink period and 2 source periods +W_PGA(Tone Volume, PIPELINE_FORMAT, 2, 2, 0) + +# Low Latency Buffers +W_BUFFER(0,COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) +W_BUFFER(1, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) # @@ -68,8 +75,13 @@ SectionGraph."pipe-tone-PIPELINE_ID" { ] } +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(1)) + # # Pipeline Configuration. # -W_PIPELINE(N_TONE(0), SCHEDULE_DEADLINE, pipe_tone_schedule_plat) +W_PIPELINE(N_TONE(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_tone_schedule_plat) From 8083e91a99380c742b4f832ac9e43e8d66e27299 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 9 Aug 2017 15:01:06 +0100 Subject: [PATCH 022/324] topology: Add machine specific update for buffer and scheduling tokens Allow machines to specify scheduling config in pipeline topologies. Signed-off-by: Liam Girdwood --- topology/reef-apl-nocodec.m4 | 86 ++++++++++++++++++++---------------- topology/reef-bdw-rt286.m4 | 83 +++++++++++++++++++--------------- topology/reef-bdw-rt5640.m4 | 83 +++++++++++++++++++--------------- topology/reef-bxt-nocodec.m4 | 84 ++++++++++++++++++++--------------- topology/reef-byt-nocodec.m4 | 84 ++++++++++++++++++++--------------- topology/reef-byt-rt5640.m4 | 84 ++++++++++++++++++++--------------- topology/reef-byt-rt5651.m4 | 85 ++++++++++++++++++++--------------- topology/reef-cht-nocodec.m4 | 86 ++++++++++++++++++++---------------- topology/reef-hsw-rt5640.m4 | 83 +++++++++++++++++++--------------- 9 files changed, 434 insertions(+), 324 deletions(-) diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index f1c181935f79..93febe0ca0f3 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -18,29 +18,40 @@ include(`dsps/bxt.m4') # # Define the pipelines # +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# PCM3 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP2 +# -# Low Latency playback pipeline 1 on PCM 0 -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) - -# Low Latency capture pipeline 2 on PCM 1 -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# PCM Media Playback pipeline 3 on PCM 2 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) +# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 4 on PCM 3 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) +# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# Tone Playback pipeline 5 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) +# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 4 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) - -# -# DAI configuration -# - -# SSP port 2 is our pipeline DAI -DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-apl-nocodec" { @@ -48,32 +59,31 @@ SectionGraph."pipe-apl-nocodec" { lines [ # media 0 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) # media 1 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] } - # -# BE configurations - overrides config in ACPI if present +# DAI configuration +# +# SSP port 2 is our only pipeline DAI # -# BE configurations - overrides config in ACPI if present -SectionHWConfig."SSP2" { - - id "2" - format "I2S" - bclk_master "true" - bclk_freq "2400000" - mclk_freq "19200000" - fsyn_master "true" - fsync_freq "48000" - tdm_slots "2" - tdm_slot_width "25" - tx_slots "2" - rx_slots "2" -} +# playback DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) +# capture DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) + +# +# BE configurations - overrides config in ACPI if present +# +DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 24, 3, 3)) diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index 38d1c6a1a96b..4135353f1928 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -18,29 +18,40 @@ include(`dsps/bdw.m4') # # Define the pipelines # +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# PCM3 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP0 +# -# Low Latency playback pipeline 1 on PCM 0 -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) - -# Low Latency capture pipeline 2 on PCM 1 -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) - -# PCM Media Playback pipeline 3 on PCM 2 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) - -# PCM Media Playback pipeline 4 on PCM 3 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Tone Playback pipeline 5 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) +# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# -# DAI configuration -# +# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 4 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) -# SSP port 2 is our pipeline DAI -DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-bdw-rt286" { @@ -48,29 +59,31 @@ SectionGraph."pipe-bdw-rt286" { lines [ # media 0 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) # media 1 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] } +# +# DAI configuration +# +# SSP port 0 is our only pipeline DAI +# + +# playback DAI is SSP0 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2) + +# capture DAI is SSP0 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -SectionHWConfig."SSP0" { - - id "2" - format "I2S" - bclk_master "true" - bclk_freq "2400000" - mclk_freq "24000000" - fsyn_master "true" - fsync_freq "48000" - tdm_slots "2" - tdm_slot_width "25" - tx_slots "2" - rx_slots "2" -} +DAI_CONFIG(SSP, 0, Codec, I2S, I2S, + DAI_CLOCK(mclk, 24000000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 24, 3, 3)) diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index 4bdfdb4c006b..540ac4c12e8c 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -18,29 +18,40 @@ include(`dsps/bdw.m4') # # Define the pipelines # +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# PCM3 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP0 +# -# Low Latency playback pipeline 1 on PCM 0 -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) - -# Low Latency capture pipeline 2 on PCM 1 -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) - -# PCM Media Playback pipeline 3 on PCM 2 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) - -# PCM Media Playback pipeline 4 on PCM 3 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Tone Playback pipeline 5 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) +# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# -# DAI configuration -# +# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 4 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) -# SSP port 2 is our pipeline DAI -DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-bdw-rt5640" { @@ -48,29 +59,31 @@ SectionGraph."pipe-bdw-rt5640" { lines [ # media 0 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) # media 1 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] } +# +# DAI configuration +# +# SSP port 0 is our only pipeline DAI +# + +# playback DAI is SSP0 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2) + +# capture DAI is SSP0 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -SectionHWConfig."SSP0" { - - id "2" - format "I2S" - bclk_master "true" - bclk_freq "2400000" - mclk_freq "24000000" - fsyn_master "true" - fsync_freq "48000" - tdm_slots "2" - tdm_slot_width "25" - tx_slots "2" - rx_slots "2" -} +DAI_CONFIG(SSP, 0, Codec, I2S, I2S, + DAI_CLOCK(mclk, 24000000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 24, 3, 3)) diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index 8634d3a3c7b0..564e78c94590 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -18,29 +18,40 @@ include(`dsps/bxt.m4') # # Define the pipelines # +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# PCM3 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP2 +# -# Low Latency playback pipeline 1 on PCM 0 -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) - -# Low Latency capture pipeline 2 on PCM 1 -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) - -# PCM Media Playback pipeline 3 on PCM 2 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) - -# PCM Media Playback pipeline 4 on PCM 3 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Tone Playback pipeline 5 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) +# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# -# DAI configuration -# +# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 4 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) -# SSP port 2 is our pipeline DAI -DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-bxt-nocodec" { @@ -48,30 +59,31 @@ SectionGraph."pipe-bxt-nocodec" { lines [ # media 0 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) # media 1 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] } +# +# DAI configuration +# +# SSP port 2 is our only pipeline DAI +# + +# playback DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) + +# capture DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -SectionHWConfig."SSP2" { - - id "2" - format "I2S" - bclk_master "true" - bclk_freq "2400000" - mclk_freq "19200000" - fsyn_master "true" - fsync_freq "48000" - tdm_slots "2" - tdm_slot_width "25" - tx_slots "2" - rx_slots "2" -} - +DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 24, 3, 3)) diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index 14660fa95acd..ab0cd8e2f418 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -18,29 +18,40 @@ include(`dsps/byt.m4') # # Define the pipelines # +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# PCM3 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP2 +# -# Low Latency playback pipeline 1 on PCM 0 -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) - -# Low Latency capture pipeline 2 on PCM 1 -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) - -# PCM Media Playback pipeline 3 on PCM 2 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) - -# PCM Media Playback pipeline 4 on PCM 3 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Tone Playback pipeline 5 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) +# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# -# DAI configuration -# +# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 4 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) -# SSP port 2 is our pipeline DAI -DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-byt-nocodec" { @@ -48,30 +59,31 @@ SectionGraph."pipe-byt-nocodec" { lines [ # media 0 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) # media 1 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] } +# +# DAI configuration +# +# SSP port 2 is our only pipeline DAI +# + +# playback DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) + +# capture DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -SectionHWConfig."SSP2" { - - id "2" - format "I2S" - bclk_master "true" - bclk_freq "2400000" - mclk_freq "19200000" - fsyn_master "true" - fsync_freq "48000" - tdm_slots "2" - tdm_slot_width "25" - tx_slots "2" - rx_slots "2" -} - +DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 24, 3, 3)) diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 90acec96a15f..2cee0930ad5f 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -18,29 +18,40 @@ include(`dsps/byt.m4') # # Define the pipelines # +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# PCM3 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP2 +# -# Low Latency playback pipeline 1 on PCM 0 -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) - -# Low Latency capture pipeline 2 on PCM 1 -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) - -# PCM Media Playback pipeline 3 on PCM 2 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) - -# PCM Media Playback pipeline 4 on PCM 3 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Tone Playback pipeline 5 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) +# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# -# DAI configuration -# +# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 4 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) -# SSP port 2 is our pipeline DAI -DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-byt-rt5640" { @@ -48,30 +59,31 @@ SectionGraph."pipe-byt-rt5640" { lines [ # media 0 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) # media 1 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] } +# +# DAI configuration +# +# SSP port 2 is our only pipeline DAI +# + +# playback DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) + +# capture DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -SectionHWConfig."SSP2" { - - id "2" - format "I2S" - bclk_master "true" - bclk_freq "2400000" - mclk_freq "19200000" - fsyn_master "true" - fsync_freq "48000" - tdm_slots "2" - tdm_slot_width "25" - tx_slots "2" - rx_slots "2" -} - +DAI_CONFIG(SSP, 2, Baytrail Audio, Audio, I2S, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 24, 3, 3)) diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index e0318076a721..46793437d9f9 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -1,5 +1,5 @@ # -# Topology for generic Baytrail board with no codec. +# Topology for generic Baytrail board with no RT5651. # # Include topology builder @@ -18,29 +18,40 @@ include(`dsps/byt.m4') # # Define the pipelines # +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# PCM3 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP2 +# -# Low Latency playback pipeline 1 on PCM 0 -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) - -# Low Latency capture pipeline 2 on PCM 1 -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) - -# PCM Media Playback pipeline 3 on PCM 2 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) - -# PCM Media Playback pipeline 4 on PCM 3 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Tone Playback pipeline 5 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) +# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# -# DAI configuration -# +# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 4 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) -# SSP port 2 is our pipeline DAI -DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-byt-rt5651" { @@ -48,29 +59,31 @@ SectionGraph."pipe-byt-rt5651" { lines [ # media 0 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) # media 1 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] } +# +# DAI configuration +# +# SSP port 2 is our only pipeline DAI +# + +# playback DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) + +# capture DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -SectionHWConfig."SSP2" { - - id "2" - format "I2S" - bclk_master "true" - bclk_freq "2400000" - mclk_freq "19200000" - fsyn_master "true" - fsync_freq "48000" - tdm_slots "2" - tdm_slot_width "25" - tx_slots "2" - rx_slots "2" -} +DAI_CONFIG(SSP, 2, Baytrail Audio, Audio, I2S, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 24, 3, 3)) diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index 6ceed8edd6b4..f7545513a88b 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -18,29 +18,40 @@ include(`dsps/cht.m4') # # Define the pipelines # +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# PCM3 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP2 +# -# Low Latency playback pipeline 1 on PCM 0 -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) - -# Low Latency capture pipeline 2 on PCM 1 -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# PCM Media Playback pipeline 3 on PCM 2 -#PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) +# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 4 on PCM 3 -#PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) +# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# Tone Playback pipeline 5 -#PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) +# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 4 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) - -# -# DAI configuration -# - -# SSP port 2 is our pipeline DAI -DAI_ADD(sof/pipe-dai.m4, SSP2, I2S, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-cht-nocodec" { @@ -48,30 +59,31 @@ SectionGraph."pipe-cht-nocodec" { lines [ # media 0 -# dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) # media 1 -# dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone -# dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] } # -# BE configurations - overrides config in ACPI if present +# DAI configuration # -SectionHWConfig."SSP2" { - - id "2" - format "I2S" - bclk "master" - bclk_freq "2400000" - mclk "master" - mclk_freq "19200000" - fsync "master" - fsync_freq "48000" - tdm_slots "2" - tdm_slot_width "25" - tx_slots "2" - rx_slots "2" -} +# SSP port 2 is our only pipeline DAI +# + +# playback DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) +# capture DAI is SSP2 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) + +# +# BE configurations - overrides config in ACPI if present +# +DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 24, 3, 3)) diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index 0648df2f7e58..cbbbfbe68557 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -18,29 +18,40 @@ include(`dsps/hsw.m4') # # Define the pipelines # +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# PCM3 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP0 +# -# Low Latency playback pipeline 1 on PCM 0 -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 768, 768, 48, 1000, 0) - -# Low Latency capture pipeline 2 on PCM 1 -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 768, 768, 48, 1000, 0) - -# PCM Media Playback pipeline 3 on PCM 2 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 1536, 1536, 96, 2000, 1) - -# PCM Media Playback pipeline 4 on PCM 3 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 1536, 1536, 96, 2000, 1) +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Tone Playback pipeline 5 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 3072, 192, 4000, 2) +# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# -# DAI configuration -# +# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 4 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) -# SSP port 2 is our pipeline DAI -DAI_ADD(sof/pipe-dai.m4, SSP2, I2S Audio, NPIPELINE_BUFFER(2, 0), NPIPELINE_BUFFER(1, 3)) +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-hsw-rt5640" { @@ -48,29 +59,31 @@ SectionGraph."pipe-hsw-rt5640" { lines [ # media 0 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(3, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) # media 1 - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(4, 2)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone - dapm(NPIPELINE_MIXER(1, 0), NPIPELINE_BUFFER(5, 1)) + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] } +# +# DAI configuration +# +# SSP port 0 is our only pipeline DAI +# + +# playback DAI is SSP0 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2) + +# capture DAI is SSP0 using I2S DAPM stream and 2 periods +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -SectionHWConfig."SSP0" { - - id "2" - format "I2S" - bclk_master "true" - bclk_freq "2400000" - mclk_freq "24000000" - fsyn_master "true" - fsync_freq "48000" - tdm_slots "2" - tdm_slot_width "25" - tx_slots "2" - rx_slots "2" -} +DAI_CONFIG(SSP, 0, Codec, I2S, I2S, + DAI_CLOCK(mclk, 24000000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 24, 3, 3)) From 0a08a62e053d0a0b115f1d9a9b61c6f09cececba Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 16 Aug 2017 20:34:01 +0100 Subject: [PATCH 023/324] topology: pipelines: give more headroom for buffer size refinement Give the ALSA HW refinement code more headroom for buffer calculations to provide more buffering options. Signed-off-by: Liam Girdwood --- topology/sof/pipe-low-latency-capture.m4 | 2 +- topology/sof/pipe-low-latency-playback.m4 | 4 ++-- topology/sof/pipe-passthrough-playback.m4 | 4 ++-- topology/sof/pipe-pcm-media.m4 | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index ca9fe9ceb868..3b53d0a67832 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -98,7 +98,7 @@ SectionPCMCapabilities.STR(Low Latency Capture PCM_ID) { periods_max "4" period_size_min "192" period_size_max "16384" - buffer_size_min "384" + buffer_size_min "65536" buffer_size_max "65536" } diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index a8e3fa55fb42..00f7447f9165 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -161,10 +161,10 @@ SectionPCMCapabilities.STR(Low Latency Playback PCM_ID) { channels_min "2" channels_max "2" periods_min "2" - periods_max "4" + periods_max "16" period_size_min "192" period_size_max "16384" - buffer_size_min "384" + buffer_size_min "65536" buffer_size_max "65536" } diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index 1fc76c7d8efa..98b479fad1ef 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -58,10 +58,10 @@ SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { channels_min "2" channels_max "4" periods_min "2" - periods_max "4" + periods_max "16" period_size_min "192" period_size_max "16384" - buffer_size_min "384" + buffer_size_min "65536" buffer_size_max "65536" } diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index ac2aaa7e81d6..fd6db049f946 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -129,7 +129,7 @@ SectionPCMCapabilities.STR(Media Playback PCM_ID) { periods_max "32" period_size_min "4096" period_size_max "262144" - buffer_size_min "8192" + buffer_size_min "8388608" buffer_size_max "8388608" } From 2436d794a30c341f34aa31cab76fea933607a793 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 16 Aug 2017 20:35:55 +0100 Subject: [PATCH 024/324] topology: dai: Fix DAI tokens to avoid naming colision The wrong name is used for naming and may collide with the capture stream on the same DAI. Signed-off-by: Liam Girdwood --- topology/m4/local.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index a888438abd74..a14f310b6708 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -255,7 +255,7 @@ define(`N_DAI_IN', DAI_NAME`.IN') dnl W_DAI_OUT(stream, type, index, data, periods_sink, periods_source, preload) define(`W_DAI_OUT', -`SectionVendorTuples."'N_DAI_IN($1)`_tuples_w_comp" {' +`SectionVendorTuples."'N_DAI_OUT($1)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' ` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) @@ -263,8 +263,8 @@ define(`W_DAI_OUT', ` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) ` }' `}' -`SectionData."'N_DAI_IN($1)`_data_w_comp" {' -` tuples "'N_DAI_IN($1)`_tuples_w_comp"' +`SectionData."'N_DAI_OUT($1)`_data_w_comp" {' +` tuples "'N_DAI_OUT($1)`_tuples_w_comp"' `}' `SectionVendorTuples."'N_DAI_OUT($1)`_tuples_w" {' ` tokens "sof_dai_tokens"' @@ -291,7 +291,7 @@ define(`W_DAI_OUT', ` stream_name "'$1`"' ` data [' ` "'N_DAI_OUT($1)`_data_w"' -` "'N_DAI_IN($1)`_data_w_comp"' +` "'N_DAI_OUT($1)`_data_w_comp"' ` "'N_DAI_OUT($1)`_data_str"' ` "'$4`"' ` ]' From 3d8e7478a4db5f72bbe43ae6ec4f4b11eb32bec4 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 21 Aug 2017 20:21:30 +0100 Subject: [PATCH 025/324] topology: Add sample bits to DAI_CONFIG Add a token for number of bits in a sample for DAI configs Signed-off-by: Liam Girdwood --- topology/m4/local.m4 | 29 +++++++++++++++++++++++++++-- topology/reef-apl-nocodec.m4 | 4 ++-- topology/reef-bdw-rt286.m4 | 4 ++-- topology/reef-bdw-rt5640.m4 | 4 ++-- topology/reef-bxt-nocodec.m4 | 4 ++-- topology/reef-byt-nocodec.m4 | 4 ++-- topology/reef-byt-rt5640.m4 | 4 ++-- topology/reef-byt-rt5651.m4 | 4 ++-- topology/reef-cht-nocodec.m4 | 4 ++-- topology/reef-hsw-rt5640.m4 | 4 ++-- topology/sof/tokens.m4 | 1 + 11 files changed, 46 insertions(+), 20 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index a14f310b6708..a5596704ea03 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -394,17 +394,38 @@ define(`DAI_TDM', ` rx_slots 'STR($4) ) -dnl DAI_CONFIG(type, idx, name, sname, format, mclk, bclk, fsync, tdm) +dnl Pipeline name) +define(`N_DAI_CONFIG', `DAICONFIG.'$1) + +dnl DAI_CONFIG(type, idx, name, sname, format, valid bits, mclk, bclk, fsync, tdm) define(`DAI_CONFIG', `SectionHWConfig."'$1$2`" {' `' ` id "'$2`"' ` format "'$5`"' `' -` '$6 ` '$7 ` '$8 ` '$9 +` '$10 +`}' +`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples_str" {' +` tokens "sof_dai_tokens"' +` tuples."string" {' +` SOF_TKN_DAI_TYPE' STR($1) +` }' +`}' +`SectionData."'N_DAI_CONFIG($1$2)`_data_str" {' +` tuples "'N_DAI_CONFIG($1$2)`_tuples_str"' +`}' +`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {' +` tokens "sof_dai_tokens"' +` tuples."word" {' +` SOF_TKN_DAI_SAMPLE_BITS' STR($6) +` }' +`}' +`SectionData."'N_DAI_CONFIG($1$2)`_data" {' +` tuples "'N_DAI_CONFIG($1$2)`_tuples"' `}' `' `SectionBE."'$3`" {' @@ -414,6 +435,10 @@ define(`DAI_CONFIG', ` hw_configs [' ` "'$1$2`"' ` ]' +` data [' +` "'N_DAI_CONFIG($1$2)`_data"' +` "'N_DAI_CONFIG($1$2)`_data_str"' +` ]' `}') dnl COMP_SAMPLE_SIZE(FMT) diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index 93febe0ca0f3..93b57fe84a6f 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -82,8 +82,8 @@ DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, +DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 24, 3, 3)) + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index 4135353f1928..e4b600ab0111 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -82,8 +82,8 @@ DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, Codec, I2S, I2S, +DAI_CONFIG(SSP, 0, Codec, I2S, I2S, 24, DAI_CLOCK(mclk, 24000000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 24, 3, 3)) + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index 540ac4c12e8c..5d962368b6c1 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -82,8 +82,8 @@ DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, Codec, I2S, I2S, +DAI_CONFIG(SSP, 0, Codec, I2S, I2S, 24, DAI_CLOCK(mclk, 24000000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 24, 3, 3)) + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index 564e78c94590..a8fd320bff85 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -82,8 +82,8 @@ DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, +DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 24, 3, 3)) + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index ab0cd8e2f418..96e2e4bb0183 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -82,8 +82,8 @@ DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, +DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 24, 3, 3)) + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 2cee0930ad5f..c135fed9bcad 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -82,8 +82,8 @@ DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, Baytrail Audio, Audio, I2S, +DAI_CONFIG(SSP, 2, Baytrail Audio, Audio, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 24, 3, 3)) + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index 46793437d9f9..877492a3b1f0 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -82,8 +82,8 @@ DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, Baytrail Audio, Audio, I2S, +DAI_CONFIG(SSP, 2, Baytrail Audio, Audio, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 24, 3, 3)) + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index f7545513a88b..381ff127ea2c 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -82,8 +82,8 @@ DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, +DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 24, 3, 3)) + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index cbbbfbe68557..3a7622325973 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -82,8 +82,8 @@ DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, Codec, I2S, I2S, +DAI_CONFIG(SSP, 0, Codec, I2S, I2S, 24, DAI_CLOCK(mclk, 24000000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 24, 3, 3)) + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index 3902c36e3824..530220a35dfd 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -19,6 +19,7 @@ SectionVendorTokens."sof_dai_tokens" { SOF_TKN_DAI_DMAC_CONFIG "153" SOF_TKN_DAI_TYPE "154" SOF_TKN_DAI_INDEX "155" + SOF_TKN_DAI_SAMPLE_BITS "156" } SectionVendorTokens."sof_sched_tokens" { From 08adb55f0b5589f55f1ab230fae060c3f4f70e25 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 21 Aug 2017 20:26:05 +0100 Subject: [PATCH 026/324] topology: Include DAI format in pipeline definitions Make sure we allow different DAI formats in pipelines. Signed-off-by: Liam Girdwood --- topology/m4/build.m4 | 6 +++-- topology/m4/local.m4 | 29 +++++++++++++++++++---- topology/sof/pipe-dai-capture.m4 | 2 +- topology/sof/pipe-dai-playback.m4 | 2 +- topology/sof/pipe-passthrough-playback.m4 | 8 +++---- 5 files changed, 35 insertions(+), 12 deletions(-) diff --git a/topology/m4/build.m4 b/topology/m4/build.m4 index 66f656254735..843dcbba3066 100644 --- a/topology/m4/build.m4 +++ b/topology/m4/build.m4 @@ -26,7 +26,7 @@ define(`PIPELINE_PCM_ADD', ) dnl PIPELINE_PCM_DAI_ADD(pipeline, id, pcm, max channels, format, frames, -dnl deadline, priority, core, dai type, dai_index, stream_name, periods) +dnl deadline, priority, core, dai type, dai_index, stream_name, dai format, periods) define(`PIPELINE_PCM_DAI_ADD', `undefine(`PCM_ID')' `undefine(`PIPELINE_ID')' @@ -41,6 +41,7 @@ define(`PIPELINE_PCM_DAI_ADD', `undefine(`DAI_TYPE')' `undefine(`DAI_INDEX')' `undefine(`DAI_SNAME')' +`undefine(`DAI_FORMAT')' `undefine(`DAI_PERIODS')' `define(`PIPELINE_ID', $2)' `define(`PCM_ID', $3)' @@ -55,7 +56,8 @@ define(`PIPELINE_PCM_DAI_ADD', `define(`DAI_TYPE', STR($12))' `define(`DAI_INDEX', STR($13))' `define(`DAI_SNAME', $14)' -`define(`DAI_PERIODS', $15)' +`define(`DAI_FORMAT', $15)' +`define(`DAI_PERIODS', $16)' `define(`DAI_NAME', $12$13)' `include($1)' ) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index a5596704ea03..7bcebeef2099 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -253,7 +253,7 @@ define(`N_DAI', DAI_NAME) define(`N_DAI_OUT', DAI_NAME`.OUT') define(`N_DAI_IN', DAI_NAME`.IN') -dnl W_DAI_OUT(stream, type, index, data, periods_sink, periods_source, preload) +dnl W_DAI_OUT(stream, type, index, format, periods_sink, periods_source, preload, data) define(`W_DAI_OUT', `SectionVendorTuples."'N_DAI_OUT($1)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' @@ -284,6 +284,15 @@ define(`W_DAI_OUT', `SectionData."'N_DAI_OUT($1)`_data_str" {' ` tuples "'N_DAI_OUT($1)`_tuples_str"' `}' +`SectionVendorTuples."'N_DAI_OUT($1)`_tuples_comp_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($4) +` }' +`}' +`SectionData."'N_DAI_OUT($1)`_data_comp_str" {' +` tuples "'N_DAI_OUT($1)`_tuples_comp_str"' +`}' `SectionWidget."'N_DAI_OUT`" {' ` index "'PIPELINE_ID`"' ` type "dai_in"' @@ -293,11 +302,12 @@ define(`W_DAI_OUT', ` "'N_DAI_OUT($1)`_data_w"' ` "'N_DAI_OUT($1)`_data_w_comp"' ` "'N_DAI_OUT($1)`_data_str"' -` "'$4`"' +` "'N_DAI_OUT($1)`_data_comp_str"' +` "'$8`"' ` ]' `}') -dnl W_DAI_IN(stream, type, index, data, periods_sink, periods_source, preload) +dnl W_DAI_IN(stream, type, index, format, periods_sink, periods_source, preload, data) define(`W_DAI_IN', `SectionVendorTuples."'N_DAI_IN($1)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' @@ -328,6 +338,15 @@ define(`W_DAI_IN', `SectionData."'N_DAI_IN($1)`_data_str" {' ` tuples "'N_DAI_IN($1)`_tuples_str"' `}' +`SectionVendorTuples."'N_DAI_IN($1)`_tuples_comp_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($4) +` }' +`}' +`SectionData."'N_DAI_IN($1)`_data_comp_str" {' +` tuples "'N_DAI_IN($1)`_tuples_comp_str"' +`}' `SectionWidget."'N_DAI_IN`" {' ` index "'PIPELINE_ID`"' ` type "dai_out"' @@ -337,7 +356,8 @@ define(`W_DAI_IN', ` "'N_DAI_IN($1)`_data_w"' ` "'N_DAI_IN($1)`_data_w_comp"' ` "'N_DAI_IN($1)`_data_str"' -` "'$4`"' +` "'N_DAI_OUT($1)`_data_comp_str"' +` "'$8`"' ` ]' `}') @@ -447,6 +467,7 @@ define(`COMP_SAMPLE_SIZE', $1, `s16le', `2', $1, `s24_4le', `4', $1, `s32le', `4', + $1, `float', `4', `4')') diff --git a/topology/sof/pipe-dai-capture.m4 b/topology/sof/pipe-dai-capture.m4 index 887cd0c6c61d..cc44c0e3c3c9 100644 --- a/topology/sof/pipe-dai-capture.m4 +++ b/topology/sof/pipe-dai-capture.m4 @@ -6,7 +6,7 @@ include(`local.m4') # # DAI definitions # -W_DAI_IN(DAI_SNAME, DAI_TYPE, DAI_INDEX, dai0c_plat_conf) +W_DAI_IN(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 2, 0, 0, dai0c_plat_conf) # # DAI pipeline - always use 0 for DAIs diff --git a/topology/sof/pipe-dai-playback.m4 b/topology/sof/pipe-dai-playback.m4 index f3d08c0c55ee..f0967c27bd79 100644 --- a/topology/sof/pipe-dai-playback.m4 +++ b/topology/sof/pipe-dai-playback.m4 @@ -6,7 +6,7 @@ include(`local.m4') # # DAI definitions # -W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, dai0p_plat_conf) +W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) # # DAI pipeline - always use 0 for DAIs diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index 98b479fad1ef..a6ecb3255516 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -16,14 +16,14 @@ include(`local.m4') # with 2 sink and 0 source periods W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) -# Capture Buffers +# Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) # # DAI definitions # -W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, dai0p_plat_conf) +W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) # # DAI pipeline - always use 0 for DAIs @@ -33,7 +33,7 @@ W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCH # # Pipeline Graph # -# host PCM <--B1-- volume <--B0-- source DAI0 +# host PCM_P --> B0 --> sink DAI0 SectionGraph."pipe-pass-playback-PIPELINE_ID" { index STR(PIPELINE_ID) @@ -65,7 +65,7 @@ SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { buffer_size_max "65536" } -# PCM Low Latency Capture +# PCM Low Latency Passthrough Playback SectionPCM.STR(PCM PCM_ID) { index STR(PIPELINE_ID) From c69a7516ef2c470dc45b83e5d0168c4bc4818f02 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 21 Aug 2017 20:28:08 +0100 Subject: [PATCH 027/324] topology: Add simple playback passthrough pipeline with volume. Signed-off-by: Liam Girdwood --- topology/sof/pipe-passthrough-vol-playback.m4 | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 topology/sof/pipe-passthrough-vol-playback.m4 diff --git a/topology/sof/pipe-passthrough-vol-playback.m4 b/topology/sof/pipe-passthrough-vol-playback.m4 new file mode 100644 index 000000000000..ae2b56978702 --- /dev/null +++ b/topology/sof/pipe-passthrough-vol-playback.m4 @@ -0,0 +1,93 @@ +# Low Latency Passthrough with volume Pipeline and PCM +# +# Pipeline Endpoints for connection are :- +# +# host PCM_P --> B0 --> Volume 0 --> B1 --> sink DAI0 + +# Include topology builder +include(`local.m4') + + +# +# Components and Buffers +# + +# Host "Passthrough Playback" PCM uses pipeline DMAC and channel +# with 2 sink and 0 source periods +W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) + +# "Volume" has 2 source and 2 sink periods +W_PGA(Volume, PIPELINE_FORMAT, 2, 2, 2) + +# Playback Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) +W_BUFFER(1, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + +# +# DAI definitions +# +W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, + DAI_PERIODS, dai0p_plat_conf) + +# +# DAI pipeline - always use 0 for DAIs +# +W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, + SCHEDULE_CORE, pipe_dai_schedule_plat) + +# +# Pipeline Graph +# +# host PCM_P --> B0 --> Volume 0 --> B1 --> sink DAI0 + +SectionGraph."pipe-pass-vol-playback-PIPELINE_ID" { + index STR(PIPELINE_ID) + + lines [ + dapm(N_PCM, Passthrough Playback PCM_ID) + dapm(N_BUFFER(0), N_PCM) + dapm(N_PGA(Volume), N_BUFFER(0)) + dapm(N_BUFFER(1), N_PGA(Volume)) + dapm(N_DAI_OUT, N_BUFFER(1)) + ] +} + + +# +# PCM Configuration +# + +SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { + + formats "S24_LE,S16_LE" + rate_min "48000" + rate_max "48000" + channels_min "2" + channels_max "4" + periods_min "2" + periods_max "16" + period_size_min "192" + period_size_max "16384" + buffer_size_min "65536" + buffer_size_max "65536" +} + +# PCM Passthrough Playback +SectionPCM.STR(PCM PCM_ID) { + + index STR(PIPELINE_ID) + + # used for binding to the PCM + id STR(PCM_ID) + + dai.STR(Passthrough Playback PCM_ID) { + id STR(PCM_ID) + } + + pcm."playback" { + + capabilities STR(Passthrough Playback PCM_ID) + } +} From 7fb7598bc31b583aceb7768702290fb41b949066 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 24 Aug 2017 17:10:49 +0100 Subject: [PATCH 028/324] rmbox: Add EQs, SRC and Tone components to trace output Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 83d3c6e24c0e..1ea78357d6d9 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -38,6 +38,10 @@ #define TRACE_CLASS_VOLUME (14 << 24) #define TRACE_CLASS_SWITCH (15 << 24) #define TRACE_CLASS_MUX (16 << 24) +#define TRACE_CLASS_SRC (17 << 24) +#define TRACE_CLASS_TONE (18 << 24) +#define TRACE_CLASS_EQ_FIR (19 << 24) +#define TRACE_CLASS_EQ_IIR (20 << 24) #define MAILBOX_HOST_OFFSET 0x144000 @@ -146,6 +150,14 @@ static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp, uint32_ trace = "switch"; else if (class == TRACE_CLASS_MUX) trace = "mux"; + else if (class == TRACE_CLASS_SRC) + trace = "src"; + else if (class == TRACE_CLASS_TONE) + trace = "tone"; + else if (class == TRACE_CLASS_EQ_FIR) + trace = "eq-fir"; + else if (class == TRACE_CLASS_EQ_IIR) + trace = "eq-iir"; else { printf("value 0x%8.8x\n", (uint32_t)val); return; From da9108adffc2288752931b07cfcb2a759a53f7aa Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 24 Aug 2017 21:49:08 +0100 Subject: [PATCH 029/324] topology: test: Add new test topologies to help with component debug Add a simple passthrough and a passthrough with volume. Signed-off-by: Liam Girdwood --- topology/test/passthrough-24bit-48k-ssp2.m4 | 54 ++++++++++++++++++ .../test/passthrough-vol-24bit-48k-ssp2.m4 | 55 +++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 topology/test/passthrough-24bit-48k-ssp2.m4 create mode 100644 topology/test/passthrough-vol-24bit-48k-ssp2.m4 diff --git a/topology/test/passthrough-24bit-48k-ssp2.m4 b/topology/test/passthrough-24bit-48k-ssp2.m4 new file mode 100644 index 000000000000..9b9919d2826e --- /dev/null +++ b/topology/test/passthrough-24bit-48k-ssp2.m4 @@ -0,0 +1,54 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# + +# DAI Link Name +define(`TEST_DAI_LINK_NAME', `Baytrail Audio') + +# DAI Link Stream Name +define(`TEST_DAI_LINK_STREAM_NAME', `Audio') + +# +# Define the pipeline +# +# PCM0 ----> SSP2 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, + 1, 0, 2, s24le, + 48, 1000, 0, 0, 0, 1, + SSP, 2, TEST_DAI_LINK_STREAM_NAME, 2) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# 24bit I2S using 25bit sample conatiner on SSP2 +# +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, TEST_DAI_LINK_STREAM_NAME, I2S, 24, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/test/passthrough-vol-24bit-48k-ssp2.m4 b/topology/test/passthrough-vol-24bit-48k-ssp2.m4 new file mode 100644 index 000000000000..b1a0dab0520b --- /dev/null +++ b/topology/test/passthrough-vol-24bit-48k-ssp2.m4 @@ -0,0 +1,55 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# + +# DAI Link Name +define(`TEST_DAI_LINK_NAME', `Baytrail Audio') + +# DAI Link Stream Name +define(`TEST_DAI_LINK_STREAM_NAME', `Audio') + + +# +# Define the pipeline +# +# PCM0 ---> volume ---> SSP2 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-vol-playback.m4, + 1, 0, 2, s24le, + 48, 1000, 0, 0, 0, 1, + SSP, 2, TEST_DAI_LINK_STREAM_NAME, s24le, 2) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# 24bit I2S using 25bit sample conatiner on SSP2 +# +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, TEST_DAI_LINK_STREAM_NAME, I2S, 24, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 25, 3, 3)) From 5ca8e8d39c5c1edec02414f3ba6b02201522726d Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 24 Aug 2017 21:52:00 +0100 Subject: [PATCH 030/324] topology: Remove second SRC from BYT/CHT default topologies SRC in default full rate and high quality configuration is quite large. free up some memory on BYT and CHT by using only one SRC. TODO: Provide the SRC with configuration data for supported rates and quality in order to significantly reduce it's footprint. Signed-off-by: Liam Girdwood --- topology/reef-byt-nocodec.m4 | 9 --------- topology/reef-byt-rt5640.m4 | 9 --------- topology/reef-byt-rt5651.m4 | 18 +++++------------- topology/reef-cht-nocodec.m4 | 9 --------- 4 files changed, 5 insertions(+), 40 deletions(-) diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index 96e2e4bb0183..01b223da3d93 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -22,8 +22,6 @@ include(`dsps/byt.m4') # |--low latency mixer ----> volume ----> SSP2 # PCM2 ----> SRC -----> volume ----+ # | -# PCM3 ----> SRC -----> volume ----+ -# | # Tone -----> volume ----+ # # PCM1 <---- Volume <---- SSP2 @@ -44,11 +42,6 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) - # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) @@ -60,8 +53,6 @@ SectionGraph."pipe-byt-nocodec" { lines [ # media 0 dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - # media 1 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index c135fed9bcad..00d31c751eca 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -22,8 +22,6 @@ include(`dsps/byt.m4') # |--low latency mixer ----> volume ----> SSP2 # PCM2 ----> SRC -----> volume ----+ # | -# PCM3 ----> SRC -----> volume ----+ -# | # Tone -----> volume ----+ # # PCM1 <---- Volume <---- SSP2 @@ -44,11 +42,6 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) - # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) @@ -60,8 +53,6 @@ SectionGraph."pipe-byt-rt5640" { lines [ # media 0 dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - # media 1 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index 877492a3b1f0..fd5263f8d0da 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -22,8 +22,6 @@ include(`dsps/byt.m4') # |--low latency mixer ----> volume ----> SSP2 # PCM2 ----> SRC -----> volume ----+ # | -# PCM3 ----> SRC -----> volume ----+ -# | # Tone -----> volume ----+ # # PCM1 <---- Volume <---- SSP2 @@ -44,11 +42,6 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) - # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) @@ -60,8 +53,6 @@ SectionGraph."pipe-byt-rt5651" { lines [ # media 0 dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - # media 1 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] @@ -73,11 +64,11 @@ SectionGraph."pipe-byt-rt5651" { # SSP port 2 is our only pipeline DAI # -# playback DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) +# playback DAI is SSP2 using "Audio" DAPM stream name and 2 periods +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, Audio, PIPELINE_SOURCE_1, 2) -# capture DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) +# capture DAI is SSP2 using "Audio" DAPM stream name and 2 periods +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, Audio, PIPELINE_SINK_2, 2) # # BE configurations - overrides config in ACPI if present @@ -87,3 +78,4 @@ DAI_CONFIG(SSP, 2, Baytrail Audio, Audio, I2S, 24, DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), DAI_TDM(2, 25, 3, 3)) + diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index 381ff127ea2c..334443b999f3 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -22,8 +22,6 @@ include(`dsps/cht.m4') # |--low latency mixer ----> volume ----> SSP2 # PCM2 ----> SRC -----> volume ----+ # | -# PCM3 ----> SRC -----> volume ----+ -# | # Tone -----> volume ----+ # # PCM1 <---- Volume <---- SSP2 @@ -39,11 +37,6 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) - # PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 4 for PCM audio playback data @@ -60,8 +53,6 @@ SectionGraph."pipe-cht-nocodec" { lines [ # media 0 dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - # media 1 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] From 91bee9eb50870d75b73d00fb1993c38ebea3e9aa Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 27 Aug 2017 17:10:08 +0100 Subject: [PATCH 031/324] Revert "rimage: update to new SOF driver file format." This reverts commit 03acfd640d87977a8337016002e23e19c0b08b2b. --- rimage/baytrail.c | 73 +++++++++++-------- rimage/cherrytrail.c | 9 +-- rimage/file_format.h | 166 ++++++++++++++++++------------------------- rimage/rimage.c | 26 ++++--- rimage/rimage.h | 11 --- 5 files changed, 134 insertions(+), 151 deletions(-) diff --git a/rimage/baytrail.c b/rimage/baytrail.c index 12ccd2355224..0053f97dfab7 100644 --- a/rimage/baytrail.c +++ b/rimage/baytrail.c @@ -40,6 +40,17 @@ static const struct section byt_sections[] = { {"NMIExceptionVector", 0xff2c061c}, }; +static const enum reef_module_id modules[] = { + REEF_MODULE_BASE_FW, + REEF_MODULE_AAC_5_1, + REEF_MODULE_PCM, + REEF_MODULE_PCM_SYSTEM, + REEF_MODULE_PCM_CAPTURE, + REEF_MODULE_PCM_REFERENCE, + REEF_MODULE_BLUETOOTH_RENDER_MODULE, + REEF_MODULE_BLUETOOTH_CAPTURE_MODULE, +}; + static int is_iram(struct image *image, Elf32_Shdr *section) { const struct adsp *adsp = image->adsp; @@ -75,7 +86,7 @@ static int block_idx = 0; static int write_block(struct image *image, Elf32_Shdr *section) { const struct adsp *adsp = image->adsp; - struct snd_sof_blk_hdr block; + struct dma_block_info block; size_t count; void *buffer; int ret; @@ -83,13 +94,11 @@ static int write_block(struct image *image, Elf32_Shdr *section) block.size = section->sh_size; if (is_iram(image, section)) { - block.type = SOF_BLK_TEXT; - block.offset = section->sh_addr - adsp->iram_base - + adsp->host_iram_offset; + block.type = REEF_IRAM; + block.ram_offset = section->sh_addr - adsp->iram_base; } else if (is_dram(image, section)) { - block.type = SOF_BLK_DATA; - block.offset = section->sh_addr - adsp->dram_base - + adsp->host_dram_offset; + block.type = REEF_DRAM; + block.ram_offset = section->sh_addr - adsp->dram_base; } else { fprintf(stderr, "error: invalid block address/size 0x%x/0x%x\n", section->sh_addr, section->sh_size); @@ -144,18 +153,18 @@ static int write_block(struct image *image, Elf32_Shdr *section) int byt_write_modules(struct image *image) { const struct adsp *adsp = image->adsp; - struct snd_sof_mod_hdr hdr; + struct byt_module_header hdr; Elf32_Shdr *section; size_t count; int i, err; uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - fprintf(stdout, "Using BYT file format\n"); - - hdr.num_blocks = image->num_sections - image->num_bss; - hdr.size = image->text_size + image->data_size + - sizeof(struct snd_sof_blk_hdr) * hdr.num_blocks; - hdr.type = SOF_FW_BASE; + memcpy(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE); + hdr.blocks = image->num_sections - image->num_bss; + hdr.mod_size = image->text_size + image->data_size + \ + sizeof(struct dma_block_info) * hdr.blocks; + hdr.type = REEF_MODULE_BASE_FW; + hdr.entry_point = 0;//section->sh_addr; count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); if (count != 1) { @@ -182,28 +191,41 @@ int byt_write_modules(struct image *image) } } + /* write the remaining 7 fake modules headers, to make the linux driver happy */ + hdr.mod_size = 0; + hdr.blocks = 0; + + for (i = 1; i < sizeof(modules) / sizeof(modules[0]); i++) { + hdr.type = modules[i]; + count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); + if (count != 1) { + fprintf(stderr, "error: failed to write section header %d\n", i); + return -errno ; + } + } + return 0; } /* used by others */ int byt_write_header(struct image *image) { - struct snd_sof_fw_header hdr; + struct fw_header hdr; size_t count; - memcpy(hdr.sig, SND_SOF_FW_SIG, SND_SOF_FW_SIG_SIZE); + memcpy(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE); - hdr.num_modules = 1; - hdr.abi = SND_SOF_FW_ABI; + hdr.modules = sizeof(modules) / sizeof(modules[0]); + hdr.file_format = 0; - image->fw_size += sizeof(struct snd_sof_blk_hdr) * + image->fw_size += sizeof(struct dma_block_info) * (image->num_sections - image->num_bss); - image->fw_size += sizeof(struct snd_sof_mod_hdr) * hdr.num_modules; + image->fw_size += sizeof(struct byt_module_header) * hdr.modules; hdr.file_size = image->fw_size; fprintf(stdout, "fw: image size %ld (0x%lx) bytes %d modules\n\n", hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), - hdr.num_modules); + hdr.modules); count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); if (count != 1) return -errno; @@ -211,19 +233,14 @@ int byt_write_header(struct image *image) return 0; } -#define IRAM_OFFSET 0x0C0000 -#define IRAM_SIZE (80 * 1024) -#define DRAM_OFFSET 0x100000 -#define DRAM_SIZE (160 * 1024) - const struct adsp byt_machine = { .name = "byt", .iram_base = 0xff2c0000, .iram_size = 0x14000, - .host_iram_offset = IRAM_OFFSET, .dram_base = 0xff300000, .dram_size = 0x28000, - .host_dram_offset = DRAM_OFFSET, + .image_size = 0xff300000 - 0xff2c0000 + 0x28000, + .dram_offset = 0xff300000 - 0xff2c0000, .machine_id = MACHINE_BAYTRAIL, .ops = { .write_header = byt_write_header, diff --git a/rimage/cherrytrail.c b/rimage/cherrytrail.c index e27bea63e565..a37a13db2353 100644 --- a/rimage/cherrytrail.c +++ b/rimage/cherrytrail.c @@ -40,19 +40,14 @@ static const struct section cht_sections[] = { {"NMIExceptionVector", 0xff2c061c}, }; -#define IRAM_OFFSET 0x0C0000 -#define IRAM_SIZE (80 * 1024) -#define DRAM_OFFSET 0x100000 -#define DRAM_SIZE (160 * 1024) - const struct adsp cht_machine = { .name = "cht", .iram_base = 0xff2c0000, .iram_size = 0x14000, - .host_iram_offset = IRAM_OFFSET, .dram_base = 0xff300000, .dram_size = 0x28000, - .host_dram_offset = DRAM_OFFSET, + .image_size = 0xff300000 - 0xff2c0000 + 0x28000, + .dram_offset = 0xff300000 - 0xff2c0000, .machine_id = MACHINE_CHERRYTRAIL, .ops = { .write_header = byt_write_header, diff --git a/rimage/file_format.h b/rimage/file_format.h index c813f49c0bc2..941df332549f 100644 --- a/rimage/file_format.h +++ b/rimage/file_format.h @@ -1,116 +1,88 @@ /* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. + * ELF to firmware image creator. * - * GPL LICENSE SUMMARY + * Copyright (c) 2015, Intel Corporation. * - * Copyright(c) 2017 Intel Corporation. All rights reserved. + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2017 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Author: Liam Girdwood + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. */ -/* - * Firmware file format . - */ +#ifndef __FILE_FORMAT_H__ +#define __FILE_FORMAT_H__ -#ifndef __INCLUDE_UAPI_SOF_FW_H__ -#define __INCLUDE_UAPI_SOF_FW_H__ +#define REEF_FW_SIGNATURE_SIZE 4 +#define REEF_FW_SIGN "$SST" +#define REEF_FW_LIB_SIGN "$LIB" -#define SND_SOF_FW_SIG_SIZE 4 -#define SND_SOF_FW_ABI 1 -#define SND_SOF_FW_SIG "Reef" +#define REEF_IRAM 1 +#define REEF_DRAM 2 +#define REEF_REGS 3 +#define REEF_CACHE 3 -/* - * Firmware module is made up of 1 . N blocks of different types. The - * Block header is used to determine where and how block is to be copied in the - * DSP/host memory space. - */ -enum snd_sof_fw_blk_type { - SOF_BLK_IMAGE = 0, /* whole image - parsed by ROMs */ - SOF_BLK_TEXT = 1, - SOF_BLK_DATA = 2, - SOF_BLK_CACHE = 3, - SOF_BLK_REGS = 4, - SOF_BLK_SIG = 5, - SOF_BLK_ROM = 6, - /* add new block types here */ +enum reef_module_id { + REEF_MODULE_BASE_FW = 0x0, + REEF_MODULE_MP3 = 0x1, + REEF_MODULE_AAC_5_1 = 0x2, + REEF_MODULE_AAC_2_0 = 0x3, + REEF_MODULE_SRC = 0x4, + REEF_MODULE_WAVES = 0x5, + REEF_MODULE_DOLBY = 0x6, + REEF_MODULE_BOOST = 0x7, + REEF_MODULE_LPAL = 0x8, + REEF_MODULE_DTS = 0x9, + REEF_MODULE_PCM_CAPTURE = 0xA, + REEF_MODULE_PCM_SYSTEM = 0xB, + REEF_MODULE_PCM_REFERENCE = 0xC, + REEF_MODULE_PCM = 0xD, + REEF_MODULE_BLUETOOTH_RENDER_MODULE = 0xE, + REEF_MODULE_BLUETOOTH_CAPTURE_MODULE = 0xF, + REEF_MAX_MODULE_ID, }; -struct snd_sof_blk_hdr { - enum snd_sof_fw_blk_type type; - uint32_t size; /* bytes minus this header */ - uint32_t offset; /* offset from base */ +struct dma_block_info { + uint32_t type; /* IRAM/DRAM */ + uint32_t size; /* Bytes */ + uint32_t ram_offset; /* Offset in I/DRAM */ + uint32_t rsvd; /* Reserved field */ } __attribute__((packed)); -/* - * Firmware file is made up of 1 .. N different modules types. The module - * type is used to determine how to load and parse the module. - */ -enum snd_sof_fw_mod_type { - SOF_FW_BASE = 0, /* base firmware image */ - SOF_FW_MODULE = 1, /* firmware module */ -}; +struct fw_module_info { + uint32_t persistent_size; + uint32_t scratch_size; +} __attribute__((packed)); -struct snd_sof_mod_hdr { - enum snd_sof_fw_mod_type type; - uint32_t size; /* bytes minus this header */ - uint32_t num_blocks; /* number of blocks */ +struct fw_header { + unsigned char signature[REEF_FW_SIGNATURE_SIZE]; /* FW signature */ + uint32_t file_size; /* size of fw minus this header */ + uint32_t modules; /* # of modules */ + uint32_t file_format; /* version of header format */ + uint32_t reserved[4]; } __attribute__((packed)); -/* - * Firmware file header. - */ -struct snd_sof_fw_header { - unsigned char sig[SND_SOF_FW_SIG_SIZE]; /* "Reef" */ - uint32_t file_size; /* size of file minus this header */ - uint32_t num_modules; /* number of modules */ - uint32_t abi; /* version of header format */ +/* ABI 0 - used by reef driver and CoE BDW/HSW firmware*/ +struct hsw_module_header { + unsigned char signature[REEF_FW_SIGNATURE_SIZE]; /* module signature */ + uint32_t mod_size; /* size of module */ + uint32_t blocks; /* # of blocks */ + uint16_t padding; + uint16_t type; /* codec type, pp lib */ + uint32_t entry_point; + struct fw_module_info info; } __attribute__((packed)); +/* ABI 1 - used by CoE/MCG BYT/CHT/BSW driver */ +struct byt_module_header { + unsigned char signature[REEF_FW_SIGNATURE_SIZE]; + uint32_t mod_size; /* size of module */ + uint32_t blocks; /* # of blocks */ + uint32_t type; /* codec type, pp lib */ + uint32_t entry_point; +}__attribute__((packed)); + #endif diff --git a/rimage/rimage.c b/rimage/rimage.c index 0695ce34398c..bed6b48cd8c3 100644 --- a/rimage/rimage.c +++ b/rimage/rimage.c @@ -223,12 +223,9 @@ int main(int argc, char *argv[]) { struct image image; const char *mach = NULL; - int opt, ret, i; + int opt, ret, i, binary = 0; memset(&image, 0, sizeof(image)); - image.text_start = 0xffffffff; - image.data_start = 0xffffffff; - image.bss_start = 0xffffffff; while ((opt = getopt(argc, argv, "ho:i:m:vba:sk:")) != -1) { switch (opt) { @@ -244,6 +241,9 @@ int main(int argc, char *argv[]) case 'v': image.verbose = 1; break; + case 'b': + binary = 1; + break; case 's': image.dump_sections = 1; break; @@ -282,16 +282,26 @@ int main(int argc, char *argv[]) image.in_file, errno); } - /* open outfile for writing */ - unlink(image.out_file); + /* open outfile for reading */ image.out_fd = fopen(image.out_file, "w"); if (image.out_fd == NULL) { fprintf(stderr, "error: unable to open %s for writing %d\n", image.out_file, errno); } - /* write data */ - ret = write_elf_data(&image); + if (binary) { + + switch(image.adsp->machine_id) { + case MACHINE_BAYTRAIL: + ret = write_byt_binary_image(&image); + break; + default: + fprintf(stderr, "error: not supported machine for binary input!\n"); + return ret; + } + + } else + ret = write_elf_data(&image); /* close files */ fclose(image.out_fd); diff --git a/rimage/rimage.h b/rimage/rimage.h index 9b8200afa36d..2c029328ceaa 100644 --- a/rimage/rimage.h +++ b/rimage/rimage.h @@ -50,13 +50,6 @@ struct image { int data_size; int file_size; int num_modules; - uint32_t text_start; - uint32_t text_end; - uint32_t data_start; - uint32_t data_end; - uint32_t bss_start; - uint32_t bss_end; - /* disa */ void *in_buffer; @@ -89,12 +82,8 @@ struct adsp { uint32_t iram_size; uint32_t dram_base; uint32_t dram_size; - uint32_t host_iram_offset; - uint32_t host_dram_offset; - uint32_t image_size; uint32_t dram_offset; - enum machine_id machine_id; struct adsp_ops ops; const struct section *sections; From 4ca4028d2c7b62821f8e5d138378af8c2a5483ae Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 27 Aug 2017 17:11:06 +0100 Subject: [PATCH 032/324] Revert "rimage: remove flat file builder." This reverts commit 072fb5c43f03a5b4f0630a1bc5d2a8db9cb38807. --- rimage/Makefile.am | 4 +- rimage/flat.c | 256 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 258 insertions(+), 2 deletions(-) create mode 100644 rimage/flat.c diff --git a/rimage/Makefile.am b/rimage/Makefile.am index 0ba8ce6f4c4d..32335fe68957 100644 --- a/rimage/Makefile.am +++ b/rimage/Makefile.am @@ -6,5 +6,5 @@ noinst_HEADERS = \ rimage_SOURCES = \ cherrytrail.c \ baytrail.c \ - rimage.c - + flat.c \ + rimage.c \ No newline at end of file diff --git a/rimage/flat.c b/rimage/flat.c new file mode 100644 index 000000000000..8c5d1c58b557 --- /dev/null +++ b/rimage/flat.c @@ -0,0 +1,256 @@ +/* + * ELF to firmware image creator. + * + * Copyright (c) 2015, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include + +#include "rimage.h" +#include "file_format.h" + +static int dump_section(struct image *image, struct dma_block_info *block, + void *data) +{ + const struct adsp *adsp = image->adsp; + uint32_t addr; + + switch (block->type) { + case REEF_IRAM: + addr = block->ram_offset + adsp->iram_base; + break; + case REEF_DRAM: + addr = block->ram_offset + adsp->dram_base; + break; + case REEF_CACHE: + addr = block->ram_offset + adsp->dram_base; + break; + default: + return -EINVAL; + } +} + +static int read_byt_bin_module(struct image *image, + struct byt_module_header *module) +{ + const struct adsp *adsp = image->adsp; + struct dma_block_info *block; + int count, offset; + void *data; + + block = (void *)module + sizeof(*module); + + for (count = 0; count < module->blocks; count++) { + + if (block->size <= 0) { + fprintf(stderr, "block %d size invalid\n", count); + return -EINVAL; + } + + switch (block->type) { + case REEF_IRAM: + offset = block->ram_offset + 0; + break; + case REEF_DRAM: + offset = block->ram_offset + + adsp->dram_offset; + break; + case REEF_CACHE: + offset = block->ram_offset + + adsp->dram_offset; + break; + default: + fprintf(stderr, "wrong ram type 0x%x in block0x%x\n", + block->type, count); + return -EINVAL; + } + + fprintf(stdout, "bin: block %d type %d offset 0x%x size 0x%x\n", + count, block->type, offset, block->size); + + data = (void *)block + sizeof(*block); + memcpy(image->out_buffer + offset, data, block->size); + + if (image->dump_sections) + dump_section(image, block, data); + + block = (void *)block + sizeof(*block) + block->size; + } + + return 0; +} + +static int read_bdw_bin_module(struct image *image, + struct hsw_module_header *module) +{ + const struct adsp *adsp = image->adsp; + struct dma_block_info *block; + int count, offset; + void *data; + + block = (void *)module + sizeof(*module); + + for (count = 0; count < module->blocks; count++) { + + if (block->size <= 0) { + fprintf(stderr, "block %d size invalid\n", count); + return -EINVAL; + } + + switch (block->type) { + case REEF_IRAM: + offset = block->ram_offset + 0; + break; + case REEF_DRAM: + offset = block->ram_offset + + adsp->dram_offset; + break; + case REEF_CACHE: + offset = block->ram_offset + + adsp->dram_offset; + break; + default: + fprintf(stderr, "wrong ram type 0x%x in block0x%x\n", + block->type, count); + return -EINVAL; + } + + fprintf(stdout, "bin: block %d type %d offset 0x%x size 0x%x\n", + count, block->type, offset, block->size); + + data = (void *)block + sizeof(*block); + memcpy(image->out_buffer + offset, data, block->size); + + if (image->dump_sections) + dump_section(image, block, data); + + block = (void *)block + sizeof(*block) + block->size; + } + + return 0; +} + +static int read_bin_data(struct image *image) +{ + const struct adsp *adsp = image->adsp; + struct fw_header hdr; + size_t count; + + count = fread(&hdr, sizeof(hdr), 1, image->in_fd); + if (count != 1) + return -errno; + + if (strncmp(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE)) { + fprintf(stderr, "invalid header signature: %c%c%c%c\n", + hdr.signature[0], hdr.signature[1], + hdr.signature[2], hdr.signature[3]); + return -EINVAL; + } + + image->fw_size = hdr.file_size; + image->num_modules = hdr.modules; + + fprintf(stdout, "bin: input image size %ld (0x%lx) bytes %d modules\n", + hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), + hdr.modules); + fprintf(stdout, "bin: output image size %d (0x%x) bytes\n", + adsp->image_size, + adsp->image_size); + + image->in_buffer = calloc(image->fw_size, 1); + if (image->in_buffer == NULL) + return -ENOMEM; + + count = fread(image->in_buffer, image->fw_size, 1, image->in_fd); + if (count != 1) { + free(image->in_buffer); + return -errno; + } + + image->out_buffer = calloc(adsp->image_size, 1); + if (image->out_buffer == NULL) { + free(image->in_buffer); + return -ENOMEM; + } + + return 0; +} + +int write_byt_binary_image(struct image *image) +{ + const struct adsp *adsp = image->adsp; + struct byt_module_header *module; + int ret, count; + + ret = read_bin_data(image); + if (ret < 0) + return ret; + + module = (void *)image->in_buffer; + + for (count = 0; count < image->num_modules; count++) { + + fprintf(stdout, "bin: module %d type %d blocks %d size 0x%x\n", + count, module->type, module->blocks, module->mod_size); + + ret = read_byt_bin_module(image, module); + if (ret < 0) { + fprintf(stderr, "invalid module %d\n", count); + return ret; + } + module = (void *)module + sizeof(*module) + module->mod_size; + } + + count = fwrite(image->out_buffer, adsp->image_size, 1, + image->out_fd); + if (count != adsp->image_size) + return -errno; + + return ret; +} + +int write_bdw_binary_image(struct image *image) +{ + const struct adsp *adsp = image->adsp; + struct hsw_module_header *module; + int ret, count; + + ret = read_bin_data(image); + if (ret < 0) + return ret; + + module = (void *)image->in_buffer; + + for (count = 0; count < image->num_modules; count++) { + + fprintf(stdout, "bin: module %d type %d blocks %d size 0x%x\n", + count, module->type, module->blocks, module->mod_size); + + ret = read_bdw_bin_module(image, module); + if (ret < 0) { + fprintf(stderr, "invalid module %d\n", count); + return ret; + } + module = (void *)module + sizeof(*module) + module->mod_size; + } + + count = fwrite(image->out_buffer, adsp->image_size, 1, + image->out_fd); + if (count != adsp->image_size) + return -errno; + + return ret; +} From 811918df7072922680d6c2f21df289ce62c784d5 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 25 Aug 2017 19:48:14 +0100 Subject: [PATCH 033/324] topology: Add format and scheduling info to DAI pipelines. Some pipelines can be used to service DAIs before data is sent on to other processing pipelines. Add scheduling and format info to DAI pipelines. Signed-off-by: Liam Girdwood --- topology/m4/build.m4 | 12 +++++++++++- topology/reef-apl-nocodec.m4 | 6 ++++-- topology/reef-bdw-rt286.m4 | 6 ++++-- topology/reef-bdw-rt5640.m4 | 6 ++++-- topology/reef-bxt-nocodec.m4 | 6 ++++-- topology/reef-byt-nocodec.m4 | 6 ++++-- topology/reef-byt-rt5640.m4 | 6 ++++-- topology/reef-byt-rt5651.m4 | 6 ++++-- topology/reef-cht-nocodec.m4 | 6 ++++-- topology/reef-hsw-rt5640.m4 | 6 ++++-- 10 files changed, 47 insertions(+), 19 deletions(-) diff --git a/topology/m4/build.m4 b/topology/m4/build.m4 index 843dcbba3066..7d248dad1853 100644 --- a/topology/m4/build.m4 +++ b/topology/m4/build.m4 @@ -81,7 +81,7 @@ define(`PIPELINE_ADD', `include($1)' ) -dnl DAI_ADD(pipeline, dai type, dai_index, stream_name, buffer, periods) +dnl DAI_ADD(pipeline, dai type, dai_index, stream_name, buffer, periods, format, frames, deadline, priority, core) define(`DAI_ADD', `undefine(`PIPELINE_ID')' `undefine(`DAI_TYPE')' @@ -89,6 +89,11 @@ define(`DAI_ADD', `undefine(`DAI_SNAME')' `undefine(`DAI_BUF')' `undefine(`DAI_PERIODS')' +`undefine(`DAI_FORMAT')' +`undefine(`SCHEDULE_FRAMES')' +`undefine(`SCHEDULE_DEADLINE')' +`undefine(`SCHEDULE_PRIORITY')' +`undefine(`SCHEDULE_CORE')' `define(`PIPELINE_ID', 0)' `define(`DAI_TYPE', STR($2))' `define(`DAI_INDEX', STR($3))' @@ -96,6 +101,11 @@ define(`DAI_ADD', `define(`DAI_BUF', $5)' `define(`DAI_NAME', $2$3)' `define(`DAI_PERIODS', $6)' +`define(`DAI_FORMAT', $7)' +`define(`SCHEDULE_FRAMES', $8)' +`define(`SCHEDULE_DEADLINE', $9)' +`define(`SCHEDULE_PRIORITY', $10)' +`define(`SCHEDULE_CORE', $11)' `include($1)' ) diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index 93b57fe84a6f..ef80fd341aef 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -74,10 +74,12 @@ SectionGraph."pipe-apl-nocodec" { # # playback DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index e4b600ab0111..e3f8dd9ff019 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -74,10 +74,12 @@ SectionGraph."pipe-bdw-rt286" { # # playback DAI is SSP0 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP0 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index 5d962368b6c1..434460548525 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -74,10 +74,12 @@ SectionGraph."pipe-bdw-rt5640" { # # playback DAI is SSP0 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP0 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index a8fd320bff85..2028323e3f0d 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -74,10 +74,12 @@ SectionGraph."pipe-bxt-nocodec" { # # playback DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index 01b223da3d93..1c3cf5f34cf5 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -65,10 +65,12 @@ SectionGraph."pipe-byt-nocodec" { # # playback DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 00d31c751eca..0629d43d8f57 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -65,10 +65,12 @@ SectionGraph."pipe-byt-rt5640" { # # playback DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index fd5263f8d0da..1b492b72de5a 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -65,10 +65,12 @@ SectionGraph."pipe-byt-rt5651" { # # playback DAI is SSP2 using "Audio" DAPM stream name and 2 periods -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, Audio, PIPELINE_SOURCE_1, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, Audio, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using "Audio" DAPM stream name and 2 periods -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, Audio, PIPELINE_SINK_2, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index 334443b999f3..ead0f7507442 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -65,10 +65,12 @@ SectionGraph."pipe-cht-nocodec" { # # playback DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index 3a7622325973..e4d93929b7f9 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -74,10 +74,12 @@ SectionGraph."pipe-hsw-rt5640" { # # playback DAI is SSP0 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP0 using I2S DAPM stream and 2 periods -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present From 7a1105772d393614b011b21e63192e364fb3e6cd Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 30 Aug 2017 22:24:03 +0100 Subject: [PATCH 034/324] rmbox: fix help output to show all options Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 1ea78357d6d9..b51ddcc9c494 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -92,7 +92,10 @@ static inline char get_char(uint32_t val, int idx) static void usage(char *name) { - fprintf(stdout, "%s:\t -i infile -o outfile\n", name); + fprintf(stdout, "Usage %s \n", name); + fprintf(stdout, "%s:\t -i infile -o outfile\tDump infile contents to outfile\n", name); + fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", name); + fprintf(stdout, "%s:\t -s\t\t\tTake a snapshot of state\n", name); exit(0); } @@ -276,9 +279,6 @@ int main(int argc, char *argv[]) } } - if (argc > 1 && (in_file == NULL || out_file == NULL)) - usage(argv[0]); - /* open infile for reading */ in_fd = fopen(in_file, "r"); if (in_fd == NULL) { From 6bb4da421c536ee2d32b2cfe338c8f4d7b27f8c5 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 30 Aug 2017 22:24:54 +0100 Subject: [PATCH 035/324] rmbox: Add support for floating point clock freq in MHz Allow timestamp clock frequency to be set in MHz Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index b51ddcc9c494..1f81e06923f6 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -99,23 +99,38 @@ static void usage(char *name) exit(0); } -static inline float to_usecs(uint32_t time, uint32_t clk) +static float to_usecs(uint32_t time, float clk) { /* trace timestamp uses CPU system clock at default 25MHz ticks */ // TODO: support variable clock rates return (float)time / clk; } -static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp, uint32_t clk) +static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp, float clk) { const char *trace; uint32_t class; + uint32_t delta = val - *timestamp; + float fdelta = to_usecs(delta, clk); /* timestamp or value ? */ if ((addr % 8) == 0) { + + /* buffer wrap ? */ + if (val < *timestamp) { + printf("----------------------------------------" + "----------------------------------------" + "--------------------------------------\n"); + delta = 0; + fdelta = 0.0; + } else { + delta = val - *timestamp; + fdelta = to_usecs(delta, clk); + } + printf("trace.io: timestamp 0x%8.8x (%2.2f us) \tdelta 0x%8.8x (%2.2f us)\t", (uint32_t)val, to_usecs(val, clk), - (uint32_t)val - *timestamp, to_usecs(val - *timestamp, clk)); + (uint32_t)delta, fdelta); *timestamp = val; return; } @@ -258,7 +273,8 @@ int main(int argc, char *argv[]) const char * out_file = NULL, *in_file = "/sys/kernel/debug/sof/mbox"; FILE *in_fd = NULL, *out_fd = NULL; char c, tmp[4] = {0}; - uint32_t addr = 0, val, clk = 25, timestamp = 0; + uint32_t addr = 0, val, timestamp = 0; + float clk = 19.2f; while ((opt = getopt(argc, argv, "ho:i:s:m:c:")) != -1) { switch (opt) { @@ -269,7 +285,7 @@ int main(int argc, char *argv[]) in_file = optarg; break; case 'c': - clk = atoi(optarg); + clk = atof(optarg); break; case 's': return snapshot(optarg); @@ -301,6 +317,8 @@ int main(int argc, char *argv[]) /* start to converting mailbox */ convert: + fprintf(stdout, "using %2.2fMHz timestamp clock\n", clk); + while (1) { count = fread(&tmp[0], 1, 4, in_fd); if (count != 4) From 1bed6ee95d3611170224fe49cfe5124f5679c8f5 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 31 Aug 2017 23:48:35 +0100 Subject: [PATCH 036/324] topology: bind kcontrols to PGA widgets. Add an parameter to bind TLV volume kcontrol to volume widget. Signed-off-by: Liam Girdwood --- topology/m4/local.m4 | 13 ++++--- topology/sof/pipe-low-latency-capture.m4 | 8 ++--- topology/sof/pipe-low-latency-playback.m4 | 16 ++++----- topology/sof/pipe-passthrough-vol-playback.m4 | 36 +++++++++++++++++-- topology/sof/pipe-pcm-media.m4 | 6 ++-- topology/sof/pipe-tone.m4 | 6 ++-- 6 files changed, 59 insertions(+), 26 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 7bcebeef2099..5da77e27da1a 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -142,14 +142,14 @@ define(`W_PCM_CAPTURE', dnl PGA name) define(`N_PGA', `PGA'PIPELINE_ID`.'$1) -dnl W_PGA(name, format, periods_sink, periods_source, preload) +dnl W_PGA(name, kcontrol, format, periods_sink, periods_source, preload) define(`W_PGA', `SectionVendorTuples."'N_PGA($1)`_tuples_w" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) ` }' `}' `SectionData."'N_PGA($1)`_data_w" {' @@ -158,7 +158,7 @@ define(`W_PGA', `SectionVendorTuples."'N_PGA($1)`_tuples_str" {' ` tokens "sof_comp_tokens"' ` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($2) +` SOF_TKN_COMP_FORMAT' STR($3) ` }' `}' `SectionData."'N_PGA($1)`_data_str" {' @@ -172,6 +172,9 @@ define(`W_PGA', ` "'N_PGA($1)`_data_w"' ` "'N_PGA($1)`_data_str"' ` ]' +` mixer [' +` "'$2`"' +` ]' `}') dnl Mixer Name) diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 3b53d0a67832..111aa86f0cb7 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -48,7 +48,7 @@ SectionControlMixer.STR(PCM PCM_ID Capture Volume) { W_PCM_CAPTURE(Low Latency Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 0) # "Capture Volume" has 2 sink and source periods for host and DAI ping-pong -W_PGA(Capture Volume, PIPELINE_FORMAT, 2, 2, 0) +W_PGA(0, PCM PCM_ID Capture Volume, PIPELINE_FORMAT, 2, 2, 0) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, @@ -67,8 +67,8 @@ SectionGraph."pipe-ll-capture-PIPELINE_ID" { lines [ dapm(Low Latency Capture PCM_ID, N_PCM) dapm(N_PCM, N_BUFFER(1)) - dapm(N_BUFFER(1), N_PGA(Capture Volume)) - dapm(N_PGA(Capture Volume), N_BUFFER(0)) + dapm(N_BUFFER(1), N_PGA(0)) + dapm(N_PGA(0), N_BUFFER(0)) ] } @@ -81,7 +81,7 @@ indir(`define', concat(`PIPELINE_SINK_', PIPELINE_ID), N_BUFFER(0)) # Pipeline Configuration. # -W_PIPELINE(N_PGA(Capture Volume), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) +W_PIPELINE(N_PGA(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) # # PCM Configuration diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index 00f7447f9165..a860c829a84b 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -91,10 +91,10 @@ SectionControlMixer.STR(Master Playback Volume) { W_PCM_PLAYBACK(Low Latency Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Playback Volume" has 1 sink period and 2 source periods for host ping-pong -W_PGA(Playback Volume, PIPELINE_FORMAT, 1, 2, 1) +W_PGA(0, PCM PCM_ID Playback Volume, PIPELINE_FORMAT, 1, 2, 1) -# "Mixer Volume" has 1 source and 2 sink periods for DAI ping-pong -W_PGA(Mixer Volume, PIPELINE_FORMAT, 2, 1, 1) +# "Master Playback Volume" has 1 source and 2 sink periods for DAI ping-pong +W_PGA(1, Master Playback Volume, PIPELINE_FORMAT, 2, 1, 1) # Mixer 0 has 1 sink and source periods. W_MIXER(0, PIPELINE_FORMAT, 1, 1, 1) @@ -127,12 +127,12 @@ SectionGraph."pipe-ll-playback-PIPELINE_ID" { lines [ dapm(N_PCM, Low Latency Playback PCM_ID) dapm(N_BUFFER(0), N_PCM) - dapm(N_PGA(Playback Volume), N_BUFFER(0)) - dapm(N_BUFFER(1), N_PGA(Playback Volume)) + dapm(N_PGA(0), N_BUFFER(0)) + dapm(N_BUFFER(1), N_PGA(0)) dapm(N_MIXER(0), N_BUFFER(1)) dapm(N_BUFFER(2), N_MIXER(0)) - dapm(N_PGA(Mixer Volume), N_BUFFER(2)) - dapm(N_BUFFER(3), N_PGA(Mixer Volume)) + dapm(N_PGA(1), N_BUFFER(2)) + dapm(N_BUFFER(3), N_PGA(1)) ] } @@ -146,7 +146,7 @@ indir(`define', concat(`PIPELINE_MIXER_', PIPELINE_ID), N_MIXER(0)) # Pipeline Configuration. # -W_PIPELINE(N_PGA(Mixer Volume), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) +W_PIPELINE(N_PGA(1), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) # # PCM Configuration diff --git a/topology/sof/pipe-passthrough-vol-playback.m4 b/topology/sof/pipe-passthrough-vol-playback.m4 index ae2b56978702..bf131c369518 100644 --- a/topology/sof/pipe-passthrough-vol-playback.m4 +++ b/topology/sof/pipe-passthrough-vol-playback.m4 @@ -7,6 +7,36 @@ # Include topology builder include(`local.m4') +# +# Controls +# +SectionControlMixer.STR(Master Playback Volume) { + + # control belongs to this index group + index STR(PIPELINE_ID) + + # Channel register and shift for Front Left/Right + channel."FL" { + reg "1" + shift "0" + } + channel."FR" { + reg "1" + shift "1" + } + + # control uses bespoke driver get/put/info ID 0 + ops."ctl" { + info "volsw" + get "256" + put "256" + } + + # TLV 32 steps from -90dB to +6dB for 3dB + max "32" + invert "false" + tlv "vtlv_m90s3" +} # # Components and Buffers @@ -17,7 +47,7 @@ include(`local.m4') W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Volume" has 2 source and 2 sink periods -W_PGA(Volume, PIPELINE_FORMAT, 2, 2, 2) +W_PGA(0, Master Playback Volume, PIPELINE_FORMAT, 2, 2, 2) # Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, @@ -48,8 +78,8 @@ SectionGraph."pipe-pass-vol-playback-PIPELINE_ID" { lines [ dapm(N_PCM, Passthrough Playback PCM_ID) dapm(N_BUFFER(0), N_PCM) - dapm(N_PGA(Volume), N_BUFFER(0)) - dapm(N_BUFFER(1), N_PGA(Volume)) + dapm(N_PGA(0), N_BUFFER(0)) + dapm(N_BUFFER(1), N_PGA(0)) dapm(N_DAI_OUT, N_BUFFER(1)) ] } diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index fd6db049f946..0ce6faacbe8a 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -70,7 +70,7 @@ SectionData."media_src_conf" { W_PCM_PLAYBACK(Media Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Playback Volume" has 2 sink period and 2 source periods for host ping-pong -W_PGA(Playback Volume, PIPELINE_FORMAT, 2, 2, 2) +W_PGA(0, PCM PCM_ID Playback Volume, PIPELINE_FORMAT, 2, 2, 2) # "SRC 0" has 2 sink and source periods. W_SRC(0, media_src_conf, PIPELINE_FORMAT, 2, 2, 2) @@ -95,8 +95,8 @@ SectionGraph."pipe-media-PIPELINE_ID" { lines [ dapm(N_PCM, Media Playback PCM_ID) dapm(N_BUFFER(0), N_PCM) - dapm(N_PGA(Playback Volume), N_BUFFER(0)) - dapm(N_BUFFER(1), N_PGA(Playback Volume)) + dapm(N_PGA(0), N_BUFFER(0)) + dapm(N_BUFFER(1), N_PGA(0)) dapm(N_SRC(0), N_BUFFER(1)) dapm(N_BUFFER(2), N_SRC(0)) ] diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index 386ddd344ddb..0cfb73cc82c7 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -50,7 +50,7 @@ SectionControlMixer.STR(Tone Volume PIPELINE_ID) { W_TONE(0, PIPELINE_FORMAT, 2, 0, 0) # "Tone Volume" has 2 sink period and 2 source periods -W_PGA(Tone Volume, PIPELINE_FORMAT, 2, 2, 0) +W_PGA(0, Tone Volume PIPELINE_ID, PIPELINE_FORMAT, 2, 2, 0) # Low Latency Buffers W_BUFFER(0,COMP_BUFFER_SIZE(2, @@ -70,8 +70,8 @@ SectionGraph."pipe-tone-PIPELINE_ID" { lines [ dapm(N_BUFFER(0), N_TONE(0)) - dapm(N_PGA(Tone Volume), N_BUFFER(0)) - dapm(N_BUFFER(1), N_PGA(Tone Volume)) + dapm(N_PGA(0), N_BUFFER(0)) + dapm(N_BUFFER(1), N_PGA(0)) ] } From 12b19074997a39314195f467cdeb70150631d430 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 3 Sep 2017 22:07:41 +0100 Subject: [PATCH 037/324] topology: src: fix W_SRC widget argument list order Put format and data in correct order. Signed-off-by: Liam Girdwood --- topology/m4/local.m4 | 4 ++-- topology/sof/pipe-pcm-media.m4 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 5da77e27da1a..5ff0a3d674a3 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -17,7 +17,7 @@ define(`W_SRC', ` tuples."word" {' ` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) ` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) ` }' `}' `SectionData."'N_SRC($1)`_data_w" {' @@ -39,7 +39,7 @@ define(`W_SRC', ` data [' ` "'N_SRC($1)`_data_w"' ` "'N_SRC($1)`_data_str"' -` "'$2`"' +` "'$5`"' ` ]' `}') diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 0ce6faacbe8a..4a68eb418ad5 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -73,7 +73,7 @@ W_PCM_PLAYBACK(Media Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) W_PGA(0, PCM PCM_ID Playback Volume, PIPELINE_FORMAT, 2, 2, 2) # "SRC 0" has 2 sink and source periods. -W_SRC(0, media_src_conf, PIPELINE_FORMAT, 2, 2, 2) +W_SRC(0, PIPELINE_FORMAT, 2, 2, media_src_conf, 2) # Media Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, From ea3ff83bdc6594fa2e9f26e3c342b67bc100f44d Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 3 Sep 2017 22:10:30 +0100 Subject: [PATCH 038/324] topology: media: fix media min period size to align with 1ms granularity Make sure media buffers can align min period size on 1ms granularity. Signed-off-by: Liam Girdwood --- topology/sof/pipe-pcm-media.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 4a68eb418ad5..596812719207 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -127,7 +127,7 @@ SectionPCMCapabilities.STR(Media Playback PCM_ID) { channels_max "2" periods_min "2" periods_max "32" - period_size_min "4096" + period_size_min "192" period_size_max "262144" buffer_size_min "8388608" buffer_size_max "8388608" From 6cb0fd2806ddd3b9344cd5bc4c46468148181413 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sun, 3 Sep 2017 22:12:49 +0100 Subject: [PATCH 039/324] topology: src: fix src config data by adding "" SRC config data was missing "". Fixed. Signed-off-by: Liam Girdwood --- topology/sof/pipe-pcm-media.m4 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 596812719207..bde9dd247ca8 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -51,9 +51,7 @@ SectionVendorTuples."media_src_tokens" { tokens "sof_src_tokens" tuples."word" { - SOF_TKN_SRC_RATE_IN 16000 - SOF_TKN_SRC_RATE_IN 44100 - SOF_TKN_SRC_RATE_OUT 48000 + SOF_TKN_SRC_RATE_OUT "48000" } } From f00e8884dd0bde86a59f56972f1d2b9903c2e7ed Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 4 Sep 2017 16:35:01 +0100 Subject: [PATCH 040/324] rmbox: check for non printable chars in trace. Non printable means trace is a value. Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 1f81e06923f6..3ef6fb4aed27 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -19,6 +19,7 @@ #include #include #include +#include // TODO: include all this stuff @@ -135,6 +136,12 @@ static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp, float c return; } + /* check for printable values - otherwise it's a value */ + if (!isprint((char)(val >> 16)) || !isprint((char)(val >> 8)) || !isprint((char)val)) { + printf("value 0x%8.8x\n", (uint32_t)val); + return; + } + class = val & 0xff000000; if (class == TRACE_CLASS_IRQ) trace = "irq"; From 5f53e40c52da9885297e2cb9e1d78cbc6c5d99c6 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 4 Sep 2017 21:03:44 +0100 Subject: [PATCH 041/324] topology: byt-rt5640: Fix stream name for BE DAI link Signed-off-by: Liam Girdwood --- topology/reef-byt-rt5640.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 0629d43d8f57..9855f1a67ff5 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -66,11 +66,11 @@ SectionGraph."pipe-byt-rt5640" { # playback DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, Audio, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present From 08ccf3380bc4b6974f20124859e48f56ab463f80 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 7 Sep 2017 14:25:18 +0100 Subject: [PATCH 042/324] topology: SRC: Use 4ms for topology scheduling and increase buffers SRC should be scheduled on at least 4ms tick. Increase buffers to deal with 2 times output rate. Signed-off-by: Liam Girdwood --- topology/reef-bxt-nocodec.m4 | 10 +++++----- topology/reef-byt-nocodec.m4 | 4 ++-- topology/reef-byt-rt5640.m4 | 4 ++-- topology/reef-byt-rt5651.m4 | 4 ++-- topology/reef-cht-nocodec.m4 | 8 ++++---- topology/reef-hsw-rt5640.m4 | 10 +++++----- topology/sof/pipe-pcm-media.m4 | 10 ++++++---- 7 files changed, 26 insertions(+), 24 deletions(-) diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index 2028323e3f0d..486d4eacaf17 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -40,14 +40,14 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) # PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) +# Schedule 192 frames per 4000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 4) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index 1c3cf5f34cf5..938666d9f607 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -38,9 +38,9 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 9855f1a67ff5..05743e21911a 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -38,9 +38,9 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index 1b492b72de5a..cb9dcc2e4438 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -38,9 +38,9 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index ead0f7507442..52e8d5099c3e 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -37,10 +37,10 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) +# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index e4d93929b7f9..af1863338bf8 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -40,14 +40,14 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) # PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) +# Schedule 192 frames per 4000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 4) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index bde9dd247ca8..97958cd36ef0 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -73,12 +73,14 @@ W_PGA(0, PCM PCM_ID Playback Volume, PIPELINE_FORMAT, 2, 2, 2) # "SRC 0" has 2 sink and source periods. W_SRC(0, PIPELINE_FORMAT, 2, 2, media_src_conf, 2) -# Media Buffers -W_BUFFER(0, COMP_BUFFER_SIZE(2, +# Media Source Buffers to SRC, make them big enough to deal with 2 * rate. +W_BUFFER(0, COMP_BUFFER_SIZE(4, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) -W_BUFFER(1,COMP_BUFFER_SIZE(2, +W_BUFFER(1,COMP_BUFFER_SIZE(4, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) -W_BUFFER(2, COMP_BUFFER_SIZE(2, + +# Buffer B2 is on fixed rate sink side of SRC. Set it 1.5 * rate. +W_BUFFER(2, COMP_BUFFER_SIZE(3, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) # From 19606eb2fc2acd22e291f9f05e19f4ff321a2c7e Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 8 Sep 2017 12:51:25 +0100 Subject: [PATCH 043/324] topology: Add support for 32bit data to playback and capture PCMs Add S32_LE data support to the PCMs Signed-off-by: Liam Girdwood --- topology/sof/pipe-low-latency-capture.m4 | 2 +- topology/sof/pipe-low-latency-playback.m4 | 2 +- topology/sof/pipe-passthrough-playback.m4 | 2 +- topology/sof/pipe-passthrough-vol-playback.m4 | 2 +- topology/sof/pipe-pcm-media.m4 | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 111aa86f0cb7..d041dca2cb68 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -89,7 +89,7 @@ W_PIPELINE(N_PGA(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHE SectionPCMCapabilities.STR(Low Latency Capture PCM_ID) { - formats "S24_LE,S16_LE" + formats "S32_LE,S24_LE,S16_LE" rate_min "48000" rate_max "48000" channels_min "2" diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index a860c829a84b..3db55cf506d1 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -155,7 +155,7 @@ W_PIPELINE(N_PGA(1), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHE # PCM capabilities supported by FW SectionPCMCapabilities.STR(Low Latency Playback PCM_ID) { - formats "S24_LE,S16_LE" + formats "S32_LE,S24_LE,S16_LE" rate_min "48000" rate_max "48000" channels_min "2" diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index a6ecb3255516..732e17311c80 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -52,7 +52,7 @@ SectionGraph."pipe-pass-playback-PIPELINE_ID" { SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { - formats "S24_LE,S16_LE" + formats "S32_LE,S24_LE,S16_LE" rate_min "48000" rate_max "48000" channels_min "2" diff --git a/topology/sof/pipe-passthrough-vol-playback.m4 b/topology/sof/pipe-passthrough-vol-playback.m4 index bf131c369518..be3f9ec28216 100644 --- a/topology/sof/pipe-passthrough-vol-playback.m4 +++ b/topology/sof/pipe-passthrough-vol-playback.m4 @@ -91,7 +91,7 @@ SectionGraph."pipe-pass-vol-playback-PIPELINE_ID" { SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { - formats "S24_LE,S16_LE" + formats "S32_LE,S24_LE,S16_LE" rate_min "48000" rate_max "48000" channels_min "2" diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 97958cd36ef0..b766e23ea122 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -120,7 +120,7 @@ W_PIPELINE(N_SRC(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHE # PCM capabilities supported by FW SectionPCMCapabilities.STR(Media Playback PCM_ID) { - formats "S24_LE,S16_LE" + formats "S32_LE,S24_LE,S16_LE" rate_min "8000" rate_max "192000" channels_min "2" From d627f9e1351bd0245e26d8e278ad0aa922612965 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 11 Sep 2017 14:53:10 +0100 Subject: [PATCH 044/324] move test files --- ...rough-24bit-48k-ssp2.m4 => test-passthrough-24bit-48k-ssp2.m4} | 0 ...l-24bit-48k-ssp2.m4 => test-passthrough-24bit-48k-vol-ssp2.m4} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename topology/{test/passthrough-24bit-48k-ssp2.m4 => test-passthrough-24bit-48k-ssp2.m4} (100%) rename topology/{test/passthrough-vol-24bit-48k-ssp2.m4 => test-passthrough-24bit-48k-vol-ssp2.m4} (100%) diff --git a/topology/test/passthrough-24bit-48k-ssp2.m4 b/topology/test-passthrough-24bit-48k-ssp2.m4 similarity index 100% rename from topology/test/passthrough-24bit-48k-ssp2.m4 rename to topology/test-passthrough-24bit-48k-ssp2.m4 diff --git a/topology/test/passthrough-vol-24bit-48k-ssp2.m4 b/topology/test-passthrough-24bit-48k-vol-ssp2.m4 similarity index 100% rename from topology/test/passthrough-vol-24bit-48k-ssp2.m4 rename to topology/test-passthrough-24bit-48k-vol-ssp2.m4 From 2b4165200738be4e1af7119ca88fcede0d71be74 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 11 Sep 2017 15:58:25 +0100 Subject: [PATCH 045/324] topology: Add support for DAI pipeline ID config Allow topology to configure the pipeline ID of any DAI specific pipeline instead of using 0. Signed-off-by: Liam Girdwood --- topology/m4/build.m4 | 26 +++++++++++++------------- topology/reef-apl-nocodec.m4 | 4 ++-- topology/reef-bdw-rt286.m4 | 4 ++-- topology/reef-bdw-rt5640.m4 | 4 ++-- topology/reef-bxt-nocodec.m4 | 4 ++-- topology/reef-byt-nocodec.m4 | 4 ++-- topology/reef-byt-rt5640.m4 | 4 ++-- topology/reef-byt-rt5651.m4 | 4 ++-- topology/reef-cht-nocodec.m4 | 4 ++-- topology/reef-hsw-rt5640.m4 | 4 ++-- 10 files changed, 31 insertions(+), 31 deletions(-) diff --git a/topology/m4/build.m4 b/topology/m4/build.m4 index 7d248dad1853..273e6b4d674e 100644 --- a/topology/m4/build.m4 +++ b/topology/m4/build.m4 @@ -81,7 +81,7 @@ define(`PIPELINE_ADD', `include($1)' ) -dnl DAI_ADD(pipeline, dai type, dai_index, stream_name, buffer, periods, format, frames, deadline, priority, core) +dnl DAI_ADD(pipeline, pipeline id, dai type, dai_index, stream_name, buffer, periods, format, frames, deadline, priority, core) define(`DAI_ADD', `undefine(`PIPELINE_ID')' `undefine(`DAI_TYPE')' @@ -94,18 +94,18 @@ define(`DAI_ADD', `undefine(`SCHEDULE_DEADLINE')' `undefine(`SCHEDULE_PRIORITY')' `undefine(`SCHEDULE_CORE')' -`define(`PIPELINE_ID', 0)' -`define(`DAI_TYPE', STR($2))' -`define(`DAI_INDEX', STR($3))' -`define(`DAI_SNAME', $4)' -`define(`DAI_BUF', $5)' -`define(`DAI_NAME', $2$3)' -`define(`DAI_PERIODS', $6)' -`define(`DAI_FORMAT', $7)' -`define(`SCHEDULE_FRAMES', $8)' -`define(`SCHEDULE_DEADLINE', $9)' -`define(`SCHEDULE_PRIORITY', $10)' -`define(`SCHEDULE_CORE', $11)' +`define(`PIPELINE_ID', $2)' +`define(`DAI_TYPE', STR($3))' +`define(`DAI_INDEX', STR($4))' +`define(`DAI_SNAME', $5)' +`define(`DAI_BUF', $6)' +`define(`DAI_NAME', $3$4)' +`define(`DAI_PERIODS', $7)' +`define(`DAI_FORMAT', $8)' +`define(`SCHEDULE_FRAMES', $9)' +`define(`SCHEDULE_DEADLINE', $10)' +`define(`SCHEDULE_PRIORITY', $11)' +`define(`SCHEDULE_CORE', $12)' `include($1)' ) diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index ef80fd341aef..068c06b8725d 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -75,11 +75,11 @@ SectionGraph."pipe-apl-nocodec" { # playback DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index e3f8dd9ff019..1a6042a7fd24 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -75,11 +75,11 @@ SectionGraph."pipe-bdw-rt286" { # playback DAI is SSP0 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP0 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index 434460548525..245310391e7f 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -75,11 +75,11 @@ SectionGraph."pipe-bdw-rt5640" { # playback DAI is SSP0 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP0 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index 486d4eacaf17..e86b30f142f4 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -75,11 +75,11 @@ SectionGraph."pipe-bxt-nocodec" { # playback DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index 938666d9f607..27e746875ace 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -66,11 +66,11 @@ SectionGraph."pipe-byt-nocodec" { # playback DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 05743e21911a..8d70e526abc9 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -66,11 +66,11 @@ SectionGraph."pipe-byt-rt5640" { # playback DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, Audio, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, Audio, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index cb9dcc2e4438..b7591379b324 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -66,11 +66,11 @@ SectionGraph."pipe-byt-rt5651" { # playback DAI is SSP2 using "Audio" DAPM stream name and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, Audio, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, Audio, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using "Audio" DAPM stream name and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index 52e8d5099c3e..5f2be4c57a7e 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -66,11 +66,11 @@ SectionGraph."pipe-cht-nocodec" { # playback DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index af1863338bf8..f64d36be1add 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -75,11 +75,11 @@ SectionGraph."pipe-hsw-rt5640" { # playback DAI is SSP0 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP0 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present From 30d3d92928e451d0170b7492de831da1830c1436 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 11 Sep 2017 16:03:57 +0100 Subject: [PATCH 046/324] topology: pipeline: Add flag to selcect either timer or IRQ scheduling Add a flag to specify whether the pipeline processing work can be scheduled via a timer or an IRQ source. IRQ scheduling will primarily be used by pipelines that include a DAI. Signed-off-by: Liam Girdwood --- topology/m4/local.m4 | 5 +++-- topology/sof/pipe-dai-capture.m4 | 2 +- topology/sof/pipe-dai-playback.m4 | 2 +- topology/sof/pipe-low-latency-capture.m4 | 2 +- topology/sof/pipe-low-latency-playback.m4 | 2 +- topology/sof/pipe-passthrough-playback.m4 | 2 +- topology/sof/pipe-passthrough-vol-playback.m4 | 2 +- topology/sof/pipe-pcm-media.m4 | 2 +- topology/sof/pipe-tone.m4 | 2 +- topology/sof/tokens.m4 | 1 + 10 files changed, 12 insertions(+), 10 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 5ff0a3d674a3..50c6b5d142f3 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -370,7 +370,7 @@ define(`NPIPELINE_BUFFER', `BUF'$1`.'$2) dnl Pipeline name) define(`N_PIPELINE', `PIPELINE.'PIPELINE_ID`.'$1) -dnl W_PIPELINE(stream, deadline, priority, frames, core, platform) +dnl W_PIPELINE(stream, deadline, priority, frames, core, timer, platform) define(`W_PIPELINE', `SectionVendorTuples."'N_PIPELINE($1)`_tuples" {' ` tokens "sof_sched_tokens"' @@ -379,6 +379,7 @@ define(`W_PIPELINE', ` SOF_TKN_SCHED_PRIORITY' STR($3) ` SOF_TKN_SCHED_CORE' STR($5) ` SOF_TKN_SCHED_FRAMES' STR($4) +` SOF_TKN_SCHED_TIMER' STR($6) ` }' `}' `SectionData."'N_PIPELINE($1)`_data" {' @@ -391,7 +392,7 @@ define(`W_PIPELINE', ` stream_name "'$1`"' ` data [' ` "'N_PIPELINE($1)`_data"' -` "'$6`"' +` "'$7`"' ` ]' `}') diff --git a/topology/sof/pipe-dai-capture.m4 b/topology/sof/pipe-dai-capture.m4 index cc44c0e3c3c9..45c6ff404122 100644 --- a/topology/sof/pipe-dai-capture.m4 +++ b/topology/sof/pipe-dai-capture.m4 @@ -11,7 +11,7 @@ W_DAI_IN(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 2, 0, 0, dai0c_plat_conf) # # DAI pipeline - always use 0 for DAIs # -W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_dai_schedule_plat) +W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, 0, pipe_dai_schedule_plat) # # Graph connections to pipelines diff --git a/topology/sof/pipe-dai-playback.m4 b/topology/sof/pipe-dai-playback.m4 index f0967c27bd79..f99aac0d153a 100644 --- a/topology/sof/pipe-dai-playback.m4 +++ b/topology/sof/pipe-dai-playback.m4 @@ -11,7 +11,7 @@ W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) # # DAI pipeline - always use 0 for DAIs # -W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_dai_schedule_plat) +W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, 0, pipe_dai_schedule_plat) # # Graph connections to pipelines diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index d041dca2cb68..22df648d5b9d 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -81,7 +81,7 @@ indir(`define', concat(`PIPELINE_SINK_', PIPELINE_ID), N_BUFFER(0)) # Pipeline Configuration. # -W_PIPELINE(N_PGA(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) +#W_PIPELINE(N_PGA(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) # # PCM Configuration diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index 3db55cf506d1..c29165e85b06 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -146,7 +146,7 @@ indir(`define', concat(`PIPELINE_MIXER_', PIPELINE_ID), N_MIXER(0)) # Pipeline Configuration. # -W_PIPELINE(N_PGA(1), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) +#W_PIPELINE(N_PGA(1), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) # # PCM Configuration diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index 732e17311c80..46ed9493c06c 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -28,7 +28,7 @@ W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) # # DAI pipeline - always use 0 for DAIs # -W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_dai_schedule_plat) +W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, 0, pipe_dai_schedule_plat) # # Pipeline Graph diff --git a/topology/sof/pipe-passthrough-vol-playback.m4 b/topology/sof/pipe-passthrough-vol-playback.m4 index be3f9ec28216..ffc9000dea6d 100644 --- a/topology/sof/pipe-passthrough-vol-playback.m4 +++ b/topology/sof/pipe-passthrough-vol-playback.m4 @@ -65,7 +65,7 @@ W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, # DAI pipeline - always use 0 for DAIs # W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, - SCHEDULE_CORE, pipe_dai_schedule_plat) + SCHEDULE_CORE, 0, pipe_dai_schedule_plat) # # Pipeline Graph diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index b766e23ea122..b04b353e066d 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -111,7 +111,7 @@ indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(2)) # Pipeline Configuration. # -W_PIPELINE(N_SRC(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_media_schedule_plat) +W_PIPELINE(N_SRC(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, 1, pipe_media_schedule_plat) # # PCM Configuration diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index 0cfb73cc82c7..ccead1068ea3 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -84,4 +84,4 @@ indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(1)) # Pipeline Configuration. # -W_PIPELINE(N_TONE(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_tone_schedule_plat) +W_PIPELINE(N_TONE(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, 1, pipe_tone_schedule_plat) diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index 530220a35dfd..704effc5f70c 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -28,6 +28,7 @@ SectionVendorTokens."sof_sched_tokens" { SOF_TKN_SCHED_MIPS "202" SOF_TKN_SCHED_CORE "203" SOF_TKN_SCHED_FRAMES "204" + SOF_TKN_SCHED_TIMER "205" } SectionVendorTokens."sof_volume_tokens" { From 530acaf46a604cd650f6829c0c566cccf9ebbf16 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 11 Sep 2017 16:12:10 +0100 Subject: [PATCH 047/324] topology: Add test SRC passthrough pipeline Add a testing SRC passthrough pipeline. Signed-off-by: Liam Girdwood --- topology/Makefile.am | 5 +- .../test-passthrough-24bit-48k-src-ssp2.m4 | 55 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 topology/test-passthrough-24bit-48k-src-ssp2.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 98661f7ce536..09618c8acb30 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -22,7 +22,10 @@ MACHINES = \ reef-bdw-rt5640.tplg \ reef-byt-rt5640.tplg \ reef-byt-rt5651.tplg \ - reef-hsw-rt5640.tplg + reef-hsw-rt5640.tplg \ + test-passthrough-24bit-48k-ssp2.tplg \ + test-passthrough-24bit-48k-vol-ssp2.tplg \ + test-passthrough-24bit-48k-src-ssp2.tplg # Uncomment the following line if you want to debug conf files .PRECIOUS: %.conf diff --git a/topology/test-passthrough-24bit-48k-src-ssp2.m4 b/topology/test-passthrough-24bit-48k-src-ssp2.m4 new file mode 100644 index 000000000000..5f88d7ddd86a --- /dev/null +++ b/topology/test-passthrough-24bit-48k-src-ssp2.m4 @@ -0,0 +1,55 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# + +# DAI Link Name +define(`TEST_DAI_LINK_NAME', `Baytrail Audio') + +# DAI Link Stream Name +define(`TEST_DAI_LINK_STREAM_NAME', `Audio') + + +# +# Define the pipeline +# +# PCM0 ---> volume ---> SSP2 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-src-playback.m4, + 1, 0, 2, s24le, + 48, 1000, 0, 0, 0, 1, + SSP, 2, TEST_DAI_LINK_STREAM_NAME, s24le, 2) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# 24bit I2S using 25bit sample conatiner on SSP2 +# +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, TEST_DAI_LINK_STREAM_NAME, I2S, 24, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 25, 3, 3)) From 81b02a796f40cd916750017146ddc1beb6cd6bf9 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 11 Sep 2017 16:38:14 +0100 Subject: [PATCH 048/324] topology: SRC testing passthrough pipeline. The testing pipline for 24 bit SRC 48kHz output. Signed-off-by: Liam Girdwood --- topology/sof/pipe-passthrough-src-playback.m4 | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 topology/sof/pipe-passthrough-src-playback.m4 diff --git a/topology/sof/pipe-passthrough-src-playback.m4 b/topology/sof/pipe-passthrough-src-playback.m4 new file mode 100644 index 000000000000..0ffc2a4b75e9 --- /dev/null +++ b/topology/sof/pipe-passthrough-src-playback.m4 @@ -0,0 +1,109 @@ +# Low Latency Passthrough with volume Pipeline and PCM +# +# Pipeline Endpoints for connection are :- +# +# host PCM_P --> SRC --> sink DAI0 + +# Include topology builder +include(`local.m4') + + +# +# Components and Buffers +# + +# Host "Passthrough Playback" PCM uses pipeline DMAC and channel +# with 4 sink and 0 source periods +W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) + +# +# SRC Configuration +# + +SectionVendorTuples."media_src_tokens" { + tokens "sof_src_tokens" + + tuples."word" { + SOF_TKN_SRC_RATE_OUT "48000" + } +} + +SectionData."media_src_conf" { + tuples "media_src_tokens" +} + +# "SRC" has 4 source and 4 sink periods +W_SRC(0, PIPELINE_FORMAT, 4, 4, media_src_conf, 2) + +# Playback Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(4, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) +W_BUFFER(1, COMP_BUFFER_SIZE(4, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + +# +# DAI definitions +# +W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, + DAI_PERIODS, dai0p_plat_conf) + +# +# DAI pipeline +# +W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, + SCHEDULE_CORE, 0, pipe_dai_schedule_plat) + +# +# Pipeline Graph +# +# host PCM_P --> B0 --> SRC 0 --> B1 --> sink DAI0 + +SectionGraph."pipe-pass-src-playback-PIPELINE_ID" { + index STR(PIPELINE_ID) + + lines [ + dapm(N_PCM, Passthrough Playback PCM_ID) + dapm(N_BUFFER(0), N_PCM) + dapm(N_SRC(0), N_BUFFER(0)) + dapm(N_BUFFER(1), N_SRC(0)) + dapm(N_DAI_OUT, N_BUFFER(1)) + ] +} + + +# +# PCM Configuration +# + +SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { + + formats "S32_LE,S24_LE,S16_LE" + rate_min "8000" + rate_max "96000" + channels_min "2" + channels_max "4" + periods_min "2" + periods_max "16" + period_size_min "192" + period_size_max "16384" + buffer_size_min "65536" + buffer_size_max "65536" +} + +# PCM Passthrough Playback +SectionPCM.STR(PCM PCM_ID) { + + index STR(PIPELINE_ID) + + # used for binding to the PCM + id STR(PCM_ID) + + dai.STR(Passthrough Playback PCM_ID) { + id STR(PCM_ID) + } + + pcm."playback" { + + capabilities STR(Passthrough Playback PCM_ID) + } +} From 924ac072334ef5cba0cc96e89acaebafe8ce98fe Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 12 Sep 2017 19:07:48 -0500 Subject: [PATCH 049/324] topology: build: fix PIPELINE/DAI_ADD comments Add a couple of missing parameters in comments, align them logically to help the rest of us figure out what parameters mean. Signed-off-by: Pierre-Louis Bossart --- topology/m4/build.m4 | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/topology/m4/build.m4 b/topology/m4/build.m4 index 273e6b4d674e..d6801deda78c 100644 --- a/topology/m4/build.m4 +++ b/topology/m4/build.m4 @@ -1,6 +1,8 @@ divert(-1) -dnl PIPELINE_PCM_ADD(pipeline, id, pcm, max channels, format, frames, deadline, priority, core) +dnl PIPELINE_PCM_ADD(pipeline, +dnl pipe id, pcm, max channels, format, +dnl frames, deadline, priority, core, dmac, dmac_chan) define(`PIPELINE_PCM_ADD', `undefine(`PCM_ID')' `undefine(`PIPELINE_ID')' @@ -25,8 +27,10 @@ define(`PIPELINE_PCM_ADD', `include($1)' ) -dnl PIPELINE_PCM_DAI_ADD(pipeline, id, pcm, max channels, format, frames, -dnl deadline, priority, core, dai type, dai_index, stream_name, dai format, periods) +dnl PIPELINE_PCM_DAI_ADD(pipeline, +dnl pipe id, pcm, max channels, format, +dnl frames, deadline, priority, core, dmac, dmac_chan, +dnl dai type, dai_index, stream_name, dai format, periods) define(`PIPELINE_PCM_DAI_ADD', `undefine(`PCM_ID')' `undefine(`PIPELINE_ID')' @@ -62,7 +66,9 @@ define(`PIPELINE_PCM_DAI_ADD', `include($1)' ) -dnl PIPELINE_ADD(pipeline, id, max channels, format, frames, deadline, priority, core) +dnl PIPELINE_ADD(pipeline, +dnl pipe id, max channels, format, +dnl frames, deadline, priority, core) define(`PIPELINE_ADD', `undefine(`PIPELINE_ID')' `undefine(`PIPELINE_CHANNELS')' @@ -81,7 +87,10 @@ define(`PIPELINE_ADD', `include($1)' ) -dnl DAI_ADD(pipeline, pipeline id, dai type, dai_index, stream_name, buffer, periods, format, frames, deadline, priority, core) +dnl DAI_ADD(pipeline, +dnl pipe id, dai type, dai_index, stream_name, +dnl buffer, periods, format, +dnl frames, deadline, priority, core) define(`DAI_ADD', `undefine(`PIPELINE_ID')' `undefine(`DAI_TYPE')' From 006fe4ef30fcb07eaf280950d1802d9f8f7636ea Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 12 Sep 2017 19:07:49 -0500 Subject: [PATCH 050/324] topology: test: fix passthrough 24bit-48k-ssp2 format was missing, not sure how this ever worked. Signed-off-by: Pierre-Louis Bossart --- topology/test-passthrough-24bit-48k-ssp2.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/test-passthrough-24bit-48k-ssp2.m4 b/topology/test-passthrough-24bit-48k-ssp2.m4 index 9b9919d2826e..8ea4748a9a36 100644 --- a/topology/test-passthrough-24bit-48k-ssp2.m4 +++ b/topology/test-passthrough-24bit-48k-ssp2.m4 @@ -38,7 +38,7 @@ define(`TEST_DAI_LINK_STREAM_NAME', `Audio') PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, 1, 0, 2, s24le, 48, 1000, 0, 0, 0, 1, - SSP, 2, TEST_DAI_LINK_STREAM_NAME, 2) + SSP, 2, TEST_DAI_LINK_STREAM_NAME, s24le, 2) # # BE configurations - overrides config in ACPI if present From 086c6348175ca59d38aa19abe654be43627f8fad Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 12 Sep 2017 19:07:50 -0500 Subject: [PATCH 051/324] topology: indent reef-*.m4 files, fix typos Align parameters on different lines to allow for easier visual comparison and direct mapping with comments in build.m4 Also fix typo in comments s/priorty/priority/g No functional change Signed-off-by: Pierre-Louis Bossart --- topology/reef-apl-nocodec.m4 | 34 +++++++++++++++++++++++++--------- topology/reef-bdw-rt286.m4 | 34 +++++++++++++++++++++++++--------- topology/reef-bdw-rt5640.m4 | 34 +++++++++++++++++++++++++--------- topology/reef-bxt-nocodec.m4 | 34 +++++++++++++++++++++++++--------- topology/reef-byt-nocodec.m4 | 30 ++++++++++++++++++++++-------- topology/reef-byt-rt5640.m4 | 30 ++++++++++++++++++++++-------- topology/reef-byt-rt5651.m4 | 30 ++++++++++++++++++++++-------- topology/reef-cht-nocodec.m4 | 30 ++++++++++++++++++++++-------- topology/reef-hsw-rt5640.m4 | 34 +++++++++++++++++++++++++--------- 9 files changed, 213 insertions(+), 77 deletions(-) diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index 068c06b8725d..f87a4e90a7eb 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -32,26 +32,36 @@ include(`dsps/bxt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) # Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 2, 2, s32le, + 96, 2000, 1, 0, 0, 3) # PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 4, 3, 2, s32le, + 96, 2000, 1, 0, 0, 4) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-apl-nocodec" { @@ -74,12 +84,18 @@ SectionGraph."pipe-apl-nocodec" { # # playback DAI is SSP2 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 2, I2S, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, SSP, 2, I2S, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index 1a6042a7fd24..eae20652b781 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -32,26 +32,36 @@ include(`dsps/bdw.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) # Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 2, 2, s32le, + 96, 2000, 1, 0, 0, 3) # PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 4, 3, 2, s32le, + 96, 2000, 1, 0, 0, 4) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-bdw-rt286" { @@ -74,12 +84,18 @@ SectionGraph."pipe-bdw-rt286" { # # playback DAI is SSP0 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 0, I2S, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) # capture DAI is SSP0 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, SSP, 0, I2S, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index 245310391e7f..60feb82c171d 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -32,26 +32,36 @@ include(`dsps/bdw.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) # Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 96, 2000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 2, 2, s32le, + 96, 2000, 1, 0, 0, 3) # PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 4, 3, 2, s32le, 96, 2000, 1, 0, 0, 4) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 4, 3, 2, s32le, + 96, 2000, 1, 0, 0, 4) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-bdw-rt5640" { @@ -74,12 +84,18 @@ SectionGraph."pipe-bdw-rt5640" { # # playback DAI is SSP0 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 0, I2S, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) # capture DAI is SSP0 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, SSP, 0, I2S, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index e86b30f142f4..744e9b1838f7 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -32,26 +32,36 @@ include(`dsps/bxt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) # Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 2, 2, s32le, + 192, 4000, 1, 0, 0, 3) # PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 4) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 2, 2, s32le, + 192, 4000, 1, 0, 0, 4) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-bxt-nocodec" { @@ -74,12 +84,18 @@ SectionGraph."pipe-bxt-nocodec" { # # playback DAI is SSP2 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 2, I2S, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, SSP, 2, I2S, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index 27e746875ace..05373f9278b5 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -30,21 +30,29 @@ include(`dsps/byt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) # Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 2, 2, s32le, + 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-byt-nocodec" { @@ -65,12 +73,18 @@ SectionGraph."pipe-byt-nocodec" { # # playback DAI is SSP2 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 2, I2S, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, SSP, 2, I2S, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 8d70e526abc9..911b4d1532da 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -30,21 +30,29 @@ include(`dsps/byt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) # Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 2, 2, s32le, + 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-byt-rt5640" { @@ -65,12 +73,18 @@ SectionGraph."pipe-byt-rt5640" { # # playback DAI is SSP2 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, Audio, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 2, Audio, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, SSP, 2, Audio, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index b7591379b324..c6f20a4eff59 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -30,21 +30,29 @@ include(`dsps/byt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) # Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 2, 2, s32le, + 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-byt-rt5651" { @@ -65,12 +73,18 @@ SectionGraph."pipe-byt-rt5651" { # # playback DAI is SSP2 using "Audio" DAPM stream name and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, Audio, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 2, Audio, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) # capture DAI is SSP2 using "Audio" DAPM stream name and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, SSP, 2, Audio, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index 5f2be4c57a7e..43e0e6e540ca 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -30,21 +30,29 @@ include(`dsps/cht.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) # Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 2, 2, s32le, + 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-cht-nocodec" { @@ -65,12 +73,18 @@ SectionGraph."pipe-cht-nocodec" { # # playback DAI is SSP2 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 2, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 2, I2S, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) # capture DAI is SSP2 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, SSP, 2, I2S, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index f64d36be1add..3d261490390c 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -32,26 +32,36 @@ include(`dsps/hsw.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) # Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 1, 2, s32le, 48, 1000, 0, 0, 0, 2) +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0, 0, 2) # PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 3) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 2, 2, s32le, + 192, 4000, 1, 0, 0, 3) # PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 2, 2, s32le, 192, 4000, 1, 0, 0, 4) +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 2, 2, s32le, + 192, 4000, 1, 0, 0, 4) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, 5, 2, s32le, 192, 4000, 2, 0) +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) # Connect pipelines together SectionGraph."pipe-hsw-rt5640" { @@ -74,12 +84,18 @@ SectionGraph."pipe-hsw-rt5640" { # # playback DAI is SSP0 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 0, I2S, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 0, I2S, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) # capture DAI is SSP0 using I2S DAPM stream and 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priorty 0 -DAI_ADD(sof/pipe-dai-capture.m4, 1, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, SSP, 0, I2S, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) # # BE configurations - overrides config in ACPI if present From d3ac267d005c69eeca6e8f69da5b61b4cc0ae3e8 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sat, 23 Sep 2017 23:10:00 +0100 Subject: [PATCH 052/324] topology: fix capture pipeline ID for SSP DAI Capture pipeline for SSP DAI should be 2. Signed-off-by: Liam Girdwood --- topology/reef-apl-nocodec.m4 | 2 +- topology/reef-bdw-rt286.m4 | 2 +- topology/reef-bdw-rt5640.m4 | 2 +- topology/reef-bxt-nocodec.m4 | 2 +- topology/reef-byt-nocodec.m4 | 2 +- topology/reef-byt-rt5640.m4 | 2 +- topology/reef-byt-rt5651.m4 | 2 +- topology/reef-cht-nocodec.m4 | 2 +- topology/reef-hsw-rt5640.m4 | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index f87a4e90a7eb..5e497f63bc13 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -93,7 +93,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # capture DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 1, SSP, 2, I2S, + 2, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index eae20652b781..cb11ad6a3ae2 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -93,7 +93,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # capture DAI is SSP0 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 1, SSP, 0, I2S, + 2, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index 60feb82c171d..b3c19c296cb0 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -93,7 +93,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # capture DAI is SSP0 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 1, SSP, 0, I2S, + 2, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index 744e9b1838f7..58bc6f6d5617 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -93,7 +93,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # capture DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 1, SSP, 2, I2S, + 2, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index 05373f9278b5..5f6cd1d90d45 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -82,7 +82,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # capture DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 1, SSP, 2, I2S, + 2, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 911b4d1532da..c5e8b526cf2c 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -82,7 +82,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # capture DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 1, SSP, 2, Audio, + 2, SSP, 2, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index c6f20a4eff59..e335d6672067 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -82,7 +82,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # capture DAI is SSP2 using "Audio" DAPM stream name and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 1, SSP, 2, Audio, + 2, SSP, 2, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index 43e0e6e540ca..ddeb71e6849b 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -82,7 +82,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # capture DAI is SSP2 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 1, SSP, 2, I2S, + 2, SSP, 2, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index 3d261490390c..efd815ba3ad7 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -93,7 +93,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # capture DAI is SSP0 using I2S DAPM stream and 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 1, SSP, 0, I2S, + 2, SSP, 0, I2S, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) From d774609c90924f98c617976a58ded83d7e4e9adb Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 2 Oct 2017 15:28:24 +0100 Subject: [PATCH 053/324] topology: Allows playback and capture pipelines to share same PCM Add support so that different playback and capture pipelines can share the same host PCM device. Modify board configs to use PCM0 for playback and capture. Signed-off-by: Liam Girdwood --- topology/m4/local.m4 | 62 +++++++++++++------ topology/reef-apl-nocodec.m4 | 15 +++-- topology/reef-bdw-rt286.m4 | 15 +++-- topology/reef-bdw-rt5640.m4 | 15 +++-- topology/reef-bxt-nocodec.m4 | 13 ++-- topology/reef-byt-nocodec.m4 | 11 ++-- topology/reef-byt-rt5640.m4 | 11 ++-- topology/reef-byt-rt5651.m4 | 11 ++-- topology/reef-cht-nocodec.m4 | 11 ++-- topology/reef-hsw-rt5640.m4 | 15 +++-- topology/sof/pipe-low-latency-capture.m4 | 28 +-------- topology/sof/pipe-low-latency-playback.m4 | 29 +-------- topology/sof/pipe-passthrough-playback.m4 | 4 +- topology/sof/pipe-passthrough-src-playback.m4 | 4 +- topology/sof/pipe-passthrough-vol-playback.m4 | 4 +- topology/sof/pipe-pcm-media.m4 | 6 +- 16 files changed, 130 insertions(+), 124 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 50c6b5d142f3..e521267b6223 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -67,12 +67,13 @@ define(`W_BUFFER', `}') dnl PCM name) -define(`N_PCM', `PCM'PCM_ID) +define(`N_PCMP', `PCM'PCM_ID`P') +define(`N_PCMC', `PCM'PCM_ID`C') dnl W_PCM_PLAYBACK(stream, dmac, dmac_chan, periods_sink, periods_source, preload) dnl PCM platform configuration define(`W_PCM_PLAYBACK', -`SectionVendorTuples."'N_PCM($1)`_tuples_w_comp" {' +`SectionVendorTuples."'N_PCMP($1)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' ` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) @@ -80,34 +81,34 @@ define(`W_PCM_PLAYBACK', ` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) ` }' `}' -`SectionData."'N_PCM($1)`_data_w_comp" {' -` tuples "'N_PCM($1)`_tuples_w_comp"' +`SectionData."'N_PCMP($1)`_data_w_comp" {' +` tuples "'N_PCMP($1)`_tuples_w_comp"' `}' -`SectionVendorTuples."'N_PCM($1)`_tuples" {' +`SectionVendorTuples."'N_PCMP($1)`_tuples" {' ` tokens "sof_pcm_tokens"' ` tuples."word" {' ` SOF_TKN_PCM_DMAC' STR($2) ` SOF_TKN_PCM_DMAC_CHAN' STR($3) ` }' `}' -`SectionData."'N_PCM($1)`_data" {' -` tuples "'N_PCM($1)`_tuples"' +`SectionData."'N_PCMP($1)`_data" {' +` tuples "'N_PCMP($1)`_tuples"' `}' -`SectionWidget."'N_PCM`" {' +`SectionWidget."'N_PCMP`" {' ` index "'PIPELINE_ID`"' ` type "aif_out"' ` no_pm "true"' ` stream_name "'$1`"' ` data [' -` "'N_PCM($1)`_data"' -` "'N_PCM($1)`_data_w_comp"' +` "'N_PCMP($1)`_data"' +` "'N_PCMP($1)`_data_w_comp"' ` ]' `}') dnl W_PCM_PLAYBACK(stream, dmac, dmac_chan, periods_sink, periods_source, preload) define(`W_PCM_CAPTURE', -`SectionVendorTuples."'N_PCM($1)`_tuples_w_comp" {' +`SectionVendorTuples."'N_PCMC($1)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' ` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) @@ -115,27 +116,27 @@ define(`W_PCM_CAPTURE', ` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) ` }' `}' -`SectionData."'N_PCM($1)`_data_w_comp" {' -` tuples "'N_PCM($1)`_tuples_w_comp"' +`SectionData."'N_PCMC($1)`_data_w_comp" {' +` tuples "'N_PCMC($1)`_tuples_w_comp"' `}' -`SectionVendorTuples."'N_PCM($1)`_tuples" {' +`SectionVendorTuples."'N_PCMC($1)`_tuples" {' ` tokens "sof_pcm_tokens"' ` tuples."word" {' ` SOF_TKN_PCM_DMAC' STR($2) ` SOF_TKN_PCM_DMAC_CHAN' STR($3) ` }' `}' -`SectionData."'N_PCM($1)`_data" {' -` tuples "'N_PCM($1)`_tuples"' +`SectionData."'N_PCMC($1)`_data" {' +` tuples "'N_PCMC($1)`_tuples"' `}' -`SectionWidget."'N_PCM`" {' +`SectionWidget."'N_PCMC`" {' ` index "'PIPELINE_ID`"' ` type "aif_out"' ` no_pm "true"' ` stream_name "'$1`"' ` data [' -` "'N_PCM($1)`_data"' -` "'N_PCM($1)`_data_w_comp"' +` "'N_PCMC($1)`_data"' +` "'N_PCMC($1)`_data_w_comp"' ` ]' `}') @@ -478,5 +479,28 @@ define(`COMP_SAMPLE_SIZE', dnl COMP_BUFFER_SIZE( num_periods, sample_size, channels, fmames) define(`COMP_BUFFER_SIZE', `eval(`$1 * $2 * $3 * $4')') +dnl PCM_DUPLEX_ADD(name, pipeline, pcm_id, dai_id, playback, capture) +define(`PCM_DUPLEX_ADD', +`SectionPCM.STR($1) {' +`' +` index STR($2)' +`' +` # used for binding to the PCM' +` id STR($3)' +`' +` dai.STR($1 $3) {' +` id STR($4)' +` }' +`' +` pcm."capture" {' +`' +` capabilities STR($6)' +` }' +`' +` pcm."playback" {' +`' +` capabilities STR($5)' +` }' +`}') divert(0) dnl diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index 5e497f63bc13..96f28d537632 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -36,25 +36,25 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 1, 2, s32le, + 2, 0, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 2, 2, s32le, + 3, 1, 2, s32le, 96, 2000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# PCM Media Playback pipeline 4 on PCM 2 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 4 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 4, 3, 2, s32le, + 4, 2, 2, s32le, 96, 2000, 1, 0, 0, 4) # Tone Playback pipeline 5 using max 2 channels of s32le. @@ -97,6 +97,9 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + # # BE configurations - overrides config in ACPI if present # diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index cb11ad6a3ae2..512efe939280 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -36,25 +36,25 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 1, 2, s32le, + 2, 0, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 2, 2, s32le, + 3, 1, 2, s32le, 96, 2000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# PCM Media Playback pipeline 4 on PCM 2 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 4 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 4, 3, 2, s32le, + 4, 2, 2, s32le, 96, 2000, 1, 0, 0, 4) # Tone Playback pipeline 5 using max 2 channels of s32le. @@ -97,6 +97,9 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + # # BE configurations - overrides config in ACPI if present # diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index b3c19c296cb0..5e259a6ac623 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -36,25 +36,25 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 1, 2, s32le, + 2, 0, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 2, 2, s32le, + 3, 1, 2, s32le, 96, 2000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# PCM Media Playback pipeline 4 on PCM 2 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 4 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 4, 3, 2, s32le, + 4, 2, 2, s32le, 96, 2000, 1, 0, 0, 4) # Tone Playback pipeline 5 using max 2 channels of s32le. @@ -97,6 +97,9 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + # # BE configurations - overrides config in ACPI if present # diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index 58bc6f6d5617..e3c45c937951 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -36,21 +36,21 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 1, 2, s32le, + 2, 0, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 2, 2, s32le, + 3, 1, 2, s32le, 192, 4000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# PCM Media Playback pipeline 4 on PCM 2 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, @@ -97,6 +97,9 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + # # BE configurations - overrides config in ACPI if present # diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index 5f6cd1d90d45..3db415df2d36 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -34,18 +34,18 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 1, 2, s32le, + 2, 0, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 2, 2, s32le, + 3, 1, 2, s32le, 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. @@ -86,6 +86,9 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + # # BE configurations - overrides config in ACPI if present # diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index c5e8b526cf2c..1e9bb5ffb984 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -34,18 +34,18 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 1, 2, s32le, + 2, 0, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 2, 2, s32le, + 3, 1, 2, s32le, 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. @@ -86,6 +86,9 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + # # BE configurations - overrides config in ACPI if present # diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index e335d6672067..0867f914f639 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -34,18 +34,18 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 1, 2, s32le, + 2, 0, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 2, 2, s32le, + 3, 1, 2, s32le, 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. @@ -86,6 +86,9 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + # # BE configurations - overrides config in ACPI if present # diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index ddeb71e6849b..195ae5c40f62 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -34,18 +34,18 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 1, 2, s32le, + 2, 0, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 2, 2, s32le, + 3, 1, 2, s32le, 192, 4000, 1, 0, 0, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. @@ -86,6 +86,9 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + # # BE configurations - overrides config in ACPI if present # diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index efd815ba3ad7..1b06828971ea 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -36,25 +36,25 @@ PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0, 0, 1) -# Low Latency capture pipeline 2 on PCM 1 using max 2 channels of s32le. +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 1, 2, s32le, + 2, 0, 2, s32le, 48, 1000, 0, 0, 0, 2) -# PCM Media Playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 2, 2, s32le, + 3, 1, 2, s32le, 192, 4000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# PCM Media Playback pipeline 4 on PCM 2 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 2, 2, s32le, + 4, 2, 2, s32le, 192, 4000, 1, 0, 0, 4) # Tone Playback pipeline 5 using max 2 channels of s32le. @@ -97,6 +97,9 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + # # BE configurations - overrides config in ACPI if present # diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 22df648d5b9d..0c989a76c58a 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -65,8 +65,8 @@ SectionGraph."pipe-ll-capture-PIPELINE_ID" { index STR(PIPELINE_ID) lines [ - dapm(Low Latency Capture PCM_ID, N_PCM) - dapm(N_PCM, N_BUFFER(1)) + dapm(Low Latency Capture PCM_ID, N_PCMC) + dapm(N_PCMC, N_BUFFER(1)) dapm(N_BUFFER(1), N_PGA(0)) dapm(N_PGA(0), N_BUFFER(0)) ] @@ -76,12 +76,7 @@ SectionGraph."pipe-ll-capture-PIPELINE_ID" { # Pipeline Source and Sinks # indir(`define', concat(`PIPELINE_SINK_', PIPELINE_ID), N_BUFFER(0)) - -# -# Pipeline Configuration. -# - -#W_PIPELINE(N_PGA(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Low Latency Capture PCM_ID) # # PCM Configuration @@ -102,20 +97,3 @@ SectionPCMCapabilities.STR(Low Latency Capture PCM_ID) { buffer_size_max "65536" } -# PCM Low Latency Capture -SectionPCM.STR(PCM PCM_ID) { - - index STR(PIPELINE_ID) - - # used for binding to the PCM - id STR(PCM_ID) - - dai.STR(Low Latency Capture PCM_ID) { - id STR(PCM_ID) - } - - pcm."capture" { - - capabilities STR(Low Latency Capture PCM_ID) - } -} diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index c29165e85b06..cd04ccfa7fa5 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -125,8 +125,8 @@ SectionGraph."pipe-ll-playback-PIPELINE_ID" { index STR(PIPELINE_ID) lines [ - dapm(N_PCM, Low Latency Playback PCM_ID) - dapm(N_BUFFER(0), N_PCM) + dapm(N_PCMP, Low Latency Playback PCM_ID) + dapm(N_BUFFER(0), N_PCMP) dapm(N_PGA(0), N_BUFFER(0)) dapm(N_BUFFER(1), N_PGA(0)) dapm(N_MIXER(0), N_BUFFER(1)) @@ -141,12 +141,7 @@ SectionGraph."pipe-ll-playback-PIPELINE_ID" { # indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(3)) indir(`define', concat(`PIPELINE_MIXER_', PIPELINE_ID), N_MIXER(0)) - -# -# Pipeline Configuration. -# - -#W_PIPELINE(N_PGA(1), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, pipe_ll_schedule_plat) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Low Latency Playback PCM_ID) # # PCM Configuration @@ -168,21 +163,3 @@ SectionPCMCapabilities.STR(Low Latency Playback PCM_ID) { buffer_size_max "65536" } -# PCM Low Latency Playback -SectionPCM.STR(PCM PCM_ID) { - - index STR(PIPELINE_ID) - - # used for binding to the PCM - id STR(PCM_ID) - - dai.STR(Low Latency Playback PCM_ID) { - id STR(PCM_ID) - } - - # Playback and Capture Configuration - pcm."playback" { - - capabilities STR(Low Latency Playback PCM_ID) - } -} diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index 46ed9493c06c..4e6e705d1141 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -39,8 +39,8 @@ SectionGraph."pipe-pass-playback-PIPELINE_ID" { index STR(PIPELINE_ID) lines [ - dapm(N_PCM, Passthrough Playback PCM_ID) - dapm(N_BUFFER(0), N_PCM) + dapm(N_PCMP, Passthrough Playback PCM_ID) + dapm(N_BUFFER(0), N_PCMP) dapm(N_DAI_OUT, N_BUFFER(0)) ] } diff --git a/topology/sof/pipe-passthrough-src-playback.m4 b/topology/sof/pipe-passthrough-src-playback.m4 index 0ffc2a4b75e9..3cadaf2d8a18 100644 --- a/topology/sof/pipe-passthrough-src-playback.m4 +++ b/topology/sof/pipe-passthrough-src-playback.m4 @@ -62,8 +62,8 @@ SectionGraph."pipe-pass-src-playback-PIPELINE_ID" { index STR(PIPELINE_ID) lines [ - dapm(N_PCM, Passthrough Playback PCM_ID) - dapm(N_BUFFER(0), N_PCM) + dapm(N_PCMP, Passthrough Playback PCM_ID) + dapm(N_BUFFER(0), N_PCMP) dapm(N_SRC(0), N_BUFFER(0)) dapm(N_BUFFER(1), N_SRC(0)) dapm(N_DAI_OUT, N_BUFFER(1)) diff --git a/topology/sof/pipe-passthrough-vol-playback.m4 b/topology/sof/pipe-passthrough-vol-playback.m4 index ffc9000dea6d..f0e39e8777a2 100644 --- a/topology/sof/pipe-passthrough-vol-playback.m4 +++ b/topology/sof/pipe-passthrough-vol-playback.m4 @@ -76,8 +76,8 @@ SectionGraph."pipe-pass-vol-playback-PIPELINE_ID" { index STR(PIPELINE_ID) lines [ - dapm(N_PCM, Passthrough Playback PCM_ID) - dapm(N_BUFFER(0), N_PCM) + dapm(N_PCMP, Passthrough Playback PCM_ID) + dapm(N_BUFFER(0), N_PCMP) dapm(N_PGA(0), N_BUFFER(0)) dapm(N_BUFFER(1), N_PGA(0)) dapm(N_DAI_OUT, N_BUFFER(1)) diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index b04b353e066d..7bfb35a35774 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -93,8 +93,8 @@ SectionGraph."pipe-media-PIPELINE_ID" { index STR(PIPELINE_ID) lines [ - dapm(N_PCM, Media Playback PCM_ID) - dapm(N_BUFFER(0), N_PCM) + dapm(N_PCMP, Media Playback PCM_ID) + dapm(N_BUFFER(0), N_PCMP) dapm(N_PGA(0), N_BUFFER(0)) dapm(N_BUFFER(1), N_PGA(0)) dapm(N_SRC(0), N_BUFFER(1)) @@ -134,7 +134,7 @@ SectionPCMCapabilities.STR(Media Playback PCM_ID) { } # PCM Low Latency Playback and Capture -SectionPCM.STR(PCM PCM_ID) { +SectionPCM.STR(Media Playback PCM_ID) { index STR(PIPELINE_ID) From 7f98c95c2a1821bf7ccf4cf5250ed217914a8372 Mon Sep 17 00:00:00 2001 From: Yan Wang Date: Thu, 12 Oct 2017 21:17:09 +0800 Subject: [PATCH 054/324] Add option "-t" to process DMA trace event with 64-bit tempstamp. 1. Timestamp is changed to 64-bit width. 2. Trace event is still 32-bit. High 32-bit of 64-bit is ignored. Signed-off-by: Yan Wang --- rmbox/rmbox.c | 64 ++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 3ef6fb4aed27..638158c44886 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -100,23 +100,22 @@ static void usage(char *name) exit(0); } -static float to_usecs(uint32_t time, float clk) +static float to_usecs(uint64_t time, float clk) { /* trace timestamp uses CPU system clock at default 25MHz ticks */ // TODO: support variable clock rates - return (float)time / clk; + return (double)time / clk; } -static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp, float clk) +static void show_trace(uint64_t val, uint64_t addr, uint64_t *timestamp, float clk, uint64_t align) { const char *trace; uint32_t class; - uint32_t delta = val - *timestamp; + uint64_t delta = val - *timestamp; float fdelta = to_usecs(delta, clk); /* timestamp or value ? */ - if ((addr % 8) == 0) { - + if ((addr % align) == 0) { /* buffer wrap ? */ if (val < *timestamp) { printf("----------------------------------------" @@ -129,9 +128,9 @@ static void show_trace(uint32_t val, uint32_t addr, uint32_t *timestamp, float c fdelta = to_usecs(delta, clk); } - printf("trace.io: timestamp 0x%8.8x (%2.2f us) \tdelta 0x%8.8x (%2.2f us)\t", - (uint32_t)val, to_usecs(val, clk), - (uint32_t)delta, fdelta); + printf("trace.io: timestamp 0x%16.16lx (%2.2f us) \tdelta 0x%16.16lx (%2.2f us)\t", + (uint64_t)val, to_usecs(val, clk), + (uint64_t)delta, fdelta); *timestamp = val; return; } @@ -279,11 +278,12 @@ int main(int argc, char *argv[]) int opt, count; const char * out_file = NULL, *in_file = "/sys/kernel/debug/sof/mbox"; FILE *in_fd = NULL, *out_fd = NULL; - char c, tmp[4] = {0}; - uint32_t addr = 0, val, timestamp = 0; + char c, tmp[8] = {0}; + uint64_t addr = 0, val, timestamp = 0, align = 4, i; float clk = 19.2f; + uint32_t is_dma_trace = 0; - while ((opt = getopt(argc, argv, "ho:i:s:m:c:")) != -1) { + while ((opt = getopt(argc, argv, "ho:i:s:m:c:t:")) != -1) { switch (opt) { case 'o': out_file = optarg; @@ -291,6 +291,11 @@ int main(int argc, char *argv[]) case 'i': in_file = optarg; break; + case 't': + in_file = optarg; + is_dma_trace = 1; + align = 8; + break; case 'c': clk = atof(optarg); break; @@ -327,36 +332,37 @@ int main(int argc, char *argv[]) fprintf(stdout, "using %2.2fMHz timestamp clock\n", clk); while (1) { - count = fread(&tmp[0], 1, 4, in_fd); - if (count != 4) + count = fread(&tmp[0], 1, align, in_fd); + if (count != align) break; - val = *((uint32_t*)tmp); + val = *((uint64_t*)tmp); - c = tmp[0]; - tmp[0] = tmp[3]; - tmp[3] = c; - c = tmp[1]; - tmp[1] = tmp[2]; - tmp[2] = c; + for (i = 0; i < align / 2; i++) { + c = tmp[i]; + tmp[i] = tmp[align - i - 1]; + tmp[align - i - 1] = c; + } - if (addr >= MAILBOX_TRACE_OFFSET && - addr < MAILBOX_TRACE_OFFSET + MAILBOX_TRACE_SIZE) - show_trace(val, addr, ×tamp, clk); + if (is_dma_trace) + show_trace(val, addr, ×tamp, clk, align * 2); + else if (addr >= MAILBOX_TRACE_OFFSET && + addr < MAILBOX_TRACE_OFFSET + MAILBOX_TRACE_SIZE) + show_trace(val, addr, ×tamp, clk, align * 2); else if (addr >= MAILBOX_DEBUG_OFFSET && - addr < MAILBOX_DEBUG_OFFSET + MAILBOX_DEBUG_SIZE) + addr < MAILBOX_DEBUG_OFFSET + MAILBOX_DEBUG_SIZE) show_debug(val, addr); else if (addr >= MAILBOX_EXCEPTION_OFFSET && - addr < MAILBOX_EXCEPTION_OFFSET + MAILBOX_EXCEPTION_SIZE) + addr < MAILBOX_EXCEPTION_OFFSET + MAILBOX_EXCEPTION_SIZE) show_exception(val, addr); if (out_fd) { - count = fwrite(&tmp[0], 1, 4, out_fd); - if (count != 4) + count = fwrite(&tmp[0], 1, align, out_fd); + if (count != align) break; } - addr += 4; + addr += align; } /* close files */ From 082b84ac61d90872e285a8a099fe132a7643df2a Mon Sep 17 00:00:00 2001 From: Yan Wang Date: Fri, 13 Oct 2017 18:06:09 +0800 Subject: [PATCH 055/324] Use new output format for 64-bit timestamp. 1. Use [second.microsecond] for 64-bit timestamp. 2. Keep previous format for 32-bit timestamp. Signed-off-by: Yan Wang --- rmbox/rmbox.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 638158c44886..d650d3055797 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -113,6 +113,9 @@ static void show_trace(uint64_t val, uint64_t addr, uint64_t *timestamp, float c uint32_t class; uint64_t delta = val - *timestamp; float fdelta = to_usecs(delta, clk); + float us = 0.0f; + uint64_t s = 0, ms = 0; + uint64_t ds = 0, dms = 0; /* timestamp or value ? */ if ((addr % align) == 0) { @@ -128,9 +131,21 @@ static void show_trace(uint64_t val, uint64_t addr, uint64_t *timestamp, float c fdelta = to_usecs(delta, clk); } - printf("trace.io: timestamp 0x%16.16lx (%2.2f us) \tdelta 0x%16.16lx (%2.2f us)\t", - (uint64_t)val, to_usecs(val, clk), - (uint64_t)delta, fdelta); + if (align == 8) { + /* 32-bit timestamp */ + printf("trace.io: timestamp 0x%16.16lx (%2.2f us) \tdelta 0x%16.16lx (%2.2f us)\t", + (uint64_t)val, to_usecs(val, clk), + (uint64_t)delta, fdelta); + } else { + /* 64-bit timestamp */ + us = to_usecs(val, clk); + s = us / 1000000; + ms = us / 1000 - s * 1000; + ds = fdelta / 1000000; + dms = fdelta / 1000 - ds * 1000; + printf("trace.io: timestamp [%lu.%lu] \tdelta [%lu.%lu]\t", + s, ms, ds, dms); + } *timestamp = val; return; } From cd0eb84acae4d8eef69839a63b46546863b4acc8 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 13 Oct 2017 16:41:29 +0100 Subject: [PATCH 056/324] rmbox: move trace into separate parser function to ease future work. Move trace handler into separate function to make it easier to add new trace features. Make sure we only support 64 bit timestamps. Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 159 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 109 insertions(+), 50 deletions(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index d650d3055797..9313f4be4be0 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -82,6 +82,9 @@ #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) + +#define TRACE_BLOCK_SIZE 8 + static inline char get_char(uint32_t val, int idx) { char c = (val >> (idx * 8)) & 0xff; @@ -94,58 +97,41 @@ static inline char get_char(uint32_t val, int idx) static void usage(char *name) { fprintf(stdout, "Usage %s \n", name); + fprintf(stdout, "%s:\t \t\t\tDisplay mailbox contents\n", name); fprintf(stdout, "%s:\t -i infile -o outfile\tDump infile contents to outfile\n", name); fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", name); fprintf(stdout, "%s:\t -s\t\t\tTake a snapshot of state\n", name); + fprintf(stdout, "%s:\t -t\t\t\tDisplay trace data\n", name); exit(0); } -static float to_usecs(uint64_t time, float clk) +static double to_usecs(uint64_t time, double clk) { /* trace timestamp uses CPU system clock at default 25MHz ticks */ // TODO: support variable clock rates return (double)time / clk; } -static void show_trace(uint64_t val, uint64_t addr, uint64_t *timestamp, float clk, uint64_t align) +static void show_trace(uint64_t val, uint64_t addr, uint64_t *timestamp, double clk) { const char *trace; uint32_t class; uint64_t delta = val - *timestamp; - float fdelta = to_usecs(delta, clk); - float us = 0.0f; - uint64_t s = 0, ms = 0; - uint64_t ds = 0, dms = 0; + double fdelta = to_usecs(delta, clk); + double us = 0.0f; /* timestamp or value ? */ - if ((addr % align) == 0) { - /* buffer wrap ? */ - if (val < *timestamp) { - printf("----------------------------------------" - "----------------------------------------" - "--------------------------------------\n"); - delta = 0; - fdelta = 0.0; - } else { - delta = val - *timestamp; - fdelta = to_usecs(delta, clk); - } + if ((addr % (TRACE_BLOCK_SIZE * 2)) == 0) { + + delta = val - *timestamp; + fdelta = to_usecs(delta, clk); + + /* 64-bit timestamp */ + us = to_usecs(val, clk); + + printf("[%6.6f]\tdelta [%6.6f]\t", + us / 1000000.0 , fdelta / 1000000.0); - if (align == 8) { - /* 32-bit timestamp */ - printf("trace.io: timestamp 0x%16.16lx (%2.2f us) \tdelta 0x%16.16lx (%2.2f us)\t", - (uint64_t)val, to_usecs(val, clk), - (uint64_t)delta, fdelta); - } else { - /* 64-bit timestamp */ - us = to_usecs(val, clk); - s = us / 1000000; - ms = us / 1000 - s * 1000; - ds = fdelta / 1000000; - dms = fdelta / 1000 - ds * 1000; - printf("trace.io: timestamp [%lu.%lu] \tdelta [%lu.%lu]\t", - s, ms, ds, dms); - } *timestamp = val; return; } @@ -206,6 +192,68 @@ static void show_trace(uint64_t val, uint64_t addr, uint64_t *timestamp, float c (char)(val >> 16), (char)(val >> 8), (char)val); } +static int trace_read(const char *in_file, const char *out_file, double clk, + int offset) +{ + int count, i; + FILE *in_fd = NULL, *out_fd = NULL; + char c, tmp[TRACE_BLOCK_SIZE] = {0}; + uint64_t addr = 0, val, timestamp = 0; + + in_fd = fopen(in_file, "r"); + if (in_fd == NULL) { + fprintf(stderr, "error: unable to open %s for reading %d\n", + in_file, errno); + return -EIO; + } + + if (out_file == NULL) + goto trace; + + out_fd = fopen(out_file, "w"); + if (out_fd == NULL) { + fprintf(stderr, "error: unable to open %s for writing %d\n", + out_file, errno); + } + +trace: + fprintf(stdout, "using %2.2fMHz timestamp clock\n", clk); + + while (1) { + count = fread(&tmp[0], 1, TRACE_BLOCK_SIZE, in_fd); + if (count != TRACE_BLOCK_SIZE) + break; + + if (addr < offset) { + addr += TRACE_BLOCK_SIZE; + continue; + } + + val = *((uint64_t*)tmp); + + for (i = 0; i < TRACE_BLOCK_SIZE / 2; i++) { + c = tmp[i]; + tmp[i] = tmp[TRACE_BLOCK_SIZE - i - 1]; + tmp[TRACE_BLOCK_SIZE - i - 1] = c; + } + + if (val == 0) + break; + + show_trace(val, addr, ×tamp, clk); + + if (out_fd) { + count = fwrite(&tmp[0], 1, TRACE_BLOCK_SIZE, out_fd); + if (count != TRACE_BLOCK_SIZE) + break; + } + + addr += TRACE_BLOCK_SIZE; + } + + return 0; +} + static void show_debug(uint32_t val, uint32_t addr) { printf("debug: 0x%x (%2.2d) = \t0x%8.8x \t(%8.8d) \t|%c%c%c%c|\n", @@ -233,7 +281,7 @@ static const char *debugfs[] = { static int snapshot(const char *name) { - const char *path = "/sys/kernel/debug"; + const char *path = "/sys/kernel/debug/sof"; uint32_t val, addr; char pinname[64], poutname[64], buffer[128]; FILE *in_fd, *out_fd; @@ -290,15 +338,15 @@ static int snapshot(const char *name) int main(int argc, char *argv[]) { - int opt, count; + int opt, count, trace = 0; const char * out_file = NULL, *in_file = "/sys/kernel/debug/sof/mbox"; FILE *in_fd = NULL, *out_fd = NULL; char c, tmp[8] = {0}; uint64_t addr = 0, val, timestamp = 0, align = 4, i; - float clk = 19.2f; - uint32_t is_dma_trace = 0; + double clk = 19.2; + int title_dbg_done = 0, title_exp_done = 0; - while ((opt = getopt(argc, argv, "ho:i:s:m:c:t:")) != -1) { + while ((opt = getopt(argc, argv, "ho:i:s:m:c:t")) != -1) { switch (opt) { case 'o': out_file = optarg; @@ -307,9 +355,7 @@ int main(int argc, char *argv[]) in_file = optarg; break; case 't': - in_file = optarg; - is_dma_trace = 1; - align = 8; + trace = 1; break; case 'c': clk = atof(optarg); @@ -322,6 +368,10 @@ int main(int argc, char *argv[]) } } + /* trace requested ? */ + if (trace) + return trace_read("/sys/kernel/debug/sof/trace", out_file, clk, 0); + /* open infile for reading */ in_fd = fopen(in_file, "r"); if (in_fd == NULL) { @@ -359,17 +409,21 @@ int main(int argc, char *argv[]) tmp[align - i - 1] = c; } - if (is_dma_trace) - show_trace(val, addr, ×tamp, clk, align * 2); - else if (addr >= MAILBOX_TRACE_OFFSET && - addr < MAILBOX_TRACE_OFFSET + MAILBOX_TRACE_SIZE) - show_trace(val, addr, ×tamp, clk, align * 2); - else if (addr >= MAILBOX_DEBUG_OFFSET && - addr < MAILBOX_DEBUG_OFFSET + MAILBOX_DEBUG_SIZE) + if (addr >= MAILBOX_DEBUG_OFFSET && + addr < MAILBOX_DEBUG_OFFSET + MAILBOX_DEBUG_SIZE) { + + if (!title_dbg_done++) + fprintf(stdout, "\nDebug log:\n"); + show_debug(val, addr); - else if (addr >= MAILBOX_EXCEPTION_OFFSET && - addr < MAILBOX_EXCEPTION_OFFSET + MAILBOX_EXCEPTION_SIZE) + } else if (addr >= MAILBOX_EXCEPTION_OFFSET && + addr < MAILBOX_EXCEPTION_OFFSET + MAILBOX_EXCEPTION_SIZE) { + + if (!title_exp_done++) + fprintf(stdout, "\nException log:\n"); + show_exception(val, addr); + } if (out_fd) { count = fwrite(&tmp[0], 1, align, out_fd); @@ -380,6 +434,11 @@ int main(int argc, char *argv[]) addr += align; } + /* read debug */ + fprintf(stdout, "\nError log:\n"); + trace_read("/sys/kernel/debug/sof/mbox", out_file, clk, + MAILBOX_TRACE_OFFSET); + /* close files */ fclose(in_fd); if (out_fd) From 44bced378143fdbaace80dbf0a4bdc8aa8b6bae0 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 19 Oct 2017 22:24:58 +0100 Subject: [PATCH 057/324] rmbox: use 64bit trace data Update trace to align with FW and use 64bit data size. Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 9313f4be4be0..b8726947ae0e 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -129,16 +129,28 @@ static void show_trace(uint64_t val, uint64_t addr, uint64_t *timestamp, double /* 64-bit timestamp */ us = to_usecs(val, clk); - printf("[%6.6f]\tdelta [%6.6f]\t", + /* empty data ? */ + if (val == 0) { + *timestamp = 0; + return; + } + + /* detect wrap around */ + if (fdelta < 1000.0 * 1000.0 * 1000.0) + printf("0x%lx [%6.6f]\tdelta [%6.6f]\t", addr, us / 1000000.0 , fdelta / 1000000.0); + else + printf("0x%lx [%6.6f]\tdelta [********]\t", addr, + us / 1000000.0); *timestamp = val; return; - } + } else if (*timestamp == 0) + return; /* check for printable values - otherwise it's a value */ if (!isprint((char)(val >> 16)) || !isprint((char)(val >> 8)) || !isprint((char)val)) { - printf("value 0x%8.8x\n", (uint32_t)val); + printf("value 0x%16.16lx\n", val); return; } @@ -237,9 +249,6 @@ static int trace_read(const char *in_file, const char *out_file, double clk, tmp[TRACE_BLOCK_SIZE - i - 1] = c; } - if (val == 0) - break; - show_trace(val, addr, ×tamp, clk); if (out_fd) { From f3b486537d57c10b8ae232ac3af9a2b60eb3b784 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 5 Dec 2017 16:31:49 +0000 Subject: [PATCH 058/324] topology: add test pass through pipe for 16bit 48kHz on SSP2 Signed-off-by: Liam Girdwood --- topology/test-passthrough-16bit-48k-ssp2.m4 | 54 +++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 topology/test-passthrough-16bit-48k-ssp2.m4 diff --git a/topology/test-passthrough-16bit-48k-ssp2.m4 b/topology/test-passthrough-16bit-48k-ssp2.m4 new file mode 100644 index 000000000000..197d8ad76528 --- /dev/null +++ b/topology/test-passthrough-16bit-48k-ssp2.m4 @@ -0,0 +1,54 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# + +# DAI Link Name +define(`TEST_DAI_LINK_NAME', `Baytrail Audio') + +# DAI Link Stream Name +define(`TEST_DAI_LINK_STREAM_NAME', `Audio') + +# +# Define the pipeline +# +# PCM0 ----> SSP2 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, + 1, 0, 2, s16le, + 48, 1000, 0, 0, 0, 1, + SSP, 2, TEST_DAI_LINK_STREAM_NAME, s16le, 2) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# 16bit I2S using 20bit sample conatiner on SSP2 +# +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, TEST_DAI_LINK_STREAM_NAME, I2S, 16, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 1920000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 20, 3, 3)) From df8b47392996e2b8cc18d24fb642e318143aa47f Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 6 Dec 2017 19:41:04 -0600 Subject: [PATCH 059/324] topology: remove stream_name parameter from DAI_CONFIG This value is never set in machine drivers, no point in setting it here Signed-off-by: Pierre-Louis Bossart --- topology/m4/local.m4 | 9 ++++----- topology/reef-apl-nocodec.m4 | 2 +- topology/reef-bdw-rt286.m4 | 2 +- topology/reef-bdw-rt5640.m4 | 2 +- topology/reef-bxt-nocodec.m4 | 2 +- topology/reef-byt-nocodec.m4 | 2 +- topology/reef-byt-rt5640.m4 | 2 +- topology/reef-byt-rt5651.m4 | 2 +- topology/reef-cht-nocodec.m4 | 2 +- topology/reef-hsw-rt5640.m4 | 2 +- topology/test-passthrough-16bit-48k-ssp2.m4 | 2 +- topology/test-passthrough-24bit-48k-src-ssp2.m4 | 2 +- topology/test-passthrough-24bit-48k-ssp2.m4 | 2 +- topology/test-passthrough-24bit-48k-vol-ssp2.m4 | 2 +- 14 files changed, 17 insertions(+), 18 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index e521267b6223..e31ba0ed56ae 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -422,17 +422,17 @@ define(`DAI_TDM', dnl Pipeline name) define(`N_DAI_CONFIG', `DAICONFIG.'$1) -dnl DAI_CONFIG(type, idx, name, sname, format, valid bits, mclk, bclk, fsync, tdm) +dnl DAI_CONFIG(type, idx, name, format, valid bits, mclk, bclk, fsync, tdm) define(`DAI_CONFIG', `SectionHWConfig."'$1$2`" {' `' ` id "'$2`"' -` format "'$5`"' +` format "'$4`"' `' +` '$6 ` '$7 ` '$8 ` '$9 -` '$10 `}' `SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples_str" {' ` tokens "sof_dai_tokens"' @@ -446,7 +446,7 @@ define(`DAI_CONFIG', `SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {' ` tokens "sof_dai_tokens"' ` tuples."word" {' -` SOF_TKN_DAI_SAMPLE_BITS' STR($6) +` SOF_TKN_DAI_SAMPLE_BITS' STR($5) ` }' `}' `SectionData."'N_DAI_CONFIG($1$2)`_data" {' @@ -456,7 +456,6 @@ define(`DAI_CONFIG', `SectionBE."'$3`" {' ` index "0"' `' -` stream_name "'$4`"' ` hw_configs [' ` "'$1$2`"' ` ]' diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index 96f28d537632..b62d9ed3e1b4 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -103,7 +103,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, 24, +DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index 512efe939280..16b5dd114434 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -103,7 +103,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, Codec, I2S, I2S, 24, +DAI_CONFIG(SSP, 0, Codec, I2S, 24, DAI_CLOCK(mclk, 24000000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index 5e259a6ac623..f0071ee48f1a 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -103,7 +103,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, Codec, I2S, I2S, 24, +DAI_CONFIG(SSP, 0, Codec, I2S, 24, DAI_CLOCK(mclk, 24000000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index e3c45c937951..ff506dd772c3 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -103,7 +103,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, 24, +DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index 3db415df2d36..17203f5ffb20 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -92,7 +92,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, 24, +DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 1e9bb5ffb984..3234b94da443 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -92,7 +92,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, Baytrail Audio, Audio, I2S, 24, +DAI_CONFIG(SSP, 2, Baytrail Audio, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index 0867f914f639..26ea7420ddad 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -92,7 +92,7 @@ PCM_DUPLEX_ADD(Low Latency, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, Baytrail Audio, Audio, I2S, 24, +DAI_CONFIG(SSP, 2, Baytrail Audio, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index 195ae5c40f62..908c037997f0 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -92,7 +92,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, I2S, 24, +DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index 1b06828971ea..13d073ae85ed 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -103,7 +103,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, Codec, I2S, I2S, 24, +DAI_CONFIG(SSP, 0, Codec, I2S, 24, DAI_CLOCK(mclk, 24000000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/test-passthrough-16bit-48k-ssp2.m4 b/topology/test-passthrough-16bit-48k-ssp2.m4 index 197d8ad76528..bf4963b7130f 100644 --- a/topology/test-passthrough-16bit-48k-ssp2.m4 +++ b/topology/test-passthrough-16bit-48k-ssp2.m4 @@ -47,7 +47,7 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, # # 16bit I2S using 20bit sample conatiner on SSP2 # -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, TEST_DAI_LINK_STREAM_NAME, I2S, 16, +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 16, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 1920000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/test-passthrough-24bit-48k-src-ssp2.m4 b/topology/test-passthrough-24bit-48k-src-ssp2.m4 index 5f88d7ddd86a..bcaed51d50fa 100644 --- a/topology/test-passthrough-24bit-48k-src-ssp2.m4 +++ b/topology/test-passthrough-24bit-48k-src-ssp2.m4 @@ -48,7 +48,7 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-src-playback.m4, # # 24bit I2S using 25bit sample conatiner on SSP2 # -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, TEST_DAI_LINK_STREAM_NAME, I2S, 24, +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/test-passthrough-24bit-48k-ssp2.m4 b/topology/test-passthrough-24bit-48k-ssp2.m4 index 8ea4748a9a36..74c3b1a641d9 100644 --- a/topology/test-passthrough-24bit-48k-ssp2.m4 +++ b/topology/test-passthrough-24bit-48k-ssp2.m4 @@ -47,7 +47,7 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, # # 24bit I2S using 25bit sample conatiner on SSP2 # -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, TEST_DAI_LINK_STREAM_NAME, I2S, 24, +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/test-passthrough-24bit-48k-vol-ssp2.m4 b/topology/test-passthrough-24bit-48k-vol-ssp2.m4 index b1a0dab0520b..3ff80fcbd73d 100644 --- a/topology/test-passthrough-24bit-48k-vol-ssp2.m4 +++ b/topology/test-passthrough-24bit-48k-vol-ssp2.m4 @@ -48,7 +48,7 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-vol-playback.m4, # # 24bit I2S using 25bit sample conatiner on SSP2 # -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, TEST_DAI_LINK_STREAM_NAME, I2S, 24, +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), From 31c4918ad5f5c27aa525a8b514d89cdc06a85a10 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 6 Dec 2017 19:41:05 -0600 Subject: [PATCH 060/324] topology: remove stream_name for all DAI definitions stream_name is not used by any machine drivers, there is no point in providing the information to topology layers Signed-off-by: Pierre-Louis Bossart --- topology/m4/build.m4 | 26 +++-- topology/m4/local.m4 | 98 +++++++++---------- topology/reef-apl-nocodec.m4 | 8 +- topology/reef-bdw-rt286.m4 | 8 +- topology/reef-bdw-rt5640.m4 | 8 +- topology/reef-bxt-nocodec.m4 | 8 +- topology/reef-byt-nocodec.m4 | 8 +- topology/reef-byt-rt5640.m4 | 8 +- topology/reef-byt-rt5651.m4 | 8 +- topology/reef-cht-nocodec.m4 | 8 +- topology/reef-hsw-rt5640.m4 | 8 +- topology/sof/pipe-dai-capture.m4 | 2 +- topology/sof/pipe-dai-playback.m4 | 2 +- topology/sof/pipe-passthrough-playback.m4 | 2 +- topology/sof/pipe-passthrough-src-playback.m4 | 2 +- topology/sof/pipe-passthrough-vol-playback.m4 | 2 +- topology/test-passthrough-16bit-48k-ssp2.m4 | 5 +- .../test-passthrough-24bit-48k-src-ssp2.m4 | 6 +- topology/test-passthrough-24bit-48k-ssp2.m4 | 5 +- .../test-passthrough-24bit-48k-vol-ssp2.m4 | 6 +- 20 files changed, 104 insertions(+), 124 deletions(-) diff --git a/topology/m4/build.m4 b/topology/m4/build.m4 index d6801deda78c..93612191d59c 100644 --- a/topology/m4/build.m4 +++ b/topology/m4/build.m4 @@ -30,7 +30,7 @@ define(`PIPELINE_PCM_ADD', dnl PIPELINE_PCM_DAI_ADD(pipeline, dnl pipe id, pcm, max channels, format, dnl frames, deadline, priority, core, dmac, dmac_chan, -dnl dai type, dai_index, stream_name, dai format, periods) +dnl dai type, dai_index, dai format, periods) define(`PIPELINE_PCM_DAI_ADD', `undefine(`PCM_ID')' `undefine(`PIPELINE_ID')' @@ -44,7 +44,6 @@ define(`PIPELINE_PCM_DAI_ADD', `undefine(`PIPELINE_DMAC_CHAN')' `undefine(`DAI_TYPE')' `undefine(`DAI_INDEX')' -`undefine(`DAI_SNAME')' `undefine(`DAI_FORMAT')' `undefine(`DAI_PERIODS')' `define(`PIPELINE_ID', $2)' @@ -59,9 +58,8 @@ define(`PIPELINE_PCM_DAI_ADD', `define(`PIPELINE_DMAC_CHAN', $11)' `define(`DAI_TYPE', STR($12))' `define(`DAI_INDEX', STR($13))' -`define(`DAI_SNAME', $14)' -`define(`DAI_FORMAT', $15)' -`define(`DAI_PERIODS', $16)' +`define(`DAI_FORMAT', $14)' +`define(`DAI_PERIODS', $15)' `define(`DAI_NAME', $12$13)' `include($1)' ) @@ -88,14 +86,13 @@ define(`PIPELINE_ADD', ) dnl DAI_ADD(pipeline, -dnl pipe id, dai type, dai_index, stream_name, +dnl pipe id, dai type, dai_index, dnl buffer, periods, format, dnl frames, deadline, priority, core) define(`DAI_ADD', `undefine(`PIPELINE_ID')' `undefine(`DAI_TYPE')' `undefine(`DAI_INDEX')' -`undefine(`DAI_SNAME')' `undefine(`DAI_BUF')' `undefine(`DAI_PERIODS')' `undefine(`DAI_FORMAT')' @@ -106,15 +103,14 @@ define(`DAI_ADD', `define(`PIPELINE_ID', $2)' `define(`DAI_TYPE', STR($3))' `define(`DAI_INDEX', STR($4))' -`define(`DAI_SNAME', $5)' -`define(`DAI_BUF', $6)' +`define(`DAI_BUF', $5)' `define(`DAI_NAME', $3$4)' -`define(`DAI_PERIODS', $7)' -`define(`DAI_FORMAT', $8)' -`define(`SCHEDULE_FRAMES', $9)' -`define(`SCHEDULE_DEADLINE', $10)' -`define(`SCHEDULE_PRIORITY', $11)' -`define(`SCHEDULE_CORE', $12)' +`define(`DAI_PERIODS', $6)' +`define(`DAI_FORMAT', $7)' +`define(`SCHEDULE_FRAMES', $8)' +`define(`SCHEDULE_DEADLINE', $9)' +`define(`SCHEDULE_PRIORITY', $10)' +`define(`SCHEDULE_CORE', $11)' `include($1)' ) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index e31ba0ed56ae..da20e1c99c8d 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -257,111 +257,109 @@ define(`N_DAI', DAI_NAME) define(`N_DAI_OUT', DAI_NAME`.OUT') define(`N_DAI_IN', DAI_NAME`.IN') -dnl W_DAI_OUT(stream, type, index, format, periods_sink, periods_source, preload, data) +dnl W_DAI_OUT(type, index, format, periods_sink, periods_source, preload, data) define(`W_DAI_OUT', -`SectionVendorTuples."'N_DAI_OUT($1)`_tuples_w_comp" {' +`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) ` }' `}' -`SectionData."'N_DAI_OUT($1)`_data_w_comp" {' -` tuples "'N_DAI_OUT($1)`_tuples_w_comp"' +`SectionData."'N_DAI_OUT($2)`_data_w_comp" {' +` tuples "'N_DAI_OUT($2)`_tuples_w_comp"' `}' -`SectionVendorTuples."'N_DAI_OUT($1)`_tuples_w" {' +`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_w" {' ` tokens "sof_dai_tokens"' ` tuples."word" {' -` SOF_TKN_DAI_INDEX' $3 +` SOF_TKN_DAI_INDEX' $2 ` }' `}' -`SectionData."'N_DAI_OUT($1)`_data_w" {' -` tuples "'N_DAI_OUT($1)`_tuples_w"' +`SectionData."'N_DAI_OUT($2)`_data_w" {' +` tuples "'N_DAI_OUT($2)`_tuples_w"' `}' -`SectionVendorTuples."'N_DAI_OUT($1)`_tuples_str" {' +`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_str" {' ` tokens "sof_dai_tokens"' ` tuples."string" {' -` SOF_TKN_DAI_TYPE' $2 +` SOF_TKN_DAI_TYPE' $1 ` }' `}' -`SectionData."'N_DAI_OUT($1)`_data_str" {' -` tuples "'N_DAI_OUT($1)`_tuples_str"' +`SectionData."'N_DAI_OUT($2)`_data_str" {' +` tuples "'N_DAI_OUT($2)`_tuples_str"' `}' -`SectionVendorTuples."'N_DAI_OUT($1)`_tuples_comp_str" {' +`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_comp_str" {' ` tokens "sof_comp_tokens"' ` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($4) +` SOF_TKN_COMP_FORMAT' STR($3) ` }' `}' -`SectionData."'N_DAI_OUT($1)`_data_comp_str" {' -` tuples "'N_DAI_OUT($1)`_tuples_comp_str"' +`SectionData."'N_DAI_OUT($2)`_data_comp_str" {' +` tuples "'N_DAI_OUT($2)`_tuples_comp_str"' `}' `SectionWidget."'N_DAI_OUT`" {' ` index "'PIPELINE_ID`"' ` type "dai_in"' ` no_pm "true"' -` stream_name "'$1`"' ` data [' -` "'N_DAI_OUT($1)`_data_w"' -` "'N_DAI_OUT($1)`_data_w_comp"' -` "'N_DAI_OUT($1)`_data_str"' -` "'N_DAI_OUT($1)`_data_comp_str"' -` "'$8`"' +` "'N_DAI_OUT($2)`_data_w"' +` "'N_DAI_OUT($2)`_data_w_comp"' +` "'N_DAI_OUT($2)`_data_str"' +` "'N_DAI_OUT($2)`_data_comp_str"' +` "'$7`"' ` ]' `}') -dnl W_DAI_IN(stream, type, index, format, periods_sink, periods_source, preload, data) +dnl W_DAI_IN(type, index, format, periods_sink, periods_source, preload, data) define(`W_DAI_IN', -`SectionVendorTuples."'N_DAI_IN($1)`_tuples_w_comp" {' +`SectionVendorTuples."'N_DAI_IN($2)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) ` }' `}' -`SectionData."'N_DAI_IN($1)`_data_w_comp" {' -` tuples "'N_DAI_IN($1)`_tuples_w_comp"' +`SectionData."'N_DAI_IN($2)`_data_w_comp" {' +` tuples "'N_DAI_IN($2)`_tuples_w_comp"' `}' -`SectionVendorTuples."'N_DAI_IN($1)`_tuples_w" {' +`SectionVendorTuples."'N_DAI_IN($2)`_tuples_w" {' ` tokens "sof_dai_tokens"' ` tuples."word" {' -` SOF_TKN_DAI_INDEX' $3 +` SOF_TKN_DAI_INDEX' $2 ` }' `}' -`SectionData."'N_DAI_IN($1)`_data_w" {' -` tuples "'N_DAI_IN($1)`_tuples_w"' +`SectionData."'N_DAI_IN($2)`_data_w" {' +` tuples "'N_DAI_IN($2)`_tuples_w"' `}' -`SectionVendorTuples."'N_DAI_IN($1)`_tuples_str" {' +`SectionVendorTuples."'N_DAI_IN($2)`_tuples_str" {' ` tokens "sof_dai_tokens"' ` tuples."string" {' -` SOF_TKN_DAI_TYPE' $2 +` SOF_TKN_DAI_TYPE' $1 ` }' `}' -`SectionData."'N_DAI_IN($1)`_data_str" {' -` tuples "'N_DAI_IN($1)`_tuples_str"' +`SectionData."'N_DAI_IN($2)`_data_str" {' +` tuples "'N_DAI_IN($2)`_tuples_str"' `}' -`SectionVendorTuples."'N_DAI_IN($1)`_tuples_comp_str" {' +`SectionVendorTuples."'N_DAI_IN($2)`_tuples_comp_str" {' ` tokens "sof_comp_tokens"' ` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($4) +` SOF_TKN_COMP_FORMAT' STR($3) ` }' `}' -`SectionData."'N_DAI_IN($1)`_data_comp_str" {' -` tuples "'N_DAI_IN($1)`_tuples_comp_str"' +`SectionData."'N_DAI_IN($2)`_data_comp_str" {' +` tuples "'N_DAI_IN($2)`_tuples_comp_str"' `}' `SectionWidget."'N_DAI_IN`" {' ` index "'PIPELINE_ID`"' ` type "dai_out"' ` no_pm "true"' -` stream_name "'$1`"' ` data [' -` "'N_DAI_IN($1)`_data_w"' -` "'N_DAI_IN($1)`_data_w_comp"' -` "'N_DAI_IN($1)`_data_str"' -` "'N_DAI_OUT($1)`_data_comp_str"' -` "'$8`"' +` "'N_DAI_IN($2)`_data_w"' +` "'N_DAI_IN($2)`_data_w_comp"' +` "'N_DAI_IN($2)`_data_str"' +` "'N_DAI_OUT($2)`_data_comp_str"' +` "'$7`"' ` ]' `}') diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index b62d9ed3e1b4..89ac0b07fd06 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -83,17 +83,17 @@ SectionGraph."pipe-apl-nocodec" { # SSP port 2 is our only pipeline DAI # -# playback DAI is SSP2 using I2S DAPM stream and 2 periods +# playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, I2S, + 1, SSP, 2, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) -# capture DAI is SSP2 using I2S DAPM stream and 2 periods +# capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, I2S, + 2, SSP, 2, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index 16b5dd114434..969d5e0d5335 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -83,17 +83,17 @@ SectionGraph."pipe-bdw-rt286" { # SSP port 0 is our only pipeline DAI # -# playback DAI is SSP0 using I2S DAPM stream and 2 periods +# playback DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 0, I2S, + 1, SSP, 0, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) -# capture DAI is SSP0 using I2S DAPM stream and 2 periods +# capture DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 0, I2S, + 2, SSP, 0, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index f0071ee48f1a..acf246299cf1 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -83,17 +83,17 @@ SectionGraph."pipe-bdw-rt5640" { # SSP port 0 is our only pipeline DAI # -# playback DAI is SSP0 using I2S DAPM stream and 2 periods +# playback DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 0, I2S, + 1, SSP, 0, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) -# capture DAI is SSP0 using I2S DAPM stream and 2 periods +# capture DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 0, I2S, + 2, SSP, 0, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index ff506dd772c3..86cc3644237a 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -83,17 +83,17 @@ SectionGraph."pipe-bxt-nocodec" { # SSP port 2 is our only pipeline DAI # -# playback DAI is SSP2 using I2S DAPM stream and 2 periods +# playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, I2S, + 1, SSP, 2, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) -# capture DAI is SSP2 using I2S DAPM stream and 2 periods +# capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, I2S, + 2, SSP, 2, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index 17203f5ffb20..56aee226cd7c 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -72,17 +72,17 @@ SectionGraph."pipe-byt-nocodec" { # SSP port 2 is our only pipeline DAI # -# playback DAI is SSP2 using I2S DAPM stream and 2 periods +# playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, I2S, + 1, SSP, 2, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) -# capture DAI is SSP2 using I2S DAPM stream and 2 periods +# capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, I2S, + 2, SSP, 2, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 3234b94da443..f8d0e40d162b 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -72,17 +72,17 @@ SectionGraph."pipe-byt-rt5640" { # SSP port 2 is our only pipeline DAI # -# playback DAI is SSP2 using I2S DAPM stream and 2 periods +# playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, Audio, + 1, SSP, 2, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) -# capture DAI is SSP2 using I2S DAPM stream and 2 periods +# capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, Audio, + 2, SSP, 2, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index 26ea7420ddad..ccac260303f9 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -72,17 +72,17 @@ SectionGraph."pipe-byt-rt5651" { # SSP port 2 is our only pipeline DAI # -# playback DAI is SSP2 using "Audio" DAPM stream name and 2 periods +# playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, Audio, + 1, SSP, 2, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) -# capture DAI is SSP2 using "Audio" DAPM stream name and 2 periods +# capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, Audio, + 2, SSP, 2, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index 908c037997f0..24560ee6a1e0 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -72,17 +72,17 @@ SectionGraph."pipe-cht-nocodec" { # SSP port 2 is our only pipeline DAI # -# playback DAI is SSP2 using I2S DAPM stream and 2 periods +# playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, I2S, + 1, SSP, 2, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) -# capture DAI is SSP2 using I2S DAPM stream and 2 periods +# capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, I2S, + 2, SSP, 2, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index 13d073ae85ed..8759704b5ea0 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -83,17 +83,17 @@ SectionGraph."pipe-hsw-rt5640" { # SSP port 0 is our only pipeline DAI # -# playback DAI is SSP0 using I2S DAPM stream and 2 periods +# playback DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 0, I2S, + 1, SSP, 0, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) -# capture DAI is SSP0 using I2S DAPM stream and 2 periods +# capture DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 0, I2S, + 2, SSP, 0, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/sof/pipe-dai-capture.m4 b/topology/sof/pipe-dai-capture.m4 index 45c6ff404122..ab63efd6b807 100644 --- a/topology/sof/pipe-dai-capture.m4 +++ b/topology/sof/pipe-dai-capture.m4 @@ -6,7 +6,7 @@ include(`local.m4') # # DAI definitions # -W_DAI_IN(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 2, 0, 0, dai0c_plat_conf) +W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 2, 0, 0, dai0c_plat_conf) # # DAI pipeline - always use 0 for DAIs diff --git a/topology/sof/pipe-dai-playback.m4 b/topology/sof/pipe-dai-playback.m4 index f99aac0d153a..3a7a15812889 100644 --- a/topology/sof/pipe-dai-playback.m4 +++ b/topology/sof/pipe-dai-playback.m4 @@ -6,7 +6,7 @@ include(`local.m4') # # DAI definitions # -W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) +W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) # # DAI pipeline - always use 0 for DAIs diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index 4e6e705d1141..2b34cef8660f 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -23,7 +23,7 @@ W_BUFFER(0, COMP_BUFFER_SIZE(2, # # DAI definitions # -W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) +W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) # # DAI pipeline - always use 0 for DAIs diff --git a/topology/sof/pipe-passthrough-src-playback.m4 b/topology/sof/pipe-passthrough-src-playback.m4 index 3cadaf2d8a18..b8fae58dcb8f 100644 --- a/topology/sof/pipe-passthrough-src-playback.m4 +++ b/topology/sof/pipe-passthrough-src-playback.m4 @@ -44,7 +44,7 @@ W_BUFFER(1, COMP_BUFFER_SIZE(4, # # DAI definitions # -W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, +W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, DAI_PERIODS, dai0p_plat_conf) # diff --git a/topology/sof/pipe-passthrough-vol-playback.m4 b/topology/sof/pipe-passthrough-vol-playback.m4 index f0e39e8777a2..6e8aba4bee03 100644 --- a/topology/sof/pipe-passthrough-vol-playback.m4 +++ b/topology/sof/pipe-passthrough-vol-playback.m4 @@ -58,7 +58,7 @@ W_BUFFER(1, COMP_BUFFER_SIZE(2, # # DAI definitions # -W_DAI_OUT(DAI_SNAME, DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, +W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, DAI_PERIODS, dai0p_plat_conf) # diff --git a/topology/test-passthrough-16bit-48k-ssp2.m4 b/topology/test-passthrough-16bit-48k-ssp2.m4 index bf4963b7130f..7bf4aaf5df06 100644 --- a/topology/test-passthrough-16bit-48k-ssp2.m4 +++ b/topology/test-passthrough-16bit-48k-ssp2.m4 @@ -22,9 +22,6 @@ include(`dsps/byt.m4') # DAI Link Name define(`TEST_DAI_LINK_NAME', `Baytrail Audio') -# DAI Link Stream Name -define(`TEST_DAI_LINK_STREAM_NAME', `Audio') - # # Define the pipeline # @@ -38,7 +35,7 @@ define(`TEST_DAI_LINK_STREAM_NAME', `Audio') PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, 1, 0, 2, s16le, 48, 1000, 0, 0, 0, 1, - SSP, 2, TEST_DAI_LINK_STREAM_NAME, s16le, 2) + SSP, 2, s16le, 2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/test-passthrough-24bit-48k-src-ssp2.m4 b/topology/test-passthrough-24bit-48k-src-ssp2.m4 index bcaed51d50fa..61c06e12b81f 100644 --- a/topology/test-passthrough-24bit-48k-src-ssp2.m4 +++ b/topology/test-passthrough-24bit-48k-src-ssp2.m4 @@ -22,10 +22,6 @@ include(`dsps/byt.m4') # DAI Link Name define(`TEST_DAI_LINK_NAME', `Baytrail Audio') -# DAI Link Stream Name -define(`TEST_DAI_LINK_STREAM_NAME', `Audio') - - # # Define the pipeline # @@ -39,7 +35,7 @@ define(`TEST_DAI_LINK_STREAM_NAME', `Audio') PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-src-playback.m4, 1, 0, 2, s24le, 48, 1000, 0, 0, 0, 1, - SSP, 2, TEST_DAI_LINK_STREAM_NAME, s24le, 2) + SSP, 2, s24le, 2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/test-passthrough-24bit-48k-ssp2.m4 b/topology/test-passthrough-24bit-48k-ssp2.m4 index 74c3b1a641d9..ca3261d22733 100644 --- a/topology/test-passthrough-24bit-48k-ssp2.m4 +++ b/topology/test-passthrough-24bit-48k-ssp2.m4 @@ -22,9 +22,6 @@ include(`dsps/byt.m4') # DAI Link Name define(`TEST_DAI_LINK_NAME', `Baytrail Audio') -# DAI Link Stream Name -define(`TEST_DAI_LINK_STREAM_NAME', `Audio') - # # Define the pipeline # @@ -38,7 +35,7 @@ define(`TEST_DAI_LINK_STREAM_NAME', `Audio') PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, 1, 0, 2, s24le, 48, 1000, 0, 0, 0, 1, - SSP, 2, TEST_DAI_LINK_STREAM_NAME, s24le, 2) + SSP, 2, s24le, 2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/test-passthrough-24bit-48k-vol-ssp2.m4 b/topology/test-passthrough-24bit-48k-vol-ssp2.m4 index 3ff80fcbd73d..707178276302 100644 --- a/topology/test-passthrough-24bit-48k-vol-ssp2.m4 +++ b/topology/test-passthrough-24bit-48k-vol-ssp2.m4 @@ -22,10 +22,6 @@ include(`dsps/byt.m4') # DAI Link Name define(`TEST_DAI_LINK_NAME', `Baytrail Audio') -# DAI Link Stream Name -define(`TEST_DAI_LINK_STREAM_NAME', `Audio') - - # # Define the pipeline # @@ -39,7 +35,7 @@ define(`TEST_DAI_LINK_STREAM_NAME', `Audio') PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-vol-playback.m4, 1, 0, 2, s24le, 48, 1000, 0, 0, 0, 1, - SSP, 2, TEST_DAI_LINK_STREAM_NAME, s24le, 2) + SSP, 2, s24le, 2) # # BE configurations - overrides config in ACPI if present From d72c06143e67b0f92d74bc595ec8d3ba05f2a0d6 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 6 Dec 2017 19:41:06 -0600 Subject: [PATCH 061/324] topology: add support for Dialog, Realtek and Maxim codecs Signed-off-by: Pierre-Louis Bossart --- topology/Makefile.am | 3 ++ topology/reef-byt-da7212.m4 | 99 +++++++++++++++++++++++++++++++++++ topology/reef-byt-rt5645.m4 | 99 +++++++++++++++++++++++++++++++++++ topology/reef-cht-max98090.m4 | 99 +++++++++++++++++++++++++++++++++++ 4 files changed, 300 insertions(+) create mode 100644 topology/reef-byt-da7212.m4 create mode 100644 topology/reef-byt-rt5645.m4 create mode 100644 topology/reef-cht-max98090.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 09618c8acb30..9d8976697b3e 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -15,13 +15,16 @@ DEPS = \ MACHINES = \ reef-cht-nocodec.tplg \ + reef-cht-max98090.tplg \ reef-apl-nocodec.tplg \ reef-bxt-nocodec.tplg \ reef-byt-nocodec.tplg \ reef-bdw-rt286.tplg \ reef-bdw-rt5640.tplg \ reef-byt-rt5640.tplg \ + reef-byt-rt5645.tplg \ reef-byt-rt5651.tplg \ + reef-byt-da7212.tplg \ reef-hsw-rt5640.tplg \ test-passthrough-24bit-48k-ssp2.tplg \ test-passthrough-24bit-48k-vol-ssp2.tplg \ diff --git a/topology/reef-byt-da7212.m4 b/topology/reef-byt-da7212.m4 new file mode 100644 index 000000000000..840ea6951210 --- /dev/null +++ b/topology/reef-byt-da7212.m4 @@ -0,0 +1,99 @@ +# +# Topology for generic Baytrail board with no codec. +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Define the pipelines +# +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP2 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) + +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 0, 2, s32le, + 48, 1000, 0, 0, 0, 2) + +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 1, 2, s32le, + 192, 4000, 1, 0, 0, 3) + +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) + +# Connect pipelines together +SectionGraph."pipe-byt-da7212" { + index "0" + + lines [ + # media 0 + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) + #tone + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) + ] +} + +# +# DAI configuration +# +# SSP port 2 is our only pipeline DAI +# + +# playback DAI is SSP2 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 2, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) + +# capture DAI is SSP2 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, 2, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) + +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + +# +# BE configurations - overrides config in ACPI if present +# +DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/reef-byt-rt5645.m4 b/topology/reef-byt-rt5645.m4 new file mode 100644 index 000000000000..023d92dbcdf6 --- /dev/null +++ b/topology/reef-byt-rt5645.m4 @@ -0,0 +1,99 @@ +# +# Topology for generic Baytrail board with no codec. +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Define the pipelines +# +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP2 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) + +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 0, 2, s32le, + 48, 1000, 0, 0, 0, 2) + +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 1, 2, s32le, + 192, 4000, 1, 0, 0, 3) + +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) + +# Connect pipelines together +SectionGraph."pipe-byt-rt5645" { + index "0" + + lines [ + # media 0 + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) + #tone + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) + ] +} + +# +# DAI configuration +# +# SSP port 2 is our only pipeline DAI +# + +# playback DAI is SSP2 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 2, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) + +# capture DAI is SSP2 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, 2, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) + +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + +# +# BE configurations - overrides config in ACPI if present +# +DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 25, 3, 3)) diff --git a/topology/reef-cht-max98090.m4 b/topology/reef-cht-max98090.m4 new file mode 100644 index 000000000000..3218402420d9 --- /dev/null +++ b/topology/reef-cht-max98090.m4 @@ -0,0 +1,99 @@ +# +# Topology for generic CHT/BSW board with Maxim 98090 codec +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Cherrytrail DSP configuration +include(`dsps/cht.m4') + +# +# Define the pipelines +# +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP2 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) + +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 0, 2, s32le, + 48, 1000, 0, 0, 0, 2) + +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 1, 2, s32le, + 192, 4000, 1, 0, 0, 3) + +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) + +# Connect pipelines together +SectionGraph."pipe-cht-max98090" { + index "0" + + lines [ + # media 0 + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) + #tone + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) + ] +} + +# +# DAI configuration +# +# SSP port 2 is our only pipeline DAI +# + +# playback DAI is SSP2 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 2, + PIPELINE_SOURCE_1, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP2 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, 2, + PIPELINE_SINK_2, 2, s16le, + 48, 1000, 0, 0) + +# PCM Low Latency +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + +# +# BE configurations - overrides config in ACPI if present +# +DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 16, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 1920000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 20, 3, 3)) From cd988c514d58c6b62d006200b655dffc7044b373 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 6 Dec 2017 19:41:07 -0600 Subject: [PATCH 062/324] topology: add files for SSP2-Codec machine drivers At some point we should have a better way of relying on common parts but for now add a passthrough shortcut directly usable with machine drivers Signed-off-by: Pierre-Louis Bossart --- topology/Makefile.am | 2 + ...t-passthrough-16bit-48k-ssp2-SSP2-Codec.m4 | 51 +++++++++++++++++++ ...t-passthrough-24bit-48k-ssp2-SSP2-Codec.m4 | 51 +++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 topology/test-passthrough-16bit-48k-ssp2-SSP2-Codec.m4 create mode 100644 topology/test-passthrough-24bit-48k-ssp2-SSP2-Codec.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 9d8976697b3e..d9be79ed54e0 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -27,6 +27,8 @@ MACHINES = \ reef-byt-da7212.tplg \ reef-hsw-rt5640.tplg \ test-passthrough-24bit-48k-ssp2.tplg \ + test-passthrough-24bit-48k-ssp2-SSP2-Codec.tplg \ + test-passthrough-16bit-48k-ssp2-SSP2-Codec.tplg \ test-passthrough-24bit-48k-vol-ssp2.tplg \ test-passthrough-24bit-48k-src-ssp2.tplg diff --git a/topology/test-passthrough-16bit-48k-ssp2-SSP2-Codec.m4 b/topology/test-passthrough-16bit-48k-ssp2-SSP2-Codec.m4 new file mode 100644 index 000000000000..e93041662063 --- /dev/null +++ b/topology/test-passthrough-16bit-48k-ssp2-SSP2-Codec.m4 @@ -0,0 +1,51 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# + +# DAI Link Name +define(`TEST_DAI_LINK_NAME', `SSP2-Codec') + +# +# Define the pipeline +# +# PCM0 ----> SSP2 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, + 1, 0, 2, s16le, + 48, 1000, 0, 0, 0, 1, + SSP, 2, s16le, 2) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# 24bit I2S using 25bit sample conatiner on SSP2 +# +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 16, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 1920000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 20, 3, 3)) diff --git a/topology/test-passthrough-24bit-48k-ssp2-SSP2-Codec.m4 b/topology/test-passthrough-24bit-48k-ssp2-SSP2-Codec.m4 new file mode 100644 index 000000000000..7e481d372d33 --- /dev/null +++ b/topology/test-passthrough-24bit-48k-ssp2-SSP2-Codec.m4 @@ -0,0 +1,51 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# + +# DAI Link Name +define(`TEST_DAI_LINK_NAME', `SSP2-Codec') + +# +# Define the pipeline +# +# PCM0 ----> SSP2 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, + 1, 0, 2, s24le, + 48, 1000, 0, 0, 0, 1, + SSP, 2, s24le, 2) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# 24bit I2S using 25bit sample conatiner on SSP2 +# +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 24, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 25, 3, 3)) From 627e52bd67abc9f23c78a2b83e80dd94a18b1822 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 6 Dec 2017 19:41:08 -0600 Subject: [PATCH 063/324] soft: topology: add 16 and 24 bit passthrough for nocodec Signed-off-by: Pierre-Louis Bossart --- topology/Makefile.am | 2 + ...test-passthrough-16bit-48k-ssp2-nocodec.m4 | 51 +++++++++++++++++++ ...test-passthrough-24bit-48k-ssp2-nocodec.m4 | 51 +++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 create mode 100644 topology/test-passthrough-24bit-48k-ssp2-nocodec.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index d9be79ed54e0..77c146fe4d9c 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -26,6 +26,8 @@ MACHINES = \ reef-byt-rt5651.tplg \ reef-byt-da7212.tplg \ reef-hsw-rt5640.tplg \ + test-passthrough-16bit-48k-ssp2-nocodec.tplg \ + test-passthrough-24bit-48k-ssp2-nocodec.tplg \ test-passthrough-24bit-48k-ssp2.tplg \ test-passthrough-24bit-48k-ssp2-SSP2-Codec.tplg \ test-passthrough-16bit-48k-ssp2-SSP2-Codec.tplg \ diff --git a/topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 b/topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 new file mode 100644 index 000000000000..a1c0988d551d --- /dev/null +++ b/topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 @@ -0,0 +1,51 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# + +# DAI Link Name +define(`TEST_DAI_LINK_NAME', `NoCodec') + +# +# Define the pipeline +# +# PCM0 ----> SSP2 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, + 1, 0, 2, s16le, + 48, 1000, 0, 0, 0, 1, + SSP, 2, s16le, 2) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# 24bit I2S using 25bit sample conatiner on SSP2 +# +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 16, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 1920000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 20, 3, 3)) diff --git a/topology/test-passthrough-24bit-48k-ssp2-nocodec.m4 b/topology/test-passthrough-24bit-48k-ssp2-nocodec.m4 new file mode 100644 index 000000000000..e0a3d4fcc23f --- /dev/null +++ b/topology/test-passthrough-24bit-48k-ssp2-nocodec.m4 @@ -0,0 +1,51 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# + +# DAI Link Name +define(`TEST_DAI_LINK_NAME', `NoCodec') + +# +# Define the pipeline +# +# PCM0 ----> SSP2 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, + 1, 0, 2, s24le, + 48, 1000, 0, 0, 0, 1, + SSP, 2, s24le, 2) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# 24bit I2S using 25bit sample conatiner on SSP2 +# +DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 24, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 25, 3, 3)) From bfe32ee87cef6a87f2533728592bea6aac728d30 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 6 Dec 2017 19:41:09 -0600 Subject: [PATCH 064/324] soft: topology: fix cht.m4 Not sure why we need these files, but the cht definitions are not aligned with the others. Fix. Signed-off-by: Pierre-Louis Bossart --- topology/dsps/cht.m4 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/topology/dsps/cht.m4 b/topology/dsps/cht.m4 index d315b0c04051..fdee83daeaa3 100644 --- a/topology/dsps/cht.m4 +++ b/topology/dsps/cht.m4 @@ -69,6 +69,20 @@ SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } +# PCM platform configuration +SectionVendorTuples."pcm_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC PIPELINE_DMAC + SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN + } +} + +SectionData."pcm_plat_conf" { + tuples "pcm_plat_tokens" +} + # DAI schedule Configuration - scheduled by IRQ SectionVendorTuples."pipe_dai_schedule_plat_tokens" { tokens "sof_sched_tokens" From 6dbbac5d13c79ced0e13ee8d9d92b2db8d55e16c Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 7 Dec 2017 21:18:15 +0000 Subject: [PATCH 065/324] topology: remove unused secondary media pcm Secondary PCM not used atm for 1.0 release so temporarily remove from standard topologies. Signed-off-by: Liam Girdwood --- topology/reef-apl-nocodec.m4 | 11 ----------- topology/reef-bdw-rt286.m4 | 11 ----------- topology/reef-bdw-rt5640.m4 | 11 ----------- topology/reef-bxt-nocodec.m4 | 11 ----------- topology/reef-hsw-rt5640.m4 | 11 ----------- 5 files changed, 55 deletions(-) diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index 89ac0b07fd06..d4ac6133aeaf 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -22,8 +22,6 @@ include(`dsps/bxt.m4') # |--low latency mixer ----> volume ----> SSP2 # PCM2 ----> SRC -----> volume ----+ # | -# PCM3 ----> SRC -----> volume ----+ -# | # Tone -----> volume ----+ # # PCM1 <---- Volume <---- SSP2 @@ -50,13 +48,6 @@ PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, 96, 2000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 2 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 4, 2, 2, s32le, - 96, 2000, 1, 0, 0, 4) - # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 PIPELINE_ADD(sof/pipe-tone.m4, @@ -70,8 +61,6 @@ SectionGraph."pipe-apl-nocodec" { lines [ # media 0 dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - # media 1 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index 969d5e0d5335..eaba2d969731 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -22,8 +22,6 @@ include(`dsps/bdw.m4') # |--low latency mixer ----> volume ----> SSP2 # PCM2 ----> SRC -----> volume ----+ # | -# PCM3 ----> SRC -----> volume ----+ -# | # Tone -----> volume ----+ # # PCM1 <---- Volume <---- SSP0 @@ -50,13 +48,6 @@ PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, 96, 2000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 2 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 4, 2, 2, s32le, - 96, 2000, 1, 0, 0, 4) - # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 PIPELINE_ADD(sof/pipe-tone.m4, @@ -70,8 +61,6 @@ SectionGraph."pipe-bdw-rt286" { lines [ # media 0 dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - # media 1 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index acf246299cf1..5d4485b96b5a 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -22,8 +22,6 @@ include(`dsps/bdw.m4') # |--low latency mixer ----> volume ----> SSP2 # PCM2 ----> SRC -----> volume ----+ # | -# PCM3 ----> SRC -----> volume ----+ -# | # Tone -----> volume ----+ # # PCM1 <---- Volume <---- SSP0 @@ -50,13 +48,6 @@ PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, 96, 2000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 2 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 4 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 4, 2, 2, s32le, - 96, 2000, 1, 0, 0, 4) - # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 PIPELINE_ADD(sof/pipe-tone.m4, @@ -70,8 +61,6 @@ SectionGraph."pipe-bdw-rt5640" { lines [ # media 0 dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - # media 1 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index 86cc3644237a..dbac98a62bde 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -22,8 +22,6 @@ include(`dsps/bxt.m4') # |--low latency mixer ----> volume ----> SSP2 # PCM2 ----> SRC -----> volume ----+ # | -# PCM3 ----> SRC -----> volume ----+ -# | # Tone -----> volume ----+ # # PCM1 <---- Volume <---- SSP2 @@ -50,13 +48,6 @@ PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, 192, 4000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 2 using max 2 channels of s32le. -# Schedule 192 frames per 4000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 2, 2, s32le, - 192, 4000, 1, 0, 0, 4) - # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 PIPELINE_ADD(sof/pipe-tone.m4, @@ -70,8 +61,6 @@ SectionGraph."pipe-bxt-nocodec" { lines [ # media 0 dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - # media 1 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index 8759704b5ea0..663686b0f528 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -22,8 +22,6 @@ include(`dsps/hsw.m4') # |--low latency mixer ----> volume ----> SSP2 # PCM2 ----> SRC -----> volume ----+ # | -# PCM3 ----> SRC -----> volume ----+ -# | # Tone -----> volume ----+ # # PCM1 <---- Volume <---- SSP0 @@ -50,13 +48,6 @@ PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, 192, 4000, 1, 0, 0, 3) -# PCM Media Playback pipeline 4 on PCM 2 using max 2 channels of s32le. -# Schedule 192 frames per 4000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 4, 2, 2, s32le, - 192, 4000, 1, 0, 0, 4) - # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 PIPELINE_ADD(sof/pipe-tone.m4, @@ -70,8 +61,6 @@ SectionGraph."pipe-hsw-rt5640" { lines [ # media 0 dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - # media 1 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_4) #tone dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) ] From 475fbdc01efa562729b28190eb356235d8d77481 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 11 Dec 2017 22:00:18 +0000 Subject: [PATCH 066/324] topology: Add passthrough capture pipe Signed-off-by: Liam Girdwood --- topology/sof/pipe-passthrough-capture.m4 | 70 ++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 topology/sof/pipe-passthrough-capture.m4 diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 new file mode 100644 index 000000000000..2c2a4957df87 --- /dev/null +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -0,0 +1,70 @@ +# Capture Passthrough Pipeline and PCM +# +# Pipeline Endpoints for connection are :- +# +# host PCM_C <-- B0 <-- sink DAI0 + +# Include topology builder +include(`local.m4') + + +# +# Components and Buffers +# + +# Host "Passthrough Capture" PCM uses pipeline DMAC and channel +# with 0 sink and 2 source periods +W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) + +# Capture Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + +# +# DAI definitions +# +W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0c_plat_conf) + +# +# DAI pipeline - always use 0 for DAIs +# +W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, 0, pipe_dai_schedule_plat) + +# +# Pipeline Graph +# +# host PCM_C <-- B0 <-- sink DAI0 + +SectionGraph."pipe-pass-capture-PIPELINE_ID" { + index STR(PIPELINE_ID) + + lines [ + dapm(Passthrough Capture PCM_ID, N_PCMC) + dapm(N_PCMC, N_BUFFER(0)) + ] +} + +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SINK_', PIPELINE_ID), N_BUFFER(0)) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID) + +# +# PCM Configuration +# + +SectionPCMCapabilities.STR(Passthrough Capture PCM_ID) { + + formats "S32_LE,S24_LE,S16_LE" + rate_min "48000" + rate_max "48000" + channels_min "2" + channels_max "4" + periods_min "2" + periods_max "16" + period_size_min "192" + period_size_max "16384" + buffer_size_min "65536" + buffer_size_max "65536" +} From 83b1704555cb6ac053ff7611081a139f45113f4a Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 11 Dec 2017 22:00:51 +0000 Subject: [PATCH 067/324] topology: Modify passthrough playback pipe for duplex operation Signed-off-by: Liam Girdwood --- topology/sof/pipe-passthrough-playback.m4 | 24 +++++------------------ 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index 2b34cef8660f..17222560926a 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -41,10 +41,14 @@ SectionGraph."pipe-pass-playback-PIPELINE_ID" { lines [ dapm(N_PCMP, Passthrough Playback PCM_ID) dapm(N_BUFFER(0), N_PCMP) - dapm(N_DAI_OUT, N_BUFFER(0)) ] } +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(0)) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_ID) # # PCM Configuration @@ -64,21 +68,3 @@ SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { buffer_size_min "65536" buffer_size_max "65536" } - -# PCM Low Latency Passthrough Playback -SectionPCM.STR(PCM PCM_ID) { - - index STR(PIPELINE_ID) - - # used for binding to the PCM - id STR(PCM_ID) - - dai.STR(Passthrough Playback PCM_ID) { - id STR(PCM_ID) - } - - pcm."playback" { - - capabilities STR(Passthrough Playback PCM_ID) - } -} From 796989d77408b357253e2877c8c5024f27060f5b Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 11 Dec 2017 22:02:42 +0000 Subject: [PATCH 068/324] topology: Add duplex support to test passthrough pipe Signed-off-by: Liam Girdwood --- ...test-passthrough-16bit-48k-ssp2-nocodec.m4 | 43 ++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 b/topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 index a1c0988d551d..76bd75b6ff00 100644 --- a/topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 +++ b/topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 @@ -25,24 +25,57 @@ define(`TEST_DAI_LINK_NAME', `NoCodec') # # Define the pipeline # -# PCM0 ----> SSP2 +# PCM0 <---> SSP2 # -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, - 1, 0, 2, s16le, +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, + 1, 0, 2, s16le, 48, 1000, 0, 0, 0, 1, SSP, 2, s16le, 2) + +# Passthrough playback pipeline 2 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-capture.m4, + 2, 0, 2, s16le, + 48, 1000, 0, 0, 0, 1, + SSP, 2, s16le, 2) + +# +# DAI configuration +# +# SSP port 2 is our only pipeline DAI +# + +# playback DAI is SSP2 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 2, + PIPELINE_SOURCE_1, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP2 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, 2, + PIPELINE_SINK_2, 2, s16le, + 48, 1000, 0, 0) + +# PCM Passthrough +PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + # # BE configurations - overrides config in ACPI if present # # Clocks masters wrt codec # -# 24bit I2S using 25bit sample conatiner on SSP2 +# 16bit I2S using 20bit sample conatiner on SSP2 # DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 16, DAI_CLOCK(mclk, 19200000, slave), From e094d38e9578df030b4e2fd11ff31f2f094d7992 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 11 Dec 2017 22:03:24 +0000 Subject: [PATCH 069/324] topology: Add passthrough volume capture pipe Signed-off-by: Liam Girdwood --- topology/sof/pipe-passthrough-vol-capture.m4 | 109 +++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 topology/sof/pipe-passthrough-vol-capture.m4 diff --git a/topology/sof/pipe-passthrough-vol-capture.m4 b/topology/sof/pipe-passthrough-vol-capture.m4 new file mode 100644 index 000000000000..258f8fa3d639 --- /dev/null +++ b/topology/sof/pipe-passthrough-vol-capture.m4 @@ -0,0 +1,109 @@ +# Passthrough with volume Pipeline and PCM +# +# Pipeline Endpoints for connection are :- +# +# host PCM_C <-- B0 <-- Volume 0 <-- B1 <-- source DAI0 + +# Include topology builder +include(`local.m4') + +# +# Controls +# +SectionControlMixer.STR(Master Capture Volume) { + + # control belongs to this index group + index STR(PIPELINE_ID) + + # Channel register and shift for Front Left/Right + channel."FL" { + reg "1" + shift "0" + } + channel."FR" { + reg "1" + shift "1" + } + + # control uses bespoke driver get/put/info ID 0 + ops."ctl" { + info "volsw" + get "256" + put "256" + } + + # TLV 32 steps from -90dB to +6dB for 3dB + max "32" + invert "false" + tlv "vtlv_m90s3" +} + +# +# Components and Buffers +# + +# Host "Passthrough Capture" PCM uses pipeline DMAC and channel +# with 0 sink and 2 source periods +W_PCM_CAPTURE(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) + +# "Volume" has 2 source and 2 sink periods +W_PGA(0, Master Capture Volume, PIPELINE_FORMAT, 2, 2, 2) + +# Playback Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) +W_BUFFER(1, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + +# +# DAI definitions +# +W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, + DAI_PERIODS, dai0c_plat_conf) + +# +# DAI pipeline - always use 0 for DAIs +# +W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, + SCHEDULE_CORE, 0, pipe_dai_schedule_plat) + +# +# Pipeline Graph +# +# host PCM_P <-- B0 <-- Volume 0 <-- B1 <-- sink DAI0 + +SectionGraph."pipe-pass-vol-capture-PIPELINE_ID" { + index STR(PIPELINE_ID) + + lines [ + dapm(Passthrough Capture PCM_ID, N_PCMC) + dapm(N_PCMC, N_BUFFER(0)) + dapm(N_BUFFER(0), N_PGA(0)) + dapm(N_PGA(0), N_BUFFER(1)) + ] +} + +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SINK_', PIPELINE_ID), N_BUFFER(1)) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID) + +# +# PCM Configuration +# + +SectionPCMCapabilities.STR(Passthrough Capture PCM_ID) { + + formats "S32_LE,S24_LE,S16_LE" + rate_min "48000" + rate_max "48000" + channels_min "2" + channels_max "4" + periods_min "2" + periods_max "16" + period_size_min "192" + period_size_max "16384" + buffer_size_min "65536" + buffer_size_max "65536" +} From e76aeeb7e9b2e99c13da8f9649d32dd3a4669829 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 11 Dec 2017 22:03:50 +0000 Subject: [PATCH 070/324] topology: modify passthrough volume playback for duplex operation Signed-off-by: Liam Girdwood --- topology/sof/pipe-passthrough-vol-playback.m4 | 24 +++++-------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/topology/sof/pipe-passthrough-vol-playback.m4 b/topology/sof/pipe-passthrough-vol-playback.m4 index 6e8aba4bee03..b5321613d453 100644 --- a/topology/sof/pipe-passthrough-vol-playback.m4 +++ b/topology/sof/pipe-passthrough-vol-playback.m4 @@ -80,10 +80,15 @@ SectionGraph."pipe-pass-vol-playback-PIPELINE_ID" { dapm(N_BUFFER(0), N_PCMP) dapm(N_PGA(0), N_BUFFER(0)) dapm(N_BUFFER(1), N_PGA(0)) - dapm(N_DAI_OUT, N_BUFFER(1)) ] } +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(1)) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_ID) + # # PCM Configuration @@ -104,20 +109,3 @@ SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { buffer_size_max "65536" } -# PCM Passthrough Playback -SectionPCM.STR(PCM PCM_ID) { - - index STR(PIPELINE_ID) - - # used for binding to the PCM - id STR(PCM_ID) - - dai.STR(Passthrough Playback PCM_ID) { - id STR(PCM_ID) - } - - pcm."playback" { - - capabilities STR(Passthrough Playback PCM_ID) - } -} From 19e3240ec762a612372296dac3c2ae662be5d02c Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 11 Dec 2017 22:04:19 +0000 Subject: [PATCH 071/324] topology: Add duplex support to 24 bit volume passthrough Signed-off-by: Liam Girdwood --- .../test-passthrough-24bit-48k-vol-ssp2.m4 | 34 ++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/topology/test-passthrough-24bit-48k-vol-ssp2.m4 b/topology/test-passthrough-24bit-48k-vol-ssp2.m4 index 707178276302..89775a79ba66 100644 --- a/topology/test-passthrough-24bit-48k-vol-ssp2.m4 +++ b/topology/test-passthrough-24bit-48k-vol-ssp2.m4 @@ -25,7 +25,7 @@ define(`TEST_DAI_LINK_NAME', `Baytrail Audio') # # Define the pipeline # -# PCM0 ---> volume ---> SSP2 +# PCM0 <---> volume <---> SSP2 # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. @@ -37,6 +37,38 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-vol-playback.m4, 48, 1000, 0, 0, 0, 1, SSP, 2, s24le, 2) +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-vol-capture.m4, + 2, 0, 2, s24le, + 48, 1000, 0, 0, 0, 1, + SSP, 2, s24le, 2) + +# +# DAI configuration +# +# SSP port 2 is our only pipeline DAI +# + +# playback DAI is SSP2 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 2, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) + +# capture DAI is SSP2 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, 2, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) + +# PCM Passthrough +PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + # # BE configurations - overrides config in ACPI if present # From 88519eee7345b38bcb86568bd73734c0cf89bf3d Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 13 Dec 2017 22:17:54 +0800 Subject: [PATCH 072/324] topology: fix 2 typos for capture pipeline 1. Widget N_PCMC type should be "aif_in", not "aif_out". 2. Widget W_DAI_IN data should be "N_DAI_IN", not "N_DAI_OUT". Signed-off-by: Xiuli Pan Signed-off-by: Keyon Jie --- topology/m4/local.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index da20e1c99c8d..08425eda5cc6 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -131,7 +131,7 @@ define(`W_PCM_CAPTURE', `}' `SectionWidget."'N_PCMC`" {' ` index "'PIPELINE_ID`"' -` type "aif_out"' +` type "aif_in"' ` no_pm "true"' ` stream_name "'$1`"' ` data [' @@ -358,7 +358,7 @@ define(`W_DAI_IN', ` "'N_DAI_IN($2)`_data_w"' ` "'N_DAI_IN($2)`_data_w_comp"' ` "'N_DAI_IN($2)`_data_str"' -` "'N_DAI_OUT($2)`_data_comp_str"' +` "'N_DAI_IN($2)`_data_comp_str"' ` "'$7`"' ` ]' `}') From 8b254b5f3de4191fca1e92624815f6be504d1639 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 13 Dec 2017 21:03:51 +0000 Subject: [PATCH 073/324] topology: AIF directions are codec centric wrt PCMs Commit 0a1a9bbc492e4eb22173ed57c7f5499c8f106289 discovered a bug in the direction of AIF widgets in relation to PCMs. AIF widgets are codec centric in ASoC so topology must align. Signed-off-by: Liam Girdwood --- topology/m4/local.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 08425eda5cc6..c0ffef2f9e77 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -96,7 +96,7 @@ define(`W_PCM_PLAYBACK', `}' `SectionWidget."'N_PCMP`" {' ` index "'PIPELINE_ID`"' -` type "aif_out"' +` type "aif_in"' ` no_pm "true"' ` stream_name "'$1`"' ` data [' @@ -131,7 +131,7 @@ define(`W_PCM_CAPTURE', `}' `SectionWidget."'N_PCMC`" {' ` index "'PIPELINE_ID`"' -` type "aif_in"' +` type "aif_out"' ` no_pm "true"' ` stream_name "'$1`"' ` data [' From c20762ecac5e0153faf21a203def0511a896090e Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 13 Dec 2017 15:50:41 +0000 Subject: [PATCH 074/324] topology: test: Add simple component test generator. Move testing pipelines into a test directory and reuse test scaffolding so that they can be used to test multiple components on multiple target with multiples configs. Test topology scafolding are now pre-processed using a script to generate the ALSA conf format with the various changes for each test case. Signed-off-by: Liam Girdwood --- .gitignore | 1 + configure.ac | 1 + topology/Makefile.am | 11 +-- topology/sof/pipe-src-capture.m4 | 95 +++++++++++++++++++ ...h-src-playback.m4 => pipe-src-playback.m4} | 23 +---- ...-vol-capture.m4 => pipe-volume-capture.m4} | 0 ...ol-playback.m4 => pipe-volume-playback.m4} | 0 ...t-passthrough-16bit-48k-ssp2-SSP2-Codec.m4 | 51 ---------- ...test-passthrough-16bit-48k-ssp2-nocodec.m4 | 84 ---------------- topology/test-passthrough-16bit-48k-ssp2.m4 | 51 ---------- .../test-passthrough-24bit-48k-src-ssp2.m4 | 51 ---------- ...t-passthrough-24bit-48k-ssp2-SSP2-Codec.m4 | 51 ---------- ...test-passthrough-24bit-48k-ssp2-nocodec.m4 | 51 ---------- topology/test-passthrough-24bit-48k-ssp2.m4 | 51 ---------- .../test-passthrough-24bit-48k-vol-ssp2.m4 | 83 ---------------- topology/test/Makefile.am | 20 ++++ topology/test/test-src-ssp.m4 | 90 ++++++++++++++++++ topology/test/test-ssp.m4 | 90 ++++++++++++++++++ topology/test/tplg-build.sh | 66 +++++++++++++ 19 files changed, 371 insertions(+), 499 deletions(-) create mode 100644 topology/sof/pipe-src-capture.m4 rename topology/sof/{pipe-passthrough-src-playback.m4 => pipe-src-playback.m4} (85%) rename topology/sof/{pipe-passthrough-vol-capture.m4 => pipe-volume-capture.m4} (100%) rename topology/sof/{pipe-passthrough-vol-playback.m4 => pipe-volume-playback.m4} (100%) delete mode 100644 topology/test-passthrough-16bit-48k-ssp2-SSP2-Codec.m4 delete mode 100644 topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 delete mode 100644 topology/test-passthrough-16bit-48k-ssp2.m4 delete mode 100644 topology/test-passthrough-24bit-48k-src-ssp2.m4 delete mode 100644 topology/test-passthrough-24bit-48k-ssp2-SSP2-Codec.m4 delete mode 100644 topology/test-passthrough-24bit-48k-ssp2-nocodec.m4 delete mode 100644 topology/test-passthrough-24bit-48k-ssp2.m4 delete mode 100644 topology/test-passthrough-24bit-48k-vol-ssp2.m4 create mode 100644 topology/test/Makefile.am create mode 100644 topology/test/test-src-ssp.m4 create mode 100644 topology/test/test-ssp.m4 create mode 100755 topology/test/tplg-build.sh diff --git a/.gitignore b/.gitignore index bc827b41e876..023e26404641 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,4 @@ rmbox/rmbox rwav/rwav *.tplg topology/*.conf +topology/test/*.conf diff --git a/configure.ac b/configure.ac index 87c75194f508..1b4f59b249db 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,7 @@ AC_OUTPUT([ rimage/Makefile rmbox/Makefile topology/Makefile + topology/test/Makefile ]) echo " diff --git a/topology/Makefile.am b/topology/Makefile.am index 77c146fe4d9c..3cbc5e64fe51 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -3,6 +3,8 @@ # Dependencies # +SUBDIRS = test + DEPS = \ dsps/*.m4 \ common/*.m4 \ @@ -25,14 +27,7 @@ MACHINES = \ reef-byt-rt5645.tplg \ reef-byt-rt5651.tplg \ reef-byt-da7212.tplg \ - reef-hsw-rt5640.tplg \ - test-passthrough-16bit-48k-ssp2-nocodec.tplg \ - test-passthrough-24bit-48k-ssp2-nocodec.tplg \ - test-passthrough-24bit-48k-ssp2.tplg \ - test-passthrough-24bit-48k-ssp2-SSP2-Codec.tplg \ - test-passthrough-16bit-48k-ssp2-SSP2-Codec.tplg \ - test-passthrough-24bit-48k-vol-ssp2.tplg \ - test-passthrough-24bit-48k-src-ssp2.tplg + reef-hsw-rt5640.tplg # Uncomment the following line if you want to debug conf files .PRECIOUS: %.conf diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 new file mode 100644 index 000000000000..9484ca8f2819 --- /dev/null +++ b/topology/sof/pipe-src-capture.m4 @@ -0,0 +1,95 @@ +# Low Latency Passthrough with volume Pipeline and PCM +# +# Pipeline Endpoints for connection are :- +# +# host PCM_P --> SRC --> sink DAI0 + +# Include topology builder +include(`local.m4') + + +# +# Components and Buffers +# + +# Host "Passthrough Playback" PCM uses pipeline DMAC and channel +# with 4 sink and 0 source periods +W_PCM_PLAYBACK(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) + +# +# SRC Configuration +# + +SectionVendorTuples."media_src_tokens" { + tokens "sof_src_tokens" + + tuples."word" { + SOF_TKN_SRC_RATE_OUT "48000" + } +} + +SectionData."media_src_conf" { + tuples "media_src_tokens" +} + +# "SRC" has 4 source and 4 sink periods +W_SRC(0, PIPELINE_FORMAT, 4, 4, media_src_conf, 2) + +# Playback Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(4, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) +W_BUFFER(1, COMP_BUFFER_SIZE(4, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + +# +# DAI definitions +# +W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, + DAI_PERIODS, dai0c_plat_conf) + +# +# DAI pipeline +# +W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, + SCHEDULE_CORE, 0, pipe_dai_schedule_plat) + +# +# Pipeline Graph +# +# host PCM_P --> B0 --> SRC 0 --> B1 --> sink DAI0 + +SectionGraph."pipe-pass-src-capture-PIPELINE_ID" { + index STR(PIPELINE_ID) + + lines [ + dapm(Passthrough Capture PCM_ID, N_PCMC) + dapm(N_PCMC, N_BUFFER(0)) + dapm(N_BUFFER(0), N_SRC(0)) + dapm(N_SRC(0), N_BUFFER(1)) + ] +} + +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SINK_', PIPELINE_ID), N_BUFFER(1)) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID) + +# +# PCM Configuration +# + +SectionPCMCapabilities.STR(Passthrough Capture PCM_ID) { + + formats "S32_LE,S24_LE,S16_LE" + rate_min "8000" + rate_max "96000" + channels_min "2" + channels_max "4" + periods_min "2" + periods_max "16" + period_size_min "192" + period_size_max "16384" + buffer_size_min "65536" + buffer_size_max "65536" +} diff --git a/topology/sof/pipe-passthrough-src-playback.m4 b/topology/sof/pipe-src-playback.m4 similarity index 85% rename from topology/sof/pipe-passthrough-src-playback.m4 rename to topology/sof/pipe-src-playback.m4 index b8fae58dcb8f..d03754389666 100644 --- a/topology/sof/pipe-passthrough-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -66,10 +66,14 @@ SectionGraph."pipe-pass-src-playback-PIPELINE_ID" { dapm(N_BUFFER(0), N_PCMP) dapm(N_SRC(0), N_BUFFER(0)) dapm(N_BUFFER(1), N_SRC(0)) - dapm(N_DAI_OUT, N_BUFFER(1)) ] } +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(1)) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_ID) # # PCM Configuration @@ -90,20 +94,3 @@ SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { buffer_size_max "65536" } -# PCM Passthrough Playback -SectionPCM.STR(PCM PCM_ID) { - - index STR(PIPELINE_ID) - - # used for binding to the PCM - id STR(PCM_ID) - - dai.STR(Passthrough Playback PCM_ID) { - id STR(PCM_ID) - } - - pcm."playback" { - - capabilities STR(Passthrough Playback PCM_ID) - } -} diff --git a/topology/sof/pipe-passthrough-vol-capture.m4 b/topology/sof/pipe-volume-capture.m4 similarity index 100% rename from topology/sof/pipe-passthrough-vol-capture.m4 rename to topology/sof/pipe-volume-capture.m4 diff --git a/topology/sof/pipe-passthrough-vol-playback.m4 b/topology/sof/pipe-volume-playback.m4 similarity index 100% rename from topology/sof/pipe-passthrough-vol-playback.m4 rename to topology/sof/pipe-volume-playback.m4 diff --git a/topology/test-passthrough-16bit-48k-ssp2-SSP2-Codec.m4 b/topology/test-passthrough-16bit-48k-ssp2-SSP2-Codec.m4 deleted file mode 100644 index e93041662063..000000000000 --- a/topology/test-passthrough-16bit-48k-ssp2-SSP2-Codec.m4 +++ /dev/null @@ -1,51 +0,0 @@ -# -# Topology for pass through pipeline -# - -# Include topology builder -include(`local.m4') -include(`build.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include Baytrail DSP configuration -include(`dsps/byt.m4') - -# -# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! -# - -# DAI Link Name -define(`TEST_DAI_LINK_NAME', `SSP2-Codec') - -# -# Define the pipeline -# -# PCM0 ----> SSP2 -# - -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, - 1, 0, 2, s16le, - 48, 1000, 0, 0, 0, 1, - SSP, 2, s16le, 2) - -# -# BE configurations - overrides config in ACPI if present -# -# Clocks masters wrt codec -# -# 24bit I2S using 25bit sample conatiner on SSP2 -# -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 16, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 1920000, slave), - DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 20, 3, 3)) diff --git a/topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 b/topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 deleted file mode 100644 index 76bd75b6ff00..000000000000 --- a/topology/test-passthrough-16bit-48k-ssp2-nocodec.m4 +++ /dev/null @@ -1,84 +0,0 @@ -# -# Topology for pass through pipeline -# - -# Include topology builder -include(`local.m4') -include(`build.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include Baytrail DSP configuration -include(`dsps/byt.m4') - -# -# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! -# - -# DAI Link Name -define(`TEST_DAI_LINK_NAME', `NoCodec') - -# -# Define the pipeline -# -# PCM0 <---> SSP2 -# - -# Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, - 1, 0, 2, s16le, - 48, 1000, 0, 0, 0, 1, - SSP, 2, s16le, 2) - - -# Passthrough playback pipeline 2 on PCM 0 using max 2 channels of s24le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-capture.m4, - 2, 0, 2, s16le, - 48, 1000, 0, 0, 0, 1, - SSP, 2, s16le, 2) - -# -# DAI configuration -# -# SSP port 2 is our only pipeline DAI -# - -# playback DAI is SSP2 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, - PIPELINE_SOURCE_1, 2, s16le, - 48, 1000, 0, 0) - -# capture DAI is SSP2 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, - PIPELINE_SINK_2, 2, s16le, - 48, 1000, 0, 0) - -# PCM Passthrough -PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) - -# -# BE configurations - overrides config in ACPI if present -# -# Clocks masters wrt codec -# -# 16bit I2S using 20bit sample conatiner on SSP2 -# -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 16, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 1920000, slave), - DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 20, 3, 3)) diff --git a/topology/test-passthrough-16bit-48k-ssp2.m4 b/topology/test-passthrough-16bit-48k-ssp2.m4 deleted file mode 100644 index 7bf4aaf5df06..000000000000 --- a/topology/test-passthrough-16bit-48k-ssp2.m4 +++ /dev/null @@ -1,51 +0,0 @@ -# -# Topology for pass through pipeline -# - -# Include topology builder -include(`local.m4') -include(`build.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include Baytrail DSP configuration -include(`dsps/byt.m4') - -# -# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! -# - -# DAI Link Name -define(`TEST_DAI_LINK_NAME', `Baytrail Audio') - -# -# Define the pipeline -# -# PCM0 ----> SSP2 -# - -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s16le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, - 1, 0, 2, s16le, - 48, 1000, 0, 0, 0, 1, - SSP, 2, s16le, 2) - -# -# BE configurations - overrides config in ACPI if present -# -# Clocks masters wrt codec -# -# 16bit I2S using 20bit sample conatiner on SSP2 -# -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 16, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 1920000, slave), - DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 20, 3, 3)) diff --git a/topology/test-passthrough-24bit-48k-src-ssp2.m4 b/topology/test-passthrough-24bit-48k-src-ssp2.m4 deleted file mode 100644 index 61c06e12b81f..000000000000 --- a/topology/test-passthrough-24bit-48k-src-ssp2.m4 +++ /dev/null @@ -1,51 +0,0 @@ -# -# Topology for pass through pipeline -# - -# Include topology builder -include(`local.m4') -include(`build.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include Baytrail DSP configuration -include(`dsps/byt.m4') - -# -# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! -# - -# DAI Link Name -define(`TEST_DAI_LINK_NAME', `Baytrail Audio') - -# -# Define the pipeline -# -# PCM0 ---> volume ---> SSP2 -# - -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-src-playback.m4, - 1, 0, 2, s24le, - 48, 1000, 0, 0, 0, 1, - SSP, 2, s24le, 2) - -# -# BE configurations - overrides config in ACPI if present -# -# Clocks masters wrt codec -# -# 24bit I2S using 25bit sample conatiner on SSP2 -# -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 25, 3, 3)) diff --git a/topology/test-passthrough-24bit-48k-ssp2-SSP2-Codec.m4 b/topology/test-passthrough-24bit-48k-ssp2-SSP2-Codec.m4 deleted file mode 100644 index 7e481d372d33..000000000000 --- a/topology/test-passthrough-24bit-48k-ssp2-SSP2-Codec.m4 +++ /dev/null @@ -1,51 +0,0 @@ -# -# Topology for pass through pipeline -# - -# Include topology builder -include(`local.m4') -include(`build.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include Baytrail DSP configuration -include(`dsps/byt.m4') - -# -# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! -# - -# DAI Link Name -define(`TEST_DAI_LINK_NAME', `SSP2-Codec') - -# -# Define the pipeline -# -# PCM0 ----> SSP2 -# - -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, - 1, 0, 2, s24le, - 48, 1000, 0, 0, 0, 1, - SSP, 2, s24le, 2) - -# -# BE configurations - overrides config in ACPI if present -# -# Clocks masters wrt codec -# -# 24bit I2S using 25bit sample conatiner on SSP2 -# -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 25, 3, 3)) diff --git a/topology/test-passthrough-24bit-48k-ssp2-nocodec.m4 b/topology/test-passthrough-24bit-48k-ssp2-nocodec.m4 deleted file mode 100644 index e0a3d4fcc23f..000000000000 --- a/topology/test-passthrough-24bit-48k-ssp2-nocodec.m4 +++ /dev/null @@ -1,51 +0,0 @@ -# -# Topology for pass through pipeline -# - -# Include topology builder -include(`local.m4') -include(`build.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include Baytrail DSP configuration -include(`dsps/byt.m4') - -# -# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! -# - -# DAI Link Name -define(`TEST_DAI_LINK_NAME', `NoCodec') - -# -# Define the pipeline -# -# PCM0 ----> SSP2 -# - -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, - 1, 0, 2, s24le, - 48, 1000, 0, 0, 0, 1, - SSP, 2, s24le, 2) - -# -# BE configurations - overrides config in ACPI if present -# -# Clocks masters wrt codec -# -# 24bit I2S using 25bit sample conatiner on SSP2 -# -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 25, 3, 3)) diff --git a/topology/test-passthrough-24bit-48k-ssp2.m4 b/topology/test-passthrough-24bit-48k-ssp2.m4 deleted file mode 100644 index ca3261d22733..000000000000 --- a/topology/test-passthrough-24bit-48k-ssp2.m4 +++ /dev/null @@ -1,51 +0,0 @@ -# -# Topology for pass through pipeline -# - -# Include topology builder -include(`local.m4') -include(`build.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include Baytrail DSP configuration -include(`dsps/byt.m4') - -# -# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! -# - -# DAI Link Name -define(`TEST_DAI_LINK_NAME', `Baytrail Audio') - -# -# Define the pipeline -# -# PCM0 ----> SSP2 -# - -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-playback.m4, - 1, 0, 2, s24le, - 48, 1000, 0, 0, 0, 1, - SSP, 2, s24le, 2) - -# -# BE configurations - overrides config in ACPI if present -# -# Clocks masters wrt codec -# -# 24bit I2S using 25bit sample conatiner on SSP2 -# -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 25, 3, 3)) diff --git a/topology/test-passthrough-24bit-48k-vol-ssp2.m4 b/topology/test-passthrough-24bit-48k-vol-ssp2.m4 deleted file mode 100644 index 89775a79ba66..000000000000 --- a/topology/test-passthrough-24bit-48k-vol-ssp2.m4 +++ /dev/null @@ -1,83 +0,0 @@ -# -# Topology for pass through pipeline -# - -# Include topology builder -include(`local.m4') -include(`build.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include Baytrail DSP configuration -include(`dsps/byt.m4') - -# -# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! -# - -# DAI Link Name -define(`TEST_DAI_LINK_NAME', `Baytrail Audio') - -# -# Define the pipeline -# -# PCM0 <---> volume <---> SSP2 -# - -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-vol-playback.m4, - 1, 0, 2, s24le, - 48, 1000, 0, 0, 0, 1, - SSP, 2, s24le, 2) - -# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s24le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-vol-capture.m4, - 2, 0, 2, s24le, - 48, 1000, 0, 0, 0, 1, - SSP, 2, s24le, 2) - -# -# DAI configuration -# -# SSP port 2 is our only pipeline DAI -# - -# playback DAI is SSP2 using 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, - PIPELINE_SOURCE_1, 2, s24le, - 48, 1000, 0, 0) - -# capture DAI is SSP2 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, - PIPELINE_SINK_2, 2, s24le, - 48, 1000, 0, 0) - -# PCM Passthrough -PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) - -# -# BE configurations - overrides config in ACPI if present -# -# Clocks masters wrt codec -# -# 24bit I2S using 25bit sample conatiner on SSP2 -# -DAI_CONFIG(SSP, 2, TEST_DAI_LINK_NAME, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 25, 3, 3)) diff --git a/topology/test/Makefile.am b/topology/test/Makefile.am new file mode 100644 index 000000000000..7da075d70102 --- /dev/null +++ b/topology/test/Makefile.am @@ -0,0 +1,20 @@ + +# +# Dependencies +# + +DEPS = \ + ../dsps/*.m4 \ + ../common/*.m4 \ + ../m4/*.m4 \ + ../sof/*.m4 + +# Uncomment the following line if you want to debug conf files +.PRECIOUS: %.conf + +all : *.m4 ${DEPS} + ./tplg-build.sh + +clean: + rm -f *.conf + rm -f *.tplg diff --git a/topology/test/test-src-ssp.m4 b/topology/test/test-src-ssp.m4 new file mode 100644 index 000000000000..4a0723ee3516 --- /dev/null +++ b/topology/test/test-src-ssp.m4 @@ -0,0 +1,90 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# +# TEST_PIPE_NAME - Pipe name +# TEST_DAI_LINK_NAME - BE DAI link name e.g. "NoCodec" +# TEST_SSP_PORT - SSP port number e.g. 2 +# TEST_SSP_FORMAT - SSP data format e.g s16le +# TEST_PIPE_FORMAT - Pipeline format e.g. s16le +# TEST_SSP_BCLK - SSP BCLK in Hz +# TEST_SSP_PHY_BITS - SSP physical slot size +# TEST_SSP_DATA_BITS - SSP data slot size +# + +# +# Define the pipeline +# +# PCM0 <--> SRC <--> SSP TEST_SSP_PORT +# + +# Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-playback.m4, + 1, 0, 2, TEST_PIPE_FORMAT, + 48, 1000, 0, 0, 0, 1, + SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) + + +# Passthrough playback pipeline 2 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-capture.m4, + 2, 0, 2, TEST_PIPE_FORMAT, + 48, 1000, 0, 0, 0, 1, + SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) + +# +# DAI configuration +# +# SSP port TEST_SSP_PORT is our only pipeline DAI +# + +# playback DAI is SSP TEST_SSP_PORT using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, TEST_SSP_PORT, + PIPELINE_SOURCE_1, 2, TEST_SSP_FORMAT, + 48, 1000, 0, 0) + +# capture DAI is SSP TEST_SSP_PORT using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, TEST_SSP_PORT, + PIPELINE_SINK_2, 2, TEST_SSP_FORMAT, + 48, 1000, 0, 0) + +# PCM Passthrough +PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT +# +DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/test-ssp.m4 b/topology/test/test-ssp.m4 new file mode 100644 index 000000000000..ff2756e1cb8c --- /dev/null +++ b/topology/test/test-ssp.m4 @@ -0,0 +1,90 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# +# TEST_PIPE_NAME - Pipe name +# TEST_DAI_LINK_NAME - BE DAI link name e.g. "NoCodec" +# TEST_SSP_PORT - SSP port number e.g. 2 +# TEST_SSP_FORMAT - SSP data format e.g s16le +# TEST_PIPE_FORMAT - Pipeline format e.g. s16le +# TEST_SSP_BCLK - SSP BCLK in Hz +# TEST_SSP_PHY_BITS - SSP physical slot size +# TEST_SSP_DATA_BITS - SSP data slot size +# + +# +# Define the pipeline +# +# PCM0 <---> SSP TEST_SSP_PORT +# + +# Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-playback.m4, + 1, 0, 2, TEST_PIPE_FORMAT, + 48, 1000, 0, 0, 0, 1, + SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) + + +# Passthrough playback pipeline 2 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-capture.m4, + 2, 0, 2, TEST_PIPE_FORMAT, + 48, 1000, 0, 0, 0, 1, + SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) + +# +# DAI configuration +# +# SSP port TEST_SSP_PORT is our only pipeline DAI +# + +# playback DAI is SSP TEST_SSP_PORT using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, TEST_SSP_PORT, + PIPELINE_SOURCE_1, 2, TEST_SSP_FORMAT, + 48, 1000, 0, 0) + +# capture DAI is SSP TEST_SSP_PORT using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, TEST_SSP_PORT, + PIPELINE_SINK_2, 2, TEST_SSP_FORMAT, + 48, 1000, 0, 0) + +# PCM Passthrough +PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT +# +DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh new file mode 100755 index 000000000000..5c81638f4033 --- /dev/null +++ b/topology/test/tplg-build.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +# Utility script to pre-process and compile topology sources into topology test +# binaries. Currently supports simple PCM <-> component <-> SSP style tests +# using simple_test() + +# fail immediately on any errors +set -e + +# M4 preprocessor flags +M4_FLAGS="-I ../ -I ../m4" + +# Simple component test cases +# can be used on components with 1 sink and 1 source. +SIMPLE_TESTS=(test-ssp test-src-ssp) + +# process m4 simple tests - +# simple_test(name, pipe_name, be_name, format, dai_id, dai_format, dai_phy_bits, dai_data_bits dai_bclk) +# 1) name - test filename suffix +# 2) pipe_name - test component pipeline filename in sof/ +# 3) be_name - BE DAI link name in machine driver, used for matching +# 4) format - PCM sample format +# 5) dai_id - SSP port number +# 6) dai_format - SSP sample format +# 7) dai_phy_bits - SSP physical number of BLKCs per slot/channel +# 8) dai_data_bits - SSP number of valid daat bits per slot/channel +# 9) dai_bclk - SSP BCLK in HZ +# +function simple_test { + for i in ${SIMPLE_TESTS[@]} + do + TFILE="$i$5-$4-48k-$1" + echo "M4 pre-processing test $i -> ${TFILE}" + m4 ${M4_FLAGS} \ + -DTEST_PIPE_NAME="$2" \ + -DTEST_DAI_LINK_NAME="$3" \ + -DTEST_SSP_PORT=$5 \ + -DTEST_SSP_FORMAT=$6 \ + -DTEST_PIPE_FORMAT=$4 \ + -DTEST_SSP_BCLK=$9 \ + -DTEST_SSP_PHY_BITS=$7 \ + -DTEST_SSP_DATA_BITS=$8 \ + $i.m4 > ${TFILE}.conf + echo "Compiling test $i -> ${TFILE}.tplg" + alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg + done +} + +# Pre-process the simple tests +simple_test nocodec passthrough "NoCodec" s16le 2 s16le 20 16 1920000 +simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 +simple_test nocodec volume "NoCodec" s16le 2 s16le 20 16 1920000 +simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 +simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 + +simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 +simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 +simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 +simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 +simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 + +simple_test baytrail passthrough "Baytrail Audio" s16le 2 s16le 20 16 1920000 +simple_test baytrail passthrough "Baytrail Audio" s24le 2 s24le 25 24 2400000 +simple_test baytrail volume "Baytrail Audio" s16le 2 s16le 20 16 1920000 +simple_test baytrail volume "Baytrail Audio" s24le 2 s24le 25 24 2400000 +simple_test baytrail volume "Baytrail Audio" s16le 2 s24le 25 24 2400000 From 90856416b6e6d29003856af4f2599804f3cab92e Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Mon, 18 Dec 2017 11:52:11 +0800 Subject: [PATCH 075/324] topology: test: Refine name for test generator. We have 5 critical arguments in the test generator but only used 3 for the naming, this will make some files be overwritten. Refine the name method to let these 5 arguments show in the tplg name. Also we decide the pipe type in one of the argument, test-ssp.m4 and test-src-ssp.m4 are almost the same, just remove one. Signed-off-by: Pan Xiuli --- topology/test/test-src-ssp.m4 | 90 ----------------------------------- topology/test/test-ssp.m4 | 2 +- topology/test/tplg-build.sh | 4 +- 3 files changed, 3 insertions(+), 93 deletions(-) delete mode 100644 topology/test/test-src-ssp.m4 diff --git a/topology/test/test-src-ssp.m4 b/topology/test/test-src-ssp.m4 deleted file mode 100644 index 4a0723ee3516..000000000000 --- a/topology/test/test-src-ssp.m4 +++ /dev/null @@ -1,90 +0,0 @@ -# -# Topology for pass through pipeline -# - -# Include topology builder -include(`local.m4') -include(`build.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include Baytrail DSP configuration -include(`dsps/byt.m4') - -# -# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! -# -# TEST_PIPE_NAME - Pipe name -# TEST_DAI_LINK_NAME - BE DAI link name e.g. "NoCodec" -# TEST_SSP_PORT - SSP port number e.g. 2 -# TEST_SSP_FORMAT - SSP data format e.g s16le -# TEST_PIPE_FORMAT - Pipeline format e.g. s16le -# TEST_SSP_BCLK - SSP BCLK in Hz -# TEST_SSP_PHY_BITS - SSP physical slot size -# TEST_SSP_DATA_BITS - SSP data slot size -# - -# -# Define the pipeline -# -# PCM0 <--> SRC <--> SSP TEST_SSP_PORT -# - -# Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-playback.m4, - 1, 0, 2, TEST_PIPE_FORMAT, - 48, 1000, 0, 0, 0, 1, - SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) - - -# Passthrough playback pipeline 2 on PCM 0 using max 2 channels of s24le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data - -PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-capture.m4, - 2, 0, 2, TEST_PIPE_FORMAT, - 48, 1000, 0, 0, 0, 1, - SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) - -# -# DAI configuration -# -# SSP port TEST_SSP_PORT is our only pipeline DAI -# - -# playback DAI is SSP TEST_SSP_PORT using 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, TEST_SSP_PORT, - PIPELINE_SOURCE_1, 2, TEST_SSP_FORMAT, - 48, 1000, 0, 0) - -# capture DAI is SSP TEST_SSP_PORT using 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, TEST_SSP_PORT, - PIPELINE_SINK_2, 2, TEST_SSP_FORMAT, - 48, 1000, 0, 0) - -# PCM Passthrough -PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) - -# -# BE configurations - overrides config in ACPI if present -# -# Clocks masters wrt codec -# -# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT -# -DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), - DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/test-ssp.m4 b/topology/test/test-ssp.m4 index ff2756e1cb8c..92e91bfcbfb9 100644 --- a/topology/test/test-ssp.m4 +++ b/topology/test/test-ssp.m4 @@ -31,7 +31,7 @@ include(`dsps/byt.m4') # # Define the pipeline # -# PCM0 <---> SSP TEST_SSP_PORT +# PCM0 <-- TEST_PIPE_NAME pipe --> SSP TEST_SSP_PORT # # Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 5c81638f4033..a73335a9d3e1 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -12,7 +12,7 @@ M4_FLAGS="-I ../ -I ../m4" # Simple component test cases # can be used on components with 1 sink and 1 source. -SIMPLE_TESTS=(test-ssp test-src-ssp) +SIMPLE_TESTS=(test-ssp) # process m4 simple tests - # simple_test(name, pipe_name, be_name, format, dai_id, dai_format, dai_phy_bits, dai_data_bits dai_bclk) @@ -29,7 +29,7 @@ SIMPLE_TESTS=(test-ssp test-src-ssp) function simple_test { for i in ${SIMPLE_TESTS[@]} do - TFILE="$i$5-$4-48k-$1" + TFILE="$i$5-$2-$4-$6-48k-$1" echo "M4 pre-processing test $i -> ${TFILE}" m4 ${M4_FLAGS} \ -DTEST_PIPE_NAME="$2" \ From c3bd8620329ad17246dcc7539cf3de2ed792c083 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Mon, 18 Dec 2017 11:52:12 +0800 Subject: [PATCH 076/324] topology: m4: Add two macros for one direction PCM We may need to generate capture only or playback only PCMs. Add these macros to help generate them. Signed-off-by: Pan Xiuli --- topology/m4/local.m4 | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index c0ffef2f9e77..ad72a117dcc7 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -476,6 +476,44 @@ define(`COMP_SAMPLE_SIZE', dnl COMP_BUFFER_SIZE( num_periods, sample_size, channels, fmames) define(`COMP_BUFFER_SIZE', `eval(`$1 * $2 * $3 * $4')') +dnl PCM_PLAYBACK_ADD(name, pipeline, pcm_id, dai_id, playback) +define(`PCM_PLAYBACK_ADD', +`SectionPCM.STR($1) {' +`' +` index STR($2)' +`' +` # used for binding to the PCM' +` id STR($3)' +`' +` dai.STR($1 $3) {' +` id STR($4)' +` }' +`' +` pcm."playback" {' +`' +` capabilities STR($5)' +` }' +`}') + +dnl PCM_CAPTURE_ADD(name, pipeline, pcm_id, dai_id, capture) +define(`PCM_CAPTURE_ADD', +`SectionPCM.STR($1) {' +`' +` index STR($2)' +`' +` # used for binding to the PCM' +` id STR($3)' +`' +` dai.STR($1 $3) {' +` id STR($4)' +` }' +`' +` pcm."capture" {' +`' +` capabilities STR($5)' +` }' +`}') + dnl PCM_DUPLEX_ADD(name, pipeline, pcm_id, dai_id, playback, capture) define(`PCM_DUPLEX_ADD', `SectionPCM.STR($1) {' From a0b92925083f445893d79118fb33f337e52dcad5 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Mon, 18 Dec 2017 11:52:13 +0800 Subject: [PATCH 077/324] topology: test: Add capture and playback only test. We may need these test for validation, add these tests. Signed-off-by: Pan Xiuli --- topology/test/test-capture-ssp.m4 | 72 ++++++++++++++++++++++++++++++ topology/test/test-playback-ssp.m4 | 72 ++++++++++++++++++++++++++++++ topology/test/tplg-build.sh | 2 +- 3 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 topology/test/test-capture-ssp.m4 create mode 100644 topology/test/test-playback-ssp.m4 diff --git a/topology/test/test-capture-ssp.m4 b/topology/test/test-capture-ssp.m4 new file mode 100644 index 000000000000..613e66662aa7 --- /dev/null +++ b/topology/test/test-capture-ssp.m4 @@ -0,0 +1,72 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# +# TEST_PIPE_NAME - Pipe name +# TEST_DAI_LINK_NAME - BE DAI link name e.g. "NoCodec" +# TEST_SSP_PORT - SSP port number e.g. 2 +# TEST_SSP_FORMAT - SSP data format e.g s16le +# TEST_PIPE_FORMAT - Pipeline format e.g. s16le +# TEST_SSP_BCLK - SSP BCLK in Hz +# TEST_SSP_PHY_BITS - SSP physical slot size +# TEST_SSP_DATA_BITS - SSP data slot size +# + +# +# Define the pipeline +# +# PCM0 <---> SSP TEST_SSP_PORT +# + +# Passthrough playback pipeline 2 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-capture.m4, + 2, 0, 2, TEST_PIPE_FORMAT, + 48, 1000, 0, 0, 0, 1, + SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) + +# +# DAI configuration +# +# SSP port TEST_SSP_PORT is our only pipeline DAI +# +# capture DAI is SSP TEST_SSP_PORT using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, TEST_SSP_PORT, + PIPELINE_SINK_2, 2, TEST_SSP_FORMAT, + 48, 1000, 0, 0) + +# PCM Passthrough +PCM_CAPTURE_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_2) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT +# +DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/test-playback-ssp.m4 b/topology/test/test-playback-ssp.m4 new file mode 100644 index 000000000000..351b8af57ffc --- /dev/null +++ b/topology/test/test-playback-ssp.m4 @@ -0,0 +1,72 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# +# TEST_PIPE_NAME - Pipe name +# TEST_DAI_LINK_NAME - BE DAI link name e.g. "NoCodec" +# TEST_SSP_PORT - SSP port number e.g. 2 +# TEST_SSP_FORMAT - SSP data format e.g s16le +# TEST_PIPE_FORMAT - Pipeline format e.g. s16le +# TEST_SSP_BCLK - SSP BCLK in Hz +# TEST_SSP_PHY_BITS - SSP physical slot size +# TEST_SSP_DATA_BITS - SSP data slot size +# + +# +# Define the pipeline +# +# PCM0 <---> SSP TEST_SSP_PORT +# + +# Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-playback.m4, + 1, 0, 2, TEST_PIPE_FORMAT, + 48, 1000, 0, 0, 0, 1, + SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) +# +# DAI configuration +# +# SSP port TEST_SSP_PORT is our only pipeline DAI +# + +# playback DAI is SSP TEST_SSP_PORT using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, TEST_SSP_PORT, + PIPELINE_SOURCE_1, 2, TEST_SSP_FORMAT, + 48, 1000, 0, 0) + +# PCM Passthrough +PCM_PLAYBACK_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT +# +DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index a73335a9d3e1..86bcfd7287c3 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -12,7 +12,7 @@ M4_FLAGS="-I ../ -I ../m4" # Simple component test cases # can be used on components with 1 sink and 1 source. -SIMPLE_TESTS=(test-ssp) +SIMPLE_TESTS=(test-ssp test-capture-ssp test-playback-ssp) # process m4 simple tests - # simple_test(name, pipe_name, be_name, format, dai_id, dai_format, dai_phy_bits, dai_data_bits dai_bclk) From 2307a6ace20198e22c53944d2954e4b4740b7437 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 9 Jun 2017 14:25:36 +0100 Subject: [PATCH 078/324] rimage: update to new SOF driver file format. Support the SOF driver file format. Signed-off-by: Liam Girdwood --- rimage/baytrail.c | 73 ++++++++----------- rimage/cherrytrail.c | 9 ++- rimage/file_format.h | 166 +++++++++++++++++++++++++------------------ rimage/rimage.c | 26 +++---- rimage/rimage.h | 11 +++ 5 files changed, 151 insertions(+), 134 deletions(-) diff --git a/rimage/baytrail.c b/rimage/baytrail.c index 4324e706130c..ed1c8409effe 100644 --- a/rimage/baytrail.c +++ b/rimage/baytrail.c @@ -40,17 +40,6 @@ static const struct section byt_sections[] = { {"NMIExceptionVector", 0xff2c061c}, }; -static const enum reef_module_id modules[] = { - REEF_MODULE_BASE_FW, - REEF_MODULE_AAC_5_1, - REEF_MODULE_PCM, - REEF_MODULE_PCM_SYSTEM, - REEF_MODULE_PCM_CAPTURE, - REEF_MODULE_PCM_REFERENCE, - REEF_MODULE_BLUETOOTH_RENDER_MODULE, - REEF_MODULE_BLUETOOTH_CAPTURE_MODULE, -}; - static int is_iram(struct image *image, Elf32_Shdr *section) { const struct adsp *adsp = image->adsp; @@ -86,7 +75,7 @@ static int block_idx = 0; static int write_block(struct image *image, Elf32_Shdr *section) { const struct adsp *adsp = image->adsp; - struct dma_block_info block; + struct snd_sof_blk_hdr block; size_t count; void *buffer; int ret; @@ -94,11 +83,13 @@ static int write_block(struct image *image, Elf32_Shdr *section) block.size = section->sh_size; if (is_iram(image, section)) { - block.type = REEF_IRAM; - block.ram_offset = section->sh_addr - adsp->iram_base; + block.type = SOF_BLK_TEXT; + block.offset = section->sh_addr - adsp->iram_base + + adsp->host_iram_offset; } else if (is_dram(image, section)) { - block.type = REEF_DRAM; - block.ram_offset = section->sh_addr - adsp->dram_base; + block.type = SOF_BLK_DATA; + block.offset = section->sh_addr - adsp->dram_base + + adsp->host_dram_offset; } else { fprintf(stderr, "error: invalid block address/size 0x%x/0x%x\n", section->sh_addr, section->sh_size); @@ -153,18 +144,18 @@ static int write_block(struct image *image, Elf32_Shdr *section) int byt_write_modules(struct image *image) { const struct adsp *adsp = image->adsp; - struct byt_module_header hdr; + struct snd_sof_mod_hdr hdr; Elf32_Shdr *section; size_t count; int i, err; uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - memcpy(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE); - hdr.blocks = image->num_sections - image->num_bss; - hdr.mod_size = image->text_size + image->data_size + \ - sizeof(struct dma_block_info) * hdr.blocks; - hdr.type = REEF_MODULE_BASE_FW; - hdr.entry_point = 0;//section->sh_addr; + fprintf(stdout, "Using BYT file format\n"); + + hdr.num_blocks = image->num_sections - image->num_bss; + hdr.size = image->text_size + image->data_size + + sizeof(struct snd_sof_blk_hdr) * hdr.num_blocks; + hdr.type = SOF_FW_BASE; count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); if (count != 1) { @@ -192,41 +183,28 @@ int byt_write_modules(struct image *image) } } - /* write the remaining 7 fake modules headers, to make the linux driver happy */ - hdr.mod_size = 0; - hdr.blocks = 0; - - for (i = 1; i < sizeof(modules) / sizeof(modules[0]); i++) { - hdr.type = modules[i]; - count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); - if (count != 1) { - fprintf(stderr, "error: failed to write section header %d\n", i); - return -errno ; - } - } - return 0; } /* used by others */ int byt_write_header(struct image *image) { - struct fw_header hdr; + struct snd_sof_fw_header hdr; size_t count; - memcpy(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE); + memcpy(hdr.sig, SND_SOF_FW_SIG, SND_SOF_FW_SIG_SIZE); - hdr.modules = sizeof(modules) / sizeof(modules[0]); - hdr.file_format = 0; + hdr.num_modules = 1; + hdr.abi = SND_SOF_FW_ABI; - image->fw_size += sizeof(struct dma_block_info) * + image->fw_size += sizeof(struct snd_sof_blk_hdr) * (image->num_sections - image->num_bss); - image->fw_size += sizeof(struct byt_module_header) * hdr.modules; + image->fw_size += sizeof(struct snd_sof_mod_hdr) * hdr.num_modules; hdr.file_size = image->fw_size; fprintf(stdout, "fw: image size %ld (0x%lx) bytes %d modules\n\n", hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), - hdr.modules); + hdr.num_modules); count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); if (count != 1) return -errno; @@ -234,14 +212,19 @@ int byt_write_header(struct image *image) return 0; } +#define IRAM_OFFSET 0x0C0000 +#define IRAM_SIZE (80 * 1024) +#define DRAM_OFFSET 0x100000 +#define DRAM_SIZE (160 * 1024) + const struct adsp byt_machine = { .name = "byt", .iram_base = 0xff2c0000, .iram_size = 0x14000, + .host_iram_offset = IRAM_OFFSET, .dram_base = 0xff300000, .dram_size = 0x28000, - .image_size = 0xff300000 - 0xff2c0000 + 0x28000, - .dram_offset = 0xff300000 - 0xff2c0000, + .host_dram_offset = DRAM_OFFSET, .machine_id = MACHINE_BAYTRAIL, .ops = { .write_header = byt_write_header, diff --git a/rimage/cherrytrail.c b/rimage/cherrytrail.c index a37a13db2353..e27bea63e565 100644 --- a/rimage/cherrytrail.c +++ b/rimage/cherrytrail.c @@ -40,14 +40,19 @@ static const struct section cht_sections[] = { {"NMIExceptionVector", 0xff2c061c}, }; +#define IRAM_OFFSET 0x0C0000 +#define IRAM_SIZE (80 * 1024) +#define DRAM_OFFSET 0x100000 +#define DRAM_SIZE (160 * 1024) + const struct adsp cht_machine = { .name = "cht", .iram_base = 0xff2c0000, .iram_size = 0x14000, + .host_iram_offset = IRAM_OFFSET, .dram_base = 0xff300000, .dram_size = 0x28000, - .image_size = 0xff300000 - 0xff2c0000 + 0x28000, - .dram_offset = 0xff300000 - 0xff2c0000, + .host_dram_offset = DRAM_OFFSET, .machine_id = MACHINE_CHERRYTRAIL, .ops = { .write_header = byt_write_header, diff --git a/rimage/file_format.h b/rimage/file_format.h index 941df332549f..c813f49c0bc2 100644 --- a/rimage/file_format.h +++ b/rimage/file_format.h @@ -1,88 +1,116 @@ /* - * ELF to firmware image creator. + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. * - * Copyright (c) 2015, Intel Corporation. + * GPL LICENSE SUMMARY * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. + * Copyright(c) 2017 Intel Corporation. All rights reserved. * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * BSD LICENSE + * + * Copyright(c) 2017 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Liam Girdwood */ -#ifndef __FILE_FORMAT_H__ -#define __FILE_FORMAT_H__ +/* + * Firmware file format . + */ -#define REEF_FW_SIGNATURE_SIZE 4 -#define REEF_FW_SIGN "$SST" -#define REEF_FW_LIB_SIGN "$LIB" +#ifndef __INCLUDE_UAPI_SOF_FW_H__ +#define __INCLUDE_UAPI_SOF_FW_H__ -#define REEF_IRAM 1 -#define REEF_DRAM 2 -#define REEF_REGS 3 -#define REEF_CACHE 3 +#define SND_SOF_FW_SIG_SIZE 4 +#define SND_SOF_FW_ABI 1 +#define SND_SOF_FW_SIG "Reef" -enum reef_module_id { - REEF_MODULE_BASE_FW = 0x0, - REEF_MODULE_MP3 = 0x1, - REEF_MODULE_AAC_5_1 = 0x2, - REEF_MODULE_AAC_2_0 = 0x3, - REEF_MODULE_SRC = 0x4, - REEF_MODULE_WAVES = 0x5, - REEF_MODULE_DOLBY = 0x6, - REEF_MODULE_BOOST = 0x7, - REEF_MODULE_LPAL = 0x8, - REEF_MODULE_DTS = 0x9, - REEF_MODULE_PCM_CAPTURE = 0xA, - REEF_MODULE_PCM_SYSTEM = 0xB, - REEF_MODULE_PCM_REFERENCE = 0xC, - REEF_MODULE_PCM = 0xD, - REEF_MODULE_BLUETOOTH_RENDER_MODULE = 0xE, - REEF_MODULE_BLUETOOTH_CAPTURE_MODULE = 0xF, - REEF_MAX_MODULE_ID, +/* + * Firmware module is made up of 1 . N blocks of different types. The + * Block header is used to determine where and how block is to be copied in the + * DSP/host memory space. + */ +enum snd_sof_fw_blk_type { + SOF_BLK_IMAGE = 0, /* whole image - parsed by ROMs */ + SOF_BLK_TEXT = 1, + SOF_BLK_DATA = 2, + SOF_BLK_CACHE = 3, + SOF_BLK_REGS = 4, + SOF_BLK_SIG = 5, + SOF_BLK_ROM = 6, + /* add new block types here */ }; -struct dma_block_info { - uint32_t type; /* IRAM/DRAM */ - uint32_t size; /* Bytes */ - uint32_t ram_offset; /* Offset in I/DRAM */ - uint32_t rsvd; /* Reserved field */ +struct snd_sof_blk_hdr { + enum snd_sof_fw_blk_type type; + uint32_t size; /* bytes minus this header */ + uint32_t offset; /* offset from base */ } __attribute__((packed)); -struct fw_module_info { - uint32_t persistent_size; - uint32_t scratch_size; -} __attribute__((packed)); +/* + * Firmware file is made up of 1 .. N different modules types. The module + * type is used to determine how to load and parse the module. + */ +enum snd_sof_fw_mod_type { + SOF_FW_BASE = 0, /* base firmware image */ + SOF_FW_MODULE = 1, /* firmware module */ +}; -struct fw_header { - unsigned char signature[REEF_FW_SIGNATURE_SIZE]; /* FW signature */ - uint32_t file_size; /* size of fw minus this header */ - uint32_t modules; /* # of modules */ - uint32_t file_format; /* version of header format */ - uint32_t reserved[4]; +struct snd_sof_mod_hdr { + enum snd_sof_fw_mod_type type; + uint32_t size; /* bytes minus this header */ + uint32_t num_blocks; /* number of blocks */ } __attribute__((packed)); -/* ABI 0 - used by reef driver and CoE BDW/HSW firmware*/ -struct hsw_module_header { - unsigned char signature[REEF_FW_SIGNATURE_SIZE]; /* module signature */ - uint32_t mod_size; /* size of module */ - uint32_t blocks; /* # of blocks */ - uint16_t padding; - uint16_t type; /* codec type, pp lib */ - uint32_t entry_point; - struct fw_module_info info; +/* + * Firmware file header. + */ +struct snd_sof_fw_header { + unsigned char sig[SND_SOF_FW_SIG_SIZE]; /* "Reef" */ + uint32_t file_size; /* size of file minus this header */ + uint32_t num_modules; /* number of modules */ + uint32_t abi; /* version of header format */ } __attribute__((packed)); -/* ABI 1 - used by CoE/MCG BYT/CHT/BSW driver */ -struct byt_module_header { - unsigned char signature[REEF_FW_SIGNATURE_SIZE]; - uint32_t mod_size; /* size of module */ - uint32_t blocks; /* # of blocks */ - uint32_t type; /* codec type, pp lib */ - uint32_t entry_point; -}__attribute__((packed)); - #endif diff --git a/rimage/rimage.c b/rimage/rimage.c index a5db6d5d71e9..af57f5a55d3c 100644 --- a/rimage/rimage.c +++ b/rimage/rimage.c @@ -226,9 +226,12 @@ int main(int argc, char *argv[]) { struct image image; const char *mach = NULL; - int opt, ret, i, binary = 0; + int opt, ret, i; memset(&image, 0, sizeof(image)); + image.text_start = 0xffffffff; + image.data_start = 0xffffffff; + image.bss_start = 0xffffffff; while ((opt = getopt(argc, argv, "ho:i:m:vba:sk:")) != -1) { switch (opt) { @@ -244,9 +247,6 @@ int main(int argc, char *argv[]) case 'v': image.verbose = 1; break; - case 'b': - binary = 1; - break; case 's': image.dump_sections = 1; break; @@ -285,26 +285,16 @@ int main(int argc, char *argv[]) image.in_file, errno); } - /* open outfile for reading */ + /* open outfile for writing */ + unlink(image.out_file); image.out_fd = fopen(image.out_file, "w"); if (image.out_fd == NULL) { fprintf(stderr, "error: unable to open %s for writing %d\n", image.out_file, errno); } - if (binary) { - - switch(image.adsp->machine_id) { - case MACHINE_BAYTRAIL: - ret = write_byt_binary_image(&image); - break; - default: - fprintf(stderr, "error: not supported machine for binary input!\n"); - return ret; - } - - } else - ret = write_elf_data(&image); + /* write data */ + ret = write_elf_data(&image); /* close files */ fclose(image.out_fd); diff --git a/rimage/rimage.h b/rimage/rimage.h index 2c029328ceaa..9b8200afa36d 100644 --- a/rimage/rimage.h +++ b/rimage/rimage.h @@ -50,6 +50,13 @@ struct image { int data_size; int file_size; int num_modules; + uint32_t text_start; + uint32_t text_end; + uint32_t data_start; + uint32_t data_end; + uint32_t bss_start; + uint32_t bss_end; + /* disa */ void *in_buffer; @@ -82,8 +89,12 @@ struct adsp { uint32_t iram_size; uint32_t dram_base; uint32_t dram_size; + uint32_t host_iram_offset; + uint32_t host_dram_offset; + uint32_t image_size; uint32_t dram_offset; + enum machine_id machine_id; struct adsp_ops ops; const struct section *sections; From 106192c58c12f9e4c94cdccde8edee145e94733a Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 9 Jun 2017 14:24:51 +0100 Subject: [PATCH 079/324] rimage: remove flat file builder. No longer needed so can be safely removed. Signed-off-by: Liam Girdwood --- rimage/Makefile.am | 4 +- rimage/flat.c | 256 --------------------------------------------- 2 files changed, 2 insertions(+), 258 deletions(-) delete mode 100644 rimage/flat.c diff --git a/rimage/Makefile.am b/rimage/Makefile.am index 32335fe68957..0ba8ce6f4c4d 100644 --- a/rimage/Makefile.am +++ b/rimage/Makefile.am @@ -6,5 +6,5 @@ noinst_HEADERS = \ rimage_SOURCES = \ cherrytrail.c \ baytrail.c \ - flat.c \ - rimage.c \ No newline at end of file + rimage.c + diff --git a/rimage/flat.c b/rimage/flat.c deleted file mode 100644 index 8c5d1c58b557..000000000000 --- a/rimage/flat.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * ELF to firmware image creator. - * - * Copyright (c) 2015, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#include -#include -#include -#include -#include - -#include "rimage.h" -#include "file_format.h" - -static int dump_section(struct image *image, struct dma_block_info *block, - void *data) -{ - const struct adsp *adsp = image->adsp; - uint32_t addr; - - switch (block->type) { - case REEF_IRAM: - addr = block->ram_offset + adsp->iram_base; - break; - case REEF_DRAM: - addr = block->ram_offset + adsp->dram_base; - break; - case REEF_CACHE: - addr = block->ram_offset + adsp->dram_base; - break; - default: - return -EINVAL; - } -} - -static int read_byt_bin_module(struct image *image, - struct byt_module_header *module) -{ - const struct adsp *adsp = image->adsp; - struct dma_block_info *block; - int count, offset; - void *data; - - block = (void *)module + sizeof(*module); - - for (count = 0; count < module->blocks; count++) { - - if (block->size <= 0) { - fprintf(stderr, "block %d size invalid\n", count); - return -EINVAL; - } - - switch (block->type) { - case REEF_IRAM: - offset = block->ram_offset + 0; - break; - case REEF_DRAM: - offset = block->ram_offset + - adsp->dram_offset; - break; - case REEF_CACHE: - offset = block->ram_offset + - adsp->dram_offset; - break; - default: - fprintf(stderr, "wrong ram type 0x%x in block0x%x\n", - block->type, count); - return -EINVAL; - } - - fprintf(stdout, "bin: block %d type %d offset 0x%x size 0x%x\n", - count, block->type, offset, block->size); - - data = (void *)block + sizeof(*block); - memcpy(image->out_buffer + offset, data, block->size); - - if (image->dump_sections) - dump_section(image, block, data); - - block = (void *)block + sizeof(*block) + block->size; - } - - return 0; -} - -static int read_bdw_bin_module(struct image *image, - struct hsw_module_header *module) -{ - const struct adsp *adsp = image->adsp; - struct dma_block_info *block; - int count, offset; - void *data; - - block = (void *)module + sizeof(*module); - - for (count = 0; count < module->blocks; count++) { - - if (block->size <= 0) { - fprintf(stderr, "block %d size invalid\n", count); - return -EINVAL; - } - - switch (block->type) { - case REEF_IRAM: - offset = block->ram_offset + 0; - break; - case REEF_DRAM: - offset = block->ram_offset + - adsp->dram_offset; - break; - case REEF_CACHE: - offset = block->ram_offset + - adsp->dram_offset; - break; - default: - fprintf(stderr, "wrong ram type 0x%x in block0x%x\n", - block->type, count); - return -EINVAL; - } - - fprintf(stdout, "bin: block %d type %d offset 0x%x size 0x%x\n", - count, block->type, offset, block->size); - - data = (void *)block + sizeof(*block); - memcpy(image->out_buffer + offset, data, block->size); - - if (image->dump_sections) - dump_section(image, block, data); - - block = (void *)block + sizeof(*block) + block->size; - } - - return 0; -} - -static int read_bin_data(struct image *image) -{ - const struct adsp *adsp = image->adsp; - struct fw_header hdr; - size_t count; - - count = fread(&hdr, sizeof(hdr), 1, image->in_fd); - if (count != 1) - return -errno; - - if (strncmp(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE)) { - fprintf(stderr, "invalid header signature: %c%c%c%c\n", - hdr.signature[0], hdr.signature[1], - hdr.signature[2], hdr.signature[3]); - return -EINVAL; - } - - image->fw_size = hdr.file_size; - image->num_modules = hdr.modules; - - fprintf(stdout, "bin: input image size %ld (0x%lx) bytes %d modules\n", - hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), - hdr.modules); - fprintf(stdout, "bin: output image size %d (0x%x) bytes\n", - adsp->image_size, - adsp->image_size); - - image->in_buffer = calloc(image->fw_size, 1); - if (image->in_buffer == NULL) - return -ENOMEM; - - count = fread(image->in_buffer, image->fw_size, 1, image->in_fd); - if (count != 1) { - free(image->in_buffer); - return -errno; - } - - image->out_buffer = calloc(adsp->image_size, 1); - if (image->out_buffer == NULL) { - free(image->in_buffer); - return -ENOMEM; - } - - return 0; -} - -int write_byt_binary_image(struct image *image) -{ - const struct adsp *adsp = image->adsp; - struct byt_module_header *module; - int ret, count; - - ret = read_bin_data(image); - if (ret < 0) - return ret; - - module = (void *)image->in_buffer; - - for (count = 0; count < image->num_modules; count++) { - - fprintf(stdout, "bin: module %d type %d blocks %d size 0x%x\n", - count, module->type, module->blocks, module->mod_size); - - ret = read_byt_bin_module(image, module); - if (ret < 0) { - fprintf(stderr, "invalid module %d\n", count); - return ret; - } - module = (void *)module + sizeof(*module) + module->mod_size; - } - - count = fwrite(image->out_buffer, adsp->image_size, 1, - image->out_fd); - if (count != adsp->image_size) - return -errno; - - return ret; -} - -int write_bdw_binary_image(struct image *image) -{ - const struct adsp *adsp = image->adsp; - struct hsw_module_header *module; - int ret, count; - - ret = read_bin_data(image); - if (ret < 0) - return ret; - - module = (void *)image->in_buffer; - - for (count = 0; count < image->num_modules; count++) { - - fprintf(stdout, "bin: module %d type %d blocks %d size 0x%x\n", - count, module->type, module->blocks, module->mod_size); - - ret = read_bdw_bin_module(image, module); - if (ret < 0) { - fprintf(stderr, "invalid module %d\n", count); - return ret; - } - module = (void *)module + sizeof(*module) + module->mod_size; - } - - count = fwrite(image->out_buffer, adsp->image_size, 1, - image->out_fd); - if (count != adsp->image_size) - return -errno; - - return ret; -} From bd363e16311ba10e9535b12c37fdcfc0382e956b Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 9 Jun 2017 14:25:36 +0100 Subject: [PATCH 080/324] rimage: update to new SOF driver file format. Support the SOF driver file format. Signed-off-by: Liam Girdwood --- rimage/baytrail.c | 73 ++++++++----------- rimage/cherrytrail.c | 9 ++- rimage/file_format.h | 166 +++++++++++++++++++++++++------------------ rimage/rimage.c | 26 +++---- rimage/rimage.h | 11 +++ 5 files changed, 151 insertions(+), 134 deletions(-) diff --git a/rimage/baytrail.c b/rimage/baytrail.c index 4324e706130c..ed1c8409effe 100644 --- a/rimage/baytrail.c +++ b/rimage/baytrail.c @@ -40,17 +40,6 @@ static const struct section byt_sections[] = { {"NMIExceptionVector", 0xff2c061c}, }; -static const enum reef_module_id modules[] = { - REEF_MODULE_BASE_FW, - REEF_MODULE_AAC_5_1, - REEF_MODULE_PCM, - REEF_MODULE_PCM_SYSTEM, - REEF_MODULE_PCM_CAPTURE, - REEF_MODULE_PCM_REFERENCE, - REEF_MODULE_BLUETOOTH_RENDER_MODULE, - REEF_MODULE_BLUETOOTH_CAPTURE_MODULE, -}; - static int is_iram(struct image *image, Elf32_Shdr *section) { const struct adsp *adsp = image->adsp; @@ -86,7 +75,7 @@ static int block_idx = 0; static int write_block(struct image *image, Elf32_Shdr *section) { const struct adsp *adsp = image->adsp; - struct dma_block_info block; + struct snd_sof_blk_hdr block; size_t count; void *buffer; int ret; @@ -94,11 +83,13 @@ static int write_block(struct image *image, Elf32_Shdr *section) block.size = section->sh_size; if (is_iram(image, section)) { - block.type = REEF_IRAM; - block.ram_offset = section->sh_addr - adsp->iram_base; + block.type = SOF_BLK_TEXT; + block.offset = section->sh_addr - adsp->iram_base + + adsp->host_iram_offset; } else if (is_dram(image, section)) { - block.type = REEF_DRAM; - block.ram_offset = section->sh_addr - adsp->dram_base; + block.type = SOF_BLK_DATA; + block.offset = section->sh_addr - adsp->dram_base + + adsp->host_dram_offset; } else { fprintf(stderr, "error: invalid block address/size 0x%x/0x%x\n", section->sh_addr, section->sh_size); @@ -153,18 +144,18 @@ static int write_block(struct image *image, Elf32_Shdr *section) int byt_write_modules(struct image *image) { const struct adsp *adsp = image->adsp; - struct byt_module_header hdr; + struct snd_sof_mod_hdr hdr; Elf32_Shdr *section; size_t count; int i, err; uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - memcpy(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE); - hdr.blocks = image->num_sections - image->num_bss; - hdr.mod_size = image->text_size + image->data_size + \ - sizeof(struct dma_block_info) * hdr.blocks; - hdr.type = REEF_MODULE_BASE_FW; - hdr.entry_point = 0;//section->sh_addr; + fprintf(stdout, "Using BYT file format\n"); + + hdr.num_blocks = image->num_sections - image->num_bss; + hdr.size = image->text_size + image->data_size + + sizeof(struct snd_sof_blk_hdr) * hdr.num_blocks; + hdr.type = SOF_FW_BASE; count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); if (count != 1) { @@ -192,41 +183,28 @@ int byt_write_modules(struct image *image) } } - /* write the remaining 7 fake modules headers, to make the linux driver happy */ - hdr.mod_size = 0; - hdr.blocks = 0; - - for (i = 1; i < sizeof(modules) / sizeof(modules[0]); i++) { - hdr.type = modules[i]; - count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); - if (count != 1) { - fprintf(stderr, "error: failed to write section header %d\n", i); - return -errno ; - } - } - return 0; } /* used by others */ int byt_write_header(struct image *image) { - struct fw_header hdr; + struct snd_sof_fw_header hdr; size_t count; - memcpy(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE); + memcpy(hdr.sig, SND_SOF_FW_SIG, SND_SOF_FW_SIG_SIZE); - hdr.modules = sizeof(modules) / sizeof(modules[0]); - hdr.file_format = 0; + hdr.num_modules = 1; + hdr.abi = SND_SOF_FW_ABI; - image->fw_size += sizeof(struct dma_block_info) * + image->fw_size += sizeof(struct snd_sof_blk_hdr) * (image->num_sections - image->num_bss); - image->fw_size += sizeof(struct byt_module_header) * hdr.modules; + image->fw_size += sizeof(struct snd_sof_mod_hdr) * hdr.num_modules; hdr.file_size = image->fw_size; fprintf(stdout, "fw: image size %ld (0x%lx) bytes %d modules\n\n", hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), - hdr.modules); + hdr.num_modules); count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); if (count != 1) return -errno; @@ -234,14 +212,19 @@ int byt_write_header(struct image *image) return 0; } +#define IRAM_OFFSET 0x0C0000 +#define IRAM_SIZE (80 * 1024) +#define DRAM_OFFSET 0x100000 +#define DRAM_SIZE (160 * 1024) + const struct adsp byt_machine = { .name = "byt", .iram_base = 0xff2c0000, .iram_size = 0x14000, + .host_iram_offset = IRAM_OFFSET, .dram_base = 0xff300000, .dram_size = 0x28000, - .image_size = 0xff300000 - 0xff2c0000 + 0x28000, - .dram_offset = 0xff300000 - 0xff2c0000, + .host_dram_offset = DRAM_OFFSET, .machine_id = MACHINE_BAYTRAIL, .ops = { .write_header = byt_write_header, diff --git a/rimage/cherrytrail.c b/rimage/cherrytrail.c index a37a13db2353..e27bea63e565 100644 --- a/rimage/cherrytrail.c +++ b/rimage/cherrytrail.c @@ -40,14 +40,19 @@ static const struct section cht_sections[] = { {"NMIExceptionVector", 0xff2c061c}, }; +#define IRAM_OFFSET 0x0C0000 +#define IRAM_SIZE (80 * 1024) +#define DRAM_OFFSET 0x100000 +#define DRAM_SIZE (160 * 1024) + const struct adsp cht_machine = { .name = "cht", .iram_base = 0xff2c0000, .iram_size = 0x14000, + .host_iram_offset = IRAM_OFFSET, .dram_base = 0xff300000, .dram_size = 0x28000, - .image_size = 0xff300000 - 0xff2c0000 + 0x28000, - .dram_offset = 0xff300000 - 0xff2c0000, + .host_dram_offset = DRAM_OFFSET, .machine_id = MACHINE_CHERRYTRAIL, .ops = { .write_header = byt_write_header, diff --git a/rimage/file_format.h b/rimage/file_format.h index 941df332549f..c813f49c0bc2 100644 --- a/rimage/file_format.h +++ b/rimage/file_format.h @@ -1,88 +1,116 @@ /* - * ELF to firmware image creator. + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. * - * Copyright (c) 2015, Intel Corporation. + * GPL LICENSE SUMMARY * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. + * Copyright(c) 2017 Intel Corporation. All rights reserved. * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * BSD LICENSE + * + * Copyright(c) 2017 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Author: Liam Girdwood */ -#ifndef __FILE_FORMAT_H__ -#define __FILE_FORMAT_H__ +/* + * Firmware file format . + */ -#define REEF_FW_SIGNATURE_SIZE 4 -#define REEF_FW_SIGN "$SST" -#define REEF_FW_LIB_SIGN "$LIB" +#ifndef __INCLUDE_UAPI_SOF_FW_H__ +#define __INCLUDE_UAPI_SOF_FW_H__ -#define REEF_IRAM 1 -#define REEF_DRAM 2 -#define REEF_REGS 3 -#define REEF_CACHE 3 +#define SND_SOF_FW_SIG_SIZE 4 +#define SND_SOF_FW_ABI 1 +#define SND_SOF_FW_SIG "Reef" -enum reef_module_id { - REEF_MODULE_BASE_FW = 0x0, - REEF_MODULE_MP3 = 0x1, - REEF_MODULE_AAC_5_1 = 0x2, - REEF_MODULE_AAC_2_0 = 0x3, - REEF_MODULE_SRC = 0x4, - REEF_MODULE_WAVES = 0x5, - REEF_MODULE_DOLBY = 0x6, - REEF_MODULE_BOOST = 0x7, - REEF_MODULE_LPAL = 0x8, - REEF_MODULE_DTS = 0x9, - REEF_MODULE_PCM_CAPTURE = 0xA, - REEF_MODULE_PCM_SYSTEM = 0xB, - REEF_MODULE_PCM_REFERENCE = 0xC, - REEF_MODULE_PCM = 0xD, - REEF_MODULE_BLUETOOTH_RENDER_MODULE = 0xE, - REEF_MODULE_BLUETOOTH_CAPTURE_MODULE = 0xF, - REEF_MAX_MODULE_ID, +/* + * Firmware module is made up of 1 . N blocks of different types. The + * Block header is used to determine where and how block is to be copied in the + * DSP/host memory space. + */ +enum snd_sof_fw_blk_type { + SOF_BLK_IMAGE = 0, /* whole image - parsed by ROMs */ + SOF_BLK_TEXT = 1, + SOF_BLK_DATA = 2, + SOF_BLK_CACHE = 3, + SOF_BLK_REGS = 4, + SOF_BLK_SIG = 5, + SOF_BLK_ROM = 6, + /* add new block types here */ }; -struct dma_block_info { - uint32_t type; /* IRAM/DRAM */ - uint32_t size; /* Bytes */ - uint32_t ram_offset; /* Offset in I/DRAM */ - uint32_t rsvd; /* Reserved field */ +struct snd_sof_blk_hdr { + enum snd_sof_fw_blk_type type; + uint32_t size; /* bytes minus this header */ + uint32_t offset; /* offset from base */ } __attribute__((packed)); -struct fw_module_info { - uint32_t persistent_size; - uint32_t scratch_size; -} __attribute__((packed)); +/* + * Firmware file is made up of 1 .. N different modules types. The module + * type is used to determine how to load and parse the module. + */ +enum snd_sof_fw_mod_type { + SOF_FW_BASE = 0, /* base firmware image */ + SOF_FW_MODULE = 1, /* firmware module */ +}; -struct fw_header { - unsigned char signature[REEF_FW_SIGNATURE_SIZE]; /* FW signature */ - uint32_t file_size; /* size of fw minus this header */ - uint32_t modules; /* # of modules */ - uint32_t file_format; /* version of header format */ - uint32_t reserved[4]; +struct snd_sof_mod_hdr { + enum snd_sof_fw_mod_type type; + uint32_t size; /* bytes minus this header */ + uint32_t num_blocks; /* number of blocks */ } __attribute__((packed)); -/* ABI 0 - used by reef driver and CoE BDW/HSW firmware*/ -struct hsw_module_header { - unsigned char signature[REEF_FW_SIGNATURE_SIZE]; /* module signature */ - uint32_t mod_size; /* size of module */ - uint32_t blocks; /* # of blocks */ - uint16_t padding; - uint16_t type; /* codec type, pp lib */ - uint32_t entry_point; - struct fw_module_info info; +/* + * Firmware file header. + */ +struct snd_sof_fw_header { + unsigned char sig[SND_SOF_FW_SIG_SIZE]; /* "Reef" */ + uint32_t file_size; /* size of file minus this header */ + uint32_t num_modules; /* number of modules */ + uint32_t abi; /* version of header format */ } __attribute__((packed)); -/* ABI 1 - used by CoE/MCG BYT/CHT/BSW driver */ -struct byt_module_header { - unsigned char signature[REEF_FW_SIGNATURE_SIZE]; - uint32_t mod_size; /* size of module */ - uint32_t blocks; /* # of blocks */ - uint32_t type; /* codec type, pp lib */ - uint32_t entry_point; -}__attribute__((packed)); - #endif diff --git a/rimage/rimage.c b/rimage/rimage.c index a5db6d5d71e9..af57f5a55d3c 100644 --- a/rimage/rimage.c +++ b/rimage/rimage.c @@ -226,9 +226,12 @@ int main(int argc, char *argv[]) { struct image image; const char *mach = NULL; - int opt, ret, i, binary = 0; + int opt, ret, i; memset(&image, 0, sizeof(image)); + image.text_start = 0xffffffff; + image.data_start = 0xffffffff; + image.bss_start = 0xffffffff; while ((opt = getopt(argc, argv, "ho:i:m:vba:sk:")) != -1) { switch (opt) { @@ -244,9 +247,6 @@ int main(int argc, char *argv[]) case 'v': image.verbose = 1; break; - case 'b': - binary = 1; - break; case 's': image.dump_sections = 1; break; @@ -285,26 +285,16 @@ int main(int argc, char *argv[]) image.in_file, errno); } - /* open outfile for reading */ + /* open outfile for writing */ + unlink(image.out_file); image.out_fd = fopen(image.out_file, "w"); if (image.out_fd == NULL) { fprintf(stderr, "error: unable to open %s for writing %d\n", image.out_file, errno); } - if (binary) { - - switch(image.adsp->machine_id) { - case MACHINE_BAYTRAIL: - ret = write_byt_binary_image(&image); - break; - default: - fprintf(stderr, "error: not supported machine for binary input!\n"); - return ret; - } - - } else - ret = write_elf_data(&image); + /* write data */ + ret = write_elf_data(&image); /* close files */ fclose(image.out_fd); diff --git a/rimage/rimage.h b/rimage/rimage.h index 2c029328ceaa..9b8200afa36d 100644 --- a/rimage/rimage.h +++ b/rimage/rimage.h @@ -50,6 +50,13 @@ struct image { int data_size; int file_size; int num_modules; + uint32_t text_start; + uint32_t text_end; + uint32_t data_start; + uint32_t data_end; + uint32_t bss_start; + uint32_t bss_end; + /* disa */ void *in_buffer; @@ -82,8 +89,12 @@ struct adsp { uint32_t iram_size; uint32_t dram_base; uint32_t dram_size; + uint32_t host_iram_offset; + uint32_t host_dram_offset; + uint32_t image_size; uint32_t dram_offset; + enum machine_id machine_id; struct adsp_ops ops; const struct section *sections; From 8d47a54f5c93679033378a7cc6c9ae8a96e2b16e Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 9 Jun 2017 14:24:51 +0100 Subject: [PATCH 081/324] rimage: remove flat file builder. No longer needed so can be safely removed. Signed-off-by: Liam Girdwood --- rimage/Makefile.am | 4 +- rimage/flat.c | 256 --------------------------------------------- 2 files changed, 2 insertions(+), 258 deletions(-) delete mode 100644 rimage/flat.c diff --git a/rimage/Makefile.am b/rimage/Makefile.am index 32335fe68957..0ba8ce6f4c4d 100644 --- a/rimage/Makefile.am +++ b/rimage/Makefile.am @@ -6,5 +6,5 @@ noinst_HEADERS = \ rimage_SOURCES = \ cherrytrail.c \ baytrail.c \ - flat.c \ - rimage.c \ No newline at end of file + rimage.c + diff --git a/rimage/flat.c b/rimage/flat.c deleted file mode 100644 index 8c5d1c58b557..000000000000 --- a/rimage/flat.c +++ /dev/null @@ -1,256 +0,0 @@ -/* - * ELF to firmware image creator. - * - * Copyright (c) 2015, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#include -#include -#include -#include -#include - -#include "rimage.h" -#include "file_format.h" - -static int dump_section(struct image *image, struct dma_block_info *block, - void *data) -{ - const struct adsp *adsp = image->adsp; - uint32_t addr; - - switch (block->type) { - case REEF_IRAM: - addr = block->ram_offset + adsp->iram_base; - break; - case REEF_DRAM: - addr = block->ram_offset + adsp->dram_base; - break; - case REEF_CACHE: - addr = block->ram_offset + adsp->dram_base; - break; - default: - return -EINVAL; - } -} - -static int read_byt_bin_module(struct image *image, - struct byt_module_header *module) -{ - const struct adsp *adsp = image->adsp; - struct dma_block_info *block; - int count, offset; - void *data; - - block = (void *)module + sizeof(*module); - - for (count = 0; count < module->blocks; count++) { - - if (block->size <= 0) { - fprintf(stderr, "block %d size invalid\n", count); - return -EINVAL; - } - - switch (block->type) { - case REEF_IRAM: - offset = block->ram_offset + 0; - break; - case REEF_DRAM: - offset = block->ram_offset + - adsp->dram_offset; - break; - case REEF_CACHE: - offset = block->ram_offset + - adsp->dram_offset; - break; - default: - fprintf(stderr, "wrong ram type 0x%x in block0x%x\n", - block->type, count); - return -EINVAL; - } - - fprintf(stdout, "bin: block %d type %d offset 0x%x size 0x%x\n", - count, block->type, offset, block->size); - - data = (void *)block + sizeof(*block); - memcpy(image->out_buffer + offset, data, block->size); - - if (image->dump_sections) - dump_section(image, block, data); - - block = (void *)block + sizeof(*block) + block->size; - } - - return 0; -} - -static int read_bdw_bin_module(struct image *image, - struct hsw_module_header *module) -{ - const struct adsp *adsp = image->adsp; - struct dma_block_info *block; - int count, offset; - void *data; - - block = (void *)module + sizeof(*module); - - for (count = 0; count < module->blocks; count++) { - - if (block->size <= 0) { - fprintf(stderr, "block %d size invalid\n", count); - return -EINVAL; - } - - switch (block->type) { - case REEF_IRAM: - offset = block->ram_offset + 0; - break; - case REEF_DRAM: - offset = block->ram_offset + - adsp->dram_offset; - break; - case REEF_CACHE: - offset = block->ram_offset + - adsp->dram_offset; - break; - default: - fprintf(stderr, "wrong ram type 0x%x in block0x%x\n", - block->type, count); - return -EINVAL; - } - - fprintf(stdout, "bin: block %d type %d offset 0x%x size 0x%x\n", - count, block->type, offset, block->size); - - data = (void *)block + sizeof(*block); - memcpy(image->out_buffer + offset, data, block->size); - - if (image->dump_sections) - dump_section(image, block, data); - - block = (void *)block + sizeof(*block) + block->size; - } - - return 0; -} - -static int read_bin_data(struct image *image) -{ - const struct adsp *adsp = image->adsp; - struct fw_header hdr; - size_t count; - - count = fread(&hdr, sizeof(hdr), 1, image->in_fd); - if (count != 1) - return -errno; - - if (strncmp(hdr.signature, REEF_FW_SIGN, REEF_FW_SIGNATURE_SIZE)) { - fprintf(stderr, "invalid header signature: %c%c%c%c\n", - hdr.signature[0], hdr.signature[1], - hdr.signature[2], hdr.signature[3]); - return -EINVAL; - } - - image->fw_size = hdr.file_size; - image->num_modules = hdr.modules; - - fprintf(stdout, "bin: input image size %ld (0x%lx) bytes %d modules\n", - hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), - hdr.modules); - fprintf(stdout, "bin: output image size %d (0x%x) bytes\n", - adsp->image_size, - adsp->image_size); - - image->in_buffer = calloc(image->fw_size, 1); - if (image->in_buffer == NULL) - return -ENOMEM; - - count = fread(image->in_buffer, image->fw_size, 1, image->in_fd); - if (count != 1) { - free(image->in_buffer); - return -errno; - } - - image->out_buffer = calloc(adsp->image_size, 1); - if (image->out_buffer == NULL) { - free(image->in_buffer); - return -ENOMEM; - } - - return 0; -} - -int write_byt_binary_image(struct image *image) -{ - const struct adsp *adsp = image->adsp; - struct byt_module_header *module; - int ret, count; - - ret = read_bin_data(image); - if (ret < 0) - return ret; - - module = (void *)image->in_buffer; - - for (count = 0; count < image->num_modules; count++) { - - fprintf(stdout, "bin: module %d type %d blocks %d size 0x%x\n", - count, module->type, module->blocks, module->mod_size); - - ret = read_byt_bin_module(image, module); - if (ret < 0) { - fprintf(stderr, "invalid module %d\n", count); - return ret; - } - module = (void *)module + sizeof(*module) + module->mod_size; - } - - count = fwrite(image->out_buffer, adsp->image_size, 1, - image->out_fd); - if (count != adsp->image_size) - return -errno; - - return ret; -} - -int write_bdw_binary_image(struct image *image) -{ - const struct adsp *adsp = image->adsp; - struct hsw_module_header *module; - int ret, count; - - ret = read_bin_data(image); - if (ret < 0) - return ret; - - module = (void *)image->in_buffer; - - for (count = 0; count < image->num_modules; count++) { - - fprintf(stdout, "bin: module %d type %d blocks %d size 0x%x\n", - count, module->type, module->blocks, module->mod_size); - - ret = read_bdw_bin_module(image, module); - if (ret < 0) { - fprintf(stderr, "invalid module %d\n", count); - return ret; - } - module = (void *)module + sizeof(*module) + module->mod_size; - } - - count = fwrite(image->out_buffer, adsp->image_size, 1, - image->out_fd); - if (count != adsp->image_size) - return -errno; - - return ret; -} From 5dcdb6524d630f7bdf312e7e3e284675dfca8509 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Tue, 19 Dec 2017 14:35:10 +0800 Subject: [PATCH 082/324] topology: sof: Fix a typo for pipe src capture Should be src capture here in capture pipe. Signed-off-by: Pan Xiuli --- topology/sof/pipe-src-capture.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index 9484ca8f2819..c843a6c592aa 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -14,7 +14,7 @@ include(`local.m4') # Host "Passthrough Playback" PCM uses pipeline DMAC and channel # with 4 sink and 0 source periods -W_PCM_PLAYBACK(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) +W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) # # SRC Configuration From c737dcacc3ad04ec652c34570a4b48eb60d84bae Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Tue, 19 Dec 2017 14:35:11 +0800 Subject: [PATCH 083/324] topology: test: Add test cases for SRC pipe Add src pipe for test case. Signed-off-by: Pan Xiuli --- topology/test/tplg-build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 86bcfd7287c3..5d7cd494f04d 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -52,15 +52,18 @@ simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 simple_test nocodec volume "NoCodec" s16le 2 s16le 20 16 1920000 simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 +simple_test nocodec src "NoCodec" s24le 2 s24le 25 24 2400000 simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 +simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 simple_test baytrail passthrough "Baytrail Audio" s16le 2 s16le 20 16 1920000 simple_test baytrail passthrough "Baytrail Audio" s24le 2 s24le 25 24 2400000 simple_test baytrail volume "Baytrail Audio" s16le 2 s16le 20 16 1920000 simple_test baytrail volume "Baytrail Audio" s24le 2 s24le 25 24 2400000 simple_test baytrail volume "Baytrail Audio" s16le 2 s24le 25 24 2400000 +simple_test baytrail src "Baytrail Audio" s24le 2 s24le 25 24 2400000 From 49d1ca9a13b2f777124df82a9aea2ef67325849d Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Tue, 19 Dec 2017 14:35:10 +0800 Subject: [PATCH 084/324] topology: sof: Fix a typo for pipe src capture Should be src capture here in capture pipe. Signed-off-by: Pan Xiuli --- topology/sof/pipe-src-capture.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index 9484ca8f2819..c843a6c592aa 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -14,7 +14,7 @@ include(`local.m4') # Host "Passthrough Playback" PCM uses pipeline DMAC and channel # with 4 sink and 0 source periods -W_PCM_PLAYBACK(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) +W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) # # SRC Configuration From 0866b2a13e3327abaed89764de7406ca7fa22537 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Tue, 19 Dec 2017 14:35:11 +0800 Subject: [PATCH 085/324] topology: test: Add test cases for SRC pipe Add src pipe for test case. Signed-off-by: Pan Xiuli --- topology/test/tplg-build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 86bcfd7287c3..5d7cd494f04d 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -52,15 +52,18 @@ simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 simple_test nocodec volume "NoCodec" s16le 2 s16le 20 16 1920000 simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 +simple_test nocodec src "NoCodec" s24le 2 s24le 25 24 2400000 simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 +simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 simple_test baytrail passthrough "Baytrail Audio" s16le 2 s16le 20 16 1920000 simple_test baytrail passthrough "Baytrail Audio" s24le 2 s24le 25 24 2400000 simple_test baytrail volume "Baytrail Audio" s16le 2 s16le 20 16 1920000 simple_test baytrail volume "Baytrail Audio" s24le 2 s24le 25 24 2400000 simple_test baytrail volume "Baytrail Audio" s16le 2 s24le 25 24 2400000 +simple_test baytrail src "Baytrail Audio" s24le 2 s24le 25 24 2400000 From 6b59f8f698802191e2115b2f06ba2f104e9e1b8f Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Wed, 20 Dec 2017 22:10:19 +0800 Subject: [PATCH 086/324] rimage: Fix some memory leak error Handle pointers and memory when error happens. Signed-off-by: Pan Xiuli --- rimage/rimage.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/rimage/rimage.c b/rimage/rimage.c index af57f5a55d3c..af4a7d0df6cc 100644 --- a/rimage/rimage.c +++ b/rimage/rimage.c @@ -208,10 +208,11 @@ static int write_elf_data(struct image *image) goto out; } - free(image->prg); - free(image->section); - out: + if (image->prg) + free(image->prg); + if (image->section) + free(image->section); return ret; } @@ -283,6 +284,8 @@ int main(int argc, char *argv[]) if (image.in_fd == NULL) { fprintf(stderr, "error: unable to open %s for reading %d\n", image.in_file, errno); + ret = -EINVAL; + goto out; } /* open outfile for writing */ @@ -291,14 +294,19 @@ int main(int argc, char *argv[]) if (image.out_fd == NULL) { fprintf(stderr, "error: unable to open %s for writing %d\n", image.out_file, errno); + ret = -EINVAL; + goto out; } /* write data */ ret = write_elf_data(&image); +out: /* close files */ - fclose(image.out_fd); - fclose(image.in_fd); + if (image.in_fd) + fclose(image.in_fd); + if (image.out_fd) + fclose(image.out_fd); return ret; } From bd40145123897059a6264cbdd01d402d4cf4f1ea Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Wed, 20 Dec 2017 22:10:19 +0800 Subject: [PATCH 087/324] rimage: Fix some memory leak error Handle pointers and memory when error happens. Signed-off-by: Pan Xiuli --- rimage/rimage.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/rimage/rimage.c b/rimage/rimage.c index af57f5a55d3c..af4a7d0df6cc 100644 --- a/rimage/rimage.c +++ b/rimage/rimage.c @@ -208,10 +208,11 @@ static int write_elf_data(struct image *image) goto out; } - free(image->prg); - free(image->section); - out: + if (image->prg) + free(image->prg); + if (image->section) + free(image->section); return ret; } @@ -283,6 +284,8 @@ int main(int argc, char *argv[]) if (image.in_fd == NULL) { fprintf(stderr, "error: unable to open %s for reading %d\n", image.in_file, errno); + ret = -EINVAL; + goto out; } /* open outfile for writing */ @@ -291,14 +294,19 @@ int main(int argc, char *argv[]) if (image.out_fd == NULL) { fprintf(stderr, "error: unable to open %s for writing %d\n", image.out_file, errno); + ret = -EINVAL; + goto out; } /* write data */ ret = write_elf_data(&image); +out: /* close files */ - fclose(image.out_fd); - fclose(image.in_fd); + if (image.in_fd) + fclose(image.in_fd); + if (image.out_fd) + fclose(image.out_fd); return ret; } From 1111cc11caf9bbe42dd07829c16817fd23c6bb1f Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Mon, 25 Dec 2017 20:42:16 +0800 Subject: [PATCH 088/324] topology: test: make mclk configurable The mclk may be different for different platforms, here make it configurable for test topology files. Signed-off-by: Keyon Jie --- topology/test/test-capture-ssp.m4 | 3 ++- topology/test/test-playback-ssp.m4 | 3 ++- topology/test/test-ssp.m4 | 3 ++- topology/test/tplg-build.sh | 43 +++++++++++++++++------------- 4 files changed, 31 insertions(+), 21 deletions(-) diff --git a/topology/test/test-capture-ssp.m4 b/topology/test/test-capture-ssp.m4 index 613e66662aa7..2c808ba099be 100644 --- a/topology/test/test-capture-ssp.m4 +++ b/topology/test/test-capture-ssp.m4 @@ -23,6 +23,7 @@ include(`dsps/byt.m4') # TEST_SSP_PORT - SSP port number e.g. 2 # TEST_SSP_FORMAT - SSP data format e.g s16le # TEST_PIPE_FORMAT - Pipeline format e.g. s16le +# TEST_SSP_MCLK - SSP MCLK in Hz # TEST_SSP_BCLK - SSP BCLK in Hz # TEST_SSP_PHY_BITS - SSP physical slot size # TEST_SSP_DATA_BITS - SSP data slot size @@ -66,7 +67,7 @@ PCM_CAPTURE_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_2) # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), DAI_CLOCK(fsync, 48000, slave), DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/test-playback-ssp.m4 b/topology/test/test-playback-ssp.m4 index 351b8af57ffc..093ad17721de 100644 --- a/topology/test/test-playback-ssp.m4 +++ b/topology/test/test-playback-ssp.m4 @@ -23,6 +23,7 @@ include(`dsps/byt.m4') # TEST_SSP_PORT - SSP port number e.g. 2 # TEST_SSP_FORMAT - SSP data format e.g s16le # TEST_PIPE_FORMAT - Pipeline format e.g. s16le +# TEST_SSP_MCLK - SSP MCLK in Hz # TEST_SSP_BCLK - SSP BCLK in Hz # TEST_SSP_PHY_BITS - SSP physical slot size # TEST_SSP_DATA_BITS - SSP data slot size @@ -66,7 +67,7 @@ PCM_PLAYBACK_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1) # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), DAI_CLOCK(fsync, 48000, slave), DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/test-ssp.m4 b/topology/test/test-ssp.m4 index 92e91bfcbfb9..304aab9f4365 100644 --- a/topology/test/test-ssp.m4 +++ b/topology/test/test-ssp.m4 @@ -23,6 +23,7 @@ include(`dsps/byt.m4') # TEST_SSP_PORT - SSP port number e.g. 2 # TEST_SSP_FORMAT - SSP data format e.g s16le # TEST_PIPE_FORMAT - Pipeline format e.g. s16le +# TEST_SSP_MCLK - SSP BCLK in Hz # TEST_SSP_BCLK - SSP BCLK in Hz # TEST_SSP_PHY_BITS - SSP physical slot size # TEST_SSP_DATA_BITS - SSP data slot size @@ -84,7 +85,7 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), DAI_CLOCK(fsync, 48000, slave), DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 5d7cd494f04d..71bb120b05fa 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -25,6 +25,7 @@ SIMPLE_TESTS=(test-ssp test-capture-ssp test-playback-ssp) # 7) dai_phy_bits - SSP physical number of BLKCs per slot/channel # 8) dai_data_bits - SSP number of valid daat bits per slot/channel # 9) dai_bclk - SSP BCLK in HZ +# 10) dai_mclk - SSP MCLK in HZ # function simple_test { for i in ${SIMPLE_TESTS[@]} @@ -38,6 +39,7 @@ function simple_test { -DTEST_SSP_FORMAT=$6 \ -DTEST_PIPE_FORMAT=$4 \ -DTEST_SSP_BCLK=$9 \ + -DTEST_SSP_BCLK=$10 \ -DTEST_SSP_PHY_BITS=$7 \ -DTEST_SSP_DATA_BITS=$8 \ $i.m4 > ${TFILE}.conf @@ -47,23 +49,28 @@ function simple_test { } # Pre-process the simple tests -simple_test nocodec passthrough "NoCodec" s16le 2 s16le 20 16 1920000 -simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 -simple_test nocodec volume "NoCodec" s16le 2 s16le 20 16 1920000 -simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 -simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 -simple_test nocodec src "NoCodec" s24le 2 s24le 25 24 2400000 +simple_test nocodec passthrough "NoCodec" s16le 2 s16le 20 16 1920000 19200000 +simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 19200000 +simple_test nocodec volume "NoCodec" s16le 2 s16le 20 16 1920000 19200000 +simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 19200000 +simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 19200000 +simple_test nocodec src "NoCodec" s24le 2 s24le 25 24 2400000 19200000 + +simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 +simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 +simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 +simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 +simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 +simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 + +simple_test baytrail passthrough "Baytrail Audio" s16le 2 s16le 20 16 1920000 19200000 +simple_test baytrail passthrough "Baytrail Audio" s24le 2 s24le 25 24 2400000 19200000 +simple_test baytrail volume "Baytrail Audio" s16le 2 s16le 20 16 1920000 19200000 +simple_test baytrail volume "Baytrail Audio" s24le 2 s24le 25 24 2400000 19200000 +simple_test baytrail volume "Baytrail Audio" s16le 2 s24le 25 24 2400000 19200000 +simple_test baytrail src "Baytrail Audio" s24le 2 s24le 25 24 2400000 19200000 + +simple_test nocodec passthrough "NoCodec" s16le 4 s16le 16 16 1536000 24576000 +simple_test apollolake passthrough "SSP4-Codec" s16le 4 s16le 16 16 1536000 24576000 -simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 -simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 -simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 -simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 -simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 -simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 -simple_test baytrail passthrough "Baytrail Audio" s16le 2 s16le 20 16 1920000 -simple_test baytrail passthrough "Baytrail Audio" s24le 2 s24le 25 24 2400000 -simple_test baytrail volume "Baytrail Audio" s16le 2 s16le 20 16 1920000 -simple_test baytrail volume "Baytrail Audio" s24le 2 s24le 25 24 2400000 -simple_test baytrail volume "Baytrail Audio" s16le 2 s24le 25 24 2400000 -simple_test baytrail src "Baytrail Audio" s24le 2 s24le 25 24 2400000 From 1f23137df9a8d13e37dc1ae96353639791b337c1 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Wed, 10 Jan 2018 21:12:10 +0000 Subject: [PATCH 089/324] rimage: build: Fix make dist and version. make dist will now include the topology files. Signed-off-by: Liam Girdwood --- configure.ac | 6 +++++- topology/Makefile.am | 15 ++++++++++++++- topology/common/Makefile.am | 3 +++ topology/dsps/Makefile.am | 7 +++++++ topology/m4/Makefile.am | 3 +++ topology/sof/Makefile.am | 14 ++++++++++++++ topology/test/Makefile.am | 9 +++++++++ 7 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 topology/common/Makefile.am create mode 100644 topology/dsps/Makefile.am create mode 100644 topology/m4/Makefile.am create mode 100644 topology/sof/Makefile.am diff --git a/configure.ac b/configure.ac index 1b4f59b249db..8c65760763a1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.69]) -AC_INIT([rimage], [0.1]) +AC_INIT([sof-tools], [1.0.1]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_SRCDIR([rimage/rimage.c]) AC_CONFIG_HEADERS([config.h]) @@ -17,6 +17,10 @@ AC_OUTPUT([ rimage/Makefile rmbox/Makefile topology/Makefile + topology/common/Makefile + topology/dsps/Makefile + topology/m4/Makefile + topology/sof/Makefile topology/test/Makefile ]) diff --git a/topology/Makefile.am b/topology/Makefile.am index 3cbc5e64fe51..3b5a3a973912 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -3,7 +3,7 @@ # Dependencies # -SUBDIRS = test +SUBDIRS = test m4 sof common dsps DEPS = \ dsps/*.m4 \ @@ -44,3 +44,16 @@ clean: rm -f *.conf rm -f *.tplg +EXTRA_DIST = \ + reef-cht-nocodec.m4 \ + reef-cht-max98090.m4 \ + reef-apl-nocodec.m4 \ + reef-bxt-nocodec.m4 \ + reef-byt-nocodec.m4 \ + reef-bdw-rt286.m4 \ + reef-bdw-rt5640.m4 \ + reef-byt-rt5640.m4 \ + reef-byt-rt5645.m4 \ + reef-byt-rt5651.m4 \ + reef-byt-da7212.m4 \ + reef-hsw-rt5640.m4 diff --git a/topology/common/Makefile.am b/topology/common/Makefile.am new file mode 100644 index 000000000000..980f0ceba946 --- /dev/null +++ b/topology/common/Makefile.am @@ -0,0 +1,3 @@ +EXTRA_DIST = \ + tlv.m4 + diff --git a/topology/dsps/Makefile.am b/topology/dsps/Makefile.am new file mode 100644 index 000000000000..9bbade76c18f --- /dev/null +++ b/topology/dsps/Makefile.am @@ -0,0 +1,7 @@ +EXTRA_DIST = \ + bdw.m4 \ + bxt.m4 \ + byt.m4 \ + cht.m4 \ + hsw.m4 + diff --git a/topology/m4/Makefile.am b/topology/m4/Makefile.am new file mode 100644 index 000000000000..35b3f8105f87 --- /dev/null +++ b/topology/m4/Makefile.am @@ -0,0 +1,3 @@ +EXTRA_DIST = \ + build.m4 \ + local.m4 diff --git a/topology/sof/Makefile.am b/topology/sof/Makefile.am new file mode 100644 index 000000000000..fc92591f738b --- /dev/null +++ b/topology/sof/Makefile.am @@ -0,0 +1,14 @@ +EXTRA_DIST = \ + pipe-dai-capture.m4 \ + pipe-dai-playback.m4 \ + pipe-low-latency-capture.m4 \ + pipe-low-latency-playback.m4 \ + pipe-passthrough-capture.m4 \ + pipe-passthrough-playback.m4 \ + pipe-pcm-media.m4 \ + pipe-src-capture.m4 \ + pipe-src-playback.m4 \ + pipe-tone.m4 \ + pipe-volume-capture.m4 \ + pipe-volume-playback.m4 \ + tokens.m4 diff --git a/topology/test/Makefile.am b/topology/test/Makefile.am index 7da075d70102..49f224058572 100644 --- a/topology/test/Makefile.am +++ b/topology/test/Makefile.am @@ -3,6 +3,8 @@ # Dependencies # + + DEPS = \ ../dsps/*.m4 \ ../common/*.m4 \ @@ -18,3 +20,10 @@ all : *.m4 ${DEPS} clean: rm -f *.conf rm -f *.tplg + + +EXTRA_DIST = \ + test-capture-ssp.m4 \ + test-playback-ssp.m4 \ + test-ssp.m4 \ + tplg-build.sh From a6bb8de907acd642302a227f403bb9fb2c18d075 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 11 Jan 2018 11:23:24 +0000 Subject: [PATCH 090/324] topology: test: fix MCLK macro usage Incorrect BCLK macro name used to specify MCLK. Fix. Signed-off-by: Liam Girdwood --- topology/test/tplg-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 71bb120b05fa..2392135f2f25 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -39,7 +39,7 @@ function simple_test { -DTEST_SSP_FORMAT=$6 \ -DTEST_PIPE_FORMAT=$4 \ -DTEST_SSP_BCLK=$9 \ - -DTEST_SSP_BCLK=$10 \ + -DTEST_SSP_MCLK=$10 \ -DTEST_SSP_PHY_BITS=$7 \ -DTEST_SSP_DATA_BITS=$8 \ $i.m4 > ${TFILE}.conf From 9f94b57e67dc38c245b7db38fd55c80585fdf068 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 16 Jan 2018 10:37:41 -0600 Subject: [PATCH 091/324] topology: test: fix shell macro expansion for MCLK argument shell expands $10 as $1 followed by 0, so test .conf topology files contained mclk_freq "codec0" instead of the expected value (e.g. 19200000). Parenthesis are required when there are more than 9 arguments to a macro... Reported-by: "Wang, Yan" Signed-off-by: Pierre-Louis Bossart --- topology/test/tplg-build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 2392135f2f25..d322ce784161 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -39,7 +39,7 @@ function simple_test { -DTEST_SSP_FORMAT=$6 \ -DTEST_PIPE_FORMAT=$4 \ -DTEST_SSP_BCLK=$9 \ - -DTEST_SSP_MCLK=$10 \ + -DTEST_SSP_MCLK=${10} \ -DTEST_SSP_PHY_BITS=$7 \ -DTEST_SSP_DATA_BITS=$8 \ $i.m4 > ${TFILE}.conf From 59d81995f682876bd34f939332e8838c76f714ec Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 23 Jan 2018 21:29:13 +0000 Subject: [PATCH 092/324] rimage: Add support for multiple modules with code signing Add support so that rimage can take as it's input multiple ELF modules and merge them into a single signed manifest and firmware binary. Remove all hard coded module descriptions. Module metadata is now read from the ELF "module" section. Remove duplicated and unused code for creating simple firmware images as used on Baytrail and Haswell. Signed-off-by: Liam Girdwood --- configure.ac | 10 + rimage/Makefile.am | 21 +- rimage/baytrail.c | 234 -------------- rimage/cherrytrail.c | 63 ---- rimage/cse.c | 45 +++ rimage/cse.h | 42 +++ rimage/css.c | 71 +++++ rimage/css.h | 69 +++++ rimage/elf.c | 523 +++++++++++++++++++++++++++++++ rimage/file_format.h | 7 +- rimage/file_simple.c | 308 ++++++++++++++++++ rimage/hash.c | 72 +++++ rimage/keys/Makefile.am | 9 + rimage/keys/README | 34 ++ rimage/keys/otc_private_key.pem | 28 ++ rimage/keys/otc_public_key.pem | 9 + rimage/man_apl.c | 144 +++++++++ rimage/man_cnl.c | 143 +++++++++ rimage/manifest.c | 532 ++++++++++++++++++++++++++++++++ rimage/manifest.h | 90 ++++++ rimage/pkcs1_5.c | 140 +++++++++ rimage/plat_auth.c | 50 +++ rimage/plat_auth.h | 92 ++++++ rimage/rimage.c | 258 +++------------- rimage/rimage.h | 146 ++++++--- 25 files changed, 2572 insertions(+), 568 deletions(-) delete mode 100644 rimage/baytrail.c delete mode 100644 rimage/cherrytrail.c create mode 100644 rimage/cse.c create mode 100644 rimage/cse.h create mode 100644 rimage/css.c create mode 100644 rimage/css.h create mode 100644 rimage/elf.c create mode 100644 rimage/file_simple.c create mode 100644 rimage/hash.c create mode 100644 rimage/keys/Makefile.am create mode 100644 rimage/keys/README create mode 100644 rimage/keys/otc_private_key.pem create mode 100644 rimage/keys/otc_public_key.pem create mode 100644 rimage/man_apl.c create mode 100644 rimage/man_cnl.c create mode 100644 rimage/manifest.c create mode 100644 rimage/manifest.h create mode 100644 rimage/pkcs1_5.c create mode 100644 rimage/plat_auth.c create mode 100644 rimage/plat_auth.h diff --git a/configure.ac b/configure.ac index 8c65760763a1..6e9c758efd3a 100644 --- a/configure.ac +++ b/configure.ac @@ -4,6 +4,7 @@ AC_INIT([sof-tools], [1.0.1]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_SRCDIR([rimage/rimage.c]) AC_CONFIG_HEADERS([config.h]) +AC_CHECK_HEADER([sof/manifest.h]) AC_CANONICAL_HOST @@ -12,9 +13,17 @@ AM_MAINTAINER_MODE([enable]) AC_PROG_CC +#check for openssl +AC_CHECK_LIB([crypto], [OPENSSL_config], , [AC_MSG_ERROR([Need OpenSSL libcrypto])]) + +PEM_KEY_PREFIX="/usr/local/share/rimage" +AC_DEFINE_UNQUOTED([PEM_KEY_PREFIX], ["$PEM_KEY_PREFIX"], ["Path for PEM keys"]) +AC_SUBST(PEM_KEY_PREFIX) + AC_OUTPUT([ Makefile rimage/Makefile + rimage/keys/Makefile rmbox/Makefile topology/Makefile topology/common/Makefile @@ -27,6 +36,7 @@ AC_OUTPUT([ echo " prefix: ${prefix} +PEM: ${PEM_KEY_PREFIX} Compiler: ${CC} CFLAGS: ${CFLAGS} " diff --git a/rimage/Makefile.am b/rimage/Makefile.am index 0ba8ce6f4c4d..467bfe638b50 100644 --- a/rimage/Makefile.am +++ b/rimage/Makefile.am @@ -1,10 +1,25 @@ +SUBDIRS=keys + bin_PROGRAMS = rimage noinst_HEADERS = \ - rimage.h + rimage.h \ + css.h \ + cse.h \ + plat_auth.h \ + manifest.h \ + file_format.h rimage_SOURCES = \ - cherrytrail.c \ - baytrail.c \ + file_simple.c \ + man_apl.c \ + man_cnl.c \ + cse.c \ + css.c \ + plat_auth.c \ + hash.c \ + pkcs1_5.c \ + manifest.c \ + elf.c \ rimage.c diff --git a/rimage/baytrail.c b/rimage/baytrail.c deleted file mode 100644 index ed1c8409effe..000000000000 --- a/rimage/baytrail.c +++ /dev/null @@ -1,234 +0,0 @@ -/* - * ELF to firmware image creator. - * - * Copyright (c) 2015, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - - -#include -#include -#include -#include -#include - -#include "rimage.h" -#include "file_format.h" - -/* taken from the linker scripts */ -static const struct section byt_sections[] = { - {"ResetVector", 0xff2c0000, 0x2e0}, - {"ResetVector.literal", 0xff2c02e0, 0x120}, - {"WindowVectors", 0xff2c0400, 0x178}, - {"Level2InterruptVector.literal", 0xff2c0578, 0x4}, - {"Level2InterruptVector", 0xff2c057c, 0x1c}, - {"Level3InterruptVector.literal", 0xff2c0598, 0x4}, - {"Level3InterruptVector", 0xff2c059c, 0x1c}, - {"Level4InterruptVector.literal", 0xff2c05b8, 0x4}, - {"Level4InterruptVector", 0xff2c05bc, 0x1c}, - {"Level5InterruptVector.literal", 0xff2c05d8, 0x4}, - {"Level5InterruptVector", 0xff2c05dc, 0x1c}, - {"DebugInterruptVector.literal", 0xff2c05d8, 0x4}, - {"NMIExceptionVector", 0xff2c061c}, -}; - -static int is_iram(struct image *image, Elf32_Shdr *section) -{ - const struct adsp *adsp = image->adsp; - uint32_t start, end; - - start = section->sh_addr; - end = section->sh_addr + section->sh_size; - - if (start < adsp->iram_base) - return 0; - if (start >= adsp->iram_base + adsp->iram_size) - return 0; - return 1; -} - -static int is_dram(struct image *image, Elf32_Shdr *section) -{ - const struct adsp *adsp = image->adsp; - uint32_t start, end; - - start = section->sh_addr; - end = section->sh_addr + section->sh_size; - - if (start < adsp->dram_base) - return 0; - if (start >= adsp->dram_base + adsp->dram_size) - return 0; - return 1; -} - -static int block_idx = 0; - -static int write_block(struct image *image, Elf32_Shdr *section) -{ - const struct adsp *adsp = image->adsp; - struct snd_sof_blk_hdr block; - size_t count; - void *buffer; - int ret; - - block.size = section->sh_size; - - if (is_iram(image, section)) { - block.type = SOF_BLK_TEXT; - block.offset = section->sh_addr - adsp->iram_base - + adsp->host_iram_offset; - } else if (is_dram(image, section)) { - block.type = SOF_BLK_DATA; - block.offset = section->sh_addr - adsp->dram_base - + adsp->host_dram_offset; - } else { - fprintf(stderr, "error: invalid block address/size 0x%x/0x%x\n", - section->sh_addr, section->sh_size); - return -EINVAL; - } - - /* write header */ - count = fwrite(&block, sizeof(block), 1, image->out_fd); - if (count != 1) - return -errno; - - /* alloc data data */ - buffer = calloc(1, section->sh_size); - if (buffer == NULL) - return -ENOMEM; - - /* read in section data */ - ret = fseek(image->in_fd, section->sh_offset, SEEK_SET); - if (ret < 0) { - fprintf(stderr, "error: cant seek to section %d\n", ret); - goto out; - } - count = fread(buffer, 1, section->sh_size, image->in_fd); - if (count != section->sh_size) { - fprintf(stderr, "error: cant read section %d\n", -errno); - ret = -errno; - goto out; - } - - /* write out section data */ - count = fwrite(buffer, 1, section->sh_size, image->out_fd); - if (count != section->sh_size) { - fprintf(stderr, "error: cant write section %d\n", -errno); - fprintf(stderr, " foffset %d size 0x%x mem addr 0x%x\n", - section->sh_offset, section->sh_size, section->sh_addr); - ret = -errno; - goto out; - } - - if (image->verbose) { - fprintf(stdout, "block: %d\n foffset %d\n size 0x%x\n mem addr 0x%x\n", - block_idx++, section->sh_offset, section->sh_size, - section->sh_addr); - } - -out: - free(buffer); - return ret; -} - -/* used by others */ -int byt_write_modules(struct image *image) -{ - const struct adsp *adsp = image->adsp; - struct snd_sof_mod_hdr hdr; - Elf32_Shdr *section; - size_t count; - int i, err; - uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - - fprintf(stdout, "Using BYT file format\n"); - - hdr.num_blocks = image->num_sections - image->num_bss; - hdr.size = image->text_size + image->data_size + - sizeof(struct snd_sof_blk_hdr) * hdr.num_blocks; - hdr.type = SOF_FW_BASE; - - count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); - if (count != 1) { - fprintf(stderr, "error: failed to write section header %d\n", - -errno); - return -errno ; - } - - for (i = 0; i < image->hdr.e_shnum; i++) { - - section = &image->section[i]; - - /* only write valid sections */ - if (!(image->section[i].sh_flags & valid)) - continue; - - /* dont write bss */ - if (section->sh_type == SHT_NOBITS) - continue; - - err = write_block(image, section); - if (err < 0) { - fprintf(stderr, "error: failed to write section #%d\n", i); - return err; - } - } - - return 0; -} - -/* used by others */ -int byt_write_header(struct image *image) -{ - struct snd_sof_fw_header hdr; - size_t count; - - memcpy(hdr.sig, SND_SOF_FW_SIG, SND_SOF_FW_SIG_SIZE); - - hdr.num_modules = 1; - hdr.abi = SND_SOF_FW_ABI; - - image->fw_size += sizeof(struct snd_sof_blk_hdr) * - (image->num_sections - image->num_bss); - image->fw_size += sizeof(struct snd_sof_mod_hdr) * hdr.num_modules; - hdr.file_size = image->fw_size; - - fprintf(stdout, "fw: image size %ld (0x%lx) bytes %d modules\n\n", - hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), - hdr.num_modules); - count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); - if (count != 1) - return -errno; - - return 0; -} - -#define IRAM_OFFSET 0x0C0000 -#define IRAM_SIZE (80 * 1024) -#define DRAM_OFFSET 0x100000 -#define DRAM_SIZE (160 * 1024) - -const struct adsp byt_machine = { - .name = "byt", - .iram_base = 0xff2c0000, - .iram_size = 0x14000, - .host_iram_offset = IRAM_OFFSET, - .dram_base = 0xff300000, - .dram_size = 0x28000, - .host_dram_offset = DRAM_OFFSET, - .machine_id = MACHINE_BAYTRAIL, - .ops = { - .write_header = byt_write_header, - .write_modules = byt_write_modules, - }, - .sections = byt_sections, -}; diff --git a/rimage/cherrytrail.c b/rimage/cherrytrail.c deleted file mode 100644 index e27bea63e565..000000000000 --- a/rimage/cherrytrail.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * ELF to firmware image creator. - * - * Copyright (c) 2015, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - - -#include -#include -#include -#include -#include - -#include "rimage.h" -#include "file_format.h" - -/* TODO: need to config CHT values */ -static const struct section cht_sections[] = { - {"ResetVector", 0xff2c0000, 0x2e0}, - {"ResetVector.literal", 0xff2c02e0, 0x120}, - {"WindowVectors", 0xff2c0400, 0x178}, - {"Level2InterruptVector.literal", 0xff2c0578, 0x4}, - {"Level2InterruptVector", 0xff2c057c, 0x1c}, - {"Level3InterruptVector.literal", 0xff2c0598, 0x4}, - {"Level3InterruptVector", 0xff2c059c, 0x1c}, - {"Level4InterruptVector.literal", 0xff2c05b8, 0x4}, - {"Level4InterruptVector", 0xff2c05bc, 0x1c}, - {"Level5InterruptVector.literal", 0xff2c05d8, 0x4}, - {"Level5InterruptVector", 0xff2c05dc, 0x1c}, - {"DebugInterruptVector.literal", 0xff2c05d8, 0x4}, - {"NMIExceptionVector", 0xff2c061c}, -}; - -#define IRAM_OFFSET 0x0C0000 -#define IRAM_SIZE (80 * 1024) -#define DRAM_OFFSET 0x100000 -#define DRAM_SIZE (160 * 1024) - -const struct adsp cht_machine = { - .name = "cht", - .iram_base = 0xff2c0000, - .iram_size = 0x14000, - .host_iram_offset = IRAM_OFFSET, - .dram_base = 0xff300000, - .dram_size = 0x28000, - .host_dram_offset = DRAM_OFFSET, - .machine_id = MACHINE_CHERRYTRAIL, - .ops = { - .write_header = byt_write_header, - .write_modules = byt_write_modules, - }, - .sections = cht_sections, -}; - diff --git a/rimage/cse.c b/rimage/cse.c new file mode 100644 index 000000000000..b5604153f120 --- /dev/null +++ b/rimage/cse.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * Author: Liam Girdwood + * Keyon Jie + */ + +#include +#include "rimage.h" +#include "cse.h" +#include "manifest.h" + +void ri_cse_create(struct image *image) +{ + struct CsePartitionDirHeader *cse_hdr = image->fw_image; + struct sof_man_adsp_meta_file_ext *meta = image->fw_image + + MAN_META_EXT_OFFSET; + struct CsePartitionDirEntry *cse_entry = + image->fw_image + sizeof(*cse_hdr); + uint8_t csum = 0, *val = image->fw_image; + int i, size; + + fprintf(stdout, " cse: completing CSE manifest\n"); + + cse_entry[2].length = meta->comp_desc[0].limit_offset - + MAN_DESC_OFFSET; + + /* calculate checksum using BSD algo */ + size = sizeof(*cse_hdr) + sizeof(*cse_entry) * MAN_CSE_PARTS; + for (i = 0; i < size; i++) { + if (i == 11) + continue; + csum += val[i]; + } + cse_hdr->checksum = 0x100 - csum; +} diff --git a/rimage/cse.h b/rimage/cse.h new file mode 100644 index 000000000000..28650dadec2b --- /dev/null +++ b/rimage/cse.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef __CSE_H__ +#define __CSE_H__ + +#include + +struct image; + +#define CSE_HEADER_MAKER 0x44504324 /* "DPC$" */ + +struct CsePartitionDirHeader { + uint32_t header_marker; + uint32_t nb_entries; + uint8_t header_version; + uint8_t entry_version; + uint8_t header_length; + uint8_t checksum; + uint8_t partition_name[4]; +} __attribute__((packed)); + +struct CsePartitionDirEntry { + uint8_t entry_name[12]; + uint32_t offset; + uint32_t length; + uint32_t reserved; +} __attribute__((packed)); + +void ri_cse_create(struct image *image); + +#endif diff --git a/rimage/css.c b/rimage/css.c new file mode 100644 index 000000000000..f662f0b7e005 --- /dev/null +++ b/rimage/css.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * Author: Liam Girdwood + * Keyon Jie + */ + +#include +#include +#include "rimage.h" +#include "css.h" +#include "manifest.h" + +void ri_css_hdr_create(struct image *image) +{ + struct css_header *css = image->fw_image + MAN_CSS_HDR_OFFSET; + struct tm *date; + struct timeval tv; + time_t time; + int val; + + fprintf(stdout, " cse: completing CSS manifest\n"); + + /* get local time and date */ + gettimeofday(&tv, NULL); + date = localtime(&tv.tv_sec); + date->tm_year += 1900; + fprintf(stdout, " css: set build date to %d:%2.2d:%2.2d\n", + date->tm_year, date->tm_mon, date->tm_mday); + + /* year yYyy */ + val = date->tm_year / 1000; + css->date |= val << 28; + date->tm_year -= val * 1000; + /* year yyYy */ + val = date->tm_year / 100; + css->date |= val << 24; + date->tm_year -= val * 100; + /* year yyyY */ + val = date->tm_year / 10; + css->date |= val << 20; + date->tm_year -= val * 10; + /* year Yyyy */ + val = date->tm_year; + css->date |= val << 16; + + /* month Mm - for some reason month starts at 0 */ + val = ++date->tm_mon / 10; + css->date |= val << 12; + date->tm_mon -= (val * 10); + /* month mM */ + val = date->tm_mon; + css->date |= val << 8; + + /* Day Dd */ + val = date->tm_mday / 10; + css->date |= val << 4; + date->tm_mday -= (val * 10); + /* Day dD */ + val = date->tm_mday; + css->date |= val << 0; +} diff --git a/rimage/css.h b/rimage/css.h new file mode 100644 index 000000000000..0516f531ba9a --- /dev/null +++ b/rimage/css.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef __CSS_H__ +#define __CSS_H__ + +#include + +struct image; + +#define MAN_CSS_MOD_TYPE 4 +#define MAN_CSS_HDR_SIZE 161 /* in words */ +#define MAN_CSS_HDR_VERSION 0x10000 +#define MAN_CSS_MOD_VENDOR 0x8086 +#define MAN_CSS_HDR_ID {'$', 'M', 'N', '2'} + +#define MAN_CSS_KEY_SIZE (MAN_RSA_KEY_MODULUS_LEN >> 2) +#define MAN_CSS_MOD_SIZE (MAN_RSA_KEY_MODULUS_LEN >> 2) +#define MAN_CSS_EXP_SIZE (MAN_RSA_KEY_EXPONENT_LEN >> 2) +#define MAN_CSS_MAN_SIZE \ + (sizeof(struct fw_image_manifest) >> 2) + +/* + * RSA Key and Crypto + */ +#define MAN_RSA_KEY_MODULUS_LEN 256 +#define MAN_RSA_KEY_EXPONENT_LEN 4 +#define MAN_RSA_SIGNATURE_LEN 256 + +struct fw_version { + uint16_t major_version; + uint16_t minor_version; + uint16_t hotfix_version; + uint16_t build_version; +} __attribute__((packed)); + +struct css_header { + uint32_t header_type; + uint32_t header_len; + uint32_t header_version; + uint32_t reserved0; /* must be 0x0 */ + uint32_t module_vendor; + uint32_t date; + uint32_t size; + uint8_t header_id[4]; + uint32_t padding; /* must be 0x0 */ + struct fw_version version; + uint32_t svn; + uint32_t reserved1[18]; /* must be 0x0 */ + uint32_t modulus_size; + uint32_t exponent_size; + uint8_t modulus[MAN_RSA_KEY_MODULUS_LEN]; + uint8_t exponent[MAN_RSA_KEY_EXPONENT_LEN]; + uint8_t signature[MAN_RSA_SIGNATURE_LEN]; +} __attribute__((packed)); + +void ri_css_hdr_create(struct image *image); + +#endif diff --git a/rimage/elf.c b/rimage/elf.c new file mode 100644 index 000000000000..b91247761a4f --- /dev/null +++ b/rimage/elf.c @@ -0,0 +1,523 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * Author: Liam Girdwood + * Keyon Jie + */ + +#include +#include +#include "rimage.h" +#include "cse.h" +#include "manifest.h" + +static int elf_read_sections(struct image *image, struct module *module) +{ + Elf32_Ehdr *hdr = &module->hdr; + Elf32_Shdr *section = module->section; + size_t count; + int i, ret; + uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); + + /* read in section header */ + ret = fseek(module->fd, hdr->e_shoff, SEEK_SET); + if (ret < 0) { + fprintf(stderr, "error: can't seek to %s section header %d\n", + module->elf_file, ret); + return ret; + } + + /* allocate space for each section header */ + section = calloc(sizeof(Elf32_Shdr), hdr->e_shnum); + if (section == NULL) + return -ENOMEM; + module->section = section; + + /* read in sections */ + count = fread(section, sizeof(Elf32_Shdr), hdr->e_shnum, module->fd); + if (count != hdr->e_shnum) { + fprintf(stderr, "error: failed to read %s section header %d\n", + module->elf_file, -errno); + return -errno; + } + + /* parse each section */ + for (i = 0; i < hdr->e_shnum; i++) { + + /* only write valid sections */ + if (!(section[i].sh_flags & valid)) + continue; + + switch (section[i].sh_type) { + case SHT_NOBITS: + /* bss */ + module->bss_size += section[i].sh_size; + module->num_bss++; + break; + case SHT_PROGBITS: + /* text or data */ + module->fw_size += section[i].sh_size; + + if (section[i].sh_flags & SHF_EXECINSTR) + module->text_size += section[i].sh_size; + else + module->data_size += section[i].sh_size; + break; + default: + continue; + } + + module->num_sections++; + + if (!image->verbose) + continue; + + fprintf(stdout, " %s section-%d: \ttype\t 0x%8.8x\n", module->elf_file, + i, section[i].sh_type); + fprintf(stdout, " %s section-%d: \tflags\t 0x%8.8x\n", module->elf_file, + i, section[i].sh_flags); + fprintf(stdout, " %s section-%d: \taddr\t 0x%8.8x\n", module->elf_file, + i, section[i].sh_addr); + fprintf(stdout, " %s section-%d: \toffset\t 0x%8.8x\n", module->elf_file, + i, section[i].sh_offset); + fprintf(stdout, " %s section-%d: \tsize\t 0x%8.8x\n", module->elf_file, + i, section[i].sh_size); + fprintf(stdout, " %s section-%d: \tlink\t 0x%8.8x\n", module->elf_file, + i, section[i].sh_link); + fprintf(stdout, " %s section-%d: \tinfo\t 0x%8.8x\n\n", module->elf_file, + i, section[i].sh_info); + } + + return 0; +} + +static int elf_read_programs(struct image *image, struct module *module) +{ + Elf32_Ehdr *hdr = &module->hdr; + Elf32_Phdr *prg = module->prg; + size_t count; + int i, ret; + + /* read in program header */ + ret = fseek(module->fd, hdr->e_phoff, SEEK_SET); + if (ret < 0) { + fprintf(stderr, "error: cant seek to %s program header %d\n", + module->elf_file ,ret); + return ret; + } + + /* allocate space for programs */ + prg = calloc(sizeof(Elf32_Phdr), hdr->e_phnum); + if (prg == NULL) + return -ENOMEM; + module->prg = prg; + + /* read in programs */ + count = fread(prg, sizeof(Elf32_Phdr), hdr->e_phnum, module->fd); + if (count != hdr->e_phnum) { + fprintf(stderr, "error: failed to read %s program header %d\n", + module->elf_file, -errno); + return -errno; + } + + /* check each program */ + for (i = 0; i < hdr->e_phnum; i++) { + + if (prg[i].p_filesz == 0) + continue; + + if (!image->verbose) + continue; + + fprintf(stdout, "%s program-%d: \ttype\t 0x%8.8x\n", + module->elf_file, i, prg[i].p_type); + fprintf(stdout, "%s program-%d: \toffset\t 0x%8.8x\n", + module->elf_file, i, prg[i].p_offset); + fprintf(stdout, "%s program-%d: \tvaddr\t 0x%8.8x\n", + module->elf_file, i, prg[i].p_vaddr); + fprintf(stdout, "%s program-%d: \tpaddr\t 0x%8.8x\n", + module->elf_file, i, prg[i].p_paddr); + fprintf(stdout, "%s program-%d: \tfsize\t 0x%8.8x\n", + module->elf_file, i, prg[i].p_filesz); + fprintf(stdout, "%s program-%d: \tmsize\t 0x%8.8x\n", + module->elf_file, i, prg[i].p_memsz); + fprintf(stdout, "%s program-%d: \tflags\t 0x%8.8x\n\n", + module->elf_file, i, prg[i].p_flags); + } + + return 0; +} + +static int elf_read_hdr(struct image *image, struct module *module) +{ + Elf32_Ehdr *hdr = &module->hdr; + size_t count; + + /* read in elf header */ + count = fread(hdr, sizeof(*hdr), 1, module->fd); + if (count != 1) { + fprintf(stderr, "error: failed to read %s elf header %d\n", + module->elf_file, -errno); + return -errno; + } + + if (!image->verbose) + return 0; + + fprintf(stdout, "%s elf: \tentry point\t 0x%8.8x\n", + module->elf_file, hdr->e_entry); + fprintf(stdout, "%s elf: \tprogram offset\t 0x%8.8x\n", + module->elf_file, hdr->e_phoff); + fprintf(stdout, "%s elf: \tsection offset\t 0x%8.8x\n", + module->elf_file, hdr->e_shoff); + fprintf(stdout, "%s elf: \tprogram size\t 0x%8.8x\n", + module->elf_file, hdr->e_phentsize); + fprintf(stdout, "%s elf: \tprogram count\t 0x%8.8x\n", + module->elf_file, hdr->e_phnum); + fprintf(stdout, "%s elf: \tsection size\t 0x%8.8x\n", + module->elf_file, hdr->e_shentsize); + fprintf(stdout, "%s elf: \tsection count\t 0x%8.8x\n", + module->elf_file, hdr->e_shnum); + fprintf(stdout, "%s elf: \tstring index\t 0x%8.8x\n\n", + module->elf_file, hdr->e_shstrndx); + + return 0; +} + +int elf_is_rom(struct image *image, Elf32_Shdr *section) +{ + const struct adsp *adsp = image->adsp; + uint32_t start, end; + + start = section->sh_addr; + end = section->sh_addr + section->sh_size; + + if (start < image->adsp->rom_base || + start > image->adsp->rom_base + image->adsp->rom_size) + return 0; + if (end < image->adsp->rom_base || + end > image->adsp->rom_base + image->adsp->rom_size) + return 0; + return 1; +} + +static void elf_module_size(struct image *image, struct module *module, + Elf32_Shdr *section) +{ + switch (section->sh_type) { + case SHT_PROGBITS: + /* text or data */ + if (section->sh_flags & SHF_EXECINSTR) { + /* text */ + if (module->text_start > section->sh_addr) + module->text_start = section->sh_addr; + if (module->text_end < section->sh_addr + section->sh_size) + module->text_end = section->sh_addr + section->sh_size; + + fprintf(stdout, "\tTEXT\n"); + } else { + /* initialized data, also calc the writable sections */ + if (module->data_start > section->sh_addr) + module->data_start = section->sh_addr; + if (module->data_end < section->sh_addr + section->sh_size) + module->data_end = section->sh_addr + section->sh_size; + + fprintf(stdout, "\tDATA\n"); + } + break; + case SHT_NOBITS: + /* bss */ + if (module->bss_start > section->sh_addr) + module->bss_start = section->sh_addr; + if (module->bss_end < section->sh_addr + section->sh_size) + module->bss_end = section->sh_addr + section->sh_size; + + fprintf(stdout, "\tBSS\n"); + break; + default: + break; + } +} + +static void elf_module_limits(struct image *image, struct module *module) +{ + Elf32_Shdr *section; + uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); + int i; + + module->text_start = module->data_start = module->bss_start = 0xffffffff; + module->text_end = module->data_end = module->bss_end = 0; + + fprintf(stdout, " Found %d sections, listing valid sections......\n", + module->hdr.e_shnum); + + fprintf(stdout, "\tNo\tStart\t\tEnd\t\tBytes\tType\n"); + + /* iterate all sections and get size of segments */ + for (i = 0; i < module->hdr.e_shnum; i++) { + + section = &module->section[i]; + + /* only check valid sections */ + if (!(section->sh_flags & valid)) + continue; + + if (section->sh_size == 0) + continue; + + if (elf_is_rom(image, section)) + continue; + + fprintf(stdout, "\t%d\t0x%8.8x\t0x%8.8x\t%d", i, + section->sh_addr, section->sh_addr + section->sh_size, + section->sh_size); + + /* text or data section */ + elf_module_size(image, module, section); + } + + fprintf(stdout, "\n"); +} + +/* make sure no section overlap from any modules */ +int elf_validate_section(struct image *image, struct module *module, + Elf32_Shdr *section) +{ + struct module *m; + Elf32_Shdr *s; + uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); + int i, j, ret; + + /* for each module */ + for (i = 0; i < image->num_modules; i++) { + m = &image->module[i]; + + if (m == module) + continue; + + /* for each section */ + for (j = 0; j < m->hdr.e_shnum; j++) { + s = &m->section[j]; + + if (s == section) + continue; + + /* only check valid sections */ + if (!(section->sh_flags & valid)) + continue; + + if (section->sh_size == 0) + continue; + + /* is section non overlapping ? */ + if (section->sh_addr >= s->sh_addr && + section->sh_addr + section->sh_size <= + s->sh_addr + s->sh_size) { + goto err; + } + } + } + + return 0; + +err: + fprintf(stderr, "error: section overlap between %s and %s\n", + module->elf_file, m->elf_file); + fprintf(stderr, " [0x%x : 0x%x] overlaps with [0x%x :0x%x]\n", + section->sh_addr, section->sh_addr + section->sh_size, + s->sh_addr, s->sh_addr + s->sh_size); + return -EINVAL; +} + +/* make sure no section overlaps from any modules */ +int elf_validate_modules(struct image *image) +{ + struct module *module; + Elf32_Shdr *section; + uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); + int i, j, ret; + + /* for each module */ + for (i = 0; i < image->num_modules; i++) { + module = &image->module[i]; + + /* for each section */ + for (j = 0; j < module->hdr.e_shnum; j++) { + section = &module->section[j]; + + /* only check valid sections */ + if (!(section->sh_flags & valid)) + continue; + + if (section->sh_size == 0) + continue; + + /* is section non overlapping ? */ + ret = elf_validate_section(image, module, section); + if (ret < 0) + return ret; + } + } + + return 0; +} + +int elf_find_section(struct image *image, struct module *module, + const char *name) +{ + Elf32_Ehdr *hdr = &module->hdr; + Elf32_Shdr *section, *s; + char *buffer; + size_t count; + int ret, i; + + section = &module->section[hdr->e_shstrndx]; + + /* alloc data data */ + buffer = calloc(1, section->sh_size); + if (buffer == NULL) + return -ENOMEM; + + /* read in section string data */ + ret = fseek(module->fd, section->sh_offset, SEEK_SET); + if (ret < 0) { + fprintf(stderr, "error: cant seek to string section %d\n", ret); + goto out; + } + + count = fread(buffer, 1, section->sh_size, module->fd); + if (count != section->sh_size) { + fprintf(stderr, "error: can't read string section %d\n", -errno); + ret = -errno; + goto out; + } + + /* find section with name */ + for (i = 0; i < hdr->e_shnum; i++) { + s = &module->section[i]; + if (!strcmp(name, buffer + s->sh_name)) { + ret = i; + goto out; + } + } + + fprintf(stderr, "error: can't find section %s in module %s\n", name, + module->elf_file); + ret = -EINVAL; + +out: + free(buffer); + return ret; +} + +int elf_parse_module(struct image *image, int module_index, const char *name) +{ + const struct adsp *adsp = image->adsp; + struct module *module; + uint32_t rem; + int ret = 0; + + /* validate module index */ + if (module_index >= MAX_MODULES) { + fprintf(stderr, "error: too any modules\n"); + return -EINVAL; + } + + module = &image->module[module_index]; + + /* open the elf input file */ + module->fd = fopen(name, "r"); + if (module->fd == NULL) { + fprintf(stderr, "error: unable to open %s for reading %d\n", + name, errno); + return -EINVAL; + } + module->elf_file = name; + + /* read in elf header */ + ret = elf_read_hdr(image, module); + if (ret < 0) + goto hdr_err; + + /* read in programs */ + ret = elf_read_programs(image, module); + if (ret < 0) { + fprintf(stderr, "error: failed to read program sections %d\n", + ret); + goto hdr_err; + } + + /* read sections */ + ret = elf_read_sections(image, module); + if (ret < 0) { + fprintf(stderr, "error: failed to read base sections %d\n", + ret); + goto sec_err; + } + + /* check limits */ + elf_module_limits(image, module); + + elf_find_section(image, module, ""); + + fprintf(stdout, " module: input size %d (0x%x) bytes %d sections\n", + module->fw_size, module->fw_size, module->num_sections); + fprintf(stdout, " module: text %d (0x%x) bytes\n" + " data %d (0x%x) bytes\n" + " bss %d (0x%x) bytes\n\n", + module->text_size, module->text_size, + module->data_size, module->data_size, + module->bss_size, module->bss_size); + + /* file sizes round up to nearest page */ + module->text_file_size = module->text_end - module->text_start; + rem = module->text_file_size % MAN_PAGE_SIZE; + if (rem) + module->text_file_size += MAN_PAGE_SIZE - rem; + + + /* apply any base FW fixups */ + if (image->adsp->base_fw_text_size_fixup && + module->text_start == image->adsp->sram_base) { + module->text_file_size += image->adsp->base_fw_text_size_fixup; + } + + /* data section */ + module->data_file_size = module->data_end - module->data_start; + rem = module->data_file_size % MAN_PAGE_SIZE; + if (rem) + module->data_file_size += MAN_PAGE_SIZE - rem; + + /* bss section */ + module->bss_file_size = module->bss_end - module->bss_start; + rem = module->bss_file_size % MAN_PAGE_SIZE; + if (rem) + module->bss_file_size += MAN_PAGE_SIZE - rem; + + return 0; + +sec_err: + free(module->prg); +hdr_err: + fclose(module->fd); + + return ret; +} + +void elf_free_module(struct image *image, int module_index) +{ + struct module *module = &image->module[module_index]; + + free(module->prg); + free(module->section); + fclose(module->fd); +} diff --git a/rimage/file_format.h b/rimage/file_format.h index c813f49c0bc2..15302589cc40 100644 --- a/rimage/file_format.h +++ b/rimage/file_format.h @@ -55,6 +55,7 @@ * Author: Liam Girdwood */ + /* * Firmware file format . */ @@ -108,9 +109,9 @@ struct snd_sof_mod_hdr { */ struct snd_sof_fw_header { unsigned char sig[SND_SOF_FW_SIG_SIZE]; /* "Reef" */ - uint32_t file_size; /* size of file minus this header */ - uint32_t num_modules; /* number of modules */ - uint32_t abi; /* version of header format */ + uint32_t file_size; /* size of file minus this header */ + uint32_t num_modules; /* number of modules */ + uint32_t abi; /* version of header format */ } __attribute__((packed)); #endif diff --git a/rimage/file_simple.c b/rimage/file_simple.c new file mode 100644 index 000000000000..2c85a76f3f32 --- /dev/null +++ b/rimage/file_simple.c @@ -0,0 +1,308 @@ +/* + * ELF to firmware image creator. + * + * Copyright (c) 2015, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + + +#include +#include +#include +#include +#include + +#include "rimage.h" +#include "file_format.h" + +#define BYT_IRAM_BASE 0xff2c0000 +#define BYT_IRAM_HOST_OFFSET 0x0C0000 +#define BYT_IRAM_SIZE (80 * 1024) +#define BYT_DRAM_BASE 0xff300000 +#define BYT_DRAM_HOST_OFFSET 0x100000 +#define BYT_DRAM_SIZE (160 * 1024) + +#define HSW_IRAM_BASE 0x00000000 +#define HSW_IRAM_HOST_OFFSET 0x00080000 +#define HSW_IRAM_SIZE (384 * 1024) +#define HSW_DRAM_BASE 0x00400000 +#define HSW_DRAM_HOST_OFFSET 0x00000000 +#define HSW_DRAM_SIZE (512 * 1024) + +#define BDW_IRAM_BASE 0x00000000 +#define BDW_IRAM_HOST_OFFSET 0x000A0000 +#define BDW_IRAM_SIZE (320 * 1024) +#define BDW_DRAM_BASE 0x00400000 +#define BDW_DRAM_HOST_OFFSET 0x00000000 +#define BDW_DRAM_SIZE (640 * 1024) + +static int is_iram(struct image *image, Elf32_Shdr *section) +{ + const struct adsp *adsp = image->adsp; + uint32_t start, end; + + start = section->sh_addr; + end = section->sh_addr + section->sh_size; + + if (start < adsp->iram_base) + return 0; + if (start >= adsp->iram_base + adsp->iram_size) + return 0; + return 1; +} + +static int is_dram(struct image *image, Elf32_Shdr *section) +{ + const struct adsp *adsp = image->adsp; + uint32_t start, end; + + start = section->sh_addr; + end = section->sh_addr + section->sh_size; + + if (start < adsp->dram_base) + return 0; + if (start >= adsp->dram_base + adsp->dram_size) + return 0; + return 1; +} + +static int block_idx = 0; + +static int write_block(struct image *image, struct module *module, + Elf32_Shdr *section) +{ + const struct adsp *adsp = image->adsp; + struct snd_sof_blk_hdr block; + size_t count; + void *buffer; + int ret; + + block.size = section->sh_size; + + if (is_iram(image, section)) { + block.type = SOF_BLK_TEXT; + block.offset = section->sh_addr - adsp->iram_base + + adsp->host_iram_offset; + } else if (is_dram(image, section)) { + block.type = SOF_BLK_DATA; + block.offset = section->sh_addr - adsp->dram_base + + adsp->host_dram_offset; + } else { + fprintf(stderr, "error: invalid block address/size 0x%x/0x%x\n", + section->sh_addr, section->sh_size); + return -EINVAL; + } + + /* write header */ + count = fwrite(&block, sizeof(block), 1, image->out_fd); + if (count != 1) + return -errno; + + /* alloc data data */ + buffer = calloc(1, section->sh_size); + if (buffer == NULL) + return -ENOMEM; + + /* read in section data */ + ret = fseek(module->fd, section->sh_offset, SEEK_SET); + if (ret < 0) { + fprintf(stderr, "error: cant seek to section %d\n", ret); + goto out; + } + count = fread(buffer, 1, section->sh_size, module->fd); + if (count != section->sh_size) { + fprintf(stderr, "error: cant read section %d\n", -errno); + ret = -errno; + goto out; + } + + /* write out section data */ + count = fwrite(buffer, 1, section->sh_size, image->out_fd); + if (count != section->sh_size) { + fprintf(stderr, "error: cant write section %d\n", -errno); + fprintf(stderr, " foffset %d size 0x%x mem addr 0x%x\n", + section->sh_offset, section->sh_size, section->sh_addr); + ret = -errno; + goto out; + } + + fprintf(stdout, "\t%d\t0x%8.8x\t0x%8.8x\t0x%8.8lx\t%s\n", block_idx++, + section->sh_addr, section->sh_size, ftell(image->out_fd), + block.type == SOF_BLK_TEXT ? "TEXT" : "DATA"); + +out: + free(buffer); + return ret; +} + +static int simple_write_module(struct image *image, struct module *module) +{ + const struct adsp *adsp = image->adsp; + struct snd_sof_mod_hdr hdr; + Elf32_Shdr *section; + size_t count; + int i, err; + uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); + + hdr.num_blocks = module->num_sections - module->num_bss; + hdr.size = module->text_size + module->data_size + + sizeof(struct snd_sof_blk_hdr) * hdr.num_blocks; + hdr.type = SOF_FW_BASE; + + count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); + if (count != 1) { + fprintf(stderr, "error: failed to write section header %d\n", + -errno); + return -errno ; + } + + fprintf(stdout, "\n\tTotals\tStart\t\tEnd\t\tSize"); + + fprintf(stdout, "\n\tTEXT\t0x%8.8x\t0x%8.8x\t0x%x\n", + module->text_start, module->text_end, + module->text_end - module->text_start); + fprintf(stdout, "\tDATA\t0x%8.8x\t0x%8.8x\t0x%x\n", + module->data_start, module->data_end, + module->data_end - module->data_start); + fprintf(stdout, "\tBSS\t0x%8.8x\t0x%8.8x\t0x%x\n\n ", + module->bss_start, module->bss_end, + module->bss_end - module->bss_start); + + fprintf(stdout, "\tNo\tAddress\t\tSize\t\tFile\t\tType\n"); + + for (i = 0; i < module->hdr.e_shnum; i++) { + + section = &module->section[i]; + + /* only write valid sections */ + if (!(module->section[i].sh_flags & valid)) + continue; + + /* dont write bss */ + if (section->sh_type == SHT_NOBITS) + continue; + + err = write_block(image, module, section); + if (err < 0) { + fprintf(stderr, "error: failed to write section #%d\n", i); + return err; + } + } + + fprintf(stdout, "\n"); + return 0; +} + +/* used by others */ +static int simple_write_firmware(struct image *image) +{ + struct snd_sof_fw_header hdr; + struct module *module; + size_t count; + int i, ret; + + memcpy(hdr.sig, SND_SOF_FW_SIG, SND_SOF_FW_SIG_SIZE); + + hdr.num_modules = image->num_modules; + hdr.abi = SND_SOF_FW_ABI; + hdr.file_size = 0; + + for (i = 0; i < image->num_modules; i++) { + module = &image->module[i]; + module->fw_size += sizeof(struct snd_sof_blk_hdr) * + (module->num_sections - module->num_bss); + module->fw_size += sizeof(struct snd_sof_mod_hdr) * hdr.num_modules; + hdr.file_size += module->fw_size; + } + + count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); + if (count != 1) + return -errno; + + for (i = 0; i < image->num_modules; i++) { + module = &image->module[i]; + + fprintf(stdout, "writing module %d %s\n", i, module->elf_file); + + ret = simple_write_module(image, module); + if (ret < 0) { + fprintf(stderr, "error: failed to write module %d\n", + i); + return ret; + } + } + + fprintf(stdout, "firmware: image size %ld (0x%lx) bytes %d modules\n\n", + hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), + hdr.num_modules); + + return 0; +} + +const struct adsp machine_byt = { + .name = "byt", + .iram_base = BYT_IRAM_BASE, + .iram_size = BYT_IRAM_SIZE, + .host_iram_offset = BYT_IRAM_HOST_OFFSET, + .dram_base = BYT_DRAM_BASE, + .dram_size = BYT_DRAM_SIZE, + .host_dram_offset = BYT_DRAM_HOST_OFFSET, + .machine_id = MACHINE_BAYTRAIL, + .write_firmware = simple_write_firmware, +}; + +const struct adsp machine_cht = { + .name = "cht", + .iram_base = BYT_IRAM_BASE, + .iram_size = BYT_IRAM_SIZE, + .host_iram_offset = BYT_IRAM_HOST_OFFSET, + .dram_base = BYT_DRAM_BASE, + .dram_size = BYT_DRAM_SIZE, + .host_dram_offset = BYT_DRAM_HOST_OFFSET, + .machine_id = MACHINE_CHERRYTRAIL, + .write_firmware = simple_write_firmware, +}; + +const struct adsp machine_bsw = { + .name = "bsw", + .iram_base = BYT_IRAM_BASE, + .iram_size = BYT_IRAM_SIZE, + .host_iram_offset = BYT_IRAM_HOST_OFFSET, + .dram_base = BYT_DRAM_BASE, + .dram_size = BYT_DRAM_SIZE, + .host_dram_offset = BYT_DRAM_HOST_OFFSET, + .machine_id = MACHINE_BRASWELL, + .write_firmware = simple_write_firmware, +}; + +const struct adsp machine_hsw = { + .name = "hsw", + .iram_base = HSW_IRAM_BASE, + .iram_size = HSW_IRAM_SIZE, + .host_iram_offset = HSW_IRAM_HOST_OFFSET, + .dram_base = HSW_DRAM_BASE, + .dram_size = HSW_DRAM_SIZE, + .host_dram_offset = HSW_DRAM_HOST_OFFSET, + .machine_id = MACHINE_HASWELL, + .write_firmware = simple_write_firmware, +}; + +const struct adsp machine_bdw = { + .name = "bdw", + .iram_base = BDW_IRAM_BASE, + .iram_size = BDW_IRAM_SIZE, + .host_iram_offset = BDW_IRAM_HOST_OFFSET, + .dram_base = BDW_DRAM_BASE, + .dram_size = BDW_DRAM_SIZE, + .host_dram_offset = BDW_DRAM_HOST_OFFSET, + .machine_id = MACHINE_BROADWELL, + .write_firmware = simple_write_firmware, +}; diff --git a/rimage/hash.c b/rimage/hash.c new file mode 100644 index 000000000000..3acf1b31745f --- /dev/null +++ b/rimage/hash.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * Author: Liam Girdwood + * Keyon Jie + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include "rimage.h" +#include "file_format.h" +#include "manifest.h" + +#define DEBUG_HASH 0 + +void module_sha256_create(struct image *image) +{ + image->md = EVP_sha256(); + image->mdctx = EVP_MD_CTX_create(); + + EVP_DigestInit_ex(image->mdctx, image->md, NULL); +} + +void module_sha256_update(struct image *image, uint8_t *data, size_t bytes) +{ + EVP_DigestUpdate(image->mdctx, data, bytes); +} + +void module_sha256_complete(struct image *image, uint8_t *hash) +{ + unsigned char md_value[EVP_MAX_MD_SIZE]; + int md_len; +#if DEBUG_HASH + int i; +#endif + EVP_DigestFinal_ex(image->mdctx, md_value, &md_len); + EVP_MD_CTX_destroy(image->mdctx); + + memcpy(hash, md_value, md_len); +#if DEBUG_HASH + fprintf(stdout, "Module digest is: "); + for (i = 0; i < md_len; i++) + fprintf(stdout, "%02x", md_value[i]); + fprintf(stdout, "\n"); +#endif +} + +void ri_hash(struct image *image, unsigned offset, unsigned size, char *hash) +{ + module_sha256_create(image); + module_sha256_update(image, image->fw_image + offset, size); + module_sha256_complete(image, hash); +} diff --git a/rimage/keys/Makefile.am b/rimage/keys/Makefile.am new file mode 100644 index 000000000000..06fe3071317a --- /dev/null +++ b/rimage/keys/Makefile.am @@ -0,0 +1,9 @@ +install-data-local: + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(PEM_KEY_PREFIX); + $(INSTALL_DATA) otc_private_key.pem $(PEM_KEY_PREFIX) + $(INSTALL_DATA) otc_public_key.pem $(PEM_KEY_PREFIX) + +EXTRA_DIST = \ + otc_private_key.pem \ + otc_public_key.pem \ No newline at end of file diff --git a/rimage/keys/README b/rimage/keys/README new file mode 100644 index 000000000000..3ece70cad290 --- /dev/null +++ b/rimage/keys/README @@ -0,0 +1,34 @@ +About +===== + +Firmware binary signing is for audio DSP is mandatory on Intel products from +Skylake onwards. i.e. no code signing on Baytrail, Cherrytrail, Braswell, +Haswell and Broadwell but mandatory on Skylake, Kabylake, Apollolake and +Cannonlake. + +rimage can now sign firmware binaries for Apollolake and Cannonlake targets. +This is done automatically as part of the "make bin" part of the build. + + +Key Pairs +========= + +The key included here is the Intel OTC (Opensource Technology Center) community +development key. It can be freely used by anyone and is intended for reference +board makers and firmware developers. + +** This key is NOT intended for locking down firmware on end user production +devices since the "private" key has been published here. A new key pair must +be genrated for securing firmware ! ** + +RSA Private and Public keys are generated as follows :- + +openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048 +openssl rsa -pubout -in private_key.pem -out public_key.pem + +The public key needs to be programmed into the OEM Key manifest (cavsManifest0) +within the BIOS in order to verify code signed with the private key. +Intel supplies tools to board makers to stitch the public key into the BIOS. + +The private key is used by rimage to sign the SOF binary. It should be kept +secret and secure for production signing. \ No newline at end of file diff --git a/rimage/keys/otc_private_key.pem b/rimage/keys/otc_private_key.pem new file mode 100644 index 000000000000..03ad749260b7 --- /dev/null +++ b/rimage/keys/otc_private_key.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQC5Q68ZJyiWWrXb +TSjlj4I/UmgusmIfv5+MCtinahekLPasIvoBhmEAr/TBizlfhj2/VN4FKNsqy7HR +QGn+iLhqnVrzpEVug4EQIpkFxTnycKMQPSDvpIqq8VL9pUCvKokSMub0oTCwoxjJ +V81wJy+NE2AnamjtnuJEXqim9U5CGjsnVNSktv/YPbso/LYFjH658Fz5QGgWfbgi +BPNFwMvemSFOIXw2J2B91ayP9ZJeI2tLyEP9EMeQqU3Gd8T5LfHIUmibpPFe1JDM +s4HmIEs7Iay03EfwjEWLVd0P/fxv9I9YNTZAi+7o8IyrTNRHDsH55efW7V58GwfS +66po4QCFAgMBAAECggEBALf7IlktTR47iRv2/WUz5hnyQWoWVmHHD6+oWc2wCzhM +Os9pkLOQ+qYPF1ZZZ6mYi5uFsVKYZ0aRsM3oVRqkNdgS2m7YtObyC2q1oRdc7JX6 +C8Wlnx69XcQzEcK4qIsMB8Gd8UQBC3RvE79nxanaEFveYP/jqb5IqdVR19SuCYCU +EZurwwAnYeLg0VSSdVQHSGVMlHkDwhgVAvp5NryPXhml51pT0gzUwnvJOsUcrc0m +tqUa2yu7/Qju1/JtFL98RgW4x3mSo4TZO3B/d664pWPOxL72zCt7bD9s06ILZmga +z1oMLMwTaNaeYIBaRvjmssKOqLXmDvfc415V82SwMYUCgYEA2p2At6acrD8Xx5GO +GeCeUbZzm0Ke9zql1W+Diq89UroFX/i9XO9Mb/ZfwouC+5n3iLjyCG7jIaIwYAyV +2qim9sINeieepM54HqYz0235nX5CqLHPDobYLn5tsbNYvXYBWiyjRppG+cnprMBk +O6vLNXNc4sRemgbcmwT3sEYLLo8CgYEA2PInWZx0JoEXriEgefv/IZeyCjpaS9uH +OOaPVAJTJPaaZhazA4ANV2bzrQAigiXbOgzPkXyldy7T7d/gHfVYnHbyhGwMEa6u +WMnj5qFXPI0hYOOrJbqXofbfGkKC996eoQybnvE0WdIwscySIki1zAenE/5nVdCJ +HLwK9xXMKasCgYA/ZxSQrsqbjgTYhVdgG+vuqOqoac7uxtyXpSrSSvaPCpJKfjp1 +PJW/lwW4x3tqewH2biUL2xUWiRJcmOnRK76YrDj6Z4k0JQljYjJ/rFKLobW1dTQm +82a5PUOVGP2wnQvRWkbUUCQrh6q0xmuLfsyFqPqUbf090KWkc/Fd90KA8wKBgG6C +q9jSAbi7ebyR02FQJJ6QD3l2UBjkMvWhPNGmfYQOuofWeEoIKMOlBevSbcGuVwYz +EGkj/YXArOQ3borUN9c8ID2kbGF1ggpojVcmSLHnkmEwmDYX3rX6c5uE1gI9vMB9 +E6jbZbd7gqKPesFMGI9eNpXQugLUv4OLpmpHCEERAoGAMF5P9jSe3JirlZ7WaH7A +I1I23L3oZfkmrcxP7B860k1ZLHDtx/MtWLkb609fq1Q2lqRuvdoaur1kW+Rv9IHS +Db8cznu9jIz3OzmJ735lHDpomylzt0+nxL5rrUnoTyMsDK0kIWs03JhPYc0+S2Ip +lkkvYQHB1eUUCxMnTgzWRr4= +-----END PRIVATE KEY----- diff --git a/rimage/keys/otc_public_key.pem b/rimage/keys/otc_public_key.pem new file mode 100644 index 000000000000..b8662bda0192 --- /dev/null +++ b/rimage/keys/otc_public_key.pem @@ -0,0 +1,9 @@ +-----BEGIN PUBLIC KEY----- +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuUOvGScollq1200o5Y+C +P1JoLrJiH7+fjArYp2oXpCz2rCL6AYZhAK/0wYs5X4Y9v1TeBSjbKsux0UBp/oi4 +ap1a86RFboOBECKZBcU58nCjED0g76SKqvFS/aVAryqJEjLm9KEwsKMYyVfNcCcv +jRNgJ2po7Z7iRF6opvVOQho7J1TUpLb/2D27KPy2BYx+ufBc+UBoFn24IgTzRcDL +3pkhTiF8NidgfdWsj/WSXiNrS8hD/RDHkKlNxnfE+S3xyFJom6TxXtSQzLOB5iBL +OyGstNxH8IxFi1XdD/38b/SPWDU2QIvu6PCMq0zURw7B+eXn1u1efBsH0uuqaOEA +hQIDAQAB +-----END PUBLIC KEY----- diff --git a/rimage/man_apl.c b/rimage/man_apl.c new file mode 100644 index 000000000000..7b32ea1c3887 --- /dev/null +++ b/rimage/man_apl.c @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include "css.h" +#include "cse.h" +#include "plat_auth.h" +#include "manifest.h" + +/* hard coded atm - will pass this in from cmd line and git */ +#define MAN_FW_HDR_VERSION_MAJOR 9 +#define MAN_FW_HDR_VERSION_MINOR 22 +#define MAN_FW_HDR_VERSION_HOTFIX 1 +#define MAN_FW_HDR_VERSION_BUILD 0x7da + +/* manifest template */ +struct fw_image_manifest apl_manifest = { + + .cse_partition_dir_header = { + .header_marker = CSE_HEADER_MAKER, + .nb_entries = MAN_CSE_PARTS, + .header_version = 1, + .entry_version = 1, + .header_length = sizeof(struct CsePartitionDirHeader), + .checksum = 0, + .partition_name = "ADSP", + }, + + .cse_partition_dir_entry = { + { + /* CssHeader + platformFirmwareAuthenticationExtension - padding */ + .entry_name = "ADSP.man", + .offset = MAN_CSS_HDR_OFFSET, + .length = sizeof(struct css_header) + + PLAT_AUTH_SIZE, + }, + { /* ADSPMetadataFileExtension */ + .entry_name = "cavs0015.met", + .offset = MAN_META_EXT_OFFSET, + .length = sizeof(struct sof_man_adsp_meta_file_ext), + }, + { /* AdspFwBinaryDesc */ + .entry_name = "cavs0015", + .offset = MAN_FW_DESC_OFFSET, + .length = 0, /* calculated by rimage - */ + }, + + }, + + .css = { + .header_type = MAN_CSS_MOD_TYPE, + .header_len = MAN_CSS_HDR_SIZE, + .header_version = MAN_CSS_HDR_VERSION, + .module_vendor = MAN_CSS_MOD_VENDOR, + .size = 222, + .header_id = MAN_CSS_HDR_ID, + .padding = 0, + .version = { + .major_version = MAN_FW_HDR_VERSION_MAJOR, + .minor_version = MAN_FW_HDR_VERSION_MINOR, + .hotfix_version = MAN_FW_HDR_VERSION_HOTFIX, + .build_version = MAN_FW_HDR_VERSION_BUILD, + }, + .modulus_size = MAN_CSS_MOD_SIZE, + .exponent_size = MAN_CSS_EXP_SIZE, + }, + + .signed_pkg = { + .ext_type = SIGN_PKG_EXT_TYPE, + .ext_len = sizeof(struct signed_pkg_info_ext), + .name = "ADSP", + .vcn = 0, + .bitmap = {0, 0, 0, 0, 8}, + + .module[0] = { + .name = "cavs0015.met", + .meta_size = 96, + .type = 0x03, + .hash_algo = 0x02, /* SHA 256 */ + .hash_size = 0x20, + }, + }, + + .partition_info = { + + .ext_type = PART_INFO_EXT_TYPE, + .ext_len = sizeof(struct partition_info_ext), + + .name = "ADSP", + .length = 0, /* calculated by rimage - rounded up to nearest PAGE */ + .part_version = 0x10000000, + .instance_id = 1, + .reserved[0 ... 19] = 0xff, + + .module[0] = { + .name = "cavs0015.met", + .meta_size = 96, + .type = 0x03, + .reserved = {0x00, 0xff, 0xff}, + }, + + }, + + .cse_padding[0 ... 47] = 0xff, + + .adsp_file_ext = { + .ext_type = 17, + .ext_len = sizeof(struct sof_man_adsp_meta_file_ext), + .imr_type = 3, + .comp_desc[0] = { + .version = 0, + .base_offset = MAN_DESC_OFFSET, + .limit_offset = 0, /* calculated length + MAN_DESC_OFFSET */ + }, + + }, + + .reserved[0 ... 31] = 0xff, + + .desc = { + .header = { + .header_id = SOF_MAN_FW_HDR_ID, + .header_len = sizeof(struct sof_man_fw_header), + .name = SOF_MAN_FW_HDR_NAME, + .preload_page_count = 0, /* size in pages from $CPD */ + .fw_image_flags = SOF_MAN_FW_HDR_FLAGS, + .feature_mask = SOF_MAN_FW_HDR_FEATURES, + .major_version = MAN_FW_HDR_VERSION_MAJOR, + .minor_version = MAN_FW_HDR_VERSION_MINOR, + .hotfix_version = MAN_FW_HDR_VERSION_HOTFIX, + .build_version = MAN_FW_HDR_VERSION_BUILD, + .load_offset = MAN_DESC_OFFSET, + }, + }, +}; diff --git a/rimage/man_cnl.c b/rimage/man_cnl.c new file mode 100644 index 000000000000..2aec2a723d79 --- /dev/null +++ b/rimage/man_cnl.c @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include "css.h" +#include "cse.h" +#include "plat_auth.h" +#include "manifest.h" + +/* hard coded atm - will pass this in from cmd line and git */ +#define MAN_FW_HDR_VERSION_MAJOR 10 +#define MAN_FW_HDR_VERSION_MINOR 23 +#define MAN_FW_HDR_VERSION_HOTFIX 0 +#define MAN_FW_HDR_VERSION_BUILD 0x2a4 + +/* manifest template */ +struct fw_image_manifest cnl_manifest = { + + .cse_partition_dir_header = { + .header_marker = CSE_HEADER_MAKER, + .nb_entries = MAN_CSE_PARTS, + .header_version = 1, + .entry_version = 1, + .header_length = sizeof(struct CsePartitionDirHeader), + .partition_name = "ADSP", + }, + + .cse_partition_dir_entry = { + { + /* CssHeader + platformFirmwareAuthenticationExtension - padding */ + .entry_name = "ADSP.man", + .offset = MAN_CSS_HDR_OFFSET, + .length = sizeof(struct css_header) + + PLAT_AUTH_SIZE, + }, + { /* ADSPMetadataFileExtension */ + .entry_name = "cavs0015.met", + .offset = MAN_META_EXT_OFFSET, + .length = sizeof(struct sof_man_adsp_meta_file_ext), + }, + { /* AdspFwBinaryDesc */ + .entry_name = "cavs0015", + .offset = MAN_FW_DESC_OFFSET, + .length = 0, /* calculated by rimage - */ + }, + + }, + + .css = { + .header_type = MAN_CSS_MOD_TYPE, + .header_len = MAN_CSS_HDR_SIZE, + .header_version = MAN_CSS_HDR_VERSION, + .module_vendor = MAN_CSS_MOD_VENDOR, + .size = 222, + .header_id = MAN_CSS_HDR_ID, + .padding = 0, + .version = { + .major_version = MAN_FW_HDR_VERSION_MAJOR, + .minor_version = MAN_FW_HDR_VERSION_MINOR, + .hotfix_version = MAN_FW_HDR_VERSION_HOTFIX, + .build_version = MAN_FW_HDR_VERSION_BUILD, + }, + .modulus_size = MAN_CSS_MOD_SIZE, + .exponent_size = MAN_CSS_EXP_SIZE, + }, + + .signed_pkg = { + .ext_type = SIGN_PKG_EXT_TYPE, + .ext_len = sizeof(struct signed_pkg_info_ext), + .name = "ADSP", + .vcn = 0, + .bitmap = {0, 0, 0, 0, 8}, + + .module[0] = { + .name = "cavs0015.met", + .meta_size = 96, + .type = 0x03, + .hash_algo = 0x02, /* SHA 256 */ + .hash_size = 0x20, + }, + }, + + .partition_info = { + + .ext_type = PART_INFO_EXT_TYPE, + .ext_len = sizeof(struct partition_info_ext), + + .name = "ADSP", + .length = 0, /* calculated by rimage - rounded up to nearest PAGE */ + .part_version = 0x10000000, + .instance_id = 1, + .reserved[0 ... 19] = 0xff, + + .module[0] = { + .name = "cavs0015.met", + .meta_size = 96, + .type = 0x03, + .reserved = {0x00, 0xff, 0xff}, + }, + + }, + + .cse_padding[0 ... 47] = 0xff, + + .adsp_file_ext = { + .ext_type = 17, + .ext_len = sizeof(struct sof_man_adsp_meta_file_ext), + .imr_type = 3, + .comp_desc[0] = { + .version = 0, + .base_offset = MAN_DESC_OFFSET, + .limit_offset = 0, /* calculated length + MAN_DESC_OFFSET */ + }, + + }, + + .reserved[0 ... 31] = 0xff, + + .desc = { + .header = { + .header_id = SOF_MAN_FW_HDR_ID, + .header_len = sizeof(struct sof_man_fw_header), + .name = SOF_MAN_FW_HDR_NAME, + .preload_page_count = 0, /* size in pages from $CPD */ + .fw_image_flags = SOF_MAN_FW_HDR_FLAGS, + .feature_mask = SOF_MAN_FW_HDR_FEATURES, + .major_version = MAN_FW_HDR_VERSION_MAJOR, + .minor_version = MAN_FW_HDR_VERSION_MINOR, + .hotfix_version = MAN_FW_HDR_VERSION_HOTFIX, + .build_version = MAN_FW_HDR_VERSION_BUILD, + .load_offset = 0x30000, + }, + }, +}; diff --git a/rimage/manifest.c b/rimage/manifest.c new file mode 100644 index 000000000000..24fb76fef9ce --- /dev/null +++ b/rimage/manifest.c @@ -0,0 +1,532 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * Author: Liam Girdwood + * Keyon Jie + */ + + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "rimage.h" +#include "file_format.h" +#include "css.h" +#include "cse.h" +#include "plat_auth.h" +#include "manifest.h" + +static int man_open_rom_file(struct image *image) +{ + sprintf(image->out_rom_file, "%s.rom", image->out_file); + unlink(image->out_rom_file); + + /* allocate ROM image */ + image->rom_image = calloc(image->adsp->rom_size, 1); + if (image->rom_image == NULL) + return -ENOMEM; + + /* open ROM outfile for writing */ + image->out_rom_fd = fopen(image->out_rom_file, "w"); + if (image->out_rom_fd == NULL) { + fprintf(stderr, "error: unable to open %s for writing %d\n", + image->out_rom_file, errno); + } + + return 0; +} + +static int man_open_manifest_file(struct image *image) +{ + /* open manifest outfile for writing */ + sprintf(image->out_man_file, "%s.met", image->out_file); + unlink(image->out_man_file); + + image->out_man_fd = fopen(image->out_man_file, "w"); + if (image->out_man_fd == NULL) { + fprintf(stderr, "error: unable to open %s for writing %d\n", + image->out_man_file, errno); + } + + return 0; +} + +static int man_init_image(struct image *image) +{ + /* allocate image and copy template manifest */ + image->fw_image = calloc(image->adsp->image_size, 1); + if (image->fw_image == NULL) + return -ENOMEM; + + memcpy(image->fw_image, image->adsp->man, + sizeof(struct fw_image_manifest)); + + return 0; +} + +/* we should call this after all segments size set up via iterate */ +static uint32_t elf_to_file_offset(struct image *image, + struct module *module, struct sof_man_module *man_module, + Elf32_Shdr *section) +{ + uint32_t elf_addr = section->sh_addr, file_offset = 0; + + if (section->sh_type == SHT_PROGBITS) { + if (section->sh_flags & SHF_EXECINSTR) { + /* text segment */ + file_offset = elf_addr - module->text_start + + module->foffset; + } + else { + /* rodata segment, append to text segment */ + file_offset = elf_addr - module->data_start + + module->foffset + module->text_file_size; + + } + } else if (section->sh_type == SHT_NOBITS) { + /* bss segment */ + file_offset = 0; + } + + return file_offset; +} + +/* write SRAM sections */ +static int man_copy_sram(struct image *image, Elf32_Shdr *section, + struct module *module, struct sof_man_module *man_module, + int section_idx) +{ + uint32_t offset = elf_to_file_offset(image, module, + man_module, section); + uint32_t end = offset + section->sh_size; + int seg_type = -1; + void *buffer = image->fw_image + offset; + size_t count; + + switch (section->sh_type) { + case SHT_PROGBITS: + /* text or data */ + if (section->sh_flags & SHF_EXECINSTR) + seg_type = SOF_MAN_SEGMENT_TEXT; + else + seg_type = SOF_MAN_SEGMENT_RODATA; + break; + case SHT_NOBITS: + seg_type = SOF_MAN_SEGMENT_BSS; + default: + return 0; + } + + /* file_offset for segment should not be 0s, we set it to + * the smallest offset of its modules ATM. + */ + if (man_module->segment[seg_type].file_offset > offset || + man_module->segment[seg_type].file_offset == 0) + man_module->segment[seg_type].file_offset = offset; + + count = fread(buffer, 1, section->sh_size, module->fd); + if (count != section->sh_size) { + fprintf(stderr, "error: cant read section %d\n", -errno); + return -errno; + } + + /* get module end offset ? */ + if (end > image->image_end) + image->image_end = end; + + fprintf(stdout, "\t%d\t0x%x\t0x%x\t0x%x\t%s\n", section_idx, + section->sh_addr, section->sh_size, offset, + seg_type == SOF_MAN_SEGMENT_TEXT ? "TEXT" : "DATA"); + + return 0; +} + +static int man_copy_elf_section(struct image *image, Elf32_Shdr *section, + struct module *module, struct sof_man_module *man_module, int idx) +{ + int ret; + + /* seek to ELF section */ + ret = fseek(module->fd, section->sh_offset, SEEK_SET); + if (ret < 0) { + fprintf(stderr, "error: can't seek to section %d\n", ret); + return ret; + } + + /* write data to DRAM or ROM image */ + if (!elf_is_rom(image, section)) + return man_copy_sram(image, section, module, man_module, idx); + + return 0; +} + +static int man_get_module_manifest(struct image *image, struct module *module, + struct sof_man_module *man_module) +{ + Elf32_Shdr *section; + struct sof_man_segment_desc *segment; + struct sof_man_module sof_mod; + size_t count; + int ret, man_section_idx; + + fprintf(stdout, "Module Write: %s\n", module->elf_file); + + /* find manifest module data */ + man_section_idx = elf_find_section(image, module, ".module"); + if (man_section_idx < 0) { + return -EINVAL; + } + + fprintf(stdout, " Manifest module metadata section at index %d\n", + man_section_idx); + section = &module->section[man_section_idx]; + + /* load in manifest data */ + ret = fseek(module->fd, section->sh_offset, SEEK_SET); + if (ret < 0) { + fprintf(stderr, "error: can't seek to section %d\n", ret); + return ret; + } + count = fread(&sof_mod, 1, sizeof(sof_mod), module->fd); + if (count != sizeof(sof_mod)) { + fprintf(stderr, "error: can't read section %d\n", -errno); + return -errno; + } + + /* configure man_module with sofmod data */ + strncpy(man_module->struct_id, "$AME", 4); + man_module->entry_point = sof_mod.entry_point; + strncpy(man_module->name, sof_mod.name, SOF_MAN_MOD_NAME_LEN); + memcpy(man_module->uuid, sof_mod.uuid, 16); + man_module->affinity_mask = sof_mod.affinity_mask; + man_module->type.auto_start = sof_mod.type.auto_start; + man_module->type.domain_dp = sof_mod.type.domain_dp; + man_module->type.domain_ll = sof_mod.type.domain_ll; + man_module->type.load_type = sof_mod.type.load_type; + + /* text segment */ + segment = &man_module->segment[SOF_MAN_SEGMENT_TEXT]; + segment->flags.r.contents = 1; + segment->flags.r.alloc = 1; + segment->flags.r.load = 1; + segment->flags.r.readonly = 1; + segment->flags.r.code = 1; + + /* data segment */ + segment = &man_module->segment[SOF_MAN_SEGMENT_RODATA]; + segment->flags.r.contents = 1; + segment->flags.r.alloc = 1; + segment->flags.r.load = 1; + segment->flags.r.readonly = 1; + segment->flags.r.data = 1; + segment->flags.r.type = 1; + + /* bss segment */ + segment = &man_module->segment[SOF_MAN_SEGMENT_BSS]; + segment->flags.r.alloc = 1; + segment->flags.r.type = 2; + + fprintf(stdout, " Entry point 0x%8.8x\n", man_module->entry_point); + + return 0; +} + +static int man_module_create(struct image *image, struct module *module, + struct sof_man_module *man_module) +{ + /* create module and segments */ + uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); + const struct adsp *adsp = image->adsp; + Elf32_Shdr *section; + size_t count; + int i, err; + unsigned pages; + + image->image_end = 0; + + err = man_get_module_manifest(image, module, man_module); + if (err < 0) + return err; + + /* stack size ??? convert sizes to PAGES */ + man_module->instance_bss_size = 1; + + /* max number of instances of this module ?? */ + man_module->instance_max_count = 1; + + fprintf(stdout, "\n\tTotals\tStart\t\tEnd\t\tSize"); + + fprintf(stdout, "\n\tTEXT\t0x%x\t0x%x\t0x%x\n", + module->text_start, module->text_end, + module->text_end - module->text_start); + fprintf(stdout, "\tDATA\t0x%x\t0x%x\t0x%x\n", + module->data_start, module->data_end, + module->data_end - module->data_start); + fprintf(stdout, "\tBSS\t0x%x\t0x%x\t0x%x\n\n ", + module->bss_start, module->bss_end, + module->bss_end - module->bss_start); + + /* main module */ + /* text section is first */ + man_module->segment[SOF_MAN_SEGMENT_TEXT].file_offset = + module->foffset; + man_module->segment[SOF_MAN_SEGMENT_TEXT].v_base_addr = + module->text_start; + + /* calculates those padding 0s by the start of next segment */ + pages = module->text_file_size / MAN_PAGE_SIZE; + if (module->text_file_size % MAN_PAGE_SIZE) + pages += 1; + + man_module->segment[SOF_MAN_SEGMENT_TEXT].flags.r.length = pages; + + /* data section */ + man_module->segment[SOF_MAN_SEGMENT_RODATA].v_base_addr = + module->data_start; + man_module->segment[SOF_MAN_SEGMENT_RODATA].file_offset = + module->foffset + module->text_file_size; + pages = module->data_file_size / MAN_PAGE_SIZE; + if (module->data_file_size % MAN_PAGE_SIZE) + pages += 1; + + man_module->segment[SOF_MAN_SEGMENT_RODATA].flags.r.length = pages; + + /* bss is last */ + man_module->segment[SOF_MAN_SEGMENT_BSS].file_offset = 0; + man_module->segment[SOF_MAN_SEGMENT_BSS].v_base_addr = module->bss_start; + pages = (module->bss_end - module->bss_start) / MAN_PAGE_SIZE; + if ((module->bss_end - module->bss_start) % MAN_PAGE_SIZE) + pages += 1; + man_module->segment[SOF_MAN_SEGMENT_BSS].flags.r.length = pages; + + fprintf(stdout, "\tNo\tAddress\t\tSize\tFile\tType\n"); + + /* find all sections and copy to corresponding segments */ + for (i = 0; i < module->hdr.e_shnum; i++) { + + section = &module->section[i]; + + /* only check valid sections */ + if (!(section->sh_flags & valid)) + continue; + + if (section->sh_size == 0) + continue; + + /* text or data section */ + if (!elf_is_rom(image, section)) + err = man_copy_elf_section(image, section, module, + man_module, i); + + if (err < 0) { + fprintf(stderr, "error: failed to write section #%d\n", i); + return err; + } + } + fprintf(stdout, "\n"); + + /* round module end upto nearest page */ + if (image->image_end % MAN_PAGE_SIZE) { + image->image_end = (image->image_end / MAN_PAGE_SIZE) + 1; + image->image_end *= MAN_PAGE_SIZE; + } + + fprintf(stdout, " Total pages text %d data %d bss %d module file limit: 0x%x\n\n", + man_module->segment[SOF_MAN_SEGMENT_TEXT].flags.r.length, + man_module->segment[SOF_MAN_SEGMENT_RODATA].flags.r.length, + man_module->segment[SOF_MAN_SEGMENT_BSS].flags.r.length, + image->image_end); + return 0; +} + +static int man_write_fw_mod(struct image *image) +{ + int count; + long unsigned int size = 0; + + /* write ROM - for VM use only */ + count = fwrite(image->rom_image, image->adsp->rom_size, 1, + image->out_rom_fd); + if (count != 1) { + fprintf(stderr, "error: failed to write rom %s %d\n", + image->out_rom_file, -errno); + return -errno; + } + fclose(image->out_rom_fd); + + /* write manifest and signed image */ + count = fwrite(image->fw_image, + image->image_end, + 1, image->out_fd); + + /* did the image write succeed ? */ + if (count != 1) { + fprintf(stderr, "error: failed to write signed firmware %s %d\n", + image->out_file, -errno); + return -errno; + } + + return 0; +} + +/* used by others */ +static int man_write_fw(struct image *image) +{ + struct sof_man_fw_desc *desc; + struct fw_image_manifest *m; + struct module *module; + struct sof_man_module *man_module; + uint8_t hash[SOF_MAN_MOD_SHA256_LEN]; + int ret, count, i, man_section_idx; + + /* init image */ + ret = man_init_image(image); + if (ret < 0) + goto err; + + /* open ROM image */ + ret = man_open_rom_file(image); + if (ret < 0) + goto err; + + /* create the manifest */ + ret = man_open_manifest_file(image); + if (ret < 0) + goto err; + + /* create the module */ + m = image->fw_image; + desc = image->fw_image + MAN_DESC_OFFSET; + + /* create each module */ + m->desc.header.num_module_entries = image->num_modules; + for (i = 0; i < image->num_modules; i++) { + + man_module = sof_man_get_module(desc, i); + module = &image->module[i]; + + /* set module file offset */ + if (i == 0) { + module->foffset = FILE_TEXT_OFFSET; + } else { + module->foffset = image->image_end; + } + + ret = man_module_create(image, module, man_module); + if (ret < 0) + goto err; + } + + fprintf(stdout, "Firmware completing manifest\n"); + + /* create structures from end of file to start of file */ + ri_adsp_meta_data_create(image); + ri_plat_ext_data_create(image); + ri_css_hdr_create(image); + ri_cse_create(image); + + fprintf(stdout, "Firmware file size 0x%x page count %d\n", + FILE_TEXT_OFFSET - MAN_DESC_OFFSET + image->image_end, + desc->header.preload_page_count); + + /* calculate hash for each module */ + for (i = 0; i < image->num_modules; i++) { + + module = &image->module[i]; + man_module = sof_man_get_module(desc, i); + + ri_hash(image, man_module->segment[SOF_MAN_SEGMENT_TEXT].file_offset, + (man_module->segment[SOF_MAN_SEGMENT_TEXT].flags.r.length + + man_module->segment[SOF_MAN_SEGMENT_RODATA].flags.r.length) * + MAN_PAGE_SIZE, man_module->hash); + } + + /* calculate hash for ADSP meta data extension - 0x480 to end */ + ri_hash(image, MAN_FW_DESC_OFFSET, image->image_end + - MAN_FW_DESC_OFFSET, m->adsp_file_ext.comp_desc[0].hash); + + /* calculate hash for platform auth data - repeated in hash 2 and 4 */ + ri_hash(image, MAN_META_EXT_OFFSET, + sizeof(struct sof_man_adsp_meta_file_ext), hash); + + /* hash values in reverse order */ + for (i = 0; i < SOF_MAN_MOD_SHA256_LEN; i++) { + m->signed_pkg.module[0].hash[i] = + m->partition_info.module[0].hash[i] = + hash[SOF_MAN_MOD_SHA256_LEN - 1 - i]; + } + + /* sign manifest */ + ret = ri_manifest_sign(image); + if (ret < 0) + goto err; + + /* write the firmware */ + ret = man_write_fw_mod(image); + if (ret < 0) + goto err; + + fprintf(stdout, "Firmware manifest and signing completed !\n"); + return 0; + +err: + free(image->rom_image); + free(image->fw_image); + unlink(image->out_file); + unlink(image->out_rom_file); + return ret; +} + +#define ADSP_APL_DSP_ROM_BASE 0xBEFE0000 +#define ADSP_APL_DSP_ROM_SIZE 0x00002000 +#define APL_DSP_BASE_ENTRY 0xa000a000 + +#define ADSP_CNL_DSP_ROM_BASE 0xBEFE0000 +#define ADSP_CNL_DSP_ROM_SIZE 0x00002000 +#define CNL_DSP_IMR_BASE_ENTRY 0xb0038000 +#define CNL_DSP_HP_BASE_ENTRY 0xbe040000 + +/* list of supported adsp */ +const struct adsp machine_apl = { + .name = "apl", + .rom_base = ADSP_APL_DSP_ROM_BASE, + .rom_size = ADSP_APL_DSP_ROM_SIZE, + .sram_base = APL_DSP_BASE_ENTRY, + .sram_size = 0x100000, + .image_size = 0x100000, + .dram_offset = 0, + .machine_id = MACHINE_APOLLOLAKE, + .write_firmware = man_write_fw, + .man = &apl_manifest, + .base_fw_text_size_fixup = 0xa000, +}; + +const struct adsp machine_cnl = { + .name = "cnl", + .rom_base = ADSP_CNL_DSP_ROM_BASE, + .rom_size = ADSP_CNL_DSP_ROM_SIZE, + .imr_base = CNL_DSP_IMR_BASE_ENTRY, + .imr_size = 0x100000, + .sram_base = CNL_DSP_HP_BASE_ENTRY, + .sram_size = 0x100000, + .image_size = 0x100000, + .dram_offset = 0, + .machine_id = MACHINE_CANNONLAKE, + .write_firmware = man_write_fw, + .man = &cnl_manifest, +}; diff --git a/rimage/manifest.h b/rimage/manifest.h new file mode 100644 index 000000000000..348f47f42493 --- /dev/null +++ b/rimage/manifest.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef __MANIFEST_H__ +#define __MANIFEST_H__ + +#include +#include +#include "css.h" +#include "cse.h" +#include "plat_auth.h" + +#define MAN_PAGE_SIZE 4096 + +/* start offset for base FW module */ +#define FILE_TEXT_OFFSET 0x8000 + +/* + * CSE values for CNL + */ +#define MAN_CSE_PARTS 3 + + +#define MAN_CSE_HDR_OFFSET 0 +#define MAN_CSE_PADDING_SIZE 0x30 +#define MAN_EXT_PADDING 0x20 +#define MAN_DESC_OFFSET 0x2000 + +#define MAN_CSS_HDR_OFFSET \ + (MAN_CSE_HDR_OFFSET + \ + sizeof(struct CsePartitionDirHeader) + \ + MAN_CSE_PARTS * sizeof(struct CsePartitionDirEntry)) + +#define MAN_SIG_PKG_OFFSET \ + (MAN_CSS_HDR_OFFSET + \ + sizeof(struct css_header)) + +#define MAN_PART_INFO_OFFSET \ + (MAN_SIG_PKG_OFFSET + \ + sizeof(struct signed_pkg_info_ext)) + +#define MAN_META_EXT_OFFSET \ + (MAN_SIG_PKG_OFFSET + \ + sizeof(struct signed_pkg_info_ext) + \ + sizeof(struct partition_info_ext) + \ + MAN_CSE_PADDING_SIZE) + +#define MAN_FW_DESC_OFFSET \ + (MAN_META_EXT_OFFSET + \ + sizeof(struct sof_man_adsp_meta_file_ext) + \ + MAN_EXT_PADDING) + +#define MAN_DESC_PADDING_SIZE \ + (MAN_DESC_OFFSET - MAN_FW_DESC_OFFSET) + +/* + * Firmware manifest header. + */ +struct fw_image_manifest { + /* MEU tool needs these sections to be 0s */ + struct CsePartitionDirHeader cse_partition_dir_header; + struct CsePartitionDirEntry cse_partition_dir_entry[MAN_CSE_PARTS]; + struct css_header css; + struct signed_pkg_info_ext signed_pkg; + struct partition_info_ext partition_info; + uint8_t cse_padding[MAN_CSE_PADDING_SIZE]; + struct sof_man_adsp_meta_file_ext adsp_file_ext; + + /* reserved / pading at end of ext data - all 0s*/ + uint8_t reserved[MAN_EXT_PADDING]; + + /* start of the unsigned binary for MEU input must start at MAN_DESC_OFFSET */ + uint8_t padding[MAN_DESC_PADDING_SIZE]; + + struct sof_man_fw_desc desc; /* at offset MAN_DESC_OFFSET */ +} __attribute__((packed)); + +extern struct fw_image_manifest apl_manifest; +extern struct fw_image_manifest cnl_manifest; +#endif diff --git a/rimage/pkcs1_5.c b/rimage/pkcs1_5.c new file mode 100644 index 000000000000..7783ac46bd93 --- /dev/null +++ b/rimage/pkcs1_5.c @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * Author: Liam Girdwood + * Keyon Jie + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "config.h" +#include "rimage.h" +#include "css.h" +#include "manifest.h" + +#define DEBUG_PKCS 0 + +static void bytes_swap(uint8_t *ptr, uint32_t size) +{ + uint8_t tmp; + uint32_t index; + + for (index = 0; index < (size / 2); index++) { + tmp = ptr[index]; + ptr[index] = ptr[size - 1 - index]; + ptr[size - 1 - index] = tmp; + } +} + +/* + * RSA signature of manifest. The signature is an PKCS + * #1-v1_5 of the entire manifest structure, including all + * extensions, and excluding the last 3 fields of the + * manifest header (Public Key, Exponent and Signature). +*/ + +int pkcs_sign(struct image *image, struct fw_image_manifest *man, + void *ptr1, unsigned size1, void *ptr2, unsigned size2) +{ + RSA *priv_rsa = NULL; + EVP_PKEY *privkey; + FILE *fp; + unsigned char digest[SHA256_DIGEST_LENGTH], path[256], mod[MAN_RSA_KEY_MODULUS_LEN]; + unsigned int siglen = MAN_RSA_SIGNATURE_LEN; + int ret = -EINVAL, i; + +#if DEBUG_PKCS + fprintf(stdout, "offsets 0x%lx size 0x%x offset 0x%lx size 0x%x\n", + ptr1 - (void*)man, size1, ptr2 - (void*)man, size2); +#endif + + /* create new key */ + privkey = EVP_PKEY_new(); + if (privkey == NULL) + return -ENOMEM; + + /* load in RSA private key from PEM file */ + if (image->key_name == NULL) { + sprintf(path, "%s/otc_private_key.pem", PEM_KEY_PREFIX); + image->key_name = path; + } + + fprintf(stdout, " pkcs: signing with key %s\n", image->key_name); + fp = fopen(image->key_name, "r"); + if (fp == NULL) { + fprintf(stderr, "error: can't open file %s %d\n", path, -errno); + return -errno; + } + PEM_read_PrivateKey(fp, &privkey, NULL, NULL); + fclose(fp); + + /* validate RSA private key */ + priv_rsa = EVP_PKEY_get1_RSA(privkey); + if (RSA_check_key(priv_rsa)) { + fprintf(stdout, " pkcs: RSA private key is valid.\n"); + } else { + fprintf(stderr, "error: validating RSA private key.\n"); + return -EINVAL; + } + + /* calculate the digest */ + module_sha256_create(image); + module_sha256_update(image, ptr1, size1); + module_sha256_update(image, ptr2, size2); + module_sha256_complete(image, digest); + + fprintf(stdout, " pkcs: digest for manifest is "); + for (i = 0; i < SHA256_DIGEST_LENGTH; i++) + fprintf(stdout, "%02x", digest[i]); + fprintf(stdout, "\n"); + + /* sign the manifest */ + ret = RSA_sign(NID_sha256, digest, SHA256_DIGEST_LENGTH, + (unsigned char *)man->css.signature, + &siglen, priv_rsa); + if (ret < 0) + fprintf(stderr, "error: failed to sign manifest\n"); + + /* copy public key modulus and exponent to manifest */ + BN_bn2bin(priv_rsa->n, mod); + BN_bn2bin(priv_rsa->e, (unsigned char*)man->css.exponent); + + /* modulus is reveresd */ + for (i = 0; i < MAN_RSA_KEY_MODULUS_LEN; i++) + man->css.modulus[i] = mod[MAN_RSA_KEY_MODULUS_LEN - (1 + i)]; + + /* signature is reveresd, swap it */ + bytes_swap(man->css.signature, sizeof(man->css.signature)); + + EVP_PKEY_free(privkey); + return ret; +} + +int ri_manifest_sign(struct image *image) +{ + struct fw_image_manifest *man = image->fw_image; + + pkcs_sign(image, man, (void *)man + MAN_CSS_HDR_OFFSET, + sizeof(struct css_header) - + (MAN_RSA_KEY_MODULUS_LEN + MAN_RSA_KEY_EXPONENT_LEN + + MAN_RSA_SIGNATURE_LEN), + (void *)man + MAN_SIG_PKG_OFFSET, + (man->css.size - man->css.header_len) * sizeof(uint32_t)); +} diff --git a/rimage/plat_auth.c b/rimage/plat_auth.c new file mode 100644 index 000000000000..21c7138cfbb1 --- /dev/null +++ b/rimage/plat_auth.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * Author: Liam Girdwood + * Keyon Jie + */ + +#include "rimage.h" +#include "manifest.h" +#include "plat_auth.h" + +void ri_adsp_meta_data_create(struct image *image) +{ + struct sof_man_adsp_meta_file_ext *meta = + image->fw_image + MAN_META_EXT_OFFSET; + + fprintf(stdout, " meta: completing ADSP manifest\n"); + + meta->comp_desc[0].limit_offset = MAN_DESC_OFFSET + image->image_end + - MAN_FW_DESC_OFFSET; + + fprintf(stdout, " meta: limit is 0x%x\n", + meta->comp_desc[0].limit_offset); + /* now hash the AdspFwBinaryDesc -> EOF */ +} + +void ri_plat_ext_data_create(struct image *image) +{ + struct partition_info_ext *part = image->fw_image + MAN_PART_INFO_OFFSET; + struct sof_man_adsp_meta_file_ext *meta = + image->fw_image + MAN_META_EXT_OFFSET; + struct sof_man_fw_desc *desc = image->fw_image + MAN_DESC_OFFSET; + + fprintf(stdout, " auth: completing authentication manifest\n"); + + part->length = meta->comp_desc[0].limit_offset - MAN_DESC_OFFSET; + part->length += MAN_PAGE_SIZE - (part->length % MAN_PAGE_SIZE); + + /* do this here atm */ + desc->header.preload_page_count = part->length / MAN_PAGE_SIZE; +} diff --git a/rimage/plat_auth.h b/rimage/plat_auth.h new file mode 100644 index 000000000000..135f2d1ce07c --- /dev/null +++ b/rimage/plat_auth.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2017, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef __PLAT_AUTH_H__ +#define __PLAT_AUTH_H__ + +#include + +struct image; + +#define PLAT_AUTH_SHA256_LEN 32 +#define PLAT_AUTH_NAME_LEN 12 +#define PLAT_AUTH_PADDING 48 /* pad at end of struct */ + +#define SIGN_PKG_EXT_TYPE 15 +#define SIGN_PKG_NUM_MODULE 1 + +struct signed_pkg_info_module { + uint8_t name[PLAT_AUTH_NAME_LEN]; /* must be padded with 0 */ + uint8_t type; + uint8_t hash_algo; + uint16_t hash_size; + uint32_t meta_size; + uint8_t hash[PLAT_AUTH_SHA256_LEN]; +} __attribute__((packed)); + +struct signed_pkg_info_ext { + uint32_t ext_type; + uint32_t ext_len; + + uint8_t name[4]; + uint32_t vcn; + uint8_t bitmap[16]; + uint32_t svn; + uint8_t fw_type; + uint8_t fw_sub_type; + uint8_t reserved[14]; /* must be 0 */ + + /* variable length of modules */ + struct signed_pkg_info_module module[SIGN_PKG_NUM_MODULE]; +} __attribute__((packed)); + + +#define PART_INFO_EXT_TYPE 3 +#define PART_INFO_NUM_MODULE 1 + +struct partition_info_module { + uint8_t name[PLAT_AUTH_NAME_LEN]; /* must be padded with 0 */ + uint8_t type; + uint8_t reserved[3]; + uint32_t meta_size; + uint8_t hash[PLAT_AUTH_SHA256_LEN]; +} __attribute__((packed)); + +struct partition_info_ext { + uint32_t ext_type; + uint32_t ext_len; + + uint8_t name[4]; /* "ADSP" */ + uint32_t length; + uint8_t hash[PLAT_AUTH_SHA256_LEN]; + + uint32_t vcn; + uint32_t part_version; + uint32_t fmt_version; + uint32_t instance_id; + uint32_t part_flags; + uint8_t reserved[20]; /* must be 0 */ + + /* variable length of modules */ + struct partition_info_module module[PART_INFO_NUM_MODULE]; +} __attribute__((packed)); + + +#define PLAT_AUTH_SIZE \ + (sizeof(struct partition_info_ext) + \ + sizeof(struct signed_pkg_info_ext)) + +void ri_adsp_meta_data_create(struct image *image); +void ri_plat_ext_data_create(struct image *image); + +#endif diff --git a/rimage/rimage.c b/rimage/rimage.c index af4a7d0df6cc..f407a42a0c24 100644 --- a/rimage/rimage.c +++ b/rimage/rimage.c @@ -21,204 +21,21 @@ #include "rimage.h" #include "file_format.h" +#include "manifest.h" static const struct adsp *machine[] = { - &byt_machine, - &cht_machine, + &machine_byt, + &machine_cht, + &machine_bsw, + &machine_hsw, + &machine_bdw, + &machine_apl, + &machine_cnl, }; -static int read_elf_sections(struct image *image) -{ - size_t count; - int i, ret; - uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - - /* read in section header */ - ret = fseek(image->in_fd, image->hdr.e_shoff, SEEK_SET); - if (ret < 0) { - fprintf(stderr, "error: cant seek to section header %d\n", ret); - return ret; - } - - image->section = calloc(sizeof(Elf32_Shdr), image->hdr.e_shnum); - if (image->section == NULL) - return -ENOMEM; - - count = fread(image->section, sizeof(Elf32_Shdr), - image->hdr.e_shnum, image->in_fd); - if (count != image->hdr.e_shnum) { - fprintf(stderr, "error: failed to read section header %d\n", - -errno); - return -errno; - } - - for (i = 0; i < image->hdr.e_shnum; i++) { - - /* only write valid sections */ - if (!(image->section[i].sh_flags & valid)) - continue; - - switch (image->section[i].sh_type) { - case SHT_NOBITS: - /* bss */ - image->bss_size += image->section[i].sh_size; - image->num_bss++; - break; - case SHT_PROGBITS: - /* text or data */ - image->fw_size += image->section[i].sh_size; - - if (image->section[i].sh_flags & SHF_EXECINSTR) - image->text_size += image->section[i].sh_size; - else - image->data_size += image->section[i].sh_size; - break; - default: - continue; - } - - image->num_sections++; - - if (!image->verbose) - continue; - - fprintf(stdout, "section-%d: \ttype\t 0x%8.8x\n", i, - image->section[i].sh_type); - fprintf(stdout, "section-%d: \tflags\t 0x%8.8x\n", i, - image->section[i].sh_flags); - fprintf(stdout, "section-%d: \taddr\t 0x%8.8x\n", i, - image->section[i].sh_addr); - fprintf(stdout, "section-%d: \toffset\t 0x%8.8x\n", i, - image->section[i].sh_offset); - fprintf(stdout, "section-%d: \tsize\t 0x%8.8x\n", i, - image->section[i].sh_size); - fprintf(stdout, "section-%d: \tlink\t 0x%8.8x\n", i, - image->section[i].sh_link); - fprintf(stdout, "section-%d: \tinfo\t 0x%8.8x\n\n", i, - image->section[i].sh_info); - } - - return 0; -} - -static int read_elf_programs(struct image *image) -{ - size_t count; - int i, ret; - - /* read in program header */ - ret = fseek(image->in_fd, image->hdr.e_phoff, SEEK_SET); - if (ret < 0) { - fprintf(stderr, "error: cant seek to program header %d\n", ret); - return ret; - } - - image->prg = calloc(sizeof(Elf32_Phdr), image->hdr.e_phnum); - if (image->prg == NULL) - return -ENOMEM; - - count = fread(image->prg, sizeof(Elf32_Phdr), - image->hdr.e_phnum, image->in_fd); - if (count != image->hdr.e_phnum) { - fprintf(stderr, "error: failed to read program header %d\n", - -errno); - return -errno; - } - - for (i = 0; i < image->hdr.e_phnum; i++) { - - if (image->prg[i].p_filesz == 0) - continue; - - if (!image->verbose) - continue; - - fprintf(stdout, "program-%d: \ttype\t 0x%8.8x\n", i, - image->prg[i].p_type); - fprintf(stdout, "program-%d: \toffset\t 0x%8.8x\n", i, - image->prg[i].p_offset); - fprintf(stdout, "program-%d: \tvaddr\t 0x%8.8x\n", i, - image->prg[i].p_vaddr); - fprintf(stdout, "program-%d: \tpaddr\t 0x%8.8x\n", i, - image->prg[i].p_paddr); - fprintf(stdout, "program-%d: \tfsize\t 0x%8.8x\n", i, - image->prg[i].p_filesz); - fprintf(stdout, "program-%d: \tmsize\t 0x%8.8x\n", i, - image->prg[i].p_memsz); - fprintf(stdout, "program-%d: \tflags\t 0x%8.8x\n\n", i, - image->prg[i].p_flags); - } - - return 0; -} - -static int write_elf_data(struct image *image) -{ - const struct adsp *adsp = image->adsp; - int ret = 0; - size_t count; - - /* read in elf header */ - count = fread(&image->hdr, sizeof(image->hdr), 1, image->in_fd); - if (count != 1) { - fprintf(stderr, "error: failed to read elf header %d\n", - -errno); - return -errno; - } - - fprintf(stdout, "elf: \tentry point\t 0x%8.8x\n", image->hdr.e_entry); - fprintf(stdout, "elf: \tprogram offset\t 0x%8.8x\n", image->hdr.e_phoff); - fprintf(stdout, "elf: \tsection offset\t 0x%8.8x\n", image->hdr.e_shoff); - fprintf(stdout, "elf: \tprogram size\t 0x%8.8x\n", image->hdr.e_phentsize); - fprintf(stdout, "elf: \tprogram count\t 0x%8.8x\n", image->hdr.e_phnum); - fprintf(stdout, "elf: \tsection size\t 0x%8.8x\n", image->hdr.e_shentsize); - fprintf(stdout, "elf: \tsection count\t 0x%8.8x\n", image->hdr.e_shnum); - fprintf(stdout, "elf: \tstring index\t 0x%8.8x\n\n", image->hdr.e_shstrndx); - - ret = read_elf_programs(image); - if (ret < 0) { - fprintf(stderr, "error: failed to read program sections %d\n", ret); - goto out; - } - - ret = read_elf_sections(image); - if (ret < 0) { - fprintf(stderr, "error: failed to read sections %d\n", ret); - goto out; - } - - fprintf(stdout, "fw: input size %d (0x%x) bytes %d sections\n", - image->fw_size, image->fw_size, image->num_sections); - fprintf(stdout, "fw: text %d (0x%x) bytes\n" - " data %d (0x%x) bytes\n" - " bss %d (0x%x) bytes\n", - image->text_size, image->text_size, - image->data_size, image->data_size, - image->bss_size, image->bss_size); - - ret = adsp->ops.write_header(image); - if (ret < 0) { - fprintf(stderr, "error: failed to write header %d\n", ret); - goto out; - } - - ret = adsp->ops.write_modules(image); - if (ret < 0) { - fprintf(stderr, "error: failed to write modules %d\n", ret); - goto out; - } - -out: - if (image->prg) - free(image->prg); - if (image->section) - free(image->section); - return ret; -} - static void usage(char *name) { - fprintf(stdout, "%s:\t -m machine -i infile -o outfile\n", name); + fprintf(stdout, "%s:\t -m machine -o outfile -k [key] ELF files\n", name); fprintf(stdout, "\t -v enable verbose output\n"); exit(0); } @@ -227,42 +44,48 @@ int main(int argc, char *argv[]) { struct image image; const char *mach = NULL; - int opt, ret, i; + int opt, ret, i, binary = 0, elf_argc = 0; memset(&image, 0, sizeof(image)); - image.text_start = 0xffffffff; - image.data_start = 0xffffffff; - image.bss_start = 0xffffffff; - while ((opt = getopt(argc, argv, "ho:i:m:vba:sk:")) != -1) { + while ((opt = getopt(argc, argv, "ho:m:vba:sk:l:")) != -1) { switch (opt) { case 'o': image.out_file = optarg; break; - case 'i': - image.in_file = optarg; - break; case 'm': mach = optarg; break; case 'v': image.verbose = 1; break; + case 'b': + binary = 1; + break; case 's': image.dump_sections = 1; break; case 'a': image.abi = atoi(optarg); break; + case 'k': + image.key_name = optarg; + break; case 'h': - default: /* '?' */ usage(argv[0]); + break; + default: + break; } } - if (image.in_file == NULL || image.out_file == NULL || mach == NULL) + elf_argc = optind; + + /* make sure we have an outfile and machine */ + if (image.out_file == NULL || mach == NULL) usage(argv[0]); + /* find machine */ for (i = 0; i < ARRAY_SIZE(machine); i++) { if (!strcmp(mach, machine[i]->name)) { @@ -274,20 +97,26 @@ int main(int argc, char *argv[]) fprintf(stderr, "error: available machines "); for (i = 0; i < ARRAY_SIZE(machine); i++) fprintf(stderr, "%s, ", machine[i]->name); - fprintf(stderr, "/n"); + fprintf(stderr, "\n"); return -EINVAL; found: - /* open infile for reading */ - image.in_fd = fopen(image.in_file, "r"); - if (image.in_fd == NULL) { - fprintf(stderr, "error: unable to open %s for reading %d\n", - image.in_file, errno); - ret = -EINVAL; - goto out; + + /* parse input ELF files */ + image.num_modules = argc - elf_argc; + for (i = elf_argc; i < argc; i++) { + fprintf(stdout, "\nModule Reading %s\n", argv[i]); + ret = elf_parse_module(&image, i - elf_argc, argv[i]); + if (ret < 0) + goto out; } + /* validate all modules */ + ret = elf_validate_modules(&image); + if (ret < 0) + goto out; + /* open outfile for writing */ unlink(image.out_file); image.out_fd = fopen(image.out_file, "w"); @@ -298,16 +127,13 @@ int main(int argc, char *argv[]) goto out; } - /* write data */ - ret = write_elf_data(&image); - + /* process and write output */ + ret = image.adsp->write_firmware(&image); out: /* close files */ - if (image.in_fd) - fclose(image.in_fd); if (image.out_fd) fclose(image.out_fd); + return ret; } - diff --git a/rimage/rimage.h b/rimage/rimage.h index 9b8200afa36d..84ff93f74114 100644 --- a/rimage/rimage.h +++ b/rimage/rimage.h @@ -1,7 +1,7 @@ /* * ELF to firmware image creator. * - * Copyright (c) 2015, Intel Corporation. + * Copyright (c) 2015-2018 Intel Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -25,92 +25,140 @@ #include #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) +#define MAX_MODULES 32 struct adsp; -struct fw_image_manifest; +struct manifest; +struct man_module; + +/* list of supported targets */ +enum machine_id { + MACHINE_BAYTRAIL = 0, + MACHINE_CHERRYTRAIL, + MACHINE_BRASWELL, + MACHINE_HASWELL, + MACHINE_BROADWELL, + MACHINE_APOLLOLAKE, + MACHINE_CANNONLAKE, + MACHINE_MAX +}; + +/* + * ELF module data + */ +struct module { + const char *elf_file; + FILE *fd; -struct image { - const char *in_file; - const char *out_file; - FILE *in_fd; - FILE *out_fd; - void *pos; Elf32_Ehdr hdr; Elf32_Shdr *section; Elf32_Phdr *prg; - const struct adsp *adsp; - int abi; - int verbose; - int num_sections; - int num_bss; - int fw_size; - int bss_size; - int text_size; - int data_size; - int file_size; - int num_modules; uint32_t text_start; uint32_t text_end; uint32_t data_start; uint32_t data_end; uint32_t bss_start; uint32_t bss_end; + uint32_t foffset; + int num_sections; + int num_bss; + int fw_size; - /* disa */ - void *in_buffer; - void *out_buffer; - int dump_sections; -}; + /* sizes do not include any gaps */ + int bss_size; + int text_size; + int data_size; -struct section { - const char *name; - uint32_t addr; - uint32_t size; + /* sizes do include gaps to nearest page */ + int bss_file_size; + int text_file_size; + int data_file_size; }; -struct adsp_ops { - /* write header or manifest */ - int (*write_header)(struct image *image); - /* write data modules */ - int (*write_modules)(struct image *image); -}; +/* + * Firmware image context. + */ +struct image { -enum machine_id { - MACHINE_BAYTRAIL = 0, - MACHINE_CHERRYTRAIL, - MACHINE_MAX + const char *out_file; + FILE *out_fd; + void *pos; + + const struct adsp *adsp; + int abi; + int verbose; + int num_modules; + struct module module[MAX_MODULES]; + uint32_t image_end;/* module end, equal to output image size */ + int dump_sections; + + /* SHA 256 */ + const char *key_name; + EVP_MD_CTX *mdctx; + const EVP_MD *md; + + /* file IO */ + void *fw_image; + void *rom_image; + FILE *out_rom_fd; + FILE *out_man_fd; + FILE *out_unsigned_fd; + char out_rom_file[256]; + char out_man_file[256]; + char out_unsigned_file[256]; }; +/* + * Audio DSP descriptor and operations. + */ struct adsp { const char *name; uint32_t iram_base; uint32_t iram_size; uint32_t dram_base; uint32_t dram_size; + uint32_t sram_base; + uint32_t sram_size; uint32_t host_iram_offset; uint32_t host_dram_offset; + uint32_t rom_base; + uint32_t rom_size; + uint32_t imr_base; + uint32_t imr_size; uint32_t image_size; uint32_t dram_offset; enum machine_id machine_id; - struct adsp_ops ops; - const struct section *sections; -}; + int (*write_firmware)(struct image *image); + struct fw_image_manifest *man; -/* headers used by multiple platforms */ -int byt_write_header(struct image *image); + /* fixups */ + uint32_t base_fw_text_size_fixup; /* added to BASEFW text size */ +}; -/* modules used by multiple platforms */ -int byt_write_modules(struct image *image); +void module_sha256_create(struct image *image); +void module_sha256_update(struct image *image, uint8_t *data, size_t bytes); +void module_sha256_complete(struct image *image, uint8_t *hash); +int ri_manifest_sign(struct image *image); +void ri_hash(struct image *image, unsigned offset, unsigned size, char *hash); -/* for disassembly */ -int write_byt_binary_image(struct image *image); +int elf_parse_module(struct image *image, int module_index, const char *name); +void elf_free_module(struct image *image, int module_index); +int elf_is_rom(struct image *image, Elf32_Shdr *section); +int elf_validate_modules(struct image *image); +int elf_find_section(struct image *image, struct module *module, + const char *name); /* supported machines */ -extern const struct adsp byt_machine; -extern const struct adsp cht_machine; +extern const struct adsp machine_byt; +extern const struct adsp machine_cht; +extern const struct adsp machine_bsw; +extern const struct adsp machine_hsw; +extern const struct adsp machine_bdw; +extern const struct adsp machine_apl; +extern const struct adsp machine_cnl; #endif From b8ba5f65f2920a3a23f5a4ffa57a9008d8e36bdc Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Wed, 24 Jan 2018 13:41:16 +0800 Subject: [PATCH 093/324] topology: test: fix buffer size for volume We may have different buffer size around volume. Change the size due to the endpoint setting. Signed-off-by: Pan Xiuli --- topology/sof/pipe-volume-capture.m4 | 2 +- topology/sof/pipe-volume-playback.m4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 258f8fa3d639..8532aa3c11ca 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -53,7 +53,7 @@ W_PGA(0, Master Capture Volume, PIPELINE_FORMAT, 2, 2, 2) W_BUFFER(0, COMP_BUFFER_SIZE(2, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) W_BUFFER(1, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) # # DAI definitions diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index b5321613d453..54bc13d6d6ba 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -53,7 +53,7 @@ W_PGA(0, Master Playback Volume, PIPELINE_FORMAT, 2, 2, 2) W_BUFFER(0, COMP_BUFFER_SIZE(2, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) W_BUFFER(1, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) # # DAI definitions From 8c9ebfe9c4f8037b0d0816dedcb87dabef347c6b Mon Sep 17 00:00:00 2001 From: Luo Xionghu Date: Fri, 26 Jan 2018 16:29:37 +0800 Subject: [PATCH 094/324] 2/3] rimage: add return for non-void function. Signed-off-by: Luo Xionghu --- rimage/pkcs1_5.c | 1 + 1 file changed, 1 insertion(+) diff --git a/rimage/pkcs1_5.c b/rimage/pkcs1_5.c index 7783ac46bd93..0c5806b2cad3 100644 --- a/rimage/pkcs1_5.c +++ b/rimage/pkcs1_5.c @@ -137,4 +137,5 @@ int ri_manifest_sign(struct image *image) MAN_RSA_SIGNATURE_LEN), (void *)man + MAN_SIG_PKG_OFFSET, (man->css.size - man->css.header_len) * sizeof(uint32_t)); + return 0; } From b5cea7f966e21f6930afe2b8e41edf3b02014231 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Mon, 29 Jan 2018 14:08:13 +0800 Subject: [PATCH 095/324] rimage: add check for .bss section We may have heap buffers for base FW, but they are handled by the runtime function. We did not need to set them as bss in FW manifest. So add check to mark the .bss segment as BSS and other segment as HEAP. Then we only update manifest BSS segmet with BSS section. Signed-off-by: Pan Xiuli --- rimage/elf.c | 26 ++++++++++++++++++++------ rimage/rimage.h | 1 + 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/rimage/elf.c b/rimage/elf.c index b91247761a4f..1dc48f3bf6cb 100644 --- a/rimage/elf.c +++ b/rimage/elf.c @@ -27,6 +27,7 @@ static int elf_read_sections(struct image *image, struct module *module) size_t count; int i, ret; uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); + int man_section_idx; /* read in section header */ ret = fseek(module->fd, hdr->e_shoff, SEEK_SET); @@ -50,6 +51,16 @@ static int elf_read_sections(struct image *image, struct module *module) return -errno; } + /* find manifest module data */ + man_section_idx = elf_find_section(image, module, ".bss"); + if (man_section_idx < 0) { + return -EINVAL; + } + module->bss_index = man_section_idx; + + fprintf(stdout, " BSS module metadata section at index %d\n", + man_section_idx); + /* parse each section */ for (i = 0; i < hdr->e_shnum; i++) { @@ -211,7 +222,7 @@ int elf_is_rom(struct image *image, Elf32_Shdr *section) } static void elf_module_size(struct image *image, struct module *module, - Elf32_Shdr *section) + Elf32_Shdr *section, int index) { switch (section->sh_type) { case SHT_PROGBITS: @@ -236,12 +247,14 @@ static void elf_module_size(struct image *image, struct module *module, break; case SHT_NOBITS: /* bss */ - if (module->bss_start > section->sh_addr) + if (index == module->bss_index) { + /* updated the .bss segment */ module->bss_start = section->sh_addr; - if (module->bss_end < section->sh_addr + section->sh_size) module->bss_end = section->sh_addr + section->sh_size; - - fprintf(stdout, "\tBSS\n"); + fprintf(stdout, "\tBSS\n"); + } else { + fprintf(stdout, "\tHEAP\n"); + } break; default: break; @@ -282,7 +295,8 @@ static void elf_module_limits(struct image *image, struct module *module) section->sh_size); /* text or data section */ - elf_module_size(image, module, section); + elf_module_size(image, module, section, i); + } fprintf(stdout, "\n"); diff --git a/rimage/rimage.h b/rimage/rimage.h index 84ff93f74114..a68f1a878b62 100644 --- a/rimage/rimage.h +++ b/rimage/rimage.h @@ -65,6 +65,7 @@ struct module { int num_sections; int num_bss; int fw_size; + int bss_index; /* sizes do not include any gaps */ int bss_size; From 57be4f5b8c96ba5839598046be4b4543ce8cf63b Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 1 Feb 2018 15:13:32 +0800 Subject: [PATCH 096/324] rimage: fix manifest header path We moved header manifest.h is sof/upai now. Modify the configure path and include path. Signed-off-by: Pan Xiuli --- configure.ac | 2 +- rimage/manifest.c | 2 +- rimage/manifest.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 6e9c758efd3a..f85f18ce5907 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT([sof-tools], [1.0.1]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_SRCDIR([rimage/rimage.c]) AC_CONFIG_HEADERS([config.h]) -AC_CHECK_HEADER([sof/manifest.h]) +AC_CHECK_HEADER([sof/uapi/manifest.h]) AC_CANONICAL_HOST diff --git a/rimage/manifest.c b/rimage/manifest.c index 24fb76fef9ce..68e6d8b64138 100644 --- a/rimage/manifest.c +++ b/rimage/manifest.c @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include "rimage.h" #include "file_format.h" diff --git a/rimage/manifest.h b/rimage/manifest.h index 348f47f42493..655963f15ead 100644 --- a/rimage/manifest.h +++ b/rimage/manifest.h @@ -15,7 +15,7 @@ #define __MANIFEST_H__ #include -#include +#include #include "css.h" #include "cse.h" #include "plat_auth.h" From 33e4b0cc6f6a44e3e7ee849c04c515a5537242c7 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 8 Feb 2018 21:01:24 +0800 Subject: [PATCH 097/324] topology: test: change to use volume topology files for apl at the moment. As it doesn't work for pass through at the moment. Signed-off-by: Keyon Jie --- topology/test/tplg-build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index d322ce784161..047ef6bc6a1a 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -70,7 +70,8 @@ simple_test baytrail volume "Baytrail Audio" s24le 2 s24le 25 24 2400000 1920000 simple_test baytrail volume "Baytrail Audio" s16le 2 s24le 25 24 2400000 19200000 simple_test baytrail src "Baytrail Audio" s24le 2 s24le 25 24 2400000 19200000 -simple_test nocodec passthrough "NoCodec" s16le 4 s16le 16 16 1536000 24576000 -simple_test apollolake passthrough "SSP4-Codec" s16le 4 s16le 16 16 1536000 24576000 +# for APL +simple_test nocodec volume "NoCodec" s16le 4 s16le 16 16 1536000 24576000 +simple_test codec volume "SSP4-Codec" s16le 4 s16le 16 16 1536000 24576000 From 4d408b0cec1af30b005c2bd49095cb7d7d93b0e3 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Fri, 9 Feb 2018 10:40:22 +0800 Subject: [PATCH 098/324] topology: add toplogy for CNL with RT274 codec Support playback and capture with volume control at 48KHZ, 24Bit, TDM4 but only 2 channel valid Signed-off-by: Rander Wang --- topology/reef-cnl-rt274.m4 | 70 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 topology/reef-cnl-rt274.m4 diff --git a/topology/reef-cnl-rt274.m4 b/topology/reef-cnl-rt274.m4 new file mode 100644 index 000000000000..67aab04670a8 --- /dev/null +++ b/topology/reef-cnl-rt274.m4 @@ -0,0 +1,70 @@ +# +# Topology for generic Cannonlake board with RT274 +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`dsps/bxt.m4') + +# +# Define the pipelines +# +# PCM0 ----> volume -----> volume ----> SSP0 +# +# PCM1 <---- Volume <---- SSP0 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 1, 0, 2, s24le, + 48, 1000, 0, 0, 0, 1, SSP, 0, s24le, 2) + +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 2, 0, 2, s24le, + 48, 1000, 0, 0, 0, 1, SSP, 0, s24le, 2) + +# +# DAI configuration +# +# SSP port 0 is our only pipeline DAI +# + +# playback DAI is SSP0 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 0, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) + +# capture DAI is SSP0 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, 0, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) + +# PCM Low Latency +PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + +# +# BE configurations - overrides config in ACPI if present +# +DAI_CONFIG(SSP, 0, SSP0-Codec, DSP_B, 24, + DAI_CLOCK(mclk, 24000000, slave), + DAI_CLOCK(bclk, 4800000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(4, 25, 3, 3)) From f0b21aee38b7365d6fcd2ae52612406c3c182afb Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Fri, 9 Feb 2018 09:36:21 -0800 Subject: [PATCH 099/324] topology: fix typos in capture pipelines This patch fixes typos in the capture pipelines to avoid confusion. Signed-off-by: Ranjani Sridharan --- topology/sof/pipe-dai-capture.m4 | 2 +- topology/sof/pipe-src-capture.m4 | 4 ++-- topology/sof/pipe-volume-capture.m4 | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/topology/sof/pipe-dai-capture.m4 b/topology/sof/pipe-dai-capture.m4 index ab63efd6b807..e69991ecee55 100644 --- a/topology/sof/pipe-dai-capture.m4 +++ b/topology/sof/pipe-dai-capture.m4 @@ -1,4 +1,4 @@ -# DAI Playback connector +# DAI Capture connector # Include topology builder include(`local.m4') diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index c843a6c592aa..dc55dd2f7223 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -12,7 +12,7 @@ include(`local.m4') # Components and Buffers # -# Host "Passthrough Playback" PCM uses pipeline DMAC and channel +# Host "Passthrough Capture" PCM uses pipeline DMAC and channel # with 4 sink and 0 source periods W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) @@ -35,7 +35,7 @@ SectionData."media_src_conf" { # "SRC" has 4 source and 4 sink periods W_SRC(0, PIPELINE_FORMAT, 4, 4, media_src_conf, 2) -# Playback Buffers +# Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(4, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) W_BUFFER(1, COMP_BUFFER_SIZE(4, diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 8532aa3c11ca..303090745d1b 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -44,12 +44,12 @@ SectionControlMixer.STR(Master Capture Volume) { # Host "Passthrough Capture" PCM uses pipeline DMAC and channel # with 0 sink and 2 source periods -W_PCM_CAPTURE(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) +W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) # "Volume" has 2 source and 2 sink periods W_PGA(0, Master Capture Volume, PIPELINE_FORMAT, 2, 2, 2) -# Playback Buffers +# Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) W_BUFFER(1, COMP_BUFFER_SIZE(2, From 09325e91fc43f39c99abb03b708e13637bfa6fc4 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Fri, 9 Feb 2018 23:49:17 -0800 Subject: [PATCH 100/324] topology: Allow multiple kcontrols for volume widget This patch adds support for multiple kcontrols for the volume widget and adds a mute switch kcontrol to the volume playback pipeline. Signed-off-by: Ranjani Sridharan --- topology/m4/local.m4 | 21 +++++++++++------ topology/sof/pipe-low-latency-capture.m4 | 2 +- topology/sof/pipe-low-latency-playback.m4 | 4 ++-- topology/sof/pipe-pcm-media.m4 | 2 +- topology/sof/pipe-tone.m4 | 2 +- topology/sof/pipe-volume-capture.m4 | 2 +- topology/sof/pipe-volume-playback.m4 | 28 ++++++++++++++++++++++- 7 files changed, 47 insertions(+), 14 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index ad72a117dcc7..02d79a5f5622 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -4,6 +4,13 @@ define(`concat',`$1$2') define(`STR', `"'$1`"') +define(`argn', `ifelse(`$1', 1, ``$2'', + `argn(decr(`$1'), shift(shift($@)))')') + +define(`KCONTROLS', `pushdef(`i', $#) pushdef(`j', `1') KCONTROL_LOOP($@)') +define(`KCONTROL_LOOP', `argn(j,$@) + ifelse(i,`1', `', `define(`i', decr(i)) define(`j', incr(j)) $0($@)')') + dnl create direct DAPM/pipeline link between 2 widgets) define(`dapm', `"$1, , $2"') @@ -143,14 +150,14 @@ define(`W_PCM_CAPTURE', dnl PGA name) define(`N_PGA', `PGA'PIPELINE_ID`.'$1) -dnl W_PGA(name, kcontrol, format, periods_sink, periods_source, preload) +dnl W_PGA(name, format, periods_sink, periods_source, preload, kcontrol0. kcontrol1...etc) define(`W_PGA', -`SectionVendorTuples."'N_PGA($1)`_tuples_w" {' +`pushdef(`args',`eval($#-6)')SectionVendorTuples."'N_PGA($1)`_tuples_w" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) ` }' `}' `SectionData."'N_PGA($1)`_data_w" {' @@ -159,7 +166,7 @@ define(`W_PGA', `SectionVendorTuples."'N_PGA($1)`_tuples_str" {' ` tokens "sof_comp_tokens"' ` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($3) +` SOF_TKN_COMP_FORMAT' STR($2) ` }' `}' `SectionData."'N_PGA($1)`_data_str" {' @@ -174,7 +181,7 @@ define(`W_PGA', ` "'N_PGA($1)`_data_str"' ` ]' ` mixer [' -` "'$2`"' + $6 ` ]' `}') diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 0c989a76c58a..2602ebd9da13 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -48,7 +48,7 @@ SectionControlMixer.STR(PCM PCM_ID Capture Volume) { W_PCM_CAPTURE(Low Latency Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 0) # "Capture Volume" has 2 sink and source periods for host and DAI ping-pong -W_PGA(0, PCM PCM_ID Capture Volume, PIPELINE_FORMAT, 2, 2, 0) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, KCONTROLS("PCM PCM_ID Capture Volume")) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index cd04ccfa7fa5..ebb14ec57625 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -91,10 +91,10 @@ SectionControlMixer.STR(Master Playback Volume) { W_PCM_PLAYBACK(Low Latency Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Playback Volume" has 1 sink period and 2 source periods for host ping-pong -W_PGA(0, PCM PCM_ID Playback Volume, PIPELINE_FORMAT, 1, 2, 1) +W_PGA(0, PIPELINE_FORMAT, 1, 2, 1, KCONTROLS("PCM PCM_ID Playback Volume")) # "Master Playback Volume" has 1 source and 2 sink periods for DAI ping-pong -W_PGA(1, Master Playback Volume, PIPELINE_FORMAT, 2, 1, 1) +W_PGA(1, PIPELINE_FORMAT, 2, 1, 1, KCONTROLS("Master Playback Volume")) # Mixer 0 has 1 sink and source periods. W_MIXER(0, PIPELINE_FORMAT, 1, 1, 1) diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 7bfb35a35774..526ae352367c 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -68,7 +68,7 @@ SectionData."media_src_conf" { W_PCM_PLAYBACK(Media Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Playback Volume" has 2 sink period and 2 source periods for host ping-pong -W_PGA(0, PCM PCM_ID Playback Volume, PIPELINE_FORMAT, 2, 2, 2) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("PCM PCM_ID Playback Volume")) # "SRC 0" has 2 sink and source periods. W_SRC(0, PIPELINE_FORMAT, 2, 2, media_src_conf, 2) diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index ccead1068ea3..e04a1b95ea5f 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -50,7 +50,7 @@ SectionControlMixer.STR(Tone Volume PIPELINE_ID) { W_TONE(0, PIPELINE_FORMAT, 2, 0, 0) # "Tone Volume" has 2 sink period and 2 source periods -W_PGA(0, Tone Volume PIPELINE_ID, PIPELINE_FORMAT, 2, 2, 0) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, KCONTROLS("Tone Volume PIPELINE_ID")) # Low Latency Buffers W_BUFFER(0,COMP_BUFFER_SIZE(2, diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 303090745d1b..58e5393b4ad6 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -47,7 +47,7 @@ SectionControlMixer.STR(Master Capture Volume) { W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) # "Volume" has 2 source and 2 sink periods -W_PGA(0, Master Capture Volume, PIPELINE_FORMAT, 2, 2, 2) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("Master Capture Volume")) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 54bc13d6d6ba..8aa02fbc50c2 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -38,6 +38,32 @@ SectionControlMixer.STR(Master Playback Volume) { tlv "vtlv_m90s3" } +SectionControlMixer.STR(Master Playback Volume Switch) { + + # control belongs to this index group + index STR(PIPELINE_ID) + + # Channel register and shift for Front Left/Right + channel."FL" { + reg "1" + shift "0" + } + channel."FR" { + reg "1" + shift "1" + } + + # control uses bespoke driver get/put/info ID 0 + ops."ctl" { + info "volsw" + get "256" + put "256" + } + + # Volume mute on/off + max "1" + invert "false" +} # # Components and Buffers # @@ -47,7 +73,7 @@ SectionControlMixer.STR(Master Playback Volume) { W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Volume" has 2 source and 2 sink periods -W_PGA(0, Master Playback Volume, PIPELINE_FORMAT, 2, 2, 2) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("Master Playback Volume Switch", "Master Playback Volume")) # Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, From f6924b170146ea21b50c56369c5901ac32077011 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Sun, 11 Feb 2018 07:29:42 +0800 Subject: [PATCH 101/324] topology: m4: add default_hw_conf_id Add default_hw_conf_id to set the default_hw_config_id value in ASOC and then we can set the dai config. Signed-off-by: Pan Xiuli --- topology/m4/local.m4 | 1 + 1 file changed, 1 insertion(+) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 02d79a5f5622..29b8b29b41d0 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -460,6 +460,7 @@ define(`DAI_CONFIG', `' `SectionBE."'$3`" {' ` index "0"' +` default_hw_conf_id "'$2`"' `' ` hw_configs [' ` "'$1$2`"' From 72d797d9ddae79b21583e5d44cb03963fb5129be Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 13 Feb 2018 20:44:03 +0000 Subject: [PATCH 102/324] rimage: move rimage to sof firmware repo This removes cyclic dependency between both repos. Signed-off-by: Liam Girdwood --- Makefile.am | 2 +- configure.ac | 14 +- rimage/Makefile.am | 25 -- rimage/cse.c | 45 ---- rimage/cse.h | 42 ---- rimage/css.c | 71 ------ rimage/css.h | 69 ------ rimage/elf.c | 537 ------------------------------------------- rimage/file_format.h | 117 ---------- rimage/file_simple.c | 308 ------------------------- rimage/hash.c | 72 ------ rimage/man_apl.c | 144 ------------ rimage/man_cnl.c | 143 ------------ rimage/manifest.c | 532 ------------------------------------------ rimage/manifest.h | 90 -------- rimage/pkcs1_5.c | 141 ------------ rimage/plat_auth.c | 50 ---- rimage/plat_auth.h | 92 -------- rimage/rimage.c | 139 ----------- rimage/rimage.h | 165 ------------- 20 files changed, 3 insertions(+), 2795 deletions(-) delete mode 100644 rimage/Makefile.am delete mode 100644 rimage/cse.c delete mode 100644 rimage/cse.h delete mode 100644 rimage/css.c delete mode 100644 rimage/css.h delete mode 100644 rimage/elf.c delete mode 100644 rimage/file_format.h delete mode 100644 rimage/file_simple.c delete mode 100644 rimage/hash.c delete mode 100644 rimage/man_apl.c delete mode 100644 rimage/man_cnl.c delete mode 100644 rimage/manifest.c delete mode 100644 rimage/manifest.h delete mode 100644 rimage/pkcs1_5.c delete mode 100644 rimage/plat_auth.c delete mode 100644 rimage/plat_auth.h delete mode 100644 rimage/rimage.c delete mode 100644 rimage/rimage.h diff --git a/Makefile.am b/Makefile.am index ea0128601270..ea5d74635b58 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1 +1 @@ -SUBDIRS = rimage rmbox topology +SUBDIRS = rmbox topology diff --git a/configure.ac b/configure.ac index f85f18ce5907..b95c44c55568 100644 --- a/configure.ac +++ b/configure.ac @@ -2,9 +2,9 @@ AC_PREREQ([2.69]) AC_INIT([sof-tools], [1.0.1]) AM_INIT_AUTOMAKE([foreign]) -AC_CONFIG_SRCDIR([rimage/rimage.c]) +AC_CONFIG_SRCDIR([rmbox/rmbox.c]) AC_CONFIG_HEADERS([config.h]) -AC_CHECK_HEADER([sof/uapi/manifest.h]) +AC_CHECK_HEADER([sof/uapi/abi.h]) AC_CANONICAL_HOST @@ -13,17 +13,8 @@ AM_MAINTAINER_MODE([enable]) AC_PROG_CC -#check for openssl -AC_CHECK_LIB([crypto], [OPENSSL_config], , [AC_MSG_ERROR([Need OpenSSL libcrypto])]) - -PEM_KEY_PREFIX="/usr/local/share/rimage" -AC_DEFINE_UNQUOTED([PEM_KEY_PREFIX], ["$PEM_KEY_PREFIX"], ["Path for PEM keys"]) -AC_SUBST(PEM_KEY_PREFIX) - AC_OUTPUT([ Makefile - rimage/Makefile - rimage/keys/Makefile rmbox/Makefile topology/Makefile topology/common/Makefile @@ -36,7 +27,6 @@ AC_OUTPUT([ echo " prefix: ${prefix} -PEM: ${PEM_KEY_PREFIX} Compiler: ${CC} CFLAGS: ${CFLAGS} " diff --git a/rimage/Makefile.am b/rimage/Makefile.am deleted file mode 100644 index 467bfe638b50..000000000000 --- a/rimage/Makefile.am +++ /dev/null @@ -1,25 +0,0 @@ -SUBDIRS=keys - -bin_PROGRAMS = rimage - -noinst_HEADERS = \ - rimage.h \ - css.h \ - cse.h \ - plat_auth.h \ - manifest.h \ - file_format.h - -rimage_SOURCES = \ - file_simple.c \ - man_apl.c \ - man_cnl.c \ - cse.c \ - css.c \ - plat_auth.c \ - hash.c \ - pkcs1_5.c \ - manifest.c \ - elf.c \ - rimage.c - diff --git a/rimage/cse.c b/rimage/cse.c deleted file mode 100644 index b5604153f120..000000000000 --- a/rimage/cse.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * Author: Liam Girdwood - * Keyon Jie - */ - -#include -#include "rimage.h" -#include "cse.h" -#include "manifest.h" - -void ri_cse_create(struct image *image) -{ - struct CsePartitionDirHeader *cse_hdr = image->fw_image; - struct sof_man_adsp_meta_file_ext *meta = image->fw_image + - MAN_META_EXT_OFFSET; - struct CsePartitionDirEntry *cse_entry = - image->fw_image + sizeof(*cse_hdr); - uint8_t csum = 0, *val = image->fw_image; - int i, size; - - fprintf(stdout, " cse: completing CSE manifest\n"); - - cse_entry[2].length = meta->comp_desc[0].limit_offset - - MAN_DESC_OFFSET; - - /* calculate checksum using BSD algo */ - size = sizeof(*cse_hdr) + sizeof(*cse_entry) * MAN_CSE_PARTS; - for (i = 0; i < size; i++) { - if (i == 11) - continue; - csum += val[i]; - } - cse_hdr->checksum = 0x100 - csum; -} diff --git a/rimage/cse.h b/rimage/cse.h deleted file mode 100644 index 28650dadec2b..000000000000 --- a/rimage/cse.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#ifndef __CSE_H__ -#define __CSE_H__ - -#include - -struct image; - -#define CSE_HEADER_MAKER 0x44504324 /* "DPC$" */ - -struct CsePartitionDirHeader { - uint32_t header_marker; - uint32_t nb_entries; - uint8_t header_version; - uint8_t entry_version; - uint8_t header_length; - uint8_t checksum; - uint8_t partition_name[4]; -} __attribute__((packed)); - -struct CsePartitionDirEntry { - uint8_t entry_name[12]; - uint32_t offset; - uint32_t length; - uint32_t reserved; -} __attribute__((packed)); - -void ri_cse_create(struct image *image); - -#endif diff --git a/rimage/css.c b/rimage/css.c deleted file mode 100644 index f662f0b7e005..000000000000 --- a/rimage/css.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * Author: Liam Girdwood - * Keyon Jie - */ - -#include -#include -#include "rimage.h" -#include "css.h" -#include "manifest.h" - -void ri_css_hdr_create(struct image *image) -{ - struct css_header *css = image->fw_image + MAN_CSS_HDR_OFFSET; - struct tm *date; - struct timeval tv; - time_t time; - int val; - - fprintf(stdout, " cse: completing CSS manifest\n"); - - /* get local time and date */ - gettimeofday(&tv, NULL); - date = localtime(&tv.tv_sec); - date->tm_year += 1900; - fprintf(stdout, " css: set build date to %d:%2.2d:%2.2d\n", - date->tm_year, date->tm_mon, date->tm_mday); - - /* year yYyy */ - val = date->tm_year / 1000; - css->date |= val << 28; - date->tm_year -= val * 1000; - /* year yyYy */ - val = date->tm_year / 100; - css->date |= val << 24; - date->tm_year -= val * 100; - /* year yyyY */ - val = date->tm_year / 10; - css->date |= val << 20; - date->tm_year -= val * 10; - /* year Yyyy */ - val = date->tm_year; - css->date |= val << 16; - - /* month Mm - for some reason month starts at 0 */ - val = ++date->tm_mon / 10; - css->date |= val << 12; - date->tm_mon -= (val * 10); - /* month mM */ - val = date->tm_mon; - css->date |= val << 8; - - /* Day Dd */ - val = date->tm_mday / 10; - css->date |= val << 4; - date->tm_mday -= (val * 10); - /* Day dD */ - val = date->tm_mday; - css->date |= val << 0; -} diff --git a/rimage/css.h b/rimage/css.h deleted file mode 100644 index 0516f531ba9a..000000000000 --- a/rimage/css.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#ifndef __CSS_H__ -#define __CSS_H__ - -#include - -struct image; - -#define MAN_CSS_MOD_TYPE 4 -#define MAN_CSS_HDR_SIZE 161 /* in words */ -#define MAN_CSS_HDR_VERSION 0x10000 -#define MAN_CSS_MOD_VENDOR 0x8086 -#define MAN_CSS_HDR_ID {'$', 'M', 'N', '2'} - -#define MAN_CSS_KEY_SIZE (MAN_RSA_KEY_MODULUS_LEN >> 2) -#define MAN_CSS_MOD_SIZE (MAN_RSA_KEY_MODULUS_LEN >> 2) -#define MAN_CSS_EXP_SIZE (MAN_RSA_KEY_EXPONENT_LEN >> 2) -#define MAN_CSS_MAN_SIZE \ - (sizeof(struct fw_image_manifest) >> 2) - -/* - * RSA Key and Crypto - */ -#define MAN_RSA_KEY_MODULUS_LEN 256 -#define MAN_RSA_KEY_EXPONENT_LEN 4 -#define MAN_RSA_SIGNATURE_LEN 256 - -struct fw_version { - uint16_t major_version; - uint16_t minor_version; - uint16_t hotfix_version; - uint16_t build_version; -} __attribute__((packed)); - -struct css_header { - uint32_t header_type; - uint32_t header_len; - uint32_t header_version; - uint32_t reserved0; /* must be 0x0 */ - uint32_t module_vendor; - uint32_t date; - uint32_t size; - uint8_t header_id[4]; - uint32_t padding; /* must be 0x0 */ - struct fw_version version; - uint32_t svn; - uint32_t reserved1[18]; /* must be 0x0 */ - uint32_t modulus_size; - uint32_t exponent_size; - uint8_t modulus[MAN_RSA_KEY_MODULUS_LEN]; - uint8_t exponent[MAN_RSA_KEY_EXPONENT_LEN]; - uint8_t signature[MAN_RSA_SIGNATURE_LEN]; -} __attribute__((packed)); - -void ri_css_hdr_create(struct image *image); - -#endif diff --git a/rimage/elf.c b/rimage/elf.c deleted file mode 100644 index 1dc48f3bf6cb..000000000000 --- a/rimage/elf.c +++ /dev/null @@ -1,537 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * Author: Liam Girdwood - * Keyon Jie - */ - -#include -#include -#include "rimage.h" -#include "cse.h" -#include "manifest.h" - -static int elf_read_sections(struct image *image, struct module *module) -{ - Elf32_Ehdr *hdr = &module->hdr; - Elf32_Shdr *section = module->section; - size_t count; - int i, ret; - uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - int man_section_idx; - - /* read in section header */ - ret = fseek(module->fd, hdr->e_shoff, SEEK_SET); - if (ret < 0) { - fprintf(stderr, "error: can't seek to %s section header %d\n", - module->elf_file, ret); - return ret; - } - - /* allocate space for each section header */ - section = calloc(sizeof(Elf32_Shdr), hdr->e_shnum); - if (section == NULL) - return -ENOMEM; - module->section = section; - - /* read in sections */ - count = fread(section, sizeof(Elf32_Shdr), hdr->e_shnum, module->fd); - if (count != hdr->e_shnum) { - fprintf(stderr, "error: failed to read %s section header %d\n", - module->elf_file, -errno); - return -errno; - } - - /* find manifest module data */ - man_section_idx = elf_find_section(image, module, ".bss"); - if (man_section_idx < 0) { - return -EINVAL; - } - module->bss_index = man_section_idx; - - fprintf(stdout, " BSS module metadata section at index %d\n", - man_section_idx); - - /* parse each section */ - for (i = 0; i < hdr->e_shnum; i++) { - - /* only write valid sections */ - if (!(section[i].sh_flags & valid)) - continue; - - switch (section[i].sh_type) { - case SHT_NOBITS: - /* bss */ - module->bss_size += section[i].sh_size; - module->num_bss++; - break; - case SHT_PROGBITS: - /* text or data */ - module->fw_size += section[i].sh_size; - - if (section[i].sh_flags & SHF_EXECINSTR) - module->text_size += section[i].sh_size; - else - module->data_size += section[i].sh_size; - break; - default: - continue; - } - - module->num_sections++; - - if (!image->verbose) - continue; - - fprintf(stdout, " %s section-%d: \ttype\t 0x%8.8x\n", module->elf_file, - i, section[i].sh_type); - fprintf(stdout, " %s section-%d: \tflags\t 0x%8.8x\n", module->elf_file, - i, section[i].sh_flags); - fprintf(stdout, " %s section-%d: \taddr\t 0x%8.8x\n", module->elf_file, - i, section[i].sh_addr); - fprintf(stdout, " %s section-%d: \toffset\t 0x%8.8x\n", module->elf_file, - i, section[i].sh_offset); - fprintf(stdout, " %s section-%d: \tsize\t 0x%8.8x\n", module->elf_file, - i, section[i].sh_size); - fprintf(stdout, " %s section-%d: \tlink\t 0x%8.8x\n", module->elf_file, - i, section[i].sh_link); - fprintf(stdout, " %s section-%d: \tinfo\t 0x%8.8x\n\n", module->elf_file, - i, section[i].sh_info); - } - - return 0; -} - -static int elf_read_programs(struct image *image, struct module *module) -{ - Elf32_Ehdr *hdr = &module->hdr; - Elf32_Phdr *prg = module->prg; - size_t count; - int i, ret; - - /* read in program header */ - ret = fseek(module->fd, hdr->e_phoff, SEEK_SET); - if (ret < 0) { - fprintf(stderr, "error: cant seek to %s program header %d\n", - module->elf_file ,ret); - return ret; - } - - /* allocate space for programs */ - prg = calloc(sizeof(Elf32_Phdr), hdr->e_phnum); - if (prg == NULL) - return -ENOMEM; - module->prg = prg; - - /* read in programs */ - count = fread(prg, sizeof(Elf32_Phdr), hdr->e_phnum, module->fd); - if (count != hdr->e_phnum) { - fprintf(stderr, "error: failed to read %s program header %d\n", - module->elf_file, -errno); - return -errno; - } - - /* check each program */ - for (i = 0; i < hdr->e_phnum; i++) { - - if (prg[i].p_filesz == 0) - continue; - - if (!image->verbose) - continue; - - fprintf(stdout, "%s program-%d: \ttype\t 0x%8.8x\n", - module->elf_file, i, prg[i].p_type); - fprintf(stdout, "%s program-%d: \toffset\t 0x%8.8x\n", - module->elf_file, i, prg[i].p_offset); - fprintf(stdout, "%s program-%d: \tvaddr\t 0x%8.8x\n", - module->elf_file, i, prg[i].p_vaddr); - fprintf(stdout, "%s program-%d: \tpaddr\t 0x%8.8x\n", - module->elf_file, i, prg[i].p_paddr); - fprintf(stdout, "%s program-%d: \tfsize\t 0x%8.8x\n", - module->elf_file, i, prg[i].p_filesz); - fprintf(stdout, "%s program-%d: \tmsize\t 0x%8.8x\n", - module->elf_file, i, prg[i].p_memsz); - fprintf(stdout, "%s program-%d: \tflags\t 0x%8.8x\n\n", - module->elf_file, i, prg[i].p_flags); - } - - return 0; -} - -static int elf_read_hdr(struct image *image, struct module *module) -{ - Elf32_Ehdr *hdr = &module->hdr; - size_t count; - - /* read in elf header */ - count = fread(hdr, sizeof(*hdr), 1, module->fd); - if (count != 1) { - fprintf(stderr, "error: failed to read %s elf header %d\n", - module->elf_file, -errno); - return -errno; - } - - if (!image->verbose) - return 0; - - fprintf(stdout, "%s elf: \tentry point\t 0x%8.8x\n", - module->elf_file, hdr->e_entry); - fprintf(stdout, "%s elf: \tprogram offset\t 0x%8.8x\n", - module->elf_file, hdr->e_phoff); - fprintf(stdout, "%s elf: \tsection offset\t 0x%8.8x\n", - module->elf_file, hdr->e_shoff); - fprintf(stdout, "%s elf: \tprogram size\t 0x%8.8x\n", - module->elf_file, hdr->e_phentsize); - fprintf(stdout, "%s elf: \tprogram count\t 0x%8.8x\n", - module->elf_file, hdr->e_phnum); - fprintf(stdout, "%s elf: \tsection size\t 0x%8.8x\n", - module->elf_file, hdr->e_shentsize); - fprintf(stdout, "%s elf: \tsection count\t 0x%8.8x\n", - module->elf_file, hdr->e_shnum); - fprintf(stdout, "%s elf: \tstring index\t 0x%8.8x\n\n", - module->elf_file, hdr->e_shstrndx); - - return 0; -} - -int elf_is_rom(struct image *image, Elf32_Shdr *section) -{ - const struct adsp *adsp = image->adsp; - uint32_t start, end; - - start = section->sh_addr; - end = section->sh_addr + section->sh_size; - - if (start < image->adsp->rom_base || - start > image->adsp->rom_base + image->adsp->rom_size) - return 0; - if (end < image->adsp->rom_base || - end > image->adsp->rom_base + image->adsp->rom_size) - return 0; - return 1; -} - -static void elf_module_size(struct image *image, struct module *module, - Elf32_Shdr *section, int index) -{ - switch (section->sh_type) { - case SHT_PROGBITS: - /* text or data */ - if (section->sh_flags & SHF_EXECINSTR) { - /* text */ - if (module->text_start > section->sh_addr) - module->text_start = section->sh_addr; - if (module->text_end < section->sh_addr + section->sh_size) - module->text_end = section->sh_addr + section->sh_size; - - fprintf(stdout, "\tTEXT\n"); - } else { - /* initialized data, also calc the writable sections */ - if (module->data_start > section->sh_addr) - module->data_start = section->sh_addr; - if (module->data_end < section->sh_addr + section->sh_size) - module->data_end = section->sh_addr + section->sh_size; - - fprintf(stdout, "\tDATA\n"); - } - break; - case SHT_NOBITS: - /* bss */ - if (index == module->bss_index) { - /* updated the .bss segment */ - module->bss_start = section->sh_addr; - module->bss_end = section->sh_addr + section->sh_size; - fprintf(stdout, "\tBSS\n"); - } else { - fprintf(stdout, "\tHEAP\n"); - } - break; - default: - break; - } -} - -static void elf_module_limits(struct image *image, struct module *module) -{ - Elf32_Shdr *section; - uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - int i; - - module->text_start = module->data_start = module->bss_start = 0xffffffff; - module->text_end = module->data_end = module->bss_end = 0; - - fprintf(stdout, " Found %d sections, listing valid sections......\n", - module->hdr.e_shnum); - - fprintf(stdout, "\tNo\tStart\t\tEnd\t\tBytes\tType\n"); - - /* iterate all sections and get size of segments */ - for (i = 0; i < module->hdr.e_shnum; i++) { - - section = &module->section[i]; - - /* only check valid sections */ - if (!(section->sh_flags & valid)) - continue; - - if (section->sh_size == 0) - continue; - - if (elf_is_rom(image, section)) - continue; - - fprintf(stdout, "\t%d\t0x%8.8x\t0x%8.8x\t%d", i, - section->sh_addr, section->sh_addr + section->sh_size, - section->sh_size); - - /* text or data section */ - elf_module_size(image, module, section, i); - - } - - fprintf(stdout, "\n"); -} - -/* make sure no section overlap from any modules */ -int elf_validate_section(struct image *image, struct module *module, - Elf32_Shdr *section) -{ - struct module *m; - Elf32_Shdr *s; - uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - int i, j, ret; - - /* for each module */ - for (i = 0; i < image->num_modules; i++) { - m = &image->module[i]; - - if (m == module) - continue; - - /* for each section */ - for (j = 0; j < m->hdr.e_shnum; j++) { - s = &m->section[j]; - - if (s == section) - continue; - - /* only check valid sections */ - if (!(section->sh_flags & valid)) - continue; - - if (section->sh_size == 0) - continue; - - /* is section non overlapping ? */ - if (section->sh_addr >= s->sh_addr && - section->sh_addr + section->sh_size <= - s->sh_addr + s->sh_size) { - goto err; - } - } - } - - return 0; - -err: - fprintf(stderr, "error: section overlap between %s and %s\n", - module->elf_file, m->elf_file); - fprintf(stderr, " [0x%x : 0x%x] overlaps with [0x%x :0x%x]\n", - section->sh_addr, section->sh_addr + section->sh_size, - s->sh_addr, s->sh_addr + s->sh_size); - return -EINVAL; -} - -/* make sure no section overlaps from any modules */ -int elf_validate_modules(struct image *image) -{ - struct module *module; - Elf32_Shdr *section; - uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - int i, j, ret; - - /* for each module */ - for (i = 0; i < image->num_modules; i++) { - module = &image->module[i]; - - /* for each section */ - for (j = 0; j < module->hdr.e_shnum; j++) { - section = &module->section[j]; - - /* only check valid sections */ - if (!(section->sh_flags & valid)) - continue; - - if (section->sh_size == 0) - continue; - - /* is section non overlapping ? */ - ret = elf_validate_section(image, module, section); - if (ret < 0) - return ret; - } - } - - return 0; -} - -int elf_find_section(struct image *image, struct module *module, - const char *name) -{ - Elf32_Ehdr *hdr = &module->hdr; - Elf32_Shdr *section, *s; - char *buffer; - size_t count; - int ret, i; - - section = &module->section[hdr->e_shstrndx]; - - /* alloc data data */ - buffer = calloc(1, section->sh_size); - if (buffer == NULL) - return -ENOMEM; - - /* read in section string data */ - ret = fseek(module->fd, section->sh_offset, SEEK_SET); - if (ret < 0) { - fprintf(stderr, "error: cant seek to string section %d\n", ret); - goto out; - } - - count = fread(buffer, 1, section->sh_size, module->fd); - if (count != section->sh_size) { - fprintf(stderr, "error: can't read string section %d\n", -errno); - ret = -errno; - goto out; - } - - /* find section with name */ - for (i = 0; i < hdr->e_shnum; i++) { - s = &module->section[i]; - if (!strcmp(name, buffer + s->sh_name)) { - ret = i; - goto out; - } - } - - fprintf(stderr, "error: can't find section %s in module %s\n", name, - module->elf_file); - ret = -EINVAL; - -out: - free(buffer); - return ret; -} - -int elf_parse_module(struct image *image, int module_index, const char *name) -{ - const struct adsp *adsp = image->adsp; - struct module *module; - uint32_t rem; - int ret = 0; - - /* validate module index */ - if (module_index >= MAX_MODULES) { - fprintf(stderr, "error: too any modules\n"); - return -EINVAL; - } - - module = &image->module[module_index]; - - /* open the elf input file */ - module->fd = fopen(name, "r"); - if (module->fd == NULL) { - fprintf(stderr, "error: unable to open %s for reading %d\n", - name, errno); - return -EINVAL; - } - module->elf_file = name; - - /* read in elf header */ - ret = elf_read_hdr(image, module); - if (ret < 0) - goto hdr_err; - - /* read in programs */ - ret = elf_read_programs(image, module); - if (ret < 0) { - fprintf(stderr, "error: failed to read program sections %d\n", - ret); - goto hdr_err; - } - - /* read sections */ - ret = elf_read_sections(image, module); - if (ret < 0) { - fprintf(stderr, "error: failed to read base sections %d\n", - ret); - goto sec_err; - } - - /* check limits */ - elf_module_limits(image, module); - - elf_find_section(image, module, ""); - - fprintf(stdout, " module: input size %d (0x%x) bytes %d sections\n", - module->fw_size, module->fw_size, module->num_sections); - fprintf(stdout, " module: text %d (0x%x) bytes\n" - " data %d (0x%x) bytes\n" - " bss %d (0x%x) bytes\n\n", - module->text_size, module->text_size, - module->data_size, module->data_size, - module->bss_size, module->bss_size); - - /* file sizes round up to nearest page */ - module->text_file_size = module->text_end - module->text_start; - rem = module->text_file_size % MAN_PAGE_SIZE; - if (rem) - module->text_file_size += MAN_PAGE_SIZE - rem; - - - /* apply any base FW fixups */ - if (image->adsp->base_fw_text_size_fixup && - module->text_start == image->adsp->sram_base) { - module->text_file_size += image->adsp->base_fw_text_size_fixup; - } - - /* data section */ - module->data_file_size = module->data_end - module->data_start; - rem = module->data_file_size % MAN_PAGE_SIZE; - if (rem) - module->data_file_size += MAN_PAGE_SIZE - rem; - - /* bss section */ - module->bss_file_size = module->bss_end - module->bss_start; - rem = module->bss_file_size % MAN_PAGE_SIZE; - if (rem) - module->bss_file_size += MAN_PAGE_SIZE - rem; - - return 0; - -sec_err: - free(module->prg); -hdr_err: - fclose(module->fd); - - return ret; -} - -void elf_free_module(struct image *image, int module_index) -{ - struct module *module = &image->module[module_index]; - - free(module->prg); - free(module->section); - fclose(module->fd); -} diff --git a/rimage/file_format.h b/rimage/file_format.h deleted file mode 100644 index 15302589cc40..000000000000 --- a/rimage/file_format.h +++ /dev/null @@ -1,117 +0,0 @@ -/* - * This file is provided under a dual BSD/GPLv2 license. When using or - * redistributing this file, you may do so under either license. - * - * GPL LICENSE SUMMARY - * - * Copyright(c) 2017 Intel Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. - * The full GNU General Public License is included in this distribution - * in the file called LICENSE.GPL. - * - * BSD LICENSE - * - * Copyright(c) 2017 Intel Corporation. All rights reserved. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Intel Corporation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * Author: Liam Girdwood - */ - - -/* - * Firmware file format . - */ - -#ifndef __INCLUDE_UAPI_SOF_FW_H__ -#define __INCLUDE_UAPI_SOF_FW_H__ - -#define SND_SOF_FW_SIG_SIZE 4 -#define SND_SOF_FW_ABI 1 -#define SND_SOF_FW_SIG "Reef" - -/* - * Firmware module is made up of 1 . N blocks of different types. The - * Block header is used to determine where and how block is to be copied in the - * DSP/host memory space. - */ -enum snd_sof_fw_blk_type { - SOF_BLK_IMAGE = 0, /* whole image - parsed by ROMs */ - SOF_BLK_TEXT = 1, - SOF_BLK_DATA = 2, - SOF_BLK_CACHE = 3, - SOF_BLK_REGS = 4, - SOF_BLK_SIG = 5, - SOF_BLK_ROM = 6, - /* add new block types here */ -}; - -struct snd_sof_blk_hdr { - enum snd_sof_fw_blk_type type; - uint32_t size; /* bytes minus this header */ - uint32_t offset; /* offset from base */ -} __attribute__((packed)); - -/* - * Firmware file is made up of 1 .. N different modules types. The module - * type is used to determine how to load and parse the module. - */ -enum snd_sof_fw_mod_type { - SOF_FW_BASE = 0, /* base firmware image */ - SOF_FW_MODULE = 1, /* firmware module */ -}; - -struct snd_sof_mod_hdr { - enum snd_sof_fw_mod_type type; - uint32_t size; /* bytes minus this header */ - uint32_t num_blocks; /* number of blocks */ -} __attribute__((packed)); - -/* - * Firmware file header. - */ -struct snd_sof_fw_header { - unsigned char sig[SND_SOF_FW_SIG_SIZE]; /* "Reef" */ - uint32_t file_size; /* size of file minus this header */ - uint32_t num_modules; /* number of modules */ - uint32_t abi; /* version of header format */ -} __attribute__((packed)); - -#endif diff --git a/rimage/file_simple.c b/rimage/file_simple.c deleted file mode 100644 index 2c85a76f3f32..000000000000 --- a/rimage/file_simple.c +++ /dev/null @@ -1,308 +0,0 @@ -/* - * ELF to firmware image creator. - * - * Copyright (c) 2015, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - - -#include -#include -#include -#include -#include - -#include "rimage.h" -#include "file_format.h" - -#define BYT_IRAM_BASE 0xff2c0000 -#define BYT_IRAM_HOST_OFFSET 0x0C0000 -#define BYT_IRAM_SIZE (80 * 1024) -#define BYT_DRAM_BASE 0xff300000 -#define BYT_DRAM_HOST_OFFSET 0x100000 -#define BYT_DRAM_SIZE (160 * 1024) - -#define HSW_IRAM_BASE 0x00000000 -#define HSW_IRAM_HOST_OFFSET 0x00080000 -#define HSW_IRAM_SIZE (384 * 1024) -#define HSW_DRAM_BASE 0x00400000 -#define HSW_DRAM_HOST_OFFSET 0x00000000 -#define HSW_DRAM_SIZE (512 * 1024) - -#define BDW_IRAM_BASE 0x00000000 -#define BDW_IRAM_HOST_OFFSET 0x000A0000 -#define BDW_IRAM_SIZE (320 * 1024) -#define BDW_DRAM_BASE 0x00400000 -#define BDW_DRAM_HOST_OFFSET 0x00000000 -#define BDW_DRAM_SIZE (640 * 1024) - -static int is_iram(struct image *image, Elf32_Shdr *section) -{ - const struct adsp *adsp = image->adsp; - uint32_t start, end; - - start = section->sh_addr; - end = section->sh_addr + section->sh_size; - - if (start < adsp->iram_base) - return 0; - if (start >= adsp->iram_base + adsp->iram_size) - return 0; - return 1; -} - -static int is_dram(struct image *image, Elf32_Shdr *section) -{ - const struct adsp *adsp = image->adsp; - uint32_t start, end; - - start = section->sh_addr; - end = section->sh_addr + section->sh_size; - - if (start < adsp->dram_base) - return 0; - if (start >= adsp->dram_base + adsp->dram_size) - return 0; - return 1; -} - -static int block_idx = 0; - -static int write_block(struct image *image, struct module *module, - Elf32_Shdr *section) -{ - const struct adsp *adsp = image->adsp; - struct snd_sof_blk_hdr block; - size_t count; - void *buffer; - int ret; - - block.size = section->sh_size; - - if (is_iram(image, section)) { - block.type = SOF_BLK_TEXT; - block.offset = section->sh_addr - adsp->iram_base - + adsp->host_iram_offset; - } else if (is_dram(image, section)) { - block.type = SOF_BLK_DATA; - block.offset = section->sh_addr - adsp->dram_base - + adsp->host_dram_offset; - } else { - fprintf(stderr, "error: invalid block address/size 0x%x/0x%x\n", - section->sh_addr, section->sh_size); - return -EINVAL; - } - - /* write header */ - count = fwrite(&block, sizeof(block), 1, image->out_fd); - if (count != 1) - return -errno; - - /* alloc data data */ - buffer = calloc(1, section->sh_size); - if (buffer == NULL) - return -ENOMEM; - - /* read in section data */ - ret = fseek(module->fd, section->sh_offset, SEEK_SET); - if (ret < 0) { - fprintf(stderr, "error: cant seek to section %d\n", ret); - goto out; - } - count = fread(buffer, 1, section->sh_size, module->fd); - if (count != section->sh_size) { - fprintf(stderr, "error: cant read section %d\n", -errno); - ret = -errno; - goto out; - } - - /* write out section data */ - count = fwrite(buffer, 1, section->sh_size, image->out_fd); - if (count != section->sh_size) { - fprintf(stderr, "error: cant write section %d\n", -errno); - fprintf(stderr, " foffset %d size 0x%x mem addr 0x%x\n", - section->sh_offset, section->sh_size, section->sh_addr); - ret = -errno; - goto out; - } - - fprintf(stdout, "\t%d\t0x%8.8x\t0x%8.8x\t0x%8.8lx\t%s\n", block_idx++, - section->sh_addr, section->sh_size, ftell(image->out_fd), - block.type == SOF_BLK_TEXT ? "TEXT" : "DATA"); - -out: - free(buffer); - return ret; -} - -static int simple_write_module(struct image *image, struct module *module) -{ - const struct adsp *adsp = image->adsp; - struct snd_sof_mod_hdr hdr; - Elf32_Shdr *section; - size_t count; - int i, err; - uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - - hdr.num_blocks = module->num_sections - module->num_bss; - hdr.size = module->text_size + module->data_size + - sizeof(struct snd_sof_blk_hdr) * hdr.num_blocks; - hdr.type = SOF_FW_BASE; - - count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); - if (count != 1) { - fprintf(stderr, "error: failed to write section header %d\n", - -errno); - return -errno ; - } - - fprintf(stdout, "\n\tTotals\tStart\t\tEnd\t\tSize"); - - fprintf(stdout, "\n\tTEXT\t0x%8.8x\t0x%8.8x\t0x%x\n", - module->text_start, module->text_end, - module->text_end - module->text_start); - fprintf(stdout, "\tDATA\t0x%8.8x\t0x%8.8x\t0x%x\n", - module->data_start, module->data_end, - module->data_end - module->data_start); - fprintf(stdout, "\tBSS\t0x%8.8x\t0x%8.8x\t0x%x\n\n ", - module->bss_start, module->bss_end, - module->bss_end - module->bss_start); - - fprintf(stdout, "\tNo\tAddress\t\tSize\t\tFile\t\tType\n"); - - for (i = 0; i < module->hdr.e_shnum; i++) { - - section = &module->section[i]; - - /* only write valid sections */ - if (!(module->section[i].sh_flags & valid)) - continue; - - /* dont write bss */ - if (section->sh_type == SHT_NOBITS) - continue; - - err = write_block(image, module, section); - if (err < 0) { - fprintf(stderr, "error: failed to write section #%d\n", i); - return err; - } - } - - fprintf(stdout, "\n"); - return 0; -} - -/* used by others */ -static int simple_write_firmware(struct image *image) -{ - struct snd_sof_fw_header hdr; - struct module *module; - size_t count; - int i, ret; - - memcpy(hdr.sig, SND_SOF_FW_SIG, SND_SOF_FW_SIG_SIZE); - - hdr.num_modules = image->num_modules; - hdr.abi = SND_SOF_FW_ABI; - hdr.file_size = 0; - - for (i = 0; i < image->num_modules; i++) { - module = &image->module[i]; - module->fw_size += sizeof(struct snd_sof_blk_hdr) * - (module->num_sections - module->num_bss); - module->fw_size += sizeof(struct snd_sof_mod_hdr) * hdr.num_modules; - hdr.file_size += module->fw_size; - } - - count = fwrite(&hdr, sizeof(hdr), 1, image->out_fd); - if (count != 1) - return -errno; - - for (i = 0; i < image->num_modules; i++) { - module = &image->module[i]; - - fprintf(stdout, "writing module %d %s\n", i, module->elf_file); - - ret = simple_write_module(image, module); - if (ret < 0) { - fprintf(stderr, "error: failed to write module %d\n", - i); - return ret; - } - } - - fprintf(stdout, "firmware: image size %ld (0x%lx) bytes %d modules\n\n", - hdr.file_size + sizeof(hdr), hdr.file_size + sizeof(hdr), - hdr.num_modules); - - return 0; -} - -const struct adsp machine_byt = { - .name = "byt", - .iram_base = BYT_IRAM_BASE, - .iram_size = BYT_IRAM_SIZE, - .host_iram_offset = BYT_IRAM_HOST_OFFSET, - .dram_base = BYT_DRAM_BASE, - .dram_size = BYT_DRAM_SIZE, - .host_dram_offset = BYT_DRAM_HOST_OFFSET, - .machine_id = MACHINE_BAYTRAIL, - .write_firmware = simple_write_firmware, -}; - -const struct adsp machine_cht = { - .name = "cht", - .iram_base = BYT_IRAM_BASE, - .iram_size = BYT_IRAM_SIZE, - .host_iram_offset = BYT_IRAM_HOST_OFFSET, - .dram_base = BYT_DRAM_BASE, - .dram_size = BYT_DRAM_SIZE, - .host_dram_offset = BYT_DRAM_HOST_OFFSET, - .machine_id = MACHINE_CHERRYTRAIL, - .write_firmware = simple_write_firmware, -}; - -const struct adsp machine_bsw = { - .name = "bsw", - .iram_base = BYT_IRAM_BASE, - .iram_size = BYT_IRAM_SIZE, - .host_iram_offset = BYT_IRAM_HOST_OFFSET, - .dram_base = BYT_DRAM_BASE, - .dram_size = BYT_DRAM_SIZE, - .host_dram_offset = BYT_DRAM_HOST_OFFSET, - .machine_id = MACHINE_BRASWELL, - .write_firmware = simple_write_firmware, -}; - -const struct adsp machine_hsw = { - .name = "hsw", - .iram_base = HSW_IRAM_BASE, - .iram_size = HSW_IRAM_SIZE, - .host_iram_offset = HSW_IRAM_HOST_OFFSET, - .dram_base = HSW_DRAM_BASE, - .dram_size = HSW_DRAM_SIZE, - .host_dram_offset = HSW_DRAM_HOST_OFFSET, - .machine_id = MACHINE_HASWELL, - .write_firmware = simple_write_firmware, -}; - -const struct adsp machine_bdw = { - .name = "bdw", - .iram_base = BDW_IRAM_BASE, - .iram_size = BDW_IRAM_SIZE, - .host_iram_offset = BDW_IRAM_HOST_OFFSET, - .dram_base = BDW_DRAM_BASE, - .dram_size = BDW_DRAM_SIZE, - .host_dram_offset = BDW_DRAM_HOST_OFFSET, - .machine_id = MACHINE_BROADWELL, - .write_firmware = simple_write_firmware, -}; diff --git a/rimage/hash.c b/rimage/hash.c deleted file mode 100644 index 3acf1b31745f..000000000000 --- a/rimage/hash.c +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * Author: Liam Girdwood - * Keyon Jie - */ - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include "rimage.h" -#include "file_format.h" -#include "manifest.h" - -#define DEBUG_HASH 0 - -void module_sha256_create(struct image *image) -{ - image->md = EVP_sha256(); - image->mdctx = EVP_MD_CTX_create(); - - EVP_DigestInit_ex(image->mdctx, image->md, NULL); -} - -void module_sha256_update(struct image *image, uint8_t *data, size_t bytes) -{ - EVP_DigestUpdate(image->mdctx, data, bytes); -} - -void module_sha256_complete(struct image *image, uint8_t *hash) -{ - unsigned char md_value[EVP_MAX_MD_SIZE]; - int md_len; -#if DEBUG_HASH - int i; -#endif - EVP_DigestFinal_ex(image->mdctx, md_value, &md_len); - EVP_MD_CTX_destroy(image->mdctx); - - memcpy(hash, md_value, md_len); -#if DEBUG_HASH - fprintf(stdout, "Module digest is: "); - for (i = 0; i < md_len; i++) - fprintf(stdout, "%02x", md_value[i]); - fprintf(stdout, "\n"); -#endif -} - -void ri_hash(struct image *image, unsigned offset, unsigned size, char *hash) -{ - module_sha256_create(image); - module_sha256_update(image, image->fw_image + offset, size); - module_sha256_complete(image, hash); -} diff --git a/rimage/man_apl.c b/rimage/man_apl.c deleted file mode 100644 index 7b32ea1c3887..000000000000 --- a/rimage/man_apl.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#include "css.h" -#include "cse.h" -#include "plat_auth.h" -#include "manifest.h" - -/* hard coded atm - will pass this in from cmd line and git */ -#define MAN_FW_HDR_VERSION_MAJOR 9 -#define MAN_FW_HDR_VERSION_MINOR 22 -#define MAN_FW_HDR_VERSION_HOTFIX 1 -#define MAN_FW_HDR_VERSION_BUILD 0x7da - -/* manifest template */ -struct fw_image_manifest apl_manifest = { - - .cse_partition_dir_header = { - .header_marker = CSE_HEADER_MAKER, - .nb_entries = MAN_CSE_PARTS, - .header_version = 1, - .entry_version = 1, - .header_length = sizeof(struct CsePartitionDirHeader), - .checksum = 0, - .partition_name = "ADSP", - }, - - .cse_partition_dir_entry = { - { - /* CssHeader + platformFirmwareAuthenticationExtension - padding */ - .entry_name = "ADSP.man", - .offset = MAN_CSS_HDR_OFFSET, - .length = sizeof(struct css_header) + - PLAT_AUTH_SIZE, - }, - { /* ADSPMetadataFileExtension */ - .entry_name = "cavs0015.met", - .offset = MAN_META_EXT_OFFSET, - .length = sizeof(struct sof_man_adsp_meta_file_ext), - }, - { /* AdspFwBinaryDesc */ - .entry_name = "cavs0015", - .offset = MAN_FW_DESC_OFFSET, - .length = 0, /* calculated by rimage - */ - }, - - }, - - .css = { - .header_type = MAN_CSS_MOD_TYPE, - .header_len = MAN_CSS_HDR_SIZE, - .header_version = MAN_CSS_HDR_VERSION, - .module_vendor = MAN_CSS_MOD_VENDOR, - .size = 222, - .header_id = MAN_CSS_HDR_ID, - .padding = 0, - .version = { - .major_version = MAN_FW_HDR_VERSION_MAJOR, - .minor_version = MAN_FW_HDR_VERSION_MINOR, - .hotfix_version = MAN_FW_HDR_VERSION_HOTFIX, - .build_version = MAN_FW_HDR_VERSION_BUILD, - }, - .modulus_size = MAN_CSS_MOD_SIZE, - .exponent_size = MAN_CSS_EXP_SIZE, - }, - - .signed_pkg = { - .ext_type = SIGN_PKG_EXT_TYPE, - .ext_len = sizeof(struct signed_pkg_info_ext), - .name = "ADSP", - .vcn = 0, - .bitmap = {0, 0, 0, 0, 8}, - - .module[0] = { - .name = "cavs0015.met", - .meta_size = 96, - .type = 0x03, - .hash_algo = 0x02, /* SHA 256 */ - .hash_size = 0x20, - }, - }, - - .partition_info = { - - .ext_type = PART_INFO_EXT_TYPE, - .ext_len = sizeof(struct partition_info_ext), - - .name = "ADSP", - .length = 0, /* calculated by rimage - rounded up to nearest PAGE */ - .part_version = 0x10000000, - .instance_id = 1, - .reserved[0 ... 19] = 0xff, - - .module[0] = { - .name = "cavs0015.met", - .meta_size = 96, - .type = 0x03, - .reserved = {0x00, 0xff, 0xff}, - }, - - }, - - .cse_padding[0 ... 47] = 0xff, - - .adsp_file_ext = { - .ext_type = 17, - .ext_len = sizeof(struct sof_man_adsp_meta_file_ext), - .imr_type = 3, - .comp_desc[0] = { - .version = 0, - .base_offset = MAN_DESC_OFFSET, - .limit_offset = 0, /* calculated length + MAN_DESC_OFFSET */ - }, - - }, - - .reserved[0 ... 31] = 0xff, - - .desc = { - .header = { - .header_id = SOF_MAN_FW_HDR_ID, - .header_len = sizeof(struct sof_man_fw_header), - .name = SOF_MAN_FW_HDR_NAME, - .preload_page_count = 0, /* size in pages from $CPD */ - .fw_image_flags = SOF_MAN_FW_HDR_FLAGS, - .feature_mask = SOF_MAN_FW_HDR_FEATURES, - .major_version = MAN_FW_HDR_VERSION_MAJOR, - .minor_version = MAN_FW_HDR_VERSION_MINOR, - .hotfix_version = MAN_FW_HDR_VERSION_HOTFIX, - .build_version = MAN_FW_HDR_VERSION_BUILD, - .load_offset = MAN_DESC_OFFSET, - }, - }, -}; diff --git a/rimage/man_cnl.c b/rimage/man_cnl.c deleted file mode 100644 index 2aec2a723d79..000000000000 --- a/rimage/man_cnl.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#include "css.h" -#include "cse.h" -#include "plat_auth.h" -#include "manifest.h" - -/* hard coded atm - will pass this in from cmd line and git */ -#define MAN_FW_HDR_VERSION_MAJOR 10 -#define MAN_FW_HDR_VERSION_MINOR 23 -#define MAN_FW_HDR_VERSION_HOTFIX 0 -#define MAN_FW_HDR_VERSION_BUILD 0x2a4 - -/* manifest template */ -struct fw_image_manifest cnl_manifest = { - - .cse_partition_dir_header = { - .header_marker = CSE_HEADER_MAKER, - .nb_entries = MAN_CSE_PARTS, - .header_version = 1, - .entry_version = 1, - .header_length = sizeof(struct CsePartitionDirHeader), - .partition_name = "ADSP", - }, - - .cse_partition_dir_entry = { - { - /* CssHeader + platformFirmwareAuthenticationExtension - padding */ - .entry_name = "ADSP.man", - .offset = MAN_CSS_HDR_OFFSET, - .length = sizeof(struct css_header) + - PLAT_AUTH_SIZE, - }, - { /* ADSPMetadataFileExtension */ - .entry_name = "cavs0015.met", - .offset = MAN_META_EXT_OFFSET, - .length = sizeof(struct sof_man_adsp_meta_file_ext), - }, - { /* AdspFwBinaryDesc */ - .entry_name = "cavs0015", - .offset = MAN_FW_DESC_OFFSET, - .length = 0, /* calculated by rimage - */ - }, - - }, - - .css = { - .header_type = MAN_CSS_MOD_TYPE, - .header_len = MAN_CSS_HDR_SIZE, - .header_version = MAN_CSS_HDR_VERSION, - .module_vendor = MAN_CSS_MOD_VENDOR, - .size = 222, - .header_id = MAN_CSS_HDR_ID, - .padding = 0, - .version = { - .major_version = MAN_FW_HDR_VERSION_MAJOR, - .minor_version = MAN_FW_HDR_VERSION_MINOR, - .hotfix_version = MAN_FW_HDR_VERSION_HOTFIX, - .build_version = MAN_FW_HDR_VERSION_BUILD, - }, - .modulus_size = MAN_CSS_MOD_SIZE, - .exponent_size = MAN_CSS_EXP_SIZE, - }, - - .signed_pkg = { - .ext_type = SIGN_PKG_EXT_TYPE, - .ext_len = sizeof(struct signed_pkg_info_ext), - .name = "ADSP", - .vcn = 0, - .bitmap = {0, 0, 0, 0, 8}, - - .module[0] = { - .name = "cavs0015.met", - .meta_size = 96, - .type = 0x03, - .hash_algo = 0x02, /* SHA 256 */ - .hash_size = 0x20, - }, - }, - - .partition_info = { - - .ext_type = PART_INFO_EXT_TYPE, - .ext_len = sizeof(struct partition_info_ext), - - .name = "ADSP", - .length = 0, /* calculated by rimage - rounded up to nearest PAGE */ - .part_version = 0x10000000, - .instance_id = 1, - .reserved[0 ... 19] = 0xff, - - .module[0] = { - .name = "cavs0015.met", - .meta_size = 96, - .type = 0x03, - .reserved = {0x00, 0xff, 0xff}, - }, - - }, - - .cse_padding[0 ... 47] = 0xff, - - .adsp_file_ext = { - .ext_type = 17, - .ext_len = sizeof(struct sof_man_adsp_meta_file_ext), - .imr_type = 3, - .comp_desc[0] = { - .version = 0, - .base_offset = MAN_DESC_OFFSET, - .limit_offset = 0, /* calculated length + MAN_DESC_OFFSET */ - }, - - }, - - .reserved[0 ... 31] = 0xff, - - .desc = { - .header = { - .header_id = SOF_MAN_FW_HDR_ID, - .header_len = sizeof(struct sof_man_fw_header), - .name = SOF_MAN_FW_HDR_NAME, - .preload_page_count = 0, /* size in pages from $CPD */ - .fw_image_flags = SOF_MAN_FW_HDR_FLAGS, - .feature_mask = SOF_MAN_FW_HDR_FEATURES, - .major_version = MAN_FW_HDR_VERSION_MAJOR, - .minor_version = MAN_FW_HDR_VERSION_MINOR, - .hotfix_version = MAN_FW_HDR_VERSION_HOTFIX, - .build_version = MAN_FW_HDR_VERSION_BUILD, - .load_offset = 0x30000, - }, - }, -}; diff --git a/rimage/manifest.c b/rimage/manifest.c deleted file mode 100644 index 68e6d8b64138..000000000000 --- a/rimage/manifest.c +++ /dev/null @@ -1,532 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * Author: Liam Girdwood - * Keyon Jie - */ - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "rimage.h" -#include "file_format.h" -#include "css.h" -#include "cse.h" -#include "plat_auth.h" -#include "manifest.h" - -static int man_open_rom_file(struct image *image) -{ - sprintf(image->out_rom_file, "%s.rom", image->out_file); - unlink(image->out_rom_file); - - /* allocate ROM image */ - image->rom_image = calloc(image->adsp->rom_size, 1); - if (image->rom_image == NULL) - return -ENOMEM; - - /* open ROM outfile for writing */ - image->out_rom_fd = fopen(image->out_rom_file, "w"); - if (image->out_rom_fd == NULL) { - fprintf(stderr, "error: unable to open %s for writing %d\n", - image->out_rom_file, errno); - } - - return 0; -} - -static int man_open_manifest_file(struct image *image) -{ - /* open manifest outfile for writing */ - sprintf(image->out_man_file, "%s.met", image->out_file); - unlink(image->out_man_file); - - image->out_man_fd = fopen(image->out_man_file, "w"); - if (image->out_man_fd == NULL) { - fprintf(stderr, "error: unable to open %s for writing %d\n", - image->out_man_file, errno); - } - - return 0; -} - -static int man_init_image(struct image *image) -{ - /* allocate image and copy template manifest */ - image->fw_image = calloc(image->adsp->image_size, 1); - if (image->fw_image == NULL) - return -ENOMEM; - - memcpy(image->fw_image, image->adsp->man, - sizeof(struct fw_image_manifest)); - - return 0; -} - -/* we should call this after all segments size set up via iterate */ -static uint32_t elf_to_file_offset(struct image *image, - struct module *module, struct sof_man_module *man_module, - Elf32_Shdr *section) -{ - uint32_t elf_addr = section->sh_addr, file_offset = 0; - - if (section->sh_type == SHT_PROGBITS) { - if (section->sh_flags & SHF_EXECINSTR) { - /* text segment */ - file_offset = elf_addr - module->text_start + - module->foffset; - } - else { - /* rodata segment, append to text segment */ - file_offset = elf_addr - module->data_start + - module->foffset + module->text_file_size; - - } - } else if (section->sh_type == SHT_NOBITS) { - /* bss segment */ - file_offset = 0; - } - - return file_offset; -} - -/* write SRAM sections */ -static int man_copy_sram(struct image *image, Elf32_Shdr *section, - struct module *module, struct sof_man_module *man_module, - int section_idx) -{ - uint32_t offset = elf_to_file_offset(image, module, - man_module, section); - uint32_t end = offset + section->sh_size; - int seg_type = -1; - void *buffer = image->fw_image + offset; - size_t count; - - switch (section->sh_type) { - case SHT_PROGBITS: - /* text or data */ - if (section->sh_flags & SHF_EXECINSTR) - seg_type = SOF_MAN_SEGMENT_TEXT; - else - seg_type = SOF_MAN_SEGMENT_RODATA; - break; - case SHT_NOBITS: - seg_type = SOF_MAN_SEGMENT_BSS; - default: - return 0; - } - - /* file_offset for segment should not be 0s, we set it to - * the smallest offset of its modules ATM. - */ - if (man_module->segment[seg_type].file_offset > offset || - man_module->segment[seg_type].file_offset == 0) - man_module->segment[seg_type].file_offset = offset; - - count = fread(buffer, 1, section->sh_size, module->fd); - if (count != section->sh_size) { - fprintf(stderr, "error: cant read section %d\n", -errno); - return -errno; - } - - /* get module end offset ? */ - if (end > image->image_end) - image->image_end = end; - - fprintf(stdout, "\t%d\t0x%x\t0x%x\t0x%x\t%s\n", section_idx, - section->sh_addr, section->sh_size, offset, - seg_type == SOF_MAN_SEGMENT_TEXT ? "TEXT" : "DATA"); - - return 0; -} - -static int man_copy_elf_section(struct image *image, Elf32_Shdr *section, - struct module *module, struct sof_man_module *man_module, int idx) -{ - int ret; - - /* seek to ELF section */ - ret = fseek(module->fd, section->sh_offset, SEEK_SET); - if (ret < 0) { - fprintf(stderr, "error: can't seek to section %d\n", ret); - return ret; - } - - /* write data to DRAM or ROM image */ - if (!elf_is_rom(image, section)) - return man_copy_sram(image, section, module, man_module, idx); - - return 0; -} - -static int man_get_module_manifest(struct image *image, struct module *module, - struct sof_man_module *man_module) -{ - Elf32_Shdr *section; - struct sof_man_segment_desc *segment; - struct sof_man_module sof_mod; - size_t count; - int ret, man_section_idx; - - fprintf(stdout, "Module Write: %s\n", module->elf_file); - - /* find manifest module data */ - man_section_idx = elf_find_section(image, module, ".module"); - if (man_section_idx < 0) { - return -EINVAL; - } - - fprintf(stdout, " Manifest module metadata section at index %d\n", - man_section_idx); - section = &module->section[man_section_idx]; - - /* load in manifest data */ - ret = fseek(module->fd, section->sh_offset, SEEK_SET); - if (ret < 0) { - fprintf(stderr, "error: can't seek to section %d\n", ret); - return ret; - } - count = fread(&sof_mod, 1, sizeof(sof_mod), module->fd); - if (count != sizeof(sof_mod)) { - fprintf(stderr, "error: can't read section %d\n", -errno); - return -errno; - } - - /* configure man_module with sofmod data */ - strncpy(man_module->struct_id, "$AME", 4); - man_module->entry_point = sof_mod.entry_point; - strncpy(man_module->name, sof_mod.name, SOF_MAN_MOD_NAME_LEN); - memcpy(man_module->uuid, sof_mod.uuid, 16); - man_module->affinity_mask = sof_mod.affinity_mask; - man_module->type.auto_start = sof_mod.type.auto_start; - man_module->type.domain_dp = sof_mod.type.domain_dp; - man_module->type.domain_ll = sof_mod.type.domain_ll; - man_module->type.load_type = sof_mod.type.load_type; - - /* text segment */ - segment = &man_module->segment[SOF_MAN_SEGMENT_TEXT]; - segment->flags.r.contents = 1; - segment->flags.r.alloc = 1; - segment->flags.r.load = 1; - segment->flags.r.readonly = 1; - segment->flags.r.code = 1; - - /* data segment */ - segment = &man_module->segment[SOF_MAN_SEGMENT_RODATA]; - segment->flags.r.contents = 1; - segment->flags.r.alloc = 1; - segment->flags.r.load = 1; - segment->flags.r.readonly = 1; - segment->flags.r.data = 1; - segment->flags.r.type = 1; - - /* bss segment */ - segment = &man_module->segment[SOF_MAN_SEGMENT_BSS]; - segment->flags.r.alloc = 1; - segment->flags.r.type = 2; - - fprintf(stdout, " Entry point 0x%8.8x\n", man_module->entry_point); - - return 0; -} - -static int man_module_create(struct image *image, struct module *module, - struct sof_man_module *man_module) -{ - /* create module and segments */ - uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); - const struct adsp *adsp = image->adsp; - Elf32_Shdr *section; - size_t count; - int i, err; - unsigned pages; - - image->image_end = 0; - - err = man_get_module_manifest(image, module, man_module); - if (err < 0) - return err; - - /* stack size ??? convert sizes to PAGES */ - man_module->instance_bss_size = 1; - - /* max number of instances of this module ?? */ - man_module->instance_max_count = 1; - - fprintf(stdout, "\n\tTotals\tStart\t\tEnd\t\tSize"); - - fprintf(stdout, "\n\tTEXT\t0x%x\t0x%x\t0x%x\n", - module->text_start, module->text_end, - module->text_end - module->text_start); - fprintf(stdout, "\tDATA\t0x%x\t0x%x\t0x%x\n", - module->data_start, module->data_end, - module->data_end - module->data_start); - fprintf(stdout, "\tBSS\t0x%x\t0x%x\t0x%x\n\n ", - module->bss_start, module->bss_end, - module->bss_end - module->bss_start); - - /* main module */ - /* text section is first */ - man_module->segment[SOF_MAN_SEGMENT_TEXT].file_offset = - module->foffset; - man_module->segment[SOF_MAN_SEGMENT_TEXT].v_base_addr = - module->text_start; - - /* calculates those padding 0s by the start of next segment */ - pages = module->text_file_size / MAN_PAGE_SIZE; - if (module->text_file_size % MAN_PAGE_SIZE) - pages += 1; - - man_module->segment[SOF_MAN_SEGMENT_TEXT].flags.r.length = pages; - - /* data section */ - man_module->segment[SOF_MAN_SEGMENT_RODATA].v_base_addr = - module->data_start; - man_module->segment[SOF_MAN_SEGMENT_RODATA].file_offset = - module->foffset + module->text_file_size; - pages = module->data_file_size / MAN_PAGE_SIZE; - if (module->data_file_size % MAN_PAGE_SIZE) - pages += 1; - - man_module->segment[SOF_MAN_SEGMENT_RODATA].flags.r.length = pages; - - /* bss is last */ - man_module->segment[SOF_MAN_SEGMENT_BSS].file_offset = 0; - man_module->segment[SOF_MAN_SEGMENT_BSS].v_base_addr = module->bss_start; - pages = (module->bss_end - module->bss_start) / MAN_PAGE_SIZE; - if ((module->bss_end - module->bss_start) % MAN_PAGE_SIZE) - pages += 1; - man_module->segment[SOF_MAN_SEGMENT_BSS].flags.r.length = pages; - - fprintf(stdout, "\tNo\tAddress\t\tSize\tFile\tType\n"); - - /* find all sections and copy to corresponding segments */ - for (i = 0; i < module->hdr.e_shnum; i++) { - - section = &module->section[i]; - - /* only check valid sections */ - if (!(section->sh_flags & valid)) - continue; - - if (section->sh_size == 0) - continue; - - /* text or data section */ - if (!elf_is_rom(image, section)) - err = man_copy_elf_section(image, section, module, - man_module, i); - - if (err < 0) { - fprintf(stderr, "error: failed to write section #%d\n", i); - return err; - } - } - fprintf(stdout, "\n"); - - /* round module end upto nearest page */ - if (image->image_end % MAN_PAGE_SIZE) { - image->image_end = (image->image_end / MAN_PAGE_SIZE) + 1; - image->image_end *= MAN_PAGE_SIZE; - } - - fprintf(stdout, " Total pages text %d data %d bss %d module file limit: 0x%x\n\n", - man_module->segment[SOF_MAN_SEGMENT_TEXT].flags.r.length, - man_module->segment[SOF_MAN_SEGMENT_RODATA].flags.r.length, - man_module->segment[SOF_MAN_SEGMENT_BSS].flags.r.length, - image->image_end); - return 0; -} - -static int man_write_fw_mod(struct image *image) -{ - int count; - long unsigned int size = 0; - - /* write ROM - for VM use only */ - count = fwrite(image->rom_image, image->adsp->rom_size, 1, - image->out_rom_fd); - if (count != 1) { - fprintf(stderr, "error: failed to write rom %s %d\n", - image->out_rom_file, -errno); - return -errno; - } - fclose(image->out_rom_fd); - - /* write manifest and signed image */ - count = fwrite(image->fw_image, - image->image_end, - 1, image->out_fd); - - /* did the image write succeed ? */ - if (count != 1) { - fprintf(stderr, "error: failed to write signed firmware %s %d\n", - image->out_file, -errno); - return -errno; - } - - return 0; -} - -/* used by others */ -static int man_write_fw(struct image *image) -{ - struct sof_man_fw_desc *desc; - struct fw_image_manifest *m; - struct module *module; - struct sof_man_module *man_module; - uint8_t hash[SOF_MAN_MOD_SHA256_LEN]; - int ret, count, i, man_section_idx; - - /* init image */ - ret = man_init_image(image); - if (ret < 0) - goto err; - - /* open ROM image */ - ret = man_open_rom_file(image); - if (ret < 0) - goto err; - - /* create the manifest */ - ret = man_open_manifest_file(image); - if (ret < 0) - goto err; - - /* create the module */ - m = image->fw_image; - desc = image->fw_image + MAN_DESC_OFFSET; - - /* create each module */ - m->desc.header.num_module_entries = image->num_modules; - for (i = 0; i < image->num_modules; i++) { - - man_module = sof_man_get_module(desc, i); - module = &image->module[i]; - - /* set module file offset */ - if (i == 0) { - module->foffset = FILE_TEXT_OFFSET; - } else { - module->foffset = image->image_end; - } - - ret = man_module_create(image, module, man_module); - if (ret < 0) - goto err; - } - - fprintf(stdout, "Firmware completing manifest\n"); - - /* create structures from end of file to start of file */ - ri_adsp_meta_data_create(image); - ri_plat_ext_data_create(image); - ri_css_hdr_create(image); - ri_cse_create(image); - - fprintf(stdout, "Firmware file size 0x%x page count %d\n", - FILE_TEXT_OFFSET - MAN_DESC_OFFSET + image->image_end, - desc->header.preload_page_count); - - /* calculate hash for each module */ - for (i = 0; i < image->num_modules; i++) { - - module = &image->module[i]; - man_module = sof_man_get_module(desc, i); - - ri_hash(image, man_module->segment[SOF_MAN_SEGMENT_TEXT].file_offset, - (man_module->segment[SOF_MAN_SEGMENT_TEXT].flags.r.length + - man_module->segment[SOF_MAN_SEGMENT_RODATA].flags.r.length) * - MAN_PAGE_SIZE, man_module->hash); - } - - /* calculate hash for ADSP meta data extension - 0x480 to end */ - ri_hash(image, MAN_FW_DESC_OFFSET, image->image_end - - MAN_FW_DESC_OFFSET, m->adsp_file_ext.comp_desc[0].hash); - - /* calculate hash for platform auth data - repeated in hash 2 and 4 */ - ri_hash(image, MAN_META_EXT_OFFSET, - sizeof(struct sof_man_adsp_meta_file_ext), hash); - - /* hash values in reverse order */ - for (i = 0; i < SOF_MAN_MOD_SHA256_LEN; i++) { - m->signed_pkg.module[0].hash[i] = - m->partition_info.module[0].hash[i] = - hash[SOF_MAN_MOD_SHA256_LEN - 1 - i]; - } - - /* sign manifest */ - ret = ri_manifest_sign(image); - if (ret < 0) - goto err; - - /* write the firmware */ - ret = man_write_fw_mod(image); - if (ret < 0) - goto err; - - fprintf(stdout, "Firmware manifest and signing completed !\n"); - return 0; - -err: - free(image->rom_image); - free(image->fw_image); - unlink(image->out_file); - unlink(image->out_rom_file); - return ret; -} - -#define ADSP_APL_DSP_ROM_BASE 0xBEFE0000 -#define ADSP_APL_DSP_ROM_SIZE 0x00002000 -#define APL_DSP_BASE_ENTRY 0xa000a000 - -#define ADSP_CNL_DSP_ROM_BASE 0xBEFE0000 -#define ADSP_CNL_DSP_ROM_SIZE 0x00002000 -#define CNL_DSP_IMR_BASE_ENTRY 0xb0038000 -#define CNL_DSP_HP_BASE_ENTRY 0xbe040000 - -/* list of supported adsp */ -const struct adsp machine_apl = { - .name = "apl", - .rom_base = ADSP_APL_DSP_ROM_BASE, - .rom_size = ADSP_APL_DSP_ROM_SIZE, - .sram_base = APL_DSP_BASE_ENTRY, - .sram_size = 0x100000, - .image_size = 0x100000, - .dram_offset = 0, - .machine_id = MACHINE_APOLLOLAKE, - .write_firmware = man_write_fw, - .man = &apl_manifest, - .base_fw_text_size_fixup = 0xa000, -}; - -const struct adsp machine_cnl = { - .name = "cnl", - .rom_base = ADSP_CNL_DSP_ROM_BASE, - .rom_size = ADSP_CNL_DSP_ROM_SIZE, - .imr_base = CNL_DSP_IMR_BASE_ENTRY, - .imr_size = 0x100000, - .sram_base = CNL_DSP_HP_BASE_ENTRY, - .sram_size = 0x100000, - .image_size = 0x100000, - .dram_offset = 0, - .machine_id = MACHINE_CANNONLAKE, - .write_firmware = man_write_fw, - .man = &cnl_manifest, -}; diff --git a/rimage/manifest.h b/rimage/manifest.h deleted file mode 100644 index 655963f15ead..000000000000 --- a/rimage/manifest.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#ifndef __MANIFEST_H__ -#define __MANIFEST_H__ - -#include -#include -#include "css.h" -#include "cse.h" -#include "plat_auth.h" - -#define MAN_PAGE_SIZE 4096 - -/* start offset for base FW module */ -#define FILE_TEXT_OFFSET 0x8000 - -/* - * CSE values for CNL - */ -#define MAN_CSE_PARTS 3 - - -#define MAN_CSE_HDR_OFFSET 0 -#define MAN_CSE_PADDING_SIZE 0x30 -#define MAN_EXT_PADDING 0x20 -#define MAN_DESC_OFFSET 0x2000 - -#define MAN_CSS_HDR_OFFSET \ - (MAN_CSE_HDR_OFFSET + \ - sizeof(struct CsePartitionDirHeader) + \ - MAN_CSE_PARTS * sizeof(struct CsePartitionDirEntry)) - -#define MAN_SIG_PKG_OFFSET \ - (MAN_CSS_HDR_OFFSET + \ - sizeof(struct css_header)) - -#define MAN_PART_INFO_OFFSET \ - (MAN_SIG_PKG_OFFSET + \ - sizeof(struct signed_pkg_info_ext)) - -#define MAN_META_EXT_OFFSET \ - (MAN_SIG_PKG_OFFSET + \ - sizeof(struct signed_pkg_info_ext) + \ - sizeof(struct partition_info_ext) + \ - MAN_CSE_PADDING_SIZE) - -#define MAN_FW_DESC_OFFSET \ - (MAN_META_EXT_OFFSET + \ - sizeof(struct sof_man_adsp_meta_file_ext) + \ - MAN_EXT_PADDING) - -#define MAN_DESC_PADDING_SIZE \ - (MAN_DESC_OFFSET - MAN_FW_DESC_OFFSET) - -/* - * Firmware manifest header. - */ -struct fw_image_manifest { - /* MEU tool needs these sections to be 0s */ - struct CsePartitionDirHeader cse_partition_dir_header; - struct CsePartitionDirEntry cse_partition_dir_entry[MAN_CSE_PARTS]; - struct css_header css; - struct signed_pkg_info_ext signed_pkg; - struct partition_info_ext partition_info; - uint8_t cse_padding[MAN_CSE_PADDING_SIZE]; - struct sof_man_adsp_meta_file_ext adsp_file_ext; - - /* reserved / pading at end of ext data - all 0s*/ - uint8_t reserved[MAN_EXT_PADDING]; - - /* start of the unsigned binary for MEU input must start at MAN_DESC_OFFSET */ - uint8_t padding[MAN_DESC_PADDING_SIZE]; - - struct sof_man_fw_desc desc; /* at offset MAN_DESC_OFFSET */ -} __attribute__((packed)); - -extern struct fw_image_manifest apl_manifest; -extern struct fw_image_manifest cnl_manifest; -#endif diff --git a/rimage/pkcs1_5.c b/rimage/pkcs1_5.c deleted file mode 100644 index 0c5806b2cad3..000000000000 --- a/rimage/pkcs1_5.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * Author: Liam Girdwood - * Keyon Jie - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "config.h" -#include "rimage.h" -#include "css.h" -#include "manifest.h" - -#define DEBUG_PKCS 0 - -static void bytes_swap(uint8_t *ptr, uint32_t size) -{ - uint8_t tmp; - uint32_t index; - - for (index = 0; index < (size / 2); index++) { - tmp = ptr[index]; - ptr[index] = ptr[size - 1 - index]; - ptr[size - 1 - index] = tmp; - } -} - -/* - * RSA signature of manifest. The signature is an PKCS - * #1-v1_5 of the entire manifest structure, including all - * extensions, and excluding the last 3 fields of the - * manifest header (Public Key, Exponent and Signature). -*/ - -int pkcs_sign(struct image *image, struct fw_image_manifest *man, - void *ptr1, unsigned size1, void *ptr2, unsigned size2) -{ - RSA *priv_rsa = NULL; - EVP_PKEY *privkey; - FILE *fp; - unsigned char digest[SHA256_DIGEST_LENGTH], path[256], mod[MAN_RSA_KEY_MODULUS_LEN]; - unsigned int siglen = MAN_RSA_SIGNATURE_LEN; - int ret = -EINVAL, i; - -#if DEBUG_PKCS - fprintf(stdout, "offsets 0x%lx size 0x%x offset 0x%lx size 0x%x\n", - ptr1 - (void*)man, size1, ptr2 - (void*)man, size2); -#endif - - /* create new key */ - privkey = EVP_PKEY_new(); - if (privkey == NULL) - return -ENOMEM; - - /* load in RSA private key from PEM file */ - if (image->key_name == NULL) { - sprintf(path, "%s/otc_private_key.pem", PEM_KEY_PREFIX); - image->key_name = path; - } - - fprintf(stdout, " pkcs: signing with key %s\n", image->key_name); - fp = fopen(image->key_name, "r"); - if (fp == NULL) { - fprintf(stderr, "error: can't open file %s %d\n", path, -errno); - return -errno; - } - PEM_read_PrivateKey(fp, &privkey, NULL, NULL); - fclose(fp); - - /* validate RSA private key */ - priv_rsa = EVP_PKEY_get1_RSA(privkey); - if (RSA_check_key(priv_rsa)) { - fprintf(stdout, " pkcs: RSA private key is valid.\n"); - } else { - fprintf(stderr, "error: validating RSA private key.\n"); - return -EINVAL; - } - - /* calculate the digest */ - module_sha256_create(image); - module_sha256_update(image, ptr1, size1); - module_sha256_update(image, ptr2, size2); - module_sha256_complete(image, digest); - - fprintf(stdout, " pkcs: digest for manifest is "); - for (i = 0; i < SHA256_DIGEST_LENGTH; i++) - fprintf(stdout, "%02x", digest[i]); - fprintf(stdout, "\n"); - - /* sign the manifest */ - ret = RSA_sign(NID_sha256, digest, SHA256_DIGEST_LENGTH, - (unsigned char *)man->css.signature, - &siglen, priv_rsa); - if (ret < 0) - fprintf(stderr, "error: failed to sign manifest\n"); - - /* copy public key modulus and exponent to manifest */ - BN_bn2bin(priv_rsa->n, mod); - BN_bn2bin(priv_rsa->e, (unsigned char*)man->css.exponent); - - /* modulus is reveresd */ - for (i = 0; i < MAN_RSA_KEY_MODULUS_LEN; i++) - man->css.modulus[i] = mod[MAN_RSA_KEY_MODULUS_LEN - (1 + i)]; - - /* signature is reveresd, swap it */ - bytes_swap(man->css.signature, sizeof(man->css.signature)); - - EVP_PKEY_free(privkey); - return ret; -} - -int ri_manifest_sign(struct image *image) -{ - struct fw_image_manifest *man = image->fw_image; - - pkcs_sign(image, man, (void *)man + MAN_CSS_HDR_OFFSET, - sizeof(struct css_header) - - (MAN_RSA_KEY_MODULUS_LEN + MAN_RSA_KEY_EXPONENT_LEN + - MAN_RSA_SIGNATURE_LEN), - (void *)man + MAN_SIG_PKG_OFFSET, - (man->css.size - man->css.header_len) * sizeof(uint32_t)); - return 0; -} diff --git a/rimage/plat_auth.c b/rimage/plat_auth.c deleted file mode 100644 index 21c7138cfbb1..000000000000 --- a/rimage/plat_auth.c +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * Author: Liam Girdwood - * Keyon Jie - */ - -#include "rimage.h" -#include "manifest.h" -#include "plat_auth.h" - -void ri_adsp_meta_data_create(struct image *image) -{ - struct sof_man_adsp_meta_file_ext *meta = - image->fw_image + MAN_META_EXT_OFFSET; - - fprintf(stdout, " meta: completing ADSP manifest\n"); - - meta->comp_desc[0].limit_offset = MAN_DESC_OFFSET + image->image_end - - MAN_FW_DESC_OFFSET; - - fprintf(stdout, " meta: limit is 0x%x\n", - meta->comp_desc[0].limit_offset); - /* now hash the AdspFwBinaryDesc -> EOF */ -} - -void ri_plat_ext_data_create(struct image *image) -{ - struct partition_info_ext *part = image->fw_image + MAN_PART_INFO_OFFSET; - struct sof_man_adsp_meta_file_ext *meta = - image->fw_image + MAN_META_EXT_OFFSET; - struct sof_man_fw_desc *desc = image->fw_image + MAN_DESC_OFFSET; - - fprintf(stdout, " auth: completing authentication manifest\n"); - - part->length = meta->comp_desc[0].limit_offset - MAN_DESC_OFFSET; - part->length += MAN_PAGE_SIZE - (part->length % MAN_PAGE_SIZE); - - /* do this here atm */ - desc->header.preload_page_count = part->length / MAN_PAGE_SIZE; -} diff --git a/rimage/plat_auth.h b/rimage/plat_auth.h deleted file mode 100644 index 135f2d1ce07c..000000000000 --- a/rimage/plat_auth.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2017, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#ifndef __PLAT_AUTH_H__ -#define __PLAT_AUTH_H__ - -#include - -struct image; - -#define PLAT_AUTH_SHA256_LEN 32 -#define PLAT_AUTH_NAME_LEN 12 -#define PLAT_AUTH_PADDING 48 /* pad at end of struct */ - -#define SIGN_PKG_EXT_TYPE 15 -#define SIGN_PKG_NUM_MODULE 1 - -struct signed_pkg_info_module { - uint8_t name[PLAT_AUTH_NAME_LEN]; /* must be padded with 0 */ - uint8_t type; - uint8_t hash_algo; - uint16_t hash_size; - uint32_t meta_size; - uint8_t hash[PLAT_AUTH_SHA256_LEN]; -} __attribute__((packed)); - -struct signed_pkg_info_ext { - uint32_t ext_type; - uint32_t ext_len; - - uint8_t name[4]; - uint32_t vcn; - uint8_t bitmap[16]; - uint32_t svn; - uint8_t fw_type; - uint8_t fw_sub_type; - uint8_t reserved[14]; /* must be 0 */ - - /* variable length of modules */ - struct signed_pkg_info_module module[SIGN_PKG_NUM_MODULE]; -} __attribute__((packed)); - - -#define PART_INFO_EXT_TYPE 3 -#define PART_INFO_NUM_MODULE 1 - -struct partition_info_module { - uint8_t name[PLAT_AUTH_NAME_LEN]; /* must be padded with 0 */ - uint8_t type; - uint8_t reserved[3]; - uint32_t meta_size; - uint8_t hash[PLAT_AUTH_SHA256_LEN]; -} __attribute__((packed)); - -struct partition_info_ext { - uint32_t ext_type; - uint32_t ext_len; - - uint8_t name[4]; /* "ADSP" */ - uint32_t length; - uint8_t hash[PLAT_AUTH_SHA256_LEN]; - - uint32_t vcn; - uint32_t part_version; - uint32_t fmt_version; - uint32_t instance_id; - uint32_t part_flags; - uint8_t reserved[20]; /* must be 0 */ - - /* variable length of modules */ - struct partition_info_module module[PART_INFO_NUM_MODULE]; -} __attribute__((packed)); - - -#define PLAT_AUTH_SIZE \ - (sizeof(struct partition_info_ext) + \ - sizeof(struct signed_pkg_info_ext)) - -void ri_adsp_meta_data_create(struct image *image); -void ri_plat_ext_data_create(struct image *image); - -#endif diff --git a/rimage/rimage.c b/rimage/rimage.c deleted file mode 100644 index f407a42a0c24..000000000000 --- a/rimage/rimage.c +++ /dev/null @@ -1,139 +0,0 @@ -/* - * ELF to firmware image creator. - * - * Copyright (c) 2015, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#include -#include -#include -#include -#include - -#include "rimage.h" -#include "file_format.h" -#include "manifest.h" - -static const struct adsp *machine[] = { - &machine_byt, - &machine_cht, - &machine_bsw, - &machine_hsw, - &machine_bdw, - &machine_apl, - &machine_cnl, -}; - -static void usage(char *name) -{ - fprintf(stdout, "%s:\t -m machine -o outfile -k [key] ELF files\n", name); - fprintf(stdout, "\t -v enable verbose output\n"); - exit(0); -} - -int main(int argc, char *argv[]) -{ - struct image image; - const char *mach = NULL; - int opt, ret, i, binary = 0, elf_argc = 0; - - memset(&image, 0, sizeof(image)); - - while ((opt = getopt(argc, argv, "ho:m:vba:sk:l:")) != -1) { - switch (opt) { - case 'o': - image.out_file = optarg; - break; - case 'm': - mach = optarg; - break; - case 'v': - image.verbose = 1; - break; - case 'b': - binary = 1; - break; - case 's': - image.dump_sections = 1; - break; - case 'a': - image.abi = atoi(optarg); - break; - case 'k': - image.key_name = optarg; - break; - case 'h': - usage(argv[0]); - break; - default: - break; - } - } - - elf_argc = optind; - - /* make sure we have an outfile and machine */ - if (image.out_file == NULL || mach == NULL) - usage(argv[0]); - - - /* find machine */ - for (i = 0; i < ARRAY_SIZE(machine); i++) { - if (!strcmp(mach, machine[i]->name)) { - image.adsp = machine[i]; - goto found; - } - } - fprintf(stderr, "error: machine %s not found\n", mach); - fprintf(stderr, "error: available machines "); - for (i = 0; i < ARRAY_SIZE(machine); i++) - fprintf(stderr, "%s, ", machine[i]->name); - fprintf(stderr, "\n"); - - return -EINVAL; - -found: - - /* parse input ELF files */ - image.num_modules = argc - elf_argc; - for (i = elf_argc; i < argc; i++) { - fprintf(stdout, "\nModule Reading %s\n", argv[i]); - ret = elf_parse_module(&image, i - elf_argc, argv[i]); - if (ret < 0) - goto out; - } - - /* validate all modules */ - ret = elf_validate_modules(&image); - if (ret < 0) - goto out; - - /* open outfile for writing */ - unlink(image.out_file); - image.out_fd = fopen(image.out_file, "w"); - if (image.out_fd == NULL) { - fprintf(stderr, "error: unable to open %s for writing %d\n", - image.out_file, errno); - ret = -EINVAL; - goto out; - } - - /* process and write output */ - ret = image.adsp->write_firmware(&image); -out: - /* close files */ - if (image.out_fd) - fclose(image.out_fd); - - - return ret; -} diff --git a/rimage/rimage.h b/rimage/rimage.h deleted file mode 100644 index a68f1a878b62..000000000000 --- a/rimage/rimage.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - * ELF to firmware image creator. - * - * Copyright (c) 2015-2018 Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - */ - -#ifndef __RIMAGE_H__ -#define __RIMAGE_H__ - -#include -#include -#include - -#include -#include -#include - -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#define MAX_MODULES 32 - -struct adsp; -struct manifest; -struct man_module; - -/* list of supported targets */ -enum machine_id { - MACHINE_BAYTRAIL = 0, - MACHINE_CHERRYTRAIL, - MACHINE_BRASWELL, - MACHINE_HASWELL, - MACHINE_BROADWELL, - MACHINE_APOLLOLAKE, - MACHINE_CANNONLAKE, - MACHINE_MAX -}; - -/* - * ELF module data - */ -struct module { - const char *elf_file; - FILE *fd; - - Elf32_Ehdr hdr; - Elf32_Shdr *section; - Elf32_Phdr *prg; - - uint32_t text_start; - uint32_t text_end; - uint32_t data_start; - uint32_t data_end; - uint32_t bss_start; - uint32_t bss_end; - uint32_t foffset; - - int num_sections; - int num_bss; - int fw_size; - int bss_index; - - /* sizes do not include any gaps */ - int bss_size; - int text_size; - int data_size; - - /* sizes do include gaps to nearest page */ - int bss_file_size; - int text_file_size; - int data_file_size; -}; - -/* - * Firmware image context. - */ -struct image { - - const char *out_file; - FILE *out_fd; - void *pos; - - const struct adsp *adsp; - int abi; - int verbose; - int num_modules; - struct module module[MAX_MODULES]; - uint32_t image_end;/* module end, equal to output image size */ - int dump_sections; - - /* SHA 256 */ - const char *key_name; - EVP_MD_CTX *mdctx; - const EVP_MD *md; - - /* file IO */ - void *fw_image; - void *rom_image; - FILE *out_rom_fd; - FILE *out_man_fd; - FILE *out_unsigned_fd; - char out_rom_file[256]; - char out_man_file[256]; - char out_unsigned_file[256]; -}; - -/* - * Audio DSP descriptor and operations. - */ -struct adsp { - const char *name; - uint32_t iram_base; - uint32_t iram_size; - uint32_t dram_base; - uint32_t dram_size; - uint32_t sram_base; - uint32_t sram_size; - uint32_t host_iram_offset; - uint32_t host_dram_offset; - uint32_t rom_base; - uint32_t rom_size; - uint32_t imr_base; - uint32_t imr_size; - - uint32_t image_size; - uint32_t dram_offset; - - enum machine_id machine_id; - int (*write_firmware)(struct image *image); - struct fw_image_manifest *man; - - /* fixups */ - uint32_t base_fw_text_size_fixup; /* added to BASEFW text size */ -}; - -void module_sha256_create(struct image *image); -void module_sha256_update(struct image *image, uint8_t *data, size_t bytes); -void module_sha256_complete(struct image *image, uint8_t *hash); -int ri_manifest_sign(struct image *image); -void ri_hash(struct image *image, unsigned offset, unsigned size, char *hash); - -int elf_parse_module(struct image *image, int module_index, const char *name); -void elf_free_module(struct image *image, int module_index); -int elf_is_rom(struct image *image, Elf32_Shdr *section); -int elf_validate_modules(struct image *image); -int elf_find_section(struct image *image, struct module *module, - const char *name); - -/* supported machines */ -extern const struct adsp machine_byt; -extern const struct adsp machine_cht; -extern const struct adsp machine_bsw; -extern const struct adsp machine_hsw; -extern const struct adsp machine_bdw; -extern const struct adsp machine_apl; -extern const struct adsp machine_cnl; - -#endif From a02abb799405d0e4ad0d6bb46eacf6fbe958c06e Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 14 Feb 2018 19:30:57 -0600 Subject: [PATCH 103/324] soft: kmod_scripts: initial import set of basic bash scripts to remove/insert SOF Linux kernel modules in the right order. This is typically used to avoid rebooting every time the SOF image or topology are updated - and detect leaks on remove. sof_remove.sh: remove all SOF modules sof_insert.sh: probe SOF modules sof_bootone.sh: combination of remove/insert in one shot sof_bootloop.sh: boot loop to see if firmware boot is reliable over time This can probably be enhanced to remove spurious "module is not currently loaded" logs. Signed-off-by: Pierre-Louis Bossart --- kmod_scripts/sof_bootloop.sh | 11 +++++++++++ kmod_scripts/sof_bootone.sh | 19 +++++++++++++++++++ kmod_scripts/sof_insert.sh | 12 ++++++++++++ kmod_scripts/sof_remove.sh | 27 +++++++++++++++++++++++++++ 4 files changed, 69 insertions(+) create mode 100755 kmod_scripts/sof_bootloop.sh create mode 100755 kmod_scripts/sof_bootone.sh create mode 100755 kmod_scripts/sof_insert.sh create mode 100755 kmod_scripts/sof_remove.sh diff --git a/kmod_scripts/sof_bootloop.sh b/kmod_scripts/sof_bootloop.sh new file mode 100755 index 000000000000..f1bc99bf315f --- /dev/null +++ b/kmod_scripts/sof_bootloop.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +MAXLOOPS=100 +COUNTER=0 + +while [ $COUNTER -lt $MAXLOOPS ]; do + echo "test $COUNTER" + ./sof_bootone.sh + dmesg > boot_$COUNTER.bootlog + let COUNTER+=1 +done diff --git a/kmod_scripts/sof_bootone.sh b/kmod_scripts/sof_bootone.sh new file mode 100755 index 000000000000..6bc5f27b161a --- /dev/null +++ b/kmod_scripts/sof_bootone.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +dmesg -C +./sof_remove.sh +./sof_insert.sh +sleep 1 + +unset FW_BOOT +unset ERROR +FW_BOOT=$(dmesg | grep sof-audio | grep "boot complete") +ERROR=$(dmesg | grep sof-audio | grep "error") + +if [ ! -z "$ERROR" ] || [ -z "$FW_BOOT" ] +then + echo "boot failed" +else + echo "boot success" +fi + diff --git a/kmod_scripts/sof_insert.sh b/kmod_scripts/sof_insert.sh new file mode 100755 index 000000000000..93b224260958 --- /dev/null +++ b/kmod_scripts/sof_insert.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +modprobe snd_soc_rt5670 +modprobe snd_soc_rt5645 +modprobe snd_soc_rt5651 +modprobe snd_soc_rt5640 +modprobe snd_soc_da7213 + +modprobe sof_acpi_dev +modprobe sof_pci_dev + + diff --git a/kmod_scripts/sof_remove.sh b/kmod_scripts/sof_remove.sh new file mode 100755 index 000000000000..1ea0598d4683 --- /dev/null +++ b/kmod_scripts/sof_remove.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +rmmod sof_pci_dev +rmmod sof_acpi_dev +rmmod snd_soc_acpi_intel_match +rmmod snd_sof_intel_byt +rmmod snd_sof_intel_hsw +rmmod snd_sof_intel_bdw +rmmod snd_sof_intel_apl +rmmod snd_sof_intel_cnl +rmmod snd_sof_intel_hda_common +rmmod snd_sof + +rmmod snd_soc_sst_bytcr_rt5640 +rmmod snd_soc_sst_bytcr_rt5651 +rmmod snd_soc_sst_cht_bsw_rt5645 +rmmod snd_soc_sst_cht_bsw_rt5670 +rmmod snd_soc_sst_byt_cht_da7213 + +rmmod snd_soc_rt5670 +rmmod snd_soc_rt5645 +rmmod snd_soc_rt5651 +rmmod snd_soc_rt5640 +rmmod snd_soc_rl6231 +rmmod snd_soc_da7213 + +rmmod snd_soc_acpi From 49555a170771680d3c3ebd36afe412f0fca788e3 Mon Sep 17 00:00:00 2001 From: Yan Wang Date: Fri, 23 Feb 2018 12:37:29 +0800 Subject: [PATCH 104/324] Enable CNL topology generating. Currently CNL topology definition is added but not enabled. Signed-off-by: Yan Wang --- topology/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/topology/Makefile.am b/topology/Makefile.am index 3b5a3a973912..1e80d5737d5f 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -27,6 +27,7 @@ MACHINES = \ reef-byt-rt5645.tplg \ reef-byt-rt5651.tplg \ reef-byt-da7212.tplg \ + reef-cnl-rt274.tplg \ reef-hsw-rt5640.tplg # Uncomment the following line if you want to debug conf files @@ -56,4 +57,5 @@ EXTRA_DIST = \ reef-byt-rt5645.m4 \ reef-byt-rt5651.m4 \ reef-byt-da7212.m4 \ + reef-cnl-rt274.m4 \ reef-hsw-rt5640.m4 From b4293de4ccd8a982f5aeabe989c6f07a68c21ed6 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Thu, 1 Mar 2018 10:17:07 -0800 Subject: [PATCH 105/324] rmbox: show error/xrun logs in red for easy identification This patch adds changes to rmbox to make it easier to spot errors/xruns in a long trace Signed-off-by: Ranjani Sridharan --- rmbox/rmbox.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index b8726947ae0e..9403cc7cdc64 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -21,6 +21,9 @@ #include #include +#define KNRM "\x1B[0m" +#define KRED "\x1B[31m" + // TODO: include all this stuff #define TRACE_CLASS_IRQ (1 << 24) @@ -200,8 +203,19 @@ static void show_trace(uint64_t val, uint64_t addr, uint64_t *timestamp, double return; } - printf("%s %c%c%c\n", trace, + switch ((char)(val >> 16)) { + case 'e': + case 'E': + case 'x': + case 'X': + printf("%s%s %c%c%c%s\n", KRED, trace, + (char)(val >> 16), (char)(val >> 8), (char)val, KNRM); + break; + default: + printf("%s %c%c%c\n", trace, (char)(val >> 16), (char)(val >> 8), (char)val); + break; + } } static int trace_read(const char *in_file, const char *out_file, double clk, From e02f6910d1892c1647098b77ad30b180cef9c2c4 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 5 Mar 2018 13:38:12 +0000 Subject: [PATCH 106/324] topology: Add support for memory capabilities Add support in topology to define different memory capabilities that can be included by standard pipeline definitions to set platform specific capabilities for buffers. This patch allows memory capabilities to be defined for each platform and included by all pipeline definitions. Signed-off-by: Liam Girdwood --- topology/Makefile.am | 2 +- topology/common/Makefile.am | 3 ++- topology/common/memory.m4 | 15 +++++++++++++++ topology/dsps/bdw.m4 | 8 ++++++++ topology/dsps/bxt.m4 | 11 +++++++++++ topology/dsps/byt.m4 | 8 ++++++++ topology/dsps/cht.m4 | 8 ++++++++ topology/dsps/hsw.m4 | 8 ++++++++ topology/m4/local.m4 | 19 ++++++++++++++++--- topology/sof/pipe-low-latency-capture.m4 | 6 ++++-- topology/sof/pipe-low-latency-playback.m4 | 12 ++++++++---- topology/sof/pipe-passthrough-capture.m4 | 3 ++- topology/sof/pipe-passthrough-playback.m4 | 3 ++- topology/sof/pipe-pcm-media.m4 | 9 ++++++--- topology/sof/pipe-src-capture.m4 | 8 +++++--- topology/sof/pipe-src-playback.m4 | 6 ++++-- topology/sof/pipe-tone.m4 | 6 ++++-- topology/sof/pipe-volume-capture.m4 | 6 ++++-- topology/sof/pipe-volume-playback.m4 | 6 ++++-- topology/sof/tokens.m4 | 1 + topology/test/tplg-build.sh | 2 +- 21 files changed, 122 insertions(+), 28 deletions(-) create mode 100644 topology/common/memory.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 1e80d5737d5f..a62aa789139c 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -34,7 +34,7 @@ MACHINES = \ .PRECIOUS: %.conf %.conf : %.m4 ${DEPS} - m4 -I m4 $< > $@ + m4 -I m4 -I common $< > $@ %.tplg : %.conf alsatplg -v 1 -c $< -o $@ diff --git a/topology/common/Makefile.am b/topology/common/Makefile.am index 980f0ceba946..7e207a79703f 100644 --- a/topology/common/Makefile.am +++ b/topology/common/Makefile.am @@ -1,3 +1,4 @@ EXTRA_DIST = \ - tlv.m4 + tlv.m4 \ + memory.m4 diff --git a/topology/common/memory.m4 b/topology/common/memory.m4 new file mode 100644 index 000000000000..0852dffefd64 --- /dev/null +++ b/topology/common/memory.m4 @@ -0,0 +1,15 @@ +dnl +dnl Memory capabilities. +dnl +dnl These are ORed together to create a capability mask that's sent to the +dnl SOF firmware when creating buffer or allocating other memory resources. +dnl +dnl ** Must match SOF_MEM_CAPS_ values in ipc.h ** + +define(`MEM_CAP_RAM', eval(1 << 0)) +define(`MEM_CAP_ROM', eval(1 << 1)) +define(`MEM_CAP_EXT', eval(1 << 2)) +define(`MEM_CAP_LP', eval(1 << 3)) +define(`MEM_CAP_HP', eval(1 << 4)) +define(`MEM_CAP_DMA', eval(1 << 5)) +define(`MEM_CAP_CACHE', eval(1 << 6)) diff --git a/topology/dsps/bdw.m4 b/topology/dsps/bdw.m4 index 428e8bb96205..ad063626a44e 100644 --- a/topology/dsps/bdw.m4 +++ b/topology/dsps/bdw.m4 @@ -2,6 +2,14 @@ # Broadwell differentiation for pipelines and components # +include(`memory.m4') + +dnl Memory capabilities for diferent buffer types on Broadwell +define(`PLATFORM_DAI_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_HOST_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_PASS_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) + # Low Latency PCM Configuration SectionVendorTuples."pipe_ll_schedule_plat_tokens" { tokens "sof_sched_tokens" diff --git a/topology/dsps/bxt.m4 b/topology/dsps/bxt.m4 index 688e9fa4caa1..61bcb7e6d7c0 100644 --- a/topology/dsps/bxt.m4 +++ b/topology/dsps/bxt.m4 @@ -2,6 +2,17 @@ # Broxton differentiation for pipelines and components # +include(`memory.m4') + +dnl Memory capabilities for diferent buffer types on Baytrail +define(`PLATFORM_DAI_MEM_CAP', + MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE, MEM_CAP_HP)) +define(`PLATFORM_HOST_MEM_CAP', + MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE, MEM_CAP_HP)) +define(`PLATFORM_PASS_MEM_CAP', + MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE, MEM_CAP_HP)) +define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) + # Low Latency PCM Configuration SectionVendorTuples."pipe_ll_schedule_plat_tokens" { tokens "sof_sched_tokens" diff --git a/topology/dsps/byt.m4 b/topology/dsps/byt.m4 index b4defaa05456..64cee72aab5c 100644 --- a/topology/dsps/byt.m4 +++ b/topology/dsps/byt.m4 @@ -2,6 +2,14 @@ # Baytrail differentiation for pipelines and components # +include(`memory.m4') + +dnl Memory capabilities for diferent buffer types on Baytrail +define(`PLATFORM_DAI_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_HOST_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_PASS_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) + # Low Latency PCM Configuration SectionVendorTuples."pipe_ll_schedule_plat_tokens" { tokens "sof_sched_tokens" diff --git a/topology/dsps/cht.m4 b/topology/dsps/cht.m4 index fdee83daeaa3..1f461d999072 100644 --- a/topology/dsps/cht.m4 +++ b/topology/dsps/cht.m4 @@ -2,6 +2,14 @@ # Cherrytrail differentiation for pipelines and components # +include(`memory.m4') + +dnl Memory capabilities for diferent buffer types on Cherrytrail +define(`PLATFORM_DAI_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_HOST_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_PASS_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) + # Low Latency PCM Configuration SectionVendorTuples."pipe_ll_schedule_plat_tokens" { tokens "sof_sched_tokens" diff --git a/topology/dsps/hsw.m4 b/topology/dsps/hsw.m4 index edb417f759e7..074542a2fc63 100644 --- a/topology/dsps/hsw.m4 +++ b/topology/dsps/hsw.m4 @@ -2,6 +2,14 @@ # Haswell differentiation for pipelines and components # +include(`memory.m4') + +dnl Memory capabilities for diferent buffer types on Haswell +define(`PLATFORM_DAI_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_HOST_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_PASS_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE)) +define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) + # Low Latency PCM Configuration SectionVendorTuples."pipe_ll_schedule_plat_tokens" { tokens "sof_sched_tokens" diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 29b8b29b41d0..14d742d257d8 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -4,13 +4,25 @@ define(`concat',`$1$2') define(`STR', `"'$1`"') +dnl Argument iterator. define(`argn', `ifelse(`$1', 1, ``$2'', `argn(decr(`$1'), shift(shift($@)))')') -define(`KCONTROLS', `pushdef(`i', $#) pushdef(`j', `1') KCONTROL_LOOP($@)') -define(`KCONTROL_LOOP', `argn(j,$@) +dnl Defines a list of items from a variable number of params. +dnl Use as last argument in a macro. +define(`LIST_LOOP', `argn(j,$@) ifelse(i,`1', `', `define(`i', decr(i)) define(`j', incr(j)) $0($@)')') +dnl Sums a list of variable arguments. Use as last argument in macro. +define(`SUM_LOOP', `eval(argn(j,$@) + ifelse(i,`1', `', `define(`i', decr(i)) define(`j', incr(j)) + $0($@)'))') + +dnl Support a varaible list of kcontrols. +define(`KCONTROLS', `pushdef(`i', $#) pushdef(`j', `1') LIST_LOOP($@)') + +dnl Memory capabilities +define(`MEMCAPS', `pushdef(`i', $#) pushdef(`j', `1') SUM_LOOP($@)') + dnl create direct DAPM/pipeline link between 2 widgets) define(`dapm', `"$1, , $2"') @@ -53,12 +65,13 @@ define(`W_SRC', dnl Buffer name) define(`N_BUFFER', `BUF'PIPELINE_ID`.'$1) -dnl W_BUFFER(name, size) +dnl W_BUFFER(name, size, capabilities) define(`W_BUFFER', `SectionVendorTuples."'N_BUFFER($1)`_tuples" {' ` tokens "sof_buffer_tokens"' ` tuples."word" {' ` SOF_TKN_BUF_SIZE' STR($2) +` SOF_TKN_BUF_CAPS' $3 ` }' `}' `SectionData."'N_BUFFER($1)`_data" {' diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 2602ebd9da13..41fc622ec929 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -52,9 +52,11 @@ W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, KCONTROLS("PCM PCM_ID Capture Volume")) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_DAI_MEM_CAP) W_BUFFER(1, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) # # Pipeline Graph diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index ebb14ec57625..37f8be21caaa 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -101,13 +101,17 @@ W_MIXER(0, PIPELINE_FORMAT, 1, 1, 1) # Low Latency Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) W_BUFFER(1, COMP_BUFFER_SIZE(1, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS,SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS,SCHEDULE_FRAMES), + PLATFORM_COMP_MEM_CAP) W_BUFFER(2, COMP_BUFFER_SIZE(1, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_COMP_MEM_CAP) W_BUFFER(3, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_DAI_MEM_CAP) # # Pipeline Graph diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index 2c2a4957df87..b0dfe48bc1e8 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -18,7 +18,8 @@ W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_PASS_MEM_CAP) # # DAI definitions diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index 17222560926a..b86f1b318323 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -18,7 +18,8 @@ W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_PASS_MEM_CAP) # # DAI definitions diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 526ae352367c..1766aca334f6 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -75,13 +75,16 @@ W_SRC(0, PIPELINE_FORMAT, 2, 2, media_src_conf, 2) # Media Source Buffers to SRC, make them big enough to deal with 2 * rate. W_BUFFER(0, COMP_BUFFER_SIZE(4, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) W_BUFFER(1,COMP_BUFFER_SIZE(4, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_COMP_MEM_CAP) # Buffer B2 is on fixed rate sink side of SRC. Set it 1.5 * rate. W_BUFFER(2, COMP_BUFFER_SIZE(3, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_COMP_MEM_CAP) # # Pipeline Graph diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index dc55dd2f7223..96d7ee717f44 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -37,9 +37,11 @@ W_SRC(0, PIPELINE_FORMAT, 4, 4, media_src_conf, 2) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(4, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) W_BUFFER(1, COMP_BUFFER_SIZE(4, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_DAI_MEM_CAP) # # DAI definitions @@ -56,7 +58,7 @@ W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, # # Pipeline Graph # -# host PCM_P --> B0 --> SRC 0 --> B1 --> sink DAI0 +# host PCM_P <-- B0 <-- SRC 0 <-- B1 <-- sink DAI0 SectionGraph."pipe-pass-src-capture-PIPELINE_ID" { index STR(PIPELINE_ID) diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index d03754389666..a6141c97eb94 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -37,9 +37,11 @@ W_SRC(0, PIPELINE_FORMAT, 4, 4, media_src_conf, 2) # Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(4, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) W_BUFFER(1, COMP_BUFFER_SIZE(4, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_DAI_MEM_CAP) # # DAI definitions diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index e04a1b95ea5f..a8064ab30f64 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -54,9 +54,11 @@ W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, KCONTROLS("Tone Volume PIPELINE_ID")) # Low Latency Buffers W_BUFFER(0,COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_COMP_MEM_CAP) W_BUFFER(1, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_COMP_MEM_CAP) # diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 58e5393b4ad6..2fd6b98303b7 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -51,9 +51,11 @@ W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("Master Capture Volume")) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) W_BUFFER(1, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_DAI_MEM_CAP) # # DAI definitions diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 8aa02fbc50c2..943117706565 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -77,9 +77,11 @@ W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("Master Playback Volume Switch", "M # Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) W_BUFFER(1, COMP_BUFFER_SIZE(2, - COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES)) + COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_DAI_MEM_CAP) # # DAI definitions diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index 704effc5f70c..6b966b3c02e1 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -11,6 +11,7 @@ SectionVendorTokens."sof_buffer_tokens" { SOF_TKN_BUF_SIZE "100" + SOF_TKN_BUF_CAPS "101" } SectionVendorTokens."sof_dai_tokens" { diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 047ef6bc6a1a..9022d1c61901 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -8,7 +8,7 @@ set -e # M4 preprocessor flags -M4_FLAGS="-I ../ -I ../m4" +M4_FLAGS="-I ../ -I ../m4 -I ../common" # Simple component test cases # can be used on components with 1 sink and 1 source. From 21a4c7d71e206e6b876ebfa5ba0984688e15e13b Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 5 Mar 2018 13:41:41 +0000 Subject: [PATCH 107/324] topology: Add cannonlake platform differentiation header Add differentiation M4 header macros for the Intel Cannonlake platform. Signed-off-by: Liam Girdwood --- topology/dsps/Makefile.am | 3 +- topology/dsps/cnl.m4 | 108 +++++++++++++++++++++++++++++++++++++ topology/reef-cnl-rt274.m4 | 2 +- 3 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 topology/dsps/cnl.m4 diff --git a/topology/dsps/Makefile.am b/topology/dsps/Makefile.am index 9bbade76c18f..d4c8dd6f2d40 100644 --- a/topology/dsps/Makefile.am +++ b/topology/dsps/Makefile.am @@ -3,5 +3,6 @@ EXTRA_DIST = \ bxt.m4 \ byt.m4 \ cht.m4 \ - hsw.m4 + hsw.m4 \ + cnl.m4 diff --git a/topology/dsps/cnl.m4 b/topology/dsps/cnl.m4 new file mode 100644 index 000000000000..547c68998800 --- /dev/null +++ b/topology/dsps/cnl.m4 @@ -0,0 +1,108 @@ +# +# Broxton differentiation for pipelines and components +# + +include(`memory.m4') + +dnl Memory capabilities for diferent buffer types on Cannonlake +define(`PLATFORM_DAI_MEM_CAP', + MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE, MEM_CAP_HP)) +define(`PLATFORM_HOST_MEM_CAP', + MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE, MEM_CAP_HP)) +define(`PLATFORM_PASS_MEM_CAP', + MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE, MEM_CAP_HP)) +define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) + +# Low Latency PCM Configuration +SectionVendorTuples."pipe_ll_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_MIPS "50000" + } +} + +SectionData."pipe_ll_schedule_plat" { + tuples "pipe_ll_schedule_plat_tokens" +} + +# Media PCM Configuration +SectionVendorTuples."pipe_media_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_MIPS "100000" + } +} + +SectionData."pipe_media_schedule_plat" { + tuples "pipe_media_schedule_plat_tokens" +} + +# Tone Signal Generator Configuration +SectionVendorTuples."pipe_tone_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_MIPS "200000" + } +} + +SectionData."pipe_tone_schedule_plat" { + tuples "pipe_tone_schedule_plat_tokens" +} + +# DAI0 platform playback configuration +SectionVendorTuples."dai0p_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "0" + } +} + +SectionData."dai0p_plat_conf" { + tuples "dai0p_plat_tokens" +} + +# DAI0 platform capture configuration +SectionVendorTuples."dai0c_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC "1" + SOF_TKN_DAI_DMAC_CHAN "1" + } +} + +SectionData."dai0c_plat_conf" { + tuples "dai0c_plat_tokens" +} + +# PCM platform configuration +SectionVendorTuples."pcm_plat_tokens" { + tokens "sof_dai_tokens" + + tuples."word" { + SOF_TKN_DAI_DMAC PIPELINE_DMAC + SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN + } +} + +SectionData."pcm_plat_conf" { + tuples "pcm_plat_tokens" +} + +# DAI schedule Configuration - scheduled by IRQ +SectionVendorTuples."pipe_dai_schedule_plat_tokens" { + tokens "sof_sched_tokens" + + tuples."word" { + SOF_TKN_SCHED_MIPS "5000" + } +} + +SectionData."pipe_dai_schedule_plat" { + tuples "pipe_dai_schedule_plat_tokens" +} diff --git a/topology/reef-cnl-rt274.m4 b/topology/reef-cnl-rt274.m4 index 67aab04670a8..f91a74fe95fc 100644 --- a/topology/reef-cnl-rt274.m4 +++ b/topology/reef-cnl-rt274.m4 @@ -13,7 +13,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Apollolake DSP configuration -include(`dsps/bxt.m4') +include(`dsps/cnl.m4') # # Define the pipelines From 5b8dfd13019cfd29999503b56c902f56209000ed Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Mon, 5 Mar 2018 16:05:39 +0000 Subject: [PATCH 108/324] topology: stringify buffer caps. Needs to be string for proper alsa-conf parsing. Signed-off-by: Liam Girdwood --- topology/m4/local.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 14d742d257d8..31221f35e999 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -71,7 +71,7 @@ define(`W_BUFFER', ` tokens "sof_buffer_tokens"' ` tuples."word" {' ` SOF_TKN_BUF_SIZE' STR($2) -` SOF_TKN_BUF_CAPS' $3 +` SOF_TKN_BUF_CAPS' STR($3) ` }' `}' `SectionData."'N_BUFFER($1)`_data" {' From da6d3eabb7066c4eb142166e23af024d1a04d587 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 5 Mar 2018 13:58:26 -0800 Subject: [PATCH 109/324] topology: make list loop more generic with formatting argument This patch adds changes to make list loop more generic with format argument Signed-off-by: Ranjani Sridharan --- topology/m4/local.m4 | 13 ++++++++----- topology/sof/pipe-low-latency-capture.m4 | 2 +- topology/sof/pipe-low-latency-playback.m4 | 4 ++-- topology/sof/pipe-pcm-media.m4 | 2 +- topology/sof/pipe-tone.m4 | 3 ++- topology/sof/pipe-volume-capture.m4 | 2 +- topology/sof/pipe-volume-playback.m4 | 2 +- 7 files changed, 16 insertions(+), 12 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 31221f35e999..1ebe19dea5fd 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -10,16 +10,16 @@ define(`argn', `ifelse(`$1', 1, ``$2'', dnl Defines a list of items from a variable number of params. dnl Use as last argument in a macro. +dnl The first argument specifies the number of tabs to be added for formatting define(`LIST_LOOP', `argn(j,$@) - ifelse(i,`1', `', `define(`i', decr(i)) define(`j', incr(j)) $0($@)')') +$1ifelse(i,`2', `', `define(`i', decr(i))define(`j', incr(j))$0($@)')') + +define(`LIST', `pushdef(`i', $#)pushdef(`j', `2')LIST_LOOP($@)popdef(i)popdef(j)') dnl Sums a list of variable arguments. Use as last argument in macro. define(`SUM_LOOP', `eval(argn(j,$@) ifelse(i,`1', `', `define(`i', decr(i)) define(`j', incr(j)) + $0($@)'))') -dnl Support a varaible list of kcontrols. -define(`KCONTROLS', `pushdef(`i', $#) pushdef(`j', `1') LIST_LOOP($@)') - dnl Memory capabilities define(`MEMCAPS', `pushdef(`i', $#) pushdef(`j', `1') SUM_LOOP($@)') @@ -165,7 +165,7 @@ define(`N_PGA', `PGA'PIPELINE_ID`.'$1) dnl W_PGA(name, format, periods_sink, periods_source, preload, kcontrol0. kcontrol1...etc) define(`W_PGA', -`pushdef(`args',`eval($#-6)')SectionVendorTuples."'N_PGA($1)`_tuples_w" {' +`SectionVendorTuples."'N_PGA($1)`_tuples_w" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' ` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) @@ -270,6 +270,9 @@ define(`W_TONE', ` "'N_TONE($1)`_data_w"' ` "'N_TONE($1)`_data_str"' ` ]' +` mixer [' + $6 +` ]' `}') dnl DAI name) diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 41fc622ec929..6bb1a3dcd5d3 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -48,7 +48,7 @@ SectionControlMixer.STR(PCM PCM_ID Capture Volume) { W_PCM_CAPTURE(Low Latency Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 0) # "Capture Volume" has 2 sink and source periods for host and DAI ping-pong -W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, KCONTROLS("PCM PCM_ID Capture Volume")) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, LIST(` ', "PCM PCM_ID Capture Volume")) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index 37f8be21caaa..64761a9d014b 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -91,10 +91,10 @@ SectionControlMixer.STR(Master Playback Volume) { W_PCM_PLAYBACK(Low Latency Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Playback Volume" has 1 sink period and 2 source periods for host ping-pong -W_PGA(0, PIPELINE_FORMAT, 1, 2, 1, KCONTROLS("PCM PCM_ID Playback Volume")) +W_PGA(0, PIPELINE_FORMAT, 1, 2, 1, LIST(` ', "PCM PCM_ID Playback Volume")) # "Master Playback Volume" has 1 source and 2 sink periods for DAI ping-pong -W_PGA(1, PIPELINE_FORMAT, 2, 1, 1, KCONTROLS("Master Playback Volume")) +W_PGA(1, PIPELINE_FORMAT, 2, 1, 1, LIST(` ', "Master Playback Volume")) # Mixer 0 has 1 sink and source periods. W_MIXER(0, PIPELINE_FORMAT, 1, 1, 1) diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 1766aca334f6..c1cff335ee2d 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -68,7 +68,7 @@ SectionData."media_src_conf" { W_PCM_PLAYBACK(Media Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Playback Volume" has 2 sink period and 2 source periods for host ping-pong -W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("PCM PCM_ID Playback Volume")) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "PCM PCM_ID Playback Volume")) # "SRC 0" has 2 sink and source periods. W_SRC(0, PIPELINE_FORMAT, 2, 2, media_src_conf, 2) diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index a8064ab30f64..f53f77f056e9 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -32,6 +32,7 @@ SectionControlMixer.STR(Tone Volume PIPELINE_ID) { # control uses bespoke driver get/put/info ID 0 ops."ctl" { info "volsw" + # 256 binds the mixer control to volume get/put handlers get "256" put "256" } @@ -50,7 +51,7 @@ SectionControlMixer.STR(Tone Volume PIPELINE_ID) { W_TONE(0, PIPELINE_FORMAT, 2, 0, 0) # "Tone Volume" has 2 sink period and 2 source periods -W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, KCONTROLS("Tone Volume PIPELINE_ID")) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, LIST(` ', "Tone Volume PIPELINE_ID")) # Low Latency Buffers W_BUFFER(0,COMP_BUFFER_SIZE(2, diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 2fd6b98303b7..56494b48c666 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -47,7 +47,7 @@ SectionControlMixer.STR(Master Capture Volume) { W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) # "Volume" has 2 source and 2 sink periods -W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("Master Capture Volume")) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Capture Volume")) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 943117706565..24ae45cfcb2e 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -73,7 +73,7 @@ SectionControlMixer.STR(Master Playback Volume Switch) { W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Volume" has 2 source and 2 sink periods -W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, KCONTROLS("Master Playback Volume Switch", "Master Playback Volume")) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume Switch", "Master Playback Volume")) # Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, From 29dd4df5d126ac3f5cc0daac517eb627440ceec8 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 5 Mar 2018 13:58:27 -0800 Subject: [PATCH 110/324] topology: add kcontrol for tone component This patch adds the changes to add kcontrols to the tone component Signed-off-by: Ranjani Sridharan --- topology/m4/local.m4 | 2 +- topology/sof/pipe-tone.m4 | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 1ebe19dea5fd..b2d4f28e87a2 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -240,7 +240,7 @@ define(`W_MIXER', dnl Tone name) define(`N_TONE', `TONE'PIPELINE_ID`.'$1) -dnl W_TONE(name, format, periods_sink, periods_source, preload) +dnl W_TONE(name, format, periods_sink, periods_source, preload, kcontrols_list) define(`W_TONE', `SectionVendorTuples."'N_TONE($1)`_tuples_w" {' ` tokens "sof_comp_tokens"' diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index f53f77f056e9..50a1050037f4 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -43,12 +43,40 @@ SectionControlMixer.STR(Tone Volume PIPELINE_ID) { tlv "vtlv_m90s3" } +SectionControlMixer.STR(Tone Switch PIPELINE_ID) { + + # control belongs to this index group + index STR(PIPELINE_ID) + + # Channel register and shift for Front Left/Right + channel."FL" { + reg "2" + shift "0" + } + channel."FR" { + reg "2" + shift "1" + } + + # control uses bespoke driver get/put/info ID 0 + ops."ctl" { + info "volsw" + # 256 binds the mixer control to volume get/put handlers + get "256" + put "256" + } + + # max 1 indicates switch type mixer control + max "1" + invert "false" +} + # # Components and Buffers # # "Tone 0" has 2 sink period and 0 source periods -W_TONE(0, PIPELINE_FORMAT, 2, 0, 0) +W_TONE(0, PIPELINE_FORMAT, 2, 0, 0, LIST(` ', "Tone Switch PIPELINE_ID")) # "Tone Volume" has 2 sink period and 2 source periods W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, LIST(` ', "Tone Volume PIPELINE_ID")) From b99d1de979366a071aef8f7b4aff02e7e88003f6 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 5 Mar 2018 13:58:28 -0800 Subject: [PATCH 111/324] topology: add a test hostless tone pipeline This patch adds changes to create a test hostless tone pipeline. Signed-off-by: Ranjani Sridharan --- topology/test/test-tone-playback-ssp.m4 | 62 +++++++++++++++++++++++++ topology/test/tplg-build.sh | 38 ++++++++++++++- 2 files changed, 99 insertions(+), 1 deletion(-) create mode 100644 topology/test/test-tone-playback-ssp.m4 diff --git a/topology/test/test-tone-playback-ssp.m4 b/topology/test/test-tone-playback-ssp.m4 new file mode 100644 index 000000000000..2fe66933faef --- /dev/null +++ b/topology/test/test-tone-playback-ssp.m4 @@ -0,0 +1,62 @@ +# +# Topology for Tone Generator Playback +# + +# Include topology builder +include(`local.m4') +include(`build.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# +# TEST_PIPE_NAME - Pipe name +# TEST_DAI_LINK_NAME - BE DAI link name e.g. "NoCodec" +# TEST_SSP_PORT - SSP port number e.g. 2 +# TEST_SSP_FORMAT - SSP data format e.g s16le +# TEST_PIPE_FORMAT - Pipeline format e.g. s16le +# TEST_SSP_MCLK - SSP MCLK in Hz +# TEST_SSP_BCLK - SSP BCLK in Hz +# TEST_SSP_PHY_BITS - SSP physical slot size +# TEST_SSP_DATA_BITS - SSP data slot size +# + +# +# Define the pipeline +# +# Tone --B0--> volume --B1--> SSP2 +# + +# Tone Playback pipeline 5 using max 2 channels of TEST_PIPE_FORMAT. +# Schedule with 48 frame per 1000us deadline on core 0 with priority 0 +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, TEST_PIPE_FORMAT, + 48, 1000, 0, 0) + +# playback DAI is SSP2 using 2 periods +# Buffers use TEST_SSP_FORMAT format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 5, SSP, TEST_SSP_PORT, + PIPELINE_SOURCE_5, 2, TEST_SSP_FORMAT, + 48, 1000, 2, 0) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT +# +DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, + DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), + DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 9022d1c61901..eaa6f8ba6d48 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -13,6 +13,8 @@ M4_FLAGS="-I ../ -I ../m4 -I ../common" # Simple component test cases # can be used on components with 1 sink and 1 source. SIMPLE_TESTS=(test-ssp test-capture-ssp test-playback-ssp) +TONE_TEST=test-tone-playback-ssp + # process m4 simple tests - # simple_test(name, pipe_name, be_name, format, dai_id, dai_format, dai_phy_bits, dai_data_bits dai_bclk) @@ -23,7 +25,7 @@ SIMPLE_TESTS=(test-ssp test-capture-ssp test-playback-ssp) # 5) dai_id - SSP port number # 6) dai_format - SSP sample format # 7) dai_phy_bits - SSP physical number of BLKCs per slot/channel -# 8) dai_data_bits - SSP number of valid daat bits per slot/channel +# 8) dai_data_bits - SSP number of valid data bits per slot/channel # 9) dai_bclk - SSP BCLK in HZ # 10) dai_mclk - SSP MCLK in HZ # @@ -48,6 +50,37 @@ function simple_test { done } +# process m4 tone test - +# tone_test(name, pipe_name, be_name, format, dai_id, dai_format, dai_phy_bits, dai_data_bits dai_bclk) +# 1) name - test filename suffix +# 2) pipe_name - test component pipeline filename in sof/ +# 3) be_name - BE DAI link name in machine driver, used for matching +# 4) format - PCM sample format +# 5) dai_id - SSP port number +# 6) dai_format - SSP sample format +# 7) dai_phy_bits - SSP physical number of BLKCs per slot/channel +# 8) dai_data_bits - SSP number of valid data bits per slot/channel +# 9) dai_bclk - SSP BCLK in HZ +# 10) dai_mclk - SSP MCLK in HZ +# +function tone_test { + TFILE="$TONE_TEST$5-$2-$4-$6-48k-$1" + echo "M4 pre-processing test $TONE_TEST -> ${TFILE}" + m4 ${M4_FLAGS} \ + -DTEST_PIPE_NAME="$2" \ + -DTEST_DAI_LINK_NAME="$3" \ + -DTEST_SSP_PORT=$5 \ + -DTEST_SSP_FORMAT=$6 \ + -DTEST_PIPE_FORMAT=$4 \ + -DTEST_SSP_BCLK=$9 \ + -DTEST_SSP_MCLK=${10} \ + -DTEST_SSP_PHY_BITS=$7 \ + -DTEST_SSP_DATA_BITS=$8 \ + $TONE_TEST.m4 > ${TFILE}.conf + echo "Compiling test $TONE_TEST -> ${TFILE}.tplg" + alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg +} + # Pre-process the simple tests simple_test nocodec passthrough "NoCodec" s16le 2 s16le 20 16 1920000 19200000 simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 19200000 @@ -74,4 +107,7 @@ simple_test baytrail src "Baytrail Audio" s24le 2 s24le 25 24 2400000 19200000 simple_test nocodec volume "NoCodec" s16le 4 s16le 16 16 1536000 24576000 simple_test codec volume "SSP4-Codec" s16le 4 s16le 16 16 1536000 24576000 +# Tone test: Tone component only supports s32le currently +tone_test codec tone "SSP2-Codec" s32le 2 s16le 20 16 1920000 19200000 + From ee8afc806416f98ca823f97e00e413eb3e6c89bd Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 5 Mar 2018 13:58:29 -0800 Subject: [PATCH 112/324] topology: create m4 wrapper for mixer control section This patch adds m4 wrapper for mixercontrol section in pipeline definition Signed-off-by: Ranjani Sridharan --- topology/m4/local.m4 | 45 ++++++++++++++ topology/sof/pipe-low-latency-capture.m4 | 36 +++-------- topology/sof/pipe-low-latency-playback.m4 | 73 ++++++----------------- topology/sof/pipe-pcm-media.m4 | 37 +++--------- topology/sof/pipe-tone.m4 | 73 ++++++----------------- topology/sof/pipe-volume-capture.m4 | 35 +++-------- topology/sof/pipe-volume-playback.m4 | 70 ++++++---------------- 7 files changed, 120 insertions(+), 249 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index b2d4f28e87a2..535bb660a278 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -562,4 +562,49 @@ define(`PCM_DUPLEX_ADD', ` }' `}') +dnl KCONTROL_CHANNEL(name, reg, shift) +define(`KCONTROL_CHANNEL', +`channel.STR($1) {' +` reg STR($2)' +` shift STR($3)' +` }') + +dnl CONTROLMIXER_MAX(comment, value) +define(`CONTROLMIXER_MAX', +`#$1' +` max STR($2)') + +dnl CONTROLMIXER_TLV(comment, value) +define(`CONTROLMIXER_TLV', +`#$1' +` tlv STR($2)') + +dnl CONTROLMIXER_OPS(info, comment, get, put) +define(`CONTROLMIXER_OPS', +`ops."ctl" {' +` info STR($1)' +` #$2' +` get STR($3)' +` put STR($4)' +` }') + +dnl C_CONTROLMIXER(name, index, ops, max, invert, tlv, KCONTROL_CHANNELS) +define(`C_CONTROLMIXER', +`SectionControlMixer.STR($1) {' +`' +` # control belongs to this index group' +` index STR($2)' +`' +` #$7' +` $8' +` # control uses bespoke driver get/put/info ID' +` $3' +`' +` $4' +` invert STR($5)' +` $6' +`}') + divert(0) dnl + + diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 6bb1a3dcd5d3..057312d2cd49 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -10,34 +10,14 @@ include(`local.m4') # # Controls # - -SectionControlMixer.STR(PCM PCM_ID Capture Volume) { - - # control belongs to this index group - index STR(PIPELINE_ID) - - # Channel register and shift for Front Left/Right - channel."FL" { - reg "0" - shift "0" - } - channel."FR" { - reg "0" - shift "1" - } - - # control uses bespoke driver get/put/info ID 0 - ops."ctl" { - info "volsw" - get "256" - put "256" - } - - # TLV 40 steps from -90dB to +20dB for 3dB - max "40" - invert "false" - tlv "vtlv_m90s3" -} +# Volume Mixer control with max value of 32 +C_CONTROLMIXER(PCM PCM_ID Capture Volume, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(, 40), + false, + CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3), + Channel register and shift for Front Left/Right, + LIST(` ', KCONTROL_CHANNEL(FL, 0, 0), KCONTROL_CHANNEL(FR, 0, 1))) # # Components and Buffers diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index 64761a9d014b..f434ce110f95 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -25,62 +25,23 @@ include(`local.m4') # # Controls # - -SectionControlMixer.STR(PCM PCM_ID Playback Volume) { - - # control belongs to this index group - index STR(PIPELINE_ID) - - # Channel register and shift for Front Left/Right - channel."FL" { - reg "0" - shift "0" - } - channel."FR" { - reg "0" - shift "1" - } - - # control uses bespoke driver get/put/info ID 0 - ops."ctl" { - info "volsw" - get "256" - put "256" - } - - # TLV 32 steps from -90dB to +6dB for 3dB - max "32" - invert "false" - tlv "vtlv_m90s3" -} - -SectionControlMixer.STR(Master Playback Volume) { - - # control belongs to this index group - index STR(PIPELINE_ID) - - # Channel register and shift for Front Left/Right - channel."FL" { - reg "1" - shift "0" - } - channel."FR" { - reg "1" - shift "1" - } - - # control uses bespoke driver get/put/info ID 0 - ops."ctl" { - info "volsw" - get "256" - put "256" - } - - # TLV 32 steps from -90dB to +6dB for 3dB - max "32" - invert "false" - tlv "vtlv_m90s3" -} +# Volume Mixer control with max value of 32 +C_CONTROLMIXER(PCM PCM_ID Playback Volume, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(, 32), + false, + CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3), + Channel register and shift for Front Left/Right, + LIST(KCONTROL_CHANNEL(FL, 0, 0), KCONTROL_CHANNEL(FR, 0, 1))) + +# Volume Mixer control with max value of 32 +C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(, 32), + false, + CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3), + Channel register and shift for Front Left/Right, + LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) # # Components and Buffers diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index c1cff335ee2d..e8c8158d24b8 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -13,35 +13,14 @@ include(`local.m4') # # Controls # - -SectionControlMixer.STR(PCM PCM_ID Playback Volume) { - - # control belongs to this index group - index STR(PIPELINE_ID) - - # Channel register and shift for Front Left/Right - channel."FL" { - reg "1" - shift "0" - } - channel."FR" { - reg "1" - shift "1" - } - - # control uses bespoke driver get/put/info ID 0 - ops."ctl" { - info "volsw" - get "256" - put "256" - } - - # TLV 32 steps from -90dB to +6dB for 3dB - max "32" - invert "false" - tlv "vtlv_m90s3" -} - +# Volume Mixer control with max value of 32 +C_CONTROLMIXER(PCM PCM_ID Playback Volume, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(, 32), + false, + CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3), + Channel register and shift for Front Left/Right, + LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) # # SRC Configuration diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index 50a1050037f4..507aeac5015d 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -14,62 +14,23 @@ include(`local.m4') # Controls # -SectionControlMixer.STR(Tone Volume PIPELINE_ID) { - - # control belongs to this index group - index STR(PIPELINE_ID) - - # Channel register and shift for Front Left/Right - channel."FL" { - reg "1" - shift "0" - } - channel."FR" { - reg "1" - shift "1" - } - - # control uses bespoke driver get/put/info ID 0 - ops."ctl" { - info "volsw" - # 256 binds the mixer control to volume get/put handlers - get "256" - put "256" - } - - # TLV 32 steps from -90dB to +6dB for 3dB - max "32" - invert "false" - tlv "vtlv_m90s3" -} - -SectionControlMixer.STR(Tone Switch PIPELINE_ID) { - - # control belongs to this index group - index STR(PIPELINE_ID) - - # Channel register and shift for Front Left/Right - channel."FL" { - reg "2" - shift "0" - } - channel."FR" { - reg "2" - shift "1" - } - - # control uses bespoke driver get/put/info ID 0 - ops."ctl" { - info "volsw" - # 256 binds the mixer control to volume get/put handlers - get "256" - put "256" - } - - # max 1 indicates switch type mixer control - max "1" - invert "false" -} +# Volume Mixer control with max value of 32 +C_CONTROLMIXER(Tone Volume PIPELINE_ID, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(, 32), + false, + CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3), + Channel register and shift for Front Left/Right, + LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) + +# Switch type Mixer Control with max value of 1 +C_CONTROLMIXER(Tone Switch PIPELINE_ID, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(max 1 indicates switch type control, 1), + false, + , + Channel register and shift for Front Left/Right, + LIST(` ', KCONTROL_CHANNEL(FL, 2, 0), KCONTROL_CHANNEL(FR, 2, 1))) # # Components and Buffers diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 56494b48c666..56aed26aa507 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -10,33 +10,14 @@ include(`local.m4') # # Controls # -SectionControlMixer.STR(Master Capture Volume) { - - # control belongs to this index group - index STR(PIPELINE_ID) - - # Channel register and shift for Front Left/Right - channel."FL" { - reg "1" - shift "0" - } - channel."FR" { - reg "1" - shift "1" - } - - # control uses bespoke driver get/put/info ID 0 - ops."ctl" { - info "volsw" - get "256" - put "256" - } - - # TLV 32 steps from -90dB to +6dB for 3dB - max "32" - invert "false" - tlv "vtlv_m90s3" -} +# Volume Mixer control with max value of 32 +C_CONTROLMIXER(Master Capture Volume, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(, 32), + false, + CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3), + Channel register and shift for Front Left/Right, + LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) # # Components and Buffers diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 24ae45cfcb2e..22de572bc43d 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -10,60 +10,24 @@ include(`local.m4') # # Controls # -SectionControlMixer.STR(Master Playback Volume) { +# Volume Mixer control with max value of 32 +C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(, 32), + false, + CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3), + Channel register and shift for Front Left/Right, + LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) + +# Volume Mixer Switch control with max value of 1 +C_CONTROLMIXER(Master Playback Volume Switch, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(max value 1 indicates switch type control, 1), + false, + , + Channel register and shift for Front Left/Right, + LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) - # control belongs to this index group - index STR(PIPELINE_ID) - - # Channel register and shift for Front Left/Right - channel."FL" { - reg "1" - shift "0" - } - channel."FR" { - reg "1" - shift "1" - } - - # control uses bespoke driver get/put/info ID 0 - ops."ctl" { - info "volsw" - get "256" - put "256" - } - - # TLV 32 steps from -90dB to +6dB for 3dB - max "32" - invert "false" - tlv "vtlv_m90s3" -} - -SectionControlMixer.STR(Master Playback Volume Switch) { - - # control belongs to this index group - index STR(PIPELINE_ID) - - # Channel register and shift for Front Left/Right - channel."FL" { - reg "1" - shift "0" - } - channel."FR" { - reg "1" - shift "1" - } - - # control uses bespoke driver get/put/info ID 0 - ops."ctl" { - info "volsw" - get "256" - put "256" - } - - # Volume mute on/off - max "1" - invert "false" -} # # Components and Buffers # From 625f2e1cc03d5e7012a9d62541fe400d2b5e4c3f Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 5 Mar 2018 13:58:30 -0800 Subject: [PATCH 113/324] topology: create m4 wrapper for Graph section This patch adds a m4 wrpper for Graph sections in pipeline definition Signed-off-by: Ranjani Sridharan --- topology/m4/local.m4 | 11 +++++++++++ topology/sof/pipe-dai-capture.m4 | 9 ++------- topology/sof/pipe-dai-playback.m4 | 9 ++------- topology/sof/pipe-low-latency-capture.m4 | 16 ++++++--------- topology/sof/pipe-low-latency-playback.m4 | 24 ++++++++++------------- topology/sof/pipe-passthrough-capture.m4 | 12 ++++-------- topology/sof/pipe-passthrough-playback.m4 | 12 ++++-------- topology/sof/pipe-pcm-media.m4 | 20 ++++++++----------- topology/sof/pipe-src-capture.m4 | 16 ++++++--------- topology/sof/pipe-src-playback.m4 | 16 ++++++--------- topology/sof/pipe-tone.m4 | 14 +++++-------- topology/sof/pipe-volume-capture.m4 | 16 ++++++--------- topology/sof/pipe-volume-playback.m4 | 16 ++++++--------- 13 files changed, 76 insertions(+), 115 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 535bb660a278..690f6771bd38 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -605,6 +605,17 @@ define(`C_CONTROLMIXER', ` $6' `}') +dnl P_GRAPH(name, CONNECTIONS) +define(`P_GRAPH', +`SectionGraph.STR($1) {' +` index STR($2)' +`' +` lines [' +` $3' +` ]' +`}') + + divert(0) dnl diff --git a/topology/sof/pipe-dai-capture.m4 b/topology/sof/pipe-dai-capture.m4 index e69991ecee55..36991387c380 100644 --- a/topology/sof/pipe-dai-capture.m4 +++ b/topology/sof/pipe-dai-capture.m4 @@ -16,10 +16,5 @@ W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHE # # Graph connections to pipelines -SectionGraph.STR(DAI_NAME) { - index STR(PIPELINE_ID) - - lines [ - dapm(DAI_BUF, N_DAI_IN) - ] -} +P_GRAPH(DAI_NAME, PIPELINE_ID, + LIST(` ', `dapm(DAI_BUF, N_DAI_IN)')) diff --git a/topology/sof/pipe-dai-playback.m4 b/topology/sof/pipe-dai-playback.m4 index 3a7a15812889..d35d3b112105 100644 --- a/topology/sof/pipe-dai-playback.m4 +++ b/topology/sof/pipe-dai-playback.m4 @@ -16,10 +16,5 @@ W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCH # # Graph connections to pipelines -SectionGraph.STR(DAI_NAME) { - index STR(PIPELINE_ID) - - lines [ - dapm(N_DAI_OUT, DAI_BUF) - ] -} +P_GRAPH(DAI_NAME, PIPELINE_ID, + LIST(` ', `dapm(N_DAI_OUT, DAI_BUF)')) diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 057312d2cd49..07b59adaf5b4 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -43,16 +43,12 @@ W_BUFFER(1, COMP_BUFFER_SIZE(2, # # host PCM <--B1-- volume <--B0-- source DAI0 -SectionGraph."pipe-ll-capture-PIPELINE_ID" { - index STR(PIPELINE_ID) - - lines [ - dapm(Low Latency Capture PCM_ID, N_PCMC) - dapm(N_PCMC, N_BUFFER(1)) - dapm(N_BUFFER(1), N_PGA(0)) - dapm(N_PGA(0), N_BUFFER(0)) - ] -} +P_GRAPH(pipe-ll-capture-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(Low Latency Capture PCM_ID, N_PCMC)', + `dapm(N_PCMC, N_BUFFER(1))', + `dapm(N_BUFFER(1), N_PGA(0))', + `dapm(N_PGA(0), N_BUFFER(0))')) # # Pipeline Source and Sinks diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index f434ce110f95..7c39f165f10e 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -86,20 +86,16 @@ W_BUFFER(3, COMP_BUFFER_SIZE(2, # pipeline n+3 >---+ .....etc....more pipes can be mixed here # -SectionGraph."pipe-ll-playback-PIPELINE_ID" { - index STR(PIPELINE_ID) - - lines [ - dapm(N_PCMP, Low Latency Playback PCM_ID) - dapm(N_BUFFER(0), N_PCMP) - dapm(N_PGA(0), N_BUFFER(0)) - dapm(N_BUFFER(1), N_PGA(0)) - dapm(N_MIXER(0), N_BUFFER(1)) - dapm(N_BUFFER(2), N_MIXER(0)) - dapm(N_PGA(1), N_BUFFER(2)) - dapm(N_BUFFER(3), N_PGA(1)) - ] -} +P_GRAPH(pipe-ll-playback-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(N_PCMP, Low Latency Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP)', + `dapm(N_PGA(0), N_BUFFER(0))', + `dapm(N_BUFFER(1), N_PGA(0))', + `dapm(N_MIXER(0), N_BUFFER(1))', + `dapm(N_BUFFER(2), N_MIXER(0))', + `dapm(N_PGA(1), N_BUFFER(2))', + `dapm(N_BUFFER(3), N_PGA(1))')) # # Pipeline Source and Sinks diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index b0dfe48bc1e8..8ef8a81ef27f 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -36,14 +36,10 @@ W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHE # # host PCM_C <-- B0 <-- sink DAI0 -SectionGraph."pipe-pass-capture-PIPELINE_ID" { - index STR(PIPELINE_ID) - - lines [ - dapm(Passthrough Capture PCM_ID, N_PCMC) - dapm(N_PCMC, N_BUFFER(0)) - ] -} +P_GRAPH(pipe-pass-capture-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(Passthrough Capture PCM_ID, N_PCMC)', + `dapm(N_PCMC, N_BUFFER(0))')) # # Pipeline Source and Sinks diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index b86f1b318323..a26b5eb2da5a 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -36,14 +36,10 @@ W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCH # # host PCM_P --> B0 --> sink DAI0 -SectionGraph."pipe-pass-playback-PIPELINE_ID" { - index STR(PIPELINE_ID) - - lines [ - dapm(N_PCMP, Passthrough Playback PCM_ID) - dapm(N_BUFFER(0), N_PCMP) - ] -} +P_GRAPH(pipe-pass-playback-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(N_PCMP, Passthrough Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP)')) # # Pipeline Source and Sinks diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index e8c8158d24b8..8cb8ed5ce15f 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -71,18 +71,14 @@ W_BUFFER(2, COMP_BUFFER_SIZE(3, # PCM --B0--> volume --B1--> SRC --> B2 --> Endpoint Pipeline # -SectionGraph."pipe-media-PIPELINE_ID" { - index STR(PIPELINE_ID) - - lines [ - dapm(N_PCMP, Media Playback PCM_ID) - dapm(N_BUFFER(0), N_PCMP) - dapm(N_PGA(0), N_BUFFER(0)) - dapm(N_BUFFER(1), N_PGA(0)) - dapm(N_SRC(0), N_BUFFER(1)) - dapm(N_BUFFER(2), N_SRC(0)) - ] -} +P_GRAPH(pipe-media-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(N_PCMP, Media Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP)', + `dapm(N_PGA(0), N_BUFFER(0))', + `dapm(N_BUFFER(1), N_PGA(0))', + `dapm(N_SRC(0), N_BUFFER(1))' + `dapm(N_BUFFER(2), N_SRC(0))')) # # Pipeline Source and Sinks diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index 96d7ee717f44..44bb030fe9f0 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -60,16 +60,12 @@ W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, # # host PCM_P <-- B0 <-- SRC 0 <-- B1 <-- sink DAI0 -SectionGraph."pipe-pass-src-capture-PIPELINE_ID" { - index STR(PIPELINE_ID) - - lines [ - dapm(Passthrough Capture PCM_ID, N_PCMC) - dapm(N_PCMC, N_BUFFER(0)) - dapm(N_BUFFER(0), N_SRC(0)) - dapm(N_SRC(0), N_BUFFER(1)) - ] -} +P_GRAPH(pipe-pass-src-capture-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(Passthrough Capture PCM_ID, N_PCMC)', + `dapm(N_PCMC, N_BUFFER(0))', + `dapm(N_BUFFER(0), N_SRC(0))', + `dapm(N_SRC(0), N_BUFFER(1))')) # # Pipeline Source and Sinks diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index a6141c97eb94..d34bc8afae96 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -60,16 +60,12 @@ W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, # # host PCM_P --> B0 --> SRC 0 --> B1 --> sink DAI0 -SectionGraph."pipe-pass-src-playback-PIPELINE_ID" { - index STR(PIPELINE_ID) - - lines [ - dapm(N_PCMP, Passthrough Playback PCM_ID) - dapm(N_BUFFER(0), N_PCMP) - dapm(N_SRC(0), N_BUFFER(0)) - dapm(N_BUFFER(1), N_SRC(0)) - ] -} +P_GRAPH(pipe-pass-src-playback-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(N_PCMP, Passthrough Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP)', + `dapm(N_SRC(0), N_BUFFER(0))', + `dapm(N_BUFFER(1), N_SRC(0))')) # # Pipeline Source and Sinks diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index 507aeac5015d..899c42667648 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -57,15 +57,11 @@ W_BUFFER(1, COMP_BUFFER_SIZE(2, # Tone --B0--> volume --B1--> Endpoint Pipeline # -SectionGraph."pipe-tone-PIPELINE_ID" { - index STR(PIPELINE_ID) - - lines [ - dapm(N_BUFFER(0), N_TONE(0)) - dapm(N_PGA(0), N_BUFFER(0)) - dapm(N_BUFFER(1), N_PGA(0)) - ] -} +P_GRAPH(pipe-tone-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(N_BUFFER(0), N_TONE(0))', + `dapm(N_PGA(0), N_BUFFER(0))', + `dapm(N_BUFFER(1), N_PGA(0))')) # # Pipeline Source and Sinks diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 56aed26aa507..0aa10bc57cb7 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -55,16 +55,12 @@ W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, # # host PCM_P <-- B0 <-- Volume 0 <-- B1 <-- sink DAI0 -SectionGraph."pipe-pass-vol-capture-PIPELINE_ID" { - index STR(PIPELINE_ID) - - lines [ - dapm(Passthrough Capture PCM_ID, N_PCMC) - dapm(N_PCMC, N_BUFFER(0)) - dapm(N_BUFFER(0), N_PGA(0)) - dapm(N_PGA(0), N_BUFFER(1)) - ] -} +P_GRAPH(pipe-pass-vol-capture-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(Passthrough Capture PCM_ID, N_PCMC)', + `dapm(N_PCMC, N_BUFFER(0))', + `dapm(N_BUFFER(0), N_PGA(0))', + `dapm(N_PGA(0), N_BUFFER(1))')) # # Pipeline Source and Sinks diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 22de572bc43d..4ca8ab767546 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -64,16 +64,12 @@ W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, # # host PCM_P --> B0 --> Volume 0 --> B1 --> sink DAI0 -SectionGraph."pipe-pass-vol-playback-PIPELINE_ID" { - index STR(PIPELINE_ID) - - lines [ - dapm(N_PCMP, Passthrough Playback PCM_ID) - dapm(N_BUFFER(0), N_PCMP) - dapm(N_PGA(0), N_BUFFER(0)) - dapm(N_BUFFER(1), N_PGA(0)) - ] -} +P_GRAPH(pipe-pass-vol-playback-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(N_PCMP, Passthrough Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP)', + `dapm(N_PGA(0), N_BUFFER(0))', + `dapm(N_BUFFER(1), N_PGA(0))')) # # Pipeline Source and Sinks From 9d846ac85ac5dcb06b287e6c8be02b5246e8bec0 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 5 Mar 2018 13:58:31 -0800 Subject: [PATCH 114/324] topology: create m4 wrapper SectionPCMCapabilities This patch adds a m4 wrpper for PCM Capabilities sections in pipeline definition Signed-off-by: Ranjani Sridharan --- topology/m4/local.m4 | 16 ++++++++++++++++ topology/sof/pipe-low-latency-capture.m4 | 16 +--------------- topology/sof/pipe-low-latency-playback.m4 | 16 ++-------------- topology/sof/pipe-passthrough-capture.m4 | 15 +-------------- topology/sof/pipe-passthrough-playback.m4 | 15 +-------------- topology/sof/pipe-pcm-media.m4 | 14 +------------- topology/sof/pipe-src-capture.m4 | 15 +-------------- topology/sof/pipe-src-playback.m4 | 15 +-------------- topology/sof/pipe-volume-capture.m4 | 14 +------------- topology/sof/pipe-volume-playback.m4 | 17 ++--------------- 10 files changed, 27 insertions(+), 126 deletions(-) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 690f6771bd38..90d690e4e40f 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -615,6 +615,22 @@ define(`P_GRAPH', ` ]' `}') +dnl PCM_CAPABILITIES(name, formats, rate_min, rate_max, channels_min, channels_max, periods_min, periods_max, period_size_min, period_size_max, buffer_size_min, buffer_size_max) +define(`PCM_CAPABILITIES', +`SectionPCMCapabilities.STR($1) {' +`' +` formats "$2"' +` rate_min STR($3)' +` rate_max STR($4)' +` channels_min STR($5)' +` channels_max STR($6)' +` periods_min STR($7)' +` periods_max STR($8)' +` period_size_min STR($9)' +` period_size_max STR($10)' +` buffer_size_min STR($11)' +` buffer_size_max STR($12)' +`}') divert(0) dnl diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 07b59adaf5b4..7adfd14ed790 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -60,18 +60,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Low Latency Capture PCM_ID # PCM Configuration # -SectionPCMCapabilities.STR(Low Latency Capture PCM_ID) { - - formats "S32_LE,S24_LE,S16_LE" - rate_min "48000" - rate_max "48000" - channels_min "2" - channels_max "4" - periods_min "2" - periods_max "4" - period_size_min "192" - period_size_max "16384" - buffer_size_min "65536" - buffer_size_max "65536" -} - +PCM_CAPABILITIES(Low Latency Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 4, 2, 4, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index 7c39f165f10e..11cf07d6a5cb 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -108,19 +108,7 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Low Latency Playback PCM_I # PCM Configuration # + # PCM capabilities supported by FW -SectionPCMCapabilities.STR(Low Latency Playback PCM_ID) { - - formats "S32_LE,S24_LE,S16_LE" - rate_min "48000" - rate_max "48000" - channels_min "2" - channels_max "2" - periods_min "2" - periods_max "16" - period_size_min "192" - period_size_max "16384" - buffer_size_min "65536" - buffer_size_max "65536" -} +PCM_CAPABILITIES(Low Latency Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 2, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index 8ef8a81ef27f..cfa357ab34b4 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -51,17 +51,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID # PCM Configuration # -SectionPCMCapabilities.STR(Passthrough Capture PCM_ID) { - - formats "S32_LE,S24_LE,S16_LE" - rate_min "48000" - rate_max "48000" - channels_min "2" - channels_max "4" - periods_min "2" - periods_max "16" - period_size_min "192" - period_size_max "16384" - buffer_size_min "65536" - buffer_size_max "65536" -} +PCM_CAPABILITIES(Passthrough Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index a26b5eb2da5a..3218431b9e93 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -51,17 +51,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # PCM Configuration # -SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { - - formats "S32_LE,S24_LE,S16_LE" - rate_min "48000" - rate_max "48000" - channels_min "2" - channels_max "4" - periods_min "2" - periods_max "16" - period_size_min "192" - period_size_max "16384" - buffer_size_min "65536" - buffer_size_max "65536" -} +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 8cb8ed5ce15f..1171d079789f 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -97,19 +97,7 @@ W_PIPELINE(N_SRC(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHE # PCM capabilities supported by FW -SectionPCMCapabilities.STR(Media Playback PCM_ID) { - formats "S32_LE,S24_LE,S16_LE" - rate_min "8000" - rate_max "192000" - channels_min "2" - channels_max "2" - periods_min "2" - periods_max "32" - period_size_min "192" - period_size_max "262144" - buffer_size_min "8388608" - buffer_size_max "8388608" -} +PCM_CAPABILITIES(Media Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 8000, 192000, 2, 2, 2, 32, 192, 262144, 8388608, 8388608) # PCM Low Latency Playback and Capture SectionPCM.STR(Media Playback PCM_ID) { diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index 44bb030fe9f0..d8e04a8bffd8 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -77,17 +77,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID # PCM Configuration # -SectionPCMCapabilities.STR(Passthrough Capture PCM_ID) { - - formats "S32_LE,S24_LE,S16_LE" - rate_min "8000" - rate_max "96000" - channels_min "2" - channels_max "4" - periods_min "2" - periods_max "16" - period_size_min "192" - period_size_max "16384" - buffer_size_min "65536" - buffer_size_max "65536" -} +PCM_CAPABILITIES(Passthrough Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 8000, 96000, 2, 4, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index d34bc8afae96..c9b415940894 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -77,18 +77,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # PCM Configuration # -SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { - - formats "S32_LE,S24_LE,S16_LE" - rate_min "8000" - rate_max "96000" - channels_min "2" - channels_max "4" - periods_min "2" - periods_max "16" - period_size_min "192" - period_size_max "16384" - buffer_size_min "65536" - buffer_size_max "65536" -} +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 8000, 96000, 2, 4, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 0aa10bc57cb7..299a0f8a6809 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -72,17 +72,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID # PCM Configuration # -SectionPCMCapabilities.STR(Passthrough Capture PCM_ID) { +PCM_CAPABILITIES(Passthrough Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) - formats "S32_LE,S24_LE,S16_LE" - rate_min "48000" - rate_max "48000" - channels_min "2" - channels_max "4" - periods_min "2" - periods_max "16" - period_size_min "192" - period_size_max "16384" - buffer_size_min "65536" - buffer_size_max "65536" -} diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 4ca8ab767546..3e3f98efde23 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -80,20 +80,7 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # # PCM Configuration -# -SectionPCMCapabilities.STR(Passthrough Playback PCM_ID) { - - formats "S32_LE,S24_LE,S16_LE" - rate_min "48000" - rate_max "48000" - channels_min "2" - channels_max "4" - periods_min "2" - periods_max "16" - period_size_min "192" - period_size_max "16384" - buffer_size_min "65536" - buffer_size_max "65536" -} +# +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) From c529b32eae194e6b4b83f3faa8f9ee56db830af0 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 5 Mar 2018 13:58:32 -0800 Subject: [PATCH 115/324] topology: create m4 wrapper for VendorTuples section in pipeline definition This patch adds a m4 wrpper for Vendor Tuples sections in pipeline definition Signed-off-by: Ranjani Sridharan --- topology/dsps/bdw.m4 | 59 ++++-------------------------- topology/dsps/bxt.m4 | 59 ++++-------------------------- topology/dsps/byt.m4 | 59 ++++-------------------------- topology/dsps/cht.m4 | 59 ++++-------------------------- topology/dsps/cnl.m4 | 60 +++++-------------------------- topology/dsps/hsw.m4 | 59 ++++-------------------------- topology/m4/local.m4 | 10 ++++++ topology/sof/pipe-pcm-media.m4 | 8 +---- topology/sof/pipe-src-capture.m4 | 8 +---- topology/sof/pipe-src-playback.m4 | 8 +---- 10 files changed, 56 insertions(+), 333 deletions(-) diff --git a/topology/dsps/bdw.m4 b/topology/dsps/bdw.m4 index ad063626a44e..8da70ecb6a29 100644 --- a/topology/dsps/bdw.m4 +++ b/topology/dsps/bdw.m4 @@ -11,94 +11,49 @@ define(`PLATFORM_PASS_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE) define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration -SectionVendorTuples."pipe_ll_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "50000" - } -} +W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) SectionData."pipe_ll_schedule_plat" { tuples "pipe_ll_schedule_plat_tokens" } # Media PCM Configuration -SectionVendorTuples."pipe_media_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "100000" - } -} +W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) SectionData."pipe_media_schedule_plat" { tuples "pipe_media_schedule_plat_tokens" } # Tone Signal Generator Configuration -SectionVendorTuples."pipe_tone_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "200000" - } -} +W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) SectionData."pipe_tone_schedule_plat" { tuples "pipe_tone_schedule_plat_tokens" } # DAI0 platform playback configuration -SectionVendorTuples."dai0p_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "0" - } -} +W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) SectionData."dai0p_plat_conf" { tuples "dai0p_plat_tokens" } # DAI0 platform capture configuration -SectionVendorTuples."dai0c_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "1" - } -} +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } # PCM platform configuration -SectionVendorTuples."pcm_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC PIPELINE_DMAC - SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN - } -} +W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) SectionData."pcm_plat_conf" { tuples "pcm_plat_tokens" } # DAI schedule Configuration - scheduled by IRQ -SectionVendorTuples."pipe_dai_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "5000" - } -} +W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) SectionData."pipe_dai_schedule_plat" { tuples "pipe_dai_schedule_plat_tokens" diff --git a/topology/dsps/bxt.m4 b/topology/dsps/bxt.m4 index 61bcb7e6d7c0..df2581ba32d7 100644 --- a/topology/dsps/bxt.m4 +++ b/topology/dsps/bxt.m4 @@ -14,94 +14,49 @@ define(`PLATFORM_PASS_MEM_CAP', define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration -SectionVendorTuples."pipe_ll_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "50000" - } -} +W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) SectionData."pipe_ll_schedule_plat" { tuples "pipe_ll_schedule_plat_tokens" } # Media PCM Configuration -SectionVendorTuples."pipe_media_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "100000" - } -} +W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) SectionData."pipe_media_schedule_plat" { tuples "pipe_media_schedule_plat_tokens" } # Tone Signal Generator Configuration -SectionVendorTuples."pipe_tone_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "200000" - } -} +W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) SectionData."pipe_tone_schedule_plat" { tuples "pipe_tone_schedule_plat_tokens" } # DAI0 platform playback configuration -SectionVendorTuples."dai0p_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "0" - } -} +W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) SectionData."dai0p_plat_conf" { tuples "dai0p_plat_tokens" } # DAI0 platform capture configuration -SectionVendorTuples."dai0c_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "1" - } -} +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } # PCM platform configuration -SectionVendorTuples."pcm_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC PIPELINE_DMAC - SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN - } -} +W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) SectionData."pcm_plat_conf" { tuples "pcm_plat_tokens" } # DAI schedule Configuration - scheduled by IRQ -SectionVendorTuples."pipe_dai_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "5000" - } -} +W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) SectionData."pipe_dai_schedule_plat" { tuples "pipe_dai_schedule_plat_tokens" diff --git a/topology/dsps/byt.m4 b/topology/dsps/byt.m4 index 64cee72aab5c..490a6ebe2976 100644 --- a/topology/dsps/byt.m4 +++ b/topology/dsps/byt.m4 @@ -11,94 +11,49 @@ define(`PLATFORM_PASS_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE) define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration -SectionVendorTuples."pipe_ll_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "50000" - } -} +W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) SectionData."pipe_ll_schedule_plat" { tuples "pipe_ll_schedule_plat_tokens" } # Media PCM Configuration -SectionVendorTuples."pipe_media_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "100000" - } -} +W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) SectionData."pipe_media_schedule_plat" { tuples "pipe_media_schedule_plat_tokens" } # Tone Signal Generator Configuration -SectionVendorTuples."pipe_tone_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "200000" - } -} +W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) SectionData."pipe_tone_schedule_plat" { tuples "pipe_tone_schedule_plat_tokens" } # DAI0 platform playback configuration -SectionVendorTuples."dai0p_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "0" - } -} +W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) SectionData."dai0p_plat_conf" { tuples "dai0p_plat_tokens" } # DAI0 platform capture configuration -SectionVendorTuples."dai0c_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "1" - } -} +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } # PCM platform configuration -SectionVendorTuples."pcm_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC PIPELINE_DMAC - SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN - } -} +W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) SectionData."pcm_plat_conf" { tuples "pcm_plat_tokens" } # DAI schedule Configuration - scheduled by IRQ -SectionVendorTuples."pipe_dai_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "5000" - } -} +W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) SectionData."pipe_dai_schedule_plat" { tuples "pipe_dai_schedule_plat_tokens" diff --git a/topology/dsps/cht.m4 b/topology/dsps/cht.m4 index 1f461d999072..bbb3d897befd 100644 --- a/topology/dsps/cht.m4 +++ b/topology/dsps/cht.m4 @@ -11,94 +11,49 @@ define(`PLATFORM_PASS_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE) define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration -SectionVendorTuples."pipe_ll_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "50000" - } -} +W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) SectionData."pipe_ll_schedule_plat" { tuples "pipe_ll_schedule_plat_tokens" } # Media PCM Configuration -SectionVendorTuples."pipe_media_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "100000" - } -} +W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) SectionData."pipe_media_schedule_plat" { tuples "pipe_media_schedule_plat_tokens" } # Tone Signal Generator Configuration -SectionVendorTuples."pipe_tone_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "200000" - } -} +W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) SectionData."pipe_tone_schedule_plat" { tuples "pipe_tone_schedule_plat_tokens" } # DAI0 platform playback configuration -SectionVendorTuples."dai0p_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "0" - } -} +W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) SectionData."dai0p_plat_conf" { tuples "dai0p_plat_tokens" } # DAI0 platform capture configuration -SectionVendorTuples."dai0c_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "1" - } -} +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } # PCM platform configuration -SectionVendorTuples."pcm_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC PIPELINE_DMAC - SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN - } -} +W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) SectionData."pcm_plat_conf" { tuples "pcm_plat_tokens" } # DAI schedule Configuration - scheduled by IRQ -SectionVendorTuples."pipe_dai_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "5000" - } -} +W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) SectionData."pipe_dai_schedule_plat" { tuples "pipe_dai_schedule_plat_tokens" diff --git a/topology/dsps/cnl.m4 b/topology/dsps/cnl.m4 index 547c68998800..2c7dd556f799 100644 --- a/topology/dsps/cnl.m4 +++ b/topology/dsps/cnl.m4 @@ -14,94 +14,50 @@ define(`PLATFORM_PASS_MEM_CAP', define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration -SectionVendorTuples."pipe_ll_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "50000" - } -} +# Low Latency PCM Configuration +W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) SectionData."pipe_ll_schedule_plat" { tuples "pipe_ll_schedule_plat_tokens" } # Media PCM Configuration -SectionVendorTuples."pipe_media_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "100000" - } -} +W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) SectionData."pipe_media_schedule_plat" { tuples "pipe_media_schedule_plat_tokens" } # Tone Signal Generator Configuration -SectionVendorTuples."pipe_tone_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "200000" - } -} +W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) SectionData."pipe_tone_schedule_plat" { tuples "pipe_tone_schedule_plat_tokens" } # DAI0 platform playback configuration -SectionVendorTuples."dai0p_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "0" - } -} +W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) SectionData."dai0p_plat_conf" { tuples "dai0p_plat_tokens" } # DAI0 platform capture configuration -SectionVendorTuples."dai0c_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "1" - } -} +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } # PCM platform configuration -SectionVendorTuples."pcm_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC PIPELINE_DMAC - SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN - } -} +W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) SectionData."pcm_plat_conf" { tuples "pcm_plat_tokens" } # DAI schedule Configuration - scheduled by IRQ -SectionVendorTuples."pipe_dai_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "5000" - } -} +W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) SectionData."pipe_dai_schedule_plat" { tuples "pipe_dai_schedule_plat_tokens" diff --git a/topology/dsps/hsw.m4 b/topology/dsps/hsw.m4 index 074542a2fc63..b64fc1078e90 100644 --- a/topology/dsps/hsw.m4 +++ b/topology/dsps/hsw.m4 @@ -11,94 +11,49 @@ define(`PLATFORM_PASS_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE) define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration -SectionVendorTuples."pipe_ll_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "50000" - } -} +W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) SectionData."pipe_ll_schedule_plat" { tuples "pipe_ll_schedule_plat_tokens" } # Media PCM Configuration -SectionVendorTuples."pipe_media_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "100000" - } -} +W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) SectionData."pipe_media_schedule_plat" { tuples "pipe_media_schedule_plat_tokens" } # Tone Signal Generator Configuration -SectionVendorTuples."pipe_tone_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "200000" - } -} +W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) SectionData."pipe_tone_schedule_plat" { tuples "pipe_tone_schedule_plat_tokens" } # DAI0 platform playback configuration -SectionVendorTuples."dai0p_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "0" - } -} +W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) SectionData."dai0p_plat_conf" { tuples "dai0p_plat_tokens" } # DAI0 platform capture configuration -SectionVendorTuples."dai0c_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC "1" - SOF_TKN_DAI_DMAC_CHAN "1" - } -} +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) SectionData."dai0c_plat_conf" { tuples "dai0c_plat_tokens" } # PCM platform configuration -SectionVendorTuples."pcm_plat_tokens" { - tokens "sof_dai_tokens" - - tuples."word" { - SOF_TKN_DAI_DMAC PIPELINE_DMAC - SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN - } -} +W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) SectionData."pcm_plat_conf" { tuples "pcm_plat_tokens" } # DAI schedule Configuration - scheduled by IRQ -SectionVendorTuples."pipe_dai_schedule_plat_tokens" { - tokens "sof_sched_tokens" - - tuples."word" { - SOF_TKN_SCHED_MIPS "5000" - } -} +W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) SectionData."pipe_dai_schedule_plat" { tuples "pipe_dai_schedule_plat_tokens" diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index 90d690e4e40f..b951d014e727 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -632,6 +632,16 @@ define(`PCM_CAPABILITIES', ` buffer_size_max STR($12)' `}') +dnl W_VENDORTUPLES(name, tokens, RATE_OUT) +define(`W_VENDORTUPLES', +`SectionVendorTuples.STR($1) {' +` tokens STR($2)' +`' +` tuples."word" {' +` $3' +` }' +`}') + divert(0) dnl diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 1171d079789f..2c59f7abd7ce 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -26,13 +26,7 @@ C_CONTROLMIXER(PCM PCM_ID Playback Volume, PIPELINE_ID, # SRC Configuration # -SectionVendorTuples."media_src_tokens" { - tokens "sof_src_tokens" - - tuples."word" { - SOF_TKN_SRC_RATE_OUT "48000" - } -} +W_VENDORTUPLES(media_src_tokens, sof_src_tokens, LIST(` ', `SOF_TKN_SRC_RATE_OUT "48000"')) SectionData."media_src_conf" { tuples "media_src_tokens" diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index d8e04a8bffd8..d09c5ac9c1d6 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -20,13 +20,7 @@ W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) # SRC Configuration # -SectionVendorTuples."media_src_tokens" { - tokens "sof_src_tokens" - - tuples."word" { - SOF_TKN_SRC_RATE_OUT "48000" - } -} +W_VENDORTUPLES(media_src_tokens, sof_src_tokens, LIST(` ', `SOF_TKN_SRC_RATE_OUT "48000"')) SectionData."media_src_conf" { tuples "media_src_tokens" diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index c9b415940894..e93cd64a838b 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -20,13 +20,7 @@ W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) # SRC Configuration # -SectionVendorTuples."media_src_tokens" { - tokens "sof_src_tokens" - - tuples."word" { - SOF_TKN_SRC_RATE_OUT "48000" - } -} +W_VENDORTUPLES(media_src_tokens, sof_src_tokens, LIST(` ', `SOF_TKN_SRC_RATE_OUT "48000"')) SectionData."media_src_conf" { tuples "media_src_tokens" From a99283da77b1d8d89ce402ce09d31f4fbd443b05 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 5 Mar 2018 13:58:33 -0800 Subject: [PATCH 116/324] topology: create m4 wrapper for Data section in pipeline definition This patch adds a m4 wrapper for data section in pipeline definitions Signed-off-by: Ranjani Sridharan --- topology/dsps/bdw.m4 | 28 +++++++--------------------- topology/dsps/bxt.m4 | 28 +++++++--------------------- topology/dsps/byt.m4 | 28 +++++++--------------------- topology/dsps/cht.m4 | 28 +++++++--------------------- topology/dsps/cnl.m4 | 28 +++++++--------------------- topology/dsps/hsw.m4 | 28 +++++++--------------------- topology/m4/local.m4 | 7 +++++++ topology/sof/pipe-pcm-media.m4 | 4 +--- topology/sof/pipe-src-capture.m4 | 4 +--- topology/sof/pipe-src-playback.m4 | 4 +--- 10 files changed, 52 insertions(+), 135 deletions(-) diff --git a/topology/dsps/bdw.m4 b/topology/dsps/bdw.m4 index 8da70ecb6a29..a6022b9e312c 100644 --- a/topology/dsps/bdw.m4 +++ b/topology/dsps/bdw.m4 @@ -13,48 +13,34 @@ define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) -SectionData."pipe_ll_schedule_plat" { - tuples "pipe_ll_schedule_plat_tokens" -} +W_DATA(pipe_ll_schedule_plat, pipe_ll_schedule_plat_tokens) # Media PCM Configuration W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) -SectionData."pipe_media_schedule_plat" { - tuples "pipe_media_schedule_plat_tokens" -} +W_DATA(pipe_media_schedule_plat, pipe_media_schedule_plat_tokens) # Tone Signal Generator Configuration W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) -SectionData."pipe_tone_schedule_plat" { - tuples "pipe_tone_schedule_plat_tokens" -} +W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) # DAI0 platform playback configuration W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) -SectionData."dai0p_plat_conf" { - tuples "dai0p_plat_tokens" -} +W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) -SectionData."dai0c_plat_conf" { - tuples "dai0c_plat_tokens" -} +W_DATA(dai0c_plat_conf, dai0c_plat_tokens) # PCM platform configuration W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) -SectionData."pcm_plat_conf" { - tuples "pcm_plat_tokens" -} +W_DATA(pcm_plat_conf, pcm_plat_tokens) # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) -SectionData."pipe_dai_schedule_plat" { - tuples "pipe_dai_schedule_plat_tokens" -} +W_DATA(pipe_dai_schedule_plat, pipe_dai_schedule_plat_tokens) diff --git a/topology/dsps/bxt.m4 b/topology/dsps/bxt.m4 index df2581ba32d7..4d45386c947e 100644 --- a/topology/dsps/bxt.m4 +++ b/topology/dsps/bxt.m4 @@ -16,48 +16,34 @@ define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) -SectionData."pipe_ll_schedule_plat" { - tuples "pipe_ll_schedule_plat_tokens" -} +W_DATA(pipe_ll_schedule_plat, pipe_ll_schedule_plat_tokens) # Media PCM Configuration W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) -SectionData."pipe_media_schedule_plat" { - tuples "pipe_media_schedule_plat_tokens" -} +W_DATA(pipe_media_schedule_plat, pipe_media_schedule_plat_tokens) # Tone Signal Generator Configuration W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) -SectionData."pipe_tone_schedule_plat" { - tuples "pipe_tone_schedule_plat_tokens" -} +W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) # DAI0 platform playback configuration W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) -SectionData."dai0p_plat_conf" { - tuples "dai0p_plat_tokens" -} +W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) -SectionData."dai0c_plat_conf" { - tuples "dai0c_plat_tokens" -} +W_DATA(dai0c_plat_conf, dai0c_plat_tokens) # PCM platform configuration W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) -SectionData."pcm_plat_conf" { - tuples "pcm_plat_tokens" -} +W_DATA(pcm_plat_conf, pcm_plat_tokens) # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) -SectionData."pipe_dai_schedule_plat" { - tuples "pipe_dai_schedule_plat_tokens" -} +W_DATA(pipe_dai_schedule_plat, pipe_dai_schedule_plat_tokens) diff --git a/topology/dsps/byt.m4 b/topology/dsps/byt.m4 index 490a6ebe2976..ab707f81191c 100644 --- a/topology/dsps/byt.m4 +++ b/topology/dsps/byt.m4 @@ -13,48 +13,34 @@ define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) -SectionData."pipe_ll_schedule_plat" { - tuples "pipe_ll_schedule_plat_tokens" -} +W_DATA(pipe_ll_schedule_plat, pipe_ll_schedule_plat_tokens) # Media PCM Configuration W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) -SectionData."pipe_media_schedule_plat" { - tuples "pipe_media_schedule_plat_tokens" -} +W_DATA(pipe_media_schedule_plat, pipe_media_schedule_plat_tokens) # Tone Signal Generator Configuration W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) -SectionData."pipe_tone_schedule_plat" { - tuples "pipe_tone_schedule_plat_tokens" -} +W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) # DAI0 platform playback configuration W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) -SectionData."dai0p_plat_conf" { - tuples "dai0p_plat_tokens" -} +W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) -SectionData."dai0c_plat_conf" { - tuples "dai0c_plat_tokens" -} +W_DATA(dai0c_plat_conf, dai0c_plat_tokens) # PCM platform configuration W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) -SectionData."pcm_plat_conf" { - tuples "pcm_plat_tokens" -} +W_DATA(pcm_plat_conf, pcm_plat_tokens) # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) -SectionData."pipe_dai_schedule_plat" { - tuples "pipe_dai_schedule_plat_tokens" -} +W_DATA(pipe_dai_schedule_plat, pipe_dai_schedule_plat_tokens) diff --git a/topology/dsps/cht.m4 b/topology/dsps/cht.m4 index bbb3d897befd..41529dca4ab2 100644 --- a/topology/dsps/cht.m4 +++ b/topology/dsps/cht.m4 @@ -13,48 +13,34 @@ define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) -SectionData."pipe_ll_schedule_plat" { - tuples "pipe_ll_schedule_plat_tokens" -} +W_DATA(pipe_ll_schedule_plat, pipe_ll_schedule_plat_tokens) # Media PCM Configuration W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) -SectionData."pipe_media_schedule_plat" { - tuples "pipe_media_schedule_plat_tokens" -} +W_DATA(pipe_media_schedule_plat, pipe_media_schedule_plat_tokens) # Tone Signal Generator Configuration W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) -SectionData."pipe_tone_schedule_plat" { - tuples "pipe_tone_schedule_plat_tokens" -} +W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) # DAI0 platform playback configuration W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) -SectionData."dai0p_plat_conf" { - tuples "dai0p_plat_tokens" -} +W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) -SectionData."dai0c_plat_conf" { - tuples "dai0c_plat_tokens" -} +W_DATA(dai0c_plat_conf, dai0c_plat_tokens) # PCM platform configuration W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) -SectionData."pcm_plat_conf" { - tuples "pcm_plat_tokens" -} +W_DATA(pcm_plat_conf, pcm_plat_tokens) # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) -SectionData."pipe_dai_schedule_plat" { - tuples "pipe_dai_schedule_plat_tokens" -} +W_DATA(pipe_dai_schedule_plat, pipe_dai_schedule_plat_tokens) diff --git a/topology/dsps/cnl.m4 b/topology/dsps/cnl.m4 index 2c7dd556f799..431db326f373 100644 --- a/topology/dsps/cnl.m4 +++ b/topology/dsps/cnl.m4 @@ -17,48 +17,34 @@ define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) -SectionData."pipe_ll_schedule_plat" { - tuples "pipe_ll_schedule_plat_tokens" -} +W_DATA(pipe_ll_schedule_plat, pipe_ll_schedule_plat_tokens) # Media PCM Configuration W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) -SectionData."pipe_media_schedule_plat" { - tuples "pipe_media_schedule_plat_tokens" -} +W_DATA(pipe_media_schedule_plat, pipe_media_schedule_plat_tokens) # Tone Signal Generator Configuration W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) -SectionData."pipe_tone_schedule_plat" { - tuples "pipe_tone_schedule_plat_tokens" -} +W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) # DAI0 platform playback configuration W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) -SectionData."dai0p_plat_conf" { - tuples "dai0p_plat_tokens" -} +W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) -SectionData."dai0c_plat_conf" { - tuples "dai0c_plat_tokens" -} +W_DATA(dai0c_plat_conf, dai0c_plat_tokens) # PCM platform configuration W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) -SectionData."pcm_plat_conf" { - tuples "pcm_plat_tokens" -} +W_DATA(pcm_plat_conf, pcm_plat_tokens) # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) -SectionData."pipe_dai_schedule_plat" { - tuples "pipe_dai_schedule_plat_tokens" -} +W_DATA(pipe_dai_schedule_plat, pipe_dai_schedule_plat_tokens) diff --git a/topology/dsps/hsw.m4 b/topology/dsps/hsw.m4 index b64fc1078e90..5db318f21dc2 100644 --- a/topology/dsps/hsw.m4 +++ b/topology/dsps/hsw.m4 @@ -13,48 +13,34 @@ define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) # Low Latency PCM Configuration W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) -SectionData."pipe_ll_schedule_plat" { - tuples "pipe_ll_schedule_plat_tokens" -} +W_DATA(pipe_ll_schedule_plat, pipe_ll_schedule_plat_tokens) # Media PCM Configuration W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) -SectionData."pipe_media_schedule_plat" { - tuples "pipe_media_schedule_plat_tokens" -} +W_DATA(pipe_media_schedule_plat, pipe_media_schedule_plat_tokens) # Tone Signal Generator Configuration W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) -SectionData."pipe_tone_schedule_plat" { - tuples "pipe_tone_schedule_plat_tokens" -} +W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) # DAI0 platform playback configuration W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) -SectionData."dai0p_plat_conf" { - tuples "dai0p_plat_tokens" -} +W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) -SectionData."dai0c_plat_conf" { - tuples "dai0c_plat_tokens" -} +W_DATA(dai0c_plat_conf, dai0c_plat_tokens) # PCM platform configuration W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) -SectionData."pcm_plat_conf" { - tuples "pcm_plat_tokens" -} +W_DATA(pcm_plat_conf, pcm_plat_tokens) # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) -SectionData."pipe_dai_schedule_plat" { - tuples "pipe_dai_schedule_plat_tokens" -} +W_DATA(pipe_dai_schedule_plat, pipe_dai_schedule_plat_tokens) diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 index b951d014e727..df6ea14db11a 100644 --- a/topology/m4/local.m4 +++ b/topology/m4/local.m4 @@ -642,6 +642,13 @@ define(`W_VENDORTUPLES', ` }' `}') +dnl W_DATA(name, tuples) +define(`W_DATA', +`SectionData.STR($1) {' +` tuples STR($2)' +`}') + + divert(0) dnl diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 2c59f7abd7ce..0196f985657d 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -28,9 +28,7 @@ C_CONTROLMIXER(PCM PCM_ID Playback Volume, PIPELINE_ID, W_VENDORTUPLES(media_src_tokens, sof_src_tokens, LIST(` ', `SOF_TKN_SRC_RATE_OUT "48000"')) -SectionData."media_src_conf" { - tuples "media_src_tokens" -} +W_DATA(media_src_conf, media_src_tokens) # # Components and Buffers diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index d09c5ac9c1d6..824dcdb14d88 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -22,9 +22,7 @@ W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) W_VENDORTUPLES(media_src_tokens, sof_src_tokens, LIST(` ', `SOF_TKN_SRC_RATE_OUT "48000"')) -SectionData."media_src_conf" { - tuples "media_src_tokens" -} +W_DATA(media_src_conf, media_src_tokens) # "SRC" has 4 source and 4 sink periods W_SRC(0, PIPELINE_FORMAT, 4, 4, media_src_conf, 2) diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index e93cd64a838b..3009ff7d7623 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -22,9 +22,7 @@ W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) W_VENDORTUPLES(media_src_tokens, sof_src_tokens, LIST(` ', `SOF_TKN_SRC_RATE_OUT "48000"')) -SectionData."media_src_conf" { - tuples "media_src_tokens" -} +W_DATA(media_src_conf, media_src_tokens) # "SRC" has 4 source and 4 sink periods W_SRC(0, PIPELINE_FORMAT, 4, 4, media_src_conf, 2) From c95433636f676e50116f8bdd7cb1db159511aba5 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 5 Mar 2018 14:17:12 -0800 Subject: [PATCH 117/324] topology: break up topology builder m4 files into per component macros This patch break up the local.m4 and build.m4 topology builder includes into per component m4 files Signed-off-by: Ranjani Sridharan --- topology/m4/buffer.m4 | 29 + topology/m4/dai.m4 | 214 +++++++ topology/m4/local.m4 | 654 ---------------------- topology/m4/mixer.m4 | 43 ++ topology/m4/mixercontrol.m4 | 49 ++ topology/m4/pcm.m4 | 161 ++++++ topology/m4/pga.m4 | 44 ++ topology/m4/{build.m4 => pipeline.m4} | 60 +- topology/m4/src.m4 | 41 ++ topology/m4/tone.m4 | 43 ++ topology/m4/utils.m4 | 65 +++ topology/reef-apl-nocodec.m4 | 5 +- topology/reef-bdw-rt286.m4 | 5 +- topology/reef-bdw-rt5640.m4 | 5 +- topology/reef-bxt-nocodec.m4 | 5 +- topology/reef-byt-da7212.m4 | 5 +- topology/reef-byt-nocodec.m4 | 5 +- topology/reef-byt-rt5640.m4 | 5 +- topology/reef-byt-rt5645.m4 | 5 +- topology/reef-byt-rt5651.m4 | 5 +- topology/reef-cht-max98090.m4 | 5 +- topology/reef-cht-nocodec.m4 | 5 +- topology/reef-cnl-rt274.m4 | 5 +- topology/reef-hsw-rt5640.m4 | 5 +- topology/sof/pipe-dai-capture.m4 | 4 +- topology/sof/pipe-dai-playback.m4 | 4 +- topology/sof/pipe-low-latency-capture.m4 | 6 +- topology/sof/pipe-low-latency-playback.m4 | 7 +- topology/sof/pipe-passthrough-capture.m4 | 7 +- topology/sof/pipe-passthrough-playback.m4 | 7 +- topology/sof/pipe-pcm-media.m4 | 7 +- topology/sof/pipe-src-capture.m4 | 8 +- topology/sof/pipe-src-playback.m4 | 8 +- topology/sof/pipe-tone.m4 | 7 +- topology/sof/pipe-volume-capture.m4 | 8 +- topology/sof/pipe-volume-playback.m4 | 8 +- topology/test/test-capture-ssp.m4 | 5 +- topology/test/test-playback-ssp.m4 | 5 +- topology/test/test-ssp.m4 | 5 +- topology/test/test-tone-playback-ssp.m4 | 5 +- 40 files changed, 836 insertions(+), 733 deletions(-) create mode 100644 topology/m4/buffer.m4 create mode 100644 topology/m4/dai.m4 delete mode 100644 topology/m4/local.m4 create mode 100644 topology/m4/mixer.m4 create mode 100644 topology/m4/mixercontrol.m4 create mode 100644 topology/m4/pcm.m4 create mode 100644 topology/m4/pga.m4 rename topology/m4/{build.m4 => pipeline.m4} (76%) create mode 100644 topology/m4/src.m4 create mode 100644 topology/m4/tone.m4 create mode 100644 topology/m4/utils.m4 diff --git a/topology/m4/buffer.m4 b/topology/m4/buffer.m4 new file mode 100644 index 000000000000..fc06ba0cf7f3 --- /dev/null +++ b/topology/m4/buffer.m4 @@ -0,0 +1,29 @@ +divert(-1) + +dnl Define the macro for buffer widget + +dnl Buffer name) +define(`N_BUFFER', `BUF'PIPELINE_ID`.'$1) + +dnl W_BUFFER(name, size, capabilities) +define(`W_BUFFER', +`SectionVendorTuples."'N_BUFFER($1)`_tuples" {' +` tokens "sof_buffer_tokens"' +` tuples."word" {' +` SOF_TKN_BUF_SIZE' STR($2) +` SOF_TKN_BUF_CAPS' STR($3) +` }' +`}' +`SectionData."'N_BUFFER($1)`_data" {' +` tuples "'N_BUFFER($1)`_tuples"' +`}' +`SectionWidget."'N_BUFFER($1)`" {' +` index "'PIPELINE_ID`"' +` type "buffer"' +` no_pm "true"' +` data [' +` "'N_BUFFER($1)`_data"' +` ]' +`}') + +divert(0)dnl diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 new file mode 100644 index 000000000000..163dfab31e96 --- /dev/null +++ b/topology/m4/dai.m4 @@ -0,0 +1,214 @@ +divert(-1) + +dnl Define macros for DAI IN/OUT widgets and DAI config + +dnl DAI name) +define(`N_DAI', DAI_NAME) +define(`N_DAI_OUT', DAI_NAME`.OUT') +define(`N_DAI_IN', DAI_NAME`.IN') + +dnl W_DAI_OUT(type, index, format, periods_sink, periods_source, preload, data) +define(`W_DAI_OUT', +`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` }' +`}' +`SectionData."'N_DAI_OUT($2)`_data_w_comp" {' +` tuples "'N_DAI_OUT($2)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_w" {' +` tokens "sof_dai_tokens"' +` tuples."word" {' +` SOF_TKN_DAI_INDEX' $2 +` }' +`}' +`SectionData."'N_DAI_OUT($2)`_data_w" {' +` tuples "'N_DAI_OUT($2)`_tuples_w"' +`}' +`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_str" {' +` tokens "sof_dai_tokens"' +` tuples."string" {' +` SOF_TKN_DAI_TYPE' $1 +` }' +`}' +`SectionData."'N_DAI_OUT($2)`_data_str" {' +` tuples "'N_DAI_OUT($2)`_tuples_str"' +`}' +`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_comp_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($3) +` }' +`}' +`SectionData."'N_DAI_OUT($2)`_data_comp_str" {' +` tuples "'N_DAI_OUT($2)`_tuples_comp_str"' +`}' +`SectionWidget."'N_DAI_OUT`" {' +` index "'PIPELINE_ID`"' +` type "dai_in"' +` no_pm "true"' +` data [' +` "'N_DAI_OUT($2)`_data_w"' +` "'N_DAI_OUT($2)`_data_w_comp"' +` "'N_DAI_OUT($2)`_data_str"' +` "'N_DAI_OUT($2)`_data_comp_str"' +` "'$7`"' +` ]' +`}') + +dnl W_DAI_IN(type, index, format, periods_sink, periods_source, preload, data) +define(`W_DAI_IN', +`SectionVendorTuples."'N_DAI_IN($2)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` }' +`}' +`SectionData."'N_DAI_IN($2)`_data_w_comp" {' +` tuples "'N_DAI_IN($2)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_DAI_IN($2)`_tuples_w" {' +` tokens "sof_dai_tokens"' +` tuples."word" {' +` SOF_TKN_DAI_INDEX' $2 +` }' +`}' +`SectionData."'N_DAI_IN($2)`_data_w" {' +` tuples "'N_DAI_IN($2)`_tuples_w"' +`}' +`SectionVendorTuples."'N_DAI_IN($2)`_tuples_str" {' +` tokens "sof_dai_tokens"' +` tuples."string" {' +` SOF_TKN_DAI_TYPE' $1 +` }' +`}' +`SectionData."'N_DAI_IN($2)`_data_str" {' +` tuples "'N_DAI_IN($2)`_tuples_str"' +`}' +`SectionVendorTuples."'N_DAI_IN($2)`_tuples_comp_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($3) +` }' +`}' +`SectionData."'N_DAI_IN($2)`_data_comp_str" {' +` tuples "'N_DAI_IN($2)`_tuples_comp_str"' +`}' +`SectionWidget."'N_DAI_IN`" {' +` index "'PIPELINE_ID`"' +` type "dai_out"' +` no_pm "true"' +` data [' +` "'N_DAI_IN($2)`_data_w"' +` "'N_DAI_IN($2)`_data_w_comp"' +` "'N_DAI_IN($2)`_data_str"' +` "'N_DAI_IN($2)`_data_comp_str"' +` "'$7`"' +` ]' +`}') + +dnl D_DAI(id, playback, capture, data)) +define(`D_DAI', `SectionDAI."'N_DAI`" {' +` index "'PIPELINE_ID`"' +` id "'$1`"' +` playback "'$2`"' +` capture "'$3`"' +`}') + +dnl DAI_CLOCK(clock, freq, codec_master) +define(`DAI_CLOCK', + $1 STR($3) + $1_freq STR($2)) + + +dnl DAI_TDM(slots, width, tx_mask, rx_mask) +define(`DAI_TDM', +` tdm_slots 'STR($1) +` tdm_slot_width 'STR($2) +` tx_slots 'STR($3) +` rx_slots 'STR($4) +) + +dnl DAI Config) +define(`N_DAI_CONFIG', `DAICONFIG.'$1) + +dnl DAI_CONFIG(type, idx, name, format, valid bits, mclk, bclk, fsync, tdm) +define(`DAI_CONFIG', +`SectionHWConfig."'$1$2`" {' +`' +` id "'$2`"' +` format "'$4`"' +`' +` '$6 +` '$7 +` '$8 +` '$9 +`}' +`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples_str" {' +` tokens "sof_dai_tokens"' +` tuples."string" {' +` SOF_TKN_DAI_TYPE' STR($1) +` }' +`}' +`SectionData."'N_DAI_CONFIG($1$2)`_data_str" {' +` tuples "'N_DAI_CONFIG($1$2)`_tuples_str"' +`}' +`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {' +` tokens "sof_dai_tokens"' +` tuples."word" {' +` SOF_TKN_DAI_SAMPLE_BITS' STR($5) +` }' +`}' +`SectionData."'N_DAI_CONFIG($1$2)`_data" {' +` tuples "'N_DAI_CONFIG($1$2)`_tuples"' +`}' +`' +`SectionBE."'$3`" {' +` index "0"' +` default_hw_conf_id "'$2`"' +`' +` hw_configs [' +` "'$1$2`"' +` ]' +` data [' +` "'N_DAI_CONFIG($1$2)`_data"' +` "'N_DAI_CONFIG($1$2)`_data_str"' +` ]' +`}') + +dnl DAI_ADD(pipeline, +dnl pipe id, dai type, dai_index, +dnl buffer, periods, format, +dnl frames, deadline, priority, core) +define(`DAI_ADD', +`undefine(`PIPELINE_ID')' +`undefine(`DAI_TYPE')' +`undefine(`DAI_INDEX')' +`undefine(`DAI_BUF')' +`undefine(`DAI_PERIODS')' +`undefine(`DAI_FORMAT')' +`undefine(`SCHEDULE_FRAMES')' +`undefine(`SCHEDULE_DEADLINE')' +`undefine(`SCHEDULE_PRIORITY')' +`undefine(`SCHEDULE_CORE')' +`define(`PIPELINE_ID', $2)' +`define(`DAI_TYPE', STR($3))' +`define(`DAI_INDEX', STR($4))' +`define(`DAI_BUF', $5)' +`define(`DAI_NAME', $3$4)' +`define(`DAI_PERIODS', $6)' +`define(`DAI_FORMAT', $7)' +`define(`SCHEDULE_FRAMES', $8)' +`define(`SCHEDULE_DEADLINE', $9)' +`define(`SCHEDULE_PRIORITY', $10)' +`define(`SCHEDULE_CORE', $11)' +`include($1)' +) + +divert(0)dnl diff --git a/topology/m4/local.m4 b/topology/m4/local.m4 deleted file mode 100644 index df6ea14db11a..000000000000 --- a/topology/m4/local.m4 +++ /dev/null @@ -1,654 +0,0 @@ -divert(-1) - -define(`concat',`$1$2') - -define(`STR', `"'$1`"') - -dnl Argument iterator. -define(`argn', `ifelse(`$1', 1, ``$2'', - `argn(decr(`$1'), shift(shift($@)))')') - -dnl Defines a list of items from a variable number of params. -dnl Use as last argument in a macro. -dnl The first argument specifies the number of tabs to be added for formatting -define(`LIST_LOOP', `argn(j,$@) -$1ifelse(i,`2', `', `define(`i', decr(i))define(`j', incr(j))$0($@)')') - -define(`LIST', `pushdef(`i', $#)pushdef(`j', `2')LIST_LOOP($@)popdef(i)popdef(j)') - -dnl Sums a list of variable arguments. Use as last argument in macro. -define(`SUM_LOOP', `eval(argn(j,$@) - ifelse(i,`1', `', `define(`i', decr(i)) define(`j', incr(j)) + $0($@)'))') - -dnl Memory capabilities -define(`MEMCAPS', `pushdef(`i', $#) pushdef(`j', `1') SUM_LOOP($@)') - -dnl create direct DAPM/pipeline link between 2 widgets) -define(`dapm', `"$1, , $2"') - -dnl SRC name) -define(`N_SRC', `SRC'PIPELINE_ID`.'$1) - -dnl W_SRC(name, format, periods_sink, periods_source, data, preload) -define(`W_SRC', -`SectionVendorTuples."'N_SRC($1)`_tuples_w" {' -` tokens "sof_comp_tokens"' -` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) -` }' -`}' -`SectionData."'N_SRC($1)`_data_w" {' -` tuples "'N_SRC($1)`_tuples_w"' -`}' -`SectionVendorTuples."'N_SRC($1)`_tuples_str" {' -` tokens "sof_comp_tokens"' -` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($2) -` }' -`}' -`SectionData."'N_SRC($1)`_data_str" {' -` tuples "'N_SRC($1)`_tuples_str"' -`}' -`SectionWidget."'N_SRC($1)`" {' -` index "'PIPELINE_ID`"' -` type "src"' -` no_pm "true"' -` data [' -` "'N_SRC($1)`_data_w"' -` "'N_SRC($1)`_data_str"' -` "'$5`"' -` ]' -`}') - -dnl Buffer name) -define(`N_BUFFER', `BUF'PIPELINE_ID`.'$1) - -dnl W_BUFFER(name, size, capabilities) -define(`W_BUFFER', -`SectionVendorTuples."'N_BUFFER($1)`_tuples" {' -` tokens "sof_buffer_tokens"' -` tuples."word" {' -` SOF_TKN_BUF_SIZE' STR($2) -` SOF_TKN_BUF_CAPS' STR($3) -` }' -`}' -`SectionData."'N_BUFFER($1)`_data" {' -` tuples "'N_BUFFER($1)`_tuples"' -`}' -`SectionWidget."'N_BUFFER($1)`" {' -` index "'PIPELINE_ID`"' -` type "buffer"' -` no_pm "true"' -` data [' -` "'N_BUFFER($1)`_data"' -` ]' -`}') - -dnl PCM name) -define(`N_PCMP', `PCM'PCM_ID`P') -define(`N_PCMC', `PCM'PCM_ID`C') - -dnl W_PCM_PLAYBACK(stream, dmac, dmac_chan, periods_sink, periods_source, preload) -dnl PCM platform configuration -define(`W_PCM_PLAYBACK', -`SectionVendorTuples."'N_PCMP($1)`_tuples_w_comp" {' -` tokens "sof_comp_tokens"' -` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) -` }' -`}' -`SectionData."'N_PCMP($1)`_data_w_comp" {' -` tuples "'N_PCMP($1)`_tuples_w_comp"' -`}' -`SectionVendorTuples."'N_PCMP($1)`_tuples" {' -` tokens "sof_pcm_tokens"' -` tuples."word" {' -` SOF_TKN_PCM_DMAC' STR($2) -` SOF_TKN_PCM_DMAC_CHAN' STR($3) -` }' -`}' -`SectionData."'N_PCMP($1)`_data" {' -` tuples "'N_PCMP($1)`_tuples"' -`}' -`SectionWidget."'N_PCMP`" {' -` index "'PIPELINE_ID`"' -` type "aif_in"' -` no_pm "true"' -` stream_name "'$1`"' -` data [' -` "'N_PCMP($1)`_data"' -` "'N_PCMP($1)`_data_w_comp"' -` ]' -`}') - - -dnl W_PCM_PLAYBACK(stream, dmac, dmac_chan, periods_sink, periods_source, preload) -define(`W_PCM_CAPTURE', -`SectionVendorTuples."'N_PCMC($1)`_tuples_w_comp" {' -` tokens "sof_comp_tokens"' -` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) -` }' -`}' -`SectionData."'N_PCMC($1)`_data_w_comp" {' -` tuples "'N_PCMC($1)`_tuples_w_comp"' -`}' -`SectionVendorTuples."'N_PCMC($1)`_tuples" {' -` tokens "sof_pcm_tokens"' -` tuples."word" {' -` SOF_TKN_PCM_DMAC' STR($2) -` SOF_TKN_PCM_DMAC_CHAN' STR($3) -` }' -`}' -`SectionData."'N_PCMC($1)`_data" {' -` tuples "'N_PCMC($1)`_tuples"' -`}' -`SectionWidget."'N_PCMC`" {' -` index "'PIPELINE_ID`"' -` type "aif_out"' -` no_pm "true"' -` stream_name "'$1`"' -` data [' -` "'N_PCMC($1)`_data"' -` "'N_PCMC($1)`_data_w_comp"' -` ]' -`}') - -dnl PGA name) -define(`N_PGA', `PGA'PIPELINE_ID`.'$1) - -dnl W_PGA(name, format, periods_sink, periods_source, preload, kcontrol0. kcontrol1...etc) -define(`W_PGA', -`SectionVendorTuples."'N_PGA($1)`_tuples_w" {' -` tokens "sof_comp_tokens"' -` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) -` }' -`}' -`SectionData."'N_PGA($1)`_data_w" {' -` tuples "'N_PGA($1)`_tuples_w"' -`}' -`SectionVendorTuples."'N_PGA($1)`_tuples_str" {' -` tokens "sof_comp_tokens"' -` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($2) -` }' -`}' -`SectionData."'N_PGA($1)`_data_str" {' -` tuples "'N_PGA($1)`_tuples_str"' -`}' -`SectionWidget."'N_PGA($1)`" {' -` index "'PIPELINE_ID`"' -` type "pga"' -` no_pm "true"' -` data [' -` "'N_PGA($1)`_data_w"' -` "'N_PGA($1)`_data_str"' -` ]' -` mixer [' - $6 -` ]' -`}') - -dnl Mixer Name) -define(`N_MIXER', `MIXER'PIPELINE_ID`.'$1) - -dnl Pipe Buffer name in pipeline (pipeline, buffer) -define(`NPIPELINE_MIXER', `MIXER'$1`.'$2) - -dnl W_MIXER(name, format, periods_sink, periods_source, preload) -define(`W_MIXER', -`SectionVendorTuples."'N_MIXER($1)`_tuples_w" {' -` tokens "sof_comp_tokens"' -` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) -` }' -`}' -`SectionData."'N_MIXER($1)`_data_w" {' -` tuples "'N_MIXER($1)`_tuples_w"' -`}' -`SectionVendorTuples."'N_MIXER($1)`_tuples_str" {' -` tokens "sof_comp_tokens"' -` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($2) -` }' -`}' -`SectionData."'N_MIXER($1)`_data_str" {' -` tuples "'N_MIXER($1)`_tuples_str"' -`}' -`SectionWidget."'N_MIXER($1)`" {' -` index "'PIPELINE_ID`"' -` type "mixer"' -` no_pm "true"' -` data [' -` "'N_MIXER($1)`_data_w"' -` "'N_MIXER($1)`_data_str"' -` ]' -`}') - - -dnl Tone name) -define(`N_TONE', `TONE'PIPELINE_ID`.'$1) - -dnl W_TONE(name, format, periods_sink, periods_source, preload, kcontrols_list) -define(`W_TONE', -`SectionVendorTuples."'N_TONE($1)`_tuples_w" {' -` tokens "sof_comp_tokens"' -` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) -` }' -`}' -`SectionData."'N_TONE($1)`_data_w" {' -` tuples "'N_TONE($1)`_tuples_w"' -`}' -`SectionVendorTuples."'N_TONE($1)`_tuples_str" {' -` tokens "sof_comp_tokens"' -` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($2) -` }' -`}' -`SectionData."'N_TONE($1)`_data_str" {' -` tuples "'N_TONE($1)`_tuples_str"' -`}' -`SectionWidget."'N_TONE($1)`" {' -` index "'PIPELINE_ID`"' -` type "siggen"' -` no_pm "true"' -` data [' -` "'N_TONE($1)`_data_w"' -` "'N_TONE($1)`_data_str"' -` ]' -` mixer [' - $6 -` ]' -`}') - -dnl DAI name) -define(`N_DAI', DAI_NAME) -define(`N_DAI_OUT', DAI_NAME`.OUT') -define(`N_DAI_IN', DAI_NAME`.IN') - -dnl W_DAI_OUT(type, index, format, periods_sink, periods_source, preload, data) -define(`W_DAI_OUT', -`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_w_comp" {' -` tokens "sof_comp_tokens"' -` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) -` }' -`}' -`SectionData."'N_DAI_OUT($2)`_data_w_comp" {' -` tuples "'N_DAI_OUT($2)`_tuples_w_comp"' -`}' -`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_w" {' -` tokens "sof_dai_tokens"' -` tuples."word" {' -` SOF_TKN_DAI_INDEX' $2 -` }' -`}' -`SectionData."'N_DAI_OUT($2)`_data_w" {' -` tuples "'N_DAI_OUT($2)`_tuples_w"' -`}' -`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_str" {' -` tokens "sof_dai_tokens"' -` tuples."string" {' -` SOF_TKN_DAI_TYPE' $1 -` }' -`}' -`SectionData."'N_DAI_OUT($2)`_data_str" {' -` tuples "'N_DAI_OUT($2)`_tuples_str"' -`}' -`SectionVendorTuples."'N_DAI_OUT($2)`_tuples_comp_str" {' -` tokens "sof_comp_tokens"' -` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($3) -` }' -`}' -`SectionData."'N_DAI_OUT($2)`_data_comp_str" {' -` tuples "'N_DAI_OUT($2)`_tuples_comp_str"' -`}' -`SectionWidget."'N_DAI_OUT`" {' -` index "'PIPELINE_ID`"' -` type "dai_in"' -` no_pm "true"' -` data [' -` "'N_DAI_OUT($2)`_data_w"' -` "'N_DAI_OUT($2)`_data_w_comp"' -` "'N_DAI_OUT($2)`_data_str"' -` "'N_DAI_OUT($2)`_data_comp_str"' -` "'$7`"' -` ]' -`}') - -dnl W_DAI_IN(type, index, format, periods_sink, periods_source, preload, data) -define(`W_DAI_IN', -`SectionVendorTuples."'N_DAI_IN($2)`_tuples_w_comp" {' -` tokens "sof_comp_tokens"' -` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) -` }' -`}' -`SectionData."'N_DAI_IN($2)`_data_w_comp" {' -` tuples "'N_DAI_IN($2)`_tuples_w_comp"' -`}' -`SectionVendorTuples."'N_DAI_IN($2)`_tuples_w" {' -` tokens "sof_dai_tokens"' -` tuples."word" {' -` SOF_TKN_DAI_INDEX' $2 -` }' -`}' -`SectionData."'N_DAI_IN($2)`_data_w" {' -` tuples "'N_DAI_IN($2)`_tuples_w"' -`}' -`SectionVendorTuples."'N_DAI_IN($2)`_tuples_str" {' -` tokens "sof_dai_tokens"' -` tuples."string" {' -` SOF_TKN_DAI_TYPE' $1 -` }' -`}' -`SectionData."'N_DAI_IN($2)`_data_str" {' -` tuples "'N_DAI_IN($2)`_tuples_str"' -`}' -`SectionVendorTuples."'N_DAI_IN($2)`_tuples_comp_str" {' -` tokens "sof_comp_tokens"' -` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($3) -` }' -`}' -`SectionData."'N_DAI_IN($2)`_data_comp_str" {' -` tuples "'N_DAI_IN($2)`_tuples_comp_str"' -`}' -`SectionWidget."'N_DAI_IN`" {' -` index "'PIPELINE_ID`"' -` type "dai_out"' -` no_pm "true"' -` data [' -` "'N_DAI_IN($2)`_data_w"' -` "'N_DAI_IN($2)`_data_w_comp"' -` "'N_DAI_IN($2)`_data_str"' -` "'N_DAI_IN($2)`_data_comp_str"' -` "'$7`"' -` ]' -`}') - -dnl Pipe Buffer name in pipeline (pipeline, buffer) -define(`NPIPELINE_BUFFER', `BUF'$1`.'$2) - -dnl Pipeline name) -define(`N_PIPELINE', `PIPELINE.'PIPELINE_ID`.'$1) - -dnl W_PIPELINE(stream, deadline, priority, frames, core, timer, platform) -define(`W_PIPELINE', -`SectionVendorTuples."'N_PIPELINE($1)`_tuples" {' -` tokens "sof_sched_tokens"' -` tuples."word" {' -` SOF_TKN_SCHED_DEADLINE' STR($2) -` SOF_TKN_SCHED_PRIORITY' STR($3) -` SOF_TKN_SCHED_CORE' STR($5) -` SOF_TKN_SCHED_FRAMES' STR($4) -` SOF_TKN_SCHED_TIMER' STR($6) -` }' -`}' -`SectionData."'N_PIPELINE($1)`_data" {' -` tuples "'N_PIPELINE($1)`_tuples"' -`}' -`SectionWidget."'N_PIPELINE($1)`" {' -` index "'PIPELINE_ID`"' -` type "scheduler"' -` no_pm "true"' -` stream_name "'$1`"' -` data [' -` "'N_PIPELINE($1)`_data"' -` "'$7`"' -` ]' -`}') - -dnl D_DAI(id, playback, capture, data)) -define(`D_DAI', `SectionDAI."'N_DAI`" {' -` index "'PIPELINE_ID`"' -` id "'$1`"' -` playback "'$2`"' -` capture "'$3`"' -`}') - -dnl DAI_CLOCK(clock, freq, codec_master) -define(`DAI_CLOCK', - $1 STR($3) - $1_freq STR($2)) - - -dnl DAI_TDM(slots, width, tx_mask, rx_mask) -define(`DAI_TDM', -` tdm_slots 'STR($1) -` tdm_slot_width 'STR($2) -` tx_slots 'STR($3) -` rx_slots 'STR($4) -) - -dnl Pipeline name) -define(`N_DAI_CONFIG', `DAICONFIG.'$1) - -dnl DAI_CONFIG(type, idx, name, format, valid bits, mclk, bclk, fsync, tdm) -define(`DAI_CONFIG', -`SectionHWConfig."'$1$2`" {' -`' -` id "'$2`"' -` format "'$4`"' -`' -` '$6 -` '$7 -` '$8 -` '$9 -`}' -`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples_str" {' -` tokens "sof_dai_tokens"' -` tuples."string" {' -` SOF_TKN_DAI_TYPE' STR($1) -` }' -`}' -`SectionData."'N_DAI_CONFIG($1$2)`_data_str" {' -` tuples "'N_DAI_CONFIG($1$2)`_tuples_str"' -`}' -`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {' -` tokens "sof_dai_tokens"' -` tuples."word" {' -` SOF_TKN_DAI_SAMPLE_BITS' STR($5) -` }' -`}' -`SectionData."'N_DAI_CONFIG($1$2)`_data" {' -` tuples "'N_DAI_CONFIG($1$2)`_tuples"' -`}' -`' -`SectionBE."'$3`" {' -` index "0"' -` default_hw_conf_id "'$2`"' -`' -` hw_configs [' -` "'$1$2`"' -` ]' -` data [' -` "'N_DAI_CONFIG($1$2)`_data"' -` "'N_DAI_CONFIG($1$2)`_data_str"' -` ]' -`}') - -dnl COMP_SAMPLE_SIZE(FMT) -define(`COMP_SAMPLE_SIZE', -`ifelse( - $1, `s16le', `2', - $1, `s24_4le', `4', - $1, `s32le', `4', - $1, `float', `4', - `4')') - - -dnl COMP_BUFFER_SIZE( num_periods, sample_size, channels, fmames) -define(`COMP_BUFFER_SIZE', `eval(`$1 * $2 * $3 * $4')') - -dnl PCM_PLAYBACK_ADD(name, pipeline, pcm_id, dai_id, playback) -define(`PCM_PLAYBACK_ADD', -`SectionPCM.STR($1) {' -`' -` index STR($2)' -`' -` # used for binding to the PCM' -` id STR($3)' -`' -` dai.STR($1 $3) {' -` id STR($4)' -` }' -`' -` pcm."playback" {' -`' -` capabilities STR($5)' -` }' -`}') - -dnl PCM_CAPTURE_ADD(name, pipeline, pcm_id, dai_id, capture) -define(`PCM_CAPTURE_ADD', -`SectionPCM.STR($1) {' -`' -` index STR($2)' -`' -` # used for binding to the PCM' -` id STR($3)' -`' -` dai.STR($1 $3) {' -` id STR($4)' -` }' -`' -` pcm."capture" {' -`' -` capabilities STR($5)' -` }' -`}') - -dnl PCM_DUPLEX_ADD(name, pipeline, pcm_id, dai_id, playback, capture) -define(`PCM_DUPLEX_ADD', -`SectionPCM.STR($1) {' -`' -` index STR($2)' -`' -` # used for binding to the PCM' -` id STR($3)' -`' -` dai.STR($1 $3) {' -` id STR($4)' -` }' -`' -` pcm."capture" {' -`' -` capabilities STR($6)' -` }' -`' -` pcm."playback" {' -`' -` capabilities STR($5)' -` }' -`}') - -dnl KCONTROL_CHANNEL(name, reg, shift) -define(`KCONTROL_CHANNEL', -`channel.STR($1) {' -` reg STR($2)' -` shift STR($3)' -` }') - -dnl CONTROLMIXER_MAX(comment, value) -define(`CONTROLMIXER_MAX', -`#$1' -` max STR($2)') - -dnl CONTROLMIXER_TLV(comment, value) -define(`CONTROLMIXER_TLV', -`#$1' -` tlv STR($2)') - -dnl CONTROLMIXER_OPS(info, comment, get, put) -define(`CONTROLMIXER_OPS', -`ops."ctl" {' -` info STR($1)' -` #$2' -` get STR($3)' -` put STR($4)' -` }') - -dnl C_CONTROLMIXER(name, index, ops, max, invert, tlv, KCONTROL_CHANNELS) -define(`C_CONTROLMIXER', -`SectionControlMixer.STR($1) {' -`' -` # control belongs to this index group' -` index STR($2)' -`' -` #$7' -` $8' -` # control uses bespoke driver get/put/info ID' -` $3' -`' -` $4' -` invert STR($5)' -` $6' -`}') - -dnl P_GRAPH(name, CONNECTIONS) -define(`P_GRAPH', -`SectionGraph.STR($1) {' -` index STR($2)' -`' -` lines [' -` $3' -` ]' -`}') - -dnl PCM_CAPABILITIES(name, formats, rate_min, rate_max, channels_min, channels_max, periods_min, periods_max, period_size_min, period_size_max, buffer_size_min, buffer_size_max) -define(`PCM_CAPABILITIES', -`SectionPCMCapabilities.STR($1) {' -`' -` formats "$2"' -` rate_min STR($3)' -` rate_max STR($4)' -` channels_min STR($5)' -` channels_max STR($6)' -` periods_min STR($7)' -` periods_max STR($8)' -` period_size_min STR($9)' -` period_size_max STR($10)' -` buffer_size_min STR($11)' -` buffer_size_max STR($12)' -`}') - -dnl W_VENDORTUPLES(name, tokens, RATE_OUT) -define(`W_VENDORTUPLES', -`SectionVendorTuples.STR($1) {' -` tokens STR($2)' -`' -` tuples."word" {' -` $3' -` }' -`}') - -dnl W_DATA(name, tuples) -define(`W_DATA', -`SectionData.STR($1) {' -` tuples STR($2)' -`}') - - -divert(0) dnl - - diff --git a/topology/m4/mixer.m4 b/topology/m4/mixer.m4 new file mode 100644 index 000000000000..1f2376ea3622 --- /dev/null +++ b/topology/m4/mixer.m4 @@ -0,0 +1,43 @@ +divert(-1) + +dnl Define macro for Mixer widget + +dnl Mixer Name) +define(`N_MIXER', `MIXER'PIPELINE_ID`.'$1) + +dnl Pipe Buffer name in pipeline (pipeline, buffer) +define(`NPIPELINE_MIXER', `MIXER'$1`.'$2) + +dnl W_MIXER(name, format, periods_sink, periods_source, preload) +define(`W_MIXER', +`SectionVendorTuples."'N_MIXER($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_MIXER($1)`_data_w" {' +` tuples "'N_MIXER($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_MIXER($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_MIXER($1)`_data_str" {' +` tuples "'N_MIXER($1)`_tuples_str"' +`}' +`SectionWidget."'N_MIXER($1)`" {' +` index "'PIPELINE_ID`"' +` type "mixer"' +` no_pm "true"' +` data [' +` "'N_MIXER($1)`_data_w"' +` "'N_MIXER($1)`_data_str"' +` ]' +`}') + +divert(0)dnl diff --git a/topology/m4/mixercontrol.m4 b/topology/m4/mixercontrol.m4 new file mode 100644 index 000000000000..77a378446c42 --- /dev/null +++ b/topology/m4/mixercontrol.m4 @@ -0,0 +1,49 @@ +divert(-1) + +dnl Define macro for mixer control + +dnl KCONTROL_CHANNEL(name, reg, shift) +define(`KCONTROL_CHANNEL', +`channel.STR($1) {' +` reg STR($2)' +` shift STR($3)' +` }') + +dnl CONTROLMIXER_MAX(comment, value) +define(`CONTROLMIXER_MAX', +`#$1' +` max STR($2)') + +dnl CONTROLMIXER_TLV(comment, value) +define(`CONTROLMIXER_TLV', +`#$1' +` tlv STR($2)') + +dnl CONTROLMIXER_OPS(info, comment, get, put) +define(`CONTROLMIXER_OPS', +`ops."ctl" {' +` info STR($1)' +` #$2' +` get STR($3)' +` put STR($4)' +` }') + +dnl C_CONTROLMIXER(name, index, ops, max, invert, tlv, KCONTROL_CHANNELS) +define(`C_CONTROLMIXER', +`SectionControlMixer.STR($1) {' +`' +` # control belongs to this index group' +` index STR($2)' +`' +` #$7' +` $8' +` # control uses bespoke driver get/put/info ID' +` $3' +`' +` $4' +` invert STR($5)' +` $6' + +`}') + +divert(0)dnl diff --git a/topology/m4/pcm.m4 b/topology/m4/pcm.m4 new file mode 100644 index 000000000000..d767350de2bb --- /dev/null +++ b/topology/m4/pcm.m4 @@ -0,0 +1,161 @@ +divert(-1) + +dnl Define the macro for PCM playback/capture/capabilities + +dnl PCM name) +define(`N_PCMP', `PCM'PCM_ID`P') +define(`N_PCMC', `PCM'PCM_ID`C') + +dnl W_PCM_PLAYBACK(stream, dmac, dmac_chan, periods_sink, periods_source, preload) +dnl PCM platform configuration +define(`W_PCM_PLAYBACK', +`SectionVendorTuples."'N_PCMP($1)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` }' +`}' +`SectionData."'N_PCMP($1)`_data_w_comp" {' +` tuples "'N_PCMP($1)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_PCMP($1)`_tuples" {' +` tokens "sof_pcm_tokens"' +` tuples."word" {' +` SOF_TKN_PCM_DMAC' STR($2) +` SOF_TKN_PCM_DMAC_CHAN' STR($3) +` }' +`}' +`SectionData."'N_PCMP($1)`_data" {' +` tuples "'N_PCMP($1)`_tuples"' +`}' +`SectionWidget."'N_PCMP`" {' +` index "'PIPELINE_ID`"' +` type "aif_in"' +` no_pm "true"' +` stream_name "'$1`"' +` data [' +` "'N_PCMP($1)`_data"' +` "'N_PCMP($1)`_data_w_comp"' +` ]' +`}') + + +dnl W_PCM_CAPTURE(stream, dmac, dmac_chan, periods_sink, periods_source, preload) +define(`W_PCM_CAPTURE', +`SectionVendorTuples."'N_PCMC($1)`_tuples_w_comp" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` }' +`}' +`SectionData."'N_PCMC($1)`_data_w_comp" {' +` tuples "'N_PCMC($1)`_tuples_w_comp"' +`}' +`SectionVendorTuples."'N_PCMC($1)`_tuples" {' +` tokens "sof_pcm_tokens"' +` tuples."word" {' +` SOF_TKN_PCM_DMAC' STR($2) +` SOF_TKN_PCM_DMAC_CHAN' STR($3) +` }' +`}' +`SectionData."'N_PCMC($1)`_data" {' +` tuples "'N_PCMC($1)`_tuples"' +`}' +`SectionWidget."'N_PCMC`" {' +` index "'PIPELINE_ID`"' +` type "aif_out"' +` no_pm "true"' +` stream_name "'$1`"' +` data [' +` "'N_PCMC($1)`_data"' +` "'N_PCMC($1)`_data_w_comp"' +` ]' +`}') + +dnl PCM_CAPABILITIES(name, formats, rate_min, rate_max, channels_min, channels_max, periods_min, periods_max, period_size_min, period_size_max, buffer_size_min, buffer_size_max) +define(`PCM_CAPABILITIES', +`SectionPCMCapabilities.STR($1) {' +`' +` formats "$2"' +` rate_min STR($3)' +` rate_max STR($4)' +` channels_min STR($5)' +` channels_max STR($6)' +` periods_min STR($7)' +` periods_max STR($8)' +` period_size_min STR($9)' +` period_size_max STR($10)' +` buffer_size_min STR($11)' +` buffer_size_max STR($12)' +`}') + +dnl COMP_BUFFER_SIZE( num_periods, sample_size, channels, fmames) +define(`COMP_BUFFER_SIZE', `eval(`$1 * $2 * $3 * $4')') + +dnl PCM_PLAYBACK_ADD(name, pipeline, pcm_id, dai_id, playback) +define(`PCM_PLAYBACK_ADD', +`SectionPCM.STR($1) {' +`' +` index STR($2)' +`' +` # used for binding to the PCM' +` id STR($3)' +`' +` dai.STR($1 $3) {' +` id STR($4)' +` }' +`' +` pcm."playback" {' +`' +` capabilities STR($5)' +` }' +`}') + +dnl PCM_CAPTURE_ADD(name, pipeline, pcm_id, dai_id, capture) +define(`PCM_CAPTURE_ADD', +`SectionPCM.STR($1) {' +`' +` index STR($2)' +`' +` # used for binding to the PCM' +` id STR($3)' +`' +` dai.STR($1 $3) {' +` id STR($4)' +` }' +`' +` pcm."capture" {' +`' +` capabilities STR($5)' +` }' +`}') + +dnl PCM_DUPLEX_ADD(name, pipeline, pcm_id, dai_id, playback, capture) +define(`PCM_DUPLEX_ADD', +`SectionPCM.STR($1) {' +`' +` index STR($2)' +`' +` # used for binding to the PCM' +` id STR($3)' +`' +` dai.STR($1 $3) {' +` id STR($4)' +` }' +`' +` pcm."capture" {' +`' +` capabilities STR($6)' +` }' +`' +` pcm."playback" {' +`' +` capabilities STR($5)' +` }' +`}') + +divert(0)dnl diff --git a/topology/m4/pga.m4 b/topology/m4/pga.m4 new file mode 100644 index 000000000000..f38f820295a5 --- /dev/null +++ b/topology/m4/pga.m4 @@ -0,0 +1,44 @@ +divert(-1) + +dnl Define macro for PGA widget + +dnl PGA name) +define(`N_PGA', `PGA'PIPELINE_ID`.'$1) + +dnl W_PGA(name, format, periods_sink, periods_source, preload, kcontrol0. kcontrol1...etc) +define(`W_PGA', +`SectionVendorTuples."'N_PGA($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_PGA($1)`_data_w" {' +` tuples "'N_PGA($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_PGA($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_PGA($1)`_data_str" {' +` tuples "'N_PGA($1)`_tuples_str"' +`}' +`SectionWidget."'N_PGA($1)`" {' +` index "'PIPELINE_ID`"' +` type "pga"' +` no_pm "true"' +` data [' +` "'N_PGA($1)`_data_w"' +` "'N_PGA($1)`_data_str"' +` ]' +` mixer [' + $6 +` ]' + +`}') + +divert(0)dnl diff --git a/topology/m4/build.m4 b/topology/m4/pipeline.m4 similarity index 76% rename from topology/m4/build.m4 rename to topology/m4/pipeline.m4 index 93612191d59c..7a9143901478 100644 --- a/topology/m4/build.m4 +++ b/topology/m4/pipeline.m4 @@ -1,5 +1,36 @@ divert(-1) +dnl Define macro for pipeline widget + +dnl Pipeline name) +define(`N_PIPELINE', `PIPELINE.'PIPELINE_ID`.'$1) + +dnl W_PIPELINE(stream, deadline, priority, frames, core, timer, platform) +define(`W_PIPELINE', +`SectionVendorTuples."'N_PIPELINE($1)`_tuples" {' +` tokens "sof_sched_tokens"' +` tuples."word" {' +` SOF_TKN_SCHED_DEADLINE' STR($2) +` SOF_TKN_SCHED_PRIORITY' STR($3) +` SOF_TKN_SCHED_CORE' STR($5) +` SOF_TKN_SCHED_FRAMES' STR($4) +` SOF_TKN_SCHED_TIMER' STR($6) +` }' +`}' +`SectionData."'N_PIPELINE($1)`_data" {' +` tuples "'N_PIPELINE($1)`_tuples"' +`}' +`SectionWidget."'N_PIPELINE($1)`" {' +` index "'PIPELINE_ID`"' +` type "scheduler"' +` no_pm "true"' +` stream_name "'$1`"' +` data [' +` "'N_PIPELINE($1)`_data"' +` "'$7`"' +` ]' +`}') + dnl PIPELINE_PCM_ADD(pipeline, dnl pipe id, pcm, max channels, format, dnl frames, deadline, priority, core, dmac, dmac_chan) @@ -85,33 +116,4 @@ define(`PIPELINE_ADD', `include($1)' ) -dnl DAI_ADD(pipeline, -dnl pipe id, dai type, dai_index, -dnl buffer, periods, format, -dnl frames, deadline, priority, core) -define(`DAI_ADD', -`undefine(`PIPELINE_ID')' -`undefine(`DAI_TYPE')' -`undefine(`DAI_INDEX')' -`undefine(`DAI_BUF')' -`undefine(`DAI_PERIODS')' -`undefine(`DAI_FORMAT')' -`undefine(`SCHEDULE_FRAMES')' -`undefine(`SCHEDULE_DEADLINE')' -`undefine(`SCHEDULE_PRIORITY')' -`undefine(`SCHEDULE_CORE')' -`define(`PIPELINE_ID', $2)' -`define(`DAI_TYPE', STR($3))' -`define(`DAI_INDEX', STR($4))' -`define(`DAI_BUF', $5)' -`define(`DAI_NAME', $3$4)' -`define(`DAI_PERIODS', $6)' -`define(`DAI_FORMAT', $7)' -`define(`SCHEDULE_FRAMES', $8)' -`define(`SCHEDULE_DEADLINE', $9)' -`define(`SCHEDULE_PRIORITY', $10)' -`define(`SCHEDULE_CORE', $11)' -`include($1)' -) - divert(0)dnl diff --git a/topology/m4/src.m4 b/topology/m4/src.m4 new file mode 100644 index 000000000000..aca18e3f9009 --- /dev/null +++ b/topology/m4/src.m4 @@ -0,0 +1,41 @@ +divert(-1) + +dnl Defines the macro for SRC widget + +dnl SRC name) +define(`N_SRC', `SRC'PIPELINE_ID`.'$1) + +dnl W_SRC(name, format, periods_sink, periods_source, data, preload) +define(`W_SRC', +`SectionVendorTuples."'N_SRC($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` }' +`}' +`SectionData."'N_SRC($1)`_data_w" {' +` tuples "'N_SRC($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_SRC($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_SRC($1)`_data_str" {' +` tuples "'N_SRC($1)`_tuples_str"' +`}' +`SectionWidget."'N_SRC($1)`" {' +` index "'PIPELINE_ID`"' +` type "src"' +` no_pm "true"' +` data [' +` "'N_SRC($1)`_data_w"' +` "'N_SRC($1)`_data_str"' +` "'$5`"' +` ]' +`}') + +divert(0)dnl diff --git a/topology/m4/tone.m4 b/topology/m4/tone.m4 new file mode 100644 index 000000000000..6a88b37cdc37 --- /dev/null +++ b/topology/m4/tone.m4 @@ -0,0 +1,43 @@ +divert(-1) + +dnl Define macro for siggen widget + +dnl Tone name) +define(`N_TONE', `TONE'PIPELINE_ID`.'$1) + +dnl W_TONE(name, format, periods_sink, periods_source, preload, kcontrols_list) +define(`W_TONE', +`SectionVendorTuples."'N_TONE($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_TONE($1)`_data_w" {' +` tuples "'N_TONE($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_TONE($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_TONE($1)`_data_str" {' +` tuples "'N_TONE($1)`_tuples_str"' +`}' +`SectionWidget."'N_TONE($1)`" {' +` index "'PIPELINE_ID`"' +` type "siggen"' +` no_pm "true"' +` data [' +` "'N_TONE($1)`_data_w"' +` "'N_TONE($1)`_data_str"' +` ]' +` mixer [' + $6 +` ]' +`}') + +divert(0)dnl diff --git a/topology/m4/utils.m4 b/topology/m4/utils.m4 new file mode 100644 index 000000000000..e929244fc6a4 --- /dev/null +++ b/topology/m4/utils.m4 @@ -0,0 +1,65 @@ +divert(-1) + +define(`concat',`$1$2') + +define(`STR', `"'$1`"') + +dnl Argument iterator. +define(`argn', `ifelse(`$1', 1, ``$2'', + `argn(decr(`$1'), shift(shift($@)))')') + +dnl Defines a list of items from a variable number of params. +dnl Use as last argument in a macro. +dnl The first argument specifies the number of tabs to be added for formatting +define(`LIST_LOOP', `argn(j,$@) +$1ifelse(i,`2', `', `define(`i', decr(i))define(`j', incr(j))$0($@)')') + +define(`LIST', `pushdef(`i', $#)pushdef(`j', `2')LIST_LOOP($@)popdef(i)popdef(j)') + +dnl Sums a list of variable arguments. Use as last argument in macro. +define(`SUM_LOOP', `eval(argn(j,$@) + ifelse(i,`1', `', `define(`i', decr(i)) define(`j', incr(j)) + $0($@)'))') + +dnl Memory capabilities +define(`MEMCAPS', `pushdef(`i', $#) pushdef(`j', `1') SUM_LOOP($@)') + +dnl create direct DAPM/pipeline link between 2 widgets) +define(`dapm', `"$1, , $2"') + +dnl COMP_SAMPLE_SIZE(FMT) +define(`COMP_SAMPLE_SIZE', +`ifelse( + $1, `s16le', `2', + $1, `s24_4le', `4', + $1, `s32le', `4', + $1, `float', `4', + `4')') + +dnl P_GRAPH(name, CONNECTIONS) +define(`P_GRAPH', +`SectionGraph.STR($1) {' +` index STR($2)' +`' +` lines [' +` $3' +` ]' +`}') + +dnl W_VENDORTUPLES(name, tokens, RATE_OUT) +define(`W_VENDORTUPLES', +`SectionVendorTuples.STR($1) {' +` tokens STR($2)' +`' +` tuples."word" {' +` $3' +` }' +`}') + +dnl W_DATA(name, tuples) +define(`W_DATA', +`SectionData.STR($1) {' +` tuples STR($2)' +`}') + +divert(0) dnl + diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index d4ac6133aeaf..cf0a20eb99de 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`pipeline.m4') +include(`utils.m4') +include(`dai.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index eaba2d969731..fa894f68e09a 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`pipeline.m4') +include(`utils.m4') +include(`dai.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index 5d4485b96b5a..ec920a5a38d4 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index dbac98a62bde..b7717d0f8d2b 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-byt-da7212.m4 b/topology/reef-byt-da7212.m4 index 840ea6951210..7515c630b8aa 100644 --- a/topology/reef-byt-da7212.m4 +++ b/topology/reef-byt-da7212.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index 56aee226cd7c..b3ca19675e17 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`pipeline.m4') +include(`utils.m4') +include(`dai.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index f8d0e40d162b..9fa15a286100 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-byt-rt5645.m4 b/topology/reef-byt-rt5645.m4 index 023d92dbcdf6..c81a4db3ca9c 100644 --- a/topology/reef-byt-rt5645.m4 +++ b/topology/reef-byt-rt5645.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index ccac260303f9..96147d3a0e85 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-cht-max98090.m4 b/topology/reef-cht-max98090.m4 index 3218402420d9..5690df4d07c9 100644 --- a/topology/reef-cht-max98090.m4 +++ b/topology/reef-cht-max98090.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index 24560ee6a1e0..32acb6216292 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`pipeline.m4') +include(`utils.m4') +include(`dai.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-cnl-rt274.m4 b/topology/reef-cnl-rt274.m4 index f91a74fe95fc..e95363b29ec2 100644 --- a/topology/reef-cnl-rt274.m4 +++ b/topology/reef-cnl-rt274.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index 663686b0f528..1f6382059758 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/sof/pipe-dai-capture.m4 b/topology/sof/pipe-dai-capture.m4 index 36991387c380..a5a72d0f2ba3 100644 --- a/topology/sof/pipe-dai-capture.m4 +++ b/topology/sof/pipe-dai-capture.m4 @@ -1,7 +1,9 @@ # DAI Capture connector # Include topology builder -include(`local.m4') +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') # # DAI definitions diff --git a/topology/sof/pipe-dai-playback.m4 b/topology/sof/pipe-dai-playback.m4 index d35d3b112105..e70998b1d676 100644 --- a/topology/sof/pipe-dai-playback.m4 +++ b/topology/sof/pipe-dai-playback.m4 @@ -1,7 +1,9 @@ # DAI Playback connector # Include topology builder -include(`local.m4') +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') # # DAI definitions diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 7adfd14ed790..5619999aaffc 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -5,7 +5,11 @@ # host PCM_C <--B5-- volume(0C) <--B4-- source DAI0 # Include topology builder -include(`local.m4') +include(`utils.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`pga.m4') +include(`mixercontrol.m4') # # Controls diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index 11cf07d6a5cb..4a4fca955396 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -20,7 +20,12 @@ # # Include topology builder -include(`local.m4') +include(`utils.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`pga.m4') +include(`mixer.m4') +include(`mixercontrol.m4') # # Controls diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index cfa357ab34b4..a13887ad9fb2 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -5,8 +5,11 @@ # host PCM_C <-- B0 <-- sink DAI0 # Include topology builder -include(`local.m4') - +include(`utils.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`dai.m4') +include(`pipeline.m4') # # Components and Buffers diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index 3218431b9e93..8a9e8ff523a0 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -5,8 +5,11 @@ # host PCM_P --> B0 --> sink DAI0 # Include topology builder -include(`local.m4') - +include(`utils.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`dai.m4') +include(`pipeline.m4') # # Components and Buffers diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 0196f985657d..f2053b7cd337 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -8,7 +8,12 @@ # # Include topology builder -include(`local.m4') +include(`utils.m4') +include(`src.m4') +include(`buffer.m4') +include(`pga.m4') +include(`mixercontrol.m4') +include(`pipeline.m4') # # Controls diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index 824dcdb14d88..a58eb68dfdee 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -5,8 +5,12 @@ # host PCM_P --> SRC --> sink DAI0 # Include topology builder -include(`local.m4') - +include(`utils.m4') +include(`src.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`dai.m4') +include(`pipeline.m4') # # Components and Buffers diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index 3009ff7d7623..7bf8f4704a8f 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -5,8 +5,12 @@ # host PCM_P --> SRC --> sink DAI0 # Include topology builder -include(`local.m4') - +include(`utils.m4') +include(`src.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`dai.m4') +include(`pipeline.m4') # # Components and Buffers diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index 899c42667648..09ed32c7afaa 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -8,7 +8,12 @@ # # Include topology builder -include(`local.m4') +include(`utils.m4') +include(`buffer.m4') +include(`pga.m4') +include(`tone.m4') +include(`mixercontrol.m4') +include(`pipeline.m4') # # Controls diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 299a0f8a6809..5aa0d12415e5 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -5,7 +5,13 @@ # host PCM_C <-- B0 <-- Volume 0 <-- B1 <-- source DAI0 # Include topology builder -include(`local.m4') +include(`utils.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`pga.m4') +include(`dai.m4') +include(`mixercontrol.m4') +include(`pipeline.m4') # # Controls diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 3e3f98efde23..90fe303766de 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -5,7 +5,13 @@ # host PCM_P --> B0 --> Volume 0 --> B1 --> sink DAI0 # Include topology builder -include(`local.m4') +include(`utils.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`pga.m4') +include(`dai.m4') +include(`mixercontrol.m4') +include(`pipeline.m4') # # Controls diff --git a/topology/test/test-capture-ssp.m4 b/topology/test/test-capture-ssp.m4 index 2c808ba099be..89502226ad83 100644 --- a/topology/test/test-capture-ssp.m4 +++ b/topology/test/test-capture-ssp.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`dai.m4') +include(`utils.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/test/test-playback-ssp.m4 b/topology/test/test-playback-ssp.m4 index 093ad17721de..db6cb6c03eaf 100644 --- a/topology/test/test-playback-ssp.m4 +++ b/topology/test/test-playback-ssp.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`pipeline.m4') +include(`dai.m4') +include(`utils.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/test/test-ssp.m4 b/topology/test/test-ssp.m4 index 304aab9f4365..01e3a024a92a 100644 --- a/topology/test/test-ssp.m4 +++ b/topology/test/test-ssp.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`dai.m4') +include(`utils.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') diff --git a/topology/test/test-tone-playback-ssp.m4 b/topology/test/test-tone-playback-ssp.m4 index 2fe66933faef..92313162ba81 100644 --- a/topology/test/test-tone-playback-ssp.m4 +++ b/topology/test/test-tone-playback-ssp.m4 @@ -3,8 +3,9 @@ # # Include topology builder -include(`local.m4') -include(`build.m4') +include(`pipeline.m4') +include(`dai.m4') +include(`utils.m4') # Include TLV library include(`common/tlv.m4') From 46a5e80fc5332b1a3397213c279c172aabbd680d Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 6 Mar 2018 14:11:13 +0000 Subject: [PATCH 118/324] rmbox: remove legacy code and use sof debugFS by default. Dump error log by default with no args. Signed-off-by: Liam Girdwood --- rmbox/rmbox.c | 99 ++++++++++----------------------------------------- 1 file changed, 18 insertions(+), 81 deletions(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 9403cc7cdc64..115be8326c12 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -47,42 +47,6 @@ #define TRACE_CLASS_EQ_FIR (19 << 24) #define TRACE_CLASS_EQ_IIR (20 << 24) -#define MAILBOX_HOST_OFFSET 0x144000 - -#define MAILBOX_OUTBOX_OFFSET 0x0 -#define MAILBOX_OUTBOX_SIZE 0x400 -#define MAILBOX_OUTBOX_BASE \ - (MAILBOX_BASE + MAILBOX_OUTBOX_OFFSET) - -#define MAILBOX_INBOX_OFFSET MAILBOX_OUTBOX_SIZE -#define MAILBOX_INBOX_SIZE 0x400 -#define MAILBOX_INBOX_BASE \ - (MAILBOX_BASE + MAILBOX_INBOX_OFFSET) - -#define MAILBOX_EXCEPTION_OFFSET \ - (MAILBOX_INBOX_SIZE + MAILBOX_OUTBOX_SIZE) -#define MAILBOX_EXCEPTION_SIZE 0x100 -#define MAILBOX_EXCEPTION_BASE \ - (MAILBOX_BASE + MAILBOX_EXCEPTION_OFFSET) - -#define MAILBOX_DEBUG_OFFSET \ - (MAILBOX_EXCEPTION_SIZE + MAILBOX_EXCEPTION_OFFSET) -#define MAILBOX_DEBUG_SIZE 0x100 -#define MAILBOX_DEBUG_BASE \ - (MAILBOX_BASE + MAILBOX_DEBUG_OFFSET) - -#define MAILBOX_STREAM_OFFSET \ - (MAILBOX_DEBUG_SIZE + MAILBOX_DEBUG_OFFSET) -#define MAILBOX_STREAM_SIZE 0x200 -#define MAILBOX_STREAM_BASE \ - (MAILBOX_BASE + MAILBOX_STREAM_OFFSET) - -#define MAILBOX_TRACE_OFFSET \ - (MAILBOX_STREAM_SIZE + MAILBOX_STREAM_OFFSET) -#define MAILBOX_TRACE_SIZE 0x380 -#define MAILBOX_TRACE_BASE \ - (MAILBOX_BASE + MAILBOX_TRACE_OFFSET) - #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) @@ -218,8 +182,7 @@ static void show_trace(uint64_t val, uint64_t addr, uint64_t *timestamp, double } } -static int trace_read(const char *in_file, const char *out_file, double clk, - int offset) +static int trace_read(const char *in_file, const char *out_file, double clk) { int count, i; FILE *in_fd = NULL, *out_fd = NULL; @@ -250,11 +213,6 @@ static int trace_read(const char *in_file, const char *out_file, double clk, if (count != TRACE_BLOCK_SIZE) break; - if (addr < offset) { - addr += TRACE_BLOCK_SIZE; - continue; - } - val = *((uint64_t*)tmp); for (i = 0; i < TRACE_BLOCK_SIZE / 2; i++) { @@ -277,21 +235,10 @@ static int trace_read(const char *in_file, const char *out_file, double clk, return 0; } -static void show_debug(uint32_t val, uint32_t addr) +static void show_data(uint32_t val, uint32_t addr) { - printf("debug: 0x%x (%2.2d) = \t0x%8.8x \t(%8.8d) \t|%c%c%c%c|\n", - (unsigned int)addr - MAILBOX_DEBUG_OFFSET, - ((unsigned int)addr - MAILBOX_DEBUG_OFFSET) / 4, - val, val, - get_char(val, 3), get_char(val, 2), - get_char(val, 1), get_char(val, 0)); -} - -static void show_exception(uint32_t val, uint32_t addr) -{ - printf("exp: 0x%x (%2.2d) = \t0x%8.8x \t(%8.8d) \t|%c%c%c%c|\n", - (unsigned int)addr - MAILBOX_EXCEPTION_OFFSET, - ((unsigned int)addr - MAILBOX_EXCEPTION_OFFSET) / 4, + printf("data: 0x%x = \t0x%8.8x \t(%8.8d) \t|%c%c%c%c|\n", + (unsigned int)addr, val, val, get_char(val, 3), get_char(val, 2), get_char(val, 1), get_char(val, 0)); @@ -299,7 +246,9 @@ static void show_exception(uint32_t val, uint32_t addr) static const char *debugfs[] = { - "dmac0","dmac1", "ssp0", "ssp1", "ssp2", "iram", "dram", "shim", "mbox" + "dmac0", "dmac1", "ssp0", "ssp1", + "ssp2", "iram", "dram", "shim", + "mbox", "etrace", }; static int snapshot(const char *name) @@ -362,12 +311,11 @@ static int snapshot(const char *name) int main(int argc, char *argv[]) { int opt, count, trace = 0; - const char * out_file = NULL, *in_file = "/sys/kernel/debug/sof/mbox"; + const char * out_file = NULL, *in_file = NULL; FILE *in_fd = NULL, *out_fd = NULL; char c, tmp[8] = {0}; uint64_t addr = 0, val, timestamp = 0, align = 4, i; double clk = 19.2; - int title_dbg_done = 0, title_exp_done = 0; while ((opt = getopt(argc, argv, "ho:i:s:m:c:t")) != -1) { switch (opt) { @@ -393,7 +341,15 @@ int main(int argc, char *argv[]) /* trace requested ? */ if (trace) - return trace_read("/sys/kernel/debug/sof/trace", out_file, clk, 0); + return trace_read("/sys/kernel/debug/sof/trace", + out_file, clk); + + /* default option with no infile is to dump errors/debug data */ + if (in_file == NULL) { + fprintf(stdout, "\nError log:\n"); + return trace_read("/sys/kernel/debug/sof/etrace", + out_file, clk); + } /* open infile for reading */ in_fd = fopen(in_file, "r"); @@ -432,21 +388,7 @@ int main(int argc, char *argv[]) tmp[align - i - 1] = c; } - if (addr >= MAILBOX_DEBUG_OFFSET && - addr < MAILBOX_DEBUG_OFFSET + MAILBOX_DEBUG_SIZE) { - - if (!title_dbg_done++) - fprintf(stdout, "\nDebug log:\n"); - - show_debug(val, addr); - } else if (addr >= MAILBOX_EXCEPTION_OFFSET && - addr < MAILBOX_EXCEPTION_OFFSET + MAILBOX_EXCEPTION_SIZE) { - - if (!title_exp_done++) - fprintf(stdout, "\nException log:\n"); - - show_exception(val, addr); - } + show_data(val, addr); if (out_fd) { count = fwrite(&tmp[0], 1, align, out_fd); @@ -457,11 +399,6 @@ int main(int argc, char *argv[]) addr += align; } - /* read debug */ - fprintf(stdout, "\nError log:\n"); - trace_read("/sys/kernel/debug/sof/mbox", out_file, clk, - MAILBOX_TRACE_OFFSET); - /* close files */ fclose(in_fd); if (out_fd) From 59bcff216aae66ed4d88062c97dfe4ca0a7b53c5 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 6 Mar 2018 15:37:07 +0000 Subject: [PATCH 119/324] topology: byt-rt5651: Fix BE DAI link name. Should be SSP2-Codec. Signed-off-by: Liam Girdwood --- topology/reef-byt-rt5651.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index 96147d3a0e85..ec114d75bdd2 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, Baytrail Audio, I2S, 24, +DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), From 3105de2481b5b5511b2fa844fe859f023f434b4c Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Tue, 6 Mar 2018 10:59:03 -0800 Subject: [PATCH 120/324] topology: fix dai capture tokens and move buffer size macro definition This patch fixes typo in dai capture tokens and moves te buffer size macro definition to buffer.m4 Signed-off-by: Ranjani Sridharan --- topology/dsps/bdw.m4 | 2 +- topology/dsps/bxt.m4 | 2 +- topology/dsps/byt.m4 | 2 +- topology/dsps/cht.m4 | 2 +- topology/dsps/cnl.m4 | 2 +- topology/dsps/hsw.m4 | 2 +- topology/m4/buffer.m4 | 22 ++++++++++++++++++++++ topology/m4/pcm.m4 | 22 ---------------------- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/topology/dsps/bdw.m4 b/topology/dsps/bdw.m4 index a6022b9e312c..c2bf04e2ba55 100644 --- a/topology/dsps/bdw.m4 +++ b/topology/dsps/bdw.m4 @@ -31,7 +31,7 @@ W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC " W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) W_DATA(dai0c_plat_conf, dai0c_plat_tokens) diff --git a/topology/dsps/bxt.m4 b/topology/dsps/bxt.m4 index 4d45386c947e..df61d1ac744d 100644 --- a/topology/dsps/bxt.m4 +++ b/topology/dsps/bxt.m4 @@ -34,7 +34,7 @@ W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC " W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) W_DATA(dai0c_plat_conf, dai0c_plat_tokens) diff --git a/topology/dsps/byt.m4 b/topology/dsps/byt.m4 index ab707f81191c..d1d4886ab97f 100644 --- a/topology/dsps/byt.m4 +++ b/topology/dsps/byt.m4 @@ -31,7 +31,7 @@ W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC " W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) W_DATA(dai0c_plat_conf, dai0c_plat_tokens) diff --git a/topology/dsps/cht.m4 b/topology/dsps/cht.m4 index 41529dca4ab2..4ed114f71ee6 100644 --- a/topology/dsps/cht.m4 +++ b/topology/dsps/cht.m4 @@ -31,7 +31,7 @@ W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC " W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) W_DATA(dai0c_plat_conf, dai0c_plat_tokens) diff --git a/topology/dsps/cnl.m4 b/topology/dsps/cnl.m4 index 431db326f373..41ece9425f47 100644 --- a/topology/dsps/cnl.m4 +++ b/topology/dsps/cnl.m4 @@ -35,7 +35,7 @@ W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC " W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) W_DATA(dai0c_plat_conf, dai0c_plat_tokens) diff --git a/topology/dsps/hsw.m4 b/topology/dsps/hsw.m4 index 5db318f21dc2..754fc413c16c 100644 --- a/topology/dsps/hsw.m4 +++ b/topology/dsps/hsw.m4 @@ -31,7 +31,7 @@ W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC " W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC "1"')) +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) W_DATA(dai0c_plat_conf, dai0c_plat_tokens) diff --git a/topology/m4/buffer.m4 b/topology/m4/buffer.m4 index fc06ba0cf7f3..4bfd212d4f2b 100644 --- a/topology/m4/buffer.m4 +++ b/topology/m4/buffer.m4 @@ -26,4 +26,26 @@ define(`W_BUFFER', ` ]' `}') +dnl COMP_BUFFER_SIZE( num_periods, sample_size, channels, fmames) +define(`COMP_BUFFER_SIZE', `eval(`$1 * $2 * $3 * $4')') + +dnl PCM_PLAYBACK_ADD(name, pipeline, pcm_id, dai_id, playback) +define(`PCM_PLAYBACK_ADD', +`SectionPCM.STR($1) {' +`' +` index STR($2)' +`' +` # used for binding to the PCM' +` id STR($3)' +`' +` dai.STR($1 $3) {' +` id STR($4)' +` }' +`' +` pcm."playback" {' +`' +` capabilities STR($5)' +` }' +`}') + divert(0)dnl diff --git a/topology/m4/pcm.m4 b/topology/m4/pcm.m4 index d767350de2bb..596f2fe7c8b8 100644 --- a/topology/m4/pcm.m4 +++ b/topology/m4/pcm.m4 @@ -93,28 +93,6 @@ define(`PCM_CAPABILITIES', ` buffer_size_max STR($12)' `}') -dnl COMP_BUFFER_SIZE( num_periods, sample_size, channels, fmames) -define(`COMP_BUFFER_SIZE', `eval(`$1 * $2 * $3 * $4')') - -dnl PCM_PLAYBACK_ADD(name, pipeline, pcm_id, dai_id, playback) -define(`PCM_PLAYBACK_ADD', -`SectionPCM.STR($1) {' -`' -` index STR($2)' -`' -` # used for binding to the PCM' -` id STR($3)' -`' -` dai.STR($1 $3) {' -` id STR($4)' -` }' -`' -` pcm."playback" {' -`' -` capabilities STR($5)' -` }' -`}') - dnl PCM_CAPTURE_ADD(name, pipeline, pcm_id, dai_id, capture) define(`PCM_CAPTURE_ADD', `SectionPCM.STR($1) {' From be6ff21ae914e759c1152a740bb6e39886670676 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 6 Mar 2018 18:45:21 -0600 Subject: [PATCH 121/324] topology: test: add simple test for Up2 board Up^2 board exposes I2S signals on the 40-pin connector (https://wiki.up-community.org/Pinout_UP2) Add test for SSP5 (marked in pinout as AVS_I2S6) Signed-off-by: Pierre-Louis Bossart --- topology/test/tplg-build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index eaa6f8ba6d48..16d3630cc98d 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -106,6 +106,7 @@ simple_test baytrail src "Baytrail Audio" s24le 2 s24le 25 24 2400000 19200000 # for APL simple_test nocodec volume "NoCodec" s16le 4 s16le 16 16 1536000 24576000 simple_test codec volume "SSP4-Codec" s16le 4 s16le 16 16 1536000 24576000 +simple_test nocodec volume "NoCodec" s16le 5 s16le 16 16 1536000 24576000 # Tone test: Tone component only supports s32le currently tone_test codec tone "SSP2-Codec" s32le 2 s16le 20 16 1920000 19200000 From 5b5bbe31e6d914079707bfa6c129c2730ea7aeff Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Wed, 7 Mar 2018 18:34:04 +0800 Subject: [PATCH 122/324] topology: Remove volume mute in volume pipeline Volume mute will cause a regression. Delete it now. Signed-off-by: Pan Xiuli --- topology/sof/pipe-volume-playback.m4 | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 90fe303766de..d6624b037216 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -25,15 +25,6 @@ C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, Channel register and shift for Front Left/Right, LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) -# Volume Mixer Switch control with max value of 1 -C_CONTROLMIXER(Master Playback Volume Switch, PIPELINE_ID, - CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), - CONTROLMIXER_MAX(max value 1 indicates switch type control, 1), - false, - , - Channel register and shift for Front Left/Right, - LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) - # # Components and Buffers # @@ -43,7 +34,7 @@ C_CONTROLMIXER(Master Playback Volume Switch, PIPELINE_ID, W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Volume" has 2 source and 2 sink periods -W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume Switch", "Master Playback Volume")) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume")) # Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, From 8d9b8d51f9c60e1c1725e9ccd3da22c0b523d0cf Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Tue, 13 Mar 2018 20:18:19 +0000 Subject: [PATCH 123/324] topology: Add stream name to DAI widgets for binding to DAI links DAI Widgets need bound to a DAI link to complete the DAPM graph. This is only working atm as we are only using one DAI. Add stream name to DAI widgets to be used by topology binder. Signed-off-by: Liam Girdwood --- topology/m4/dai.m4 | 44 ++++++++++++----------- topology/reef-apl-nocodec.m4 | 4 +-- topology/reef-bdw-rt286.m4 | 4 +-- topology/reef-bdw-rt5640.m4 | 4 +-- topology/reef-bxt-nocodec.m4 | 4 +-- topology/reef-byt-da7212.m4 | 4 +-- topology/reef-byt-nocodec.m4 | 4 +-- topology/reef-byt-rt5640.m4 | 4 +-- topology/reef-byt-rt5645.m4 | 4 +-- topology/reef-byt-rt5651.m4 | 4 +-- topology/reef-cht-max98090.m4 | 4 +-- topology/reef-cht-nocodec.m4 | 4 +-- topology/reef-cnl-rt274.m4 | 4 +-- topology/reef-hsw-rt5640.m4 | 4 +-- topology/sof/pipe-dai-capture.m4 | 2 +- topology/sof/pipe-dai-playback.m4 | 2 +- topology/sof/pipe-passthrough-capture.m4 | 2 +- topology/sof/pipe-passthrough-playback.m4 | 2 +- topology/sof/pipe-src-capture.m4 | 2 +- topology/sof/pipe-src-playback.m4 | 2 +- topology/sof/pipe-volume-capture.m4 | 2 +- topology/sof/pipe-volume-playback.m4 | 2 +- topology/test/test-capture-ssp.m4 | 2 +- topology/test/test-playback-ssp.m4 | 2 +- topology/test/test-ssp.m4 | 4 +-- topology/test/test-tone-playback-ssp.m4 | 2 +- 26 files changed, 63 insertions(+), 59 deletions(-) diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index 163dfab31e96..0b030afdd341 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -7,14 +7,14 @@ define(`N_DAI', DAI_NAME) define(`N_DAI_OUT', DAI_NAME`.OUT') define(`N_DAI_IN', DAI_NAME`.IN') -dnl W_DAI_OUT(type, index, format, periods_sink, periods_source, preload, data) +dnl W_DAI_OUT(type, index, dai_link, format, periods_sink, periods_source, preload, data) define(`W_DAI_OUT', `SectionVendorTuples."'N_DAI_OUT($2)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) ` }' `}' `SectionData."'N_DAI_OUT($2)`_data_w_comp" {' @@ -41,7 +41,7 @@ define(`W_DAI_OUT', `SectionVendorTuples."'N_DAI_OUT($2)`_tuples_comp_str" {' ` tokens "sof_comp_tokens"' ` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($3) +` SOF_TKN_COMP_FORMAT' STR($4) ` }' `}' `SectionData."'N_DAI_OUT($2)`_data_comp_str" {' @@ -50,24 +50,25 @@ define(`W_DAI_OUT', `SectionWidget."'N_DAI_OUT`" {' ` index "'PIPELINE_ID`"' ` type "dai_in"' +` stream_name' STR($3) ` no_pm "true"' ` data [' ` "'N_DAI_OUT($2)`_data_w"' ` "'N_DAI_OUT($2)`_data_w_comp"' ` "'N_DAI_OUT($2)`_data_str"' ` "'N_DAI_OUT($2)`_data_comp_str"' -` "'$7`"' +` "'$8`"' ` ]' `}') -dnl W_DAI_IN(type, index, format, periods_sink, periods_source, preload, data) +dnl W_DAI_IN(type, index, dai_link, format, periods_sink, periods_source, preload, data) define(`W_DAI_IN', `SectionVendorTuples."'N_DAI_IN($2)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) ` }' `}' `SectionData."'N_DAI_IN($2)`_data_w_comp" {' @@ -94,7 +95,7 @@ define(`W_DAI_IN', `SectionVendorTuples."'N_DAI_IN($2)`_tuples_comp_str" {' ` tokens "sof_comp_tokens"' ` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($3) +` SOF_TKN_COMP_FORMAT' STR($4) ` }' `}' `SectionData."'N_DAI_IN($2)`_data_comp_str" {' @@ -103,13 +104,14 @@ define(`W_DAI_IN', `SectionWidget."'N_DAI_IN`" {' ` index "'PIPELINE_ID`"' ` type "dai_out"' +` stream_name' STR($3) ` no_pm "true"' ` data [' ` "'N_DAI_IN($2)`_data_w"' ` "'N_DAI_IN($2)`_data_w_comp"' ` "'N_DAI_IN($2)`_data_str"' ` "'N_DAI_IN($2)`_data_comp_str"' -` "'$7`"' +` "'$8`"' ` ]' `}') @@ -183,13 +185,14 @@ define(`DAI_CONFIG', `}') dnl DAI_ADD(pipeline, -dnl pipe id, dai type, dai_index, +dnl pipe id, dai type, dai_index, dai_be, dnl buffer, periods, format, dnl frames, deadline, priority, core) define(`DAI_ADD', `undefine(`PIPELINE_ID')' `undefine(`DAI_TYPE')' `undefine(`DAI_INDEX')' +`undefine(`DAI_BE')' `undefine(`DAI_BUF')' `undefine(`DAI_PERIODS')' `undefine(`DAI_FORMAT')' @@ -200,14 +203,15 @@ define(`DAI_ADD', `define(`PIPELINE_ID', $2)' `define(`DAI_TYPE', STR($3))' `define(`DAI_INDEX', STR($4))' -`define(`DAI_BUF', $5)' +`define(`DAI_BE', $5)' +`define(`DAI_BUF', $6)' `define(`DAI_NAME', $3$4)' -`define(`DAI_PERIODS', $6)' -`define(`DAI_FORMAT', $7)' -`define(`SCHEDULE_FRAMES', $8)' -`define(`SCHEDULE_DEADLINE', $9)' -`define(`SCHEDULE_PRIORITY', $10)' -`define(`SCHEDULE_CORE', $11)' +`define(`DAI_PERIODS', $7)' +`define(`DAI_FORMAT', $8)' +`define(`SCHEDULE_FRAMES', $9)' +`define(`SCHEDULE_DEADLINE', $10)' +`define(`SCHEDULE_PRIORITY', $11)' +`define(`SCHEDULE_CORE', $12)' `include($1)' ) diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index cf0a20eb99de..78a1a4eb117d 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-apl-nocodec" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, + 1, SSP, 2, NoCodec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, + 2, SSP, 2, NoCodec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index fa894f68e09a..a305e7d7a8ce 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-bdw-rt286" { # playback DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 0, + 1, SSP, 0, Codec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 0, + 2, SSP, 0, Codec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index ec920a5a38d4..3fbb8444fde2 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-bdw-rt5640" { # playback DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 0, + 1, SSP, 0, Audio, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 0, + 2, SSP, 0, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 index b7717d0f8d2b..7e2b624c73f9 100644 --- a/topology/reef-bxt-nocodec.m4 +++ b/topology/reef-bxt-nocodec.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-bxt-nocodec" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, + 1, SSP, 2, NoCodec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, + 2, SSP, 2, NoCodec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-byt-da7212.m4 b/topology/reef-byt-da7212.m4 index 7515c630b8aa..a9789c627f50 100644 --- a/topology/reef-byt-da7212.m4 +++ b/topology/reef-byt-da7212.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-byt-da7212" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, + 1, SSP, 2, SSP2-Codec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, + 2, SSP, 2, SSP2-Codec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-byt-nocodec.m4 b/topology/reef-byt-nocodec.m4 index b3ca19675e17..3be5d00d0b0c 100644 --- a/topology/reef-byt-nocodec.m4 +++ b/topology/reef-byt-nocodec.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-byt-nocodec" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, + 1, SSP, 2, NoCodec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, + 2, SSP, 2, NoCodec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 9fa15a286100..c971d4103919 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-byt-rt5640" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, + 1, SSP, 2, Audio PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, + 2, SSP, 2, Audio, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-byt-rt5645.m4 b/topology/reef-byt-rt5645.m4 index c81a4db3ca9c..15cac48cef3e 100644 --- a/topology/reef-byt-rt5645.m4 +++ b/topology/reef-byt-rt5645.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-byt-rt5645" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, + 1, SSP, 2, SSP2-Codec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, + 2, SSP, 2, SSP2-Codec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-byt-rt5651.m4 b/topology/reef-byt-rt5651.m4 index ec114d75bdd2..0e76c5679ab9 100644 --- a/topology/reef-byt-rt5651.m4 +++ b/topology/reef-byt-rt5651.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-byt-rt5651" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, + 1, SSP, 2, SSP2-Codec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, + 2, SSP, 2, SSP2-Codec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-cht-max98090.m4 b/topology/reef-cht-max98090.m4 index 5690df4d07c9..ab1b6393e0de 100644 --- a/topology/reef-cht-max98090.m4 +++ b/topology/reef-cht-max98090.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-cht-max98090" { # playback DAI is SSP2 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, + 1, SSP, 2, SSP2-Codec, PIPELINE_SOURCE_1, 2, s16le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, + 2, SSP, 2, SSP2-Codec, PIPELINE_SINK_2, 2, s16le, 48, 1000, 0, 0) diff --git a/topology/reef-cht-nocodec.m4 b/topology/reef-cht-nocodec.m4 index 32acb6216292..3f61e4440390 100644 --- a/topology/reef-cht-nocodec.m4 +++ b/topology/reef-cht-nocodec.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-cht-nocodec" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, + 1, SSP, 2, NoCodec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, + 2, SSP, 2, NoCodec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-cnl-rt274.m4 b/topology/reef-cnl-rt274.m4 index e95363b29ec2..495fab387edc 100644 --- a/topology/reef-cnl-rt274.m4 +++ b/topology/reef-cnl-rt274.m4 @@ -47,14 +47,14 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, # playback DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 0, + 1, SSP, 0, SSP0-Codec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 0, + 2, SSP, 0, SSP0-Codec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index 1f6382059758..5ab33ea14484 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-hsw-rt5640" { # playback DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 0, + 1, SSP, 0, Codec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 0, + 2, SSP, 0, Codec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) diff --git a/topology/sof/pipe-dai-capture.m4 b/topology/sof/pipe-dai-capture.m4 index a5a72d0f2ba3..3f16f879552c 100644 --- a/topology/sof/pipe-dai-capture.m4 +++ b/topology/sof/pipe-dai-capture.m4 @@ -8,7 +8,7 @@ include(`pipeline.m4') # # DAI definitions # -W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 2, 0, 0, dai0c_plat_conf) +W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 2, 0, 0, dai0c_plat_conf) # # DAI pipeline - always use 0 for DAIs diff --git a/topology/sof/pipe-dai-playback.m4 b/topology/sof/pipe-dai-playback.m4 index e70998b1d676..2397875d4576 100644 --- a/topology/sof/pipe-dai-playback.m4 +++ b/topology/sof/pipe-dai-playback.m4 @@ -8,7 +8,7 @@ include(`pipeline.m4') # # DAI definitions # -W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) +W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) # # DAI pipeline - always use 0 for DAIs diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index a13887ad9fb2..07961b3f50f7 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -27,7 +27,7 @@ W_BUFFER(0, COMP_BUFFER_SIZE(2, # # DAI definitions # -W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0c_plat_conf) +W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, 2, 2, dai0c_plat_conf) # # DAI pipeline - always use 0 for DAIs diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index 8a9e8ff523a0..715fcee14506 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -27,7 +27,7 @@ W_BUFFER(0, COMP_BUFFER_SIZE(2, # # DAI definitions # -W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) +W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) # # DAI pipeline - always use 0 for DAIs diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index a58eb68dfdee..1b1a58d0235c 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -42,7 +42,7 @@ W_BUFFER(1, COMP_BUFFER_SIZE(4, # # DAI definitions # -W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, +W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, DAI_PERIODS, DAI_PERIODS, dai0c_plat_conf) # diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index 7bf8f4704a8f..9dfdcd80a10f 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -42,7 +42,7 @@ W_BUFFER(1, COMP_BUFFER_SIZE(4, # # DAI definitions # -W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, +W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, DAI_PERIODS, DAI_PERIODS, dai0p_plat_conf) # diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 5aa0d12415e5..61b70a9def72 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -47,7 +47,7 @@ W_BUFFER(1, COMP_BUFFER_SIZE(2, # # DAI definitions # -W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, +W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, DAI_PERIODS, DAI_PERIODS, dai0c_plat_conf) # diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index d6624b037216..5fea0c7bfc30 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -47,7 +47,7 @@ W_BUFFER(1, COMP_BUFFER_SIZE(2, # # DAI definitions # -W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_FORMAT, 0, DAI_PERIODS, +W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, DAI_PERIODS, DAI_PERIODS, dai0p_plat_conf) # diff --git a/topology/test/test-capture-ssp.m4 b/topology/test/test-capture-ssp.m4 index 89502226ad83..3d10d7a2ee27 100644 --- a/topology/test/test-capture-ssp.m4 +++ b/topology/test/test-capture-ssp.m4 @@ -53,7 +53,7 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-capture.m4, # capture DAI is SSP TEST_SSP_PORT using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, TEST_SSP_PORT, + 2, SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, PIPELINE_SINK_2, 2, TEST_SSP_FORMAT, 48, 1000, 0, 0) diff --git a/topology/test/test-playback-ssp.m4 b/topology/test/test-playback-ssp.m4 index db6cb6c03eaf..ab775a451ed2 100644 --- a/topology/test/test-playback-ssp.m4 +++ b/topology/test/test-playback-ssp.m4 @@ -53,7 +53,7 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-playback.m4, # playback DAI is SSP TEST_SSP_PORT using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, TEST_SSP_PORT, + 1, SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, PIPELINE_SOURCE_1, 2, TEST_SSP_FORMAT, 48, 1000, 0, 0) diff --git a/topology/test/test-ssp.m4 b/topology/test/test-ssp.m4 index 01e3a024a92a..fa5fd29b85c8 100644 --- a/topology/test/test-ssp.m4 +++ b/topology/test/test-ssp.m4 @@ -64,14 +64,14 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-capture.m4, # playback DAI is SSP TEST_SSP_PORT using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, TEST_SSP_PORT, + 1, SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, PIPELINE_SOURCE_1, 2, TEST_SSP_FORMAT, 48, 1000, 0, 0) # capture DAI is SSP TEST_SSP_PORT using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, TEST_SSP_PORT, + 2, SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, PIPELINE_SINK_2, 2, TEST_SSP_FORMAT, 48, 1000, 0, 0) diff --git a/topology/test/test-tone-playback-ssp.m4 b/topology/test/test-tone-playback-ssp.m4 index 92313162ba81..7cf1ed5005cf 100644 --- a/topology/test/test-tone-playback-ssp.m4 +++ b/topology/test/test-tone-playback-ssp.m4 @@ -45,7 +45,7 @@ PIPELINE_ADD(sof/pipe-tone.m4, # playback DAI is SSP2 using 2 periods # Buffers use TEST_SSP_FORMAT format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 5, SSP, TEST_SSP_PORT, + 5, SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, PIPELINE_SOURCE_5, 2, TEST_SSP_FORMAT, 48, 1000, 2, 0) From 9b220db8790469f5c11f4f7982ae45b00ace1e0d Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 15 Mar 2018 11:40:09 +0000 Subject: [PATCH 124/324] topology: byt-rt5640. Fix DAI stream name. Stream name should match bytcr driver and not legacy byt-rt5640 driver. Signed-off-by: Liam Girdwood --- topology/reef-byt-rt5640.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index c971d4103919..879e9a9074e7 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-byt-rt5640" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, Audio + 1, SSP, 2, SSP-Codec PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, Audio, + 2, SSP, 2, SSP-Codec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) From 6e82dfb5d1bb92b966dfd50c537ae0f566909a7c Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 15 Mar 2018 16:55:38 +0000 Subject: [PATCH 125/324] topology: byt-da7213: fix topology file name. reef-byt-da7212 -> reef-byt->da7213 Signed-off-by: Liam Girdwood --- topology/Makefile.am | 4 ++-- topology/{reef-byt-da7212.m4 => reef-byt-da7213.m4} | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) rename topology/{reef-byt-da7212.m4 => reef-byt-da7213.m4} (97%) diff --git a/topology/Makefile.am b/topology/Makefile.am index a62aa789139c..f161ba267e6c 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -26,7 +26,7 @@ MACHINES = \ reef-byt-rt5640.tplg \ reef-byt-rt5645.tplg \ reef-byt-rt5651.tplg \ - reef-byt-da7212.tplg \ + reef-byt-da7213.tplg \ reef-cnl-rt274.tplg \ reef-hsw-rt5640.tplg @@ -56,6 +56,6 @@ EXTRA_DIST = \ reef-byt-rt5640.m4 \ reef-byt-rt5645.m4 \ reef-byt-rt5651.m4 \ - reef-byt-da7212.m4 \ + reef-byt-da7213.m4 \ reef-cnl-rt274.m4 \ reef-hsw-rt5640.m4 diff --git a/topology/reef-byt-da7212.m4 b/topology/reef-byt-da7213.m4 similarity index 97% rename from topology/reef-byt-da7212.m4 rename to topology/reef-byt-da7213.m4 index a9789c627f50..1e77e7ed67bd 100644 --- a/topology/reef-byt-da7212.m4 +++ b/topology/reef-byt-da7213.m4 @@ -1,5 +1,5 @@ # -# Topology for generic Baytrail board with no codec. +# Topology for generic Baytrail board with DA7213 codec. # # Include topology builder From dcee7c1c53e3e6b6d3bdad1902a665e4c1578c08 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 15 Mar 2018 21:20:12 +0000 Subject: [PATCH 126/324] topology: byt-rt5640: Fix DAI config DAI config was coming from deprecated machine driver. Fix it to use bytcr-rt5640 machine driver. Signed-off-by: Liam Girdwood --- topology/reef-byt-rt5640.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index 879e9a9074e7..d301ea6441ec 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -1,5 +1,5 @@ # -# Topology for generic Baytrail board with no codec. +# Topology for generic Baytrail board with RT5640. # # Include topology builder @@ -76,7 +76,7 @@ SectionGraph."pipe-byt-rt5640" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, SSP-Codec + 1, SSP, 2, SSP-Codec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, Baytrail Audio, I2S, 24, +DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, DAI_CLOCK(mclk, 19200000, slave), DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), From d041c6f42dab3e4d6d14d35b2ba44d1f4137fb14 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 16 Mar 2018 11:59:24 +0000 Subject: [PATCH 127/324] topology: byt-rt5640: rt5640 uses SSP2-Codec Signed-off-by: Liam Girdwood --- topology/reef-byt-rt5640.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/reef-byt-rt5640.m4 b/topology/reef-byt-rt5640.m4 index d301ea6441ec..14313db0ee95 100644 --- a/topology/reef-byt-rt5640.m4 +++ b/topology/reef-byt-rt5640.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-byt-rt5640" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, SSP-Codec, + 1, SSP, 2, SSP2-Codec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, SSP-Codec, + 2, SSP, 2, SSP2-Codec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) From 07d025363a07dd0ad7ae5e2e13728cb5b732c9ed Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 16 Mar 2018 12:00:04 +0000 Subject: [PATCH 128/324] topology: remove deprecated drivers from test topologies Signed-off-by: Liam Girdwood --- topology/test/tplg-build.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 16d3630cc98d..b042909500a8 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -96,13 +96,6 @@ simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 -simple_test baytrail passthrough "Baytrail Audio" s16le 2 s16le 20 16 1920000 19200000 -simple_test baytrail passthrough "Baytrail Audio" s24le 2 s24le 25 24 2400000 19200000 -simple_test baytrail volume "Baytrail Audio" s16le 2 s16le 20 16 1920000 19200000 -simple_test baytrail volume "Baytrail Audio" s24le 2 s24le 25 24 2400000 19200000 -simple_test baytrail volume "Baytrail Audio" s16le 2 s24le 25 24 2400000 19200000 -simple_test baytrail src "Baytrail Audio" s24le 2 s24le 25 24 2400000 19200000 - # for APL simple_test nocodec volume "NoCodec" s16le 4 s16le 16 16 1536000 24576000 simple_test codec volume "SSP4-Codec" s16le 4 s16le 16 16 1536000 24576000 From cc91c73aa3e91eea35abdeb76d578b97f718feff Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 16 Mar 2018 17:17:33 +0000 Subject: [PATCH 129/324] topology: pcm: Fix PCM ID for topologies > 1 PCM PCM number was not being preserved and was always zero. This would overwrite previous PCMs and cause the FW to return invalid PCM error messages. Signed-off-by: Liam Girdwood --- topology/m4/pcm.m4 | 36 +++++++++++------------ topology/sof/pipe-low-latency-capture.m4 | 6 ++-- topology/sof/pipe-low-latency-playback.m4 | 6 ++-- topology/sof/pipe-passthrough-capture.m4 | 6 ++-- topology/sof/pipe-passthrough-playback.m4 | 6 ++-- topology/sof/pipe-pcm-media.m4 | 6 ++-- topology/sof/pipe-src-capture.m4 | 6 ++-- topology/sof/pipe-src-playback.m4 | 6 ++-- topology/sof/pipe-volume-capture.m4 | 6 ++-- topology/sof/pipe-volume-playback.m4 | 6 ++-- 10 files changed, 45 insertions(+), 45 deletions(-) diff --git a/topology/m4/pcm.m4 b/topology/m4/pcm.m4 index 596f2fe7c8b8..f77cb013c403 100644 --- a/topology/m4/pcm.m4 +++ b/topology/m4/pcm.m4 @@ -3,18 +3,18 @@ divert(-1) dnl Define the macro for PCM playback/capture/capabilities dnl PCM name) -define(`N_PCMP', `PCM'PCM_ID`P') -define(`N_PCMC', `PCM'PCM_ID`C') +define(`N_PCMP', `PCM'$1`P') +define(`N_PCMC', `PCM'$1`C') -dnl W_PCM_PLAYBACK(stream, dmac, dmac_chan, periods_sink, periods_source, preload) +dnl W_PCM_PLAYBACK(pcm, stream, dmac, dmac_chan, periods_sink, periods_source, preload) dnl PCM platform configuration define(`W_PCM_PLAYBACK', `SectionVendorTuples."'N_PCMP($1)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) ` }' `}' `SectionData."'N_PCMP($1)`_data_w_comp" {' @@ -23,18 +23,18 @@ define(`W_PCM_PLAYBACK', `SectionVendorTuples."'N_PCMP($1)`_tuples" {' ` tokens "sof_pcm_tokens"' ` tuples."word" {' -` SOF_TKN_PCM_DMAC' STR($2) -` SOF_TKN_PCM_DMAC_CHAN' STR($3) +` SOF_TKN_PCM_DMAC' STR($3) +` SOF_TKN_PCM_DMAC_CHAN' STR($4) ` }' `}' `SectionData."'N_PCMP($1)`_data" {' ` tuples "'N_PCMP($1)`_tuples"' `}' -`SectionWidget."'N_PCMP`" {' +`SectionWidget."'N_PCMP($1)`" {' ` index "'PIPELINE_ID`"' ` type "aif_in"' ` no_pm "true"' -` stream_name "'$1`"' +` stream_name "'$2`"' ` data [' ` "'N_PCMP($1)`_data"' ` "'N_PCMP($1)`_data_w_comp"' @@ -42,14 +42,14 @@ define(`W_PCM_PLAYBACK', `}') -dnl W_PCM_CAPTURE(stream, dmac, dmac_chan, periods_sink, periods_source, preload) +dnl W_PCM_CAPTURE(pcm, stream, dmac, dmac_chan, periods_sink, periods_source, preload) define(`W_PCM_CAPTURE', `SectionVendorTuples."'N_PCMC($1)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($4) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($5) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($6) +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) ` }' `}' `SectionData."'N_PCMC($1)`_data_w_comp" {' @@ -58,18 +58,18 @@ define(`W_PCM_CAPTURE', `SectionVendorTuples."'N_PCMC($1)`_tuples" {' ` tokens "sof_pcm_tokens"' ` tuples."word" {' -` SOF_TKN_PCM_DMAC' STR($2) -` SOF_TKN_PCM_DMAC_CHAN' STR($3) +` SOF_TKN_PCM_DMAC' STR($3) +` SOF_TKN_PCM_DMAC_CHAN' STR($4) ` }' `}' `SectionData."'N_PCMC($1)`_data" {' ` tuples "'N_PCMC($1)`_tuples"' `}' -`SectionWidget."'N_PCMC`" {' +`SectionWidget."'N_PCMC($1)`" {' ` index "'PIPELINE_ID`"' ` type "aif_out"' ` no_pm "true"' -` stream_name "'$1`"' +` stream_name "'$2`"' ` data [' ` "'N_PCMC($1)`_data"' ` "'N_PCMC($1)`_data_w_comp"' diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 5619999aaffc..96fa3ccb5dab 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -29,7 +29,7 @@ C_CONTROLMIXER(PCM PCM_ID Capture Volume, PIPELINE_ID, # Host "Low Latency Capture" PCM uses pipeline DMAC and channel # with 0 sink and 2 source periods -W_PCM_CAPTURE(Low Latency Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 0) +W_PCM_CAPTURE(PCM_ID, Low Latency Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 0) # "Capture Volume" has 2 sink and source periods for host and DAI ping-pong W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, LIST(` ', "PCM PCM_ID Capture Volume")) @@ -49,8 +49,8 @@ W_BUFFER(1, COMP_BUFFER_SIZE(2, P_GRAPH(pipe-ll-capture-PIPELINE_ID, PIPELINE_ID, LIST(` ', - `dapm(Low Latency Capture PCM_ID, N_PCMC)', - `dapm(N_PCMC, N_BUFFER(1))', + `dapm(Low Latency Capture PCM_ID, N_PCMC(PCM_ID))', + `dapm(N_PCMC(PCM_ID), N_BUFFER(1))', `dapm(N_BUFFER(1), N_PGA(0))', `dapm(N_PGA(0), N_BUFFER(0))')) diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index 4a4fca955396..b7f2d114ec1f 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -54,7 +54,7 @@ C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, # Host "Low latency Playback" PCM uses pipeline DMAC and channel # with 2 sink and 0 source periods -W_PCM_PLAYBACK(Low Latency Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) +W_PCM_PLAYBACK(PCM_ID, Low Latency Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Playback Volume" has 1 sink period and 2 source periods for host ping-pong W_PGA(0, PIPELINE_FORMAT, 1, 2, 1, LIST(` ', "PCM PCM_ID Playback Volume")) @@ -93,8 +93,8 @@ W_BUFFER(3, COMP_BUFFER_SIZE(2, P_GRAPH(pipe-ll-playback-PIPELINE_ID, PIPELINE_ID, LIST(` ', - `dapm(N_PCMP, Low Latency Playback PCM_ID)', - `dapm(N_BUFFER(0), N_PCMP)', + `dapm(N_PCMP(PCM_ID), Low Latency Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP(PCM_ID))', `dapm(N_PGA(0), N_BUFFER(0))', `dapm(N_BUFFER(1), N_PGA(0))', `dapm(N_MIXER(0), N_BUFFER(1))', diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index 07961b3f50f7..ff7c8420b2bf 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -17,7 +17,7 @@ include(`pipeline.m4') # Host "Passthrough Capture" PCM uses pipeline DMAC and channel # with 0 sink and 2 source periods -W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) +W_PCM_CAPTURE(PCM_ID, Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, @@ -41,8 +41,8 @@ W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHE P_GRAPH(pipe-pass-capture-PIPELINE_ID, PIPELINE_ID, LIST(` ', - `dapm(Passthrough Capture PCM_ID, N_PCMC)', - `dapm(N_PCMC, N_BUFFER(0))')) + `dapm(Passthrough Capture PCM_ID, N_PCMC(PCM_ID))', + `dapm(N_PCMC(PCM_ID), N_BUFFER(0))')) # # Pipeline Source and Sinks diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index 715fcee14506..84aa126ce5db 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -17,7 +17,7 @@ include(`pipeline.m4') # Host "Passthrough Playback" PCM uses pipeline DMAC and channel # with 2 sink and 0 source periods -W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) +W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, @@ -41,8 +41,8 @@ W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCH P_GRAPH(pipe-pass-playback-PIPELINE_ID, PIPELINE_ID, LIST(` ', - `dapm(N_PCMP, Passthrough Playback PCM_ID)', - `dapm(N_BUFFER(0), N_PCMP)')) + `dapm(N_PCMP(PCM_ID), Passthrough Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP(PCM_ID))')) # # Pipeline Source and Sinks diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index f2053b7cd337..1ca829fa41d3 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -41,7 +41,7 @@ W_DATA(media_src_conf, media_src_tokens) # Host "Low latency Playback" PCM uses pipeline DMAC and channel # with 2 sink and 0 source periods -W_PCM_PLAYBACK(Media Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) +W_PCM_PLAYBACK(PCM_ID, Media Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Playback Volume" has 2 sink period and 2 source periods for host ping-pong W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "PCM PCM_ID Playback Volume")) @@ -70,8 +70,8 @@ W_BUFFER(2, COMP_BUFFER_SIZE(3, P_GRAPH(pipe-media-PIPELINE_ID, PIPELINE_ID, LIST(` ', - `dapm(N_PCMP, Media Playback PCM_ID)', - `dapm(N_BUFFER(0), N_PCMP)', + `dapm(N_PCMP(PCM_ID), Media Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP(PCM_ID))', `dapm(N_PGA(0), N_BUFFER(0))', `dapm(N_BUFFER(1), N_PGA(0))', `dapm(N_SRC(0), N_BUFFER(1))' diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index 1b1a58d0235c..54eeea3f5004 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -18,7 +18,7 @@ include(`pipeline.m4') # Host "Passthrough Capture" PCM uses pipeline DMAC and channel # with 4 sink and 0 source periods -W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) +W_PCM_CAPTURE(PCM_ID, Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) # # SRC Configuration @@ -58,8 +58,8 @@ W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, P_GRAPH(pipe-pass-src-capture-PIPELINE_ID, PIPELINE_ID, LIST(` ', - `dapm(Passthrough Capture PCM_ID, N_PCMC)', - `dapm(N_PCMC, N_BUFFER(0))', + `dapm(Passthrough Capture PCM_ID, N_PCMC(PCM_ID))', + `dapm(N_PCMC(PCM_ID), N_BUFFER(0))', `dapm(N_BUFFER(0), N_SRC(0))', `dapm(N_SRC(0), N_BUFFER(1))')) diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index 9dfdcd80a10f..51237acf972c 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -18,7 +18,7 @@ include(`pipeline.m4') # Host "Passthrough Playback" PCM uses pipeline DMAC and channel # with 4 sink and 0 source periods -W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) +W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) # # SRC Configuration @@ -58,8 +58,8 @@ W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, P_GRAPH(pipe-pass-src-playback-PIPELINE_ID, PIPELINE_ID, LIST(` ', - `dapm(N_PCMP, Passthrough Playback PCM_ID)', - `dapm(N_BUFFER(0), N_PCMP)', + `dapm(N_PCMP(PCM_ID), Passthrough Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP(PCM_ID))', `dapm(N_SRC(0), N_BUFFER(0))', `dapm(N_BUFFER(1), N_SRC(0))')) diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 61b70a9def72..c3917ca6ecb3 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -31,7 +31,7 @@ C_CONTROLMIXER(Master Capture Volume, PIPELINE_ID, # Host "Passthrough Capture" PCM uses pipeline DMAC and channel # with 0 sink and 2 source periods -W_PCM_CAPTURE(Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) +W_PCM_CAPTURE(PCM_ID, Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) # "Volume" has 2 source and 2 sink periods W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Capture Volume")) @@ -63,8 +63,8 @@ W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, P_GRAPH(pipe-pass-vol-capture-PIPELINE_ID, PIPELINE_ID, LIST(` ', - `dapm(Passthrough Capture PCM_ID, N_PCMC)', - `dapm(N_PCMC, N_BUFFER(0))', + `dapm(Passthrough Capture PCM_ID, N_PCMC(PCM_ID))', + `dapm(N_PCMC(PCM_ID), N_BUFFER(0))', `dapm(N_BUFFER(0), N_PGA(0))', `dapm(N_PGA(0), N_BUFFER(1))')) diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 5fea0c7bfc30..194aad967afc 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -31,7 +31,7 @@ C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, # Host "Passthrough Playback" PCM uses pipeline DMAC and channel # with 2 sink and 0 source periods -W_PCM_PLAYBACK(Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) +W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Volume" has 2 source and 2 sink periods W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume")) @@ -63,8 +63,8 @@ W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, P_GRAPH(pipe-pass-vol-playback-PIPELINE_ID, PIPELINE_ID, LIST(` ', - `dapm(N_PCMP, Passthrough Playback PCM_ID)', - `dapm(N_BUFFER(0), N_PCMP)', + `dapm(N_PCMP(PCM_ID), Passthrough Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP(PCM_ID))', `dapm(N_PGA(0), N_BUFFER(0))', `dapm(N_BUFFER(1), N_PGA(0))')) From dbd15bb847ad6415eafc88d1e81a64a6b5ebac0d Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Sat, 17 Mar 2018 20:33:07 +0000 Subject: [PATCH 130/324] topology: media: fix incorrect pipeline ID for media PCM Missing include for pcm.m4 Signed-off-by: Liam Girdwood --- topology/sof/pipe-pcm-media.m4 | 1 + 1 file changed, 1 insertion(+) diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 1ca829fa41d3..9eaa187b54b3 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -14,6 +14,7 @@ include(`buffer.m4') include(`pga.m4') include(`mixercontrol.m4') include(`pipeline.m4') +include(`pcm.m4') # # Controls From 105c88febf1b974b9f03b02712dbc154eff5eb4d Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Mon, 19 Mar 2018 16:05:36 +0800 Subject: [PATCH 131/324] topology: Remove duplicate W_DAI_IN/OUT and W_PIPELINE We call PIPELINE_PCM_DAI_ADD and DAI_ADD that will duplicate call W_DAI_IN/OUT and W_PIPELINE. Signed-off-by: Pan Xiuli --- topology/sof/pipe-passthrough-capture.m4 | 10 ---------- topology/sof/pipe-passthrough-playback.m4 | 10 ---------- topology/sof/pipe-src-capture.m4 | 12 ------------ topology/sof/pipe-src-playback.m4 | 12 ------------ topology/sof/pipe-volume-capture.m4 | 12 ------------ topology/sof/pipe-volume-playback.m4 | 12 ------------ 6 files changed, 68 deletions(-) diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index ff7c8420b2bf..203003ce54c5 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -24,16 +24,6 @@ W_BUFFER(0, COMP_BUFFER_SIZE(2, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), PLATFORM_PASS_MEM_CAP) -# -# DAI definitions -# -W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, 2, 2, dai0c_plat_conf) - -# -# DAI pipeline - always use 0 for DAIs -# -W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, 0, pipe_dai_schedule_plat) - # # Pipeline Graph # diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index 84aa126ce5db..a2a88ad9f30e 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -24,16 +24,6 @@ W_BUFFER(0, COMP_BUFFER_SIZE(2, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), PLATFORM_PASS_MEM_CAP) -# -# DAI definitions -# -W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) - -# -# DAI pipeline - always use 0 for DAIs -# -W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, 0, pipe_dai_schedule_plat) - # # Pipeline Graph # diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index 54eeea3f5004..6211d33e62bf 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -39,18 +39,6 @@ W_BUFFER(1, COMP_BUFFER_SIZE(4, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), PLATFORM_DAI_MEM_CAP) -# -# DAI definitions -# -W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, DAI_PERIODS, - DAI_PERIODS, dai0c_plat_conf) - -# -# DAI pipeline -# -W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, - SCHEDULE_CORE, 0, pipe_dai_schedule_plat) - # # Pipeline Graph # diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index 51237acf972c..119ee2cbd0e8 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -39,18 +39,6 @@ W_BUFFER(1, COMP_BUFFER_SIZE(4, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), PLATFORM_DAI_MEM_CAP) -# -# DAI definitions -# -W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, DAI_PERIODS, - DAI_PERIODS, dai0p_plat_conf) - -# -# DAI pipeline -# -W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, - SCHEDULE_CORE, 0, pipe_dai_schedule_plat) - # # Pipeline Graph # diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index c3917ca6ecb3..5d1c24f515dc 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -44,18 +44,6 @@ W_BUFFER(1, COMP_BUFFER_SIZE(2, COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), PLATFORM_DAI_MEM_CAP) -# -# DAI definitions -# -W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, DAI_PERIODS, - DAI_PERIODS, dai0c_plat_conf) - -# -# DAI pipeline - always use 0 for DAIs -# -W_PIPELINE(N_DAI_IN, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, - SCHEDULE_CORE, 0, pipe_dai_schedule_plat) - # # Pipeline Graph # diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 194aad967afc..727490d9d965 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -44,18 +44,6 @@ W_BUFFER(1, COMP_BUFFER_SIZE(2, COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), PLATFORM_DAI_MEM_CAP) -# -# DAI definitions -# -W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, DAI_PERIODS, - DAI_PERIODS, dai0p_plat_conf) - -# -# DAI pipeline - always use 0 for DAIs -# -W_PIPELINE(N_DAI_OUT, SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, - SCHEDULE_CORE, 0, pipe_dai_schedule_plat) - # # Pipeline Graph # From b77473c0b2129082aa6492d5eac25fb8aa2a48b6 Mon Sep 17 00:00:00 2001 From: Wu Zhigang Date: Wed, 21 Mar 2018 18:49:31 +0800 Subject: [PATCH 132/324] topology: apl-tdf8532: create m4 file for gpmrb platform Here add topology file for apollolake GP-MRB platform, it is initial version, we only support one playback and one capture PCM pipeline at the moment, with SSP/DAI set to tdm8-32le-48kHz (active on first 4 slots for both transmit and receive). Signed-off-by: Wu Zhigang Reviewed-by: Keyon Jie --- topology/Makefile.am | 6 ++- topology/reef-apl-tdf8532.m4 | 71 ++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 topology/reef-apl-tdf8532.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index f161ba267e6c..a7e86fd76c87 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -28,7 +28,8 @@ MACHINES = \ reef-byt-rt5651.tplg \ reef-byt-da7213.tplg \ reef-cnl-rt274.tplg \ - reef-hsw-rt5640.tplg + reef-hsw-rt5640.tplg \ + reef-apl-tdf8532.tplg # Uncomment the following line if you want to debug conf files .PRECIOUS: %.conf @@ -58,4 +59,5 @@ EXTRA_DIST = \ reef-byt-rt5651.m4 \ reef-byt-da7213.m4 \ reef-cnl-rt274.m4 \ - reef-hsw-rt5640.m4 + reef-hsw-rt5640.m4 \ + reef-apl-tdf8532.m4 diff --git a/topology/reef-apl-tdf8532.m4 b/topology/reef-apl-tdf8532.m4 new file mode 100644 index 000000000000..eaddac9dbc10 --- /dev/null +++ b/topology/reef-apl-tdf8532.m4 @@ -0,0 +1,71 @@ +# +# Topology for generic Apollolake board with TDF8532 +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`dsps/bxt.m4') + +# +# Define the pipelines +# +# PCM0 ----> volume -----> SSP4 +# +# PCM1 <---- Volume <----- SSP4 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 4 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 1, 0, 4, s32le, + 48, 1000, 0, 0, 0, 1, SSP, 4, s32le, 2) + +# Low Latency capture pipeline 2 on PCM 0 using max 4 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 2, 0, 4, s32le, + 48, 1000, 0, 0, 0, 1, SSP, 4, s32le, 2) + +# +# DAI configuration +# +# SSP port 4 is our only pipeline DAI +# + +# playback DAI is SSP4 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 4, SSP4-Codec, + PIPELINE_SOURCE_1, 2, s32le, + 48, 1000, 0, 0) + +# capture DAI is SSP4 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, 4, SSP4-Codec, + PIPELINE_SINK_2, 2, s32le, + 48, 1000, 0, 0) + +# PCM Low Latency +PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + +# +# BE configurations - overrides config in ACPI if present +# +DAI_CONFIG(SSP, 4, SSP4-Codec, DSP_B, 32, + DAI_CLOCK(mclk, 24576000, slave), + DAI_CLOCK(bclk, 12288000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(8, 32, 15, 15)) From 149d7c36eaa60e27b7c991d18674fdb45a2fc9db Mon Sep 17 00:00:00 2001 From: "Keqiao.Zhang" Date: Thu, 22 Mar 2018 15:01:57 +0800 Subject: [PATCH 133/324] topology: test: add more topologies for test Signed-off-by: Keqiao.Zhang --- topology/test/tplg-build.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index b042909500a8..5a6a8f58a476 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -90,16 +90,35 @@ simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 19200000 simple_test nocodec src "NoCodec" s24le 2 s24le 25 24 2400000 19200000 simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 +simple_test codec passthrough "SSP2-Codec" s24le 2 s16le 20 16 1920000 19200000 +simple_test codec passthrough "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 +simple_test codec volume "SSP2-Codec" s24le 2 s16le 20 16 1920000 19200000 simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 # for APL simple_test nocodec volume "NoCodec" s16le 4 s16le 16 16 1536000 24576000 +simple_test nocodec volume "NoCodec" s24le 4 s16le 16 16 1536000 24576000 +simple_test nocodec volume "NoCodec" s32le 4 s16le 16 16 1536000 24576000 +simple_test nocodec volume "NoCodec" s16le 4 s24le 32 24 3072000 24576000 +simple_test nocodec volume "NoCodec" s24le 4 s24le 32 24 3072000 24576000 +simple_test nocodec volume "NoCodec" s32le 4 s24le 32 24 3072000 24576000 +simple_test nocodec volume "NoCodec" s16le 4 s32le 32 32 3072000 24576000 +simple_test nocodec volume "NoCodec" s24le 4 s32le 32 32 3072000 24576000 +simple_test nocodec volume "NoCodec" s32le 4 s32le 32 32 3072000 24576000 simple_test codec volume "SSP4-Codec" s16le 4 s16le 16 16 1536000 24576000 simple_test nocodec volume "NoCodec" s16le 5 s16le 16 16 1536000 24576000 +simple_test nocodec src "NoCodec" s24le 4 s24le 32 24 3072000 24576000 + +# for CNL +simple_test nocodec volume "NoCodec" s16le 2 s16le 25 16 2400000 24000000 +simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 24000000 +simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 24000000 +simple_test nocodec volume "NoCodec" s24le 2 s16le 25 16 2400000 24000000 +simple_test nocodec src "NoCodec" s24le 4 s24le 25 24 2400000 24000000 # Tone test: Tone component only supports s32le currently tone_test codec tone "SSP2-Codec" s32le 2 s16le 20 16 1920000 19200000 From 277b7a011a6340525d203d3ed43d72c13b1196a6 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 22 Mar 2018 17:55:48 +0800 Subject: [PATCH 134/324] topology: utils: add get format name helper function We may need to get format name from some format short name. Signed-off-by: Pan Xiuli --- topology/m4/utils.m4 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/topology/m4/utils.m4 b/topology/m4/utils.m4 index e929244fc6a4..ba87c8d1ee30 100644 --- a/topology/m4/utils.m4 +++ b/topology/m4/utils.m4 @@ -35,6 +35,15 @@ define(`COMP_SAMPLE_SIZE', $1, `float', `4', `4')') +dnl COMP_FORMAT_NAME(FMT) +define(`COMP_FORMAT_NAME', +`ifelse( + $1, `s16le', `S16_LE', + $1, `s24le', `S24_LE', + $1, `s32le', `S32_LE', + $1, `float', `FLOAT_LE', + )') + dnl P_GRAPH(name, CONNECTIONS) define(`P_GRAPH', `SectionGraph.STR($1) {' From b799e3fa3bab7f5df70f2458bda42de167e65fb3 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 22 Mar 2018 17:55:49 +0800 Subject: [PATCH 135/324] topology: modify passthrough pipelien PCM capabilities For passthrough PCM, we can only support the SSP DAI format as PCM capabilities. Signed-off-by: Pan Xiuli --- topology/sof/pipe-passthrough-capture.m4 | 2 +- topology/sof/pipe-passthrough-playback.m4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index 203003ce54c5..c6850f96bc2b 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -44,4 +44,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID # PCM Configuration # -PCM_CAPABILITIES(Passthrough Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Capture PCM_ID, COMP_FORMAT_NAME(PIPELINE_FORMAT), 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index a2a88ad9f30e..e2cd645fbdc9 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -44,4 +44,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # PCM Configuration # -PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Playback PCM_ID, COMP_FORMAT_NAME(PIPELINE_FORMAT), 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) From 0f9612cf9dc0bef16066d8c6ba8ef7112539c71c Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Thu, 22 Mar 2018 21:33:50 -0700 Subject: [PATCH 136/324] topology: modify tlv data to match volume range supported by firmware This patch modifies the tlv data for volume controls to match the volume range supported in the firmware. Signed-off-by: Ranjani Sridharan --- topology/common/tlv.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/topology/common/tlv.m4 b/topology/common/tlv.m4 index e591fa8116a4..f1a9effc3dfa 100644 --- a/topology/common/tlv.m4 +++ b/topology/common/tlv.m4 @@ -4,11 +4,11 @@ # SectionTLV."vtlv_m90s3" { - Comment "-90dB step 3dB" + Comment "-64dB step 2dB" scale { - min "-9000" - step "300" + min "-6400" + step "200" mute "1" } } From 49c1b450e635ac0c893d67ff0ddfd34e03a85b46 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 23 Mar 2018 21:44:25 +0000 Subject: [PATCH 137/324] topology: hsw/bdw: Use DMAC1 for host DMA DMAC0 missing some configuration so use DMAC1 Signed-off-by: Liam Girdwood --- topology/reef-bdw-rt286.m4 | 6 +++--- topology/reef-bdw-rt5640.m4 | 6 +++--- topology/reef-hsw-rt5640.m4 | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/topology/reef-bdw-rt286.m4 b/topology/reef-bdw-rt286.m4 index a305e7d7a8ce..c7dded6f9c2b 100644 --- a/topology/reef-bdw-rt286.m4 +++ b/topology/reef-bdw-rt286.m4 @@ -33,21 +33,21 @@ include(`dsps/bdw.m4') # Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) + 48, 1000, 0, 0, 1, 1) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) + 48, 1000, 0, 0, 1, 2) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 96, 2000, 1, 0, 0, 3) + 96, 2000, 1, 0, 1, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index 3fbb8444fde2..53c96104af93 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -33,21 +33,21 @@ include(`dsps/bdw.m4') # Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) + 48, 1000, 0, 0, 1, 1) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) + 48, 1000, 0, 0, 1, 2) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 96, 2000, 1, 0, 0, 3) + 96, 2000, 1, 0, 1, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/reef-hsw-rt5640.m4 b/topology/reef-hsw-rt5640.m4 index 5ab33ea14484..5516451820ad 100644 --- a/topology/reef-hsw-rt5640.m4 +++ b/topology/reef-hsw-rt5640.m4 @@ -33,21 +33,21 @@ include(`dsps/hsw.m4') # Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) + 48, 1000, 0, 0, 1, 1) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) + 48, 1000, 0, 0, 1, 2) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 # Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 192, 4000, 1, 0, 0, 3) + 192, 4000, 1, 0, 1, 3) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 From 73a454544c29afdd02bd55eb568be9a38ec354d8 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 28 Mar 2018 20:43:20 +0800 Subject: [PATCH 138/324] topology: append pipeline id to PGA and control mixer Signed-off-by: Keyon Jie --- topology/m4/mixercontrol.m4 | 2 +- topology/sof/pipe-low-latency-capture.m4 | 2 +- topology/sof/pipe-low-latency-playback.m4 | 4 ++-- topology/sof/pipe-pcm-media.m4 | 2 +- topology/sof/pipe-tone.m4 | 4 ++-- topology/sof/pipe-volume-capture.m4 | 2 +- topology/sof/pipe-volume-playback.m4 | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/topology/m4/mixercontrol.m4 b/topology/m4/mixercontrol.m4 index 77a378446c42..a3423c385746 100644 --- a/topology/m4/mixercontrol.m4 +++ b/topology/m4/mixercontrol.m4 @@ -30,7 +30,7 @@ define(`CONTROLMIXER_OPS', dnl C_CONTROLMIXER(name, index, ops, max, invert, tlv, KCONTROL_CHANNELS) define(`C_CONTROLMIXER', -`SectionControlMixer.STR($1) {' +`SectionControlMixer."$1 PIPELINE_ID" {' `' ` # control belongs to this index group' ` index STR($2)' diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 96fa3ccb5dab..39be2bc14fb4 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -32,7 +32,7 @@ C_CONTROLMIXER(PCM PCM_ID Capture Volume, PIPELINE_ID, W_PCM_CAPTURE(PCM_ID, Low Latency Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 0) # "Capture Volume" has 2 sink and source periods for host and DAI ping-pong -W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, LIST(` ', "PCM PCM_ID Capture Volume")) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, LIST(` ', "PCM PCM_ID Capture Volume PIPELINE_ID")) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index b7f2d114ec1f..b40b793ecc77 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -57,10 +57,10 @@ C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, W_PCM_PLAYBACK(PCM_ID, Low Latency Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Playback Volume" has 1 sink period and 2 source periods for host ping-pong -W_PGA(0, PIPELINE_FORMAT, 1, 2, 1, LIST(` ', "PCM PCM_ID Playback Volume")) +W_PGA(0, PIPELINE_FORMAT, 1, 2, 1, LIST(` ', "PCM PCM_ID Playback Volume PIPELINE_ID")) # "Master Playback Volume" has 1 source and 2 sink periods for DAI ping-pong -W_PGA(1, PIPELINE_FORMAT, 2, 1, 1, LIST(` ', "Master Playback Volume")) +W_PGA(1, PIPELINE_FORMAT, 2, 1, 1, LIST(` ', "Master Playback Volume PIPELINE_ID")) # Mixer 0 has 1 sink and source periods. W_MIXER(0, PIPELINE_FORMAT, 1, 1, 1) diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 9eaa187b54b3..7f68977d8aa8 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -45,7 +45,7 @@ W_DATA(media_src_conf, media_src_tokens) W_PCM_PLAYBACK(PCM_ID, Media Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Playback Volume" has 2 sink period and 2 source periods for host ping-pong -W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "PCM PCM_ID Playback Volume")) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "PCM PCM_ID Playback Volume PIPELINE_ID")) # "SRC 0" has 2 sink and source periods. W_SRC(0, PIPELINE_FORMAT, 2, 2, media_src_conf, 2) diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index 09ed32c7afaa..3cdd4085c182 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -20,7 +20,7 @@ include(`pipeline.m4') # # Volume Mixer control with max value of 32 -C_CONTROLMIXER(Tone Volume PIPELINE_ID, PIPELINE_ID, +C_CONTROLMIXER(Tone Volume, PIPELINE_ID, CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), CONTROLMIXER_MAX(, 32), false, @@ -29,7 +29,7 @@ C_CONTROLMIXER(Tone Volume PIPELINE_ID, PIPELINE_ID, LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) # Switch type Mixer Control with max value of 1 -C_CONTROLMIXER(Tone Switch PIPELINE_ID, PIPELINE_ID, +C_CONTROLMIXER(Tone Switch, PIPELINE_ID, CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), CONTROLMIXER_MAX(max 1 indicates switch type control, 1), false, diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 5d1c24f515dc..b3d320667312 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -34,7 +34,7 @@ C_CONTROLMIXER(Master Capture Volume, PIPELINE_ID, W_PCM_CAPTURE(PCM_ID, Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) # "Volume" has 2 source and 2 sink periods -W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Capture Volume")) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Capture Volume PIPELINE_ID")) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 727490d9d965..4b12d2acdb69 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -34,7 +34,7 @@ C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) # "Volume" has 2 source and 2 sink periods -W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume")) +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume PIPELINE_ID")) # Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, From 30aaefaea07e3108969edaf8d3564b1751e88545 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 28 Mar 2018 20:43:21 +0800 Subject: [PATCH 139/324] topology: pcm: add pipeline_id for stream name to avoid duplicate Signed-off-by: Keyon Jie --- topology/m4/pcm.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/m4/pcm.m4 b/topology/m4/pcm.m4 index f77cb013c403..40a3b17b52c0 100644 --- a/topology/m4/pcm.m4 +++ b/topology/m4/pcm.m4 @@ -34,7 +34,7 @@ define(`W_PCM_PLAYBACK', ` index "'PIPELINE_ID`"' ` type "aif_in"' ` no_pm "true"' -` stream_name "'$2`"' +` stream_name "'$2` '$1`"' ` data [' ` "'N_PCMP($1)`_data"' ` "'N_PCMP($1)`_data_w_comp"' @@ -69,7 +69,7 @@ define(`W_PCM_CAPTURE', ` index "'PIPELINE_ID`"' ` type "aif_out"' ` no_pm "true"' -` stream_name "'$2`"' +` stream_name "'$2` '$1`"' ` data [' ` "'N_PCMC($1)`_data"' ` "'N_PCMC($1)`_data_w_comp"' From 0d63b75d1e74e2fcb9508fc1585db983c7fb3482 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 28 Mar 2018 20:43:22 +0800 Subject: [PATCH 140/324] topology: reef-apl-nocodec: use SSP4 for playback and SSP2 for both Signed-off-by: Keyon Jie --- topology/reef-apl-nocodec.m4 | 96 ++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 53 deletions(-) diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index 78a1a4eb117d..72eff0e43dce 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -19,82 +19,72 @@ include(`dsps/bxt.m4') # # Define the pipelines # -# PCM0 ----> volume ---------------+ -# |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ -# | -# Tone -----> volume ----+ -# -# PCM1 <---- Volume <---- SSP2 +# PCM0 ----> Volume ----> SSP4 +# PCM1 ----> Volume ----> SSP2 +# PCM2 <---- Volume <---- SSP2 # -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Volume playback pipeline 1 on PCM 0 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, - 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 1, 0, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 4, s16le, 2) -# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. +# Volume playback pipeline 1 on PCM 0 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) - -# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 1, 2, s32le, - 96, 2000, 1, 0, 0, 3) - -# Tone Playback pipeline 5 using max 2 channels of s32le. -# Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, - 5, 2, s32le, - 192, 4000, 2, 0) - -# Connect pipelines together -SectionGraph."pipe-apl-nocodec" { - index "0" +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 2, 1, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 2, s16le, 2) - lines [ - # media 0 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - #tone - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) - ] -} +# Volume playback pipeline 1 on PCM 0 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 2 for PCM audio capture data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 3, 1, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 2, s16le, 2) # # DAI configuration # -# SSP port 2 is our only pipeline DAI -# + +# playback DAI is SSP4 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 4, SSP4-NoCodec, + PIPELINE_SOURCE_1, 2, s16le, + 48, 1000, 0, 0) # playback DAI is SSP2 using 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, NoCodec, - PIPELINE_SOURCE_1, 2, s24le, + 2, SSP, 2, SSP4-NoCodec, + PIPELINE_SOURCE_2, 2, s16le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, NoCodec, - PIPELINE_SINK_2, 2, s24le, + 3, SSP, 2, SSP2-NoCodec, + PIPELINE_SINK_3, 2, s16le, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_PLAYBACK_ADD(Port4, 1, 0, 0, PIPELINE_PCM_1) +PCM_DUPLEX_ADD(Port2, 4, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), +DAI_CONFIG(SSP, 2, SSP2-NoCodec, I2S, 16, + DAI_CLOCK(mclk, 24576000, slave), + DAI_CLOCK(bclk, 1536000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 16, 3, 3)) + +DAI_CONFIG(SSP, 4, SSP4-NoCodec, I2S, 16, + DAI_CLOCK(mclk, 24576000, slave), + DAI_CLOCK(bclk, 1536000, slave), DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 25, 3, 3)) + DAI_TDM(2, 16, 3, 3)) From 739acd1e5e542b09f7b204f44350d676dacf0000 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 28 Mar 2018 22:11:18 +0800 Subject: [PATCH 141/324] topology: apl-tdf8532: add support for SSP2-Codec Signed-off-by: Keyon Jie --- topology/reef-apl-tdf8532.m4 | 48 +++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/topology/reef-apl-tdf8532.m4 b/topology/reef-apl-tdf8532.m4 index eaddac9dbc10..50023f03bd4a 100644 --- a/topology/reef-apl-tdf8532.m4 +++ b/topology/reef-apl-tdf8532.m4 @@ -20,8 +20,8 @@ include(`dsps/bxt.m4') # Define the pipelines # # PCM0 ----> volume -----> SSP4 -# -# PCM1 <---- Volume <----- SSP4 +# PCM1 ----> volume -----> SSP2 +# PCM2 <---- Volume <----- SSP2 # # Low Latency playback pipeline 1 on PCM 0 using max 4 channels of s32le. @@ -31,18 +31,22 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, 1, 0, 4, s32le, 48, 1000, 0, 0, 0, 1, SSP, 4, s32le, 2) -# Low Latency capture pipeline 2 on PCM 0 using max 4 channels of s32le. +# Low Latency playback pipeline 3 on PCM 1 using max 4 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, - 2, 0, 4, s32le, - 48, 1000, 0, 0, 0, 1, SSP, 4, s32le, 2) +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 2, 1, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 2, s16le, 2) +# Low Latency playback pipeline 1 on PCM 0 using max 4 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 3, 1, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 2, s16le, 2) # # DAI configuration # -# SSP port 4 is our only pipeline DAI -# # playback DAI is SSP4 using 2 periods # Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 @@ -51,15 +55,23 @@ DAI_ADD(sof/pipe-dai-playback.m4, PIPELINE_SOURCE_1, 2, s32le, 48, 1000, 0, 0) -# capture DAI is SSP4 using 2 periods -# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +# playback DAI is SSP2 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 2, SSP, 2, SSP2-Codec, + PIPELINE_SOURCE_2, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP2 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 4, SSP4-Codec, - PIPELINE_SINK_2, 2, s32le, + 3, SSP, 2, SSP2-Codec, + PIPELINE_SINK_3, 2, s16le, 48, 1000, 0, 0) -# PCM Low Latency -PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +# PCM Low Latency, id 0 +PCM_PLAYBACK_ADD(Port4, 1, 0, 0, PIPELINE_PCM_1) +PCM_DUPLEX_ADD(Port2, 4, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) # # BE configurations - overrides config in ACPI if present @@ -69,3 +81,9 @@ DAI_CONFIG(SSP, 4, SSP4-Codec, DSP_B, 32, DAI_CLOCK(bclk, 12288000, slave), DAI_CLOCK(fsync, 48000, slave), DAI_TDM(8, 32, 15, 15)) + +DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 16, + DAI_CLOCK(mclk, 24576000, slave), + DAI_CLOCK(bclk, 1536000, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, 16, 3, 3)) From 78ad1ccce5ac689680adc32f8136f5bf551b0f7c Mon Sep 17 00:00:00 2001 From: Tomasz Lauda Date: Thu, 29 Mar 2018 13:55:47 +0200 Subject: [PATCH 142/324] rmbox: Close opened files Input and output files in trace_read function should be closed after using. Signed-off-by: Tomasz Lauda --- rmbox/rmbox.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 115be8326c12..4df2ee1c5576 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -232,6 +232,10 @@ static int trace_read(const char *in_file, const char *out_file, double clk) addr += TRACE_BLOCK_SIZE; } + fclose(in_fd); + if (out_fd) + fclose(out_fd); + return 0; } From 3c71cf866c593bc878c130d4824aa01f681f677f Mon Sep 17 00:00:00 2001 From: "Keqiao.Zhang" Date: Fri, 30 Mar 2018 14:57:37 +0800 Subject: [PATCH 143/324] topology: ssp: add TEST_SSP_MODE for ssp to support more modes Signed-off-by: Keqiao.Zhang --- topology/test/test-capture-ssp.m4 | 3 +- topology/test/test-playback-ssp.m4 | 3 +- topology/test/test-ssp.m4 | 3 +- topology/test/tplg-build.sh | 69 ++++++++++++++++-------------- 4 files changed, 42 insertions(+), 36 deletions(-) diff --git a/topology/test/test-capture-ssp.m4 b/topology/test/test-capture-ssp.m4 index 3d10d7a2ee27..78b64798bbd0 100644 --- a/topology/test/test-capture-ssp.m4 +++ b/topology/test/test-capture-ssp.m4 @@ -28,6 +28,7 @@ include(`dsps/byt.m4') # TEST_SSP_BCLK - SSP BCLK in Hz # TEST_SSP_PHY_BITS - SSP physical slot size # TEST_SSP_DATA_BITS - SSP data slot size +# TEST_SSP_MODE - SSP mode e.g. I2S, LEFT_J, DSP_A and DSP_B # # @@ -67,7 +68,7 @@ PCM_CAPTURE_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_2) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # -DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, +DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/test/test-playback-ssp.m4 b/topology/test/test-playback-ssp.m4 index ab775a451ed2..e4b09ecf6b67 100644 --- a/topology/test/test-playback-ssp.m4 +++ b/topology/test/test-playback-ssp.m4 @@ -28,6 +28,7 @@ include(`dsps/byt.m4') # TEST_SSP_BCLK - SSP BCLK in Hz # TEST_SSP_PHY_BITS - SSP physical slot size # TEST_SSP_DATA_BITS - SSP data slot size +# TEST_SSP_MODE - SSP mode e.g. I2S, LEFT_J, DSP_A and DSP_B # # @@ -67,7 +68,7 @@ PCM_PLAYBACK_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # -DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, +DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/test/test-ssp.m4 b/topology/test/test-ssp.m4 index fa5fd29b85c8..676e19ba9ee1 100644 --- a/topology/test/test-ssp.m4 +++ b/topology/test/test-ssp.m4 @@ -28,6 +28,7 @@ include(`dsps/byt.m4') # TEST_SSP_BCLK - SSP BCLK in Hz # TEST_SSP_PHY_BITS - SSP physical slot size # TEST_SSP_DATA_BITS - SSP data slot size +# TEST_SSP_MODE - SSP mode e.g. I2S, LEFT_J, DSP_A and DSP_B # # @@ -85,7 +86,7 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # -DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, +DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), DAI_CLOCK(fsync, 48000, slave), diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 5a6a8f58a476..96f3f9fdcb85 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -28,11 +28,13 @@ TONE_TEST=test-tone-playback-ssp # 8) dai_data_bits - SSP number of valid data bits per slot/channel # 9) dai_bclk - SSP BCLK in HZ # 10) dai_mclk - SSP MCLK in HZ +# 11) SSP mode - SSP mode e.g. I2S, LEFT_J, DSP_A and DSP_B # + function simple_test { for i in ${SIMPLE_TESTS[@]} do - TFILE="$i$5-$2-$4-$6-48k-$1" + TFILE="$i$5-${11}-$2-$4-$6-48k-$1" echo "M4 pre-processing test $i -> ${TFILE}" m4 ${M4_FLAGS} \ -DTEST_PIPE_NAME="$2" \ @@ -44,6 +46,7 @@ function simple_test { -DTEST_SSP_MCLK=${10} \ -DTEST_SSP_PHY_BITS=$7 \ -DTEST_SSP_DATA_BITS=$8 \ + -DTEST_SSP_MODE=${11} \ $i.m4 > ${TFILE}.conf echo "Compiling test $i -> ${TFILE}.tplg" alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg @@ -82,43 +85,43 @@ function tone_test { } # Pre-process the simple tests -simple_test nocodec passthrough "NoCodec" s16le 2 s16le 20 16 1920000 19200000 -simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 19200000 -simple_test nocodec volume "NoCodec" s16le 2 s16le 20 16 1920000 19200000 -simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 19200000 -simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 19200000 -simple_test nocodec src "NoCodec" s24le 2 s24le 25 24 2400000 19200000 +simple_test nocodec passthrough "NoCodec" s16le 2 s16le 20 16 1920000 19200000 I2S +simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S +simple_test nocodec volume "NoCodec" s16le 2 s16le 20 16 1920000 19200000 I2S +simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S +simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 19200000 I2S +simple_test nocodec src "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S -simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 -simple_test codec passthrough "SSP2-Codec" s24le 2 s16le 20 16 1920000 19200000 -simple_test codec passthrough "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 -simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 -simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 -simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 -simple_test codec volume "SSP2-Codec" s24le 2 s16le 20 16 1920000 19200000 -simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 -simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 +simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 I2S +simple_test codec passthrough "SSP2-Codec" s24le 2 s16le 20 16 1920000 19200000 I2S +simple_test codec passthrough "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 I2S +simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S +simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 I2S +simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S +simple_test codec volume "SSP2-Codec" s24le 2 s16le 20 16 1920000 19200000 I2S +simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 I2S +simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S # for APL -simple_test nocodec volume "NoCodec" s16le 4 s16le 16 16 1536000 24576000 -simple_test nocodec volume "NoCodec" s24le 4 s16le 16 16 1536000 24576000 -simple_test nocodec volume "NoCodec" s32le 4 s16le 16 16 1536000 24576000 -simple_test nocodec volume "NoCodec" s16le 4 s24le 32 24 3072000 24576000 -simple_test nocodec volume "NoCodec" s24le 4 s24le 32 24 3072000 24576000 -simple_test nocodec volume "NoCodec" s32le 4 s24le 32 24 3072000 24576000 -simple_test nocodec volume "NoCodec" s16le 4 s32le 32 32 3072000 24576000 -simple_test nocodec volume "NoCodec" s24le 4 s32le 32 32 3072000 24576000 -simple_test nocodec volume "NoCodec" s32le 4 s32le 32 32 3072000 24576000 -simple_test codec volume "SSP4-Codec" s16le 4 s16le 16 16 1536000 24576000 -simple_test nocodec volume "NoCodec" s16le 5 s16le 16 16 1536000 24576000 -simple_test nocodec src "NoCodec" s24le 4 s24le 32 24 3072000 24576000 +simple_test nocodec volume "NoCodec" s16le 4 s16le 16 16 1536000 24576000 I2S +simple_test nocodec volume "NoCodec" s24le 4 s16le 16 16 1536000 24576000 I2S +simple_test nocodec volume "NoCodec" s32le 4 s16le 16 16 1536000 24576000 I2S +simple_test nocodec volume "NoCodec" s16le 4 s24le 32 24 3072000 24576000 I2S +simple_test nocodec volume "NoCodec" s24le 4 s24le 32 24 3072000 24576000 I2S +simple_test nocodec volume "NoCodec" s32le 4 s24le 32 24 3072000 24576000 I2S +simple_test nocodec volume "NoCodec" s16le 4 s32le 32 32 3072000 24576000 I2S +simple_test nocodec volume "NoCodec" s24le 4 s32le 32 32 3072000 24576000 I2S +simple_test nocodec volume "NoCodec" s32le 4 s32le 32 32 3072000 24576000 I2S +simple_test codec volume "SSP4-Codec" s16le 4 s16le 16 16 1536000 24576000 I2S +simple_test nocodec volume "NoCodec" s16le 5 s16le 16 16 1536000 24576000 I2S +simple_test nocodec src "NoCodec" s24le 4 s24le 32 24 3072000 24576000 I2S # for CNL -simple_test nocodec volume "NoCodec" s16le 2 s16le 25 16 2400000 24000000 -simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 24000000 -simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 24000000 -simple_test nocodec volume "NoCodec" s24le 2 s16le 25 16 2400000 24000000 -simple_test nocodec src "NoCodec" s24le 4 s24le 25 24 2400000 24000000 +simple_test nocodec volume "NoCodec" s16le 2 s16le 25 16 2400000 24000000 I2S +simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 24000000 I2S +simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 24000000 I2S +simple_test nocodec volume "NoCodec" s24le 2 s16le 25 16 2400000 24000000 I2S +simple_test nocodec src "NoCodec" s24le 4 s24le 25 24 2400000 24000000 I2S # Tone test: Tone component only supports s32le currently tone_test codec tone "SSP2-Codec" s32le 2 s16le 20 16 1920000 19200000 From 2bd31df02b059004a1a3e35eca9e4e7de3abaaeb Mon Sep 17 00:00:00 2001 From: "Keqiao.Zhang" Date: Fri, 30 Mar 2018 15:07:05 +0800 Subject: [PATCH 144/324] topology: test: add different ssp modes of topologies for test Signed-off-by: Keqiao.Zhang --- topology/test/tplg-build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 96f3f9fdcb85..5926ee746841 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -104,14 +104,17 @@ simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S # for APL simple_test nocodec volume "NoCodec" s16le 4 s16le 16 16 1536000 24576000 I2S +simple_test nocodec volume "NoCodec" s16le 4 s16le 16 16 1536000 24576000 DSP_A simple_test nocodec volume "NoCodec" s24le 4 s16le 16 16 1536000 24576000 I2S simple_test nocodec volume "NoCodec" s32le 4 s16le 16 16 1536000 24576000 I2S simple_test nocodec volume "NoCodec" s16le 4 s24le 32 24 3072000 24576000 I2S simple_test nocodec volume "NoCodec" s24le 4 s24le 32 24 3072000 24576000 I2S +simple_test nocodec volume "NoCodec" s24le 4 s24le 32 24 3072000 24576000 DSP_B simple_test nocodec volume "NoCodec" s32le 4 s24le 32 24 3072000 24576000 I2S simple_test nocodec volume "NoCodec" s16le 4 s32le 32 32 3072000 24576000 I2S simple_test nocodec volume "NoCodec" s24le 4 s32le 32 32 3072000 24576000 I2S simple_test nocodec volume "NoCodec" s32le 4 s32le 32 32 3072000 24576000 I2S +simple_test nocodec volume "NoCodec" s32le 4 s32le 32 32 3072000 24576000 LEFT_J simple_test codec volume "SSP4-Codec" s16le 4 s16le 16 16 1536000 24576000 I2S simple_test nocodec volume "NoCodec" s16le 5 s16le 16 16 1536000 24576000 I2S simple_test nocodec src "NoCodec" s24le 4 s24le 32 24 3072000 24576000 I2S From e2c5794d6ddb62ffcfe55b8cb4075c279ec2679a Mon Sep 17 00:00:00 2001 From: "Keqiao.Zhang" Date: Fri, 30 Mar 2018 16:55:26 +0800 Subject: [PATCH 145/324] topology: test: remove 2 unsupported passthrough tplg Signed-off-by: Keqiao.Zhang --- topology/test/tplg-build.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 5926ee746841..ff2d14431e33 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -93,8 +93,6 @@ simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 19200000 I2S simple_test nocodec src "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 I2S -simple_test codec passthrough "SSP2-Codec" s24le 2 s16le 20 16 1920000 19200000 I2S -simple_test codec passthrough "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 I2S simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 I2S simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S From 90e3a384395885af30c7f94115ce2a6e2b52277c Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 30 Mar 2018 14:12:54 +0100 Subject: [PATCH 146/324] Revert "topology: reef-apl-nocodec: use SSP4 for playback and SSP2 for both" This reverts commit 0d63b75d1e74e2fcb9508fc1585db983c7fb3482. Needs multi DAI support scheduled for 1.2 Signed-off-by: Liam Girdwood --- topology/reef-apl-nocodec.m4 | 96 ++++++++++++++++++++---------------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/topology/reef-apl-nocodec.m4 b/topology/reef-apl-nocodec.m4 index 72eff0e43dce..78a1a4eb117d 100644 --- a/topology/reef-apl-nocodec.m4 +++ b/topology/reef-apl-nocodec.m4 @@ -19,72 +19,82 @@ include(`dsps/bxt.m4') # # Define the pipelines # -# PCM0 ----> Volume ----> SSP4 -# PCM1 ----> Volume ----> SSP2 -# PCM2 <---- Volume <---- SSP2 +# PCM0 ----> volume ---------------+ +# |--low latency mixer ----> volume ----> SSP2 +# PCM2 ----> SRC -----> volume ----+ +# | +# Tone -----> volume ----+ +# +# PCM1 <---- Volume <---- SSP2 # -# Volume playback pipeline 1 on PCM 0 using max 2 channels of s16le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, - 1, 0, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 4, s16le, 2) - -# Volume playback pipeline 1 on PCM 0 using max 2 channels of s16le. +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, - 2, 1, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 2, s16le, 2) +PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0, 0, 1) -# Volume playback pipeline 1 on PCM 0 using max 2 channels of s16le. +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, - 3, 1, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 2, s16le, 2) +PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, + 2, 0, 2, s32le, + 48, 1000, 0, 0, 0, 2) + +# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. +# Schedule 96 frames per 2000us deadline on core 0 with priority 1 +# Use DMAC 0 channel 3 for PCM audio playback data +PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, + 3, 1, 2, s32le, + 96, 2000, 1, 0, 0, 3) + +# Tone Playback pipeline 5 using max 2 channels of s32le. +# Schedule 192 frames per 4000us deadline on core 0 with priority 2 +PIPELINE_ADD(sof/pipe-tone.m4, + 5, 2, s32le, + 192, 4000, 2, 0) + +# Connect pipelines together +SectionGraph."pipe-apl-nocodec" { + index "0" + + lines [ + # media 0 + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) + #tone + dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) + ] +} # # DAI configuration # - -# playback DAI is SSP4 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 4, SSP4-NoCodec, - PIPELINE_SOURCE_1, 2, s16le, - 48, 1000, 0, 0) +# SSP port 2 is our only pipeline DAI +# # playback DAI is SSP2 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 2, SSP, 2, SSP4-NoCodec, - PIPELINE_SOURCE_2, 2, s16le, + 1, SSP, 2, NoCodec, + PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 3, SSP, 2, SSP2-NoCodec, - PIPELINE_SINK_3, 2, s16le, + 2, SSP, 2, NoCodec, + PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) # PCM Low Latency -PCM_PLAYBACK_ADD(Port4, 1, 0, 0, PIPELINE_PCM_1) -PCM_DUPLEX_ADD(Port2, 4, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) +PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, SSP2-NoCodec, I2S, 16, - DAI_CLOCK(mclk, 24576000, slave), - DAI_CLOCK(bclk, 1536000, slave), - DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 16, 3, 3)) - -DAI_CONFIG(SSP, 4, SSP4-NoCodec, I2S, 16, - DAI_CLOCK(mclk, 24576000, slave), - DAI_CLOCK(bclk, 1536000, slave), +DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, + DAI_CLOCK(mclk, 19200000, slave), + DAI_CLOCK(bclk, 2400000, slave), DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 16, 3, 3)) + DAI_TDM(2, 25, 3, 3)) From 99c09871a85111e52d4fa68a4d6f96770d1aabbd Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 30 Mar 2018 14:24:03 +0100 Subject: [PATCH 147/324] topology: bdw-rt5640: Fix BE DAI name to match legacy driver Now matches legacy driver. Signed-off-by: Liam Girdwood --- topology/reef-bdw-rt5640.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/reef-bdw-rt5640.m4 b/topology/reef-bdw-rt5640.m4 index 53c96104af93..0a083e4cc7be 100644 --- a/topology/reef-bdw-rt5640.m4 +++ b/topology/reef-bdw-rt5640.m4 @@ -76,14 +76,14 @@ SectionGraph."pipe-bdw-rt5640" { # playback DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 0, Audio, + 1, SSP, 0, Codec, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP0 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 0, Audio, + 2, SSP, 0, Codec, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) From 4b8d6b5c601baf0d09c6395d78660d7dad35aa74 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Thu, 5 Apr 2018 11:21:02 +0100 Subject: [PATCH 148/324] dist: fix make dist for topology M4 Signed-off-by: Liam Girdwood --- topology/m4/Makefile.am | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/topology/m4/Makefile.am b/topology/m4/Makefile.am index 35b3f8105f87..d7b867f316cd 100644 --- a/topology/m4/Makefile.am +++ b/topology/m4/Makefile.am @@ -1,3 +1,11 @@ EXTRA_DIST = \ - build.m4 \ - local.m4 + buffer.m4 \ + dai.m4 \ + mixer.m4 \ + mixercontrol.m4 \ + pcm.m4 \ + pga.m4 \ + pipeline.m4 \ + src.m4 \ + tone.m4 \ + utils.m4 From c0857f17fafd9e0fb8f3dbca768c0b5a77860e38 Mon Sep 17 00:00:00 2001 From: "Keqiao.Zhang" Date: Tue, 10 Apr 2018 15:07:29 +0800 Subject: [PATCH 149/324] dist: fix make dist for tone topology M4 Signed-off-by: Keqiao.Zhang --- topology/test/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/topology/test/Makefile.am b/topology/test/Makefile.am index 49f224058572..565f222b935b 100644 --- a/topology/test/Makefile.am +++ b/topology/test/Makefile.am @@ -25,5 +25,6 @@ clean: EXTRA_DIST = \ test-capture-ssp.m4 \ test-playback-ssp.m4 \ + test-tone-playback-ssp.m4 \ test-ssp.m4 \ tplg-build.sh From 8e8cd884c36e297f5996a7bb4f1e830a0f1ee84c Mon Sep 17 00:00:00 2001 From: "Keqiao.Zhang" Date: Wed, 11 Apr 2018 13:28:22 +0800 Subject: [PATCH 150/324] Makefile: fix the make clean issue at the top-level directory make clean done at the top-level does not clean the topology/test directory, use clean-local instead of clean Signed-off-by: Keqiao.Zhang --- topology/Makefile.am | 2 +- topology/test/Makefile.am | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/Makefile.am b/topology/Makefile.am index a7e86fd76c87..31d266efc85b 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -42,7 +42,7 @@ MACHINES = \ all: ${MACHINES} -clean: +clean-local: rm -f *.conf rm -f *.tplg diff --git a/topology/test/Makefile.am b/topology/test/Makefile.am index 565f222b935b..61713f9f8dc2 100644 --- a/topology/test/Makefile.am +++ b/topology/test/Makefile.am @@ -17,7 +17,7 @@ DEPS = \ all : *.m4 ${DEPS} ./tplg-build.sh -clean: +clean-local: rm -f *.conf rm -f *.tplg From 4f6d459586c22a8c9d946ee821ccf9c1ce7804c7 Mon Sep 17 00:00:00 2001 From: Liam Girdwood Date: Fri, 13 Apr 2018 14:47:25 +0100 Subject: [PATCH 151/324] topology: rename topologies to use sof prefix Use sof- prefix instead of reef- Signed-off-by: Liam Girdwood --- topology/Makefile.am | 54 +++++----- topology/reef-bxt-nocodec.m4 | 100 ------------------ ...reef-apl-nocodec.m4 => sof-apl-nocodec.m4} | 0 ...reef-apl-tdf8532.m4 => sof-apl-tdf8532.m4} | 0 .../{reef-bdw-rt286.m4 => sof-bdw-rt286.m4} | 0 .../{reef-bdw-rt5640.m4 => sof-bdw-rt5640.m4} | 0 .../{reef-byt-da7213.m4 => sof-byt-da7213.m4} | 0 ...reef-byt-nocodec.m4 => sof-byt-nocodec.m4} | 0 .../{reef-byt-rt5640.m4 => sof-byt-rt5640.m4} | 0 .../{reef-byt-rt5645.m4 => sof-byt-rt5645.m4} | 0 .../{reef-byt-rt5651.m4 => sof-byt-rt5651.m4} | 0 ...ef-cht-max98090.m4 => sof-cht-max98090.m4} | 0 ...reef-cht-nocodec.m4 => sof-cht-nocodec.m4} | 0 .../{reef-cnl-rt274.m4 => sof-cnl-rt274.m4} | 0 .../{reef-hsw-rt5640.m4 => sof-hsw-rt5640.m4} | 0 15 files changed, 26 insertions(+), 128 deletions(-) delete mode 100644 topology/reef-bxt-nocodec.m4 rename topology/{reef-apl-nocodec.m4 => sof-apl-nocodec.m4} (100%) rename topology/{reef-apl-tdf8532.m4 => sof-apl-tdf8532.m4} (100%) rename topology/{reef-bdw-rt286.m4 => sof-bdw-rt286.m4} (100%) rename topology/{reef-bdw-rt5640.m4 => sof-bdw-rt5640.m4} (100%) rename topology/{reef-byt-da7213.m4 => sof-byt-da7213.m4} (100%) rename topology/{reef-byt-nocodec.m4 => sof-byt-nocodec.m4} (100%) rename topology/{reef-byt-rt5640.m4 => sof-byt-rt5640.m4} (100%) rename topology/{reef-byt-rt5645.m4 => sof-byt-rt5645.m4} (100%) rename topology/{reef-byt-rt5651.m4 => sof-byt-rt5651.m4} (100%) rename topology/{reef-cht-max98090.m4 => sof-cht-max98090.m4} (100%) rename topology/{reef-cht-nocodec.m4 => sof-cht-nocodec.m4} (100%) rename topology/{reef-cnl-rt274.m4 => sof-cnl-rt274.m4} (100%) rename topology/{reef-hsw-rt5640.m4 => sof-hsw-rt5640.m4} (100%) diff --git a/topology/Makefile.am b/topology/Makefile.am index 31d266efc85b..73e10e90e3e2 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -16,20 +16,19 @@ DEPS = \ # MACHINES = \ - reef-cht-nocodec.tplg \ - reef-cht-max98090.tplg \ - reef-apl-nocodec.tplg \ - reef-bxt-nocodec.tplg \ - reef-byt-nocodec.tplg \ - reef-bdw-rt286.tplg \ - reef-bdw-rt5640.tplg \ - reef-byt-rt5640.tplg \ - reef-byt-rt5645.tplg \ - reef-byt-rt5651.tplg \ - reef-byt-da7213.tplg \ - reef-cnl-rt274.tplg \ - reef-hsw-rt5640.tplg \ - reef-apl-tdf8532.tplg + sof-cht-nocodec.tplg \ + sof-cht-max98090.tplg \ + sof-apl-nocodec.tplg \ + sof-byt-nocodec.tplg \ + sof-bdw-rt286.tplg \ + sof-bdw-rt5640.tplg \ + sof-byt-rt5640.tplg \ + sof-byt-rt5645.tplg \ + sof-byt-rt5651.tplg \ + sof-byt-da7213.tplg \ + sof-cnl-rt274.tplg \ + sof-hsw-rt5640.tplg \ + sof-apl-tdf8532.tplg # Uncomment the following line if you want to debug conf files .PRECIOUS: %.conf @@ -47,17 +46,16 @@ clean-local: rm -f *.tplg EXTRA_DIST = \ - reef-cht-nocodec.m4 \ - reef-cht-max98090.m4 \ - reef-apl-nocodec.m4 \ - reef-bxt-nocodec.m4 \ - reef-byt-nocodec.m4 \ - reef-bdw-rt286.m4 \ - reef-bdw-rt5640.m4 \ - reef-byt-rt5640.m4 \ - reef-byt-rt5645.m4 \ - reef-byt-rt5651.m4 \ - reef-byt-da7213.m4 \ - reef-cnl-rt274.m4 \ - reef-hsw-rt5640.m4 \ - reef-apl-tdf8532.m4 + sof-cht-nocodec.m4 \ + sof-cht-max98090.m4 \ + sof-apl-nocodec.m4 \ + sof-byt-nocodec.m4 \ + sof-bdw-rt286.m4 \ + sof-bdw-rt5640.m4 \ + sof-byt-rt5640.m4 \ + sof-byt-rt5645.m4 \ + sof-byt-rt5651.m4 \ + sof-byt-da7213.m4 \ + sof-cnl-rt274.m4 \ + sof-hsw-rt5640.m4 \ + sof-apl-tdf8532.m4 diff --git a/topology/reef-bxt-nocodec.m4 b/topology/reef-bxt-nocodec.m4 deleted file mode 100644 index 7e2b624c73f9..000000000000 --- a/topology/reef-bxt-nocodec.m4 +++ /dev/null @@ -1,100 +0,0 @@ -# -# Topology for generic Broxton board with no codec. -# - -# Include topology builder -include(`utils.m4') -include(`dai.m4') -include(`pipeline.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include Broxton DSP configuration -include(`dsps/bxt.m4') - -# -# Define the pipelines -# -# PCM0 ----> volume ---------------+ -# |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ -# | -# Tone -----> volume ----+ -# -# PCM1 <---- Volume <---- SSP2 -# - -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, - 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) - -# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) - -# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. -# Schedule 192 frames per 4000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 1, 2, s32le, - 192, 4000, 1, 0, 0, 3) - -# Tone Playback pipeline 5 using max 2 channels of s32le. -# Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, - 5, 2, s32le, - 192, 4000, 2, 0) - -# Connect pipelines together -SectionGraph."pipe-bxt-nocodec" { - index "0" - - lines [ - # media 0 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - #tone - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) - ] -} - -# -# DAI configuration -# -# SSP port 2 is our only pipeline DAI -# - -# playback DAI is SSP2 using 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, NoCodec, - PIPELINE_SOURCE_1, 2, s24le, - 48, 1000, 0, 0) - -# capture DAI is SSP2 using 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, NoCodec, - PIPELINE_SINK_2, 2, s24le, - 48, 1000, 0, 0) - -# PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) - -# -# BE configurations - overrides config in ACPI if present -# -DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), - DAI_TDM(2, 25, 3, 3)) diff --git a/topology/reef-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 similarity index 100% rename from topology/reef-apl-nocodec.m4 rename to topology/sof-apl-nocodec.m4 diff --git a/topology/reef-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 similarity index 100% rename from topology/reef-apl-tdf8532.m4 rename to topology/sof-apl-tdf8532.m4 diff --git a/topology/reef-bdw-rt286.m4 b/topology/sof-bdw-rt286.m4 similarity index 100% rename from topology/reef-bdw-rt286.m4 rename to topology/sof-bdw-rt286.m4 diff --git a/topology/reef-bdw-rt5640.m4 b/topology/sof-bdw-rt5640.m4 similarity index 100% rename from topology/reef-bdw-rt5640.m4 rename to topology/sof-bdw-rt5640.m4 diff --git a/topology/reef-byt-da7213.m4 b/topology/sof-byt-da7213.m4 similarity index 100% rename from topology/reef-byt-da7213.m4 rename to topology/sof-byt-da7213.m4 diff --git a/topology/reef-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 similarity index 100% rename from topology/reef-byt-nocodec.m4 rename to topology/sof-byt-nocodec.m4 diff --git a/topology/reef-byt-rt5640.m4 b/topology/sof-byt-rt5640.m4 similarity index 100% rename from topology/reef-byt-rt5640.m4 rename to topology/sof-byt-rt5640.m4 diff --git a/topology/reef-byt-rt5645.m4 b/topology/sof-byt-rt5645.m4 similarity index 100% rename from topology/reef-byt-rt5645.m4 rename to topology/sof-byt-rt5645.m4 diff --git a/topology/reef-byt-rt5651.m4 b/topology/sof-byt-rt5651.m4 similarity index 100% rename from topology/reef-byt-rt5651.m4 rename to topology/sof-byt-rt5651.m4 diff --git a/topology/reef-cht-max98090.m4 b/topology/sof-cht-max98090.m4 similarity index 100% rename from topology/reef-cht-max98090.m4 rename to topology/sof-cht-max98090.m4 diff --git a/topology/reef-cht-nocodec.m4 b/topology/sof-cht-nocodec.m4 similarity index 100% rename from topology/reef-cht-nocodec.m4 rename to topology/sof-cht-nocodec.m4 diff --git a/topology/reef-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 similarity index 100% rename from topology/reef-cnl-rt274.m4 rename to topology/sof-cnl-rt274.m4 diff --git a/topology/reef-hsw-rt5640.m4 b/topology/sof-hsw-rt5640.m4 similarity index 100% rename from topology/reef-hsw-rt5640.m4 rename to topology/sof-hsw-rt5640.m4 From 935161d09fbd8bc93a7f808c2151dd37d6fcc617 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 12 Apr 2018 21:51:57 -0500 Subject: [PATCH 152/324] topology: test: generate more configurations for ApolloLake Disk space is cheap, life is short, let's just brute-force generate all the combinations supported on SSP. Testers should just pick from the generated configurations instead of adding their own changes to the tplg-build.sh file. Passthrough is special-cased since pipeline and DAI format need to match. The frequencies and DAI formats remain in clear-text and duplicated, we could optimize further but then it'd become unmaintainable. Next step is to add slave mode and make the frame rate vary. If this is deemed to heavy, we can define a 'make test' target to avoid generating all these files by default. Alternatively people can select the modes needed by just changing the APL_ arrays. Signed-off-by: Pierre-Louis Bossart --- topology/test/tplg-build.sh | 71 ++++++++++++++++++++++++++++--------- 1 file changed, 55 insertions(+), 16 deletions(-) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index ff2d14431e33..4a4348fe4abf 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -34,7 +34,7 @@ TONE_TEST=test-tone-playback-ssp function simple_test { for i in ${SIMPLE_TESTS[@]} do - TFILE="$i$5-${11}-$2-$4-$6-48k-$1" + TFILE="$i$5-${11}-$2-$4-$6-48k-$((${10} / 1000))k-$1" echo "M4 pre-processing test $i -> ${TFILE}" m4 ${M4_FLAGS} \ -DTEST_PIPE_NAME="$2" \ @@ -101,21 +101,60 @@ simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 I2S simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S # for APL -simple_test nocodec volume "NoCodec" s16le 4 s16le 16 16 1536000 24576000 I2S -simple_test nocodec volume "NoCodec" s16le 4 s16le 16 16 1536000 24576000 DSP_A -simple_test nocodec volume "NoCodec" s24le 4 s16le 16 16 1536000 24576000 I2S -simple_test nocodec volume "NoCodec" s32le 4 s16le 16 16 1536000 24576000 I2S -simple_test nocodec volume "NoCodec" s16le 4 s24le 32 24 3072000 24576000 I2S -simple_test nocodec volume "NoCodec" s24le 4 s24le 32 24 3072000 24576000 I2S -simple_test nocodec volume "NoCodec" s24le 4 s24le 32 24 3072000 24576000 DSP_B -simple_test nocodec volume "NoCodec" s32le 4 s24le 32 24 3072000 24576000 I2S -simple_test nocodec volume "NoCodec" s16le 4 s32le 32 32 3072000 24576000 I2S -simple_test nocodec volume "NoCodec" s24le 4 s32le 32 32 3072000 24576000 I2S -simple_test nocodec volume "NoCodec" s32le 4 s32le 32 32 3072000 24576000 I2S -simple_test nocodec volume "NoCodec" s32le 4 s32le 32 32 3072000 24576000 LEFT_J -simple_test codec volume "SSP4-Codec" s16le 4 s16le 16 16 1536000 24576000 I2S -simple_test nocodec volume "NoCodec" s16le 5 s16le 16 16 1536000 24576000 I2S -simple_test nocodec src "NoCodec" s24le 4 s24le 32 24 3072000 24576000 I2S +APL_PROTOCOL_TESTS=(I2S LEFT_J DSP_A DSP_B) +APL_SSP_TESTS=(0 1 2 3 4 5) +APL_MODE_TESTS=(volume src) +APL_FORMAT_TESTS=(s16le s24le s32le) + +for protocol in ${APL_PROTOCOL_TESTS[@]} +do + for ssp in ${APL_SSP_TESTS[@]} + do + for mode in ${APL_MODE_TESTS[@]} + do + for format in ${APL_FORMAT_TESTS[@]} + do + simple_test nocodec $mode "NoCodec" $format $ssp s16le 16 16 1536000 24576000 $protocol + simple_test nocodec $mode "NoCodec" $format $ssp s24le 32 24 3072000 24576000 $protocol + simple_test nocodec $mode "NoCodec" $format $ssp s32le 32 32 3072000 24576000 $protocol + + simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s16le 16 16 1536000 24576000 $protocol + simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s24le 32 24 3072000 24576000 $protocol + simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s32le 32 32 3072000 24576000 $protocol + done + done + simple_test nocodec passthrough "NoCodec" s16le $ssp s16le 16 16 1536000 24576000 $protocol + simple_test nocodec passthrough "NoCodec" s24le $ssp s24le 32 24 3072000 24576000 $protocol + simple_test nocodec passthrough "NoCodec" s32le $ssp s32le 32 32 3072000 24576000 $protocol + + simple_test codec passthrough "SSP${ssp}-Codec" s16le $ssp s16le 16 16 1536000 24576000 $protocol + simple_test codec passthrough "SSP${ssp}-Codec" s24le $ssp s24le 32 24 3072000 24576000 $protocol + simple_test codec passthrough "SSP${ssp}-Codec" s32le $ssp s32le 32 32 3072000 24576000 $protocol + done +done + +for protocol in ${APL_PROTOCOL_TESTS[@]} +do + for ssp in ${APL_SSP_TESTS[@]} + do + for mode in ${APL_MODE_TESTS[@]} + do + for format in ${APL_FORMAT_TESTS[@]} + do + simple_test nocodec $mode "NoCodec" $format $ssp s16le 20 16 1920000 19200000 $protocol + simple_test nocodec $mode "NoCodec" $format $ssp s24le 25 24 2400000 19200000 $protocol + + simple_test nocodec $mode "SSP${ssp}-Codec" $format $ssp s16le 20 16 1920000 19200000 $protocol + simple_test nocodec $mode "SSP${ssp}-Codec" $format $ssp s24le 25 24 2400000 19200000 $protocol + done + done + simple_test nocodec passthrough "NoCodec" s16le $ssp s16le 20 16 1920000 19200000 $protocol + simple_test nocodec passthrough "NoCodec" s24le $ssp s24le 25 24 2400000 19200000 $protocol + + simple_test codec passthrough "SSP${ssp}-Codec" s16le $ssp s16le 20 16 1920000 19200000 $protocol + simple_test codec passthrough "SSP${ssp}-Codec" s24le $ssp s24le 25 24 2400000 19200000 $protocol + done +done # for CNL simple_test nocodec volume "NoCodec" s16le 2 s16le 25 16 2400000 24000000 I2S From 6ad7a30c76d68af69c0df34ebb3c9ea2fa35a0ef Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 13 Apr 2018 12:14:22 -0500 Subject: [PATCH 153/324] topology: test: fix APL test loops Copy/paste mistake, fix. Signed-off-by: Pierre-Louis Bossart --- topology/test/tplg-build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 4a4348fe4abf..7c55fba8797e 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -144,8 +144,8 @@ do simple_test nocodec $mode "NoCodec" $format $ssp s16le 20 16 1920000 19200000 $protocol simple_test nocodec $mode "NoCodec" $format $ssp s24le 25 24 2400000 19200000 $protocol - simple_test nocodec $mode "SSP${ssp}-Codec" $format $ssp s16le 20 16 1920000 19200000 $protocol - simple_test nocodec $mode "SSP${ssp}-Codec" $format $ssp s24le 25 24 2400000 19200000 $protocol + simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s16le 20 16 1920000 19200000 $protocol + simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s24le 25 24 2400000 19200000 $protocol done done simple_test nocodec passthrough "NoCodec" s16le $ssp s16le 20 16 1920000 19200000 $protocol From b327539e98f1c84e3a131dd048460189a5de8c26 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 13 Apr 2018 19:43:27 -0500 Subject: [PATCH 154/324] kmod_scripts: handle nocodec machine driver make sure it's removed Signed-off-by: Pierre-Louis Bossart --- kmod_scripts/sof_remove.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/kmod_scripts/sof_remove.sh b/kmod_scripts/sof_remove.sh index 1ea0598d4683..74b94d507bc2 100755 --- a/kmod_scripts/sof_remove.sh +++ b/kmod_scripts/sof_remove.sh @@ -16,6 +16,7 @@ rmmod snd_soc_sst_bytcr_rt5651 rmmod snd_soc_sst_cht_bsw_rt5645 rmmod snd_soc_sst_cht_bsw_rt5670 rmmod snd_soc_sst_byt_cht_da7213 +rmmod snd_sof_nocodec rmmod snd_soc_rt5670 rmmod snd_soc_rt5645 From 13b56fa6047c566a8ba3edd0882ea786e595ee2a Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 27 Apr 2018 13:47:11 -0500 Subject: [PATCH 155/324] topology: mirror alsa-lib definitions for mclk/bclk ALSA-lib introduced new definitions to work around an logical inversion for master/slave definitions. see e.g. commit 3778a30bb00 ('ASoC: topology: Fix bclk and fsync inversion in set_link_hw_format()') Make sure clarifications are reflected in the topology files bclk/fsync slave -> codec_slave mclk slave -> codec_mclk_in This patch requires the use of the latest alsa-lib git master (v1.1.6 does not contain the relevant patches). This patch also requires an updated kernel. Signed-off-by: Pierre-Louis Bossart --- topology/sof-apl-nocodec.m4 | 6 +++--- topology/sof-apl-tdf8532.m4 | 12 ++++++------ topology/sof-bdw-rt286.m4 | 6 +++--- topology/sof-bdw-rt5640.m4 | 6 +++--- topology/sof-byt-da7213.m4 | 6 +++--- topology/sof-byt-nocodec.m4 | 6 +++--- topology/sof-byt-rt5640.m4 | 6 +++--- topology/sof-byt-rt5645.m4 | 6 +++--- topology/sof-byt-rt5651.m4 | 6 +++--- topology/sof-cht-max98090.m4 | 6 +++--- topology/sof-cht-nocodec.m4 | 6 +++--- topology/sof-cnl-rt274.m4 | 6 +++--- topology/sof-hsw-rt5640.m4 | 6 +++--- topology/test/test-capture-ssp.m4 | 6 +++--- topology/test/test-playback-ssp.m4 | 6 +++--- topology/test/test-ssp.m4 | 6 +++--- topology/test/test-tone-playback-ssp.m4 | 6 +++--- 17 files changed, 54 insertions(+), 54 deletions(-) diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 78a1a4eb117d..9c4286bc41a4 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -94,7 +94,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3)) diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index 50023f03bd4a..1ff0a0da50ea 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -77,13 +77,13 @@ PCM_DUPLEX_ADD(Port2, 4, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 4, SSP4-Codec, DSP_B, 32, - DAI_CLOCK(mclk, 24576000, slave), - DAI_CLOCK(bclk, 12288000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 12288000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(8, 32, 15, 15)) DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 16, - DAI_CLOCK(mclk, 24576000, slave), - DAI_CLOCK(bclk, 1536000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 1536000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 16, 3, 3)) diff --git a/topology/sof-bdw-rt286.m4 b/topology/sof-bdw-rt286.m4 index c7dded6f9c2b..a13a49c41b47 100644 --- a/topology/sof-bdw-rt286.m4 +++ b/topology/sof-bdw-rt286.m4 @@ -94,7 +94,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 0, Codec, I2S, 24, - DAI_CLOCK(mclk, 24000000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 24000000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3)) diff --git a/topology/sof-bdw-rt5640.m4 b/topology/sof-bdw-rt5640.m4 index 0a083e4cc7be..007944ab5ec4 100644 --- a/topology/sof-bdw-rt5640.m4 +++ b/topology/sof-bdw-rt5640.m4 @@ -94,7 +94,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 0, Codec, I2S, 24, - DAI_CLOCK(mclk, 24000000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 24000000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3)) diff --git a/topology/sof-byt-da7213.m4 b/topology/sof-byt-da7213.m4 index 1e77e7ed67bd..ecf90c65ee46 100644 --- a/topology/sof-byt-da7213.m4 +++ b/topology/sof-byt-da7213.m4 @@ -94,7 +94,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3)) diff --git a/topology/sof-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 index 3be5d00d0b0c..efa321bdd83e 100644 --- a/topology/sof-byt-nocodec.m4 +++ b/topology/sof-byt-nocodec.m4 @@ -94,7 +94,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3)) diff --git a/topology/sof-byt-rt5640.m4 b/topology/sof-byt-rt5640.m4 index 14313db0ee95..ae54969f17ad 100644 --- a/topology/sof-byt-rt5640.m4 +++ b/topology/sof-byt-rt5640.m4 @@ -94,7 +94,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3)) diff --git a/topology/sof-byt-rt5645.m4 b/topology/sof-byt-rt5645.m4 index 15cac48cef3e..364121f56d78 100644 --- a/topology/sof-byt-rt5645.m4 +++ b/topology/sof-byt-rt5645.m4 @@ -94,7 +94,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3)) diff --git a/topology/sof-byt-rt5651.m4 b/topology/sof-byt-rt5651.m4 index 0e76c5679ab9..be3d994434ca 100644 --- a/topology/sof-byt-rt5651.m4 +++ b/topology/sof-byt-rt5651.m4 @@ -94,8 +94,8 @@ PCM_DUPLEX_ADD(Low Latency, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3)) diff --git a/topology/sof-cht-max98090.m4 b/topology/sof-cht-max98090.m4 index ab1b6393e0de..7ba4df740e4b 100644 --- a/topology/sof-cht-max98090.m4 +++ b/topology/sof-cht-max98090.m4 @@ -94,7 +94,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 16, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 1920000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 1920000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 20, 3, 3)) diff --git a/topology/sof-cht-nocodec.m4 b/topology/sof-cht-nocodec.m4 index 3f61e4440390..a0eb9cd7de06 100644 --- a/topology/sof-cht-nocodec.m4 +++ b/topology/sof-cht-nocodec.m4 @@ -94,7 +94,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, - DAI_CLOCK(mclk, 19200000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3)) diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index 495fab387edc..89d5a259dd56 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -65,7 +65,7 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 0, SSP0-Codec, DSP_B, 24, - DAI_CLOCK(mclk, 24000000, slave), - DAI_CLOCK(bclk, 4800000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 24000000, codec_mclk_in), + DAI_CLOCK(bclk, 4800000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(4, 25, 3, 3)) diff --git a/topology/sof-hsw-rt5640.m4 b/topology/sof-hsw-rt5640.m4 index 5516451820ad..85b82090947f 100644 --- a/topology/sof-hsw-rt5640.m4 +++ b/topology/sof-hsw-rt5640.m4 @@ -94,7 +94,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 0, Codec, I2S, 24, - DAI_CLOCK(mclk, 24000000, slave), - DAI_CLOCK(bclk, 2400000, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, 24000000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3)) diff --git a/topology/test/test-capture-ssp.m4 b/topology/test/test-capture-ssp.m4 index 78b64798bbd0..6d666dc9e976 100644 --- a/topology/test/test-capture-ssp.m4 +++ b/topology/test/test-capture-ssp.m4 @@ -69,7 +69,7 @@ PCM_CAPTURE_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_2) # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), - DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), + DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/test-playback-ssp.m4 b/topology/test/test-playback-ssp.m4 index e4b09ecf6b67..5ee1b53dffe9 100644 --- a/topology/test/test-playback-ssp.m4 +++ b/topology/test/test-playback-ssp.m4 @@ -69,7 +69,7 @@ PCM_PLAYBACK_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1) # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), - DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_slave), + DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/test-ssp.m4 b/topology/test/test-ssp.m4 index 676e19ba9ee1..1bdce2f772bc 100644 --- a/topology/test/test-ssp.m4 +++ b/topology/test/test-ssp.m4 @@ -87,7 +87,7 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), - DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), + DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) diff --git a/topology/test/test-tone-playback-ssp.m4 b/topology/test/test-tone-playback-ssp.m4 index 7cf1ed5005cf..069ad6430605 100644 --- a/topology/test/test-tone-playback-ssp.m4 +++ b/topology/test/test-tone-playback-ssp.m4 @@ -57,7 +57,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), - DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), - DAI_CLOCK(fsync, 48000, slave), + DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), + DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) From d0f4aba9340d9f18206d639b3eff303142ef73b6 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Fri, 4 May 2018 11:04:49 -0700 Subject: [PATCH 156/324] topology: speed up topology build Speed up topology with batch processing of m4 files Signed-off-by: Ranjani Sridharan --- configure.ac | 2 ++ topology/test/Makefile.am | 4 ++- topology/test/tplg-build.sh | 65 ++++++++++++++++++++++++++----------- 3 files changed, 51 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index b95c44c55568..cc5e59e13140 100644 --- a/configure.ac +++ b/configure.ac @@ -5,6 +5,8 @@ AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_SRCDIR([rmbox/rmbox.c]) AC_CONFIG_HEADERS([config.h]) AC_CHECK_HEADER([sof/uapi/abi.h]) +AC_CHECK_PROG([XARGS], xargs, "yes", "no", [$PATH]) +AM_CONDITIONAL(XARGS, test "$XARGS" = "yes") AC_CANONICAL_HOST diff --git a/topology/test/Makefile.am b/topology/test/Makefile.am index 61713f9f8dc2..d494fcb5a5cb 100644 --- a/topology/test/Makefile.am +++ b/topology/test/Makefile.am @@ -3,7 +3,9 @@ # Dependencies # - +if XARGS +export USE_XARGS=yes +endif DEPS = \ ../dsps/*.m4 \ diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 7c55fba8797e..e32df816a45d 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -8,14 +8,14 @@ set -e # M4 preprocessor flags -M4_FLAGS="-I ../ -I ../m4 -I ../common" +export M4PATH="../:../m4:../common" # Simple component test cases # can be used on components with 1 sink and 1 source. SIMPLE_TESTS=(test-ssp test-capture-ssp test-playback-ssp) TONE_TEST=test-tone-playback-ssp - - +TEST_STRINGS="" +M4_STRINGS="" # process m4 simple tests - # simple_test(name, pipe_name, be_name, format, dai_id, dai_format, dai_phy_bits, dai_data_bits dai_bclk) # 1) name - test filename suffix @@ -35,21 +35,35 @@ function simple_test { for i in ${SIMPLE_TESTS[@]} do TFILE="$i$5-${11}-$2-$4-$6-48k-$((${10} / 1000))k-$1" - echo "M4 pre-processing test $i -> ${TFILE}" - m4 ${M4_FLAGS} \ - -DTEST_PIPE_NAME="$2" \ - -DTEST_DAI_LINK_NAME="$3" \ - -DTEST_SSP_PORT=$5 \ - -DTEST_SSP_FORMAT=$6 \ - -DTEST_PIPE_FORMAT=$4 \ - -DTEST_SSP_BCLK=$9 \ - -DTEST_SSP_MCLK=${10} \ - -DTEST_SSP_PHY_BITS=$7 \ - -DTEST_SSP_DATA_BITS=$8 \ - -DTEST_SSP_MODE=${11} \ - $i.m4 > ${TFILE}.conf - echo "Compiling test $i -> ${TFILE}.tplg" - alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg + if [ "$USE_XARGS" == "yes" ] + then + #create input string for batch m4 processing + M4_STRINGS+="-DTEST_PIPE_NAME=$2,-DTEST_DAI_LINK_NAME=$3\ + -DTEST_SSP_PORT=$5,-DTEST_SSP_FORMAT=$6\ + -DTEST_PIPE_FORMAT=$4,-DTEST_SSP_BCLK=$9\ + -DTEST_SSP_MCLK=${10},-DTEST_SSP_PHY_BITS=$7\ + -DTEST_SSP_DATA_BITS=$8,-DTEST_SSP_MODE=${11}\ + $i.m4,${TFILE}," + #create input string for batch processing of conf files + TEST_STRINGS+=${TFILE}"," + else + echo "M4 pre-processing test $i -> ${TFILE}" + m4 ${M4_FLAGS} \ + -DTEST_PIPE_NAME="$2" \ + -DTEST_DAI_LINK_NAME="$3" \ + -DTEST_SSP_PORT=$5 \ + -DTEST_SSP_FORMAT=$6 \ + -DTEST_PIPE_FORMAT=$4 \ + -DTEST_SSP_BCLK=$9 \ + -DTEST_SSP_MCLK=${10} \ + -DTEST_SSP_PHY_BITS=$7 \ + -DTEST_SSP_DATA_BITS=$8 \ + -DTEST_SSP_MODE=${11} \ + $i.m4 > ${TFILE}.conf + echo "Compiling test $i -> ${TFILE}.tplg" + alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg + fi + done } @@ -69,7 +83,7 @@ function simple_test { function tone_test { TFILE="$TONE_TEST$5-$2-$4-$6-48k-$1" echo "M4 pre-processing test $TONE_TEST -> ${TFILE}" - m4 ${M4_FLAGS} \ + m4 \ -DTEST_PIPE_NAME="$2" \ -DTEST_DAI_LINK_NAME="$3" \ -DTEST_SSP_PORT=$5 \ @@ -84,6 +98,8 @@ function tone_test { alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg } +echo "Preparing topology build input..." + # Pre-process the simple tests simple_test nocodec passthrough "NoCodec" s16le 2 s16le 20 16 1920000 19200000 I2S simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S @@ -166,4 +182,15 @@ simple_test nocodec src "NoCodec" s24le 4 s24le 25 24 2400000 24000000 I2S # Tone test: Tone component only supports s32le currently tone_test codec tone "SSP2-Codec" s32le 2 s16le 20 16 1920000 19200000 +if [ "$USE_XARGS" == "yes" ] +then + echo "Batch processing m4 files..." + M4_STRINGS=${M4_STRINGS%?}; + #m4 processing + echo $M4_STRINGS | tr " " "," | tr '\n' '\0' | xargs -P0 -d ',' -n12 bash -c 'm4 "${@:1:${#}-1}" > ${12}.conf' m4 + + #execute alsatplg to create topology binary + TEST_STRINGS=${TEST_STRINGS%?} + echo $TEST_STRINGS | tr '\n' '\0' | xargs -d ',' -P0 -n1 -I string alsatplg -v 1 -c string".conf" -o string".tplg" +fi From 86fe688a2b4f68a1ce87e0951686be12a00f1a3c Mon Sep 17 00:00:00 2001 From: Zhang Keqiao Date: Fri, 4 May 2018 13:23:48 +0800 Subject: [PATCH 157/324] topology: test: add some passthrough topologies for CNL Signed-off-by: Zhang Keqiao --- topology/test/tplg-build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index e32df816a45d..36b657ee7b27 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -173,6 +173,8 @@ do done # for CNL +simple_test nocodec passthrough "NoCodec" s16le 2 s16le 25 16 2400000 24000000 I2S +simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 24000000 I2S simple_test nocodec volume "NoCodec" s16le 2 s16le 25 16 2400000 24000000 I2S simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 24000000 I2S simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 24000000 I2S From 35420bec93f1cc7ba3aec4c754cf8025beeb7675 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Fri, 18 May 2018 16:56:46 +0800 Subject: [PATCH 158/324] topology: add virtual dapm route supported in topology file To reuse some machine drivers in Linux kernel without hacking dapm route info, some unsupported routes and widgets could be added in toplogy file. Signed-off-by: Rander Wang --- topology/m4/utils.m4 | 38 ++++++++++++++++++++++++++++++++++++++ topology/sof-cnl-rt274.m4 | 11 +++++++++++ 2 files changed, 49 insertions(+) diff --git a/topology/m4/utils.m4 b/topology/m4/utils.m4 index ba87c8d1ee30..8b397b627d52 100644 --- a/topology/m4/utils.m4 +++ b/topology/m4/utils.m4 @@ -70,5 +70,43 @@ define(`W_DATA', ` tuples STR($2)' `}') +dnl VIRTUAL_DAPM_ROUTE_OUT(name, dai type, dai index, direction, index) +define(`VIRTUAL_DAPM_ROUTE_OUT', +`SectionWidget.STR($1) {' +` index STR($5)' +` type "aif_out"' +` no_pm "true"' +`}' +`SectionGraph.STR($2) {' +` index STR($5)' +`' +` lines [' +` dapm($1,$2$3.$4)' +` ]' +`}') + +dnl VIRTUAL_DAPM_ROUTE_IN(name, dai type, dai index, direction, index) +define(`VIRTUAL_DAPM_ROUTE_IN', +`SectionWidget.STR($1) {' +` index STR($5)' +` type "aif_in"' +` no_pm "true"' +`}' +`SectionGraph.STR($2) {' +` index STR($5)' +`' +` lines [' +` dapm($2$3.$4, $1)' +` ]' +`}') + +dnl VIRTUAL_WIDGET(name, index) +define(`VIRTUAL_WIDGET', +`SectionWidget.STR($1) {' +` index STR($2)' +` type "mixer"' +` no_pm "true"' +`}') + divert(0) dnl diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index 89d5a259dd56..36cd91f5c68d 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -69,3 +69,14 @@ DAI_CONFIG(SSP, 0, SSP0-Codec, DSP_B, 24, DAI_CLOCK(bclk, 4800000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(4, 25, 3, 3)) + +VIRTUAL_DAPM_ROUTE_OUT(codec0_out, SSP, 0, OUT, 0) +VIRTUAL_DAPM_ROUTE_OUT(codec1_out, SSP, 0, OUT, 1) +VIRTUAL_DAPM_ROUTE_OUT(ssp0 Tx, SSP, 0, OUT, 2) +VIRTUAL_DAPM_ROUTE_OUT(Capture, SSP, 0, OUT, 3) +VIRTUAL_DAPM_ROUTE_OUT(SoC DMIC, SSP, 0, OUT, 4) +VIRTUAL_DAPM_ROUTE_IN(codec0_in, SSP, 0, IN, 5) +VIRTUAL_WIDGET(DMIC01 Rx, 6) +VIRTUAL_WIDGET(DMic, 7) +VIRTUAL_WIDGET(dmic01_hifi, 8) +VIRTUAL_WIDGET(ssp0 Rx, 9) From 04691ffbe55501e2a73fc5c03571f6d7c94f12c4 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 21 May 2018 10:49:10 -0700 Subject: [PATCH 159/324] topology: add ssp tokens defined in kernel UAPI header Signed-off-by: Ranjani Sridharan --- topology/sof/tokens.m4 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index 6b966b3c02e1..e9aa302a6c6d 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -54,3 +54,9 @@ SectionVendorTokens."sof_comp_tokens" { SOF_TKN_COMP_FORMAT "402" SOF_TKN_COMP_PRELOAD_COUNT "403" } + +SectionVendorTokens."sof_ssp_tokens" { + SOF_TKN_INTEL_SSP_MCLK_KEEP_ACTIVE "500" + SOF_TKN_INTEL_SSP_BCLK_KEEP_ACTIVE "501" + SOF_TKN_INTEL_SSP_FS_KEEP_ACTIVE "502" +} From 28ab096452cd947a3013582a391d9aa822bf55c2 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 21 May 2018 16:02:32 -0700 Subject: [PATCH 160/324] topology: scripts: modify simple_test function to be generic and remove tone_test function Make simple_test function generic by accepting the array of test cases as an argument. The tone_test function can be removed and replaced with the modified simple_test function and passing the required test case to generate the tone topology file. Signed-off-by: Ranjani Sridharan --- topology/test/tplg-build.sh | 118 ++++++++++++++---------------------- 1 file changed, 44 insertions(+), 74 deletions(-) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 36b657ee7b27..26c70add78f9 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -32,7 +32,8 @@ M4_STRINGS="" # function simple_test { - for i in ${SIMPLE_TESTS[@]} + TESTS=("${!12}") + for i in ${TESTS[@]} do TFILE="$i$5-${11}-$2-$4-$6-48k-$((${10} / 1000))k-$1" if [ "$USE_XARGS" == "yes" ] @@ -67,54 +68,23 @@ function simple_test { done } -# process m4 tone test - -# tone_test(name, pipe_name, be_name, format, dai_id, dai_format, dai_phy_bits, dai_data_bits dai_bclk) -# 1) name - test filename suffix -# 2) pipe_name - test component pipeline filename in sof/ -# 3) be_name - BE DAI link name in machine driver, used for matching -# 4) format - PCM sample format -# 5) dai_id - SSP port number -# 6) dai_format - SSP sample format -# 7) dai_phy_bits - SSP physical number of BLKCs per slot/channel -# 8) dai_data_bits - SSP number of valid data bits per slot/channel -# 9) dai_bclk - SSP BCLK in HZ -# 10) dai_mclk - SSP MCLK in HZ -# -function tone_test { - TFILE="$TONE_TEST$5-$2-$4-$6-48k-$1" - echo "M4 pre-processing test $TONE_TEST -> ${TFILE}" - m4 \ - -DTEST_PIPE_NAME="$2" \ - -DTEST_DAI_LINK_NAME="$3" \ - -DTEST_SSP_PORT=$5 \ - -DTEST_SSP_FORMAT=$6 \ - -DTEST_PIPE_FORMAT=$4 \ - -DTEST_SSP_BCLK=$9 \ - -DTEST_SSP_MCLK=${10} \ - -DTEST_SSP_PHY_BITS=$7 \ - -DTEST_SSP_DATA_BITS=$8 \ - $TONE_TEST.m4 > ${TFILE}.conf - echo "Compiling test $TONE_TEST -> ${TFILE}.tplg" - alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg -} - echo "Preparing topology build input..." # Pre-process the simple tests -simple_test nocodec passthrough "NoCodec" s16le 2 s16le 20 16 1920000 19200000 I2S -simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S -simple_test nocodec volume "NoCodec" s16le 2 s16le 20 16 1920000 19200000 I2S -simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S -simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 19200000 I2S -simple_test nocodec src "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S - -simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 I2S -simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S -simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 I2S -simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S -simple_test codec volume "SSP2-Codec" s24le 2 s16le 20 16 1920000 19200000 I2S -simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 I2S -simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S +simple_test nocodec passthrough "NoCodec" s16le 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s16le 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec src "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] + +simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s24le 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] # for APL APL_PROTOCOL_TESTS=(I2S LEFT_J DSP_A DSP_B) @@ -130,22 +100,22 @@ do do for format in ${APL_FORMAT_TESTS[@]} do - simple_test nocodec $mode "NoCodec" $format $ssp s16le 16 16 1536000 24576000 $protocol - simple_test nocodec $mode "NoCodec" $format $ssp s24le 32 24 3072000 24576000 $protocol - simple_test nocodec $mode "NoCodec" $format $ssp s32le 32 32 3072000 24576000 $protocol + simple_test nocodec $mode "NoCodec" $format $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec" $format $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec" $format $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s16le 16 16 1536000 24576000 $protocol - simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s24le 32 24 3072000 24576000 $protocol - simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s32le 32 32 3072000 24576000 $protocol + simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] done done - simple_test nocodec passthrough "NoCodec" s16le $ssp s16le 16 16 1536000 24576000 $protocol - simple_test nocodec passthrough "NoCodec" s24le $ssp s24le 32 24 3072000 24576000 $protocol - simple_test nocodec passthrough "NoCodec" s32le $ssp s32le 32 32 3072000 24576000 $protocol + simple_test nocodec passthrough "NoCodec" s16le $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec" s24le $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec" s32le $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s16le $ssp s16le 16 16 1536000 24576000 $protocol - simple_test codec passthrough "SSP${ssp}-Codec" s24le $ssp s24le 32 24 3072000 24576000 $protocol - simple_test codec passthrough "SSP${ssp}-Codec" s32le $ssp s32le 32 32 3072000 24576000 $protocol + simple_test codec passthrough "SSP${ssp}-Codec" s16le $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s24le $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s32le $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] done done @@ -157,32 +127,32 @@ do do for format in ${APL_FORMAT_TESTS[@]} do - simple_test nocodec $mode "NoCodec" $format $ssp s16le 20 16 1920000 19200000 $protocol - simple_test nocodec $mode "NoCodec" $format $ssp s24le 25 24 2400000 19200000 $protocol + simple_test nocodec $mode "NoCodec" $format $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec" $format $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] - simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s16le 20 16 1920000 19200000 $protocol - simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s24le 25 24 2400000 19200000 $protocol + simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] done done - simple_test nocodec passthrough "NoCodec" s16le $ssp s16le 20 16 1920000 19200000 $protocol - simple_test nocodec passthrough "NoCodec" s24le $ssp s24le 25 24 2400000 19200000 $protocol + simple_test nocodec passthrough "NoCodec" s16le $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec" s24le $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s16le $ssp s16le 20 16 1920000 19200000 $protocol - simple_test codec passthrough "SSP${ssp}-Codec" s24le $ssp s24le 25 24 2400000 19200000 $protocol + simple_test codec passthrough "SSP${ssp}-Codec" s16le $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s24le $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] done done # for CNL -simple_test nocodec passthrough "NoCodec" s16le 2 s16le 25 16 2400000 24000000 I2S -simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 24000000 I2S -simple_test nocodec volume "NoCodec" s16le 2 s16le 25 16 2400000 24000000 I2S -simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 24000000 I2S -simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 24000000 I2S -simple_test nocodec volume "NoCodec" s24le 2 s16le 25 16 2400000 24000000 I2S -simple_test nocodec src "NoCodec" s24le 4 s24le 25 24 2400000 24000000 I2S +simple_test nocodec passthrough "NoCodec" s16le 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s16le 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s24le 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec src "NoCodec" s24le 4 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] # Tone test: Tone component only supports s32le currently -tone_test codec tone "SSP2-Codec" s32le 2 s16le 20 16 1920000 19200000 +simple_test codec tone "SSP2-Codec" s32le 2 s16le 20 16 1920000 19200000 I2S TONE_TEST[@] if [ "$USE_XARGS" == "yes" ] then From 2c31bbdc20074077ec3a9d2c38ae8eeac688346f Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 24 May 2018 10:14:27 +0800 Subject: [PATCH 161/324] topology: change virtual widget types to non-DSP ones This means they won't be sent to firmware for components creation. Signed-off-by: Keyon Jie --- topology/m4/utils.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/topology/m4/utils.m4 b/topology/m4/utils.m4 index 8b397b627d52..73faae63daee 100644 --- a/topology/m4/utils.m4 +++ b/topology/m4/utils.m4 @@ -74,7 +74,7 @@ dnl VIRTUAL_DAPM_ROUTE_OUT(name, dai type, dai index, direction, index) define(`VIRTUAL_DAPM_ROUTE_OUT', `SectionWidget.STR($1) {' ` index STR($5)' -` type "aif_out"' +` type "output"' ` no_pm "true"' `}' `SectionGraph.STR($2) {' @@ -89,7 +89,7 @@ dnl VIRTUAL_DAPM_ROUTE_IN(name, dai type, dai index, direction, index) define(`VIRTUAL_DAPM_ROUTE_IN', `SectionWidget.STR($1) {' ` index STR($5)' -` type "aif_in"' +` type "input"' ` no_pm "true"' `}' `SectionGraph.STR($2) {' @@ -104,7 +104,7 @@ dnl VIRTUAL_WIDGET(name, index) define(`VIRTUAL_WIDGET', `SectionWidget.STR($1) {' ` index STR($2)' -` type "mixer"' +` type "out_drv"' ` no_pm "true"' `}') From 7ee114d2ed822a0dbfc0dc3a37fd5c4977e00be8 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 24 May 2018 10:14:28 +0800 Subject: [PATCH 162/324] topology: sof-apl-tdf8532: add virtual widgets and routes Add virtual widgets and routes to make it aligned with machine driver. Signed-off-by: Keyon Jie --- topology/sof-apl-tdf8532.m4 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index 1ff0a0da50ea..11299cd2254b 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -87,3 +87,27 @@ DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 16, DAI_CLOCK(bclk, 1536000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 16, 3, 3)) + +VIRTUAL_DAPM_ROUTE_IN(BtHfp_ssp0_in, SSP, 0, IN, 0) +VIRTUAL_DAPM_ROUTE_OUT(BtHfp_ssp0_out, SSP, 0, OUT, 1) +VIRTUAL_DAPM_ROUTE_IN(hdmi_ssp1_in, SSP, 1, IN, 2) +VIRTUAL_DAPM_ROUTE_IN(dirana_in, SSP, 2, IN, 3) +VIRTUAL_DAPM_ROUTE_IN(dirana_aux_in, SSP, 2, IN, 4) +VIRTUAL_DAPM_ROUTE_IN(dirana_tuner_in, SSP, 2, IN, 5) +VIRTUAL_DAPM_ROUTE_OUT(dirana_out, SSP, 2, OUT, 6) +VIRTUAL_DAPM_ROUTE_IN(Modem_ssp3_in, SSP, 3, IN, 7) +VIRTUAL_DAPM_ROUTE_OUT(Modem_ssp3_out, SSP, 3, OUT, 8) +VIRTUAL_DAPM_ROUTE_OUT(codec0_out, SSP, 4, OUT, 9) +VIRTUAL_DAPM_ROUTE_IN(TestPin_ssp5_in, SSP, 5, IN, 10) +VIRTUAL_DAPM_ROUTE_OUT(TestPin_ssp5_out, SSP, 5, OUT, 11) +VIRTUAL_WIDGET(ssp0 Tx, 12) +VIRTUAL_WIDGET(ssp0 Rx, 13) +VIRTUAL_WIDGET(ssp1 Rx, 14) +VIRTUAL_WIDGET(ssp2 Tx, 15) +VIRTUAL_WIDGET(ssp2 Rx, 16) +VIRTUAL_WIDGET(ssp3 Tx, 17) +VIRTUAL_WIDGET(ssp3 Rx, 18) +VIRTUAL_WIDGET(ssp4 Tx, 19) +VIRTUAL_WIDGET(ssp5 Tx, 20) +VIRTUAL_WIDGET(ssp5 Rx, 21) + From ed3f3aa94a1675f2a2886b07f68dd9f458eb9503 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Tue, 29 May 2018 12:15:01 -0700 Subject: [PATCH 163/324] topology: tone pipeline should be DAI driver and not timer driven Signed-off-by: Ranjani Sridharan --- topology/sof/pipe-tone.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index 3cdd4085c182..53cef5a34964 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -77,4 +77,4 @@ indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(1)) # Pipeline Configuration. # -W_PIPELINE(N_TONE(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, 1, pipe_tone_schedule_plat) +W_PIPELINE(N_TONE(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHEDULE_CORE, 0, pipe_tone_schedule_plat) From ed471edb8fa311d5c326a85da9fdd15bb8dcf983 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 31 May 2018 22:27:43 +0800 Subject: [PATCH 164/324] topology: dai: add link_id for dai_link matching in DAI_CONFIG This is used for the matching with snd_soc_dai_link.id in BE dai_links. Signed-off-by: Keyon Jie --- topology/m4/dai.m4 | 11 ++++++----- topology/sof-apl-nocodec.m4 | 2 +- topology/sof-apl-tdf8532.m4 | 4 ++-- topology/sof-bdw-rt286.m4 | 2 +- topology/sof-bdw-rt5640.m4 | 2 +- topology/sof-byt-da7213.m4 | 2 +- topology/sof-byt-nocodec.m4 | 2 +- topology/sof-byt-rt5640.m4 | 2 +- topology/sof-byt-rt5645.m4 | 2 +- topology/sof-byt-rt5651.m4 | 2 +- topology/sof-cht-max98090.m4 | 2 +- topology/sof-cht-nocodec.m4 | 2 +- topology/sof-cnl-rt274.m4 | 2 +- topology/sof-hsw-rt5640.m4 | 2 +- topology/test/test-capture-ssp.m4 | 2 +- topology/test/test-playback-ssp.m4 | 2 +- topology/test/test-ssp.m4 | 2 +- topology/test/test-tone-playback-ssp.m4 | 2 +- 18 files changed, 24 insertions(+), 23 deletions(-) diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index 0b030afdd341..ba6cba41d692 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -140,17 +140,17 @@ define(`DAI_TDM', dnl DAI Config) define(`N_DAI_CONFIG', `DAICONFIG.'$1) -dnl DAI_CONFIG(type, idx, name, format, valid bits, mclk, bclk, fsync, tdm) +dnl DAI_CONFIG(type, idx, link_id, name, format, valid bits, mclk, bclk, fsync, tdm) define(`DAI_CONFIG', `SectionHWConfig."'$1$2`" {' `' ` id "'$2`"' -` format "'$4`"' +` format "'$5`"' `' -` '$6 ` '$7 ` '$8 ` '$9 +` '$10 `}' `SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples_str" {' ` tokens "sof_dai_tokens"' @@ -164,14 +164,15 @@ define(`DAI_CONFIG', `SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {' ` tokens "sof_dai_tokens"' ` tuples."word" {' -` SOF_TKN_DAI_SAMPLE_BITS' STR($5) +` SOF_TKN_DAI_SAMPLE_BITS' STR($6) ` }' `}' `SectionData."'N_DAI_CONFIG($1$2)`_data" {' ` tuples "'N_DAI_CONFIG($1$2)`_tuples"' `}' `' -`SectionBE."'$3`" {' +`SectionBE."'$4`" {' +` id "'$3`"' ` index "0"' ` default_hw_conf_id "'$2`"' `' diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 9c4286bc41a4..68380e4f24e6 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, +DAI_CONFIG(SSP, 2, 0, NoCodec, I2S, 24, DAI_CLOCK(mclk, 19200000, codec_mclk_in), DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index 11299cd2254b..b8973465570c 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -76,13 +76,13 @@ PCM_DUPLEX_ADD(Port2, 4, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 4, SSP4-Codec, DSP_B, 32, +DAI_CONFIG(SSP, 4, 4, SSP4-Codec, DSP_B, 32, DAI_CLOCK(mclk, 24576000, codec_mclk_in), DAI_CLOCK(bclk, 12288000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(8, 32, 15, 15)) -DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 16, +DAI_CONFIG(SSP, 2, 2, SSP2-Codec, I2S, 16, DAI_CLOCK(mclk, 24576000, codec_mclk_in), DAI_CLOCK(bclk, 1536000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-bdw-rt286.m4 b/topology/sof-bdw-rt286.m4 index a13a49c41b47..098d4c836107 100644 --- a/topology/sof-bdw-rt286.m4 +++ b/topology/sof-bdw-rt286.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, Codec, I2S, 24, +DAI_CONFIG(SSP, 0, 0, Codec, I2S, 24, DAI_CLOCK(mclk, 24000000, codec_mclk_in), DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-bdw-rt5640.m4 b/topology/sof-bdw-rt5640.m4 index 007944ab5ec4..bbbbbe4ccbe1 100644 --- a/topology/sof-bdw-rt5640.m4 +++ b/topology/sof-bdw-rt5640.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, Codec, I2S, 24, +DAI_CONFIG(SSP, 0, 0, Codec, I2S, 24, DAI_CLOCK(mclk, 24000000, codec_mclk_in), DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-byt-da7213.m4 b/topology/sof-byt-da7213.m4 index ecf90c65ee46..e3c79528d653 100644 --- a/topology/sof-byt-da7213.m4 +++ b/topology/sof-byt-da7213.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, +DAI_CONFIG(SSP, 2, 0, SSP2-Codec, I2S, 24, DAI_CLOCK(mclk, 19200000, codec_mclk_in), DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 index efa321bdd83e..5c65fb082397 100644 --- a/topology/sof-byt-nocodec.m4 +++ b/topology/sof-byt-nocodec.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, +DAI_CONFIG(SSP, 2, 0, NoCodec, I2S, 24, DAI_CLOCK(mclk, 19200000, codec_mclk_in), DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-byt-rt5640.m4 b/topology/sof-byt-rt5640.m4 index ae54969f17ad..7fae6f0618ac 100644 --- a/topology/sof-byt-rt5640.m4 +++ b/topology/sof-byt-rt5640.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, +DAI_CONFIG(SSP, 2, 0, SSP2-Codec, I2S, 24, DAI_CLOCK(mclk, 19200000, codec_mclk_in), DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-byt-rt5645.m4 b/topology/sof-byt-rt5645.m4 index 364121f56d78..7b81cbd2c78f 100644 --- a/topology/sof-byt-rt5645.m4 +++ b/topology/sof-byt-rt5645.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, +DAI_CONFIG(SSP, 2, 0, SSP2-Codec, I2S, 24, DAI_CLOCK(mclk, 19200000, codec_mclk_in), DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-byt-rt5651.m4 b/topology/sof-byt-rt5651.m4 index be3d994434ca..91324aec9196 100644 --- a/topology/sof-byt-rt5651.m4 +++ b/topology/sof-byt-rt5651.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 24, +DAI_CONFIG(SSP, 2, 0, SSP2-Codec, I2S, 24, DAI_CLOCK(mclk, 19200000, codec_mclk_in), DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-cht-max98090.m4 b/topology/sof-cht-max98090.m4 index 7ba4df740e4b..5fb7802c9db2 100644 --- a/topology/sof-cht-max98090.m4 +++ b/topology/sof-cht-max98090.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, SSP2-Codec, I2S, 16, +DAI_CONFIG(SSP, 2, 0, SSP2-Codec, I2S, 16, DAI_CLOCK(mclk, 19200000, codec_mclk_in), DAI_CLOCK(bclk, 1920000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-cht-nocodec.m4 b/topology/sof-cht-nocodec.m4 index a0eb9cd7de06..bd4d9697c8af 100644 --- a/topology/sof-cht-nocodec.m4 +++ b/topology/sof-cht-nocodec.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, NoCodec, I2S, 24, +DAI_CONFIG(SSP, 2, 0, NoCodec, I2S, 24, DAI_CLOCK(mclk, 19200000, codec_mclk_in), DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index 36cd91f5c68d..01cd20343ba9 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -64,7 +64,7 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, SSP0-Codec, DSP_B, 24, +DAI_CONFIG(SSP, 0, 0, SSP0-Codec, DSP_B, 24, DAI_CLOCK(mclk, 24000000, codec_mclk_in), DAI_CLOCK(bclk, 4800000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-hsw-rt5640.m4 b/topology/sof-hsw-rt5640.m4 index 85b82090947f..28d5c6ae7e7c 100644 --- a/topology/sof-hsw-rt5640.m4 +++ b/topology/sof-hsw-rt5640.m4 @@ -93,7 +93,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, Codec, I2S, 24, +DAI_CONFIG(SSP, 0, 0, Codec, I2S, 24, DAI_CLOCK(mclk, 24000000, codec_mclk_in), DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/test/test-capture-ssp.m4 b/topology/test/test-capture-ssp.m4 index 6d666dc9e976..67f0da92633b 100644 --- a/topology/test/test-capture-ssp.m4 +++ b/topology/test/test-capture-ssp.m4 @@ -68,7 +68,7 @@ PCM_CAPTURE_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_2) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # -DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, +DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/test/test-playback-ssp.m4 b/topology/test/test-playback-ssp.m4 index 5ee1b53dffe9..22943b0fdabc 100644 --- a/topology/test/test-playback-ssp.m4 +++ b/topology/test/test-playback-ssp.m4 @@ -68,7 +68,7 @@ PCM_PLAYBACK_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # -DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, +DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_slave), DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/test/test-ssp.m4 b/topology/test/test-ssp.m4 index 1bdce2f772bc..0b305e153539 100644 --- a/topology/test/test-ssp.m4 +++ b/topology/test/test-ssp.m4 @@ -86,7 +86,7 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # -DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, +DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/test/test-tone-playback-ssp.m4 b/topology/test/test-tone-playback-ssp.m4 index 069ad6430605..b08447ad5b39 100644 --- a/topology/test/test-tone-playback-ssp.m4 +++ b/topology/test/test-tone-playback-ssp.m4 @@ -56,7 +56,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT # -DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, +DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), From 885ae37f49fe2ade35ed3f32ffeeb5ba42ab8abe Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 31 May 2018 22:31:19 +0800 Subject: [PATCH 165/324] topology: bxt: change to use dmac0 for capture Otherwise, the channels may be used up when pipeline number > 8. Todo: remove dmac definition from tplg, just allocate them inside firmware. Signed-off-by: Keyon Jie --- topology/dsps/bxt.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/dsps/bxt.m4 b/topology/dsps/bxt.m4 index df61d1ac744d..472fa882fa10 100644 --- a/topology/dsps/bxt.m4 +++ b/topology/dsps/bxt.m4 @@ -34,7 +34,7 @@ W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC " W_DATA(dai0p_plat_conf, dai0p_plat_tokens) # DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) +W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "0"', `SOF_TKN_DAI_DMAC_CHAN "1"')) W_DATA(dai0c_plat_conf, dai0c_plat_tokens) From 0876e73f310d09d8402c0a4662fbdb2df76ca930 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Thu, 31 May 2018 22:31:20 +0800 Subject: [PATCH 166/324] Topology: sof-apl-tdf8532: enable all 6 SSPs and pipelines. Todo: to confirm and refine settings for each SSP/dai. Signed-off-by: Keyon Jie --- topology/sof-apl-tdf8532.m4 | 149 ++++++++++++++++++++++++++++++++++-- 1 file changed, 142 insertions(+), 7 deletions(-) diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index b8973465570c..c737a65369fa 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -20,8 +20,15 @@ include(`dsps/bxt.m4') # Define the pipelines # # PCM0 ----> volume -----> SSP4 -# PCM1 ----> volume -----> SSP2 -# PCM2 <---- Volume <----- SSP2 +# PCM1 ----> volume -----> SSP2(Dirana Pb) +# <---- Volume <----- SSP2(Dirana Cp) +# PCM2 ----> volume -----> SSP0(BT HFP out) +# <---- volume <----- SSP0(BT HFP in) +# PCM3 <---- Volume <----- SSP1(HDMI in) +# PCM4 ----> volume -----> SSP3(Modem out) +# <---- volume <----- SSP3(Modem in) +# PCM5 ----> volume -----> SSP5(TestPin out) +# <---- volume <----- SSP3(TestPin in) # # Low Latency playback pipeline 1 on PCM 0 using max 4 channels of s32le. @@ -31,21 +38,72 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, 1, 0, 4, s32le, 48, 1000, 0, 0, 0, 1, SSP, 4, s32le, 2) -# Low Latency playback pipeline 3 on PCM 1 using max 4 channels of s32le. +# Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, 2, 1, 2, s16le, 48, 1000, 0, 0, 0, 1, SSP, 2, s16le, 2) -# Low Latency playback pipeline 1 on PCM 0 using max 4 channels of s32le. +# Low Latency capture pipeline 3 on PCM 1 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, 3, 1, 2, s16le, 48, 1000, 0, 0, 0, 1, SSP, 2, s16le, 2) + +# Low Latency playback pipeline 4 on PCM 2 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 4, 2, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 0, s16le, 2) + +# Low Latency capture pipeline 5 on PCM 2 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 5, 2, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 0, s16le, 2) + +# Low Latency capture pipeline 6 on PCM 3 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 6, 3, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 1, s16le, 2) + +# Low Latency playback pipeline 7 on PCM 4 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 7, 4, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 3, s16le, 2) + +# Low Latency capture pipeline 8 on PCM 4 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 8, 4, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 3, s16le, 2) + +# Low Latency playback pipeline 9 on PCM 5 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 9, 5, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 5, s16le, 2) + +# Low Latency capture pipeline 10 on PCM 5 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 10, 5, 2, s16le, + 48, 1000, 0, 0, 0, 1, SSP, 5, s16le, 2) + + # -# DAI configuration +# DAIs configuration # # playback DAI is SSP4 using 2 periods @@ -69,9 +127,62 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_3, 2, s16le, 48, 1000, 0, 0) +# playback DAI is SSP0 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 4, SSP, 0, SSP0-Codec, + PIPELINE_SOURCE_4, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP0 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 5, SSP, 0, SSP0-Codec, + PIPELINE_SINK_5, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 6, SSP, 1, SSP1-Codec, + PIPELINE_SINK_6, 2, s16le, + 48, 1000, 0, 0) + +# playback DAI is SSP3 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 7, SSP, 3, SSP3-Codec, + PIPELINE_SOURCE_7, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP3 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 8, SSP, 3, SSP3-Codec, + PIPELINE_SINK_8, 2, s16le, + 48, 1000, 0, 0) + +# playback DAI is SSP5 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 9, SSP, 5, SSP5-Codec, + PIPELINE_SOURCE_9, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP5 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 10, SSP, 5, SSP5-Codec, + PIPELINE_SINK_10, 2, s16le, + 48, 1000, 0, 0) + # PCM Low Latency, id 0 -PCM_PLAYBACK_ADD(Port4, 1, 0, 0, PIPELINE_PCM_1) -PCM_DUPLEX_ADD(Port2, 4, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) +PCM_PLAYBACK_ADD(Port4, 0, 0, 0, PIPELINE_PCM_1) +PCM_DUPLEX_ADD(Port2, 1, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) +PCM_DUPLEX_ADD(Port0, 2, 2, 2, PIPELINE_PCM_4, PIPELINE_PCM_5) +PCM_CAPTURE_ADD(Port1, 3, 3, 3, PIPELINE_PCM_6) +PCM_DUPLEX_ADD(Port3, 4, 4, 4, PIPELINE_PCM_7, PIPELINE_PCM_8) +PCM_DUPLEX_ADD(Port5, 5, 5, 5, PIPELINE_PCM_9, PIPELINE_PCM_10) # # BE configurations - overrides config in ACPI if present @@ -88,6 +199,30 @@ DAI_CONFIG(SSP, 2, 2, SSP2-Codec, I2S, 16, DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 16, 3, 3)) +DAI_CONFIG(SSP, 0, 0, SSP0-Codec, I2S, 16, + DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 1536000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 16, 3, 3)) + +DAI_CONFIG(SSP, 1, 1, SSP1-Codec, I2S, 16, + DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 1536000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 16, 3, 3)) + +DAI_CONFIG(SSP, 3, 3, SSP3-Codec, I2S, 16, + DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 1536000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 16, 3, 3)) + +DAI_CONFIG(SSP, 5, 5, SSP5-Codec, I2S, 16, + DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 1536000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 16, 3, 3)) + VIRTUAL_DAPM_ROUTE_IN(BtHfp_ssp0_in, SSP, 0, IN, 0) VIRTUAL_DAPM_ROUTE_OUT(BtHfp_ssp0_out, SSP, 0, OUT, 1) VIRTUAL_DAPM_ROUTE_IN(hdmi_ssp1_in, SSP, 1, IN, 2) From 21f523401e4244dfd2fdce04db907ea092aea81e Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Thu, 31 May 2018 13:01:20 -0700 Subject: [PATCH 167/324] topology:scripts: fix tplg build script to compile last topology when using xargs When using xargs, the last topology file while batch processing alsatplg doesn't get compiled properly. Also remove a stray ; in the script. Signed-off-by: Ranjani Sridharan --- topology/test/tplg-build.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 26c70add78f9..af23b6608f24 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -157,12 +157,14 @@ simple_test codec tone "SSP2-Codec" s32le 2 s16le 20 16 1920000 19200000 I2S TON if [ "$USE_XARGS" == "yes" ] then echo "Batch processing m4 files..." - M4_STRINGS=${M4_STRINGS%?}; + M4_STRINGS=${M4_STRINGS%?} #m4 processing echo $M4_STRINGS | tr " " "," | tr '\n' '\0' | xargs -P0 -d ',' -n12 bash -c 'm4 "${@:1:${#}-1}" > ${12}.conf' m4 #execute alsatplg to create topology binary TEST_STRINGS=${TEST_STRINGS%?} - echo $TEST_STRINGS | tr '\n' '\0' | xargs -d ',' -P0 -n1 -I string alsatplg -v 1 -c string".conf" -o string".tplg" + echo $TEST_STRINGS | tr '\n' ',' |\ + xargs -d ',' -P0 -n1 -I string alsatplg -v 1 -c\ + string".conf" -o string".tplg" fi From e77a8ef269736d4d5cd047a6e121933d54eef7f5 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Thu, 31 May 2018 10:34:42 -0700 Subject: [PATCH 168/324] topology: scripts: changes to accommodate different DAI types This patch makes the following changes to make way for handling different DAI types in tplg build script: 1. Define the test DAI type while processing m4 files 2. DAI format and DAI port might be relevant for other types of DAI's. So use generic TEST_DAI_PORT and TEST_DAI_FORMAT instead of TEST_SSP_PORT TEST_SSP_FORMAT Signed-off-by: Ranjani Sridharan --- topology/test/test-capture-ssp.m4 | 18 +-- topology/test/test-playback-ssp.m4 | 18 +-- topology/test/test-ssp.m4 | 26 ++-- topology/test/test-tone-playback-ssp.m4 | 12 +- topology/test/tplg-build.sh | 154 +++++++++++++----------- 5 files changed, 121 insertions(+), 107 deletions(-) diff --git a/topology/test/test-capture-ssp.m4 b/topology/test/test-capture-ssp.m4 index 67f0da92633b..b6f093587d04 100644 --- a/topology/test/test-capture-ssp.m4 +++ b/topology/test/test-capture-ssp.m4 @@ -21,8 +21,8 @@ include(`dsps/byt.m4') # # TEST_PIPE_NAME - Pipe name # TEST_DAI_LINK_NAME - BE DAI link name e.g. "NoCodec" -# TEST_SSP_PORT - SSP port number e.g. 2 -# TEST_SSP_FORMAT - SSP data format e.g s16le +# TEST_DAI_PORT - SSP port number e.g. 2 +# TEST_DAI_FORMAT - SSP data format e.g s16le # TEST_PIPE_FORMAT - Pipeline format e.g. s16le # TEST_SSP_MCLK - SSP MCLK in Hz # TEST_SSP_BCLK - SSP BCLK in Hz @@ -34,7 +34,7 @@ include(`dsps/byt.m4') # # Define the pipeline # -# PCM0 <---> SSP TEST_SSP_PORT +# PCM0 <---> SSP TEST_DAI_PORT # # Passthrough playback pipeline 2 on PCM 0 using max 2 channels of s24le. @@ -44,18 +44,18 @@ include(`dsps/byt.m4') PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-capture.m4, 2, 0, 2, TEST_PIPE_FORMAT, 48, 1000, 0, 0, 0, 1, - SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) + TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_FORMAT, 2) # # DAI configuration # -# SSP port TEST_SSP_PORT is our only pipeline DAI +# SSP port TEST_DAI_PORT is our only pipeline DAI # -# capture DAI is SSP TEST_SSP_PORT using 2 periods +# capture DAI is SSP TEST_DAI_PORT using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, - PIPELINE_SINK_2, 2, TEST_SSP_FORMAT, + 2, TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_LINK_NAME, + PIPELINE_SINK_2, 2, TEST_DAI_FORMAT, 48, 1000, 0, 0) # PCM Passthrough @@ -66,7 +66,7 @@ PCM_CAPTURE_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_2) # # Clocks masters wrt codec # -# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT +# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), diff --git a/topology/test/test-playback-ssp.m4 b/topology/test/test-playback-ssp.m4 index 22943b0fdabc..a12db578236b 100644 --- a/topology/test/test-playback-ssp.m4 +++ b/topology/test/test-playback-ssp.m4 @@ -21,8 +21,8 @@ include(`dsps/byt.m4') # # TEST_PIPE_NAME - Pipe name # TEST_DAI_LINK_NAME - BE DAI link name e.g. "NoCodec" -# TEST_SSP_PORT - SSP port number e.g. 2 -# TEST_SSP_FORMAT - SSP data format e.g s16le +# TEST_DAI_PORT - SSP port number e.g. 2 +# TEST_DAI_FORMAT - SSP data format e.g s16le # TEST_PIPE_FORMAT - Pipeline format e.g. s16le # TEST_SSP_MCLK - SSP MCLK in Hz # TEST_SSP_BCLK - SSP BCLK in Hz @@ -34,7 +34,7 @@ include(`dsps/byt.m4') # # Define the pipeline # -# PCM0 <---> SSP TEST_SSP_PORT +# PCM0 <---> SSP TEST_DAI_PORT # # Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. @@ -44,18 +44,18 @@ include(`dsps/byt.m4') PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-playback.m4, 1, 0, 2, TEST_PIPE_FORMAT, 48, 1000, 0, 0, 0, 1, - SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) + TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_FORMAT, 2) # # DAI configuration # -# SSP port TEST_SSP_PORT is our only pipeline DAI +# SSP port TEST_DAI_PORT is our only pipeline DAI # -# playback DAI is SSP TEST_SSP_PORT using 2 periods +# playback DAI is SSP TEST_DAI_PORT using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, - PIPELINE_SOURCE_1, 2, TEST_SSP_FORMAT, + 1, TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_LINK_NAME, + PIPELINE_SOURCE_1, 2, TEST_DAI_FORMAT, 48, 1000, 0, 0) # PCM Passthrough @@ -66,7 +66,7 @@ PCM_PLAYBACK_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1) # # Clocks masters wrt codec # -# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT +# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_slave), diff --git a/topology/test/test-ssp.m4 b/topology/test/test-ssp.m4 index 0b305e153539..05c6fee26e33 100644 --- a/topology/test/test-ssp.m4 +++ b/topology/test/test-ssp.m4 @@ -21,8 +21,8 @@ include(`dsps/byt.m4') # # TEST_PIPE_NAME - Pipe name # TEST_DAI_LINK_NAME - BE DAI link name e.g. "NoCodec" -# TEST_SSP_PORT - SSP port number e.g. 2 -# TEST_SSP_FORMAT - SSP data format e.g s16le +# TEST_DAI_PORT - SSP port number e.g. 2 +# TEST_DAI_FORMAT - SSP data format e.g s16le # TEST_PIPE_FORMAT - Pipeline format e.g. s16le # TEST_SSP_MCLK - SSP BCLK in Hz # TEST_SSP_BCLK - SSP BCLK in Hz @@ -34,7 +34,7 @@ include(`dsps/byt.m4') # # Define the pipeline # -# PCM0 <-- TEST_PIPE_NAME pipe --> SSP TEST_SSP_PORT +# PCM0 <-- TEST_PIPE_NAME pipe --> SSP TEST_DAI_PORT # # Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. @@ -44,7 +44,7 @@ include(`dsps/byt.m4') PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-playback.m4, 1, 0, 2, TEST_PIPE_FORMAT, 48, 1000, 0, 0, 0, 1, - SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) + TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_FORMAT, 2) # Passthrough playback pipeline 2 on PCM 0 using max 2 channels of s24le. @@ -54,26 +54,26 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-playback.m4, PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-capture.m4, 2, 0, 2, TEST_PIPE_FORMAT, 48, 1000, 0, 0, 0, 1, - SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) + TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_FORMAT, 2) # # DAI configuration # -# SSP port TEST_SSP_PORT is our only pipeline DAI +# SSP port TEST_DAI_PORT is our only pipeline DAI # -# playback DAI is SSP TEST_SSP_PORT using 2 periods +# playback DAI is SSP TEST_DAI_PORT using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, - PIPELINE_SOURCE_1, 2, TEST_SSP_FORMAT, + 1, TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_LINK_NAME, + PIPELINE_SOURCE_1, 2, TEST_DAI_FORMAT, 48, 1000, 0, 0) -# capture DAI is SSP TEST_SSP_PORT using 2 periods +# capture DAI is SSP TEST_DAI_PORT using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, - PIPELINE_SINK_2, 2, TEST_SSP_FORMAT, + 2, TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_LINK_NAME, + PIPELINE_SINK_2, 2, TEST_DAI_FORMAT, 48, 1000, 0, 0) # PCM Passthrough @@ -84,7 +84,7 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # Clocks masters wrt codec # -# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT +# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), diff --git a/topology/test/test-tone-playback-ssp.m4 b/topology/test/test-tone-playback-ssp.m4 index b08447ad5b39..a53035424ff8 100644 --- a/topology/test/test-tone-playback-ssp.m4 +++ b/topology/test/test-tone-playback-ssp.m4 @@ -21,8 +21,8 @@ include(`dsps/byt.m4') # # TEST_PIPE_NAME - Pipe name # TEST_DAI_LINK_NAME - BE DAI link name e.g. "NoCodec" -# TEST_SSP_PORT - SSP port number e.g. 2 -# TEST_SSP_FORMAT - SSP data format e.g s16le +# TEST_DAI_PORT - SSP port number e.g. 2 +# TEST_DAI_FORMAT - SSP data format e.g s16le # TEST_PIPE_FORMAT - Pipeline format e.g. s16le # TEST_SSP_MCLK - SSP MCLK in Hz # TEST_SSP_BCLK - SSP BCLK in Hz @@ -43,10 +43,10 @@ PIPELINE_ADD(sof/pipe-tone.m4, 48, 1000, 0, 0) # playback DAI is SSP2 using 2 periods -# Buffers use TEST_SSP_FORMAT format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use TEST_DAI_FORMAT format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 5, SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, - PIPELINE_SOURCE_5, 2, TEST_SSP_FORMAT, + 5, TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_LINK_NAME, + PIPELINE_SOURCE_5, 2, TEST_DAI_FORMAT, 48, 1000, 2, 0) # @@ -54,7 +54,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # # Clocks masters wrt codec # -# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT +# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index af23b6608f24..4c3381950c3b 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -14,6 +14,7 @@ export M4PATH="../:../m4:../common" # can be used on components with 1 sink and 1 source. SIMPLE_TESTS=(test-ssp test-capture-ssp test-playback-ssp) TONE_TEST=test-tone-playback-ssp +DMIC_TEST=test-capture-ssp TEST_STRINGS="" M4_STRINGS="" # process m4 simple tests - @@ -22,6 +23,7 @@ M4_STRINGS="" # 2) pipe_name - test component pipeline filename in sof/ # 3) be_name - BE DAI link name in machine driver, used for matching # 4) format - PCM sample format +# 5) dai_type - dai type e.g. SSP/DMIC # 5) dai_id - SSP port number # 6) dai_format - SSP sample format # 7) dai_phy_bits - SSP physical number of BLKCs per slot/channel @@ -32,59 +34,71 @@ M4_STRINGS="" # function simple_test { - TESTS=("${!12}") + if [ $5 == "SSP" ] + then + TESTS=("${!13}") + fi for i in ${TESTS[@]} do - TFILE="$i$5-${11}-$2-$4-$6-48k-$((${10} / 1000))k-$1" + TFILE="$i$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" if [ "$USE_XARGS" == "yes" ] then - #create input string for batch m4 processing - M4_STRINGS+="-DTEST_PIPE_NAME=$2,-DTEST_DAI_LINK_NAME=$3\ - -DTEST_SSP_PORT=$5,-DTEST_SSP_FORMAT=$6\ - -DTEST_PIPE_FORMAT=$4,-DTEST_SSP_BCLK=$9\ - -DTEST_SSP_MCLK=${10},-DTEST_SSP_PHY_BITS=$7\ - -DTEST_SSP_DATA_BITS=$8,-DTEST_SSP_MODE=${11}\ - $i.m4,${TFILE}," - #create input string for batch processing of conf files - TEST_STRINGS+=${TFILE}"," + #if DAI type is SSP, define the SSP specific params + if [ $5 == "SSP" ] + then + #create input string for batch m4 processing + M4_STRINGS+="-DTEST_PIPE_NAME=$2,-DTEST_DAI_LINK_NAME=$3\ + -DTEST_DAI_PORT=$6,-DTEST_DAI_FORMAT=$7\ + -DTEST_PIPE_FORMAT=$4,-DTEST_SSP_BCLK=${10}\ + -DTEST_SSP_MCLK=${11},-DTEST_SSP_PHY_BITS=$8\ + -DTEST_SSP_DATA_BITS=$9,-DTEST_SSP_MODE=${12}\ + -DTEST_DAI_TYPE=$5\ + $i.m4,${TFILE}," + #create input string for batch processing of conf files + TEST_STRINGS+=${TFILE}"," + fi else - echo "M4 pre-processing test $i -> ${TFILE}" - m4 ${M4_FLAGS} \ - -DTEST_PIPE_NAME="$2" \ - -DTEST_DAI_LINK_NAME="$3" \ - -DTEST_SSP_PORT=$5 \ - -DTEST_SSP_FORMAT=$6 \ - -DTEST_PIPE_FORMAT=$4 \ - -DTEST_SSP_BCLK=$9 \ - -DTEST_SSP_MCLK=${10} \ - -DTEST_SSP_PHY_BITS=$7 \ - -DTEST_SSP_DATA_BITS=$8 \ - -DTEST_SSP_MODE=${11} \ - $i.m4 > ${TFILE}.conf - echo "Compiling test $i -> ${TFILE}.tplg" - alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg + #if DAI type is SSP, define the SSP specific params + if [ $5 == "SSP" ] + then + echo "M4 pre-processing test $i -> ${TFILE}" + m4 ${M4_FLAGS} \ + -DTEST_PIPE_NAME="$2" \ + -DTEST_DAI_LINK_NAME="$3" \ + -DTEST_DAI_PORT=$6 \ + -DTEST_DAI_FORMAT=$7 \ + -DTEST_PIPE_FORMAT=$4 \ + -DTEST_SSP_BCLK=${10} \ + -DTEST_SSP_MCLK=${11} \ + -DTEST_SSP_PHY_BITS=$8 \ + -DTEST_SSP_DATA_BITS=$9 \ + -DTEST_SSP_MODE=${12} \ + -DTEST_DAI_TYPE=$5 \ + $i.m4 > ${TFILE}.conf + echo "Compiling test $i -> ${TFILE}.tplg" + alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg + fi fi - done } echo "Preparing topology build input..." # Pre-process the simple tests -simple_test nocodec passthrough "NoCodec" s16le 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s16le 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec src "NoCodec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] - -simple_test codec passthrough "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec passthrough "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec volume "SSP2-Codec" s16le 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec volume "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec volume "SSP2-Codec" s24le 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec volume "SSP2-Codec" s16le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec src "SSP2-Codec" s24le 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s16le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec src "NoCodec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] + +simple_test codec passthrough "SSP2-Codec" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec passthrough "SSP2-Codec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s24le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s16le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test codec src "SSP2-Codec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] # for APL APL_PROTOCOL_TESTS=(I2S LEFT_J DSP_A DSP_B) @@ -100,22 +114,22 @@ do do for format in ${APL_FORMAT_TESTS[@]} do - simple_test nocodec $mode "NoCodec" $format $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec $mode "NoCodec" $format $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec $mode "NoCodec" $format $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec" $format SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec" $format SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec" $format SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] done done - simple_test nocodec passthrough "NoCodec" s16le $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec passthrough "NoCodec" s24le $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec passthrough "NoCodec" s32le $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec" s16le SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec" s24le SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec" s32le SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s16le $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s24le $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s32le $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s16le SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s24le SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s32le SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] done done @@ -127,39 +141,39 @@ do do for format in ${APL_FORMAT_TESTS[@]} do - simple_test nocodec $mode "NoCodec" $format $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] - simple_test nocodec $mode "NoCodec" $format $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec" $format SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec" $format SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] - simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] - simple_test codec $mode "SSP${ssp}-Codec" $format $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] done done - simple_test nocodec passthrough "NoCodec" s16le $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] - simple_test nocodec passthrough "NoCodec" s24le $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec" s16le SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec" s24le SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s16le $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s24le $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s16le SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s24le SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] done done # for CNL -simple_test nocodec passthrough "NoCodec" s16le 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec passthrough "NoCodec" s24le 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s16le 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s16le 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s24le 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s24le 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec src "NoCodec" s24le 4 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec" s16le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec" s24le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s16le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s16le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s24le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec" s24le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec src "NoCodec" s24le SSP 4 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] # Tone test: Tone component only supports s32le currently -simple_test codec tone "SSP2-Codec" s32le 2 s16le 20 16 1920000 19200000 I2S TONE_TEST[@] +simple_test codec tone "SSP2-Codec" s32le SSP 2 s16le 20 16 1920000 19200000 I2S TONE_TEST[@] if [ "$USE_XARGS" == "yes" ] then echo "Batch processing m4 files..." M4_STRINGS=${M4_STRINGS%?} #m4 processing - echo $M4_STRINGS | tr " " "," | tr '\n' '\0' | xargs -P0 -d ',' -n12 bash -c 'm4 "${@:1:${#}-1}" > ${12}.conf' m4 + echo $M4_STRINGS | tr " " "," | tr '\n' '\0' | xargs -P0 -d ',' -n13 bash -c 'm4 "${@:1:${#}-1}" > ${13}.conf' m4 #execute alsatplg to create topology binary TEST_STRINGS=${TEST_STRINGS%?} From 56b8316e2a796d776aaf293ff0cdb4f45ba2b4b9 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Thu, 31 May 2018 10:34:43 -0700 Subject: [PATCH 169/324] topology: separate ssp params from dai common params This patch makes changes to DAI config in topology to separate out SSP specific params from common params in preparation for other DAI types coming soon. Signed-off-by: Ranjani Sridharan --- topology/m4/dai.m4 | 43 ++++++++------ topology/sof-apl-nocodec.m4 | 11 ++-- topology/sof-apl-tdf8532.m4 | 79 ++++++++++++++----------- topology/sof-bdw-rt286.m4 | 11 ++-- topology/sof-bdw-rt5640.m4 | 11 ++-- topology/sof-byt-da7213.m4 | 11 ++-- topology/sof-byt-nocodec.m4 | 11 ++-- topology/sof-byt-rt5640.m4 | 11 ++-- topology/sof-byt-rt5645.m4 | 11 ++-- topology/sof-byt-rt5651.m4 | 12 ++-- topology/sof-cht-max98090.m4 | 11 ++-- topology/sof-cht-nocodec.m4 | 11 ++-- topology/sof-cnl-rt274.m4 | 11 ++-- topology/sof-hsw-rt5640.m4 | 11 ++-- topology/test/test-capture-ssp.m4 | 13 ++-- topology/test/test-playback-ssp.m4 | 13 ++-- topology/test/test-ssp.m4 | 13 ++-- topology/test/test-tone-playback-ssp.m4 | 13 ++-- 18 files changed, 173 insertions(+), 134 deletions(-) diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index ba6cba41d692..8a79ebc3df74 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -131,27 +131,45 @@ define(`DAI_CLOCK', dnl DAI_TDM(slots, width, tx_mask, rx_mask) define(`DAI_TDM', -` tdm_slots 'STR($1) +`tdm_slots 'STR($1) ` tdm_slot_width 'STR($2) ` tx_slots 'STR($3) ` rx_slots 'STR($4) ) +dnl SSP_CONFIG(format, mclk, bclk, fsync, tdm, ssp sample bits) +define(`SSP_CONFIG', +` format "'$1`"' +` '$2 +` '$3 +` '$4 +` '$5 +`}' +$6 +) + +dnl SSP_SAMPLE_BITS(type, idx, valid bits) +define(`SSP_SAMPLE_BITS', +`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {' +` tokens "sof_dai_tokens"' +` tuples."word" {' +` SOF_TKN_DAI_SAMPLE_BITS' STR($3) +` }' +`}' +`SectionData."'N_DAI_CONFIG($1$2)`_data" {' +` tuples "'N_DAI_CONFIG($1$2)`_tuples"' +`}' +) dnl DAI Config) define(`N_DAI_CONFIG', `DAICONFIG.'$1) -dnl DAI_CONFIG(type, idx, link_id, name, format, valid bits, mclk, bclk, fsync, tdm) +dnl DAI_CONFIG(type, idx, link_id, name, ssp_config) define(`DAI_CONFIG', `SectionHWConfig."'$1$2`" {' `' ` id "'$2`"' -` format "'$5`"' `' -` '$7 -` '$8 -` '$9 -` '$10 -`}' +` ifelse($1, `SSP', $5, `}')' `SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples_str" {' ` tokens "sof_dai_tokens"' ` tuples."string" {' @@ -161,15 +179,6 @@ define(`DAI_CONFIG', `SectionData."'N_DAI_CONFIG($1$2)`_data_str" {' ` tuples "'N_DAI_CONFIG($1$2)`_tuples_str"' `}' -`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {' -` tokens "sof_dai_tokens"' -` tuples."word" {' -` SOF_TKN_DAI_SAMPLE_BITS' STR($6) -` }' -`}' -`SectionData."'N_DAI_CONFIG($1$2)`_data" {' -` tuples "'N_DAI_CONFIG($1$2)`_tuples"' -`}' `' `SectionBE."'$4`" {' ` id "'$3`"' diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 68380e4f24e6..ac3ee7517c09 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -93,8 +93,9 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, NoCodec, I2S, 24, - DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3)) +DAI_CONFIG(SSP, 2, 0, NoCodec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 25, 3, 3), + SSP_SAMPLE_BITS(SSP, 2, 24))) diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index c737a65369fa..5554e58395f6 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -187,41 +187,49 @@ PCM_DUPLEX_ADD(Port5, 5, 5, 5, PIPELINE_PCM_9, PIPELINE_PCM_10) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 4, 4, SSP4-Codec, DSP_B, 32, - DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 12288000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(8, 32, 15, 15)) - -DAI_CONFIG(SSP, 2, 2, SSP2-Codec, I2S, 16, - DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 1536000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 16, 3, 3)) - -DAI_CONFIG(SSP, 0, 0, SSP0-Codec, I2S, 16, - DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 1536000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 16, 3, 3)) - -DAI_CONFIG(SSP, 1, 1, SSP1-Codec, I2S, 16, - DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 1536000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 16, 3, 3)) - -DAI_CONFIG(SSP, 3, 3, SSP3-Codec, I2S, 16, - DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 1536000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 16, 3, 3)) - -DAI_CONFIG(SSP, 5, 5, SSP5-Codec, I2S, 16, - DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 1536000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 16, 3, 3)) + +DAI_CONFIG(SSP, 4, 4, SSP4-Codec, + SSP_CONFIG(DSP_B, DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 12288000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(8, 32, 15, 15), + SSP_SAMPLE_BITS(SSP, 4, 32))) + +DAI_CONFIG(SSP, 2, 2, SSP2-Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 1536000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 16, 3, 3), + SSP_SAMPLE_BITS(SSP, 2, 16))) + +DAI_CONFIG(SSP, 0, 0, SSP0-Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 1536000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 16, 3, 3), + SSP_SAMPLE_BITS(SSP, 0, 16))) + +DAI_CONFIG(SSP, 1, 1, SSP1-Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 1536000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 16, 3, 3), + SSP_SAMPLE_BITS(SSP, 1, 16))) + +DAI_CONFIG(SSP, 3, 3, SSP3-Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 1536000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 16, 3, 3), + SSP_SAMPLE_BITS(SSP, 3, 16))) + +DAI_CONFIG(SSP, 5, 5, SSP5-Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 1536000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 16, 3, 3), + SSP_SAMPLE_BITS(SSP, 5, 16))) + VIRTUAL_DAPM_ROUTE_IN(BtHfp_ssp0_in, SSP, 0, IN, 0) VIRTUAL_DAPM_ROUTE_OUT(BtHfp_ssp0_out, SSP, 0, OUT, 1) @@ -245,4 +253,3 @@ VIRTUAL_WIDGET(ssp3 Rx, 18) VIRTUAL_WIDGET(ssp4 Tx, 19) VIRTUAL_WIDGET(ssp5 Tx, 20) VIRTUAL_WIDGET(ssp5 Rx, 21) - diff --git a/topology/sof-bdw-rt286.m4 b/topology/sof-bdw-rt286.m4 index 098d4c836107..6d09e2e23c31 100644 --- a/topology/sof-bdw-rt286.m4 +++ b/topology/sof-bdw-rt286.m4 @@ -93,8 +93,9 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, 0, Codec, I2S, 24, - DAI_CLOCK(mclk, 24000000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3)) +DAI_CONFIG(SSP, 0, 0, Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24000000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 25, 3, 3), + SSP_SAMPLE_BITS(SSP, 0, 24))) diff --git a/topology/sof-bdw-rt5640.m4 b/topology/sof-bdw-rt5640.m4 index bbbbbe4ccbe1..2f9badbde540 100644 --- a/topology/sof-bdw-rt5640.m4 +++ b/topology/sof-bdw-rt5640.m4 @@ -93,8 +93,9 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, 0, Codec, I2S, 24, - DAI_CLOCK(mclk, 24000000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3)) +DAI_CONFIG(SSP, 0, 0, Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24000000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 25, 3, 3), + SSP_SAMPLE_BITS(SSP, 0, 24))) diff --git a/topology/sof-byt-da7213.m4 b/topology/sof-byt-da7213.m4 index e3c79528d653..090b034948ab 100644 --- a/topology/sof-byt-da7213.m4 +++ b/topology/sof-byt-da7213.m4 @@ -93,8 +93,9 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, SSP2-Codec, I2S, 24, - DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3)) +DAI_CONFIG(SSP, 2, 0, SSP2-Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 25, 3, 3), + SSP_SAMPLE_BITS(SSP, 2, 24))) diff --git a/topology/sof-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 index 5c65fb082397..9bed36ec0a50 100644 --- a/topology/sof-byt-nocodec.m4 +++ b/topology/sof-byt-nocodec.m4 @@ -93,8 +93,9 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, NoCodec, I2S, 24, - DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3)) +DAI_CONFIG(SSP, 2, 0, NoCodec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 25, 3, 3), + SSP_SAMPLE_BITS(SSP, 2, 24))) diff --git a/topology/sof-byt-rt5640.m4 b/topology/sof-byt-rt5640.m4 index 7fae6f0618ac..f852616de766 100644 --- a/topology/sof-byt-rt5640.m4 +++ b/topology/sof-byt-rt5640.m4 @@ -93,8 +93,9 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, SSP2-Codec, I2S, 24, - DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3)) +DAI_CONFIG(SSP, 2, 0, SSP2-Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 25, 3, 3), + SSP_SAMPLE_BITS(SSP, 2, 24))) diff --git a/topology/sof-byt-rt5645.m4 b/topology/sof-byt-rt5645.m4 index 7b81cbd2c78f..7d8eee584ee0 100644 --- a/topology/sof-byt-rt5645.m4 +++ b/topology/sof-byt-rt5645.m4 @@ -93,8 +93,9 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, SSP2-Codec, I2S, 24, - DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3)) +DAI_CONFIG(SSP, 2, 0, SSP2-Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 25, 3, 3), + SSP_SAMPLE_BITS(SSP, 2, 24))) diff --git a/topology/sof-byt-rt5651.m4 b/topology/sof-byt-rt5651.m4 index 91324aec9196..894602aee571 100644 --- a/topology/sof-byt-rt5651.m4 +++ b/topology/sof-byt-rt5651.m4 @@ -93,9 +93,9 @@ PCM_DUPLEX_ADD(Low Latency, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, SSP2-Codec, I2S, 24, - DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3)) - +DAI_CONFIG(SSP, 2, 0, SSP2-Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 25, 3, 3), + SSP_SAMPLE_BITS(SSP, 2, 24))) diff --git a/topology/sof-cht-max98090.m4 b/topology/sof-cht-max98090.m4 index 5fb7802c9db2..2d5192a0712f 100644 --- a/topology/sof-cht-max98090.m4 +++ b/topology/sof-cht-max98090.m4 @@ -93,8 +93,9 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, SSP2-Codec, I2S, 16, - DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 1920000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 20, 3, 3)) +DAI_CONFIG(SSP, 2, 0, SSP2-Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 1920000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 20, 3, 3), + SSP_SAMPLE_BITS(SSP, 2, 16))) diff --git a/topology/sof-cht-nocodec.m4 b/topology/sof-cht-nocodec.m4 index bd4d9697c8af..68abf37ddeca 100644 --- a/topology/sof-cht-nocodec.m4 +++ b/topology/sof-cht-nocodec.m4 @@ -93,8 +93,9 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, NoCodec, I2S, 24, - DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3)) +DAI_CONFIG(SSP, 2, 0, NoCodec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 25, 3, 3), + SSP_SAMPLE_BITS(SSP, 2, 24))) diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index 01cd20343ba9..25a4913383a3 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -64,11 +64,12 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, 0, SSP0-Codec, DSP_B, 24, - DAI_CLOCK(mclk, 24000000, codec_mclk_in), - DAI_CLOCK(bclk, 4800000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(4, 25, 3, 3)) +DAI_CONFIG(SSP, 0, 0, SSP0-Codec, + SSP_CONFIG(DSP_B, DAI_CLOCK(mclk, 24000000, codec_mclk_in), + DAI_CLOCK(bclk, 4800000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(4, 25, 3, 3), + SSP_SAMPLE_BITS(SSP, 0, 24))) VIRTUAL_DAPM_ROUTE_OUT(codec0_out, SSP, 0, OUT, 0) VIRTUAL_DAPM_ROUTE_OUT(codec1_out, SSP, 0, OUT, 1) diff --git a/topology/sof-hsw-rt5640.m4 b/topology/sof-hsw-rt5640.m4 index 28d5c6ae7e7c..22d79d5bcb1a 100644 --- a/topology/sof-hsw-rt5640.m4 +++ b/topology/sof-hsw-rt5640.m4 @@ -93,8 +93,9 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, 0, Codec, I2S, 24, - DAI_CLOCK(mclk, 24000000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3)) +DAI_CONFIG(SSP, 0, 0, Codec, + SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24000000, codec_mclk_in), + DAI_CLOCK(bclk, 2400000, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, 25, 3, 3), + SSP_SAMPLE_BITS(SSP, 0, 24))) diff --git a/topology/test/test-capture-ssp.m4 b/topology/test/test-capture-ssp.m4 index b6f093587d04..65a3bcd8c9da 100644 --- a/topology/test/test-capture-ssp.m4 +++ b/topology/test/test-capture-ssp.m4 @@ -68,8 +68,11 @@ PCM_CAPTURE_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_2) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # -DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), - DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) +DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, + SSP_CONFIG(TEST_SSP_MODE, + DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), + DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), + SSP_SAMPLE_BITS(TEST_DAI_TYPE, TEST_DAI_PORT, + TEST_SSP_DATA_BITS))) diff --git a/topology/test/test-playback-ssp.m4 b/topology/test/test-playback-ssp.m4 index a12db578236b..b0f3fecfdcf3 100644 --- a/topology/test/test-playback-ssp.m4 +++ b/topology/test/test-playback-ssp.m4 @@ -68,8 +68,11 @@ PCM_PLAYBACK_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # -DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_slave), - DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) +DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, + SSP_CONFIG(TEST_SSP_MODE, + DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_slave), + DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), + SSP_SAMPLE_BITS(TEST_DAI_TYPE, TEST_DAI_PORT, + TEST_SSP_DATA_BITS))) diff --git a/topology/test/test-ssp.m4 b/topology/test/test-ssp.m4 index 05c6fee26e33..383a3972d53b 100644 --- a/topology/test/test-ssp.m4 +++ b/topology/test/test-ssp.m4 @@ -86,8 +86,11 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # -DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, TEST_SSP_MODE, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), - DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) +DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, + SSP_CONFIG(TEST_SSP_MODE, + DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), + DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), + SSP_SAMPLE_BITS(TEST_DAI_TYPE, TEST_DAI_PORT, + TEST_SSP_DATA_BITS))) diff --git a/topology/test/test-tone-playback-ssp.m4 b/topology/test/test-tone-playback-ssp.m4 index a53035424ff8..1c38c092abc2 100644 --- a/topology/test/test-tone-playback-ssp.m4 +++ b/topology/test/test-tone-playback-ssp.m4 @@ -56,8 +56,11 @@ DAI_ADD(sof/pipe-dai-playback.m4, # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # -DAI_CONFIG(SSP, TEST_SSP_PORT, 0, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, - DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), - DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) +DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, + SSP_CONFIG(TEST_SSP_MODE, + DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), + DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), + SSP_SAMPLE_BITS(TEST_DAI_TYPE, TEST_DAI_PORT, + TEST_SSP_DATA_BITS))) From a913f77e654eb235c6afd02bde13f77fa37947c3 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Thu, 31 May 2018 10:34:44 -0700 Subject: [PATCH 170/324] topology: add DMIC tokens This patch introduces the DMIC specific config parameter tokens in topology. Signed-off-by: Ranjani Sridharan --- topology/sof/tokens.m4 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index e9aa302a6c6d..d1230d8ebdde 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -60,3 +60,24 @@ SectionVendorTokens."sof_ssp_tokens" { SOF_TKN_INTEL_SSP_BCLK_KEEP_ACTIVE "501" SOF_TKN_INTEL_SSP_FS_KEEP_ACTIVE "502" } + +SectionVendorTokens."sof_dmic_tokens" { + SOF_TKN_INTEL_DMIC_DRIVER_VERSION "600" + SOF_TKN_INTEL_DMIC_CLK_MIN "601" + SOF_TKN_INTEL_DMIC_CLK_MAX "602" + SOF_TKN_INTEL_DMIC_DUTY_MIN "603" + SOF_TKN_INTEL_DMIC_DUTY_MAX "604" + SOF_TKN_INTEL_DMIC_NUM_PDM_ACTIVE "605" + SOF_TKN_INTEL_DMIC_SAMPLE_RATE "608" + SOF_TKN_INTEL_DMIC_FIFO_WORD_LENGTH "609" +} + +SectionVendorTokens."sof_dmic_pdm_tokens" { + SOF_TKN_INTEL_DMIC_PDM_CTRL_ID "700" + SOF_TKN_INTEL_DMIC_PDM_MIC_A_Enable "701" + SOF_TKN_INTEL_DMIC_PDM_MIC_B_Enable "702" + SOF_TKN_INTEL_DMIC_PDM_POLARITY_A "703" + SOF_TKN_INTEL_DMIC_PDM_POLARITY_B "704" + SOF_TKN_INTEL_DMIC_PDM_CLK_EDGE "705" + SOF_TKN_INTEL_DMIC_PDM_SKEW "706" +} From 1dcac3225ecf9e99e42a324b374face345b970ce Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Thu, 31 May 2018 10:34:45 -0700 Subject: [PATCH 171/324] topology: make m4 filenames dai type agnostic Signed-off-by: Ranjani Sridharan --- topology/test/{test-ssp.m4 => test-all.m4} | 0 .../test/{test-capture-ssp.m4 => test-capture.m4} | 0 .../test/{test-playback-ssp.m4 => test-playback.m4} | 0 ...t-tone-playback-ssp.m4 => test-tone-playback.m4} | 0 topology/test/tplg-build.sh | 13 +++++++++---- 5 files changed, 9 insertions(+), 4 deletions(-) rename topology/test/{test-ssp.m4 => test-all.m4} (100%) rename topology/test/{test-capture-ssp.m4 => test-capture.m4} (100%) rename topology/test/{test-playback-ssp.m4 => test-playback.m4} (100%) rename topology/test/{test-tone-playback-ssp.m4 => test-tone-playback.m4} (100%) diff --git a/topology/test/test-ssp.m4 b/topology/test/test-all.m4 similarity index 100% rename from topology/test/test-ssp.m4 rename to topology/test/test-all.m4 diff --git a/topology/test/test-capture-ssp.m4 b/topology/test/test-capture.m4 similarity index 100% rename from topology/test/test-capture-ssp.m4 rename to topology/test/test-capture.m4 diff --git a/topology/test/test-playback-ssp.m4 b/topology/test/test-playback.m4 similarity index 100% rename from topology/test/test-playback-ssp.m4 rename to topology/test/test-playback.m4 diff --git a/topology/test/test-tone-playback-ssp.m4 b/topology/test/test-tone-playback.m4 similarity index 100% rename from topology/test/test-tone-playback-ssp.m4 rename to topology/test/test-tone-playback.m4 diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 4c3381950c3b..a48a3e2b0216 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -12,9 +12,9 @@ export M4PATH="../:../m4:../common" # Simple component test cases # can be used on components with 1 sink and 1 source. -SIMPLE_TESTS=(test-ssp test-capture-ssp test-playback-ssp) -TONE_TEST=test-tone-playback-ssp -DMIC_TEST=test-capture-ssp +SIMPLE_TESTS=(test-all test-capture test-playback) +TONE_TEST=test-tone-playback +DMIC_TEST=test-capture TEST_STRINGS="" M4_STRINGS="" # process m4 simple tests - @@ -40,12 +40,17 @@ function simple_test { fi for i in ${TESTS[@]} do - TFILE="$i$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" if [ "$USE_XARGS" == "yes" ] then #if DAI type is SSP, define the SSP specific params if [ $5 == "SSP" ] then + if [ $i == "test-all" ] + then + TFILE="test-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" + else + TFILE="$i-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" + fi #create input string for batch m4 processing M4_STRINGS+="-DTEST_PIPE_NAME=$2,-DTEST_DAI_LINK_NAME=$3\ -DTEST_DAI_PORT=$6,-DTEST_DAI_FORMAT=$7\ From d6e201c96118d316ebdcf3399daf7d9197d59e99 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Thu, 31 May 2018 10:34:46 -0700 Subject: [PATCH 172/324] topology: scripts: add dmic test topology This patch adds the dmic test case to the tplg generating script. Signed-off-by: Ranjani Sridharan --- topology/test/tplg-build.sh | 106 +++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 38 deletions(-) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index a48a3e2b0216..fadf7f52edab 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -37,51 +37,77 @@ function simple_test { if [ $5 == "SSP" ] then TESTS=("${!13}") + elif [ $5 == "DMIC" ] + then + TESTS=("${!15}") fi for i in ${TESTS[@]} do - if [ "$USE_XARGS" == "yes" ] + if [ $5 == "DMIC" ] then - #if DAI type is SSP, define the SSP specific params - if [ $5 == "SSP" ] + TFILE="$i-dmic$6-$2-$4-$7-48k-$1" + echo "M4 pre-processing test $i -> ${TFILE}" + m4 ${M4_FLAGS} \ + -DTEST_PIPE_NAME="$2" \ + -DTEST_DAI_LINK_NAME="$3" \ + -DTEST_DAI_PORT=$6 \ + -DTEST_DAI_FORMAT=$7 \ + -DTEST_PIPE_FORMAT=$4 \ + -DTEST_DAI_TYPE=$5 \ + -DTEST_DMIC_DRIVER_VERSION=$8 \ + -DTEST_DMIC_CLK_MIN=$9 \ + -DTEST_DMIC_CLK_MAX=${10} \ + -DTEST_DMIC_DUTY_MIN=${11} \ + -DTEST_DMIC_DUTY_MAX=${12} \ + -DTEST_PDM_ACTIVE=${13} \ + -DTEST_DMIC_SAMPLE_RATE=${14} \ + $i.m4 > ${TFILE}.conf + echo "Compiling test $i -> ${TFILE}.tplg" + alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg + else + if [ "$USE_XARGS" == "yes" ] then - if [ $i == "test-all" ] + #if DAI type is SSP, define the SSP specific params + if [ $5 == "SSP" ] then - TFILE="test-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" - else - TFILE="$i-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" + if [ $i == "test-all" ] + then + TFILE="test-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" + else + TFILE="$i-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" + fi + #create input string for batch m4 processing + M4_STRINGS+="-DTEST_PIPE_NAME=$2,-DTEST_DAI_LINK_NAME=$3\ + -DTEST_DAI_PORT=$6,-DTEST_DAI_FORMAT=$7\ + -DTEST_PIPE_FORMAT=$4,-DTEST_SSP_BCLK=${10}\ + -DTEST_SSP_MCLK=${11},-DTEST_SSP_PHY_BITS=$8\ + -DTEST_SSP_DATA_BITS=$9,-DTEST_SSP_MODE=${12}\ + -DTEST_DAI_TYPE=$5\ + $i.m4,${TFILE}," + #create input string for batch processing of conf files + TEST_STRINGS+=${TFILE}"," + fi + else + #if DAI type is SSP, define the SSP specific params + if [ $5 == "SSP" ] + then + echo "M4 pre-processing test $i -> ${TFILE}" + m4 ${M4_FLAGS} \ + -DTEST_PIPE_NAME="$2" \ + -DTEST_DAI_LINK_NAME="$3" \ + -DTEST_DAI_PORT=$6 \ + -DTEST_DAI_FORMAT=$7 \ + -DTEST_PIPE_FORMAT=$4 \ + -DTEST_SSP_BCLK=${10} \ + -DTEST_SSP_MCLK=${11} \ + -DTEST_SSP_PHY_BITS=$8 \ + -DTEST_SSP_DATA_BITS=$9 \ + -DTEST_SSP_MODE=${12} \ + -DTEST_DAI_TYPE=$5 \ + $i.m4 > ${TFILE}.conf + echo "Compiling test $i -> ${TFILE}.tplg" + alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg fi - #create input string for batch m4 processing - M4_STRINGS+="-DTEST_PIPE_NAME=$2,-DTEST_DAI_LINK_NAME=$3\ - -DTEST_DAI_PORT=$6,-DTEST_DAI_FORMAT=$7\ - -DTEST_PIPE_FORMAT=$4,-DTEST_SSP_BCLK=${10}\ - -DTEST_SSP_MCLK=${11},-DTEST_SSP_PHY_BITS=$8\ - -DTEST_SSP_DATA_BITS=$9,-DTEST_SSP_MODE=${12}\ - -DTEST_DAI_TYPE=$5\ - $i.m4,${TFILE}," - #create input string for batch processing of conf files - TEST_STRINGS+=${TFILE}"," - fi - else - #if DAI type is SSP, define the SSP specific params - if [ $5 == "SSP" ] - then - echo "M4 pre-processing test $i -> ${TFILE}" - m4 ${M4_FLAGS} \ - -DTEST_PIPE_NAME="$2" \ - -DTEST_DAI_LINK_NAME="$3" \ - -DTEST_DAI_PORT=$6 \ - -DTEST_DAI_FORMAT=$7 \ - -DTEST_PIPE_FORMAT=$4 \ - -DTEST_SSP_BCLK=${10} \ - -DTEST_SSP_MCLK=${11} \ - -DTEST_SSP_PHY_BITS=$8 \ - -DTEST_SSP_DATA_BITS=$9 \ - -DTEST_SSP_MODE=${12} \ - -DTEST_DAI_TYPE=$5 \ - $i.m4 > ${TFILE}.conf - echo "Compiling test $i -> ${TFILE}.tplg" - alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg fi fi done @@ -173,6 +199,10 @@ simple_test nocodec src "NoCodec" s24le SSP 4 s24le 25 24 2400000 24000000 I2S S # Tone test: Tone component only supports s32le currently simple_test codec tone "SSP2-Codec" s32le SSP 2 s16le 20 16 1920000 19200000 I2S TONE_TEST[@] +#DMIC Test +simple_test nocodec passthrough "DMIC0" s32le DMIC 0 s32le 1 500000 4800000\ + 40 60 1 48000 DMIC_TEST[@] + if [ "$USE_XARGS" == "yes" ] then echo "Batch processing m4 files..." From 082f9714a9e54a288817e82dd6db81ed0e3f45d3 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Thu, 31 May 2018 10:34:47 -0700 Subject: [PATCH 173/324] topology: add DMIC config definition to DAI config This patch adds the DMIC config definition and the DMIC config entry in DAI config. Signed-off-by: Ranjani Sridharan --- topology/m4/dai.m4 | 59 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index 8a79ebc3df74..a349a3cc1089 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -160,16 +160,72 @@ define(`SSP_SAMPLE_BITS', `}' ) +dnl PDM_TUPLES(pdm ctrl id, mic_a_enable, mic_b_enable, polarity_a, polarity_b, +dnl clk_egde, skew) +define(`PDM_TUPLES', +` tuples."short.pdm$1" {' +` SOF_TKN_INTEL_DMIC_PDM_CTRL_ID' STR($1) +` SOF_TKN_INTEL_DMIC_PDM_MIC_A_Enable' STR($2) +` SOF_TKN_INTEL_DMIC_PDM_MIC_B_Enable' STR($3) +` SOF_TKN_INTEL_DMIC_PDM_POLARITY_A' STR($4) +` SOF_TKN_INTEL_DMIC_PDM_POLARITY_B' STR($5) +` SOF_TKN_INTEL_DMIC_PDM_CLK_EDGE' STR($6) +` SOF_TKN_INTEL_DMIC_PDM_SKEW' STR($7) +` }' +) + +dnl PDM_CONFIG(type, idx, pdm tuples list) +define(`PDM_CONFIG', +`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_pdm_tuples" {' +` tokens "sof_dmic_pdm_tokens"' +$3 +`}' +) + +dnl DMIC currently only supports 16 bit or 32-bit word length +dnl DMIC_WORD_LENGTH(frame format) +define(`DMIC_WORD_LENGTH', +`ifelse($1, `s16le', 16, $1, `s32le', 32, `')') + +dnl DMIC_CONFIG(driver_version, clk_min, clk_mac, duty_min, duty_max, +dnl req pdm count, sample_rate, +dnl fifo word length, type, idx, pdm controller config) +define(`DMIC_CONFIG', +`SectionVendorTuples."'N_DAI_CONFIG($9$10)`_dmic_tuples" {' +` tokens "sof_dmic_tokens"' +` tuples."word" {' +` SOF_TKN_INTEL_DMIC_DRIVER_VERSION' STR($1) +` SOF_TKN_INTEL_DMIC_CLK_MIN' STR($2) +` SOF_TKN_INTEL_DMIC_CLK_MAX' STR($3) +` SOF_TKN_INTEL_DMIC_DUTY_MIN' STR($4) +` SOF_TKN_INTEL_DMIC_DUTY_MAX' STR($5) +` SOF_TKN_INTEL_DMIC_NUM_PDM_ACTIVE' STR($6) +` SOF_TKN_INTEL_DMIC_SAMPLE_RATE' STR($7) +` SOF_TKN_INTEL_DMIC_FIFO_WORD_LENGTH' STR($8) +` }' +`}' +dnl PDM config for the number of active PDM controllers +$11 +`SectionData."'N_DAI_CONFIG($9$10)`_pdm_data" {' +` tuples "'N_DAI_CONFIG($9$10)`_pdm_tuples"' +`}' +`SectionData."'N_DAI_CONFIG($9$10)`_data" {' +` tuples "'N_DAI_CONFIG($9$10)`_dmic_tuples"' + +`}' +) + dnl DAI Config) define(`N_DAI_CONFIG', `DAICONFIG.'$1) -dnl DAI_CONFIG(type, idx, link_id, name, ssp_config) +dnl DAI_CONFIG(type, idx, link_id, name, ssp_config/dmic_config) define(`DAI_CONFIG', `SectionHWConfig."'$1$2`" {' `' ` id "'$2`"' `' ` ifelse($1, `SSP', $5, `}')' +`ifelse($1, `DMIC', $5, `')' `SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples_str" {' ` tokens "sof_dai_tokens"' ` tuples."string" {' @@ -191,6 +247,7 @@ define(`DAI_CONFIG', ` data [' ` "'N_DAI_CONFIG($1$2)`_data"' ` "'N_DAI_CONFIG($1$2)`_data_str"' +`ifelse($1, `DMIC',` "'N_DAI_CONFIG($1$2)`_pdm_data"', `')' ` ]' `}') From 07d290c8ac6026af28bada021ac2215e3453fa88 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Thu, 31 May 2018 10:34:48 -0700 Subject: [PATCH 174/324] topology: add DMIC dai support in test capture m4 Add support for adding DMIC config for DMIC DAI type. Signed-off-by: Ranjani Sridharan --- topology/test/test-capture.m4 | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/topology/test/test-capture.m4 b/topology/test/test-capture.m4 index 65a3bcd8c9da..bed59c4670e0 100644 --- a/topology/test/test-capture.m4 +++ b/topology/test/test-capture.m4 @@ -69,10 +69,20 @@ PCM_CAPTURE_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_2) # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, - SSP_CONFIG(TEST_SSP_MODE, - DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), - DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), - SSP_SAMPLE_BITS(TEST_DAI_TYPE, TEST_DAI_PORT, - TEST_SSP_DATA_BITS))) + ifelse(TEST_DAI_TYPE, `SSP', + SSP_CONFIG(TEST_SSP_MODE, + DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), + DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + DAI_CLOCK(fsync, 48000, codec_slave), + DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), + SSP_SAMPLE_BITS(TEST_DAI_TYPE, TEST_DAI_PORT, + TEST_SSP_DATA_BITS)), + TEST_DAI_TYPE, `DMIC', + DMIC_CONFIG(TEST_DMIC_DRIVER_VERSION,TEST_DMIC_CLK_MIN, + TEST_DMIC_CLK_MAX, TEST_DMIC_DUTY_MIN, + TEST_DMIC_DUTY_MAX, TEST_PDM_ACTIVE, + TEST_DMIC_SAMPLE_RATE, DMIC_WORD_LENGTH(TEST_DAI_FORMAT), + TEST_DAI_TYPE, TEST_DAI_PORT, + PDM_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, + LIST(`', PDM_TUPLES(0, 1, 1, 0, 0, 0, 0)))), + `')) From 5a59eca380043b3bec534be29dfc517cc6010350 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Mon, 4 Jun 2018 10:43:10 +0800 Subject: [PATCH 175/324] topology: test: Fix tplb-build.sh when did no use XARGS Miss TFILE when not using XARGS. Signed-off-by: Pan Xiuli --- topology/test/tplg-build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index fadf7f52edab..ad4d1da10c2d 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -91,6 +91,12 @@ function simple_test { #if DAI type is SSP, define the SSP specific params if [ $5 == "SSP" ] then + if [ $i == "test-all" ] + then + TFILE="test-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" + else + TFILE="$i-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" + fi echo "M4 pre-processing test $i -> ${TFILE}" m4 ${M4_FLAGS} \ -DTEST_PIPE_NAME="$2" \ From b3221684388e57f8031af6186172ea83b4f1edd2 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 4 Jun 2018 11:02:00 +0300 Subject: [PATCH 176/324] SOFT: Add SRC coefficients generate tool This patch adds the scripts src_std_int32.m and src_tiny_int16.m those were used to create the conversions matrices for the default and tiny profiles. The scripts call the included src_generate function that does the task with help from the filter design and coefficients export utilities. The quality and resources consumption of SRC can be customized with this tool. Signed-off-by: Seppo Ingalsuo --- tune/src/README | 36 ++++ tune/src/src_export_coef.m | 212 ++++++++++++++++++++++ tune/src/src_export_defines.m | 66 +++++++ tune/src/src_export_table_2s.m | 190 ++++++++++++++++++++ tune/src/src_factor1_lm.m | 44 +++++ tune/src/src_factor2_lm.m | 155 ++++++++++++++++ tune/src/src_find_l0m0.m | 71 ++++++++ tune/src/src_generate.m | 311 +++++++++++++++++++++++++++++++++ tune/src/src_get.m | 254 +++++++++++++++++++++++++++ tune/src/src_param.m | 87 +++++++++ tune/src/src_std_int32.m | 30 ++++ tune/src/src_tiny_int16.m | 41 +++++ 12 files changed, 1497 insertions(+) create mode 100644 tune/src/README create mode 100644 tune/src/src_export_coef.m create mode 100644 tune/src/src_export_defines.m create mode 100644 tune/src/src_export_table_2s.m create mode 100644 tune/src/src_factor1_lm.m create mode 100644 tune/src/src_factor2_lm.m create mode 100644 tune/src/src_find_l0m0.m create mode 100644 tune/src/src_generate.m create mode 100644 tune/src/src_get.m create mode 100644 tune/src/src_param.m create mode 100644 tune/src/src_std_int32.m create mode 100644 tune/src/src_tiny_int16.m diff --git a/tune/src/README b/tune/src/README new file mode 100644 index 000000000000..e135f9a21979 --- /dev/null +++ b/tune/src/README @@ -0,0 +1,36 @@ +Sample rate converter (SRC) Setup Tools +======================================= + +This is a tool to set up SRC conversions sample rates list, define +quality related parameters, and test the C implementation for a number +of objective audio quality parameters. + +The tools need GNU Octave version 4.0.0 or later with octave-signal +package. + +src_std_int32.m +--------------- + +This script creates the default coefficient set and contains nothing +else but call for src_generate. + +src_tiny_int16.m +---------------- + +This script creates the tiny coefficient set. The script contains an +example how to customize the input/output rates matrix and in a simple +way the scale conversions quality. More controlled quality adjust can +be done by editing file src_param.m directly. Note that int16 +presentation for SRC coefficients will degrade even the default +quality. + +src_generate.m +-------------- + +Creates the header files to include to C into directory "include". A +report of create modes is written to directory "reports". The +coefficients need to be copied to directory +sof.git/src/include/sof/audio/coefficients/src. + +The default quality of SRC is defined in module src_param.m. The +quality impacts the complexity and coefficents tables size of SRC. diff --git a/tune/src/src_export_coef.m b/tune/src/src_export_coef.m new file mode 100644 index 000000000000..f6fdbb40ba23 --- /dev/null +++ b/tune/src/src_export_coef.m @@ -0,0 +1,212 @@ +function success=src_export_coef(src, ctype, vtype, hdir, profile) + +% src_export_coef - Export FIR coefficients +% +% success=src_export_coef(src, ctype, hdir, profile) +% +% src - src definition struct +% ctype - 'float','int32', or 'int24' +% vtype - 'float','int32_t' +% hdir - directory for header files +% profile - string to append to filename +% + +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +if nargin < 5 + profile = ''; +end + +if src.L == src.M + success = 0; +else + pbi = round(src.c_pb*1e4); + sbi = round(src.c_sb*1e4); + if isempty(profile) + hfn = sprintf('%s/src_%s_%d_%d_%d_%d.h', ... + hdir, ctype, src.L, src.M, pbi, sbi); + else + hfn = sprintf('%s/src_%s_%s_%d_%d_%d_%d.h', ... + hdir, profile, ctype, src.L, src.M, pbi, sbi); + end + vfn = sprintf('src_%s_%d_%d_%d_%d_fir', ctype, src.L, src.M, pbi, sbi); + sfn = sprintf('src_%s_%d_%d_%d_%d', ctype, src.L, src.M, pbi, sbi); + + fprintf('Exporting %s ...\n', hfn); + fh = fopen(hfn, 'w'); + + switch ctype + case 'float' + fprintf(fh, 'const %s %s[%d] = {\n', ... + vtype, vfn, src.filter_length); + fprintf(fh,'\t%16.9e', src.coefs(1)); + for n=2:src.filter_length + fprintf(fh, ',\n'); + fprintf(fh,'\t%16.9e', src.coefs(n)); + end + fprintf(fh,'\n\n};'); + case 'int32' + print_int_coef(src, fh, vtype, vfn, 32); + case 'int24' + print_int_coef(src, fh, vtype, vfn, 24); + case 'int16' + print_int_coef(src, fh, vtype, vfn, 16); + otherwise + error('Unknown type %s !!!', ctype); + end + + fprintf(fh, '\n'); + switch ctype + case 'float' + fprintf(fh, 'struct src_stage %s = {\n', sfn); + fprintf(fh, '\t%d, %d, %d, %d, %d, %d, %d, %d, %f,\n\t%s};\n', ... + src.idm, src.odm, src.num_of_subfilters, ... + src.subfilter_length, src.filter_length, ... + src.blk_in, src.blk_out, src.halfband, ... + src.gain, vfn); + case { 'int16' 'int24' 'int32' } + fprintf(fh, 'struct src_stage %s = {\n', sfn); + fprintf(fh, '\t%d, %d, %d, %d, %d, %d, %d, %d, %d,\n\t%s};\n', ... + src.idm, src.odm, src.num_of_subfilters, ... + src.subfilter_length, src.filter_length, ... + src.blk_in, src.blk_out, src.halfband, ... + src.shift, vfn); + otherwise + error('Unknown type %s !!!', ctype); + end + %fprintf(fh, '\n'); + fclose(fh); + success = 1; +end + +end + +function print_int_coef(src, fh, vtype, vfn, nbits) + fprintf(fh, 'const %s %s[%d] = {\n', ... + vtype, vfn, src.filter_length); + + cint = coef_quant(src, nbits); + fprintf(fh,'\t%d', cint(1)); + for n=2:src.filter_length + fprintf(fh, ',\n'); + fprintf(fh,'\t%d', cint(n)); + end + fprintf(fh,'\n\n};'); +end + +function cint = coef_quant(src, nbits) + + sref = 2^(nbits-1); + pmax = sref-1; + nmin = -sref; + + if nbits > 16 + %% Round() is OK + cint0 = round(sref*src.coefs); + else + %% Prepare to optimize coefficient quantization + fs = max(src.fs1, src.fs2); + f = linspace(0, fs/2, 1000); + + %% Test sensitivity for stopband and find the most sensitive + % coefficients + sbf = linspace(src.f_sb,fs/2, 500); + n = src.filter_length; + psens = zeros(1,n); + bq0 = round(sref*src.coefs); + h = freqz(bq0/sref/src.L, 1, sbf, fs); + sb1 = 20*log10(sqrt(sum(h.*conj(h)))); + for i=1:n + bq = src.coefs; + bq(i) = round(sref*bq(i))/sref; + %tbq = bq; %tbq(i) = bq(i)+1; + h = freqz(bq, 1, sbf, fs); + psens(i) = sum(h.*conj(h)); + end + [spsens, pidx] = sort(psens, 'descend'); + + %% Test quantization in the found order + % The impact to passband is minimal so it's not tested + bi = round(sref*src.coefs); + bi0 = bi; + dl = -1:1; + nd = length(dl); + msb = zeros(1,nd); + for i=pidx + bit = bi; + for j=1:nd + bit(i) = bi(i) + dl(j); + h = freqz(bit, 1, sbf, fs); + msb(j) = sum(h.*conj(h)); + end + idx = find(msb == min(msb), 1, 'first'); + bi(i) = bi(i) + dl(idx); + end + h = freqz(bi/sref/src.L, 1, sbf, fs); + sb2 = 20*log10(sqrt(sum(h.*conj(h)))); + + %% Plot to compare + if 0 + f = linspace(0, fs/2, 1000); + h1 = freqz(src.coefs/src.L, 1, f, fs); + h2 = freqz(bq0/sref/src.L, 1, f, fs); + h3 = freqz(bi/sref/src.L, 1, f, fs); + figure; + plot(f, 20*log10(abs(h1)), f, 20*log10(abs(h2)), f, 20*log10(abs(h3))); + grid on; + fprintf('Original = %4.1f dB, optimized = %4.1f dB, delta = %4.1f dB\n', ... + sb1, sb2, sb1-sb2); + end + cint0 = bi; + end + + + %% Re-order coefficients for filter implementation + cint = zeros(src.filter_length,1); + for n = 1:src.num_of_subfilters + i11 = (n-1)*src.subfilter_length+1; + i12 = i11+src.subfilter_length-1; + cint(i11:i12) = cint0(n:src.num_of_subfilters:end); + end + + %% Done check for no overflow + max_fix = max(cint); + min_fix = min(cint); + if (max_fix > pmax) + printf('Fixed point coefficient %d exceeded %d\n.', max_fix, pmax); + error('Something went wrong!'); + end + if (min_fix < nmin) + printf('Fixed point coefficient %d exceeded %d\n.', min_fix, nmax); + error('Something went wrong!'); + end + + +end diff --git a/tune/src/src_export_defines.m b/tune/src/src_export_defines.m new file mode 100644 index 000000000000..63fb4c28f7d5 --- /dev/null +++ b/tune/src/src_export_defines.m @@ -0,0 +1,66 @@ +function src_export_defines(defs, ctype, hdir, profile) + +% src_export_defines - Exports the constants to header files +% +% src_export_defines(defs, ctype, hdir) +% +% defs - defs struct +% ctype - e.g. 'int24' appended to file name +% hdir - directory for header file +% profile - string to append to file name +% + + +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +if nargin < 4 + profile = ''; +end + +if isempty(profile) + hfn = sprintf('src_%s_define.h', ctype); +else + hfn = sprintf('src_%s_%s_define.h', profile, ctype); +end +fh = fopen(fullfile(hdir,hfn), 'w'); +fprintf(fh, '/* SRC constants */\n'); +fprintf(fh, '#define MAX_FIR_DELAY_SIZE %d\n', defs.fir_delay_size); +fprintf(fh, '#define MAX_OUT_DELAY_SIZE %d\n', defs.out_delay_size); +fprintf(fh, '#define MAX_BLK_IN %d\n', defs.blk_in); +fprintf(fh, '#define MAX_BLK_OUT %d\n', defs.blk_out); +fprintf(fh, '#define NUM_IN_FS %d\n', defs.num_in_fs); +fprintf(fh, '#define NUM_OUT_FS %d\n', defs.num_out_fs); +fprintf(fh, '#define STAGE1_TIMES_MAX %d\n', defs.stage1_times_max); +fprintf(fh, '#define STAGE2_TIMES_MAX %d\n', defs.stage2_times_max); +fprintf(fh, '#define STAGE_BUF_SIZE %d\n', defs.stage_buf_size); +fprintf(fh, '#define NUM_ALL_COEFFICIENTS %d\n', defs.sum_filter_lengths); +fclose(fh); + +end diff --git a/tune/src/src_export_table_2s.m b/tune/src/src_export_table_2s.m new file mode 100644 index 000000000000..7772b9369205 --- /dev/null +++ b/tune/src/src_export_table_2s.m @@ -0,0 +1,190 @@ +function sfl = src_export_table_2s(fs_in, fs_out, l_2s, m_2s, ... + pb_2s, sb_2s, taps_2s, ctype, vtype, ppath, hdir, profile) + +% src_export_table_2s - Export src setup table +% +% src_export_table_2s(fs_in, fs_out, l, m, pb, sb, ctype, vtype, hdir, profile) +% +% The parameters are used to differentiate files for possibly many same +% conversion factor filters with possibly different characteristic. +% +% fs_in - input sample rates +% fs_out - output sample rates +% l - interpolation factors +% m - decimation factors +% pb - passband widths +% sb - stopband start frequencies +% ctype - coefficient quantization +% vtype - C variable type +% ppath - print directory prefix to header file name include +% hdir - directory for header files +% profile - string to append to file name +% + +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +if nargin < 12 + profile = ''; +end + +if isempty(profile) + hfn = sprintf('src_%s_table.h', ctype); +else + hfn = sprintf('src_%s_%s_table.h', profile, ctype); +end +fh = fopen(fullfile(hdir,hfn), 'w'); + +fprintf(fh, '/* SRC conversions */\n'); +sfl = 0; +n_in = length(fs_in); +n_out = length(fs_out); +i=1; +all_modes = zeros(2*n_in*n_out, 7); +for n=1:2 + for b=1:n_out + for a=1:n_in + all_modes(i,:) = [ l_2s(n,a,b) m_2s(n,a,b) ... + pb_2s(n,a,b) sb_2s(n,a,b) n a b ]; + i=i+1; + end + end +end + +all_modes_sub = all_modes(:,1:4); +[unique_modes, ia] = unique(all_modes_sub,'rows'); +sm = size(unique_modes); + +if isempty(profile) + prof_ctype = ctype; +else + prof_ctype = sprintf('%s_%s', profile, ctype); +end +for i=1:sm(1) + um_tmp = unique_modes(i,:); + if isequal(um_tmp(1:2),[1 1]) || isequal(um_tmp(1:2),[0 0]) + else + fprintf(fh, '#include <%ssrc_%s_%d_%d_%d_%d.h>\n', ... + ppath, prof_ctype, um_tmp(1:4)); + + n = all_modes(ia(i), 5); + a = all_modes(ia(i), 6); + b = all_modes(ia(i), 7); + sfl = sfl +taps_2s(n, a, b); % Count sum of filter lengths + end +end +fprintf(fh,'\n'); + +fprintf(fh, '/* SRC table */\n'); +switch ctype + case 'float' + fprintf(fh, '%s fir_one = 1.0;\n', vtype); + fprintf(fh, 'struct src_stage src_double_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, 1.0, &fir_one };\n'); + fprintf(fh, 'struct src_stage src_double_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0.0, &fir_one };\n'); + case 'int16' + scale16 = 2^15; + fprintf(fh, '%s fir_one = %d;\n', vtype, round(scale16*0.5)); + fprintf(fh, 'struct src_stage src_int16_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n'); + fprintf(fh, 'struct src_stage src_int16_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n'); + case 'int24' + scale24 = 2^23; + fprintf(fh, '%s fir_one = %d;\n', vtype, round(scale24*0.5)); + fprintf(fh, 'struct src_stage src_int24_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n'); + fprintf(fh, 'struct src_stage src_int24_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n'); + case 'int32' + scale32 = 2^31; + fprintf(fh, '%s fir_one = %d;\n', vtype, round(scale32*0.5)); + fprintf(fh, 'struct src_stage src_int32_1_1_0_0 = { 0, 0, 1, 1, 1, 1, 1, 0, -1, &fir_one };\n'); + fprintf(fh, 'struct src_stage src_int32_0_0_0_0 = { 0, 0, 0, 0, 0, 0, 0, 0, 0, &fir_one };\n'); + otherwise + error('Unknown coefficient type!'); +end + +fprintf(fh, 'int src_in_fs[%d] = {', n_in); +j = 1; +for i=1:n_in + fprintf(fh, ' %d', fs_in(i)); + if i < n_in + fprintf(fh, ','); + end + j = j + 1; + if (j > 8) + fprintf(fh, '\n\t'); + j = 1; + end +end +fprintf(fh, '};\n'); + +fprintf(fh, 'int src_out_fs[%d] = {', n_out); +j = 1; +for i=1:n_out + fprintf(fh, ' %d', fs_out(i)); + if i < n_out + fprintf(fh, ','); + end + j = j + 1; + if (j > 8) + fprintf(fh, '\n\t'); + j = 1; + end +end +fprintf(fh, '};\n'); + +for n = 1:2 + fprintf(fh, 'struct src_stage *src_table%d[%d][%d] = {\n', ... + n, n_out, n_in); + i = 1; + for b = 1:n_out + fprintf(fh, '\t{'); + for a = 1:n_in + fprintf(fh, ' &src_%s_%d_%d_%d_%d', ... + ctype, l_2s(n,a,b), m_2s(n,a,b), ... + pb_2s(n,a,b), sb_2s(n,a,b)); + if a < n_in + fprintf(fh, ','); + end + i = i + 1; + if i > 2 + fprintf(fh, '\n\t'); + i = 1; + end + end + fprintf(fh, '}'); + if b < n_out + fprintf(fh, ',\n'); + else + fprintf(fh, '\n'); + end + end + fprintf(fh, '};\n'); +end + +fclose(fh); + +end diff --git a/tune/src/src_factor1_lm.m b/tune/src/src_factor1_lm.m new file mode 100644 index 000000000000..54e9173e3f84 --- /dev/null +++ b/tune/src/src_factor1_lm.m @@ -0,0 +1,44 @@ +function [l, m] = src_factor1_lm(fs1, fs2) + +% factor1_lm - factorize input and output sample rates ratio to fraction l/m +% +% [l, m] = factor1_lm(fs1, fs2) +% +% fs1 - input sample rate +% fs2 - output sample rate +% + +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +k = gcd(fs1, fs2); +l = fs2/k; +m = fs1/k; + +end diff --git a/tune/src/src_factor2_lm.m b/tune/src/src_factor2_lm.m new file mode 100644 index 000000000000..6ac86020d438 --- /dev/null +++ b/tune/src/src_factor2_lm.m @@ -0,0 +1,155 @@ +function [l1, m1, l2, m2] = src_factor2_lm(fs1, fs2) + +% factor2_lm - factorize input and output sample rates ratio to fraction l1/m2*l2/m2 +% +% [l1, m1, l2, m2] = factor2_lm(fs1, fs2) +% +% fs1 - input sample rate +% fs2 - output sample rate +% + +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + + +%% The same sample rate? +if abs(fs1-fs2) < eps + l1 = 1; m1 = 1; l2 = 1; m2 = 1; + return +end + +%% Find fraction, and factorize +k = gcd(fs1, fs2); +l = fs2/k; +m = fs1/k; +[l01, l02] = factor2(l); +[m01, m02] = factor2(m); + +%% Hand fixing for some ratios, guide to reuse some common filters +if (l==147) && (m==640) + l01 = 7; m01 = 8; l02 = l/l01; m02 = m/m01; % 192 to 44.1 +end +if (l==147) && (m==320) + l01 = 7; m01 = 8; l02 = l/l01; m02 = m/m01; % 96 to 44.1 +end +if (l==147) && (m==160) + l01 = 7; m01 = 8; l02 = l/l01; m02 = m/m01; % 48 to 44.1 +end +if (l==160) && (m==147) + l01 = 8; m01 = 7; l02 = l/l01; m02 = m/m01; % 44.1 to 48 +end +if (l==320) && (m==147) + l01 = 8; m01 = 7; l02 = l/l01; m02 = m/m01; % 44.1 to 96 +end +if (l==4) && (m==3) + l01 = 4; m01 = 3; l02 = l/l01; m02 = m/m01; % 24 to 32, no 2 stage +end +if (l==3) && (m==4) + l01 = 3; m01 = 4; l02 = l/l01; m02 = m/m01; % 24 to 32, no 2 stage +end + + +r11 = l01/m01; +r22 = l02/m02; +r12 = l01/m02; +r21 = l02/m01; +fs3 = [r11 r12 r21 r22].*fs1; + + +if fs1 > fs2 % Decrease sample rate, dont go below output rate + idx = find(fs3 >= fs2); + if length(idx) < 1 + error('Cant factorise interpolations'); + end + fs3_possible = fs3(idx); + delta = fs3_possible-fs2; % Fs3 that is nearest to fs2 + idx = find(delta == min(delta), 1, 'first'); + fs3_min = fs3_possible(idx); + idx = find(fs3 == fs3_min, 1, 'first'); + switch idx + case 1, l1 = l01; m1 = m01; l2 = l02; m2 = m02; + case 2, l1 = l01; m1 = m02; l2 = l02; m2 = m01; + case 3, l1 = l02; m1 = m01; l2 = l01; m2 = m02; + case 4, l1 = l02; m1 = m02; l2 = l01; m2 = m01; + end +else % Increase sample rate, don't go below input rate + idx = find(fs3 >= fs1); + if length(idx) < 1 + error('Cant factorise interpolations'); + end + fs3_possible = fs3(idx); + delta = fs3_possible-fs1; % Fs2 that is nearest to fs1 + idx = find(delta == min(delta), 1, 'first'); + fs3_min = fs3_possible(idx); + idx = find(fs3 == fs3_min, 1, 'first'); + switch idx + case 1, l1 = l01; m1 = m01; l2 = l02; m2 = m02; + case 2, l1 = l01; m1 = m02; l2 = l02; m2 = m01; + case 3, l1 = l02; m1 = m01; l2 = l01; m2 = m02; + case 4, l1 = l02; m1 = m02; l2 = l01; m2 = m01; + end +end + +%% If 1st stage is 1:1 +if (l1 == 1) && (m1 == 1) + l1 = l2; + m1 = m2; + l2 = 1; + m2 = 1; +end + +f1=l/m; +f2=l1/m1*l2/m2; +if abs(f1 - f2) > 1e-6 + error('Bug in factorization code!'); +end + +end + + +function [a, b]=factor2(c) +x = round(sqrt(c)); +t1 = x:2*x; +d1 = c./t1; +idx1 = find(d1 == floor(d1), 1, 'first'); +a1 = t1(idx1); +t2 = x:-1:floor(x/2); +d2 = c./t2; +idx2 = find(d2 == floor(d2), 1, 'first'); +a2 = t2(idx2); +if (a1-x) < (x-a2) + a = a1; +else + a = a2; +end +b = c/a; +end + + + diff --git a/tune/src/src_find_l0m0.m b/tune/src/src_find_l0m0.m new file mode 100644 index 000000000000..2a360a363a90 --- /dev/null +++ b/tune/src/src_find_l0m0.m @@ -0,0 +1,71 @@ +function [l0, m0] = src_find_l0m0(L, M) + +% find_l0m0 - find l0, m0 to meet -l0*L + m0*M == 1 +% +% [l0, m0] = find_l0m0(L, M) +% +% L - interpolatation factor +% M - decimation factor +% + +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +if M == 1 + l0 = 0; + m0 = 1; + return +end + +if L == 1 + l0 = 1; + m0 = 0; + return +end + +l0 = []; +m0 = []; +for lt=1:4*L + mt = (1+lt*L)/M; % Check if -lt*L + mt*M == 1 + if floor(mt) == mt + l0 = [l0 lt]; + m0 = [m0 mt]; + end +end + +s = l0+m0; +idx = find(s == min(s), 1, 'first'); +l0 = l0(idx); +m0 = m0(idx); + +if -l0*L + m0*M ~= 1 + error('Something went wrong!'); +end + +end diff --git a/tune/src/src_generate.m b/tune/src/src_generate.m new file mode 100644 index 000000000000..b01b29ddb062 --- /dev/null +++ b/tune/src/src_generate.m @@ -0,0 +1,311 @@ +function src_generate(fs_in, fs_out, ctype, fs_inout, profile, qc) + +% src_generate - export src conversions for given fs_in and fs_out +% +% src_generate(fs_in, fs_out <, ctype, fs_inout>>) +% +% fs_in - vector of input sample rates (M) +% fs_out - vector of output sample rates (N) +% ctype - coefficient type, use 'int16','int24', 'int32', or 'float' +% fs_inout - matrix of supported conversions (MxN), +% 0 = no support, 1 = supported +% % +% if ctype is omitted then ctype defaults to 'int16'. +% +% If fs_inout matrix is omitted this script will compute coefficients +% for all fs_in <-> fs_out combinations. +% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +if (nargin == 1) || (nargin > 6) + error('Incorrect arguments for function!'); +end +if nargin == 0 + %% Default input and output rates + fs_in = [8e3 11025 12e3 16e3 18900 22050 24e3 32e3 44100 48e3 ... + 64e3 88.2e3 96e3 176400 192e3]; + + fs_out = [8e3 11025 12e3 16e3 18900 22050 24e3 32e3 44100 48e3]; + + fs_inout = [ 0 0 0 1 0 0 1 1 0 1 ; ... + 0 0 0 0 0 0 0 0 0 1 ; ... + 0 0 0 0 0 0 0 0 0 1 ; ... + 1 0 0 0 0 0 1 1 0 1 ; ... + 0 0 0 0 0 0 0 0 0 1 ; ... + 0 0 0 0 0 0 0 0 0 1 ; ... + 1 0 0 1 0 0 0 1 0 1 ; ... + 1 0 0 1 0 0 1 0 0 1 ; ... + 0 0 0 0 0 0 0 0 0 1 ; ... + 1 1 1 1 0 1 1 1 1 0 ; ... + 0 0 0 0 0 0 0 0 0 1 ; ... + 0 0 0 0 0 0 0 0 0 1 ; ... + 0 0 0 0 0 0 0 0 0 1 ; ... + 0 0 0 0 0 0 0 0 0 1 ; ... + 0 0 0 0 0 0 0 0 0 1 ]; + + ctype = 'int32'; + profile = 'std'; + qc = 1.0; +else + if nargin < 3 + ctype = 'int16'; + end + if nargin < 4 + fs_inout = ones(length(fs_in), length(fs_out)); + end + if nargin < 5 + profile = ''; + end + if nargin < 6 + qc = 1.0; + end +end + +sio = size(fs_inout); +if (length(fs_in) ~= sio(1)) || (length(fs_out) ~= sio(2)) + error('Sample rates in/out matrix size mismatch!'); +end + +%% Exported coefficients type int16, int24, int32, float + +switch ctype + case 'int16' + coef_label = 'int16'; + coef_ctype = 'int16_t'; + coef_bits = 16; + coef_bytes = 2; + case 'int24' + coef_label = 'int24'; + coef_ctype = 'int32_t'; + coef_bits = 24; + coef_bytes = 4; + case 'int32' + coef_label = 'int32'; + coef_ctype = 'int32_t'; + coef_bits = 32; + coef_bytes = 4; + case 'float' + coef_label = 'float'; coef_ctype = 'float'; + coef_bits = 24; + coef_bytes = 4; + otherwise + error('Request for incorrect coefficient type'); +end +data_bytes = 4; + +hdir = mkdir_check('include'); +rdir = mkdir_check('reports'); + +%% Find fractional conversion factors +nfsi = length(fs_in); +nfso = length(fs_out); +l_2s = zeros(2, nfsi, nfso); +m_2s = zeros(2, nfsi, nfso); +mops_2s = zeros(2, nfsi, nfso); +pb_2s = zeros(2,nfsi, nfso); +sb_2s = zeros(2,nfsi, nfso); +taps_2s = zeros(2,nfsi, nfso); +defs.fir_delay_size = 0; +defs.out_delay_size = 0; +defs.blk_in = 0; +defs.blk_out = 0; +defs.num_in_fs = nfsi; +defs.num_out_fs = nfso; +defs.stage1_times_max = 0; +defs.stage2_times_max = 0; +defs.stage_buf_size = 0; +h = 1; +for b = 1:nfso + for a = 1:nfsi + fs1 = fs_in(a); + fs2 = fs_out(b); + [l1, m1, l2, m2] = src_factor2_lm(fs1, fs2); + fs3 = fs1*l1/m1; + cnv1 = src_param(fs1, fs3, coef_bits, qc); + cnv2 = src_param(fs3, fs2, coef_bits, qc); + if (fs2 < fs1) + % When decimating 1st stage passband can be limited + % for wider transition band + f_pb = fs2*cnv2.c_pb; + cnv1.c_pb = f_pb/min(fs1,fs3); + end + if (fs2 > fs1) + % When interpolating 2nd stage passband can be limited + % for wider transition band + f_pb = fs1*cnv1.c_pb; + cnv2.c_pb = f_pb/min(fs2,fs3); + end + if fs_inout(a,b) > 0 || (a == b) + if cnv2.fs1-cnv2.fs2 > eps + % Allow half ripple for dual stage SRC parts + cnv1.rp = cnv1.rp/2; + cnv2.rp = cnv2.rp/2; + end + src1 = src_get(cnv1); + src2 = src_get(cnv2); + k = gcd(src1.blk_out, src2.blk_in); + stage1_times = src2.blk_in/k; + stage2_times = stage1_times*src1.blk_out/src2.blk_in; + defs.stage1_times_max = max(defs.stage1_times_max, stage1_times); + defs.stage2_times_max = max(defs.stage2_times_max, stage2_times); + l_2s(:,a,b) = [src1.L src2.L]; + m_2s(:,a,b) = [src1.M src2.M]; + mops_2s(:,a,b) = [src1.MOPS src2.MOPS]; + pb_2s(:,a,b) = [round(1e4*src1.c_pb) round(1e4*src2.c_pb)]; + sb_2s(:,a,b) = [round(1e4*src1.c_sb) round(1e4*src2.c_sb)]; + taps_2s(:,a,b) = [src1.filter_length src2.filter_length]; + defs.fir_delay_size = max(defs.fir_delay_size, src1.fir_delay_size); + defs.out_delay_size = max(defs.out_delay_size, src1.out_delay_size); + defs.blk_in = max(defs.blk_in, src1.blk_in); + defs.blk_out = max(defs.blk_out, src1.blk_out); + defs.fir_delay_size = max(defs.fir_delay_size, src2.fir_delay_size); + defs.out_delay_size = max(defs.out_delay_size, src2.out_delay_size); + defs.blk_in = max(defs.blk_in, src2.blk_in); + defs.blk_out = max(defs.blk_out, src2.blk_out); + defs.stage_buf_size = max(defs.stage_buf_size, src1.blk_out*stage1_times); + src_export_coef(src1, coef_label, coef_ctype, hdir, profile); + src_export_coef(src2, coef_label, coef_ctype, hdir, profile); + end + end +end + +%% Export modes table +defs.sum_filter_lengths = src_export_table_2s(fs_in, fs_out, l_2s, m_2s, ... + pb_2s, sb_2s, taps_2s, coef_label, coef_ctype, ... + 'sof/audio/coefficients/src/', hdir, profile); +src_export_defines(defs, coef_label, hdir, profile); + +%% Print 2 stage conversion factors +fn = sprintf('%s/src_2stage.txt', rdir); +fh = fopen(fn,'w'); +fprintf(fh,'\n'); +fprintf(fh,'Dual stage fractional SRC: Ratios\n'); +fprintf(fh,'%8s, ', 'in \ out'); +for b = 1:nfso + fprintf(fh,'%12.1f, ', fs_out(b)/1e3); +end +fprintf(fh,'\n'); +for a = 1:nfsi + fprintf(fh,'%8.1f, ', fs_in(a)/1e3); + for b = 1:nfso + cstr = print_ratios(l_2s, m_2s, a, b); + fprintf(fh,'%12s, ', cstr); + end + fprintf(fh,'\n'); +end +fprintf(fh,'\n'); + +%% Print 2 stage MOPS +fprintf(fh,'Dual stage fractional SRC: MOPS\n'); +fprintf(fh,'%8s, ', 'in \ out'); +for b = 1:nfso + fprintf(fh,'%8.1f, ', fs_out(b)/1e3); +end +fprintf(fh,'\n'); +for a = 1:nfsi + fprintf(fh,'%8.1f, ', fs_in(a)/1e3); + for b = 1:nfso + mops = sum(mops_2s(:,a,b)); + if sum(l_2s(:,a,b)) < eps + mops_str = 'x'; + else + mops_str = sprintf('%.2f', mops); + end + fprintf(fh,'%8s, ', mops_str); + end + fprintf(fh,'\n'); +end +fprintf(fh,'\n'); + +%% Print 2 stage MOPS per stage +fprintf(fh,'Dual stage fractional SRC: MOPS per stage\n'); +fprintf(fh,'%10s, ', 'in \ out'); +for b = 1:nfso + fprintf(fh,'%10.1f, ', fs_out(b)/1e3); +end +fprintf(fh,'\n'); +for a = 1:nfsi + fprintf(fh,'%10.1f, ', fs_in(a)/1e3); + for b = 1:nfso + mops = mops_2s(:,a,b); + if sum(l_2s(:,a,b)) < eps + mops_str = 'x'; + else + mops_str = sprintf('%.2f+%.2f', mops(1), mops(2)); + end + fprintf(fh,'%10s, ', mops_str); + end + fprintf(fh,'\n'); +end +fprintf(fh,'\n'); + +fprintf(fh,'Coefficient RAM %.1f kB\n', ... + defs.sum_filter_lengths*coef_bytes/1024); +fprintf(fh,'Max. data RAM %.1f kB\n', ... + (defs.fir_delay_size + defs.out_delay_size+defs.stage_buf_size) ... + * data_bytes/1024); + +fprintf(fh,'\n'); +fclose(fh); +type(fn); + +end + +function d = mkdir_check(d) +if exist(d) ~= 7 + mkdir(d); +end +end + +function cstr = print_ratios(l_2s, m_2s, a, b) +l1 = l_2s(1,a,b); +m1 = m_2s(1,a,b); +l2 = l_2s(2,a,b); +m2 = m_2s(2,a,b); +if l1+m2+l2+m2 == 0 + cstr = 'x'; +else + if m2 == 1 + if l2 == 1 + cstr2 = ''; + else + cstr2 = sprintf('*%d', l2); + end + else + cstr2 = sprintf('*%d/%d', l2, m2); + end + if m1 == 1 + cstr1 = sprintf('%d', l1); + else + cstr1 = sprintf('%d/%d', l1, m1); + end + cstr = sprintf('%s%s', cstr1, cstr2); +end +end diff --git a/tune/src/src_get.m b/tune/src/src_get.m new file mode 100644 index 000000000000..4520af99a850 --- /dev/null +++ b/tune/src/src_get.m @@ -0,0 +1,254 @@ +function src = src_get(cnv) + +% src_get - calculate coefficients for a src +% +% src = src_get(cnv); +% +% cnv - src parameters +% src - src result +% + +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +use_firpm = 0; +use_remez = 0; +use_kaiser = 0; +switch lower(cnv.design) + case 'firpm' + if exist('OCTAVE_VERSION', 'builtin') + use_remez = 1; + else + use_firpm = 1; + end + case 'kaiser' + use_kaiser = 1; + otherwise + error('Unknown FIR design request!'); +end + +if abs(cnv.fs1-cnv.fs2) < 1 + %% Return minimum needed for scripts to work + src.L=1; + src.M=1; + src.odm=1; + src.idm=1; + src.MOPS=0; + src.c_pb = 0; + src.c_sb = 0; + src.fir_delay_size = 0; + src.out_delay_size = 0; + src.blk_in = 1; + src.blk_out = 1; + src.gain = 1; + src.filter_length = 0; + return +end + +%% fractional SRC parameters +[L, M] = src_factor1_lm(cnv.fs1, cnv.fs2); +src.L = L; +src.M = M; +src.num_of_subfilters = L; +[src.idm src.odm] = src_find_l0m0(src.L, src.M); +min_fs = min(cnv.fs1,cnv.fs2); +src.f_pb = min_fs*cnv.c_pb; +src.f_sb = min_fs*cnv.c_sb; +src.c_pb = cnv.c_pb; +src.c_sb = cnv.c_sb; +src.fs1 = cnv.fs1; +src.fs2 = cnv.fs2; +src.rp = cnv.rp; +src.rs = cnv.rs; + +%% FIR PM design +fs3 = src.L*cnv.fs1; +f = [src.f_pb src.f_sb]; +a = [1 0]; + +% Kaiser fir is not equiripple, can allow more ripple in the passband +% lower freq. +dev = [(10^(cnv.rp/20)-1)/(10^(cnv.rp/20)+1) 10^(-cnv.rs/20)]; +[kn0, kw, kbeta, kftype] = kaiserord(f, a, dev, fs3); +if use_firpm + %dev = [(10^(cnv.rp/20)-1)/(10^(cnv.rp/20)+1) 10^(-cnv.rs/20)]; + [n0,fo,ao,w] = firpmord(f,a,dev,fs3); + n0 = round(n0*0.95); % Decrease order to 95% +end +if use_remez + n0 = round(kn0*0.60); % Decrease order to 70% + fo = [0 2*f/fs3 1]; + ao = [1 1 0 0]; + w = [1 dev(1)/dev(2)]; +end +if use_kaiser + n0 = round(kn0*0.70); % Decrease order to 70% +end + +% Constrain filter length to be a suitable multiple. Multiple of +% interpolation factor ensures that all subfilters are equal length. +% Make each sub-filter order multiple of N helps in making efficient +% implementation. +nfir_increment = src.num_of_subfilters * cnv.filter_length_mult; + +nsf0 = (n0+1)/nfir_increment; +if nsf0 > floor(nsf0) + n = (floor(nsf0)+1)*nfir_increment-1; +else + n = n0; +end + +src.subfilter_length = (n+1)/src.num_of_subfilters; +src.filter_length = n+1; +nfir = n; +f_sb = linspace(src.f_sb, fs3/2, 500); +stopband_ok = 0; +need_to_stop = 0; +delta = 100; +n_worse = 0; +n_worse_max = 20; +n = 1; +n_max = 100; +dn = ones(1, n_max)*1000; +fn = zeros(1, n_max); +while (stopband_ok) == 0 && (n < n_max) + if use_firpm || use_remez + if nfir > 1800 + b = fir1(nfir, kw, kftype, kaiser(nfir+1, kbeta)); + else + if use_firpm + b = firpm(nfir,fo,ao,w); + else + b = remez(nfir,fo,ao,w); + end + end + else + b = fir1(nfir, kw, kftype, kaiser(nfir+1, kbeta)); + end + m_b = max(abs(b)); + %sref = 2^(cnv.coef_bits-1); + %bq = round(b*sref/m_b)*m_b/sref; + bq = b; + h_sb = freqz(bq, 1, f_sb, fs3); + m_sb = 20*log10(abs(h_sb)); + delta_prev = delta; + delta = cnv.rs+max(m_sb); + fprintf('Step=%3d, Delta=%f dB, N=%d\n', n, delta, nfir); + dn(n) = delta; + fn(n) = nfir; + if delta < 0 + stopband_ok = 1; + else + if delta_prev < delta + n_worse = n_worse+1; + if n_worse > n_worse_max + need_to_stop = 1; % No improvement, reverse + idx = find(dn == min(dn), 1, 'first'); + nfir = fn(idx); + else + nfir = nfir + nfir_increment; + end + else + if need_to_stop == 0 + nfir = nfir + nfir_increment; + else + stopband_ok = 1; % Exit after reverse + fprintf('Warning: Filter stop band could not be '); + fprintf('reached.\n', cnv.coef_bits); + end + end + end + n = n + 1; +end + +f_p = linspace(0, fs3/2, 2000); +m_db = 20*log10(abs(freqz(bq, 1, f_p, fs3))); +i_pb = find(f_p < src.f_pb); +g_pb = max(m_db(i_pb)); +g_att_lin = 10^(-g_pb/20); + +if 1 + p_ymin = floor((-cnv.rs-50)/10)*10; + p_ymax = 10; + figure; + clf; + plot(f_p, m_db); + grid on; + xlabel('Frequency (Hz)'); + ylabel('Magnitude (dB)'); + axis([0 fs3/2 p_ymin p_ymax]); + hold on + plot([src.f_sb src.f_sb],[p_ymin p_ymax], 'r--'); + plot([0 fs3],[-cnv.rs -cnv.rs], 'r--'); + hold off + axes('Position', [ 0.58 0.7 0.3 0.2]); + box on; + plot(f_p(i_pb), m_db(i_pb)); + axis([0 src.f_pb -cnv.rp-0.01 cnv.rp+0.01]); + hold on + plot([0 src.f_pb], +0.5*cnv.rp*ones(1,2), 'r--'); + plot([0 src.f_pb], -0.5*cnv.rp*ones(1,2), 'r--'); + hold off + grid on; + box off; +end + +src.subfilter_length = ceil((nfir+1)/src.num_of_subfilters); +src.filter_length = src.subfilter_length*src.num_of_subfilters; +src.b = zeros(src.filter_length,1); +src.gain = 1; +src.b(1:nfir+1) = b*src.L*g_att_lin; +m = max(abs(src.b)); +gmax = (32767/32768)/m; +maxshift = floor(log(gmax)/log(2)); +src.b = src.b * 2^maxshift; +src.gain = 1/2^maxshift; +src.shift = maxshift; + +%% Reorder coefficients +if 1 + src.coefs = src.b; +else + src.coefs = zeros(src.filter_length,1); + for n = 1:src.num_of_subfilters + i11 = (n-1)*src.subfilter_length+1; + i12 = i11+src.subfilter_length-1; + src.coefs(i11:i12) = src.b(n:src.num_of_subfilters:end); + end +end + +src.halfband = 0; +src.blk_in = M; +src.blk_out = L; +src.MOPS = cnv.fs1/M*src.filter_length/1e6; +src.fir_delay_size = src.subfilter_length + ... + (src.num_of_subfilters-1)*src.idm + src.blk_in; +src.out_delay_size = (src.num_of_subfilters-1)*src.odm + 1; + +end diff --git a/tune/src/src_param.m b/tune/src/src_param.m new file mode 100644 index 000000000000..49e935ce0096 --- /dev/null +++ b/tune/src/src_param.m @@ -0,0 +1,87 @@ +function cnv = src_param(fs1, fs2, coef_bits, q) + +% src_param - get converter parameters +% +% cnv = src_param(fs1, fs2, coef_bits, q) +% +% fs1 - input rate +% fs2 - output rate +% coef_bits - word length identifier +% q - quality scale filter bandwidth and stopband attenuation, +% 1 is default +% + +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +% Note: firpm design with rs 93 dB, or kaiser with 69 dB rs is fair quality. +% Both give about -80 dB THD+N with 24 bit coefficients. With 16 bit +% coefficients THD+N is limited to about -76 dB. + +if nargin < 4 + q = 1.0; +end + +%% Copy input parameters +cnv.fs1 = fs1; +cnv.fs2 = fs2; +cnv.coef_bits = coef_bits; + +%% FIR design +cnv.design = 'kaiser'; % Use firpm or kaiser + +%% Default SRC quality +cnv.c_pb = q * 22/48; % Gives 22 kHz BW @ 48 kHz +cnv.c_sb = 0.5; % Start stopband at Fs/2 +cnv.rs = 70; % Stopband attenuation in dB +cnv.rp = 0.1; % Passband ripple in dB +cnv.rp_tot = 0.1; % Max +/- passband ripple allowed, used in test script only + +%% Constrain sub-filter lengths. Make subfilters lengths multiple of four +% is a good assumption for processors. +cnv.filter_length_mult = 4; + +%% Exceptions for quality +if min(fs1, fs2) > 80e3 + cnv.c_pb = 30e3/min(fs1, fs2); % 30 kHz BW for > 80 kHz +end + +%% Sanity checks +if cnv.c_pb > 0.49 + error('Too wide passband'); +end +if cnv.c_pb < 0.15 + error('Too narrow passband'); +end +if cnv.rs > 160 + error('Too large stopband attenuation'); +end +if cnv.rs < 40 + error('Too low stopband attenuation'); +end diff --git a/tune/src/src_std_int32.m b/tune/src/src_std_int32.m new file mode 100644 index 000000000000..125ae9637449 --- /dev/null +++ b/tune/src/src_std_int32.m @@ -0,0 +1,30 @@ +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +src_generate(); diff --git a/tune/src/src_tiny_int16.m b/tune/src/src_tiny_int16.m new file mode 100644 index 000000000000..be310fbb8e21 --- /dev/null +++ b/tune/src/src_tiny_int16.m @@ -0,0 +1,41 @@ +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +fs1 = [8e3 16e3 24e3 32e3 44.1e3 48e3]; +fs2 = [8e3 16e3 24e3 32e3 44.1e3 48e3]; +fsm = [0 0 0 0 0 1; ... + 0 0 0 0 0 1; ... + 0 0 0 0 0 1; ... + 0 0 0 0 0 1; ... + 0 0 0 0 0 1; ... + 1 1 1 1 1 0; ... + ]; +fmt = 'int16'; profile = 'tiny'; q = 0.75; + +src_generate(fs1, fs2, fmt, fsm, profile, q); From f85f5f8e38bbb99d6887998f445fad7400d2b4ac Mon Sep 17 00:00:00 2001 From: Wu Zhigang Date: Mon, 11 Jun 2018 14:51:15 +0800 Subject: [PATCH 177/324] topology: enable ssp2 for capture feature. the ssp2 should be tdm8-32bit. Signed-off-by: Wu Zhigang --- topology/sof-apl-tdf8532.m4 | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index 5554e58395f6..776f8d58a0e8 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -38,19 +38,19 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, 1, 0, 4, s32le, 48, 1000, 0, 0, 0, 1, SSP, 4, s32le, 2) -# Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s16le. +# Low Latency playback pipeline 2 on PCM 1 using max 8 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, - 2, 1, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 2, s16le, 2) + 2, 1, 8, s32le, + 48, 1000, 0, 0, 0, 1, SSP, 2, s32le, 2) -# Low Latency capture pipeline 3 on PCM 1 using max 2 channels of s16le. +# Low Latency capture pipeline 3 on PCM 1 using max 8 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, - 3, 1, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 2, s16le, 2) + 3, 1, 8, s32le, + 48, 1000, 0, 0, 0, 1, SSP, 2, s32le, 2) # Low Latency playback pipeline 4 on PCM 2 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 @@ -114,17 +114,17 @@ DAI_ADD(sof/pipe-dai-playback.m4, 48, 1000, 0, 0) # playback DAI is SSP2 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, 2, SSP, 2, SSP2-Codec, - PIPELINE_SOURCE_2, 2, s16le, + PIPELINE_SOURCE_2, 2, s32le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, 3, SSP, 2, SSP2-Codec, - PIPELINE_SINK_3, 2, s16le, + PIPELINE_SINK_3, 2, s32le, 48, 1000, 0, 0) # playback DAI is SSP0 using 2 periods @@ -196,11 +196,11 @@ DAI_CONFIG(SSP, 4, 4, SSP4-Codec, SSP_SAMPLE_BITS(SSP, 4, 32))) DAI_CONFIG(SSP, 2, 2, SSP2-Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 1536000, codec_slave), + SSP_CONFIG(DSP_B, DAI_CLOCK(mclk, 24576000, codec_mclk_in), + DAI_CLOCK(bclk, 12288000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 16, 3, 3), - SSP_SAMPLE_BITS(SSP, 2, 16))) + DAI_TDM(2, 32, 255, 255), + SSP_SAMPLE_BITS(SSP, 2, 32))) DAI_CONFIG(SSP, 0, 0, SSP0-Codec, SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), From 2cc3ad2a9287e8354ae9f7dc5161d7f4d4539949 Mon Sep 17 00:00:00 2001 From: Wu Zhigang Date: Mon, 11 Jun 2018 14:51:16 +0800 Subject: [PATCH 178/324] topology: 8-channel should be supported 8 channels should be supported. Signed-off-by: Wu Zhigang Suggested-by: Keyon Jie --- topology/sof/pipe-volume-capture.m4 | 2 +- topology/sof/pipe-volume-playback.m4 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index b3d320667312..6b768e32a15a 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -66,5 +66,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID # PCM Configuration # -PCM_CAPABILITIES(Passthrough Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 4b12d2acdb69..f3203f79ecf8 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -67,5 +67,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # PCM Configuration # -PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536) From bd7dc88231f31d385340310cef467f211a739eeb Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Tue, 12 Jun 2018 13:01:56 -0700 Subject: [PATCH 179/324] topology: remove DMAC ID/DMAC_CHANNEL from PIPELINE/PCM/DAI definitions The firmware no longer uses the DMAC ID and channel info from topology. Signed-off-by: Ranjani Sridharan --- topology/dsps/bdw.m4 | 15 --------- topology/dsps/bxt.m4 | 15 --------- topology/dsps/byt.m4 | 15 --------- topology/dsps/cht.m4 | 15 --------- topology/dsps/cnl.m4 | 15 --------- topology/dsps/hsw.m4 | 15 --------- topology/m4/dai.m4 | 6 ++-- topology/m4/pcm.m4 | 38 +++++------------------ topology/m4/pipeline.m4 | 22 +++++-------- topology/sof-apl-nocodec.m4 | 9 ++---- topology/sof-apl-tdf8532.m4 | 30 ++++++------------ topology/sof-bdw-rt286.m4 | 9 ++---- topology/sof-bdw-rt5640.m4 | 9 ++---- topology/sof-byt-da7213.m4 | 9 ++---- topology/sof-byt-nocodec.m4 | 9 ++---- topology/sof-byt-rt5640.m4 | 9 ++---- topology/sof-byt-rt5645.m4 | 9 ++---- topology/sof-byt-rt5651.m4 | 9 ++---- topology/sof-cht-max98090.m4 | 9 ++---- topology/sof-cht-nocodec.m4 | 9 ++---- topology/sof-cnl-rt274.m4 | 6 ++-- topology/sof-hsw-rt5640.m4 | 9 ++---- topology/sof/pipe-dai-capture.m4 | 2 +- topology/sof/pipe-dai-playback.m4 | 2 +- topology/sof/pipe-low-latency-capture.m4 | 4 +-- topology/sof/pipe-low-latency-playback.m4 | 4 +-- topology/sof/pipe-passthrough-capture.m4 | 4 +-- topology/sof/pipe-passthrough-playback.m4 | 4 +-- topology/sof/pipe-pcm-media.m4 | 4 +-- topology/sof/pipe-src-capture.m4 | 4 +-- topology/sof/pipe-src-playback.m4 | 4 +-- topology/sof/pipe-volume-capture.m4 | 4 +-- topology/sof/pipe-volume-playback.m4 | 4 +-- topology/sof/tokens.m4 | 4 --- topology/test/test-all.m4 | 6 ++-- topology/test/test-capture.m4 | 3 +- topology/test/test-playback.m4 | 3 +- 37 files changed, 86 insertions(+), 261 deletions(-) diff --git a/topology/dsps/bdw.m4 b/topology/dsps/bdw.m4 index c2bf04e2ba55..1af669996969 100644 --- a/topology/dsps/bdw.m4 +++ b/topology/dsps/bdw.m4 @@ -25,21 +25,6 @@ W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) -# DAI0 platform playback configuration -W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) - -W_DATA(dai0p_plat_conf, dai0p_plat_tokens) - -# DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) - -W_DATA(dai0c_plat_conf, dai0c_plat_tokens) - -# PCM platform configuration -W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) - -W_DATA(pcm_plat_conf, pcm_plat_tokens) - # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) diff --git a/topology/dsps/bxt.m4 b/topology/dsps/bxt.m4 index 472fa882fa10..76265130e8cb 100644 --- a/topology/dsps/bxt.m4 +++ b/topology/dsps/bxt.m4 @@ -28,21 +28,6 @@ W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) -# DAI0 platform playback configuration -W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) - -W_DATA(dai0p_plat_conf, dai0p_plat_tokens) - -# DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "0"', `SOF_TKN_DAI_DMAC_CHAN "1"')) - -W_DATA(dai0c_plat_conf, dai0c_plat_tokens) - -# PCM platform configuration -W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) - -W_DATA(pcm_plat_conf, pcm_plat_tokens) - # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) diff --git a/topology/dsps/byt.m4 b/topology/dsps/byt.m4 index d1d4886ab97f..a25d9935f0bc 100644 --- a/topology/dsps/byt.m4 +++ b/topology/dsps/byt.m4 @@ -25,21 +25,6 @@ W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) -# DAI0 platform playback configuration -W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) - -W_DATA(dai0p_plat_conf, dai0p_plat_tokens) - -# DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) - -W_DATA(dai0c_plat_conf, dai0c_plat_tokens) - -# PCM platform configuration -W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) - -W_DATA(pcm_plat_conf, pcm_plat_tokens) - # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) diff --git a/topology/dsps/cht.m4 b/topology/dsps/cht.m4 index 4ed114f71ee6..b6317cdcfed3 100644 --- a/topology/dsps/cht.m4 +++ b/topology/dsps/cht.m4 @@ -25,21 +25,6 @@ W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) -# DAI0 platform playback configuration -W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) - -W_DATA(dai0p_plat_conf, dai0p_plat_tokens) - -# DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) - -W_DATA(dai0c_plat_conf, dai0c_plat_tokens) - -# PCM platform configuration -W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) - -W_DATA(pcm_plat_conf, pcm_plat_tokens) - # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) diff --git a/topology/dsps/cnl.m4 b/topology/dsps/cnl.m4 index 41ece9425f47..96bf6de2462b 100644 --- a/topology/dsps/cnl.m4 +++ b/topology/dsps/cnl.m4 @@ -29,21 +29,6 @@ W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) -# DAI0 platform playback configuration -W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) - -W_DATA(dai0p_plat_conf, dai0p_plat_tokens) - -# DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) - -W_DATA(dai0c_plat_conf, dai0c_plat_tokens) - -# PCM platform configuration -W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) - -W_DATA(pcm_plat_conf, pcm_plat_tokens) - # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) diff --git a/topology/dsps/hsw.m4 b/topology/dsps/hsw.m4 index 754fc413c16c..c096732a7cc5 100644 --- a/topology/dsps/hsw.m4 +++ b/topology/dsps/hsw.m4 @@ -25,21 +25,6 @@ W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) -# DAI0 platform playback configuration -W_VENDORTUPLES(dai0p_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "0"')) - -W_DATA(dai0p_plat_conf, dai0p_plat_tokens) - -# DAI0 platform capture configuration -W_VENDORTUPLES(dai0c_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC "1"', `SOF_TKN_DAI_DMAC_CHAN "1"')) - -W_DATA(dai0c_plat_conf, dai0c_plat_tokens) - -# PCM platform configuration -W_VENDORTUPLES(pcm_plat_tokens, sof_dai_tokens, LIST(` ', `SOF_TKN_DAI_DMAC PIPELINE_DMAC', `SOF_TKN_DAI_DMAC_CHAN PIPELINE_DMAC_CHAN')) - -W_DATA(pcm_plat_conf, pcm_plat_tokens) - # DAI schedule Configuration - scheduled by IRQ W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index a349a3cc1089..bd674138757a 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -7,7 +7,7 @@ define(`N_DAI', DAI_NAME) define(`N_DAI_OUT', DAI_NAME`.OUT') define(`N_DAI_IN', DAI_NAME`.IN') -dnl W_DAI_OUT(type, index, dai_link, format, periods_sink, periods_source, preload, data) +dnl W_DAI_OUT(type, index, dai_link, format, periods_sink, periods_source, preload) define(`W_DAI_OUT', `SectionVendorTuples."'N_DAI_OUT($2)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' @@ -57,11 +57,10 @@ define(`W_DAI_OUT', ` "'N_DAI_OUT($2)`_data_w_comp"' ` "'N_DAI_OUT($2)`_data_str"' ` "'N_DAI_OUT($2)`_data_comp_str"' -` "'$8`"' ` ]' `}') -dnl W_DAI_IN(type, index, dai_link, format, periods_sink, periods_source, preload, data) +dnl W_DAI_IN(type, index, dai_link, format, periods_sink, periods_source, preload) define(`W_DAI_IN', `SectionVendorTuples."'N_DAI_IN($2)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' @@ -111,7 +110,6 @@ define(`W_DAI_IN', ` "'N_DAI_IN($2)`_data_w_comp"' ` "'N_DAI_IN($2)`_data_str"' ` "'N_DAI_IN($2)`_data_comp_str"' -` "'$8`"' ` ]' `}') diff --git a/topology/m4/pcm.m4 b/topology/m4/pcm.m4 index 40a3b17b52c0..51775fb8c884 100644 --- a/topology/m4/pcm.m4 +++ b/topology/m4/pcm.m4 @@ -6,72 +6,50 @@ dnl PCM name) define(`N_PCMP', `PCM'$1`P') define(`N_PCMC', `PCM'$1`C') -dnl W_PCM_PLAYBACK(pcm, stream, dmac, dmac_chan, periods_sink, periods_source, preload) +dnl W_PCM_PLAYBACK(pcm, stream, periods_sink, periods_source, preload) dnl PCM platform configuration define(`W_PCM_PLAYBACK', `SectionVendorTuples."'N_PCMP($1)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) ` }' `}' `SectionData."'N_PCMP($1)`_data_w_comp" {' ` tuples "'N_PCMP($1)`_tuples_w_comp"' `}' -`SectionVendorTuples."'N_PCMP($1)`_tuples" {' -` tokens "sof_pcm_tokens"' -` tuples."word" {' -` SOF_TKN_PCM_DMAC' STR($3) -` SOF_TKN_PCM_DMAC_CHAN' STR($4) -` }' -`}' -`SectionData."'N_PCMP($1)`_data" {' -` tuples "'N_PCMP($1)`_tuples"' -`}' `SectionWidget."'N_PCMP($1)`" {' ` index "'PIPELINE_ID`"' ` type "aif_in"' ` no_pm "true"' ` stream_name "'$2` '$1`"' ` data [' -` "'N_PCMP($1)`_data"' ` "'N_PCMP($1)`_data_w_comp"' ` ]' `}') -dnl W_PCM_CAPTURE(pcm, stream, dmac, dmac_chan, periods_sink, periods_source, preload) +dnl W_PCM_CAPTURE(pcm, stream, periods_sink, periods_source, preload) define(`W_PCM_CAPTURE', `SectionVendorTuples."'N_PCMC($1)`_tuples_w_comp" {' ` tokens "sof_comp_tokens"' ` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($5) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($6) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($7) +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) ` }' `}' `SectionData."'N_PCMC($1)`_data_w_comp" {' ` tuples "'N_PCMC($1)`_tuples_w_comp"' `}' -`SectionVendorTuples."'N_PCMC($1)`_tuples" {' -` tokens "sof_pcm_tokens"' -` tuples."word" {' -` SOF_TKN_PCM_DMAC' STR($3) -` SOF_TKN_PCM_DMAC_CHAN' STR($4) -` }' -`}' -`SectionData."'N_PCMC($1)`_data" {' -` tuples "'N_PCMC($1)`_tuples"' -`}' `SectionWidget."'N_PCMC($1)`" {' ` index "'PIPELINE_ID`"' ` type "aif_out"' ` no_pm "true"' ` stream_name "'$2` '$1`"' ` data [' -` "'N_PCMC($1)`_data"' ` "'N_PCMC($1)`_data_w_comp"' ` ]' `}') diff --git a/topology/m4/pipeline.m4 b/topology/m4/pipeline.m4 index 7a9143901478..0cfe4861c66c 100644 --- a/topology/m4/pipeline.m4 +++ b/topology/m4/pipeline.m4 @@ -33,7 +33,7 @@ define(`W_PIPELINE', dnl PIPELINE_PCM_ADD(pipeline, dnl pipe id, pcm, max channels, format, -dnl frames, deadline, priority, core, dmac, dmac_chan) +dnl frames, deadline, priority, core) define(`PIPELINE_PCM_ADD', `undefine(`PCM_ID')' `undefine(`PIPELINE_ID')' @@ -43,8 +43,6 @@ define(`PIPELINE_PCM_ADD', `undefine(`SCHEDULE_DEADLINE')' `undefine(`SCHEDULE_PRIORITY')' `undefine(`SCHEDULE_CORE')' -`undefine(`PIPELINE_DMAC')' -`undefine(`PIPELINE_DMAC_CHAN')' `define(`PIPELINE_ID', $2)' `define(`PCM_ID', $3)' `define(`PIPELINE_CHANNELS', $4)' @@ -53,14 +51,12 @@ define(`PIPELINE_PCM_ADD', `define(`SCHEDULE_DEADLINE', $7)' `define(`SCHEDULE_PRIORITY', $8)' `define(`SCHEDULE_CORE', $9)' -`define(`PIPELINE_DMAC', $10)' -`define(`PIPELINE_DMAC_CHAN', $11)' `include($1)' ) dnl PIPELINE_PCM_DAI_ADD(pipeline, dnl pipe id, pcm, max channels, format, -dnl frames, deadline, priority, core, dmac, dmac_chan, +dnl frames, deadline, priority, core, dnl dai type, dai_index, dai format, periods) define(`PIPELINE_PCM_DAI_ADD', `undefine(`PCM_ID')' @@ -71,8 +67,6 @@ define(`PIPELINE_PCM_DAI_ADD', `undefine(`SCHEDULE_DEADLINE')' `undefine(`SCHEDULE_PRIORITY')' `undefine(`SCHEDULE_CORE')' -`undefine(`PIPELINE_DMAC')' -`undefine(`PIPELINE_DMAC_CHAN')' `undefine(`DAI_TYPE')' `undefine(`DAI_INDEX')' `undefine(`DAI_FORMAT')' @@ -85,13 +79,11 @@ define(`PIPELINE_PCM_DAI_ADD', `define(`SCHEDULE_DEADLINE', $7)' `define(`SCHEDULE_PRIORITY', $8)' `define(`SCHEDULE_CORE', $9)' -`define(`PIPELINE_DMAC', $10)' -`define(`PIPELINE_DMAC_CHAN', $11)' -`define(`DAI_TYPE', STR($12))' -`define(`DAI_INDEX', STR($13))' -`define(`DAI_FORMAT', $14)' -`define(`DAI_PERIODS', $15)' -`define(`DAI_NAME', $12$13)' +`define(`DAI_TYPE', STR($10))' +`define(`DAI_INDEX', STR($11))' +`define(`DAI_FORMAT', $12)' +`define(`DAI_PERIODS', $13)' +`define(`DAI_NAME', $10$11)' `include($1)' ) diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index ac3ee7517c09..32a3b869c7f0 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -30,24 +30,21 @@ include(`dsps/bxt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) + 48, 1000, 0, 0) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 96, 2000, 1, 0, 0, 3) + 96, 2000, 1, 0) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index 776f8d58a0e8..a0b44e2618af 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -33,73 +33,63 @@ include(`dsps/bxt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 4 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, 1, 0, 4, s32le, - 48, 1000, 0, 0, 0, 1, SSP, 4, s32le, 2) + 48, 1000, 0, 0, SSP, 4, s32le, 2) # Low Latency playback pipeline 2 on PCM 1 using max 8 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, 2, 1, 8, s32le, - 48, 1000, 0, 0, 0, 1, SSP, 2, s32le, 2) + 48, 1000, 0, 0, SSP, 2, s32le, 2) # Low Latency capture pipeline 3 on PCM 1 using max 8 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, 3, 1, 8, s32le, - 48, 1000, 0, 0, 0, 1, SSP, 2, s32le, 2) + 48, 1000, 0, 0, SSP, 2, s32le, 2) # Low Latency playback pipeline 4 on PCM 2 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, 4, 2, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 0, s16le, 2) + 48, 1000, 0, 0, SSP, 0, s16le, 2) # Low Latency capture pipeline 5 on PCM 2 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, 5, 2, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 0, s16le, 2) + 48, 1000, 0, 0, SSP, 0, s16le, 2) # Low Latency capture pipeline 6 on PCM 3 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, 6, 3, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 1, s16le, 2) + 48, 1000, 0, 0, SSP, 1, s16le, 2) # Low Latency playback pipeline 7 on PCM 4 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, 7, 4, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 3, s16le, 2) + 48, 1000, 0, 0, SSP, 3, s16le, 2) # Low Latency capture pipeline 8 on PCM 4 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, 8, 4, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 3, s16le, 2) + 48, 1000, 0, 0, SSP, 3, s16le, 2) # Low Latency playback pipeline 9 on PCM 5 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, 9, 5, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 5, s16le, 2) + 48, 1000, 0, 0, SSP, 5, s16le, 2) # Low Latency capture pipeline 10 on PCM 5 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, 10, 5, 2, s16le, - 48, 1000, 0, 0, 0, 1, SSP, 5, s16le, 2) + 48, 1000, 0, 0, SSP, 5, s16le, 2) # diff --git a/topology/sof-bdw-rt286.m4 b/topology/sof-bdw-rt286.m4 index 6d09e2e23c31..d1ef53562f72 100644 --- a/topology/sof-bdw-rt286.m4 +++ b/topology/sof-bdw-rt286.m4 @@ -30,24 +30,21 @@ include(`dsps/bdw.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 1, 1) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 1, 2) + 48, 1000, 0, 0) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 96, 2000, 1, 0, 1, 3) + 96, 2000, 1, 0) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof-bdw-rt5640.m4 b/topology/sof-bdw-rt5640.m4 index 2f9badbde540..258ecc4de8d1 100644 --- a/topology/sof-bdw-rt5640.m4 +++ b/topology/sof-bdw-rt5640.m4 @@ -30,24 +30,21 @@ include(`dsps/bdw.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 1, 1) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 1, 2) + 48, 1000, 0, 0) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 96 frames per 2000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 96, 2000, 1, 0, 1, 3) + 96, 2000, 1, 0) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof-byt-da7213.m4 b/topology/sof-byt-da7213.m4 index 090b034948ab..a89e51b0c7f3 100644 --- a/topology/sof-byt-da7213.m4 +++ b/topology/sof-byt-da7213.m4 @@ -30,24 +30,21 @@ include(`dsps/byt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) + 48, 1000, 0, 0) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 192, 4000, 1, 0, 0, 3) + 192, 4000, 1, 0) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 index 9bed36ec0a50..b305d27394e4 100644 --- a/topology/sof-byt-nocodec.m4 +++ b/topology/sof-byt-nocodec.m4 @@ -30,24 +30,21 @@ include(`dsps/byt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) + 48, 1000, 0, 0) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 192, 4000, 1, 0, 0, 3) + 192, 4000, 1, 0) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof-byt-rt5640.m4 b/topology/sof-byt-rt5640.m4 index f852616de766..aafa10fa4359 100644 --- a/topology/sof-byt-rt5640.m4 +++ b/topology/sof-byt-rt5640.m4 @@ -30,24 +30,21 @@ include(`dsps/byt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) + 48, 1000, 0, 0) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 192, 4000, 1, 0, 0, 3) + 192, 4000, 1, 0) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof-byt-rt5645.m4 b/topology/sof-byt-rt5645.m4 index 7d8eee584ee0..415bc0aea148 100644 --- a/topology/sof-byt-rt5645.m4 +++ b/topology/sof-byt-rt5645.m4 @@ -30,24 +30,21 @@ include(`dsps/byt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) + 48, 1000, 0, 0) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 192, 4000, 1, 0, 0, 3) + 192, 4000, 1, 0) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof-byt-rt5651.m4 b/topology/sof-byt-rt5651.m4 index 894602aee571..14e45c08926d 100644 --- a/topology/sof-byt-rt5651.m4 +++ b/topology/sof-byt-rt5651.m4 @@ -30,24 +30,21 @@ include(`dsps/byt.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) + 48, 1000, 0, 0) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 192, 4000, 1, 0, 0, 3) + 192, 4000, 1, 0) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof-cht-max98090.m4 b/topology/sof-cht-max98090.m4 index 2d5192a0712f..e02056c9c0c0 100644 --- a/topology/sof-cht-max98090.m4 +++ b/topology/sof-cht-max98090.m4 @@ -30,24 +30,21 @@ include(`dsps/cht.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) + 48, 1000, 0, 0) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 192, 4000, 1, 0, 0, 3) + 192, 4000, 1, 0) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof-cht-nocodec.m4 b/topology/sof-cht-nocodec.m4 index 68abf37ddeca..f56a7a5179c8 100644 --- a/topology/sof-cht-nocodec.m4 +++ b/topology/sof-cht-nocodec.m4 @@ -30,24 +30,21 @@ include(`dsps/cht.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 0, 1) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 0, 2) + 48, 1000, 0, 0) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 192, 4000, 1, 0, 0, 3) + 192, 4000, 1, 0) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index 25a4913383a3..a805f9e9f581 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -26,17 +26,15 @@ include(`dsps/cnl.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, 1, 0, 2, s24le, - 48, 1000, 0, 0, 0, 1, SSP, 0, s24le, 2) + 48, 1000, 0, 0, SSP, 0, s24le, 2) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s24le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, 2, 0, 2, s24le, - 48, 1000, 0, 0, 0, 1, SSP, 0, s24le, 2) + 48, 1000, 0, 0, SSP, 0, s24le, 2) # # DAI configuration diff --git a/topology/sof-hsw-rt5640.m4 b/topology/sof-hsw-rt5640.m4 index 22d79d5bcb1a..c99f39bd6f6b 100644 --- a/topology/sof-hsw-rt5640.m4 +++ b/topology/sof-hsw-rt5640.m4 @@ -30,24 +30,21 @@ include(`dsps/hsw.m4') # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, 1, 0, 2, s32le, - 48, 1000, 0, 0, 1, 1) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 2 for PCM audio capture data PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, 2, 0, 2, s32le, - 48, 1000, 0, 0, 1, 2) + 48, 1000, 0, 0) # PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 1 -# Use DMAC 0 channel 3 for PCM audio playback data PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, 3, 1, 2, s32le, - 192, 4000, 1, 0, 1, 3) + 192, 4000, 1, 0) # Tone Playback pipeline 5 using max 2 channels of s32le. # Schedule 192 frames per 4000us deadline on core 0 with priority 2 diff --git a/topology/sof/pipe-dai-capture.m4 b/topology/sof/pipe-dai-capture.m4 index 3f16f879552c..c69d586ff19d 100644 --- a/topology/sof/pipe-dai-capture.m4 +++ b/topology/sof/pipe-dai-capture.m4 @@ -8,7 +8,7 @@ include(`pipeline.m4') # # DAI definitions # -W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 2, 0, 0, dai0c_plat_conf) +W_DAI_IN(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 2, 0, 0) # # DAI pipeline - always use 0 for DAIs diff --git a/topology/sof/pipe-dai-playback.m4 b/topology/sof/pipe-dai-playback.m4 index 2397875d4576..804b180eb2ae 100644 --- a/topology/sof/pipe-dai-playback.m4 +++ b/topology/sof/pipe-dai-playback.m4 @@ -8,7 +8,7 @@ include(`pipeline.m4') # # DAI definitions # -W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, 2, 2, dai0p_plat_conf) +W_DAI_OUT(DAI_TYPE, DAI_INDEX, DAI_BE, DAI_FORMAT, 0, 2, 2) # # DAI pipeline - always use 0 for DAIs diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 39be2bc14fb4..39c2ccefa6d6 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -27,9 +27,9 @@ C_CONTROLMIXER(PCM PCM_ID Capture Volume, PIPELINE_ID, # Components and Buffers # -# Host "Low Latency Capture" PCM uses pipeline DMAC and channel +# Host "Low Latency Capture" PCM # with 0 sink and 2 source periods -W_PCM_CAPTURE(PCM_ID, Low Latency Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 0) +W_PCM_CAPTURE(PCM_ID, Low Latency Capture, 0, 2, 0) # "Capture Volume" has 2 sink and source periods for host and DAI ping-pong W_PGA(0, PIPELINE_FORMAT, 2, 2, 0, LIST(` ', "PCM PCM_ID Capture Volume PIPELINE_ID")) diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index b40b793ecc77..8cfe5e418769 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -52,9 +52,9 @@ C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, # Components and Buffers # -# Host "Low latency Playback" PCM uses pipeline DMAC and channel +# Host "Low latency Playback" PCM # with 2 sink and 0 source periods -W_PCM_PLAYBACK(PCM_ID, Low Latency Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) +W_PCM_PLAYBACK(PCM_ID, Low Latency Playback, 2, 0, 2) # "Playback Volume" has 1 sink period and 2 source periods for host ping-pong W_PGA(0, PIPELINE_FORMAT, 1, 2, 1, LIST(` ', "PCM PCM_ID Playback Volume PIPELINE_ID")) diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index c6850f96bc2b..1dc695c3dcba 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -15,9 +15,9 @@ include(`pipeline.m4') # Components and Buffers # -# Host "Passthrough Capture" PCM uses pipeline DMAC and channel +# Host "Passthrough Capture" PCM # with 0 sink and 2 source periods -W_PCM_CAPTURE(PCM_ID, Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) +W_PCM_CAPTURE(PCM_ID, Passthrough Capture, 0, 2, 2) # Capture Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index e2cd645fbdc9..c7c12371c274 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -15,9 +15,9 @@ include(`pipeline.m4') # Components and Buffers # -# Host "Passthrough Playback" PCM uses pipeline DMAC and channel +# Host "Passthrough Playback" PCM # with 2 sink and 0 source periods -W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) +W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 2, 0, 2) # Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index 7f68977d8aa8..b526e435a91e 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -40,9 +40,9 @@ W_DATA(media_src_conf, media_src_tokens) # Components and Buffers # -# Host "Low latency Playback" PCM uses pipeline DMAC and channel +# Host "Low latency Playback" PCM # with 2 sink and 0 source periods -W_PCM_PLAYBACK(PCM_ID, Media Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) +W_PCM_PLAYBACK(PCM_ID, Media Playback, 2, 0, 2) # "Playback Volume" has 2 sink period and 2 source periods for host ping-pong W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "PCM PCM_ID Playback Volume PIPELINE_ID")) diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index 6211d33e62bf..e0a68e4613b5 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -16,9 +16,9 @@ include(`pipeline.m4') # Components and Buffers # -# Host "Passthrough Capture" PCM uses pipeline DMAC and channel +# Host "Passthrough Capture" PCM # with 4 sink and 0 source periods -W_PCM_CAPTURE(PCM_ID, Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) +W_PCM_CAPTURE(PCM_ID, Passthrough Capture, 4, 0, 2) # # SRC Configuration diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index 119ee2cbd0e8..16991985564b 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -16,9 +16,9 @@ include(`pipeline.m4') # Components and Buffers # -# Host "Passthrough Playback" PCM uses pipeline DMAC and channel +# Host "Passthrough Playback" PCM # with 4 sink and 0 source periods -W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 4, 0, 2) +W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 4, 0, 2) # # SRC Configuration diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 6b768e32a15a..820b745c7fc5 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -29,9 +29,9 @@ C_CONTROLMIXER(Master Capture Volume, PIPELINE_ID, # Components and Buffers # -# Host "Passthrough Capture" PCM uses pipeline DMAC and channel +# Host "Passthrough Capture" PCM # with 0 sink and 2 source periods -W_PCM_CAPTURE(PCM_ID, Passthrough Capture, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 0, 2, 2) +W_PCM_CAPTURE(PCM_ID, Passthrough Capture, 0, 2, 2) # "Volume" has 2 source and 2 sink periods W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Capture Volume PIPELINE_ID")) diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index f3203f79ecf8..4ebd02da5721 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -29,9 +29,9 @@ C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, # Components and Buffers # -# Host "Passthrough Playback" PCM uses pipeline DMAC and channel +# Host "Passthrough Playback" PCM # with 2 sink and 0 source periods -W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, PIPELINE_DMAC, PIPELINE_DMAC_CHAN, 2, 0, 2) +W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 2, 0, 2) # "Volume" has 2 source and 2 sink periods W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume PIPELINE_ID")) diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index d1230d8ebdde..f0b34284cbc9 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -15,8 +15,6 @@ SectionVendorTokens."sof_buffer_tokens" { } SectionVendorTokens."sof_dai_tokens" { - SOF_TKN_DAI_DMAC "151" - SOF_TKN_DAI_DMAC_CHAN "152" SOF_TKN_DAI_DMAC_CONFIG "153" SOF_TKN_DAI_TYPE "154" SOF_TKN_DAI_INDEX "155" @@ -43,8 +41,6 @@ SectionVendorTokens."sof_src_tokens" { } SectionVendorTokens."sof_pcm_tokens" { - SOF_TKN_PCM_DMAC "351" - SOF_TKN_PCM_DMAC_CHAN "352" SOF_TKN_PCM_DMAC_CONFIG "353" } diff --git a/topology/test/test-all.m4 b/topology/test/test-all.m4 index 383a3972d53b..2a4dae429cda 100644 --- a/topology/test/test-all.m4 +++ b/topology/test/test-all.m4 @@ -39,21 +39,19 @@ include(`dsps/byt.m4') # Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-playback.m4, 1, 0, 2, TEST_PIPE_FORMAT, - 48, 1000, 0, 0, 0, 1, + 48, 1000, 0, 0, TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_FORMAT, 2) # Passthrough playback pipeline 2 on PCM 0 using max 2 channels of s24le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-capture.m4, 2, 0, 2, TEST_PIPE_FORMAT, - 48, 1000, 0, 0, 0, 1, + 48, 1000, 0, 0, TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_FORMAT, 2) # diff --git a/topology/test/test-capture.m4 b/topology/test/test-capture.m4 index bed59c4670e0..7e5ca86c2962 100644 --- a/topology/test/test-capture.m4 +++ b/topology/test/test-capture.m4 @@ -39,11 +39,10 @@ include(`dsps/byt.m4') # Passthrough playback pipeline 2 on PCM 0 using max 2 channels of s24le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-capture.m4, 2, 0, 2, TEST_PIPE_FORMAT, - 48, 1000, 0, 0, 0, 1, + 48, 1000, 0, 0, TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_FORMAT, 2) # diff --git a/topology/test/test-playback.m4 b/topology/test/test-playback.m4 index b0f3fecfdcf3..ade8a8e45d64 100644 --- a/topology/test/test-playback.m4 +++ b/topology/test/test-playback.m4 @@ -39,11 +39,10 @@ include(`dsps/byt.m4') # Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -# Use DMAC 0 channel 1 for PCM audio playback data PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-playback.m4, 1, 0, 2, TEST_PIPE_FORMAT, - 48, 1000, 0, 0, 0, 1, + 48, 1000, 0, 0, TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_FORMAT, 2) # # DAI configuration From 41ef0529fc5bfa677975d1e247275de2ba147d42 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Tue, 12 Jun 2018 11:32:59 -0700 Subject: [PATCH 180/324] topology: use switch IO handler for tone switch Use the bespoke switch IO handler in the driver for the tone switch kcontrol. Signed-off-by: Ranjani Sridharan --- topology/sof/pipe-tone.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof/pipe-tone.m4 b/topology/sof/pipe-tone.m4 index 53cef5a34964..fc5eb0099144 100644 --- a/topology/sof/pipe-tone.m4 +++ b/topology/sof/pipe-tone.m4 @@ -30,7 +30,7 @@ C_CONTROLMIXER(Tone Volume, PIPELINE_ID, # Switch type Mixer Control with max value of 1 C_CONTROLMIXER(Tone Switch, PIPELINE_ID, - CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_OPS(volsw, 259 binds the mixer control to switch get/put handlers, 259, 259), CONTROLMIXER_MAX(max 1 indicates switch type control, 1), false, , From 09148482f90c3c08cec6a6d15883539a7ae20a99 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Tue, 12 Jun 2018 11:33:51 -0700 Subject: [PATCH 181/324] topology: add test tone pipelines for APL Signed-off-by: Ranjani Sridharan --- topology/test/tplg-build.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index ad4d1da10c2d..9d3649edf7a9 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -204,6 +204,9 @@ simple_test nocodec src "NoCodec" s24le SSP 4 s24le 25 24 2400000 24000000 I2S S # Tone test: Tone component only supports s32le currently simple_test codec tone "SSP2-Codec" s32le SSP 2 s16le 20 16 1920000 19200000 I2S TONE_TEST[@] +#Tone Test for APL +simple_test codec tone "SSP5-Codec" s32le SSP 5 s24le 32 24 3072000 24576000 I2S TONE_TEST[@] +simple_test codec tone "SSP5-Codec" s32le SSP 5 s32le 32 32 3072000 24576000 I2S TONE_TEST[@] #DMIC Test simple_test nocodec passthrough "DMIC0" s32le DMIC 0 s32le 1 500000 4800000\ From c0172307ff924fd8a3d1a72370b5d5cff626035f Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 20 Jun 2018 21:21:09 -0700 Subject: [PATCH 182/324] topology: add new token for SSP MCLK ID Some platforms might have more than one MCLK's exposed. Add a token that will allow specifying the MCLK ID to be used in such cases. Signed-off-by: Ranjani Sridharan --- topology/sof/tokens.m4 | 1 + 1 file changed, 1 insertion(+) diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index f0b34284cbc9..7033b7440ce4 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -55,6 +55,7 @@ SectionVendorTokens."sof_ssp_tokens" { SOF_TKN_INTEL_SSP_MCLK_KEEP_ACTIVE "500" SOF_TKN_INTEL_SSP_BCLK_KEEP_ACTIVE "501" SOF_TKN_INTEL_SSP_FS_KEEP_ACTIVE "502" + SOF_TKN_INTEL_SSP_MCLK_ID "503" } SectionVendorTokens."sof_dmic_tokens" { From e6140f82003e33b9a94409b6e984da37b3651a77 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 13 Jun 2018 20:35:20 -0700 Subject: [PATCH 183/324] topology: add SAMPLE_RATE token for tone comp and define it in tone definition Add SAMPLE_RATE token for tone comp. Include it in tone definition and set it from the test pipeline definition. Signed-off-by: Ranjani Sridharan --- topology/m4/tone.m4 | 7 +++++++ topology/sof/tokens.m4 | 4 ++++ topology/test/test-tone-playback.m4 | 3 +++ 3 files changed, 14 insertions(+) diff --git a/topology/m4/tone.m4 b/topology/m4/tone.m4 index 6a88b37cdc37..583134c6f920 100644 --- a/topology/m4/tone.m4 +++ b/topology/m4/tone.m4 @@ -15,8 +15,15 @@ define(`W_TONE', ` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) ` }' `}' +`SectionVendorTuples."'N_TONE($1)`_tone_tuples_w" {' +` tokens "sof_tone_tokens"' +` tuples."word" {' +` SOF_TKN_TONE_SAMPLE_RATE' ifdef(TONE_SAMPLE_RATE, STR(TONE_SAMPLE_RATE), "48000") +` }' +`}' `SectionData."'N_TONE($1)`_data_w" {' ` tuples "'N_TONE($1)`_tuples_w"' +` tuples "'N_TONE($1)`_tone_tuples_w"' `}' `SectionVendorTuples."'N_TONE($1)`_tuples_str" {' ` tokens "sof_comp_tokens"' diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index f0b34284cbc9..62c478bec312 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -77,3 +77,7 @@ SectionVendorTokens."sof_dmic_pdm_tokens" { SOF_TKN_INTEL_DMIC_PDM_CLK_EDGE "705" SOF_TKN_INTEL_DMIC_PDM_SKEW "706" } + +SectionVendorTokens."sof_tone_tokens" { + SOF_TKN_TONE_SAMPLE_RATE "800" +} diff --git a/topology/test/test-tone-playback.m4 b/topology/test/test-tone-playback.m4 index 1c38c092abc2..6c227a3f7bf9 100644 --- a/topology/test/test-tone-playback.m4 +++ b/topology/test/test-tone-playback.m4 @@ -36,6 +36,9 @@ include(`dsps/byt.m4') # Tone --B0--> volume --B1--> SSP2 # +# Set sample rate for tone +define(`TONE_SAMPLE_RATE', 48000) + # Tone Playback pipeline 5 using max 2 channels of TEST_PIPE_FORMAT. # Schedule with 48 frame per 1000us deadline on core 0 with priority 0 PIPELINE_ADD(sof/pipe-tone.m4, From 0beda35193980400297dbfb4e8c32b42e2d1ce82 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Mon, 25 Jun 2018 12:59:07 +0800 Subject: [PATCH 184/324] rmbox: add missing trace class to sync with firmware Add missing trace class to the rmbox to avoid unknow value message. Signed-off-by: Pan Xiuli --- rmbox/rmbox.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 4df2ee1c5576..913249b6e58f 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -46,6 +46,10 @@ #define TRACE_CLASS_TONE (18 << 24) #define TRACE_CLASS_EQ_FIR (19 << 24) #define TRACE_CLASS_EQ_IIR (20 << 24) +#define TRACE_CLASS_SA (21 << 24) +#define TRACE_CLASS_DMIC (22 << 24) +#define TRACE_CLASS_POWER (23 << 24) + #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) @@ -162,6 +166,12 @@ static void show_trace(uint64_t val, uint64_t addr, uint64_t *timestamp, double trace = "eq-fir"; else if (class == TRACE_CLASS_EQ_IIR) trace = "eq-iir"; + else if (class == TRACE_CLASS_SA) + trace = "sa"; + else if (class == TRACE_CLASS_DMIC) + trace = "dmic"; + else if (class == TRACE_CLASS_POWER) + trace = "pm"; else { printf("value 0x%8.8x\n", (uint32_t)val); return; From 6d9ad7a5053394dd19cd84e266e6774857296649 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Sun, 24 Jun 2018 21:41:22 -0700 Subject: [PATCH 185/324] tokens: move SAMPLE_BITS to ssp tokens SAMPLE_BITS is SSP specific. So move it to be part of the ssp tokens. Signed-off-by: Ranjani Sridharan --- topology/sof/tokens.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index 7033b7440ce4..dfc6f3348fca 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -18,7 +18,6 @@ SectionVendorTokens."sof_dai_tokens" { SOF_TKN_DAI_DMAC_CONFIG "153" SOF_TKN_DAI_TYPE "154" SOF_TKN_DAI_INDEX "155" - SOF_TKN_DAI_SAMPLE_BITS "156" } SectionVendorTokens."sof_sched_tokens" { @@ -56,6 +55,7 @@ SectionVendorTokens."sof_ssp_tokens" { SOF_TKN_INTEL_SSP_BCLK_KEEP_ACTIVE "501" SOF_TKN_INTEL_SSP_FS_KEEP_ACTIVE "502" SOF_TKN_INTEL_SSP_MCLK_ID "503" + SOF_TKN_INTEL_SSP_SAMPLE_BITS "504" } SectionVendorTokens."sof_dmic_tokens" { From 1adb92ab2e39969d6e8e7f43e7d4e71e37ffcfb1 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Sun, 24 Jun 2018 22:03:16 -0700 Subject: [PATCH 186/324] topology: dai: rename sample_bits macro to config_data Rename SAMPLE_BITS macro to a more generic CONFIG_DATA macro for SSP to also include the mclk id. Also modify users of the macro with the new name. Signed-off-by: Ranjani Sridharan --- topology/m4/dai.m4 | 14 +++++++++----- topology/sof-apl-nocodec.m4 | 2 +- topology/sof-apl-tdf8532.m4 | 12 ++++++------ topology/sof-bdw-rt286.m4 | 2 +- topology/sof-bdw-rt5640.m4 | 2 +- topology/sof-byt-da7213.m4 | 2 +- topology/sof-byt-nocodec.m4 | 2 +- topology/sof-byt-rt5640.m4 | 2 +- topology/sof-byt-rt5645.m4 | 2 +- topology/sof-byt-rt5651.m4 | 2 +- topology/sof-cht-max98090.m4 | 2 +- topology/sof-cht-nocodec.m4 | 2 +- topology/sof-cnl-rt274.m4 | 2 +- topology/sof-hsw-rt5640.m4 | 2 +- topology/test/test-all.m4 | 2 +- topology/test/test-capture.m4 | 2 +- topology/test/test-playback.m4 | 2 +- topology/test/test-tone-playback.m4 | 2 +- 18 files changed, 31 insertions(+), 27 deletions(-) diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index bd674138757a..882d958e8842 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -134,7 +134,7 @@ define(`DAI_TDM', ` tx_slots 'STR($3) ` rx_slots 'STR($4) ) -dnl SSP_CONFIG(format, mclk, bclk, fsync, tdm, ssp sample bits) +dnl SSP_CONFIG(format, mclk, bclk, fsync, tdm, ssp_config_data) define(`SSP_CONFIG', ` format "'$1`"' ` '$2 @@ -145,12 +145,16 @@ define(`SSP_CONFIG', $6 ) -dnl SSP_SAMPLE_BITS(type, idx, valid bits) -define(`SSP_SAMPLE_BITS', +dnl SSP_CONFIG_DATA(type, idx, valid bits, mclk_id) +dnl mclk_id is optional +define(`SSP_CONFIG_DATA', `SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {' -` tokens "sof_dai_tokens"' +` tokens "sof_ssp_tokens"' ` tuples."word" {' -` SOF_TKN_DAI_SAMPLE_BITS' STR($3) +` SOF_TKN_INTEL_SSP_SAMPLE_BITS' STR($3) +` }' +` tuples."short" {' +` SOF_TKN_INTEL_SSP_MCLK_ID' ifelse($4, `', "0", STR($4)) ` }' `}' `SectionData."'N_DAI_CONFIG($1$2)`_data" {' diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 32a3b869c7f0..0698b42939a6 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -95,4 +95,4 @@ DAI_CONFIG(SSP, 2, 0, NoCodec, DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3), - SSP_SAMPLE_BITS(SSP, 2, 24))) + SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index a0b44e2618af..b913d42b5a21 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -183,42 +183,42 @@ DAI_CONFIG(SSP, 4, 4, SSP4-Codec, DAI_CLOCK(bclk, 12288000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(8, 32, 15, 15), - SSP_SAMPLE_BITS(SSP, 4, 32))) + SSP_CONFIG_DATA(SSP, 4, 32))) DAI_CONFIG(SSP, 2, 2, SSP2-Codec, SSP_CONFIG(DSP_B, DAI_CLOCK(mclk, 24576000, codec_mclk_in), DAI_CLOCK(bclk, 12288000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 32, 255, 255), - SSP_SAMPLE_BITS(SSP, 2, 32))) + SSP_CONFIG_DATA(SSP, 2, 32))) DAI_CONFIG(SSP, 0, 0, SSP0-Codec, SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), DAI_CLOCK(bclk, 1536000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 16, 3, 3), - SSP_SAMPLE_BITS(SSP, 0, 16))) + SSP_CONFIG_DATA(SSP, 0, 16))) DAI_CONFIG(SSP, 1, 1, SSP1-Codec, SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), DAI_CLOCK(bclk, 1536000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 16, 3, 3), - SSP_SAMPLE_BITS(SSP, 1, 16))) + SSP_CONFIG_DATA(SSP, 1, 16))) DAI_CONFIG(SSP, 3, 3, SSP3-Codec, SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), DAI_CLOCK(bclk, 1536000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 16, 3, 3), - SSP_SAMPLE_BITS(SSP, 3, 16))) + SSP_CONFIG_DATA(SSP, 3, 16))) DAI_CONFIG(SSP, 5, 5, SSP5-Codec, SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), DAI_CLOCK(bclk, 1536000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 16, 3, 3), - SSP_SAMPLE_BITS(SSP, 5, 16))) + SSP_CONFIG_DATA(SSP, 5, 16))) VIRTUAL_DAPM_ROUTE_IN(BtHfp_ssp0_in, SSP, 0, IN, 0) diff --git a/topology/sof-bdw-rt286.m4 b/topology/sof-bdw-rt286.m4 index d1ef53562f72..e1f5bfbfdd3b 100644 --- a/topology/sof-bdw-rt286.m4 +++ b/topology/sof-bdw-rt286.m4 @@ -95,4 +95,4 @@ DAI_CONFIG(SSP, 0, 0, Codec, DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3), - SSP_SAMPLE_BITS(SSP, 0, 24))) + SSP_CONFIG_DATA(SSP, 0, 24))) diff --git a/topology/sof-bdw-rt5640.m4 b/topology/sof-bdw-rt5640.m4 index 258ecc4de8d1..cd955505bde5 100644 --- a/topology/sof-bdw-rt5640.m4 +++ b/topology/sof-bdw-rt5640.m4 @@ -95,4 +95,4 @@ DAI_CONFIG(SSP, 0, 0, Codec, DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3), - SSP_SAMPLE_BITS(SSP, 0, 24))) + SSP_CONFIG_DATA(SSP, 0, 24))) diff --git a/topology/sof-byt-da7213.m4 b/topology/sof-byt-da7213.m4 index a89e51b0c7f3..a8c5c01960bb 100644 --- a/topology/sof-byt-da7213.m4 +++ b/topology/sof-byt-da7213.m4 @@ -95,4 +95,4 @@ DAI_CONFIG(SSP, 2, 0, SSP2-Codec, DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3), - SSP_SAMPLE_BITS(SSP, 2, 24))) + SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 index b305d27394e4..ac4af7906430 100644 --- a/topology/sof-byt-nocodec.m4 +++ b/topology/sof-byt-nocodec.m4 @@ -95,4 +95,4 @@ DAI_CONFIG(SSP, 2, 0, NoCodec, DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3), - SSP_SAMPLE_BITS(SSP, 2, 24))) + SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-byt-rt5640.m4 b/topology/sof-byt-rt5640.m4 index aafa10fa4359..19eca6d169ee 100644 --- a/topology/sof-byt-rt5640.m4 +++ b/topology/sof-byt-rt5640.m4 @@ -95,4 +95,4 @@ DAI_CONFIG(SSP, 2, 0, SSP2-Codec, DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3), - SSP_SAMPLE_BITS(SSP, 2, 24))) + SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-byt-rt5645.m4 b/topology/sof-byt-rt5645.m4 index 415bc0aea148..2c0eac500a07 100644 --- a/topology/sof-byt-rt5645.m4 +++ b/topology/sof-byt-rt5645.m4 @@ -95,4 +95,4 @@ DAI_CONFIG(SSP, 2, 0, SSP2-Codec, DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3), - SSP_SAMPLE_BITS(SSP, 2, 24))) + SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-byt-rt5651.m4 b/topology/sof-byt-rt5651.m4 index 14e45c08926d..4397b3bd8e03 100644 --- a/topology/sof-byt-rt5651.m4 +++ b/topology/sof-byt-rt5651.m4 @@ -95,4 +95,4 @@ DAI_CONFIG(SSP, 2, 0, SSP2-Codec, DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3), - SSP_SAMPLE_BITS(SSP, 2, 24))) + SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-cht-max98090.m4 b/topology/sof-cht-max98090.m4 index e02056c9c0c0..5a3a89564c50 100644 --- a/topology/sof-cht-max98090.m4 +++ b/topology/sof-cht-max98090.m4 @@ -95,4 +95,4 @@ DAI_CONFIG(SSP, 2, 0, SSP2-Codec, DAI_CLOCK(bclk, 1920000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 20, 3, 3), - SSP_SAMPLE_BITS(SSP, 2, 16))) + SSP_CONFIG_DATA(SSP, 2, 16))) diff --git a/topology/sof-cht-nocodec.m4 b/topology/sof-cht-nocodec.m4 index f56a7a5179c8..cfb2453f4996 100644 --- a/topology/sof-cht-nocodec.m4 +++ b/topology/sof-cht-nocodec.m4 @@ -95,4 +95,4 @@ DAI_CONFIG(SSP, 2, 0, NoCodec, DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3), - SSP_SAMPLE_BITS(SSP, 2, 24))) + SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index a805f9e9f581..66bd3a07b878 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -67,7 +67,7 @@ DAI_CONFIG(SSP, 0, 0, SSP0-Codec, DAI_CLOCK(bclk, 4800000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(4, 25, 3, 3), - SSP_SAMPLE_BITS(SSP, 0, 24))) + SSP_CONFIG_DATA(SSP, 0, 24))) VIRTUAL_DAPM_ROUTE_OUT(codec0_out, SSP, 0, OUT, 0) VIRTUAL_DAPM_ROUTE_OUT(codec1_out, SSP, 0, OUT, 1) diff --git a/topology/sof-hsw-rt5640.m4 b/topology/sof-hsw-rt5640.m4 index c99f39bd6f6b..f839fc382156 100644 --- a/topology/sof-hsw-rt5640.m4 +++ b/topology/sof-hsw-rt5640.m4 @@ -95,4 +95,4 @@ DAI_CONFIG(SSP, 0, 0, Codec, DAI_CLOCK(bclk, 2400000, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, 25, 3, 3), - SSP_SAMPLE_BITS(SSP, 0, 24))) + SSP_CONFIG_DATA(SSP, 0, 24))) diff --git a/topology/test/test-all.m4 b/topology/test/test-all.m4 index 2a4dae429cda..00318b0155f4 100644 --- a/topology/test/test-all.m4 +++ b/topology/test/test-all.m4 @@ -90,5 +90,5 @@ DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), - SSP_SAMPLE_BITS(TEST_DAI_TYPE, TEST_DAI_PORT, + SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_SSP_DATA_BITS))) diff --git a/topology/test/test-capture.m4 b/topology/test/test-capture.m4 index 7e5ca86c2962..9d85009a41a0 100644 --- a/topology/test/test-capture.m4 +++ b/topology/test/test-capture.m4 @@ -74,7 +74,7 @@ DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), - SSP_SAMPLE_BITS(TEST_DAI_TYPE, TEST_DAI_PORT, + SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_SSP_DATA_BITS)), TEST_DAI_TYPE, `DMIC', DMIC_CONFIG(TEST_DMIC_DRIVER_VERSION,TEST_DMIC_CLK_MIN, diff --git a/topology/test/test-playback.m4 b/topology/test/test-playback.m4 index ade8a8e45d64..d607d3a455b9 100644 --- a/topology/test/test-playback.m4 +++ b/topology/test/test-playback.m4 @@ -73,5 +73,5 @@ DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), - SSP_SAMPLE_BITS(TEST_DAI_TYPE, TEST_DAI_PORT, + SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_SSP_DATA_BITS))) diff --git a/topology/test/test-tone-playback.m4 b/topology/test/test-tone-playback.m4 index 1c38c092abc2..52484276624e 100644 --- a/topology/test/test-tone-playback.m4 +++ b/topology/test/test-tone-playback.m4 @@ -62,5 +62,5 @@ DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), DAI_CLOCK(fsync, 48000, codec_slave), DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), - SSP_SAMPLE_BITS(TEST_DAI_TYPE, TEST_DAI_PORT, + SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_SSP_DATA_BITS))) From a835ff2ae962a483af8f63f02142938c0278d909 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Sun, 24 Jun 2018 23:42:07 -0700 Subject: [PATCH 187/324] topology: move platform m4 files from dsps directory to platform/intel Signed-off-by: Ranjani Sridharan --- configure.ac | 3 ++- topology/Makefile.am | 4 ++-- topology/platform/Makefile.am | 1 + topology/{dsps => platform/intel}/Makefile.am | 0 topology/{dsps => platform/intel}/bdw.m4 | 0 topology/{dsps => platform/intel}/bxt.m4 | 0 topology/{dsps => platform/intel}/byt.m4 | 0 topology/{dsps => platform/intel}/cht.m4 | 0 topology/{dsps => platform/intel}/cnl.m4 | 0 topology/{dsps => platform/intel}/hsw.m4 | 0 topology/sof-apl-nocodec.m4 | 2 +- topology/sof-apl-tdf8532.m4 | 2 +- topology/sof-bdw-rt286.m4 | 2 +- topology/sof-bdw-rt5640.m4 | 2 +- topology/sof-byt-da7213.m4 | 2 +- topology/sof-byt-nocodec.m4 | 2 +- topology/sof-byt-rt5640.m4 | 2 +- topology/sof-byt-rt5645.m4 | 2 +- topology/sof-byt-rt5651.m4 | 2 +- topology/sof-cht-max98090.m4 | 2 +- topology/sof-cht-nocodec.m4 | 2 +- topology/sof-cnl-rt274.m4 | 2 +- topology/sof-hsw-rt5640.m4 | 2 +- topology/test/Makefile.am | 2 +- topology/test/test-all.m4 | 2 +- topology/test/test-capture.m4 | 2 +- topology/test/test-playback.m4 | 2 +- topology/test/test-tone-playback.m4 | 2 +- topology/test/tplg-build.sh | 2 +- 29 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 topology/platform/Makefile.am rename topology/{dsps => platform/intel}/Makefile.am (100%) rename topology/{dsps => platform/intel}/bdw.m4 (100%) rename topology/{dsps => platform/intel}/bxt.m4 (100%) rename topology/{dsps => platform/intel}/byt.m4 (100%) rename topology/{dsps => platform/intel}/cht.m4 (100%) rename topology/{dsps => platform/intel}/cnl.m4 (100%) rename topology/{dsps => platform/intel}/hsw.m4 (100%) diff --git a/configure.ac b/configure.ac index cc5e59e13140..df5cd92a149b 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,8 @@ AC_OUTPUT([ rmbox/Makefile topology/Makefile topology/common/Makefile - topology/dsps/Makefile + topology/platform/Makefile + topology/platform/intel/Makefile topology/m4/Makefile topology/sof/Makefile topology/test/Makefile diff --git a/topology/Makefile.am b/topology/Makefile.am index 73e10e90e3e2..25410b0f24ce 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -3,10 +3,10 @@ # Dependencies # -SUBDIRS = test m4 sof common dsps +SUBDIRS = test m4 sof common platform DEPS = \ - dsps/*.m4 \ + platform/intel/*.m4 \ common/*.m4 \ m4/*.m4 \ sof/*.m4 diff --git a/topology/platform/Makefile.am b/topology/platform/Makefile.am new file mode 100644 index 000000000000..c6966a9b67d6 --- /dev/null +++ b/topology/platform/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = intel diff --git a/topology/dsps/Makefile.am b/topology/platform/intel/Makefile.am similarity index 100% rename from topology/dsps/Makefile.am rename to topology/platform/intel/Makefile.am diff --git a/topology/dsps/bdw.m4 b/topology/platform/intel/bdw.m4 similarity index 100% rename from topology/dsps/bdw.m4 rename to topology/platform/intel/bdw.m4 diff --git a/topology/dsps/bxt.m4 b/topology/platform/intel/bxt.m4 similarity index 100% rename from topology/dsps/bxt.m4 rename to topology/platform/intel/bxt.m4 diff --git a/topology/dsps/byt.m4 b/topology/platform/intel/byt.m4 similarity index 100% rename from topology/dsps/byt.m4 rename to topology/platform/intel/byt.m4 diff --git a/topology/dsps/cht.m4 b/topology/platform/intel/cht.m4 similarity index 100% rename from topology/dsps/cht.m4 rename to topology/platform/intel/cht.m4 diff --git a/topology/dsps/cnl.m4 b/topology/platform/intel/cnl.m4 similarity index 100% rename from topology/dsps/cnl.m4 rename to topology/platform/intel/cnl.m4 diff --git a/topology/dsps/hsw.m4 b/topology/platform/intel/hsw.m4 similarity index 100% rename from topology/dsps/hsw.m4 rename to topology/platform/intel/hsw.m4 diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 0698b42939a6..847bfb40b686 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Apollolake DSP configuration -include(`dsps/bxt.m4') +include(`platform/intel/bxt.m4') # # Define the pipelines diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index b913d42b5a21..9110ffaa49b6 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Apollolake DSP configuration -include(`dsps/bxt.m4') +include(`platform/intel/bxt.m4') # # Define the pipelines diff --git a/topology/sof-bdw-rt286.m4 b/topology/sof-bdw-rt286.m4 index e1f5bfbfdd3b..461cb6ab4713 100644 --- a/topology/sof-bdw-rt286.m4 +++ b/topology/sof-bdw-rt286.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Broadwell DSP configuration -include(`dsps/bdw.m4') +include(`platform/intel/bdw.m4') # # Define the pipelines diff --git a/topology/sof-bdw-rt5640.m4 b/topology/sof-bdw-rt5640.m4 index cd955505bde5..e811a130f7c2 100644 --- a/topology/sof-bdw-rt5640.m4 +++ b/topology/sof-bdw-rt5640.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Broadwell DSP configuration -include(`dsps/bdw.m4') +include(`platform/intel/bdw.m4') # # Define the pipelines diff --git a/topology/sof-byt-da7213.m4 b/topology/sof-byt-da7213.m4 index a8c5c01960bb..c36ed67c2b2a 100644 --- a/topology/sof-byt-da7213.m4 +++ b/topology/sof-byt-da7213.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Baytrail DSP configuration -include(`dsps/byt.m4') +include(`platform/intel/byt.m4') # # Define the pipelines diff --git a/topology/sof-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 index ac4af7906430..2bde71a72d13 100644 --- a/topology/sof-byt-nocodec.m4 +++ b/topology/sof-byt-nocodec.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Baytrail DSP configuration -include(`dsps/byt.m4') +include(`platform/intel/byt.m4') # # Define the pipelines diff --git a/topology/sof-byt-rt5640.m4 b/topology/sof-byt-rt5640.m4 index 19eca6d169ee..a64d5c3a5b99 100644 --- a/topology/sof-byt-rt5640.m4 +++ b/topology/sof-byt-rt5640.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Baytrail DSP configuration -include(`dsps/byt.m4') +include(`platform/intel/byt.m4') # # Define the pipelines diff --git a/topology/sof-byt-rt5645.m4 b/topology/sof-byt-rt5645.m4 index 2c0eac500a07..57e395969781 100644 --- a/topology/sof-byt-rt5645.m4 +++ b/topology/sof-byt-rt5645.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Baytrail DSP configuration -include(`dsps/byt.m4') +include(`platform/intel/byt.m4') # # Define the pipelines diff --git a/topology/sof-byt-rt5651.m4 b/topology/sof-byt-rt5651.m4 index 4397b3bd8e03..c5bd9741881e 100644 --- a/topology/sof-byt-rt5651.m4 +++ b/topology/sof-byt-rt5651.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Baytrail DSP configuration -include(`dsps/byt.m4') +include(`platform/intel/byt.m4') # # Define the pipelines diff --git a/topology/sof-cht-max98090.m4 b/topology/sof-cht-max98090.m4 index 5a3a89564c50..96ac5a5d8fd5 100644 --- a/topology/sof-cht-max98090.m4 +++ b/topology/sof-cht-max98090.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Cherrytrail DSP configuration -include(`dsps/cht.m4') +include(`platform/intel/cht.m4') # # Define the pipelines diff --git a/topology/sof-cht-nocodec.m4 b/topology/sof-cht-nocodec.m4 index cfb2453f4996..f1c6694fb822 100644 --- a/topology/sof-cht-nocodec.m4 +++ b/topology/sof-cht-nocodec.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include CherryTrail DSP configuration -include(`dsps/cht.m4') +include(`platform/intel/cht.m4') # # Define the pipelines diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index 66bd3a07b878..5a55c8a32a6a 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Apollolake DSP configuration -include(`dsps/cnl.m4') +include(`platform/intel/cnl.m4') # # Define the pipelines diff --git a/topology/sof-hsw-rt5640.m4 b/topology/sof-hsw-rt5640.m4 index f839fc382156..92722869aeda 100644 --- a/topology/sof-hsw-rt5640.m4 +++ b/topology/sof-hsw-rt5640.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Haswell DSP configuration -include(`dsps/hsw.m4') +include(`platform/intel/hsw.m4') # # Define the pipelines diff --git a/topology/test/Makefile.am b/topology/test/Makefile.am index d494fcb5a5cb..e1894e0deeba 100644 --- a/topology/test/Makefile.am +++ b/topology/test/Makefile.am @@ -8,7 +8,7 @@ export USE_XARGS=yes endif DEPS = \ - ../dsps/*.m4 \ + ../platform/intel/*.m4 \ ../common/*.m4 \ ../m4/*.m4 \ ../sof/*.m4 diff --git a/topology/test/test-all.m4 b/topology/test/test-all.m4 index 00318b0155f4..709e861bf873 100644 --- a/topology/test/test-all.m4 +++ b/topology/test/test-all.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Baytrail DSP configuration -include(`dsps/byt.m4') +include(`byt.m4') # # Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! diff --git a/topology/test/test-capture.m4 b/topology/test/test-capture.m4 index 9d85009a41a0..b9aa29bb37ab 100644 --- a/topology/test/test-capture.m4 +++ b/topology/test/test-capture.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Baytrail DSP configuration -include(`dsps/byt.m4') +include(`byt.m4') # # Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! diff --git a/topology/test/test-playback.m4 b/topology/test/test-playback.m4 index d607d3a455b9..10a9eb6d2572 100644 --- a/topology/test/test-playback.m4 +++ b/topology/test/test-playback.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Baytrail DSP configuration -include(`dsps/byt.m4') +include(`byt.m4') # # Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! diff --git a/topology/test/test-tone-playback.m4 b/topology/test/test-tone-playback.m4 index 52484276624e..e16a525cfea7 100644 --- a/topology/test/test-tone-playback.m4 +++ b/topology/test/test-tone-playback.m4 @@ -14,7 +14,7 @@ include(`common/tlv.m4') include(`sof/tokens.m4') # Include Baytrail DSP configuration -include(`dsps/byt.m4') +include(`byt.m4') # # Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index ad4d1da10c2d..89cd515613ef 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -8,7 +8,7 @@ set -e # M4 preprocessor flags -export M4PATH="../:../m4:../common" +export M4PATH="../:../m4:../common:../platform/intel" # Simple component test cases # can be used on components with 1 sink and 1 source. From f58a047278cbf6254da2a3500c2dc74ef07e4f3a Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 25 Jun 2018 00:04:27 -0700 Subject: [PATCH 188/324] topology: move ssp related macros to ssp.m4 in platform/common Signed-off-by: Ranjani Sridharan --- configure.ac | 1 + topology/Makefile.am | 3 +- topology/m4/dai.m4 | 41 ----------------------- topology/platform/Makefile.am | 2 +- topology/platform/common/Makefile.am | 2 ++ topology/platform/common/ssp.m4 | 46 ++++++++++++++++++++++++++ topology/sof-apl-nocodec.m4 | 9 ++--- topology/sof-apl-tdf8532.m4 | 49 ++++++++++++++-------------- topology/sof-bdw-rt286.m4 | 9 ++--- topology/sof-bdw-rt5640.m4 | 9 ++--- topology/sof-byt-da7213.m4 | 9 ++--- topology/sof-byt-nocodec.m4 | 9 ++--- topology/sof-byt-rt5640.m4 | 9 ++--- topology/sof-byt-rt5645.m4 | 9 ++--- topology/sof-byt-rt5651.m4 | 9 ++--- topology/sof-cht-max98090.m4 | 9 ++--- topology/sof-cht-nocodec.m4 | 9 ++--- topology/sof-cnl-rt274.m4 | 9 ++--- topology/sof-hsw-rt5640.m4 | 9 ++--- topology/test/test-all.m4 | 9 ++--- topology/test/test-capture.m4 | 9 ++--- topology/test/test-playback.m4 | 9 ++--- topology/test/test-tone-playback.m4 | 9 ++--- topology/test/tplg-build.sh | 2 +- 24 files changed, 158 insertions(+), 132 deletions(-) create mode 100644 topology/platform/common/Makefile.am create mode 100644 topology/platform/common/ssp.m4 diff --git a/configure.ac b/configure.ac index df5cd92a149b..0336378270c3 100644 --- a/configure.ac +++ b/configure.ac @@ -22,6 +22,7 @@ AC_OUTPUT([ topology/common/Makefile topology/platform/Makefile topology/platform/intel/Makefile + topology/platform/common/Makefile topology/m4/Makefile topology/sof/Makefile topology/test/Makefile diff --git a/topology/Makefile.am b/topology/Makefile.am index 25410b0f24ce..b59c6f588079 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -7,6 +7,7 @@ SUBDIRS = test m4 sof common platform DEPS = \ platform/intel/*.m4 \ + platform/common/*.m4 \ common/*.m4 \ m4/*.m4 \ sof/*.m4 @@ -34,7 +35,7 @@ MACHINES = \ .PRECIOUS: %.conf %.conf : %.m4 ${DEPS} - m4 -I m4 -I common $< > $@ + m4 -I m4 -I common -I platform/common $< > $@ %.tplg : %.conf alsatplg -v 1 -c $< -o $@ diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index 882d958e8842..5fc1dedde66b 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -121,47 +121,6 @@ define(`D_DAI', `SectionDAI."'N_DAI`" {' ` capture "'$3`"' `}') -dnl DAI_CLOCK(clock, freq, codec_master) -define(`DAI_CLOCK', - $1 STR($3) - $1_freq STR($2)) - - -dnl DAI_TDM(slots, width, tx_mask, rx_mask) -define(`DAI_TDM', -`tdm_slots 'STR($1) -` tdm_slot_width 'STR($2) -` tx_slots 'STR($3) -` rx_slots 'STR($4) -) -dnl SSP_CONFIG(format, mclk, bclk, fsync, tdm, ssp_config_data) -define(`SSP_CONFIG', -` format "'$1`"' -` '$2 -` '$3 -` '$4 -` '$5 -`}' -$6 -) - -dnl SSP_CONFIG_DATA(type, idx, valid bits, mclk_id) -dnl mclk_id is optional -define(`SSP_CONFIG_DATA', -`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {' -` tokens "sof_ssp_tokens"' -` tuples."word" {' -` SOF_TKN_INTEL_SSP_SAMPLE_BITS' STR($3) -` }' -` tuples."short" {' -` SOF_TKN_INTEL_SSP_MCLK_ID' ifelse($4, `', "0", STR($4)) -` }' -`}' -`SectionData."'N_DAI_CONFIG($1$2)`_data" {' -` tuples "'N_DAI_CONFIG($1$2)`_tuples"' -`}' -) - dnl PDM_TUPLES(pdm ctrl id, mic_a_enable, mic_b_enable, polarity_a, polarity_b, dnl clk_egde, skew) define(`PDM_TUPLES', diff --git a/topology/platform/Makefile.am b/topology/platform/Makefile.am index c6966a9b67d6..011ff9e938aa 100644 --- a/topology/platform/Makefile.am +++ b/topology/platform/Makefile.am @@ -1 +1 @@ -SUBDIRS = intel +SUBDIRS = intel common diff --git a/topology/platform/common/Makefile.am b/topology/platform/common/Makefile.am new file mode 100644 index 000000000000..a8576d588efc --- /dev/null +++ b/topology/platform/common/Makefile.am @@ -0,0 +1,2 @@ +EXTRA_DIST = \ + ssp.m4 diff --git a/topology/platform/common/ssp.m4 b/topology/platform/common/ssp.m4 new file mode 100644 index 000000000000..f3c78626c1c0 --- /dev/null +++ b/topology/platform/common/ssp.m4 @@ -0,0 +1,46 @@ +divert(-1) + +dnl SSP related macros + +dnl SSP_CLOCK(clock, freq, codec_master) +define(`SSP_CLOCK', + $1 STR($3) + $1_freq STR($2)) + + +dnl SSP_TDM(slots, width, tx_mask, rx_mask) +define(`SSP_TDM', +`tdm_slots 'STR($1) +` tdm_slot_width 'STR($2) +` tx_slots 'STR($3) +` rx_slots 'STR($4) +) +dnl SSP_CONFIG(format, mclk, bclk, fsync, tdm, ssp_config_data) +define(`SSP_CONFIG', +` format "'$1`"' +` '$2 +` '$3 +` '$4 +` '$5 +`}' +$6 +) + +dnl SSP_CONFIG_DATA(type, idx, valid bits, mclk_id) +dnl mclk_id is optional +define(`SSP_CONFIG_DATA', +`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples" {' +` tokens "sof_ssp_tokens"' +` tuples."word" {' +` SOF_TKN_INTEL_SSP_SAMPLE_BITS' STR($3) +` }' +` tuples."short" {' +` SOF_TKN_INTEL_SSP_MCLK_ID' ifelse($4, `', "0", STR($4)) +` }' +`}' +`SectionData."'N_DAI_CONFIG($1$2)`_data" {' +` tuples "'N_DAI_CONFIG($1$2)`_tuples"' +`}' +) + +divert(0)dnl diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 847bfb40b686..07a1c5b2cdc0 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -6,6 +6,7 @@ include(`pipeline.m4') include(`utils.m4') include(`dai.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -91,8 +92,8 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, 0, NoCodec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 2400000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 25, 3, 3), SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index 9110ffaa49b6..a37e5216a5a2 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -6,6 +6,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -179,45 +180,45 @@ PCM_DUPLEX_ADD(Port5, 5, 5, 5, PIPELINE_PCM_9, PIPELINE_PCM_10) # DAI_CONFIG(SSP, 4, 4, SSP4-Codec, - SSP_CONFIG(DSP_B, DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 12288000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(8, 32, 15, 15), + SSP_CONFIG(DSP_B, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 12288000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(8, 32, 15, 15), SSP_CONFIG_DATA(SSP, 4, 32))) DAI_CONFIG(SSP, 2, 2, SSP2-Codec, - SSP_CONFIG(DSP_B, DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 12288000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 32, 255, 255), + SSP_CONFIG(DSP_B, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 12288000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 32, 255, 255), SSP_CONFIG_DATA(SSP, 2, 32))) DAI_CONFIG(SSP, 0, 0, SSP0-Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 1536000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 16, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), SSP_CONFIG_DATA(SSP, 0, 16))) DAI_CONFIG(SSP, 1, 1, SSP1-Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 1536000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 16, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), SSP_CONFIG_DATA(SSP, 1, 16))) DAI_CONFIG(SSP, 3, 3, SSP3-Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 1536000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 16, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), SSP_CONFIG_DATA(SSP, 3, 16))) DAI_CONFIG(SSP, 5, 5, SSP5-Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24576000, codec_mclk_in), - DAI_CLOCK(bclk, 1536000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 16, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), SSP_CONFIG_DATA(SSP, 5, 16))) diff --git a/topology/sof-bdw-rt286.m4 b/topology/sof-bdw-rt286.m4 index 461cb6ab4713..f8294d2026e8 100644 --- a/topology/sof-bdw-rt286.m4 +++ b/topology/sof-bdw-rt286.m4 @@ -6,6 +6,7 @@ include(`pipeline.m4') include(`utils.m4') include(`dai.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -91,8 +92,8 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 0, 0, Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24000000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24000000, codec_mclk_in), + SSP_CLOCK(bclk, 2400000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 25, 3, 3), SSP_CONFIG_DATA(SSP, 0, 24))) diff --git a/topology/sof-bdw-rt5640.m4 b/topology/sof-bdw-rt5640.m4 index e811a130f7c2..3c72d3008191 100644 --- a/topology/sof-bdw-rt5640.m4 +++ b/topology/sof-bdw-rt5640.m4 @@ -6,6 +6,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -91,8 +92,8 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 0, 0, Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24000000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24000000, codec_mclk_in), + SSP_CLOCK(bclk, 2400000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 25, 3, 3), SSP_CONFIG_DATA(SSP, 0, 24))) diff --git a/topology/sof-byt-da7213.m4 b/topology/sof-byt-da7213.m4 index c36ed67c2b2a..af5129c8d71b 100644 --- a/topology/sof-byt-da7213.m4 +++ b/topology/sof-byt-da7213.m4 @@ -6,6 +6,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -91,8 +92,8 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, 0, SSP2-Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 2400000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 25, 3, 3), SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 index 2bde71a72d13..aed2b977a546 100644 --- a/topology/sof-byt-nocodec.m4 +++ b/topology/sof-byt-nocodec.m4 @@ -6,6 +6,7 @@ include(`pipeline.m4') include(`utils.m4') include(`dai.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -91,8 +92,8 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, 0, NoCodec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 2400000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 25, 3, 3), SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-byt-rt5640.m4 b/topology/sof-byt-rt5640.m4 index a64d5c3a5b99..41074914d905 100644 --- a/topology/sof-byt-rt5640.m4 +++ b/topology/sof-byt-rt5640.m4 @@ -6,6 +6,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -91,8 +92,8 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, 0, SSP2-Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 2400000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 25, 3, 3), SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-byt-rt5645.m4 b/topology/sof-byt-rt5645.m4 index 57e395969781..028cb45d6d19 100644 --- a/topology/sof-byt-rt5645.m4 +++ b/topology/sof-byt-rt5645.m4 @@ -6,6 +6,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -91,8 +92,8 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, 0, SSP2-Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 2400000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 25, 3, 3), SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-byt-rt5651.m4 b/topology/sof-byt-rt5651.m4 index c5bd9741881e..d2cdfad5e0d7 100644 --- a/topology/sof-byt-rt5651.m4 +++ b/topology/sof-byt-rt5651.m4 @@ -6,6 +6,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -91,8 +92,8 @@ PCM_DUPLEX_ADD(Low Latency, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, 0, SSP2-Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 2400000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 25, 3, 3), SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-cht-max98090.m4 b/topology/sof-cht-max98090.m4 index 96ac5a5d8fd5..38244d76ff6e 100644 --- a/topology/sof-cht-max98090.m4 +++ b/topology/sof-cht-max98090.m4 @@ -6,6 +6,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -91,8 +92,8 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, 0, SSP2-Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 1920000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 20, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 1920000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 20, 3, 3), SSP_CONFIG_DATA(SSP, 2, 16))) diff --git a/topology/sof-cht-nocodec.m4 b/topology/sof-cht-nocodec.m4 index f1c6694fb822..466f56d0c624 100644 --- a/topology/sof-cht-nocodec.m4 +++ b/topology/sof-cht-nocodec.m4 @@ -6,6 +6,7 @@ include(`pipeline.m4') include(`utils.m4') include(`dai.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -91,8 +92,8 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 2, 0, NoCodec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 19200000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 2400000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 25, 3, 3), SSP_CONFIG_DATA(SSP, 2, 24))) diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index 5a55c8a32a6a..e416ce3f6b72 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -6,6 +6,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -63,10 +64,10 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 0, 0, SSP0-Codec, - SSP_CONFIG(DSP_B, DAI_CLOCK(mclk, 24000000, codec_mclk_in), - DAI_CLOCK(bclk, 4800000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(4, 25, 3, 3), + SSP_CONFIG(DSP_B, SSP_CLOCK(mclk, 24000000, codec_mclk_in), + SSP_CLOCK(bclk, 4800000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(4, 25, 3, 3), SSP_CONFIG_DATA(SSP, 0, 24))) VIRTUAL_DAPM_ROUTE_OUT(codec0_out, SSP, 0, OUT, 0) diff --git a/topology/sof-hsw-rt5640.m4 b/topology/sof-hsw-rt5640.m4 index 92722869aeda..9bf8976df364 100644 --- a/topology/sof-hsw-rt5640.m4 +++ b/topology/sof-hsw-rt5640.m4 @@ -6,6 +6,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') +include(`ssp.m4') # Include TLV library include(`common/tlv.m4') @@ -91,8 +92,8 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # BE configurations - overrides config in ACPI if present # DAI_CONFIG(SSP, 0, 0, Codec, - SSP_CONFIG(I2S, DAI_CLOCK(mclk, 24000000, codec_mclk_in), - DAI_CLOCK(bclk, 2400000, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, 25, 3, 3), + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24000000, codec_mclk_in), + SSP_CLOCK(bclk, 2400000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 25, 3, 3), SSP_CONFIG_DATA(SSP, 0, 24))) diff --git a/topology/test/test-all.m4 b/topology/test/test-all.m4 index 709e861bf873..174f7d2600db 100644 --- a/topology/test/test-all.m4 +++ b/topology/test/test-all.m4 @@ -4,6 +4,7 @@ # Include topology builder include(`dai.m4') +include(`ssp.m4') include(`utils.m4') include(`pipeline.m4') @@ -86,9 +87,9 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, SSP_CONFIG(TEST_SSP_MODE, - DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), - DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), + SSP_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), + SSP_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, TEST_SSP_PHY_BITS, 3, 3), SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_SSP_DATA_BITS))) diff --git a/topology/test/test-capture.m4 b/topology/test/test-capture.m4 index b9aa29bb37ab..128717b8690a 100644 --- a/topology/test/test-capture.m4 +++ b/topology/test/test-capture.m4 @@ -4,6 +4,7 @@ # Include topology builder include(`dai.m4') +include(`ssp.m4') include(`utils.m4') include(`pipeline.m4') @@ -70,10 +71,10 @@ PCM_CAPTURE_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_2) DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, ifelse(TEST_DAI_TYPE, `SSP', SSP_CONFIG(TEST_SSP_MODE, - DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), - DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), + SSP_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), + SSP_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, TEST_SSP_PHY_BITS, 3, 3), SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_SSP_DATA_BITS)), TEST_DAI_TYPE, `DMIC', diff --git a/topology/test/test-playback.m4 b/topology/test/test-playback.m4 index 10a9eb6d2572..789c8bb6e28f 100644 --- a/topology/test/test-playback.m4 +++ b/topology/test/test-playback.m4 @@ -5,6 +5,7 @@ # Include topology builder include(`pipeline.m4') include(`dai.m4') +include(`ssp.m4') include(`utils.m4') # Include TLV library @@ -69,9 +70,9 @@ PCM_PLAYBACK_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1) # DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, SSP_CONFIG(TEST_SSP_MODE, - DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_slave), - DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), + SSP_CLOCK(mclk, TEST_SSP_MCLK, codec_slave), + SSP_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, TEST_SSP_PHY_BITS, 3, 3), SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_SSP_DATA_BITS))) diff --git a/topology/test/test-tone-playback.m4 b/topology/test/test-tone-playback.m4 index e16a525cfea7..e74ae4ac5a4b 100644 --- a/topology/test/test-tone-playback.m4 +++ b/topology/test/test-tone-playback.m4 @@ -5,6 +5,7 @@ # Include topology builder include(`pipeline.m4') include(`dai.m4') +include(`ssp.m4') include(`utils.m4') # Include TLV library @@ -58,9 +59,9 @@ DAI_ADD(sof/pipe-dai-playback.m4, # DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, SSP_CONFIG(TEST_SSP_MODE, - DAI_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), - DAI_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), - DAI_CLOCK(fsync, 48000, codec_slave), - DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3), + SSP_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), + SSP_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, TEST_SSP_PHY_BITS, 3, 3), SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_SSP_DATA_BITS))) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 89cd515613ef..ec750934dd6b 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -8,7 +8,7 @@ set -e # M4 preprocessor flags -export M4PATH="../:../m4:../common:../platform/intel" +export M4PATH="../:../m4:../common:../platform/intel:../platform/common" # Simple component test cases # can be used on components with 1 sink and 1 source. From f73aa7397896b58f1a17fcc16513f79625881d22 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 25 Jun 2018 00:09:53 -0700 Subject: [PATCH 189/324] topology: move dmic related macros to dmic.m4 in platform/intel Signed-off-by: Ranjani Sridharan --- topology/m4/dai.m4 | 55 -------------------------- topology/platform/intel/Makefile.am | 3 +- topology/platform/intel/dmic.m4 | 60 +++++++++++++++++++++++++++++ topology/test/test-capture.m4 | 1 + 4 files changed, 63 insertions(+), 56 deletions(-) create mode 100644 topology/platform/intel/dmic.m4 diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index 5fc1dedde66b..b0802affd733 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -121,61 +121,6 @@ define(`D_DAI', `SectionDAI."'N_DAI`" {' ` capture "'$3`"' `}') -dnl PDM_TUPLES(pdm ctrl id, mic_a_enable, mic_b_enable, polarity_a, polarity_b, -dnl clk_egde, skew) -define(`PDM_TUPLES', -` tuples."short.pdm$1" {' -` SOF_TKN_INTEL_DMIC_PDM_CTRL_ID' STR($1) -` SOF_TKN_INTEL_DMIC_PDM_MIC_A_Enable' STR($2) -` SOF_TKN_INTEL_DMIC_PDM_MIC_B_Enable' STR($3) -` SOF_TKN_INTEL_DMIC_PDM_POLARITY_A' STR($4) -` SOF_TKN_INTEL_DMIC_PDM_POLARITY_B' STR($5) -` SOF_TKN_INTEL_DMIC_PDM_CLK_EDGE' STR($6) -` SOF_TKN_INTEL_DMIC_PDM_SKEW' STR($7) -` }' -) - -dnl PDM_CONFIG(type, idx, pdm tuples list) -define(`PDM_CONFIG', -`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_pdm_tuples" {' -` tokens "sof_dmic_pdm_tokens"' -$3 -`}' -) - -dnl DMIC currently only supports 16 bit or 32-bit word length -dnl DMIC_WORD_LENGTH(frame format) -define(`DMIC_WORD_LENGTH', -`ifelse($1, `s16le', 16, $1, `s32le', 32, `')') - -dnl DMIC_CONFIG(driver_version, clk_min, clk_mac, duty_min, duty_max, -dnl req pdm count, sample_rate, -dnl fifo word length, type, idx, pdm controller config) -define(`DMIC_CONFIG', -`SectionVendorTuples."'N_DAI_CONFIG($9$10)`_dmic_tuples" {' -` tokens "sof_dmic_tokens"' -` tuples."word" {' -` SOF_TKN_INTEL_DMIC_DRIVER_VERSION' STR($1) -` SOF_TKN_INTEL_DMIC_CLK_MIN' STR($2) -` SOF_TKN_INTEL_DMIC_CLK_MAX' STR($3) -` SOF_TKN_INTEL_DMIC_DUTY_MIN' STR($4) -` SOF_TKN_INTEL_DMIC_DUTY_MAX' STR($5) -` SOF_TKN_INTEL_DMIC_NUM_PDM_ACTIVE' STR($6) -` SOF_TKN_INTEL_DMIC_SAMPLE_RATE' STR($7) -` SOF_TKN_INTEL_DMIC_FIFO_WORD_LENGTH' STR($8) -` }' -`}' -dnl PDM config for the number of active PDM controllers -$11 -`SectionData."'N_DAI_CONFIG($9$10)`_pdm_data" {' -` tuples "'N_DAI_CONFIG($9$10)`_pdm_tuples"' -`}' -`SectionData."'N_DAI_CONFIG($9$10)`_data" {' -` tuples "'N_DAI_CONFIG($9$10)`_dmic_tuples"' - -`}' -) - dnl DAI Config) define(`N_DAI_CONFIG', `DAICONFIG.'$1) diff --git a/topology/platform/intel/Makefile.am b/topology/platform/intel/Makefile.am index d4c8dd6f2d40..bc56971989ed 100644 --- a/topology/platform/intel/Makefile.am +++ b/topology/platform/intel/Makefile.am @@ -4,5 +4,6 @@ EXTRA_DIST = \ byt.m4 \ cht.m4 \ hsw.m4 \ - cnl.m4 + cnl.m4 \ + dmic.m4 diff --git a/topology/platform/intel/dmic.m4 b/topology/platform/intel/dmic.m4 new file mode 100644 index 000000000000..393c3a08bde0 --- /dev/null +++ b/topology/platform/intel/dmic.m4 @@ -0,0 +1,60 @@ +divert(-1) + +dnl DMIC related macros + +dnl PDM_TUPLES(pdm ctrl id, mic_a_enable, mic_b_enable, polarity_a, polarity_b, +dnl clk_egde, skew) +define(`PDM_TUPLES', +` tuples."short.pdm$1" {' +` SOF_TKN_INTEL_DMIC_PDM_CTRL_ID' STR($1) +` SOF_TKN_INTEL_DMIC_PDM_MIC_A_Enable' STR($2) +` SOF_TKN_INTEL_DMIC_PDM_MIC_B_Enable' STR($3) +` SOF_TKN_INTEL_DMIC_PDM_POLARITY_A' STR($4) +` SOF_TKN_INTEL_DMIC_PDM_POLARITY_B' STR($5) +` SOF_TKN_INTEL_DMIC_PDM_CLK_EDGE' STR($6) +` SOF_TKN_INTEL_DMIC_PDM_SKEW' STR($7) +` }' +) + +dnl PDM_CONFIG(type, idx, pdm tuples list) +define(`PDM_CONFIG', +`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_pdm_tuples" {' +` tokens "sof_dmic_pdm_tokens"' +$3 +`}' +) + +dnl DMIC currently only supports 16 bit or 32-bit word length +dnl DMIC_WORD_LENGTH(frame format) +define(`DMIC_WORD_LENGTH', +`ifelse($1, `s16le', 16, $1, `s32le', 32, `')') + +dnl DMIC_CONFIG(driver_version, clk_min, clk_mac, duty_min, duty_max, +dnl req pdm count, sample_rate, +dnl fifo word length, type, idx, pdm controller config) +define(`DMIC_CONFIG', +`SectionVendorTuples."'N_DAI_CONFIG($9$10)`_dmic_tuples" {' +` tokens "sof_dmic_tokens"' +` tuples."word" {' +` SOF_TKN_INTEL_DMIC_DRIVER_VERSION' STR($1) +` SOF_TKN_INTEL_DMIC_CLK_MIN' STR($2) +` SOF_TKN_INTEL_DMIC_CLK_MAX' STR($3) +` SOF_TKN_INTEL_DMIC_DUTY_MIN' STR($4) +` SOF_TKN_INTEL_DMIC_DUTY_MAX' STR($5) +` SOF_TKN_INTEL_DMIC_NUM_PDM_ACTIVE' STR($6) +` SOF_TKN_INTEL_DMIC_SAMPLE_RATE' STR($7) +` SOF_TKN_INTEL_DMIC_FIFO_WORD_LENGTH' STR($8) +` }' +`}' +dnl PDM config for the number of active PDM controllers +$11 +`SectionData."'N_DAI_CONFIG($9$10)`_pdm_data" {' +` tuples "'N_DAI_CONFIG($9$10)`_pdm_tuples"' +`}' +`SectionData."'N_DAI_CONFIG($9$10)`_data" {' +` tuples "'N_DAI_CONFIG($9$10)`_dmic_tuples"' + +`}' +) + +divert(0)dnl diff --git a/topology/test/test-capture.m4 b/topology/test/test-capture.m4 index 128717b8690a..dd75bf5d9018 100644 --- a/topology/test/test-capture.m4 +++ b/topology/test/test-capture.m4 @@ -5,6 +5,7 @@ # Include topology builder include(`dai.m4') include(`ssp.m4') +include(`dmic.m4') include(`utils.m4') include(`pipeline.m4') From 229da95e0d5a9d8abce89a5bb3804926b74d1ba0 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Mon, 25 Jun 2018 16:52:22 +0800 Subject: [PATCH 190/324] topology: dai: correct default_hw_conf_id default_hw_conf_id was used by mistake, we should use index 0 of the hw config array. Signed-off-by: Keyon Jie --- topology/m4/dai.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index b0802affd733..65988ce9d446 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -145,7 +145,7 @@ define(`DAI_CONFIG', `SectionBE."'$4`" {' ` id "'$3`"' ` index "0"' -` default_hw_conf_id "'$2`"' +` default_hw_conf_id "0"' `' ` hw_configs [' ` "'$1$2`"' From 553137d7414f632d4d5e81d3c1eba5a6a33b8fc3 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Mon, 25 Jun 2018 16:55:50 +0800 Subject: [PATCH 191/324] topology: sof-apl-nocodec: enable multiple SSP pipelines Signed-off-by: Keyon Jie --- topology/sof-apl-nocodec.m4 | 262 ++++++++++++++++++++++++++++-------- 1 file changed, 207 insertions(+), 55 deletions(-) diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 07a1c5b2cdc0..3ba5806d7979 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -3,10 +3,10 @@ # # Include topology builder -include(`pipeline.m4') include(`utils.m4') include(`dai.m4') include(`ssp.m4') +include(`pipeline.m4') # Include TLV library include(`common/tlv.m4') @@ -20,80 +20,232 @@ include(`platform/intel/bxt.m4') # # Define the pipelines # -# PCM0 ----> volume ---------------+ -# |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ -# | -# Tone -----> volume ----+ -# -# PCM1 <---- Volume <---- SSP2 +# PCM0 ----> volume -----> SSP0 +# <---- volume <----- SSP0 +# PCM1 <---- Volume <----- SSP1 +# <---- Volume <----- SSP1 +# PCM2 ----> volume -----> SSP2 +# <---- Volume <----- SSP2 +# PCM3 ----> volume -----> SSP3 +# <---- volume <----- SSP3 +# PCM4 ----> volume -----> SSP4 +# <---- Volume <----- SSP4 +# PCM5 ----> volume -----> SSP5 +# <---- volume <----- SSP3 # -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_ADD(sof/pipe-low-latency-playback.m4, - 1, 0, 2, s32le, - 48, 1000, 0, 0) +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 1, 0, 2, s16le, + 48, 1000, 0, 0, SSP, 0, s16le, 2) -# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_ADD(sof/pipe-low-latency-capture.m4, - 2, 0, 2, s32le, - 48, 1000, 0, 0) +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 2, 0, 2, s16le, + 48, 1000, 0, 0, SSP, 0, s16le, 2) + +# Low Latency playback pipeline 3 on PCM 1 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 3, 1, 2, s16le, + 48, 1000, 0, 0, SSP, 1, s16le, 2) + +# Low Latency capture pipeline 4 on PCM 1 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 4, 1, 2, s16le, + 48, 1000, 0, 0, SSP, 1, s16le, 2) + +# Low Latency playback pipeline 5 on PCM 2 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 5, 2, 2, s16le, + 48, 1000, 0, 0, SSP, 2, s16le, 2) + +# Low Latency capture pipeline 6 on PCM 2 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 6, 2, 2, s16le, + 48, 1000, 0, 0, SSP, 2, s16le, 2) + +# Low Latency playback pipeline 7 on PCM 3 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 7, 3, 2, s16le, + 48, 1000, 0, 0, SSP, 3, s16le, 2) + +# Low Latency capture pipeline 8 on PCM 3 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 8, 3, 2, s16le, + 48, 1000, 0, 0, SSP, 3, s16le, 2) + +# Low Latency playback pipeline 9 on PCM 4 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +#PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, +# 9, 4, 2, s16le, +# 48, 1000, 0, 0, SSP, 4, s16le, 2) + +# Low Latency capture pipeline 10 on PCM 4 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +#PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, +# 10, 4, 2, s16le, +# 48, 1000, 0, 0, SSP, 4, s16le, 2) + +# Low Latency playback pipeline 11 on PCM 5 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +#PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, +# 11, 5, 2, s16le, +# 48, 1000, 0, 0, SSP, 5, s16le, 2) + +# Low Latency capture pipeline 12 on PCM 5 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +#PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, +# 12, 5, 2, s16le, +# 48, 1000, 0, 0, SSP, 5, s16le, 2) -# PCM Media Playback pipeline 3 on PCM 1 using max 2 channels of s32le. -# Schedule 96 frames per 2000us deadline on core 0 with priority 1 -PIPELINE_PCM_ADD(sof/pipe-pcm-media.m4, - 3, 1, 2, s32le, - 96, 2000, 1, 0) - -# Tone Playback pipeline 5 using max 2 channels of s32le. -# Schedule 192 frames per 4000us deadline on core 0 with priority 2 -PIPELINE_ADD(sof/pipe-tone.m4, - 5, 2, s32le, - 192, 4000, 2, 0) - -# Connect pipelines together -SectionGraph."pipe-apl-nocodec" { - index "0" - - lines [ - # media 0 - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_3) - #tone - dapm(PIPELINE_MIXER_1, PIPELINE_SOURCE_5) - ] -} # -# DAI configuration -# -# SSP port 2 is our only pipeline DAI +# DAIs configuration # +# playback DAI is SSP0 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 0, NoCodec-0, + PIPELINE_SOURCE_1, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP0 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, 0, NoCodec-0, + PIPELINE_SINK_2, 2, s16le, + 48, 1000, 0, 0) + +# playback DAI is SSP1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 3, SSP, 1, NoCodec-1, + PIPELINE_SOURCE_3, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 4, SSP, 1, NoCodec-1, + PIPELINE_SINK_4, 2, s16le, + 48, 1000, 0, 0) + # playback DAI is SSP2 using 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, NoCodec, - PIPELINE_SOURCE_1, 2, s24le, + 5, SSP, 2, NoCodec-2, + PIPELINE_SOURCE_5, 2, s16le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods -# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 6, SSP, 2, NoCodec-2, + PIPELINE_SINK_6, 2, s16le, + 48, 1000, 0, 0) + +# playback DAI is SSP3 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 7, SSP, 3, NoCodec-3, + PIPELINE_SOURCE_7, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP3 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, NoCodec, - PIPELINE_SINK_2, 2, s24le, + 8, SSP, 3, NoCodec-3, + PIPELINE_SINK_8, 2, s16le, 48, 1000, 0, 0) -# PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +# playback DAI is SSP4 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +#DAI_ADD(sof/pipe-dai-playback.m4, +# 9, SSP, 4, NoCodec, +# PIPELINE_SOURCE_9, 2, s16le, +# 48, 1000, 0, 0) + +# capture DAI is SSP4 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +#DAI_ADD(sof/pipe-dai-capture.m4, +# 10, SSP, 4, NoCodec, +# PIPELINE_SINK_10, 2, s16le, +# 48, 1000, 0, 0) + +# playback DAI is SSP5 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +#DAI_ADD(sof/pipe-dai-playback.m4, +# 11, SSP, 5, NoCodec, +# PIPELINE_SOURCE_11, 2, s16le, +# 48, 1000, 0, 0) + +# capture DAI is SSP5 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +#DAI_ADD(sof/pipe-dai-capture.m4, +# 12, SSP, 5, NoCdec, +# PIPELINE_SINK_12, 2, s16le, +# 48, 1000, 0, 0) + +# PCM Low Latency, id 0 +PCM_DUPLEX_ADD(Port0, 0, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Port1, 1, 1, 1, PIPELINE_PCM_3, PIPELINE_PCM_4) +PCM_DUPLEX_ADD(Port2, 2, 2, 2, PIPELINE_PCM_5, PIPELINE_PCM_6) +PCM_DUPLEX_ADD(Port3, 3, 3, 3, PIPELINE_PCM_7, PIPELINE_PCM_8) +#PCM_DUPLEX_ADD(Port4, 4, 4, 4, PIPELINE_PCM_9, PIPELINE_PCM_10) +#PCM_DUPLEX_ADD(Port5, 5, 5, 5, PIPELINE_PCM_11, PIPELINE_PCM_12) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, NoCodec, - SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), - SSP_CLOCK(bclk, 2400000, codec_slave), + +DAI_CONFIG(SSP, 0, 0, NoCodec-0, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), SSP_CLOCK(fsync, 48000, codec_slave), - SSP_TDM(2, 25, 3, 3), - SSP_CONFIG_DATA(SSP, 2, 24))) + SSP_TDM(2, 16, 3, 3), + SSP_CONFIG_DATA(SSP, 0, 16))) + +DAI_CONFIG(SSP, 1, 1, NoCodec-1, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), + SSP_CONFIG_DATA(SSP, 1, 16))) + +DAI_CONFIG(SSP, 2, 2, NoCodec-2, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), + SSP_CONFIG_DATA(SSP, 2, 16))) + +DAI_CONFIG(SSP, 3, 3, NoCodec-3, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), + SSP_CONFIG_DATA(SSP, 3, 16))) + +#DAI_CONFIG(SSP, 4, 0, NoCodec, +# SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), +# SSP_CLOCK(bclk, 1536000, codec_slave), +# SSP_CLOCK(fsync, 48000, codec_slave), +# SSP_TDM(2, 16, 3, 3), +# SSP_CONFIG_DATA(SSP, 4, 16))) + +#DAI_CONFIG(SSP, 5, 0, NoCodec, +# SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), +# SSP_CLOCK(bclk, 1536000, codec_slave), +# SSP_CLOCK(fsync, 48000, codec_slave), +# SSP_TDM(2, 16, 3, 3), +# SSP_CONFIG_DATA(SSP, 5, 16))) + From 9ac2e32099f5f6409ddf95ddd5ce634bcbaa4e0d Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Mon, 25 Jun 2018 17:32:43 +0800 Subject: [PATCH 192/324] topology: change BE name for NoCodec to support multiple SSPs/BEs Signed-off-by: Keyon Jie --- topology/sof-byt-nocodec.m4 | 6 ++-- topology/sof-cht-nocodec.m4 | 6 ++-- topology/test/test-all.m4 | 2 +- topology/test/test-capture.m4 | 2 +- topology/test/test-playback.m4 | 2 +- topology/test/test-tone-playback.m4 | 2 +- topology/test/tplg-build.sh | 46 ++++++++++++++--------------- 7 files changed, 33 insertions(+), 33 deletions(-) diff --git a/topology/sof-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 index aed2b977a546..2345fa51e140 100644 --- a/topology/sof-byt-nocodec.m4 +++ b/topology/sof-byt-nocodec.m4 @@ -74,14 +74,14 @@ SectionGraph."pipe-byt-nocodec" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, NoCodec, + 1, SSP, 2, NoCodec-2, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, NoCodec, + 2, SSP, 2, NoCodec-2, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) @@ -91,7 +91,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, NoCodec, +DAI_CONFIG(SSP, 2, 0, NoCodec-2, SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), SSP_CLOCK(bclk, 2400000, codec_slave), SSP_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/sof-cht-nocodec.m4 b/topology/sof-cht-nocodec.m4 index 466f56d0c624..23c6ef71ffa8 100644 --- a/topology/sof-cht-nocodec.m4 +++ b/topology/sof-cht-nocodec.m4 @@ -74,14 +74,14 @@ SectionGraph."pipe-cht-nocodec" { # playback DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 2, NoCodec, + 1, SSP, 2, NoCodec-2, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # capture DAI is SSP2 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 2, NoCodec, + 2, SSP, 2, NoCodec-2, PIPELINE_SINK_2, 2, s24le, 48, 1000, 0, 0) @@ -91,7 +91,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, NoCodec, +DAI_CONFIG(SSP, 2, 0, NoCodec-2, SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), SSP_CLOCK(bclk, 2400000, codec_slave), SSP_CLOCK(fsync, 48000, codec_slave), diff --git a/topology/test/test-all.m4 b/topology/test/test-all.m4 index 174f7d2600db..9bd2e0a1fe94 100644 --- a/topology/test/test-all.m4 +++ b/topology/test/test-all.m4 @@ -85,7 +85,7 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # -DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, +DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_PORT, TEST_DAI_LINK_NAME, SSP_CONFIG(TEST_SSP_MODE, SSP_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), SSP_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), diff --git a/topology/test/test-capture.m4 b/topology/test/test-capture.m4 index dd75bf5d9018..67cdbc4f8cca 100644 --- a/topology/test/test-capture.m4 +++ b/topology/test/test-capture.m4 @@ -69,7 +69,7 @@ PCM_CAPTURE_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_2) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # -DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, +DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_PORT, TEST_DAI_LINK_NAME, ifelse(TEST_DAI_TYPE, `SSP', SSP_CONFIG(TEST_SSP_MODE, SSP_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), diff --git a/topology/test/test-playback.m4 b/topology/test/test-playback.m4 index 789c8bb6e28f..7e11798ba133 100644 --- a/topology/test/test-playback.m4 +++ b/topology/test/test-playback.m4 @@ -68,7 +68,7 @@ PCM_PLAYBACK_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # -DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, +DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_PORT, TEST_DAI_LINK_NAME, SSP_CONFIG(TEST_SSP_MODE, SSP_CLOCK(mclk, TEST_SSP_MCLK, codec_slave), SSP_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), diff --git a/topology/test/test-tone-playback.m4 b/topology/test/test-tone-playback.m4 index 9bc3bc829a34..60d5155106b1 100644 --- a/topology/test/test-tone-playback.m4 +++ b/topology/test/test-tone-playback.m4 @@ -60,7 +60,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # -DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, 0, TEST_DAI_LINK_NAME, +DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_PORT, TEST_DAI_LINK_NAME, SSP_CONFIG(TEST_SSP_MODE, SSP_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), SSP_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index 68bc633b3868..ab0183f063fb 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -122,12 +122,12 @@ function simple_test { echo "Preparing topology build input..." # Pre-process the simple tests -simple_test nocodec passthrough "NoCodec" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec passthrough "NoCodec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s16le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec src "NoCodec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec-2" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s16le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec src "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] simple_test codec passthrough "SSP2-Codec" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] simple_test codec passthrough "SSP2-Codec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] @@ -151,18 +151,18 @@ do do for format in ${APL_FORMAT_TESTS[@]} do - simple_test nocodec $mode "NoCodec" $format SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec $mode "NoCodec" $format SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec $mode "NoCodec" $format SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] done done - simple_test nocodec passthrough "NoCodec" s16le SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec passthrough "NoCodec" s24le SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec passthrough "NoCodec" s32le SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec-${ssp}" s16le SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec-${ssp}" s24le SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec-${ssp}" s32le SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] simple_test codec passthrough "SSP${ssp}-Codec" s16le SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] simple_test codec passthrough "SSP${ssp}-Codec" s24le SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] @@ -178,15 +178,15 @@ do do for format in ${APL_FORMAT_TESTS[@]} do - simple_test nocodec $mode "NoCodec" $format SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] - simple_test nocodec $mode "NoCodec" $format SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] done done - simple_test nocodec passthrough "NoCodec" s16le SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] - simple_test nocodec passthrough "NoCodec" s24le SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec-${ssp}" s16le SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec-${ssp}" s24le SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] simple_test codec passthrough "SSP${ssp}-Codec" s16le SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] simple_test codec passthrough "SSP${ssp}-Codec" s24le SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] @@ -194,13 +194,13 @@ do done # for CNL -simple_test nocodec passthrough "NoCodec" s16le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec passthrough "NoCodec" s24le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s16le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s16le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s24le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec" s24le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec src "NoCodec" s24le SSP 4 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec-2" s16le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s16le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s16le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s24le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec src "NoCodec-4" s24le SSP 4 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] # Tone test: Tone component only supports s32le currently simple_test codec tone "SSP2-Codec" s32le SSP 2 s16le 20 16 1920000 19200000 I2S TONE_TEST[@] From 71dff859e346a7e07427397999094382a5ea8d7e Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Tue, 26 Jun 2018 10:30:12 -0700 Subject: [PATCH 193/324] topology: add test topologies with mclk id 1 Add some test topologies with mclk id 1 Signed-off-by: Ranjani Sridharan --- topology/test/test-all.m4 | 2 +- topology/test/test-capture.m4 | 2 +- topology/test/test-playback.m4 | 2 +- topology/test/test-tone-playback.m4 | 2 +- topology/test/tplg-build.sh | 114 +++++++++++++++------------- 5 files changed, 66 insertions(+), 56 deletions(-) diff --git a/topology/test/test-all.m4 b/topology/test/test-all.m4 index 9bd2e0a1fe94..8f9747c3ecf5 100644 --- a/topology/test/test-all.m4 +++ b/topology/test/test-all.m4 @@ -92,4 +92,4 @@ DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_PORT, TEST_DAI_LINK_NAME, SSP_CLOCK(fsync, 48000, codec_slave), SSP_TDM(2, TEST_SSP_PHY_BITS, 3, 3), SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, - TEST_SSP_DATA_BITS))) + TEST_SSP_DATA_BITS, TEST_SSP_MCLK_ID))) diff --git a/topology/test/test-capture.m4 b/topology/test/test-capture.m4 index 67cdbc4f8cca..ef47e35b3c27 100644 --- a/topology/test/test-capture.m4 +++ b/topology/test/test-capture.m4 @@ -77,7 +77,7 @@ DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_PORT, TEST_DAI_LINK_NAME, SSP_CLOCK(fsync, 48000, codec_slave), SSP_TDM(2, TEST_SSP_PHY_BITS, 3, 3), SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, - TEST_SSP_DATA_BITS)), + TEST_SSP_DATA_BITS, TEST_SSP_MCLK_ID)), TEST_DAI_TYPE, `DMIC', DMIC_CONFIG(TEST_DMIC_DRIVER_VERSION,TEST_DMIC_CLK_MIN, TEST_DMIC_CLK_MAX, TEST_DMIC_DUTY_MIN, diff --git a/topology/test/test-playback.m4 b/topology/test/test-playback.m4 index 7e11798ba133..1c6f7126d160 100644 --- a/topology/test/test-playback.m4 +++ b/topology/test/test-playback.m4 @@ -75,4 +75,4 @@ DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_PORT, TEST_DAI_LINK_NAME, SSP_CLOCK(fsync, 48000, codec_slave), SSP_TDM(2, TEST_SSP_PHY_BITS, 3, 3), SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, - TEST_SSP_DATA_BITS))) + TEST_SSP_DATA_BITS, TEST_SSP_MCLK_ID))) diff --git a/topology/test/test-tone-playback.m4 b/topology/test/test-tone-playback.m4 index 60d5155106b1..77db4d1d84bf 100644 --- a/topology/test/test-tone-playback.m4 +++ b/topology/test/test-tone-playback.m4 @@ -67,4 +67,4 @@ DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_PORT, TEST_DAI_LINK_NAME, SSP_CLOCK(fsync, 48000, codec_slave), SSP_TDM(2, TEST_SSP_PHY_BITS, 3, 3), SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, - TEST_SSP_DATA_BITS))) + TEST_SSP_DATA_BITS, TEST_SSP_MCLK_ID))) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index ab0183f063fb..f324a086ad6f 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -31,12 +31,14 @@ M4_STRINGS="" # 9) dai_bclk - SSP BCLK in HZ # 10) dai_mclk - SSP MCLK in HZ # 11) SSP mode - SSP mode e.g. I2S, LEFT_J, DSP_A and DSP_B +# 12) SSP mclk_id +# 13) Test pipelines # function simple_test { if [ $5 == "SSP" ] then - TESTS=("${!13}") + TESTS=("${!14}") elif [ $5 == "DMIC" ] then TESTS=("${!15}") @@ -72,9 +74,9 @@ function simple_test { then if [ $i == "test-all" ] then - TFILE="test-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" + TFILE="test-ssp$6-mclk-${13}-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" else - TFILE="$i-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" + TFILE="$i-ssp$6-mclk-${13}-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" fi #create input string for batch m4 processing M4_STRINGS+="-DTEST_PIPE_NAME=$2,-DTEST_DAI_LINK_NAME=$3\ @@ -82,7 +84,7 @@ function simple_test { -DTEST_PIPE_FORMAT=$4,-DTEST_SSP_BCLK=${10}\ -DTEST_SSP_MCLK=${11},-DTEST_SSP_PHY_BITS=$8\ -DTEST_SSP_DATA_BITS=$9,-DTEST_SSP_MODE=${12}\ - -DTEST_DAI_TYPE=$5\ + -DTEST_SSP_MCLK_ID=${13},-DTEST_DAI_TYPE=$5\ $i.m4,${TFILE}," #create input string for batch processing of conf files TEST_STRINGS+=${TFILE}"," @@ -93,9 +95,9 @@ function simple_test { then if [ $i == "test-all" ] then - TFILE="test-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" + TFILE="test-ssp$6-mclk-${13}-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" else - TFILE="$i-ssp$6-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" + TFILE="$i-ssp$6-mclk-${13}-${12}-$2-$4-$7-48k-$((${11} / 1000))k-$1" fi echo "M4 pre-processing test $i -> ${TFILE}" m4 ${M4_FLAGS} \ @@ -109,6 +111,7 @@ function simple_test { -DTEST_SSP_PHY_BITS=$8 \ -DTEST_SSP_DATA_BITS=$9 \ -DTEST_SSP_MODE=${12} \ + -DTEST_SSP_MCLK_ID=${13} \ -DTEST_DAI_TYPE=$5 \ $i.m4 > ${TFILE}.conf echo "Compiling test $i -> ${TFILE}.tplg" @@ -122,26 +125,27 @@ function simple_test { echo "Preparing topology build input..." # Pre-process the simple tests -simple_test nocodec passthrough "NoCodec-2" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec passthrough "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec-2" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec-2" s16le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test nocodec src "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] - -simple_test codec passthrough "SSP2-Codec" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec passthrough "SSP2-Codec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec volume "SSP2-Codec" s16le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec volume "SSP2-Codec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec volume "SSP2-Codec" s24le SSP 2 s16le 20 16 1920000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec volume "SSP2-Codec" s16le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] -simple_test codec src "SSP2-Codec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec-2" s16le SSP 2 s16le 20 16 1920000 19200000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 19200000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s16le SSP 2 s16le 20 16 1920000 19200000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 19200000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s16le SSP 2 s24le 25 24 2400000 19200000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec src "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 19200000 I2S 0 SIMPLE_TESTS[@] + +simple_test codec passthrough "SSP2-Codec" s16le SSP 2 s16le 20 16 1920000 19200000 I2S 0 SIMPLE_TESTS[@] +simple_test codec passthrough "SSP2-Codec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S 0 SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s16le SSP 2 s16le 20 16 1920000 19200000 I2S 0 SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S 0 SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s24le SSP 2 s16le 20 16 1920000 19200000 I2S 0 SIMPLE_TESTS[@] +simple_test codec volume "SSP2-Codec" s16le SSP 2 s24le 25 24 2400000 19200000 I2S 0 SIMPLE_TESTS[@] +simple_test codec src "SSP2-Codec" s24le SSP 2 s24le 25 24 2400000 19200000 I2S 0 SIMPLE_TESTS[@] # for APL APL_PROTOCOL_TESTS=(I2S LEFT_J DSP_A DSP_B) APL_SSP_TESTS=(0 1 2 3 4 5) APL_MODE_TESTS=(volume src) APL_FORMAT_TESTS=(s16le s24le s32le) +MCLK_IDS=(0 1) for protocol in ${APL_PROTOCOL_TESTS[@]} do @@ -151,22 +155,28 @@ do do for format in ${APL_FORMAT_TESTS[@]} do - simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] - - simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] + for mclk_id in ${MCLK_IDS[@]} + do + simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s16le 16 16 1536000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s24le 32 24 3072000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s32le 32 32 3072000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] + + simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s16le 16 16 1536000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s24le 32 24 3072000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s32le 32 32 3072000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] + done done done - simple_test nocodec passthrough "NoCodec-${ssp}" s16le SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec passthrough "NoCodec-${ssp}" s24le SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test nocodec passthrough "NoCodec-${ssp}" s32le SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] + for mclk_id in ${MCLK_IDS[@]} + do + simple_test nocodec passthrough "NoCodec-${ssp}" s16le SSP $ssp s16le 16 16 1536000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec-${ssp}" s24le SSP $ssp s24le 32 24 3072000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec-${ssp}" s32le SSP $ssp s32le 32 32 3072000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s16le SSP $ssp s16le 16 16 1536000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s24le SSP $ssp s24le 32 24 3072000 24576000 $protocol SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s32le SSP $ssp s32le 32 32 3072000 24576000 $protocol SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s16le SSP $ssp s16le 16 16 1536000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s24le SSP $ssp s24le 32 24 3072000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s32le SSP $ssp s32le 32 32 3072000 24576000 $protocol $mclk_id SIMPLE_TESTS[@] + done done done @@ -178,35 +188,35 @@ do do for format in ${APL_FORMAT_TESTS[@]} do - simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] - simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s16le 20 16 1920000 19200000 $protocol 0 SIMPLE_TESTS[@] + simple_test nocodec $mode "NoCodec-${ssp}" $format SSP $ssp s24le 25 24 2400000 19200000 $protocol 0 SIMPLE_TESTS[@] - simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] - simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s16le 20 16 1920000 19200000 $protocol 0 SIMPLE_TESTS[@] + simple_test codec $mode "SSP${ssp}-Codec" $format SSP $ssp s24le 25 24 2400000 19200000 $protocol 0 SIMPLE_TESTS[@] done done - simple_test nocodec passthrough "NoCodec-${ssp}" s16le SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] - simple_test nocodec passthrough "NoCodec-${ssp}" s24le SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec-${ssp}" s16le SSP $ssp s16le 20 16 1920000 19200000 $protocol 0 SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec-${ssp}" s24le SSP $ssp s24le 25 24 2400000 19200000 $protocol 0 SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s16le SSP $ssp s16le 20 16 1920000 19200000 $protocol SIMPLE_TESTS[@] - simple_test codec passthrough "SSP${ssp}-Codec" s24le SSP $ssp s24le 25 24 2400000 19200000 $protocol SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s16le SSP $ssp s16le 20 16 1920000 19200000 $protocol 0 SIMPLE_TESTS[@] + simple_test codec passthrough "SSP${ssp}-Codec" s24le SSP $ssp s24le 25 24 2400000 19200000 $protocol 0 SIMPLE_TESTS[@] done done # for CNL -simple_test nocodec passthrough "NoCodec-2" s16le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec passthrough "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec-2" s16le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec-2" s16le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec volume "NoCodec-2" s24le SSP 2 s16le 25 16 2400000 24000000 I2S SIMPLE_TESTS[@] -simple_test nocodec src "NoCodec-4" s24le SSP 4 s24le 25 24 2400000 24000000 I2S SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec-2" s16le SSP 2 s16le 25 16 2400000 24000000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 24000000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s16le SSP 2 s16le 25 16 2400000 24000000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s16le SSP 2 s24le 25 24 2400000 24000000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 24000000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-2" s24le SSP 2 s16le 25 16 2400000 24000000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec src "NoCodec-4" s24le SSP 4 s24le 25 24 2400000 24000000 I2S 0 SIMPLE_TESTS[@] # Tone test: Tone component only supports s32le currently -simple_test codec tone "SSP2-Codec" s32le SSP 2 s16le 20 16 1920000 19200000 I2S TONE_TEST[@] +simple_test codec tone "SSP2-Codec" s32le SSP 2 s16le 20 16 1920000 19200000 I2S 0 TONE_TEST[@] #Tone Test for APL -simple_test codec tone "SSP5-Codec" s32le SSP 5 s24le 32 24 3072000 24576000 I2S TONE_TEST[@] -simple_test codec tone "SSP5-Codec" s32le SSP 5 s32le 32 32 3072000 24576000 I2S TONE_TEST[@] +simple_test codec tone "SSP5-Codec" s32le SSP 5 s24le 32 24 3072000 24576000 I2S 0 TONE_TEST[@] +simple_test codec tone "SSP5-Codec" s32le SSP 5 s32le 32 32 3072000 24576000 I2S 0 TONE_TEST[@] #DMIC Test simple_test nocodec passthrough "DMIC0" s32le DMIC 0 s32le 1 500000 4800000\ @@ -217,7 +227,7 @@ then echo "Batch processing m4 files..." M4_STRINGS=${M4_STRINGS%?} #m4 processing - echo $M4_STRINGS | tr " " "," | tr '\n' '\0' | xargs -P0 -d ',' -n13 bash -c 'm4 "${@:1:${#}-1}" > ${13}.conf' m4 + echo $M4_STRINGS | tr " " "," | tr '\n' '\0' | xargs -P0 -d ',' -n14 bash -c 'm4 "${@:1:${#}-1}" > ${14}.conf' m4 #execute alsatplg to create topology binary TEST_STRINGS=${TEST_STRINGS%?} From 82996c24a52cc5993953d3f88e56924f89766480 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Tue, 26 Jun 2018 11:35:22 -0700 Subject: [PATCH 194/324] topology: add pre-defined PDM controller configs Add some pre-defined PDM controller configs that sets the number of active controllers and the corresponding pdm tuples. Signed-off-by: Ranjani Sridharan --- topology/platform/intel/dmic.m4 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/topology/platform/intel/dmic.m4 b/topology/platform/intel/dmic.m4 index 393c3a08bde0..d7898b4d11d5 100644 --- a/topology/platform/intel/dmic.m4 +++ b/topology/platform/intel/dmic.m4 @@ -57,4 +57,13 @@ $11 `}' ) +dnl DMIC PDM configurations +dnl macros to get the number of active pdm's and their config +define(`MONO_PDM0_MICA', `1, LIST(`', PDM_TUPLES(0, 1, 0, 0, 0, 0, 0))') +define(`MONO_PDM0_MICB', `1, LIST(`', PDM_TUPLES(0, 0, 1, 0, 0, 0, 0))') +define(`STEREO_PDM0', `1, LIST(`', PDM_TUPLES(0, 1, 1, 0, 0, 0, 0))') +define(`STEREO_PDM1', `1, LIST(`', PDM_TUPLES(1, 1, 1, 0, 0, 0, 0))') +define(`FOUR_CH_PDM0_PDM1', + `2, LIST(`', PDM_TUPLES(0, 1, 1, 0, 0, 0, 0), PDM_TUPLES(1, 1, 1, 0, 0, 0, 0))') + divert(0)dnl From ddbd2d655faa936bfaa9340b18a9f0e08a373e21 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 25 Jun 2018 22:17:03 -0700 Subject: [PATCH 195/324] topology: add more dmic test topologies This patch modifies the test topology generator to add dmic topologies with pre-defined PDM controller configurations, sample rates and formats. It also modifies the DMIC_CONFIG macro to get the number of active pdm from the pdm config. Signed-off-by: Ranjani Sridharan --- topology/platform/intel/dmic.m4 | 28 ++++++++++++++-------------- topology/test/test-capture.m4 | 8 ++++---- topology/test/tplg-build.sh | 26 ++++++++++++++++++++------ 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/topology/platform/intel/dmic.m4 b/topology/platform/intel/dmic.m4 index d7898b4d11d5..7a93069ee81e 100644 --- a/topology/platform/intel/dmic.m4 +++ b/topology/platform/intel/dmic.m4 @@ -16,11 +16,14 @@ define(`PDM_TUPLES', ` }' ) -dnl PDM_CONFIG(type, idx, pdm tuples list) +dnl PDM_CONFIG(type, idx, num pdm active, pdm tuples list) define(`PDM_CONFIG', +` SOF_TKN_INTEL_DMIC_NUM_PDM_ACTIVE' STR($3) +` }' +`}' `SectionVendorTuples."'N_DAI_CONFIG($1$2)`_pdm_tuples" {' ` tokens "sof_dmic_pdm_tokens"' -$3 +$4 `}' ) @@ -30,10 +33,10 @@ define(`DMIC_WORD_LENGTH', `ifelse($1, `s16le', 16, $1, `s32le', 32, `')') dnl DMIC_CONFIG(driver_version, clk_min, clk_mac, duty_min, duty_max, -dnl req pdm count, sample_rate, +dnl sample_rate, dnl fifo word length, type, idx, pdm controller config) define(`DMIC_CONFIG', -`SectionVendorTuples."'N_DAI_CONFIG($9$10)`_dmic_tuples" {' +`SectionVendorTuples."'N_DAI_CONFIG($8$9)`_dmic_tuples" {' ` tokens "sof_dmic_tokens"' ` tuples."word" {' ` SOF_TKN_INTEL_DMIC_DRIVER_VERSION' STR($1) @@ -41,18 +44,15 @@ define(`DMIC_CONFIG', ` SOF_TKN_INTEL_DMIC_CLK_MAX' STR($3) ` SOF_TKN_INTEL_DMIC_DUTY_MIN' STR($4) ` SOF_TKN_INTEL_DMIC_DUTY_MAX' STR($5) -` SOF_TKN_INTEL_DMIC_NUM_PDM_ACTIVE' STR($6) -` SOF_TKN_INTEL_DMIC_SAMPLE_RATE' STR($7) -` SOF_TKN_INTEL_DMIC_FIFO_WORD_LENGTH' STR($8) -` }' -`}' +` SOF_TKN_INTEL_DMIC_SAMPLE_RATE' STR($6) +` SOF_TKN_INTEL_DMIC_FIFO_WORD_LENGTH' STR($7) dnl PDM config for the number of active PDM controllers -$11 -`SectionData."'N_DAI_CONFIG($9$10)`_pdm_data" {' -` tuples "'N_DAI_CONFIG($9$10)`_pdm_tuples"' +$10 +`SectionData."'N_DAI_CONFIG($8$9)`_pdm_data" {' +` tuples "'N_DAI_CONFIG($8$9)`_pdm_tuples"' `}' -`SectionData."'N_DAI_CONFIG($9$10)`_data" {' -` tuples "'N_DAI_CONFIG($9$10)`_dmic_tuples"' +`SectionData."'N_DAI_CONFIG($8$9)`_data" {' +` tuples "'N_DAI_CONFIG($8$9)`_dmic_tuples"' `}' ) diff --git a/topology/test/test-capture.m4 b/topology/test/test-capture.m4 index ef47e35b3c27..1102c415e8e1 100644 --- a/topology/test/test-capture.m4 +++ b/topology/test/test-capture.m4 @@ -79,11 +79,11 @@ DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_PORT, TEST_DAI_LINK_NAME, SSP_CONFIG_DATA(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_SSP_DATA_BITS, TEST_SSP_MCLK_ID)), TEST_DAI_TYPE, `DMIC', - DMIC_CONFIG(TEST_DMIC_DRIVER_VERSION,TEST_DMIC_CLK_MIN, + DMIC_CONFIG(TEST_DMIC_DRIVER_VERSION, TEST_DMIC_CLK_MIN, TEST_DMIC_CLK_MAX, TEST_DMIC_DUTY_MIN, - TEST_DMIC_DUTY_MAX, TEST_PDM_ACTIVE, - TEST_DMIC_SAMPLE_RATE, DMIC_WORD_LENGTH(TEST_DAI_FORMAT), + TEST_DMIC_DUTY_MAX, TEST_DMIC_SAMPLE_RATE, + DMIC_WORD_LENGTH(TEST_DAI_FORMAT), TEST_DAI_TYPE, TEST_DAI_PORT, PDM_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, - LIST(`', PDM_TUPLES(0, 1, 1, 0, 0, 0, 0)))), + TEST_DMIC_PDM_CONFIG)), `')) diff --git a/topology/test/tplg-build.sh b/topology/test/tplg-build.sh index f324a086ad6f..bd505930d1fc 100755 --- a/topology/test/tplg-build.sh +++ b/topology/test/tplg-build.sh @@ -47,7 +47,7 @@ function simple_test { do if [ $5 == "DMIC" ] then - TFILE="$i-dmic$6-$2-$4-$7-48k-$1" + TFILE="$i-dmic$6-${14}-$2-$4-$7-$((${13} / 1000))k-$1" echo "M4 pre-processing test $i -> ${TFILE}" m4 ${M4_FLAGS} \ -DTEST_PIPE_NAME="$2" \ @@ -61,8 +61,8 @@ function simple_test { -DTEST_DMIC_CLK_MAX=${10} \ -DTEST_DMIC_DUTY_MIN=${11} \ -DTEST_DMIC_DUTY_MAX=${12} \ - -DTEST_PDM_ACTIVE=${13} \ - -DTEST_DMIC_SAMPLE_RATE=${14} \ + -DTEST_DMIC_SAMPLE_RATE=${13} \ + -DTEST_DMIC_PDM_CONFIG=${14} \ $i.m4 > ${TFILE}.conf echo "Compiling test $i -> ${TFILE}.tplg" alsatplg -v 1 -c ${TFILE}.conf -o ${TFILE}.tplg @@ -218,9 +218,23 @@ simple_test codec tone "SSP2-Codec" s32le SSP 2 s16le 20 16 1920000 19200000 I2S simple_test codec tone "SSP5-Codec" s32le SSP 5 s24le 32 24 3072000 24576000 I2S 0 TONE_TEST[@] simple_test codec tone "SSP5-Codec" s32le SSP 5 s32le 32 32 3072000 24576000 I2S 0 TONE_TEST[@] -#DMIC Test -simple_test nocodec passthrough "DMIC0" s32le DMIC 0 s32le 1 500000 4800000\ - 40 60 1 48000 DMIC_TEST[@] +# DMIC Test Topologies for APL/GLK +DMIC_PDM_CONFIGS=(MONO_PDM0_MICA MONO_PDM0_MICB STEREO_PDM0 STEREO_PDM1 FOUR_CH_PDM0_PDM1) +DMIC_SAMPLE_RATE=(8000 16000 24000 32000 48000 64000 96000) +DMIC_SAMPLE_FORMATS=(s16le s32le) + +for pdm in ${DMIC_PDM_CONFIGS[@]} +do + for rate in ${DMIC_SAMPLE_RATE[@]} + do + for format in ${DMIC_SAMPLE_FORMATS[@]} + do + simple_test nocodec passthrough "DMIC0" $format DMIC 0\ + $format 1 500000 4800000 40 60 $rate $pdm\ + DMIC_TEST[@] + done + done +done if [ "$USE_XARGS" == "yes" ] then From aa3e72400c26a4195a251dde09e82c88cff20e47 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 27 Jun 2018 13:48:07 +0300 Subject: [PATCH 196/324] SOFT: Add SRC component test scripts This patch provides tests for sample rate converter (SRC) SOF component. The tests are executed via the SOF host (x86) version test executable and the SRC component library. Signed-off-by: Seppo Ingalsuo --- test/README | 64 +++++ test/src_run.sh | 39 +++ test/src_test.m | 607 ++++++++++++++++++++++++++++++++++++++++++++ test/src_test.sh | 39 +++ test/src_test_top.m | 42 +++ 5 files changed, 791 insertions(+) create mode 100644 test/README create mode 100755 test/src_run.sh create mode 100644 test/src_test.m create mode 100755 test/src_test.sh create mode 100644 test/src_test_top.m diff --git a/test/README b/test/README new file mode 100644 index 000000000000..488005a190a0 --- /dev/null +++ b/test/README @@ -0,0 +1,64 @@ +SOF Audio Processing Components Tests +===================================== + +This is a set of test scripts to test that performance requirements +are met. The tests are currently for measured audio objective quality +parameters. The used criteria for performance is only an initial +assumption and need to be adjusted for various applications needs. + +The scripts support currently support the next list of objective +quality parameters. The test scripts need Matlab(R) [2] or GNU Octave +scientific programming language [3]. + + - Gain + - Frequency Response + - THD+N vs. Frequency + - Dynamic Range + - Attenuation of Alias Products + - Attenuation of Image Products + +Note: The metric is an effort to follow AES17 [1] recommendation for +parameters and test procedures. This was created to help developers to +quickly check their work but has not been verified to be +compliant. Professional equipment and formal calibration process is +recommended for professional applications where both accurate absolute +and relative metric is needed. + +Note: The test bench uses by default raw binary data files. It is +possible to convert with SoX (v14.4.1) [4] the raw data to e.g. wav +format for other audio tools and subjective listening. + +$ sox -b 32 -c 2 -r 48000 -L -e signed-integer fr_test_out.raw fr_test_out.wav + +For debugging purposes it is possible to switch from test scripts the +test vectors format to txt for easy manual data creation and +inspection. + + +Tests for component SRC +----------------------- + +The top level shell script to launch tests is src_test.sh. See script +src_run.sh for assumed install location of SOF host test bench +executable and component libraries. Exit code 0 indicates success and +exit code 1 indicates failed test cases. + +The default in/out rates matrix to test is defined in the beginning of +script src_test.m. The matrix can be also passed from calling function +src_test_top.m if need. + +The key objective quality parameters requiremements are in the +beginning of script src_test.m as well under comment Generic test +pass/fail criteria. + +Test run creates plots into directory "plots". Brief text format +reports are placed to directory "reports". + + +References +---------- + +[1] AES17-1015 standard, http://www.aes.org/publications/standards/search.cfm?docID=21 +[2] Matlab(R), https://www.mathworks.com/products/matlab.html +[3] GNU Octave, https://www.gnu.org/software/octave/ +[4] SoX - Sound eXchange, http://sox.sourceforge.net/ diff --git a/test/src_run.sh b/test/src_run.sh new file mode 100755 index 000000000000..632de859dca2 --- /dev/null +++ b/test/src_run.sh @@ -0,0 +1,39 @@ +#!/bin/bash + +# SRC specifics +COMP=src +BITS_IN=$1 +BITS_OUT=$2 +FS1=$3 +FS2=$4 +FN_IN=$5 +FN_OUT=$6 + +# The HOST_ROOT path need to be retrived from SOFT .configure command +HOST_ROOT=../../host-root +HOST_EXE=$HOST_ROOT/bin/testbench +HOST_LIB=$HOST_ROOT/lib + +# Topology +INFMT=s${BITS_IN}le +OUTFMT=s${BITS_IN}le +MCLK=24576k +TPLG=../topology/test/test-playback-ssp2-I2S-${COMP}-${INFMT}-${OUTFMT}-48k-${MCLK}-nocodec.tplg + +# If binary test vectors +if [ ${FN_IN: -4} == ".raw" ]; then + CMDFMT="-b S${BITS_IN}_LE" +else + CMDFMT="" +fi + +# Run command +CMD0=$HOST_EXE +CMD1="-d -x $FS1 -y $FS2 -i $FN_IN -o $FN_OUT -t $TPLG -a src=libsof_${COMP}.so $CMDFMT" +CMD="$CMD0 $CMD1" +export LD_LIBRARY_PATH=$HOST_LIB + +# Run test bench +echo "Command: $CMD0" +echo "Arg: $CMD1" +$CMD diff --git a/test/src_test.m b/test/src_test.m new file mode 100644 index 000000000000..91251ebd6305 --- /dev/null +++ b/test/src_test.m @@ -0,0 +1,607 @@ +function [n_fail, n_pass, n_na] = src_test(bits_in, bits_out, fs_in_list, fs_out_list) + +%% +% src_test - test with SRC test bench objective audio quality parameters +% +% src_test(fs_in, fs_out) +% +% bits_in - input word length +% bits_out - output word length +% fs_in - vector of rates in +% fs_out - vector of rates out +% +% A default in-out matrix with 32 bits data is tested if the +% paremeters are omitted. +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +addpath('std_utils'); +addpath('test_utils'); +addpath('../tune/src'); +mkdir_check('plots'); +mkdir_check('reports'); + +%% Defaults for call parameters +if nargin < 1 + bits_in = 32; +end +if nargin < 2 + bits_out = 32; +end +if nargin < 3 + fs_in_list = [8e3 11025 12e3 16e3 18900 22050 24e3 32e3 44100 48e3 ... + 64e3 88.2e3 96e3 176400 192e3]; +end +if nargin < 4 + fs_out_list = [8e3 11025 12e3 16e3 18900 22050 24e3 32e3 44100 48e3]; +end + +%% Generic test pass/fail criteria +% Note that AAP and AIP are relaxed a bit from THD+N due to inclusion +% of point Fs/2 to test. The stopband of kaiser FIR is not equiripple +% and there's sufficient amount of attnuation at higher frequencies to +% meet THD+N requirement. +t.g_db_tol = 0.1; +t.thdnf_db_max = -80; +t.dr_db_min = 100; +t.aap_db_max = -60; +t.aip_db_max = -60; + +%% Defaults for test +t.fmt = 'raw'; % Can be 'raw' (fast binary) or 'txt' (debug) +t.nch = 2; % Number of channels +t.ch = 0; % 1..nch. With value 0 test a randomly selected channel. +t.bits_in = bits_in; % Input word length +t.bits_out = bits_out; % Output word length +t.full_test = 1; % 0 is quick check only, 1 is full set + +%% Show graphics or not. With visible plot windows Octave may freeze if too +% many windows are kept open. As workaround setting close windows to +% 1 shows only flashing windows while the test proceeds. With +% visibility set to to 0 only console text is seen. The plots are +% exported into plots directory in png format and can be viewed from +% there. +t.close_plot_windows = 0; % Workaround for visible windows if Octave hangs +t.visible = 'off'; % Use off for batch tests and on for interactive +t.delete = 1; % Set to 0 to inspect the audio data files + +%% Init for test loop +n_test = 7; % We have next seven test cases for SRC +n_fsi = length(fs_in_list); +n_fso = length(fs_out_list); +r.fs_in_list = fs_in_list; +r.fs_out_list = fs_out_list; +r.g = NaN(n_fsi, n_fso); +r.dr = NaN(n_fsi, n_fso); +r.fr_db = NaN(n_fsi, n_fso); +r.fr_hz = NaN(n_fsi, n_fso, 2); +r.fr3db_hz = NaN(n_fsi, n_fso); +r.thdnf = NaN(n_fsi, n_fso); +r.aap = NaN(n_fsi, n_fso); +r.aip = NaN(n_fsi, n_fso); +r.pf = NaN(n_fsi, n_fso, n_test); +r.n_fail = 0; +r.n_pass = 0; +r.n_skipped = 0; +r.n_na = 0; +%% Loop all modes to test +for b = 1:n_fso + for a = 1:n_fsi + v = -ones(n_test,1); % Set pass/fail test verdict to not executed + tn = 1; + t.fs1 = fs_in_list(a); + t.fs2 = fs_out_list(b); + v(1) = chirp_test(t); + if v(1) ~= -1 && t.full_test == 1 + %% Chirp was processed so this in/out Fs is supported + [v(2), r.g(a,b)] = g_test(t); + [v(3), r.fr_db(a,b), r.fr_hz(a,b,:), r.fr3db_hz(a,b)] = fr_test(t); + [v(4), r.thdnf(a,b)] = thdnf_test(t); + [v(5), r.dr(a,b)] = dr_test(t); + [v(6), r.aap(a,b)] = aap_test(t); + [v(7), r.aip(a,b)] = aip_test(t); + end + %% Done, store pass/fail + r.pf(a, b, :) = v; + if v(1) ~= -1 + idx = find(v > 0); + r.n_fail = r.n_fail + length(idx); + idx = find(v == 0); + r.n_pass = r.n_pass + length(idx); + idx = find(v == -1); + r.n_skipped = r.n_skipped + length(idx); + idx = find(v == -2); + r.n_na = r.n_na + length(idx); + end + end +end + +%% Print table with test summary: Gain +fn = 'reports/g_src.txt'; +print_val(fn, fs_in_list, fs_out_list, r.g, r.pf, 'Gain dB'); + +%% Print table with test summary: FR +fn = 'reports/fr_src.txt'; +print_fr(fn, fs_in_list, fs_out_list, r.fr_db, r.fr_hz, r.pf); + +%% Print table with test summary: FR +fn = 'reports/fr_src.txt'; +print_val(fn, fs_in_list, fs_out_list, r.fr3db_hz/1e3, r.pf, ... + 'Frequency response -3 dB 0 - X kHz'); + +%% Print table with test summary: THD+N vs. frequency +fn = 'reports/thdnf_src.txt'; +print_val(fn, fs_in_list, fs_out_list, r.thdnf, r.pf, ... + 'Worst-case THD+N vs. frequency'); + +%% Print table with test summary: DR +fn = 'reports/dr_src.txt'; +print_val(fn, fs_in_list, fs_out_list, r.dr, r.pf, ... + 'Dynamic range dB (CCIR-RMS)'); + +%% Print table with test summary: AAP +fn = 'reports/aap_src.txt'; +print_val(fn, fs_in_list, fs_out_list, r.aap, r.pf, ... + 'Attenuation of alias products dB'); + +%% Print table with test summary: AIP +fn = 'reports/aip_src.txt'; +print_val(fn, fs_in_list, fs_out_list, r.aip, r.pf, ... + 'Attenuation of image products dB'); + + +%% Print table with test summary: pass/fail +fn = 'reports/pf_src.txt'; +print_pf(fn, fs_in_list, fs_out_list, r.pf); + +fprintf('\n'); +fprintf('Number of passed tests = %d\n', r.n_pass); +fprintf('Number of failed tests = %d\n', r.n_fail); +fprintf('Number of non-applicable tests = %d\n', r.n_na); +fprintf('Number of skipped tests = %d\n', r.n_skipped); + + +if r.n_fail > 0 || r.n_pass < 1 + fprintf('\nERROR: TEST FAILED!!!\n'); +else + fprintf('\nTest passed.\n'); +end + +n_fail = r.n_fail; +n_pass = r.n_pass; +n_na = r.n_na; + +end + + +%% +%% Test execution with help of common functions +%% + +function [fail, g_db] = g_test(t) + +%% Reference: AES17 6.2.2 Gain +test = test_defaults_src(t); +prm = src_param(t.fs1, t.fs2, test.coef_bits); +test.fu = prm.c_pb*min(t.fs1,t.fs2); +test.g_db_tol = t.g_db_tol; +test.g_db_expect = 0; + +%% Create input file +test = g_test_input(test); + +%% Run test +test = test_run_src(test, t); + +%% Measure +test.fs = t.fs2; +test = g_test_measure(test); + +%% Get output parameters +fail = test.fail; +g_db = test.g_db; +delete_check(t.delete, test.fn_in); +delete_check(t.delete, test.fn_out); + +end + +function [fail, pm_range_db, range_hz, fr3db_hz] = fr_test(t) + +%% Reference: AES17 6.2.3 Frequency response +test = test_defaults_src(t); +prm = src_param(t.fs1, t.fs2, test.coef_bits); + +test.rp_max = prm.rp_tot; % Max. ripple +/- dB allowed +test.f_lo = 20; % For response reporting, measure from 20 Hz +test.f_hi = min(t.fs1,t.fs2)*prm.c_pb; % to designed filter upper frequency +test.f_max = min(t.fs1/2, t.fs2/2); % Measure up to Nyquist frequency + +%% Create input file +test = fr_test_input(test); + +%% Run test +test = test_run_src(test, t); + +%% Measure +test.fs = t.fs2; +test = fr_test_measure(test); + +fail = test.fail; +pm_range_db = test.rp; +range_hz = [test.f_lo test.f_hi]; +fr3db_hz = test.fr3db_hz; +delete_check(t.delete, test.fn_in); +delete_check(t.delete, test.fn_out); + +%% Print +src_test_result_print(t, 'Frequency response', 'FR', test.ph); + +end + +function [fail, thdnf] = thdnf_test(t) + +%% Reference: AES17 6.3.2 THD+N ratio vs. frequency +test = test_defaults_src(t); + +prm = src_param(t.fs1, t.fs2, test.coef_bits); +test.f_start = 20; +test.f_end = prm.c_pb*min(t.fs1, t.fs2); +test.fu = prm.c_pb*min(t.fs1, t.fs2); +%test.f_end = 0.4535*min(t.fs1, t.fs2); +%test.fu = 0.4535*min(t.fs1, t.fs2); + +%% Create input file +test = thdnf_test_input(test); + +%% Run test +test = test_run_src(test, t); + +%% Measure +test.fs = t.fs2; +test.thdnf_max = t.thdnf_db_max; +test = thdnf_test_measure(test); +thdnf = max(max(test.thdnf)); +fail = test.fail; +delete_check(t.delete, test.fn_in); +delete_check(t.delete, test.fn_out); + +%% Print +src_test_result_print(t, 'THD+N ratio vs. frequency', 'THDNF'); + +end + +function [fail, dr_db] = dr_test(t) + +%% Reference: AES17 6.4.1 Dynamic range +test = test_defaults_src(t); +test.dr_db_min = t.dr_db_min; + +%% Create input file +test = dr_test_input(test); + +%% Run test +test = test_run_src(test, t); + +%% Measure +test.fs = t.fs2; +test = dr_test_measure(test); + +%% Get output parameters +fail = test.fail; +dr_db = test.dr_db; +delete_check(t.delete, test.fn_in); +delete_check(t.delete, test.fn_out); + +end + + +function [fail, aap_db] = aap_test(t) + +%% Reference: AES17 6.6.6 Attenuation of alias products +test = test_defaults_src(t); +test.aap_max = t.aap_db_max; + +if t.fs1 <= t.fs2 + %% Internal rate must be lower than input + fail = -2; + aap_db = NaN; + return; +end + +test.f_start = 0.5*t.fs1; +test.f_end = 0.5*t.fs2; + +%% Create input file +test = aap_test_input(test); + +%% Run test +test = test_run_src(test, t); + +%% Measure +test.fs = t.fs2; +test = aap_test_measure(test); +aap_db = test.aap; +fail = test.fail; +delete_check(t.delete, test.fn_in); +delete_check(t.delete, test.fn_out); + +%% Print +src_test_result_print(t, 'Attenuation of alias products', 'AAP'); + +end + +function [fail, aip_db] = aip_test(t) + +%% Reference: AES17 6.6.7 Attenuation of image products +test = test_defaults_src(t); +test.aip_max = t.aip_db_max; +if t.fs1 >= t.fs2 + %% Internal rate must be higher than input + fail = -2; + aip_db = NaN; + return; +%% +end + +%% Create input file +test.f_end = t.fs1/2; +test = aip_test_input(test); + +%% Run test +test = test_run_src(test, t); + +%% Measure +test.fs = t.fs2; +test = aip_test_measure(test); +aip_db = test.aip; +fail = test.fail; +delete_check(t.delete, test.fn_in); +delete_check(t.delete, test.fn_out); + +%% Print +src_test_result_print(t, 'Attenuation of image products', 'AIP'); + +end + +%% Chirp spectrogram test. This is a visual check only. Aliasing is visible +% in the plot as additional freqiencies than main linear up sweep. The aliasing +% can be a line, few lines, or lattice pattern depending the SRC conversion +% to test. The main sweep line should be steady level and extend from near +% zero freqeuncy to near Nyquist (Fs/2). + +function fail = chirp_test(t) + +fprintf('Spectrogram test %d -> %d ...\n', t.fs1, t.fs2); + +%% Create input file +test = test_defaults_src(t); +test = chirp_test_input(test); + +%% Run test +test = test_run_src(test, t); + +%% Analyze +test.fs = t.fs2; +test = chirp_test_analyze(test); +src_test_result_print(t, 'Chirp', 'chirpf'); + +% Delete files unless e.g. debugging and need data to run +delete_check(t.delete, test.fn_in); +delete_check(t.delete, test.fn_out); + +fail = test.fail; +end + + +%% Some SRC test specific utility functions +%% + +function test = test_defaults_src(t) +test.fmt = t.fmt; +test.bits_in = t.bits_in; +test.bits_out = t.bits_out; +test.nch = t.nch; +test.ch = t.ch; +test.fs = t.fs1; +test.fs1 = t.fs1; +test.fs2 = t.fs2; +test.mask_f = []; +test.mask_lo = []; +test.mask_hi = []; +test.coef_bits = 24; % No need to use actual word length in test +test.visible = t.visible; +end + +function test = test_run_src(test, t) +test.ex = './src_run.sh'; +test.arg = { num2str(t.bits_in), num2str(t.bits_out), num2str(t.fs1), num2str(t.fs2), test.fn_in, test.fn_out}; +delete_check(1, test.fn_out); +test = test_run(test); +end + +function src_test_result_print(t, testverbose, testacronym, ph) +tstr = sprintf('%s SRC %d, %d', testverbose, t.fs1, t.fs2); +if nargin > 3 + title(ph, tstr); +else + title(tstr); +end +pfn = sprintf('plots/%s_src_%d_%d.png', testacronym, t.fs1, t.fs2); +print(pfn, '-dpng'); +if t.close_plot_windows + close all; +end +end + +%% The next are results printing functions + +function print_val(fn, fs_in_list, fs_out_list, val, pf, valstr) +n_fsi = length(fs_in_list); +n_fso = length(fs_out_list); +fh = fopen(fn,'w'); +fprintf(fh,'\n'); +fprintf(fh,'SRC test result: %s\n', valstr); +fprintf(fh,'%8s, ', 'in \ out'); +for a = 1:n_fso-1 + fprintf(fh,'%8.1f, ', fs_out_list(a)/1e3); +end +fprintf(fh,'%8.1f', fs_out_list(n_fso)/1e3); +fprintf(fh,'\n'); +for a = 1:n_fsi + fprintf(fh,'%8.1f, ', fs_in_list(a)/1e3); + for b = 1:n_fso + if pf(a,b,1) < 0 + cstr = 'x'; + else + if isnan(val(a,b)) + cstr = '-'; + else + cstr = sprintf('%8.2f', val(a,b)); + end + end + if b < n_fso + fprintf(fh,'%8s, ', cstr); + else + fprintf(fh,'%8s', cstr); + end + end + fprintf(fh,'\n'); +end +fclose(fh); +type(fn); +end + +function print_fr(fn, fs_in_list, fs_out_list, fr_db, fr_hz, pf) +n_fsi = length(fs_in_list); +n_fso = length(fs_out_list); +fh = fopen(fn,'w'); +fprintf(fh,'\n'); +fprintf(fh,'SRC test result: Frequency response +/- X.XX dB (YY.Y kHz) \n'); +fprintf(fh,'%8s, ', 'in \ out'); +for a = 1:n_fso-1 + fprintf(fh,'%12.1f, ', fs_out_list(a)/1e3); +end +fprintf(fh,'%12.1f', fs_out_list(n_fso)/1e3); +fprintf(fh,'\n'); +for a = 1:n_fsi + fprintf(fh,'%8.1f, ', fs_in_list(a)/1e3); + for b = 1:n_fso + if pf(a,b,1) < 0 + cstr = 'x'; + else + cstr = sprintf('%4.2f (%4.1f)', fr_db(a,b), fr_hz(a,b,2)/1e3); + end + if b < n_fso + fprintf(fh,'%12s, ', cstr); + else + fprintf(fh,'%12s', cstr); + end + end + fprintf(fh,'\n'); +end +fclose(fh); +type(fn); +end + +function print_fr3db(fn, fs_in_list, fs_out_list, fr3db_hz, pf) +n_fsi = length(fs_in_list); +n_fso = length(fs_out_list); +fh = fopen(fn,'w'); +fprintf(fh,'\n'); +fprintf(fh,'SRC test result: Frequency response -3dB 0 - X.XX kHz\n'); +fprintf(fh,'%8s, ', 'in \ out'); +for a = 1:n_fso-1 + fprintf(fh,'%8.1f, ', fs_out_list(a)/1e3); +end +fprintf(fh,'%8.1f', fs_out_list(n_fso)/1e3); +fprintf(fh,'\n'); +for a = 1:n_fsi + fprintf(fh,'%8.1f, ', fs_in_list(a)/1e3); + for b = 1:n_fso + if pf(a,b,1) < 0 + cstr = 'x'; + else + cstr = sprintf('%4.1f', fr3db_hz(a,b)/1e3); + end + if b < n_fso + fprintf(fh,'%8s, ', cstr); + else + fprintf(fh,'%8s', cstr); + end + end + fprintf(fh,'\n'); +end +fclose(fh); +type(fn); +end + + +function print_pf(fn, fs_in_list, fs_out_list, pf) +n_fsi = length(fs_in_list); +n_fso = length(fs_out_list); +fh = fopen(fn,'w'); +fprintf(fh,'\n'); +fprintf(fh,'SRC test result: Fails\n'); +fprintf(fh,'%8s, ', 'in \ out'); +for a = 1:n_fso-1 + fprintf(fh,'%14.1f, ', fs_out_list(a)/1e3); +end +fprintf(fh,'%14.1f', fs_out_list(n_fso)/1e3); +fprintf(fh,'\n'); +spf = size(pf); +npf = spf(3); +for a = 1:n_fsi + fprintf(fh,'%8.1f, ', fs_in_list(a)/1e3); + for b = 1:n_fso + if pf(a,b,1) < 0 + cstr = 'x'; + else + cstr = sprintf('%d', pf(a,b,1)); + for n=2:npf + if pf(a,b,n) < 0 + cstr = sprintf('%s/x', cstr); + else + cstr = sprintf('%s/%d', cstr,pf(a,b,n)); + end + end + end + if b < n_fso + fprintf(fh,'%14s, ', cstr); + else + fprintf(fh,'%14s', cstr); + end + end + fprintf(fh,'\n'); +end +fclose(fh); +type(fn); +end diff --git a/test/src_test.sh b/test/src_test.sh new file mode 100755 index 000000000000..84e88c91dfe6 --- /dev/null +++ b/test/src_test.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +# Copyright (c) 2017, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of the Intel Corporation nor the +# names of its contributors may be used to endorse or promote products +# derived from this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# Author: Seppo Ingalsuo +# + +octave --no-gui src_test_top.m +if [ $? -eq 0 ]; then + echo "Test passed." + exit 0 +else + echo "Test failed." >&2 + exit 1 +fi diff --git a/test/src_test_top.m b/test/src_test_top.m new file mode 100644 index 000000000000..a0bf826245d4 --- /dev/null +++ b/test/src_test_top.m @@ -0,0 +1,42 @@ +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +[n_fail, n_pass] = src_test(24, 24); +if n_fail > 0 || n_pass < 1 + fprintf('Error: SRC test with 24 bits data failed.\n'); + quit(1) +end +[n_fail, n_pass] = src_test(32, 32); +if n_fail > 0 || n_pass < 1 + fprintf('Error: SRC test with 32 bits data failed.\n'); + quit(1) +end + +fprintf('Success: SRC test with 24 and 32 bits data passed.\n'); From a852b5341e264ce320a5f7dbb9689a1e5647d9ec Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 27 Jun 2018 13:49:33 +0300 Subject: [PATCH 197/324] SOFT: Add audio standards based objective performance measurements This patch provides scripts to measure such performance as THD+N, dynamic range, frequency response, gain, etc. Signed-off-by: Seppo Ingalsuo --- test/std_utils/aap_test_input.m | 103 +++++++++++++++++ test/std_utils/aap_test_measure.m | 77 +++++++++++++ test/std_utils/aip_test_input.m | 101 ++++++++++++++++ test/std_utils/aip_test_measure.m | 84 ++++++++++++++ test/std_utils/dr_test_input.m | 91 +++++++++++++++ test/std_utils/dr_test_measure.m | 76 ++++++++++++ test/std_utils/fr_test_input.m | 123 ++++++++++++++++++++ test/std_utils/fr_test_measure.m | 173 ++++++++++++++++++++++++++++ test/std_utils/g_test_input.m | 97 ++++++++++++++++ test/std_utils/g_test_measure.m | 70 +++++++++++ test/std_utils/level_dbfs.m | 46 ++++++++ test/std_utils/stdhpf.m | 54 +++++++++ test/std_utils/stdhpf_get.m | 68 +++++++++++ test/std_utils/stdlpf.m | 54 +++++++++ test/std_utils/stdlpf_get.m | 70 +++++++++++ test/std_utils/stdnotch.m | 47 ++++++++ test/std_utils/stdnotch_get.m | 70 +++++++++++ test/std_utils/stdweight.m | 86 ++++++++++++++ test/std_utils/thdnf_test_input.m | 95 +++++++++++++++ test/std_utils/thdnf_test_measure.m | 83 +++++++++++++ 20 files changed, 1668 insertions(+) create mode 100644 test/std_utils/aap_test_input.m create mode 100644 test/std_utils/aap_test_measure.m create mode 100644 test/std_utils/aip_test_input.m create mode 100644 test/std_utils/aip_test_measure.m create mode 100644 test/std_utils/dr_test_input.m create mode 100644 test/std_utils/dr_test_measure.m create mode 100644 test/std_utils/fr_test_input.m create mode 100644 test/std_utils/fr_test_measure.m create mode 100644 test/std_utils/g_test_input.m create mode 100644 test/std_utils/g_test_measure.m create mode 100644 test/std_utils/level_dbfs.m create mode 100644 test/std_utils/stdhpf.m create mode 100644 test/std_utils/stdhpf_get.m create mode 100644 test/std_utils/stdlpf.m create mode 100644 test/std_utils/stdlpf_get.m create mode 100644 test/std_utils/stdnotch.m create mode 100644 test/std_utils/stdnotch_get.m create mode 100644 test/std_utils/stdweight.m create mode 100644 test/std_utils/thdnf_test_input.m create mode 100644 test/std_utils/thdnf_test_measure.m diff --git a/test/std_utils/aap_test_input.m b/test/std_utils/aap_test_input.m new file mode 100644 index 000000000000..0a969c62a99f --- /dev/null +++ b/test/std_utils/aap_test_input.m @@ -0,0 +1,103 @@ +function test = aap_test_input(test) + +%% t = aap_test_input(t) +% +% Create frequency sweep data file for playback & record on real device or +% for algorithm simulation. +% +% Input parameters +% t.f_start - start frequency +% t.f_end - end frequency +% t.fs - sample rate +% t.bits_in - number of bits in signal +% t.ch - mix test signal to channel ch +% t.nch - total number of channels in data +% +% Output parameters +% t.fn_in - created input file name +% t.fn_out - proposed output file name for captured output +% t.f - frequencies in sweep +% t.nf - number of frequencies +% t.tl - tone length in seconds +% t.ts - tone start times +% t.tr - tone gain ramp length in seconds +% t.ti - ignore time from tone start and end, must be ti > tr +% t.a - tone amplitude (lin) +% t.a_db - tone amplitude (dB) +% t.mark_t - length of marker tone in seconds +% t.mark_a - amplitude max of marker tone (lin) +% t.mark_a_db - amplitude max of marker tone (dB) +% + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference: AES17 6.6.6 Attenuation of alias products +% http://www.aes.org/publications/standards/ + +if nargin < 1 + error('This function must be called with argunment.'); +end + +if test.ch == 0 + test.ch = 1+round(rand(1,1)*(test.nch-1)); % Test random channel 1..Nch +end + +fprintf('Using parameters Fstart=%d Hz, Fend=%d Hz, Fs=%.1f kHz, bits_in=%d, ch=%d, nch=%d\n', ... + test.f_start, test.f_end, test.fs, test.bits_in, test.ch, test.nch); + + +test.fn_in = sprintf('aap_test_in.%s', test.fmt); +test.fn_out = sprintf('aap_test_out.%s', test.fmt); +f_first = 997; +f_max = max(test.f_start, test.f_end); +f_min = min(test.f_start, test.f_end); +n_third = ceil(log(f_max/f_min)/log(2)*3); % max 1/3 octave step +steps = max(n_third, 50); % Min 50 steps +test.f = [f_first logspace(log10(test.f_start), log10(test.f_end), steps) ]; + +%% Tone sweep parameters +test.is = 20e-3; % Ignore signal from tone start +test.ie = 20e-3; % Ignore signal from tone end +test.tr = 10e-3; % Gain ramp time for tones +test.sm = 3; % Seek start marker from 3s from start +test.em = 3; % Seek end marker from 3s from end +test.mt = 0.3; % Error if marker positions delta is greater than 0.3s +test.tc = 20; % Min. 20 cycles of sine wave for a frequency +t_min = 0.2; +test.a_db = -20; +test.a = 10^(test.a_db/20); +% Use t_min or min cycles count as tone length +test.tl = max(test.tc*1/min(test.f),t_min); + +%% Mix the input file for test and write output +test = mix_sweep(test); + +end diff --git a/test/std_utils/aap_test_measure.m b/test/std_utils/aap_test_measure.m new file mode 100644 index 000000000000..a61dadf30653 --- /dev/null +++ b/test/std_utils/aap_test_measure.m @@ -0,0 +1,77 @@ +function test = aap_test_measure(test) + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference: AES17 6.6.6 Attenuation of alias products +% http://www.aes.org/publications/standards/ + +%% Load output file +[x, nx] = load_test_output(test); +if nx == 0 + test.fail = 1; + return +end + +%% Find sync +[d, nt, nt_use, nt_skip] = find_test_signal(x, test); + +%% Measure +win = hamming(nt_use); +m0 = zeros(test.nf,1); +for n=1:test.nf + fprintf('Measuring %.0f Hz ...\n', test.f(n)); + i1 = d+(n-1)*nt+nt_skip; + i2 = i1+nt_use-1; + m0(n) = level_dbfs(x(i1:i2).*win); +end + +%% Calculate levels relative to first 997 Hz frequency, +% remove it from result, sort to ascinding order for plot +m_ref = m0(1); +test.m = m0(2:end)-m0(1); +[test.f, idx] = sort(test.f(2:end)); +test.m = test.m(idx); +test.aap = max(test.m); % Worst-case + +if test.aap > test.aap_max + test.fail = 1; +else + test.fail = 0; +end + +test.fh = figure('visible', test.visible); +semilogx(test.f, test.m); +grid on; +xlabel('Frequency (Hz)'); +ylabel('Relative level (dB)'); +grid on; + +end diff --git a/test/std_utils/aip_test_input.m b/test/std_utils/aip_test_input.m new file mode 100644 index 000000000000..a946c9680145 --- /dev/null +++ b/test/std_utils/aip_test_input.m @@ -0,0 +1,101 @@ +function test = aip_test_input(test) + +%% t = aap_test_input(t) +% +% Create frequency sweep data file for playback & record on real device or +% for algorithm simulation. +% +% Input parameters +% t.f_start - start frequency +% t.f_end - end frequency +% t.fs - sample rate +% t.bits_in - number of bits in signal +% t.ch - mix test signal to channel ch +% t.nch - total number of channels in data +% +% Output parameters +% t.fn_in - created input file name +% t.fn_out - proposed output file name for captured output +% t.f - frequencies in sweep +% t.nf - number of frequencies +% t.tl - tone length in seconds +% t.ts - tone start times +% t.tr - tone gain ramp length in seconds +% t.ti - ignore time from tone start and end, must be ti > tr +% t.a - tone amplitude (lin) +% t.a_db - tone amplitude (dB) +% t.mark_t - length of marker tone in seconds +% t.mark_a - amplitude max of marker tone (lin) +% t.mark_a_db - amplitude max of marker tone (dB) +% + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference: AES17 6.6.7 Attenuation of image products +% http://www.aes.org/publications/standards/ + +if nargin < 1 + error('This function must be called with argument.'); +end + +if test.ch == 0 + test.ch = 1+round(rand(1,1)*(test.nch-1)); % Test random channel 1..Nch +end + +fprintf('Using parameters Fend=%d Hz, Fs=%.1f kHz, bits_in=%d, ch=%d, nch=%d\n', ... + test.f_end, test.fs, test.bits_in, test.ch, test.nch); + +test.fn_in = sprintf('aip_test_in.%s', test.fmt); +test.fn_out = sprintf('aip_test_out.%s', test.fmt); +f_first = 997; +test.f_start = 20; +f_min = min(test.f_start, test.f_end); +f_max = max(test.f_start, test.f_end); +test.fu = f_max; +n_thirdoct = ceil(log(f_max/f_min)/log(2)*3); % max 1/3 octave step +steps = n_thirdoct; +test.f = [f_first logspace(log10(test.f_start), log10(test.f_end), steps) ]; + +%% Tone sweep parameters +test.is = 20e-3; % Ignore signal from tone start +test.ie = 20e-3; % Ignore signal from tone end +test.tr = 10e-3; % Gain ramp time for tones +test.sm = 3; % Seek start marker from 3s from start +test.em = 3; % Seek end marker from 3s from end +test.mt = 0.1; % Error if marker positions delta is greater than 0.1s +test.tl = 3; +test.a_db = -20; +test.a = 10^(test.a_db/20); + +%% Mix the input file for test and write output +test = mix_sweep(test); + +end diff --git a/test/std_utils/aip_test_measure.m b/test/std_utils/aip_test_measure.m new file mode 100644 index 000000000000..56aee93b9125 --- /dev/null +++ b/test/std_utils/aip_test_measure.m @@ -0,0 +1,84 @@ +function test = aip_test_measure(test) + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference: AES17 6.6.7 Attenuation of image products +% http://www.aes.org/publications/standards/ + +%% Load output file +[x, nx] = load_test_output(test); +if nx == 0 + test.g_db = NaN; + test.fail = 1; + return +end + +%% Find sync +[d, nt, nt_use, nt_skip] = find_test_signal(x, test); + +%% Measure all test frequencies +t_skip = 1.0; +ml = zeros(test.nf,1); +mn = zeros(test.nf,1); +b_lpf = stdlpf_get(test.fu, test.fs); % Get LPF coef +b_hpf = stdhpf_get(test.fu, test.fs); % Get HPF coef +for n=1:test.nf + fprintf('Measuring %.0f Hz ...\n', test.f(n)); + % Get notch coef for this frequency + [b_notch, a_notch] = stdnotch_get(test.f(n), test.fs); + i1 = d+(n-1)*nt+nt_skip; + i2 = i1+nt_use-1; + x_lpf = filter(b_lpf, 1, x(i1:i2)); % Standard LPF, need for 997 Hz only + x_notch = filter(b_notch, a_notch, x(i1:i2)); % Standard notch + x_hpf = filter(b_hpf, 1, x_notch); % Standard HPF + ml(n) = level_dbfs(x_lpf(round(t_skip*test.fs):end)); + mn(n) = level_dbfs(x_hpf(round(t_skip*test.fs):end)); +end + +%% Calculate levels relative to first 997 Hz frequency, +% remove it from result, sort to ascinding order for plot +test.f = test.f(2:end); +test.m = mn(2:end)-ml(1); +test.aip = max(test.m); % Worst-case +if test.aip > test.aip_max + test.fail = 1; +else + test.fail = 0; +end + +test.fh = figure('visible', test.visible); +semilogx(test.f, test.m); +grid on; +xlabel('Frequency (Hz)'); +ylabel('Relative level (dB)'); +grid on; + +end diff --git a/test/std_utils/dr_test_input.m b/test/std_utils/dr_test_input.m new file mode 100644 index 000000000000..396d7d09036d --- /dev/null +++ b/test/std_utils/dr_test_input.m @@ -0,0 +1,91 @@ +function test = dr_test_input(test) + +%% t = dr_test_input(t) +% +% Create tone data file for playback & record on real device or +% for algorithm simulation. +% +% Input parameters +% t.fs - sample rate +% t.bits_in - signal word length +% t.ch - mix test signal to channel ch +% t.nch - total number of channels in data +% +% Output parameters +% t.fn_in - created input file name +% t.fn_out - proposed output file name for captured output +% t.f - test signal frequency +% t.tl - tone length in seconds +% t.ts - tone start time +% t.tr - tone gain ramp length in seconds +% t.ti - ignore time from tone start and end, must be ti > tr +% t.a - tone amplitude (lin) +% t.a_db - tone amplitude (dB) +% t.mark_t - length of marker tone in seconds +% t.mark_a - amplitude max of marker tone (lin) +% t.mark_a_db - amplitude max of marker tone (dB) +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference: AES17 6.2.3 Frequency response + +if nargin < 1 + fprintf('Warning, using default parameters!\n'); + test.fs = 48e3; test.bits_in=32; test.ch=1; test.nch=1; +end + +if test.ch == 0 + test.ch = 1+round(rand(1,1)*(test.nch-1)); % Test random channel 1..Nch +end + +fprintf('Using parameters Fs=%.1f, bits=%d, ch=%d, Nch=%d\n', ... + test.fs/1e3, test.bits_in, test.ch, test.nch ); + +%% Test tone parameters +test.fn_in = sprintf('dr_test_in.%s', test.fmt); +test.fn_out = sprintf('dr_test_out.%s', test.fmt); +test.f = 997; +test.a_db = -60; +test.a = 10^(test.a_db/20); +test.is = 1.0; % Ignore signal from tone start +test.ie = 20e-3; % Ignore signal from tone end +test.tr = 10e-3; % Gain ramp time for tones +test.sm = 3; % Seek start marker from 3s from start +test.em = 3; % Seek end marker from 3s from end +test.mt = 0.3; % Error if marker positions delta is greater than 0.3s +test.tc = 25; % Min. 20 cycles of sine wave for a frequency +test.tl = 3; % 3 seconds tone + +%% Mix the input file for test and write output +test = mix_sweep(test); + +end diff --git a/test/std_utils/dr_test_measure.m b/test/std_utils/dr_test_measure.m new file mode 100644 index 000000000000..6e8634fb90d8 --- /dev/null +++ b/test/std_utils/dr_test_measure.m @@ -0,0 +1,76 @@ +function test = dr_test_measure(test) + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Load output file +[x, nx] = load_test_output(test); +if nx == 0 + test.dr_db = NaN; + test.fail = 1; + return +end + +%% Find sync +[d, nt, nt_use, nt_skip] = find_test_signal(x, test); + +%% Notch filter +y0n = stdnotch(x, test.f, test.fs); + +%% CCIR-RMS weighting filter +y0w = stdweight(y0n, test.fs); + +%% Trim sample by removing first 1s to let the notch to apply +i1 = d+nt_skip; +i2 = i1+nt_use-1; +y = x(i1:i2); +y_n = y0w(i1:i2); + +%% Gain, SNR +level_in = test.a_db; +level_out = level_dbfs(y); +level_final = level_dbfs(y_n); +test.dr_db = level_out-level_final-test.a_db; +fprintf('DR = %5.1f dB\n', test.dr_db); +if 0 + plot(y); + hold on + plot(y_n,'g'); + hold off +end + +%% Check pass/fail +test.fail = 0; +if test.dr_db < test.dr_db_min + fprintf('Failed DR %f dB (min %f dB)\n', test.dr_db, test.dr_db_min); + test.fail = 1; +end + +end diff --git a/test/std_utils/fr_test_input.m b/test/std_utils/fr_test_input.m new file mode 100644 index 000000000000..5471bf7c4698 --- /dev/null +++ b/test/std_utils/fr_test_input.m @@ -0,0 +1,123 @@ +function test = fr_test_input(test) + +%% t = fr_test_input(t) +% +% Create frequency sweep data file for playback & record on real device or +% for algorithm simulation. +% +% Input parameters +% t.f_max - maximum frequency of sweep, set e.g. to 0.99*fs/2 +% t.fs - sample rate +% t.bits_in - number of bits in signal +% t.ch - mix test signal to channel ch, e.g. set to [1 2] to measure +% two channels +% t.nch - total number of channels in data +% +% Output parameters +% t.fn_in - Created input file name +% t.fn_out - Proposed output file name for captured output +% t.f_ref - Reference frequency used to report deviation (997 Hz) +% t.f_min - Sweep start frequency +% t.f - Frequencies in sweep +% t.is - Ignore signal from tone start +% t.ie - Ignore signal from tone end +% t.tr - tone gain ramp length in seconds +% t.sm - Seek start marker this time length from start +% t.em - Seek end marker this time length from end +% t.mt - Error if marker positions delta is greater than this +% t.tc - Min cycles of sine wave per frequency +% t.tl - Tone length in seconds +% t.a_db - Tone amplitude (dB) +% t.a - Tone amplitude (lin) +% t.nt - Number of samples per tone +% t.nf - Number of frequencies +% t.na - Number of amplitudes +% t.mark_t - Length of marker tone in seconds +% t.mark_a - Amplitude max of marker tone (lin) +% t.mark_a_db - Amplitude max of marker tone (dB) +% t.ts - Tone start times +% +% E.g. +% t.fs=48e3; t.f_max=20e3; t.bits_in=16; t.ch=1; t.nch=2; t = fr_test_input(t); +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference: AES17 6.2.3 Frequency response +% http://www.aes.org/publications/standards/ + +if nargin < 1 + fprintf('Warning, using default parameters!\n'); + test.fs = 48e3; test.f_max = 0.99*test.fs/2; test.ch=1; test.nch=1; + test.bits_in=32; +end + +if test.ch == 0 + test.ch = 1+round(rand(1,1)*(test.nch-1)); % Test random channel 1..Nch +end + +fprintf('Using parameters Fmax=%.1f kHz, Fs=%.1f, ch=%d, Nch=%d, bits_in=%d\n', ... + test.f_max/1e3, test.fs/1e3, test.ch, test.nch, test.bits_in); + +test.fn_in = sprintf('fr_test_in.%s', test.fmt); +test.fn_out = sprintf('fr_test_out.%s', test.fmt); +test.f_ref = 997; +test.f_min = 20; + +%% Use a dense frequency grid to see -3 dB point well +n_oct = ceil(log(test.f_max/test.f_ref)/log(2)*35); +f = logspace(log10(test.f_ref), log10(test.f_max), n_oct); +c = f(1)/f(2); +f_next = test.f_ref*c; +while (f_next > test.f_min) + f = [f_next f]; + f_next = f_next*c; +end +test.f = f; + +%% Tone sweep parameters +test.is = 20e-3; % Ignore signal from tone start +test.ie = 20e-3; % Ignore signal from tone end +test.tr = 10e-3; % Gain ramp time for tones +test.sm = 3; % Seek start marker from 3s from start +test.em = 3; % Seek end marker from 3s from end +test.mt = 0.1; % Error if marker positions delta is greater than 0.1s +test.tc = 10; % Min. 10 cycles of sine wave for a frequency +t_min = 0.2; +% Use t_min or min cycles count as tone length +test.tl = max(test.tc*1/min(f),t_min); +test.a_db = -20; +test.a = 10.^(test.a_db/20); + +%% Mix the input file for test and write output +test = mix_sweep(test); + +end diff --git a/test/std_utils/fr_test_measure.m b/test/std_utils/fr_test_measure.m new file mode 100644 index 000000000000..e7156fede631 --- /dev/null +++ b/test/std_utils/fr_test_measure.m @@ -0,0 +1,173 @@ +function test = fr_test_measure(test) + +%% t = fr_test_measure(t) +% +% Measure frequency response from captured frequency sweep created by +% fr_test_input() that sets most of the input struct fiels. The output +% is read from file t.fn_out. +% +% Input parameters +% t.f_lo - Measure ripple start frequency +% t.f_hi - Measure ripple end frequency +% t.rp_max - Max. ripple +/- dB +% t.mask_f - Frequencies for mask +% t.mask_lo - Upper limits of mask +% t.mask_hi - Lower limits of mask +% +% Output parameters +% t.m - Measured frequency response +% t.rp - Measured ripple +/- dB +% t.fr3db_hz - Bandwidth in Hz for -3 dB attenuated response +% t.fail - Returns zero for passed +% t.fh - Figure handle +% t.ph - Plot handle +% +% E.g. +% t.fs=48e3; t.f_max=20e3; t.bits_out=16; t.ch=1; t.nch=2; t=fr_test_input(t); +% t.fn_out=t.fn_in; t.f_lo=20; t.f_hi=20e3; t.rp_max=[]; t.mask_f=[]; +% t=fr_test_measure(t); +% + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference: AES17 6.2.3 Frequency response +% http://www.aes.org/publications/standards/ + +[x, nx] = load_test_output(test); + +j = 1; +for channel = test.ch + + if nx == 0 + test.rp(j) = NaN; + test.fr3db_hz(j) = NaN; + test.fail = 1; + return + end + + %% Find sync + [d, nt, nt_use, nt_skip] = find_test_signal(x(:,j), test); + + win = hamming(nt_use); + m0 = zeros(test.nf,1); + for n=1:test.nf + fprintf('Measuring %.0f Hz ...\n', test.f(n)); + i1 = d+(n-1)*nt+nt_skip; + i2 = i1+nt_use-1; + m0(n) = level_dbfs(x(i1:i2,j).*win) -test.a_db; + end + + %% Scale 997 Hz point as 0 dB + df = test.f - test.f_ref; + [~,i997] = min(abs(df)); + m_offs = m0(i997); + test.m(:,j) = m0 - m_offs; + + %% Check pass/fail + idx0 = find(test.f < test.f_hi); + idx1 = find(test.f(idx0) > test.f_lo); + range_db = max(test.m(idx1,j))-min(test.m(idx1,j)); + test.rp(j) = range_db/2; + test.fail = 0; + if ~isempty(test.rp_max) + if test.rp > test.rp_max + fprintf('Failed response +/- %f dBpp (max +/- %f dB)\n', ... + test.rp, test.rp_max); + test.fail = 1; + end + end + + %% Find frequency response 3 dB 0-X Hz + idx3 = find(test.m(:,j) > -3); + test.fr3db_hz(j) = test.f(idx3(end)); + + %% Interpolate mask in logaritmic frequencies, check + if ~isempty(test.mask_f) + f_log = log(test.f); + mask_hi = interp1(log(test.mask_f), test.mask_hi(:,j), ... + f_log, 'linear'); + mask_lo = interp1(log(test.mask_f), test.mask_lo(:,j), ... + f_log, 'linear'); + over_mask = test.m(:,j)-mask_hi'; + under_mask = mask_lo'-test.m(:,j); + idx = find(isnan(over_mask) == 0); + [m_over_mask, io] = max(over_mask(idx)); + idx = find(isnan(under_mask) == 0); + [m_under_mask, iu] = max(under_mask(idx)); + if m_over_mask > 0 + fprintf('Failed upper response mask around %.0f Hz\n', ... + test.f(io)); + test.fail = 1; + end + if m_under_mask > 0 + fprintf('Failed lower response mask around %.0f Hz\n', ... + test.f(iu)); + test.fail = 1; + end + end + + test.fh(j) = figure('visible', test.visible); + subplot(1,1,1); + test.ph(j) = subplot(1,1,1); + %semilogx(test.f, test.m(:,j)); + plot(test.f, test.m(:,j)); + grid on; + xlabel('Frequency (Hz)'); + ylabel('Magnitude (dB)'); + if length(test.mask_f) > 0 + hold on; + plot(test.f, mask_hi, 'r--'); + plot(test.f, mask_lo, 'r--'); + hold off; + end + ax = axis(); + axis([ax(1:2) -4 1]); + if max(max(test.m(idx1,j))-min(test.m(idx1,j))) < 1 + axes('Position', [ 0.2 0.2 0.4 0.2]); + box on; + plot(test.f(idx1), test.m(idx1,j)); + if ~isempty(test.rp_max) + hold on; + plot([test.f_lo test.f_hi], ... + [-test.rp_max/2 -test.rp_max/2], 'r--'); + plot([test.f_lo test.f_hi], ... + [ test.rp_max/2 test.rp_max/2], 'r--'); + hold off; + end + grid on; + axis([0 test.f_hi -0.1 0.1]); + end + + %% Next channel to measure + j=j+1; +end + +end diff --git a/test/std_utils/g_test_input.m b/test/std_utils/g_test_input.m new file mode 100644 index 000000000000..bc0e19b04f92 --- /dev/null +++ b/test/std_utils/g_test_input.m @@ -0,0 +1,97 @@ +function test = g_test_input(test) + +%% t = dr_test_input(t) +% +% Create tone data file for playback & record on real device or +% for algorithm simulation. +% +% Input parameters +% t.fs - sample rate +% t.bits_in - signal word length +% t.ch - mix test signal to channel ch +% t.nch - total number of channels in data +% +% Output parameters +% t.fn_in - created input file name +% t.fn_out - proposed output file name for captured output +% t.f - test signal frequency +% t.tl - tone length in seconds +% t.ts - tone start time +% t.tr - tone gain ramp length in seconds +% t.ti - ignore time from tone start and end, must be ti > tr +% t.a - tone amplitude (lin) +% t.a_db - tone amplitude (dB) +% t.mark_t - length of marker tone in seconds +% t.mark_a - amplitude max of marker tone (lin) +% t.mark_a_db - amplitude max of marker tone (dB) +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference: AES17 6.2.2 Gain +% http://www.aes.org/publications/standards/ + + +if nargin < 1 + fprintf('Warning, using default parameters!\n'); + test.fs = 48e3; test.bits=32; test.ch=1; test.nch=1; +end + +if test.ch == 0 + test.ch = 1+round(rand(1,1)*(test.nch-1)); % Test random channel 1..Nch +end + +fprintf('Using parameters Fs=%.1f, bits_in=%d', test.fs/1e3, test.bits_in); +fprintf(', ch=%d', test.ch ); +fprintf(', Nch=%d\n', test.nch ); + +test.fn_in = sprintf('g_test_in.%s', test.fmt); +test.fn_out = sprintf('g_test_out.%s', test.fmt); +test.f = 997; + + +%% Tone sweep parameters +test.is = 20e-3; % Ignore signal from tone start +test.ie = 20e-3; % Ignore signal from tone end +test.tr = 10e-3; % Gain ramp time for tones +test.sm = 3; % Seek start marker from 3s from start +test.em = 3; % Seek end marker from 3s from end +test.mt = 0.3; % Error if marker positions delta is greater than 0.3s +test.tc = 25; % Min. 20 cycles of sine wave for a frequency +test.a_db = -20; % -20 dBFS level +test.a = 10^(test.a_db/20); +% 0.5 seconds tone, this will be adjusted to be integer number of samples +test.tl = 0.5; + +%% Mix the input file for test and write output +test = mix_sweep(test); + +end diff --git a/test/std_utils/g_test_measure.m b/test/std_utils/g_test_measure.m new file mode 100644 index 000000000000..40c98716c55f --- /dev/null +++ b/test/std_utils/g_test_measure.m @@ -0,0 +1,70 @@ +function test = g_test_measure(test) + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference: AES17 6.2.2 Gain +% http://www.aes.org/publications/standards/ + +%% Load output file +[x, nx] = load_test_output(test); + +if nx == 0 + test.g_db = NaN; + test.fail = 1; + return +end + +%% Standard low-pass +y0 = stdlpf(x, test.fu, test.fs); + +%% Find sync +[d, nt, nt_use, nt_skip] = find_test_signal(y0, test); + +%% Trim sample by removing first 1s to let the notch to apply +i1 = d+nt_skip; +i2 = i1+nt_use-1; +y = y0(i1:i2); + +%% Gain, SNR +level_in = test.a_db; +level_out = level_dbfs(y); +test.g_db = level_out-level_in; +fprintf('Gain = %6.3f dB (expecting %6.3f dB)\n', test.g_db, test.g_db_expect); + +%% Check pass/fail +test.fail = 0; +if abs(test.g_db_expect-test.g_db) > test.g_db_tol + fprintf('Failed gain %f dB (max %f dB)\n', test.g_db, test.g_db_tol); + test.fail = 1; +end + +end + diff --git a/test/std_utils/level_dbfs.m b/test/std_utils/level_dbfs.m new file mode 100644 index 000000000000..73cddedb4ce8 --- /dev/null +++ b/test/std_utils/level_dbfs.m @@ -0,0 +1,46 @@ +function dbfs = level_dbfs(x) + +%% dbfs = level_dbfs(x) +% +% Input +% x - signal +% +% Output +% dbfs - sigmal level in dBFS +% + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference AES 17 3.12.3 +level_ms = mean(x.^2); +dbfs = 10*log10(level_ms) + 20*log10(sqrt(2)); + +end diff --git a/test/std_utils/stdhpf.m b/test/std_utils/stdhpf.m new file mode 100644 index 000000000000..bf855a063686 --- /dev/null +++ b/test/std_utils/stdhpf.m @@ -0,0 +1,54 @@ +function y = stdhpf(x, fu, fs) + +%% y = stdhpf(x, fu, fs) +% +% Standard high-pass filter +% +% Input +% x - input signal +% fu - upper band-edge frequency +% fs - sample rate +% +% Output +% y - filtered signal +% +% Reference AES17 5.2.6 + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Design filter +b = stdhpf_get(fu, fs); + +%% Filter +y = filter(b, 1, x); + + +end diff --git a/test/std_utils/stdhpf_get.m b/test/std_utils/stdhpf_get.m new file mode 100644 index 000000000000..367a39bbffb9 --- /dev/null +++ b/test/std_utils/stdhpf_get.m @@ -0,0 +1,68 @@ +function b = stdhpf_get(fu, fs) + +%% y = stdhpf(x, fu, fs) +% +% Standard high-pass filter +% +% Input +% x - input signal +% fu - upper band-edge frequency +% fs - sample rate +% +% Output +% y - filtered signal +% +% Reference AES17 5.2.6 + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Design filter +rp = 0.5; +rs = -50; % Some margin vs. requirement +a = [0 1]; +fc = min(1.3*fu, 0.99*fs/2); +f = [fu fc]; +dev = [ 10^(rs/20) (10^(rp/20)-1)/(10^(rp/20)+1) ]; +[n, wn, beta, ftype] = kaiserord(f, a, dev, fs); +b = fir1(n, wn, ftype, kaiser(n+1,beta)); + +if 0 + f = linspace(0, fs/2, 1000); + h = freqz(b,1, f, fs); + figure + plot(f, 20*log10(abs(h))) + hold on; + plot( [0 fu], [-40 -40], 'r', [fc fs/2], [-0.5 -0.5], 'r', [fc fs/2], [0.5 0.5], 'r'); + hold off; + grid on; +end + +end diff --git a/test/std_utils/stdlpf.m b/test/std_utils/stdlpf.m new file mode 100644 index 000000000000..56fdc5a44458 --- /dev/null +++ b/test/std_utils/stdlpf.m @@ -0,0 +1,54 @@ +function y = stdlpf(x, fu, fs) + +%% y = stdhpf(x, fu, fs) +% +% Standard high-pass filter +% +% Input +% x - input signal +% fu - upper band-edge frequency +% fs - sample rate +% +% Output +% y - filtered signal +% +% Reference AES17 5.2.5 + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Design filter +b = stdlpf_get(fu, fs); + +%% Filter +y = filter(b, 1, x); + + +end diff --git a/test/std_utils/stdlpf_get.m b/test/std_utils/stdlpf_get.m new file mode 100644 index 000000000000..ac344d155d55 --- /dev/null +++ b/test/std_utils/stdlpf_get.m @@ -0,0 +1,70 @@ +function b = stdlpf_get(fu, fs) + +%% b = stdlpf_get(fu, fs) +% +% Standard loww-pass filter +% +% Input +% fu - upper band-edge frequency +% fs - sample rate +% +% Output +% b - coefficients for FIR filter +% +% Reference AES17 5.2.5 + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Design filter +rp = 0.001; % Since this may need to be in frequency response measurement the ripple must be very small +rs = -65; % Some margin vs. requirement +a = [1 0]; +% Note: The fc-fu for digital low-pass is not feasible. Use of fu*1.2 instead +% results to example 24 kHz for 20 kHz upper band-edge. This could be a mistake +% in specification. +fc = min(fu*1.2, 0.99*fs/2); +f = [fu fc]; +dev = [ (10^(rp/20)-1)/(10^(rp/20)+1) 10^(rs/20) ]; +[n, wn, beta, ftype] = kaiserord(f, a, dev, fs); +b = fir1(n, wn, ftype, kaiser(n+1,beta)); + +if 0 + f = linspace(0, fs/2, 1000); + h = freqz(b,1, f, fs); + figure + plot(f, 20*log10(abs(h))) + hold on; + plot( [fc fs/2], [-60 -60], 'r', [0 fu], [-0.1 -0.1], 'r', [0 fu], [0.1 0.1], 'r'); + hold off; + grid on; +end + +end diff --git a/test/std_utils/stdnotch.m b/test/std_utils/stdnotch.m new file mode 100644 index 000000000000..51d00d2e21d3 --- /dev/null +++ b/test/std_utils/stdnotch.m @@ -0,0 +1,47 @@ +function y = stdnotch(x, fn, fs) + +%% y = stdnotch(x, fn, fs) +% +% Input +% x - input signal +% fn - notch frequency +% fs - sample rate +% +% Output +% y - filtered signal +% + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +[b, a] = stdnotch_get(fn, fs); +y = filter(b, a, x); + +end diff --git a/test/std_utils/stdnotch_get.m b/test/std_utils/stdnotch_get.m new file mode 100644 index 000000000000..5213fa8eae35 --- /dev/null +++ b/test/std_utils/stdnotch_get.m @@ -0,0 +1,70 @@ +function [b, a] = stdnotch_get(fn, fs) + +%% [b, a] = stdnotch_get(fn, fs) +% +% Input +% fn - notch frequency +% fs - sample rate +% +% Output +% b - coefficients for filter zeros +% a - coefficients for filter poles +% + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +target_q = 2.1; +bw = (2*fn/fs)/target_q; +if exist('iirnotch.m') == 2 + [b, a] = iirnotch(2*fn/fs, bw); +else + [b, a] = pei_tseng_notch(2*fn/fs, bw); +end +if 0 + %% In AES17 5.2.8 standard notch must have Q 1.2-3.0 + % Quality factor is ratio of of center frequency to + % differenence between -3 dB frequencies. + figure; + f = linspace(0.2*fn, min(2*fn,fs/2), 5000); + h = freqz(b, a, f, fs); + m = 20*log10(abs(h)); + plot(f, m); grid on; + idx = find(m < -3); + f1 = f(idx(1)); + f2 = f(idx(end)); + q = fn/(f2-f1); + if (q < 1.2) || (q > 3.0) + fprintf('Required Q value failed, Q = %5.2f\n', q); + else + fprintf('Q = %5.2f\n', q); + end +end +end diff --git a/test/std_utils/stdweight.m b/test/std_utils/stdweight.m new file mode 100644 index 000000000000..92e3a3cb1354 --- /dev/null +++ b/test/std_utils/stdweight.m @@ -0,0 +1,86 @@ +function y = stdweight(x, fs) + +%% y = stdweight(x, fs) +% +% Input +% x - input signal +% fs - sample rate +% +% Output +% y - filtered signal +% + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Frequency grid for FIR design +f = linspace(0, fs/2, 6000); + +%% From https://en.wikipedia.org/wiki/ITU-R_468_noise_weighting +h1 = -4.737338981378384e-24*f.^6 +2.043828333606125e-15*f.^4 -1.363894795463638e-7*f.^2 +1; +h2 = 1.306612257412824e-19*f.^5 -2.118150887518656e-11*f.^3 +5.559488023498642e-4*f; +RITU = 1.246332637532143e-4*f./sqrt(h1.^2+h2.^2); +ITU = 18.2+20*log10(RITU)-5.63; % AES17 CCIR-RMS +fc = [ 31.5 63 100 200 400 800 1000 2000 3150 4000 5000 6300 7100 8000 9000 10000 12500 14000 16000 20000 31500]; +ga = [-35.5 -29.5 -25.4 -19.4 -13.4 -7.5 -5.6 0 3.4 4.9 6.1 6.6 6.4 5.8 4.5 2.5 -5.6 -10.9 -17.3 -27.8 -48.3]; +tu = [ 2.0 1.4 1.0 0.85 0.70 0.55 0.50 0.50 0.50 0.50 0.50 0.01 0.20 0.40 0.60 0.80 1.2 1.4 1.6 2.0 2.8]; +tl = [ -2.0 -1.4 -1.0 -0.85 -0.70 -0.55 -0.50 -0.50 -0.50 -0.50 -0.50 -0.01 -0.20 -0.40 -0.60 -0.80 -1.2 -1.4 -1.6 -2.0 NaN]; + +%% Fine tune the 6300Hz, 6.6 dB point +if fs > 2*6300 + idx = find(f > 6300, 1, 'first'); + ITU = ITU + 6.6-ITU(idx); +else + idx = find(f > 3150, 1, 'first'); + ITU = ITU + 3.4-ITU(idx); +end + +m_fir = 10.^(ITU/20); +f_fir = 2*f/fs; +n_fir = 4000; % Sufficient up to 192 kHz +if (fs < 96001) + n_fir = 2000; +end +if (fs < 48001) + n_fir = 1000; +end +if (fs < 16001) + n_fir = 400; +end +bz = fir2(n_fir, f_fir, m_fir); +y = filter(bz, 1, x); +if 0 + h = freqz(bz, 1, f, fs); + my_w_db = 20*log10(abs(h)); + figure; + semilogx(f,ITU,fc,ga,'x',fc,ga+tu,fc,ga+tl, f, my_w_db ); + grid on; xlabel('Hz'); ylabel('dB'); +end +end diff --git a/test/std_utils/thdnf_test_input.m b/test/std_utils/thdnf_test_input.m new file mode 100644 index 000000000000..b07f21f42e27 --- /dev/null +++ b/test/std_utils/thdnf_test_input.m @@ -0,0 +1,95 @@ +function test = thdnf_test_input(test) + +%% t = dr_test_input(t) +% +% Create tone data file for playback & record on real device or +% for algorithm simulation. +% +% Input parameters +% t.fs - sample rate +% t.bits_in - signal word length +% t.ch - mix test signal to channel ch +% t.nch - total number of channels in data +% +% Output parameters +% t.fn_in - created input file name +% t.fn_out - proposed output file name for captured output +% t.f - test signal frequency +% t.tl - tone length in seconds +% t.ts - tone start time +% t.tr - tone gain ramp length in seconds +% t.ti - ignore time from tone start and end, must be ti > tr +% t.a - tone amplitude (lin) +% t.a_db - tone amplitude (dB) +% t.mark_t - length of marker tone in seconds +% t.mark_a - amplitude max of marker tone (lin) +% t.mark_a_db - amplitude max of marker tone (dB) +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference: AES17 6.3.2 THD+N ratio vs frequency +% http://www.aes.org/publications/standards/ + +if nargin < 1 + fprintf('Warning, using default parameters!\n'); + test.fs = 48e3; test.f_start=20; test.f_end=20e3; test.bits_in=32; test.ch=1; test.nch=1; +end + +if test.ch == 0 + test.ch = 1+round(rand(1,1)*(test.nch-1)); % Test random channel 1..Nch +end + +fprintf('Using parameters Fstart=%.0f Hz, Fend=%.0f Hz, Fs=%.1f Hz, bits_in=%d, ch=%d, Nch=%d\n', ... + test.f_start, test.f_end, test.fs/1e3, test.bits_in, test.ch, test.nch ); + +test.fn_in = sprintf('thdnf_test_in.%s', test.fmt); +test.fn_out = sprintf('thdnf_test_out.%s', test.fmt); +noct = ceil(log(test.f_end/test.f_start)/log(2)); % Max 1 octave steps +test.f = logspace(log10(test.f_start),log10(test.f_end), noct); + + +%% Tone sweep parameters +test.is = 20e-3; % Ignore signal from tone start +test.ie = 20e-3; % Ignore signal from tone end +test.tr = 10e-3; % Gain ramp time for tones +test.sm = 3; % Seek start marker from 3s from start +test.em = 3; % Seek end marker from 3s from end +test.mt = 0.1; % Error if marker positions delta is greater than 0.1s +test.a_db = [-1 -20]; % -1 and -20 dBFS levels +test.a = 10.^(test.a_db/20); +test.tl = 4; % 3 seconds tone +test.nst = 2; % Wait 1 seconds for frequency specific notch output to settle + +%% Mix the input file for test and write output +test = mix_sweep(test); + +end diff --git a/test/std_utils/thdnf_test_measure.m b/test/std_utils/thdnf_test_measure.m new file mode 100644 index 000000000000..6e10f17b5f73 --- /dev/null +++ b/test/std_utils/thdnf_test_measure.m @@ -0,0 +1,83 @@ +function test = thdnf_test_measure(test) + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Reference: AES17 6.3.2 THD+N ratio vs frequency +% http://www.aes.org/publications/standards/ + +%% Load output file +[x, nx] = load_test_output(test); +if nx == 0 + test.g_db = NaN; + test.fail = 1; + return +end + +%% Standard low-pass +y0 = stdlpf(x, test.fu, test.fs); + +%% Find sync +[d, nt, nt_use, nt_skip] = find_test_signal(y0, test); + +%% Measure all test frequencies +ml = zeros(test.nf,test.na); +mn = zeros(test.nf,test.na); +n_notch_settle = round(test.fs*test.nst); +nn = 1; +for m=1:test.na + for n=1:test.nf + fprintf('Measuring %.0f Hz ...\n', test.f(n)); + i1 = d+(nn-1)*nt+nt_skip; + i2 = i1+nt_use-1; + nn = nn+1; + y0n = stdnotch(y0(i1:i2), test.f(n), test.fs); + ml(n,m) = level_dbfs(y0(i1:i2)); + mn(n,m) = level_dbfs(y0n(n_notch_settle:end)); + end +end + +test.thdnf = mn - ml; +test.thdnf_high = test.thdnf(:,1); +test.thdnf_low = test.thdnf(:,2); +if max(max(test.thdnf)) > test.thdnf_max + test.fail = 1; +else + test.fail = 0; +end + +test.fh = figure('visible', test.visible); +semilogx(test.f, test.thdnf(:,1), 'b', test.f, test.thdnf(:,2), 'g--'); +grid on; +xlabel('Frequency (Hz)'); +ylabel('THD+N (dB)'); +legend('-1 dBFS','-20 dBFS'); + +end From 1abae16a111ff4ca116f7b2704da276aaea2860a Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 27 Jun 2018 13:50:49 +0300 Subject: [PATCH 198/324] SOFT: Add various utility scripts for audio component tests This patch provides the non-standard based utilities to help to execute the tests. Signed-off-by: Seppo Ingalsuo --- test/test_utils/chirp_test_analyze.m | 91 +++++++++++++++++++++++ test/test_utils/chirp_test_input.m | 96 ++++++++++++++++++++++++ test/test_utils/delete_check.m | 35 +++++++++ test/test_utils/dither_and_quantize.m | 61 +++++++++++++++ test/test_utils/find_test_signal.m | 75 +++++++++++++++++++ test/test_utils/load_test_output.m | 87 ++++++++++++++++++++++ test/test_utils/mix_chirp.m | 82 ++++++++++++++++++++ test/test_utils/mix_sweep.m | 103 ++++++++++++++++++++++++++ test/test_utils/mkdir_check.m | 35 +++++++++ test/test_utils/multitone.m | 61 +++++++++++++++ test/test_utils/sync_chirp.m | 68 +++++++++++++++++ test/test_utils/test_run.m | 53 +++++++++++++ test/test_utils/write_test_data.m | 71 ++++++++++++++++++ 13 files changed, 918 insertions(+) create mode 100644 test/test_utils/chirp_test_analyze.m create mode 100644 test/test_utils/chirp_test_input.m create mode 100644 test/test_utils/delete_check.m create mode 100644 test/test_utils/dither_and_quantize.m create mode 100644 test/test_utils/find_test_signal.m create mode 100644 test/test_utils/load_test_output.m create mode 100644 test/test_utils/mix_chirp.m create mode 100644 test/test_utils/mix_sweep.m create mode 100644 test/test_utils/mkdir_check.m create mode 100644 test/test_utils/multitone.m create mode 100644 test/test_utils/sync_chirp.m create mode 100644 test/test_utils/test_run.m create mode 100644 test/test_utils/write_test_data.m diff --git a/test/test_utils/chirp_test_analyze.m b/test/test_utils/chirp_test_analyze.m new file mode 100644 index 000000000000..bd70adc17a69 --- /dev/null +++ b/test/test_utils/chirp_test_analyze.m @@ -0,0 +1,91 @@ +function test = chirp_test_analyze(test) + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Load output file +[x, nx] = load_test_output(test); +if nx < 1 + test.fail = -1; % No data + return; +end + +%% Find sync +[d, nt, nt_use, nt_skip] = find_test_signal(x, test); + +%% Trim sample +i1 = d+nt_skip; +i2 = i1+nt_use-1; +z = x(i1:i2, :); +y = z(:,test.ch); +s = sum(z,2); + +%% Quick check length, RMS, offset, and channels sum +sz = size(z); +tz = sz(1)/test.fs; +et = abs(test.cl-tz)/test.cl; +rms_db = 10*log10(mean(z.^2)) + 20*log10(sqrt(2)); +offs_db = 20*log10(abs(mean(z))); +sum_max_db = 20*log10(max(abs(s))); +% Check for proper ratio of out/in samples, minimum level, maximum offset +% and maximum of sum of channels. The input is such that the channels should +% sum to zero. A phase difference in channels would cause non-zero output +% for channels sum. Dithered input causes a small non-zero sum value. + +if et > 0.05 + fail = 1; + fprintf('Failed output chirp length, err=%f, t=%f.\n', et, tz); +else if (min(rms_db) < -3) && (test.fs2 + 1 > test.fs1) + fail = 1; + fprintf('Failed output chirp level.\n'); + else if max(offs_db) > -40 + fail = 1; + fprintf('Failed output chirp DC offset.\n'); + else if (sum_max_db > -100) && (mod(test.nch, 2) == 0) + fail = 1; + fprintf('Failed output chirp channels phase.\n'); + else + fail = 0; + end + end + end +end + +test.fh = figure('visible', test.visible); +ns = 1024; +no = round(0.9*ns); +specgram(y(:,1), ns, test.fs, kaiser(ns,27), no); +colormap('jet'); +caxis([-150 0]); +colorbar('EastOutside'); + +test.fail = fail; + +end diff --git a/test/test_utils/chirp_test_input.m b/test/test_utils/chirp_test_input.m new file mode 100644 index 000000000000..c4d07fbc09e9 --- /dev/null +++ b/test/test_utils/chirp_test_input.m @@ -0,0 +1,96 @@ +function test = chirp_test_input(test) + +%% t = dr_test_input(t) +% +% Create tone data file for playback & record on real device or +% for algorithm simulation. +% +% Input parameters +% t.fs - sample rate +% t.bits_in - signal word length +% t.ch - mix test signal to channel ch +% t.nch - total number of channels in data +% +% Output parameters +% t.fn_in - created input file name +% t.fn_out - proposed output file name for captured output +% t.f - test signal frequency +% t.tl - tone length in seconds +% t.ts - tone start time +% t.tr - tone gain ramp length in seconds +% t.ti - ignore time from tone start and end, must be ti > tr +% t.a - tone amplitude (lin) +% t.a_db - tone amplitude (dB) +% t.mark_t - length of marker tone in seconds +% t.mark_a - amplitude max of marker tone (lin) +% t.mark_a_db - amplitude max of marker tone (dB) +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +if nargin < 1 + fprintf('Warning, using default parameters!\n'); + test.fs = 48e3; test.bits=32; test.ch=1; test.nch=1; +end + +if test.ch == 0 + test.ch = 1:test.nch; % Test all channels 1..Nch +end + +fprintf('Using parameters Fs=%.1f, bits_in=%d', test.fs/1e3, test.bits_in); +fprintf(', ch=%d', test.ch ); +fprintf(', Nch=%d\n', test.nch ); + +test.fn_in = sprintf('chirp_test_in.%s', test.fmt); +test.fn_out = sprintf('chirp_test_out.%s', test.fmt); + + +%% Chirp parameters +test.a_db = -0.1; % Near full scale +test.a = 10^(test.a_db/20); +test.f_min = 20; +test.f_max = test.fs/2; +test.cl = 2.0; + + +%% Parameters to find signal between markers +test.nf = 1; +test.na = 1; +test.sm = 3; % Seek start marker from 3s from start +test.em = 3; % Seek end marker from 3s from end +test.mt = 0.3; % Error if marker positions delta is greater than 0.3s +test.is = 0; % Ignore signal from tone start +test.ie = 0; % Ignore signal from tone end + +%% Mix the input file for test and write output +test = mix_chirp(test); + +end diff --git a/test/test_utils/delete_check.m b/test/test_utils/delete_check.m new file mode 100644 index 000000000000..b3e1c8219fac --- /dev/null +++ b/test/test_utils/delete_check.m @@ -0,0 +1,35 @@ +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +function delete_check(really, f) +if really && exist(f) == 2 + delete(f); +end +end diff --git a/test/test_utils/dither_and_quantize.m b/test/test_utils/dither_and_quantize.m new file mode 100644 index 000000000000..56a2a58b71f2 --- /dev/null +++ b/test/test_utils/dither_and_quantize.m @@ -0,0 +1,61 @@ +%% xq = dither_and_quantize(x, bits) +% +% Input +% x - input signal +% bits - number of bits +% +% Output +% (int32) xq - scaled, dithered and quantized signal +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +function xq = dither_and_quantize(x, bits) + +if (bits > 32) || (bits < 1) + error('This function supports max 32 bits quantization!'); +end + +scale = 2^(bits-1); +smax = scale-1; +smin = -scale; +sx = size(x); +nx = sx(1); +nch = sx(2); + +xq = int32(floor( scale*x + randn(nx,nch) - randn(nx,nch) -0.5)); % TPDF dither +%xq = int32(round( scale*x )); % Omit dither +idx = find(xq > smax); +xq(idx) = smax; +idx = find(xq < smin); +xq(idx) = smin; + +end diff --git a/test/test_utils/find_test_signal.m b/test/test_utils/find_test_signal.m new file mode 100644 index 000000000000..4fcc3c2ddcd6 --- /dev/null +++ b/test/test_utils/find_test_signal.m @@ -0,0 +1,75 @@ +function [d, nt, nt_use, nt_skip] = find_test_signal(x, test) + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Find start marker +fprintf('Finding test start marker...\n'); +s = sync_chirp(test.fs, 'up'); +nx = length(x); +n_half = round(nx/2); +n = min(round(test.fs*test.sm), n_half); +y = x(1:n); +[r, lags] = xcorr(y, s); +[r_max, idx] = max(r); +d_start = lags(idx); + +%% Find end marker +fprintf('Finding test end marker...\n'); +s = sync_chirp(test.fs, 'down'); +n = min(round(test.fs*test.em),n_half); +y = x(end-n+1:end); +[r, lags] = xcorr(y, s); +[r_max, idx] = max(r); +d_end = nx-n+lags(idx); + +%% Check correct length of signal +len = d_end-d_start; +len_s = len/test.fs; +ref_s = test.mark_t+test.nf*test.na*test.tl; +if abs(len_s-ref_s) > test.mt + len_s + ref_s + error('Start and end markers were not found. Test play or capture quality may be poor'); +end + +%% Delay to first tone, length of tone in samples +d = d_start + round(test.mark_t*test.fs); +if (d < 0) + error('Invalid negative delay seen. Test play or capture quality may be poor'); +end +nt = round(test.tl*test.fs); +nt_use = nt -round(test.is*test.fs) -round(test.ie*test.fs); +if nt_use < 0 + error('Test signal length parameters must be wrong!'); +end +nt_skip = round(test.is*test.fs); + +end diff --git a/test/test_utils/load_test_output.m b/test/test_utils/load_test_output.m new file mode 100644 index 000000000000..320a4d633b4c --- /dev/null +++ b/test/test_utils/load_test_output.m @@ -0,0 +1,87 @@ +function [x, nx] = load_test_output(test) + +%% [x, n] = load_test_output(t) +% +% Input +% t.fn_out - file name to load +% t.bits_out - word length of data +% t.fmt - file format 'raw' or 'txt +% t.ch - channel to extract +% t.nch - number of channels in (interleaved) data +% +% Output +% x - samples +% n - number of samples +% + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Integer type for binary files +switch test.bits_out + case 16 + bfmt = 'int16'; + case 24 + bfmt = 'int32'; + case 32 + bfmt = 'int32'; + otherwise + error('Bits_out must be 16, 24, or 32.'); +end + +%% Check that output file exists +if exist(test.fn_out) + fprintf('Reading output data file %s...\n', test.fn_out); + switch lower(test.fmt) + case 'txt' + out = load(test.fn_out); + case 'raw' + fh = fopen(test.fn_out, 'r'); + out = fread(fh, inf, bfmt); + fclose(fh); + otherwise + error('Fmt must be raw or txt.'); + end +else + out = []; +end + +%% Exctract channels to measure +scale = 1/2^(test.bits_out-1); +lout = length(out); +nx = floor(lout/test.nch); +x = zeros(nx,length(test.ch)); +j = 1; +for ch = test.ch + x(:,j) = out(ch:test.nch:end)*scale; + j = j + 1; +end + +end diff --git a/test/test_utils/mix_chirp.m b/test/test_utils/mix_chirp.m new file mode 100644 index 000000000000..6340ad896476 --- /dev/null +++ b/test/test_utils/mix_chirp.m @@ -0,0 +1,82 @@ +function test = mix_chirp(test) + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Adjust tone length to integer number of samples +test.nt = round(test.cl*test.fs); % Make number of samples per tone +test.tl = test.nt/test.fs; % an integer by adjusting tl. + +%% Test start and end marker tones +[h1, mark_start] = sync_chirp(test.fs, 'up'); +[h2, mark_end] = sync_chirp(test.fs, 'down'); +test.mark_t = mark_start.t; +test.mark_a = mark_start.a; +test.mark_a_db = mark_start.a_db; +test.ts = mark_start.t; + +%% Idle time to start and end +t_idle0 = 0.5; +n_idle = round(test.fs*t_idle0); +t_idle = n_idle/test.fs; +x = zeros(test.nt + mark_start.n + mark_end.n +2*n_idle, test.nch, 'int32'); + +%% Add markers +idx1 = n_idle+1; +idx2 = length(x)-n_idle-mark_end.n; +for ch=test.ch + x(idx1:idx1+mark_start.n-1, ch) = dither_and_quantize(h1, test.bits_in); + x(idx2:idx2+mark_end.n-1, ch) = dither_and_quantize(h2, test.bits_in); +end + +%% Dither also idle parts +x(1:n_idle) = dither_and_quantize(zeros(n_idle,1), test.bits_in); +x(end-n_idle+1:end) = dither_and_quantize(zeros(n_idle,1), test.bits_in); + +%% Add Chirp +i1 = n_idle+mark_start.n+1; +i2 = i1+test.nt-1; +fprintf('Mixing %.1f dBFS chirp ...\n', test.a_db); +tc = ((1:round(test.cl*test.fs))-1)/test.fs; +s = test.a * chirp(tc, test.f_min, test.tl, test.f_max, 'linear'); +sign = 1; +for ch=test.ch + x(i1:i2, ch) = dither_and_quantize(sign * s, test.bits_in); + sign = -sign; +end + +test.signal = x; + +%% Output +fprintf('Writing output data file %s...\n', test.fn_in); +write_test_data(x, test.fn_in, test.bits_in, test.fmt); +fprintf('Done.\n') + +end diff --git a/test/test_utils/mix_sweep.m b/test/test_utils/mix_sweep.m new file mode 100644 index 000000000000..5971f0d4f5fd --- /dev/null +++ b/test/test_utils/mix_sweep.m @@ -0,0 +1,103 @@ +function test = mix_sweep(test) + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Adjust tone lengt to integer number of samples +test.nt = round(test.tl*test.fs); % Make number of samples per tone +test.tl = test.nt/test.fs; % an integer by adjusting tl. +test.nf = length(test.f); % Number of frequencies +test.na = length(test.a); % Number of amplitudes + +%% Test start and end marker tones +[h1, mark_start] = sync_chirp(test.fs, 'up'); +[h2, mark_end] = sync_chirp(test.fs, 'down'); +test.mark_t = mark_start.t; +test.mark_a = mark_start.a; +test.mark_a_db = mark_start.a_db; +test.ts = mark_start.t; + +%% Idle time to start and end +t_idle0 = 0.5; +n_idle = round(test.fs*t_idle0); +t_idle = n_idle/test.fs; +x = zeros(test.nf*test.na*test.nt +mark_start.n +mark_end.n +2*n_idle, ... + test.nch, 'int32'); + +%% Add markers +idx1 = n_idle+1; +idx2 = length(x)-n_idle-mark_end.n; +for ch=test.ch + x(idx1:idx1+mark_start.n-1, ch) = dither_and_quantize(h1, test.bits_in); + x(idx2:idx2+mark_end.n-1, ch) = dither_and_quantize(h2, test.bits_in); +end + +%% Dither also idle parts +x(1:n_idle) = dither_and_quantize(zeros(n_idle,1), test.bits_in); +x(end-n_idle+1:end) = dither_and_quantize(zeros(n_idle,1), test.bits_in); + +%% Add discrete frequencies sweep +n_r = round(test.fs*test.tr); +win = ones(test.nt,1); +win(1:n_r) = linspace(0,1,n_r); +win(end-n_r+1:end) = linspace(1,0,n_r); +i0 = n_idle+mark_start.n+1; +nn = 1; +for m=1:test.na + for n=1:test.nf + i1 = i0 + (nn-1)*test.nt+1; + i2 = i1+test.nt-1; + nn = nn+1; + if length(test.f) > 1 + f = test.f(n); + else + f = test.f; + end + if length(test.a) > 1 + a = test.a(m); + else + a = test.a; + end + fprintf('Mixing %.0f Hz %.1f dBFS sine ...\n', f, 20*log10(a)); + s = multitone(test.fs, f, a, test.tl); + for ch=test.ch + x(i1:i2, ch) = dither_and_quantize(s.*win, test.bits_in); + end + end +end + +test.signal = x; + +%% Output +fprintf('Writing output data file %s...\n', test.fn_in); +write_test_data(x, test.fn_in, test.bits_in, test.fmt); +fprintf('Done.\n') + +end diff --git a/test/test_utils/mkdir_check.m b/test/test_utils/mkdir_check.m new file mode 100644 index 000000000000..b453d0b8d898 --- /dev/null +++ b/test/test_utils/mkdir_check.m @@ -0,0 +1,35 @@ +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +function d = mkdir_check(d) +if exist(d) ~= 7 + mkdir(d); +end +end diff --git a/test/test_utils/multitone.m b/test/test_utils/multitone.m new file mode 100644 index 000000000000..7f3faa37f9bd --- /dev/null +++ b/test/test_utils/multitone.m @@ -0,0 +1,61 @@ +function x = multitone( fs, f, amp, tlength ) + +%% +% Create single or multiple sine wave(s) +% +% x = multitone(fs, f, a, t); +% +% fs - Sample rate +% f - Frequency (Hz) +% a - Amplitude (lin) +% t - Lenght in seconds +% +% Example: +% x = multitone(48000, [997 1997], 10.^([-26 -46]/20), 1.0); +% + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +n = round(fs*tlength); +t = (0:n-1)/fs; +nf = length(f); +if nf > 1 + ph = rand(nf, 1)*2*pi; +else + ph = 0; +end + +x = amp(1)*sin(2*pi*f(1)*t'); +for i=2:length(f) + x = x + amp(i)*sin(2*pi*f(i)*t+ph(i)); +end + +end diff --git a/test/test_utils/sync_chirp.m b/test/test_utils/sync_chirp.m new file mode 100644 index 000000000000..513a426904a0 --- /dev/null +++ b/test/test_utils/sync_chirp.m @@ -0,0 +1,68 @@ +function [y, mark]= sync_chirp(fs, direction) + +%% [y, mark]= sync_chirp(fs, direction) +% +% Returns a chirp signal that can be used to mark end and beginning of audio +% tests to syncronize input and captured output accurately. +% +% Input +% fs - sample rate +% direction - direction of frequency sweep 'up' or 'down' +% +% Output +% y - windowed chirp signal +% mark - struct with parameters for chirp +% + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +mark.a_db = -10; +mark.a = 10^(mark.a_db/20); +mark.fs = fs; +mark.t = 0.2; % Short, to not consume much test time +switch lower(direction) + case 'up' + mark.f0 = 200; % Should work with any speaker + mark.f1 = 3500; % Should work with any speaker + case 'down' + mark.f1 = 200; % Should work with any speaker + mark.f0 = 3500; % Should work with any speaker + otherwise + error('Parameter direction must be ''up'' or ''down'''); +end + +mark.n = round(mark.t*fs); +t_vec = (0:mark.n-1)/fs; +w = hanning(mark.n); +x = chirp(t_vec, mark.f0, mark.t, mark.f1, 'linear')'; +y = x .* w * mark.a; + +end diff --git a/test/test_utils/test_run.m b/test/test_utils/test_run.m new file mode 100644 index 000000000000..1eb34057f48f --- /dev/null +++ b/test/test_utils/test_run.m @@ -0,0 +1,53 @@ +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +function test = test_run(test) + +if exist(test.ex) == 2 + %fcmd = sprintf('file %s', test.ex); + %[status, output]=system(fcmd); + %if findstr(output, "Tensilica Xtensa") + % ex = sprintf('xt-run --turbo --summary %s', test.ex); + %else + ex = test.ex; + %end +else + error('Can''t find executable %s', test.ex); +end +test.narg = length(test.arg); +arg = ''; +for n=1:test.narg + arg = sprintf('%s %s', arg, char(test.arg(n))); +end +rcmd = sprintf('%s %s', ex, arg); +fprintf('Running ''%s''...\n', rcmd); +system(rcmd); + +end diff --git a/test/test_utils/write_test_data.m b/test/test_utils/write_test_data.m new file mode 100644 index 000000000000..e998fff3446d --- /dev/null +++ b/test/test_utils/write_test_data.m @@ -0,0 +1,71 @@ +function write_test_data(x, fn, bits, fmt) + +%% +% Copyright (c) 2017, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +switch lower(fmt) + case 'raw' + fh = fopen(fn, 'wb'); + case 'txt' + fh = fopen(fn, 'w'); + otherwise + error('The file format must be raw or txt'); +end +switch bits + case 16 + bfmt = 'int16'; + case 24 + bfmt = 'int32'; + case 32 + bfmt = 'int32'; + otherwise + error('The bits must be set to 16, 24, or 32'); +end + +%% Interleave the channels if two or more +sx = size(x); +xi = zeros(sx(1)*sx(2), 1, bfmt); +if sx(2) > 1 + for n=1:sx(2) + xi(n:sx(2):end) = x(:,n); + end +else + xi(1:end) = x; +end + +%% Write file and close +if strcmp(lower(fmt), 'raw') + fwrite(fh, xi, bfmt); +else + fprintf(fh,'%d\n', xi); +end +fclose(fh); + +end From 934a3300d67bc55b399e19c0494364b6690c324b Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 27 Jun 2018 15:43:00 +0300 Subject: [PATCH 199/324] SOFT: Fix the topology file name in SRC test topology lookup The topology files naming has been updated to include mclk-N so it needs to be added here as well for the script src_run.sh to work. Signed-off-by: Seppo Ingalsuo --- test/src_run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/src_run.sh b/test/src_run.sh index 632de859dca2..93c67db888bb 100755 --- a/test/src_run.sh +++ b/test/src_run.sh @@ -18,7 +18,7 @@ HOST_LIB=$HOST_ROOT/lib INFMT=s${BITS_IN}le OUTFMT=s${BITS_IN}le MCLK=24576k -TPLG=../topology/test/test-playback-ssp2-I2S-${COMP}-${INFMT}-${OUTFMT}-48k-${MCLK}-nocodec.tplg +TPLG=../topology/test/test-playback-ssp2-mclk-0-I2S-${COMP}-${INFMT}-${OUTFMT}-48k-${MCLK}-nocodec.tplg # If binary test vectors if [ ${FN_IN: -4} == ".raw" ]; then From dc0d9e028e0e7f7feb1fda344bc64bb2edd37601 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 27 Jun 2018 16:44:43 +0300 Subject: [PATCH 200/324] SOFT: Increase SRC playback topology buffer size This patch increases the SRC source buffer to contain 5 periods of data (measured for 1 ms @ 48 kHz ). It fixes the issue in 176.4 kHz to 48 kHz playback conversion that the pipeline freezes with insufficient available data in source buffer for SRC to convert and too little free in buffer for host to fill another 48 frames. 176.4 kHz playback is currently the largest buffer size consumer due to non-steady in/out rate. The higher rate conversion 192 kHz to 48 kHz can operate with smaller size buffer due to steady in/out rate. Note: This has been only simulated in the host test bench since SRC playback does not run currently in real devices due to another issue. However since buffers simulation is accurate this should be a real issue. Signed-off-by: Seppo Ingalsuo --- topology/sof/pipe-src-playback.m4 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index 16991985564b..0aa0f5c66cc8 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -17,8 +17,8 @@ include(`pipeline.m4') # # Host "Passthrough Playback" PCM -# with 4 sink and 0 source periods -W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 4, 0, 2) +# with 5 sink and 0 source periods +W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 5, 0, 2) # # SRC Configuration @@ -28,11 +28,11 @@ W_VENDORTUPLES(media_src_tokens, sof_src_tokens, LIST(` ', `SOF_TKN_SRC_RATE_OU W_DATA(media_src_conf, media_src_tokens) -# "SRC" has 4 source and 4 sink periods -W_SRC(0, PIPELINE_FORMAT, 4, 4, media_src_conf, 2) +# "SRC" has 5 source and 4 sink periods +W_SRC(0, PIPELINE_FORMAT, 5, 4, media_src_conf, 2) # Playback Buffers -W_BUFFER(0, COMP_BUFFER_SIZE(4, +W_BUFFER(0, COMP_BUFFER_SIZE(5, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), PLATFORM_HOST_MEM_CAP) W_BUFFER(1, COMP_BUFFER_SIZE(4, From 254013aa9402039b3f6ff8bd2d2b2d20b6da2d75 Mon Sep 17 00:00:00 2001 From: Wu Zhigang Date: Thu, 28 Jun 2018 10:27:36 +0800 Subject: [PATCH 201/324] topology: ssp2 should be 8 channels this is typo error. ssp2 should be 8-channel Signed-off-by: Wu Zhigang --- topology/sof-apl-tdf8532.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index a37e5216a5a2..a76ccaf78de5 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -190,7 +190,7 @@ DAI_CONFIG(SSP, 2, 2, SSP2-Codec, SSP_CONFIG(DSP_B, SSP_CLOCK(mclk, 24576000, codec_mclk_in), SSP_CLOCK(bclk, 12288000, codec_slave), SSP_CLOCK(fsync, 48000, codec_slave), - SSP_TDM(2, 32, 255, 255), + SSP_TDM(8, 32, 255, 255), SSP_CONFIG_DATA(SSP, 2, 32))) DAI_CONFIG(SSP, 0, 0, SSP0-Codec, From 3540310eea01247bc6cf86165c3ece01094674a5 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 28 Jun 2018 13:26:11 +0300 Subject: [PATCH 202/324] SOFT: Extend PCM parameters range in passtrough capture pipelines for DMIC This patch extends the allowed sample rate range to 8 - 192 kHz, and channels count to 1 - 16. Previously only 48 kHz and 2 - 4 channels was allowed. Signed-off-by: Seppo Ingalsuo --- topology/sof/pipe-passthrough-capture.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index 1dc695c3dcba..4614083111ee 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -44,4 +44,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID # PCM Configuration # -PCM_CAPABILITIES(Passthrough Capture PCM_ID, COMP_FORMAT_NAME(PIPELINE_FORMAT), 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Capture PCM_ID, COMP_FORMAT_NAME(PIPELINE_FORMAT), 8000, 192000, 1, 16, 2, 16, 192, 16384, 65536, 65536) From 17f5a08d2e1c40a5cea528cce84536b1f80d5ff1 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 28 Jun 2018 14:39:36 +0300 Subject: [PATCH 203/324] SOFT: Increase test capture pipeline max. channels count to 4 The 4ch DMIC capture test topologies can't work without this change to pipeline. Signed-off-by: Seppo Ingalsuo --- topology/test/test-capture.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/test/test-capture.m4 b/topology/test/test-capture.m4 index 1102c415e8e1..b21a47f725a6 100644 --- a/topology/test/test-capture.m4 +++ b/topology/test/test-capture.m4 @@ -39,11 +39,11 @@ include(`byt.m4') # PCM0 <---> SSP TEST_DAI_PORT # -# Passthrough playback pipeline 2 on PCM 0 using max 2 channels of s24le. +# Passthrough capture pipeline 2 on PCM 0 using max 4 channels. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-capture.m4, - 2, 0, 2, TEST_PIPE_FORMAT, + 2, 0, 4, TEST_PIPE_FORMAT, 48, 1000, 0, 0, TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_FORMAT, 2) From 707d6d6a5c259bd19fa0cb016da88710dd114d32 Mon Sep 17 00:00:00 2001 From: Wu Zhigang Date: Thu, 28 Jun 2018 13:10:31 +0800 Subject: [PATCH 204/324] topology: reorder the ssp setting by increasing order reorder the ssp setting according on the ssp port number from ssp0~ssp5. make it more clear. Signed-off-by: Wu Zhigang --- topology/sof-apl-tdf8532.m4 | 75 ++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index a76ccaf78de5..8421c077ee2e 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -97,27 +97,6 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, # DAIs configuration # -# playback DAI is SSP4 using 2 periods -# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 1, SSP, 4, SSP4-Codec, - PIPELINE_SOURCE_1, 2, s32le, - 48, 1000, 0, 0) - -# playback DAI is SSP2 using 2 periods -# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 2, SSP, 2, SSP2-Codec, - PIPELINE_SOURCE_2, 2, s32le, - 48, 1000, 0, 0) - -# capture DAI is SSP2 using 2 periods -# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-capture.m4, - 3, SSP, 2, SSP2-Codec, - PIPELINE_SINK_3, 2, s32le, - 48, 1000, 0, 0) - # playback DAI is SSP0 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, @@ -139,6 +118,20 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_6, 2, s16le, 48, 1000, 0, 0) +# playback DAI is SSP2 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 2, SSP, 2, SSP2-Codec, + PIPELINE_SOURCE_2, 2, s32le, + 48, 1000, 0, 0) + +# capture DAI is SSP2 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 3, SSP, 2, SSP2-Codec, + PIPELINE_SINK_3, 2, s32le, + 48, 1000, 0, 0) + # playback DAI is SSP3 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, @@ -153,6 +146,13 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_8, 2, s16le, 48, 1000, 0, 0) +# playback DAI is SSP4 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 4, SSP4-Codec, + PIPELINE_SOURCE_1, 2, s32le, + 48, 1000, 0, 0) + # playback DAI is SSP5 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, @@ -168,31 +168,16 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency, id 0 -PCM_PLAYBACK_ADD(Port4, 0, 0, 0, PIPELINE_PCM_1) -PCM_DUPLEX_ADD(Port2, 1, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) PCM_DUPLEX_ADD(Port0, 2, 2, 2, PIPELINE_PCM_4, PIPELINE_PCM_5) PCM_CAPTURE_ADD(Port1, 3, 3, 3, PIPELINE_PCM_6) +PCM_DUPLEX_ADD(Port2, 1, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) PCM_DUPLEX_ADD(Port3, 4, 4, 4, PIPELINE_PCM_7, PIPELINE_PCM_8) +PCM_PLAYBACK_ADD(Port4, 0, 0, 0, PIPELINE_PCM_1) PCM_DUPLEX_ADD(Port5, 5, 5, 5, PIPELINE_PCM_9, PIPELINE_PCM_10) # # BE configurations - overrides config in ACPI if present # - -DAI_CONFIG(SSP, 4, 4, SSP4-Codec, - SSP_CONFIG(DSP_B, SSP_CLOCK(mclk, 24576000, codec_mclk_in), - SSP_CLOCK(bclk, 12288000, codec_slave), - SSP_CLOCK(fsync, 48000, codec_slave), - SSP_TDM(8, 32, 15, 15), - SSP_CONFIG_DATA(SSP, 4, 32))) - -DAI_CONFIG(SSP, 2, 2, SSP2-Codec, - SSP_CONFIG(DSP_B, SSP_CLOCK(mclk, 24576000, codec_mclk_in), - SSP_CLOCK(bclk, 12288000, codec_slave), - SSP_CLOCK(fsync, 48000, codec_slave), - SSP_TDM(8, 32, 255, 255), - SSP_CONFIG_DATA(SSP, 2, 32))) - DAI_CONFIG(SSP, 0, 0, SSP0-Codec, SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), SSP_CLOCK(bclk, 1536000, codec_slave), @@ -207,6 +192,13 @@ DAI_CONFIG(SSP, 1, 1, SSP1-Codec, SSP_TDM(2, 16, 3, 3), SSP_CONFIG_DATA(SSP, 1, 16))) +DAI_CONFIG(SSP, 2, 2, SSP2-Codec, + SSP_CONFIG(DSP_B, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 12288000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(8, 32, 255, 255), + SSP_CONFIG_DATA(SSP, 2, 32))) + DAI_CONFIG(SSP, 3, 3, SSP3-Codec, SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), SSP_CLOCK(bclk, 1536000, codec_slave), @@ -214,6 +206,13 @@ DAI_CONFIG(SSP, 3, 3, SSP3-Codec, SSP_TDM(2, 16, 3, 3), SSP_CONFIG_DATA(SSP, 3, 16))) +DAI_CONFIG(SSP, 4, 4, SSP4-Codec, + SSP_CONFIG(DSP_B, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 12288000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(8, 32, 15, 15), + SSP_CONFIG_DATA(SSP, 4, 32))) + DAI_CONFIG(SSP, 5, 5, SSP5-Codec, SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), SSP_CLOCK(bclk, 1536000, codec_slave), From f359214717ee40bcc3f0bd32dd12cbe0fa9219df Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 29 Jun 2018 15:45:15 +0800 Subject: [PATCH 205/324] Revert "topology: dai: correct default_hw_conf_id" This reverts commit 229da95e0d5a9d8abce89a5bb3804926b74d1ba0 which call regression: https://github.com/thesofproject/soft/issues/15 Default_hw_conf_id is id, not index of array, revert to fix it. Signed-off-by: Keyon Jie --- topology/m4/dai.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index 65988ce9d446..b0802affd733 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -145,7 +145,7 @@ define(`DAI_CONFIG', `SectionBE."'$4`" {' ` id "'$3`"' ` index "0"' -` default_hw_conf_id "0"' +` default_hw_conf_id "'$2`"' `' ` hw_configs [' ` "'$1$2`"' From 6da473ebabc4f57ddd6b87387ced4d04d12c4c70 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 29 Jun 2018 17:06:50 +0800 Subject: [PATCH 206/324] topology: sof-apl-nocodec: fix a comment typo Signed-off-by: Keyon Jie --- topology/sof-apl-nocodec.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 3ba5806d7979..823674e3159f 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -31,7 +31,7 @@ include(`platform/intel/bxt.m4') # PCM4 ----> volume -----> SSP4 # <---- Volume <----- SSP4 # PCM5 ----> volume -----> SSP5 -# <---- volume <----- SSP3 +# <---- volume <----- SSP5 # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s16le. From b5abe7194bb63708aff293c54838c74da946ae36 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 29 Jun 2018 18:05:23 +0800 Subject: [PATCH 207/324] topology: initial topology file for UP^2 Signed-off-by: Keyon Jie --- topology/Makefile.am | 6 ++- topology/sof-apl-pcm512x.m4 | 93 +++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 topology/sof-apl-pcm512x.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index b59c6f588079..c6868e1245f6 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -29,7 +29,8 @@ MACHINES = \ sof-byt-da7213.tplg \ sof-cnl-rt274.tplg \ sof-hsw-rt5640.tplg \ - sof-apl-tdf8532.tplg + sof-apl-tdf8532.tplg \ + sof-apl-pcm512x.tplg # Uncomment the following line if you want to debug conf files .PRECIOUS: %.conf @@ -59,4 +60,5 @@ EXTRA_DIST = \ sof-byt-da7213.m4 \ sof-cnl-rt274.m4 \ sof-hsw-rt5640.m4 \ - sof-apl-tdf8532.m4 + sof-apl-tdf8532.m4 \ + sof-apl-pcm512x.m4 diff --git a/topology/sof-apl-pcm512x.m4 b/topology/sof-apl-pcm512x.m4 new file mode 100644 index 000000000000..3412559a1c21 --- /dev/null +++ b/topology/sof-apl-pcm512x.m4 @@ -0,0 +1,93 @@ +# +# Topology for generic Apollolake UP^2 with pcm512x codec. +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') +include(`ssp.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`platform/intel/bxt.m4') +include(`platform/intel/dmic.m4') + +# +# Define the pipelines +# +# PCM0 <---- volume <----- DMIC0 (SSP3) +# PCM1 ----> volume -----> SSP5 (pcm512x) +# <---- volume <----- SSP5 +# + +# Low Latency capture pipeline 1 on PCM 0 using max 4 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 1, 0, 4, s32le, + 48, 1000, 0, 0, DMIC, 0, s32le, 2) + +# Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 2, 1, 2, s16le, + 48, 1000, 0, 0, SSP, 5, s16le, 2) + +# Low Latency capture pipeline 3 on PCM 1 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 3, 1, 2, s16le, + 48, 1000, 0, 0, SSP, 5, s16le, 2) + + +# +# DAIs configuration +# + +# capture DAI is DMIC0 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, DMIC, 0, DMIC0, + PIPELINE_SINK_1, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is SSP5 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 2, SSP, 5, SSP5-Codec, + PIPELINE_SOURCE_2, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP5 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 3, SSP, 5, SSP5-Codec, + PIPELINE_SINK_3, 2, s16le, + 48, 1000, 0, 0) + + +# PCM Low Latency, id 0 +PCM_CAPTURE_ADD(Dmic0, 0, 0, 0, PIPELINE_PCM_1) +PCM_DUPLEX_ADD(Port5, 1, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) + +# +# BE configurations - overrides config in ACPI if present +# + +DAI_CONFIG(DMIC, 0, 0, DMIC0, + DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, + DMIC_WORD_LENGTH(s32le), DMIC, 0, + PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) + +DAI_CONFIG(SSP, 5, 1, SSP5-Codec, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), + SSP_CONFIG_DATA(SSP, 5, 16))) + From 2cc0d1f9c614d8b18f1557b5cf957fd5cd801cbc Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 29 Jun 2018 17:05:40 +0300 Subject: [PATCH 208/324] SOFT: Improve audio test synchronization code The audio tests signals contain a start and end marker to extract the test output to analyze from in-between the markers. This patch fixes a fail in SRC tests that was caused by incorrect synchronization to output data. The chirp upper frequency is limited to 0.99 x Nyquist frequency since the Nyquist frequency in the end aliased and caused a visible artefact to spectral plot and it triggered a resampler filter impulse response that had some correlation with start/end marker chirps. The cosine chirp initialization to start from 90 degrees (zero PCM code instead of max.) also cleaned the start impulse and improved the look of spectrogram plot. The syncronization was limited to seek from one measured channel only. The sync finder also didn't handle properly multi-channel input. The output file start marker scan length was reduced to be idle+marker length. And the scan time for end was reduced to be 2xidle+marker length Signed-off-by: Seppo Ingalsuo --- test/test_utils/chirp_test_analyze.m | 2 +- test/test_utils/chirp_test_input.m | 2 +- test/test_utils/find_test_signal.m | 7 ++++--- test/test_utils/mix_chirp.m | 6 +++--- test/test_utils/mix_sweep.m | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/test/test_utils/chirp_test_analyze.m b/test/test_utils/chirp_test_analyze.m index bd70adc17a69..e7026f61f5e6 100644 --- a/test/test_utils/chirp_test_analyze.m +++ b/test/test_utils/chirp_test_analyze.m @@ -38,7 +38,7 @@ end %% Find sync -[d, nt, nt_use, nt_skip] = find_test_signal(x, test); +[d, nt, nt_use, nt_skip] = find_test_signal(x(:,test.ch(1)), test); %% Trim sample i1 = d+nt_skip; diff --git a/test/test_utils/chirp_test_input.m b/test/test_utils/chirp_test_input.m index c4d07fbc09e9..89b2861e538b 100644 --- a/test/test_utils/chirp_test_input.m +++ b/test/test_utils/chirp_test_input.m @@ -77,7 +77,7 @@ test.a_db = -0.1; % Near full scale test.a = 10^(test.a_db/20); test.f_min = 20; -test.f_max = test.fs/2; +test.f_max = 0.99*test.fs/2; test.cl = 2.0; diff --git a/test/test_utils/find_test_signal.m b/test/test_utils/find_test_signal.m index 4fcc3c2ddcd6..fee52d56bac0 100644 --- a/test/test_utils/find_test_signal.m +++ b/test/test_utils/find_test_signal.m @@ -34,8 +34,8 @@ fprintf('Finding test start marker...\n'); s = sync_chirp(test.fs, 'up'); nx = length(x); -n_half = round(nx/2); -n = min(round(test.fs*test.sm), n_half); +n_seek = round(test.fs*(test.idle_t + test.mark_t)); +n = min(round(test.fs*test.sm), n_seek); y = x(1:n); [r, lags] = xcorr(y, s); [r_max, idx] = max(r); @@ -44,7 +44,8 @@ %% Find end marker fprintf('Finding test end marker...\n'); s = sync_chirp(test.fs, 'down'); -n = min(round(test.fs*test.em),n_half); +n_seek = round(test.fs*(2*test.idle_t + test.mark_t)); +n = min(round(test.fs*test.em),n_seek); y = x(end-n+1:end); [r, lags] = xcorr(y, s); [r_max, idx] = max(r); diff --git a/test/test_utils/mix_chirp.m b/test/test_utils/mix_chirp.m index 6340ad896476..9b57f2c74e79 100644 --- a/test/test_utils/mix_chirp.m +++ b/test/test_utils/mix_chirp.m @@ -43,8 +43,8 @@ test.ts = mark_start.t; %% Idle time to start and end -t_idle0 = 0.5; -n_idle = round(test.fs*t_idle0); +test.idle_t = 0.5; +n_idle = round(test.fs*test.idle_t); t_idle = n_idle/test.fs; x = zeros(test.nt + mark_start.n + mark_end.n +2*n_idle, test.nch, 'int32'); @@ -65,7 +65,7 @@ i2 = i1+test.nt-1; fprintf('Mixing %.1f dBFS chirp ...\n', test.a_db); tc = ((1:round(test.cl*test.fs))-1)/test.fs; -s = test.a * chirp(tc, test.f_min, test.tl, test.f_max, 'linear'); +s = test.a * chirp(tc, test.f_min, test.tl, test.f_max, 'linear', 90); sign = 1; for ch=test.ch x(i1:i2, ch) = dither_and_quantize(sign * s, test.bits_in); diff --git a/test/test_utils/mix_sweep.m b/test/test_utils/mix_sweep.m index 5971f0d4f5fd..1b76437b8588 100644 --- a/test/test_utils/mix_sweep.m +++ b/test/test_utils/mix_sweep.m @@ -45,8 +45,8 @@ test.ts = mark_start.t; %% Idle time to start and end -t_idle0 = 0.5; -n_idle = round(test.fs*t_idle0); +test.idle_t = 0.5; +n_idle = round(test.fs*test.idle_t); t_idle = n_idle/test.fs; x = zeros(test.nf*test.na*test.nt +mark_start.n +mark_end.n +2*n_idle, ... test.nch, 'int32'); From fa2e98a118a575274542505073ed563427bfefd8 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Wed, 4 Jul 2018 14:04:48 +0800 Subject: [PATCH 209/324] SOFT: fix this topology failed to be loaded Set dai id number according to NoCodec-id Signed-off-by: Rander Wang --- topology/sof-byt-nocodec.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 index 2345fa51e140..3c5260366240 100644 --- a/topology/sof-byt-nocodec.m4 +++ b/topology/sof-byt-nocodec.m4 @@ -91,7 +91,7 @@ PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 2, 0, NoCodec-2, +DAI_CONFIG(SSP, 2, 2, NoCodec-2, SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), SSP_CLOCK(bclk, 2400000, codec_slave), SSP_CLOCK(fsync, 48000, codec_slave), From dfe7fa919622406515c6644bc6038f60a932be1b Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Fri, 6 Jul 2018 17:50:51 +0800 Subject: [PATCH 210/324] topology: test: set id to 0 for codec topology For nocodec topology, we need the id to be same with SSP index since all SSP ports are enabled in nocodec. Codec machine drivers always have id to 0. Signed-off-by: Pan Xiuli --- topology/test/test-all.m4 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/topology/test/test-all.m4 b/topology/test/test-all.m4 index 8f9747c3ecf5..4f4241fb13fb 100644 --- a/topology/test/test-all.m4 +++ b/topology/test/test-all.m4 @@ -85,7 +85,9 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_DAI_PORT # -DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, TEST_DAI_PORT, TEST_DAI_LINK_NAME, +DAI_CONFIG(TEST_DAI_TYPE, TEST_DAI_PORT, + ifelse(index(TEST_DAI_LINK_NAME, NoCodec), -1, 0 ,TEST_DAI_PORT), + TEST_DAI_LINK_NAME, SSP_CONFIG(TEST_SSP_MODE, SSP_CLOCK(mclk, TEST_SSP_MCLK, codec_mclk_in), SSP_CLOCK(bclk, TEST_SSP_BCLK, codec_slave), From 794cf7a7077b44bc603e640b95d59d1ce4869b9c Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Fri, 6 Jul 2018 17:53:06 +0800 Subject: [PATCH 211/324] topology: fix id for sof_apl_pcm512x topology SSP5 id should be kept to 0 and new added DMIC goes to 1 to keep old machine driver work with both old topology and this topology. Signed-off-by: Pan Xiuli --- topology/sof-apl-pcm512x.m4 | 55 ++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 29 deletions(-) diff --git a/topology/sof-apl-pcm512x.m4 b/topology/sof-apl-pcm512x.m4 index 3412559a1c21..703aa02a414b 100644 --- a/topology/sof-apl-pcm512x.m4 +++ b/topology/sof-apl-pcm512x.m4 @@ -21,73 +21,70 @@ include(`platform/intel/dmic.m4') # # Define the pipelines # -# PCM0 <---- volume <----- DMIC0 (SSP3) -# PCM1 ----> volume -----> SSP5 (pcm512x) +# PCM0 ----> volume -----> SSP5 (pcm512x) # <---- volume <----- SSP5 +# PCM1 <---- volume <----- DMIC0 (SSP3) # -# Low Latency capture pipeline 1 on PCM 0 using max 4 channels of s32le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, - 1, 0, 4, s32le, - 48, 1000, 0, 0, DMIC, 0, s32le, 2) - # Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, - 2, 1, 2, s16le, + 1, 0, 2, s16le, 48, 1000, 0, 0, SSP, 5, s16le, 2) # Low Latency capture pipeline 3 on PCM 1 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, - 3, 1, 2, s16le, + 2, 0, 2, s16le, 48, 1000, 0, 0, SSP, 5, s16le, 2) +# Low Latency capture pipeline 1 on PCM 0 using max 4 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 3, 1, 4, s32le, + 48, 1000, 0, 0, DMIC, 0, s32le, 2) # # DAIs configuration # -# capture DAI is DMIC0 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-capture.m4, - 1, DMIC, 0, DMIC0, - PIPELINE_SINK_1, 2, s32le, - 48, 1000, 0, 0) - # playback DAI is SSP5 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, - 2, SSP, 5, SSP5-Codec, - PIPELINE_SOURCE_2, 2, s16le, + 1, SSP, 5, SSP5-Codec, + PIPELINE_SOURCE_1, 2, s16le, 48, 1000, 0, 0) # capture DAI is SSP5 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, - 3, SSP, 5, SSP5-Codec, - PIPELINE_SINK_3, 2, s16le, + 2, SSP, 5, SSP5-Codec, + PIPELINE_SINK_2, 2, s16le, 48, 1000, 0, 0) +# capture DAI is DMIC0 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 3, DMIC, 0, DMIC0, + PIPELINE_SINK_3, 2, s32le, + 48, 1000, 0, 0) # PCM Low Latency, id 0 -PCM_CAPTURE_ADD(Dmic0, 0, 0, 0, PIPELINE_PCM_1) -PCM_DUPLEX_ADD(Port5, 1, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) +PCM_DUPLEX_ADD(Port5, 0, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_CAPTURE_ADD(Dmic0, 1, 1, 1, PIPELINE_PCM_3) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(DMIC, 0, 0, DMIC0, - DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, - DMIC_WORD_LENGTH(s32le), DMIC, 0, - PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) - -DAI_CONFIG(SSP, 5, 1, SSP5-Codec, +DAI_CONFIG(SSP, 5, 0, SSP5-Codec, SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), SSP_CLOCK(bclk, 1536000, codec_slave), SSP_CLOCK(fsync, 48000, codec_slave), SSP_TDM(2, 16, 3, 3), SSP_CONFIG_DATA(SSP, 5, 16))) +DAI_CONFIG(DMIC, 0, 1, DMIC0, + DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, + DMIC_WORD_LENGTH(s32le), DMIC, 0, + PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) From 591a07d02d83d76ac481b37fc84f7f1fca7416c3 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Fri, 6 Jul 2018 15:33:44 -0700 Subject: [PATCH 212/324] topology: add multi-stream topology for GLK Add a multi-stream topology for GLK with speaker on SSP1, headset on SSP2 and DMIC. Only playback pipelines on SSP1/2 for now. Capture pipelines to be added later. Signed-off-by: Ranjani Sridharan --- topology/Makefile.am | 6 ++- topology/sof-glk-codec.m4 | 100 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 topology/sof-glk-codec.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index c6868e1245f6..33d0418e80b7 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -30,7 +30,8 @@ MACHINES = \ sof-cnl-rt274.tplg \ sof-hsw-rt5640.tplg \ sof-apl-tdf8532.tplg \ - sof-apl-pcm512x.tplg + sof-apl-pcm512x.tplg \ + sof-glk-codec.tplg # Uncomment the following line if you want to debug conf files .PRECIOUS: %.conf @@ -61,4 +62,5 @@ EXTRA_DIST = \ sof-cnl-rt274.m4 \ sof-hsw-rt5640.m4 \ sof-apl-tdf8532.m4 \ - sof-apl-pcm512x.m4 + sof-apl-pcm512x.m4 \ + sof-glk-codec.m4 diff --git a/topology/sof-glk-codec.m4 b/topology/sof-glk-codec.m4 new file mode 100644 index 000000000000..d8fe3053e2a6 --- /dev/null +++ b/topology/sof-glk-codec.m4 @@ -0,0 +1,100 @@ +# +# Topology for Geminilake with headset on SSP2, spk on SSP1 and DMIC capture +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') +include(`ssp.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include bxt DSP configuration +include(`platform/intel/bxt.m4') +include(`platform/intel/dmic.m4') + +# +# Define the pipelines +# +# PCM0 <---- volume <----- DMIC0 (dmic capture) +# PCM1 ----> volume -----> SSP1 (speaker - maxim98357a) +# PCM2 ----> volume -----> SSP2 (headset - da7219) +# + +# Low Latency capture pipeline 1 on PCM 0 using max 4 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 1, 0, 4, s32le, + 48, 1000, 0, 0, DMIC, 0, s32le, 2) + +# Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 2, 1, 2, s16le, + 48, 1000, 0, 0, SSP, 1, s16le, 2) + +# Low Latency playback pipeline 3 on PCM 2 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 3, 2, 2, s16le, + 48, 1000, 0, 0, SSP, 2, s16le, 2) + +# +# DAIs configuration +# + +# capture DAI is DMIC0 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, DMIC, 0, DMIC0, + PIPELINE_SINK_1, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is SSP1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 2, SSP, 1, SSP1-Codec, + PIPELINE_SOURCE_2, 2, s16le, + 48, 1000, 0, 0) + +# playback DAI is SSP2 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 3, SSP, 2, SSP2-Codec, + PIPELINE_SOURCE_3, 2, s16le, + 48, 1000, 0, 0) + +# PCM +PCM_CAPTURE_ADD(DMIC0, 1, 0, 0, PIPELINE_PCM_1) +PCM_PLAYBACK_ADD(SSP1, 2, 1, 1, PIPELINE_PCM_2) +PCM_PLAYBACK_ADD(SSP2, 3, 2, 2, PIPELINE_PCM_3) + +# +# BE configurations - overrides config in ACPI if present +# + +DAI_CONFIG(DMIC, 0, 0, DMIC0, + DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, + DMIC_WORD_LENGTH(s32le), DMIC, 0, + PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) + +#SSP 1 (ID: 1) with 19.2MHz mclk with MCLK_ID 1 +DAI_CONFIG(SSP, 1, 1, SSP1-Codec, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 1920000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 20, 3, 3), + SSP_CONFIG_DATA(SSP, 1, 16, 1))) + +#SSP 2 (ID: 2) with 19.2MHz mclk with MCLK_ID 1 +DAI_CONFIG(SSP, 2, 2, SSP2-Codec, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 1920000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 20, 3, 3), + SSP_CONFIG_DATA(SSP, 2, 16, 1))) From e55cd317a25d0dcb966cdbbdf7d78ad97ed2bf2e Mon Sep 17 00:00:00 2001 From: Zhang Keqiao Date: Tue, 10 Jul 2018 10:47:14 +0800 Subject: [PATCH 213/324] topology: fix id for sof_cnl_rt274 topology Codec SSP id doesn't match with machine driver, so change the id to 1 to fix the topology loading issue. Signed-off-by: Zhang Keqiao --- topology/sof-cnl-rt274.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index e416ce3f6b72..a2e6d52cbbac 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -63,7 +63,7 @@ PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present # -DAI_CONFIG(SSP, 0, 0, SSP0-Codec, +DAI_CONFIG(SSP, 0, 1, SSP0-Codec, SSP_CONFIG(DSP_B, SSP_CLOCK(mclk, 24000000, codec_mclk_in), SSP_CLOCK(bclk, 4800000, codec_slave), SSP_CLOCK(fsync, 48000, codec_slave), From 4d1b3d15b6c5edefa550910c2580965f9b36519a Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Fri, 13 Jul 2018 12:56:08 -0500 Subject: [PATCH 214/324] topology: fix sof-apl-pcm512x Remove DMIC support to avoid topology load fail, Remove capture (not supported by PCM512x codec) Simplify structure using PCM_PIPELINE_ADD instead of PCM_PIPELINE_DAI_ADD Enable 24-bit output Enable up to 32-bit PCM (tested with S16_LE and S32_LE) Tested on Up2, no issues detected. Signed-off-by: Pierre-Louis Bossart --- topology/sof-apl-pcm512x.m4 | 55 +++++++------------------------------ 1 file changed, 10 insertions(+), 45 deletions(-) diff --git a/topology/sof-apl-pcm512x.m4 b/topology/sof-apl-pcm512x.m4 index 703aa02a414b..d0b44610f889 100644 --- a/topology/sof-apl-pcm512x.m4 +++ b/topology/sof-apl-pcm512x.m4 @@ -16,62 +16,32 @@ include(`sof/tokens.m4') # Include Apollolake DSP configuration include(`platform/intel/bxt.m4') -include(`platform/intel/dmic.m4') # # Define the pipelines # # PCM0 ----> volume -----> SSP5 (pcm512x) -# <---- volume <----- SSP5 -# PCM1 <---- volume <----- DMIC0 (SSP3) # -# Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s16le. +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, - 1, 0, 2, s16le, - 48, 1000, 0, 0, SSP, 5, s16le, 2) - -# Low Latency capture pipeline 3 on PCM 1 using max 2 channels of s16le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, - 2, 0, 2, s16le, - 48, 1000, 0, 0, SSP, 5, s16le, 2) - -# Low Latency capture pipeline 1 on PCM 0 using max 4 channels of s32le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, - 3, 1, 4, s32le, - 48, 1000, 0, 0, DMIC, 0, s32le, 2) +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0) # # DAIs configuration # # playback DAI is SSP5 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, 1, SSP, 5, SSP5-Codec, - PIPELINE_SOURCE_1, 2, s16le, - 48, 1000, 0, 0) - -# capture DAI is SSP5 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-capture.m4, - 2, SSP, 5, SSP5-Codec, - PIPELINE_SINK_2, 2, s16le, - 48, 1000, 0, 0) - -# capture DAI is DMIC0 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-capture.m4, - 3, DMIC, 0, DMIC0, - PIPELINE_SINK_3, 2, s32le, + PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) # PCM Low Latency, id 0 -PCM_DUPLEX_ADD(Port5, 0, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) -PCM_CAPTURE_ADD(Dmic0, 1, 1, 1, PIPELINE_PCM_3) +PCM_PLAYBACK_ADD(Port5, 0, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present @@ -79,12 +49,7 @@ PCM_CAPTURE_ADD(Dmic0, 1, 1, 1, PIPELINE_PCM_3) DAI_CONFIG(SSP, 5, 0, SSP5-Codec, SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), - SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(bclk, 3072000, codec_slave), SSP_CLOCK(fsync, 48000, codec_slave), - SSP_TDM(2, 16, 3, 3), - SSP_CONFIG_DATA(SSP, 5, 16))) - -DAI_CONFIG(DMIC, 0, 1, DMIC0, - DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, - DMIC_WORD_LENGTH(s32le), DMIC, 0, - PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) + SSP_TDM(2, 32, 3, 3), + SSP_CONFIG_DATA(SSP, 5, 24))) From 6ba607461d4063f38ddf58a4c87fb0e97708aa58 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Thu, 12 Jul 2018 17:31:30 +0800 Subject: [PATCH 215/324] tplg: add nocodec topology for icelake Signed-off-by: Rander Wang --- topology/Makefile.am | 3 +- topology/platform/intel/icl.m4 | 38 ++++++++++++++++++ topology/sof-icl-nocodec.m4 | 71 ++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 topology/platform/intel/icl.m4 create mode 100644 topology/sof-icl-nocodec.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 33d0418e80b7..9e65c90df721 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -31,7 +31,8 @@ MACHINES = \ sof-hsw-rt5640.tplg \ sof-apl-tdf8532.tplg \ sof-apl-pcm512x.tplg \ - sof-glk-codec.tplg + sof-glk-codec.tplg \ + sof-icl-nocodec.tplg # Uncomment the following line if you want to debug conf files .PRECIOUS: %.conf diff --git a/topology/platform/intel/icl.m4 b/topology/platform/intel/icl.m4 new file mode 100644 index 000000000000..9671289fdafc --- /dev/null +++ b/topology/platform/intel/icl.m4 @@ -0,0 +1,38 @@ +# +# Icelake differentiation for pipelines and components +# + +include(`memory.m4') + +dnl Memory capabilities for different buffer types on Icelake +define(`PLATFORM_DAI_MEM_CAP', + MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE, MEM_CAP_HP)) +define(`PLATFORM_HOST_MEM_CAP', + MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE, MEM_CAP_HP)) +define(`PLATFORM_PASS_MEM_CAP', + MEMCAPS(MEM_CAP_RAM, MEM_CAP_DMA, MEM_CAP_CACHE, MEM_CAP_HP)) +define(`PLATFORM_COMP_MEM_CAP', MEMCAPS(MEM_CAP_RAM, MEM_CAP_CACHE)) + +# Low Latency PCM Configuration +W_VENDORTUPLES(pipe_ll_schedule_plat_tokens, sof_sched_tokens, + LIST(` ', `SOF_TKN_SCHED_MIPS "50000"')) + +W_DATA(pipe_ll_schedule_plat, pipe_ll_schedule_plat_tokens) + +# Media PCM Configuration +W_VENDORTUPLES(pipe_media_schedule_plat_tokens, sof_sched_tokens, + LIST(` ', `SOF_TKN_SCHED_MIPS "100000"')) + +W_DATA(pipe_media_schedule_plat, pipe_media_schedule_plat_tokens) + +# Tone Signal Generator Configuration +W_VENDORTUPLES(pipe_tone_schedule_plat_tokens, sof_sched_tokens, + LIST(` ', `SOF_TKN_SCHED_MIPS "200000"')) + +W_DATA(pipe_tone_schedule_plat, pipe_tone_schedule_plat_tokens) + +# DAI schedule Configuration - scheduled by IRQ +W_VENDORTUPLES(pipe_dai_schedule_plat_tokens, sof_sched_tokens, + LIST(` ', `SOF_TKN_SCHED_MIPS "5000"')) + +W_DATA(pipe_dai_schedule_plat, pipe_dai_schedule_plat_tokens) diff --git a/topology/sof-icl-nocodec.m4 b/topology/sof-icl-nocodec.m4 new file mode 100644 index 000000000000..9cabf7eff517 --- /dev/null +++ b/topology/sof-icl-nocodec.m4 @@ -0,0 +1,71 @@ +# +# Topology for generic Icelake board with nocodec +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') +include(`ssp.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Icelake DSP configuration +include(`platform/intel/icl.m4') + +# +# Define the pipelines +# +# PCM0 ----> Volume ----> SSP0 +# +# PCM1 <---- Volume <---- SSP0 +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 1, 0, 2, s24le, + 48, 1000, 0, 0, SSP, 0, s24le, 2) + +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 2, 0, 2, s24le, + 48, 1000, 0, 0, SSP, 0, s24le, 2) + +# +# DAI configuration +# +# SSP port 0 is our only pipeline DAI +# + +# playback DAI is SSP0 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 0, NoCodec-0, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) + +# capture DAI is SSP0 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, SSP, 0, NoCodec-0, + PIPELINE_SINK_2, 2, s24le, + 48, 1000, 0, 0) + +# PCM Low Latency +PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) + +# +# BE configurations - overrides config in ACPI if present +# +DAI_CONFIG(SSP, 0, 0, NoCodec-0, + SSP_CONFIG(DSP_B, SSP_CLOCK(mclk, 38400000, codec_mclk_in), + SSP_CLOCK(bclk, 2400000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 25, 3, 3), + SSP_CONFIG_DATA(SSP, 0, 24))) From 446e415f6a538cce0155b625a3601f9991ba36bb Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 16 Jul 2018 15:22:29 -0500 Subject: [PATCH 216/324] kmod_scripts: clean-up and add pcm512x support Update module names, only unload what is loaded and add pcm512x support for Up^2 board. Signed-off-by: Pierre-Louis Bossart --- kmod_scripts/sof_insert.sh | 1 + kmod_scripts/sof_remove.sh | 59 +++++++++++++++++++++++--------------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/kmod_scripts/sof_insert.sh b/kmod_scripts/sof_insert.sh index 93b224260958..3ccee5792e4c 100755 --- a/kmod_scripts/sof_insert.sh +++ b/kmod_scripts/sof_insert.sh @@ -5,6 +5,7 @@ modprobe snd_soc_rt5645 modprobe snd_soc_rt5651 modprobe snd_soc_rt5640 modprobe snd_soc_da7213 +modprobe snd_soc_pcm512x_i2c modprobe sof_acpi_dev modprobe sof_pci_dev diff --git a/kmod_scripts/sof_remove.sh b/kmod_scripts/sof_remove.sh index 74b94d507bc2..64d8f8c0945a 100755 --- a/kmod_scripts/sof_remove.sh +++ b/kmod_scripts/sof_remove.sh @@ -1,28 +1,41 @@ #!/bin/bash -rmmod sof_pci_dev -rmmod sof_acpi_dev -rmmod snd_soc_acpi_intel_match -rmmod snd_sof_intel_byt -rmmod snd_sof_intel_hsw -rmmod snd_sof_intel_bdw -rmmod snd_sof_intel_apl -rmmod snd_sof_intel_cnl -rmmod snd_sof_intel_hda_common -rmmod snd_sof +remove_module() { -rmmod snd_soc_sst_bytcr_rt5640 -rmmod snd_soc_sst_bytcr_rt5651 -rmmod snd_soc_sst_cht_bsw_rt5645 -rmmod snd_soc_sst_cht_bsw_rt5670 -rmmod snd_soc_sst_byt_cht_da7213 -rmmod snd_sof_nocodec + MODULE="$1" -rmmod snd_soc_rt5670 -rmmod snd_soc_rt5645 -rmmod snd_soc_rt5651 -rmmod snd_soc_rt5640 -rmmod snd_soc_rl6231 -rmmod snd_soc_da7213 + if lsmod | grep "$MODULE" &> /dev/null ; then + echo "Removing $MODULE" + rmmod $MODULE + else + echo "skipping $MODULE, not loaded" + fi +} -rmmod snd_soc_acpi +remove_module sof_pci_dev +remove_module sof_acpi_dev +remove_module snd_soc_acpi_intel_match +remove_module snd_sof_intel_byt +remove_module snd_sof_intel_hsw +remove_module snd_sof_intel_bdw +remove_module snd_sof_intel_hda_common +remove_module snd_sof_xtensa_dsp + +remove_module snd_soc_sst_bytcr_rt5640 +remove_module snd_soc_sst_bytcr_rt5651 +remove_module snd_soc_sst_cht_bsw_rt5645 +remove_module snd_soc_sst_cht_bsw_rt5670 +remove_module snd_soc_sst_byt_cht_da7213 +remove_module snd_soc_sst_bxt_pcm512x +remove_module snd_sof_nocodec +remove_module snd_sof + +remove_module snd_soc_rt5670 +remove_module snd_soc_rt5645 +remove_module snd_soc_rt5651 +remove_module snd_soc_rt5640 +remove_module snd_soc_rl6231 +remove_module snd_soc_da7213 +remove_module snd_soc_pcm512x_i2c +remove_module snd_soc_pcm512x +remove_module snd_soc_acpi From 812c15cb66a846f11b2896a2d694e6bc439fa36f Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 17 Jul 2018 17:25:16 -0500 Subject: [PATCH 217/324] topology: sof-apl-nocodec: enable all 6 SSPs For some reason parts of the topology were commented out. Make sure all 6 SSPs are enabled. Tested on Up2 with a LogicPro-based check on SSP5 (only interface accessive on the HAT connector) Signed-off-by: Pierre-Louis Bossart --- topology/sof-apl-nocodec.m4 | 88 ++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 823674e3159f..b5ad3509a066 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -22,7 +22,7 @@ include(`platform/intel/bxt.m4') # # PCM0 ----> volume -----> SSP0 # <---- volume <----- SSP0 -# PCM1 <---- Volume <----- SSP1 +# PCM1 ----> Volume <----- SSP1 # <---- Volume <----- SSP1 # PCM2 ----> volume -----> SSP2 # <---- Volume <----- SSP2 @@ -84,27 +84,27 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, # Low Latency playback pipeline 9 on PCM 4 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -#PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, -# 9, 4, 2, s16le, -# 48, 1000, 0, 0, SSP, 4, s16le, 2) +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 9, 4, 2, s16le, + 48, 1000, 0, 0, SSP, 4, s16le, 2) # Low Latency capture pipeline 10 on PCM 4 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -#PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, -# 10, 4, 2, s16le, -# 48, 1000, 0, 0, SSP, 4, s16le, 2) +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 10, 4, 2, s16le, + 48, 1000, 0, 0, SSP, 4, s16le, 2) # Low Latency playback pipeline 11 on PCM 5 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -#PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, -# 11, 5, 2, s16le, -# 48, 1000, 0, 0, SSP, 5, s16le, 2) +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, + 11, 5, 2, s16le, + 48, 1000, 0, 0, SSP, 5, s16le, 2) # Low Latency capture pipeline 12 on PCM 5 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -#PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, -# 12, 5, 2, s16le, -# 48, 1000, 0, 0, SSP, 5, s16le, 2) +PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, + 12, 5, 2, s16le, + 48, 1000, 0, 0, SSP, 5, s16le, 2) # @@ -169,39 +169,39 @@ DAI_ADD(sof/pipe-dai-capture.m4, # playback DAI is SSP4 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -#DAI_ADD(sof/pipe-dai-playback.m4, -# 9, SSP, 4, NoCodec, -# PIPELINE_SOURCE_9, 2, s16le, -# 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, + 9, SSP, 4, NoCodec-4, + PIPELINE_SOURCE_9, 2, s16le, + 48, 1000, 0, 0) # capture DAI is SSP4 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -#DAI_ADD(sof/pipe-dai-capture.m4, -# 10, SSP, 4, NoCodec, -# PIPELINE_SINK_10, 2, s16le, -# 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, + 10, SSP, 4, NoCodec-4, + PIPELINE_SINK_10, 2, s16le, + 48, 1000, 0, 0) # playback DAI is SSP5 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -#DAI_ADD(sof/pipe-dai-playback.m4, -# 11, SSP, 5, NoCodec, -# PIPELINE_SOURCE_11, 2, s16le, -# 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-playback.m4, + 11, SSP, 5, NoCodec-5, + PIPELINE_SOURCE_11, 2, s16le, + 48, 1000, 0, 0) # capture DAI is SSP5 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -#DAI_ADD(sof/pipe-dai-capture.m4, -# 12, SSP, 5, NoCdec, -# PIPELINE_SINK_12, 2, s16le, -# 48, 1000, 0, 0) +DAI_ADD(sof/pipe-dai-capture.m4, + 12, SSP, 5, NoCodec-5, + PIPELINE_SINK_12, 2, s16le, + 48, 1000, 0, 0) # PCM Low Latency, id 0 PCM_DUPLEX_ADD(Port0, 0, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) PCM_DUPLEX_ADD(Port1, 1, 1, 1, PIPELINE_PCM_3, PIPELINE_PCM_4) PCM_DUPLEX_ADD(Port2, 2, 2, 2, PIPELINE_PCM_5, PIPELINE_PCM_6) PCM_DUPLEX_ADD(Port3, 3, 3, 3, PIPELINE_PCM_7, PIPELINE_PCM_8) -#PCM_DUPLEX_ADD(Port4, 4, 4, 4, PIPELINE_PCM_9, PIPELINE_PCM_10) -#PCM_DUPLEX_ADD(Port5, 5, 5, 5, PIPELINE_PCM_11, PIPELINE_PCM_12) +PCM_DUPLEX_ADD(Port4, 4, 4, 4, PIPELINE_PCM_9, PIPELINE_PCM_10) +PCM_DUPLEX_ADD(Port5, 5, 5, 5, PIPELINE_PCM_11, PIPELINE_PCM_12) # # BE configurations - overrides config in ACPI if present @@ -235,17 +235,17 @@ DAI_CONFIG(SSP, 3, 3, NoCodec-3, SSP_TDM(2, 16, 3, 3), SSP_CONFIG_DATA(SSP, 3, 16))) -#DAI_CONFIG(SSP, 4, 0, NoCodec, -# SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), -# SSP_CLOCK(bclk, 1536000, codec_slave), -# SSP_CLOCK(fsync, 48000, codec_slave), -# SSP_TDM(2, 16, 3, 3), -# SSP_CONFIG_DATA(SSP, 4, 16))) - -#DAI_CONFIG(SSP, 5, 0, NoCodec, -# SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), -# SSP_CLOCK(bclk, 1536000, codec_slave), -# SSP_CLOCK(fsync, 48000, codec_slave), -# SSP_TDM(2, 16, 3, 3), -# SSP_CONFIG_DATA(SSP, 5, 16))) +DAI_CONFIG(SSP, 4, 4, NoCodec-4, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), + SSP_CONFIG_DATA(SSP, 4, 16))) + +DAI_CONFIG(SSP, 5, 5, NoCodec-5, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), + SSP_CONFIG_DATA(SSP, 5, 16))) From 3dd17dc01d4bf61465276b2ed0296881c63b6bc6 Mon Sep 17 00:00:00 2001 From: Zhang Keqiao Date: Thu, 19 Jul 2018 13:37:29 +0800 Subject: [PATCH 218/324] dist: fix make dist for topology M4 Signed-off-by: Zhang Keqiao --- topology/Makefile.am | 3 ++- topology/test/Makefile.am | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/topology/Makefile.am b/topology/Makefile.am index 9e65c90df721..7284ee0fc5e5 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -64,4 +64,5 @@ EXTRA_DIST = \ sof-hsw-rt5640.m4 \ sof-apl-tdf8532.m4 \ sof-apl-pcm512x.m4 \ - sof-glk-codec.m4 + sof-glk-codec.m4 \ + sof-icl-nocodec.tplg diff --git a/topology/test/Makefile.am b/topology/test/Makefile.am index e1894e0deeba..3a613e84a300 100644 --- a/topology/test/Makefile.am +++ b/topology/test/Makefile.am @@ -25,8 +25,8 @@ clean-local: EXTRA_DIST = \ - test-capture-ssp.m4 \ - test-playback-ssp.m4 \ - test-tone-playback-ssp.m4 \ - test-ssp.m4 \ + test-capture.m4 \ + test-playback.m4 \ + test-tone-playback.m4 \ + test-all.m4 \ tplg-build.sh From e08ea66bd17201fe695a1836bf8261cbb2be6af1 Mon Sep 17 00:00:00 2001 From: Zhang Keqiao Date: Thu, 19 Jul 2018 21:20:55 +0800 Subject: [PATCH 219/324] kmod_scripts: add rt274 and tdf8532 support Signed-off-by: Zhang Keqiao --- kmod_scripts/sof_insert.sh | 2 ++ kmod_scripts/sof_remove.sh | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/kmod_scripts/sof_insert.sh b/kmod_scripts/sof_insert.sh index 3ccee5792e4c..60753107fba6 100755 --- a/kmod_scripts/sof_insert.sh +++ b/kmod_scripts/sof_insert.sh @@ -6,6 +6,8 @@ modprobe snd_soc_rt5651 modprobe snd_soc_rt5640 modprobe snd_soc_da7213 modprobe snd_soc_pcm512x_i2c +modprobe snd_soc_tdf8532 +modprobe snd_soc_rt274 modprobe sof_acpi_dev modprobe sof_pci_dev diff --git a/kmod_scripts/sof_remove.sh b/kmod_scripts/sof_remove.sh index 64d8f8c0945a..8f0b49cbd162 100755 --- a/kmod_scripts/sof_remove.sh +++ b/kmod_scripts/sof_remove.sh @@ -27,6 +27,8 @@ remove_module snd_soc_sst_cht_bsw_rt5645 remove_module snd_soc_sst_cht_bsw_rt5670 remove_module snd_soc_sst_byt_cht_da7213 remove_module snd_soc_sst_bxt_pcm512x +remove_module snd_soc_sst_bxt_tdf8532 +remove_module snd_soc_cnl_rt274 remove_module snd_sof_nocodec remove_module snd_sof @@ -38,4 +40,6 @@ remove_module snd_soc_rl6231 remove_module snd_soc_da7213 remove_module snd_soc_pcm512x_i2c remove_module snd_soc_pcm512x +remove_module snd_soc_tdf8532 +remove_module snd_soc_rt274 remove_module snd_soc_acpi From 3d903b5e3fa07c738ec479ba95e89a5ed60df9bc Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Mon, 23 Jul 2018 16:12:23 +0800 Subject: [PATCH 220/324] topology: Add dai index in DAI SectionBE DAI_TYPE and DAI_INDEX are both needed to get the dai in FW, add DAI_INDEX in SectionBE to make sure we can handle multiple type dais. Signed-off-by: Pan Xiuli --- topology/m4/dai.m4 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index b0802affd733..516354b32068 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -132,14 +132,17 @@ define(`DAI_CONFIG', `' ` ifelse($1, `SSP', $5, `}')' `ifelse($1, `DMIC', $5, `')' -`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples_str" {' +`SectionVendorTuples."'N_DAI_CONFIG($1$2)`_tuples_common" {' ` tokens "sof_dai_tokens"' ` tuples."string" {' ` SOF_TKN_DAI_TYPE' STR($1) ` }' +` tuples."word" {' +` SOF_TKN_DAI_INDEX' STR($2) +` }' `}' -`SectionData."'N_DAI_CONFIG($1$2)`_data_str" {' -` tuples "'N_DAI_CONFIG($1$2)`_tuples_str"' +`SectionData."'N_DAI_CONFIG($1$2)`_data_common" {' +` tuples "'N_DAI_CONFIG($1$2)`_tuples_common"' `}' `' `SectionBE."'$4`" {' @@ -152,7 +155,7 @@ define(`DAI_CONFIG', ` ]' ` data [' ` "'N_DAI_CONFIG($1$2)`_data"' -` "'N_DAI_CONFIG($1$2)`_data_str"' +` "'N_DAI_CONFIG($1$2)`_data_common"' `ifelse($1, `DMIC',` "'N_DAI_CONFIG($1$2)`_pdm_data"', `')' ` ]' `}') From eecc7f6665f92dad9378c8065d3616d230efa373 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Mon, 23 Jul 2018 11:43:32 -0500 Subject: [PATCH 221/324] topology: fix Makefile.am copy/paste mistake Fixes: 3dd17dc0 ('dist: fix make dist for topology M4') Signed-off-by: Pierre-Louis Bossart --- topology/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/Makefile.am b/topology/Makefile.am index 7284ee0fc5e5..e49af0878210 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -65,4 +65,4 @@ EXTRA_DIST = \ sof-apl-tdf8532.m4 \ sof-apl-pcm512x.m4 \ sof-glk-codec.m4 \ - sof-icl-nocodec.tplg + sof-icl-nocodec.m4 From c7adc3dae6a4cd613ee9d3eb34ece5cab2c94abc Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 23 Jul 2018 15:40:23 -0700 Subject: [PATCH 222/324] topology: fix BE DAI id to be set to ID (not index) Previously it was set to be the dai index which works if there's only one type of BE DAI's. Signed-off-by: Ranjani Sridharan --- topology/m4/dai.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index b0802affd733..3944ff5d6c47 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -128,7 +128,7 @@ dnl DAI_CONFIG(type, idx, link_id, name, ssp_config/dmic_config) define(`DAI_CONFIG', `SectionHWConfig."'$1$2`" {' `' -` id "'$2`"' +` id "'$3`"' `' ` ifelse($1, `SSP', $5, `}')' `ifelse($1, `DMIC', $5, `')' @@ -145,7 +145,7 @@ define(`DAI_CONFIG', `SectionBE."'$4`" {' ` id "'$3`"' ` index "0"' -` default_hw_conf_id "'$2`"' +` default_hw_conf_id "'$3`"' `' ` hw_configs [' ` "'$1$2`"' From 2187702ee24325caf691db91bc6ddbaa0febbeff Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 18 Jul 2018 22:42:26 -0700 Subject: [PATCH 223/324] topology: add dmic pipeline to apl nocodec topology Add DMIC capture pipeline for DMIC01 to the apl nocodec topology. DMIC16k to be added later. Signed-off-by: Ranjani Sridharan --- topology/sof-apl-nocodec.m4 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index b5ad3509a066..1582c206a917 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -16,6 +16,7 @@ include(`sof/tokens.m4') # Include Apollolake DSP configuration include(`platform/intel/bxt.m4') +include(`platform/intel/dmic.m4') # # Define the pipelines @@ -32,6 +33,7 @@ include(`platform/intel/bxt.m4') # <---- Volume <----- SSP4 # PCM5 ----> volume -----> SSP5 # <---- volume <----- SSP5 +# PCM6 <---- volume <----- DMIC6 (DMIC01) # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s16le. @@ -106,6 +108,12 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, 12, 5, 2, s16le, 48, 1000, 0, 0, SSP, 5, s16le, 2) +# Passthrough capture pipeline 13 on PCM 6 using max 4 channels. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-capture.m4, + 13, 6, 4, s32le, + 48, 1000, 0, 0, + DMIC, 0, s32le, 2) # # DAIs configuration @@ -195,6 +203,13 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_12, 2, s16le, 48, 1000, 0, 0) +# capture DAI is DMIC 0 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 13, DMIC, 0, NoCodec-6, + PIPELINE_SINK_13, 2, s32le, + 48, 1000, 0, 0) + # PCM Low Latency, id 0 PCM_DUPLEX_ADD(Port0, 0, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) PCM_DUPLEX_ADD(Port1, 1, 1, 1, PIPELINE_PCM_3, PIPELINE_PCM_4) @@ -202,6 +217,7 @@ PCM_DUPLEX_ADD(Port2, 2, 2, 2, PIPELINE_PCM_5, PIPELINE_PCM_6) PCM_DUPLEX_ADD(Port3, 3, 3, 3, PIPELINE_PCM_7, PIPELINE_PCM_8) PCM_DUPLEX_ADD(Port4, 4, 4, 4, PIPELINE_PCM_9, PIPELINE_PCM_10) PCM_DUPLEX_ADD(Port5, 5, 5, 5, PIPELINE_PCM_11, PIPELINE_PCM_12) +PCM_CAPTURE_ADD(DMIC01, 6, 6, 6, PIPELINE_PCM_13) # # BE configurations - overrides config in ACPI if present @@ -249,3 +265,8 @@ DAI_CONFIG(SSP, 5, 5, NoCodec-5, SSP_TDM(2, 16, 3, 3), SSP_CONFIG_DATA(SSP, 5, 16))) +DAI_CONFIG(DMIC, 0, 6, NoCodec-6, + DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, + DMIC_WORD_LENGTH(s32le), DMIC, 0, + PDM_CONFIG(DMIC, 0, STEREO_PDM0))) + From 27d3e14bdf5a095fe609684c3638bf70ab35f85e Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 23 Jul 2018 15:57:14 -0700 Subject: [PATCH 224/324] topology: add comments to sof-apl-nocodec m4 file This makes it easier to look up the macro definitions. Signed-off-by: Ranjani Sridharan --- topology/sof-apl-nocodec.m4 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 1582c206a917..2b2b839cf489 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -36,6 +36,11 @@ include(`platform/intel/dmic.m4') # PCM6 <---- volume <----- DMIC6 (DMIC01) # +dnl PIPELINE_PCM_DAI_ADD(pipeline, +dnl pipe id, pcm, max channels, format, +dnl frames, deadline, priority, core, +dnl dai type, dai_index, dai format, periods) + # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, @@ -119,6 +124,11 @@ PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-capture.m4, # DAIs configuration # +dnl DAI_ADD(pipeline, +dnl pipe id, dai type, dai_index, dai_be, +dnl buffer, periods, format, +dnl frames, deadline, priority, core) + # playback DAI is SSP0 using 2 periods # Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, @@ -211,23 +221,28 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency, id 0 +dnl PCM_DUPLEX_ADD(name, pipeline, pcm_id, dai_id, playback, capture) PCM_DUPLEX_ADD(Port0, 0, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) PCM_DUPLEX_ADD(Port1, 1, 1, 1, PIPELINE_PCM_3, PIPELINE_PCM_4) PCM_DUPLEX_ADD(Port2, 2, 2, 2, PIPELINE_PCM_5, PIPELINE_PCM_6) PCM_DUPLEX_ADD(Port3, 3, 3, 3, PIPELINE_PCM_7, PIPELINE_PCM_8) PCM_DUPLEX_ADD(Port4, 4, 4, 4, PIPELINE_PCM_9, PIPELINE_PCM_10) PCM_DUPLEX_ADD(Port5, 5, 5, 5, PIPELINE_PCM_11, PIPELINE_PCM_12) +dnl PCM_CAPTURE_ADD(name, pipeline, pcm_id, dai_id, capture) PCM_CAPTURE_ADD(DMIC01, 6, 6, 6, PIPELINE_PCM_13) # # BE configurations - overrides config in ACPI if present # +dnl DAI_CONFIG(type, dai_index, link_id, name, ssp_config/dmic_config) DAI_CONFIG(SSP, 0, 0, NoCodec-0, + dnl SSP_CONFIG(format, mclk, bclk, fsync, tdm, ssp_config_data) SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), SSP_CLOCK(bclk, 1536000, codec_slave), SSP_CLOCK(fsync, 48000, codec_slave), SSP_TDM(2, 16, 3, 3), + dnl SSP_CONFIG_DATA(type, dai_index, valid bits, mclk_id) SSP_CONFIG_DATA(SSP, 0, 16))) DAI_CONFIG(SSP, 1, 1, NoCodec-1, @@ -266,7 +281,13 @@ DAI_CONFIG(SSP, 5, 5, NoCodec-5, SSP_CONFIG_DATA(SSP, 5, 16))) DAI_CONFIG(DMIC, 0, 6, NoCodec-6, + dnl DMIC_CONFIG(driver_version, clk_min, clk_mac, duty_min, duty_max, + dnl sample_rate, + dnl fifo word length, type, dai_index, pdm controller config) DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, + dnl DMIC_WORD_LENGTH(frame_format) DMIC_WORD_LENGTH(s32le), DMIC, 0, + dnl PDM_CONFIG(type, dai_index, num pdm active, pdm tuples list) + dnl STEREO_PDM0 is a pre-defined pdm config for stereo capture PDM_CONFIG(DMIC, 0, STEREO_PDM0))) From f08c93721d9399e221d93c27fad7e82538be1b19 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Tue, 24 Jul 2018 22:42:34 -0700 Subject: [PATCH 225/324] topology: replace PIPELINE_PCM_DAI_ADD with PIPELINE_PCM_ADD Avoid duplicating dai_add in sof-apl-nocodec topology. Signed-off-by: Ranjani Sridharan --- topology/sof-apl-nocodec.m4 | 58 ++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 2b2b839cf489..0818026fcd23 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -36,89 +36,87 @@ include(`platform/intel/dmic.m4') # PCM6 <---- volume <----- DMIC6 (DMIC01) # -dnl PIPELINE_PCM_DAI_ADD(pipeline, +dnl PIPELINE_PCM_ADD(pipeline, dnl pipe id, pcm, max channels, format, -dnl frames, deadline, priority, core, -dnl dai type, dai_index, dai format, periods) +dnl frames, deadline, priority, core) # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, 1, 0, 2, s16le, - 48, 1000, 0, 0, SSP, 0, s16le, 2) + 48, 1000, 0, 0) # Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, 2, 0, 2, s16le, - 48, 1000, 0, 0, SSP, 0, s16le, 2) + 48, 1000, 0, 0) # Low Latency playback pipeline 3 on PCM 1 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, 3, 1, 2, s16le, - 48, 1000, 0, 0, SSP, 1, s16le, 2) + 48, 1000, 0, 0) # Low Latency capture pipeline 4 on PCM 1 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, 4, 1, 2, s16le, - 48, 1000, 0, 0, SSP, 1, s16le, 2) + 48, 1000, 0, 0) # Low Latency playback pipeline 5 on PCM 2 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, 5, 2, 2, s16le, - 48, 1000, 0, 0, SSP, 2, s16le, 2) + 48, 1000, 0, 0) # Low Latency capture pipeline 6 on PCM 2 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, 6, 2, 2, s16le, - 48, 1000, 0, 0, SSP, 2, s16le, 2) + 48, 1000, 0, 0) # Low Latency playback pipeline 7 on PCM 3 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, 7, 3, 2, s16le, - 48, 1000, 0, 0, SSP, 3, s16le, 2) + 48, 1000, 0, 0) # Low Latency capture pipeline 8 on PCM 3 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, 8, 3, 2, s16le, - 48, 1000, 0, 0, SSP, 3, s16le, 2) + 48, 1000, 0, 0) # Low Latency playback pipeline 9 on PCM 4 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, 9, 4, 2, s16le, - 48, 1000, 0, 0, SSP, 4, s16le, 2) + 48, 1000, 0, 0) # Low Latency capture pipeline 10 on PCM 4 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, 10, 4, 2, s16le, - 48, 1000, 0, 0, SSP, 4, s16le, 2) + 48, 1000, 0, 0) # Low Latency playback pipeline 11 on PCM 5 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, 11, 5, 2, s16le, - 48, 1000, 0, 0, SSP, 5, s16le, 2) + 48, 1000, 0, 0) # Low Latency capture pipeline 12 on PCM 5 using max 2 channels of s16le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, 12, 5, 2, s16le, - 48, 1000, 0, 0, SSP, 5, s16le, 2) + 48, 1000, 0, 0) # Passthrough capture pipeline 13 on PCM 6 using max 4 channels. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-passthrough-capture.m4, +PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, 13, 6, 4, s32le, - 48, 1000, 0, 0, - DMIC, 0, s32le, 2) + 48, 1000, 0, 0) # # DAIs configuration From dc10876c20a598290eb0d2b47ee5087db7ffaae4 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 23 Jul 2018 22:47:48 -0700 Subject: [PATCH 226/324] topology: changes to SectionPCM macros This patch addresses the following: 1. Move PCM_PLAYBACK_ADD to pcm.m4 The macro was in the wrong m4 file (buffer.m4) 2. Remove pipeline_id argument and "index" from SectionPCM "index" is not a member of struct snd_soc_tplg_pcm. So this information is not used in the kernel at all. Secondly, the PCM ID could be associated with more than one pipeline especially in the case of DUPLEX PCM's. So better to remove it to avoid ambiguities. 3. Remove dai_id This dai_id is the ID given to the CPU DAI when the FE DAI link is created. In the case of SOF, we should use an linearly increasing unique ID for CPU DAI ID's. If this argument is omitted, the kernel automatially assignes an ID based on the component->num_dai which is linearly incremented every time a new DAI link is added. 4. Finally update users to align with the new definitions. Signed-off-by: Ranjani Sridharan --- topology/m4/buffer.m4 | 19 ---------------- topology/m4/pcm.m4 | 40 +++++++++++++++++++++------------- topology/sof-apl-nocodec.m4 | 19 ++++++++-------- topology/sof-apl-pcm512x.m4 | 2 +- topology/sof-apl-tdf8532.m4 | 12 +++++----- topology/sof-bdw-rt286.m4 | 2 +- topology/sof-bdw-rt5640.m4 | 2 +- topology/sof-byt-da7213.m4 | 2 +- topology/sof-byt-nocodec.m4 | 2 +- topology/sof-byt-rt5640.m4 | 2 +- topology/sof-byt-rt5645.m4 | 2 +- topology/sof-byt-rt5651.m4 | 2 +- topology/sof-cht-max98090.m4 | 2 +- topology/sof-cht-nocodec.m4 | 2 +- topology/sof-cnl-rt274.m4 | 2 +- topology/sof-hsw-rt5640.m4 | 2 +- topology/sof-icl-nocodec.m4 | 2 +- topology/test/test-all.m4 | 2 +- topology/test/test-capture.m4 | 2 +- topology/test/test-playback.m4 | 2 +- 20 files changed, 56 insertions(+), 66 deletions(-) diff --git a/topology/m4/buffer.m4 b/topology/m4/buffer.m4 index 4bfd212d4f2b..55dd06524856 100644 --- a/topology/m4/buffer.m4 +++ b/topology/m4/buffer.m4 @@ -29,23 +29,4 @@ define(`W_BUFFER', dnl COMP_BUFFER_SIZE( num_periods, sample_size, channels, fmames) define(`COMP_BUFFER_SIZE', `eval(`$1 * $2 * $3 * $4')') -dnl PCM_PLAYBACK_ADD(name, pipeline, pcm_id, dai_id, playback) -define(`PCM_PLAYBACK_ADD', -`SectionPCM.STR($1) {' -`' -` index STR($2)' -`' -` # used for binding to the PCM' -` id STR($3)' -`' -` dai.STR($1 $3) {' -` id STR($4)' -` }' -`' -` pcm."playback" {' -`' -` capabilities STR($5)' -` }' -`}') - divert(0)dnl diff --git a/topology/m4/pcm.m4 b/topology/m4/pcm.m4 index 51775fb8c884..28bcb8fee4e6 100644 --- a/topology/m4/pcm.m4 +++ b/topology/m4/pcm.m4 @@ -71,46 +71,56 @@ define(`PCM_CAPABILITIES', ` buffer_size_max STR($12)' `}') -dnl PCM_CAPTURE_ADD(name, pipeline, pcm_id, dai_id, capture) -define(`PCM_CAPTURE_ADD', +dnl PCM_PLAYBACK_ADD(name, pcm_id, playback) +define(`PCM_PLAYBACK_ADD', `SectionPCM.STR($1) {' `' -` index STR($2)' +` # used for binding to the PCM' +` id STR($2)' +`' +` dai.STR($1 $2) {' +` }' +`' +` pcm."playback" {' +`' +` capabilities STR($3)' +` }' +`}') + +dnl PCM_CAPTURE_ADD(name, pcm_id, capture) +define(`PCM_CAPTURE_ADD', +`SectionPCM.STR($1) {' `' ` # used for binding to the PCM' -` id STR($3)' +` id STR($2)' `' -` dai.STR($1 $3) {' -` id STR($4)' +` dai.STR($1 $2) {' ` }' `' ` pcm."capture" {' `' -` capabilities STR($5)' +` capabilities STR($3)' ` }' `}') -dnl PCM_DUPLEX_ADD(name, pipeline, pcm_id, dai_id, playback, capture) +dnl PCM_DUPLEX_ADD(name, pcm_id, playback, capture) define(`PCM_DUPLEX_ADD', `SectionPCM.STR($1) {' `' -` index STR($2)' -`' ` # used for binding to the PCM' -` id STR($3)' +` id STR($2)' `' -` dai.STR($1 $3) {' -` id STR($4)' +` dai.STR($1 $2) {' ` }' `' ` pcm."capture" {' `' -` capabilities STR($6)' +` capabilities STR($4)' ` }' `' ` pcm."playback" {' `' -` capabilities STR($5)' +` capabilities STR($3)' ` }' `}') diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 0818026fcd23..da61ece08787 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -218,16 +218,15 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_13, 2, s32le, 48, 1000, 0, 0) -# PCM Low Latency, id 0 -dnl PCM_DUPLEX_ADD(name, pipeline, pcm_id, dai_id, playback, capture) -PCM_DUPLEX_ADD(Port0, 0, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) -PCM_DUPLEX_ADD(Port1, 1, 1, 1, PIPELINE_PCM_3, PIPELINE_PCM_4) -PCM_DUPLEX_ADD(Port2, 2, 2, 2, PIPELINE_PCM_5, PIPELINE_PCM_6) -PCM_DUPLEX_ADD(Port3, 3, 3, 3, PIPELINE_PCM_7, PIPELINE_PCM_8) -PCM_DUPLEX_ADD(Port4, 4, 4, 4, PIPELINE_PCM_9, PIPELINE_PCM_10) -PCM_DUPLEX_ADD(Port5, 5, 5, 5, PIPELINE_PCM_11, PIPELINE_PCM_12) -dnl PCM_CAPTURE_ADD(name, pipeline, pcm_id, dai_id, capture) -PCM_CAPTURE_ADD(DMIC01, 6, 6, 6, PIPELINE_PCM_13) +dnl PCM_DUPLEX_ADD(name, pcm_id, playback, capture) +PCM_DUPLEX_ADD(Port0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Port1, 1, PIPELINE_PCM_3, PIPELINE_PCM_4) +PCM_DUPLEX_ADD(Port2, 2, PIPELINE_PCM_5, PIPELINE_PCM_6) +PCM_DUPLEX_ADD(Port3, 3, PIPELINE_PCM_7, PIPELINE_PCM_8) +PCM_DUPLEX_ADD(Port4, 4, PIPELINE_PCM_9, PIPELINE_PCM_10) +PCM_DUPLEX_ADD(Port5, 5, PIPELINE_PCM_11, PIPELINE_PCM_12) +dnl PCM_CAPTURE_ADD(name, pipeline, capture) +PCM_CAPTURE_ADD(DMIC01, 6, PIPELINE_PCM_13) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-apl-pcm512x.m4 b/topology/sof-apl-pcm512x.m4 index d0b44610f889..cf853377fad7 100644 --- a/topology/sof-apl-pcm512x.m4 +++ b/topology/sof-apl-pcm512x.m4 @@ -41,7 +41,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, 48, 1000, 0, 0) # PCM Low Latency, id 0 -PCM_PLAYBACK_ADD(Port5, 0, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_PLAYBACK_ADD(Port5, 0, PIPELINE_PCM_1) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index 8421c077ee2e..c82c1f000d62 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -168,12 +168,12 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency, id 0 -PCM_DUPLEX_ADD(Port0, 2, 2, 2, PIPELINE_PCM_4, PIPELINE_PCM_5) -PCM_CAPTURE_ADD(Port1, 3, 3, 3, PIPELINE_PCM_6) -PCM_DUPLEX_ADD(Port2, 1, 1, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) -PCM_DUPLEX_ADD(Port3, 4, 4, 4, PIPELINE_PCM_7, PIPELINE_PCM_8) -PCM_PLAYBACK_ADD(Port4, 0, 0, 0, PIPELINE_PCM_1) -PCM_DUPLEX_ADD(Port5, 5, 5, 5, PIPELINE_PCM_9, PIPELINE_PCM_10) +PCM_DUPLEX_ADD(Port0, 2, PIPELINE_PCM_4, PIPELINE_PCM_5) +PCM_CAPTURE_ADD(Port1, 3, PIPELINE_PCM_6) +PCM_DUPLEX_ADD(Port2, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) +PCM_DUPLEX_ADD(Port3, 4, PIPELINE_PCM_7, PIPELINE_PCM_8) +PCM_PLAYBACK_ADD(Port4, 0, PIPELINE_PCM_1) +PCM_DUPLEX_ADD(Port5, 5, PIPELINE_PCM_9, PIPELINE_PCM_10) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-bdw-rt286.m4 b/topology/sof-bdw-rt286.m4 index f8294d2026e8..a75034485cda 100644 --- a/topology/sof-bdw-rt286.m4 +++ b/topology/sof-bdw-rt286.m4 @@ -86,7 +86,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Low Latency, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-bdw-rt5640.m4 b/topology/sof-bdw-rt5640.m4 index 3c72d3008191..454e050b527c 100644 --- a/topology/sof-bdw-rt5640.m4 +++ b/topology/sof-bdw-rt5640.m4 @@ -86,7 +86,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Low Latency, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-byt-da7213.m4 b/topology/sof-byt-da7213.m4 index af5129c8d71b..6008ff0f23cf 100644 --- a/topology/sof-byt-da7213.m4 +++ b/topology/sof-byt-da7213.m4 @@ -86,7 +86,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Low Latency, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 index 3c5260366240..6df25cad8f97 100644 --- a/topology/sof-byt-nocodec.m4 +++ b/topology/sof-byt-nocodec.m4 @@ -86,7 +86,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Low Latency, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-byt-rt5640.m4 b/topology/sof-byt-rt5640.m4 index 41074914d905..2177fe30412c 100644 --- a/topology/sof-byt-rt5640.m4 +++ b/topology/sof-byt-rt5640.m4 @@ -86,7 +86,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Low Latency, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-byt-rt5645.m4 b/topology/sof-byt-rt5645.m4 index 028cb45d6d19..23f1a758128e 100644 --- a/topology/sof-byt-rt5645.m4 +++ b/topology/sof-byt-rt5645.m4 @@ -86,7 +86,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Low Latency, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-byt-rt5651.m4 b/topology/sof-byt-rt5651.m4 index d2cdfad5e0d7..724c34e6410c 100644 --- a/topology/sof-byt-rt5651.m4 +++ b/topology/sof-byt-rt5651.m4 @@ -86,7 +86,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Low Latency, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-cht-max98090.m4 b/topology/sof-cht-max98090.m4 index 38244d76ff6e..627181ffcf46 100644 --- a/topology/sof-cht-max98090.m4 +++ b/topology/sof-cht-max98090.m4 @@ -86,7 +86,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Low Latency, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-cht-nocodec.m4 b/topology/sof-cht-nocodec.m4 index 23c6ef71ffa8..dae6dca39522 100644 --- a/topology/sof-cht-nocodec.m4 +++ b/topology/sof-cht-nocodec.m4 @@ -86,7 +86,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Low Latency, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index a2e6d52cbbac..141e03be4ead 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -58,7 +58,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Passthrough, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-hsw-rt5640.m4 b/topology/sof-hsw-rt5640.m4 index 9bf8976df364..272cb154a7d0 100644 --- a/topology/sof-hsw-rt5640.m4 +++ b/topology/sof-hsw-rt5640.m4 @@ -86,7 +86,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Low Latency, 6, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Low Latency, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/sof-icl-nocodec.m4 b/topology/sof-icl-nocodec.m4 index 9cabf7eff517..1dffe18c146e 100644 --- a/topology/sof-icl-nocodec.m4 +++ b/topology/sof-icl-nocodec.m4 @@ -58,7 +58,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Low Latency -PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Passthrough, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/test/test-all.m4 b/topology/test/test-all.m4 index 4f4241fb13fb..518c909cf129 100644 --- a/topology/test/test-all.m4 +++ b/topology/test/test-all.m4 @@ -76,7 +76,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Passthrough -PCM_DUPLEX_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(Passthrough, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/test/test-capture.m4 b/topology/test/test-capture.m4 index b21a47f725a6..4e10d3d31b53 100644 --- a/topology/test/test-capture.m4 +++ b/topology/test/test-capture.m4 @@ -60,7 +60,7 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # PCM Passthrough -PCM_CAPTURE_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_2) +PCM_CAPTURE_ADD(Passthrough, 0, PIPELINE_PCM_2) # # BE configurations - overrides config in ACPI if present diff --git a/topology/test/test-playback.m4 b/topology/test/test-playback.m4 index 1c6f7126d160..9833ea97ddcc 100644 --- a/topology/test/test-playback.m4 +++ b/topology/test/test-playback.m4 @@ -59,7 +59,7 @@ DAI_ADD(sof/pipe-dai-playback.m4, 48, 1000, 0, 0) # PCM Passthrough -PCM_PLAYBACK_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1) +PCM_PLAYBACK_ADD(Passthrough, 0, PIPELINE_PCM_1) # # BE configurations - overrides config in ACPI if present From 7c214b83b7f3a92c7a7784a7872d61007e5fa3f1 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Thu, 26 Jul 2018 16:01:00 -0500 Subject: [PATCH 227/324] topology: Fix SectionPCM macros PR43 and commit dc10876c20a5 ('topology: changes to SectionPCM macros') went a bit too far and removed a much-needed alignment between pcm id and dummy dai id. Tested on APL/Reef Chromebook Signed-off-by: Pierre-Louis Bossart --- topology/m4/pcm.m4 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/topology/m4/pcm.m4 b/topology/m4/pcm.m4 index 28bcb8fee4e6..f8b4ee679ad7 100644 --- a/topology/m4/pcm.m4 +++ b/topology/m4/pcm.m4 @@ -79,6 +79,7 @@ define(`PCM_PLAYBACK_ADD', ` id STR($2)' `' ` dai.STR($1 $2) {' +` id STR($2)' ` }' `' ` pcm."playback" {' @@ -95,6 +96,7 @@ define(`PCM_CAPTURE_ADD', ` id STR($2)' `' ` dai.STR($1 $2) {' +` id STR($2)' ` }' `' ` pcm."capture" {' @@ -111,6 +113,7 @@ define(`PCM_DUPLEX_ADD', ` id STR($2)' `' ` dai.STR($1 $2) {' +` id STR($2)' ` }' `' ` pcm."capture" {' From 8e50a510c3281db06619382ee1f0a3357a12bec9 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 31 Jul 2018 23:21:52 -0500 Subject: [PATCH 228/324] topology: add APL and GLK Chromebook support The APL and GLK topologies are identical except for a swap of SSPs and MCLKs. Tested on Reef and GLK TODO: 1. there is currently a kernel bug where only duplex pipelines can be assigned to the same PCM number. For now mark DMIC as device 99 to track this is a work-around to be modified in the near future 2. Edit the Virtual routes/widgets to remove kernel warnings (no functional impact) Signed-off-by: Pierre-Louis Bossart --- topology/Makefile.am | 6 +- topology/sof-apl-da7219.m4 | 144 +++++++++++++++++++++++++++++++++++++ topology/sof-glk-codec.m4 | 100 -------------------------- topology/sof-glk-da7219.m4 | 144 +++++++++++++++++++++++++++++++++++++ 4 files changed, 292 insertions(+), 102 deletions(-) create mode 100644 topology/sof-apl-da7219.m4 delete mode 100644 topology/sof-glk-codec.m4 create mode 100644 topology/sof-glk-da7219.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index e49af0878210..2c68376796f1 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -31,7 +31,8 @@ MACHINES = \ sof-hsw-rt5640.tplg \ sof-apl-tdf8532.tplg \ sof-apl-pcm512x.tplg \ - sof-glk-codec.tplg \ + sof-apl-da7219.tplg \ + sof-glk-da7219.tplg \ sof-icl-nocodec.tplg # Uncomment the following line if you want to debug conf files @@ -64,5 +65,6 @@ EXTRA_DIST = \ sof-hsw-rt5640.m4 \ sof-apl-tdf8532.m4 \ sof-apl-pcm512x.m4 \ - sof-glk-codec.m4 \ + sof-apl-da7219.m4 \ + sof-glk-da7219.m4 \ sof-icl-nocodec.m4 diff --git a/topology/sof-apl-da7219.m4 b/topology/sof-apl-da7219.m4 new file mode 100644 index 000000000000..514dd415b3fa --- /dev/null +++ b/topology/sof-apl-da7219.m4 @@ -0,0 +1,144 @@ +# +# Topology for AppoloLake with headset on SSP1, spk on SSP5 and DMIC capture +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') +include(`ssp.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include bxt DSP configuration +include(`platform/intel/bxt.m4') +include(`platform/intel/dmic.m4') + +# +# Define the pipelines +# +# PCM0 ----> volume -----> SSP5 (speaker - maxim98357a) +# PCM1 <---> volume <----> SSP1 (headset - da7219) +# PCM99 <---- volume <----- DMIC0 (dmic capture) +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency capture pipeline 3 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, + 3, 1, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency capture pipeline 4 on PCM 0 using max 4 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +#PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, +PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, + 4, 99, 4, s32le, + 48, 1000, 0, 0) + +# +# DAIs configuration +# + +# playback DAI is SSP5 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 5, SSP5-Codec, + PIPELINE_SOURCE_1, 2, s16le, + 48, 1000, 0, 0) + +# playback DAI is SSP1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 2, SSP, 1, SSP1-Codec, + PIPELINE_SOURCE_2, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 3, SSP, 1, SSP1-Codec, + PIPELINE_SINK_3, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is DMIC0 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 4, DMIC, 0, dmic01, + PIPELINE_SINK_4, 2, s32le, + 48, 1000, 0, 0) + +PCM_PLAYBACK_ADD(Speakers, 0, PIPELINE_PCM_1) +PCM_DUPLEX_ADD(Headset, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) +PCM_CAPTURE_ADD(DMIC01, 99, PIPELINE_PCM_4) + +# +# BE configurations - overrides config in ACPI if present +# + +#SSP 5 (ID: 0) with 19.2 MHz mclk with MCLK_ID 0 (unused), 1.536 MHz blck +DAI_CONFIG(SSP, 5, 0, SSP5-Codec, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), + SSP_CONFIG_DATA(SSP, 5, 16, 0))) + +#SSP 1 (ID: 1) with 19.2 MHz mclk with MCLK_ID 0, 1.92 MHz bclk +DAI_CONFIG(SSP, 1, 1, SSP1-Codec, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 1920000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 20, 3, 3), + SSP_CONFIG_DATA(SSP, 1, 16, 0))) + +# dmic01 (id: 2) +DAI_CONFIG(DMIC, 0, 2, dmic01, + DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, + DMIC_WORD_LENGTH(s32le), DMIC, 0, + # FIXME: what is the right configuration + # PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) + PDM_CONFIG(DMIC, 0, STEREO_PDM0))) + +## remove warnings with SST hard-coded routes (FIXME) + +VIRTUAL_WIDGET(ssp5 Tx, 0) +VIRTUAL_WIDGET(ssp1 Rx, 1) +VIRTUAL_WIDGET(ssp1 Tx, 2) +VIRTUAL_WIDGET(DMIC01 Rx, 3) +VIRTUAL_WIDGET(DMic, 4) +VIRTUAL_WIDGET(dmic01_hifi, 5) +VIRTUAL_WIDGET(hif5-0 Output, 6) +VIRTUAL_WIDGET(hif6-0 Output, 7) +VIRTUAL_WIDGET(hif7-0 Output, 8) +VIRTUAL_WIDGET(hifi1, 9) +VIRTUAL_WIDGET(hifi2, 10) +VIRTUAL_WIDGET(hifi3, 11) + +VIRTUAL_DAPM_ROUTE_OUT(codec0_out, SSP, 0, OUT, 12) +VIRTUAL_DAPM_ROUTE_OUT(codec1_out, SSP, 0, OUT, 13) +VIRTUAL_DAPM_ROUTE_OUT(ssp1 Tx, SSP, 0, OUT, 14) +VIRTUAL_DAPM_ROUTE_IN(ssp1 Rx, SSP, 0, IN, 15) +VIRTUAL_DAPM_ROUTE_OUT(Capture, SSP, 0, OUT, 16) +VIRTUAL_DAPM_ROUTE_OUT(SoC DMIC, SSP, 0, OUT, 17) +VIRTUAL_DAPM_ROUTE_IN(codec0_in, SSP, 0, IN, 18) + + + + + diff --git a/topology/sof-glk-codec.m4 b/topology/sof-glk-codec.m4 deleted file mode 100644 index d8fe3053e2a6..000000000000 --- a/topology/sof-glk-codec.m4 +++ /dev/null @@ -1,100 +0,0 @@ -# -# Topology for Geminilake with headset on SSP2, spk on SSP1 and DMIC capture -# - -# Include topology builder -include(`utils.m4') -include(`dai.m4') -include(`pipeline.m4') -include(`ssp.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include bxt DSP configuration -include(`platform/intel/bxt.m4') -include(`platform/intel/dmic.m4') - -# -# Define the pipelines -# -# PCM0 <---- volume <----- DMIC0 (dmic capture) -# PCM1 ----> volume -----> SSP1 (speaker - maxim98357a) -# PCM2 ----> volume -----> SSP2 (headset - da7219) -# - -# Low Latency capture pipeline 1 on PCM 0 using max 4 channels of s32le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-capture.m4, - 1, 0, 4, s32le, - 48, 1000, 0, 0, DMIC, 0, s32le, 2) - -# Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s16le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, - 2, 1, 2, s16le, - 48, 1000, 0, 0, SSP, 1, s16le, 2) - -# Low Latency playback pipeline 3 on PCM 2 using max 2 channels of s16le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_DAI_ADD(sof/pipe-volume-playback.m4, - 3, 2, 2, s16le, - 48, 1000, 0, 0, SSP, 2, s16le, 2) - -# -# DAIs configuration -# - -# capture DAI is DMIC0 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-capture.m4, - 1, DMIC, 0, DMIC0, - PIPELINE_SINK_1, 2, s32le, - 48, 1000, 0, 0) - -# playback DAI is SSP1 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 2, SSP, 1, SSP1-Codec, - PIPELINE_SOURCE_2, 2, s16le, - 48, 1000, 0, 0) - -# playback DAI is SSP2 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 3, SSP, 2, SSP2-Codec, - PIPELINE_SOURCE_3, 2, s16le, - 48, 1000, 0, 0) - -# PCM -PCM_CAPTURE_ADD(DMIC0, 1, 0, 0, PIPELINE_PCM_1) -PCM_PLAYBACK_ADD(SSP1, 2, 1, 1, PIPELINE_PCM_2) -PCM_PLAYBACK_ADD(SSP2, 3, 2, 2, PIPELINE_PCM_3) - -# -# BE configurations - overrides config in ACPI if present -# - -DAI_CONFIG(DMIC, 0, 0, DMIC0, - DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, - DMIC_WORD_LENGTH(s32le), DMIC, 0, - PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) - -#SSP 1 (ID: 1) with 19.2MHz mclk with MCLK_ID 1 -DAI_CONFIG(SSP, 1, 1, SSP1-Codec, - SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), - SSP_CLOCK(bclk, 1920000, codec_slave), - SSP_CLOCK(fsync, 48000, codec_slave), - SSP_TDM(2, 20, 3, 3), - SSP_CONFIG_DATA(SSP, 1, 16, 1))) - -#SSP 2 (ID: 2) with 19.2MHz mclk with MCLK_ID 1 -DAI_CONFIG(SSP, 2, 2, SSP2-Codec, - SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), - SSP_CLOCK(bclk, 1920000, codec_slave), - SSP_CLOCK(fsync, 48000, codec_slave), - SSP_TDM(2, 20, 3, 3), - SSP_CONFIG_DATA(SSP, 2, 16, 1))) diff --git a/topology/sof-glk-da7219.m4 b/topology/sof-glk-da7219.m4 new file mode 100644 index 000000000000..121f4edeb67a --- /dev/null +++ b/topology/sof-glk-da7219.m4 @@ -0,0 +1,144 @@ +# +# Topology for AppoloLake with headset on SSP2, spk on SSP1 and DMIC capture +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') +include(`ssp.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include bxt DSP configuration +include(`platform/intel/bxt.m4') +include(`platform/intel/dmic.m4') + +# +# Define the pipelines +# +# PCM0 ----> volume -----> SSP1 (speaker - maxim98357a) +# PCM1 <---> volume <----> SSP2 (headset - da7219) +# PCM99 <---- volume <----- DMIC0 (dmic capture) +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency capture pipeline 3 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, + 3, 1, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency capture pipeline 4 on PCM 0 using max 4 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +#PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, +PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, + 4, 99, 4, s32le, + 48, 1000, 0, 0) + +# +# DAIs configuration +# + +# playback DAI is SSP1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 1, SSP1-Codec, + PIPELINE_SOURCE_1, 2, s16le, + 48, 1000, 0, 0) + +# playback DAI is SSP1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 2, SSP, 2, SSP2-Codec, + PIPELINE_SOURCE_2, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is SSP1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 3, SSP, 2, SSP2-Codec, + PIPELINE_SINK_3, 2, s16le, + 48, 1000, 0, 0) + +# capture DAI is DMIC0 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 4, DMIC, 0, dmic01, + PIPELINE_SINK_4, 2, s32le, + 48, 1000, 0, 0) + +PCM_PLAYBACK_ADD(Speakers, 0, PIPELINE_PCM_1) +PCM_DUPLEX_ADD(Headset, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) +PCM_CAPTURE_ADD(DMIC01, 99, PIPELINE_PCM_4) + +# +# BE configurations - overrides config in ACPI if present +# + +#SSP 1 (ID: 0) with 19.2 MHz mclk with MCLK_ID 1 (unused), 1.536 MHz blck +DAI_CONFIG(SSP, 1, 0, SSP1-Codec, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 1536000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 16, 3, 3), + SSP_CONFIG_DATA(SSP, 1, 16, 1))) + +#SSP 2 (ID: 1) with 19.2 MHz mclk with MCLK_ID 1, 1.92 MHz bclk +DAI_CONFIG(SSP, 2, 1, SSP2-Codec, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 19200000, codec_mclk_in), + SSP_CLOCK(bclk, 1920000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 20, 3, 3), + SSP_CONFIG_DATA(SSP, 2, 16, 1))) + +# dmic01 (id: 2) +DAI_CONFIG(DMIC, 0, 2, dmic01, + DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, + DMIC_WORD_LENGTH(s32le), DMIC, 0, + # FIXME: what is the right configuration + # PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) + PDM_CONFIG(DMIC, 0, STEREO_PDM0))) + +## remove warnings with SST hard-coded routes (FIXME) + +VIRTUAL_WIDGET(ssp5 Tx, 0) +VIRTUAL_WIDGET(ssp1 Rx, 1) +VIRTUAL_WIDGET(ssp1 Tx, 2) +VIRTUAL_WIDGET(DMIC01 Rx, 3) +VIRTUAL_WIDGET(DMic, 4) +VIRTUAL_WIDGET(dmic01_hifi, 5) +VIRTUAL_WIDGET(hif5-0 Output, 6) +VIRTUAL_WIDGET(hif6-0 Output, 7) +VIRTUAL_WIDGET(hif7-0 Output, 8) +VIRTUAL_WIDGET(hifi1, 9) +VIRTUAL_WIDGET(hifi2, 10) +VIRTUAL_WIDGET(hifi3, 11) + +VIRTUAL_DAPM_ROUTE_OUT(codec0_out, SSP, 0, OUT, 12) +VIRTUAL_DAPM_ROUTE_OUT(codec1_out, SSP, 0, OUT, 13) +VIRTUAL_DAPM_ROUTE_OUT(ssp1 Tx, SSP, 0, OUT, 14) +VIRTUAL_DAPM_ROUTE_IN(ssp1 Rx, SSP, 0, IN, 15) +VIRTUAL_DAPM_ROUTE_OUT(Capture, SSP, 0, OUT, 16) +VIRTUAL_DAPM_ROUTE_OUT(SoC DMIC, SSP, 0, OUT, 17) +VIRTUAL_DAPM_ROUTE_IN(codec0_in, SSP, 0, IN, 18) + + + + + From 5eb017512ec0664ab29e00bf4d4c3ce15b99fcee Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 7 Aug 2018 18:55:19 +0300 Subject: [PATCH 229/324] SOFT: Add equalizer tuning scripts and small examples This patch adds support to SOFT to setup FIR and IIR equalizer types. The examples scripts for simple FIR loudness effect, IIR loudness effect and speaker equalization case demonstrate the usage of the tool. The output ".txt" files will be possible to apply with alsactl to setup the equalizers in SOF. Signed-off-by: Seppo Ingalsuo --- tune/eq/eq_align.m | 52 ++++ tune/eq/eq_alsactl_write.m | 56 ++++ tune/eq/eq_blob_write.m | 49 ++++ tune/eq/eq_coef_quant.m | 50 ++++ tune/eq/eq_compute.m | 458 ++++++++++++++++++++++++++++++ tune/eq/eq_compute_response.m | 45 +++ tune/eq/eq_compute_tot_response.m | 50 ++++ tune/eq/eq_defaults.m | 111 ++++++++ tune/eq/eq_define_parametric_eq.m | 137 +++++++++ tune/eq/eq_fir_blob_merge.m | 50 ++++ tune/eq/eq_fir_blob_pack.m | 139 +++++++++ tune/eq/eq_fir_blob_quant.m | 89 ++++++ tune/eq/eq_iir_blob_merge.m | 52 ++++ tune/eq/eq_iir_blob_pack.m | 84 ++++++ tune/eq/eq_iir_blob_quant.m | 115 ++++++++ tune/eq/eq_norm.m | 114 ++++++++ tune/eq/eq_plot.m | 172 +++++++++++ tune/eq/example_fir_eq.m | 119 ++++++++ tune/eq/example_iir_eq.m | 136 +++++++++ tune/eq/example_spk_eq.m | 145 ++++++++++ 20 files changed, 2223 insertions(+) create mode 100644 tune/eq/eq_align.m create mode 100644 tune/eq/eq_alsactl_write.m create mode 100644 tune/eq/eq_blob_write.m create mode 100644 tune/eq/eq_coef_quant.m create mode 100644 tune/eq/eq_compute.m create mode 100644 tune/eq/eq_compute_response.m create mode 100644 tune/eq/eq_compute_tot_response.m create mode 100644 tune/eq/eq_defaults.m create mode 100644 tune/eq/eq_define_parametric_eq.m create mode 100644 tune/eq/eq_fir_blob_merge.m create mode 100644 tune/eq/eq_fir_blob_pack.m create mode 100644 tune/eq/eq_fir_blob_quant.m create mode 100644 tune/eq/eq_iir_blob_merge.m create mode 100644 tune/eq/eq_iir_blob_pack.m create mode 100644 tune/eq/eq_iir_blob_quant.m create mode 100644 tune/eq/eq_norm.m create mode 100644 tune/eq/eq_plot.m create mode 100644 tune/eq/example_fir_eq.m create mode 100644 tune/eq/example_iir_eq.m create mode 100644 tune/eq/example_spk_eq.m diff --git a/tune/eq/eq_align.m b/tune/eq/eq_align.m new file mode 100644 index 000000000000..71edfd632d85 --- /dev/null +++ b/tune/eq/eq_align.m @@ -0,0 +1,52 @@ +function [am, offs, p] = eq_align(f, m, f_align, m_align) + +%% [am, offs, p] = eq_align(f, m, f_align, m_align) +% +% Move by adding/subtracting an offset to frequency response +% curve to cross desired frequency and magnitude, usually 997 Hz, 0 dB +% +% Input +% f - frequencies +% m - magnitude response +% +% Output +% am - aligned magnitude resposne +% offs - offset (gain) in decibels used +% p - index of f_align in f +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +p = find(f < f_align, 1, 'last')+1; +offs = m_align-m(p); +am = m+offs; + +end diff --git a/tune/eq/eq_alsactl_write.m b/tune/eq/eq_alsactl_write.m new file mode 100644 index 000000000000..56b798889e1c --- /dev/null +++ b/tune/eq/eq_alsactl_write.m @@ -0,0 +1,56 @@ +function eq_alsactl_write(fn, blob8) + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Write blob +fh = fopen(fn, 'w'); + +%% Pad blob length to multiple of four bytes +n_orig = length(blob8); +n_new = ceil(n_orig/4); +blob8_new = zeros(1, n_new*4); +blob8_new(1:n_orig) = blob8; + +%% Convert to 32 bit +blob32 = zeros(1, n_new, 'uint32'); +k = 2.^[0 8 16 24]; +for i=1:n_new + j = (i-1)*4; + blob32(i) = blob8_new(j+1)*k(1) + blob8_new(j+2)*k(2) ... + + blob8_new(j+3)*k(3) + blob8_new(j+4)*k(4); +end +for i=1:n_new-1 + fprintf(fh, '%ld,', blob32(i)); +end +fprintf(fh, '%ld,\n', blob32(end)); +fclose(fh); + +end diff --git a/tune/eq/eq_blob_write.m b/tune/eq/eq_blob_write.m new file mode 100644 index 000000000000..95f83854ba22 --- /dev/null +++ b/tune/eq/eq_blob_write.m @@ -0,0 +1,49 @@ +function eq_blob_write(fn, blob8) + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Write blob +fh = fopen(fn, 'wb'); +fwrite(fh, blob8, 'uint8'); +fclose(fh); + +%% Print as 8 bit hex +nb = length(blob8); +nl = ceil(nb/16); +for i = 1:nl + m = min(16, nb-(i-1)*16); + for j = 1:m + fprintf(1, "%02x ", blob8((i-1)*16 + j)); + end + fprintf(1, "\n"); +end + +end diff --git a/tune/eq/eq_coef_quant.m b/tune/eq/eq_coef_quant.m new file mode 100644 index 000000000000..e56efca3350d --- /dev/null +++ b/tune/eq/eq_coef_quant.m @@ -0,0 +1,50 @@ +function qc = eq_coef_quant(c, bits, qf) + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +scale = 2^qf; +cmax = 2^(bits-1)-1; +cmin = -2^(bits-1); +qc = int64(round(c*scale)); +idx = find(qc > cmax); +if ~isempty(idx) + fprintf('Warning: Max. value of Q format is exceeded: %d (%d)\n', ... + qc(idx(1)), cmax); + qc(idx) = cmax; +end +idx = find(qc < cmin); +if ~isempty(idx) + fprintf('Warning: Min. value of Q format is exceeded: %d (%d)\n', ... + qc(idx(1)), cmin); + qc(idx) = cmin; +end + +end diff --git a/tune/eq/eq_compute.m b/tune/eq/eq_compute.m new file mode 100644 index 000000000000..960bd8671300 --- /dev/null +++ b/tune/eq/eq_compute.m @@ -0,0 +1,458 @@ +function eq = eq_compute( eq ) + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Extrapolate response to 0..fs/2, convert to logaritmic grid, and smooth +% with 1/N octave filter +eq = preprocess_responses(eq); + +%% Define target (e.g. speaker) response as parametric filter. This could also +% be numerical data interpolated to the grid. +if length(eq.parametric_target_response) > 0 + [eq.b_t, eq.a_t] = eq_define_parametric_eq( ... + eq.parametric_target_response, eq.fs); + eq.t_db = eq_compute_response(eq.b_t, eq.a_t, eq.f, eq.fs); +end + +if isempty(eq.t_db) + fprintf('Warning: No target response is defined.\n'); +end + +%% Align responses at some frequency and dB +[eq.m_db_s, offs] = eq_align(eq.f, eq.m_db_s, eq.f_align, eq.db_align); +eq.raw_m_db = eq.raw_m_db + offs; +eq.m_db = eq.m_db + offs; +eq.t_db = eq_align(eq.f, eq.t_db, eq.f_align, eq.db_align); + +%% Error to equalize = target - raw response, apply 1/N octave smoothing to +% soften the EQ shape +eq.err_db = eq.t_db - eq.m_db; +[eq.err_db_s, eq.logsmooth_noct] = logsmooth(eq.f, eq.err_db, eq.logsmooth_eq); + +%% Parametric IIR EQ definition +if eq.enable_iir + [eq.b_p, eq.a_p] = eq_define_parametric_eq(eq.peq, eq.fs); + if length(eq.b_p) > 2*eq.iir_biquads_max+1 + error('Maximum number of IIR biquads is exceeded'); + end +else + eq.b_p = 1; + eq.a_p = 1; +end +[eq.iir_eq_db, eq.iir_eq_ph, eq.iir_eq_gd] = eq_compute_response(eq.b_p, ... + eq.a_p, eq.f, eq.fs); + + +%% FIR EQ computation +% Find remaining responses error ater IIR for FIR to handle +if eq.fir_compensate_iir + eq.err2_db = eq.err_db_s-eq.iir_eq_db; +else + eq.err2_db = eq.err_db_s; +end + +if eq.enable_fir + [eq.t_fir_db, eq.fmin_fir, eq.fmax_fir] = ... + get_fir_target(eq.f, eq.err2_db, eq.fmin_fir, eq.fmax_fir, ... + eq.amin_fir, eq.amax_fir, eq.logsmooth_noct, eq.fir_autoband); + + if eq.fir_minph + eq.b_fir = compute_minph_fir(eq.f, eq.t_fir_db, ... + eq.fir_length, eq.fs, eq.fir_beta); + else + eq.b_fir = compute_linph_fir(eq.f, eq.t_fir_db, ... + eq.fir_length, eq.fs, eq.fir_beta); + end +else + eq.b_fir = 1; + eq.tfirdb = zeros(1,length(eq.f)); +end + +%% Update all responses +eq = eq_compute_tot_response(eq); + +%% Normalize +eq = eq_norm(eq); + +end + +function eq = preprocess_responses(eq) +%% Usually too narrow measurement without the lowest and highest frequencies +[f0, m0, gd0] = fix_response_dcnyquist_mult(eq.raw_f, eq.raw_m_db, ... + eq.raw_gd_s, eq.fs); + +%% Create dense logarithmic frequency grid, then average possible multiple +% measurements +[eq.f, eq.m_db, eq.gd_s, eq.num_responses] = map_to_logfreq_mult(f0, m0, ... + gd0, 1, eq.fs/2, eq.np_fine); + +%% Smooth response with 1/N octave filter for plotting +eq.m_db_s = logsmooth(eq.f, eq.m_db, eq.logsmooth_plot); + +if length(eq.target_m_db) > 0 + % Use target_m_db as dummy group delay, ignore other than magnitude + [f0, m0, ~] = fix_response_dcnyquist_mult(eq.target_f, ... + eq.target_m_db, [], eq.fs); + [~, eq.t_db, ~, ~] = map_to_logfreq_mult(f0, m0, [], 1, ... + eq.fs/2, eq.np_fine); +end +end + + +function [f_hz, m_db, gd_s] = fix_response_dcnyquist(f_hz0, m_db0, gd_s0, fs) +%% Append DC and Fs/2 if missing +f_hz = f_hz0; +m_db = m_db0; +gd_s = gd_s0; +if min(f_hz) > 0 + f_hz = [0 f_hz]; + m_db = [m_db(1) m_db]; % DC the same as 1st measured point + if length(gd_s) > 0 + gd_s = [gd_s(1) gd_s]; % DC the same as 1st measured point + end +end +if max(f_hz) < fs/2 + f_hz = [f_hz fs/2]; + m_db = [m_db m_db(end)]; % Fs/2 the same as last measured point + if length(gd_s) > 0 + gd_s = [gd_s gd_s(end)]; % Fs/2 the same as last measured point + end +end +end + +function [f_hz, m_db, gd_s] = fix_response_dcnyquist_mult(f_hz0, m_db0, ... + gd_s0, fs) + +if iscolumn(f_hz0) + f_hz0 = f_hz0.'; +end +if iscolumn(m_db0) + m_db0 = m_db0.'; +end +if iscolumn(gd_s0) + gd_s0 = gd_s0.'; +end + +s1 = size(f_hz0); +s2 = size(m_db0); +s3 = size(gd_s0); + +if s1(1) == 0 + error('Frequencies vector is empty'); +end +if (s1(1) ~= s2(1)) + error('There must be equal number of frequency and magnitude data'); +end +if (s1(2) ~= s2(2)) + error('There must be equal number of points in frequency, magnitude, and group delay data'); +end +if sum(s3) == 0 + gd_s0 = zeros(s2(1),s2(2)); +end +for i=1:s1(1) + [f_hz(i,:), m_db(i,:), gd_s(i,:)] = fix_response_dcnyquist(... + f_hz0(i,:), m_db0(i,:), gd_s0(i,:), fs); +end + +end + +function [f_hz, m_db, gd_s] = map_to_logfreq(f_hz0, m_db0, gd_s0, f1, f2, np) +%% Create logarithmic frequency vector and interpolate +f_hz = logspace(log10(f1),log10(f2), np); +m_db = interp1(f_hz0, m_db0, f_hz); +gd_s = interp1(f_hz0, gd_s0, f_hz); +m_db(end) = m_db(end-1); % Fix NaN in the end +gd_s(end) = gd_s(end-1); % Fix NaN in the end +end + +function [f_hz, mm_db, mgd_s, num] = map_to_logfreq_mult(f_hz0, m_db0, ... + gd_s0, f1, f2, np) + +s1 = size(f_hz0); +s2 = size(m_db0); +s3 = size(gd_s0); +if (s1(1) ~= s2(1)) + error('There must be equal number of frequency and magnitude data sets'); +end +if (s1(2) ~= s2(2)) + error('There must be equal number of points in frequency and magnitude data'); +end +num = s1(1); +if sum(s3) == 0 + gd_s0 = zeros(s2(1),s2(2)); +end +for i=1:num + [f_hz, m_db(i,:), gd_s(i,:)] = map_to_logfreq(f_hz0(i,:), ... + m_db0(i,:), gd_s0(i,:), f1, f2, np); +end + +if num > 1 + mm_db = mean(m_db); + mgd_s = mean(gd_s); +else + mm_db = m_db; + mgd_s = gd_s; +end +end + +function [ms_db, noct] = logsmooth(f, m_db, c) + +%% Create a 1/N octave smoothing filter +ind1 = find(f < 1000); +ind2 = find(f < 2000); +noct = ind2(end)-ind1(end); +n = 2*round(c*noct/2); +b_smooth = ones(1,n)*1/n; + +%% Smooth the response +tmp = filter(b_smooth, 1, m_db); +ms_db = [tmp(n/2+1:end) linspace(tmp(end), m_db(end), n/2)]; +ms_db(1:n) = ones(1,n)*ms_db(n); +end + +function [m_db, fmin_fir, fmax_fir] = get_fir_target(fhz, err2db, fmin_fir, ... + fmax_fir, amin_fir, amax_fir, noct, auto) + + +%% Find maximum in 1-6 kHz band +idx = find(fhz > 1e3, 1, 'first') - 1; +m_db = err2db - err2db(idx); +if auto + cf = [1e3 6e3]; + ind1 = find(fhz < cf(2)); + ind2 = find(fhz(ind1) > cf(1)); + ipeak = find(m_db(ind2) == max(m_db(ind2))) + ind2(1); + ind1 = find(fhz < cf(1)); + ind2 = find(m_db(ind1) > m_db(ipeak)); + if length(ind2) > 0 + fmin_fir = fhz(ind2(end)); + end + ind1 = find(fhz > cf(2)); + ind2 = find(m_db(ind1) > m_db(ipeak)) + ind1(1); + if length(ind2) > 0 + fmax_fir = fhz(ind2(1)); + end +end + +%% Find FIR target response +ind1 = find(fhz < fmin_fir); +ind2 = find(fhz > fmax_fir); +p1 = ind1(end)+1; +if length(ind2) > 0 + p2 = ind2(1)-1; +else + p2 = length(fhz); +end +m_db(ind1) = m_db(p1); +m_db(ind2) = m_db(p2); +ind = find(m_db > amax_fir); +m_db(ind) = amax_fir; +ind = find(m_db < amin_fir); +m_db(ind) = amin_fir; + +%% Smooth high frequency corner with spline +nn = round(noct/8); +x = [p2-nn p2-nn+1 p2+nn-1 p2+nn]; +if max(x) < length(m_db) + y = m_db(x); + xx = p2-nn:p2+nn; + yy = spline(x, y, xx); + m_db(p2-nn:p2+nn) = yy; +end + +%% Smooth low frequency corner with spline +nn = round(noct/8); +x = [p1-nn p1-nn+1 p1+nn-1 p1+nn]; +if min(x) > 0 + y = m_db(x); + xx = p1-nn:p1+nn; + yy = spline(x, y, xx); + m_db(p1-nn:p1+nn) = yy; +end + +end + +function b = compute_linph_fir(f_hz, m_db, taps, fs, beta) +if nargin < 5 + beta = 4; +end +if mod(taps,2) == 0 + fprintf('Warning: Even FIR length requested.\n'); +end +n_fft = 2*2^ceil(log(taps)/log(2)); +n_half = n_fft/2+1; +f_fft = linspace(0, fs/2, n_half); +m_lin = 10.^(m_db/20); +if f_hz(1) > 0 + f_hz = [0 f_hz]; + m_lin = [m_lin(1) m_lin]; +end +a_half = interp1(f_hz, m_lin, f_fft, 'linear'); +a = [a_half conj(a_half(end-1:-1:2))]; +h = real(fftshift(ifft(a))); +b0 = h(n_half-floor((taps-1)/2):n_half+floor((taps-1)/2)); +win = kaiser(length(b0), beta)'; +b = b0 .* win; +if length(b) < taps + % Append to even length + b = [b 0]; +end +end + +function b_fir = compute_minph_fir(f, m_db, fir_length, fs, beta) + +%% Design double length H^2 FIR +n = 2*fir_length+1; +m_lin2 = (10.^(m_db/20)).^2; +m_db2 = 20*log10(m_lin2); +blin = compute_linph_fir(f, m_db2, n, fs, beta); + +%% Find zeros inside unit circle +myeps = 1e-3; +hdzeros = roots(blin); +ind1 = find( abs(hdzeros) < (1-myeps) ); +minzeros = hdzeros(ind1); + +%% Find double zeros at unit circle +ind2 = find( abs(hdzeros) > (1-myeps) ); +outzeros = hdzeros(ind2); +ind3 = find( abs(outzeros) < (1+myeps) ); +circlezeros = outzeros(ind3); + +%% Get half of the unit circle zeros +if isempty(circlezeros) + %% We are fine ... +else + %% Eliminate double zeros + cangle = angle(circlezeros); + [sorted_cangle, ind] = sort(cangle); + sorted_czeros = circlezeros(ind); + pos = find(angle(sorted_czeros) > 0); + neg = find(angle(sorted_czeros) < 0); + pos_czeros = sorted_czeros(pos); + neg_czeros = sorted_czeros(neg(end:-1:1)); + h1 = []; + for i = 1:2:length(pos_czeros)-1 + x=mean(angle(pos_czeros(i:i+1))); + h1 = [h1' complex(cos(x),sin(x))]'; + end + h2 = []; + for i = 1:2:length(neg_czeros)-1; + x=mean(angle(neg_czeros(i:i+1))); + h2 = [h2' complex(cos(x),sin(x))]'; + end + halfcirclezeros = [h1' h2']'; + if length(halfcirclezeros)*2 < length(circlezeros)-0.1 + %% Replace the last zero pair + halfcirclezeros = [halfcirclezeros' complex(-1, 0)]'; + end + minzeros = [ minzeros' halfcirclezeros' ]'; +end + +%% Convert to transfer function +bmin = mypoly(minzeros); + +%% Scale peak in passhz to max m_db +hmin = freqz(bmin, 1, 512, fs); +b_fir = 10^(max(m_db)/20)*bmin/max(abs(hmin)); + +end + +function tf = mypoly( upolyroots ) + +% Sort roots to increasing angle to ensure more consistent behavior +aa = abs(angle(upolyroots)); +[sa, ind] = sort(aa); +polyroots = upolyroots(ind); + +n = length(polyroots); +n1 = 16; % do not change, hardwired to 16 code below + +if n < (2*n1+1) + % No need to split + tf = poly(polyroots); +else + % Split roots evenly to 16 poly computations + % The fist polys will rpb+1 roots and the rest + % rpb roots to compute + rpb = floor(n/n1); + rem = mod(n,n1); + i1 = zeros(1,n1); + i2 = zeros(1,n1); + i1(1) = 1; + for i = 1:n1-1; + if rem > 0 + i2(i) = i1(i)+rpb; + rem = rem-1; + else + i2(i) = i1(i)+rpb-1; + end + i1(i+1) = i2(i)+1; + end + i2(n1) = n; + tf101 = poly(polyroots(i1(1):i2(1))); + tf102 = poly(polyroots(i1(2):i2(2))); + tf103 = poly(polyroots(i1(3):i2(3))); + tf104 = poly(polyroots(i1(4):i2(4))); + tf105 = poly(polyroots(i1(5):i2(5))); + tf106 = poly(polyroots(i1(6):i2(6))); + tf107 = poly(polyroots(i1(7):i2(7))); + tf108 = poly(polyroots(i1(8):i2(8))); + tf109 = poly(polyroots(i1(9):i2(9))); + tf110 = poly(polyroots(i1(10):i2(10))); + tf111 = poly(polyroots(i1(11):i2(11))); + tf112 = poly(polyroots(i1(12):i2(12))); + tf113 = poly(polyroots(i1(13):i2(13))); + tf114 = poly(polyroots(i1(14):i2(14))); + tf115 = poly(polyroots(i1(15):i2(15))); + tf116 = poly(polyroots(i1(16):i2(16))); + % Combine coefficients with convolution + tf21 = conv(tf101, tf116); + tf22 = conv(tf102, tf115); + tf23 = conv(tf103, tf114); + tf24 = conv(tf104, tf113); + tf25 = conv(tf105, tf112); + tf26 = conv(tf106, tf111); + tf27 = conv(tf107, tf110); + tf28 = conv(tf108, tf109); + tf31 = conv(tf21, tf28); + tf32 = conv(tf22, tf27); + tf33 = conv(tf23, tf26); + tf34 = conv(tf24, tf25); + tf41 = conv(tf31, tf34); + tf42 = conv(tf32, tf33); + tf = conv(tf41, tf42); + + % Ensure the tf coefficents are real if rounding issues + tf = real(tf); +end + +end diff --git a/tune/eq/eq_compute_response.m b/tune/eq/eq_compute_response.m new file mode 100644 index 000000000000..cf8a295381e0 --- /dev/null +++ b/tune/eq/eq_compute_response.m @@ -0,0 +1,45 @@ +function [m, ph, gd] = eq_compute_response(b, a, f, fs) + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +h = freqz(b, a, f, fs); +m = 20*log10(abs(h)); +ph = 180/pi*angle(h); + +lb = length(b); +la = length(a); +if lb == 1 && la == 1 + gd = zeros(1, length(f)); +else + gd = 1/fs*grpdelay(b, a, f, fs); +end + +end diff --git a/tune/eq/eq_compute_tot_response.m b/tune/eq/eq_compute_tot_response.m new file mode 100644 index 000000000000..828b9365280c --- /dev/null +++ b/tune/eq/eq_compute_tot_response.m @@ -0,0 +1,50 @@ +function eq = eq_compute_tot_response(eq) + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +% FIR response and combined IIR+FIR EQ +[eq.iir_eq_db, eq.iir_eq_ph, eq.iir_eq_gd] = eq_compute_response(eq.b_p, eq.a_p, eq.f, eq.fs); +[eq.fir_eq_db, eq.fir_eq_ph, eq.fir_eq_gd] = eq_compute_response(eq.b_fir, 1, eq.f, eq.fs); +eq.tot_eq_db = eq.iir_eq_db + eq.fir_eq_db; +eq.tot_eq_gd = eq.iir_eq_gd + eq.fir_eq_gd; + +% Simulated equalized result +eq.m_eqd = eq.m_db + eq.tot_eq_db; % Simulated response +eq.m_eqd_s = eq.m_db_s + eq.tot_eq_db; % Smoothed simulated response +eq.gd_eqd = eq.gd_s' + eq.tot_eq_gd; + +% Align +[eq.m_eqd_s, adjust, p] = eq_align(eq.f, eq.m_eqd_s, eq.f_align, eq.db_align); +eq.m_eqd = eq.m_eqd + adjust; +eq.m_eq_loss = eq.tot_eq_db(p); +eq.m_eqd_abs = eq.m_db_abs+eq.m_eq_loss; + +end diff --git a/tune/eq/eq_defaults.m b/tune/eq/eq_defaults.m new file mode 100644 index 000000000000..7c00a195c9e2 --- /dev/null +++ b/tune/eq/eq_defaults.m @@ -0,0 +1,111 @@ +function p = eq_defaults + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +% Misc +p.plot_figs = 0; +p.fn = 'configuration.txt'; +p.fs = 48e3; +p.f_align = 997; +p.db_align = 0; +p.logsmooth_plot = 1/3; % Smooth over 1/3 octaves +p.logsmooth_eq = 1/3; % Smooth over 1/3 octaves +p.np_fine = 5000; % 5000 point design grid + +% Parametric EQ IDs +p.PEQ_HP1 = 1; p.PEQ_HP2 = 2; p.PEQ_LP1 = 3; p.PEQ_LP2 = 4; +p.PEQ_LS1 = 5; p.PEQ_LS2 = 6; p.PEQ_HS1 = 7; p.PEQ_HS2 = 8; +p.PEQ_PN2 = 9; p.PEQ_LP4 = 10; p.PEQ_HP4 = 11; + +% FIR constraints +p.fmin_fir = 200; % +p.fmax_fir = 15e3; % +p.amax_fir = 20; +p.amin_fir = -20; +p.fir_beta = 8; +p.fir_length = 63; +p.fir_minph = 0; % 0 = linear phase, 1 = minimum phase +% Adjust fmin_fir, fmax_fir automatically for least gain loss in FIR +p.fir_autoband = 1; +p.enable_fir = 1; + +% IIR conf +p.iir_biquads_max = 6; +p.enable_iir = 0; + +% Initialize other fields those are computed later to allow use of struct +% arrays +p.raw_f = [10 100e3]; +p.raw_m_db = [0 0]; +p.raw_gd_s = []; +p.f = []; +p.m_db = []; +p.gd_s = []; +p.num_responses = 0; +p.m_db_s = []; +p.gd_s_s = []; +p.logsmooth_noct = 0; +p.b_t = []; +p.a_t = []; +p.t_db = []; +p.m_db_abs = 0; +p.m_db_offs = 0; +p.raw_m_noalign_db = []; +p.err_db = []; +p.b_p = 0; +p.a_p = 0; +p.iir_eq_db = []; +p.iir_eq_ph = []; +p.iir_eq_gd = []; +p.err2_db = []; +p.t_fir_db = []; +p.b_fir = []; +p.fir_eq_db = []; +p.fir_eq_ph = []; +p.fir_eq_gd = []; +p.tot_eq_db = []; +p.tot_eq_gd = []; +p.m_eqd = []; +p.gd_eqd = []; +p.m_eq_loss = 0; +p.m_eqd_abs = 0; +p.sim_m_db = []; +p.parametric_target_response = []; +p.target_f = [10 100e3]; +p.target_m_db = [0 0]; +p.fir_compensate_iir = 1; +p.p_fmin = 10; +p.p_fmax = 30e3; +p.name = ''; +p.norm_type = 'loudness'; % loudness/peak/1k +p.norm_offs_db = 1; + +end diff --git a/tune/eq/eq_define_parametric_eq.m b/tune/eq/eq_define_parametric_eq.m new file mode 100644 index 000000000000..300103d76f5c --- /dev/null +++ b/tune/eq/eq_define_parametric_eq.m @@ -0,0 +1,137 @@ +function [b_t, a_t] = eq_define_parametric_eq(peq, fs) + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +% Parametric types +PEQ_HP1 = 1; PEQ_HP2 = 2; PEQ_LP1 = 3; PEQ_LP2 = 4; +PEQ_LS1 = 5; PEQ_LS2 = 6; PEQ_HS1 = 7; PEQ_HS2 = 8; +PEQ_PN2 = 9; PEQ_LP4 = 10; PEQ_HP4 = 11; + +%figure(100); +%fv = logspace(log10(20),log10(20e3),500); +%hold on; +sp = size(peq); +b_t = 1; a_t = 1; +for i=1:sp(1) + type = peq(i,1); + f = peq(i,2); + g = peq(i,3); + bw = peq(i,4); + if f < fs/2 + switch peq(i,1) + case PEQ_HP1, [b0, a0] = butter(1, 2*f/fs, 'high'); + case PEQ_HP2, [b0, a0] = butter(2, 2*f/fs, 'high'); + case PEQ_HP4, [b0, a0] = butter(4, 2*f/fs, 'high'); + case PEQ_LP1, [b0, a0] = butter(1, 2*f/fs); + case PEQ_LP2, [b0, a0] = butter(2, 2*f/fs); + case PEQ_LP4, [b0, a0] = butter(4, 2*f/fs); + case PEQ_LS1, [b0, a0] = low_shelf_1st(f, g, fs); + case PEQ_LS2, [b0, a0] = low_shelf_2nd(f, g, fs); + case PEQ_HS1, [b0, a0] = high_shelf_1st(f, g, fs); + case PEQ_HS2, [b0, a0] = high_shelf_2nd(f, g, fs); + case PEQ_PN2, [b0, a0] = peak_2nd(f, g, bw, fs); + otherwise + error('Unknown parametric EQ type'); + end + %h = freqz(b0, a0, fv, fs); + %semilogx(fv, 20*log10(abs(h)),'g--'); + b_t=conv(b_t, b0); a_t = conv(a_t, a0); + end +end +%h = freqz(b_t, a_t, fv, fs); +%semilogx(fv, 20*log10(abs(h)),'b'); +%hold off; grid on; axis([20 20e3 -1 12]); +%xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)'); +%print -dpng peq.png; +end + +function [b, a] = low_shelf_1st(fhz, gdb, fs) +zw = 2*pi*fhz; +w = wmap(zw, fs); +glin = 10^(gdb/20); +bs = [1 glin*w]; +as = [1 w]; +[b, a] = my_bilinear(bs, as, fs); +end + +function [b, a] = low_shelf_2nd(fhz, gdb, fs) +zw = 2*pi*fhz; +w = wmap(zw, fs); +glin = 10^(gdb/20); +bs = [1 w*sqrt(2*glin) glin*w^2]; +as = [1 w*sqrt(2) w^2]; +[b, a] = my_bilinear(bs, as, fs); +end + +function [b, a] = high_shelf_1st(fhz, gdb, fs) +zw = 2*pi*fhz; +w = wmap(zw, fs); +glin = 10^(gdb/20); +bs = [glin w]; +as = [1 w]; +[b, a] = my_bilinear(bs, as, fs); +end + +function [b, a] = high_shelf_2nd(fhz, gdb, fs) +zw = 2*pi*fhz; +w = wmap(zw, fs); +glin = 10^(gdb/20); +bs = [glin w*sqrt(2*glin) w^2]; +as = [1 w*sqrt(2) w^2]; +[b, a] = my_bilinear(bs, as, fs); +end + + +function [b, a] = peak_2nd(fhz, gdb, Q, fs) + % Reference http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt + A = 10^(gdb/40); % Square root of linear gain + wc = 2*pi*fhz/fs; + alpha = sin(wc)/(2*Q); + b0 = 1 + alpha * A; + b1 = -2 * cos(wc); + b2 = 1 - alpha * A; + a0 = 1 + alpha / A; + a1 = -2 * cos(wc); + a2 = 1 - alpha / A; + b = [b0 / a0 b1 / a0 b2 / a0]; + a = [1 a1 / a0 a2 / a0]; +end + + +function [b, a] = my_bilinear(sb, sa, fs) +t = 1/fs; +[b, a] = bilinear(sb, sa, t); +end + +function sw = wmap(w, fs) +t = 1/fs; +sw = 2/t*tan(w*t/2); +end diff --git a/tune/eq/eq_fir_blob_merge.m b/tune/eq/eq_fir_blob_merge.m new file mode 100644 index 000000000000..68764532210f --- /dev/null +++ b/tune/eq/eq_fir_blob_merge.m @@ -0,0 +1,50 @@ +function bs = eq_fir_blob_merge(platform_max_channels, ... + number_of_responses_defined, assign_response, all_coefficients); + +%% Merge equalizer definition into a struct used by successive blob making +% functions. +% +% bs = eq_fir_blob_merge(platform_max_channels, number_of_responses_defined, ... +% assign_response, all_coefficients); +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +if length(assign_response) ~= platform_max_channels + error("Incorrect length in EQ assign vector!"); +end + +bs.platform_max_channels = platform_max_channels; +bs.number_of_responses_defined = number_of_responses_defined; +bs.assign_response = assign_response; +bs.all_coefficients = all_coefficients; + +end diff --git a/tune/eq/eq_fir_blob_pack.m b/tune/eq/eq_fir_blob_pack.m new file mode 100644 index 000000000000..f8e647f25a11 --- /dev/null +++ b/tune/eq/eq_fir_blob_pack.m @@ -0,0 +1,139 @@ +function blob8 = eq_fir_blob_pack(bs, endian) + +%% Pack equalizer struct to bytes +% +% blob8 = eq_fir_blob_pack(bs, endian) +% bs - blob struct +% endian - optional, use 'little' or 'big'. Defaults to little. +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +if nargin < 2 + endian = 'little'; +end + +%% Endiannes of blob +switch lower(endian) + case 'little' + sh16 = [0 -8]; + sh32 = [0 -8 -16 -24]; + case 'big' + sh16 = [-8 0]; + sh32 = [-24 -16 -8 0]; + otherwise + error('Unknown endiannes'); +end + +%% Channels count must be even +if mod(bs.platform_max_channels, 2) > 0 + error("Channels # must be even"); +end + +%% Channels cound and assign vector length must be the same +if bs.platform_max_channels ~= length( bs.assign_response) + bs + error("Channels # and response assign length must match"); +end + +%% Coefficients vector length must be multiple of 4 +len = length(bs.all_coefficients); +len_no_header = len - 2 * bs.number_of_responses_defined; +if mod(len_no_header, 4) > 0 + bs + error("Coefficient data vector length must be multiple of 4"); +end + +%% Pack as 16 bits +nh16 = 4+bs.platform_max_channels; +h16 = zeros(1, nh16, 'int16'); +h16(3) = bs.platform_max_channels; +h16(4) = bs.number_of_responses_defined; +for i=1:bs.platform_max_channels + h16(4+i) = bs.assign_response(i); +end + +%% Merge header and coefficients, make even number of int16 to make it +% multiple of int32 +nc16 = length(bs.all_coefficients); +nb16 = ceil((nh16+nc16)/2)*2; +blob16 = zeros(1,nb16, 'int16'); +blob16(1:nh16) = h16; +blob16(nh16+1:nh16+nc16) = int16(bs.all_coefficients); + +%% Print as 16 bit hex +nl = ceil(nb16/16); +for i = 1:nl + m = min(16, nb16-(i-1)*16); + for j = 1:m + k = (i-1)*16 + j; + v = int32(blob16(k)); + if v < 0 + v = 65536+v; + end + fprintf(1, "%04x ", v); + end + fprintf(1, "\n"); +end +fprintf(1, "\n"); + + +%% Pack as 8 bits +nb8 = length(blob16)*2; +blob8 = zeros(1, nb8, 'uint8'); +j = 1; +for i = 1:length(blob16) + blob8(j:j+1) = w16b(blob16(i), sh16); + j = j+2; +end + +%% Add size into first four bytes +blob8(1:4) = w32b(nb8, sh32); + +%% Done +fprintf('Blob size is %d bytes.\n', nb8); + +end + + +function bytes = w16b(word, sh) +bytes = uint8(zeros(1,2)); +bytes(1) = bitand(bitshift(word, sh(1)), 255); +bytes(2) = bitand(bitshift(word, sh(2)), 255); +end + +function bytes = w32b(word, sh) +bytes = uint8(zeros(1,4)); +bytes(1) = bitand(bitshift(word, sh(1)), 255); +bytes(2) = bitand(bitshift(word, sh(2)), 255); +bytes(3) = bitand(bitshift(word, sh(3)), 255); +bytes(4) = bitand(bitshift(word, sh(4)), 255); +end diff --git a/tune/eq/eq_fir_blob_quant.m b/tune/eq/eq_fir_blob_quant.m new file mode 100644 index 000000000000..f3c53fcd948d --- /dev/null +++ b/tune/eq/eq_fir_blob_quant.m @@ -0,0 +1,89 @@ +function fbr = eq_fir_blob_quant(b, bits) + +%% Quantize FIR coefficients and return vector with length, +% out shift, and coefficients to be used in the setup blob. +% +% fbr = eq_fir_blob_resp(b, bits) +% b - FIR coefficients +% bits - optional number of bits, defaults to 16 +% +% fbr - vector with length, in shift, out shift, and quantized coefficients +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +if nargin < 2 + bits = 16; +end + +[bq, shift] = eq_fir_quantize(b, bits); + +nb = length(bq); +mod4 = mod(nb, 4); +if mod4 > 0 + pad = zeros(1,4-mod4); + bqp = [bq pad]; + nnew = length(bqp); + fprintf(1,'Note: Filter length was %d, padded length into %d,\n', nb, nnew); +else + nnew = nb; + bqp = bq; +end + +fbr = [nnew shift bqp]; + +end + +function [bq, shift] = eq_fir_quantize(b, bits) + +% [bq, shift] = eq_fir_quantize(b, bits) +% +% Inputs +% b - FIR coefficients +% bits - number bits for 2s complement coefficient +% +% Outputs +% bq - quantized coefficients +% shift - shift right parameter to apply after FIR computation to +% compensate for coefficients scaling +% + +scale = 2^(bits-1); + +%% Output shift for coefficients +m = max(abs(b)); +shift = -ceil(log(m+1/scale)/log(2)); +bsr = b*2^shift; + +%% Quantize to Q1.bits-1 format, e.g. Q1.15 for 16 bits +bq = eq_coef_quant(bsr, bits, bits-1); + +end diff --git a/tune/eq/eq_iir_blob_merge.m b/tune/eq/eq_iir_blob_merge.m new file mode 100644 index 000000000000..c05fe67c40b1 --- /dev/null +++ b/tune/eq/eq_iir_blob_merge.m @@ -0,0 +1,52 @@ +function bs = eq_iir_blob_merge(platform_max_channels, ... + number_of_responses_defined, ... + assign_response, ... + all_coefficients); + +%% Merge equalizer definition into a struct used by successive blob making +% functions. +% +% bs = eq_iir_blob_merge(platform_max_channels, number_of_responses_defined, ... +% assign_response, all_coefficients); +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +if length(assign_response) ~= platform_max_channels + error("Assign response does not match channels count!"); +end + +bs.platform_max_channels = platform_max_channels; +bs.number_of_responses_defined = number_of_responses_defined; +bs.assign_response = assign_response; +bs.all_coefficients = all_coefficients; + +end diff --git a/tune/eq/eq_iir_blob_pack.m b/tune/eq/eq_iir_blob_pack.m new file mode 100644 index 000000000000..8a55f38cbceb --- /dev/null +++ b/tune/eq/eq_iir_blob_pack.m @@ -0,0 +1,84 @@ +function blob8 = eq_iir_blob_pack(bs, endian) + +%% Pack equalizer struct to bytes +% +% blob8 = eq_iir_blob_pack(bs, endian) +% bs - blob struct +% endian - optional, use 'little' or 'big'. Defaults to little. +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +if nargin < 2 + endian = 'little'; +end + +%% Shift values for little/big endian +switch lower(endian) + case 'little' + sh = [0 -8 -16 -24]; + case 'big' + sh = [-24 -16 -8 0]; + otherwise + error('Unknown endiannes'); +end + +%% Pack as 8 bits, header +nbytes_head = (3+bs.platform_max_channels)*4; +nbytes_coef = length(bs.all_coefficients)*4; +nbytes = nbytes_head + nbytes_coef; +blob8 = uint8(zeros(1,nbytes)); + +j = 1; +blob8(j:j+3) = w2b(nbytes, sh); j=j+4; +blob8(j:j+3) = w2b(bs.platform_max_channels, sh); j=j+4; +blob8(j:j+3) = w2b(bs.number_of_responses_defined, sh); j=j+4; + +for i=1:bs.platform_max_channels + blob8(j:j+3) = w2b(bs.assign_response(i), sh); j=j+4; +end + +%% Pack coefficients +for i=1:length(bs.all_coefficients) + blob8(j:j+3) = w2b(bs.all_coefficients(i), sh); j=j+4; +end +fprintf('Blob size is %d bytes.\n', nbytes); + + +end + +function bytes = w2b(word, sh) +bytes = uint8(zeros(1,4)); +bytes(1) = bitand(bitshift(word, sh(1)), 255); +bytes(2) = bitand(bitshift(word, sh(2)), 255); +bytes(3) = bitand(bitshift(word, sh(3)), 255); +bytes(4) = bitand(bitshift(word, sh(4)), 255); +end diff --git a/tune/eq/eq_iir_blob_quant.m b/tune/eq/eq_iir_blob_quant.m new file mode 100644 index 000000000000..30ba48007a25 --- /dev/null +++ b/tune/eq/eq_iir_blob_quant.m @@ -0,0 +1,115 @@ +function iir_resp = eq_iir_blob_quant(eq_b, eq_a) + +%% Convert IIR coefficients to 2nd order sections and quantize +% +% iir_resp = eq_iir_blob_quant(b, a, bits) +% +% b - numerator coefficients +% a - denominator coefficients +% bits - number of bits to quantize +% +% iir_resp - vector to setup an IIR equalizer with number of sections, shifts, +% and quantized coefficients +% + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Settings +bits_iir = 32; % Q2.30 +qf_iir = 30; +bits_gain = 16; % Q2.14 +qf_gain = 14; +scale_max = -3; % dB, scale biquad L-inf norm +plot_pz = 0; +plot_fr = 0; + +%% Convert IIR to 2nd order sections +[sos, gain] = tf2sos(eq_b , eq_a); +sz = size(sos); +nbr_sections = sz(1); +n_section_header = 2; +n_section = 7; +iir_resp = int32(zeros(1,n_section_header+nbr_sections*n_section)); +iir_resp(1) = nbr_sections; +iir_resp(2) = nbr_sections; % Note: All sections in series + +for n=1:nbr_sections + b = sos(n,1:3); + a = sos(n,4:6); + + if plot_pz + figure + zplane(b,a); + tstr = sprintf('SOS %d poles and zeros', n); + title(tstr); + end + + np = 1024; + [h, w] = freqz(b, a, np); + hm = max(abs(h)); + scale = 10^(scale_max/20)/hm; + gain_remain = 1/scale; + gain = gain*gain_remain; + b = b * scale; + + ma = max(abs(a)); + mb = max(abs(b)); + + if plot_fr + figure + [h, w] = freqz(b, a, np); + plot(w, 20*log10(abs(h))); grid on; + xlabel('Frequency (w)'); + ylabel('Magnitude (dB)'); + tstr = sprintf('SOS %d frequency response', n); + title(tstr); + end + + %% Apply remaining gain at last section output + if n == nbr_sections + section_shift = -fix(log(gain)/log(2)); + section_gain= gain/2^(-section_shift); + else + section_shift = 0; + section_gain = 1; + end + + %% Note: Invert sign of a! + %% Note: a(1) is omitted, it's always 1 + m = n_section_header+(n-1)*n_section+1; + iir_resp(m:m+1) = eq_coef_quant(-a(3:-1:2), bits_iir, qf_iir); + iir_resp(m+2:m+4) = eq_coef_quant( b(3:-1:1), bits_iir, qf_iir); + iir_resp(m+5) = section_shift; + iir_resp(m+6) = eq_coef_quant( section_gain, bits_gain, qf_gain); + +end + +end diff --git a/tune/eq/eq_norm.m b/tune/eq/eq_norm.m new file mode 100644 index 000000000000..ddb4b333b98f --- /dev/null +++ b/tune/eq/eq_norm.m @@ -0,0 +1,114 @@ +function eq = eq_norm(eq) + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Normalize loudness of EQ by computing weighted average of linear +% response. Find scale need to make the average one. +w_lin = level_norm_fweight(eq.f); +m_lin_fir = 10.^(eq.fir_eq_db/20); +m_lin_iir = 10.^(eq.iir_eq_db/20); +i1k = find(eq.f > 1e3, 1, 'first') - 1; +m_max_fir = max(eq.fir_eq_db); +m_max_iir = max(eq.iir_eq_db); +sens_fir = sum(m_lin_fir.*w_lin)/sum(w_lin); +sens_iir = sum(m_lin_fir.*w_lin)/sum(w_lin); +g_offs = 10^(eq.norm_offs_db/20); + +%% Determine scaling gain +switch lower(eq.norm_type) + case 'loudness' + g_fir = 1/sens_fir; + g_iir = 1/sens_iir; + case '1k' + g_fir = 1/m_lin_fir(i1k); + g_iir = 1/m_lin_iir(i1k); + + case 'peak' + g_fir = 10^(-m_max_fir/20); + g_iir = 10^(-m_max_iir/20); + otherwise + error('Requested normalization is not supported'); +end + +%% Adjust FIR and IIR gains if enabled +if eq.enable_fir && eq.enable_iir + eq.b_fir = eq.b_fir * g_fir * g_offs; + eq.b_p = eq.b_p * g_iir * g_offs; +end +if eq.enable_fir && eq.enable_iir == 0 + eq.b_fir = eq.b_fir * g_fir * g_offs; +end +if eq.enable_fir == 0 && eq.enable_iir + eq.b_p = eq.b_p * g_iir * g_offs; +end + +%% Re-compute response after adjusting gain +eq = eq_compute_tot_response(eq); + +end + +function m_lin = level_norm_fweight(f) + +%% w_lin = level_norm_fweight(f) +% +% Provides frequency weight that is useful in normalization of +% loudness of effect like equalizers. The weight consists of pink noise +% like spectral shape that attenuates higher frequencies 3 dB per +% octave. The low frequencies are shaped by 2nd order high-pass +% response at 20 Hz and higher frequencies by 3rd order low-pass at 20 +% kHz. +% +% Note: This weight may have similarity with a standard defined test signal +% characteristic for evaluating music player output levels but this is not +% an implementation of it. This weight may help in avoiding a designed EQ to +% exceed safe playback levels in othervise compliant device. +% +% Input f - frequencies vector in Hz +% +% Output w_lin - weight curve, aligned to peak of 1.0 in the requested f +% + +[z_hp, p_hp] = butter(2, 22.4,'high','s'); +[z_lp, p_lp] = butter(3, 22.4e3,'s'); +z_bp = conv(z_hp, z_lp); +p_bp = conv(p_hp, p_lp); +h = freqs(z_bp, p_bp, f); +m0 = 20*log10(abs(h)); +noct = log(max(f)/min(f))/log(2); +att = 3*noct; +nf = length(f); +w = zeros(1,nf); +w = w - linspace(0,att,nf); +m = m0 + w; +m = m-max(m); +m_lin = 10.^(m/20); + +end diff --git a/tune/eq/eq_plot.m b/tune/eq/eq_plot.m new file mode 100644 index 000000000000..6231eab21eb5 --- /dev/null +++ b/tune/eq/eq_plot.m @@ -0,0 +1,172 @@ +function eq_plot(eq, fn) + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Raw measured response +if length(eq.raw_m_db) > 2 + % Raw without EQ + fh=figure(fn); fn = fn+1; + f1 = min(eq.raw_f); + f2 = max(eq.raw_f); + i1 = find(eq.f > f1, 1, 'first') - 1; + i2 = find(eq.f > f2, 1, 'first') - 1; + idx = i1:i2; + semilogx(eq.f(idx), eq.m_db(idx), eq.f(idx), eq.m_db_s(idx)); + grid on; + ax=axis; axis([eq.p_fmin eq.p_fmax min(max(ax(3:4), -40), 20)]); + legend('Raw','Smoothed'); + xlabel('Frequency (Hz)'); + ylabel('Magnitude (dB)'); + tstr = sprintf('Imported frequency response: %s', eq.name); + title(tstr); + + % Simulated with EQ + fh=figure(fn); fn = fn+1; + semilogx(eq.f(idx), eq.m_eqd(idx), eq.f(idx), eq.m_eqd_s(idx)); + grid on; + ax=axis; axis([eq.p_fmin eq.p_fmax min(max(ax(3:4), -40), 20)]); + legend('Raw','Smoothed'); + xlabel('Frequency (Hz)'); + ylabel('Magnitude (dB)'); + tstr = sprintf('Simulated frequency response: %s', eq.name); + title(tstr); +end + +%% Filter responses +fh=figure(fn); fn = fn+1; +i1k = find(eq.f > 1e3, 1, 'first') - 1; +offs_tot = -eq.tot_eq_db(i1k); +offs_fir = -eq.fir_eq_db(i1k); +offs_iir = -eq.iir_eq_db(i1k); +if eq.enable_fir && eq.enable_iir + semilogx(eq.f, eq.err_db_s, eq.f, eq.tot_eq_db + offs_tot, ... + eq.f, eq.iir_eq_db + offs_iir, '--',... + eq.f, eq.fir_eq_db + offs_fir, '--'); + legend('Target', 'Combined', 'IIR', 'FIR', 'Location', 'NorthWest'); +end +if eq.enable_fir && eq.enable_iir == 0 + semilogx(eq.f, eq.err_db_s, eq.f, eq.fir_eq_db + offs_fir); + legend('Target', 'FIR', 'Location', 'NorthWest'); +end +if eq.enable_fir == 0 && eq.enable_iir + semilogx(eq.f, eq.err_db_s, eq.f, eq.iir_eq_db + offs_iir); + legend('Target', 'IIR', 'Location', 'NorthWest'); +end +grid on; +ax=axis; axis([eq.p_fmin eq.p_fmax min(max(ax(3:4), -40), 40)]); +xlabel('Frequency (Hz)'); +ylabel('Magnitude (dB)'); +tstr = sprintf('Filter target vs. achieved response: %s', eq.name); +title(tstr); + +%% FIR filter +if length(eq.b_fir) > 1 + % Response + fh=figure(fn); fn = fn+1; + semilogx(eq.f, eq.fir_eq_db); + grid on; + xlabel('Frequency (Hz)'); + ylabel('Magnitude (dB)'); + ax = axis; axis([eq.p_fmin eq.p_fmax max(ax(3:4), -40)]); + tstr = sprintf('FIR filter normalized response: %s', eq.name); + title(tstr); + + % Impulse response / coefficients + fh=figure(fn); fn = fn+1; + stem(eq.b_fir); + grid on; + xlabel('Coefficient #'); + ylabel('Coefficient value'); + tstr = sprintf('FIR filter impulse response: %s', eq.name); + title(tstr); + +end + +%% IIR filter +if length(eq.b_p) > 1 + % Response + fh=figure(fn); fn = fn+1; + semilogx(eq.f, eq.iir_eq_db); + grid on; + xlabel('Frequency (Hz)'); + ylabel('Magnitude (dB)'); + ax = axis; axis([eq.p_fmin eq.p_fmax max(ax(3:4), -40)]); + tstr = sprintf('IIR filter normalized response: %s', eq.name); + title(tstr); + + % Polar + fh=figure(fn); fn = fn+1; + zplane(eq.b_p, eq.a_p); + grid on; + tstr = sprintf('IIR zeros and poles: %s', eq.name); + title(tstr); + + % Impulse + ti = 50e-3; + x = zeros(1, ti * round(eq.fs)); + x(1) = 1; + y = filter(eq.b_p, eq.a_p, x); + fh=figure(fn); fn = fn+1; + t = (0:(length(x)-1)) / eq.fs; + plot(t, y); + grid on; + xlabel('Time (s)'); + ylabel('Sample value'); + tstr = sprintf('IIR filter impulse response: %s', eq.name); + title(tstr); +end + +%% Group delay +fh=figure(fn); fn = fn+1; +if eq.enable_fir && eq.enable_iir + semilogx(eq.f, eq.tot_eq_gd * 1e3, ... + eq.f, eq.fir_eq_gd * 1e3, '--', ... + eq.f, eq.iir_eq_gd * 1e3, '--'); + legend('Combined','FIR','IIR'); +end +if eq.enable_fir && eq.enable_iir == 0 + semilogx(eq.f, eq.fir_eq_gd * 1e3); + legend('FIR'); +end +if eq.enable_fir == 0 && eq.enable_iir + semilogx(eq.f, eq.iir_eq_gd * 1e3); + legend('IIR'); +end +grid on; +xlabel('Frequency (Hz)'); +ylabel('Group delay (ms)'); +ax = axis; axis([eq.p_fmin eq.p_fmax ax(3:4)]); +tstr = sprintf('Filter group delay: %s', eq.name); +title(tstr); + + + +end diff --git a/tune/eq/example_fir_eq.m b/tune/eq/example_fir_eq.m new file mode 100644 index 000000000000..c7f3fa31e98d --- /dev/null +++ b/tune/eq/example_fir_eq.m @@ -0,0 +1,119 @@ +%% Design demo EQs and bundle them to parameter block + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +function example_fir_eq() + +ascii_blob_fn = 'example_fir_eq.txt'; +binary_blob_fn = 'example_fir_eq.blob'; +endian = 'little'; +fs = 48e3; +bits = 16; + +%% Design FIR loudness equalizer +eq_loud = loudness_fir_eq(fs, 1); + +%% Define a passthru EQ with one tap +b_pass = 1; + +%% Quantize filter coefficients for both equalizers +bq_pass = eq_fir_blob_quant(b_pass, bits); +bq_loud = eq_fir_blob_quant(eq_loud.b_fir, bits); + +%% Build blob +platform_max_channels = 4; % Setup max 4 channels EQ +assign_response = [1 1 1 1]; % Switch to response #1 +num_responses = 2; % Two responses pass, loud +bm = eq_fir_blob_merge(platform_max_channels, ... + num_responses, ... + assign_response, ... + [ bq_pass bq_loud ]); + +%% Pack and write file +bp = eq_fir_blob_pack(bm, endian); +eq_alsactl_write(ascii_blob_fn, bp); +eq_blob_write(binary_blob_fn, bp); + +end + +function eq = loudness_fir_eq(fs, fn) + +if nargin < 2 + fn = 1; +end +if nargin < 1 + fs = 48e3; +end + +%% Derived from Fletcher-Munson curves for 80 and 60 phon +f = [ 20,21,22,24,25,27,28,30,32,34,36,38,40,43,45,48,51,54,57,60,64, ... + 68,72,76,81,85,90,96,102,108,114,121,128,136,144,153,162,171, ... + 182,192,204,216,229,243,257,273,289,306,324,344,364,386,409, ... + 434,460,487,516,547,580,614,651,690,731,775,821,870,922,977, ... + 1036,1098,1163,1233,1307,1385,1467,1555,1648,1747,1851,1962, ... + 2079,2203,2335,2474,2622,2779,2945,3121,3308,3505,3715,3937, ... + 4172,4421,4686,4966,5263,5577,5910,6264,6638,7035,7455,7901, ... + 8373,8873,9404,9966,10561,11193,11861,12570,13322,14118,14962, ... + 15856,16803,17808,18872,20000]; + +m = [ 0.00,-0.13,-0.27,-0.39,-0.52,-0.64,-0.77,-0.89,-1.02,-1.16, ... + -1.31,-1.46,-1.61,-1.76,-1.91,-2.07,-2.24,-2.43,-2.64,-2.85, ... + -3.04,-3.21,-3.35,-3.48,-3.62,-3.78,-3.96,-4.16,-4.35,-4.54, ... + -4.72,-4.90,-5.08,-5.26,-5.45,-5.64,-5.83,-6.02,-6.19,-6.37, ... + -6.57,-6.77,-6.98,-7.19,-7.40,-7.58,-7.76,-7.92,-8.08,-8.25, ... + -8.43,-8.60,-8.76,-8.92,-9.08,-9.23,-9.38,-9.54,-9.69,-9.84, ... + -9.97,-10.09,-10.18,-10.26,-10.33,-10.38,-10.43,-10.48,-10.54, ... + -10.61,-10.70,-10.78,-10.85,-10.91,-10.95,-10.98,-11.02, ... + -11.05,-11.07,-11.10,-11.11,-11.11,-11.10,-11.10,-11.11, ... + -11.14,-11.17,-11.20,-11.21,-11.22,-11.21,-11.20,-11.20, ... + -11.21,-11.21,-11.20,-11.17,-11.11,-11.02,-10.91,-10.78, ... + -10.63,-10.46,-10.25,-10.00,-9.72,-9.39,-9.02,-8.62,-8.19, ... + -7.73,-7.25,-6.75,-6.25,-5.75,-5.28,-4.87,-4.54,-4.33,-4.30]; + +%% Design EQ +eq = eq_defaults(); +eq.fs = fs; +eq.target_f = f; % Set EQ frequency response target: frequency vector +eq.target_m_db = m; % Set EQ frequency response target: magnitude +eq.fir_beta = 3.5; % Use with care, low value can corrupt +eq.fir_length = 107; % Gives just < 255 bytes +eq.fir_autoband = 0; % Select manually frequency limits +eq.fmin_fir = 100; % Equalization starts from 100 Hz +eq.fmax_fir = 20e3; % Equalization ends at 20 kHz +eq.fir_minph = 1; % If no linear phase required, check result carefully if 1 +eq.norm_type = 'loudness'; % Can be loudness/peak/1k to select normalize criteria +eq.norm_offs_db = 0; % E.g. -1 would leave 1 dB headroom if used with peak +eq = eq_compute(eq); + +%% Plot +eq_plot(eq, fn); + +end diff --git a/tune/eq/example_iir_eq.m b/tune/eq/example_iir_eq.m new file mode 100644 index 000000000000..4e36ac997b35 --- /dev/null +++ b/tune/eq/example_iir_eq.m @@ -0,0 +1,136 @@ +%% Design effect EQs and bundle them to parameter block + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +function example_iir_eq() + +blob_fn = 'example_iir_eq.blob'; +alsa_fn = 'example_iir_eq.txt'; +endian = 'little'; +fs = 48e3; + +%% Design IIR loudness equalizer +eq_loud = loudness_iir_eq(fs, 2); + +%% Define a passthru IIR EQ equalizer +b_pass = [1 0 0]; +a_pass = [1 0 0]; + +%% Quantize and pack filter coefficients plus shifts etc. +bq_pass = eq_iir_blob_quant(b_pass, a_pass); +bq_loud = eq_iir_blob_quant(eq_loud.b_p, eq_loud.a_p); + +%% Build blob +platform_max_channels = 4; % Setup max 4 channels EQ +assign_response = [1 1 1 1]; % Switch to response #1 +num_responses = 2; % Two responses: pass, loud +bm = eq_iir_blob_merge(platform_max_channels, ... + num_responses, ... + assign_response, ... + [bq_pass bq_loud]); + +%% Pack and write file +bp = eq_iir_blob_pack(bm); +eq_blob_write(blob_fn, bp); +eq_alsactl_write(alsa_fn, bp); + +end + +%% + +function eq = loudness_iir_eq(fs, fn) + +if nargin < 2 + fn = 1; +end +if nargin < 1 + fs = 48e3; +end + +%% Derived from Fletcher-Munson curves for 80 and 60 phon +f = [ 20,21,22,24,25,27,28,30,32,34,36,38,40,43,45,48,51,54,57,60,64, ... + 68,72,76,81,85,90,96,102,108,114,121,128,136,144,153,162,171, ... + 182,192,204,216,229,243,257,273,289,306,324,344,364,386,409, ... + 434,460,487,516,547,580,614,651,690,731,775,821,870,922,977, ... + 1036,1098,1163,1233,1307,1385,1467,1555,1648,1747,1851,1962, ... + 2079,2203,2335,2474,2622,2779,2945,3121,3308,3505,3715,3937, ... + 4172,4421,4686,4966,5263,5577,5910,6264,6638,7035,7455,7901, ... + 8373,8873,9404,9966,10561,11193,11861,12570,13322,14118,14962, ... + 15856,16803,17808,18872,20000]; + +m = [ 0.00,-0.13,-0.27,-0.39,-0.52,-0.64,-0.77,-0.89,-1.02,-1.16, ... + -1.31,-1.46,-1.61,-1.76,-1.91,-2.07,-2.24,-2.43,-2.64,-2.85, ... + -3.04,-3.21,-3.35,-3.48,-3.62,-3.78,-3.96,-4.16,-4.35,-4.54, ... + -4.72,-4.90,-5.08,-5.26,-5.45,-5.64,-5.83,-6.02,-6.19,-6.37, ... + -6.57,-6.77,-6.98,-7.19,-7.40,-7.58,-7.76,-7.92,-8.08,-8.25, ... + -8.43,-8.60,-8.76,-8.92,-9.08,-9.23,-9.38,-9.54,-9.69,-9.84, ... + -9.97,-10.09,-10.18,-10.26,-10.33,-10.38,-10.43,-10.48,-10.54, ... + -10.61,-10.70,-10.78,-10.85,-10.91,-10.95,-10.98,-11.02, ... + -11.05,-11.07,-11.10,-11.11,-11.11,-11.10,-11.10,-11.11, ... + -11.14,-11.17,-11.20,-11.21,-11.22,-11.21,-11.20,-11.20, ... + -11.21,-11.21,-11.20,-11.17,-11.11,-11.02,-10.91,-10.78, ... + -10.63,-10.46,-10.25,-10.00,-9.72,-9.39,-9.02,-8.62,-8.19, ... + -7.73,-7.25,-6.75,-6.25,-5.75,-5.28,-4.87,-4.54,-4.33,-4.30]; + +%% Get defaults for equalizer design +eq = eq_defaults(); +eq.fs = fs; +eq.target_f = f; +eq.target_m_db = m; +eq.enable_fir = 0; +eq.enable_iir = 1; +eq.norm_type = 'loudness'; +eq.norm_offs_db = 0; + + +%% Manually setup low-shelf and high shelf parametric equalizers +% +% Parametric EQs are PEQ_HP1, PEQ_HP2, PEQ_LP1, PEQ_LP2, PEQ_LS1, +% PEQ_LS2, PEQ_HS1, PEQ_HS2 = 8, PEQ_PN2, PEQ_LP4, and PEQ_HP4. +% +% Parametric EQs take as second argument the cutoff frequency in Hz +% and as second argument a dB value (or NaN when not applicable) . The +% Third argument is a Q-value (or NaN when not applicable). +eq.peq = [ ... + eq.PEQ_LS1 40 +2 NaN ; ... + eq.PEQ_LS1 80 +3 NaN ; ... + eq.PEQ_LS1 200 +3 NaN ; ... + eq.PEQ_LS1 400 +3 NaN ; ... + eq.PEQ_HS2 13000 +7 NaN ; ... + ]; + +%% Design EQ +eq = eq_compute(eq); + +%% Plot +eq_plot(eq, fn); + +end diff --git a/tune/eq/example_spk_eq.m b/tune/eq/example_spk_eq.m new file mode 100644 index 000000000000..be633064a182 --- /dev/null +++ b/tune/eq/example_spk_eq.m @@ -0,0 +1,145 @@ +%% Design an example speaker equalizer with the provided sample data +% This equalizer by default uses a FIR and IIR components those should be +% both in the speaker pipeline. +% +% Note that IIR should be first since the included band-pass response provides +% signal headroom. + +%% +% Copyright (c) 2016, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Get defaults for equalizer design +eq = eq_defaults(); + +%% Settings for this EQ +eq.fs = 48e3; % Default sample rate in SOF +eq.enable_fir = 1; % Try enabling and disabling FIR part +eq.enable_iir = 1; % Try enabling and disabling IIR part +eq.norm_type = 'loudness'; % Preserve loudness approximately +eq.norm_offs_db = 0; % Can be used to control gain +eq.p_fmin = 100; % With this data start plots from 100 Hz +eq.p_fmax = 20e3; % and end to 20 kHz. + +%% Get acousticial frequency response measurement data. This is +% a quite typical response for a miniature speaker. Alternatively +% the response could be read from spreadsheet column format that is +% commonly supported by audio measurement equipment. Then extract +% the frequency and magnitude columns. E.g. +% +% data = xlsread('spkr.xlsx', 1, 'A5:B78'); +% eq.raw_f = data(:,1); +% eq.raw_m_db = data(:,2); + +eq.raw_f = [ ... + 298.533, 316.232, 334.971, 354.813, 375.838, 398.106, ... + 421.699, 446.685, 473.153, 501.186, 530.887, 562.342, ... + 595.663, 630.958, 668.345, 707.946, 749.895, 794.329, ... + 841.397, 891.252, 944.062, 1000, 1059.26, 1122.02, ... + 1188.5, 1258.93, 1333.52, 1412.54, 1496.24, 1584.9, ... + 1678.81, 1778.28, 1883.65, 1995.27, 2113.49, 2238.72, ... + 2371.38, 2511.89, 2660.73, 2818.39, 2985.39, 3162.28, ... + 3349.66, 3548.14, 3758.38, 3981.08, 4216.97, 4466.84, ... + 4731.52, 5011.88, 5308.85, 5623.42, 5956.63, 6309.58, ... + 6683.45, 7079.47, 7498.95, 7943.3, 8413.97, 8912.52, ... + 9440.62, 10000, 10592.6, 11220.2, 11885, 12589.3, ... + 13335.2, 14125.4, 14962.4, 15849, 16788.1, 17782.8, ... + 18836.5, 19952.7 ... +]; + +eq.raw_m_db = [ ... + 58.1704, 60.074, 60.4541, 61.3079, 62.8198, 64.3749, ... + 65.1556, 66.512, 67.5916, 68.6344, 69.9276, 70.7658, ... + 71.1125, 72.0627, 73.5348, 75.4887, 77.3088, 79.1541, ... + 80.9627, 82.0607, 81.943, 81.2228, 81.9497, 83.1848, ... + 84.3375, 85.4993, 86.4642, 87.1179, 87.4424, 87.53, ... + 85.7425, 85.0095, 82.9405, 82.9242, 82.7327, 83.6423, ... + 83.2839, 82.4201, 84.1403, 84.6485, 83.9274, 83.3366, ... + 83.3005, 84.2598, 85.1544, 86.015, 86.6519, 87.2118, ... + 87.5498, 88.1742, 88.5215, 88.3801, 89.8762, 91.4418, ... + 93.1845, 94.3355, 95.0918, 95.0258, 94.0337, 91.1068, ... + 88.7303, 87.4853, 86.2916, 83.037, 79.8056, 78.2022, ... + 76.0341, 74.5674, 69.2288, 56.1308, 68.697, 69.687, ... + 68.0005, 64.698 ... +]; + +%% With parametric IIR EQ try to place peaking EQ at +% resonant frequencies 1.4 kHz and 7.5 kHz. The gain +% and Q values were experimented manually. Additionally +% The lowest and highest frequeciens below and above speaker +% capability are attenuated with high-pass and low-pass +% filtering. +if eq.enable_iir; + eq.peq = [ ... + eq.PEQ_HP2 100 NaN NaN; ... + eq.PEQ_PN2 1480 -6 2.0; ... + eq.PEQ_PN2 7600 -12 1.3; ... + eq.PEQ_LP2 14500 NaN NaN; ... + ]; +end + +%% With FIR EQ try to flatten frequency response within +% 1 - 13 kHz frequency band. +if eq.enable_fir + eq.fir_minph = 1; + eq.fir_beta = 4; + eq.fir_length = 63; + eq.fir_autoband = 0; + eq.fmin_fir = 1000; + eq.fmax_fir = 13e3; +end + +%% Design EQ +eq = eq_compute(eq); + +%% Plot +eq_plot(eq, 1); + +%% Export FIR part +platform_max_channels = 2; % Identical two speakers +assign_response = [0 0]; % Switch to response #0 +num_responses = 1; % Single response +bq_fir = eq_fir_blob_quant(eq.b_fir); +bm_fir = eq_fir_blob_merge(platform_max_channels, ... + num_responses, ... + assign_response, ... + [ bq_fir ]); +bp_fir = eq_fir_blob_pack(bm_fir); +eq_alsactl_write('example_spk_eq_fir.txt', bp_fir); +eq_blob_write('example_spk_eq_fir.blob', bp_fir); + +%% Export IIR part +bq_iir = eq_iir_blob_quant(eq.b_p, eq.a_p); +bm_iir = eq_iir_blob_merge(platform_max_channels, ... + num_responses, ... + assign_response, ... + [ bq_iir ]); +bp_iir = eq_iir_blob_pack(bm_iir); +eq_alsactl_write('example_spk_eq_iir.txt', bp_iir); +eq_blob_write('example_spk_eq_iir.blob', bp_iir); From ef307ba6844d81928d5d3918dc2f3f416cc1bbbf Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 7 Aug 2018 20:02:46 -0500 Subject: [PATCH 230/324] kmod_scripts: filter out DMA trace overflow The occurrence of DMA trace overflows has become so bad I need to filter out these error messages to test module load/unload. Sad but what can I say. Signed-off-by: Pierre-Louis Bossart --- kmod_scripts/sof_bootone.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kmod_scripts/sof_bootone.sh b/kmod_scripts/sof_bootone.sh index 6bc5f27b161a..0b533a6490c7 100755 --- a/kmod_scripts/sof_bootone.sh +++ b/kmod_scripts/sof_bootone.sh @@ -8,7 +8,7 @@ sleep 1 unset FW_BOOT unset ERROR FW_BOOT=$(dmesg | grep sof-audio | grep "boot complete") -ERROR=$(dmesg | grep sof-audio | grep "error") +ERROR=$(dmesg | grep sof-audio | grep -v "DSP trace buffer overflow" | grep "error") if [ ! -z "$ERROR" ] || [ -z "$FW_BOOT" ] then From ea08faf5b0f3173a413206b9f9a9b8c6c28739b5 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 7 Aug 2018 20:21:07 -0500 Subject: [PATCH 231/324] kmod_scripts: look for timeout errors and stop loops Timeout errors happen randomly but need to be checked. This helps check issues reported at https://github.com/thesofproject/sof/issues/209 Signed-off-by: Pierre-Louis Bossart --- kmod_scripts/sof_bootloop.sh | 2 ++ kmod_scripts/sof_bootone.sh | 7 +++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kmod_scripts/sof_bootloop.sh b/kmod_scripts/sof_bootloop.sh index f1bc99bf315f..da9296dbe23d 100755 --- a/kmod_scripts/sof_bootloop.sh +++ b/kmod_scripts/sof_bootloop.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + MAXLOOPS=100 COUNTER=0 diff --git a/kmod_scripts/sof_bootone.sh b/kmod_scripts/sof_bootone.sh index 0b533a6490c7..92071fab7152 100755 --- a/kmod_scripts/sof_bootone.sh +++ b/kmod_scripts/sof_bootone.sh @@ -9,10 +9,13 @@ unset FW_BOOT unset ERROR FW_BOOT=$(dmesg | grep sof-audio | grep "boot complete") ERROR=$(dmesg | grep sof-audio | grep -v "DSP trace buffer overflow" | grep "error") +TIMEOUT=$(dmesg | grep sof-audio | grep "ipc timed out") -if [ ! -z "$ERROR" ] || [ -z "$FW_BOOT" ] +if [ ! -z "$ERROR" ] || [ -z "$FW_BOOT" ] || [ ! -z "$TIMEOUT" ] then - echo "boot failed" + dmesg > boot_fail.log + echo "boot failed, see boot_fail.log for details" + exit 1 else echo "boot success" fi From 046e763974fe1914e2574af3a5bf1efff318d30e Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 9 Aug 2018 17:03:44 +0800 Subject: [PATCH 232/324] ci: travis: enable travis ci for SOFT Signed-off-by: Pan Xiuli --- .travis.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000000..12533d10f63e --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +sudo: required + +language: c + +services: + - docker + +before_install: + - docker pull xiulipan/sof + - echo -e '#!/bin/bash \n./autogen.sh && ./configure && make' > quickbuild.sh + - chmod 755 quickbuild.sh + +script: + - docker run -it -v `pwd`:/home/sof/work/sof.git --user `id -u` xiulipan/sof ./quickbuild.sh From 684737cf5dfa45ce6935743a0eace484e9488ce3 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 9 Aug 2018 17:00:19 +0300 Subject: [PATCH 233/324] EQ: Improve Matlab compatibility of equalizer filter design plus cleanup This patch adds checks into places where Octave and Matlab handle the used functions differently. In previous version the difference in bilinear transform caused IIR designs to fail totally in Matlab. There remains an issue with IIR EQs design with Matlab. In that case a warning text is printed since the problem with tf2sos() does not happen with all designs (example_spk_eq is impacted). It will be investigated and fixed later. The problem does not happen with Octave. Equalizer defaults had accidentally by default boost of one dB compared to desired filter scaling. the offset (norm_offs_db) is now restored to 0. In parametric equalizers design renamed BW to Q for the correct purpose (peaking filter Q-value). Fixed bug in filters normalization where loudness based scaling of IIR filters was using calculated value for the FIR part. Also cleaned up lot commented out lines and simplified some functions parameters usage. Signed-off-by: Seppo Ingalsuo --- tune/eq/eq_compute.m | 5 +++++ tune/eq/eq_defaults.m | 4 ++-- tune/eq/eq_define_parametric_eq.m | 22 +++++++--------------- tune/eq/eq_iir_blob_quant.m | 11 ++++++++++- tune/eq/eq_norm.m | 2 +- tune/eq/eq_plot.m | 4 ++++ 6 files changed, 29 insertions(+), 19 deletions(-) diff --git a/tune/eq/eq_compute.m b/tune/eq/eq_compute.m index 960bd8671300..a5143b42599d 100644 --- a/tune/eq/eq_compute.m +++ b/tune/eq/eq_compute.m @@ -30,6 +30,11 @@ % Author: Seppo Ingalsuo % +%% Sanity checks +if eq.enable_iir == 0 && eq.enable_fir == 0 + fprintf('Warning: Nothing to do. Please enable FIR or IIR!\n'); +end + %% Extrapolate response to 0..fs/2, convert to logaritmic grid, and smooth % with 1/N octave filter eq = preprocess_responses(eq); diff --git a/tune/eq/eq_defaults.m b/tune/eq/eq_defaults.m index 7c00a195c9e2..cf16aea460c5 100644 --- a/tune/eq/eq_defaults.m +++ b/tune/eq/eq_defaults.m @@ -55,7 +55,7 @@ p.fir_minph = 0; % 0 = linear phase, 1 = minimum phase % Adjust fmin_fir, fmax_fir automatically for least gain loss in FIR p.fir_autoband = 1; -p.enable_fir = 1; +p.enable_fir = 0; % IIR conf p.iir_biquads_max = 6; @@ -106,6 +106,6 @@ p.p_fmax = 30e3; p.name = ''; p.norm_type = 'loudness'; % loudness/peak/1k -p.norm_offs_db = 1; +p.norm_offs_db = 0; end diff --git a/tune/eq/eq_define_parametric_eq.m b/tune/eq/eq_define_parametric_eq.m index 300103d76f5c..06136e238e8a 100644 --- a/tune/eq/eq_define_parametric_eq.m +++ b/tune/eq/eq_define_parametric_eq.m @@ -35,16 +35,13 @@ PEQ_LS1 = 5; PEQ_LS2 = 6; PEQ_HS1 = 7; PEQ_HS2 = 8; PEQ_PN2 = 9; PEQ_LP4 = 10; PEQ_HP4 = 11; -%figure(100); -%fv = logspace(log10(20),log10(20e3),500); -%hold on; sp = size(peq); b_t = 1; a_t = 1; for i=1:sp(1) type = peq(i,1); f = peq(i,2); g = peq(i,3); - bw = peq(i,4); + Q = peq(i,4); if f < fs/2 switch peq(i,1) case PEQ_HP1, [b0, a0] = butter(1, 2*f/fs, 'high'); @@ -57,20 +54,13 @@ case PEQ_LS2, [b0, a0] = low_shelf_2nd(f, g, fs); case PEQ_HS1, [b0, a0] = high_shelf_1st(f, g, fs); case PEQ_HS2, [b0, a0] = high_shelf_2nd(f, g, fs); - case PEQ_PN2, [b0, a0] = peak_2nd(f, g, bw, fs); + case PEQ_PN2, [b0, a0] = peak_2nd(f, g, Q, fs); otherwise error('Unknown parametric EQ type'); end - %h = freqz(b0, a0, fv, fs); - %semilogx(fv, 20*log10(abs(h)),'g--'); b_t=conv(b_t, b0); a_t = conv(a_t, a0); end end -%h = freqz(b_t, a_t, fv, fs); -%semilogx(fv, 20*log10(abs(h)),'b'); -%hold off; grid on; axis([20 20e3 -1 12]); -%xlabel('Frequency (Hz)'); ylabel('Magnitude (dB)'); -%print -dpng peq.png; end function [b, a] = low_shelf_1st(fhz, gdb, fs) @@ -125,10 +115,12 @@ a = [1 a1 / a0 a2 / a0]; end - function [b, a] = my_bilinear(sb, sa, fs) -t = 1/fs; -[b, a] = bilinear(sb, sa, t); +if exist('OCTAVE_VERSION', 'builtin') + [b, a] = bilinear(sb, sa, 1/fs); +else + [b, a] = bilinear(sb, sa, fs); +end end function sw = wmap(w, fs) diff --git a/tune/eq/eq_iir_blob_quant.m b/tune/eq/eq_iir_blob_quant.m index 30ba48007a25..823d256e259b 100644 --- a/tune/eq/eq_iir_blob_quant.m +++ b/tune/eq/eq_iir_blob_quant.m @@ -52,7 +52,16 @@ plot_fr = 0; %% Convert IIR to 2nd order sections -[sos, gain] = tf2sos(eq_b , eq_a); +if exist('OCTAVE_VERSION', 'builtin') + [sos, gain] = tf2sos(eq_b, eq_a); +else + % TODO: tf2sos produces in Matlab EQs with zero output due to + % very high gain variations within biquad. Need to investigate if + % this is incorrect usage and a bug here. + [sos, gain] = tf2sos(eq_b, eq_a, 'UP', Inf); + fprintf('Warning: Problems have been seen with some IIR designs.\n'); + fprintf('Warning: Please check the result.\n'); +end sz = size(sos); nbr_sections = sz(1); n_section_header = 2; diff --git a/tune/eq/eq_norm.m b/tune/eq/eq_norm.m index ddb4b333b98f..fdb1cb5281d3 100644 --- a/tune/eq/eq_norm.m +++ b/tune/eq/eq_norm.m @@ -39,7 +39,7 @@ m_max_fir = max(eq.fir_eq_db); m_max_iir = max(eq.iir_eq_db); sens_fir = sum(m_lin_fir.*w_lin)/sum(w_lin); -sens_iir = sum(m_lin_fir.*w_lin)/sum(w_lin); +sens_iir = sum(m_lin_iir.*w_lin)/sum(w_lin); g_offs = 10^(eq.norm_offs_db/20); %% Determine scaling gain diff --git a/tune/eq/eq_plot.m b/tune/eq/eq_plot.m index 6231eab21eb5..2dc5743f1285 100644 --- a/tune/eq/eq_plot.m +++ b/tune/eq/eq_plot.m @@ -30,6 +30,10 @@ function eq_plot(eq, fn) % Author: Seppo Ingalsuo % +if nargin < 2 + fn = 1; +end + %% Raw measured response if length(eq.raw_m_db) > 2 % Raw without EQ From 085b68058b32e1de3b1baba756ada6a9cbdf9cdf Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 9 Aug 2018 17:04:09 +0300 Subject: [PATCH 234/324] EQ: Improve example equalizer design scripts This patch cleans up the scripts and improves the accuracy of speaker case with more carefully set manual equalizer design parameters. Signed-off-by: Seppo Ingalsuo --- tune/eq/example_fir_eq.m | 24 +++++++------------ tune/eq/example_iir_eq.m | 15 +++--------- tune/eq/example_spk_eq.m | 51 +++++++++++++++++++++++----------------- 3 files changed, 42 insertions(+), 48 deletions(-) diff --git a/tune/eq/example_fir_eq.m b/tune/eq/example_fir_eq.m index c7f3fa31e98d..d57374dfc766 100644 --- a/tune/eq/example_fir_eq.m +++ b/tune/eq/example_fir_eq.m @@ -36,17 +36,16 @@ function example_fir_eq() binary_blob_fn = 'example_fir_eq.blob'; endian = 'little'; fs = 48e3; -bits = 16; %% Design FIR loudness equalizer -eq_loud = loudness_fir_eq(fs, 1); +eq_loud = loudness_fir_eq(fs); %% Define a passthru EQ with one tap b_pass = 1; %% Quantize filter coefficients for both equalizers -bq_pass = eq_fir_blob_quant(b_pass, bits); -bq_loud = eq_fir_blob_quant(eq_loud.b_fir, bits); +bq_pass = eq_fir_blob_quant(b_pass); +bq_loud = eq_fir_blob_quant(eq_loud.b_fir); %% Build blob platform_max_channels = 4; % Setup max 4 channels EQ @@ -64,14 +63,7 @@ function example_fir_eq() end -function eq = loudness_fir_eq(fs, fn) - -if nargin < 2 - fn = 1; -end -if nargin < 1 - fs = 48e3; -end +function eq = loudness_fir_eq(fs) %% Derived from Fletcher-Munson curves for 80 and 60 phon f = [ 20,21,22,24,25,27,28,30,32,34,36,38,40,43,45,48,51,54,57,60,64, ... @@ -103,17 +95,19 @@ function example_fir_eq() eq.fs = fs; eq.target_f = f; % Set EQ frequency response target: frequency vector eq.target_m_db = m; % Set EQ frequency response target: magnitude +eq.norm_type = 'loudness'; % Can be loudness/peak/1k to select normalize criteria +eq.norm_offs_db = 0; % E.g. -1 would leave 1 dB headroom if used with peak + +eq.enable_fir = 1; % By default both FIR and IIR disabled, enable one eq.fir_beta = 3.5; % Use with care, low value can corrupt eq.fir_length = 107; % Gives just < 255 bytes eq.fir_autoband = 0; % Select manually frequency limits eq.fmin_fir = 100; % Equalization starts from 100 Hz eq.fmax_fir = 20e3; % Equalization ends at 20 kHz eq.fir_minph = 1; % If no linear phase required, check result carefully if 1 -eq.norm_type = 'loudness'; % Can be loudness/peak/1k to select normalize criteria -eq.norm_offs_db = 0; % E.g. -1 would leave 1 dB headroom if used with peak eq = eq_compute(eq); %% Plot -eq_plot(eq, fn); +eq_plot(eq); end diff --git a/tune/eq/example_iir_eq.m b/tune/eq/example_iir_eq.m index 4e36ac997b35..963d6b862875 100644 --- a/tune/eq/example_iir_eq.m +++ b/tune/eq/example_iir_eq.m @@ -38,7 +38,7 @@ function example_iir_eq() fs = 48e3; %% Design IIR loudness equalizer -eq_loud = loudness_iir_eq(fs, 2); +eq_loud = loudness_iir_eq(fs); %% Define a passthru IIR EQ equalizer b_pass = [1 0 0]; @@ -66,14 +66,7 @@ function example_iir_eq() %% -function eq = loudness_iir_eq(fs, fn) - -if nargin < 2 - fn = 1; -end -if nargin < 1 - fs = 48e3; -end +function eq = loudness_iir_eq(fs) %% Derived from Fletcher-Munson curves for 80 and 60 phon f = [ 20,21,22,24,25,27,28,30,32,34,36,38,40,43,45,48,51,54,57,60,64, ... @@ -105,12 +98,10 @@ function example_iir_eq() eq.fs = fs; eq.target_f = f; eq.target_m_db = m; -eq.enable_fir = 0; eq.enable_iir = 1; eq.norm_type = 'loudness'; eq.norm_offs_db = 0; - %% Manually setup low-shelf and high shelf parametric equalizers % % Parametric EQs are PEQ_HP1, PEQ_HP2, PEQ_LP1, PEQ_LP2, PEQ_LS1, @@ -131,6 +122,6 @@ function example_iir_eq() eq = eq_compute(eq); %% Plot -eq_plot(eq, fn); +eq_plot(eq); end diff --git a/tune/eq/example_spk_eq.m b/tune/eq/example_spk_eq.m index be633064a182..fd4cafc79e37 100644 --- a/tune/eq/example_spk_eq.m +++ b/tune/eq/example_spk_eq.m @@ -1,3 +1,5 @@ +function example_spk_eq() + %% Design an example speaker equalizer with the provided sample data % This equalizer by default uses a FIR and IIR components those should be % both in the speaker pipeline. @@ -42,7 +44,7 @@ eq.fs = 48e3; % Default sample rate in SOF eq.enable_fir = 1; % Try enabling and disabling FIR part eq.enable_iir = 1; % Try enabling and disabling IIR part -eq.norm_type = 'loudness'; % Preserve loudness approximately +eq.norm_type = 'peak'; % Scale filters to have peak at 0 dB eq.norm_offs_db = 0; % Can be used to control gain eq.p_fmin = 100; % With this data start plots from 100 Hz eq.p_fmax = 20e3; % and end to 20 kHz. @@ -98,8 +100,8 @@ if eq.enable_iir; eq.peq = [ ... eq.PEQ_HP2 100 NaN NaN; ... - eq.PEQ_PN2 1480 -6 2.0; ... - eq.PEQ_PN2 7600 -12 1.3; ... + eq.PEQ_PN2 1480 -7 2.0; ... + eq.PEQ_PN2 7600 -11 1.3; ... eq.PEQ_LP2 14500 NaN NaN; ... ]; end @@ -111,8 +113,8 @@ eq.fir_beta = 4; eq.fir_length = 63; eq.fir_autoband = 0; - eq.fmin_fir = 1000; - eq.fmax_fir = 13e3; + eq.fmin_fir = 900; + eq.fmax_fir = 10700; end %% Design EQ @@ -125,21 +127,28 @@ platform_max_channels = 2; % Identical two speakers assign_response = [0 0]; % Switch to response #0 num_responses = 1; % Single response -bq_fir = eq_fir_blob_quant(eq.b_fir); -bm_fir = eq_fir_blob_merge(platform_max_channels, ... - num_responses, ... - assign_response, ... - [ bq_fir ]); -bp_fir = eq_fir_blob_pack(bm_fir); -eq_alsactl_write('example_spk_eq_fir.txt', bp_fir); -eq_blob_write('example_spk_eq_fir.blob', bp_fir); +if eq.enable_fir + bq_fir = eq_fir_blob_quant(eq.b_fir); + bm_fir = eq_fir_blob_merge(platform_max_channels, ... + num_responses, ... + assign_response, ... + [ bq_fir ]); + bp_fir = eq_fir_blob_pack(bm_fir); + eq_alsactl_write('example_spk_eq_fir.txt', bp_fir); + eq_blob_write('example_spk_eq_fir.blob', bp_fir); +end %% Export IIR part -bq_iir = eq_iir_blob_quant(eq.b_p, eq.a_p); -bm_iir = eq_iir_blob_merge(platform_max_channels, ... - num_responses, ... - assign_response, ... - [ bq_iir ]); -bp_iir = eq_iir_blob_pack(bm_iir); -eq_alsactl_write('example_spk_eq_iir.txt', bp_iir); -eq_blob_write('example_spk_eq_iir.blob', bp_iir); +if eq.enable_iir + bq_iir = eq_iir_blob_quant(eq.b_p, eq.a_p); + bm_iir = eq_iir_blob_merge(platform_max_channels, ... + num_responses, ... + assign_response, ... + [ bq_iir ]); + bp_iir = eq_iir_blob_pack(bm_iir); + eq_alsactl_write('example_spk_eq_iir.txt', bp_iir); + eq_blob_write('example_spk_eq_iir.blob', bp_iir); +end + +end + From a3b38152fbf19e63da796ad710c10e71fd6652da Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Tue, 14 Aug 2018 16:57:46 +0800 Subject: [PATCH 235/324] topology: add some virtual widgets to topology of cnl It fixs dai link error in kernel log Signed-off-by: Rander Wang --- topology/sof-cnl-rt274.m4 | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index 141e03be4ead..d40efc142bb3 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -76,7 +76,17 @@ VIRTUAL_DAPM_ROUTE_OUT(ssp0 Tx, SSP, 0, OUT, 2) VIRTUAL_DAPM_ROUTE_OUT(Capture, SSP, 0, OUT, 3) VIRTUAL_DAPM_ROUTE_OUT(SoC DMIC, SSP, 0, OUT, 4) VIRTUAL_DAPM_ROUTE_IN(codec0_in, SSP, 0, IN, 5) -VIRTUAL_WIDGET(DMIC01 Rx, 6) -VIRTUAL_WIDGET(DMic, 7) -VIRTUAL_WIDGET(dmic01_hifi, 8) -VIRTUAL_WIDGET(ssp0 Rx, 9) +VIRTUAL_DAPM_ROUTE_OUT(ssp2_out, SSP, 0, OUT, 6) +VIRTUAL_DAPM_ROUTE_IN(ssp2_in, SSP, 0, IN, 7) +VIRTUAL_DAPM_ROUTE_OUT(ssp1_out, SSP, 0, OUT, 8) +VIRTUAL_WIDGET(DMIC01 Rx, 9) +VIRTUAL_WIDGET(DMic, 10) +VIRTUAL_WIDGET(dmic01_hifi, 11) +VIRTUAL_WIDGET(ssp0 Rx, 12) +VIRTUAL_WIDGET(ssp1_out, 13) +VIRTUAL_WIDGET(ssp2_out, 14) +VIRTUAL_WIDGET(ssp2_in, 15) +VIRTUAL_WIDGET(ssp2 Rx, 16) +VIRTUAL_WIDGET(ssp2 Tx, 17) +VIRTUAL_WIDGET(Dummy Playback, 18) +VIRTUAL_WIDGET(Dummy Capture, 19) From 157e37856d8ec0425d74721ed6f8f1cd56728868 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 21 Aug 2018 13:18:50 +0300 Subject: [PATCH 236/324] Decrease SRC pipeline buffers RAM size and update PCM configuration This patch decreases pipeline buffers usage from 5x or 4x periods to 3x to avoid DAI error in APL platform when allocating buffers. The smaller buffers are sufficient since the test topology pipelines are scheduled every 1ms (earlier assumption was every 5 ms). The PCM capability is updated to 8 channels similarly as with low delay pipeline. The highest sample rate is increased from 96 kHz to 192 kHz. Signed-off-by: Seppo Ingalsuo --- topology/sof/pipe-src-playback.m4 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index 0aa0f5c66cc8..ce05b9449670 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -17,8 +17,8 @@ include(`pipeline.m4') # # Host "Passthrough Playback" PCM -# with 5 sink and 0 source periods -W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 5, 0, 2) +# with 3 sink and 0 source periods +W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 3, 0, 2) # # SRC Configuration @@ -28,14 +28,14 @@ W_VENDORTUPLES(media_src_tokens, sof_src_tokens, LIST(` ', `SOF_TKN_SRC_RATE_OU W_DATA(media_src_conf, media_src_tokens) -# "SRC" has 5 source and 4 sink periods -W_SRC(0, PIPELINE_FORMAT, 5, 4, media_src_conf, 2) +# "SRC" has 3 source and 3 sink periods +W_SRC(0, PIPELINE_FORMAT, 3, 3, media_src_conf, 2) # Playback Buffers -W_BUFFER(0, COMP_BUFFER_SIZE(5, +W_BUFFER(0, COMP_BUFFER_SIZE(3, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), PLATFORM_HOST_MEM_CAP) -W_BUFFER(1, COMP_BUFFER_SIZE(4, +W_BUFFER(1, COMP_BUFFER_SIZE(3, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), PLATFORM_DAI_MEM_CAP) @@ -61,5 +61,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # PCM Configuration # -PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 8000, 96000, 2, 4, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 8000, 192000, 2, 8, 2, 16, 192, 16384, 65536, 65536) From 67802d8174304d7baba1ae6cb8b50e21aea038c9 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Wed, 22 Aug 2018 21:46:01 -0500 Subject: [PATCH 237/324] topology: add support for wm8804 This SPDIF transmitter/receiver is used by the HifiBerry DIGI+ and DIGI IO. The wm8804 operates as bit clock and frame master. TODO in future update: add support for capture on the DIGI+ IO (this may be done with a different topology file to avoid confusing users with a non-working PCM capture patch) Signed-off-by: Pierre-Louis Bossart --- topology/Makefile.am | 2 ++ topology/sof-apl-wm8804.m4 | 55 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 topology/sof-apl-wm8804.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 2c68376796f1..4da69e4c0c8e 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -31,6 +31,7 @@ MACHINES = \ sof-hsw-rt5640.tplg \ sof-apl-tdf8532.tplg \ sof-apl-pcm512x.tplg \ + sof-apl-wm8804.tplg \ sof-apl-da7219.tplg \ sof-glk-da7219.tplg \ sof-icl-nocodec.tplg @@ -65,6 +66,7 @@ EXTRA_DIST = \ sof-hsw-rt5640.m4 \ sof-apl-tdf8532.m4 \ sof-apl-pcm512x.m4 \ + sof-apl-wm8804.m4 \ sof-apl-da7219.m4 \ sof-glk-da7219.m4 \ sof-icl-nocodec.m4 diff --git a/topology/sof-apl-wm8804.m4 b/topology/sof-apl-wm8804.m4 new file mode 100644 index 000000000000..4dc15ebecc8c --- /dev/null +++ b/topology/sof-apl-wm8804.m4 @@ -0,0 +1,55 @@ +# +# Topology for generic Apollolake UP^2 with wm8804 codec. +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') +include(`ssp.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`platform/intel/bxt.m4') + +# +# Define the pipelines +# +# PCM0 ----> volume -----> SSP5 (wm8804) +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0) + +# +# DAIs configuration +# + +# playback DAI is SSP5 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 5, SSP5-Codec, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) + +# PCM Low Latency, id 0 +PCM_PLAYBACK_ADD(Port5, 0, PIPELINE_PCM_1) + +# +# BE configurations - overrides config in ACPI if present +# + +DAI_CONFIG(SSP, 5, 0, SSP5-Codec, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 3072000, codec_master), + SSP_CLOCK(fsync, 48000, codec_master), + SSP_TDM(2, 32, 3, 3), + SSP_CONFIG_DATA(SSP, 5, 24))) From 206deaf457b4a9d7260ea4cd99220e7d4297099d Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 30 Aug 2018 13:49:17 +0300 Subject: [PATCH 238/324] EQ Tool: Fix compatibility with Matlab and improve accuracy of IIR filters This patch changes code to allocate filter poles and zeros to biquads to allow seeing poor SNR due to strong scaling vs. available fixed point filter word length. The issue was severe especially with Matlab version of tf2sos() function. The replacement is straighforward z, p frequency sort. The scaling of biquads was changed to max -6 dB instead of previous -3 dB to be more safe against internal signal clipping. The IIR design was changed entirely to be based on zeros and poles (z, p, k) in intermediate storate instead of polynomial coefficients. This improves the accuracy especially of low frequencies high-pass designs. The default max. IIR order is increased from 12 to 16. Finally since the grpdelay() function in octave-signal package calculates incorrect result the group delay computation and plotting is disabled for now in Octave. It works in Matlab. Signed-off-by: Seppo Ingalsuo --- tune/eq/eq_compute.m | 15 ++++---- tune/eq/eq_compute_response.m | 47 +++++++++++++++++++------ tune/eq/eq_compute_tot_response.m | 4 +-- tune/eq/eq_defaults.m | 12 ++++--- tune/eq/eq_define_parametric_eq.m | 32 ++++++++++++----- tune/eq/eq_iir_blob_quant.m | 58 +++++++++++++++++++++---------- tune/eq/eq_norm.m | 4 +-- tune/eq/eq_plot.m | 52 ++++++++++++++------------- tune/eq/example_iir_eq.m | 7 ++-- tune/eq/example_spk_eq.m | 2 +- 10 files changed, 148 insertions(+), 85 deletions(-) diff --git a/tune/eq/eq_compute.m b/tune/eq/eq_compute.m index a5143b42599d..57a6293c3556 100644 --- a/tune/eq/eq_compute.m +++ b/tune/eq/eq_compute.m @@ -42,9 +42,9 @@ %% Define target (e.g. speaker) response as parametric filter. This could also % be numerical data interpolated to the grid. if length(eq.parametric_target_response) > 0 - [eq.b_t, eq.a_t] = eq_define_parametric_eq( ... + [eq.t_z, eq.t_p, eq.t_k] = eq_define_parametric_eq( ... eq.parametric_target_response, eq.fs); - eq.t_db = eq_compute_response(eq.b_t, eq.a_t, eq.f, eq.fs); + eq.t_db = eq_compute_response(eq.t_z, eq.t_p, eq.t_k, eq.f, eq.fs); end if isempty(eq.t_db) @@ -64,16 +64,15 @@ %% Parametric IIR EQ definition if eq.enable_iir - [eq.b_p, eq.a_p] = eq_define_parametric_eq(eq.peq, eq.fs); - if length(eq.b_p) > 2*eq.iir_biquads_max+1 + [eq.p_z, eq.p_p, eq.p_k] = eq_define_parametric_eq(eq.peq, eq.fs); + if max(length(eq.p_z), length(eq.p_p)) > 2*eq.iir_biquads_max error('Maximum number of IIR biquads is exceeded'); end else - eq.b_p = 1; - eq.a_p = 1; + [eq.p_z, eq.p_p, eq.p_k] = tf2zp(1, 1); end -[eq.iir_eq_db, eq.iir_eq_ph, eq.iir_eq_gd] = eq_compute_response(eq.b_p, ... - eq.a_p, eq.f, eq.fs); +[eq.iir_eq_db, eq.iir_eq_ph, eq.iir_eq_gd] = eq_compute_response(eq.p_z, ... + eq.p_p, eq.p_k, eq.f, eq.fs); %% FIR EQ computation diff --git a/tune/eq/eq_compute_response.m b/tune/eq/eq_compute_response.m index cf8a295381e0..e8a470466ca7 100644 --- a/tune/eq/eq_compute_response.m +++ b/tune/eq/eq_compute_response.m @@ -1,4 +1,4 @@ -function [m, ph, gd] = eq_compute_response(b, a, f, fs) +function [m, ph, gd] = eq_compute_response(z, p, k, f, fs) %% % Copyright (c) 2016, Intel Corporation @@ -30,16 +30,43 @@ % Author: Seppo Ingalsuo % -h = freqz(b, a, f, fs); -m = 20*log10(abs(h)); -ph = 180/pi*angle(h); +switch nargin + case 3 + b = z; % 1st arg + f = p; % 2nd arg + fs = k; % 3rd arg + h = freqz(b, 1, f, fs); + m = 20*log10(abs(h)); + ph = 180/pi*angle(h); -lb = length(b); -la = length(a); -if lb == 1 && la == 1 - gd = zeros(1, length(f)); -else - gd = 1/fs*grpdelay(b, a, f, fs); + if length(b) == 1 + gd = zeros(1, length(f)); + else + if exist('OCTAVE_VERSION', 'builtin') + % grpdelay() has some issue so better to not show a plot + gd = NaN * zeros(1, length(f)); + else + gd = 1/fs*grpdelay(b, 1, f, fs); + end + end + case 5 + [b, a] = zp2tf(z, p, k); + h = freqz(b, a, f, fs); + m = 20*log10(abs(h)); + ph = 180/pi*angle(h); + + if length(z) == 0 && length(p) == 0 + gd = zeros(1, length(f)); + else + if exist('OCTAVE_VERSION', 'builtin') + % grpdelay() has some issue so better to not show a plot + gd = NaN * zeros(1, length(f)); + else + gd = 1/fs*grpdelay(b, a, f, fs); + end + end + otherwise + error('Incorrect input parameters'); end end diff --git a/tune/eq/eq_compute_tot_response.m b/tune/eq/eq_compute_tot_response.m index 828b9365280c..250c3640c9ed 100644 --- a/tune/eq/eq_compute_tot_response.m +++ b/tune/eq/eq_compute_tot_response.m @@ -31,8 +31,8 @@ % % FIR response and combined IIR+FIR EQ -[eq.iir_eq_db, eq.iir_eq_ph, eq.iir_eq_gd] = eq_compute_response(eq.b_p, eq.a_p, eq.f, eq.fs); -[eq.fir_eq_db, eq.fir_eq_ph, eq.fir_eq_gd] = eq_compute_response(eq.b_fir, 1, eq.f, eq.fs); +[eq.iir_eq_db, eq.iir_eq_ph, eq.iir_eq_gd] = eq_compute_response(eq.p_z, eq.p_p, eq.p_k, eq.f, eq.fs); +[eq.fir_eq_db, eq.fir_eq_ph, eq.fir_eq_gd] = eq_compute_response(eq.b_fir, eq.f, eq.fs); eq.tot_eq_db = eq.iir_eq_db + eq.fir_eq_db; eq.tot_eq_gd = eq.iir_eq_gd + eq.fir_eq_gd; diff --git a/tune/eq/eq_defaults.m b/tune/eq/eq_defaults.m index cf16aea460c5..880e4e3c4db4 100644 --- a/tune/eq/eq_defaults.m +++ b/tune/eq/eq_defaults.m @@ -58,7 +58,7 @@ p.enable_fir = 0; % IIR conf -p.iir_biquads_max = 6; +p.iir_biquads_max = 8; p.enable_iir = 0; % Initialize other fields those are computed later to allow use of struct @@ -73,15 +73,17 @@ p.m_db_s = []; p.gd_s_s = []; p.logsmooth_noct = 0; -p.b_t = []; -p.a_t = []; +p.t_z = []; +p.t_p = []; +p.t_k = []; p.t_db = []; p.m_db_abs = 0; p.m_db_offs = 0; p.raw_m_noalign_db = []; p.err_db = []; -p.b_p = 0; -p.a_p = 0; +p.p_z = []; +p.p_p = []; +p.p_k = []; p.iir_eq_db = []; p.iir_eq_ph = []; p.iir_eq_gd = []; diff --git a/tune/eq/eq_define_parametric_eq.m b/tune/eq/eq_define_parametric_eq.m index 06136e238e8a..2beecf2b34db 100644 --- a/tune/eq/eq_define_parametric_eq.m +++ b/tune/eq/eq_define_parametric_eq.m @@ -1,4 +1,4 @@ -function [b_t, a_t] = eq_define_parametric_eq(peq, fs) +function [z, p, k] = eq_define_parametric_eq(peq, fs) %% % Copyright (c) 2016, Intel Corporation @@ -36,20 +36,27 @@ PEQ_PN2 = 9; PEQ_LP4 = 10; PEQ_HP4 = 11; sp = size(peq); -b_t = 1; a_t = 1; +z = []; +p = []; +k = 1; for i=1:sp(1) type = peq(i,1); f = peq(i,2); g = peq(i,3); Q = peq(i,4); if f < fs/2 + a0 = []; + b0 = []; + z0 = []; + p0 = []; + k0 = []; switch peq(i,1) - case PEQ_HP1, [b0, a0] = butter(1, 2*f/fs, 'high'); - case PEQ_HP2, [b0, a0] = butter(2, 2*f/fs, 'high'); - case PEQ_HP4, [b0, a0] = butter(4, 2*f/fs, 'high'); - case PEQ_LP1, [b0, a0] = butter(1, 2*f/fs); - case PEQ_LP2, [b0, a0] = butter(2, 2*f/fs); - case PEQ_LP4, [b0, a0] = butter(4, 2*f/fs); + case PEQ_HP1, [z0, p0, k0] = butter(1, 2*f/fs, 'high'); + case PEQ_HP2, [z0, p0, k0] = butter(2, 2*f/fs, 'high'); + case PEQ_HP4, [z0, p0, k0] = butter(4, 2*f/fs, 'high'); + case PEQ_LP1, [z0, p0, k0] = butter(1, 2*f/fs); + case PEQ_LP2, [z0, p0, k0] = butter(2, 2*f/fs); + case PEQ_LP4, [z0, p0, k0] = butter(4, 2*f/fs); case PEQ_LS1, [b0, a0] = low_shelf_1st(f, g, fs); case PEQ_LS2, [b0, a0] = low_shelf_2nd(f, g, fs); case PEQ_HS1, [b0, a0] = high_shelf_1st(f, g, fs); @@ -58,7 +65,14 @@ otherwise error('Unknown parametric EQ type'); end - b_t=conv(b_t, b0); a_t = conv(a_t, a0); + if length(a0) > 0 + [z0, p0, k0] = tf2zp(b0, a0); + end + if length(k0) > 0 + z = [z ; z0(:)]; + p = [p ; p0(:)]; + k = k * k0; + end end end end diff --git a/tune/eq/eq_iir_blob_quant.m b/tune/eq/eq_iir_blob_quant.m index 823d256e259b..0c19fb313db7 100644 --- a/tune/eq/eq_iir_blob_quant.m +++ b/tune/eq/eq_iir_blob_quant.m @@ -1,12 +1,12 @@ -function iir_resp = eq_iir_blob_quant(eq_b, eq_a) +function iir_resp = eq_iir_blob_quant(eq_z, eq_p, eq_k) %% Convert IIR coefficients to 2nd order sections and quantize % -% iir_resp = eq_iir_blob_quant(b, a, bits) +% iir_resp = eq_iir_blob_quant(z, p, k) % -% b - numerator coefficients -% a - denominator coefficients -% bits - number of bits to quantize +% z - zeros +% p - poles +% k - gain % % iir_resp - vector to setup an IIR equalizer with number of sections, shifts, % and quantized coefficients @@ -47,21 +47,41 @@ qf_iir = 30; bits_gain = 16; % Q2.14 qf_gain = 14; -scale_max = -3; % dB, scale biquad L-inf norm +scale_max = -6; % dB, scale biquads peak gain to this plot_pz = 0; plot_fr = 0; %% Convert IIR to 2nd order sections -if exist('OCTAVE_VERSION', 'builtin') - [sos, gain] = tf2sos(eq_b, eq_a); -else - % TODO: tf2sos produces in Matlab EQs with zero output due to - % very high gain variations within biquad. Need to investigate if - % this is incorrect usage and a bug here. - [sos, gain] = tf2sos(eq_b, eq_a, 'UP', Inf); - fprintf('Warning: Problems have been seen with some IIR designs.\n'); - fprintf('Warning: Please check the result.\n'); +% This a simple implementation of zp2sos() function. It is not used here due +% to utilization of rather strong scaling and resulting low SNR with the +% available word length in EQ in SOF. This poles and zeros allocation to +% biquads is base only in ascending sort of angular frequency. +sz = length(eq_z); +sp = length(eq_p); +sk = length(eq_k); +nb = max(sz, sp)/2; +az = angle(eq_z); +ap = angle(eq_p); +[~, iz] = sort(abs(az)); +[~, ip] = sort(abs(ap)); +eq_z = eq_z(iz); +eq_p = eq_p(ip); +sos = zeros(nb, 6); +for i = 1:nb + j = 2*(i-1)+1; + if i == 1 + [b, a] = zp2tf(eq_z(j:j+1), eq_p(j:j+1), eq_k); + else + [b, a] = zp2tf(eq_z(j:j+1), eq_p(j:j+1), 1); + end + sos(i,1:3) = b; + sos(i,4:6) = a; end +gain = 1; + +%% Convert 2nd order sections to SOF parameters format and scale the biquads +% with criteria below (Gain max -6 dB at any frequency). Then calculate +% scaling shifts and finally gain multiplier for output. sz = size(sos); nbr_sections = sz(1); n_section_header = 2; @@ -70,10 +90,10 @@ iir_resp(1) = nbr_sections; iir_resp(2) = nbr_sections; % Note: All sections in series +scale_max_lin = 10^(scale_max/20); for n=1:nbr_sections b = sos(n,1:3); a = sos(n,4:6); - if plot_pz figure zplane(b,a); @@ -84,14 +104,12 @@ np = 1024; [h, w] = freqz(b, a, np); hm = max(abs(h)); - scale = 10^(scale_max/20)/hm; + scale = scale_max_lin/hm; gain_remain = 1/scale; gain = gain*gain_remain; b = b * scale; - ma = max(abs(a)); mb = max(abs(b)); - if plot_fr figure [h, w] = freqz(b, a, np); @@ -119,6 +137,8 @@ iir_resp(m+5) = section_shift; iir_resp(m+6) = eq_coef_quant( section_gain, bits_gain, qf_gain); + %fprintf('sec=%d, shift=%d, gain=%f\n', n, section_shift, section_gain); + end end diff --git a/tune/eq/eq_norm.m b/tune/eq/eq_norm.m index fdb1cb5281d3..47b40d9a5fca 100644 --- a/tune/eq/eq_norm.m +++ b/tune/eq/eq_norm.m @@ -61,13 +61,13 @@ %% Adjust FIR and IIR gains if enabled if eq.enable_fir && eq.enable_iir eq.b_fir = eq.b_fir * g_fir * g_offs; - eq.b_p = eq.b_p * g_iir * g_offs; + eq.p_k = eq.p_k * g_iir * g_offs; end if eq.enable_fir && eq.enable_iir == 0 eq.b_fir = eq.b_fir * g_fir * g_offs; end if eq.enable_fir == 0 && eq.enable_iir - eq.b_p = eq.b_p * g_iir * g_offs; + eq.p_k = eq.p_k * g_iir * g_offs; end %% Re-compute response after adjusting gain diff --git a/tune/eq/eq_plot.m b/tune/eq/eq_plot.m index 2dc5743f1285..95968c4cf34c 100644 --- a/tune/eq/eq_plot.m +++ b/tune/eq/eq_plot.m @@ -115,7 +115,7 @@ function eq_plot(eq, fn) end %% IIR filter -if length(eq.b_p) > 1 +if length(eq.p_z) > 1 || length(eq.p_p) > 1 % Response fh=figure(fn); fn = fn+1; semilogx(eq.f, eq.iir_eq_db); @@ -128,7 +128,7 @@ function eq_plot(eq, fn) % Polar fh=figure(fn); fn = fn+1; - zplane(eq.b_p, eq.a_p); + zplane(eq.p_z, eq.p_p); grid on; tstr = sprintf('IIR zeros and poles: %s', eq.name); title(tstr); @@ -137,7 +137,8 @@ function eq_plot(eq, fn) ti = 50e-3; x = zeros(1, ti * round(eq.fs)); x(1) = 1; - y = filter(eq.b_p, eq.a_p, x); + sos = zp2sos(eq.p_z, eq.p_p, eq.p_k); + y = sosfilt(sos, x); fh=figure(fn); fn = fn+1; t = (0:(length(x)-1)) / eq.fs; plot(t, y); @@ -149,28 +150,29 @@ function eq_plot(eq, fn) end %% Group delay -fh=figure(fn); fn = fn+1; -if eq.enable_fir && eq.enable_iir - semilogx(eq.f, eq.tot_eq_gd * 1e3, ... - eq.f, eq.fir_eq_gd * 1e3, '--', ... - eq.f, eq.iir_eq_gd * 1e3, '--'); - legend('Combined','FIR','IIR'); -end -if eq.enable_fir && eq.enable_iir == 0 - semilogx(eq.f, eq.fir_eq_gd * 1e3); - legend('FIR'); -end -if eq.enable_fir == 0 && eq.enable_iir - semilogx(eq.f, eq.iir_eq_gd * 1e3); - legend('IIR'); +if ~exist('OCTAVE_VERSION', 'builtin') + % Skip plot if running in Octave due to incorrect result + fh=figure(fn); fn = fn+1; + if eq.enable_fir && eq.enable_iir + semilogx(eq.f, eq.tot_eq_gd * 1e3, ... + eq.f, eq.fir_eq_gd * 1e3, '--', ... + eq.f, eq.iir_eq_gd * 1e3, '--'); + legend('Combined','FIR','IIR'); + end + if eq.enable_fir && eq.enable_iir == 0 + semilogx(eq.f, eq.fir_eq_gd * 1e3); + legend('FIR'); + end + if eq.enable_fir == 0 && eq.enable_iir + semilogx(eq.f, eq.iir_eq_gd * 1e3); + legend('IIR'); + end + grid on; + xlabel('Frequency (Hz)'); + ylabel('Group delay (ms)'); + ax = axis; axis([eq.p_fmin eq.p_fmax ax(3:4)]); + tstr = sprintf('Filter group delay: %s', eq.name); + title(tstr); end -grid on; -xlabel('Frequency (Hz)'); -ylabel('Group delay (ms)'); -ax = axis; axis([eq.p_fmin eq.p_fmax ax(3:4)]); -tstr = sprintf('Filter group delay: %s', eq.name); -title(tstr); - - end diff --git a/tune/eq/example_iir_eq.m b/tune/eq/example_iir_eq.m index 963d6b862875..ddcc17eb508b 100644 --- a/tune/eq/example_iir_eq.m +++ b/tune/eq/example_iir_eq.m @@ -41,12 +41,11 @@ function example_iir_eq() eq_loud = loudness_iir_eq(fs); %% Define a passthru IIR EQ equalizer -b_pass = [1 0 0]; -a_pass = [1 0 0]; +[z_pass, p_pass, k_pass] = tf2zp([1 0 0],[1 0 0]); %% Quantize and pack filter coefficients plus shifts etc. -bq_pass = eq_iir_blob_quant(b_pass, a_pass); -bq_loud = eq_iir_blob_quant(eq_loud.b_p, eq_loud.a_p); +bq_pass = eq_iir_blob_quant(z_pass, p_pass, k_pass); +bq_loud = eq_iir_blob_quant(eq_loud.p_z, eq_loud.p_p, eq_loud.p_k); %% Build blob platform_max_channels = 4; % Setup max 4 channels EQ diff --git a/tune/eq/example_spk_eq.m b/tune/eq/example_spk_eq.m index fd4cafc79e37..7be22c3ff92f 100644 --- a/tune/eq/example_spk_eq.m +++ b/tune/eq/example_spk_eq.m @@ -140,7 +140,7 @@ function example_spk_eq() %% Export IIR part if eq.enable_iir - bq_iir = eq_iir_blob_quant(eq.b_p, eq.a_p); + bq_iir = eq_iir_blob_quant(eq.p_z, eq.p_p, eq.p_k); bm_iir = eq_iir_blob_merge(platform_max_channels, ... num_responses, ... assign_response, ... From a47524a2b26578fc5746e508b5b1e9e01fc91d4f Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 30 Aug 2018 16:32:02 +0300 Subject: [PATCH 239/324] SRC test: Fix testbench execute command line plus cleanup This patch fixes the command line sample rate parameters passing into host testbench (-r & -R). In my computer at least the print command of non-visible plots stopped working into error so I disabled the print commant that creates PNG graphics files. It's OK since the purpose of this script is batch testing. The visible plot files can be enabled from SRC test script to see plots if need for deep dive. The patch includes also fix for text output for "help src_test". The input and output word lengths were missing from sample command. Signed-off-by: Seppo Ingalsuo --- test/src_run.sh | 2 +- test/src_test.m | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/test/src_run.sh b/test/src_run.sh index 93c67db888bb..670dc4415dd2 100755 --- a/test/src_run.sh +++ b/test/src_run.sh @@ -29,7 +29,7 @@ fi # Run command CMD0=$HOST_EXE -CMD1="-d -x $FS1 -y $FS2 -i $FN_IN -o $FN_OUT -t $TPLG -a src=libsof_${COMP}.so $CMDFMT" +CMD1="-d -r $FS1 -R $FS2 -i $FN_IN -o $FN_OUT -t $TPLG -a src=libsof_${COMP}.so $CMDFMT" CMD="$CMD0 $CMD1" export LD_LIBRARY_PATH=$HOST_LIB diff --git a/test/src_test.m b/test/src_test.m index 91251ebd6305..bad220604003 100644 --- a/test/src_test.m +++ b/test/src_test.m @@ -3,7 +3,7 @@ %% % src_test - test with SRC test bench objective audio quality parameters % -% src_test(fs_in, fs_out) +% src_test(bits_in, bits_out, fs_in, fs_out) % % bits_in - input word length % bits_out - output word length @@ -456,7 +456,9 @@ function src_test_result_print(t, testverbose, testacronym, ph) title(tstr); end pfn = sprintf('plots/%s_src_%d_%d.png', testacronym, t.fs1, t.fs2); -print(pfn, '-dpng'); +% The print command caused a strange error with __osmesa_print__ +% so disable it for now until solved. +%print(pfn, '-dpng'); if t.close_plot_windows close all; end From e767798c7f3ecd5d571afb74d2e7c58a8d726631 Mon Sep 17 00:00:00 2001 From: Mengdong Lin Date: Tue, 7 Aug 2018 22:17:38 -0400 Subject: [PATCH 240/324] topology: Define hda.m4 for HD-Audio configurations This patch adds a new file hda.m4. This file defines macro HDA_DAI_CONFIG(idx, link_id, name) for user to define configurations for HDA Backend links. The link's data tuple will carry the HDA type info for kernel driver to check the link type. Pleae note that there are no HW configurations defined for HDA BE links because current HW configurations is more suitable for SSP BE links, but not for HDA. We'll decide what HW configurations are suitable for HDA BE links later. Signed-off-by: Mengdong Lin --- topology/m4/Makefile.am | 1 + topology/m4/hda.m4 | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 topology/m4/hda.m4 diff --git a/topology/m4/Makefile.am b/topology/m4/Makefile.am index d7b867f316cd..4d74cefaa8cf 100644 --- a/topology/m4/Makefile.am +++ b/topology/m4/Makefile.am @@ -1,6 +1,7 @@ EXTRA_DIST = \ buffer.m4 \ dai.m4 \ + hda.m4 \ mixer.m4 \ mixercontrol.m4 \ pcm.m4 \ diff --git a/topology/m4/hda.m4 b/topology/m4/hda.m4 new file mode 100644 index 000000000000..dcce69fc5370 --- /dev/null +++ b/topology/m4/hda.m4 @@ -0,0 +1,22 @@ +dnl HDA_DAI_CONFIG(idx, link_id, name) +define(`HDA_DAI_CONFIG', +`SectionVendorTuples."'N_DAI_CONFIG(HDA$1)`_tuples_common" {' +` tokens "sof_dai_tokens"' +` tuples."string" {' +` SOF_TKN_DAI_TYPE "HDA"' +` }' +` tuples."word" {' +` SOF_TKN_DAI_INDEX' STR($1) +` }' +`}' +`SectionData."'N_DAI_CONFIG(HDA$1)`_data_common" {' +` tuples "'N_DAI_CONFIG(HDA$1)`_tuples_common"' +`}' +`' +`SectionBE."'$3`" {' +` id "'$2`"' +` index "0"' +` data [' +` "'N_DAI_CONFIG(HDA$1)`_data_common"' +` ]' +`}') From c0062f98c7ec8d9bc03f6bfd7ff46d8fbe08a5cd Mon Sep 17 00:00:00 2001 From: Mengdong Lin Date: Thu, 2 Aug 2018 17:13:19 -0400 Subject: [PATCH 241/324] topology: Create HDMI only m4 file for APL This patch creates sof_apl_hdmi.m4 to define topology for 3 playback pipelines, FE and BE links for HDMI/DisplayPort(DP) audio. This can be a reference to verify audio over HDMI/DP on APL platforms. The HDMI/DP frontends are named as HDMIx, to reuse the generic HDA DSP machine driver which checks the link names and will do extra initialization on HDMI/DP frontends if "HDMI" is found in the link name. This m4 does't include topology for using external HD-A analog codecs. We will create another m4 file to include both HDA display and analog audio. Signed-off-by: Mengdong Lin --- topology/Makefile.am | 2 + topology/sof-apl-hdmi.m4 | 93 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 topology/sof-apl-hdmi.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 4da69e4c0c8e..767d3d549af9 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -19,6 +19,7 @@ DEPS = \ MACHINES = \ sof-cht-nocodec.tplg \ sof-cht-max98090.tplg \ + sof-apl-hdmi.tplg \ sof-apl-nocodec.tplg \ sof-byt-nocodec.tplg \ sof-bdw-rt286.tplg \ @@ -54,6 +55,7 @@ clean-local: EXTRA_DIST = \ sof-cht-nocodec.m4 \ sof-cht-max98090.m4 \ + sof-apl-hdmi.m4 \ sof-apl-nocodec.m4 \ sof-byt-nocodec.m4 \ sof-bdw-rt286.m4 \ diff --git a/topology/sof-apl-hdmi.m4 b/topology/sof-apl-hdmi.m4 new file mode 100644 index 000000000000..00d7c68687dd --- /dev/null +++ b/topology/sof-apl-hdmi.m4 @@ -0,0 +1,93 @@ +# +# Topology for generic Apollolake board with no codec. +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`hda.m4') +include(`ssp.m4') +include(`pipeline.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`platform/intel/bxt.m4') + +# +# Define the pipelines +# +# PCM0 ----> volume -----> iDisp1 +# PCM1 ----> Volume -----> iDisp2 +# PCM2 ----> volume -----> iDisp3 + +dnl PIPELINE_PCM_ADD(pipeline, +dnl pipe id, pcm, max channels, format, +dnl frames, deadline, priority, core) + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 1, 0, 2, s16le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 2, 1, 2, s16le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 3 on PCM 2 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 3, 2, 2, s16le, + 48, 1000, 0, 0) + +# +# DAIs configuration +# + +dnl DAI_ADD(pipeline, +dnl pipe id, dai type, dai_index, dai_be, +dnl buffer, periods, format, +dnl frames, deadline, priority, core) + +# playback DAI is iDisp1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, HDA, 0, iDisp1, + PIPELINE_SOURCE_1, 2, s16le, + 48, 1000, 0, 0) + +# playback DAI is iDisp2 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 2, HDA, 1, iDisp2, + PIPELINE_SOURCE_2, 2, s16le, + 48, 1000, 0, 0) + +# playback DAI is iDisp3 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 3, HDA, 2, iDisp3, + PIPELINE_SOURCE_3, 2, s16le, + 48, 1000, 0, 0) + + +dnl PCM_PLAYBACK_ADD(name, pcm_id, playback) +PCM_PLAYBACK_ADD(HDMI1, 0, PIPELINE_PCM_1) +PCM_PLAYBACK_ADD(HDMI2, 1, PIPELINE_PCM_2) +PCM_PLAYBACK_ADD(HDMI3, 2, PIPELINE_PCM_3) + +# +# BE configurations - overrides config in ACPI if present +# + +dnl HDA_DAI_CONFIG(dai_index, link_id, name) +HDA_DAI_CONFIG(0, 1, iDisp1) +HDA_DAI_CONFIG(1, 2, iDisp2) +HDA_DAI_CONFIG(2, 3, iDisp3) From 72629ac2d996f59b91dee669bc4b044f9add36fd Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Tue, 4 Sep 2018 10:30:38 +0300 Subject: [PATCH 242/324] topology: first try of m4 debug macros Signed-off-by: Jaska Uimonen --- topology/m4/dai.m4 | 7 ++++++- topology/m4/debug.m4 | 29 +++++++++++++++++++++++++++++ topology/m4/pipeline.m4 | 1 + topology/m4/utils.m4 | 4 +++- topology/sof-apl-da7219.m4 | 7 +++---- topology/sof-apl-pcm512x.m4 | 4 ++++ 6 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 topology/m4/debug.m4 diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index f38433f3f740..74717189f197 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -1,5 +1,7 @@ divert(-1) +include(`debug.m4') + dnl Define macros for DAI IN/OUT widgets and DAI config dnl DAI name) @@ -158,7 +160,9 @@ define(`DAI_CONFIG', ` "'N_DAI_CONFIG($1$2)`_data_common"' `ifelse($1, `DMIC',` "'N_DAI_CONFIG($1$2)`_pdm_data"', `')' ` ]' -`}') +`}' +`DEBUG_DAI_CONFIG($1, $3)' +) dnl DAI_ADD(pipeline, dnl pipe id, dai type, dai_index, dai_be, @@ -189,6 +193,7 @@ define(`DAI_ADD', `define(`SCHEDULE_PRIORITY', $11)' `define(`SCHEDULE_CORE', $12)' `include($1)' +`DEBUG_DAI($3, $4)' ) divert(0)dnl diff --git a/topology/m4/debug.m4 b/topology/m4/debug.m4 new file mode 100644 index 000000000000..6cd16c863cb8 --- /dev/null +++ b/topology/m4/debug.m4 @@ -0,0 +1,29 @@ +divert(-1) + +define(`DEBUG_START', +`ifdef(`GRAPH', `errprint(`digraph topology { +node [color=Red,fontname=Courier] +edge [color=Blue, style=dashed]' +)')') + +define(`DEBUG_END', +`ifdef(`GRAPH', `errprint(`}' +)')') + +define(`DEBUG_GRAPH', +`ifdef(`GRAPH', `errprint("$2"->"$1" +)')') + +define(`DEBUG_DAI', +`ifdef(`INFO', `errprint(/* note: $1 DAI ADD dai_index $2 should match the member (index) in struct dai array (firmware platform specific, usually in dai.c) */ +)')') + +define(`DEBUG_DAI_CONFIG', +`ifdef(`INFO', `errprint(/* note: $1 DAI CONFIG id $2 should match the member (id) in struct snd_soc_dai_link in kernel machine driver (usually under linux/sound/soc/intel/boards/) */ +)')') + +define(`DEBUG_PCM_ADD', +`ifdef(`INFO', `errprint(/* note: PCM ADD for $1 id $2 should be unique within playback or capture pcm ids*/ +)')') + +divert(0)dnl diff --git a/topology/m4/pipeline.m4 b/topology/m4/pipeline.m4 index 0cfe4861c66c..7c1f307b7c66 100644 --- a/topology/m4/pipeline.m4 +++ b/topology/m4/pipeline.m4 @@ -52,6 +52,7 @@ define(`PIPELINE_PCM_ADD', `define(`SCHEDULE_PRIORITY', $8)' `define(`SCHEDULE_CORE', $9)' `include($1)' +`DEBUG_PCM_ADD($1, $3)' ) dnl PIPELINE_PCM_DAI_ADD(pipeline, diff --git a/topology/m4/utils.m4 b/topology/m4/utils.m4 index 73faae63daee..a1fe94bfaa3e 100644 --- a/topology/m4/utils.m4 +++ b/topology/m4/utils.m4 @@ -1,5 +1,7 @@ divert(-1) +include(`debug.m4') + define(`concat',`$1$2') define(`STR', `"'$1`"') @@ -24,7 +26,7 @@ dnl Memory capabilities define(`MEMCAPS', `pushdef(`i', $#) pushdef(`j', `1') SUM_LOOP($@)') dnl create direct DAPM/pipeline link between 2 widgets) -define(`dapm', `"$1, , $2"') +define(`dapm', `"$1, , $2"'`DEBUG_GRAPH($1, $2)') dnl COMP_SAMPLE_SIZE(FMT) define(`COMP_SAMPLE_SIZE', diff --git a/topology/sof-apl-da7219.m4 b/topology/sof-apl-da7219.m4 index 514dd415b3fa..0c102feaa98b 100644 --- a/topology/sof-apl-da7219.m4 +++ b/topology/sof-apl-da7219.m4 @@ -18,6 +18,8 @@ include(`sof/tokens.m4') include(`platform/intel/bxt.m4') include(`platform/intel/dmic.m4') +DEBUG_START + # # Define the pipelines # @@ -138,7 +140,4 @@ VIRTUAL_DAPM_ROUTE_OUT(Capture, SSP, 0, OUT, 16) VIRTUAL_DAPM_ROUTE_OUT(SoC DMIC, SSP, 0, OUT, 17) VIRTUAL_DAPM_ROUTE_IN(codec0_in, SSP, 0, IN, 18) - - - - +DEBUG_END diff --git a/topology/sof-apl-pcm512x.m4 b/topology/sof-apl-pcm512x.m4 index cf853377fad7..48257ae3e8b0 100644 --- a/topology/sof-apl-pcm512x.m4 +++ b/topology/sof-apl-pcm512x.m4 @@ -17,6 +17,8 @@ include(`sof/tokens.m4') # Include Apollolake DSP configuration include(`platform/intel/bxt.m4') +DEBUG_START + # # Define the pipelines # @@ -53,3 +55,5 @@ DAI_CONFIG(SSP, 5, 0, SSP5-Codec, SSP_CLOCK(fsync, 48000, codec_slave), SSP_TDM(2, 32, 3, 3), SSP_CONFIG_DATA(SSP, 5, 24))) + +DEBUG_END From 1354af8b6664f6c43d32953eff347f8f8b7c7a8c Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Tue, 4 Sep 2018 17:47:22 +0300 Subject: [PATCH 243/324] topology: make building tests into a separate target Signed-off-by: Jaska Uimonen --- Makefile.am | 4 ++++ README | 6 ++++++ topology/Makefile.am | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index ea5d74635b58..902f0e99474f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1 +1,5 @@ SUBDIRS = rmbox topology +TESTDIR = topology/test + +tests: + $(MAKE) -C $(TESTDIR) diff --git a/README b/README index 4eca4b532177..a8f818b8ecb4 100644 --- a/README +++ b/README @@ -34,3 +34,9 @@ xtensa-byt-elf-objcopy -I binary -O elf32-xtensa-le -B xtensa image.bin image.bi xtensa-byt-elf-objdump -D image.bin.elf > image.dis.txt +tests +===== + +To generate all test configuration files: + +make tests \ No newline at end of file diff --git a/topology/Makefile.am b/topology/Makefile.am index 767d3d549af9..207e5207136d 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -3,7 +3,7 @@ # Dependencies # -SUBDIRS = test m4 sof common platform +SUBDIRS = m4 sof common platform DEPS = \ platform/intel/*.m4 \ From 4c9e3ddaf3e27f7bae6f203be30fc4f0238e6690 Mon Sep 17 00:00:00 2001 From: Mengdong Lin Date: Tue, 4 Sep 2018 21:10:35 -0400 Subject: [PATCH 244/324] topology: Add 3 HDMI/DP PCMs and backends for GLK Define 3 new PCMs and backends for HDMI/DP playback on GLK platform. Here are the updated pipelines in sof-glk-da7219.m4: PCM0 ----> volume (pipe 1) ---> SSP1 (speaker - maxim98357a, BE link 0) PCM1 <---> volume (pipe 2,3) <--> SSP2 (headset - da7219, BE link 1) PCM99 <---- volume (pipe 4) <--- DMIC0 (dmic capture, BE link 2) PCM5 ----> volume (pipe 5) ---> iDisp1 (HDMI/DP playback, BE link 3) PCM6 ----> Volume (pipe 6) ---> iDisp2 (HDMI/DP playback, BE link 4) PCM7 ----> volume (pipe 7) ---> iDisp3 (HDMI/DP playback, BE link 5) There is also support for changing HDMI/DP pipelines to pass-through for validation purpose, which is commented off by default. Pleaes note that 3 virtual widgets hifi1~3 are removed, because they'll be created by HDMI codec driver. This m4 was verified on GLK platform. --- topology/sof-glk-da7219.m4 | 65 ++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 7 deletions(-) diff --git a/topology/sof-glk-da7219.m4 b/topology/sof-glk-da7219.m4 index 121f4edeb67a..a2ac09fcd766 100644 --- a/topology/sof-glk-da7219.m4 +++ b/topology/sof-glk-da7219.m4 @@ -7,6 +7,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') include(`ssp.m4') +include(`hda.m4') # Include TLV library include(`common/tlv.m4') @@ -21,9 +22,12 @@ include(`platform/intel/dmic.m4') # # Define the pipelines # -# PCM0 ----> volume -----> SSP1 (speaker - maxim98357a) -# PCM1 <---> volume <----> SSP2 (headset - da7219) -# PCM99 <---- volume <----- DMIC0 (dmic capture) +# PCM0 ----> volume (pipe 1) -----> SSP1 (speaker - maxim98357a, BE link 0) +# PCM1 <---> volume (pipe 2,3) <----> SSP2 (headset - da7219, BE link 1) +# PCM99 <---- volume (pipe 4) <----- DMIC0 (dmic capture, BE link 2) +# PCM5 ----> volume (pipe 5) -----> iDisp1 (HDMI/DP playback, BE link 3) +# PCM6 ----> Volume (pipe 6) -----> iDisp2 (HDMI/DP playback, BE link 4) +# PCM7 ----> volume (pipe 7) -----> iDisp3 (HDMI/DP playback, BE link 5) # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. @@ -44,13 +48,34 @@ PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, 3, 1, 2, s32le, 48, 1000, 0, 0) -# Low Latency capture pipeline 4 on PCM 0 using max 4 channels of s32le. +# Low Latency capture pipeline 4 on PCM 99 using max 4 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 #PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, 4, 99, 4, s32le, 48, 1000, 0, 0) +# Low Latency playback pipeline 5 on PCM 5 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 5, 5, 2, s16le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 6 on PCM 6 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 6, 6, 2, s16le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 7 on PCM 7 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4, +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 7, 7, 2, s16le, + 48, 1000, 0, 0) + # # DAIs configuration # @@ -83,9 +108,33 @@ DAI_ADD(sof/pipe-dai-capture.m4, PIPELINE_SINK_4, 2, s32le, 48, 1000, 0, 0) +# playback DAI is iDisp1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 5, HDA, 3, iDisp1, + PIPELINE_SOURCE_5, 2, s16le, + 48, 1000, 0, 0) + +# playback DAI is iDisp2 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 6, HDA, 4, iDisp2, + PIPELINE_SOURCE_6, 2, s16le, + 48, 1000, 0, 0) + +# playback DAI is iDisp3 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 7, HDA, 5, iDisp3, + PIPELINE_SOURCE_7, 2, s16le, + 48, 1000, 0, 0) + PCM_PLAYBACK_ADD(Speakers, 0, PIPELINE_PCM_1) PCM_DUPLEX_ADD(Headset, 1, PIPELINE_PCM_2, PIPELINE_PCM_3) PCM_CAPTURE_ADD(DMIC01, 99, PIPELINE_PCM_4) +PCM_PLAYBACK_ADD(HDMI1, 5, PIPELINE_PCM_5) +PCM_PLAYBACK_ADD(HDMI2, 6, PIPELINE_PCM_6) +PCM_PLAYBACK_ADD(HDMI3, 7, PIPELINE_PCM_7) # # BE configurations - overrides config in ACPI if present @@ -115,6 +164,11 @@ DAI_CONFIG(DMIC, 0, 2, dmic01, # PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) PDM_CONFIG(DMIC, 0, STEREO_PDM0))) +# 3 HDMI/DP outputs (ID: 3,4,5) +HDA_DAI_CONFIG(3, 3, iDisp1) +HDA_DAI_CONFIG(4, 4, iDisp2) +HDA_DAI_CONFIG(5, 5, iDisp3) + ## remove warnings with SST hard-coded routes (FIXME) VIRTUAL_WIDGET(ssp5 Tx, 0) @@ -126,9 +180,6 @@ VIRTUAL_WIDGET(dmic01_hifi, 5) VIRTUAL_WIDGET(hif5-0 Output, 6) VIRTUAL_WIDGET(hif6-0 Output, 7) VIRTUAL_WIDGET(hif7-0 Output, 8) -VIRTUAL_WIDGET(hifi1, 9) -VIRTUAL_WIDGET(hifi2, 10) -VIRTUAL_WIDGET(hifi3, 11) VIRTUAL_DAPM_ROUTE_OUT(codec0_out, SSP, 0, OUT, 12) VIRTUAL_DAPM_ROUTE_OUT(codec1_out, SSP, 0, OUT, 13) From e3d68ecd8914d486429e64908a71e04ca56a114e Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 17 Sep 2018 16:48:31 +0300 Subject: [PATCH 245/324] EQ Tool: Output topology m4 binary control style configuration data This patch adds export function for the m4 syntax bytes data and adds the export of such blob to example designs. The example EQ designs are edited to make this format export too. In addition the example FIR length is adjusted to be near current IPC length maximum (384) and improve the effect quality. Signed-off-by: Seppo Ingalsuo --- tune/eq/eq_tplg_write.m | 63 ++++++++++++++++++++++++++++++++++++++++ tune/eq/example_fir_eq.m | 4 ++- tune/eq/example_iir_eq.m | 2 ++ tune/eq/example_spk_eq.m | 3 +- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 tune/eq/eq_tplg_write.m diff --git a/tune/eq/eq_tplg_write.m b/tune/eq/eq_tplg_write.m new file mode 100644 index 000000000000..cda5e016db1a --- /dev/null +++ b/tune/eq/eq_tplg_write.m @@ -0,0 +1,63 @@ +function eq_tplg_write(fn, blob8, eqtype) + +%% +% Copyright (c) 2018, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Pad blob length to multiple of four bytes +n_orig = length(blob8); +n_new = ceil(n_orig/4)*4; +blob8_new = zeros(1, n_new); +blob8_new(1:n_orig) = blob8; + +%% Write blob +fh = fopen(fn, 'w'); +nl = 8; +fprintf(fh, '`SectionData."''N_EQ_%s($1)`_data_bytes" {''\n', ... + upper(eqtype)); +fprintf(fh, '` bytes "'); +for i = 1:nl:n_new + if i > 1 + fprintf(fh, '` '); + end + for j = 0:nl-1 + n = i + j; + if n < n_new + fprintf(fh, '0x%02x,', blob8_new(n)); + end + if n == n_new + fprintf(fh, '0x%02x"', blob8_new(n)); + end + end + fprintf(fh, '''\n'); +end +fprintf(fh, '`}''\n'); +fclose(fh); + +end diff --git a/tune/eq/example_fir_eq.m b/tune/eq/example_fir_eq.m index d57374dfc766..2186ea6a2296 100644 --- a/tune/eq/example_fir_eq.m +++ b/tune/eq/example_fir_eq.m @@ -34,6 +34,7 @@ function example_fir_eq() ascii_blob_fn = 'example_fir_eq.txt'; binary_blob_fn = 'example_fir_eq.blob'; +tplg_blob_fn = 'example_fir_eq.m4'; endian = 'little'; fs = 48e3; @@ -60,6 +61,7 @@ function example_fir_eq() bp = eq_fir_blob_pack(bm, endian); eq_alsactl_write(ascii_blob_fn, bp); eq_blob_write(binary_blob_fn, bp); +eq_tplg_write(tplg_blob_fn, bp, 'FIR'); end @@ -100,7 +102,7 @@ function example_fir_eq() eq.enable_fir = 1; % By default both FIR and IIR disabled, enable one eq.fir_beta = 3.5; % Use with care, low value can corrupt -eq.fir_length = 107; % Gives just < 255 bytes +eq.fir_length = 136; % Gives just < 316 bytes eq.fir_autoband = 0; % Select manually frequency limits eq.fmin_fir = 100; % Equalization starts from 100 Hz eq.fmax_fir = 20e3; % Equalization ends at 20 kHz diff --git a/tune/eq/example_iir_eq.m b/tune/eq/example_iir_eq.m index ddcc17eb508b..0345bcf46829 100644 --- a/tune/eq/example_iir_eq.m +++ b/tune/eq/example_iir_eq.m @@ -34,6 +34,7 @@ function example_iir_eq() blob_fn = 'example_iir_eq.blob'; alsa_fn = 'example_iir_eq.txt'; +tplg_fn = 'example_iir_eq.m4'; endian = 'little'; fs = 48e3; @@ -60,6 +61,7 @@ function example_iir_eq() bp = eq_iir_blob_pack(bm); eq_blob_write(blob_fn, bp); eq_alsactl_write(alsa_fn, bp); +eq_tplg_write(tplg_fn, bp, 'IIR'); end diff --git a/tune/eq/example_spk_eq.m b/tune/eq/example_spk_eq.m index 7be22c3ff92f..d829e0256e9f 100644 --- a/tune/eq/example_spk_eq.m +++ b/tune/eq/example_spk_eq.m @@ -136,6 +136,7 @@ function example_spk_eq() bp_fir = eq_fir_blob_pack(bm_fir); eq_alsactl_write('example_spk_eq_fir.txt', bp_fir); eq_blob_write('example_spk_eq_fir.blob', bp_fir); + eq_tplg_write('example_spk_eq_fir.m4', bp_fir, 'FIR'); end %% Export IIR part @@ -148,7 +149,7 @@ function example_spk_eq() bp_iir = eq_iir_blob_pack(bm_iir); eq_alsactl_write('example_spk_eq_iir.txt', bp_iir); eq_blob_write('example_spk_eq_iir.blob', bp_iir); + eq_tplg_write('example_spk_eq_iir.m4', bp_iir, 'IIR'); end end - From c43666d6f05bf920de5326489073adbcc60a88cc Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 19 Sep 2018 16:36:22 +0300 Subject: [PATCH 246/324] EQ FIR: Add check and removal for trailing zeros in filter coefficients This patch adds removing of extra zeros in the FIR coefficients. The zeros can happen in some responses due to fixed point quantization of very small values. The zero taps consume DSP resources for nothing so better to clean them out for EQ configuration data. Signed-off-by: Seppo Ingalsuo --- tune/eq/eq_fir_blob_quant.m | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tune/eq/eq_fir_blob_quant.m b/tune/eq/eq_fir_blob_quant.m index f3c53fcd948d..6d060032d364 100644 --- a/tune/eq/eq_fir_blob_quant.m +++ b/tune/eq/eq_fir_blob_quant.m @@ -44,15 +44,31 @@ bits = 16; end +%% Quantize [bq, shift] = eq_fir_quantize(b, bits); -nb = length(bq); +%% Check trailing zeros +nf = length(bq); +nz = nf; +while bq(nz) == 0 + nz = nz - 1; +end +if nz < nf + nb = nz + 1; + fprintf(1,'Note: Filter length was reduced to %d -> %d due to trailing zeros.\n', ... + nf, nb); + bq = bq(1:nb); +else + nb = nf; +end + +%% Make length multiple of four (optimized FIR core) mod4 = mod(nb, 4); if mod4 > 0 pad = zeros(1,4-mod4); bqp = [bq pad]; nnew = length(bqp); - fprintf(1,'Note: Filter length was %d, padded length into %d,\n', nb, nnew); + fprintf(1,'Note: Filter length was %d, padded length into %d.\n', nb, nnew); else nnew = nb; bqp = bq; From 46fc6fdf6e151e54c7e27e4785dc3f0aebc5bcd1 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 21 Sep 2018 13:19:45 -0700 Subject: [PATCH 247/324] Set capabilities of channels to those defined in topology Do not use a static defined number of channels, use the channels passed in otherwise ASoC will try to allocate number of channels that should not be allowed. Signed-off-by: Curtis Malainey --- topology/sof/pipe-low-latency-capture.m4 | 2 +- topology/sof/pipe-low-latency-playback.m4 | 2 +- topology/sof/pipe-passthrough-capture.m4 | 2 +- topology/sof/pipe-passthrough-playback.m4 | 2 +- topology/sof/pipe-pcm-media.m4 | 2 +- topology/sof/pipe-src-capture.m4 | 2 +- topology/sof/pipe-src-playback.m4 | 2 +- topology/sof/pipe-volume-capture.m4 | 2 +- topology/sof/pipe-volume-playback.m4 | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/topology/sof/pipe-low-latency-capture.m4 b/topology/sof/pipe-low-latency-capture.m4 index 39c2ccefa6d6..897fe050c54d 100644 --- a/topology/sof/pipe-low-latency-capture.m4 +++ b/topology/sof/pipe-low-latency-capture.m4 @@ -64,4 +64,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Low Latency Capture PCM_ID # PCM Configuration # -PCM_CAPABILITIES(Low Latency Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 4, 2, 4, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Low Latency Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, PIPELINE_CHANNELS, 2, 4, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-low-latency-playback.m4 b/topology/sof/pipe-low-latency-playback.m4 index 8cfe5e418769..c316bf4940f7 100644 --- a/topology/sof/pipe-low-latency-playback.m4 +++ b/topology/sof/pipe-low-latency-playback.m4 @@ -115,5 +115,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Low Latency Playback PCM_I # PCM capabilities supported by FW -PCM_CAPABILITIES(Low Latency Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 2, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Low Latency Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index 4614083111ee..5eb29a23597e 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -44,4 +44,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID # PCM Configuration # -PCM_CAPABILITIES(Passthrough Capture PCM_ID, COMP_FORMAT_NAME(PIPELINE_FORMAT), 8000, 192000, 1, 16, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Capture PCM_ID, COMP_FORMAT_NAME(PIPELINE_FORMAT), 8000, 192000, 1, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-passthrough-playback.m4 b/topology/sof/pipe-passthrough-playback.m4 index c7c12371c274..b0ee4632bb7b 100644 --- a/topology/sof/pipe-passthrough-playback.m4 +++ b/topology/sof/pipe-passthrough-playback.m4 @@ -44,4 +44,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # PCM Configuration # -PCM_CAPABILITIES(Passthrough Playback PCM_ID, COMP_FORMAT_NAME(PIPELINE_FORMAT), 48000, 48000, 2, 4, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Playback PCM_ID, COMP_FORMAT_NAME(PIPELINE_FORMAT), 48000, 48000, 2, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-pcm-media.m4 b/topology/sof/pipe-pcm-media.m4 index b526e435a91e..ae2090db41ed 100644 --- a/topology/sof/pipe-pcm-media.m4 +++ b/topology/sof/pipe-pcm-media.m4 @@ -95,7 +95,7 @@ W_PIPELINE(N_SRC(0), SCHEDULE_DEADLINE, SCHEDULE_PRIORITY, SCHEDULE_FRAMES, SCHE # PCM capabilities supported by FW -PCM_CAPABILITIES(Media Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 8000, 192000, 2, 2, 2, 32, 192, 262144, 8388608, 8388608) +PCM_CAPABILITIES(Media Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 8000, 192000, 2, PIPELINE_CHANNELS, 2, 32, 192, 262144, 8388608, 8388608) # PCM Low Latency Playback and Capture SectionPCM.STR(Media Playback PCM_ID) { diff --git a/topology/sof/pipe-src-capture.m4 b/topology/sof/pipe-src-capture.m4 index e0a68e4613b5..e151bf0dd0bc 100644 --- a/topology/sof/pipe-src-capture.m4 +++ b/topology/sof/pipe-src-capture.m4 @@ -61,4 +61,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID # PCM Configuration # -PCM_CAPABILITIES(Passthrough Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 8000, 96000, 2, 4, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 8000, 96000, 2, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-src-playback.m4 b/topology/sof/pipe-src-playback.m4 index ce05b9449670..8003b50288ed 100644 --- a/topology/sof/pipe-src-playback.m4 +++ b/topology/sof/pipe-src-playback.m4 @@ -61,5 +61,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # PCM Configuration # -PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 8000, 192000, 2, 8, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 8000, 192000, 2, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-volume-capture.m4 b/topology/sof/pipe-volume-capture.m4 index 820b745c7fc5..a044ed6524f8 100644 --- a/topology/sof/pipe-volume-capture.m4 +++ b/topology/sof/pipe-volume-capture.m4 @@ -66,5 +66,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID # PCM Configuration # -PCM_CAPABILITIES(Passthrough Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Capture PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-volume-playback.m4 b/topology/sof/pipe-volume-playback.m4 index 4ebd02da5721..e373adc320d4 100644 --- a/topology/sof/pipe-volume-playback.m4 +++ b/topology/sof/pipe-volume-playback.m4 @@ -67,5 +67,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # PCM Configuration # -PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) From baa791f6e10b96ec2f31d3ec39a10ecba31c35ef Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 6 Sep 2018 13:00:17 +0300 Subject: [PATCH 248/324] Topology: Add Equalizer This patch adds EQ, bytecontrol, and EQ+volume pipeline m4 macros and an enhanced topology with EQ for UP2 + HiFiberry. There is not yet FIR/IIR type select. The EQ type is currently hardcoded into kernel. Signed-off-by: Seppo Ingalsuo Signed-off-by: Ranjani Sridharan Signed-off-by: Jaska Uimonen --- topology/Makefile.am | 6 +- topology/m4/bytecontrol.m4 | 54 ++++++++++++ topology/m4/eq.m4 | 43 ++++++++++ topology/sof-apl-eq-pcm512x.m4 | 55 ++++++++++++ topology/sof/pipe-eq-volume-playback.m4 | 88 ++++++++++++++++++++ topology/test/test-equalizer-playback-ssp.m4 | 74 ++++++++++++++++ 6 files changed, 318 insertions(+), 2 deletions(-) create mode 100644 topology/m4/bytecontrol.m4 create mode 100644 topology/m4/eq.m4 create mode 100644 topology/sof-apl-eq-pcm512x.m4 create mode 100644 topology/sof/pipe-eq-volume-playback.m4 create mode 100644 topology/test/test-equalizer-playback-ssp.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 207e5207136d..3e466df665cc 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -35,7 +35,8 @@ MACHINES = \ sof-apl-wm8804.tplg \ sof-apl-da7219.tplg \ sof-glk-da7219.tplg \ - sof-icl-nocodec.tplg + sof-icl-nocodec.tplg \ + sof-apl-eq-pcm512x.tplg # Uncomment the following line if you want to debug conf files .PRECIOUS: %.conf @@ -71,4 +72,5 @@ EXTRA_DIST = \ sof-apl-wm8804.m4 \ sof-apl-da7219.m4 \ sof-glk-da7219.m4 \ - sof-icl-nocodec.m4 + sof-icl-nocodec.m4 \ + sof-apl-eq-pcm512x.m4 diff --git a/topology/m4/bytecontrol.m4 b/topology/m4/bytecontrol.m4 new file mode 100644 index 000000000000..d36b93fdc6e8 --- /dev/null +++ b/topology/m4/bytecontrol.m4 @@ -0,0 +1,54 @@ +divert(-1) + +dnl Define macro for byte control + +dnl CONTROLBYTES_MAX(comment, value) +define(`CONTROLBYTES_MAX', +`#$1' +` max STR($2)') + +dnl CONTROLMIXER_TLV(comment, value) +define(`CONTROLBYTES_TLV', +`#$1' +` tlv STR($2)') + +dnl CONTROLMIXER_OPS(info, comment, get, put) +define(`CONTROLBYTES_OPS', +`ops."ctl" {' +` info STR($1)' +` #$2' +` }') + +dnl CONTROLMIXER_OPS(info, comment, get, put) +define(`CONTROLBYTES_EXTOPS', +`extops."extctl" {' +` #$1' +` get STR($2)' +` put STR($3)' +` }') + +dnl C_CONTROLMIXER(name, index, ops, base, num_regs, mask, max, tlv) +define(`C_CONTROLBYTES', +`SectionControlBytes.STR($1) {' +`' +` # control belongs to this index group' +` index STR($2)' +`' +` # control uses bespoke driver get/put/info ID for io ops' +` $3' +` # control uses bespoke driver get/put/info ID for ext ops' +` $4' +`' +` base STR($5)' +` num_regs STR($6)' +` mask STR($7)' +` $8' +` $9' +` access [' +` tlv_write' +` tlv_read' +` tlv_callback' +` ]' +`}') + +divert(0)dnl diff --git a/topology/m4/eq.m4 b/topology/m4/eq.m4 new file mode 100644 index 000000000000..d9efee3c2fd1 --- /dev/null +++ b/topology/m4/eq.m4 @@ -0,0 +1,43 @@ +divert(-1) + +dnl Define macro for Eq effect widget + +dnl EQ name) +define(`N_EQ', `EQ'PIPELINE_ID`.'$1) + +dnl W_EQ(name, format, periods_sink, periods_source, preload, kcontrols_list) +define(`W_EQ', +`SectionVendorTuples."'N_EQ($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_EQ($1)`_data_w" {' +` tuples "'N_EQ($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_EQ($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_EQ($1)`_data_str" {' +` tuples "'N_EQ($1)`_tuples_str"' +`}' +`SectionWidget."'N_EQ($1)`" {' +` index "'PIPELINE_ID`"' +` type "effect"' +` no_pm "true"' +` data [' +` "'N_EQ($1)`_data_w"' +` "'N_EQ($1)`_data_str"' +` ]' +` bytes [' + $6 +` ]' +`}') + +divert(0)dnl diff --git a/topology/sof-apl-eq-pcm512x.m4 b/topology/sof-apl-eq-pcm512x.m4 new file mode 100644 index 000000000000..f1fda8de9b7c --- /dev/null +++ b/topology/sof-apl-eq-pcm512x.m4 @@ -0,0 +1,55 @@ +# +# Topology for generic Apollolake UP^2 with pcm512x codec. +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') +include(`ssp.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`platform/intel/bxt.m4') + +# +# Define the pipelines +# +# PCM0 ----> volume -----> SSP5 (pcm512x) +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-eq-volume-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0) + +# +# DAIs configuration +# + +# playback DAI is SSP5 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 5, SSP5-Codec, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) + +# PCM Low Latency, id 0 +PCM_PLAYBACK_ADD(Port5, 0, PIPELINE_PCM_1) + +# +# BE configurations - overrides config in ACPI if present +# + +DAI_CONFIG(SSP, 5, 0, SSP5-Codec, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 3072000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 32, 3, 3), + SSP_CONFIG_DATA(SSP, 5, 24))) diff --git a/topology/sof/pipe-eq-volume-playback.m4 b/topology/sof/pipe-eq-volume-playback.m4 new file mode 100644 index 000000000000..4b7cb321be02 --- /dev/null +++ b/topology/sof/pipe-eq-volume-playback.m4 @@ -0,0 +1,88 @@ +# Low Latency Passthrough with volume Pipeline and PCM +# +# Pipeline Endpoints for connection are :- +# +# host PCM_P --> B0 --> EQ 0 --> B1 --> Volume 0 --> B2 --> sink DAI0 + +# Include topology builder +include(`utils.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`pga.m4') +include(`dai.m4') +include(`mixercontrol.m4') +include(`bytecontrol.m4') +include(`pipeline.m4') +include(`eq.m4') + +# +# Controls +# +# Volume Mixer control with max value of 32 +C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(, 32), + false, + CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3), + Channel register and shift for Front Left/Right, + LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) + +# EQ Bytes control with max value of 255 +C_CONTROLBYTES(EQ, PIPELINE_ID, + CONTROLBYTES_OPS(bytes, 258 binds the mixer control to bytes get/put handlers, 258, 258), + CONTROLBYTES_EXTOPS(258 binds the mixer control to bytes get/put handlers, 258, 258), + , , , + CONTROLBYTES_MAX(, 10)) + +# +# Components and Buffers +# + +# Host "Passthrough Playback" PCM +# with 2 sink and 0 source periods +W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 2, 0, 2) + +# "Volume" has 2 source and 2 sink periods +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume PIPELINE_ID")) + +# "EQ 0" has 2 sink period and 2 source periods +W_EQ(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "EQ")) + +# Playback Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) +W_BUFFER(1, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) +W_BUFFER(2, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_DAI_MEM_CAP) + +# +# Pipeline Graph +# +# host PCM_P --> B0 --> EQ 0 --> B1 --> Volume 0 --> B2 --> sink DAI0 + +P_GRAPH(pipe-pass-vol-playback-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(N_PCMP(PCM_ID), Passthrough Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP(PCM_ID))', + `dapm(N_EQ(0), N_BUFFER(0))', + `dapm(N_BUFFER(1), N_EQ(0))', + `dapm(N_PGA(0), N_BUFFER(1))', + `dapm(N_BUFFER(2), N_PGA(0))')) + +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(2)) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_ID) + + +# +# PCM Configuration + +# +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536) + diff --git a/topology/test/test-equalizer-playback-ssp.m4 b/topology/test/test-equalizer-playback-ssp.m4 new file mode 100644 index 000000000000..ab775a451ed2 --- /dev/null +++ b/topology/test/test-equalizer-playback-ssp.m4 @@ -0,0 +1,74 @@ +# +# Topology for pass through pipeline +# + +# Include topology builder +include(`pipeline.m4') +include(`dai.m4') +include(`utils.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Baytrail DSP configuration +include(`dsps/byt.m4') + +# +# Machine Specific Config - !! MUST BE SET TO MATCH TEST MACHINE DRIVER !! +# +# TEST_PIPE_NAME - Pipe name +# TEST_DAI_LINK_NAME - BE DAI link name e.g. "NoCodec" +# TEST_SSP_PORT - SSP port number e.g. 2 +# TEST_SSP_FORMAT - SSP data format e.g s16le +# TEST_PIPE_FORMAT - Pipeline format e.g. s16le +# TEST_SSP_MCLK - SSP MCLK in Hz +# TEST_SSP_BCLK - SSP BCLK in Hz +# TEST_SSP_PHY_BITS - SSP physical slot size +# TEST_SSP_DATA_BITS - SSP data slot size +# + +# +# Define the pipeline +# +# PCM0 <---> SSP TEST_SSP_PORT +# + +# Passthrough playback pipeline 1 on PCM 0 using max 2 channels of s24le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +# Use DMAC 0 channel 1 for PCM audio playback data + +PIPELINE_PCM_DAI_ADD(sof/pipe-TEST_PIPE_NAME-playback.m4, + 1, 0, 2, TEST_PIPE_FORMAT, + 48, 1000, 0, 0, 0, 1, + SSP, TEST_SSP_PORT, TEST_SSP_FORMAT, 2) +# +# DAI configuration +# +# SSP port TEST_SSP_PORT is our only pipeline DAI +# + +# playback DAI is SSP TEST_SSP_PORT using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, + PIPELINE_SOURCE_1, 2, TEST_SSP_FORMAT, + 48, 1000, 0, 0) + +# PCM Passthrough +PCM_PLAYBACK_ADD(Passthrough, 3, 0, 0, PIPELINE_PCM_1) + +# +# BE configurations - overrides config in ACPI if present +# +# Clocks masters wrt codec +# +# TEST_SSP_DATA_BITS bit I2S using TEST_SSP_PHY_BITS bit sample conatiner on SSP TEST_SSP_PORT +# +DAI_CONFIG(SSP, TEST_SSP_PORT, TEST_DAI_LINK_NAME, I2S, TEST_SSP_DATA_BITS, + DAI_CLOCK(mclk, TEST_SSP_MCLK, slave), + DAI_CLOCK(bclk, TEST_SSP_BCLK, slave), + DAI_CLOCK(fsync, 48000, slave), + DAI_TDM(2, TEST_SSP_PHY_BITS, 3, 3)) From 6b56dafe305b1f2725084ca3a81db114230af336 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Sun, 9 Sep 2018 19:22:42 +0300 Subject: [PATCH 249/324] Topology: Add generic type string to effect widgets data field Adding type string to widget data allows the driver to identify different effects. As an example use this in the equalizer. Also modify equalizer to pass default parameters in control's private data. Signed-off-by: Jaska Uimonen --- topology/m4/bytecontrol.m4 | 10 +- topology/m4/eq.m4 | 43 --------- topology/m4/eq_fir.m4 | 53 ++++++++++ topology/m4/eq_iir.m4 | 53 ++++++++++ topology/sof/pipe-eq-fir-volume-playback.m4 | 97 +++++++++++++++++++ topology/sof/pipe-eq-iir-volume-playback.m4 | 101 ++++++++++++++++++++ topology/sof/pipe-eq-volume-playback.m4 | 61 +++++++++--- topology/sof/tokens.m4 | 4 + 8 files changed, 366 insertions(+), 56 deletions(-) delete mode 100644 topology/m4/eq.m4 create mode 100644 topology/m4/eq_fir.m4 create mode 100644 topology/m4/eq_iir.m4 create mode 100644 topology/sof/pipe-eq-fir-volume-playback.m4 create mode 100644 topology/sof/pipe-eq-iir-volume-playback.m4 diff --git a/topology/m4/bytecontrol.m4 b/topology/m4/bytecontrol.m4 index d36b93fdc6e8..22a7b6f31c5d 100644 --- a/topology/m4/bytecontrol.m4 +++ b/topology/m4/bytecontrol.m4 @@ -27,7 +27,12 @@ define(`CONTROLBYTES_EXTOPS', ` put STR($3)' ` }') -dnl C_CONTROLMIXER(name, index, ops, base, num_regs, mask, max, tlv) +define(`CONTROLBYTES_PRIV', +`SectionData.STR($1) {' +` $2' +`}') + +dnl C_CONTROLMIXER(name, index, ops, base, num_regs, mask, max, tlv, priv) define(`C_CONTROLBYTES', `SectionControlBytes.STR($1) {' `' @@ -49,6 +54,9 @@ define(`C_CONTROLBYTES', ` tlv_read' ` tlv_callback' ` ]' +` data [' +` $10' +` ]' `}') divert(0)dnl diff --git a/topology/m4/eq.m4 b/topology/m4/eq.m4 deleted file mode 100644 index d9efee3c2fd1..000000000000 --- a/topology/m4/eq.m4 +++ /dev/null @@ -1,43 +0,0 @@ -divert(-1) - -dnl Define macro for Eq effect widget - -dnl EQ name) -define(`N_EQ', `EQ'PIPELINE_ID`.'$1) - -dnl W_EQ(name, format, periods_sink, periods_source, preload, kcontrols_list) -define(`W_EQ', -`SectionVendorTuples."'N_EQ($1)`_tuples_w" {' -` tokens "sof_comp_tokens"' -` tuples."word" {' -` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) -` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) -` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) -` }' -`}' -`SectionData."'N_EQ($1)`_data_w" {' -` tuples "'N_EQ($1)`_tuples_w"' -`}' -`SectionVendorTuples."'N_EQ($1)`_tuples_str" {' -` tokens "sof_comp_tokens"' -` tuples."string" {' -` SOF_TKN_COMP_FORMAT' STR($2) -` }' -`}' -`SectionData."'N_EQ($1)`_data_str" {' -` tuples "'N_EQ($1)`_tuples_str"' -`}' -`SectionWidget."'N_EQ($1)`" {' -` index "'PIPELINE_ID`"' -` type "effect"' -` no_pm "true"' -` data [' -` "'N_EQ($1)`_data_w"' -` "'N_EQ($1)`_data_str"' -` ]' -` bytes [' - $6 -` ]' -`}') - -divert(0)dnl diff --git a/topology/m4/eq_fir.m4 b/topology/m4/eq_fir.m4 new file mode 100644 index 000000000000..75d1d9f7d089 --- /dev/null +++ b/topology/m4/eq_fir.m4 @@ -0,0 +1,53 @@ +divert(-1) + +dnl Define macro for Eq effect widget + +dnl EQ name) +define(`N_EQ_FIR', `EQFIR'PIPELINE_ID`.'$1) + +dnl W_EQ(name, format, periods_sink, periods_source, preload, kcontrols_list) +define(`W_EQ_FIR', +`SectionVendorTuples."'N_EQ_FIR($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_EQ_FIR($1)`_data_w" {' +` tuples "'N_EQ_FIR($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_EQ_FIR($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_EQ_FIR($1)`_data_str" {' +` tuples "'N_EQ_FIR($1)`_tuples_str"' +`}' +`SectionVendorTuples."'N_EQ_FIR($1)`_tuples_str_type" {' +` tokens "sof_effect_tokens"' +` tuples."string" {' +` SOF_TKN_EFFECT_TYPE' "EQFIR" +` }' +`}' +`SectionData."'N_EQ_FIR($1)`_data_str_type" {' +` tuples "'N_EQ_FIR($1)`_tuples_str_type"' +`}' +`SectionWidget."'N_EQ_FIR($1)`" {' +` index "'PIPELINE_ID`"' +` type "effect"' +` no_pm "true"' +` data [' +` "'N_EQ_FIR($1)`_data_w"' +` "'N_EQ_FIR($1)`_data_str"' +` "'N_EQ_FIR($1)`_data_str_type"' +` ]' +` bytes [' + $6 +` ]' +`}') + +divert(0)dnl diff --git a/topology/m4/eq_iir.m4 b/topology/m4/eq_iir.m4 new file mode 100644 index 000000000000..1f6466bd9b6f --- /dev/null +++ b/topology/m4/eq_iir.m4 @@ -0,0 +1,53 @@ +divert(-1) + +dnl Define macro for Eq effect widget + +dnl EQ name) +define(`N_EQ_IIR', `EQIIR'PIPELINE_ID`.'$1) + +dnl W_EQ(name, format, periods_sink, periods_source, preload, kcontrols_list) +define(`W_EQ_IIR', +`SectionVendorTuples."'N_EQ_IIR($1)`_tuples_w" {' +` tokens "sof_comp_tokens"' +` tuples."word" {' +` SOF_TKN_COMP_PERIOD_SINK_COUNT' STR($3) +` SOF_TKN_COMP_PERIOD_SOURCE_COUNT' STR($4) +` SOF_TKN_COMP_PRELOAD_COUNT' STR($5) +` }' +`}' +`SectionData."'N_EQ_IIR($1)`_data_w" {' +` tuples "'N_EQ_IIR($1)`_tuples_w"' +`}' +`SectionVendorTuples."'N_EQ_IIR($1)`_tuples_str" {' +` tokens "sof_comp_tokens"' +` tuples."string" {' +` SOF_TKN_COMP_FORMAT' STR($2) +` }' +`}' +`SectionData."'N_EQ_IIR($1)`_data_str" {' +` tuples "'N_EQ_IIR($1)`_tuples_str"' +`}' +`SectionVendorTuples."'N_EQ_IIR($1)`_tuples_str_type" {' +` tokens "sof_effect_tokens"' +` tuples."string" {' +` SOF_TKN_EFFECT_TYPE' "EQIIR" +` }' +`}' +`SectionData."'N_EQ_IIR($1)`_data_str_type" {' +` tuples "'N_EQ_IIR($1)`_tuples_str_type"' +`}' +`SectionWidget."'N_EQ_IIR($1)`" {' +` index "'PIPELINE_ID`"' +` type "effect"' +` no_pm "true"' +` data [' +` "'N_EQ_IIR($1)`_data_w"' +` "'N_EQ_IIR($1)`_data_str"' +` "'N_EQ_IIR($1)`_data_str_type"' +` ]' +` bytes [' + $6 +` ]' +`}') + +divert(0)dnl diff --git a/topology/sof/pipe-eq-fir-volume-playback.m4 b/topology/sof/pipe-eq-fir-volume-playback.m4 new file mode 100644 index 000000000000..da66d6c0598b --- /dev/null +++ b/topology/sof/pipe-eq-fir-volume-playback.m4 @@ -0,0 +1,97 @@ +# Low Latency Passthrough with volume Pipeline and PCM +# +# Pipeline Endpoints for connection are :- +# +# host PCM_P --> B0 --> EQ 0 --> B1 --> Volume 0 --> B2 --> sink DAI0 + +# Include topology builder +include(`utils.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`pga.m4') +include(`dai.m4') +include(`mixercontrol.m4') +include(`bytecontrol.m4') +include(`pipeline.m4') +include(`eq_fir.m4') + +# +# Controls +# +# Volume Mixer control with max value of 32 +C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(, 32), + false, + CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3), + Channel register and shift for Front Left/Right, + LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) + +# EQ initial parameters, in this case flat response +CONTROLBYTES_PRIV(EQFIR_priv, +` bytes "0x18,0x00,0x00,0x00,0x02,0x00,0x01,0x00,' +` 0x00,0x00,0x00,0x00,0x04,0x00,0xff,0xff,' +` 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00"' +) + +# EQ Bytes control with max value of 255 +C_CONTROLBYTES(EQFIR, PIPELINE_ID, + CONTROLBYTES_OPS(bytes, 258 binds the mixer control to bytes get/put handlers, 258, 258), + CONTROLBYTES_EXTOPS(258 binds the mixer control to bytes get/put handlers, 258, 258), + , , , + CONTROLBYTES_MAX(, 316), + , + EQFIR_priv) + +# +# Components and Buffers +# + +# Host "Passthrough Playback" PCM +# with 2 sink and 0 source periods +W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 2, 0, 2) + +# "Volume" has 2 source and 2 sink periods +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume PIPELINE_ID")) + +# "EQ 0" has 2 sink period and 2 source periods +W_EQ_FIR(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "EQFIR")) + +# Playback Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) +W_BUFFER(1, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) +W_BUFFER(2, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_DAI_MEM_CAP) + +# +# Pipeline Graph +# +# host PCM_P --> B0 --> EQ 0 --> B1 --> Volume 0 --> B2 --> sink DAI0 + +P_GRAPH(pipe-pass-vol-playback-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(N_PCMP(PCM_ID), Passthrough Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP(PCM_ID))', + `dapm(N_EQ_FIR(0), N_BUFFER(0))', + `dapm(N_BUFFER(1), N_EQ_FIR(0))', + `dapm(N_PGA(0), N_BUFFER(1))', + `dapm(N_BUFFER(2), N_PGA(0))')) + +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(2)) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_ID) + + +# +# PCM Configuration + +# +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536) + diff --git a/topology/sof/pipe-eq-iir-volume-playback.m4 b/topology/sof/pipe-eq-iir-volume-playback.m4 new file mode 100644 index 000000000000..3b93f3cdb689 --- /dev/null +++ b/topology/sof/pipe-eq-iir-volume-playback.m4 @@ -0,0 +1,101 @@ +# Low Latency Passthrough with volume Pipeline and PCM +# +# Pipeline Endpoints for connection are :- +# +# host PCM_P --> B0 --> EQ 0 --> B1 --> Volume 0 --> B2 --> sink DAI0 + +# Include topology builder +include(`utils.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`pga.m4') +include(`dai.m4') +include(`mixercontrol.m4') +include(`bytecontrol.m4') +include(`pipeline.m4') +include(`eq_iir.m4') + +# +# Controls +# +# Volume Mixer control with max value of 32 +C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, + CONTROLMIXER_OPS(volsw, 256 binds the mixer control to volume get/put handlers, 256, 256), + CONTROLMIXER_MAX(, 32), + false, + CONTROLMIXER_TLV(TLV 32 steps from -90dB to +6dB for 3dB, vtlv_m90s3), + Channel register and shift for Front Left/Right, + LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) + +# EQ initial parameters, in this case flat response +CONTROLBYTES_PRIV(EQIIR_priv, +` bytes "0x38,0x00,0x00,0x00,0x02,0x00,0x00,0x00,' +` 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,' +` 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x9e,0x73,0x13,0x20,' +` 0x00,0x00,0x00,0x00,0xb2,0x7f,0x00,0x00"' +) + +# EQ Bytes control with max value of 255 +C_CONTROLBYTES(EQIIR, PIPELINE_ID, + CONTROLBYTES_OPS(bytes, 258 binds the mixer control to bytes get/put handlers, 258, 258), + CONTROLBYTES_EXTOPS(258 binds the mixer control to bytes get/put handlers, 258, 258), + , , , + CONTROLBYTES_MAX(, 316), + , + EQIIR_priv) + +# +# Components and Buffers +# + +# Host "Passthrough Playback" PCM +# with 2 sink and 0 source periods +W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 2, 0, 2) + +# "Volume" has 2 source and 2 sink periods +W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume PIPELINE_ID")) + +# "EQ 0" has 2 sink period and 2 source periods +W_EQ_IIR(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "EQIIR")) + +# Playback Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) +W_BUFFER(1, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) +W_BUFFER(2, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_DAI_MEM_CAP) + +# +# Pipeline Graph +# +# host PCM_P --> B0 --> EQ 0 --> B1 --> Volume 0 --> B2 --> sink DAI0 + +P_GRAPH(pipe-pass-vol-playback-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(N_PCMP(PCM_ID), Passthrough Playback PCM_ID)', + `dapm(N_BUFFER(0), N_PCMP(PCM_ID))', + `dapm(N_EQ_IIR(0), N_BUFFER(0))', + `dapm(N_BUFFER(1), N_EQ_IIR(0))', + `dapm(N_PGA(0), N_BUFFER(1))', + `dapm(N_BUFFER(2), N_PGA(0))')) + +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(2)) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_ID) + + +# +# PCM Configuration + +# +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536) + diff --git a/topology/sof/pipe-eq-volume-playback.m4 b/topology/sof/pipe-eq-volume-playback.m4 index 4b7cb321be02..c3ca5b7fd3d5 100644 --- a/topology/sof/pipe-eq-volume-playback.m4 +++ b/topology/sof/pipe-eq-volume-playback.m4 @@ -2,7 +2,7 @@ # # Pipeline Endpoints for connection are :- # -# host PCM_P --> B0 --> EQ 0 --> B1 --> Volume 0 --> B2 --> sink DAI0 +# host PCM_P --> B0 --> EQ_IIR 0 --> B1 --> EQ_FIR 0 --> B2 --> Volume 0 --> B3 --> sink DAI0 # Include topology builder include(`utils.m4') @@ -13,7 +13,8 @@ include(`dai.m4') include(`mixercontrol.m4') include(`bytecontrol.m4') include(`pipeline.m4') -include(`eq.m4') +include(`eq_iir.m4') +include(`eq_fir.m4') # # Controls @@ -27,12 +28,41 @@ C_CONTROLMIXER(Master Playback Volume, PIPELINE_ID, Channel register and shift for Front Left/Right, LIST(` ', KCONTROL_CHANNEL(FL, 1, 0), KCONTROL_CHANNEL(FR, 1, 1))) +# EQ initial parameters, in this case flat response +CONTROLBYTES_PRIV(EQIIR_priv, +` bytes "0x38,0x00,0x00,0x00,0x02,0x00,0x00,0x00,' +` 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,' +` 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x9e,0x73,0x13,0x20,' +` 0x00,0x00,0x00,0x00,0xb2,0x7f,0x00,0x00"' +) + +# EQ Bytes control with max value of 255 +C_CONTROLBYTES(EQIIR, PIPELINE_ID, + CONTROLBYTES_OPS(bytes, 258 binds the mixer control to bytes get/put handlers, 258, 258), + CONTROLBYTES_EXTOPS(258 binds the mixer control to bytes get/put handlers, 258, 258), + , , , + CONTROLBYTES_MAX(, 316), + , + EQIIR_priv) + +# EQ initial parameters, in this case flat response +CONTROLBYTES_PRIV(EQFIR_priv, +` bytes "0x18,0x00,0x00,0x00,0x02,0x00,0x01,0x00,' +` 0x00,0x00,0x00,0x00,0x04,0x00,0xff,0xff,' +` 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00"' +) + # EQ Bytes control with max value of 255 -C_CONTROLBYTES(EQ, PIPELINE_ID, +C_CONTROLBYTES(EQFIR, PIPELINE_ID, CONTROLBYTES_OPS(bytes, 258 binds the mixer control to bytes get/put handlers, 258, 258), CONTROLBYTES_EXTOPS(258 binds the mixer control to bytes get/put handlers, 258, 258), , , , - CONTROLBYTES_MAX(, 10)) + CONTROLBYTES_MAX(, 316), + , + EQFIR_priv) # # Components and Buffers @@ -46,7 +76,10 @@ W_PCM_PLAYBACK(PCM_ID, Passthrough Playback, 2, 0, 2) W_PGA(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "Master Playback Volume PIPELINE_ID")) # "EQ 0" has 2 sink period and 2 source periods -W_EQ(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "EQ")) +W_EQ_IIR(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "EQIIR")) + +# "EQ 0" has 2 sink period and 2 source periods +W_EQ_FIR(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "EQFIR")) # Playback Buffers W_BUFFER(0, COMP_BUFFER_SIZE(2, @@ -56,30 +89,34 @@ W_BUFFER(1, COMP_BUFFER_SIZE(2, COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), PLATFORM_HOST_MEM_CAP) W_BUFFER(2, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_HOST_MEM_CAP) +W_BUFFER(3, COMP_BUFFER_SIZE(2, COMP_SAMPLE_SIZE(DAI_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), PLATFORM_DAI_MEM_CAP) # # Pipeline Graph # -# host PCM_P --> B0 --> EQ 0 --> B1 --> Volume 0 --> B2 --> sink DAI0 +# host host PCM_P --> B0 --> EQ_IIR 0 --> B1 --> EQ_FIR 0 --> B2 --> Volume 0 --> B3 --> sink DAI0 P_GRAPH(pipe-pass-vol-playback-PIPELINE_ID, PIPELINE_ID, LIST(` ', `dapm(N_PCMP(PCM_ID), Passthrough Playback PCM_ID)', `dapm(N_BUFFER(0), N_PCMP(PCM_ID))', - `dapm(N_EQ(0), N_BUFFER(0))', - `dapm(N_BUFFER(1), N_EQ(0))', - `dapm(N_PGA(0), N_BUFFER(1))', - `dapm(N_BUFFER(2), N_PGA(0))')) + `dapm(N_EQ_IIR(0), N_BUFFER(0))', + `dapm(N_BUFFER(1), N_EQ_IIR(0))', + `dapm(N_EQ_FIR(0), N_BUFFER(1))', + `dapm(N_BUFFER(2), N_EQ_FIR(0))', + `dapm(N_PGA(0), N_BUFFER(2))', + `dapm(N_BUFFER(3), N_PGA(0))')) # # Pipeline Source and Sinks # -indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(2)) +indir(`define', concat(`PIPELINE_SOURCE_', PIPELINE_ID), N_BUFFER(3)) indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_ID) - # # PCM Configuration diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index 4aa2fea8f37f..b584f56e1dec 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -82,3 +82,7 @@ SectionVendorTokens."sof_dmic_pdm_tokens" { SectionVendorTokens."sof_tone_tokens" { SOF_TKN_TONE_SAMPLE_RATE "800" } + +SectionVendorTokens."sof_effect_tokens" { + SOF_TKN_EFFECT_TYPE "900" +} From 110378d61c565259026302765cd41bb35fedcec8 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Wed, 26 Sep 2018 17:02:42 +0800 Subject: [PATCH 250/324] topology: sof-glk-da7219: update to use s32le format for HDMI pipelines Signed-off-by: Keyon Jie --- topology/sof-glk-da7219.m4 | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/topology/sof-glk-da7219.m4 b/topology/sof-glk-da7219.m4 index a2ac09fcd766..85f4a7e3c764 100644 --- a/topology/sof-glk-da7219.m4 +++ b/topology/sof-glk-da7219.m4 @@ -55,25 +55,25 @@ PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, 4, 99, 4, s32le, 48, 1000, 0, 0) -# Low Latency playback pipeline 5 on PCM 5 using max 2 channels of s16le. +# Low Latency playback pipeline 5 on PCM 5 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4, PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, - 5, 5, 2, s16le, + 5, 5, 2, s32le, 48, 1000, 0, 0) -# Low Latency playback pipeline 6 on PCM 6 using max 2 channels of s16le. +# Low Latency playback pipeline 6 on PCM 6 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4, PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, - 6, 6, 2, s16le, + 6, 6, 2, s32le, 48, 1000, 0, 0) -# Low Latency playback pipeline 7 on PCM 7 using max 2 channels of s16le. +# Low Latency playback pipeline 7 on PCM 7 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 # PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4, PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, - 7, 7, 2, s16le, + 7, 7, 2, s32le, 48, 1000, 0, 0) # @@ -102,31 +102,31 @@ DAI_ADD(sof/pipe-dai-capture.m4, 48, 1000, 0, 0) # capture DAI is DMIC0 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-capture.m4, 4, DMIC, 0, dmic01, PIPELINE_SINK_4, 2, s32le, 48, 1000, 0, 0) # playback DAI is iDisp1 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, 5, HDA, 3, iDisp1, - PIPELINE_SOURCE_5, 2, s16le, + PIPELINE_SOURCE_5, 2, s32le, 48, 1000, 0, 0) # playback DAI is iDisp2 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, 6, HDA, 4, iDisp2, - PIPELINE_SOURCE_6, 2, s16le, + PIPELINE_SOURCE_6, 2, s32le, 48, 1000, 0, 0) # playback DAI is iDisp3 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, 7, HDA, 5, iDisp3, - PIPELINE_SOURCE_7, 2, s16le, + PIPELINE_SOURCE_7, 2, s32le, 48, 1000, 0, 0) PCM_PLAYBACK_ADD(Speakers, 0, PIPELINE_PCM_1) From 41184b076ff9e72654f130c61dff3b683a3606cb Mon Sep 17 00:00:00 2001 From: Bard liao Date: Thu, 27 Sep 2018 09:02:47 +0800 Subject: [PATCH 251/324] topology: initial topology file for APL RVP It is basically copy from sof-apl-pcm512x.m4 and add hdmi support Signed-off-by: Bard liao --- topology/Makefile.am | 2 + topology/sof-apl-rt298.m4 | 106 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 topology/sof-apl-rt298.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 4da69e4c0c8e..f136b0c47d01 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -31,6 +31,7 @@ MACHINES = \ sof-hsw-rt5640.tplg \ sof-apl-tdf8532.tplg \ sof-apl-pcm512x.tplg \ + sof-apl-rt298.tplg \ sof-apl-wm8804.tplg \ sof-apl-da7219.tplg \ sof-glk-da7219.tplg \ @@ -66,6 +67,7 @@ EXTRA_DIST = \ sof-hsw-rt5640.m4 \ sof-apl-tdf8532.m4 \ sof-apl-pcm512x.m4 \ + sof-apl-rt298.m4 \ sof-apl-wm8804.m4 \ sof-apl-da7219.m4 \ sof-glk-da7219.m4 \ diff --git a/topology/sof-apl-rt298.m4 b/topology/sof-apl-rt298.m4 new file mode 100644 index 000000000000..e6dbec8137c5 --- /dev/null +++ b/topology/sof-apl-rt298.m4 @@ -0,0 +1,106 @@ +# +# Topology for generic Apollolake UP^2 with pcm512x codec. +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') +include(`ssp.m4') +include(`hda.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`platform/intel/bxt.m4') + +# +# Define the pipelines +# +# PCM0 ----> volume -----> SSP5 (rt298) +# PCM5 ----> volume (pipe 5) -----> iDisp1 (HDMI/DP playback, BE link 3) +# PCM6 ----> Volume (pipe 6) -----> iDisp2 (HDMI/DP playback, BE link 4) +# PCM7 ----> volume (pipe 7) -----> iDisp3 (HDMI/DP playback, BE link 5) +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 5 on PCM 5 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 5, 5, 2, s16le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 6 on PCM 6 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 6, 6, 2, s16le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 7 on PCM 7 using max 2 channels of s16le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 7, 7, 2, s16le, + 48, 1000, 0, 0) +# +# DAIs configuration +# + +# playback DAI is SSP5 using 2 periods +# Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, SSP, 5, SSP5-Codec, + PIPELINE_SOURCE_1, 2, s24le, + 48, 1000, 0, 0) + +# playback DAI is iDisp1 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 5, HDA, 3, iDisp1, + PIPELINE_SOURCE_5, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is iDisp2 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 6, HDA, 4, iDisp2, + PIPELINE_SOURCE_6, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is iDisp3 using 2 periods +# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 7, HDA, 5, iDisp3, + PIPELINE_SOURCE_7, 2, s32le, + 48, 1000, 0, 0) + +# PCM Low Latency, id 0 +PCM_PLAYBACK_ADD(Port5, 0, PIPELINE_PCM_1) +PCM_PLAYBACK_ADD(HDMI1, 5, PIPELINE_PCM_5) +PCM_PLAYBACK_ADD(HDMI2, 6, PIPELINE_PCM_6) +PCM_PLAYBACK_ADD(HDMI3, 7, PIPELINE_PCM_7) + +# +# BE configurations - overrides config in ACPI if present +# +# +# 3 HDMI/DP outputs (ID: 3,4,5) +DAI_CONFIG(SSP, 5, 0, SSP5-Codec, + SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), + SSP_CLOCK(bclk, 3072000, codec_slave), + SSP_CLOCK(fsync, 48000, codec_slave), + SSP_TDM(2, 32, 3, 3), + SSP_CONFIG_DATA(SSP, 5, 24))) + +HDA_DAI_CONFIG(3, 3, iDisp1) +HDA_DAI_CONFIG(4, 4, iDisp2) +HDA_DAI_CONFIG(5, 5, iDisp3) + From 8dc01f7cb5ae5aeefbdfe3c8041a1e35add654b3 Mon Sep 17 00:00:00 2001 From: Keyon Jie Date: Fri, 28 Sep 2018 13:02:12 +0800 Subject: [PATCH 252/324] topology: add topology file for hda generic machine Signed-off-by: Keyon Jie --- topology/Makefile.am | 2 + topology/sof-hda-generic.m4 | 142 ++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100644 topology/sof-hda-generic.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 3e466df665cc..53b85f8b5d5c 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -20,6 +20,7 @@ MACHINES = \ sof-cht-nocodec.tplg \ sof-cht-max98090.tplg \ sof-apl-hdmi.tplg \ + sof-hda-generic.tplg \ sof-apl-nocodec.tplg \ sof-byt-nocodec.tplg \ sof-bdw-rt286.tplg \ @@ -57,6 +58,7 @@ EXTRA_DIST = \ sof-cht-nocodec.m4 \ sof-cht-max98090.m4 \ sof-apl-hdmi.m4 \ + sof-hda-generic.m4 \ sof-apl-nocodec.m4 \ sof-byt-nocodec.m4 \ sof-bdw-rt286.m4 \ diff --git a/topology/sof-hda-generic.m4 b/topology/sof-hda-generic.m4 new file mode 100644 index 000000000000..8d8dcf3e418e --- /dev/null +++ b/topology/sof-hda-generic.m4 @@ -0,0 +1,142 @@ +# +# Topology for SKL+ HDA Generic machine +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') +include(`hda.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include bxt DSP configuration +include(`platform/intel/bxt.m4') + +# +# Define the pipelines +# +# PCM0 <---> volume (pipe 1,2) <----> HDA Analog (HDA Analog playback/capture) +# PCM1 <---> volume (pipe 3,4) <----> HDA Digital (HDA Digital playback/capture) +# PCM3 ----> volume (pipe 7) -----> iDisp1 (HDMI/DP playback, BE link 3) +# PCM4 ----> Volume (pipe 8) -----> iDisp2 (HDMI/DP playback, BE link 4) +# PCM5 ----> volume (pipe 9) -----> iDisp3 (HDMI/DP playback, BE link 5) +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, + 2, 0, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 3 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 3, 1, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency capture pipeline 4 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, + 4, 1, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 7 on PCM 3 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 7, 3, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 8 on PCM 4 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 8, 4, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 9 on PCM 5 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 9, 5, 2, s32le, + 48, 1000, 0, 0) + +# +# DAIs configuration +# + +# playback DAI is HDA Analog using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, HDA, 0, Analog Playback and Capture, + PIPELINE_SOURCE_1, 2, s32le, + 48, 1000, 0, 0) + +# capture DAI is HDA Analog using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, HDA, 0, Analog Playback and Capture, + PIPELINE_SINK_2, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is HDA Digital using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 3, HDA, 1, Digital Playback and Capture, + PIPELINE_SOURCE_3, 2, s32le, + 48, 1000, 0, 0) + +# capture DAI is HDA Digital using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 4, HDA, 1, Digital Playback and Capture, + PIPELINE_SINK_4, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is iDisp1 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 7, HDA, 3, iDisp1, + PIPELINE_SOURCE_7, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is iDisp2 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 8, HDA, 4, iDisp2, + PIPELINE_SOURCE_8, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is iDisp3 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 9, HDA, 5, iDisp3, + PIPELINE_SOURCE_9, 2, s32le, + 48, 1000, 0, 0) + +PCM_DUPLEX_ADD(HDA Analog, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(HDA Digital, 1, PIPELINE_PCM_3, PIPELINE_PCM_4) +PCM_PLAYBACK_ADD(HDMI1, 3, PIPELINE_PCM_7) +PCM_PLAYBACK_ADD(HDMI2, 4, PIPELINE_PCM_8) +PCM_PLAYBACK_ADD(HDMI3, 5, PIPELINE_PCM_9) + +# +# BE configurations - overrides config in ACPI if present +# + +# HDA outputs +HDA_DAI_CONFIG(0, 4, Analog Playback and Capture) +HDA_DAI_CONFIG(1, 5, Digital Playback and Capture) +# 3 HDMI/DP outputs (ID: 3,4,5) +HDA_DAI_CONFIG(3, 1, iDisp1) +HDA_DAI_CONFIG(4, 2, iDisp2) +HDA_DAI_CONFIG(5, 3, iDisp3) + From 6157e899e21792885766c018a6c579122eea502d Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Wed, 26 Sep 2018 16:53:46 +0200 Subject: [PATCH 253/324] logger: added tool for parsing new trace format Signed-off-by: Bartosz Kokoszko --- logger/logger.c | 294 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 294 insertions(+) create mode 100644 logger/logger.c diff --git a/logger/logger.c b/logger/logger.c new file mode 100644 index 000000000000..fbfd0549379c --- /dev/null +++ b/logger/logger.c @@ -0,0 +1,294 @@ +#include +#include +#include +#include +#include +#include +#include "/usr/local/include/sof/uapi/logging.h" + +#define CEIL(a, b) ((a+b-1)/b) + +/* elf signature params */ +#define SND_SOF_LOGS_SIG_SIZE 4 +#define SND_SOF_LOGS_SIG "Logs" + +struct snd_sof_logs_header { + /* "Logs" */ + unsigned char sig[SND_SOF_LOGS_SIG_SIZE]; + /* address of log entries section */ + uint32_t base_address; + /* amount of bytes following this header */ + uint32_t data_length; + /* offset to first entry in this file */ + uint32_t data_offset; +}; + +struct ldc_entry_header { + uint32_t level; + uint32_t component_id; + uint32_t params_num; + uint32_t line_idx; + uint32_t file_name_len; +}; + +struct ldc_entry { + struct ldc_entry_header header; + char *file_name; + uint32_t text_len; + char *text; + uint32_t *params; +}; + +struct dma_log { + struct log_entry_header header; + uint32_t address; +}; + +static int fetch_entry(FILE *f_ldc, FILE *f_dma, uint32_t base_address, + uint32_t data_offset, struct dma_log dma_log); +static void print_table_header(void); +static void print_entry_params(struct dma_log dma_log, struct ldc_entry); +static void usage(char *name); + +static inline void print_table_header(void) +{ + fprintf(stdout, "%10s %8s %8s %14s %16s %24s\t%s\n", + "ADDRESS", + "CORE_ID", + "LEVEL", + "COMPONENT_ID", + "TIMESTAMP", + "FILE_NAME", + "CONTENT"); +} + +static void print_entry_params(struct dma_log dma_log, + struct ldc_entry entry) +{ + fprintf(stdout, "%10x %8u %8u %14u %16lu %20s:%u\t", + dma_log.address, + dma_log.header.core_id, + entry.header.level, + entry.header.component_id, + dma_log.header.timestamp, + entry.file_name, + entry.header.line_idx); + + switch (entry.header.params_num){ + case 0: + fprintf(stdout, "%s", entry.text); + break; + case 1: + fprintf(stdout, entry.text, entry.params[0]); + break; + case 2: + fprintf(stdout, entry.text, entry.params[0], + entry.params[1]); + break; + case 3: + fprintf(stdout, entry.text, entry.params[0], entry.params[1], + entry.params[2]); + break; + } + fprintf(stdout, "\n"); +} + +static void usage(char *name) +{ + fprintf(stdout, "Usage %s \n", name); + fprintf(stdout, "%s:\t Parse traces logs\n", name); + fprintf(stdout, "%s:\t -l *.ldc_file\t-d dma_dump_file\n", name); + exit(0); +} + + +static int fetch_entry(FILE *f_ldc, FILE *f_dma, uint32_t base_address, + uint32_t data_offset, struct dma_log dma_log) +{ + + struct ldc_entry entry; + long int padding; + + uint32_t entry_offset; + uint32_t text_len; + + int ret; + + entry.file_name = NULL; + entry.text = NULL; + entry.params = NULL; + + /* evaluate entry offset in input file */ + entry_offset = dma_log.address - base_address; + + /* set file position to beginning of processed entry */ + fseek(f_ldc, entry_offset + data_offset, SEEK_SET); + + /* fetching elf header params */ + ret = fread(&entry.header, sizeof(entry.header), 1, f_ldc); + if (!ret) { + ret = -ferror(f_ldc); + goto out; + } + + entry.file_name = (char *) malloc(entry.header.file_name_len); + if (!entry.file_name){ + fprintf(stderr, "error: can't allocate %d byte for " + "entry.file_name\n", entry.header.file_name_len); + ret = -ENOMEM; + goto out; + } + + ret = fread(entry.file_name, sizeof(char), entry.header.file_name_len, + f_ldc); + if (ret != entry.header.file_name_len) { + ret = -ferror(f_ldc); + goto out; + } + + /* padding - sequences of chars are aligned to DWORDS */ + fseek(f_ldc, CEIL(entry.header.file_name_len, sizeof(uint32_t)) * + sizeof(uint32_t) - entry.header.file_name_len, SEEK_CUR); + + /* fetching text length */ + ret = fread(&entry.text_len, sizeof(entry.text_len), 1, f_ldc); + if (!ret) { + ret = -ferror(f_ldc); + goto out; + } + + /* fetching text */ + entry.text = (char *) malloc(entry.text_len); + if (entry.text == NULL) { + fprintf(stderr, "error: can't allocate %d byte for " + "entry.text\n", entry.text_len); + ret = -ENOMEM; + goto out; + } + + ret = fread(entry.text, sizeof(char), entry.text_len, f_ldc); + if (ret != entry.text_len) { + ret = -ferror(f_ldc); + goto out; + } + + /* fetching entry params from dma dump */ + entry.params = (uint32_t *) malloc(sizeof(uint32_t) * + entry.header.params_num); + ret = fread(entry.params, sizeof(uint32_t), entry.header.params_num, + f_dma); + if (ret != entry.header.params_num) { + ret = -ferror(f_dma); + goto out; + } + + /* printing entry content */ + print_entry_params(dma_log, entry); + + /* set f_ldc file position to the beginning */ + rewind(f_ldc); + + ret = 0; +out: + /* free alocated memory */ + free(entry.params); + free(entry.text); + free(entry.file_name); + + return ret; +} + +int main(int argc, char *argv[]) +{ + struct dma_log dma_log; + struct snd_sof_logs_header snd; + + int ret; + int opt; + + const char *ldc_dir = NULL; + const char *dma_dump = NULL; + + while ((opt = getopt(argc, argv, "l:d:")) != -1) { + switch (opt) { + case 'l': + ldc_dir = optarg; + break; + case 'd': + dma_dump = optarg; + break; + default: + usage(argv[0]); + } + } + + if (!ldc_dir) { + fprintf(stderr, "error: invalid ldc file.\n"); + return -EINVAL; + } + if (!dma_dump) { + fprintf(stderr, "error: invalid dma_dump file.\n"); + return -EINVAL; + } + + FILE *f_ldc = fopen(ldc_dir, "r"); + FILE *f_dma = fopen(dma_dump, "r"); + + if (f_ldc == NULL) { + fprintf(stderr, "Error while opening %s. \n", ldc_dir); + ret = errno; + goto out; + } + + if (f_dma == NULL) { + fprintf(stderr, "Error while opening %s. \n", dma_dump); + ret = errno; + goto out; + } + + /* set file positions to the beginning */ + rewind(f_ldc); + rewind(f_dma); + + /* veryfing ldc signature */ + ret = fread(&snd, sizeof(snd), 1, f_ldc); + if (!ret) { + ret = -ferror(f_ldc); + goto out; + } + + if (strncmp(snd.sig, SND_SOF_LOGS_SIG, SND_SOF_LOGS_SIG_SIZE)) { + fprintf(stderr, "Error: Invalid ldc file signature. \n"); + ret = -EINVAL; + goto out; + } + + print_table_header(); + + while (!feof(f_dma)) { + + /* getting entry parameters from dma dump */ + ret = fread(&dma_log, sizeof(dma_log), 1, f_dma); + if (!ret) { + ret = -ferror(f_dma); + goto out; + } + + /* checking log address */ + if ((dma_log.address < snd.base_address) || + (dma_log.address > (snd.base_address + snd.data_length))) + continue; + + /* fetching entry from elf dump*/ + ret = fetch_entry(f_ldc, f_dma, snd.base_address, + snd.data_offset, dma_log); + if (ret) goto out; + } + + ret = 0; +out: + if (f_dma) fclose(f_dma); + if (f_ldc) fclose(f_ldc); + + return ret; +} From 437de79ec065f28af4dbb7634ee5917601b06df7 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Fri, 28 Sep 2018 14:24:09 +0200 Subject: [PATCH 254/324] logger: added and updated logger makefiles Signed-off-by: Bartosz Kokoszko --- Makefile.am | 2 +- configure.ac | 1 + logger/Makefile.am | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 logger/Makefile.am diff --git a/Makefile.am b/Makefile.am index 902f0e99474f..565fe477c1f7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = rmbox topology +SUBDIRS = logger rmbox topology TESTDIR = topology/test tests: diff --git a/configure.ac b/configure.ac index 0336378270c3..62c6f421b4e6 100644 --- a/configure.ac +++ b/configure.ac @@ -17,6 +17,7 @@ AC_PROG_CC AC_OUTPUT([ Makefile + logger/Makefile rmbox/Makefile topology/Makefile topology/common/Makefile diff --git a/logger/Makefile.am b/logger/Makefile.am new file mode 100644 index 000000000000..24d4db6e35cd --- /dev/null +++ b/logger/Makefile.am @@ -0,0 +1,4 @@ +bin_PROGRAMS = sof_logger + +sof_logger_SOURCES = \ + logger.c From 1a1e1268eedb818eb8ef0358669816727b718c31 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 24 Sep 2018 19:01:39 +0300 Subject: [PATCH 255/324] EQ: Add equalizer control tool eqctl This patch adds a simple control tool to setup during runtime (idle) the IIR or FIR equalizer with new coefficients configuration. It is useful in tuning of the equalizers. The tool also has capability to read the EQ configuration from DSP. Run "sof-eqctl -h" to see usage. The directory SOFT/tune/eq contains tool to create EQ setup data. Signed-off-by: Seppo Ingalsuo --- Makefile.am | 2 +- configure.ac | 2 + eqctl/Makefile.am | 6 + eqctl/README | 7 ++ eqctl/eq_fir_flat.txt | 1 + eqctl/eq_fir_loudness.txt | 1 + eqctl/eq_fir_mid.txt | 1 + eqctl/eq_iir_bandpass.txt | 1 + eqctl/eq_iir_bassboost.txt | 1 + eqctl/eq_iir_flat.txt | 1 + eqctl/eq_iir_loudness.txt | 1 + eqctl/eqctl.c | 238 +++++++++++++++++++++++++++++++++++++ 12 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 eqctl/Makefile.am create mode 100644 eqctl/README create mode 100644 eqctl/eq_fir_flat.txt create mode 100644 eqctl/eq_fir_loudness.txt create mode 100644 eqctl/eq_fir_mid.txt create mode 100644 eqctl/eq_iir_bandpass.txt create mode 100644 eqctl/eq_iir_bassboost.txt create mode 100644 eqctl/eq_iir_flat.txt create mode 100644 eqctl/eq_iir_loudness.txt create mode 100644 eqctl/eqctl.c diff --git a/Makefile.am b/Makefile.am index 565fe477c1f7..627c3b106fc2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = logger rmbox topology +SUBDIRS = logger rmbox topology eqctl TESTDIR = topology/test tests: diff --git a/configure.ac b/configure.ac index 62c6f421b4e6..0463ad9f3643 100644 --- a/configure.ac +++ b/configure.ac @@ -3,6 +3,7 @@ AC_PREREQ([2.69]) AC_INIT([sof-tools], [1.0.1]) AM_INIT_AUTOMAKE([foreign]) AC_CONFIG_SRCDIR([rmbox/rmbox.c]) +AC_CONFIG_SRCDIR([eqctl/eqctl.c]) AC_CONFIG_HEADERS([config.h]) AC_CHECK_HEADER([sof/uapi/abi.h]) AC_CHECK_PROG([XARGS], xargs, "yes", "no", [$PATH]) @@ -19,6 +20,7 @@ AC_OUTPUT([ Makefile logger/Makefile rmbox/Makefile + eqctl/Makefile topology/Makefile topology/common/Makefile topology/platform/Makefile diff --git a/eqctl/Makefile.am b/eqctl/Makefile.am new file mode 100644 index 000000000000..c1759c05b65a --- /dev/null +++ b/eqctl/Makefile.am @@ -0,0 +1,6 @@ +LDADD = -lasound + +bin_PROGRAMS = sof-eqctl + +sof_eqctl_SOURCES = \ + eqctl.c diff --git a/eqctl/README b/eqctl/README new file mode 100644 index 000000000000..49762054eeb4 --- /dev/null +++ b/eqctl/README @@ -0,0 +1,7 @@ +How to use sof-eqctl tool +========================= + +This tool helps to access the ext bytes or tlv bytes control of SOF +equalizer components eq_iir and eq_fir. Please find the documentation +in https://thesofproject.github.io/latest/getting_started/index.html +for more information. diff --git a/eqctl/eq_fir_flat.txt b/eqctl/eq_fir_flat.txt new file mode 100644 index 000000000000..ee630d924f80 --- /dev/null +++ b/eqctl/eq_fir_flat.txt @@ -0,0 +1 @@ +24,65538,0,4294901764,16384,0, diff --git a/eqctl/eq_fir_loudness.txt b/eqctl/eq_fir_loudness.txt new file mode 100644 index 000000000000..71788fc4e944 --- /dev/null +++ b/eqctl/eq_fir_loudness.txt @@ -0,0 +1 @@ +248,131076,65537,65537,4294901764,16384,0,108,3558500271,114559883,47710217,28574198,28836345,29032901,28180917,26280352,24510851,23200107,21954905,20578629,19136814,17891610,16843017,16122107,15335663,14549220,13762777,12976332,12124351,11337907,10551463,9896092,9175185,8585352,7995518,7405685,6815852,6291556,5767260,5308500,4849741,4456519,4063297,3735612,3473463,3145778,2883630,2687018,2424871,2228260,2031648,1835037,1638427,1507352,1376278,1179667,1048593,983056,851982,786444,720907,393225, diff --git a/eqctl/eq_fir_mid.txt b/eqctl/eq_fir_mid.txt new file mode 100644 index 000000000000..1cdab1f8c326 --- /dev/null +++ b/eqctl/eq_fir_mid.txt @@ -0,0 +1 @@ +192,65538,0,65624,1213426791,4254606209,3887459083,4018203428,4105564850,4147181068,4183947337,4217764461,4245486661,4267048379,4283170521,4294836140,7602239,12320925,14745811,15466729,14942442,13697244,11993285,10092713,8257676,6488176,4915287,3604544,2490414,1572895,917523,458762,65540,4294901759,4294770685,4294705147,4294639611,4294705146,4294705147,4294770683,4294836220,4294836221,4294901758,4294901758,4294967295,4294967295,65535,0, diff --git a/eqctl/eq_iir_bandpass.txt b/eqctl/eq_iir_bandpass.txt new file mode 100644 index 000000000000..3a097b9f215b --- /dev/null +++ b/eqctl/eq_iir_bandpass.txt @@ -0,0 +1 @@ +84,2,1,0,0,2,2,3316150158,2048164275,513807534,3267352229,513807534,0,16384,3867454526,1191025347,38870735,77741469,38870735,4294967294,16458, diff --git a/eqctl/eq_iir_bassboost.txt b/eqctl/eq_iir_bassboost.txt new file mode 100644 index 000000000000..ae30294c3d07 --- /dev/null +++ b/eqctl/eq_iir_bassboost.txt @@ -0,0 +1 @@ +84,2,1,0,0,2,2,3227172081,2141520527,536653443,3221660410,536653443,0,16384,3260252783,2107733822,161646111,3961037800,172645501,4294967294,27910, diff --git a/eqctl/eq_iir_flat.txt b/eqctl/eq_iir_flat.txt new file mode 100644 index 000000000000..59c75db9dca7 --- /dev/null +++ b/eqctl/eq_iir_flat.txt @@ -0,0 +1 @@ +56,2,1,0,0,1,1,0,0,0,0,538145694,0,32690, diff --git a/eqctl/eq_iir_loudness.txt b/eqctl/eq_iir_loudness.txt new file mode 100644 index 000000000000..6bb76ad48f86 --- /dev/null +++ b/eqctl/eq_iir_loudness.txt @@ -0,0 +1 @@ +156,4,2,1,1,1,1,1,1,0,0,0,0,538145694,0,32690,3,3,3237960220,2130690484,297056159,3694463533,303476880,0,16384,3302357025,2064935920,245217319,3776455865,274003881,0,16384,4106268671,4130185751,69182517,4179658584,365641401,4294967292,25468, diff --git a/eqctl/eqctl.c b/eqctl/eqctl.c new file mode 100644 index 000000000000..320b8de0f712 --- /dev/null +++ b/eqctl/eqctl.c @@ -0,0 +1,238 @@ +/* + * Copyright (c) 2018, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Intel Corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Author: Seppo Ingalsuo + */ + +#include +#include +#include +#include + +#define SOF_CTRL_CMD_BINARY 3 /* TODO: From uapi ipc */ + +static void usage(char *name) +{ + fprintf(stdout, "Usage %s \n", name); + fprintf(stdout, "Set example %s -Dhw:0 ", name); + fprintf(stdout, "-c \"numid=22,name=\\\"EQIIR1.0 EQIIR\\\"\" -s "); + fprintf(stdout, "iir.txt\n"); + fprintf(stdout, "Set example %s -Dhw:0 -n 22 -s iir.txt\n", name); + fprintf(stdout, "Get example %s -Dhw:0 -n 22\n", name); + fprintf(stdout, "%s:\t \t\tControl SOF equalizers\n", name); + fprintf(stdout, "%s:\t -D \tUse device , defaults to hw:0\n", + name); + fprintf(stdout, "%s:\t -c \tGet configuration for EQ \n", + name); + fprintf(stdout, "%s:\t -n \tGet configuration for ", name); + fprintf(stdout, "given numid\n"); + fprintf(stdout, "%s:\t -s \tSetup equalizer with data", name); + fprintf(stdout, "in .\n"); + fprintf(stdout, "\t\t\t\tThe ASCII text file must contain comma\n"); + fprintf(stdout, "\t\t\t\tseparated unsigned integers.\n"); + exit(0); +} + +static int read_setup(unsigned int *data, char setup[], size_t smax) +{ + FILE *fh; + int n = 0; + int n_max = smax / sizeof(unsigned int); + int separator; + + fh = fopen(setup, "r"); + while (fscanf(fh, "%u", &data[n]) != EOF && n < n_max) { + if (n > 0) + fprintf(stdout, ","); + fprintf(stdout, "%u", data[n]); + separator = fgetc(fh); + while (separator != ',' && separator != EOF) + separator = fgetc(fh); + + n++; + } + fclose(fh); + fprintf(stdout, "\n"); + return n; +} + +int main(int argc, char *argv[]) +{ + snd_ctl_t *ctl; + snd_ctl_elem_id_t *id; + snd_ctl_elem_info_t *info; + snd_ctl_elem_value_t *value; + uint32_t *config; + unsigned int *user_data; + char nname[256]; + int ret; + int ctrl_size; + int read; + int write; + int type; + int i; + char opt; + int n; + int buffer_size; + int mode = SND_CTL_NONBLOCK; + char *dev = "hw:0"; + char *cname = NULL; + char *setup = NULL; + int set = 0; + + while ((opt = getopt(argc, argv, "hD:c:s:n:")) != -1) { + switch (opt) { + case 'D': + dev = optarg; + break; + case 'c': + cname = optarg; + break; + case 'n': + sprintf(nname, "numid=%d", atoi(optarg)); + cname = nname; + break; + case 's': + setup = optarg; + set = 1; + break; + case 'h': + usage(argv[0]); + exit(0); + break; + default: + usage(argv[0]); + exit(EXIT_FAILURE); + } + } + + /* The control need to be defined. */ + if (!cname) { + fprintf(stderr, "Error: No control was requested.\n"); + usage(argv[0]); + exit(EXIT_FAILURE); + + } + + /* Open the device, mixer control and get read/write/type properties. + */ + ret = snd_ctl_open(&ctl, dev, mode); + if (ret) { + fprintf(stderr, "Error: Could not open device %s.\n", dev); + exit(ret); + } + + /* Allocate buffers for pointers info, id, and value. */ + snd_ctl_elem_info_alloca(&info); + snd_ctl_elem_id_alloca(&id); + snd_ctl_elem_value_alloca(&value); + + /* Get handle id for the ascii control name. */ + ret = snd_ctl_ascii_elem_id_parse(id, cname); + if (ret) { + fprintf(stderr, "Error: Can't find %s.\n", cname); + exit(ret); + } + + /* Get handle info from id. */ + snd_ctl_elem_info_set_id(info, id); + ret = snd_ctl_elem_info(ctl, info); + if (ret) { + fprintf(stderr, "Error: Could not get elem info.\n"); + exit(ret); + } + + /* Get control attributes from info. */ + ctrl_size = snd_ctl_elem_info_get_count(info); + read = snd_ctl_elem_info_is_tlv_readable(info); + write = snd_ctl_elem_info_is_tlv_writable(info); + type = snd_ctl_elem_info_get_type(info); + if (!read) { + fprintf(stderr, "Error: No read capability.\n"); + exit(EXIT_FAILURE); + } + if (!write) { + fprintf(stderr, "Error: No write capability.\n"); + exit(EXIT_FAILURE); + } + if (type != SND_CTL_ELEM_TYPE_BYTES) { + fprintf(stderr, "Error: control type has no bytes support.\n"); + exit(EXIT_FAILURE); + } + + /* Next allocate buffer for tlv write/read. The buffer needs a two + * words header with tag (SOF_CTRL_CMD_BINARY) and size in bytes. + */ + buffer_size = ctrl_size + 2 * sizeof(unsigned int); + user_data = calloc(1, buffer_size); + user_data[0] = SOF_CTRL_CMD_BINARY; + if (set) { + fprintf(stdout, "Applying configuration \"%s\" ", setup); + fprintf(stdout, "into device %s control %s.\n", dev, cname); + n = read_setup(&user_data[2], setup, ctrl_size); + if (n < 1) { + fprintf(stderr, "Error: failed data read from %s.\n", + setup); + free(user_data); + exit(EXIT_FAILURE); + } + user_data[1] = n * sizeof(unsigned int); + ret = snd_ctl_elem_tlv_write(ctl, id, user_data); + if (ret) { + fprintf(stderr, "Error: failed TLV write.\n"); + free(user_data); + exit(ret); + } + fprintf(stdout, "Success.\n"); + + } else { + fprintf(stdout, "Retrieving configuration for "); + fprintf(stdout, "device %s control %s.\n", dev, cname); + user_data[1] = ctrl_size; + ret = snd_ctl_elem_tlv_read(ctl, id, + user_data, buffer_size); + if (ret) { + fprintf(stderr, "Error: failed TLV read.\n"); + free(user_data); + exit(ret); + } + fprintf(stdout, "Success.\n"); + + /* Print the read EQ configuration data with similar syntax + * as the input file format. + */ + config = (uint32_t *) (user_data + 2); + n = config[0] / sizeof(uint32_t); + for (i = 0; i < n; i++) { + if (i == n - 1) + fprintf(stdout, "%u\n", config[i]); + else + fprintf(stdout, "%u,", config[i]); + } + } + free(user_data); +} From 2f65d96833f101542983fedaa0227be69c4b26f0 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Sat, 29 Sep 2018 10:22:30 +0800 Subject: [PATCH 256/324] hda: add virtual widgets to kill error message in kernel log Signed-off-by: Rander Wang --- topology/sof-hda-generic.m4 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/topology/sof-hda-generic.m4 b/topology/sof-hda-generic.m4 index 8d8dcf3e418e..079fa1bb3847 100644 --- a/topology/sof-hda-generic.m4 +++ b/topology/sof-hda-generic.m4 @@ -140,3 +140,17 @@ HDA_DAI_CONFIG(3, 1, iDisp1) HDA_DAI_CONFIG(4, 2, iDisp2) HDA_DAI_CONFIG(5, 3, iDisp3) + +VIRTUAL_DAPM_ROUTE_IN(codec0_in, HDA, 0, IN, 1) +VIRTUAL_DAPM_ROUTE_IN(codec1_in, HDA, 1, IN, 2) +VIRTUAL_DAPM_ROUTE_OUT(codec0_out, HDA, 0, OUT, 3) +VIRTUAL_DAPM_ROUTE_OUT(codec1_out, HDA, 1, OUT, 4) + +# codec2 is not supported in dai links but it exists +# in dapm routes, so hack this one to HDA1 +VIRTUAL_DAPM_ROUTE_IN(codec2_in, HDA, 1, IN, 5) +VIRTUAL_DAPM_ROUTE_OUT(codec2_out, HDA, 1, OUT, 6) + +VIRTUAL_DAPM_ROUTE_OUT(iDisp1_out, HDA, 3, OUT, 7) +VIRTUAL_DAPM_ROUTE_OUT(iDisp2_out, HDA, 4, OUT, 8) +VIRTUAL_DAPM_ROUTE_OUT(iDisp3_out, HDA, 5, OUT, 9) From 497acc82a9c34d6c62575c080e897dc2fe77ab6b Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Sat, 29 Sep 2018 11:55:03 +0800 Subject: [PATCH 257/324] logger: change include filename for uapi Did not include header in a absolute path. Signed-off-by: Pan Xiuli --- logger/logger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logger/logger.c b/logger/logger.c index fbfd0549379c..1aebf397df6c 100644 --- a/logger/logger.c +++ b/logger/logger.c @@ -4,7 +4,7 @@ #include #include #include -#include "/usr/local/include/sof/uapi/logging.h" +#include #define CEIL(a, b) ((a+b-1)/b) From 8f9b35071bf5e9a2bf88c05f33285659a07d6351 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Sat, 29 Sep 2018 11:56:44 +0800 Subject: [PATCH 258/324] logger: run dos2unix for some format issues Change some dos format to unix Signed-off-by: Pan Xiuli --- logger/logger.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/logger/logger.c b/logger/logger.c index 1aebf397df6c..a5ec7cd9a5df 100644 --- a/logger/logger.c +++ b/logger/logger.c @@ -93,12 +93,12 @@ static void print_entry_params(struct dma_log dma_log, fprintf(stdout, "\n"); } -static void usage(char *name) -{ - fprintf(stdout, "Usage %s \n", name); - fprintf(stdout, "%s:\t Parse traces logs\n", name); - fprintf(stdout, "%s:\t -l *.ldc_file\t-d dma_dump_file\n", name); - exit(0); +static void usage(char *name) +{ + fprintf(stdout, "Usage %s \n", name); + fprintf(stdout, "%s:\t Parse traces logs\n", name); + fprintf(stdout, "%s:\t -l *.ldc_file\t-d dma_dump_file\n", name); + exit(0); } @@ -209,17 +209,17 @@ int main(int argc, char *argv[]) const char *ldc_dir = NULL; const char *dma_dump = NULL; - while ((opt = getopt(argc, argv, "l:d:")) != -1) { - switch (opt) { - case 'l': - ldc_dir = optarg; - break; - case 'd': - dma_dump = optarg; - break; - default: - usage(argv[0]); - } + while ((opt = getopt(argc, argv, "l:d:")) != -1) { + switch (opt) { + case 'l': + ldc_dir = optarg; + break; + case 'd': + dma_dump = optarg; + break; + default: + usage(argv[0]); + } } if (!ldc_dir) { From a8d54314c971b4cb9b3c1e58780f93c4c1546240 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Sat, 29 Sep 2018 13:06:25 +0800 Subject: [PATCH 259/324] logger: make logger usage similiar to old rmbox Add wrapper for parser function and add default path for error trace and dam trace. Signed-off-by: Pan Xiuli --- logger/logger.c | 128 ++++++++++++++++++++++++++++-------------------- 1 file changed, 75 insertions(+), 53 deletions(-) diff --git a/logger/logger.c b/logger/logger.c index a5ec7cd9a5df..4d119878700b 100644 --- a/logger/logger.c +++ b/logger/logger.c @@ -44,7 +44,7 @@ struct dma_log { uint32_t address; }; -static int fetch_entry(FILE *f_ldc, FILE *f_dma, uint32_t base_address, +static int fetch_entry(FILE *f_ldc, FILE *f_in, uint32_t base_address, uint32_t data_offset, struct dma_log dma_log); static void print_table_header(void); static void print_entry_params(struct dma_log dma_log, struct ldc_entry); @@ -95,14 +95,15 @@ static void print_entry_params(struct dma_log dma_log, static void usage(char *name) { - fprintf(stdout, "Usage %s \n", name); - fprintf(stdout, "%s:\t Parse traces logs\n", name); - fprintf(stdout, "%s:\t -l *.ldc_file\t-d dma_dump_file\n", name); + fprintf(stdout, "Usage %s \n", name); + fprintf(stdout, "%s:\t \t\t\tParse traces logs\n", name); + fprintf(stdout, "%s:\t -l *.ldc_file\t-i in_file\n", name); + fprintf(stdout, "%s:\t -t\t\t\tDisplay dma trace data\n", name); exit(0); } -static int fetch_entry(FILE *f_ldc, FILE *f_dma, uint32_t base_address, +static int fetch_entry(FILE *f_ldc, FILE *f_in, uint32_t base_address, uint32_t data_offset, struct dma_log dma_log) { @@ -176,9 +177,9 @@ static int fetch_entry(FILE *f_ldc, FILE *f_dma, uint32_t base_address, entry.params = (uint32_t *) malloc(sizeof(uint32_t) * entry.header.params_num); ret = fread(entry.params, sizeof(uint32_t), entry.header.params_num, - f_dma); + f_in); if (ret != entry.header.params_num) { - ret = -ferror(f_dma); + ret = -ferror(f_in); goto out; } @@ -198,57 +199,92 @@ static int fetch_entry(FILE *f_ldc, FILE *f_dma, uint32_t base_address, return ret; } -int main(int argc, char *argv[]) +static int logger_read(const char *in_file, FILE *f_ldc, struct snd_sof_logs_header *snd) { struct dma_log dma_log; - struct snd_sof_logs_header snd; + FILE *f_in = NULL; + int ret = 0; - int ret; - int opt; + f_in = fopen(in_file, "r"); + + if (f_in == NULL) { + fprintf(stderr, "Error while opening %s. \n", in_file); + ret = errno; + goto out; + } + + print_table_header(); + + while (!feof(f_in)) { + + /* getting entry parameters from dma dump */ + ret = fread(&dma_log, sizeof(dma_log), 1, f_in); + if (!ret) { + ret = -ferror(f_in); + goto out; + } - const char *ldc_dir = NULL; - const char *dma_dump = NULL; + /* checking log address */ + if ((dma_log.address < snd->base_address) || + (dma_log.address > (snd->base_address + snd->data_length))) + continue; + + /* fetching entry from elf dump*/ + ret = fetch_entry(f_ldc, f_in, snd->base_address, + snd->data_offset, dma_log); + if (ret) + break; + } + +out: + if (f_ldc) fclose(f_ldc); + if (f_in) fclose(f_in); + + return ret; + +} + +int main(int argc, char *argv[]) +{ + struct snd_sof_logs_header snd; + const char *ldc_file = NULL; + const char *in_file = NULL; + int opt, trace = 0, ret = 0; + FILE *f_ldc = NULL; - while ((opt = getopt(argc, argv, "l:d:")) != -1) { + while ((opt = getopt(argc, argv, "l:i:th")) != -1) { switch (opt) { case 'l': - ldc_dir = optarg; + ldc_file = optarg; + break; + case 'i': + in_file = optarg; break; - case 'd': - dma_dump = optarg; + case 't': + trace = 1; break; + case 'h': default: usage(argv[0]); } } - if (!ldc_dir) { + if (!ldc_file) { fprintf(stderr, "error: invalid ldc file.\n"); - return -EINVAL; - } - if (!dma_dump) { - fprintf(stderr, "error: invalid dma_dump file.\n"); + usage(argv[0]); return -EINVAL; } - FILE *f_ldc = fopen(ldc_dir, "r"); - FILE *f_dma = fopen(dma_dump, "r"); + f_ldc = fopen(ldc_file, "r"); if (f_ldc == NULL) { - fprintf(stderr, "Error while opening %s. \n", ldc_dir); - ret = errno; - goto out; - } - - if (f_dma == NULL) { - fprintf(stderr, "Error while opening %s. \n", dma_dump); + fprintf(stderr, "Error while opening %s. \n", ldc_file); ret = errno; goto out; } /* set file positions to the beginning */ rewind(f_ldc); - rewind(f_dma); /* veryfing ldc signature */ ret = fread(&snd, sizeof(snd), 1, f_ldc); @@ -263,31 +299,17 @@ int main(int argc, char *argv[]) goto out; } - print_table_header(); - - while (!feof(f_dma)) { - - /* getting entry parameters from dma dump */ - ret = fread(&dma_log, sizeof(dma_log), 1, f_dma); - if (!ret) { - ret = -ferror(f_dma); - goto out; - } + /* dma trace requested */ + if (trace) + return logger_read("/sys/kernel/debug/sof/trace", f_ldc, &snd); - /* checking log address */ - if ((dma_log.address < snd.base_address) || - (dma_log.address > (snd.base_address + snd.data_length))) - continue; + /* default option with no infile is to dump errors/debug data */ + if (!in_file) + return logger_read("/sys/kernel/debug/sof/etrace", f_ldc, &snd); - /* fetching entry from elf dump*/ - ret = fetch_entry(f_ldc, f_dma, snd.base_address, - snd.data_offset, dma_log); - if (ret) goto out; - } + return logger_read(in_file, f_ldc, &snd); - ret = 0; out: - if (f_dma) fclose(f_dma); if (f_ldc) fclose(f_ldc); return ret; From e4171c89f89828ab2fe5d42a9aa4b4ece3ed695c Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 1 Oct 2018 11:12:08 -0700 Subject: [PATCH 260/324] eqctl: do not process invalid input file name Fixes seg faults when input file does not exist. Signed-off-by: Ranjani Sridharan --- eqctl/eqctl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/eqctl/eqctl.c b/eqctl/eqctl.c index 320b8de0f712..843a047c03ab 100644 --- a/eqctl/eqctl.c +++ b/eqctl/eqctl.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #define SOF_CTRL_CMD_BINARY 3 /* TODO: From uapi ipc */ @@ -64,7 +65,13 @@ static int read_setup(unsigned int *data, char setup[], size_t smax) int n_max = smax / sizeof(unsigned int); int separator; + /* open input file */ fh = fopen(setup, "r"); + if (!fh) { + fprintf(stderr, "error: %s\n", strerror(errno)); + return -errno; + } + while (fscanf(fh, "%u", &data[n]) != EOF && n < n_max) { if (n > 0) fprintf(stdout, ","); From 9050d82a7d7dd588bd0267d17ad2b6ec0a2379b6 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Tue, 2 Oct 2018 13:54:04 -0700 Subject: [PATCH 261/324] Use passed in number of channels for pipeline Pipelines should not expose more channels than what they are configured to support. Signed-off-by: Curtis Malainey --- topology/sof/pipe-eq-fir-volume-playback.m4 | 2 +- topology/sof/pipe-eq-iir-volume-playback.m4 | 2 +- topology/sof/pipe-eq-volume-playback.m4 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/topology/sof/pipe-eq-fir-volume-playback.m4 b/topology/sof/pipe-eq-fir-volume-playback.m4 index da66d6c0598b..8f6c645bb65e 100644 --- a/topology/sof/pipe-eq-fir-volume-playback.m4 +++ b/topology/sof/pipe-eq-fir-volume-playback.m4 @@ -93,5 +93,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # PCM Configuration # -PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-eq-iir-volume-playback.m4 b/topology/sof/pipe-eq-iir-volume-playback.m4 index 3b93f3cdb689..490835c15254 100644 --- a/topology/sof/pipe-eq-iir-volume-playback.m4 +++ b/topology/sof/pipe-eq-iir-volume-playback.m4 @@ -97,5 +97,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # PCM Configuration # -PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) diff --git a/topology/sof/pipe-eq-volume-playback.m4 b/topology/sof/pipe-eq-volume-playback.m4 index c3ca5b7fd3d5..fc40c4d01627 100644 --- a/topology/sof/pipe-eq-volume-playback.m4 +++ b/topology/sof/pipe-eq-volume-playback.m4 @@ -121,5 +121,5 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Playback PCM_I # PCM Configuration # -PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, 8, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Playback PCM_ID, `S32_LE,S24_LE,S16_LE', 48000, 48000, 2, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) From 7372f1ec7e7c34c92bd83aff50709b0c991ca339 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 4 Oct 2018 18:16:26 +0300 Subject: [PATCH 262/324] EQ tune: Update m4 format EQ filter coefficients syntax This patch updates the export format to currently used format in topology. It adds also possibility to pass text comment into line above the bytes from EQ design script. The date is appended automatically after comment. Signed-off-by: Seppo Ingalsuo --- tune/eq/eq_tplg_write.m | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tune/eq/eq_tplg_write.m b/tune/eq/eq_tplg_write.m index cda5e016db1a..fc6f13236842 100644 --- a/tune/eq/eq_tplg_write.m +++ b/tune/eq/eq_tplg_write.m @@ -1,4 +1,4 @@ -function eq_tplg_write(fn, blob8, eqtype) +function eq_tplg_write(fn, blob8, eqtype, comment) %% % Copyright (c) 2018, Intel Corporation @@ -30,6 +30,10 @@ function eq_tplg_write(fn, blob8, eqtype) % Author: Seppo Ingalsuo % +if nargin < 4 + comment = 'Exported EQ'; +end + %% Pad blob length to multiple of four bytes n_orig = length(blob8); n_new = ceil(n_orig/4)*4; @@ -39,8 +43,8 @@ function eq_tplg_write(fn, blob8, eqtype) %% Write blob fh = fopen(fn, 'w'); nl = 8; -fprintf(fh, '`SectionData."''N_EQ_%s($1)`_data_bytes" {''\n', ... - upper(eqtype)); +fprintf(fh, '# %s %s\n', comment, date()); +fprintf(fh, 'CONTROLBYTES_PRIV(EQ%s_priv,\n', upper(eqtype)); fprintf(fh, '` bytes "'); for i = 1:nl:n_new if i > 1 @@ -57,7 +61,7 @@ function eq_tplg_write(fn, blob8, eqtype) end fprintf(fh, '''\n'); end -fprintf(fh, '`}''\n'); +fprintf(fh, ')\n'); fclose(fh); end From 86b8dafe4105ce13a1835d42d0e57f68fec1f35c Mon Sep 17 00:00:00 2001 From: ArturX Kloniecki Date: Tue, 2 Oct 2018 09:36:44 +0200 Subject: [PATCH 263/324] logger/rmbox: unify implementation of new logger tool with old rmbox Integrate both tools to provide common CLI. Also provide better logging format for logger tool. Signed-off-by: ArturX Kloniecki arturx.kloniecki@linux.intel.com --- Makefile.am | 2 +- configure.ac | 1 - logger/Makefile.am | 4 - logger/logger.c | 316 ------------------------------- rmbox/Makefile.am | 12 +- rmbox/convert.h | 41 ++++ rmbox/logger_convert.c | 286 ++++++++++++++++++++++++++++ rmbox/rmbox.c | 393 ++++++++++----------------------------- rmbox/rmbox_convert.c | 142 ++++++++++++++ rmbox/sof/uapi/abi.h | 76 ++++++++ rmbox/sof/uapi/logging.h | 115 ++++++++++++ 11 files changed, 766 insertions(+), 622 deletions(-) delete mode 100644 logger/Makefile.am delete mode 100644 logger/logger.c create mode 100644 rmbox/convert.h create mode 100644 rmbox/logger_convert.c create mode 100644 rmbox/rmbox_convert.c create mode 100644 rmbox/sof/uapi/abi.h create mode 100644 rmbox/sof/uapi/logging.h diff --git a/Makefile.am b/Makefile.am index 627c3b106fc2..f48e66f54047 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = logger rmbox topology eqctl +SUBDIRS = rmbox topology eqctl TESTDIR = topology/test tests: diff --git a/configure.ac b/configure.ac index 0463ad9f3643..321c59c86d67 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,6 @@ AC_PROG_CC AC_OUTPUT([ Makefile - logger/Makefile rmbox/Makefile eqctl/Makefile topology/Makefile diff --git a/logger/Makefile.am b/logger/Makefile.am deleted file mode 100644 index 24d4db6e35cd..000000000000 --- a/logger/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -bin_PROGRAMS = sof_logger - -sof_logger_SOURCES = \ - logger.c diff --git a/logger/logger.c b/logger/logger.c deleted file mode 100644 index 4d119878700b..000000000000 --- a/logger/logger.c +++ /dev/null @@ -1,316 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#define CEIL(a, b) ((a+b-1)/b) - -/* elf signature params */ -#define SND_SOF_LOGS_SIG_SIZE 4 -#define SND_SOF_LOGS_SIG "Logs" - -struct snd_sof_logs_header { - /* "Logs" */ - unsigned char sig[SND_SOF_LOGS_SIG_SIZE]; - /* address of log entries section */ - uint32_t base_address; - /* amount of bytes following this header */ - uint32_t data_length; - /* offset to first entry in this file */ - uint32_t data_offset; -}; - -struct ldc_entry_header { - uint32_t level; - uint32_t component_id; - uint32_t params_num; - uint32_t line_idx; - uint32_t file_name_len; -}; - -struct ldc_entry { - struct ldc_entry_header header; - char *file_name; - uint32_t text_len; - char *text; - uint32_t *params; -}; - -struct dma_log { - struct log_entry_header header; - uint32_t address; -}; - -static int fetch_entry(FILE *f_ldc, FILE *f_in, uint32_t base_address, - uint32_t data_offset, struct dma_log dma_log); -static void print_table_header(void); -static void print_entry_params(struct dma_log dma_log, struct ldc_entry); -static void usage(char *name); - -static inline void print_table_header(void) -{ - fprintf(stdout, "%10s %8s %8s %14s %16s %24s\t%s\n", - "ADDRESS", - "CORE_ID", - "LEVEL", - "COMPONENT_ID", - "TIMESTAMP", - "FILE_NAME", - "CONTENT"); -} - -static void print_entry_params(struct dma_log dma_log, - struct ldc_entry entry) -{ - fprintf(stdout, "%10x %8u %8u %14u %16lu %20s:%u\t", - dma_log.address, - dma_log.header.core_id, - entry.header.level, - entry.header.component_id, - dma_log.header.timestamp, - entry.file_name, - entry.header.line_idx); - - switch (entry.header.params_num){ - case 0: - fprintf(stdout, "%s", entry.text); - break; - case 1: - fprintf(stdout, entry.text, entry.params[0]); - break; - case 2: - fprintf(stdout, entry.text, entry.params[0], - entry.params[1]); - break; - case 3: - fprintf(stdout, entry.text, entry.params[0], entry.params[1], - entry.params[2]); - break; - } - fprintf(stdout, "\n"); -} - -static void usage(char *name) -{ - fprintf(stdout, "Usage %s \n", name); - fprintf(stdout, "%s:\t \t\t\tParse traces logs\n", name); - fprintf(stdout, "%s:\t -l *.ldc_file\t-i in_file\n", name); - fprintf(stdout, "%s:\t -t\t\t\tDisplay dma trace data\n", name); - exit(0); -} - - -static int fetch_entry(FILE *f_ldc, FILE *f_in, uint32_t base_address, - uint32_t data_offset, struct dma_log dma_log) -{ - - struct ldc_entry entry; - long int padding; - - uint32_t entry_offset; - uint32_t text_len; - - int ret; - - entry.file_name = NULL; - entry.text = NULL; - entry.params = NULL; - - /* evaluate entry offset in input file */ - entry_offset = dma_log.address - base_address; - - /* set file position to beginning of processed entry */ - fseek(f_ldc, entry_offset + data_offset, SEEK_SET); - - /* fetching elf header params */ - ret = fread(&entry.header, sizeof(entry.header), 1, f_ldc); - if (!ret) { - ret = -ferror(f_ldc); - goto out; - } - - entry.file_name = (char *) malloc(entry.header.file_name_len); - if (!entry.file_name){ - fprintf(stderr, "error: can't allocate %d byte for " - "entry.file_name\n", entry.header.file_name_len); - ret = -ENOMEM; - goto out; - } - - ret = fread(entry.file_name, sizeof(char), entry.header.file_name_len, - f_ldc); - if (ret != entry.header.file_name_len) { - ret = -ferror(f_ldc); - goto out; - } - - /* padding - sequences of chars are aligned to DWORDS */ - fseek(f_ldc, CEIL(entry.header.file_name_len, sizeof(uint32_t)) * - sizeof(uint32_t) - entry.header.file_name_len, SEEK_CUR); - - /* fetching text length */ - ret = fread(&entry.text_len, sizeof(entry.text_len), 1, f_ldc); - if (!ret) { - ret = -ferror(f_ldc); - goto out; - } - - /* fetching text */ - entry.text = (char *) malloc(entry.text_len); - if (entry.text == NULL) { - fprintf(stderr, "error: can't allocate %d byte for " - "entry.text\n", entry.text_len); - ret = -ENOMEM; - goto out; - } - - ret = fread(entry.text, sizeof(char), entry.text_len, f_ldc); - if (ret != entry.text_len) { - ret = -ferror(f_ldc); - goto out; - } - - /* fetching entry params from dma dump */ - entry.params = (uint32_t *) malloc(sizeof(uint32_t) * - entry.header.params_num); - ret = fread(entry.params, sizeof(uint32_t), entry.header.params_num, - f_in); - if (ret != entry.header.params_num) { - ret = -ferror(f_in); - goto out; - } - - /* printing entry content */ - print_entry_params(dma_log, entry); - - /* set f_ldc file position to the beginning */ - rewind(f_ldc); - - ret = 0; -out: - /* free alocated memory */ - free(entry.params); - free(entry.text); - free(entry.file_name); - - return ret; -} - -static int logger_read(const char *in_file, FILE *f_ldc, struct snd_sof_logs_header *snd) -{ - struct dma_log dma_log; - FILE *f_in = NULL; - int ret = 0; - - f_in = fopen(in_file, "r"); - - if (f_in == NULL) { - fprintf(stderr, "Error while opening %s. \n", in_file); - ret = errno; - goto out; - } - - print_table_header(); - - while (!feof(f_in)) { - - /* getting entry parameters from dma dump */ - ret = fread(&dma_log, sizeof(dma_log), 1, f_in); - if (!ret) { - ret = -ferror(f_in); - goto out; - } - - /* checking log address */ - if ((dma_log.address < snd->base_address) || - (dma_log.address > (snd->base_address + snd->data_length))) - continue; - - /* fetching entry from elf dump*/ - ret = fetch_entry(f_ldc, f_in, snd->base_address, - snd->data_offset, dma_log); - if (ret) - break; - } - -out: - if (f_ldc) fclose(f_ldc); - if (f_in) fclose(f_in); - - return ret; - -} - -int main(int argc, char *argv[]) -{ - struct snd_sof_logs_header snd; - const char *ldc_file = NULL; - const char *in_file = NULL; - int opt, trace = 0, ret = 0; - FILE *f_ldc = NULL; - - while ((opt = getopt(argc, argv, "l:i:th")) != -1) { - switch (opt) { - case 'l': - ldc_file = optarg; - break; - case 'i': - in_file = optarg; - break; - case 't': - trace = 1; - break; - case 'h': - default: - usage(argv[0]); - } - } - - if (!ldc_file) { - fprintf(stderr, "error: invalid ldc file.\n"); - usage(argv[0]); - return -EINVAL; - } - - f_ldc = fopen(ldc_file, "r"); - - if (f_ldc == NULL) { - fprintf(stderr, "Error while opening %s. \n", ldc_file); - ret = errno; - goto out; - } - - /* set file positions to the beginning */ - rewind(f_ldc); - - /* veryfing ldc signature */ - ret = fread(&snd, sizeof(snd), 1, f_ldc); - if (!ret) { - ret = -ferror(f_ldc); - goto out; - } - - if (strncmp(snd.sig, SND_SOF_LOGS_SIG, SND_SOF_LOGS_SIG_SIZE)) { - fprintf(stderr, "Error: Invalid ldc file signature. \n"); - ret = -EINVAL; - goto out; - } - - /* dma trace requested */ - if (trace) - return logger_read("/sys/kernel/debug/sof/trace", f_ldc, &snd); - - /* default option with no infile is to dump errors/debug data */ - if (!in_file) - return logger_read("/sys/kernel/debug/sof/etrace", f_ldc, &snd); - - return logger_read(in_file, f_ldc, &snd); - -out: - if (f_ldc) fclose(f_ldc); - - return ret; -} diff --git a/rmbox/Makefile.am b/rmbox/Makefile.am index bfeb184fde52..40017a7f5bb4 100644 --- a/rmbox/Makefile.am +++ b/rmbox/Makefile.am @@ -1,4 +1,12 @@ -bin_PROGRAMS = rmbox +bin_PROGRAMS = rmbox logger rmbox_SOURCES = \ - rmbox.c \ No newline at end of file + rmbox.c \ + rmbox_convert.c + +logger_SOURCES = \ + rmbox.c \ + logger_convert.c + +logger_CFLAGS = \ + -DLOGGER_FORMAT \ No newline at end of file diff --git a/rmbox/convert.h b/rmbox/convert.h new file mode 100644 index 000000000000..19c296b52b20 --- /dev/null +++ b/rmbox/convert.h @@ -0,0 +1,41 @@ +/* +* debug log converter interface. +* +* Copyright (c) 2018, Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ +#include +#include + +#define KNRM "\x1B[0m" +#define KRED "\x1B[31m" + +static double to_usecs(uint64_t time, double clk) +{ + /* trace timestamp uses CPU system clock at default 25MHz ticks */ + // TODO: support variable clock rates + return (double)time / clk; +} + +struct convert_config { + const char *out_file; + const char *in_file; + FILE *out_fd; + FILE *in_fd; + double clock; + int trace; +#ifdef LOGGER_FORMAT + const char *ldc_file; + FILE* ldc_fd; +#endif +}; + +int convert(struct convert_config *config); diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c new file mode 100644 index 000000000000..84f858534961 --- /dev/null +++ b/rmbox/logger_convert.c @@ -0,0 +1,286 @@ +/* + * debug log converter, using new logger format. + * + * Copyright (c) 2018, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include +#include + +#include "convert.h" + +#define CEIL(a, b) ((a+b-1)/b) + +/* logs file signature */ +#define SND_SOF_LOGS_SIG_SIZE 4 +#define SND_SOF_LOGS_SIG "Logs" + +struct snd_sof_logs_header { + /* "Logs" */ + unsigned char sig[SND_SOF_LOGS_SIG_SIZE]; + /* address of log entries section */ + uint32_t base_address; + /* amount of bytes following this header */ + uint32_t data_length; + /* offset to first entry in this file */ + uint32_t data_offset; +}; + +struct ldc_entry_header { + uint32_t level; + uint32_t component_id; + uint32_t params_num; + uint32_t line_idx; + uint32_t file_name_len; +}; + +struct ldc_entry { + struct ldc_entry_header header; + char *file_name; + uint32_t text_len; + char *text; + uint32_t *params; +}; + +struct dma_log { + struct log_entry_header header; + uint32_t address; +}; + +static inline void print_table_header(FILE *out_fd) +{ + fprintf(out_fd, "%5s %6s %8s %16s %16s %24s\t%s\n", + "CORE", + "LEVEL", + "COMP_ID", + "TIMESTAMP", + "DELTA", + "FILE_NAME", + "CONTENT"); +} + +#define CASE(x) \ + case(TRACE_CLASS_##x): return #x + +static const char * get_component_name(uint32_t component_id) { + switch (component_id) { + CASE(IRQ); + CASE(IPC); + CASE(PIPE); + CASE(HOST); + CASE(DAI); + CASE(DMA); + CASE(SSP); + CASE(COMP); + CASE(WAIT); + CASE(LOCK); + CASE(MEM); + CASE(MIXER); + CASE(BUFFER); + CASE(VOLUME); + CASE(SWITCH); + CASE(MUX); + CASE(SRC); + CASE(TONE); + CASE(EQ_FIR); + CASE(EQ_IIR); + CASE(SA); + CASE(DMIC); + CASE(POWER); + default: return "unknown"; + } +} + +static void print_entry_params(FILE *out_fd, struct dma_log dma_log, + struct ldc_entry entry, uint64_t last_timestamp, double clock) +{ + float dt = to_usecs(dma_log.header.timestamp - last_timestamp, clock); + if (dt < 0 || dt > 1000.0 * 1000.0 * 1000.0) + dt = NAN; + + fprintf(out_fd, "%s%5u %6u %8s %16.6f %16.6f %20s:%u\t", + entry.header.level == LOG_LEVEL_CRITICAL ? KRED : KNRM, + dma_log.header.core_id, + entry.header.level, + get_component_name(entry.header.component_id), + to_usecs(dma_log.header.timestamp, clock), + dt, + entry.file_name, + entry.header.line_idx); + + switch (entry.header.params_num) { + case 0: + fprintf(out_fd, "%s", entry.text); + break; + case 1: + fprintf(out_fd, entry.text, entry.params[0]); + break; + case 2: + fprintf(out_fd, entry.text, entry.params[0], entry.params[1]); + break; + case 3: + fprintf(out_fd, entry.text, entry.params[0], entry.params[1], + entry.params[2]); + break; + } + fprintf(out_fd, "\n"); +} + +static int fetch_entry(struct convert_config *config, uint32_t base_address, + uint32_t data_offset, struct dma_log dma_log, uint64_t *last_timestamp) +{ + struct ldc_entry entry; + long int padding; + + uint32_t entry_offset; + uint32_t text_len; + + int ret; + + entry.file_name = NULL; + entry.text = NULL; + entry.params = NULL; + + /* evaluate entry offset in input file */ + entry_offset = dma_log.address - base_address; + + /* set file position to beginning of processed entry */ + fseek(config->ldc_fd, entry_offset + data_offset, SEEK_SET); + + /* fetching elf header params */ + ret = fread(&entry.header, sizeof(entry.header), 1, config->ldc_fd); + if (!ret) { + ret = -ferror(config->ldc_fd); + goto out; + } + + entry.file_name = (char *)malloc(entry.header.file_name_len); + if (!entry.file_name) { + fprintf(stderr, "error: can't allocate %d byte for " + "entry.file_name\n", entry.header.file_name_len); + ret = -ENOMEM; + goto out; + } + + ret = fread(entry.file_name, sizeof(char), entry.header.file_name_len, + config->ldc_fd); + if (ret != entry.header.file_name_len) { + ret = -ferror(config->ldc_fd); + goto out; + } + + /* padding - sequences of chars are aligned to DWORDS */ + fseek(config->ldc_fd, CEIL(entry.header.file_name_len, sizeof(uint32_t)) * + sizeof(uint32_t) - entry.header.file_name_len, SEEK_CUR); + + /* fetching text length */ + ret = fread(&entry.text_len, sizeof(entry.text_len), 1, config->ldc_fd); + if (!ret) { + ret = -ferror(config->ldc_fd); + goto out; + } + + /* fetching text */ + entry.text = (char *)malloc(entry.text_len); + if (entry.text == NULL) { + fprintf(stderr, "error: can't allocate %d byte for " + "entry.text\n", entry.text_len); + ret = -ENOMEM; + goto out; + } + + ret = fread(entry.text, sizeof(char), entry.text_len, config->ldc_fd); + if (ret != entry.text_len) { + ret = -ferror(config->ldc_fd); + goto out; + } + + /* fetching entry params from dma dump */ + entry.params = (uint32_t *)malloc(sizeof(uint32_t) * + entry.header.params_num); + ret = fread(entry.params, sizeof(uint32_t), entry.header.params_num, + config->in_fd); + if (ret != entry.header.params_num) { + ret = -ferror(config->in_fd); + goto out; + } + + /* printing entry content */ + print_entry_params(config->out_fd, dma_log, entry, *last_timestamp, + config->clock); + *last_timestamp = dma_log.header.timestamp; + + /* set f_ldc file position to the beginning */ + rewind(config->ldc_fd); + + ret = 0; +out: + /* free alocated memory */ + free(entry.params); + free(entry.text); + free(entry.file_name); + + return ret; +} + +static int logger_read(struct convert_config *config, + struct snd_sof_logs_header *snd) +{ + struct dma_log dma_log; + int ret = 0; + + print_table_header(config->out_fd); + uint64_t last_timestamp = 0; + + while (!feof(config->in_fd)) { + /* getting entry parameters from dma dump */ + ret = fread(&dma_log, sizeof(dma_log), 1, config->in_fd); + if (!ret) { + return -ferror(config->in_fd); + } + + /* checking log address */ + if ((dma_log.address < snd->base_address) || + dma_log.address > snd->base_address + snd->data_length) + continue; + + /* fetching entry from elf dump */ + ret = fetch_entry(config, snd->base_address, snd->data_offset, + dma_log, &last_timestamp); + if (ret) + break; + } + + return ret; +} + +int convert(struct convert_config *config) { + struct snd_sof_logs_header snd; + int count, ret = 0; + + count = fread(&snd, sizeof(snd), 1, config->ldc_fd); + if (!count) { + fprintf(stderr, "Error while reading %s. \n", config->ldc_file); + return -ferror(config->ldc_fd); + } + + if (strncmp(snd.sig, SND_SOF_LOGS_SIG, SND_SOF_LOGS_SIG_SIZE)) { + fprintf(stderr, "Error: Invalid ldc file signature. \n"); + return -EINVAL; + } + + return logger_read(config, &snd); +} \ No newline at end of file diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 913249b6e58f..0e713b8f780c 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -12,259 +12,43 @@ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * more details. */ - #include -#include #include #include #include #include #include -#define KNRM "\x1B[0m" -#define KRED "\x1B[31m" - -// TODO: include all this stuff - -#define TRACE_CLASS_IRQ (1 << 24) -#define TRACE_CLASS_IPC (2 << 24) -#define TRACE_CLASS_PIPE (3 << 24) -#define TRACE_CLASS_HOST (4 << 24) -#define TRACE_CLASS_DAI (5 << 24) -#define TRACE_CLASS_DMA (6 << 24) -#define TRACE_CLASS_SSP (7 << 24) -#define TRACE_CLASS_COMP (8 << 24) -#define TRACE_CLASS_WAIT (9 << 24) -#define TRACE_CLASS_LOCK (10 << 24) -#define TRACE_CLASS_MEM (11 << 24) -#define TRACE_CLASS_MIXER (12 << 24) -#define TRACE_CLASS_BUFFER (13 << 24) -#define TRACE_CLASS_VOLUME (14 << 24) -#define TRACE_CLASS_SWITCH (15 << 24) -#define TRACE_CLASS_MUX (16 << 24) -#define TRACE_CLASS_SRC (17 << 24) -#define TRACE_CLASS_TONE (18 << 24) -#define TRACE_CLASS_EQ_FIR (19 << 24) -#define TRACE_CLASS_EQ_IIR (20 << 24) -#define TRACE_CLASS_SA (21 << 24) -#define TRACE_CLASS_DMIC (22 << 24) -#define TRACE_CLASS_POWER (23 << 24) +#include "convert.h" +#ifdef LOGGER_FORMAT +#define APP_NAME "logger" +#else +#define APP_NAME "rmbox" +#endif #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) - -#define TRACE_BLOCK_SIZE 8 - -static inline char get_char(uint32_t val, int idx) -{ - char c = (val >> (idx * 8)) & 0xff; - if (c < '0' || c > 'z') - return '.'; - else - return c; -} - -static void usage(char *name) -{ - fprintf(stdout, "Usage %s \n", name); - fprintf(stdout, "%s:\t \t\t\tDisplay mailbox contents\n", name); - fprintf(stdout, "%s:\t -i infile -o outfile\tDump infile contents to outfile\n", name); - fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", name); - fprintf(stdout, "%s:\t -s\t\t\tTake a snapshot of state\n", name); - fprintf(stdout, "%s:\t -t\t\t\tDisplay trace data\n", name); - exit(0); -} - -static double to_usecs(uint64_t time, double clk) -{ - /* trace timestamp uses CPU system clock at default 25MHz ticks */ - // TODO: support variable clock rates - return (double)time / clk; -} - -static void show_trace(uint64_t val, uint64_t addr, uint64_t *timestamp, double clk) -{ - const char *trace; - uint32_t class; - uint64_t delta = val - *timestamp; - double fdelta = to_usecs(delta, clk); - double us = 0.0f; - - /* timestamp or value ? */ - if ((addr % (TRACE_BLOCK_SIZE * 2)) == 0) { - - delta = val - *timestamp; - fdelta = to_usecs(delta, clk); - - /* 64-bit timestamp */ - us = to_usecs(val, clk); - - /* empty data ? */ - if (val == 0) { - *timestamp = 0; - return; - } - - /* detect wrap around */ - if (fdelta < 1000.0 * 1000.0 * 1000.0) - printf("0x%lx [%6.6f]\tdelta [%6.6f]\t", addr, - us / 1000000.0 , fdelta / 1000000.0); - else - printf("0x%lx [%6.6f]\tdelta [********]\t", addr, - us / 1000000.0); - - *timestamp = val; - return; - } else if (*timestamp == 0) - return; - - /* check for printable values - otherwise it's a value */ - if (!isprint((char)(val >> 16)) || !isprint((char)(val >> 8)) || !isprint((char)val)) { - printf("value 0x%16.16lx\n", val); - return; - } - - class = val & 0xff000000; - if (class == TRACE_CLASS_IRQ) - trace = "irq"; - else if (class == TRACE_CLASS_IPC) - trace = "ipc"; - else if (class == TRACE_CLASS_PIPE) - trace = "pipe"; - else if (class == TRACE_CLASS_HOST) - trace = "host"; - else if (class == TRACE_CLASS_DAI) - trace = "dai"; - else if (class == TRACE_CLASS_DMA) - trace = "dma"; - else if (class == TRACE_CLASS_SSP) - trace = "ssp"; - else if (class == TRACE_CLASS_COMP) - trace = "comp"; - else if (class == TRACE_CLASS_WAIT) - trace = "wait"; - else if (class == TRACE_CLASS_LOCK) - trace = "lock"; - else if (class == TRACE_CLASS_MEM) - trace = "mem"; - else if (class == TRACE_CLASS_MIXER) - trace = "mixer"; - else if (class == TRACE_CLASS_BUFFER) - trace = "buffer"; - else if (class == TRACE_CLASS_VOLUME) - trace = "volume"; - else if (class == TRACE_CLASS_SWITCH) - trace = "switch"; - else if (class == TRACE_CLASS_MUX) - trace = "mux"; - else if (class == TRACE_CLASS_SRC) - trace = "src"; - else if (class == TRACE_CLASS_TONE) - trace = "tone"; - else if (class == TRACE_CLASS_EQ_FIR) - trace = "eq-fir"; - else if (class == TRACE_CLASS_EQ_IIR) - trace = "eq-iir"; - else if (class == TRACE_CLASS_SA) - trace = "sa"; - else if (class == TRACE_CLASS_DMIC) - trace = "dmic"; - else if (class == TRACE_CLASS_POWER) - trace = "pm"; - else { - printf("value 0x%8.8x\n", (uint32_t)val); - return; - } - - switch ((char)(val >> 16)) { - case 'e': - case 'E': - case 'x': - case 'X': - printf("%s%s %c%c%c%s\n", KRED, trace, - (char)(val >> 16), (char)(val >> 8), (char)val, KNRM); - break; - default: - printf("%s %c%c%c\n", trace, - (char)(val >> 16), (char)(val >> 8), (char)val); - break; - } -} - -static int trace_read(const char *in_file, const char *out_file, double clk) -{ - int count, i; - FILE *in_fd = NULL, *out_fd = NULL; - char c, tmp[TRACE_BLOCK_SIZE] = {0}; - uint64_t addr = 0, val, timestamp = 0; - - in_fd = fopen(in_file, "r"); - if (in_fd == NULL) { - fprintf(stderr, "error: unable to open %s for reading %d\n", - in_file, errno); - return -EIO; - } - - if (out_file == NULL) - goto trace; - - out_fd = fopen(out_file, "w"); - if (out_fd == NULL) { - fprintf(stderr, "error: unable to open %s for writing %d\n", - out_file, errno); - } - -trace: - fprintf(stdout, "using %2.2fMHz timestamp clock\n", clk); - - while (1) { - count = fread(&tmp[0], 1, TRACE_BLOCK_SIZE, in_fd); - if (count != TRACE_BLOCK_SIZE) - break; - - val = *((uint64_t*)tmp); - - for (i = 0; i < TRACE_BLOCK_SIZE / 2; i++) { - c = tmp[i]; - tmp[i] = tmp[TRACE_BLOCK_SIZE - i - 1]; - tmp[TRACE_BLOCK_SIZE - i - 1] = c; - } - - show_trace(val, addr, ×tamp, clk); - - if (out_fd) { - count = fwrite(&tmp[0], 1, TRACE_BLOCK_SIZE, out_fd); - if (count != TRACE_BLOCK_SIZE) - break; - } - - addr += TRACE_BLOCK_SIZE; - } - - fclose(in_fd); - if (out_fd) - fclose(out_fd); - - return 0; -} - -static void show_data(uint32_t val, uint32_t addr) -{ - printf("data: 0x%x = \t0x%8.8x \t(%8.8d) \t|%c%c%c%c|\n", - (unsigned int)addr, - val, val, - get_char(val, 3), get_char(val, 2), - get_char(val, 1), get_char(val, 0)); -} - - static const char *debugfs[] = { "dmac0", "dmac1", "ssp0", "ssp1", "ssp2", "iram", "dram", "shim", "mbox", "etrace", }; +static void usage(void) +{ + fprintf(stdout, "Usage %s \n", APP_NAME); + fprintf(stdout, "%s:\t \t\t\tDisplay mailbox contents\n", APP_NAME); + fprintf(stdout, "%s:\t -i infile -o outfile\tDump infile contents to outfile\n", APP_NAME); +#ifdef LOGGER_FORMAT + fprintf(stdout, "%s:\t -l *.ldc_file\t-i in_file\n", APP_NAME); +#endif + fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", APP_NAME); + fprintf(stdout, "%s:\t -s\t\t\tTake a snapshot of state\n", APP_NAME); + fprintf(stdout, "%s:\t -t\t\t\tDisplay trace data\n", APP_NAME); + exit(0); +} + static int snapshot(const char *name) { const char *path = "/sys/kernel/debug/sof"; @@ -324,99 +108,112 @@ static int snapshot(const char *name) int main(int argc, char *argv[]) { - int opt, count, trace = 0; - const char * out_file = NULL, *in_file = NULL; + struct convert_config config; + int opt, count, ret = 0; FILE *in_fd = NULL, *out_fd = NULL; char c, tmp[8] = {0}; uint64_t addr = 0, val, timestamp = 0, align = 4, i; - double clk = 19.2; + config.trace = 0; + config.clock = 19.2; + config.in_file = NULL; + config.out_file = NULL; + config.out_fd = NULL; + config.in_fd = NULL; +#ifdef LOGGER_FORMAT + config.ldc_file = NULL; +#endif + +#ifdef LOGGER_FORMAT + while ((opt = getopt(argc, argv, "ho:i:l:s:m:c:t")) != -1) { +#else while ((opt = getopt(argc, argv, "ho:i:s:m:c:t")) != -1) { +#endif switch (opt) { case 'o': - out_file = optarg; + config.out_file = optarg; break; case 'i': - in_file = optarg; + config.in_file = optarg; break; case 't': - trace = 1; + config.trace = 1; break; case 'c': - clk = atof(optarg); + config.clock = atof(optarg); break; case 's': return snapshot(optarg); +#ifdef LOGGER_FORMAT + case 'l': + config.ldc_file = optarg; + break; +#endif case 'h': default: /* '?' */ - usage(argv[0]); + usage(); } } - /* trace requested ? */ - if (trace) - return trace_read("/sys/kernel/debug/sof/trace", - out_file, clk); - - /* default option with no infile is to dump errors/debug data */ - if (in_file == NULL) { - fprintf(stdout, "\nError log:\n"); - return trace_read("/sys/kernel/debug/sof/etrace", - out_file, clk); +#ifdef LOGGER_FORMAT + if (!config.ldc_file) { + fprintf(stderr, "error: Missing ldc file"); + usage(); } - /* open infile for reading */ - in_fd = fopen(in_file, "r"); - if (in_fd == NULL) { - fprintf(stderr, "error: unable to open %s for reading %d\n", - in_file, errno); - return -EIO; + config.ldc_fd = fopen(config.ldc_file, "r"); + if (!config.ldc_fd) { + fprintf(stderr, "error: Unable to open ldc file %s\n", + config.ldc_file); + ret = -errno; + goto out; } - - /* open outfile for writing */ - if (out_file == NULL) - goto convert; - - out_fd = fopen(out_file, "w"); - if (out_fd == NULL) { - fprintf(stderr, "error: unable to open %s for writing %d\n", - out_file, errno); - fclose(in_fd); - return -EIO; +#endif + + if (config.out_file) { + config.out_fd = fopen(config.out_file, "w"); + if (!config.out_fd) { + fprintf(stderr, "error: Unable to open out file %s\n", + config.out_file); + ret = -errno; + goto out; + } + } else { + config.out_fd = stdout; } - /* start to converting mailbox */ -convert: - fprintf(stdout, "using %2.2fMHz timestamp clock\n", clk); - - while (1) { - count = fread(&tmp[0], 1, align, in_fd); - if (count != align) - break; - - val = *((uint64_t*)tmp); + /* trace requested ? */ + if (config.trace) + config.in_file = "/sys/kernel/debug/sof/trace"; - for (i = 0; i < align / 2; i++) { - c = tmp[i]; - tmp[i] = tmp[align - i - 1]; - tmp[align - i - 1] = c; + /* default option with no infile is to dump errors/debug data */ + if (!config.in_file) + config.in_file = "/sys/kernel/debug/sof/etrace"; + + if (config.in_file) { + config.in_fd = fopen(config.in_file, "r"); + if (!config.in_fd) { + fprintf(stderr, "error: Unable to open in file %s\n", + config.in_file); + ret = -errno; + goto out; } + } - show_data(val, addr); + convert(&config); - if (out_fd) { - count = fwrite(&tmp[0], 1, align, out_fd); - if (count != align) - break; - } +out: + /* close files */ + if (config.out_file) + fclose(config.out_fd); - addr += align; - } + if (config.in_fd) + fclose(config.in_fd); - /* close files */ - fclose(in_fd); - if (out_fd) - fclose(out_fd); +#ifdef LOGGER_FORMAT + if (config.ldc_fd) + fclose(config.ldc_fd); +#endif - return 0; + return ret; } diff --git a/rmbox/rmbox_convert.c b/rmbox/rmbox_convert.c new file mode 100644 index 000000000000..ddd419a08a07 --- /dev/null +++ b/rmbox/rmbox_convert.c @@ -0,0 +1,142 @@ +/* +* debug log converter, using old rmbox format. +* +* Copyright (c) 2018, Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ + +#include +#include +#include +#include "convert.h" + +#define TRACE_BLOCK_SIZE 8 + +#define CASE(x) case(TRACE_CLASS_##x): trace = #x; break + +static void show_trace(FILE *out_fd, uint64_t val, uint64_t addr, + uint64_t *timestamp, double clk) +{ + const char *trace; + uint32_t class; + uint64_t delta = val - *timestamp; + double fdelta = to_usecs(delta, clk); + double us = 0.0f; + + /* timestamp or value ? */ + if ((addr % (TRACE_BLOCK_SIZE * 2)) == 0) { + + delta = val - *timestamp; + fdelta = to_usecs(delta, clk); + + /* 64-bit timestamp */ + us = to_usecs(val, clk); + + /* empty data ? */ + if (val == 0) { + *timestamp = 0; + return; + } + + /* detect wrap around */ + if (fdelta < 1000.0 * 1000.0 * 1000.0) + fprintf(out_fd, "0x%lx [%6.6f]\tdelta [%6.6f]\t", addr, + us / 1000000.0, fdelta / 1000000.0); + else + fprintf(out_fd, "0x%lx [%6.6f]\tdelta [********]\t", addr, + us / 1000000.0); + + *timestamp = val; + return; + } + else if (*timestamp == 0) + return; + + /* check for printable values - otherwise it's a value */ + if (!isprint((char)(val >> 16)) || !isprint((char)(val >> 8)) || !isprint((char)val)) { + fprintf(out_fd, "value 0x%16.16lx\n", val); + return; + } + + class = val & 0xff000000; + switch (class) + { + CASE(IRQ); + CASE(IPC); + CASE(PIPE); + CASE(HOST); + CASE(DAI); + CASE(DMA); + CASE(SSP); + CASE(COMP); + CASE(WAIT); + CASE(LOCK); + CASE(MEM); + CASE(MIXER); + CASE(BUFFER); + CASE(VOLUME); + CASE(SWITCH); + CASE(MUX); + CASE(SRC); + CASE(TONE); + CASE(EQ_FIR); + CASE(EQ_IIR); + CASE(SA); + CASE(DMIC); + CASE(POWER); + default: + fprintf(out_fd, "value 0x%8.8x\n", (uint32_t)val); + return; + } + + switch ((char)(val >> 16)) { + case 'e': + case 'E': + case 'x': + case 'X': + fprintf(out_fd, "%s%s %c%c%c%s\n", KRED, trace, + (char)(val >> 16), (char)(val >> 8), (char)val, KNRM); + break; + default: + fprintf(out_fd, "%s %c%c%c\n", trace, + (char)(val >> 16), (char)(val >> 8), (char)val); + break; + } +} + +int convert(struct convert_config *config) +{ + int count, i; + char c, tmp[TRACE_BLOCK_SIZE] = { 0 }; + uint64_t addr = 0, val, timestamp = 0; + + fprintf(stdout, "using %2.2fMHz timestamp clock\n", config->clock); + + while (1) { + count = fread(&tmp[0], 1, TRACE_BLOCK_SIZE, config->in_fd); + if (count != TRACE_BLOCK_SIZE) + break; + + val = *((uint64_t*)tmp); + + for (i = 0; i < TRACE_BLOCK_SIZE / 2; i++) { + c = tmp[i]; + tmp[i] = tmp[TRACE_BLOCK_SIZE - i - 1]; + tmp[TRACE_BLOCK_SIZE - i - 1] = c; + } + + show_trace(config->out_fd, val, addr, ×tamp, config->clock); + + addr += TRACE_BLOCK_SIZE; + } + + return 0; +} diff --git a/rmbox/sof/uapi/abi.h b/rmbox/sof/uapi/abi.h new file mode 100644 index 000000000000..118ea64d4686 --- /dev/null +++ b/rmbox/sof/uapi/abi.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2016, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Intel Corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Author: Liam Girdwood + */ + +/** + * \file include/uapi/abi.h + * \brief ABI definitions + * \author Liam Girdwood + */ + +#ifndef __INCLUDE_UAPI_ABI_H__ +#define __INCLUDE_UAPI_ABI_H__ + +/** \brief SOF ABI version number. */ +#define SOF_ABI_VER(major, minor, micro) \ + (((major)<<8)|((minor)<<4)|(micro)) +#define SOF_ABI_VERSION_MAJOR(version) (((version)>>8) & 0xff) +#define SOF_ABI_VERSION_MINOR(version) (((version)>>4) & 0xf) +#define SOF_ABI_VERSION_MICRO(version) ((version) & 0xf) +#define SOF_ABI_VERSION_INCOMPATIBLE(sof_ver, client_ver) \ + (SOF_ABI_VERSION_MAJOR(sof_ver) != SOF_ABI_VERSION_MAJOR(client_ver) ||\ + (SOF_ABI_VERSION_MAJOR(sof_ver) == SOF_ABI_VERSION_MAJOR(client_ver) &&\ + SOF_ABI_VERSION_MINOR(sof_ver) != SOF_ABI_VERSION_MINOR(client_ver))) + +#define SOF_ABI_MAJOR 1 +#define SOF_ABI_MINOR 0 +#define SOF_ABI_MICRO 0 + +#define SOF_ABI_VERSION SOF_ABI_VER(SOF_ABI_MAJOR, SOF_ABI_MINOR, SOF_ABI_MICRO) + +/** \brief SOF ABI magic number "SOF\0". */ +#define SOF_ABI_MAGIC 0x00464F53 + +/** + * \brief Header for all non IPC ABI data. + * + * Identifies data type, size and ABI. + * Used by any bespoke component data structures or binary blobs. + */ +struct sof_abi_hdr { + uint32_t magic; /**< 'S', 'O', 'F', '\0' */ + uint32_t type; /**< component specific type */ + uint32_t size; /**< size in bytes of data excl. this struct */ + uint32_t abi; /**< SOF ABI version */ + uint32_t comp_abi; /**< component specific ABI version */ + char data[0]; /**< data */ +} __attribute__((packed)); + +#endif + diff --git a/rmbox/sof/uapi/logging.h b/rmbox/sof/uapi/logging.h new file mode 100644 index 000000000000..b97309c29034 --- /dev/null +++ b/rmbox/sof/uapi/logging.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2018, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Intel Corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Author: Bartosz Kokoszko + * Artur Kloniecki + */ + +#ifndef __INCLUDE_LOGGING__ +#define __INCLUDE_LOGGING__ + +#include + +/* + * Host system time. + * + * This property is used by the driver to pass down information about + * current system time. It is expressed in us. + * FW translates timestamps (in log entries, probe pockets) to this time + * domain. + * + * (cavs: SystemTime). + */ +struct system_time { + uint32_t val_l; /* Lower dword of current host time value */ + uint32_t val_u; /* Upper dword of current host time value */ +}; + +/* trace event classes - high 8 bits*/ +#define TRACE_CLASS_IRQ (1 << 24) +#define TRACE_CLASS_IPC (2 << 24) +#define TRACE_CLASS_PIPE (3 << 24) +#define TRACE_CLASS_HOST (4 << 24) +#define TRACE_CLASS_DAI (5 << 24) +#define TRACE_CLASS_DMA (6 << 24) +#define TRACE_CLASS_SSP (7 << 24) +#define TRACE_CLASS_COMP (8 << 24) +#define TRACE_CLASS_WAIT (9 << 24) +#define TRACE_CLASS_LOCK (10 << 24) +#define TRACE_CLASS_MEM (11 << 24) +#define TRACE_CLASS_MIXER (12 << 24) +#define TRACE_CLASS_BUFFER (13 << 24) +#define TRACE_CLASS_VOLUME (14 << 24) +#define TRACE_CLASS_SWITCH (15 << 24) +#define TRACE_CLASS_MUX (16 << 24) +#define TRACE_CLASS_SRC (17 << 24) +#define TRACE_CLASS_TONE (18 << 24) +#define TRACE_CLASS_EQ_FIR (19 << 24) +#define TRACE_CLASS_EQ_IIR (20 << 24) +#define TRACE_CLASS_SA (21 << 24) +#define TRACE_CLASS_DMIC (22 << 24) +#define TRACE_CLASS_POWER (23 << 24) +#define TRACE_CLASS_IDC (24 << 24) +#define TRACE_CLASS_CPU (25 << 24) + +#define LOG_ENABLE 1 /* Enable logging */ +#define LOG_DISABLE 0 /* Disable logging */ + +#define LOG_LEVEL_CRITICAL 1 /* (FDK fatal) */ +#define LOG_LEVEL_VERBOSE 2 + +/* + * Layout of a log fifo. + */ +struct log_buffer_layout { + uint32_t read_ptr; /*read pointer */ + uint32_t write_ptr; /* write pointer */ + uint32_t buffer[0]; /* buffer */ +}; + +/* + * Log buffer status reported by FW. + */ +struct log_buffer_status { + uint32_t core_id; /* ID of core that logged to other half */ +}; + +/* + * Log entry header. + * + * The header is followed by an array of arguments (uint32_t[]). + * Number of arguments is specified by the params_num field of log_entry, + * and is 0-based value (entry_len=0 means there is 1 argument). + */ +struct log_entry_header { + uint32_t rsvd : 24; /* Unused */ + uint32_t core_id : 8; /* Reporting core's id */ + + uint64_t timestamp; /* Timestamp (in dsp ticks) */ +} __attribute__((__packed__)); + +#endif //#ifndef __INCLUDE_LOGGING__ From c569a95905b1c896ea18fe86bde33fe77a3ce6e8 Mon Sep 17 00:00:00 2001 From: Rander Wang Date: Tue, 9 Oct 2018 10:36:34 +0800 Subject: [PATCH 264/324] WHL: add a bespoke hda topology for WHL Only passthrough is required on WHL Signed-off-by: Rander Wang --- topology/Makefile.am | 2 + topology/sof-whl-hda.m4 | 156 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 topology/sof-whl-hda.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 317db22a4ee5..22191c0fd215 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -20,6 +20,7 @@ MACHINES = \ sof-cht-nocodec.tplg \ sof-cht-max98090.tplg \ sof-apl-hdmi.tplg \ + sof-whl-hda.tplg \ sof-hda-generic.tplg \ sof-apl-nocodec.tplg \ sof-byt-nocodec.tplg \ @@ -59,6 +60,7 @@ EXTRA_DIST = \ sof-cht-nocodec.m4 \ sof-cht-max98090.m4 \ sof-apl-hdmi.m4 \ + sof-whl-hda.m4 \ sof-hda-generic.m4 \ sof-apl-nocodec.m4 \ sof-byt-nocodec.m4 \ diff --git a/topology/sof-whl-hda.m4 b/topology/sof-whl-hda.m4 new file mode 100644 index 000000000000..0eec9e4e0d91 --- /dev/null +++ b/topology/sof-whl-hda.m4 @@ -0,0 +1,156 @@ +# +# HDA passthrough topology for WHL +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') +include(`hda.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include bxt DSP configuration +include(`platform/intel/bxt.m4') + +# +# Define the pipelines +# +# PCM0 <---> passthrough (pipe 1,2) <----> HDA Analog (HDA Analog playback/capture) +# PCM1 <---> passthrough (pipe 3,4) <----> HDA Digital (HDA Digital playback/capture) +# PCM3 ----> passthrough (pipe 7) -----> iDisp1 (HDMI/DP playback, BE link 3) +# PCM4 ----> passthrough (pipe 8) -----> iDisp2 (HDMI/DP playback, BE link 4) +# PCM5 ----> passthrough (pipe 9) -----> iDisp3 (HDMI/DP playback, BE link 5) +# + +# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4, + 1, 0, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency capture pipeline 2 on PCM 0 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, + 2, 0, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 3 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4, + 3, 1, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency capture pipeline 4 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, + 4, 1, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 7 on PCM 3 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4, + 7, 3, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 8 on PCM 4 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4, + 8, 4, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 9 on PCM 5 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-passthrough-playback.m4, + 9, 5, 2, s32le, + 48, 1000, 0, 0) + +# +# DAIs configuration +# + +# playback DAI is HDA Analog using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 1, HDA, 0, Analog Playback and Capture, + PIPELINE_SOURCE_1, 2, s32le, + 48, 1000, 0, 0) + +# capture DAI is HDA Analog using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 2, HDA, 0, Analog Playback and Capture, + PIPELINE_SINK_2, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is HDA Digital using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 3, HDA, 1, Digital Playback and Capture, + PIPELINE_SOURCE_3, 2, s32le, + 48, 1000, 0, 0) + +# capture DAI is HDA Digital using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 4, HDA, 1, Digital Playback and Capture, + PIPELINE_SINK_4, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is iDisp1 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 7, HDA, 3, iDisp1, + PIPELINE_SOURCE_7, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is iDisp2 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 8, HDA, 4, iDisp2, + PIPELINE_SOURCE_8, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is iDisp3 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 9, HDA, 5, iDisp3, + PIPELINE_SOURCE_9, 2, s32le, + 48, 1000, 0, 0) + +PCM_DUPLEX_ADD(HDA Analog, 0, PIPELINE_PCM_1, PIPELINE_PCM_2) +PCM_DUPLEX_ADD(HDA Digital, 1, PIPELINE_PCM_3, PIPELINE_PCM_4) +PCM_PLAYBACK_ADD(HDMI1, 3, PIPELINE_PCM_7) +PCM_PLAYBACK_ADD(HDMI2, 4, PIPELINE_PCM_8) +PCM_PLAYBACK_ADD(HDMI3, 5, PIPELINE_PCM_9) + +# +# BE configurations - overrides config in ACPI if present +# + +# HDA outputs +HDA_DAI_CONFIG(0, 4, Analog Playback and Capture) +HDA_DAI_CONFIG(1, 5, Digital Playback and Capture) +# 3 HDMI/DP outputs (ID: 3,4,5) +HDA_DAI_CONFIG(3, 1, iDisp1) +HDA_DAI_CONFIG(4, 2, iDisp2) +HDA_DAI_CONFIG(5, 3, iDisp3) + + +VIRTUAL_DAPM_ROUTE_IN(codec0_in, HDA, 0, IN, 1) +VIRTUAL_DAPM_ROUTE_IN(codec1_in, HDA, 1, IN, 2) +VIRTUAL_DAPM_ROUTE_OUT(codec0_out, HDA, 0, OUT, 3) +VIRTUAL_DAPM_ROUTE_OUT(codec1_out, HDA, 1, OUT, 4) + +# codec2 is not supported in dai links but it exists +# in dapm routes, so hack this one to HDA1 +VIRTUAL_DAPM_ROUTE_IN(codec2_in, HDA, 1, IN, 5) +VIRTUAL_DAPM_ROUTE_OUT(codec2_out, HDA, 1, OUT, 6) + +VIRTUAL_DAPM_ROUTE_OUT(iDisp1_out, HDA, 3, OUT, 7) +VIRTUAL_DAPM_ROUTE_OUT(iDisp2_out, HDA, 4, OUT, 8) +VIRTUAL_DAPM_ROUTE_OUT(iDisp3_out, HDA, 5, OUT, 9) From 5e4995f99521aa5b2d20ba63dca99893d93320b1 Mon Sep 17 00:00:00 2001 From: ArturX Kloniecki Date: Mon, 8 Oct 2018 14:18:08 +0200 Subject: [PATCH 265/324] logger: Implement possibility to read log data from stdin Signed-off-by: ArturX Kloniecki --- rmbox/convert.h | 1 + rmbox/logger_convert.c | 3 ++- rmbox/rmbox.c | 14 ++++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/rmbox/convert.h b/rmbox/convert.h index 19c296b52b20..085ea5f4868f 100644 --- a/rmbox/convert.h +++ b/rmbox/convert.h @@ -35,6 +35,7 @@ struct convert_config { #ifdef LOGGER_FORMAT const char *ldc_file; FILE* ldc_fd; + int input_std; #endif }; diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index 84f858534961..a859d4920017 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -70,6 +70,7 @@ static inline void print_table_header(FILE *out_fd) "DELTA", "FILE_NAME", "CONTENT"); + fflush(out_fd); } #define CASE(x) \ @@ -137,6 +138,7 @@ static void print_entry_params(FILE *out_fd, struct dma_log dma_log, break; } fprintf(out_fd, "\n"); + fflush(out_fd); } static int fetch_entry(struct convert_config *config, uint32_t base_address, @@ -241,7 +243,6 @@ static int logger_read(struct convert_config *config, { struct dma_log dma_log; int ret = 0; - print_table_header(config->out_fd); uint64_t last_timestamp = 0; diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 0e713b8f780c..671a2d1bea57 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -42,6 +42,7 @@ static void usage(void) fprintf(stdout, "%s:\t -i infile -o outfile\tDump infile contents to outfile\n", APP_NAME); #ifdef LOGGER_FORMAT fprintf(stdout, "%s:\t -l *.ldc_file\t-i in_file\n", APP_NAME); + fprintf(stdout, "%s:\t -p \tinput from stdin\n", APP_NAME); #endif fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", APP_NAME); fprintf(stdout, "%s:\t -s\t\t\tTake a snapshot of state\n", APP_NAME); @@ -122,10 +123,11 @@ int main(int argc, char *argv[]) config.in_fd = NULL; #ifdef LOGGER_FORMAT config.ldc_file = NULL; + config.input_std = 0; #endif #ifdef LOGGER_FORMAT - while ((opt = getopt(argc, argv, "ho:i:l:s:m:c:t")) != -1) { + while ((opt = getopt(argc, argv, "ho:i:l:ps:m:c:t")) != -1) { #else while ((opt = getopt(argc, argv, "ho:i:s:m:c:t")) != -1) { #endif @@ -148,6 +150,9 @@ int main(int argc, char *argv[]) case 'l': config.ldc_file = optarg; break; + case 'p': + config.input_std = 1; + break; #endif case 'h': default: /* '?' */ @@ -190,7 +195,12 @@ int main(int argc, char *argv[]) if (!config.in_file) config.in_file = "/sys/kernel/debug/sof/etrace"; - if (config.in_file) { +#ifdef LOGGER_FORMAT + if (config.input_std) { + config.in_fd = stdin; + } else +#endif + { config.in_fd = fopen(config.in_file, "r"); if (!config.in_fd) { fprintf(stderr, "error: Unable to open in file %s\n", From 932f09f0c200c7f9c3bc5892991b7124c46e09c0 Mon Sep 17 00:00:00 2001 From: ArturX Kloniecki Date: Wed, 10 Oct 2018 09:17:54 +0200 Subject: [PATCH 266/324] logger: Fix formatting of line number value. Signed-off-by: ArturX Kloniecki --- rmbox/logger_convert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index 84f858534961..4b03d3096de5 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -111,7 +111,7 @@ static void print_entry_params(FILE *out_fd, struct dma_log dma_log, if (dt < 0 || dt > 1000.0 * 1000.0 * 1000.0) dt = NAN; - fprintf(out_fd, "%s%5u %6u %8s %16.6f %16.6f %20s:%u\t", + fprintf(out_fd, "%s%5u %6u %8s %16.6f %16.6f %20s:%-4u\t", entry.header.level == LOG_LEVEL_CRITICAL ? KRED : KNRM, dma_log.header.core_id, entry.header.level, From 3bf2641ef57967d4c1472ee2410b8c8e12a98b75 Mon Sep 17 00:00:00 2001 From: ArturX Kloniecki Date: Wed, 10 Oct 2018 11:44:12 +0200 Subject: [PATCH 267/324] logger: Add support for 4 parameters passed to log message. Signed-off-by: ArturX Kloniecki --- rmbox/logger_convert.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index 84f858534961..cad2c61d8a17 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -135,6 +135,10 @@ static void print_entry_params(FILE *out_fd, struct dma_log dma_log, fprintf(out_fd, entry.text, entry.params[0], entry.params[1], entry.params[2]); break; + case 4: + fprintf(out_fd, entry.text, entry.params[0], entry.params[1], + entry.params[2], entry.params[3]); + break; } fprintf(out_fd, "\n"); } From 1cbba6c5e82e56abb93f749187b410d9f040370e Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 10 Oct 2018 16:43:38 +0300 Subject: [PATCH 268/324] EQ: Add tool for acoustical frequency response measurement This patch adds into SOFT/tune/eq a script mls_freq_resp.m that can be used as low budget or quick developer tool to measure device frequency response. The configuration files mls_play_config.txt and mls_rec_config.txt configure the audio devices for local or remote ssh aplay/arecord execution. The MLS measurement with a short time window, e.g. less than 10 ms can partially achieve the same as anechoic measurement. However this is not intended to replace usage any professional audio measurement. If using this use with care! Note also that as such this script measures the response of a speaker - microphone system. One response need to be known and under calibration to get reliable results for other. Even ADC and DAC responses may impact. Signed-off-by: Seppo Ingalsuo --- test/test_utils/mls_calc_resp.m | 98 ++++++++++ tune/eq/mls_freq_resp.m | 306 ++++++++++++++++++++++++++++++++ tune/eq/mls_play_config.txt | 5 + tune/eq/mls_rec_config.txt | 5 + 4 files changed, 414 insertions(+) create mode 100644 test/test_utils/mls_calc_resp.m create mode 100644 tune/eq/mls_freq_resp.m create mode 100644 tune/eq/mls_play_config.txt create mode 100644 tune/eq/mls_rec_config.txt diff --git a/test/test_utils/mls_calc_resp.m b/test/test_utils/mls_calc_resp.m new file mode 100644 index 000000000000..41e2185d5261 --- /dev/null +++ b/test/test_utils/mls_calc_resp.m @@ -0,0 +1,98 @@ +function [f, m_db, b] = mls_calc_resp(csv_fn, ref_wfn, meas_wfn, t_tot, np, f_lo, f_hi) + +%% Calculate frequency response from MLS recordings +% +% [f, m, b] = calc_freq_resp(csv_fn, ref_fn, meas_fn, t_tot, np, f_lo, f_hi) +% +% Inputs parameters: +% csv_fn - File name for CSV format response output +% ref_fn - Reference MLS wave file +% meas_fn - Captured MSL wave file +% t_tot - Time window of MLS analysis in s, e.g. 5 - 10 ms +% np - Number of frequency points +% f_lo - Lower frequency limit for analysis +% f_hi - Upper frequency limit for analysis + +%% +% Copyright (c) 2018, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + + %% Read audio files + [xr, fs] = audioread(ref_wfn); + [xm, fsm] = audioread(meas_wfn); + sm = size(xm); + nch = sm(2); + + if (fs ~= fsm) + error('Reference and measured sample rates do not match.'); + end + + ind_imp = zeros(1, nch); + for ch=1:nch + [acor(:,ch),lag] = xcorr(xm(:,ch), xr, 'coeff'); + [~,I] = max(abs(acor(:,ch))); + timeDiff = lag(I); + % Crosscorrelation maximum points to max of impulse response. + % Use it beginning of impulse response + ind_imp(ch) = find(lag == timeDiff); + end + % Keep the channels time aligned by using average of max as reference + ind_imp_avg = round(sum(ind_imp)/nch); + + b = []; + nwin_half = round(t_tot*fs); + nwin_tot = 2*nwin_half; + win = hanning(nwin_tot); + for ch = 1:nch + % All channels are windowed from the same location + p1 = ind_imp_avg-nwin_half; + p2 = p1 + nwin_tot-1; + acor_windowed = acor(p1:p2,ch) .* win; + b(:,ch) = acor_windowed; + end + + + %% Compute frequency response + f = logspace(log10(f_lo),log10(f_hi),np); + for ch=1:nch + h(:,ch) = freqz(b(:,ch), 1, f, fs); + end + m_db = 20*log10(abs(h)); + + fh = fopen(csv_fn, 'w'); + for i = 1:np + fprintf(fh, '%10.3f', f(i)); + for j = 1:nch + fprintf(fh, ', %8.3f', m_db(i, j)); + end + fprintf(fh, '\n'); + end + fclose(fh); + +end diff --git a/tune/eq/mls_freq_resp.m b/tune/eq/mls_freq_resp.m new file mode 100644 index 000000000000..8a96461a3840 --- /dev/null +++ b/tune/eq/mls_freq_resp.m @@ -0,0 +1,306 @@ +function [f, m_db] = mls_freq_resp(id) +%% Measure frequency response with MLS test signal +% +% [f, m] = mls_freq_resp(id) +% +% Input parameters +% id - A string identifier for test case. An id 'selftest' is for special +% usage. It calculates response of filtered MLS signal and computes +% the measurement vs. known. Deviation is reported as error. It can +% be useful if the internal MLS measurement parameters are adjusted. +% +% Output parameters +% f - Frequency vector in Hz +% m - Measured magnitude responses in dB +% +% Configuration (edit these): +% mls_play_config.txt +% mls_rec_config.txt +% +% The script will return also a text CSV format file with name mls-.txt. +% + +%% +% Copyright (c) 2018, Intel Corporation +% All rights reserved. +% +% Redistribution and use in source and binary forms, with or without +% modification, are permitted provided that the following conditions are met: +% * Redistributions of source code must retain the above copyright +% notice, this list of conditions and the following disclaimer. +% * Redistributions in binary form must reproduce the above copyright +% notice, this list of conditions and the following disclaimer in the +% documentation and/or other materials provided with the distribution. +% * Neither the name of the Intel Corporation nor the +% names of its contributors may be used to endorse or promote products +% derived from this software without specific prior written permission. +% +% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +% AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +% IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +% ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +% LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +% SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +% INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +% ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +% POSSIBILITY OF SUCH DAMAGE. +% +% Author: Seppo Ingalsuo +% + +%% Settings +np = 1024; % Number of frequency points to use +f_lo = 100; % Lower frequency limit for analysis +f_hi = 20e3; % Upper frequency limit for analysis +t_tot = 10e-3; % MLS analysis window length in s +t_mls_s = 1.0; % MLS test signal length in s +a_mls_db = -10; % MLS test signal amplitude in dB +fs = 48e3; % Sample rate in Hz +bits = 16; % Audio format to use (bits) +fmt = 'S16_LE'; % Audio format to use (ALSA) +dir = '/tmp'; % Directory for temporary files +capture_level_max_db = -1; % Expected max. level +capture_level_min_db = -30; % Expacted min. level + +%% Get device identifier to use +if nargin < 1 + id = 'unknown'; +end + +if strcmp(id, 'selftest') + selftest = 1; + % Just some simulated speaker response to use as self test case + stb = [ 0.341762453, -0.915611126, 0.482465118, ... + 1.017612317, -1.722527013, 0.711608745, ... + 0.630608859, -0.813609935, 0.267690582, ]; + sta = [ 1.000000000, -3.931695128, 6.630812276, ... + -6.339248735, 3.800407709, -1.559376698, ... + 0.619626250, -0.317702349, 0.097453451, ]; +else + selftest = 0; +end +measfn = sprintf('mls-%s.wav', id); +csvfn = sprintf('mls-%s.txt', id); + +%% Paths +addpath('../../test/test_utils'); + +%% MLS +n_mls = round(fs*t_mls_s); +mls = 10^(a_mls_db/20) * (2 * mlsp12(1, n_mls) - 1); +mlsfn = 'mls-ref.wav'; +audiowrite(mlsfn, mls, fs); + +%% Chip markers and parameters for find sync +[x1, m1] = sync_chirp(fs, 'up'); +[x2, m2] = sync_chirp(fs, 'down'); +fnd.fs = fs; % Sample rate +fnd.sm = 3; % Max seek from start +fnd.em = 3; % Max seek from end +fnd.idle_t = 2; % max idle in start or end +fnd.mark_t = m1.t; % Marker length +fnd.nf = 1; % One signal (amplitude) +fnd.na = 1; % One signal (frequency) +fnd.tl = t_mls_s; % Length of signal +fnd.mt = 0.1; % Threshold length to issue error +fnd.is = 0; % Ignore from start +fnd.ie = 0; % Ignore from end + +%% Merge markers and MLS +z = zeros(n_mls + m1.n + m2.n, 1); +i1 = m1.n + 1; +i2 = m1.n + n_mls; +z(1:i1 - 1) = x1; +z(i1:i2) = mls; +z(i2 + 1:end) = x2; + +%% Get config +rec_cfg = meas_remote_rec_config(fs, fmt); +play_cfg = meas_remote_play_config; + +%% Capture MLS from all playback channel at time +mixfn = 'mlsmix.wav'; +recfn = 'recch.wav'; +y = []; +for i=1:play_cfg.nch + fprintf('\n'); + fprintf('Measure playback channel %d\n', i); + if selftest + tz =zeros(2*fs+length(z), 1); % Pad 2s + tz(fs:fs+length(z)-1) = z; + t = filter(stb, sta, tz); % Filter with test response + r = t(:) * ones(1, rec_cfg.nch); % Copy to all channels + else + x = zeros(length(z), play_cfg.nch); + x(:,i) = z; + mixdfn = sprintf('%s/%s', dir, mixfn); + audiowrite(mixdfn, x, fs, 'BitsPerSample', bits); + copy_playback(mixdfn, play_cfg); + tcap = floor(3 + t_mls_s); + remote_capture(recfn, rec_cfg, tcap); + pause(1); + remote_play(mixfn, play_cfg); + pause(3); + r = get_recording(recfn, rec_cfg); + end + [d, nt] = find_test_signal(r(:,1), fnd); + for j = 1:rec_cfg.nch + y(:, rec_cfg.nch*(i-1) + j) = r(d:d + nt -1, j); + end + m = 20*log10(max(abs(r))); + fprintf('Peak levels for capture channels (dB):'); + for j = 1:rec_cfg.nch + fprintf(' %5.1f', m(j)); + end + fprintf('\n'); + if max(m) > capture_level_max_db + fprintf('Warning: The recording level is too loud.\n'); + end + if min(m) < capture_level_min_db + fprintf('Warning: The recording level is too silent.\n'); + end + +end +audiowrite(measfn, y, fs, 'BitsPerSample', bits); +fprintf('\n'); +fprintf('Done.\n'); + +[f, m_db, b] = mls_calc_resp(csvfn, mlsfn, measfn, t_tot, np, f_lo, f_hi); + +figure +idx = find(f>1e3, 1, 'first') - 1; +m_db_align = m_db - m_db(idx); +semilogx(f, m_db_align); +ax=axis(); axis([f_lo f_hi ax(3:4)]); +grid on; +xlabel('Frequency (Hz)'); +ylabel('Magnitude (dB)'); + +if selftest + title('Measured vs. reference response'); + h = freqz(stb, sta, f, fs); + ref_db = 20*log10(abs(h)); + ref_db_align = ref_db - ref_db(idx); + hold on; + plot(f, ref_db_align, 'r--'); + hold off; + idx = find(f < f_hi); + idx = find(f(idx) > f_lo); + m_lin = 10.^(m_db_align(idx)/20); + ref_lin = 10.^(ref_db_align(idx)/20); + err_lin = m_lin - ref_lin; + e_rms = sqrt(mean(err_lin.^2)); + e_db = 20*log10(e_rms); + figure; + semilogx(f(idx), 20*log10(abs(err_lin))) + grid on; + xlabel('Frequency (Hz)'); + ylabel('Magnitude (dB)'); + title('Observed Error in self test'); + if e_db < -30 + fprintf('Passed self test. '); + else + fprintf('Failed self test. '); + end + fprintf('Response RMS error is %4.1f dB.\n', e_db); +end + +end + +function copy_playback(fn, cfg) + if cfg.ssh + cmd = sprintf('scp %s %s:%s/', fn, cfg.user, cfg.dir); + fprintf('Remote copy: %s\n', cmd); + system(cmd); + else + %cmd = sprintf('cp %s %s/', fn, cfg.dir); + %fprintf('Local copy: %s\n', cmd); + end +end + +function y = get_recording(fn, cfg) + if cfg.ssh + cmd = sprintf('scp %s:%s/%s %s', cfg.user, cfg.dir, fn, fn); + fprintf('Remote copy: %s\n', cmd); + else + cmd = sprintf('cp %s/%s %s', cfg.dir, fn, fn); + fprintf('Local copy: %s\n', cmd); + end + system(cmd); + y = audioread(fn); + delete(fn); +end + +function remote_play(fn, cfg) + if cfg.ssh + cmd = sprintf('ssh %s aplay -D%s %s/%s', cfg.user, cfg.dev, cfg.dir, fn); + fprintf('Remote play: %s\n', cmd); + else + cmd = sprintf('aplay -D%s %s/%s', cfg.dev, cfg.dir, fn); + fprintf('Local play: %s\n', cmd); + end + system(cmd); +end + +function remote_capture(fn, cfg, t) + if cfg.ssh + cmd = sprintf('ssh %s arecord -q -D%s %s -d %d %s/%s &', ... + cfg.user, cfg.dev, cfg.fmt, t, cfg.dir, fn); + fprintf('Remote capture: %s\n', cmd); + else + cmd = sprintf('arecord -q -D%s %s -d %d %s/%s &', ... + cfg.dev, cfg.fmt, t, cfg.dir, fn); + fprintf('Local capture: %s\n', cmd); + end + system(cmd); +end + +function play = meas_remote_play_config() + source mls_play_config.txt; + fprintf('\nThe setttings for remote playback are\n'); + fprintf('Use ssh : %d\n', play.ssh); + fprintf('User : %s\n', play.user); + fprintf('Directory : %s\n', play.dir); + fprintf('Device : %s\n', play.dev); + fprintf('Channels : %d\n', play.nch); +end + +function rec = meas_remote_rec_config(fs, fmt) + source mls_rec_config.txt; + rec.fmt = sprintf('-t wav -c %d -f %s -r %d', ... + rec.nch, fmt, fs); + + fprintf('\nThe setttings for remote capture are\n'); + fprintf('Use ssh : %d\n', rec.ssh); + fprintf('User : %s\n', rec.user); + fprintf('Directory : %s\n', rec.dir); + fprintf('Device : %s\n', rec.dev); + fprintf('format : %s\n', rec.fmt); + fprintf('Channels : %d\n', rec.nch); +end + +function [x, seed] = mlsp12(seed, n) + +% Based on book Numerical Recipes in C, chapter 7.4 Generation of +% random bits method II p. 298-299 example and 12 bit primitive +% polynomial (12, 6, 4, 1, 0) + + x = zeros(1,n); + ib1 = 2^(1-1); + ib4 = 2^(4-1); + ib6 = 2^(6-1); + ib12 = 2^(12-1); + mask = ib1 + ib4 + ib6 + ib12; + + for i = 1:n + if bitand(seed, ib12) + seed = bitor(bitxor(seed, mask) * 2 , ib1); + x(i) = 1; + else + seed = seed * 2; + x(i) = 0; + end + end +end diff --git a/tune/eq/mls_play_config.txt b/tune/eq/mls_play_config.txt new file mode 100644 index 000000000000..5f7a8d0e3ae3 --- /dev/null +++ b/tune/eq/mls_play_config.txt @@ -0,0 +1,5 @@ +play.ssh = 0; % Set to use remote ssh commands +play.user = ''; % Set user@domain for ssh +play.dir = '/tmp'; % directory for temporary files +play.dev = 'hw:0,0'; % Audio device for playback +play.nch = 2; % Number of playback channels to test diff --git a/tune/eq/mls_rec_config.txt b/tune/eq/mls_rec_config.txt new file mode 100644 index 000000000000..70afd2664f57 --- /dev/null +++ b/tune/eq/mls_rec_config.txt @@ -0,0 +1,5 @@ +rec.ssh = 0; % Set to 1 for remote capture +rec.user = ''; % Set to user@domain for ssh +rec.dir = '/tmp'; % Directory for temporary files +rec.dev = 'hw:0,0'; % Audio capture device +rec.nch = 2; % Number audio capture channels to use From 27281d75e72529165cc3609aaf5a95806b078737 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 9 Oct 2018 15:12:12 +0300 Subject: [PATCH 269/324] Topology: Add DMIC capture pipeline with gain and high-pass filter This patch adds topology sof-apl-eq-dmic to help testing acoustical audio capture via DMIC or work as example for other machine drivers. The capture format is set as four channels, S32_LE, 48 kHz. The IIR EQ is a 2nd order Butterworth high-pass with cut-off frequency at 50 Hz to suppress non-audible lowest frequencies. The EQ provides additional +20 dB gain to avoid the recording to sound too silent. The IIR EQ or additional FIR EQ instance can when needed provide other form factor specific equalization. Signed-off-by: Seppo Ingalsuo --- topology/Makefile.am | 6 +- topology/m4/eq_fir_coef_flat.m4 | 6 ++ topology/m4/eq_iir_coef_flat.m4 | 10 +++ .../eq_iir_coef_highpass_50hz_20db_48khz.m4 | 10 +++ topology/sof-apl-eq-dmic.m4 | 75 +++++++++++++++++++ topology/sof/pipe-eq-capture.m4 | 74 ++++++++++++++++++ 6 files changed, 179 insertions(+), 2 deletions(-) create mode 100644 topology/m4/eq_fir_coef_flat.m4 create mode 100644 topology/m4/eq_iir_coef_flat.m4 create mode 100644 topology/m4/eq_iir_coef_highpass_50hz_20db_48khz.m4 create mode 100644 topology/sof-apl-eq-dmic.m4 create mode 100644 topology/sof/pipe-eq-capture.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 22191c0fd215..3598055d5e63 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -39,7 +39,8 @@ MACHINES = \ sof-apl-da7219.tplg \ sof-glk-da7219.tplg \ sof-icl-nocodec.tplg \ - sof-apl-eq-pcm512x.tplg + sof-apl-eq-pcm512x.tplg \ + sof-apl-eq-dmic.tplg # Uncomment the following line if you want to debug conf files .PRECIOUS: %.conf @@ -79,4 +80,5 @@ EXTRA_DIST = \ sof-apl-da7219.m4 \ sof-glk-da7219.m4 \ sof-icl-nocodec.m4 \ - sof-apl-eq-pcm512x.m4 + sof-apl-eq-pcm512x.m4 \ + sof-apl-eq-dmic.m4 diff --git a/topology/m4/eq_fir_coef_flat.m4 b/topology/m4/eq_fir_coef_flat.m4 new file mode 100644 index 000000000000..c7ae5d6309af --- /dev/null +++ b/topology/m4/eq_fir_coef_flat.m4 @@ -0,0 +1,6 @@ +# Flat FIR EQ 11-Oct-2018 +CONTROLBYTES_PRIV(EQFIR_priv, +` bytes "0x18,0x00,0x00,0x00,0x02,0x00,0x01,0x00,' +` 0x00,0x00,0x00,0x00,0x04,0x00,0xff,0xff,' +` 0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00"' +) diff --git a/topology/m4/eq_iir_coef_flat.m4 b/topology/m4/eq_iir_coef_flat.m4 new file mode 100644 index 000000000000..12769abd37f4 --- /dev/null +++ b/topology/m4/eq_iir_coef_flat.m4 @@ -0,0 +1,10 @@ +# Flat IIR EQ 11-Oct-2018 +CONTROLBYTES_PRIV(EQIIR_priv, +` bytes "0x38,0x00,0x00,0x00,0x02,0x00,0x00,0x00,' +` 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,' +` 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x9e,0x73,0x13,0x20,' +` 0x00,0x00,0x00,0x00,0xb2,0x7f,0x00,0x00"' +) diff --git a/topology/m4/eq_iir_coef_highpass_50hz_20db_48khz.m4 b/topology/m4/eq_iir_coef_highpass_50hz_20db_48khz.m4 new file mode 100644 index 000000000000..fcd73b5bd343 --- /dev/null +++ b/topology/m4/eq_iir_coef_highpass_50hz_20db_48khz.m4 @@ -0,0 +1,10 @@ +# 50 Hz 2nd order high-pass and +20 dB gain 09-Oct-2018 +CONTROLBYTES_PRIV(EQIIR_priv, +` bytes "0x38,0x00,0x00,0x00,0x02,0x00,0x00,0x00,' +` 0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,' +` 0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,' +` 0x01,0x00,0x00,0x00,0x63,0xf3,0x96,0xc0,' +` 0xc6,0x59,0x68,0x7f,0x6d,0x89,0xed,0x1f,' +` 0x27,0xed,0x24,0xc0,0x6d,0x89,0xed,0x1f,' +` 0xfc,0xff,0xff,0xff,0xd0,0x4f,0x00,0x00"' +) diff --git a/topology/sof-apl-eq-dmic.m4 b/topology/sof-apl-eq-dmic.m4 new file mode 100644 index 000000000000..7768af44fa14 --- /dev/null +++ b/topology/sof-apl-eq-dmic.m4 @@ -0,0 +1,75 @@ +# +# Topology for Apollo Lake with direct attach digital microphones array +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`platform/intel/bxt.m4') +include(`platform/intel/dmic.m4') + +# +# Define the pipelines +# +# PCM6 <---- volume <----- DMIC6 (DMIC01) +# + +dnl PIPELINE_PCM_ADD(pipeline, +dnl pipe id, pcm, max channels, format, +dnl frames, deadline, priority, core) + + +# Passthrough capture pipeline 13 on PCM 6 using max 4 channels. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-eq-capture.m4, + 1, 6, 4, s32le, + 48, 1000, 0, 0) + +# +# DAIs configuration +# + +dnl DAI_ADD(pipeline, +dnl pipe id, dai type, dai_index, dai_be, +dnl buffer, periods, format, +dnl frames, deadline, priority, core) + + +# capture DAI is DMIC 0 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, DMIC, 0, NoCodec-6, + PIPELINE_SINK_1, 2, s32le, + 48, 1000, 0, 0) + +dnl PCM_DUPLEX_ADD(name, pcm_id, playback, capture) + +dnl PCM_CAPTURE_ADD(name, pipeline, capture) +PCM_CAPTURE_ADD(DMIC01, 6, PIPELINE_PCM_1) + +# +# BE configurations - overrides config in ACPI if present +# + +dnl DAI_CONFIG(type, dai_index, link_id, name, ssp_config/dmic_config) + +DAI_CONFIG(DMIC, 0, 6, NoCodec-6, + dnl DMIC_CONFIG(driver_version, clk_min, clk_mac, duty_min, duty_max, + dnl sample_rate, + dnl fifo word length, type, dai_index, pdm controller config) + DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, + dnl DMIC_WORD_LENGTH(frame_format) + DMIC_WORD_LENGTH(s32le), DMIC, 0, + dnl PDM_CONFIG(type, dai_index, num pdm active, pdm tuples list) + dnl STEREO_PDM0 is a pre-defined pdm config for stereo capture + PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) + diff --git a/topology/sof/pipe-eq-capture.m4 b/topology/sof/pipe-eq-capture.m4 new file mode 100644 index 000000000000..5b415f08f640 --- /dev/null +++ b/topology/sof/pipe-eq-capture.m4 @@ -0,0 +1,74 @@ +# Capture Passthrough Pipeline and PCM +# +# Pipeline Endpoints for connection are :- +# +# host PCM_C <-- B0 <-- sink DAI0 + +# Include topology builder +include(`utils.m4') +include(`buffer.m4') +include(`pcm.m4') +include(`dai.m4') +include(`pipeline.m4') +include(`bytecontrol.m4') +include(`eq_iir.m4') + +# +# Controls +# + +# Use 50 Hz highpass response with +20 dB gain +include(`eq_iir_coef_highpass_50hz_20db_48khz.m4') + +# EQ Bytes control with max value of 255 +C_CONTROLBYTES(EQIIR, PIPELINE_ID, + CONTROLBYTES_OPS(bytes, 258 binds the mixer control to bytes get/put handlers, 258, 258), + CONTROLBYTES_EXTOPS(258 binds the mixer control to bytes get/put handlers, 258, 258), + , , , + CONTROLBYTES_MAX(, 316), + , + EQIIR_priv) + +# +# Components and Buffers +# + +# Host "Highpass Capture" PCM +# with 0 sink and 2 source periods +W_PCM_CAPTURE(PCM_ID, Highpass Capture, 0, 2, 2) + +# "EQ 0" has 2 sink period and 2 source periods +W_EQ_IIR(0, PIPELINE_FORMAT, 2, 2, 2, LIST(` ', "EQIIR")) + +# Capture Buffers +W_BUFFER(0, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_PASS_MEM_CAP) + +W_BUFFER(1, COMP_BUFFER_SIZE(2, + COMP_SAMPLE_SIZE(PIPELINE_FORMAT), PIPELINE_CHANNELS, SCHEDULE_FRAMES), + PLATFORM_PASS_MEM_CAP) + +# +# Pipeline Graph +# +# host PCM_C <--- B1 <--- EQ_IIR 0 <-- B0 <-- sink DAI0 + +P_GRAPH(pipe-pass-capture-PIPELINE_ID, PIPELINE_ID, + LIST(` ', + `dapm(Highpass Capture PCM_ID, N_PCMC(PCM_ID))', + `dapm(N_PCMC(PCM_ID), N_BUFFER(1))', + `dapm(N_BUFFER(1), N_EQ_IIR(0))', + `dapm(N_EQ_IIR(0), N_BUFFER(0))')) + +# +# Pipeline Source and Sinks +# +indir(`define', concat(`PIPELINE_SINK_', PIPELINE_ID), N_BUFFER(0)) +indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Highpass Capture PCM_ID) + +# +# PCM Configuration +# + +PCM_CAPABILITIES(Highpass Capture PCM_ID, COMP_FORMAT_NAME(PIPELINE_FORMAT), 48000, 48000, PIPELINE_CHANNELS, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) From 0808765bf47a9a9a2648524d591eb93d743cb333 Mon Sep 17 00:00:00 2001 From: Jaska Uimonen Date: Thu, 11 Oct 2018 09:27:39 +0300 Subject: [PATCH 270/324] tests: add qa tests and rearrange other tests under one directory Previously we used to have tests scattered around, so let's put them under one directory to make things more clear. Now under top level test directory we have directories: audio - objective audio quality tests used to be under test/ qa - qa tests run by the CI new test component in soft repo topology - topology test file generation used to be under topology/tests Signed-off-by: Jaska Uimonen --- Makefile.am | 2 +- configure.ac | 2 +- test/{ => audio}/README | 0 test/{ => audio}/src_run.sh | 0 test/{ => audio}/src_test.m | 0 test/{ => audio}/src_test.sh | 0 test/{ => audio}/src_test_top.m | 0 test/{ => audio}/std_utils/aap_test_input.m | 0 test/{ => audio}/std_utils/aap_test_measure.m | 0 test/{ => audio}/std_utils/aip_test_input.m | 0 test/{ => audio}/std_utils/aip_test_measure.m | 0 test/{ => audio}/std_utils/dr_test_input.m | 0 test/{ => audio}/std_utils/dr_test_measure.m | 0 test/{ => audio}/std_utils/fr_test_input.m | 0 test/{ => audio}/std_utils/fr_test_measure.m | 0 test/{ => audio}/std_utils/g_test_input.m | 0 test/{ => audio}/std_utils/g_test_measure.m | 0 test/{ => audio}/std_utils/level_dbfs.m | 0 test/{ => audio}/std_utils/stdhpf.m | 0 test/{ => audio}/std_utils/stdhpf_get.m | 0 test/{ => audio}/std_utils/stdlpf.m | 0 test/{ => audio}/std_utils/stdlpf_get.m | 0 test/{ => audio}/std_utils/stdnotch.m | 0 test/{ => audio}/std_utils/stdnotch_get.m | 0 test/{ => audio}/std_utils/stdweight.m | 0 test/{ => audio}/std_utils/thdnf_test_input.m | 0 .../std_utils/thdnf_test_measure.m | 0 .../test_utils/chirp_test_analyze.m | 0 .../{ => audio}/test_utils/chirp_test_input.m | 0 test/{ => audio}/test_utils/delete_check.m | 0 .../test_utils/dither_and_quantize.m | 0 .../{ => audio}/test_utils/find_test_signal.m | 0 .../{ => audio}/test_utils/load_test_output.m | 0 test/{ => audio}/test_utils/mix_chirp.m | 0 test/{ => audio}/test_utils/mix_sweep.m | 0 test/{ => audio}/test_utils/mkdir_check.m | 0 test/{ => audio}/test_utils/multitone.m | 0 test/{ => audio}/test_utils/sync_chirp.m | 0 test/{ => audio}/test_utils/test_run.m | 0 test/{ => audio}/test_utils/write_test_data.m | 0 test/qa/run_test.sh | 208 ++++ test/qa/tests/common-test | 9 + .../functionality_test/capture_pcm_list.sh | 10 + .../tests/functionality_test/channel_test.sh | 29 + .../tests/functionality_test/check_aplay.sh | 12 + .../functionality_test/check_dma_trace.sh | 13 + .../check_dual_channels_playback.sh | 30 + .../check_line_in_out_playback.sh | 33 + .../check_modules_loading_time.sh | 17 + ...passthrough_pulseaudio_capture_function.sh | 22 + ...assthrough_pulseaudio_playback_function.sh | 18 + .../functionality_test/check_pcm_playback.sh | 36 + .../check_playback_after_modules_reloaded.sh | 15 + .../check_playback_function.sh | 29 + .../check_pulseaudio_capture_function.sh | 22 + .../check_pulseaudio_function.sh | 29 + .../check_pulseaudio_playback_function.sh | 18 + .../estimate_firmware_loaded_time.sh | 14 + .../get_mixer_properties.sh | 10 + .../functionality_test/modules_reload.sh | 51 + .../functionality_test/playback_pcm_list.sh | 10 + .../set_ADC_volume_to_maximum.sh | 10 + .../set_ADC_volume_to_minimum.sh | 10 + .../set_HP_volume_to_maximum.sh | 10 + .../set_HP_volume_to_minimum.sh | 10 + .../functionality_test/verify_capture_info.sh | 16 + .../verify_playback_pcm_list.sh | 11 + .../verify_sof_firmware_load.sh | 12 + .../verify_sof_firmware_presence.sh | 19 + .../verify_sof_firmware_version.sh | 13 + .../verify_sof_firmware_version_info.sh | 11 + .../verify_sound_modules.sh | 10 + .../verify_topology_load.sh | 11 + test/qa/tests/platform/apl/up/feature-test | 2 + test/qa/tests/platform/apl/up/tplg | 2 + .../asound_state/apl/asound.state.passthrough | 34 + .../asound_state/apl/asound.state.volume | 34 + .../asound_state/byt/asound.state.line | 1036 +++++++++++++++++ .../asound_state/byt/asound.state.passthrough | 1014 ++++++++++++++++ .../asound_state/byt/asound.state.pulse-c | 1024 ++++++++++++++++ .../asound_state/byt/asound.state.pulse-p | 1024 ++++++++++++++++ .../asound_state/byt/asound.state.volume | 1014 ++++++++++++++++ test/qa/tests/platform/byt/feature-test | 8 + .../qa/tests/platform/byt/minnow/feature-test | 7 + test/qa/tests/platform/byt/minnow/tplg | 3 + test/qa/tests/platform/byt/tplg | 7 + .../byt_smoke_test_48k16bit_passthrough.sh | 144 +++ .../stability_test/test_modules_reloadable.sh | 106 ++ {topology/test => test/topology}/Makefile.am | 8 +- {topology/test => test/topology}/test-all.m4 | 0 .../test => test/topology}/test-capture.m4 | 0 .../topology}/test-equalizer-playback-ssp.m4 | 0 .../test => test/topology}/test-playback.m4 | 0 .../topology}/test-tone-playback.m4 | 0 .../test => test/topology}/tplg-build.sh | 2 +- 95 files changed, 6244 insertions(+), 7 deletions(-) rename test/{ => audio}/README (100%) rename test/{ => audio}/src_run.sh (100%) rename test/{ => audio}/src_test.m (100%) rename test/{ => audio}/src_test.sh (100%) rename test/{ => audio}/src_test_top.m (100%) rename test/{ => audio}/std_utils/aap_test_input.m (100%) rename test/{ => audio}/std_utils/aap_test_measure.m (100%) rename test/{ => audio}/std_utils/aip_test_input.m (100%) rename test/{ => audio}/std_utils/aip_test_measure.m (100%) rename test/{ => audio}/std_utils/dr_test_input.m (100%) rename test/{ => audio}/std_utils/dr_test_measure.m (100%) rename test/{ => audio}/std_utils/fr_test_input.m (100%) rename test/{ => audio}/std_utils/fr_test_measure.m (100%) rename test/{ => audio}/std_utils/g_test_input.m (100%) rename test/{ => audio}/std_utils/g_test_measure.m (100%) rename test/{ => audio}/std_utils/level_dbfs.m (100%) rename test/{ => audio}/std_utils/stdhpf.m (100%) rename test/{ => audio}/std_utils/stdhpf_get.m (100%) rename test/{ => audio}/std_utils/stdlpf.m (100%) rename test/{ => audio}/std_utils/stdlpf_get.m (100%) rename test/{ => audio}/std_utils/stdnotch.m (100%) rename test/{ => audio}/std_utils/stdnotch_get.m (100%) rename test/{ => audio}/std_utils/stdweight.m (100%) rename test/{ => audio}/std_utils/thdnf_test_input.m (100%) rename test/{ => audio}/std_utils/thdnf_test_measure.m (100%) rename test/{ => audio}/test_utils/chirp_test_analyze.m (100%) rename test/{ => audio}/test_utils/chirp_test_input.m (100%) rename test/{ => audio}/test_utils/delete_check.m (100%) rename test/{ => audio}/test_utils/dither_and_quantize.m (100%) rename test/{ => audio}/test_utils/find_test_signal.m (100%) rename test/{ => audio}/test_utils/load_test_output.m (100%) rename test/{ => audio}/test_utils/mix_chirp.m (100%) rename test/{ => audio}/test_utils/mix_sweep.m (100%) rename test/{ => audio}/test_utils/mkdir_check.m (100%) rename test/{ => audio}/test_utils/multitone.m (100%) rename test/{ => audio}/test_utils/sync_chirp.m (100%) rename test/{ => audio}/test_utils/test_run.m (100%) rename test/{ => audio}/test_utils/write_test_data.m (100%) create mode 100755 test/qa/run_test.sh create mode 100644 test/qa/tests/common-test create mode 100755 test/qa/tests/functionality_test/capture_pcm_list.sh create mode 100755 test/qa/tests/functionality_test/channel_test.sh create mode 100755 test/qa/tests/functionality_test/check_aplay.sh create mode 100755 test/qa/tests/functionality_test/check_dma_trace.sh create mode 100755 test/qa/tests/functionality_test/check_dual_channels_playback.sh create mode 100755 test/qa/tests/functionality_test/check_line_in_out_playback.sh create mode 100755 test/qa/tests/functionality_test/check_modules_loading_time.sh create mode 100755 test/qa/tests/functionality_test/check_passthrough_pulseaudio_capture_function.sh create mode 100755 test/qa/tests/functionality_test/check_passthrough_pulseaudio_playback_function.sh create mode 100755 test/qa/tests/functionality_test/check_pcm_playback.sh create mode 100755 test/qa/tests/functionality_test/check_playback_after_modules_reloaded.sh create mode 100755 test/qa/tests/functionality_test/check_playback_function.sh create mode 100755 test/qa/tests/functionality_test/check_pulseaudio_capture_function.sh create mode 100755 test/qa/tests/functionality_test/check_pulseaudio_function.sh create mode 100755 test/qa/tests/functionality_test/check_pulseaudio_playback_function.sh create mode 100755 test/qa/tests/functionality_test/estimate_firmware_loaded_time.sh create mode 100755 test/qa/tests/functionality_test/get_mixer_properties.sh create mode 100755 test/qa/tests/functionality_test/modules_reload.sh create mode 100755 test/qa/tests/functionality_test/playback_pcm_list.sh create mode 100755 test/qa/tests/functionality_test/set_ADC_volume_to_maximum.sh create mode 100755 test/qa/tests/functionality_test/set_ADC_volume_to_minimum.sh create mode 100755 test/qa/tests/functionality_test/set_HP_volume_to_maximum.sh create mode 100755 test/qa/tests/functionality_test/set_HP_volume_to_minimum.sh create mode 100755 test/qa/tests/functionality_test/verify_capture_info.sh create mode 100755 test/qa/tests/functionality_test/verify_playback_pcm_list.sh create mode 100755 test/qa/tests/functionality_test/verify_sof_firmware_load.sh create mode 100755 test/qa/tests/functionality_test/verify_sof_firmware_presence.sh create mode 100755 test/qa/tests/functionality_test/verify_sof_firmware_version.sh create mode 100755 test/qa/tests/functionality_test/verify_sof_firmware_version_info.sh create mode 100755 test/qa/tests/functionality_test/verify_sound_modules.sh create mode 100755 test/qa/tests/functionality_test/verify_topology_load.sh create mode 100644 test/qa/tests/platform/apl/up/feature-test create mode 100644 test/qa/tests/platform/apl/up/tplg create mode 100644 test/qa/tests/platform/asound_state/apl/asound.state.passthrough create mode 100644 test/qa/tests/platform/asound_state/apl/asound.state.volume create mode 100644 test/qa/tests/platform/asound_state/byt/asound.state.line create mode 100644 test/qa/tests/platform/asound_state/byt/asound.state.passthrough create mode 100644 test/qa/tests/platform/asound_state/byt/asound.state.pulse-c create mode 100644 test/qa/tests/platform/asound_state/byt/asound.state.pulse-p create mode 100644 test/qa/tests/platform/asound_state/byt/asound.state.volume create mode 100644 test/qa/tests/platform/byt/feature-test create mode 100644 test/qa/tests/platform/byt/minnow/feature-test create mode 100644 test/qa/tests/platform/byt/minnow/tplg create mode 100644 test/qa/tests/platform/byt/tplg create mode 100755 test/qa/tests/smoke_test/byt_smoke_test_48k16bit_passthrough.sh create mode 100755 test/qa/tests/stability_test/test_modules_reloadable.sh rename {topology/test => test/topology}/Makefile.am (74%) rename {topology/test => test/topology}/test-all.m4 (100%) rename {topology/test => test/topology}/test-capture.m4 (100%) rename {topology/test => test/topology}/test-equalizer-playback-ssp.m4 (100%) rename {topology/test => test/topology}/test-playback.m4 (100%) rename {topology/test => test/topology}/test-tone-playback.m4 (100%) rename {topology/test => test/topology}/tplg-build.sh (98%) diff --git a/Makefile.am b/Makefile.am index f48e66f54047..6e2a1cac0028 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ SUBDIRS = rmbox topology eqctl -TESTDIR = topology/test +TESTDIR = test/topology tests: $(MAKE) -C $(TESTDIR) diff --git a/configure.ac b/configure.ac index 321c59c86d67..ed763c62fcde 100644 --- a/configure.ac +++ b/configure.ac @@ -27,7 +27,7 @@ AC_OUTPUT([ topology/platform/common/Makefile topology/m4/Makefile topology/sof/Makefile - topology/test/Makefile + test/topology/Makefile ]) echo " diff --git a/test/README b/test/audio/README similarity index 100% rename from test/README rename to test/audio/README diff --git a/test/src_run.sh b/test/audio/src_run.sh similarity index 100% rename from test/src_run.sh rename to test/audio/src_run.sh diff --git a/test/src_test.m b/test/audio/src_test.m similarity index 100% rename from test/src_test.m rename to test/audio/src_test.m diff --git a/test/src_test.sh b/test/audio/src_test.sh similarity index 100% rename from test/src_test.sh rename to test/audio/src_test.sh diff --git a/test/src_test_top.m b/test/audio/src_test_top.m similarity index 100% rename from test/src_test_top.m rename to test/audio/src_test_top.m diff --git a/test/std_utils/aap_test_input.m b/test/audio/std_utils/aap_test_input.m similarity index 100% rename from test/std_utils/aap_test_input.m rename to test/audio/std_utils/aap_test_input.m diff --git a/test/std_utils/aap_test_measure.m b/test/audio/std_utils/aap_test_measure.m similarity index 100% rename from test/std_utils/aap_test_measure.m rename to test/audio/std_utils/aap_test_measure.m diff --git a/test/std_utils/aip_test_input.m b/test/audio/std_utils/aip_test_input.m similarity index 100% rename from test/std_utils/aip_test_input.m rename to test/audio/std_utils/aip_test_input.m diff --git a/test/std_utils/aip_test_measure.m b/test/audio/std_utils/aip_test_measure.m similarity index 100% rename from test/std_utils/aip_test_measure.m rename to test/audio/std_utils/aip_test_measure.m diff --git a/test/std_utils/dr_test_input.m b/test/audio/std_utils/dr_test_input.m similarity index 100% rename from test/std_utils/dr_test_input.m rename to test/audio/std_utils/dr_test_input.m diff --git a/test/std_utils/dr_test_measure.m b/test/audio/std_utils/dr_test_measure.m similarity index 100% rename from test/std_utils/dr_test_measure.m rename to test/audio/std_utils/dr_test_measure.m diff --git a/test/std_utils/fr_test_input.m b/test/audio/std_utils/fr_test_input.m similarity index 100% rename from test/std_utils/fr_test_input.m rename to test/audio/std_utils/fr_test_input.m diff --git a/test/std_utils/fr_test_measure.m b/test/audio/std_utils/fr_test_measure.m similarity index 100% rename from test/std_utils/fr_test_measure.m rename to test/audio/std_utils/fr_test_measure.m diff --git a/test/std_utils/g_test_input.m b/test/audio/std_utils/g_test_input.m similarity index 100% rename from test/std_utils/g_test_input.m rename to test/audio/std_utils/g_test_input.m diff --git a/test/std_utils/g_test_measure.m b/test/audio/std_utils/g_test_measure.m similarity index 100% rename from test/std_utils/g_test_measure.m rename to test/audio/std_utils/g_test_measure.m diff --git a/test/std_utils/level_dbfs.m b/test/audio/std_utils/level_dbfs.m similarity index 100% rename from test/std_utils/level_dbfs.m rename to test/audio/std_utils/level_dbfs.m diff --git a/test/std_utils/stdhpf.m b/test/audio/std_utils/stdhpf.m similarity index 100% rename from test/std_utils/stdhpf.m rename to test/audio/std_utils/stdhpf.m diff --git a/test/std_utils/stdhpf_get.m b/test/audio/std_utils/stdhpf_get.m similarity index 100% rename from test/std_utils/stdhpf_get.m rename to test/audio/std_utils/stdhpf_get.m diff --git a/test/std_utils/stdlpf.m b/test/audio/std_utils/stdlpf.m similarity index 100% rename from test/std_utils/stdlpf.m rename to test/audio/std_utils/stdlpf.m diff --git a/test/std_utils/stdlpf_get.m b/test/audio/std_utils/stdlpf_get.m similarity index 100% rename from test/std_utils/stdlpf_get.m rename to test/audio/std_utils/stdlpf_get.m diff --git a/test/std_utils/stdnotch.m b/test/audio/std_utils/stdnotch.m similarity index 100% rename from test/std_utils/stdnotch.m rename to test/audio/std_utils/stdnotch.m diff --git a/test/std_utils/stdnotch_get.m b/test/audio/std_utils/stdnotch_get.m similarity index 100% rename from test/std_utils/stdnotch_get.m rename to test/audio/std_utils/stdnotch_get.m diff --git a/test/std_utils/stdweight.m b/test/audio/std_utils/stdweight.m similarity index 100% rename from test/std_utils/stdweight.m rename to test/audio/std_utils/stdweight.m diff --git a/test/std_utils/thdnf_test_input.m b/test/audio/std_utils/thdnf_test_input.m similarity index 100% rename from test/std_utils/thdnf_test_input.m rename to test/audio/std_utils/thdnf_test_input.m diff --git a/test/std_utils/thdnf_test_measure.m b/test/audio/std_utils/thdnf_test_measure.m similarity index 100% rename from test/std_utils/thdnf_test_measure.m rename to test/audio/std_utils/thdnf_test_measure.m diff --git a/test/test_utils/chirp_test_analyze.m b/test/audio/test_utils/chirp_test_analyze.m similarity index 100% rename from test/test_utils/chirp_test_analyze.m rename to test/audio/test_utils/chirp_test_analyze.m diff --git a/test/test_utils/chirp_test_input.m b/test/audio/test_utils/chirp_test_input.m similarity index 100% rename from test/test_utils/chirp_test_input.m rename to test/audio/test_utils/chirp_test_input.m diff --git a/test/test_utils/delete_check.m b/test/audio/test_utils/delete_check.m similarity index 100% rename from test/test_utils/delete_check.m rename to test/audio/test_utils/delete_check.m diff --git a/test/test_utils/dither_and_quantize.m b/test/audio/test_utils/dither_and_quantize.m similarity index 100% rename from test/test_utils/dither_and_quantize.m rename to test/audio/test_utils/dither_and_quantize.m diff --git a/test/test_utils/find_test_signal.m b/test/audio/test_utils/find_test_signal.m similarity index 100% rename from test/test_utils/find_test_signal.m rename to test/audio/test_utils/find_test_signal.m diff --git a/test/test_utils/load_test_output.m b/test/audio/test_utils/load_test_output.m similarity index 100% rename from test/test_utils/load_test_output.m rename to test/audio/test_utils/load_test_output.m diff --git a/test/test_utils/mix_chirp.m b/test/audio/test_utils/mix_chirp.m similarity index 100% rename from test/test_utils/mix_chirp.m rename to test/audio/test_utils/mix_chirp.m diff --git a/test/test_utils/mix_sweep.m b/test/audio/test_utils/mix_sweep.m similarity index 100% rename from test/test_utils/mix_sweep.m rename to test/audio/test_utils/mix_sweep.m diff --git a/test/test_utils/mkdir_check.m b/test/audio/test_utils/mkdir_check.m similarity index 100% rename from test/test_utils/mkdir_check.m rename to test/audio/test_utils/mkdir_check.m diff --git a/test/test_utils/multitone.m b/test/audio/test_utils/multitone.m similarity index 100% rename from test/test_utils/multitone.m rename to test/audio/test_utils/multitone.m diff --git a/test/test_utils/sync_chirp.m b/test/audio/test_utils/sync_chirp.m similarity index 100% rename from test/test_utils/sync_chirp.m rename to test/audio/test_utils/sync_chirp.m diff --git a/test/test_utils/test_run.m b/test/audio/test_utils/test_run.m similarity index 100% rename from test/test_utils/test_run.m rename to test/audio/test_utils/test_run.m diff --git a/test/test_utils/write_test_data.m b/test/audio/test_utils/write_test_data.m similarity index 100% rename from test/test_utils/write_test_data.m rename to test/audio/test_utils/write_test_data.m diff --git a/test/qa/run_test.sh b/test/qa/run_test.sh new file mode 100755 index 000000000000..8394db45b5a0 --- /dev/null +++ b/test/qa/run_test.sh @@ -0,0 +1,208 @@ +#!/bin/bash + +CURRENT_PATH=`pwd` +FEATURE_PASS=0 +FEATURE_CNT=0 +TEST_TYPE="functionality_test" +FIRMWARE_PATH="/lib/firmware/intel" +AMIXER_PATH="tests/platform/asound_state" +PLATFORM_PATH="tests/platform" +DATE=`date +%Y_%m_%d_%H_%M` +para=$1 + +switch_tplg() { + + # get next tplg name + tplg_num=`cat $CURRENT_PATH/test_status/tplg |awk -F ' ' '{print $1}'` + tplg_next=$(($tplg_num + 1)) + if [ $tplg_next -gt $tplg_max ]; then + echo "Done the test for all supported topologies" + echo "done" > test_status/status + exit 0 + fi + + tplg_name=`sed -n ${tplg_next}p $CURRENT_PATH/$PLATFORM_PATH/$PLATFORM/$MACHINE/tplg` + echo "continue" > $CURRENT_PATH/test_status/status + echo $tplg_next > $CURRENT_PATH/test_status/tplg + + # relink the tplg + if [ $PLATFORM == "byt" -a $MACHINE == "minnow" ]; then + sudo ln -fs $FIRMWARE_PATH/topology/$tplg_name $FIRMWARE_PATH/sof-$PLATFORM-rt5651.tplg + elif [ $PLATFORM == "apl" -a $MACHINE == "up" ]; then + sudo ln -fs $FIRMWARE_PATH/topology/$tplg_name $FIRMWARE_PATH/sof-$PLATFORM-nocodec.tplg + else + sudo ln -fs $FIRMWARE_PATH/topology/$tplg_name $FIRMWARE_PATH/sof-$PLATFORM.tplg + fi + # system will auto reboot for another tplg test + sleep 2 + sudo reboot +} + +feature_test_list() { + tplg_file=`find $FIRMWARE_PATH -name "sof-*.tplg"` + link_path=`readlink $tplg_file` + link_file=${link_path##*/} + + echo "now is testing $link_file" >> $CURRENT_PATH/$test_report + while read line + do + feature_test $line + done < $CURRENT_PATH/$PLATFORM_PATH/$PLATFORM/$MACHINE/feature-test + switch_tplg +} + +run_test() { + #get tplg name + cd $FIRMWARE_PATH + [[ $def_tplg =~ ^/ ]] && cur_tplg=$def_tplg || cur_tplg=`pwd`/$def_tplg + while [ -h $cur_tplg ] + do + b=`ls -ld $cur_tplg|awk '{print $NF}'` + c=`ls -ld $cur_tplg|awk '{print $(NF-2)}'` + [[ $b =~ ^/ ]] && cur_tplg=$b || cur_tplg=`dirname $c`/$b + done + tplg_name=`echo ${cur_tplg:29}` + cd - + + # parse the tplg + SSP=`echo $tplg_name |awk -F "-" '{print $2}'` + MODE=`echo $tplg_name |awk -F "-" '{print $5}'` + PIPELINE=`echo $tplg_name |awk -F "-" '{print $6}'` + FORMAT_INPUT=`echo $tplg_name |awk -F "-" '{print $7}'` + FORMAT_OUTPUT=`echo $tplg_name |awk -F "-" '{print $8}'` + RATE=`echo $tplg_name |awk -F "-" '{print $9}'` + MCLK=`echo $tplg_name |awk -F "-" '{print $10}'` + CODEC=`echo $tplg_name |awk -F "-" '{print $11}'` + + # run test cases for specfied tplg + alsactl restore -f $CURRENT_PATH/$AMIXER_PATH/$PLATFORM/asound.state.$PIPELINE # alsa setting + feature_test_list # run tplg test +} + +feature_test() { + FEATURE_CUT=$((FEATURE_CNT+1)) + TEST_SUIT=$1 + TEST_CASE=$2 + TEST_PARA=$3 + if [ $TEST_SUIT == "PCM_playback" ] || [ $TEST_SUIT == "pulseaudio" ]; then + bash $CURRENT_PATH/tests/$TEST_TYPE/$TEST_CASE.sh $RATE $FORMAT_INPUT $PIPELINE $PLATFORM # run test + cat playback.result | while read line + do + TEST_CASE=`echo $line|awk -F " " '{ print $1}'` + if [[ $line =~ FAIL ]]; then + echo "$TEST_CASE FAIL" + echo "testsuite_"$TEST_SUIT"_testcase_"$TEST_CASE" testtype_"$TEST_TYPE" FAIL" >> $CURRENT_PATH/$test_report + else + echo "$TEST_CASE PASS" + echo "testsuite_"$TEST_SUIT"_testcase_"$TEST_CASE" testtype_"$TEST_TYPE" PASS" >> $CURRENT_PATH/$test_report + fi + done + else + bash $CURRENT_PATH/tests/$TEST_TYPE/$TEST_CASE.sh $TEST_PARA # run test + if [ $? -eq 0 ]; then + FEATURE_PASS=$((FEATURE_PASS+1)) + echo "$TEST_CASE PASS" + echo "testsuite_"$TEST_SUIT"_testcase_"$TEST_CASE" testtype_"$TEST_TYPE" PASS" >> $CURRENT_PATH/$test_report + else + echo "$TEST_CASE FAIL" + echo "testsuite_"$TEST_SUIT"_testcase_"$TEST_CASE" testtype_"$TEST_TYPE" FAIL" >> $CURRENT_PATH/$test_report + fi + fi + sleep 2 +} + +feature_test_common_list(){ + + echo "now is doing the common test on $PLATFORM" >> $CURRENT_PATH/$test_report + while read line + do + feature_test $line + done < tests/common-test + + # run feature test + run_test +} + +check_status() { + tplg_max=`awk 'END{print NR}' $CURRENT_PATH/$PLATFORM_PATH/$PLATFORM/$MACHINE/tplg` + if [ -f test_status/status ]; then + status=`cat test_status/status |awk -F ' ' '{print $1}'` + if [ $status == "new" ]; then + if [ ! -d "report" ]; then + mkdir report + fi + test_report=report/$DATE-$PLATFORM + echo $test_report > test_status/report + tplg_num=1 + echo $tplg_num > test_status/tplg + feature_test_common_list + elif [ $status == "continue" ]; then + test_report=`cat test_status/report |awk -F ' ' '{print $1}'` + run_test + elif [ $status == "done" ]; then + echo "new" > test_status/status + check_status + fi + else + read -p "Unable to get the test status, do you want to reset the test: Y/N?" answer + case $answer in + Y | y) + reset_status;; + N | n) + echo "Test Exit" + exit 0;; + *) + echo "error choice" + check_status;; + esac + fi +} + +# get platform info +get_platform() { + + MOD_VER=`lscpu |grep "Model name" |awk -F " " '{print $6}'` + if [ $MOD_VER == "E3826" ] || [ $MOD_VER == "E3845" ]; then + PLATFORM="byt" + MACHINE="minnow" + def_tplg="sof-byt.tplg" + check_status + elif [ $MOD_VER == "N4200" ]; then + PLATFORM="apl" + MACHINE="up" + MCLK=24576k + def_tplg="sof-apl-nocodec.tplg" + check_status + elif [ $MOD_VER == "0000" ]; then + PLATFORM="cnl" + MACHINE="cnl" + MCLK=24000k + def_tplg="sof-cnl-nocodec.tplg" + check_status + else + echo "no matched platform, please confirm it" + exit 1 + fi +} + +# reset the test status +reset_status() { + if [ ! -d "test_status" ]; then + mkdir test_status + fi + echo "new" > test_status/status + echo "1" > test_status/tplg + get_platform +} + +function main(){ + sleep 5 + + if [ "$para" == "-r" ]; then + reset_status + fi + get_platform +} + +#Audio CI call main function for testing +main diff --git a/test/qa/tests/common-test b/test/qa/tests/common-test new file mode 100644 index 000000000000..ddbc43fd75a4 --- /dev/null +++ b/test/qa/tests/common-test @@ -0,0 +1,9 @@ +information_detection verify_sof_firmware_presence +information_detection verify_sof_firmware_load +information_detection verify_sof_firmware_version_info +information_detection playback_pcm_list +information_detection verify_sound_modules +information_detection capture_pcm_list +information_detection verify_playback_pcm_list +aplay_check check_aplay +dma_trace check_dma_trace diff --git a/test/qa/tests/functionality_test/capture_pcm_list.sh b/test/qa/tests/functionality_test/capture_pcm_list.sh new file mode 100755 index 000000000000..d32cdcfda8a5 --- /dev/null +++ b/test/qa/tests/functionality_test/capture_pcm_list.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Check capture devices with Audio Legacy +arecord -l |grep "device"> /dev/null +if [ $? != 0 ]; then + echo "Fail: Can not get capture pcm list." + exit 1 +else + exit 0 +fi diff --git a/test/qa/tests/functionality_test/channel_test.sh b/test/qa/tests/functionality_test/channel_test.sh new file mode 100755 index 000000000000..9bd95de386a1 --- /dev/null +++ b/test/qa/tests/functionality_test/channel_test.sh @@ -0,0 +1,29 @@ +#!bin/bash + +# channel test for low latency +rm -rf playback.result + +input_freq=12000 +bit=S32_LE +# Check Media Playback Pipeline +alsabat -D hw:0,0 -c 2 -F $input_freq:$input_freq -f $bit +if [ $? != 0 ]; then + echo "Fail: channel test failed with low latency pipeline ." + echo "channel_test_with_low_latency pipeline_"$input_freq:$input_freq"_Bit_"$bit" FAIL" >> playback.result +else + echo "channel_test_with_low_latency_pipeline_"$input_freq:$input_freq"_Bit_"$bit" PASS" >> playback.result +fi + +# media pipeline check +frequency_L=900 +frequency_R=12000 +bit=S32_LE +# Check Media Playback Pipeline +alsabat -P hw:0,1 -C hw:0,0 -c 2 -F $frequency_L:$frequency_R -f $bit +if [ $? != 0 ]; then + echo "Fail: channel test failed with media pipeline ." + echo "channel_test_with_media_pipeline_"$frequency_L:$frequency_R"_Bit_"$bit" FAIL" >> playback.result +else + echo "channel_test_with_media_pipeline_"$frequency_L:$frequency_R"_Bit_"$bit" PASS" >> playback.result +fi + diff --git a/test/qa/tests/functionality_test/check_aplay.sh b/test/qa/tests/functionality_test/check_aplay.sh new file mode 100755 index 000000000000..bdc5d28f72e0 --- /dev/null +++ b/test/qa/tests/functionality_test/check_aplay.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Check aplay function +aplay -D hw:0,0 -f dat -d 5 -c 2 -r 48000 /dev/zero +if [ $? != 0 ]; then + echo "Aplay FAIL" + exit 1 +else + echo "APlay PASS" + exit 0 +fi + diff --git a/test/qa/tests/functionality_test/check_dma_trace.sh b/test/qa/tests/functionality_test/check_dma_trace.sh new file mode 100755 index 000000000000..a67425922eea --- /dev/null +++ b/test/qa/tests/functionality_test/check_dma_trace.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# check dma trace output +sudo rmbox -t > rmbox.log & sleep 2 ; pkill -9 rmbox +# get size of trace log +size=`du -k rmbox.log |awk '{print $1}'` + +if [ $size -gt 1 ]; then + exit 0 +else + exit 1 +fi +rm -f rmbox.log diff --git a/test/qa/tests/functionality_test/check_dual_channels_playback.sh b/test/qa/tests/functionality_test/check_dual_channels_playback.sh new file mode 100755 index 000000000000..a54be5106608 --- /dev/null +++ b/test/qa/tests/functionality_test/check_dual_channels_playback.sh @@ -0,0 +1,30 @@ +#/bin/bash + +# Check two channel playabck function +rm -rf playback.result +RATE=$1 +if [ $RATE == "48k" ]; then + RATE=48000 +fi +FORMAT=$2 +if [ $FORMAT == "s16le" ]; then + FORMAT=dat +elif [ $FORMAT == "s24le" ]; then + FORMAT=S24_3LE +elif [ $FORMAT == "s32le" ]; then + FORMAT=S32_LE +fi + +PIPELINE_TYPE=$3 +PLATFORM=$4 + +# amixer setting for line in/out mode +alsabat -D hw:0,0 -r $RATE -c 2 -f $FORMAT -F 1500 + if [ $? != 0 ]; then + echo "Fail: dual channels playback test failed." + echo "Check_"$PIPELINE_TYPE"_dual_channels_"$RATE"_"$FORMAT"_playback FAIL" >> playback.result + exit 1 + else + echo "Check_"$PIPELINE_TYPE"_dual_channels_"$RATE"_"$FORMAT"_playback PASS" >> playback.result + exit 0 + fi diff --git a/test/qa/tests/functionality_test/check_line_in_out_playback.sh b/test/qa/tests/functionality_test/check_line_in_out_playback.sh new file mode 100755 index 000000000000..04df1061d44e --- /dev/null +++ b/test/qa/tests/functionality_test/check_line_in_out_playback.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Check line in/out function +rm -rf playback.result +RATE=$1 +if [ $RATE == "48K" ]; then + RATE=48000 +fi + +FORMAT=$2 +if [ $FORMAT == "s16le" ]; then + FORMAT=dat +elif [ $FORMAT == "s24le" ]; then + FORMAT=S24_LE +elif [ $FORMAT == "s32le" ]; then + FORMAT=S32_LE +fi + +PIPELINE_TYPE=$3 +PLATFORM=$4 + +# amixer setting for line in/out mode +alsactl restore -f asound_state/$PLATFORM/asound.state.line +sleep 2 +alsabat -D hw:0,0 -r $RATE -c 2 -f $FORMAT -F 1500 + if [ $? != 0 ]; then + echo "Fail: line in/out mode playback test failed." + echo "Check_"$PIPELINE_TYPE"_line_in_out_"$RATE"_"$FORMAT"_playback FAIL" >> playback.result + exit 1 + else + echo "Check_"$PIPELINE_TYPE"_line_in_out_"$RATE"_"$FORMAT"_playback PASS" >> playback.result + exit 0 + fi diff --git a/test/qa/tests/functionality_test/check_modules_loading_time.sh b/test/qa/tests/functionality_test/check_modules_loading_time.sh new file mode 100755 index 000000000000..181f19cce4b1 --- /dev/null +++ b/test/qa/tests/functionality_test/check_modules_loading_time.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# reloading the audio modules +criterion_time=50 + +(time modprobe sof_acpi_dev) >& rl_time.log +reload_time=`cat rl_time.log |grep "real" | awk -F '.' '{print $2}' |cut -c1-3` +echo $reload_time +if [ "$reload_time" -gt "$criterion_time" ]; then + exit 1 +else + exit 0 +fi + +sleep 2 + + diff --git a/test/qa/tests/functionality_test/check_passthrough_pulseaudio_capture_function.sh b/test/qa/tests/functionality_test/check_passthrough_pulseaudio_capture_function.sh new file mode 100755 index 000000000000..9c787ad9dacb --- /dev/null +++ b/test/qa/tests/functionality_test/check_passthrough_pulseaudio_capture_function.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Check capture function +ps -aux |grep pulseaudio +if [ $? != 0 ]; then + usr/bin/pulseaudio --system & + sleep 10 +else + echo "Pass: start pulseaudio server passed" +fi +alsactl restore -f asound_state/asound.state.pulse-c +sleep 2 +rm -rf playback.result +#inputsample=(8000 11025 12000 16000 18900 22050 24000 32000 44100 48000 64000 88200 96000 176400 192000) +alsabat -Phw:0,0 -r 48000 -c 2 -F 1500 -Cpulse +if [ $? != 0 ]; then + echo "Fail: pulseaudio capture failed with passthrough pipeline." + echo "Check_pulseaudio_capture FAIL" >> playback.result +else + echo "Check_pulseaudio_capture PASS" >> playback.result +fi + diff --git a/test/qa/tests/functionality_test/check_passthrough_pulseaudio_playback_function.sh b/test/qa/tests/functionality_test/check_passthrough_pulseaudio_playback_function.sh new file mode 100755 index 000000000000..bc4804b1e22f --- /dev/null +++ b/test/qa/tests/functionality_test/check_passthrough_pulseaudio_playback_function.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Check playback function +/usr/bin/pulseaudio --system & +sleep 10 + +alsactl restore -f asound_state/asound.state.pulse-p +sleep 2 +rm -rf playback.result +#inputsample=(8000 11025 12000 16000 18900 22050 24000 32000 44100 48000 64000 88200 96000 176400 192000) +alsabat -Ppulse -r 48000 -c 2 -F 1500 -Chw:0,0 +if [ $? != 0 ]; then + echo "Fail: pulseaudio playback failed with passthrough pipeline." + echo "Check_pulseaudio_Playback FAIL" >> playback.result +else + echo "Check_pulseaudio_Playback PASS" >> playback.result +fi + diff --git a/test/qa/tests/functionality_test/check_pcm_playback.sh b/test/qa/tests/functionality_test/check_pcm_playback.sh new file mode 100755 index 000000000000..313b994c6e6a --- /dev/null +++ b/test/qa/tests/functionality_test/check_pcm_playback.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Check playback function +FREQ=("17" "31" "67" "131" "257" "521" "997" "1033" "2069" "4139" "8273" "16547") + +rm -rf playback.result +RATE=$1 +if [ $RATE == "48k" ]; then + RATE=48000 +fi + +FORMAT=$2 +if [ $FORMAT == "s16le" ]; then + FORMAT=dat +elif [ $FORMAT == "s24le" ]; then + FORMAT=S24_LE +elif [ $FORMAT == "s32le" ]; then + FORMAT=S32_LE +fi + +PIPELINE_TYPE=$3 +PLATFORM=$4 + +# Check passthrough Playback Pipeline +for freq in "${FREQ[@]}" +do + alsabat -D hw:0,0 -r $RATE -c 2 -f $FORMAT -F $freq + if [ $? != 0 ]; then + echo "Fail: playback failed with "$PIPELINE_TYPE" pipeline." + echo "Check_"$PIPELINE_TYPE"_Playback_"$RATE"_format_"$FORMAT"_freq_"$freq" FAIL" >> playback.result + else + echo "Check_"$PIPELINE_TYPE"_Playback_"$RATE"_format_"$FORMAT"_freq_"$freq" PASS" >> playback.result + echo "Check_"$PIPELINE_TYPE"_Capture_"$RATE"_format_"$FORMAT"_freq_"$freq" PASS" >> playback.result + fi +done + diff --git a/test/qa/tests/functionality_test/check_playback_after_modules_reloaded.sh b/test/qa/tests/functionality_test/check_playback_after_modules_reloaded.sh new file mode 100755 index 000000000000..de11ea67d941 --- /dev/null +++ b/test/qa/tests/functionality_test/check_playback_after_modules_reloaded.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +#check playback after modules reloaded +pkill -9 alsabat +sleep 2 + +alsactl restore -f asound_state/asound.state-1.0-passthrough-16bit +sleep 2 +alsabat -D hw:0,0 -r 48000 -c 2 -f dat -F 1500 +if [ $? -eq 0 ]; then + exit 0 +else + exit 1 +fi + diff --git a/test/qa/tests/functionality_test/check_playback_function.sh b/test/qa/tests/functionality_test/check_playback_function.sh new file mode 100755 index 000000000000..4edc32613364 --- /dev/null +++ b/test/qa/tests/functionality_test/check_playback_function.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Check playback function +rm -f playback.tmp +#inputsample=(8000 11025 12000 16000 18900 22050 24000 32000 44100 48000 64000 88200 96000 176400 192000) +inputsample=(8000, 16000, 24000, 32000, 44100, 48000) +bitlist=(U8 S16_LE S24_3LE S32_LE) +# Check Media Playback Pipeline +for samplerate in ${inputsample[*]};do + for bit in ${bitlist[*]}; do + alsabat -P hw:0,1 -C hw:0,0 -r $samplerate -c 2 -f $bit + if [ $? != 0 ]; then + echo "Fail: playback failed with Media pipeline." + echo "Check_Media_Playback_Pipeline_Playback_"$samplerate"_Bit_"$bit" FAIL" >> playback.tmp + else + echo "Check_Media_Playback_Pipeline_Playback_"$samplerate"_Bit_"$bit" PASS" >> playback.tmp + fi + done +done +# Check Low Latency Playback Pipeline +for bit in S16_LE S24_3LE S32_LE ; do + alsabat -D hw:0,0 -r 48000 -c 2 -f $bit + if [ $? != 0 ]; then + echo "Fail: playback failed with low latency pipeline." + echo "Check_Low_Latency_Pipeline_Playback_48000_Bit_"$bit" FAIL" >> playback.tmp + else + echo "Check_Low_latency_Pipeline_Playback_48000_Bit_"$bit" PASS" >> playback.tmp + fi +done diff --git a/test/qa/tests/functionality_test/check_pulseaudio_capture_function.sh b/test/qa/tests/functionality_test/check_pulseaudio_capture_function.sh new file mode 100755 index 000000000000..9c787ad9dacb --- /dev/null +++ b/test/qa/tests/functionality_test/check_pulseaudio_capture_function.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# Check capture function +ps -aux |grep pulseaudio +if [ $? != 0 ]; then + usr/bin/pulseaudio --system & + sleep 10 +else + echo "Pass: start pulseaudio server passed" +fi +alsactl restore -f asound_state/asound.state.pulse-c +sleep 2 +rm -rf playback.result +#inputsample=(8000 11025 12000 16000 18900 22050 24000 32000 44100 48000 64000 88200 96000 176400 192000) +alsabat -Phw:0,0 -r 48000 -c 2 -F 1500 -Cpulse +if [ $? != 0 ]; then + echo "Fail: pulseaudio capture failed with passthrough pipeline." + echo "Check_pulseaudio_capture FAIL" >> playback.result +else + echo "Check_pulseaudio_capture PASS" >> playback.result +fi + diff --git a/test/qa/tests/functionality_test/check_pulseaudio_function.sh b/test/qa/tests/functionality_test/check_pulseaudio_function.sh new file mode 100755 index 000000000000..d3f42b983a9b --- /dev/null +++ b/test/qa/tests/functionality_test/check_pulseaudio_function.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Check playback function +rm -rf playback.result +#inputsample=(8000 11025 12000 16000 18900 22050 24000 32000 44100 48000 64000 88200 96000 176400 192000) +inputsample=(8000, 16000, 24000, 32000, 44100, 48000) +bitlist=(U8 S16_LE S24_3LE S32_LE) +# Check Media Playback Pipeline +for samplerate in ${inputsample[*]};do + for bit in ${bitlist[*]}; do + alsabat -P hw:0,1 -C hw:0,0 -r $samplerate -c 2 -f $bit + if [ $? != 0 ]; then + echo "Fail: playback failed with Media pipeline." + echo "Check_Media_Playback_Pipeline_Playback_"$samplerate"_Bit_"$bit" FAIL" >> playback.result + else + echo "Check_Media_Playback_Pipeline_Playback_"$samplerate"_Bit_"$bit" PASS" >> playback.result + fi + done +done +# Check Low Latency Playback Pipeline +for bit in S16_LE S24_3LE S32_LE ; do + alsabat -D hw:0,0 -r 48000 -c 2 -f $bit + if [ $? != 0 ]; then + echo "Fail: playback failed with low latency pipeline." + echo "Check_Low_Latency_Pipeline_Playback_48000_Bit_"$bit" FAIL" >> playback.result + else + echo "Check_Low_latency_Pipeline_Playback_48000_Bit_"$bit" PASS" >> playback.result + fi +done diff --git a/test/qa/tests/functionality_test/check_pulseaudio_playback_function.sh b/test/qa/tests/functionality_test/check_pulseaudio_playback_function.sh new file mode 100755 index 000000000000..bc4804b1e22f --- /dev/null +++ b/test/qa/tests/functionality_test/check_pulseaudio_playback_function.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Check playback function +/usr/bin/pulseaudio --system & +sleep 10 + +alsactl restore -f asound_state/asound.state.pulse-p +sleep 2 +rm -rf playback.result +#inputsample=(8000 11025 12000 16000 18900 22050 24000 32000 44100 48000 64000 88200 96000 176400 192000) +alsabat -Ppulse -r 48000 -c 2 -F 1500 -Chw:0,0 +if [ $? != 0 ]; then + echo "Fail: pulseaudio playback failed with passthrough pipeline." + echo "Check_pulseaudio_Playback FAIL" >> playback.result +else + echo "Check_pulseaudio_Playback PASS" >> playback.result +fi + diff --git a/test/qa/tests/functionality_test/estimate_firmware_loaded_time.sh b/test/qa/tests/functionality_test/estimate_firmware_loaded_time.sh new file mode 100755 index 000000000000..6e94e932acc3 --- /dev/null +++ b/test/qa/tests/functionality_test/estimate_firmware_loaded_time.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Estimate firmware loaded time +t2=`dmesg | grep "firmware boot complete" | awk -F"[" '{print $2}' | awk -F"]" '{print $1}'` +t1=`dmesg | grep "loading firmware" | awk -F"[" '{print $2}' | awk -F"]" '{print $1}'` +t=`echo "$t2 $t1" | awk '{print $1-$2}'` +# Firmware load time need less than 50ms +if [ $(echo "$t > 0.05" | bc) -eq 1 ]; then + echo "Fail: Firmware load timeout." + exit 1 +else + exit 0 +fi + diff --git a/test/qa/tests/functionality_test/get_mixer_properties.sh b/test/qa/tests/functionality_test/get_mixer_properties.sh new file mode 100755 index 000000000000..ddc9bf7a10ae --- /dev/null +++ b/test/qa/tests/functionality_test/get_mixer_properties.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +#Get mixer properties +amixer -D hw:sofbytcrrt5651 > /dev/null +if [ $? -ne 0 ]; then + echo "get mixer properties failed" + exit 1 +else + exit 0 +fi diff --git a/test/qa/tests/functionality_test/modules_reload.sh b/test/qa/tests/functionality_test/modules_reload.sh new file mode 100755 index 000000000000..a9e9d7bda9d9 --- /dev/null +++ b/test/qa/tests/functionality_test/modules_reload.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +PLATFORM=$1 + +lsmod |egrep "snd|sof" > lsmod.list + +SOF_MODULE=(sof_pci_dev sof_acpi_dev snd_soc_acpi_intel_match snd_sof_intel_byt snd_sof_intel_hsw snd_sof_intel_bdw snd_sof_intel_hda_common snd_sof_xtensa_dsp snd_soc_sst_bytcr_rt5640 snd_soc_sst_bytcr_rt5651 snd_soc_sst_cht_bsw_rt5645 snd_soc_sst_cht_bsw_rt5670 snd_soc_sst_byt_cht_da7213 snd_soc_sst_bxt_pcm512x snd_soc_sst_bxt_tdf8532 snd_soc_cnl_rt274 snd_sof_nocodec snd_sof snd_soc_rt5670 snd_soc_rt5645 snd_soc_rt5651 snd_soc_rt5640 snd_soc_rl6231 snd_soc_da7213 snd_soc_pcm512x_i2c snd_soc_pcm512x snd_soc_tdf8532 snd_soc_rt274 snd_soc_acpi) +RELOAD_MODULE=(modprobe snd_soc_rt5670 modprobe snd_soc_rt5645 modprobe snd_soc_rt5651 modprobe snd_soc_rt5640 modprobe snd_soc_da7213 modprobe snd_soc_pcm512x_i2c modprobe snd_soc_tdf8532 modprobe snd_soc_rt274 modprobe sof_acpi_dev modprobe sof_pci_dev) + +LOAD_MODULES=($(awk '{print $1}' lsmod.list)) + +ERR_COUNT_BEFORE=`dmesg | grep sof-audio | grep "error" | wc -l` + +# unload audio modules +remove() +{ + for module in ${SOF_MODULE[@]} + do + if lsmod | grep "$module" &> /dev/null ; then + echo "Removing $module" + rmmod $module + else + echo "skipping $module, not loaded" + fi + done +} + +err_check() +{ + ERR_COUNT_AFTER=`dmesg | grep sof-audio | grep "error" | wc -l` + if [ $ERR_COUNT_AFTER -gt $ERR_COUNT_BEFORE ] + then + exit 1 + else + exit 0 + fi +} + +# reload audio modules +insert(){ +RELOAD_MODULE=(snd_soc_rt5670 snd_soc_rt5645 snd_soc_rt5651 snd_soc_rt5640 snd_soc_da7213 snd_soc_pcm512x_i2c snd_soc_tdf8532 sof_acpi_dev sof_pci_dev) + for module in ${RELOAD_MODULE[@]} + do + modprobe $module + done +} + +remove +sleep 2 +insert +err_check diff --git a/test/qa/tests/functionality_test/playback_pcm_list.sh b/test/qa/tests/functionality_test/playback_pcm_list.sh new file mode 100755 index 000000000000..5e65d3406b2f --- /dev/null +++ b/test/qa/tests/functionality_test/playback_pcm_list.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Check playback PCM list +aplay -l > /dev/null +if [ $? != 0 ]; then + echo "Fail: Can not get playback pcm list." + exit 1 +else + exit 0 +fi diff --git a/test/qa/tests/functionality_test/set_ADC_volume_to_maximum.sh b/test/qa/tests/functionality_test/set_ADC_volume_to_maximum.sh new file mode 100755 index 000000000000..71f02115cabb --- /dev/null +++ b/test/qa/tests/functionality_test/set_ADC_volume_to_maximum.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +#Get mixer properties +amixer -D hw:sofbytcrrt5651 sset 'ADC' 127 > /dev/null +if [ $? -ne 0 ]; then + echo "set ADC volume to maximum FAIL" + exit 1 +else + exit 0 +fi diff --git a/test/qa/tests/functionality_test/set_ADC_volume_to_minimum.sh b/test/qa/tests/functionality_test/set_ADC_volume_to_minimum.sh new file mode 100755 index 000000000000..48ad7e197bd6 --- /dev/null +++ b/test/qa/tests/functionality_test/set_ADC_volume_to_minimum.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +#Get mixer properties +amixer -D hw:sofbytcrrt5651 sset 'ADC' 0 > /dev/null +if [ $? -ne 0 ]; then + echo "set ADC volume to minimum FAIL" + exit 1 +else + exit 0 +fi diff --git a/test/qa/tests/functionality_test/set_HP_volume_to_maximum.sh b/test/qa/tests/functionality_test/set_HP_volume_to_maximum.sh new file mode 100755 index 000000000000..bc001714bdcf --- /dev/null +++ b/test/qa/tests/functionality_test/set_HP_volume_to_maximum.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +#Get mixer properties +amixer -D hw:sofbytcrrt5651 sset 'HP' 39 > /dev/null +if [ $? -ne 0 ]; then + echo "set HP volume to maximum FAIL" + exit 1 +else + exit 0 +fi diff --git a/test/qa/tests/functionality_test/set_HP_volume_to_minimum.sh b/test/qa/tests/functionality_test/set_HP_volume_to_minimum.sh new file mode 100755 index 000000000000..9f843dd98b45 --- /dev/null +++ b/test/qa/tests/functionality_test/set_HP_volume_to_minimum.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +#Get mixer properties +amixer -D hw:sofbytcrrt5651 sset 'HP' 0 > /dev/null +if [ $? -ne 0 ]; then + echo "set HP volume to minimum FAIL" + exit 1 +else + exit 0 +fi diff --git a/test/qa/tests/functionality_test/verify_capture_info.sh b/test/qa/tests/functionality_test/verify_capture_info.sh new file mode 100755 index 000000000000..632871ba2540 --- /dev/null +++ b/test/qa/tests/functionality_test/verify_capture_info.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +#diff test_scripts/pcm0cinfo /proc/asound/card0/pcm0c/info > /tmp/capinfdiff.log +cat /proc/asound/sofbytcrrt5651/pcm0c/info |grep "stream: CAPTURE" > /dev/null +if [ $? -ne 0 ]; then + echo "Fail: DSP capture info doesnot match" +# echo "The diff is:" +# cat /tmp/capinfdiff.log | while read line +# do +# echo $line +# done + exit 1 +else + exit 0 +fi + diff --git a/test/qa/tests/functionality_test/verify_playback_pcm_list.sh b/test/qa/tests/functionality_test/verify_playback_pcm_list.sh new file mode 100755 index 000000000000..528061d4e2af --- /dev/null +++ b/test/qa/tests/functionality_test/verify_playback_pcm_list.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Check playback pcm list. +aplay -l |grep "device"> /dev/null +if [ $? != 0 ]; then + echo "Fail: Can not get playback pcm list." + exit 1 +else + exit 0 +fi + diff --git a/test/qa/tests/functionality_test/verify_sof_firmware_load.sh b/test/qa/tests/functionality_test/verify_sof_firmware_load.sh new file mode 100755 index 000000000000..ad6b8a909fb7 --- /dev/null +++ b/test/qa/tests/functionality_test/verify_sof_firmware_load.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Verify DSP firmware is loaded +#dmesg | grep "FW loaded" > /dev/null +dmesg | grep "firmware boot complete" > /dev/null +if [ $? != 0 ]; then + echo "Fail: DSP firmware were not loaded." + exit 1 +else + exit 0 +fi + diff --git a/test/qa/tests/functionality_test/verify_sof_firmware_presence.sh b/test/qa/tests/functionality_test/verify_sof_firmware_presence.sh new file mode 100755 index 000000000000..0740ec43a261 --- /dev/null +++ b/test/qa/tests/functionality_test/verify_sof_firmware_presence.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +MOD_VER=`lscpu |grep "Model name" |awk -F " " '{print $6}'` +if [ $MOD_VER == "E3826" ] || [ $MOD_VER == "E3845" ]; then + PLATFORM="byt" +elif [ $MOD_VER == "A3960" ] || [ $MOD_VER == "N4200" ]; then + PLATFORM="apl" +elif [ $MOD_VER == "0000" ]; then + PLATFORM="cnl" +fi + +# Verify DSP firmware is presence +ls /lib/firmware/intel/sof-$PLATFORM.ri > /dev/null +if [ $? != 0 ]; then + echo "Fail: DSP firmware doesnot presence." + exit 1 +else + exit 0 +fi diff --git a/test/qa/tests/functionality_test/verify_sof_firmware_version.sh b/test/qa/tests/functionality_test/verify_sof_firmware_version.sh new file mode 100755 index 000000000000..a8e926283149 --- /dev/null +++ b/test/qa/tests/functionality_test/verify_sof_firmware_version.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Verify DSP firmware is loaded +firmware_version=0.9 +get_version=`dmesg | grep "FW loaded" |head -1 |grep "version:" |cut -d : -f 4 |cut -c 2-4` +#get_version=`cat /var/log/kern.log | grep "FW loaded" |head -1 |grep "version:" |cut -d : -f 7 |cut -b 2-4` +if [ "$get_version" != "$firmware_version" ]; then + echo "Fail: DSP firmware were not loaded." + exit 1 +else + exit 0 +fi + diff --git a/test/qa/tests/functionality_test/verify_sof_firmware_version_info.sh b/test/qa/tests/functionality_test/verify_sof_firmware_version_info.sh new file mode 100755 index 000000000000..7f14a14a4951 --- /dev/null +++ b/test/qa/tests/functionality_test/verify_sof_firmware_version_info.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Verify DSP topology loading +dmesg | grep "Firmware info" > /dev/null +if [ $? != 0 ]; then + echo "Fail: No firmware info exist." + exit 1 +else + exit 0 +fi + diff --git a/test/qa/tests/functionality_test/verify_sound_modules.sh b/test/qa/tests/functionality_test/verify_sound_modules.sh new file mode 100755 index 000000000000..f032dfa0bac2 --- /dev/null +++ b/test/qa/tests/functionality_test/verify_sound_modules.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Verify DSP sound modules are loaded +lsmod | grep -i snd_soc > /dev/null +if [ $? != 0 ]; then + echo "Fail: Intel HDA modules were not loaded." + exit 1 +else + exit 0 +fi diff --git a/test/qa/tests/functionality_test/verify_topology_load.sh b/test/qa/tests/functionality_test/verify_topology_load.sh new file mode 100755 index 000000000000..f85c59455e10 --- /dev/null +++ b/test/qa/tests/functionality_test/verify_topology_load.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Verify DSP topology loading +dmesg | grep "loading topology" > /dev/null +if [ $? != 0 ]; then + echo "Fail: DSP topology was not loaded." + exit 1 +else + exit 0 +fi + diff --git a/test/qa/tests/platform/apl/up/feature-test b/test/qa/tests/platform/apl/up/feature-test new file mode 100644 index 000000000000..4e4066de42b9 --- /dev/null +++ b/test/qa/tests/platform/apl/up/feature-test @@ -0,0 +1,2 @@ +PCM_playback check_pcm_playback +PCM_playback check_dual_channels_playback diff --git a/test/qa/tests/platform/apl/up/tplg b/test/qa/tests/platform/apl/up/tplg new file mode 100644 index 000000000000..c606558a4eeb --- /dev/null +++ b/test/qa/tests/platform/apl/up/tplg @@ -0,0 +1,2 @@ +test-ssp5-mclk-0-I2S-volume-s16le-s16le-48k-24576k-nocodec.tplg +test-ssp5-mclk-0-DSP_A-volume-s16le-s16le-48k-24576k-nocodec.tplg diff --git a/test/qa/tests/platform/asound_state/apl/asound.state.passthrough b/test/qa/tests/platform/asound_state/apl/asound.state.passthrough new file mode 100644 index 000000000000..fa1a93effe28 --- /dev/null +++ b/test/qa/tests/platform/asound_state/apl/asound.state.passthrough @@ -0,0 +1,34 @@ +state.sofsofnocodec { + control.1 { + iface MIXER + name 'PGA1.0 Master Playback Volume 1' + value.0 26 + value.1 26 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 32' + dbmin -9999999 + dbmax 0 + dbvalue.0 -1200 + dbvalue.1 -1200 + } + } + control.2 { + iface MIXER + name 'PGA2.0 Master Capture Volume 2' + value.0 26 + value.1 26 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 32' + dbmin -9999999 + dbmax 0 + dbvalue.0 -1200 + dbvalue.1 -1200 + } + } +} diff --git a/test/qa/tests/platform/asound_state/apl/asound.state.volume b/test/qa/tests/platform/asound_state/apl/asound.state.volume new file mode 100644 index 000000000000..fa1a93effe28 --- /dev/null +++ b/test/qa/tests/platform/asound_state/apl/asound.state.volume @@ -0,0 +1,34 @@ +state.sofsofnocodec { + control.1 { + iface MIXER + name 'PGA1.0 Master Playback Volume 1' + value.0 26 + value.1 26 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 32' + dbmin -9999999 + dbmax 0 + dbvalue.0 -1200 + dbvalue.1 -1200 + } + } + control.2 { + iface MIXER + name 'PGA2.0 Master Capture Volume 2' + value.0 26 + value.1 26 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 32' + dbmin -9999999 + dbmax 0 + dbvalue.0 -1200 + dbvalue.1 -1200 + } + } +} diff --git a/test/qa/tests/platform/asound_state/byt/asound.state.line b/test/qa/tests/platform/asound_state/byt/asound.state.line new file mode 100644 index 000000000000..c2a513ee94ca --- /dev/null +++ b/test/qa/tests/platform/asound_state/byt/asound.state.line @@ -0,0 +1,1036 @@ +state.sofbytcrrt5651 { + control.1 { + iface MIXER + name 'HP Playback Volume' + value.0 21 + value.1 21 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 39' + dbmin -4650 + dbmax 1200 + dbvalue.0 -1500 + dbvalue.1 -1500 + } + } + control.2 { + iface MIXER + name 'OUT Playback Volume' + value.0 24 + value.1 24 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 39' + dbmin -4650 + dbmax 1200 + dbvalue.0 -1050 + dbvalue.1 -1050 + } + } + control.3 { + iface MIXER + name 'DAC2 Playback Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.4 { + iface MIXER + name 'DAC1 Playback Volume' + value.0 169 + value.1 169 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 175' + dbmin -65625 + dbmax 0 + dbvalue.0 -2250 + dbvalue.1 -2250 + } + } + control.5 { + iface MIXER + name 'Mono DAC Playback Volume' + value.0 163 + value.1 163 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 175' + dbmin -65625 + dbmax 0 + dbvalue.0 -4500 + dbvalue.1 -4500 + } + } + control.6 { + iface MIXER + name 'IN1 Boost' + value 1 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 8' + dbmin 0 + dbmax 5200 + dbvalue.0 2000 + } + } + control.7 { + iface MIXER + name 'IN2 Boost' + value 1 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 8' + dbmin 0 + dbmax 5200 + dbvalue.0 2000 + } + } + control.8 { + iface MIXER + name 'IN Capture Volume' + value.0 16 + value.1 16 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 31' + dbmin -3450 + dbmax 1200 + dbvalue.0 -1050 + dbvalue.1 -1050 + } + } + control.9 { + iface MIXER + name 'ADC Capture Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.10 { + iface MIXER + name 'ADC Capture Volume' + value.0 106 + value.1 106 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 127' + dbmin -17625 + dbmax 30000 + dbvalue.0 22125 + dbvalue.1 22125 + } + } + control.11 { + iface MIXER + name 'Mono ADC Capture Volume' + value.0 0 + value.1 0 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 127' + dbmin -17625 + dbmax 30000 + dbvalue.0 -17625 + dbvalue.1 -17625 + } + } + control.12 { + iface MIXER + name 'ADC Boost Gain' + value.0 0 + value.1 0 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 3' + dbmin 0 + dbmax 3600 + dbvalue.0 0 + dbvalue.1 0 + } + } + control.13 { + iface MIXER + name 'IF1 ASRC Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.14 { + iface MIXER + name 'IF2 ASRC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.15 { + iface MIXER + name 'DMIC ASRC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.16 { + iface MIXER + name 'ADC IF2 Data Switch' + value Normal + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Normal + item.1 Swap + item.2 'left copy to right' + item.3 'right copy to left' + } + } + control.17 { + iface MIXER + name 'DAC IF2 Data Switch' + value Normal + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Normal + item.1 Swap + item.2 'left copy to right' + item.3 'right copy to left' + } + } + control.18 { + iface MIXER + name 'Headphone Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.19 { + iface MIXER + name 'Headset Mic Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.20 { + iface MIXER + name 'Internal Mic Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.21 { + iface MIXER + name 'Speaker Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.22 { + iface MIXER + name 'Line In Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.23 { + iface MIXER + name 'RECMIXL INL1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.24 { + iface MIXER + name 'RECMIXL BST3 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.25 { + iface MIXER + name 'RECMIXL BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.26 { + iface MIXER + name 'RECMIXL BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.27 { + iface MIXER + name 'RECMIXR INR1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.28 { + iface MIXER + name 'RECMIXR BST3 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.29 { + iface MIXER + name 'RECMIXR BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.30 { + iface MIXER + name 'RECMIXR BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.31 { + iface MIXER + name 'Stereo1 ADC L2 Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 DMIC + item.1 'DD MIX' + } + } + control.32 { + iface MIXER + name 'Stereo1 ADC R2 Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 DMIC + item.1 'DD MIX' + } + } + control.33 { + iface MIXER + name 'Stereo1 ADC L1 Mux' + value ADC + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 ADC + } + } + control.34 { + iface MIXER + name 'Stereo1 ADC R1 Mux' + value ADC + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 ADC + } + } + control.35 { + iface MIXER + name 'Stereo2 ADC L2 Mux' + value 'DD MIXL' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DMIC L' + item.1 'DD MIXL' + } + } + control.36 { + iface MIXER + name 'Stereo2 ADC L1 Mux' + value ADCL + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIXL' + item.1 ADCL + } + } + control.37 { + iface MIXER + name 'Stereo2 ADC R1 Mux' + value 'DD MIXR' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIXR' + item.1 ADCR + } + } + control.38 { + iface MIXER + name 'Stereo2 ADC R2 Mux' + value 'DMIC R' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DMIC R' + item.1 'DD MIXR' + } + } + control.39 { + iface MIXER + name 'Stereo1 ADC MIXL ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.40 { + iface MIXER + name 'Stereo1 ADC MIXL ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.41 { + iface MIXER + name 'Stereo1 ADC MIXR ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.42 { + iface MIXER + name 'Stereo1 ADC MIXR ADC2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.43 { + iface MIXER + name 'Stereo2 ADC MIXL ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.44 { + iface MIXER + name 'Stereo2 ADC MIXL ADC2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.45 { + iface MIXER + name 'Stereo2 ADC MIXR ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.46 { + iface MIXER + name 'Stereo2 ADC MIXR ADC2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.47 { + iface MIXER + name 'IF2 ADC' + value 'IF1 ADC1' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'IF1 ADC1' + item.1 'IF1 ADC2' + } + } + control.48 { + iface MIXER + name 'PDM L Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 'Stereo DAC MIX' + } + } + control.49 { + iface MIXER + name 'PDM R Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 'Stereo DAC MIX' + } + } + control.50 { + iface MIXER + name 'DAC MIXL Stereo ADC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.51 { + iface MIXER + name 'DAC MIXL INF1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.52 { + iface MIXER + name 'DAC MIXR Stereo ADC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.53 { + iface MIXER + name 'DAC MIXR INF1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.54 { + iface MIXER + name 'DAC L2 Mux' + value IF2 + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 IF1 + item.1 IF2 + } + } + control.55 { + iface MIXER + name 'DAC R2 Mux' + value IF2 + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 IF1 + item.1 IF2 + } + } + control.56 { + iface MIXER + name 'Stereo DAC MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.57 { + iface MIXER + name 'Stereo DAC MIXL DAC L2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.58 { + iface MIXER + name 'Stereo DAC MIXL DAC R1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.59 { + iface MIXER + name 'Stereo DAC MIXR DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.60 { + iface MIXER + name 'Stereo DAC MIXR DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.61 { + iface MIXER + name 'Stereo DAC MIXR DAC L1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.62 { + iface MIXER + name 'DD MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.63 { + iface MIXER + name 'DD MIXL DAC L2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.64 { + iface MIXER + name 'DD MIXL DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.65 { + iface MIXER + name 'DD MIXR DAC R1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.66 { + iface MIXER + name 'DD MIXR DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.67 { + iface MIXER + name 'DD MIXR DAC L2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.68 { + iface MIXER + name 'OUT MIXL BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.69 { + iface MIXER + name 'OUT MIXL BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.70 { + iface MIXER + name 'OUT MIXL INL1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.71 { + iface MIXER + name 'OUT MIXL REC MIXL Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.72 { + iface MIXER + name 'OUT MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.73 { + iface MIXER + name 'OUT MIXR BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.74 { + iface MIXER + name 'OUT MIXR BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.75 { + iface MIXER + name 'OUT MIXR INR1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.76 { + iface MIXER + name 'OUT MIXR REC MIXR Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.77 { + iface MIXER + name 'OUT MIXR DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.78 { + iface MIXER + name 'OUTVOL L Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.79 { + iface MIXER + name 'OUTVOL R Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.80 { + iface MIXER + name 'HPOVOL L Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.81 { + iface MIXER + name 'HPOVOL R Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.82 { + iface MIXER + name 'HPO MIX DAC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.83 { + iface MIXER + name 'HPO MIX HPVOL Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.84 { + iface MIXER + name 'LOUT MIX DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.85 { + iface MIXER + name 'LOUT MIX DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.86 { + iface MIXER + name 'LOUT MIX OUTVOL L Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.87 { + iface MIXER + name 'LOUT MIX OUTVOL R Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.88 { + iface MIXER + name 'HPO L Playback Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.89 { + iface MIXER + name 'HPO R Playback Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.90 { + iface MIXER + name 'LOUT L Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.91 { + iface MIXER + name 'LOUT R Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.92 { + iface MIXER + name 'PGA1.0 Master Playback Volume 1' + value.0 24 + value.1 24 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 32' + dbmin -9999999 + dbmax 0 + dbvalue.0 -1600 + dbvalue.1 -1600 + } + } + control.93 { + iface MIXER + name 'PGA2.0 Master Capture Volume 2' + value.0 24 + value.1 24 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 32' + dbmin -9999999 + dbmax 0 + dbvalue.0 -1600 + dbvalue.1 -1600 + } + } +} diff --git a/test/qa/tests/platform/asound_state/byt/asound.state.passthrough b/test/qa/tests/platform/asound_state/byt/asound.state.passthrough new file mode 100644 index 000000000000..6302218c0454 --- /dev/null +++ b/test/qa/tests/platform/asound_state/byt/asound.state.passthrough @@ -0,0 +1,1014 @@ +state.sofbytcrrt5651 { + control.1 { + iface MIXER + name 'HP Playback Volume' + value.0 10 + value.1 10 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 39' + dbmin -4650 + dbmax 1200 + dbvalue.0 -3150 + dbvalue.1 -3150 + } + } + control.2 { + iface MIXER + name 'OUT Playback Volume' + value.0 26 + value.1 26 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 39' + dbmin -4650 + dbmax 1200 + dbvalue.0 -750 + dbvalue.1 -750 + } + } + control.3 { + iface MIXER + name 'DAC2 Playback Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.4 { + iface MIXER + name 'DAC1 Playback Volume' + value.0 159 + value.1 159 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 175' + dbmin -65625 + dbmax 0 + dbvalue.0 -6000 + dbvalue.1 -6000 + } + } + control.5 { + iface MIXER + name 'Mono DAC Playback Volume' + value.0 163 + value.1 163 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 175' + dbmin -65625 + dbmax 0 + dbvalue.0 -4500 + dbvalue.1 -4500 + } + } + control.6 { + iface MIXER + name 'IN1 Boost' + value 2 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 8' + dbmin 0 + dbmax 5200 + dbvalue.0 2400 + } + } + control.7 { + iface MIXER + name 'IN2 Boost' + value 1 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 8' + dbmin 0 + dbmax 5200 + dbvalue.0 2000 + } + } + control.8 { + iface MIXER + name 'IN Capture Volume' + value.0 8 + value.1 8 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 31' + dbmin -3450 + dbmax 1200 + dbvalue.0 -2250 + dbvalue.1 -2250 + } + } + control.9 { + iface MIXER + name 'ADC Capture Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.10 { + iface MIXER + name 'ADC Capture Volume' + value.0 112 + value.1 112 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 127' + dbmin -17625 + dbmax 30000 + dbvalue.0 24375 + dbvalue.1 24375 + } + } + control.11 { + iface MIXER + name 'Mono ADC Capture Volume' + value.0 0 + value.1 0 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 127' + dbmin -17625 + dbmax 30000 + dbvalue.0 -17625 + dbvalue.1 -17625 + } + } + control.12 { + iface MIXER + name 'ADC Boost Gain' + value.0 0 + value.1 0 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 3' + dbmin 0 + dbmax 3600 + dbvalue.0 0 + dbvalue.1 0 + } + } + control.13 { + iface MIXER + name 'IF1 ASRC Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.14 { + iface MIXER + name 'IF2 ASRC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.15 { + iface MIXER + name 'DMIC ASRC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.16 { + iface MIXER + name 'ADC IF2 Data Switch' + value Normal + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Normal + item.1 Swap + item.2 'left copy to right' + item.3 'right copy to left' + } + } + control.17 { + iface MIXER + name 'DAC IF2 Data Switch' + value Normal + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Normal + item.1 Swap + item.2 'left copy to right' + item.3 'right copy to left' + } + } + control.18 { + iface MIXER + name 'Headphone Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.19 { + iface MIXER + name 'Headset Mic Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.20 { + iface MIXER + name 'Internal Mic Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.21 { + iface MIXER + name 'Speaker Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.22 { + iface CARD + name 'Headphone Jack' + value true + comment { + access read + type BOOLEAN + count 1 + } + } + control.23 { + iface CARD + name 'Headset Mic Jack' + value true + comment { + access read + type BOOLEAN + count 1 + } + } + control.24 { + iface MIXER + name 'RECMIXL INL1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.25 { + iface MIXER + name 'RECMIXL BST3 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.26 { + iface MIXER + name 'RECMIXL BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.27 { + iface MIXER + name 'RECMIXL BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.28 { + iface MIXER + name 'RECMIXR INR1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.29 { + iface MIXER + name 'RECMIXR BST3 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.30 { + iface MIXER + name 'RECMIXR BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.31 { + iface MIXER + name 'RECMIXR BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.32 { + iface MIXER + name 'Stereo1 ADC L2 Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 DMIC + item.1 'DD MIX' + } + } + control.33 { + iface MIXER + name 'Stereo1 ADC R2 Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 DMIC + item.1 'DD MIX' + } + } + control.34 { + iface MIXER + name 'Stereo1 ADC L1 Mux' + value ADC + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 ADC + } + } + control.35 { + iface MIXER + name 'Stereo1 ADC R1 Mux' + value ADC + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 ADC + } + } + control.36 { + iface MIXER + name 'Stereo2 ADC L2 Mux' + value 'DD MIXL' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DMIC L' + item.1 'DD MIXL' + } + } + control.37 { + iface MIXER + name 'Stereo2 ADC L1 Mux' + value ADCL + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIXL' + item.1 ADCL + } + } + control.38 { + iface MIXER + name 'Stereo2 ADC R1 Mux' + value 'DD MIXR' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIXR' + item.1 ADCR + } + } + control.39 { + iface MIXER + name 'Stereo2 ADC R2 Mux' + value 'DMIC R' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DMIC R' + item.1 'DD MIXR' + } + } + control.40 { + iface MIXER + name 'Stereo1 ADC MIXL ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.41 { + iface MIXER + name 'Stereo1 ADC MIXL ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.42 { + iface MIXER + name 'Stereo1 ADC MIXR ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.43 { + iface MIXER + name 'Stereo1 ADC MIXR ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.44 { + iface MIXER + name 'Stereo2 ADC MIXL ADC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.45 { + iface MIXER + name 'Stereo2 ADC MIXL ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.46 { + iface MIXER + name 'Stereo2 ADC MIXR ADC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.47 { + iface MIXER + name 'Stereo2 ADC MIXR ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.48 { + iface MIXER + name 'IF2 ADC' + value 'IF1 ADC1' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'IF1 ADC1' + item.1 'IF1 ADC2' + } + } + control.49 { + iface MIXER + name 'PDM L Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 'Stereo DAC MIX' + } + } + control.50 { + iface MIXER + name 'PDM R Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 'Stereo DAC MIX' + } + } + control.51 { + iface MIXER + name 'DAC MIXL Stereo ADC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.52 { + iface MIXER + name 'DAC MIXL INF1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.53 { + iface MIXER + name 'DAC MIXR Stereo ADC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.54 { + iface MIXER + name 'DAC MIXR INF1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.55 { + iface MIXER + name 'DAC L2 Mux' + value IF2 + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 IF1 + item.1 IF2 + } + } + control.56 { + iface MIXER + name 'DAC R2 Mux' + value IF2 + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 IF1 + item.1 IF2 + } + } + control.57 { + iface MIXER + name 'Stereo DAC MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.58 { + iface MIXER + name 'Stereo DAC MIXL DAC L2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.59 { + iface MIXER + name 'Stereo DAC MIXL DAC R1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.60 { + iface MIXER + name 'Stereo DAC MIXR DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.61 { + iface MIXER + name 'Stereo DAC MIXR DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.62 { + iface MIXER + name 'Stereo DAC MIXR DAC L1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.63 { + iface MIXER + name 'DD MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.64 { + iface MIXER + name 'DD MIXL DAC L2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.65 { + iface MIXER + name 'DD MIXL DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.66 { + iface MIXER + name 'DD MIXR DAC R1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.67 { + iface MIXER + name 'DD MIXR DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.68 { + iface MIXER + name 'DD MIXR DAC L2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.69 { + iface MIXER + name 'OUT MIXL BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.70 { + iface MIXER + name 'OUT MIXL BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.71 { + iface MIXER + name 'OUT MIXL INL1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.72 { + iface MIXER + name 'OUT MIXL REC MIXL Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.73 { + iface MIXER + name 'OUT MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.74 { + iface MIXER + name 'OUT MIXR BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.75 { + iface MIXER + name 'OUT MIXR BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.76 { + iface MIXER + name 'OUT MIXR INR1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.77 { + iface MIXER + name 'OUT MIXR REC MIXR Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.78 { + iface MIXER + name 'OUT MIXR DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.79 { + iface MIXER + name 'OUTVOL L Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.80 { + iface MIXER + name 'OUTVOL R Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.81 { + iface MIXER + name 'HPOVOL L Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.82 { + iface MIXER + name 'HPOVOL R Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.83 { + iface MIXER + name 'HPO MIX DAC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.84 { + iface MIXER + name 'HPO MIX HPVOL Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.85 { + iface MIXER + name 'LOUT MIX DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.86 { + iface MIXER + name 'LOUT MIX DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.87 { + iface MIXER + name 'LOUT MIX OUTVOL L Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.88 { + iface MIXER + name 'LOUT MIX OUTVOL R Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.89 { + iface MIXER + name 'HPO L Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.90 { + iface MIXER + name 'HPO R Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.91 { + iface MIXER + name 'LOUT L Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.92 { + iface MIXER + name 'LOUT R Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } +} diff --git a/test/qa/tests/platform/asound_state/byt/asound.state.pulse-c b/test/qa/tests/platform/asound_state/byt/asound.state.pulse-c new file mode 100644 index 000000000000..75565b135fb4 --- /dev/null +++ b/test/qa/tests/platform/asound_state/byt/asound.state.pulse-c @@ -0,0 +1,1024 @@ +state.sofbytcrrt5651 { + control.1 { + iface MIXER + name 'HP Playback Volume' + value.0 11 + value.1 11 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 39' + dbmin -4650 + dbmax 1200 + dbvalue.0 -3000 + dbvalue.1 -3000 + } + } + control.2 { + iface MIXER + name 'OUT Playback Volume' + value.0 30 + value.1 30 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 39' + dbmin -4650 + dbmax 1200 + dbvalue.0 -150 + dbvalue.1 -150 + } + } + control.3 { + iface MIXER + name 'DAC2 Playback Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.4 { + iface MIXER + name 'DAC1 Playback Volume' + value.0 159 + value.1 159 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 175' + dbmin -65625 + dbmax 0 + dbvalue.0 -6000 + dbvalue.1 -6000 + } + } + control.5 { + iface MIXER + name 'Mono DAC Playback Volume' + value.0 163 + value.1 163 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 175' + dbmin -65625 + dbmax 0 + dbvalue.0 -4500 + dbvalue.1 -4500 + } + } + control.6 { + iface MIXER + name 'IN1 Boost' + value 6 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 8' + dbmin 0 + dbmax 5200 + dbvalue.0 4400 + } + } + control.7 { + iface MIXER + name 'IN2 Boost' + value 3 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 8' + dbmin 0 + dbmax 5200 + dbvalue.0 3000 + } + } + control.8 { + iface MIXER + name 'IN Capture Volume' + value.0 8 + value.1 8 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 31' + dbmin -3450 + dbmax 1200 + dbvalue.0 -2250 + dbvalue.1 -2250 + } + } + control.9 { + iface MIXER + name 'ADC Capture Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.10 { + iface MIXER + name 'ADC Capture Volume' + value.0 111 + value.1 111 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 127' + dbmin -17625 + dbmax 30000 + dbvalue.0 24000 + dbvalue.1 24000 + } + } + control.11 { + iface MIXER + name 'Mono ADC Capture Volume' + value.0 0 + value.1 0 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 127' + dbmin -17625 + dbmax 30000 + dbvalue.0 -17625 + dbvalue.1 -17625 + } + } + control.12 { + iface MIXER + name 'ADC Boost Gain' + value.0 0 + value.1 0 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 3' + dbmin 0 + dbmax 3600 + dbvalue.0 0 + dbvalue.1 0 + } + } + control.13 { + iface MIXER + name 'IF1 ASRC Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.14 { + iface MIXER + name 'IF2 ASRC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.15 { + iface MIXER + name 'DMIC ASRC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.16 { + iface MIXER + name 'ADC IF2 Data Switch' + value Normal + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Normal + item.1 Swap + item.2 'left copy to right' + item.3 'right copy to left' + } + } + control.17 { + iface MIXER + name 'DAC IF2 Data Switch' + value Normal + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Normal + item.1 Swap + item.2 'left copy to right' + item.3 'right copy to left' + } + } + control.18 { + iface MIXER + name 'Headphone Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.19 { + iface MIXER + name 'Headset Mic Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.20 { + iface MIXER + name 'Internal Mic Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.21 { + iface MIXER + name 'Speaker Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.22 { + iface MIXER + name 'Line In Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.23 { + iface CARD + name 'Headphone Jack' + value true + comment { + access read + type BOOLEAN + count 1 + } + } + control.24 { + iface CARD + name 'Headset Mic Jack' + value true + comment { + access read + type BOOLEAN + count 1 + } + } + control.25 { + iface MIXER + name 'RECMIXL INL1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.26 { + iface MIXER + name 'RECMIXL BST3 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.27 { + iface MIXER + name 'RECMIXL BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.28 { + iface MIXER + name 'RECMIXL BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.29 { + iface MIXER + name 'RECMIXR INR1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.30 { + iface MIXER + name 'RECMIXR BST3 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.31 { + iface MIXER + name 'RECMIXR BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.32 { + iface MIXER + name 'RECMIXR BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.33 { + iface MIXER + name 'Stereo1 ADC L2 Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 DMIC + item.1 'DD MIX' + } + } + control.34 { + iface MIXER + name 'Stereo1 ADC R2 Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 DMIC + item.1 'DD MIX' + } + } + control.35 { + iface MIXER + name 'Stereo1 ADC L1 Mux' + value ADC + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 ADC + } + } + control.36 { + iface MIXER + name 'Stereo1 ADC R1 Mux' + value ADC + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 ADC + } + } + control.37 { + iface MIXER + name 'Stereo2 ADC L2 Mux' + value 'DD MIXL' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DMIC L' + item.1 'DD MIXL' + } + } + control.38 { + iface MIXER + name 'Stereo2 ADC L1 Mux' + value ADCL + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIXL' + item.1 ADCL + } + } + control.39 { + iface MIXER + name 'Stereo2 ADC R1 Mux' + value 'DD MIXR' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIXR' + item.1 ADCR + } + } + control.40 { + iface MIXER + name 'Stereo2 ADC R2 Mux' + value 'DMIC R' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DMIC R' + item.1 'DD MIXR' + } + } + control.41 { + iface MIXER + name 'Stereo1 ADC MIXL ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.42 { + iface MIXER + name 'Stereo1 ADC MIXL ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.43 { + iface MIXER + name 'Stereo1 ADC MIXR ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.44 { + iface MIXER + name 'Stereo1 ADC MIXR ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.45 { + iface MIXER + name 'Stereo2 ADC MIXL ADC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.46 { + iface MIXER + name 'Stereo2 ADC MIXL ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.47 { + iface MIXER + name 'Stereo2 ADC MIXR ADC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.48 { + iface MIXER + name 'Stereo2 ADC MIXR ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.49 { + iface MIXER + name 'IF2 ADC' + value 'IF1 ADC1' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'IF1 ADC1' + item.1 'IF1 ADC2' + } + } + control.50 { + iface MIXER + name 'PDM L Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 'Stereo DAC MIX' + } + } + control.51 { + iface MIXER + name 'PDM R Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 'Stereo DAC MIX' + } + } + control.52 { + iface MIXER + name 'DAC MIXL Stereo ADC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.53 { + iface MIXER + name 'DAC MIXL INF1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.54 { + iface MIXER + name 'DAC MIXR Stereo ADC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.55 { + iface MIXER + name 'DAC MIXR INF1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.56 { + iface MIXER + name 'DAC L2 Mux' + value IF2 + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 IF1 + item.1 IF2 + } + } + control.57 { + iface MIXER + name 'DAC R2 Mux' + value IF2 + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 IF1 + item.1 IF2 + } + } + control.58 { + iface MIXER + name 'Stereo DAC MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.59 { + iface MIXER + name 'Stereo DAC MIXL DAC L2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.60 { + iface MIXER + name 'Stereo DAC MIXL DAC R1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.61 { + iface MIXER + name 'Stereo DAC MIXR DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.62 { + iface MIXER + name 'Stereo DAC MIXR DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.63 { + iface MIXER + name 'Stereo DAC MIXR DAC L1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.64 { + iface MIXER + name 'DD MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.65 { + iface MIXER + name 'DD MIXL DAC L2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.66 { + iface MIXER + name 'DD MIXL DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.67 { + iface MIXER + name 'DD MIXR DAC R1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.68 { + iface MIXER + name 'DD MIXR DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.69 { + iface MIXER + name 'DD MIXR DAC L2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.70 { + iface MIXER + name 'OUT MIXL BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.71 { + iface MIXER + name 'OUT MIXL BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.72 { + iface MIXER + name 'OUT MIXL INL1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.73 { + iface MIXER + name 'OUT MIXL REC MIXL Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.74 { + iface MIXER + name 'OUT MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.75 { + iface MIXER + name 'OUT MIXR BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.76 { + iface MIXER + name 'OUT MIXR BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.77 { + iface MIXER + name 'OUT MIXR INR1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.78 { + iface MIXER + name 'OUT MIXR REC MIXR Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.79 { + iface MIXER + name 'OUT MIXR DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.80 { + iface MIXER + name 'OUTVOL L Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.81 { + iface MIXER + name 'OUTVOL R Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.82 { + iface MIXER + name 'HPOVOL L Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.83 { + iface MIXER + name 'HPOVOL R Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.84 { + iface MIXER + name 'HPO MIX DAC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.85 { + iface MIXER + name 'HPO MIX HPVOL Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.86 { + iface MIXER + name 'LOUT MIX DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.87 { + iface MIXER + name 'LOUT MIX DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.88 { + iface MIXER + name 'LOUT MIX OUTVOL L Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.89 { + iface MIXER + name 'LOUT MIX OUTVOL R Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.90 { + iface MIXER + name 'HPO L Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.91 { + iface MIXER + name 'HPO R Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.92 { + iface MIXER + name 'LOUT L Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.93 { + iface MIXER + name 'LOUT R Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } +} diff --git a/test/qa/tests/platform/asound_state/byt/asound.state.pulse-p b/test/qa/tests/platform/asound_state/byt/asound.state.pulse-p new file mode 100644 index 000000000000..05f8e02eb56e --- /dev/null +++ b/test/qa/tests/platform/asound_state/byt/asound.state.pulse-p @@ -0,0 +1,1024 @@ +state.sofbytcrrt5651 { + control.1 { + iface MIXER + name 'HP Playback Volume' + value.0 14 + value.1 14 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 39' + dbmin -4650 + dbmax 1200 + dbvalue.0 -2550 + dbvalue.1 -2550 + } + } + control.2 { + iface MIXER + name 'OUT Playback Volume' + value.0 24 + value.1 24 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 39' + dbmin -4650 + dbmax 1200 + dbvalue.0 -1050 + dbvalue.1 -1050 + } + } + control.3 { + iface MIXER + name 'DAC2 Playback Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.4 { + iface MIXER + name 'DAC1 Playback Volume' + value.0 159 + value.1 159 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 175' + dbmin -65625 + dbmax 0 + dbvalue.0 -6000 + dbvalue.1 -6000 + } + } + control.5 { + iface MIXER + name 'Mono DAC Playback Volume' + value.0 163 + value.1 163 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 175' + dbmin -65625 + dbmax 0 + dbvalue.0 -4500 + dbvalue.1 -4500 + } + } + control.6 { + iface MIXER + name 'IN1 Boost' + value 2 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 8' + dbmin 0 + dbmax 5200 + dbvalue.0 2400 + } + } + control.7 { + iface MIXER + name 'IN2 Boost' + value 1 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 8' + dbmin 0 + dbmax 5200 + dbvalue.0 2000 + } + } + control.8 { + iface MIXER + name 'IN Capture Volume' + value.0 7 + value.1 7 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 31' + dbmin -3450 + dbmax 1200 + dbvalue.0 -2400 + dbvalue.1 -2400 + } + } + control.9 { + iface MIXER + name 'ADC Capture Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.10 { + iface MIXER + name 'ADC Capture Volume' + value.0 111 + value.1 111 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 127' + dbmin -17625 + dbmax 30000 + dbvalue.0 24000 + dbvalue.1 24000 + } + } + control.11 { + iface MIXER + name 'Mono ADC Capture Volume' + value.0 0 + value.1 0 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 127' + dbmin -17625 + dbmax 30000 + dbvalue.0 -17625 + dbvalue.1 -17625 + } + } + control.12 { + iface MIXER + name 'ADC Boost Gain' + value.0 0 + value.1 0 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 3' + dbmin 0 + dbmax 3600 + dbvalue.0 0 + dbvalue.1 0 + } + } + control.13 { + iface MIXER + name 'IF1 ASRC Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.14 { + iface MIXER + name 'IF2 ASRC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.15 { + iface MIXER + name 'DMIC ASRC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.16 { + iface MIXER + name 'ADC IF2 Data Switch' + value Normal + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Normal + item.1 Swap + item.2 'left copy to right' + item.3 'right copy to left' + } + } + control.17 { + iface MIXER + name 'DAC IF2 Data Switch' + value Normal + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Normal + item.1 Swap + item.2 'left copy to right' + item.3 'right copy to left' + } + } + control.18 { + iface MIXER + name 'Headphone Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.19 { + iface MIXER + name 'Headset Mic Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.20 { + iface MIXER + name 'Internal Mic Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.21 { + iface MIXER + name 'Speaker Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.22 { + iface MIXER + name 'Line In Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.23 { + iface CARD + name 'Headphone Jack' + value true + comment { + access read + type BOOLEAN + count 1 + } + } + control.24 { + iface CARD + name 'Headset Mic Jack' + value true + comment { + access read + type BOOLEAN + count 1 + } + } + control.25 { + iface MIXER + name 'RECMIXL INL1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.26 { + iface MIXER + name 'RECMIXL BST3 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.27 { + iface MIXER + name 'RECMIXL BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.28 { + iface MIXER + name 'RECMIXL BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.29 { + iface MIXER + name 'RECMIXR INR1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.30 { + iface MIXER + name 'RECMIXR BST3 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.31 { + iface MIXER + name 'RECMIXR BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.32 { + iface MIXER + name 'RECMIXR BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.33 { + iface MIXER + name 'Stereo1 ADC L2 Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 DMIC + item.1 'DD MIX' + } + } + control.34 { + iface MIXER + name 'Stereo1 ADC R2 Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 DMIC + item.1 'DD MIX' + } + } + control.35 { + iface MIXER + name 'Stereo1 ADC L1 Mux' + value ADC + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 ADC + } + } + control.36 { + iface MIXER + name 'Stereo1 ADC R1 Mux' + value ADC + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 ADC + } + } + control.37 { + iface MIXER + name 'Stereo2 ADC L2 Mux' + value 'DD MIXL' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DMIC L' + item.1 'DD MIXL' + } + } + control.38 { + iface MIXER + name 'Stereo2 ADC L1 Mux' + value ADCL + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIXL' + item.1 ADCL + } + } + control.39 { + iface MIXER + name 'Stereo2 ADC R1 Mux' + value 'DD MIXR' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIXR' + item.1 ADCR + } + } + control.40 { + iface MIXER + name 'Stereo2 ADC R2 Mux' + value 'DMIC R' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DMIC R' + item.1 'DD MIXR' + } + } + control.41 { + iface MIXER + name 'Stereo1 ADC MIXL ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.42 { + iface MIXER + name 'Stereo1 ADC MIXL ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.43 { + iface MIXER + name 'Stereo1 ADC MIXR ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.44 { + iface MIXER + name 'Stereo1 ADC MIXR ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.45 { + iface MIXER + name 'Stereo2 ADC MIXL ADC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.46 { + iface MIXER + name 'Stereo2 ADC MIXL ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.47 { + iface MIXER + name 'Stereo2 ADC MIXR ADC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.48 { + iface MIXER + name 'Stereo2 ADC MIXR ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.49 { + iface MIXER + name 'IF2 ADC' + value 'IF1 ADC1' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'IF1 ADC1' + item.1 'IF1 ADC2' + } + } + control.50 { + iface MIXER + name 'PDM L Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 'Stereo DAC MIX' + } + } + control.51 { + iface MIXER + name 'PDM R Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 'Stereo DAC MIX' + } + } + control.52 { + iface MIXER + name 'DAC MIXL Stereo ADC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.53 { + iface MIXER + name 'DAC MIXL INF1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.54 { + iface MIXER + name 'DAC MIXR Stereo ADC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.55 { + iface MIXER + name 'DAC MIXR INF1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.56 { + iface MIXER + name 'DAC L2 Mux' + value IF2 + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 IF1 + item.1 IF2 + } + } + control.57 { + iface MIXER + name 'DAC R2 Mux' + value IF2 + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 IF1 + item.1 IF2 + } + } + control.58 { + iface MIXER + name 'Stereo DAC MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.59 { + iface MIXER + name 'Stereo DAC MIXL DAC L2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.60 { + iface MIXER + name 'Stereo DAC MIXL DAC R1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.61 { + iface MIXER + name 'Stereo DAC MIXR DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.62 { + iface MIXER + name 'Stereo DAC MIXR DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.63 { + iface MIXER + name 'Stereo DAC MIXR DAC L1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.64 { + iface MIXER + name 'DD MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.65 { + iface MIXER + name 'DD MIXL DAC L2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.66 { + iface MIXER + name 'DD MIXL DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.67 { + iface MIXER + name 'DD MIXR DAC R1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.68 { + iface MIXER + name 'DD MIXR DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.69 { + iface MIXER + name 'DD MIXR DAC L2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.70 { + iface MIXER + name 'OUT MIXL BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.71 { + iface MIXER + name 'OUT MIXL BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.72 { + iface MIXER + name 'OUT MIXL INL1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.73 { + iface MIXER + name 'OUT MIXL REC MIXL Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.74 { + iface MIXER + name 'OUT MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.75 { + iface MIXER + name 'OUT MIXR BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.76 { + iface MIXER + name 'OUT MIXR BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.77 { + iface MIXER + name 'OUT MIXR INR1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.78 { + iface MIXER + name 'OUT MIXR REC MIXR Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.79 { + iface MIXER + name 'OUT MIXR DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.80 { + iface MIXER + name 'OUTVOL L Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.81 { + iface MIXER + name 'OUTVOL R Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.82 { + iface MIXER + name 'HPOVOL L Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.83 { + iface MIXER + name 'HPOVOL R Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.84 { + iface MIXER + name 'HPO MIX DAC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.85 { + iface MIXER + name 'HPO MIX HPVOL Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.86 { + iface MIXER + name 'LOUT MIX DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.87 { + iface MIXER + name 'LOUT MIX DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.88 { + iface MIXER + name 'LOUT MIX OUTVOL L Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.89 { + iface MIXER + name 'LOUT MIX OUTVOL R Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.90 { + iface MIXER + name 'HPO L Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.91 { + iface MIXER + name 'HPO R Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.92 { + iface MIXER + name 'LOUT L Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.93 { + iface MIXER + name 'LOUT R Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } +} diff --git a/test/qa/tests/platform/asound_state/byt/asound.state.volume b/test/qa/tests/platform/asound_state/byt/asound.state.volume new file mode 100644 index 000000000000..6302218c0454 --- /dev/null +++ b/test/qa/tests/platform/asound_state/byt/asound.state.volume @@ -0,0 +1,1014 @@ +state.sofbytcrrt5651 { + control.1 { + iface MIXER + name 'HP Playback Volume' + value.0 10 + value.1 10 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 39' + dbmin -4650 + dbmax 1200 + dbvalue.0 -3150 + dbvalue.1 -3150 + } + } + control.2 { + iface MIXER + name 'OUT Playback Volume' + value.0 26 + value.1 26 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 39' + dbmin -4650 + dbmax 1200 + dbvalue.0 -750 + dbvalue.1 -750 + } + } + control.3 { + iface MIXER + name 'DAC2 Playback Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.4 { + iface MIXER + name 'DAC1 Playback Volume' + value.0 159 + value.1 159 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 175' + dbmin -65625 + dbmax 0 + dbvalue.0 -6000 + dbvalue.1 -6000 + } + } + control.5 { + iface MIXER + name 'Mono DAC Playback Volume' + value.0 163 + value.1 163 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 175' + dbmin -65625 + dbmax 0 + dbvalue.0 -4500 + dbvalue.1 -4500 + } + } + control.6 { + iface MIXER + name 'IN1 Boost' + value 2 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 8' + dbmin 0 + dbmax 5200 + dbvalue.0 2400 + } + } + control.7 { + iface MIXER + name 'IN2 Boost' + value 1 + comment { + access 'read write' + type INTEGER + count 1 + range '0 - 8' + dbmin 0 + dbmax 5200 + dbvalue.0 2000 + } + } + control.8 { + iface MIXER + name 'IN Capture Volume' + value.0 8 + value.1 8 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 31' + dbmin -3450 + dbmax 1200 + dbvalue.0 -2250 + dbvalue.1 -2250 + } + } + control.9 { + iface MIXER + name 'ADC Capture Switch' + value.0 true + value.1 true + comment { + access 'read write' + type BOOLEAN + count 2 + } + } + control.10 { + iface MIXER + name 'ADC Capture Volume' + value.0 112 + value.1 112 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 127' + dbmin -17625 + dbmax 30000 + dbvalue.0 24375 + dbvalue.1 24375 + } + } + control.11 { + iface MIXER + name 'Mono ADC Capture Volume' + value.0 0 + value.1 0 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 127' + dbmin -17625 + dbmax 30000 + dbvalue.0 -17625 + dbvalue.1 -17625 + } + } + control.12 { + iface MIXER + name 'ADC Boost Gain' + value.0 0 + value.1 0 + comment { + access 'read write' + type INTEGER + count 2 + range '0 - 3' + dbmin 0 + dbmax 3600 + dbvalue.0 0 + dbvalue.1 0 + } + } + control.13 { + iface MIXER + name 'IF1 ASRC Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.14 { + iface MIXER + name 'IF2 ASRC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.15 { + iface MIXER + name 'DMIC ASRC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.16 { + iface MIXER + name 'ADC IF2 Data Switch' + value Normal + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Normal + item.1 Swap + item.2 'left copy to right' + item.3 'right copy to left' + } + } + control.17 { + iface MIXER + name 'DAC IF2 Data Switch' + value Normal + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 Normal + item.1 Swap + item.2 'left copy to right' + item.3 'right copy to left' + } + } + control.18 { + iface MIXER + name 'Headphone Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.19 { + iface MIXER + name 'Headset Mic Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.20 { + iface MIXER + name 'Internal Mic Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.21 { + iface MIXER + name 'Speaker Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.22 { + iface CARD + name 'Headphone Jack' + value true + comment { + access read + type BOOLEAN + count 1 + } + } + control.23 { + iface CARD + name 'Headset Mic Jack' + value true + comment { + access read + type BOOLEAN + count 1 + } + } + control.24 { + iface MIXER + name 'RECMIXL INL1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.25 { + iface MIXER + name 'RECMIXL BST3 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.26 { + iface MIXER + name 'RECMIXL BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.27 { + iface MIXER + name 'RECMIXL BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.28 { + iface MIXER + name 'RECMIXR INR1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.29 { + iface MIXER + name 'RECMIXR BST3 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.30 { + iface MIXER + name 'RECMIXR BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.31 { + iface MIXER + name 'RECMIXR BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.32 { + iface MIXER + name 'Stereo1 ADC L2 Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 DMIC + item.1 'DD MIX' + } + } + control.33 { + iface MIXER + name 'Stereo1 ADC R2 Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 DMIC + item.1 'DD MIX' + } + } + control.34 { + iface MIXER + name 'Stereo1 ADC L1 Mux' + value ADC + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 ADC + } + } + control.35 { + iface MIXER + name 'Stereo1 ADC R1 Mux' + value ADC + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 ADC + } + } + control.36 { + iface MIXER + name 'Stereo2 ADC L2 Mux' + value 'DD MIXL' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DMIC L' + item.1 'DD MIXL' + } + } + control.37 { + iface MIXER + name 'Stereo2 ADC L1 Mux' + value ADCL + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIXL' + item.1 ADCL + } + } + control.38 { + iface MIXER + name 'Stereo2 ADC R1 Mux' + value 'DD MIXR' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIXR' + item.1 ADCR + } + } + control.39 { + iface MIXER + name 'Stereo2 ADC R2 Mux' + value 'DMIC R' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DMIC R' + item.1 'DD MIXR' + } + } + control.40 { + iface MIXER + name 'Stereo1 ADC MIXL ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.41 { + iface MIXER + name 'Stereo1 ADC MIXL ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.42 { + iface MIXER + name 'Stereo1 ADC MIXR ADC1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.43 { + iface MIXER + name 'Stereo1 ADC MIXR ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.44 { + iface MIXER + name 'Stereo2 ADC MIXL ADC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.45 { + iface MIXER + name 'Stereo2 ADC MIXL ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.46 { + iface MIXER + name 'Stereo2 ADC MIXR ADC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.47 { + iface MIXER + name 'Stereo2 ADC MIXR ADC2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.48 { + iface MIXER + name 'IF2 ADC' + value 'IF1 ADC1' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'IF1 ADC1' + item.1 'IF1 ADC2' + } + } + control.49 { + iface MIXER + name 'PDM L Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 'Stereo DAC MIX' + } + } + control.50 { + iface MIXER + name 'PDM R Mux' + value 'DD MIX' + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 'DD MIX' + item.1 'Stereo DAC MIX' + } + } + control.51 { + iface MIXER + name 'DAC MIXL Stereo ADC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.52 { + iface MIXER + name 'DAC MIXL INF1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.53 { + iface MIXER + name 'DAC MIXR Stereo ADC Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.54 { + iface MIXER + name 'DAC MIXR INF1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.55 { + iface MIXER + name 'DAC L2 Mux' + value IF2 + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 IF1 + item.1 IF2 + } + } + control.56 { + iface MIXER + name 'DAC R2 Mux' + value IF2 + comment { + access 'read write' + type ENUMERATED + count 1 + item.0 IF1 + item.1 IF2 + } + } + control.57 { + iface MIXER + name 'Stereo DAC MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.58 { + iface MIXER + name 'Stereo DAC MIXL DAC L2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.59 { + iface MIXER + name 'Stereo DAC MIXL DAC R1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.60 { + iface MIXER + name 'Stereo DAC MIXR DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.61 { + iface MIXER + name 'Stereo DAC MIXR DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.62 { + iface MIXER + name 'Stereo DAC MIXR DAC L1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.63 { + iface MIXER + name 'DD MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.64 { + iface MIXER + name 'DD MIXL DAC L2 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.65 { + iface MIXER + name 'DD MIXL DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.66 { + iface MIXER + name 'DD MIXR DAC R1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.67 { + iface MIXER + name 'DD MIXR DAC R2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.68 { + iface MIXER + name 'DD MIXR DAC L2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.69 { + iface MIXER + name 'OUT MIXL BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.70 { + iface MIXER + name 'OUT MIXL BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.71 { + iface MIXER + name 'OUT MIXL INL1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.72 { + iface MIXER + name 'OUT MIXL REC MIXL Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.73 { + iface MIXER + name 'OUT MIXL DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.74 { + iface MIXER + name 'OUT MIXR BST2 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.75 { + iface MIXER + name 'OUT MIXR BST1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.76 { + iface MIXER + name 'OUT MIXR INR1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.77 { + iface MIXER + name 'OUT MIXR REC MIXR Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.78 { + iface MIXER + name 'OUT MIXR DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.79 { + iface MIXER + name 'OUTVOL L Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.80 { + iface MIXER + name 'OUTVOL R Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.81 { + iface MIXER + name 'HPOVOL L Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.82 { + iface MIXER + name 'HPOVOL R Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.83 { + iface MIXER + name 'HPO MIX DAC1 Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.84 { + iface MIXER + name 'HPO MIX HPVOL Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.85 { + iface MIXER + name 'LOUT MIX DAC L1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.86 { + iface MIXER + name 'LOUT MIX DAC R1 Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.87 { + iface MIXER + name 'LOUT MIX OUTVOL L Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.88 { + iface MIXER + name 'LOUT MIX OUTVOL R Switch' + value false + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.89 { + iface MIXER + name 'HPO L Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.90 { + iface MIXER + name 'HPO R Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.91 { + iface MIXER + name 'LOUT L Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } + control.92 { + iface MIXER + name 'LOUT R Playback Switch' + value true + comment { + access 'read write' + type BOOLEAN + count 1 + } + } +} diff --git a/test/qa/tests/platform/byt/feature-test b/test/qa/tests/platform/byt/feature-test new file mode 100644 index 000000000000..1f806f4a5ffa --- /dev/null +++ b/test/qa/tests/platform/byt/feature-test @@ -0,0 +1,8 @@ +PCM_playback check_pcm_playback +PCM_playback check_line_in_out_playback +PCM_playback check_dual_channels_playback +volume_control get_mixer_properties +volume_control set_HP_volume_to_minimum +volume_control set_HP_volume_to_maximum +volume_control set_ADC_volume_to_minimum +volume_control set_ADC_volume_to_maximum diff --git a/test/qa/tests/platform/byt/minnow/feature-test b/test/qa/tests/platform/byt/minnow/feature-test new file mode 100644 index 000000000000..241b1397f711 --- /dev/null +++ b/test/qa/tests/platform/byt/minnow/feature-test @@ -0,0 +1,7 @@ +PCM_playback check_line_in_out_playback +PCM_playback check_dual_channels_playback +volume_control get_mixer_properties +volume_control set_HP_volume_to_minimum +volume_control set_HP_volume_to_maximum +volume_control set_ADC_volume_to_minimum +volume_control set_ADC_volume_to_maximum diff --git a/test/qa/tests/platform/byt/minnow/tplg b/test/qa/tests/platform/byt/minnow/tplg new file mode 100644 index 000000000000..076b01ca5fce --- /dev/null +++ b/test/qa/tests/platform/byt/minnow/tplg @@ -0,0 +1,3 @@ +test-ssp2-mclk-0-I2S-volume-s16le-s24le-48k-19200k-codec.tplg +test-ssp2-mclk-0-I2S-volume-s24le-s24le-48k-19200k-codec.tplg +test-ssp2-mclk-0-I2S-volume-s24le-s16le-48k-19200k-codec.tplg diff --git a/test/qa/tests/platform/byt/tplg b/test/qa/tests/platform/byt/tplg new file mode 100644 index 000000000000..f57370f0b9ff --- /dev/null +++ b/test/qa/tests/platform/byt/tplg @@ -0,0 +1,7 @@ +test-ssp2-I2S-volume-s16le-s16le-48k-19200k-codec.tplg-0 +test-ssp2-I2S-volume-s16le-s16le-48k-19200k-codec.tplg-1 +test-ssp2-I2S-volume-s16le-s16le-48k-19200k-codec.tplg-2 +test-ssp2-I2S-volume-s16le-s16le-48k-19200k-codec.tplg-3 +test-ssp2-I2S-volume-s16le-s16le-48k-19200k-codec.tplg-4 +test-ssp2-I2S-volume-s16le-s16le-48k-19200k-codec.tplg-5 +test-ssp2-I2S-volume-s16le-s16le-48k-19200k-codec.tplg-6 diff --git a/test/qa/tests/smoke_test/byt_smoke_test_48k16bit_passthrough.sh b/test/qa/tests/smoke_test/byt_smoke_test_48k16bit_passthrough.sh new file mode 100755 index 000000000000..0ac1714665c0 --- /dev/null +++ b/test/qa/tests/smoke_test/byt_smoke_test_48k16bit_passthrough.sh @@ -0,0 +1,144 @@ +#!/bin/bash + +# default devices +psth_p="0,0" # device ID of pass-through playback +psth_c="0,0" # device ID of pass-through capture + +# flag for modules status +flag=0 + +# audio modules list +modules_list="sof_acpi_dev snd_sof_intel_hsw snd_sof_intel_bdw snd_sof_intel_byt snd_soc_sst_bytcr_rt5651 + snd_soc_rt5651 snd_sof snd_soc-core snd_soc_acpi snd_soc_acpi_intel_match snd_soc_rl6231" + +# features passes vs. features all +feature_pass=0 +feature_cnt=1 + +init_counter () { + feature_pass=0 + feature_all=0 +} + +evaluate_result () { + feature_cnt=$((feature_cnt+1)) + if [ $1 -eq 0 ]; then + feature_pass=$((feature_pass+1)) + echo "pass" + sleep 1 + else + echo "fail" + sleep 1 + fi +} + +print_result () { + let feature_cnt=$feature_cnt-1 + echo "[$feature_pass/$feature_cnt] features passes." +} + +# test items +run_feature_test() { + init_counter + + # check FW loading + echo "$feature_cnt: check FW loading" + dmesg |grep "firmware boot complete" > /dev/null + evaluate_result $? + # check sound modules + echo "$feature_cnt: check sound modules" + lsmod |grep "snd" > /dev/null + evaluate_result $? + # check sof modules + echo "$feature_cnt: check sof modules" + lsmod |grep "sof" > /dev/null + evaluate_result $? + # check PCMs + echo "$feature_cnt: check playback PCMs list" + aplay -l |grep "device" + evaluate_result $? + echo "$feature_cnt: check capture PCM list" + arecord -l |grep "device" > /dev/null + evaluate_result $? + # check audio playback + echo "$feature_cnt: check Mono wav playback with pass-through pipeline" + aplay -Dhw:$psth_p -c1 -r48000 -f dat -d5 /dev/zero > /dev/null + evaluate_result $? + echo "$feature_cnt: check stereo wav playback with pass-through pipeline" + aplay -Dhw:$psth_p -c2 -r48000 -f dat -d5 /dev/zero > /dev/null + evaluate_result $? + # check audio capture + echo "$feature_cnt: check mono wav capture" + arecord -Dhw:$path_c -c1 -r48000 -f dat -d2 /dev/zero + evaluate_result $? + echo "$feature_cnt: check stereo wav capture" + arecord -Dhw:$psth_c -c2 -r48000 -f dat -d5 /dev/null + evaluate_result $? + # check modules unloadable + echo "$feature_cnt: check the modules unloadable" + for modules in $modules_list + do + rmmod $modules + done + lsmod |grep snd_soc + if [ $? -eq 0 ]; then + evaluate_result 1 + flag=0 + else + evaluate_result 0 + flag=1 + fi + # check the modules reloadable + echo "$feature_cnt: check the modules reloadable" + if [ $flag -eq 1 ]; then + modprobe sof-acpi-dev + if [ $? -eq 0 ]; then + evaluate_result 0 + flag=0 + else + evaluate_result 1 + flag=1 + fi + else + echo "modules unload failed, skip modules reloadable test" + let feature_cnt=$feature_cnt-1 + fi + # check playback/capture after modules reloaded + sleep 8 # waiting for PCM device ready + if [ $flag -eq 0 ]; then + echo "$feature_cnt: check audio playback after modules reloaded" + aplay -Dhw:$psth_p -c2 -r48000 -f dat -d5 /dev/zero + evaluate_result $? + echo "$feature_cnt: check audio capture after modules reloaded" + arecord -Dhw:$psth_c -c2 -r48000 -f dat -d5 /dev/null + evaluate_result $? + else + echo "modules reloading failed, skip the playback/capture check" + fi + + print_result +} + +echo "*******************************************" +echo " SOF Smoke Test " +echo "-------------------------------------------" + +# get device +echo "usage:" +echo " $0 " + +if [ $# -eq 2 ]; then + psth_p=$1 + psth_c=$2 +elif [ $# -eq 1 ]; then + psth_p=$1 + psth_c=$1 +fi + +echo "current setting:" +echo " playback device: pass-through playback device: $psth_p \ + capture device: pass-through capture device: $psth_c" + +# run test +run_feature_test +echo "*******************************************" diff --git a/test/qa/tests/stability_test/test_modules_reloadable.sh b/test/qa/tests/stability_test/test_modules_reloadable.sh new file mode 100755 index 000000000000..335a98118ed1 --- /dev/null +++ b/test/qa/tests/stability_test/test_modules_reloadable.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +COUNTER=0 +MAXLOOPS=100 +touch test.log + +# remove audio modules +remove() +{ + rmmod sof_acpi_dev + rmmod snd_soc_acpi_intel_match +# rmmod snd_sof_nocodec +# rmmod snd_sof_intel_hsw +# rmmod snd_sof_intel_bdw + rmmod snd_sof_intel_byt + rmmod snd_sof + rmmod snd_soc_sst_bytcr_rt5651 + rmmod snd_soc_acpi +} + +# reload audio modules +reload() +{ + modprobe sof_acpi_dev +} + +err_check() +{ + unset FW_BOOT + unset ERROR + FW_BOOT=$(dmesg | grep sof-audio | grep "boot complete") + ERROR=$(dmesg | grep sof-audio | grep "error") + if [ ! -z "$ERROR" ] || [ -z "$FW_BOOT" ] + then + echo "modules reload failed with error" + dmesg > dmesg.log + exit 1 + else + echo "audio modules are reloaded successfully" + fi +} + +playback() +{ + aplay -D hw:0,0 -r 48000 -c2 -f dat -d5 /dev/zero +} + +main() +{ +echo "modules reloadable test start: " > result.log +while [ $COUNTER -lt $MAXLOOPS ]; do + echo "test $COUNTER" + echo "audio modules are removing..." + remove + if [ $? -eq 0 ]; then + echo "$COUNTER: modules remove - PASS" >> result.log + else + echo "$COUNTER: modules remove - FAIL" >> result.log + dmesg > dmesg.log + exit 1 + fi + sleep 1 + + # check modules is removed + aplay -l |grep "device" > /dev/null + if [ $? -ne 0 ]; then + echo "$COUNTER: check audio device after modules removed - PASS" >> result.log + else + echo "$COUNTER: check audio device after modules removed - FAIL" >> result.log + dmesg > dmesg.log + exit 1 + fi + sleep 1 + + # reload the audio moduels + echo "audio modules are reloading..." + reload + if [ $? -eq 0 ]; then + echo "$COUNTER: modules reload - PASS" >> result.log + else + echo "$COUNTER: modules reload - FAIL" >> result.log + dmesg > dmesg.log + exit 1 + fi + + # check the error log + err_check + + sleep 8 # wait for modules initComplete + + # check playback after modules reloaded + playback + if [ $? -eq 0 ]; then + echo "$COUNTER: playback after modules reloaded - PASS" >> result.log + else + echo "$COUNTER: playback after modules reloaded - FAIL" >> result.log + dmesg > dmesg.log + exit 1 + fi + + sleep 1 + let COUNTER+=1 +done +} + +main diff --git a/topology/test/Makefile.am b/test/topology/Makefile.am similarity index 74% rename from topology/test/Makefile.am rename to test/topology/Makefile.am index 3a613e84a300..be2830bd2b92 100644 --- a/topology/test/Makefile.am +++ b/test/topology/Makefile.am @@ -8,10 +8,10 @@ export USE_XARGS=yes endif DEPS = \ - ../platform/intel/*.m4 \ - ../common/*.m4 \ - ../m4/*.m4 \ - ../sof/*.m4 + ../../topology/platform/intel/*.m4 \ + ../../topology/common/*.m4 \ + ../../topology/m4/*.m4 \ + ../../topology/sof/*.m4 # Uncomment the following line if you want to debug conf files .PRECIOUS: %.conf diff --git a/topology/test/test-all.m4 b/test/topology/test-all.m4 similarity index 100% rename from topology/test/test-all.m4 rename to test/topology/test-all.m4 diff --git a/topology/test/test-capture.m4 b/test/topology/test-capture.m4 similarity index 100% rename from topology/test/test-capture.m4 rename to test/topology/test-capture.m4 diff --git a/topology/test/test-equalizer-playback-ssp.m4 b/test/topology/test-equalizer-playback-ssp.m4 similarity index 100% rename from topology/test/test-equalizer-playback-ssp.m4 rename to test/topology/test-equalizer-playback-ssp.m4 diff --git a/topology/test/test-playback.m4 b/test/topology/test-playback.m4 similarity index 100% rename from topology/test/test-playback.m4 rename to test/topology/test-playback.m4 diff --git a/topology/test/test-tone-playback.m4 b/test/topology/test-tone-playback.m4 similarity index 100% rename from topology/test/test-tone-playback.m4 rename to test/topology/test-tone-playback.m4 diff --git a/topology/test/tplg-build.sh b/test/topology/tplg-build.sh similarity index 98% rename from topology/test/tplg-build.sh rename to test/topology/tplg-build.sh index bd505930d1fc..da4fbad53d7d 100755 --- a/topology/test/tplg-build.sh +++ b/test/topology/tplg-build.sh @@ -8,7 +8,7 @@ set -e # M4 preprocessor flags -export M4PATH="../:../m4:../common:../platform/intel:../platform/common" +export M4PATH="../../topology/:../../topology/m4:../../topology/common:../../topology/platform/intel:../../topology/platform/common" # Simple component test cases # can be used on components with 1 sink and 1 source. From 97ae708c5e5fb2bdad642a8b7525f75470ebf1c5 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Mon, 15 Oct 2018 08:16:24 +0800 Subject: [PATCH 271/324] topology: enable hdmi support on UP2 board Add HDMI support to sof-apl-pcm512x Signed-off-by: Pan Xiuli --- topology/sof-apl-pcm512x.m4 | 60 +++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/topology/sof-apl-pcm512x.m4 b/topology/sof-apl-pcm512x.m4 index 48257ae3e8b0..3b4d01e9cc79 100644 --- a/topology/sof-apl-pcm512x.m4 +++ b/topology/sof-apl-pcm512x.m4 @@ -7,6 +7,7 @@ include(`utils.m4') include(`dai.m4') include(`pipeline.m4') include(`ssp.m4') +include(`hda.m4') # Include TLV library include(`common/tlv.m4') @@ -25,16 +26,43 @@ DEBUG_START # PCM0 ----> volume -----> SSP5 (pcm512x) # +dnl PIPELINE_PCM_ADD(pipeline, +dnl pipe id, pcm, max channels, format, +dnl frames, deadline, priority, core) + # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, 1, 0, 2, s32le, 48, 1000, 0, 0) +# Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 2, 1, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 3 on PCM 2 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 3, 2, 2, s32le, + 48, 1000, 0, 0) + +# Low Latency playback pipeline 4 on PCM 3 using max 2 channels of s32le. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, + 4, 3, 2, s32le, + 48, 1000, 0, 0) + # # DAIs configuration # +dnl DAI_ADD(pipeline, +dnl pipe id, dai type, dai_index, dai_be, +dnl buffer, periods, format, +dnl frames, deadline, priority, core) + # playback DAI is SSP5 using 2 periods # Buffers use s24le format, with 48 frame per 1000us on core 0 with priority 0 DAI_ADD(sof/pipe-dai-playback.m4, @@ -42,13 +70,39 @@ DAI_ADD(sof/pipe-dai-playback.m4, PIPELINE_SOURCE_1, 2, s24le, 48, 1000, 0, 0) +# playback DAI is iDisp1 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 2, HDA, 0, iDisp1, + PIPELINE_SOURCE_2, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is iDisp2 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 3, HDA, 1, iDisp2, + PIPELINE_SOURCE_3, 2, s32le, + 48, 1000, 0, 0) + +# playback DAI is iDisp3 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-playback.m4, + 4, HDA, 2, iDisp3, + PIPELINE_SOURCE_4, s32le, + 48, 1000, 0, 0) + # PCM Low Latency, id 0 +dnl PCM_PLAYBACK_ADD(name, pcm_id, playback) PCM_PLAYBACK_ADD(Port5, 0, PIPELINE_PCM_1) +PCM_PLAYBACK_ADD(HDMI1, 1, PIPELINE_PCM_2) +PCM_PLAYBACK_ADD(HDMI2, 2, PIPELINE_PCM_3) +PCM_PLAYBACK_ADD(HDMI3, 3, PIPELINE_PCM_4) # # BE configurations - overrides config in ACPI if present # +#SSP 5 (ID: 0) DAI_CONFIG(SSP, 5, 0, SSP5-Codec, SSP_CONFIG(I2S, SSP_CLOCK(mclk, 24576000, codec_mclk_in), SSP_CLOCK(bclk, 3072000, codec_slave), @@ -56,4 +110,10 @@ DAI_CONFIG(SSP, 5, 0, SSP5-Codec, SSP_TDM(2, 32, 3, 3), SSP_CONFIG_DATA(SSP, 5, 24))) +# 3 HDMI/DP outputs (ID: 1,2,3) +dnl HDA_DAI_CONFIG(dai_index, link_id, name) +HDA_DAI_CONFIG(0, 1, iDisp1) +HDA_DAI_CONFIG(1, 2, iDisp2) +HDA_DAI_CONFIG(2, 3, iDisp3) + DEBUG_END From 9250bfe034ebd199d6c10043642fd227f9d585b0 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 15 Oct 2018 10:44:42 +0300 Subject: [PATCH 272/324] EQ: Update new path into objective quality test functions This patch fixes the path issue from previous directory structure maintenance. Signed-off-by: Seppo Ingalsuo --- test/{ => audio}/test_utils/mls_calc_resp.m | 0 tune/eq/mls_freq_resp.m | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename test/{ => audio}/test_utils/mls_calc_resp.m (100%) diff --git a/test/test_utils/mls_calc_resp.m b/test/audio/test_utils/mls_calc_resp.m similarity index 100% rename from test/test_utils/mls_calc_resp.m rename to test/audio/test_utils/mls_calc_resp.m diff --git a/tune/eq/mls_freq_resp.m b/tune/eq/mls_freq_resp.m index 8a96461a3840..cee76c6500b2 100644 --- a/tune/eq/mls_freq_resp.m +++ b/tune/eq/mls_freq_resp.m @@ -85,7 +85,7 @@ csvfn = sprintf('mls-%s.txt', id); %% Paths -addpath('../../test/test_utils'); +addpath('../../test/audio/test_utils'); %% MLS n_mls = round(fs*t_mls_s); From 0913d7c83a7eb83115471472f3412a6682381035 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 12 Oct 2018 18:46:30 +0300 Subject: [PATCH 273/324] EQ: Fix an integer type bug in IIR coefficients blob packer This patch adds explicit conversion to signed int32 type for response to channels indices in assign_response and filter coefficients. The bug was visible if trying to activate in IIR blob the per channel filter bypass by having a negative value (-1) in any of channel assigns. Octave assumed the type to be unsigned and produced wrong configuration bytes. The filter coefficients are already integer type from previous quantization code in the conversion process. However it does not hurt to have extra safety to avoid similar issue as assign. Signed-off-by: Seppo Ingalsuo --- tune/eq/eq_iir_blob_pack.m | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tune/eq/eq_iir_blob_pack.m b/tune/eq/eq_iir_blob_pack.m index 8a55f38cbceb..3f33cb709afb 100644 --- a/tune/eq/eq_iir_blob_pack.m +++ b/tune/eq/eq_iir_blob_pack.m @@ -41,6 +41,12 @@ endian = 'little'; end +%% Channels count and assign vector lengths must be the same +if bs.platform_max_channels ~= length( bs.assign_response) + bs + error("Channels # and response assign length must match"); +end + %% Shift values for little/big endian switch lower(endian) case 'little' @@ -63,12 +69,14 @@ blob8(j:j+3) = w2b(bs.number_of_responses_defined, sh); j=j+4; for i=1:bs.platform_max_channels - blob8(j:j+3) = w2b(bs.assign_response(i), sh); j=j+4; + blob8(j:j+3) = w2b(int32(bs.assign_response(i)), sh); + j=j+4; end %% Pack coefficients for i=1:length(bs.all_coefficients) - blob8(j:j+3) = w2b(bs.all_coefficients(i), sh); j=j+4; + blob8(j:j+3) = w2b(int32(bs.all_coefficients(i)), sh); + j=j+4; end fprintf('Blob size is %d bytes.\n', nbytes); From c9731f1678e32b8dcef5e1d997dcec1a9f1dd75c Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Mon, 15 Oct 2018 11:08:06 +0200 Subject: [PATCH 274/324] rmbox: usage function refinement Refines the output content when displaying the logger usage. Signed-off-by: Bartosz Kokoszko --- rmbox/rmbox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 671a2d1bea57..b66ce1c9654f 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -41,8 +41,8 @@ static void usage(void) fprintf(stdout, "%s:\t \t\t\tDisplay mailbox contents\n", APP_NAME); fprintf(stdout, "%s:\t -i infile -o outfile\tDump infile contents to outfile\n", APP_NAME); #ifdef LOGGER_FORMAT - fprintf(stdout, "%s:\t -l *.ldc_file\t-i in_file\n", APP_NAME); - fprintf(stdout, "%s:\t -p \tinput from stdin\n", APP_NAME); + fprintf(stdout, "%s:\t -l *.ldc_file\t\t*.ldc files generated by rimage\n", APP_NAME); + fprintf(stdout, "%s:\t -p \t\t\tInput from stdin\n", APP_NAME); #endif fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", APP_NAME); fprintf(stdout, "%s:\t -s\t\t\tTake a snapshot of state\n", APP_NAME); From 7ad6c23121df528fcb73a47ba38d0eaec1a8f213 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Thu, 11 Oct 2018 11:34:14 +0200 Subject: [PATCH 275/324] rmbox: fix rmbox KW issues Signed-off-by: Bartosz Kokoszko --- rmbox/logger_convert.c | 29 +++++++++++++++++++++++++++-- rmbox/rmbox.c | 2 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index 7156b61ad365..e54f3d535644 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -24,6 +24,10 @@ #define CEIL(a, b) ((a+b-1)/b) +#define TRACE_MAX_PARAMS_COUNT 4 +#define TRACE_MAX_TEXT_LEN 1024 +#define TRACE_MAX_FILENAME_LEN 128 + /* logs file signature */ #define SND_SOF_LOGS_SIG_SIZE 4 #define SND_SOF_LOGS_SIG "Logs" @@ -172,8 +176,13 @@ static int fetch_entry(struct convert_config *config, uint32_t base_address, ret = -ferror(config->ldc_fd); goto out; } - + if (entry.header.file_name_len > TRACE_MAX_FILENAME_LEN) { + fprintf(stderr, "Error: Invalid filename length. \n"); + ret = -EINVAL; + goto out; + } entry.file_name = (char *)malloc(entry.header.file_name_len); + if (!entry.file_name) { fprintf(stderr, "error: can't allocate %d byte for " "entry.file_name\n", entry.header.file_name_len); @@ -200,6 +209,11 @@ static int fetch_entry(struct convert_config *config, uint32_t base_address, } /* fetching text */ + if (entry.text_len > TRACE_MAX_TEXT_LEN) { + fprintf(stderr, "Error: Invalid text length. \n"); + ret = -EINVAL; + goto out; + } entry.text = (char *)malloc(entry.text_len); if (entry.text == NULL) { fprintf(stderr, "error: can't allocate %d byte for " @@ -207,7 +221,6 @@ static int fetch_entry(struct convert_config *config, uint32_t base_address, ret = -ENOMEM; goto out; } - ret = fread(entry.text, sizeof(char), entry.text_len, config->ldc_fd); if (ret != entry.text_len) { ret = -ferror(config->ldc_fd); @@ -215,8 +228,20 @@ static int fetch_entry(struct convert_config *config, uint32_t base_address, } /* fetching entry params from dma dump */ + if (entry.header.params_num > TRACE_MAX_PARAMS_COUNT) { + fprintf(stderr, "Error: Invalid number of parameters. \n"); + ret = -EINVAL; + goto out; + } entry.params = (uint32_t *)malloc(sizeof(uint32_t) * entry.header.params_num); + if (entry.params == NULL) { + fprintf(stderr, "error: can't allocate %d byte for " + "entry.params\n", (int)(sizeof(uint32_t) * + entry.header.params_num)); + ret = -ENOMEM; + goto out; + } ret = fread(entry.params, sizeof(uint32_t), entry.header.params_num, config->in_fd); if (ret != entry.header.params_num) { diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 671a2d1bea57..6a53be74fce1 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -214,7 +214,7 @@ int main(int argc, char *argv[]) out: /* close files */ - if (config.out_file) + if (config.out_fd) fclose(config.out_fd); if (config.in_fd) From e6885d04a785285cbf3031177385d91ca461e8ab Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Fri, 12 Oct 2018 13:02:55 +0200 Subject: [PATCH 276/324] readme: upgrade readme with sof-logger instruction Signed-off-by: Bartosz Kokoszko --- README | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/README b/README index a8f818b8ecb4..f647ac637e6c 100644 --- a/README +++ b/README @@ -34,6 +34,83 @@ xtensa-byt-elf-objcopy -I binary -O elf32-xtensa-le -B xtensa image.bin image.bi xtensa-byt-elf-objdump -D image.bin.elf > image.dis.txt + +sof-logger +====== + +sof-logger is used to print logs delivered from FW dma_trace mechanism, by searching log +entries in *.ldc file generated by rimage. + +Every entry declared in FW is placed in elf output file (e.g. sof-apl) in +.static_log_entries section in a form of struct defined in sof/src/include/sof/trace.h +in sof fw repo. + +*.ldc file contains snd_sof_logs_header (defined in rmbox/logger_convert.c) +following by .static_log_entries section incorporated from FW elf file (e.g. sof-apl). +snd_sof_logs_header contains basic information about .static_log_entries section +like base_address and data_length. + +sof-logger works by reading entry parameters value and entries addresses from FW +dma_trace mechanism and searching suitable entry in *.ldc file by its address. + +Usage sof-logger + Display mailbox contents +-h help +-l *.ldc_file Specify the *.ldc file +-i in_file Get traces from in_file, instead of the default + "/sys/kernel/debug/sof/etrace" +-o out_file Specify the output file, instead of default stdout +-t Get traces from "/sys/kernel/debug/sof/trace", instead + of the default "/sys/kernel/debug/sof/etrace" +-p Get traces from stdin, instead of the default + "/sys/kernel/debug/sof/etrace" +-c Set timestamp clock in MHz +-s Take a snapshot of state + + +Examples: + +- Get traces from "/sys/kernel/debug/sof/etrace" file and prints logs to stdout + + $ sof-logger -l ldc_file + +- Get traces from "/sys/kernel/debug/sof/etrace" file and prints logs to + out_file file + + $ sof-logger -l ldc_file -o out_file + +- Get traces from "/sys/kernel/debug/sof/trace" file and prints logs to stdout + + $ sof-logger -l ldc_file -t + +- Get traces from "/sys/kernel/debug/sof/trace" file and prints logs to + out_file file + + $ sof-logger -l ldc_file -t -o out_file + +- Get traces from stdin and prints logs to stdout + + $ sof-logger -l ldc_file -p + +- Get traces from stdin and prints logs to out_file file + + $ sof-logger -l ldc_file -p -o out_file + +- Get traces from trace_dump file and prints logs to stdout + + $ sof-logger -l ldc_file -i trace_dump + +- Get traces from trace_dump file and prints logs to out_file file + + $ sof-logger -l ldc_file -i trace_dump -o out_file + +- c flag is intented for defining clock value (in MHz) used to format log + timestamps. By default clock value is set to 19.2 (MHz). Below example + set clock value to 19.9 (MHz). + + $ sof-logger -l ldc_file -i trace_dump -o out_file -c 19.9 + + tests ===== From c8f671b7461d0e77d4e0675e87c138d923c698a5 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Fri, 12 Oct 2018 14:56:41 +0200 Subject: [PATCH 277/324] rmbox: change bins name to sof-logger sof-rmbox Change binary names: from logger to sof-logger and from rmbox to sof-rmbox Signed-off-by: Bartosz Kokoszko --- rmbox/Makefile.am | 10 +++++----- rmbox/rmbox.c | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rmbox/Makefile.am b/rmbox/Makefile.am index 40017a7f5bb4..c35e6e95579f 100644 --- a/rmbox/Makefile.am +++ b/rmbox/Makefile.am @@ -1,12 +1,12 @@ -bin_PROGRAMS = rmbox logger +bin_PROGRAMS = sof-rmbox sof-logger -rmbox_SOURCES = \ +sof_rmbox_SOURCES = \ rmbox.c \ rmbox_convert.c -logger_SOURCES = \ +sof_logger_SOURCES = \ rmbox.c \ logger_convert.c -logger_CFLAGS = \ - -DLOGGER_FORMAT \ No newline at end of file +sof_logger_CFLAGS = \ + -DLOGGER_FORMAT diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index da52f1bfd5b7..e5e965be4acd 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -22,9 +22,9 @@ #include "convert.h" #ifdef LOGGER_FORMAT -#define APP_NAME "logger" +#define APP_NAME "sof-logger" #else -#define APP_NAME "rmbox" +#define APP_NAME "sof-rmbox" #endif #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) From 7a8ed190e8e22fff64386eea080a2c8a32d64840 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Mon, 15 Oct 2018 19:20:26 +0300 Subject: [PATCH 278/324] eqctl: Add check for calloc() success and return 0 in exit This patch adds the missed details into the code. Signed-off-by: Seppo Ingalsuo --- eqctl/eqctl.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/eqctl/eqctl.c b/eqctl/eqctl.c index 843a047c03ab..8963c5cb47b7 100644 --- a/eqctl/eqctl.c +++ b/eqctl/eqctl.c @@ -196,6 +196,12 @@ int main(int argc, char *argv[]) */ buffer_size = ctrl_size + 2 * sizeof(unsigned int); user_data = calloc(1, buffer_size); + if (!user_data) { + fprintf(stderr, + "Error: Failed to allocate buffer for user data.\n"); + exit(EXIT_FAILURE); + } + user_data[0] = SOF_CTRL_CMD_BINARY; if (set) { fprintf(stdout, "Applying configuration \"%s\" ", setup); @@ -242,4 +248,5 @@ int main(int argc, char *argv[]) } } free(user_data); + return 0; } From 53f90d9c6a49b466a6689e83413b92195b6961c7 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Thu, 4 Oct 2018 16:57:11 +0300 Subject: [PATCH 279/324] Topology: DMIC: Reduce PCM capabilities to DMIC configuration This patch impacts topologies sof-apl-nocodec, sof-apl-da7219, and sof-glk-da7219 those use the pipe-passthrough-capture macro for DMIC. The PCM saple rate is limited to 48 kHz (was 8 - 192 kHz). The capture channels count can be only PIPELINE_CHANNELS (was 1 - PIPELINE_CHANNELS). This prevents corrupted audio capture that happens when DMIC topology parameters and capture parameters differ. It happens because DMIC FIFOs drop samples or add unwanted samples when the configuration does not match. In sof-apl-nocodec topology the PIPELINE_CHANNELS is set to 2 that matches the configuration. Signed-off-by: Seppo Ingalsuo --- topology/sof-apl-nocodec.m4 | 4 ++-- topology/sof/pipe-passthrough-capture.m4 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index da61ece08787..2a9956087621 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -112,10 +112,10 @@ PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, 12, 5, 2, s16le, 48, 1000, 0, 0) -# Passthrough capture pipeline 13 on PCM 6 using max 4 channels. +# Passthrough capture pipeline 13 on PCM 6 using max 2 channels. # Schedule 48 frames per 1000us deadline on core 0 with priority 0 PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, - 13, 6, 4, s32le, + 13, 6, 2, s32le, 48, 1000, 0, 0) # diff --git a/topology/sof/pipe-passthrough-capture.m4 b/topology/sof/pipe-passthrough-capture.m4 index 5eb29a23597e..072b569456e0 100644 --- a/topology/sof/pipe-passthrough-capture.m4 +++ b/topology/sof/pipe-passthrough-capture.m4 @@ -44,4 +44,4 @@ indir(`define', concat(`PIPELINE_PCM_', PIPELINE_ID), Passthrough Capture PCM_ID # PCM Configuration # -PCM_CAPABILITIES(Passthrough Capture PCM_ID, COMP_FORMAT_NAME(PIPELINE_FORMAT), 8000, 192000, 1, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) +PCM_CAPABILITIES(Passthrough Capture PCM_ID, COMP_FORMAT_NAME(PIPELINE_FORMAT), 48000, 48000, PIPELINE_CHANNELS, PIPELINE_CHANNELS, 2, 16, 192, 16384, 65536, 65536) From b6016cd5e59a8862f34663a4ade2ba077da3881b Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 18 Oct 2018 18:43:37 +0800 Subject: [PATCH 280/324] topology: duplicate dai formart for pcm add In PIPELINE_PCM_ADD, DAI_FORMAT is not set but are used later. Need to set this value to avoid protenial issues. Signed-off-by: Pan Xiuli --- topology/m4/pipeline.m4 | 1 + 1 file changed, 1 insertion(+) diff --git a/topology/m4/pipeline.m4 b/topology/m4/pipeline.m4 index 7c1f307b7c66..8c0ac8779e59 100644 --- a/topology/m4/pipeline.m4 +++ b/topology/m4/pipeline.m4 @@ -51,6 +51,7 @@ define(`PIPELINE_PCM_ADD', `define(`SCHEDULE_DEADLINE', $7)' `define(`SCHEDULE_PRIORITY', $8)' `define(`SCHEDULE_CORE', $9)' +`define(`DAI_FORMAT', $5)' `include($1)' `DEBUG_PCM_ADD($1, $3)' ) From 489832137ca5e3d107d89137dc1939db3be5abcd Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 18 Oct 2018 18:54:32 +0800 Subject: [PATCH 281/324] topology: m4: add SOF_TKN_DAI_DIRECTION for DAI Signed-off-by: Rander Wang Signed-off-by: Pan Xiuli --- topology/sof/tokens.m4 | 1 + 1 file changed, 1 insertion(+) diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index b584f56e1dec..3810e3f354a5 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -18,6 +18,7 @@ SectionVendorTokens."sof_dai_tokens" { SOF_TKN_DAI_DMAC_CONFIG "153" SOF_TKN_DAI_TYPE "154" SOF_TKN_DAI_INDEX "155" + SOF_TKN_DAI_DIRECTION "156" } SectionVendorTokens."sof_sched_tokens" { From 25dcef9219ff2bd4c694697fa230744ecfdd965a Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 18 Oct 2018 18:56:42 +0800 Subject: [PATCH 282/324] topolgy: m4: add direction for widget dai Add direction for widget dai, 0 for playback and 1 for capture. Signed-off-by: Rander Wang Signed-off-by: Pan Xiuli --- topology/m4/dai.m4 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/topology/m4/dai.m4 b/topology/m4/dai.m4 index 74717189f197..2303671bc618 100644 --- a/topology/m4/dai.m4 +++ b/topology/m4/dai.m4 @@ -26,6 +26,7 @@ define(`W_DAI_OUT', ` tokens "sof_dai_tokens"' ` tuples."word" {' ` SOF_TKN_DAI_INDEX' $2 +` SOF_TKN_DAI_DIRECTION' "0" ` }' `}' `SectionData."'N_DAI_OUT($2)`_data_w" {' @@ -79,6 +80,7 @@ define(`W_DAI_IN', ` tokens "sof_dai_tokens"' ` tuples."word" {' ` SOF_TKN_DAI_INDEX' $2 +` SOF_TKN_DAI_DIRECTION' "1" ` }' `}' `SectionData."'N_DAI_IN($2)`_data_w" {' From 8d4b10c5399eb55b74f3af2d48eafae7311b0bd9 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 23 Oct 2018 11:27:25 +0300 Subject: [PATCH 283/324] Topology: Add 2ch and 4ch raw DMIC capture topologies for APL This patch adds two minimal capture topologies to enable doing tests those require raw audio capture with unmodified S32_LE samples, e.g. channels order preserve test where the mic # origin can be checked from side information in LSB bits. Signed-off-by: Seppo Ingalsuo --- topology/Makefile.am | 9 ++++- topology/sof-apl-dmic-2ch.m4 | 75 ++++++++++++++++++++++++++++++++++++ topology/sof-apl-dmic-4ch.m4 | 75 ++++++++++++++++++++++++++++++++++++ 3 files changed, 157 insertions(+), 2 deletions(-) create mode 100644 topology/sof-apl-dmic-2ch.m4 create mode 100644 topology/sof-apl-dmic-4ch.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index 3598055d5e63..d6809f1993b8 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -40,7 +40,10 @@ MACHINES = \ sof-glk-da7219.tplg \ sof-icl-nocodec.tplg \ sof-apl-eq-pcm512x.tplg \ - sof-apl-eq-dmic.tplg + sof-apl-eq-dmic.tplg \ + sof-apl-dmic-2ch.tplg \ + sof-apl-dmic-4ch.tplg + # Uncomment the following line if you want to debug conf files .PRECIOUS: %.conf @@ -81,4 +84,6 @@ EXTRA_DIST = \ sof-glk-da7219.m4 \ sof-icl-nocodec.m4 \ sof-apl-eq-pcm512x.m4 \ - sof-apl-eq-dmic.m4 + sof-apl-eq-dmic.m4 \ + sof-apl-dmic-4ch.m4 \ + sof-apl-dmic-2ch.m4 diff --git a/topology/sof-apl-dmic-2ch.m4 b/topology/sof-apl-dmic-2ch.m4 new file mode 100644 index 000000000000..0a8091b2904b --- /dev/null +++ b/topology/sof-apl-dmic-2ch.m4 @@ -0,0 +1,75 @@ +# +# Topology for Apollo Lake with direct attach digital microphones array +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`platform/intel/bxt.m4') +include(`platform/intel/dmic.m4') + +# +# Define the pipelines +# +# PCM6 <---- volume <----- DMIC6 (DMIC01) +# + +dnl PIPELINE_PCM_ADD(pipeline, +dnl pipe id, pcm, max channels, format, +dnl frames, deadline, priority, core) + + +# Passthrough capture pipeline 1 on PCM 6 using max 2 channels. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, + 1, 6, 2, s32le, + 48, 1000, 0, 0) + +# +# DAIs configuration +# + +dnl DAI_ADD(pipeline, +dnl pipe id, dai type, dai_index, dai_be, +dnl buffer, periods, format, +dnl frames, deadline, priority, core) + + +# capture DAI is DMIC 0 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, DMIC, 0, NoCodec-6, + PIPELINE_SINK_1, 2, s32le, + 48, 1000, 0, 0) + +dnl PCM_DUPLEX_ADD(name, pcm_id, playback, capture) + +dnl PCM_CAPTURE_ADD(name, pipeline, capture) +PCM_CAPTURE_ADD(DMIC01, 6, PIPELINE_PCM_1) + +# +# BE configurations - overrides config in ACPI if present +# + +dnl DAI_CONFIG(type, dai_index, link_id, name, ssp_config/dmic_config) + +DAI_CONFIG(DMIC, 0, 6, NoCodec-6, + dnl DMIC_CONFIG(driver_version, clk_min, clk_mac, duty_min, duty_max, + dnl sample_rate, + dnl fifo word length, type, dai_index, pdm controller config) + DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, + dnl DMIC_WORD_LENGTH(frame_format) + DMIC_WORD_LENGTH(s32le), DMIC, 0, + dnl PDM_CONFIG(type, dai_index, num pdm active, pdm tuples list) + dnl STEREO_PDM0 is a pre-defined pdm config for stereo capture + PDM_CONFIG(DMIC, 0, STEREO_PDM0))) + diff --git a/topology/sof-apl-dmic-4ch.m4 b/topology/sof-apl-dmic-4ch.m4 new file mode 100644 index 000000000000..74cbdb958838 --- /dev/null +++ b/topology/sof-apl-dmic-4ch.m4 @@ -0,0 +1,75 @@ +# +# Topology for Apollo Lake with direct attach digital microphones array +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`platform/intel/bxt.m4') +include(`platform/intel/dmic.m4') + +# +# Define the pipelines +# +# PCM6 <---- volume <----- DMIC6 (DMIC01) +# + +dnl PIPELINE_PCM_ADD(pipeline, +dnl pipe id, pcm, max channels, format, +dnl frames, deadline, priority, core) + + +# Passthrough capture pipeline 1 on PCM 6 using max 4 channels. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, + 1, 6, 4, s32le, + 48, 1000, 0, 0) + +# +# DAIs configuration +# + +dnl DAI_ADD(pipeline, +dnl pipe id, dai type, dai_index, dai_be, +dnl buffer, periods, format, +dnl frames, deadline, priority, core) + + +# capture DAI is DMIC 0 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, DMIC, 0, NoCodec-6, + PIPELINE_SINK_1, 2, s32le, + 48, 1000, 0, 0) + +dnl PCM_DUPLEX_ADD(name, pcm_id, playback, capture) + +dnl PCM_CAPTURE_ADD(name, pipeline, capture) +PCM_CAPTURE_ADD(DMIC01, 6, PIPELINE_PCM_1) + +# +# BE configurations - overrides config in ACPI if present +# + +dnl DAI_CONFIG(type, dai_index, link_id, name, ssp_config/dmic_config) + +DAI_CONFIG(DMIC, 0, 6, NoCodec-6, + dnl DMIC_CONFIG(driver_version, clk_min, clk_mac, duty_min, duty_max, + dnl sample_rate, + dnl fifo word length, type, dai_index, pdm controller config) + DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, + dnl DMIC_WORD_LENGTH(frame_format) + DMIC_WORD_LENGTH(s32le), DMIC, 0, + dnl PDM_CONFIG(type, dai_index, num pdm active, pdm tuples list) + dnl STEREO_PDM0 is a pre-defined pdm config for stereo capture + PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) + From 092db5e22521393c5f9b371984ea5e5cbe63710d Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 23 Oct 2018 13:43:55 +0300 Subject: [PATCH 284/324] Test: Audio: Fix paths in SRC host version testbench The directories were restructured lately and this patch fixes the changed paths issue. Signed-off-by: Seppo Ingalsuo --- test/audio/src_run.sh | 4 ++-- test/audio/src_test.m | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/audio/src_run.sh b/test/audio/src_run.sh index 670dc4415dd2..41fb8c98fd86 100755 --- a/test/audio/src_run.sh +++ b/test/audio/src_run.sh @@ -10,7 +10,7 @@ FN_IN=$5 FN_OUT=$6 # The HOST_ROOT path need to be retrived from SOFT .configure command -HOST_ROOT=../../host-root +HOST_ROOT=../../../host-root HOST_EXE=$HOST_ROOT/bin/testbench HOST_LIB=$HOST_ROOT/lib @@ -18,7 +18,7 @@ HOST_LIB=$HOST_ROOT/lib INFMT=s${BITS_IN}le OUTFMT=s${BITS_IN}le MCLK=24576k -TPLG=../topology/test/test-playback-ssp2-mclk-0-I2S-${COMP}-${INFMT}-${OUTFMT}-48k-${MCLK}-nocodec.tplg +TPLG=../../topology/test/test-playback-ssp2-mclk-0-I2S-${COMP}-${INFMT}-${OUTFMT}-48k-${MCLK}-nocodec.tplg # If binary test vectors if [ ${FN_IN: -4} == ".raw" ]; then diff --git a/test/audio/src_test.m b/test/audio/src_test.m index bad220604003..7e503a557d06 100644 --- a/test/audio/src_test.m +++ b/test/audio/src_test.m @@ -46,7 +46,7 @@ addpath('std_utils'); addpath('test_utils'); -addpath('../tune/src'); +addpath('../../tune/src'); mkdir_check('plots'); mkdir_check('reports'); From 8d0f1783a6195d85640a085811df88b3d75d9bd7 Mon Sep 17 00:00:00 2001 From: Pierre-Louis Bossart Date: Tue, 23 Oct 2018 12:28:47 -0500 Subject: [PATCH 285/324] topology: renumber SSP tokens - ABI CHANGE Initial _ACTIVE fields are replaced by a single clock control This change can lead to regressions, it needs to be aligned with the same change at the kernel level. Signed-off-by: Pierre-Louis Bossart --- topology/sof/tokens.m4 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/topology/sof/tokens.m4 b/topology/sof/tokens.m4 index 3810e3f354a5..91298b89fff2 100644 --- a/topology/sof/tokens.m4 +++ b/topology/sof/tokens.m4 @@ -52,11 +52,12 @@ SectionVendorTokens."sof_comp_tokens" { } SectionVendorTokens."sof_ssp_tokens" { - SOF_TKN_INTEL_SSP_MCLK_KEEP_ACTIVE "500" - SOF_TKN_INTEL_SSP_BCLK_KEEP_ACTIVE "501" - SOF_TKN_INTEL_SSP_FS_KEEP_ACTIVE "502" - SOF_TKN_INTEL_SSP_MCLK_ID "503" - SOF_TKN_INTEL_SSP_SAMPLE_BITS "504" + SOF_TKN_INTEL_SSP_CLKS_CONTROL "500" + SOF_TKN_INTEL_SSP_MCLK_ID "501" + SOF_TKN_INTEL_SSP_SAMPLE_BITS "502" + SOF_TKN_INTEL_SSP_FRAME_PULSE_WIDTH "503" + SOF_TKN_INTEL_SSP_QUIRKS "504" + SOF_TKN_INTEL_SSP_TDM_PADDING_PER_SLOT "505" } SectionVendorTokens."sof_dmic_tokens" { From b8dfacba88aa811dba6f87bb33af32147375dae6 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Thu, 25 Oct 2018 12:59:51 +0200 Subject: [PATCH 286/324] logger: refinement handling invalid trace address In case of getting invalid trace address file descriptor now moves forward only one dword, not whole struct dma_log as it was earlier. Signed-off-by: Bartosz Kokoszko --- rmbox/logger_convert.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index e54f3d535644..f2adab91226c 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -282,10 +282,17 @@ static int logger_read(struct convert_config *config, return -ferror(config->in_fd); } - /* checking log address */ + /* checking if received trace address is located in + * entry section in elf file. + */ if ((dma_log.address < snd->base_address) || - dma_log.address > snd->base_address + snd->data_length) + dma_log.address > snd->base_address + snd->data_length) { + /* in case the address is not correct input fd should be + * move forward by one DWORD, not entire struct dma_log + */ + fseek(config->in_fd, -(sizeof(dma_log) - sizeof(uint32_t)), SEEK_CUR); continue; + } /* fetching entry from elf dump */ ret = fetch_entry(config, snd->base_address, snd->data_offset, From fa0735572b72d1bb6659667a862fcdbe6942fea9 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 19 Oct 2018 19:27:34 +0300 Subject: [PATCH 287/324] EQ Tool: Add calibration data import This patch adds capability to apply for capture microphone calibration data (ASCII text lines with Hz, dB values). The calibration data file name needs to be edited into configuration file mls_rec_config.txt. Such calibration data is provided by several inexpensive USB measurement microphones manufacturers. Signed-off-by: Seppo Ingalsuo --- tune/eq/mls_freq_resp.m | 118 +++++++++++++++++++++++++++++++++++-- tune/eq/mls_rec_config.txt | 21 +++++-- 2 files changed, 128 insertions(+), 11 deletions(-) diff --git a/tune/eq/mls_freq_resp.m b/tune/eq/mls_freq_resp.m index cee76c6500b2..b4ad8e211586 100644 --- a/tune/eq/mls_freq_resp.m +++ b/tune/eq/mls_freq_resp.m @@ -169,6 +169,8 @@ [f, m_db, b] = mls_calc_resp(csvfn, mlsfn, measfn, t_tot, np, f_lo, f_hi); +[f, m_db] = apply_mic_calibration(f, m_db, rec_cfg); + figure idx = find(f>1e3, 1, 'first') - 1; m_db_align = m_db - m_db(idx); @@ -273,12 +275,89 @@ function remote_capture(fn, cfg, t) rec.nch, fmt, fs); fprintf('\nThe setttings for remote capture are\n'); - fprintf('Use ssh : %d\n', rec.ssh); - fprintf('User : %s\n', rec.user); - fprintf('Directory : %s\n', rec.dir); - fprintf('Device : %s\n', rec.dev); - fprintf('format : %s\n', rec.fmt); - fprintf('Channels : %d\n', rec.nch); + fprintf('Use ssh : %d\n', rec.ssh); + fprintf('User : %s\n', rec.user); + fprintf('Directory : %s\n', rec.dir); + fprintf('Device : %s\n', rec.dev); + fprintf('format : %s\n', rec.fmt); + fprintf('Channels : %d\n', rec.nch); + fprintf('Calibration Data : %s\n', rec.cal); + + if length(rec.cal) > 0 + if exist(rec.cal, 'file') + [rec.cf, rec.cm, rec.sens, rec.cs] = get_calibration(rec.cal); + else + error('The calibration file does not exist'); + end + else + rec.cf = []; + rec.cm = []; + rec.sens = []; + rec.cs = ''; + end +end + +% The syntax of ASCII text calibration data is such that first line is +% text string sometimes within "" or text line about Sensitivity. Such +% lines are read and stored to description text. The sensitivty is extracted +% and printed if success but currently it is not utilized by the code. +% +% The next lines are for +% measurement data for microphone. If there are more than two numbers +% per line the other than two first columns are ignored. This code +% applies inverse of calibration data for measured response calibration. + +function [f, m, sens, desc] = get_calibration(fn) + fh = fopen(fn, 'r'); + if fh < 0 + error('Cannot open calibration data file'); + end + n = 1; + f = []; + m = []; + sens =[]; + desc = ''; + str = fgets(fh); + idx = findstr(str, '"'); + while length(idx) > 0 + line = str(idx(1)+1:idx(2)-1); + desc = sprintf('%s%s ', desc, line); + str = fgets(fh); + idx = findstr(str, '"'); + end + if length(strfind(str, 'Sens')) + desc = str; + str = fgets(fh); + end + while str ~= -1 + d=sscanf(str,'%f'); + f(n) = d(1); + m(n) = d(2); + n = n + 1; + str = fgets(fh); + end + + % Strip possible linefeed from description end + if double(desc(end)) == 10 + desc = desc(1:end-1); + end + fprintf('Calibration Info : %s\n', desc); + i1 = strfind(desc, 'Sens Factor ='); + i2 = strfind(desc, 'dB'); + if length(i1) == 1 && length(i2) == 1 + sens = sscanf(desc(i1+13:i2-1), '%f'); + fprintf('Calibration Sens : %6.2f dB\n', sens); + end + + fprintf('Calibration range: %.2f .. %.2f Hz\n', min(f), max(f)); + fprintf('Calibration range: %.2f .. %.2f dB\n', min(m), max(m)); + + figure; + semilogx(f, m); + grid on; + title(desc); + xlabel('Frequency (Hz)'); + ylabel('Magnitude (dB)'); end function [x, seed] = mlsp12(seed, n) @@ -304,3 +383,30 @@ function remote_capture(fn, cfg, t) end end end + +%% Calibration apply function +% Resample microphone calibration data into used grid and +% then subtract calibration response from measured +% response. + +function [cal_f, cal_m_db] = apply_mic_calibration(f, m_db, rec) + + if length(rec.cm) > 0 + if ~isvector(rec.cm) + error('Calibration can be for one channel only'); + end + mic_m_db = interp1(rec.cf, rec.cm, f, 'linear'); + nans = isnan(mic_m_db); + idx = find(nans == 0); + cal_f = f(idx); + cal_db = mic_m_db(idx); + s = size(m_db); + for i = 1:s(2) + cal_m_db(:,i) = m_db(idx,i) - cal_db(:); + end + else + cal_m_db = m_db; + cal_f = f; + end + +end diff --git a/tune/eq/mls_rec_config.txt b/tune/eq/mls_rec_config.txt index 70afd2664f57..95c77ab6061c 100644 --- a/tune/eq/mls_rec_config.txt +++ b/tune/eq/mls_rec_config.txt @@ -1,5 +1,16 @@ -rec.ssh = 0; % Set to 1 for remote capture -rec.user = ''; % Set to user@domain for ssh -rec.dir = '/tmp'; % Directory for temporary files -rec.dev = 'hw:0,0'; % Audio capture device -rec.nch = 2; % Number audio capture channels to use +%% Recording device configuration + +rec.ssh = 0; % Set to 1 for remote capture +rec.user = ''; % Set to user@domain for ssh +rec.dir = '/tmp'; % Directory for temporary files +rec.dev = 'hw:0,0'; % Audio capture device +rec.nch = 2; % Number audio capture channels to use + +% Use '' if calibration is not needed. Otherwise set to +% e.g. '1234567.txt'. Such calibration data format is supported for +% some reasonably priced measurement microphones. The ASCII text +% calibration data file is the measured frequency response of the used +% microphone. Lines in the beginning those start with character " are +% treated as comment. The successive lines should be +% number pairs. Their unit must be Hz and dB. +rec.cal = ''; From 22fba69dfbde47bad02a7d7b352dc305cea0c26d Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 31 Oct 2018 22:31:08 -0700 Subject: [PATCH 288/324] topology: glk: fix channel count for dmic stereo recording Fix the channel count to 2 for stereo dmic recording. Signed-off-by: Ranjani Sridharan --- topology/sof-glk-da7219.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof-glk-da7219.m4 b/topology/sof-glk-da7219.m4 index 85f4a7e3c764..2132c130e683 100644 --- a/topology/sof-glk-da7219.m4 +++ b/topology/sof-glk-da7219.m4 @@ -52,7 +52,7 @@ PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, # Schedule 48 frames per 1000us deadline on core 0 with priority 0 #PIPELINE_PCM_ADD(sof/pipe-volume-capture.m4, PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, - 4, 99, 4, s32le, + 4, 99, 2, s32le, 48, 1000, 0, 0) # Low Latency playback pipeline 5 on PCM 5 using max 2 channels of s32le. From a73c4f63ca41dcc77f90d435d9da4f5dfe1e6ecf Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Wed, 24 Oct 2018 15:17:33 +0200 Subject: [PATCH 289/324] logger: add firmware verification capability I've added two logger flags for firmware version verification: -e - enables checking fw version with default file -v ver_file - enables checking fw version with ver_file file Signed-off-by: Bartosz Kokoszko --- README | 14 + rmbox/convert.h | 3 + rmbox/logger_convert.c | 42 +- rmbox/rmbox.c | 36 +- rmbox/sof/uapi/ipc.h | 1020 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 1102 insertions(+), 13 deletions(-) create mode 100644 rmbox/sof/uapi/ipc.h diff --git a/README b/README index f647ac637e6c..07e9777d67a8 100644 --- a/README +++ b/README @@ -65,11 +65,25 @@ Usage sof-logger -p Get traces from stdin, instead of the default "/sys/kernel/debug/sof/etrace" -c Set timestamp clock in MHz +-e Enable checking firmware version with default verification file + "/sys/kernel/debug/sof/fw_version" +-v ver_file Enable checking firmware version with ver_file file, + instead of default: "/sys/kernel/debug/sof/fw_version" -s Take a snapshot of state Examples: +- Get traces from "/sys/kernel/debug/sof/etrace" file, verifies fw_version with + "/sys/kernel/debug/sof/fw_version" and prints logs to stdout + + $ sof-logger -l ldc_file -e + +- Get traces from "/sys/kernel/debug/sof/etrace" file, verifies fw_version with + ver_file file and prints logs to stdout + + $ sof-logger -l ldc_file -v ver_file + - Get traces from "/sys/kernel/debug/sof/etrace" file and prints logs to stdout $ sof-logger -l ldc_file diff --git a/rmbox/convert.h b/rmbox/convert.h index 085ea5f4868f..2e0e391f610b 100644 --- a/rmbox/convert.h +++ b/rmbox/convert.h @@ -36,6 +36,9 @@ struct convert_config { const char *ldc_file; FILE* ldc_fd; int input_std; + int version_fw; + char *version_file; + FILE *version_fd; #endif }; diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index f2adab91226c..e2009537bacf 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -19,7 +19,7 @@ #include #include #include - +#include #include "convert.h" #define CEIL(a, b) ((a+b-1)/b) @@ -32,15 +32,15 @@ #define SND_SOF_LOGS_SIG_SIZE 4 #define SND_SOF_LOGS_SIG "Logs" +/* +* Logs dictionary file header. +*/ struct snd_sof_logs_header { - /* "Logs" */ - unsigned char sig[SND_SOF_LOGS_SIG_SIZE]; - /* address of log entries section */ - uint32_t base_address; - /* amount of bytes following this header */ - uint32_t data_length; - /* offset to first entry in this file */ - uint32_t data_offset; + unsigned char sig[SND_SOF_LOGS_SIG_SIZE]; /* "Logs" */ + uint32_t base_address; /* address of log entries section */ + uint32_t data_length; /* amount of bytes following this header */ + uint32_t data_offset; /* offset to first entry in this file */ + struct sof_ipc_fw_version version; }; struct ldc_entry_header { @@ -145,7 +145,7 @@ static void print_entry_params(FILE *out_fd, struct dma_log dma_log, entry.params[2], entry.params[3]); break; } - fprintf(out_fd, "\n"); + fprintf(out_fd, "%s\n", KNRM); fflush(out_fd); } @@ -319,5 +319,25 @@ int convert(struct convert_config *config) { return -EINVAL; } + /* fw verification */ + if (config->version_fd) { + struct sof_ipc_fw_version ver; + int i; + /* here fw verification should be exploited */ + count = fread(&ver, sizeof(ver), 1, config->version_fd); + if (!count) { + fprintf(stderr, "Error while reading %s. \n", config->version_file); + return -ferror(config->version_fd); + } + + ret = memcmp(&ver, &snd.version, sizeof(struct sof_ipc_fw_version)); + if (ret) { + fprintf(stderr, "Error: fw version in %s file " + "does not coincide with fw version in " + "%s file. \n", config->ldc_file, config->version_file); + return -EINVAL; + } + } + return logger_read(config, &snd); -} \ No newline at end of file +} diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index e5e965be4acd..2528c7518d26 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -43,6 +43,8 @@ static void usage(void) #ifdef LOGGER_FORMAT fprintf(stdout, "%s:\t -l *.ldc_file\t\t*.ldc files generated by rimage\n", APP_NAME); fprintf(stdout, "%s:\t -p \t\t\tInput from stdin\n", APP_NAME); + fprintf(stdout, "%s:\t -e \t\t\tEnable checking firmware version with default verification file\n", APP_NAME); + fprintf(stdout, "%s:\t -v ver_file\t\tEnable checking firmware version with ver_file file\n", APP_NAME); #endif fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", APP_NAME); fprintf(stdout, "%s:\t -s\t\t\tTake a snapshot of state\n", APP_NAME); @@ -123,11 +125,16 @@ int main(int argc, char *argv[]) config.in_fd = NULL; #ifdef LOGGER_FORMAT config.ldc_file = NULL; + config.ldc_fd = NULL; config.input_std = 0; + /* checking fw version is disabled by default */ + config.version_file = NULL; + config.version_fd = NULL; + config.version_fw = 0; #endif #ifdef LOGGER_FORMAT - while ((opt = getopt(argc, argv, "ho:i:l:ps:m:c:t")) != -1) { + while ((opt = getopt(argc, argv, "ho:i:l:ps:m:c:tev:")) != -1) { #else while ((opt = getopt(argc, argv, "ho:i:s:m:c:t")) != -1) { #endif @@ -153,6 +160,18 @@ int main(int argc, char *argv[]) case 'p': config.input_std = 1; break; + case 'e': + /* enabling checking fw version with default verification + * file + */ + config.version_fw = 1; + config.version_file = "/sys/kernel/debug/sof/fw_version"; + break; + case 'v': + /* enabling checking fw version with ver_file file */ + config.version_fw = 1; + config.version_file = optarg; + break; #endif case 'h': default: /* '?' */ @@ -161,8 +180,9 @@ int main(int argc, char *argv[]) } #ifdef LOGGER_FORMAT + if (!config.ldc_file) { - fprintf(stderr, "error: Missing ldc file"); + fprintf(stderr, "error: Missing ldc file\n"); usage(); } @@ -173,6 +193,16 @@ int main(int argc, char *argv[]) ret = -errno; goto out; } + + if (config.version_fw) { + config.version_fd = fopen(config.version_file, "r"); + if (!config.version_fd) { + fprintf(stderr, "error: Unable to open ver file %s\n", + config.version_file); + ret = -errno; + goto out; + } + } #endif if (config.out_file) { @@ -223,6 +253,8 @@ int main(int argc, char *argv[]) #ifdef LOGGER_FORMAT if (config.ldc_fd) fclose(config.ldc_fd); + if (config.version_fd) + fclose(config.version_fd); #endif return ret; diff --git a/rmbox/sof/uapi/ipc.h b/rmbox/sof/uapi/ipc.h new file mode 100644 index 000000000000..e9883acb0cd7 --- /dev/null +++ b/rmbox/sof/uapi/ipc.h @@ -0,0 +1,1020 @@ +/* + * Copyright (c) 2016, Intel Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the Intel Corporation nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * Author: Liam Girdwood + * Keyon Jie + */ + +/** + * \file include/uapi/ipc.h + * \brief IPC definitions + * \author Liam Girdwood + * \author Keyon Jie + */ + +#ifndef __INCLUDE_UAPI_IPC_H__ +#define __INCLUDE_UAPI_IPC_H__ + +#include + +/** \addtogroup sof_uapi uAPI + * SOF uAPI specification. + * @{ + */ + +/* + * IPC messages have a prefixed 32 bit identifier made up as follows :- + * + * 0xGCCCNNNN where + * G is global cmd type (4 bits) + * C is command type (12 bits) + * I is the ID number (16 bits) - monotonic and overflows + * + * This is sent at the start of the IPM message in the mailbox. Messages should + * not be sent in the doorbell (special exceptions for firmware . + */ + +/* Global Message - Generic */ +#define SOF_GLB_TYPE_SHIFT 28 +#define SOF_GLB_TYPE_MASK (0xf << SOF_GLB_TYPE_SHIFT) +#define SOF_GLB_TYPE(x) ((x) << SOF_GLB_TYPE_SHIFT) + +/* Command Message - Generic */ +#define SOF_CMD_TYPE_SHIFT 16 +#define SOF_CMD_TYPE_MASK (0xfff << SOF_CMD_TYPE_SHIFT) +#define SOF_CMD_TYPE(x) ((x) << SOF_CMD_TYPE_SHIFT) + +/* Global Message Types */ +#define SOF_IPC_GLB_REPLY SOF_GLB_TYPE(0x1U) +#define SOF_IPC_GLB_COMPOUND SOF_GLB_TYPE(0x2U) +#define SOF_IPC_GLB_TPLG_MSG SOF_GLB_TYPE(0x3U) +#define SOF_IPC_GLB_PM_MSG SOF_GLB_TYPE(0x4U) +#define SOF_IPC_GLB_COMP_MSG SOF_GLB_TYPE(0x5U) +#define SOF_IPC_GLB_STREAM_MSG SOF_GLB_TYPE(0x6U) +#define SOF_IPC_FW_READY SOF_GLB_TYPE(0x7U) +#define SOF_IPC_GLB_DAI_MSG SOF_GLB_TYPE(0x8U) +#define SOF_IPC_GLB_TRACE_MSG SOF_GLB_TYPE(0x9U) + +/* + * DSP Command Message Types + */ + +/* topology */ +#define SOF_IPC_TPLG_COMP_NEW SOF_CMD_TYPE(0x001) +#define SOF_IPC_TPLG_COMP_FREE SOF_CMD_TYPE(0x002) +#define SOF_IPC_TPLG_COMP_CONNECT SOF_CMD_TYPE(0x003) +#define SOF_IPC_TPLG_PIPE_NEW SOF_CMD_TYPE(0x010) +#define SOF_IPC_TPLG_PIPE_FREE SOF_CMD_TYPE(0x011) +#define SOF_IPC_TPLG_PIPE_CONNECT SOF_CMD_TYPE(0x012) +#define SOF_IPC_TPLG_PIPE_COMPLETE SOF_CMD_TYPE(0x013) +#define SOF_IPC_TPLG_BUFFER_NEW SOF_CMD_TYPE(0x020) +#define SOF_IPC_TPLG_BUFFER_FREE SOF_CMD_TYPE(0x021) + +/* PM */ +#define SOF_IPC_PM_CTX_SAVE SOF_CMD_TYPE(0x001) +#define SOF_IPC_PM_CTX_RESTORE SOF_CMD_TYPE(0x002) +#define SOF_IPC_PM_CTX_SIZE SOF_CMD_TYPE(0x003) +#define SOF_IPC_PM_CLK_SET SOF_CMD_TYPE(0x004) +#define SOF_IPC_PM_CLK_GET SOF_CMD_TYPE(0x005) +#define SOF_IPC_PM_CLK_REQ SOF_CMD_TYPE(0x006) +#define SOF_IPC_PM_CORE_ENABLE SOF_CMD_TYPE(0x007) + +/* component runtime config - multiple different types */ +#define SOF_IPC_COMP_SET_VALUE SOF_CMD_TYPE(0x001) +#define SOF_IPC_COMP_GET_VALUE SOF_CMD_TYPE(0x002) +#define SOF_IPC_COMP_SET_DATA SOF_CMD_TYPE(0x003) +#define SOF_IPC_COMP_GET_DATA SOF_CMD_TYPE(0x004) + +/* DAI messages */ +#define SOF_IPC_DAI_CONFIG SOF_CMD_TYPE(0x001) +#define SOF_IPC_DAI_LOOPBACK SOF_CMD_TYPE(0x002) + +/* stream */ +#define SOF_IPC_STREAM_PCM_PARAMS SOF_CMD_TYPE(0x001) +#define SOF_IPC_STREAM_PCM_PARAMS_REPLY SOF_CMD_TYPE(0x002) +#define SOF_IPC_STREAM_PCM_FREE SOF_CMD_TYPE(0x003) +#define SOF_IPC_STREAM_TRIG_START SOF_CMD_TYPE(0x004) +#define SOF_IPC_STREAM_TRIG_STOP SOF_CMD_TYPE(0x005) +#define SOF_IPC_STREAM_TRIG_PAUSE SOF_CMD_TYPE(0x006) +#define SOF_IPC_STREAM_TRIG_RELEASE SOF_CMD_TYPE(0x007) +#define SOF_IPC_STREAM_TRIG_DRAIN SOF_CMD_TYPE(0x008) +#define SOF_IPC_STREAM_TRIG_XRUN SOF_CMD_TYPE(0x009) +#define SOF_IPC_STREAM_POSITION SOF_CMD_TYPE(0x00a) +#define SOF_IPC_STREAM_VORBIS_PARAMS SOF_CMD_TYPE(0x010) +#define SOF_IPC_STREAM_VORBIS_FREE SOF_CMD_TYPE(0x011) + +/* trace and debug */ +#define SOF_IPC_TRACE_DMA_PARAMS SOF_CMD_TYPE(0x001) +#define SOF_IPC_TRACE_DMA_POSITION SOF_CMD_TYPE(0x002) + +/* Get message component id */ +#define SOF_IPC_MESSAGE_ID(x) ((x) & 0xffff) + +/* maximum message size for mailbox Tx/Rx */ +#define SOF_IPC_MSG_MAX_SIZE 384 + +/* + * SOF panic codes + */ +#define SOF_IPC_PANIC_MAGIC 0x0dead000 +#define SOF_IPC_PANIC_MAGIC_MASK 0x0ffff000 +#define SOF_IPC_PANIC_CODE_MASK 0x00000fff +#define SOF_IPC_PANIC_MEM (SOF_IPC_PANIC_MAGIC | 0x0) +#define SOF_IPC_PANIC_WORK (SOF_IPC_PANIC_MAGIC | 0x1) +#define SOF_IPC_PANIC_IPC (SOF_IPC_PANIC_MAGIC | 0x2) +#define SOF_IPC_PANIC_ARCH (SOF_IPC_PANIC_MAGIC | 0x3) +#define SOF_IPC_PANIC_PLATFORM (SOF_IPC_PANIC_MAGIC | 0x4) +#define SOF_IPC_PANIC_TASK (SOF_IPC_PANIC_MAGIC | 0x5) +#define SOF_IPC_PANIC_EXCEPTION (SOF_IPC_PANIC_MAGIC | 0x6) +#define SOF_IPC_PANIC_DEADLOCK (SOF_IPC_PANIC_MAGIC | 0x7) +#define SOF_IPC_PANIC_STACK (SOF_IPC_PANIC_MAGIC | 0x8) +#define SOF_IPC_PANIC_IDLE (SOF_IPC_PANIC_MAGIC | 0x9) +#define SOF_IPC_PANIC_WFI (SOF_IPC_PANIC_MAGIC | 0xa) + +/* + * SOF memory capabilities, add new ones at the end + */ +#define SOF_MEM_CAPS_RAM (1 << 0) +#define SOF_MEM_CAPS_ROM (1 << 1) +#define SOF_MEM_CAPS_EXT (1 << 2) /* external */ +#define SOF_MEM_CAPS_LP (1 << 3) /* low power */ +#define SOF_MEM_CAPS_HP (1 << 4) /* high performance */ +#define SOF_MEM_CAPS_DMA (1 << 5) /* DMA'able */ +#define SOF_MEM_CAPS_CACHE (1 << 6) /* cacheable */ +#define SOF_MEM_CAPS_EXEC (1 << 7) /* executable */ + +/* + * Command Header - Header for all IPC. Identifies IPC message. + * The size can be greater than the structure size and that means there is + * extended bespoke data beyond the end of the structure including variable + * arrays. + */ + +struct sof_ipc_hdr { + uint32_t cmd; /* SOF_IPC_GLB_ + cmd */ + uint32_t size; /* size of structure */ +} __attribute__((packed)); + +/* + * Generic reply message. Some commands override this with their own reply + * types that must include this at start. + */ +struct sof_ipc_reply { + struct sof_ipc_hdr hdr; + int32_t error; /* negative error numbers */ +} __attribute__((packed)); + +/* + * Compound commands - SOF_IPC_GLB_COMPOUND. + * + * Compound commands are sent to the DSP as a single IPC operation. The + * commands are split into blocks and each block has a header. This header + * identifies the command type and the number of commands before the next + * header. + */ + +struct sof_ipc_compound_hdr { + struct sof_ipc_hdr hdr; + uint32_t count; /* count of 0 means end of compound sequence */ +} __attribute__((packed)); + +/* + * DAI Configuration. + * + * Each different DAI type will have it's own structure and IPC cmd. + */ + +#define SOF_DAI_FMT_I2S 1 /* I2S mode */ +#define SOF_DAI_FMT_RIGHT_J 2 /* Right Justified mode */ +#define SOF_DAI_FMT_LEFT_J 3 /* Left Justified mode */ +#define SOF_DAI_FMT_DSP_A 4 /* L data MSB after FRM LRC */ +#define SOF_DAI_FMT_DSP_B 5 /* L data MSB during FRM LRC */ +#define SOF_DAI_FMT_PDM 6 /* Pulse density modulation */ + +#define SOF_DAI_FMT_CONT (1 << 4) /* continuous clock */ +#define SOF_DAI_FMT_GATED (0 << 4) /* clock is gated */ + +#define SOF_DAI_FMT_NB_NF (0 << 8) /* normal bit clock + frame */ +#define SOF_DAI_FMT_NB_IF (2 << 8) /* normal BCLK + inv FRM */ +#define SOF_DAI_FMT_IB_NF (3 << 8) /* invert BCLK + nor FRM */ +#define SOF_DAI_FMT_IB_IF (4 << 8) /* invert BCLK + FRM */ + +#define SOF_DAI_FMT_CBM_CFM (0 << 12) /* codec clk & FRM master */ +#define SOF_DAI_FMT_CBS_CFM (2 << 12) /* codec clk slave & FRM master */ +#define SOF_DAI_FMT_CBM_CFS (3 << 12) /* codec clk master & frame slave */ +#define SOF_DAI_FMT_CBS_CFS (4 << 12) /* codec clk & FRM slave */ + +#define SOF_DAI_FMT_FORMAT_MASK 0x000f +#define SOF_DAI_FMT_CLOCK_MASK 0x00f0 +#define SOF_DAI_FMT_INV_MASK 0x0f00 +#define SOF_DAI_FMT_MASTER_MASK 0xf000 + + /* ssc1: TINTE */ +#define SOF_DAI_INTEL_SSP_QUIRK_TINTE (1 << 0) + /* ssc1: PINTE */ +#define SOF_DAI_INTEL_SSP_QUIRK_PINTE (1 << 1) + /* ssc2: SMTATF */ +#define SOF_DAI_INTEL_SSP_QUIRK_SMTATF (1 << 2) + /* ssc2: MMRATF */ +#define SOF_DAI_INTEL_SSP_QUIRK_MMRATF (1 << 3) + /* ssc2: PSPSTWFDFD */ +#define SOF_DAI_INTEL_SSP_QUIRK_PSPSTWFDFD (1 << 4) + /* ssc2: PSPSRWFDFD */ +#define SOF_DAI_INTEL_SSP_QUIRK_PSPSRWFDFD (1 << 5) + /* here is the possibility to define others aux macros */ + +#define SOF_DAI_INTEL_SSP_FRAME_PULSE_WIDTH_MAX 38 +#define SOF_DAI_INTEL_SSP_SLOT_PADDING_MAX 31 + +/* SSP clocks control settings + * + * Macros for clks_control field in sof_ipc_dai_ssp_params struct. + */ + +/* mclk 0 disable */ +#define SOF_DAI_INTEL_SSP_MCLK_0_DISABLE BIT(0) +/* mclk 1 disable */ +#define SOF_DAI_INTEL_SSP_MCLK_1_DISABLE BIT(1) +/* mclk keep active */ +#define SOF_DAI_INTEL_SSP_CLKCTRL_MCLK_KA BIT(2) +/* bclk keep active */ +#define SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_KA BIT(3) +/* fs keep active */ +#define SOF_DAI_INTEL_SSP_CLKCTRL_FS_KA BIT(4) +/* bclk idle */ +#define SOF_DAI_INTEL_SSP_CLKCTRL_BCLK_IDLE_HIGH BIT(5) + +/** \brief Types of DAI */ +enum sof_ipc_dai_type { + SOF_DAI_INTEL_NONE = 0, /**< None */ + SOF_DAI_INTEL_SSP, /**< Intel SSP */ + SOF_DAI_INTEL_DMIC, /**< Intel DMIC */ + SOF_DAI_INTEL_HDA, /**< Intel HD/A */ +}; + +/* SSP Configuration Request - SOF_IPC_DAI_SSP_CONFIG */ +struct sof_ipc_dai_ssp_params { + uint16_t mode; // FIXME: do we need this? + uint16_t mclk_id; + + uint32_t mclk_rate; /* mclk frequency in Hz */ + uint32_t fsync_rate; /* fsync frequency in Hz */ + uint32_t bclk_rate; /* bclk frequency in Hz */ + + /* TDM */ + uint32_t tdm_slots; + uint32_t rx_slots; + uint32_t tx_slots; + + /* data */ + uint32_t sample_valid_bits; + uint16_t tdm_slot_width; + uint16_t reserved2; /* alignment */ + + /* MCLK */ + uint32_t mclk_direction; + + uint16_t frame_pulse_width; + uint16_t tdm_per_slot_padding_flag; + uint32_t clks_control; + uint32_t quirks; // FIXME: is 32 bits enough ? + /* private data, e.g. for quirks */ + //uint32_t pdata[10]; // FIXME: would really need ~16 u32 +} __attribute__((packed)); + +/* HDA Configuration Request - SOF_IPC_DAI_HDA_CONFIG */ +struct sof_ipc_dai_hda_params { + struct sof_ipc_hdr hdr; + /* TODO */ +} __attribute__((packed)); + +/* DMIC Configuration Request - SOF_IPC_DAI_DMIC_CONFIG */ + +/* This struct is defined per 2ch PDM controller available in the platform. + * Normally it is sufficient to set the used microphone specific enables to 1 + * and keep other parameters as zero. The customizations are: + * + * 1. If a device mixes different microphones types with different polarity + * and/or the absolute polarity matters the PCM signal from a microphone + * can be inverted with the controls. + * + * 2. If the microphones in a stereo pair do not appear in captured stream + * in desired order due to board schematics choises they can be swapped with + * the clk_edge parameter. + * + * 3. If PDM bit errors are seen in capture (poor quality) the skew parameter + * that delays the sampling time of data by half cycles of DMIC source clock + * can be tried for improvement. However there is no guarantee for this to fix + * data integrity problems. + */ +struct sof_ipc_dai_dmic_pdm_ctrl { + uint16_t id; /* PDM controller ID */ + uint16_t enable_mic_a; /* Use A (left) channel mic (0 or 1)*/ + uint16_t enable_mic_b; /* Use B (right) channel mic (0 or 1)*/ + uint16_t polarity_mic_a; /* Optionally invert mic A signal (0 or 1) */ + uint16_t polarity_mic_b; /* Optionally invert mic B signal (0 or 1) */ + uint16_t clk_edge; /* Optionally swap data clock edge (0 or 1) */ + uint16_t skew; /* Adjust PDM data sampling vs. clock (0..15) */ + uint16_t pad; /* Make sure the total size is 4 bytes aligned */ +} __attribute__((packed)); + +/* This struct contains the global settings for all 2ch PDM controllers. The + * version number used in configuration data is checked vs. version used by + * device driver src/drivers/dmic.c need to match. It is incremented from + * initial value 1 if updates done for the to driver would alter the operation + * of the microhone. + * + * Note: The microphone clock (pdmclk_min, pdmclk_max, duty_min, duty_max) + * parameters need to be set as defined in microphone data sheet. E.g. clock + * range 1.0 - 3.2 MHz is usually supported microphones. Some microphones are + * multi-mode capable and there may be denied mic clock frequencies between + * the modes. In such case set the clock range limits of the desired mode to + * avoid the driver to set clock to an illegal rate. + * + * The duty cycle could be set to 48-52% if not known. Generally these + * parameters can be altered within data sheet specified limits to match + * required audio application performance power. + * + * The microphone clock needs to be usually about 50-80 times the used audio + * sample rate. With highest sample rates above 48 kHz this can relaxed + * somewhat. + */ +struct sof_ipc_dai_dmic_params { + uint32_t driver_ipc_version; /* Version (1..N) */ + uint32_t pdmclk_min; /* Minimum microphone clock in Hz (100000..N) */ + uint32_t pdmclk_max; /* Maximum microphone clock in Hz (min...N) */ + uint32_t fifo_fs_a; /* FIFO A sample rate in Hz (8000..96000) */ + uint32_t fifo_fs_b; /* FIFO B sample rate in Hz (8000..96000) */ + uint16_t fifo_bits_a; /* FIFO A word length (16 or 32) */ + uint16_t fifo_bits_b; /* FIFO B word length (16 or 32) */ + uint16_t duty_min; /* Min. mic clock duty cycle in % (20..80) */ + uint16_t duty_max; /* Max. mic clock duty cycle in % (min..80) */ + uint32_t num_pdm_active; /* Number of active pdm controllers */ + /* variable number of pdm controller config */ + struct sof_ipc_dai_dmic_pdm_ctrl pdm[0]; +} __attribute__((packed)); + +/* general purpose DAI configuration */ +struct sof_ipc_dai_config { + struct sof_ipc_hdr hdr; + enum sof_ipc_dai_type type; + uint32_t dai_index; /* index of this type dai */ + + /* physical protocol and clocking */ + uint16_t format; /* SOF_DAI_FMT_ */ + uint16_t reserved; /* alignment */ + + /* HW specific data */ + union { + struct sof_ipc_dai_ssp_params ssp; + struct sof_ipc_dai_hda_params hda; + struct sof_ipc_dai_dmic_params dmic; + }; +}; + +/* + * Stream configuration. + */ + +#define SOF_IPC_MAX_CHANNELS 8 + +/* channel positions - uses same values as ALSA */ +enum sof_ipc_chmap { + SOF_CHMAP_UNKNOWN = 0, + SOF_CHMAP_NA, /* N/A, silent */ + SOF_CHMAP_MONO, /* mono stream */ + SOF_CHMAP_FL, /* front left */ + SOF_CHMAP_FR, /* front right */ + SOF_CHMAP_RL, /* rear left */ + SOF_CHMAP_RR, /* rear right */ + SOF_CHMAP_FC, /* front centre */ + SOF_CHMAP_LFE, /* LFE */ + SOF_CHMAP_SL, /* side left */ + SOF_CHMAP_SR, /* side right */ + SOF_CHMAP_RC, /* rear centre */ + SOF_CHMAP_FLC, /* front left centre */ + SOF_CHMAP_FRC, /* front right centre */ + SOF_CHMAP_RLC, /* rear left centre */ + SOF_CHMAP_RRC, /* rear right centre */ + SOF_CHMAP_FLW, /* front left wide */ + SOF_CHMAP_FRW, /* front right wide */ + SOF_CHMAP_FLH, /* front left high */ + SOF_CHMAP_FCH, /* front centre high */ + SOF_CHMAP_FRH, /* front right high */ + SOF_CHMAP_TC, /* top centre */ + SOF_CHMAP_TFL, /* top front left */ + SOF_CHMAP_TFR, /* top front right */ + SOF_CHMAP_TFC, /* top front centre */ + SOF_CHMAP_TRL, /* top rear left */ + SOF_CHMAP_TRR, /* top rear right */ + SOF_CHMAP_TRC, /* top rear centre */ + SOF_CHMAP_TFLC, /* top front left centre */ + SOF_CHMAP_TFRC, /* top front right centre */ + SOF_CHMAP_TSL, /* top side left */ + SOF_CHMAP_TSR, /* top side right */ + SOF_CHMAP_LLFE, /* left LFE */ + SOF_CHMAP_RLFE, /* right LFE */ + SOF_CHMAP_BC, /* bottom centre */ + SOF_CHMAP_BLC, /* bottom left centre */ + SOF_CHMAP_BRC, /* bottom right centre */ + SOF_CHMAP_LAST = SOF_CHMAP_BRC, +}; + +/* common sample rates for use in masks */ +#define SOF_RATE_8000 (1 << 0) /* 8000Hz */ +#define SOF_RATE_11025 (1 << 1) /* 11025Hz */ +#define SOF_RATE_12000 (1 << 2) /* 12000Hz */ +#define SOF_RATE_16000 (1 << 3) /* 16000Hz */ +#define SOF_RATE_22050 (1 << 4) /* 22050Hz */ +#define SOF_RATE_24000 (1 << 5) /* 24000Hz */ +#define SOF_RATE_32000 (1 << 6) /* 32000Hz */ +#define SOF_RATE_44100 (1 << 7) /* 44100Hz */ +#define SOF_RATE_48000 (1 << 8) /* 48000Hz */ +#define SOF_RATE_64000 (1 << 9) /* 64000Hz */ +#define SOF_RATE_88200 (1 << 10) /* 88200Hz */ +#define SOF_RATE_96000 (1 << 11) /* 96000Hz */ +#define SOF_RATE_176400 (1 << 12) /* 176400Hz */ +#define SOF_RATE_192000 (1 << 13) /* 192000Hz */ + +/* continuous and non-standard rates for flexibility */ +#define SOF_RATE_CONTINUOUS (1 << 30) /* range */ +#define SOF_RATE_KNOT (1 << 31) /* non-continuous */ + +/* stream PCM frame format */ +enum sof_ipc_frame { + SOF_IPC_FRAME_S16_LE = 0, + SOF_IPC_FRAME_S24_4LE, + SOF_IPC_FRAME_S32_LE, + SOF_IPC_FRAME_FLOAT, + /* other formats here */ +}; + +/* stream buffer format */ +enum sof_ipc_buffer_format { + SOF_IPC_BUFFER_INTERLEAVED, + SOF_IPC_BUFFER_NONINTERLEAVED, + /* other formats here */ +}; + +/* stream direction */ +enum sof_ipc_stream_direction { + SOF_IPC_STREAM_PLAYBACK = 0, + SOF_IPC_STREAM_CAPTURE, +}; + +/* stream ring info */ +struct sof_ipc_host_buffer { + uint32_t phy_addr; + uint32_t pages; + uint32_t size; + uint32_t offset; +} __attribute__((packed)); + +struct sof_ipc_stream_params { + struct sof_ipc_host_buffer buffer; + enum sof_ipc_stream_direction direction; + enum sof_ipc_frame frame_fmt; + enum sof_ipc_buffer_format buffer_fmt; + uint32_t host_dma_ch; + uint32_t be_dma_ch; + uint32_t rate; + uint32_t channels; + uint32_t sample_valid_bytes; + uint32_t sample_container_bytes; + /* for notifying host period has completed - 0 means no period IRQ */ + uint32_t host_period_bytes; + enum sof_ipc_chmap chmap[SOF_IPC_MAX_CHANNELS]; /* channel map */ +} __attribute__((packed)); + +/* PCM params info - SOF_IPC_STREAM_PCM_PARAMS */ +struct sof_ipc_pcm_params { + struct sof_ipc_hdr hdr; + uint32_t comp_id; + struct sof_ipc_stream_params params; +} __attribute__((packed)); + +/* PCM params info reply - SOF_IPC_STREAM_PCM_PARAMS_REPLY */ +struct sof_ipc_pcm_params_reply { + struct sof_ipc_reply rhdr; + uint32_t comp_id; + uint32_t posn_offset; +} __attribute__((packed)); + +/* compressed vorbis params - SOF_IPC_STREAM_VORBIS_PARAMS */ +struct sof_ipc_vorbis_params { + struct sof_ipc_hdr hdr; + uint32_t comp_id; + struct sof_ipc_stream_params params; + /* TODO */ +} __attribute__((packed)); + +/* free stream - SOF_IPC_STREAM_PCM_PARAMS */ +struct sof_ipc_stream { + struct sof_ipc_hdr hdr; + uint32_t comp_id; +} __attribute__((packed)); + +/* flags indicating which time stamps are in sync with each other */ +#define SOF_TIME_HOST_SYNC (1 << 0) +#define SOF_TIME_DAI_SYNC (1 << 1) +#define SOF_TIME_WALL_SYNC (1 << 2) +#define SOF_TIME_STAMP_SYNC (1 << 3) + +/* flags indicating which time stamps are valid */ +#define SOF_TIME_HOST_VALID (1 << 8) +#define SOF_TIME_DAI_VALID (1 << 9) +#define SOF_TIME_WALL_VALID (1 << 10) +#define SOF_TIME_STAMP_VALID (1 << 11) + +/* flags indicating time stamps are 64bit else 3use low 32bit */ +#define SOF_TIME_HOST_64 (1 << 16) +#define SOF_TIME_DAI_64 (1 << 17) +#define SOF_TIME_WALL_64 (1 << 18) +#define SOF_TIME_STAMP_64 (1 << 19) + +struct sof_ipc_stream_posn { + struct sof_ipc_reply rhdr; + uint32_t comp_id; /* host component ID */ + uint32_t flags; /* SOF_TIME_ */ + uint32_t wallclock_hz; /* frequency of wallclock in Hz */ + uint32_t timestamp_ns; /* resolution of timestamp in ns */ + uint64_t host_posn; /* host DMA position in bytes */ + uint64_t dai_posn; /* DAI DMA position in bytes */ + uint64_t comp_posn; /* comp position in bytes */ + uint64_t wallclock; /* audio wall clock */ + uint64_t timestamp; /* system time stamp */ + uint32_t xrun_comp_id; /* comp ID of XRUN component */ + int32_t xrun_size; /* XRUN size in bytes */ +} __attribute__((packed)); + +/* + * Component Mixers and Controls + */ + +/* control data type and direction */ +enum sof_ipc_ctrl_type { + /* per channel data - uses struct sof_ipc_ctrl_value_chan */ + SOF_CTRL_TYPE_VALUE_CHAN_GET = 0, + SOF_CTRL_TYPE_VALUE_CHAN_SET, + /* component data - uses struct sof_ipc_ctrl_value_comp */ + SOF_CTRL_TYPE_VALUE_COMP_GET, + SOF_CTRL_TYPE_VALUE_COMP_SET, + /* bespoke data - struct struct sof_abi_hdr */ + SOF_CTRL_TYPE_DATA_GET, + SOF_CTRL_TYPE_DATA_SET, +}; + +/* control command type */ +enum sof_ipc_ctrl_cmd { + SOF_CTRL_CMD_VOLUME = 0, /* maps to ALSA volume style controls */ + SOF_CTRL_CMD_ENUM, /* maps to ALSA enum style controls */ + SOF_CTRL_CMD_SWITCH, /* maps to ALSA switch style controls */ + SOF_CTRL_CMD_BINARY, /* maps to ALSA binary style controls */ +}; + +/* generic channel mapped value data */ +struct sof_ipc_ctrl_value_chan { + enum sof_ipc_chmap channel; + uint32_t value; +} __attribute__((packed)); + +/* generic component mapped value data */ +struct sof_ipc_ctrl_value_comp { + uint32_t index; /* component source/sink/control index in control */ + union { + uint32_t uvalue; + int32_t svalue; + }; +} __attribute__((packed)); + +/* generic control data */ +struct sof_ipc_ctrl_data { + struct sof_ipc_reply rhdr; + uint32_t comp_id; + + /* control access and data type */ + enum sof_ipc_ctrl_type type; + enum sof_ipc_ctrl_cmd cmd; + uint32_t index; /* control index for comps > 1 control */ + + /* control data - can either be appended or DMAed from host */ + struct sof_ipc_host_buffer buffer; + uint32_t num_elems; /* in array elems or bytes */ + + /* control data - add new types if needed */ + union { + /* channel values can be used by volume type controls */ + struct sof_ipc_ctrl_value_chan chanv[0]; + /* component values used by routing controls like mux, mixer */ + struct sof_ipc_ctrl_value_comp compv[0]; + /* data can be used by binary controls */ + struct sof_abi_hdr data[0]; + }; +} __attribute__((packed)); + +/* + * Component + */ + +/* types of component */ +enum sof_comp_type { + SOF_COMP_NONE = 0, + SOF_COMP_HOST, + SOF_COMP_DAI, + SOF_COMP_SG_HOST, /* scatter gather variant */ + SOF_COMP_SG_DAI, /* scatter gather variant */ + SOF_COMP_VOLUME, + SOF_COMP_MIXER, + SOF_COMP_MUX, + SOF_COMP_SRC, + SOF_COMP_SPLITTER, + SOF_COMP_TONE, + SOF_COMP_SWITCH, + SOF_COMP_BUFFER, + SOF_COMP_EQ_IIR, + SOF_COMP_EQ_FIR, + SOF_COMP_FILEREAD, /* host test based file IO */ + SOF_COMP_FILEWRITE, /* host test based file IO */ +}; + +/* XRUN action for component */ +#define SOF_XRUN_STOP 1 /* stop stream */ +#define SOF_XRUN_UNDER_ZERO 2 /* send 0s to sink */ +#define SOF_XRUN_OVER_NULL 4 /* send data to NULL */ + +/* create new generic component - SOF_IPC_TPLG_COMP_NEW */ +struct sof_ipc_comp { + struct sof_ipc_hdr hdr; + uint32_t id; + enum sof_comp_type type; + uint32_t pipeline_id; +} __attribute__((packed)); + +/* + * Component Buffers + */ + +/* create new component buffer - SOF_IPC_TPLG_BUFFER_NEW */ +struct sof_ipc_buffer { + struct sof_ipc_comp comp; + uint32_t size; /* buffer size in bytes */ + uint32_t caps; /* SOF_MEM_CAPS_ */ +} __attribute__((packed)); + +/* generic component config data - must always be after struct sof_ipc_comp */ +struct sof_ipc_comp_config { + uint32_t periods_sink; /* 0 means variable */ + uint32_t periods_source; /* 0 means variable */ + uint32_t preload_count; /* how many periods to preload */ + enum sof_ipc_frame frame_fmt; + uint32_t xrun_action; +} __attribute__((packed)); + +/* generic host component */ +struct sof_ipc_comp_host { + struct sof_ipc_comp comp; + struct sof_ipc_comp_config config; + enum sof_ipc_stream_direction direction; + uint32_t no_irq; /* don't send periodic IRQ to host/DSP */ + uint32_t dmac_config; /* DMA engine specific */ +} __attribute__((packed)); + +/* generic DAI component */ +struct sof_ipc_comp_dai { + struct sof_ipc_comp comp; + struct sof_ipc_comp_config config; + enum sof_ipc_stream_direction direction; + uint32_t dai_index; /* index of this type dai */ + enum sof_ipc_dai_type type; + uint32_t dmac_config; /* DMA engine specific */ +} __attribute__((packed)); + +/* generic mixer component */ +struct sof_ipc_comp_mixer { + struct sof_ipc_comp comp; + struct sof_ipc_comp_config config; +} __attribute__((packed)); + +/* volume ramping types */ +enum sof_volume_ramp { + SOF_VOLUME_LINEAR = 0, + SOF_VOLUME_LOG, + SOF_VOLUME_LINEAR_ZC, + SOF_VOLUME_LOG_ZC, +}; + +/* generic volume component */ +struct sof_ipc_comp_volume { + struct sof_ipc_comp comp; + struct sof_ipc_comp_config config; + uint32_t channels; + uint32_t min_value; + uint32_t max_value; + enum sof_volume_ramp ramp; + uint32_t initial_ramp; /* ramp space in ms */ +} __attribute__((packed)); + +/* generic SRC component */ +struct sof_ipc_comp_src { + struct sof_ipc_comp comp; + struct sof_ipc_comp_config config; + /* either source or sink rate must be non zero */ + uint32_t source_rate; /* source rate or 0 for variable */ + uint32_t sink_rate; /* sink rate or 0 for variable */ + uint32_t rate_mask; /* SOF_RATE_ supported rates */ +} __attribute__((packed)); + +/* generic MUX component */ +struct sof_ipc_comp_mux { + struct sof_ipc_comp comp; + struct sof_ipc_comp_config config; +} __attribute__((packed)); + +/* generic tone generator component */ +struct sof_ipc_comp_tone { + struct sof_ipc_comp comp; + struct sof_ipc_comp_config config; + int32_t sample_rate; + int32_t frequency; + int32_t amplitude; + int32_t freq_mult; + int32_t ampl_mult; + int32_t length; + int32_t period; + int32_t repeats; + int32_t ramp_step; +} __attribute__((packed)); + +/* FIR equalizer component */ +struct sof_ipc_comp_eq_fir { + struct sof_ipc_comp comp; + struct sof_ipc_comp_config config; + uint32_t size; + unsigned char data[0]; +} __attribute__((packed)); + +/* IIR equalizer component */ +struct sof_ipc_comp_eq_iir { + struct sof_ipc_comp comp; + struct sof_ipc_comp_config config; + uint32_t size; + unsigned char data[0]; +} __attribute__((packed)); + +/** \brief Types of EFFECT */ +enum sof_ipc_effect_type { + SOF_EFFECT_NONE = 0, /**< None */ + SOF_EFFECT_INTEL_EQFIR, /**< Intel FIR */ + SOF_EFFECT_INTEL_EQIIR, /**< Intel IIR */ +}; + +/* frees components, buffers and pipelines + * SOF_IPC_TPLG_COMP_FREE, SOF_IPC_TPLG_PIPE_FREE, SOF_IPC_TPLG_BUFFER_FREE + */ +struct sof_ipc_free { + struct sof_ipc_hdr hdr; + uint32_t id; +} __attribute__((packed)); + +struct sof_ipc_comp_reply { + struct sof_ipc_reply rhdr; + uint32_t id; + uint32_t offset; +} __attribute__((packed)); + +/* + * Pipeline + */ + +/* new pipeline - SOF_IPC_TPLG_PIPE_NEW */ +struct sof_ipc_pipe_new { + struct sof_ipc_hdr hdr; + uint32_t comp_id; /* component id for pipeline */ + uint32_t pipeline_id; /* pipeline id */ + uint32_t sched_id; /* sheduling component id */ + uint32_t core; /* core we run on */ + uint32_t deadline; /* execution completion deadline in us*/ + uint32_t priority; /* priority level 0 (low) to 10 (max) */ + uint32_t mips; /* worst case instruction count per period */ + uint32_t frames_per_sched;/* output frames of pipeline, 0 is variable */ + uint32_t xrun_limit_usecs; /* report xruns greater than limit */ + + /* non zero if timer scheduled, otherwise DAI DMA irq scheduled */ + uint32_t timer_delay; +} __attribute__((packed)); + +/* pipeline construction complete - SOF_IPC_TPLG_PIPE_COMPLETE */ +struct sof_ipc_pipe_ready { + struct sof_ipc_hdr hdr; + uint32_t comp_id; +} __attribute__((packed)); + +struct sof_ipc_pipe_free { + struct sof_ipc_hdr hdr; + uint32_t comp_id; +} __attribute__((packed)); + +/* connect two components in pipeline - SOF_IPC_TPLG_COMP_CONNECT */ +struct sof_ipc_pipe_comp_connect { + struct sof_ipc_hdr hdr; + uint32_t source_id; + uint32_t sink_id; +} __attribute__((packed)); + +/* + * PM + */ + +/* PM context element */ +struct sof_ipc_pm_ctx_elem { + uint32_t type; + uint32_t size; + uint64_t addr; +} __attribute__((packed)); + +/* + * PM context - SOF_IPC_PM_CTX_SAVE, SOF_IPC_PM_CTX_RESTORE, + * SOF_IPC_PM_CTX_SIZE + */ +struct sof_ipc_pm_ctx { + struct sof_ipc_hdr hdr; + struct sof_ipc_host_buffer buffer; + uint32_t num_elems; + uint32_t size; + struct sof_ipc_pm_ctx_elem elems[]; +}; + +/* enable or disable cores - SOF_IPC_PM_CORE_ENABLE */ +struct sof_ipc_pm_core_config { + struct sof_ipc_hdr hdr; + uint32_t enable_mask; +}; + +/* + * Firmware boot and version + */ + +#define SOF_IPC_MAX_ELEMS 16 + +/* extended data types that can be appended onto end of sof_ipc_fw_ready */ +enum sof_ipc_ext_data { + SOF_IPC_EXT_DMA_BUFFER = 0, + SOF_IPC_EXT_WINDOW, +}; + +/* FW version - SOF_IPC_GLB_VERSION */ +struct sof_ipc_fw_version { + uint16_t major; + uint16_t minor; + uint16_t build; + uint8_t date[12]; + uint8_t time[10]; + uint8_t tag[6]; + uint16_t abi_version; + /* Make sure the total size is 4 bytes aligned */ +} __attribute__((packed)); + +/* FW ready Message - sent by firmware when boot has completed */ +struct sof_ipc_fw_ready { + struct sof_ipc_hdr hdr; + uint32_t dspbox_offset; /* dsp initiated IPC mailbox */ + uint32_t hostbox_offset; /* host initiated IPC mailbox */ + uint32_t dspbox_size; + uint32_t hostbox_size; + struct sof_ipc_fw_version version; +} __attribute__((packed)); + +/* + * Extended Firmware data. All optional, depends on platform/arch. + */ + +enum sof_ipc_region { + SOF_IPC_REGION_DOWNBOX = 0, + SOF_IPC_REGION_UPBOX, + SOF_IPC_REGION_TRACE, + SOF_IPC_REGION_DEBUG, + SOF_IPC_REGION_STREAM, + SOF_IPC_REGION_REGS, + SOF_IPC_REGION_EXCEPTION, +}; + +struct sof_ipc_ext_data_hdr { + struct sof_ipc_hdr hdr; + enum sof_ipc_ext_data type; /* SOF_IPC_EXT_ */ +}; + +struct sof_ipc_dma_buffer_elem { + enum sof_ipc_region type; + uint32_t id; /* platform specific - used to map to host memory */ + struct sof_ipc_host_buffer buffer; +}; + +/* extended data DMA buffers for IPC, trace and debug */ +struct sof_ipc_dma_buffer_data { + struct sof_ipc_ext_data_hdr ext_hdr; + uint32_t num_buffers; + /* host files in buffer[n].buffer */ + struct sof_ipc_dma_buffer_elem buffer[]; +} __attribute__((packed)); + +struct sof_ipc_window_elem { + enum sof_ipc_region type; + uint32_t id; /* platform specific - used to map to host memory */ + uint32_t flags; /* R, W, RW, etc - to define */ + uint32_t size; /* size of region in bytes */ + /* offset in window region as windows can be partitioned */ + uint32_t offset; +}; + +/* extended data memory windows for IPC, trace and debug */ +struct sof_ipc_window { + struct sof_ipc_ext_data_hdr ext_hdr; + uint32_t num_windows; + struct sof_ipc_window_elem window[]; +} __attribute__((packed)); + +/* + * DMA for Trace + */ + +/* DMA for Trace params info - SOF_IPC_DEBUG_DMA_PARAMS */ +struct sof_ipc_dma_trace_params { + struct sof_ipc_hdr hdr; + struct sof_ipc_host_buffer buffer; + uint32_t stream_tag; +} __attribute__((packed)); + +/* DMA for Trace params info - SOF_IPC_DEBUG_DMA_PARAMS */ +struct sof_ipc_dma_trace_posn { + struct sof_ipc_reply rhdr; + uint32_t host_offset; /* Offset of DMA host buffer */ + uint32_t overflow; /* overflow bytes if any */ + uint32_t messages; /* total trace messages */ +} __attribute__((packed)); + +/* + * Architecture specific debug + */ + +/* Xtensa Firmware Oops data */ +struct sof_ipc_dsp_oops_xtensa { + uint32_t exccause; + uint32_t excvaddr; + uint32_t ps; + uint32_t epc1; + uint32_t epc2; + uint32_t epc3; + uint32_t epc4; + uint32_t epc5; + uint32_t epc6; + uint32_t epc7; + uint32_t eps2; + uint32_t eps3; + uint32_t eps4; + uint32_t eps5; + uint32_t eps6; + uint32_t eps7; + uint32_t depc; + uint32_t intenable; + uint32_t interrupt; + uint32_t sar; + uint32_t stack; +} __attribute__((packed)); + +/* + * Commom debug + */ + +/* panic info include filename and line number */ +struct sof_ipc_panic_info { + char filename[32]; + uint32_t linenum; +} __attribute__((packed)); + +/** @}*/ + +#endif From 105b9b51abed7787d6348ba6f95e4b9c6b593526 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Fri, 2 Nov 2018 14:33:27 +0100 Subject: [PATCH 290/324] logger: logging topology number for component I've added printing component topology number (i.e. pipeline_id.component_id). If id's are not defined logger will not print any values. e.g.: CORE LEVEL COMP_ID TIMESTAMP ... 0 2 HOST 487048.229167 ... (not defined id's) 0 2 PIPE 1.3 591235.052083 ... (defined id's) Signed-off-by: Bartosz Kokoszko --- rmbox/logger_convert.c | 67 ++++++++++++++++++---------------------- rmbox/rmbox.c | 1 - rmbox/sof/uapi/logging.h | 10 ++++-- 3 files changed, 37 insertions(+), 41 deletions(-) diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index e2009537bacf..256ed3d2381d 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -27,6 +27,7 @@ #define TRACE_MAX_PARAMS_COUNT 4 #define TRACE_MAX_TEXT_LEN 1024 #define TRACE_MAX_FILENAME_LEN 128 +#define TRACE_MAX_IDS_STR 9 /* logs file signature */ #define SND_SOF_LOGS_SIG_SIZE 4 @@ -45,31 +46,28 @@ struct snd_sof_logs_header { struct ldc_entry_header { uint32_t level; - uint32_t component_id; + uint32_t component_class; + uint32_t has_ids; uint32_t params_num; uint32_t line_idx; uint32_t file_name_len; + uint32_t text_len; }; struct ldc_entry { struct ldc_entry_header header; char *file_name; - uint32_t text_len; char *text; uint32_t *params; }; -struct dma_log { - struct log_entry_header header; - uint32_t address; -}; - static inline void print_table_header(FILE *out_fd) { - fprintf(out_fd, "%5s %6s %8s %16s %16s %24s\t%s\n", + fprintf(out_fd, "%5s %6s %12s %7s %16s %16s %24s\t%s\n", "CORE", "LEVEL", "COMP_ID", + "", "TIMESTAMP", "DELTA", "FILE_NAME", @@ -109,19 +107,25 @@ static const char * get_component_name(uint32_t component_id) { } } -static void print_entry_params(FILE *out_fd, struct dma_log dma_log, +static void print_entry_params(FILE *out_fd, struct log_entry_header dma_log, struct ldc_entry entry, uint64_t last_timestamp, double clock) -{ - float dt = to_usecs(dma_log.header.timestamp - last_timestamp, clock); +{ + char ids[TRACE_MAX_IDS_STR]; + float dt = to_usecs(dma_log.timestamp - last_timestamp, clock); + if (dt < 0 || dt > 1000.0 * 1000.0 * 1000.0) dt = NAN; + + if (entry.header.has_ids) + sprintf(ids, "%d.%d", dma_log.id_0, dma_log.id_1); - fprintf(out_fd, "%s%5u %6u %8s %16.6f %16.6f %20s:%-4u\t", + fprintf(out_fd, "%s%5u %6u %12s %-7s %16.6f %16.6f %20s:%-4u\t", entry.header.level == LOG_LEVEL_CRITICAL ? KRED : KNRM, - dma_log.header.core_id, + dma_log.core_id, entry.header.level, - get_component_name(entry.header.component_id), - to_usecs(dma_log.header.timestamp, clock), + get_component_name(entry.header.component_class), + entry.header.has_ids ? ids : "", + to_usecs(dma_log.timestamp, clock), dt, entry.file_name, entry.header.line_idx); @@ -150,7 +154,7 @@ static void print_entry_params(FILE *out_fd, struct dma_log dma_log, } static int fetch_entry(struct convert_config *config, uint32_t base_address, - uint32_t data_offset, struct dma_log dma_log, uint64_t *last_timestamp) + uint32_t data_offset, struct log_entry_header dma_log, uint64_t *last_timestamp) { struct ldc_entry entry; long int padding; @@ -165,7 +169,7 @@ static int fetch_entry(struct convert_config *config, uint32_t base_address, entry.params = NULL; /* evaluate entry offset in input file */ - entry_offset = dma_log.address - base_address; + entry_offset = dma_log.log_entry_address - base_address; /* set file position to beginning of processed entry */ fseek(config->ldc_fd, entry_offset + data_offset, SEEK_SET); @@ -197,32 +201,21 @@ static int fetch_entry(struct convert_config *config, uint32_t base_address, goto out; } - /* padding - sequences of chars are aligned to DWORDS */ - fseek(config->ldc_fd, CEIL(entry.header.file_name_len, sizeof(uint32_t)) * - sizeof(uint32_t) - entry.header.file_name_len, SEEK_CUR); - - /* fetching text length */ - ret = fread(&entry.text_len, sizeof(entry.text_len), 1, config->ldc_fd); - if (!ret) { - ret = -ferror(config->ldc_fd); - goto out; - } - /* fetching text */ - if (entry.text_len > TRACE_MAX_TEXT_LEN) { + if (entry.header.text_len > TRACE_MAX_TEXT_LEN) { fprintf(stderr, "Error: Invalid text length. \n"); ret = -EINVAL; goto out; } - entry.text = (char *)malloc(entry.text_len); + entry.text = (char *)malloc(entry.header.text_len); if (entry.text == NULL) { fprintf(stderr, "error: can't allocate %d byte for " - "entry.text\n", entry.text_len); + "entry.text\n", entry.header.text_len); ret = -ENOMEM; goto out; } - ret = fread(entry.text, sizeof(char), entry.text_len, config->ldc_fd); - if (ret != entry.text_len) { + ret = fread(entry.text, sizeof(char), entry.header.text_len, config->ldc_fd); + if (ret != entry.header.text_len) { ret = -ferror(config->ldc_fd); goto out; } @@ -252,7 +245,7 @@ static int fetch_entry(struct convert_config *config, uint32_t base_address, /* printing entry content */ print_entry_params(config->out_fd, dma_log, entry, *last_timestamp, config->clock); - *last_timestamp = dma_log.header.timestamp; + *last_timestamp = dma_log.timestamp; /* set f_ldc file position to the beginning */ rewind(config->ldc_fd); @@ -270,7 +263,7 @@ static int fetch_entry(struct convert_config *config, uint32_t base_address, static int logger_read(struct convert_config *config, struct snd_sof_logs_header *snd) { - struct dma_log dma_log; + struct log_entry_header dma_log; int ret = 0; print_table_header(config->out_fd); uint64_t last_timestamp = 0; @@ -285,8 +278,8 @@ static int logger_read(struct convert_config *config, /* checking if received trace address is located in * entry section in elf file. */ - if ((dma_log.address < snd->base_address) || - dma_log.address > snd->base_address + snd->data_length) { + if ((dma_log.log_entry_address < snd->base_address) || + dma_log.log_entry_address > snd->base_address + snd->data_length) { /* in case the address is not correct input fd should be * move forward by one DWORD, not entire struct dma_log */ diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 2528c7518d26..3f27b11d72ab 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -18,7 +18,6 @@ #include #include #include - #include "convert.h" #ifdef LOGGER_FORMAT diff --git a/rmbox/sof/uapi/logging.h b/rmbox/sof/uapi/logging.h index b97309c29034..c5423fc111a5 100644 --- a/rmbox/sof/uapi/logging.h +++ b/rmbox/sof/uapi/logging.h @@ -98,6 +98,8 @@ struct log_buffer_status { uint32_t core_id; /* ID of core that logged to other half */ }; +#define TRACE_ID_LENGTH 12 + /* * Log entry header. * @@ -106,10 +108,12 @@ struct log_buffer_status { * and is 0-based value (entry_len=0 means there is 1 argument). */ struct log_entry_header { - uint32_t rsvd : 24; /* Unused */ - uint32_t core_id : 8; /* Reporting core's id */ + uint32_t id_0 : TRACE_ID_LENGTH; /* Pipeline ID */ + uint32_t id_1 : TRACE_ID_LENGTH; /* Component ID */ + uint32_t core_id : 8; /* Reporting core's id */ - uint64_t timestamp; /* Timestamp (in dsp ticks) */ + uint64_t timestamp; /* Timestamp (in dsp ticks) */ + uint32_t log_entry_address; /* Address of log entry in ELF */ } __attribute__((__packed__)); #endif //#ifndef __INCLUDE_LOGGING__ From b141daee34aafb108c474c1eaf946eceb48f5621 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Fri, 9 Nov 2018 15:03:18 +0100 Subject: [PATCH 291/324] logger: string overflow warning fix fixes #124 Signed-off-by: Bartosz Kokoszko --- rmbox/logger_convert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index 256ed3d2381d..daf5f9903016 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -27,7 +27,7 @@ #define TRACE_MAX_PARAMS_COUNT 4 #define TRACE_MAX_TEXT_LEN 1024 #define TRACE_MAX_FILENAME_LEN 128 -#define TRACE_MAX_IDS_STR 9 +#define TRACE_MAX_IDS_STR 10 /* logs file signature */ #define SND_SOF_LOGS_SIG_SIZE 4 From d6bb7043b75f95ecfbd4f783f974b7c0fc669ae0 Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Fri, 9 Nov 2018 17:38:59 +0100 Subject: [PATCH 292/324] logger: added Werr and Wall and removed warnings Signed-off-by: Bartosz Kokoszko --- rmbox/Makefile.am | 10 +++++++++- rmbox/convert.c | 22 ++++++++++++++++++++++ rmbox/convert.h | 7 +------ rmbox/logger_convert.c | 7 ++----- rmbox/rmbox.c | 5 +---- rmbox/rmbox_convert.c | 13 +++++++------ 6 files changed, 42 insertions(+), 22 deletions(-) create mode 100644 rmbox/convert.c diff --git a/rmbox/Makefile.am b/rmbox/Makefile.am index c35e6e95579f..54819b2fceff 100644 --- a/rmbox/Makefile.am +++ b/rmbox/Makefile.am @@ -2,11 +2,19 @@ bin_PROGRAMS = sof-rmbox sof-logger sof_rmbox_SOURCES = \ rmbox.c \ + convert.c \ rmbox_convert.c sof_logger_SOURCES = \ rmbox.c \ + convert.c \ logger_convert.c +sof_rmbox_CFLAGS = \ + -Wall \ + -Werror + sof_logger_CFLAGS = \ - -DLOGGER_FORMAT + -DLOGGER_FORMAT \ + -Wall \ + -Werror diff --git a/rmbox/convert.c b/rmbox/convert.c new file mode 100644 index 000000000000..c877c6cc1072 --- /dev/null +++ b/rmbox/convert.c @@ -0,0 +1,22 @@ +/* +* debug log converter interface. +* +* Copyright (c) 2018, Intel Corporation. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms and conditions of the GNU General Public License, +* version 2, as published by the Free Software Foundation. +* +* This program is distributed in the hope it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +*/ +#include "convert.h" + +double to_usecs(uint64_t time, double clk) +{ + /* trace timestamp uses CPU system clock at default 25MHz ticks */ + // TODO: support variable clock rates + return (double)time / clk; +} diff --git a/rmbox/convert.h b/rmbox/convert.h index 2e0e391f610b..488258f68fdd 100644 --- a/rmbox/convert.h +++ b/rmbox/convert.h @@ -18,12 +18,7 @@ #define KNRM "\x1B[0m" #define KRED "\x1B[31m" -static double to_usecs(uint64_t time, double clk) -{ - /* trace timestamp uses CPU system clock at default 25MHz ticks */ - // TODO: support variable clock rates - return (double)time / clk; -} +double to_usecs(uint64_t time, double clk); struct convert_config { const char *out_file; diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index daf5f9903016..0204350fd650 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -157,10 +157,7 @@ static int fetch_entry(struct convert_config *config, uint32_t base_address, uint32_t data_offset, struct log_entry_header dma_log, uint64_t *last_timestamp) { struct ldc_entry entry; - long int padding; - uint32_t entry_offset; - uint32_t text_len; int ret; @@ -307,7 +304,7 @@ int convert(struct convert_config *config) { return -ferror(config->ldc_fd); } - if (strncmp(snd.sig, SND_SOF_LOGS_SIG, SND_SOF_LOGS_SIG_SIZE)) { + if (strncmp((char *) snd.sig, SND_SOF_LOGS_SIG, SND_SOF_LOGS_SIG_SIZE)) { fprintf(stderr, "Error: Invalid ldc file signature. \n"); return -EINVAL; } @@ -315,7 +312,7 @@ int convert(struct convert_config *config) { /* fw verification */ if (config->version_fd) { struct sof_ipc_fw_version ver; - int i; + /* here fw verification should be exploited */ count = fread(&ver, sizeof(ver), 1, config->version_fd); if (!count) { diff --git a/rmbox/rmbox.c b/rmbox/rmbox.c index 3f27b11d72ab..55d6b4795eae 100644 --- a/rmbox/rmbox.c +++ b/rmbox/rmbox.c @@ -111,10 +111,7 @@ static int snapshot(const char *name) int main(int argc, char *argv[]) { struct convert_config config; - int opt, count, ret = 0; - FILE *in_fd = NULL, *out_fd = NULL; - char c, tmp[8] = {0}; - uint64_t addr = 0, val, timestamp = 0, align = 4, i; + int opt, ret = 0; config.trace = 0; config.clock = 19.2; diff --git a/rmbox/rmbox_convert.c b/rmbox/rmbox_convert.c index ddd419a08a07..d47fab18eec3 100644 --- a/rmbox/rmbox_convert.c +++ b/rmbox/rmbox_convert.c @@ -115,7 +115,8 @@ static void show_trace(FILE *out_fd, uint64_t val, uint64_t addr, int convert(struct convert_config *config) { int count, i; - char c, tmp[TRACE_BLOCK_SIZE] = { 0 }; + char c; + uint64_t tmp[TRACE_BLOCK_SIZE / sizeof(uint64_t)] = { 0 }; uint64_t addr = 0, val, timestamp = 0; fprintf(stdout, "using %2.2fMHz timestamp clock\n", config->clock); @@ -125,12 +126,12 @@ int convert(struct convert_config *config) if (count != TRACE_BLOCK_SIZE) break; - val = *((uint64_t*)tmp); - + val = *tmp; for (i = 0; i < TRACE_BLOCK_SIZE / 2; i++) { - c = tmp[i]; - tmp[i] = tmp[TRACE_BLOCK_SIZE - i - 1]; - tmp[TRACE_BLOCK_SIZE - i - 1] = c; + c = ((char *) tmp)[i]; + ((char *)tmp)[i] = + ((char *) tmp)[TRACE_BLOCK_SIZE - i - 1]; + ((char *)tmp)[TRACE_BLOCK_SIZE - i - 1] = c; } show_trace(config->out_fd, val, addr, ×tamp, config->clock); From 7f3b59b88897dd95ab3fb7f0d89390d7d0ae35ed Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 15 Nov 2018 14:44:26 +0800 Subject: [PATCH 293/324] test: topology: add test topology for CNL CNL nocodec use SSP0, add SSP0 test for CNL Signed-off-by: Pan Xiuli --- test/topology/tplg-build.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/topology/tplg-build.sh b/test/topology/tplg-build.sh index da4fbad53d7d..9df05ac71154 100755 --- a/test/topology/tplg-build.sh +++ b/test/topology/tplg-build.sh @@ -204,6 +204,13 @@ do done # for CNL +simple_test nocodec passthrough "NoCodec-0" s16le SSP 0 s16le 25 16 2400000 24000000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec passthrough "NoCodec-2" s24le SSP 0 s24le 25 24 2400000 24000000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-0" s16le SSP 0 s16le 25 16 2400000 24000000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-0" s16le SSP 0 s24le 25 24 2400000 24000000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-0" s24le SSP 0 s24le 25 24 2400000 24000000 I2S 0 SIMPLE_TESTS[@] +simple_test nocodec volume "NoCodec-0" s24le SSP 0 s16le 25 16 2400000 24000000 I2S 0 SIMPLE_TESTS[@] + simple_test nocodec passthrough "NoCodec-2" s16le SSP 2 s16le 25 16 2400000 24000000 I2S 0 SIMPLE_TESTS[@] simple_test nocodec passthrough "NoCodec-2" s24le SSP 2 s24le 25 24 2400000 24000000 I2S 0 SIMPLE_TESTS[@] simple_test nocodec volume "NoCodec-2" s16le SSP 2 s16le 25 16 2400000 24000000 I2S 0 SIMPLE_TESTS[@] From ee6f54b8432d542dce57a4112fe5b50db6c3e741 Mon Sep 17 00:00:00 2001 From: Pan Xiuli Date: Thu, 15 Nov 2018 14:45:21 +0800 Subject: [PATCH 294/324] ci: travis: add test topology Build tests for travis CI Signed-off-by: Pan Xiuli --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 12533d10f63e..58c664662cc0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,7 @@ services: before_install: - docker pull xiulipan/sof - - echo -e '#!/bin/bash \n./autogen.sh && ./configure && make' > quickbuild.sh + - echo -e '#!/bin/bash \n./autogen.sh && ./configure && make && make tests 1>/dev/null' > quickbuild.sh - chmod 755 quickbuild.sh script: From 22354d61e1d7eae6790379aebd9155bb8869113a Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Thu, 15 Nov 2018 10:38:06 +0100 Subject: [PATCH 295/324] logger: kw: fix logger klockwork issues Signed-off-by: Bartosz Kokoszko --- rmbox/logger_convert.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rmbox/logger_convert.c b/rmbox/logger_convert.c index 0204350fd650..267e3e8c0c55 100644 --- a/rmbox/logger_convert.c +++ b/rmbox/logger_convert.c @@ -28,6 +28,7 @@ #define TRACE_MAX_TEXT_LEN 1024 #define TRACE_MAX_FILENAME_LEN 128 #define TRACE_MAX_IDS_STR 10 +#define TRACE_IDS_MASK ((1 << TRACE_ID_LENGTH) - 1) /* logs file signature */ #define SND_SOF_LOGS_SIG_SIZE 4 @@ -117,7 +118,8 @@ static void print_entry_params(FILE *out_fd, struct log_entry_header dma_log, dt = NAN; if (entry.header.has_ids) - sprintf(ids, "%d.%d", dma_log.id_0, dma_log.id_1); + sprintf(ids, "%d.%d", (dma_log.id_0 & TRACE_IDS_MASK), + (dma_log.id_1 & TRACE_IDS_MASK)); fprintf(out_fd, "%s%5u %6u %12s %-7s %16.6f %16.6f %20s:%-4u\t", entry.header.level == LOG_LEVEL_CRITICAL ? KRED : KNRM, From 2e319edcb663bc698d3eeece5c4c38633d38e03a Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Nov 2018 17:54:37 -0800 Subject: [PATCH 296/324] Ignore built binaries Git is seeing build artifacts Signed-off-by: Curtis Malainey --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 023e26404641..9771824e7581 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ rwav/rwav *.tplg topology/*.conf topology/test/*.conf +eqctl/sof-eqctl +rmbox/sof-logger +rmbox/sof-rmbox From cbf60f2bb2549d5ee81a27fc3162615ec540456f Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Nov 2018 18:05:19 -0800 Subject: [PATCH 297/324] Correct sof-bdw-rt5640 Correct comments to reflect code Signed-off-by: Curtis Malainey --- topology/sof-bdw-rt5640.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/topology/sof-bdw-rt5640.m4 b/topology/sof-bdw-rt5640.m4 index 454e050b527c..5280327dd034 100644 --- a/topology/sof-bdw-rt5640.m4 +++ b/topology/sof-bdw-rt5640.m4 @@ -1,5 +1,5 @@ # -# Topology for generic Broadwell board with no codec. +# Topology for generic Broadwell board with rt5640. # # Include topology builder @@ -21,12 +21,12 @@ include(`platform/intel/bdw.m4') # Define the pipelines # # PCM0 ----> volume ---------------+ -# |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ +# |--low latency mixer ----> volume ----> SSP0 +# PCM1 -----> volume ----> SRC ----+ # | # Tone -----> volume ----+ # -# PCM1 <---- Volume <---- SSP0 +# PCM0 <---- Volume <---- SSP0 # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. From f704d361e1f975883dc759b010caa224acbd1617 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Nov 2018 18:09:34 -0800 Subject: [PATCH 298/324] Fix pipe-eq-capture comments Fix copy paste comment errors Signed-off-by: Curtis Malainey --- topology/sof/pipe-eq-capture.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/sof/pipe-eq-capture.m4 b/topology/sof/pipe-eq-capture.m4 index 5b415f08f640..752bc66330e8 100644 --- a/topology/sof/pipe-eq-capture.m4 +++ b/topology/sof/pipe-eq-capture.m4 @@ -1,8 +1,8 @@ -# Capture Passthrough Pipeline and PCM +# Capture EQ Pipeline and PCM # # Pipeline Endpoints for connection are :- # -# host PCM_C <-- B0 <-- sink DAI0 +# host PCM_C <--- B1 <--- EQ_IIR 0 <-- B0 <-- sink DAI0 # Include topology builder include(`utils.m4') From b65fe8e02163a98c5462f44d7a7cbbd0ed8f0843 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Nov 2018 18:10:22 -0800 Subject: [PATCH 299/324] Fix sof-apl-eq-dmic comments Fix copy paste comment errors Signed-off-by: Curtis Malainey --- topology/sof-apl-eq-dmic.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof-apl-eq-dmic.m4 b/topology/sof-apl-eq-dmic.m4 index 7768af44fa14..f38bb1acfee0 100644 --- a/topology/sof-apl-eq-dmic.m4 +++ b/topology/sof-apl-eq-dmic.m4 @@ -20,7 +20,7 @@ include(`platform/intel/dmic.m4') # # Define the pipelines # -# PCM6 <---- volume <----- DMIC6 (DMIC01) +# PCM6 <---- EQ IIR <----- DMIC6 (DMIC01) # dnl PIPELINE_PCM_ADD(pipeline, From 42e9bd979df72f6220995cc52e7011960d72b4bb Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Nov 2018 18:15:46 -0800 Subject: [PATCH 300/324] Fix sof-apl-eq-pcm512x comments Fix copy paste errors Signed-off-by: Curtis Malainey --- topology/sof-apl-eq-pcm512x.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/sof-apl-eq-pcm512x.m4 b/topology/sof-apl-eq-pcm512x.m4 index f1fda8de9b7c..25de02418a7b 100644 --- a/topology/sof-apl-eq-pcm512x.m4 +++ b/topology/sof-apl-eq-pcm512x.m4 @@ -1,5 +1,5 @@ # -# Topology for generic Apollolake UP^2 with pcm512x codec. +# Topology for generic Apollolake UP^2 with pcm512x codec with equalizer components. # # Include topology builder @@ -20,7 +20,7 @@ include(`platform/intel/bxt.m4') # # Define the pipelines # -# PCM0 ----> volume -----> SSP5 (pcm512x) +# PCM0 ----> EQ IIR ----> EQ FIR ----> volume ----> SSP5 (pcm512x) # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. From 79252d6c466f20bb8c3965fb3e075d2d752a4d1f Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Nov 2018 18:19:57 -0800 Subject: [PATCH 301/324] Fix sof-apl-nocodec comments Follow graph convention in other files as well as fix typos and comments Signed-off-by: Curtis Malainey --- topology/sof-apl-nocodec.m4 | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/topology/sof-apl-nocodec.m4 b/topology/sof-apl-nocodec.m4 index 2a9956087621..b82503d812ef 100644 --- a/topology/sof-apl-nocodec.m4 +++ b/topology/sof-apl-nocodec.m4 @@ -1,5 +1,5 @@ # -# Topology for generic Apollolake board with no codec. +# Topology for generic Apollolake board with no codec and digital mic array. # # Include topology builder @@ -21,18 +21,12 @@ include(`platform/intel/dmic.m4') # # Define the pipelines # -# PCM0 ----> volume -----> SSP0 -# <---- volume <----- SSP0 -# PCM1 ----> Volume <----- SSP1 -# <---- Volume <----- SSP1 -# PCM2 ----> volume -----> SSP2 -# <---- Volume <----- SSP2 -# PCM3 ----> volume -----> SSP3 -# <---- volume <----- SSP3 -# PCM4 ----> volume -----> SSP4 -# <---- Volume <----- SSP4 -# PCM5 ----> volume -----> SSP5 -# <---- volume <----- SSP5 +# PCM0 <---> volume <----> SSP0 +# PCM1 <---> Volume <----> SSP1 +# PCM2 <---> volume <----> SSP2 +# PCM3 <---> volume <----> SSP3 +# PCM4 <---> volume <----> SSP4 +# PCM5 <---> volume <----> SSP5 # PCM6 <---- volume <----- DMIC6 (DMIC01) # From af9d2d4e5719b3b225e0546d5698cd2c5952d2c2 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Nov 2018 18:22:45 -0800 Subject: [PATCH 302/324] Fix sof-apl-pcm512x Fix graph to reflect file Signed-off-by: Curtis Malainey --- topology/sof-apl-pcm512x.m4 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/topology/sof-apl-pcm512x.m4 b/topology/sof-apl-pcm512x.m4 index 3b4d01e9cc79..0688c98ca5e5 100644 --- a/topology/sof-apl-pcm512x.m4 +++ b/topology/sof-apl-pcm512x.m4 @@ -1,5 +1,5 @@ # -# Topology for generic Apollolake UP^2 with pcm512x codec. +# Topology for generic Apollolake UP^2 with pcm512x codec and HDMI. # # Include topology builder @@ -24,6 +24,9 @@ DEBUG_START # Define the pipelines # # PCM0 ----> volume -----> SSP5 (pcm512x) +# PCM1 ----> volume -----> iDisp1 +# PCM2 ----> volume -----> iDisp2 +# PCM3 ----> volume -----> iDisp3 # dnl PIPELINE_PCM_ADD(pipeline, From 5452897dc9308c7e4fd4e17649550dec880eacdb Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Nov 2018 18:32:29 -0800 Subject: [PATCH 303/324] update sof-apl-tdf8532 consolidate graph styles Signed-off-by: Curtis Malainey --- topology/sof-apl-tdf8532.m4 | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/topology/sof-apl-tdf8532.m4 b/topology/sof-apl-tdf8532.m4 index c82c1f000d62..b8d1faa03d6c 100644 --- a/topology/sof-apl-tdf8532.m4 +++ b/topology/sof-apl-tdf8532.m4 @@ -20,16 +20,12 @@ include(`platform/intel/bxt.m4') # # Define the pipelines # -# PCM0 ----> volume -----> SSP4 -# PCM1 ----> volume -----> SSP2(Dirana Pb) -# <---- Volume <----- SSP2(Dirana Cp) -# PCM2 ----> volume -----> SSP0(BT HFP out) -# <---- volume <----- SSP0(BT HFP in) -# PCM3 <---- Volume <----- SSP1(HDMI in) -# PCM4 ----> volume -----> SSP3(Modem out) -# <---- volume <----- SSP3(Modem in) -# PCM5 ----> volume -----> SSP5(TestPin out) -# <---- volume <----- SSP3(TestPin in) +# PCM0 -----> Volume -----> SSP4 +# PCM1 <----> Volume <----> SSP2(Dirana Pb/Cp) +# PCM2 <----> Volume <----> SSP0(BT HFP out/in) +# PCM3 <----- Volume <----- SSP1(HDMI in) +# PCM4 <----> Volume <----> SSP3(Modem out/in) +# PCM5 <----> Volume <----> SSP5(TestPin out/in) # # Low Latency playback pipeline 1 on PCM 0 using max 4 channels of s32le. From 888260a768ef65652f0b821cbd66fe315a423669 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Nov 2018 18:37:51 -0800 Subject: [PATCH 304/324] Update comments for sof-bdw-rt286 Update header to reflect code Signed-off-by: Curtis Malainey --- topology/sof-bdw-rt286.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/topology/sof-bdw-rt286.m4 b/topology/sof-bdw-rt286.m4 index a75034485cda..848ca424cec2 100644 --- a/topology/sof-bdw-rt286.m4 +++ b/topology/sof-bdw-rt286.m4 @@ -1,5 +1,5 @@ # -# Topology for generic Broadwell board with no codec. +# Topology for generic Broadwell board with rt286. # # Include topology builder @@ -21,12 +21,12 @@ include(`platform/intel/bdw.m4') # Define the pipelines # # PCM0 ----> volume ---------------+ -# |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ +# |--low latency mixer ----> volume ----> SSP0 +# PCM1 -----> volume -----> SRC ---+ # | # Tone -----> volume ----+ # -# PCM1 <---- Volume <---- SSP0 +# PCM0 <---- Volume <---- SSP0 # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. From 9f210ad755e5fa0b2f56ceef82ce5a3a1da1306f Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Nov 2018 18:51:43 -0800 Subject: [PATCH 305/324] Update sof-byt-da7213 Update graph to represent code Signed-off-by: Curtis Malainey --- topology/sof-byt-da7213.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/sof-byt-da7213.m4 b/topology/sof-byt-da7213.m4 index 6008ff0f23cf..68fe7567b0e7 100644 --- a/topology/sof-byt-da7213.m4 +++ b/topology/sof-byt-da7213.m4 @@ -22,11 +22,11 @@ include(`platform/intel/byt.m4') # # PCM0 ----> volume ---------------+ # |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ +# PCM1 -----> volume ----> SRC ----+ # | # Tone -----> volume ----+ # -# PCM1 <---- Volume <---- SSP2 +# PCM0 <---- Volume <---- SSP2 # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. From d5ac458f56ac6d16cd42bab8b3b4fbdbeb27a29b Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Thu, 15 Nov 2018 18:52:35 -0800 Subject: [PATCH 306/324] Update sof-byt-nocodec Make it clearer that there is no codec as well as update the media graph Signed-off-by: Curtis Malainey --- topology/sof-byt-nocodec.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/topology/sof-byt-nocodec.m4 b/topology/sof-byt-nocodec.m4 index 6df25cad8f97..ee4e93efac97 100644 --- a/topology/sof-byt-nocodec.m4 +++ b/topology/sof-byt-nocodec.m4 @@ -21,12 +21,12 @@ include(`platform/intel/byt.m4') # Define the pipelines # # PCM0 ----> volume ---------------+ -# |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ +# |--low latency mixer ----> volume ----> SSP2 (NoCodec) +# PCM2 -----> volume ----> SRC ----+ # | # Tone -----> volume ----+ # -# PCM1 <---- Volume <---- SSP2 +# PCM1 <---- Volume <---- SSP2 (NoCodec) # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. From 141493604af59eac5db94c0f75adf061c840c021 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 16 Nov 2018 15:02:58 -0800 Subject: [PATCH 307/324] Update sof-byt-rt5640 graph correct graph Signed-off-by: Curtis Malainey --- topology/sof-byt-rt5640.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/sof-byt-rt5640.m4 b/topology/sof-byt-rt5640.m4 index 2177fe30412c..5e6cb0491b9e 100644 --- a/topology/sof-byt-rt5640.m4 +++ b/topology/sof-byt-rt5640.m4 @@ -22,11 +22,11 @@ include(`platform/intel/byt.m4') # # PCM0 ----> volume ---------------+ # |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ +# PCM1 -----> volume ----> SRC ----+ # | # Tone -----> volume ----+ # -# PCM1 <---- Volume <---- SSP2 +# PCM0 <---- Volume <---- SSP2 # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. From adf6db4d859c8d496f451a949ce30a2a995b8497 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 16 Nov 2018 15:06:45 -0800 Subject: [PATCH 308/324] Update sof-byt-rt5645 graph update graph to represent code Signed-off-by: Curtis Malainey --- topology/sof-byt-rt5645.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/topology/sof-byt-rt5645.m4 b/topology/sof-byt-rt5645.m4 index 23f1a758128e..354104fc4eb2 100644 --- a/topology/sof-byt-rt5645.m4 +++ b/topology/sof-byt-rt5645.m4 @@ -1,5 +1,5 @@ # -# Topology for generic Baytrail board with no codec. +# Topology for generic Baytrail board with RT5645. # # Include topology builder @@ -22,11 +22,11 @@ include(`platform/intel/byt.m4') # # PCM0 ----> volume ---------------+ # |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ +# PCM1 -----> volume ----> SRC ----+ # | # Tone -----> volume ----+ # -# PCM1 <---- Volume <---- SSP2 +# PCM0 <---- Volume <---- SSP2 # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. From f18a895aec7610da51f78c72cb7b220fb21d18ac Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 16 Nov 2018 15:08:11 -0800 Subject: [PATCH 309/324] Update sof-byt-rt5651 Correct graph Signed-off-by: Curtis Malainey --- topology/sof-byt-rt5651.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/sof-byt-rt5651.m4 b/topology/sof-byt-rt5651.m4 index 724c34e6410c..ee9b70e69ace 100644 --- a/topology/sof-byt-rt5651.m4 +++ b/topology/sof-byt-rt5651.m4 @@ -22,11 +22,11 @@ include(`platform/intel/byt.m4') # # PCM0 ----> volume ---------------+ # |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ +# PCM1 -----> volume ----> SRC ----+ # | # Tone -----> volume ----+ # -# PCM1 <---- Volume <---- SSP2 +# PCM0 <---- Volume <---- SSP2 # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. From 3560320ca3d411e720858326455c99ff121bb391 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 16 Nov 2018 15:11:58 -0800 Subject: [PATCH 310/324] Update sof-cht-max98090 graph Update to properly reflect code Signed-off-by: Curtis Malainey --- topology/sof-cht-max98090.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/sof-cht-max98090.m4 b/topology/sof-cht-max98090.m4 index 627181ffcf46..b88af17ea212 100644 --- a/topology/sof-cht-max98090.m4 +++ b/topology/sof-cht-max98090.m4 @@ -22,11 +22,11 @@ include(`platform/intel/cht.m4') # # PCM0 ----> volume ---------------+ # |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ +# PCM1 -----> volume ----> SRC ----+ # | # Tone -----> volume ----+ # -# PCM1 <---- Volume <---- SSP2 +# PCM0 <---- Volume <---- SSP2 # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. From 2331cfaf9eb292b6cad8d688734e164aaf5d984c Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 16 Nov 2018 15:14:03 -0800 Subject: [PATCH 311/324] Update sof-cht-nocodec Update graph comments Signed-off-by: Curtis Malainey --- topology/sof-cht-nocodec.m4 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/topology/sof-cht-nocodec.m4 b/topology/sof-cht-nocodec.m4 index dae6dca39522..c56773a9655f 100644 --- a/topology/sof-cht-nocodec.m4 +++ b/topology/sof-cht-nocodec.m4 @@ -21,12 +21,12 @@ include(`platform/intel/cht.m4') # Define the pipelines # # PCM0 ----> volume ---------------+ -# |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ +# |--low latency mixer ----> volume ----> SSP2 (NoCodec) +# PCM1 -----> volume ----> SRC ----+ # | # Tone -----> volume ----+ # -# PCM1 <---- Volume <---- SSP2 +# PCM0 <---- Volume <---- SSP2 (NoCodec) # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. From c304613744981fe0ea385ed1efa234ac2f42786e Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 16 Nov 2018 15:17:45 -0800 Subject: [PATCH 312/324] Update sof-cnl-rt274 Update graph to represent actual layout Signed-off-by: Curtis Malainey --- topology/sof-cnl-rt274.m4 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/topology/sof-cnl-rt274.m4 b/topology/sof-cnl-rt274.m4 index d40efc142bb3..3a0bce0ac9af 100644 --- a/topology/sof-cnl-rt274.m4 +++ b/topology/sof-cnl-rt274.m4 @@ -20,9 +20,8 @@ include(`platform/intel/cnl.m4') # # Define the pipelines # -# PCM0 ----> volume -----> volume ----> SSP0 +# PCM0 <---> volume <---> SSP0 # -# PCM1 <---- Volume <---- SSP0 # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. From c1c68420369748fedf74a6cb2d94e5b19fa3dab1 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 16 Nov 2018 15:22:34 -0800 Subject: [PATCH 313/324] Update sof-glk-da7219 Update graph and comments Signed-off-by: Curtis Malainey --- topology/sof-glk-da7219.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/topology/sof-glk-da7219.m4 b/topology/sof-glk-da7219.m4 index 2132c130e683..0adcbcf6e7ab 100644 --- a/topology/sof-glk-da7219.m4 +++ b/topology/sof-glk-da7219.m4 @@ -1,5 +1,5 @@ # -# Topology for AppoloLake with headset on SSP2, spk on SSP1 and DMIC capture +# Topology for GeminiLake with Dialog7219. # # Include topology builder @@ -24,7 +24,7 @@ include(`platform/intel/dmic.m4') # # PCM0 ----> volume (pipe 1) -----> SSP1 (speaker - maxim98357a, BE link 0) # PCM1 <---> volume (pipe 2,3) <----> SSP2 (headset - da7219, BE link 1) -# PCM99 <---- volume (pipe 4) <----- DMIC0 (dmic capture, BE link 2) +# PCM99 <---- DMIC0 (dmic capture, BE link 2) # PCM5 ----> volume (pipe 5) -----> iDisp1 (HDMI/DP playback, BE link 3) # PCM6 ----> Volume (pipe 6) -----> iDisp2 (HDMI/DP playback, BE link 4) # PCM7 ----> volume (pipe 7) -----> iDisp3 (HDMI/DP playback, BE link 5) From 25e6b20f03d60f9fbb978b03a548db340787ea40 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 16 Nov 2018 15:24:32 -0800 Subject: [PATCH 314/324] Fix sof-apl-da7219 typo Signed-off-by: Curtis Malainey --- topology/sof-apl-da7219.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/topology/sof-apl-da7219.m4 b/topology/sof-apl-da7219.m4 index 0c102feaa98b..aaba865e005d 100644 --- a/topology/sof-apl-da7219.m4 +++ b/topology/sof-apl-da7219.m4 @@ -1,5 +1,5 @@ # -# Topology for AppoloLake with headset on SSP1, spk on SSP5 and DMIC capture +# Topology for ApolloLake with Dialog7219 codec. # # Include topology builder From 4194dae527d628efde6394ab40c19f373b862230 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 16 Nov 2018 15:27:33 -0800 Subject: [PATCH 315/324] Update sof-hsw-rt5640 Update comments and graph Signed-off-by: Curtis Malainey --- topology/sof-hsw-rt5640.m4 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/topology/sof-hsw-rt5640.m4 b/topology/sof-hsw-rt5640.m4 index 272cb154a7d0..5a5fbc1661fc 100644 --- a/topology/sof-hsw-rt5640.m4 +++ b/topology/sof-hsw-rt5640.m4 @@ -1,5 +1,5 @@ # -# Topology for generic Haswell board with no codec. +# Topology for generic Haswell board with RT5640. # # Include topology builder @@ -21,12 +21,12 @@ include(`platform/intel/hsw.m4') # Define the pipelines # # PCM0 ----> volume ---------------+ -# |--low latency mixer ----> volume ----> SSP2 -# PCM2 ----> SRC -----> volume ----+ +# |--low latency mixer ----> volume ----> SSP0 +# PCM1 -----> volume ----> SRC ----+ # | # Tone -----> volume ----+ # -# PCM1 <---- Volume <---- SSP0 +# PCM0 <---- Volume <---- SSP0 # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s32le. From d710f99de98b57619556db5aca36e367daeba6af Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Fri, 16 Nov 2018 15:28:47 -0800 Subject: [PATCH 316/324] Update sof-icl-nocodec Update graph Signed-off-by: Curtis Malainey --- topology/sof-icl-nocodec.m4 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/topology/sof-icl-nocodec.m4 b/topology/sof-icl-nocodec.m4 index 1dffe18c146e..5801b6febac3 100644 --- a/topology/sof-icl-nocodec.m4 +++ b/topology/sof-icl-nocodec.m4 @@ -20,9 +20,7 @@ include(`platform/intel/icl.m4') # # Define the pipelines # -# PCM0 ----> Volume ----> SSP0 -# -# PCM1 <---- Volume <---- SSP0 +# PCM0 <---> Volume <---> SSP0 (NoCodec) # # Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s24le. From ac7fb0060d5aeb02e0a8f2125114668e5efa33fb Mon Sep 17 00:00:00 2001 From: Bartosz Kokoszko Date: Mon, 19 Nov 2018 11:40:05 +0100 Subject: [PATCH 317/324] rmbox: removing rmbox fixes #127 Signed-off-by: Bartosz Kokoszko --- .gitignore | 4 +- Makefile.am | 2 +- configure.ac | 4 +- logger/Makefile.am | 9 ++ rmbox/logger_convert.c => logger/convert.c | 8 ++ {rmbox => logger}/convert.h | 4 - rmbox/rmbox.c => logger/logger.c | 25 +--- {rmbox => logger}/sof/uapi/abi.h | 0 {rmbox => logger}/sof/uapi/ipc.h | 0 {rmbox => logger}/sof/uapi/logging.h | 0 rmbox/Makefile.am | 20 --- rmbox/convert.c | 22 ---- rmbox/rmbox_convert.c | 143 --------------------- 13 files changed, 23 insertions(+), 218 deletions(-) create mode 100644 logger/Makefile.am rename rmbox/logger_convert.c => logger/convert.c (97%) rename {rmbox => logger}/convert.h (92%) rename rmbox/rmbox.c => logger/logger.c (94%) rename {rmbox => logger}/sof/uapi/abi.h (100%) rename {rmbox => logger}/sof/uapi/ipc.h (100%) rename {rmbox => logger}/sof/uapi/logging.h (100%) delete mode 100644 rmbox/Makefile.am delete mode 100644 rmbox/convert.c delete mode 100644 rmbox/rmbox_convert.c diff --git a/.gitignore b/.gitignore index 9771824e7581..27a4118a27e9 100644 --- a/.gitignore +++ b/.gitignore @@ -15,11 +15,9 @@ aclocal.m4 compile ltmain.sh rimage/rimage -rmbox/rmbox rwav/rwav *.tplg topology/*.conf topology/test/*.conf eqctl/sof-eqctl -rmbox/sof-logger -rmbox/sof-rmbox +logger/sof-logger diff --git a/Makefile.am b/Makefile.am index 6e2a1cac0028..da48543f1672 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = rmbox topology eqctl +SUBDIRS = logger topology eqctl TESTDIR = test/topology tests: diff --git a/configure.ac b/configure.ac index ed763c62fcde..829937a699b0 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ([2.69]) AC_INIT([sof-tools], [1.0.1]) AM_INIT_AUTOMAKE([foreign]) -AC_CONFIG_SRCDIR([rmbox/rmbox.c]) +AC_CONFIG_SRCDIR([logger/logger.c]) AC_CONFIG_SRCDIR([eqctl/eqctl.c]) AC_CONFIG_HEADERS([config.h]) AC_CHECK_HEADER([sof/uapi/abi.h]) @@ -18,7 +18,7 @@ AC_PROG_CC AC_OUTPUT([ Makefile - rmbox/Makefile + logger/Makefile eqctl/Makefile topology/Makefile topology/common/Makefile diff --git a/logger/Makefile.am b/logger/Makefile.am new file mode 100644 index 000000000000..b938dfd44b66 --- /dev/null +++ b/logger/Makefile.am @@ -0,0 +1,9 @@ +bin_PROGRAMS = sof-logger + +sof_logger_SOURCES = \ + logger.c \ + convert.c + +sof_logger_CFLAGS = \ + -Wall \ + -Werror diff --git a/rmbox/logger_convert.c b/logger/convert.c similarity index 97% rename from rmbox/logger_convert.c rename to logger/convert.c index 267e3e8c0c55..29f1e1b3147a 100644 --- a/rmbox/logger_convert.c +++ b/logger/convert.c @@ -62,6 +62,14 @@ struct ldc_entry { uint32_t *params; }; +static double to_usecs(uint64_t time, double clk) +{ + /* trace timestamp uses CPU system clock at default 25MHz ticks */ + // TODO: support variable clock rates + return (double)time / clk; +} + + static inline void print_table_header(FILE *out_fd) { fprintf(out_fd, "%5s %6s %12s %7s %16s %16s %24s\t%s\n", diff --git a/rmbox/convert.h b/logger/convert.h similarity index 92% rename from rmbox/convert.h rename to logger/convert.h index 488258f68fdd..16e3c3be7640 100644 --- a/rmbox/convert.h +++ b/logger/convert.h @@ -18,8 +18,6 @@ #define KNRM "\x1B[0m" #define KRED "\x1B[31m" -double to_usecs(uint64_t time, double clk); - struct convert_config { const char *out_file; const char *in_file; @@ -27,14 +25,12 @@ struct convert_config { FILE *in_fd; double clock; int trace; -#ifdef LOGGER_FORMAT const char *ldc_file; FILE* ldc_fd; int input_std; int version_fw; char *version_file; FILE *version_fd; -#endif }; int convert(struct convert_config *config); diff --git a/rmbox/rmbox.c b/logger/logger.c similarity index 94% rename from rmbox/rmbox.c rename to logger/logger.c index 55d6b4795eae..b888d01e19c5 100644 --- a/rmbox/rmbox.c +++ b/logger/logger.c @@ -20,11 +20,7 @@ #include #include "convert.h" -#ifdef LOGGER_FORMAT #define APP_NAME "sof-logger" -#else -#define APP_NAME "sof-rmbox" -#endif #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) @@ -39,12 +35,10 @@ static void usage(void) fprintf(stdout, "Usage %s \n", APP_NAME); fprintf(stdout, "%s:\t \t\t\tDisplay mailbox contents\n", APP_NAME); fprintf(stdout, "%s:\t -i infile -o outfile\tDump infile contents to outfile\n", APP_NAME); -#ifdef LOGGER_FORMAT fprintf(stdout, "%s:\t -l *.ldc_file\t\t*.ldc files generated by rimage\n", APP_NAME); fprintf(stdout, "%s:\t -p \t\t\tInput from stdin\n", APP_NAME); fprintf(stdout, "%s:\t -e \t\t\tEnable checking firmware version with default verification file\n", APP_NAME); fprintf(stdout, "%s:\t -v ver_file\t\tEnable checking firmware version with ver_file file\n", APP_NAME); -#endif fprintf(stdout, "%s:\t -c\t\t\tSet timestamp clock in MHz\n", APP_NAME); fprintf(stdout, "%s:\t -s\t\t\tTake a snapshot of state\n", APP_NAME); fprintf(stdout, "%s:\t -t\t\t\tDisplay trace data\n", APP_NAME); @@ -119,7 +113,6 @@ int main(int argc, char *argv[]) config.out_file = NULL; config.out_fd = NULL; config.in_fd = NULL; -#ifdef LOGGER_FORMAT config.ldc_file = NULL; config.ldc_fd = NULL; config.input_std = 0; @@ -127,13 +120,8 @@ int main(int argc, char *argv[]) config.version_file = NULL; config.version_fd = NULL; config.version_fw = 0; -#endif -#ifdef LOGGER_FORMAT while ((opt = getopt(argc, argv, "ho:i:l:ps:m:c:tev:")) != -1) { -#else - while ((opt = getopt(argc, argv, "ho:i:s:m:c:t")) != -1) { -#endif switch (opt) { case 'o': config.out_file = optarg; @@ -149,7 +137,6 @@ int main(int argc, char *argv[]) break; case 's': return snapshot(optarg); -#ifdef LOGGER_FORMAT case 'l': config.ldc_file = optarg; break; @@ -168,14 +155,11 @@ int main(int argc, char *argv[]) config.version_fw = 1; config.version_file = optarg; break; -#endif case 'h': default: /* '?' */ usage(); } } - -#ifdef LOGGER_FORMAT if (!config.ldc_file) { fprintf(stderr, "error: Missing ldc file\n"); @@ -199,7 +183,6 @@ int main(int argc, char *argv[]) goto out; } } -#endif if (config.out_file) { config.out_fd = fopen(config.out_file, "w"); @@ -221,12 +204,9 @@ int main(int argc, char *argv[]) if (!config.in_file) config.in_file = "/sys/kernel/debug/sof/etrace"; -#ifdef LOGGER_FORMAT if (config.input_std) { config.in_fd = stdin; - } else -#endif - { + } else { config.in_fd = fopen(config.in_file, "r"); if (!config.in_fd) { fprintf(stderr, "error: Unable to open in file %s\n", @@ -246,12 +226,11 @@ int main(int argc, char *argv[]) if (config.in_fd) fclose(config.in_fd); -#ifdef LOGGER_FORMAT if (config.ldc_fd) fclose(config.ldc_fd); + if (config.version_fd) fclose(config.version_fd); -#endif return ret; } diff --git a/rmbox/sof/uapi/abi.h b/logger/sof/uapi/abi.h similarity index 100% rename from rmbox/sof/uapi/abi.h rename to logger/sof/uapi/abi.h diff --git a/rmbox/sof/uapi/ipc.h b/logger/sof/uapi/ipc.h similarity index 100% rename from rmbox/sof/uapi/ipc.h rename to logger/sof/uapi/ipc.h diff --git a/rmbox/sof/uapi/logging.h b/logger/sof/uapi/logging.h similarity index 100% rename from rmbox/sof/uapi/logging.h rename to logger/sof/uapi/logging.h diff --git a/rmbox/Makefile.am b/rmbox/Makefile.am deleted file mode 100644 index 54819b2fceff..000000000000 --- a/rmbox/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ -bin_PROGRAMS = sof-rmbox sof-logger - -sof_rmbox_SOURCES = \ - rmbox.c \ - convert.c \ - rmbox_convert.c - -sof_logger_SOURCES = \ - rmbox.c \ - convert.c \ - logger_convert.c - -sof_rmbox_CFLAGS = \ - -Wall \ - -Werror - -sof_logger_CFLAGS = \ - -DLOGGER_FORMAT \ - -Wall \ - -Werror diff --git a/rmbox/convert.c b/rmbox/convert.c deleted file mode 100644 index c877c6cc1072..000000000000 --- a/rmbox/convert.c +++ /dev/null @@ -1,22 +0,0 @@ -/* -* debug log converter interface. -* -* Copyright (c) 2018, Intel Corporation. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -*/ -#include "convert.h" - -double to_usecs(uint64_t time, double clk) -{ - /* trace timestamp uses CPU system clock at default 25MHz ticks */ - // TODO: support variable clock rates - return (double)time / clk; -} diff --git a/rmbox/rmbox_convert.c b/rmbox/rmbox_convert.c deleted file mode 100644 index d47fab18eec3..000000000000 --- a/rmbox/rmbox_convert.c +++ /dev/null @@ -1,143 +0,0 @@ -/* -* debug log converter, using old rmbox format. -* -* Copyright (c) 2018, Intel Corporation. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -*/ - -#include -#include -#include -#include "convert.h" - -#define TRACE_BLOCK_SIZE 8 - -#define CASE(x) case(TRACE_CLASS_##x): trace = #x; break - -static void show_trace(FILE *out_fd, uint64_t val, uint64_t addr, - uint64_t *timestamp, double clk) -{ - const char *trace; - uint32_t class; - uint64_t delta = val - *timestamp; - double fdelta = to_usecs(delta, clk); - double us = 0.0f; - - /* timestamp or value ? */ - if ((addr % (TRACE_BLOCK_SIZE * 2)) == 0) { - - delta = val - *timestamp; - fdelta = to_usecs(delta, clk); - - /* 64-bit timestamp */ - us = to_usecs(val, clk); - - /* empty data ? */ - if (val == 0) { - *timestamp = 0; - return; - } - - /* detect wrap around */ - if (fdelta < 1000.0 * 1000.0 * 1000.0) - fprintf(out_fd, "0x%lx [%6.6f]\tdelta [%6.6f]\t", addr, - us / 1000000.0, fdelta / 1000000.0); - else - fprintf(out_fd, "0x%lx [%6.6f]\tdelta [********]\t", addr, - us / 1000000.0); - - *timestamp = val; - return; - } - else if (*timestamp == 0) - return; - - /* check for printable values - otherwise it's a value */ - if (!isprint((char)(val >> 16)) || !isprint((char)(val >> 8)) || !isprint((char)val)) { - fprintf(out_fd, "value 0x%16.16lx\n", val); - return; - } - - class = val & 0xff000000; - switch (class) - { - CASE(IRQ); - CASE(IPC); - CASE(PIPE); - CASE(HOST); - CASE(DAI); - CASE(DMA); - CASE(SSP); - CASE(COMP); - CASE(WAIT); - CASE(LOCK); - CASE(MEM); - CASE(MIXER); - CASE(BUFFER); - CASE(VOLUME); - CASE(SWITCH); - CASE(MUX); - CASE(SRC); - CASE(TONE); - CASE(EQ_FIR); - CASE(EQ_IIR); - CASE(SA); - CASE(DMIC); - CASE(POWER); - default: - fprintf(out_fd, "value 0x%8.8x\n", (uint32_t)val); - return; - } - - switch ((char)(val >> 16)) { - case 'e': - case 'E': - case 'x': - case 'X': - fprintf(out_fd, "%s%s %c%c%c%s\n", KRED, trace, - (char)(val >> 16), (char)(val >> 8), (char)val, KNRM); - break; - default: - fprintf(out_fd, "%s %c%c%c\n", trace, - (char)(val >> 16), (char)(val >> 8), (char)val); - break; - } -} - -int convert(struct convert_config *config) -{ - int count, i; - char c; - uint64_t tmp[TRACE_BLOCK_SIZE / sizeof(uint64_t)] = { 0 }; - uint64_t addr = 0, val, timestamp = 0; - - fprintf(stdout, "using %2.2fMHz timestamp clock\n", config->clock); - - while (1) { - count = fread(&tmp[0], 1, TRACE_BLOCK_SIZE, config->in_fd); - if (count != TRACE_BLOCK_SIZE) - break; - - val = *tmp; - for (i = 0; i < TRACE_BLOCK_SIZE / 2; i++) { - c = ((char *) tmp)[i]; - ((char *)tmp)[i] = - ((char *) tmp)[TRACE_BLOCK_SIZE - i - 1]; - ((char *)tmp)[TRACE_BLOCK_SIZE - i - 1] = c; - } - - show_trace(config->out_fd, val, addr, ×tamp, config->clock); - - addr += TRACE_BLOCK_SIZE; - } - - return 0; -} From 70227d6a8925203d701dd0ebc16b7fa16cfcfa6d Mon Sep 17 00:00:00 2001 From: Michal Jerzy Wierzbicki Date: Mon, 19 Nov 2018 16:17:57 +0100 Subject: [PATCH 318/324] Coredumper: initial Added tool to process coredumps, and to feed gdb commands to examine what caused the dump. Signed-off-by: Michal Jerzy Wierzbicki --- coredumper/sof-coredump-reader.py | 569 ++++++++++++++++++++++++++++++ coredumper/sof-coredump-to-gdb.sh | 18 + 2 files changed, 587 insertions(+) create mode 100755 coredumper/sof-coredump-reader.py create mode 100755 coredumper/sof-coredump-to-gdb.sh diff --git a/coredumper/sof-coredump-reader.py b/coredumper/sof-coredump-reader.py new file mode 100755 index 000000000000..33aa628e5b68 --- /dev/null +++ b/coredumper/sof-coredump-reader.py @@ -0,0 +1,569 @@ +#!/usr/bin/env python3 + +# Tool for processing FW stack dumps. +# For more detailed useage, use --help option. + +from __future__ import print_function +import argparse +import struct +import os +import sys +import itertools +import re +import shutil +from ctypes import LittleEndianStructure, BigEndianStructure, c_uint32, c_char +from collections import namedtuple +from operator import attrgetter +from functools import partial + +def stderr_print(*args, **kwargs): + print(*args, file=sys.stderr, **kwargs) + +try: + from sty import fg, bg, ef, rs, Rule, Render + CAN_COLOUR=True +except ImportError: + CAN_COLOUR=False + +ArchDefinition = namedtuple('ArchDefinition', ['name', 'bitness', 'endianness']) +VALID_ARCHS = {} +[VALID_ARCHS.update({archdef.name : archdef}) + for archdef in [ArchDefinition(*tup) for tup in + [ + ( 'LE32bit', + 32, + LittleEndianStructure, ), + ( 'LE64bit', + 64, + LittleEndianStructure, ), +# ( 'BE32bit', #untested, treat as not implemented +# 32, +# BigEndianStructure, ), +# ( 'BE64bit', #untested, treat as not implemented +# 64, +# BigEndianStructure, ), + ]] +] + +def valid_archs_print(): + archs = ''.join("{0}, ".format(x) for x in VALID_ARCHS) + archs = archs[:len(archs)-2] + return "{0}.".format(archs) + +TERM_SIZE = shutil.get_terminal_size((120, 20)) +AR_WINDOW_WIDTH = 4 +IS_COLOUR=False + +class argparse_readable_file( argparse.Action): + def raise_error(self, filepath, reason): + raise argparse.ArgumentTypeError( + "is_readable_file:{0} {1}".format( + filepath, + reason + )) + def is_readable_file(self, filepath): + if not os.path.isfile(filepath): + self.raise_error(filepath, "is not a valid path") + if os.access(filepath, os.R_OK): + return True + else: + self.raise_error(filepath, "is not a readable file") + return False + def __call__(self, parser, namespace, values, option_string=None): + filepath = values[0] + if (self.is_readable_file(filepath)): + setattr(namespace, self.dest, filepath) + +class argparse_writeable_file(argparse.Action): + def raise_error(self, filepath, reason): + raise argparse.ArgumentTypeError( + "is_writeable_file:{0} {1}".format( + filepath, + reason + )) + def is_writeable_file(self, filepath): + absdir = os.path.abspath(os.path.dirname(filepath)) + if os.path.isdir(absdir) and not os.path.exists(filepath): + return True + else: + if not os.path.isfile(filepath): + self.raise_error(filepath, "is not a valid path") + if os.access(filepath, os.W_OK): + return True + else: + self.raise_error(filepath, "is not a writeable file") + return False + def __call__(self, parser, namespace, values, option_string=None): + filepath = values[0] + if (self.is_writeable_file(filepath)): + setattr(namespace, self.dest, filepath) + else: + self.raise_error( + filepath, + "failed to determine whether file is writeable" + ) + +class argparse_architecture( argparse.Action): + def raise_error(self, value, reason): + raise argparse.ArgumentTypeError( + "architecture: {0} {1}".format( + value, + reason + )) + def is_valid_architecture(self, value): + if value in VALID_ARCHS: + return True + return False + def __call__(self, parser, namespace, values, option_string=None): + value = values[0] + if (self.is_valid_architecture(value)): + setattr(namespace, self.dest, VALID_ARCHS[value]) + else: + self.raise_error( + value, + "is invalid architecture. Valid architectures are: {0}".format(valid_archs_print()) + ) + +def parse_params(): + parser = argparse.ArgumentParser( + description="Tool for processing FW stack dumps." + +" In verbose mode it prints DSP registers, and function call" + +" addresses in stack up to that which caused core dump." + +" It then prints either to file or to stdin all gdb" + +" commands unwrapping those function call addresses to" + +" function calls in human readable format." + ) + ArgTuple = namedtuple('ArgTuple', ['name', 'optionals', 'parent']) + ArgTuple.__new__.__defaults__ = ((), {}, parser) + + # below cannot be empty once declared + outputMethod = parser.add_mutually_exclusive_group(required=True) + inputMethod = parser.add_mutually_exclusive_group() + [parent.add_argument(*name, **optionals) + for name, optionals, parent in sorted([ArgTuple(*x) for x in + [ + ( ( '-a', '--arch' , ), { + 'type' : str, + 'help' :'determine architecture of dump file; valid archs are: {0}' + .format(valid_archs_print()), + 'action' : argparse_architecture, + 'nargs' : 1, + 'default': VALID_ARCHS['LE64bit'], + },), + ( ( '-v', '--verbose' , ), { + 'help' :'increase output verbosity', + 'action':'store_true', + },), + ( ( '--stdin' , ), { + 'help' :'input is from stdin', + 'action' : 'store_true', + }, + inputMethod), + ( ( '-o', '--outfile' , ), { + 'type' : str, + 'help' :'output is to FILE', + 'action' : argparse_writeable_file, + 'nargs' : 1, + }, + outputMethod), + ( ( '--stdout' , ), { + 'help' :'output is to stdout', + 'action' :'store_true', + }, + outputMethod), + ( ( '-c', '--colour', ), { + 'help' :'set output to be colourful!', + 'action':'store_true', + },), + ( ( '-l', '--columncount', ), { + 'type' : int, + 'help' :'set how many colums to group the output in', + 'action':'store', + 'nargs' : 1, + },), + # below makes it impossible to have input file while getting stdin from pipe + ] + ([] if not sys.stdin.isatty() else [ + ( ( '-i', '--infile' , ), { + 'type' : str, + 'help' :'path to sys dump bin', + 'action' : argparse_readable_file, + 'nargs' : 1, + }, + inputMethod), + ])], + key=lambda argtup: (argtup.parent.__hash__(), argtup.name) + ) + ] + + parsed = parser.parse_args() + if not sys.stdin.isatty(): + parsed.stdin = True + + return parsed + +def chunks(l, n): + return [l[i:i + n] for i in range(0, len(l), n)] + +def flaten(l): + return [item for sublist in l for item in sublist] + +def raiseIfArchNotValid(arch): + if arch not in VALID_ARCHS.values(): + raise ValueError( + "CoreDumpFactory: {0} not in valid architectures: {1}" + .format(arch, valid_archs_print()) + ) + endiannesses = [arch.endianness for arch in VALID_ARCHS.values()] + if arch.endianness not in endiannesses: + raise ValueError( + "CoreDumpFactory: {0} not in valid endiannesses: {1}" + .format(endianness, endiannesses) + ) + +def FileInfoFactory(arch, filename_length): + raiseIfArchNotValid(arch) + class FileInfo(arch.endianness): + _fields_ = [ + ("filename", filename_length * c_char), + ("line_no", c_uint32) + ] + def __str__(self): + return "{}:{:d}".format(self.filename.decode(), self.line_no) + if FileInfo is None: + raise RuntimeError( + "FileInfoFactory: failed to produce FileInfo({0})" + .format(arch.name) + ) + return FileInfo + +class Colorer(): + #TODO: Add detection of 8bit/24bit terminal + # Add 8bit/24bit colours (with flag, maybe --colour=24bit) + # Use this below as fallback only + __print = partial(stderr_print) + __style = { + 'o' : fg.red, + 'O' : fg.yellow, + 'y' : fg.blue, + 'Y' : fg.cyan, + 'D' : fg.white + bg.red, + } + def __init__(self): + self.matchings = [ + ( + lambda x: self.enstyleNumHex(x.group()), + re.compile(r'\b([a-f0-9]{8})\b') + ), + ( + lambda x: self.enstyleNumBin(x.group()), + re.compile(r'\b(b[01]+)\b') + ), + ( + r'\1' + + r'\2' + + self.enstyle( fg.green , r'\3') , + re.compile(r'(\|)(ar)([0-9]+)\b') + ), + ( + self.enstyle(bg.green + fg.black , r'\1') + + r'\2' + + self.enstyle( fg.green , r'\3') , + re.compile(r'(\#)(ar)([0-9]+)\b') + ), + ] + + def toGroup(self, txt): + return [ (label, sum(1 for _ in group)) + for label, group in itertools.groupby(txt) ] + + def leadingZero(self, txt, char): + result = "" + groups = self.toGroup(txt) + lead = 0 + if groups[0][0] == '0': + lead = min(4, groups[0][1]) + result += char.lower() * lead + result += char.upper() * (4-lead) + return result + + def findSub(self, txt, mask, sub, char): + pos = txt.find(sub) + if pos >= 0: + return mask[:pos] + char * len(sub) + mask[(len(sub)+pos):] + else: + return mask + + def enstyleNumBin(self, txt): + result = rs.all + bg.magenta + "b" + prev = "" + for c in txt[1:]: + if prev != c: + prev = c + result += rs.all + if c == "0": + result += fg.red + result += c + result += rs.all + return result + + def enstyleNumHex(self, txt): + p1 = 'o' + p2 = 'y' + if txt == "00000000": + styleMask = p1 * 8 + elif txt.lower() == "deadbeef": + styleMask = "DDDDDDDD" + else: + styleMask = "".join( + [self.leadingZero(string, style) + for string, style in [ + (txt[:4], p1), + (txt[4:], p2), + ]]) + styleMask = "".join( + [self.findSub(txt, styleMask, string, style) + for string, style in [ + ('dead', 'D'), + ]]) + + result = "" + thisstyle = '' + for iter, style in enumerate(styleMask): + if thisstyle != style: + thisstyle = style + result += rs.all + self.__style[thisstyle] + result += txt[iter] + result += rs.all + return result + + def enstyle(self, style, txt): + return style + txt + rs.all + + def print(self, word): + result = word + for repl, regex in self.matchings: + result = re.sub(regex, repl, result) + self.__print(result) + +def CoreDumpFactory(arch): + raiseIfArchNotValid(arch) + class CoreDump(arch.endianness): + _fields_ = [(x, c_uint32) for x in + [ + "exccause", + "excvaddr", + "ps" + ] + + ["epc" + str(x) for x in range(1,7+1)] + + ["eps" + str(x) for x in range(2,7+1)] + + [ + "depc", + "intenable", + "interrupt", + "sar", + "debugcause", + "windowbase", + "windowstart", + "excsave1" # to + ] + ] + [ + ("a", arch.bitness * c_uint32) + ] + + def __init__(self, columncount): + self.arch = arch + self._fields_ + # below: smart column count + self._longest_field = len(max([x[0] for x in self._fields_], key=len)) + if columncount is not None: + self.columncount = max (1, int(columncount[0])) + else: + self.columncount = max(1, + int(TERM_SIZE[0]/(self._longest_field + 2 + 2 * AR_WINDOW_WIDTH + 2)) + ) + self.columncount_ar = ( + self.columncount + if self.columncount <= AR_WINDOW_WIDTH else + AR_WINDOW_WIDTH * int(self.columncount/AR_WINDOW_WIDTH) + ) + + def __windowbase_shift(self, iter, direction): + return (iter + self.windowbase * AR_WINDOW_WIDTH * direction) % self.arch.bitness + def windowbase_shift_left(self, iter): + return self.__windowbase_shift(iter, -1) + def windowbase_shift_right(self, iter): + return self.__windowbase_shift(iter, 1) + + def reg_from_string(self, string): + if string.startswith("ar"): + return self.a[self.windowbase_shift_left(int(string[2:]))] + else: + return self.__getattribute__(string) + + def __str__(self): + string = "" + string += "exccause" + return string + + def to_string(self, is_gdb): + # flatten + chunk enable to smartly print in N columns + string = ''.join([self.fmt(is_gdb, x) + for x in flaten( + [chunks(word, self.columncount) for word in [ + ["exccause", "excvaddr","ps"], + ["epc" + str(x) for x in range(1,7+1)], + ["eps" + str(x) for x in range(2,7+1)], + ["depc", "intenable", "interrupt", "sar", "debugcause"], + ["windowbase", "windowstart"], + ["excsave1"], + ]] +\ + [chunks(word, self.columncount_ar) for word in [ + ["ar" + str(x) for x in itertools.chain( + range( self.windowbase * AR_WINDOW_WIDTH, self.arch.bitness), + range(0, self.windowbase * AR_WINDOW_WIDTH), + )] + ]] + ) + ]) + if not is_gdb: + string += "\n" + return string + + def fmt_gdb_command(self): + return "set ${}=0x{:08x}\n" + + def fmt_pretty_form(self, separator = "|"): + return separator + "{:" + str(self._longest_field) + "} {:08x} " + + def fmt_separator(self, name): + separator = "|" + if name.startswith("ar") and int(name[2:]) % AR_WINDOW_WIDTH == 0 : + separator = "#" + return separator + + def fmt_pretty_auto(self, name): + return self.fmt_pretty_form(self.fmt_separator(name)) + + def fmt(self, is_gdb, names): + if is_gdb: + fmtr = lambda name: self.fmt_gdb_command() + else: + fmtr = lambda name: self.fmt_pretty_auto(name) + + string = "" + for name in names: + string += fmtr(name).format( + name, self.reg_from_string(name) + ) + if not is_gdb: + string += "\n" + return string + + def windowstart_process(self): + string = "" + binary = "b{0:b}".format(self.windowstart) + fnc_num = 0 + header = " " + for it, c in enumerate(binary[1:]): + if c != "0": + header += str(fnc_num) + fnc_num += 1 + else: + header += " " + string += " {0}\n".format(header) + string += "windowstart: {0}\n".format(binary) + + fnc_num = 0 + for iter, digit in enumerate(binary[1:]): + if (digit == '1'): + reg = "ar{0}".format( + self.windowbase_shift_right(AR_WINDOW_WIDTH * iter) + ) + string += "{0:2d} ".format(++fnc_num) + string += self.fmt_pretty_auto(reg).format( + reg, self.reg_from_string(reg) + ) + "\n" + fnc_num += 1 + return string + + if CoreDump is None: + raise RuntimeError( + "CoreDumpFactory: failed to produce CoreDump({0})" + .format(arch.name) + ) + return CoreDump + +class CoreDumpReader(object): + def __init__(self, args): + self.core_dump = CoreDumpFactory(args.arch)( + args.columncount + ) + self.file_info = FileInfoFactory(args.arch, 32)() + + if args.verbose: + if IS_COLOUR: + colorer = Colorer() + verbosePrint = colorer.print + else: + verbosePrint = stderr_print + else: + verbosePrint = lambda *discard_this: None + + if args.stdout: + stdoutPrint = print + stdoutClose = lambda : None + else: + outFile = open(args.outfile, "w") + stdoutPrint = outFile.write + stdoutClose = outFile.close + + if args.stdin or not sys.stdin.isatty(): + inStream = lambda : sys.stdin.buffer + else: + inStream = lambda : open(args.infile, "rb") + + with inStream() as cd_file: + [cd_file.readinto(x) for x in [ + self.core_dump, + self.file_info + ]] + self.stack = cd_file.read() + + verbosePrint(self.core_dump.to_string(0)) + + verbosePrint(self.core_dump.windowstart_process()) + + verbosePrint("Location: " + str(self.file_info)); + stack_base = self.core_dump.a[1] + 16 + stack_dw_num = int(len(self.stack)/AR_WINDOW_WIDTH) + verbosePrint("Stack dumped from {:08x} dwords num {:d}" + .format(stack_base, stack_dw_num)) + + stdoutPrint("break *0xbefe0000\nrun\n") + stdoutPrint(self.core_dump.to_string(1)) + + #TODO: make this elegant + for dw, addr in [( + struct.unpack("I", self.stack[i*AR_WINDOW_WIDTH : (i+1)*AR_WINDOW_WIDTH])[0], + stack_base + i*AR_WINDOW_WIDTH + ) for i in range(0, stack_dw_num)]: + stdoutPrint("set *0x{:08x}=0x{:08x}\n" + .format(addr, dw)) + + # TODO: if excsave1 is not empty, pc should be set to that value + # (exception mode, not forced panic mode) + # dodac sobie przyklad + # ustawiac pc z + stdoutPrint("set $pc=&arch_dump_regs_a\nbacktrace\n") + + stdoutClose() + +if __name__ == "__main__": + args = parse_params() + if args.colour: + if CAN_COLOUR: + IS_COLOUR=True + else: + stderr_print("Cannot color the output: module 'sty' not found!") + CoreDumpReader(args) + diff --git a/coredumper/sof-coredump-to-gdb.sh b/coredumper/sof-coredump-to-gdb.sh new file mode 100755 index 000000000000..a35c86f245d0 --- /dev/null +++ b/coredumper/sof-coredump-to-gdb.sh @@ -0,0 +1,18 @@ +#!/bin/bash +# Exemplatory usage of sof-coredump-reader.py ($reader_name) +# We read from dump file into sof-coredump-reader.py, then we pipe its output +# to xt-gdb, which operates on given elf-file. + +THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" +elf="${1}" +dump="${2}" + +reader_name="sof-coredump-reader.py" # in case it is changed +reader_output="$(${THIS_SCRIPT_DIR}/${reader_name} -vc -i ${dump} --stdout -l 4)" +reader_result="$?" # if $reader_name script fails, running xt-gdb is pointless +if [[ ${reader_result} -ne 0 ]] ; then + echo "${reader_name} failed!" + exit ${reader_result} +else + xt-gdb "${elf}" < <(echo "${reader_output}") +fi From 7e2f4e3b9c373fc621cd4bf00787ccb270925832 Mon Sep 17 00:00:00 2001 From: Mengdong Lin Date: Tue, 20 Nov 2018 19:28:48 -0500 Subject: [PATCH 319/324] topology: Remove sof-apl-hdmi.m4 sof-apl-hdmi.m4 is no longer needed. It was used in early stage of HDA enablement as the 1st reference. Now HDA settings are added to UP2/GLK/WHL platform m4 files. Signed-off-by: Mengdong Lin --- topology/Makefile.am | 1 - topology/sof-apl-hdmi.m4 | 93 ---------------------------------------- 2 files changed, 94 deletions(-) delete mode 100644 topology/sof-apl-hdmi.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index d6809f1993b8..44b8a5964b36 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -19,7 +19,6 @@ DEPS = \ MACHINES = \ sof-cht-nocodec.tplg \ sof-cht-max98090.tplg \ - sof-apl-hdmi.tplg \ sof-whl-hda.tplg \ sof-hda-generic.tplg \ sof-apl-nocodec.tplg \ diff --git a/topology/sof-apl-hdmi.m4 b/topology/sof-apl-hdmi.m4 deleted file mode 100644 index 00d7c68687dd..000000000000 --- a/topology/sof-apl-hdmi.m4 +++ /dev/null @@ -1,93 +0,0 @@ -# -# Topology for generic Apollolake board with no codec. -# - -# Include topology builder -include(`utils.m4') -include(`dai.m4') -include(`hda.m4') -include(`ssp.m4') -include(`pipeline.m4') - -# Include TLV library -include(`common/tlv.m4') - -# Include Token library -include(`sof/tokens.m4') - -# Include Apollolake DSP configuration -include(`platform/intel/bxt.m4') - -# -# Define the pipelines -# -# PCM0 ----> volume -----> iDisp1 -# PCM1 ----> Volume -----> iDisp2 -# PCM2 ----> volume -----> iDisp3 - -dnl PIPELINE_PCM_ADD(pipeline, -dnl pipe id, pcm, max channels, format, -dnl frames, deadline, priority, core) - -# Low Latency playback pipeline 1 on PCM 0 using max 2 channels of s16le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, - 1, 0, 2, s16le, - 48, 1000, 0, 0) - -# Low Latency playback pipeline 2 on PCM 1 using max 2 channels of s16le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, - 2, 1, 2, s16le, - 48, 1000, 0, 0) - -# Low Latency playback pipeline 3 on PCM 2 using max 2 channels of s16le. -# Schedule 48 frames per 1000us deadline on core 0 with priority 0 -PIPELINE_PCM_ADD(sof/pipe-volume-playback.m4, - 3, 2, 2, s16le, - 48, 1000, 0, 0) - -# -# DAIs configuration -# - -dnl DAI_ADD(pipeline, -dnl pipe id, dai type, dai_index, dai_be, -dnl buffer, periods, format, -dnl frames, deadline, priority, core) - -# playback DAI is iDisp1 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 1, HDA, 0, iDisp1, - PIPELINE_SOURCE_1, 2, s16le, - 48, 1000, 0, 0) - -# playback DAI is iDisp2 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 2, HDA, 1, iDisp2, - PIPELINE_SOURCE_2, 2, s16le, - 48, 1000, 0, 0) - -# playback DAI is iDisp3 using 2 periods -# Buffers use s16le format, with 48 frame per 1000us on core 0 with priority 0 -DAI_ADD(sof/pipe-dai-playback.m4, - 3, HDA, 2, iDisp3, - PIPELINE_SOURCE_3, 2, s16le, - 48, 1000, 0, 0) - - -dnl PCM_PLAYBACK_ADD(name, pcm_id, playback) -PCM_PLAYBACK_ADD(HDMI1, 0, PIPELINE_PCM_1) -PCM_PLAYBACK_ADD(HDMI2, 1, PIPELINE_PCM_2) -PCM_PLAYBACK_ADD(HDMI3, 2, PIPELINE_PCM_3) - -# -# BE configurations - overrides config in ACPI if present -# - -dnl HDA_DAI_CONFIG(dai_index, link_id, name) -HDA_DAI_CONFIG(0, 1, iDisp1) -HDA_DAI_CONFIG(1, 2, iDisp2) -HDA_DAI_CONFIG(2, 3, iDisp3) From 093f6b70daf705f3441d61ecac16f3a8086ea038 Mon Sep 17 00:00:00 2001 From: Zhang Keqiao Date: Wed, 21 Nov 2018 16:06:21 +0800 Subject: [PATCH 320/324] topology: add 4-ch dmic topology for ICL Signed-off-by: Zhang Keqiao --- topology/Makefile.am | 3 +- topology/sof-icl-dmic-4ch.m4 | 68 ++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 topology/sof-icl-dmic-4ch.m4 diff --git a/topology/Makefile.am b/topology/Makefile.am index d6809f1993b8..14b9786a8a77 100644 --- a/topology/Makefile.am +++ b/topology/Makefile.am @@ -42,7 +42,8 @@ MACHINES = \ sof-apl-eq-pcm512x.tplg \ sof-apl-eq-dmic.tplg \ sof-apl-dmic-2ch.tplg \ - sof-apl-dmic-4ch.tplg + sof-apl-dmic-4ch.tplg \ + sof-icl-dmic-4ch.tplg # Uncomment the following line if you want to debug conf files diff --git a/topology/sof-icl-dmic-4ch.m4 b/topology/sof-icl-dmic-4ch.m4 new file mode 100644 index 000000000000..24bbd845bbfa --- /dev/null +++ b/topology/sof-icl-dmic-4ch.m4 @@ -0,0 +1,68 @@ +# +# Topology for ICL Lake with direct attach digital microphones array +# + +# Include topology builder +include(`utils.m4') +include(`dai.m4') +include(`pipeline.m4') + +# Include TLV library +include(`common/tlv.m4') + +# Include Token library +include(`sof/tokens.m4') + +# Include Apollolake DSP configuration +include(`platform/intel/bxt.m4') +include(`platform/intel/dmic.m4') + +# +# Define the pipelines +# +# PCM6 <---- volume <----- DMIC01 (dmic0 capture) +# + +dnl PIPELINE_PCM_ADD(pipeline, +dnl pipe id, pcm, max channels, format, +dnl frames, deadline, priority, core) + + +# Passthrough capture pipeline 1 on PCM 1 using max 4 channels. +# Schedule 48 frames per 1000us deadline on core 0 with priority 0 +PIPELINE_PCM_ADD(sof/pipe-passthrough-capture.m4, + 1, 1, 4, s32le, + 48, 1000, 0, 0) + +# +# DAIs configuration +# + +dnl DAI_ADD(pipeline, +dnl pipe id, dai type, dai_index, dai_be, +dnl buffer, periods, format, +dnl frames, deadline, priority, core) + + +# capture DAI is DMIC 0 using 2 periods +# Buffers use s32le format, with 48 frame per 1000us on core 0 with priority 0 +DAI_ADD(sof/pipe-dai-capture.m4, + 1, DMIC, 0, dmic01, + PIPELINE_SINK_1, 2, s32le, + 48, 1000, 0, 0) + +dnl PCM_DUPLEX_ADD(name, pcm_id, playback, capture) + +dnl PCM_CAPTURE_ADD(name, pipeline, capture) +PCM_CAPTURE_ADD(DMIC01, 1, PIPELINE_PCM_1) + +# +# BE configurations - overrides config in ACPI if present +# + +dnl DAI_CONFIG(type, dai_index, link_id, name, ssp_config/dmic_config) + +DAI_CONFIG(DMIC, 0, 1, dmic01, + DMIC_CONFIG(1, 500000, 4800000, 40, 60, 48000, + DMIC_WORD_LENGTH(s32le), DMIC, 0, + PDM_CONFIG(DMIC, 0, FOUR_CH_PDM0_PDM1))) From 044077cb86d38fe349ba44318c6c7aaf99716e33 Mon Sep 17 00:00:00 2001 From: Michal Jerzy Wierzbicki Date: Tue, 20 Nov 2018 12:10:46 +0100 Subject: [PATCH 321/324] shell-scripts: human-readable preprocessor output Added script I used to read preprocessor output during preprocessor metaprogramming development. Normally it is highly unreadable, this tool makes things a wee bit easier. Signed-off-by: Michal Jerzy Wierzbicki --- scripts/pretty-macro.sh | 123 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100755 scripts/pretty-macro.sh diff --git a/scripts/pretty-macro.sh b/scripts/pretty-macro.sh new file mode 100755 index 000000000000..c01b4453dfcb --- /dev/null +++ b/scripts/pretty-macro.sh @@ -0,0 +1,123 @@ +#!/bin/bash +# Simple script for printing preprocessor output in human-readable fashion +# Mostly useful for debugging macro metaprogramming +# For more detailed useage, use --h option. +enstyle(){ + awk \ + -v style="${1}" \ + -v regex="${2}" \ +'{\ + gsub(\ + regex,\ + "\033["style"m&\033[0m"\ + );\ + print;\ +}' +} +styleUserRegexp() +{ + if [[ "${USER_REGEXP}" != "" ]] ; then + enstyle "7;33" "${USER_REGEXP}" + else + tee # pipe that does nothing, just pass input to output + fi +} +styleAll(){ + if [[ "${COLORISE}" == "1" ]] ; then + enstyle "33" '[{}()\\[\\],;]'\ + | enstyle "1;31" '->|\\.|&'\ + | enstyle "1;35" '\\s(if|while|do|for|return|exit|panic)'\ + | enstyle "1;36" '(u?int(32|64)_t|void|struct|const|char|volatile|static|unsigned|long)\\s*\\**'\ + | enstyle "32" '0x[A-Za-z0-9]+'\ + | styleUserRegexp + else + tee # pipe that does nothing, just pass input to output + fi +} + +pretty_macro(){ + params="${1}" + infile="${2}" + + gcc_params="${params} -E -dD ${infile}" + if [[ "${SHOW_ERR}" == "0" ]] ; then + gcc_params+=" 2>/dev/null" + fi + cmd="gcc ${gcc_params}" + if [[ "${VERBOSE}" == "1" ]] ; then + echo "params are: [${params}]" + echo "infile is: [${infile}]" + echo "cmd is: [${cmd}]" + fi + + bash -c "$cmd" \ + | sed\ + -e 's/;\ /;\n\t/g'\ + -e 's/{\ /\n{\n\t/g'\ + -e 's/}[\ ]*/\n}\n/g'\ + | styleAll +} + +VERBOSE=0 +SHOW_ERR=0 +COLORISE=0 +gcc_params="" +USER_REGEXP="" +while getopts ":f:I:u:hevc" opt; do + case ${opt} in + h) #usage + echo \ +"usage: $0 [-hevc] (-f IN_FILE) [-I INCLUDE_DIR] [-u USER_REGEXP] + +Expands c macroes in files given with -f flag and prints them prettily. + +mandatory arguments: + -f IN_FILE input file to gcc +optional arguments: + -h show this help message and exit + -e don't redirect gcc errors to /dev/null + -v show verbose output + -c color the output + -u USER_REGEXP highlights user defined regular expression + -I INCLUDE_DIR pass INCLUDE_DIR to gcc with -I option +" + exit 0 + ;; + u) + USER_REGEXP="${OPTARG}" + ;; + e) + SHOW_ERR=1 + ;; + v) + VERBOSE=1 + ;; + c) + COLORISE=1 + ;; + I) + gcc_params+=" -I ${OPTARG}" + ;; + f) + infiles+=("${OPTARG}") + ;; + \?) + echo "Invalid option: -${OPTARG}" >&2 + exit 1 + ;; + :) + echo "Option -${OPTARG} requires an argument." >&2 + exit 1 + ;; + esac +done +if [[ "${VERBOSE}" == "1" ]] ; then + echo "gcc_params are: [${gcc_params}]" + echo "infiles are: [${infiles[@]}]" + echo "user regexp is: [${USER_REGEXP}]" +fi +for file in ${infiles[@]} ; do + pretty_macro "${gcc_params}" "${file}" +done +exit 0 + From 5b5888ce075d3ab6e72f38be3a0bde4c0040b378 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 24 Nov 2018 23:24:36 -0800 Subject: [PATCH 322/324] Move SOFT into sub folder for SOF merge Signed-off-by: Curtis Malainey --- .gitignore => tools/.gitignore | 0 .travis.yml => tools/.travis.yml | 0 Makefile.am => tools/Makefile.am | 0 README => tools/README | 0 autogen.sh => tools/autogen.sh | 0 configure.ac => tools/configure.ac | 0 {coredumper => tools/coredumper}/sof-coredump-reader.py | 0 {coredumper => tools/coredumper}/sof-coredump-to-gdb.sh | 0 {eqctl => tools/eqctl}/Makefile.am | 0 {eqctl => tools/eqctl}/README | 0 {eqctl => tools/eqctl}/eq_fir_flat.txt | 0 {eqctl => tools/eqctl}/eq_fir_loudness.txt | 0 {eqctl => tools/eqctl}/eq_fir_mid.txt | 0 {eqctl => tools/eqctl}/eq_iir_bandpass.txt | 0 {eqctl => tools/eqctl}/eq_iir_bassboost.txt | 0 {eqctl => tools/eqctl}/eq_iir_flat.txt | 0 {eqctl => tools/eqctl}/eq_iir_loudness.txt | 0 {eqctl => tools/eqctl}/eqctl.c | 0 {kmod_scripts => tools/kmod_scripts}/sof_bootloop.sh | 0 {kmod_scripts => tools/kmod_scripts}/sof_bootone.sh | 0 {kmod_scripts => tools/kmod_scripts}/sof_insert.sh | 0 {kmod_scripts => tools/kmod_scripts}/sof_remove.sh | 0 {logger => tools/logger}/Makefile.am | 0 {logger => tools/logger}/convert.c | 0 {logger => tools/logger}/convert.h | 0 {logger => tools/logger}/logger.c | 0 {logger => tools/logger}/sof/uapi/abi.h | 0 {logger => tools/logger}/sof/uapi/ipc.h | 0 {logger => tools/logger}/sof/uapi/logging.h | 0 {rimage => tools/rimage}/keys/Makefile.am | 0 {rimage => tools/rimage}/keys/README | 0 {rimage => tools/rimage}/keys/otc_private_key.pem | 0 {rimage => tools/rimage}/keys/otc_public_key.pem | 0 {scripts => tools/scripts}/pretty-macro.sh | 0 {test => tools/test}/audio/README | 0 {test => tools/test}/audio/src_run.sh | 0 {test => tools/test}/audio/src_test.m | 0 {test => tools/test}/audio/src_test.sh | 0 {test => tools/test}/audio/src_test_top.m | 0 {test => tools/test}/audio/std_utils/aap_test_input.m | 0 {test => tools/test}/audio/std_utils/aap_test_measure.m | 0 {test => tools/test}/audio/std_utils/aip_test_input.m | 0 {test => tools/test}/audio/std_utils/aip_test_measure.m | 0 {test => tools/test}/audio/std_utils/dr_test_input.m | 0 {test => tools/test}/audio/std_utils/dr_test_measure.m | 0 {test => tools/test}/audio/std_utils/fr_test_input.m | 0 {test => tools/test}/audio/std_utils/fr_test_measure.m | 0 {test => tools/test}/audio/std_utils/g_test_input.m | 0 {test => tools/test}/audio/std_utils/g_test_measure.m | 0 {test => tools/test}/audio/std_utils/level_dbfs.m | 0 {test => tools/test}/audio/std_utils/stdhpf.m | 0 {test => tools/test}/audio/std_utils/stdhpf_get.m | 0 {test => tools/test}/audio/std_utils/stdlpf.m | 0 {test => tools/test}/audio/std_utils/stdlpf_get.m | 0 {test => tools/test}/audio/std_utils/stdnotch.m | 0 {test => tools/test}/audio/std_utils/stdnotch_get.m | 0 {test => tools/test}/audio/std_utils/stdweight.m | 0 {test => tools/test}/audio/std_utils/thdnf_test_input.m | 0 {test => tools/test}/audio/std_utils/thdnf_test_measure.m | 0 {test => tools/test}/audio/test_utils/chirp_test_analyze.m | 0 {test => tools/test}/audio/test_utils/chirp_test_input.m | 0 {test => tools/test}/audio/test_utils/delete_check.m | 0 {test => tools/test}/audio/test_utils/dither_and_quantize.m | 0 {test => tools/test}/audio/test_utils/find_test_signal.m | 0 {test => tools/test}/audio/test_utils/load_test_output.m | 0 {test => tools/test}/audio/test_utils/mix_chirp.m | 0 {test => tools/test}/audio/test_utils/mix_sweep.m | 0 {test => tools/test}/audio/test_utils/mkdir_check.m | 0 {test => tools/test}/audio/test_utils/mls_calc_resp.m | 0 {test => tools/test}/audio/test_utils/multitone.m | 0 {test => tools/test}/audio/test_utils/sync_chirp.m | 0 {test => tools/test}/audio/test_utils/test_run.m | 0 {test => tools/test}/audio/test_utils/write_test_data.m | 0 {test => tools/test}/qa/run_test.sh | 0 {test => tools/test}/qa/tests/common-test | 0 .../test}/qa/tests/functionality_test/capture_pcm_list.sh | 0 {test => tools/test}/qa/tests/functionality_test/channel_test.sh | 0 {test => tools/test}/qa/tests/functionality_test/check_aplay.sh | 0 .../test}/qa/tests/functionality_test/check_dma_trace.sh | 0 .../qa/tests/functionality_test/check_dual_channels_playback.sh | 0 .../qa/tests/functionality_test/check_line_in_out_playback.sh | 0 .../qa/tests/functionality_test/check_modules_loading_time.sh | 0 .../check_passthrough_pulseaudio_capture_function.sh | 0 .../check_passthrough_pulseaudio_playback_function.sh | 0 .../test}/qa/tests/functionality_test/check_pcm_playback.sh | 0 .../functionality_test/check_playback_after_modules_reloaded.sh | 0 .../test}/qa/tests/functionality_test/check_playback_function.sh | 0 .../tests/functionality_test/check_pulseaudio_capture_function.sh | 0 .../qa/tests/functionality_test/check_pulseaudio_function.sh | 0 .../functionality_test/check_pulseaudio_playback_function.sh | 0 .../qa/tests/functionality_test/estimate_firmware_loaded_time.sh | 0 .../test}/qa/tests/functionality_test/get_mixer_properties.sh | 0 .../test}/qa/tests/functionality_test/modules_reload.sh | 0 .../test}/qa/tests/functionality_test/playback_pcm_list.sh | 0 .../qa/tests/functionality_test/set_ADC_volume_to_maximum.sh | 0 .../qa/tests/functionality_test/set_ADC_volume_to_minimum.sh | 0 .../test}/qa/tests/functionality_test/set_HP_volume_to_maximum.sh | 0 .../test}/qa/tests/functionality_test/set_HP_volume_to_minimum.sh | 0 .../test}/qa/tests/functionality_test/verify_capture_info.sh | 0 .../test}/qa/tests/functionality_test/verify_playback_pcm_list.sh | 0 .../test}/qa/tests/functionality_test/verify_sof_firmware_load.sh | 0 .../qa/tests/functionality_test/verify_sof_firmware_presence.sh | 0 .../qa/tests/functionality_test/verify_sof_firmware_version.sh | 0 .../tests/functionality_test/verify_sof_firmware_version_info.sh | 0 .../test}/qa/tests/functionality_test/verify_sound_modules.sh | 0 .../test}/qa/tests/functionality_test/verify_topology_load.sh | 0 {test => tools/test}/qa/tests/platform/apl/up/feature-test | 0 {test => tools/test}/qa/tests/platform/apl/up/tplg | 0 .../qa/tests/platform/asound_state/apl/asound.state.passthrough | 0 .../test}/qa/tests/platform/asound_state/apl/asound.state.volume | 0 .../test}/qa/tests/platform/asound_state/byt/asound.state.line | 0 .../qa/tests/platform/asound_state/byt/asound.state.passthrough | 0 .../test}/qa/tests/platform/asound_state/byt/asound.state.pulse-c | 0 .../test}/qa/tests/platform/asound_state/byt/asound.state.pulse-p | 0 .../test}/qa/tests/platform/asound_state/byt/asound.state.volume | 0 {test => tools/test}/qa/tests/platform/byt/feature-test | 0 {test => tools/test}/qa/tests/platform/byt/minnow/feature-test | 0 {test => tools/test}/qa/tests/platform/byt/minnow/tplg | 0 {test => tools/test}/qa/tests/platform/byt/tplg | 0 .../qa/tests/smoke_test/byt_smoke_test_48k16bit_passthrough.sh | 0 .../test}/qa/tests/stability_test/test_modules_reloadable.sh | 0 {test => tools/test}/topology/Makefile.am | 0 {test => tools/test}/topology/test-all.m4 | 0 {test => tools/test}/topology/test-capture.m4 | 0 {test => tools/test}/topology/test-equalizer-playback-ssp.m4 | 0 {test => tools/test}/topology/test-playback.m4 | 0 {test => tools/test}/topology/test-tone-playback.m4 | 0 {test => tools/test}/topology/tplg-build.sh | 0 {topology => tools/topology}/Makefile.am | 0 {topology => tools/topology}/common/Makefile.am | 0 {topology => tools/topology}/common/memory.m4 | 0 {topology => tools/topology}/common/tlv.m4 | 0 {topology => tools/topology}/m4/Makefile.am | 0 {topology => tools/topology}/m4/buffer.m4 | 0 {topology => tools/topology}/m4/bytecontrol.m4 | 0 {topology => tools/topology}/m4/dai.m4 | 0 {topology => tools/topology}/m4/debug.m4 | 0 {topology => tools/topology}/m4/eq_fir.m4 | 0 {topology => tools/topology}/m4/eq_fir_coef_flat.m4 | 0 {topology => tools/topology}/m4/eq_iir.m4 | 0 {topology => tools/topology}/m4/eq_iir_coef_flat.m4 | 0 .../topology}/m4/eq_iir_coef_highpass_50hz_20db_48khz.m4 | 0 {topology => tools/topology}/m4/hda.m4 | 0 {topology => tools/topology}/m4/mixer.m4 | 0 {topology => tools/topology}/m4/mixercontrol.m4 | 0 {topology => tools/topology}/m4/pcm.m4 | 0 {topology => tools/topology}/m4/pga.m4 | 0 {topology => tools/topology}/m4/pipeline.m4 | 0 {topology => tools/topology}/m4/src.m4 | 0 {topology => tools/topology}/m4/tone.m4 | 0 {topology => tools/topology}/m4/utils.m4 | 0 {topology => tools/topology}/platform/Makefile.am | 0 {topology => tools/topology}/platform/common/Makefile.am | 0 {topology => tools/topology}/platform/common/ssp.m4 | 0 {topology => tools/topology}/platform/intel/Makefile.am | 0 {topology => tools/topology}/platform/intel/bdw.m4 | 0 {topology => tools/topology}/platform/intel/bxt.m4 | 0 {topology => tools/topology}/platform/intel/byt.m4 | 0 {topology => tools/topology}/platform/intel/cht.m4 | 0 {topology => tools/topology}/platform/intel/cnl.m4 | 0 {topology => tools/topology}/platform/intel/dmic.m4 | 0 {topology => tools/topology}/platform/intel/hsw.m4 | 0 {topology => tools/topology}/platform/intel/icl.m4 | 0 {topology => tools/topology}/sof-apl-da7219.m4 | 0 {topology => tools/topology}/sof-apl-dmic-2ch.m4 | 0 {topology => tools/topology}/sof-apl-dmic-4ch.m4 | 0 {topology => tools/topology}/sof-apl-eq-dmic.m4 | 0 {topology => tools/topology}/sof-apl-eq-pcm512x.m4 | 0 {topology => tools/topology}/sof-apl-nocodec.m4 | 0 {topology => tools/topology}/sof-apl-pcm512x.m4 | 0 {topology => tools/topology}/sof-apl-rt298.m4 | 0 {topology => tools/topology}/sof-apl-tdf8532.m4 | 0 {topology => tools/topology}/sof-apl-wm8804.m4 | 0 {topology => tools/topology}/sof-bdw-rt286.m4 | 0 {topology => tools/topology}/sof-bdw-rt5640.m4 | 0 {topology => tools/topology}/sof-byt-da7213.m4 | 0 {topology => tools/topology}/sof-byt-nocodec.m4 | 0 {topology => tools/topology}/sof-byt-rt5640.m4 | 0 {topology => tools/topology}/sof-byt-rt5645.m4 | 0 {topology => tools/topology}/sof-byt-rt5651.m4 | 0 {topology => tools/topology}/sof-cht-max98090.m4 | 0 {topology => tools/topology}/sof-cht-nocodec.m4 | 0 {topology => tools/topology}/sof-cnl-rt274.m4 | 0 {topology => tools/topology}/sof-glk-da7219.m4 | 0 {topology => tools/topology}/sof-hda-generic.m4 | 0 {topology => tools/topology}/sof-hsw-rt5640.m4 | 0 {topology => tools/topology}/sof-icl-dmic-4ch.m4 | 0 {topology => tools/topology}/sof-icl-nocodec.m4 | 0 {topology => tools/topology}/sof-whl-hda.m4 | 0 {topology => tools/topology}/sof/Makefile.am | 0 {topology => tools/topology}/sof/pipe-dai-capture.m4 | 0 {topology => tools/topology}/sof/pipe-dai-playback.m4 | 0 {topology => tools/topology}/sof/pipe-eq-capture.m4 | 0 {topology => tools/topology}/sof/pipe-eq-fir-volume-playback.m4 | 0 {topology => tools/topology}/sof/pipe-eq-iir-volume-playback.m4 | 0 {topology => tools/topology}/sof/pipe-eq-volume-playback.m4 | 0 {topology => tools/topology}/sof/pipe-low-latency-capture.m4 | 0 {topology => tools/topology}/sof/pipe-low-latency-playback.m4 | 0 {topology => tools/topology}/sof/pipe-passthrough-capture.m4 | 0 {topology => tools/topology}/sof/pipe-passthrough-playback.m4 | 0 {topology => tools/topology}/sof/pipe-pcm-media.m4 | 0 {topology => tools/topology}/sof/pipe-src-capture.m4 | 0 {topology => tools/topology}/sof/pipe-src-playback.m4 | 0 {topology => tools/topology}/sof/pipe-tone.m4 | 0 {topology => tools/topology}/sof/pipe-volume-capture.m4 | 0 {topology => tools/topology}/sof/pipe-volume-playback.m4 | 0 {topology => tools/topology}/sof/tokens.m4 | 0 {tune => tools/tune}/eq/eq_align.m | 0 {tune => tools/tune}/eq/eq_alsactl_write.m | 0 {tune => tools/tune}/eq/eq_blob_write.m | 0 {tune => tools/tune}/eq/eq_coef_quant.m | 0 {tune => tools/tune}/eq/eq_compute.m | 0 {tune => tools/tune}/eq/eq_compute_response.m | 0 {tune => tools/tune}/eq/eq_compute_tot_response.m | 0 {tune => tools/tune}/eq/eq_defaults.m | 0 {tune => tools/tune}/eq/eq_define_parametric_eq.m | 0 {tune => tools/tune}/eq/eq_fir_blob_merge.m | 0 {tune => tools/tune}/eq/eq_fir_blob_pack.m | 0 {tune => tools/tune}/eq/eq_fir_blob_quant.m | 0 {tune => tools/tune}/eq/eq_iir_blob_merge.m | 0 {tune => tools/tune}/eq/eq_iir_blob_pack.m | 0 {tune => tools/tune}/eq/eq_iir_blob_quant.m | 0 {tune => tools/tune}/eq/eq_norm.m | 0 {tune => tools/tune}/eq/eq_plot.m | 0 {tune => tools/tune}/eq/eq_tplg_write.m | 0 {tune => tools/tune}/eq/example_fir_eq.m | 0 {tune => tools/tune}/eq/example_iir_eq.m | 0 {tune => tools/tune}/eq/example_spk_eq.m | 0 {tune => tools/tune}/eq/mls_freq_resp.m | 0 {tune => tools/tune}/eq/mls_play_config.txt | 0 {tune => tools/tune}/eq/mls_rec_config.txt | 0 {tune => tools/tune}/src/README | 0 {tune => tools/tune}/src/src_export_coef.m | 0 {tune => tools/tune}/src/src_export_defines.m | 0 {tune => tools/tune}/src/src_export_table_2s.m | 0 {tune => tools/tune}/src/src_factor1_lm.m | 0 {tune => tools/tune}/src/src_factor2_lm.m | 0 {tune => tools/tune}/src/src_find_l0m0.m | 0 {tune => tools/tune}/src/src_generate.m | 0 {tune => tools/tune}/src/src_get.m | 0 {tune => tools/tune}/src/src_param.m | 0 {tune => tools/tune}/src/src_std_int32.m | 0 {tune => tools/tune}/src/src_tiny_int16.m | 0 243 files changed, 0 insertions(+), 0 deletions(-) rename .gitignore => tools/.gitignore (100%) rename .travis.yml => tools/.travis.yml (100%) rename Makefile.am => tools/Makefile.am (100%) rename README => tools/README (100%) rename autogen.sh => tools/autogen.sh (100%) rename configure.ac => tools/configure.ac (100%) rename {coredumper => tools/coredumper}/sof-coredump-reader.py (100%) rename {coredumper => tools/coredumper}/sof-coredump-to-gdb.sh (100%) rename {eqctl => tools/eqctl}/Makefile.am (100%) rename {eqctl => tools/eqctl}/README (100%) rename {eqctl => tools/eqctl}/eq_fir_flat.txt (100%) rename {eqctl => tools/eqctl}/eq_fir_loudness.txt (100%) rename {eqctl => tools/eqctl}/eq_fir_mid.txt (100%) rename {eqctl => tools/eqctl}/eq_iir_bandpass.txt (100%) rename {eqctl => tools/eqctl}/eq_iir_bassboost.txt (100%) rename {eqctl => tools/eqctl}/eq_iir_flat.txt (100%) rename {eqctl => tools/eqctl}/eq_iir_loudness.txt (100%) rename {eqctl => tools/eqctl}/eqctl.c (100%) rename {kmod_scripts => tools/kmod_scripts}/sof_bootloop.sh (100%) rename {kmod_scripts => tools/kmod_scripts}/sof_bootone.sh (100%) rename {kmod_scripts => tools/kmod_scripts}/sof_insert.sh (100%) rename {kmod_scripts => tools/kmod_scripts}/sof_remove.sh (100%) rename {logger => tools/logger}/Makefile.am (100%) rename {logger => tools/logger}/convert.c (100%) rename {logger => tools/logger}/convert.h (100%) rename {logger => tools/logger}/logger.c (100%) rename {logger => tools/logger}/sof/uapi/abi.h (100%) rename {logger => tools/logger}/sof/uapi/ipc.h (100%) rename {logger => tools/logger}/sof/uapi/logging.h (100%) rename {rimage => tools/rimage}/keys/Makefile.am (100%) rename {rimage => tools/rimage}/keys/README (100%) rename {rimage => tools/rimage}/keys/otc_private_key.pem (100%) rename {rimage => tools/rimage}/keys/otc_public_key.pem (100%) rename {scripts => tools/scripts}/pretty-macro.sh (100%) rename {test => tools/test}/audio/README (100%) rename {test => tools/test}/audio/src_run.sh (100%) rename {test => tools/test}/audio/src_test.m (100%) rename {test => tools/test}/audio/src_test.sh (100%) rename {test => tools/test}/audio/src_test_top.m (100%) rename {test => tools/test}/audio/std_utils/aap_test_input.m (100%) rename {test => tools/test}/audio/std_utils/aap_test_measure.m (100%) rename {test => tools/test}/audio/std_utils/aip_test_input.m (100%) rename {test => tools/test}/audio/std_utils/aip_test_measure.m (100%) rename {test => tools/test}/audio/std_utils/dr_test_input.m (100%) rename {test => tools/test}/audio/std_utils/dr_test_measure.m (100%) rename {test => tools/test}/audio/std_utils/fr_test_input.m (100%) rename {test => tools/test}/audio/std_utils/fr_test_measure.m (100%) rename {test => tools/test}/audio/std_utils/g_test_input.m (100%) rename {test => tools/test}/audio/std_utils/g_test_measure.m (100%) rename {test => tools/test}/audio/std_utils/level_dbfs.m (100%) rename {test => tools/test}/audio/std_utils/stdhpf.m (100%) rename {test => tools/test}/audio/std_utils/stdhpf_get.m (100%) rename {test => tools/test}/audio/std_utils/stdlpf.m (100%) rename {test => tools/test}/audio/std_utils/stdlpf_get.m (100%) rename {test => tools/test}/audio/std_utils/stdnotch.m (100%) rename {test => tools/test}/audio/std_utils/stdnotch_get.m (100%) rename {test => tools/test}/audio/std_utils/stdweight.m (100%) rename {test => tools/test}/audio/std_utils/thdnf_test_input.m (100%) rename {test => tools/test}/audio/std_utils/thdnf_test_measure.m (100%) rename {test => tools/test}/audio/test_utils/chirp_test_analyze.m (100%) rename {test => tools/test}/audio/test_utils/chirp_test_input.m (100%) rename {test => tools/test}/audio/test_utils/delete_check.m (100%) rename {test => tools/test}/audio/test_utils/dither_and_quantize.m (100%) rename {test => tools/test}/audio/test_utils/find_test_signal.m (100%) rename {test => tools/test}/audio/test_utils/load_test_output.m (100%) rename {test => tools/test}/audio/test_utils/mix_chirp.m (100%) rename {test => tools/test}/audio/test_utils/mix_sweep.m (100%) rename {test => tools/test}/audio/test_utils/mkdir_check.m (100%) rename {test => tools/test}/audio/test_utils/mls_calc_resp.m (100%) rename {test => tools/test}/audio/test_utils/multitone.m (100%) rename {test => tools/test}/audio/test_utils/sync_chirp.m (100%) rename {test => tools/test}/audio/test_utils/test_run.m (100%) rename {test => tools/test}/audio/test_utils/write_test_data.m (100%) rename {test => tools/test}/qa/run_test.sh (100%) rename {test => tools/test}/qa/tests/common-test (100%) rename {test => tools/test}/qa/tests/functionality_test/capture_pcm_list.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/channel_test.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_aplay.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_dma_trace.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_dual_channels_playback.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_line_in_out_playback.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_modules_loading_time.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_passthrough_pulseaudio_capture_function.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_passthrough_pulseaudio_playback_function.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_pcm_playback.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_playback_after_modules_reloaded.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_playback_function.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_pulseaudio_capture_function.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_pulseaudio_function.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/check_pulseaudio_playback_function.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/estimate_firmware_loaded_time.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/get_mixer_properties.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/modules_reload.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/playback_pcm_list.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/set_ADC_volume_to_maximum.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/set_ADC_volume_to_minimum.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/set_HP_volume_to_maximum.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/set_HP_volume_to_minimum.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/verify_capture_info.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/verify_playback_pcm_list.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/verify_sof_firmware_load.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/verify_sof_firmware_presence.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/verify_sof_firmware_version.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/verify_sof_firmware_version_info.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/verify_sound_modules.sh (100%) rename {test => tools/test}/qa/tests/functionality_test/verify_topology_load.sh (100%) rename {test => tools/test}/qa/tests/platform/apl/up/feature-test (100%) rename {test => tools/test}/qa/tests/platform/apl/up/tplg (100%) rename {test => tools/test}/qa/tests/platform/asound_state/apl/asound.state.passthrough (100%) rename {test => tools/test}/qa/tests/platform/asound_state/apl/asound.state.volume (100%) rename {test => tools/test}/qa/tests/platform/asound_state/byt/asound.state.line (100%) rename {test => tools/test}/qa/tests/platform/asound_state/byt/asound.state.passthrough (100%) rename {test => tools/test}/qa/tests/platform/asound_state/byt/asound.state.pulse-c (100%) rename {test => tools/test}/qa/tests/platform/asound_state/byt/asound.state.pulse-p (100%) rename {test => tools/test}/qa/tests/platform/asound_state/byt/asound.state.volume (100%) rename {test => tools/test}/qa/tests/platform/byt/feature-test (100%) rename {test => tools/test}/qa/tests/platform/byt/minnow/feature-test (100%) rename {test => tools/test}/qa/tests/platform/byt/minnow/tplg (100%) rename {test => tools/test}/qa/tests/platform/byt/tplg (100%) rename {test => tools/test}/qa/tests/smoke_test/byt_smoke_test_48k16bit_passthrough.sh (100%) rename {test => tools/test}/qa/tests/stability_test/test_modules_reloadable.sh (100%) rename {test => tools/test}/topology/Makefile.am (100%) rename {test => tools/test}/topology/test-all.m4 (100%) rename {test => tools/test}/topology/test-capture.m4 (100%) rename {test => tools/test}/topology/test-equalizer-playback-ssp.m4 (100%) rename {test => tools/test}/topology/test-playback.m4 (100%) rename {test => tools/test}/topology/test-tone-playback.m4 (100%) rename {test => tools/test}/topology/tplg-build.sh (100%) rename {topology => tools/topology}/Makefile.am (100%) rename {topology => tools/topology}/common/Makefile.am (100%) rename {topology => tools/topology}/common/memory.m4 (100%) rename {topology => tools/topology}/common/tlv.m4 (100%) rename {topology => tools/topology}/m4/Makefile.am (100%) rename {topology => tools/topology}/m4/buffer.m4 (100%) rename {topology => tools/topology}/m4/bytecontrol.m4 (100%) rename {topology => tools/topology}/m4/dai.m4 (100%) rename {topology => tools/topology}/m4/debug.m4 (100%) rename {topology => tools/topology}/m4/eq_fir.m4 (100%) rename {topology => tools/topology}/m4/eq_fir_coef_flat.m4 (100%) rename {topology => tools/topology}/m4/eq_iir.m4 (100%) rename {topology => tools/topology}/m4/eq_iir_coef_flat.m4 (100%) rename {topology => tools/topology}/m4/eq_iir_coef_highpass_50hz_20db_48khz.m4 (100%) rename {topology => tools/topology}/m4/hda.m4 (100%) rename {topology => tools/topology}/m4/mixer.m4 (100%) rename {topology => tools/topology}/m4/mixercontrol.m4 (100%) rename {topology => tools/topology}/m4/pcm.m4 (100%) rename {topology => tools/topology}/m4/pga.m4 (100%) rename {topology => tools/topology}/m4/pipeline.m4 (100%) rename {topology => tools/topology}/m4/src.m4 (100%) rename {topology => tools/topology}/m4/tone.m4 (100%) rename {topology => tools/topology}/m4/utils.m4 (100%) rename {topology => tools/topology}/platform/Makefile.am (100%) rename {topology => tools/topology}/platform/common/Makefile.am (100%) rename {topology => tools/topology}/platform/common/ssp.m4 (100%) rename {topology => tools/topology}/platform/intel/Makefile.am (100%) rename {topology => tools/topology}/platform/intel/bdw.m4 (100%) rename {topology => tools/topology}/platform/intel/bxt.m4 (100%) rename {topology => tools/topology}/platform/intel/byt.m4 (100%) rename {topology => tools/topology}/platform/intel/cht.m4 (100%) rename {topology => tools/topology}/platform/intel/cnl.m4 (100%) rename {topology => tools/topology}/platform/intel/dmic.m4 (100%) rename {topology => tools/topology}/platform/intel/hsw.m4 (100%) rename {topology => tools/topology}/platform/intel/icl.m4 (100%) rename {topology => tools/topology}/sof-apl-da7219.m4 (100%) rename {topology => tools/topology}/sof-apl-dmic-2ch.m4 (100%) rename {topology => tools/topology}/sof-apl-dmic-4ch.m4 (100%) rename {topology => tools/topology}/sof-apl-eq-dmic.m4 (100%) rename {topology => tools/topology}/sof-apl-eq-pcm512x.m4 (100%) rename {topology => tools/topology}/sof-apl-nocodec.m4 (100%) rename {topology => tools/topology}/sof-apl-pcm512x.m4 (100%) rename {topology => tools/topology}/sof-apl-rt298.m4 (100%) rename {topology => tools/topology}/sof-apl-tdf8532.m4 (100%) rename {topology => tools/topology}/sof-apl-wm8804.m4 (100%) rename {topology => tools/topology}/sof-bdw-rt286.m4 (100%) rename {topology => tools/topology}/sof-bdw-rt5640.m4 (100%) rename {topology => tools/topology}/sof-byt-da7213.m4 (100%) rename {topology => tools/topology}/sof-byt-nocodec.m4 (100%) rename {topology => tools/topology}/sof-byt-rt5640.m4 (100%) rename {topology => tools/topology}/sof-byt-rt5645.m4 (100%) rename {topology => tools/topology}/sof-byt-rt5651.m4 (100%) rename {topology => tools/topology}/sof-cht-max98090.m4 (100%) rename {topology => tools/topology}/sof-cht-nocodec.m4 (100%) rename {topology => tools/topology}/sof-cnl-rt274.m4 (100%) rename {topology => tools/topology}/sof-glk-da7219.m4 (100%) rename {topology => tools/topology}/sof-hda-generic.m4 (100%) rename {topology => tools/topology}/sof-hsw-rt5640.m4 (100%) rename {topology => tools/topology}/sof-icl-dmic-4ch.m4 (100%) rename {topology => tools/topology}/sof-icl-nocodec.m4 (100%) rename {topology => tools/topology}/sof-whl-hda.m4 (100%) rename {topology => tools/topology}/sof/Makefile.am (100%) rename {topology => tools/topology}/sof/pipe-dai-capture.m4 (100%) rename {topology => tools/topology}/sof/pipe-dai-playback.m4 (100%) rename {topology => tools/topology}/sof/pipe-eq-capture.m4 (100%) rename {topology => tools/topology}/sof/pipe-eq-fir-volume-playback.m4 (100%) rename {topology => tools/topology}/sof/pipe-eq-iir-volume-playback.m4 (100%) rename {topology => tools/topology}/sof/pipe-eq-volume-playback.m4 (100%) rename {topology => tools/topology}/sof/pipe-low-latency-capture.m4 (100%) rename {topology => tools/topology}/sof/pipe-low-latency-playback.m4 (100%) rename {topology => tools/topology}/sof/pipe-passthrough-capture.m4 (100%) rename {topology => tools/topology}/sof/pipe-passthrough-playback.m4 (100%) rename {topology => tools/topology}/sof/pipe-pcm-media.m4 (100%) rename {topology => tools/topology}/sof/pipe-src-capture.m4 (100%) rename {topology => tools/topology}/sof/pipe-src-playback.m4 (100%) rename {topology => tools/topology}/sof/pipe-tone.m4 (100%) rename {topology => tools/topology}/sof/pipe-volume-capture.m4 (100%) rename {topology => tools/topology}/sof/pipe-volume-playback.m4 (100%) rename {topology => tools/topology}/sof/tokens.m4 (100%) rename {tune => tools/tune}/eq/eq_align.m (100%) rename {tune => tools/tune}/eq/eq_alsactl_write.m (100%) rename {tune => tools/tune}/eq/eq_blob_write.m (100%) rename {tune => tools/tune}/eq/eq_coef_quant.m (100%) rename {tune => tools/tune}/eq/eq_compute.m (100%) rename {tune => tools/tune}/eq/eq_compute_response.m (100%) rename {tune => tools/tune}/eq/eq_compute_tot_response.m (100%) rename {tune => tools/tune}/eq/eq_defaults.m (100%) rename {tune => tools/tune}/eq/eq_define_parametric_eq.m (100%) rename {tune => tools/tune}/eq/eq_fir_blob_merge.m (100%) rename {tune => tools/tune}/eq/eq_fir_blob_pack.m (100%) rename {tune => tools/tune}/eq/eq_fir_blob_quant.m (100%) rename {tune => tools/tune}/eq/eq_iir_blob_merge.m (100%) rename {tune => tools/tune}/eq/eq_iir_blob_pack.m (100%) rename {tune => tools/tune}/eq/eq_iir_blob_quant.m (100%) rename {tune => tools/tune}/eq/eq_norm.m (100%) rename {tune => tools/tune}/eq/eq_plot.m (100%) rename {tune => tools/tune}/eq/eq_tplg_write.m (100%) rename {tune => tools/tune}/eq/example_fir_eq.m (100%) rename {tune => tools/tune}/eq/example_iir_eq.m (100%) rename {tune => tools/tune}/eq/example_spk_eq.m (100%) rename {tune => tools/tune}/eq/mls_freq_resp.m (100%) rename {tune => tools/tune}/eq/mls_play_config.txt (100%) rename {tune => tools/tune}/eq/mls_rec_config.txt (100%) rename {tune => tools/tune}/src/README (100%) rename {tune => tools/tune}/src/src_export_coef.m (100%) rename {tune => tools/tune}/src/src_export_defines.m (100%) rename {tune => tools/tune}/src/src_export_table_2s.m (100%) rename {tune => tools/tune}/src/src_factor1_lm.m (100%) rename {tune => tools/tune}/src/src_factor2_lm.m (100%) rename {tune => tools/tune}/src/src_find_l0m0.m (100%) rename {tune => tools/tune}/src/src_generate.m (100%) rename {tune => tools/tune}/src/src_get.m (100%) rename {tune => tools/tune}/src/src_param.m (100%) rename {tune => tools/tune}/src/src_std_int32.m (100%) rename {tune => tools/tune}/src/src_tiny_int16.m (100%) diff --git a/.gitignore b/tools/.gitignore similarity index 100% rename from .gitignore rename to tools/.gitignore diff --git a/.travis.yml b/tools/.travis.yml similarity index 100% rename from .travis.yml rename to tools/.travis.yml diff --git a/Makefile.am b/tools/Makefile.am similarity index 100% rename from Makefile.am rename to tools/Makefile.am diff --git a/README b/tools/README similarity index 100% rename from README rename to tools/README diff --git a/autogen.sh b/tools/autogen.sh similarity index 100% rename from autogen.sh rename to tools/autogen.sh diff --git a/configure.ac b/tools/configure.ac similarity index 100% rename from configure.ac rename to tools/configure.ac diff --git a/coredumper/sof-coredump-reader.py b/tools/coredumper/sof-coredump-reader.py similarity index 100% rename from coredumper/sof-coredump-reader.py rename to tools/coredumper/sof-coredump-reader.py diff --git a/coredumper/sof-coredump-to-gdb.sh b/tools/coredumper/sof-coredump-to-gdb.sh similarity index 100% rename from coredumper/sof-coredump-to-gdb.sh rename to tools/coredumper/sof-coredump-to-gdb.sh diff --git a/eqctl/Makefile.am b/tools/eqctl/Makefile.am similarity index 100% rename from eqctl/Makefile.am rename to tools/eqctl/Makefile.am diff --git a/eqctl/README b/tools/eqctl/README similarity index 100% rename from eqctl/README rename to tools/eqctl/README diff --git a/eqctl/eq_fir_flat.txt b/tools/eqctl/eq_fir_flat.txt similarity index 100% rename from eqctl/eq_fir_flat.txt rename to tools/eqctl/eq_fir_flat.txt diff --git a/eqctl/eq_fir_loudness.txt b/tools/eqctl/eq_fir_loudness.txt similarity index 100% rename from eqctl/eq_fir_loudness.txt rename to tools/eqctl/eq_fir_loudness.txt diff --git a/eqctl/eq_fir_mid.txt b/tools/eqctl/eq_fir_mid.txt similarity index 100% rename from eqctl/eq_fir_mid.txt rename to tools/eqctl/eq_fir_mid.txt diff --git a/eqctl/eq_iir_bandpass.txt b/tools/eqctl/eq_iir_bandpass.txt similarity index 100% rename from eqctl/eq_iir_bandpass.txt rename to tools/eqctl/eq_iir_bandpass.txt diff --git a/eqctl/eq_iir_bassboost.txt b/tools/eqctl/eq_iir_bassboost.txt similarity index 100% rename from eqctl/eq_iir_bassboost.txt rename to tools/eqctl/eq_iir_bassboost.txt diff --git a/eqctl/eq_iir_flat.txt b/tools/eqctl/eq_iir_flat.txt similarity index 100% rename from eqctl/eq_iir_flat.txt rename to tools/eqctl/eq_iir_flat.txt diff --git a/eqctl/eq_iir_loudness.txt b/tools/eqctl/eq_iir_loudness.txt similarity index 100% rename from eqctl/eq_iir_loudness.txt rename to tools/eqctl/eq_iir_loudness.txt diff --git a/eqctl/eqctl.c b/tools/eqctl/eqctl.c similarity index 100% rename from eqctl/eqctl.c rename to tools/eqctl/eqctl.c diff --git a/kmod_scripts/sof_bootloop.sh b/tools/kmod_scripts/sof_bootloop.sh similarity index 100% rename from kmod_scripts/sof_bootloop.sh rename to tools/kmod_scripts/sof_bootloop.sh diff --git a/kmod_scripts/sof_bootone.sh b/tools/kmod_scripts/sof_bootone.sh similarity index 100% rename from kmod_scripts/sof_bootone.sh rename to tools/kmod_scripts/sof_bootone.sh diff --git a/kmod_scripts/sof_insert.sh b/tools/kmod_scripts/sof_insert.sh similarity index 100% rename from kmod_scripts/sof_insert.sh rename to tools/kmod_scripts/sof_insert.sh diff --git a/kmod_scripts/sof_remove.sh b/tools/kmod_scripts/sof_remove.sh similarity index 100% rename from kmod_scripts/sof_remove.sh rename to tools/kmod_scripts/sof_remove.sh diff --git a/logger/Makefile.am b/tools/logger/Makefile.am similarity index 100% rename from logger/Makefile.am rename to tools/logger/Makefile.am diff --git a/logger/convert.c b/tools/logger/convert.c similarity index 100% rename from logger/convert.c rename to tools/logger/convert.c diff --git a/logger/convert.h b/tools/logger/convert.h similarity index 100% rename from logger/convert.h rename to tools/logger/convert.h diff --git a/logger/logger.c b/tools/logger/logger.c similarity index 100% rename from logger/logger.c rename to tools/logger/logger.c diff --git a/logger/sof/uapi/abi.h b/tools/logger/sof/uapi/abi.h similarity index 100% rename from logger/sof/uapi/abi.h rename to tools/logger/sof/uapi/abi.h diff --git a/logger/sof/uapi/ipc.h b/tools/logger/sof/uapi/ipc.h similarity index 100% rename from logger/sof/uapi/ipc.h rename to tools/logger/sof/uapi/ipc.h diff --git a/logger/sof/uapi/logging.h b/tools/logger/sof/uapi/logging.h similarity index 100% rename from logger/sof/uapi/logging.h rename to tools/logger/sof/uapi/logging.h diff --git a/rimage/keys/Makefile.am b/tools/rimage/keys/Makefile.am similarity index 100% rename from rimage/keys/Makefile.am rename to tools/rimage/keys/Makefile.am diff --git a/rimage/keys/README b/tools/rimage/keys/README similarity index 100% rename from rimage/keys/README rename to tools/rimage/keys/README diff --git a/rimage/keys/otc_private_key.pem b/tools/rimage/keys/otc_private_key.pem similarity index 100% rename from rimage/keys/otc_private_key.pem rename to tools/rimage/keys/otc_private_key.pem diff --git a/rimage/keys/otc_public_key.pem b/tools/rimage/keys/otc_public_key.pem similarity index 100% rename from rimage/keys/otc_public_key.pem rename to tools/rimage/keys/otc_public_key.pem diff --git a/scripts/pretty-macro.sh b/tools/scripts/pretty-macro.sh similarity index 100% rename from scripts/pretty-macro.sh rename to tools/scripts/pretty-macro.sh diff --git a/test/audio/README b/tools/test/audio/README similarity index 100% rename from test/audio/README rename to tools/test/audio/README diff --git a/test/audio/src_run.sh b/tools/test/audio/src_run.sh similarity index 100% rename from test/audio/src_run.sh rename to tools/test/audio/src_run.sh diff --git a/test/audio/src_test.m b/tools/test/audio/src_test.m similarity index 100% rename from test/audio/src_test.m rename to tools/test/audio/src_test.m diff --git a/test/audio/src_test.sh b/tools/test/audio/src_test.sh similarity index 100% rename from test/audio/src_test.sh rename to tools/test/audio/src_test.sh diff --git a/test/audio/src_test_top.m b/tools/test/audio/src_test_top.m similarity index 100% rename from test/audio/src_test_top.m rename to tools/test/audio/src_test_top.m diff --git a/test/audio/std_utils/aap_test_input.m b/tools/test/audio/std_utils/aap_test_input.m similarity index 100% rename from test/audio/std_utils/aap_test_input.m rename to tools/test/audio/std_utils/aap_test_input.m diff --git a/test/audio/std_utils/aap_test_measure.m b/tools/test/audio/std_utils/aap_test_measure.m similarity index 100% rename from test/audio/std_utils/aap_test_measure.m rename to tools/test/audio/std_utils/aap_test_measure.m diff --git a/test/audio/std_utils/aip_test_input.m b/tools/test/audio/std_utils/aip_test_input.m similarity index 100% rename from test/audio/std_utils/aip_test_input.m rename to tools/test/audio/std_utils/aip_test_input.m diff --git a/test/audio/std_utils/aip_test_measure.m b/tools/test/audio/std_utils/aip_test_measure.m similarity index 100% rename from test/audio/std_utils/aip_test_measure.m rename to tools/test/audio/std_utils/aip_test_measure.m diff --git a/test/audio/std_utils/dr_test_input.m b/tools/test/audio/std_utils/dr_test_input.m similarity index 100% rename from test/audio/std_utils/dr_test_input.m rename to tools/test/audio/std_utils/dr_test_input.m diff --git a/test/audio/std_utils/dr_test_measure.m b/tools/test/audio/std_utils/dr_test_measure.m similarity index 100% rename from test/audio/std_utils/dr_test_measure.m rename to tools/test/audio/std_utils/dr_test_measure.m diff --git a/test/audio/std_utils/fr_test_input.m b/tools/test/audio/std_utils/fr_test_input.m similarity index 100% rename from test/audio/std_utils/fr_test_input.m rename to tools/test/audio/std_utils/fr_test_input.m diff --git a/test/audio/std_utils/fr_test_measure.m b/tools/test/audio/std_utils/fr_test_measure.m similarity index 100% rename from test/audio/std_utils/fr_test_measure.m rename to tools/test/audio/std_utils/fr_test_measure.m diff --git a/test/audio/std_utils/g_test_input.m b/tools/test/audio/std_utils/g_test_input.m similarity index 100% rename from test/audio/std_utils/g_test_input.m rename to tools/test/audio/std_utils/g_test_input.m diff --git a/test/audio/std_utils/g_test_measure.m b/tools/test/audio/std_utils/g_test_measure.m similarity index 100% rename from test/audio/std_utils/g_test_measure.m rename to tools/test/audio/std_utils/g_test_measure.m diff --git a/test/audio/std_utils/level_dbfs.m b/tools/test/audio/std_utils/level_dbfs.m similarity index 100% rename from test/audio/std_utils/level_dbfs.m rename to tools/test/audio/std_utils/level_dbfs.m diff --git a/test/audio/std_utils/stdhpf.m b/tools/test/audio/std_utils/stdhpf.m similarity index 100% rename from test/audio/std_utils/stdhpf.m rename to tools/test/audio/std_utils/stdhpf.m diff --git a/test/audio/std_utils/stdhpf_get.m b/tools/test/audio/std_utils/stdhpf_get.m similarity index 100% rename from test/audio/std_utils/stdhpf_get.m rename to tools/test/audio/std_utils/stdhpf_get.m diff --git a/test/audio/std_utils/stdlpf.m b/tools/test/audio/std_utils/stdlpf.m similarity index 100% rename from test/audio/std_utils/stdlpf.m rename to tools/test/audio/std_utils/stdlpf.m diff --git a/test/audio/std_utils/stdlpf_get.m b/tools/test/audio/std_utils/stdlpf_get.m similarity index 100% rename from test/audio/std_utils/stdlpf_get.m rename to tools/test/audio/std_utils/stdlpf_get.m diff --git a/test/audio/std_utils/stdnotch.m b/tools/test/audio/std_utils/stdnotch.m similarity index 100% rename from test/audio/std_utils/stdnotch.m rename to tools/test/audio/std_utils/stdnotch.m diff --git a/test/audio/std_utils/stdnotch_get.m b/tools/test/audio/std_utils/stdnotch_get.m similarity index 100% rename from test/audio/std_utils/stdnotch_get.m rename to tools/test/audio/std_utils/stdnotch_get.m diff --git a/test/audio/std_utils/stdweight.m b/tools/test/audio/std_utils/stdweight.m similarity index 100% rename from test/audio/std_utils/stdweight.m rename to tools/test/audio/std_utils/stdweight.m diff --git a/test/audio/std_utils/thdnf_test_input.m b/tools/test/audio/std_utils/thdnf_test_input.m similarity index 100% rename from test/audio/std_utils/thdnf_test_input.m rename to tools/test/audio/std_utils/thdnf_test_input.m diff --git a/test/audio/std_utils/thdnf_test_measure.m b/tools/test/audio/std_utils/thdnf_test_measure.m similarity index 100% rename from test/audio/std_utils/thdnf_test_measure.m rename to tools/test/audio/std_utils/thdnf_test_measure.m diff --git a/test/audio/test_utils/chirp_test_analyze.m b/tools/test/audio/test_utils/chirp_test_analyze.m similarity index 100% rename from test/audio/test_utils/chirp_test_analyze.m rename to tools/test/audio/test_utils/chirp_test_analyze.m diff --git a/test/audio/test_utils/chirp_test_input.m b/tools/test/audio/test_utils/chirp_test_input.m similarity index 100% rename from test/audio/test_utils/chirp_test_input.m rename to tools/test/audio/test_utils/chirp_test_input.m diff --git a/test/audio/test_utils/delete_check.m b/tools/test/audio/test_utils/delete_check.m similarity index 100% rename from test/audio/test_utils/delete_check.m rename to tools/test/audio/test_utils/delete_check.m diff --git a/test/audio/test_utils/dither_and_quantize.m b/tools/test/audio/test_utils/dither_and_quantize.m similarity index 100% rename from test/audio/test_utils/dither_and_quantize.m rename to tools/test/audio/test_utils/dither_and_quantize.m diff --git a/test/audio/test_utils/find_test_signal.m b/tools/test/audio/test_utils/find_test_signal.m similarity index 100% rename from test/audio/test_utils/find_test_signal.m rename to tools/test/audio/test_utils/find_test_signal.m diff --git a/test/audio/test_utils/load_test_output.m b/tools/test/audio/test_utils/load_test_output.m similarity index 100% rename from test/audio/test_utils/load_test_output.m rename to tools/test/audio/test_utils/load_test_output.m diff --git a/test/audio/test_utils/mix_chirp.m b/tools/test/audio/test_utils/mix_chirp.m similarity index 100% rename from test/audio/test_utils/mix_chirp.m rename to tools/test/audio/test_utils/mix_chirp.m diff --git a/test/audio/test_utils/mix_sweep.m b/tools/test/audio/test_utils/mix_sweep.m similarity index 100% rename from test/audio/test_utils/mix_sweep.m rename to tools/test/audio/test_utils/mix_sweep.m diff --git a/test/audio/test_utils/mkdir_check.m b/tools/test/audio/test_utils/mkdir_check.m similarity index 100% rename from test/audio/test_utils/mkdir_check.m rename to tools/test/audio/test_utils/mkdir_check.m diff --git a/test/audio/test_utils/mls_calc_resp.m b/tools/test/audio/test_utils/mls_calc_resp.m similarity index 100% rename from test/audio/test_utils/mls_calc_resp.m rename to tools/test/audio/test_utils/mls_calc_resp.m diff --git a/test/audio/test_utils/multitone.m b/tools/test/audio/test_utils/multitone.m similarity index 100% rename from test/audio/test_utils/multitone.m rename to tools/test/audio/test_utils/multitone.m diff --git a/test/audio/test_utils/sync_chirp.m b/tools/test/audio/test_utils/sync_chirp.m similarity index 100% rename from test/audio/test_utils/sync_chirp.m rename to tools/test/audio/test_utils/sync_chirp.m diff --git a/test/audio/test_utils/test_run.m b/tools/test/audio/test_utils/test_run.m similarity index 100% rename from test/audio/test_utils/test_run.m rename to tools/test/audio/test_utils/test_run.m diff --git a/test/audio/test_utils/write_test_data.m b/tools/test/audio/test_utils/write_test_data.m similarity index 100% rename from test/audio/test_utils/write_test_data.m rename to tools/test/audio/test_utils/write_test_data.m diff --git a/test/qa/run_test.sh b/tools/test/qa/run_test.sh similarity index 100% rename from test/qa/run_test.sh rename to tools/test/qa/run_test.sh diff --git a/test/qa/tests/common-test b/tools/test/qa/tests/common-test similarity index 100% rename from test/qa/tests/common-test rename to tools/test/qa/tests/common-test diff --git a/test/qa/tests/functionality_test/capture_pcm_list.sh b/tools/test/qa/tests/functionality_test/capture_pcm_list.sh similarity index 100% rename from test/qa/tests/functionality_test/capture_pcm_list.sh rename to tools/test/qa/tests/functionality_test/capture_pcm_list.sh diff --git a/test/qa/tests/functionality_test/channel_test.sh b/tools/test/qa/tests/functionality_test/channel_test.sh similarity index 100% rename from test/qa/tests/functionality_test/channel_test.sh rename to tools/test/qa/tests/functionality_test/channel_test.sh diff --git a/test/qa/tests/functionality_test/check_aplay.sh b/tools/test/qa/tests/functionality_test/check_aplay.sh similarity index 100% rename from test/qa/tests/functionality_test/check_aplay.sh rename to tools/test/qa/tests/functionality_test/check_aplay.sh diff --git a/test/qa/tests/functionality_test/check_dma_trace.sh b/tools/test/qa/tests/functionality_test/check_dma_trace.sh similarity index 100% rename from test/qa/tests/functionality_test/check_dma_trace.sh rename to tools/test/qa/tests/functionality_test/check_dma_trace.sh diff --git a/test/qa/tests/functionality_test/check_dual_channels_playback.sh b/tools/test/qa/tests/functionality_test/check_dual_channels_playback.sh similarity index 100% rename from test/qa/tests/functionality_test/check_dual_channels_playback.sh rename to tools/test/qa/tests/functionality_test/check_dual_channels_playback.sh diff --git a/test/qa/tests/functionality_test/check_line_in_out_playback.sh b/tools/test/qa/tests/functionality_test/check_line_in_out_playback.sh similarity index 100% rename from test/qa/tests/functionality_test/check_line_in_out_playback.sh rename to tools/test/qa/tests/functionality_test/check_line_in_out_playback.sh diff --git a/test/qa/tests/functionality_test/check_modules_loading_time.sh b/tools/test/qa/tests/functionality_test/check_modules_loading_time.sh similarity index 100% rename from test/qa/tests/functionality_test/check_modules_loading_time.sh rename to tools/test/qa/tests/functionality_test/check_modules_loading_time.sh diff --git a/test/qa/tests/functionality_test/check_passthrough_pulseaudio_capture_function.sh b/tools/test/qa/tests/functionality_test/check_passthrough_pulseaudio_capture_function.sh similarity index 100% rename from test/qa/tests/functionality_test/check_passthrough_pulseaudio_capture_function.sh rename to tools/test/qa/tests/functionality_test/check_passthrough_pulseaudio_capture_function.sh diff --git a/test/qa/tests/functionality_test/check_passthrough_pulseaudio_playback_function.sh b/tools/test/qa/tests/functionality_test/check_passthrough_pulseaudio_playback_function.sh similarity index 100% rename from test/qa/tests/functionality_test/check_passthrough_pulseaudio_playback_function.sh rename to tools/test/qa/tests/functionality_test/check_passthrough_pulseaudio_playback_function.sh diff --git a/test/qa/tests/functionality_test/check_pcm_playback.sh b/tools/test/qa/tests/functionality_test/check_pcm_playback.sh similarity index 100% rename from test/qa/tests/functionality_test/check_pcm_playback.sh rename to tools/test/qa/tests/functionality_test/check_pcm_playback.sh diff --git a/test/qa/tests/functionality_test/check_playback_after_modules_reloaded.sh b/tools/test/qa/tests/functionality_test/check_playback_after_modules_reloaded.sh similarity index 100% rename from test/qa/tests/functionality_test/check_playback_after_modules_reloaded.sh rename to tools/test/qa/tests/functionality_test/check_playback_after_modules_reloaded.sh diff --git a/test/qa/tests/functionality_test/check_playback_function.sh b/tools/test/qa/tests/functionality_test/check_playback_function.sh similarity index 100% rename from test/qa/tests/functionality_test/check_playback_function.sh rename to tools/test/qa/tests/functionality_test/check_playback_function.sh diff --git a/test/qa/tests/functionality_test/check_pulseaudio_capture_function.sh b/tools/test/qa/tests/functionality_test/check_pulseaudio_capture_function.sh similarity index 100% rename from test/qa/tests/functionality_test/check_pulseaudio_capture_function.sh rename to tools/test/qa/tests/functionality_test/check_pulseaudio_capture_function.sh diff --git a/test/qa/tests/functionality_test/check_pulseaudio_function.sh b/tools/test/qa/tests/functionality_test/check_pulseaudio_function.sh similarity index 100% rename from test/qa/tests/functionality_test/check_pulseaudio_function.sh rename to tools/test/qa/tests/functionality_test/check_pulseaudio_function.sh diff --git a/test/qa/tests/functionality_test/check_pulseaudio_playback_function.sh b/tools/test/qa/tests/functionality_test/check_pulseaudio_playback_function.sh similarity index 100% rename from test/qa/tests/functionality_test/check_pulseaudio_playback_function.sh rename to tools/test/qa/tests/functionality_test/check_pulseaudio_playback_function.sh diff --git a/test/qa/tests/functionality_test/estimate_firmware_loaded_time.sh b/tools/test/qa/tests/functionality_test/estimate_firmware_loaded_time.sh similarity index 100% rename from test/qa/tests/functionality_test/estimate_firmware_loaded_time.sh rename to tools/test/qa/tests/functionality_test/estimate_firmware_loaded_time.sh diff --git a/test/qa/tests/functionality_test/get_mixer_properties.sh b/tools/test/qa/tests/functionality_test/get_mixer_properties.sh similarity index 100% rename from test/qa/tests/functionality_test/get_mixer_properties.sh rename to tools/test/qa/tests/functionality_test/get_mixer_properties.sh diff --git a/test/qa/tests/functionality_test/modules_reload.sh b/tools/test/qa/tests/functionality_test/modules_reload.sh similarity index 100% rename from test/qa/tests/functionality_test/modules_reload.sh rename to tools/test/qa/tests/functionality_test/modules_reload.sh diff --git a/test/qa/tests/functionality_test/playback_pcm_list.sh b/tools/test/qa/tests/functionality_test/playback_pcm_list.sh similarity index 100% rename from test/qa/tests/functionality_test/playback_pcm_list.sh rename to tools/test/qa/tests/functionality_test/playback_pcm_list.sh diff --git a/test/qa/tests/functionality_test/set_ADC_volume_to_maximum.sh b/tools/test/qa/tests/functionality_test/set_ADC_volume_to_maximum.sh similarity index 100% rename from test/qa/tests/functionality_test/set_ADC_volume_to_maximum.sh rename to tools/test/qa/tests/functionality_test/set_ADC_volume_to_maximum.sh diff --git a/test/qa/tests/functionality_test/set_ADC_volume_to_minimum.sh b/tools/test/qa/tests/functionality_test/set_ADC_volume_to_minimum.sh similarity index 100% rename from test/qa/tests/functionality_test/set_ADC_volume_to_minimum.sh rename to tools/test/qa/tests/functionality_test/set_ADC_volume_to_minimum.sh diff --git a/test/qa/tests/functionality_test/set_HP_volume_to_maximum.sh b/tools/test/qa/tests/functionality_test/set_HP_volume_to_maximum.sh similarity index 100% rename from test/qa/tests/functionality_test/set_HP_volume_to_maximum.sh rename to tools/test/qa/tests/functionality_test/set_HP_volume_to_maximum.sh diff --git a/test/qa/tests/functionality_test/set_HP_volume_to_minimum.sh b/tools/test/qa/tests/functionality_test/set_HP_volume_to_minimum.sh similarity index 100% rename from test/qa/tests/functionality_test/set_HP_volume_to_minimum.sh rename to tools/test/qa/tests/functionality_test/set_HP_volume_to_minimum.sh diff --git a/test/qa/tests/functionality_test/verify_capture_info.sh b/tools/test/qa/tests/functionality_test/verify_capture_info.sh similarity index 100% rename from test/qa/tests/functionality_test/verify_capture_info.sh rename to tools/test/qa/tests/functionality_test/verify_capture_info.sh diff --git a/test/qa/tests/functionality_test/verify_playback_pcm_list.sh b/tools/test/qa/tests/functionality_test/verify_playback_pcm_list.sh similarity index 100% rename from test/qa/tests/functionality_test/verify_playback_pcm_list.sh rename to tools/test/qa/tests/functionality_test/verify_playback_pcm_list.sh diff --git a/test/qa/tests/functionality_test/verify_sof_firmware_load.sh b/tools/test/qa/tests/functionality_test/verify_sof_firmware_load.sh similarity index 100% rename from test/qa/tests/functionality_test/verify_sof_firmware_load.sh rename to tools/test/qa/tests/functionality_test/verify_sof_firmware_load.sh diff --git a/test/qa/tests/functionality_test/verify_sof_firmware_presence.sh b/tools/test/qa/tests/functionality_test/verify_sof_firmware_presence.sh similarity index 100% rename from test/qa/tests/functionality_test/verify_sof_firmware_presence.sh rename to tools/test/qa/tests/functionality_test/verify_sof_firmware_presence.sh diff --git a/test/qa/tests/functionality_test/verify_sof_firmware_version.sh b/tools/test/qa/tests/functionality_test/verify_sof_firmware_version.sh similarity index 100% rename from test/qa/tests/functionality_test/verify_sof_firmware_version.sh rename to tools/test/qa/tests/functionality_test/verify_sof_firmware_version.sh diff --git a/test/qa/tests/functionality_test/verify_sof_firmware_version_info.sh b/tools/test/qa/tests/functionality_test/verify_sof_firmware_version_info.sh similarity index 100% rename from test/qa/tests/functionality_test/verify_sof_firmware_version_info.sh rename to tools/test/qa/tests/functionality_test/verify_sof_firmware_version_info.sh diff --git a/test/qa/tests/functionality_test/verify_sound_modules.sh b/tools/test/qa/tests/functionality_test/verify_sound_modules.sh similarity index 100% rename from test/qa/tests/functionality_test/verify_sound_modules.sh rename to tools/test/qa/tests/functionality_test/verify_sound_modules.sh diff --git a/test/qa/tests/functionality_test/verify_topology_load.sh b/tools/test/qa/tests/functionality_test/verify_topology_load.sh similarity index 100% rename from test/qa/tests/functionality_test/verify_topology_load.sh rename to tools/test/qa/tests/functionality_test/verify_topology_load.sh diff --git a/test/qa/tests/platform/apl/up/feature-test b/tools/test/qa/tests/platform/apl/up/feature-test similarity index 100% rename from test/qa/tests/platform/apl/up/feature-test rename to tools/test/qa/tests/platform/apl/up/feature-test diff --git a/test/qa/tests/platform/apl/up/tplg b/tools/test/qa/tests/platform/apl/up/tplg similarity index 100% rename from test/qa/tests/platform/apl/up/tplg rename to tools/test/qa/tests/platform/apl/up/tplg diff --git a/test/qa/tests/platform/asound_state/apl/asound.state.passthrough b/tools/test/qa/tests/platform/asound_state/apl/asound.state.passthrough similarity index 100% rename from test/qa/tests/platform/asound_state/apl/asound.state.passthrough rename to tools/test/qa/tests/platform/asound_state/apl/asound.state.passthrough diff --git a/test/qa/tests/platform/asound_state/apl/asound.state.volume b/tools/test/qa/tests/platform/asound_state/apl/asound.state.volume similarity index 100% rename from test/qa/tests/platform/asound_state/apl/asound.state.volume rename to tools/test/qa/tests/platform/asound_state/apl/asound.state.volume diff --git a/test/qa/tests/platform/asound_state/byt/asound.state.line b/tools/test/qa/tests/platform/asound_state/byt/asound.state.line similarity index 100% rename from test/qa/tests/platform/asound_state/byt/asound.state.line rename to tools/test/qa/tests/platform/asound_state/byt/asound.state.line diff --git a/test/qa/tests/platform/asound_state/byt/asound.state.passthrough b/tools/test/qa/tests/platform/asound_state/byt/asound.state.passthrough similarity index 100% rename from test/qa/tests/platform/asound_state/byt/asound.state.passthrough rename to tools/test/qa/tests/platform/asound_state/byt/asound.state.passthrough diff --git a/test/qa/tests/platform/asound_state/byt/asound.state.pulse-c b/tools/test/qa/tests/platform/asound_state/byt/asound.state.pulse-c similarity index 100% rename from test/qa/tests/platform/asound_state/byt/asound.state.pulse-c rename to tools/test/qa/tests/platform/asound_state/byt/asound.state.pulse-c diff --git a/test/qa/tests/platform/asound_state/byt/asound.state.pulse-p b/tools/test/qa/tests/platform/asound_state/byt/asound.state.pulse-p similarity index 100% rename from test/qa/tests/platform/asound_state/byt/asound.state.pulse-p rename to tools/test/qa/tests/platform/asound_state/byt/asound.state.pulse-p diff --git a/test/qa/tests/platform/asound_state/byt/asound.state.volume b/tools/test/qa/tests/platform/asound_state/byt/asound.state.volume similarity index 100% rename from test/qa/tests/platform/asound_state/byt/asound.state.volume rename to tools/test/qa/tests/platform/asound_state/byt/asound.state.volume diff --git a/test/qa/tests/platform/byt/feature-test b/tools/test/qa/tests/platform/byt/feature-test similarity index 100% rename from test/qa/tests/platform/byt/feature-test rename to tools/test/qa/tests/platform/byt/feature-test diff --git a/test/qa/tests/platform/byt/minnow/feature-test b/tools/test/qa/tests/platform/byt/minnow/feature-test similarity index 100% rename from test/qa/tests/platform/byt/minnow/feature-test rename to tools/test/qa/tests/platform/byt/minnow/feature-test diff --git a/test/qa/tests/platform/byt/minnow/tplg b/tools/test/qa/tests/platform/byt/minnow/tplg similarity index 100% rename from test/qa/tests/platform/byt/minnow/tplg rename to tools/test/qa/tests/platform/byt/minnow/tplg diff --git a/test/qa/tests/platform/byt/tplg b/tools/test/qa/tests/platform/byt/tplg similarity index 100% rename from test/qa/tests/platform/byt/tplg rename to tools/test/qa/tests/platform/byt/tplg diff --git a/test/qa/tests/smoke_test/byt_smoke_test_48k16bit_passthrough.sh b/tools/test/qa/tests/smoke_test/byt_smoke_test_48k16bit_passthrough.sh similarity index 100% rename from test/qa/tests/smoke_test/byt_smoke_test_48k16bit_passthrough.sh rename to tools/test/qa/tests/smoke_test/byt_smoke_test_48k16bit_passthrough.sh diff --git a/test/qa/tests/stability_test/test_modules_reloadable.sh b/tools/test/qa/tests/stability_test/test_modules_reloadable.sh similarity index 100% rename from test/qa/tests/stability_test/test_modules_reloadable.sh rename to tools/test/qa/tests/stability_test/test_modules_reloadable.sh diff --git a/test/topology/Makefile.am b/tools/test/topology/Makefile.am similarity index 100% rename from test/topology/Makefile.am rename to tools/test/topology/Makefile.am diff --git a/test/topology/test-all.m4 b/tools/test/topology/test-all.m4 similarity index 100% rename from test/topology/test-all.m4 rename to tools/test/topology/test-all.m4 diff --git a/test/topology/test-capture.m4 b/tools/test/topology/test-capture.m4 similarity index 100% rename from test/topology/test-capture.m4 rename to tools/test/topology/test-capture.m4 diff --git a/test/topology/test-equalizer-playback-ssp.m4 b/tools/test/topology/test-equalizer-playback-ssp.m4 similarity index 100% rename from test/topology/test-equalizer-playback-ssp.m4 rename to tools/test/topology/test-equalizer-playback-ssp.m4 diff --git a/test/topology/test-playback.m4 b/tools/test/topology/test-playback.m4 similarity index 100% rename from test/topology/test-playback.m4 rename to tools/test/topology/test-playback.m4 diff --git a/test/topology/test-tone-playback.m4 b/tools/test/topology/test-tone-playback.m4 similarity index 100% rename from test/topology/test-tone-playback.m4 rename to tools/test/topology/test-tone-playback.m4 diff --git a/test/topology/tplg-build.sh b/tools/test/topology/tplg-build.sh similarity index 100% rename from test/topology/tplg-build.sh rename to tools/test/topology/tplg-build.sh diff --git a/topology/Makefile.am b/tools/topology/Makefile.am similarity index 100% rename from topology/Makefile.am rename to tools/topology/Makefile.am diff --git a/topology/common/Makefile.am b/tools/topology/common/Makefile.am similarity index 100% rename from topology/common/Makefile.am rename to tools/topology/common/Makefile.am diff --git a/topology/common/memory.m4 b/tools/topology/common/memory.m4 similarity index 100% rename from topology/common/memory.m4 rename to tools/topology/common/memory.m4 diff --git a/topology/common/tlv.m4 b/tools/topology/common/tlv.m4 similarity index 100% rename from topology/common/tlv.m4 rename to tools/topology/common/tlv.m4 diff --git a/topology/m4/Makefile.am b/tools/topology/m4/Makefile.am similarity index 100% rename from topology/m4/Makefile.am rename to tools/topology/m4/Makefile.am diff --git a/topology/m4/buffer.m4 b/tools/topology/m4/buffer.m4 similarity index 100% rename from topology/m4/buffer.m4 rename to tools/topology/m4/buffer.m4 diff --git a/topology/m4/bytecontrol.m4 b/tools/topology/m4/bytecontrol.m4 similarity index 100% rename from topology/m4/bytecontrol.m4 rename to tools/topology/m4/bytecontrol.m4 diff --git a/topology/m4/dai.m4 b/tools/topology/m4/dai.m4 similarity index 100% rename from topology/m4/dai.m4 rename to tools/topology/m4/dai.m4 diff --git a/topology/m4/debug.m4 b/tools/topology/m4/debug.m4 similarity index 100% rename from topology/m4/debug.m4 rename to tools/topology/m4/debug.m4 diff --git a/topology/m4/eq_fir.m4 b/tools/topology/m4/eq_fir.m4 similarity index 100% rename from topology/m4/eq_fir.m4 rename to tools/topology/m4/eq_fir.m4 diff --git a/topology/m4/eq_fir_coef_flat.m4 b/tools/topology/m4/eq_fir_coef_flat.m4 similarity index 100% rename from topology/m4/eq_fir_coef_flat.m4 rename to tools/topology/m4/eq_fir_coef_flat.m4 diff --git a/topology/m4/eq_iir.m4 b/tools/topology/m4/eq_iir.m4 similarity index 100% rename from topology/m4/eq_iir.m4 rename to tools/topology/m4/eq_iir.m4 diff --git a/topology/m4/eq_iir_coef_flat.m4 b/tools/topology/m4/eq_iir_coef_flat.m4 similarity index 100% rename from topology/m4/eq_iir_coef_flat.m4 rename to tools/topology/m4/eq_iir_coef_flat.m4 diff --git a/topology/m4/eq_iir_coef_highpass_50hz_20db_48khz.m4 b/tools/topology/m4/eq_iir_coef_highpass_50hz_20db_48khz.m4 similarity index 100% rename from topology/m4/eq_iir_coef_highpass_50hz_20db_48khz.m4 rename to tools/topology/m4/eq_iir_coef_highpass_50hz_20db_48khz.m4 diff --git a/topology/m4/hda.m4 b/tools/topology/m4/hda.m4 similarity index 100% rename from topology/m4/hda.m4 rename to tools/topology/m4/hda.m4 diff --git a/topology/m4/mixer.m4 b/tools/topology/m4/mixer.m4 similarity index 100% rename from topology/m4/mixer.m4 rename to tools/topology/m4/mixer.m4 diff --git a/topology/m4/mixercontrol.m4 b/tools/topology/m4/mixercontrol.m4 similarity index 100% rename from topology/m4/mixercontrol.m4 rename to tools/topology/m4/mixercontrol.m4 diff --git a/topology/m4/pcm.m4 b/tools/topology/m4/pcm.m4 similarity index 100% rename from topology/m4/pcm.m4 rename to tools/topology/m4/pcm.m4 diff --git a/topology/m4/pga.m4 b/tools/topology/m4/pga.m4 similarity index 100% rename from topology/m4/pga.m4 rename to tools/topology/m4/pga.m4 diff --git a/topology/m4/pipeline.m4 b/tools/topology/m4/pipeline.m4 similarity index 100% rename from topology/m4/pipeline.m4 rename to tools/topology/m4/pipeline.m4 diff --git a/topology/m4/src.m4 b/tools/topology/m4/src.m4 similarity index 100% rename from topology/m4/src.m4 rename to tools/topology/m4/src.m4 diff --git a/topology/m4/tone.m4 b/tools/topology/m4/tone.m4 similarity index 100% rename from topology/m4/tone.m4 rename to tools/topology/m4/tone.m4 diff --git a/topology/m4/utils.m4 b/tools/topology/m4/utils.m4 similarity index 100% rename from topology/m4/utils.m4 rename to tools/topology/m4/utils.m4 diff --git a/topology/platform/Makefile.am b/tools/topology/platform/Makefile.am similarity index 100% rename from topology/platform/Makefile.am rename to tools/topology/platform/Makefile.am diff --git a/topology/platform/common/Makefile.am b/tools/topology/platform/common/Makefile.am similarity index 100% rename from topology/platform/common/Makefile.am rename to tools/topology/platform/common/Makefile.am diff --git a/topology/platform/common/ssp.m4 b/tools/topology/platform/common/ssp.m4 similarity index 100% rename from topology/platform/common/ssp.m4 rename to tools/topology/platform/common/ssp.m4 diff --git a/topology/platform/intel/Makefile.am b/tools/topology/platform/intel/Makefile.am similarity index 100% rename from topology/platform/intel/Makefile.am rename to tools/topology/platform/intel/Makefile.am diff --git a/topology/platform/intel/bdw.m4 b/tools/topology/platform/intel/bdw.m4 similarity index 100% rename from topology/platform/intel/bdw.m4 rename to tools/topology/platform/intel/bdw.m4 diff --git a/topology/platform/intel/bxt.m4 b/tools/topology/platform/intel/bxt.m4 similarity index 100% rename from topology/platform/intel/bxt.m4 rename to tools/topology/platform/intel/bxt.m4 diff --git a/topology/platform/intel/byt.m4 b/tools/topology/platform/intel/byt.m4 similarity index 100% rename from topology/platform/intel/byt.m4 rename to tools/topology/platform/intel/byt.m4 diff --git a/topology/platform/intel/cht.m4 b/tools/topology/platform/intel/cht.m4 similarity index 100% rename from topology/platform/intel/cht.m4 rename to tools/topology/platform/intel/cht.m4 diff --git a/topology/platform/intel/cnl.m4 b/tools/topology/platform/intel/cnl.m4 similarity index 100% rename from topology/platform/intel/cnl.m4 rename to tools/topology/platform/intel/cnl.m4 diff --git a/topology/platform/intel/dmic.m4 b/tools/topology/platform/intel/dmic.m4 similarity index 100% rename from topology/platform/intel/dmic.m4 rename to tools/topology/platform/intel/dmic.m4 diff --git a/topology/platform/intel/hsw.m4 b/tools/topology/platform/intel/hsw.m4 similarity index 100% rename from topology/platform/intel/hsw.m4 rename to tools/topology/platform/intel/hsw.m4 diff --git a/topology/platform/intel/icl.m4 b/tools/topology/platform/intel/icl.m4 similarity index 100% rename from topology/platform/intel/icl.m4 rename to tools/topology/platform/intel/icl.m4 diff --git a/topology/sof-apl-da7219.m4 b/tools/topology/sof-apl-da7219.m4 similarity index 100% rename from topology/sof-apl-da7219.m4 rename to tools/topology/sof-apl-da7219.m4 diff --git a/topology/sof-apl-dmic-2ch.m4 b/tools/topology/sof-apl-dmic-2ch.m4 similarity index 100% rename from topology/sof-apl-dmic-2ch.m4 rename to tools/topology/sof-apl-dmic-2ch.m4 diff --git a/topology/sof-apl-dmic-4ch.m4 b/tools/topology/sof-apl-dmic-4ch.m4 similarity index 100% rename from topology/sof-apl-dmic-4ch.m4 rename to tools/topology/sof-apl-dmic-4ch.m4 diff --git a/topology/sof-apl-eq-dmic.m4 b/tools/topology/sof-apl-eq-dmic.m4 similarity index 100% rename from topology/sof-apl-eq-dmic.m4 rename to tools/topology/sof-apl-eq-dmic.m4 diff --git a/topology/sof-apl-eq-pcm512x.m4 b/tools/topology/sof-apl-eq-pcm512x.m4 similarity index 100% rename from topology/sof-apl-eq-pcm512x.m4 rename to tools/topology/sof-apl-eq-pcm512x.m4 diff --git a/topology/sof-apl-nocodec.m4 b/tools/topology/sof-apl-nocodec.m4 similarity index 100% rename from topology/sof-apl-nocodec.m4 rename to tools/topology/sof-apl-nocodec.m4 diff --git a/topology/sof-apl-pcm512x.m4 b/tools/topology/sof-apl-pcm512x.m4 similarity index 100% rename from topology/sof-apl-pcm512x.m4 rename to tools/topology/sof-apl-pcm512x.m4 diff --git a/topology/sof-apl-rt298.m4 b/tools/topology/sof-apl-rt298.m4 similarity index 100% rename from topology/sof-apl-rt298.m4 rename to tools/topology/sof-apl-rt298.m4 diff --git a/topology/sof-apl-tdf8532.m4 b/tools/topology/sof-apl-tdf8532.m4 similarity index 100% rename from topology/sof-apl-tdf8532.m4 rename to tools/topology/sof-apl-tdf8532.m4 diff --git a/topology/sof-apl-wm8804.m4 b/tools/topology/sof-apl-wm8804.m4 similarity index 100% rename from topology/sof-apl-wm8804.m4 rename to tools/topology/sof-apl-wm8804.m4 diff --git a/topology/sof-bdw-rt286.m4 b/tools/topology/sof-bdw-rt286.m4 similarity index 100% rename from topology/sof-bdw-rt286.m4 rename to tools/topology/sof-bdw-rt286.m4 diff --git a/topology/sof-bdw-rt5640.m4 b/tools/topology/sof-bdw-rt5640.m4 similarity index 100% rename from topology/sof-bdw-rt5640.m4 rename to tools/topology/sof-bdw-rt5640.m4 diff --git a/topology/sof-byt-da7213.m4 b/tools/topology/sof-byt-da7213.m4 similarity index 100% rename from topology/sof-byt-da7213.m4 rename to tools/topology/sof-byt-da7213.m4 diff --git a/topology/sof-byt-nocodec.m4 b/tools/topology/sof-byt-nocodec.m4 similarity index 100% rename from topology/sof-byt-nocodec.m4 rename to tools/topology/sof-byt-nocodec.m4 diff --git a/topology/sof-byt-rt5640.m4 b/tools/topology/sof-byt-rt5640.m4 similarity index 100% rename from topology/sof-byt-rt5640.m4 rename to tools/topology/sof-byt-rt5640.m4 diff --git a/topology/sof-byt-rt5645.m4 b/tools/topology/sof-byt-rt5645.m4 similarity index 100% rename from topology/sof-byt-rt5645.m4 rename to tools/topology/sof-byt-rt5645.m4 diff --git a/topology/sof-byt-rt5651.m4 b/tools/topology/sof-byt-rt5651.m4 similarity index 100% rename from topology/sof-byt-rt5651.m4 rename to tools/topology/sof-byt-rt5651.m4 diff --git a/topology/sof-cht-max98090.m4 b/tools/topology/sof-cht-max98090.m4 similarity index 100% rename from topology/sof-cht-max98090.m4 rename to tools/topology/sof-cht-max98090.m4 diff --git a/topology/sof-cht-nocodec.m4 b/tools/topology/sof-cht-nocodec.m4 similarity index 100% rename from topology/sof-cht-nocodec.m4 rename to tools/topology/sof-cht-nocodec.m4 diff --git a/topology/sof-cnl-rt274.m4 b/tools/topology/sof-cnl-rt274.m4 similarity index 100% rename from topology/sof-cnl-rt274.m4 rename to tools/topology/sof-cnl-rt274.m4 diff --git a/topology/sof-glk-da7219.m4 b/tools/topology/sof-glk-da7219.m4 similarity index 100% rename from topology/sof-glk-da7219.m4 rename to tools/topology/sof-glk-da7219.m4 diff --git a/topology/sof-hda-generic.m4 b/tools/topology/sof-hda-generic.m4 similarity index 100% rename from topology/sof-hda-generic.m4 rename to tools/topology/sof-hda-generic.m4 diff --git a/topology/sof-hsw-rt5640.m4 b/tools/topology/sof-hsw-rt5640.m4 similarity index 100% rename from topology/sof-hsw-rt5640.m4 rename to tools/topology/sof-hsw-rt5640.m4 diff --git a/topology/sof-icl-dmic-4ch.m4 b/tools/topology/sof-icl-dmic-4ch.m4 similarity index 100% rename from topology/sof-icl-dmic-4ch.m4 rename to tools/topology/sof-icl-dmic-4ch.m4 diff --git a/topology/sof-icl-nocodec.m4 b/tools/topology/sof-icl-nocodec.m4 similarity index 100% rename from topology/sof-icl-nocodec.m4 rename to tools/topology/sof-icl-nocodec.m4 diff --git a/topology/sof-whl-hda.m4 b/tools/topology/sof-whl-hda.m4 similarity index 100% rename from topology/sof-whl-hda.m4 rename to tools/topology/sof-whl-hda.m4 diff --git a/topology/sof/Makefile.am b/tools/topology/sof/Makefile.am similarity index 100% rename from topology/sof/Makefile.am rename to tools/topology/sof/Makefile.am diff --git a/topology/sof/pipe-dai-capture.m4 b/tools/topology/sof/pipe-dai-capture.m4 similarity index 100% rename from topology/sof/pipe-dai-capture.m4 rename to tools/topology/sof/pipe-dai-capture.m4 diff --git a/topology/sof/pipe-dai-playback.m4 b/tools/topology/sof/pipe-dai-playback.m4 similarity index 100% rename from topology/sof/pipe-dai-playback.m4 rename to tools/topology/sof/pipe-dai-playback.m4 diff --git a/topology/sof/pipe-eq-capture.m4 b/tools/topology/sof/pipe-eq-capture.m4 similarity index 100% rename from topology/sof/pipe-eq-capture.m4 rename to tools/topology/sof/pipe-eq-capture.m4 diff --git a/topology/sof/pipe-eq-fir-volume-playback.m4 b/tools/topology/sof/pipe-eq-fir-volume-playback.m4 similarity index 100% rename from topology/sof/pipe-eq-fir-volume-playback.m4 rename to tools/topology/sof/pipe-eq-fir-volume-playback.m4 diff --git a/topology/sof/pipe-eq-iir-volume-playback.m4 b/tools/topology/sof/pipe-eq-iir-volume-playback.m4 similarity index 100% rename from topology/sof/pipe-eq-iir-volume-playback.m4 rename to tools/topology/sof/pipe-eq-iir-volume-playback.m4 diff --git a/topology/sof/pipe-eq-volume-playback.m4 b/tools/topology/sof/pipe-eq-volume-playback.m4 similarity index 100% rename from topology/sof/pipe-eq-volume-playback.m4 rename to tools/topology/sof/pipe-eq-volume-playback.m4 diff --git a/topology/sof/pipe-low-latency-capture.m4 b/tools/topology/sof/pipe-low-latency-capture.m4 similarity index 100% rename from topology/sof/pipe-low-latency-capture.m4 rename to tools/topology/sof/pipe-low-latency-capture.m4 diff --git a/topology/sof/pipe-low-latency-playback.m4 b/tools/topology/sof/pipe-low-latency-playback.m4 similarity index 100% rename from topology/sof/pipe-low-latency-playback.m4 rename to tools/topology/sof/pipe-low-latency-playback.m4 diff --git a/topology/sof/pipe-passthrough-capture.m4 b/tools/topology/sof/pipe-passthrough-capture.m4 similarity index 100% rename from topology/sof/pipe-passthrough-capture.m4 rename to tools/topology/sof/pipe-passthrough-capture.m4 diff --git a/topology/sof/pipe-passthrough-playback.m4 b/tools/topology/sof/pipe-passthrough-playback.m4 similarity index 100% rename from topology/sof/pipe-passthrough-playback.m4 rename to tools/topology/sof/pipe-passthrough-playback.m4 diff --git a/topology/sof/pipe-pcm-media.m4 b/tools/topology/sof/pipe-pcm-media.m4 similarity index 100% rename from topology/sof/pipe-pcm-media.m4 rename to tools/topology/sof/pipe-pcm-media.m4 diff --git a/topology/sof/pipe-src-capture.m4 b/tools/topology/sof/pipe-src-capture.m4 similarity index 100% rename from topology/sof/pipe-src-capture.m4 rename to tools/topology/sof/pipe-src-capture.m4 diff --git a/topology/sof/pipe-src-playback.m4 b/tools/topology/sof/pipe-src-playback.m4 similarity index 100% rename from topology/sof/pipe-src-playback.m4 rename to tools/topology/sof/pipe-src-playback.m4 diff --git a/topology/sof/pipe-tone.m4 b/tools/topology/sof/pipe-tone.m4 similarity index 100% rename from topology/sof/pipe-tone.m4 rename to tools/topology/sof/pipe-tone.m4 diff --git a/topology/sof/pipe-volume-capture.m4 b/tools/topology/sof/pipe-volume-capture.m4 similarity index 100% rename from topology/sof/pipe-volume-capture.m4 rename to tools/topology/sof/pipe-volume-capture.m4 diff --git a/topology/sof/pipe-volume-playback.m4 b/tools/topology/sof/pipe-volume-playback.m4 similarity index 100% rename from topology/sof/pipe-volume-playback.m4 rename to tools/topology/sof/pipe-volume-playback.m4 diff --git a/topology/sof/tokens.m4 b/tools/topology/sof/tokens.m4 similarity index 100% rename from topology/sof/tokens.m4 rename to tools/topology/sof/tokens.m4 diff --git a/tune/eq/eq_align.m b/tools/tune/eq/eq_align.m similarity index 100% rename from tune/eq/eq_align.m rename to tools/tune/eq/eq_align.m diff --git a/tune/eq/eq_alsactl_write.m b/tools/tune/eq/eq_alsactl_write.m similarity index 100% rename from tune/eq/eq_alsactl_write.m rename to tools/tune/eq/eq_alsactl_write.m diff --git a/tune/eq/eq_blob_write.m b/tools/tune/eq/eq_blob_write.m similarity index 100% rename from tune/eq/eq_blob_write.m rename to tools/tune/eq/eq_blob_write.m diff --git a/tune/eq/eq_coef_quant.m b/tools/tune/eq/eq_coef_quant.m similarity index 100% rename from tune/eq/eq_coef_quant.m rename to tools/tune/eq/eq_coef_quant.m diff --git a/tune/eq/eq_compute.m b/tools/tune/eq/eq_compute.m similarity index 100% rename from tune/eq/eq_compute.m rename to tools/tune/eq/eq_compute.m diff --git a/tune/eq/eq_compute_response.m b/tools/tune/eq/eq_compute_response.m similarity index 100% rename from tune/eq/eq_compute_response.m rename to tools/tune/eq/eq_compute_response.m diff --git a/tune/eq/eq_compute_tot_response.m b/tools/tune/eq/eq_compute_tot_response.m similarity index 100% rename from tune/eq/eq_compute_tot_response.m rename to tools/tune/eq/eq_compute_tot_response.m diff --git a/tune/eq/eq_defaults.m b/tools/tune/eq/eq_defaults.m similarity index 100% rename from tune/eq/eq_defaults.m rename to tools/tune/eq/eq_defaults.m diff --git a/tune/eq/eq_define_parametric_eq.m b/tools/tune/eq/eq_define_parametric_eq.m similarity index 100% rename from tune/eq/eq_define_parametric_eq.m rename to tools/tune/eq/eq_define_parametric_eq.m diff --git a/tune/eq/eq_fir_blob_merge.m b/tools/tune/eq/eq_fir_blob_merge.m similarity index 100% rename from tune/eq/eq_fir_blob_merge.m rename to tools/tune/eq/eq_fir_blob_merge.m diff --git a/tune/eq/eq_fir_blob_pack.m b/tools/tune/eq/eq_fir_blob_pack.m similarity index 100% rename from tune/eq/eq_fir_blob_pack.m rename to tools/tune/eq/eq_fir_blob_pack.m diff --git a/tune/eq/eq_fir_blob_quant.m b/tools/tune/eq/eq_fir_blob_quant.m similarity index 100% rename from tune/eq/eq_fir_blob_quant.m rename to tools/tune/eq/eq_fir_blob_quant.m diff --git a/tune/eq/eq_iir_blob_merge.m b/tools/tune/eq/eq_iir_blob_merge.m similarity index 100% rename from tune/eq/eq_iir_blob_merge.m rename to tools/tune/eq/eq_iir_blob_merge.m diff --git a/tune/eq/eq_iir_blob_pack.m b/tools/tune/eq/eq_iir_blob_pack.m similarity index 100% rename from tune/eq/eq_iir_blob_pack.m rename to tools/tune/eq/eq_iir_blob_pack.m diff --git a/tune/eq/eq_iir_blob_quant.m b/tools/tune/eq/eq_iir_blob_quant.m similarity index 100% rename from tune/eq/eq_iir_blob_quant.m rename to tools/tune/eq/eq_iir_blob_quant.m diff --git a/tune/eq/eq_norm.m b/tools/tune/eq/eq_norm.m similarity index 100% rename from tune/eq/eq_norm.m rename to tools/tune/eq/eq_norm.m diff --git a/tune/eq/eq_plot.m b/tools/tune/eq/eq_plot.m similarity index 100% rename from tune/eq/eq_plot.m rename to tools/tune/eq/eq_plot.m diff --git a/tune/eq/eq_tplg_write.m b/tools/tune/eq/eq_tplg_write.m similarity index 100% rename from tune/eq/eq_tplg_write.m rename to tools/tune/eq/eq_tplg_write.m diff --git a/tune/eq/example_fir_eq.m b/tools/tune/eq/example_fir_eq.m similarity index 100% rename from tune/eq/example_fir_eq.m rename to tools/tune/eq/example_fir_eq.m diff --git a/tune/eq/example_iir_eq.m b/tools/tune/eq/example_iir_eq.m similarity index 100% rename from tune/eq/example_iir_eq.m rename to tools/tune/eq/example_iir_eq.m diff --git a/tune/eq/example_spk_eq.m b/tools/tune/eq/example_spk_eq.m similarity index 100% rename from tune/eq/example_spk_eq.m rename to tools/tune/eq/example_spk_eq.m diff --git a/tune/eq/mls_freq_resp.m b/tools/tune/eq/mls_freq_resp.m similarity index 100% rename from tune/eq/mls_freq_resp.m rename to tools/tune/eq/mls_freq_resp.m diff --git a/tune/eq/mls_play_config.txt b/tools/tune/eq/mls_play_config.txt similarity index 100% rename from tune/eq/mls_play_config.txt rename to tools/tune/eq/mls_play_config.txt diff --git a/tune/eq/mls_rec_config.txt b/tools/tune/eq/mls_rec_config.txt similarity index 100% rename from tune/eq/mls_rec_config.txt rename to tools/tune/eq/mls_rec_config.txt diff --git a/tune/src/README b/tools/tune/src/README similarity index 100% rename from tune/src/README rename to tools/tune/src/README diff --git a/tune/src/src_export_coef.m b/tools/tune/src/src_export_coef.m similarity index 100% rename from tune/src/src_export_coef.m rename to tools/tune/src/src_export_coef.m diff --git a/tune/src/src_export_defines.m b/tools/tune/src/src_export_defines.m similarity index 100% rename from tune/src/src_export_defines.m rename to tools/tune/src/src_export_defines.m diff --git a/tune/src/src_export_table_2s.m b/tools/tune/src/src_export_table_2s.m similarity index 100% rename from tune/src/src_export_table_2s.m rename to tools/tune/src/src_export_table_2s.m diff --git a/tune/src/src_factor1_lm.m b/tools/tune/src/src_factor1_lm.m similarity index 100% rename from tune/src/src_factor1_lm.m rename to tools/tune/src/src_factor1_lm.m diff --git a/tune/src/src_factor2_lm.m b/tools/tune/src/src_factor2_lm.m similarity index 100% rename from tune/src/src_factor2_lm.m rename to tools/tune/src/src_factor2_lm.m diff --git a/tune/src/src_find_l0m0.m b/tools/tune/src/src_find_l0m0.m similarity index 100% rename from tune/src/src_find_l0m0.m rename to tools/tune/src/src_find_l0m0.m diff --git a/tune/src/src_generate.m b/tools/tune/src/src_generate.m similarity index 100% rename from tune/src/src_generate.m rename to tools/tune/src/src_generate.m diff --git a/tune/src/src_get.m b/tools/tune/src/src_get.m similarity index 100% rename from tune/src/src_get.m rename to tools/tune/src/src_get.m diff --git a/tune/src/src_param.m b/tools/tune/src/src_param.m similarity index 100% rename from tune/src/src_param.m rename to tools/tune/src/src_param.m diff --git a/tune/src/src_std_int32.m b/tools/tune/src/src_std_int32.m similarity index 100% rename from tune/src/src_std_int32.m rename to tools/tune/src/src_std_int32.m diff --git a/tune/src/src_tiny_int16.m b/tools/tune/src/src_tiny_int16.m similarity index 100% rename from tune/src/src_tiny_int16.m rename to tools/tune/src/src_tiny_int16.m From f8e3b126e1a8e0e738b27c17db2c332280c05c0e Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 24 Nov 2018 23:30:33 -0800 Subject: [PATCH 323/324] Adjust tools build script for new path Signed-off-by: Curtis Malainey --- scripts/{build-soft.sh => build-tools.sh} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename scripts/{build-soft.sh => build-tools.sh} (63%) diff --git a/scripts/build-soft.sh b/scripts/build-tools.sh similarity index 63% rename from scripts/build-soft.sh rename to scripts/build-tools.sh index 0756cc54ba38..e6fbae078ce2 100755 --- a/scripts/build-soft.sh +++ b/scripts/build-tools.sh @@ -1,6 +1,6 @@ #!/bin/sh -cd ../soft.git +cd tools ./autogen.sh ./configure make -j$(nproc) -cd ../sof.git +cd ../ From c0c8172535359da5cab781d75982aa60032578c5 Mon Sep 17 00:00:00 2001 From: Curtis Malainey Date: Sat, 24 Nov 2018 23:38:51 -0800 Subject: [PATCH 324/324] Update Docker README for SOFT merge Signed-off-by: Curtis Malainey --- scripts/README.docker | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/README.docker b/scripts/README.docker index 468ae251fb77..76b727f67041 100644 --- a/scripts/README.docker +++ b/scripts/README.docker @@ -26,8 +26,8 @@ To build for baytrail: or (may need password test0000 for rimage install) ./scripts/docker-run.sh ./scripts/xtensa-build-all.sh byt -To rebuild the topology in soft.git: -./scripts/docker-run.sh ./scripts/build-soft.sh +To rebuild the topology and logger: +./scripts/docker-run.sh ./scripts/build-tools.sh An incremental sof.git build: ./scripts/docker-run.sh make