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 HDMI 25c72fcc34Sopenharmony_ciHDMI_device_num=0 26c72fcc34Sopenharmony_ci$ABAT_TEST_PATH/hdmi_audio_subdevice_number.sh 27c72fcc34Sopenharmony_ciHDMI_device_num=$? 28c72fcc34Sopenharmony_ciif [ $HDMI_device_num = 77 ]; then 29c72fcc34Sopenharmony_ci echo "Prompt: Can not get device with HDMI audio or \ 30c72fcc34Sopenharmony_cishow the wrong connection type as DP in ELD info" 31c72fcc34Sopenharmony_ci exit 1 32c72fcc34Sopenharmony_cifi 33c72fcc34Sopenharmony_ci 34c72fcc34Sopenharmony_ci#To get HDMI audio device number 35c72fcc34Sopenharmony_ciHDMI_card_number=$(aplay -l | grep "HDMI 0" | cut -b 6) 36c72fcc34Sopenharmony_ciif [ "$HDMI_card_number" = "" ]; then 37c72fcc34Sopenharmony_ci echo "Error: Can not get Display audio card." 38c72fcc34Sopenharmony_ci exit 1 39c72fcc34Sopenharmony_cifi 40c72fcc34Sopenharmony_ci 41c72fcc34Sopenharmony_ciHDMI_device="hw:$HDMI_card_number,$HDMI_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_ciif [ "$record_device_number" = "" ]; then 55c72fcc34Sopenharmony_ci echo "Can not get record device number" 56c72fcc34Sopenharmony_ci exit 1 57c72fcc34Sopenharmony_cifi 58c72fcc34Sopenharmony_ci 59c72fcc34Sopenharmony_ci#Notice: to loopback the HDMI audio output to the analog audio input 60c72fcc34Sopenharmony_cirecord_device="hw:$record_card_number,$record_device_number" 61c72fcc34Sopenharmony_citest_flag=0 62c72fcc34Sopenharmony_ci 63c72fcc34Sopenharmony_ciecho -e "\e[31m Notice: to loopback the HDMI audio output \ 64c72fcc34Sopenharmony_cito the analog audio input" 65c72fcc34Sopenharmony_ciecho -e "\e[0m" 66c72fcc34Sopenharmony_ciread -p "Press enter to continue" 67c72fcc34Sopenharmony_ci#call alsabat to do the test for each frequency in the freq_table 68c72fcc34Sopenharmony_cifor freq in $freq_table 69c72fcc34Sopenharmony_ci do 70c72fcc34Sopenharmony_ci alsabat -P $HDMI_device -C plug$record_device -c $test_channel -F $freq 71c72fcc34Sopenharmony_ci if [ $? = 0 ]; then 72c72fcc34Sopenharmony_ci echo "Test target frequency:$freq for HDMI audio playback \ 73c72fcc34Sopenharmony_ci-- Passed " >> $ABAT_TEST_LOG_FILE 74c72fcc34Sopenharmony_ci else 75c72fcc34Sopenharmony_ci echo "Test target frequency:$freq for HDMI audio playback \ 76c72fcc34Sopenharmony_ci-- Failed " >> $ABAT_TEST_LOG_FILE 77c72fcc34Sopenharmony_ci test_flag=1 78c72fcc34Sopenharmony_ci fi 79c72fcc34Sopenharmony_ci done 80c72fcc34Sopenharmony_ci 81c72fcc34Sopenharmony_ciexit $test_flag 82