From f2bcaa6b1aad2f1690bb3a792319540fa2499892 Mon Sep 17 00:00:00 2001 From: Amery Song Date: Wed, 19 Feb 2020 14:20:17 +0800 Subject: [PATCH 1/2] tools: split both type pcm into playback and capture Previously, for pcm with both playback and capture capabilities, we only output one line, and tag its type as both. This patch outputs playback and capture pipeline info separately. Signed-off-by: Amery Song --- tools/sof-tplgreader.py | 41 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/tools/sof-tplgreader.py b/tools/sof-tplgreader.py index 7d2d7a98..3c55518a 100755 --- a/tools/sof-tplgreader.py +++ b/tools/sof-tplgreader.py @@ -23,21 +23,33 @@ def _key2str(self, cap, key): def loadFile(self, filename, sofcard=0): tplg_parser = TplgParser() parsed_tplg = tplg_parser.parse(filename) + formatter = TplgFormatter(parsed_tplg) # ignore the last element, for it is tplg name for item in parsed_tplg[:-1]: if "pcm" not in item: continue for pcm in item['pcm']: - pipeline_dict = {} - pipeline_dict['pcm'] = pcm["pcm_name"] - pipeline_dict['id'] = str(pcm["pcm_id"]) - pipeline_dict['type'] = TplgFormatter.get_pcm_type(pcm) + pcm_type = TplgFormatter.get_pcm_type(pcm) # if we find None type pcm, there must be errors in topology - if pipeline_dict['type'] == "None": + if pcm_type == "None": print("type of %s is neither playback nor capture, please check your" "topology source file" % pcm["pcm_name"]) exit(1) + pgas = formatter.find_comp_for_pcm(pcm, 'PGA') + eqs = formatter.find_comp_for_pcm(pcm, 'EQ') + pipeline_dict = {} + pipeline_dict['pcm'] = pcm["pcm_name"] + pipeline_dict['id'] = str(pcm["pcm_id"]) + pipeline_dict['type'] = TplgFormatter.get_pcm_type(pcm) cap = pcm["caps"][pcm['capture']] + pga = pgas[pcm['capture']] + if pga != []: + pga_names = [i['name'] for i in pga] + pipeline_dict['pga'] = " ".join(pga_names) + eq = eqs[pcm['capture']] + if eq != []: + eq_names = [i['name'] for i in eq] + pipeline_dict['eq'] = " ".join(eq_names) # supported formats of playback pipeline in formats[0] # supported formats of capture pipeline in formats[1] formats = TplgFormatter.get_pcm_fmt(pcm) @@ -46,6 +58,25 @@ def loadFile(self, filename, sofcard=0): pipeline_dict['fmt'] = pipeline_dict['fmts'].split(' ')[0] pipeline_dict['rate_min'], pipeline_dict['rate_max'] = self._key2str(cap, 'rate') pipeline_dict['ch_min'], pipeline_dict['ch_max'] = self._key2str(cap, 'channels') + if pcm_type == "both": + pipeline_dict["type"] = "capture" + # copy pipeline and change values + pb_pipeline_dict = pipeline_dict.copy() + pb_pipeline_dict["type"] = "playback" + cap = pcm["caps"][pcm['playback']] + pga = pgas[pcm['capture']] + if pga != []: + pga_names = [i['name'] for i in pga] + pipeline_dict['pga'] = " ".join(pga_names) + eq = eqs[pcm['capture']] + if eq != []: + eq_names = [i['name'] for i in eq] + pipeline_dict['eq'] = " ".join(eq_names) + pb_pipeline_dict["fmts"] = " ".join(formats[pcm['playback']]) + pipeline_dict['fmt'] = pipeline_dict['fmts'].split(' ')[0] + pb_pipeline_dict['rate_min'], pb_pipeline_dict['rate_max'] = self._key2str(cap, 'rate') + pb_pipeline_dict['ch_min'], pb_pipeline_dict['ch_max'] = self._key2str(cap, 'channels') + self._pipeline_lst.append(pb_pipeline_dict) self._pipeline_lst.append(pipeline_dict) # format pipeline, this change for script direct access 'rate' 'channel' 'dev' From e5a0fc5be0fd0ea47da62fe92c8155d8afc1a06b Mon Sep 17 00:00:00 2001 From: Amery Song Date: Wed, 19 Feb 2020 14:34:57 +0800 Subject: [PATCH 2/2] test-case: remove both for test cases when obtain pipelines Since we have split both type pcm into playback and capture pipelines, we don't need to specify "both" when obtain pipelines. This patch removes both for test cases when obtain pipelins with func_pipeline_export function. Signed-off-by: Amery Song --- test-case/check-capture.sh | 4 ++-- test-case/check-kmod-load-unload-after-playback.sh | 6 +++--- test-case/check-pause-resume.sh | 2 +- test-case/check-playback.sh | 4 ++-- test-case/check-runtime-pm-status.sh | 2 +- test-case/check-signal-stop-start.sh | 2 +- test-case/check-suspend-resume-with-audio.sh | 2 +- test-case/check-xrun-injection.sh | 4 ++-- test-case/multiple-pipeline-capture.sh | 10 +++++----- test-case/multiple-pipeline-playback.sh | 10 +++++----- test-case/test-speaker.sh | 2 +- test-case/volume-basic-test.sh | 4 ++-- 12 files changed, 26 insertions(+), 26 deletions(-) diff --git a/test-case/check-capture.sh b/test-case/check-capture.sh index c726cc64..27ffa900 100755 --- a/test-case/check-capture.sh +++ b/test-case/check-capture.sh @@ -9,7 +9,7 @@ ## default duration is 10s ## default loop count is 3 ## Case step: -## 1. Parse TPLG file to get pipeline with type of "record" and "both" +## 1. Parse TPLG file to get pipeline with type of "record" ## 2. Specify the audio parameters ## 3. Run arecord on each pipeline with parameters ## Expect result: @@ -55,7 +55,7 @@ file_prefix=${OPT_VALUE_lst['f']} func_lib_setup_kernel_last_line func_lib_check_sudo -func_pipeline_export $tplg "type:capture,both" +func_pipeline_export $tplg "type:capture" for round in $(seq 1 $round_cnt) do diff --git a/test-case/check-kmod-load-unload-after-playback.sh b/test-case/check-kmod-load-unload-after-playback.sh index 9855d20c..5a51e022 100755 --- a/test-case/check-kmod-load-unload-after-playback.sh +++ b/test-case/check-kmod-load-unload-after-playback.sh @@ -8,7 +8,7 @@ ## check kernel module removal/insert process with playback before and after ## Case step: ## 1. enter loop for module remove / insert test -## 2. for each pcm type == playback or both: +## 2. for each pcm type == playback: ## start playback of duration OPT_VALUE_lst['d]' ## 3. check for playback errors ## 4. remove all loaded modules listed in sof_remove.sh @@ -19,7 +19,7 @@ ## (only once, not per PCM) ## 8. check for successful sof-firmware boot ## 9. check for dmesg errors -## 10. for each pcm type == playback or both: +## 10. for each pcm type == playback: ## start playback of duration OPT_VALUE_lst['d]' ## 11. check for playback errors ## 12. loop to beginning (max OPT_VALUE_lst['l']) @@ -50,7 +50,7 @@ tplg=${OPT_VALUE_lst['t']} loop_cnt=${OPT_VALUE_lst['l']} pb_duration=${OPT_VALUE_lst['d']} -func_pipeline_export $tplg "type:playback,both" +func_pipeline_export $tplg "type:playback" func_lib_check_sudo # overwirte the subscript: test-case LOG_ROOT environment diff --git a/test-case/check-pause-resume.sh b/test-case/check-pause-resume.sh index f4c0cc19..a4572f89 100755 --- a/test-case/check-pause-resume.sh +++ b/test-case/check-pause-resume.sh @@ -70,7 +70,7 @@ esac [[ -z $file_name ]] && file_name=$dummy_file -func_pipeline_export $tplg "type:$test_mode,both" +func_pipeline_export $tplg "type:$test_mode" func_lib_setup_kernel_last_line for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1)) do diff --git a/test-case/check-playback.sh b/test-case/check-playback.sh index ac2f9e7a..a50b68ee 100755 --- a/test-case/check-playback.sh +++ b/test-case/check-playback.sh @@ -9,7 +9,7 @@ ## default duration is 10s ## default loop count is 3 ## Case step: -## 1. Parse TPLG file to get pipeline with type of "play" and "both" +## 1. Parse TPLG file to get pipeline with type of "play" ## 2. Specify the audio parameters ## 3. Run aplay on each pipeline with parameters ## Expect result: @@ -63,7 +63,7 @@ fi func_lib_setup_kernel_last_line func_lib_check_sudo -func_pipeline_export $tplg "type:playback,both" +func_pipeline_export $tplg "type:playback" for round in $(seq 1 $round_cnt) do diff --git a/test-case/check-runtime-pm-status.sh b/test-case/check-runtime-pm-status.sh index a364ae5e..a30851fa 100755 --- a/test-case/check-runtime-pm-status.sh +++ b/test-case/check-runtime-pm-status.sh @@ -52,7 +52,7 @@ runtime_status="/sys/bus/pci/devices/0000:$(lspci |awk '/[Aa]udio/ {print $1;}') dlogc "Runtime status check: cat $runtime_status" [[ ${OPT_VALUE_lst['s']} -eq 1 ]] && func_lib_start_log_collect -func_pipeline_export $tplg "type:playback,both" +func_pipeline_export $tplg "type:playback" func_lib_setup_kernel_last_line #TODO: need to go through both playback and capture for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1)) diff --git a/test-case/check-signal-stop-start.sh b/test-case/check-signal-stop-start.sh index ead558a6..a715ead9 100755 --- a/test-case/check-signal-stop-start.sh +++ b/test-case/check-signal-stop-start.sh @@ -82,7 +82,7 @@ func_stop_start_pipeline() done } -func_pipeline_export $tplg "type:$test_mode,both" +func_pipeline_export $tplg "type:$test_mode" for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1)) do channel=$(func_pipeline_parse_value $idx channel) diff --git a/test-case/check-suspend-resume-with-audio.sh b/test-case/check-suspend-resume-with-audio.sh index 8bbda2f2..10b9ee4a 100755 --- a/test-case/check-suspend-resume-with-audio.sh +++ b/test-case/check-suspend-resume-with-audio.sh @@ -71,7 +71,7 @@ else fi [[ -z $file_name ]] && file_name=$dummy_file -func_pipeline_export $tplg "type:${OPT_VALUE_lst['m']},both" +func_pipeline_export $tplg "type:${OPT_VALUE_lst['m']}" if [ "${OPT_VALUE_lst['T']}" ]; then opt="-l ${OPT_VALUE_lst['l']} -T ${OPT_VALUE_lst['T']}" diff --git a/test-case/check-xrun-injection.sh b/test-case/check-xrun-injection.sh index ddd108e5..8409c804 100755 --- a/test-case/check-xrun-injection.sh +++ b/test-case/check-xrun-injection.sh @@ -45,7 +45,7 @@ interval=${OPT_VALUE_lst['i']} func_lib_setup_kernel_last_line func_lib_check_sudo -func_pipeline_export $tplg "type:playback,capture,both" +func_pipeline_export $tplg "type:playback,capture" case $test_mode in "playback") @@ -83,7 +83,7 @@ func_xrun_injection() done } -func_pipeline_export $tplg "type:$test_mode,both" +func_pipeline_export $tplg "type:$test_mode" for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1)) do channel=$(func_pipeline_parse_value $idx channel) diff --git a/test-case/multiple-pipeline-capture.sh b/test-case/multiple-pipeline-capture.sh index efc7acf2..d730a568 100755 --- a/test-case/multiple-pipeline-capture.sh +++ b/test-case/multiple-pipeline-capture.sh @@ -8,11 +8,11 @@ ## Pick up pipelines from TPLG file for max count ## Rule: ## a. fill pipeline need match max count -## b. fill pipeline type order: capture & both > playback +## b. fill pipeline type order: capture > playback ## c. if pipeline in TPLG is not enough of count, max count is pipeline count ## Case step: ## 1. Parse TPLG file to get pipeline count to decide max count is parameter or pipeline count -## 2. load capture & both for arecord to fill pipeline count +## 2. load capture for arecord to fill pipeline count ## 3. load playback for aplay fill pipeline count ## 4. wait for 0.5s for process already loaded ## 5. check process status & process count @@ -57,8 +57,8 @@ func_lib_setup_kernel_last_line declare -A APP_LST DEV_LST APP_LST['playback']='aplay' DEV_LST['playback']='/dev/zero' -APP_LST['capture,both']='arecord' -DEV_LST['capture,both']='/dev/null' +APP_LST['capture']='arecord' +DEV_LST['capture']='/dev/null' tmp_count=$max_count @@ -107,7 +107,7 @@ do sudo dmesg -C # start capture: - func_run_pipeline_with_type "capture,both" + func_run_pipeline_with_type "capture" func_run_pipeline_with_type "playback" dlogi "pipeline start sleep 0.5s for device wakeup" diff --git a/test-case/multiple-pipeline-playback.sh b/test-case/multiple-pipeline-playback.sh index 25392305..ea564554 100755 --- a/test-case/multiple-pipeline-playback.sh +++ b/test-case/multiple-pipeline-playback.sh @@ -8,11 +8,11 @@ ## Pick up pipelines from TPLG file for max count ## Rule: ## a. fill pipeline need match max count -## b. fill pipeline type order: playback & both > capture +## b. fill pipeline type order: playback > capture ## c. if pipeline in TPLG is not enough of count, max count is pipeline count ## Case step: ## 1. Parse TPLG file to get pipeline count to decide max count is parameter or pipeline count -## 2. load playback & both for aplay to fill pipeline count +## 2. load playback for aplay to fill pipeline count ## 3. load capture for arecord to fill pipeline count ## 4. wait for 0.5s for process already loaded ## 5. check process status & process count @@ -55,8 +55,8 @@ func_lib_setup_kernel_last_line # now small function define declare -A APP_LST DEV_LST -APP_LST['playback,both']='aplay' -DEV_LST['playback,both']='/dev/zero' +APP_LST['playback']='aplay' +DEV_LST['playback']='/dev/zero' APP_LST['capture']='arecord' DEV_LST['capture']='/dev/null' @@ -107,7 +107,7 @@ do sudo dmesg -C # start capture: - func_run_pipeline_with_type "playback,both" + func_run_pipeline_with_type "playback" func_run_pipeline_with_type "capture" dlogi "pipeline start sleep 0.5s for device wakeup" diff --git a/test-case/test-speaker.sh b/test-case/test-speaker.sh index 11f43f1a..1a8abe2f 100755 --- a/test-case/test-speaker.sh +++ b/test-case/test-speaker.sh @@ -28,7 +28,7 @@ func_opt_parse_option $* tplg=${OPT_VALUE_lst['t']} [[ ${OPT_VALUE_lst['s']} -eq 1 ]] && func_lib_start_log_collect -func_pipeline_export $tplg "type:playback,both" +func_pipeline_export $tplg "type:playback" tcnt=${OPT_VALUE_lst['l']} func_lib_setup_kernel_last_line for idx in $(seq 0 $(expr $PIPELINE_COUNT - 1)) diff --git a/test-case/volume-basic-test.sh b/test-case/volume-basic-test.sh index 6deb2ae7..6ff69173 100755 --- a/test-case/volume-basic-test.sh +++ b/test-case/volume-basic-test.sh @@ -39,10 +39,10 @@ func_error_exit() } [[ -z $tplg ]] && dlogw "Missing tplg file needed to run" && exit 1 -func_pipeline_export $tplg "type:playback,both" +func_pipeline_export $tplg "type:playback" [[ ${OPT_VALUE_lst['s']} -eq 1 ]] && func_lib_start_log_collect -[[ $PIPELINE_COUNT -eq 0 ]] && dlogw "Missing playback/both pipeline needed to run the aplay" && exit 1 +[[ $PIPELINE_COUNT -eq 0 ]] && dlogw "Missing playback pipeline for aplay to run" && exit 1 channel=$(func_pipeline_parse_value 0 channel) rate=$(func_pipeline_parse_value 0 rate) fmt=$(func_pipeline_parse_value 0 fmt)