tarina

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

dp_audio_subdevice_number.sh (1793B)


      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 #set -x
     18 
     19 subdevice_number=0
     20 get_subdevice=0
     21 
     22 #make sure the DP monitor is connected and active
     23 
     24 # To get DisplayPort audio device number
     25 card_number=$(aplay -l | grep "HDMI 1" | cut -b 6)
     26 echo $card_number
     27 if [ "$card_number" = "" ]; then
     28 	echo "Can not get Display audio card."
     29 	exit 254
     30 fi
     31 
     32 audio_card_dir="/proc/asound/card$card_number/"
     33 
     34 cd $audio_card_dir
     35 
     36 for file in `ls`
     37 do
     38 	#To get the ELD info according to the connented monitor with DisplayPort.
     39 	if [[ $file == eld* ]]; then
     40 		let subdevice_number+=1
     41 		cat $file | grep connection_type | grep DisplayPort > /dev/null
     42 		if [ $? = 0 ]; then
     43 			echo "Get the ELD information according to the connented \
     44 monitor with DisplayPort."
     45 			get_subdevice=1
     46 			break
     47 		fi
     48 	fi
     49 done
     50 
     51 #failed to get the subdevice number of DisplayPort audio
     52 if [ $get_subdevice == 0 ]; then
     53         exit 77
     54 fi
     55 
     56 #the subdevice number of DisplayPort audio is 3
     57 if [ $subdevice_number == 1 ]; then
     58 	exit 3
     59 #the subdevice number of DisplayPort audio is 7.
     60 elif [ $subdevice_number == 2 ]; then
     61 	exit 7
     62 #the subdevice number of DisplayPort audio is 8
     63 elif [ $subdevice_number == 3 ]; then
     64 	exit 8
     65 #default: failed to get the subdevice number of DisplayPort audio
     66 else
     67 	exit 77
     68 fi