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

  • 4 participants
  • 1568 discussions
[Sound-open-firmware] [PATCH] scripts: checkpatch: don't complain about volatile
by Xiuli Pan 13 Apr '18

13 Apr '18
From: Pan Xiuli <xiuli.pan(a)linux.intel.com> Signed-off-by: Pan Xiuli <xiuli.pan(a)linux.intel.com> --- scripts/checkpatch.pl | 7 ------- 1 file changed, 7 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 16d035e..6afecfe 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5189,13 +5189,6 @@ sub process { } } -# no volatiles please - my $asm_volatile = qr{\b(__asm__|asm)\s+(__volatile__|volatile)\b}; - if ($line =~ /\bvolatile\b/ && $line !~ /$asm_volatile/) { - WARN("VOLATILE", - "Use of volatile is usually wrong: see Documentation/process/volatile-considered-harmful.rst\n" . $herecurr); - } - # Check for user-visible strings broken across lines, which breaks the ability # to grep for the string. Make exceptions when the previous string ends in a # newline (multiple lines in one string constant) or '\t', '\r', ';', or '{' -- 2.7.4
5 5
0 0
[Sound-open-firmware] [PATCH] topology: test: generate more configurations for ApolloLake
by Pierre-Louis Bossart 13 Apr '18

13 Apr '18
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 <pierre-louis.bossart(a)linux.intel.com> --- 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 ff2d144..4a4348f 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 -- 2.14.1
2 1
0 0
[Sound-open-firmware] [PATCH] topology: rename topologies to use sof prefix
by Liam Girdwood 13 Apr '18

13 Apr '18
Use sof- prefix instead of reef- Signed-off-by: Liam Girdwood <liam.r.girdwood(a)linux.intel.com> --- 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 topology/{reef-bdw-rt286.m4 => sof-bdw-rt286.m4} | 0 topology/{reef-bdw-rt5640.m4 => sof-bdw-rt5640.m4} | 0 topology/{reef-byt-da7213.m4 => sof-byt-da7213.m4} | 0 .../{reef-byt-nocodec.m4 => sof-byt-nocodec.m4} | 0 topology/{reef-byt-rt5640.m4 => sof-byt-rt5640.m4} | 0 topology/{reef-byt-rt5645.m4 => sof-byt-rt5645.m4} | 0 topology/{reef-byt-rt5651.m4 => sof-byt-rt5651.m4} | 0 .../{reef-cht-max98090.m4 => sof-cht-max98090.m4} | 0 .../{reef-cht-nocodec.m4 => sof-cht-nocodec.m4} | 0 topology/{reef-cnl-rt274.m4 => sof-cnl-rt274.m4} | 0 topology/{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 31d266e..73e10e9 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 7e2b624..0000000 --- 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 -- 2.14.1
2 2
0 0
[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
  • ← Newer
  • 1
  • ...
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • ...
  • 157
  • Older →

HyperKitty Powered by HyperKitty version 1.3.8.