1c72fcc34Sopenharmony_ci#!/bin/bash 2c72fcc34Sopenharmony_ci 3c72fcc34Sopenharmony_ci#/* 4c72fcc34Sopenharmony_ci# * Copyright (C) 2013-2016 Intel Corporation 5c72fcc34Sopenharmony_ci# * 6c72fcc34Sopenharmony_ci# * This program is free software; you can redistribute it and/or modify 7c72fcc34Sopenharmony_ci# * it under the terms of the GNU General Public License as published by 8c72fcc34Sopenharmony_ci# * the Free Software Foundation; either version 2 of the License, or 9c72fcc34Sopenharmony_ci# * (at your option) any later version. 10c72fcc34Sopenharmony_ci# * 11c72fcc34Sopenharmony_ci# * This program is distributed in the hope that it will be useful, 12c72fcc34Sopenharmony_ci# * but WITHOUT ANY WARRANTY; without even the implied warranty of 13c72fcc34Sopenharmony_ci# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14c72fcc34Sopenharmony_ci# * GNU General Public License for more details. 15c72fcc34Sopenharmony_ci# * 16c72fcc34Sopenharmony_ci# */ 17c72fcc34Sopenharmony_ci 18c72fcc34Sopenharmony_ci#set test freq table (HZ) 19c72fcc34Sopenharmony_cifreq_table="10 31 73 155 380 977 1932 4119 8197 16197" 20c72fcc34Sopenharmony_ci 21c72fcc34Sopenharmony_ci#set test number of channels 22c72fcc34Sopenharmony_citest_channel=2 23c72fcc34Sopenharmony_ci 24c72fcc34Sopenharmony_ci#get device number for DP 25c72fcc34Sopenharmony_ciDP_device_num=0 26c72fcc34Sopenharmony_ci$ABAT_TEST_PATH/dp_audio_subdevice_number.sh 27c72fcc34Sopenharmony_ciDP_device_num=$? 28c72fcc34Sopenharmony_ciif [ $DP_device_num = 77 ]; then 29c72fcc34Sopenharmony_ci echo "Prompt: Can not get device with DP audio or \ 30c72fcc34Sopenharmony_cishow the wrong connection type as HDMI in ELD info" 31c72fcc34Sopenharmony_ci exit 1 32c72fcc34Sopenharmony_cifi 33c72fcc34Sopenharmony_ci 34c72fcc34Sopenharmony_ci#To get DP audio device number 35c72fcc34Sopenharmony_ciDP_card_number=$(aplay -l | grep "HDMI 0" | cut -b 6) 36c72fcc34Sopenharmony_ciif [ "$DP_card_number" = "" ]; then 37c72fcc34Sopenharmony_ci echo "Error: Can not get Display audio card." 38c72fcc34Sopenharmony_ci exit 1 39c72fcc34Sopenharmony_cifi 40c72fcc34Sopenharmony_ci 41c72fcc34Sopenharmony_ciDP_device="hw:$DP_card_number,$DP_device_num" 42c72fcc34Sopenharmony_ciecho $device 43c72fcc34Sopenharmony_cisleep 2 44c72fcc34Sopenharmony_ci 45c72fcc34Sopenharmony_ci#get Analog audio record card number 46c72fcc34Sopenharmony_cirecord_card_number=$(arecord -l | grep "Analog" | cut -b 6) 47c72fcc34Sopenharmony_ciif [ "$record_card_number" = "" ]; then 48c72fcc34Sopenharmony_ci echo "Can not get record card number." 49c72fcc34Sopenharmony_ci exit 1 50c72fcc34Sopenharmony_cifi 51c72fcc34Sopenharmony_ci 52c72fcc34Sopenharmony_ci#get Analog audio record device number 53c72fcc34Sopenharmony_cirecord_device_number=$(arecord -l | grep "Analog"| cut -d " " -f 8 |cut -b 1) 54c72fcc34Sopenharmony_ciecho $record_device_number 55c72fcc34Sopenharmony_ciif [ "$record_device_number" = "" ]; then 56c72fcc34Sopenharmony_ci echo "Can not get record device number" 57c72fcc34Sopenharmony_ci exit 1 58c72fcc34Sopenharmony_cifi 59c72fcc34Sopenharmony_ci 60c72fcc34Sopenharmony_ci#Notice: to loopback the DP audio output to the analog audio input 61c72fcc34Sopenharmony_cirecord_device="hw:$record_card_number,$record_device_number" 62c72fcc34Sopenharmony_citest_flag=0 63c72fcc34Sopenharmony_ci 64c72fcc34Sopenharmony_ciecho -e "\e[31m Notice: to loopback the DP audio \ 65c72fcc34Sopenharmony_cioutput to the analog audio input" 66c72fcc34Sopenharmony_ciecho -e "\e[0m" 67c72fcc34Sopenharmony_ciread -p "Press enter to continue" 68c72fcc34Sopenharmony_ci 69c72fcc34Sopenharmony_ci#call alsabat to do the test for each frequency in the freq_table 70c72fcc34Sopenharmony_cifor freq in $freq_table 71c72fcc34Sopenharmony_ci do 72c72fcc34Sopenharmony_ci alsabat -P $DP_device -C plug$record_device -c $test_channel -F $freq 73c72fcc34Sopenharmony_ci if [ $? = 0 ]; then 74c72fcc34Sopenharmony_ci echo "Test target frequency:$freq for DP audio playback--Passed" \ 75c72fcc34Sopenharmony_ci>> $ABAT_TEST_LOG_FILE 76c72fcc34Sopenharmony_ci else 77c72fcc34Sopenharmony_ci echo "Test target frequency:$freq for DP audio playback--Failed" \ 78c72fcc34Sopenharmony_ci>> $ABAT_TEST_LOG_FILE 79c72fcc34Sopenharmony_ci test_flag=1 80c72fcc34Sopenharmony_ci fi 81c72fcc34Sopenharmony_ci done 82c72fcc34Sopenharmony_ci 83c72fcc34Sopenharmony_ciexit $test_flag 84