mailman.alsa-project.org
Sign In Sign Up
Manage this list Sign In Sign Up

Keyboard Shortcuts

Thread View

  • j: Next unread message
  • k: Previous unread message
  • j a: Jump to all threads
  • j l: Jump to MailingList overview

Sound-open-firmware

Thread Start a new thread
Download
Threads by month
  • ----- 2025 -----
  • May
  • April
  • March
  • February
  • January
  • ----- 2024 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2023 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2022 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2021 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2020 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2019 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2018 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2017 -----
  • December
  • November
  • October
  • September
  • August
  • July
  • June
  • May
  • April
  • March
  • February
  • January
  • ----- 2016 -----
  • December
  • November
  • October
sound-open-firmware@alsa-project.org

April 2018

  • 14 participants
  • 55 discussions
[Sound-open-firmware] [PATCH] apl-ssp: fix padding bit issues in I2S/LEFT_J mode
by Pierre-Louis Bossart 13 Apr '18

13 Apr '18
The current code doesn't work for I2S/LEFT_J when the slot width and number of valid bits don't match (e.g. 24 bit data in 32-bit slot). In I2S/LEFT_J mode, the padding is not at the end of the frame but at the end of each slot, and is evenly distributed between the two left and right phases. Fix by using DMYSTOP for I2S/LEFT_J, and only program SSPSP2 for DSP_A and DSP_B modes Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart(a)linux.intel.com> --- src/drivers/apl-ssp.c | 79 ++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 16 deletions(-) diff --git a/src/drivers/apl-ssp.c b/src/drivers/apl-ssp.c index a02d934..3a97cb8 100644 --- a/src/drivers/apl-ssp.c +++ b/src/drivers/apl-ssp.c @@ -107,6 +107,7 @@ static inline int ssp_set_config(struct dai *dai, uint32_t data_size; uint32_t start_delay; uint32_t frame_end_padding; + uint32_t slot_end_padding; uint32_t frame_len = 0; uint32_t bdiv_min; uint32_t tft; @@ -299,6 +300,20 @@ static inline int ssp_set_config(struct dai *dai, goto out; } + bdiv_min = config->ssp.tdm_slots * config->ssp.sample_valid_bits; + if (bdiv < bdiv_min) { + trace_ssp_error("ecc"); + ret = -EINVAL; + goto out; + } + + frame_end_padding = bdiv - bdiv_min; + if (frame_end_padding > SSPSP2_FEP_MASK) { + trace_ssp_error("ecd"); + ret = -EINVAL; + goto out; + } + /* format */ switch (config->format & SOF_DAI_FMT_FORMAT_MASK) { case SOF_DAI_FMT_I2S: @@ -325,6 +340,28 @@ static inline int ssp_set_config(struct dai *dai, sspsp |= SSPSP_SFRMP(inverted_frame); sspsp |= SSPSP_FSRT; + /* + * for I2S/LEFT_J, the padding has to happen at the end + * of each slot + */ + if (frame_end_padding % 2) { + trace_ssp_error("ece"); + ret = -EINVAL; + goto out; + } + + slot_end_padding = frame_end_padding / 2; + + if (slot_end_padding > 15) { + /* can't handle padding over 15 bits */ + trace_ssp_error("ecf"); + ret = -EINVAL; + goto out; + } + + sspsp |= SSPSP_EDMYSTOP((slot_end_padding >> 2) & 0x3); + sspsp |= SSPSP_DMYSTOP(slot_end_padding & 0x3); + break; case SOF_DAI_FMT_LEFT_J: @@ -353,6 +390,28 @@ static inline int ssp_set_config(struct dai *dai, */ sspsp |= SSPSP_SFRMP(!inverted_frame); + /* + * for I2S/LEFT_J, the padding has to happen at the end + * of each slot + */ + if (frame_end_padding % 2) { + trace_ssp_error("ecg"); + ret = -EINVAL; + goto out; + } + + slot_end_padding = frame_end_padding / 2; + + if (slot_end_padding > 15) { + /* can't handle padding over 15 bits */ + trace_ssp_error("ech"); + ret = -EINVAL; + goto out; + } + + sspsp |= SSPSP_EDMYSTOP((slot_end_padding >> 2) & 0x3); + sspsp |= SSPSP_DMYSTOP(slot_end_padding & 0x3); + break; case SOF_DAI_FMT_DSP_A: @@ -375,6 +434,8 @@ static inline int ssp_set_config(struct dai *dai, active_tx_slots = hweight_32(config->ssp.tx_slots); active_rx_slots = hweight_32(config->ssp.rx_slots); + sspsp2 |= (frame_end_padding & SSPSP2_FEP_MASK); + break; case SOF_DAI_FMT_DSP_B: @@ -396,6 +457,8 @@ static inline int ssp_set_config(struct dai *dai, active_tx_slots = hweight_32(config->ssp.tx_slots); active_rx_slots = hweight_32(config->ssp.rx_slots); + sspsp2 |= (frame_end_padding & SSPSP2_FEP_MASK); + break; default: trace_ssp_error("eca"); @@ -406,22 +469,6 @@ static inline int ssp_set_config(struct dai *dai, sspsp |= SSPSP_STRTDLY(start_delay); sspsp |= SSPSP_SFRMWDTH(frame_len); - bdiv_min = config->ssp.tdm_slots * config->ssp.sample_valid_bits; - if (bdiv < bdiv_min) { - trace_ssp_error("ecc"); - ret = -EINVAL; - goto out; - } - - frame_end_padding = bdiv - bdiv_min; - if (frame_end_padding > SSPSP2_FEP_MASK) { - trace_ssp_error("ecd"); - ret = -EINVAL; - goto out; - } - - sspsp2 |= (frame_end_padding & SSPSP2_FEP_MASK); - data_size = config->ssp.sample_valid_bits; if (data_size > 16) -- 2.14.1
3 4
0 0
[Sound-open-firmware] [PATCH] configure: check for doxygen and graphviz to build docs
by Liam Girdwood 13 Apr '18

13 Apr '18
Documentation needs doxygen and graphviz so warn if they are not installed. Signed-off-by: Liam Girdwood <liam.r.girdwood(a)linux.intel.com> --- configure.ac | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/configure.ac b/configure.ac index 2765f0e4..d67c1546 100644 --- a/configure.ac +++ b/configure.ac @@ -327,6 +327,16 @@ 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) +# Check for doxygen and graphviz - used by make doc +AC_CHECK_PROG(have_doxygen, doxygen, true, false) +if test "$have_doxygen" = "false"; then + AC_MSG_WARN([Need doxygen to build documentation]) +fi +AC_CHECK_PROG(have_graphviz, dot, true, false) +if test "$have_graphviz" = "false"; then + AC_MSG_WARN([Need graphviz to build documentation]) +fi + AM_EXTRA_RECURSIVE_TARGETS([bin]) AM_EXTRA_RECURSIVE_TARGETS([vminstall]) -- 2.14.1
1 0
0 0
[Sound-open-firmware] [PATCH] apl-ssp: allow for 19.2 MHz SSP reference
by Pierre-Louis Bossart 13 Apr '18

13 Apr '18
Don't hard-code MCLK source on ApolloLake, use settings provided over IPC to select 24.576 MHz PLL or 19.2 MHz XTAL oscillator. Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart(a)linux.intel.com> --- src/drivers/apl-ssp.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/drivers/apl-ssp.c b/src/drivers/apl-ssp.c index 3a97cb8..8f9bc14 100644 --- a/src/drivers/apl-ssp.c +++ b/src/drivers/apl-ssp.c @@ -479,7 +479,17 @@ static inline int ssp_set_config(struct dai *dai, #ifdef CONFIG_CANNONLAKE mdivc = 0x1; #else - mdivc = 0x00100001; + if (config->ssp.mclk_rate == 24576000) { + /* enable PLL, bypass M/N dividers */ + mdivc = 0x00100001; + } else if (config->ssp.mclk_rate == 19200000) { + /* no PLL, use XTAl oscillator as source */ + mdivc = 0; + } else { + trace_ssp_error("eci"); + ret = -EINVAL; + goto out; + } #endif /* bypass divider for MCLK */ mdivr = 0x00000fff; -- 2.14.1
2 2
0 0
[Sound-open-firmware] [PATCH] Makefile support for doc target.
by Liam Girdwood 13 Apr '18

13 Apr '18
From: Marcin Maka <marcin.maka(a)linux.intel.com> Builds uapi documentation in html format using doxygen. See doc/sof_uapi/html/index.html First dox samples in the source code provided by the patch. Signed-off-by: Marcin Maka <marcin.maka(a)linux.intel.com> --- .gitignore | 2 ++ Makefile.am | 7 ++++++- configure.ac | 1 + doc/Makefile.am | 10 ++++++++++ doc/sof_uapi.doxygen.in | 33 +++++++++++++++++++++++++++++++++ src/include/uapi/abi.h | 30 ++++++++++++++++++++---------- src/include/uapi/ipc.h | 17 ++++++++++++----- src/include/uapi/manifest.h | 15 ++++++++++++++- 8 files changed, 98 insertions(+), 17 deletions(-) create mode 100644 doc/Makefile.am create mode 100644 doc/sof_uapi.doxygen.in diff --git a/.gitignore b/.gitignore index 4c5b67bc..c03c83ef 100644 --- a/.gitignore +++ b/.gitignore @@ -37,6 +37,8 @@ m4/lt* m4/libtool.m4 libtool src/include/version.h +doc/sof_uapi +*.doxygen autom4te* config.* diff --git a/Makefile.am b/Makefile.am index 1e4de766..ee8df72b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ if BUILD_RIMAGE SUBDIRS = rimage else -SUBDIRS = src +SUBDIRS = doc src endif ACLOCAL_AMFLAGS = -I m4 @@ -39,5 +39,10 @@ dist-hook: cat .version > $(distdir)/.tarball-version cat .version > $(distdir)/.version +doc-dummy: + +doc: doc-dummy + $(MAKE) -C doc doc + all-local: rm -f $(top_srcdir)/src/include/version.h diff --git a/configure.ac b/configure.ac index 6bd1323c..2765f0e4 100644 --- a/configure.ac +++ b/configure.ac @@ -335,6 +335,7 @@ AC_CONFIG_FILES([ Makefile rimage/Makefile rimage/keys/Makefile + doc/Makefile src/Makefile src/tasks/Makefile src/init/Makefile diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 00000000..200c55bc --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,10 @@ +EXTRA_DIST=sof_uapi.doxygen + +AM_CPPFLAGS=-I$(top_srcdir)/include + +doc: + test -e sof_uapi.doxygen || sed s:[@]top_srcdir[@]:..:g sof_uapi.doxygen.in > sof_uapi.doxygen + doxygen sof_uapi.doxygen + +doc-clean: + rm -rf $(top_srcdir)/doc/sof_uapi/* diff --git a/doc/sof_uapi.doxygen.in b/doc/sof_uapi.doxygen.in new file mode 100644 index 00000000..74052f1a --- /dev/null +++ b/doc/sof_uapi.doxygen.in @@ -0,0 +1,33 @@ +PROJECT_NAME = "Sound Open Firmware" +OUTPUT_DIRECTORY = sof_uapi +GENERATE_LATEX = NO +GENERATE_RTF = NO +GENERATE_MAN = NO +GENERATE_XML = YES + +CASE_SENSE_NAMES = NO +INPUT = @top_srcdir@/src/include/uapi +EXCLUDE = +RECURSIVE = YES +FILE_PATTERNS = *.c *.h +EXAMPLE_PATH = ../test +IMAGE_PATH = +QUIET = YES + +EXTRACT_ALL = NO +EXTRACT_STATIC = NO +SHOW_INCLUDE_FILES = NO +JAVADOC_AUTOBRIEF = NO +INHERIT_DOCS = YES +ENABLED_SECTIONS = "" +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = YES +PREDEFINED = + +OPTIMIZE_OUTPUT_FOR_C = YES +TYPEDEF_HIDES_STRUCT = YES + +#INPUT_FILTER = inputfilter +#FILTER_SOURCE_FILES = YES + +HTML_TIMESTAMP = NO diff --git a/src/include/uapi/abi.h b/src/include/uapi/abi.h index 8b700a89..cb28aea4 100644 --- a/src/include/uapi/abi.h +++ b/src/include/uapi/abi.h @@ -28,24 +28,34 @@ * Author: Liam Girdwood <liam.r.girdwood(a)linux.intel.com> */ +/** + * \file include/uapi/abi.h + * \brief ABI definitions + * \author Liam Girdwood <liam.r.girdwood(a)linux.intel.com> + */ + #ifndef __INCLUDE_UAPI_ABI_H__ #define __INCLUDE_UAPI_ABI_H__ +/** \brief SOF ABI version number. */ #define SOF_ABI_VERSION 1 -#define SOF_ABI_MAGIC 0x00464F53 /* "SOF\0" */ -/* - * Header for all non IPC ABI data. Identifies data type, size and ABI. +/** \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 excluding this struct */ - uint32_t abi; /* SOF ABI version */ - uint32_t comp_abi; /* component specific ABI version */ - char data[0]; + 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/src/include/uapi/ipc.h b/src/include/uapi/ipc.h index 396a3c49..7d0a9a44 100644 --- a/src/include/uapi/ipc.h +++ b/src/include/uapi/ipc.h @@ -29,6 +29,13 @@ * Keyon Jie <yang.jie(a)linux.intel.com> */ +/** + * \file include/uapi/ipc.h + * \brief IPC definitions + * \author Liam Girdwood <liam.r.girdwood(a)linux.intel.com> + * \author Keyon Jie <yang.jie(a)linux.intel.com> + */ + #ifndef __INCLUDE_UAPI_IPC_H__ #define __INCLUDE_UAPI_IPC_H__ @@ -219,12 +226,12 @@ struct sof_ipc_compound_hdr { #define SOF_DAI_FMT_INV_MASK 0x0f00 #define SOF_DAI_FMT_MASTER_MASK 0xf000 -/* types of DAI */ +/** \brief Types of DAI */ enum sof_ipc_dai_type { - SOF_DAI_INTEL_NONE = 0, - SOF_DAI_INTEL_SSP, - SOF_DAI_INTEL_DMIC, - SOF_DAI_INTEL_HDA, + 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 */ diff --git a/src/include/uapi/manifest.h b/src/include/uapi/manifest.h index f53a6628..c1dce92f 100644 --- a/src/include/uapi/manifest.h +++ b/src/include/uapi/manifest.h @@ -28,6 +28,12 @@ * Author: Liam Girdwood <liam.r.girdwood(a)linux.intel.com> */ +/** + * \file include/uapi/ipc.h + * \brief FW Image Manifest definitions. + * \author Liam Girdwood <liam.r.girdwood(a)linux.intel.com> + */ + #ifndef SOF_UAPI_MANIFEST_H #define SOF_UAPI_MANIFEST_H @@ -211,7 +217,14 @@ struct sof_man_module_manifest { uint32_t text_size; }; -/* utility to get module pointer from position */ +/** + * \brief Utility to get module pointer from position. + * \param [in,out] desc FW descriptor in manifest. + * \param [in] index Index of the module. + * \return Pointer to module descriptor. + * + * Note that index is not verified against OOB. + */ static inline struct sof_man_module *sof_man_get_module( struct sof_man_fw_desc *desc, int index) { -- 2.14.1
1 0
0 0
[Sound-open-firmware] [PATCH] library: fix errors with host library build
by Ranjani Sridharan 13 Apr '18

13 Apr '18
This patch fixes compilation errors in host libary build due to missing header file and changes in mailbox defs. Signed-off-by: Ranjani Sridharan <ranjani.sridharan(a)linux.intel.com> --- src/arch/host/include/arch/sof.h | 3 --- src/arch/host/include/arch/string.h | 40 ++++++++++++++++++++++++++++++++++ src/library/include/platform/mailbox.h | 22 +++++++++---------- src/library/include/platform/memory.h | 3 ++- 4 files changed, 53 insertions(+), 15 deletions(-) create mode 100644 src/arch/host/include/arch/string.h diff --git a/src/arch/host/include/arch/sof.h b/src/arch/host/include/arch/sof.h index 75d0b25..ce2bd69 100644 --- a/src/arch/host/include/arch/sof.h +++ b/src/arch/host/include/arch/sof.h @@ -42,9 +42,6 @@ /* architecture specific stack frames to dump */ #define ARCH_STACK_DUMP_FRAMES 32 -#define arch_memcpy(dest, src, size) \ - memcpy(dest, src, size) - static inline void *arch_get_stack_ptr(void) { void *frames[ARCH_STACK_DUMP_FRAMES]; diff --git a/src/arch/host/include/arch/string.h b/src/arch/host/include/arch/string.h new file mode 100644 index 0000000..56258b3 --- /dev/null +++ b/src/arch/host/include/arch/string.h @@ -0,0 +1,40 @@ +/* + * 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: Liam Girdwood <liam.r.girdwood(a)linux.intel.com> + * + */ + +#ifndef __INCLUDE_ARCH_STRING_SOF__ +#define __INCLUDE_ARCH_STRING_SOF__ + +void *xthal_memcpy(void *dst, const void *src, size_t len); + +#define arch_memcpy(dest, src, size) \ + xthal_memcpy(dest, src, size) + +#endif diff --git a/src/library/include/platform/mailbox.h b/src/library/include/platform/mailbox.h index 650ab47..b03887e 100644 --- a/src/library/include/platform/mailbox.h +++ b/src/library/include/platform/mailbox.h @@ -28,25 +28,25 @@ * Author: Liam Girdwood <liam.r.girdwood(a)linux.intel.com> */ -#ifndef __INCLUDE_PLATFORM_HOST_MAILBOX__ -#define __INCLUDE_PLATFORM_HOST_MAILBOX__ +#ifndef __INCLUDE_PLATFORM_MAILBOX__ +#define __INCLUDE_PLATFORM_MAILBOX__ #include <platform/memory.h> #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_DSPBOX_OFFSET 0x0 +#define MAILBOX_DSPBOX_SIZE 0x400 +#define MAILBOX_DSPBOX_BASE \ + (MAILBOX_BASE + MAILBOX_DSPBOX_OFFSET) -#define MAILBOX_INBOX_OFFSET MAILBOX_OUTBOX_SIZE -#define MAILBOX_INBOX_SIZE 0x400 -#define MAILBOX_INBOX_BASE \ - (MAILBOX_BASE + MAILBOX_INBOX_OFFSET) +#define MAILBOX_HOSTBOX_OFFSET MAILBOX_DSPBOX_SIZE +#define MAILBOX_HOSTBOX_SIZE 0x400 +#define MAILBOX_HOSTBOX_BASE \ + (MAILBOX_BASE + MAILBOX_HOSTBOX_OFFSET) #define MAILBOX_EXCEPTION_OFFSET \ - (MAILBOX_INBOX_SIZE + MAILBOX_OUTBOX_SIZE) + (MAILBOX_HOSTBOX_SIZE + MAILBOX_DSPBOX_SIZE) #define MAILBOX_EXCEPTION_SIZE 0x100 #define MAILBOX_EXCEPTION_BASE \ (MAILBOX_BASE + MAILBOX_EXCEPTION_OFFSET) diff --git a/src/library/include/platform/memory.h b/src/library/include/platform/memory.h index ed7de10..00a9ad2 100644 --- a/src/library/include/platform/memory.h +++ b/src/library/include/platform/memory.h @@ -41,6 +41,8 @@ #define PLATFORM_HEAP_RUNTIME 1 #define PLATFORM_HEAP_BUFFER 3 +#define MAILBOX_BASE 0xFF344000 + #if 0 /* physical DSP addresses */ @@ -51,7 +53,6 @@ #define DRAM0_SIZE 0x00028000 #define DRAM0_VBASE 0xC0000000 -#define MAILBOX_BASE (DRAM0_BASE + DRAM0_SIZE - 0x2000) /* HEAP Constants - WARNING this MUST be aligned with the linker script */ -- 2.14.1
1 1
0 0
[Sound-open-firmware] [PATCH] uapi: ipc: Add executable memory flag
by Liam Girdwood 12 Apr '18

12 Apr '18
Add flag to mark memory as executable. Signed-off-by: Liam Girdwood <liam.r.girdwood(a)linux.intel.com> --- src/include/uapi/ipc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/uapi/ipc.h b/src/include/uapi/ipc.h index fbf1c072..396a3c49 100644 --- a/src/include/uapi/ipc.h +++ b/src/include/uapi/ipc.h @@ -151,6 +151,7 @@ #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. -- 2.14.1
1 0
0 0
[Sound-open-firmware] [PATCH] rimage: add support to build and sign runtime modules
by Liam Girdwood 12 Apr '18

12 Apr '18
Currently rimage only supports building ELF images with know TEXT, DATA and BSS addresses. This patch adds support to build runtime relocatable modules that can be loaded linked into the base SOF FW at runtime. Signed-off-by: Liam Girdwood <liam.r.girdwood(a)linux.intel.com> --- rimage/elf.c | 72 +++++++++++++++++++++++++++++++++----- rimage/file_simple.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++- rimage/manifest.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++-- rimage/rimage.c | 9 +++-- rimage/rimage.h | 4 +++ 5 files changed, 266 insertions(+), 13 deletions(-) diff --git a/rimage/elf.c b/rimage/elf.c index b1a1861b..6c7e3dae 100644 --- a/rimage/elf.c +++ b/rimage/elf.c @@ -283,6 +283,42 @@ static void elf_module_size(struct image *image, struct module *module, } } +static void elf_module_size_reloc(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 */ + module->text_start = 0; + module->text_end += section->sh_size; + + fprintf(stdout, "\tTEXT\t"); + } else { + /* initialized data, also calc the writable sections */ + module->data_start = 0; + module->data_end += section->sh_size; + + fprintf(stdout, "\tDATA\t"); + } + 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\t"); + } else { + fprintf(stdout, "\tHEAP\t"); + } + break; + default: + break; + } +} + static void elf_module_limits(struct image *image, struct module *module) { Elf32_Shdr *section; @@ -302,22 +338,29 @@ static void elf_module_limits(struct image *image, struct module *module) section = &module->section[i]; - /* only check valid sections */ - if (!(section->sh_flags & valid)) - continue; + /* module bss can sometimes be missed */ + if (i != module->bss_index) { - if (section->sh_size == 0) - continue; + /* only check valid sections */ + if (!(section->sh_flags & valid)) + continue; - if (elf_is_rom(image, section)) - 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); + if (image->reloc) + elf_module_size_reloc(image, module, section, i); + else + elf_module_size(image, module, section, i); /* section name */ fprintf(stdout, "%s\n", module->strings + section->sh_name); @@ -388,6 +431,10 @@ int elf_validate_modules(struct image *image) uint32_t valid = (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR); int i, j, ret; + /* relocatable modules have no physical addresses until runtime */ + if (image->reloc) + return 0; + /* for each module */ for (i = 0; i < image->num_modules; i++) { module = &image->module[i]; @@ -484,6 +531,15 @@ int elf_parse_module(struct image *image, int module_index, const char *name) } module->elf_file = name; + /* get file size */ + ret = fseek(module->fd, 0, SEEK_END); + if (ret < 0) + goto hdr_err; + module->file_size = ftell(module->fd); + ret = fseek(module->fd, 0, SEEK_SET); + if (ret < 0) + goto hdr_err; + /* read in elf header */ ret = elf_read_hdr(image, module); if (ret < 0) diff --git a/rimage/file_simple.c b/rimage/file_simple.c index dcf0d5b2..a9f22d04 100644 --- a/rimage/file_simple.c +++ b/rimage/file_simple.c @@ -204,6 +204,98 @@ static int simple_write_module(struct image *image, struct module *module) return 0; } +static int write_block_reloc(struct image *image, struct module *module) +{ + struct snd_sof_blk_hdr block; + size_t count; + void *buffer; + int ret; + + block.size = module->file_size; + block.type = SOF_BLK_DATA; + block.offset = 0; + + /* write header */ + count = fwrite(&block, sizeof(block), 1, image->out_fd); + if (count != 1) + return -errno; + + /* alloc data data */ + buffer = calloc(1, module->file_size); + if (!buffer) + return -ENOMEM; + + /* read in section data */ + ret = fseek(module->fd, 0, SEEK_SET); + if (ret < 0) { + fprintf(stderr, "error: can't seek to section %d\n", ret); + goto out; + } + count = fread(buffer, 1, module->file_size, module->fd); + if (count != module->file_size) { + fprintf(stderr, "error: can't read section %d\n", -errno); + ret = -errno; + goto out; + } + + /* write out section data */ + count = fwrite(buffer, 1, module->file_size, image->out_fd); + if (count != module->file_size) { + fprintf(stderr, "error: can't write section %d\n", -errno); + ret = -errno; + goto out; + } + + fprintf(stdout, "\t%d\t0x%8.8x\t0x%8.8x\t0x%8.8lx\t%s\n", block_idx++, + 0, module->file_size, ftell(image->out_fd), + block.type == SOF_BLK_TEXT ? "TEXT" : "DATA"); + +out: + free(buffer); + return ret; +} + +static int simple_write_module_reloc(struct image *image, struct module *module) +{ + struct snd_sof_mod_hdr hdr; + size_t count; + int i, err; + + hdr.num_blocks = 1; + hdr.size = module->text_size + module->data_size; + hdr.type = SOF_FW_BASE; // module + + 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"); + + err = write_block_reloc(image, module); + 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) { @@ -235,7 +327,10 @@ static int simple_write_firmware(struct image *image) fprintf(stdout, "writing module %d %s\n", i, module->elf_file); - ret = simple_write_module(image, module); + if (image->reloc) + ret = simple_write_module_reloc(image, module); + else + ret = simple_write_module(image, module); if (ret < 0) { fprintf(stderr, "error: failed to write module %d\n", i); diff --git a/rimage/manifest.c b/rimage/manifest.c index 87f80d7c..6bb4ad3f 100644 --- a/rimage/manifest.c +++ b/rimage/manifest.c @@ -403,7 +403,6 @@ static int man_module_create(struct image *image, struct module *module, fprintf(stdout, "\tNo\tAddress\t\tSize\t\tFile\tType\n"); - /* validate segments */ if (man_module_validate(man_module) < 0) return -EINVAL; @@ -445,6 +444,96 @@ static int man_module_create(struct image *image, struct module *module, return 0; } +static int man_module_create_reloc(struct image *image, struct module *module, + struct sof_man_module *man_module) +{ + /* create module and segments */ + int err; + unsigned int pages; + void *buffer = image->fw_image + module->foffset; + size_t count; + + 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%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); + + /* 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 = 0; + man_module->segment[SOF_MAN_SEGMENT_TEXT].flags.r.length = 0; + + /* data section */ + man_module->segment[SOF_MAN_SEGMENT_RODATA].v_base_addr = 0; + man_module->segment[SOF_MAN_SEGMENT_RODATA].file_offset = + module->foffset; + 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 = 0; + man_module->segment[SOF_MAN_SEGMENT_BSS].flags.r.length = 0; + + fprintf(stdout, "\tNo\tAddress\t\tSize\t\tFile\tType\n"); + + /* seek to beginning of file */ + err = fseek(module->fd, 0, SEEK_SET); + if (err < 0) { + fprintf(stderr, "error: can't seek to section %d\n", err); + return err; + } + + count = fread(buffer, 1, module->file_size, module->fd); + if (count != module->file_size) { + fprintf(stderr, "error: can't read section %d\n", -errno); + return -errno; + } + + fprintf(stdout, "\t%d\t0x%8.8x\t0x%8.8x\t0x%x\t%s\n", 0, + 0, module->file_size, 0, "DATA"); + + fprintf(stdout, "\n"); + image->image_end = module->foffset + module->file_size; + + /* round module end up to 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_unsigned_mod(struct image *image) { int count; @@ -555,7 +644,11 @@ static int man_write_fw(struct image *image) module->foffset = image->image_end; } - ret = man_module_create(image, module, man_module); + if (image->reloc) + ret = man_module_create_reloc(image, module, + man_module); + else + ret = man_module_create(image, module, man_module); if (ret < 0) goto err; } diff --git a/rimage/rimage.c b/rimage/rimage.c index 322820b0..cc0a6101 100644 --- a/rimage/rimage.c +++ b/rimage/rimage.c @@ -35,8 +35,10 @@ static const struct adsp *machine[] = { static void usage(char *name) { - fprintf(stdout, "%s:\t -m machine -o outfile -k [key] ELF files\n", name); + fprintf(stdout, "%s:\t -m machine -o outfile -k [key] ELF files\n", + name); fprintf(stdout, "\t -v enable verbose output\n"); + fprintf(stdout, "\t -r enable relocatable ELF files\n"); exit(0); } @@ -48,7 +50,7 @@ int main(int argc, char *argv[]) memset(&image, 0, sizeof(image)); - while ((opt = getopt(argc, argv, "ho:m:vba:sk:l:")) != -1) { + while ((opt = getopt(argc, argv, "ho:m:vba:sk:l:r")) != -1) { switch (opt) { case 'o': image.out_file = optarg; @@ -68,6 +70,9 @@ int main(int argc, char *argv[]) case 'k': image.key_name = optarg; break; + case 'r': + image.reloc = 1; + break; case 'h': usage(argv[0]); break; diff --git a/rimage/rimage.h b/rimage/rimage.h index 8b46766d..888e7e8e 100644 --- a/rimage/rimage.h +++ b/rimage/rimage.h @@ -78,6 +78,9 @@ struct module { int text_file_size; int text_fixup_size; int data_file_size; + + /* total file size */ + int file_size; }; /* @@ -92,6 +95,7 @@ struct image { const struct adsp *adsp; int abi; int verbose; + int reloc; /* ELF data is relocatable */ int num_modules; struct module module[MAX_MODULES]; uint32_t image_end;/* module end, equal to output image size */ -- 2.14.1
1 0
0 0
[Sound-open-firmware] [PATCH] ipc: page tables; Make page table API generic for use outside IPC core
by Liam Girdwood 12 Apr '18

12 Apr '18
Allow users outside of IPC to make use of compressed host page tables. Signed-off-by: Liam Girdwood <liam.r.girdwood(a)linux.intel.com> --- src/include/sof/intel-ipc.h | 1 - src/include/sof/ipc.h | 8 +++ src/ipc/handler.c | 143 +++----------------------------------------- src/ipc/ipc.c | 129 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+), 135 deletions(-) diff --git a/src/include/sof/intel-ipc.h b/src/include/sof/intel-ipc.h index f89e9b57..a59c106f 100644 --- a/src/include/sof/intel-ipc.h +++ b/src/include/sof/intel-ipc.h @@ -38,7 +38,6 @@ struct intel_ipc_data { /* DMA */ struct dma *dmac; uint8_t *page_table; - completion_t complete; /* PM */ int pm_prepare_D3; /* do we need to prepare for D3 */ diff --git a/src/include/sof/ipc.h b/src/include/sof/ipc.h index 2e1818df..06425b34 100644 --- a/src/include/sof/ipc.h +++ b/src/include/sof/ipc.h @@ -134,6 +134,14 @@ int ipc_send_short_msg(uint32_t msg); void ipc_platform_do_cmd(struct ipc *ipc); void ipc_platform_send_msg(struct ipc *ipc); +/* create a SG page table eme list from a compressed page table */ +int ipc_parse_page_descriptors(uint8_t *page_table, + struct sof_ipc_host_buffer *ring, + struct list_item *elem_list, + uint32_t direction); +int ipc_get_page_descriptors(struct dma *dmac, uint8_t *page_table, + struct sof_ipc_host_buffer *ring); + /* * IPC Component creation and destruction. */ diff --git a/src/ipc/handler.c b/src/ipc/handler.c index 6a51765b..581ce9e7 100644 --- a/src/ipc/handler.c +++ b/src/ipc/handler.c @@ -83,134 +83,6 @@ static inline struct sof_ipc_hdr *mailbox_validate(void) return hdr; } -#ifdef CONFIG_HOST_PTABLE -static void dma_complete(void *data, uint32_t type, struct dma_sg_elem *next) -{ - struct intel_ipc_data *iipc = (struct intel_ipc_data *)data; - - if (type == DMA_IRQ_TYPE_LLIST) - wait_completed(&iipc->complete); -} - -/* - * Copy the audio buffer page tables from the host to the DSP max of 4K. - */ -static int get_page_descriptors(struct intel_ipc_data *iipc, - struct sof_ipc_host_buffer *ring) -{ - struct dma_sg_config config; - struct dma_sg_elem elem; - struct dma *dma; - int chan; - int ret = 0; - - /* get DMA channel from DMAC */ - chan = dma_channel_get(iipc->dmac, 0); - if (chan < 0) { - trace_ipc_error("ePC"); - return chan; - } - dma = iipc->dmac; - - /* set up DMA configuration */ - config.direction = DMA_DIR_HMEM_TO_LMEM; - config.src_width = sizeof(uint32_t); - config.dest_width = sizeof(uint32_t); - config.cyclic = 0; - list_init(&config.elem_list); - - /* set up DMA descriptor */ - elem.dest = (uint32_t)iipc->page_table; - elem.src = ring->phy_addr; - - /* source buffer size is always PAGE_SIZE bytes */ - /* 20 bits for each page, round up to 32 */ - elem.size = (ring->pages * 5 * 16 + 31) / 32; - list_item_prepend(&elem.list, &config.elem_list); - - ret = dma_set_config(dma, chan, &config); - if (ret < 0) { - trace_ipc_error("ePs"); - goto out; - } - - /* set up callback */ - dma_set_cb(dma, chan, DMA_IRQ_TYPE_LLIST, dma_complete, iipc); - - wait_init(&iipc->complete); - - /* start the copy of page table to DSP */ - dma_start(dma, chan); - - /* wait for DMA to complete */ - iipc->complete.timeout = PLATFORM_HOST_DMA_TIMEOUT; - ret = wait_for_completion_timeout(&iipc->complete); - - /* compressed page tables now in buffer at _ipc->page_table */ -out: - dma_channel_put(dma, chan); - return ret; -} - -/* - * Parse the host page tables and create the audio DMA SG configuration - * for host audio DMA buffer. This involves creating a dma_sg_elem for each - * page table entry and adding each elem to a list in struct dma_sg_config. - */ -static int parse_page_descriptors(struct intel_ipc_data *iipc, - struct sof_ipc_host_buffer *ring, struct list_item *elem_list, - uint32_t direction) -{ - int i; - uint32_t idx; - uint32_t phy_addr; - struct dma_sg_elem *e; - - /* the ring size may be not multiple of the page size, the last - * page may be not full used. The used size should be in range - * of (ring->pages - 1, ring->pages] * PAGES. - */ - if ((ring->size <= HOST_PAGE_SIZE * (ring->pages - 1)) || - (ring->size > HOST_PAGE_SIZE * ring->pages)) { - /* error buffer size */ - trace_ipc_error("eBs"); - return -EINVAL; - } - - for (i = 0; i < ring->pages; i++) { - idx = (((i << 2) + i)) >> 1; - phy_addr = iipc->page_table[idx] | (iipc->page_table[idx + 1] << 8) - | (iipc->page_table[idx + 2] << 16); - - if (i & 0x1) - phy_addr <<= 8; - else - phy_addr <<= 12; - phy_addr &= 0xfffff000; - - /* allocate new host DMA elem and add it to our list */ - e = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*e)); - if (!e) - return -ENOMEM; - - if (direction == SOF_IPC_STREAM_PLAYBACK) - e->src = phy_addr; - else - e->dest = phy_addr; - - /* the last page may be not full used */ - if (i == (ring->pages - 1)) - e->size = ring->size - HOST_PAGE_SIZE * i; - else - e->size = HOST_PAGE_SIZE; - - list_item_append(&e->list, elem_list); - } - - return 0; -} -#endif - /* * Stream IPC Operations. */ @@ -258,7 +130,8 @@ static int ipc_stream_pcm_params(uint32_t stream) list_init(&elem_list); /* use DMA to read in compressed page table ringbuffer from host */ - err = get_page_descriptors(iipc, &pcm_params->params.buffer); + err = ipc_get_page_descriptors(iipc->dmac, iipc->page_table, + &pcm_params->params.buffer); if (err < 0) { trace_ipc_error("eAp"); goto error; @@ -268,8 +141,9 @@ static int ipc_stream_pcm_params(uint32_t stream) host = (struct sof_ipc_comp_host *)&cd->comp; ring_size = pcm_params->params.buffer.size; - err = parse_page_descriptors(iipc, &pcm_params->params.buffer, - &elem_list, host->direction); + err = ipc_parse_page_descriptors(iipc->page_table, + &pcm_params->params.buffer, + &elem_list, host->direction); if (err < 0) { trace_ipc_error("eAP"); goto error; @@ -656,7 +530,8 @@ static int ipc_dma_trace_config(uint32_t header) list_init(&elem_list); /* use DMA to read in compressed page table ringbuffer from host */ - err = get_page_descriptors(iipc, &params->buffer); + err = ipc_get_page_descriptors(iipc->dmac, iipc->page_table, + &params->buffer); if (err < 0) { trace_ipc_error("eCp"); goto error; @@ -667,8 +542,8 @@ static int ipc_dma_trace_config(uint32_t header) /* Parse host tables */ ring_size = params->buffer.size; - err = parse_page_descriptors(iipc, &params->buffer, - &elem_list, SOF_IPC_STREAM_CAPTURE); + err = ipc_parse_page_descriptors(iipc->page_table, &params->buffer, + &elem_list, SOF_IPC_STREAM_CAPTURE); if (err < 0) { trace_ipc_error("ePP"); goto error; diff --git a/src/ipc/ipc.c b/src/ipc/ipc.c index ed2cbb8e..fbb1be6c 100644 --- a/src/ipc/ipc.c +++ b/src/ipc/ipc.c @@ -39,6 +39,7 @@ #include <sof/alloc.h> #include <sof/ipc.h> #include <sof/debug.h> +#include <platform/platform.h> #include <sof/audio/component.h> #include <sof/audio/pipeline.h> #include <sof/audio/buffer.h> @@ -366,6 +367,134 @@ int ipc_comp_dai_config(struct ipc *ipc, struct sof_ipc_dai_config *config) return ret; } +#ifdef CONFIG_HOST_PTABLE +/* + * Parse the host page tables and create the audio DMA SG configuration + * for host audio DMA buffer. This involves creating a dma_sg_elem for each + * page table entry and adding each elem to a list in struct dma_sg_config. + */ +int ipc_parse_page_descriptors(uint8_t *page_table, + struct sof_ipc_host_buffer *ring, + struct list_item *elem_list, + uint32_t direction) +{ + int i; + uint32_t idx; + uint32_t phy_addr; + struct dma_sg_elem *e; + + /* the ring size may be not multiple of the page size, the last + * page may be not full used. The used size should be in range + * of (ring->pages - 1, ring->pages] * PAGES. + */ + if ((ring->size <= HOST_PAGE_SIZE * (ring->pages - 1)) || + (ring->size > HOST_PAGE_SIZE * ring->pages)) { + /* error buffer size */ + trace_ipc_error("eBs"); + return -EINVAL; + } + + for (i = 0; i < ring->pages; i++) { + idx = (((i << 2) + i)) >> 1; + phy_addr = page_table[idx] | (page_table[idx + 1] << 8) + | (page_table[idx + 2] << 16); + + if (i & 0x1) + phy_addr <<= 8; + else + phy_addr <<= 12; + phy_addr &= 0xfffff000; + + /* allocate new host DMA elem and add it to our list */ + e = rzalloc(RZONE_RUNTIME, SOF_MEM_CAPS_RAM, sizeof(*e)); + if (!e) + return -ENOMEM; + + if (direction == SOF_IPC_STREAM_PLAYBACK) + e->src = phy_addr; + else + e->dest = phy_addr; + + /* the last page may be not full used */ + if (i == (ring->pages - 1)) + e->size = ring->size - HOST_PAGE_SIZE * i; + else + e->size = HOST_PAGE_SIZE; + + list_item_append(&e->list, elem_list); + } + + return 0; +} + +static void dma_complete(void *data, uint32_t type, struct dma_sg_elem *next) +{ + completion_t *complete = data; + + if (type == DMA_IRQ_TYPE_LLIST) + wait_completed(complete); +} + +/* + * Copy the audio buffer page tables from the host to the DSP max of 4K. + */ +int ipc_get_page_descriptors(struct dma *dmac, uint8_t *page_table, + struct sof_ipc_host_buffer *ring) +{ + struct dma_sg_config config; + struct dma_sg_elem elem; + completion_t complete; + int chan; + int ret = 0; + + /* get DMA channel from DMAC */ + chan = dma_channel_get(dmac, 0); + if (chan < 0) { + trace_ipc_error("ePC"); + return chan; + } + + /* set up DMA configuration */ + config.direction = DMA_DIR_HMEM_TO_LMEM; + config.src_width = sizeof(uint32_t); + config.dest_width = sizeof(uint32_t); + config.cyclic = 0; + list_init(&config.elem_list); + + /* set up DMA descriptor */ + elem.dest = (uint32_t)page_table; + elem.src = ring->phy_addr; + + /* source buffer size is always PAGE_SIZE bytes */ + /* 20 bits for each page, round up to 32 */ + elem.size = (ring->pages * 5 * 16 + 31) / 32; + list_item_prepend(&elem.list, &config.elem_list); + + ret = dma_set_config(dmac, chan, &config); + if (ret < 0) { + trace_ipc_error("ePs"); + goto out; + } + + /* set up callback */ + dma_set_cb(dmac, chan, DMA_IRQ_TYPE_LLIST, dma_complete, &complete); + + wait_init(&complete); + + /* start the copy of page table to DSP */ + dma_start(dmac, chan); + + /* wait for DMA to complete */ + complete.timeout = PLATFORM_HOST_DMA_TIMEOUT; + ret = wait_for_completion_timeout(&complete); + + /* compressed page tables now in buffer at _ipc->page_table */ +out: + dma_channel_put(dmac, chan); + return ret; +} +#endif + int ipc_init(struct sof *sof) { int i; -- 2.14.1
2 1
0 0
[Sound-open-firmware] [PATCH] rimage: fix formatting and alignment of manifest section printf
by Liam Girdwood 12 Apr '18

12 Apr '18
Signed-off-by: Liam Girdwood <liam.r.girdwood(a)linux.intel.com> --- rimage/manifest.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/rimage/manifest.c b/rimage/manifest.c index f3f85600..87f80d7c 100644 --- a/rimage/manifest.c +++ b/rimage/manifest.c @@ -163,7 +163,7 @@ static int man_copy_sram(struct image *image, Elf32_Shdr *section, if (end > image->image_end) image->image_end = end; - fprintf(stdout, "\t%d\t0x%x\t0x%x\t0x%x\t%s\n", section_idx, + fprintf(stdout, "\t%d\t0x%x\t0x%x\t\t0x%x\t%s\n", section_idx, section->sh_addr, section->sh_size, offset, seg_type == SOF_MAN_SEGMENT_TEXT ? "TEXT" : "DATA"); @@ -349,15 +349,15 @@ static int man_module_create(struct image *image, struct module *module, 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); + 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); /* main module */ /* text section is first */ @@ -401,7 +401,7 @@ static int man_module_create(struct image *image, struct module *module, pages += 1; man_module->segment[SOF_MAN_SEGMENT_BSS].flags.r.length = pages; - fprintf(stdout, "\tNo\tAddress\t\tSize\tFile\tType\n"); + fprintf(stdout, "\tNo\tAddress\t\tSize\t\tFile\tType\n"); /* validate segments */ if (man_module_validate(man_module) < 0) -- 2.14.1
1 0
0 0
[Sound-open-firmware] [PATCH] host: string: remove xthal references.
by Liam Girdwood 12 Apr '18

12 Apr '18
xthal only needed for xtensa arch. Signed-off-by: Liam Girdwood <liam.r.girdwood(a)linux.intel.com> --- src/arch/host/include/arch/string.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/arch/host/include/arch/string.h b/src/arch/host/include/arch/string.h index 56258b34..6b2755dc 100644 --- a/src/arch/host/include/arch/string.h +++ b/src/arch/host/include/arch/string.h @@ -32,9 +32,7 @@ #ifndef __INCLUDE_ARCH_STRING_SOF__ #define __INCLUDE_ARCH_STRING_SOF__ -void *xthal_memcpy(void *dst, const void *src, size_t len); - #define arch_memcpy(dest, src, size) \ - xthal_memcpy(dest, src, size) + memcpy(dest, src, size) #endif -- 2.14.1
1 0
0 0
  • ← Newer
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • Older →

HyperKitty Powered by HyperKitty version 1.3.8.