tarina

git clone https://git.tarina.org/tarina
Log | Files | Refs | README | LICENSE

analog_audio_playback_and_capture.sh (2502B)


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